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