summaryrefslogtreecommitdiffstats
path: root/syscall
diff options
context:
space:
mode:
Diffstat (limited to 'syscall')
-rw-r--r--syscall/handler.c27
-rw-r--r--syscall/invoke-untyped.c25
2 files changed, 41 insertions, 11 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;
}
diff --git a/syscall/invoke-untyped.c b/syscall/invoke-untyped.c
index fe34ce9..a89306e 100644
--- a/syscall/invoke-untyped.c
+++ b/syscall/invoke-untyped.c
@@ -1,4 +1,5 @@
#include "handles.h"
+#include "object.h"
#include "syscall.h"
#include "error.h"
#include "memory.h"
@@ -69,7 +70,7 @@ s_handle_invoke_untyped_split(
};
size_t *split = ko_entry_data(dest_entry);
- *untyped -= dest_bytes;
+*untyped -= dest_bytes;
*split = dest_bytes;
#ifdef DBG_SYSCALL
@@ -80,11 +81,29 @@ s_handle_invoke_untyped_split(
return 0;
}
+static int
+s_handle_invoke_untyped_retype(
+ objdir_t *root_dir,
+ objdir_entry_t *target,
+ uint8_t *payload,
+ size_t payload_at
+ )
+{
+ obj_type_t retype;
+ SYSCALL_PAYLOAD_TAKEL(payload, payload_at, retype, obj_type_t);
+
+ switch(retype) {
+ case KO_OBJECT_DIRECTORY:
+ return ko_untyped_retype_objdir(target);
+ default: return KE_BADTYPE;
+ }
+}
+
static int (*s_invoke_handles[])(objdir_t*, objdir_entry_t*, uint8_t*, size_t) = {
[INVOKE_UNTYPED_SIZE] = s_handle_invoke_untyped_size,
[INVOKE_UNTYPED_SPLIT] = s_handle_invoke_untyped_split,
-
- [INVOKE_UNTYPED_ALIGNMENT] = s_handle_invoke_untyped_alignment
+ [INVOKE_UNTYPED_ALIGNMENT] = s_handle_invoke_untyped_alignment,
+ [INVOKE_UNTYPED_RETYPE] = s_handle_invoke_untyped_retype,
};
static size_t s_invoke_handles_count = sizeof(s_invoke_handles) / sizeof(void*);