bug.h 1.7 KB

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