bug.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * Copyright (C) 2006 Atmel Corporation
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. */
  8. #ifndef __ASM_AVR32_BUG_H
  9. #define __ASM_AVR32_BUG_H
  10. #ifdef CONFIG_BUG
  11. /*
  12. * According to our Chief Architect, this compact opcode is very
  13. * unlikely to ever be implemented.
  14. */
  15. #define AVR32_BUG_OPCODE 0x5df0
  16. #ifdef CONFIG_DEBUG_BUGVERBOSE
  17. #define _BUG_OR_WARN(flags) \
  18. asm volatile( \
  19. "1: .hword %0\n" \
  20. " .section __bug_table,\"a\",@progbits\n" \
  21. "2: .long 1b\n" \
  22. " .long %1\n" \
  23. " .short %2\n" \
  24. " .short %3\n" \
  25. " .org 2b + %4\n" \
  26. " .previous" \
  27. : \
  28. : "i"(AVR32_BUG_OPCODE), "i"(__FILE__), \
  29. "i"(__LINE__), "i"(flags), \
  30. "i"(sizeof(struct bug_entry)))
  31. #else
  32. #define _BUG_OR_WARN(flags) \
  33. asm volatile( \
  34. "1: .hword %0\n" \
  35. " .section __bug_table,\"a\",@progbits\n" \
  36. "2: .long 1b\n" \
  37. " .short %1\n" \
  38. " .org 2b + %2\n" \
  39. " .previous" \
  40. : \
  41. : "i"(AVR32_BUG_OPCODE), "i"(flags), \
  42. "i"(sizeof(struct bug_entry)))
  43. #endif /* CONFIG_DEBUG_BUGVERBOSE */
  44. #define BUG() \
  45. do { \
  46. _BUG_OR_WARN(0); \
  47. unreachable(); \
  48. } while (0)
  49. #define WARN_ON(condition) \
  50. ({ \
  51. int __ret_warn_on = !!(condition); \
  52. if (unlikely(__ret_warn_on)) \
  53. _BUG_OR_WARN(BUGFLAG_WARNING); \
  54. unlikely(__ret_warn_on); \
  55. })
  56. #define HAVE_ARCH_BUG
  57. #define HAVE_ARCH_WARN_ON
  58. #endif /* CONFIG_BUG */
  59. #include <asm-generic/bug.h>
  60. struct pt_regs;
  61. void die(const char *str, struct pt_regs *regs, long err);
  62. void _exception(long signr, struct pt_regs *regs, int code,
  63. unsigned long addr);
  64. #endif /* __ASM_AVR32_BUG_H */