blob: 9a149f7899cc1b1f725afc8add05b672024bfaaa [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
Patrick Williams16c2a0a2024-08-16 15:20:59 -040036const pldm_pdr_record* getRecordByHandle(
37 const RepoInterface& pdrRepo, RecordHandle recordHandle, PdrEntry& pdrEntry)
George Liue53193f2020-02-24 09:23:26 +080038{
39 uint8_t* pdrData = nullptr;
Patrick Williams16c2a0a2024-08-16 15:20:59 -040040 auto record =
41 pldm_pdr_find_record(pdrRepo.getPdr(), recordHandle, &pdrData,
42 &pdrEntry.size, &pdrEntry.handle.nextRecordHandle);
George Liue53193f2020-02-24 09:23:26 +080043 if (record)
44 {
45 pdrEntry.data = pdrData;
46 }
47
48 return record;
49}
50
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -050051} // namespace pdr
52} // namespace responder
53} // namespace pldm