summaryrefslogtreecommitdiffstats
path: root/src/include
diff options
context:
space:
mode:
authorMichael Brown2014-03-10 17:36:21 +0100
committerMichael Brown2014-03-10 17:39:46 +0100
commit9681170fbe0a5877fdc21ce4a4166e81918d8451 (patch)
treebd47459ea861548ac28c480aa745b4919e0b1754 /src/include
parent[image] Add "--timeout" parameter to image downloading commands (diff)
downloadipxe-9681170fbe0a5877fdc21ce4a4166e81918d8451.tar.gz
ipxe-9681170fbe0a5877fdc21ce4a4166e81918d8451.tar.xz
ipxe-9681170fbe0a5877fdc21ce4a4166e81918d8451.zip
[efi] Allow for 64-bit EFI_STATUS codes
On a 64-bit build, EFI_STATUS codes are 64-bit quantities, with the "error/warning" bit located in bit 63. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include')
-rw-r--r--src/include/ipxe/errno/efi.h25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/include/ipxe/errno/efi.h b/src/include/ipxe/errno/efi.h
index e4f9e5fe1..2d2c50176 100644
--- a/src/include/ipxe/errno/efi.h
+++ b/src/include/ipxe/errno/efi.h
@@ -9,15 +9,15 @@
* We derive our platform error codes from the possible values for
* EFI_STATUS defined in the UEFI specification.
*
- * EFI_STATUS codes are 32-bit values consisting of a top bit which is
- * set for errors and clear for warnings, and a mildly undefined
- * code of low bits indicating the precise error/warning code.
- * Errors and warnings have completely separate namespaces.
+ * EFI_STATUS codes are 32/64-bit values consisting of a top bit which
+ * is set for errors and clear for warnings, and a mildly undefined
+ * code of low bits indicating the precise error/warning code. Errors
+ * and warnings have completely separate namespaces.
*
* We assume that no EFI_STATUS code will ever be defined which uses
* more than bits 0-6 of the low bits. We then choose to encode our
- * platform-specific error by mapping bit 31 of the EFI_STATUS to bit
- * 7 of the platform-specific error code, and preserving bits 0-6
+ * platform-specific error by mapping bit 31/63 of the EFI_STATUS to
+ * bit 7 of the platform-specific error code, and preserving bits 0-6
* as-is.
*/
@@ -26,14 +26,18 @@ FILE_LICENCE ( GPL2_OR_LATER );
#include <ipxe/efi/efi.h>
#include <ipxe/efi/Uefi/UefiBaseType.h>
+/** Bit shift for EFI error/warning bit */
+#define EFI_ERR_SHIFT ( 8 * ( sizeof ( EFI_STATUS ) - 1 ) )
+
/**
* Convert platform error code to platform component of iPXE error code
*
* @v platform Platform error code
* @ret errno Platform component of iPXE error code
*/
-#define PLATFORM_TO_ERRNO( platform ) \
- ( ( (platform) | ( (platform) >> 24 ) ) & 0xff )
+#define PLATFORM_TO_ERRNO( platform ) \
+ ( ( (platform) | \
+ ( ( ( EFI_STATUS ) (platform) ) >> EFI_ERR_SHIFT ) ) & 0xff )
/**
* Convert iPXE error code to platform error code
@@ -41,8 +45,9 @@ FILE_LICENCE ( GPL2_OR_LATER );
* @v errno iPXE error code
* @ret platform Platform error code
*/
-#define ERRNO_TO_PLATFORM( errno ) \
- ( ( ( (errno) << 24 ) | (errno) ) & 0x8000007f )
+#define ERRNO_TO_PLATFORM( errno ) \
+ ( ( ( ( EFI_STATUS ) (errno) & 0x80 ) << EFI_ERR_SHIFT ) | \
+ ( (errno) & 0x7f ) )
/* Platform-specific error codes */
#define PLATFORM_ENOERR EFI_SUCCESS