[NDK]
[reactos.git] / reactos / include / ndk / amd64 / ketypes.h
1 /*++ NDK Version: 0098
2
3 Copyright (c) Alex Ionescu. All rights reserved.
4 Copyright (c) Timo Kreuzer. All rights reserved.
5
6 Header Name:
7
8 ketypes.h (AMD64)
9
10 Abstract:
11
12 amd64 Type definitions for the Kernel services.
13
14 Author:
15
16 Alex Ionescu (alexi@tinykrnl.org) - Updated - 27-Feb-2006
17 Timo Kreuzer (timo.kreuzer@reactos.org) - Updated - 14-Aug-2008
18
19 --*/
20
21 #ifndef _AMD64_KETYPES_H
22 #define _AMD64_KETYPES_H
23
24 //
25 // Dependencies
26 //
27
28 //
29 // KPCR Access for non-IA64 builds
30 //
31 //#define K0IPCR ((ULONG_PTR)(KIP0PCRADDRESS))
32 //#define PCR ((volatile KPCR * const)K0IPCR)
33 #define PCR ((volatile KPCR * const)__readgsqword(FIELD_OFFSET(KPCR, Self)))
34 //#if defined(CONFIG_SMP) || defined(NT_BUILD)
35 //#undef KeGetPcr
36 //#define KeGetPcr() ((volatile KPCR * const)__readfsdword(0x1C))
37 //#endif
38
39 //
40 // Machine Types
41 //
42 #define MACHINE_TYPE_ISA 0x0000
43 #define MACHINE_TYPE_EISA 0x0001
44 #define MACHINE_TYPE_MCA 0x0002
45
46 //
47 // X86 80386 Segment Types
48 //
49 #define I386_TASK_GATE 0x5
50 #define I386_TSS 0x9
51 #define I386_ACTIVE_TSS 0xB
52 #define I386_CALL_GATE 0xC
53 #define I386_INTERRUPT_GATE 0xE
54 #define I386_TRAP_GATE 0xF
55
56 //
57 // Selector Names
58 //
59 #define RPL_MASK 0x0003
60 #define MODE_MASK 0x0001
61 #define KGDT64_NULL 0x0000
62 #define KGDT64_R0_CODE 0x0010
63 #define KGDT64_R0_DATA 0x0018
64 #define KGDT64_R3_CMCODE 0x0020
65 #define KGDT64_R3_DATA 0x0028
66 #define KGDT64_R3_CODE 0x0030
67 #define KGDT64_SYS_TSS 0x0040
68 #define KGDT64_R3_CMTEB 0x0050
69
70
71 //
72 // CR4
73 //
74 #define CR4_VME 0x1
75 #define CR4_PVI 0x2
76 #define CR4_TSD 0x4
77 #define CR4_DE 0x8
78 #define CR4_PSE 0x10
79 #define CR4_PAE 0x20
80 #define CR4_MCE 0x40
81 #define CR4_PGE 0x80
82 #define CR4_FXSR 0x200
83 #define CR4_XMMEXCPT 0x400
84
85 //
86 // EFlags
87 //
88 #define EFLAGS_CF 0x01L
89 #define EFLAGS_ZF 0x40L
90 #define EFLAGS_TF 0x100L
91 #define EFLAGS_INTERRUPT_MASK 0x200L
92 #define EFLAGS_DF 0x400L
93 #define EFLAGS_NESTED_TASK 0x4000L
94 #define EFLAGS_V86_MASK 0x20000
95 #define EFLAGS_ALIGN_CHECK 0x40000
96 #define EFLAGS_VIF 0x80000
97 #define EFLAGS_VIP 0x100000
98 #define EFLAGS_USER_SANITIZE 0x3F4DD7
99 #define EFLAG_SIGN 0x8000
100 #define EFLAG_ZERO 0x4000
101
102 //
103 // IPI Types
104 //
105 #define IPI_APC 1
106 #define IPI_DPC 2
107 #define IPI_FREEZE 4
108 #define IPI_PACKET_READY 8
109 #define IPI_SYNCH_REQUEST 16
110
111 //
112 // PRCB Flags
113 //
114 #define PRCB_MAJOR_VERSION 1
115 #define PRCB_BUILD_DEBUG 1
116 #define PRCB_BUILD_UNIPROCESSOR 2
117
118 //
119 // HAL Variables
120 //
121 #define INITIAL_STALL_COUNT 100
122
123 //
124 // IOPM Definitions
125 //
126 #define IO_ACCESS_MAP_NONE 0
127 #define IOPM_OFFSET FIELD_OFFSET(KTSS, IoMaps[0].IoMap)
128 #define KiComputeIopmOffset(MapNumber) \
129 (MapNumber == IO_ACCESS_MAP_NONE) ? \
130 (USHORT)(sizeof(KTSS)) : \
131 (USHORT)(FIELD_OFFSET(KTSS, IoMaps[MapNumber-1].IoMap))
132
133 //
134 // Static Kernel-Mode Address start (use MM_KSEG0_BASE for actual)
135 //
136 #define KSEG0_BASE 0xfffff80000000000ULL
137
138 //
139 // Synchronization-level IRQL
140 //
141 #ifndef CONFIG_SMP
142 #define SYNCH_LEVEL DISPATCH_LEVEL
143 #else
144 #define SYNCH_LEVEL (IPI_LEVEL - 2)
145 #endif
146
147 //
148 // Trap Frame Definition
149 //
150 typedef struct _KTRAP_FRAME
151 {
152 UINT64 P1Home;
153 UINT64 P2Home;
154 UINT64 P3Home;
155 UINT64 P4Home;
156 UINT64 P5;
157 CHAR PreviousMode;
158 UCHAR PreviousIrql;
159 UCHAR FaultIndicator;
160 UCHAR ExceptionActive;
161 ULONG MxCsr;
162 UINT64 Rax;
163 UINT64 Rcx;
164 UINT64 Rdx;
165 UINT64 R8;
166 UINT64 R9;
167 UINT64 R10;
168 UINT64 R11;
169 union
170 {
171 UINT64 GsBase;
172 UINT64 GsSwap;
173 };
174 M128A Xmm0;
175 M128A Xmm1;
176 M128A Xmm2;
177 M128A Xmm3;
178 M128A Xmm4;
179 M128A Xmm5;
180 union
181 {
182 UINT64 FaultAddress;
183 UINT64 ContextRecord;
184 UINT64 TimeStampCKCL;
185 };
186 UINT64 Dr0;
187 UINT64 Dr1;
188 UINT64 Dr2;
189 UINT64 Dr3;
190 UINT64 Dr6;
191 UINT64 Dr7;
192 union
193 {
194 struct
195 {
196 UINT64 DebugControl;
197 UINT64 LastBranchToRip;
198 UINT64 LastBranchFromRip;
199 UINT64 LastExceptionToRip;
200 UINT64 LastExceptionFromRip;
201 };
202 struct
203 {
204 UINT64 LastBranchControl;
205 ULONG LastBranchMSR;
206 };
207 };
208 USHORT SegDs;
209 USHORT SegEs;
210 USHORT SegFs;
211 USHORT SegGs;
212 UINT64 TrapFrame;
213 UINT64 Rbx;
214 UINT64 Rdi;
215 UINT64 Rsi;
216 UINT64 Rbp;
217 union
218 {
219 UINT64 ErrorCode;
220 UINT64 ExceptionFrame;
221 UINT64 TimeStampKlog;
222 };
223 UINT64 Rip;
224 USHORT SegCs;
225 UCHAR Fill0;
226 UCHAR Logging;
227 USHORT Fill1[2];
228 ULONG EFlags;
229 ULONG Fill2;
230 UINT64 Rsp;
231 USHORT SegSs;
232 USHORT Fill3;
233 LONG CodePatchCycle;
234 } KTRAP_FRAME, *PKTRAP_FRAME;
235
236 //
237 // Defines the Callback Stack Layout for User Mode Callbacks
238 //
239 typedef struct _KCALLOUT_FRAME
240 {
241 ULONG64 InitialStack;
242 ULONG64 TrapFrame;
243 ULONG64 CallbackStack;
244 ULONG64 Rdi;
245 ULONG64 Rsi;
246 ULONG64 Rbx;
247 ULONG64 Rbp;
248 ULONG64 ReturnAddress;
249 ULONG64 Result;
250 ULONG64 ResultLength;
251 } KCALLOUT_FRAME, *PKCALLOUT_FRAME;
252
253 //
254 // Dummy LDT_ENTRY
255 //
256 typedef ULONG LDT_ENTRY;
257
258 //
259 // GDT Entry Definition
260 //
261 typedef union _KGDTENTRY64
262 {
263 struct
264 {
265 USHORT LimitLow;
266 USHORT BaseLow;
267 union
268 {
269 struct
270 {
271 UCHAR BaseMiddle;
272 UCHAR Flags1;
273 UCHAR Flags2;
274 UCHAR BaseHigh;
275 } Bytes;
276 struct
277 {
278 ULONG BaseMiddle:8;
279 ULONG Type:5;
280 ULONG Dpl:2;
281 ULONG Present:1;
282 ULONG LimitHigh:4;
283 ULONG System:1;
284 ULONG LongMode:1;
285 ULONG DefaultBig:1;
286 ULONG Granularity:1;
287 ULONG BaseHigh:8;
288 } Bits;
289 };
290 ULONG BaseUpper;
291 ULONG MustBeZero;
292 };
293 UINT64 Alignment;
294 } KGDTENTRY64, *PKGDTENTRY64;
295 #define KGDTENTRY KGDTENTRY64
296 #define PKGDTENTRY PKGDTENTRY64
297
298 //
299 // IDT Entry Access Definition
300 //
301 typedef struct _KIDT_ACCESS
302 {
303 union
304 {
305 struct
306 {
307 UCHAR Reserved;
308 UCHAR SegmentType:4;
309 UCHAR SystemSegmentFlag:1;
310 UCHAR Dpl:2;
311 UCHAR Present:1;
312 };
313 USHORT Value;
314 };
315 } KIDT_ACCESS, *PKIDT_ACCESS;
316
317 //
318 // IDT Entry Definition
319 //
320 typedef union _KIDTENTRY64
321 {
322 struct
323 {
324 USHORT OffsetLow;
325 USHORT Selector;
326 USHORT IstIndex:3;
327 USHORT Reserved0:5;
328 USHORT Type:5;
329 USHORT Dpl:2;
330 USHORT Present:1;
331 USHORT OffsetMiddle;
332 ULONG OffsetHigh;
333 ULONG Reserved1;
334 };
335 UINT64 Alignment;
336 } KIDTENTRY64, *PKIDTENTRY64;
337 #define KIDTENTRY KIDTENTRY64
338 #define PKIDTENTRY PKIDTENTRY64
339
340 typedef struct _KDESCRIPTOR
341 {
342 USHORT Pad[3];
343 USHORT Limit;
344 PVOID Base;
345 } KDESCRIPTOR, *PKDESCRIPTOR;
346
347 #ifndef NTOS_MODE_USER
348
349 //
350 // Special Registers Structure (outside of CONTEXT)
351 //
352 typedef struct _KSPECIAL_REGISTERS
353 {
354 UINT64 Cr0;
355 UINT64 Cr2;
356 UINT64 Cr3;
357 UINT64 Cr4;
358 UINT64 KernelDr0;
359 UINT64 KernelDr1;
360 UINT64 KernelDr2;
361 UINT64 KernelDr3;
362 UINT64 KernelDr6;
363 UINT64 KernelDr7;
364 struct _KDESCRIPTOR Gdtr;
365 struct _KDESCRIPTOR Idtr;
366 USHORT Tr;
367 USHORT Ldtr;
368 ULONG MxCsr;
369 UINT64 DebugControl;
370 UINT64 LastBranchToRip;
371 UINT64 LastBranchFromRip;
372 UINT64 LastExceptionToRip;
373 UINT64 LastExceptionFromRip;
374 UINT64 Cr8;
375 UINT64 MsrGsBase;
376 UINT64 MsrGsSwap;
377 UINT64 MsrStar;
378 UINT64 MsrLStar;
379 UINT64 MsrCStar;
380 UINT64 MsrSyscallMask;
381 } KSPECIAL_REGISTERS, *PKSPECIAL_REGISTERS;
382
383 //
384 // Processor State Data
385 //
386 typedef struct _KPROCESSOR_STATE
387 {
388 KSPECIAL_REGISTERS SpecialRegisters;
389 CONTEXT ContextFrame;
390 } KPROCESSOR_STATE, *PKPROCESSOR_STATE;
391
392 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
393 typedef struct _GENERAL_LOOKASIDE_POOL
394 {
395 union
396 {
397 SLIST_HEADER ListHead;
398 SINGLE_LIST_ENTRY SingleListHead;
399 };
400 USHORT Depth;
401 USHORT MaximumDepth;
402 ULONG TotalAllocates;
403 union
404 {
405 ULONG AllocateMisses;
406 ULONG AllocateHits;
407 };
408 union
409 {
410 ULONG TotalFrees;
411 ULONG FreeMisses;
412 };
413 ULONG FreeHits;
414 POOL_TYPE Type;
415 ULONG Tag;
416 ULONG Size;
417 union
418 {
419 PVOID AllocateEx;
420 PVOID Allocate;
421 };
422 union
423 {
424 PVOID FreeEx;
425 PVOID Free;
426 };
427 LIST_ENTRY ListEntry;
428 ULONG LastTotalAllocates;
429 union
430 {
431 ULONG LastAllocateMisses;
432 ULONG LastAllocateHits;
433 };
434 ULONG Future[2];
435 } GENERAL_LOOKASIDE_POOL, *PGENERAL_LOOKASIDE_POOL;
436 #else
437 #define GENERAL_LOOKASIDE_POOL PP_LOOKASIDE_LIST
438 #endif
439
440 typedef struct _KREQUEST_PACKET
441 {
442 PVOID CurrentPacket[3];
443 PVOID WorkerRoutine;
444 } KREQUEST_PACKET, *PKREQUEST_PACKET;
445
446 typedef struct _REQUEST_MAILBOX
447 {
448 INT64 RequestSummary;
449 KREQUEST_PACKET RequestPacket;
450 PVOID Virtual[7];
451 } REQUEST_MAILBOX, *PREQUEST_MAILBOX;
452
453 //
454 // Processor Region Control Block
455 //
456 #pragma pack(push,4)
457 typedef struct _KPRCB
458 {
459 ULONG MxCsr;
460 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
461 USHORT Number;
462 #else
463 UCHAR Number;
464 UCHAR NestingLevel;
465 #endif
466 UCHAR InterruptRequest;
467 UCHAR IdleHalt;
468 struct _KTHREAD *CurrentThread;
469 struct _KTHREAD *NextThread;
470 struct _KTHREAD *IdleThread;
471 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
472 UCHAR NestingLevel;
473 UCHAR Group;
474 UCHAR PrcbPad00[6];
475 #else
476 UINT64 UserRsp;
477 #endif
478 UINT64 RspBase;
479 UINT64 PrcbLock;
480 UINT64 SetMember;
481 KPROCESSOR_STATE ProcessorState;
482 CHAR CpuType;
483 CHAR CpuID;
484 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
485 union
486 {
487 USHORT CpuStep;
488 struct
489 {
490 UCHAR CpuStepping;
491 UCHAR CpuModel;
492 };
493 };
494 #else
495 USHORT CpuStep;
496 #endif
497 ULONG MHz;
498 UINT64 HalReserved[8];
499 USHORT MinorVersion;
500 USHORT MajorVersion;
501 UCHAR BuildType;
502 UCHAR CpuVendor;
503 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
504 UCHAR CoresPerPhysicalProcessor;
505 UCHAR LogicalProcessorsPerCore;
506 #else
507 UCHAR InitialApicId;
508 UCHAR LogicalProcessorsPerPhysicalProcessor;
509 #endif
510 ULONG ApicMask;
511 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
512 ULONG CFlushSize;
513 #else
514 UCHAR CFlushSize;
515 UCHAR PrcbPad0x[3];
516 #endif
517 PVOID AcpiReserved;
518 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
519 ULONG InitialApicId;
520 ULONG Stride;
521 UINT64 PrcbPad01[3];
522 #else
523 UINT64 PrcbPad00[4];
524 #endif
525 KSPIN_LOCK_QUEUE LockQueue[LockQueueMaximumLock]; // 2003: 33, vista:49
526 PP_LOOKASIDE_LIST PPLookasideList[16];
527 GENERAL_LOOKASIDE_POOL PPNPagedLookasideList[32];
528 GENERAL_LOOKASIDE_POOL PPPagedLookasideList[32];
529 UINT64 PacketBarrier;
530 SINGLE_LIST_ENTRY DeferredReadyListHead;
531 LONG MmPageFaultCount;
532 LONG MmCopyOnWriteCount;
533 LONG MmTransitionCount;
534 #if (NTDDI_VERSION < NTDDI_LONGHORN)
535 LONG MmCacheTransitionCount;
536 #endif
537 LONG MmDemandZeroCount;
538 LONG MmPageReadCount;
539 LONG MmPageReadIoCount;
540 #if (NTDDI_VERSION < NTDDI_LONGHORN)
541 LONG MmCacheReadCount;
542 LONG MmCacheIoCount;
543 #endif
544 LONG MmDirtyPagesWriteCount;
545 LONG MmDirtyWriteIoCount;
546 LONG MmMappedPagesWriteCount;
547 LONG MmMappedWriteIoCount;
548 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
549 ULONG KeSystemCalls;
550 ULONG KeContextSwitches;
551 ULONG CcFastReadNoWait;
552 ULONG CcFastReadWait;
553 ULONG CcFastReadNotPossible;
554 ULONG CcCopyReadNoWait;
555 ULONG CcCopyReadWait;
556 ULONG CcCopyReadNoWaitMiss;
557 LONG LookasideIrpFloat;
558 #else
559 LONG LookasideIrpFloat;
560 ULONG KeSystemCalls;
561 #endif
562 LONG IoReadOperationCount;
563 LONG IoWriteOperationCount;
564 LONG IoOtherOperationCount;
565 LARGE_INTEGER IoReadTransferCount;
566 LARGE_INTEGER IoWriteTransferCount;
567 LARGE_INTEGER IoOtherTransferCount;
568 #if (NTDDI_VERSION < NTDDI_LONGHORN)
569 ULONG KeContextSwitches;
570 UCHAR PrcbPad2[12];
571 #endif
572 UINT64 TargetSet;
573 ULONG IpiFrozen;
574 UCHAR PrcbPad3[116];
575 REQUEST_MAILBOX RequestMailbox[64];
576 UINT64 SenderSummary;
577 UCHAR PrcbPad4[120];
578 KDPC_DATA DpcData[2];
579 PVOID DpcStack;
580 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
581 PVOID SparePtr0;
582 #else
583 PVOID SavedRsp;
584 #endif
585 LONG MaximumDpcQueueDepth;
586 ULONG DpcRequestRate;
587 ULONG MinimumDpcRate;
588 UCHAR DpcInterruptRequested;
589 UCHAR DpcThreadRequested;
590 UCHAR DpcRoutineActive;
591 UCHAR DpcThreadActive;
592 UINT64 TimerHand;
593 UINT64 TimerRequest;
594 LONG TickOffset;
595 LONG MasterOffset;
596 ULONG DpcLastCount;
597 UCHAR ThreadDpcEnable;
598 UCHAR QuantumEnd;
599 UCHAR PrcbPad50;
600 UCHAR IdleSchedule;
601 LONG DpcSetEventRequest;
602 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
603 ULONG KeExceptionDispatchCount;
604 #else
605 LONG PrcbPad40;
606 PVOID DpcThread;
607 #endif
608 KEVENT DpcEvent;
609 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
610 PVOID PrcbPad51;
611 #endif
612 KDPC CallDpc;
613 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
614 LONG ClockKeepAlive;
615 UCHAR ClockCheckSlot;
616 UCHAR ClockPollCycle;
617 UCHAR PrcbPad6[2];
618 LONG DpcWatchdogPeriod;
619 LONG DpcWatchdogCount;
620 UINT64 PrcbPad70[2];
621 #else
622 UINT64 PrcbPad7[4];
623 #endif
624 LIST_ENTRY WaitListHead;
625 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
626 UINT64 WaitLock;
627 #endif
628 ULONG ReadySummary;
629 ULONG QueueIndex;
630 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
631 UINT64 PrcbPad71[12];
632 #endif
633 LIST_ENTRY DispatcherReadyListHead[32];
634 ULONG InterruptCount;
635 ULONG KernelTime;
636 ULONG UserTime;
637 ULONG DpcTime;
638 ULONG InterruptTime;
639 ULONG AdjustDpcThreshold;
640 UCHAR SkipTick;
641 UCHAR DebuggerSavedIRQL;
642 UCHAR PollSlot;
643 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
644 UCHAR PrcbPad80[5];
645 ULONG DpcTimeCount;
646 ULONG DpcTimeLimit;
647 ULONG PeriodicCount;
648 ULONG PeriodicBias;
649 UINT64 PrcbPad81[2];
650 #else
651 UCHAR PrcbPad8[13];
652 #endif
653 struct _KNODE *ParentNode;
654 UINT64 MultiThreadProcessorSet;
655 struct _KPRCB *MultiThreadSetMaster;
656 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
657 UINT64 StartCycles;
658 LONG MmSpinLockOrdering;
659 ULONG PageColor;
660 ULONG NodeColor;
661 ULONG NodeShiftedColor;
662 ULONG SecondaryColorMask;
663 #endif
664 LONG Sleeping;
665 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
666 UINT64 CycleTime;
667 ULONG CcFastMdlReadNoWait;
668 ULONG CcFastMdlReadWait;
669 ULONG CcFastMdlReadNotPossible;
670 ULONG CcMapDataNoWait;
671 ULONG CcMapDataWait;
672 ULONG CcPinMappedDataCount;
673 ULONG CcPinReadNoWait;
674 ULONG CcPinReadWait;
675 ULONG CcMdlReadNoWait;
676 ULONG CcMdlReadWait;
677 ULONG CcLazyWriteHotSpots;
678 ULONG CcLazyWriteIos;
679 ULONG CcLazyWritePages;
680 ULONG CcDataFlushes;
681 ULONG CcDataPages;
682 ULONG CcLostDelayedWrites;
683 ULONG CcFastReadResourceMiss;
684 ULONG CcCopyReadWaitMiss;
685 ULONG CcFastMdlReadResourceMiss;
686 ULONG CcMapDataNoWaitMiss;
687 ULONG CcMapDataWaitMiss;
688 ULONG CcPinReadNoWaitMiss;
689 ULONG CcPinReadWaitMiss;
690 ULONG CcMdlReadNoWaitMiss;
691 ULONG CcMdlReadWaitMiss;
692 ULONG CcReadAheadIos;
693 LONG MmCacheTransitionCount;
694 LONG MmCacheReadCount;
695 LONG MmCacheIoCount;
696 ULONG PrcbPad91[3];
697 PROCESSOR_POWER_STATE PowerState;
698 ULONG KeAlignmentFixupCount;
699 UCHAR VendorString[13];
700 UCHAR PrcbPad10[3];
701 ULONG FeatureBits;
702 LARGE_INTEGER UpdateSignature;
703 KDPC DpcWatchdogDpc;
704 KTIMER DpcWatchdogTimer;
705 CACHE_DESCRIPTOR Cache[5];
706 ULONG CacheCount;
707 ULONG CachedCommit;
708 ULONG CachedResidentAvailable;
709 PVOID HyperPte;
710 PVOID WheaInfo;
711 PVOID EtwSupport;
712 SLIST_HEADER InterruptObjectPool;
713 SLIST_HEADER HypercallPageList;
714 PVOID HypercallPageVirtual;
715 PVOID VirtualApicAssist;
716 UINT64* StatisticsPage;
717 PVOID RateControl;
718 UINT64 CacheProcessorMask[5];
719 UINT64 PackageProcessorSet;
720 UINT64 CoreProcessorSet;
721 #else
722 ULONG PrcbPad90[1];
723 ULONG DebugDpcTime;
724 ULONG PageColor;
725 ULONG NodeColor;
726 ULONG NodeShiftedColor;
727 ULONG SecondaryColorMask;
728 UCHAR PrcbPad9[12];
729 ULONG CcFastReadNoWait;
730 ULONG CcFastReadWait;
731 ULONG CcFastReadNotPossible;
732 ULONG CcCopyReadNoWait;
733 ULONG CcCopyReadWait;
734 ULONG CcCopyReadNoWaitMiss;
735 ULONG KeAlignmentFixupCount;
736 ULONG KeDcacheFlushCount;
737 ULONG KeExceptionDispatchCount;
738 ULONG KeFirstLevelTbFills;
739 ULONG KeFloatingEmulationCount;
740 ULONG KeIcacheFlushCount;
741 ULONG KeSecondLevelTbFills;
742 UCHAR VendorString[13];
743 UCHAR PrcbPad10[2];
744 ULONG FeatureBits;
745 LARGE_INTEGER UpdateSignature;
746 PROCESSOR_POWER_STATE PowerState;
747 CACHE_DESCRIPTOR Cache[5];
748 ULONG CacheCount;
749 #endif
750 }
751 KPRCB, *PKPRCB;
752
753 //
754 // Processor Control Region
755 //
756 typedef struct _KIPCR
757 {
758 union
759 {
760 NT_TIB NtTib;
761 struct
762 {
763 union _KGDTENTRY64 *GdtBase;
764 struct _KTSS64 *TssBase;
765 ULONG64 UserRsp;
766 struct _KPCR *Self;
767 struct _KPRCB *CurrentPrcb;
768 PKSPIN_LOCK_QUEUE LockArray;
769 PVOID Used_Self;
770 };
771 };
772 union _KIDTENTRY64 *IdtBase;
773 ULONG64 Unused[2];
774 KIRQL Irql;
775 UCHAR SecondLevelCacheAssociativity;
776 UCHAR ObsoleteNumber;
777 UCHAR Fill0;
778 ULONG Unused0[3];
779 USHORT MajorVersion;
780 USHORT MinorVersion;
781 ULONG StallScaleFactor;
782 PVOID Unused1[3];
783 ULONG KernelReserved[15];
784 ULONG SecondLevelCacheSize;
785 ULONG HalReserved[16];
786 ULONG Unused2;
787 ULONG Fill1;
788 PVOID KdVersionBlock; // 0x108
789 PVOID Unused3;
790 ULONG PcrAlign1[24];
791 ULONG Fill2[2]; // 0x178
792 KPRCB Prcb; // 0x180
793
794 // hack:
795 ULONG ContextSwitches;
796
797 } KIPCR, *PKIPCR;
798 #pragma pack(pop)
799
800 //
801 // TSS Definition
802 //
803 typedef struct _KiIoAccessMap
804 {
805 UCHAR DirectionMap[32];
806 UCHAR IoMap[8196];
807 } KIIO_ACCESS_MAP;
808
809
810 #pragma pack(push,4)
811 typedef struct _KTSS64
812 {
813 /* 000 */ ULONG Reserved0;
814 /* 004 */ UINT64 Rsp0;
815 /* 00c */ UINT64 Rsp1;
816 /* 014 */ UINT64 Rsp2;
817 /* 01c */ UINT64 Ist[8];
818 /* 05c */ UINT64 Reserved1;
819 /* 064 */ USHORT Reserved2;
820 /* 066 */ USHORT IoMapBase;
821 } KTSS64, *PKTSS64;
822 #pragma pack(pop)
823 #define KTSS KTSS64
824 #define PKTSS PKTSS64
825
826 //
827 // i386 CPUs don't have exception frames
828 //
829 typedef struct _KEXCEPTION_FRAME KEXCEPTION_FRAME, *PKEXCEPTION_FRAME;
830
831 //
832 // Inline function to get current KPRCB
833 //
834 FORCEINLINE
835 struct _KPRCB *
836 KeGetCurrentPrcb(VOID)
837 {
838 return (struct _KPRCB *)__readgsqword(FIELD_OFFSET(KIPCR, CurrentPrcb));
839 }
840
841 #endif
842 #endif