:: commit 553c7b2945c796c548ee2f1e9a9ffd43acc703d7

mintsuki <mintsuki@protonmail.com> — 2023-11-01 22:45

parents: f4b78bec63

limine: Slight change of how base revision is determined

diff --git a/common/protos/limine.c b/common/protos/limine.c
index fd60d6aa..8d10ad90 100644
--- a/common/protos/limine.c
+++ b/common/protos/limine.c
@@ -343,21 +343,16 @@ noreturn void limine_load(char *config, char *cmdline) {
     kaslr = kaslr && is_reloc;
 
     // Determine base revision
-    LIMINE_BASE_REVISION_1
+    LIMINE_BASE_REVISION(0)
     int base_revision = 0;
     for (size_t i = 0; i < ALIGN_DOWN(image_size_before_bss, 8); i += 8) {
-        void *p = (void *)(uintptr_t)physical_base + i;
-        int new_revision = 0;
+        uint64_t *p = (void *)(uintptr_t)physical_base + i;
 
-        if (memcmp(p, (void *)&limine_base_revision_1, 16) == 0) {
-            new_revision = 1;
-        }
-
-        if (new_revision != 0) {
+        if (p[0] == limine_base_revision[0] && p[1] == limine_base_revision[1]) {
             if (base_revision != 0) {
                 panic(true, "limine: Duplicated base revision tag");
             }
-            base_revision = new_revision;
+            base_revision = p[2];
         }
     }
 
@@ -409,6 +404,7 @@ noreturn void limine_load(char *config, char *cmdline) {
     printv("limine: Virtual base:    %X\n", virtual_base);
     printv("limine: Slide:           %X\n", slide);
     printv("limine: ELF entry point: %X\n", entry_point);
+    printv("limine: Base revision:   %u\n", base_revision);
     printv("limine: Requests count:  %u\n", requests_count);
 
     // Paging Mode
diff --git a/limine.h b/limine.h
index 542f2a65..721a8195 100644
--- a/limine.h
+++ b/limine.h
@@ -44,8 +44,8 @@ extern "C" {
 #  define LIMINE_DEPRECATED_IGNORE_END
 #endif
 
-#define LIMINE_BASE_REVISION_1 \
-    volatile uint64_t limine_base_revision_1[2] = { 0xf9562b2d5c95a6c8, 0x6a7b384944536bdc };
+#define LIMINE_BASE_REVISION(N) \
+    uint64_t limine_base_revision[3] = { 0xf9562b2d5c95a6c8, 0x6a7b384944536bdc, (N) };
 
 #define LIMINE_COMMON_MAGIC 0xc7b1dd30df4c8b88, 0x0a82e883a194f07b
 
diff --git a/test/limine.c b/test/limine.c
index 7728cb18..cfd463cb 100644
--- a/test/limine.c
+++ b/test/limine.c
@@ -5,6 +5,8 @@
 #include <flanterm/flanterm.h>
 #include <flanterm/backends/fb.h>
 
+LIMINE_BASE_REVISION(1)
+
 static void limine_main(void);
 
 struct limine_entry_point_request entry_point_request = {
tab: 248 wrap: offon