From ace65b453151845bc361f21f3e5b651c35f9f126 Mon Sep 17 00:00:00 2001 From: Jon Santmyer Date: Wed, 22 May 2024 13:00:41 -0400 Subject: massive refactor for mp and organization --- syscall/handler.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 syscall/handler.c (limited to 'syscall/handler.c') diff --git a/syscall/handler.c b/syscall/handler.c new file mode 100644 index 0000000..5cafdc6 --- /dev/null +++ b/syscall/handler.c @@ -0,0 +1,23 @@ +#include "handler.h" +#include "print.h" +#include "umode_vma.h" +#include "api/errno.h" + +static void *s_handlers[] = { + (void*)_handler_dbg_log, + (void*)_handler_exit +}; +static size_t s_handlers_size = sizeof(s_handlers); + +int +_syscall_handler(void *data) +{ + uintmax_t req_id = 0; + if(user_vma_read(&req_id, data, sizeof(uintmax_t)) != 0) + return -EFAIL; + + if(req_id >= s_handlers_size) return -1; + int (*handle)(void*) = (int (*)(void*))s_handlers[req_id]; + kdbgf("syscall id %i handle %p\n", req_id, handle); + return handle(data); +} -- cgit v1.2.1