[U-Boot] [PATCH 12/16] New config variable CONFIG_MENUCMD

Pali Rohár pali.rohar at gmail.com
Sat Dec 17 18:03:14 CET 2011


 * If defined CONFIG_MENUCMD and CONFIG_MENUKEY to 0 run env "menu_cmd" if key any pressed
 * If defined CONFIG_MENUCMD and other CONFIG_MENUKEY run env "menu_cmd" if key pressed is save as CONFIG_MENUKEY
 * If defined CONFIG_MENUCMD and not CONFIG_MENUKEY run env "menu_cmd" always
 * If not defined CONFIG_MENUCMD do nothing
 * CONFIG_MENUKEY working only if defined CONFIG_MENUCMD and CONFIG_BOOTDELAY >= 0

Signed-off-by: Pali Rohár <pali.rohar at gmail.com>
---
 common/main.c |   32 +++++++++++++++++++++-----------
 1 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/common/main.c b/common/main.c
index 5531130..fc80317 100644
--- a/common/main.c
+++ b/common/main.c
@@ -82,6 +82,19 @@ 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 is defined, but not CONFIG_MENUCMD and/or CONFIG_BOOTDELAY >= 0
+#error define CONFIG_MENUCMD and CONFIG_BOOTDELAY too
+#endif
+
+#ifdef CONFIG_MENUCMD
+# ifdef CONFIG_MENUKEY
+static int menucmd = 0;
+# 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 +214,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 +250,9 @@ 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 +302,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 +311,6 @@ void main_loop (void)
 #endif
 
 #if defined(CONFIG_BOOTDELAY) && (CONFIG_BOOTDELAY >= 0)
-	char *s;
 	int bootdelay;
 #endif
 #ifdef CONFIG_PREBOOT
@@ -405,15 +415,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
-- 
1.7.5.4



More information about the U-Boot mailing list