1 #pragma once 2 3 #include "libpldm/platform.h" 4 #include "libpldm/pldm.h" 5 6 #include "terminus.hpp" 7 #include "terminus_manager.hpp" 8 9 #include <vector> 10 11 namespace pldm 12 { 13 14 namespace platform_mc 15 { 16 17 /** 18 * @brief PlatformManager 19 * 20 * PlatformManager class manages the actions outlined in the platform spec. 21 */ 22 class PlatformManager 23 { 24 public: 25 PlatformManager() = delete; 26 PlatformManager(const PlatformManager&) = delete; 27 PlatformManager(PlatformManager&&) = delete; 28 PlatformManager& operator=(const PlatformManager&) = delete; 29 PlatformManager& operator=(PlatformManager&&) = delete; 30 ~PlatformManager() = default; 31 32 explicit PlatformManager(TerminusManager& terminusManager, 33 TerminiMapper& termini) : 34 terminusManager(terminusManager), termini(termini) 35 {} 36 37 /** @brief Initialize terminus which supports PLDM Type 2 38 * 39 * @return coroutine return_value - PLDM completion code 40 */ 41 exec::task<int> initTerminus(); 42 43 /** @brief Helper to get the supported event messages and set event receiver 44 * 45 * @param[in] tid - Destination TID 46 * @return coroutine return_value - PLDM completion code 47 */ 48 exec::task<int> configEventReceiver(pldm_tid_t tid); 49 50 private: 51 /** @brief Fetch all PDRs from terminus. 52 * 53 * @param[in] terminus - The terminus object to store fetched PDRs 54 * @return coroutine return_value - PLDM completion code 55 */ 56 exec::task<int> getPDRs(std::shared_ptr<Terminus> terminus); 57 58 /** @brief Fetch PDR from terminus 59 * 60 * @param[in] tid - Destination TID 61 * @param[in] recordHndl - Record handle 62 * @param[in] dataTransferHndl - Data transfer handle 63 * @param[in] transferOpFlag - Transfer Operation Flag 64 * @param[in] requstCnt - Request Count of data 65 * @param[in] recordChgNum - Record change number 66 * @param[out] nextRecordHndl - Next record handle 67 * @param[out] nextDataTransferHndl - Next data transfer handle 68 * @param[out] transferFlag - Transfer flag 69 * @param[out] responseCnt - Response count of record data 70 * @param[out] recordData - Returned record data 71 * @param[out] transferCrc - CRC value when record data is last part of PDR 72 * @return coroutine return_value - PLDM completion code 73 */ 74 exec::task<int> 75 getPDR(const pldm_tid_t tid, const uint32_t recordHndl, 76 const uint32_t dataTransferHndl, const uint8_t transferOpFlag, 77 const uint16_t requestCnt, const uint16_t recordChgNum, 78 uint32_t& nextRecordHndl, uint32_t& nextDataTransferHndl, 79 uint8_t& transferFlag, uint16_t& responseCnt, 80 std::vector<uint8_t>& recordData, uint8_t& transferCrc); 81 82 /** @brief get PDR repository information. 83 * 84 * @param[in] tid - Destination TID 85 * @param[out] repositoryState - the state of repository 86 * @param[out] recordCount - number of records 87 * @param[out] repositorySize - repository size 88 * @param[out] largestRecordSize - largest record size 89 * * 90 * @return coroutine return_value - PLDM completion code 91 */ 92 exec::task<int> getPDRRepositoryInfo( 93 const pldm_tid_t tid, uint8_t& repositoryState, uint32_t& recordCount, 94 uint32_t& repositorySize, uint32_t& largestRecordSize); 95 96 /** @brief Send setEventReceiver command to destination EID. 97 * 98 * @param[in] tid - Destination TID 99 * @param[in] eventMessageGlobalEnable - Enable/disable event message 100 * generation from the terminus 101 * @param[in] eventReceiverEid - The EID of eventReceiver that terminus 102 * should send event message to 103 * @param[in] protocolType - Provided in the request to help the responder 104 * verify that the content of the eventReceiverAddressInfo field 105 * @param[in] heartbeatTimer - Amount of time in seconds after each 106 * elapsing of which the terminus shall emit a heartbeat event. 107 * @return coroutine return_value - PLDM completion code 108 */ 109 exec::task<int> setEventReceiver( 110 pldm_tid_t tid, 111 pldm_event_message_global_enable eventMessageGlobalEnable, 112 pldm_transport_protocol_type protocolType, uint16_t heartbeatTimer); 113 114 /** @brief send eventMessageBufferSize 115 * @param[in] tid - Destination TID 116 * @param[in] receiverMaxBufferSize 117 * @param[out] terminusBufferSize 118 * @return coroutine return_value - PLDM completion code 119 */ 120 exec::task<int> eventMessageBufferSize(pldm_tid_t tid, 121 uint16_t receiverMaxBufferSize, 122 uint16_t& terminusBufferSize); 123 124 /** @brief send eventMessageSupported 125 * @param[in] tid - Destination TID 126 * @param[in] formatVersion - version of the event format 127 * @param[out] synchronyConfiguration - messaging style most recently 128 * configured via the setEventReceiver command 129 * @param[out] synchronyConfigurationSupported - event messaging styles 130 * supported by the terminus 131 * @param[out] numerEventClassReturned - number of eventClass enumerated 132 * bytes 133 * @param[out] eventClass - vector of eventClass the device can generate 134 * @return coroutine return_value - PLDM completion code 135 */ 136 exec::task<int> eventMessageSupported( 137 pldm_tid_t tid, uint8_t formatVersion, uint8_t& synchronyConfiguration, 138 bitfield8_t& synchronyConfigurationSupported, 139 uint8_t& numerEventClassReturned, std::vector<uint8_t>& eventClass); 140 141 /** reference of TerminusManager for sending PLDM request to terminus*/ 142 TerminusManager& terminusManager; 143 144 /** @brief Managed termini list */ 145 TerminiMapper& termini; 146 }; 147 } // namespace platform_mc 148 } // namespace pldm 149