From patchwork Thu Sep 1 11:34:39 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 112888 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id BCD73B6F7B for ; Thu, 1 Sep 2011 21:37:55 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 109542819A; Thu, 1 Sep 2011 13:37:21 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id p-fu+kMbhHfg; Thu, 1 Sep 2011 13:37:20 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1B0AC281D7; Thu, 1 Sep 2011 13:37:14 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id DB7D5281AE for ; Thu, 1 Sep 2011 13:37:10 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id VnXZCMVbskaa for ; Thu, 1 Sep 2011 13:37:10 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-bw0-f44.google.com (mail-bw0-f44.google.com [209.85.214.44]) by theia.denx.de (Postfix) with ESMTPS id 724C5281C5 for ; Thu, 1 Sep 2011 13:37:02 +0200 (CEST) Received: by mail-bw0-f44.google.com with SMTP id r4so1508588bka.3 for ; Thu, 01 Sep 2011 04:37:02 -0700 (PDT) Received: by 10.204.151.212 with SMTP id d20mr888246bkw.43.1314877022136; Thu, 01 Sep 2011 04:37:02 -0700 (PDT) Received: from Pali-EliteBook.kolej.mff.cuni.cz (rohar.kolej.mff.cuni.cz [78.128.193.202]) by mx.google.com with ESMTPS id a17sm159596bku.56.2011.09.01.04.37.00 (version=SSLv3 cipher=OTHER); Thu, 01 Sep 2011 04:37:01 -0700 (PDT) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: u-boot@lists.denx.de Date: Thu, 1 Sep 2011 13:34:39 +0200 Message-Id: <1314876881-9669-13-git-send-email-pali.rohar@gmail.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1314876881-9669-1-git-send-email-pali.rohar@gmail.com> References: <201109011304.46581.marek.vasut@gmail.com> <1314876881-9669-1-git-send-email-pali.rohar@gmail.com> Subject: [U-Boot] [PATCH 13/15] New config variable CONFIG_MENU X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de * 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