Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 1 | #ifndef OPENBMC_IPMI_FRU_PARSER_H |
| 2 | #define OPENBMC_IPMI_FRU_PARSER_H |
| 3 | |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 4 | #include <systemd/sd-bus.h> |
Ratan Gupta | cb0d4e5 | 2016-12-22 19:05:57 +0530 | [diff] [blame] | 5 | #include <array> |
Ratan Gupta | 6eed403 | 2017-02-10 15:59:31 +0530 | [diff] [blame] | 6 | #include <string> |
| 7 | #include <map> |
Chris Austen | b45c4cb | 2015-11-01 06:34:56 -0600 | [diff] [blame] | 8 | |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 9 | enum ipmi_fru_area_type |
Hariharasubramanian R | c2d7946 | 2015-10-16 06:47:56 -0500 | [diff] [blame] | 10 | { |
| 11 | IPMI_FRU_AREA_INTERNAL_USE = 0x00, |
| 12 | IPMI_FRU_AREA_CHASSIS_INFO, |
| 13 | IPMI_FRU_AREA_BOARD_INFO, |
| 14 | IPMI_FRU_AREA_PRODUCT_INFO, |
| 15 | IPMI_FRU_AREA_MULTI_RECORD, |
| 16 | IPMI_FRU_AREA_TYPE_MAX |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 17 | }; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 18 | |
Ratan Gupta | cb0d4e5 | 2016-12-22 19:05:57 +0530 | [diff] [blame] | 19 | |
| 20 | enum openbmc_vpd_key_id |
| 21 | { |
| 22 | OPENBMC_VPD_KEY_CHASSIS_TYPE = 1, /* not a type/len */ |
| 23 | OPENBMC_VPD_KEY_CHASSIS_PART_NUM, |
| 24 | OPENBMC_VPD_KEY_CHASSIS_SERIAL_NUM, |
| 25 | OPENBMC_VPD_KEY_CHASSIS_CUSTOM1, |
| 26 | OPENBMC_VPD_KEY_CHASSIS_CUSTOM2, |
| 27 | OPENBMC_VPD_KEY_CHASSIS_CUSTOM3, |
| 28 | OPENBMC_VPD_KEY_CHASSIS_CUSTOM4, |
| 29 | OPENBMC_VPD_KEY_CHASSIS_CUSTOM5, |
| 30 | OPENBMC_VPD_KEY_CHASSIS_CUSTOM6, |
| 31 | OPENBMC_VPD_KEY_CHASSIS_CUSTOM7, |
| 32 | OPENBMC_VPD_KEY_CHASSIS_CUSTOM8, |
| 33 | OPENBMC_VPD_KEY_CHASSIS_MAX = OPENBMC_VPD_KEY_CHASSIS_CUSTOM8, |
| 34 | /* TODO: chassis_custom_fields */ |
| 35 | |
| 36 | OPENBMC_VPD_KEY_BOARD_MFG_DATE, /* not a type/len */ |
| 37 | OPENBMC_VPD_KEY_BOARD_MFR, |
| 38 | OPENBMC_VPD_KEY_BOARD_NAME, |
| 39 | OPENBMC_VPD_KEY_BOARD_SERIAL_NUM, |
| 40 | OPENBMC_VPD_KEY_BOARD_PART_NUM, |
| 41 | OPENBMC_VPD_KEY_BOARD_FRU_FILE_ID, |
| 42 | OPENBMC_VPD_KEY_BOARD_CUSTOM1, |
| 43 | OPENBMC_VPD_KEY_BOARD_CUSTOM2, |
| 44 | OPENBMC_VPD_KEY_BOARD_CUSTOM3, |
| 45 | OPENBMC_VPD_KEY_BOARD_CUSTOM4, |
| 46 | OPENBMC_VPD_KEY_BOARD_CUSTOM5, |
| 47 | OPENBMC_VPD_KEY_BOARD_CUSTOM6, |
| 48 | OPENBMC_VPD_KEY_BOARD_CUSTOM7, |
| 49 | OPENBMC_VPD_KEY_BOARD_CUSTOM8, |
| 50 | OPENBMC_VPD_KEY_BOARD_MAX = OPENBMC_VPD_KEY_BOARD_CUSTOM8, |
| 51 | /* TODO: board_custom_fields */ |
| 52 | |
| 53 | OPENBMC_VPD_KEY_PRODUCT_MFR, |
| 54 | OPENBMC_VPD_KEY_PRODUCT_NAME, |
| 55 | OPENBMC_VPD_KEY_PRODUCT_PART_MODEL_NUM, |
| 56 | OPENBMC_VPD_KEY_PRODUCT_VER, |
| 57 | OPENBMC_VPD_KEY_PRODUCT_SERIAL_NUM, |
| 58 | OPENBMC_VPD_KEY_PRODUCT_ASSET_TAG, |
| 59 | OPENBMC_VPD_KEY_PRODUCT_FRU_FILE_ID, |
| 60 | OPENBMC_VPD_KEY_PRODUCT_CUSTOM1, |
| 61 | OPENBMC_VPD_KEY_PRODUCT_CUSTOM2, |
| 62 | OPENBMC_VPD_KEY_PRODUCT_CUSTOM3, |
| 63 | OPENBMC_VPD_KEY_PRODUCT_CUSTOM4, |
| 64 | OPENBMC_VPD_KEY_PRODUCT_CUSTOM5, |
| 65 | OPENBMC_VPD_KEY_PRODUCT_CUSTOM6, |
| 66 | OPENBMC_VPD_KEY_PRODUCT_CUSTOM7, |
| 67 | OPENBMC_VPD_KEY_PRODUCT_CUSTOM8, |
| 68 | OPENBMC_VPD_KEY_PRODUCT_MAX = OPENBMC_VPD_KEY_PRODUCT_CUSTOM8, |
| 69 | |
| 70 | OPENBMC_VPD_KEY_MAX, |
| 71 | OPENBMC_VPD_KEY_CUSTOM_FIELDS_MAX=8, |
| 72 | |
| 73 | }; |
| 74 | |
| 75 | using IPMIFruInfo = std::array<std::pair<std::string,std::string>, |
| 76 | OPENBMC_VPD_KEY_MAX>; |
| 77 | |
Patrick Williams | aeb726d | 2017-06-01 19:00:43 -0500 | [diff] [blame^] | 78 | struct IPMIFruData |
| 79 | { |
| 80 | std::string section; |
| 81 | std::string property; |
| 82 | std::string delimiter; |
| 83 | }; |
Ratan Gupta | 6eed403 | 2017-02-10 15:59:31 +0530 | [diff] [blame] | 84 | |
| 85 | using DbusProperty = std::string; |
Patrick Williams | aeb726d | 2017-06-01 19:00:43 -0500 | [diff] [blame^] | 86 | using DbusPropertyMap = std::map<DbusProperty,IPMIFruData>; |
Ratan Gupta | 6eed403 | 2017-02-10 15:59:31 +0530 | [diff] [blame] | 87 | |
| 88 | using DbusInterface = std::string; |
| 89 | using DbusInterfaceMap = std::map<DbusInterface,DbusPropertyMap>; |
| 90 | |
| 91 | using FruInstancePath = std::string; |
| 92 | using FruInstanceMap = std::map<FruInstancePath,DbusInterfaceMap>; |
| 93 | |
| 94 | using FruId = uint32_t; |
| 95 | using FruMap = std::map<FruId,FruInstanceMap>; |
Ratan Gupta | cb0d4e5 | 2016-12-22 19:05:57 +0530 | [diff] [blame] | 96 | |
| 97 | /* Parse an IPMI write fru data message into a dictionary containing name value pair of VPD entries.*/ |
| 98 | int parse_fru (const void* msgbuf, sd_bus_message* vpdtbl); |
| 99 | |
| 100 | int parse_fru_area (const uint8_t area, const void* msgbuf, |
| 101 | const size_t len, IPMIFruInfo& info); |
| 102 | |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 103 | #endif |