diff options
author | Michael Brown | 2013-04-18 22:29:53 +0200 |
---|---|---|
committer | Michael Brown | 2013-04-19 14:34:19 +0200 |
commit | 54409583e29c481556e94a99dc73316d18aafc74 (patch) | |
tree | 150a8ceb85c1b523dc8dd8dd36daf8f6260e6538 /src/interface/efi/efi_timer.c | |
parent | [libc] Redefine low 8 bits of error code as "platform error code" (diff) | |
download | ipxe-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_timer.c')
-rw-r--r-- | src/interface/efi/efi_timer.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/interface/efi/efi_timer.c b/src/interface/efi/efi_timer.c index b110cae2..7a1ff786 100644 --- a/src/interface/efi/efi_timer.c +++ b/src/interface/efi/efi_timer.c @@ -19,6 +19,8 @@ FILE_LICENCE ( GPL2_OR_LATER ); +#include <string.h> +#include <errno.h> #include <limits.h> #include <assert.h> #include <unistd.h> @@ -54,10 +56,12 @@ EFI_REQUIRE_PROTOCOL ( EFI_CPU_ARCH_PROTOCOL, &cpu_arch ); static void efi_udelay ( unsigned long usecs ) { EFI_BOOT_SERVICES *bs = efi_systab->BootServices; EFI_STATUS efirc; + int rc; if ( ( efirc = bs->Stall ( usecs ) ) != 0 ) { + rc = -EEFI ( efirc ); DBG ( "EFI could not delay for %ldus: %s\n", - usecs, efi_strerror ( efirc ) ); + usecs, strerror ( rc ) ); /* Probably screwed */ } } @@ -70,12 +74,13 @@ static void efi_udelay ( unsigned long usecs ) { static unsigned long efi_currticks ( void ) { UINT64 time; EFI_STATUS efirc; + int rc; /* Read CPU timer 0 (TSC) */ if ( ( efirc = cpu_arch->GetTimerValue ( cpu_arch, 0, &time, NULL ) ) != 0 ) { - DBG ( "EFI could not read CPU timer: %s\n", - efi_strerror ( efirc ) ); + rc = -EEFI ( efirc ); + DBG ( "EFI could not read CPU timer: %s\n", strerror ( rc ) ); /* Probably screwed */ return -1UL; } |