mirror of
https://github.com/limine-bootloader/limine
synced 2025-01-05 20:34:33 +03:00
efi: Properly propagate exits after loading an image using chainloading; do not try to return from panics if boot services were exited
This commit is contained in:
parent
eadee3e6cb
commit
ae2d924c14
@ -26,13 +26,20 @@ __attribute__((noreturn)) void panic(const char *fmt, ...) {
|
||||
print("System halted.");
|
||||
rm_hcf();
|
||||
#elif defined (uefi)
|
||||
print("Press [ENTER] to return to firmware.");
|
||||
while (getchar() != '\n');
|
||||
fb_clear(&fbinfo);
|
||||
if (efi_boot_services_exited == false) {
|
||||
print("Press [ENTER] to return to firmware.");
|
||||
while (getchar() != '\n');
|
||||
fb_clear(&fbinfo);
|
||||
|
||||
// release all uefi memory and return to firmware
|
||||
pmm_release_uefi_mem();
|
||||
uefi_call_wrapper(gBS->Exit, 4, efi_image_handle, EFI_ABORTED, 0, NULL);
|
||||
__builtin_unreachable();
|
||||
// release all uefi memory and return to firmware
|
||||
pmm_release_uefi_mem();
|
||||
uefi_call_wrapper(gBS->Exit, 4, efi_image_handle, EFI_ABORTED, 0, NULL);
|
||||
__builtin_unreachable();
|
||||
} else {
|
||||
print("System halted.");
|
||||
for (;;) {
|
||||
asm ("hlt");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -189,9 +189,15 @@ void chainload(char *config) {
|
||||
|
||||
new_handle_loaded_image->DeviceHandle = loader_loaded_image->DeviceHandle;
|
||||
|
||||
status = uefi_call_wrapper(gBS->StartImage, 3, new_handle, NULL, NULL);
|
||||
UINTN exit_data_size = 0;
|
||||
CHAR16 *exit_data = NULL;
|
||||
EFI_STATUS exit_status = uefi_call_wrapper(gBS->StartImage, 3,
|
||||
new_handle, &exit_data_size, &exit_data);
|
||||
|
||||
status = uefi_call_wrapper(gBS->Exit, 4,
|
||||
efi_image_handle, exit_status, exit_data_size, exit_data);
|
||||
if (status) {
|
||||
panic("chainload: StartImage failure (%x)", status);
|
||||
panic("chainload: Exit failure (%x)", status);
|
||||
}
|
||||
|
||||
__builtin_unreachable();
|
||||
|
Loading…
Reference in New Issue
Block a user