blob: 281f928ae45babe0ce8a1bbc5f4520ddaa528c80 [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"
Kamalkumar Patel56da5742024-05-23 04:53:07 -05008#include "cpu_core.hpp"
Archana Kakani413f51e2025-02-03 04:14:36 -06009#include "fan.hpp"
Kamalkumar Patel2ed986c2024-05-08 02:20:47 -050010#include "motherboard.hpp"
Archana Kakani733b39d2024-06-05 21:05:20 -050011#include "pcie_device.hpp"
Archana Kakanibf1fd272024-06-05 13:25:53 -050012#include "pcie_slot.hpp"
Archana Kakani24e9a9b2025-02-04 00:27:25 -060013#include "power_supply.hpp"
George Liu682ee182020-12-25 15:24:33 +080014
15#include <sdbusplus/server.hpp>
16#include <xyz/openbmc_project/Inventory/Decorator/LocationCode/server.hpp>
17
18#include <memory>
19#include <optional>
20#include <string>
21#include <unordered_map>
22
23namespace pldm
24{
25namespace dbus
26{
27using ObjectPath = std::string;
28
Patrick Williams705fa982023-09-27 02:32:20 -050029using LocationIntf =
30 sdbusplus::server::object_t<sdbusplus::xyz::openbmc_project::Inventory::
31 Decorator::server::LocationCode>;
George Liu682ee182020-12-25 15:24:33 +080032
33/** @class CustomDBus
34 * @brief This is a custom D-Bus object, used to add D-Bus interface and update
35 * the corresponding properties value.
36 */
37class CustomDBus
38{
39 private:
40 CustomDBus() {}
41
42 public:
43 CustomDBus(const CustomDBus&) = delete;
44 CustomDBus(CustomDBus&&) = delete;
45 CustomDBus& operator=(const CustomDBus&) = delete;
46 CustomDBus& operator=(CustomDBus&&) = delete;
47 ~CustomDBus() = default;
48
49 static CustomDBus& getCustomDBus()
50 {
51 static CustomDBus customDBus;
52 return customDBus;
53 }
54
55 public:
56 /** @brief Set the LocationCode property
57 *
58 * @param[in] path - The object path
59 *
60 * @param[in] value - The value of the LocationCode property
61 */
62 void setLocationCode(const std::string& path, std::string value);
63
64 /** @brief Get the LocationCode property
65 *
Kamalkumar Patel56da5742024-05-23 04:53:07 -050066 * @param[in] path - The object path
George Liu682ee182020-12-25 15:24:33 +080067 *
68 * @return std::optional<std::string> - The value of the LocationCode
69 * property
70 */
71 std::optional<std::string> getLocationCode(const std::string& path) const;
Kamalkumar Patel56da5742024-05-23 04:53:07 -050072 /** @brief Implement CpuCore Interface
73 *
74 * @param[in] path - The object path
75 *
76 */
77 void implementCpuCoreInterface(const std::string& path);
78 /** @brief Set the microcode property
79 *
80 * @param[in] path - The object path
81 *
82 * @param[in] value - microcode value
83 */
84 void setMicroCode(const std::string& path, uint32_t value);
85
86 /** @brief Get the microcode property
87 *
88 * @param[in] path - The object path
89 *
90 * @return std::optional<uint32_t> - The value of the microcode value
91 */
92 std::optional<uint32_t> getMicroCode(const std::string& path) const;
George Liu682ee182020-12-25 15:24:33 +080093
Archana Kakanibf1fd272024-06-05 13:25:53 -050094 /** @brief Implement PCIeSlot Interface
95 *
96 * @param[in] path - the object path
97 */
98 void implementPCIeSlotInterface(const std::string& path);
99
100 /** @brief Set the slot type
101 *
102 * @param[in] path - the object path
103 * @param[in] slot type - Slot type
104 */
105 void setSlotType(const std::string& path, const std::string& slotType);
106
Archana Kakani733b39d2024-06-05 21:05:20 -0500107 /** @brief Implement PCIe Device Interface
108 *
109 * @param[in] path - the object path
110 */
111 void implementPCIeDeviceInterface(const std::string& path);
112
113 /** @brief Set PCIe Device Lanes in use property
114 *
115 * @param[in] path - the object path
116 * @param[in] lanesInUse - Lanes in use
117 * @param[in] value - Generation in use
118 */
119 void setPCIeDeviceProps(const std::string& path, size_t lanesInUse,
120 const std::string& value);
121
Archana Kakanib40f4f82024-06-06 01:04:38 -0500122 /** @brief Implement PCIe Cable Interface
123 *
124 * @param[in] path - the object path
125 */
126 void implementCableInterface(const std::string& path);
127
128 /** @brief set cable attributes
129 *
130 * @param[in] path - the object path
131 * @param[in] length - length of the wire
132 * @param[in] cableDescription - cable details
133 */
134 void setCableAttributes(const std::string& path, double length,
135 const std::string& cableDescription);
Kamalkumar Patel2ed986c2024-05-08 02:20:47 -0500136 /** @brief Implement interface for motherboard property
137 *
138 * @param[in] path - The object path
139 *
140 */
141 void implementMotherboardInterface(const std::string& path);
Archana Kakanib40f4f82024-06-06 01:04:38 -0500142
Archana Kakani413f51e2025-02-03 04:14:36 -0600143 /** @brief Implement Fan Interface
144 *
145 * @param[in] path - The object path
146 *
147 */
148 void implementFanInterface(const std::string& path);
149
Archana Kakanidb65c3b2025-02-03 05:27:28 -0600150 /** @brief Implement Chassis Interface
151 * @param[in] path - the object path
152 */
153 void implementChassisInterface(const std::string& path);
154
Archana Kakani24e9a9b2025-02-04 00:27:25 -0600155 /** @brief Implement PowerSupply Interface
156 *
157 * @param[in] path - The object path
158 *
159 */
160 void implementPowerSupplyInterface(const std::string& path);
161
Archana Kakani1634a6e2025-02-04 01:12:29 -0600162 /** @brief Implement Asset Interface
163 *
164 * @param[in] path - The object path
165 *
166 */
167 void implementAssetInterface(const std::string& path);
168
Archana Kakanif9355372025-02-04 03:13:24 -0600169 /** @brief Set the availability state property
170 *
171 * @param[in] path - The object path
172 *
173 * @param[in] state - Availability state
174 */
175 void setAvailabilityState(const std::string& path, const bool& state);
176
George Liu682ee182020-12-25 15:24:33 +0800177 private:
Archana Kakani1634a6e2025-02-04 01:12:29 -0600178 std::unordered_map<ObjectPath, std::unique_ptr<Asset>> asset;
Archana Kakanif9355372025-02-04 03:13:24 -0600179 std::unordered_map<ObjectPath, std::unique_ptr<Availability>>
180 availabilityState;
George Liu682ee182020-12-25 15:24:33 +0800181 std::unordered_map<ObjectPath, std::unique_ptr<LocationIntf>> location;
Kamalkumar Patel56da5742024-05-23 04:53:07 -0500182 std::unordered_map<ObjectPath, std::unique_ptr<CPUCore>> cpuCore;
Archana Kakanidb65c3b2025-02-03 05:27:28 -0600183 std::unordered_map<ObjectPath, std::unique_ptr<ItemChassis>> chassis;
Archana Kakani733b39d2024-06-05 21:05:20 -0500184 std::unordered_map<ObjectPath, std::unique_ptr<PCIeDevice>> pcieDevice;
Archana Kakanibf1fd272024-06-05 13:25:53 -0500185 std::unordered_map<ObjectPath, std::unique_ptr<PCIeSlot>> pcieSlot;
Archana Kakani24e9a9b2025-02-04 00:27:25 -0600186 std::unordered_map<ObjectPath, std::unique_ptr<PowerSupply>> powersupply;
Archana Kakanib40f4f82024-06-06 01:04:38 -0500187 std::unordered_map<ObjectPath, std::unique_ptr<Cable>> cable;
Kamalkumar Patel2ed986c2024-05-08 02:20:47 -0500188 std::unordered_map<ObjectPath, std::unique_ptr<Motherboard>> motherboard;
Archana Kakani413f51e2025-02-03 04:14:36 -0600189 std::unordered_map<ObjectPath, std::unique_ptr<Fan>> fan;
George Liu682ee182020-12-25 15:24:33 +0800190};
191
192} // namespace dbus
193} // namespace pldm