1 #pragma once 2 3 #include "common/utils.hpp" 4 #include "cpu_core.hpp" 5 #include "pcie_slot.hpp" 6 7 #include <sdbusplus/server.hpp> 8 #include <xyz/openbmc_project/Inventory/Decorator/LocationCode/server.hpp> 9 10 #include <memory> 11 #include <optional> 12 #include <string> 13 #include <unordered_map> 14 15 namespace pldm 16 { 17 namespace dbus 18 { 19 using ObjectPath = std::string; 20 21 using LocationIntf = 22 sdbusplus::server::object_t<sdbusplus::xyz::openbmc_project::Inventory:: 23 Decorator::server::LocationCode>; 24 25 /** @class CustomDBus 26 * @brief This is a custom D-Bus object, used to add D-Bus interface and update 27 * the corresponding properties value. 28 */ 29 class CustomDBus 30 { 31 private: CustomDBus()32 CustomDBus() {} 33 34 public: 35 CustomDBus(const CustomDBus&) = delete; 36 CustomDBus(CustomDBus&&) = delete; 37 CustomDBus& operator=(const CustomDBus&) = delete; 38 CustomDBus& operator=(CustomDBus&&) = delete; 39 ~CustomDBus() = default; 40 getCustomDBus()41 static CustomDBus& getCustomDBus() 42 { 43 static CustomDBus customDBus; 44 return customDBus; 45 } 46 47 public: 48 /** @brief Set the LocationCode property 49 * 50 * @param[in] path - The object path 51 * 52 * @param[in] value - The value of the LocationCode property 53 */ 54 void setLocationCode(const std::string& path, std::string value); 55 56 /** @brief Get the LocationCode property 57 * 58 * @param[in] path - The object path 59 * 60 * @return std::optional<std::string> - The value of the LocationCode 61 * property 62 */ 63 std::optional<std::string> getLocationCode(const std::string& path) const; 64 /** @brief Implement CpuCore Interface 65 * 66 * @param[in] path - The object path 67 * 68 */ 69 void implementCpuCoreInterface(const std::string& path); 70 /** @brief Set the microcode property 71 * 72 * @param[in] path - The object path 73 * 74 * @param[in] value - microcode value 75 */ 76 void setMicroCode(const std::string& path, uint32_t value); 77 78 /** @brief Get the microcode property 79 * 80 * @param[in] path - The object path 81 * 82 * @return std::optional<uint32_t> - The value of the microcode value 83 */ 84 std::optional<uint32_t> getMicroCode(const std::string& path) const; 85 86 /** @brief Implement PCIeSlot Interface 87 * 88 * @param[in] path - the object path 89 */ 90 void implementPCIeSlotInterface(const std::string& path); 91 92 /** @brief Set the slot type 93 * 94 * @param[in] path - the object path 95 * @param[in] slot type - Slot type 96 */ 97 void setSlotType(const std::string& path, const std::string& slotType); 98 99 private: 100 std::unordered_map<ObjectPath, std::unique_ptr<LocationIntf>> location; 101 std::unordered_map<ObjectPath, std::unique_ptr<CPUCore>> cpuCore; 102 std::unordered_map<ObjectPath, std::unique_ptr<PCIeSlot>> pcieSlot; 103 }; 104 105 } // namespace dbus 106 } // namespace pldm 107