blob: 8d6e7b4f3058e5044a5ca22bdf19f20c2d2bb9bc [file] [log] [blame]
Gilbert Chen6c7fed42022-02-22 15:40:17 +00001#pragma once
2
3#include "libpldm/platform.h"
4#include "libpldm/pldm.h"
5
6#include "terminus.hpp"
7#include "terminus_manager.hpp"
8
Gilbert Chende2a1322022-05-24 15:35:21 +01009#include <vector>
10
Gilbert Chen6c7fed42022-02-22 15:40:17 +000011namespace pldm
12{
13
14namespace platform_mc
15{
16
17/**
18 * @brief PlatformManager
19 *
20 * PlatformManager class manages the actions outlined in the platform spec.
21 */
22class 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) :
Patrick Williams16c2a0a2024-08-16 15:20:59 -040034 terminusManager(terminusManager), termini(termini)
Gilbert Chen6c7fed42022-02-22 15:40:17 +000035 {}
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 private:
Gilbert Chende2a1322022-05-24 15:35:21 +010044 /** @brief Fetch all PDRs from terminus.
45 *
46 * @param[in] terminus - The terminus object to store fetched PDRs
47 * @return coroutine return_value - PLDM completion code
48 */
49 exec::task<int> getPDRs(std::shared_ptr<Terminus> terminus);
50
51 /** @brief Fetch PDR from terminus
52 *
53 * @param[in] tid - Destination TID
54 * @param[in] recordHndl - Record handle
55 * @param[in] dataTransferHndl - Data transfer handle
56 * @param[in] transferOpFlag - Transfer Operation Flag
57 * @param[in] requstCnt - Request Count of data
58 * @param[in] recordChgNum - Record change number
59 * @param[out] nextRecordHndl - Next record handle
60 * @param[out] nextDataTransferHndl - Next data transfer handle
61 * @param[out] transferFlag - Transfer flag
62 * @param[out] responseCnt - Response count of record data
63 * @param[out] recordData - Returned record data
64 * @param[out] transferCrc - CRC value when record data is last part of PDR
65 * @return coroutine return_value - PLDM completion code
66 */
67 exec::task<int>
68 getPDR(const pldm_tid_t tid, const uint32_t recordHndl,
69 const uint32_t dataTransferHndl, const uint8_t transferOpFlag,
70 const uint16_t requestCnt, const uint16_t recordChgNum,
71 uint32_t& nextRecordHndl, uint32_t& nextDataTransferHndl,
72 uint8_t& transferFlag, uint16_t& responseCnt,
73 std::vector<uint8_t>& recordData, uint8_t& transferCrc);
74
75 /** @brief get PDR repository information.
76 *
77 * @param[in] tid - Destination TID
78 * @param[out] repositoryState - the state of repository
79 * @param[out] recordCount - number of records
80 * @param[out] repositorySize - repository size
81 * @param[out] largestRecordSize - largest record size
82 * *
83 * @return coroutine return_value - PLDM completion code
84 */
Patrick Williams16c2a0a2024-08-16 15:20:59 -040085 exec::task<int> getPDRRepositoryInfo(
86 const pldm_tid_t tid, uint8_t& repositoryState, uint32_t& recordCount,
87 uint32_t& repositorySize, uint32_t& largestRecordSize);
Gilbert Chende2a1322022-05-24 15:35:21 +010088
Gilbert Chen6c7fed42022-02-22 15:40:17 +000089 /** reference of TerminusManager for sending PLDM request to terminus*/
90 TerminusManager& terminusManager;
91
92 /** @brief Managed termini list */
93 TerminiMapper& termini;
94};
95} // namespace platform_mc
96} // namespace pldm