Stuff with syscall API
Some checks failed
Continuous Integration / Clippy (push) Has been cancelled
Continuous Integration / Check (push) Failing after 1m0s

This commit is contained in:
August 2026-03-16 22:12:29 +00:00
parent 583c6860b5
commit d3c40b54f8
Signed by: shibedrill
SSH Key Fingerprint: SHA256:M0m3JW1s38BgO2t0fG146Yxd9OJ2IOqkvCAsuRHQ6Pw

View File

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