This commit is contained in:
Niklas Gollenstede
2025-10-31 22:37:36 +01:00
commit 174fe17e89
197 changed files with 79558 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
; Generic high-level syscall handler
[EXTERN syscall_handler]
; Low-level interrupt based system call entry function
[GLOBAL syscall_entry]
[SECTION .text]
; The SystemV ABI for x64 uses the register `rdi`, `rsi`, `rdx`, `rcx`, `r8` and
; `r9` to pass the first six parameters of a function. Since every syscall can
; have a maximum of 5 parameters, these register will just be forwarded (without
; requiring any additional operation), having the syscall number stored in `rdi`.
; The return value will be stored in `rax`.
ALIGN 8
syscall_entry:
; Interrupt Context Pointer (7th Parameter)
push rsp
; Clear direction flag for string operations
cld
; Call the high-level (C++) system call handler
call syscall_handler
; Optional: Prevent kernel information leakage
; by zeroing scratch registers
mov rdi, 0
mov rsi, 0
mov rdx, 0
mov rcx, 0
mov r8, 0
mov r9, 0
mov r10, 0
mov r11, 0
; Drop 7th parameter
add rsp, 8
; Return from interrupt entry function
iretq