Sjoerd Simons | 2b22a99 | 2015-12-04 23:27:38 +0100 | [diff] [blame] | 1 | /* |
| 2 | * linux/lib/vsprintf.c |
| 3 | * |
| 4 | * Copyright (C) 1991, 1992 Linus Torvalds |
| 5 | */ |
| 6 | |
| 7 | /* vsprintf.c -- Lars Wirzenius & Linus Torvalds. */ |
| 8 | /* |
| 9 | * Wirzenius wrote this portably, Torvalds fucked it up :-) |
| 10 | */ |
| 11 | |
| 12 | #include <common.h> |
| 13 | #if !defined(CONFIG_PANIC_HANG) |
| 14 | #include <command.h> |
| 15 | #endif |
| 16 | |
| 17 | static void panic_finish(void) __attribute__ ((noreturn)); |
| 18 | |
| 19 | static void panic_finish(void) |
| 20 | { |
| 21 | putc('\n'); |
| 22 | #if defined(CONFIG_PANIC_HANG) |
| 23 | hang(); |
| 24 | #else |
| 25 | udelay(100000); /* allow messages to go out */ |
| 26 | do_reset(NULL, 0, 0, NULL); |
| 27 | #endif |
| 28 | while (1) |
| 29 | ; |
| 30 | } |
| 31 | |
| 32 | void panic_str(const char *str) |
| 33 | { |
| 34 | puts(str); |
| 35 | panic_finish(); |
| 36 | } |
| 37 | |
| 38 | void panic(const char *fmt, ...) |
| 39 | { |
Alex Kiernan | 4f1eed7 | 2018-04-19 04:32:55 +0000 | [diff] [blame] | 40 | #if CONFIG_IS_ENABLED(PRINTF) |
Sjoerd Simons | 2b22a99 | 2015-12-04 23:27:38 +0100 | [diff] [blame] | 41 | va_list args; |
| 42 | va_start(args, fmt); |
| 43 | vprintf(fmt, args); |
| 44 | va_end(args); |
Alex Kiernan | 4f1eed7 | 2018-04-19 04:32:55 +0000 | [diff] [blame] | 45 | #endif |
Sjoerd Simons | 2b22a99 | 2015-12-04 23:27:38 +0100 | [diff] [blame] | 46 | panic_finish(); |
| 47 | } |
Alex Kiernan | e21c03b | 2018-04-19 04:32:56 +0000 | [diff] [blame^] | 48 | |
| 49 | void __assert_fail(const char *assertion, const char *file, unsigned int line, |
| 50 | const char *function) |
| 51 | { |
| 52 | /* This will not return */ |
| 53 | panic("%s:%u: %s: Assertion `%s' failed.", file, line, function, |
| 54 | assertion); |
| 55 | } |