Merge branch 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab...
[deliverable/linux.git] / arch / cris / kernel / traps.c
CommitLineData
1ddba025 1/*
1da177e4
LT
2 * linux/arch/cris/traps.c
3 *
1ddba025
JN
4 * Here we handle the break vectors not used by the system call
5 * mechanism, as well as some general stack/register dumping
1da177e4 6 * things.
1ddba025
JN
7 *
8 * Copyright (C) 2000-2007 Axis Communications AB
1da177e4
LT
9 *
10 * Authors: Bjorn Wesen
1ddba025 11 * Hans-Peter Nilsson
1da177e4
LT
12 *
13 */
14
15#include <linux/init.h>
16#include <linux/module.h>
1ddba025 17
1da177e4
LT
18#include <asm/pgtable.h>
19#include <asm/uaccess.h>
b1a154db 20#include <arch/system.h>
1da177e4 21
1ddba025
JN
22extern void arch_enable_nmi(void);
23extern void stop_watchdog(void);
24extern void reset_watchdog(void);
25extern void show_registers(struct pt_regs *regs);
26
27#ifdef CONFIG_DEBUG_BUGVERBOSE
28extern void handle_BUG(struct pt_regs *regs);
29#else
30#define handle_BUG(regs)
31#endif
32
1da177e4
LT
33static int kstack_depth_to_print = 24;
34
1ddba025 35void (*nmi_handler)(struct pt_regs *);
059163ca 36
1ddba025
JN
37void
38show_trace(unsigned long *stack)
1da177e4
LT
39{
40 unsigned long addr, module_start, module_end;
41 extern char _stext, _etext;
42 int i;
43
1ddba025 44 printk("\nCall Trace: ");
1da177e4 45
1ddba025
JN
46 i = 1;
47 module_start = VMALLOC_START;
48 module_end = VMALLOC_END;
1da177e4 49
1ddba025
JN
50 while (((long)stack & (THREAD_SIZE-1)) != 0) {
51 if (__get_user(addr, stack)) {
1da177e4
LT
52 /* This message matches "failing address" marked
53 s390 in ksymoops, so lines containing it will
54 not be filtered out by ksymoops. */
1ddba025 55 printk("Failing address 0x%lx\n", (unsigned long)stack);
1da177e4
LT
56 break;
57 }
58 stack++;
59
1ddba025
JN
60 /*
61 * If the address is either in the text segment of the
62 * kernel, or in the region which contains vmalloc'ed
63 * memory, it *may* be the address of a calling
64 * routine; if so, print it so that someone tracing
65 * down the cause of the crash will be able to figure
66 * out the call path that was taken.
67 */
68 if (((addr >= (unsigned long)&_stext) &&
69 (addr <= (unsigned long)&_etext)) ||
70 ((addr >= module_start) && (addr <= module_end))) {
71 if (i && ((i % 8) == 0))
72 printk("\n ");
73 printk("[<%08lx>] ", addr);
74 i++;
75 }
76 }
1da177e4
LT
77}
78
79/*
80 * These constants are for searching for possible module text
81 * segments. MODULE_RANGE is a guess of how much space is likely
82 * to be vmalloced.
83 */
84
85#define MODULE_RANGE (8*1024*1024)
86
87/*
88 * The output (format, strings and order) is adjusted to be usable with
89 * ksymoops-2.4.1 with some necessary CRIS-specific patches. Please don't
90 * change it unless you're serious about adjusting ksymoops and syncing
91 * with the ksymoops maintainer.
92 */
93
1ddba025 94void
1da177e4
LT
95show_stack(struct task_struct *task, unsigned long *sp)
96{
1ddba025
JN
97 unsigned long *stack, addr;
98 int i;
1da177e4
LT
99
100 /*
101 * debugging aid: "show_stack(NULL);" prints a
102 * back trace.
103 */
104
1ddba025 105 if (sp == NULL) {
1da177e4
LT
106 if (task)
107 sp = (unsigned long*)task->thread.ksp;
108 else
109 sp = (unsigned long*)rdsp();
110 }
111
1ddba025 112 stack = sp;
1da177e4 113
1ddba025
JN
114 printk("\nStack from %08lx:\n ", (unsigned long)stack);
115 for (i = 0; i < kstack_depth_to_print; i++) {
116 if (((long)stack & (THREAD_SIZE-1)) == 0)
117 break;
118 if (i && ((i % 8) == 0))
119 printk("\n ");
120 if (__get_user(addr, stack)) {
1da177e4
LT
121 /* This message matches "failing address" marked
122 s390 in ksymoops, so lines containing it will
123 not be filtered out by ksymoops. */
1ddba025 124 printk("Failing address 0x%lx\n", (unsigned long)stack);
1da177e4
LT
125 break;
126 }
127 stack++;
1ddba025
JN
128 printk("%08lx ", addr);
129 }
1da177e4
LT
130 show_trace(sp);
131}
132
1ddba025
JN
133#if 0
134/* displays a short stack trace */
059163ca 135
1ddba025
JN
136int
137show_stack(void)
059163ca 138{
1ddba025
JN
139 unsigned long *sp = (unsigned long *)rdusp();
140 int i;
141
142 printk("Stack dump [0x%08lx]:\n", (unsigned long)sp);
143 for (i = 0; i < 16; i++)
144 printk("sp + %d: 0x%08lx\n", i*4, sp[i]);
145 return 0;
059163ca 146}
1ddba025 147#endif
059163ca 148
1ddba025
JN
149void
150set_nmi_handler(void (*handler)(struct pt_regs *))
151{
152 nmi_handler = handler;
153 arch_enable_nmi();
059163ca
MS
154}
155
156#ifdef CONFIG_DEBUG_NMI_OOPS
1ddba025
JN
157void
158oops_nmi_handler(struct pt_regs *regs)
059163ca 159{
1ddba025
JN
160 stop_watchdog();
161 oops_in_progress = 1;
162 printk("NMI!\n");
163 show_registers(regs);
164 oops_in_progress = 0;
059163ca
MS
165}
166
1ddba025
JN
167static int __init
168oops_nmi_register(void)
059163ca 169{
1ddba025
JN
170 set_nmi_handler(oops_nmi_handler);
171 return 0;
059163ca
MS
172}
173
174__initcall(oops_nmi_register);
175
176#endif
177
1ddba025
JN
178/*
179 * This gets called from entry.S when the watchdog has bitten. Show something
25985edc 180 * similar to an Oops dump, and if the kernel is configured to be a nice
1ddba025
JN
181 * doggy, then halt instead of reboot.
182 */
183void
184watchdog_bite_hook(struct pt_regs *regs)
1da177e4 185{
1ddba025
JN
186#ifdef CONFIG_ETRAX_WATCHDOG_NICE_DOGGY
187 local_irq_disable();
188 stop_watchdog();
189 show_registers(regs);
190
191 while (1)
192 ; /* Do nothing. */
193#else
194 show_registers(regs);
1da177e4 195#endif
1ddba025 196}
1da177e4 197
1ddba025
JN
198/* This is normally the Oops function. */
199void
200die_if_kernel(const char *str, struct pt_regs *regs, long err)
1da177e4 201{
1ddba025
JN
202 if (user_mode(regs))
203 return;
1da177e4 204
1ddba025
JN
205#ifdef CONFIG_ETRAX_WATCHDOG_NICE_DOGGY
206 /*
207 * This printout might take too long and could trigger
208 * the watchdog normally. If NICE_DOGGY is set, simply
209 * stop the watchdog during the printout.
210 */
211 stop_watchdog();
212#endif
1da177e4 213
1ddba025
JN
214 handle_BUG(regs);
215
216 printk("%s: %04lx\n", str, err & 0xffff);
217
218 show_registers(regs);
219
220 oops_in_progress = 0;
221
222#ifdef CONFIG_ETRAX_WATCHDOG_NICE_DOGGY
223 reset_watchdog();
224#endif
225 do_exit(SIGSEGV);
1da177e4 226}
059163ca 227
1ddba025
JN
228void __init
229trap_init(void)
059163ca 230{
1ddba025 231 /* Nothing needs to be done */
059163ca 232}
This page took 0.622767 seconds and 5 git commands to generate.