George Liu | 682ee18 | 2020-12-25 15:24:33 +0800 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "common/utils.hpp" |
Kamalkumar Patel | 56da574 | 2024-05-23 04:53:07 -0500 | [diff] [blame] | 4 | #include "cpu_core.hpp" |
George Liu | 682ee18 | 2020-12-25 15:24:33 +0800 | [diff] [blame] | 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 | |
Patrick Williams | 705fa98 | 2023-09-27 02:32:20 -0500 | [diff] [blame] | 20 | using LocationIntf = |
| 21 | sdbusplus::server::object_t<sdbusplus::xyz::openbmc_project::Inventory:: |
| 22 | Decorator::server::LocationCode>; |
George Liu | 682ee18 | 2020-12-25 15:24:33 +0800 | [diff] [blame] | 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: |
| 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 | |
| 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 | * |
Kamalkumar Patel | 56da574 | 2024-05-23 04:53:07 -0500 | [diff] [blame] | 57 | * @param[in] path - The object path |
George Liu | 682ee18 | 2020-12-25 15:24:33 +0800 | [diff] [blame] | 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; |
Kamalkumar Patel | 56da574 | 2024-05-23 04:53:07 -0500 | [diff] [blame] | 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; |
George Liu | 682ee18 | 2020-12-25 15:24:33 +0800 | [diff] [blame] | 84 | |
| 85 | private: |
| 86 | std::unordered_map<ObjectPath, std::unique_ptr<LocationIntf>> location; |
Kamalkumar Patel | 56da574 | 2024-05-23 04:53:07 -0500 | [diff] [blame] | 87 | std::unordered_map<ObjectPath, std::unique_ptr<CPUCore>> cpuCore; |
George Liu | 682ee18 | 2020-12-25 15:24:33 +0800 | [diff] [blame] | 88 | }; |
| 89 | |
| 90 | } // namespace dbus |
| 91 | } // namespace pldm |