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