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