diff options
author | Simon Glass <sjg@chromium.org> | 2011-08-12 15:50:32 -0700 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2011-08-29 10:59:33 -0700 |
commit | 6539b64d87a18763d551b9d49603852c07be2916 (patch) | |
tree | 9bbbe0688c138bb4cc9abaef166ed3a9ee2a6b92 /lib | |
parent | 39ca04024b9c9e5671143c3d390222bc2f9dabb3 (diff) |
Add board_panic_no_console to deal with early critical errors
Change-Id: I1e1cc76214cdb45399cec090677d3164ca2d33eb
Reviewed-on: http://gerrit.chromium.org/gerrit/6065
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Anton Staaf <robotboy@chromium.org>
Tested-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/vsprintf.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 3b924ec5e0d..a12c47fe294 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -24,6 +24,8 @@ # define NUM_TYPE long long #define noinline __attribute__((noinline)) +DECLARE_GLOBAL_DATA_PTR; + const char hex_asc[] = "0123456789abcdef"; #define hex_asc_lo(x) hex_asc[((x) & 0x0f)] #define hex_asc_hi(x) hex_asc[((x) & 0xf0) >> 4] @@ -714,13 +716,33 @@ int sprintf(char * buf, const char *fmt, ...) return i; } +/* 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); + } + #if defined (CONFIG_PANIC_HANG) hang(); #else |