]> git.saurik.com Git - apple/xnu.git/blob - osfmk/i386/idt.s
9d85315a16edf731151e845dc4b08b81f1b1730c
[apple/xnu.git] / osfmk / i386 / idt.s
1 /*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23 /*
24 * @OSF_COPYRIGHT@
25 */
26 /*
27 * Mach Operating System
28 * Copyright (c) 1991,1990 Carnegie Mellon University
29 * All Rights Reserved.
30 *
31 * Permission to use, copy, modify and distribute this software and its
32 * documentation is hereby granted, provided that both the copyright
33 * notice and this permission notice appear in all copies of the
34 * software, derivative works or modified versions, and any portions
35 * thereof, and that both notices appear in supporting documentation.
36 *
37 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
38 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
39 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
40 *
41 * Carnegie Mellon requests users of this software to return to
42 *
43 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
44 * School of Computer Science
45 * Carnegie Mellon University
46 * Pittsburgh PA 15213-3890
47 *
48 * any improvements or extensions that they make and grant Carnegie Mellon
49 * the rights to redistribute these changes.
50 */
51 /*
52 */
53 #include <i386/asm.h>
54 #include <assym.s>
55 #include <mach_kdb.h>
56
57 /*
58 * Interrupt descriptor table and code vectors for it.
59 */
60 #define IDT_BASE_ENTRY(vec,seg,type) \
61 .data ;\
62 .long vec ;\
63 .word seg ;\
64 .byte 0 ;\
65 .byte type ;\
66 .text
67
68 #define IDT_ENTRY(vec,type) IDT_BASE_ENTRY(vec,KERNEL_CS,type)
69
70 /*
71 * No error code. Clear error code and push trap number.
72 */
73 #define EXCEPTION(n,name) \
74 IDT_ENTRY(EXT(name),K_TRAP_GATE);\
75 Entry(name) ;\
76 pushl $0 ;\
77 pushl $(n) ;\
78 jmp EXT(alltraps)
79
80 /*
81 * Interrupt from user. Clear error code and push trap number.
82 */
83 #define EXCEP_USR(n,name) \
84 IDT_ENTRY(EXT(name),U_TRAP_GATE);\
85 Entry(name) ;\
86 pushl $0 ;\
87 pushl $(n) ;\
88 jmp EXT(alltraps)
89
90 /*
91 * Special interrupt code.
92 */
93 #define EXCEP_SPC(n,name) \
94 IDT_ENTRY(EXT(name),K_TRAP_GATE)
95
96 /*
97 * Special interrupt code from user.
98 */
99 #define EXCEP_SPC_USR(n,name) \
100 IDT_ENTRY(EXT(name),U_TRAP_GATE)
101
102 /*
103 * Extra-special interrupt code. Note that no offset may be
104 * specified in a task gate descriptor, so name is ignored.
105 */
106 #define EXCEP_TASK(n,name) \
107 IDT_BASE_ENTRY(0,DEBUG_TSS,K_TASK_GATE)
108
109 /*
110 * Error code has been pushed. Push trap number.
111 */
112 #define EXCEP_ERR(n,name) \
113 IDT_ENTRY(EXT(name),K_TRAP_GATE);\
114 Entry(name) ;\
115 pushl $(n) ;\
116 jmp EXT(alltraps)
117
118 /*
119 * Interrupt.
120 */
121 #define INTERRUPT(n) \
122 IDT_ENTRY(0f,K_INTR_GATE) ;\
123 0: ;\
124 pushl %eax ;\
125 movl $(n),%eax ;\
126 jmp EXT(all_intrs)
127
128 .data
129 Entry(idt)
130 .text
131
132 EXCEPTION(0x00,t_zero_div)
133 EXCEP_SPC(0x01,t_debug)
134 INTERRUPT(0x02) /* NMI */
135 EXCEP_USR(0x03,t_int3)
136 EXCEP_USR(0x04,t_into)
137 EXCEP_USR(0x05,t_bounds)
138 EXCEPTION(0x06,t_invop)
139 EXCEPTION(0x07,t_nofpu)
140 #if MACH_KDB
141 EXCEP_TASK(0x08,db_task_dbl_fault)
142 #else
143 EXCEPTION(0x08,a_dbl_fault)
144 #endif
145 EXCEPTION(0x09,a_fpu_over)
146 EXCEPTION(0x0a,a_inv_tss)
147 EXCEP_SPC(0x0b,t_segnp)
148 #if MACH_KDB
149 EXCEP_TASK(0x0c,db_task_stk_fault)
150 #else
151 EXCEP_ERR(0x0c,t_stack_fault)
152 #endif
153 EXCEP_SPC(0x0d,t_gen_prot)
154 EXCEP_SPC(0x0e,t_page_fault)
155 EXCEPTION(0x0f,t_trap_0f)
156 EXCEPTION(0x10,t_fpu_err)
157 EXCEPTION(0x11,t_trap_11)
158 EXCEPTION(0x12,t_trap_12)
159 EXCEPTION(0x13,t_trap_13)
160 EXCEPTION(0x14,t_trap_14)
161 EXCEPTION(0x15,t_trap_15)
162 EXCEPTION(0x16,t_trap_16)
163 EXCEPTION(0x17,t_trap_17)
164 EXCEPTION(0x18,t_trap_18)
165 EXCEPTION(0x19,t_trap_19)
166 EXCEPTION(0x1a,t_trap_1a)
167 EXCEPTION(0x1b,t_trap_1b)
168 EXCEPTION(0x1c,t_trap_1c)
169 EXCEPTION(0x1d,t_trap_1d)
170 EXCEPTION(0x1e,t_trap_1e)
171 EXCEPTION(0x1f,t_trap_1f)
172
173 INTERRUPT(0x20)
174 INTERRUPT(0x21)
175 INTERRUPT(0x22)
176 INTERRUPT(0x23)
177 INTERRUPT(0x24)
178 INTERRUPT(0x25)
179 INTERRUPT(0x26)
180 INTERRUPT(0x27)
181 INTERRUPT(0x28)
182 INTERRUPT(0x29)
183 INTERRUPT(0x2a)
184 INTERRUPT(0x2b)
185 INTERRUPT(0x2c)
186 INTERRUPT(0x2d)
187 INTERRUPT(0x2e)
188 INTERRUPT(0x2f)
189
190 INTERRUPT(0x30)
191 INTERRUPT(0x31)
192 INTERRUPT(0x32)
193 INTERRUPT(0x33)
194 INTERRUPT(0x34)
195 INTERRUPT(0x35)
196 INTERRUPT(0x36)
197 INTERRUPT(0x37)
198 INTERRUPT(0x38)
199 INTERRUPT(0x39)
200 INTERRUPT(0x3a)
201 INTERRUPT(0x3b)
202 INTERRUPT(0x3c)
203 INTERRUPT(0x3d)
204 INTERRUPT(0x3e)
205 INTERRUPT(0x3f)
206
207 INTERRUPT(0x40)
208 INTERRUPT(0x41)
209 INTERRUPT(0x42)
210 INTERRUPT(0x43)
211 INTERRUPT(0x44)
212 INTERRUPT(0x45)
213 INTERRUPT(0x46)
214 INTERRUPT(0x47)
215 INTERRUPT(0x48)
216 INTERRUPT(0x49)
217 INTERRUPT(0x4a)
218 INTERRUPT(0x4b)
219 INTERRUPT(0x4c)
220 INTERRUPT(0x4d)
221 INTERRUPT(0x4e)
222 INTERRUPT(0x4f)
223
224 INTERRUPT(0x50)
225 INTERRUPT(0x51)
226 INTERRUPT(0x52)
227 INTERRUPT(0x53)
228 INTERRUPT(0x54)
229 INTERRUPT(0x55)
230 INTERRUPT(0x56)
231 INTERRUPT(0x57)
232 INTERRUPT(0x58)
233 INTERRUPT(0x59)
234 INTERRUPT(0x5a)
235 INTERRUPT(0x5b)
236 INTERRUPT(0x5c)
237 INTERRUPT(0x5d)
238 INTERRUPT(0x5e)
239 INTERRUPT(0x5f)
240
241 INTERRUPT(0x60)
242 INTERRUPT(0x61)
243 INTERRUPT(0x62)
244 INTERRUPT(0x63)
245 INTERRUPT(0x64)
246 INTERRUPT(0x65)
247 INTERRUPT(0x66)
248 INTERRUPT(0x67)
249 INTERRUPT(0x68)
250 INTERRUPT(0x69)
251 INTERRUPT(0x6a)
252 INTERRUPT(0x6b)
253 INTERRUPT(0x6c)
254 INTERRUPT(0x6d)
255 INTERRUPT(0x6e)
256 INTERRUPT(0x6f)
257
258 INTERRUPT(0x70)
259 INTERRUPT(0x71)
260 INTERRUPT(0x72)
261 INTERRUPT(0x73)
262 INTERRUPT(0x74)
263 INTERRUPT(0x75)
264 INTERRUPT(0x76)
265 INTERRUPT(0x77)
266 INTERRUPT(0x78)
267 INTERRUPT(0x79)
268 INTERRUPT(0x7a)
269 INTERRUPT(0x7b)
270 INTERRUPT(0x7c)
271 INTERRUPT(0x7d)
272 INTERRUPT(0x7e)
273 INTERRUPT(0x7f)
274
275 EXCEP_SPC_USR(0x80,syscall_int80)
276 INTERRUPT(0x81)
277 INTERRUPT(0x82)
278 INTERRUPT(0x83)
279 INTERRUPT(0x84)
280 INTERRUPT(0x85)
281 INTERRUPT(0x86)
282 INTERRUPT(0x87)
283 INTERRUPT(0x88)
284 INTERRUPT(0x89)
285 INTERRUPT(0x8a)
286 INTERRUPT(0x8b)
287 INTERRUPT(0x8c)
288 INTERRUPT(0x8d)
289 INTERRUPT(0x8e)
290 INTERRUPT(0x8f)
291
292 INTERRUPT(0x90)
293 INTERRUPT(0x91)
294 INTERRUPT(0x92)
295 INTERRUPT(0x93)
296 INTERRUPT(0x94)
297 INTERRUPT(0x95)
298 INTERRUPT(0x96)
299 INTERRUPT(0x97)
300 INTERRUPT(0x98)
301 INTERRUPT(0x99)
302 INTERRUPT(0x9a)
303 INTERRUPT(0x9b)
304 INTERRUPT(0x9c)
305 INTERRUPT(0x9d)
306 INTERRUPT(0x9e)
307 INTERRUPT(0x9f)
308
309 INTERRUPT(0xa0)
310 INTERRUPT(0xa1)
311 INTERRUPT(0xa2)
312 INTERRUPT(0xa3)
313 INTERRUPT(0xa4)
314 INTERRUPT(0xa5)
315 INTERRUPT(0xa6)
316 INTERRUPT(0xa7)
317 INTERRUPT(0xa8)
318 INTERRUPT(0xa9)
319 INTERRUPT(0xaa)
320 INTERRUPT(0xab)
321 INTERRUPT(0xac)
322 INTERRUPT(0xad)
323 INTERRUPT(0xae)
324 INTERRUPT(0xaf)
325
326 INTERRUPT(0xb0)
327 INTERRUPT(0xb1)
328 INTERRUPT(0xb2)
329 INTERRUPT(0xb3)
330 INTERRUPT(0xb4)
331 INTERRUPT(0xb5)
332 INTERRUPT(0xb6)
333 INTERRUPT(0xb7)
334 INTERRUPT(0xb8)
335 INTERRUPT(0xb9)
336 INTERRUPT(0xba)
337 INTERRUPT(0xbb)
338 INTERRUPT(0xbc)
339 INTERRUPT(0xbd)
340 INTERRUPT(0xbe)
341 INTERRUPT(0xbf)
342
343 INTERRUPT(0xc0)
344 INTERRUPT(0xc1)
345 INTERRUPT(0xc2)
346 INTERRUPT(0xc3)
347 INTERRUPT(0xc4)
348 INTERRUPT(0xc5)
349 INTERRUPT(0xc6)
350 INTERRUPT(0xc7)
351 INTERRUPT(0xc8)
352 INTERRUPT(0xc9)
353 INTERRUPT(0xca)
354 INTERRUPT(0xcb)
355 INTERRUPT(0xcc)
356 INTERRUPT(0xcd)
357 INTERRUPT(0xce)
358 INTERRUPT(0xcf)
359
360 INTERRUPT(0xd0)
361 INTERRUPT(0xd1)
362 INTERRUPT(0xd2)
363 INTERRUPT(0xd3)
364 INTERRUPT(0xd4)
365 INTERRUPT(0xd5)
366 INTERRUPT(0xd6)
367 INTERRUPT(0xd7)
368 INTERRUPT(0xd8)
369 INTERRUPT(0xd9)
370 INTERRUPT(0xda)
371 INTERRUPT(0xdb)
372 INTERRUPT(0xdc)
373 INTERRUPT(0xdd)
374 INTERRUPT(0xde)
375 INTERRUPT(0xdf)
376
377 INTERRUPT(0xe0)
378 INTERRUPT(0xe1)
379 INTERRUPT(0xe2)
380 INTERRUPT(0xe3)
381 INTERRUPT(0xe4)
382 INTERRUPT(0xe5)
383 INTERRUPT(0xe6)
384 INTERRUPT(0xe7)
385 INTERRUPT(0xe8)
386 INTERRUPT(0xe9)
387 INTERRUPT(0xea)
388 INTERRUPT(0xeb)
389 INTERRUPT(0xec)
390 INTERRUPT(0xed)
391 INTERRUPT(0xee)
392 INTERRUPT(0xef)
393
394 INTERRUPT(0xf0)
395 INTERRUPT(0xf1)
396 INTERRUPT(0xf2)
397 INTERRUPT(0xf3)
398 INTERRUPT(0xf4)
399 INTERRUPT(0xf5)
400 INTERRUPT(0xf6)
401 INTERRUPT(0xf7)
402 INTERRUPT(0xf8)
403 INTERRUPT(0xf9)
404 INTERRUPT(0xfa)
405 INTERRUPT(0xfb)
406 INTERRUPT(0xfc)
407 INTERRUPT(0xfd)
408 INTERRUPT(0xfe)
409 EXCEPTION(0xff,t_preempt)
410