bug.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Copyright 2004-2009 Analog Devices Inc.
  3. *
  4. * Licensed under the GPL-2 or later.
  5. */
  6. #ifndef _BLACKFIN_BUG_H
  7. #define _BLACKFIN_BUG_H
  8. #ifdef CONFIG_BUG
  9. #define BFIN_BUG_OPCODE 0xefcd
  10. #ifdef CONFIG_DEBUG_BUGVERBOSE
  11. #define _BUG_OR_WARN(flags) \
  12. asm volatile( \
  13. "1: .hword %0\n" \
  14. " .section __bug_table,\"a\",@progbits\n" \
  15. "2: .long 1b\n" \
  16. " .long %1\n" \
  17. " .short %2\n" \
  18. " .short %3\n" \
  19. " .org 2b + %4\n" \
  20. " .previous" \
  21. : \
  22. : "i"(BFIN_BUG_OPCODE), "i"(__FILE__), \
  23. "i"(__LINE__), "i"(flags), \
  24. "i"(sizeof(struct bug_entry)))
  25. #else
  26. #define _BUG_OR_WARN(flags) \
  27. asm volatile( \
  28. "1: .hword %0\n" \
  29. " .section __bug_table,\"a\",@progbits\n" \
  30. "2: .long 1b\n" \
  31. " .short %1\n" \
  32. " .org 2b + %2\n" \
  33. " .previous" \
  34. : \
  35. : "i"(BFIN_BUG_OPCODE), "i"(flags), \
  36. "i"(sizeof(struct bug_entry)))
  37. #endif /* CONFIG_DEBUG_BUGVERBOSE */
  38. #define BUG() \
  39. do { \
  40. _BUG_OR_WARN(0); \
  41. for (;;); \
  42. } while (0)
  43. #define WARN_ON(condition) \
  44. ({ \
  45. int __ret_warn_on = !!(condition); \
  46. if (unlikely(__ret_warn_on)) \
  47. _BUG_OR_WARN(BUGFLAG_WARNING); \
  48. unlikely(__ret_warn_on); \
  49. })
  50. #define HAVE_ARCH_BUG
  51. #define HAVE_ARCH_WARN_ON
  52. #endif
  53. #include <asm-generic/bug.h>
  54. #endif