[U-Boot] [PATCH 1/2] Add board_panic_no_console to deal with early critical errors

Graeme Russ graeme.russ at gmail.com
Tue Aug 30 01:15:09 CEST 2011


Hi Simon

On Tue, Aug 30, 2011 at 2:05 AM, Simon Glass <sjg at chromium.org> wrote:
> Tested-by: Simon Glass <sjg at chromium.org>
> Signed-off-by: Simon Glass <sjg at chromium.org>
> ---
>  include/common.h |    8 ++++++++
>  lib/vsprintf.c   |   26 ++++++++++++++++++++++++--
>  2 files changed, 32 insertions(+), 2 deletions(-)
>
> diff --git a/include/common.h b/include/common.h
> index 12a1074..856df9a 100644
> --- a/include/common.h
> +++ b/include/common.h
> @@ -250,6 +250,14 @@ int        last_stage_init(void);
>  extern ulong monitor_flash_len;
>  int mac_read_from_eeprom(void);
>

[snip]

> +/* Provide a default function for when no console is available */
> +static void __board_panic_no_console(const char *msg)
> +{
> +       /* Just return since we can't access the console */
> +}
> +
> +void board_panic_no_console(const char *msg) __attribute__((weak,
> +                                       alias("__board_panic_no_console")));
> +
>  void panic(const char *fmt, ...)
>  {
> +       char str[CONFIG_SYS_PBSIZE];
>        va_list args;
> +
>        va_start(args, fmt);
> -       vprintf(fmt, args);
> -       putc('\n');
> +
> +       /* TODO)sjg): Move to vsnprintf() when available */
> +       vsprintf(str, fmt, args);
>        va_end(args);
> +
> +       if (gd->have_console) {
> +               puts(str);
> +               putc('\n');
> +       } else {
> +               board_panic_no_console(str);
> +       }
> +

This patch highlights why console squelching should be done in console.c.
We are ending up with more and more if (gd->have_console) all over the
place. With the console squelching patch I posted earlier, I think it might
be easier to create a weak 'panic_printf()' which aliases to printf() which
the board can override if it has the ability to generate emergency output
before console is initialised. Console output will be squelched if the
board does not define such an override.

Regards,

Graeme


More information about the U-Boot mailing list