]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
main: Hide the hush/simple details inside cli.c
authorSimon Glass <sjg@chromium.org>
Fri, 11 Apr 2014 02:01:34 +0000 (20:01 -0600)
committerTom Rini <trini@ti.com>
Thu, 29 May 2014 21:51:42 +0000 (17:51 -0400)
Move these details from main (which doesn't care which parser is used) to
cli.c where they belong.

Signed-off-by: Simon Glass <sjg@chromium.org>
common/cli.c
common/cli_simple.c
common/main.c
include/cli.h

index 9cf7ba1bd7948444e0415407152f6d5ab415407f..4ac9b3f017cbe547aa93ad810c02cff10cc15459 100644 (file)
@@ -104,3 +104,25 @@ int do_run(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
        return 0;
 }
 #endif
+
+void cli_loop(void)
+{
+#ifdef CONFIG_SYS_HUSH_PARSER
+       parse_file_outer();
+       /* This point is never reached */
+       for (;;);
+#else
+       cli_simple_loop();
+#endif /*CONFIG_SYS_HUSH_PARSER*/
+}
+
+void cli_init(void)
+{
+#ifdef CONFIG_SYS_HUSH_PARSER
+       u_boot_hush_start();
+#endif
+
+#if defined(CONFIG_HUSH_INIT_VAR)
+       hush_init_var();
+#endif
+}
index bba586ed44e2f9a6c2b2c1c944eb6d4977f3c4d1..413c2eb89ec26fb5d68522ac33e0eddbf679dee2 100644 (file)
@@ -256,7 +256,7 @@ int cli_simple_run_command(const char *cmd, int flag)
        return rc ? rc : repeatable;
 }
 
-void cli_loop(void)
+void cli_simple_loop(void)
 {
        static char lastcommand[CONFIG_SYS_CBSIZE] = { 0, };
 
index b4cf289dc5dfcae2c72c1c86848b981ce9b1d879..8c846c84c804a7e9e561bee292ab745580858847 100644 (file)
@@ -10,7 +10,6 @@
 #include <common.h>
 #include <autoboot.h>
 #include <cli.h>
-#include <cli_hush.h>
 #include <malloc.h>
 #include <version.h>
 
@@ -71,13 +70,7 @@ void main_loop(void)
        setenv("ver", version_string);  /* set version variable */
 #endif /* CONFIG_VERSION_VARIABLE */
 
-#ifdef CONFIG_SYS_HUSH_PARSER
-       u_boot_hush_start();
-#endif
-
-#if defined(CONFIG_HUSH_INIT_VAR)
-       hush_init_var();
-#endif
+       cli_init();
 
        run_preboot_environment_command();
 
@@ -89,11 +82,6 @@ void main_loop(void)
        /*
         * Main Loop for Monitor Command Processing
         */
-#ifdef CONFIG_SYS_HUSH_PARSER
-       parse_file_outer();
-       /* This point is never reached */
-       for (;;);
-#else
+
        cli_loop();
-#endif /*CONFIG_SYS_HUSH_PARSER*/
 }
index 10dbc6665153427c215bed6fffdf65f8a222ef4e..5158976b8dd4db143acc766bb5c66e8eb646fcf0 100644 (file)
@@ -14,7 +14,7 @@
  * This will return if we get a timeout waiting for a command. See
  * CONFIG_BOOT_RETRY_TIME.
  */
-void cli_loop(void);
+void cli_simple_loop(void);
 
 /**
  * cli_simple_run_command() - Execute a command with the simple CLI
@@ -100,6 +100,17 @@ int cli_readline_into_buffer(const char *const prompt, char *buffer,
  */
 int cli_simple_parse_line(char *line, char *argv[]);
 
+/**
+ * Go into the command loop
+ *
+ * This will return if we get a timeout waiting for a command, but only for
+ * the simple parser (not hush). See CONFIG_BOOT_RETRY_TIME.
+ */
+void cli_loop(void);
+
+/** Set up the command line interpreter ready for action */
+void cli_init(void);
+
 #define endtick(seconds) (get_ticks() + (uint64_t)(seconds) * get_tbclk())
 
 #endif