03ee79c4be044fdfc20dd536415bbedc255555f8
[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 // Dummy LDT_ENTRY
236 //
237 typedef ULONG LDT_ENTRY;
238
239 //
240 // GDT Entry Definition
241 //
242 typedef union _KGDTENTRY64
243 {
244 struct
245 {
246 USHORT LimitLow;
247 USHORT BaseLow;
248 union
249 {
250 struct
251 {
252 UCHAR BaseMiddle;
253 UCHAR Flags1;
254 UCHAR Flags2;
255 UCHAR BaseHigh;
256 } Bytes;
257 struct
258 {
259 ULONG BaseMiddle:8;
260 ULONG Type:5;
261 ULONG Dpl:2;
262 ULONG Present:1;
263 ULONG LimitHigh:4;
264 ULONG System:1;
265 ULONG LongMode:1;
266 ULONG DefaultBig:1;
267 ULONG Granularity:1;
268 ULONG BaseHigh:8;
269 } Bits;
270 };
271 ULONG BaseUpper;
272 ULONG MustBeZero;
273 };
274 UINT64 Alignment;
275 } KGDTENTRY64, *PKGDTENTRY64;
276 #define KGDTENTRY KGDTENTRY64
277 #define PKGDTENTRY PKGDTENTRY64
278
279 //
280 // IDT Entry Access Definition
281 //
282 typedef struct _KIDT_ACCESS
283 {
284 union
285 {
286 struct
287 {
288 UCHAR Reserved;
289 UCHAR SegmentType:4;
290 UCHAR SystemSegmentFlag:1;
291 UCHAR Dpl:2;
292 UCHAR Present:1;
293 };
294 USHORT Value;
295 };
296 } KIDT_ACCESS, *PKIDT_ACCESS;
297
298 //
299 // IDT Entry Definition
300 //
301 typedef union _KIDTENTRY64
302 {
303 struct
304 {
305 USHORT OffsetLow;
306 USHORT Selector;
307 USHORT IstIndex:3;
308 USHORT Reserved0:5;
309 USHORT Type:5;
310 USHORT Dpl:2;
311 USHORT Present:1;
312 USHORT OffsetMiddle;
313 ULONG OffsetHigh;
314 ULONG Reserved1;
315 };
316 UINT64 Alignment;
317 } KIDTENTRY64, *PKIDTENTRY64;
318 #define KIDTENTRY KIDTENTRY64
319 #define PKIDTENTRY PKIDTENTRY64
320
321 typedef struct _KDESCRIPTOR
322 {
323 USHORT Pad[3];
324 USHORT Limit;
325 PVOID Base;
326 } KDESCRIPTOR, *PKDESCRIPTOR;
327
328 #ifndef NTOS_MODE_USER
329
330 //
331 // Special Registers Structure (outside of CONTEXT)
332 //
333 typedef struct _KSPECIAL_REGISTERS
334 {
335 UINT64 Cr0;
336 UINT64 Cr2;
337 UINT64 Cr3;
338 UINT64 Cr4;
339 UINT64 KernelDr0;
340 UINT64 KernelDr1;
341 UINT64 KernelDr2;
342 UINT64 KernelDr3;
343 UINT64 KernelDr6;
344 UINT64 KernelDr7;
345 struct _KDESCRIPTOR Gdtr;
346 struct _KDESCRIPTOR Idtr;
347 USHORT Tr;
348 USHORT Ldtr;
349 ULONG MxCsr;
350 UINT64 DebugControl;
351 UINT64 LastBranchToRip;
352 UINT64 LastBranchFromRip;
353 UINT64 LastExceptionToRip;
354 UINT64 LastExceptionFromRip;
355 UINT64 Cr8;
356 UINT64 MsrGsBase;
357 UINT64 MsrGsSwap;
358 UINT64 MsrStar;
359 UINT64 MsrLStar;
360 UINT64 MsrCStar;
361 UINT64 MsrSyscallMask;
362 } KSPECIAL_REGISTERS, *PKSPECIAL_REGISTERS;
363
364 //
365 // Processor State Data
366 //
367 typedef struct _KPROCESSOR_STATE
368 {
369 KSPECIAL_REGISTERS SpecialRegisters;
370 CONTEXT ContextFrame;
371 } KPROCESSOR_STATE, *PKPROCESSOR_STATE;
372
373 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
374 typedef struct _GENERAL_LOOKASIDE_POOL
375 {
376 union
377 {
378 SLIST_HEADER ListHead;
379 SINGLE_LIST_ENTRY SingleListHead;
380 };
381 USHORT Depth;
382 USHORT MaximumDepth;
383 ULONG TotalAllocates;
384 union
385 {
386 ULONG AllocateMisses;
387 ULONG AllocateHits;
388 };
389 union
390 {
391 ULONG TotalFrees;
392 ULONG FreeMisses;
393 };
394 ULONG FreeHits;
395 POOL_TYPE Type;
396 ULONG Tag;
397 ULONG Size;
398 union
399 {
400 PVOID AllocateEx;
401 PVOID Allocate;
402 };
403 union
404 {
405 PVOID FreeEx;
406 PVOID Free;
407 };
408 LIST_ENTRY ListEntry;
409 ULONG LastTotalAllocates;
410 union
411 {
412 ULONG LastAllocateMisses;
413 ULONG LastAllocateHits;
414 };
415 ULONG Future[2];
416 } GENERAL_LOOKASIDE_POOL, *PGENERAL_LOOKASIDE_POOL;
417 #else
418 #define GENERAL_LOOKASIDE_POOL PP_LOOKASIDE_LIST
419 #endif
420
421 typedef struct _KREQUEST_PACKET
422 {
423 PVOID CurrentPacket[3];
424 PVOID WorkerRoutine;
425 } KREQUEST_PACKET, *PKREQUEST_PACKET;
426
427 typedef struct _REQUEST_MAILBOX
428 {
429 INT64 RequestSummary;
430 KREQUEST_PACKET RequestPacket;
431 PVOID Virtual[7];
432 } REQUEST_MAILBOX, *PREQUEST_MAILBOX;
433
434 //
435 // Processor Region Control Block
436 //
437 #pragma pack(push,4)
438 typedef struct _KPRCB
439 {
440 ULONG MxCsr;
441 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
442 USHORT Number;
443 #else
444 UCHAR Number;
445 UCHAR NestingLevel;
446 #endif
447 UCHAR InterruptRequest;
448 UCHAR IdleHalt;
449 struct _KTHREAD *CurrentThread;
450 struct _KTHREAD *NextThread;
451 struct _KTHREAD *IdleThread;
452 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
453 UCHAR NestingLevel;
454 UCHAR Group;
455 UCHAR PrcbPad00[6];
456 #else
457 UINT64 UserRsp;
458 #endif
459 UINT64 RspBase;
460 UINT64 PrcbLock;
461 UINT64 SetMember;
462 KPROCESSOR_STATE ProcessorState;
463 CHAR CpuType;
464 CHAR CpuID;
465 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
466 union
467 {
468 USHORT CpuStep;
469 struct
470 {
471 UCHAR CpuStepping;
472 UCHAR CpuModel;
473 };
474 };
475 #else
476 USHORT CpuStep;
477 #endif
478 ULONG MHz;
479 UINT64 HalReserved[8];
480 USHORT MinorVersion;
481 USHORT MajorVersion;
482 UCHAR BuildType;
483 UCHAR CpuVendor;
484 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
485 UCHAR CoresPerPhysicalProcessor;
486 UCHAR LogicalProcessorsPerCore;
487 #else
488 UCHAR InitialApicId;
489 UCHAR LogicalProcessorsPerPhysicalProcessor;
490 #endif
491 ULONG ApicMask;
492 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
493 ULONG CFlushSize;
494 #else
495 UCHAR CFlushSize;
496 UCHAR PrcbPad0x[3];
497 #endif
498 PVOID AcpiReserved;
499 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
500 ULONG InitialApicId;
501 ULONG Stride;
502 UINT64 PrcbPad01[3];
503 #else
504 UINT64 PrcbPad00[4];
505 #endif
506 KSPIN_LOCK_QUEUE LockQueue[LockQueueMaximumLock]; // 2003: 33, vista:49
507 PP_LOOKASIDE_LIST PPLookasideList[16];
508 GENERAL_LOOKASIDE_POOL PPNPagedLookasideList[32];
509 GENERAL_LOOKASIDE_POOL PPPagedLookasideList[32];
510 UINT64 PacketBarrier;
511 SINGLE_LIST_ENTRY DeferredReadyListHead;
512 LONG MmPageFaultCount;
513 LONG MmCopyOnWriteCount;
514 LONG MmTransitionCount;
515 #if (NTDDI_VERSION < NTDDI_LONGHORN)
516 LONG MmCacheTransitionCount;
517 #endif
518 LONG MmDemandZeroCount;
519 LONG MmPageReadCount;
520 LONG MmPageReadIoCount;
521 #if (NTDDI_VERSION < NTDDI_LONGHORN)
522 LONG MmCacheReadCount;
523 LONG MmCacheIoCount;
524 #endif
525 LONG MmDirtyPagesWriteCount;
526 LONG MmDirtyWriteIoCount;
527 LONG MmMappedPagesWriteCount;
528 LONG MmMappedWriteIoCount;
529 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
530 ULONG KeSystemCalls;
531 ULONG KeContextSwitches;
532 ULONG CcFastReadNoWait;
533 ULONG CcFastReadWait;
534 ULONG CcFastReadNotPossible;
535 ULONG CcCopyReadNoWait;
536 ULONG CcCopyReadWait;
537 ULONG CcCopyReadNoWaitMiss;
538 LONG LookasideIrpFloat;
539 #else
540 LONG LookasideIrpFloat;
541 ULONG KeSystemCalls;
542 #endif
543 LONG IoReadOperationCount;
544 LONG IoWriteOperationCount;
545 LONG IoOtherOperationCount;
546 LARGE_INTEGER IoReadTransferCount;
547 LARGE_INTEGER IoWriteTransferCount;
548 LARGE_INTEGER IoOtherTransferCount;
549 #if (NTDDI_VERSION < NTDDI_LONGHORN)
550 ULONG KeContextSwitches;
551 UCHAR PrcbPad2[12];
552 #endif
553 UINT64 TargetSet;
554 ULONG IpiFrozen;
555 UCHAR PrcbPad3[116];
556 REQUEST_MAILBOX RequestMailbox[64];
557 UINT64 SenderSummary;
558 UCHAR PrcbPad4[120];
559 KDPC_DATA DpcData[2];
560 PVOID DpcStack;
561 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
562 PVOID SparePtr0;
563 #else
564 PVOID SavedRsp;
565 #endif
566 LONG MaximumDpcQueueDepth;
567 ULONG DpcRequestRate;
568 ULONG MinimumDpcRate;
569 UCHAR DpcInterruptRequested;
570 UCHAR DpcThreadRequested;
571 UCHAR DpcRoutineActive;
572 UCHAR DpcThreadActive;
573 UINT64 TimerHand;
574 UINT64 TimerRequest;
575 LONG TickOffset;
576 LONG MasterOffset;
577 ULONG DpcLastCount;
578 UCHAR ThreadDpcEnable;
579 UCHAR QuantumEnd;
580 UCHAR PrcbPad50;
581 UCHAR IdleSchedule;
582 LONG DpcSetEventRequest;
583 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
584 ULONG KeExceptionDispatchCount;
585 #else
586 LONG PrcbPad40;
587 PVOID DpcThread;
588 #endif
589 KEVENT DpcEvent;
590 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
591 PVOID PrcbPad51;
592 #endif
593 KDPC CallDpc;
594 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
595 LONG ClockKeepAlive;
596 UCHAR ClockCheckSlot;
597 UCHAR ClockPollCycle;
598 UCHAR PrcbPad6[2];
599 LONG DpcWatchdogPeriod;
600 LONG DpcWatchdogCount;
601 UINT64 PrcbPad70[2];
602 #else
603 UINT64 PrcbPad7[4];
604 #endif
605 LIST_ENTRY WaitListHead;
606 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
607 UINT64 WaitLock;
608 #endif
609 ULONG ReadySummary;
610 ULONG QueueIndex;
611 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
612 UINT64 PrcbPad71[12];
613 #endif
614 LIST_ENTRY DispatcherReadyListHead[32];
615 ULONG InterruptCount;
616 ULONG KernelTime;
617 ULONG UserTime;
618 ULONG DpcTime;
619 ULONG InterruptTime;
620 ULONG AdjustDpcThreshold;
621 UCHAR SkipTick;
622 UCHAR DebuggerSavedIRQL;
623 UCHAR PollSlot;
624 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
625 UCHAR PrcbPad80[5];
626 ULONG DpcTimeCount;
627 ULONG DpcTimeLimit;
628 ULONG PeriodicCount;
629 ULONG PeriodicBias;
630 UINT64 PrcbPad81[2];
631 #else
632 UCHAR PrcbPad8[13];
633 #endif
634 struct _KNODE *ParentNode;
635 UINT64 MultiThreadProcessorSet;
636 struct _KPRCB *MultiThreadSetMaster;
637 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
638 UINT64 StartCycles;
639 LONG MmSpinLockOrdering;
640 ULONG PageColor;
641 ULONG NodeColor;
642 ULONG NodeShiftedColor;
643 ULONG SecondaryColorMask;
644 #endif
645 LONG Sleeping;
646 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
647 UINT64 CycleTime;
648 ULONG CcFastMdlReadNoWait;
649 ULONG CcFastMdlReadWait;
650 ULONG CcFastMdlReadNotPossible;
651 ULONG CcMapDataNoWait;
652 ULONG CcMapDataWait;
653 ULONG CcPinMappedDataCount;
654 ULONG CcPinReadNoWait;
655 ULONG CcPinReadWait;
656 ULONG CcMdlReadNoWait;
657 ULONG CcMdlReadWait;
658 ULONG CcLazyWriteHotSpots;
659 ULONG CcLazyWriteIos;
660 ULONG CcLazyWritePages;
661 ULONG CcDataFlushes;
662 ULONG CcDataPages;
663 ULONG CcLostDelayedWrites;
664 ULONG CcFastReadResourceMiss;
665 ULONG CcCopyReadWaitMiss;
666 ULONG CcFastMdlReadResourceMiss;
667 ULONG CcMapDataNoWaitMiss;
668 ULONG CcMapDataWaitMiss;
669 ULONG CcPinReadNoWaitMiss;
670 ULONG CcPinReadWaitMiss;
671 ULONG CcMdlReadNoWaitMiss;
672 ULONG CcMdlReadWaitMiss;
673 ULONG CcReadAheadIos;
674 LONG MmCacheTransitionCount;
675 LONG MmCacheReadCount;
676 LONG MmCacheIoCount;
677 ULONG PrcbPad91[3];
678 PROCESSOR_POWER_STATE PowerState;
679 ULONG KeAlignmentFixupCount;
680 UCHAR VendorString[13];
681 UCHAR PrcbPad10[3];
682 ULONG FeatureBits;
683 LARGE_INTEGER UpdateSignature;
684 KDPC DpcWatchdogDpc;
685 KTIMER DpcWatchdogTimer;
686 CACHE_DESCRIPTOR Cache[5];
687 ULONG CacheCount;
688 ULONG CachedCommit;
689 ULONG CachedResidentAvailable;
690 PVOID HyperPte;
691 PVOID WheaInfo;
692 PVOID EtwSupport;
693 SLIST_HEADER InterruptObjectPool;
694 SLIST_HEADER HypercallPageList;
695 PVOID HypercallPageVirtual;
696 PVOID VirtualApicAssist;
697 UINT64* StatisticsPage;
698 PVOID RateControl;
699 UINT64 CacheProcessorMask[5];
700 UINT64 PackageProcessorSet;
701 UINT64 CoreProcessorSet;
702 #else
703 ULONG PrcbPad90[1];
704 ULONG DebugDpcTime;
705 ULONG PageColor;
706 ULONG NodeColor;
707 ULONG NodeShiftedColor;
708 ULONG SecondaryColorMask;
709 UCHAR PrcbPad9[12];
710 ULONG CcFastReadNoWait;
711 ULONG CcFastReadWait;
712 ULONG CcFastReadNotPossible;
713 ULONG CcCopyReadNoWait;
714 ULONG CcCopyReadWait;
715 ULONG CcCopyReadNoWaitMiss;
716 ULONG KeAlignmentFixupCount;
717 ULONG KeDcacheFlushCount;
718 ULONG KeExceptionDispatchCount;
719 ULONG KeFirstLevelTbFills;
720 ULONG KeFloatingEmulationCount;
721 ULONG KeIcacheFlushCount;
722 ULONG KeSecondLevelTbFills;
723 UCHAR VendorString[13];
724 UCHAR PrcbPad10[2];
725 ULONG FeatureBits;
726 LARGE_INTEGER UpdateSignature;
727 PROCESSOR_POWER_STATE PowerState;
728 CACHE_DESCRIPTOR Cache[5];
729 ULONG CacheCount;
730 #endif
731 }
732 KPRCB, *PKPRCB;
733
734 //
735 // Processor Control Region
736 //
737 typedef struct _KIPCR
738 {
739 union
740 {
741 NT_TIB NtTib;
742 struct
743 {
744 union _KGDTENTRY64 *GdtBase;
745 struct _KTSS64 *TssBase;
746 ULONG64 UserRsp;
747 struct _KPCR *Self;
748 struct _KPRCB *CurrentPrcb;
749 PKSPIN_LOCK_QUEUE LockArray;
750 PVOID Used_Self;
751 };
752 };
753 union _KIDTENTRY64 *IdtBase;
754 ULONG64 Unused[2];
755 KIRQL Irql;
756 UCHAR SecondLevelCacheAssociativity;
757 UCHAR ObsoleteNumber;
758 UCHAR Fill0;
759 ULONG Unused0[3];
760 USHORT MajorVersion;
761 USHORT MinorVersion;
762 ULONG StallScaleFactor;
763 PVOID Unused1[3];
764 ULONG KernelReserved[15];
765 ULONG SecondLevelCacheSize;
766 ULONG HalReserved[16];
767 ULONG Unused2;
768 ULONG Fill1;
769 PVOID KdVersionBlock; // 0x108
770 PVOID Unused3;
771 ULONG PcrAlign1[24];
772 ULONG Fill2[2]; // 0x178
773 KPRCB Prcb; // 0x180
774
775 // hack:
776 ULONG ContextSwitches;
777
778 } KIPCR, *PKIPCR;
779 #pragma pack(pop)
780
781 //
782 // TSS Definition
783 //
784 typedef struct _KiIoAccessMap
785 {
786 UCHAR DirectionMap[32];
787 UCHAR IoMap[8196];
788 } KIIO_ACCESS_MAP;
789
790
791 #pragma pack(push,4)
792 typedef struct _KTSS64
793 {
794 /* 000 */ ULONG Reserved0;
795 /* 004 */ UINT64 Rsp0;
796 /* 00c */ UINT64 Rsp1;
797 /* 014 */ UINT64 Rsp2;
798 /* 01c */ UINT64 Ist[8];
799 /* 05c */ UINT64 Reserved1;
800 /* 064 */ USHORT Reserved2;
801 /* 066 */ USHORT IoMapBase;
802 } KTSS64, *PKTSS64;
803 #pragma pack(pop)
804 #define KTSS KTSS64
805 #define PKTSS PKTSS64
806
807 //
808 // i386 CPUs don't have exception frames
809 //
810 typedef struct _KEXCEPTION_FRAME KEXCEPTION_FRAME, *PKEXCEPTION_FRAME;
811
812 //
813 // Inline function to get current KPRCB
814 //
815 FORCEINLINE
816 struct _KPRCB *
817 KeGetCurrentPrcb(VOID)
818 {
819 return (struct _KPRCB *)__readgsqword(FIELD_OFFSET(KIPCR, CurrentPrcb));
820 }
821
822 #endif
823 #endif