diff --git a/stand/efi/loader/Makefile b/stand/efi/loader/Makefile --- a/stand/efi/loader/Makefile +++ b/stand/efi/loader/Makefile @@ -43,6 +43,8 @@ CFLAGS.bootinfo.c += -I${SRCTOP}/contrib/pnglite CFLAGS.framebuffer.c += -I$(SRCTOP)/sys/teken CFLAGS.framebuffer.c += -I${SRCTOP}/contrib/pnglite +CFLAGS.efi_main.c += -I$(SRCTOP)/sys/teken +CFLAGS.efi_main.c += -I${SRCTOP}/contrib/pnglite CFLAGS.main.c += -I$(SRCTOP)/sys/teken CFLAGS.main.c += -I${SRCTOP}/contrib/pnglite CFLAGS.gfx_fb.c += -I$(SRCTOP)/sys/teken diff --git a/stand/efi/loader/copy.c b/stand/efi/loader/copy.c --- a/stand/efi/loader/copy.c +++ b/stand/efi/loader/copy.c @@ -192,7 +192,7 @@ bool stage_offset_set = false; ssize_t stage_offset; -static void +void efi_copy_free(void) { BS->FreePages(staging_base, (staging_end - staging_base) / diff --git a/stand/efi/loader/efi_main.c b/stand/efi/loader/efi_main.c --- a/stand/efi/loader/efi_main.c +++ b/stand/efi/loader/efi_main.c @@ -28,6 +28,8 @@ #include #include #include +#include +#include #include static EFI_PHYSICAL_ADDRESS heap; @@ -36,10 +38,25 @@ void efi_exit(EFI_STATUS exit_code) { + extern char panicbuf[160]; if (boot_services_active) { + UINTN size = (strlen(panicbuf) + 1) * 2; + CHAR16 *msg; + if (BS->AllocatePool(EfiLoaderData, size, (void **)&msg) != + EFI_SUCCESS) { + size = 0; + msg = NULL; + } else { + cpy8to16(panicbuf, msg, size); + } + + efi_copy_free(); + if (gfx_state.tg_shadow_fb != NULL) + BS->FreePages((uintptr_t)gfx_state.tg_shadow_fb, + gfx_state.tg_shadow_sz); BS->FreePages(heap, EFI_SIZE_TO_PAGES(heapsize)); - BS->Exit(IH, exit_code, 0, NULL); + BS->Exit(IH, exit_code, size, msg); } else { RS->ResetSystem(EfiResetCold, EFI_SUCCESS, 0, NULL); } diff --git a/stand/efi/loader/loader_efi.h b/stand/efi/loader/loader_efi.h --- a/stand/efi/loader/loader_efi.h +++ b/stand/efi/loader/loader_efi.h @@ -50,6 +50,7 @@ int efi_autoload(void); int efi_copy_init(void); +void efi_copy_free(void); ssize_t efi_copyin(const void *src, vm_offset_t dest, const size_t len); ssize_t efi_copyout(const vm_offset_t src, void *dest, const size_t len); diff --git a/stand/libsa/panic.c b/stand/libsa/panic.c --- a/stand/libsa/panic.c +++ b/stand/libsa/panic.c @@ -36,6 +36,7 @@ #include #include +char panicbuf[160]; /* * Boot loaders and other standalone programs that wish to have a * different panic policy can provide their own panic_action rotuine. @@ -43,6 +44,7 @@ __weak_symbol void panic_action(void) { + printf("%s\n", panicbuf); printf("--> Press a key on the console to reboot <--\n"); getchar(); printf("Rebooting...\n"); @@ -56,8 +58,7 @@ printf("panic: "); va_start(ap, fmt); - vprintf(fmt, ap); + vsnprintf(panicbuf, sizeof(panicbuf), fmt, ap); va_end(ap); - printf("\n"); panic_action(); }