twizzler_abi/syscall/
mod.rs1mod console;
5mod create;
6mod handle;
7mod info;
8mod kaction;
9mod map;
10mod object_control;
11mod object_stat;
12mod random;
13mod security;
14mod spawn;
15mod thread_control;
16mod thread_sync;
17mod time;
18
19use crate::arch::syscall::raw_syscall;
20#[derive(Copy, Clone, Debug)]
21#[repr(C)]
22pub enum Syscall {
24 Null,
25 KernelConsoleRead,
27 KernelConsoleWrite,
29 ThreadSync,
31 ThreadCtrl,
33 ObjectCreate,
35 ObjectMap,
37 SysInfo,
39 Spawn,
41 ReadClockInfo,
43 ReadClockList,
45 Kaction,
47 NewHandle,
49 ObjectUnmap,
51 ObjectCtrl,
53 ObjectStat,
55 ObjectReadMap,
57 UnbindHandle,
59 SctxAttach,
61 GetRandom,
63 NumSyscalls,
64}
65
66impl Syscall {
67 pub fn num(&self) -> u64 {
69 *self as u64
70 }
71}
72
73impl From<usize> for Syscall {
74 fn from(x: usize) -> Self {
75 if x >= Syscall::NumSyscalls as usize {
76 return Syscall::Null;
77 }
78 unsafe { core::intrinsics::transmute(x as u32) }
79 }
80}
81
82pub use console::*;
83pub use create::*;
84pub use handle::*;
85pub use info::*;
86pub use kaction::*;
87pub use map::*;
88pub use object_control::*;
89pub use object_stat::*;
90pub use random::*;
91pub use security::*;
92pub use spawn::*;
93pub use thread_control::*;
94pub use thread_sync::*;
95pub use time::*;
96use twizzler_rt_abi::error::{RawTwzError, TwzError};
97
98#[inline]
99fn convert_codes_to_result<T, E, D, F, G>(code: u64, val: u64, d: D, f: F, g: G) -> Result<T, E>
100where
101 F: Fn(u64, u64) -> T,
102 G: Fn(u64, u64) -> E,
103 D: Fn(u64, u64) -> bool,
104{
105 if d(code, val) {
106 Err(g(code, val))
107 } else {
108 Ok(f(code, val))
109 }
110}
111
112#[inline]
113fn twzerr(_: u64, v: u64) -> TwzError {
114 RawTwzError::new(v).error()
115}
116
117#[deprecated]
119pub fn sys_debug_shutdown(code: u32) {
120 unsafe {
121 raw_syscall(Syscall::Null, &[0x12345678, code as u64]);
122 }
123}