diff options
| author | Jon Santmyer <jon@jonsantmyer.com> | 2026-09-11 11:16:36 -0400 |
|---|---|---|
| committer | Jon Santmyer <jon@jonsantmyer.com> | 2026-09-11 11:16:36 -0400 |
| commit | bb08472a04127c994d3ea5a2cbc195f7116a03b8 (patch) | |
| tree | c55910449fae5cc2a722c4b6619f4c8dde8d5b56 /arch/x86_64 | |
| parent | 880dc3ee72809e74a5bde2275fc8f419a762b255 (diff) | |
| download | jove-kernel-bb08472a04127c994d3ea5a2cbc195f7116a03b8.tar.gz jove-kernel-bb08472a04127c994d3ea5a2cbc195f7116a03b8.tar.bz2 jove-kernel-bb08472a04127c994d3ea5a2cbc195f7116a03b8.zip | |
preliminary object linking support. needs testing
Diffstat (limited to 'arch/x86_64')
| -rw-r--r-- | arch/x86_64/hal/obj.c | 15 | ||||
| -rw-r--r-- | arch/x86_64/hal/obj.h | 11 | ||||
| -rw-r--r-- | arch/x86_64/sys/init.c | 1 | ||||
| -rw-r--r-- | arch/x86_64/sys/link.c | 19 |
4 files changed, 30 insertions, 16 deletions
diff --git a/arch/x86_64/hal/obj.c b/arch/x86_64/hal/obj.c index 8011347..c5d5c69 100644 --- a/arch/x86_64/hal/obj.c +++ b/arch/x86_64/hal/obj.c @@ -3,6 +3,7 @@ #include "paging.h" #include "hal/obj.h" #include "jove.h" +#include "sys/link.h" jove_owned_obj_t* obj_take(jove_obj_t *obj) @@ -20,7 +21,7 @@ obj_release(jove_owned_obj_t *obj) if((uintptr_t)obj < IDENT_VIRT_BASE) { reterr(EBADOBJ); } - release_mutex((atomic_flag*)&obj->lock); + release_mutex((atomic_flag*)&obj->locked.lock); return (jove_obj_t*)obj; } @@ -33,25 +34,25 @@ obj_deref(jove_owned_obj_t *obj) uint8_t obj_gettype(jove_owned_obj_t *obj) { - return obj->type; + return obj->locked.type; } void obj_settype(jove_owned_obj_t *obj, uint8_t type) { - obj->type = type; + obj->locked.type = type; } uintmax_t obj_getvalue(jove_owned_obj_t *obj) { - return obj->value; + return obj->locked.value; } void obj_setvalue(jove_owned_obj_t *obj, uintmax_t value) { - obj->value = value & 0x00007FFFFFFFFFFFULL; + obj->locked.value = value & 0x00007FFFFFFFFFFFULL; } jove_owned_obj_t* @@ -59,14 +60,14 @@ objdir_getlocal( jove_owned_obj_t *objdir_obj, uint16_t entry) { - if(objdir_obj->type != JOVE_OBJ_OBJDIR) { + if(obj_gettype_linked(objdir_obj) != JOVE_OBJ_OBJDIR) { reterr(EBADOBJ); } if(entry >= JOVE_OBJDIR_ENTRIES) { reterr(EOOB); } - jove_objdir_t *objtab = obj_deref(objdir_obj); + jove_objdir_t *objtab = obj_deref_linked(objdir_obj); return obj_take(&objtab->entries[entry]); } diff --git a/arch/x86_64/hal/obj.h b/arch/x86_64/hal/obj.h index 78d7383..fcb7506 100644 --- a/arch/x86_64/hal/obj.h +++ b/arch/x86_64/hal/obj.h @@ -7,7 +7,7 @@ enum { - JOVE_OBJ_SERIAL_COM = 0x80, + JOVE_OBJ_SERIAL_COM = 0x40, }; /*Represents a locked kernel object pointer inside of a object directory.*/ @@ -25,14 +25,9 @@ typedef union jove_obj /*Represents an unlocked kernel object pointer. *This object should only exist temporarily while accessing the underlying *structure this object points to.*/ -typedef union jove_obj_locked +typedef struct jove_locked_obj { - struct { - uint8_t type; - uint8_t lock; - uint64_t value : 48; - }; - uintmax_t data; + jove_obj_t locked; } jove_owned_obj_t; /*Object directories are always 1 page wide. Since an object inside the directory diff --git a/arch/x86_64/sys/init.c b/arch/x86_64/sys/init.c index cecca32..681ba09 100644 --- a/arch/x86_64/sys/init.c +++ b/arch/x86_64/sys/init.c @@ -134,7 +134,6 @@ init_setup(void) } //Copy data from section if SHT_PROGBITS - kprintf("init: load %p : %p\n", base, limit); memcpy((void*)phdr->p_vaddr, init_data + phdr->p_offset, phdr->p_memsz); } diff --git a/arch/x86_64/sys/link.c b/arch/x86_64/sys/link.c new file mode 100644 index 0000000..96f8eeb --- /dev/null +++ b/arch/x86_64/sys/link.c @@ -0,0 +1,19 @@ +#include "sys/link.h" + +jove_obj_t +link_unlink(jove_owned_obj_t *link) +{ + struct obj_link *linkval = obj_deref(link); + if(--linkval->refcount == 1) { + jove_obj_t held_obj = linkval->obj; + link->locked = held_obj; + return (jove_obj_t) { + .lock = 0, + .type = JOVE_OBJ_UNTYPED, + .value = (uintptr_t)linkval + }; + }else{ + obj_settype(link, JOVE_OBJ_NONE); + } + return (jove_obj_t) { 0 }; +} |
