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