blob: 2d4ac6bee2bd36887a8c66bef0669c4006ad0ae3 [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 Kakani413f51e2025-02-03 04:14:36 -060010#include "fan.hpp"
Kamalkumar Patel2ed986c2024-05-08 02:20:47 -050011#include "motherboard.hpp"
Archana Kakani733b39d2024-06-05 21:05:20 -050012#include "pcie_device.hpp"
Archana Kakanibf1fd272024-06-05 13:25:53 -050013#include "pcie_slot.hpp"
Archana Kakani24e9a9b2025-02-04 00:27:25 -060014#include "power_supply.hpp"
George Liu682ee182020-12-25 15:24:33 +080015
16#include <sdbusplus/server.hpp>
17#include <xyz/openbmc_project/Inventory/Decorator/LocationCode/server.hpp>
18
19#include <memory>
20#include <optional>
21#include <string>
22#include <unordered_map>
23
24namespace pldm
25{
26namespace dbus
27{
28using ObjectPath = std::string;
29
Patrick Williams705fa982023-09-27 02:32:20 -050030using LocationIntf =
31 sdbusplus::server::object_t<sdbusplus::xyz::openbmc_project::Inventory::
32 Decorator::server::LocationCode>;
George Liu682ee182020-12-25 15:24:33 +080033
34/** @class CustomDBus
35 * @brief This is a custom D-Bus object, used to add D-Bus interface and update
36 * the corresponding properties value.
37 */
38class CustomDBus
39{
40 private:
41 CustomDBus() {}
42
43 public:
44 CustomDBus(const CustomDBus&) = delete;
45 CustomDBus(CustomDBus&&) = delete;
46 CustomDBus& operator=(const CustomDBus&) = delete;
47 CustomDBus& operator=(CustomDBus&&) = delete;
48 ~CustomDBus() = default;
49
50 static CustomDBus& getCustomDBus()
51 {
52 static CustomDBus customDBus;
53 return customDBus;
54 }
55
56 public:
57 /** @brief Set the LocationCode property
58 *
59 * @param[in] path - The object path
60 *
61 * @param[in] value - The value of the LocationCode property
62 */
63 void setLocationCode(const std::string& path, std::string value);
64
65 /** @brief Get the LocationCode property
66 *
Kamalkumar Patel56da5742024-05-23 04:53:07 -050067 * @param[in] path - The object path
George Liu682ee182020-12-25 15:24:33 +080068 *
69 * @return std::optional<std::string> - The value of the LocationCode
70 * property
71 */
72 std::optional<std::string> getLocationCode(const std::string& path) const;
Kamalkumar Patel56da5742024-05-23 04:53:07 -050073 /** @brief Implement CpuCore Interface
74 *
75 * @param[in] path - The object path
76 *
77 */
78 void implementCpuCoreInterface(const std::string& path);
79 /** @brief Set the microcode property
80 *
81 * @param[in] path - The object path
82 *
83 * @param[in] value - microcode value
84 */
85 void setMicroCode(const std::string& path, uint32_t value);
86
87 /** @brief Get the microcode property
88 *
89 * @param[in] path - The object path
90 *
91 * @return std::optional<uint32_t> - The value of the microcode value
92 */
93 std::optional<uint32_t> getMicroCode(const std::string& path) const;
George Liu682ee182020-12-25 15:24:33 +080094
Archana Kakanibf1fd272024-06-05 13:25:53 -050095 /** @brief Implement PCIeSlot Interface
96 *
97 * @param[in] path - the object path
98 */
99 void implementPCIeSlotInterface(const std::string& path);
100
101 /** @brief Set the slot type
102 *
103 * @param[in] path - the object path
104 * @param[in] slot type - Slot type
105 */
106 void setSlotType(const std::string& path, const std::string& slotType);
107
Archana Kakani733b39d2024-06-05 21:05:20 -0500108 /** @brief Implement PCIe Device Interface
109 *
110 * @param[in] path - the object path
111 */
112 void implementPCIeDeviceInterface(const std::string& path);
113
114 /** @brief Set PCIe Device Lanes in use property
115 *
116 * @param[in] path - the object path
117 * @param[in] lanesInUse - Lanes in use
118 * @param[in] value - Generation in use
119 */
120 void setPCIeDeviceProps(const std::string& path, size_t lanesInUse,
121 const std::string& value);
122
Archana Kakanib40f4f82024-06-06 01:04:38 -0500123 /** @brief Implement PCIe Cable Interface
124 *
125 * @param[in] path - the object path
126 */
127 void implementCableInterface(const std::string& path);
128
129 /** @brief set cable attributes
130 *
131 * @param[in] path - the object path
132 * @param[in] length - length of the wire
133 * @param[in] cableDescription - cable details
134 */
135 void setCableAttributes(const std::string& path, double length,
136 const std::string& cableDescription);
Kamalkumar Patel2ed986c2024-05-08 02:20:47 -0500137 /** @brief Implement interface for motherboard property
138 *
139 * @param[in] path - The object path
140 *
141 */
142 void implementMotherboardInterface(const std::string& path);
Archana Kakanib40f4f82024-06-06 01:04:38 -0500143
Archana Kakani413f51e2025-02-03 04:14:36 -0600144 /** @brief Implement Fan Interface
145 *
146 * @param[in] path - The object path
147 *
148 */
149 void implementFanInterface(const std::string& path);
150
Archana Kakanidb65c3b2025-02-03 05:27:28 -0600151 /** @brief Implement Chassis Interface
152 * @param[in] path - the object path
153 */
154 void implementChassisInterface(const std::string& path);
155
Archana Kakani24e9a9b2025-02-04 00:27:25 -0600156 /** @brief Implement PowerSupply Interface
157 *
158 * @param[in] path - The object path
159 *
160 */
161 void implementPowerSupplyInterface(const std::string& path);
162
Archana Kakani17b1e8a2025-02-04 03:50:24 -0600163 /** @brief Implement Connector Interface
164 *
165 * @param[in] path - The object path
166 *
167 */
168 void implementConnecterInterface(const std::string& path);
169
Archana Kakani1634a6e2025-02-04 01:12:29 -0600170 /** @brief Implement Asset Interface
171 *
172 * @param[in] path - The object path
173 *
174 */
175 void implementAssetInterface(const std::string& path);
176
Archana Kakanif9355372025-02-04 03:13:24 -0600177 /** @brief Set the availability state property
178 *
179 * @param[in] path - The object path
180 *
181 * @param[in] state - Availability state
182 */
183 void setAvailabilityState(const std::string& path, const bool& state);
184
George Liu682ee182020-12-25 15:24:33 +0800185 private:
Archana Kakani1634a6e2025-02-04 01:12:29 -0600186 std::unordered_map<ObjectPath, std::unique_ptr<Asset>> asset;
Archana Kakanif9355372025-02-04 03:13:24 -0600187 std::unordered_map<ObjectPath, std::unique_ptr<Availability>>
188 availabilityState;
George Liu682ee182020-12-25 15:24:33 +0800189 std::unordered_map<ObjectPath, std::unique_ptr<LocationIntf>> location;
Kamalkumar Patel56da5742024-05-23 04:53:07 -0500190 std::unordered_map<ObjectPath, std::unique_ptr<CPUCore>> cpuCore;
Archana Kakanidb65c3b2025-02-03 05:27:28 -0600191 std::unordered_map<ObjectPath, std::unique_ptr<ItemChassis>> chassis;
Archana Kakani733b39d2024-06-05 21:05:20 -0500192 std::unordered_map<ObjectPath, std::unique_ptr<PCIeDevice>> pcieDevice;
Archana Kakanibf1fd272024-06-05 13:25:53 -0500193 std::unordered_map<ObjectPath, std::unique_ptr<PCIeSlot>> pcieSlot;
Archana Kakani24e9a9b2025-02-04 00:27:25 -0600194 std::unordered_map<ObjectPath, std::unique_ptr<PowerSupply>> powersupply;
Archana Kakanib40f4f82024-06-06 01:04:38 -0500195 std::unordered_map<ObjectPath, std::unique_ptr<Cable>> cable;
Kamalkumar Patel2ed986c2024-05-08 02:20:47 -0500196 std::unordered_map<ObjectPath, std::unique_ptr<Motherboard>> motherboard;
Archana Kakani413f51e2025-02-03 04:14:36 -0600197 std::unordered_map<ObjectPath, std::unique_ptr<Fan>> fan;
Archana Kakani17b1e8a2025-02-04 03:50:24 -0600198 std::unordered_map<ObjectPath, std::unique_ptr<Connector>> connector;
George Liu682ee182020-12-25 15:24:33 +0800199};
200
201} // namespace dbus
202} // namespace pldm