Commit c1bb2cd0b6a3d1b152be3686601234b3a363772b
Committed by
Tom Rini
1 parent
1364a0e48a
Exists in
v2017.01-smarct4x
and in
41 other branches
main: Hide the hush/simple details inside cli.c
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>
Showing 4 changed files with 37 additions and 16 deletions Side-by-side Diff
common/cli.c
... | ... | @@ -104,4 +104,26 @@ |
104 | 104 | return 0; |
105 | 105 | } |
106 | 106 | #endif |
107 | + | |
108 | +void cli_loop(void) | |
109 | +{ | |
110 | +#ifdef CONFIG_SYS_HUSH_PARSER | |
111 | + parse_file_outer(); | |
112 | + /* This point is never reached */ | |
113 | + for (;;); | |
114 | +#else | |
115 | + cli_simple_loop(); | |
116 | +#endif /*CONFIG_SYS_HUSH_PARSER*/ | |
117 | +} | |
118 | + | |
119 | +void cli_init(void) | |
120 | +{ | |
121 | +#ifdef CONFIG_SYS_HUSH_PARSER | |
122 | + u_boot_hush_start(); | |
123 | +#endif | |
124 | + | |
125 | +#if defined(CONFIG_HUSH_INIT_VAR) | |
126 | + hush_init_var(); | |
127 | +#endif | |
128 | +} |
common/cli_simple.c
common/main.c
... | ... | @@ -10,7 +10,6 @@ |
10 | 10 | #include <common.h> |
11 | 11 | #include <autoboot.h> |
12 | 12 | #include <cli.h> |
13 | -#include <cli_hush.h> | |
14 | 13 | #include <malloc.h> |
15 | 14 | #include <version.h> |
16 | 15 | |
17 | 16 | |
... | ... | @@ -71,14 +70,8 @@ |
71 | 70 | setenv("ver", version_string); /* set version variable */ |
72 | 71 | #endif /* CONFIG_VERSION_VARIABLE */ |
73 | 72 | |
74 | -#ifdef CONFIG_SYS_HUSH_PARSER | |
75 | - u_boot_hush_start(); | |
76 | -#endif | |
73 | + cli_init(); | |
77 | 74 | |
78 | -#if defined(CONFIG_HUSH_INIT_VAR) | |
79 | - hush_init_var(); | |
80 | -#endif | |
81 | - | |
82 | 75 | run_preboot_environment_command(); |
83 | 76 | |
84 | 77 | #if defined(CONFIG_UPDATE_TFTP) |
85 | 78 | |
... | ... | @@ -89,12 +82,7 @@ |
89 | 82 | /* |
90 | 83 | * Main Loop for Monitor Command Processing |
91 | 84 | */ |
92 | -#ifdef CONFIG_SYS_HUSH_PARSER | |
93 | - parse_file_outer(); | |
94 | - /* This point is never reached */ | |
95 | - for (;;); | |
96 | -#else | |
85 | + | |
97 | 86 | cli_loop(); |
98 | -#endif /*CONFIG_SYS_HUSH_PARSER*/ | |
99 | 87 | } |
include/cli.h
... | ... | @@ -14,7 +14,7 @@ |
14 | 14 | * This will return if we get a timeout waiting for a command. See |
15 | 15 | * CONFIG_BOOT_RETRY_TIME. |
16 | 16 | */ |
17 | -void cli_loop(void); | |
17 | +void cli_simple_loop(void); | |
18 | 18 | |
19 | 19 | /** |
20 | 20 | * cli_simple_run_command() - Execute a command with the simple CLI |
... | ... | @@ -99,6 +99,17 @@ |
99 | 99 | * @return number of arguments |
100 | 100 | */ |
101 | 101 | int cli_simple_parse_line(char *line, char *argv[]); |
102 | + | |
103 | +/** | |
104 | + * Go into the command loop | |
105 | + * | |
106 | + * This will return if we get a timeout waiting for a command, but only for | |
107 | + * the simple parser (not hush). See CONFIG_BOOT_RETRY_TIME. | |
108 | + */ | |
109 | +void cli_loop(void); | |
110 | + | |
111 | +/** Set up the command line interpreter ready for action */ | |
112 | +void cli_init(void); | |
102 | 113 | |
103 | 114 | #define endtick(seconds) (get_ticks() + (uint64_t)(seconds) * get_tbclk()) |
104 | 115 |