blob: d8d937588be8b35068ff6e1525114020e99e1de0 [file] [log] [blame]
George Liu682ee182020-12-25 15:24:33 +08001#pragma once
2
Archana Kakani1634a6e2025-02-04 01:12:29 -06003#include "asset.hpp"
Archana Kakanif9355372025-02-04 03:13:24 -06004#include "availability.hpp"
Archana Kakanib40f4f82024-06-06 01:04:38 -05005#include "cable.hpp"
Archana Kakanidb65c3b2025-02-03 05:27:28 -06006#include "chassis.hpp"
George Liu682ee182020-12-25 15:24:33 +08007#include "common/utils.hpp"
Archana Kakani17b1e8a2025-02-04 03:50:24 -06008#include "connector.hpp"
Kamalkumar Patel56da5742024-05-23 04:53:07 -05009#include "cpu_core.hpp"
Archana Kakani42876b62025-02-04 04:22:29 -060010#include "fabric_adapter.hpp"
Archana Kakani413f51e2025-02-03 04:14:36 -060011#include "fan.hpp"
Archana Kakanic3664472025-02-04 05:36:37 -060012#include "inventory_item.hpp"
Kamalkumar Patel2ed986c2024-05-08 02:20:47 -050013#include "motherboard.hpp"
Archana Kakani765cf032025-02-04 06:24:14 -060014#include "panel.hpp"
Archana Kakani733b39d2024-06-05 21:05:20 -050015#include "pcie_device.hpp"
Archana Kakanibf1fd272024-06-05 13:25:53 -050016#include "pcie_slot.hpp"
Archana Kakani24e9a9b2025-02-04 00:27:25 -060017#include "power_supply.hpp"
Archana Kakani2832f2c2025-02-04 22:29:30 -060018#include "vrm.hpp"
George Liu682ee182020-12-25 15:24:33 +080019
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
28namespace pldm
29{
30namespace dbus
31{
32using ObjectPath = std::string;
33
Patrick Williams705fa982023-09-27 02:32:20 -050034using LocationIntf =
35 sdbusplus::server::object_t<sdbusplus::xyz::openbmc_project::Inventory::
36 Decorator::server::LocationCode>;
George Liu682ee182020-12-25 15:24:33 +080037
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 */
42class 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 Patel56da5742024-05-23 04:53:07 -050071 * @param[in] path - The object path
George Liu682ee182020-12-25 15:24:33 +080072 *
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 Patel56da5742024-05-23 04:53:07 -050077 /** @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 Liu682ee182020-12-25 15:24:33 +080098
Archana Kakanibf1fd272024-06-05 13:25:53 -050099 /** @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 Kakani733b39d2024-06-05 21:05:20 -0500112 /** @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 Kakanib40f4f82024-06-06 01:04:38 -0500127 /** @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 Patel2ed986c2024-05-08 02:20:47 -0500141 /** @brief Implement interface for motherboard property
142 *
143 * @param[in] path - The object path
144 *
145 */
146 void implementMotherboardInterface(const std::string& path);
Archana Kakanib40f4f82024-06-06 01:04:38 -0500147
Archana Kakani413f51e2025-02-03 04:14:36 -0600148 /** @brief Implement Fan Interface
149 *
150 * @param[in] path - The object path
151 *
152 */
153 void implementFanInterface(const std::string& path);
154
Archana Kakanidb65c3b2025-02-03 05:27:28 -0600155 /** @brief Implement Chassis Interface
156 * @param[in] path - the object path
157 */
158 void implementChassisInterface(const std::string& path);
159
Archana Kakani24e9a9b2025-02-04 00:27:25 -0600160 /** @brief Implement PowerSupply Interface
161 *
162 * @param[in] path - The object path
163 *
164 */
165 void implementPowerSupplyInterface(const std::string& path);
166
Archana Kakani17b1e8a2025-02-04 03:50:24 -0600167 /** @brief Implement Connector Interface
168 *
169 * @param[in] path - The object path
170 *
171 */
172 void implementConnecterInterface(const std::string& path);
173
Archana Kakani42876b62025-02-04 04:22:29 -0600174 /** @brief Implement Fabric Adapter Interface
175 *
176 * @param[in] path - The object path
177 *
178 */
179 void implementFabricAdapter(const std::string& path);
180
Archana Kakani1634a6e2025-02-04 01:12:29 -0600181 /** @brief Implement Asset Interface
182 *
183 * @param[in] path - The object path
184 *
185 */
186 void implementAssetInterface(const std::string& path);
187
Archana Kakanif9355372025-02-04 03:13:24 -0600188 /** @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 Kakanic3664472025-02-04 05:36:37 -0600196 /** @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 Kakani765cf032025-02-04 06:24:14 -0600202 /** @brief Implement Panel Interface
203 *
204 * @param[in] path - The object path
205 *
206 */
207 void implementPanelInterface(const std::string& path);
208
Archana Kakani2832f2c2025-02-04 22:29:30 -0600209 /** @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 Liu682ee182020-12-25 15:24:33 +0800216 private:
Archana Kakani1634a6e2025-02-04 01:12:29 -0600217 std::unordered_map<ObjectPath, std::unique_ptr<Asset>> asset;
Archana Kakanif9355372025-02-04 03:13:24 -0600218 std::unordered_map<ObjectPath, std::unique_ptr<Availability>>
219 availabilityState;
George Liu682ee182020-12-25 15:24:33 +0800220 std::unordered_map<ObjectPath, std::unique_ptr<LocationIntf>> location;
Archana Kakanic3664472025-02-04 05:36:37 -0600221 std::unordered_map<ObjectPath, std::unique_ptr<InventoryItem>>
222 presentStatus;
Kamalkumar Patel56da5742024-05-23 04:53:07 -0500223 std::unordered_map<ObjectPath, std::unique_ptr<CPUCore>> cpuCore;
Archana Kakanidb65c3b2025-02-03 05:27:28 -0600224 std::unordered_map<ObjectPath, std::unique_ptr<ItemChassis>> chassis;
Archana Kakani733b39d2024-06-05 21:05:20 -0500225 std::unordered_map<ObjectPath, std::unique_ptr<PCIeDevice>> pcieDevice;
Archana Kakanibf1fd272024-06-05 13:25:53 -0500226 std::unordered_map<ObjectPath, std::unique_ptr<PCIeSlot>> pcieSlot;
Archana Kakani24e9a9b2025-02-04 00:27:25 -0600227 std::unordered_map<ObjectPath, std::unique_ptr<PowerSupply>> powersupply;
Archana Kakani42876b62025-02-04 04:22:29 -0600228 std::unordered_map<ObjectPath, std::unique_ptr<FabricAdapter>>
229 fabricAdapter;
Archana Kakanib40f4f82024-06-06 01:04:38 -0500230 std::unordered_map<ObjectPath, std::unique_ptr<Cable>> cable;
Kamalkumar Patel2ed986c2024-05-08 02:20:47 -0500231 std::unordered_map<ObjectPath, std::unique_ptr<Motherboard>> motherboard;
Archana Kakani413f51e2025-02-03 04:14:36 -0600232 std::unordered_map<ObjectPath, std::unique_ptr<Fan>> fan;
Archana Kakani17b1e8a2025-02-04 03:50:24 -0600233 std::unordered_map<ObjectPath, std::unique_ptr<Connector>> connector;
Archana Kakani765cf032025-02-04 06:24:14 -0600234 std::unordered_map<ObjectPath, std::unique_ptr<Panel>> panel;
Archana Kakani2832f2c2025-02-04 22:29:30 -0600235 std::unordered_map<ObjectPath, std::unique_ptr<VRM>> vrm;
George Liu682ee182020-12-25 15:24:33 +0800236};
237
238} // namespace dbus
239} // namespace pldm