George Liu | 682ee18 | 2020-12-25 15:24:33 +0800 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Archana Kakani | b40f4f8 | 2024-06-06 01:04:38 -0500 | [diff] [blame] | 3 | #include "cable.hpp" |
Archana Kakani | db65c3b | 2025-02-03 05:27:28 -0600 | [diff] [blame] | 4 | #include "chassis.hpp" |
George Liu | 682ee18 | 2020-12-25 15:24:33 +0800 | [diff] [blame] | 5 | #include "common/utils.hpp" |
Kamalkumar Patel | 56da574 | 2024-05-23 04:53:07 -0500 | [diff] [blame] | 6 | #include "cpu_core.hpp" |
Archana Kakani | 413f51e | 2025-02-03 04:14:36 -0600 | [diff] [blame] | 7 | #include "fan.hpp" |
Kamalkumar Patel | 2ed986c | 2024-05-08 02:20:47 -0500 | [diff] [blame] | 8 | #include "motherboard.hpp" |
Archana Kakani | 733b39d | 2024-06-05 21:05:20 -0500 | [diff] [blame] | 9 | #include "pcie_device.hpp" |
Archana Kakani | bf1fd27 | 2024-06-05 13:25:53 -0500 | [diff] [blame] | 10 | #include "pcie_slot.hpp" |
Archana Kakani | 24e9a9b | 2025-02-04 00:27:25 -0600 | [diff] [blame^] | 11 | #include "power_supply.hpp" |
George Liu | 682ee18 | 2020-12-25 15:24:33 +0800 | [diff] [blame] | 12 | |
| 13 | #include <sdbusplus/server.hpp> |
| 14 | #include <xyz/openbmc_project/Inventory/Decorator/LocationCode/server.hpp> |
| 15 | |
| 16 | #include <memory> |
| 17 | #include <optional> |
| 18 | #include <string> |
| 19 | #include <unordered_map> |
| 20 | |
| 21 | namespace pldm |
| 22 | { |
| 23 | namespace dbus |
| 24 | { |
| 25 | using ObjectPath = std::string; |
| 26 | |
Patrick Williams | 705fa98 | 2023-09-27 02:32:20 -0500 | [diff] [blame] | 27 | using LocationIntf = |
| 28 | sdbusplus::server::object_t<sdbusplus::xyz::openbmc_project::Inventory:: |
| 29 | Decorator::server::LocationCode>; |
George Liu | 682ee18 | 2020-12-25 15:24:33 +0800 | [diff] [blame] | 30 | |
| 31 | /** @class CustomDBus |
| 32 | * @brief This is a custom D-Bus object, used to add D-Bus interface and update |
| 33 | * the corresponding properties value. |
| 34 | */ |
| 35 | class CustomDBus |
| 36 | { |
| 37 | private: |
| 38 | CustomDBus() {} |
| 39 | |
| 40 | public: |
| 41 | CustomDBus(const CustomDBus&) = delete; |
| 42 | CustomDBus(CustomDBus&&) = delete; |
| 43 | CustomDBus& operator=(const CustomDBus&) = delete; |
| 44 | CustomDBus& operator=(CustomDBus&&) = delete; |
| 45 | ~CustomDBus() = default; |
| 46 | |
| 47 | static CustomDBus& getCustomDBus() |
| 48 | { |
| 49 | static CustomDBus customDBus; |
| 50 | return customDBus; |
| 51 | } |
| 52 | |
| 53 | public: |
| 54 | /** @brief Set the LocationCode property |
| 55 | * |
| 56 | * @param[in] path - The object path |
| 57 | * |
| 58 | * @param[in] value - The value of the LocationCode property |
| 59 | */ |
| 60 | void setLocationCode(const std::string& path, std::string value); |
| 61 | |
| 62 | /** @brief Get the LocationCode property |
| 63 | * |
Kamalkumar Patel | 56da574 | 2024-05-23 04:53:07 -0500 | [diff] [blame] | 64 | * @param[in] path - The object path |
George Liu | 682ee18 | 2020-12-25 15:24:33 +0800 | [diff] [blame] | 65 | * |
| 66 | * @return std::optional<std::string> - The value of the LocationCode |
| 67 | * property |
| 68 | */ |
| 69 | std::optional<std::string> getLocationCode(const std::string& path) const; |
Kamalkumar Patel | 56da574 | 2024-05-23 04:53:07 -0500 | [diff] [blame] | 70 | /** @brief Implement CpuCore Interface |
| 71 | * |
| 72 | * @param[in] path - The object path |
| 73 | * |
| 74 | */ |
| 75 | void implementCpuCoreInterface(const std::string& path); |
| 76 | /** @brief Set the microcode property |
| 77 | * |
| 78 | * @param[in] path - The object path |
| 79 | * |
| 80 | * @param[in] value - microcode value |
| 81 | */ |
| 82 | void setMicroCode(const std::string& path, uint32_t value); |
| 83 | |
| 84 | /** @brief Get the microcode property |
| 85 | * |
| 86 | * @param[in] path - The object path |
| 87 | * |
| 88 | * @return std::optional<uint32_t> - The value of the microcode value |
| 89 | */ |
| 90 | std::optional<uint32_t> getMicroCode(const std::string& path) const; |
George Liu | 682ee18 | 2020-12-25 15:24:33 +0800 | [diff] [blame] | 91 | |
Archana Kakani | bf1fd27 | 2024-06-05 13:25:53 -0500 | [diff] [blame] | 92 | /** @brief Implement PCIeSlot Interface |
| 93 | * |
| 94 | * @param[in] path - the object path |
| 95 | */ |
| 96 | void implementPCIeSlotInterface(const std::string& path); |
| 97 | |
| 98 | /** @brief Set the slot type |
| 99 | * |
| 100 | * @param[in] path - the object path |
| 101 | * @param[in] slot type - Slot type |
| 102 | */ |
| 103 | void setSlotType(const std::string& path, const std::string& slotType); |
| 104 | |
Archana Kakani | 733b39d | 2024-06-05 21:05:20 -0500 | [diff] [blame] | 105 | /** @brief Implement PCIe Device Interface |
| 106 | * |
| 107 | * @param[in] path - the object path |
| 108 | */ |
| 109 | void implementPCIeDeviceInterface(const std::string& path); |
| 110 | |
| 111 | /** @brief Set PCIe Device Lanes in use property |
| 112 | * |
| 113 | * @param[in] path - the object path |
| 114 | * @param[in] lanesInUse - Lanes in use |
| 115 | * @param[in] value - Generation in use |
| 116 | */ |
| 117 | void setPCIeDeviceProps(const std::string& path, size_t lanesInUse, |
| 118 | const std::string& value); |
| 119 | |
Archana Kakani | b40f4f8 | 2024-06-06 01:04:38 -0500 | [diff] [blame] | 120 | /** @brief Implement PCIe Cable Interface |
| 121 | * |
| 122 | * @param[in] path - the object path |
| 123 | */ |
| 124 | void implementCableInterface(const std::string& path); |
| 125 | |
| 126 | /** @brief set cable attributes |
| 127 | * |
| 128 | * @param[in] path - the object path |
| 129 | * @param[in] length - length of the wire |
| 130 | * @param[in] cableDescription - cable details |
| 131 | */ |
| 132 | void setCableAttributes(const std::string& path, double length, |
| 133 | const std::string& cableDescription); |
Kamalkumar Patel | 2ed986c | 2024-05-08 02:20:47 -0500 | [diff] [blame] | 134 | /** @brief Implement interface for motherboard property |
| 135 | * |
| 136 | * @param[in] path - The object path |
| 137 | * |
| 138 | */ |
| 139 | void implementMotherboardInterface(const std::string& path); |
Archana Kakani | b40f4f8 | 2024-06-06 01:04:38 -0500 | [diff] [blame] | 140 | |
Archana Kakani | 413f51e | 2025-02-03 04:14:36 -0600 | [diff] [blame] | 141 | /** @brief Implement Fan Interface |
| 142 | * |
| 143 | * @param[in] path - The object path |
| 144 | * |
| 145 | */ |
| 146 | void implementFanInterface(const std::string& path); |
| 147 | |
Archana Kakani | db65c3b | 2025-02-03 05:27:28 -0600 | [diff] [blame] | 148 | /** @brief Implement Chassis Interface |
| 149 | * @param[in] path - the object path |
| 150 | */ |
| 151 | void implementChassisInterface(const std::string& path); |
| 152 | |
Archana Kakani | 24e9a9b | 2025-02-04 00:27:25 -0600 | [diff] [blame^] | 153 | /** @brief Implement PowerSupply Interface |
| 154 | * |
| 155 | * @param[in] path - The object path |
| 156 | * |
| 157 | */ |
| 158 | void implementPowerSupplyInterface(const std::string& path); |
| 159 | |
George Liu | 682ee18 | 2020-12-25 15:24:33 +0800 | [diff] [blame] | 160 | private: |
| 161 | std::unordered_map<ObjectPath, std::unique_ptr<LocationIntf>> location; |
Kamalkumar Patel | 56da574 | 2024-05-23 04:53:07 -0500 | [diff] [blame] | 162 | std::unordered_map<ObjectPath, std::unique_ptr<CPUCore>> cpuCore; |
Archana Kakani | db65c3b | 2025-02-03 05:27:28 -0600 | [diff] [blame] | 163 | std::unordered_map<ObjectPath, std::unique_ptr<ItemChassis>> chassis; |
Archana Kakani | 733b39d | 2024-06-05 21:05:20 -0500 | [diff] [blame] | 164 | std::unordered_map<ObjectPath, std::unique_ptr<PCIeDevice>> pcieDevice; |
Archana Kakani | bf1fd27 | 2024-06-05 13:25:53 -0500 | [diff] [blame] | 165 | std::unordered_map<ObjectPath, std::unique_ptr<PCIeSlot>> pcieSlot; |
Archana Kakani | 24e9a9b | 2025-02-04 00:27:25 -0600 | [diff] [blame^] | 166 | std::unordered_map<ObjectPath, std::unique_ptr<PowerSupply>> powersupply; |
Archana Kakani | b40f4f8 | 2024-06-06 01:04:38 -0500 | [diff] [blame] | 167 | std::unordered_map<ObjectPath, std::unique_ptr<Cable>> cable; |
Kamalkumar Patel | 2ed986c | 2024-05-08 02:20:47 -0500 | [diff] [blame] | 168 | std::unordered_map<ObjectPath, std::unique_ptr<Motherboard>> motherboard; |
Archana Kakani | 413f51e | 2025-02-03 04:14:36 -0600 | [diff] [blame] | 169 | std::unordered_map<ObjectPath, std::unique_ptr<Fan>> fan; |
George Liu | 682ee18 | 2020-12-25 15:24:33 +0800 | [diff] [blame] | 170 | }; |
| 171 | |
| 172 | } // namespace dbus |
| 173 | } // namespace pldm |