1 #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 12 using namespace pldm::dbus_api; 13 14 namespace pldm 15 { 16 namespace led 17 { 18 19 using LEDGroupObj = sdbusplus::server::object_t< 20 sdbusplus::xyz::openbmc_project::Led::server::Group>; 21 22 class HostLampTestInterfaces 23 { 24 public: ~HostLampTestInterfaces()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 */ 34 class 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 */ HostLampTest(sdbusplus::bus_t & bus,const std::string & objPath,uint8_t mctp_eid,pldm::InstanceIdDb & instanceIdDb,pldm_pdr * repo,pldm::requester::Handler<pldm::requester::Request> * handler)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()), path(objPath), mctp_eid(mctp_eid), 59 instanceIdDb(instanceIdDb), pdrRepo(repo), handler(handler) 60 {} 61 62 /** @brief Property SET Override function 63 * 64 * @param[in] value - True or False 65 * @return - Success or exception thrown 66 */ 67 bool asserted(bool value) override; 68 69 /** @brief Property GET Override function 70 * 71 * @return - True or False 72 */ 73 bool asserted() const override; 74 75 /** @brief Get effecterID from PDRs. 76 * 77 * @return effecterID 78 */ 79 uint16_t getEffecterID() override; 80 81 /** @brief Set state effecter states to PHYP. 82 * 83 * @param[in] effecterID - effecterID 84 * 85 * @return rc - PLDM completion codes 86 */ 87 uint8_t setHostStateEffecter(uint16_t effecterID) override; 88 89 private: 90 /** @brief Path of the group instance */ 91 std::string path; 92 93 /** @brief MCTP EID of host firmware */ 94 uint8_t mctp_eid; 95 96 /** @brief Reference to the InstanceIdDb object to obtain instance id 97 */ 98 pldm::InstanceIdDb& instanceIdDb; 99 100 /** @brief pointer to BMC's primary PDR repo */ 101 const pldm_pdr* pdrRepo; 102 103 /** @brief Effecter ID */ 104 uint16_t effecterID = 0; 105 106 /** @brief PLDM request handler */ 107 pldm::requester::Handler<pldm::requester::Request>* handler; 108 }; 109 110 } // namespace led 111 } // namespace pldm 112