:: commit 40e0f3fd777ae13dac13f641c71424a71b910239

mintsuki <mintsuki@protonmail.com> — 2022-03-20 18:13

parents: 2ba3770766

Revert "limine: Move memmap request to using SoA"

This reverts commit 82627d86933246585b1ab9d724bc3681cf5c0bdf.
diff --git a/common/limine.h b/common/limine.h
index ec62bc8b..9a1e287b 100644
--- a/common/limine.h
+++ b/common/limine.h
@@ -156,13 +156,18 @@ 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 revision;
 
-    uint64_t entry_count;
-    LIMINE_PTR(uint64_t *) entry_base;
-    LIMINE_PTR(uint64_t *) entry_length;
-    LIMINE_PTR(uint32_t *) entry_type;
+    uint64_t entries_count;
+    LIMINE_PTR(struct limine_memmap_entry *) entries;
 };
 
 struct limine_memmap_request {
diff --git a/common/protos/limine.c b/common/protos/limine.c
index 069361bd..9d8c36d3 100644
--- a/common/protos/limine.c
+++ b/common/protos/limine.c
@@ -541,15 +541,11 @@ FEAT_END
 FEAT_START
     struct limine_memmap_request *memmap_request = get_request(LIMINE_MEMMAP_REQUEST);
     struct limine_memmap_response *memmap_response;
-
-    uint64_t *memmap_base, *memmap_length;
-    uint32_t *memmap_type;
+    struct limine_memmap_entry *_memmap;
 
     if (memmap_request != NULL) {
         memmap_response = ext_mem_alloc(sizeof(struct limine_memmap_response));
-        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);
+        _memmap = ext_mem_alloc(sizeof(struct limine_memmap_entry) * MAX_MEMMAP);
     }
 
     size_t mmap_entries;
@@ -564,42 +560,40 @@ FEAT_START
     }
 
     for (size_t i = 0; i < mmap_entries; i++) {
-        memmap_base[i] = mmap[i].base;
-        memmap_length[i] = mmap[i].length;
+        _memmap[i].base = mmap[i].base;
+        _memmap[i].length = mmap[i].length;
 
         switch (mmap[i].type) {
             case MEMMAP_USABLE:
-                memmap_type[i] = LIMINE_MEMMAP_USABLE;
+                _memmap[i].type = LIMINE_MEMMAP_USABLE;
                 break;
             case MEMMAP_ACPI_RECLAIMABLE:
-                memmap_type[i] = LIMINE_MEMMAP_ACPI_RECLAIMABLE;
+                _memmap[i].type = LIMINE_MEMMAP_ACPI_RECLAIMABLE;
                 break;
             case MEMMAP_ACPI_NVS:
-                memmap_type[i] = LIMINE_MEMMAP_ACPI_NVS;
+                _memmap[i].type = LIMINE_MEMMAP_ACPI_NVS;
                 break;
             case MEMMAP_BAD_MEMORY:
-                memmap_type[i] = LIMINE_MEMMAP_BAD_MEMORY;
+                _memmap[i].type = LIMINE_MEMMAP_BAD_MEMORY;
                 break;
             case MEMMAP_BOOTLOADER_RECLAIMABLE:
-                memmap_type[i] = LIMINE_MEMMAP_BOOTLOADER_RECLAIMABLE;
+                _memmap[i].type = LIMINE_MEMMAP_BOOTLOADER_RECLAIMABLE;
                 break;
             case MEMMAP_KERNEL_AND_MODULES:
-                memmap_type[i] = LIMINE_MEMMAP_KERNEL_AND_MODULES;
+                _memmap[i].type = LIMINE_MEMMAP_KERNEL_AND_MODULES;
                 break;
             case MEMMAP_FRAMEBUFFER:
-                memmap_type[i] = LIMINE_MEMMAP_FRAMEBUFFER;
+                _memmap[i].type = LIMINE_MEMMAP_FRAMEBUFFER;
                 break;
             default:
             case MEMMAP_RESERVED:
-                memmap_type[i] = LIMINE_MEMMAP_RESERVED;
+                _memmap[i].type = LIMINE_MEMMAP_RESERVED;
                 break;
         }
     }
 
-    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_response->entries_count = mmap_entries;
+    memmap_response->entries = reported_addr(_memmap);
 
     memmap_request->response = reported_addr(memmap_response);
 FEAT_END
diff --git a/test/limine.c b/test/limine.c
index 5c8e750a..ca2b747f 100644
--- a/test/limine.c
+++ b/test/limine.c
@@ -167,11 +167,10 @@ FEAT_START
         break;
     }
     struct limine_memmap_response *memmap_response = memmap_request.response;
-    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]));
+    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));
     }
 FEAT_END
 
tab: 248 wrap: offon