blob: 4fff6c91a9916ccc7c3ecfe2316cbb81428b9357 [file] [log] [blame]
George Liub49b7d82021-02-08 14:10:17 +08001#pragma once
2
3#include "pldmd/dbus_impl_pdr.hpp"
George Liub49b7d82021-02-08 14:10:17 +08004#include "requester/handler.hpp"
5
6#include <sdbusplus/server/object.hpp>
7#include <xyz/openbmc_project/Led/Group/server.hpp>
8
9#include <string>
10
11using namespace pldm::dbus_api;
12
13namespace pldm
14{
15namespace led
16{
17
18using LEDGroupObj = sdbusplus::server::object_t<
19 sdbusplus::xyz::openbmc_project::Led::server::Group>;
20
21class HostLampTestInterfaces
22{
23 public:
24 virtual ~HostLampTestInterfaces() {}
25
26 virtual uint16_t getEffecterID() = 0;
27 virtual uint8_t setHostStateEffecter(uint16_t effecterID) = 0;
28};
29
30/** @class HostLampTest
31 * @brief Manages group of Host lamp test LEDs
32 */
33class HostLampTest : public HostLampTestInterfaces, public LEDGroupObj
34{
35 public:
36 HostLampTest() = delete;
37 ~HostLampTest() = default;
38 HostLampTest(const HostLampTest&) = delete;
39 HostLampTest& operator=(const HostLampTest&) = delete;
40 HostLampTest(HostLampTest&&) = delete;
41 HostLampTest& operator=(HostLampTest&&) = delete;
42
43 /** @brief Constructs LED Group
44 *
45 * @param[in] bus - Handle to system dbus
46 * @param[in] objPath - The D-Bus path that hosts LED group
47 * @param[in] mctp_fd - MCTP file descriptor
48 * @param[in] mctp_eid - MCTP EID
49 * @param[in] instanceIdDb - InstanceIdDb object to obtain instance id
50 * @param[in] repo - pointer to BMC's primary PDR repo
51 * @param[in] handler - PLDM request handler
52 */
53 HostLampTest(sdbusplus::bus_t& bus, const std::string& objPath,
54 uint8_t mctp_eid, pldm::InstanceIdDb& instanceIdDb,
55 pldm_pdr* repo,
56 pldm::requester::Handler<pldm::requester::Request>* handler) :
Patrick Williams16c2a0a2024-08-16 15:20:59 -040057 LEDGroupObj(bus, objPath.c_str()), path(objPath), mctp_eid(mctp_eid),
58 instanceIdDb(instanceIdDb), pdrRepo(repo), handler(handler)
George Liub49b7d82021-02-08 14:10:17 +080059 {}
60
61 /** @brief Property SET Override function
62 *
63 * @param[in] value - True or False
64 * @return - Success or exception thrown
65 */
66 bool asserted(bool value) override;
67
68 /** @brief Property GET Override function
69 *
70 * @return - True or False
71 */
72 bool asserted() const override;
73
74 /** @brief Get effecterID from PDRs.
75 *
76 * @return effecterID
77 */
78 uint16_t getEffecterID() override;
79
80 /** @brief Set state effecter states to PHYP.
81 *
82 * @param[in] effecterID - effecterID
83 *
84 * @return rc - PLDM completion codes
85 */
86 uint8_t setHostStateEffecter(uint16_t effecterID) override;
87
88 private:
89 /** @brief Path of the group instance */
90 std::string path;
91
92 /** @brief MCTP EID of host firmware */
93 uint8_t mctp_eid;
94
95 /** @brief Reference to the InstanceIdDb object to obtain instance id
96 */
97 pldm::InstanceIdDb& instanceIdDb;
98
99 /** @brief pointer to BMC's primary PDR repo */
100 const pldm_pdr* pdrRepo;
101
102 /** @brief Effecter ID */
103 uint16_t effecterID = 0;
104
105 /** @brief PLDM request handler */
106 pldm::requester::Handler<pldm::requester::Request>* handler;
107};
108
109} // namespace led
110} // namespace pldm