blob: 857d6c78b1abd9e03050b49a49726f7e3bbacd37 [file] [log] [blame]
Kamalkumar Patel4e69d252024-05-10 08:48:03 -05001#include "libpldm/pdr.h"
2
3#include "libpldmresponder/oem_handler.hpp"
4
5#include <nlohmann/json.hpp>
6#include <phosphor-logging/lg2.hpp>
7
8#include <filesystem>
9#include <fstream>
10#include <map>
11#include <string>
12#include <vector>
13
14PHOSPHOR_LOG2_USING;
15namespace pldm
16{
17using EntityName = std::string;
18using EntityType = uint16_t;
19
20using Entities = std::vector<pldm_entity_node*>;
21using EntityAssociations = std::vector<Entities>;
22using ObjectPathMaps = std::map<fs::path, pldm_entity_node*>;
23namespace hostbmc
24{
25namespace utils
26{
27
28const std::map<EntityType, EntityName> entityMaps = {
29 {PLDM_ENTITY_SYSTEM_CHASSIS, "chassis"},
30 {PLDM_ENTITY_BOARD, "io_board"},
31 {PLDM_ENTITY_SYS_BOARD, "motherboard"},
32 {PLDM_ENTITY_POWER_SUPPLY, "powersupply"},
33 {PLDM_ENTITY_PROC, "cpu"},
34 {PLDM_ENTITY_SYSTEM_CHASSIS | 0x8000, "system"},
35 {PLDM_ENTITY_PROC_MODULE, "dcm"},
36 {PLDM_ENTITY_PROC | 0x8000, "core"},
37 {PLDM_ENTITY_IO_MODULE, "io_module"},
38 {PLDM_ENTITY_FAN, "fan"},
39 {PLDM_ENTITY_SYS_MGMT_MODULE, "system_management_module"},
40 {PLDM_ENTITY_POWER_CONVERTER, "power_converter"},
41 {PLDM_ENTITY_SLOT, "slot"},
42 {PLDM_ENTITY_CONNECTOR, "connector"}};
43
44/** @brief Vector a entity name to pldm_entity from entity association tree
45 * @param[in] entityAssoc - Vector of associated pldm entities
46 * @param[in] entityTree - entity association tree
47 * @param[out] objPathMap - maps an object path to pldm_entity from the
48 * BMC's entity association tree
49 * @return
50 */
51void updateEntityAssociation(const EntityAssociations& entityAssoc,
52 pldm_entity_association_tree* entityTree,
53 ObjectPathMaps& objPathMap);
54
55} // namespace utils
56} // namespace hostbmc
57} // namespace pldm