1 #pragma once 2 3 #include "pldmd/dbus_impl_pdr.hpp" 4 #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 11 using namespace pldm::dbus_api; 12 13 namespace pldm 14 { 15 namespace led 16 { 17 18 using LEDGroupObj = sdbusplus::server::object_t< 19 sdbusplus::xyz::openbmc_project::Led::server::Group>; 20 21 class HostLampTestInterfaces 22 { 23 public: ~HostLampTestInterfaces()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 */ 33 class 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 */ 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)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) : 57 LEDGroupObj(bus, objPath.c_str()), path(objPath), mctp_eid(mctp_eid), 58 instanceIdDb(instanceIdDb), pdrRepo(repo), handler(handler) 59 {} 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 111