#include #include #include #if uefi == 1 # include #endif #include #include #include #include __attribute__((noreturn)) void panic(const char *fmt, ...) { va_list args; va_start(args, fmt); print("\033[31mPANIC\033[37;1m\033[0m: "); vprint(fmt, args); va_end(args); print("\n"); print_stacktrace(NULL); #if bios == 1 print("System halted."); rm_hcf(); #elif uefi == 1 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(); } else { print("System halted."); for (;;) { asm ("hlt"); } } #endif }