1*a743e384SChau Ly #pragma once 2*a743e384SChau Ly 3*a743e384SChau Ly #include "libpldm/pldm.h" 4*a743e384SChau Ly 5*a743e384SChau Ly #include "common/instance_id.hpp" 6*a743e384SChau Ly #include "common/types.hpp" 7*a743e384SChau Ly #include "oem_event_manager.hpp" 8*a743e384SChau Ly #include "platform-mc/manager.hpp" 9*a743e384SChau Ly #include "requester/handler.hpp" 10*a743e384SChau Ly #include "requester/request.hpp" 11*a743e384SChau Ly 12*a743e384SChau Ly namespace pldm 13*a743e384SChau Ly { 14*a743e384SChau Ly namespace oem_ampere 15*a743e384SChau Ly { 16*a743e384SChau Ly using namespace pldm::pdr; 17*a743e384SChau Ly 18*a743e384SChau Ly using EventToMsgMap_t = std::unordered_map<uint8_t, std::string>; 19*a743e384SChau Ly 20*a743e384SChau Ly enum sensor_ids 21*a743e384SChau Ly { 22*a743e384SChau Ly BOOT_OVERALL = 175, 23*a743e384SChau Ly }; 24*a743e384SChau Ly 25*a743e384SChau Ly namespace boot 26*a743e384SChau Ly { 27*a743e384SChau Ly namespace status 28*a743e384SChau Ly { 29*a743e384SChau Ly enum boot_status 30*a743e384SChau Ly { 31*a743e384SChau Ly BOOT_STATUS_SUCCESS = 0x80, 32*a743e384SChau Ly BOOT_STATUS_FAILURE = 0x81, 33*a743e384SChau Ly }; 34*a743e384SChau Ly } // namespace status 35*a743e384SChau Ly namespace stage 36*a743e384SChau Ly { 37*a743e384SChau Ly enum boot_stage 38*a743e384SChau Ly { 39*a743e384SChau Ly UEFI_STATUS_CLASS_CODE_MIN = 0x00, 40*a743e384SChau Ly UEFI_STATUS_CLASS_CODE_MAX = 0x7f, 41*a743e384SChau Ly SECPRO = 0x90, 42*a743e384SChau Ly MPRO = 0x91, 43*a743e384SChau Ly ATF_BL1 = 0x92, 44*a743e384SChau Ly ATF_BL2 = 0x93, 45*a743e384SChau Ly DDR_INITIALIZATION = 0x94, 46*a743e384SChau Ly DDR_TRAINING = 0x95, 47*a743e384SChau Ly S0_DDR_TRAINING_FAILURE = 0x96, 48*a743e384SChau Ly ATF_BL31 = 0x97, 49*a743e384SChau Ly ATF_BL32 = 0x98, 50*a743e384SChau Ly S1_DDR_TRAINING_FAILURE = 0x99, 51*a743e384SChau Ly }; 52*a743e384SChau Ly } // namespace stage 53*a743e384SChau Ly } // namespace boot 54*a743e384SChau Ly 55*a743e384SChau Ly enum class log_level : int 56*a743e384SChau Ly { 57*a743e384SChau Ly OK, 58*a743e384SChau Ly BIOSFWPANIC, 59*a743e384SChau Ly }; 60*a743e384SChau Ly 61*a743e384SChau Ly /** 62*a743e384SChau Ly * @brief OemEventManager 63*a743e384SChau Ly * 64*a743e384SChau Ly * 65*a743e384SChau Ly */ 66*a743e384SChau Ly class OemEventManager 67*a743e384SChau Ly { 68*a743e384SChau Ly public: 69*a743e384SChau Ly OemEventManager() = delete; 70*a743e384SChau Ly OemEventManager(const OemEventManager&) = delete; 71*a743e384SChau Ly OemEventManager(OemEventManager&&) = delete; 72*a743e384SChau Ly OemEventManager& operator=(const OemEventManager&) = delete; 73*a743e384SChau Ly OemEventManager& operator=(OemEventManager&&) = delete; 74*a743e384SChau Ly virtual ~OemEventManager() = default; 75*a743e384SChau Ly OemEventManager(sdeventplus::Event & event,requester::Handler<requester::Request> *,pldm::InstanceIdDb &)76*a743e384SChau Ly explicit OemEventManager( 77*a743e384SChau Ly sdeventplus::Event& event, 78*a743e384SChau Ly requester::Handler<requester::Request>* /* handler */, 79*a743e384SChau Ly pldm::InstanceIdDb& /* instanceIdDb */) : event(event) {}; 80*a743e384SChau Ly 81*a743e384SChau Ly /** @brief Decode sensor event messages and handle correspondingly. 82*a743e384SChau Ly * 83*a743e384SChau Ly * @param[in] request - the request message of sensor event 84*a743e384SChau Ly * @param[in] payloadLength - the payload length of sensor event 85*a743e384SChau Ly * @param[in] formatVersion - the format version of sensor event 86*a743e384SChau Ly * @param[in] tid - TID 87*a743e384SChau Ly * @param[in] eventDataOffset - the event data offset of sensor event 88*a743e384SChau Ly * 89*a743e384SChau Ly * @return int - returned error code 90*a743e384SChau Ly */ 91*a743e384SChau Ly int handleSensorEvent(const pldm_msg* request, size_t payloadLength, 92*a743e384SChau Ly uint8_t /* formatVersion */, pldm_tid_t tid, 93*a743e384SChau Ly size_t eventDataOffset); 94*a743e384SChau Ly 95*a743e384SChau Ly protected: 96*a743e384SChau Ly /** @brief Create prefix string for logging message. 97*a743e384SChau Ly * 98*a743e384SChau Ly * @param[in] tid - TID 99*a743e384SChau Ly * @param[in] sensorId - Sensor ID 100*a743e384SChau Ly * 101*a743e384SChau Ly * @return std::string - the prefeix string 102*a743e384SChau Ly */ 103*a743e384SChau Ly std::string prefixMsgStrCreation(pldm_tid_t tid, uint16_t sensorId); 104*a743e384SChau Ly 105*a743e384SChau Ly /** @brief Log the message into Redfish SEL. 106*a743e384SChau Ly * 107*a743e384SChau Ly * @param[in] description - the logging message 108*a743e384SChau Ly * @param[in] logLevel - the logging level 109*a743e384SChau Ly */ 110*a743e384SChau Ly void sendJournalRedfish(const std::string& description, 111*a743e384SChau Ly log_level& logLevel); 112*a743e384SChau Ly 113*a743e384SChau Ly /** @brief Convert the one-hot DIMM index byte into a string of DIMM 114*a743e384SChau Ly * indexes. 115*a743e384SChau Ly * 116*a743e384SChau Ly * @param[in] dimmIdxs - the one-hot DIMM index byte 117*a743e384SChau Ly * 118*a743e384SChau Ly * @return std::string - the string of DIMM indexes 119*a743e384SChau Ly */ 120*a743e384SChau Ly std::string dimmIdxsToString(uint32_t dimmIdxs); 121*a743e384SChau Ly 122*a743e384SChau Ly /** @brief Handle numeric sensor event message from boot overall sensor. 123*a743e384SChau Ly * 124*a743e384SChau Ly * @param[in] tid - TID 125*a743e384SChau Ly * @param[in] sensorId - Sensor ID 126*a743e384SChau Ly * @param[in] presentReading - the present reading of the sensor 127*a743e384SChau Ly */ 128*a743e384SChau Ly void handleBootOverallEvent(pldm_tid_t /*tid*/, uint16_t /*sensorId*/, 129*a743e384SChau Ly uint32_t presentReading); 130*a743e384SChau Ly 131*a743e384SChau Ly /** @brief Handle numeric sensor event messages. 132*a743e384SChau Ly * 133*a743e384SChau Ly * @param[in] tid - TID 134*a743e384SChau Ly * @param[in] sensorId - Sensor ID 135*a743e384SChau Ly * @param[in] sensorData - the sensor data 136*a743e384SChau Ly * @param[in] sensorDataLength - the length of sensor data 137*a743e384SChau Ly * 138*a743e384SChau Ly * @return int - returned error code 139*a743e384SChau Ly */ 140*a743e384SChau Ly int processNumericSensorEvent(pldm_tid_t tid, uint16_t sensorId, 141*a743e384SChau Ly const uint8_t* sensorData, 142*a743e384SChau Ly size_t sensorDataLength); 143*a743e384SChau Ly 144*a743e384SChau Ly /** @brief Handle state sensor event messages. 145*a743e384SChau Ly * 146*a743e384SChau Ly * @param[in] tid - TID 147*a743e384SChau Ly * @param[in] sensorId - Sensor ID 148*a743e384SChau Ly * @param[in] sensorData - the sensor data 149*a743e384SChau Ly * @param[in] sensorDataLength - the length of sensor data 150*a743e384SChau Ly * 151*a743e384SChau Ly * @return int - returned error code 152*a743e384SChau Ly */ 153*a743e384SChau Ly int processStateSensorEvent(pldm_tid_t tid, uint16_t sensorId, 154*a743e384SChau Ly const uint8_t* sensorData, 155*a743e384SChau Ly size_t sensorDataLength); 156*a743e384SChau Ly 157*a743e384SChau Ly /** @brief Handle op state sensor event messages. 158*a743e384SChau Ly * 159*a743e384SChau Ly * @param[in] tid - TID 160*a743e384SChau Ly * @param[in] sensorId - Sensor ID 161*a743e384SChau Ly * @param[in] sensorData - the sensor data 162*a743e384SChau Ly * @param[in] sensorDataLength - the length of sensor data 163*a743e384SChau Ly * 164*a743e384SChau Ly * @return int - returned error code 165*a743e384SChau Ly */ 166*a743e384SChau Ly int processSensorOpStateEvent(pldm_tid_t tid, uint16_t sensorId, 167*a743e384SChau Ly const uint8_t* sensorData, 168*a743e384SChau Ly size_t sensorDataLength); 169*a743e384SChau Ly 170*a743e384SChau Ly /** @brief reference of main event loop of pldmd, primarily used to schedule 171*a743e384SChau Ly * work 172*a743e384SChau Ly */ 173*a743e384SChau Ly sdeventplus::Event& event; 174*a743e384SChau Ly }; 175*a743e384SChau Ly } // namespace oem_ampere 176*a743e384SChau Ly } // namespace pldm 177