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 dispatcher;
17pub mod error;
18pub mod exec;
19pub mod fcntl;
20pub mod fork;
21pub mod futex;
22pub mod mmap;
23pub mod numbers;
24pub mod poll;
25pub mod process;
26pub mod signal;
27pub mod time;
28pub mod wait;
29
30pub use dispatcher::dispatch;
31pub use exec::sys_execve;
32pub use fcntl::sys_fcntl;
33pub use fork::sys_fork;
34pub use time::{sys_clock_gettime, sys_nanosleep};
35
36/// Stack frame passed to the Rust syscall dispatcher.
37///
38/// This matches the push order in `syscall_entry` (arch/x86_64/syscall.rs).
39/// The struct is laid out in memory from low to high address (RSP grows down,
40/// so first push = highest address, last push = lowest = RSP).
41#[repr(C)]
42pub struct SyscallFrame {
43    // Pushed last → at lowest address (RSP points here)
44    pub r15: u64,
45    pub r14: u64,
46    pub r13: u64,
47    pub r12: u64,
48    pub rbp: u64,
49    pub rbx: u64,
50    pub r11: u64, // user RFLAGS
51    pub r10: u64, // arg 4
52    pub r9: u64,  // arg 6
53    pub r8: u64,  // arg 5
54    pub rsi: u64, // arg 2
55    pub rdi: u64, // arg 1
56    pub rdx: u64, // arg 3
57    pub rcx: u64, // user RIP
58    pub rax: u64, // syscall number / return value
59
60    // IRET frame follows (pushed first → highest address)
61    pub iret_rip: u64,
62    pub iret_cs: u64,
63    pub iret_rflags: u64,
64    pub iret_rsp: u64,
65    pub iret_ss: u64,
66}