summaryrefslogtreecommitdiffstats
path: root/common/cli_readline.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2014-04-10 20:01:30 -0600
committerTom Rini <trini@ti.com>2014-05-29 17:48:21 -0400
commit0098e179e1afacb3cf595c67a98b8739dc7edcde (patch)
treec19140ef37a8f86d6ccd5d2a065239f09cf09121 /common/cli_readline.c
parent30354978ff470470c15caea2566b61b5792ad277 (diff)
downloadtalos-obmc-uboot-0098e179e1afacb3cf595c67a98b8739dc7edcde.tar.gz
talos-obmc-uboot-0098e179e1afacb3cf595c67a98b8739dc7edcde.zip
Move bootretry code into bootretry.c and clean up
This code is only used by one board, so it seems a shame to clutter up the readline code with it. Move it into its own file. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'common/cli_readline.c')
-rw-r--r--common/cli_readline.c60
1 files changed, 5 insertions, 55 deletions
diff --git a/common/cli_readline.c b/common/cli_readline.c
index df446b8c83..9a9fb35b71 100644
--- a/common/cli_readline.c
+++ b/common/cli_readline.c
@@ -10,6 +10,7 @@
*/
#include <common.h>
+#include <bootretry.h>
#include <cli.h>
#include <watchdog.h>
@@ -18,17 +19,8 @@ DECLARE_GLOBAL_DATA_PTR;
static const char erase_seq[] = "\b \b"; /* erase sequence */
static const char tab_seq[] = " "; /* used to expand TABs */
-#ifdef CONFIG_BOOT_RETRY_TIME
-static uint64_t endtime; /* must be set, default is instant timeout */
-static int retry_time = -1; /* -1 so can call readline before main_loop */
-#endif
-
char console_buffer[CONFIG_SYS_CBSIZE + 1]; /* console I/O buffer */
-#ifndef CONFIG_BOOT_RETRY_MIN
-#define CONFIG_BOOT_RETRY_MIN CONFIG_BOOT_RETRY_TIME
-#endif
-
static char *delete_char (char *buffer, char *p, int *colp, int *np, int plen)
{
char *s;
@@ -267,13 +259,8 @@ static int cread_line(const char *const prompt, char *buf, unsigned int *len,
cread_add_str(buf, init_len, 1, &num, &eol_num, buf, *len);
while (1) {
-#ifdef CONFIG_BOOT_RETRY_TIME
- while (!tstc()) { /* while no incoming data */
- if (retry_time >= 0 && get_ticks() > endtime)
- return -2; /* timed out */
- WATCHDOG_RESET();
- }
-#endif
+ if (bootretry_tstc_timeout())
+ return -2; /* timed out */
if (first && timeout) {
uint64_t etime = endtick(timeout);
@@ -539,13 +526,8 @@ int cli_readline_into_buffer(const char *const prompt, char *buffer,
col = plen;
for (;;) {
-#ifdef CONFIG_BOOT_RETRY_TIME
- while (!tstc()) { /* while no incoming data */
- if (retry_time >= 0 && get_ticks() > endtime)
- return -2; /* timed out */
- WATCHDOG_RESET();
- }
-#endif
+ if (bootretry_tstc_timeout())
+ return -2; /* timed out */
WATCHDOG_RESET(); /* Trigger watchdog, if needed */
#ifdef CONFIG_SHOW_ACTIVITY
@@ -637,35 +619,3 @@ int cli_readline_into_buffer(const char *const prompt, char *buffer,
}
#endif
}
-
-#ifdef CONFIG_BOOT_RETRY_TIME
-/***************************************************************************
- * initialize command line timeout
- */
-void init_cmd_timeout(void)
-{
- char *s = getenv("bootretry");
-
- if (s != NULL)
- retry_time = (int)simple_strtol(s, NULL, 10);
- else
- retry_time = CONFIG_BOOT_RETRY_TIME;
-
- if (retry_time >= 0 && retry_time < CONFIG_BOOT_RETRY_MIN)
- retry_time = CONFIG_BOOT_RETRY_MIN;
-}
-
-/***************************************************************************
- * reset command line timeout to retry_time seconds
- */
-void reset_cmd_timeout(void)
-{
- endtime = endtick(retry_time);
-}
-
-void bootretry_dont_retry(void)
-{
- retry_time = -1;
-}
-
-#endif
OpenPOWER on IntegriCloud