bug.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #ifndef __ASM_CRISv10_ARCH_BUG_H
  2. #define __ASM_CRISv10_ARCH_BUG_H
  3. #include <linux/stringify.h>
  4. #ifdef CONFIG_BUG
  5. #ifdef CONFIG_DEBUG_BUGVERBOSE
  6. /* The BUG() macro is used for marking obviously incorrect code paths.
  7. * It will cause a message with the file name and line number to be printed,
  8. * and then cause an oops. The message is actually printed by handle_BUG()
  9. * in arch/cris/kernel/traps.c, and the reason we use this method of storing
  10. * the file name and line number is that we do not want to affect the registers
  11. * by calling printk() before causing the oops.
  12. */
  13. #define BUG_PREFIX 0x0D7F
  14. #define BUG_MAGIC 0x00001234
  15. struct bug_frame {
  16. unsigned short prefix;
  17. unsigned int magic;
  18. unsigned short clear;
  19. unsigned short movu;
  20. unsigned short line;
  21. unsigned short jump;
  22. unsigned char *filename;
  23. };
  24. #if 0
  25. /* Unfortunately this version of the macro does not work due to a problem
  26. * with the compiler (aka a bug) when compiling with -O2, which sometimes
  27. * erroneously causes the second input to be stored in a register...
  28. */
  29. #define BUG() \
  30. __asm__ __volatile__ ("clear.d [" __stringify(BUG_MAGIC) "]\n\t"\
  31. "movu.w %0,$r0\n\t" \
  32. "jump %1\n\t" \
  33. : : "i" (__LINE__), "i" (__FILE__))
  34. #else
  35. /* This version will have to do for now, until the compiler is fixed.
  36. * The drawbacks of this version are that the file name will appear multiple
  37. * times in the .rodata section, and that __LINE__ and __FILE__ can probably
  38. * not be used like this with newer versions of gcc.
  39. */
  40. #define BUG() \
  41. __asm__ __volatile__ ("clear.d [" __stringify(BUG_MAGIC) "]\n\t"\
  42. "movu.w " __stringify(__LINE__) ",$r0\n\t"\
  43. "jump 0f\n\t" \
  44. ".section .rodata\n" \
  45. "0:\t.string \"" __FILE__ "\"\n\t" \
  46. ".previous")
  47. #endif
  48. #else
  49. /* This just causes an oops. */
  50. #define BUG() (*(int *)0 = 0)
  51. #endif
  52. #define HAVE_ARCH_BUG
  53. #endif
  54. #include <asm-generic/bug.h>
  55. #endif