Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef __ASM_SH_BUG_H |
| 2 | #define __ASM_SH_BUG_H |
| 3 | |
Paul Mundt | 44530c6 | 2007-05-08 12:14:54 +0900 | [diff] [blame] | 4 | #define TRAPA_BUG_OPCODE 0xc33e /* trapa #0x3e */ |
| 5 | |
Paul Mundt | e1cd93e | 2007-11-08 18:58:00 +0900 | [diff] [blame] | 6 | #ifdef CONFIG_GENERIC_BUG |
Paul Mundt | fa69151 | 2007-03-08 19:41:21 +0900 | [diff] [blame] | 7 | #define HAVE_ARCH_BUG |
| 8 | #define HAVE_ARCH_WARN_ON |
Paul Mundt | dc34d31 | 2006-12-08 17:41:43 +0900 | [diff] [blame] | 9 | |
Paul Mundt | fa69151 | 2007-03-08 19:41:21 +0900 | [diff] [blame] | 10 | /** |
| 11 | * _EMIT_BUG_ENTRY |
| 12 | * %1 - __FILE__ |
| 13 | * %2 - __LINE__ |
| 14 | * %3 - trap type |
| 15 | * %4 - sizeof(struct bug_entry) |
| 16 | * |
| 17 | * The trapa opcode itself sits in %0. |
| 18 | * The %O notation is used to avoid # generation. |
| 19 | * |
| 20 | * The offending file and line are encoded in the __bug_table section. |
| 21 | */ |
Paul Mundt | dc34d31 | 2006-12-08 17:41:43 +0900 | [diff] [blame] | 22 | #ifdef CONFIG_DEBUG_BUGVERBOSE |
Paul Mundt | fa69151 | 2007-03-08 19:41:21 +0900 | [diff] [blame] | 23 | #define _EMIT_BUG_ENTRY \ |
| 24 | "\t.pushsection __bug_table,\"a\"\n" \ |
| 25 | "2:\t.long 1b, %O1\n" \ |
| 26 | "\t.short %O2, %O3\n" \ |
| 27 | "\t.org 2b+%O4\n" \ |
| 28 | "\t.popsection\n" |
| 29 | #else |
| 30 | #define _EMIT_BUG_ENTRY \ |
| 31 | "\t.pushsection __bug_table,\"a\"\n" \ |
| 32 | "2:\t.long 1b\n" \ |
| 33 | "\t.short %O3\n" \ |
| 34 | "\t.org 2b+%O4\n" \ |
| 35 | "\t.popsection\n" |
| 36 | #endif |
Paul Mundt | dc34d31 | 2006-12-08 17:41:43 +0900 | [diff] [blame] | 37 | |
| 38 | #define BUG() \ |
| 39 | do { \ |
| 40 | __asm__ __volatile__ ( \ |
Paul Mundt | fa69151 | 2007-03-08 19:41:21 +0900 | [diff] [blame] | 41 | "1:\t.short %O0\n" \ |
| 42 | _EMIT_BUG_ENTRY \ |
| 43 | : \ |
| 44 | : "n" (TRAPA_BUG_OPCODE), \ |
| 45 | "i" (__FILE__), \ |
| 46 | "i" (__LINE__), "i" (0), \ |
| 47 | "i" (sizeof(struct bug_entry))); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | } while (0) |
| 49 | |
Paul Mundt | fa69151 | 2007-03-08 19:41:21 +0900 | [diff] [blame] | 50 | #define __WARN() \ |
| 51 | do { \ |
| 52 | __asm__ __volatile__ ( \ |
| 53 | "1:\t.short %O0\n" \ |
| 54 | _EMIT_BUG_ENTRY \ |
| 55 | : \ |
| 56 | : "n" (TRAPA_BUG_OPCODE), \ |
| 57 | "i" (__FILE__), \ |
| 58 | "i" (__LINE__), \ |
| 59 | "i" (BUGFLAG_WARNING), \ |
| 60 | "i" (sizeof(struct bug_entry))); \ |
Paul Mundt | dc34d31 | 2006-12-08 17:41:43 +0900 | [diff] [blame] | 61 | } while (0) |
| 62 | |
Paul Mundt | fa69151 | 2007-03-08 19:41:21 +0900 | [diff] [blame] | 63 | #define WARN_ON(x) ({ \ |
Heiko Carstens | fd0cbdd | 2007-08-02 00:18:38 +0200 | [diff] [blame] | 64 | int __ret_warn_on = !!(x); \ |
Paul Mundt | fa69151 | 2007-03-08 19:41:21 +0900 | [diff] [blame] | 65 | if (__builtin_constant_p(__ret_warn_on)) { \ |
| 66 | if (__ret_warn_on) \ |
| 67 | __WARN(); \ |
| 68 | } else { \ |
| 69 | if (unlikely(__ret_warn_on)) \ |
| 70 | __WARN(); \ |
| 71 | } \ |
| 72 | unlikely(__ret_warn_on); \ |
| 73 | }) |
Paul Mundt | dc34d31 | 2006-12-08 17:41:43 +0900 | [diff] [blame] | 74 | |
Paul Mundt | e1cd93e | 2007-11-08 18:58:00 +0900 | [diff] [blame] | 75 | #endif /* CONFIG_GENERIC_BUG */ |
Matt Mackall | c8538a7 | 2005-05-01 08:59:01 -0700 | [diff] [blame] | 76 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | #include <asm-generic/bug.h> |
| 78 | |
Paul Mundt | dc34d31 | 2006-12-08 17:41:43 +0900 | [diff] [blame] | 79 | #endif /* __ASM_SH_BUG_H */ |