2 * linux/arch/cris/traps.c
4 * Here we handle the break vectors not used by the system call
5 * mechanism, as well as some general stack/register dumping
8 * Copyright (C) 2000-2007 Axis Communications AB
10 * Authors: Bjorn Wesen
15 #include <linux/init.h>
16 #include <linux/module.h>
17 #include <linux/utsname.h>
18 #ifdef CONFIG_KALLSYMS
19 #include <linux/kallsyms.h>
22 #include <asm/pgtable.h>
23 #include <asm/uaccess.h>
24 #include <arch/system.h>
26 extern void arch_enable_nmi(void);
27 extern void stop_watchdog(void);
28 extern void reset_watchdog(void);
29 extern void show_registers(struct pt_regs
*regs
);
31 #ifdef CONFIG_DEBUG_BUGVERBOSE
32 extern void handle_BUG(struct pt_regs
*regs
);
34 #define handle_BUG(regs)
37 static int kstack_depth_to_print
= 24;
39 void (*nmi_handler
)(struct pt_regs
*);
41 void show_trace(unsigned long *stack
)
43 unsigned long addr
, module_start
, module_end
;
44 extern char _stext
, _etext
;
47 pr_err("\nCall Trace: ");
50 module_start
= VMALLOC_START
;
51 module_end
= VMALLOC_END
;
53 while (((long)stack
& (THREAD_SIZE
- 1)) != 0) {
54 if (__get_user(addr
, stack
)) {
55 /* This message matches "failing address" marked
56 s390 in ksymoops, so lines containing it will
57 not be filtered out by ksymoops. */
58 pr_err("Failing address 0x%lx\n", (unsigned long)stack
);
64 * If the address is either in the text segment of the
65 * kernel, or in the region which contains vmalloc'ed
66 * memory, it *may* be the address of a calling
67 * routine; if so, print it so that someone tracing
68 * down the cause of the crash will be able to figure
69 * out the call path that was taken.
71 if (((addr
>= (unsigned long)&_stext
) &&
72 (addr
<= (unsigned long)&_etext
)) ||
73 ((addr
>= module_start
) && (addr
<= module_end
))) {
74 #ifdef CONFIG_KALLSYMS
77 if (i
&& ((i
% 8) == 0))
79 pr_err("[<%08lx>] ", addr
);
87 * These constants are for searching for possible module text
88 * segments. MODULE_RANGE is a guess of how much space is likely
92 #define MODULE_RANGE (8*1024*1024)
95 * The output (format, strings and order) is adjusted to be usable with
96 * ksymoops-2.4.1 with some necessary CRIS-specific patches. Please don't
97 * change it unless you're serious about adjusting ksymoops and syncing
98 * with the ksymoops maintainer.
102 show_stack(struct task_struct
*task
, unsigned long *sp
)
104 unsigned long *stack
, addr
;
108 * debugging aid: "show_stack(NULL);" prints a
114 sp
= (unsigned long*)task
->thread
.ksp
;
116 sp
= (unsigned long*)rdsp();
121 pr_err("\nStack from %08lx:\n ", (unsigned long)stack
);
122 for (i
= 0; i
< kstack_depth_to_print
; i
++) {
123 if (((long)stack
& (THREAD_SIZE
-1)) == 0)
125 if (i
&& ((i
% 8) == 0))
127 if (__get_user(addr
, stack
)) {
128 /* This message matches "failing address" marked
129 s390 in ksymoops, so lines containing it will
130 not be filtered out by ksymoops. */
131 pr_err("Failing address 0x%lx\n", (unsigned long)stack
);
135 pr_err("%08lx ", addr
);
141 /* displays a short stack trace */
146 unsigned long *sp
= (unsigned long *)rdusp();
149 pr_err("Stack dump [0x%08lx]:\n", (unsigned long)sp
);
150 for (i
= 0; i
< 16; i
++)
151 pr_err("sp + %d: 0x%08lx\n", i
*4, sp
[i
]);
156 void set_nmi_handler(void (*handler
)(struct pt_regs
*))
158 nmi_handler
= handler
;
162 #ifdef CONFIG_DEBUG_NMI_OOPS
163 void oops_nmi_handler(struct pt_regs
*regs
)
166 oops_in_progress
= 1;
168 show_registers(regs
);
169 oops_in_progress
= 0;
171 pr_err("\n"); /* Flush mtdoops. */
174 static int __init
oops_nmi_register(void)
176 set_nmi_handler(oops_nmi_handler
);
180 __initcall(oops_nmi_register
);
185 * This gets called from entry.S when the watchdog has bitten. Show something
186 * similar to an Oops dump, and if the kernel is configured to be a nice
187 * doggy, then halt instead of reboot.
189 void watchdog_bite_hook(struct pt_regs
*regs
)
191 #ifdef CONFIG_ETRAX_WATCHDOG_NICE_DOGGY
194 show_registers(regs
);
199 show_registers(regs
);
203 /* This is normally the Oops function. */
204 void die_if_kernel(const char *str
, struct pt_regs
*regs
, long err
)
209 #ifdef CONFIG_ETRAX_WATCHDOG_NICE_DOGGY
211 * This printout might take too long and could trigger
212 * the watchdog normally. If NICE_DOGGY is set, simply
213 * stop the watchdog during the printout.
221 pr_err("Linux %s %s\n", utsname()->release
, utsname()->version
);
222 pr_err("%s: %04lx\n", str
, err
& 0xffff);
224 show_registers(regs
);
227 oops_in_progress
= 0;
228 pr_err("\n"); /* Flush mtdoops. */
230 #ifdef CONFIG_ETRAX_WATCHDOG_NICE_DOGGY
236 void __init
trap_init(void)
238 /* Nothing needs to be done */