Becky Bruce | 25433b1 | 2005-09-19 17:01:54 -0500 | [diff] [blame] | 1 | #ifndef _ASM_POWERPC_BUG_H |
| 2 | #define _ASM_POWERPC_BUG_H |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | |
| 4 | /* |
| 5 | * Define an illegal instr to trap on the bug. |
| 6 | * We don't use 0 because that marks the end of a function |
| 7 | * in the ELF ABI. That's "Boo Boo" in case you wonder... |
| 8 | */ |
| 9 | #define BUG_OPCODE .long 0x00b00b00 /* For asm */ |
| 10 | #define BUG_ILLEGAL_INSTR "0x00b00b00" /* For BUG macro */ |
| 11 | |
| 12 | #ifndef __ASSEMBLY__ |
| 13 | |
Becky Bruce | 25433b1 | 2005-09-19 17:01:54 -0500 | [diff] [blame] | 14 | #ifdef __powerpc64__ |
Paul Mackerras | 104dd65 | 2005-11-02 15:19:47 +1100 | [diff] [blame^] | 15 | #define BUG_TABLE_ENTRY ".llong" |
| 16 | #define BUG_TRAP_OP "tdnei" |
Becky Bruce | 25433b1 | 2005-09-19 17:01:54 -0500 | [diff] [blame] | 17 | #else |
Paul Mackerras | 104dd65 | 2005-11-02 15:19:47 +1100 | [diff] [blame^] | 18 | #define BUG_TABLE_ENTRY ".long" |
| 19 | #define BUG_TRAP_OP "twnei" |
Becky Bruce | 25433b1 | 2005-09-19 17:01:54 -0500 | [diff] [blame] | 20 | #endif /* __powerpc64__ */ |
| 21 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | struct bug_entry { |
| 23 | unsigned long bug_addr; |
Paul Mackerras | 89003eb | 2005-11-01 21:54:38 +1100 | [diff] [blame] | 24 | long line; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | const char *file; |
| 26 | const char *function; |
| 27 | }; |
| 28 | |
| 29 | struct bug_entry *find_bug(unsigned long bugaddr); |
| 30 | |
| 31 | /* |
| 32 | * If this bit is set in the line number it means that the trap |
| 33 | * is for WARN_ON rather than BUG or BUG_ON. |
| 34 | */ |
| 35 | #define BUG_WARNING_TRAP 0x1000000 |
| 36 | |
Matt Mackall | c8538a7 | 2005-05-01 08:59:01 -0700 | [diff] [blame] | 37 | #ifdef CONFIG_BUG |
| 38 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | #define BUG() do { \ |
| 40 | __asm__ __volatile__( \ |
| 41 | "1: twi 31,0,0\n" \ |
Paul Mackerras | 104dd65 | 2005-11-02 15:19:47 +1100 | [diff] [blame^] | 42 | ".section __bug_table,\"a\"\n" \ |
| 43 | "\t"BUG_TABLE_ENTRY" 1b,%0,%1,%2\n" \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | ".previous" \ |
| 45 | : : "i" (__LINE__), "i" (__FILE__), "i" (__FUNCTION__)); \ |
| 46 | } while (0) |
| 47 | |
| 48 | #define BUG_ON(x) do { \ |
| 49 | __asm__ __volatile__( \ |
Paul Mackerras | 104dd65 | 2005-11-02 15:19:47 +1100 | [diff] [blame^] | 50 | "1: "BUG_TRAP_OP" %0,0\n" \ |
| 51 | ".section __bug_table,\"a\"\n" \ |
| 52 | "\t"BUG_TABLE_ENTRY" 1b,%1,%2,%3\n" \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | ".previous" \ |
Al Viro | f2cad7a | 2005-11-02 03:10:43 +0000 | [diff] [blame] | 54 | : : "r" ((long)(x)), "i" (__LINE__), \ |
Anton Blanchard | 32818c2 | 2005-08-26 18:34:07 -0700 | [diff] [blame] | 55 | "i" (__FILE__), "i" (__FUNCTION__)); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | } while (0) |
| 57 | |
| 58 | #define WARN_ON(x) do { \ |
| 59 | __asm__ __volatile__( \ |
Paul Mackerras | 104dd65 | 2005-11-02 15:19:47 +1100 | [diff] [blame^] | 60 | "1: "BUG_TRAP_OP" %0,0\n" \ |
| 61 | ".section __bug_table,\"a\"\n" \ |
| 62 | "\t"BUG_TABLE_ENTRY" 1b,%1,%2,%3\n" \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | ".previous" \ |
Al Viro | f2cad7a | 2005-11-02 03:10:43 +0000 | [diff] [blame] | 64 | : : "r" ((long)(x)), \ |
Anton Blanchard | 32818c2 | 2005-08-26 18:34:07 -0700 | [diff] [blame] | 65 | "i" (__LINE__ + BUG_WARNING_TRAP), \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | "i" (__FILE__), "i" (__FUNCTION__)); \ |
| 67 | } while (0) |
| 68 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | #define HAVE_ARCH_BUG |
| 70 | #define HAVE_ARCH_BUG_ON |
| 71 | #define HAVE_ARCH_WARN_ON |
Becky Bruce | 25433b1 | 2005-09-19 17:01:54 -0500 | [diff] [blame] | 72 | #endif /* CONFIG_BUG */ |
| 73 | #endif /* __ASSEMBLY __ */ |
Matt Mackall | c8538a7 | 2005-05-01 08:59:01 -0700 | [diff] [blame] | 74 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | #include <asm-generic/bug.h> |
| 76 | |
Becky Bruce | 25433b1 | 2005-09-19 17:01:54 -0500 | [diff] [blame] | 77 | #endif /* _ASM_POWERPC_BUG_H */ |