bug.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #ifndef _PPC64_BUG_H
  2. #define _PPC64_BUG_H
  3. /*
  4. * Define an illegal instr to trap on the bug.
  5. * We don't use 0 because that marks the end of a function
  6. * in the ELF ABI. That's "Boo Boo" in case you wonder...
  7. */
  8. #define BUG_OPCODE .long 0x00b00b00 /* For asm */
  9. #define BUG_ILLEGAL_INSTR "0x00b00b00" /* For BUG macro */
  10. #ifndef __ASSEMBLY__
  11. struct bug_entry {
  12. unsigned long bug_addr;
  13. long line;
  14. const char *file;
  15. const char *function;
  16. };
  17. struct bug_entry *find_bug(unsigned long bugaddr);
  18. /*
  19. * If this bit is set in the line number it means that the trap
  20. * is for WARN_ON rather than BUG or BUG_ON.
  21. */
  22. #define BUG_WARNING_TRAP 0x1000000
  23. #ifdef CONFIG_BUG
  24. #define BUG() do { \
  25. __asm__ __volatile__( \
  26. "1: twi 31,0,0\n" \
  27. ".section __bug_table,\"a\"\n\t" \
  28. " .llong 1b,%0,%1,%2\n" \
  29. ".previous" \
  30. : : "i" (__LINE__), "i" (__FILE__), "i" (__FUNCTION__)); \
  31. } while (0)
  32. #define BUG_ON(x) do { \
  33. __asm__ __volatile__( \
  34. "1: tdnei %0,0\n" \
  35. ".section __bug_table,\"a\"\n\t" \
  36. " .llong 1b,%1,%2,%3\n" \
  37. ".previous" \
  38. : : "r" ((long long)(x)), "i" (__LINE__), \
  39. "i" (__FILE__), "i" (__FUNCTION__)); \
  40. } while (0)
  41. #define WARN_ON(x) do { \
  42. __asm__ __volatile__( \
  43. "1: tdnei %0,0\n" \
  44. ".section __bug_table,\"a\"\n\t" \
  45. " .llong 1b,%1,%2,%3\n" \
  46. ".previous" \
  47. : : "r" ((long long)(x)), \
  48. "i" (__LINE__ + BUG_WARNING_TRAP), \
  49. "i" (__FILE__), "i" (__FUNCTION__)); \
  50. } while (0)
  51. #define HAVE_ARCH_BUG
  52. #define HAVE_ARCH_BUG_ON
  53. #define HAVE_ARCH_WARN_ON
  54. #endif
  55. #endif
  56. #include <asm-generic/bug.h>
  57. #endif