diff --git a/apps/libc/Makefile b/apps/libc/Makefile index 09a3fb02..69a84be4 100644 --- a/apps/libc/Makefile +++ b/apps/libc/Makefile @@ -12,14 +12,14 @@ ifeq ($(TARGET),musl) CFLAGS := -static -no-pie ifeq ($(ARCH),x86_64) RUST_TARGET := x86_64-unknown-linux-musl - RUSTFLAGS := "" + RUSTFLAGS := else ifeq ($(ARCH),aarch64) RUST_TARGET := aarch64-unknown-linux-musl - RUSTFLAGS := "-C linker=aarch64-linux-musl-ld" + RUSTFLAGS := -C linker=aarch64-linux-musl-ld else ifeq ($(ARCH),riscv64) $(warning "Warn: Rust musl target not supported for riscv64") RUST_TARGET := "" - RUSTFLAGS := "" + RUSTFLAGS := else $(error "Unknown ARCH") endif @@ -38,6 +38,9 @@ else $(error "Unknown TARGET") endif +$(info RUSTFLAGS: "$(RUSTFLAGS)") +export RUSTFLAGS + all: build build: build_dir build_c build_rust @@ -58,7 +61,6 @@ build_rust: for app in $(shell find rust -name Cargo.toml); do \ echo "Building $$(dirname $${app})"; \ app_name=$$(basename $$(dirname $${app})); \ - export RUSTFLAGS=$(RUSTFLAGS); \ cargo build --release --target $(RUST_TARGET) --manifest-path $${app} ; \ cp $$(dirname $${app})/target/$(RUST_TARGET)/release/$${app_name} build/$(ARCH)/$${app_name}_rust ; \ done \ diff --git a/apps/nimbos/c/CMakeLists.txt b/apps/nimbos/c/CMakeLists.txt index 0557bd27..5725cb28 100644 --- a/apps/nimbos/c/CMakeLists.txt +++ b/apps/nimbos/c/CMakeLists.txt @@ -61,18 +61,24 @@ foreach(PATH ${SRCS}) endforeach() # If arch is not x86_64, we need to use different syscall ids -if (NOT ${ARCH} STREQUAL x86_64) - add_custom_command( - OUTPUT syscall_ids.h - COMMAND sed ARGS -n -e s/__NR_/SYS_/p - < ${CMAKE_SOURCE_DIR}/lib/syscall_ids.h.no_x86.in - > ${CMAKE_SOURCE_DIR}/lib/syscall_ids.h - ) -else() - add_custom_command( - OUTPUT syscall_ids.h - COMMAND sed ARGS -n -e s/__NR_/SYS_/p - < ${CMAKE_SOURCE_DIR}/lib/syscall_ids.h.in - > ${CMAKE_SOURCE_DIR}/lib/syscall_ids.h - ) -endif() \ No newline at end of file +# if (NOT ${ARCH} STREQUAL x86_64) +# add_custom_command( +# OUTPUT syscall_ids.h +# COMMAND sed ARGS -n -e s/__NR_/SYS_/p +# < ${CMAKE_SOURCE_DIR}/lib/syscall_ids.h.no_x86.in +# > ${CMAKE_SOURCE_DIR}/lib/syscall_ids.h +# ) +# else() +# add_custom_command( +# OUTPUT syscall_ids.h +# COMMAND sed ARGS -n -e s/__NR_/SYS_/p +# < ${CMAKE_SOURCE_DIR}/lib/syscall_ids.h.in +# > ${CMAKE_SOURCE_DIR}/lib/syscall_ids.h +# ) +# endif() +add_custom_command( + OUTPUT syscall_ids.h + COMMAND sed ARGS -n -e s/__NR_/SYS_/p + < ${CMAKE_SOURCE_DIR}/lib/arch/${ARCH}/syscall_ids.h.in + > ${CMAKE_SOURCE_DIR}/lib/syscall_ids.h +) \ No newline at end of file diff --git a/apps/nimbos/c/lib/syscall_ids.h.no_x86.in b/apps/nimbos/c/lib/arch/aarch64/syscall_ids.h.in similarity index 100% rename from apps/nimbos/c/lib/syscall_ids.h.no_x86.in rename to apps/nimbos/c/lib/arch/aarch64/syscall_ids.h.in diff --git a/apps/nimbos/c/lib/arch/riscv/syscall_ids.h.in b/apps/nimbos/c/lib/arch/riscv/syscall_ids.h.in new file mode 100644 index 00000000..e1c9c7c5 --- /dev/null +++ b/apps/nimbos/c/lib/arch/riscv/syscall_ids.h.in @@ -0,0 +1,11 @@ +#define __NR_read 63 +#define __NR_write 64 +#define __NR_exit 93 +#define __NR_yield 124 +#define __NR_getpid 172 +#define __NR_clone 220 +#define __NR_fork 220 +#define __NR_exec 221 +#define __NR_waitpid 260 +#define __NR_clock_gettime 403 +#define __NR_clock_nanosleep 407 diff --git a/apps/nimbos/c/lib/arch/x86_64/syscall_ids.h.in b/apps/nimbos/c/lib/arch/x86_64/syscall_ids.h.in new file mode 100644 index 00000000..9aeecc9f --- /dev/null +++ b/apps/nimbos/c/lib/arch/x86_64/syscall_ids.h.in @@ -0,0 +1,11 @@ +#define __NR_read 0 +#define __NR_write 1 +#define __NR_yield 24 +#define __NR_getpid 39 +#define __NR_clone 56 +#define __NR_fork 57 +#define __NR_exec 59 +#define __NR_exit 60 +#define __NR_waitpid 61 +#define __NR_clock_gettime 228 +#define __NR_clock_nanosleep 230 diff --git a/apps/nimbos/c/lib/syscall_ids.h.in b/apps/nimbos/c/lib/syscall_ids.h.in deleted file mode 100644 index 4631dbcf..00000000 --- a/apps/nimbos/c/lib/syscall_ids.h.in +++ /dev/null @@ -1,11 +0,0 @@ -#define __NR_read 0 -#define __NR_write 1 -#define __NR_yield 24 -#define __NR_getpid 39 -#define __NR_clone 56 -#define __NR_fork 57 -#define __NR_exec 59 -#define __NR_exit 60 -#define __NR_waitpid 61 -#define __NR_clock_gettime 228 -#define __NR_clock_nanosleep 230 diff --git a/build.rs b/build.rs index 82c88a9f..c83f3f69 100644 --- a/build.rs +++ b/build.rs @@ -100,24 +100,13 @@ fn gen_kernel_config(arch: &str) -> Result<()> { writeln!(f, "{}", comments)?; if let Item::Value(value) = item { let key_name = key.to_uppercase().replace('-', "_"); + writeln!(f, "#[allow(dead_code)]")?; match value { toml_edit::Value::Integer(i) => { - writeln!( - f, - " - #[allow(dead_code)]\n - pub const {}: usize = {};", - key_name, i - )?; + writeln!(f, "pub const {}: usize = {};", key_name, i)?; } toml_edit::Value::String(s) => { - writeln!( - f, - " - #[allow(dead_code)]\n - pub const {}: &str = \"{}\";", - key_name, s - )?; + writeln!(f, "pub const {}: &str = \"{}\";", key_name, s)?; } _ => { panic!("Unsupported value type"); diff --git a/src/main.rs b/src/main.rs index eab9cc46..35f18bd1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -26,7 +26,7 @@ fn main() { .split(',') .filter(|&x| !x.is_empty()); for testcase in testcases { - log::info!("Running testcase: {}", testcase); + info!("Running testcase: {}", testcase); let (entry_vaddr, ustack_top, uspace) = mm::load_user_app(testcase).unwrap(); let user_task = task::spawn_user_task( Arc::new(Mutex::new(uspace)),