stivale: Use anchor struct definitions from public stivale headers

This commit is contained in:
mintsuki 2021-07-05 12:20:47 +02:00
parent 84e540ee48
commit 591f601299
3 changed files with 6 additions and 16 deletions

View File

@ -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.");
}

View File

@ -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(

View File

@ -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;