aboutsummaryrefslogtreecommitdiff
path: root/common/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/main.c')
-rw-r--r--common/main.c83
1 files changed, 66 insertions, 17 deletions
diff --git a/common/main.c b/common/main.c
index 3b9e39a980..8b7fd8fffe 100644
--- a/common/main.c
+++ b/common/main.c
@@ -43,6 +43,8 @@
#include <linux/ctype.h>
#include <menu.h>
+/* #define DEBUG_BOOTKEYS 1 */
+
#if defined(CONFIG_SILENT_CONSOLE) || defined(CONFIG_POST) || defined(CONFIG_CMDLINE_EDITING)
DECLARE_GLOBAL_DATA_PTR;
#endif
@@ -50,7 +52,7 @@ DECLARE_GLOBAL_DATA_PTR;
/*
* Board-specific Platform code can reimplement show_boot_progress () if needed
*/
-void inline __show_boot_progress (int val) {}
+void __show_boot_progress (int val) {}
void show_boot_progress (int val) __attribute__((weak, alias("__show_boot_progress")));
#if defined(CONFIG_UPDATE_TFTP)
@@ -95,7 +97,7 @@ static inline
int abortboot(int bootdelay)
{
int abort = 0;
- uint64_t etime = endtick(bootdelay);
+ uint64_t etime = endtick(1);
struct {
char* str;
u_int len;
@@ -113,10 +115,6 @@ int abortboot(int bootdelay)
u_int presskey_max = 0;
u_int i;
-# ifdef CONFIG_AUTOBOOT_PROMPT
- printf(CONFIG_AUTOBOOT_PROMPT);
-# endif
-
# ifdef CONFIG_AUTOBOOT_DELAY_STR
if (delaykey[0].str == NULL)
delaykey[0].str = CONFIG_AUTOBOOT_DELAY_STR;
@@ -134,6 +132,10 @@ int abortboot(int bootdelay)
delaykey[3].str = CONFIG_AUTOBOOT_STOP_STR2;
# endif
+# if DEBUG_BOOTKEYS
+ printf("\n");
+# endif
+
for (i = 0; i < sizeof(delaykey) / sizeof(delaykey[0]); i ++) {
delaykey[i].len = delaykey[i].str == NULL ?
0 : strlen (delaykey[i].str);
@@ -144,16 +146,46 @@ int abortboot(int bootdelay)
presskey_max : delaykey[i].len;
# if DEBUG_BOOTKEYS
- printf("%s key:<%s>\n",
- delaykey[i].retry ? "delay" : "stop",
- delaykey[i].str ? delaykey[i].str : "NULL");
+ u_int j;
+ printf("%s key: <", delaykey[i].retry ? "Delay" : "Stop ");
+ if (delaykey[i].str) {
+ for (j = 0; j < delaykey[i].len; j++) {
+ if (delaykey[i].str[j] < 0x80 &&
+ isprint(delaykey[i].str[j])) {
+ printf("%c", delaykey[i].str[j]);
+ } else {
+ printf("\\x%02X", delaykey[i].str[j]);
+ }
+ }
+ } else {
+ printf("NULL");
+ }
+ printf(">\n");
# endif
}
+# if DEBUG_BOOTKEYS
+ printf("\n");
+# endif
+
+# ifdef CONFIG_AUTOBOOT_PROMPT
+ printf(CONFIG_AUTOBOOT_PROMPT);
+# else
+ printf("Hit delay/stop key to delay/stop autoboot: %2d ", bootdelay);
+# endif
+
/* In order to keep up with incoming data, check timeout only
* when catch up.
*/
- do {
+ while (!abort && bootdelay > 0) {
+ if (get_ticks() > etime) {
+ etime = endtick(1);
+ --bootdelay;
+# ifndef CONFIG_AUTOBOOT_PROMPT
+ printf("\b\b\b%2d ", bootdelay);
+# endif
+ }
+
if (tstc()) {
if (presskey_len < presskey_max) {
presskey [presskey_len ++] = getc();
@@ -172,11 +204,14 @@ int abortboot(int bootdelay)
memcmp (presskey + presskey_len - delaykey[i].len,
delaykey[i].str,
delaykey[i].len) == 0) {
+# ifndef CONFIG_AUTOBOOT_PROMPT
+ puts("\n");
+# endif
# if DEBUG_BOOTKEYS
- printf("got %skey\n",
+ printf("Got %s key\n",
delaykey[i].retry ? "delay" : "stop");
# endif
-
+ puts("\n");
# ifdef CONFIG_BOOT_RETRY_TIME
/* don't retry auto boot */
if (! delaykey[i].retry)
@@ -185,12 +220,17 @@ int abortboot(int bootdelay)
abort = 1;
}
}
- } while (!abort && get_ticks() <= etime);
+ }
+ if (!abort) {
+# ifndef CONFIG_AUTOBOOT_PROMPT
+ puts("\n");
+# endif
# if DEBUG_BOOTKEYS
- if (!abort)
- puts("key timeout\n");
+ puts("Key timeout\n");
# endif
+ puts("\n");
+ }
#ifdef CONFIG_SILENT_CONSOLE
if (abort)
@@ -227,7 +267,9 @@ int abortboot(int bootdelay)
if (bootdelay >= 0) {
if (tstc()) { /* we got a key press */
(void) getc(); /* consume input */
+#ifndef CONFIG_MENUPROMPT
puts ("\b\b\b 0");
+#endif
abort = 1; /* don't auto boot */
}
}
@@ -252,7 +294,9 @@ int abortboot(int bootdelay)
udelay(10000);
}
+#ifndef CONFIG_MENUPROMPT
printf("\b\b\b%2d ", bootdelay);
+#endif
}
putc('\n');
@@ -271,6 +315,7 @@ int abortboot(int bootdelay)
void main_loop (void)
{
+ int autoboot;
#ifndef CONFIG_SYS_HUSH_PARSER
static char lastcommand[CONFIG_SYS_CBSIZE] = { 0, };
int len;
@@ -376,7 +421,12 @@ void main_loop (void)
debug ("### main_loop: bootcmd=\"%s\"\n", s ? s : "<UNDEFINED>");
- if (bootdelay >= 0 && s && !abortboot (bootdelay)) {
+# ifdef REBOOT_WHEN_CRASH
+ autoboot = (s != NULL);
+# else
+ autoboot = (bootdelay >= 0 && s && !abortboot (bootdelay));
+# endif
+ if (autoboot) {
# ifdef CONFIG_AUTOBOOT_KEYED
int prev = disable_ctrlc(1); /* disable Control C checking */
# endif
@@ -973,7 +1023,6 @@ int readline_into_buffer(const char *const prompt, char *buffer, int timeout)
#ifdef CONFIG_SHOW_ACTIVITY
while (!tstc()) {
- extern void show_activity(int arg);
show_activity(0);
WATCHDOG_RESET();
}