From 5f813d49a08cf3c3f8cf6c422cfb6587df575f62 Mon Sep 17 00:00:00 2001 From: Jon Santmyer Date: Sat, 26 Sep 2026 17:11:50 -0400 Subject: add docs for syscalls. make syscall code kind-of cleaner --- arch/x86_64/sys/syscall.c | 48 +++++++++++++++++++---------------------------- 1 file changed, 19 insertions(+), 29 deletions(-) (limited to 'arch/x86_64/sys/syscall.c') diff --git a/arch/x86_64/sys/syscall.c b/arch/x86_64/sys/syscall.c index 53351e7..a694674 100644 --- a/arch/x86_64/sys/syscall.c +++ b/arch/x86_64/sys/syscall.c @@ -10,24 +10,17 @@ syscall_handle_t s_arch_handles[128] = { }; int -_syscall_handle_arch( - jove_owned_obj_t *pcb_obj, - jove_owned_obj_t *objdir, - jove_owned_obj_t *message_obj, - jove_owned_obj_t *target_obj, - struct syscall_header *header, - size_t bytes_left, - void *payload) +_syscall_handle_arch(syscall_context_t *ctx) { - uint8_t target_type = obj_gettype(target_obj) - 0x80; + uint8_t target_type = obj_gettype(ctx->target.obj) - 0x80; syscall_handle_t call_handle = s_arch_handles[target_type]; if(call_handle == NULL) { kprintf("syscall: Process %i tried to call syscall on object %P which doesn't support syscalls!\n", - pcb_pid(obj_deref(pcb_obj)), header->path, header->pathlen); - return EBADOBJ; + pcb_pid(obj_deref(ctx->pcb)), ctx->header->path, ctx->header->pathlen); + return -EBADOBJ; } - return call_handle(pcb_obj, objdir, message_obj, target_obj, header, bytes_left, payload); + return call_handle(ctx); } __attribute__((naked)) @@ -38,32 +31,29 @@ void _syscall_entry(void) movq %%gs:%c[pcb], %%rax; \ movq %%rsp, %%rdx; \ movq %c[ksp](%%rax), %%rsp; \ + pushq %%rcx; \ pushq %%rdx; \ pushq %%r11; \ - pushq %%rbx; \ - pushq %%rcx; \ pushq %%rbp; \ - pushq %%r12; \ - pushq %%r13; \ - pushq %%r14; \ - pushq %%r15; \ callq syscall_handler; \ swapgs; \ - popq %%r15; \ - popq %%r14; \ - popq %%r13; \ - popq %%r12; \ - popq %%rbp; \ - popq %%rcx; \ - popq %%rbx; \ - xorq %%rdx, %%rdx; \ + xorq %%r15, %%r15; \ + xorq %%r14, %%r14; \ + xorq %%r13, %%r13; \ + xorq %%r12, %%r12; \ + xorq %%r10, %%r10; \ + xorq %%r9, %%r9; \ + xorq %%r8, %%r8; \ xorq %%rsi, %%rsi; \ xorq %%rdi, %%rdi; \ - xorq %%r8, %%r8; \ - xorq %%r9, %%r9; \ - xorq %%r10, %%r10; \ + xorq %%rbp, %%rbp; \ + xorq %%rdx, %%rdx; \ + xorq %%rcx, %%rcx; \ + xorq %%rbx, %%rbx; \ + popq %%rbp; \ popq %%r11; \ popq %%rsp; \ + popq %%rcx; \ sysretq;" :: [pcb] "i"(offsetof(processor_t, pcb)), -- cgit v1.2.3