From cc23ea5a4b38807e79aceb23e6f43e965926618f Mon Sep 17 00:00:00 2001 From: Jon Santmyer Date: Fri, 9 Oct 2026 10:24:41 -0400 Subject: add basic scheduler logic. rename init rootdir indexes --- sys/syscall_untyped.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'sys/syscall_untyped.c') diff --git a/sys/syscall_untyped.c b/sys/syscall_untyped.c index 8fe592d..1ec21c7 100644 --- a/sys/syscall_untyped.c +++ b/sys/syscall_untyped.c @@ -2,6 +2,7 @@ #include "hal/memory.h" #include "jove.h" #include "lib/printf.h" +#include "proc/process.h" #include "syscall.h" static int @@ -73,6 +74,27 @@ s_syscall_untyped_merge( return sysret; } +int +s_syscall_untyped_retype_pcb(jove_owned_obj_t *untyped_obj, + lockstack_t *lockstack, + jove_owned_obj_t *rootdir, + struct syscall_header *header) +{ + jove_untyped_t *untyped = obj_deref(untyped_obj); + CHECK_TOOSMALL(PCB_MINSIZE, untyped->limit, "Untyped object too small for PCB"); + + jove_perm_obj_t objdir_obj = link_try_traverse_objdir( + rootdir, lockstack, header->pathlen - 1, header->path); + if(errno) { + klogf("Unable to retrieve parent objdir at %P\n", + header->path, header->pathlen - 1); + return -errno; + } + CHECK_OBJPERM(objdir_obj, JOVE_PERM_ALL, "New PCB needs full access to it's root objdir!"); + + obj_settype(untyped_obj, JOVE_OBJ_PCB); + return pcb_new(untyped_obj, untyped->limit, objdir_obj.obj); +} int _syscall_handle_untyped(syscall_context_t *ctx) { @@ -99,6 +121,27 @@ int _syscall_handle_untyped(syscall_context_t *ctx) &ctx->lockstack, ctx->objdir, ctx->target.obj, ctx->bytes_left, ctx->payload); return -EPERM; + case SYSCALL_UNTYPED_RETYPE_OBJDIR: + if(ctx->target.permissions & SYSCALL_PERM_UNTYPED_RETYPE) + return objdir_new(ctx->target.obj); + return -EPERM; + + case SYSCALL_UNTYPED_RETYPE_PAGEDIR: + if(ctx->target.permissions & SYSCALL_PERM_UNTYPED_RETYPE) + return pagedir_new(ctx->target.obj); + return -EPERM; + + case SYSCALL_UNTYPED_RETYPE_SHMEMORY: + if(ctx->target.permissions & SYSCALL_PERM_UNTYPED_RETYPE) + return shmem_new(ctx->target.obj); + return -EPERM; + + case SYSCALL_UNTYPED_RETYPE_PCB: + if(ctx->target.permissions & SYSCALL_PERM_UNTYPED_RETYPE) + return s_syscall_untyped_retype_pcb( + ctx->target.obj, &ctx->lockstack, ctx->objdir, ctx->header); + return -EPERM; + default: return -EBADCALL; } -- cgit v1.2.3