From patchwork Sat Dec 17 17:03:14 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 132013 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 E72771007DB for ; Sun, 18 Dec 2011 04:19:18 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 72AAC28342; Sat, 17 Dec 2011 18:18:31 +0100 (CET) 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 ahb3-eoYTxAr; Sat, 17 Dec 2011 18:18:31 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 888BA28349; Sat, 17 Dec 2011 18:17:22 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C4AEF280BF for ; Sat, 17 Dec 2011 18:04:52 +0100 (CET) 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 LJWvP-t-bYgt for ; Sat, 17 Dec 2011 18:04:52 +0100 (CET) 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-ee0-f44.google.com (mail-ee0-f44.google.com [74.125.83.44]) by theia.denx.de (Postfix) with ESMTPS id 78FAF28083 for ; Sat, 17 Dec 2011 18:04:52 +0100 (CET) Received: by mail-ee0-f44.google.com with SMTP id c14so2998501eek.3 for ; Sat, 17 Dec 2011 09:04:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=r0cuqMdudVB0EJr/kEOy3TbTzemeGN7O3Up9ODOvj+g=; b=QadZ5TnilW4MBMUtkLaATr4ap/HasayXcSaWEEI5G5jjgI+rlkxN+yHI49zweGCavo Qs78Y+y4hSvx0/DTM7box4ltd/oKSgW60mYdihuy7XYbbizTF1zhP376dVbW3p3Eh0mb 9GPUraG+vNBk8lV3dE30Y8d6H4cyaysWRAZvM= Received: by 10.14.9.160 with SMTP id 32mr1432292eet.63.1324141492321; Sat, 17 Dec 2011 09:04:52 -0800 (PST) Received: from Pali-EliteBook.kolej.mff.cuni.cz (pali.kolej.mff.cuni.cz. [78.128.193.202]) by mx.google.com with ESMTPS id a60sm17652568eeb.4.2011.12.17.09.04.50 (version=SSLv3 cipher=OTHER); Sat, 17 Dec 2011 09:04:51 -0800 (PST) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: u-boot@lists.denx.de Date: Sat, 17 Dec 2011 18:03:14 +0100 Message-Id: <1324141398-14859-12-git-send-email-pali.rohar@gmail.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1324141398-14859-1-git-send-email-pali.rohar@gmail.com> References: <2772527.Czs1Sl5aoH@pali-elitebook> <1324141398-14859-1-git-send-email-pali.rohar@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Sat, 17 Dec 2011 18:17:05 +0100 Cc: Sebastian Reichel , Marcel Mol , Martin Jansa , =?UTF-8?q?Pali=20Roh=C3=A1r?= Subject: [U-Boot] [PATCH 12/16] New config variable CONFIG_MENUCMD X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de * 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 --- 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