bug.h 1.7 KB

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