1a881c170SGeorge Liu #pragma once 2a881c170SGeorge Liu 3b49b7d80SGeorge Liu #include "../oem/ibm/host-bmc/host_lamp_test.hpp" 4a881c170SGeorge Liu #include "../oem/ibm/libpldmresponder/file_io.hpp" 5a881c170SGeorge Liu #include "../oem/ibm/libpldmresponder/fru_oem_ibm.hpp" 6a881c170SGeorge Liu #include "../oem/ibm/libpldmresponder/oem_ibm_handler.hpp" 7eb43d6c8SKamalkumar Patel #include "../oem/ibm/libpldmresponder/utils.hpp" 8a881c170SGeorge Liu #include "common/utils.hpp" 9a881c170SGeorge Liu #include "dbus_impl_requester.hpp" 10a881c170SGeorge Liu #include "host-bmc/dbus_to_event_handler.hpp" 11a881c170SGeorge Liu #include "invoker.hpp" 12928e87faSPavithra Barithaya #include "libpldmresponder/base.hpp" 13a881c170SGeorge Liu #include "libpldmresponder/fru.hpp" 14a881c170SGeorge Liu #include "requester/request.hpp" 15a881c170SGeorge Liu 1641ca40dcSAndrew Jeffery #include <libpldm/pdr.h> 1741ca40dcSAndrew Jeffery 18a881c170SGeorge Liu namespace pldm 19a881c170SGeorge Liu { 20a881c170SGeorge Liu namespace oem_ibm 21a881c170SGeorge Liu { 22a881c170SGeorge Liu 23a881c170SGeorge Liu using namespace pldm::state_sensor; 24a881c170SGeorge Liu using namespace pldm::dbus_api; 25a881c170SGeorge Liu 26a881c170SGeorge Liu /** 27a881c170SGeorge Liu * @class OemIBM 28a881c170SGeorge Liu * 29a881c170SGeorge Liu * @brief class for creating all the OEM IBM handlers 30a881c170SGeorge Liu * 31a881c170SGeorge Liu * Only in case of OEM_IBM this class object will be instantiated 32a881c170SGeorge Liu */ 33a881c170SGeorge Liu class OemIBM 34a881c170SGeorge Liu { 35a881c170SGeorge Liu public: 36a881c170SGeorge Liu OemIBM() = delete; 37a881c170SGeorge Liu OemIBM(const Pdr&) = delete; 38a881c170SGeorge Liu OemIBM& operator=(const OemIBM&) = delete; 39a881c170SGeorge Liu OemIBM(OemIBM&&) = delete; 40a881c170SGeorge Liu OemIBM& operator=(OemIBM&&) = delete; 41a881c170SGeorge Liu 42a881c170SGeorge Liu public: 43a881c170SGeorge Liu /** Constructs OemIBM object 44a881c170SGeorge Liu * 45a881c170SGeorge Liu * @param[in] dBusIntf - D-Bus handler 46a881c170SGeorge Liu * @param[in] mctp_fd - fd of MCTP communications socket 47a881c170SGeorge Liu * @param[in] mctp_eid - MCTP EID of remote host firmware 48a881c170SGeorge Liu * @param[in] repo - pointer to BMC's primary PDR repo 49a881c170SGeorge Liu * @param[in] instanceIdDb - pointer to an InstanceIdDb object 50a881c170SGeorge Liu * @param[in] event - sd_event handler 51a881c170SGeorge Liu * @param[in] invoker - invoker handler 52a881c170SGeorge Liu * @param[in] hostPDRHandler - hostPDRHandler handler 53a881c170SGeorge Liu * @param[in] platformHandler - platformHandler handler 54a881c170SGeorge Liu * @param[in] fruHandler - fruHandler handler 55a881c170SGeorge Liu * @param[in] baseHandler - baseHandler handler 56a881c170SGeorge Liu * @param[in] reqHandler - reqHandler handler 57a881c170SGeorge Liu */ OemIBM(const pldm::utils::DBusHandler * dBusIntf,int mctp_fd,uint8_t mctp_eid,pldm_pdr * repo,pldm::InstanceIdDb & instanceIdDb,sdeventplus::Event & event,responder::Invoker & invoker,HostPDRHandler * hostPDRHandler,responder::platform::Handler * platformHandler,responder::fru::Handler * fruHandler,responder::base::Handler * baseHandler,pldm::requester::Handler<pldm::requester::Request> * reqHandler)58a881c170SGeorge Liu explicit OemIBM( 59a881c170SGeorge Liu const pldm::utils::DBusHandler* dBusIntf, int mctp_fd, uint8_t mctp_eid, 60a881c170SGeorge Liu pldm_pdr* repo, pldm::InstanceIdDb& instanceIdDb, 61928e87faSPavithra Barithaya sdeventplus::Event& event, responder::Invoker& invoker, 62928e87faSPavithra Barithaya HostPDRHandler* hostPDRHandler, 63928e87faSPavithra Barithaya responder::platform::Handler* platformHandler, 64928e87faSPavithra Barithaya responder::fru::Handler* fruHandler, 65928e87faSPavithra Barithaya responder::base::Handler* baseHandler, 66a881c170SGeorge Liu pldm::requester::Handler<pldm::requester::Request>* reqHandler) : 6716c2a0a0SPatrick Williams dBusIntf(dBusIntf), mctp_fd(mctp_fd), mctp_eid(mctp_eid), repo(repo), 68a881c170SGeorge Liu instanceIdDb(instanceIdDb), event(event), invoker(invoker), 69a881c170SGeorge Liu reqHandler(reqHandler) 70a881c170SGeorge Liu { 71a881c170SGeorge Liu createOemFruHandler(); 72a881c170SGeorge Liu fruHandler->setOemFruHandler(oemFruHandler.get()); 73a881c170SGeorge Liu 74a881c170SGeorge Liu createOemIbmFruHandler(); 75a881c170SGeorge Liu oemIbmFruHandler->setIBMFruHandler(fruHandler); 76a881c170SGeorge Liu 77a881c170SGeorge Liu createCodeUpdate(); 78*a31ceb91SManojkiran Eda createSlotHandler(); 79a881c170SGeorge Liu createOemPlatformHandler(); 80eb43d6c8SKamalkumar Patel createOemIbmUtilsHandler(); 81a881c170SGeorge Liu codeUpdate->setOemPlatformHandler(oemPlatformHandler.get()); 82a881c170SGeorge Liu hostPDRHandler->setOemPlatformHandler(oemPlatformHandler.get()); 83eb43d6c8SKamalkumar Patel hostPDRHandler->setOemUtilsHandler(oemUtilsHandler.get()); 84a881c170SGeorge Liu platformHandler->setOemPlatformHandler(oemPlatformHandler.get()); 85a881c170SGeorge Liu baseHandler->setOemPlatformHandler(oemPlatformHandler.get()); 86*a31ceb91SManojkiran Eda slotHandler->setOemPlatformHandler(oemPlatformHandler.get()); 87a881c170SGeorge Liu 88a881c170SGeorge Liu createOemIbmPlatformHandler(); 89a881c170SGeorge Liu oemIbmPlatformHandler->setPlatformHandler(platformHandler); 90a881c170SGeorge Liu 91b49b7d80SGeorge Liu createHostLampTestHandler(); 92b49b7d80SGeorge Liu 93a881c170SGeorge Liu registerHandler(); 94a881c170SGeorge Liu } 95a881c170SGeorge Liu 96a881c170SGeorge Liu private: 97a881c170SGeorge Liu /** @brief Method for creating codeUpdate handler */ createCodeUpdate()98a881c170SGeorge Liu void createCodeUpdate() 99a881c170SGeorge Liu { 100a881c170SGeorge Liu codeUpdate = std::make_unique<pldm::responder::CodeUpdate>(dBusIntf); 101a881c170SGeorge Liu codeUpdate->clearDirPath(LID_STAGING_DIR); 102a881c170SGeorge Liu } 103a881c170SGeorge Liu 104*a31ceb91SManojkiran Eda /** @brief Method for creating slot handler */ createSlotHandler()105*a31ceb91SManojkiran Eda void createSlotHandler() 106*a31ceb91SManojkiran Eda { 107*a31ceb91SManojkiran Eda slotHandler = 108*a31ceb91SManojkiran Eda std::make_unique<pldm::responder::SlotHandler>(event, repo); 109*a31ceb91SManojkiran Eda } 110*a31ceb91SManojkiran Eda 111a881c170SGeorge Liu /** @brief Method for creating oemPlatformHandler 112a881c170SGeorge Liu * 113a881c170SGeorge Liu * This method also assigns the oemPlatformHandler to the below 114a881c170SGeorge Liu * different handlers. 115a881c170SGeorge Liu */ createOemPlatformHandler()116a881c170SGeorge Liu void createOemPlatformHandler() 117a881c170SGeorge Liu { 118*a31ceb91SManojkiran Eda oemPlatformHandler = std::make_unique<oem_ibm_platform::Handler>( 119*a31ceb91SManojkiran Eda dBusIntf, codeUpdate.get(), slotHandler.get(), mctp_fd, mctp_eid, 120*a31ceb91SManojkiran Eda instanceIdDb, event, reqHandler); 121a881c170SGeorge Liu } 122a881c170SGeorge Liu 123a881c170SGeorge Liu /** @brief Method for creating oemIbmPlatformHandler */ createOemIbmPlatformHandler()124a881c170SGeorge Liu void createOemIbmPlatformHandler() 125a881c170SGeorge Liu { 126a881c170SGeorge Liu oemIbmPlatformHandler = 127a881c170SGeorge Liu dynamic_cast<pldm::responder::oem_ibm_platform::Handler*>( 128a881c170SGeorge Liu oemPlatformHandler.get()); 129a881c170SGeorge Liu } 130a881c170SGeorge Liu 131a881c170SGeorge Liu /** @brief Method for creating oemFruHandler */ createOemFruHandler()132a881c170SGeorge Liu void createOemFruHandler() 133a881c170SGeorge Liu { 134928e87faSPavithra Barithaya oemFruHandler = std::make_unique<responder::oem_ibm_fru::Handler>(repo); 135a881c170SGeorge Liu } 136a881c170SGeorge Liu 137eb43d6c8SKamalkumar Patel /** @brief Method for creating oemIbmUtilsHandler */ createOemIbmUtilsHandler()138eb43d6c8SKamalkumar Patel void createOemIbmUtilsHandler() 139eb43d6c8SKamalkumar Patel { 140928e87faSPavithra Barithaya oemUtilsHandler = 141928e87faSPavithra Barithaya std::make_unique<responder::oem_ibm_utils::Handler>(dBusIntf); 142eb43d6c8SKamalkumar Patel } 143eb43d6c8SKamalkumar Patel 144a881c170SGeorge Liu /** @brief Method for creating oemIbmFruHandler */ createOemIbmFruHandler()145a881c170SGeorge Liu void createOemIbmFruHandler() 146a881c170SGeorge Liu { 147a881c170SGeorge Liu oemIbmFruHandler = dynamic_cast<pldm::responder::oem_ibm_fru::Handler*>( 148a881c170SGeorge Liu oemFruHandler.get()); 149a881c170SGeorge Liu } 150a881c170SGeorge Liu createHostLampTestHandler()151b49b7d80SGeorge Liu void createHostLampTestHandler() 152b49b7d80SGeorge Liu { 153b49b7d80SGeorge Liu auto& bus = pldm::utils::DBusHandler::getBus(); 154b49b7d80SGeorge Liu hostLampTest = std::make_unique<pldm::led::HostLampTest>( 155b49b7d80SGeorge Liu bus, "/xyz/openbmc_project/led/groups/host_lamp_test", mctp_eid, 156b49b7d80SGeorge Liu instanceIdDb, repo, reqHandler); 157b49b7d80SGeorge Liu } 158b49b7d80SGeorge Liu 159a881c170SGeorge Liu /** @brief Method for registering PLDM OEM handler */ registerHandler()160a881c170SGeorge Liu void registerHandler() 161a881c170SGeorge Liu { 162a881c170SGeorge Liu invoker.registerHandler( 163a881c170SGeorge Liu PLDM_OEM, std::make_unique<pldm::responder::oem_ibm::Handler>( 164a881c170SGeorge Liu oemPlatformHandler.get(), mctp_fd, mctp_eid, 165a881c170SGeorge Liu &instanceIdDb, reqHandler)); 166a881c170SGeorge Liu } 167a881c170SGeorge Liu 168a881c170SGeorge Liu private: 169a881c170SGeorge Liu /** @brief D-Bus handler */ 170a881c170SGeorge Liu const pldm::utils::DBusHandler* dBusIntf; 171a881c170SGeorge Liu 172a881c170SGeorge Liu /** @brief fd of MCTP communications socket */ 173a881c170SGeorge Liu int mctp_fd; 174a881c170SGeorge Liu 175a881c170SGeorge Liu /** @brief MCTP EID of remote host firmware */ 176a881c170SGeorge Liu uint8_t mctp_eid; 177a881c170SGeorge Liu 178a881c170SGeorge Liu /** @brief pointer to BMC's primary PDR repo */ 179a881c170SGeorge Liu pldm_pdr* repo; 180a881c170SGeorge Liu 181a881c170SGeorge Liu /** @brief reference to an Instance ID database object, used to obtain PLDM 182a881c170SGeorge Liu * instance IDs 183a881c170SGeorge Liu */ 184a881c170SGeorge Liu pldm::InstanceIdDb& instanceIdDb; 185a881c170SGeorge Liu 186a881c170SGeorge Liu /** @brief reference of main event loop of pldmd, primarily used to schedule 187a881c170SGeorge Liu * work 188a881c170SGeorge Liu */ 189a881c170SGeorge Liu sdeventplus::Event& event; 190a881c170SGeorge Liu 191a881c170SGeorge Liu /** @brief Object to the invoker class*/ 192928e87faSPavithra Barithaya responder::Invoker& invoker; 193a881c170SGeorge Liu 194a881c170SGeorge Liu /** @brief pointer to the requester class*/ 195a881c170SGeorge Liu requester::Handler<requester::Request>* reqHandler; 196a881c170SGeorge Liu 197a881c170SGeorge Liu /** @brief pointer to the oem_ibm_handler class*/ 198928e87faSPavithra Barithaya std::unique_ptr<responder::oem_platform::Handler> oemPlatformHandler{}; 199a881c170SGeorge Liu 200a881c170SGeorge Liu /** @brief pointer to the oem_ibm_fru class*/ 201928e87faSPavithra Barithaya std::unique_ptr<responder::oem_fru::Handler> oemFruHandler{}; 202a881c170SGeorge Liu 203a881c170SGeorge Liu /** @brief pointer to the CodeUpdate class*/ 204a881c170SGeorge Liu std::unique_ptr<pldm::responder::CodeUpdate> codeUpdate{}; 205a881c170SGeorge Liu 206*a31ceb91SManojkiran Eda /** @brief pointer to the SlotHanlder class*/ 207*a31ceb91SManojkiran Eda std::unique_ptr<pldm::responder::SlotHandler> slotHandler{}; 208*a31ceb91SManojkiran Eda 209a881c170SGeorge Liu /** @brief oem IBM Platform handler*/ 210a881c170SGeorge Liu pldm::responder::oem_ibm_platform::Handler* oemIbmPlatformHandler = nullptr; 211a881c170SGeorge Liu 212a881c170SGeorge Liu /** @brief oem IBM Fru handler*/ 213a881c170SGeorge Liu pldm::responder::oem_ibm_fru::Handler* oemIbmFruHandler = nullptr; 214b49b7d80SGeorge Liu 215b49b7d80SGeorge Liu std::unique_ptr<pldm::led::HostLampTest> hostLampTest; 216eb43d6c8SKamalkumar Patel 217eb43d6c8SKamalkumar Patel /** @brief oem IBM Utils handler*/ 218928e87faSPavithra Barithaya std::unique_ptr<responder::oem_utils::Handler> oemUtilsHandler; 219a881c170SGeorge Liu }; 220a881c170SGeorge Liu 221a881c170SGeorge Liu } // namespace oem_ibm 222a881c170SGeorge Liu } // namespace pldm 223