#include <common.h>
#include <watchdog.h>
#include <command.h>
-#include <cmd_nvedit.h>
-#include <cmd_bootm.h>
-#include <malloc.h>
-#if defined(CONFIG_BOOT_RETRY_TIME) && defined(CONFIG_RESET_TO_RETRY)
-#include <cmd_boot.h> /* for do_reset() prototype */
+#ifdef CONFIG_MODEM_SUPPORT
+#include <malloc.h> /* for free() prototype */
#endif
#ifdef CFG_HUSH_PARSER
#include <hush.h>
#endif
+#include <post.h>
+
+#ifdef CONFIG_SILENT_CONSOLE
+DECLARE_GLOBAL_DATA_PTR;
+#endif
+
+#if defined(CONFIG_BOOT_RETRY_TIME) && defined(CONFIG_RESET_TO_RETRY)
+extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); /* for do_reset() prototype */
+#endif
+
+extern int do_bootd (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
+
+
#define MAX_DELAY_STOP_STR 32
static char * delete_char (char *buffer, char *p, int *colp, int *np, int plen);
u_int presskey_max = 0;
u_int i;
+#ifdef CONFIG_SILENT_CONSOLE
+ if (gd->flags & GD_FLG_SILENT) {
+ /* Restore serial console */
+ console_assign (stdout, "serial");
+ console_assign (stderr, "serial");
+ }
+#endif
+
# ifdef CONFIG_AUTOBOOT_PROMPT
printf (CONFIG_AUTOBOOT_PROMPT, bootdelay);
# endif
if (delaykey[i].len > 0 &&
presskey_len >= delaykey[i].len &&
memcmp (presskey + presskey_len - delaykey[i].len,
- delaykey[i].str,
+ delaykey[i].str,
delaykey[i].len) == 0) {
# if DEBUG_BOOTKEYS
printf("got %skey\n",
}
# if DEBUG_BOOTKEYS
if (!abort)
- printf("key timeout\n");
+ puts ("key timeout\n");
# endif
+#ifdef CONFIG_SILENT_CONSOLE
+ if (abort) {
+ /* permanently enable normal console output */
+ gd->flags &= ~(GD_FLG_SILENT);
+ } else if (gd->flags & GD_FLG_SILENT) {
+ /* Restore silent console */
+ console_assign (stdout, "nulldev");
+ console_assign (stderr, "nulldev");
+ }
+#endif
+
return abort;
}
{
int abort = 0;
+#ifdef CONFIG_SILENT_CONSOLE
+ if (gd->flags & GD_FLG_SILENT) {
+ /* Restore serial console */
+ console_assign (stdout, "serial");
+ console_assign (stderr, "serial");
+ }
+#endif
+
#ifdef CONFIG_MENUPROMPT
printf(CONFIG_MENUPROMPT, bootdelay);
#else
#endif
#if defined CONFIG_ZERO_BOOTDELAY_CHECK
- /*
- * Check if key already pressed
- * Don't check if bootdelay < 0
- */
+ /*
+ * Check if key already pressed
+ * Don't check if bootdelay < 0
+ */
if (bootdelay >= 0) {
if (tstc()) { /* we got a key press */
(void) getc(); /* consume input */
- printf ("\b\b\b 0\n");
- return 1; /* don't auto boot */
+ puts ("\b\b\b 0");
+ abort = 1; /* don't auto boot */
}
- }
+ }
#endif
- while (bootdelay > 0) {
+ while ((bootdelay > 0) && (!abort)) {
int i;
--bootdelay;
putc ('\n');
+#ifdef CONFIG_SILENT_CONSOLE
+ if (abort) {
+ /* permanently enable normal console output */
+ gd->flags &= ~(GD_FLG_SILENT);
+ } else if (gd->flags & GD_FLG_SILENT) {
+ /* Restore silent console */
+ console_assign (stdout, "nulldev");
+ console_assign (stderr, "nulldev");
+ }
+#endif
+
return abort;
}
# endif /* CONFIG_AUTOBOOT_KEYED */
#ifdef CONFIG_PREBOOT
char *p;
#endif
+#ifdef CONFIG_BOOTCOUNT_LIMIT
+ unsigned long bootcount = 0;
+ unsigned long bootlimit = 0;
+ char *bcs;
+ char bcs_set[16];
+#endif /* CONFIG_BOOTCOUNT_LIMIT */
#if defined(CONFIG_VFD) && defined(VFD_TEST_LOGO)
ulong bmp = 0; /* default bitmap */
trab_vfd (bmp);
#endif /* CONFIG_VFD && VFD_TEST_LOGO */
+#ifdef CONFIG_BOOTCOUNT_LIMIT
+ bootcount = bootcount_load();
+ bootcount++;
+ bootcount_store (bootcount);
+ sprintf (bcs_set, "%lu", bootcount);
+ setenv ("bootcount", bcs_set);
+ bcs = getenv ("bootlimit");
+ bootlimit = bcs ? simple_strtoul (bcs, NULL, 10) : 0;
+#endif /* CONFIG_BOOTCOUNT_LIMIT */
+
#ifdef CONFIG_MODEM_SUPPORT
debug ("DEBUG: main_loop: do_mdm_init=%d\n", do_mdm_init);
if (do_mdm_init) {
- uchar *str = strdup(getenv("mdm_cmd"));
+ char *str = strdup(getenv("mdm_cmd"));
setenv ("preboot", str); /* set or delete definition */
if (str != NULL)
free (str);
#ifdef CONFIG_VERSION_VARIABLE
{
extern char version_string[];
- char *str = getenv("ver");
- if (!str)
- setenv ("ver", version_string); /* set version variable */
+ setenv ("ver", version_string); /* set version variable */
}
#endif /* CONFIG_VERSION_VARIABLE */
u_boot_hush_start ();
#endif
+#ifdef CONFIG_AUTO_COMPLETE
+ install_auto_complete();
+#endif
+
#ifdef CONFIG_PREBOOT
if ((p = getenv ("preboot")) != NULL) {
# ifdef CONFIG_AUTOBOOT_KEYED
init_cmd_timeout ();
# endif /* CONFIG_BOOT_RETRY_TIME */
- s = getenv ("bootcmd");
+#ifdef CONFIG_BOOTCOUNT_LIMIT
+ if (bootlimit && (bootcount > bootlimit)) {
+ printf ("Warning: Bootlimit (%u) exceeded. Using altbootcmd.\n",
+ (unsigned)bootlimit);
+ s = getenv ("altbootcmd");
+ }
+ else
+#endif /* CONFIG_BOOTCOUNT_LIMIT */
+ s = getenv ("bootcmd");
debug ("### main_loop: bootcmd=\"%s\"\n", s ? s : "<UNDEFINED>");
s = getenv("menucmd");
if (s) {
# ifndef CFG_HUSH_PARSER
- run_command (s, bd, 0);
+ run_command (s, 0);
# else
parse_string_outer(s, FLAG_PARSE_SEMICOLON |
FLAG_EXIT_FROM_LOOP);
else if (len == -2) {
/* -2 means timed out, retry autoboot
*/
- printf("\nTimed out waiting for command\n");
+ puts ("\nTimed out waiting for command\n");
# ifdef CONFIG_RESET_TO_RETRY
/* Reinit board to run initialization code again */
do_reset (NULL, 0, 0, NULL);
#endif
if (len == -1)
- printf ("<INTERRUPT>\n");
+ puts ("<INTERRUPT>\n");
else
rc = run_command (lastcommand, flag);
char *s = getenv ("bootretry");
if (s != NULL)
- retry_time = (int)simple_strtoul(s, NULL, 10);
+ retry_time = (int)simple_strtol(s, NULL, 10);
else
retry_time = CONFIG_BOOT_RETRY_TIME;
puts ("\r\n");
return (p - console_buffer);
+ case '\0': /* nul */
+ continue;
+
case 0x03: /* ^C - break */
console_buffer[0] = '\0'; /* discard input */
return (-1);
*/
if (n < CFG_CBSIZE-2) {
if (c == '\t') { /* expand TABs */
+#ifdef CONFIG_AUTO_COMPLETE
+ /* if auto completion triggered just continue */
+ *p = '\0';
+ if (cmd_auto_complete(prompt, console_buffer, &n, &col)) {
+ p = console_buffer + n; /* reset */
+ continue;
+ }
+#endif
puts (tab_seq+(col&07));
col += 8 - (col&07);
} else {
int inputcnt = strlen (input);
int outputcnt = CFG_CBSIZE;
int state = 0; /* 0 = waiting for '$' */
- /* 1 = waiting for '(' */
- /* 2 = waiting for ')' */
- /* 3 = waiting for ''' */
+ /* 1 = waiting for '(' or '{' */
+ /* 2 = waiting for ')' or '}' */
+ /* 3 = waiting for ''' */
#ifdef DEBUG_PARSER
char *output_start = output;
if (inputcnt-- == 0)
break;
prev = c;
- c = *input++;
+ c = *input++;
}
}
}
break;
case 1: /* Waiting for ( */
- if (c == '(') {
+ if (c == '(' || c == '{') {
state++;
varname_start = input;
} else {
}
break;
case 2: /* Waiting for ) */
- if (c == ')') {
+ if (c == ')' || c == '}') {
int i;
char envname[CFG_CBSIZE], *envval;
int envcnt = input-varname_start-1; /* Varname # of chars */
process_macros (token, finaltoken);
/* Extract arguments */
- argc = parse_line (finaltoken, argv);
+ if ((argc = parse_line (finaltoken, argv)) == 0) {
+ rc = -1; /* no command at all */
+ continue;
+ }
/* Look up command in command table */
if ((cmdtp = find_cmd(argv[0])) == NULL) {
printf ("[%s]\n", finaltoken);
#endif
if (flag & CMD_FLAG_BOOTD) {
- printf ("'bootd' recursion detected\n");
+ puts ("'bootd' recursion detected\n");
rc = -1;
continue;
- }
- else
+ } else {
flag |= CMD_FLAG_BOOTD;
+ }
}
#endif /* CFG_CMD_BOOTD */