panic.c 730 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. va_list args;
  35. va_start(args, fmt);
  36. vprintf(fmt, args);
  37. va_end(args);
  38. panic_finish();
  39. }