summaryrefslogtreecommitdiffstats
path: root/sys/syscall_untyped.c
diff options
context:
space:
mode:
authorJon Santmyer <jon@jonsantmyer.com>2026-09-07 19:19:24 -0400
committerJon Santmyer <jon@jonsantmyer.com>2026-09-07 19:19:24 -0400
commitdf0688efa326a03a22bcbc36d1900926b7b1c986 (patch)
treec67df82b0a6cd94693278a809ed0c9a69daf840f /sys/syscall_untyped.c
parent4ca0bdf61196d0c3fd3f0fdbfb2d72481025cca2 (diff)
downloadjove-kernel-df0688efa326a03a22bcbc36d1900926b7b1c986.tar.gz
jove-kernel-df0688efa326a03a22bcbc36d1900926b7b1c986.tar.bz2
jove-kernel-df0688efa326a03a22bcbc36d1900926b7b1c986.zip
split syscall info into api subfolder. untyped syscalls
Diffstat (limited to 'sys/syscall_untyped.c')
-rw-r--r--sys/syscall_untyped.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/sys/syscall_untyped.c b/sys/syscall_untyped.c
new file mode 100644
index 0000000..52a0715
--- /dev/null
+++ b/sys/syscall_untyped.c
@@ -0,0 +1,69 @@
+#include "arch/x86_64/hal/obj.h"
+#include "hal/memory.h"
+#include "jove.h"
+#include "lib/printf.h"
+#include "syscall.h"
+
+static int
+s_syscall_untyped_split(
+ jove_owned_obj_t *objdir,
+ jove_owned_obj_t *target_obj,
+ size_t payload_bytes,
+ void *payload_data)
+{
+ int bytes_needed = sizeof(struct syscall_untyped_split);
+ CHECK_TOOSMALL(bytes_needed, payload_bytes, "Message is too small for payload!");
+
+ struct syscall_untyped_split *payload = payload_data;
+ bytes_needed += payload->dest_pathlen * 2;
+ CHECK_TOOSMALL(bytes_needed, payload_bytes, "Message is too small for destination path!");
+
+ jove_owned_obj_t *dst_obj = objdir_getobj(objdir, payload->dest_path, payload->dest_pathlen);
+ CHECK_OBJTYPE(dst_obj, JOVE_OBJ_NONE, "Destination path is occupied!");
+
+ return untyped_split(target_obj, dst_obj, payload->bytes);
+}
+
+static int
+s_syscall_untyped_merge(
+ jove_owned_obj_t *objdir,
+ jove_owned_obj_t *target_obj,
+ size_t payload_bytes,
+ void *payload_data)
+{
+ int bytes_needed = sizeof(struct syscall_generic_objpath);
+ CHECK_TOOSMALL(bytes_needed, payload_bytes, "Message is too small for payload!");
+
+ struct syscall_generic_objpath *payload = payload_data;
+ bytes_needed += payload->second_pathlen * 2;
+ CHECK_TOOSMALL(bytes_needed, payload_bytes, "Message is too small for second path!");
+
+ jove_owned_obj_t *snd_obj = objdir_getobj(objdir, payload->second_path, payload->second_pathlen);
+ CHECK_OBJTYPE(snd_obj, JOVE_OBJ_UNTYPED, "Second object is not an untyped!");
+
+ return untyped_merge(target_obj, snd_obj);
+}
+
+
+int _syscall_handle_untyped(
+ jove_owned_obj_t* pcb_obj,
+ jove_owned_obj_t* objdir,
+ jove_owned_obj_t* message_obj,
+ jove_owned_obj_t* target_obj,
+ struct syscall_header* header,
+ size_t payload_bytes,
+ void* payload)
+{
+ switch(header->callid) {
+ case SYSCALL_UNTYPED_SIZE:
+ return untyped_size(target_obj);
+ case SYSCALL_UNTYPED_ALIGN:
+ return untyped_align(target_obj);
+ case SYSCALL_UNTYPED_SPLIT:
+ return s_syscall_untyped_split(objdir, target_obj, payload_bytes, payload);
+ default:
+ kprintf("syscall_untyped: Untyped object does not support syscall %i\n", header->callid);
+ return EBADARG;
+ }
+ return 0;
+}