| ... | ... | @@ -9,16 +9,23 @@ pub const MBOX_TERMINAL = 1; |
| 9 | 9 | //// Syscall numbers //// |
| 10 | 10 | /////////////////////////// |
| 11 | 11 | |
| 12 | | pub const SYS_createMailbox = 0; |
| 13 | | pub const SYS_send = 1; |
| 14 | | pub const SYS_receive = 2; |
| 15 | | pub const SYS_map = 3; |
| 12 | pub const SYS_exit = 0; |
| 13 | pub const SYS_createMailbox = 1; |
| 14 | pub const SYS_send = 2; |
| 15 | pub const SYS_receive = 3; |
| 16 | pub const SYS_map = 4; |
| 17 | pub const SYS_createThread = 5; |
| 16 | 18 | |
| 17 | 19 | |
| 18 | 20 | //////////////////// |
| 19 | 21 | //// Syscalls //// |
| 20 | 22 | //////////////////// |
| 21 | 23 | |
| 24 | pub fn exit(status: i32) -> noreturn { |
| 25 | _ = syscall1(SYS_exit, @bitCast(usize, isize(status))); |
| 26 | unreachable; |
| 27 | } |
| 28 | |
| 22 | 29 | pub fn createMailbox(id: u16) { |
| 23 | 30 | _ = syscall1(SYS_createMailbox, id); |
| 24 | 31 | } |
| ... | ... | @@ -35,6 +42,10 @@ pub fn map(v_addr: usize, p_addr: usize, size: usize, writable: bool) -> bool { |
| 35 | 42 | return syscall4(SYS_map, v_addr, p_addr, size, usize(writable)) != 0; |
| 36 | 43 | } |
| 37 | 44 | |
| 45 | pub fn createThread(function: fn()) -> u16 { |
| 46 | return u16(syscall1(SYS_createThread, @ptrToInt(function))); |
| 47 | } |
| 48 | |
| 38 | 49 | |
| 39 | 50 | ///////////////////////// |
| 40 | 51 | //// Syscall stubs //// |