[PATCH 13/15] New config variable CONFIG_MENU

Pali Rohár pali.rohar at gmail.com
Wed Aug 31 12:08:17 CEST 2011


 * If defined CONFIG_MENU and CONFIG_MENUKEY to 0 run env "menu_cmd" if key any pressed
 * If defined CONFIG_MENU and other CONFIG_MENUKEY run env "menu_cmd" if key pressed is save as CONFIG_MENUKEY
 * If defined CONFIG_MENU and not CONFIG_MENUKEY run env "menu_cmd" always
 * If not defined CONFIG_MENU do nothing
 * CONFIG_MENUKEY working only if defined CONFIG_MENU and CONFIG_BOOTDELAY >= 0
---
 common/main.c |   32 +++++++++++++++++++++-----------
 1 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/common/main.c b/common/main.c
index 3324d9d..f28b250 100644
--- a/common/main.c
+++ b/common/main.c
@@ -81,6 +81,19 @@ int do_mdm_init = 0;
 extern void mdm_init(void); /* defined in board.c */
 #endif
 
+#if defined (CONFIG_MENUKEY) && ! defined (CONFIG_MENU) && ( ! defined(CONFIG_BOOTDELAY) || CONFIG_BOOTDELAY < 0 )
+#error CONFIG_MENUKEY is defined, but not CONFIG_MENU and/or CONFIG_BOOTDELAY >= 0
+#error define CONFIG_MENU and CONFIG_BOOTDELAY too
+#endif
+
+#ifdef CONFIG_MENU
+# 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
@@ -198,10 +211,6 @@ static inline int abortboot(int bootdelay)
 
 # else	/* !defined(CONFIG_AUTOBOOT_KEYED) */
 
-#ifdef CONFIG_MENUKEY
-static int menukey = 0;
-#endif
-
 static inline int abortboot(int bootdelay)
 {
 	int abort = 0;
@@ -235,8 +244,9 @@ static inline 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_MENU) && defined (CONFIG_MENUKEY)
+				if (CONFIG_MENUKEY == 0 || CONFIG_MENUKEY == getc())
+					menucmd = 1;
 # else
 				(void) getc();  /* consume input	*/
 # endif
@@ -264,6 +274,7 @@ static inline int abortboot(int bootdelay)
 
 void main_loop (void)
 {
+	char *s;
 #ifndef CONFIG_SYS_HUSH_PARSER
 	static char lastcommand[CONFIG_SYS_CBSIZE] = { 0, };
 	int len;
@@ -272,7 +283,6 @@ void main_loop (void)
 #endif
 
 #if defined(CONFIG_BOOTDELAY) && (CONFIG_BOOTDELAY >= 0)
-	char *s;
 	int bootdelay;
 #endif
 #ifdef CONFIG_PREBOOT
@@ -387,9 +397,10 @@ void main_loop (void)
 		disable_ctrlc(prev);	/* restore Control C checking */
 # endif
 	}
+#endif /* CONFIG_BOOTDELAY */
 
-# ifdef CONFIG_MENUKEY
-	if (menukey == CONFIG_MENUKEY) {
+#ifdef CONFIG_MENU
+	if (menucmd == 1) {
 		s = getenv("menucmd");
 		if (s) {
 # ifndef CONFIG_SYS_HUSH_PARSER
@@ -400,8 +411,7 @@ void main_loop (void)
 # endif
 		}
 	}
-#endif /* CONFIG_MENUKEY */
-#endif /* CONFIG_BOOTDELAY */
+#endif
 
 	/*
 	 * Main Loop for Monitor Command Processing
-- 
1.7.4.1


--nextPart1511561.nRVgJThL9n
Content-Disposition: attachment; filename="0014-New-config-variable-CONFIG_PREMONITOR.patch"
Content-Transfer-Encoding: 7Bit
Content-Type: text/x-patch; charset="UTF-8"; name="0014-New-config-variable-CONFIG_PREMONITOR.patch"



More information about the U-Boot mailing list