John Wang | 58a0e06 | 2019-11-08 15:38:15 +0800 | [diff] [blame] | 1 | #include "pldm_base_cmd.hpp" |
Sridevi Ramesh | 9857643 | 2019-11-27 10:10:28 -0600 | [diff] [blame] | 2 | #include "pldm_bios_cmd.hpp" |
John Wang | 58a0e06 | 2019-11-08 15:38:15 +0800 | [diff] [blame] | 3 | #include "pldm_cmd_helper.hpp" |
Sridevi Ramesh | d448975 | 2019-12-08 09:03:29 -0600 | [diff] [blame] | 4 | #include "pldm_fru_cmd.hpp" |
Tom Joseph | eea835a | 2021-10-25 19:30:32 +0530 | [diff] [blame] | 5 | #include "pldm_fw_update_cmd.hpp" |
George Liu | d664936 | 2019-11-27 19:06:51 +0800 | [diff] [blame] | 6 | #include "pldm_platform_cmd.hpp" |
Pavithra Barithaya | c4e80cc | 2020-05-26 07:00:26 -0500 | [diff] [blame] | 7 | #include "pldmtool/oem/ibm/pldm_oem_ibm.hpp" |
Lakshminarayana R. Kammath | 27693a4 | 2019-06-24 00:51:47 -0500 | [diff] [blame] | 8 | |
| 9 | #include <CLI/CLI.hpp> |
| 10 | |
John Wang | 58a0e06 | 2019-11-08 15:38:15 +0800 | [diff] [blame] | 11 | namespace pldmtool |
| 12 | { |
| 13 | |
| 14 | namespace raw |
| 15 | { |
| 16 | |
| 17 | using namespace pldmtool::helper; |
| 18 | |
| 19 | namespace |
| 20 | { |
| 21 | std::vector<std::unique_ptr<CommandInterface>> commands; |
| 22 | } |
| 23 | |
| 24 | class RawOp : public CommandInterface |
| 25 | { |
| 26 | public: |
| 27 | ~RawOp() = default; |
| 28 | RawOp() = delete; |
| 29 | RawOp(const RawOp&) = delete; |
| 30 | RawOp(RawOp&&) = default; |
| 31 | RawOp& operator=(const RawOp&) = delete; |
| 32 | RawOp& operator=(RawOp&&) = default; |
| 33 | |
| 34 | explicit RawOp(const char* type, const char* name, CLI::App* app) : |
| 35 | CommandInterface(type, name, app) |
| 36 | { |
| 37 | app->add_option("-d,--data", rawData, "raw data") |
| 38 | ->required() |
| 39 | ->expected(-3); |
| 40 | } |
| 41 | std::pair<int, std::vector<uint8_t>> createRequestMsg() override |
| 42 | |
| 43 | { |
Thu Nguyen | 66871b4 | 2023-05-28 17:35:48 +0700 | [diff] [blame] | 44 | rawData[0] = (rawData[0] & 0xe0) | instanceId; |
John Wang | 58a0e06 | 2019-11-08 15:38:15 +0800 | [diff] [blame] | 45 | return {PLDM_SUCCESS, rawData}; |
| 46 | } |
| 47 | |
| 48 | void parseResponseMsg(pldm_msg* /* responsePtr */, |
| 49 | size_t /* payloadLength */) override |
George Liu | 6492f52 | 2020-06-16 10:34:05 +0800 | [diff] [blame] | 50 | {} |
John Wang | 58a0e06 | 2019-11-08 15:38:15 +0800 | [diff] [blame] | 51 | |
| 52 | private: |
| 53 | std::vector<uint8_t> rawData; |
| 54 | }; |
| 55 | |
| 56 | void registerCommand(CLI::App& app) |
| 57 | { |
Patrick Williams | 6da4f91 | 2023-05-10 07:50:53 -0500 | [diff] [blame] | 58 | auto raw = app.add_subcommand("raw", |
| 59 | "send a raw request and print response"); |
John Wang | 58a0e06 | 2019-11-08 15:38:15 +0800 | [diff] [blame] | 60 | commands.push_back(std::make_unique<RawOp>("raw", "raw", raw)); |
| 61 | } |
| 62 | |
| 63 | } // namespace raw |
| 64 | } // namespace pldmtool |
| 65 | |
Lakshminarayana R. Kammath | 27693a4 | 2019-06-24 00:51:47 -0500 | [diff] [blame] | 66 | int main(int argc, char** argv) |
| 67 | { |
Lakshminarayana R. Kammath | 27693a4 | 2019-06-24 00:51:47 -0500 | [diff] [blame] | 68 | CLI::App app{"PLDM requester tool for OpenBMC"}; |
John Wang | 58a0e06 | 2019-11-08 15:38:15 +0800 | [diff] [blame] | 69 | app.require_subcommand(1)->ignore_case(); |
Lakshminarayana R. Kammath | 27693a4 | 2019-06-24 00:51:47 -0500 | [diff] [blame] | 70 | |
John Wang | 58a0e06 | 2019-11-08 15:38:15 +0800 | [diff] [blame] | 71 | pldmtool::raw::registerCommand(app); |
| 72 | pldmtool::base::registerCommand(app); |
Sridevi Ramesh | 9857643 | 2019-11-27 10:10:28 -0600 | [diff] [blame] | 73 | pldmtool::bios::registerCommand(app); |
George Liu | d664936 | 2019-11-27 19:06:51 +0800 | [diff] [blame] | 74 | pldmtool::platform::registerCommand(app); |
Sridevi Ramesh | d448975 | 2019-12-08 09:03:29 -0600 | [diff] [blame] | 75 | pldmtool::fru::registerCommand(app); |
Tom Joseph | eea835a | 2021-10-25 19:30:32 +0530 | [diff] [blame] | 76 | pldmtool::fw_update::registerCommand(app); |
Zahed Hossain | f0d1722 | 2020-04-03 05:24:58 -0500 | [diff] [blame] | 77 | |
| 78 | #ifdef OEM_IBM |
Pavithra Barithaya | c4e80cc | 2020-05-26 07:00:26 -0500 | [diff] [blame] | 79 | pldmtool::oem_ibm::registerCommand(app); |
Zahed Hossain | f0d1722 | 2020-04-03 05:24:58 -0500 | [diff] [blame] | 80 | #endif |
Lakshminarayana R. Kammath | 27693a4 | 2019-06-24 00:51:47 -0500 | [diff] [blame] | 81 | |
| 82 | CLI11_PARSE(app, argc, argv); |
John Wang | 58a0e06 | 2019-11-08 15:38:15 +0800 | [diff] [blame] | 83 | return 0; |
Lakshminarayana R. Kammath | 27693a4 | 2019-06-24 00:51:47 -0500 | [diff] [blame] | 84 | } |