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