Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | #ifndef __ASM_SH_BUG_H |
2 | #define __ASM_SH_BUG_H | |
3 | ||
44530c69 PM |
4 | #define TRAPA_BUG_OPCODE 0xc33e /* trapa #0x3e */ |
5 | ||
c8538a7a | 6 | #ifdef CONFIG_BUG |
fa691511 PM |
7 | #define HAVE_ARCH_BUG |
8 | #define HAVE_ARCH_WARN_ON | |
dc34d312 | 9 | |
fa691511 PM |
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 | */ | |
dc34d312 | 22 | #ifdef CONFIG_DEBUG_BUGVERBOSE |
fa691511 PM |
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 | |
dc34d312 PM |
37 | |
38 | #define BUG() \ | |
39 | do { \ | |
40 | __asm__ __volatile__ ( \ | |
fa691511 PM |
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))); \ | |
dc34d312 PM |
48 | } while (0) |
49 | ||
fa691511 PM |
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))); \ | |
1da177e4 LT |
61 | } while (0) |
62 | ||
fa691511 PM |
63 | #define WARN_ON(x) ({ \ |
64 | typeof(x) __ret_warn_on = (x); \ | |
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 | }) | |
dc34d312 | 74 | |
fa691511 PM |
75 | struct pt_regs; |
76 | ||
77 | /* arch/sh/kernel/traps.c */ | |
78 | void handle_BUG(struct pt_regs *); | |
dc34d312 PM |
79 | |
80 | #endif /* CONFIG_BUG */ | |
c8538a7a | 81 | |
1da177e4 LT |
82 | #include <asm-generic/bug.h> |
83 | ||
dc34d312 | 84 | #endif /* __ASM_SH_BUG_H */ |