|
miniOS
x86_64 hobby kernel with SMP, VFS, and POSIX process model
|
#include <miniOS/syscall.h>#include <miniOS/sched/sched.h>#include <miniOS/arch/x86_64/irq.h>#include <miniOS/io.h>#include <miniOS/types.h>#include <stddef.h>#include "syscall_internal.h"
Macros | |
| #define | IA32_EFER 0xC0000080UL |
| #define | IA32_STAR 0xC0000081UL |
| #define | IA32_LSTAR 0xC0000082UL |
| #define | IA32_SFMASK 0xC0000084UL |
| #define | SYSCALL_DISPATCH_UNHANDLED ((int64_t)0x7fffffffffffffffLL) |
Functions | |
| static void | wrmsr (uint32_t msr, uint64_t val) |
| static uint64_t | rdmsr (uint32_t msr) |
| void | syscall_entry (void) |
| void | int80_entry (void) |
| void | syscall_save_user_regs (uint64_t user_rip, uint64_t user_rflags, uint64_t user_rsp) |
| void | syscall_save_user_callee_regs (uint64_t user_rbp, uint64_t user_rbx, uint64_t user_r12, uint64_t user_r13, uint64_t user_r14, uint64_t user_r15) |
| void | syscall_get_saved_user_callee_regs (uint64_t *out_rbp, uint64_t *out_rbx, uint64_t *out_r12, uint64_t *out_r13, uint64_t *out_r14, uint64_t *out_r15) |
| void | syscall_get_saved_user_ctx (uint64_t *out_rip, uint64_t *out_rfl, uint64_t *out_rsp) |
| void | syscall_get_saved_user_rdi_rsi_rdx (uint64_t *out_rdi, uint64_t *out_rsi, uint64_t *out_rdx) |
| The SYSCALL instruction clobbers RCX and R11; arguments in RDI/RSI/RDX are preserved by the syscall.asm stub in per-CPU scratch space. This helper exposes them to kernel C code (e.g., SYS_execve handler) that needs all three argument registers. | |
| void | syscall_save_restart_state (uint64_t nr, uint64_t a1, uint64_t a2, uint64_t a3, uint64_t a4, uint64_t a5, uint64_t a6) |
| void | syscall_init (void) |
| Writes IA32_LSTAR MSR to the address of syscall_entry (the NASM entry stub in syscall.asm), writes IA32_STAR MSR with kernel CS (0x08) and user CS (0x1B) selectors, writes IA32_FMASK to mask IF during syscall entry (interrupts disabled at syscall boundary), and sets SCE bit in IA32_EFER. Called once by the BSP during boot. | |
| int64_t | syscall_dispatch (uint64_t nr, uint64_t arg1, uint64_t arg2, uint64_t arg3, uint64_t arg4, uint64_t arg5, uint64_t arg6) |
Variables | |
| uint64_t | syscall_kernel_rsp_storage |
| #define IA32_EFER 0xC0000080UL |
| #define IA32_LSTAR 0xC0000082UL |
| #define IA32_SFMASK 0xC0000084UL |
| #define IA32_STAR 0xC0000081UL |
| #define SYSCALL_DISPATCH_UNHANDLED ((int64_t)0x7fffffffffffffffLL) |
|
extern |




| int64_t syscall_dispatch | ( | uint64_t | nr, |
| uint64_t | arg1, | ||
| uint64_t | arg2, | ||
| uint64_t | arg3, | ||
| uint64_t | arg4, | ||
| uint64_t | arg5, | ||
| uint64_t | arg6 ) |
syscall_dispatch() - Dispatch a syscall number to grouped subsystem handlers.
src/kernel/syscall.c owns the stable public entrypoints and delegates the large implementation bodies to subsystem-specific pieces:


|
extern |


| void syscall_get_saved_user_callee_regs | ( | uint64_t * | out_rbp, |
| uint64_t * | out_rbx, | ||
| uint64_t * | out_r12, | ||
| uint64_t * | out_r13, | ||
| uint64_t * | out_r14, | ||
| uint64_t * | out_r15 ) |




| void syscall_save_user_callee_regs | ( | uint64_t | user_rbp, |
| uint64_t | user_rbx, | ||
| uint64_t | user_r12, | ||
| uint64_t | user_r13, | ||
| uint64_t | user_r14, | ||
| uint64_t | user_r15 ) |






|
extern |