Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Sagar Srinivas | 79669c9 | 2021-04-28 15:43:30 -0500 | [diff] [blame] | 3 | #include "libpldmresponder/platform.hpp" |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 4 | |
George Liu | c453e16 | 2022-12-21 17:16:23 +0800 | [diff] [blame] | 5 | #include <libpldm/base.h> |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 6 | #include <stdint.h> |
| 7 | |
Sagar Srinivas | a6a8ccd | 2021-04-01 07:58:33 -0500 | [diff] [blame] | 8 | #include <sdeventplus/source/event.hpp> |
| 9 | |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 10 | #include <vector> |
| 11 | |
Sagar Srinivas | a6a8ccd | 2021-04-01 07:58:33 -0500 | [diff] [blame] | 12 | using namespace pldm::responder; |
| 13 | |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 14 | namespace pldm |
| 15 | { |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 16 | namespace responder |
| 17 | { |
Jinu Joy Thomas | f666db1 | 2019-05-29 05:22:31 -0500 | [diff] [blame] | 18 | namespace base |
| 19 | { |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 20 | class Handler : public CmdHandler |
| 21 | { |
| 22 | public: |
Sagar Srinivas | 90314a3 | 2023-10-17 10:38:03 -0500 | [diff] [blame] | 23 | Handler(sdeventplus::Event& event, |
| 24 | pldm::responder::oem_platform::Handler* oemPlatformHandler) : |
| 25 | event(event), |
| 26 | oemPlatformHandler(oemPlatformHandler) |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 27 | { |
Delphine CC Chiu | d2e4899 | 2023-12-05 16:29:51 +0800 | [diff] [blame] | 28 | handlers.emplace( |
| 29 | PLDM_GET_PLDM_TYPES, |
| 30 | [this](pldm_tid_t, const pldm_msg* request, size_t payloadLength) { |
Patrick Williams | 6da4f91 | 2023-05-10 07:50:53 -0500 | [diff] [blame] | 31 | return this->getPLDMTypes(request, payloadLength); |
| 32 | }); |
Delphine CC Chiu | d2e4899 | 2023-12-05 16:29:51 +0800 | [diff] [blame] | 33 | handlers.emplace( |
| 34 | PLDM_GET_PLDM_COMMANDS, |
| 35 | [this](pldm_tid_t, const pldm_msg* request, size_t payloadLength) { |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 36 | return this->getPLDMCommands(request, payloadLength); |
| 37 | }); |
Delphine CC Chiu | d2e4899 | 2023-12-05 16:29:51 +0800 | [diff] [blame] | 38 | handlers.emplace( |
| 39 | PLDM_GET_PLDM_VERSION, |
| 40 | [this](pldm_tid_t, const pldm_msg* request, size_t payloadLength) { |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 41 | return this->getPLDMVersion(request, payloadLength); |
| 42 | }); |
Delphine CC Chiu | d2e4899 | 2023-12-05 16:29:51 +0800 | [diff] [blame] | 43 | handlers.emplace( |
| 44 | PLDM_GET_TID, |
| 45 | [this](pldm_tid_t, const pldm_msg* request, size_t payloadLength) { |
Patrick Williams | 6da4f91 | 2023-05-10 07:50:53 -0500 | [diff] [blame] | 46 | return this->getTID(request, payloadLength); |
| 47 | }); |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | /** @brief Handler for getPLDMTypes |
| 51 | * |
| 52 | * @param[in] request - Request message payload |
| 53 | * @param[in] payload_length - Request message payload length |
| 54 | * @param[return] Response - PLDM Response message |
| 55 | */ |
| 56 | Response getPLDMTypes(const pldm_msg* request, size_t payloadLength); |
| 57 | |
| 58 | /** @brief Handler for getPLDMCommands |
| 59 | * |
| 60 | * @param[in] request - Request message payload |
| 61 | * @param[in] payload_length - Request message payload length |
| 62 | * @param[return] Response - PLDM Response message |
| 63 | */ |
| 64 | Response getPLDMCommands(const pldm_msg* request, size_t payloadLength); |
| 65 | |
| 66 | /** @brief Handler for getPLDMCommands |
| 67 | * |
| 68 | * @param[in] request - Request message payload |
| 69 | * @param[in] payload_length - Request message payload length |
| 70 | * @param[return] Response - PLDM Response message |
| 71 | */ |
| 72 | Response getPLDMVersion(const pldm_msg* request, size_t payloadLength); |
| 73 | |
Sagar Srinivas | a6a8ccd | 2021-04-01 07:58:33 -0500 | [diff] [blame] | 74 | /** @brief _processSetEventReceiver does the actual work that needs |
| 75 | * to be carried out for setEventReceiver command. This is deferred |
| 76 | * after sending response for getTID command to the host |
| 77 | * |
| 78 | * @param[in] source - sdeventplus event source |
| 79 | */ |
Sagar Srinivas | 90314a3 | 2023-10-17 10:38:03 -0500 | [diff] [blame] | 80 | void _processSetEventReceiver(sdeventplus::source::EventBase& source); |
Sagar Srinivas | a6a8ccd | 2021-04-01 07:58:33 -0500 | [diff] [blame] | 81 | |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 82 | /** @brief Handler for getTID |
| 83 | * |
| 84 | * @param[in] request - Request message payload |
| 85 | * @param[in] payload_length - Request message payload length |
| 86 | * @param[return] Response - PLDM Response message |
| 87 | */ |
| 88 | Response getTID(const pldm_msg* request, size_t payloadLength); |
Sagar Srinivas | a6a8ccd | 2021-04-01 07:58:33 -0500 | [diff] [blame] | 89 | |
| 90 | private: |
Sagar Srinivas | a6a8ccd | 2021-04-01 07:58:33 -0500 | [diff] [blame] | 91 | /** @brief reference of main event loop of pldmd, primarily used to schedule |
| 92 | * work |
| 93 | */ |
| 94 | sdeventplus::Event& event; |
| 95 | |
Sagar Srinivas | 79669c9 | 2021-04-28 15:43:30 -0500 | [diff] [blame] | 96 | /** @brief OEM platform handler */ |
| 97 | pldm::responder::oem_platform::Handler* oemPlatformHandler; |
| 98 | |
Sagar Srinivas | a6a8ccd | 2021-04-01 07:58:33 -0500 | [diff] [blame] | 99 | /** @brief sdeventplus event source */ |
| 100 | std::unique_ptr<sdeventplus::source::Defer> survEvent; |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 101 | }; |
| 102 | |
Jinu Joy Thomas | f666db1 | 2019-05-29 05:22:31 -0500 | [diff] [blame] | 103 | } // namespace base |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 104 | } // namespace responder |
| 105 | } // namespace pldm |