Kamalkumar Patel | 4e69d25 | 2024-05-10 08:48:03 -0500 | [diff] [blame^] | 1 | #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 | |
| 14 | PHOSPHOR_LOG2_USING; |
| 15 | namespace pldm |
| 16 | { |
| 17 | using EntityName = std::string; |
| 18 | using EntityType = uint16_t; |
| 19 | |
| 20 | using Entities = std::vector<pldm_entity_node*>; |
| 21 | using EntityAssociations = std::vector<Entities>; |
| 22 | using ObjectPathMaps = std::map<fs::path, pldm_entity_node*>; |
| 23 | namespace hostbmc |
| 24 | { |
| 25 | namespace utils |
| 26 | { |
| 27 | |
| 28 | const 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 | */ |
| 51 | void updateEntityAssociation(const EntityAssociations& entityAssoc, |
| 52 | pldm_entity_association_tree* entityTree, |
| 53 | ObjectPathMaps& objPathMap); |
| 54 | |
| 55 | } // namespace utils |
| 56 | } // namespace hostbmc |
| 57 | } // namespace pldm |