diff options
author | Paul Mundt <lethal@linux-sh.org> | 2007-11-20 04:08:06 -0500 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2008-01-27 23:18:50 -0500 |
commit | 5a4f7c66be981c6b5f44a4d66a14ea6ac9b7b6b0 (patch) | |
tree | a605424a32ce11d189a1aa1385c3fc22f972449f /arch/sh/kernel/traps.c | |
parent | 811d50cb43eb730cc325df0c6913556e25739797 (diff) |
sh: Share bug/debug traps across _32 and _64.
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch/sh/kernel/traps.c')
-rw-r--r-- | arch/sh/kernel/traps.c | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/arch/sh/kernel/traps.c b/arch/sh/kernel/traps.c new file mode 100644 index 000000000000..bf70827b17cc --- /dev/null +++ b/arch/sh/kernel/traps.c | |||
@@ -0,0 +1,66 @@ | |||
1 | #include <linux/bug.h> | ||
2 | #include <linux/io.h> | ||
3 | #include <linux/types.h> | ||
4 | #include <linux/kdebug.h> | ||
5 | #include <asm/system.h> | ||
6 | |||
7 | #ifdef CONFIG_BUG | ||
8 | static void handle_BUG(struct pt_regs *regs) | ||
9 | { | ||
10 | enum bug_trap_type tt; | ||
11 | tt = report_bug(regs->pc, regs); | ||
12 | if (tt == BUG_TRAP_TYPE_WARN) { | ||
13 | regs->pc += instruction_size(regs->pc); | ||
14 | return; | ||
15 | } | ||
16 | |||
17 | die("Kernel BUG", regs, TRAPA_BUG_OPCODE & 0xff); | ||
18 | } | ||
19 | |||
20 | int is_valid_bugaddr(unsigned long addr) | ||
21 | { | ||
22 | return addr >= PAGE_OFFSET; | ||
23 | } | ||
24 | #endif | ||
25 | |||
26 | /* | ||
27 | * Generic trap handler. | ||
28 | */ | ||
29 | BUILD_TRAP_HANDLER(debug) | ||
30 | { | ||
31 | TRAP_HANDLER_DECL; | ||
32 | |||
33 | /* Rewind */ | ||
34 | regs->pc -= instruction_size(ctrl_inw(regs->pc - 4)); | ||
35 | |||
36 | if (notify_die(DIE_TRAP, "debug trap", regs, 0, vec & 0xff, | ||
37 | SIGTRAP) == NOTIFY_STOP) | ||
38 | return; | ||
39 | |||
40 | force_sig(SIGTRAP, current); | ||
41 | } | ||
42 | |||
43 | /* | ||
44 | * Special handler for BUG() traps. | ||
45 | */ | ||
46 | BUILD_TRAP_HANDLER(bug) | ||
47 | { | ||
48 | TRAP_HANDLER_DECL; | ||
49 | |||
50 | /* Rewind */ | ||
51 | regs->pc -= instruction_size(ctrl_inw(regs->pc - 4)); | ||
52 | |||
53 | if (notify_die(DIE_TRAP, "bug trap", regs, 0, TRAPA_BUG_OPCODE & 0xff, | ||
54 | SIGTRAP) == NOTIFY_STOP) | ||
55 | return; | ||
56 | |||
57 | #ifdef CONFIG_BUG | ||
58 | if (__kernel_text_address(instruction_pointer(regs))) { | ||
59 | opcode_t insn = *(opcode_t *)instruction_pointer(regs); | ||
60 | if (insn == TRAPA_BUG_OPCODE) | ||
61 | handle_BUG(regs); | ||
62 | } | ||
63 | #endif | ||
64 | |||
65 | force_sig(SIGTRAP, current); | ||
66 | } | ||