Commit | Line | Data |
---|---|---|
25433b12 BB |
1 | #ifndef _ASM_POWERPC_BUG_H |
2 | #define _ASM_POWERPC_BUG_H | |
88ced031 | 3 | #ifdef __KERNEL__ |
1da177e4 | 4 | |
3ddfbcf1 | 5 | #include <asm/asm-compat.h> |
1da177e4 LT |
6 | /* |
7 | * Define an illegal instr to trap on the bug. | |
8 | * We don't use 0 because that marks the end of a function | |
9 | * in the ELF ABI. That's "Boo Boo" in case you wonder... | |
10 | */ | |
11 | #define BUG_OPCODE .long 0x00b00b00 /* For asm */ | |
12 | #define BUG_ILLEGAL_INSTR "0x00b00b00" /* For BUG macro */ | |
13 | ||
14 | #ifndef __ASSEMBLY__ | |
15 | ||
16 | struct bug_entry { | |
17 | unsigned long bug_addr; | |
89003ebf | 18 | long line; |
1da177e4 LT |
19 | const char *file; |
20 | const char *function; | |
21 | }; | |
22 | ||
23 | struct bug_entry *find_bug(unsigned long bugaddr); | |
24 | ||
25 | /* | |
26 | * If this bit is set in the line number it means that the trap | |
27 | * is for WARN_ON rather than BUG or BUG_ON. | |
28 | */ | |
29 | #define BUG_WARNING_TRAP 0x1000000 | |
30 | ||
c8538a7a MM |
31 | #ifdef CONFIG_BUG |
32 | ||
e3f94b85 ME |
33 | /* |
34 | * BUG_ON() and WARN_ON() do their best to cooperate with compile-time | |
35 | * optimisations. However depending on the complexity of the condition | |
36 | * some compiler versions may not produce optimal results. | |
37 | */ | |
38 | ||
1da177e4 LT |
39 | #define BUG() do { \ |
40 | __asm__ __volatile__( \ | |
41 | "1: twi 31,0,0\n" \ | |
104dd65f | 42 | ".section __bug_table,\"a\"\n" \ |
872345b7 | 43 | "\t"PPC_LONG" 1b,%0,%1,%2\n" \ |
1da177e4 LT |
44 | ".previous" \ |
45 | : : "i" (__LINE__), "i" (__FILE__), "i" (__FUNCTION__)); \ | |
46 | } while (0) | |
47 | ||
48 | #define BUG_ON(x) do { \ | |
e3f94b85 ME |
49 | if (__builtin_constant_p(x)) { \ |
50 | if (x) \ | |
51 | BUG(); \ | |
52 | } else { \ | |
53 | __asm__ __volatile__( \ | |
3ddfbcf1 | 54 | "1: "PPC_TLNEI" %0,0\n" \ |
104dd65f | 55 | ".section __bug_table,\"a\"\n" \ |
872345b7 | 56 | "\t"PPC_LONG" 1b,%1,%2,%3\n" \ |
1da177e4 | 57 | ".previous" \ |
f2cad7a8 | 58 | : : "r" ((long)(x)), "i" (__LINE__), \ |
32818c2e | 59 | "i" (__FILE__), "i" (__FUNCTION__)); \ |
e3f94b85 | 60 | } \ |
1da177e4 LT |
61 | } while (0) |
62 | ||
872345b7 | 63 | #define __WARN() do { \ |
1da177e4 | 64 | __asm__ __volatile__( \ |
e3f94b85 ME |
65 | "1: twi 31,0,0\n" \ |
66 | ".section __bug_table,\"a\"\n" \ | |
67 | "\t"PPC_LONG" 1b,%0,%1,%2\n" \ | |
68 | ".previous" \ | |
69 | : : "i" (__LINE__ + BUG_WARNING_TRAP), \ | |
70 | "i" (__FILE__), "i" (__FUNCTION__)); \ | |
71 | } while (0) | |
72 | ||
73 | #define WARN_ON(x) do { \ | |
74 | if (__builtin_constant_p(x)) { \ | |
75 | if (x) \ | |
872345b7 | 76 | __WARN(); \ |
e3f94b85 ME |
77 | } else { \ |
78 | __asm__ __volatile__( \ | |
3ddfbcf1 | 79 | "1: "PPC_TLNEI" %0,0\n" \ |
104dd65f | 80 | ".section __bug_table,\"a\"\n" \ |
872345b7 | 81 | "\t"PPC_LONG" 1b,%1,%2,%3\n" \ |
1da177e4 | 82 | ".previous" \ |
f2cad7a8 | 83 | : : "r" ((long)(x)), \ |
32818c2e | 84 | "i" (__LINE__ + BUG_WARNING_TRAP), \ |
1da177e4 | 85 | "i" (__FILE__), "i" (__FUNCTION__)); \ |
e3f94b85 | 86 | } \ |
1da177e4 LT |
87 | } while (0) |
88 | ||
1da177e4 LT |
89 | #define HAVE_ARCH_BUG |
90 | #define HAVE_ARCH_BUG_ON | |
91 | #define HAVE_ARCH_WARN_ON | |
25433b12 BB |
92 | #endif /* CONFIG_BUG */ |
93 | #endif /* __ASSEMBLY __ */ | |
c8538a7a | 94 | |
1da177e4 LT |
95 | #include <asm-generic/bug.h> |
96 | ||
88ced031 | 97 | #endif /* __KERNEL__ */ |
25433b12 | 98 | #endif /* _ASM_POWERPC_BUG_H */ |