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" |
Archana Kakani | bf1fd27 | 2024-06-05 13:25:53 -0500 | [diff] [blame^] | 5 | #include "pcie_slot.hpp" |
George Liu | 682ee18 | 2020-12-25 15:24:33 +0800 | [diff] [blame] | 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 | |
Patrick Williams | 705fa98 | 2023-09-27 02:32:20 -0500 | [diff] [blame] | 21 | using LocationIntf = |
| 22 | sdbusplus::server::object_t<sdbusplus::xyz::openbmc_project::Inventory:: |
| 23 | Decorator::server::LocationCode>; |
George Liu | 682ee18 | 2020-12-25 15:24:33 +0800 | [diff] [blame] | 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: |
| 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 | |
| 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 | * |
Kamalkumar Patel | 56da574 | 2024-05-23 04:53:07 -0500 | [diff] [blame] | 58 | * @param[in] path - The object path |
George Liu | 682ee18 | 2020-12-25 15:24:33 +0800 | [diff] [blame] | 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; |
Kamalkumar Patel | 56da574 | 2024-05-23 04:53:07 -0500 | [diff] [blame] | 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; |
George Liu | 682ee18 | 2020-12-25 15:24:33 +0800 | [diff] [blame] | 85 | |
Archana Kakani | bf1fd27 | 2024-06-05 13:25:53 -0500 | [diff] [blame^] | 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 | |
George Liu | 682ee18 | 2020-12-25 15:24:33 +0800 | [diff] [blame] | 99 | private: |
| 100 | std::unordered_map<ObjectPath, std::unique_ptr<LocationIntf>> location; |
Kamalkumar Patel | 56da574 | 2024-05-23 04:53:07 -0500 | [diff] [blame] | 101 | std::unordered_map<ObjectPath, std::unique_ptr<CPUCore>> cpuCore; |
Archana Kakani | bf1fd27 | 2024-06-05 13:25:53 -0500 | [diff] [blame^] | 102 | std::unordered_map<ObjectPath, std::unique_ptr<PCIeSlot>> pcieSlot; |
George Liu | 682ee18 | 2020-12-25 15:24:33 +0800 | [diff] [blame] | 103 | }; |
| 104 | |
| 105 | } // namespace dbus |
| 106 | } // namespace pldm |