Ricardo Quesada has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/57396 )
Change subject: elogtool: add argc / argv support for commands ......................................................................
elogtool: add argc / argv support for commands
Adds argc/argv argumentso the available commands. This is needed for the future command "cmd_add" that will parse its own arguments (see CL in the chain).
BUG=b:172210863 TEST=elogtool list && elogtool clear
Change-Id: I50067567b60a955a5ea3aed7ae8ff4139852b808 Signed-off-by: Ricardo Quesada ricardoq@google.com --- M util/cbfstool/elogtool.c 1 file changed, 15 insertions(+), 6 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/96/57396/1
diff --git a/util/cbfstool/elogtool.c b/util/cbfstool/elogtool.c index a3cd9de..6a4a707 100644 --- a/util/cbfstool/elogtool.c +++ b/util/cbfstool/elogtool.c @@ -14,6 +14,8 @@
#include "eventlog.h"
+#define UNUSED(_x) (void)(_x) + enum elogtool_return { ELOGTOOL_EXIT_SUCCESS = 0, ELOGTOOL_EXIT_BAD_ARGS, @@ -24,12 +26,12 @@ ELOGTOOL_EXIT_NOT_ENOUGH_BUFFER_SPACE, };
-static int cmd_list(const struct buffer *); -static int cmd_clear(const struct buffer *); +static int cmd_list(const struct buffer *, int, char **); +static int cmd_clear(const struct buffer *, int, char **);
static const struct { const char *name; - int (*func)(const struct buffer *buf); + int (*func)(const struct buffer *buf, int argc, char **argv); /* Whether it requires to write the buffer back */ bool write_back; } cmds[] = { @@ -132,11 +134,14 @@ return offset; }
-static int cmd_list(const struct buffer *buf) +static int cmd_list(const struct buffer *buf, int argc, char **argv) { const struct event_header *event; unsigned int count = 0;
+ UNUSED(argc); + UNUSED(argv); + /* Point to the first event */ event = buffer_get(buf) + sizeof(struct elog_header);
@@ -156,12 +161,15 @@ * Clears the elog events from the given buffer, which is a valid RW_ELOG region. * A LOG_CLEAR event is appended. */ -static int cmd_clear(const struct buffer *b) +static int cmd_clear(const struct buffer *b, int argc, char **argv) { uint32_t offset; struct buffer buf; void *start;
+ UNUSED(argc); + UNUSED(argv); + start = buffer_get(b); /* * Calculate the size of the "used" buffer, needed for ELOG_TYPE_LOG_CLEAR. @@ -236,7 +244,8 @@
for (i = 0; i < ARRAY_SIZE(cmds); i++) { if (!strcmp(cmds[i].name, argv[optind])) { - ret = cmds[i].func(&buf); + /* Only pass the non-processed arguments */ + ret = cmds[i].func(&buf, argc-optind-1, &argv[optind+1]); break; } }