xref: /csrg-svn/sys/sparc/include/trap.h (revision 55501)
155127Storek /*
255127Storek  * Copyright (c) 1992 The Regents of the University of California.
355127Storek  * All rights reserved.
455127Storek  *
555127Storek  * This software was developed by the Computer Systems Engineering group
655127Storek  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
755127Storek  * contributed to Berkeley.
855127Storek  *
9*55501Sbostic  * All advertising materials mentioning features or use of this software
10*55501Sbostic  * must display the following acknowledgement:
11*55501Sbostic  *	This product includes software developed by the University of
12*55501Sbostic  *	California, Lawrence Berkeley Laboratories.
13*55501Sbostic  *
1455127Storek  * %sccs.include.redist.c%
1555127Storek  *
16*55501Sbostic  *	@(#)trap.h	7.2 (Berkeley) 07/21/92
1755127Storek  *
1855127Storek  * from: $Header: trap.h,v 1.8 92/07/03 18:49:02 torek Exp $
1955127Storek  */
2055127Storek 
2155127Storek #ifndef	_MACHINE_TRAP_H
2255127Storek #define	_MACHINE_TRAP_H
2355127Storek /*
2455127Storek  *
2555127Storek  * The SPARC has a Trap Base Register (TBR) which holds the upper 20 bits
2655127Storek  * of the trap vector table.  The next eight bits are supplied by the
2755127Storek  * hardware when the trap occurs, and the bottom four bits are always
2855127Storek  * zero (so that we can shove up to 16 bytes of executable code---exactly
2955127Storek  * four instructions---into each trap vector).
3055127Storek  *
3155127Storek  * The hardware allocates half the trap vectors to hardware and half to
3255127Storek  * software.
3355127Storek  *
3455127Storek  * Traps have priorities assigned (lower number => higher priority).
3555127Storek  */
3655127Storek 
3755127Storek #if defined(KERNEL) && !defined(LOCORE)
3855127Storek struct trapvec {
3955127Storek 	int	tv_instr[4];		/* the four instructions */
4055127Storek };
4155127Storek extern struct trapvec trapbase[256];	/* the 256 vectors */
4255127Storek #endif
4355127Storek 
4455127Storek /*	trap		vec	  (pri) description	*/
4555127Storek #define	T_RESET		0x00	/* (1) not actually vectored; jumps to 0 */
4655127Storek #define	T_TEXTFAULT	0x01	/* (2) address fault during instr fetch */
4755127Storek #define	T_ILLINST	0x02	/* (3) illegal instruction */
4855127Storek #define	T_PRIVINST	0x03	/* (4) privileged instruction */
4955127Storek #define	T_FPDISABLED	0x04	/* (5) fp instr while fp disabled */
5055127Storek #define	T_WINOF		0x05	/* (6) register window overflow */
5155127Storek #define	T_WINUF		0x06	/* (7) register window underflow */
5255127Storek #define	T_ALIGN		0x07	/* (8) address not properly aligned */
5355127Storek #define	T_FPE		0x08	/* (9) floating point exception */
5455127Storek #define	T_DATAFAULT	0x09	/* (10) address fault during data fetch */
5555127Storek #define	T_TAGOF		0x0a	/* (11) tag overflow */
5655127Storek /*			0x0b	   unused */
5755127Storek /*			0x0c	   unused */
5855127Storek /*			0x0d	   unused */
5955127Storek /*			0x0e	   unused */
6055127Storek /*			0x0f	   unused */
6155127Storek /*			0x10	   unused */
6255127Storek #define	T_L1INT		0x11	/* (27) level 1 interrupt */
6355127Storek #define	T_L2INT		0x12	/* (26) level 2 interrupt */
6455127Storek #define	T_L3INT		0x13	/* (25) level 3 interrupt */
6555127Storek #define	T_L4INT		0x14	/* (24) level 4 interrupt */
6655127Storek #define	T_L5INT		0x15	/* (23) level 5 interrupt */
6755127Storek #define	T_L6INT		0x16	/* (22) level 6 interrupt */
6855127Storek #define	T_L7INT		0x17	/* (21) level 7 interrupt */
6955127Storek #define	T_L8INT		0x18	/* (20) level 8 interrupt */
7055127Storek #define	T_L9INT		0x19	/* (19) level 9 interrupt */
7155127Storek #define	T_L10INT	0x1a	/* (18) level 10 interrupt */
7255127Storek #define	T_L11INT	0x1b	/* (17) level 11 interrupt */
7355127Storek #define	T_L12INT	0x1c	/* (16) level 12 interrupt */
7455127Storek #define	T_L13INT	0x1d	/* (15) level 13 interrupt */
7555127Storek #define	T_L14INT	0x1e	/* (14) level 14 interrupt */
7655127Storek #define	T_L15INT	0x1f	/* (13) level 15 interrupt */
7755127Storek /*			0x20	   unused */
7855127Storek /*	through		0x23	   unused */
7955127Storek #define	T_CPDISABLED	0x24	/* (5) coprocessor instr while disabled */
8055127Storek /*			0x25	   unused */
8155127Storek /*	through		0x27	   unused */
8255127Storek #define	T_CPEXCEPTION	0x28	/* (9) coprocessor exception */
8355127Storek /*			0x29	   unused */
8455127Storek /*	through		0x7f	   unused */
8555127Storek 
8655127Storek /* beginning of `user' vectors (from trap instructions) - all priority 12 */
8755127Storek #define	T_SUN_SYSCALL	0x80	/* system call */
8855127Storek #define	T_BREAKPOINT	0x81	/* breakpoint `instruction' */
8955127Storek #define	T_DIV0		0x82	/* division routine was handed 0 */
9055127Storek #define	T_FLUSHWIN	0x83	/* flush windows */
9155127Storek #define	T_CLEANWIN	0x84	/* provide clean windows */
9255127Storek #define	T_RANGECHECK	0x85	/* ? */
9355127Storek #define	T_FIXALIGN	0x86	/* fix up unaligned accesses */
9455127Storek #define	T_INTOF		0x87	/* integer overflow ? */
9555127Storek #define	T_KGDB_EXEC	0x88	/* for kernel gdb */
9655127Storek #define	T_BSD_SYSCALL	0x89	/* BSD system call */
9755127Storek 
9855127Storek /* 0x8a..0xff are currently unallocated */
9955127Storek 
10055127Storek #ifdef KERNEL			/* pseudo traps for locore.s */
10155127Storek #define	T_RWRET		-1	/* need first user window for trap return */
10255127Storek #define	T_AST		-2	/* no-op, just needed reschedule or profile */
10355127Storek #endif
10455127Storek 
10555127Storek /* flags to system call (flags in %g1 along with syscall number) */
10655127Storek #define	SYSCALL_G2RFLAG	0x400	/* on success, return to %g2 rather than npc */
10755127Storek #define	SYSCALL_G7RFLAG	0x800	/* use %g7 as above (deprecated) */
10855127Storek 
10955127Storek /*
11055127Storek  * `software trap' macros to keep people happy (sparc v8 manual says not
11155127Storek  * to set the upper bits).
11255127Storek  */
11355127Storek #define	ST_BREAKPOINT	(T_BREAKPOINT & 0x7f)
11455127Storek #define	ST_DIV0		(T_DIV0 & 0x7f)
11555127Storek #define	ST_FLUSHWIN	(T_FLUSHWIN & 0x7f)
11655127Storek #define	ST_SYSCALL	(T_BSD_SYSCALL & 0x7f)
11755127Storek 
11855127Storek #endif /* _MACHINE_TRAP_H_ */
119