1 global syscall_entry:function
2 global ksyscall:function
9 ; syscall number in rax
10 ; fourth argument (rcx) on stack?
12 ; syscall over-writes rcx, save it
18 %define STAR 0xC0000081
19 %define LSTAR 0xC0000082
20 %define FMASK 0xC0000084
24 global init_syscalls:function
29 mov edx, 0x23 ; user code segment / user data segment / 64 bit user code segment
31 or edx, 0x10 ; kernel code segment
35 mov rax, qword syscall_entry
36 mov rdx, qword syscall_entry
47 ; turn on the enable bit (bit 1 of EFER, iirc)
51 ; still using user stack and memory map
52 ; can't use user's stack because user may lie about where it is
53 ; causing us to overwrite memory.
63 ; TODO switch to kernel stack
65 ; save values for sysret
68 mov r10, rcx ; fourth arg in r10, since syscall clobbers rcx
76 mov rdi, qword sleepstr
77 mov rdx, qword timer_ticks
89 ; syscall number in rax
90 ; rcx would be the fourth argument, but over-written by syscall
91 ; so we pass it in r10, another scratch register
93 ; may not need to check for schedule, the syscall itself
94 ; should do a yield if it wants to
96 ; need to check for schedule, could possible just do
97 ; an interrupt if it needed scheduling
106 int 0x81 ; force a schedule call, any int would do actually
117 db 0x48 ; no sysretq in yasm
121 db 'ignoring syscall %u', 0xa, 0
124 db '%u pid %u syscall %u : %u %u', 0xa, 0