Sridevi Ramesh | 70e1418 | 2019-08-27 04:04:27 -0500 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | |
| 3 | r""" |
| 4 | Contains PLDM-related constants. |
| 5 | """ |
| 6 | |
Rahul Maheshwari | 4d48857 | 2019-12-10 23:53:05 -0600 | [diff] [blame] | 7 | |
Sridevi Ramesh | c4e1cba | 2019-12-03 00:12:27 -0600 | [diff] [blame] | 8 | # PLDM types. |
| 9 | PLDM_TYPE_BASE = {'VALUE': '00', 'STRING': 'base'} |
| 10 | PLDM_TYPE_PLATFORM = {'VALUE': '02', 'STRING': 'platform'} |
| 11 | PLDM_TYPE_BIOS = {'VALUE': '03', 'STRING': 'bios'} |
| 12 | PLDM_TYPE_FRU = {'VALUE': '04', 'STRING': 'fru'} |
| 13 | PLDM_TYPE_OEM = {'VALUE': '3F', 'STRING': 'oem'} |
Sridevi Ramesh | 70e1418 | 2019-08-27 04:04:27 -0500 | [diff] [blame] | 14 | |
Sridevi Ramesh | c4e1cba | 2019-12-03 00:12:27 -0600 | [diff] [blame] | 15 | VERSION_BASE = {'VALUE': ['f1', 'f0', 'f0', '00'], 'STRING': '1.0.0'} |
| 16 | VERSION_PLATFORM = {'VALUE': ['f1', 'f0', 'f0', '00'], 'STRING': '1.1.1'} |
| 17 | VERSION_BIOS = {'VALUE': ['f1', 'f1', 'f1', '00'], 'STRING': '1.0.0'} |
| 18 | VERSION_FRU = {'VALUE': ['f1', 'f0', 'f0', '00'], 'STRING': '1.0.0'} |
Sridevi Ramesh | 70e1418 | 2019-08-27 04:04:27 -0500 | [diff] [blame] | 19 | |
Sridevi Ramesh | c4e1cba | 2019-12-03 00:12:27 -0600 | [diff] [blame] | 20 | # PLDM base related variables. |
Sridevi Ramesh | 70e1418 | 2019-08-27 04:04:27 -0500 | [diff] [blame] | 21 | PLDM_BASE_CMD = { |
Sridevi Ramesh | c4e1cba | 2019-12-03 00:12:27 -0600 | [diff] [blame] | 22 | 'GET_TID': '02', |
| 23 | 'GET_PLDM_VERSION': '03', |
| 24 | 'GET_PLDM_TYPES': '04', |
| 25 | 'GET_PLDM_COMMANDS': '05'} |
Sridevi Ramesh | 70e1418 | 2019-08-27 04:04:27 -0500 | [diff] [blame] | 26 | |
Sridevi Ramesh | c4e1cba | 2019-12-03 00:12:27 -0600 | [diff] [blame] | 27 | # Response lengths are inclusive of completion code. |
| 28 | GET_TID_RESP_BYTES = 2 |
| 29 | GET_PLDM_VERSION_RESP_BYTES = 10 |
| 30 | GET_PLDM_TYPES_RESP_BYTES = 9 |
| 31 | GET_PLDM_COMMANDS_RESP_BYTES = 33 |
Sridevi Ramesh | 70e1418 | 2019-08-27 04:04:27 -0500 | [diff] [blame] | 32 | |
Sridevi Ramesh | c4e1cba | 2019-12-03 00:12:27 -0600 | [diff] [blame] | 33 | # PLDM bios related variables. |
Sridevi Ramesh | 70e1418 | 2019-08-27 04:04:27 -0500 | [diff] [blame] | 34 | PLDM_BIOS_CMD = { |
| 35 | 'GET_BIOS_TABLE': '01', |
| 36 | 'SET_BIOS_ATTRIBUTE_CURRENT_VALUE': '07', |
| 37 | 'GET_BIOS_ATTRIBUTE_CURRENT_VALUE_BY_HANDLE': '08', |
| 38 | 'GET_DATE_TIME': '0c'} |
| 39 | |
Sridevi Ramesh | c4e1cba | 2019-12-03 00:12:27 -0600 | [diff] [blame] | 40 | PLDM_BIOS_TABLE_TYPES = { |
| 41 | 'STRING_TABLE': '00', |
| 42 | 'ATTRIBUTE_TABLE': '01', |
| 43 | 'ATTRIBUTE_VAL_TABLE': '02'} |
| 44 | |
| 45 | TRANSFER_OPERATION_FLAG = { |
| 46 | 'GETNEXTPART': '00', |
| 47 | 'GETFIRSTPART': '01'} |
| 48 | |
| 49 | TRANSFER_RESP_FLAG = { |
| 50 | 'PLDM_START': '01', |
| 51 | 'PLDM_MIDDLE': '02', |
| 52 | 'PLDM_END': '04', |
| 53 | 'PLDM_START_AND_END': '05'} |
| 54 | |
| 55 | # PLDM platform related variables. |
Sridevi Ramesh | 70e1418 | 2019-08-27 04:04:27 -0500 | [diff] [blame] | 56 | PLDM_PLATFORM_CMD = { |
| 57 | 'SET_STATE_EFFECTER_STATES': '39', |
| 58 | 'GET_PDR': '51'} |
| 59 | |
| 60 | PLDM_PDR_TYPES = { |
| 61 | 'STATE_EFFECTER_PDR': '11'} |
| 62 | |
| 63 | # PLDM OEM related variables. |
| 64 | PLDM_FILEIO_CMD = { |
| 65 | 'GET_FILE_TABLE': '1', |
| 66 | 'READ_FILE': '4', |
| 67 | 'WRITE_FILE': '5', |
| 68 | 'READ_FILE_INTO_MEMORY': '6', |
| 69 | 'WRITE_FILE_FROM_MEMORY': '7'} |
| 70 | |
| 71 | PLDM_FILEIO_COMPLETION_CODES = { |
| 72 | 'INVALID_FILE_HANDLE': '80', |
| 73 | 'DATA_OUT_OF_RANGE': '81', |
| 74 | 'INVALID_READ_LENGTH': '82', |
| 75 | 'INVALID_WRITE_LENGTH': '83', |
| 76 | 'FILE_TABLE_UNAVAILABLE': '84', |
| 77 | 'INVALID_FILE_TABLE_TYPE': '85'} |
Sridevi Ramesh | c4e1cba | 2019-12-03 00:12:27 -0600 | [diff] [blame] | 78 | |
| 79 | # PLDM FRU related variables. |
| 80 | PLDM_FRU_CMD = { |
| 81 | 'PLDM_GET_FRU_RECORD_TABLE_METADATA': '01', |
| 82 | 'PLDM_GET_FRU_RECORD_TABLE': '02'} |
| 83 | |
| 84 | # PLDM command format. |
| 85 | |
Rahul Maheshwari | 4d48857 | 2019-12-10 23:53:05 -0600 | [diff] [blame] | 86 | CMD_GETPLDMTYPES = 'base GetPLDMTypes' |
Sridevi Ramesh | c4e1cba | 2019-12-03 00:12:27 -0600 | [diff] [blame] | 87 | |
| 88 | ''' |
| 89 | e.g. : GetPLDMVersion usage |
| 90 | |
| 91 | pldmtool base GetPLDMVersion -t <pldm_type> |
| 92 | |
| 93 | pldm supported types |
| 94 | |
| 95 | base->0,platform->2,bios->3,fru->4 |
| 96 | |
| 97 | ''' |
Rahul Maheshwari | 4d48857 | 2019-12-10 23:53:05 -0600 | [diff] [blame] | 98 | CMD_GETPLDMVERSION = 'base GetPLDMVersion -t %s' |
Sridevi Ramesh | c4e1cba | 2019-12-03 00:12:27 -0600 | [diff] [blame] | 99 | |
| 100 | ''' |
| 101 | e.g. : PLDM raw command usage |
| 102 | |
| 103 | pldmtool raw -d 0x80 0x00 0x03 0x00 0x00 0x00 0x00 0x01 0x00 |
| 104 | |
| 105 | pldm raw -d 0x<header> 0x<pldm_type> 0x<pldm_cmd_type> 0x<payload_data> |
| 106 | ''' |
| 107 | |
Rahul Maheshwari | 4d48857 | 2019-12-10 23:53:05 -0600 | [diff] [blame] | 108 | CMD_PLDMTOOL_RAW = 'raw -d 0x80' + '0x%s' + ' ' + '0x%s' |
Sridevi Ramesh | c4e1cba | 2019-12-03 00:12:27 -0600 | [diff] [blame] | 109 | |
| 110 | |
| 111 | # PLDM command payload data. |
| 112 | |
| 113 | PAYLOAD_GetPLDMVersion = \ |
| 114 | ' 0x00 0x00 0x00 0x00 0x%s 0x%s' # %(TransferOperationFlag, PLDMType) |
Rahul Maheshwari | 4d48857 | 2019-12-10 23:53:05 -0600 | [diff] [blame] | 115 | |
| 116 | |
| 117 | PLDM_SUPPORTED_TYPES = ['base', 'platform', 'bios'] |