:: commit e2c6a23c6c8f10b9b6ccd47f82145221116a9d96

mintsuki <mintsuki@protonmail.com> — 2022-08-04 12:16

parents: 768e383305

linux: Find compromise for 32-bit EFI boot

diff --git a/common/protos/linux.c b/common/protos/linux.c
index 60ee699d..ebf1b71d 100644
--- a/common/protos/linux.c
+++ b/common/protos/linux.c
@@ -577,15 +577,24 @@ set_textmode:;
 
 #if defined (__x86_64__)
     memcpy(&boot_params->efi_info.efi_loader_signature, "EL64", 4);
+#elif defined (__i386__)
+    memcpy(&boot_params->efi_info.efi_loader_signature, "EL32", 4);
+#endif
 
     boot_params->efi_info.efi_systab    = (uint32_t)(uint64_t)(uintptr_t)gST;
     boot_params->efi_info.efi_systab_hi = (uint32_t)((uint64_t)(uintptr_t)gST >> 32);
     boot_params->efi_info.efi_memmap    = (uint32_t)(uint64_t)(uintptr_t)efi_mmap;
     boot_params->efi_info.efi_memmap_hi = (uint32_t)((uint64_t)(uintptr_t)efi_mmap >> 32);
+#if defined (__x86_64__)
     boot_params->efi_info.efi_memmap_size     = efi_mmap_size;
+#elif defined (__i386__)
+    // A memmap size of 0 will cause Linux to force bail out of trying to use
+    // 32-bit EFI runtime services without ignoring other EFI info.
+    // XXX: Figure out why 64-bit Linux hangs if trying to use 32-bit boot services.
+    boot_params->efi_info.efi_memmap_size     = 0;
+#endif
     boot_params->efi_info.efi_memdesc_size    = efi_desc_size;
     boot_params->efi_info.efi_memdesc_version = efi_desc_ver;
-#endif
 #endif
 
     ///////////////////////////////////////
tab: 248 wrap: offon