1*a743e384SChau Ly #pragma once 2*a743e384SChau Ly #include "../../common/utils.hpp" 3*a743e384SChau Ly #include "../../libpldmresponder/base.hpp" 4*a743e384SChau Ly #include "../../libpldmresponder/bios.hpp" 5*a743e384SChau Ly #include "../../libpldmresponder/fru.hpp" 6*a743e384SChau Ly #include "../../libpldmresponder/platform.hpp" 7*a743e384SChau Ly #include "../../oem/ampere/event/oem_event_manager.hpp" 8*a743e384SChau Ly #include "../../platform-mc/manager.hpp" 9*a743e384SChau Ly #include "../../pldmd/invoker.hpp" 10*a743e384SChau Ly #include "../../requester/request.hpp" 11*a743e384SChau Ly 12*a743e384SChau Ly namespace pldm 13*a743e384SChau Ly { 14*a743e384SChau Ly namespace oem_ampere 15*a743e384SChau Ly { 16*a743e384SChau Ly 17*a743e384SChau Ly /** 18*a743e384SChau Ly * @class OemAMPERE 19*a743e384SChau Ly * 20*a743e384SChau Ly * @brief class for creating all the OEM AMPERE handlers 21*a743e384SChau Ly * 22*a743e384SChau Ly * Only in case of OEM_AMPERE this class object will be instantiated 23*a743e384SChau Ly */ 24*a743e384SChau Ly class OemAMPERE 25*a743e384SChau Ly { 26*a743e384SChau Ly public: 27*a743e384SChau Ly OemAMPERE() = delete; 28*a743e384SChau Ly OemAMPERE& operator=(const OemAMPERE&) = delete; 29*a743e384SChau Ly OemAMPERE(OemAMPERE&&) = delete; 30*a743e384SChau Ly OemAMPERE& operator=(OemAMPERE&&) = delete; 31*a743e384SChau Ly 32*a743e384SChau Ly public: 33*a743e384SChau Ly /** Constructs OemAMPERE object 34*a743e384SChau Ly * 35*a743e384SChau Ly * @param[in] dBusIntf - D-Bus handler 36*a743e384SChau Ly * @param[in] mctp_fd - fd of MCTP communications socket 37*a743e384SChau Ly * @param[in] mctp_eid - MCTP EID of remote host firmware 38*a743e384SChau Ly * @param[in] repo - pointer to BMC's primary PDR repo 39*a743e384SChau Ly * @param[in] instanceIdDb - pointer to an InstanceIdDb object 40*a743e384SChau Ly * @param[in] event - sd_event handler 41*a743e384SChau Ly * @param[in] invoker - invoker handler 42*a743e384SChau Ly * @param[in] hostPDRHandler - hostPDRHandler handler 43*a743e384SChau Ly * @param[in] platformHandler - platformHandler handler 44*a743e384SChau Ly * @param[in] fruHandler - fruHandler handler 45*a743e384SChau Ly * @param[in] baseHandler - baseHandler handler 46*a743e384SChau Ly * @param[in] biosHandler - biosHandler handler 47*a743e384SChau Ly * @param[in] reqHandler - reqHandler handler 48*a743e384SChau Ly */ OemAMPERE(const pldm::utils::DBusHandler *,int,pldm_pdr *,pldm::InstanceIdDb & instanceIdDb,sdeventplus::Event & event,responder::Invoker &,HostPDRHandler *,responder::platform::Handler * platformHandler,responder::fru::Handler *,responder::base::Handler *,responder::bios::Handler *,platform_mc::Manager *,pldm::requester::Handler<pldm::requester::Request> * reqHandler)49*a743e384SChau Ly explicit OemAMPERE( 50*a743e384SChau Ly const pldm::utils::DBusHandler* /* dBusIntf */, int /* mctp_fd */, 51*a743e384SChau Ly pldm_pdr* /* repo */, pldm::InstanceIdDb& instanceIdDb, 52*a743e384SChau Ly sdeventplus::Event& event, responder::Invoker& /* invoker */, 53*a743e384SChau Ly HostPDRHandler* /* hostPDRHandler */, 54*a743e384SChau Ly responder::platform::Handler* platformHandler, 55*a743e384SChau Ly responder::fru::Handler* /* fruHandler */, 56*a743e384SChau Ly responder::base::Handler* /* baseHandler */, 57*a743e384SChau Ly responder::bios::Handler* /* biosHandler */, 58*a743e384SChau Ly platform_mc::Manager* /* platformManager */, 59*a743e384SChau Ly pldm::requester::Handler<pldm::requester::Request>* reqHandler) : 60*a743e384SChau Ly instanceIdDb(instanceIdDb), event(event), 61*a743e384SChau Ly platformHandler(platformHandler), reqHandler(reqHandler) 62*a743e384SChau Ly { 63*a743e384SChau Ly oemEventManager = std::make_shared<oem_ampere::OemEventManager>( 64*a743e384SChau Ly this->event, this->reqHandler, this->instanceIdDb); 65*a743e384SChau Ly createOemEventHandler(oemEventManager); 66*a743e384SChau Ly } 67*a743e384SChau Ly 68*a743e384SChau Ly private: 69*a743e384SChau Ly /** @brief Method for creating OemEventManager 70*a743e384SChau Ly * 71*a743e384SChau Ly * This method also assigns the OemEventManager to the below 72*a743e384SChau Ly * different handlers. 73*a743e384SChau Ly */ createOemEventHandler(std::shared_ptr<oem_ampere::OemEventManager> oemEventManager)74*a743e384SChau Ly void createOemEventHandler( 75*a743e384SChau Ly std::shared_ptr<oem_ampere::OemEventManager> oemEventManager) 76*a743e384SChau Ly { 77*a743e384SChau Ly platformHandler->registerEventHandlers( 78*a743e384SChau Ly PLDM_SENSOR_EVENT, 79*a743e384SChau Ly {[&oemEventManager](const pldm_msg* request, size_t payloadLength, 80*a743e384SChau Ly uint8_t formatVersion, uint8_t tid, 81*a743e384SChau Ly size_t eventDataOffset) { 82*a743e384SChau Ly return oemEventManager->handleSensorEvent( 83*a743e384SChau Ly request, payloadLength, formatVersion, tid, 84*a743e384SChau Ly eventDataOffset); 85*a743e384SChau Ly }}); 86*a743e384SChau Ly } 87*a743e384SChau Ly 88*a743e384SChau Ly private: 89*a743e384SChau Ly /** @brief reference to an Instance ID database object, used to obtain PLDM 90*a743e384SChau Ly * instance IDs 91*a743e384SChau Ly */ 92*a743e384SChau Ly pldm::InstanceIdDb& instanceIdDb; 93*a743e384SChau Ly 94*a743e384SChau Ly /** @brief reference of main event loop of pldmd, primarily used to schedule 95*a743e384SChau Ly * work 96*a743e384SChau Ly */ 97*a743e384SChau Ly sdeventplus::Event& event; 98*a743e384SChau Ly 99*a743e384SChau Ly /** @brief Platform handler*/ 100*a743e384SChau Ly responder::platform::Handler* platformHandler = nullptr; 101*a743e384SChau Ly 102*a743e384SChau Ly /** @brief pointer to the requester class*/ 103*a743e384SChau Ly requester::Handler<requester::Request>* reqHandler = nullptr; 104*a743e384SChau Ly 105*a743e384SChau Ly std::shared_ptr<oem_ampere::OemEventManager> oemEventManager{}; 106*a743e384SChau Ly }; 107*a743e384SChau Ly 108*a743e384SChau Ly } // namespace oem_ampere 109*a743e384SChau Ly } // namespace pldm 110