bug.h 1.9 KB

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