blob: 1b5ff747e2ae8e1e13f469b977219e6435627d75 [file] [log] [blame]
Gilbert Chen6c7fed42022-02-22 15:40:17 +00001#include "manager.hpp"
2
3#include <phosphor-logging/lg2.hpp>
4
5PHOSPHOR_LOG2_USING;
6
7namespace pldm
8{
9namespace platform_mc
10{
11exec::task<int> Manager::beforeDiscoverTerminus()
12{
13 // Add any setup or checks needed before discovering a terminus
14 // If any setup/check fails, return the appropriate error code
15 // For now, we assume everything is successful
16 co_return PLDM_SUCCESS;
17}
18
19exec::task<int> Manager::afterDiscoverTerminus()
20{
21 auto rc = co_await platformManager.initTerminus();
22 if (rc != PLDM_SUCCESS)
23 {
24 lg2::error("Failed to initialize platform manager, error {RC}", "RC",
25 rc);
26 }
27 else
28 {
29 lg2::info("Successfully initialized platform manager");
30 }
31 co_return rc;
32}
33
Dung Caof48015b2023-11-21 04:38:29 +000034exec::task<int> Manager::pollForPlatformEvent(
35 pldm_tid_t tid, uint16_t /* pollEventId */, uint32_t pollDataTransferHandle)
36{
37 auto it = termini.find(tid);
38 if (it != termini.end())
39 {
40 auto& terminus = it->second;
41 co_await eventManager.pollForPlatformEventTask(tid,
42 pollDataTransferHandle);
43 terminus->pollEvent = false;
44 }
45 co_return PLDM_SUCCESS;
46}
47
Dung Cao50287342023-11-22 02:30:49 +000048exec::task<int> Manager::oemPollForPlatformEvent(pldm_tid_t tid)
49{
50 for (auto& handler : pollHandlers)
51 {
52 if (handler)
53 {
54 co_await handler(tid);
55 }
56 }
57 co_return PLDM_SUCCESS;
58}
Gilbert Chen6c7fed42022-02-22 15:40:17 +000059} // namespace platform_mc
60} // namespace pldm