bug.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #ifndef _PARISC_BUG_H
  2. #define _PARISC_BUG_H
  3. #include <linux/kernel.h> /* for BUGFLAG_TAINT */
  4. /*
  5. * Tell the user there is some problem.
  6. * The offending file and line are encoded in the __bug_table section.
  7. */
  8. #ifdef CONFIG_BUG
  9. #define HAVE_ARCH_BUG
  10. #define HAVE_ARCH_WARN_ON
  11. /* the break instruction is used as BUG() marker. */
  12. #define PARISC_BUG_BREAK_ASM "break 0x1f, 0x1fff"
  13. #define PARISC_BUG_BREAK_INSN 0x03ffe01f /* PARISC_BUG_BREAK_ASM */
  14. #if defined(CONFIG_64BIT)
  15. #define ASM_WORD_INSN ".dword\t"
  16. #else
  17. #define ASM_WORD_INSN ".word\t"
  18. #endif
  19. #ifdef CONFIG_DEBUG_BUGVERBOSE
  20. #define BUG() \
  21. do { \
  22. asm volatile("\n" \
  23. "1:\t" PARISC_BUG_BREAK_ASM "\n" \
  24. "\t.pushsection __bug_table,\"a\"\n" \
  25. "2:\t" ASM_WORD_INSN "1b, %c0\n" \
  26. "\t.short %c1, %c2\n" \
  27. "\t.org 2b+%c3\n" \
  28. "\t.popsection" \
  29. : : "i" (__FILE__), "i" (__LINE__), \
  30. "i" (0), "i" (sizeof(struct bug_entry)) ); \
  31. unreachable(); \
  32. } while(0)
  33. #else
  34. #define BUG() \
  35. do { \
  36. asm volatile(PARISC_BUG_BREAK_ASM : : ); \
  37. unreachable(); \
  38. } while(0)
  39. #endif
  40. #ifdef CONFIG_DEBUG_BUGVERBOSE
  41. #define __WARN_TAINT(taint) \
  42. do { \
  43. asm volatile("\n" \
  44. "1:\t" PARISC_BUG_BREAK_ASM "\n" \
  45. "\t.pushsection __bug_table,\"a\"\n" \
  46. "2:\t" ASM_WORD_INSN "1b, %c0\n" \
  47. "\t.short %c1, %c2\n" \
  48. "\t.org 2b+%c3\n" \
  49. "\t.popsection" \
  50. : : "i" (__FILE__), "i" (__LINE__), \
  51. "i" (BUGFLAG_TAINT(taint)), \
  52. "i" (sizeof(struct bug_entry)) ); \
  53. } while(0)
  54. #else
  55. #define __WARN_TAINT(taint) \
  56. do { \
  57. asm volatile("\n" \
  58. "1:\t" PARISC_BUG_BREAK_ASM "\n" \
  59. "\t.pushsection __bug_table,\"a\"\n" \
  60. "2:\t" ASM_WORD_INSN "1b\n" \
  61. "\t.short %c0\n" \
  62. "\t.org 2b+%c1\n" \
  63. "\t.popsection" \
  64. : : "i" (BUGFLAG_TAINT(taint)), \
  65. "i" (sizeof(struct bug_entry)) ); \
  66. } while(0)
  67. #endif
  68. #define WARN_ON(x) ({ \
  69. int __ret_warn_on = !!(x); \
  70. if (__builtin_constant_p(__ret_warn_on)) { \
  71. if (__ret_warn_on) \
  72. __WARN(); \
  73. } else { \
  74. if (unlikely(__ret_warn_on)) \
  75. __WARN(); \
  76. } \
  77. unlikely(__ret_warn_on); \
  78. })
  79. #endif
  80. #include <asm-generic/bug.h>
  81. #endif