From 8e81358e51c5685773b041b450fba7f02c58d8ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Rativel?= Date: Wed, 29 Mar 2023 17:16:08 +0200 Subject: [PATCH] Started to implement syscall.rs --- Cargo.lock | 7 +++++++ Cargo.toml | 5 ++++- build.rs | 5 +++++ test/userlib/sys.s | 2 +- test/userlib/syscall.rs | 21 +++++++++++++++++++++ 5 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 build.rs create mode 100644 test/userlib/syscall.rs diff --git a/Cargo.lock b/Cargo.lock index 9bb9ed5..30384b1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6,9 +6,16 @@ version = 3 name = "burritos" version = "0.1.0" dependencies = [ + "cc", "libc", ] +[[package]] +name = "cc" +version = "1.0.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" + [[package]] name = "libc" version = "0.2.140" diff --git a/Cargo.toml b/Cargo.toml index 95cb216..911c397 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,4 +7,7 @@ edition = "2021" libc = { version = "0.2.139", features = ["extra_traits"] } [registries.crates-io] -protocol = "sparse" \ No newline at end of file +protocol = "sparse" + +[build-dependencies] +cc = "1.0" \ No newline at end of file diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..7b5ec8a --- /dev/null +++ b/build.rs @@ -0,0 +1,5 @@ +fn main() { + cc::Build::new() + .file("test/userlib/sys.s") + .compile("my-asm-lib"); +} \ No newline at end of file diff --git a/test/userlib/sys.s b/test/userlib/sys.s index 64c3069..970117b 100644 --- a/test/userlib/sys.s +++ b/test/userlib/sys.s @@ -65,7 +65,7 @@ __start: .globl Halt .type __Halt, @function -Halt: +Shutdown: addi a7,zero,SC_HALT ecall jr ra diff --git a/test/userlib/syscall.rs b/test/userlib/syscall.rs new file mode 100644 index 0000000..4350f5a --- /dev/null +++ b/test/userlib/syscall.rs @@ -0,0 +1,21 @@ +pub struct Burritos_Time { + seconds: i64, + nanos: i64 +} +pub struct ThreadId{ + id: u64 +} +pub struct t_error{ + t: i32 +} +extern "C"{ + fn Shutdown() -> (); + fn SysTime(t: Burritos_Time) -> (); + fn Exit(status: i32) -> (); + fn Exec(name: String) -> ThreadId; + fn newThread(debug_name: String, func: i32, arg: i32) -> ThreadId; + fn Join (id: ThreadId) -> t_error; + fn Yield() -> (); + fn Perror(mess: String) -> (); + +} \ No newline at end of file