blob: b8fe5a9482bf3611c5f461cfb140197029709fd3 [file] [log] [blame]
John Wang58a0e062019-11-08 15:38:15 +08001#include "pldm_base_cmd.hpp"
Sridevi Ramesh98576432019-11-27 10:10:28 -06002#include "pldm_bios_cmd.hpp"
John Wang58a0e062019-11-08 15:38:15 +08003#include "pldm_cmd_helper.hpp"
Sridevi Rameshd4489752019-12-08 09:03:29 -06004#include "pldm_fru_cmd.hpp"
Tom Josepheea835a2021-10-25 19:30:32 +05305#include "pldm_fw_update_cmd.hpp"
George Liud6649362019-11-27 19:06:51 +08006#include "pldm_platform_cmd.hpp"
Pavithra Barithayac4e80cc2020-05-26 07:00:26 -05007#include "pldmtool/oem/ibm/pldm_oem_ibm.hpp"
Lakshminarayana R. Kammath27693a42019-06-24 00:51:47 -05008
9#include <CLI/CLI.hpp>
10
John Wang58a0e062019-11-08 15:38:15 +080011namespace pldmtool
12{
13
14namespace raw
15{
16
17using namespace pldmtool::helper;
18
19namespace
20{
21std::vector<std::unique_ptr<CommandInterface>> commands;
22}
23
24class 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 Nguyen66871b42023-05-28 17:35:48 +070044 rawData[0] = (rawData[0] & 0xe0) | instanceId;
John Wang58a0e062019-11-08 15:38:15 +080045 return {PLDM_SUCCESS, rawData};
46 }
47
48 void parseResponseMsg(pldm_msg* /* responsePtr */,
49 size_t /* payloadLength */) override
George Liu6492f522020-06-16 10:34:05 +080050 {}
John Wang58a0e062019-11-08 15:38:15 +080051
52 private:
53 std::vector<uint8_t> rawData;
54};
55
56void registerCommand(CLI::App& app)
57{
Patrick Williams6da4f912023-05-10 07:50:53 -050058 auto raw = app.add_subcommand("raw",
59 "send a raw request and print response");
John Wang58a0e062019-11-08 15:38:15 +080060 commands.push_back(std::make_unique<RawOp>("raw", "raw", raw));
61}
62
63} // namespace raw
64} // namespace pldmtool
65
Lakshminarayana R. Kammath27693a42019-06-24 00:51:47 -050066int main(int argc, char** argv)
67{
Lakshminarayana R. Kammath27693a42019-06-24 00:51:47 -050068 CLI::App app{"PLDM requester tool for OpenBMC"};
John Wang58a0e062019-11-08 15:38:15 +080069 app.require_subcommand(1)->ignore_case();
Lakshminarayana R. Kammath27693a42019-06-24 00:51:47 -050070
John Wang58a0e062019-11-08 15:38:15 +080071 pldmtool::raw::registerCommand(app);
72 pldmtool::base::registerCommand(app);
Sridevi Ramesh98576432019-11-27 10:10:28 -060073 pldmtool::bios::registerCommand(app);
George Liud6649362019-11-27 19:06:51 +080074 pldmtool::platform::registerCommand(app);
Sridevi Rameshd4489752019-12-08 09:03:29 -060075 pldmtool::fru::registerCommand(app);
Tom Josepheea835a2021-10-25 19:30:32 +053076 pldmtool::fw_update::registerCommand(app);
Zahed Hossainf0d17222020-04-03 05:24:58 -050077
78#ifdef OEM_IBM
Pavithra Barithayac4e80cc2020-05-26 07:00:26 -050079 pldmtool::oem_ibm::registerCommand(app);
Zahed Hossainf0d17222020-04-03 05:24:58 -050080#endif
Lakshminarayana R. Kammath27693a42019-06-24 00:51:47 -050081
82 CLI11_PARSE(app, argc, argv);
John Wang58a0e062019-11-08 15:38:15 +080083 return 0;
Lakshminarayana R. Kammath27693a42019-06-24 00:51:47 -050084}