xref: /openbmc/pldm/platform-mc/manager.cpp (revision 7db557b5)
1 #include "manager.hpp"
2 
3 #include <phosphor-logging/lg2.hpp>
4 
5 PHOSPHOR_LOG2_USING;
6 
7 namespace pldm
8 {
9 namespace platform_mc
10 {
11 exec::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 
19 exec::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 
34 exec::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 
48 } // namespace platform_mc
49 } // namespace pldm
50