Commit | Line | Data |
---|---|---|
25433b12 BB |
1 | #ifndef _ASM_POWERPC_BUG_H |
2 | #define _ASM_POWERPC_BUG_H | |
1da177e4 | 3 | |
3ddfbcf1 | 4 | #include <asm/asm-compat.h> |
1da177e4 LT |
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; | |
89003ebf | 17 | long line; |
1da177e4 LT |
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 | ||
c8538a7a MM |
30 | #ifdef CONFIG_BUG |
31 | ||
1da177e4 LT |
32 | #define BUG() do { \ |
33 | __asm__ __volatile__( \ | |
34 | "1: twi 31,0,0\n" \ | |
104dd65f | 35 | ".section __bug_table,\"a\"\n" \ |
3ddfbcf1 | 36 | "\t"PPC_LONG" 1b,%0,%1,%2\n" \ |
1da177e4 LT |
37 | ".previous" \ |
38 | : : "i" (__LINE__), "i" (__FILE__), "i" (__FUNCTION__)); \ | |
39 | } while (0) | |
40 | ||
41 | #define BUG_ON(x) do { \ | |
42 | __asm__ __volatile__( \ | |
3ddfbcf1 | 43 | "1: "PPC_TLNEI" %0,0\n" \ |
104dd65f | 44 | ".section __bug_table,\"a\"\n" \ |
3ddfbcf1 | 45 | "\t"PPC_LONG" 1b,%1,%2,%3\n" \ |
1da177e4 | 46 | ".previous" \ |
f2cad7a8 | 47 | : : "r" ((long)(x)), "i" (__LINE__), \ |
32818c2e | 48 | "i" (__FILE__), "i" (__FUNCTION__)); \ |
1da177e4 LT |
49 | } while (0) |
50 | ||
51 | #define WARN_ON(x) do { \ | |
52 | __asm__ __volatile__( \ | |
3ddfbcf1 | 53 | "1: "PPC_TLNEI" %0,0\n" \ |
104dd65f | 54 | ".section __bug_table,\"a\"\n" \ |
3ddfbcf1 | 55 | "\t"PPC_LONG" 1b,%1,%2,%3\n" \ |
1da177e4 | 56 | ".previous" \ |
f2cad7a8 | 57 | : : "r" ((long)(x)), \ |
32818c2e | 58 | "i" (__LINE__ + BUG_WARNING_TRAP), \ |
1da177e4 LT |
59 | "i" (__FILE__), "i" (__FUNCTION__)); \ |
60 | } while (0) | |
61 | ||
1da177e4 LT |
62 | #define HAVE_ARCH_BUG |
63 | #define HAVE_ARCH_BUG_ON | |
64 | #define HAVE_ARCH_WARN_ON | |
25433b12 BB |
65 | #endif /* CONFIG_BUG */ |
66 | #endif /* __ASSEMBLY __ */ | |
c8538a7a | 67 | |
1da177e4 LT |
68 | #include <asm-generic/bug.h> |
69 | ||
25433b12 | 70 | #endif /* _ASM_POWERPC_BUG_H */ |