From: Aleksander Morgado <aleksander@aleksander.es>
To: barebox@lists.infradead.org
Cc: Aleksander Morgado <aleksander@aleksander.es>
Subject: [PATCH 09/10] ratp: new reset command
Date: Fri, 2 Feb 2018 12:14:41 +0100 [thread overview]
Message-ID: <20180202111442.12444-10-aleksander@aleksander.es> (raw)
In-Reply-To: <20180202111442.12444-1-aleksander@aleksander.es>
Signed-off-by: Aleksander Morgado <aleksander@aleksander.es>
---
commands/reset.c | 48 +++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 41 insertions(+), 7 deletions(-)
diff --git a/commands/reset.c b/commands/reset.c
index 6eac53262..7971b9f2f 100644
--- a/commands/reset.c
+++ b/commands/reset.c
@@ -19,10 +19,26 @@
#include <common.h>
#include <command.h>
+#include <ratp_bb.h>
#include <complete.h>
#include <getopt.h>
#include <restart.h>
+static int common_reset (int shutdown_flag)
+{
+ debug("running reset %s\n", shutdown_flag ? "" : "(forced)");
+
+ if (shutdown_flag)
+ shutdown_barebox();
+
+ restart_machine();
+
+ /* Not reached */
+ return 1;
+}
+
+/* Console command */
+
static int cmd_reset(int argc, char *argv[])
{
int opt, shutdown_flag;
@@ -39,13 +55,7 @@ static int cmd_reset(int argc, char *argv[])
}
}
- if (shutdown_flag)
- shutdown_barebox();
-
- restart_machine();
-
- /* Not reached */
- return 1;
+ return common_reset (shutdown_flag);
}
BAREBOX_CMD_HELP_START(reset)
@@ -61,3 +71,27 @@ BAREBOX_CMD_START(reset)
BAREBOX_CMD_HELP(cmd_reset_help)
BAREBOX_CMD_COMPLETE(empty_complete)
BAREBOX_CMD_END
+
+/* RATP command */
+
+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;
+ }
+
+ return common_reset (reset_req->force);
+}
+
+BAREBOX_RATP_CMD_START(RESET)
+ .cmd = ratp_cmd_reset
+BAREBOX_RATP_CMD_END
--
2.15.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2018-02-02 11:15 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-02 11:14 [RFC PATCH 00/10] ratp: new generic RATP command support Aleksander Morgado
2018-02-02 11:14 ` [PATCH 01/10] ratp: define message type flags Aleksander Morgado
2018-02-02 11:14 ` [PATCH 02/10] ratp: port command operation to req/rsp/ind format Aleksander Morgado
2018-02-02 11:14 ` [PATCH 03/10] ratp: port ping operation to req/rsp format Aleksander Morgado
2018-02-02 11:14 ` [PATCH 04/10] ratp: port getenv " Aleksander Morgado
2018-02-02 11:14 ` [PATCH 05/10] ratp: port filesystem " Aleksander Morgado
2018-02-02 11:14 ` [PATCH 06/10] ratp: implement generic command support Aleksander Morgado
2018-02-06 9:30 ` Sascha Hauer
2018-02-06 16:49 ` Aleksander Morgado
2018-02-07 8:34 ` Sascha Hauer
2018-02-02 11:14 ` [PATCH 07/10] ratp: implement ping as a standard ratp command Aleksander Morgado
2018-02-06 9:33 ` Sascha Hauer
2018-02-06 16:51 ` Aleksander Morgado
2018-02-07 8:26 ` Sascha Hauer
2018-02-02 11:14 ` [PATCH 08/10] ratp: implement getenv " Aleksander Morgado
2018-02-02 11:14 ` Aleksander Morgado [this message]
2018-02-02 11:14 ` [PATCH 10/10] ratp: new md and mw commands Aleksander Morgado
2018-02-06 9:24 ` [RFC PATCH 00/10] ratp: new generic RATP command support Sascha Hauer
2018-02-06 16:43 ` Aleksander Morgado
2018-02-07 8:33 ` Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180202111442.12444-10-aleksander@aleksander.es \
--to=aleksander@aleksander.es \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox