George Liu | 682ee18 | 2020-12-25 15:24:33 +0800 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Archana Kakani | 1634a6e | 2025-02-04 01:12:29 -0600 | [diff] [blame] | 3 | #include "asset.hpp" |
Archana Kakani | f935537 | 2025-02-04 03:13:24 -0600 | [diff] [blame] | 4 | #include "availability.hpp" |
Archana Kakani | b40f4f8 | 2024-06-06 01:04:38 -0500 | [diff] [blame] | 5 | #include "cable.hpp" |
Archana Kakani | db65c3b | 2025-02-03 05:27:28 -0600 | [diff] [blame] | 6 | #include "chassis.hpp" |
George Liu | 682ee18 | 2020-12-25 15:24:33 +0800 | [diff] [blame] | 7 | #include "common/utils.hpp" |
Archana Kakani | 17b1e8a | 2025-02-04 03:50:24 -0600 | [diff] [blame^] | 8 | #include "connector.hpp" |
Kamalkumar Patel | 56da574 | 2024-05-23 04:53:07 -0500 | [diff] [blame] | 9 | #include "cpu_core.hpp" |
Archana Kakani | 413f51e | 2025-02-03 04:14:36 -0600 | [diff] [blame] | 10 | #include "fan.hpp" |
Kamalkumar Patel | 2ed986c | 2024-05-08 02:20:47 -0500 | [diff] [blame] | 11 | #include "motherboard.hpp" |
Archana Kakani | 733b39d | 2024-06-05 21:05:20 -0500 | [diff] [blame] | 12 | #include "pcie_device.hpp" |
Archana Kakani | bf1fd27 | 2024-06-05 13:25:53 -0500 | [diff] [blame] | 13 | #include "pcie_slot.hpp" |
Archana Kakani | 24e9a9b | 2025-02-04 00:27:25 -0600 | [diff] [blame] | 14 | #include "power_supply.hpp" |
George Liu | 682ee18 | 2020-12-25 15:24:33 +0800 | [diff] [blame] | 15 | |
| 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 | |
| 24 | namespace pldm |
| 25 | { |
| 26 | namespace dbus |
| 27 | { |
| 28 | using ObjectPath = std::string; |
| 29 | |
Patrick Williams | 705fa98 | 2023-09-27 02:32:20 -0500 | [diff] [blame] | 30 | using LocationIntf = |
| 31 | sdbusplus::server::object_t<sdbusplus::xyz::openbmc_project::Inventory:: |
| 32 | Decorator::server::LocationCode>; |
George Liu | 682ee18 | 2020-12-25 15:24:33 +0800 | [diff] [blame] | 33 | |
| 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 | */ |
| 38 | class 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 Patel | 56da574 | 2024-05-23 04:53:07 -0500 | [diff] [blame] | 67 | * @param[in] path - The object path |
George Liu | 682ee18 | 2020-12-25 15:24:33 +0800 | [diff] [blame] | 68 | * |
| 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 Patel | 56da574 | 2024-05-23 04:53:07 -0500 | [diff] [blame] | 73 | /** @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 Liu | 682ee18 | 2020-12-25 15:24:33 +0800 | [diff] [blame] | 94 | |
Archana Kakani | bf1fd27 | 2024-06-05 13:25:53 -0500 | [diff] [blame] | 95 | /** @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 Kakani | 733b39d | 2024-06-05 21:05:20 -0500 | [diff] [blame] | 108 | /** @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 Kakani | b40f4f8 | 2024-06-06 01:04:38 -0500 | [diff] [blame] | 123 | /** @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 Patel | 2ed986c | 2024-05-08 02:20:47 -0500 | [diff] [blame] | 137 | /** @brief Implement interface for motherboard property |
| 138 | * |
| 139 | * @param[in] path - The object path |
| 140 | * |
| 141 | */ |
| 142 | void implementMotherboardInterface(const std::string& path); |
Archana Kakani | b40f4f8 | 2024-06-06 01:04:38 -0500 | [diff] [blame] | 143 | |
Archana Kakani | 413f51e | 2025-02-03 04:14:36 -0600 | [diff] [blame] | 144 | /** @brief Implement Fan Interface |
| 145 | * |
| 146 | * @param[in] path - The object path |
| 147 | * |
| 148 | */ |
| 149 | void implementFanInterface(const std::string& path); |
| 150 | |
Archana Kakani | db65c3b | 2025-02-03 05:27:28 -0600 | [diff] [blame] | 151 | /** @brief Implement Chassis Interface |
| 152 | * @param[in] path - the object path |
| 153 | */ |
| 154 | void implementChassisInterface(const std::string& path); |
| 155 | |
Archana Kakani | 24e9a9b | 2025-02-04 00:27:25 -0600 | [diff] [blame] | 156 | /** @brief Implement PowerSupply Interface |
| 157 | * |
| 158 | * @param[in] path - The object path |
| 159 | * |
| 160 | */ |
| 161 | void implementPowerSupplyInterface(const std::string& path); |
| 162 | |
Archana Kakani | 17b1e8a | 2025-02-04 03:50:24 -0600 | [diff] [blame^] | 163 | /** @brief Implement Connector Interface |
| 164 | * |
| 165 | * @param[in] path - The object path |
| 166 | * |
| 167 | */ |
| 168 | void implementConnecterInterface(const std::string& path); |
| 169 | |
Archana Kakani | 1634a6e | 2025-02-04 01:12:29 -0600 | [diff] [blame] | 170 | /** @brief Implement Asset Interface |
| 171 | * |
| 172 | * @param[in] path - The object path |
| 173 | * |
| 174 | */ |
| 175 | void implementAssetInterface(const std::string& path); |
| 176 | |
Archana Kakani | f935537 | 2025-02-04 03:13:24 -0600 | [diff] [blame] | 177 | /** @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 Liu | 682ee18 | 2020-12-25 15:24:33 +0800 | [diff] [blame] | 185 | private: |
Archana Kakani | 1634a6e | 2025-02-04 01:12:29 -0600 | [diff] [blame] | 186 | std::unordered_map<ObjectPath, std::unique_ptr<Asset>> asset; |
Archana Kakani | f935537 | 2025-02-04 03:13:24 -0600 | [diff] [blame] | 187 | std::unordered_map<ObjectPath, std::unique_ptr<Availability>> |
| 188 | availabilityState; |
George Liu | 682ee18 | 2020-12-25 15:24:33 +0800 | [diff] [blame] | 189 | std::unordered_map<ObjectPath, std::unique_ptr<LocationIntf>> location; |
Kamalkumar Patel | 56da574 | 2024-05-23 04:53:07 -0500 | [diff] [blame] | 190 | std::unordered_map<ObjectPath, std::unique_ptr<CPUCore>> cpuCore; |
Archana Kakani | db65c3b | 2025-02-03 05:27:28 -0600 | [diff] [blame] | 191 | std::unordered_map<ObjectPath, std::unique_ptr<ItemChassis>> chassis; |
Archana Kakani | 733b39d | 2024-06-05 21:05:20 -0500 | [diff] [blame] | 192 | std::unordered_map<ObjectPath, std::unique_ptr<PCIeDevice>> pcieDevice; |
Archana Kakani | bf1fd27 | 2024-06-05 13:25:53 -0500 | [diff] [blame] | 193 | std::unordered_map<ObjectPath, std::unique_ptr<PCIeSlot>> pcieSlot; |
Archana Kakani | 24e9a9b | 2025-02-04 00:27:25 -0600 | [diff] [blame] | 194 | std::unordered_map<ObjectPath, std::unique_ptr<PowerSupply>> powersupply; |
Archana Kakani | b40f4f8 | 2024-06-06 01:04:38 -0500 | [diff] [blame] | 195 | std::unordered_map<ObjectPath, std::unique_ptr<Cable>> cable; |
Kamalkumar Patel | 2ed986c | 2024-05-08 02:20:47 -0500 | [diff] [blame] | 196 | std::unordered_map<ObjectPath, std::unique_ptr<Motherboard>> motherboard; |
Archana Kakani | 413f51e | 2025-02-03 04:14:36 -0600 | [diff] [blame] | 197 | std::unordered_map<ObjectPath, std::unique_ptr<Fan>> fan; |
Archana Kakani | 17b1e8a | 2025-02-04 03:50:24 -0600 | [diff] [blame^] | 198 | std::unordered_map<ObjectPath, std::unique_ptr<Connector>> connector; |
George Liu | 682ee18 | 2020-12-25 15:24:33 +0800 | [diff] [blame] | 199 | }; |
| 200 | |
| 201 | } // namespace dbus |
| 202 | } // namespace pldm |