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