mirror of
https://github.com/ipxe/ipxe
synced 2025-12-31 15:25:23 +03:00
[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>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user