Merge pull request #84 from chocabloc/trunk

Return to firmware instead of halting in UEFI mode
This commit is contained in:
mint 2021-05-19 08:46:20 +02:00 committed by GitHub
commit 0d3d667ba8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 2 deletions

View File

@ -1,6 +1,13 @@
#include <lib/print.h>
#include <lib/real.h>
#include <lib/trace.h>
#if defined (uefi)
# include <efi.h>
#endif
#include <lib/blib.h>
#include <lib/readline.h>
#include <lib/gterm.h>
#include <mm/pmm.h>
__attribute__((noreturn)) void panic(const char *fmt, ...) {
asm volatile ("cli" ::: "memory");
@ -18,8 +25,15 @@ __attribute__((noreturn)) void panic(const char *fmt, ...) {
print_stacktrace(NULL);
#if defined (bios)
print("System halted.");
rm_hcf();
#elif defined (uefi)
for (;;) asm ("hlt");
print("Press [ENTER] to return to firmware.");
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();
#endif
}

View File

@ -73,5 +73,5 @@ void print_stacktrace(size_t *base_ptr) {
break;
base_ptr = (void*)old_bp;
}
print("End of trace.\n");
print("End of trace. ");
}