]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | #ifndef _PARISC_BUG_H |
2 | #define _PARISC_BUG_H | |
3 | ||
f1ea8b66 JB |
4 | #include <linux/kernel.h> /* for BUGFLAG_TAINT */ |
5 | ||
6891f8a1 HD |
6 | /* |
7 | * Tell the user there is some problem. | |
8 | * The offending file and line are encoded in the __bug_table section. | |
9 | */ | |
10 | ||
c8538a7a | 11 | #ifdef CONFIG_BUG |
1da177e4 | 12 | #define HAVE_ARCH_BUG |
6891f8a1 HD |
13 | #define HAVE_ARCH_WARN_ON |
14 | ||
15 | /* the break instruction is used as BUG() marker. */ | |
16 | #define PARISC_BUG_BREAK_ASM "break 0x1f, 0x1fff" | |
17 | #define PARISC_BUG_BREAK_INSN 0x03ffe01f /* PARISC_BUG_BREAK_ASM */ | |
18 | ||
0b3d643f HD |
19 | #if defined(CONFIG_64BIT) |
20 | #define ASM_WORD_INSN ".dword\t" | |
6891f8a1 | 21 | #else |
0b3d643f | 22 | #define ASM_WORD_INSN ".word\t" |
6891f8a1 HD |
23 | #endif |
24 | ||
25 | #ifdef CONFIG_DEBUG_BUGVERBOSE | |
26 | #define BUG() \ | |
27 | do { \ | |
28 | asm volatile("\n" \ | |
29 | "1:\t" PARISC_BUG_BREAK_ASM "\n" \ | |
325cdacd | 30 | "\t.pushsection __bug_table,\"aw\"\n" \ |
0b3d643f | 31 | "2:\t" ASM_WORD_INSN "1b, %c0\n" \ |
6891f8a1 HD |
32 | "\t.short %c1, %c2\n" \ |
33 | "\t.org 2b+%c3\n" \ | |
34 | "\t.popsection" \ | |
35 | : : "i" (__FILE__), "i" (__LINE__), \ | |
36 | "i" (0), "i" (sizeof(struct bug_entry)) ); \ | |
05920797 | 37 | unreachable(); \ |
6891f8a1 HD |
38 | } while(0) |
39 | ||
40 | #else | |
41 | #define BUG() \ | |
42 | do { \ | |
43 | asm volatile(PARISC_BUG_BREAK_ASM : : ); \ | |
05920797 | 44 | unreachable(); \ |
6891f8a1 HD |
45 | } while(0) |
46 | #endif | |
47 | ||
e3828764 | 48 | #ifdef CONFIG_DEBUG_BUGVERBOSE |
19d43626 | 49 | #define __WARN_FLAGS(flags) \ |
6891f8a1 HD |
50 | do { \ |
51 | asm volatile("\n" \ | |
52 | "1:\t" PARISC_BUG_BREAK_ASM "\n" \ | |
325cdacd | 53 | "\t.pushsection __bug_table,\"aw\"\n" \ |
0b3d643f | 54 | "2:\t" ASM_WORD_INSN "1b, %c0\n" \ |
6891f8a1 HD |
55 | "\t.short %c1, %c2\n" \ |
56 | "\t.org 2b+%c3\n" \ | |
57 | "\t.popsection" \ | |
58 | : : "i" (__FILE__), "i" (__LINE__), \ | |
19d43626 | 59 | "i" (BUGFLAG_WARNING|(flags)), \ |
6891f8a1 HD |
60 | "i" (sizeof(struct bug_entry)) ); \ |
61 | } while(0) | |
e3828764 | 62 | #else |
19d43626 | 63 | #define __WARN_FLAGS(flags) \ |
e3828764 HD |
64 | do { \ |
65 | asm volatile("\n" \ | |
66 | "1:\t" PARISC_BUG_BREAK_ASM "\n" \ | |
325cdacd | 67 | "\t.pushsection __bug_table,\"aw\"\n" \ |
0b3d643f | 68 | "2:\t" ASM_WORD_INSN "1b\n" \ |
e3828764 HD |
69 | "\t.short %c0\n" \ |
70 | "\t.org 2b+%c1\n" \ | |
71 | "\t.popsection" \ | |
19d43626 | 72 | : : "i" (BUGFLAG_WARNING|(flags)), \ |
e3828764 HD |
73 | "i" (sizeof(struct bug_entry)) ); \ |
74 | } while(0) | |
75 | #endif | |
6891f8a1 HD |
76 | |
77 | ||
78 | #define WARN_ON(x) ({ \ | |
fd0cbdd3 | 79 | int __ret_warn_on = !!(x); \ |
6891f8a1 HD |
80 | if (__builtin_constant_p(__ret_warn_on)) { \ |
81 | if (__ret_warn_on) \ | |
82 | __WARN(); \ | |
83 | } else { \ | |
84 | if (unlikely(__ret_warn_on)) \ | |
85 | __WARN(); \ | |
86 | } \ | |
87 | unlikely(__ret_warn_on); \ | |
88 | }) | |
89 | ||
c8538a7a | 90 | #endif |
1da177e4 LT |
91 | |
92 | #include <asm-generic/bug.h> | |
93 | #endif | |
6891f8a1 | 94 |