blob: c5d7e29cc34317e12d89613005c06665f80d02d3 [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 Kakanibf1fd272024-06-05 13:25:53 -05005#include "pcie_slot.hpp"
George Liu682ee182020-12-25 15:24:33 +08006
7#include <sdbusplus/server.hpp>
8#include <xyz/openbmc_project/Inventory/Decorator/LocationCode/server.hpp>
9
10#include <memory>
11#include <optional>
12#include <string>
13#include <unordered_map>
14
15namespace pldm
16{
17namespace dbus
18{
19using ObjectPath = std::string;
20
Patrick Williams705fa982023-09-27 02:32:20 -050021using LocationIntf =
22 sdbusplus::server::object_t<sdbusplus::xyz::openbmc_project::Inventory::
23 Decorator::server::LocationCode>;
George Liu682ee182020-12-25 15:24:33 +080024
25/** @class CustomDBus
26 * @brief This is a custom D-Bus object, used to add D-Bus interface and update
27 * the corresponding properties value.
28 */
29class CustomDBus
30{
31 private:
32 CustomDBus() {}
33
34 public:
35 CustomDBus(const CustomDBus&) = delete;
36 CustomDBus(CustomDBus&&) = delete;
37 CustomDBus& operator=(const CustomDBus&) = delete;
38 CustomDBus& operator=(CustomDBus&&) = delete;
39 ~CustomDBus() = default;
40
41 static CustomDBus& getCustomDBus()
42 {
43 static CustomDBus customDBus;
44 return customDBus;
45 }
46
47 public:
48 /** @brief Set the LocationCode property
49 *
50 * @param[in] path - The object path
51 *
52 * @param[in] value - The value of the LocationCode property
53 */
54 void setLocationCode(const std::string& path, std::string value);
55
56 /** @brief Get the LocationCode property
57 *
Kamalkumar Patel56da5742024-05-23 04:53:07 -050058 * @param[in] path - The object path
George Liu682ee182020-12-25 15:24:33 +080059 *
60 * @return std::optional<std::string> - The value of the LocationCode
61 * property
62 */
63 std::optional<std::string> getLocationCode(const std::string& path) const;
Kamalkumar Patel56da5742024-05-23 04:53:07 -050064 /** @brief Implement CpuCore Interface
65 *
66 * @param[in] path - The object path
67 *
68 */
69 void implementCpuCoreInterface(const std::string& path);
70 /** @brief Set the microcode property
71 *
72 * @param[in] path - The object path
73 *
74 * @param[in] value - microcode value
75 */
76 void setMicroCode(const std::string& path, uint32_t value);
77
78 /** @brief Get the microcode property
79 *
80 * @param[in] path - The object path
81 *
82 * @return std::optional<uint32_t> - The value of the microcode value
83 */
84 std::optional<uint32_t> getMicroCode(const std::string& path) const;
George Liu682ee182020-12-25 15:24:33 +080085
Archana Kakanibf1fd272024-06-05 13:25:53 -050086 /** @brief Implement PCIeSlot Interface
87 *
88 * @param[in] path - the object path
89 */
90 void implementPCIeSlotInterface(const std::string& path);
91
92 /** @brief Set the slot type
93 *
94 * @param[in] path - the object path
95 * @param[in] slot type - Slot type
96 */
97 void setSlotType(const std::string& path, const std::string& slotType);
98
George Liu682ee182020-12-25 15:24:33 +080099 private:
100 std::unordered_map<ObjectPath, std::unique_ptr<LocationIntf>> location;
Kamalkumar Patel56da5742024-05-23 04:53:07 -0500101 std::unordered_map<ObjectPath, std::unique_ptr<CPUCore>> cpuCore;
Archana Kakanibf1fd272024-06-05 13:25:53 -0500102 std::unordered_map<ObjectPath, std::unique_ptr<PCIeSlot>> pcieSlot;
George Liu682ee182020-12-25 15:24:33 +0800103};
104
105} // namespace dbus
106} // namespace pldm