Gilbert Chen | 6c7fed4 | 2022-02-22 15:40:17 +0000 | [diff] [blame] | 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 | |
Dung Cao | f48015b | 2023-11-21 04:38:29 +0000 | [diff] [blame] | 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 | |
Dung Cao | 5028734 | 2023-11-22 02:30:49 +0000 | [diff] [blame] | 48 | exec::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 Chen | 6c7fed4 | 2022-02-22 15:40:17 +0000 | [diff] [blame] | 59 | } // namespace platform_mc |
| 60 | } // namespace pldm |