1 #pragma once 2 3 #include "asset.hpp" 4 #include "availability.hpp" 5 #include "board.hpp" 6 #include "cable.hpp" 7 #include "chassis.hpp" 8 #include "common/utils.hpp" 9 #include "connector.hpp" 10 #include "cpu_core.hpp" 11 #include "fabric_adapter.hpp" 12 #include "fan.hpp" 13 #include "inventory_item.hpp" 14 #include "motherboard.hpp" 15 #include "panel.hpp" 16 #include "pcie_device.hpp" 17 #include "pcie_slot.hpp" 18 #include "power_supply.hpp" 19 #include "vrm.hpp" 20 21 #include <sdbusplus/server.hpp> 22 #include <xyz/openbmc_project/Inventory/Decorator/LocationCode/server.hpp> 23 24 #include <memory> 25 #include <optional> 26 #include <string> 27 #include <unordered_map> 28 29 namespace pldm 30 { 31 namespace dbus 32 { 33 using ObjectPath = std::string; 34 35 using LocationIntf = 36 sdbusplus::server::object_t<sdbusplus::xyz::openbmc_project::Inventory:: 37 Decorator::server::LocationCode>; 38 39 /** @class CustomDBus 40 * @brief This is a custom D-Bus object, used to add D-Bus interface and update 41 * the corresponding properties value. 42 */ 43 class CustomDBus 44 { 45 private: CustomDBus()46 CustomDBus() {} 47 48 public: 49 CustomDBus(const CustomDBus&) = delete; 50 CustomDBus(CustomDBus&&) = delete; 51 CustomDBus& operator=(const CustomDBus&) = delete; 52 CustomDBus& operator=(CustomDBus&&) = delete; 53 ~CustomDBus() = default; 54 getCustomDBus()55 static CustomDBus& getCustomDBus() 56 { 57 static CustomDBus customDBus; 58 return customDBus; 59 } 60 61 public: 62 /** @brief Set the LocationCode property 63 * 64 * @param[in] path - The object path 65 * 66 * @param[in] value - The value of the LocationCode property 67 */ 68 void setLocationCode(const std::string& path, std::string value); 69 70 /** @brief Get the LocationCode property 71 * 72 * @param[in] path - The object path 73 * 74 * @return std::optional<std::string> - The value of the LocationCode 75 * property 76 */ 77 std::optional<std::string> getLocationCode(const std::string& path) const; 78 /** @brief Implement CpuCore Interface 79 * 80 * @param[in] path - The object path 81 * 82 */ 83 void implementCpuCoreInterface(const std::string& path); 84 /** @brief Set the microcode property 85 * 86 * @param[in] path - The object path 87 * 88 * @param[in] value - microcode value 89 */ 90 void setMicroCode(const std::string& path, uint32_t value); 91 92 /** @brief Get the microcode property 93 * 94 * @param[in] path - The object path 95 * 96 * @return std::optional<uint32_t> - The value of the microcode value 97 */ 98 std::optional<uint32_t> getMicroCode(const std::string& path) const; 99 100 /** @brief Implement PCIeSlot Interface 101 * 102 * @param[in] path - the object path 103 */ 104 void implementPCIeSlotInterface(const std::string& path); 105 106 /** @brief Set the slot type 107 * 108 * @param[in] path - the object path 109 * @param[in] slot type - Slot type 110 */ 111 void setSlotType(const std::string& path, const std::string& slotType); 112 113 /** @brief Implement PCIe Device Interface 114 * 115 * @param[in] path - the object path 116 */ 117 void implementPCIeDeviceInterface(const std::string& path); 118 119 /** @brief Set PCIe Device Lanes in use property 120 * 121 * @param[in] path - the object path 122 * @param[in] lanesInUse - Lanes in use 123 * @param[in] value - Generation in use 124 */ 125 void setPCIeDeviceProps(const std::string& path, size_t lanesInUse, 126 const std::string& value); 127 128 /** @brief Implement PCIe Cable Interface 129 * 130 * @param[in] path - the object path 131 */ 132 void implementCableInterface(const std::string& path); 133 134 /** @brief set cable attributes 135 * 136 * @param[in] path - the object path 137 * @param[in] length - length of the wire 138 * @param[in] cableDescription - cable details 139 */ 140 void setCableAttributes(const std::string& path, double length, 141 const std::string& cableDescription); 142 /** @brief Implement interface for motherboard property 143 * 144 * @param[in] path - The object path 145 * 146 */ 147 void implementMotherboardInterface(const std::string& path); 148 149 /** @brief Implement Fan Interface 150 * 151 * @param[in] path - The object path 152 * 153 */ 154 void implementFanInterface(const std::string& path); 155 156 /** @brief Implement Chassis Interface 157 * @param[in] path - the object path 158 */ 159 void implementChassisInterface(const std::string& path); 160 161 /** @brief Implement PowerSupply Interface 162 * 163 * @param[in] path - The object path 164 * 165 */ 166 void implementPowerSupplyInterface(const std::string& path); 167 168 /** @brief Implement Connector Interface 169 * 170 * @param[in] path - The object path 171 * 172 */ 173 void implementConnecterInterface(const std::string& path); 174 175 /** @brief Implement Fabric Adapter Interface 176 * 177 * @param[in] path - The object path 178 * 179 */ 180 void implementFabricAdapter(const std::string& path); 181 182 /** @brief Implement Board Interface 183 * 184 * @param[in] path - The object path 185 * 186 */ 187 void implementBoard(const std::string& path); 188 189 /** @brief Implement Asset Interface 190 * 191 * @param[in] path - The object path 192 * 193 */ 194 void implementAssetInterface(const std::string& path); 195 196 /** @brief Set the availability state property 197 * 198 * @param[in] path - The object path 199 * 200 * @param[in] state - Availability state 201 */ 202 void setAvailabilityState(const std::string& path, const bool& state); 203 204 /** @brief Set the Inventory Item property 205 * @param[in] path - The object path 206 * @param[in] bool - the presence of fru 207 */ 208 void updateItemPresentStatus(const std::string& path, bool isPresent); 209 210 /** @brief Implement Panel Interface 211 * 212 * @param[in] path - The object path 213 * 214 */ 215 void implementPanelInterface(const std::string& path); 216 217 /** @brief Implement Voltage Regulator Module Interface 218 * 219 * @param[in] path - The object path 220 * 221 */ 222 void implementVRMInterface(const std::string& path); 223 224 private: 225 std::unordered_map<ObjectPath, std::unique_ptr<Asset>> asset; 226 std::unordered_map<ObjectPath, std::unique_ptr<Availability>> 227 availabilityState; 228 std::unordered_map<ObjectPath, std::unique_ptr<LocationIntf>> location; 229 std::unordered_map<ObjectPath, std::unique_ptr<InventoryItem>> 230 presentStatus; 231 std::unordered_map<ObjectPath, std::unique_ptr<CPUCore>> cpuCore; 232 std::unordered_map<ObjectPath, std::unique_ptr<ItemChassis>> chassis; 233 std::unordered_map<ObjectPath, std::unique_ptr<PCIeDevice>> pcieDevice; 234 std::unordered_map<ObjectPath, std::unique_ptr<PCIeSlot>> pcieSlot; 235 std::unordered_map<ObjectPath, std::unique_ptr<PowerSupply>> powersupply; 236 std::unordered_map<ObjectPath, std::unique_ptr<Board>> board; 237 std::unordered_map<ObjectPath, std::unique_ptr<FabricAdapter>> 238 fabricAdapter; 239 std::unordered_map<ObjectPath, std::unique_ptr<Cable>> cable; 240 std::unordered_map<ObjectPath, std::unique_ptr<Motherboard>> motherboard; 241 std::unordered_map<ObjectPath, std::unique_ptr<Fan>> fan; 242 std::unordered_map<ObjectPath, std::unique_ptr<Connector>> connector; 243 std::unordered_map<ObjectPath, std::unique_ptr<Panel>> panel; 244 std::unordered_map<ObjectPath, std::unique_ptr<VRM>> vrm; 245 }; 246 247 } // namespace dbus 248 } // namespace pldm 249