summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorJon Santmyer <jon@jonsantmyer.com>2026-10-17 16:21:55 -0400
committerJon Santmyer <jon@jonsantmyer.com>2026-10-17 16:21:55 -0400
commitb2920331b103d43793ac8be927a80a593ce0be5a (patch)
treea91934ff588ffe02697b530899c8c0227521e04a /sys
parentd8aca3ff2501f9a77e22e5afb7a30380aed205af (diff)
downloadjove-kernel-b2920331b103d43793ac8be927a80a593ce0be5a.tar.gz
jove-kernel-b2920331b103d43793ac8be927a80a593ce0be5a.tar.bz2
jove-kernel-b2920331b103d43793ac8be927a80a593ce0be5a.zip
add pcb stop syscall and scheduler dequeueingHEADmain
Diffstat (limited to 'sys')
-rw-r--r--sys/objdir.h7
-rw-r--r--sys/syscall_objdir.c2
-rw-r--r--sys/syscall_pcb.c45
3 files changed, 53 insertions, 1 deletions
diff --git a/sys/objdir.h b/sys/objdir.h
index 4ef6d04..8ef602d 100644
--- a/sys/objdir.h
+++ b/sys/objdir.h
@@ -4,6 +4,13 @@
#include "api/obj.h"
#include "hal/obj.h"
+typedef struct jove_objdir
+{
+ jove_obj_t entries[OBJDIR_ENTRIES];
+} jove_objdir_t;
+
+jove_objdir_t *obj_getobjdir(jove_obj_t *obj);
+
int objdir_new(jove_owned_obj_t *untyped_obj);
/*Returns the n'th entry of the object directory passed.
* If the passed object is not an objdir, returns NULL and sets errno to EBADOBJ.
diff --git a/sys/syscall_objdir.c b/sys/syscall_objdir.c
index 8a17671..28eba68 100644
--- a/sys/syscall_objdir.c
+++ b/sys/syscall_objdir.c
@@ -18,7 +18,7 @@ s_syscall_objdir_objtype(
uint16_t local_idx = *((uint16_t*)payload_data);
if(local_idx > OBJDIR_ENTRIES) {
- kprintf("%s: Object index is out of bounds (>= 512)\n", __func__);
+ kprintf("%s: Object index is out of bounds (%i >= 512)\n", __func__, local_idx);
return EOOB;
}
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;
}