Stuff with syscall API
This commit is contained in:
parent
583c6860b5
commit
d3c40b54f8
@ -1,7 +1,13 @@
|
||||
use core::{error::Error, num::ParseIntError};
|
||||
|
||||
use num_derive::FromPrimitive;
|
||||
use num_traits::FromPrimitive;
|
||||
|
||||
use crate::arch;
|
||||
|
||||
pub struct SyscallError {
|
||||
}
|
||||
|
||||
#[repr(u32)]
|
||||
#[derive(FromPrimitive, Debug)]
|
||||
pub enum Syscall {
|
||||
@ -15,11 +21,17 @@ pub enum Syscall {
|
||||
Pid = 1,
|
||||
/// Send a message to another process.
|
||||
Message = 2,
|
||||
/// Map new pages.
|
||||
MemMap = 3,
|
||||
/// Unmap existing pages.
|
||||
MemUnmap = 4,
|
||||
/// Resolve a service name to a process.
|
||||
Resolve = 5,
|
||||
/// Spawn a new process.
|
||||
Spawn = 6,
|
||||
/// Access information about the kernel versioning.
|
||||
Version = 7,
|
||||
/// Yield the remainder of quantum to another process.
|
||||
Yield = 8,
|
||||
}
|
||||
|
||||
@ -27,23 +39,33 @@ pub enum Syscall {
|
||||
#[derive(FromPrimitive, Debug)]
|
||||
pub enum SyscallStatus {
|
||||
/// Syscall completed without any issues.
|
||||
Success,
|
||||
Success = 0,
|
||||
/// Issued a system call with the wrong call ID.
|
||||
NoSuchCall,
|
||||
NoSuchProcess,
|
||||
NoSuchService,
|
||||
SecurityFailure,
|
||||
OutOfMemory,
|
||||
Aborted,
|
||||
Unspecified,
|
||||
Unknown,
|
||||
Unimplemented,
|
||||
InvalidPage,
|
||||
NoSuchCall = 1,
|
||||
/// Issued a system call referencing a nonexistent process.
|
||||
NoSuchProcess = 2,
|
||||
/// Issued a system call referencing a nonexistent service name.
|
||||
NoSuchService = 3,
|
||||
/// System call was prevented by some security policy.
|
||||
SecurityFailure = 4,
|
||||
/// Could not allocate any more pages since there are none left.
|
||||
OutOfMemory = 5,
|
||||
/// System call failed to complete in constant time.
|
||||
Aborted = 6,
|
||||
/// Attempted to issue an unimplemented system call.
|
||||
Unimplemented = 7,
|
||||
/// Issued a system call with a malformed parameter.
|
||||
InvalidParameter = 8,
|
||||
}
|
||||
|
||||
impl From<u64> for SyscallStatus {
|
||||
fn from(value: u64) -> Self {
|
||||
SyscallStatus::from_u64(value).unwrap_or(Self::Unknown)
|
||||
impl TryFrom<u64> for SyscallStatus {
|
||||
type Error = SyscallError;
|
||||
fn try_from(value: u64) -> Result<Self, Self::Error> {
|
||||
if let Some(status) = SyscallStatus::from_u64(value) {
|
||||
Ok(status)
|
||||
} else {
|
||||
Err(SyscallError {})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user