2 * arch/niosnommu/kernel/traps.c
4 * Copyright 2004 Microtronix Datacom Ltd.
5 * Copyright 2001 Vic Phillips
6 * Copyright 1995 David S. Miller (davem@caip.rutgers.edu)
10 * arch/sparcnommu/kernel/traps.c
12 * All rights reserved.
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful, but
20 * WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
22 * NON INFRINGEMENT. See the GNU General Public License for more
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
31 #include <linux/sched.h> /* for jiffies */
32 #include <linux/kernel.h>
33 #include <linux/signal.h>
34 #include <linux/module.h>
36 #include <asm/delay.h>
37 #include <asm/system.h>
38 #include <asm/ptrace.h>
40 #include <asm/pgtable.h>
41 #include <asm/unistd.h>
45 /* #define TRAP_DEBUG */
48 void dumpit(unsigned long l1
, unsigned long l2
)
50 printk("0x%08x l1 0x%08x l2\n");
54 struct trap_trace_entry
{
60 struct trap_trace_entry trapbuf
[1024];
62 void syscall_trace_entry(struct pt_regs
*regs
)
64 printk("%s[%d]: ", current
->comm
, current
->pid
);
65 printk("scall<%d> (could be %d)\n", (int) regs
->r3
,
69 void syscall_trace_exit(struct pt_regs
*regs
)
75 * The architecture-independent backtrace generator
81 show_stack(current
, &stack
);
84 EXPORT_SYMBOL(dump_stack
);
87 * The show_stack is an external API which we do not use ourselves.
88 * The oops is printed in die_if_kernel.
91 int kstack_depth_to_print
= 48;
93 void show_stack(struct task_struct
*task
, unsigned long *stack
)
95 unsigned long *endstack
, addr
;
96 extern char _start
, _etext
;
101 stack
= (unsigned long *)task
->thread
.ksp
;
103 stack
= (unsigned long *)&stack
;
106 addr
= (unsigned long) stack
;
107 endstack
= (unsigned long *) PAGE_ALIGN(addr
);
109 printk(KERN_EMERG
"Stack from %08lx:", (unsigned long)stack
);
110 for (i
= 0; i
< kstack_depth_to_print
; i
++) {
111 if (stack
+ 1 > endstack
)
114 printk(KERN_EMERG
"\n ");
115 printk(KERN_EMERG
" %08lx", *stack
++);
118 printk(KERN_EMERG
"\nCall Trace:");
120 while (stack
+ 1 <= endstack
) {
123 * If the address is either in the text segment of the
124 * kernel, or in the region which contains vmalloc'ed
125 * memory, it *may* be the address of a calling
126 * routine; if so, print it so that someone tracing
127 * down the cause of the crash will be able to figure
128 * out the call path that was taken.
130 if (((addr
>= (unsigned long) &_start
) &&
131 (addr
<= (unsigned long) &_etext
))) {
133 printk(KERN_EMERG
"\n ");
134 printk(KERN_EMERG
" [<%08lx>]", addr
);
138 printk(KERN_EMERG
"\n");
141 void die_if_kernel(char *str
, struct pt_regs
*pregs
)
146 printk("0x%08lx\n trapped to die_if_kernel\n",pregs
->ra
);
148 if(pregs
->status_extension
& PS_S
)
153 void do_hw_interrupt(unsigned long type
, unsigned long psr
, unsigned long pc
)
156 printk("Unimplemented Nios2 TRAP, type = %02lx\n", type
);
157 die_if_kernel("Whee... Hello Mr. Penguin", current
->thread
.kregs
);
162 void handle_watchpoint(struct pt_regs
*regs
, unsigned long pc
, unsigned long psr
)
165 printk("Watchpoint detected at PC %08lx PSR %08lx\n", pc
, psr
);
167 if(psr
& PSR_SUPERVISOR
)
168 panic("Tell me what a watchpoint trap is, and I'll then deal "
169 "with such a beast...");
176 printk("trap_init reached\n");