114107a10SKamalkumar Patel #pragma once 214107a10SKamalkumar Patel 314107a10SKamalkumar Patel #include "common/utils.hpp" 4*56da5740SKamalkumar Patel #include "cpu_core.hpp" 514107a10SKamalkumar Patel 614107a10SKamalkumar Patel #include <sdbusplus/server.hpp> 714107a10SKamalkumar Patel #include <xyz/openbmc_project/Inventory/Decorator/LocationCode/server.hpp> 814107a10SKamalkumar Patel 914107a10SKamalkumar Patel #include <memory> 1014107a10SKamalkumar Patel #include <optional> 1114107a10SKamalkumar Patel #include <string> 1214107a10SKamalkumar Patel #include <unordered_map> 1314107a10SKamalkumar Patel 1414107a10SKamalkumar Patel namespace pldm 1514107a10SKamalkumar Patel { 1614107a10SKamalkumar Patel namespace dbus 1714107a10SKamalkumar Patel { 1814107a10SKamalkumar Patel using ObjectPath = std::string; 1914107a10SKamalkumar Patel 2014107a10SKamalkumar Patel using LocationIntf = 2114107a10SKamalkumar Patel sdbusplus::server::object_t<sdbusplus::xyz::openbmc_project::Inventory:: 2214107a10SKamalkumar Patel Decorator::server::LocationCode>; 2314107a10SKamalkumar Patel 2414107a10SKamalkumar Patel /** @class CustomDBus 2514107a10SKamalkumar Patel * @brief This is a custom D-Bus object, used to add D-Bus interface and update 2614107a10SKamalkumar Patel * the corresponding properties value. 2714107a10SKamalkumar Patel */ 2814107a10SKamalkumar Patel class CustomDBus 2914107a10SKamalkumar Patel { 3014107a10SKamalkumar Patel private: CustomDBus()3114107a10SKamalkumar Patel CustomDBus() {} 3214107a10SKamalkumar Patel 3314107a10SKamalkumar Patel public: 3414107a10SKamalkumar Patel CustomDBus(const CustomDBus&) = delete; 3514107a10SKamalkumar Patel CustomDBus(CustomDBus&&) = delete; 3614107a10SKamalkumar Patel CustomDBus& operator=(const CustomDBus&) = delete; 3714107a10SKamalkumar Patel CustomDBus& operator=(CustomDBus&&) = delete; 3814107a10SKamalkumar Patel ~CustomDBus() = default; 3914107a10SKamalkumar Patel getCustomDBus()4014107a10SKamalkumar Patel static CustomDBus& getCustomDBus() 4114107a10SKamalkumar Patel { 4214107a10SKamalkumar Patel static CustomDBus customDBus; 4314107a10SKamalkumar Patel return customDBus; 4414107a10SKamalkumar Patel } 4514107a10SKamalkumar Patel 4614107a10SKamalkumar Patel public: 4714107a10SKamalkumar Patel /** @brief Set the LocationCode property 4814107a10SKamalkumar Patel * 4914107a10SKamalkumar Patel * @param[in] path - The object path 5014107a10SKamalkumar Patel * 5114107a10SKamalkumar Patel * @param[in] value - The value of the LocationCode property 5214107a10SKamalkumar Patel */ 5314107a10SKamalkumar Patel void setLocationCode(const std::string& path, std::string value); 5414107a10SKamalkumar Patel 5514107a10SKamalkumar Patel /** @brief Get the LocationCode property 5614107a10SKamalkumar Patel * 5714107a10SKamalkumar Patel * @param[in] path - The object path 5814107a10SKamalkumar Patel * 5914107a10SKamalkumar Patel * @return std::optional<std::string> - The value of the LocationCode 6014107a10SKamalkumar Patel * property 6114107a10SKamalkumar Patel */ 6214107a10SKamalkumar Patel std::optional<std::string> getLocationCode(const std::string& path) const; 63*56da5740SKamalkumar Patel /** @brief Implement CpuCore Interface 64*56da5740SKamalkumar Patel * 65*56da5740SKamalkumar Patel * @param[in] path - The object path 66*56da5740SKamalkumar Patel * 67*56da5740SKamalkumar Patel */ 68*56da5740SKamalkumar Patel void implementCpuCoreInterface(const std::string& path); 69*56da5740SKamalkumar Patel /** @brief Set the microcode property 70*56da5740SKamalkumar Patel * 71*56da5740SKamalkumar Patel * @param[in] path - The object path 72*56da5740SKamalkumar Patel * 73*56da5740SKamalkumar Patel * @param[in] value - microcode value 74*56da5740SKamalkumar Patel */ 75*56da5740SKamalkumar Patel void setMicroCode(const std::string& path, uint32_t value); 76*56da5740SKamalkumar Patel 77*56da5740SKamalkumar Patel /** @brief Get the microcode property 78*56da5740SKamalkumar Patel * 79*56da5740SKamalkumar Patel * @param[in] path - The object path 80*56da5740SKamalkumar Patel * 81*56da5740SKamalkumar Patel * @return std::optional<uint32_t> - The value of the microcode value 82*56da5740SKamalkumar Patel */ 83*56da5740SKamalkumar Patel std::optional<uint32_t> getMicroCode(const std::string& path) const; 8414107a10SKamalkumar Patel 8514107a10SKamalkumar Patel private: 8614107a10SKamalkumar Patel std::unordered_map<ObjectPath, std::unique_ptr<LocationIntf>> location; 87*56da5740SKamalkumar Patel std::unordered_map<ObjectPath, std::unique_ptr<CPUCore>> cpuCore; 8814107a10SKamalkumar Patel }; 8914107a10SKamalkumar Patel 9014107a10SKamalkumar Patel } // namespace dbus 9114107a10SKamalkumar Patel } // namespace pldm 92