trap.h revision 205360
1139749Simp/*	$OpenBSD: trap.h,v 1.3 1999/01/27 04:46:06 imp Exp $	*/
255992Swpaul
355992Swpaul/*-
455992Swpaul * Copyright (c) 1988 University of Utah.
555992Swpaul * Copyright (c) 1992, 1993
655992Swpaul *	The Regents of the University of California.  All rights reserved.
755992Swpaul *
855992Swpaul * This code is derived from software contributed to Berkeley by
955992Swpaul * the Systems Programming Group of the University of Utah Computer
1055992Swpaul * Science Department and Ralph Campbell.
1155992Swpaul *
1255992Swpaul * Redistribution and use in source and binary forms, with or without
1355992Swpaul * modification, are permitted provided that the following conditions
1455992Swpaul * are met:
1555992Swpaul * 1. Redistributions of source code must retain the above copyright
1655992Swpaul *    notice, this list of conditions and the following disclaimer.
1755992Swpaul * 2. Redistributions in binary form must reproduce the above copyright
1855992Swpaul *    notice, this list of conditions and the following disclaimer in the
1955992Swpaul *    documentation and/or other materials provided with the distribution.
2055992Swpaul * 4. Neither the name of the University nor the names of its contributors
2155992Swpaul *    may be used to endorse or promote products derived from this software
2255992Swpaul *    without specific prior written permission.
2355992Swpaul *
2455992Swpaul * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2555992Swpaul * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2655992Swpaul * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2755992Swpaul * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2855992Swpaul * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2955992Swpaul * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3055992Swpaul * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3155992Swpaul * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3255992Swpaul * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3355992Swpaul * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3455992Swpaul * SUCH DAMAGE.
3555992Swpaul *
3655992Swpaul *	from: Utah Hdr: trap.h 1.1 90/07/09
3755992Swpaul *	from: @(#)trap.h	8.1 (Berkeley) 6/10/93
3855992Swpaul *	JNPR: trap.h,v 1.3 2006/12/02 09:53:41 katta
3955992Swpaul * $FreeBSD: head/sys/mips/include/trap.h 205360 2010-03-20 05:07:15Z neel $
4055992Swpaul */
4155992Swpaul
4255992Swpaul#ifndef _MACHINE_TRAP_H_
4355992Swpaul#define	_MACHINE_TRAP_H_
4455992Swpaul
4555992Swpaul/*
4655992Swpaul * Trap codes also known in trap.c for name strings.
4755992Swpaul * Used for indexing so modify with care.
4855992Swpaul */
4955992Swpaul
5055992Swpaul#define	T_INT			0	/* Interrupt pending */
5155992Swpaul#define	T_TLB_MOD		1	/* TLB modified fault */
5255992Swpaul#define	T_TLB_LD_MISS		2	/* TLB miss on load or ifetch */
5355992Swpaul#define	T_TLB_ST_MISS		3	/* TLB miss on a store */
5455992Swpaul#define	T_ADDR_ERR_LD		4	/* Address error on a load or ifetch */
5555992Swpaul#define	T_ADDR_ERR_ST		5	/* Address error on a store */
5655992Swpaul#define	T_BUS_ERR_IFETCH	6	/* Bus error on an ifetch */
5755992Swpaul#define	T_BUS_ERR_LD_ST		7	/* Bus error on a load or store */
5855992Swpaul#define	T_SYSCALL		8	/* System call */
5955992Swpaul#define	T_BREAK			9	/* Breakpoint */
6055992Swpaul#define	T_RES_INST		10	/* Reserved instruction exception */
6155992Swpaul#define	T_COP_UNUSABLE		11	/* Coprocessor unusable */
6255992Swpaul#define	T_OVFLOW		12	/* Arithmetic overflow */
6355992Swpaul#define	T_TRAP			13	/* Trap instruction */
6455992Swpaul#define	T_VCEI			14	/* Virtual coherency instruction */
6555992Swpaul#define	T_FPE			15	/* Floating point exception */
66119156Sambrisko#define	T_IWATCH		16	/* Inst. Watch address reference */
6755992Swpaul#define T_C2E                   18      /* Exception from coprocessor 2 */
6855992Swpaul#define	T_DWATCH		23	/* Data Watch address reference */
6955992Swpaul#define T_MCHECK                24      /* Received an MCHECK */
7055992Swpaul#define	T_VCED			31	/* Virtual coherency data */
7155992Swpaul
7255992Swpaul#define	T_USER			0x20	/* user-mode flag or'ed with type */
7355992Swpaul
7455992Swpaul#if !defined(SMP) && (defined(DDB) || defined(DEBUG))
7555992Swpaul
7655992Swpaulstruct trapdebug {		/* trap history buffer for debugging */
7755992Swpaul	u_int	status;
7855992Swpaul	u_int	cause;
7955992Swpaul	u_int	vadr;
8055992Swpaul	u_int	pc;
8155992Swpaul	u_int	ra;
8255992Swpaul	u_int	sp;
8355992Swpaul	u_int	code;
8455992Swpaul};
8555992Swpaul
8655992Swpaul#define	trapdebug_enter(x, cd) {	\
8755992Swpaul	intrmask_t s = disableintr();	\
8855992Swpaul	trp->status = x->sr;		\
8955992Swpaul	trp->cause = x->cause;		\
9055992Swpaul	trp->vadr = x->badvaddr;	\
9155992Swpaul	trp->pc = x->pc;		\
9255992Swpaul	trp->sp = x->sp;		\
9355992Swpaul	trp->ra = x->ra;		\
9455992Swpaul	trp->code = cd;			\
9555992Swpaul	if (++trp == &trapdebug[TRAPSIZE])	\
9655992Swpaul		trp = trapdebug;	\
9755992Swpaul	restoreintr(s);			\
9855992Swpaul}
9955992Swpaul
10055992Swpaul#define	TRAPSIZE 10		/* Trap log buffer length */
10155992Swpaulextern struct trapdebug trapdebug[TRAPSIZE], *trp;
10255992Swpaul
10355992Swpaulvoid trapDump(char *msg);
10455992Swpaul
10555992Swpaul#else
10655992Swpaul
10755992Swpaul#define	trapdebug_enter(x, cd)
10855992Swpaul
10955992Swpaul#endif
11055992Swpaul
11155992Swpaulvoid MipsFPTrap(u_int, u_int, u_int);
11255992Swpaulvoid MipsKernGenException(void);
11355992Swpaulvoid MipsKernIntr(void);
11483270Sbrooksvoid MipsTLBInvalidException(void);
11555992Swpaulvoid MipsTLBMissException(void);
11655992Swpaulvoid MipsUserGenException(void);
11755992Swpaulvoid MipsUserIntr(void);
11855992Swpaul
11955992Swpaulu_int trap(struct trapframe *);
12055992Swpaul
12155992Swpaul#ifndef LOCORE /* XXX */
12255992Swpaulint check_address(void *);
12355992Swpaulvoid platform_trap_enter(void);
12455992Swpaulvoid platform_trap_exit(void);
12555992Swpaul#endif
12655992Swpaul
12755992Swpaul#endif /* !_MACHINE_TRAP_H_ */
12855992Swpaul