Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _PARISC_BUG_H |
| 2 | #define _PARISC_BUG_H |
| 3 | |
James Bottomley | f1ea8b6 | 2012-06-03 01:49:32 -0700 | [diff] [blame] | 4 | #include <linux/kernel.h> /* for BUGFLAG_TAINT */ |
| 5 | |
Helge Deller | 6891f8a | 2006-12-16 16:16:50 +0100 | [diff] [blame] | 6 | /* |
| 7 | * Tell the user there is some problem. |
| 8 | * The offending file and line are encoded in the __bug_table section. |
| 9 | */ |
| 10 | |
Matt Mackall | c8538a7 | 2005-05-01 08:59:01 -0700 | [diff] [blame] | 11 | #ifdef CONFIG_BUG |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #define HAVE_ARCH_BUG |
Helge Deller | 6891f8a | 2006-12-16 16:16:50 +0100 | [diff] [blame] | 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 | |
Helge Deller | 0b3d643 | 2007-01-28 14:52:57 +0100 | [diff] [blame] | 19 | #if defined(CONFIG_64BIT) |
| 20 | #define ASM_WORD_INSN ".dword\t" |
Helge Deller | 6891f8a | 2006-12-16 16:16:50 +0100 | [diff] [blame] | 21 | #else |
Helge Deller | 0b3d643 | 2007-01-28 14:52:57 +0100 | [diff] [blame] | 22 | #define ASM_WORD_INSN ".word\t" |
Helge Deller | 6891f8a | 2006-12-16 16:16:50 +0100 | [diff] [blame] | 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" \ |
Josh Poimboeuf | 325cdac | 2017-07-15 00:10:58 -0500 | [diff] [blame] | 30 | "\t.pushsection __bug_table,\"aw\"\n" \ |
Helge Deller | 0b3d643 | 2007-01-28 14:52:57 +0100 | [diff] [blame] | 31 | "2:\t" ASM_WORD_INSN "1b, %c0\n" \ |
Helge Deller | 6891f8a | 2006-12-16 16:16:50 +0100 | [diff] [blame] | 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)) ); \ |
David Daney | 0592079 | 2009-12-10 17:28:18 +0000 | [diff] [blame] | 37 | unreachable(); \ |
Helge Deller | 6891f8a | 2006-12-16 16:16:50 +0100 | [diff] [blame] | 38 | } while(0) |
| 39 | |
| 40 | #else |
| 41 | #define BUG() \ |
| 42 | do { \ |
| 43 | asm volatile(PARISC_BUG_BREAK_ASM : : ); \ |
David Daney | 0592079 | 2009-12-10 17:28:18 +0000 | [diff] [blame] | 44 | unreachable(); \ |
Helge Deller | 6891f8a | 2006-12-16 16:16:50 +0100 | [diff] [blame] | 45 | } while(0) |
| 46 | #endif |
| 47 | |
Helge Deller | e382876 | 2006-12-16 17:48:26 +0100 | [diff] [blame] | 48 | #ifdef CONFIG_DEBUG_BUGVERBOSE |
Peter Zijlstra | 19d4362 | 2017-02-25 08:56:53 +0100 | [diff] [blame] | 49 | #define __WARN_FLAGS(flags) \ |
Helge Deller | 6891f8a | 2006-12-16 16:16:50 +0100 | [diff] [blame] | 50 | do { \ |
| 51 | asm volatile("\n" \ |
| 52 | "1:\t" PARISC_BUG_BREAK_ASM "\n" \ |
Josh Poimboeuf | 325cdac | 2017-07-15 00:10:58 -0500 | [diff] [blame] | 53 | "\t.pushsection __bug_table,\"aw\"\n" \ |
Helge Deller | 0b3d643 | 2007-01-28 14:52:57 +0100 | [diff] [blame] | 54 | "2:\t" ASM_WORD_INSN "1b, %c0\n" \ |
Helge Deller | 6891f8a | 2006-12-16 16:16:50 +0100 | [diff] [blame] | 55 | "\t.short %c1, %c2\n" \ |
| 56 | "\t.org 2b+%c3\n" \ |
| 57 | "\t.popsection" \ |
| 58 | : : "i" (__FILE__), "i" (__LINE__), \ |
Peter Zijlstra | 19d4362 | 2017-02-25 08:56:53 +0100 | [diff] [blame] | 59 | "i" (BUGFLAG_WARNING|(flags)), \ |
Helge Deller | 6891f8a | 2006-12-16 16:16:50 +0100 | [diff] [blame] | 60 | "i" (sizeof(struct bug_entry)) ); \ |
| 61 | } while(0) |
Helge Deller | e382876 | 2006-12-16 17:48:26 +0100 | [diff] [blame] | 62 | #else |
Peter Zijlstra | 19d4362 | 2017-02-25 08:56:53 +0100 | [diff] [blame] | 63 | #define __WARN_FLAGS(flags) \ |
Helge Deller | e382876 | 2006-12-16 17:48:26 +0100 | [diff] [blame] | 64 | do { \ |
| 65 | asm volatile("\n" \ |
| 66 | "1:\t" PARISC_BUG_BREAK_ASM "\n" \ |
Josh Poimboeuf | 325cdac | 2017-07-15 00:10:58 -0500 | [diff] [blame] | 67 | "\t.pushsection __bug_table,\"aw\"\n" \ |
Helge Deller | 0b3d643 | 2007-01-28 14:52:57 +0100 | [diff] [blame] | 68 | "2:\t" ASM_WORD_INSN "1b\n" \ |
Helge Deller | e382876 | 2006-12-16 17:48:26 +0100 | [diff] [blame] | 69 | "\t.short %c0\n" \ |
| 70 | "\t.org 2b+%c1\n" \ |
| 71 | "\t.popsection" \ |
Peter Zijlstra | 19d4362 | 2017-02-25 08:56:53 +0100 | [diff] [blame] | 72 | : : "i" (BUGFLAG_WARNING|(flags)), \ |
Helge Deller | e382876 | 2006-12-16 17:48:26 +0100 | [diff] [blame] | 73 | "i" (sizeof(struct bug_entry)) ); \ |
| 74 | } while(0) |
| 75 | #endif |
Helge Deller | 6891f8a | 2006-12-16 16:16:50 +0100 | [diff] [blame] | 76 | |
| 77 | |
| 78 | #define WARN_ON(x) ({ \ |
Heiko Carstens | fd0cbdd | 2007-08-02 00:18:38 +0200 | [diff] [blame] | 79 | int __ret_warn_on = !!(x); \ |
Helge Deller | 6891f8a | 2006-12-16 16:16:50 +0100 | [diff] [blame] | 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 | |
Matt Mackall | c8538a7 | 2005-05-01 08:59:01 -0700 | [diff] [blame] | 90 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | |
| 92 | #include <asm-generic/bug.h> |
| 93 | #endif |
Helge Deller | 6891f8a | 2006-12-16 16:16:50 +0100 | [diff] [blame] | 94 | |