|  | @@ -9,15 +9,15 @@
 | 
		
	
		
			
			| 9 | 9 |   * We derive our platform error codes from the possible values for
 | 
		
	
		
			
			| 10 | 10 |   * EFI_STATUS defined in the UEFI specification.
 | 
		
	
		
			
			| 11 | 11 |   *
 | 
		
	
		
			
			| 12 |  | - * EFI_STATUS codes are 32-bit values consisting of a top bit which is
 | 
		
	
		
			
			| 13 |  | - * set for errors and clear for warnings, and a mildly undefined
 | 
		
	
		
			
			| 14 |  | - * code of low bits indicating the precise error/warning code.
 | 
		
	
		
			
			| 15 |  | - * Errors and warnings have completely separate namespaces.
 | 
		
	
		
			
			|  | 12 | + * EFI_STATUS codes are 32/64-bit values consisting of a top bit which
 | 
		
	
		
			
			|  | 13 | + * is set for errors and clear for warnings, and a mildly undefined
 | 
		
	
		
			
			|  | 14 | + * code of low bits indicating the precise error/warning code.  Errors
 | 
		
	
		
			
			|  | 15 | + * and warnings have completely separate namespaces.
 | 
		
	
		
			
			| 16 | 16 |   *
 | 
		
	
		
			
			| 17 | 17 |   * We assume that no EFI_STATUS code will ever be defined which uses
 | 
		
	
		
			
			| 18 | 18 |   * more than bits 0-6 of the low bits.  We then choose to encode our
 | 
		
	
		
			
			| 19 |  | - * platform-specific error by mapping bit 31 of the EFI_STATUS to bit
 | 
		
	
		
			
			| 20 |  | - * 7 of the platform-specific error code, and preserving bits 0-6
 | 
		
	
		
			
			|  | 19 | + * platform-specific error by mapping bit 31/63 of the EFI_STATUS to
 | 
		
	
		
			
			|  | 20 | + * bit 7 of the platform-specific error code, and preserving bits 0-6
 | 
		
	
		
			
			| 21 | 21 |   * as-is.
 | 
		
	
		
			
			| 22 | 22 |   */
 | 
		
	
		
			
			| 23 | 23 |  
 | 
		
	
	
		
			
			|  | @@ -26,14 +26,18 @@ FILE_LICENCE ( GPL2_OR_LATER );
 | 
		
	
		
			
			| 26 | 26 |  #include <ipxe/efi/efi.h>
 | 
		
	
		
			
			| 27 | 27 |  #include <ipxe/efi/Uefi/UefiBaseType.h>
 | 
		
	
		
			
			| 28 | 28 |  
 | 
		
	
		
			
			|  | 29 | +/** Bit shift for EFI error/warning bit */
 | 
		
	
		
			
			|  | 30 | +#define EFI_ERR_SHIFT ( 8 * ( sizeof ( EFI_STATUS ) - 1 ) )
 | 
		
	
		
			
			|  | 31 | +
 | 
		
	
		
			
			| 29 | 32 |  /**
 | 
		
	
		
			
			| 30 | 33 |   * Convert platform error code to platform component of iPXE error code
 | 
		
	
		
			
			| 31 | 34 |   *
 | 
		
	
		
			
			| 32 | 35 |   * @v platform		Platform error code
 | 
		
	
		
			
			| 33 | 36 |   * @ret errno		Platform component of iPXE error code
 | 
		
	
		
			
			| 34 | 37 |   */
 | 
		
	
		
			
			| 35 |  | -#define PLATFORM_TO_ERRNO( platform ) \
 | 
		
	
		
			
			| 36 |  | -	( ( (platform) | ( (platform) >> 24 ) ) & 0xff )
 | 
		
	
		
			
			|  | 38 | +#define PLATFORM_TO_ERRNO( platform )					\
 | 
		
	
		
			
			|  | 39 | +	( ( (platform) |						\
 | 
		
	
		
			
			|  | 40 | +	    ( ( ( EFI_STATUS ) (platform) ) >> EFI_ERR_SHIFT ) ) & 0xff )
 | 
		
	
		
			
			| 37 | 41 |  
 | 
		
	
		
			
			| 38 | 42 |  /**
 | 
		
	
		
			
			| 39 | 43 |   * Convert iPXE error code to platform error code
 | 
		
	
	
		
			
			|  | @@ -41,8 +45,9 @@ FILE_LICENCE ( GPL2_OR_LATER );
 | 
		
	
		
			
			| 41 | 45 |   * @v errno		iPXE error code
 | 
		
	
		
			
			| 42 | 46 |   * @ret platform	Platform error code
 | 
		
	
		
			
			| 43 | 47 |   */
 | 
		
	
		
			
			| 44 |  | -#define ERRNO_TO_PLATFORM( errno ) \
 | 
		
	
		
			
			| 45 |  | -	( ( ( (errno) << 24 ) | (errno) ) & 0x8000007f )
 | 
		
	
		
			
			|  | 48 | +#define ERRNO_TO_PLATFORM( errno )					\
 | 
		
	
		
			
			|  | 49 | +	( ( ( ( EFI_STATUS ) (errno) & 0x80 ) << EFI_ERR_SHIFT ) |	\
 | 
		
	
		
			
			|  | 50 | +	  ( (errno) & 0x7f ) )
 | 
		
	
		
			
			| 46 | 51 |  
 | 
		
	
		
			
			| 47 | 52 |  /* Platform-specific error codes */
 | 
		
	
		
			
			| 48 | 53 |  #define PLATFORM_ENOERR		EFI_SUCCESS
 |