summaryrefslogtreecommitdiffstats
path: root/hal
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
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')
-rw-r--r--hal/memory.h4
-rw-r--r--hal/obj.h20
-rw-r--r--hal/shmem.c20
-rw-r--r--hal/smp.h5
4 files changed, 29 insertions, 20 deletions
diff --git a/hal/memory.h b/hal/memory.h
index 84cb7f2..1aec7e9 100644
--- a/hal/memory.h
+++ b/hal/memory.h
@@ -32,6 +32,7 @@ typedef struct jove_obj_untyped
} jove_untyped_t;
#define JOVE_UNTYPED_MINSIZE 0x10
+#define JOVE_SMHEM_MAXPAGES 0xFFF
void mem_setup_regions(void);
@@ -57,6 +58,8 @@ size_t untyped_size(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 pagedir_new(jove_owned_obj_t *untyped_obj);
+
void pagedir_invlpg(virtaddr_t vptr);
virtaddr_t *pagedir_get_mapping(
@@ -82,5 +85,6 @@ int pagedir_unmap_untyped_table(
int pagedir_unmap_shmem_frame(
jove_owned_obj_t *tgt, uintptr_t vptr);
+int shmem_new(jove_owned_obj_t *untyped_obj);
#endif
diff --git a/hal/obj.h b/hal/obj.h
index 68f4bdc..5a48eb2 100644
--- a/hal/obj.h
+++ b/hal/obj.h
@@ -17,6 +17,7 @@ typedef struct jove_objdir
/*Locks the mutex of the kernel object provided. Returns the locked version. */
jove_owned_obj_t *obj_take(jove_obj_t *obj);
jove_owned_obj_t *obj_trytake(jove_obj_t *obj);
+jove_obj_t *obj_asunowned(jove_owned_obj_t *obj);
/*Unlocks the mutex of the kernel object provided. Returns the unlocked version. */
jove_obj_t *obj_release(jove_owned_obj_t *obj);
@@ -32,23 +33,4 @@ void obj_settype(jove_owned_obj_t *obj, uint8_t type);
uintmax_t obj_getvalue(jove_owned_obj_t *obj);
void obj_setvalue(jove_owned_obj_t *obj, uintmax_t value);
-/*Returns the n'th entry of the object directory passed.
- * If the passed object is not an objdir, returns NULL and sets errno to EBADOBJ.
- * If the passed entry index is out of bounds, returns NULL and sets errno to EOOB.*/
-jove_owned_obj_t *objdir_getlocal(jove_owned_obj_t *objdir_obj, uint16_t entry);
-/*Same as objdir_getlocal except does not block if entry obj is taken.*/
-jove_owned_obj_t *objdir_trygetlocal(jove_owned_obj_t *objdir_obj, uint16_t entry);
-jove_obj_t objdir_peeklocal(jove_owned_obj_t *objdir_obj, uint16_t entry);
-
-/*Recursively seeks through an object directory for an object following the passed
- * path variable.
- * If the path length is zero, returns the passed object.
- * If the passed object is not an objdir, returns NULL and sets errno to EBADOBJ.
- * If any object excluding the object at the end of the path is not an objdir,
- * returns NULL and sets errno to EBADOBJ.
- * If any entry in the path is out of bounds, returns NULL and sets errno to EBADOBJ.*/
-jove_owned_obj_t *objdir_getobj(jove_owned_obj_t *objdir_obj, const uint16_t *path, size_t path_len);
-/*Same as objdir_getobj but does not block if child objects are locked.*/
-jove_owned_obj_t *objdir_trygetobj(jove_owned_obj_t *objdir_obj, const uint16_t *path, size_t path_len);
-
#endif
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;
+}
diff --git a/hal/smp.h b/hal/smp.h
index 6713665..8efe180 100644
--- a/hal/smp.h
+++ b/hal/smp.h
@@ -2,12 +2,15 @@
#define _JOVE_HAL_SMP_H 1
#include "obj.h"
+#include "proc/process.h"
typedef struct processor processor_t;
processor_t *processor_current(void);
jove_owned_obj_t *processor_objdir(processor_t *processor);
-jove_owned_obj_t *processor_pcb(processor_t *processor);
+jove_owned_obj_t *processor_getpcb(processor_t *processor);
+
+void processor_setpcb(processor_t *processor, jove_owned_obj_t *pcb_obj);
#endif