aboutsummaryrefslogtreecommitdiffstats
path: root/arch/cris/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'arch/cris/kernel')
-rw-r--r--arch/cris/kernel/module.c14
-rw-r--r--arch/cris/kernel/process.c103
-rw-r--r--arch/cris/kernel/ptrace.c58
-rw-r--r--arch/cris/kernel/semaphore.c1
-rw-r--r--arch/cris/kernel/setup.c27
-rw-r--r--arch/cris/kernel/time.c13
-rw-r--r--arch/cris/kernel/traps.c226
7 files changed, 183 insertions, 259 deletions
diff --git a/arch/cris/kernel/module.c b/arch/cris/kernel/module.c
index 11b867df8617..a187833febc8 100644
--- a/arch/cris/kernel/module.c
+++ b/arch/cris/kernel/module.c
@@ -28,20 +28,28 @@
28#define DEBUGP(fmt , ...) 28#define DEBUGP(fmt , ...)
29#endif 29#endif
30 30
31#ifdef CONFIG_ETRAX_KMALLOCED_MODULES
32#define MALLOC_MODULE(size) kmalloc(size, GFP_KERNEL)
33#define FREE_MODULE(region) kfree(region)
34#else
35#define MALLOC_MODULE(size) vmalloc_exec(size)
36#define FREE_MODULE(region) vfree(region)
37#endif
38
31void *module_alloc(unsigned long size) 39void *module_alloc(unsigned long size)
32{ 40{
33 if (size == 0) 41 if (size == 0)
34 return NULL; 42 return NULL;
35 return vmalloc_exec(size); 43 return MALLOC_MODULE(size);
36} 44}
37 45
38 46
39/* Free memory returned from module_alloc */ 47/* Free memory returned from module_alloc */
40void module_free(struct module *mod, void *module_region) 48void module_free(struct module *mod, void *module_region)
41{ 49{
42 vfree(module_region); 50 FREE_MODULE(module_region);
43 /* FIXME: If module_region == mod->init_region, trim exception 51 /* FIXME: If module_region == mod->init_region, trim exception
44 table entries. */ 52 table entries. */
45} 53}
46 54
47/* We don't need anything special. */ 55/* We don't need anything special. */
diff --git a/arch/cris/kernel/process.c b/arch/cris/kernel/process.c
index 9ca558fc5bc8..ef2db8fd102a 100644
--- a/arch/cris/kernel/process.c
+++ b/arch/cris/kernel/process.c
@@ -1,5 +1,4 @@
1/* $Id: process.c,v 1.21 2005/03/04 08:16:17 starvik Exp $ 1/*
2 *
3 * linux/arch/cris/kernel/process.c 2 * linux/arch/cris/kernel/process.c
4 * 3 *
5 * Copyright (C) 1995 Linus Torvalds 4 * Copyright (C) 1995 Linus Torvalds
@@ -7,105 +6,6 @@
7 * 6 *
8 * Authors: Bjorn Wesen (bjornw@axis.com) 7 * Authors: Bjorn Wesen (bjornw@axis.com)
9 * 8 *
10 * $Log: process.c,v $
11 * Revision 1.21 2005/03/04 08:16:17 starvik
12 * Merge of Linux 2.6.11.
13 *
14 * Revision 1.20 2005/01/18 05:57:22 starvik
15 * Renamed hlt_counter to cris_hlt_counter and made it global.
16 *
17 * Revision 1.19 2004/10/19 13:07:43 starvik
18 * Merge of Linux 2.6.9
19 *
20 * Revision 1.18 2004/08/16 12:37:23 starvik
21 * Merge of Linux 2.6.8
22 *
23 * Revision 1.17 2004/04/05 13:53:48 starvik
24 * Merge of Linux 2.6.5
25 *
26 * Revision 1.16 2003/10/27 08:04:33 starvik
27 * Merge of Linux 2.6.0-test9
28 *
29 * Revision 1.15 2003/09/11 07:29:52 starvik
30 * Merge of Linux 2.6.0-test5
31 *
32 * Revision 1.14 2003/06/10 10:21:12 johana
33 * Moved thread_saved_pc() from arch/cris/kernel/process.c to
34 * subarch specific process.c. arch-v32 has an erp, no irp.
35 *
36 * Revision 1.13 2003/04/09 05:20:47 starvik
37 * Merge of Linux 2.5.67
38 *
39 * Revision 1.12 2002/12/11 15:41:11 starvik
40 * Extracted v10 (ETRAX 100LX) specific stuff to arch/cris/arch-v10/kernel
41 *
42 * Revision 1.11 2002/12/10 09:00:10 starvik
43 * Merge of Linux 2.5.51
44 *
45 * Revision 1.10 2002/11/27 08:42:34 starvik
46 * Argument to user_regs() is thread_info*
47 *
48 * Revision 1.9 2002/11/26 09:44:21 starvik
49 * New threads exits through ret_from_fork (necessary for preemptive scheduling)
50 *
51 * Revision 1.8 2002/11/19 14:35:24 starvik
52 * Changes from linux 2.4
53 * Changed struct initializer syntax to the currently prefered notation
54 *
55 * Revision 1.7 2002/11/18 07:39:42 starvik
56 * thread_saved_pc moved here from processor.h
57 *
58 * Revision 1.6 2002/11/14 06:51:27 starvik
59 * Made cpu_idle more similar with other archs
60 * init_task_union -> init_thread_union
61 * Updated for new interrupt macros
62 * sys_clone and do_fork have a new argument, user_tid
63 *
64 * Revision 1.5 2002/11/05 06:45:11 starvik
65 * Merge of Linux 2.5.45
66 *
67 * Revision 1.4 2002/02/05 15:37:44 bjornw
68 * Need init_task.h
69 *
70 * Revision 1.3 2002/01/21 15:22:49 bjornw
71 * current->counter is gone
72 *
73 * Revision 1.22 2001/11/13 09:40:43 orjanf
74 * Added dump_fpu (needed for core dumps).
75 *
76 * Revision 1.21 2001/11/12 18:26:21 pkj
77 * Fixed compiler warnings.
78 *
79 * Revision 1.20 2001/10/03 08:21:39 jonashg
80 * cause_of_death does not exist if CONFIG_SVINTO_SIM is defined.
81 *
82 * Revision 1.19 2001/09/26 11:52:54 bjornw
83 * INIT_MMAP is gone in 2.4.10
84 *
85 * Revision 1.18 2001/08/21 21:43:51 hp
86 * Move last watchdog fix inside #ifdef CONFIG_ETRAX_WATCHDOG
87 *
88 * Revision 1.17 2001/08/21 13:48:01 jonashg
89 * Added fix by HP to avoid oops when doing a hard_reset_now.
90 *
91 * Revision 1.16 2001/06/21 02:00:40 hp
92 * * entry.S: Include asm/unistd.h.
93 * (_sys_call_table): Use section .rodata, not .data.
94 * (_kernel_thread): Move from...
95 * * process.c: ... here.
96 * * entryoffsets.c (VAL): Break out from...
97 * (OF): Use VAL.
98 * (LCLONE_VM): New asmified value from CLONE_VM.
99 *
100 * Revision 1.15 2001/06/20 16:31:57 hp
101 * Add comments to describe empty functions according to review.
102 *
103 * Revision 1.14 2001/05/29 11:27:59 markusl
104 * Fixed so that hard_reset_now will do reset even if watchdog wasn't enabled
105 *
106 * Revision 1.13 2001/03/20 19:44:06 bjornw
107 * Use the 7th syscall argument for regs instead of current_regs
108 *
109 */ 9 */
110 10
111/* 11/*
@@ -206,6 +106,7 @@ EXPORT_SYMBOL(pm_power_off);
206 * low exit latency (ie sit in a loop waiting for 106 * low exit latency (ie sit in a loop waiting for
207 * somebody to say that they'd like to reschedule) 107 * somebody to say that they'd like to reschedule)
208 */ 108 */
109
209void cpu_idle (void) 110void cpu_idle (void)
210{ 111{
211 /* endless idle loop with no priority at all */ 112 /* endless idle loop with no priority at all */
diff --git a/arch/cris/kernel/ptrace.c b/arch/cris/kernel/ptrace.c
index 3ccd20e85dce..b326023baab2 100644
--- a/arch/cris/kernel/ptrace.c
+++ b/arch/cris/kernel/ptrace.c
@@ -2,65 +2,11 @@
2 * linux/arch/cris/kernel/ptrace.c 2 * linux/arch/cris/kernel/ptrace.c
3 * 3 *
4 * Parts taken from the m68k port. 4 * Parts taken from the m68k port.
5 * 5 *
6 * Copyright (c) 2000, 2001, 2002 Axis Communications AB 6 * Copyright (c) 2000, 2001, 2002 Axis Communications AB
7 * 7 *
8 * Authors: Bjorn Wesen 8 * Authors: Bjorn Wesen
9 * 9 *
10 * $Log: ptrace.c,v $
11 * Revision 1.10 2004/09/22 11:50:01 orjanf
12 * * Moved get_reg/put_reg to arch-specific files.
13 * * Added functions to access debug registers (CRISv32).
14 * * Added support for PTRACE_SINGLESTEP (CRISv32).
15 * * Added S flag to CCS_MASK (CRISv32).
16 *
17 * Revision 1.9 2003/07/04 12:56:11 tobiasa
18 * Moved arch-specific code to arch-specific files.
19 *
20 * Revision 1.8 2003/04/09 05:20:47 starvik
21 * Merge of Linux 2.5.67
22 *
23 * Revision 1.7 2002/11/27 08:42:34 starvik
24 * Argument to user_regs() is thread_info*
25 *
26 * Revision 1.6 2002/11/20 11:56:11 starvik
27 * Merge of Linux 2.5.48
28 *
29 * Revision 1.5 2002/11/18 07:41:19 starvik
30 * Removed warning
31 *
32 * Revision 1.4 2002/11/11 12:47:28 starvik
33 * SYSCALL_TRACE has been moved to thread flags
34 *
35 * Revision 1.3 2002/02/05 15:37:18 bjornw
36 * * Add do_notify_resume (replaces do_signal in the callchain)
37 * * syscall_trace is now do_syscall_trace
38 * * current->ptrace flag PT_TRACESYS -> PT_SYSCALLTRACE
39 * * Keep track of the current->work.syscall_trace counter
40 *
41 * Revision 1.2 2001/12/18 13:35:20 bjornw
42 * Applied the 2.4.13->2.4.16 CRIS patch to 2.5.1 (is a copy of 2.4.15).
43 *
44 * Revision 1.8 2001/11/12 18:26:21 pkj
45 * Fixed compiler warnings.
46 *
47 * Revision 1.7 2001/09/26 11:53:49 bjornw
48 * PTRACE_DETACH works more simple in 2.4.10
49 *
50 * Revision 1.6 2001/07/25 16:08:47 bjornw
51 * PTRACE_ATTACH bulk moved into arch-independent code in 2.4.7
52 *
53 * Revision 1.5 2001/03/26 14:24:28 orjanf
54 * * Changed loop condition.
55 * * Added comment documenting non-standard ptrace behaviour.
56 *
57 * Revision 1.4 2001/03/20 19:44:41 bjornw
58 * Use the user_regs macro instead of thread.esp0
59 *
60 * Revision 1.3 2000/12/18 23:45:25 bjornw
61 * Linux/CRIS first version
62 *
63 *
64 */ 10 */
65 11
66#include <linux/kernel.h> 12#include <linux/kernel.h>
@@ -85,7 +31,7 @@ extern int do_signal(int canrestart, struct pt_regs *regs);
85 31
86 32
87void do_notify_resume(int canrestart, struct pt_regs *regs, 33void do_notify_resume(int canrestart, struct pt_regs *regs,
88 __u32 thread_info_flags ) 34 __u32 thread_info_flags)
89{ 35{
90 /* deal with pending signal delivery */ 36 /* deal with pending signal delivery */
91 if (thread_info_flags & _TIF_SIGPENDING) 37 if (thread_info_flags & _TIF_SIGPENDING)
diff --git a/arch/cris/kernel/semaphore.c b/arch/cris/kernel/semaphore.c
index b884263d3cd4..f137a439041f 100644
--- a/arch/cris/kernel/semaphore.c
+++ b/arch/cris/kernel/semaphore.c
@@ -4,7 +4,6 @@
4 */ 4 */
5 5
6#include <linux/sched.h> 6#include <linux/sched.h>
7#include <linux/init.h>
8#include <asm/semaphore-helper.h> 7#include <asm/semaphore-helper.h>
9 8
10/* 9/*
diff --git a/arch/cris/kernel/setup.c b/arch/cris/kernel/setup.c
index c34fb235b09f..04d48dd91ddf 100644
--- a/arch/cris/kernel/setup.c
+++ b/arch/cris/kernel/setup.c
@@ -18,7 +18,7 @@
18#include <linux/screen_info.h> 18#include <linux/screen_info.h>
19#include <linux/utsname.h> 19#include <linux/utsname.h>
20#include <linux/pfn.h> 20#include <linux/pfn.h>
21 21#include <linux/cpu.h>
22#include <asm/setup.h> 22#include <asm/setup.h>
23 23
24/* 24/*
@@ -36,6 +36,8 @@ extern unsigned long dram_start, dram_end;
36 36
37extern unsigned long romfs_start, romfs_length, romfs_in_flash; /* from head.S */ 37extern unsigned long romfs_start, romfs_length, romfs_in_flash; /* from head.S */
38 38
39static struct cpu cpu_devices[NR_CPUS];
40
39extern void show_etrax_copyright(void); /* arch-vX/kernel/setup.c */ 41extern void show_etrax_copyright(void); /* arch-vX/kernel/setup.c */
40 42
41/* This mainly sets up the memory area, and can be really confusing. 43/* This mainly sets up the memory area, and can be really confusing.
@@ -45,24 +47,23 @@ extern void show_etrax_copyright(void); /* arch-vX/kernel/setup.c */
45 * given by the macro __pa(). 47 * given by the macro __pa().
46 * 48 *
47 * In this DRAM, the kernel code and data is loaded, in the beginning. 49 * In this DRAM, the kernel code and data is loaded, in the beginning.
48 * It really starts at c0004000 to make room for some special pages - 50 * It really starts at c0004000 to make room for some special pages -
49 * the start address is text_start. The kernel data ends at _end. After 51 * the start address is text_start. The kernel data ends at _end. After
50 * this the ROM filesystem is appended (if there is any). 52 * this the ROM filesystem is appended (if there is any).
51 * 53 *
52 * Between this address and dram_end, we have RAM pages usable to the 54 * Between this address and dram_end, we have RAM pages usable to the
53 * boot code and the system. 55 * boot code and the system.
54 * 56 *
55 */ 57 */
56 58
57void __init 59void __init setup_arch(char **cmdline_p)
58setup_arch(char **cmdline_p)
59{ 60{
60 extern void init_etrax_debug(void); 61 extern void init_etrax_debug(void);
61 unsigned long bootmap_size; 62 unsigned long bootmap_size;
62 unsigned long start_pfn, max_pfn; 63 unsigned long start_pfn, max_pfn;
63 unsigned long memory_start; 64 unsigned long memory_start;
64 65
65 /* register an initial console printing routine for printk's */ 66 /* register an initial console printing routine for printk's */
66 67
67 init_etrax_debug(); 68 init_etrax_debug();
68 69
@@ -121,7 +122,7 @@ setup_arch(char **cmdline_p)
121 min_low_pfn = PAGE_OFFSET >> PAGE_SHIFT; 122 min_low_pfn = PAGE_OFFSET >> PAGE_SHIFT;
122 123
123 bootmap_size = init_bootmem_node(NODE_DATA(0), start_pfn, 124 bootmap_size = init_bootmem_node(NODE_DATA(0), start_pfn,
124 min_low_pfn, 125 min_low_pfn,
125 max_low_pfn); 126 max_low_pfn);
126 127
127 /* And free all memory not belonging to the kernel (addr, size) */ 128 /* And free all memory not belonging to the kernel (addr, size) */
@@ -187,4 +188,16 @@ const struct seq_operations cpuinfo_op = {
187 .show = show_cpuinfo, 188 .show = show_cpuinfo,
188}; 189};
189 190
191static int __init topology_init(void)
192{
193 int i;
194
195 for_each_possible_cpu(i) {
196 return register_cpu(&cpu_devices[i], i);
197 }
198
199 return 0;
200}
201
202subsys_initcall(topology_init);
190 203
diff --git a/arch/cris/kernel/time.c b/arch/cris/kernel/time.c
index 7a2cc7efbcf8..ff4c6aa75def 100644
--- a/arch/cris/kernel/time.c
+++ b/arch/cris/kernel/time.c
@@ -1,5 +1,4 @@
1/* $Id: time.c,v 1.18 2005/03/04 08:16:17 starvik Exp $ 1/*
2 *
3 * linux/arch/cris/kernel/time.c 2 * linux/arch/cris/kernel/time.c
4 * 3 *
5 * Copyright (C) 1991, 1992, 1995 Linus Torvalds 4 * Copyright (C) 1991, 1992, 1995 Linus Torvalds
@@ -18,7 +17,7 @@
18 * Linux/CRIS specific code: 17 * Linux/CRIS specific code:
19 * 18 *
20 * Authors: Bjorn Wesen 19 * Authors: Bjorn Wesen
21 * Johan Adolfsson 20 * Johan Adolfsson
22 * 21 *
23 */ 22 */
24 23
@@ -208,10 +207,16 @@ cris_do_profile(struct pt_regs* regs)
208#endif 207#endif
209 208
210#ifdef CONFIG_PROFILING 209#ifdef CONFIG_PROFILING
211 profile_tick(CPU_PROFILING); 210 profile_tick(CPU_PROFILING);
212#endif 211#endif
213} 212}
214 213
214unsigned long long sched_clock(void)
215{
216 return (unsigned long long)jiffies * (1000000000 / HZ) +
217 get_ns_in_jiffie();
218}
219
215static int 220static int
216__init init_udelay(void) 221__init init_udelay(void)
217{ 222{
diff --git a/arch/cris/kernel/traps.c b/arch/cris/kernel/traps.c
index 520d92205fed..541efbf09371 100644
--- a/arch/cris/kernel/traps.c
+++ b/arch/cris/kernel/traps.c
@@ -1,66 +1,78 @@
1/* $Id: traps.c,v 1.11 2005/01/24 16:03:19 orjanf Exp $ 1/*
2 *
3 * linux/arch/cris/traps.c 2 * linux/arch/cris/traps.c
4 * 3 *
5 * Here we handle the break vectors not used by the system call 4 * Here we handle the break vectors not used by the system call
6 * mechanism, as well as some general stack/register dumping 5 * mechanism, as well as some general stack/register dumping
7 * things. 6 * things.
8 * 7 *
9 * Copyright (C) 2000-2002 Axis Communications AB 8 * Copyright (C) 2000-2007 Axis Communications AB
10 * 9 *
11 * Authors: Bjorn Wesen 10 * Authors: Bjorn Wesen
12 * Hans-Peter Nilsson 11 * Hans-Peter Nilsson
13 * 12 *
14 */ 13 */
15 14
16#include <linux/init.h> 15#include <linux/init.h>
17#include <linux/module.h> 16#include <linux/module.h>
17
18#include <asm/pgtable.h> 18#include <asm/pgtable.h>
19#include <asm/uaccess.h> 19#include <asm/uaccess.h>
20 20
21extern void arch_enable_nmi(void);
22extern void stop_watchdog(void);
23extern void reset_watchdog(void);
24extern void show_registers(struct pt_regs *regs);
25
26#ifdef CONFIG_DEBUG_BUGVERBOSE
27extern void handle_BUG(struct pt_regs *regs);
28#else
29#define handle_BUG(regs)
30#endif
31
21static int kstack_depth_to_print = 24; 32static int kstack_depth_to_print = 24;
22 33
23extern int raw_printk(const char *fmt, ...); 34void (*nmi_handler)(struct pt_regs *);
24 35
25void show_trace(unsigned long * stack) 36void
37show_trace(unsigned long *stack)
26{ 38{
27 unsigned long addr, module_start, module_end; 39 unsigned long addr, module_start, module_end;
28 extern char _stext, _etext; 40 extern char _stext, _etext;
29 int i; 41 int i;
30 42
31 raw_printk("\nCall Trace: "); 43 printk("\nCall Trace: ");
32 44
33 i = 1; 45 i = 1;
34 module_start = VMALLOC_START; 46 module_start = VMALLOC_START;
35 module_end = VMALLOC_END; 47 module_end = VMALLOC_END;
36 48
37 while (((long) stack & (THREAD_SIZE-1)) != 0) { 49 while (((long)stack & (THREAD_SIZE-1)) != 0) {
38 if (__get_user (addr, stack)) { 50 if (__get_user(addr, stack)) {
39 /* This message matches "failing address" marked 51 /* This message matches "failing address" marked
40 s390 in ksymoops, so lines containing it will 52 s390 in ksymoops, so lines containing it will
41 not be filtered out by ksymoops. */ 53 not be filtered out by ksymoops. */
42 raw_printk ("Failing address 0x%lx\n", (unsigned long)stack); 54 printk("Failing address 0x%lx\n", (unsigned long)stack);
43 break; 55 break;
44 } 56 }
45 stack++; 57 stack++;
46 58
47 /* 59 /*
48 * If the address is either in the text segment of the 60 * If the address is either in the text segment of the
49 * kernel, or in the region which contains vmalloc'ed 61 * kernel, or in the region which contains vmalloc'ed
50 * memory, it *may* be the address of a calling 62 * memory, it *may* be the address of a calling
51 * routine; if so, print it so that someone tracing 63 * routine; if so, print it so that someone tracing
52 * down the cause of the crash will be able to figure 64 * down the cause of the crash will be able to figure
53 * out the call path that was taken. 65 * out the call path that was taken.
54 */ 66 */
55 if (((addr >= (unsigned long) &_stext) && 67 if (((addr >= (unsigned long)&_stext) &&
56 (addr <= (unsigned long) &_etext)) || 68 (addr <= (unsigned long)&_etext)) ||
57 ((addr >= module_start) && (addr <= module_end))) { 69 ((addr >= module_start) && (addr <= module_end))) {
58 if (i && ((i % 8) == 0)) 70 if (i && ((i % 8) == 0))
59 raw_printk("\n "); 71 printk("\n ");
60 raw_printk("[<%08lx>] ", addr); 72 printk("[<%08lx>] ", addr);
61 i++; 73 i++;
62 } 74 }
63 } 75 }
64} 76}
65 77
66/* 78/*
@@ -78,109 +90,149 @@ void show_trace(unsigned long * stack)
78 * with the ksymoops maintainer. 90 * with the ksymoops maintainer.
79 */ 91 */
80 92
81void 93void
82show_stack(struct task_struct *task, unsigned long *sp) 94show_stack(struct task_struct *task, unsigned long *sp)
83{ 95{
84 unsigned long *stack, addr; 96 unsigned long *stack, addr;
85 int i; 97 int i;
86 98
87 /* 99 /*
88 * debugging aid: "show_stack(NULL);" prints a 100 * debugging aid: "show_stack(NULL);" prints a
89 * back trace. 101 * back trace.
90 */ 102 */
91 103
92 if(sp == NULL) { 104 if (sp == NULL) {
93 if (task) 105 if (task)
94 sp = (unsigned long*)task->thread.ksp; 106 sp = (unsigned long*)task->thread.ksp;
95 else 107 else
96 sp = (unsigned long*)rdsp(); 108 sp = (unsigned long*)rdsp();
97 } 109 }
98 110
99 stack = sp; 111 stack = sp;
100 112
101 raw_printk("\nStack from %08lx:\n ", (unsigned long)stack); 113 printk("\nStack from %08lx:\n ", (unsigned long)stack);
102 for(i = 0; i < kstack_depth_to_print; i++) { 114 for (i = 0; i < kstack_depth_to_print; i++) {
103 if (((long) stack & (THREAD_SIZE-1)) == 0) 115 if (((long)stack & (THREAD_SIZE-1)) == 0)
104 break; 116 break;
105 if (i && ((i % 8) == 0)) 117 if (i && ((i % 8) == 0))
106 raw_printk("\n "); 118 printk("\n ");
107 if (__get_user (addr, stack)) { 119 if (__get_user(addr, stack)) {
108 /* This message matches "failing address" marked 120 /* This message matches "failing address" marked
109 s390 in ksymoops, so lines containing it will 121 s390 in ksymoops, so lines containing it will
110 not be filtered out by ksymoops. */ 122 not be filtered out by ksymoops. */
111 raw_printk ("Failing address 0x%lx\n", (unsigned long)stack); 123 printk("Failing address 0x%lx\n", (unsigned long)stack);
112 break; 124 break;
113 } 125 }
114 stack++; 126 stack++;
115 raw_printk("%08lx ", addr); 127 printk("%08lx ", addr);
116 } 128 }
117 show_trace(sp); 129 show_trace(sp);
118} 130}
119 131
120static void (*nmi_handler)(struct pt_regs*); 132#if 0
121extern void arch_enable_nmi(void); 133/* displays a short stack trace */
122 134
123void set_nmi_handler(void (*handler)(struct pt_regs*)) 135int
136show_stack(void)
124{ 137{
125 nmi_handler = handler; 138 unsigned long *sp = (unsigned long *)rdusp();
126 arch_enable_nmi(); 139 int i;
140
141 printk("Stack dump [0x%08lx]:\n", (unsigned long)sp);
142 for (i = 0; i < 16; i++)
143 printk("sp + %d: 0x%08lx\n", i*4, sp[i]);
144 return 0;
127} 145}
146#endif
128 147
129void handle_nmi(struct pt_regs* regs) 148void
149dump_stack(void)
130{ 150{
131 if (nmi_handler) 151 show_stack(NULL, NULL);
132 nmi_handler(regs); 152}
153EXPORT_SYMBOL(dump_stack);
154
155void
156set_nmi_handler(void (*handler)(struct pt_regs *))
157{
158 nmi_handler = handler;
159 arch_enable_nmi();
133} 160}
134 161
135#ifdef CONFIG_DEBUG_NMI_OOPS 162#ifdef CONFIG_DEBUG_NMI_OOPS
136void oops_nmi_handler(struct pt_regs* regs) 163void
164oops_nmi_handler(struct pt_regs *regs)
137{ 165{
138 stop_watchdog(); 166 stop_watchdog();
139 raw_printk("NMI!\n"); 167 oops_in_progress = 1;
140 show_registers(regs); 168 printk("NMI!\n");
169 show_registers(regs);
170 oops_in_progress = 0;
141} 171}
142 172
143static int 173static int __init
144__init oops_nmi_register(void) 174oops_nmi_register(void)
145{ 175{
146 set_nmi_handler(oops_nmi_handler); 176 set_nmi_handler(oops_nmi_handler);
147 return 0; 177 return 0;
148} 178}
149 179
150__initcall(oops_nmi_register); 180__initcall(oops_nmi_register);
151 181
152#endif 182#endif
153 183
154#if 0 184/*
155/* displays a short stack trace */ 185 * This gets called from entry.S when the watchdog has bitten. Show something
156 186 * similiar to an Oops dump, and if the kernel is configured to be a nice
157int 187 * doggy, then halt instead of reboot.
158show_stack() 188 */
189void
190watchdog_bite_hook(struct pt_regs *regs)
159{ 191{
160 unsigned long *sp = (unsigned long *)rdusp(); 192#ifdef CONFIG_ETRAX_WATCHDOG_NICE_DOGGY
161 int i; 193 local_irq_disable();
162 raw_printk("Stack dump [0x%08lx]:\n", (unsigned long)sp); 194 stop_watchdog();
163 for(i = 0; i < 16; i++) 195 show_registers(regs);
164 raw_printk("sp + %d: 0x%08lx\n", i*4, sp[i]); 196
165 return 0; 197 while (1)
166} 198 ; /* Do nothing. */
199#else
200 show_registers(regs);
167#endif 201#endif
202}
168 203
169void dump_stack(void) 204/* This is normally the Oops function. */
205void
206die_if_kernel(const char *str, struct pt_regs *regs, long err)
170{ 207{
171 show_stack(NULL, NULL); 208 if (user_mode(regs))
172} 209 return;
173 210
174EXPORT_SYMBOL(dump_stack); 211#ifdef CONFIG_ETRAX_WATCHDOG_NICE_DOGGY
212 /*
213 * This printout might take too long and could trigger
214 * the watchdog normally. If NICE_DOGGY is set, simply
215 * stop the watchdog during the printout.
216 */
217 stop_watchdog();
218#endif
175 219
176void __init 220 handle_BUG(regs);
177trap_init(void) 221
178{ 222 printk("%s: %04lx\n", str, err & 0xffff);
179 /* Nothing needs to be done */ 223
224 show_registers(regs);
225
226 oops_in_progress = 0;
227
228#ifdef CONFIG_ETRAX_WATCHDOG_NICE_DOGGY
229 reset_watchdog();
230#endif
231 do_exit(SIGSEGV);
180} 232}
181 233
182void spinning_cpu(void* addr) 234void __init
235trap_init(void)
183{ 236{
184 raw_printk("CPU %d spinning on %X\n", smp_processor_id(), addr); 237 /* Nothing needs to be done */
185 dump_stack();
186} 238}