blob: 0cf93859434455386f23109ebdde607a151134a1 [file] [log] [blame]
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -05001#pragma once
2
3#include "effecters.hpp"
George Liue53193f2020-02-24 09:23:26 +08004#include "libpldmresponder/pdr_utils.hpp"
Sampa Misraaa8ae722019-12-12 03:20:40 -06005#include "utils.hpp"
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -05006
7#include <stdint.h>
8
9#include <filesystem>
10#include <fstream>
11#include <functional>
Sampa Misraaa8ae722019-12-12 03:20:40 -060012#include <iostream>
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -050013#include <map>
14#include <nlohmann/json.hpp>
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -050015#include <string>
16#include <vector>
17#include <xyz/openbmc_project/Common/error.hpp>
18
George Liue53193f2020-02-24 09:23:26 +080019#include "libpldm/pdr.h"
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -050020#include "libpldm/platform.h"
21
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -050022using InternalFailure =
23 sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
24namespace fs = std::filesystem;
25
George Liue53193f2020-02-24 09:23:26 +080026using namespace pldm::responder::pdr_utils;
27
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -050028namespace pldm
29{
30
31namespace responder
32{
33
34namespace pdr
35{
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -050036/** @brief Parse PDR JSONs and build PDR repository
37 *
38 * @param[in] dir - directory housing platform specific PDR JSON files
George Liue53193f2020-02-24 09:23:26 +080039 * @param[in] repo - instance of the concrete implementation of RepoInterface
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -050040 */
George Liue53193f2020-02-24 09:23:26 +080041void generate(const std::string& dir, RepoInterface& repo);
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -050042
43/** @brief Build (if not built already) and retrieve PDR
44 *
45 * @param[in] dir - directory housing platform specific PDR JSON files
46 *
George Liue53193f2020-02-24 09:23:26 +080047 * @return RepoInterface& - Reference to instance of pdr::RepoInterface
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -050048 */
George Liue53193f2020-02-24 09:23:26 +080049RepoInterface& 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 */
58Repo 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 */
69const pldm_pdr_record* getRecordByHandle(RepoInterface& pdrRepo,
70 RecordHandle recordHandle,
71 PdrEntry& pdrEntry);
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -050072
73} // namespace pdr
74} // namespace responder
75} // namespace pldm