1 #include "pdr.hpp"
2
3 #include "pdr_state_effecter.hpp"
4
5 namespace pldm
6 {
7
8 namespace responder
9 {
10
11 namespace pdr
12 {
13 using namespace pldm::responder::pdr_utils;
14
getRepoByType(const Repo & inRepo,Repo & outRepo,Type pdrType)15 void getRepoByType(const Repo& inRepo, Repo& outRepo, Type pdrType)
16 {
17 uint8_t* pdrData = nullptr;
18 uint32_t pdrSize{};
19 auto record = pldm_pdr_find_record_by_type(inRepo.getPdr(), pdrType, NULL,
20 &pdrData, &pdrSize);
21 while (record)
22 {
23 PdrEntry pdrEntry{};
24 pdrEntry.data = pdrData;
25 pdrEntry.size = pdrSize;
26 pdrEntry.handle.recordHandle = inRepo.getRecordHandle(record);
27 outRepo.addRecord(pdrEntry);
28
29 pdrData = nullptr;
30 pdrSize = 0;
31 record = pldm_pdr_find_record_by_type(inRepo.getPdr(), pdrType, record,
32 &pdrData, &pdrSize);
33 }
34 }
35
getRecordByHandle(const RepoInterface & pdrRepo,RecordHandle recordHandle,PdrEntry & pdrEntry)36 const pldm_pdr_record* getRecordByHandle(
37 const RepoInterface& pdrRepo, RecordHandle recordHandle, PdrEntry& pdrEntry)
38 {
39 uint8_t* pdrData = nullptr;
40 auto record =
41 pldm_pdr_find_record(pdrRepo.getPdr(), recordHandle, &pdrData,
42 &pdrEntry.size, &pdrEntry.handle.nextRecordHandle);
43 if (record)
44 {
45 pdrEntry.data = pdrData;
46 }
47
48 return record;
49 }
50
51 } // namespace pdr
52 } // namespace responder
53 } // namespace pldm
54