blob: e83c955c57b54cfac01e31d14b3217f9b422cf4c [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 Kakanid432b482025-02-04 22:52:28 -06005#include "board.hpp"
Archana Kakanib40f4f82024-06-06 01:04:38 -05006#include "cable.hpp"
Archana Kakanidb65c3b2025-02-03 05:27:28 -06007#include "chassis.hpp"
George Liu682ee182020-12-25 15:24:33 +08008#include "common/utils.hpp"
Archana Kakani17b1e8a2025-02-04 03:50:24 -06009#include "connector.hpp"
Kamalkumar Patel56da5742024-05-23 04:53:07 -050010#include "cpu_core.hpp"
Archana Kakani42876b62025-02-04 04:22:29 -060011#include "fabric_adapter.hpp"
Archana Kakani413f51e2025-02-03 04:14:36 -060012#include "fan.hpp"
Archana Kakanic3664472025-02-04 05:36:37 -060013#include "inventory_item.hpp"
Kamalkumar Patel2ed986c2024-05-08 02:20:47 -050014#include "motherboard.hpp"
Archana Kakani765cf032025-02-04 06:24:14 -060015#include "panel.hpp"
Archana Kakani733b39d2024-06-05 21:05:20 -050016#include "pcie_device.hpp"
Archana Kakanibf1fd272024-06-05 13:25:53 -050017#include "pcie_slot.hpp"
Archana Kakani24e9a9b2025-02-04 00:27:25 -060018#include "power_supply.hpp"
Archana Kakani2832f2c2025-02-04 22:29:30 -060019#include "vrm.hpp"
George Liu682ee182020-12-25 15:24:33 +080020
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
29namespace pldm
30{
31namespace dbus
32{
33using ObjectPath = std::string;
34
Patrick Williams705fa982023-09-27 02:32:20 -050035using LocationIntf =
36 sdbusplus::server::object_t<sdbusplus::xyz::openbmc_project::Inventory::
37 Decorator::server::LocationCode>;
George Liu682ee182020-12-25 15:24:33 +080038
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 */
43class 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 Patel56da5742024-05-23 04:53:07 -050072 * @param[in] path - The object path
George Liu682ee182020-12-25 15:24:33 +080073 *
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 Patel56da5742024-05-23 04:53:07 -050078 /** @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 Liu682ee182020-12-25 15:24:33 +080099
Archana Kakanibf1fd272024-06-05 13:25:53 -0500100 /** @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 Kakani733b39d2024-06-05 21:05:20 -0500113 /** @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 Kakanib40f4f82024-06-06 01:04:38 -0500128 /** @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 Patel2ed986c2024-05-08 02:20:47 -0500142 /** @brief Implement interface for motherboard property
143 *
144 * @param[in] path - The object path
145 *
146 */
147 void implementMotherboardInterface(const std::string& path);
Archana Kakanib40f4f82024-06-06 01:04:38 -0500148
Archana Kakani413f51e2025-02-03 04:14:36 -0600149 /** @brief Implement Fan Interface
150 *
151 * @param[in] path - The object path
152 *
153 */
154 void implementFanInterface(const std::string& path);
155
Archana Kakanidb65c3b2025-02-03 05:27:28 -0600156 /** @brief Implement Chassis Interface
157 * @param[in] path - the object path
158 */
159 void implementChassisInterface(const std::string& path);
160
Archana Kakani24e9a9b2025-02-04 00:27:25 -0600161 /** @brief Implement PowerSupply Interface
162 *
163 * @param[in] path - The object path
164 *
165 */
166 void implementPowerSupplyInterface(const std::string& path);
167
Archana Kakani17b1e8a2025-02-04 03:50:24 -0600168 /** @brief Implement Connector Interface
169 *
170 * @param[in] path - The object path
171 *
172 */
173 void implementConnecterInterface(const std::string& path);
174
Archana Kakani42876b62025-02-04 04:22:29 -0600175 /** @brief Implement Fabric Adapter Interface
176 *
177 * @param[in] path - The object path
178 *
179 */
180 void implementFabricAdapter(const std::string& path);
181
Archana Kakanid432b482025-02-04 22:52:28 -0600182 /** @brief Implement Board Interface
183 *
184 * @param[in] path - The object path
185 *
186 */
187 void implementBoard(const std::string& path);
188
Archana Kakani1634a6e2025-02-04 01:12:29 -0600189 /** @brief Implement Asset Interface
190 *
191 * @param[in] path - The object path
192 *
193 */
194 void implementAssetInterface(const std::string& path);
195
Archana Kakanif9355372025-02-04 03:13:24 -0600196 /** @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 Kakanic3664472025-02-04 05:36:37 -0600204 /** @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 Kakani765cf032025-02-04 06:24:14 -0600210 /** @brief Implement Panel Interface
211 *
212 * @param[in] path - The object path
213 *
214 */
215 void implementPanelInterface(const std::string& path);
216
Archana Kakani2832f2c2025-02-04 22:29:30 -0600217 /** @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 Liu682ee182020-12-25 15:24:33 +0800224 private:
Archana Kakani1634a6e2025-02-04 01:12:29 -0600225 std::unordered_map<ObjectPath, std::unique_ptr<Asset>> asset;
Archana Kakanif9355372025-02-04 03:13:24 -0600226 std::unordered_map<ObjectPath, std::unique_ptr<Availability>>
227 availabilityState;
George Liu682ee182020-12-25 15:24:33 +0800228 std::unordered_map<ObjectPath, std::unique_ptr<LocationIntf>> location;
Archana Kakanic3664472025-02-04 05:36:37 -0600229 std::unordered_map<ObjectPath, std::unique_ptr<InventoryItem>>
230 presentStatus;
Kamalkumar Patel56da5742024-05-23 04:53:07 -0500231 std::unordered_map<ObjectPath, std::unique_ptr<CPUCore>> cpuCore;
Archana Kakanidb65c3b2025-02-03 05:27:28 -0600232 std::unordered_map<ObjectPath, std::unique_ptr<ItemChassis>> chassis;
Archana Kakani733b39d2024-06-05 21:05:20 -0500233 std::unordered_map<ObjectPath, std::unique_ptr<PCIeDevice>> pcieDevice;
Archana Kakanibf1fd272024-06-05 13:25:53 -0500234 std::unordered_map<ObjectPath, std::unique_ptr<PCIeSlot>> pcieSlot;
Archana Kakani24e9a9b2025-02-04 00:27:25 -0600235 std::unordered_map<ObjectPath, std::unique_ptr<PowerSupply>> powersupply;
Archana Kakanid432b482025-02-04 22:52:28 -0600236 std::unordered_map<ObjectPath, std::unique_ptr<Board>> board;
Archana Kakani42876b62025-02-04 04:22:29 -0600237 std::unordered_map<ObjectPath, std::unique_ptr<FabricAdapter>>
238 fabricAdapter;
Archana Kakanib40f4f82024-06-06 01:04:38 -0500239 std::unordered_map<ObjectPath, std::unique_ptr<Cable>> cable;
Kamalkumar Patel2ed986c2024-05-08 02:20:47 -0500240 std::unordered_map<ObjectPath, std::unique_ptr<Motherboard>> motherboard;
Archana Kakani413f51e2025-02-03 04:14:36 -0600241 std::unordered_map<ObjectPath, std::unique_ptr<Fan>> fan;
Archana Kakani17b1e8a2025-02-04 03:50:24 -0600242 std::unordered_map<ObjectPath, std::unique_ptr<Connector>> connector;
Archana Kakani765cf032025-02-04 06:24:14 -0600243 std::unordered_map<ObjectPath, std::unique_ptr<Panel>> panel;
Archana Kakani2832f2c2025-02-04 22:29:30 -0600244 std::unordered_map<ObjectPath, std::unique_ptr<VRM>> vrm;
George Liu682ee182020-12-25 15:24:33 +0800245};
246
247} // namespace dbus
248} // namespace pldm