xref: /csrg-svn/sys/luna68k/stand/trap.c (revision 57105)
1*57105Sakito /*
2*57105Sakito  * Copyright (c) 1992 OMRON Corporation.
3*57105Sakito  * Copyright (c) 1992 The Regents of the University of California.
4*57105Sakito  * All rights reserved.
5*57105Sakito  *
6*57105Sakito  * This code is derived from software contributed to Berkeley by
7*57105Sakito  * OMRON Corporation.
8*57105Sakito  *
9*57105Sakito  * %sccs.include.redist.c%
10*57105Sakito  *
11*57105Sakito  *	@(#)trap.c	7.1 (Berkeley) 12/13/92
12*57105Sakito  */
13*57105Sakito 
14*57105Sakito #include <sys/param.h>
15*57105Sakito #include <machine/frame.h>
16*57105Sakito #include <luna68k/stand/romvec.h>
17*57105Sakito 
18*57105Sakito #define	USER	040		/* user-mode flag added to type */
19*57105Sakito 
20*57105Sakito char	*trap_type[] = {
21*57105Sakito 	"Bus error",
22*57105Sakito 	"Address error",
23*57105Sakito 	"Illegal instruction",
24*57105Sakito 	"Zero divide",
25*57105Sakito 	"CHK instruction",
26*57105Sakito 	"TRAPV instruction",
27*57105Sakito 	"Privilege violation",
28*57105Sakito 	"Trace trap",
29*57105Sakito 	"MMU fault",
30*57105Sakito 	"SSIR trap",
31*57105Sakito 	"Format error",
32*57105Sakito 	"68881 exception",
33*57105Sakito 	"Coprocessor violation",
34*57105Sakito 	"Async system trap"
35*57105Sakito };
36*57105Sakito #define	TRAP_TYPES	(sizeof trap_type / sizeof trap_type[0])
37*57105Sakito 
38*57105Sakito /*
39*57105Sakito  * Called from the trap handler when a processor trap occurs.
40*57105Sakito  */
41*57105Sakito /*ARGSUSED*/
42*57105Sakito trap(type, code, v, frame)
43*57105Sakito 	int type;
44*57105Sakito 	unsigned code;
45*57105Sakito 	register unsigned v;
46*57105Sakito 	struct frame frame;
47*57105Sakito {
48*57105Sakito 	switch (type) {
49*57105Sakito 
50*57105Sakito 	default:
51*57105Sakito dopanic:
52*57105Sakito 		printf("trap type %d, code = %x, v = %x\n", type, code, v);
53*57105Sakito 		regdump(frame.f_regs, 128);
54*57105Sakito 		type &= ~USER;
55*57105Sakito 		if ((unsigned)type < TRAP_TYPES)
56*57105Sakito 			panic(trap_type[type]);
57*57105Sakito 		panic("trap");
58*57105Sakito 	}
59*57105Sakito }
60