:: commit a4713c0d4e8513d87644b584e85c70fddf4f1e26

pitust <piotr@stelmaszek.com> — 2021-11-06 14:36

parents: 3f2e2bc68e

bootboot: fix two issues in bootboot proto

diff --git a/stage23/protos/bootboot.c b/stage23/protos/bootboot.c
index 41b74b2d..29959bc8 100644
--- a/stage23/protos/bootboot.c
+++ b/stage23/protos/bootboot.c
@@ -135,8 +135,6 @@ void bootboot_load(char *config) {
 
     /// Memory mappings ///
     pagemap_t pmap = new_pagemap(4);
-    BOOTBOOT* bootboot = (BOOTBOOT*)ext_mem_alloc_type_aligned(4096, MEMMAP_BOOTLOADER_RECLAIMABLE, 4096);
-    map_page(pmap, struct_vaddr, (uint64_t)(size_t)bootboot, VMM_FLAG_PRESENT | VMM_FLAG_WRITE, false);
 
     /// Load kernel ///
     uint64_t entry, top, slide, rangecount, physbase, virtbase = 0;
@@ -194,6 +192,11 @@ void bootboot_load(char *config) {
     printv("bootboot: mapping framebuffer to %X\n", fb_vaddr);
     printv("bootboot: the init stack is %X bytes\n", init_stack_size);;
 
+    /// Bootboot structure ///
+    BOOTBOOT* bootboot = (BOOTBOOT*)ext_mem_alloc_type_aligned(4096, MEMMAP_BOOTLOADER_RECLAIMABLE, 4096);
+    map_page(pmap, struct_vaddr, (uint64_t)(size_t)bootboot, VMM_FLAG_PRESENT | VMM_FLAG_WRITE, false);
+
+
     /// Environment ///
     {
         map_page(pmap, env_vaddr, (uint64_t)(size_t)env, VMM_FLAG_PRESENT | VMM_FLAG_WRITE, false);
diff --git a/stage23/protos/bootboot/initrd.c b/stage23/protos/bootboot/initrd.c
index b6661440..859ad815 100644
--- a/stage23/protos/bootboot/initrd.c
+++ b/stage23/protos/bootboot/initrd.c
@@ -11,7 +11,7 @@ INITRD_HANDLER(cpio);
 INITRD_HANDLER(auto) {
 #define DETECT_FAILED panic("bootboot: cannot read file `%s`: cannot detect initrd type (only ustar, cpio and jamesm is supported).", path)
     if (file.size < 4) DETECT_FAILED;
-    if (!memcmp(file.data, "ELF\x7f", 4)) {
+    if (!memcmp(file.data, "\x7f""ELF", 4)) {
         if (strcmp("sys/core", path) == 0) {
             printv("bootboot: using ELF as initrd to open sys/core\n");
             return file;
tab: 248 wrap: offon