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