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