]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - include/asm-powerpc/bug.h
powerpc: clean up bug.h further
[karo-tx-linux.git] / include / asm-powerpc / bug.h
1 #ifndef _ASM_POWERPC_BUG_H
2 #define _ASM_POWERPC_BUG_H
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
14 #ifdef __powerpc64__
15 #define BUG_TABLE_ENTRY         ".llong"
16 #define BUG_TRAP_OP             "tdnei"
17 #else 
18 #define BUG_TABLE_ENTRY         ".long"
19 #define BUG_TRAP_OP             "twnei"
20 #endif /* __powerpc64__ */
21
22 struct bug_entry {
23         unsigned long   bug_addr;
24         long            line;
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
37 #ifdef CONFIG_BUG
38
39 #define BUG() do {                                                       \
40         __asm__ __volatile__(                                            \
41                 "1:     twi 31,0,0\n"                                    \
42                 ".section __bug_table,\"a\"\n"                           \
43                 "\t"BUG_TABLE_ENTRY"    1b,%0,%1,%2\n"                   \
44                 ".previous"                                              \
45                 : : "i" (__LINE__), "i" (__FILE__), "i" (__FUNCTION__)); \
46 } while (0)
47
48 #define BUG_ON(x) do {                                          \
49         __asm__ __volatile__(                                   \
50                 "1:     "BUG_TRAP_OP"   %0,0\n"                 \
51                 ".section __bug_table,\"a\"\n"                  \
52                 "\t"BUG_TABLE_ENTRY"    1b,%1,%2,%3\n"          \
53                 ".previous"                                     \
54                 : : "r" ((long)(x)), "i" (__LINE__),            \
55                     "i" (__FILE__), "i" (__FUNCTION__));        \
56 } while (0)
57
58 #define WARN_ON(x) do {                                         \
59         __asm__ __volatile__(                                   \
60                 "1:     "BUG_TRAP_OP"   %0,0\n"                 \
61                 ".section __bug_table,\"a\"\n"                  \
62                 "\t"BUG_TABLE_ENTRY"    1b,%1,%2,%3\n"          \
63                 ".previous"                                     \
64                 : : "r" ((long)(x)),                            \
65                     "i" (__LINE__ + BUG_WARNING_TRAP),          \
66                     "i" (__FILE__), "i" (__FUNCTION__));        \
67 } while (0)
68
69 #define HAVE_ARCH_BUG
70 #define HAVE_ARCH_BUG_ON
71 #define HAVE_ARCH_WARN_ON
72 #endif /* CONFIG_BUG */
73 #endif /* __ASSEMBLY __ */
74
75 #include <asm-generic/bug.h>
76
77 #endif /* _ASM_POWERPC_BUG_H */