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