summaryrefslogtreecommitdiffstats
path: root/src/interface/efi/efi_init.c
diff options
context:
space:
mode:
authorMichael Brown2013-04-18 22:29:53 +0200
committerMichael Brown2013-04-19 14:34:19 +0200
commit54409583e29c481556e94a99dc73316d18aafc74 (patch)
tree150a8ceb85c1b523dc8dd8dd36daf8f6260e6538 /src/interface/efi/efi_init.c
parent[libc] Redefine low 8 bits of error code as "platform error code" (diff)
downloadipxe-54409583e29c481556e94a99dc73316d18aafc74.tar.gz
ipxe-54409583e29c481556e94a99dc73316d18aafc74.tar.xz
ipxe-54409583e29c481556e94a99dc73316d18aafc74.zip
[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/interface/efi/efi_init.c')
-rw-r--r--src/interface/efi/efi_init.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/interface/efi/efi_init.c b/src/interface/efi/efi_init.c
index e40de4dd5..2f6ca89c2 100644
--- a/src/interface/efi/efi_init.c
+++ b/src/interface/efi/efi_init.c
@@ -20,6 +20,7 @@
FILE_LICENCE ( GPL2_OR_LATER );
#include <string.h>
+#include <errno.h>
#include <ipxe/efi/efi.h>
#include <ipxe/efi/Protocol/LoadedImage.h>
#include <ipxe/efi/Protocol/DevicePath.h>
@@ -94,6 +95,7 @@ EFI_STATUS efi_init ( EFI_HANDLE image_handle,
void *loaded_image;
void *loaded_image_path;
EFI_STATUS efirc;
+ int rc;
/* Store image handle and system table pointer for future use */
efi_image_handle = image_handle;
@@ -149,8 +151,9 @@ EFI_STATUS efi_init ( EFI_HANDLE image_handle,
&efi_loaded_image_protocol_guid,
&loaded_image, image_handle, NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) {
+ rc = -EEFI ( efirc );
DBGC ( systab, "EFI could not get loaded image protocol: %s",
- efi_strerror ( efirc ) );
+ strerror ( rc ) );
return efirc;
}
efi_loaded_image = loaded_image;
@@ -162,8 +165,9 @@ EFI_STATUS efi_init ( EFI_HANDLE image_handle,
&efi_loaded_image_device_path_protocol_guid,
&loaded_image_path, image_handle, NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) {
+ rc = -EEFI ( efirc );
DBGC ( systab, "EFI could not get loaded image device path "
- "protocol: %s", efi_strerror ( efirc ) );
+ "protocol: %s", strerror ( rc ) );
return efirc;
}
efi_loaded_image_path = loaded_image_path;
@@ -179,8 +183,9 @@ EFI_STATUS efi_init ( EFI_HANDLE image_handle,
if ( ( efirc = bs->CreateEvent ( EVT_SIGNAL_EXIT_BOOT_SERVICES,
TPL_CALLBACK, efi_shutdown_hook,
NULL, &efi_shutdown_event ) ) != 0 ) {
+ rc = -EEFI ( efirc );
DBGC ( systab, "EFI could not create ExitBootServices event: "
- "%s\n", efi_strerror ( efirc ) );
+ "%s\n", strerror ( rc ) );
return efirc;
}