1 #pragma once 2 3 #include <ipmid/api.h> 4 #include <stdint.h> 5 6 #include <map> 7 #include <string> 8 9 static constexpr auto propertiesIntf = "org.freedesktop.DBus.Properties"; 10 static constexpr auto bmcUpdaterServiceName = 11 "xyz.openbmc_project.Software.BMC.Updater"; 12 static constexpr auto softwarePath = "/xyz/openbmc_project/software"; 13 static constexpr auto factoryResetIntf = 14 "xyz.openbmc_project.Common.FactoryReset"; 15 static constexpr auto stateChassisPath = "/xyz/openbmc_project/state/chassis0"; 16 static constexpr auto stateChassisIntf = "xyz.openbmc_project.State.Chassis"; 17 static constexpr auto stateBmcPath = "/xyz/openbmc_project/state/bmc0"; 18 static constexpr auto stateBmcIntf = "xyz.openbmc_project.State.BMC"; 19 20 // IPMI commands for net functions. 21 enum ipmi_netfn_oem_cmds 22 { 23 IPMI_CMD_PREP_FW_UPDATE = 0x10, 24 IPMI_CMD_BMC_FACTORY_RESET = 0x11, 25 IPMI_CMD_PESEL = 0xF0, 26 IPMI_CMD_OCC_RESET = 0x0E, 27 }; 28 29 /** @brief Read eSEL data into a string 30 * 31 * @param[in] filename - filename of file containing eSEL 32 * 33 * @return On success return the eSEL data 34 */ 35 std::string readESEL(const char* filename); 36 37 /** @brief Create OCC metrics log entry 38 * 39 * @param[in] eSELData - eSEL data containing OCC metrics data 40 */ 41 void createLogEntry(const std::string& eSELData); 42 43 ipmi_ret_t ipmi_ibm_oem_partial_esel(ipmi_netfn_t netfn, ipmi_cmd_t cmd, 44 ipmi_request_t request, 45 ipmi_response_t response, 46 ipmi_data_len_t data_len, 47 ipmi_context_t context); 48 49 struct esel_request_t 50 { 51 uint16_t resid; 52 uint16_t selrecord; 53 uint16_t offset; 54 uint8_t progress; 55 } __attribute__((packed)); 56 57 /** @struct SELEventRecord 58 * 59 * IPMI SEL event record format. 60 */ 61 struct SELEventRecord 62 { 63 uint16_t recordID; //!< Record ID. 64 uint8_t recordType; //!< Record Type. 65 uint32_t timeStamp; //!< Timestamp. 66 uint16_t generatorID; //!< Generator ID. 67 uint8_t eventMsgRevision; //!< Event Message Revision. 68 uint8_t sensorType; //!< Sensor Type. 69 uint8_t sensorNum; //!< Sensor Number. 70 uint8_t eventType; //!< Event Dir | Event Type. 71 uint8_t eventData1; //!< Event Data 1. 72 uint8_t eventData2; //!< Event Data 2. 73 uint8_t eventData3; //!< Event Data 3. 74 } __attribute__((packed)); 75 76 using Id = uint8_t; 77 using Type = uint8_t; 78 using ReadingType = uint8_t; 79 using Offset = uint8_t; 80 using Path = std::string; 81 82 struct Data 83 { 84 Id sensorID; 85 Type sensorType; 86 ReadingType eventReadingType; 87 Offset eventOffset; 88 }; 89 90 using ObjectIDMap = std::map<Path, Data>; 91