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