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 | 733b39d | 2024-06-05 21:05:20 -0500 | [diff] [blame^] | 5 | #include "pcie_device.hpp" |
Archana Kakani | bf1fd27 | 2024-06-05 13:25:53 -0500 | [diff] [blame] | 6 | #include "pcie_slot.hpp" |
George Liu | 682ee18 | 2020-12-25 15:24:33 +0800 | [diff] [blame] | 7 | |
| 8 | #include <sdbusplus/server.hpp> |
| 9 | #include <xyz/openbmc_project/Inventory/Decorator/LocationCode/server.hpp> |
| 10 | |
| 11 | #include <memory> |
| 12 | #include <optional> |
| 13 | #include <string> |
| 14 | #include <unordered_map> |
| 15 | |
| 16 | namespace pldm |
| 17 | { |
| 18 | namespace dbus |
| 19 | { |
| 20 | using ObjectPath = std::string; |
| 21 | |
Patrick Williams | 705fa98 | 2023-09-27 02:32:20 -0500 | [diff] [blame] | 22 | using LocationIntf = |
| 23 | sdbusplus::server::object_t<sdbusplus::xyz::openbmc_project::Inventory:: |
| 24 | Decorator::server::LocationCode>; |
George Liu | 682ee18 | 2020-12-25 15:24:33 +0800 | [diff] [blame] | 25 | |
| 26 | /** @class CustomDBus |
| 27 | * @brief This is a custom D-Bus object, used to add D-Bus interface and update |
| 28 | * the corresponding properties value. |
| 29 | */ |
| 30 | class CustomDBus |
| 31 | { |
| 32 | private: |
| 33 | CustomDBus() {} |
| 34 | |
| 35 | public: |
| 36 | CustomDBus(const CustomDBus&) = delete; |
| 37 | CustomDBus(CustomDBus&&) = delete; |
| 38 | CustomDBus& operator=(const CustomDBus&) = delete; |
| 39 | CustomDBus& operator=(CustomDBus&&) = delete; |
| 40 | ~CustomDBus() = default; |
| 41 | |
| 42 | static CustomDBus& getCustomDBus() |
| 43 | { |
| 44 | static CustomDBus customDBus; |
| 45 | return customDBus; |
| 46 | } |
| 47 | |
| 48 | public: |
| 49 | /** @brief Set the LocationCode property |
| 50 | * |
| 51 | * @param[in] path - The object path |
| 52 | * |
| 53 | * @param[in] value - The value of the LocationCode property |
| 54 | */ |
| 55 | void setLocationCode(const std::string& path, std::string value); |
| 56 | |
| 57 | /** @brief Get the LocationCode property |
| 58 | * |
Kamalkumar Patel | 56da574 | 2024-05-23 04:53:07 -0500 | [diff] [blame] | 59 | * @param[in] path - The object path |
George Liu | 682ee18 | 2020-12-25 15:24:33 +0800 | [diff] [blame] | 60 | * |
| 61 | * @return std::optional<std::string> - The value of the LocationCode |
| 62 | * property |
| 63 | */ |
| 64 | std::optional<std::string> getLocationCode(const std::string& path) const; |
Kamalkumar Patel | 56da574 | 2024-05-23 04:53:07 -0500 | [diff] [blame] | 65 | /** @brief Implement CpuCore Interface |
| 66 | * |
| 67 | * @param[in] path - The object path |
| 68 | * |
| 69 | */ |
| 70 | void implementCpuCoreInterface(const std::string& path); |
| 71 | /** @brief Set the microcode property |
| 72 | * |
| 73 | * @param[in] path - The object path |
| 74 | * |
| 75 | * @param[in] value - microcode value |
| 76 | */ |
| 77 | void setMicroCode(const std::string& path, uint32_t value); |
| 78 | |
| 79 | /** @brief Get the microcode property |
| 80 | * |
| 81 | * @param[in] path - The object path |
| 82 | * |
| 83 | * @return std::optional<uint32_t> - The value of the microcode value |
| 84 | */ |
| 85 | std::optional<uint32_t> getMicroCode(const std::string& path) const; |
George Liu | 682ee18 | 2020-12-25 15:24:33 +0800 | [diff] [blame] | 86 | |
Archana Kakani | bf1fd27 | 2024-06-05 13:25:53 -0500 | [diff] [blame] | 87 | /** @brief Implement PCIeSlot Interface |
| 88 | * |
| 89 | * @param[in] path - the object path |
| 90 | */ |
| 91 | void implementPCIeSlotInterface(const std::string& path); |
| 92 | |
| 93 | /** @brief Set the slot type |
| 94 | * |
| 95 | * @param[in] path - the object path |
| 96 | * @param[in] slot type - Slot type |
| 97 | */ |
| 98 | void setSlotType(const std::string& path, const std::string& slotType); |
| 99 | |
Archana Kakani | 733b39d | 2024-06-05 21:05:20 -0500 | [diff] [blame^] | 100 | /** @brief Implement PCIe Device Interface |
| 101 | * |
| 102 | * @param[in] path - the object path |
| 103 | */ |
| 104 | void implementPCIeDeviceInterface(const std::string& path); |
| 105 | |
| 106 | /** @brief Set PCIe Device Lanes in use property |
| 107 | * |
| 108 | * @param[in] path - the object path |
| 109 | * @param[in] lanesInUse - Lanes in use |
| 110 | * @param[in] value - Generation in use |
| 111 | */ |
| 112 | void setPCIeDeviceProps(const std::string& path, size_t lanesInUse, |
| 113 | const std::string& value); |
| 114 | |
George Liu | 682ee18 | 2020-12-25 15:24:33 +0800 | [diff] [blame] | 115 | private: |
| 116 | std::unordered_map<ObjectPath, std::unique_ptr<LocationIntf>> location; |
Kamalkumar Patel | 56da574 | 2024-05-23 04:53:07 -0500 | [diff] [blame] | 117 | std::unordered_map<ObjectPath, std::unique_ptr<CPUCore>> cpuCore; |
Archana Kakani | 733b39d | 2024-06-05 21:05:20 -0500 | [diff] [blame^] | 118 | std::unordered_map<ObjectPath, std::unique_ptr<PCIeDevice>> pcieDevice; |
Archana Kakani | bf1fd27 | 2024-06-05 13:25:53 -0500 | [diff] [blame] | 119 | std::unordered_map<ObjectPath, std::unique_ptr<PCIeSlot>> pcieSlot; |
George Liu | 682ee18 | 2020-12-25 15:24:33 +0800 | [diff] [blame] | 120 | }; |
| 121 | |
| 122 | } // namespace dbus |
| 123 | } // namespace pldm |