panic.c 1009 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. #include <hang.h>
  12. #if !defined(CONFIG_PANIC_HANG)
  13. #include <command.h>
  14. #endif
  15. static void panic_finish(void) __attribute__ ((noreturn));
  16. static void panic_finish(void)
  17. {
  18. putc('\n');
  19. #if defined(CONFIG_PANIC_HANG)
  20. hang();
  21. #else
  22. udelay(100000); /* allow messages to go out */
  23. do_reset(NULL, 0, 0, NULL);
  24. #endif
  25. while (1)
  26. ;
  27. }
  28. void panic_str(const char *str)
  29. {
  30. puts(str);
  31. panic_finish();
  32. }
  33. void panic(const char *fmt, ...)
  34. {
  35. #if CONFIG_IS_ENABLED(PRINTF)
  36. va_list args;
  37. va_start(args, fmt);
  38. vprintf(fmt, args);
  39. va_end(args);
  40. #endif
  41. panic_finish();
  42. }
  43. void __assert_fail(const char *assertion, const char *file, unsigned int line,
  44. const char *function)
  45. {
  46. /* This will not return */
  47. panic("%s:%u: %s: Assertion `%s' failed.", file, line, function,
  48. assertion);
  49. }