Sampa Misra | aea5dde | 2020-08-31 08:33:47 -0500 | [diff] [blame] | 1 | #pragma once |
Varsha Kaverappa | bb585b2 | 2020-09-10 06:15:42 -0500 | [diff] [blame] | 2 | #include "libpldm/platform.h" |
| 3 | |
Sampa Misra | aea5dde | 2020-08-31 08:33:47 -0500 | [diff] [blame] | 4 | #include "inband_code_update.hpp" |
| 5 | #include "libpldmresponder/oem_handler.hpp" |
Varsha Kaverappa | bb585b2 | 2020-09-10 06:15:42 -0500 | [diff] [blame] | 6 | #include "libpldmresponder/pdr_utils.hpp" |
Sampa Misra | aea5dde | 2020-08-31 08:33:47 -0500 | [diff] [blame] | 7 | #include "libpldmresponder/platform.hpp" |
| 8 | |
| 9 | namespace pldm |
| 10 | { |
Sampa Misra | aea5dde | 2020-08-31 08:33:47 -0500 | [diff] [blame] | 11 | namespace responder |
| 12 | { |
Sampa Misra | aea5dde | 2020-08-31 08:33:47 -0500 | [diff] [blame] | 13 | namespace oem_ibm_platform |
| 14 | { |
| 15 | |
| 16 | #define PLDM_OEM_IBM_FIRMWARE_UPDATE_STATE 32768 |
| 17 | #define PLDM_OEM_IBM_BOOT_STATE 32769 |
| 18 | |
Sagar Srinivas | 78a225a | 2020-08-27 00:52:20 -0500 | [diff] [blame] | 19 | static constexpr auto PLDM_OEM_IBM_ENTITY_FIRMWARE_UPDATE = 24577; |
| 20 | constexpr uint16_t ENTITY_INSTANCE_0 = 0; |
| 21 | constexpr uint16_t ENTITY_INSTANCE_1 = 1; |
| 22 | |
Varsha Kaverappa | bb585b2 | 2020-09-10 06:15:42 -0500 | [diff] [blame] | 23 | enum class CodeUpdateState : uint8_t |
| 24 | { |
| 25 | START = 0x1, |
| 26 | END = 0x2, |
| 27 | FAIL = 0x3, |
| 28 | ABORT = 0x4, |
| 29 | ACCEPT = 0x5, |
| 30 | REJECT = 0x6 |
| 31 | }; |
| 32 | |
Sampa Misra | aea5dde | 2020-08-31 08:33:47 -0500 | [diff] [blame] | 33 | class Handler : public oem_platform::Handler |
| 34 | { |
| 35 | public: |
| 36 | Handler(const pldm::utils::DBusHandler* dBusIntf, |
Varsha Kaverappa | bb585b2 | 2020-09-10 06:15:42 -0500 | [diff] [blame] | 37 | pldm::responder::CodeUpdate* codeUpdate, int mctp_fd, |
| 38 | uint8_t mctp_eid, Requester& requester) : |
Sampa Misra | aea5dde | 2020-08-31 08:33:47 -0500 | [diff] [blame] | 39 | oem_platform::Handler(dBusIntf), |
Varsha Kaverappa | bb585b2 | 2020-09-10 06:15:42 -0500 | [diff] [blame] | 40 | codeUpdate(codeUpdate), platformHandler(nullptr), mctp_fd(mctp_fd), |
| 41 | mctp_eid(mctp_eid), requester(requester) |
Sampa Misra | aea5dde | 2020-08-31 08:33:47 -0500 | [diff] [blame] | 42 | { |
| 43 | codeUpdate->setVersions(); |
| 44 | } |
| 45 | |
| 46 | int getOemStateSensorReadingsHandler( |
| 47 | EntityType entityType, EntityInstance entityInstance, |
| 48 | StateSetId stateSetId, CompositeCount compSensorCnt, |
| 49 | std::vector<get_sensor_state_field>& stateField); |
| 50 | |
Varsha Kaverappa | 3fbd39e | 2020-09-28 01:40:22 -0500 | [diff] [blame^] | 51 | int OemSetStateEffecterStatesHandler( |
| 52 | uint16_t entityType, uint16_t entityInstance, uint16_t stateSetId, |
| 53 | uint8_t compEffecterCnt, |
| 54 | std::vector<set_effecter_state_field>& stateField, uint16_t effecterId); |
Sampa Misra | aea5dde | 2020-08-31 08:33:47 -0500 | [diff] [blame] | 55 | |
| 56 | /** @brief Method to set the platform handler in the |
| 57 | * oem_ibm_handler class |
| 58 | * @param[in] handler - pointer to PLDM platform handler |
| 59 | */ |
| 60 | void setPlatformHandler(pldm::responder::platform::Handler* handler); |
| 61 | |
Sagar Srinivas | 78a225a | 2020-08-27 00:52:20 -0500 | [diff] [blame] | 62 | /** @brief Method to fetch the effecter ID of the code update PDRs |
| 63 | * |
| 64 | * @return platformHandler->getNextEffecterId() - returns the |
| 65 | * effecter ID from the platform handler |
| 66 | */ |
| 67 | uint16_t getNextEffecterId() |
| 68 | { |
| 69 | return platformHandler->getNextEffecterId(); |
| 70 | } |
| 71 | |
| 72 | /** @brief Method to fetch the sensor ID of the code update PDRs |
| 73 | * |
| 74 | * @return platformHandler->getNextSensorId() - returns the |
| 75 | * Sensor ID from the platform handler |
| 76 | */ |
| 77 | uint16_t getNextSensorId() |
| 78 | { |
| 79 | return platformHandler->getNextSensorId(); |
| 80 | } |
| 81 | |
| 82 | /** @brief Method to Generate the OEM PDRs |
| 83 | * |
| 84 | * @param[in] repo - instance of concrete implementation of Repo |
| 85 | */ |
| 86 | void buildOEMPDR(pdr_utils::Repo& repo); |
| 87 | |
Varsha Kaverappa | bb585b2 | 2020-09-10 06:15:42 -0500 | [diff] [blame] | 88 | /** @brief Method to send code update event to host |
| 89 | * @param[in] sensorId - sendor ID |
| 90 | * @param[in] sensorEventClass - event class of sensor |
| 91 | * @param[in] sensorOffset - sensor offset |
| 92 | * @param[in] eventState - new code update event state |
| 93 | * @param[in] prevEventState - previous code update event state |
| 94 | * @return none |
| 95 | */ |
| 96 | void sendStateSensorEvent(uint16_t sensorId, |
| 97 | enum sensor_event_class_states sensorEventClass, |
| 98 | uint8_t sensorOffset, uint8_t eventState, |
| 99 | uint8_t prevEventState); |
| 100 | |
| 101 | /** @brief Method to send encoded request msg of code update event to host |
| 102 | * @param[in] requestMsg - encoded request msg |
| 103 | * @return PLDM status code |
| 104 | */ |
| 105 | int sendEventToHost(std::vector<uint8_t>& requestMsg); |
| 106 | |
Sampa Misra | aea5dde | 2020-08-31 08:33:47 -0500 | [diff] [blame] | 107 | ~Handler() = default; |
| 108 | |
| 109 | pldm::responder::CodeUpdate* codeUpdate; //!< pointer to CodeUpdate object |
| 110 | pldm::responder::platform::Handler* |
| 111 | platformHandler; //!< pointer to PLDM platform handler |
Varsha Kaverappa | bb585b2 | 2020-09-10 06:15:42 -0500 | [diff] [blame] | 112 | |
| 113 | /** @brief fd of MCTP communications socket */ |
| 114 | int mctp_fd; |
| 115 | |
| 116 | /** @brief MCTP EID of host firmware */ |
| 117 | uint8_t mctp_eid; |
| 118 | |
| 119 | /** @brief reference to Requester object, primarily used to access API to |
| 120 | * obtain PLDM instance id. |
| 121 | */ |
| 122 | Requester& requester; |
Sampa Misra | aea5dde | 2020-08-31 08:33:47 -0500 | [diff] [blame] | 123 | }; |
| 124 | |
Varsha Kaverappa | bb585b2 | 2020-09-10 06:15:42 -0500 | [diff] [blame] | 125 | /** @brief Method to encode code update event msg |
| 126 | * @param[in] eventType - type of event |
| 127 | * @param[in] eventDataVec - vector of event data to be sent to host |
| 128 | * @param[in/out] requestMsg - request msg to be encoded |
| 129 | * @param[in] instanceId - instance ID |
| 130 | * @return PLDM status code |
| 131 | */ |
| 132 | int encodeEventMsg(uint8_t eventType, const std::vector<uint8_t>& eventDataVec, |
| 133 | std::vector<uint8_t>& requestMsg, uint8_t instanceId); |
| 134 | |
Sampa Misra | aea5dde | 2020-08-31 08:33:47 -0500 | [diff] [blame] | 135 | } // namespace oem_ibm_platform |
| 136 | |
| 137 | } // namespace responder |
| 138 | |
| 139 | } // namespace pldm |