xref: /reactos/sdk/include/ndk/i386/ketypes.h (revision bf9cac8a)
1 /*++ NDK Version: 0098
2 
3 Copyright (c) Alex Ionescu.  All rights reserved.
4 
5 Header Name:
6 
7     ketypes.h (X86)
8 
9 Abstract:
10 
11     i386 Type definitions for the Kernel services.
12 
13 Author:
14 
15     Alex Ionescu (alexi@tinykrnl.org) - Updated - 27-Feb-2006
16 
17 --*/
18 
19 #ifndef _I386_KETYPES_H
20 #define _I386_KETYPES_H
21 
22 //
23 // Dependencies
24 //
25 
26 //
27 // Kernel Feature Bits
28 // See https://www.geoffchappell.com/studies/windows/km/ntoskrnl/structs/kprcb/featurebits.htm?tx=61&ts=0,1400
29 //
30 #define KF_V86_VIS                      0x00000001 // From ks386.inc
31 #define KF_RDTSC                        0x00000002 // From ks386.inc, ksamd64.inc
32 #define KF_CR4                          0x00000004 // From ks386.inc, ksamd64.inc
33 #define KF_CMOV                         0x00000008
34 #define KF_GLOBAL_PAGE                  0x00000010 // From ks386.inc, ksamd64.inc
35 #define KF_LARGE_PAGE                   0x00000020 // From ks386.inc, ksamd64.inc
36 #define KF_MTRR                         0x00000040
37 #define KF_CMPXCHG8B                    0x00000080 // From ks386.inc, ksamd64.inc
38 #define KF_MMX                          0x00000100
39 #define KF_WORKING_PTE                  0x00000200
40 #define KF_PAT                          0x00000400
41 #define KF_FXSR                         0x00000800
42 #define KF_FAST_SYSCALL                 0x00001000 // From ks386.inc, ksamd64.inc
43 #define KF_XMMI                         0x00002000 // SSE
44 #define KF_3DNOW                        0x00004000
45 #define KF_AMDK6MTRR                    0x00008000 // Win 5.0-6.1
46 #define KF_XSAVEOPT                     0x00008000 // From KF_XSAVEOPT_BIT
47 #define KF_XMMI64                       0x00010000 // SSE2
48 #define KF_DTS                          0x00020000
49 #define KF_CLFLUSH                      0x00040000 // Win 6.0+
50 #define KF_SSE3                         0x00080000 // Win 6.0+
51 #define KF_AUTHENTICAMD                 0x00100000 // Win 6.1+ (family 5+)
52 #define KF_ACNT2                        0x00200000 // Win 6.1+
53 #define KF_XSTATE                       0x00400000 // From ks386.inc, Win 6.1+
54 #define KF_GENUINE_INTEL                0x00800000 // Win 6.1+
55 #define KF_SMEP                         0x01000000 // Win 6.2+
56 #define KF_RDRAND                       0x02000000 // Win 6.3+
57 #define KF_SLAT                         0x04000000 // Win 6.2+, Intel: EPT supported
58 #define KF_08000000                     0x08000000 // Win 6.2+
59 #define KF_NX_BIT                       0x20000000
60 #define KF_NX_DISABLED                  0x40000000
61 #define KF_NX_ENABLED                   0x80000000
62 #define KF_RDTSCP               0x0000000100000000ULL // Win 10.0+
63 #define KF_CLFLUSHOPT           0x0000000200000000ULL // Win 10.0+
64 #define KF_HDC                  0x0000000400000000ULL // Win 10.0+
65 #define KF_FPU_LEAKAGE          0x0000001000000000ULL // From ks386.inc KF_FPU_LEAKAGE_BIT
66 #define KF_SSSE3                0x0000004000000000ULL
67 #define KF_SSE4_1               0x0000008000000000ULL
68 #define KF_SSE4_2               0x0000010000000000ULL
69 
70 #define KF_FPU_LEAKAGE_BIT              36 // From ks386.inc (0x24 -> 0x1000000000)
71 
72 //
73 // KPCR Access for non-IA64 builds
74 //
75 #define K0IPCR                  ((ULONG_PTR)(KIP0PCRADDRESS))
76 #define PCR                     ((KPCR *)K0IPCR)
77 #if defined(CONFIG_SMP) || defined(NT_BUILD)
78 //#undef  KeGetPcr
79 #define KeGetPcr()              ((KPCR *)__readfsdword(FIELD_OFFSET(KPCR, SelfPcr)))
80 #else
81 #define KeGetPcr()              PCR
82 #endif
83 
84 //
85 // CPU Vendors
86 //
87 typedef enum
88 {
89     CPU_NONE      = 0,
90     CPU_INTEL     = 1,
91     CPU_AMD       = 2,
92     CPU_CYRIX     = 3,
93     CPU_TRANSMETA = 4,
94     CPU_VIA       = 5,
95     CPU_CENTAUR   = CPU_VIA,
96     CPU_RISE      = 6,
97     CPU_UNKNOWN   = 7
98 } CPU_VENDORS;
99 
100 //
101 // Machine Types
102 //
103 #define MACHINE_TYPE_ISA        0x0000
104 #define MACHINE_TYPE_EISA       0x0001
105 #define MACHINE_TYPE_MCA        0x0002
106 
107 //
108 // X86 80386 Segment Types
109 //
110 #define I386_TASK_GATE          0x5
111 #define I386_TSS                0x9
112 #define I386_ACTIVE_TSS         0xB
113 #define I386_CALL_GATE          0xC
114 #define I386_INTERRUPT_GATE     0xE
115 #define I386_TRAP_GATE          0xF
116 
117 //
118 // Selector Names
119 //
120 #define RPL_MASK                0x0003
121 #define MODE_MASK               0x0001
122 #define KGDT_NULL               0x00
123 #define KGDT_R0_CODE            0x08
124 #define KGDT_R0_DATA            0x10
125 #define KGDT_R3_CODE            0x18
126 #define KGDT_R3_DATA            0x20
127 #define KGDT_TSS                0x28
128 #define KGDT_R0_PCR             0x30
129 #define KGDT_R3_TEB             0x38
130 #define KGDT_VDM_TILE           0x40
131 #define KGDT_LDT                0x48
132 #define KGDT_DF_TSS             0x50
133 #define KGDT_NMI_TSS            0x58
134 
135 //
136 // Define the number of GDTs that can be queried by user mode
137 //
138 #define KGDT_NUMBER             10
139 
140 //
141 // CR4
142 //
143 #define CR4_VME                 0x1
144 #define CR4_PVI                 0x2
145 #define CR4_TSD                 0x4
146 #define CR4_DE                  0x8
147 #define CR4_PSE                 0x10
148 #define CR4_PAE                 0x20
149 #define CR4_MCE                 0x40
150 #define CR4_PGE                 0x80
151 #define CR4_FXSR                0x200
152 #define CR4_XMMEXCPT            0x400
153 
154 //
155 // EFlags
156 //
157 #define EFLAGS_CF               0x01L
158 #define EFLAGS_ZF               0x40L
159 #define EFLAGS_TF               0x100L
160 #define EFLAGS_INTERRUPT_MASK   0x200L
161 #define EFLAGS_DF               0x400L
162 #define EFLAGS_IOPL             0x3000L
163 #define EFLAGS_NESTED_TASK      0x4000L
164 #define EFLAGS_RF               0x10000
165 #define EFLAGS_V86_MASK         0x20000
166 #define EFLAGS_ALIGN_CHECK      0x40000
167 #define EFLAGS_VIF              0x80000
168 #define EFLAGS_VIP              0x100000
169 #define EFLAGS_ID               0x200000
170 #define EFLAGS_USER_SANITIZE    0x3F4DD7
171 #define EFLAG_SIGN              0x8000
172 #define EFLAG_ZERO              0x4000
173 
174 //
175 // Legacy floating status word bit masks.
176 //
177 #define FSW_INVALID_OPERATION   0x1
178 #define FSW_DENORMAL            0x2
179 #define FSW_ZERO_DIVIDE         0x4
180 #define FSW_OVERFLOW            0x8
181 #define FSW_UNDERFLOW           0x10
182 #define FSW_PRECISION           0x20
183 #define FSW_STACK_FAULT         0x40
184 
185 //
186 // Machine Specific Registers
187 //
188 #define MSR_AMD_ACCESS          0x9C5A203A
189 #define MSR_IA32_MISC_ENABLE    0x01A0
190 #define MSR_EFER                0xC0000080
191 
192 //
193 // MSR internal Values
194 //
195 #define MSR_NXE                 0x0800
196 #define XHF_NOEXECUTE           0x100000
197 #define MSR_XD_ENABLE_MASK      0xFFFFFFFB
198 
199 //
200 // IPI Types
201 //
202 #define IPI_APC                 1
203 #define IPI_DPC                 2
204 #define IPI_FREEZE              4
205 #define IPI_PACKET_READY        8
206 #define IPI_SYNCH_REQUEST       16
207 
208 //
209 // PRCB Flags
210 //
211 #define PRCB_MINOR_VERSION      1
212 #define PRCB_MAJOR_VERSION      1
213 #define PRCB_BUILD_DEBUG        1
214 #define PRCB_BUILD_UNIPROCESSOR 2
215 
216 //
217 // HAL Variables
218 //
219 #define INITIAL_STALL_COUNT     100
220 #define MM_HAL_VA_START         0xFFC00000
221 #define MM_HAL_VA_END           0xFFFFFFFF
222 #define APIC_BASE               0xFFFE0000
223 
224 //
225 // IOPM Definitions
226 //
227 #define IOPM_COUNT              1
228 #define IOPM_SIZE               8192
229 #define IOPM_FULL_SIZE          8196
230 #define IO_ACCESS_MAP_NONE      0
231 #define IOPM_DIRECTION_MAP_SIZE 32
232 #define IOPM_OFFSET             FIELD_OFFSET(KTSS, IoMaps[0].IoMap)
233 #define KiComputeIopmOffset(MapNumber)              \
234     (MapNumber == IO_ACCESS_MAP_NONE) ?             \
235         (USHORT)(sizeof(KTSS)) :                    \
236         (USHORT)(FIELD_OFFSET(KTSS, IoMaps[MapNumber-1].IoMap))
237 
238 typedef UCHAR KIO_ACCESS_MAP[IOPM_SIZE];
239 
240 typedef KIO_ACCESS_MAP *PKIO_ACCESS_MAP;
241 
242 //
243 // Size of the XMM register save area in the FXSAVE format
244 //
245 #define SIZE_OF_FX_REGISTERS    128
246 
247 //
248 // Static Kernel-Mode Address start (use MM_KSEG0_BASE for actual)
249 //
250 #define KSEG0_BASE              0x80000000
251 
252 //
253 // Synchronization-level IRQL
254 //
255 #ifndef CONFIG_SMP
256 #define SYNCH_LEVEL             DISPATCH_LEVEL
257 #else
258 #if (NTDDI_VERSION < NTDDI_WS03)
259 #define SYNCH_LEVEL             (IPI_LEVEL - 1)
260 #else
261 #define SYNCH_LEVEL             (IPI_LEVEL - 2)
262 #endif
263 #endif
264 
265 //
266 // Double fault stack size
267 //
268 #define DOUBLE_FAULT_STACK_SIZE             0x3000
269 
270 //
271 // Number of pool lookaside lists per pool in the PRCB
272 //
273 #define NUMBER_POOL_LOOKASIDE_LISTS 32
274 
275 //
276 // Structure for CPUID
277 //
278 typedef union _CPU_INFO
279 {
280     UINT32 AsUINT32[4];
281     struct
282     {
283         ULONG Eax;
284         ULONG Ebx;
285         ULONG Ecx;
286         ULONG Edx;
287     };
288 } CPU_INFO, *PCPU_INFO;
289 
290 //
291 // Trap Frame Definition
292 //
293 typedef struct _KTRAP_FRAME
294 {
295     ULONG DbgEbp;
296     ULONG DbgEip;
297     ULONG DbgArgMark;
298     ULONG DbgArgPointer;
299     ULONG TempSegCs;
300     ULONG TempEsp;
301     ULONG Dr0;
302     ULONG Dr1;
303     ULONG Dr2;
304     ULONG Dr3;
305     ULONG Dr6;
306     ULONG Dr7;
307     ULONG SegGs;
308     ULONG SegEs;
309     ULONG SegDs;
310     ULONG Edx;
311     ULONG Ecx;
312     ULONG Eax;
313     ULONG PreviousPreviousMode;
314     struct _EXCEPTION_REGISTRATION_RECORD FAR *ExceptionList;
315     ULONG SegFs;
316     ULONG Edi;
317     ULONG Esi;
318     ULONG Ebx;
319     ULONG Ebp;
320     ULONG ErrCode;
321     ULONG Eip;
322     ULONG SegCs;
323     ULONG EFlags;
324     ULONG HardwareEsp;
325     ULONG HardwareSegSs;
326     ULONG V86Es;
327     ULONG V86Ds;
328     ULONG V86Fs;
329     ULONG V86Gs;
330 } KTRAP_FRAME, *PKTRAP_FRAME;
331 
332 //
333 // Defines the Callback Stack Layout for User Mode Callbacks
334 //
335 typedef struct _KCALLOUT_FRAME
336 {
337     ULONG InitialStack;
338     ULONG TrapFrame;
339     ULONG CallbackStack;
340     ULONG Edi;
341     ULONG Esi;
342     ULONG Ebx;
343     ULONG Ebp;
344     ULONG ReturnAddress;
345     ULONG Result;
346     ULONG ResultLength;
347 } KCALLOUT_FRAME, *PKCALLOUT_FRAME;
348 
349 //
350 // LDT Entry Definition
351 //
352 #ifndef _LDT_ENTRY_DEFINED
353 #define _LDT_ENTRY_DEFINED
354 typedef struct _LDT_ENTRY
355 {
356     USHORT LimitLow;
357     USHORT BaseLow;
358     union
359     {
360         struct
361         {
362             UCHAR BaseMid;
363             UCHAR Flags1;
364             UCHAR Flags2;
365             UCHAR BaseHi;
366         } Bytes;
367         struct
368         {
369             ULONG BaseMid:8;
370             ULONG Type:5;
371             ULONG Dpl:2;
372             ULONG Pres:1;
373             ULONG LimitHi:4;
374             ULONG Sys:1;
375             ULONG Reserved_0:1;
376             ULONG Default_Big:1;
377             ULONG Granularity:1;
378             ULONG BaseHi:8;
379         } Bits;
380     } HighWord;
381 } LDT_ENTRY, *PLDT_ENTRY, *LPLDT_ENTRY;
382 #endif
383 
384 //
385 // GDT Entry Definition
386 //
387 typedef struct _KGDTENTRY
388 {
389     USHORT LimitLow;
390     USHORT BaseLow;
391     union
392     {
393         struct
394         {
395             UCHAR BaseMid;
396             UCHAR Flags1;
397             UCHAR Flags2;
398             UCHAR BaseHi;
399         } Bytes;
400         struct
401         {
402             ULONG BaseMid:8;
403             ULONG Type:5;
404             ULONG Dpl:2;
405             ULONG Pres:1;
406             ULONG LimitHi:4;
407             ULONG Sys:1;
408             ULONG Reserved_0:1;
409             ULONG Default_Big:1;
410             ULONG Granularity:1;
411             ULONG BaseHi:8;
412         } Bits;
413     } HighWord;
414 } KGDTENTRY, *PKGDTENTRY;
415 
416 //
417 // IDT Entry Access Definition
418 //
419 typedef struct _KIDT_ACCESS
420 {
421     union
422     {
423         struct
424         {
425             UCHAR Reserved;
426             UCHAR SegmentType:4;
427             UCHAR SystemSegmentFlag:1;
428             UCHAR Dpl:2;
429             UCHAR Present:1;
430         };
431         USHORT Value;
432     };
433 } KIDT_ACCESS, *PKIDT_ACCESS;
434 
435 //
436 // IDT Entry Definition
437 //
438 typedef struct _KIDTENTRY
439 {
440     USHORT Offset;
441     USHORT Selector;
442     USHORT Access;
443     USHORT ExtendedOffset;
444 } KIDTENTRY, *PKIDTENTRY;
445 
446 typedef struct _DESCRIPTOR
447 {
448     USHORT Pad;
449     USHORT Limit;
450     ULONG Base;
451 } KDESCRIPTOR, *PKDESCRIPTOR;
452 
453 #ifndef NTOS_MODE_USER
454 //
455 // Macro to get current KPRCB
456 //
457 FORCEINLINE
458 struct _KPRCB *
KeGetCurrentPrcb(VOID)459 KeGetCurrentPrcb(VOID)
460 {
461     return (struct _KPRCB *)(ULONG_PTR)__readfsdword(FIELD_OFFSET(KPCR, Prcb));
462 }
463 
464 //
465 // FN/FX (FPU) Save Area Structures
466 //
467 typedef struct _FNSAVE_FORMAT
468 {
469     ULONG ControlWord;
470     ULONG StatusWord;
471     ULONG TagWord;
472     ULONG ErrorOffset;
473     ULONG ErrorSelector;
474     ULONG DataOffset;
475     ULONG DataSelector;
476     UCHAR RegisterArea[80];
477 } FNSAVE_FORMAT, *PFNSAVE_FORMAT;
478 
479 typedef struct _FXSAVE_FORMAT
480 {
481     USHORT ControlWord;
482     USHORT StatusWord;
483     USHORT TagWord;
484     USHORT ErrorOpcode;
485     ULONG ErrorOffset;
486     ULONG ErrorSelector;
487     ULONG DataOffset;
488     ULONG DataSelector;
489     ULONG MXCsr;
490     ULONG MXCsrMask;
491     UCHAR RegisterArea[SIZE_OF_FX_REGISTERS];
492     UCHAR Reserved3[128];
493     UCHAR Reserved4[224];
494     UCHAR Align16Byte[8];
495 } FXSAVE_FORMAT, *PFXSAVE_FORMAT;
496 
497 typedef struct _FX_SAVE_AREA
498 {
499     union
500     {
501         FNSAVE_FORMAT FnArea;
502         FXSAVE_FORMAT FxArea;
503     } U;
504     ULONG NpxSavedCpu;
505     ULONG Cr0NpxState;
506 } FX_SAVE_AREA, *PFX_SAVE_AREA;
507 
508 //
509 // Special Registers Structure (outside of CONTEXT)
510 //
511 typedef struct _KSPECIAL_REGISTERS
512 {
513     ULONG Cr0;
514     ULONG Cr2;
515     ULONG Cr3;
516     ULONG Cr4;
517     ULONG KernelDr0;
518     ULONG KernelDr1;
519     ULONG KernelDr2;
520     ULONG KernelDr3;
521     ULONG KernelDr6;
522     ULONG KernelDr7;
523     KDESCRIPTOR Gdtr;
524     KDESCRIPTOR Idtr;
525     USHORT Tr;
526     USHORT Ldtr;
527     ULONG Reserved[6];
528 } KSPECIAL_REGISTERS, *PKSPECIAL_REGISTERS;
529 
530 //
531 // Processor State Data
532 //
533 typedef struct _KPROCESSOR_STATE
534 {
535     CONTEXT ContextFrame;
536     KSPECIAL_REGISTERS SpecialRegisters;
537 } KPROCESSOR_STATE, *PKPROCESSOR_STATE;
538 
539 //
540 // Processor Region Control Block
541 //
542 #pragma pack(push,4)
543 typedef struct _KPRCB
544 {
545     USHORT MinorVersion;
546     USHORT MajorVersion;
547     struct _KTHREAD *CurrentThread;
548     struct _KTHREAD *NextThread;
549     struct _KTHREAD *IdleThread;
550     UCHAR Number;
551     UCHAR Reserved;
552     USHORT BuildType;
553     KAFFINITY SetMember;
554     UCHAR CpuType;
555     UCHAR CpuID;
556     USHORT CpuStep;
557     KPROCESSOR_STATE ProcessorState;
558     ULONG KernelReserved[16];
559     ULONG HalReserved[16];
560 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
561     ULONG CFlushSize;
562     UCHAR PrcbPad0[88];
563 #else
564     UCHAR PrcbPad0[92];
565 #endif
566     KSPIN_LOCK_QUEUE LockQueue[LockQueueMaximumLock];
567     struct _KTHREAD *NpxThread;
568     ULONG InterruptCount;
569     ULONG KernelTime;
570     ULONG UserTime;
571     ULONG DpcTime;
572     ULONG DebugDpcTime;
573     ULONG InterruptTime;
574     ULONG AdjustDpcThreshold;
575     ULONG PageColor;
576     UCHAR SkipTick;
577     UCHAR DebuggerSavedIRQL;
578 #if (NTDDI_VERSION >= NTDDI_WS03)
579     UCHAR NodeColor;
580 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
581     UCHAR PollSlot;
582 #else
583     UCHAR Spare1;
584 #endif
585     ULONG NodeShiftedColor;
586 #else
587     UCHAR Spare1[6];
588 #endif
589     struct _KNODE *ParentNode;
590     ULONG MultiThreadProcessorSet;
591     struct _KPRCB *MultiThreadSetMaster;
592 #if (NTDDI_VERSION >= NTDDI_WS03)
593     ULONG SecondaryColorMask;
594 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
595     ULONG DpcTimeLimit;
596 #else
597     LONG Sleeping;
598 #endif
599 #else
600     ULONG ThreadStartCount[2];
601 #endif
602     ULONG CcFastReadNoWait;
603     ULONG CcFastReadWait;
604     ULONG CcFastReadNotPossible;
605     ULONG CcCopyReadNoWait;
606     ULONG CcCopyReadWait;
607     ULONG CcCopyReadNoWaitMiss;
608 #if (NTDDI_VERSION < NTDDI_LONGHORN)
609     ULONG KeAlignmentFixupCount;
610 #endif
611     ULONG SpareCounter0;
612 #if (NTDDI_VERSION < NTDDI_LONGHORN)
613     ULONG KeDcacheFlushCount;
614     ULONG KeExceptionDispatchCount;
615     ULONG KeFirstLevelTbFills;
616     ULONG KeFloatingEmulationCount;
617     ULONG KeIcacheFlushCount;
618     ULONG KeSecondLevelTbFills;
619     ULONG KeSystemCalls;
620 #endif
621     volatile ULONG IoReadOperationCount;
622     volatile ULONG IoWriteOperationCount;
623     volatile ULONG IoOtherOperationCount;
624     LARGE_INTEGER IoReadTransferCount;
625     LARGE_INTEGER IoWriteTransferCount;
626     LARGE_INTEGER IoOtherTransferCount;
627 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
628     ULONG CcFastMdlReadNoWait;
629     ULONG CcFastMdlReadWait;
630     ULONG CcFastMdlReadNotPossible;
631     ULONG CcMapDataNoWait;
632     ULONG CcMapDataWait;
633     ULONG CcPinMappedDataCount;
634     ULONG CcPinReadNoWait;
635     ULONG CcPinReadWait;
636     ULONG CcMdlReadNoWait;
637     ULONG CcMdlReadWait;
638     ULONG CcLazyWriteHotSpots;
639     ULONG CcLazyWriteIos;
640     ULONG CcLazyWritePages;
641     ULONG CcDataFlushes;
642     ULONG CcDataPages;
643     ULONG CcLostDelayedWrites;
644     ULONG CcFastReadResourceMiss;
645     ULONG CcCopyReadWaitMiss;
646     ULONG CcFastMdlReadResourceMiss;
647     ULONG CcMapDataNoWaitMiss;
648     ULONG CcMapDataWaitMiss;
649     ULONG CcPinReadNoWaitMiss;
650     ULONG CcPinReadWaitMiss;
651     ULONG CcMdlReadNoWaitMiss;
652     ULONG CcMdlReadWaitMiss;
653     ULONG CcReadAheadIos;
654     ULONG KeAlignmentFixupCount;
655     ULONG KeExceptionDispatchCount;
656     ULONG KeSystemCalls;
657     ULONG PrcbPad1[3];
658 #else
659     ULONG SpareCounter1[8];
660 #endif
661     PP_LOOKASIDE_LIST PPLookasideList[16];
662     PP_LOOKASIDE_LIST PPNPagedLookasideList[NUMBER_POOL_LOOKASIDE_LISTS];
663     PP_LOOKASIDE_LIST PPPagedLookasideList[NUMBER_POOL_LOOKASIDE_LISTS];
664     volatile ULONG PacketBarrier;
665     volatile ULONG ReverseStall;
666     PVOID IpiFrame;
667     UCHAR PrcbPad2[52];
668     volatile PVOID CurrentPacket[3];
669     volatile ULONG TargetSet;
670     volatile PKIPI_WORKER WorkerRoutine;
671     volatile ULONG IpiFrozen;
672     UCHAR PrcbPad3[40];
673     volatile ULONG RequestSummary;
674     volatile struct _KPRCB *SignalDone;
675     UCHAR PrcbPad4[56];
676     struct _KDPC_DATA DpcData[2];
677     PVOID DpcStack;
678     ULONG MaximumDpcQueueDepth;
679     ULONG DpcRequestRate;
680     ULONG MinimumDpcRate;
681     volatile UCHAR DpcInterruptRequested;
682     volatile UCHAR DpcThreadRequested;
683     volatile UCHAR DpcRoutineActive;
684     volatile UCHAR DpcThreadActive;
685     ULONG PrcbLock;
686     ULONG DpcLastCount;
687     volatile ULONG TimerHand;
688     volatile ULONG TimerRequest;
689     PVOID DpcThread;
690     KEVENT DpcEvent;
691     UCHAR ThreadDpcEnable;
692     volatile BOOLEAN QuantumEnd;
693     UCHAR PrcbPad50;
694     volatile UCHAR IdleSchedule;
695     LONG DpcSetEventRequest;
696 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
697     LONG Sleeping;
698     ULONG PeriodicCount;
699     ULONG PeriodicBias;
700     UCHAR PrcbPad5[6];
701 #else
702     UCHAR PrcbPad5[18];
703 #endif
704     LONG TickOffset;
705     KDPC CallDpc;
706 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
707     LONG ClockKeepAlive;
708     UCHAR ClockCheckSlot;
709     UCHAR ClockPollCycle;
710     UCHAR PrcbPad6[2];
711     LONG DpcWatchdogPeriod;
712     LONG DpcWatchDogCount;
713     LONG ThreadWatchdogPeriod;
714     LONG ThreadWatchDogCount;
715     ULONG PrcbPad70[2];
716 #else
717     ULONG PrcbPad7[8];
718 #endif
719     LIST_ENTRY WaitListHead;
720     ULONG ReadySummary;
721     ULONG QueueIndex;
722 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
723     SINGLE_LIST_ENTRY DeferredReadyListHead;
724     ULONGLONG StartCycles;
725     ULONGLONG CycleTime;
726     ULONGLONG PrcbPad71[3];
727     LIST_ENTRY DispatcherReadyListHead[32];
728 #else
729     LIST_ENTRY DispatcherReadyListHead[32];
730     SINGLE_LIST_ENTRY DeferredReadyListHead;
731     ULONG PrcbPad72[11];
732 #endif
733     PVOID ChainedInterruptList;
734     LONG LookasideIrpFloat;
735     volatile LONG MmPageFaultCount;
736     volatile LONG MmCopyOnWriteCount;
737     volatile LONG MmTransitionCount;
738     volatile LONG MmCacheTransitionCount;
739     volatile LONG MmDemandZeroCount;
740     volatile LONG MmPageReadCount;
741     volatile LONG MmPageReadIoCount;
742     volatile LONG MmCacheReadCount;
743     volatile LONG MmCacheIoCount;
744     volatile LONG MmDirtyPagesWriteCount;
745     volatile LONG MmDirtyWriteIoCount;
746     volatile LONG MmMappedPagesWriteCount;
747     volatile LONG MmMappedWriteIoCount;
748 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
749     ULONG CachedCommit;
750     ULONG CachedResidentAvailable;
751     PVOID HyperPte;
752     UCHAR CpuVendor;
753     UCHAR PrcbPad9[3];
754 #else
755     ULONG SpareFields0[1];
756 #endif
757     CHAR VendorString[13];
758     UCHAR InitialApicId;
759     UCHAR LogicalProcessorsPerPhysicalProcessor;
760     ULONG MHz;
761     ULONG FeatureBits;
762     LARGE_INTEGER UpdateSignature;
763     volatile LARGE_INTEGER IsrTime;
764     LARGE_INTEGER SpareField1;
765     FX_SAVE_AREA NpxSaveArea;
766     PROCESSOR_POWER_STATE PowerState;
767 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
768     KDPC DpcWatchdogDoc;
769     KTIMER DpcWatchdogTimer;
770     PVOID WheaInfo;
771     PVOID EtwSupport;
772     SLIST_HEADER InterruptObjectPool;
773     LARGE_INTEGER HyperCallPagePhysical;
774     LARGE_INTEGER HyperCallPageVirtual;
775     PVOID RateControl;
776     CACHE_DESCRIPTOR Cache[5];
777     ULONG CacheCount;
778     ULONG CacheProcessorMask[5];
779     UCHAR LogicalProcessorsPerCore;
780     UCHAR PrcbPad8[3];
781     ULONG PackageProcessorSet;
782     ULONG CoreProcessorSet;
783 #endif
784 } KPRCB, *PKPRCB;
785 
786 //
787 // Processor Control Region
788 //
789 typedef struct _KIPCR
790 {
791     union
792     {
793         NT_TIB NtTib;
794         struct
795         {
796             struct _EXCEPTION_REGISTRATION_RECORD *Used_ExceptionList;
797             PVOID Used_StackBase;
798             PVOID PerfGlobalGroupMask;
799             PVOID TssCopy;
800             ULONG ContextSwitches;
801             KAFFINITY SetMemberCopy;
802             PVOID Used_Self;
803         };
804     };
805     struct _KPCR *SelfPcr;
806     struct _KPRCB *Prcb;
807     KIRQL Irql;
808     ULONG IRR;
809     ULONG IrrActive;
810     ULONG IDR;
811     PVOID KdVersionBlock;
812     PKIDTENTRY IDT;
813     PKGDTENTRY GDT;
814     struct _KTSS *TSS;
815     USHORT MajorVersion;
816     USHORT MinorVersion;
817     KAFFINITY SetMember;
818     ULONG StallScaleFactor;
819     UCHAR SpareUnused;
820     UCHAR Number;
821     UCHAR Spare0;
822     UCHAR SecondLevelCacheAssociativity;
823     ULONG VdmAlert;
824     ULONG KernelReserved[14];
825     ULONG SecondLevelCacheSize;
826     ULONG HalReserved[16];
827     ULONG InterruptMode;
828     UCHAR Spare1;
829     ULONG KernelReserved2[17];
830     KPRCB PrcbData;
831 } KIPCR, *PKIPCR;
832 #pragma pack(pop)
833 
834 //
835 // TSS Definition
836 //
837 typedef struct _KiIoAccessMap
838 {
839     UCHAR DirectionMap[IOPM_DIRECTION_MAP_SIZE];
840     UCHAR IoMap[IOPM_FULL_SIZE];
841 } KIIO_ACCESS_MAP;
842 
843 typedef struct _KTSS
844 {
845     USHORT Backlink;
846     USHORT Reserved0;
847     ULONG Esp0;
848     USHORT Ss0;
849     USHORT Reserved1;
850     ULONG NotUsed1[4];
851     ULONG CR3;
852     ULONG Eip;
853     ULONG EFlags;
854     ULONG Eax;
855     ULONG Ecx;
856     ULONG Edx;
857     ULONG Ebx;
858     ULONG Esp;
859     ULONG Ebp;
860     ULONG Esi;
861     ULONG Edi;
862     USHORT Es;
863     USHORT Reserved2;
864     USHORT Cs;
865     USHORT Reserved3;
866     USHORT Ss;
867     USHORT Reserved4;
868     USHORT Ds;
869     USHORT Reserved5;
870     USHORT Fs;
871     USHORT Reserved6;
872     USHORT Gs;
873     USHORT Reserved7;
874     USHORT LDT;
875     USHORT Reserved8;
876     USHORT Flags;
877     USHORT IoMapBase;
878     KIIO_ACCESS_MAP IoMaps[IOPM_COUNT];
879     UCHAR IntDirectionMap[IOPM_DIRECTION_MAP_SIZE];
880 } KTSS, *PKTSS;
881 
882 //
883 // i386 CPUs don't have exception frames
884 //
885 typedef struct _KEXCEPTION_FRAME KEXCEPTION_FRAME, *PKEXCEPTION_FRAME;
886 
887 #endif /* NTOS_MODE_USER */
888 
889 typedef enum _WOW64_SERVICE_TYPES
890 {
891     ServiceNoTurbo = 0x0000,
892     Service0Arg = 0x0001,
893     Service0ArgReloadState = 0x0002,
894     Service1ArgSp = 0x0003,
895     Service1ArgNSp = 0x0004,
896     Service2ArgNSpNSp = 0x0005,
897     Service2ArgNSpNSpReloadState = 0x0006,
898     Service2ArgSpNSp = 0x0007,
899     Service2ArgSpSp = 0x0008,
900     Service2ArgNSpSp = 0x0009,
901     Service3ArgNSpNSpNSp = 0x000A,
902     Service3ArgSpSpSp = 0x000B,
903     Service3ArgSpNSpNSp = 0x000C,
904     Service3ArgSpNSpNSpReloadState = 0x000D,
905     Service3ArgSpSpNSp = 0x000E,
906     Service3ArgNSpSpNSp = 0x000F,
907     Service3ArgSpNSpSp = 0x0010,
908     Service4ArgNSpNSpNSpNSp = 0x0011,
909     Service4ArgSpSpNSpNSp = 0x0012,
910     Service4ArgSpSpNSpNSpReloadState = 0x0013,
911     Service4ArgSpNSpNSpNSp = 0x0014,
912     Service4ArgSpNSpNSpNSpReloadState = 0x0015,
913     Service4ArgNSpSpNSpNSp = 0x0016,
914     Service4ArgSpSpSpNSp = 0x0017,
915     ServiceCpupTdQuerySystemTime = 0x0018,
916     ServiceCpupTdGetCurrentProcessorNumber = 0x0019,
917     ServiceCpupTdReadWriteFile = 0x001A,
918     ServiceCpupTdDeviceIoControlFile = 0x001B,
919     ServiceCpupTdRemoveIoCompletion = 0x001C,
920     ServiceCpupTdWaitForMultipleObjects = 0x001D,
921     ServiceCpupTdWaitForMultipleObjects32 = 0x001E,
922     Wow64ServiceTypesCount // = 0x001F
923 } WOW64_SERVICE_TYPES, *PWOW64_SERVICE_TYPES;
924 
925 typedef enum _VDM_INDEX
926 {
927     VDM_INDEX_Invalid = 0,
928     VDM_INDEX_0F,
929     VDM_INDEX_ESPrefix,
930     VDM_INDEX_CSPrefix,
931     VDM_INDEX_SSPrefix,
932     VDM_INDEX_DSPrefix,
933     VDM_INDEX_FSPrefix,
934     VDM_INDEX_GSPrefix,
935     VDM_INDEX_OPER32Prefix,
936     VDM_INDEX_ADDR32Prefix,
937     VDM_INDEX_INSB,
938     VDM_INDEX_INSW,
939     VDM_INDEX_OUTSB,
940     VDM_INDEX_OUTSW,
941     VDM_INDEX_PUSHF,
942     VDM_INDEX_POPF,
943     VDM_INDEX_INTnn,
944     VDM_INDEX_INTO,
945     VDM_INDEX_IRET,
946     VDM_INDEX_NPX,
947     VDM_INDEX_INBimm,
948     VDM_INDEX_INWimm,
949     VDM_INDEX_OUTBimm,
950     VDM_INDEX_OUTWimm,
951     VDM_INDEX_INB,
952     VDM_INDEX_INW,
953     VDM_INDEX_OUTB,
954     VDM_INDEX_OUTW,
955     VDM_INDEX_LOCKPrefix,
956     VDM_INDEX_REPNEPrefix,
957     VDM_INDEX_REPPrefix,
958     VDM_INDEX_CLI,
959     VDM_INDEX_STI,
960     VDM_INDEX_HLT,
961     MAX_VDM_INDEX
962 } VDM_INDEX, *PVDM_INDEX;
963 
964 #endif /* _I386_KETYPES_H */
965