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.c58
1 files changed, 57 insertions, 1 deletions
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)));
}