Linux-2.6.12-rc2
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / arch / cris / kernel / traps.c
1 /* $Id: traps.c,v 1.9 2004/05/11 12:28:26 starvik Exp $
2 *
3 * linux/arch/cris/traps.c
4 *
5 * Here we handle the break vectors not used by the system call
6 * mechanism, as well as some general stack/register dumping
7 * things.
8 *
9 * Copyright (C) 2000-2002 Axis Communications AB
10 *
11 * Authors: Bjorn Wesen
12 * Hans-Peter Nilsson
13 *
14 */
15
16 #include <linux/init.h>
17 #include <linux/module.h>
18 #include <asm/pgtable.h>
19 #include <asm/uaccess.h>
20
21 static int kstack_depth_to_print = 24;
22
23 void show_trace(unsigned long * stack)
24 {
25 unsigned long addr, module_start, module_end;
26 extern char _stext, _etext;
27 int i;
28
29 printk("\nCall Trace: ");
30
31 i = 1;
32 module_start = VMALLOC_START;
33 module_end = VMALLOC_END;
34
35 while (((long) stack & (THREAD_SIZE-1)) != 0) {
36 if (__get_user (addr, stack)) {
37 /* This message matches "failing address" marked
38 s390 in ksymoops, so lines containing it will
39 not be filtered out by ksymoops. */
40 printk ("Failing address 0x%lx\n", (unsigned long)stack);
41 break;
42 }
43 stack++;
44
45 /*
46 * If the address is either in the text segment of the
47 * kernel, or in the region which contains vmalloc'ed
48 * memory, it *may* be the address of a calling
49 * routine; if so, print it so that someone tracing
50 * down the cause of the crash will be able to figure
51 * out the call path that was taken.
52 */
53 if (((addr >= (unsigned long) &_stext) &&
54 (addr <= (unsigned long) &_etext)) ||
55 ((addr >= module_start) && (addr <= module_end))) {
56 if (i && ((i % 8) == 0))
57 printk("\n ");
58 printk("[<%08lx>] ", addr);
59 i++;
60 }
61 }
62 }
63
64 /*
65 * These constants are for searching for possible module text
66 * segments. MODULE_RANGE is a guess of how much space is likely
67 * to be vmalloced.
68 */
69
70 #define MODULE_RANGE (8*1024*1024)
71
72 /*
73 * The output (format, strings and order) is adjusted to be usable with
74 * ksymoops-2.4.1 with some necessary CRIS-specific patches. Please don't
75 * change it unless you're serious about adjusting ksymoops and syncing
76 * with the ksymoops maintainer.
77 */
78
79 void
80 show_stack(struct task_struct *task, unsigned long *sp)
81 {
82 unsigned long *stack, addr;
83 int i;
84
85 /*
86 * debugging aid: "show_stack(NULL);" prints a
87 * back trace.
88 */
89
90 if(sp == NULL) {
91 if (task)
92 sp = (unsigned long*)task->thread.ksp;
93 else
94 sp = (unsigned long*)rdsp();
95 }
96
97 stack = sp;
98
99 printk("\nStack from %08lx:\n ", (unsigned long)stack);
100 for(i = 0; i < kstack_depth_to_print; i++) {
101 if (((long) stack & (THREAD_SIZE-1)) == 0)
102 break;
103 if (i && ((i % 8) == 0))
104 printk("\n ");
105 if (__get_user (addr, stack)) {
106 /* This message matches "failing address" marked
107 s390 in ksymoops, so lines containing it will
108 not be filtered out by ksymoops. */
109 printk ("Failing address 0x%lx\n", (unsigned long)stack);
110 break;
111 }
112 stack++;
113 printk("%08lx ", addr);
114 }
115 show_trace(sp);
116 }
117
118 #if 0
119 /* displays a short stack trace */
120
121 int
122 show_stack()
123 {
124 unsigned long *sp = (unsigned long *)rdusp();
125 int i;
126 printk("Stack dump [0x%08lx]:\n", (unsigned long)sp);
127 for(i = 0; i < 16; i++)
128 printk("sp + %d: 0x%08lx\n", i*4, sp[i]);
129 return 0;
130 }
131 #endif
132
133 void dump_stack(void)
134 {
135 show_stack(NULL, NULL);
136 }
137
138 EXPORT_SYMBOL(dump_stack);
139
140 void __init
141 trap_init(void)
142 {
143 /* Nothing needs to be done */
144 }