:: commit ed590257af0c605d7e819782d88eee86a2cfc005

mintsuki <mintsuki@protonmail.com> — 2020-11-17 23:53

parents: a8a079425a

misc: Reuse buffers that hold the paths of module files for protocols

diff --git a/limine-pxe.bin b/limine-pxe.bin
index 228ebd4d..4bc1e3b8 100644
Binary files a/limine-pxe.bin and b/limine-pxe.bin differ
diff --git a/limine.bin b/limine.bin
index 59a89fb2..b2c29d4b 100644
Binary files a/limine.bin and b/limine.bin differ
diff --git a/stage2.map b/stage2.map
index 527c227a..34fb9da4 100644
Binary files a/stage2.map and b/stage2.map differ
diff --git a/stage2/protos/linux.c b/stage2/protos/linux.c
index 8a7cf6fd..c3386277 100644
--- a/stage2/protos/linux.c
+++ b/stage2/protos/linux.c
@@ -129,15 +129,14 @@ void linux_load(char *config, char *cmdline) {
 
     size_t modules_mem_base = INITRD_LOAD_ADDR;
     for (size_t i = 0; ; i++) {
-        char module_path[64];
-        if (!config_get_value(config, module_path, i, 64, "MODULE_PATH"))
+        if (!config_get_value(config, buf, i, 128, "MODULE_PATH"))
             break;
 
         struct file_handle module;
-        if (!uri_open(&module, module_path))
-            panic("Could not open `%s`", module_path);
+        if (!uri_open(&module, buf))
+            panic("Could not open `%s`", buf);
 
-        print("Loading module `%s`...\n", module_path);
+        print("Loading module `%s`...\n", buf);
 
         memmap_alloc_range(modules_mem_base, module.size, 0);
         fread(&module, (void *)modules_mem_base, 0, module.size);
diff --git a/stage2/protos/stivale.c b/stage2/protos/stivale.c
index 559d0949..8dabb812 100644
--- a/stage2/protos/stivale.c
+++ b/stage2/protos/stivale.c
@@ -116,8 +116,7 @@ void stivale_load(char *config, char *cmdline) {
     stivale_struct.module_count = 0;
     uint64_t *prev_mod_ptr = &stivale_struct.modules;
     for (int i = 0; ; i++) {
-        char module_file[64];
-        if (!config_get_value(config, module_file, i, 64, "MODULE_PATH"))
+        if (!config_get_value(config, buf, i, 128, "MODULE_PATH"))
             break;
 
         stivale_struct.module_count++;
@@ -129,14 +128,14 @@ void stivale_load(char *config, char *cmdline) {
         }
 
         struct file_handle f;
-        if (!uri_open(&f, module_file))
-            panic("Requested module with path \"%s\" not found!", module_file);
+        if (!uri_open(&f, buf))
+            panic("Requested module with path \"%s\" not found!", buf);
 
         void *module_addr = (void *)(((uint32_t)top_used_addr & 0xfff) ?
             ((uint32_t)top_used_addr & ~((uint32_t)0xfff)) + 0x1000 :
             (uint32_t)top_used_addr);
 
-        print("stivale: Loading module `%s`...\n", module_file);
+        print("stivale: Loading module `%s`...\n", buf);
 
         memmap_alloc_range((size_t)module_addr, f.size, 10);
         fread(&f, module_addr, 0, f.size);
@@ -151,7 +150,7 @@ void stivale_load(char *config, char *cmdline) {
         prev_mod_ptr  = &m->next;
 
         print("stivale: Requested module %u:\n", i);
-        print("         Path:   %s\n", module_file);
+        print("         Path:   %s\n", buf);
         print("         String: %s\n", m->string);
         print("         Begin:  %X\n", m->begin);
         print("         End:    %X\n", m->end);
diff --git a/stage2/protos/stivale2.c b/stage2/protos/stivale2.c
index 3ec78b6d..81917230 100644
--- a/stage2/protos/stivale2.c
+++ b/stage2/protos/stivale2.c
@@ -170,8 +170,7 @@ void stivale2_load(char *config, char *cmdline) {
     tag->module_count   = module_count;
 
     for (int i = 0; ; i++) {
-        char module_file[64];
-        if (!config_get_value(config, module_file, i, 64, "MODULE_PATH"))
+        if (!config_get_value(config, buf, i, 128, "MODULE_PATH"))
             break;
 
         struct stivale2_module *m = &tag->modules[i];
@@ -181,14 +180,14 @@ void stivale2_load(char *config, char *cmdline) {
         }
 
         struct file_handle f;
-        if (!uri_open(&f, module_file))
-            panic("Requested module with path \"%s\" not found!", module_file);
+        if (!uri_open(&f, buf))
+            panic("Requested module with path \"%s\" not found!", buf);
 
         void *module_addr = (void *)(((uint32_t)top_used_addr & 0xfff) ?
             ((uint32_t)top_used_addr & ~((uint32_t)0xfff)) + 0x1000 :
             (uint32_t)top_used_addr);
 
-        print("stivale2: Loading module `%s`...\n", module_file);
+        print("stivale2: Loading module `%s`...\n", buf);
 
         memmap_alloc_range((size_t)module_addr, f.size, 0x1001);
         fread(&f, module_addr, 0, f.size);
@@ -199,7 +198,7 @@ void stivale2_load(char *config, char *cmdline) {
         top_used_addr = (uint64_t)(size_t)m->end;
 
         print("stivale2: Requested module %u:\n", i);
-        print("          Path:   %s\n", module_file);
+        print("          Path:   %s\n", buf);
         print("          String: %s\n", m->string);
         print("          Begin:  %X\n", m->begin);
         print("          End:    %X\n", m->end);
tab: 248 wrap: offon