summaryrefslogtreecommitdiffstats
path: root/hal/shmem.c
diff options
context:
space:
mode:
authorJon Santmyer <jon@jonsantmyer.com>2026-10-09 10:24:41 -0400
committerJon Santmyer <jon@jonsantmyer.com>2026-10-09 10:24:41 -0400
commitcc23ea5a4b38807e79aceb23e6f43e965926618f (patch)
tree90142bb44186f4dad7bbd82d3d53655b835c822b /hal/shmem.c
parent434ddcd907832b1febc7d70e4faa52109c7eb3bd (diff)
downloadjove-kernel-cc23ea5a4b38807e79aceb23e6f43e965926618f.tar.gz
jove-kernel-cc23ea5a4b38807e79aceb23e6f43e965926618f.tar.bz2
jove-kernel-cc23ea5a4b38807e79aceb23e6f43e965926618f.zip
add basic scheduler logic. rename init rootdir indexes
Diffstat (limited to 'hal/shmem.c')
-rw-r--r--hal/shmem.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/hal/shmem.c b/hal/shmem.c
new file mode 100644
index 0000000..3785c2e
--- /dev/null
+++ b/hal/shmem.c
@@ -0,0 +1,20 @@
+#include "api/error.h"
+#include "hal/obj.h"
+#include "lib/string.h"
+#include "memory.h"
+
+int
+shmem_new(jove_owned_obj_t *untyped_obj)
+{
+ jove_untyped_t *untyped = obj_deref(untyped_obj);
+ if((uintptr_t)untyped & 0xFFF) return -EALIGN;
+ if(untyped->limit & 0xFFF) return -EBADSIZE;
+
+ size_t limit_pages = untyped->limit >> 12;
+ if(limit_pages > JOVE_SMHEM_MAXPAGES) return -ETOOBIG;
+
+ obj_setvalue(untyped_obj, (uintptr_t)untyped | limit_pages);
+ obj_settype(untyped_obj, JOVE_OBJ_SHMEMORY);
+ memset(untyped, 0, untyped->limit);
+ return 0;
+}