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