
If not defined CONFIG_MENUCMD do nothing
If CONFIG_MENUKEY is 0 and was pressed any key run env "menu_cmd"
If pressed key was CONFIG_MENUKEY run env "menu_cmd"
If CONFIG_MENUKEY is not defined run env "menu_cmd" always
CONFIG_MENUKEY working if defined CONFIG_MENUCMD and CONFIG_BOOTDELAY >=
0
Signed-off-by: Pali Rohár pali.rohar@gmail.com
So this is just to interrupt autoboot? Why not just report the "menukey" as any other keypress and do it that way?
M
Changes since original version:
- Fixed commit message
common/main.c | 34 +++++++++++++++++++++++----------- 1 files changed, 23 insertions(+), 11 deletions(-)
diff --git a/common/main.c b/common/main.c index e7b5516..503d6c4 100644 --- a/common/main.c +++ b/common/main.c @@ -82,6 +82,20 @@ int do_mdm_init = 0; extern void mdm_init(void); /* defined in board.c */ #endif
+#if defined(CONFIG_MENUKEY) && !defined(CONFIG_MENUCMD) && \ +(!defined(CONFIG_BOOTDELAY) || CONFIG_BOOTDELAY < 0) +#error CONFIG_MENUKEY defined, but not CONFIG_MENUCMD or CONFIG_BOOTDELAY
= 0 +#error define CONFIG_MENUCMD and CONFIG_BOOTDELAY too
+#endif
+#ifdef CONFIG_MENUCMD +# ifdef CONFIG_MENUKEY +static int menucmd; +# else +static int menucmd = 1; +# endif +#endif
/************************************************************************* ** * Watch for 'delay' seconds for autoboot stop or autoboot delay string.
- returns: 0 - no key string, allow autoboot 1 - got key string, abort @@
-201,10 +215,6 @@ int abortboot(int bootdelay)
# else /* !defined(CONFIG_AUTOBOOT_KEYED) */
-#ifdef CONFIG_MENUKEY -static int menukey = 0; -#endif
#ifndef CONFIG_MENU static inline #endif @@ -241,8 +251,10 @@ int abortboot(int bootdelay) if (tstc()) { /* we got a key press */ abort = 1; /* don't auto boot */ bootdelay = 0; /* no more delay */ -# ifdef CONFIG_MENUKEY
menukey = getc();
+# if defined(CONFIG_MENUCMD) && defined(CONFIG_MENUKEY)
if (CONFIG_MENUKEY == 0 ||
CONFIG_MENUKEY == getc())
menucmd = 1;
# else (void) getc(); /* consume input */ # endif @@ -292,6 +304,7 @@ int run_command2(const char *cmd, int flag)
void main_loop (void) {
- char *s;
#ifndef CONFIG_SYS_HUSH_PARSER static char lastcommand[CONFIG_SYS_CBSIZE] = { 0, }; int len; @@ -300,7 +313,6 @@ void main_loop (void) #endif
#if defined(CONFIG_BOOTDELAY) && (CONFIG_BOOTDELAY >= 0)
- char *s; int bootdelay;
#endif #ifdef CONFIG_PREBOOT @@ -405,15 +417,15 @@ void main_loop (void) disable_ctrlc(prev); /* restore Control C checking */ # endif } +#endif /* CONFIG_BOOTDELAY */
-# ifdef CONFIG_MENUKEY
- if (menukey == CONFIG_MENUKEY) {
+#ifdef CONFIG_MENUCMD
- if (menucmd == 1) { s = getenv("menucmd"); if (s) run_command2(s, 0); }
-#endif /* CONFIG_MENUKEY */ -#endif /* CONFIG_BOOTDELAY */ +#endif
/* * Main Loop for Monitor Command Processing