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
This commit is contained in:
+11
-2
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user