/* syscall.h - System call interface for Pactor64 */ #ifndef _SYSCALL_H #define _SYSCALL_H #include "pactor64.h" /* Linux x86-64 compatible syscall numbers */ #define SYS_READ 0 #define SYS_WRITE 1 #define SYS_OPEN 2 #define SYS_CLOSE 3 #define SYS_LSEEK 8 #define SYS_BRK 12 #define SYS_IOCTL 16 #define SYS_PIPE 22 #define SYS_DUP 32 #define SYS_GETPID 39 #define SYS_EXIT 60 #define SYS_GETUID 102 #define SYS_GETGID 104 /* MSR addresses for SYSCALL support */ #define MSR_STAR 0xC0000081 #define MSR_LSTAR 0xC0000082 #define MSR_FMASK 0xC0000084 #define MAX_SYSCALL 128 /* Initialize the syscall interface (sets up STAR/LSTAR MSRs) */ void syscall_init(void); /* The syscall handler (called from assembly stub) */ uint64_t syscall_dispatch(uint64_t num, uint64_t arg1, uint64_t arg2, uint64_t arg3, uint64_t arg4, uint64_t arg5); /* Assembly syscall entry point */ extern void syscall_entry(void); /* Return from userspace back to kernel shell (called from sys_exit) */ extern void return_to_kernel(void) __attribute__((noreturn)); /* Low-level MSR read/write */ static inline uint64_t read_msr(uint32_t msr) { uint32_t lo, hi; __asm__ volatile ("rdmsr" : "=a"(lo), "=d"(hi) : "c"(msr)); return ((uint64_t)hi << 32) | lo; } static inline void write_msr(uint32_t msr, uint64_t val) { uint32_t lo = (uint32_t)val; uint32_t hi = (uint32_t)(val >> 32); __asm__ volatile ("wrmsr" : : "a"(lo), "d"(hi), "c"(msr)); } #endif /* _SYSCALL_H */