platform-mc: Support register OEM mechanism to poll events

When the terminus only supports the `Poll-based message` type as `Table
17 - EventMessageSupported command format` in DSP0248 V1.3.0, BMC needs
polling the events from the terminus.
Add method to register OEM mechanism to poll the event from terminus.

Change-Id: I9c10d66ce076de3ddb38c9a391c3784b57ebb934
Signed-off-by: Dung Cao <dung@os.amperecomputing.com>
Signed-off-by: Dung Cao <dung@os.amperecomputing.com>
diff --git a/platform-mc/manager.cpp b/platform-mc/manager.cpp
index db5175a..1b5ff74 100644
--- a/platform-mc/manager.cpp
+++ b/platform-mc/manager.cpp
@@ -45,5 +45,16 @@
     co_return PLDM_SUCCESS;
 }
 
+exec::task<int> Manager::oemPollForPlatformEvent(pldm_tid_t tid)
+{
+    for (auto& handler : pollHandlers)
+    {
+        if (handler)
+        {
+            co_await handler(tid);
+        }
+    }
+    co_return PLDM_SUCCESS;
+}
 } // namespace platform_mc
 } // namespace pldm
diff --git a/platform-mc/manager.hpp b/platform-mc/manager.hpp
index 29d924a..213f1f5 100644
--- a/platform-mc/manager.hpp
+++ b/platform-mc/manager.hpp
@@ -16,6 +16,9 @@
 namespace platform_mc
 {
 
+using PollHandler = std::function<exec::task<int>(pldm_tid_t tid)>;
+using PollHandlers = std::vector<PollHandler>;
+
 /**
  * @brief Manager
  *
@@ -209,6 +212,23 @@
         eventManager.registerPolledEventHandler(eventClass, handlers);
     }
 
+    /** @brief Register OEM flow to poll the PLDM Event use
+     *         PollForPlatformEventMessage command
+     *
+     *  @param[in] handler - Poll event handlerr
+     */
+    void registerOEMPollMethod(PollHandler handler)
+    {
+        pollHandlers.push_back(std::move(handler));
+    }
+
+    /** @brief OEM task to do OEM event polling
+     *
+     *  @param[in] tid - Destination TID
+     *  @return coroutine return_value - PLDM completion code
+     */
+    exec::task<int> oemPollForPlatformEvent(pldm_tid_t tid);
+
   private:
     /** @brief List of discovered termini */
     TerminiMapper termini{};
@@ -224,6 +244,9 @@
 
     /** @brief Store event manager handler */
     EventManager eventManager;
+
+    /** @brief map of PLDM event type to EventHandlers */
+    PollHandlers pollHandlers;
 };
 } // namespace platform_mc
 } // namespace pldm
diff --git a/platform-mc/sensor_manager.cpp b/platform-mc/sensor_manager.cpp
index 2ffc679..95dd422 100644
--- a/platform-mc/sensor_manager.cpp
+++ b/platform-mc/sensor_manager.cpp
@@ -189,6 +189,11 @@
                 tid, terminus->pollEventId, terminus->pollDataTransferHandle);
         }
 
+        if (manager && (!terminus->pollEvent))
+        {
+            co_await manager->oemPollForPlatformEvent(tid);
+        }
+
         sd_event_now(event.get(), CLOCK_MONOTONIC, &t1);
         auto toBeUpdated = roundRobinSensors[tid].size();
         while (((t1 - t0) < pollingTimeInUsec) && (toBeUpdated > 0))