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