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