panic.c 767 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. }