Merge branch 'ch8' of github.com:rcore-os/rCore-Tutorial-v3 into ch8

This commit is contained in:
Yu Chen 2022-04-24 13:00:00 +08:00
commit 02a3880e34
7 changed files with 48 additions and 4 deletions

1
.gitignore vendored
View File

@ -5,6 +5,7 @@ os/src/link_app.S
os/src/linker.ld
os/last-*
os/Cargo.lock
os/.gdb_history
user/target/*
user/.idea/*
user/Cargo.lock

View File

@ -9,3 +9,6 @@ edition = "2018"
[dependencies]
spin = "0.7.0"
lazy_static = { version = "1.4.0", features = ["spin_no_std"] }
[profile.release]
debug = true

View File

@ -21,3 +21,6 @@ easy-fs = { path = "../easy-fs" }
[features]
board_qemu = []
board_k210 = []
[profile.release]
debug = true

View File

@ -14,6 +14,11 @@ SBI ?= rustsbi
BOOTLOADER := ../bootloader/$(SBI)-$(BOARD).bin
K210_BOOTLOADER_SIZE := 131072
# Building mode argument
ifeq ($(MODE), release)
MODE_ARG := --release
endif
# KERNEL ENTRY
ifeq ($(BOARD), qemu)
KERNEL_ENTRY_PA := 0x80200000
@ -106,4 +111,11 @@ debug: build
tmux split-window -h "riscv64-unknown-elf-gdb -ex 'file $(KERNEL_ELF)' -ex 'set arch riscv:rv64' -ex 'target remote localhost:1234'" && \
tmux -2 attach-session -d
.PHONY: build env kernel clean disasm disasm-vim run-inner switch-check fs-img
gdbserver: build
@qemu-system-riscv64 -machine virt -nographic -bios $(BOOTLOADER) -device loader,file=$(KERNEL_BIN),addr=$(KERNEL_ENTRY_PA) -s -S
gdbclient:
@riscv64-unknown-elf-gdb -ex 'file $(KERNEL_ELF)' -ex 'set arch riscv:rv64' -ex 'target remote localhost:1234'
.PHONY: build env kernel clean disasm disasm-vim run-inner switch-check fs-img gdbserver gdbclient

View File

@ -1 +1 @@
nightly-2022-01-19
nightly-2022-04-11

View File

@ -10,3 +10,6 @@ edition = "2018"
buddy_system_allocator = "0.6"
bitflags = "1.2.1"
riscv = { git = "https://github.com/rcore-os/riscv", features = ["inline-asm"] }
[profile.release]
debug = true

View File

@ -0,0 +1,22 @@
#![no_std]
#![no_main]
#[macro_use]
extern crate user_lib;
extern crate alloc;
use user_lib::{thread_create, exit};
use alloc::vec::Vec;
pub fn thread_a() -> ! {
for i in 0..1000 { print!("{}", i); }
exit(1)
}
#[no_mangle]
pub fn main() -> i32 {
thread_create(thread_a as usize, 0);
println!("main thread exited.");
exit(0)
}