From c3f23032f0727c7c9a91b396f4e26a2353bf08e7 Mon Sep 17 00:00:00 2001 From: Mark Date: Sat, 5 Sep 2020 02:08:52 +0300 Subject: [PATCH] boot: yboot protocol change: memory map Memory map is now a part of boot protocol structure. The change was caused by UEFI placing this boot structure (as part of yboot's data section) very high in physical memory, above kernel's mapped 4GiB range, so kernel had no way of accessing it. It's not the best solution, but will work for sure. --- arch/amd64/boot/yboot.S | 2 +- arch/amd64/kernel.c | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/arch/amd64/boot/yboot.S b/arch/amd64/boot/yboot.S index 22bfb2d..c2d44f3 100644 --- a/arch/amd64/boot/yboot.S +++ b/arch/amd64/boot/yboot.S @@ -10,7 +10,6 @@ yboot_data: .quad BOOT_KERNEL_MAGIC // kernel_magic .quad 0 // loader_magic - .quad 0 // memory_map_base .long 0 // memory_map_size .long 0 // memory_map_entsize @@ -32,6 +31,7 @@ yboot_data: .quad 0 // rsdp .skip 256 // cmdline + .skip 3072 // memory map data .size yboot_data, . - yboot_data .section .text diff --git a/arch/amd64/kernel.c b/arch/amd64/kernel.c index ab97cdf..7ee7afe 100644 --- a/arch/amd64/kernel.c +++ b/arch/amd64/kernel.c @@ -153,7 +153,6 @@ struct boot_struct { uint64_t kernel_magic; // R uint64_t loader_magic; // W - uint64_t memory_map_base; // W uint32_t memory_map_size; // W uint32_t memory_map_entsize; // W @@ -176,16 +175,13 @@ struct boot_struct { uint64_t rsdp; // W char cmdline[256]; // W + char memory_map_data[3072]; // W } __attribute__((packed)); #endif static void entry_yboot(void) { extern struct boot_struct yboot_data; - if (yboot_data.memory_map_base == 0) { - panic("No memory map available\n"); - } - if (yboot_data.rsdp == 0) { kwarn("Booted from UEFI and no RSDP was provided, will likely result in error\n"); } else { @@ -204,7 +200,7 @@ static void entry_yboot(void) { } phys_memory_map.format = MM_PHYS_MMAP_FMT_YBOOT; - phys_memory_map.address = (void *) MM_VIRTUALIZE(yboot_data.memory_map_base); + phys_memory_map.address = yboot_data.memory_map_data; phys_memory_map.entry_size = yboot_data.memory_map_entsize; phys_memory_map.entry_count = yboot_data.memory_map_size / yboot_data.memory_map_entsize; }