blob: 7ccac2700e2d40cb0aa673ff0705e243b00a3df5 [file] [log] [blame]
Deepak Kodihalli1b24f972019-02-01 04:09:13 -06001#pragma once
2
Sagar Srinivas79669c92021-04-28 15:43:30 -05003#include "libpldmresponder/platform.hpp"
Deepak Kodihallibc669f12019-11-28 08:52:07 -06004
George Liuc453e162022-12-21 17:16:23 +08005#include <libpldm/base.h>
Deepak Kodihalli1b24f972019-02-01 04:09:13 -06006#include <stdint.h>
7
Sagar Srinivasa6a8ccd2021-04-01 07:58:33 -05008#include <sdeventplus/source/event.hpp>
9
Deepak Kodihalli1b24f972019-02-01 04:09:13 -060010#include <vector>
11
Sagar Srinivasa6a8ccd2021-04-01 07:58:33 -050012using namespace pldm::responder;
13
Deepak Kodihalli1b24f972019-02-01 04:09:13 -060014namespace pldm
15{
Deepak Kodihalli1b24f972019-02-01 04:09:13 -060016namespace responder
17{
Jinu Joy Thomasf666db12019-05-29 05:22:31 -050018namespace base
19{
Deepak Kodihallibc669f12019-11-28 08:52:07 -060020class Handler : public CmdHandler
21{
22 public:
Sagar Srinivas90314a32023-10-17 10:38:03 -050023 Handler(sdeventplus::Event& event,
24 pldm::responder::oem_platform::Handler* oemPlatformHandler) :
25 event(event),
26 oemPlatformHandler(oemPlatformHandler)
Deepak Kodihallibc669f12019-11-28 08:52:07 -060027 {
Delphine CC Chiud2e48992023-12-05 16:29:51 +080028 handlers.emplace(
29 PLDM_GET_PLDM_TYPES,
30 [this](pldm_tid_t, const pldm_msg* request, size_t payloadLength) {
Patrick Williams6da4f912023-05-10 07:50:53 -050031 return this->getPLDMTypes(request, payloadLength);
32 });
Delphine CC Chiud2e48992023-12-05 16:29:51 +080033 handlers.emplace(
34 PLDM_GET_PLDM_COMMANDS,
35 [this](pldm_tid_t, const pldm_msg* request, size_t payloadLength) {
Deepak Kodihallibc669f12019-11-28 08:52:07 -060036 return this->getPLDMCommands(request, payloadLength);
37 });
Delphine CC Chiud2e48992023-12-05 16:29:51 +080038 handlers.emplace(
39 PLDM_GET_PLDM_VERSION,
40 [this](pldm_tid_t, const pldm_msg* request, size_t payloadLength) {
Deepak Kodihallibc669f12019-11-28 08:52:07 -060041 return this->getPLDMVersion(request, payloadLength);
42 });
Delphine CC Chiud2e48992023-12-05 16:29:51 +080043 handlers.emplace(
44 PLDM_GET_TID,
45 [this](pldm_tid_t, const pldm_msg* request, size_t payloadLength) {
Patrick Williams6da4f912023-05-10 07:50:53 -050046 return this->getTID(request, payloadLength);
47 });
Deepak Kodihallibc669f12019-11-28 08:52:07 -060048 }
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 Srinivasa6a8ccd2021-04-01 07:58:33 -050074 /** @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 Srinivas90314a32023-10-17 10:38:03 -050080 void _processSetEventReceiver(sdeventplus::source::EventBase& source);
Sagar Srinivasa6a8ccd2021-04-01 07:58:33 -050081
Deepak Kodihallibc669f12019-11-28 08:52:07 -060082 /** @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 Srinivasa6a8ccd2021-04-01 07:58:33 -050089
90 private:
Sagar Srinivasa6a8ccd2021-04-01 07:58:33 -050091 /** @brief reference of main event loop of pldmd, primarily used to schedule
92 * work
93 */
94 sdeventplus::Event& event;
95
Sagar Srinivas79669c92021-04-28 15:43:30 -050096 /** @brief OEM platform handler */
97 pldm::responder::oem_platform::Handler* oemPlatformHandler;
98
Sagar Srinivasa6a8ccd2021-04-01 07:58:33 -050099 /** @brief sdeventplus event source */
100 std::unique_ptr<sdeventplus::source::Defer> survEvent;
Deepak Kodihallibc669f12019-11-28 08:52:07 -0600101};
102
Jinu Joy Thomasf666db12019-05-29 05:22:31 -0500103} // namespace base
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600104} // namespace responder
105} // namespace pldm