diff options
| author | Jon Santmyer <jon@jonsantmyer.com> | 2026-09-07 19:19:24 -0400 |
|---|---|---|
| committer | Jon Santmyer <jon@jonsantmyer.com> | 2026-09-07 19:19:24 -0400 |
| commit | df0688efa326a03a22bcbc36d1900926b7b1c986 (patch) | |
| tree | c67df82b0a6cd94693278a809ed0c9a69daf840f /hal | |
| parent | 4ca0bdf61196d0c3fd3f0fdbfb2d72481025cca2 (diff) | |
| download | jove-kernel-df0688efa326a03a22bcbc36d1900926b7b1c986.tar.gz jove-kernel-df0688efa326a03a22bcbc36d1900926b7b1c986.tar.bz2 jove-kernel-df0688efa326a03a22bcbc36d1900926b7b1c986.zip | |
split syscall info into api subfolder. untyped syscalls
Diffstat (limited to 'hal')
| -rw-r--r-- | hal/memory.h | 12 | ||||
| -rw-r--r-- | hal/obj.h | 15 | ||||
| -rw-r--r-- | hal/untyped.c | 54 |
3 files changed, 65 insertions, 16 deletions
diff --git a/hal/memory.h b/hal/memory.h index 4d866d0..659263c 100644 --- a/hal/memory.h +++ b/hal/memory.h @@ -1,16 +1,24 @@ #ifndef _JOVE_HAL_MEMORY_H #define _JOVE_HAL_MEMORY_H 1 -#include <stddef.h> -#include <stdint.h> +#include "obj.h" typedef struct jove_obj_untyped { size_t limit; } jove_untyped_t; +#define JOVE_UNTYPED_MINSIZE 0x10 + void mem_setup_untyped(void); void *phys_tovirt(uintptr_t phys); +size_t untyped_size(jove_owned_obj_t *tgt); +size_t untyped_align(jove_owned_obj_t *tgt); + +int untyped_split(jove_owned_obj_t *tgt, jove_owned_obj_t *dst, size_t bytes); +int untyped_merge(jove_owned_obj_t *a, jove_owned_obj_t *b); +int untyped_retype(jove_owned_obj_t *tgt, uint8_t newtype); + #endif @@ -3,20 +3,7 @@ #include <stddef.h> -enum -{ - JOVE_OBJ_NONE = 0, - JOVE_OBJ_UNTYPED, - JOVE_OBJ_OBJDIR, - JOVE_OBJ_PAGEDIR, - JOVE_OBJ_PROCESSOR, - JOVE_OBJ_PROCESS, - JOVE_OBJ_PAGEFRAME, - JOVE_OBJ_INITRD_FILE, - JOVE_OBJ_FRAMEBUFFER, - JOVE_OBJ_VIRTTERM, - JOVE_OBJ_MESSAGE -}; +#include "api/obj.h" #ifdef __x86_64__ #include "arch/x86_64/hal/obj.h" diff --git a/hal/untyped.c b/hal/untyped.c new file mode 100644 index 0000000..243f3ec --- /dev/null +++ b/hal/untyped.c @@ -0,0 +1,54 @@ +#include "arch/x86_64/hal/obj.h" +#include "jove.h" +#include "memory.h" + +size_t +untyped_size(jove_owned_obj_t *tgt) +{ + return ((jove_untyped_t*)obj_deref(tgt))->limit; +} + +size_t +untyped_align(jove_owned_obj_t *tgt) +{ + return (uintptr_t)obj_deref(tgt) & 0xFFF; +} + +int +untyped_split(jove_owned_obj_t *tgt, jove_owned_obj_t *dst, size_t bytes) +{ + jove_untyped_t *tgt_untyped = obj_deref(tgt); + if(bytes < JOVE_UNTYPED_MINSIZE) return EBADARG; + if(tgt_untyped->limit - bytes < JOVE_UNTYPED_MINSIZE) return ETOOSMALL; + + tgt_untyped->limit -= bytes; + obj_settype(dst, JOVE_OBJ_UNTYPED); + obj_setvalue(dst, (uintptr_t)tgt_untyped + tgt_untyped->limit); + + jove_untyped_t *dst_untyped = obj_deref(dst); + dst_untyped->limit = bytes; + return 0; +} + +int +untyped_merge(jove_owned_obj_t *a, jove_owned_obj_t *b) +{ + jove_untyped_t *a_untyped = obj_deref(a); + jove_untyped_t *b_untyped = obj_deref(b); + if((uintptr_t)a_untyped + a_untyped->limit == (uintptr_t)b_untyped) { + return EBADARG; + } + if((uintptr_t)b_untyped + b_untyped->limit == (uintptr_t)a_untyped) { + return untyped_merge(b, a); + } + + a_untyped->limit += b_untyped->limit; + obj_settype(b, JOVE_OBJ_NONE); + return 0; +} + +int untyped_retype(jove_owned_obj_t *tgt, uint8_t newtype) +{ + obj_settype(tgt, newtype); + return 0; +} |
