]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - common/cli_readline.c
common: add call to show_activity() in main cmd loop
[karo-tx-uboot.git] / common / cli_readline.c
index cea0b7c81b8f9eb327065844de1666b002de7890..4e821a5cfcf0c963b16b13041372b1896e551851 100644 (file)
@@ -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);
 
@@ -285,6 +272,12 @@ static int cread_line(const char *const prompt, char *buf, unsigned int *len,
                        first = 0;
                }
 
+#ifdef CONFIG_SHOW_ACTIVITY
+               while (!tstc()) {       /* while no incoming data */
+                       show_activity(0);
+                       WATCHDOG_RESET();
+               }
+#endif
                ichar = getcmd_getch();
 
                if ((ichar == '\n') || (ichar == '\r')) {
@@ -484,7 +477,7 @@ static int cread_line(const char *const prompt, char *buf, unsigned int *len,
 
 /****************************************************************************/
 
-int readline(const char *const prompt)
+int cli_readline(const char *const prompt)
 {
        /*
         * If console_buffer isn't 0-length the user will be prompted to modify
@@ -492,11 +485,12 @@ int readline(const char *const prompt)
         */
        console_buffer[0] = '\0';
 
-       return readline_into_buffer(prompt, console_buffer, 0);
+       return cli_readline_into_buffer(prompt, console_buffer, 0);
 }
 
 
-int readline_into_buffer(const char *const prompt, char *buffer, int timeout)
+int cli_readline_into_buffer(const char *const prompt, char *buffer,
+                            int timeout)
 {
        char *p = buffer;
 #ifdef CONFIG_CMDLINE_EDITING
@@ -538,13 +532,8 @@ int readline_into_buffer(const char *const prompt, char *buffer, int timeout)
        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
@@ -636,35 +625,3 @@ int readline_into_buffer(const char *const prompt, char *buffer, int timeout)
        }
 #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