mirror of
https://github.com/rcore-os/rCore-Tutorial-v3.git
synced 2024-11-25 10:56:25 +04:00
Bump rustsbi to 0.1.1 && make config of qemu/k210 different
This commit is contained in:
parent
cf11c789d1
commit
e73735e5e4
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,6 +1,8 @@
|
|||||||
.idea/*
|
.idea/*
|
||||||
os/target/*
|
os/target/*
|
||||||
os/.idea/*
|
os/.idea/*
|
||||||
|
os/Cargo.lock
|
||||||
os/src/link_app.S
|
os/src/link_app.S
|
||||||
user/target/*
|
user/target/*
|
||||||
user/.idea/*
|
user/.idea/*
|
||||||
|
user/Cargo.lock
|
||||||
|
Binary file not shown.
Binary file not shown.
132
os/Cargo.lock
generated
132
os/Cargo.lock
generated
@ -1,132 +0,0 @@
|
|||||||
# This file is automatically @generated by Cargo.
|
|
||||||
# It is not intended for manual editing.
|
|
||||||
[[package]]
|
|
||||||
name = "aho-corasick"
|
|
||||||
version = "0.7.15"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "7404febffaa47dac81aa44dba71523c9d069b1bdc50a77db41195149e17f68e5"
|
|
||||||
dependencies = [
|
|
||||||
"memchr",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "bare-metal"
|
|
||||||
version = "0.2.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "5deb64efa5bd81e31fcd1938615a6d98c82eafcbcd787162b6f63b91d6bac5b3"
|
|
||||||
dependencies = [
|
|
||||||
"rustc_version",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "bit_field"
|
|
||||||
version = "0.10.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "dcb6dd1c2376d2e096796e234a70e17e94cc2d5d54ff8ce42b28cef1d0d359a4"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "bitflags"
|
|
||||||
version = "1.2.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "lazy_static"
|
|
||||||
version = "1.4.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
|
||||||
dependencies = [
|
|
||||||
"spin",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "memchr"
|
|
||||||
version = "2.3.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "os"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"lazy_static",
|
|
||||||
"riscv",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "regex"
|
|
||||||
version = "1.4.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "38cf2c13ed4745de91a5eb834e11c00bcc3709e773173b2ce4c56c9fbde04b9c"
|
|
||||||
dependencies = [
|
|
||||||
"aho-corasick",
|
|
||||||
"memchr",
|
|
||||||
"regex-syntax",
|
|
||||||
"thread_local",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "regex-syntax"
|
|
||||||
version = "0.6.21"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "3b181ba2dcf07aaccad5448e8ead58db5b742cf85dfe035e2227f137a539a189"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "riscv"
|
|
||||||
version = "0.6.0"
|
|
||||||
source = "git+https://github.com/rcore-os/riscv#21e32ee1dc786cc0d5006ceee0040ce4f8398575"
|
|
||||||
dependencies = [
|
|
||||||
"bare-metal",
|
|
||||||
"bit_field",
|
|
||||||
"bitflags",
|
|
||||||
"riscv-target",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "riscv-target"
|
|
||||||
version = "0.1.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "88aa938cda42a0cf62a20cfe8d139ff1af20c2e681212b5b34adb5a58333f222"
|
|
||||||
dependencies = [
|
|
||||||
"lazy_static",
|
|
||||||
"regex",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rustc_version"
|
|
||||||
version = "0.2.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
|
|
||||||
dependencies = [
|
|
||||||
"semver",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "semver"
|
|
||||||
version = "0.9.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
|
|
||||||
dependencies = [
|
|
||||||
"semver-parser",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "semver-parser"
|
|
||||||
version = "0.7.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "spin"
|
|
||||||
version = "0.5.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "thread_local"
|
|
||||||
version = "1.0.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14"
|
|
||||||
dependencies = [
|
|
||||||
"lazy_static",
|
|
||||||
]
|
|
14
os/Makefile
14
os/Makefile
@ -3,13 +3,20 @@ TARGET := riscv64gc-unknown-none-elf
|
|||||||
MODE := release
|
MODE := release
|
||||||
KERNEL_ELF := target/$(TARGET)/$(MODE)/os
|
KERNEL_ELF := target/$(TARGET)/$(MODE)/os
|
||||||
KERNEL_BIN := $(KERNEL_ELF).bin
|
KERNEL_BIN := $(KERNEL_ELF).bin
|
||||||
KERNEL_ENTRY_PA := 0x80020000
|
|
||||||
DISASM_TMP := target/$(TARGET)/$(MODE)/asm
|
DISASM_TMP := target/$(TARGET)/$(MODE)/asm
|
||||||
|
|
||||||
# BOARD
|
# BOARD
|
||||||
BOARD ?= qemu
|
BOARD ?= qemu
|
||||||
SBI ?= rustsbi
|
SBI ?= rustsbi
|
||||||
BOOTLOADER := ../bootloader/$(SBI)-$(BOARD).bin
|
BOOTLOADER := ../bootloader/$(SBI)-$(BOARD).bin
|
||||||
|
K210_BOOTLOADER_SIZE := 131072
|
||||||
|
|
||||||
|
# KERNEL ENTRY
|
||||||
|
ifeq ($(BOARD), qemu)
|
||||||
|
KERNEL_ENTRY_PA := 0x80200000
|
||||||
|
else ifeq ($(BOARD), k210)
|
||||||
|
KERNEL_ENTRY_PA := 0x80020000
|
||||||
|
endif
|
||||||
|
|
||||||
# Run K210
|
# Run K210
|
||||||
K210-SERIALPORT = /dev/ttyUSB0
|
K210-SERIALPORT = /dev/ttyUSB0
|
||||||
@ -35,7 +42,10 @@ $(KERNEL_BIN): kernel
|
|||||||
|
|
||||||
kernel:
|
kernel:
|
||||||
@cd ../user && make build
|
@cd ../user && make build
|
||||||
|
@echo Platform: $(BOARD)
|
||||||
|
@cp src/linker-$(BOARD).ld src/linker.ld
|
||||||
@cargo build --release
|
@cargo build --release
|
||||||
|
@rm src/linker.ld
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@cargo clean
|
@cargo clean
|
||||||
@ -59,7 +69,7 @@ ifeq ($(BOARD),qemu)
|
|||||||
-device loader,file=$(KERNEL_BIN),addr=$(KERNEL_ENTRY_PA)
|
-device loader,file=$(KERNEL_BIN),addr=$(KERNEL_ENTRY_PA)
|
||||||
else
|
else
|
||||||
@cp $(BOOTLOADER) $(BOOTLOADER).copy
|
@cp $(BOOTLOADER) $(BOOTLOADER).copy
|
||||||
@dd if=$(KERNEL_BIN) of=$(BOOTLOADER).copy bs=128K seek=1
|
@dd if=$(KERNEL_BIN) of=$(BOOTLOADER).copy bs=$(K210_BOOTLOADER_SIZE) seek=1
|
||||||
@mv $(BOOTLOADER).copy $(KERNEL_BIN)
|
@mv $(BOOTLOADER).copy $(KERNEL_BIN)
|
||||||
@sudo chmod 777 $(K210-SERIALPORT)
|
@sudo chmod 777 $(K210-SERIALPORT)
|
||||||
python3 $(K210-BURNER) -p $(K210-SERIALPORT) -b 1500000 $(KERNEL_BIN)
|
python3 $(K210-BURNER) -p $(K210-SERIALPORT) -b 1500000 $(KERNEL_BIN)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
pub const USER_STACK_SIZE: usize = 4096 * 2;
|
pub const USER_STACK_SIZE: usize = 4096 * 2;
|
||||||
pub const KERNEL_STACK_SIZE: usize = 4096 * 2;
|
pub const KERNEL_STACK_SIZE: usize = 4096 * 2;
|
||||||
pub const MAX_APP_NUM: usize = 4;
|
pub const MAX_APP_NUM: usize = 4;
|
||||||
pub const APP_BASE_ADDRESS: usize = 0x80100000;
|
pub const APP_BASE_ADDRESS: usize = 0x80400000;
|
||||||
pub const APP_SIZE_LIMIT: usize = 0x20000;
|
pub const APP_SIZE_LIMIT: usize = 0x20000;
|
45
os/src/linker-qemu.ld
Normal file
45
os/src/linker-qemu.ld
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
OUTPUT_ARCH(riscv)
|
||||||
|
ENTRY(_start)
|
||||||
|
BASE_ADDRESS = 0x80200000;
|
||||||
|
|
||||||
|
SECTIONS
|
||||||
|
{
|
||||||
|
. = BASE_ADDRESS;
|
||||||
|
skernel = .;
|
||||||
|
|
||||||
|
stext = .;
|
||||||
|
.text : {
|
||||||
|
*(.text.entry)
|
||||||
|
*(.text .text.*)
|
||||||
|
}
|
||||||
|
|
||||||
|
. = ALIGN(4K);
|
||||||
|
etext = .;
|
||||||
|
srodata = .;
|
||||||
|
.rodata : {
|
||||||
|
*(.rodata .rodata.*)
|
||||||
|
}
|
||||||
|
|
||||||
|
. = ALIGN(4K);
|
||||||
|
erodata = .;
|
||||||
|
sdata = .;
|
||||||
|
.data : {
|
||||||
|
*(.data .data.*)
|
||||||
|
}
|
||||||
|
|
||||||
|
. = ALIGN(4K);
|
||||||
|
edata = .;
|
||||||
|
.bss : {
|
||||||
|
*(.bss.stack)
|
||||||
|
sbss = .;
|
||||||
|
*(.bss .bss.*)
|
||||||
|
}
|
||||||
|
|
||||||
|
. = ALIGN(4K);
|
||||||
|
ebss = .;
|
||||||
|
ekernel = .;
|
||||||
|
|
||||||
|
/DISCARD/ : {
|
||||||
|
*(.eh_frame)
|
||||||
|
}
|
||||||
|
}
|
5
user/Cargo.lock
generated
5
user/Cargo.lock
generated
@ -1,5 +0,0 @@
|
|||||||
# This file is automatically @generated by Cargo.
|
|
||||||
# It is not intended for manual editing.
|
|
||||||
[[package]]
|
|
||||||
name = "user_lib"
|
|
||||||
version = "0.1.0"
|
|
@ -1,6 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
base_address = 0x80100000
|
base_address = 0x80400000
|
||||||
step = 0x20000
|
step = 0x20000
|
||||||
linker = 'src/linker.ld'
|
linker = 'src/linker.ld'
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
OUTPUT_ARCH(riscv)
|
OUTPUT_ARCH(riscv)
|
||||||
ENTRY(_start)
|
ENTRY(_start)
|
||||||
|
|
||||||
BASE_ADDRESS = 0x80100000;
|
BASE_ADDRESS = 0x80400000;
|
||||||
|
|
||||||
SECTIONS
|
SECTIONS
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user