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), 35 termini(termini) 36 {} 37 38 /** @brief Initialize terminus which supports PLDM Type 2 39 * 40 * @return coroutine return_value - PLDM completion code 41 */ 42 exec::task<int> initTerminus(); 43 44 private: 45 /** @brief Fetch all PDRs from terminus. 46 * 47 * @param[in] terminus - The terminus object to store fetched PDRs 48 * @return coroutine return_value - PLDM completion code 49 */ 50 exec::task<int> getPDRs(std::shared_ptr<Terminus> terminus); 51 52 /** @brief Fetch PDR from terminus 53 * 54 * @param[in] tid - Destination TID 55 * @param[in] recordHndl - Record handle 56 * @param[in] dataTransferHndl - Data transfer handle 57 * @param[in] transferOpFlag - Transfer Operation Flag 58 * @param[in] requstCnt - Request Count of data 59 * @param[in] recordChgNum - Record change number 60 * @param[out] nextRecordHndl - Next record handle 61 * @param[out] nextDataTransferHndl - Next data transfer handle 62 * @param[out] transferFlag - Transfer flag 63 * @param[out] responseCnt - Response count of record data 64 * @param[out] recordData - Returned record data 65 * @param[out] transferCrc - CRC value when record data is last part of PDR 66 * @return coroutine return_value - PLDM completion code 67 */ 68 exec::task<int> 69 getPDR(const pldm_tid_t tid, const uint32_t recordHndl, 70 const uint32_t dataTransferHndl, const uint8_t transferOpFlag, 71 const uint16_t requestCnt, const uint16_t recordChgNum, 72 uint32_t& nextRecordHndl, uint32_t& nextDataTransferHndl, 73 uint8_t& transferFlag, uint16_t& responseCnt, 74 std::vector<uint8_t>& recordData, uint8_t& transferCrc); 75 76 /** @brief get PDR repository information. 77 * 78 * @param[in] tid - Destination TID 79 * @param[out] repositoryState - the state of repository 80 * @param[out] recordCount - number of records 81 * @param[out] repositorySize - repository size 82 * @param[out] largestRecordSize - largest record size 83 * * 84 * @return coroutine return_value - PLDM completion code 85 */ 86 exec::task<int> getPDRRepositoryInfo(const pldm_tid_t tid, 87 uint8_t& repositoryState, 88 uint32_t& recordCount, 89 uint32_t& repositorySize, 90 uint32_t& largestRecordSize); 91 92 /** reference of TerminusManager for sending PLDM request to terminus*/ 93 TerminusManager& terminusManager; 94 95 /** @brief Managed termini list */ 96 TerminiMapper& termini; 97 }; 98 } // namespace platform_mc 99 } // namespace pldm 100