:: commit b29763cb8f1d53d0601665f9515b4394616ad139

mintsuki <mintsuki@protonmail.com> — 2024-01-07 00:45

parents: 47be45e251

limine: Add compressed internal modules support. Closes #324

diff --git a/PROTOCOL.md b/PROTOCOL.md
index 866ffaf0..4bcd2658 100644
--- a/PROTOCOL.md
+++ b/PROTOCOL.md
@@ -1164,6 +1164,7 @@ ID:
 Request:
 ```c
 #define LIMINE_INTERNAL_MODULE_REQUIRED (1 << 0)
+#define LIMINE_INTERNAL_MODULE_COMPRESSED (1 << 1)
 
 struct limine_internal_module {
     const char *path;
@@ -1195,6 +1196,7 @@ the kernel.
 * `cmdline` - Command line for the given module.
 * `flags` - Flags changing module loading behaviour:
   - `LIMINE_INTERNAL_MODULE_REQUIRED`: Fail if the requested module is not found.
+  - `LIMINE_INTERNAL_MODULE_COMPRESSED`: The module is GZ-compressed and should be decompressed by the bootloader. This is honoured if the response is revision 2 or greater.
 
 Internal Limine modules are guaranteed to be loaded *before* user-specified
 (configuration) modules, and thus they are guaranteed to appear before user-specified
diff --git a/common/protos/limine.c b/common/protos/limine.c
index 06425c6b..3fb21ed5 100644
--- a/common/protos/limine.c
+++ b/common/protos/limine.c
@@ -717,7 +717,7 @@ FEAT_START
     struct limine_module_response *module_response =
         ext_mem_alloc(sizeof(struct limine_module_response));
 
-    module_response->revision = 1;
+    module_response->revision = 2;
 
     struct limine_file *modules = ext_mem_alloc(module_count * sizeof(struct limine_file));
 
@@ -737,6 +737,10 @@ FEAT_START
 
             char *module_path_abs = ext_mem_alloc(1024);
             char *module_path_abs_p = module_path_abs;
+            if (internal_module->flags & LIMINE_INTERNAL_MODULE_COMPRESSED) {
+                strcpy(module_path_abs_p, "$");
+                module_path_abs_p += 1;
+            }
             strcpy(module_path_abs_p, k_resource);
             module_path_abs_p += strlen(k_resource);
             strcpy(module_path_abs_p, "://");
diff --git a/limine.h b/limine.h
index b7baa79a..c331a6cf 100644
--- a/limine.h
+++ b/limine.h
@@ -438,6 +438,7 @@ struct limine_kernel_file_request {
 #define LIMINE_MODULE_REQUEST { LIMINE_COMMON_MAGIC, 0x3e7e279702be32af, 0xca1c4f3bd1280cee }
 
 #define LIMINE_INTERNAL_MODULE_REQUIRED (1 << 0)
+#define LIMINE_INTERNAL_MODULE_COMPRESSED (1 << 1)
 
 struct limine_internal_module {
     LIMINE_PTR(const char *) path;
tab: 248 wrap: offon