diff options
author | dzwdz | 2021-07-22 19:11:42 +0200 |
---|---|---|
committer | dzwdz | 2021-07-22 19:11:42 +0200 |
commit | 4823f92f9d3feabdc758d8cd6eef855de90fee2a (patch) | |
tree | 374c065807f422818d79b35c33082df3d00b461d /src/kernel/syscalls.c | |
parent | 8a168f2be5d90f972975abf0b40145a75c0231b7 (diff) |
implement the debuglog() syscall
Diffstat (limited to 'src/kernel/syscalls.c')
-rw-r--r-- | src/kernel/syscalls.c | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/src/kernel/syscalls.c b/src/kernel/syscalls.c index a42dc44..2af8cf9 100644 --- a/src/kernel/syscalls.c +++ b/src/kernel/syscalls.c @@ -1,15 +1,29 @@ #include <kernel/arch/generic.h> #include <kernel/panic.h> +#include <kernel/proc.h> +#include <kernel/syscalls.h> +#include <stdint.h> -int syscall_handler(int a, int b, int c, int d) { - // verify that the parameters get passed correctly - if (a != 1) panic(); - if (b != 2) panic(); - if (c != 3) panic(); - if (d != 4) panic(); +int sc_debuglog(const char *msg, size_t len) { + struct pagedir *pages = process_current->pages; + void *phys = pagedir_virt2phys(pages, msg, true, false); - log_const("in a syscall!"); + // page overrun check + if (((uintptr_t)msg & PAGE_MASK) + len > PAGE_SIZE) + len = PAGE_SIZE - ((uintptr_t)msg & PAGE_MASK); + if (((uintptr_t)msg & PAGE_MASK) + len > PAGE_SIZE) + panic(); // just in case I made an off by 1 error - // used to check if the return value gets passed correctly - return 0x4e; + log_write(phys, len); + return len; +} + +int syscall_handler(int num, int a, int b, int c) { + switch (num) { + case SC_DEBUGLOG: + return sc_debuglog((void*)a, b); + default: + log_const("unknown syscall "); + panic(); + } } |