bug.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #ifndef _ASM_POWERPC_BUG_H
  2. #define _ASM_POWERPC_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. #ifdef __powerpc64__
  12. #define BUG_TABLE_ENTRY(label, line, file, func) \
  13. ".llong " #label "\n .long " #line "\n .llong " #file ", " #func "\n"
  14. #define TRAP_OP(ra, rb) "1: tdnei " #ra ", " #rb "\n"
  15. #define DATA_TYPE long long
  16. #else
  17. #define BUG_TABLE_ENTRY(label, line, file, func) \
  18. ".long " #label ", " #line ", " #file ", " #func "\n"
  19. #define TRAP_OP(ra, rb) "1: twnei " #ra ", " #rb "\n"
  20. #define DATA_TYPE int
  21. #endif /* __powerpc64__ */
  22. struct bug_entry {
  23. unsigned long bug_addr;
  24. int line;
  25. const char *file;
  26. const char *function;
  27. };
  28. struct bug_entry *find_bug(unsigned long bugaddr);
  29. /*
  30. * If this bit is set in the line number it means that the trap
  31. * is for WARN_ON rather than BUG or BUG_ON.
  32. */
  33. #define BUG_WARNING_TRAP 0x1000000
  34. #ifdef CONFIG_BUG
  35. #define BUG() do { \
  36. __asm__ __volatile__( \
  37. "1: twi 31,0,0\n" \
  38. ".section __bug_table,\"a\"\n\t" \
  39. BUG_TABLE_ENTRY(1b,%0,%1,%2) \
  40. ".previous" \
  41. : : "i" (__LINE__), "i" (__FILE__), "i" (__FUNCTION__)); \
  42. } while (0)
  43. #define BUG_ON(x) do { \
  44. __asm__ __volatile__( \
  45. TRAP_OP(%0,0) \
  46. ".section __bug_table,\"a\"\n\t" \
  47. BUG_TABLE_ENTRY(1b,%1,%2,%3) \
  48. ".previous" \
  49. : : "r" ((DATA_TYPE)(x)), "i" (__LINE__), \
  50. "i" (__FILE__), "i" (__FUNCTION__)); \
  51. } while (0)
  52. #define WARN_ON(x) do { \
  53. __asm__ __volatile__( \
  54. TRAP_OP(%0,0) \
  55. ".section __bug_table,\"a\"\n\t" \
  56. BUG_TABLE_ENTRY(1b,%1,%2,%3) \
  57. ".previous" \
  58. : : "r" ((DATA_TYPE)(x)), \
  59. "i" (__LINE__ + BUG_WARNING_TRAP), \
  60. "i" (__FILE__), "i" (__FUNCTION__)); \
  61. } while (0)
  62. #define HAVE_ARCH_BUG
  63. #define HAVE_ARCH_BUG_ON
  64. #define HAVE_ARCH_WARN_ON
  65. #endif /* CONFIG_BUG */
  66. #endif /* __ASSEMBLY __ */
  67. #include <asm-generic/bug.h>
  68. #endif /* _ASM_POWERPC_BUG_H */