毎回EFI_STATUS
の値を調べるのが手間なのでここでまとめておく.
TL;DR
EFI_STATUS | Value (64-bit) |
---|---|
EFI_SUCCESS | 0x0 |
EFI_LOAD_ERROR | 0x8000000000000001 |
EFI_INVALID_PARAMETER | 0x8000000000000002 |
EFI_UNSUPPORTED | 0x8000000000000003 |
EFI_BAD_BUFFER_SIZE | 0x8000000000000004 |
EFI_BUFFER_TOO_SMALL | 0x8000000000000005 |
EFI_NOT_READY | 0x8000000000000006 |
EFI_DEVICE_ERROR | 0x8000000000000007 |
EFI_WRITE_PROTECTED | 0x8000000000000008 |
EFI_OUT_OF_RESOURCES | 0x8000000000000009 |
EFI_VOLUME_CORRUPTED | 0x800000000000000a |
EFI_VOLUME_FULL | 0x800000000000000b |
EFI_NO_MEDIA | 0x800000000000000c |
EFI_MEDIA_CHANGED | 0x800000000000000d |
EFI_NOT_FOUND | 0x800000000000000e |
EFI_ACCESS_DENIED | 0x800000000000000f |
EFI_NO_RESPONSE | 0x8000000000000010 |
EFI_NO_MAPPING | 0x8000000000000011 |
EFI_TIMEOUT | 0x8000000000000012 |
EFI_NOT_STARTED | 0x8000000000000013 |
EFI_ALREADY_STARTED | 0x8000000000000014 |
EFI_ABORTED | 0x8000000000000015 |
EFI_ICMP_ERROR | 0x8000000000000016 |
EFI_TFTP_ERROR | 0x8000000000000017 |
EFI_PROTOCOL_ERROR | 0x8000000000000018 |
EFI_INCOMPATIBLE_VERSION | 0x8000000000000019 |
EFI_SECURITY_VIOLATION | 0x800000000000001a |
EFI_CRC_ERROR | 0x800000000000001b |
EFI_END_OF_MEDIA | 0x800000000000001c |
EFI_END_OF_FILE | 0x800000000000001f |
EFI_INVALID_LANGUAGE | 0x8000000000000020 |
EFI_COMPROMISED_DATA | 0x8000000000000021 |
EFI_HTTP_ERROR | 0x8000000000000023 |
EFI_NETWORK_UNREACHABLE | 0x8000000000000064 |
EFI_HOST_UNREACHABLE | 0x8000000000000065 |
EFI_PROTOCOL_UNREACHABLE | 0x8000000000000066 |
EFI_PORT_UNREACHABLE | 0x8000000000000067 |
EFI_CONNECTION_FIN | 0x8000000000000068 |
EFI_CONNECTION_RESET | 0x8000000000000069 |
EFI_CONNECTION_REFUSED | 0x800000000000006a |
EFI_WARN_UNKNOWN_GLYPH | 0x1 |
EFI_WARN_DELETE_FAILURE | 0x2 |
EFI_WARN_WRITE_FAILURE | 0x3 |
EFI_WARN_BUFFER_TOO_SMALL | 0x4 |
EFI_WARN_STALE_DATA | 0x5 |
EFI_WARN_FILE_SYSTEM | 0x6 |
EDK2での定義
/// /// Function return status for EFI API. /// typedef RETURN_STATUS EFI_STATUS;
// // Status codes common to all execution phases // typedef UINTN RETURN_STATUS;
なのでEFI_STATUS
はUINTN
である.
x64ではUINTN
はUINT64
となっている.
/// /// Enumeration of EFI_STATUS. ///@{ #define EFI_SUCCESS RETURN_SUCCESS #define EFI_LOAD_ERROR RETURN_LOAD_ERROR #define EFI_INVALID_PARAMETER RETURN_INVALID_PARAMETER #define EFI_UNSUPPORTED RETURN_UNSUPPORTED #define EFI_BAD_BUFFER_SIZE RETURN_BAD_BUFFER_SIZE #define EFI_BUFFER_TOO_SMALL RETURN_BUFFER_TOO_SMALL #define EFI_NOT_READY RETURN_NOT_READY #define EFI_DEVICE_ERROR RETURN_DEVICE_ERROR #define EFI_WRITE_PROTECTED RETURN_WRITE_PROTECTED #define EFI_OUT_OF_RESOURCES RETURN_OUT_OF_RESOURCES #define EFI_VOLUME_CORRUPTED RETURN_VOLUME_CORRUPTED #define EFI_VOLUME_FULL RETURN_VOLUME_FULL #define EFI_NO_MEDIA RETURN_NO_MEDIA #define EFI_MEDIA_CHANGED RETURN_MEDIA_CHANGED #define EFI_NOT_FOUND RETURN_NOT_FOUND #define EFI_ACCESS_DENIED RETURN_ACCESS_DENIED #define EFI_NO_RESPONSE RETURN_NO_RESPONSE #define EFI_NO_MAPPING RETURN_NO_MAPPING #define EFI_TIMEOUT RETURN_TIMEOUT #define EFI_NOT_STARTED RETURN_NOT_STARTED #define EFI_ALREADY_STARTED RETURN_ALREADY_STARTED #define EFI_ABORTED RETURN_ABORTED #define EFI_ICMP_ERROR RETURN_ICMP_ERROR #define EFI_TFTP_ERROR RETURN_TFTP_ERROR #define EFI_PROTOCOL_ERROR RETURN_PROTOCOL_ERROR #define EFI_INCOMPATIBLE_VERSION RETURN_INCOMPATIBLE_VERSION #define EFI_SECURITY_VIOLATION RETURN_SECURITY_VIOLATION #define EFI_CRC_ERROR RETURN_CRC_ERROR #define EFI_END_OF_MEDIA RETURN_END_OF_MEDIA #define EFI_END_OF_FILE RETURN_END_OF_FILE #define EFI_INVALID_LANGUAGE RETURN_INVALID_LANGUAGE #define EFI_COMPROMISED_DATA RETURN_COMPROMISED_DATA #define EFI_HTTP_ERROR RETURN_HTTP_ERROR #define EFI_WARN_UNKNOWN_GLYPH RETURN_WARN_UNKNOWN_GLYPH #define EFI_WARN_DELETE_FAILURE RETURN_WARN_DELETE_FAILURE #define EFI_WARN_WRITE_FAILURE RETURN_WARN_WRITE_FAILURE #define EFI_WARN_BUFFER_TOO_SMALL RETURN_WARN_BUFFER_TOO_SMALL #define EFI_WARN_STALE_DATA RETURN_WARN_STALE_DATA #define EFI_WARN_FILE_SYSTEM RETURN_WARN_FILE_SYSTEM ///@} /// /// Define macro to encode the status code. /// #define EFIERR(_a) ENCODE_ERROR(_a) #define EFI_ERROR(A) RETURN_ERROR(A) /// /// ICMP error definitions ///@{ #define EFI_NETWORK_UNREACHABLE EFIERR(100) #define EFI_HOST_UNREACHABLE EFIERR(101) #define EFI_PROTOCOL_UNREACHABLE EFIERR(102) #define EFI_PORT_UNREACHABLE EFIERR(103) ///@} /// /// Tcp connection status definitions ///@{ #define EFI_CONNECTION_FIN EFIERR(104) #define EFI_CONNECTION_RESET EFIERR(105) #define EFI_CONNECTION_REFUSED EFIERR(106) ///@}
#define RETURN_SUCCESS 0 #define RETURN_LOAD_ERROR ENCODE_ERROR (1) #define RETURN_INVALID_PARAMETER ENCODE_ERROR (2) #define RETURN_UNSUPPORTED ENCODE_ERROR (3) #define RETURN_BAD_BUFFER_SIZE ENCODE_ERROR (4) #define RETURN_BUFFER_TOO_SMALL ENCODE_ERROR (5) #define RETURN_NOT_READY ENCODE_ERROR (6) #define RETURN_DEVICE_ERROR ENCODE_ERROR (7) #define RETURN_WRITE_PROTECTED ENCODE_ERROR (8) #define RETURN_OUT_OF_RESOURCES ENCODE_ERROR (9) #define RETURN_VOLUME_CORRUPTED ENCODE_ERROR (10) #define RETURN_VOLUME_FULL ENCODE_ERROR (11) #define RETURN_NO_MEDIA ENCODE_ERROR (12) #define RETURN_MEDIA_CHANGED ENCODE_ERROR (13) #define RETURN_NOT_FOUND ENCODE_ERROR (14) #define RETURN_ACCESS_DENIED ENCODE_ERROR (15) #define RETURN_NO_RESPONSE ENCODE_ERROR (16) #define RETURN_NO_MAPPING ENCODE_ERROR (17) #define RETURN_TIMEOUT ENCODE_ERROR (18) #define RETURN_NOT_STARTED ENCODE_ERROR (19) #define RETURN_ALREADY_STARTED ENCODE_ERROR (20) #define RETURN_ABORTED ENCODE_ERROR (21) #define RETURN_ICMP_ERROR ENCODE_ERROR (22) #define RETURN_TFTP_ERROR ENCODE_ERROR (23) #define RETURN_PROTOCOL_ERROR ENCODE_ERROR (24) #define RETURN_INCOMPATIBLE_VERSION ENCODE_ERROR (25) #define RETURN_SECURITY_VIOLATION ENCODE_ERROR (26) #define RETURN_CRC_ERROR ENCODE_ERROR (27) #define RETURN_END_OF_MEDIA ENCODE_ERROR (28) #define RETURN_END_OF_FILE ENCODE_ERROR (31) #define RETURN_INVALID_LANGUAGE ENCODE_ERROR (32) #define RETURN_COMPROMISED_DATA ENCODE_ERROR (33) #define RETURN_HTTP_ERROR ENCODE_ERROR (35)
#define RETURN_WARN_UNKNOWN_GLYPH ENCODE_WARNING (1) #define RETURN_WARN_DELETE_FAILURE ENCODE_WARNING (2) #define RETURN_WARN_WRITE_FAILURE ENCODE_WARNING (3) #define RETURN_WARN_BUFFER_TOO_SMALL ENCODE_WARNING (4) #define RETURN_WARN_STALE_DATA ENCODE_WARNING (5) #define RETURN_WARN_FILE_SYSTEM ENCODE_WARNING (6)
#define ENCODE_ERROR(StatusCode) ((RETURN_STATUS)(MAX_BIT | (StatusCode)))
#define ENCODE_WARNING(StatusCode) ((RETURN_STATUS)(StatusCode))
ここでMAX_BIT
はx64では次のようになっている.
#define MAX_BIT 0x8000000000000000ULL
以上をまとめるとx64ではEFI_STATUS
の値は最初に示した表のようになる.
以下は表の生成に利用したスクリプトである.
#!/usr/bin/env python import sys MAX_BIT = 0x8000000000000000 # MAX_BIT = 0x80000000 def print_row(status, val, status_width, val_width): status_padding = status_width - len(status) val_padding = val_width - len(val) print('| ' + status + ' ' * status_padding + ' | ' \ + val + ' ' * val_padding + ' |') def main(): if len(sys.argv) < 3: return -1 efi_status_path = sys.argv[1] efi_to_return = dict() with open(efi_status_path, 'r') as fp: for line in fp: [_, efi_status, return_status] = line.strip().split() efi_to_return[efi_status] = return_status return_status_path = sys.argv[2] return_to_val = dict() with open(return_status_path, 'r') as fp: for line in fp: [_, return_status, val] = line.strip().split() return_to_val[return_status] = val status_width = max(map(len, efi_to_return.keys())) val_width = len(hex(MAX_BIT)) print_row('EFI_STATUS', 'Value (64-bit)', status_width, val_width) print_row('-' * status_width, '-' * val_width, status_width, val_width) for (efi_status, return_status) in efi_to_return.items(): if return_status.startswith('EFIERR'): v = return_status else: v = return_to_val[return_status] if v.startswith('ENCODE_ERROR') or v.startswith('EFIERR'): val = MAX_BIT | int(v[v.index('(')+1:v.index(')')]) elif v.startswith('ENCODE_WARNING'): val = int(v[v.index('(')+1:v.index(')')]) else: val = int(v) # 0 is expected print_row(efi_status, hex(val), status_width, val_width) return 0 if __name__ == '__main__': sys.exit(main())