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