ReactOS  0.4.15-dev-5446-g3f3714b
ke.h
Go to the documentation of this file.
1 #pragma once
2 
3 #ifndef __ASM__
4 
5 #include "intrin_i.h"
6 
7 #ifdef __cplusplus
8 extern "C"
9 {
10 #endif
11 
12 //
13 // Thread Dispatcher Header DebugActive Mask
14 //
15 #define DR_MASK(x) (1 << (x))
16 #define DR_REG_MASK 0x4F
17 
18 //
19 // INT3 is 1 byte long
20 //
21 #define KD_BREAKPOINT_TYPE UCHAR
22 #define KD_BREAKPOINT_SIZE sizeof(UCHAR)
23 #define KD_BREAKPOINT_VALUE 0xCC
24 
25 //
26 // One-liners for getting and setting special purpose registers in portable code
27 //
31 {
32  return Context->Eip;
33 }
34 
36 VOID
38 {
39  Context->Eip = ProgramCounter;
40 }
41 
45 {
46  return Context->Eax;
47 }
48 
50 VOID
52 {
53  Context->Eax = ReturnValue;
54 }
55 
59 {
60  return Context->Ebp;
61 }
62 
64 VOID
66 {
67  Context->Ebp = Frame;
68 }
69 
73 {
74  return TrapFrame->Eip;
75 }
76 
80 {
81  return (PKTRAP_FRAME)TrapFrame->Edx;
82 }
83 
84 
88 {
89  if (TrapFrame->PreviousPreviousMode == KernelMode)
90  return TrapFrame->TempEsp;
91  return TrapFrame->HardwareEsp;
92 }
93 
97 {
98  return TrapFrame->Ebp;
99 }
100 
101 //
102 // Macro to get trap and exception frame from a thread stack
103 //
104 #define KeGetTrapFrame(Thread) \
105  (PKTRAP_FRAME)((ULONG_PTR)((Thread)->InitialStack) - \
106  sizeof(KTRAP_FRAME) - \
107  sizeof(FX_SAVE_AREA))
108 
109 #define KeGetExceptionFrame(Thread) \
110  NULL
111 
112 //
113 // Macro to get context switches from the PRCB
114 // All architectures but x86 have it in the PRCB's KeContextSwitches
115 //
116 #define KeGetContextSwitches(Prcb) \
117  CONTAINING_RECORD(Prcb, KIPCR, PrcbData)->ContextSwitches
118 
119 //
120 // Macro to get the second level cache size field name which differs between
121 // CISC and RISC architectures, as the former has unified I/D cache
122 //
123 #define KiGetSecondLevelDCacheSize() ((PKIPCR)KeGetPcr())->SecondLevelCacheSize
124 
125 //
126 // Returns the Interrupt State from a Trap Frame.
127 // ON = TRUE, OFF = FALSE
128 //
129 #define KeGetTrapFrameInterruptState(TrapFrame) \
130  BooleanFlagOn((TrapFrame)->EFlags, EFLAGS_INTERRUPT_MASK)
131 
132 //
133 // Flags for exiting a trap
134 //
135 #define KTE_SKIP_PM_BIT (((KTRAP_EXIT_SKIP_BITS) { { .SkipPreviousMode = TRUE } }).Bits)
136 #define KTE_SKIP_SEG_BIT (((KTRAP_EXIT_SKIP_BITS) { { .SkipSegments = TRUE } }).Bits)
137 #define KTE_SKIP_VOL_BIT (((KTRAP_EXIT_SKIP_BITS) { { .SkipVolatiles = TRUE } }).Bits)
138 
140 {
141  struct
142  {
147  };
150 
151 
152 //
153 // Flags used by the VDM/V8086 emulation engine for determining instruction prefixes
154 //
155 #define PFX_FLAG_ES 0x00000100
156 #define PFX_FLAG_CS 0x00000200
157 #define PFX_FLAG_SS 0x00000400
158 #define PFX_FLAG_DS 0x00000800
159 #define PFX_FLAG_FS 0x00001000
160 #define PFX_FLAG_GS 0x00002000
161 #define PFX_FLAG_OPER32 0x00004000
162 #define PFX_FLAG_ADDR32 0x00008000
163 #define PFX_FLAG_LOCK 0x00010000
164 #define PFX_FLAG_REPNE 0x00020000
165 #define PFX_FLAG_REP 0x00040000
166 
167 //
168 // VDM Helper Macros
169 //
170 // All VDM/V8086 opcode emulators have the same FASTCALL function definition.
171 // We need to keep 2 parameters while the original ASM implementation uses 4:
172 // TrapFrame, PrefixFlags, Eip, InstructionSize;
173 //
174 // We pass the trap frame, and prefix flags, in our two parameters.
175 //
176 // We then realize that since the smallest prefix flag is 0x100, this gives us
177 // a count of up to 0xFF. So we OR in the instruction size with the prefix flags
178 //
179 // We further realize that we always have access to EIP from the trap frame, and
180 // that if we want the *current instruction* EIP, we simply have to add the
181 // instruction size *MINUS ONE*, and that gives us the EIP we should be looking
182 // at now, so we don't need to use the stack to push this parameter.
183 //
184 // We actually only care about the *current instruction* EIP in one location,
185 // so although it may be slightly more expensive to re-calculate the EIP one
186 // more time, this way we don't redefine ALL opcode handlers to have 3 parameters,
187 // which would be forcing stack usage in all other scenarios.
188 //
189 #define KiVdmSetVdmEFlags(x) InterlockedOr((PLONG)KiNtVdmState, (x));
190 #define KiVdmClearVdmEFlags(x) InterlockedAnd((PLONG)KiNtVdmState, ~(x))
191 #define KiCallVdmHandler(x) KiVdmOpcode##x(TrapFrame, Flags)
192 #define KiCallVdmPrefixHandler(x) KiVdmOpcodePrefix(TrapFrame, Flags | x)
193 #define KiVdmUnhandledOpcode(x) \
194  BOOLEAN \
195  FASTCALL \
196  KiVdmOpcode##x(IN PKTRAP_FRAME TrapFrame, \
197  IN ULONG Flags) \
198  { \
199  /* Not yet handled */ \
200  UNIMPLEMENTED_DBGBREAK(); \
201  return FALSE; \
202  }
203 
205 
206 //
207 // Local parameters
208 //
209 typedef struct _KV86_FRAME
210 {
215 
216 //
217 // Virtual Stack Frame
218 //
219 typedef struct _KV8086_STACK_FRAME
220 {
225 
226 //
227 // Large Pages Support
228 //
229 typedef struct _LARGE_IDENTITY_MAP
230 {
237 
238 //
239 // Floating Point Internal Context Structure
240 //
242 {
248 
249 /* Diable interrupts and return whether they were enabled before */
251 BOOLEAN
253 {
254  ULONG Flags;
255  BOOLEAN Return;
256 
257  /* Get EFLAGS and check if the interrupt bit is set */
258  Flags = __readeflags();
259  Return = (Flags & EFLAGS_INTERRUPT_MASK) ? TRUE: FALSE;
260 
261  /* Disable interrupts */
262  _disable();
263  return Return;
264 }
265 
266 /* Restore previous interrupt state */
268 VOID
270 {
271  if (WereEnabled) _enable();
272 }
273 
274 //
275 // Registers an interrupt handler with an IDT vector
276 //
278 VOID
280  IN PVOID Handler)
281 {
282  UCHAR Entry;
284  PKIPCR Pcr = (PKIPCR)KeGetPcr();
285 
286  //
287  // Get the entry from the HAL
288  //
291 
292  //
293  // Now set the data
294  //
295  Pcr->IDT[Entry].ExtendedOffset = (USHORT)(Address >> 16);
296  Pcr->IDT[Entry].Offset = (USHORT)Address;
297 }
298 
299 //
300 // Returns the registered interrupt handler for a given IDT vector
301 //
303 PVOID
305 {
306  PKIPCR Pcr = (PKIPCR)KeGetPcr();
307  UCHAR Entry;
308 
309  //
310  // Get the entry from the HAL
311  //
313 
314  //
315  // Read the entry from the IDT
316  //
317  return (PVOID)(((Pcr->IDT[Entry].ExtendedOffset << 16) & 0xFFFF0000) |
318  (Pcr->IDT[Entry].Offset & 0xFFFF));
319 }
320 
321 //
322 // Invalidates the TLB entry for a specified address
323 //
325 VOID
327 {
328  /* Invalidate the TLB entry for this address */
329  __invlpg(Address);
330 }
331 
333 VOID
335 {
336  /* Flush the TLB by resetting CR3 */
338 }
339 
341 VOID
343  IN SIZE_T FlushSize)
344 {
345  //
346  // Always sweep the whole cache
347  //
349  UNREFERENCED_PARAMETER(FlushSize);
350  __wbinvd();
351 }
352 
354 PRKTHREAD
356 {
357  /* Return the current thread */
358  return ((PKIPCR)KeGetPcr())->PrcbData.CurrentThread;
359 }
360 
362 VOID
364 {
365 #ifndef CONFIG_SMP
366  /* Check if this is the NPX Thread */
367  if (KeGetCurrentPrcb()->NpxThread == Thread)
368  {
369  /* Clear it */
370  KeGetCurrentPrcb()->NpxThread = NULL;
371  Ke386FnInit();
372  }
373 #else
374  /* Nothing to do */
375 #endif
376 }
377 
379 VOID
381 {
382  GdtEntry->BaseLow = (USHORT)((ULONG_PTR)BaseAddress & 0xFFFF);
383  GdtEntry->HighWord.Bytes.BaseMid = (UCHAR)((ULONG_PTR)BaseAddress >> 16);
384  GdtEntry->HighWord.Bytes.BaseHi = (UCHAR)((ULONG_PTR)BaseAddress >> 24);
385 }
386 
388 VOID
389 KiSetTebBase(PKPCR Pcr, PNT_TIB TebAddress)
390 {
391  Pcr->NtTib.Self = TebAddress;
392  Ke386SetGdtEntryBase(&Pcr->GDT[KGDT_R3_TEB / sizeof(KGDTENTRY)], TebAddress);
393 }
394 
395 CODE_SEG("INIT")
396 VOID
397 FASTCALL
399  IN PKTSS Tss,
400  IN PKIDTENTRY Idt,
401  IN PKGDTENTRY Gdt
402 );
403 
404 CODE_SEG("INIT")
405 VOID
406 NTAPI
408 
409 CODE_SEG("INIT")
410 VOID
411 NTAPI
413 
414 CODE_SEG("INIT")
415 BOOLEAN
416 NTAPI
418  VOID
419 );
420 
421 CODE_SEG("INIT")
422 BOOLEAN
423 NTAPI
425  VOID
426 );
427 
428 CODE_SEG("INIT")
429 VOID
430 NTAPI
432 
433 CODE_SEG("INIT")
434 ULONG
435 NTAPI
437 
438 VOID
439 NTAPI
441 
442 NTSTATUS
443 NTAPI
446  IN ULONG Offset,
448 );
449 
450 VOID
451 NTAPI
453  IN FLOATING_SAVE_AREA *SaveArea
454 );
455 
456 VOID
457 NTAPI
459  IN PKTRAP_FRAME TrapFrame
460 );
461 
462 VOID
463 NTAPI
465  OUT PTEB VdmTeb
466 );
467 
468 CODE_SEG("INIT")
469 VOID
470 NTAPI
472  VOID
473 );
474 
475 CODE_SEG("INIT")
476 ULONG_PTR
477 NTAPI
480 );
481 
482 CODE_SEG("INIT")
483 ULONG_PTR
484 NTAPI
487 );
488 
489 BOOLEAN
490 NTAPI
492  IN PLARGE_IDENTITY_MAP IdentityMap,
493  IN PVOID StartPtr,
494  IN ULONG Length
495 );
496 
497 VOID
498 NTAPI
500  IN PLARGE_IDENTITY_MAP IdentityMap
501 );
502 
503 VOID
504 NTAPI
506  IN ULONG_PTR StartAddress,
507  IN ULONG Cr3
508 );
509 
510 CODE_SEG("INIT")
511 VOID
512 NTAPI
514  VOID
515 );
516 
517 CODE_SEG("INIT")
518 VOID
519 NTAPI
521  VOID
522 );
523 
524 CODE_SEG("INIT")
525 VOID
526 NTAPI
528  IN BOOLEAN FinalCpu
529 );
530 
531 CODE_SEG("INIT")
532 VOID
533 NTAPI
535  VOID
536 );
537 
538 CODE_SEG("INIT")
539 VOID
540 NTAPI
542  VOID
543 );
544 
545 CODE_SEG("INIT")
546 ULONG_PTR
547 NTAPI
550 );
551 
552 CODE_SEG("INIT")
553 ULONG_PTR
554 NTAPI
557 );
558 
559 CODE_SEG("INIT")
560 ULONG_PTR
561 NTAPI
564 );
565 
566 BOOLEAN
567 NTAPI
569  IN PKTRAP_FRAME TrapFrame
570 );
571 
572 BOOLEAN
573 NTAPI
575  _In_ PKTRAP_FRAME TrapFrame
576 );
577 
578 BOOLEAN
579 FASTCALL
581  IN PKTRAP_FRAME TrapFrame,
582  IN ULONG Flags
583 );
584 
585 BOOLEAN
586 FASTCALL
588  IN PKTRAP_FRAME TrapFrame
589 );
590 
592 VOID
593 FASTCALL
595  IN PKTRAP_FRAME TrapFrame
596 );
597 
598 VOID
599 FASTCALL
601  IN PKTRAP_FRAME TrapFrame
602 );
603 
604 ULONG_PTR
605 FASTCALL
607  IN PKTRAP_FRAME TrapFrame
608 );
609 
611 VOID
612 NTAPI
614  IN NTSTATUS Code,
615  IN ULONG Flags,
617  IN ULONG ParameterCount,
618  IN ULONG_PTR Parameter1,
619  IN ULONG_PTR Parameter2,
620  IN ULONG_PTR Parameter3,
621  IN PKTRAP_FRAME TrapFrame
622 );
623 
624 NTSTATUS
625 NTAPI
627  VOID
628 );
629 
630 //
631 // Global x86 only Kernel data
632 //
633 extern PVOID Ki386IopmSaveArea;
640 extern ULONG KeI386NpxPresent;
641 extern ULONG KeI386XMMIPresent;
642 extern ULONG KeI386FxsrPresent;
643 extern ULONG KiMXCsrMask;
644 extern ULONG KeI386CpuType;
645 extern ULONG KeI386CpuStep;
649 extern VOID __cdecl KiTrap02(VOID);
650 extern VOID __cdecl KiTrap08(VOID);
651 extern VOID __cdecl KiTrap13(VOID);
655 extern VOID __cdecl CopyParams(VOID);
656 extern VOID __cdecl ReadBatch(VOID);
658 extern CHAR KiSystemCallExit[];
659 extern CHAR KiSystemCallExit2[];
660 
661 //
662 // Trap Macros
663 //
664 #include "trap_x.h"
665 
666 //
667 // Returns a thread's FPU save area
668 //
672 {
673  ASSERT((ULONG_PTR)Thread->InitialStack % 16 == 0);
674  return (PFX_SAVE_AREA)((ULONG_PTR)Thread->InitialStack - sizeof(FX_SAVE_AREA));
675 }
676 
677 //
678 // Sanitizes a selector
679 //
681 ULONG
684 {
685  //
686  // Check if we're in kernel-mode, and force CPL 0 if so.
687  // Otherwise, force CPL 3.
688  //
689  return ((Mode == KernelMode) ?
690  (Cs & (0xFFFF & ~RPL_MASK)) :
691  (RPL_MASK | (Cs & 0xFFFF)));
692 }
693 
694 //
695 // Sanitizes EFLAGS
696 //
698 ULONG
701 {
702  //
703  // Check if we're in kernel-mode, and sanitize EFLAGS if so.
704  // Otherwise, also force interrupt mask on.
705  //
706  return ((Mode == KernelMode) ?
709 }
710 
711 //
712 // Sanitizes a Debug Register
713 //
715 PVOID
718 {
719  //
720  // Check if we're in kernel-mode, and return the address directly if so.
721  // Otherwise, make sure it's not inside the kernel-mode address space.
722  // If it is, then clear the address.
723  //
724  return ((Mode == KernelMode) ? DrAddress :
725  (DrAddress <= MM_HIGHEST_USER_ADDRESS) ? DrAddress : 0);
726 }
727 
728 //
729 // Exception with no arguments
730 //
733 VOID
736  IN PKTRAP_FRAME TrapFrame)
737 {
738  /* Helper for exceptions with no arguments */
739  KiDispatchExceptionFromTrapFrame(Code, 0, Address, 0, 0, 0, 0, TrapFrame);
740 }
741 
742 //
743 // Exception with one argument
744 //
747 VOID
750  IN ULONG P1,
751  IN PKTRAP_FRAME TrapFrame)
752 {
753  /* Helper for exceptions with no arguments */
754  KiDispatchExceptionFromTrapFrame(Code, 0, Address, 1, P1, 0, 0, TrapFrame);
755 }
756 
757 //
758 // Exception with two arguments
759 //
762 VOID
765  IN ULONG P1,
766  IN ULONG P2,
767  IN PKTRAP_FRAME TrapFrame)
768 {
769  /* Helper for exceptions with no arguments */
770  KiDispatchExceptionFromTrapFrame(Code, 0, Address, 2, P1, P2, 0, TrapFrame);
771 }
772 
773 //
774 // Performs a system call
775 //
776 NTSTATUS
777 NTAPI
779  _In_ PVOID Arguments,
780  _In_ ULONG StackBytes);
781 
782 
783 //
784 // Checks for pending APCs
785 //
787 VOID
789 {
791  KIRQL OldIrql;
792 
793  /* Check for V8086 or user-mode trap */
794  if ((TrapFrame->EFlags & EFLAGS_V86_MASK) || (KiUserTrap(TrapFrame)))
795  {
796  /* Get the thread */
798  while (TRUE)
799  {
800  /* Turn off the alerted state for kernel mode */
801  Thread->Alerted[KernelMode] = FALSE;
802 
803  /* Are there pending user APCs? */
804  if (!Thread->ApcState.UserApcPending) break;
805 
806  /* Raise to APC level and enable interrupts */
808  _enable();
809 
810  /* Deliver APCs */
811  KiDeliverApc(UserMode, NULL, TrapFrame);
812 
813  /* Restore IRQL and disable interrupts once again */
815  _disable();
816  }
817  }
818 }
819 
820 //
821 // Switches from boot loader to initial kernel stack
822 //
823 CODE_SEG("INIT")
826 VOID
828 {
830 
831  /* We have to switch to a new stack before continuing kernel initialization */
832 #ifdef __GNUC__
833  __asm__
834  (
835  "movl %0, %%esp\n\t"
836  "subl %1, %%esp\n\t"
837  "pushl %2\n\t"
838  "jmp _KiSystemStartupBootStack@0"
839  :
840  : "c"(InitialStack),
842  "i"(CR0_EM | CR0_TS | CR0_MP),
844  : "%esp"
845  );
846 #elif defined(_MSC_VER)
847  __asm
848  {
849  mov esp, InitialStack
851  push (CR0_EM | CR0_TS | CR0_MP)
853  }
854 #else
855 #error Unknown Compiler
856 #endif
857 
858  UNREACHABLE;
859 }
860 
861 //
862 // Emits the iret instruction for C code
863 //
866 VOID
868 {
869 #if defined(__GNUC__)
870  __asm__ __volatile__
871  (
872  "iret"
873  );
874 #elif defined(_MSC_VER)
875  __asm
876  {
877  iretd
878  }
879 #else
880 #error Unsupported compiler
881 #endif
882  UNREACHABLE;
883 }
884 
885 //
886 // Normally this is done by the HAL, but on x86 as an optimization, the kernel
887 // initiates the end by calling back into the HAL and exiting the trap here.
888 //
890 VOID
892  IN PKTRAP_FRAME TrapFrame)
893 {
894  /* Disable interrupts and end the interrupt */
895  _disable();
896  HalEndSystemInterrupt(Irql, TrapFrame);
897 
898  /* Exit the interrupt */
899  KiEoiHelper(TrapFrame);
900 }
901 
902 //
903 // PERF Code
904 //
906 VOID
908 {
911  DbgPrint("Boot took %I64u cycles!\n", BootCyclesEnd - BootCycles);
912  DbgPrint("Interrupts: %u System Calls: %u Context Switches: %u\n",
913  KeGetCurrentPrcb()->InterruptCount,
914  KeGetCurrentPrcb()->KeSystemCalls,
916 }
917 
919 PULONG
921 {
923 }
924 
925 #ifdef __cplusplus
926 } // extern "C"
927 #endif
928 
929 #endif
VOID NTAPI ExpInterlockedPopEntrySListResume(VOID)
#define CR0_EM
Definition: asm.h:247
KV86_FRAME V86Frame
Definition: ke.h:223
struct _NT_TIB * Self
Definition: compat.h:720
ULONG TempEsp
Definition: ketypes.h:247
#define MM_HIGHEST_USER_ADDRESS
Definition: armddk.h:17
#define IN
Definition: typedefs.h:39
VOID NTAPI HalEndSystemInterrupt(IN KIRQL OldIrql, IN PKTRAP_FRAME TrapFrame)
Definition: pic.c:335
FORCEINLINE VOID KeSetContextFrameRegister(PCONTEXT Context, ULONG_PTR Frame)
Definition: ke.h:172
BOOLEAN KiI386PentiumLockErrataPresent
Definition: cpu.c:42
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:339
#define NPX_FRAME_LENGTH
Definition: asm.h:246
UCHAR SkipSegments
Definition: ke.h:144
FORCEINLINE DECLSPEC_NORETURN VOID KiDispatchException2Args(IN NTSTATUS Code, IN ULONG_PTR Address, IN ULONG P1, IN ULONG P2, IN PKTRAP_FRAME TrapFrame)
Definition: ke.h:763
#define DbgPrint
Definition: hal.h:12
FORCEINLINE PKTRAP_FRAME KiGetLinkedTrapFrame(PKTRAP_FRAME TrapFrame)
Definition: ke.h:186
struct _Entry Entry
Definition: kefuncs.h:629
CHAR KiSystemCallExit2[]
#define __cdecl
Definition: accygwin.h:79
_In_ ULONG Mode
Definition: hubbusif.h:303
ULONG_PTR StartAddress
Definition: ke.h:233
DECLSPEC_NORETURN VOID KiSwitchToBootStack(IN ULONG_PTR InitialStack)
Definition: ke.h:827
FX_SAVE_AREA NpxArea
Definition: ke.h:222
VOID NTAPI KiSetCR0Bits(VOID)
Definition: cpu.c:728
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
USHORT BaseLow
Definition: ketypes.h:337
struct _KV8086_STACK_FRAME * PKV8086_STACK_FRAME
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn UINT32 *TableIdx UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER Handler
Definition: acpixf.h:672
ULONGLONG BootCycles
Definition: kiinit.c:37
ULONG KiFastSystemCallDisable
Definition: cpu.c:28
BOOLEAN NTAPI Ki386CreateIdentityMap(IN PLARGE_IDENTITY_MAP IdentityMap, IN PVOID StartPtr, IN ULONG Length)
char CHAR
Definition: xmlstorage.h:175
FORCEINLINE ULONG Ke386SanitizeFlags(IN ULONG Eflags, IN KPROCESSOR_MODE Mode)
Definition: ke.h:699
void __cdecl _enable(void)
Definition: intrin_arm.h:373
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN FASTCALL Ki386HandleOpcodeV86(IN PKTRAP_FRAME TrapFrame)
Definition: v86vdm.c:456
ULONG KiGetFeatureBits(VOID)
Definition: cpu.c:150
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1080
ULONG KeI386EFlagsOrMaskV86
Definition: v86vdm.c:22
DECLSPEC_NORETURN VOID NTAPI KiSystemStartupBootStack(VOID)
Definition: krnlinit.c:58
struct _KIPCR * PKIPCR
VOID NTAPI Ki386AdjustEsp0(IN PKTRAP_FRAME TrapFrame)
Definition: exp.c:280
DECLSPEC_NORETURN VOID NTAPI KiDispatchExceptionFromTrapFrame(IN NTSTATUS Code, IN ULONG Flags, IN ULONG_PTR Address, IN ULONG ParameterCount, IN ULONG_PTR Parameter1, IN ULONG_PTR Parameter2, IN ULONG_PTR Parameter3, IN PKTRAP_FRAME TrapFrame)
Definition: exp.c:1055
PVOID PcrTeb
Definition: ke.h:213
PPC_QUAL unsigned long long __rdtsc(void)
Definition: intrin_ppc.h:688
VOID NTAPI KiInitializeMTRR(IN BOOLEAN FinalCpu)
Definition: mtrr.c:22
FORCEINLINE PVOID Ke386SanitizeDr(IN PVOID DrAddress, IN KPROCESSOR_MODE Mode)
Definition: ke.h:716
PKTRAP_FRAME TrapFrame
Definition: ketypes.h:1714
ULONG KeI386NpxPresent
Definition: cpu.c:25
BOOLEAN NTAPI KiIsNpxErrataPresent(VOID)
Definition: cpu.c:1159
__asm__("\n\t \ NewInt3Handler:\n\t \ pushl $" STR(REASON_INT3) "\n\t \ // call debugger loop\n\t \ jmp NewInt31Handler\n\t \ ")
Definition: ke.h:289
__INTRIN_INLINE unsigned long __readcr3(void)
Definition: intrin_x86.h:1818
union _KTRAP_EXIT_SKIP_BITS KTRAP_EXIT_SKIP_BITS
ULONG_PTR NTAPI Ki386EnableGlobalPage(IN ULONG_PTR Context)
Definition: patpge.c:23
FORCEINLINE PULONG_PTR KiGetUserModeStackAddress(void)
Definition: ke.h:465
ULONG_PTR NTAPI Ki386EnableDE(IN ULONG_PTR Context)
Definition: cpu.c:1045
#define FASTCALL
Definition: nt_native.h:50
union _KTRAP_EXIT_SKIP_BITS * PKTRAP_EXIT_SKIP_BITS
_Out_ PKIRQL Irql
Definition: csq.h:179
DECLSPEC_NORETURN VOID FASTCALL KiEoiHelper(IN PKTRAP_FRAME TrapFrame)
Definition: traphdlr.c:126
#define DECLSPEC_NORETURN
Definition: ntbasedef.h:176
KIRQL OldNpxIrql
Definition: ke.h:244
FORCEINLINE PVOID KeQueryInterruptHandler(IN ULONG Vector)
Definition: ke.h:327
ULONG KeI386FxsrPresent
Definition: cpu.c:33
#define EFLAGS_V86_MASK
Definition: ketypes.h:132
PFX_SAVE_AREA Buffer
Definition: ke.h:245
uint32_t ULONG_PTR
Definition: typedefs.h:65
BOOLEAN NTAPI KiIsNpxPresent(VOID)
UCHAR KIRQL
Definition: env_spec_w32.h:591
__INTRIN_INLINE void __writecr3(unsigned int Data)
Definition: intrin_x86.h:1794
__INTRIN_INLINE uintptr_t __readeflags(void)
Definition: intrin_x86.h:1674
UINT32 void void ** ReturnValue
Definition: acevents.h:214
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
PVOID ThreadStack
Definition: ke.h:211
#define FALSE
Definition: types.h:117
FORCEINLINE VOID KeSetContextPc(PCONTEXT Context, ULONG_PTR ProgramCounter)
Definition: ke.h:137
UCHAR Reserved
Definition: ke.h:146
ULONG PagesCount
Definition: ke.h:234
NTKERNELAPI KIRQL NTAPI KfRaiseIrql(IN KIRQL NewIrql)
Definition: pic.c:187
FORCEINLINE PRKTHREAD KeGetCurrentThread(VOID)
Definition: ke.h:355
#define EFLAGS_USER_SANITIZE
Definition: ketypes.h:137
#define RPL_MASK
Definition: ketypes.h:69
unsigned char BOOLEAN
NTSTATUS NTAPI KiConvertToGuiThread(VOID)
VOID NTAPI KiInitializePAT(VOID)
Definition: patpge.c:61
struct _KV86_FRAME KV86_FRAME
static WCHAR Address[46]
Definition: ping.c:68
struct _FLOATING_SAVE_CONTEXT * PFLOATING_SAVE_CONTEXT
#define _In_
Definition: ms_sal.h:308
VOID NTAPI Ki386FreeIdentityMap(IN PLARGE_IDENTITY_MAP IdentityMap)
Definition: ketypes.h:790
FORCEINLINE BOOLEAN KeDisableInterrupts(VOID)
Definition: ke.h:239
ULONG KeI386XMMIPresent
Definition: cpu.c:32
FORCEINLINE VOID Ke386SetGdtEntryBase(PKGDTENTRY GdtEntry, PVOID BaseAddress)
Definition: ke.h:380
FORCEINLINE ULONG_PTR KeGetTrapFrameStackRegister(PKTRAP_FRAME TrapFrame)
Definition: ke.h:193
ULONGLONG BootCyclesEnd
Definition: kiinit.c:37
VOID __cdecl CopyParams(VOID)
UCHAR SkipPreviousMode
Definition: ke.h:143
ULONG KiMXCsrMask
Definition: cpu.c:30
VOID NTAPI ExpInterlockedPopEntrySListFault(VOID)
#define PtrToUlong(u)
Definition: config.h:107
FORCEINLINE PFX_SAVE_AREA KiGetThreadNpxArea(IN PKTHREAD Thread)
Definition: ke.h:671
PFX_SAVE_AREA PfxSaveArea
Definition: ke.h:246
UCHAR KiDebugRegisterTrapOffsets[9]
FORCEINLINE VOID KiCheckForApcDelivery(IN PKTRAP_FRAME TrapFrame)
Definition: ke.h:788
VOID FASTCALL Ki386InitializeTss(IN PKTSS Tss, IN PKIDTENTRY Idt, IN PKGDTENTRY Gdt)
Definition: cpu.c:799
FORCEINLINE VOID KeInvalidateTlbEntry(IN PVOID Address)
Definition: ke.h:264
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define ASSERT(a)
Definition: mode.c:44
C_ASSERT(NPX_FRAME_LENGTH==sizeof(FX_SAVE_AREA))
uint64_t ULONGLONG
Definition: typedefs.h:67
#define APC_LEVEL
VOID NTAPI KiRestoreFastSyscallReturnState(VOID)
Definition: cpu.c:1011
ULONG HardwareEsp
Definition: ketypes.h:271
ULONG KeI386CpuType
Definition: cpu.c:22
#define KGDT_R3_TEB
Definition: ketypes.h:81
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2652
VOID KiGetCacheInformation(VOID)
Definition: cpu.c:239
USHORT Offset
Definition: ketypes.h:387
CCHAR KPROCESSOR_MODE
Definition: ketypes.h:7
PPC_QUAL void __wbinvd(void)
Definition: intrin_ppc.h:759
BOOLEAN FASTCALL KiVdmOpcodePrefix(IN PKTRAP_FRAME TrapFrame, IN ULONG Flags)
Definition: v86vdm.c:442
USHORT ExtendedOffset
Definition: ketypes.h:390
PVOID ThreadTeb
Definition: ke.h:212
FORCEINLINE DECLSPEC_NORETURN VOID KiIret(VOID)
Definition: ke.h:867
FORCEINLINE ULONG_PTR KeGetContextPc(PCONTEXT Context)
Definition: ke.h:130
unsigned char UCHAR
Definition: xmlstorage.h:181
ULONG KeI386CpuStep
Definition: cpu.c:23
NTSTATUS NTAPI KiSystemCallTrampoline(_In_ PVOID Handler, _In_ PVOID Arguments, _In_ ULONG StackBytes)
NTSTATUS NTAPI Ke386GetGdtEntryThread(IN PKTHREAD Thread, IN ULONG Offset, IN PKGDTENTRY Descriptor)
Definition: ldt.c:26
VOID NTAPI Ki386SetupAndExitToV86Mode(OUT PTEB VdmTeb)
struct _KGDTENTRY::@2405::@2406 Bytes
VOID __cdecl KiTrap13(VOID)
struct _KV8086_STACK_FRAME KV8086_STACK_FRAME
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:792
VOID FASTCALL Ki386BiosCallReturnAddress(IN PKTRAP_FRAME TrapFrame)
_In_ UCHAR _In_ UCHAR _In_ ULONG Code
Definition: wdfdevice.h:1697
FORCEINLINE VOID KeSetContextReturnRegister(PCONTEXT Context, ULONG_PTR ReturnValue)
Definition: ke.h:151
ULONG_PTR FASTCALL KiExitV86Mode(IN PKTRAP_FRAME TrapFrame)
Definition: v86vdm.c:468
PVOID Ki386IopmSaveArea
Definition: v86vdm.c:23
ULONG_PTR NTAPI Ki386EnableXMMIExceptions(IN ULONG_PTR Context)
Definition: cpu.c:1065
NT_TIB NtTib
Definition: ke.h:293
ULONG Eip
Definition: ketypes.h:268
struct _LARGE_IDENTITY_MAP LARGE_IDENTITY_MAP
FORCEINLINE BOOLEAN KiUserTrap(IN PKTRAP_FRAME TrapFrame)
Definition: ke.h:364
UCHAR KiDebugRegisterContextOffsets[9]
FORCEINLINE ULONG Ke386SanitizeSeg(IN ULONG Cs, IN KPROCESSOR_MODE Mode)
Definition: ke.h:682
FORCEINLINE PKPCR KeGetPcr(VOID)
Definition: ke.h:327
FORCEINLINE VOID KeRegisterInterruptHandler(IN ULONG Vector, IN PVOID Handler)
Definition: ke.h:301
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
KIDTENTRY KiIdt[MAXIMUM_IDTVECTOR+1]
Definition: except.c:50
ULONG PreviousPreviousMode
Definition: ketypes.h:260
FORCEINLINE ULONG_PTR KeGetTrapFramePc(PKTRAP_FRAME TrapFrame)
Definition: ke.h:179
PUSHORT GDT
Definition: ke.h:54
ULONG_PTR SIZE_T
Definition: typedefs.h:80
VOID __cdecl ReadBatch(VOID)
Definition: compat.h:835
FORCEINLINE DECLSPEC_NORETURN VOID KiDispatchException0Args(IN NTSTATUS Code, IN ULONG_PTR Address, IN PKTRAP_FRAME TrapFrame)
Definition: ke.h:734
struct _KV86_FRAME * PKV86_FRAME
FORCEINLINE VOID KiSetTebBase(PKPCR Pcr, PNT_TIB TebAddress)
Definition: ke.h:389
FORCEINLINE ULONG_PTR KeGetContextReturnRegister(PCONTEXT Context)
Definition: ke.h:144
FORCEINLINE DECLSPEC_NORETURN VOID KiDispatchException1Args(IN NTSTATUS Code, IN ULONG_PTR Address, IN ULONG P1, IN PKTRAP_FRAME TrapFrame)
Definition: ke.h:748
VOID __cdecl KiTrap08(VOID)
unsigned short USHORT
Definition: pedump.c:61
PHARDWARE_PTE TopLevelDirectory
Definition: ke.h:231
BOOLEAN NTAPI VdmDispatchPageFault(_In_ PKTRAP_FRAME TrapFrame)
Definition: vdmexec.c:367
PVOID PagesList[30]
Definition: ke.h:235
ULONG KeI386EFlagsAndMaskV86
Definition: v86vdm.c:21
NTKERNELAPI VOID NTAPI KfLowerIrql(IN KIRQL NewIrql)
Definition: pic.c:232
#define CR0_TS
Definition: asm.h:248
FORCEINLINE ULONG_PTR KeGetContextFrameRegister(PCONTEXT Context)
Definition: ke.h:165
#define FORCEINLINE
Definition: wdftypes.h:67
VOID NTAPI KiFlushNPXState(IN FLOATING_SAVE_AREA *SaveArea)
FORCEINLINE VOID KeRestoreInterrupts(BOOLEAN WereEnabled)
Definition: ke.h:254
UCHAR SkipVolatiles
Definition: ke.h:145
FORCEINLINE VOID KiRundownThread(IN PKTHREAD Thread)
Definition: ke.h:293
unsigned int * PULONG
Definition: retypes.h:1
#define NULL
Definition: types.h:112
VOID NTAPI KiAmdK6InitializeMTRR(VOID)
Definition: mtrr.c:31
BOOLEAN NTAPI VdmDispatchBop(IN PKTRAP_FRAME TrapFrame)
Definition: vdmexec.c:313
FORCEINLINE VOID KiEndInterrupt(IN KIRQL Irql, IN PKTRAP_FRAME TrapFrame)
Definition: ke.h:354
KDESCRIPTOR KiIdtDescriptor
Definition: except.c:51
FORCEINLINE VOID KeFlushProcessTb(VOID)
Definition: ke.h:272
struct _FLOATING_SAVE_CONTEXT FLOATING_SAVE_CONTEXT
__INTRIN_INLINE void __invlpg(void *Address)
Definition: intrin_x86.h:1968
VOID NTAPI KeI386VdmInitialize(VOID)
Definition: vdmmain.c:42
FORCEINLINE VOID Ki386PerfEnd(VOID)
Definition: ke.h:375
#define OUT
Definition: typedefs.h:40
VOID __cdecl KiTrap02(VOID)
VOID NTAPI Ki386EnableCurrentLargePage(IN ULONG_PTR StartAddress, IN ULONG Cr3)
VOID NTAPI KiThreadStartup(VOID)
Definition: thrdini.c:63
void __cdecl _disable(void)
Definition: intrin_arm.h:365
FORCEINLINE ULONG_PTR KeGetTrapFrameFrameRegister(PKTRAP_FRAME TrapFrame)
Definition: ke.h:200
unsigned int ULONG
Definition: retypes.h:1
CHAR KiSystemCallExitBranch[]
struct _LARGE_IDENTITY_MAP * PLARGE_IDENTITY_MAP
#define UNREACHABLE
VOID __cdecl KiFastCallEntry(VOID)
#define ULONG_PTR
Definition: config.h:101
#define KTRAP_FRAME_LENGTH
Definition: asm.h:126
ULONG_PTR NTAPI Ki386EnableTargetLargePage(IN ULONG_PTR Context)
Definition: patpge.c:70
static void push(calc_node_t *op)
Definition: rpn_ieee.c:113
VOID KiSetProcessorType(VOID)
Definition: cpu.c:97
#define CR0_MP
Definition: asm.h:246
BOOLEAN KeI386VirtualIntExtensions
Definition: v86vdm.c:24
PKIDTENTRY IDT
Definition: ketypes.h:759
ULONG_PTR NTAPI Ki386EnableFxsr(IN ULONG_PTR Context)
Definition: cpu.c:1055
CHAR KiSystemCallExit[]
#define KTRAP_FRAME_ALIGN
Definition: asm.h:125
VOID NTAPI KiDeliverApc(IN KPROCESSOR_MODE DeliveryMode, IN PKEXCEPTION_FRAME ExceptionFrame, IN PKTRAP_FRAME TrapFrame)
Definition: apc.c:302
static CODE_SEG("PAGE")
Definition: isapnp.c:1482
#define KeGetContextSwitches(Prcb)
Definition: ke.h:116
#define MAXIMUM_IDTVECTOR
Definition: asm.h:280
base of all file and directory entries
Definition: entries.h:82
ULONG Edx
Definition: ketypes.h:257
ULONG Ebp
Definition: ketypes.h:266
FORCEINLINE VOID KeSweepICache(IN PVOID BaseAddress, IN SIZE_T FlushSize)
Definition: ke.h:280
union _KGDTENTRY::@2405 HighWord
VOID NTAPI KiI386PentiumLockErrataFixup(VOID)
Definition: cpu.c:1088
KTRAP_FRAME TrapFrame
Definition: ke.h:221
#define EFLAGS_INTERRUPT_MASK
Definition: ketypes.h:126
PKTHREAD CurrentThread
Definition: ke.h:243
#define HalVectorToIDTEntry
Definition: halfuncs.h:51