From patchwork Tue Feb 26 16:11:02 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 223323 X-Patchwork-Delegate: trini@ti.com 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 85C7F2C0082 for ; Wed, 27 Feb 2013 03:15:39 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id EE3124A18C; Tue, 26 Feb 2013 17:14:47 +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 2hPwPHPk5uai; Tue, 26 Feb 2013 17:14:47 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 668A44A146; Tue, 26 Feb 2013 17:13:27 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B37374A0C2 for ; Tue, 26 Feb 2013 17:13:08 +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 WXJO5rNyRslt for ; Tue, 26 Feb 2013 17:13:07 +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-qa0-f73.google.com (mail-qa0-f73.google.com [209.85.216.73]) by theia.denx.de (Postfix) with ESMTPS id B29D24A0BE for ; Tue, 26 Feb 2013 17:13:02 +0100 (CET) Received: by mail-qa0-f73.google.com with SMTP id g10so474249qah.0 for ; Tue, 26 Feb 2013 08:13:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=FO5Vy8shFztZ3CR74VS9g3yL0Zplrp2ug/a0T7HWq7s=; b=mWiIJ8L82OAQQKX4SptILiozkF+ZH88mC6WUl65s1j4qlLtseUuR9PyaqPR/2/418a dmvnDT/rstJhIIgxvb2NT2rw8Es42OgIrviUNGxWElr/Z//4wzOI6jvbsbyNiMr2zQIt C9XrqDHGFtLo0rVdChnMxKsO6GzsulI3C+TowL2dysNxHahuwXbQq6qFGMajjGKlEf5U 9kTfirS13FLsornr+kZcqeAn+TpoP04yBAfvNFFHWVmbGSGwehj3vtg/YmtZHPDDUvt9 pePEaMK5JDmdmKj8Zm36vaV+cUCsIcx9p/E2EH8XWRoJKhTFxcE8EY66IQqd1snfFbg6 D+xw== X-Received: by 10.236.131.69 with SMTP id l45mr9339001yhi.10.1361895181010; Tue, 26 Feb 2013 08:13:01 -0800 (PST) Received: from corp2gmr1-2.hot.corp.google.com (corp2gmr1-2.hot.corp.google.com [172.24.189.93]) by gmr-mx.google.com with ESMTPS id t30si64495yhi.6.2013.02.26.08.13.00 (version=TLSv1.1 cipher=AES128-SHA bits=128/128); Tue, 26 Feb 2013 08:13:01 -0800 (PST) Received: from kaka.mtv.corp.google.com (kaka.mtv.corp.google.com [172.22.73.79]) by corp2gmr1-2.hot.corp.google.com (Postfix) with ESMTP id BC0945A427E; Tue, 26 Feb 2013 08:13:00 -0800 (PST) Received: by kaka.mtv.corp.google.com (Postfix, from userid 121222) id 9B29516097F; Tue, 26 Feb 2013 08:13:00 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Date: Tue, 26 Feb 2013 08:11:02 -0800 Message-Id: <1361895069-7343-10-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.8.1.3 In-Reply-To: <1361895069-7343-1-git-send-email-sjg@chromium.org> References: <1361895069-7343-1-git-send-email-sjg@chromium.org> X-Gm-Message-State: ALoCoQmI3UdM5qsPlx5OpJcperhsMhavtrvrjvOitxqaSEBw0tZuO1sbkTtT7V8st0VnZzSx9peukHsJ868TPfJ5d4FG6+4DWCBwWNT6rxsm4ujyQrQNqQ4hfFcFX1N0QynehdT0ktQEdgGsQ6D2sJK7T57ASto2ZrzrO6/vD1inyMQVP+VbT5x9U0cfvgxlFsuEVoe2iF0W Cc: David Hendrix , Graeme Russ , Joe Hershberger , Tom Rini , Vadim Bendebury Subject: [U-Boot] [PATCH v3 09/16] main: Use autoconf for boot_delay code 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: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Convert this function and its children to use autoconf instead of #ifdef. Some header files must now be included unconditionally, so remove some of the #ifdefs from the header section, and put these header files into the right order. Signed-off-by: Simon Glass Acked-by: Joe Hershberger --- Changes in v3: - Simplify code for finding out bootdelay from config or environment Changes in v2: None common/main.c | 107 ++++++++++++++++++++++----------------------------------- include/menu.h | 2 -- 2 files changed, 42 insertions(+), 67 deletions(-) diff --git a/common/main.c b/common/main.c index 8987444..974fc82 100644 --- a/common/main.c +++ b/common/main.c @@ -31,27 +31,17 @@ #include #include #include +#include #include +#include #include -#ifdef CONFIG_MODEM_SUPPORT -#include /* for free() prototype */ -#endif #ifdef CONFIG_SYS_HUSH_PARSER #include #endif -#ifdef CONFIG_OF_CONTROL -#include -#endif - -#ifdef CONFIG_OF_LIBFDT -#include -#endif /* CONFIG_OF_LIBFDT */ - #include #include -#include DECLARE_GLOBAL_DATA_PTR; @@ -258,7 +248,6 @@ static int abortboot(int bootdelay) * printing the error message to console. */ -#ifdef CONFIG_OF_CONTROL static void secure_boot_cmd(char *cmd) { cmd_tbl_t *cmdtp; @@ -311,93 +300,81 @@ static void process_fdt_options(const void *blob) (void *)(autoconf_sys_text_base() + addr)); } } -#endif /* CONFIG_OF_CONTROL */ static void process_boot_delay(void) { -#ifdef CONFIG_BOOTCOUNT_LIMIT unsigned long bootcount = 0; unsigned long bootlimit = 0; -#endif /* CONFIG_BOOTCOUNT_LIMIT */ -#ifdef CONFIG_OF_CONTROL - char *env; -#endif - char *s; + const char *s; int bootdelay; -#ifdef CONFIG_BOOTCOUNT_LIMIT - bootcount = bootcount_load(); - bootcount++; - bootcount_store (bootcount); - setenv_ulong("bootcount", bootcount); - bootlimit = getenv_ulong("bootlimit", 10, 0); -#endif /* CONFIG_BOOTCOUNT_LIMIT */ + if (autoconf_bootcount_limit()) { + bootcount = bootcount_load(); + bootcount++; + bootcount_store(bootcount); + setenv_ulong("bootcount", bootcount); + bootlimit = getenv_ulong("bootlimit", 10, 0); + } - s = getenv ("bootdelay"); - bootdelay = s ? (int)simple_strtol(s, NULL, 10) : autoconf_bootdelay(); + bootdelay = getenv_ulong("bootdelay", 10, autoconf_bootdelay()); debug ("### main_loop entered: bootdelay=%d\n\n", bootdelay); -#if defined(CONFIG_MENU_SHOW) - bootdelay = menu_show(bootdelay); -#endif + if (autoconf_menu_show()) + bootdelay = menu_show(bootdelay); if (autoconf_boot_retry_time()) init_cmd_timeout(); -#ifdef CONFIG_POST - if (gd->flags & GD_FLG_POSTFAIL) { + if (autoconf_post() && (gd->flags & GD_FLG_POSTFAIL)) { s = getenv("failbootcmd"); - } - else -#endif /* CONFIG_POST */ -#ifdef CONFIG_BOOTCOUNT_LIMIT - if (bootlimit && (bootcount > bootlimit)) { + } else if (autoconf_bootcount_limit() && bootlimit && + (bootcount > bootlimit)) { printf ("Warning: Bootlimit (%u) exceeded. Using altbootcmd.\n", (unsigned)bootlimit); s = getenv ("altbootcmd"); - } - else -#endif /* CONFIG_BOOTCOUNT_LIMIT */ + } else { s = getenv ("bootcmd"); -#ifdef CONFIG_OF_CONTROL - /* Allow the fdt to override the boot command */ - env = fdtdec_get_config_string(gd->fdt_blob, "bootcmd"); - if (env) - s = env; + } + if (autoconf_of_control()) { + char *env; - process_fdt_options(gd->fdt_blob); + /* Allow the fdt to override the boot command */ + env = fdtdec_get_config_string(gd->fdt_blob, "bootcmd"); + if (env) + s = env; - /* - * If the bootsecure option was chosen, use secure_boot_cmd(). - * Always use 'env' in this case, since bootsecure requres that the - * bootcmd was specified in the FDT too. - */ - if (fdtdec_get_config_int(gd->fdt_blob, "bootsecure", 0)) - secure_boot_cmd(env); + process_fdt_options(gd->fdt_blob); -#endif /* CONFIG_OF_CONTROL */ + /* + * If the bootsecure option was chosen, use secure_boot_cmd(). + * Always use 'env' in this case, since bootsecure requres that + * the bootcmd was specified in the FDT too. + */ + if (fdtdec_get_config_int(gd->fdt_blob, "bootsecure", 0)) + secure_boot_cmd(env); + } debug ("### main_loop: bootcmd=\"%s\"\n", s ? s : ""); if (bootdelay != -1 && s && !abortboot(bootdelay)) { -# ifdef CONFIG_AUTOBOOT_KEYED - int prev = disable_ctrlc(1); /* disable Control C checking */ -# endif + int prev; + + /* disable Control C checking */ + if (autoconf_autoboot_keyed()) + prev = disable_ctrlc(1); run_command_list(s, -1, 0); -# ifdef CONFIG_AUTOBOOT_KEYED - disable_ctrlc(prev); /* restore Control C checking */ -# endif + /* restore Control C checking */ + if (autoconf_autoboot_keyed()) + disable_ctrlc(prev); } -# ifdef CONFIG_MENUKEY - if (menukey == CONFIG_MENUKEY) { + if (autoconf_menukey() && menukey == autoconf_menukey()) { s = getenv("menucmd"); if (s) run_command_list(s, -1, 0); } -#endif /* CONFIG_MENUKEY */ } /****************************************************************************/ diff --git a/include/menu.h b/include/menu.h index 7af5fdb..1cdcb88 100644 --- a/include/menu.h +++ b/include/menu.h @@ -28,7 +28,5 @@ int menu_item_add(struct menu *m, char *item_key, void *item_data); int menu_destroy(struct menu *m); void menu_display_statusline(struct menu *m); -#if defined(CONFIG_MENU_SHOW) int menu_show(int bootdelay); -#endif #endif /* __MENU_H__ */