diff options
Diffstat (limited to 'include/asm-powerpc/bug.h')
-rw-r--r-- | include/asm-powerpc/bug.h | 80 |
1 files changed, 40 insertions, 40 deletions
diff --git a/include/asm-powerpc/bug.h b/include/asm-powerpc/bug.h index 978b2c7e84ea..709568879f73 100644 --- a/include/asm-powerpc/bug.h +++ b/include/asm-powerpc/bug.h | |||
@@ -13,36 +13,39 @@ | |||
13 | 13 | ||
14 | #ifndef __ASSEMBLY__ | 14 | #ifndef __ASSEMBLY__ |
15 | 15 | ||
16 | struct bug_entry { | ||
17 | unsigned long bug_addr; | ||
18 | long line; | ||
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 | |||
31 | #ifdef CONFIG_BUG | 16 | #ifdef CONFIG_BUG |
32 | 17 | ||
18 | /* _EMIT_BUG_ENTRY expects args %0,%1,%2,%3 to be FILE, LINE, flags and | ||
19 | sizeof(struct bug_entry), respectively */ | ||
20 | #ifdef CONFIG_DEBUG_BUGVERBOSE | ||
21 | #define _EMIT_BUG_ENTRY \ | ||
22 | ".section __bug_table,\"a\"\n" \ | ||
23 | "2:\t" PPC_LONG "1b, %0\n" \ | ||
24 | "\t.short %1, %2\n" \ | ||
25 | ".org 2b+%3\n" \ | ||
26 | ".previous\n" | ||
27 | #else | ||
28 | #define _EMIT_BUG_ENTRY \ | ||
29 | ".section __bug_table,\"a\"\n" \ | ||
30 | "2:\t" PPC_LONG "1b\n" \ | ||
31 | "\t.short %2\n" \ | ||
32 | ".org 2b+%3\n" \ | ||
33 | ".previous\n" | ||
34 | #endif | ||
35 | |||
33 | /* | 36 | /* |
34 | * BUG_ON() and WARN_ON() do their best to cooperate with compile-time | 37 | * BUG_ON() and WARN_ON() do their best to cooperate with compile-time |
35 | * optimisations. However depending on the complexity of the condition | 38 | * optimisations. However depending on the complexity of the condition |
36 | * some compiler versions may not produce optimal results. | 39 | * some compiler versions may not produce optimal results. |
37 | */ | 40 | */ |
38 | 41 | ||
39 | #define BUG() do { \ | 42 | #define BUG() do { \ |
40 | __asm__ __volatile__( \ | 43 | __asm__ __volatile__( \ |
41 | "1: twi 31,0,0\n" \ | 44 | "1: twi 31,0,0\n" \ |
42 | ".section __bug_table,\"a\"\n" \ | 45 | _EMIT_BUG_ENTRY \ |
43 | "\t"PPC_LONG" 1b,%0,%1,%2\n" \ | 46 | : : "i" (__FILE__), "i" (__LINE__), \ |
44 | ".previous" \ | 47 | "i" (0), "i" (sizeof(struct bug_entry))); \ |
45 | : : "i" (__LINE__), "i" (__FILE__), "i" (__FUNCTION__)); \ | 48 | for(;;) ; \ |
46 | } while (0) | 49 | } while (0) |
47 | 50 | ||
48 | #define BUG_ON(x) do { \ | 51 | #define BUG_ON(x) do { \ |
@@ -51,23 +54,21 @@ struct bug_entry *find_bug(unsigned long bugaddr); | |||
51 | BUG(); \ | 54 | BUG(); \ |
52 | } else { \ | 55 | } else { \ |
53 | __asm__ __volatile__( \ | 56 | __asm__ __volatile__( \ |
54 | "1: "PPC_TLNEI" %0,0\n" \ | 57 | "1: "PPC_TLNEI" %4,0\n" \ |
55 | ".section __bug_table,\"a\"\n" \ | 58 | _EMIT_BUG_ENTRY \ |
56 | "\t"PPC_LONG" 1b,%1,%2,%3\n" \ | 59 | : : "i" (__FILE__), "i" (__LINE__), "i" (0), \ |
57 | ".previous" \ | 60 | "i" (sizeof(struct bug_entry)), \ |
58 | : : "r" ((long)(x)), "i" (__LINE__), \ | 61 | "r" ((long)(x))); \ |
59 | "i" (__FILE__), "i" (__FUNCTION__)); \ | ||
60 | } \ | 62 | } \ |
61 | } while (0) | 63 | } while (0) |
62 | 64 | ||
63 | #define __WARN() do { \ | 65 | #define __WARN() do { \ |
64 | __asm__ __volatile__( \ | 66 | __asm__ __volatile__( \ |
65 | "1: twi 31,0,0\n" \ | 67 | "1: twi 31,0,0\n" \ |
66 | ".section __bug_table,\"a\"\n" \ | 68 | _EMIT_BUG_ENTRY \ |
67 | "\t"PPC_LONG" 1b,%0,%1,%2\n" \ | 69 | : : "i" (__FILE__), "i" (__LINE__), \ |
68 | ".previous" \ | 70 | "i" (BUGFLAG_WARNING), \ |
69 | : : "i" (__LINE__ + BUG_WARNING_TRAP), \ | 71 | "i" (sizeof(struct bug_entry))); \ |
70 | "i" (__FILE__), "i" (__FUNCTION__)); \ | ||
71 | } while (0) | 72 | } while (0) |
72 | 73 | ||
73 | #define WARN_ON(x) ({ \ | 74 | #define WARN_ON(x) ({ \ |
@@ -77,13 +78,12 @@ struct bug_entry *find_bug(unsigned long bugaddr); | |||
77 | __WARN(); \ | 78 | __WARN(); \ |
78 | } else { \ | 79 | } else { \ |
79 | __asm__ __volatile__( \ | 80 | __asm__ __volatile__( \ |
80 | "1: "PPC_TLNEI" %0,0\n" \ | 81 | "1: "PPC_TLNEI" %4,0\n" \ |
81 | ".section __bug_table,\"a\"\n" \ | 82 | _EMIT_BUG_ENTRY \ |
82 | "\t"PPC_LONG" 1b,%1,%2,%3\n" \ | 83 | : : "i" (__FILE__), "i" (__LINE__), \ |
83 | ".previous" \ | 84 | "i" (BUGFLAG_WARNING), \ |
84 | : : "r" (__ret_warn_on), \ | 85 | "i" (sizeof(struct bug_entry)), \ |
85 | "i" (__LINE__ + BUG_WARNING_TRAP), \ | 86 | "r" (__ret_warn_on)); \ |
86 | "i" (__FILE__), "i" (__FUNCTION__)); \ | ||
87 | } \ | 87 | } \ |
88 | unlikely(__ret_warn_on); \ | 88 | unlikely(__ret_warn_on); \ |
89 | }) | 89 | }) |