Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _PARISC_BUG_H |
| 2 | #define _PARISC_BUG_H |
| 3 | |
Helge Deller | 6891f8a | 2006-12-16 16:16:50 +0100 | [diff] [blame] | 4 | /* |
| 5 | * Tell the user there is some problem. |
| 6 | * The offending file and line are encoded in the __bug_table section. |
| 7 | */ |
| 8 | |
Matt Mackall | c8538a7 | 2005-05-01 08:59:01 -0700 | [diff] [blame] | 9 | #ifdef CONFIG_BUG |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | #define HAVE_ARCH_BUG |
Helge Deller | 6891f8a | 2006-12-16 16:16:50 +0100 | [diff] [blame] | 11 | #define HAVE_ARCH_WARN_ON |
| 12 | |
| 13 | /* the break instruction is used as BUG() marker. */ |
| 14 | #define PARISC_BUG_BREAK_ASM "break 0x1f, 0x1fff" |
| 15 | #define PARISC_BUG_BREAK_INSN 0x03ffe01f /* PARISC_BUG_BREAK_ASM */ |
| 16 | |
Helge Deller | 0b3d643 | 2007-01-28 14:52:57 +0100 | [diff] [blame] | 17 | #if defined(CONFIG_64BIT) |
| 18 | #define ASM_WORD_INSN ".dword\t" |
Helge Deller | 6891f8a | 2006-12-16 16:16:50 +0100 | [diff] [blame] | 19 | #else |
Helge Deller | 0b3d643 | 2007-01-28 14:52:57 +0100 | [diff] [blame] | 20 | #define ASM_WORD_INSN ".word\t" |
Helge Deller | 6891f8a | 2006-12-16 16:16:50 +0100 | [diff] [blame] | 21 | #endif |
| 22 | |
| 23 | #ifdef CONFIG_DEBUG_BUGVERBOSE |
| 24 | #define BUG() \ |
| 25 | do { \ |
| 26 | asm volatile("\n" \ |
| 27 | "1:\t" PARISC_BUG_BREAK_ASM "\n" \ |
| 28 | "\t.pushsection __bug_table,\"a\"\n" \ |
Helge Deller | 0b3d643 | 2007-01-28 14:52:57 +0100 | [diff] [blame] | 29 | "2:\t" ASM_WORD_INSN "1b, %c0\n" \ |
Helge Deller | 6891f8a | 2006-12-16 16:16:50 +0100 | [diff] [blame] | 30 | "\t.short %c1, %c2\n" \ |
| 31 | "\t.org 2b+%c3\n" \ |
| 32 | "\t.popsection" \ |
| 33 | : : "i" (__FILE__), "i" (__LINE__), \ |
| 34 | "i" (0), "i" (sizeof(struct bug_entry)) ); \ |
| 35 | for(;;) ; \ |
| 36 | } while(0) |
| 37 | |
| 38 | #else |
| 39 | #define BUG() \ |
| 40 | do { \ |
| 41 | asm volatile(PARISC_BUG_BREAK_ASM : : ); \ |
| 42 | for(;;) ; \ |
| 43 | } while(0) |
| 44 | #endif |
| 45 | |
Helge Deller | e382876 | 2006-12-16 17:48:26 +0100 | [diff] [blame] | 46 | #ifdef CONFIG_DEBUG_BUGVERBOSE |
Helge Deller | 6891f8a | 2006-12-16 16:16:50 +0100 | [diff] [blame] | 47 | #define __WARN() \ |
| 48 | do { \ |
| 49 | asm volatile("\n" \ |
| 50 | "1:\t" PARISC_BUG_BREAK_ASM "\n" \ |
| 51 | "\t.pushsection __bug_table,\"a\"\n" \ |
Helge Deller | 0b3d643 | 2007-01-28 14:52:57 +0100 | [diff] [blame] | 52 | "2:\t" ASM_WORD_INSN "1b, %c0\n" \ |
Helge Deller | 6891f8a | 2006-12-16 16:16:50 +0100 | [diff] [blame] | 53 | "\t.short %c1, %c2\n" \ |
| 54 | "\t.org 2b+%c3\n" \ |
| 55 | "\t.popsection" \ |
| 56 | : : "i" (__FILE__), "i" (__LINE__), \ |
| 57 | "i" (BUGFLAG_WARNING), \ |
| 58 | "i" (sizeof(struct bug_entry)) ); \ |
| 59 | } while(0) |
Helge Deller | e382876 | 2006-12-16 17:48:26 +0100 | [diff] [blame] | 60 | #else |
| 61 | #define __WARN() \ |
| 62 | do { \ |
| 63 | asm volatile("\n" \ |
| 64 | "1:\t" PARISC_BUG_BREAK_ASM "\n" \ |
| 65 | "\t.pushsection __bug_table,\"a\"\n" \ |
Helge Deller | 0b3d643 | 2007-01-28 14:52:57 +0100 | [diff] [blame] | 66 | "2:\t" ASM_WORD_INSN "1b\n" \ |
Helge Deller | e382876 | 2006-12-16 17:48:26 +0100 | [diff] [blame] | 67 | "\t.short %c0\n" \ |
| 68 | "\t.org 2b+%c1\n" \ |
| 69 | "\t.popsection" \ |
| 70 | : : "i" (BUGFLAG_WARNING), \ |
| 71 | "i" (sizeof(struct bug_entry)) ); \ |
| 72 | } while(0) |
| 73 | #endif |
Helge Deller | 6891f8a | 2006-12-16 16:16:50 +0100 | [diff] [blame] | 74 | |
| 75 | |
| 76 | #define WARN_ON(x) ({ \ |
Heiko Carstens | fd0cbdd | 2007-08-02 00:18:38 +0200 | [diff] [blame] | 77 | int __ret_warn_on = !!(x); \ |
Helge Deller | 6891f8a | 2006-12-16 16:16:50 +0100 | [diff] [blame] | 78 | if (__builtin_constant_p(__ret_warn_on)) { \ |
| 79 | if (__ret_warn_on) \ |
| 80 | __WARN(); \ |
| 81 | } else { \ |
| 82 | if (unlikely(__ret_warn_on)) \ |
| 83 | __WARN(); \ |
| 84 | } \ |
| 85 | unlikely(__ret_warn_on); \ |
| 86 | }) |
| 87 | |
Matt Mackall | c8538a7 | 2005-05-01 08:59:01 -0700 | [diff] [blame] | 88 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | |
| 90 | #include <asm-generic/bug.h> |
| 91 | #endif |
Helge Deller | 6891f8a | 2006-12-16 16:16:50 +0100 | [diff] [blame] | 92 | |