summaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2020-06-02 09:57:57 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2020-09-15 14:42:49 +0200
commitd97016d3a53e5d9959f1e2b966c7cd0922f6bba3 (patch)
tree2e975aafefbb4d8ae55a57fe616007739b94f3fa /commands
parent119d453c0b40d4a477781626f944d74d439956da (diff)
downloadbarebox-d97016d3a53e5d9959f1e2b966c7cd0922f6bba3.tar.gz
barebox-d97016d3a53e5d9959f1e2b966c7cd0922f6bba3.tar.xz
commands: reset: allow specifying reset by name
So far, we were fine by using the highest priority restart handler whenever more than one was available. There are reasons to want to configure this however: - When communicating with BootROM, e.g. to force boot from recovery mode: The reset chosen must not cause the reboot mode stored to volatile memory to vanish - When testing (undocumented) reset behavior, e.g. to analyze how the EFI reset behaves Extend the reset command to support this. When no extra command line option is supplied, the old behavior is maintained. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands')
-rw-r--r--commands/reset.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/commands/reset.c b/commands/reset.c
index 2b10f1cd18..fe54e2f9b4 100644
--- a/commands/reset.c
+++ b/commands/reset.c
@@ -11,24 +11,43 @@
static int cmd_reset(int argc, char *argv[])
{
+ struct restart_handler *rst;
int opt, shutdown_flag;
+ const char *name = NULL;
shutdown_flag = 1;
- while ((opt = getopt(argc, argv, "f")) > 0) {
+ while ((opt = getopt(argc, argv, "flr:")) > 0) {
switch (opt) {
case 'f':
shutdown_flag = 0;
break;
+ case 'l':
+ restart_handlers_print();
+ return 0;
+ case 'r':
+ name = optarg;
+ break;
default:
return COMMAND_ERROR_USAGE;
}
}
+ rst = restart_handler_get_by_name(name);
+ if (!rst && name) {
+ printf("reset '%s' does not exist\n", name);
+ return COMMAND_ERROR;
+ }
+
if (shutdown_flag)
shutdown_barebox();
- restart_machine();
+ if (rst) {
+ console_flush();
+ rst->restart(rst);
+ }
+
+ hang();
/* Not reached */
return 1;
@@ -37,12 +56,14 @@ static int cmd_reset(int argc, char *argv[])
BAREBOX_CMD_HELP_START(reset)
BAREBOX_CMD_HELP_TEXT("Options:")
BAREBOX_CMD_HELP_OPT("-f", "force RESET, don't call shutdown")
+BAREBOX_CMD_HELP_OPT("-l", "list reset handlers")
+BAREBOX_CMD_HELP_OPT("-r RESET", "use reset handler named RESET")
BAREBOX_CMD_HELP_END
BAREBOX_CMD_START(reset)
.cmd = cmd_reset,
BAREBOX_CMD_DESC("perform RESET of the CPU")
- BAREBOX_CMD_OPTS("[-f]")
+ BAREBOX_CMD_OPTS("[-flr]")
BAREBOX_CMD_GROUP(CMD_GRP_BOOT)
BAREBOX_CMD_HELP(cmd_reset_help)
BAREBOX_CMD_COMPLETE(empty_complete)