:: commit 591f6012999cd825ef3fe70c0080f5076bcde86e

mintsuki <mintsuki@protonmail.com> — 2021-07-05 10:20

parents: 84e540ee48

stivale: Use anchor struct definitions from public stivale headers

diff --git a/stage23/protos/stivale.c b/stage23/protos/stivale.c
index 713e9083..57e9afa9 100644
--- a/stage23/protos/stivale.c
+++ b/stage23/protos/stivale.c
@@ -26,7 +26,7 @@
     ((PTR) + ((stivale_hdr.flags & (1 << 3)) ? \
     (want_5lv ? 0xff00000000000000 : 0xffff800000000000) : 0))
 
-bool stivale_load_by_anchor(struct stivale_anchor **_anchor, const char *magic,
+bool stivale_load_by_anchor(void **_anchor, const char *magic,
                             uint8_t *file, uint64_t filesize) {
     struct stivale_anchor *anchor = NULL;
     for (size_t i = 0; i < filesize; i += 16) {
@@ -91,7 +91,7 @@ void stivale_load(char *config, char *cmdline) {
 
     if (bits == -1) {
         struct stivale_anchor *anchor;
-        if (!stivale_load_by_anchor(&anchor, "STIVALE1  ANCHOR", kernel, kernel_file->size)) {
+        if (!stivale_load_by_anchor((void **)&anchor, "STIVALE1  ANCHOR", kernel, kernel_file->size)) {
             panic("stivale: Not a valid ELF or anchored file.");
         }
 
diff --git a/stage23/protos/stivale.h b/stage23/protos/stivale.h
index 9ecac8a3..e09708cb 100644
--- a/stage23/protos/stivale.h
+++ b/stage23/protos/stivale.h
@@ -3,21 +3,11 @@
 
 #include <stdbool.h>
 #include <stdint.h>
-#include <sys/e820.h>
 #include <mm/vmm.h>
 
 void stivale_load(char *config, char *cmdline);
 
-struct stivale_anchor {
-    uint8_t anchor[16];
-    uint64_t phys_load_addr;
-    uint64_t phys_bss_start;
-    uint64_t phys_bss_end;
-    uint64_t phys_stivalehdr;
-    uint64_t bits;
-};
-
-bool stivale_load_by_anchor(struct stivale_anchor **_anchor, const char *magic,
+bool stivale_load_by_anchor(void **_anchor, const char *magic,
                             uint8_t *file, uint64_t filesize);
 pagemap_t stivale_build_pagemap(bool level5pg, bool unmap_null);
 __attribute__((noreturn)) void stivale_spinup(
diff --git a/stage23/protos/stivale2.c b/stage23/protos/stivale2.c
index 51cb3ddf..2653f769 100644
--- a/stage23/protos/stivale2.c
+++ b/stage23/protos/stivale2.c
@@ -86,14 +86,14 @@ void stivale2_load(char *config, char *cmdline, bool pxe, void *efi_system_table
     bool loaded_by_anchor = false;
 
     if (bits == -1) {
-        struct stivale_anchor *anchor;
-        if (!stivale_load_by_anchor(&anchor, "STIVALE2  ANCHOR", kernel, kernel_file->size)) {
+        struct stivale2_anchor *anchor;
+        if (!stivale_load_by_anchor((void **)&anchor, "STIVALE2  ANCHOR", kernel, kernel_file->size)) {
             panic("stivale2: Not a valid ELF or anchored file.");
         }
 
         bits = anchor->bits;
 
-        memcpy(&stivale2_hdr, (void *)(uintptr_t)anchor->phys_stivalehdr,
+        memcpy(&stivale2_hdr, (void *)(uintptr_t)anchor->phys_stivale2hdr,
                sizeof(struct stivale2_header));
 
         loaded_by_anchor = true;
tab: 248 wrap: offon