From 73cbb23130f634bf52ac92da063efd3e6016f8ee Mon Sep 17 00:00:00 2001 From: Jon Santmyer Date: Sat, 5 Sep 2026 11:38:27 -0400 Subject: make objdir_getlocal return locked object --- arch/x86_64/hal/obj.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'arch/x86_64/hal/obj.c') diff --git a/arch/x86_64/hal/obj.c b/arch/x86_64/hal/obj.c index 783d2f4..8011347 100644 --- a/arch/x86_64/hal/obj.c +++ b/arch/x86_64/hal/obj.c @@ -1,11 +1,15 @@ #include "obj.h" #include "arch/x86_64/lock.h" +#include "paging.h" #include "hal/obj.h" #include "jove.h" jove_owned_obj_t* obj_take(jove_obj_t *obj) { + if((uintptr_t)obj < IDENT_VIRT_BASE) { + reterr(EBADOBJ); + } take_mutex(&obj->lock); return (jove_owned_obj_t*)obj; } @@ -13,6 +17,9 @@ obj_take(jove_obj_t *obj) jove_obj_t* obj_release(jove_owned_obj_t *obj) { + if((uintptr_t)obj < IDENT_VIRT_BASE) { + reterr(EBADOBJ); + } release_mutex((atomic_flag*)&obj->lock); return (jove_obj_t*)obj; } @@ -47,7 +54,7 @@ obj_setvalue(jove_owned_obj_t *obj, uintmax_t value) obj->value = value & 0x00007FFFFFFFFFFFULL; } -jove_obj_t* +jove_owned_obj_t* objdir_getlocal( jove_owned_obj_t *objdir_obj, uint16_t entry) @@ -60,7 +67,7 @@ objdir_getlocal( } jove_objdir_t *objtab = obj_deref(objdir_obj); - return &objtab->entries[entry]; + return obj_take(&objtab->entries[entry]); } jove_owned_obj_t* @@ -73,12 +80,11 @@ objdir_getobj( return objdir_obj; } { - jove_obj_t *child_locked_objdir = objdir_getlocal(objdir_obj, path[0]); - if(child_locked_objdir == NULL) { + jove_owned_obj_t *child_objdir = objdir_getlocal(objdir_obj, path[0]); + if(child_objdir == 0) { return 0; } - jove_owned_obj_t *child_objdir = obj_take(child_locked_objdir); jove_owned_obj_t *target_obj = objdir_getobj(child_objdir, path + 1, path_len - 1); obj_release(child_objdir); return target_obj; -- cgit v1.2.3