refactor(kernel): split syscall.rs into per-tier modules (simple, memory, lifecycle, capability, ipc)
This commit is contained in:
40
crates/kernel/src/syscall/mod.rs
Normal file
40
crates/kernel/src/syscall/mod.rs
Normal file
@@ -0,0 +1,40 @@
|
||||
mod capability;
|
||||
mod ipc;
|
||||
mod lifecycle;
|
||||
mod memory;
|
||||
mod simple;
|
||||
|
||||
use domain::syscall::Syscall;
|
||||
use platform::Platform;
|
||||
|
||||
use crate::{Kernel, SyscallOutcome, SyscallResult};
|
||||
|
||||
impl<P: Platform> Kernel<P> {
|
||||
pub fn handle_syscall(&mut self, syscall: Syscall) -> SyscallOutcome {
|
||||
let (tid, pid) = match self.caller() {
|
||||
Ok(caller) => caller,
|
||||
Err(e) => return SyscallOutcome::Complete(SyscallResult::Error(e)),
|
||||
};
|
||||
|
||||
match syscall {
|
||||
Syscall::GetTime => self.handle_get_time(),
|
||||
Syscall::GetProcessId => self.handle_get_process_id(pid),
|
||||
Syscall::Yield => self.handle_yield(tid),
|
||||
Syscall::Exit => self.handle_exit(tid, pid),
|
||||
Syscall::ExitThread => self.handle_exit_thread(tid, pid),
|
||||
Syscall::RequestPages { count } => self.handle_request_pages(pid, count),
|
||||
Syscall::ReleasePages { addr, count } => self.handle_release_pages(pid, addr, count),
|
||||
Syscall::SpawnThread { entry, stack } => self.handle_spawn_thread(pid, entry, stack),
|
||||
Syscall::CreateProcess { create_cap, image } => self.handle_create_process(pid, create_cap, image),
|
||||
Syscall::Kill { process } => self.handle_kill(pid, process),
|
||||
Syscall::Delegate { slot, to_endpoint, permissions } => {
|
||||
self.handle_delegate(pid, slot, to_endpoint, permissions)
|
||||
}
|
||||
Syscall::Send { endpoint, message } => self.handle_send(tid, pid, endpoint, message),
|
||||
Syscall::Receive { endpoint } => self.handle_receive(tid, pid, endpoint),
|
||||
Syscall::WaitForInterrupt { irq } => self.handle_wait_for_interrupt(tid, pid, irq),
|
||||
Syscall::AcknowledgeInterrupt { irq } => self.handle_ack_interrupt(pid, irq),
|
||||
Syscall::WaitAny { sources } => self.handle_wait_any(tid, pid, sources),
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user