summaryrefslogtreecommitdiffstats
path: root/sys/syscall_pcb.c
diff options
context:
space:
mode:
authorJon Santmyer <jon@jonsantmyer.com>2026-10-16 16:42:22 -0400
committerJon Santmyer <jon@jonsantmyer.com>2026-10-16 16:42:22 -0400
commitd8aca3ff2501f9a77e22e5afb7a30380aed205af (patch)
treea27db1749a35aea07317406f170a2d9b2a799ce7 /sys/syscall_pcb.c
parent548506392b789f58b1556a6ffca917441e1d89fd (diff)
downloadjove-kernel-d8aca3ff2501f9a77e22e5afb7a30380aed205af.tar.gz
jove-kernel-d8aca3ff2501f9a77e22e5afb7a30380aed205af.tar.bz2
jove-kernel-d8aca3ff2501f9a77e22e5afb7a30380aed205af.zip
remove explicit framebuffer in kernel. reduce locking in syscalls
Diffstat (limited to 'sys/syscall_pcb.c')
-rw-r--r--sys/syscall_pcb.c84
1 files changed, 46 insertions, 38 deletions
diff --git a/sys/syscall_pcb.c b/sys/syscall_pcb.c
index 3aeb22b..7a6d4e3 100644
--- a/sys/syscall_pcb.c
+++ b/sys/syscall_pcb.c
@@ -12,7 +12,7 @@ s_syscall_pcb_yield(jove_owned_obj_t *pcb_obj,
size_t bytes_left,
void *payload_data)
{
- //Validate that message is big enough for payload
+ //Verify message is big enough for payload
size_t bytes_needed = sizeof(pid_t);
CHECK_TOOSMALL(bytes_needed, bytes_left, "Message too small for payload");
@@ -26,40 +26,43 @@ s_syscall_pcb_yield(jove_owned_obj_t *pcb_obj,
int
s_syscall_pcb_send(jove_owned_obj_t *pcb_obj,
lockstack_t *lockstack,
- jove_owned_obj_t *objdir_obj,
+ jove_obj_t *objdir_obj,
size_t bytes_left,
void *payload_data)
{
- //Validate that message is big enough for payload.
+ //Verify message is big enough for payload.
size_t bytes_needed = sizeof(struct syscall_pcb_send);
CHECK_TOOSMALL(bytes_needed, bytes_left, "Message too small for payload");
struct syscall_pcb_send *payload = payload_data;
- //Validate that message is big enough for payload object path.
+ //Verify message is big enough for payload object path.
bytes_needed += payload->send_path_length;
CHECK_TOOSMALL(bytes_needed, bytes_left, "Message too small for subject path");
- //Validate that subject object path is not the root directory.
+ //Verify subject object path is not the root directory.
if(payload->send_path_length == 0) {
kprintf("%s: Unable to send root directory\n", __func__);
return -EBADPATH;
}
- //Validate that the subject objdir path is valid.
- jove_perm_obj_t subject_objdir = link_try_traverse_objdir(
- objdir_obj, lockstack, payload->send_path_length - 1, payload->send_path);
- if(errno) {
+ //Verify the subject objdir path is valid.
+ jove_perm_obj_t subject_objdir = link_traverse_objdir(objdir_obj, payload->send_path_length - 1, payload->send_path);
+
+ if(subject_objdir.obj == NULL) {
klogf("Unable to get subject %P objdir : %s\n",
payload->send_path, payload->send_path_length, errstr(errno));
+ obj_release(subject_objdir.obj);
return -errno;
}
- //Validate that the currently running PCB has mutate permissions for this objdir.
+ //Verify the currently running PCB has mutate permissions for this objdir.
CHECK_OBJPERM(subject_objdir, SYSCALL_PERM_PCB_SEND_OBJDIR, "Subject objdir does not permit send");
- //Validate that the subject exists in the subject objdir.
- jove_owned_obj_t *subject = objdir_trygetlocal(subject_objdir.obj,
- payload->send_path[payload->send_path_length-1]);
+ //Verify the subject exists in the subject objdir.
+ jove_owned_obj_t *subject = objdir_getlocal(
+ obj_release(subject_objdir.obj), payload->send_path[payload->send_path_length-1]);
+ lockstack_push(lockstack, subject);
+
if(subject == 0) {
klogf("Unable to get subject %P object : %s\n",
payload->send_path, payload->send_path_length, errstr(errno));
@@ -73,29 +76,30 @@ s_syscall_pcb_send(jove_owned_obj_t *pcb_obj,
int
s_syscall_pcb_recv(jove_owned_obj_t *pcb_obj,
lockstack_t *lockstack,
- jove_owned_obj_t *objdir_obj,
+ jove_obj_t *objdir_obj,
size_t bytes_left,
void *payload_data)
{
- //Validate that the message is big enough for the payload.
+ //Verify the message is big enough for the payload.
size_t bytes_needed = sizeof(struct syscall_pcb_recv);
CHECK_TOOSMALL(bytes_needed, bytes_left, "Message too small for payload");
struct syscall_pcb_recv *payload = payload_data;
- //Validate that the message is big enough for the payload object.
+ //Verify the message is big enough for the payload object.
bytes_needed += payload->recv_path_length * sizeof(objpath_part_t);
CHECK_TOOSMALL(bytes_needed, bytes_left, "Message too small for destination path");
- //Validate that the destination object exists.
- jove_perm_obj_t destination = link_try_traverse_objdir(
- objdir_obj, lockstack, payload->recv_path_length, payload->recv_path);
+ //Verify the destination object exists.
+ jove_perm_obj_t destination = link_traverse_objdir(objdir_obj, payload->recv_path_length, payload->recv_path);
+ lockstack_push(lockstack, destination.obj);
+
if(errno) {
klogf("Unable to get destination %P : %s\n",
payload->recv_path, payload->recv_path_length, errstr(errno));
return -errno;
}
- //Validate that the destination path is JOVE_OBJ_NONE and that the object has recieve permissions.
+ //Verify the destination path is JOVE_OBJ_NONE and that the object has recieve permissions.
CHECK_OBJTYPE(destination.obj, JOVE_OBJ_NONE, "Destination object is occupied");
CHECK_OBJPERM(destination, SYSCALL_PERM_PCB_RECV_DST, "Destination object does not permit recv.");
@@ -106,52 +110,55 @@ s_syscall_pcb_recv(jove_owned_obj_t *pcb_obj,
int
s_syscall_pcb_swap(jove_owned_obj_t *pcb_obj,
lockstack_t *lockstack,
- jove_owned_obj_t *objdir_obj,
+ jove_obj_t *objdir_obj,
size_t bytes_left,
void *payload_data)
{
- //Validate that the message is big enough for payload.
+ //Verify the message is big enough for payload.
size_t bytes_needed = sizeof(struct syscall_pcb_recv);
CHECK_TOOSMALL(bytes_needed, bytes_left, "Message too small for payload");
struct syscall_pcb_swap *payload = payload_data;
- //Validate that the message is big enough for the subject path.
+ //Verify the message is big enough for the subject path.
bytes_needed += payload->swap_path_length * sizeof(objpath_part_t);
CHECK_TOOSMALL(bytes_needed, bytes_left, "Message too small for swap path");
- //Validate that the subject is not the rootdir.
+ //Verify the subject is not the rootdir.
if(payload->swap_path_length == 0) {
kprintf("%s: Unable to swap the root directory\n", __func__);
return -EBADPATH;
}
- //Validate that the subject objdir exists.
- jove_perm_obj_t subject_objdir = link_try_traverse_objdir(
- objdir_obj, lockstack, payload->swap_path_length - 1, payload->swap_path);
- if(errno) {
+ //Verify the subject objdir exists.
+ jove_perm_obj_t subject_objdir = link_traverse_objdir(objdir_obj, payload->swap_path_length - 1, payload->swap_path);
+
+ if(subject_objdir.obj == NULL) {
klogf("Unable to get subject %P objdir : %s\n",
payload->swap_path, payload->swap_path_length, errstr(errno));
+ obj_release(subject_objdir.obj);
return -errno;
}
- //Validate that the subject objdir has send permissions.
+ //Verify the subject objdir has send permissions.
CHECK_OBJPERM(subject_objdir, SYSCALL_PERM_PCB_SEND_OBJDIR, "Subject objdir does not permit send");
- //Validate that the subject object exists.
- jove_owned_obj_t *subject = objdir_trygetlocal(subject_objdir.obj,
- payload->swap_path[payload->swap_path_length-1]);
+ //Verify the subject object exists.
+ jove_owned_obj_t *subject = objdir_getlocal(
+ obj_release(subject_objdir.obj), payload->swap_path[payload->swap_path_length-1]);
+ lockstack_push(lockstack, subject);
+
if(subject == 0) {
klogf("Unable to get subject %P object : %s\n",
payload->swap_path, payload->swap_path_length, errstr(errno));
return -errno;
}
- //Validate that the target PCB exists.
+ //Verify the target PCB exists.
if(pcb_frompid(payload->swap_target) == 0) {
klogf("Swap PCB target %i does not exist\n", payload->swap_target);
return -EBADPROC;
}
- //Validate that the message was sent before timeout.
+ //Verify the message was sent before timeout.
int send_result = pcb_send(
obj_deref(pcb_obj), payload->swap_target, subject, payload->send_timeout);
if(send_result < 0) {
@@ -159,7 +166,7 @@ s_syscall_pcb_swap(jove_owned_obj_t *pcb_obj,
return send_result;
}
- //Validate that a message was recieved before timeout.
+ //Verify a message was recieved before timeout.
int recv_result = pcb_recv(
obj_deref(pcb_obj), payload->swap_target, subject, payload->recv_timeout);
return recv_result;
@@ -168,7 +175,7 @@ s_syscall_pcb_swap(jove_owned_obj_t *pcb_obj,
int
s_syscall_pcb_stack(jove_owned_obj_t *pcb_obj,
lockstack_t *lockstack,
- jove_owned_obj_t *rootdir,
+ jove_obj_t *rootdir,
size_t bytes_left,
void *payload_data)
{
@@ -181,8 +188,9 @@ s_syscall_pcb_stack(jove_owned_obj_t *pcb_obj,
bytes_needed += sizeof(objpath_part_t) * payload->stack_path_length;
CHECK_TOOSMALL(bytes_needed, bytes_left, "Message too small for untyped path");
- jove_perm_obj_t untyped = link_try_traverse_objdir(rootdir, lockstack,
- payload->stack_path_length, payload->stack_path);
+ jove_perm_obj_t untyped = link_traverse_objdir(rootdir, payload->stack_path_length, payload->stack_path);
+ lockstack_push(lockstack, untyped.obj);
+
//Verify the untyped object exists.
if(untyped.obj == NULL) {
klogf("Unable to get untyped %P : %s\n",