From patchwork Wed Apr 17 11:02:48 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_Bie=C3=9Fmann?= X-Patchwork-Id: 237207 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 9A68C2C0153 for ; Wed, 17 Apr 2013 21:21:56 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id DAF094A2BD; Wed, 17 Apr 2013 13:21:54 +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 BJnjdG4canWZ; Wed, 17 Apr 2013 13:21:54 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B827E4A2A3; Wed, 17 Apr 2013 13:21:40 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id CE84C4A236 for ; Wed, 17 Apr 2013 13:02:50 +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 lx8Nghd1ikkt for ; Wed, 17 Apr 2013 13:02:49 +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-bk0-f45.google.com (mail-bk0-f45.google.com [209.85.214.45]) by theia.denx.de (Postfix) with ESMTPS id DC55C4A2B3 for ; Wed, 17 Apr 2013 13:02:36 +0200 (CEST) Received: by mail-bk0-f45.google.com with SMTP id j10so705668bkw.18 for ; Wed, 17 Apr 2013 04:02:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=BrI05XH3KPwe33xPR4rW7qXFUsEHvnaJxMsP5I5WW40=; b=06c6Gi2JJQaA3B/wi2MvI+64kQ64LSJjBoyQwnaPLMh64n7uEfc1+DMO+JGPyrwNar WjRa/LgXXOTzFsBLtbS8OqOw+a7DE6WEca/xvgXRr7I85BYIthSkxKpLPeLGrYzcGOSx mmTRI63sEw7AnEC49NoB6LyvL2/r/ADDW/awgGHigLXDFzZNVxfFpzb6J+SPTBInUNoP E6dKdS+LExp6586Dh5jIeeZisryiXY2D2nZuW2pqzw5q6gMKr9p0iObxZUtmeXqqtr9g u6WZuw43+9l62OGiYleHQBOo9XxED9W5/ihRgeTS/LyGsVaRi6rbL93ZusGNu2ZIk4XN V6YQ== X-Received: by 10.205.127.11 with SMTP id gy11mr2062849bkc.54.1366196555784; Wed, 17 Apr 2013 04:02:35 -0700 (PDT) Received: from localhost ([2a01:198:47b:1:210:75ff:fe1a:cd1e]) by mx.google.com with ESMTPS id v8sm1961054bkh.20.2013.04.17.04.02.32 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 17 Apr 2013 04:02:35 -0700 (PDT) From: =?UTF-8?q?Andreas=20Bie=C3=9Fmann?= To: U-Boot Mailing List Date: Wed, 17 Apr 2013 13:02:48 +0200 Message-Id: <1366196568-23008-6-git-send-email-andreas.devel@googlemail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1366196568-23008-1-git-send-email-andreas.devel@googlemail.com> References: <1366107249-24547-1-git-send-email-andreas.devel@googlemail.com> <1366196568-23008-1-git-send-email-andreas.devel@googlemail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 17 Apr 2013 13:21:37 +0200 Cc: Scott McNutt , Kim Phillips , Shinya Kuribayashi , Graeme Russ , Kumar Gala , Macpaul Lin , Andy Fleming , Stefan Roese Subject: [U-Boot] [PATCH v2 5/5] lib: consolidate hang() 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 Delete all occurrences of hang() and provide a generic function. Signed-off-by: Andreas Bießmann --- Changes in v2: * delete all hang() and provide generic lib/hang.c arch/arm/cpu/arm926ejs/mxs/spl_boot.c | 8 +----- arch/arm/cpu/arm926ejs/spear/spl.c | 7 ----- arch/arm/lib/board.c | 7 +---- arch/avr32/lib/board.c | 6 +---- arch/blackfin/lib/board.c | 15 +---------- arch/m68k/lib/board.c | 7 ----- arch/microblaze/lib/board.c | 7 ----- arch/mips/lib/board.c | 8 +----- arch/nds32/lib/board.c | 8 +----- arch/nios2/lib/board.c | 12 +-------- arch/openrisc/lib/board.c | 13 +-------- arch/powerpc/lib/board.c | 10 +------ arch/sandbox/lib/board.c | 8 +----- arch/sh/lib/board.c | 10 +------ arch/sparc/lib/board.c | 10 +------ arch/x86/lib/board.c | 8 +----- common/board_f.c | 6 ----- common/spl/spl.c | 7 ----- drivers/mtd/nand/mxc_nand_spl.c | 10 +------ lib/Makefile | 1 + lib/hang.c | 47 +++++++++++++++++++++++++++++++++ 21 files changed, 62 insertions(+), 153 deletions(-) create mode 100644 lib/hang.c diff --git a/arch/arm/cpu/arm926ejs/mxs/spl_boot.c b/arch/arm/cpu/arm926ejs/mxs/spl_boot.c index 7e70440..6e6ae30 100644 --- a/arch/arm/cpu/arm926ejs/mxs/spl_boot.c +++ b/arch/arm/cpu/arm926ejs/mxs/spl_boot.c @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -148,10 +149,3 @@ inline void board_init_r(gd_t *id, ulong dest_addr) for (;;) ; } - -void hang(void) __attribute__ ((noreturn)); -void hang(void) -{ - for (;;) - ; -} diff --git a/arch/arm/cpu/arm926ejs/spear/spl.c b/arch/arm/cpu/arm926ejs/spear/spl.c index 48e6efb..0101c5d 100644 --- a/arch/arm/cpu/arm926ejs/spear/spl.c +++ b/arch/arm/cpu/arm926ejs/spear/spl.c @@ -31,13 +31,6 @@ #include #include -inline void hang(void) -{ - serial_puts("### ERROR ### Please RESET the board ###\n"); - for (;;) - ; -} - static void ddr_clock_init(void) { struct misc_regs *misc_p = (struct misc_regs *)CONFIG_SPEAR_MISCBASE; diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c index 0521178..39a6cf9 100644 --- a/arch/arm/lib/board.c +++ b/arch/arm/lib/board.c @@ -53,6 +53,7 @@ #include #include #include +#include #include #ifdef CONFIG_BITBANGMII @@ -706,9 +707,3 @@ void board_init_r(gd_t *id, ulong dest_addr) /* NOTREACHED - no way out of command loop except booting */ } - -void hang(void) -{ - puts("### ERROR ### Please RESET the board ###\n"); - for (;;); -} diff --git a/arch/avr32/lib/board.c b/arch/avr32/lib/board.c index 57e07df..42a013c 100644 --- a/arch/avr32/lib/board.c +++ b/arch/avr32/lib/board.c @@ -26,6 +26,7 @@ #include #include #include +#include #ifdef CONFIG_BITBANGMII #include @@ -120,11 +121,6 @@ static int display_banner (void) return 0; } -void hang(void) -{ - for (;;) ; -} - static int display_dram_config (void) { int i; diff --git a/arch/blackfin/lib/board.c b/arch/blackfin/lib/board.c index 75b6c46..6b8686b 100644 --- a/arch/blackfin/lib/board.c +++ b/arch/blackfin/lib/board.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -432,17 +433,3 @@ void board_init_r(gd_t * id, ulong dest_addr) for (;;) main_loop(); } - -void hang(void) -{ -#ifdef CONFIG_STATUS_LED - status_led_set(STATUS_LED_BOOT, STATUS_LED_OFF); - status_led_set(STATUS_LED_CRASH, STATUS_LED_BLINKING); -#endif - puts("### ERROR ### Please RESET the board ###\n"); - while (1) - /* If a JTAG emulator is hooked up, we'll automatically trigger - * a breakpoint in it. If one isn't, this is just a NOP. - */ - asm("emuexcpt;"); -} diff --git a/arch/m68k/lib/board.c b/arch/m68k/lib/board.c index adaccfe..b2e3068 100644 --- a/arch/m68k/lib/board.c +++ b/arch/m68k/lib/board.c @@ -663,10 +663,3 @@ void board_init_r (gd_t *id, ulong dest_addr) /* NOTREACHED - no way out of command loop except booting */ } - - -void hang(void) -{ - puts ("### ERROR ### Please RESET the board ###\n"); - for (;;); -} diff --git a/arch/microblaze/lib/board.c b/arch/microblaze/lib/board.c index 846ffe1..2b92ec7 100644 --- a/arch/microblaze/lib/board.c +++ b/arch/microblaze/lib/board.c @@ -193,10 +193,3 @@ void board_init_f(ulong not_used) main_loop(); } } - -void hang(void) -{ - puts("### ERROR ### Please RESET the board ###\n"); - for (;;) - ; -} diff --git a/arch/mips/lib/board.c b/arch/mips/lib/board.c index f19f198..8f8d8bc 100644 --- a/arch/mips/lib/board.c +++ b/arch/mips/lib/board.c @@ -32,6 +32,7 @@ #include #include #include +#include #ifdef CONFIG_BITBANGMII #include @@ -344,10 +345,3 @@ void board_init_r(gd_t *id, ulong dest_addr) /* NOTREACHED - no way out of command loop except booting */ } - -void hang(void) -{ - puts("### ERROR ### Please RESET the board ###\n"); - for (;;) - ; -} diff --git a/arch/nds32/lib/board.c b/arch/nds32/lib/board.c index a7d27fc..f9d9f25 100644 --- a/arch/nds32/lib/board.c +++ b/arch/nds32/lib/board.c @@ -36,6 +36,7 @@ #include #include #include +#include DECLARE_GLOBAL_DATA_PTR; @@ -404,10 +405,3 @@ void board_init_r(gd_t *id, ulong dest_addr) /* NOTREACHED - no way out of command loop except booting */ } - -void hang(void) -{ - puts("### ERROR ### Please RESET the board ###\n"); - for (;;) - ; -} diff --git a/arch/nios2/lib/board.c b/arch/nios2/lib/board.c index 0f2bc7e..5db47d7 100644 --- a/arch/nios2/lib/board.c +++ b/arch/nios2/lib/board.c @@ -30,6 +30,7 @@ #include #include #include +#include #ifdef CONFIG_STATUS_LED #include #endif @@ -162,14 +163,3 @@ void board_init(void) main_loop(); } } - - -/***********************************************************************/ - -void hang(void) -{ - disable_interrupts(); - puts("### ERROR ### Please reset board ###\n"); - for (;;) - ; -} diff --git a/arch/openrisc/lib/board.c b/arch/openrisc/lib/board.c index 85aa189..c74b64a 100644 --- a/arch/openrisc/lib/board.c +++ b/arch/openrisc/lib/board.c @@ -34,6 +34,7 @@ #include #include #include +#include #ifdef CONFIG_STATUS_LED #include #endif @@ -154,15 +155,3 @@ void board_init(void) main_loop(); } } - - -/***********************************************************************/ - -void hang(void) -{ - disable_interrupts(); - puts("### ERROR ### Please reset board ###\n"); - - for (;;) - ; -} diff --git a/arch/powerpc/lib/board.c b/arch/powerpc/lib/board.c index 422b4a3..f306d7d 100644 --- a/arch/powerpc/lib/board.c +++ b/arch/powerpc/lib/board.c @@ -26,6 +26,7 @@ #include #include #include +#include #ifdef CONFIG_8xx #include #endif @@ -1050,15 +1051,6 @@ void board_init_r(gd_t *id, ulong dest_addr) /* NOTREACHED - no way out of command loop except booting */ } -void hang(void) -{ - puts("### ERROR ### Please RESET the board ###\n"); - bootstage_error(BOOTSTAGE_ID_NEED_RESET); - for (;;) - ; -} - - #if 0 /* We could use plain global data, but the resulting code is bigger */ /* * Pointer to initial global data area diff --git a/arch/sandbox/lib/board.c b/arch/sandbox/lib/board.c index 3752fab..bfab0eb 100644 --- a/arch/sandbox/lib/board.c +++ b/arch/sandbox/lib/board.c @@ -44,6 +44,7 @@ #include #include #include +#include #include @@ -276,10 +277,3 @@ void board_init_r(gd_t *id, ulong dest_addr) /* NOTREACHED - no way out of command loop except booting */ } - -void hang(void) -{ - puts("### ERROR ### Please RESET the board ###\n"); - for (;;) - ; -} diff --git a/arch/sh/lib/board.c b/arch/sh/lib/board.c index 6e43acf..be65793 100644 --- a/arch/sh/lib/board.c +++ b/arch/sh/lib/board.c @@ -27,6 +27,7 @@ #include #include #include +#include #ifdef CONFIG_BITBANGMII #include @@ -200,12 +201,3 @@ void sh_generic_init(void) main_loop(); } } - -/***********************************************************************/ - -void hang(void) -{ - puts("Board ERROR\n"); - for (;;) - ; -} diff --git a/arch/sparc/lib/board.c b/arch/sparc/lib/board.c index 79fb4c8..51bf8cf 100644 --- a/arch/sparc/lib/board.c +++ b/arch/sparc/lib/board.c @@ -30,6 +30,7 @@ #include #include #include +#include #if defined(CONFIG_CMD_IDE) #include #endif @@ -411,13 +412,4 @@ void board_init_f(ulong bootflag) } -void hang(void) -{ - puts("### ERROR ### Please RESET the board ###\n"); -#ifdef CONFIG_SHOW_BOOT_PROGRESS - bootstage_error(BOOTSTAGE_ID_NEED_RESET); -#endif - for (;;) ; -} - /************************************************************************/ diff --git a/arch/x86/lib/board.c b/arch/x86/lib/board.c index f372898..2c00004 100644 --- a/arch/x86/lib/board.c +++ b/arch/x86/lib/board.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -264,10 +265,3 @@ void board_init_r(gd_t *id, ulong dest_addr) /* NOTREACHED - no way out of command loop except booting */ } - -void hang(void) -{ - puts("### ERROR ### Please RESET the board ###\n"); - for (;;) - ; -} diff --git a/common/board_f.c b/common/board_f.c index 00ca811..7eaf6b9 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -1003,9 +1003,3 @@ void board_init_f_r(void) hang(); } #endif /* CONFIG_X86 */ - -void hang(void) -{ - puts("### ERROR ### Please RESET the board ###\n"); - for (;;); -} diff --git a/common/spl/spl.c b/common/spl/spl.c index 6715e0d..7ce2d5f 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -48,13 +48,6 @@ struct spl_image_info spl_image; /* Define board data structure */ static bd_t bdata __attribute__ ((section(".data"))); -inline void hang(void) -{ - puts("### ERROR ### Please RESET the board ###\n"); - for (;;) - ; -} - /* * Default function to determine if u-boot or the OS should * be started. This implementation always returns 1. diff --git a/drivers/mtd/nand/mxc_nand_spl.c b/drivers/mtd/nand/mxc_nand_spl.c index 09f23c3..1687bfd 100644 --- a/drivers/mtd/nand/mxc_nand_spl.c +++ b/drivers/mtd/nand/mxc_nand_spl.c @@ -26,6 +26,7 @@ #include #include +#include #include #include #include "mxc_nand.h" @@ -355,12 +356,3 @@ void nand_boot(void) hang(); } } - -/* - * Called in case of an exception. - */ -void hang(void) -{ - /* Loop forever */ - while (1) ; -} diff --git a/lib/Makefile b/lib/Makefile index e901cc7..655ed7f 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -71,6 +71,7 @@ COBJS-$(CONFIG_BCH) += bch.o COBJS-y += crc32.o COBJS-y += ctype.o COBJS-y += div64.o +COBJS-y += hang.o COBJS-y += linux_string.o COBJS-y += string.o COBJS-y += time.o diff --git a/lib/hang.c b/lib/hang.c new file mode 100644 index 0000000..9b6d485 --- /dev/null +++ b/lib/hang.c @@ -0,0 +1,47 @@ +/* + * (C) Copyright 2013 + * Andreas Bießmann + * + * This file consolidates all the different hang() functions implemented in + * u-boot. + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include +#include + +/** + * hang - stop processing by staying in an endless loop + * + * The purpose of this function is to stop further execution of code cause + * something went completely wrong. To catch this and give some feedback to + * the user the one needs to catch the bootstage_error (see + * show_boot_progress()) in the board code. + */ +void hang(void) +{ +#if !defined(CONFIG_SPL_BUILD) || \ + (defined(CONFIG_SPL_BUID) && defined(CONFIG_SPL_LIBCOMMON_SUPPORT)) + puts("### ERROR ### Please RESET the board ###\n"); +#endif + bootstage_error(BOOTSTAGE_ID_NEED_RESET); + for (;;) + ; +}