Add reboot command.
authorKeith Packard <keithp@keithp.com>
Fri, 6 Nov 2009 05:45:00 +0000 (21:45 -0800)
committerKeith Packard <keithp@keithp.com>
Fri, 6 Nov 2009 05:45:00 +0000 (21:45 -0800)
This resets the processor using the watchdog timer.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/ao.h
src/ao_cmd.c

index 508ed37a47c65027ee9705781857956c7470c94e..2df81d2a7285d8230d91f86e5c75c138079fead5 100644 (file)
--- a/src/ao.h
+++ b/src/ao.h
@@ -107,6 +107,7 @@ ao_start_scheduler(void);
 #define AO_PANIC_LOG           5       /* Failing to read/write log data */
 #define AO_PANIC_CMD           6       /* Too many command sets registered */
 #define AO_PANIC_STDIO         7       /* Too many stdio handlers registered */
+#define AO_PANIC_REBOOT                8       /* Reboot failed */
 
 /* Stop the operating system, beeping and blinking the reason */
 void
index 81a527085faf5b099fa89f177d871b16a1c235ea..58039f3a20df24860438ca0815cebfb5f160197c 100644 (file)
@@ -199,6 +199,17 @@ echo(void)
        lex_echo = ao_cmd_lex_i != 0;
 }
 
+static void
+ao_reboot(void)
+{
+       ao_cmd_white();
+       if (!ao_match_word("eboot"))
+               return;
+       WDCTL = WDCTL_EN | WDCTL_MODE_WATCHDOG | WDCTL_INT_64;
+       ao_sleep(AO_SEC_TO_TICKS(2));
+       ao_panic(AO_PANIC_REBOOT);
+}
+
 static void
 version(void)
 {
@@ -292,6 +303,7 @@ __code struct ao_cmds       ao_base_cmds[] = {
        { '?', help,            "?                                  Print this message" },
        { 'T', ao_task_info,    "T                                  Show task states" },
        { 'E', echo,            "E <0 off, 1 on>                    Set command echo mode" },
+       { 'r', ao_reboot,       "r eboot                            Reboot" },
        { 'v', version,         "v                                  Show version" },
        { 0,    help,   NULL },
 };