summaryrefslogtreecommitdiffstats
path: root/arch/x86_64/hal/obj.c
diff options
context:
space:
mode:
authorJon Santmyer <jon@jonsantmyer.com>2026-09-04 11:31:40 -0400
committerJon Santmyer <jon@jonsantmyer.com>2026-09-04 11:31:40 -0400
commit8251da342161767fe203627223ccd4a7026701c6 (patch)
treeaf2db0f11b0ea8ad35f88663a855bab39a80f679 /arch/x86_64/hal/obj.c
downloadjove-kernel-8251da342161767fe203627223ccd4a7026701c6.tar.gz
jove-kernel-8251da342161767fe203627223ccd4a7026701c6.tar.bz2
jove-kernel-8251da342161767fe203627223ccd4a7026701c6.zip
initial commit. working on tasking
Diffstat (limited to 'arch/x86_64/hal/obj.c')
-rw-r--r--arch/x86_64/hal/obj.c87
1 files changed, 87 insertions, 0 deletions
diff --git a/arch/x86_64/hal/obj.c b/arch/x86_64/hal/obj.c
new file mode 100644
index 0000000..783d2f4
--- /dev/null
+++ b/arch/x86_64/hal/obj.c
@@ -0,0 +1,87 @@
+#include "obj.h"
+#include "arch/x86_64/lock.h"
+#include "hal/obj.h"
+#include "jove.h"
+
+jove_owned_obj_t*
+obj_take(jove_obj_t *obj)
+{
+ take_mutex(&obj->lock);
+ return (jove_owned_obj_t*)obj;
+}
+
+jove_obj_t*
+obj_release(jove_owned_obj_t *obj)
+{
+ release_mutex((atomic_flag*)&obj->lock);
+ return (jove_obj_t*)obj;
+}
+
+void*
+obj_deref(jove_owned_obj_t *obj)
+{
+ return (void*)(((uintptr_t)obj_getvalue(obj)) | 0xFFFF800000000000ULL);
+}
+
+uint8_t
+obj_gettype(jove_owned_obj_t *obj)
+{
+ return obj->type;
+}
+
+void
+obj_settype(jove_owned_obj_t *obj, uint8_t type)
+{
+ obj->type = type;
+}
+
+uintmax_t
+obj_getvalue(jove_owned_obj_t *obj)
+{
+ return obj->value;
+}
+
+void
+obj_setvalue(jove_owned_obj_t *obj, uintmax_t value)
+{
+ obj->value = value & 0x00007FFFFFFFFFFFULL;
+}
+
+jove_obj_t*
+objdir_getlocal(
+ jove_owned_obj_t *objdir_obj,
+ uint16_t entry)
+{
+ if(objdir_obj->type != JOVE_OBJ_OBJDIR) {
+ reterr(EBADOBJ);
+ }
+ if(entry >= JOVE_OBJDIR_ENTRIES) {
+ reterr(EOOB);
+ }
+
+ jove_objdir_t *objtab = obj_deref(objdir_obj);
+ return &objtab->entries[entry];
+}
+
+jove_owned_obj_t*
+objdir_getobj(
+ jove_owned_obj_t *objdir_obj,
+ const uint16_t *path,
+ size_t path_len)
+{
+ if(path_len == 0) {
+ return objdir_obj;
+ }
+ {
+ jove_obj_t *child_locked_objdir = objdir_getlocal(objdir_obj, path[0]);
+ if(child_locked_objdir == NULL) {
+ 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;
+ }
+}
+