blob: d543e1f245a00464de4501b0fa308f021d072bfc [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"
George Liu682ee182020-12-25 15:24:33 +080018
19#include <sdbusplus/server.hpp>
20#include <xyz/openbmc_project/Inventory/Decorator/LocationCode/server.hpp>
21
22#include <memory>
23#include <optional>
24#include <string>
25#include <unordered_map>
26
27namespace pldm
28{
29namespace dbus
30{
31using ObjectPath = std::string;
32
Patrick Williams705fa982023-09-27 02:32:20 -050033using LocationIntf =
34 sdbusplus::server::object_t<sdbusplus::xyz::openbmc_project::Inventory::
35 Decorator::server::LocationCode>;
George Liu682ee182020-12-25 15:24:33 +080036
37/** @class CustomDBus
38 * @brief This is a custom D-Bus object, used to add D-Bus interface and update
39 * the corresponding properties value.
40 */
41class CustomDBus
42{
43 private:
44 CustomDBus() {}
45
46 public:
47 CustomDBus(const CustomDBus&) = delete;
48 CustomDBus(CustomDBus&&) = delete;
49 CustomDBus& operator=(const CustomDBus&) = delete;
50 CustomDBus& operator=(CustomDBus&&) = delete;
51 ~CustomDBus() = default;
52
53 static CustomDBus& getCustomDBus()
54 {
55 static CustomDBus customDBus;
56 return customDBus;
57 }
58
59 public:
60 /** @brief Set the LocationCode property
61 *
62 * @param[in] path - The object path
63 *
64 * @param[in] value - The value of the LocationCode property
65 */
66 void setLocationCode(const std::string& path, std::string value);
67
68 /** @brief Get the LocationCode property
69 *
Kamalkumar Patel56da5742024-05-23 04:53:07 -050070 * @param[in] path - The object path
George Liu682ee182020-12-25 15:24:33 +080071 *
72 * @return std::optional<std::string> - The value of the LocationCode
73 * property
74 */
75 std::optional<std::string> getLocationCode(const std::string& path) const;
Kamalkumar Patel56da5742024-05-23 04:53:07 -050076 /** @brief Implement CpuCore Interface
77 *
78 * @param[in] path - The object path
79 *
80 */
81 void implementCpuCoreInterface(const std::string& path);
82 /** @brief Set the microcode property
83 *
84 * @param[in] path - The object path
85 *
86 * @param[in] value - microcode value
87 */
88 void setMicroCode(const std::string& path, uint32_t value);
89
90 /** @brief Get the microcode property
91 *
92 * @param[in] path - The object path
93 *
94 * @return std::optional<uint32_t> - The value of the microcode value
95 */
96 std::optional<uint32_t> getMicroCode(const std::string& path) const;
George Liu682ee182020-12-25 15:24:33 +080097
Archana Kakanibf1fd272024-06-05 13:25:53 -050098 /** @brief Implement PCIeSlot Interface
99 *
100 * @param[in] path - the object path
101 */
102 void implementPCIeSlotInterface(const std::string& path);
103
104 /** @brief Set the slot type
105 *
106 * @param[in] path - the object path
107 * @param[in] slot type - Slot type
108 */
109 void setSlotType(const std::string& path, const std::string& slotType);
110
Archana Kakani733b39d2024-06-05 21:05:20 -0500111 /** @brief Implement PCIe Device Interface
112 *
113 * @param[in] path - the object path
114 */
115 void implementPCIeDeviceInterface(const std::string& path);
116
117 /** @brief Set PCIe Device Lanes in use property
118 *
119 * @param[in] path - the object path
120 * @param[in] lanesInUse - Lanes in use
121 * @param[in] value - Generation in use
122 */
123 void setPCIeDeviceProps(const std::string& path, size_t lanesInUse,
124 const std::string& value);
125
Archana Kakanib40f4f82024-06-06 01:04:38 -0500126 /** @brief Implement PCIe Cable Interface
127 *
128 * @param[in] path - the object path
129 */
130 void implementCableInterface(const std::string& path);
131
132 /** @brief set cable attributes
133 *
134 * @param[in] path - the object path
135 * @param[in] length - length of the wire
136 * @param[in] cableDescription - cable details
137 */
138 void setCableAttributes(const std::string& path, double length,
139 const std::string& cableDescription);
Kamalkumar Patel2ed986c2024-05-08 02:20:47 -0500140 /** @brief Implement interface for motherboard property
141 *
142 * @param[in] path - The object path
143 *
144 */
145 void implementMotherboardInterface(const std::string& path);
Archana Kakanib40f4f82024-06-06 01:04:38 -0500146
Archana Kakani413f51e2025-02-03 04:14:36 -0600147 /** @brief Implement Fan Interface
148 *
149 * @param[in] path - The object path
150 *
151 */
152 void implementFanInterface(const std::string& path);
153
Archana Kakanidb65c3b2025-02-03 05:27:28 -0600154 /** @brief Implement Chassis Interface
155 * @param[in] path - the object path
156 */
157 void implementChassisInterface(const std::string& path);
158
Archana Kakani24e9a9b2025-02-04 00:27:25 -0600159 /** @brief Implement PowerSupply Interface
160 *
161 * @param[in] path - The object path
162 *
163 */
164 void implementPowerSupplyInterface(const std::string& path);
165
Archana Kakani17b1e8a2025-02-04 03:50:24 -0600166 /** @brief Implement Connector Interface
167 *
168 * @param[in] path - The object path
169 *
170 */
171 void implementConnecterInterface(const std::string& path);
172
Archana Kakani42876b62025-02-04 04:22:29 -0600173 /** @brief Implement Fabric Adapter Interface
174 *
175 * @param[in] path - The object path
176 *
177 */
178 void implementFabricAdapter(const std::string& path);
179
Archana Kakani1634a6e2025-02-04 01:12:29 -0600180 /** @brief Implement Asset Interface
181 *
182 * @param[in] path - The object path
183 *
184 */
185 void implementAssetInterface(const std::string& path);
186
Archana Kakanif9355372025-02-04 03:13:24 -0600187 /** @brief Set the availability state property
188 *
189 * @param[in] path - The object path
190 *
191 * @param[in] state - Availability state
192 */
193 void setAvailabilityState(const std::string& path, const bool& state);
194
Archana Kakanic3664472025-02-04 05:36:37 -0600195 /** @brief Set the Inventory Item property
196 * @param[in] path - The object path
197 * @param[in] bool - the presence of fru
198 */
199 void updateItemPresentStatus(const std::string& path, bool isPresent);
200
Archana Kakani765cf032025-02-04 06:24:14 -0600201 /** @brief Implement Panel Interface
202 *
203 * @param[in] path - The object path
204 *
205 */
206 void implementPanelInterface(const std::string& path);
207
George Liu682ee182020-12-25 15:24:33 +0800208 private:
Archana Kakani1634a6e2025-02-04 01:12:29 -0600209 std::unordered_map<ObjectPath, std::unique_ptr<Asset>> asset;
Archana Kakanif9355372025-02-04 03:13:24 -0600210 std::unordered_map<ObjectPath, std::unique_ptr<Availability>>
211 availabilityState;
George Liu682ee182020-12-25 15:24:33 +0800212 std::unordered_map<ObjectPath, std::unique_ptr<LocationIntf>> location;
Archana Kakanic3664472025-02-04 05:36:37 -0600213 std::unordered_map<ObjectPath, std::unique_ptr<InventoryItem>>
214 presentStatus;
Kamalkumar Patel56da5742024-05-23 04:53:07 -0500215 std::unordered_map<ObjectPath, std::unique_ptr<CPUCore>> cpuCore;
Archana Kakanidb65c3b2025-02-03 05:27:28 -0600216 std::unordered_map<ObjectPath, std::unique_ptr<ItemChassis>> chassis;
Archana Kakani733b39d2024-06-05 21:05:20 -0500217 std::unordered_map<ObjectPath, std::unique_ptr<PCIeDevice>> pcieDevice;
Archana Kakanibf1fd272024-06-05 13:25:53 -0500218 std::unordered_map<ObjectPath, std::unique_ptr<PCIeSlot>> pcieSlot;
Archana Kakani24e9a9b2025-02-04 00:27:25 -0600219 std::unordered_map<ObjectPath, std::unique_ptr<PowerSupply>> powersupply;
Archana Kakani42876b62025-02-04 04:22:29 -0600220 std::unordered_map<ObjectPath, std::unique_ptr<FabricAdapter>>
221 fabricAdapter;
Archana Kakanib40f4f82024-06-06 01:04:38 -0500222 std::unordered_map<ObjectPath, std::unique_ptr<Cable>> cable;
Kamalkumar Patel2ed986c2024-05-08 02:20:47 -0500223 std::unordered_map<ObjectPath, std::unique_ptr<Motherboard>> motherboard;
Archana Kakani413f51e2025-02-03 04:14:36 -0600224 std::unordered_map<ObjectPath, std::unique_ptr<Fan>> fan;
Archana Kakani17b1e8a2025-02-04 03:50:24 -0600225 std::unordered_map<ObjectPath, std::unique_ptr<Connector>> connector;
Archana Kakani765cf032025-02-04 06:24:14 -0600226 std::unordered_map<ObjectPath, std::unique_ptr<Panel>> panel;
George Liu682ee182020-12-25 15:24:33 +0800227};
228
229} // namespace dbus
230} // namespace pldm