diff options
| author | Toomas Soome <tsoome@FreeBSD.org> | 2025-09-04 12:24:25 +0000 |
|---|---|---|
| committer | Toomas Soome <tsoome@FreeBSD.org> | 2025-09-11 15:47:53 +0000 |
| commit | ed19c4ff846e09e00d8e2a756845261e2b6b7345 (patch) | |
| tree | 06f3dad2889c47ae055e657f20c00ad8bc01d1c9 | |
| parent | 3c38dce87ecd2c87744e4b7ff1904ee841f88a47 (diff) | |
loader.efi: improve StartImage error message
StartImage() may return additional data from failure. This data
has text message followed by optional binary blob. Print
out the text message (if present) and free the data.
See 7.4.2 EFI_BOOT_SERVICES.StartImage() page 199
UEFI_Spec_Final_2.11.pdf.
Reviewed by: imp
| -rw-r--r-- | stand/efi/loader/main.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/stand/efi/loader/main.c b/stand/efi/loader/main.c index 208b8b424e60..3e179bd4296c 100644 --- a/stand/efi/loader/main.c +++ b/stand/efi/loader/main.c @@ -1854,6 +1854,8 @@ command_chain(int argc, char *argv[]) EFI_GUID LoadedImageGUID = LOADED_IMAGE_PROTOCOL; EFI_HANDLE loaderhandle; EFI_LOADED_IMAGE *loaded_image; + UINTN ExitDataSize; + CHAR16 *ExitData = NULL; EFI_STATUS status; struct stat st; struct devdesc *dev; @@ -1969,9 +1971,16 @@ command_chain(int argc, char *argv[]) } dev_cleanup(); - status = BS->StartImage(loaderhandle, NULL, NULL); + + status = BS->StartImage(loaderhandle, &ExitDataSize, &ExitData); if (status != EFI_SUCCESS) { - command_errmsg = "StartImage failed"; + printf("StartImage failed (%lu)", EFI_ERROR_CODE(status)); + if (ExitData != NULL) { + printf(": %S", ExitData); + BS->FreePool(ExitData); + } + putchar('\n'); + command_errmsg = ""; free(loaded_image->LoadOptions); loaded_image->LoadOptions = NULL; status = BS->UnloadImage(loaded_image); |
