]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
lib: consolidate hang()
authorAndreas Bießmann <andreas.devel@googlemail.com>
Thu, 18 Apr 2013 22:48:50 +0000 (22:48 +0000)
committerTom Rini <trini@ti.com>
Wed, 1 May 2013 20:41:08 +0000 (16:41 -0400)
Delete all occurrences of hang() and provide a generic function.

Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com>
Acked-by: Albert ARIBAUD <albert.u.boot@aribaud.net>
[trini: Modify check around puts() in hang.c slightly]
Signed-off-by: Tom Rini <trini@ti.com>
20 files changed:
arch/arm/cpu/arm926ejs/mxs/spl_boot.c
arch/arm/cpu/arm926ejs/spear/spl.c
arch/arm/lib/board.c
arch/avr32/lib/board.c
arch/blackfin/lib/board.c
arch/m68k/lib/board.c
arch/microblaze/lib/board.c
arch/mips/lib/board.c
arch/nds32/lib/board.c
arch/nios2/lib/board.c
arch/openrisc/lib/board.c
arch/powerpc/lib/board.c
arch/sh/lib/board.c
arch/sparc/lib/board.c
arch/x86/lib/board.c
common/board_f.c
common/spl/spl.c
drivers/mtd/nand/mxc_nand_spl.c
lib/Makefile
lib/hang.c [new file with mode: 0644]

index 7e7044033ec8dc5e62a2c4df9c27c64d517044ab..ed525e58f3d53d0060ede69203601f56b0921bfb 100644 (file)
@@ -148,10 +148,3 @@ inline void board_init_r(gd_t *id, ulong dest_addr)
        for (;;)
                ;
 }
        for (;;)
                ;
 }
-
-void hang(void) __attribute__ ((noreturn));
-void hang(void)
-{
-       for (;;)
-               ;
-}
index 48e6efbc473cb2fb7b5cc8cd182ed9123518aa8a..0101c5dd121278e50b18556c1083a09180ab5dc1 100644 (file)
 #include <asm/arch/spr_misc.h>
 #include <asm/arch/spr_syscntl.h>
 
 #include <asm/arch/spr_misc.h>
 #include <asm/arch/spr_syscntl.h>
 
-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;
 static void ddr_clock_init(void)
 {
        struct misc_regs *misc_p = (struct misc_regs *)CONFIG_SPEAR_MISCBASE;
index 0521178ac3c9bb66c10bcadaae00ea9ef6555ec8..09ab4ad73645a01fffb8f1e696f6bc6db8ff74ae 100644 (file)
@@ -706,9 +706,3 @@ void board_init_r(gd_t *id, ulong dest_addr)
 
        /* NOTREACHED - no way out of command loop except booting */
 }
 
        /* NOTREACHED - no way out of command loop except booting */
 }
-
-void hang(void)
-{
-       puts("### ERROR ### Please RESET the board ###\n");
-       for (;;);
-}
index 57e07dfb89b7fd63d19efe386fad4694182cdc75..ccf862a7fbf2ca3d88b96375e1392eefbca5fe22 100644 (file)
@@ -120,11 +120,6 @@ static int display_banner (void)
        return 0;
 }
 
        return 0;
 }
 
-void hang(void)
-{
-       for (;;) ;
-}
-
 static int display_dram_config (void)
 {
        int i;
 static int display_dram_config (void)
 {
        int i;
index 75b6c463d87ba0348af947a5a1466a51c94aae4b..ccea3b9fb1c9593700c815e93f8275bb4add539f 100644 (file)
@@ -432,17 +432,3 @@ void board_init_r(gd_t * id, ulong dest_addr)
        for (;;)
                main_loop();
 }
        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;");
-}
index adaccfe69eee08db5328950b577feebe4bfaa720..b2e306836412665a9185ebd03e0b6abd10f81701 100644 (file)
@@ -663,10 +663,3 @@ void board_init_r (gd_t *id, ulong dest_addr)
 
        /* NOTREACHED - no way out of command loop except booting */
 }
 
        /* NOTREACHED - no way out of command loop except booting */
 }
-
-
-void hang(void)
-{
-       puts ("### ERROR ### Please RESET the board ###\n");
-       for (;;);
-}
index 3a6d81aa0909e33e2cc82fb9d4dda0ba87bf46df..bb402432c6cdac8c2f1c609bc0bb81f2059da58b 100644 (file)
@@ -195,10 +195,3 @@ void board_init_f(ulong not_used)
                main_loop();
        }
 }
                main_loop();
        }
 }
-
-void hang(void)
-{
-       puts("### ERROR ### Please RESET the board ###\n");
-       for (;;)
-               ;
-}
index f19f198ae98eab8f4069727d94cdc8141eb0c201..fac791520e10444b18d44ccac9e595e945800bba 100644 (file)
@@ -344,10 +344,3 @@ void board_init_r(gd_t *id, ulong dest_addr)
 
        /* NOTREACHED - no way out of command loop except booting */
 }
 
        /* NOTREACHED - no way out of command loop except booting */
 }
-
-void hang(void)
-{
-       puts("### ERROR ### Please RESET the board ###\n");
-       for (;;)
-               ;
-}
index a7d27fc7f8e78ec43ef635f181e84e5209cf16e1..57af1bee9b25864318b95e32e6e58cc2f174e66f 100644 (file)
@@ -404,10 +404,3 @@ void board_init_r(gd_t *id, ulong dest_addr)
 
        /* NOTREACHED - no way out of command loop except booting */
 }
 
        /* NOTREACHED - no way out of command loop except booting */
 }
-
-void hang(void)
-{
-       puts("### ERROR ### Please RESET the board ###\n");
-       for (;;)
-               ;
-}
index 0f2bc7e8ae7afdc837ae6f4ac4363719d4312978..f430ef082ad909d39fad275d75bd6adddd57c3a6 100644 (file)
@@ -162,14 +162,3 @@ void board_init(void)
                main_loop();
        }
 }
                main_loop();
        }
 }
-
-
-/***********************************************************************/
-
-void hang(void)
-{
-       disable_interrupts();
-       puts("### ERROR ### Please reset board ###\n");
-       for (;;)
-               ;
-}
index 85aa1899be02776f602772610a579270eaa37526..630e45fdb178c0e9fe4171c6c62e9d3eb76a87ac 100644 (file)
@@ -154,15 +154,3 @@ void board_init(void)
                main_loop();
        }
 }
                main_loop();
        }
 }
-
-
-/***********************************************************************/
-
-void hang(void)
-{
-       disable_interrupts();
-       puts("### ERROR ### Please reset board ###\n");
-
-       for (;;)
-               ;
-}
index 422b4a39bb8a5c08d2f0f195cbc41902e4fe6ae3..41b22949ff9964d2633d07bb26af77a29938bf39 100644 (file)
@@ -1050,15 +1050,6 @@ void board_init_r(gd_t *id, ulong dest_addr)
        /* NOTREACHED - no way out of command loop except booting */
 }
 
        /* 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
 #if 0  /* We could use plain global data, but the resulting code is bigger */
 /*
  * Pointer to initial global data area
index 6e43acfbd35778165843651f724bf646d368c69c..0789ed055d86b138c6801966922255f6815d159b 100644 (file)
@@ -200,12 +200,3 @@ void sh_generic_init(void)
                main_loop();
        }
 }
                main_loop();
        }
 }
-
-/***********************************************************************/
-
-void hang(void)
-{
-       puts("Board ERROR\n");
-       for (;;)
-               ;
-}
index 79fb4c87eff46f2fc5f2daac458bb8a992b36a0f..fbc535fa09fb6618217724cedb5c024f00c2c908 100644 (file)
@@ -411,13 +411,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 (;;) ;
-}
-
 /************************************************************************/
 /************************************************************************/
index f372898f61276ea0dced65499d613797c9283f27..228c2c82261bafaa352d0e2d268048824fd5664d 100644 (file)
@@ -264,10 +264,3 @@ void board_init_r(gd_t *id, ulong dest_addr)
 
        /* NOTREACHED - no way out of command loop except booting */
 }
 
        /* NOTREACHED - no way out of command loop except booting */
 }
-
-void hang(void)
-{
-       puts("### ERROR ### Please RESET the board ###\n");
-       for (;;)
-               ;
-}
index 3a6638f8ee7c497078bcf82874f1087e0a8fd51a..32e59faa027bc6040fe5ba1cd13ab774b203a904 100644 (file)
@@ -1087,13 +1087,3 @@ void board_init_f_r(void)
        hang();
 }
 #endif /* CONFIG_X86 */
        hang();
 }
 #endif /* CONFIG_X86 */
-
-void hang(void)
-{
-       puts("### ERROR ### Please RESET the board ###\n");
-#ifdef CONFIG_SANDBOX
-       os_exit(0);
-#else
-       for (;;);
-#endif
-}
index 6715e0d203a829053b002ff8bfae87d0e118fdaa..7ce2d5f2149200b18c63d9db82d2f94e5b5da594 100644 (file)
@@ -48,13 +48,6 @@ struct spl_image_info spl_image;
 /* Define board data structure */
 static bd_t bdata __attribute__ ((section(".data")));
 
 /* 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.
 /*
  * Default function to determine if u-boot or the OS should
  * be started. This implementation always returns 1.
index 09f23c30c4ef46a4e5158750fba8d8b2125989ba..edc589e5b7012d650fc14db4e120d3c32db36651 100644 (file)
@@ -355,12 +355,3 @@ void nand_boot(void)
                hang();
        }
 }
                hang();
        }
 }
-
-/*
- * Called in case of an exception.
- */
-void hang(void)
-{
-       /* Loop forever */
-       while (1) ;
-}
index a3131d873f496b3cfce976ae1140daa72bcde471..8f81862b720b8ef44c79549869cd34b5c793f913 100644 (file)
@@ -71,6 +71,7 @@ COBJS-$(CONFIG_BCH) += bch.o
 COBJS-y += crc32.o
 COBJS-y += ctype.o
 COBJS-y += div64.o
 COBJS-y += crc32.o
 COBJS-y += ctype.o
 COBJS-y += div64.o
+COBJS-y += hang.o
 COBJS-y += linux_string.o
 COBJS-$(CONFIG_REGEX) += slre.o
 COBJS-y += string.o
 COBJS-y += linux_string.o
 COBJS-$(CONFIG_REGEX) += slre.o
 COBJS-y += string.o
diff --git a/lib/hang.c b/lib/hang.c
new file mode 100644 (file)
index 0000000..fc1286c
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * (C) Copyright 2013
+ * Andreas Bießmann <andreas.devel@googlemail.com>
+ *
+ * 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 <common.h>
+#include <bootstage.h>
+
+/**
+ * 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 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_LIBCOMMON_SUPPORT) && \
+               defined(CONFIG_SPL_SERIAL_SUPPORT))
+       puts("### ERROR ### Please RESET the board ###\n");
+#endif
+       bootstage_error(BOOTSTAGE_ID_NEED_RESET);
+       for (;;)
+               ;
+}