From 73cbb23130f634bf52ac92da063efd3e6016f8ee Mon Sep 17 00:00:00 2001 From: Jon Santmyer Date: Sat, 5 Sep 2026 11:38:27 -0400 Subject: make objdir_getlocal return locked object --- arch/x86_64/sys/init.c | 4 ++-- arch/x86_64/sys/syscall.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 59 insertions(+), 3 deletions(-) (limited to 'arch/x86_64/sys') diff --git a/arch/x86_64/sys/init.c b/arch/x86_64/sys/init.c index 2bd86d5..26eefde 100644 --- a/arch/x86_64/sys/init.c +++ b/arch/x86_64/sys/init.c @@ -77,7 +77,7 @@ init_setup(void) kpanic("Kernel commandline is missing 'init' arg.\n"); } - jove_owned_obj_t *initrd_obj = obj_take(objdir_getlocal(_rootdir_obj, ROOTDIR_INITRD_I)); + jove_owned_obj_t *initrd_obj = objdir_getlocal(_rootdir_obj, ROOTDIR_INITRD_I); jove_owned_obj_t *init_obj = initrd_seek(initrd_obj, init_path); if(init_obj == NULL) { kpanic("init: Cannot find file '%s' in initrd.\n", init_path); @@ -96,7 +96,7 @@ init_setup(void) kpanic("init: Either passed file '%s' is not an ELF file or is not loadable.\n", init_path); } - jove_owned_obj_t *init_pagedir = obj_take(objdir_getlocal(_rootdir_obj, ROOTDIR_PAGEDIR_I)); + jove_owned_obj_t *init_pagedir = objdir_getlocal(_rootdir_obj, ROOTDIR_PAGEDIR_I); page_t *pml4 = obj_deref(init_pagedir); //Load the init ELF diff --git a/arch/x86_64/sys/syscall.c b/arch/x86_64/sys/syscall.c index 8cc58bf..4e95225 100644 --- a/arch/x86_64/sys/syscall.c +++ b/arch/x86_64/sys/syscall.c @@ -1,7 +1,63 @@ +#include "arch/x86_64/hal/process.h" +#include "arch/x86_64/hal/smp.h" +#include "hal/smp.h" +#include "jove.h" +int +syscall_handler_arch(uint64_t message_path_raw, uint64_t message_pathlen) +{ + uint16_t *message_path = (uint16_t*)&message_path_raw; + if(message_pathlen > 4) { + return EBADPATH; + } + processor_t *proc = processor_current(); + jove_owned_obj_t *objdir = obj_take(proc->pcb->rootdir); + jove_owned_obj_t *message_obj = objdir_getobj(objdir, message_path, message_pathlen); + if(message_obj == 0) { + obj_release(objdir); + return errno; + } + + return 0; +} __attribute__((naked)) void _syscall_entry(void) { - + __asm__ volatile(" \ + swapgs; \ + movq %%gs:%c[pcb], %%rax; \ + movq %%rsp, %%rdx; \ + movq %c[ksp](%%rax), %%rsp; \ + pushq %%rdx; \ + pushq %%r11; \ + pushq %%rbx; \ + pushq %%rcx; \ + pushq %%rbp; \ + pushq %%r12; \ + pushq %%r13; \ + pushq %%r14; \ + pushq %%r15; \ + callq syscall_handler_arch; \ + swapgs; \ + popq %%r15; \ + popq %%r14; \ + popq %%r13; \ + popq %%r12; \ + popq %%rbp; \ + popq %%rcx; \ + popq %%rbx; \ + xorq %%rdx, %%rdx; \ + xorq %%rsi, %%rsi; \ + xorq %%rdi, %%rdi; \ + xorq %%r8, %%r8; \ + xorq %%r9, %%r9; \ + xorq %%r10, %%r10; \ + popq %%rcx; \ + popq %%r11; \ + popq %%rsp; \ + sysretq;" + :: + [pcb] "i"(offsetof(processor_t, pcb)), + [ksp] "i"(offsetof(pcb_t, ksp))); } -- cgit v1.2.3