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