tool: LPC data handler needs an address and length
The host needs to have memory set aside for this purpose, and this
enables the caller to provide those values.
Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: If40ec3b08bd1932cba91d3f770c7fde6f280463d
diff --git a/tools/main.cpp b/tools/main.cpp
index 536cde1..ff00dd4 100644
--- a/tools/main.cpp
+++ b/tools/main.cpp
@@ -27,6 +27,7 @@
#include <algorithm>
#include <cstdio>
+#include <cstdlib>
#include <exception>
#include <iostream>
#include <ipmiblob/blob_handler.hpp>
@@ -74,6 +75,9 @@
int main(int argc, char* argv[])
{
std::string command, interface, imagePath, signaturePath;
+ char* valueEnd = nullptr;
+ long address = 0;
+ long length = 0;
while (1)
{
@@ -83,13 +87,15 @@
{"interface", required_argument, 0, 'i'},
{"image", required_argument, 0, 'm'},
{"sig", required_argument, 0, 's'},
+ {"address", required_argument, 0, 'a'},
+ {"length", required_argument, 0, 'l'},
{0, 0, 0, 0}
};
// clang-format on
int option_index = 0;
int c =
- getopt_long(argc, argv, "c:i:m:s:", long_options, &option_index);
+ getopt_long(argc, argv, "c:i:m:s:a:l", long_options, &option_index);
if (c == -1)
{
break;
@@ -120,6 +126,22 @@
case 's':
signaturePath = std::string{optarg};
break;
+ case 'a':
+ address = std::strtol(&optarg[0], &valueEnd, 0);
+ if (valueEnd == nullptr)
+ {
+ usage(argv[0]);
+ exit(EXIT_FAILURE);
+ }
+ break;
+ case 'l':
+ length = std::strtol(&optarg[0], &valueEnd, 0);
+ if (valueEnd == nullptr)
+ {
+ usage(argv[0]);
+ exit(EXIT_FAILURE);
+ }
+ break;
default:
usage(argv[0]);
exit(EXIT_FAILURE);
@@ -155,8 +177,13 @@
}
else if (interface == IPMILPC)
{
- handler =
- std::make_unique<host_tool::LpcDataHandler>(&blob, &devmem);
+ if (address == 0 || length == 0)
+ {
+ std::fprintf(stderr, "Address or Length were 0\n");
+ exit(EXIT_FAILURE);
+ }
+ handler = std::make_unique<host_tool::LpcDataHandler>(
+ &blob, &devmem, address, length);
}
else if (interface == IPMIPCI)
{