xref: /csrg-svn/sys/sparc/include/trap.h (revision 55127)
1*55127Storek /*
2*55127Storek  * Copyright (c) 1992 The Regents of the University of California.
3*55127Storek  * All rights reserved.
4*55127Storek  *
5*55127Storek  * This software was developed by the Computer Systems Engineering group
6*55127Storek  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
7*55127Storek  * contributed to Berkeley.
8*55127Storek  *
9*55127Storek  * %sccs.include.redist.c%
10*55127Storek  *
11*55127Storek  *	@(#)trap.h	7.1 (Berkeley) 07/13/92
12*55127Storek  *
13*55127Storek  * from: $Header: trap.h,v 1.8 92/07/03 18:49:02 torek Exp $
14*55127Storek  */
15*55127Storek 
16*55127Storek #ifndef	_MACHINE_TRAP_H
17*55127Storek #define	_MACHINE_TRAP_H
18*55127Storek /*
19*55127Storek  *
20*55127Storek  * The SPARC has a Trap Base Register (TBR) which holds the upper 20 bits
21*55127Storek  * of the trap vector table.  The next eight bits are supplied by the
22*55127Storek  * hardware when the trap occurs, and the bottom four bits are always
23*55127Storek  * zero (so that we can shove up to 16 bytes of executable code---exactly
24*55127Storek  * four instructions---into each trap vector).
25*55127Storek  *
26*55127Storek  * The hardware allocates half the trap vectors to hardware and half to
27*55127Storek  * software.
28*55127Storek  *
29*55127Storek  * Traps have priorities assigned (lower number => higher priority).
30*55127Storek  */
31*55127Storek 
32*55127Storek #if defined(KERNEL) && !defined(LOCORE)
33*55127Storek struct trapvec {
34*55127Storek 	int	tv_instr[4];		/* the four instructions */
35*55127Storek };
36*55127Storek extern struct trapvec trapbase[256];	/* the 256 vectors */
37*55127Storek #endif
38*55127Storek 
39*55127Storek /*	trap		vec	  (pri) description	*/
40*55127Storek #define	T_RESET		0x00	/* (1) not actually vectored; jumps to 0 */
41*55127Storek #define	T_TEXTFAULT	0x01	/* (2) address fault during instr fetch */
42*55127Storek #define	T_ILLINST	0x02	/* (3) illegal instruction */
43*55127Storek #define	T_PRIVINST	0x03	/* (4) privileged instruction */
44*55127Storek #define	T_FPDISABLED	0x04	/* (5) fp instr while fp disabled */
45*55127Storek #define	T_WINOF		0x05	/* (6) register window overflow */
46*55127Storek #define	T_WINUF		0x06	/* (7) register window underflow */
47*55127Storek #define	T_ALIGN		0x07	/* (8) address not properly aligned */
48*55127Storek #define	T_FPE		0x08	/* (9) floating point exception */
49*55127Storek #define	T_DATAFAULT	0x09	/* (10) address fault during data fetch */
50*55127Storek #define	T_TAGOF		0x0a	/* (11) tag overflow */
51*55127Storek /*			0x0b	   unused */
52*55127Storek /*			0x0c	   unused */
53*55127Storek /*			0x0d	   unused */
54*55127Storek /*			0x0e	   unused */
55*55127Storek /*			0x0f	   unused */
56*55127Storek /*			0x10	   unused */
57*55127Storek #define	T_L1INT		0x11	/* (27) level 1 interrupt */
58*55127Storek #define	T_L2INT		0x12	/* (26) level 2 interrupt */
59*55127Storek #define	T_L3INT		0x13	/* (25) level 3 interrupt */
60*55127Storek #define	T_L4INT		0x14	/* (24) level 4 interrupt */
61*55127Storek #define	T_L5INT		0x15	/* (23) level 5 interrupt */
62*55127Storek #define	T_L6INT		0x16	/* (22) level 6 interrupt */
63*55127Storek #define	T_L7INT		0x17	/* (21) level 7 interrupt */
64*55127Storek #define	T_L8INT		0x18	/* (20) level 8 interrupt */
65*55127Storek #define	T_L9INT		0x19	/* (19) level 9 interrupt */
66*55127Storek #define	T_L10INT	0x1a	/* (18) level 10 interrupt */
67*55127Storek #define	T_L11INT	0x1b	/* (17) level 11 interrupt */
68*55127Storek #define	T_L12INT	0x1c	/* (16) level 12 interrupt */
69*55127Storek #define	T_L13INT	0x1d	/* (15) level 13 interrupt */
70*55127Storek #define	T_L14INT	0x1e	/* (14) level 14 interrupt */
71*55127Storek #define	T_L15INT	0x1f	/* (13) level 15 interrupt */
72*55127Storek /*			0x20	   unused */
73*55127Storek /*	through		0x23	   unused */
74*55127Storek #define	T_CPDISABLED	0x24	/* (5) coprocessor instr while disabled */
75*55127Storek /*			0x25	   unused */
76*55127Storek /*	through		0x27	   unused */
77*55127Storek #define	T_CPEXCEPTION	0x28	/* (9) coprocessor exception */
78*55127Storek /*			0x29	   unused */
79*55127Storek /*	through		0x7f	   unused */
80*55127Storek 
81*55127Storek /* beginning of `user' vectors (from trap instructions) - all priority 12 */
82*55127Storek #define	T_SUN_SYSCALL	0x80	/* system call */
83*55127Storek #define	T_BREAKPOINT	0x81	/* breakpoint `instruction' */
84*55127Storek #define	T_DIV0		0x82	/* division routine was handed 0 */
85*55127Storek #define	T_FLUSHWIN	0x83	/* flush windows */
86*55127Storek #define	T_CLEANWIN	0x84	/* provide clean windows */
87*55127Storek #define	T_RANGECHECK	0x85	/* ? */
88*55127Storek #define	T_FIXALIGN	0x86	/* fix up unaligned accesses */
89*55127Storek #define	T_INTOF		0x87	/* integer overflow ? */
90*55127Storek #define	T_KGDB_EXEC	0x88	/* for kernel gdb */
91*55127Storek #define	T_BSD_SYSCALL	0x89	/* BSD system call */
92*55127Storek 
93*55127Storek /* 0x8a..0xff are currently unallocated */
94*55127Storek 
95*55127Storek #ifdef KERNEL			/* pseudo traps for locore.s */
96*55127Storek #define	T_RWRET		-1	/* need first user window for trap return */
97*55127Storek #define	T_AST		-2	/* no-op, just needed reschedule or profile */
98*55127Storek #endif
99*55127Storek 
100*55127Storek /* flags to system call (flags in %g1 along with syscall number) */
101*55127Storek #define	SYSCALL_G2RFLAG	0x400	/* on success, return to %g2 rather than npc */
102*55127Storek #define	SYSCALL_G7RFLAG	0x800	/* use %g7 as above (deprecated) */
103*55127Storek 
104*55127Storek /*
105*55127Storek  * `software trap' macros to keep people happy (sparc v8 manual says not
106*55127Storek  * to set the upper bits).
107*55127Storek  */
108*55127Storek #define	ST_BREAKPOINT	(T_BREAKPOINT & 0x7f)
109*55127Storek #define	ST_DIV0		(T_DIV0 & 0x7f)
110*55127Storek #define	ST_FLUSHWIN	(T_FLUSHWIN & 0x7f)
111*55127Storek #define	ST_SYSCALL	(T_BSD_SYSCALL & 0x7f)
112*55127Storek 
113*55127Storek #endif /* _MACHINE_TRAP_H_ */
114