[PATCH 09/10] ratp: new reset command

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Aleksander Morgado <aleksander@xxxxxxxxxxxxx>
---
 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@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux