George Liu | 682ee18 | 2020-12-25 15:24:33 +0800 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Archana Kakani | 1634a6e | 2025-02-04 01:12:29 -0600 | [diff] [blame] | 3 | #include "asset.hpp" |
Archana Kakani | f935537 | 2025-02-04 03:13:24 -0600 | [diff] [blame] | 4 | #include "availability.hpp" |
Archana Kakani | d432b48 | 2025-02-04 22:52:28 -0600 | [diff] [blame] | 5 | #include "board.hpp" |
Archana Kakani | b40f4f8 | 2024-06-06 01:04:38 -0500 | [diff] [blame] | 6 | #include "cable.hpp" |
Archana Kakani | db65c3b | 2025-02-03 05:27:28 -0600 | [diff] [blame] | 7 | #include "chassis.hpp" |
George Liu | 682ee18 | 2020-12-25 15:24:33 +0800 | [diff] [blame] | 8 | #include "common/utils.hpp" |
Archana Kakani | 17b1e8a | 2025-02-04 03:50:24 -0600 | [diff] [blame] | 9 | #include "connector.hpp" |
Kamalkumar Patel | 56da574 | 2024-05-23 04:53:07 -0500 | [diff] [blame] | 10 | #include "cpu_core.hpp" |
Archana Kakani | 42876b6 | 2025-02-04 04:22:29 -0600 | [diff] [blame] | 11 | #include "fabric_adapter.hpp" |
Archana Kakani | 413f51e | 2025-02-03 04:14:36 -0600 | [diff] [blame] | 12 | #include "fan.hpp" |
Archana Kakani | c366447 | 2025-02-04 05:36:37 -0600 | [diff] [blame] | 13 | #include "inventory_item.hpp" |
Kamalkumar Patel | 2ed986c | 2024-05-08 02:20:47 -0500 | [diff] [blame] | 14 | #include "motherboard.hpp" |
Archana Kakani | 765cf03 | 2025-02-04 06:24:14 -0600 | [diff] [blame] | 15 | #include "panel.hpp" |
Archana Kakani | 733b39d | 2024-06-05 21:05:20 -0500 | [diff] [blame] | 16 | #include "pcie_device.hpp" |
Archana Kakani | bf1fd27 | 2024-06-05 13:25:53 -0500 | [diff] [blame] | 17 | #include "pcie_slot.hpp" |
Archana Kakani | 24e9a9b | 2025-02-04 00:27:25 -0600 | [diff] [blame] | 18 | #include "power_supply.hpp" |
Archana Kakani | 2832f2c | 2025-02-04 22:29:30 -0600 | [diff] [blame] | 19 | #include "vrm.hpp" |
George Liu | 682ee18 | 2020-12-25 15:24:33 +0800 | [diff] [blame] | 20 | |
| 21 | #include <sdbusplus/server.hpp> |
| 22 | #include <xyz/openbmc_project/Inventory/Decorator/LocationCode/server.hpp> |
| 23 | |
| 24 | #include <memory> |
| 25 | #include <optional> |
| 26 | #include <string> |
| 27 | #include <unordered_map> |
| 28 | |
| 29 | namespace pldm |
| 30 | { |
| 31 | namespace dbus |
| 32 | { |
| 33 | using ObjectPath = std::string; |
| 34 | |
Patrick Williams | 705fa98 | 2023-09-27 02:32:20 -0500 | [diff] [blame] | 35 | using LocationIntf = |
| 36 | sdbusplus::server::object_t<sdbusplus::xyz::openbmc_project::Inventory:: |
| 37 | Decorator::server::LocationCode>; |
George Liu | 682ee18 | 2020-12-25 15:24:33 +0800 | [diff] [blame] | 38 | |
| 39 | /** @class CustomDBus |
| 40 | * @brief This is a custom D-Bus object, used to add D-Bus interface and update |
| 41 | * the corresponding properties value. |
| 42 | */ |
| 43 | class CustomDBus |
| 44 | { |
| 45 | private: |
| 46 | CustomDBus() {} |
| 47 | |
| 48 | public: |
| 49 | CustomDBus(const CustomDBus&) = delete; |
| 50 | CustomDBus(CustomDBus&&) = delete; |
| 51 | CustomDBus& operator=(const CustomDBus&) = delete; |
| 52 | CustomDBus& operator=(CustomDBus&&) = delete; |
| 53 | ~CustomDBus() = default; |
| 54 | |
| 55 | static CustomDBus& getCustomDBus() |
| 56 | { |
| 57 | static CustomDBus customDBus; |
| 58 | return customDBus; |
| 59 | } |
| 60 | |
| 61 | public: |
| 62 | /** @brief Set the LocationCode property |
| 63 | * |
| 64 | * @param[in] path - The object path |
| 65 | * |
| 66 | * @param[in] value - The value of the LocationCode property |
| 67 | */ |
| 68 | void setLocationCode(const std::string& path, std::string value); |
| 69 | |
| 70 | /** @brief Get the LocationCode property |
| 71 | * |
Kamalkumar Patel | 56da574 | 2024-05-23 04:53:07 -0500 | [diff] [blame] | 72 | * @param[in] path - The object path |
George Liu | 682ee18 | 2020-12-25 15:24:33 +0800 | [diff] [blame] | 73 | * |
| 74 | * @return std::optional<std::string> - The value of the LocationCode |
| 75 | * property |
| 76 | */ |
| 77 | std::optional<std::string> getLocationCode(const std::string& path) const; |
Kamalkumar Patel | 56da574 | 2024-05-23 04:53:07 -0500 | [diff] [blame] | 78 | /** @brief Implement CpuCore Interface |
| 79 | * |
| 80 | * @param[in] path - The object path |
| 81 | * |
| 82 | */ |
| 83 | void implementCpuCoreInterface(const std::string& path); |
| 84 | /** @brief Set the microcode property |
| 85 | * |
| 86 | * @param[in] path - The object path |
| 87 | * |
| 88 | * @param[in] value - microcode value |
| 89 | */ |
| 90 | void setMicroCode(const std::string& path, uint32_t value); |
| 91 | |
| 92 | /** @brief Get the microcode property |
| 93 | * |
| 94 | * @param[in] path - The object path |
| 95 | * |
| 96 | * @return std::optional<uint32_t> - The value of the microcode value |
| 97 | */ |
| 98 | std::optional<uint32_t> getMicroCode(const std::string& path) const; |
George Liu | 682ee18 | 2020-12-25 15:24:33 +0800 | [diff] [blame] | 99 | |
Archana Kakani | bf1fd27 | 2024-06-05 13:25:53 -0500 | [diff] [blame] | 100 | /** @brief Implement PCIeSlot Interface |
| 101 | * |
| 102 | * @param[in] path - the object path |
| 103 | */ |
| 104 | void implementPCIeSlotInterface(const std::string& path); |
| 105 | |
| 106 | /** @brief Set the slot type |
| 107 | * |
| 108 | * @param[in] path - the object path |
| 109 | * @param[in] slot type - Slot type |
| 110 | */ |
| 111 | void setSlotType(const std::string& path, const std::string& slotType); |
| 112 | |
Archana Kakani | 733b39d | 2024-06-05 21:05:20 -0500 | [diff] [blame] | 113 | /** @brief Implement PCIe Device Interface |
| 114 | * |
| 115 | * @param[in] path - the object path |
| 116 | */ |
| 117 | void implementPCIeDeviceInterface(const std::string& path); |
| 118 | |
| 119 | /** @brief Set PCIe Device Lanes in use property |
| 120 | * |
| 121 | * @param[in] path - the object path |
| 122 | * @param[in] lanesInUse - Lanes in use |
| 123 | * @param[in] value - Generation in use |
| 124 | */ |
| 125 | void setPCIeDeviceProps(const std::string& path, size_t lanesInUse, |
| 126 | const std::string& value); |
| 127 | |
Archana Kakani | b40f4f8 | 2024-06-06 01:04:38 -0500 | [diff] [blame] | 128 | /** @brief Implement PCIe Cable Interface |
| 129 | * |
| 130 | * @param[in] path - the object path |
| 131 | */ |
| 132 | void implementCableInterface(const std::string& path); |
| 133 | |
| 134 | /** @brief set cable attributes |
| 135 | * |
| 136 | * @param[in] path - the object path |
| 137 | * @param[in] length - length of the wire |
| 138 | * @param[in] cableDescription - cable details |
| 139 | */ |
| 140 | void setCableAttributes(const std::string& path, double length, |
| 141 | const std::string& cableDescription); |
Kamalkumar Patel | 2ed986c | 2024-05-08 02:20:47 -0500 | [diff] [blame] | 142 | /** @brief Implement interface for motherboard property |
| 143 | * |
| 144 | * @param[in] path - The object path |
| 145 | * |
| 146 | */ |
| 147 | void implementMotherboardInterface(const std::string& path); |
Archana Kakani | b40f4f8 | 2024-06-06 01:04:38 -0500 | [diff] [blame] | 148 | |
Archana Kakani | 413f51e | 2025-02-03 04:14:36 -0600 | [diff] [blame] | 149 | /** @brief Implement Fan Interface |
| 150 | * |
| 151 | * @param[in] path - The object path |
| 152 | * |
| 153 | */ |
| 154 | void implementFanInterface(const std::string& path); |
| 155 | |
Archana Kakani | db65c3b | 2025-02-03 05:27:28 -0600 | [diff] [blame] | 156 | /** @brief Implement Chassis Interface |
| 157 | * @param[in] path - the object path |
| 158 | */ |
| 159 | void implementChassisInterface(const std::string& path); |
| 160 | |
Archana Kakani | 24e9a9b | 2025-02-04 00:27:25 -0600 | [diff] [blame] | 161 | /** @brief Implement PowerSupply Interface |
| 162 | * |
| 163 | * @param[in] path - The object path |
| 164 | * |
| 165 | */ |
| 166 | void implementPowerSupplyInterface(const std::string& path); |
| 167 | |
Archana Kakani | 17b1e8a | 2025-02-04 03:50:24 -0600 | [diff] [blame] | 168 | /** @brief Implement Connector Interface |
| 169 | * |
| 170 | * @param[in] path - The object path |
| 171 | * |
| 172 | */ |
| 173 | void implementConnecterInterface(const std::string& path); |
| 174 | |
Archana Kakani | 42876b6 | 2025-02-04 04:22:29 -0600 | [diff] [blame] | 175 | /** @brief Implement Fabric Adapter Interface |
| 176 | * |
| 177 | * @param[in] path - The object path |
| 178 | * |
| 179 | */ |
| 180 | void implementFabricAdapter(const std::string& path); |
| 181 | |
Archana Kakani | d432b48 | 2025-02-04 22:52:28 -0600 | [diff] [blame] | 182 | /** @brief Implement Board Interface |
| 183 | * |
| 184 | * @param[in] path - The object path |
| 185 | * |
| 186 | */ |
| 187 | void implementBoard(const std::string& path); |
| 188 | |
Archana Kakani | 1634a6e | 2025-02-04 01:12:29 -0600 | [diff] [blame] | 189 | /** @brief Implement Asset Interface |
| 190 | * |
| 191 | * @param[in] path - The object path |
| 192 | * |
| 193 | */ |
| 194 | void implementAssetInterface(const std::string& path); |
| 195 | |
Archana Kakani | f935537 | 2025-02-04 03:13:24 -0600 | [diff] [blame] | 196 | /** @brief Set the availability state property |
| 197 | * |
| 198 | * @param[in] path - The object path |
| 199 | * |
| 200 | * @param[in] state - Availability state |
| 201 | */ |
| 202 | void setAvailabilityState(const std::string& path, const bool& state); |
| 203 | |
Archana Kakani | c366447 | 2025-02-04 05:36:37 -0600 | [diff] [blame] | 204 | /** @brief Set the Inventory Item property |
| 205 | * @param[in] path - The object path |
| 206 | * @param[in] bool - the presence of fru |
| 207 | */ |
| 208 | void updateItemPresentStatus(const std::string& path, bool isPresent); |
| 209 | |
Archana Kakani | 765cf03 | 2025-02-04 06:24:14 -0600 | [diff] [blame] | 210 | /** @brief Implement Panel Interface |
| 211 | * |
| 212 | * @param[in] path - The object path |
| 213 | * |
| 214 | */ |
| 215 | void implementPanelInterface(const std::string& path); |
| 216 | |
Archana Kakani | 2832f2c | 2025-02-04 22:29:30 -0600 | [diff] [blame] | 217 | /** @brief Implement Voltage Regulator Module Interface |
| 218 | * |
| 219 | * @param[in] path - The object path |
| 220 | * |
| 221 | */ |
| 222 | void implementVRMInterface(const std::string& path); |
| 223 | |
George Liu | 682ee18 | 2020-12-25 15:24:33 +0800 | [diff] [blame] | 224 | private: |
Archana Kakani | 1634a6e | 2025-02-04 01:12:29 -0600 | [diff] [blame] | 225 | std::unordered_map<ObjectPath, std::unique_ptr<Asset>> asset; |
Archana Kakani | f935537 | 2025-02-04 03:13:24 -0600 | [diff] [blame] | 226 | std::unordered_map<ObjectPath, std::unique_ptr<Availability>> |
| 227 | availabilityState; |
George Liu | 682ee18 | 2020-12-25 15:24:33 +0800 | [diff] [blame] | 228 | std::unordered_map<ObjectPath, std::unique_ptr<LocationIntf>> location; |
Archana Kakani | c366447 | 2025-02-04 05:36:37 -0600 | [diff] [blame] | 229 | std::unordered_map<ObjectPath, std::unique_ptr<InventoryItem>> |
| 230 | presentStatus; |
Kamalkumar Patel | 56da574 | 2024-05-23 04:53:07 -0500 | [diff] [blame] | 231 | std::unordered_map<ObjectPath, std::unique_ptr<CPUCore>> cpuCore; |
Archana Kakani | db65c3b | 2025-02-03 05:27:28 -0600 | [diff] [blame] | 232 | std::unordered_map<ObjectPath, std::unique_ptr<ItemChassis>> chassis; |
Archana Kakani | 733b39d | 2024-06-05 21:05:20 -0500 | [diff] [blame] | 233 | std::unordered_map<ObjectPath, std::unique_ptr<PCIeDevice>> pcieDevice; |
Archana Kakani | bf1fd27 | 2024-06-05 13:25:53 -0500 | [diff] [blame] | 234 | std::unordered_map<ObjectPath, std::unique_ptr<PCIeSlot>> pcieSlot; |
Archana Kakani | 24e9a9b | 2025-02-04 00:27:25 -0600 | [diff] [blame] | 235 | std::unordered_map<ObjectPath, std::unique_ptr<PowerSupply>> powersupply; |
Archana Kakani | d432b48 | 2025-02-04 22:52:28 -0600 | [diff] [blame] | 236 | std::unordered_map<ObjectPath, std::unique_ptr<Board>> board; |
Archana Kakani | 42876b6 | 2025-02-04 04:22:29 -0600 | [diff] [blame] | 237 | std::unordered_map<ObjectPath, std::unique_ptr<FabricAdapter>> |
| 238 | fabricAdapter; |
Archana Kakani | b40f4f8 | 2024-06-06 01:04:38 -0500 | [diff] [blame] | 239 | std::unordered_map<ObjectPath, std::unique_ptr<Cable>> cable; |
Kamalkumar Patel | 2ed986c | 2024-05-08 02:20:47 -0500 | [diff] [blame] | 240 | std::unordered_map<ObjectPath, std::unique_ptr<Motherboard>> motherboard; |
Archana Kakani | 413f51e | 2025-02-03 04:14:36 -0600 | [diff] [blame] | 241 | std::unordered_map<ObjectPath, std::unique_ptr<Fan>> fan; |
Archana Kakani | 17b1e8a | 2025-02-04 03:50:24 -0600 | [diff] [blame] | 242 | std::unordered_map<ObjectPath, std::unique_ptr<Connector>> connector; |
Archana Kakani | 765cf03 | 2025-02-04 06:24:14 -0600 | [diff] [blame] | 243 | std::unordered_map<ObjectPath, std::unique_ptr<Panel>> panel; |
Archana Kakani | 2832f2c | 2025-02-04 22:29:30 -0600 | [diff] [blame] | 244 | std::unordered_map<ObjectPath, std::unique_ptr<VRM>> vrm; |
George Liu | 682ee18 | 2020-12-25 15:24:33 +0800 | [diff] [blame] | 245 | }; |
| 246 | |
| 247 | } // namespace dbus |
| 248 | } // namespace pldm |