From bc2e1f80d38544ebc1da666ef2dfaf362af59171 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Thu, 4 Mar 2021 18:05:20 +0100 Subject: [PATCH] Syscall args --- include/kernel/ke/syscall.h | 3 ++- kaleid/kernel/ke/isr.asm | 2 +- kaleid/kernel/ke/syscall.asm | 20 ++++++++++---------- kaleid/kernel/ke/syscall.c | 3 ++- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/include/kernel/ke/syscall.h b/include/kernel/ke/syscall.h index 3c21ddb..508546c 100644 --- a/include/kernel/ke/syscall.h +++ b/include/kernel/ke/syscall.h @@ -35,7 +35,8 @@ extern error_t KeSyscall(ulong code); extern void KeJumpToUserspace(ulong args, void *entryPoint, void *stackAddr); -error_t _KeSyscallHandler(ulong code, ISRFrame_t *regs); +error_t _KeSyscallHandler( ulong code, void *arg0, void *arg1, void *arg2, + ISRFrame_t *regs ); //----------------------------------------------------------------------------// diff --git a/kaleid/kernel/ke/isr.asm b/kaleid/kernel/ke/isr.asm index 57ada84..f2bc220 100644 --- a/kaleid/kernel/ke/isr.asm +++ b/kaleid/kernel/ke/isr.asm @@ -68,7 +68,7 @@ isrPreHandler: add rsp, 48 ; pop registers popAll - ; pop the error code and interrupt id + ; pop the error code, interrupt id + crx add rsp, 16 iretq diff --git a/kaleid/kernel/ke/syscall.asm b/kaleid/kernel/ke/syscall.asm index c9cca05..3c6db3e 100644 --- a/kaleid/kernel/ke/syscall.asm +++ b/kaleid/kernel/ke/syscall.asm @@ -41,13 +41,13 @@ syscallPreHandler: push r13 push r12 push r11 - push 0 + push 0 ; r10 push r9 push r8 push rbp - push 0 - push 0 - push 0 + push 0 ; rdi + push 0 ; rsi + push 0 ; rdx push rcx push rbx push rax @@ -76,21 +76,21 @@ syscallPreHandler: add rsp, 48 ; pop registers except return value pop rbx - pop rbx ; 2x rbx to discard rax + pop rbx ; 2x rbx to discard old rax pop rcx - pop rdx - pop rsi - pop rdi + pop rdx ; 0 + pop rsi ; 0 + pop rdi ; 0 pop rbp pop r8 pop r9 - pop r10 + pop r10 ; 0 pop r11 pop r12 pop r13 pop r14 pop r15 - ; pop the error code and interrupt id + ; pop the error code, interrupt id + crx add rsp, 16 iretq diff --git a/kaleid/kernel/ke/syscall.c b/kaleid/kernel/ke/syscall.c index 55dbad3..249f66a 100644 --- a/kaleid/kernel/ke/syscall.c +++ b/kaleid/kernel/ke/syscall.c @@ -27,7 +27,8 @@ #include #include -error_t _KeSyscallHandler(ulong code, ISRFrame_t *regs) +error_t _KeSyscallHandler( ulong code, void *arg0, void *arg1, void *arg2, + ISRFrame_t *regs ) { DebugLog("Got a system call code %ld from cs %#x\n", code, regs->cs);