diff options
Diffstat (limited to 'syscall/handler.c')
-rw-r--r-- | syscall/handler.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/syscall/handler.c b/syscall/handler.c index b3eea99..a586a73 100644 --- a/syscall/handler.c +++ b/syscall/handler.c @@ -60,21 +60,32 @@ _syscall_handler(uintmax_t argsi, int calli) return -KE_BADMSG; } mtx_acquire(&payload_entry->lock); - uint8_t *payload = ko_entry_data(payload_entry); + + uint8_t *payload; + int result = 0; + + if(ko_message_unmap(payload_entry, (uintptr_t*)&payload)) { + klogf("Failed to unmap message %p\n", payload_entry); + result = KE_BADMSG; + goto handle_end; + } switch(calli) { case SYSCALL_INVOKE: { - int e = s_syscall_handle_invoke(root_dir, payload); - mtx_release(&payload_entry->lock); - return e; + result = s_syscall_handle_invoke(root_dir, payload); + goto handle_end; } case SYSCALL_DEBUG_PUTC: kprintf("%c", (char)payload[0]); - mtx_release(&payload_entry->lock); - return 0; + goto handle_end; default: klogf("Invalid syscall %i caught! Failing.\n", calli); - mtx_release(&payload_entry->lock); - return -KE_BADCALL; + result = KE_BADCALL; + goto handle_end; } + +handle_end: + ko_message_remap(payload_entry); + mtx_release(&payload_entry->lock); + return result; } |