Skip to main content

strat9_kernel/syscall/
mod.rs

1//! Strat9-OS Syscall Interface
2//!
3//! Implements the kernel-side syscall dispatcher and handlers for the
4//! Strat9-OS native ABI.
5//!
6//! Syscall numbers are organized in blocks of 100:
7//!
8//! - 000-099 : Capabilities (handle management)
9//! - 100-199: memory
10//! - 200-299: IPC
11//! - 300-399: process/thread
12//! - 400-499: filesystem/VFS
13//! - 500-599: time/alarms
14//! - 600-699: debug/profiling
15
16pub mod chan;
17pub mod debug;
18pub mod dispatcher;
19pub mod error;
20pub mod exec;
21pub mod fcntl;
22pub mod fork;
23pub mod futex;
24pub mod ipc_port;
25pub mod ipc_ring;
26pub mod mmap;
27pub mod net;
28pub mod numbers;
29pub mod pci;
30pub mod poll;
31pub mod process;
32pub mod random;
33pub mod robust_list;
34pub mod semaphore;
35pub mod signal;
36pub mod time;
37pub mod transport;
38pub mod volume;
39pub mod wait;
40
41pub use dispatcher::dispatch;
42pub use exec::sys_execve;
43pub use fcntl::sys_fcntl;
44pub use fork::sys_fork;
45pub use time::{sys_clock_gettime, sys_nanosleep};
46
47/// Stack frame passed to the Rust syscall dispatcher.
48///
49/// This matches the push order in `syscall_entry` (arch/x86_64/syscall.rs).
50/// The struct is laid out in memory from low to high address (RSP grows down,
51/// so first push = highest address, last push = lowest = RSP).
52#[repr(C)]
53pub struct SyscallFrame {
54    // Pushed last → at lowest address (RSP points here)
55    pub r15: u64,
56    pub r14: u64,
57    pub r13: u64,
58    pub r12: u64,
59    pub rbp: u64,
60    pub rbx: u64,
61    pub r11: u64, // user RFLAGS
62    pub r10: u64, // arg 4
63    pub r9: u64,  // arg 6
64    pub r8: u64,  // arg 5
65    pub rsi: u64, // arg 2
66    pub rdi: u64, // arg 1
67    pub rdx: u64, // arg 3
68    pub rcx: u64, // user RIP
69    pub rax: u64, // syscall number / return value
70
71    // IRET frame follows (pushed first → highest address)
72    pub iret_rip: u64,
73    pub iret_cs: u64,
74    pub iret_rflags: u64,
75    pub iret_rsp: u64,
76    pub iret_ss: u64,
77}