diff options
author | Michael Brown <mcb30@ipxe.org> | 2013-04-18 21:29:53 +0100 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2013-04-19 13:34:19 +0100 |
commit | 54409583e29c481556e94a99dc73316d18aafc74 (patch) | |
tree | 150a8ceb85c1b523dc8dd8dd36daf8f6260e6538 /src/interface/efi/efi_umalloc.c | |
parent | 73480352315a12fdef467402ea41be9ac285e4e7 (diff) | |
download | ipxe-54409583e29c481556e94a99dc73316d18aafc74.tar.gz |
[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_umalloc.c')
-rw-r--r-- | src/interface/efi/efi_umalloc.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/interface/efi/efi_umalloc.c b/src/interface/efi/efi_umalloc.c index b49949327..356efaa6f 100644 --- a/src/interface/efi/efi_umalloc.c +++ b/src/interface/efi/efi_umalloc.c @@ -19,6 +19,8 @@ FILE_LICENCE ( GPL2_OR_LATER ); +#include <string.h> +#include <errno.h> #include <assert.h> #include <ipxe/umalloc.h> #include <ipxe/efi/efi.h> @@ -49,6 +51,7 @@ static userptr_t efi_urealloc ( userptr_t old_ptr, size_t new_size ) { userptr_t new_ptr = UNOWHERE; size_t old_size; EFI_STATUS efirc; + int rc; /* Allocate new memory if necessary. If allocation fails, * return without touching the old block. @@ -59,8 +62,9 @@ static userptr_t efi_urealloc ( userptr_t old_ptr, size_t new_size ) { EfiBootServicesData, new_pages, &phys_addr ) ) != 0 ) { + rc = -EEFI ( efirc ); DBG ( "EFI could not allocate %d pages: %s\n", - new_pages, efi_strerror ( efirc ) ); + new_pages, strerror ( rc ) ); return UNULL; } assert ( phys_addr != 0 ); @@ -84,8 +88,9 @@ static userptr_t efi_urealloc ( userptr_t old_ptr, size_t new_size ) { old_pages = ( EFI_SIZE_TO_PAGES ( old_size ) + 1 ); phys_addr = user_to_phys ( old_ptr, -EFI_PAGE_SIZE ); if ( ( efirc = bs->FreePages ( phys_addr, old_pages ) ) != 0 ){ + rc = -EEFI ( efirc ); DBG ( "EFI could not free %d pages at %llx: %s\n", - old_pages, phys_addr, efi_strerror ( efirc ) ); + old_pages, phys_addr, strerror ( rc ) ); /* Not fatal; we have leaked memory but successfully * allocated (if asked to do so). */ |