aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-sh/bug.h
diff options
context:
space:
mode:
authorPaul Mundt <lethal@linux-sh.org>2007-03-08 05:41:21 -0500
committerPaul Mundt <lethal@hera.kernel.org>2007-05-06 22:10:53 -0400
commitfa69151173b1fc6fa3ced0edd5c2ea83b5d32bc1 (patch)
treee7af97ccddc06d54dd6d6982a64cbf4982693379 /include/asm-sh/bug.h
parent45ed285b54930767937deb0eaf718b1d08c3c475 (diff)
sh: generic BUG() support.
Wire up GENERIC_BUG for SH. This moves off of the special bug frame and on to the generic struct bug_entry. Roughly the same semantics are retained, and we can kill off some of the verbose BUG() reporting code. Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'include/asm-sh/bug.h')
-rw-r--r--include/asm-sh/bug.h92
1 files changed, 61 insertions, 31 deletions
diff --git a/include/asm-sh/bug.h b/include/asm-sh/bug.h
index 2f89dd06d0cd..794c36daf06d 100644
--- a/include/asm-sh/bug.h
+++ b/include/asm-sh/bug.h
@@ -2,50 +2,80 @@
2#define __ASM_SH_BUG_H 2#define __ASM_SH_BUG_H
3 3
4#ifdef CONFIG_BUG 4#ifdef CONFIG_BUG
5 5#define HAVE_ARCH_BUG
6struct bug_frame { 6#define HAVE_ARCH_WARN_ON
7 unsigned short opcode;
8 unsigned short line;
9 const char *file;
10 const char *func;
11};
12
13struct pt_regs;
14
15extern void handle_BUG(struct pt_regs *);
16 7
17#define TRAPA_BUG_OPCODE 0xc33e /* trapa #0x3e */ 8#define TRAPA_BUG_OPCODE 0xc33e /* trapa #0x3e */
18 9
10/**
11 * _EMIT_BUG_ENTRY
12 * %1 - __FILE__
13 * %2 - __LINE__
14 * %3 - trap type
15 * %4 - sizeof(struct bug_entry)
16 *
17 * The trapa opcode itself sits in %0.
18 * The %O notation is used to avoid # generation.
19 *
20 * The offending file and line are encoded in the __bug_table section.
21 */
19#ifdef CONFIG_DEBUG_BUGVERBOSE 22#ifdef CONFIG_DEBUG_BUGVERBOSE
23#define _EMIT_BUG_ENTRY \
24 "\t.pushsection __bug_table,\"a\"\n" \
25 "2:\t.long 1b, %O1\n" \
26 "\t.short %O2, %O3\n" \
27 "\t.org 2b+%O4\n" \
28 "\t.popsection\n"
29#else
30#define _EMIT_BUG_ENTRY \
31 "\t.pushsection __bug_table,\"a\"\n" \
32 "2:\t.long 1b\n" \
33 "\t.short %O3\n" \
34 "\t.org 2b+%O4\n" \
35 "\t.popsection\n"
36#endif
20 37
21#define BUG() \ 38#define BUG() \
22do { \ 39do { \
23 __asm__ __volatile__ ( \ 40 __asm__ __volatile__ ( \
24 ".align 2\n\t" \ 41 "1:\t.short %O0\n" \
25 ".short %O0\n\t" \ 42 _EMIT_BUG_ENTRY \
26 ".short %O1\n\t" \ 43 : \
27 ".long %O2\n\t" \ 44 : "n" (TRAPA_BUG_OPCODE), \
28 ".long %O3\n\t" \ 45 "i" (__FILE__), \
29 : \ 46 "i" (__LINE__), "i" (0), \
30 : "n" (TRAPA_BUG_OPCODE), \ 47 "i" (sizeof(struct bug_entry))); \
31 "i" (__LINE__), "X" (__FILE__), \
32 "X" (__FUNCTION__)); \
33} while (0) 48} while (0)
34 49
35#else 50#define __WARN() \
36 51do { \
37#define BUG() \ 52 __asm__ __volatile__ ( \
38do { \ 53 "1:\t.short %O0\n" \
39 __asm__ __volatile__ ( \ 54 _EMIT_BUG_ENTRY \
40 ".align 2\n\t" \ 55 : \
41 ".short %O0\n\t" \ 56 : "n" (TRAPA_BUG_OPCODE), \
42 : \ 57 "i" (__FILE__), \
43 : "n" (TRAPA_BUG_OPCODE)); \ 58 "i" (__LINE__), \
59 "i" (BUGFLAG_WARNING), \
60 "i" (sizeof(struct bug_entry))); \
44} while (0) 61} while (0)
45 62
46#endif /* CONFIG_DEBUG_BUGVERBOSE */ 63#define WARN_ON(x) ({ \
64 typeof(x) __ret_warn_on = (x); \
65 if (__builtin_constant_p(__ret_warn_on)) { \
66 if (__ret_warn_on) \
67 __WARN(); \
68 } else { \
69 if (unlikely(__ret_warn_on)) \
70 __WARN(); \
71 } \
72 unlikely(__ret_warn_on); \
73})
47 74
48#define HAVE_ARCH_BUG 75struct pt_regs;
76
77/* arch/sh/kernel/traps.c */
78void handle_BUG(struct pt_regs *);
49 79
50#endif /* CONFIG_BUG */ 80#endif /* CONFIG_BUG */
51 81