bug.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #ifndef _ASMARM_BUG_H
  2. #define _ASMARM_BUG_H
  3. #ifdef CONFIG_BUG
  4. /*
  5. * Use a suitable undefined instruction to use for ARM/Thumb2 bug handling.
  6. * We need to be careful not to conflict with those used by other modules and
  7. * the register_undef_hook() system.
  8. */
  9. #ifdef CONFIG_THUMB2_KERNEL
  10. #define BUG_INSTR_VALUE 0xde02
  11. #define BUG_INSTR_TYPE ".hword "
  12. #else
  13. #define BUG_INSTR_VALUE 0xe7f001f2
  14. #define BUG_INSTR_TYPE ".word "
  15. #endif
  16. #define BUG() _BUG(__FILE__, __LINE__, BUG_INSTR_VALUE)
  17. #define _BUG(file, line, value) __BUG(file, line, value)
  18. #ifdef CONFIG_DEBUG_BUGVERBOSE
  19. /*
  20. * The extra indirection is to ensure that the __FILE__ string comes through
  21. * OK. Many version of gcc do not support the asm %c parameter which would be
  22. * preferable to this unpleasantness. We use mergeable string sections to
  23. * avoid multiple copies of the string appearing in the kernel image.
  24. */
  25. #define __BUG(__file, __line, __value) \
  26. do { \
  27. asm volatile("1:\t" BUG_INSTR_TYPE #__value "\n" \
  28. ".pushsection .rodata.str, \"aMS\", %progbits, 1\n" \
  29. "2:\t.asciz " #__file "\n" \
  30. ".popsection\n" \
  31. ".pushsection __bug_table,\"a\"\n" \
  32. "3:\t.word 1b, 2b\n" \
  33. "\t.hword " #__line ", 0\n" \
  34. ".popsection"); \
  35. unreachable(); \
  36. } while (0)
  37. #else /* not CONFIG_DEBUG_BUGVERBOSE */
  38. #define __BUG(__file, __line, __value) \
  39. do { \
  40. asm volatile(BUG_INSTR_TYPE #__value); \
  41. unreachable(); \
  42. } while (0)
  43. #endif /* CONFIG_DEBUG_BUGVERBOSE */
  44. #define HAVE_ARCH_BUG
  45. #endif /* CONFIG_BUG */
  46. #include <asm-generic/bug.h>
  47. #endif