panic.c 991 B

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