blob: aa0530322e139997e90535f248f279fa77d0c72d [file] [log] [blame]
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -05001#include "pdr.hpp"
2
George Liua2870722020-02-11 11:09:30 +08003#include "pdr_state_effecter.hpp"
Deepak Kodihallic682fe22020-03-04 00:42:54 -06004
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -05005namespace pldm
6{
7
8namespace responder
9{
10
11namespace pdr
12{
George Liue53193f2020-02-24 09:23:26 +080013using namespace pldm::responder::pdr_utils;
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -050014
Deepak Kodihallic682fe22020-03-04 00:42:54 -060015void getRepoByType(const Repo& inRepo, Repo& outRepo, Type pdrType)
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -050016{
George Liue53193f2020-02-24 09:23:26 +080017 uint8_t* pdrData = nullptr;
18 uint32_t pdrSize{};
Deepak Kodihallic682fe22020-03-04 00:42:54 -060019 auto record = pldm_pdr_find_record_by_type(inRepo.getPdr(), pdrType, NULL,
George Liue53193f2020-02-24 09:23:26 +080020 &pdrData, &pdrSize);
21 while (record)
22 {
23 PdrEntry pdrEntry{};
24 pdrEntry.data = pdrData;
25 pdrEntry.size = pdrSize;
Deepak Kodihallic682fe22020-03-04 00:42:54 -060026 pdrEntry.handle.recordHandle = inRepo.getRecordHandle(record);
27 outRepo.addRecord(pdrEntry);
George Liue53193f2020-02-24 09:23:26 +080028
29 pdrData = nullptr;
30 pdrSize = 0;
Deepak Kodihallic682fe22020-03-04 00:42:54 -060031 record = pldm_pdr_find_record_by_type(inRepo.getPdr(), pdrType, record,
George Liue53193f2020-02-24 09:23:26 +080032 &pdrData, &pdrSize);
33 }
George Liue53193f2020-02-24 09:23:26 +080034}
35
Deepak Kodihallic682fe22020-03-04 00:42:54 -060036const pldm_pdr_record* getRecordByHandle(const RepoInterface& pdrRepo,
George Liue53193f2020-02-24 09:23:26 +080037 RecordHandle recordHandle,
38 PdrEntry& pdrEntry)
39{
40 uint8_t* pdrData = nullptr;
Patrick Williams6da4f912023-05-10 07:50:53 -050041 auto record = pldm_pdr_find_record(pdrRepo.getPdr(), recordHandle, &pdrData,
42 &pdrEntry.size,
43 &pdrEntry.handle.nextRecordHandle);
George Liue53193f2020-02-24 09:23:26 +080044 if (record)
45 {
46 pdrEntry.data = pdrData;
47 }
48
49 return record;
50}
51
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -050052} // namespace pdr
53} // namespace responder
54} // namespace pldm