aboutsummaryrefslogtreecommitdiff
path: root/src/image
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2013-04-18 21:29:53 +0100
committerMichael Brown <mcb30@ipxe.org>2013-04-19 13:34:19 +0100
commit54409583e29c481556e94a99dc73316d18aafc74 (patch)
tree150a8ceb85c1b523dc8dd8dd36daf8f6260e6538 /src/image
parent73480352315a12fdef467402ea41be9ac285e4e7 (diff)
downloadipxe-54409583e29c481556e94a99dc73316d18aafc74.zip
ipxe-54409583e29c481556e94a99dc73316d18aafc74.tar.gz
ipxe-54409583e29c481556e94a99dc73316d18aafc74.tar.bz2
[efi] Perform meaningful error code conversions
Exploit the redefinition of iPXE error codes to include a "platform error code" to allow for meaningful conversion of EFI_STATUS values to iPXE errors and vice versa. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/image')
-rw-r--r--src/image/efi_image.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/image/efi_image.c b/src/image/efi_image.c
index 0368b82..0e90954 100644
--- a/src/image/efi_image.c
+++ b/src/image/efi_image.c
@@ -176,9 +176,9 @@ static int efi_image_exec ( struct image *image ) {
user_to_virt ( image->data, 0 ),
image->len, &handle ) ) != 0 ) {
/* Not an EFI image */
+ rc = -EEFI ( efirc );
DBGC ( image, "EFIIMAGE %p could not load: %s\n",
- image, efi_strerror ( efirc ) );
- rc = -ENOEXEC;
+ image, strerror ( rc ) );
goto err_load_image;
}
@@ -188,7 +188,7 @@ static int efi_image_exec ( struct image *image ) {
NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL );
if ( efirc ) {
/* Should never happen */
- rc = EFIRC_TO_RC ( efirc );
+ rc = -EEFI ( efirc );
goto err_open_protocol;
}
@@ -205,9 +205,9 @@ static int efi_image_exec ( struct image *image ) {
/* Start the image */
if ( ( efirc = bs->StartImage ( handle, NULL, NULL ) ) != 0 ) {
+ rc = -EEFI ( efirc );
DBGC ( image, "EFIIMAGE %p returned with status %s\n",
- image, efi_strerror ( efirc ) );
- rc = EFIRC_TO_RC ( efirc );
+ image, strerror ( rc ) );
goto err_start_image;
}
@@ -220,8 +220,9 @@ static int efi_image_exec ( struct image *image ) {
* have no "unload" operation.
*/
if ( ( efirc = bs->UnloadImage ( handle ) ) != 0 ) {
+ rc = -EEFI ( efirc );
DBGC ( image, "EFIIMAGE %p could not unload: %s\n",
- image, efi_strerror ( efirc ) );
+ image, strerror ( rc ) );
}
err_load_image:
free ( cmdline );
@@ -246,15 +247,17 @@ static int efi_image_probe ( struct image *image ) {
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
EFI_HANDLE handle;
EFI_STATUS efirc;
+ int rc;
/* Attempt loading image */
if ( ( efirc = bs->LoadImage ( FALSE, efi_image_handle, NULL,
user_to_virt ( image->data, 0 ),
image->len, &handle ) ) != 0 ) {
/* Not an EFI image */
+ rc = -EEFI ( efirc );
DBGC ( image, "EFIIMAGE %p could not load: %s\n",
- image, efi_strerror ( efirc ) );
- return -ENOEXEC;
+ image, strerror ( rc ) );
+ return rc;
}
/* Unload the image. We can't leave it loaded, because we