From b33fbb75dc5df9d2b4e3986ced9fb9a734b82103 Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Tue, 27 Oct 2026 17:14:51 +0800 Subject: [PATCH] fix(boot): read the ACPI RSDP before taking the memory-map key ExitBootServices failed with EFI_INVALID_PARAMETER because Print ran after GetMemoryMap, so the console output could change the memory map and invalidate MapKey. Locate the RSDP and print it before GetMemoryMap. --- boot/boot.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/boot/boot.c b/boot/boot.c index 146ee2b..36f65bc 100644 --- a/boot/boot.c +++ b/boot/boot.c @@ -500,6 +500,11 @@ EFI_STATUS ExitBootServicesAndJumpToKernel( // ========================== Print(L"Exiting Boot Services...\r\n"); + // Capture the RSDP before GetMemoryMap: any boot-service call that + // allocates after the map key is taken invalidates ExitBootServices. + UINT64 AcpiRsdp = FindAcpiRsdp(SystemTable); + Print(L"ACPI RSDP: 0x%lx\r\n", AcpiRsdp); + UINTN MemoryMapSize = 0; UINTN MapKey; UINTN DescriptorSize; @@ -546,8 +551,7 @@ EFI_STATUS ExitBootServicesAndJumpToKernel( BootInfo.framebuffer_pitch = framebuffer_pitch; BootInfo.framebuffer_format = framebuffer_format; BootInfo.system_table = 0; - BootInfo.acpi_rsdp = FindAcpiRsdp(SystemTable); - Print(L"ACPI RSDP: 0x%lx\r\n", BootInfo.acpi_rsdp); + BootInfo.acpi_rsdp = AcpiRsdp; static boot_info_t static_boot_info; static_boot_info = BootInfo;