summaryrefslogtreecommitdiffstats
path: root/hal
diff options
context:
space:
mode:
authorJon Santmyer <jon@jonsantmyer.com>2026-09-15 10:03:20 -0400
committerJon Santmyer <jon@jonsantmyer.com>2026-09-15 10:03:20 -0400
commita783cc865f1f261c20f6ef55cb37d4839f519865 (patch)
treeeabd6992f3be7c0f4d778a9fba2bfe7173ed6c8c /hal
parent1f4260648f02db1b4fe8c60fe36f936125042880 (diff)
downloadjove-kernel-a783cc865f1f261c20f6ef55cb37d4839f519865.tar.gz
jove-kernel-a783cc865f1f261c20f6ef55cb37d4839f519865.tar.bz2
jove-kernel-a783cc865f1f261c20f6ef55cb37d4839f519865.zip
move constants to api. centralize interrupts. fix rootdir lock hang
Diffstat (limited to 'hal')
-rw-r--r--hal/memory.h2
-rw-r--r--hal/obj.h37
-rw-r--r--hal/uacpi.c33
-rw-r--r--hal/uacpi.h6
4 files changed, 77 insertions, 1 deletions
diff --git a/hal/memory.h b/hal/memory.h
index ca021ef..f1cf9db 100644
--- a/hal/memory.h
+++ b/hal/memory.h
@@ -1,7 +1,7 @@
#ifndef _JOVE_HAL_MEMORY_H
#define _JOVE_HAL_MEMORY_H 1
-#include "obj.h"
+#include "hal/obj.h"
#include "api/syscall.h"
typedef struct jove_obj_untyped
diff --git a/hal/obj.h b/hal/obj.h
index 7a6ab76..151f4eb 100644
--- a/hal/obj.h
+++ b/hal/obj.h
@@ -9,4 +9,41 @@
#include "arch/x86_64/hal/obj.h"
#endif
+typedef struct jove_objdir
+{
+ jove_obj_t entries[JOVE_OBJDIR_ENTRIES];
+} jove_objdir_t;
+
+/*Locks the mutex of the kernel object provided. Returns the locked version. */
+jove_owned_obj_t *obj_take(jove_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);
+
+/*Converts the value pointer of the object into a pointer to kernel memory.*/
+void *obj_deref(jove_owned_obj_t *obj);
+
+/*Getters and setters for accessing the type field of the kernel object. */
+uint8_t obj_gettype(jove_owned_obj_t *obj);
+uint8_t obj_peektype(jove_obj_t obj);
+void obj_settype(jove_owned_obj_t *obj, uint8_t type);
+
+/*Getters and setters for accessing the value field of the kernel object. */
+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);
+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);
+
#endif
diff --git a/hal/uacpi.c b/hal/uacpi.c
index 0af50b2..5aea792 100644
--- a/hal/uacpi.c
+++ b/hal/uacpi.c
@@ -1,5 +1,11 @@
+#include "arch/x86_64/hal/obj.h"
+#include "init.h"
#include "uacpi/uacpi.h"
#include "lib/printf.h"
+#include "uacpi/tables.h"
+#include <hal/obj.h>
+
+jove_objdir_t s_acpi_objdir = { 0 };
void uacpi_kernel_log(uacpi_log_level lvl, const uacpi_char* fmt, ...)
{
@@ -11,3 +17,30 @@ void uacpi_kernel_log(uacpi_log_level lvl, const uacpi_char* fmt, ...)
va_end(ap);
}
+void
+uacpi_kernel_init(void)
+{
+ uint8_t uacpi_buffer[1024];
+ uacpi_setup_early_table_access(uacpi_buffer, 1024);
+
+ jove_owned_obj_t *acpi_objdir_obj = objdir_getlocal(_rootdir_obj, ROOTDIR_ACPI_I);
+ obj_settype(acpi_objdir_obj, JOVE_OBJ_OBJDIR);
+ obj_setvalue(acpi_objdir_obj, (uintptr_t)&s_acpi_objdir);
+
+ size_t num_tables = uacpi_table_count();
+ for(size_t i = 0; i < num_tables; i++) {
+ uacpi_table table;
+ uacpi_status get_res = uacpi_table_get_by_index(i, &table);
+
+ if(get_res != UACPI_STATUS_OK) {
+ kprintf("uacpi: Failed to get table %i with code %s\n", i, uacpi_status_to_string(get_res));
+ continue;
+ }
+
+ jove_owned_obj_t *table_obj = objdir_getlocal(acpi_objdir_obj, i);
+ obj_settype(table_obj, JOVE_OBJ_ACPI_TABLE);
+ obj_setvalue(table_obj, table.virt_addr);
+ obj_release(table_obj);
+ }
+ obj_release(acpi_objdir_obj);
+}
diff --git a/hal/uacpi.h b/hal/uacpi.h
new file mode 100644
index 0000000..a3790c0
--- /dev/null
+++ b/hal/uacpi.h
@@ -0,0 +1,6 @@
+#ifndef _JOVE_UACPI_H
+#define _JOVE_UACPI_H 1
+
+void uacpi_kernel_init(void);
+
+#endif