Deepak Kodihalli | c6e8fb5 | 2019-05-02 08:35:31 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "effecters.hpp" |
George Liu | e53193f | 2020-02-24 09:23:26 +0800 | [diff] [blame] | 4 | #include "libpldmresponder/pdr_utils.hpp" |
Sampa Misra | aa8ae72 | 2019-12-12 03:20:40 -0600 | [diff] [blame] | 5 | #include "utils.hpp" |
Deepak Kodihalli | c6e8fb5 | 2019-05-02 08:35:31 -0500 | [diff] [blame] | 6 | |
| 7 | #include <stdint.h> |
| 8 | |
| 9 | #include <filesystem> |
| 10 | #include <fstream> |
| 11 | #include <functional> |
Sampa Misra | aa8ae72 | 2019-12-12 03:20:40 -0600 | [diff] [blame] | 12 | #include <iostream> |
Deepak Kodihalli | c6e8fb5 | 2019-05-02 08:35:31 -0500 | [diff] [blame] | 13 | #include <map> |
| 14 | #include <nlohmann/json.hpp> |
Deepak Kodihalli | c6e8fb5 | 2019-05-02 08:35:31 -0500 | [diff] [blame] | 15 | #include <string> |
| 16 | #include <vector> |
| 17 | #include <xyz/openbmc_project/Common/error.hpp> |
| 18 | |
George Liu | e53193f | 2020-02-24 09:23:26 +0800 | [diff] [blame] | 19 | #include "libpldm/pdr.h" |
Deepak Kodihalli | c6e8fb5 | 2019-05-02 08:35:31 -0500 | [diff] [blame] | 20 | #include "libpldm/platform.h" |
| 21 | |
Deepak Kodihalli | c6e8fb5 | 2019-05-02 08:35:31 -0500 | [diff] [blame] | 22 | using InternalFailure = |
| 23 | sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure; |
| 24 | namespace fs = std::filesystem; |
| 25 | |
George Liu | e53193f | 2020-02-24 09:23:26 +0800 | [diff] [blame] | 26 | using namespace pldm::responder::pdr_utils; |
| 27 | |
Deepak Kodihalli | c6e8fb5 | 2019-05-02 08:35:31 -0500 | [diff] [blame] | 28 | namespace pldm |
| 29 | { |
| 30 | |
| 31 | namespace responder |
| 32 | { |
| 33 | |
| 34 | namespace pdr |
| 35 | { |
Deepak Kodihalli | c6e8fb5 | 2019-05-02 08:35:31 -0500 | [diff] [blame] | 36 | /** @brief Parse PDR JSONs and build PDR repository |
| 37 | * |
| 38 | * @param[in] dir - directory housing platform specific PDR JSON files |
George Liu | e53193f | 2020-02-24 09:23:26 +0800 | [diff] [blame] | 39 | * @param[in] repo - instance of the concrete implementation of RepoInterface |
Deepak Kodihalli | c6e8fb5 | 2019-05-02 08:35:31 -0500 | [diff] [blame] | 40 | */ |
George Liu | e53193f | 2020-02-24 09:23:26 +0800 | [diff] [blame] | 41 | void generate(const std::string& dir, RepoInterface& repo); |
Deepak Kodihalli | c6e8fb5 | 2019-05-02 08:35:31 -0500 | [diff] [blame] | 42 | |
| 43 | /** @brief Build (if not built already) and retrieve PDR |
| 44 | * |
| 45 | * @param[in] dir - directory housing platform specific PDR JSON files |
| 46 | * |
George Liu | e53193f | 2020-02-24 09:23:26 +0800 | [diff] [blame] | 47 | * @return RepoInterface& - Reference to instance of pdr::RepoInterface |
Deepak Kodihalli | c6e8fb5 | 2019-05-02 08:35:31 -0500 | [diff] [blame] | 48 | */ |
George Liu | e53193f | 2020-02-24 09:23:26 +0800 | [diff] [blame] | 49 | RepoInterface& getRepo(const std::string& dir); |
| 50 | |
| 51 | /** @brief Build (if not built already) and retrieve PDR by the PDR types |
| 52 | * |
| 53 | * @param[in] dir - directory housing platform specific PDR JSON files |
| 54 | * @param[in] pdrType - the type of PDRs |
| 55 | * |
| 56 | * @return Repo - Instance of pdr::Repo |
| 57 | */ |
| 58 | Repo getRepoByType(const std::string& dir, Type pdrType); |
| 59 | |
| 60 | /** @brief Get the record of PDR by the record handle |
| 61 | * |
| 62 | * @param[in] pdrRepo - pdr::RepoInterface |
| 63 | * @param[in] recordHandle - The recordHandle value for the PDR to be |
| 64 | * retrieved. |
| 65 | * @param[out] pdrEntry - PDR entry structure reference |
| 66 | * |
| 67 | * @return pldm_pdr_record - Instance of pdr::RepoInterface |
| 68 | */ |
| 69 | const pldm_pdr_record* getRecordByHandle(RepoInterface& pdrRepo, |
| 70 | RecordHandle recordHandle, |
| 71 | PdrEntry& pdrEntry); |
Deepak Kodihalli | c6e8fb5 | 2019-05-02 08:35:31 -0500 | [diff] [blame] | 72 | |
| 73 | } // namespace pdr |
| 74 | } // namespace responder |
| 75 | } // namespace pldm |