blob: 7988bd9c4ded37e38322163234dd650fe659fff9 [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 Kakanib40f4f82024-06-06 01:04:38 -05004#include "cable.hpp"
Archana Kakanidb65c3b2025-02-03 05:27:28 -06005#include "chassis.hpp"
George Liu682ee182020-12-25 15:24:33 +08006#include "common/utils.hpp"
Kamalkumar Patel56da5742024-05-23 04:53:07 -05007#include "cpu_core.hpp"
Archana Kakani413f51e2025-02-03 04:14:36 -06008#include "fan.hpp"
Kamalkumar Patel2ed986c2024-05-08 02:20:47 -05009#include "motherboard.hpp"
Archana Kakani733b39d2024-06-05 21:05:20 -050010#include "pcie_device.hpp"
Archana Kakanibf1fd272024-06-05 13:25:53 -050011#include "pcie_slot.hpp"
Archana Kakani24e9a9b2025-02-04 00:27:25 -060012#include "power_supply.hpp"
George Liu682ee182020-12-25 15:24:33 +080013
14#include <sdbusplus/server.hpp>
15#include <xyz/openbmc_project/Inventory/Decorator/LocationCode/server.hpp>
16
17#include <memory>
18#include <optional>
19#include <string>
20#include <unordered_map>
21
22namespace pldm
23{
24namespace dbus
25{
26using ObjectPath = std::string;
27
Patrick Williams705fa982023-09-27 02:32:20 -050028using LocationIntf =
29 sdbusplus::server::object_t<sdbusplus::xyz::openbmc_project::Inventory::
30 Decorator::server::LocationCode>;
George Liu682ee182020-12-25 15:24:33 +080031
32/** @class CustomDBus
33 * @brief This is a custom D-Bus object, used to add D-Bus interface and update
34 * the corresponding properties value.
35 */
36class CustomDBus
37{
38 private:
39 CustomDBus() {}
40
41 public:
42 CustomDBus(const CustomDBus&) = delete;
43 CustomDBus(CustomDBus&&) = delete;
44 CustomDBus& operator=(const CustomDBus&) = delete;
45 CustomDBus& operator=(CustomDBus&&) = delete;
46 ~CustomDBus() = default;
47
48 static CustomDBus& getCustomDBus()
49 {
50 static CustomDBus customDBus;
51 return customDBus;
52 }
53
54 public:
55 /** @brief Set the LocationCode property
56 *
57 * @param[in] path - The object path
58 *
59 * @param[in] value - The value of the LocationCode property
60 */
61 void setLocationCode(const std::string& path, std::string value);
62
63 /** @brief Get the LocationCode property
64 *
Kamalkumar Patel56da5742024-05-23 04:53:07 -050065 * @param[in] path - The object path
George Liu682ee182020-12-25 15:24:33 +080066 *
67 * @return std::optional<std::string> - The value of the LocationCode
68 * property
69 */
70 std::optional<std::string> getLocationCode(const std::string& path) const;
Kamalkumar Patel56da5742024-05-23 04:53:07 -050071 /** @brief Implement CpuCore Interface
72 *
73 * @param[in] path - The object path
74 *
75 */
76 void implementCpuCoreInterface(const std::string& path);
77 /** @brief Set the microcode property
78 *
79 * @param[in] path - The object path
80 *
81 * @param[in] value - microcode value
82 */
83 void setMicroCode(const std::string& path, uint32_t value);
84
85 /** @brief Get the microcode property
86 *
87 * @param[in] path - The object path
88 *
89 * @return std::optional<uint32_t> - The value of the microcode value
90 */
91 std::optional<uint32_t> getMicroCode(const std::string& path) const;
George Liu682ee182020-12-25 15:24:33 +080092
Archana Kakanibf1fd272024-06-05 13:25:53 -050093 /** @brief Implement PCIeSlot Interface
94 *
95 * @param[in] path - the object path
96 */
97 void implementPCIeSlotInterface(const std::string& path);
98
99 /** @brief Set the slot type
100 *
101 * @param[in] path - the object path
102 * @param[in] slot type - Slot type
103 */
104 void setSlotType(const std::string& path, const std::string& slotType);
105
Archana Kakani733b39d2024-06-05 21:05:20 -0500106 /** @brief Implement PCIe Device Interface
107 *
108 * @param[in] path - the object path
109 */
110 void implementPCIeDeviceInterface(const std::string& path);
111
112 /** @brief Set PCIe Device Lanes in use property
113 *
114 * @param[in] path - the object path
115 * @param[in] lanesInUse - Lanes in use
116 * @param[in] value - Generation in use
117 */
118 void setPCIeDeviceProps(const std::string& path, size_t lanesInUse,
119 const std::string& value);
120
Archana Kakanib40f4f82024-06-06 01:04:38 -0500121 /** @brief Implement PCIe Cable Interface
122 *
123 * @param[in] path - the object path
124 */
125 void implementCableInterface(const std::string& path);
126
127 /** @brief set cable attributes
128 *
129 * @param[in] path - the object path
130 * @param[in] length - length of the wire
131 * @param[in] cableDescription - cable details
132 */
133 void setCableAttributes(const std::string& path, double length,
134 const std::string& cableDescription);
Kamalkumar Patel2ed986c2024-05-08 02:20:47 -0500135 /** @brief Implement interface for motherboard property
136 *
137 * @param[in] path - The object path
138 *
139 */
140 void implementMotherboardInterface(const std::string& path);
Archana Kakanib40f4f82024-06-06 01:04:38 -0500141
Archana Kakani413f51e2025-02-03 04:14:36 -0600142 /** @brief Implement Fan Interface
143 *
144 * @param[in] path - The object path
145 *
146 */
147 void implementFanInterface(const std::string& path);
148
Archana Kakanidb65c3b2025-02-03 05:27:28 -0600149 /** @brief Implement Chassis Interface
150 * @param[in] path - the object path
151 */
152 void implementChassisInterface(const std::string& path);
153
Archana Kakani24e9a9b2025-02-04 00:27:25 -0600154 /** @brief Implement PowerSupply Interface
155 *
156 * @param[in] path - The object path
157 *
158 */
159 void implementPowerSupplyInterface(const std::string& path);
160
Archana Kakani1634a6e2025-02-04 01:12:29 -0600161 /** @brief Implement Asset Interface
162 *
163 * @param[in] path - The object path
164 *
165 */
166 void implementAssetInterface(const std::string& path);
167
George Liu682ee182020-12-25 15:24:33 +0800168 private:
Archana Kakani1634a6e2025-02-04 01:12:29 -0600169 std::unordered_map<ObjectPath, std::unique_ptr<Asset>> asset;
George Liu682ee182020-12-25 15:24:33 +0800170 std::unordered_map<ObjectPath, std::unique_ptr<LocationIntf>> location;
Kamalkumar Patel56da5742024-05-23 04:53:07 -0500171 std::unordered_map<ObjectPath, std::unique_ptr<CPUCore>> cpuCore;
Archana Kakanidb65c3b2025-02-03 05:27:28 -0600172 std::unordered_map<ObjectPath, std::unique_ptr<ItemChassis>> chassis;
Archana Kakani733b39d2024-06-05 21:05:20 -0500173 std::unordered_map<ObjectPath, std::unique_ptr<PCIeDevice>> pcieDevice;
Archana Kakanibf1fd272024-06-05 13:25:53 -0500174 std::unordered_map<ObjectPath, std::unique_ptr<PCIeSlot>> pcieSlot;
Archana Kakani24e9a9b2025-02-04 00:27:25 -0600175 std::unordered_map<ObjectPath, std::unique_ptr<PowerSupply>> powersupply;
Archana Kakanib40f4f82024-06-06 01:04:38 -0500176 std::unordered_map<ObjectPath, std::unique_ptr<Cable>> cable;
Kamalkumar Patel2ed986c2024-05-08 02:20:47 -0500177 std::unordered_map<ObjectPath, std::unique_ptr<Motherboard>> motherboard;
Archana Kakani413f51e2025-02-03 04:14:36 -0600178 std::unordered_map<ObjectPath, std::unique_ptr<Fan>> fan;
George Liu682ee182020-12-25 15:24:33 +0800179};
180
181} // namespace dbus
182} // namespace pldm