xref: /csrg-svn/sys/luna68k/stand/trap.c (revision 63199)
157105Sakito /*
257105Sakito  * Copyright (c) 1992 OMRON Corporation.
3*63199Sbostic  * Copyright (c) 1992, 1993
4*63199Sbostic  *	The Regents of the University of California.  All rights reserved.
557105Sakito  *
657105Sakito  * This code is derived from software contributed to Berkeley by
757105Sakito  * OMRON Corporation.
857105Sakito  *
957105Sakito  * %sccs.include.redist.c%
1057105Sakito  *
11*63199Sbostic  *	@(#)trap.c	8.1 (Berkeley) 06/10/93
1257105Sakito  */
1357105Sakito 
1457105Sakito #include <sys/param.h>
1557105Sakito #include <machine/frame.h>
1657105Sakito #include <luna68k/stand/romvec.h>
1757105Sakito 
1857105Sakito #define	USER	040		/* user-mode flag added to type */
1957105Sakito 
2057105Sakito char	*trap_type[] = {
2157105Sakito 	"Bus error",
2257105Sakito 	"Address error",
2357105Sakito 	"Illegal instruction",
2457105Sakito 	"Zero divide",
2557105Sakito 	"CHK instruction",
2657105Sakito 	"TRAPV instruction",
2757105Sakito 	"Privilege violation",
2857105Sakito 	"Trace trap",
2957105Sakito 	"MMU fault",
3057105Sakito 	"SSIR trap",
3157105Sakito 	"Format error",
3257105Sakito 	"68881 exception",
3357105Sakito 	"Coprocessor violation",
3457105Sakito 	"Async system trap"
3557105Sakito };
3657105Sakito #define	TRAP_TYPES	(sizeof trap_type / sizeof trap_type[0])
3757105Sakito 
3857105Sakito /*
3957105Sakito  * Called from the trap handler when a processor trap occurs.
4057105Sakito  */
4157105Sakito /*ARGSUSED*/
trap(type,code,v,frame)4257105Sakito trap(type, code, v, frame)
4357105Sakito 	int type;
4457105Sakito 	unsigned code;
4557105Sakito 	register unsigned v;
4657105Sakito 	struct frame frame;
4757105Sakito {
4857105Sakito 	switch (type) {
4957105Sakito 
5057105Sakito 	default:
5157105Sakito dopanic:
5257105Sakito 		printf("trap type %d, code = %x, v = %x\n", type, code, v);
5357105Sakito 		regdump(frame.f_regs, 128);
5457105Sakito 		type &= ~USER;
5557105Sakito 		if ((unsigned)type < TRAP_TYPES)
5657105Sakito 			panic(trap_type[type]);
5757105Sakito 		panic("trap");
5857105Sakito 	}
5957105Sakito }
60