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>
18 #include <asm/pgtable.h>
19 #include <asm/uaccess.h>
21 extern void arch_enable_nmi(void);
22 extern void stop_watchdog(void);
23 extern void reset_watchdog(void);
24 extern void show_registers(struct pt_regs
*regs
);
26 #ifdef CONFIG_DEBUG_BUGVERBOSE
27 extern void handle_BUG(struct pt_regs
*regs
);
29 #define handle_BUG(regs)
32 static int kstack_depth_to_print
= 24;
34 void (*nmi_handler
)(struct pt_regs
*);
37 show_trace(unsigned long *stack
)
39 unsigned long addr
, module_start
, module_end
;
40 extern char _stext
, _etext
;
43 printk("\nCall Trace: ");
46 module_start
= VMALLOC_START
;
47 module_end
= VMALLOC_END
;
49 while (((long)stack
& (THREAD_SIZE
-1)) != 0) {
50 if (__get_user(addr
, stack
)) {
51 /* This message matches "failing address" marked
52 s390 in ksymoops, so lines containing it will
53 not be filtered out by ksymoops. */
54 printk("Failing address 0x%lx\n", (unsigned long)stack
);
60 * If the address is either in the text segment of the
61 * kernel, or in the region which contains vmalloc'ed
62 * memory, it *may* be the address of a calling
63 * routine; if so, print it so that someone tracing
64 * down the cause of the crash will be able to figure
65 * out the call path that was taken.
67 if (((addr
>= (unsigned long)&_stext
) &&
68 (addr
<= (unsigned long)&_etext
)) ||
69 ((addr
>= module_start
) && (addr
<= module_end
))) {
70 if (i
&& ((i
% 8) == 0))
72 printk("[<%08lx>] ", addr
);
79 * These constants are for searching for possible module text
80 * segments. MODULE_RANGE is a guess of how much space is likely
84 #define MODULE_RANGE (8*1024*1024)
87 * The output (format, strings and order) is adjusted to be usable with
88 * ksymoops-2.4.1 with some necessary CRIS-specific patches. Please don't
89 * change it unless you're serious about adjusting ksymoops and syncing
90 * with the ksymoops maintainer.
94 show_stack(struct task_struct
*task
, unsigned long *sp
)
96 unsigned long *stack
, addr
;
100 * debugging aid: "show_stack(NULL);" prints a
106 sp
= (unsigned long*)task
->thread
.ksp
;
108 sp
= (unsigned long*)rdsp();
113 printk("\nStack from %08lx:\n ", (unsigned long)stack
);
114 for (i
= 0; i
< kstack_depth_to_print
; i
++) {
115 if (((long)stack
& (THREAD_SIZE
-1)) == 0)
117 if (i
&& ((i
% 8) == 0))
119 if (__get_user(addr
, stack
)) {
120 /* This message matches "failing address" marked
121 s390 in ksymoops, so lines containing it will
122 not be filtered out by ksymoops. */
123 printk("Failing address 0x%lx\n", (unsigned long)stack
);
127 printk("%08lx ", addr
);
136 show_stack(NULL
, NULL
);
138 EXPORT_SYMBOL(dump_stack
);
141 set_nmi_handler(void (*handler
)(struct pt_regs
*))
143 nmi_handler
= handler
;
147 #ifdef CONFIG_DEBUG_NMI_OOPS
149 oops_nmi_handler(struct pt_regs
*regs
)
152 oops_in_progress
= 1;
154 show_registers(regs
);
155 oops_in_progress
= 0;
159 oops_nmi_register(void)
161 set_nmi_handler(oops_nmi_handler
);
165 __initcall(oops_nmi_register
);
170 * This gets called from entry.S when the watchdog has bitten. Show something
171 * similiar to an Oops dump, and if the kernel is configured to be a nice
172 * doggy, then halt instead of reboot.
175 watchdog_bite_hook(struct pt_regs
*regs
)
177 #ifdef CONFIG_ETRAX_WATCHDOG_NICE_DOGGY
180 show_registers(regs
);
185 show_registers(regs
);
189 /* This is normally the Oops function. */
191 die_if_kernel(const char *str
, struct pt_regs
*regs
, long err
)
196 #ifdef CONFIG_ETRAX_WATCHDOG_NICE_DOGGY
198 * This printout might take too long and could trigger
199 * the watchdog normally. If NICE_DOGGY is set, simply
200 * stop the watchdog during the printout.
207 printk("%s: %04lx\n", str
, err
& 0xffff);
209 show_registers(regs
);
211 oops_in_progress
= 0;
213 #ifdef CONFIG_ETRAX_WATCHDOG_NICE_DOGGY
222 /* Nothing needs to be done */