]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
91447636 | 2 | * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved. |
1c79356b | 3 | * |
8ad349bb | 4 | * @APPLE_LICENSE_OSREFERENCE_HEADER_START@ |
1c79356b | 5 | * |
8ad349bb A |
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. The rights granted to you under the | |
10 | * License may not be used to create, or enable the creation or | |
11 | * redistribution of, unlawful or unlicensed copies of an Apple operating | |
12 | * system, or to circumvent, violate, or enable the circumvention or | |
13 | * violation of, any terms of an Apple operating system software license | |
14 | * agreement. | |
15 | * | |
16 | * Please obtain a copy of the License at | |
17 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
18 | * file. | |
19 | * | |
20 | * The Original Code and all software distributed under the License are | |
21 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
22 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
23 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
24 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
25 | * Please see the License for the specific language governing rights and | |
26 | * limitations under the License. | |
27 | * | |
28 | * @APPLE_LICENSE_OSREFERENCE_HEADER_END@ | |
1c79356b A |
29 | */ |
30 | /* | |
31 | * @OSF_COPYRIGHT@ | |
32 | */ | |
33 | /* | |
34 | * Mach Operating System | |
35 | * Copyright (c) 1991,1990,1989 Carnegie Mellon University | |
36 | * All Rights Reserved. | |
37 | * | |
38 | * Permission to use, copy, modify and distribute this software and its | |
39 | * documentation is hereby granted, provided that both the copyright | |
40 | * notice and this permission notice appear in all copies of the | |
41 | * software, derivative works or modified versions, and any portions | |
42 | * thereof, and that both notices appear in supporting documentation. | |
43 | * | |
44 | * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" | |
45 | * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR | |
46 | * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. | |
47 | * | |
48 | * Carnegie Mellon requests users of this software to return to | |
49 | * | |
50 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU | |
51 | * School of Computer Science | |
52 | * Carnegie Mellon University | |
53 | * Pittsburgh PA 15213-3890 | |
54 | * | |
55 | * any improvements or extensions that they make and grant Carnegie Mellon | |
56 | * the rights to redistribute these changes. | |
57 | */ | |
58 | /* | |
59 | */ | |
60 | /* | |
61 | * File: thread_status.h | |
62 | * Author: Avadis Tevanian, Jr. | |
63 | * Date: 1985 | |
64 | * | |
65 | * This file contains the structure definitions for the thread | |
66 | * state as applied to I386 processors. | |
67 | */ | |
68 | ||
69 | #ifndef _MACH_I386_THREAD_STATUS_H_ | |
70 | #define _MACH_I386_THREAD_STATUS_H_ | |
71 | ||
91447636 | 72 | #include <mach/message.h> |
1c79356b A |
73 | #include <mach/i386/fp_reg.h> |
74 | #include <mach/i386/thread_state.h> | |
5d5c5d0d A |
75 | #include <i386/eflags.h> |
76 | ||
77 | ||
78 | ||
1c79356b | 79 | /* |
5d5c5d0d A |
80 | * the i386_xxxx form is kept for legacy purposes since these types |
81 | * are externally known... eventually they should be deprecated. | |
82 | * our internal implementation has moved to the following naming convention | |
8ad349bb | 83 | * |
5d5c5d0d A |
84 | * x86_xxxx32 names are used to deal with 32 bit states |
85 | * x86_xxxx64 names are used to deal with 64 bit states | |
86 | * x86_xxxx names are used to deal with either 32 or 64 bit states | |
87 | * via a self-describing mechanism | |
c0fea474 A |
88 | */ |
89 | ||
90 | ||
91 | ||
92 | /* | |
5d5c5d0d A |
93 | * these are the legacy names which should be deprecated in the future |
94 | * they are externally known which is the only reason we don't just get | |
95 | * rid of them | |
96 | */ | |
97 | #define i386_THREAD_STATE 1 | |
98 | #define i386_FLOAT_STATE 2 | |
99 | #define i386_EXCEPTION_STATE 3 | |
100 | ||
101 | ||
102 | /* | |
c0fea474 A |
103 | * THREAD_STATE_FLAVOR_LIST 0 |
104 | * these are the supported flavors | |
1c79356b | 105 | */ |
c0fea474 A |
106 | #define x86_THREAD_STATE32 1 |
107 | #define x86_FLOAT_STATE32 2 | |
108 | #define x86_EXCEPTION_STATE32 3 | |
109 | #define x86_THREAD_STATE64 4 | |
110 | #define x86_FLOAT_STATE64 5 | |
111 | #define x86_EXCEPTION_STATE64 6 | |
112 | #define x86_THREAD_STATE 7 | |
113 | #define x86_FLOAT_STATE 8 | |
114 | #define x86_EXCEPTION_STATE 9 | |
115 | #define x86_DEBUG_STATE32 10 | |
116 | #define x86_DEBUG_STATE64 11 | |
117 | #define x86_DEBUG_STATE 12 | |
5d5c5d0d | 118 | #define THREAD_STATE_NONE 13 |
1c79356b | 119 | |
c0fea474 A |
120 | |
121 | ||
8ad349bb A |
122 | /* |
123 | * Largest state on this machine: | |
124 | * (be sure mach/machine/thread_state.h matches!) | |
125 | */ | |
126 | #define THREAD_MACHINE_STATE_MAX THREAD_STATE_MAX | |
127 | ||
8ad349bb A |
128 | |
129 | /* | |
5d5c5d0d A |
130 | * VALID_THREAD_STATE_FLAVOR is a platform specific macro that when passed |
131 | * an exception flavor will return if that is a defined flavor for that | |
132 | * platform. The macro must be manually updated to include all of the valid | |
133 | * exception flavors as defined above. | |
8ad349bb | 134 | */ |
5d5c5d0d A |
135 | #define VALID_THREAD_STATE_FLAVOR(x) \ |
136 | ((x == x86_THREAD_STATE32) || \ | |
137 | (x == x86_FLOAT_STATE32) || \ | |
138 | (x == x86_EXCEPTION_STATE32) || \ | |
139 | (x == x86_DEBUG_STATE32) || \ | |
140 | (x == x86_THREAD_STATE64) || \ | |
141 | (x == x86_FLOAT_STATE64) || \ | |
142 | (x == x86_EXCEPTION_STATE64) || \ | |
143 | (x == x86_DEBUG_STATE64) || \ | |
144 | (x == x86_THREAD_STATE) || \ | |
145 | (x == x86_FLOAT_STATE) || \ | |
146 | (x == x86_EXCEPTION_STATE) || \ | |
147 | (x == x86_DEBUG_STATE) || \ | |
148 | (x == THREAD_STATE_NONE)) | |
8ad349bb | 149 | |
8ad349bb | 150 | |
8ad349bb | 151 | |
5d5c5d0d A |
152 | struct x86_state_hdr { |
153 | int flavor; | |
154 | int count; | |
8ad349bb | 155 | }; |
5d5c5d0d | 156 | typedef struct x86_state_hdr x86_state_hdr_t; |
8ad349bb | 157 | |
8ad349bb | 158 | |
1c79356b | 159 | /* |
c0fea474 A |
160 | * Main thread state consists of |
161 | * general registers, segment registers, | |
162 | * eip and eflags. | |
1c79356b | 163 | */ |
c0fea474 | 164 | |
5d5c5d0d | 165 | struct i386_thread_state { |
c0fea474 A |
166 | unsigned int eax; |
167 | unsigned int ebx; | |
168 | unsigned int ecx; | |
169 | unsigned int edx; | |
170 | unsigned int edi; | |
171 | unsigned int esi; | |
172 | unsigned int ebp; | |
173 | unsigned int esp; | |
174 | unsigned int ss; | |
175 | unsigned int eflags; | |
176 | unsigned int eip; | |
177 | unsigned int cs; | |
178 | unsigned int ds; | |
179 | unsigned int es; | |
180 | unsigned int fs; | |
181 | unsigned int gs; | |
5d5c5d0d | 182 | } ; |
c0fea474 | 183 | |
5d5c5d0d A |
184 | /* |
185 | * to be depecrated in the future | |
186 | */ | |
187 | typedef struct i386_thread_state i386_thread_state_t; | |
c0fea474 A |
188 | #define i386_THREAD_STATE_COUNT ((mach_msg_type_number_t) \ |
189 | ( sizeof (i386_thread_state_t) / sizeof (int) )) | |
190 | ||
5d5c5d0d A |
191 | |
192 | typedef struct i386_thread_state x86_thread_state32_t; | |
c0fea474 A |
193 | #define x86_THREAD_STATE32_COUNT ((mach_msg_type_number_t) \ |
194 | ( sizeof (x86_thread_state32_t) / sizeof (int) )) | |
195 | ||
196 | ||
197 | ||
198 | ||
199 | struct x86_thread_state64 { | |
200 | uint64_t rax; | |
201 | uint64_t rbx; | |
202 | uint64_t rcx; | |
203 | uint64_t rdx; | |
204 | uint64_t rdi; | |
205 | uint64_t rsi; | |
206 | uint64_t rbp; | |
207 | uint64_t rsp; | |
208 | uint64_t r8; | |
209 | uint64_t r9; | |
210 | uint64_t r10; | |
211 | uint64_t r11; | |
212 | uint64_t r12; | |
213 | uint64_t r13; | |
214 | uint64_t r14; | |
215 | uint64_t r15; | |
216 | uint64_t rip; | |
217 | uint64_t rflags; | |
218 | uint64_t cs; | |
219 | uint64_t fs; | |
220 | uint64_t gs; | |
221 | } ; | |
222 | ||
223 | ||
224 | typedef struct x86_thread_state64 x86_thread_state64_t; | |
225 | #define x86_THREAD_STATE64_COUNT ((mach_msg_type_number_t) \ | |
226 | ( sizeof (x86_thread_state64_t) / sizeof (int) )) | |
227 | ||
228 | ||
229 | ||
230 | ||
231 | struct x86_thread_state { | |
232 | x86_state_hdr_t tsh; | |
233 | union { | |
234 | x86_thread_state32_t ts32; | |
235 | x86_thread_state64_t ts64; | |
236 | } uts; | |
237 | } ; | |
238 | ||
239 | ||
240 | typedef struct x86_thread_state x86_thread_state_t; | |
241 | #define x86_THREAD_STATE_COUNT ((mach_msg_type_number_t) \ | |
242 | ( sizeof (x86_thread_state_t) / sizeof (int) )) | |
243 | ||
244 | ||
245 | ||
246 | /* | |
247 | * Default segment register values. | |
248 | */ | |
249 | ||
250 | #define USER_CODE_SELECTOR 0x0017 | |
251 | #define USER_DATA_SELECTOR 0x001f | |
252 | #define KERN_CODE_SELECTOR 0x0008 | |
253 | #define KERN_DATA_SELECTOR 0x0010 | |
254 | ||
5d5c5d0d A |
255 | typedef struct fp_control { |
256 | unsigned short invalid :1, | |
257 | denorm :1, | |
258 | zdiv :1, | |
259 | ovrfl :1, | |
260 | undfl :1, | |
261 | precis :1, | |
262 | :2, | |
263 | pc :2, | |
264 | #define FP_PREC_24B 0 | |
265 | #define FP_PREC_53B 2 | |
266 | #define FP_PREC_64B 3 | |
267 | rc :2, | |
268 | #define FP_RND_NEAR 0 | |
269 | #define FP_RND_DOWN 1 | |
270 | #define FP_RND_UP 2 | |
271 | #define FP_CHOP 3 | |
272 | /*inf*/ :1, | |
273 | :3; | |
274 | } fp_control_t; | |
c0fea474 | 275 | /* |
5d5c5d0d | 276 | * Status word. |
c0fea474 A |
277 | */ |
278 | ||
5d5c5d0d A |
279 | typedef struct fp_status { |
280 | unsigned short invalid :1, | |
281 | denorm :1, | |
282 | zdiv :1, | |
283 | ovrfl :1, | |
284 | undfl :1, | |
285 | precis :1, | |
286 | stkflt :1, | |
287 | errsumm :1, | |
288 | c0 :1, | |
289 | c1 :1, | |
290 | c2 :1, | |
291 | tos :3, | |
292 | c3 :1, | |
293 | busy :1; | |
294 | } fp_status_t; | |
295 | ||
296 | /* defn of 80bit x87 FPU or MMX register */ | |
297 | struct mmst_reg { | |
298 | char mmst_reg[10]; | |
299 | char mmst_rsrv[6]; | |
300 | }; | |
301 | ||
302 | ||
303 | /* defn of 128 bit XMM regs */ | |
304 | struct xmm_reg { | |
305 | char xmm_reg[16]; | |
306 | }; | |
307 | ||
308 | /* | |
309 | * Floating point state. | |
310 | */ | |
c0fea474 | 311 | |
5d5c5d0d A |
312 | #define FP_STATE_BYTES 512 /* number of chars worth of data from fpu_fcw */ |
313 | ||
314 | /* For legacy reasons we need to leave the hw_state as char bytes */ | |
315 | struct i386_float_state { | |
316 | int fpu_reserved[2]; | |
317 | fp_control_t fpu_fcw; /* x87 FPU control word */ | |
318 | fp_status_t fpu_fsw; /* x87 FPU status word */ | |
319 | uint8_t fpu_ftw; /* x87 FPU tag word */ | |
320 | uint8_t fpu_rsrv1; /* reserved */ | |
321 | uint16_t fpu_fop; /* x87 FPU Opcode */ | |
322 | uint32_t fpu_ip; /* x87 FPU Instruction Pointer offset */ | |
323 | uint16_t fpu_cs; /* x87 FPU Instruction Pointer Selector */ | |
324 | uint16_t fpu_rsrv2; /* reserved */ | |
325 | uint32_t fpu_dp; /* x87 FPU Instruction Operand(Data) Pointer offset */ | |
326 | uint16_t fpu_ds; /* x87 FPU Instruction Operand(Data) Pointer Selector */ | |
327 | uint16_t fpu_rsrv3; /* reserved */ | |
328 | uint32_t fpu_mxcsr; /* MXCSR Register state */ | |
329 | uint32_t fpu_mxcsrmask; /* MXCSR mask */ | |
330 | struct mmst_reg fpu_stmm0; /* ST0/MM0 */ | |
331 | struct mmst_reg fpu_stmm1; /* ST1/MM1 */ | |
332 | struct mmst_reg fpu_stmm2; /* ST2/MM2 */ | |
333 | struct mmst_reg fpu_stmm3; /* ST3/MM3 */ | |
334 | struct mmst_reg fpu_stmm4; /* ST4/MM4 */ | |
335 | struct mmst_reg fpu_stmm5; /* ST5/MM5 */ | |
336 | struct mmst_reg fpu_stmm6; /* ST6/MM6 */ | |
337 | struct mmst_reg fpu_stmm7; /* ST7/MM7 */ | |
338 | struct xmm_reg fpu_xmm0; /* XMM 0 */ | |
339 | struct xmm_reg fpu_xmm1; /* XMM 1 */ | |
340 | struct xmm_reg fpu_xmm2; /* XMM 2 */ | |
341 | struct xmm_reg fpu_xmm3; /* XMM 3 */ | |
342 | struct xmm_reg fpu_xmm4; /* XMM 4 */ | |
343 | struct xmm_reg fpu_xmm5; /* XMM 5 */ | |
344 | struct xmm_reg fpu_xmm6; /* XMM 6 */ | |
345 | struct xmm_reg fpu_xmm7; /* XMM 7 */ | |
346 | char fpu_rsrv4[14*16]; /* reserved */ | |
347 | int fpu_reserved1; | |
348 | }; | |
c0fea474 A |
349 | |
350 | ||
351 | /* | |
5d5c5d0d | 352 | * to be depecrated in the future |
c0fea474 | 353 | */ |
5d5c5d0d A |
354 | typedef struct i386_float_state i386_float_state_t; |
355 | #define i386_FLOAT_STATE_COUNT ((mach_msg_type_number_t) \ | |
356 | (sizeof(i386_float_state_t)/sizeof(unsigned int))) | |
357 | ||
358 | typedef struct i386_float_state x86_float_state32_t; | |
c0fea474 A |
359 | #define x86_FLOAT_STATE32_COUNT ((mach_msg_type_number_t) \ |
360 | (sizeof(x86_float_state32_t)/sizeof(unsigned int))) | |
361 | ||
362 | ||
363 | struct x86_float_state64 { | |
364 | int fpu_reserved[2]; | |
365 | fp_control_t fpu_fcw; /* x87 FPU control word */ | |
366 | fp_status_t fpu_fsw; /* x87 FPU status word */ | |
367 | uint8_t fpu_ftw; /* x87 FPU tag word */ | |
368 | uint8_t fpu_rsrv1; /* reserved */ | |
369 | uint16_t fpu_fop; /* x87 FPU Opcode */ | |
370 | uint32_t fpu_ip; /* x87 FPU Instruction Pointer offset */ | |
371 | uint16_t fpu_cs; /* x87 FPU Instruction Pointer Selector */ | |
372 | uint16_t fpu_rsrv2; /* reserved */ | |
373 | uint32_t fpu_dp; /* x87 FPU Instruction Operand(Data) Pointer offset */ | |
374 | uint16_t fpu_ds; /* x87 FPU Instruction Operand(Data) Pointer Selector */ | |
375 | uint16_t fpu_rsrv3; /* reserved */ | |
376 | uint32_t fpu_mxcsr; /* MXCSR Register state */ | |
377 | uint32_t fpu_mxcsrmask; /* MXCSR mask */ | |
378 | struct mmst_reg fpu_stmm0; /* ST0/MM0 */ | |
379 | struct mmst_reg fpu_stmm1; /* ST1/MM1 */ | |
380 | struct mmst_reg fpu_stmm2; /* ST2/MM2 */ | |
381 | struct mmst_reg fpu_stmm3; /* ST3/MM3 */ | |
382 | struct mmst_reg fpu_stmm4; /* ST4/MM4 */ | |
383 | struct mmst_reg fpu_stmm5; /* ST5/MM5 */ | |
384 | struct mmst_reg fpu_stmm6; /* ST6/MM6 */ | |
385 | struct mmst_reg fpu_stmm7; /* ST7/MM7 */ | |
386 | struct xmm_reg fpu_xmm0; /* XMM 0 */ | |
387 | struct xmm_reg fpu_xmm1; /* XMM 1 */ | |
388 | struct xmm_reg fpu_xmm2; /* XMM 2 */ | |
389 | struct xmm_reg fpu_xmm3; /* XMM 3 */ | |
390 | struct xmm_reg fpu_xmm4; /* XMM 4 */ | |
391 | struct xmm_reg fpu_xmm5; /* XMM 5 */ | |
392 | struct xmm_reg fpu_xmm6; /* XMM 6 */ | |
393 | struct xmm_reg fpu_xmm7; /* XMM 7 */ | |
394 | struct xmm_reg fpu_xmm8; /* XMM 8 */ | |
395 | struct xmm_reg fpu_xmm9; /* XMM 9 */ | |
396 | struct xmm_reg fpu_xmm10; /* XMM 10 */ | |
397 | struct xmm_reg fpu_xmm11; /* XMM 11 */ | |
398 | struct xmm_reg fpu_xmm12; /* XMM 12 */ | |
399 | struct xmm_reg fpu_xmm13; /* XMM 13 */ | |
400 | struct xmm_reg fpu_xmm14; /* XMM 14 */ | |
401 | struct xmm_reg fpu_xmm15; /* XMM 15 */ | |
402 | char fpu_rsrv4[6*16]; /* reserved */ | |
403 | int fpu_reserved1; | |
404 | }; | |
405 | ||
406 | typedef struct x86_float_state64 x86_float_state64_t; | |
407 | #define x86_FLOAT_STATE64_COUNT ((mach_msg_type_number_t) \ | |
408 | (sizeof(x86_float_state64_t)/sizeof(unsigned int))) | |
409 | ||
410 | ||
411 | ||
412 | ||
413 | struct x86_float_state { | |
414 | x86_state_hdr_t fsh; | |
415 | union { | |
416 | x86_float_state32_t fs32; | |
417 | x86_float_state64_t fs64; | |
418 | } ufs; | |
419 | } ; | |
420 | ||
421 | ||
422 | typedef struct x86_float_state x86_float_state_t; | |
423 | #define x86_FLOAT_STATE_COUNT ((mach_msg_type_number_t) \ | |
424 | ( sizeof (x86_float_state_t) / sizeof (int) )) | |
425 | ||
426 | ||
427 | ||
428 | /* | |
429 | * Extra state that may be | |
430 | * useful to exception handlers. | |
431 | */ | |
432 | ||
433 | struct i386_exception_state { | |
434 | unsigned int trapno; | |
435 | unsigned int err; | |
436 | unsigned int faultvaddr; | |
437 | }; | |
438 | ||
5d5c5d0d A |
439 | /* |
440 | * to be depecrated in the future | |
441 | */ | |
442 | typedef struct i386_exception_state i386_exception_state_t; | |
443 | #define i386_EXCEPTION_STATE_COUNT ((mach_msg_type_number_t) \ | |
444 | ( sizeof (i386_exception_state_t) / sizeof (int) )) | |
445 | ||
446 | #define I386_EXCEPTION_STATE_COUNT i386_EXCEPTION_STATE_COUNT | |
447 | ||
c0fea474 A |
448 | typedef struct i386_exception_state x86_exception_state32_t; |
449 | #define x86_EXCEPTION_STATE32_COUNT ((mach_msg_type_number_t) \ | |
450 | ( sizeof (x86_exception_state32_t) / sizeof (int) )) | |
451 | ||
452 | struct x86_debug_state32 { | |
453 | unsigned int dr0; | |
454 | unsigned int dr1; | |
455 | unsigned int dr2; | |
456 | unsigned int dr3; | |
457 | unsigned int dr4; | |
458 | unsigned int dr5; | |
459 | unsigned int dr6; | |
460 | unsigned int dr7; | |
461 | }; | |
462 | ||
463 | typedef struct x86_debug_state32 x86_debug_state32_t; | |
464 | #define x86_DEBUG_STATE32_COUNT ((mach_msg_type_number_t) \ | |
465 | ( sizeof (x86_debug_state32_t) / sizeof (int) )) | |
466 | #define X86_DEBUG_STATE32_COUNT x86_DEBUG_STATE32_COUNT | |
467 | ||
468 | ||
469 | struct x86_exception_state64 { | |
470 | unsigned int trapno; | |
471 | unsigned int err; | |
472 | uint64_t faultvaddr; | |
473 | }; | |
474 | ||
475 | typedef struct x86_exception_state64 x86_exception_state64_t; | |
476 | #define x86_EXCEPTION_STATE64_COUNT ((mach_msg_type_number_t) \ | |
477 | ( sizeof (x86_exception_state64_t) / sizeof (int) )) | |
478 | ||
479 | ||
480 | struct x86_debug_state64 { | |
481 | uint64_t dr0; | |
482 | uint64_t dr1; | |
483 | uint64_t dr2; | |
484 | uint64_t dr3; | |
485 | uint64_t dr4; | |
486 | uint64_t dr5; | |
487 | uint64_t dr6; | |
488 | uint64_t dr7; | |
489 | }; | |
490 | ||
491 | ||
492 | typedef struct x86_debug_state64 x86_debug_state64_t; | |
493 | #define x86_DEBUG_STATE64_COUNT ((mach_msg_type_number_t) \ | |
494 | ( sizeof (x86_debug_state64_t) / sizeof (int) )) | |
495 | ||
496 | #define X86_DEBUG_STATE64_COUNT x86_DEBUG_STATE64_COUNT | |
497 | ||
498 | ||
499 | ||
500 | struct x86_exception_state { | |
501 | x86_state_hdr_t esh; | |
502 | union { | |
503 | x86_exception_state32_t es32; | |
504 | x86_exception_state64_t es64; | |
505 | } ues; | |
506 | } ; | |
507 | ||
508 | ||
509 | typedef struct x86_exception_state x86_exception_state_t; | |
510 | #define x86_EXCEPTION_STATE_COUNT ((mach_msg_type_number_t) \ | |
511 | ( sizeof (x86_exception_state_t) / sizeof (int) )) | |
512 | ||
513 | struct x86_debug_state { | |
514 | x86_state_hdr_t dsh; | |
515 | union { | |
516 | x86_debug_state32_t ds32; | |
517 | x86_debug_state64_t ds64; | |
518 | } uds; | |
519 | }; | |
520 | ||
521 | ||
522 | ||
523 | typedef struct x86_debug_state x86_debug_state_t; | |
524 | #define x86_DEBUG_STATE_COUNT ((mach_msg_type_number_t) \ | |
525 | (sizeof(x86_debug_state_t)/sizeof(unsigned int))) | |
526 | ||
5d5c5d0d A |
527 | /* |
528 | * Machine-independent way for servers and Mach's exception mechanism to | |
529 | * choose the most efficient state flavor for exception RPC's: | |
530 | */ | |
531 | #define MACHINE_THREAD_STATE x86_THREAD_STATE | |
532 | #define MACHINE_THREAD_STATE_COUNT x86_THREAD_STATE_COUNT | |
533 | ||
534 | ||
535 | #ifdef XNU_KERNEL_PRIVATE | |
536 | ||
537 | #define x86_SAVED_STATE32 THREAD_STATE_NONE + 1 | |
538 | #define x86_SAVED_STATE64 THREAD_STATE_NONE + 2 | |
539 | ||
540 | #define OLD_i386_THREAD_STATE -1 | |
541 | ||
c0fea474 A |
542 | |
543 | /* | |
5d5c5d0d A |
544 | * when reloading the segment registers on |
545 | * a return out of the kernel, we may take | |
546 | * a GeneralProtection or SegmentNotPresent | |
547 | * fault if one or more of the segment | |
548 | * registers in the saved state was improperly | |
549 | * specified via an x86_THREAD_STATE32 call | |
550 | * the frame we push on top of the existing | |
551 | * save area looks like this... we need to | |
552 | * carry this as part of the save area | |
553 | * in case we get hit so that we have a big | |
554 | * enough stack | |
555 | */ | |
556 | struct x86_seg_load_fault32 { | |
557 | unsigned int trapno; | |
558 | unsigned int err; | |
559 | unsigned int eip; | |
560 | unsigned int cs; | |
561 | unsigned int efl; | |
562 | }; | |
563 | ||
564 | ||
565 | /* | |
566 | * Subset of saved state stored by processor on kernel-to-kernel | |
567 | * trap. (Used by ddb to examine state guaranteed to be present | |
568 | * on all traps into debugger.) | |
569 | */ | |
570 | struct x86_saved_state32_from_kernel { | |
571 | unsigned int gs; | |
572 | unsigned int fs; | |
573 | unsigned int es; | |
574 | unsigned int ds; | |
575 | unsigned int edi; | |
576 | unsigned int esi; | |
577 | unsigned int ebp; | |
578 | unsigned int cr2; /* kernel esp stored by pusha - we save cr2 here later */ | |
579 | unsigned int ebx; | |
580 | unsigned int edx; | |
581 | unsigned int ecx; | |
582 | unsigned int eax; | |
583 | unsigned int trapno; | |
584 | unsigned int err; | |
585 | unsigned int eip; | |
586 | unsigned int cs; | |
587 | unsigned int efl; | |
588 | }; | |
589 | ||
590 | /* | |
591 | * The format in which thread state is saved by Mach on this machine. This | |
592 | * state flavor is most efficient for exception RPC's to kernel-loaded | |
593 | * servers, because copying can be avoided: | |
1c79356b | 594 | */ |
c0fea474 | 595 | |
5d5c5d0d A |
596 | struct x86_saved_state32 { |
597 | unsigned int gs; | |
598 | unsigned int fs; | |
599 | unsigned int es; | |
600 | unsigned int ds; | |
601 | unsigned int edi; | |
602 | unsigned int esi; | |
603 | unsigned int ebp; | |
604 | unsigned int cr2; /* kernel esp stored by pusha - we save cr2 here later */ | |
605 | unsigned int ebx; | |
606 | unsigned int edx; | |
607 | unsigned int ecx; | |
608 | unsigned int eax; | |
609 | unsigned int trapno; | |
610 | unsigned int err; | |
611 | unsigned int eip; | |
612 | unsigned int cs; | |
613 | unsigned int efl; | |
614 | unsigned int uesp; | |
615 | unsigned int ss; | |
616 | }; | |
617 | typedef struct x86_saved_state32 x86_saved_state32_t; | |
8ad349bb | 618 | |
5d5c5d0d A |
619 | #define x86_SAVED_STATE32_COUNT ((mach_msg_type_number_t) \ |
620 | (sizeof (x86_saved_state32_t)/sizeof(unsigned int))) | |
621 | ||
622 | struct x86_saved_state32_tagged { | |
623 | uint32_t tag; | |
624 | struct x86_saved_state32 state; | |
625 | }; | |
626 | typedef struct x86_saved_state32_tagged x86_saved_state32_tagged_t; | |
627 | ||
628 | struct x86_sframe32 { | |
629 | /* | |
630 | * in case we throw a fault reloading | |
631 | * segment registers on a return out of | |
632 | * the kernel... the 'slf' state is only kept | |
633 | * long enough to rejigger (i.e. restore | |
634 | * the save area to its original state) | |
635 | * the save area and throw the appropriate | |
636 | * kernel trap pointing to the 'ssf' state | |
637 | */ | |
638 | struct x86_seg_load_fault32 slf; | |
639 | struct x86_saved_state32_tagged ssf; | |
640 | }; | |
641 | typedef struct x86_sframe32 x86_sframe32_t; | |
642 | ||
643 | ||
644 | ||
645 | /* | |
646 | * This is the state pushed onto the 64-bit interrupt stack | |
647 | * on any exception/trap/interrupt. | |
648 | */ | |
649 | struct x86_64_intr_stack_frame { | |
650 | uint32_t trapno; | |
651 | uint32_t trapfn; | |
652 | uint64_t err; | |
653 | uint64_t rip; | |
654 | uint64_t cs; | |
655 | uint64_t rflags; | |
656 | uint64_t rsp; | |
657 | uint64_t ss; | |
658 | }; | |
659 | typedef struct x86_64_intr_stack_frame x86_64_intr_stack_frame_t; | |
660 | ||
661 | /* | |
662 | * This defines the state saved before entry into compatibility mode. | |
663 | * The machine state is pushed automatically and the compat state is | |
664 | * synthethized in the exception handling code. | |
665 | */ | |
666 | struct x86_saved_state_compat32 { | |
667 | struct x86_saved_state32_tagged iss32; | |
668 | uint32_t pad_for_16byte_alignment[2]; | |
669 | struct x86_64_intr_stack_frame isf64; | |
670 | }; | |
671 | typedef struct x86_saved_state_compat32 x86_saved_state_compat32_t; | |
672 | ||
673 | ||
674 | struct x86_sframe_compat32 { | |
675 | struct x86_64_intr_stack_frame slf; | |
676 | uint32_t pad_for_16byte_alignment[2]; | |
677 | struct x86_saved_state_compat32 ssf; | |
678 | uint32_t empty[4]; | |
679 | }; | |
680 | typedef struct x86_sframe_compat32 x86_sframe_compat32_t; | |
681 | ||
682 | ||
683 | ||
684 | /* | |
685 | * thread state format for task running in 64bit long mode | |
686 | * in long mode, the same hardware frame is always pushed regardless | |
687 | * of whether there was a change in privlege level... therefore, there | |
688 | * is no need for an x86_saved_state64_from_kernel variant | |
689 | */ | |
690 | ||
691 | struct x86_saved_state64 { | |
692 | /* | |
693 | * saved state organized to reflect the | |
694 | * system call ABI register convention | |
695 | * so that we can just pass a pointer | |
696 | * to the saved state when calling through | |
697 | * to the actual system call functions | |
698 | * the ABI limits us to 6 args passed in | |
699 | * registers... I've add v_arg6 - v_arg8 | |
700 | * to accomodate our most 'greedy' system | |
701 | * calls (both BSD and MACH)... the individual | |
702 | * system call handlers will fill these in | |
703 | * via copyin if needed... | |
704 | */ | |
705 | uint64_t rdi; /* arg0 for system call */ | |
706 | uint64_t rsi; | |
707 | uint64_t rdx; | |
708 | uint64_t r10; | |
709 | uint64_t r8; | |
710 | uint64_t r9; /* arg5 for system call */ | |
711 | uint64_t v_arg6; | |
712 | uint64_t v_arg7; | |
713 | uint64_t v_arg8; | |
714 | ||
715 | uint64_t cr2; | |
716 | uint64_t r15; | |
717 | uint64_t r14; | |
718 | uint64_t r13; | |
719 | uint64_t r12; | |
720 | uint64_t r11; | |
721 | uint64_t rbp; | |
722 | uint64_t rbx; | |
723 | uint64_t rcx; | |
724 | uint64_t rax; | |
725 | ||
726 | uint32_t gs; | |
727 | uint32_t fs; | |
728 | struct x86_64_intr_stack_frame isf; | |
729 | }; | |
730 | typedef struct x86_saved_state64 x86_saved_state64_t; | |
731 | #define x86_SAVED_STATE64_COUNT ((mach_msg_type_number_t) \ | |
732 | (sizeof (struct x86_saved_state64)/sizeof(unsigned int))) | |
733 | ||
734 | struct x86_saved_state64_tagged { | |
735 | uint32_t tag; | |
736 | x86_saved_state64_t state; | |
737 | }; | |
738 | typedef struct x86_saved_state64_tagged x86_saved_state64_tagged_t; | |
739 | ||
740 | struct x86_sframe64 { | |
741 | struct x86_64_intr_stack_frame slf; | |
742 | uint32_t pad_for_16byte_alignment[3]; | |
743 | struct x86_saved_state64_tagged ssf; | |
744 | }; | |
745 | typedef struct x86_sframe64 x86_sframe64_t; | |
746 | ||
747 | extern uint32_t get_eflags_exportmask(void); | |
748 | /* | |
749 | * Unified, tagged saved state: | |
750 | */ | |
751 | typedef struct { | |
752 | uint32_t flavor; | |
753 | union { | |
754 | x86_saved_state32_t ss_32; | |
755 | x86_saved_state64_t ss_64; | |
756 | } uss; | |
757 | } x86_saved_state_t; | |
758 | #define ss_32 uss.ss_32 | |
759 | #define ss_64 uss.ss_64 | |
760 | ||
761 | static inline boolean_t | |
762 | is_saved_state64(x86_saved_state_t *iss) | |
763 | { | |
764 | return (iss->flavor == x86_SAVED_STATE64); | |
765 | } | |
766 | ||
767 | static inline boolean_t | |
768 | is_saved_state32(x86_saved_state_t *iss) | |
769 | { | |
770 | return (iss->flavor == x86_SAVED_STATE32); | |
771 | } | |
772 | ||
773 | static inline x86_saved_state32_t * | |
774 | saved_state32(x86_saved_state_t *iss) | |
775 | { | |
776 | return &iss->ss_32; | |
777 | } | |
778 | ||
779 | static inline x86_saved_state64_t * | |
780 | saved_state64(x86_saved_state_t *iss) | |
781 | { | |
782 | return &iss->ss_64; | |
783 | } | |
784 | ||
785 | #endif /* XNU_KERNEL_PRIVATE */ | |
1c79356b A |
786 | |
787 | #endif /* _MACH_I386_THREAD_STATUS_H_ */ |