From patchwork Tue Feb 26 16:11:06 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 223327 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 BACA32C0091 for ; Wed, 27 Feb 2013 03:15:49 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id EE1BF4A100; Tue, 26 Feb 2013 17:14:53 +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 3N4y1WZfWCGW; Tue, 26 Feb 2013 17:14:53 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 55F4C4A151; Tue, 26 Feb 2013 17:13:31 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D00FF4A0C5 for ; Tue, 26 Feb 2013 17:13:10 +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 s4ZuncdJn-7b for ; Tue, 26 Feb 2013 17:13:10 +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-qe0-f74.google.com (mail-qe0-f74.google.com [209.85.128.74]) by theia.denx.de (Postfix) with ESMTPS id 163DD4A0BD for ; Tue, 26 Feb 2013 17:13:03 +0100 (CET) Received: by mail-qe0-f74.google.com with SMTP id 1so233024qee.1 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=EkWG/w23ZDslr0iDePgEXn/DvY0ZOfZQGE59OO0/miE=; b=hH2QJv5/1rVzj8sPTc3Ke4v3EfxiTH6KaDDaq9ibif+hsXY+/QVEOwaUWSRu5Yy+Wt n+5qqxd81hS++eoviP7qQc7o1kmkdc7di1YLKSWEHumav0RGKUVdYMAT0H6e7DKv2xUm 1vkqIszhvpRCEJSoLEt7Q8qqPvLGixwQLjGzQrg1aQ34ewVofaVpZp54qrKhDwHAXgTl im84XqixPG9Aa7EfqYljU+qobdUwD/qcu48FPGxGh+j5hXGUtZ9Fh+aCRCVnkvE44y+E +t2legZ98fsMyXAaMcm7SLs/5PDjJsHZ8iW9F4OkWEYmgxfW2zHRKmngrduFafNERlGl R3TA== X-Received: by 10.236.118.137 with SMTP id l9mr9590897yhh.5.1361895181458; 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 f64si64513yhj.7.2013.02.26.08.13.01 (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 3CB745A4173; Tue, 26 Feb 2013 08:13:01 -0800 (PST) Received: by kaka.mtv.corp.google.com (Postfix, from userid 121222) id 1A0351608FB; Tue, 26 Feb 2013 08:13:01 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Date: Tue, 26 Feb 2013 08:11:06 -0800 Message-Id: <1361895069-7343-14-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: ALoCoQlY9hdJdQ3dzHcfRBuSsSBnLqEeTkWUxPo9yJuIWd0+4FWqlnlVsDVBWnb316XOPYSf4ekQ77RMhNXtWFcKvg6b4qJVgKozH+9ZoI+bqDyc+jvj3XPHnYuneTSGZqkePVmDHcJluUhSohZdRC0jtP/bU8u/1tMETgUMy1WhP5UYAKUhXYhUoXsWXB0qHovgLy1xpctg Cc: David Hendrix , Graeme Russ , Joe Hershberger , Tom Rini , Vadim Bendebury Subject: [U-Boot] [PATCH v3 13/16] main: Use autoconf in main_loop() 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 main_loop() over to use autoconf, and add a required prototype to common.h. The do_mdm_init variable is now always defined, but this seems like an acceptable compromise. In fdt_support.h the #ifdef used is CONFIG_OF_LIBFDT. However, even if this is not defined we want to make the functions available for our conditional-compilation scheme. The only place where we really don't have access to these support functions is when USE_HOSTCC is defined. So change the #ifdef to that. Signed-off-by: Simon Glass Reviewed-by: Joe Hershberger --- Changes in v3: - Remove the extra config_of_libfdt() condition in main_loop() Changes in v2: None common/main.c | 77 +++++++++++++++++++++++---------------------------- include/common.h | 1 + include/fdt_support.h | 4 +-- 3 files changed, 37 insertions(+), 45 deletions(-) diff --git a/common/main.c b/common/main.c index 66b74b6..cd068e7 100644 --- a/common/main.c +++ b/common/main.c @@ -63,10 +63,7 @@ static int retry_time = -1; /* -1 so can call readline before main_loop */ #define endtick(seconds) (get_ticks() + (uint64_t)(seconds) * get_tbclk()) -#ifdef CONFIG_MODEM_SUPPORT int do_mdm_init = 0; -extern void mdm_init(void); /* defined in board.c */ -#endif /*************************************************************************** * Watch for 'delay' seconds for autoboot stop or autoboot delay string. @@ -382,51 +379,47 @@ void main_loop(void) int len; int rc = 1; int flag; -#ifdef CONFIG_PREBOOT - char *p; -#endif bootstage_mark_name(BOOTSTAGE_ID_MAIN_LOOP, "main_loop"); -#ifdef CONFIG_MODEM_SUPPORT - debug("DEBUG: main_loop: do_mdm_init=%d\n", do_mdm_init); - if (do_mdm_init) { - char *str = strdup(getenv("mdm_cmd")); - setenv("preboot", str); /* set or delete definition */ - if (str != NULL) - free(str); - mdm_init(); /* wait for modem connection */ + if (autoconf_modem_support()) { + debug("DEBUG: main_loop: do_mdm_init=%d\n", do_mdm_init); + if (do_mdm_init) { + char *str = strdup(getenv("mdm_cmd")); + + setenv("preboot", str); /* set or delete definition */ + if (str != NULL) + free(str); + mdm_init(); /* wait for modem connection */ + } } -#endif /* CONFIG_MODEM_SUPPORT */ -#ifdef CONFIG_VERSION_VARIABLE - { + if (autoconf_version_variable()) setenv("ver", version_string); /* set version variable */ - } -#endif /* CONFIG_VERSION_VARIABLE */ -#ifdef CONFIG_SYS_HUSH_PARSER - u_boot_hush_start(); -#endif + if (autoconf_sys_hush_parser()) + u_boot_hush_start(); -#if defined(CONFIG_HUSH_INIT_VAR) - hush_init_var(); -#endif + if (autoconf_hush_init_var()) + hush_init_var(); + + if (autoconf_preboot()) { + char *p = getenv("preboot"); + + if (p) { + int prev; -#ifdef CONFIG_PREBOOT - p = getenv("preboot"); - if (p) { -# ifdef CONFIG_AUTOBOOT_KEYED - int prev = disable_ctrlc(1); /* disable Control C checking */ -# endif + /* disable Control C checking */ + if (autoconf_autoboot_keyed()) + prev = disable_ctrlc(1); - run_command_list(p, -1, 0); + run_command_list(p, -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); + } } -#endif /* CONFIG_PREBOOT */ if (autoconf_update_tftp()) update_tftp(0UL); @@ -434,9 +427,8 @@ void main_loop(void) if (autoconf_has_bootdelay() && autoconf_bootdelay() >= 0) process_boot_delay(); -#if defined CONFIG_OF_CONTROL - set_working_fdt_addr((void *)gd->fdt_blob); -#endif /* CONFIG_OF_CONTROL */ + if (autoconf_of_control()) + set_working_fdt_addr((void *)gd->fdt_blob); /* * Main Loop for Monitor Command Processing @@ -471,14 +463,13 @@ void main_loop(void) } if (len == -1) - puts ("\n"); + puts("\n"); else rc = run_command(lastcommand, flag); - if (rc <= 0) { - /* invalid command or not repeatable, forget it */ + /* If an invalid command or not repeatable, forget it */ + if (rc <= 0) lastcommand[0] = 0; - } } } diff --git a/include/common.h b/include/common.h index 1457349..e5eb882 100644 --- a/include/common.h +++ b/include/common.h @@ -310,6 +310,7 @@ extern ulong monitor_flash_len; int mac_read_from_eeprom(void); extern u8 _binary_dt_dtb_start[]; /* embedded device tree blob */ int set_cpu_clk_info(void); +extern int mdm_init(void); /* defined in board.c */ /** * Show the DRAM size in a board-specific way diff --git a/include/fdt_support.h b/include/fdt_support.h index 2cccc35..cf8f5e0 100644 --- a/include/fdt_support.h +++ b/include/fdt_support.h @@ -24,7 +24,7 @@ #ifndef __FDT_SUPPORT_H #define __FDT_SUPPORT_H -#ifdef CONFIG_OF_LIBFDT +#ifndef USE_HOSTCC #include @@ -132,5 +132,5 @@ static inline int fdt_status_disabled_by_alias(void *fdt, const char* alias) return fdt_set_status_by_alias(fdt, alias, FDT_STATUS_DISABLED, 0); } -#endif /* ifdef CONFIG_OF_LIBFDT */ +#endif /* ifdef USE_HOSTCC */ #endif /* ifndef __FDT_SUPPORT_H */