blob: 5d7cf2ec836b4d2be3c15298c8142f6e84a0541a [file] [log] [blame]
George Liu682ee182020-12-25 15:24:33 +08001#pragma once
2
3#include "common/utils.hpp"
Kamalkumar Patel56da5742024-05-23 04:53:07 -05004#include "cpu_core.hpp"
Archana Kakani733b39d2024-06-05 21:05:20 -05005#include "pcie_device.hpp"
Archana Kakanibf1fd272024-06-05 13:25:53 -05006#include "pcie_slot.hpp"
George Liu682ee182020-12-25 15:24:33 +08007
8#include <sdbusplus/server.hpp>
9#include <xyz/openbmc_project/Inventory/Decorator/LocationCode/server.hpp>
10
11#include <memory>
12#include <optional>
13#include <string>
14#include <unordered_map>
15
16namespace pldm
17{
18namespace dbus
19{
20using ObjectPath = std::string;
21
Patrick Williams705fa982023-09-27 02:32:20 -050022using LocationIntf =
23 sdbusplus::server::object_t<sdbusplus::xyz::openbmc_project::Inventory::
24 Decorator::server::LocationCode>;
George Liu682ee182020-12-25 15:24:33 +080025
26/** @class CustomDBus
27 * @brief This is a custom D-Bus object, used to add D-Bus interface and update
28 * the corresponding properties value.
29 */
30class CustomDBus
31{
32 private:
33 CustomDBus() {}
34
35 public:
36 CustomDBus(const CustomDBus&) = delete;
37 CustomDBus(CustomDBus&&) = delete;
38 CustomDBus& operator=(const CustomDBus&) = delete;
39 CustomDBus& operator=(CustomDBus&&) = delete;
40 ~CustomDBus() = default;
41
42 static CustomDBus& getCustomDBus()
43 {
44 static CustomDBus customDBus;
45 return customDBus;
46 }
47
48 public:
49 /** @brief Set the LocationCode property
50 *
51 * @param[in] path - The object path
52 *
53 * @param[in] value - The value of the LocationCode property
54 */
55 void setLocationCode(const std::string& path, std::string value);
56
57 /** @brief Get the LocationCode property
58 *
Kamalkumar Patel56da5742024-05-23 04:53:07 -050059 * @param[in] path - The object path
George Liu682ee182020-12-25 15:24:33 +080060 *
61 * @return std::optional<std::string> - The value of the LocationCode
62 * property
63 */
64 std::optional<std::string> getLocationCode(const std::string& path) const;
Kamalkumar Patel56da5742024-05-23 04:53:07 -050065 /** @brief Implement CpuCore Interface
66 *
67 * @param[in] path - The object path
68 *
69 */
70 void implementCpuCoreInterface(const std::string& path);
71 /** @brief Set the microcode property
72 *
73 * @param[in] path - The object path
74 *
75 * @param[in] value - microcode value
76 */
77 void setMicroCode(const std::string& path, uint32_t value);
78
79 /** @brief Get the microcode property
80 *
81 * @param[in] path - The object path
82 *
83 * @return std::optional<uint32_t> - The value of the microcode value
84 */
85 std::optional<uint32_t> getMicroCode(const std::string& path) const;
George Liu682ee182020-12-25 15:24:33 +080086
Archana Kakanibf1fd272024-06-05 13:25:53 -050087 /** @brief Implement PCIeSlot Interface
88 *
89 * @param[in] path - the object path
90 */
91 void implementPCIeSlotInterface(const std::string& path);
92
93 /** @brief Set the slot type
94 *
95 * @param[in] path - the object path
96 * @param[in] slot type - Slot type
97 */
98 void setSlotType(const std::string& path, const std::string& slotType);
99
Archana Kakani733b39d2024-06-05 21:05:20 -0500100 /** @brief Implement PCIe Device Interface
101 *
102 * @param[in] path - the object path
103 */
104 void implementPCIeDeviceInterface(const std::string& path);
105
106 /** @brief Set PCIe Device Lanes in use property
107 *
108 * @param[in] path - the object path
109 * @param[in] lanesInUse - Lanes in use
110 * @param[in] value - Generation in use
111 */
112 void setPCIeDeviceProps(const std::string& path, size_t lanesInUse,
113 const std::string& value);
114
George Liu682ee182020-12-25 15:24:33 +0800115 private:
116 std::unordered_map<ObjectPath, std::unique_ptr<LocationIntf>> location;
Kamalkumar Patel56da5742024-05-23 04:53:07 -0500117 std::unordered_map<ObjectPath, std::unique_ptr<CPUCore>> cpuCore;
Archana Kakani733b39d2024-06-05 21:05:20 -0500118 std::unordered_map<ObjectPath, std::unique_ptr<PCIeDevice>> pcieDevice;
Archana Kakanibf1fd272024-06-05 13:25:53 -0500119 std::unordered_map<ObjectPath, std::unique_ptr<PCIeSlot>> pcieSlot;
George Liu682ee182020-12-25 15:24:33 +0800120};
121
122} // namespace dbus
123} // namespace pldm