summaryrefslogtreecommitdiffstats
path: root/arch/x86_64/sys/syscall.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86_64/sys/syscall.c')
-rw-r--r--arch/x86_64/sys/syscall.c40
1 files changed, 24 insertions, 16 deletions
diff --git a/arch/x86_64/sys/syscall.c b/arch/x86_64/sys/syscall.c
index 4e95225..b2d3e7f 100644
--- a/arch/x86_64/sys/syscall.c
+++ b/arch/x86_64/sys/syscall.c
@@ -1,24 +1,33 @@
+#include "arch/x86_64/hal/obj.h"
#include "arch/x86_64/hal/process.h"
#include "arch/x86_64/hal/smp.h"
-#include "hal/smp.h"
-#include "jove.h"
+#include "lib/printf.h"
+
+#include "syscall.h"
+
+syscall_handle_t s_arch_handles[128] = {
+ [JOVE_OBJ_SERIAL_COM-0x80] = _syscall_handle_serial
+};
int
-syscall_handler_arch(uint64_t message_path_raw, uint64_t message_pathlen)
+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)
{
- 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;
+ uint8_t target_type = obj_gettype(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;
}
- return 0;
+ return call_handle(pcb_obj, objdir, message_obj, target_obj, header, bytes_left, payload);
}
__attribute__((naked))
@@ -38,7 +47,7 @@ void _syscall_entry(void)
pushq %%r13; \
pushq %%r14; \
pushq %%r15; \
- callq syscall_handler_arch; \
+ callq syscall_handler; \
swapgs; \
popq %%r15; \
popq %%r14; \
@@ -53,7 +62,6 @@ void _syscall_entry(void)
xorq %%r8, %%r8; \
xorq %%r9, %%r9; \
xorq %%r10, %%r10; \
- popq %%rcx; \
popq %%r11; \
popq %%rsp; \
sysretq;"