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