update user module to 2021autumn version
This commit is contained in:
parent
92d9170fca
commit
b03d06c330
29 changed files with 964 additions and 78 deletions
|
@ -29,6 +29,8 @@ OBJCOPY := rust-objcopy --binary-architecture=riscv64
|
|||
# Disassembly
|
||||
DISASM ?= -x
|
||||
|
||||
TEST ?= 0
|
||||
|
||||
build: env switch-check $(KERNEL_BIN)
|
||||
|
||||
switch-check:
|
||||
|
@ -48,7 +50,7 @@ $(KERNEL_BIN): kernel
|
|||
@$(OBJCOPY) $(KERNEL_ELF) --strip-all -O binary $@
|
||||
|
||||
kernel:
|
||||
@cd ../user && make build
|
||||
@cd ../user && make build TEST=$(TEST)
|
||||
@echo Platform: $(BOARD)
|
||||
@cp src/linker-$(BOARD).ld src/linker.ld
|
||||
@cargo build --release --features "board_$(BOARD)"
|
||||
|
|
24
os/build.rs
24
os/build.rs
|
@ -1,5 +1,5 @@
|
|||
use std::fs::{read_dir, File};
|
||||
use std::io::{Result, Write};
|
||||
use std::fs::{File, read_dir};
|
||||
|
||||
fn main() {
|
||||
println!("cargo:rerun-if-changed=../user/src/");
|
||||
|
@ -7,11 +7,11 @@ fn main() {
|
|||
insert_app_data().unwrap();
|
||||
}
|
||||
|
||||
static TARGET_PATH: &str = "../user/target/riscv64gc-unknown-none-elf/release/";
|
||||
static TARGET_PATH: &str = "../user/build/bin/";
|
||||
|
||||
fn insert_app_data() -> Result<()> {
|
||||
let mut f = File::create("src/link_app.S").unwrap();
|
||||
let mut apps: Vec<_> = read_dir("../user/src/bin")
|
||||
let mut apps: Vec<_> = read_dir("../user/build/bin/")
|
||||
.unwrap()
|
||||
.into_iter()
|
||||
.map(|dir_entry| {
|
||||
|
@ -22,12 +22,16 @@ fn insert_app_data() -> Result<()> {
|
|||
.collect();
|
||||
apps.sort();
|
||||
|
||||
writeln!(f, r#"
|
||||
writeln!(
|
||||
f,
|
||||
r#"
|
||||
.align 3
|
||||
.section .data
|
||||
.global _num_app
|
||||
_num_app:
|
||||
.quad {}"#, apps.len())?;
|
||||
.quad {}"#,
|
||||
apps.len()
|
||||
)?;
|
||||
|
||||
for i in 0..apps.len() {
|
||||
writeln!(f, r#" .quad app_{}_start"#, i)?;
|
||||
|
@ -36,13 +40,17 @@ _num_app:
|
|||
|
||||
for (idx, app) in apps.iter().enumerate() {
|
||||
println!("app_{}: {}", idx, app);
|
||||
writeln!(f, r#"
|
||||
writeln!(
|
||||
f,
|
||||
r#"
|
||||
.section .data
|
||||
.global app_{0}_start
|
||||
.global app_{0}_end
|
||||
app_{0}_start:
|
||||
.incbin "{2}{1}.bin"
|
||||
app_{0}_end:"#, idx, app, TARGET_PATH)?;
|
||||
app_{0}_end:"#,
|
||||
idx, app, TARGET_PATH
|
||||
)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
pub const USER_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 = 8;
|
||||
pub const APP_BASE_ADDRESS: usize = 0x80400000;
|
||||
pub const APP_SIZE_LIMIT: usize = 0x20000;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue