blob: c8307c69079a25c8c86079e1e766af7dfaff0610 [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"
George Liu682ee182020-12-25 15:24:33 +08005
6#include <sdbusplus/server.hpp>
7#include <xyz/openbmc_project/Inventory/Decorator/LocationCode/server.hpp>
8
9#include <memory>
10#include <optional>
11#include <string>
12#include <unordered_map>
13
14namespace pldm
15{
16namespace dbus
17{
18using ObjectPath = std::string;
19
Patrick Williams705fa982023-09-27 02:32:20 -050020using LocationIntf =
21 sdbusplus::server::object_t<sdbusplus::xyz::openbmc_project::Inventory::
22 Decorator::server::LocationCode>;
George Liu682ee182020-12-25 15:24:33 +080023
24/** @class CustomDBus
25 * @brief This is a custom D-Bus object, used to add D-Bus interface and update
26 * the corresponding properties value.
27 */
28class CustomDBus
29{
30 private:
31 CustomDBus() {}
32
33 public:
34 CustomDBus(const CustomDBus&) = delete;
35 CustomDBus(CustomDBus&&) = delete;
36 CustomDBus& operator=(const CustomDBus&) = delete;
37 CustomDBus& operator=(CustomDBus&&) = delete;
38 ~CustomDBus() = default;
39
40 static CustomDBus& getCustomDBus()
41 {
42 static CustomDBus customDBus;
43 return customDBus;
44 }
45
46 public:
47 /** @brief Set the LocationCode property
48 *
49 * @param[in] path - The object path
50 *
51 * @param[in] value - The value of the LocationCode property
52 */
53 void setLocationCode(const std::string& path, std::string value);
54
55 /** @brief Get the LocationCode property
56 *
Kamalkumar Patel56da5742024-05-23 04:53:07 -050057 * @param[in] path - The object path
George Liu682ee182020-12-25 15:24:33 +080058 *
59 * @return std::optional<std::string> - The value of the LocationCode
60 * property
61 */
62 std::optional<std::string> getLocationCode(const std::string& path) const;
Kamalkumar Patel56da5742024-05-23 04:53:07 -050063 /** @brief Implement CpuCore Interface
64 *
65 * @param[in] path - The object path
66 *
67 */
68 void implementCpuCoreInterface(const std::string& path);
69 /** @brief Set the microcode property
70 *
71 * @param[in] path - The object path
72 *
73 * @param[in] value - microcode value
74 */
75 void setMicroCode(const std::string& path, uint32_t value);
76
77 /** @brief Get the microcode property
78 *
79 * @param[in] path - The object path
80 *
81 * @return std::optional<uint32_t> - The value of the microcode value
82 */
83 std::optional<uint32_t> getMicroCode(const std::string& path) const;
George Liu682ee182020-12-25 15:24:33 +080084
85 private:
86 std::unordered_map<ObjectPath, std::unique_ptr<LocationIntf>> location;
Kamalkumar Patel56da5742024-05-23 04:53:07 -050087 std::unordered_map<ObjectPath, std::unique_ptr<CPUCore>> cpuCore;
George Liu682ee182020-12-25 15:24:33 +080088};
89
90} // namespace dbus
91} // namespace pldm