blob: e2924629d38ffcdb6ee338c9ed113da2357d2eb4 [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"
Kamalkumar Patel2ed986c2024-05-08 02:20:47 -050012#include "motherboard.hpp"
Archana Kakani733b39d2024-06-05 21:05:20 -050013#include "pcie_device.hpp"
Archana Kakanibf1fd272024-06-05 13:25:53 -050014#include "pcie_slot.hpp"
Archana Kakani24e9a9b2025-02-04 00:27:25 -060015#include "power_supply.hpp"
George Liu682ee182020-12-25 15:24:33 +080016
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
25namespace pldm
26{
27namespace dbus
28{
29using ObjectPath = std::string;
30
Patrick Williams705fa982023-09-27 02:32:20 -050031using LocationIntf =
32 sdbusplus::server::object_t<sdbusplus::xyz::openbmc_project::Inventory::
33 Decorator::server::LocationCode>;
George Liu682ee182020-12-25 15:24:33 +080034
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 */
39class 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 Patel56da5742024-05-23 04:53:07 -050068 * @param[in] path - The object path
George Liu682ee182020-12-25 15:24:33 +080069 *
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 Patel56da5742024-05-23 04:53:07 -050074 /** @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 Liu682ee182020-12-25 15:24:33 +080095
Archana Kakanibf1fd272024-06-05 13:25:53 -050096 /** @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 Kakani733b39d2024-06-05 21:05:20 -0500109 /** @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 Kakanib40f4f82024-06-06 01:04:38 -0500124 /** @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 Patel2ed986c2024-05-08 02:20:47 -0500138 /** @brief Implement interface for motherboard property
139 *
140 * @param[in] path - The object path
141 *
142 */
143 void implementMotherboardInterface(const std::string& path);
Archana Kakanib40f4f82024-06-06 01:04:38 -0500144
Archana Kakani413f51e2025-02-03 04:14:36 -0600145 /** @brief Implement Fan Interface
146 *
147 * @param[in] path - The object path
148 *
149 */
150 void implementFanInterface(const std::string& path);
151
Archana Kakanidb65c3b2025-02-03 05:27:28 -0600152 /** @brief Implement Chassis Interface
153 * @param[in] path - the object path
154 */
155 void implementChassisInterface(const std::string& path);
156
Archana Kakani24e9a9b2025-02-04 00:27:25 -0600157 /** @brief Implement PowerSupply Interface
158 *
159 * @param[in] path - The object path
160 *
161 */
162 void implementPowerSupplyInterface(const std::string& path);
163
Archana Kakani17b1e8a2025-02-04 03:50:24 -0600164 /** @brief Implement Connector Interface
165 *
166 * @param[in] path - The object path
167 *
168 */
169 void implementConnecterInterface(const std::string& path);
170
Archana Kakani42876b62025-02-04 04:22:29 -0600171 /** @brief Implement Fabric Adapter Interface
172 *
173 * @param[in] path - The object path
174 *
175 */
176 void implementFabricAdapter(const std::string& path);
177
Archana Kakani1634a6e2025-02-04 01:12:29 -0600178 /** @brief Implement Asset Interface
179 *
180 * @param[in] path - The object path
181 *
182 */
183 void implementAssetInterface(const std::string& path);
184
Archana Kakanif9355372025-02-04 03:13:24 -0600185 /** @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 Liu682ee182020-12-25 15:24:33 +0800193 private:
Archana Kakani1634a6e2025-02-04 01:12:29 -0600194 std::unordered_map<ObjectPath, std::unique_ptr<Asset>> asset;
Archana Kakanif9355372025-02-04 03:13:24 -0600195 std::unordered_map<ObjectPath, std::unique_ptr<Availability>>
196 availabilityState;
George Liu682ee182020-12-25 15:24:33 +0800197 std::unordered_map<ObjectPath, std::unique_ptr<LocationIntf>> location;
Kamalkumar Patel56da5742024-05-23 04:53:07 -0500198 std::unordered_map<ObjectPath, std::unique_ptr<CPUCore>> cpuCore;
Archana Kakanidb65c3b2025-02-03 05:27:28 -0600199 std::unordered_map<ObjectPath, std::unique_ptr<ItemChassis>> chassis;
Archana Kakani733b39d2024-06-05 21:05:20 -0500200 std::unordered_map<ObjectPath, std::unique_ptr<PCIeDevice>> pcieDevice;
Archana Kakanibf1fd272024-06-05 13:25:53 -0500201 std::unordered_map<ObjectPath, std::unique_ptr<PCIeSlot>> pcieSlot;
Archana Kakani24e9a9b2025-02-04 00:27:25 -0600202 std::unordered_map<ObjectPath, std::unique_ptr<PowerSupply>> powersupply;
Archana Kakani42876b62025-02-04 04:22:29 -0600203 std::unordered_map<ObjectPath, std::unique_ptr<FabricAdapter>>
204 fabricAdapter;
Archana Kakanib40f4f82024-06-06 01:04:38 -0500205 std::unordered_map<ObjectPath, std::unique_ptr<Cable>> cable;
Kamalkumar Patel2ed986c2024-05-08 02:20:47 -0500206 std::unordered_map<ObjectPath, std::unique_ptr<Motherboard>> motherboard;
Archana Kakani413f51e2025-02-03 04:14:36 -0600207 std::unordered_map<ObjectPath, std::unique_ptr<Fan>> fan;
Archana Kakani17b1e8a2025-02-04 03:50:24 -0600208 std::unordered_map<ObjectPath, std::unique_ptr<Connector>> connector;
George Liu682ee182020-12-25 15:24:33 +0800209};
210
211} // namespace dbus
212} // namespace pldm