summaryrefslogtreecommitdiffstats
path: root/commands/reset.c
diff options
context:
space:
mode:
Diffstat (limited to 'commands/reset.c')
-rw-r--r--commands/reset.c55
1 files changed, 33 insertions, 22 deletions
diff --git a/commands/reset.c b/commands/reset.c
index 6eac532623..88e677afab 100644
--- a/commands/reset.c
+++ b/commands/reset.c
@@ -1,21 +1,7 @@
-/*
- * reset.c - reset the cpu
- *
- * Copyright (c) 2007 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
- *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- */
+// SPDX-License-Identifier: GPL-2.0-only
+// SPDX-FileCopyrightText: © 2007 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
+
+/* reset.c - reset the cpu */
#include <common.h>
#include <command.h>
@@ -25,24 +11,46 @@
static int cmd_reset(int argc, char *argv[])
{
- int opt, shutdown_flag;
+ struct restart_handler *rst;
+ int opt, shutdown_flag, flags = 0;
+ const char *name = NULL;
shutdown_flag = 1;
- while ((opt = getopt(argc, argv, "f")) > 0) {
+ while ((opt = getopt(argc, argv, "flwr:")) > 0) {
switch (opt) {
case 'f':
shutdown_flag = 0;
break;
+ case 'l':
+ restart_handlers_print();
+ return 0;
+ case 'w':
+ flags |= RESTART_FLAG_WARM_BOOTROM;
+ break;
+ case 'r':
+ name = optarg;
+ break;
default:
return COMMAND_ERROR_USAGE;
}
}
+ rst = restart_handler_get_by_name(name, flags);
+ if (!rst && (name || flags)) {
+ printf("No matching restart handler found\n");
+ return COMMAND_ERROR;
+ }
+
if (shutdown_flag)
shutdown_barebox();
- restart_machine();
+ if (rst) {
+ console_flush();
+ rst->restart(rst);
+ }
+
+ hang();
/* Not reached */
return 1;
@@ -51,12 +59,15 @@ 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("-w", "only consider warm BootROM reboot-mode-preserving resets")
+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("[-flrw]")
BAREBOX_CMD_GROUP(CMD_GRP_BOOT)
BAREBOX_CMD_HELP(cmd_reset_help)
BAREBOX_CMD_COMPLETE(empty_complete)