:: commit fb19f6bc9779b366cdbae83ca01e2e646f74055c

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

parents: 40e0f3fd77

Revert "limine: Move module request to using SoA"

This reverts commit f39578f4e316c97b4d7b898f09e41cf8ca58dcdd.
diff --git a/common/limine.h b/common/limine.h
index 9a1e287b..74716e3f 100644
--- a/common/limine.h
+++ b/common/limine.h
@@ -196,15 +196,20 @@ struct limine_entry_point_request {
 
 #define LIMINE_MODULE_REQUEST { LIMINE_COMMON_MAGIC, 0x3e7e279702be32af, 0xca1c4f3bd1280cee }
 
+struct limine_module {
+    uint64_t base;
+    uint64_t length;
+    LIMINE_PTR(char *) path;
+    LIMINE_PTR(char *) cmdline;
+    LIMINE_PTR(struct limine_file_location *) file_location;
+    uint8_t reserved[256];
+};
+
 struct limine_module_response {
     uint64_t revision;
 
-    uint64_t module_count;
-    LIMINE_PTR(uint64_t *) module_base;
-    LIMINE_PTR(uint64_t *) module_length;
-    LIMINE_PTR(LIMINE_PTR(char *) *) module_path;
-    LIMINE_PTR(LIMINE_PTR(char *) *) module_cmdline;
-    LIMINE_PTR(LIMINE_PTR(struct limine_file_location *) *) module_file_location;
+    uint64_t modules_count;
+    LIMINE_PTR(struct limine_module *) modules;
 };
 
 struct limine_module_request {
diff --git a/common/protos/limine.c b/common/protos/limine.c
index 9d8c36d3..fbf729e0 100644
--- a/common/protos/limine.c
+++ b/common/protos/limine.c
@@ -356,55 +356,50 @@ FEAT_START
     struct limine_module_response *module_response =
         ext_mem_alloc(sizeof(struct limine_module_response));
 
-    uint64_t *module_base = ext_mem_alloc(sizeof(uint64_t) * module_count);
-    uint64_t *module_length = ext_mem_alloc(sizeof(uint64_t) * module_count);
-    uint64_t *module_path = ext_mem_alloc(sizeof(uint64_t) * module_count);
-    uint64_t *module_cmdline = ext_mem_alloc(sizeof(uint64_t) * module_count);
-    uint64_t *module_file_location = ext_mem_alloc(sizeof(uint64_t) * module_count);
-
-    module_base[0] = reported_addr(kernel);
-    module_length[0] = kernel_file_size;
-    module_path[0] = reported_addr(kernel_path);
-    module_cmdline[0] = reported_addr(cmdline);
-    module_file_location[0] = reported_addr(kl);
+    struct limine_module *modules = ext_mem_alloc(module_count * sizeof(struct limine_module));
+
+    modules[0].base = reported_addr(kernel);
+    modules[0].length = kernel_file_size;
+    modules[0].path = reported_addr(kernel_path);
+    modules[0].cmdline = reported_addr(cmdline);
+
+    modules[0].file_location = reported_addr(kl);
 
     for (size_t i = 1; i < module_count; i++) {
         struct conf_tuple conf_tuple =
                 config_get_tuple(config, i - 1,
                                  "MODULE_PATH", "MODULE_CMDLINE");
 
-        char *m_path = conf_tuple.value1;
-        char *m_cmdline = conf_tuple.value2;
+        char *module_path = conf_tuple.value1;
+        char *module_cmdline = conf_tuple.value2;
+
+        struct limine_module *m = &modules[i];
 
-        if (m_cmdline == NULL) {
-            m_cmdline = "";
+        if (module_cmdline == NULL) {
+            module_cmdline = "";
         }
 
         print("limine: Loading module `%s`...\n", m_path);
 
         struct file_handle *f;
-        if ((f = uri_open(m_path)) == NULL)
+        if ((f = uri_open(module_path)) == NULL)
             panic(true, "limine: Failed to open module with path `%s`. Is the path correct?", module_path);
 
-        module_base[i] = reported_addr(freadall(f, MEMMAP_KERNEL_AND_MODULES));
-        module_length[i] = f->size;
-        module_path[i] = reported_addr(m_path);
-        module_cmdline[i] = reported_addr(m_cmdline);
+        m->base = reported_addr(freadall(f, MEMMAP_KERNEL_AND_MODULES));
+        m->length = f->size;
+        m->path = reported_addr(module_path);
+        m->cmdline = reported_addr(module_cmdline);
 
         struct limine_file_location *l = ext_mem_alloc(sizeof(struct limine_file_location));
         *l = get_file_loc(f);
 
-        module_file_location[i] = reported_addr(l);
+        m->file_location = reported_addr(l);
 
         fclose(f);
     }
 
-    module_response->module_count = module_count;
-    module_response->module_base = reported_addr(module_base);
-    module_response->module_length = reported_addr(module_length);
-    module_response->module_path = reported_addr(module_path);
-    module_response->module_cmdline = reported_addr(module_cmdline);
-    module_response->module_file_location = reported_addr(module_file_location);
+    module_response->modules_count = module_count;
+    module_response->modules = reported_addr(modules);
 
     module_request->response = reported_addr(module_response);
 FEAT_END
diff --git a/test/limine.c b/test/limine.c
index ca2b747f..de679c4b 100644
--- a/test/limine.c
+++ b/test/limine.c
@@ -208,14 +208,16 @@ FEAT_START
         break;
     }
     struct limine_module_response *module_response = module_request.response;
-    e9_printf("%d module(s)", module_response->module_count);
-    for (size_t i = 0; i < module_response->module_count; i++) {
-        e9_printf("Base: %x", module_response->module_base[i]);
-        e9_printf("Length: %x", module_response->module_length[i]);
-        e9_printf("Path: %s", module_response->module_path[i]);
-        e9_printf("Cmdline: %s", module_response->module_cmdline[i]);
-
-        print_file_loc(module_response->module_file_location[i]);
+    e9_printf("%d module(s)", module_response->modules_count);
+    for (size_t i = 0; i < module_response->modules_count; i++) {
+        struct limine_module *m = &module_response->modules[i];
+
+        e9_printf("Base: %x", m->base);
+        e9_printf("Length: %x", m->length);
+        e9_printf("Path: %s", m->path);
+        e9_printf("Cmdline: %s", m->cmdline);
+
+        print_file_loc(m->file_location);
     }
 FEAT_END
 
tab: 248 wrap: offon