blob: e099712c7ba1a6d031122526cf83e545ce257078 [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 Kakani733b39d2024-06-05 21:05:20 -050014#include "pcie_device.hpp"
Archana Kakanibf1fd272024-06-05 13:25:53 -050015#include "pcie_slot.hpp"
Archana Kakani24e9a9b2025-02-04 00:27:25 -060016#include "power_supply.hpp"
George Liu682ee182020-12-25 15:24:33 +080017
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
26namespace pldm
27{
28namespace dbus
29{
30using ObjectPath = std::string;
31
Patrick Williams705fa982023-09-27 02:32:20 -050032using LocationIntf =
33 sdbusplus::server::object_t<sdbusplus::xyz::openbmc_project::Inventory::
34 Decorator::server::LocationCode>;
George Liu682ee182020-12-25 15:24:33 +080035
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 */
40class 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 Patel56da5742024-05-23 04:53:07 -050069 * @param[in] path - The object path
George Liu682ee182020-12-25 15:24:33 +080070 *
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 Patel56da5742024-05-23 04:53:07 -050075 /** @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 Liu682ee182020-12-25 15:24:33 +080096
Archana Kakanibf1fd272024-06-05 13:25:53 -050097 /** @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 Kakani733b39d2024-06-05 21:05:20 -0500110 /** @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 Kakanib40f4f82024-06-06 01:04:38 -0500125 /** @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 Patel2ed986c2024-05-08 02:20:47 -0500139 /** @brief Implement interface for motherboard property
140 *
141 * @param[in] path - The object path
142 *
143 */
144 void implementMotherboardInterface(const std::string& path);
Archana Kakanib40f4f82024-06-06 01:04:38 -0500145
Archana Kakani413f51e2025-02-03 04:14:36 -0600146 /** @brief Implement Fan Interface
147 *
148 * @param[in] path - The object path
149 *
150 */
151 void implementFanInterface(const std::string& path);
152
Archana Kakanidb65c3b2025-02-03 05:27:28 -0600153 /** @brief Implement Chassis Interface
154 * @param[in] path - the object path
155 */
156 void implementChassisInterface(const std::string& path);
157
Archana Kakani24e9a9b2025-02-04 00:27:25 -0600158 /** @brief Implement PowerSupply Interface
159 *
160 * @param[in] path - The object path
161 *
162 */
163 void implementPowerSupplyInterface(const std::string& path);
164
Archana Kakani17b1e8a2025-02-04 03:50:24 -0600165 /** @brief Implement Connector Interface
166 *
167 * @param[in] path - The object path
168 *
169 */
170 void implementConnecterInterface(const std::string& path);
171
Archana Kakani42876b62025-02-04 04:22:29 -0600172 /** @brief Implement Fabric Adapter Interface
173 *
174 * @param[in] path - The object path
175 *
176 */
177 void implementFabricAdapter(const std::string& path);
178
Archana Kakani1634a6e2025-02-04 01:12:29 -0600179 /** @brief Implement Asset Interface
180 *
181 * @param[in] path - The object path
182 *
183 */
184 void implementAssetInterface(const std::string& path);
185
Archana Kakanif9355372025-02-04 03:13:24 -0600186 /** @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 Kakanic3664472025-02-04 05:36:37 -0600194 /** @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 Liu682ee182020-12-25 15:24:33 +0800200 private:
Archana Kakani1634a6e2025-02-04 01:12:29 -0600201 std::unordered_map<ObjectPath, std::unique_ptr<Asset>> asset;
Archana Kakanif9355372025-02-04 03:13:24 -0600202 std::unordered_map<ObjectPath, std::unique_ptr<Availability>>
203 availabilityState;
George Liu682ee182020-12-25 15:24:33 +0800204 std::unordered_map<ObjectPath, std::unique_ptr<LocationIntf>> location;
Archana Kakanic3664472025-02-04 05:36:37 -0600205 std::unordered_map<ObjectPath, std::unique_ptr<InventoryItem>>
206 presentStatus;
Kamalkumar Patel56da5742024-05-23 04:53:07 -0500207 std::unordered_map<ObjectPath, std::unique_ptr<CPUCore>> cpuCore;
Archana Kakanidb65c3b2025-02-03 05:27:28 -0600208 std::unordered_map<ObjectPath, std::unique_ptr<ItemChassis>> chassis;
Archana Kakani733b39d2024-06-05 21:05:20 -0500209 std::unordered_map<ObjectPath, std::unique_ptr<PCIeDevice>> pcieDevice;
Archana Kakanibf1fd272024-06-05 13:25:53 -0500210 std::unordered_map<ObjectPath, std::unique_ptr<PCIeSlot>> pcieSlot;
Archana Kakani24e9a9b2025-02-04 00:27:25 -0600211 std::unordered_map<ObjectPath, std::unique_ptr<PowerSupply>> powersupply;
Archana Kakani42876b62025-02-04 04:22:29 -0600212 std::unordered_map<ObjectPath, std::unique_ptr<FabricAdapter>>
213 fabricAdapter;
Archana Kakanib40f4f82024-06-06 01:04:38 -0500214 std::unordered_map<ObjectPath, std::unique_ptr<Cable>> cable;
Kamalkumar Patel2ed986c2024-05-08 02:20:47 -0500215 std::unordered_map<ObjectPath, std::unique_ptr<Motherboard>> motherboard;
Archana Kakani413f51e2025-02-03 04:14:36 -0600216 std::unordered_map<ObjectPath, std::unique_ptr<Fan>> fan;
Archana Kakani17b1e8a2025-02-04 03:50:24 -0600217 std::unordered_map<ObjectPath, std::unique_ptr<Connector>> connector;
George Liu682ee182020-12-25 15:24:33 +0800218};
219
220} // namespace dbus
221} // namespace pldm