blob: fe54e2f9b472dde1f49981aa43cae8da6a4c8d1f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
// 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>
#include <complete.h>
#include <getopt.h>
#include <restart.h>
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, "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();
if (rst) {
console_flush();
rst->restart(rst);
}
hang();
/* Not reached */
return 1;
}
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("[-flr]")
BAREBOX_CMD_GROUP(CMD_GRP_BOOT)
BAREBOX_CMD_HELP(cmd_reset_help)
BAREBOX_CMD_COMPLETE(empty_complete)
BAREBOX_CMD_END
|