diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2018-02-24 16:01:20 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2018-03-01 09:39:42 +0100 |
commit | 266db810bffe4002bce9e2a1f485c27006c093b5 (patch) | |
tree | 4f60dac10d73639e386d75606535bb3fdc4129c3 /common | |
parent | bfcdef33add4f58ebd7f6a9621c94b1fb2caabd5 (diff) | |
download | barebox-266db810bffe4002bce9e2a1f485c27006c093b5.tar.gz barebox-266db810bffe4002bce9e2a1f485c27006c093b5.tar.xz |
ratp: new reset command
E.g.:
$ ./bbremote -v --port /dev/ttyUSB2 reset
Signed-off-by: Aleksander Morgado <aleksander@aleksander.es>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common')
-rw-r--r-- | common/ratp/Makefile | 1 | ||||
-rw-r--r-- | common/ratp/reset.c | 55 |
2 files changed, 56 insertions, 0 deletions
diff --git a/common/ratp/Makefile b/common/ratp/Makefile index d4cfdf95fa..2c6d674f61 100644 --- a/common/ratp/Makefile +++ b/common/ratp/Makefile @@ -3,3 +3,4 @@ obj-y += ping.o obj-y += getenv.o obj-y += md.o obj-y += mw.o +obj-y += reset.o diff --git a/common/ratp/reset.c b/common/ratp/reset.c new file mode 100644 index 0000000000..ca8be4e62f --- /dev/null +++ b/common/ratp/reset.c @@ -0,0 +1,55 @@ +/* + * 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. + * + */ + +#include <common.h> +#include <command.h> +#include <ratp_bb.h> +#include <complete.h> +#include <getopt.h> +#include <restart.h> + +struct ratp_bb_reset { + struct ratp_bb header; + uint8_t force; +} __attribute__((packed)); + +static int ratp_cmd_reset(const struct ratp_bb *req, int req_len, + struct ratp_bb **rsp, int *rsp_len) +{ + struct ratp_bb_reset *reset_req = (struct ratp_bb_reset *)req; + + if (req_len < sizeof (*reset_req)) { + printf ("ratp reset ignored: size mismatch (%d < %zu)\n", req_len, sizeof (*reset_req)); + return 2; + } + + debug("running reset %s\n", reset_req->force ? "(forced)" : ""); + + if (!reset_req->force) + shutdown_barebox(); + + restart_machine(); + /* Not reached */ + return 1; +} + +BAREBOX_RATP_CMD_START(RESET) + .request_id = BB_RATP_TYPE_RESET, + .cmd = ratp_cmd_reset +BAREBOX_RATP_CMD_END |