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