54 lines
1.2 KiB
Rust
54 lines
1.2 KiB
Rust
use num_derive::FromPrimitive;
|
|
use num_traits::FromPrimitive;
|
|
|
|
use crate::arch;
|
|
#[repr(u32)]
|
|
#[derive(FromPrimitive, Debug)]
|
|
pub enum Syscall {
|
|
/// Kill the calling process, and deallocate all
|
|
/// resources associated, including shared memory channels,
|
|
/// IPC sessions, handles, etc.
|
|
/// Arguments:
|
|
/// 0 - Exit code
|
|
Exit = 0,
|
|
/// Get the current PID of the calling process.
|
|
Pid = 1,
|
|
/// Send a message to another process.
|
|
Message = 2,
|
|
MemMap = 3,
|
|
MemUnmap = 4,
|
|
Resolve = 5,
|
|
Spawn = 6,
|
|
Version = 7,
|
|
Yield = 8,
|
|
}
|
|
|
|
#[repr(u32)]
|
|
#[derive(FromPrimitive, Debug)]
|
|
pub enum SyscallStatus {
|
|
/// Syscall completed without any issues.
|
|
Success,
|
|
/// Issued a system call with the wrong call ID.
|
|
NoSuchCall,
|
|
NoSuchProcess,
|
|
NoSuchService,
|
|
SecurityFailure,
|
|
OutOfMemory,
|
|
Aborted,
|
|
Unspecified,
|
|
Unknown,
|
|
Unimplemented,
|
|
InvalidPage,
|
|
}
|
|
|
|
impl From<u64> for SyscallStatus {
|
|
fn from(value: u64) -> Self {
|
|
SyscallStatus::from_u64(value).unwrap_or(Self::Unknown)
|
|
}
|
|
}
|
|
|
|
pub fn exit(code: u32) -> ! {
|
|
arch::syscall_impl::caller_syscall_1(Syscall::Exit as u64, code as u64);
|
|
unreachable!();
|
|
}
|