diff options
| author | Jon Santmyer <jon@jonsantmyer.com> | 2026-10-17 16:21:55 -0400 |
|---|---|---|
| committer | Jon Santmyer <jon@jonsantmyer.com> | 2026-10-17 16:21:55 -0400 |
| commit | b2920331b103d43793ac8be927a80a593ce0be5a (patch) | |
| tree | a91934ff588ffe02697b530899c8c0227521e04a /sys/syscall_pcb.c | |
| parent | d8aca3ff2501f9a77e22e5afb7a30380aed205af (diff) | |
| download | jove-kernel-main.tar.gz jove-kernel-main.tar.bz2 jove-kernel-main.zip | |
Diffstat (limited to 'sys/syscall_pcb.c')
| -rw-r--r-- | sys/syscall_pcb.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/sys/syscall_pcb.c b/sys/syscall_pcb.c index 7a6d4e3..19699ce 100644 --- a/sys/syscall_pcb.c +++ b/sys/syscall_pcb.c @@ -5,6 +5,7 @@ #include "lib/printf.h" #include "proc/process.h" #include "proc/scheduler.h" +#include "sys/objdir.h" #include "syscall.h" int @@ -242,6 +243,40 @@ s_syscall_pcb_stack(jove_owned_obj_t *pcb_obj, return 0; } +int s_syscall_pcb_ready( + jove_owned_obj_t *target_obj, + lockstack_t *lockstack, + jove_obj_t *objdir) +{ + jove_objdir_t *target_objdir = obj_getobjdir(obj_asunowned(target_obj)); + if(!obj_compare(&target_objdir->entries[PCB_ROOTDIR_SELF_I], obj_asunowned(target_obj))) { + klogf("Target PCB is not in entry %i of it's objdir!\n", PCB_ROOTDIR_SELF_I); + return -EBADPATH; + } + + jove_owned_obj_t *pagedir_obj = obj_take(&target_objdir->entries[PCB_ROOTDIR_PAGEDIR_I]); + if(obj_gettype(pagedir_obj) != JOVE_OBJ_PAGEDIR) { + klogf("Target PCB rootdir does not have pagedir in entry %i\n", PCB_ROOTDIR_PAGEDIR_I); + obj_release(pagedir_obj); + return -EBADPATH; + } + + obj_release(pagedir_obj); + return 0; +} + +int +s_syscall_pcb_stop(jove_owned_obj_t *pcb_obj, + size_t bytes_left, + void *payload_data) +{ + size_t bytes_needed = sizeof(int); + CHECK_TOOSMALL(bytes_needed, bytes_left, "Message too small for payload"); + + int stop_code = *((int*)payload_data); + return scheduler_stop(pcb_obj, stop_code); +} + int _syscall_handle_pcb(syscall_context_t *ctx) { @@ -275,6 +310,16 @@ _syscall_handle_pcb(syscall_context_t *ctx) ctx->target.obj, &ctx->lockstack, ctx->objdir, ctx->bytes_left, ctx->payload); return -EPERM; + case SYSCALL_PCB_READY: + if(ctx->target.permissions & SYSCALL_PERM_PCB_READY) + return s_syscall_pcb_ready( + ctx->target.obj, &ctx->lockstack, ctx->objdir); + return -EPERM; + case SYSCALL_PCB_STOP: + if(ctx->target.permissions & SYSCALL_PERM_PCB_STOP) + return s_syscall_pcb_stop( + ctx->target.obj, ctx->bytes_left, ctx->payload); + default: return -EBADCALL; } |
