:: commit 82627d86933246585b1ab9d724bc3681cf5c0bdf

mintsuki <mintsuki@protonmail.com> — 2022-03-18 07:32

parents: 03700dea96

limine: Move memmap request to using SoA

diff --git a/common/limine.h b/common/limine.h
index 00713576..fdda475b 100644
--- a/common/limine.h
+++ b/common/limine.h
@@ -151,18 +151,13 @@ struct limine_smp_request {
 #define LIMINE_MEMMAP_KERNEL_AND_MODULES     6
 #define LIMINE_MEMMAP_FRAMEBUFFER            7
 
-struct limine_memmap_entry {
-    uint64_t base;
-    uint64_t length;
-    uint64_t type;
-    uint8_t reserved[256];
-};
-
 struct limine_memmap_response {
     uint64_t flags;
 
-    uint64_t entries_count;
-    LIMINE_PTR(struct limine_memmap_entry *) entries;
+    uint64_t entry_count;
+    LIMINE_PTR(uint64_t *) entry_base;
+    LIMINE_PTR(uint64_t *) entry_length;
+    LIMINE_PTR(uint32_t *) entry_type;
 };
 
 struct limine_memmap_request {
diff --git a/common/protos/limine.c b/common/protos/limine.c
index 9119f5d5..3c1b8690 100644
--- a/common/protos/limine.c
+++ b/common/protos/limine.c
@@ -532,11 +532,15 @@ FEAT_END
 FEAT_START
     struct limine_memmap_request *memmap_request = get_request(LIMINE_MEMMAP_REQUEST);
     struct limine_memmap_response *memmap_response;
-    struct limine_memmap_entry *_memmap;
+
+    uint64_t *memmap_base, *memmap_length;
+    uint32_t *memmap_type;
 
     if (memmap_request != NULL) {
         memmap_response = ext_mem_alloc(sizeof(struct limine_memmap_response));
-        _memmap = ext_mem_alloc(sizeof(struct limine_memmap_entry) * MAX_MEMMAP);
+        memmap_base = ext_mem_alloc(sizeof(uint64_t) * MAX_MEMMAP);
+        memmap_length = ext_mem_alloc(sizeof(uint64_t) * MAX_MEMMAP);
+        memmap_type = ext_mem_alloc(sizeof(uint32_t) * MAX_MEMMAP);
     }
 
     size_t mmap_entries;
@@ -551,40 +555,42 @@ FEAT_START
     }
 
     for (size_t i = 0; i < mmap_entries; i++) {
-        _memmap[i].base = mmap[i].base;
-        _memmap[i].length = mmap[i].length;
+        memmap_base[i] = mmap[i].base;
+        memmap_length[i] = mmap[i].length;
 
         switch (mmap[i].type) {
             case MEMMAP_USABLE:
-                _memmap[i].type = LIMINE_MEMMAP_USABLE;
+                memmap_type[i] = LIMINE_MEMMAP_USABLE;
                 break;
             case MEMMAP_ACPI_RECLAIMABLE:
-                _memmap[i].type = LIMINE_MEMMAP_ACPI_RECLAIMABLE;
+                memmap_type[i] = LIMINE_MEMMAP_ACPI_RECLAIMABLE;
                 break;
             case MEMMAP_ACPI_NVS:
-                _memmap[i].type = LIMINE_MEMMAP_ACPI_NVS;
+                memmap_type[i] = LIMINE_MEMMAP_ACPI_NVS;
                 break;
             case MEMMAP_BAD_MEMORY:
-                _memmap[i].type = LIMINE_MEMMAP_BAD_MEMORY;
+                memmap_type[i] = LIMINE_MEMMAP_BAD_MEMORY;
                 break;
             case MEMMAP_BOOTLOADER_RECLAIMABLE:
-                _memmap[i].type = LIMINE_MEMMAP_BOOTLOADER_RECLAIMABLE;
+                memmap_type[i] = LIMINE_MEMMAP_BOOTLOADER_RECLAIMABLE;
                 break;
             case MEMMAP_KERNEL_AND_MODULES:
-                _memmap[i].type = LIMINE_MEMMAP_KERNEL_AND_MODULES;
+                memmap_type[i] = LIMINE_MEMMAP_KERNEL_AND_MODULES;
                 break;
             case MEMMAP_FRAMEBUFFER:
-                _memmap[i].type = LIMINE_MEMMAP_FRAMEBUFFER;
+                memmap_type[i] = LIMINE_MEMMAP_FRAMEBUFFER;
                 break;
             default:
             case MEMMAP_RESERVED:
-                _memmap[i].type = LIMINE_MEMMAP_RESERVED;
+                memmap_type[i] = LIMINE_MEMMAP_RESERVED;
                 break;
         }
     }
 
-    memmap_response->entries_count = mmap_entries;
-    memmap_response->entries = reported_addr(_memmap);
+    memmap_response->entry_count = mmap_entries;
+    memmap_response->entry_base = reported_addr(memmap_base);
+    memmap_response->entry_length = reported_addr(memmap_length);
+    memmap_response->entry_type = reported_addr(memmap_type);
 
     memmap_request->response = reported_addr(memmap_response);
 FEAT_END
diff --git a/test/limine.c b/test/limine.c
index decf1b25..9a78e4f8 100644
--- a/test/limine.c
+++ b/test/limine.c
@@ -141,10 +141,11 @@ FEAT_START
     }
     e9_printf("");
     struct limine_memmap_response *memmap_response = memmap_request.response;
-    e9_printf("%d memory map entries", memmap_response->entries_count);
-    for (size_t i = 0; i < memmap_response->entries_count; i++) {
-        struct limine_memmap_entry *e = &memmap_response->entries[i];
-        e9_printf("%x->%x %s", e->base, e->base + e->length, get_memmap_type(e->type));
+    e9_printf("%d memory map entries", memmap_response->entry_count);
+    for (size_t i = 0; i < memmap_response->entry_count; i++) {
+        e9_printf("%x->%x %s", memmap_response->entry_base[i],
+                  memmap_response->entry_base[i] + memmap_response->entry_length[i],
+                  get_memmap_type(memmap_response->entry_type[i]));
     }
 FEAT_END
 
tab: 248 wrap: offon