[U-Boot] [PATCH] make hang() a weak function
Graeme Russ
graeme.russ at gmail.com
Tue Apr 16 15:35:25 CEST 2013
Hi Andreas,
On Tue, Apr 16, 2013 at 11:32 PM, Andreas Bießmann <
andreas.devel at googlemail.com> wrote:
>
> Dear Wolfgang,
>
> On 04/16/2013 03:05 PM, Wolfgang Denk wrote:
> > Dear Andreas,
> >
> > In message <516D4B00.9030102 at gmail.com> you wrote:
> >>
> >>> So it is dead code in mainline, and we will not add it.
> >>
> >> Well, I don't think it is dead code cause the hang() is called in some
ways.
> >> This patch opens just the possibility to specialize the hang() by for
> >> example a specific board. Maybe this could also be used for specific
> >> hang() for different arches when we get closer to the common board
files.
> >
> > I think it is dead code, and not needed nor useful in mainline. I
> > cannot even see how it would be useful for you. hang() is defined to
> > "hang" the CPU, i. e. to make sure the system will remain in the
> > current state. To me this naturally translates into an infinite loop,
> > the implementation of which is completely hardware and architecture
> > independent.
>
> Yes it is independent (or should at least). But there are still slightly
> different versions:
>
> ---8<---
> arch/blackfin/lib/board.c:void hang(void)
> arch/blackfin/lib/board.c-{
> arch/blackfin/lib/board.c-#ifdef CONFIG_STATUS_LED
> arch/blackfin/lib/board.c- status_led_set(STATUS_LED_BOOT,
> STATUS_LED_OFF);
> arch/blackfin/lib/board.c- status_led_set(STATUS_LED_CRASH,
> STATUS_LED_BLINKING);
> --->8---
>
> ---8<---
> arch/arm/lib/board.c:void __hang(void)
> arch/arm/lib/board.c-{
> arch/arm/lib/board.c- puts("### ERROR ### Please RESET the board
###\n");
> arch/arm/lib/board.c- for (;;);
> arch/arm/lib/board.c-}
> --->8---
>
> ---8<---
> arch/powerpc/lib/board.c:void __hang(void)
> arch/powerpc/lib/board.c-{
> arch/powerpc/lib/board.c- puts("### ERROR ### Please RESET the
> board ###\n");
> arch/powerpc/lib/board.c- bootstage_error(BOOTSTAGE_ID_NEED_RESET);
> arch/powerpc/lib/board.c- for (;;)
> --->8---
I think that ultimately there should only be a single hang() function
> > Note that hang() is not supposed to do anything else, it just hangs
> > the system. If you have a debugger attached, you will be able to do a
> > simple stack backtrace and see exactly where you are hanging, and why.
>
> Well, for this specific board I plan to panic() on wrong hardware
> detection (which will in turn call hang()). My requirements say that I
> have to visualize this state then, I thought it would be a good idea to
> blink some lights in the endless loop in hang() for this specific board.
>
> > If you think you need to have specialized code, you are doing
> > something wrong.
>
> Really? How would you solve this requirement?
Doesn't it make sense to use panic()?
Regards,
Graeme
More information about the U-Boot
mailing list