summaryrefslogtreecommitdiffstats
path: root/arch/x86_64/boot/limine/memorymap.c
diff options
context:
space:
mode:
authorJon Santmyer <jon@jonsantmyer.com>2025-09-02 11:35:38 -0400
committerJon Santmyer <jon@jonsantmyer.com>2025-09-02 11:35:38 -0400
commitd26eb8b54969e79d933a8e20f2725343cd42deab (patch)
tree9b6aaf6e84ed965d146c129028e32e00ef846adc /arch/x86_64/boot/limine/memorymap.c
parent8f0ba2fd31408d04175513b8826bf9418ad8b087 (diff)
downloadjove-kernel-d26eb8b54969e79d933a8e20f2725343cd42deab.tar.gz
jove-kernel-d26eb8b54969e79d933a8e20f2725343cd42deab.tar.bz2
jove-kernel-d26eb8b54969e79d933a8e20f2725343cd42deab.zip
move limine to arch-specific directory.
untie boot code from non-boot code
Diffstat (limited to 'arch/x86_64/boot/limine/memorymap.c')
-rw-r--r--arch/x86_64/boot/limine/memorymap.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/arch/x86_64/boot/limine/memorymap.c b/arch/x86_64/boot/limine/memorymap.c
new file mode 100644
index 0000000..ec0f545
--- /dev/null
+++ b/arch/x86_64/boot/limine/memorymap.c
@@ -0,0 +1,45 @@
+#include "boot.h"
+#include "limine.h"
+#include "object.h"
+#include "print.h"
+#include "jove.h"
+#include "arch/x86_64/page.h"
+
+static struct jove_ObjectDirectory s_untyped_dir = {
+ .self = { .type = KO_OBJECT_DIRECTORY, .data = 1 },
+};
+
+static volatile struct limine_memmap_request s_memmap_req = {
+ .id = LIMINE_MEMMAP_REQUEST
+};
+
+void
+boot_populate_untyped(void)
+{
+ _initDirectory.entries[INIT_OBJECT_UNTYPED_DIR] = (objdir_entry_t) {
+ .type = KO_OBJECT_DIRECTORY,
+ .data = (uintptr_t)&s_untyped_dir
+ };
+
+ if(s_memmap_req.response == NULL) {
+ klogf("Failed to load physical memory map");
+ hcf();
+ }
+ struct limine_memmap_response *response = s_memmap_req.response;
+ for(size_t i = 0; i < response->entry_count; i++) {
+ struct limine_memmap_entry *entry = response->entries[i];
+ if(entry->type != LIMINE_MEMMAP_USABLE) continue;
+
+ size_t table_index = s_untyped_dir.self.data++;
+ uintmax_t *untyped_data = vmem_phys_tovirt(entry->base);
+ objdir_entry_t *table_entry = &s_untyped_dir.entries[table_index];
+
+ table_entry->type = KO_MEMORY_UNTYPED;
+ table_entry->data = (uintptr_t)entry->base;
+ *untyped_data = entry->length;
+
+ klogf("New untyped block %i at %p:%p\n",
+ table_index, entry->base, entry->length);
+ }
+}
+