blob: 8e72c265a617e1f2223a008e5375829537b8c49b [file] [log] [blame]
Sjoerd Simons2b22a992015-12-04 23:27:38 +01001/*
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>
Simon Glassdb41d652019-12-28 10:45:07 -070013#include <hang.h>
Sjoerd Simons2b22a992015-12-04 23:27:38 +010014#if !defined(CONFIG_PANIC_HANG)
15#include <command.h>
16#endif
17
18static void panic_finish(void) __attribute__ ((noreturn));
19
20static void panic_finish(void)
21{
22 putc('\n');
23#if defined(CONFIG_PANIC_HANG)
24 hang();
25#else
26 udelay(100000); /* allow messages to go out */
27 do_reset(NULL, 0, 0, NULL);
28#endif
29 while (1)
30 ;
31}
32
33void panic_str(const char *str)
34{
35 puts(str);
36 panic_finish();
37}
38
39void panic(const char *fmt, ...)
40{
Alex Kiernan4f1eed72018-04-19 04:32:55 +000041#if CONFIG_IS_ENABLED(PRINTF)
Sjoerd Simons2b22a992015-12-04 23:27:38 +010042 va_list args;
43 va_start(args, fmt);
44 vprintf(fmt, args);
45 va_end(args);
Alex Kiernan4f1eed72018-04-19 04:32:55 +000046#endif
Sjoerd Simons2b22a992015-12-04 23:27:38 +010047 panic_finish();
48}
Alex Kiernane21c03b2018-04-19 04:32:56 +000049
50void __assert_fail(const char *assertion, const char *file, unsigned int line,
51 const char *function)
52{
53 /* This will not return */
54 panic("%s:%u: %s: Assertion `%s' failed.", file, line, function,
55 assertion);
56}