VirtualBox

source: vbox/trunk/include/VBox/x86.h@ 3700

Last change on this file since 3700 was 3632, checked in by vboxsync, 18 years ago

VBox_hdr_h -> _VBox_hdr_h

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 74.3 KB
Line 
1/** @file
2 * X86 (and AMD64) Structures and Definitions.
3 */
4
5/*
6 * Copyright (C) 2006-2007 innotek GmbH
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License as published by the Free Software Foundation,
12 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
13 * distribution. VirtualBox OSE is distributed in the hope that it will
14 * be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * If you received this file as part of a commercial VirtualBox
17 * distribution, then only the terms of your commercial VirtualBox
18 * license agreement apply instead of the previous paragraph.
19 */
20
21/*
22 * x86.mac is generated from this file using:
23 * sed -e '/__VBox_x86_h__/d' -e '/#define/!d' -e 's/#define/%define/' include/VBox/x86.h
24 */
25
26#ifndef ___VBox_x86_h
27#define ___VBox_x86_h
28
29#include <VBox/types.h>
30
31/** @defgroup grp_x86 x86 Types and Definitions
32 * @{
33 */
34
35/**
36 * EFLAGS Bits.
37 */
38typedef struct X86EFLAGSBITS
39{
40 /** Bit 0 - CF - Carry flag - Status flag. */
41 unsigned u1CF : 1;
42 /** Bit 1 - 1 - Reserved flag. */
43 unsigned u1Reserved0 : 1;
44 /** Bit 2 - PF - Parity flag - Status flag. */
45 unsigned u1PF : 1;
46 /** Bit 3 - 0 - Reserved flag. */
47 unsigned u1Reserved1 : 1;
48 /** Bit 4 - AF - Auxiliary carry flag - Status flag. */
49 unsigned u1AF : 1;
50 /** Bit 5 - 0 - Reserved flag. */
51 unsigned u1Reserved2 : 1;
52 /** Bit 6 - ZF - Zero flag - Status flag. */
53 unsigned u1ZF : 1;
54 /** Bit 7 - SF - Signed flag - Status flag. */
55 unsigned u1SF : 1;
56 /** Bit 8 - TF - Trap flag - System flag. */
57 unsigned u1TF : 1;
58 /** Bit 9 - IF - Interrupt flag - System flag. */
59 unsigned u1IF : 1;
60 /** Bit 10 - DF - Direction flag - Control flag. */
61 unsigned u1DF : 1;
62 /** Bit 11 - OF - Overflow flag - Status flag. */
63 unsigned u1OF : 1;
64 /** Bit 12-13 - IOPL - I/O prvilege level flag - System flag. */
65 unsigned u2IOPL : 2;
66 /** Bit 14 - NT - Nested task flag - System flag. */
67 unsigned u1NT : 1;
68 /** Bit 15 - 0 - Reserved flag. */
69 unsigned u1Reserved3 : 1;
70 /** Bit 16 - RF - Resume flag - System flag. */
71 unsigned u1RF : 1;
72 /** Bit 17 - VM - Virtual 8086 mode - System flag. */
73 unsigned u1VM : 1;
74 /** Bit 18 - AC - Alignment check flag - System flag. Works with CR0.AM. */
75 unsigned u1AC : 1;
76 /** Bit 19 - VIF - Virtual interupt flag - System flag. */
77 unsigned u1VIF : 1;
78 /** Bit 20 - VIP - Virtual interupt pending flag - System flag. */
79 unsigned u1VIP : 1;
80 /** Bit 21 - ID - CPUID flag - System flag. If this responds to flipping CPUID is supported. */
81 unsigned u1ID : 1;
82 /** Bit 22-31 - 0 - Reserved flag. */
83 unsigned u10Reserved4 : 10;
84} X86EFLAGSBITS;
85/** Pointer to EFLAGS bits. */
86typedef X86EFLAGSBITS *PX86EFLAGSBITS;
87/** Pointer to const EFLAGS bits. */
88typedef const X86EFLAGSBITS *PCX86EFLAGSBITS;
89
90/**
91 * EFLAGS.
92 */
93typedef union X86EFLAGS
94{
95 /** The bitfield view. */
96 X86EFLAGSBITS Bits;
97 /** The 8-bit view. */
98 uint8_t au8[4];
99 /** The 16-bit view. */
100 uint16_t au16[2];
101 /** The 32-bit view. */
102 uint32_t au32[1];
103 /** The 32-bit view. */
104 uint32_t u32;
105} X86EFLAGS;
106/** Pointer to EFLAGS. */
107typedef X86EFLAGS *PX86EFLAGS;
108/** Pointer to const EFLAGS. */
109typedef const X86EFLAGS *PCX86EFLAGS;
110
111
112/** @name EFLAGS
113 * @{
114 */
115/** Bit 0 - CF - Carry flag - Status flag. */
116#define X86_EFL_CF BIT(0)
117/** Bit 2 - PF - Parity flag - Status flag. */
118#define X86_EFL_PF BIT(2)
119/** Bit 4 - AF - Auxiliary carry flag - Status flag. */
120#define X86_EFL_AF BIT(4)
121/** Bit 6 - ZF - Zero flag - Status flag. */
122#define X86_EFL_ZF BIT(6)
123/** Bit 7 - SF - Signed flag - Status flag. */
124#define X86_EFL_SF BIT(7)
125/** Bit 8 - TF - Trap flag - System flag. */
126#define X86_EFL_TF BIT(8)
127/** Bit 9 - IF - Interrupt flag - System flag. */
128#define X86_EFL_IF BIT(9)
129/** Bit 10 - DF - Direction flag - Control flag. */
130#define X86_EFL_DF BIT(10)
131/** Bit 11 - OF - Overflow flag - Status flag. */
132#define X86_EFL_OF BIT(11)
133/** Bit 12-13 - IOPL - I/O prvilege level flag - System flag. */
134#define X86_EFL_IOPL (BIT(12) | BIT(13))
135/** Bit 14 - NT - Nested task flag - System flag. */
136#define X86_EFL_NT BIT(14)
137/** Bit 16 - RF - Resume flag - System flag. */
138#define X86_EFL_RF BIT(16)
139/** Bit 17 - VM - Virtual 8086 mode - System flag. */
140#define X86_EFL_VM BIT(17)
141/** Bit 18 - AC - Alignment check flag - System flag. Works with CR0.AM. */
142#define X86_EFL_AC BIT(18)
143/** Bit 19 - VIF - Virtual interupt flag - System flag. */
144#define X86_EFL_VIF BIT(19)
145/** Bit 20 - VIP - Virtual interupt pending flag - System flag. */
146#define X86_EFL_VIP BIT(20)
147/** Bit 21 - ID - CPUID flag - System flag. If this responds to flipping CPUID is supported. */
148#define X86_EFL_ID BIT(21)
149/** IOPL shift. */
150#define X86_EFL_IOPL_SHIFT 12
151/** The the IOPL level from the flags. */
152#define X86_EFL_GET_IOPL(efl) (((efl) >> X86_EFL_IOPL_SHIFT) & 3)
153/** @} */
154
155
156/** CPUID Feature information - ECX.
157 * CPUID query with EAX=1.
158 */
159typedef struct X86CPUIDFEATECX
160{
161 /** Bit 0 - SSE3 - Supports SSE3 or not. */
162 unsigned u1SSE3 : 1;
163 /** Reserved. */
164 unsigned u2Reserved1 : 2;
165 /** Bit 3 - MONITOR - Supports MONITOR/MWAIT. */
166 unsigned u1Monitor : 1;
167 /** Bit 4 - CPL-DS - CPL Qualified Debug Store. */
168 unsigned u1CPLDS : 1;
169 /** Bit 5 - VMX - Virtual Machine Technology. */
170 unsigned u1VMX : 1;
171 /** Reserved. */
172 unsigned u1Reserved2 : 1;
173 /** Bit 7 - EST - Enh. SpeedStep Tech. */
174 unsigned u1EST : 1;
175 /** Bit 8 - TM2 - Terminal Monitor 2. */
176 unsigned u1TM2 : 1;
177 /** Reserved. */
178 unsigned u1Reserved3 : 1;
179 /** Bit 10 - CNTX-ID - L1 Context ID. */
180 unsigned u1CNTXID : 1;
181 /** Reserved. */
182 unsigned u2Reserved4 : 2;
183 /** Bit 13 - CX16 - CMPXCHG16B. */
184 unsigned u1CX16 : 1;
185 /** Reserved. */
186 unsigned u18Reserved5 : 18;
187
188} X86CPUIDFEATECX;
189/** Pointer to CPUID Feature Information - ECX. */
190typedef X86CPUIDFEATECX *PX86CPUIDFEATECX;
191/** Pointer to const CPUID Feature Information - ECX. */
192typedef const X86CPUIDFEATECX *PCX86CPUIDFEATECX;
193
194
195/** CPUID Feature Information - EDX.
196 * CPUID query with EAX=1.
197 */
198typedef struct X86CPUIDFEATEDX
199{
200 /** Bit 0 - FPU - x87 FPU on Chip. */
201 unsigned u1FPU : 1;
202 /** Bit 1 - VME - Virtual 8086 Mode Enhancements. */
203 unsigned u1VME : 1;
204 /** Bit 2 - DE - Debugging extensions. */
205 unsigned u1DE : 1;
206 /** Bit 3 - PSE - Page Size Extension. */
207 unsigned u1PSE : 1;
208 /** Bit 4 - TSC - Tiem Stamp Counter. */
209 unsigned u1TSC : 1;
210 /** Bit 5 - MSR - Model Specific Registers RDMSR and WRMSR Instructions. */
211 unsigned u1MSR : 1;
212 /** Bit 6 - PAE - Physical Address Extension. */
213 unsigned u1PAE : 1;
214 /** Bit 7 - MCE - Machine Check Exception. */
215 unsigned u1MCE : 1;
216 /** Bit 8 - CX8 - CMPXCHG8B instruction. */
217 unsigned u1CX8 : 1;
218 /** Bit 9 - APIC - APIC On-Chick. */
219 unsigned u1APIC : 1;
220 /** Bit 10 - Reserved. */
221 unsigned u1Reserved1 : 1;
222 /** Bit 11 - SEP - SYSENTER and SYSEXIT. */
223 unsigned u1SEP : 1;
224 /** Bit 12 - MTRR - Memory Type Range Registers. */
225 unsigned u1MTRR : 1;
226 /** Bit 13 - PGE - PTE Global Bit. */
227 unsigned u1PGE : 1;
228 /** Bit 14 - MCA - Machine Check Architecture. */
229 unsigned u1MCA : 1;
230 /** Bit 15 - CMOV - Conditional Move Instructions. */
231 unsigned u1CMOV : 1;
232 /** Bit 16 - PAT - Page Attribute Table. */
233 unsigned u1PAT : 1;
234 /** Bit 17 - PSE-36 - 36-bit Page Size Extention. */
235 unsigned u1PSE36 : 1;
236 /** Bit 18 - PSN - Processor Serial Number. */
237 unsigned u1PSN : 1;
238 /** Bit 19 - CLFSH - CLFLUSH Instruction. */
239 unsigned u1CLFSH : 1;
240 /** Bit 20 - Reserved. */
241 unsigned u1Reserved2 : 1;
242 /** Bit 21 - DS - Debug Store. */
243 unsigned u1DS : 1;
244 /** Bit 22 - ACPI - Thermal Monitor and Software Controlled Clock Facilities. */
245 unsigned u1ACPI : 1;
246 /** Bit 23 - MMX - Intel MMX 'Technology'. */
247 unsigned u1MMX : 1;
248 /** Bit 24 - FXSR - FXSAVE and FXRSTOR Instructions. */
249 unsigned u1FXSR : 1;
250 /** Bit 25 - SSE - SSE Support. */
251 unsigned u1SSE : 1;
252 /** Bit 26 - SSE2 - SSE2 Support. */
253 unsigned u1SSE2 : 1;
254 /** Bit 27 - SS - Self Snoop. */
255 unsigned u1SS : 1;
256 /** Bit 28 - HTT - Hyper-Threading Technology. */
257 unsigned u1HTT : 1;
258 /** Bit 29 - TM - Thermal Monitor. */
259 unsigned u1TM : 1;
260 /** Bit 30 - Reserved - . */
261 unsigned u1Reserved3 : 1;
262 /** Bit 31 - PBE - Pending Break Enabled. */
263 unsigned u1PBE : 1;
264} X86CPUIDFEATEDX;
265/** Pointer to CPUID Feature Information - EDX. */
266typedef X86CPUIDFEATEDX *PX86CPUIDFEATEDX;
267/** Pointer to const CPUID Feature Information - EDX. */
268typedef const X86CPUIDFEATEDX *PCX86CPUIDFEATEDX;
269
270
271/** @name CPUID Feature information.
272 * CPUID query with EAX=1.
273 * @{
274 */
275/** ECX Bit 0 - SSE3 - Supports SSE3 or not. */
276#define X86_CPUID_FEATURE_ECX_SSE3 BIT(0)
277/** ECX Bit 3 - MONITOR - Supports MONITOR/MWAIT. */
278#define X86_CPUID_FEATURE_ECX_MONITOR BIT(3)
279/** ECX Bit 4 - CPL-DS - CPL Qualified Debug Store. */
280#define X86_CPUID_FEATURE_ECX_CPLDS BIT(4)
281/** ECX Bit 5 - VMX - Virtual Machine Technology. */
282#define X86_CPUID_FEATURE_ECX_VMX BIT(5)
283/** ECX Bit 7 - EST - Enh. SpeedStep Tech. */
284#define X86_CPUID_FEATURE_ECX_EST BIT(7)
285/** ECX Bit 8 - TM2 - Terminal Monitor 2. */
286#define X86_CPUID_FEATURE_ECX_TM2 BIT(8)
287/** ECX Bit 10 - CNTX-ID - L1 Context ID. */
288#define X86_CPUID_FEATURE_ECX_CNTXID BIT(10)
289/** ECX Bit 13 - CX16 - L1 Context ID. */
290#define X86_CPUID_FEATURE_ECX_CX16 BIT(13)
291
292
293/** Bit 0 - FPU - x87 FPU on Chip. */
294#define X86_CPUID_FEATURE_EDX_FPU BIT(0)
295/** Bit 1 - VME - Virtual 8086 Mode Enhancements. */
296#define X86_CPUID_FEATURE_EDX_VME BIT(1)
297/** Bit 2 - DE - Debugging extensions. */
298#define X86_CPUID_FEATURE_EDX_DE BIT(2)
299/** Bit 3 - PSE - Page Size Extension. */
300#define X86_CPUID_FEATURE_EDX_PSE BIT(3)
301/** Bit 4 - TSC - Time Stamp Counter. */
302#define X86_CPUID_FEATURE_EDX_TSC BIT(4)
303/** Bit 5 - MSR - Model Specific Registers RDMSR and WRMSR Instructions. */
304#define X86_CPUID_FEATURE_EDX_MSR BIT(5)
305/** Bit 6 - PAE - Physical Address Extension. */
306#define X86_CPUID_FEATURE_EDX_PAE BIT(6)
307/** Bit 7 - MCE - Machine Check Exception. */
308#define X86_CPUID_FEATURE_EDX_MCE BIT(7)
309/** Bit 8 - CX8 - CMPXCHG8B instruction. */
310#define X86_CPUID_FEATURE_EDX_CX8 BIT(8)
311/** Bit 9 - APIC - APIC On-Chip. */
312#define X86_CPUID_FEATURE_EDX_APIC BIT(9)
313/** Bit 11 - SEP - SYSENTER and SYSEXIT. */
314#define X86_CPUID_FEATURE_EDX_SEP BIT(11)
315/** Bit 12 - MTRR - Memory Type Range Registers. */
316#define X86_CPUID_FEATURE_EDX_MTRR BIT(12)
317/** Bit 13 - PGE - PTE Global Bit. */
318#define X86_CPUID_FEATURE_EDX_PGE BIT(13)
319/** Bit 14 - MCA - Machine Check Architecture. */
320#define X86_CPUID_FEATURE_EDX_MCA BIT(14)
321/** Bit 15 - CMOV - Conditional Move Instructions. */
322#define X86_CPUID_FEATURE_EDX_CMOV BIT(15)
323/** Bit 16 - PAT - Page Attribute Table. */
324#define X86_CPUID_FEATURE_EDX_PAT BIT(16)
325/** Bit 17 - PSE-36 - 36-bit Page Size Extention. */
326#define X86_CPUID_FEATURE_EDX_PSE36 BIT(17)
327/** Bit 18 - PSN - Processor Serial Number. */
328#define X86_CPUID_FEATURE_EDX_PSN BIT(18)
329/** Bit 19 - CLFSH - CLFLUSH Instruction. */
330#define X86_CPUID_FEATURE_EDX_CLFSH BIT(19)
331/** Bit 21 - DS - Debug Store. */
332#define X86_CPUID_FEATURE_EDX_DS BIT(21)
333/** Bit 22 - ACPI - Termal Monitor and Software Controlled Clock Facilities. */
334#define X86_CPUID_FEATURE_EDX_ACPI BIT(22)
335/** Bit 23 - MMX - Intel MMX Technology. */
336#define X86_CPUID_FEATURE_EDX_MMX BIT(23)
337/** Bit 24 - FXSR - FXSAVE and FXRSTOR Instructions. */
338#define X86_CPUID_FEATURE_EDX_FXSR BIT(24)
339/** Bit 25 - SSE - SSE Support. */
340#define X86_CPUID_FEATURE_EDX_SSE BIT(25)
341/** Bit 26 - SSE2 - SSE2 Support. */
342#define X86_CPUID_FEATURE_EDX_SSE2 BIT(26)
343/** Bit 27 - SS - Self Snoop. */
344#define X86_CPUID_FEATURE_EDX_SS BIT(27)
345/** Bit 28 - HTT - Hyper-Threading Technology. */
346#define X86_CPUID_FEATURE_EDX_HTT BIT(28)
347/** Bit 29 - TM - Therm. Monitor. */
348#define X86_CPUID_FEATURE_EDX_TM BIT(29)
349/** Bit 31 - PBE - Pending Break Enabled. */
350#define X86_CPUID_FEATURE_EDX_PBE BIT(31)
351/** @} */
352
353
354/** @name CPUID AMD Feature information.
355 * CPUID query with EAX=0x80000001.
356 * @{
357 */
358/** Bit 0 - FPU - x87 FPU on Chip. */
359#define X86_CPUID_AMD_FEATURE_EDX_FPU BIT(0)
360/** Bit 1 - VME - Virtual 8086 Mode Enhancements. */
361#define X86_CPUID_AMD_FEATURE_EDX_VME BIT(1)
362/** Bit 2 - DE - Debugging extensions. */
363#define X86_CPUID_AMD_FEATURE_EDX_DE BIT(2)
364/** Bit 3 - PSE - Page Size Extension. */
365#define X86_CPUID_AMD_FEATURE_EDX_PSE BIT(3)
366/** Bit 4 - TSC - Time Stamp Counter. */
367#define X86_CPUID_AMD_FEATURE_EDX_TSC BIT(4)
368/** Bit 5 - MSR - K86 Model Specific Registers RDMSR and WRMSR Instructions. */
369#define X86_CPUID_AMD_FEATURE_EDX_MSR BIT(5)
370/** Bit 6 - PAE - Physical Address Extension. */
371#define X86_CPUID_AMD_FEATURE_EDX_PAE BIT(6)
372/** Bit 7 - MCE - Machine Check Exception. */
373#define X86_CPUID_AMD_FEATURE_EDX_MCE BIT(7)
374/** Bit 8 - CX8 - CMPXCHG8B instruction. */
375#define X86_CPUID_AMD_FEATURE_EDX_CX8 BIT(8)
376/** Bit 9 - APIC - APIC On-Chip. */
377#define X86_CPUID_AMD_FEATURE_EDX_APIC BIT(9)
378/** Bit 11 - SEP - AMD SYSCALL and SYSRET. */
379#define X86_CPUID_AMD_FEATURE_EDX_SEP BIT(11)
380/** Bit 12 - MTRR - Memory Type Range Registers. */
381#define X86_CPUID_AMD_FEATURE_EDX_MTRR BIT(12)
382/** Bit 13 - PGE - PTE Global Bit. */
383#define X86_CPUID_AMD_FEATURE_EDX_PGE BIT(13)
384/** Bit 14 - MCA - Machine Check Architecture. */
385#define X86_CPUID_AMD_FEATURE_EDX_MCA BIT(14)
386/** Bit 15 - CMOV - Conditional Move Instructions. */
387#define X86_CPUID_AMD_FEATURE_EDX_CMOV BIT(15)
388/** Bit 16 - PAT - Page Attribute Table. */
389#define X86_CPUID_AMD_FEATURE_EDX_PAT BIT(16)
390/** Bit 17 - PSE-36 - 36-bit Page Size Extention. */
391#define X86_CPUID_AMD_FEATURE_EDX_PSE36 BIT(17)
392/** Bit 20 - NX - AMD No-Execute Page Protection. */
393#define X86_CPUID_AMD_FEATURE_EDX_NX BIT(20)
394/** Bit 22 - AXMMX - AMD Extensions to MMX Instructions. */
395#define X86_CPUID_AMD_FEATURE_EDX_AXMMX BIT(22)
396/** Bit 23 - MMX - Intel MMX Technology. */
397#define X86_CPUID_AMD_FEATURE_EDX_MMX BIT(23)
398/** Bit 24 - FXSR - FXSAVE and FXRSTOR Instructions. */
399#define X86_CPUID_AMD_FEATURE_EDX_FXSR BIT(24)
400/** Bit 25 - ???? - AMD fast FXSAVE and FXRSTOR Instructions. */
401#define X86_CPUID_AMD_FEATURE_EDX_FFXSR BIT(25)
402/** Bit 29 - ???? - AMD Long Mode. */
403#define X86_CPUID_AMD_FEATURE_EDX_LONG_MODE BIT(29)
404/** Bit 30 - ???? - AMD Extensions to 3DNow. */
405#define X86_CPUID_AMD_FEATURE_EDX_3DNOW_EX BIT(30)
406/** Bit 31 - ???? - AMD 3DNow. */
407#define X86_CPUID_AMD_FEATURE_EDX_3DNOW BIT(31)
408
409/** Bit 1 - LAHF/SAHF - ???. */
410/*define X86_CPUID_AMD_FEATURE_ECX_TODO BIT(0)*/
411/** Bit 1 - CMPL - ???. */
412#define X86_CPUID_AMD_FEATURE_ECX_CMPL BIT(1)
413/** Bit 2 - SVM - AMD VM extensions. */
414#define X86_CPUID_AMD_FEATURE_ECX_SVM BIT(2)
415/** Bit 4 - CR8L - ???. */
416#define X86_CPUID_AMD_FEATURE_ECX_CR8L BIT(4)
417
418/** @} */
419
420
421/** @name CR0
422 * @{ */
423/** Bit 0 - PE - Protection Enabled */
424#define X86_CR0_PE BIT(0)
425#define X86_CR0_PROTECTION_ENABLE BIT(0)
426/** Bit 1 - MP - Monitor Coprocessor */
427#define X86_CR0_MP BIT(1)
428#define X86_CR0_MONITOR_COPROCESSOR BIT(1)
429/** Bit 2 - EM - Emulation. */
430#define X86_CR0_EM BIT(2)
431#define X86_CR0_EMULATE_FPU BIT(2)
432/** Bit 3 - TS - Task Switch. */
433#define X86_CR0_TS BIT(3)
434#define X86_CR0_TASK_SWITCH BIT(3)
435/** Bit 4 - ET - Extension flag. ('hardcoded' to 1) */
436#define X86_CR0_ET BIT(4)
437#define X86_CR0_EXTENSION_TYPE BIT(4)
438/** Bit 5 - NE - Numeric error. */
439#define X86_CR0_NE BIT(5)
440#define X86_CR0_NUMERIC_ERROR BIT(5)
441/** Bit 16 - WP - Write Protect. */
442#define X86_CR0_WP BIT(16)
443#define X86_CR0_WRITE_PROTECT BIT(16)
444/** Bit 18 - AM - Alignment Mask. */
445#define X86_CR0_AM BIT(18)
446#define X86_CR0_ALIGMENT_MASK BIT(18)
447/** Bit 29 - NW - Not Write-though. */
448#define X86_CR0_NW BIT(29)
449#define X86_CR0_NOT_WRITE_THROUGH BIT(29)
450/** Bit 30 - WP - Cache Disable. */
451#define X86_CR0_CD BIT(30)
452#define X86_CR0_CACHE_DISABLE BIT(30)
453/** Bit 31 - PG - Paging. */
454#define X86_CR0_PG BIT(31)
455#define X86_CR0_PAGING BIT(31)
456/** @} */
457
458
459/** @name CR3
460 * @{ */
461/** Bit 3 - PWT - Page-level Writes Transparent. */
462#define X86_CR3_PWT BIT(3)
463/** Bit 4 - PCD - Page-level Cache Disable. */
464#define X86_CR3_PCD BIT(4)
465/** Bits 12-31 - - Page directory page number. */
466#define X86_CR3_PAGE_MASK (0xfffff000)
467/** Bits 5-31 - - PAE Page directory page number. */
468#define X86_CR3_PAE_PAGE_MASK (0xffffffe0)
469/** @} */
470
471
472/** @name CR4
473 * @{ */
474/** Bit 0 - VME - Virtual-8086 Mode Extensions. */
475#define X86_CR4_VME BIT(0)
476/** Bit 1 - PVI - Protected-Mode Virtual Interrupts. */
477#define X86_CR4_PVI BIT(1)
478/** Bit 2 - TSD - Time Stamp Disable. */
479#define X86_CR4_TSD BIT(2)
480/** Bit 3 - DE - Debugging Extensions. */
481#define X86_CR4_DE BIT(3)
482/** Bit 4 - PSE - Page Size Extension. */
483#define X86_CR4_PSE BIT(4)
484/** Bit 5 - PAE - Physical Address Extension. */
485#define X86_CR4_PAE BIT(5)
486/** Bit 6 - MCE - Machine-Check Enable. */
487#define X86_CR4_MCE BIT(6)
488/** Bit 7 - PGE - Page Global Enable. */
489#define X86_CR4_PGE BIT(7)
490/** Bit 8 - PCE - Performance-Monitoring Counter Enable. */
491#define X86_CR4_PCE BIT(8)
492/** Bit 9 - OSFSXR - Operating System Support for FXSAVE and FXRSTORE instruction. */
493#define X86_CR4_OSFSXR BIT(9)
494/** Bit 10 - OSXMMEEXCPT - Operating System Support for Unmasked SIMD Floating-Point Exceptions. */
495#define X86_CR4_OSXMMEEXCPT BIT(10)
496/** Bit 13 - VMXE - VMX mode is enabled. */
497#define X86_CR4_VMXE BIT(13)
498/** @} */
499
500
501/** @name DR6
502 * @{ */
503/** Bit 0 - B0 - Breakpoint 0 condition detected. */
504#define X86_DR6_B0 BIT(0)
505/** Bit 1 - B1 - Breakpoint 1 condition detected. */
506#define X86_DR6_B1 BIT(1)
507/** Bit 2 - B2 - Breakpoint 2 condition detected. */
508#define X86_DR6_B2 BIT(2)
509/** Bit 3 - B3 - Breakpoint 3 condition detected. */
510#define X86_DR6_B3 BIT(3)
511/** Bit 13 - BD - Debug register access detected. Corresponds to the X86_DR7_GD bit. */
512#define X86_DR6_BD BIT(13)
513/** Bit 14 - BS - Single step */
514#define X86_DR6_BS BIT(14)
515/** Bit 15 - BT - Task switch. (TSS T bit.) */
516#define X86_DR6_BT BIT(15)
517/** @} */
518
519
520/** @name DR7
521 * @{ */
522/** Bit 0 - L0 - Local breakpoint enable. Cleared on task switch. */
523#define X86_DR7_L0 BIT(0)
524/** Bit 1 - G0 - Global breakpoint enable. Not cleared on task switch. */
525#define X86_DR7_G0 BIT(1)
526/** Bit 2 - L1 - Local breakpoint enable. Cleared on task switch. */
527#define X86_DR7_L1 BIT(2)
528/** Bit 3 - G1 - Global breakpoint enable. Not cleared on task switch. */
529#define X86_DR7_G1 BIT(3)
530/** Bit 4 - L2 - Local breakpoint enable. Cleared on task switch. */
531#define X86_DR7_L2 BIT(4)
532/** Bit 5 - G2 - Global breakpoint enable. Not cleared on task switch. */
533#define X86_DR7_G2 BIT(5)
534/** Bit 6 - L3 - Local breakpoint enable. Cleared on task switch. */
535#define X86_DR7_L3 BIT(6)
536/** Bit 7 - G3 - Global breakpoint enable. Not cleared on task switch. */
537#define X86_DR7_G3 BIT(7)
538/** Bit 8 - LE - Local breakpoint exact. (Not supported (read ignored) by P6 and later.) */
539#define X86_DR7_LE BIT(8)
540/** Bit 9 - GE - Local breakpoint exact. (Not supported (read ignored) by P6 and later.) */
541#define X86_DR7_GE BIT(9)
542
543/** Bit 13 - GD - General detect enable. Enables emulators to get exceptions when
544 * any DR register is accessed. */
545#define X86_DR7_GD BIT(13)
546/** Bit 16 & 17 - R/W0 - Read write field 0. Values X86_DR7_RW_*. */
547#define X86_DR7_RW0_MASK (3 << 16)
548/** Bit 18 & 19 - LEN0 - Length field 0. Values X86_DR7_LEN_*. */
549#define X86_DR7_LEN0_MASK (3 << 18)
550/** Bit 20 & 21 - R/W1 - Read write field 0. Values X86_DR7_RW_*. */
551#define X86_DR7_RW1_MASK (3 << 20)
552/** Bit 22 & 23 - LEN1 - Length field 0. Values X86_DR7_LEN_*. */
553#define X86_DR7_LEN1_MASK (3 << 22)
554/** Bit 24 & 25 - R/W2 - Read write field 0. Values X86_DR7_RW_*. */
555#define X86_DR7_RW2_MASK (3 << 24)
556/** Bit 26 & 27 - LEN2 - Length field 0. Values X86_DR7_LEN_*. */
557#define X86_DR7_LEN2_MASK (3 << 26)
558/** Bit 28 & 29 - R/W3 - Read write field 0. Values X86_DR7_RW_*. */
559#define X86_DR7_RW3_MASK (3 << 28)
560/** Bit 30 & 31 - LEN3 - Length field 0. Values X86_DR7_LEN_*. */
561#define X86_DR7_LEN3_MASK (3 << 30)
562
563/** Bits which must be 1s. */
564#define X86_DR7_MB1_MASK (BIT(10))
565
566/** Calcs the L bit of Nth breakpoint.
567 * @param iBp The breakpoint number [0..3].
568 */
569#define X86_DR7_L(iBp) ( 1 << (iBp * 2) )
570
571/** Calcs the G bit of Nth breakpoint.
572 * @param iBp The breakpoint number [0..3].
573 */
574#define X86_DR7_G(iBp) ( 1 << (iBp * 2 + 1) )
575
576/** @name Read/Write values.
577 * @{ */
578/** Break on instruction fetch only. */
579#define X86_DR7_RW_EO 0
580/** Break on write only. */
581#define X86_DR7_RW_WO 1
582/** Break on I/O read/write. This is only defined if CR4.DE is set. */
583#define X86_DR7_RW_IO 2
584/** Break on read or write (but not instruction fetches). */
585#define X86_DR7_RW_RW 3
586/** @} */
587
588/** Shifts a X86_DR7_RW_* value to its right place.
589 * @param iBp The breakpoint number [0..3].
590 * @param fRw One of the X86_DR7_RW_* value.
591 */
592#define X86_DR7_RW(iBp, fRw) ( (fRw) << ((iBp) * 4 + 16) )
593
594/** @name Length values.
595 * @{ */
596#define X86_DR7_LEN_BYTE 0
597#define X86_DR7_LEN_WORD 1
598#define X86_DR7_LEN_QWORD 2 /**< AMD64 long mode only. */
599#define X86_DR7_LEN_DWORD 3
600/** @} */
601
602/** Shifts a X86_DR7_LEN_* value to its right place.
603 * @param iBp The breakpoint number [0..3].
604 * @param cb One of the X86_DR7_LEN_* values.
605 */
606#define X86_DR7_LEN(iBp, cb) ( (cb) << ((iBp) * 4 + 18) )
607
608/** Mask used to check if any breakpoints are enabled. */
609#define X86_DR7_ENABLED_MASK (BIT(0) | BIT(1) | BIT(2) | BIT(3) | BIT(4) | BIT(6) | BIT(7))
610
611/** @} */
612
613
614/** @name Machine Specific Registers
615 * @{
616 */
617/** CPU Feature control. */
618#define MSR_IA32_FEATURE_CONTROL 0x3A
619#define MSR_IA32_FEATURE_CONTROL_LOCK BIT(0)
620#define MSR_IA32_FEATURE_CONTROL_VMXON BIT(2)
621
622
623#ifndef MSR_IA32_SYSENTER_CS /* qemu cpu.h klugde */
624/** SYSENTER_CS - the R0 CS, indirectly giving R0 SS, R3 CS and R3 DS.
625 * R0 SS == CS + 8
626 * R3 CS == CS + 16
627 * R3 SS == CS + 24
628 */
629#define MSR_IA32_SYSENTER_CS 0x174
630/** SYSENTER_ESP - the R0 ESP. */
631#define MSR_IA32_SYSENTER_ESP 0x175
632/** SYSENTER_EIP - the R0 EIP. */
633#define MSR_IA32_SYSENTER_EIP 0x176
634#endif
635
636/** Basic VMX information. */
637#define MSR_IA32_VMX_BASIC_INFO 0x480
638/** Allowed settings for pin-based VM execution controls */
639#define MSR_IA32_VMX_PINBASED_CTLS 0x481
640/** Allowed settings for proc-based VM execution controls */
641#define MSR_IA32_VMX_PROCBASED_CTLS 0x482
642/** Allowed settings for the VMX exit controls. */
643#define MSR_IA32_VMX_EXIT_CTLS 0x483
644/** Allowed settings for the VMX entry controls. */
645#define MSR_IA32_VMX_ENTRY_CTLS 0x484
646/** Misc VMX info. */
647#define MSR_IA32_VMX_MISC 0x485
648/** Fixed cleared bits in CR0. */
649#define MSR_IA32_VMX_CR0_FIXED0 0x486
650/** Fixed set bits in CR0. */
651#define MSR_IA32_VMX_CR0_FIXED1 0x487
652/** Fixed cleared bits in CR4. */
653#define MSR_IA32_VMX_CR4_FIXED0 0x488
654/** Fixed set bits in CR4. */
655#define MSR_IA32_VMX_CR4_FIXED1 0x489
656/** Information for enumerating fields in the VMCS. */
657#define MSR_IA32_VMX_VMCS_ENUM 0x48A
658
659
660/** K6 EFER - Extended Feature Enable Register. */
661#define MSR_K6_EFER 0xc0000080
662/** @todo document EFER */
663/** Bit 0 - SCE - System call extensions (SYSCALL / SYSRET). (R/W) */
664#define MSR_K6_EFER_SCE BIT(0)
665/** Bit 8 - LME - Long mode enabled. (R/W) */
666#define MSR_K6_EFER_LME BIT(8)
667/** Bit 10 - LMA - Long mode active. (R) */
668#define MSR_K6_EFER_LMA BIT(10)
669/** Bit 11 - NXE - No-Execute Page Protection Enabled. (R/W) */
670#define MSR_K6_EFER_NXE BIT(11)
671/** Bit 12 - SVME - Secure VM Extension Enabled. (R/W) */
672#define MSR_K6_EFER_SVME BIT(12)
673/** Bit 13 - LMSLE - Long Mode Segment Limit Enable. (R/W?) */
674#define MSR_K6_EFER_LMSLE BIT(13)
675/** Bit 14 - FFXSR - Fast FXSAVE / FXRSTOR (skip XMM*). (R/W) */
676#define MSR_K6_EFER_FFXSR BIT(14)
677/** K6 STAR - SYSCALL/RET targets. */
678#define MSR_K6_STAR 0xc0000081
679/** Shift value for getting the SYSRET CS and SS value. */
680#define MSR_K6_STAR_SYSRET_CS_SS_SHIFT 48
681/** Shift value for getting the SYSCALL CS and SS value. */
682#define MSR_K6_STAR_SYSCALL_CS_SS_SHIFT 32
683/** Selector mask for use after shifting. */
684#define MSR_K6_STAR_SEL_MASK 0xffff
685/** The mask which give the SYSCALL EIP. */
686#define MSR_K6_STAR_SYSCALL_EIP_MASK 0xffffffff
687/** K6 WHCR - Write Handling Control Register. */
688#define MSR_K6_WHCR 0xc0000082
689/** K6 UWCCR - UC/WC Cacheability Control Register. */
690#define MSR_K6_UWCCR 0xc0000085
691/** K6 PSOR - Processor State Observability Register. */
692#define MSR_K6_PSOR 0xc0000087
693/** K6 PFIR - Page Flush/Invalidate Register. */
694#define MSR_K6_PFIR 0xc0000088
695
696#define MSR_K7_EVNTSEL0 0xc0010000
697#define MSR_K7_EVNTSEL1 0xc0010001
698#define MSR_K7_EVNTSEL2 0xc0010002
699#define MSR_K7_EVNTSEL3 0xc0010003
700#define MSR_K7_PERFCTR0 0xc0010004
701#define MSR_K7_PERFCTR1 0xc0010005
702#define MSR_K7_PERFCTR2 0xc0010006
703#define MSR_K7_PERFCTR3 0xc0010007
704
705/** K8 LSTAR - Long mode SYSCALL target (RIP). */
706#define MSR_K8_LSTAR 0xc0000082
707/** K8 CSTAR - Compatibility mode SYSCALL target (RIP). */
708#define MSR_K8_CSTAR 0xc0000083
709/** K8 SF_MASK - SYSCALL flag mask. (aka SFMASK) */
710#define MSR_K8_SF_MASK 0xc0000084
711/** K8 FS.base - The 64-bit base FS register. */
712#define MSR_K8_FS_BASE 0xc0000100
713/** K8 GS.base - The 64-bit base GS register. */
714#define MSR_K8_GS_BASE 0xc0000101
715/** K8 KernelGSbase - Used with SWAPGS. */
716#define MSR_K8_KERNEL_GS_BASE 0xc0000102
717#define MSR_K8_TSC_AUX 0xc0000103
718#define MSR_K8_SYSCFG 0xc0010010
719#define MSR_K8_HWCR 0xc0010015
720#define MSR_K8_IORRBASE0 0xc0010016
721#define MSR_K8_IORRMASK0 0xc0010017
722#define MSR_K8_IORRBASE1 0xc0010018
723#define MSR_K8_IORRMASK1 0xc0010019
724#define MSR_K8_TOP_MEM1 0xc001001a
725#define MSR_K8_TOP_MEM2 0xc001001d
726#define MSR_K8_VM_CR 0xc0010114
727#define MSR_K8_IGNNE 0xc0010115
728#define MSR_K8_SMM_CTL 0xc0010116
729/** SVM - VM_HSAVE_PA - Physical address for saving and restoring
730 * host state during world switch.
731 */
732#define MSR_K8_VM_HSAVE_PA 0xc0010117
733
734/** @} */
735
736
737/** @name Page Table / Directory / Directory Pointers / L4.
738 * @{
739 */
740
741/** Page table/directory entry as an unsigned integer. */
742typedef uint32_t X86PGUINT;
743/** Pointer to a page table/directory table entry as an unsigned integer. */
744typedef X86PGUINT *PX86PGUINT;
745
746/** Number of entries in a 32-bit PT/PD. */
747#define X86_PG_ENTRIES 1024
748
749
750/** PAE page table/page directory/pdptr/l4/l5 entry as an unsigned integer. */
751typedef uint64_t X86PGPAEUINT;
752/** Pointer to a PAE page table/page directory/pdptr/l4/l5 entry as an unsigned integer. */
753typedef X86PGPAEUINT *PX86PGPAEUINT;
754
755/** Number of entries in a PAE PT/PD/PDPTR/L4/L5. */
756#define X86_PG_PAE_ENTRIES 512
757
758
759/** The size of a 4KB page. */
760#define X86_PAGE_4K_SIZE _4K
761/** The page shift of a 4KB page. */
762#define X86_PAGE_4K_SHIFT 12
763/** The 4KB page offset mask. */
764#define X86_PAGE_4K_OFFSET_MASK 0xfff
765/** The 4KB page base mask for virtual addresses. */
766#define X86_PAGE_4K_BASE_MASK 0xfffffffffffff000ULL
767/** The 4KB page base mask for virtual addresses - 32bit version. */
768#define X86_PAGE_4K_BASE_MASK_32 0xfffff000U
769
770/** The size of a 2MB page. */
771#define X86_PAGE_2M_SIZE _2M
772/** The page shift of a 2MB page. */
773#define X86_PAGE_2M_SHIFT 21
774/** The 2MB page offset mask. */
775#define X86_PAGE_2M_OFFSET_MASK 0x001fffff
776/** The 2MB page base mask for virtual addresses. */
777#define X86_PAGE_2M_BASE_MASK 0xffffffffffe00000ULL
778/** The 2MB page base mask for virtual addresses - 32bit version. */
779#define X86_PAGE_2M_BASE_MASK_32 0xffe00000U
780
781/** The size of a 4MB page. */
782#define X86_PAGE_4M_SIZE _4M
783/** The page shift of a 4MB page. */
784#define X86_PAGE_4M_SHIFT 22
785/** The 4MB page offset mask. */
786#define X86_PAGE_4M_OFFSET_MASK 0x003fffff
787/** The 4MB page base mask for virtual addresses. */
788#define X86_PAGE_4M_BASE_MASK 0xffffffffffc00000ULL
789/** The 4MB page base mask for virtual addresses - 32bit version. */
790#define X86_PAGE_4M_BASE_MASK_32 0xffc00000U
791
792
793
794/** @name Page Table Entry
795 * @{
796 */
797/** Bit 0 - P - Present bit. */
798#define X86_PTE_P BIT(0)
799/** Bit 1 - R/W - Read (clear) / Write (set) bit. */
800#define X86_PTE_RW BIT(1)
801/** Bit 2 - U/S - User (set) / Supervisor (clear) bit. */
802#define X86_PTE_US BIT(2)
803/** Bit 3 - PWT - Page level write thru bit. */
804#define X86_PTE_PWT BIT(3)
805/** Bit 4 - PCD - Page level cache disable bit. */
806#define X86_PTE_PCD BIT(4)
807/** Bit 5 - A - Access bit. */
808#define X86_PTE_A BIT(5)
809/** Bit 6 - D - Dirty bit. */
810#define X86_PTE_D BIT(6)
811/** Bit 7 - PAT - Page Attribute Table index bit. Reserved and 0 if not supported. */
812#define X86_PTE_PAT BIT(7)
813/** Bit 8 - G - Global flag. */
814#define X86_PTE_G BIT(8)
815/** Bits 9-11 - - Available for use to system software. */
816#define X86_PTE_AVL_MASK (BIT(9) | BIT(10) | BIT(11))
817/** Bits 12-31 - - Physical Page number of the next level. */
818#define X86_PTE_PG_MASK ( 0xfffff000 )
819
820/** Bits 12-51 - - PAE - Physical Page number of the next level. */
821#if 1 /* we're using this internally and have to mask of the top 16-bit. */
822#define X86_PTE_PAE_PG_MASK ( 0x0000fffffffff000ULL )
823#else
824#define X86_PTE_PAE_PG_MASK ( 0x000ffffffffff000ULL )
825#endif
826/** Bits 63 - NX - PAE - No execution flag. */
827#define X86_PTE_PAE_NX BIT64(63)
828
829/**
830 * Page table entry.
831 */
832typedef struct X86PTEBITS
833{
834 /** Flags whether(=1) or not the page is present. */
835 unsigned u1Present : 1;
836 /** Read(=0) / Write(=1) flag. */
837 unsigned u1Write : 1;
838 /** User(=1) / Supervisor (=0) flag. */
839 unsigned u1User : 1;
840 /** Write Thru flag. If PAT enabled, bit 0 of the index. */
841 unsigned u1WriteThru : 1;
842 /** Cache disabled flag. If PAT enabled, bit 1 of the index. */
843 unsigned u1CacheDisable : 1;
844 /** Accessed flag.
845 * Indicates that the page have been read or written to. */
846 unsigned u1Accessed : 1;
847 /** Dirty flag.
848 * Indicates that the page have been written to. */
849 unsigned u1Dirty : 1;
850 /** Reserved / If PAT enabled, bit 2 of the index. */
851 unsigned u1PAT : 1;
852 /** Global flag. (Ignored in all but final level.) */
853 unsigned u1Global : 1;
854 /** Available for use to system software. */
855 unsigned u3Available : 3;
856 /** Physical Page number of the next level. */
857 unsigned u20PageNo : 20;
858} X86PTEBITS;
859/** Pointer to a page table entry. */
860typedef X86PTEBITS *PX86PTEBITS;
861/** Pointer to a const page table entry. */
862typedef const X86PTEBITS *PCX86PTEBITS;
863
864/**
865 * Page table entry.
866 */
867typedef union X86PTE
868{
869 /** Bit field view. */
870 X86PTEBITS n;
871 /** Unsigned integer view */
872 X86PGUINT u;
873 /** 32-bit view. */
874 uint32_t au32[1];
875 /** 16-bit view. */
876 uint16_t au16[2];
877 /** 8-bit view. */
878 uint8_t au8[4];
879} X86PTE;
880/** Pointer to a page table entry. */
881typedef X86PTE *PX86PTE;
882/** Pointer to a const page table entry. */
883typedef const X86PTE *PCX86PTE;
884
885
886/**
887 * PAE page table entry.
888 */
889typedef struct X86PTEPAEBITS
890{
891 /** Flags whether(=1) or not the page is present. */
892 uint32_t u1Present : 1;
893 /** Read(=0) / Write(=1) flag. */
894 uint32_t u1Write : 1;
895 /** User(=1) / Supervisor(=0) flag. */
896 uint32_t u1User : 1;
897 /** Write Thru flag. If PAT enabled, bit 0 of the index. */
898 uint32_t u1WriteThru : 1;
899 /** Cache disabled flag. If PAT enabled, bit 1 of the index. */
900 uint32_t u1CacheDisable : 1;
901 /** Accessed flag.
902 * Indicates that the page have been read or written to. */
903 uint32_t u1Accessed : 1;
904 /** Dirty flag.
905 * Indicates that the page have been written to. */
906 uint32_t u1Dirty : 1;
907 /** Reserved / If PAT enabled, bit 2 of the index. */
908 uint32_t u1PAT : 1;
909 /** Global flag. (Ignored in all but final level.) */
910 uint32_t u1Global : 1;
911 /** Available for use to system software. */
912 uint32_t u3Available : 3;
913 /** Physical Page number of the next level - Low Part. Don't use this. */
914 uint32_t u20PageNoLow : 20;
915 /** Physical Page number of the next level - High Part. Don't use this. */
916 uint32_t u20PageNoHigh : 20;
917 /** MBZ bits */
918 uint32_t u11Reserved : 11;
919 /** No Execute flag. */
920 uint32_t u1NoExecute : 1;
921} X86PTEPAEBITS;
922/** Pointer to a page table entry. */
923typedef X86PTEPAEBITS *PX86PTEPAEBITS;
924/** Pointer to a page table entry. */
925typedef const X86PTEPAEBITS *PCX86PTEPAEBITS;
926
927/**
928 * PAE Page table entry.
929 */
930typedef union X86PTEPAE
931{
932 /** Bit field view. */
933 X86PTEPAEBITS n;
934 /** Unsigned integer view */
935 X86PGPAEUINT u;
936 /** 32-bit view. */
937 uint32_t au32[2];
938 /** 16-bit view. */
939 uint16_t au16[4];
940 /** 8-bit view. */
941 uint8_t au8[8];
942} X86PTEPAE;
943/** Pointer to a PAE page table entry. */
944typedef X86PTEPAE *PX86PTEPAE;
945/** Pointer to a const PAE page table entry. */
946typedef const X86PTEPAE *PCX86PTEPAE;
947/** @} */
948
949/**
950 * Page table.
951 */
952typedef struct X86PT
953{
954 /** PTE Array. */
955 X86PTE a[X86_PG_ENTRIES];
956} X86PT;
957/** Pointer to a page table. */
958typedef X86PT *PX86PT;
959/** Pointer to a const page table. */
960typedef const X86PT *PCX86PT;
961
962/** The page shift to get the PT index. */
963#define X86_PT_SHIFT 12
964/** The PT index mask (apply to a shifted page address). */
965#define X86_PT_MASK 0x3ff
966
967
968/**
969 * Page directory.
970 */
971typedef struct X86PTPAE
972{
973 /** PTE Array. */
974 X86PTEPAE a[X86_PG_PAE_ENTRIES];
975} X86PTPAE;
976/** Pointer to a page table. */
977typedef X86PTPAE *PX86PTPAE;
978/** Pointer to a const page table. */
979typedef const X86PTPAE *PCX86PTPAE;
980
981/** The page shift to get the PA PTE index. */
982#define X86_PT_PAE_SHIFT 12
983/** The PAE PT index mask (apply to a shifted page address). */
984#define X86_PT_PAE_MASK 0x1ff
985
986
987/** @name 4KB Page Directory Entry
988 * @{
989 */
990/** Bit 0 - P - Present bit. */
991#define X86_PDE_P BIT(0)
992/** Bit 1 - R/W - Read (clear) / Write (set) bit. */
993#define X86_PDE_RW BIT(1)
994/** Bit 2 - U/S - User (set) / Supervisor (clear) bit. */
995#define X86_PDE_US BIT(2)
996/** Bit 3 - PWT - Page level write thru bit. */
997#define X86_PDE_PWT BIT(3)
998/** Bit 4 - PCD - Page level cache disable bit. */
999#define X86_PDE_PCD BIT(4)
1000/** Bit 5 - A - Access bit. */
1001#define X86_PDE_A BIT(5)
1002/** Bit 7 - PS - Page size attribute.
1003 * Clear mean 4KB pages, set means large pages (2/4MB). */
1004#define X86_PDE_PS BIT(7)
1005/** Bits 9-11 - - Available for use to system software. */
1006#define X86_PDE_AVL_MASK (BIT(9) | BIT(10) | BIT(11))
1007/** Bits 12-31 - - Physical Page number of the next level. */
1008#define X86_PDE_PG_MASK ( 0xfffff000 )
1009
1010/** Bits 12-51 - - PAE - Physical Page number of the next level. */
1011#if 1 /* we're using this internally and have to mask of the top 16-bit. */
1012#define X86_PDE_PAE_PG_MASK ( 0x0000fffffffff000ULL )
1013#else
1014#define X86_PDE_PAE_PG_MASK ( 0x000ffffffffff000ULL )
1015#endif
1016/** Bits 63 - NX - PAE - No execution flag. */
1017#define X86_PDE_PAE_NX BIT64(63)
1018
1019/**
1020 * Page directory entry.
1021 */
1022typedef struct X86PDEBITS
1023{
1024 /** Flags whether(=1) or not the page is present. */
1025 unsigned u1Present : 1;
1026 /** Read(=0) / Write(=1) flag. */
1027 unsigned u1Write : 1;
1028 /** User(=1) / Supervisor (=0) flag. */
1029 unsigned u1User : 1;
1030 /** Write Thru flag. If PAT enabled, bit 0 of the index. */
1031 unsigned u1WriteThru : 1;
1032 /** Cache disabled flag. If PAT enabled, bit 1 of the index. */
1033 unsigned u1CacheDisable : 1;
1034 /** Accessed flag.
1035 * Indicates that the page have been read or written to. */
1036 unsigned u1Accessed : 1;
1037 /** Reserved / Ignored (dirty bit). */
1038 unsigned u1Reserved0 : 1;
1039 /** Size bit if PSE is enabled - in any event it's 0. */
1040 unsigned u1Size : 1;
1041 /** Reserved / Ignored (global bit). */
1042 unsigned u1Reserved1 : 1;
1043 /** Available for use to system software. */
1044 unsigned u3Available : 3;
1045 /** Physical Page number of the next level. */
1046 unsigned u20PageNo : 20;
1047} X86PDEBITS;
1048/** Pointer to a page directory entry. */
1049typedef X86PDEBITS *PX86PDEBITS;
1050/** Pointer to a const page directory entry. */
1051typedef const X86PDEBITS *PCX86PDEBITS;
1052
1053
1054/**
1055 * PAE page directory entry.
1056 */
1057typedef struct X86PDEPAEBITS
1058{
1059 /** Flags whether(=1) or not the page is present. */
1060 uint32_t u1Present : 1;
1061 /** Read(=0) / Write(=1) flag. */
1062 uint32_t u1Write : 1;
1063 /** User(=1) / Supervisor (=0) flag. */
1064 uint32_t u1User : 1;
1065 /** Write Thru flag. If PAT enabled, bit 0 of the index. */
1066 uint32_t u1WriteThru : 1;
1067 /** Cache disabled flag. If PAT enabled, bit 1 of the index. */
1068 uint32_t u1CacheDisable : 1;
1069 /** Accessed flag.
1070 * Indicates that the page have been read or written to. */
1071 uint32_t u1Accessed : 1;
1072 /** Reserved / Ignored (dirty bit). */
1073 uint32_t u1Reserved0 : 1;
1074 /** Size bit if PSE is enabled - in any event it's 0. */
1075 uint32_t u1Size : 1;
1076 /** Reserved / Ignored (global bit). / */
1077 uint32_t u1Reserved1 : 1;
1078 /** Available for use to system software. */
1079 uint32_t u3Available : 3;
1080 /** Physical Page number of the next level - Low Part. Don't use! */
1081 uint32_t u20PageNoLow : 20;
1082 /** Physical Page number of the next level - High Part. Don't use! */
1083 uint32_t u20PageNoHigh : 20;
1084 /** MBZ bits */
1085 uint32_t u11Reserved : 11;
1086 /** No Execute flag. */
1087 uint32_t u1NoExecute : 1;
1088} X86PDEPAEBITS;
1089/** Pointer to a page directory entry. */
1090typedef X86PDEPAEBITS *PX86PDEPAEBITS;
1091/** Pointer to a const page directory entry. */
1092typedef const X86PDEPAEBITS *PCX86PDEPAEBITS;
1093
1094/** @} */
1095
1096
1097/** @name 2/4MB Page Directory Entry
1098 * @{
1099 */
1100/** Bit 0 - P - Present bit. */
1101#define X86_PDE4M_P BIT(0)
1102/** Bit 1 - R/W - Read (clear) / Write (set) bit. */
1103#define X86_PDE4M_RW BIT(1)
1104/** Bit 2 - U/S - User (set) / Supervisor (clear) bit. */
1105#define X86_PDE4M_US BIT(2)
1106/** Bit 3 - PWT - Page level write thru bit. */
1107#define X86_PDE4M_PWT BIT(3)
1108/** Bit 4 - PCD - Page level cache disable bit. */
1109#define X86_PDE4M_PCD BIT(4)
1110/** Bit 5 - A - Access bit. */
1111#define X86_PDE4M_A BIT(5)
1112/** Bit 6 - D - Dirty bit. */
1113#define X86_PDE4M_D BIT(6)
1114/** Bit 7 - PS - Page size attribute. Clear mean 4KB pages, set means large pages (2/4MB). */
1115#define X86_PDE4M_PS BIT(7)
1116/** Bit 8 - G - Global flag. */
1117#define X86_PDE4M_G BIT(8)
1118/** Bits 9-11 - AVL - Available for use to system software. */
1119#define X86_PDE4M_AVL (BIT(9) | BIT(10) | BIT(11))
1120/** Bit 12 - PAT - Page Attribute Table index bit. Reserved and 0 if not supported. */
1121#define X86_PDE4M_PAT BIT(12)
1122/** Shift to get from X86_PTE_PAT to X86_PDE4M_PAT. */
1123#define X86_PDE4M_PAT_SHIFT (12 - 7)
1124/** Bits 22-31 - - Physical Page number. */
1125#define X86_PDE4M_PG_MASK ( 0xffc00000 )
1126/** Bits 13-20 - - Physical Page number high part (32-39 bits). AMD64 hack. */
1127#define X86_PDE4M_PG_HIGH_MASK ( 0x001fe000 )
1128/** The number of bits to the high part of the page number. */
1129#define X86_PDE4M_PG_HIGH_SHIFT 19
1130
1131/** Bits 12-51 - - PAE - Physical Page number. */
1132#define X86_PDE4M_PAE_PG_MASK ( 0x000fffffffc00000ULL )
1133/** Bits 63 - NX - PAE - No execution flag. */
1134#define X86_PDE4M_PAE_NX BIT64(63)
1135
1136/**
1137 * 4MB page directory entry.
1138 */
1139typedef struct X86PDE4MBITS
1140{
1141 /** Flags whether(=1) or not the page is present. */
1142 unsigned u1Present : 1;
1143 /** Read(=0) / Write(=1) flag. */
1144 unsigned u1Write : 1;
1145 /** User(=1) / Supervisor (=0) flag. */
1146 unsigned u1User : 1;
1147 /** Write Thru flag. If PAT enabled, bit 0 of the index. */
1148 unsigned u1WriteThru : 1;
1149 /** Cache disabled flag. If PAT enabled, bit 1 of the index. */
1150 unsigned u1CacheDisable : 1;
1151 /** Accessed flag.
1152 * Indicates that the page have been read or written to. */
1153 unsigned u1Accessed : 1;
1154 /** Dirty flag.
1155 * Indicates that the page have been written to. */
1156 unsigned u1Dirty : 1;
1157 /** Page size flag - always 1 for 4MB entries. */
1158 unsigned u1Size : 1;
1159 /** Global flag. */
1160 unsigned u1Global : 1;
1161 /** Available for use to system software. */
1162 unsigned u3Available : 3;
1163 /** Reserved / If PAT enabled, bit 2 of the index. */
1164 unsigned u1PAT : 1;
1165 /** Bits 32-39 of the page number on AMD64.
1166 * This AMD64 hack allows accessing 40bits of physical memory without PAE. */
1167 unsigned u8PageNoHigh : 8;
1168 /** Reserved. */
1169 unsigned u1Reserved : 1;
1170 /** Physical Page number of the page. */
1171 unsigned u10PageNo : 10;
1172} X86PDE4MBITS;
1173/** Pointer to a page table entry. */
1174typedef X86PDE4MBITS *PX86PDE4MBITS;
1175/** Pointer to a const page table entry. */
1176typedef const X86PDE4MBITS *PCX86PDE4MBITS;
1177
1178
1179/**
1180 * 2MB PAE page directory entry.
1181 */
1182typedef struct X86PDE2MPAEBITS
1183{
1184 /** Flags whether(=1) or not the page is present. */
1185 uint32_t u1Present : 1;
1186 /** Read(=0) / Write(=1) flag. */
1187 uint32_t u1Write : 1;
1188 /** User(=1) / Supervisor(=0) flag. */
1189 uint32_t u1User : 1;
1190 /** Write Thru flag. If PAT enabled, bit 0 of the index. */
1191 uint32_t u1WriteThru : 1;
1192 /** Cache disabled flag. If PAT enabled, bit 1 of the index. */
1193 uint32_t u1CacheDisable : 1;
1194 /** Accessed flag.
1195 * Indicates that the page have been read or written to. */
1196 uint32_t u1Accessed : 1;
1197 /** Dirty flag.
1198 * Indicates that the page have been written to. */
1199 uint32_t u1Dirty : 1;
1200 /** Page size flag - always 1 for 2MB entries. */
1201 uint32_t u1Size : 1;
1202 /** Global flag. */
1203 uint32_t u1Global : 1;
1204 /** Available for use to system software. */
1205 uint32_t u3Available : 3;
1206 /** Reserved / If PAT enabled, bit 2 of the index. */
1207 uint32_t u1PAT : 1;
1208 /** Reserved. */
1209 uint32_t u9Reserved : 9;
1210 /** Physical Page number of the next level - Low part. Don't use! */
1211 uint32_t u10PageNoLow : 10;
1212 /** Physical Page number of the next level - High part. Don't use! */
1213 uint32_t u20PageNoHigh : 20;
1214 /** MBZ bits */
1215 uint32_t u11Reserved : 11;
1216 /** No Execute flag. */
1217 uint32_t u1NoExecute : 1;
1218} X86PDE2MPAEBITS;
1219/** Pointer to a 4MB PAE page table entry. */
1220typedef X86PDE2MPAEBITS *PX86PDE2MPAEBITS;
1221/** Pointer to a 4MB PAE page table entry. */
1222typedef const X86PDE2MPAEBITS *PCX86PDE2MPAEBITS;
1223
1224/** @} */
1225
1226/**
1227 * Page directory entry.
1228 */
1229typedef union X86PDE
1230{
1231 /** Normal view. */
1232 X86PDEBITS n;
1233 /** 4MB view (big). */
1234 X86PDE4MBITS b;
1235 /** Unsigned integer view. */
1236 X86PGUINT u;
1237 /** 8 bit unsigned integer view. */
1238 uint8_t au8[4];
1239 /** 16 bit unsigned integer view. */
1240 uint16_t au16[2];
1241 /** 32 bit unsigned integer view. */
1242 uint32_t au32[1];
1243} X86PDE;
1244/** Pointer to a page directory entry. */
1245typedef X86PDE *PX86PDE;
1246/** Pointer to a const page directory entry. */
1247typedef const X86PDE *PCX86PDE;
1248
1249/**
1250 * PAE page directory entry.
1251 */
1252typedef union X86PDEPAE
1253{
1254 /** Normal view. */
1255 X86PDEPAEBITS n;
1256 /** 2MB page view (big). */
1257 X86PDE2MPAEBITS b;
1258 /** Unsigned integer view. */
1259 X86PGPAEUINT u;
1260 /** 8 bit unsigned integer view. */
1261 uint8_t au8[8];
1262 /** 16 bit unsigned integer view. */
1263 uint16_t au16[4];
1264 /** 32 bit unsigned integer view. */
1265 uint32_t au32[2];
1266} X86PDEPAE;
1267/** Pointer to a page directory entry. */
1268typedef X86PDEPAE *PX86PDEPAE;
1269/** Pointer to a const page directory entry. */
1270typedef const X86PDEPAE *PCX86PDEPAE;
1271
1272/**
1273 * Page directory.
1274 */
1275typedef struct X86PD
1276{
1277 /** PDE Array. */
1278 X86PDE a[X86_PG_ENTRIES];
1279} X86PD;
1280/** Pointer to a page directory. */
1281typedef X86PD *PX86PD;
1282/** Pointer to a const page directory. */
1283typedef const X86PD *PCX86PD;
1284
1285/** The page shift to get the PD index. */
1286#define X86_PD_SHIFT 22
1287/** The PD index mask (apply to a shifted page address). */
1288#define X86_PD_MASK 0x3ff
1289
1290
1291/**
1292 * PAE page directory.
1293 */
1294typedef struct X86PDPAE
1295{
1296 /** PDE Array. */
1297 X86PDEPAE a[X86_PG_PAE_ENTRIES];
1298} X86PDPAE;
1299/** Pointer to a PAE page directory. */
1300typedef X86PDPAE *PX86PDPAE;
1301/** Pointer to a const PAE page directory. */
1302typedef const X86PDPAE *PCX86PDPAE;
1303
1304/** The page shift to get the PAE PD index. */
1305#define X86_PD_PAE_SHIFT 21
1306/** The PAE PD index mask (apply to a shifted page address). */
1307#define X86_PD_PAE_MASK 0x1ff
1308
1309
1310/** @name Page Directory Pointer Table Entry (PAE)
1311 * @{
1312 */
1313/** Bit 0 - P - Present bit. */
1314#define X86_PDPE_P BIT(0)
1315/** Bit 1 - R/W - Read (clear) / Write (set) bit. Long Mode only. */
1316#define X86_PDPE_RW BIT(1)
1317/** Bit 2 - U/S - User (set) / Supervisor (clear) bit. Long Mode only. */
1318#define X86_PDPE_US BIT(2)
1319/** Bit 3 - PWT - Page level write thru bit. */
1320#define X86_PDPE_PWT BIT(3)
1321/** Bit 4 - PCD - Page level cache disable bit. */
1322#define X86_PDPE_PCD BIT(4)
1323/** Bit 5 - A - Access bit. Long Mode only. */
1324#define X86_PDPE_A BIT(5)
1325/** Bits 9-11 - - Available for use to system software. */
1326#define X86_PDPE_AVL_MASK (BIT(9) | BIT(10) | BIT(11))
1327/** Bits 12-51 - - PAE - Physical Page number of the next level. */
1328#if 1 /* we're using this internally and have to mask of the top 16-bit. */
1329#define X86_PDPE_PG_MASK ( 0x0000fffffffff000ULL )
1330#else
1331#define X86_PDPE_PG_MASK ( 0x000ffffffffff000ULL )
1332#endif
1333/** Bits 63 - NX - PAE - No execution flag. */
1334#define X86_PDPE_NX BIT64(63)
1335
1336/**
1337 * Page directory pointer table entry.
1338 */
1339typedef struct X86PDPEBITS
1340{
1341 /** Flags whether(=1) or not the page is present. */
1342 uint32_t u1Present : 1;
1343 /** Read(=0) / Write(=1) flag. */
1344 uint32_t u1Write : 1;
1345 /** User(=1) / Supervisor (=0) flag. */
1346 uint32_t u1User : 1;
1347 /** Write Thru flag. If PAT enabled, bit 0 of the index. */
1348 uint32_t u1WriteThru : 1;
1349 /** Cache disabled flag. If PAT enabled, bit 1 of the index. */
1350 uint32_t u1CacheDisable : 1;
1351 /** Accessed flag.
1352 * Indicates that the page have been read or written to. */
1353 uint32_t u1Accessed : 1;
1354 /** Chunk of reserved bits. */
1355 uint32_t u3Reserved : 3;
1356 /** Available for use to system software. */
1357 uint32_t u3Available : 3;
1358 /** Physical Page number of the next level - Low Part. Don't use! */
1359 uint32_t u20PageNoLow : 20;
1360 /** Physical Page number of the next level - High Part. Don't use! */
1361 uint32_t u20PageNoHigh : 20;
1362 /** MBZ bits */
1363 uint32_t u11Reserved : 11;
1364 /** No Execute flag. */
1365 uint32_t u1NoExecute : 1;
1366} X86PDPEBITS;
1367/** Pointer to a page directory pointer table entry. */
1368typedef X86PDPEBITS *PX86PTPEBITS;
1369/** Pointer to a const page directory pointer table entry. */
1370typedef const X86PDPEBITS *PCX86PTPEBITS;
1371
1372/**
1373 * Page directory pointer table entry.
1374 */
1375typedef union X86PDPE
1376{
1377 /** Normal view. */
1378 X86PDPEBITS n;
1379 /** Unsigned integer view. */
1380 X86PGPAEUINT u;
1381 /** 8 bit unsigned integer view. */
1382 uint8_t au8[8];
1383 /** 16 bit unsigned integer view. */
1384 uint16_t au16[4];
1385 /** 32 bit unsigned integer view. */
1386 uint32_t au32[2];
1387} X86PDPE;
1388/** Pointer to a page directory pointer table entry. */
1389typedef X86PDPE *PX86PDPE;
1390/** Pointer to a const page directory pointer table entry. */
1391typedef const X86PDPE *PCX86PDPE;
1392
1393
1394/**
1395 * Page directory pointer table.
1396 */
1397typedef struct X86PDPTR
1398{
1399 /** PDE Array. */
1400 X86PDPE a[X86_PG_PAE_ENTRIES];
1401} X86PDPTR;
1402/** Pointer to a page directory pointer table. */
1403typedef X86PDPTR *PX86PDPTR;
1404/** Pointer to a const page directory pointer table. */
1405typedef const X86PDPTR *PCX86PDPTR;
1406
1407/** The page shift to get the PDPTR index. */
1408#define X86_PDPTR_SHIFT 30
1409/** The PDPTR index mask (apply to a shifted page address). (32 bits PAE) */
1410#define X86_PDPTR_MASK_32 0x3
1411/** The PDPTR index mask (apply to a shifted page address). (64 bits PAE)*/
1412#define X86_PDPTR_MASK 0x1ff
1413
1414/** @} */
1415
1416
1417/** @name Page Map Level-4 Entry (Long Mode PAE)
1418 * @{
1419 */
1420/** Bit 0 - P - Present bit. */
1421#define X86_PML4E_P BIT(0)
1422/** Bit 1 - R/W - Read (clear) / Write (set) bit. */
1423#define X86_PML4E_RW BIT(1)
1424/** Bit 2 - U/S - User (set) / Supervisor (clear) bit. */
1425#define X86_PML4E_US BIT(2)
1426/** Bit 3 - PWT - Page level write thru bit. */
1427#define X86_PML4E_PWT BIT(3)
1428/** Bit 4 - PCD - Page level cache disable bit. */
1429#define X86_PML4E_PCD BIT(4)
1430/** Bit 5 - A - Access bit. */
1431#define X86_PML4E_A BIT(5)
1432/** Bits 9-11 - - Available for use to system software. */
1433#define X86_PML4E_AVL_MASK (BIT(9) | BIT(10) | BIT(11))
1434/** Bits 12-51 - - PAE - Physical Page number of the next level. */
1435#if 1 /* we're using this internally and have to mask of the top 16-bit. */
1436#define X86_PML4E_PG_MASK ( 0x0000fffffffff000ULL )
1437#else
1438#define X86_PML4E_PG_MASK ( 0x000ffffffffff000ULL )
1439#endif
1440/** Bits 63 - NX - PAE - No execution flag. */
1441#define X86_PML4E_NX BIT64(63)
1442
1443/**
1444 * Page Map Level-4 Entry
1445 */
1446typedef struct X86PML4EBITS
1447{
1448 /** Flags whether(=1) or not the page is present. */
1449 uint32_t u1Present : 1;
1450 /** Read(=0) / Write(=1) flag. */
1451 uint32_t u1Write : 1;
1452 /** User(=1) / Supervisor (=0) flag. */
1453 uint32_t u1User : 1;
1454 /** Write Thru flag. If PAT enabled, bit 0 of the index. */
1455 uint32_t u1WriteThru : 1;
1456 /** Cache disabled flag. If PAT enabled, bit 1 of the index. */
1457 uint32_t u1CacheDisable : 1;
1458 /** Accessed flag.
1459 * Indicates that the page have been read or written to. */
1460 uint32_t u1Accessed : 1;
1461 /** Chunk of reserved bits. */
1462 uint32_t u3Reserved : 3;
1463 /** Available for use to system software. */
1464 uint32_t u3Available : 3;
1465 /** Physical Page number of the next level - Low Part. Don't use! */
1466 uint32_t u20PageNoLow : 20;
1467 /** Physical Page number of the next level - High Part. Don't use! */
1468 uint32_t u20PageNoHigh : 20;
1469 /** MBZ bits */
1470 uint32_t u11Reserved : 11;
1471 /** No Execute flag. */
1472 uint32_t u1NoExecute : 1;
1473} X86PML4EBITS;
1474/** Pointer to a page map level-4 entry. */
1475typedef X86PML4EBITS *PX86PML4EBITS;
1476/** Pointer to a const page map level-4 entry. */
1477typedef const X86PML4EBITS *PCX86PML4EBITS;
1478
1479/**
1480 * Page Map Level-4 Entry.
1481 */
1482typedef union X86PML4E
1483{
1484 /** Normal view. */
1485 X86PML4EBITS n;
1486 /** Unsigned integer view. */
1487 X86PGPAEUINT u;
1488 /** 8 bit unsigned integer view. */
1489 uint8_t au8[8];
1490 /** 16 bit unsigned integer view. */
1491 uint16_t au16[4];
1492 /** 32 bit unsigned integer view. */
1493 uint32_t au32[2];
1494} X86PML4E;
1495/** Pointer to a page map level-4 entry. */
1496typedef X86PML4E *PX86PML4E;
1497/** Pointer to a const page map level-4 entry. */
1498typedef const X86PML4E *PCX86PML4E;
1499
1500
1501/**
1502 * Page Map Level-4.
1503 */
1504typedef struct X86PML4
1505{
1506 /** PDE Array. */
1507 X86PML4E a[X86_PG_PAE_ENTRIES];
1508} X86PML4;
1509/** Pointer to a page map level-4. */
1510typedef X86PML4 *PX86PML4;
1511/** Pointer to a const page map level-4. */
1512typedef const X86PML4 *PCX86PML4;
1513
1514/** The page shift to get the PML4 index. */
1515#define X86_PML4_SHIFT 39
1516/** The PML4 index mask (apply to a shifted page address). */
1517#define X86_PML4_MASK 0x1ff
1518
1519/** @} */
1520
1521/** @} */
1522
1523
1524/**
1525 * 80-bit MMX/FPU register type.
1526 */
1527typedef struct X86FPUMMX
1528{
1529 uint8_t reg[10];
1530} X86FPUMMX;
1531/** Pointer to a 80-bit MMX/FPU register type. */
1532typedef X86FPUMMX *PX86FPUMMX;
1533/** Pointer to a const 80-bit MMX/FPU register type. */
1534typedef const X86FPUMMX *PCX86FPUMMX;
1535
1536/**
1537 * FPU state (aka FSAVE/FRSTOR Memory Region).
1538 */
1539#pragma pack(1)
1540typedef struct X86FPUSTATE
1541{
1542 /** Control word. */
1543 uint16_t FCW;
1544 /** Alignment word */
1545 uint16_t Dummy1;
1546 /** Status word. */
1547 uint16_t FSW;
1548 /** Alignment word */
1549 uint16_t Dummy2;
1550 /** Tag word */
1551 uint16_t FTW;
1552 /** Alignment word */
1553 uint16_t Dummy3;
1554
1555 /** Instruction pointer. */
1556 uint32_t FPUIP;
1557 /** Code selector. */
1558 uint16_t CS;
1559 /** Opcode. */
1560 uint16_t FOP;
1561 /** FOO. */
1562 uint32_t FPUOO;
1563 /** FOS. */
1564 uint32_t FPUOS;
1565 /** FPU view - todo. */
1566 X86FPUMMX regs[8];
1567} X86FPUSTATE;
1568#pragma pack()
1569/** Pointer to a FPU state. */
1570typedef X86FPUSTATE *PX86FPUSTATE;
1571/** Pointer to a const FPU state. */
1572typedef const X86FPUSTATE *PCX86FPUSTATE;
1573
1574/**
1575 * FPU Extended state (aka FXSAVE/FXRSTORE Memory Region).
1576 */
1577#pragma pack(1)
1578typedef struct X86FXSTATE
1579{
1580 /** Control word. */
1581 uint16_t FCW;
1582 /** Status word. */
1583 uint16_t FSW;
1584 /** Tag word (it's a byte actually). */
1585 uint8_t FTW;
1586 uint8_t huh1;
1587 /** Opcode. */
1588 uint16_t FOP;
1589 /** Instruction pointer. */
1590 uint32_t FPUIP;
1591 /** Code selector. */
1592 uint16_t CS;
1593 uint16_t Rsvrd1;
1594 /* - offset 16 - */
1595 /** Data pointer. */
1596 uint32_t FPUDP;
1597 /** Data segment */
1598 uint16_t DS;
1599 uint16_t Rsrvd2;
1600 uint32_t MXCSR;
1601 uint32_t MXCSR_MASK;
1602 /* - offset 32 - */
1603 union
1604 {
1605 /** MMX view. */
1606 uint64_t mmx;
1607 /** FPU view - todo. */
1608 X86FPUMMX fpu;
1609 /** 8-bit view. */
1610 uint8_t au8[16];
1611 /** 16-bit view. */
1612 uint16_t au16[8];
1613 /** 32-bit view. */
1614 uint32_t au32[4];
1615 /** 64-bit view. */
1616 uint64_t au64[2];
1617 /** 128-bit view. (yeah, very helpful) */
1618 uint128_t au128[1];
1619 } aRegs[8];
1620 /* - offset 160 - */
1621 union
1622 {
1623 /** XMM Register view *. */
1624 uint128_t xmm;
1625 /** 8-bit view. */
1626 uint8_t au8[16];
1627 /** 16-bit view. */
1628 uint16_t au16[8];
1629 /** 32-bit view. */
1630 uint32_t au32[4];
1631 /** 64-bit view. */
1632 uint64_t au64[2];
1633 /** 128-bit view. (yeah, very helpful) */
1634 uint128_t au128[1];
1635 } aXMM[8];
1636 /* - offset 288 - */
1637 uint32_t au32RsrvdRest[(512 - 288) / sizeof(uint32_t)];
1638} X86FXSTATE;
1639#pragma pack()
1640/** Pointer to a FPU Extended state. */
1641typedef X86FXSTATE *PX86FXSTATE;
1642/** Pointer to a const FPU Extended state. */
1643typedef const X86FXSTATE *PCX86FXSTATE;
1644
1645
1646/** @name Selector Descriptor
1647 * @{
1648 */
1649
1650/**
1651 * Generic descriptor table entry
1652 */
1653#pragma pack(1)
1654typedef struct X86DESCGENERIC
1655{
1656 /** Limit - Low word. */
1657 unsigned u16LimitLow : 16;
1658 /** Base address - lowe word.
1659 * Don't try set this to 24 because MSC is doing studing things then. */
1660 unsigned u16BaseLow : 16;
1661 /** Base address - first 8 bits of high word. */
1662 unsigned u8BaseHigh1 : 8;
1663 /** Segment Type. */
1664 unsigned u4Type : 4;
1665 /** Descriptor Type. System(=0) or code/data selector */
1666 unsigned u1DescType : 1;
1667 /** Descriptor Privelege level. */
1668 unsigned u2Dpl : 2;
1669 /** Flags selector present(=1) or not. */
1670 unsigned u1Present : 1;
1671 /** Segment limit 16-19. */
1672 unsigned u4LimitHigh : 4;
1673 /** Available for system software. */
1674 unsigned u1Available : 1;
1675 /** Reserved - 0. */
1676 unsigned u1Reserved : 1;
1677 /** This flags meaning depends on the segment type. Try make sense out
1678 * of the intel manual yourself. */
1679 unsigned u1DefBig : 1;
1680 /** Granularity of the limit. If set 4KB granularity is used, if
1681 * clear byte. */
1682 unsigned u1Granularity : 1;
1683 /** Base address - highest 8 bits. */
1684 unsigned u8BaseHigh2 : 8;
1685} X86DESCGENERIC;
1686#pragma pack()
1687/** Pointer to a generic descriptor entry. */
1688typedef X86DESCGENERIC *PX86DESCGENERIC;
1689/** Pointer to a const generic descriptor entry. */
1690typedef const X86DESCGENERIC *PCX86DESCGENERIC;
1691
1692
1693/**
1694 * Descriptor attributes.
1695 */
1696typedef struct X86DESCATTRBITS
1697{
1698 /** Segment Type. */
1699 unsigned u4Type : 4;
1700 /** Descriptor Type. System(=0) or code/data selector */
1701 unsigned u1DescType : 1;
1702 /** Descriptor Privelege level. */
1703 unsigned u2Dpl : 2;
1704 /** Flags selector present(=1) or not. */
1705 unsigned u1Present : 1;
1706 /** Segment limit 16-19. */
1707 unsigned u4LimitHigh : 4;
1708 /** Available for system software. */
1709 unsigned u1Available : 1;
1710 /** Reserved - 0. */
1711 unsigned u1Reserved : 1;
1712 /** This flags meaning depends on the segment type. Try make sense out
1713 * of the intel manual yourself. */
1714 unsigned u1DefBig : 1;
1715 /** Granularity of the limit. If set 4KB granularity is used, if
1716 * clear byte. */
1717 unsigned u1Granularity : 1;
1718} X86DESCATTRBITS;
1719
1720
1721#pragma pack(1)
1722typedef union X86DESCATTR
1723{
1724 /** Normal view. */
1725 X86DESCATTRBITS n;
1726 /** Unsigned integer view. */
1727 uint32_t u;
1728} X86DESCATTR;
1729#pragma pack()
1730
1731/** Pointer to descriptor attributes. */
1732typedef X86DESCATTR *PX86DESCATTR;
1733/** Pointer to const descriptor attributes. */
1734typedef const X86DESCATTR *PCX86DESCATTR;
1735
1736
1737/**
1738 * Descriptor table entry.
1739 */
1740#pragma pack(1)
1741typedef union X86DESC
1742{
1743 /** Generic descriptor view. */
1744 X86DESCGENERIC Gen;
1745#if 0
1746 /** IDT view. */
1747 VBOXIDTE Idt;
1748#endif
1749
1750 /** 8 bit unsigned interger view. */
1751 uint8_t au8[8];
1752 /** 16 bit unsigned interger view. */
1753 uint16_t au16[4];
1754 /** 32 bit unsigned interger view. */
1755 uint32_t au32[2];
1756} X86DESC;
1757#pragma pack()
1758/** Pointer to descriptor table entry. */
1759typedef X86DESC *PX86DESC;
1760/** Pointer to const descriptor table entry. */
1761typedef const X86DESC *PCX86DESC;
1762
1763
1764/**
1765 * 64 bits generic descriptor table entry
1766 * Note: most of these bits have no meaning in long mode.
1767 */
1768#pragma pack(1)
1769typedef struct X86DESC64GENERIC
1770{
1771 /** Limit - Low word - *IGNORED*. */
1772 unsigned u16LimitLow : 16;
1773 /** Base address - lowe word. - *IGNORED*
1774 * Don't try set this to 24 because MSC is doing studing things then. */
1775 unsigned u16BaseLow : 16;
1776 /** Base address - first 8 bits of high word. - *IGNORED* */
1777 unsigned u8BaseHigh1 : 8;
1778 /** Segment Type. */
1779 unsigned u4Type : 4;
1780 /** Descriptor Type. System(=0) or code/data selector */
1781 unsigned u1DescType : 1;
1782 /** Descriptor Privelege level. */
1783 unsigned u2Dpl : 2;
1784 /** Flags selector present(=1) or not. */
1785 unsigned u1Present : 1;
1786 /** Segment limit 16-19. - *IGNORED* */
1787 unsigned u4LimitHigh : 4;
1788 /** Available for system software. - *IGNORED* */
1789 unsigned u1Available : 1;
1790 /** Long mode flag. */
1791 unsigned u1Long : 1;
1792 /** This flags meaning depends on the segment type. Try make sense out
1793 * of the intel manual yourself. */
1794 unsigned u1DefBig : 1;
1795 /** Granularity of the limit. If set 4KB granularity is used, if
1796 * clear byte. - *IGNORED* */
1797 unsigned u1Granularity : 1;
1798 /** Base address - highest 8 bits. - *IGNORED* */
1799 unsigned u8BaseHigh2 : 8;
1800 /** Base address - bits 63-32. */
1801 unsigned u32BaseHigh3 : 32;
1802 unsigned u8Reserved : 8;
1803 unsigned u5Zeros : 5;
1804 unsigned u19Reserved : 19;
1805} X86DESC64GENERIC;
1806#pragma pack()
1807/** Pointer to a generic descriptor entry. */
1808typedef X86DESC64GENERIC *PX86DESC64GENERIC;
1809/** Pointer to a const generic descriptor entry. */
1810typedef const X86DESC64GENERIC *PCX86DESC64GENERIC;
1811
1812/**
1813 * System descriptor table entry (64 bits)
1814 */
1815#pragma pack(1)
1816typedef struct X86DESC64SYSTEM
1817{
1818 /** Limit - Low word. */
1819 unsigned u16LimitLow : 16;
1820 /** Base address - lowe word.
1821 * Don't try set this to 24 because MSC is doing studing things then. */
1822 unsigned u16BaseLow : 16;
1823 /** Base address - first 8 bits of high word. */
1824 unsigned u8BaseHigh1 : 8;
1825 /** Segment Type. */
1826 unsigned u4Type : 4;
1827 /** Descriptor Type. System(=0) or code/data selector */
1828 unsigned u1DescType : 1;
1829 /** Descriptor Privelege level. */
1830 unsigned u2Dpl : 2;
1831 /** Flags selector present(=1) or not. */
1832 unsigned u1Present : 1;
1833 /** Segment limit 16-19. */
1834 unsigned u4LimitHigh : 4;
1835 /** Available for system software. */
1836 unsigned u1Available : 1;
1837 /** Reserved - 0. */
1838 unsigned u1Reserved : 1;
1839 /** This flags meaning depends on the segment type. Try make sense out
1840 * of the intel manual yourself. */
1841 unsigned u1DefBig : 1;
1842 /** Granularity of the limit. If set 4KB granularity is used, if
1843 * clear byte. */
1844 unsigned u1Granularity : 1;
1845 /** Base address - bits 31-24. */
1846 unsigned u8BaseHigh2 : 8;
1847 /** Base address - bits 63-32. */
1848 unsigned u32BaseHigh3 : 32;
1849 unsigned u8Reserved : 8;
1850 unsigned u5Zeros : 5;
1851 unsigned u19Reserved : 19;
1852} X86DESC64SYSTEM;
1853#pragma pack()
1854/** Pointer to a generic descriptor entry. */
1855typedef X86DESC64SYSTEM *PX86DESC64SYSTEM;
1856/** Pointer to a const generic descriptor entry. */
1857typedef const X86DESC64SYSTEM *PCX86DESC64SYSTEM;
1858
1859
1860/**
1861 * Descriptor table entry.
1862 */
1863#pragma pack(1)
1864typedef union X86DESC64
1865{
1866 /** Generic descriptor view. */
1867 X86DESC64GENERIC Gen;
1868 /** System descriptor view. */
1869 X86DESC64SYSTEM System;
1870#if 0
1871 X86DESC64GATE Gate;
1872#endif
1873
1874 /** 8 bit unsigned interger view. */
1875 uint8_t au8[16];
1876 /** 16 bit unsigned interger view. */
1877 uint16_t au16[8];
1878 /** 32 bit unsigned interger view. */
1879 uint32_t au32[4];
1880 /** 64 bit unsigned interger view. */
1881 uint64_t au64[2];
1882} X86DESC64;
1883#pragma pack()
1884/** Pointer to descriptor table entry. */
1885typedef X86DESC64 *PX86DESC64;
1886/** Pointer to const descriptor table entry. */
1887typedef const X86DESC64 *PCX86DESC64;
1888
1889#if HC_ARCH_BITS == 64
1890typedef X86DESC64 X86DESCHC;
1891typedef X86DESC64 *PX86DESCHC;
1892#else
1893typedef X86DESC X86DESCHC;
1894typedef X86DESC *PX86DESCHC;
1895#endif
1896
1897/** @name Selector Descriptor Types.
1898 * @{
1899 */
1900
1901/** @name Non-System Selector Types.
1902 * @{ */
1903/** Code(=set)/Data(=clear) bit. */
1904#define X86_SEL_TYPE_CODE 8
1905/** Memory(=set)/System(=clear) bit. */
1906#define X86_SEL_TYPE_MEMORY BIT(4)
1907/** Accessed bit. */
1908#define X86_SEL_TYPE_ACCESSED 1
1909/** Expand down bit (for data selectors only). */
1910#define X86_SEL_TYPE_DOWN 4
1911/** Conforming bit (for code selectors only). */
1912#define X86_SEL_TYPE_CONF 4
1913/** Write bit (for data selectors only). */
1914#define X86_SEL_TYPE_WRITE 2
1915/** Read bit (for code selectors only). */
1916#define X86_SEL_TYPE_READ 2
1917
1918/** Read only selector type. */
1919#define X86_SEL_TYPE_RO 0
1920/** Accessed read only selector type. */
1921#define X86_SEL_TYPE_RO_ACC (0 | X86_SEL_TYPE_ACCESSED)
1922/** Read write selector type. */
1923#define X86_SEL_TYPE_RW 2
1924/** Accessed read write selector type. */
1925#define X86_SEL_TYPE_RW_ACC (2 | X86_SEL_TYPE_ACCESSED)
1926/** Expand down read only selector type. */
1927#define X86_SEL_TYPE_RO_DOWN 4
1928/** Accessed expand down read only selector type. */
1929#define X86_SEL_TYPE_RO_DOWN_ACC (4 | X86_SEL_TYPE_ACCESSED)
1930/** Expand down read write selector type. */
1931#define X86_SEL_TYPE_RW_DOWN 6
1932/** Accessed expand down read write selector type. */
1933#define X86_SEL_TYPE_RW_DOWN_ACC (6 | X86_SEL_TYPE_ACCESSED)
1934/** Execute only selector type. */
1935#define X86_SEL_TYPE_EO (0 | X86_SEL_TYPE_CODE)
1936/** Accessed execute only selector type. */
1937#define X86_SEL_TYPE_EO_ACC (0 | X86_SEL_TYPE_CODE | X86_SEL_TYPE_ACCESSED)
1938/** Execute and read selector type. */
1939#define X86_SEL_TYPE_ER (2 | X86_SEL_TYPE_CODE)
1940/** Accessed execute and read selector type. */
1941#define X86_SEL_TYPE_ER_ACC (2 | X86_SEL_TYPE_CODE | X86_SEL_TYPE_ACCESSED)
1942/** Conforming execute only selector type. */
1943#define X86_SEL_TYPE_EO_CONF (4 | X86_SEL_TYPE_CODE)
1944/** Accessed Conforming execute only selector type. */
1945#define X86_SEL_TYPE_EO_CONF_ACC (4 | X86_SEL_TYPE_CODE | X86_SEL_TYPE_ACCESSED)
1946/** Conforming execute and write selector type. */
1947#define X86_SEL_TYPE_ER_CONF (6 | X86_SEL_TYPE_CODE)
1948/** Accessed Conforming execute and write selector type. */
1949#define X86_SEL_TYPE_ER_CONF_ACC (6 | X86_SEL_TYPE_CODE | X86_SEL_TYPE_ACCESSED)
1950/** @} */
1951
1952
1953/** @name System Selector Types.
1954 * @{ */
1955/** Undefined system selector type. */
1956#define X86_SEL_TYPE_SYS_UNDEFINED 0
1957/** 286 TSS selector. */
1958#define X86_SEL_TYPE_SYS_286_TSS_AVAIL 1
1959/** LDT selector. */
1960#define X86_SEL_TYPE_SYS_LDT 2
1961/** 286 TSS selector - Busy. */
1962#define X86_SEL_TYPE_SYS_286_TSS_BUSY 3
1963/** 286 Callgate selector. */
1964#define X86_SEL_TYPE_SYS_286_CALL_GATE 4
1965/** Taskgate selector. */
1966#define X86_SEL_TYPE_SYS_TASK_GATE 5
1967/** 286 Interrupt gate selector. */
1968#define X86_SEL_TYPE_SYS_286_INT_GATE 6
1969/** 286 Trapgate selector. */
1970#define X86_SEL_TYPE_SYS_286_TRAP_GATE 7
1971/** Undefined system selector. */
1972#define X86_SEL_TYPE_SYS_UNDEFINED2 8
1973/** 386 TSS selector. */
1974#define X86_SEL_TYPE_SYS_386_TSS_AVAIL 9
1975/** Undefined system selector. */
1976#define X86_SEL_TYPE_SYS_UNDEFINED3 0xA
1977/** 386 TSS selector - Busy. */
1978#define X86_SEL_TYPE_SYS_386_TSS_BUSY 0xB
1979/** 386 Callgate selector. */
1980#define X86_SEL_TYPE_SYS_386_CALL_GATE 0xC
1981/** Undefined system selector. */
1982#define X86_SEL_TYPE_SYS_UNDEFINED4 0xD
1983/** 386 Interruptgate selector. */
1984#define X86_SEL_TYPE_SYS_386_INT_GATE 0xE
1985/** 386 Trapgate selector. */
1986#define X86_SEL_TYPE_SYS_386_TRAP_GATE 0xF
1987/** @} */
1988
1989/** @name AMD64 System Selector Types.
1990 * @{ */
1991#define AMD64_SEL_TYPE_SYS_LDT 2
1992/** 286 TSS selector - Busy. */
1993#define AMD64_SEL_TYPE_SYS_TSS_AVAIL 9
1994/** 386 TSS selector - Busy. */
1995#define AMD64_SEL_TYPE_SYS_TSS_BUSY 0xB
1996/** 386 Callgate selector. */
1997#define AMD64_SEL_TYPE_SYS_CALL_GATE 0xC
1998/** 386 Interruptgate selector. */
1999#define AMD64_SEL_TYPE_SYS_INT_GATE 0xE
2000/** 386 Trapgate selector. */
2001#define AMD64_SEL_TYPE_SYS_TRAP_GATE 0xF
2002/** @} */
2003
2004/** @} */
2005
2006
2007/** @name Descriptor Table Entry Flag Masks.
2008 * These are for the 2nd 32-bit word of a descriptor.
2009 * @{ */
2010/** Bits 8-11 - TYPE - Descriptor type mask. */
2011#define X86_DESC_TYPE_MASK (BIT(8) | BIT(9) | BIT(10) | BIT(11))
2012/** Bit 12 - S - System (=0) or Code/Data (=1). */
2013#define X86_DESC_S BIT(12)
2014/** Bits 13-14 - DPL - Descriptor Privilege Level. */
2015#define X86_DESC_DPL (BIT(13) | BIT(14))
2016/** Bit 15 - P - Present. */
2017#define X86_DESC_P BIT(15)
2018/** Bit 20 - AVL - Available for system software. */
2019#define X86_DESC_AVL BIT(20)
2020/** Bit 22 - DB - Default operation size. 0 = 16 bit, 1 = 32 bit. */
2021#define X86_DESC_DB BIT(22)
2022/** Bit 23 - G - Granularity of the limit. If set 4KB granularity is
2023 * used, if clear byte. */
2024#define X86_DESC_G BIT(23)
2025/** @} */
2026
2027/** @} */
2028
2029
2030/** @name Selectors.
2031 * @{
2032 */
2033
2034/**
2035 * The shift used to convert a selector from and to index an index (C).
2036 */
2037#define X86_SEL_SHIFT 3
2038
2039/**
2040 * The shift used to convert a selector from and to index an index (C).
2041 */
2042#define AMD64_SEL_SHIFT 4
2043
2044#if HC_ARCH_BITS == 64
2045#define X86_SEL_SHIFT_HC AMD64_SEL_SHIFT
2046#else
2047#define X86_SEL_SHIFT_HC X86_SEL_SHIFT
2048#endif
2049
2050/**
2051 * The mask used to mask off the table indicator and CPL of an selector.
2052 */
2053#define X86_SEL_MASK 0xfff8
2054
2055/**
2056 * The bit indicating that a selector is in the LDT and not in the GDT.
2057 */
2058#define X86_SEL_LDT 0x0004
2059/**
2060 * The bit mask for getting the RPL of a selector.
2061 */
2062#define X86_SEL_RPL 0x0003
2063
2064/** @} */
2065
2066
2067/**
2068 * x86 Exceptions/Faults/Traps.
2069 */
2070typedef enum X86XCPT
2071{
2072 /** \#DE - Divide error. */
2073 X86_XCPT_DE = 0x00,
2074 /** \#DB - Debug event (single step, DRx, ..) */
2075 X86_XCPT_DB = 0x01,
2076 /** NMI - Non-Maskable Interrupt */
2077 X86_XCPT_NMI = 0x02,
2078 /** \#BP - Breakpoint (INT3). */
2079 X86_XCPT_BP = 0x03,
2080 /** \#OF - Overflow (INTO). */
2081 X86_XCPT_OF = 0x04,
2082 /** \#BR - Bound range exceeded (BOUND). */
2083 X86_XCPT_BR = 0x05,
2084 /** \#UD - Undefined opcode. */
2085 X86_XCPT_UD = 0x06,
2086 /** \#NM - Device not available (math coprocessor device). */
2087 X86_XCPT_NM = 0x07,
2088 /** \#DF - Double fault. */
2089 X86_XCPT_DF = 0x08,
2090 /** ??? - Coprocessor segment overrun (obsolete). */
2091 X86_XCPT_CO_SEG_OVERRUN = 0x09,
2092 /** \#TS - Taskswitch (TSS). */
2093 X86_XCPT_TS = 0x0a,
2094 /** \#NP - Segment no present. */
2095 X86_XCPT_NP = 0x0b,
2096 /** \#SS - Stack segment fault. */
2097 X86_XCPT_SS = 0x0c,
2098 /** \#GP - General protection fault. */
2099 X86_XCPT_GP = 0x0d,
2100 /** \#PF - Page fault. */
2101 X86_XCPT_PF = 0x0e,
2102 /* 0x0f is reserved. */
2103 /** \#MF - Math fault (FPU). */
2104 X86_XCPT_MF = 0x10,
2105 /** \#AC - Alignment check. */
2106 X86_XCPT_AC = 0x11,
2107 /** \#MC - Machine check. */
2108 X86_XCPT_MC = 0x12,
2109 /** \#XF - SIMD Floating-Pointer Exception. */
2110 X86_XCPT_XF = 0x13
2111} X86XCPT;
2112/** Pointer to a x86 exception code. */
2113typedef X86XCPT *PX86XCPT;
2114/** Pointer to a const x86 exception code. */
2115typedef const X86XCPT *PCX86XCPT;
2116
2117
2118/** @name Trap Error Codes
2119 * @{
2120 */
2121/** External indicator. */
2122#define X86_TRAP_ERR_EXTERNAL 1
2123/** IDT indicator. */
2124#define X86_TRAP_ERR_IDT 2
2125/** Descriptor table indicator - If set LDT, if clear GDT. */
2126#define X86_TRAP_ERR_TI 4
2127/** Mask for getting the selector. */
2128#define X86_TRAP_ERR_SEL_MASK 0xfff8
2129/** Shift for getting the selector table index (C type index). */
2130#define X86_TRAP_ERR_SEL_SHIFT 3
2131/** @} */
2132
2133
2134/** @name \#PF Trap Error Codes
2135 * @{
2136 */
2137/** Bit 0 - P - Not present (clear) or page level protection (set) fault. */
2138#define X86_TRAP_PF_P BIT(0)
2139/** Bit 1 - R/W - Read (clear) or write (set) access. */
2140#define X86_TRAP_PF_RW BIT(1)
2141/** Bit 2 - U/S - CPU executing in user mode (set) or supervisor mode (clear). */
2142#define X86_TRAP_PF_US BIT(2)
2143/** Bit 3 - RSVD- Reserved bit violation (set), i.e. reserved bit was set to 1. */
2144#define X86_TRAP_PF_RSVD BIT(3)
2145/** Bit 4 - I/D - Instruction fetch (set) / Data access (clear) - PAE + NXE. */
2146#define X86_TRAP_PF_ID BIT(4)
2147/** @} */
2148
2149#pragma pack(1)
2150/**
2151 * 32-bit IDTR/GDTR.
2152 */
2153typedef struct X86XDTR32
2154{
2155 /** Size of the descriptor table. */
2156 uint16_t cb;
2157 /** Address of the descriptor table. */
2158 uint32_t uAddr;
2159} X86XDTR32, *PX86XDTR32;
2160#pragma pack()
2161
2162#pragma pack(1)
2163/**
2164 * 64-bit IDTR/GDTR.
2165 */
2166typedef struct X86XDTR64
2167{
2168 /** Size of the descriptor table. */
2169 uint16_t cb;
2170 /** Address of the descriptor table. */
2171 uint64_t uAddr;
2172} X86XDTR64, *PX86XDTR64;
2173#pragma pack()
2174
2175/** @} */
2176
2177#endif
2178
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette