bug.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. /*
  10. * This can be any undefined 16-bit opcode, meaning
  11. * ((opcode & 0xc000) != 0xc000)
  12. * Anything from 0x0001 to 0x000A (inclusive) will work
  13. */
  14. #define BFIN_BUG_OPCODE 0x0001
  15. #ifdef CONFIG_DEBUG_BUGVERBOSE
  16. #define _BUG_OR_WARN(flags) \
  17. asm volatile( \
  18. "1: .hword %0\n" \
  19. " .section __bug_table,\"a\",@progbits\n" \
  20. "2: .long 1b\n" \
  21. " .long %1\n" \
  22. " .short %2\n" \
  23. " .short %3\n" \
  24. " .org 2b + %4\n" \
  25. " .previous" \
  26. : \
  27. : "i"(BFIN_BUG_OPCODE), "i"(__FILE__), \
  28. "i"(__LINE__), "i"(flags), \
  29. "i"(sizeof(struct bug_entry)))
  30. #else
  31. #define _BUG_OR_WARN(flags) \
  32. asm volatile( \
  33. "1: .hword %0\n" \
  34. " .section __bug_table,\"a\",@progbits\n" \
  35. "2: .long 1b\n" \
  36. " .short %1\n" \
  37. " .org 2b + %2\n" \
  38. " .previous" \
  39. : \
  40. : "i"(BFIN_BUG_OPCODE), "i"(flags), \
  41. "i"(sizeof(struct bug_entry)))
  42. #endif /* CONFIG_DEBUG_BUGVERBOSE */
  43. #define BUG() \
  44. do { \
  45. _BUG_OR_WARN(0); \
  46. unreachable(); \
  47. } while (0)
  48. #define WARN_ON(condition) \
  49. ({ \
  50. int __ret_warn_on = !!(condition); \
  51. if (unlikely(__ret_warn_on)) \
  52. _BUG_OR_WARN(BUGFLAG_WARNING); \
  53. unlikely(__ret_warn_on); \
  54. })
  55. #define HAVE_ARCH_BUG
  56. #define HAVE_ARCH_WARN_ON
  57. #endif
  58. #include <asm-generic/bug.h>
  59. #endif