Started to implement syscall.rs

This commit is contained in:
Rémi Rativel 2023-03-29 17:16:08 +02:00
parent e117ec2132
commit 8e81358e51
5 changed files with 38 additions and 2 deletions

7
Cargo.lock generated
View File

@ -6,9 +6,16 @@ version = 3
name = "burritos" name = "burritos"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"cc",
"libc", "libc",
] ]
[[package]]
name = "cc"
version = "1.0.79"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f"
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.140" version = "0.2.140"

View File

@ -7,4 +7,7 @@ edition = "2021"
libc = { version = "0.2.139", features = ["extra_traits"] } libc = { version = "0.2.139", features = ["extra_traits"] }
[registries.crates-io] [registries.crates-io]
protocol = "sparse" protocol = "sparse"
[build-dependencies]
cc = "1.0"

5
build.rs Normal file
View File

@ -0,0 +1,5 @@
fn main() {
cc::Build::new()
.file("test/userlib/sys.s")
.compile("my-asm-lib");
}

View File

@ -65,7 +65,7 @@ __start:
.globl Halt .globl Halt
.type __Halt, @function .type __Halt, @function
Halt: Shutdown:
addi a7,zero,SC_HALT addi a7,zero,SC_HALT
ecall ecall
jr ra jr ra

21
test/userlib/syscall.rs Normal file
View File

@ -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) -> ();
}