summaryrefslogtreecommitdiffstats
path: root/arch/x86_64/sys
diff options
context:
space:
mode:
authorJon Santmyer <jon@jonsantmyer.com>2026-09-26 17:11:50 -0400
committerJon Santmyer <jon@jonsantmyer.com>2026-09-26 17:11:50 -0400
commit5f813d49a08cf3c3f8cf6c422cfb6587df575f62 (patch)
treebd8872ee24580614b3eb845e1de26d465b025a09 /arch/x86_64/sys
parentb6765812f7da9feccc271e8e0b06f166e8054386 (diff)
downloadjove-kernel-5f813d49a08cf3c3f8cf6c422cfb6587df575f62.tar.gz
jove-kernel-5f813d49a08cf3c3f8cf6c422cfb6587df575f62.tar.bz2
jove-kernel-5f813d49a08cf3c3f8cf6c422cfb6587df575f62.zip
add docs for syscalls. make syscall code kind-of cleaner
Diffstat (limited to 'arch/x86_64/sys')
-rw-r--r--arch/x86_64/sys/syscall.c48
-rw-r--r--arch/x86_64/sys/syscall.h2
-rw-r--r--arch/x86_64/sys/syscall_serial.c (renamed from arch/x86_64/sys/serial.c)20
3 files changed, 27 insertions, 43 deletions
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)),
diff --git a/arch/x86_64/sys/syscall.h b/arch/x86_64/sys/syscall.h
index 868ce0b..34f6a2a 100644
--- a/arch/x86_64/sys/syscall.h
+++ b/arch/x86_64/sys/syscall.h
@@ -3,7 +3,7 @@
#include "sys/syscall.h"
-int _syscall_handle_serial(SYSCALL_FUNCTION_ARGS);
+int _syscall_handle_serial(syscall_context_t *ctx);
#define SYSCALL_SERIAL_COM_WRITE 0
diff --git a/arch/x86_64/sys/serial.c b/arch/x86_64/sys/syscall_serial.c
index 12db6fd..786a78b 100644
--- a/arch/x86_64/sys/serial.c
+++ b/arch/x86_64/sys/syscall_serial.c
@@ -1,5 +1,6 @@
#include "jove.h"
#include "lib/printf.h"
+#include "sys/syscall.h"
#include "syscall.h"
#include "arch/x86_64/hal/serial_com.h"
@@ -20,20 +21,13 @@ s_syscall_serial_write(
}
int
-_syscall_handle_serial(
- 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_data)
+_syscall_handle_serial(syscall_context_t *ctx)
{
- switch(header->callid) {
- case 0:
- return s_syscall_serial_write(target_obj, bytes_left, payload_data);
+ switch(ctx->header->callid) {
+ case SYSCALL_SERIAL_COM_WRITE:
+ return s_syscall_serial_write(ctx->target.obj, ctx->bytes_left, ctx->payload);
default:
- kprintf("syscall_serial: serial com object does not support syscall %i\n", header->callid);
- return EOOB;
+ kprintf("syscall_serial: serial com object does not support syscall %i\n", ctx->header->callid);
+ return -EBADCALL;
}
}