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