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