1 /*        $NetBSD: trap.h,v 1.12 2018/12/19 13:57:50 maxv Exp $ */
2 
3 /*
4  * Copyright (c) 1996-1999 Eduardo Horvath
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  *
12  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR  ``AS IS'' AND
13  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
15  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR  BE LIABLE
16  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
17  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
18  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
19  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
20  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
21  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
22  * SUCH DAMAGE.
23  *
24  */
25 
26 
27 #ifndef   _MACHINE_TRAP_H
28 #define   _MACHINE_TRAP_H
29 
30 /*        trap                vec         (pri) description */
31 /*                            0x000        unused */
32 #define   T_POR               0x001     /* (0) power on reset */
33 #define T_WDR                 0x002     /* (1) watchdog reset */
34 #define T_XIR                 0x003     /* (1) externally initiated reset */
35 #define T_SIR                 0x004     /* (1) software initiated reset */
36 #define T_RED_EXCEPTION       0x005     /* (1) RED state exception */
37 /*                            0x006        unused */
38 /*                            0x007        unused */
39 #define T_INST_EXCEPT         0x008     /* (5) instruction access exception */
40 #define T_TEXTFAULT 0x009     /* (2) ? Text fault */
41 #define T_INST_ERROR          0x00a     /* (3) instruction access error */
42 /*                            0x00b        unused */
43 /*        through             0x00f        unused */
44 #define T_ILLINST   0x010     /* (7) illegal instruction */
45 #define T_PRIVINST  0x011     /* (6) privileged opcode */
46 /*                            0x012        unused */
47 /*        through             0x01f        unused */
48 #define T_FPDISABLED          0x020     /* (8) fpu disabled */
49 #define T_FP_IEEE_754         0x021     /* (11) ieee 754 exception */
50 #define T_FP_OTHER  0x022     /* (11) other fp exception */
51 #define T_TAGOF               0x023     /* (14) tag overflow */
52 #define T_CLEAN_WINDOW        0x024     /* (10) clean window exception */
53 /*        through             0x027        unused */
54 #define T_IDIV0               0x028     /* (15) division by 0 */
55 /*                            0x029        unused */
56 /*        through             0x02f        unused */
57 #define   T_DATAFAULT         0x030     /* (12) address fault during data fetch */
58 #define   T_DATA_MMU_MISS     0x031     /* (N/A) address fault during data fetch [USIII] */
59 #define   T_DATA_ERROR        0x032     /* (12) data access error */
60 #define   T_DATA_PROT         0x033     /* (12) Data protection ??? */
61 #define   T_ALIGN             0x034     /* (10) address not properly aligned */
62 #define   T_LDDF_ALIGN        0x035     /* (10) LDDF address not properly aligned */
63 #define   T_STDF_ALIGN        0x036     /* (10) STDF address not properly aligned */
64 #define T_PRIVACT   0x037     /* (11) privileged action */
65 /*                            0x038        unused */
66 /*        through             0x03f        unused */
67 #define T_ASYNC_ERROR         0x040     /* ???? */
68 #define   T_L1INT             0x041     /* (31) level 1 interrupt */
69 #define   T_L2INT             0x042     /* (30) level 2 interrupt */
70 #define   T_L3INT             0x043     /* (29) level 3 interrupt */
71 #define   T_L4INT             0x044     /* (28) level 4 interrupt */
72 #define   T_L5INT             0x045     /* (27) level 5 interrupt */
73 #define   T_L6INT             0x046     /* (26) level 6 interrupt */
74 #define   T_L7INT             0x047     /* (25) level 7 interrupt */
75 #define   T_L8INT             0x048     /* (24) level 8 interrupt */
76 #define   T_L9INT             0x049     /* (23) level 9 interrupt */
77 #define   T_L10INT  0x04a     /* (22) level 10 interrupt */
78 #define   T_L11INT  0x04b     /* (21) level 11 interrupt */
79 #define   T_L12INT  0x04c     /* (20) level 12 interrupt */
80 #define   T_L13INT  0x04d     /* (19) level 13 interrupt */
81 #define   T_L14INT  0x04e     /* (18) level 14 interrupt */
82 #define   T_L15INT  0x04f     /* (17) level 15 interrupt */
83 /*                            0x050        unused */
84 /*        through             0x05f        unused */
85 #define T_INTVEC    0x060     /* (16) interrupt vector [Interrupt Global Regs]*/
86 #define T_PA_WATCHPT          0x061     /* (12) Physical addr data watchpoint */
87 #define T_VA_WATCHPT          0x062     /* (11) Virtual addr data watchpoint */
88 #define T_ECCERR    0x063     /* (33) ECC correction error */
89 #define T_FIMMU_MISS          0x064     /* (2) fast instruction access MMU miss */
90 /*        through             0x067        unused */
91 #define T_FDMMU_MISS          0x068     /* (2) fast data access MMU miss */
92 /*        through             0x06b        unused */
93 #define T_FDMMU_PROT          0x06c     /* (2) fast data access protection */
94 /*        through             0x06f        unused */
95 /*  0x070...0x07f implementation dependent exceptions */
96 #define T_FAST_ECC_ERROR 0x070          /* (2) fast ECC error [USIII] */
97 #define T_DC_PAR_ERR          0x071     /* (2) dcache parity error [USIII] */
98 #define T_IC_PAR_ERR          0x072     /* (2) icache parity error [USIII] */
99 #define T_CPU_MONDO 0x07c     /* cpu mondo [SUN4V] */
100 #define T_SPILL_N_NORM        0x080     /* (9) spill (n=0..7) normal */
101 /*        through             0x09f        unused */
102 #define T_SPILL_N_OTHER       0x0a0     /* (9) spill (n=0..7) other */
103 /*        through             0x0bF        unused */
104 #define T_FILL_N_NORM         0x0c0     /* (9) fill (n=0..7) normal */
105 /*        through             0x0dF        unused */
106 #define T_FILL_N_OTHER        0x0e0     /* (9) fill (n=0..7) other */
107 /*        through             0x0fF        unused */
108 
109 /* beginning of `user' vectors (from trap instructions) - all priority 16 */
110 #define   T_SUN_SYSCALL       0x100     /* system call */
111 #define   T_BREAKPOINT        0x101     /* breakpoint `instruction' */
112 #define   T_DIV0              0x102     /* division routine was handed 0 */
113 #define   T_FLUSHWIN          0x103     /* flush windows */
114 #define   T_CLEANWIN          0x104     /* provide clean windows */
115 #define   T_RANGECHECK        0x105     /* ? */
116 #define   T_FIXALIGN          0x106     /* fix up unaligned accesses */
117 #define   T_INTOF             0x107     /* integer overflow ? */
118 #define   T_BSD_SYSCALL       0x109     /* BSD system call */
119 #define   T_KGDB_EXEC         0x10a     /* for kernel gdb */
120 
121 /* 0x10c..0x1ff are currently unallocated, except the following */
122 #define T_GETCC                         0x132
123 #define T_SETCC                         0x133
124 #define T_SVID_SYSCALL                  0x164
125 #define   T_SPARC_INTL_SYSCALL          0x165
126 #define   T_OS_VENDOR_SYSCALL 0x166
127 #define   T_HW_OEM_SYSCALL    0x167
128 #define T_RTF_DEF_TRAP                  0x168
129 
130 #ifdef _KERNEL                          /* pseudo traps for locore.s */
131 #define   T_RWRET             -1        /* need first user window for trap return */
132 #define   T_AST               -2        /* no-op, just needed reschedule or profile */
133 #endif
134 
135 /* flags to system call (flags in %g1 along with syscall number) */
136 #define   SYSCALL_G2RFLAG     0x400     /* on success, return to %g2 rather than npc */
137 #define   SYSCALL_G7RFLAG     0x800     /* use %g7 as above (deprecated) */
138 #define   SYSCALL_G5RFLAG     0xc00     /* use %g5 as above (only ABI compatible way) */
139 
140 /* Software traps */
141 #ifdef SUN4V
142 #define ST_FAST_TRAP            0x80
143 #define ST_MMU_MAP_ADDR         0x83
144 #define ST_MMU_UNMAP_ADDR     0x84
145 #define ST_CORE_TRAP                  0xff
146 #endif
147 
148 /*
149  * `software trap' macros to keep people happy (sparc v8 manual says not
150  * to set the upper bits). Correct mask is 0xff for v9, but all values
151  * here are small enough - so keep it the same as the sparc port.
152  */
153 #define   ST_BREAKPOINT       (T_BREAKPOINT & 0x7f)
154 #define   ST_DIV0             (T_DIV0 & 0x7f)
155 #define   ST_FLUSHWIN         (T_FLUSHWIN & 0x7f)
156 #define   ST_SYSCALL          (T_SUN_SYSCALL & 0x7f)
157 
158 #endif /* _MACHINE_TRAP_H_ */
159