:: commit 30aed730b6cc8f451e6ca15533f182dcbc31c54b

mintsuki <mintsuki@protonmail.com> — 2022-03-16 19:33

parents: a51f8a39c0

limine: Add kernel to modules request

diff --git a/common/limine.h b/common/limine.h
index a8425566..3f295249 100644
--- a/common/limine.h
+++ b/common/limine.h
@@ -43,21 +43,6 @@ struct limine_boot_info_request {
     LIMINE_PTR(struct limine_boot_info_response *) response;
 };
 
-// Command line
-
-#define LIMINE_CMDLINE_REQUEST { LIMINE_COMMON_MAGIC, 0x859894000fc0b7d3, 0xaab4ab57e5c3e348 }
-
-struct limine_cmdline_response {
-    uint64_t flags;
-    LIMINE_PTR(char *) cmdline;
-};
-
-struct limine_cmdline_request {
-    uint64_t id[4];
-    uint64_t flags;
-    LIMINE_PTR(struct limine_cmdline_response *) response;
-};
-
 // Framebuffer
 
 #define LIMINE_FRAMEBUFFER_REQUEST { LIMINE_COMMON_MAGIC, 0xcbfe81d7dd2d1977, 0x063150319ebc9b71 }
diff --git a/common/protos/limine.c b/common/protos/limine.c
index 2e82c961..c44f7365 100644
--- a/common/protos/limine.c
+++ b/common/protos/limine.c
@@ -111,7 +111,7 @@ bool limine_load(char *config, char *cmdline) {
 
     size_t kernel_file_size = kernel_file->size;
 
-    //struct volume *kernel_volume = kernel_file->vol;
+    struct volume *kernel_volume = kernel_file->vol;
 
     fclose(kernel_file);
 
@@ -238,21 +238,6 @@ FEAT_START
     boot_info_request->response = reported_addr(boot_info_response);
 FEAT_END
 
-    // Command line
-FEAT_START
-    struct limine_cmdline_request *cmdline_request = get_request(LIMINE_CMDLINE_REQUEST);
-    if (cmdline_request == NULL) {
-        break; // next feature
-    }
-
-    struct limine_cmdline_response *cmdline_response =
-        ext_mem_alloc(sizeof(struct limine_cmdline_response));
-
-    cmdline_response->cmdline = reported_addr(cmdline);
-
-    cmdline_request->response = reported_addr(cmdline_response);
-FEAT_END
-
     // Modules
 FEAT_START
     struct limine_module_request *module_request = get_request(LIMINE_MODULE_REQUEST);
@@ -267,14 +252,28 @@ FEAT_START
             break;
     }
 
+    // Module 0 is always the kernel
+    module_count++;
+
     struct limine_module_response *module_response =
         ext_mem_alloc(sizeof(struct limine_module_response));
 
     struct limine_module *modules = ext_mem_alloc(module_count * sizeof(struct limine_module));
 
-    for (size_t i = 0; i < module_count; i++) {
+    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);
+
+    struct limine_file_location *kl = ext_mem_alloc(sizeof(struct limine_file_location));
+    *kl = get_file_loc(kernel_volume);
+
+    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, "MODULE_PATH", "MODULE_CMDLINE");
+                config_get_tuple(config, i - 1,
+                                 "MODULE_PATH", "MODULE_CMDLINE");
 
         char *module_path = conf_tuple.value1;
         char *module_cmdline = conf_tuple.value2;
diff --git a/test/limine.c b/test/limine.c
index 677adc39..3c333f48 100644
--- a/test/limine.c
+++ b/test/limine.c
@@ -19,12 +19,6 @@ static struct limine_entry_point_request entry_point_request = {
     .entry = limine_main
 };
 
-__attribute__((used))
-static struct limine_cmdline_request cmdline_request = {
-    .id = LIMINE_CMDLINE_REQUEST,
-    .flags = 0, .response = NULL
-};
-
 __attribute__((used))
 static struct limine_boot_info_request boot_info_request = {
     .id = LIMINE_BOOT_INFO_REQUEST,
@@ -102,15 +96,6 @@ FEAT_START
     e9_printf("Bootloader name: %s", boot_info_response->loader);
 FEAT_END
 
-FEAT_START
-    if (cmdline_request.response == NULL) {
-        e9_printf("Command line not passed");
-        break;
-    }
-    struct limine_cmdline_response *cmdline_response = cmdline_request.response;
-    e9_printf("Command line: %s", cmdline_response->cmdline);
-FEAT_END
-
 FEAT_START
     if (memmap_request.response == NULL) {
         e9_printf("Memory map not passed");
tab: 248 wrap: offon