platform-mc: Support pollForPlatFormEventMessage

Supports polling all events synchronously when the terminus sends
`pldmMessagePollEvent` with the event id. BMC will use the received
event id as input for `pollForPlatformEventMessage` command to retrieve
the event data.

Change-Id: If01f63f30d3f57f8423c863ec776e83dda8e3042
Signed-off-by: Dung Cao <dung@os.amperecomputing.com>
Signed-off-by: Thu Nguyen <thu@os.amperecomputing.com>
diff --git a/platform-mc/manager.hpp b/platform-mc/manager.hpp
index c499f88..0cb0178 100644
--- a/platform-mc/manager.hpp
+++ b/platform-mc/manager.hpp
@@ -147,6 +147,40 @@
         return PLDM_SUCCESS;
     }
 
+    /** @brief PLDM POLL event handler function
+     *
+     *  @param[in] request - Event message
+     *  @param[in] payloadLength - Event message payload size
+     *  @param[in] tid - Terminus ID
+     *  @param[in] eventDataOffset - Event data offset
+     *
+     *  @return PLDM error code: PLDM_SUCCESS when there is no error in handling
+     *          the event
+     */
+    int handlePldmMessagePollEvent(
+        const pldm_msg* request, size_t payloadLength,
+        uint8_t /* formatVersion */, uint8_t tid, size_t eventDataOffset)
+    {
+        auto eventData = reinterpret_cast<const uint8_t*>(request->payload) +
+                         eventDataOffset;
+        auto eventDataSize = payloadLength - eventDataOffset;
+        eventManager.handlePlatformEvent(tid, PLDM_PLATFORM_EVENT_ID_NULL,
+                                         PLDM_MESSAGE_POLL_EVENT, eventData,
+                                         eventDataSize);
+        return PLDM_SUCCESS;
+    }
+
+    /** @brief The function to trigger the event polling
+     *
+     *  @param[in] tid - Terminus ID
+     *  @param[in] pollEventId - The source eventID from pldmMessagePollEvent
+     *  @param[in] pollDataTransferHandle - The dataTransferHandle from
+     *             pldmMessagePollEvent event
+     *  @return coroutine return_value - PLDM completion code
+     */
+    exec::task<int> pollForPlatformEvent(pldm_tid_t tid, uint16_t pollEventId,
+                                         uint32_t pollDataTransferHandle);
+
   private:
     /** @brief List of discovered termini */
     TerminiMapper termini{};