ReactOS  0.4.13-dev-39-g8b6696f
ke.h
Go to the documentation of this file.
1 #pragma once
2 
3 #ifndef __ASM__
4 
5 #include "intrin_i.h"
6 
7 //
8 // Thread Dispatcher Header DebugActive Mask
9 //
10 #define DR_MASK(x) (1 << (x))
11 #define DR_REG_MASK 0x4F
12 
13 //
14 // INT3 is 1 byte long
15 //
16 #define KD_BREAKPOINT_TYPE UCHAR
17 #define KD_BREAKPOINT_SIZE sizeof(UCHAR)
18 #define KD_BREAKPOINT_VALUE 0xCC
19 
20 //
21 // Macros for getting and setting special purpose registers in portable code
22 //
23 #define KeGetContextPc(Context) \
24  ((Context)->Eip)
25 
26 #define KeSetContextPc(Context, ProgramCounter) \
27  ((Context)->Eip = (ProgramCounter))
28 
29 #define KeGetTrapFramePc(TrapFrame) \
30  ((TrapFrame)->Eip)
31 
32 #define KiGetLinkedTrapFrame(x) \
33  (PKTRAP_FRAME)((x)->Edx)
34 
35 #define KeGetContextReturnRegister(Context) \
36  ((Context)->Eax)
37 
38 #define KeSetContextReturnRegister(Context, ReturnValue) \
39  ((Context)->Eax = (ReturnValue))
40 
41 //
42 // Macro to get trap and exception frame from a thread stack
43 //
44 #define KeGetTrapFrame(Thread) \
45  (PKTRAP_FRAME)((ULONG_PTR)((Thread)->InitialStack) - \
46  sizeof(KTRAP_FRAME) - \
47  sizeof(FX_SAVE_AREA))
48 
49 #define KeGetExceptionFrame(Thread) \
50  NULL
51 
52 //
53 // Macro to get context switches from the PRCB
54 // All architectures but x86 have it in the PRCB's KeContextSwitches
55 //
56 #define KeGetContextSwitches(Prcb) \
57  CONTAINING_RECORD(Prcb, KIPCR, PrcbData)->ContextSwitches
58 
59 //
60 // Macro to get the second level cache size field name which differs between
61 // CISC and RISC architectures, as the former has unified I/D cache
62 //
63 #define KiGetSecondLevelDCacheSize() ((PKIPCR)KeGetPcr())->SecondLevelCacheSize
64 
65 //
66 // Returns the Interrupt State from a Trap Frame.
67 // ON = TRUE, OFF = FALSE
68 //
69 #define KeGetTrapFrameInterruptState(TrapFrame) \
70  BooleanFlagOn((TrapFrame)->EFlags, EFLAGS_INTERRUPT_MASK)
71 
72 //
73 // Flags for exiting a trap
74 //
75 #define KTE_SKIP_PM_BIT (((KTRAP_EXIT_SKIP_BITS) { { .SkipPreviousMode = TRUE } }).Bits)
76 #define KTE_SKIP_SEG_BIT (((KTRAP_EXIT_SKIP_BITS) { { .SkipSegments = TRUE } }).Bits)
77 #define KTE_SKIP_VOL_BIT (((KTRAP_EXIT_SKIP_BITS) { { .SkipVolatiles = TRUE } }).Bits)
78 
79 typedef union _KTRAP_EXIT_SKIP_BITS
80 {
81  struct
82  {
87  };
90 
91 
92 //
93 // Flags used by the VDM/V8086 emulation engine for determining instruction prefixes
94 //
95 #define PFX_FLAG_ES 0x00000100
96 #define PFX_FLAG_CS 0x00000200
97 #define PFX_FLAG_SS 0x00000400
98 #define PFX_FLAG_DS 0x00000800
99 #define PFX_FLAG_FS 0x00001000
100 #define PFX_FLAG_GS 0x00002000
101 #define PFX_FLAG_OPER32 0x00004000
102 #define PFX_FLAG_ADDR32 0x00008000
103 #define PFX_FLAG_LOCK 0x00010000
104 #define PFX_FLAG_REPNE 0x00020000
105 #define PFX_FLAG_REP 0x00040000
106 
107 //
108 // VDM Helper Macros
109 //
110 // All VDM/V8086 opcode emulators have the same FASTCALL function definition.
111 // We need to keep 2 parameters while the original ASM implementation uses 4:
112 // TrapFrame, PrefixFlags, Eip, InstructionSize;
113 //
114 // We pass the trap frame, and prefix flags, in our two parameters.
115 //
116 // We then realize that since the smallest prefix flag is 0x100, this gives us
117 // a count of up to 0xFF. So we OR in the instruction size with the prefix flags
118 //
119 // We further realize that we always have access to EIP from the trap frame, and
120 // that if we want the *current instruction* EIP, we simply have to add the
121 // instruction size *MINUS ONE*, and that gives us the EIP we should be looking
122 // at now, so we don't need to use the stack to push this parameter.
123 //
124 // We actually only care about the *current instruction* EIP in one location,
125 // so although it may be slightly more expensive to re-calculate the EIP one
126 // more time, this way we don't redefine ALL opcode handlers to have 3 parameters,
127 // which would be forcing stack usage in all other scenarios.
128 //
129 #define KiVdmSetVdmEFlags(x) InterlockedOr((PLONG)KiNtVdmState, (x));
130 #define KiVdmClearVdmEFlags(x) InterlockedAnd((PLONG)KiNtVdmState, ~(x))
131 #define KiCallVdmHandler(x) KiVdmOpcode##x(TrapFrame, Flags)
132 #define KiCallVdmPrefixHandler(x) KiVdmOpcodePrefix(TrapFrame, Flags | x)
133 #define KiVdmUnhandledOpcode(x) \
134  BOOLEAN \
135  FASTCALL \
136  KiVdmOpcode##x(IN PKTRAP_FRAME TrapFrame, \
137  IN ULONG Flags) \
138  { \
139  /* Not yet handled */ \
140  UNIMPLEMENTED_DBGBREAK(); \
141  return FALSE; \
142  }
143 
145 
146 //
147 // Local parameters
148 //
149 typedef struct _KV86_FRAME
150 {
155 
156 //
157 // Virtual Stack Frame
158 //
159 typedef struct _KV8086_STACK_FRAME
160 {
165 
166 //
167 // Large Pages Support
168 //
169 typedef struct _LARGE_IDENTITY_MAP
170 {
177 
178 /* Diable interrupts and return whether they were enabled before */
180 BOOLEAN
182 {
183  ULONG Flags;
184  BOOLEAN Return;
185 
186  /* Get EFLAGS and check if the interrupt bit is set */
187  Flags = __readeflags();
188  Return = (Flags & EFLAGS_INTERRUPT_MASK) ? TRUE: FALSE;
189 
190  /* Disable interrupts */
191  _disable();
192  return Return;
193 }
194 
195 /* Restore previous interrupt state */
197 VOID
199 {
200  if (WereEnabled) _enable();
201 }
202 
203 //
204 // Registers an interrupt handler with an IDT vector
205 //
207 VOID
209  IN PVOID Handler)
210 {
211  UCHAR Entry;
213  PKIPCR Pcr = (PKIPCR)KeGetPcr();
214 
215  //
216  // Get the entry from the HAL
217  //
220 
221  //
222  // Now set the data
223  //
224  Pcr->IDT[Entry].ExtendedOffset = (USHORT)(Address >> 16);
225  Pcr->IDT[Entry].Offset = (USHORT)Address;
226 }
227 
228 //
229 // Returns the registered interrupt handler for a given IDT vector
230 //
232 PVOID
234 {
235  PKIPCR Pcr = (PKIPCR)KeGetPcr();
236  UCHAR Entry;
237 
238  //
239  // Get the entry from the HAL
240  //
242 
243  //
244  // Read the entry from the IDT
245  //
246  return (PVOID)(((Pcr->IDT[Entry].ExtendedOffset << 16) & 0xFFFF0000) |
247  (Pcr->IDT[Entry].Offset & 0xFFFF));
248 }
249 
250 //
251 // Invalidates the TLB entry for a specified address
252 //
254 VOID
256 {
257  /* Invalidate the TLB entry for this address */
258  __invlpg(Address);
259 }
260 
262 VOID
264 {
265  /* Flush the TLB by resetting CR3 */
267 }
268 
270 VOID
272  IN SIZE_T FlushSize)
273 {
274  //
275  // Always sweep the whole cache
276  //
278  UNREFERENCED_PARAMETER(FlushSize);
279  __wbinvd();
280 }
281 
283 PRKTHREAD
285 {
286  /* Return the current thread */
287  return ((PKIPCR)KeGetPcr())->PrcbData.CurrentThread;
288 }
289 
291 VOID
293 {
294 #ifndef CONFIG_SMP
295  /* Check if this is the NPX Thread */
296  if (KeGetCurrentPrcb()->NpxThread == Thread)
297  {
298  /* Clear it */
299  KeGetCurrentPrcb()->NpxThread = NULL;
300  Ke386FnInit();
301  }
302 #else
303  /* Nothing to do */
304 #endif
305 }
306 
308 VOID
310 {
311  GdtEntry->BaseLow = (USHORT)((ULONG_PTR)BaseAddress & 0xFFFF);
312  GdtEntry->HighWord.Bytes.BaseMid = (UCHAR)((ULONG_PTR)BaseAddress >> 16);
313  GdtEntry->HighWord.Bytes.BaseHi = (UCHAR)((ULONG_PTR)BaseAddress >> 24);
314 }
315 
317 VOID
318 KiSetTebBase(PKPCR Pcr, PVOID TebAddress)
319 {
320  Pcr->NtTib.Self = TebAddress;
321  Ke386SetGdtEntryBase(&Pcr->GDT[KGDT_R3_TEB / sizeof(KGDTENTRY)], TebAddress);
322 }
323 
324 INIT_FUNCTION
325 VOID
326 FASTCALL
328  IN PKTSS Tss,
329  IN PKIDTENTRY Idt,
330  IN PKGDTENTRY Gdt
331 );
332 
333 INIT_FUNCTION
334 VOID
335 NTAPI
337 
338 INIT_FUNCTION
339 VOID
340 NTAPI
342 
343 INIT_FUNCTION
344 BOOLEAN
345 NTAPI
347  VOID
348 );
349 
350 INIT_FUNCTION
351 BOOLEAN
352 NTAPI
354  VOID
355 );
356 
357 INIT_FUNCTION
358 VOID
359 NTAPI
361 
362 INIT_FUNCTION
363 ULONG
364 NTAPI
366 
367 VOID
368 NTAPI
370 
371 NTSTATUS
372 NTAPI
375  IN ULONG Offset,
377 );
378 
379 VOID
380 NTAPI
382  IN FLOATING_SAVE_AREA *SaveArea
383 );
384 
385 VOID
386 NTAPI
388  IN PKTRAP_FRAME TrapFrame
389 );
390 
391 VOID
392 NTAPI
394  OUT PTEB VdmTeb
395 );
396 
397 INIT_FUNCTION
398 VOID
399 NTAPI
401  VOID
402 );
403 
404 INIT_FUNCTION
405 ULONG_PTR
406 NTAPI
409 );
410 
411 INIT_FUNCTION
412 ULONG_PTR
413 NTAPI
416 );
417 
418 BOOLEAN
419 NTAPI
421  IN PLARGE_IDENTITY_MAP IdentityMap,
422  IN PVOID StartPtr,
423  IN ULONG Length
424 );
425 
426 VOID
427 NTAPI
429  IN PLARGE_IDENTITY_MAP IdentityMap
430 );
431 
432 VOID
433 NTAPI
435  IN ULONG_PTR StartAddress,
436  IN ULONG Cr3
437 );
438 
439 INIT_FUNCTION
440 VOID
441 NTAPI
443  VOID
444 );
445 
446 INIT_FUNCTION
447 VOID
448 NTAPI
450  VOID
451 );
452 
453 INIT_FUNCTION
454 VOID
455 NTAPI
457  IN BOOLEAN FinalCpu
458 );
459 
460 INIT_FUNCTION
461 VOID
462 NTAPI
464  VOID
465 );
466 
467 INIT_FUNCTION
468 VOID
469 NTAPI
471  VOID
472 );
473 
474 INIT_FUNCTION
475 ULONG_PTR
476 NTAPI
479 );
480 
481 INIT_FUNCTION
482 ULONG_PTR
483 NTAPI
486 );
487 
488 INIT_FUNCTION
489 ULONG_PTR
490 NTAPI
493 );
494 
495 BOOLEAN
496 NTAPI
498  IN PKTRAP_FRAME TrapFrame
499 );
500 
501 BOOLEAN
502 NTAPI
504  _In_ PKTRAP_FRAME TrapFrame
505 );
506 
507 BOOLEAN
508 FASTCALL
510  IN PKTRAP_FRAME TrapFrame,
511  IN ULONG Flags
512 );
513 
514 BOOLEAN
515 FASTCALL
517  IN PKTRAP_FRAME TrapFrame
518 );
519 
521 VOID
522 FASTCALL
524  IN PKTRAP_FRAME TrapFrame
525 );
526 
527 VOID
528 FASTCALL
530  IN PKTRAP_FRAME TrapFrame
531 );
532 
533 ULONG_PTR
534 FASTCALL
536  IN PKTRAP_FRAME TrapFrame
537 );
538 
540 VOID
541 NTAPI
543  IN NTSTATUS Code,
544  IN ULONG Flags,
546  IN ULONG ParameterCount,
547  IN ULONG_PTR Parameter1,
548  IN ULONG_PTR Parameter2,
549  IN ULONG_PTR Parameter3,
550  IN PKTRAP_FRAME TrapFrame
551 );
552 
553 NTSTATUS
554 NTAPI
556  VOID
557 );
558 
559 //
560 // Global x86 only Kernel data
561 //
562 extern PVOID Ki386IopmSaveArea;
569 extern ULONG KeI386NpxPresent;
570 extern ULONG KeI386XMMIPresent;
571 extern ULONG KeI386FxsrPresent;
572 extern ULONG KiMXCsrMask;
573 extern ULONG KeI386CpuType;
574 extern ULONG KeI386CpuStep;
579 extern VOID __cdecl KiTrap08(VOID);
580 extern VOID __cdecl KiTrap13(VOID);
584 extern VOID __cdecl CopyParams(VOID);
585 extern VOID __cdecl ReadBatch(VOID);
587 extern CHAR KiSystemCallExit[];
588 extern CHAR KiSystemCallExit2[];
589 
590 //
591 // Trap Macros
592 //
593 #include "trap_x.h"
594 
595 //
596 // Returns a thread's FPU save area
597 //
601 {
602  ASSERT((ULONG_PTR)Thread->InitialStack % 16 == 0);
603  return (PFX_SAVE_AREA)((ULONG_PTR)Thread->InitialStack - sizeof(FX_SAVE_AREA));
604 }
605 
606 //
607 // Sanitizes a selector
608 //
610 ULONG
613 {
614  //
615  // Check if we're in kernel-mode, and force CPL 0 if so.
616  // Otherwise, force CPL 3.
617  //
618  return ((Mode == KernelMode) ?
619  (Cs & (0xFFFF & ~RPL_MASK)) :
620  (RPL_MASK | (Cs & 0xFFFF)));
621 }
622 
623 //
624 // Sanitizes EFLAGS
625 //
627 ULONG
630 {
631  //
632  // Check if we're in kernel-mode, and sanitize EFLAGS if so.
633  // Otherwise, also force interrupt mask on.
634  //
635  return ((Mode == KernelMode) ?
638 }
639 
640 //
641 // Sanitizes a Debug Register
642 //
644 PVOID
647 {
648  //
649  // Check if we're in kernel-mode, and return the address directly if so.
650  // Otherwise, make sure it's not inside the kernel-mode address space.
651  // If it is, then clear the address.
652  //
653  return ((Mode == KernelMode) ? DrAddress :
654  (DrAddress <= MM_HIGHEST_USER_ADDRESS) ? DrAddress : 0);
655 }
656 
657 //
658 // Exception with no arguments
659 //
662 VOID
665  IN PKTRAP_FRAME TrapFrame)
666 {
667  /* Helper for exceptions with no arguments */
668  KiDispatchExceptionFromTrapFrame(Code, 0, Address, 0, 0, 0, 0, TrapFrame);
669 }
670 
671 //
672 // Exception with one argument
673 //
676 VOID
679  IN ULONG P1,
680  IN PKTRAP_FRAME TrapFrame)
681 {
682  /* Helper for exceptions with no arguments */
683  KiDispatchExceptionFromTrapFrame(Code, 0, Address, 1, P1, 0, 0, TrapFrame);
684 }
685 
686 //
687 // Exception with two arguments
688 //
691 VOID
694  IN ULONG P1,
695  IN ULONG P2,
696  IN PKTRAP_FRAME TrapFrame)
697 {
698  /* Helper for exceptions with no arguments */
699  KiDispatchExceptionFromTrapFrame(Code, 0, Address, 2, P1, P2, 0, TrapFrame);
700 }
701 
702 //
703 // Performs a system call
704 //
705 
706  /*
707  * This sequence does a RtlCopyMemory(Stack - StackBytes, Arguments, StackBytes)
708  * and then calls the function associated with the system call.
709  *
710  * It's done in assembly for two reasons: we need to muck with the stack,
711  * and the call itself restores the stack back for us. The only way to do
712  * this in C is to do manual C handlers for every possible number of args on
713  * the stack, and then have the handler issue a call by pointer. This is
714  * wasteful since it'll basically push the values twice and require another
715  * level of call indirection.
716  *
717  * The ARM kernel currently does this, but it should probably be changed
718  * later to function like this as well.
719  *
720  */
721 #ifdef __GNUC__
723 NTSTATUS
724 KiSystemCallTrampoline(IN PVOID Handler,
725  IN PVOID Arguments,
726  IN ULONG StackBytes)
727 {
729 
730  __asm__ __volatile__
731  (
732  "subl %1, %%esp\n\t"
733  "movl %%esp, %%edi\n\t"
734  "movl %2, %%esi\n\t"
735  "shrl $2, %1\n\t"
736  "rep movsd\n\t"
737  "call *%3\n\t"
738  "movl %%eax, %0"
739  : "=r"(Result)
740  : "c"(StackBytes),
741  "d"(Arguments),
742  "r"(Handler)
743  : "%esp", "%esi", "%edi"
744  );
745  return Result;
746 }
747 #elif defined(_MSC_VER)
749 NTSTATUS
750 KiSystemCallTrampoline(IN PVOID Handler,
751  IN PVOID Arguments,
752  IN ULONG StackBytes)
753 {
754  __asm
755  {
756  mov ecx, StackBytes
757  mov esi, Arguments
758  mov eax, Handler
759  sub esp, ecx
760  mov edi, esp
761  shr ecx, 2
762  rep movsd
763  call eax
764  }
765  /* Return with result in EAX */
766 }
767 #else
768 #error Unknown Compiler
769 #endif
770 
771 
772 //
773 // Checks for pending APCs
774 //
776 VOID
778 {
780  KIRQL OldIrql;
781 
782  /* Check for V8086 or user-mode trap */
783  if ((TrapFrame->EFlags & EFLAGS_V86_MASK) || (KiUserTrap(TrapFrame)))
784  {
785  /* Get the thread */
787  while (TRUE)
788  {
789  /* Turn off the alerted state for kernel mode */
790  Thread->Alerted[KernelMode] = FALSE;
791 
792  /* Are there pending user APCs? */
793  if (!Thread->ApcState.UserApcPending) break;
794 
795  /* Raise to APC level and enable interrupts */
797  _enable();
798 
799  /* Deliver APCs */
800  KiDeliverApc(UserMode, NULL, TrapFrame);
801 
802  /* Restore IRQL and disable interrupts once again */
804  _disable();
805  }
806  }
807 }
808 
809 //
810 // Switches from boot loader to initial kernel stack
811 //
812 INIT_FUNCTION
814 VOID
816 {
817  INIT_FUNCTION VOID NTAPI KiSystemStartupBootStack(VOID);
818 
819  /* We have to switch to a new stack before continuing kernel initialization */
820 #ifdef __GNUC__
821  __asm__
822  (
823  "movl %0, %%esp\n\t"
824  "subl %1, %%esp\n\t"
825  "pushl %2\n\t"
826  "jmp _KiSystemStartupBootStack@0"
827  :
828  : "c"(InitialStack),
830  "i"(CR0_EM | CR0_TS | CR0_MP),
832  : "%esp"
833  );
834 #elif defined(_MSC_VER)
835  __asm
836  {
837  mov esp, InitialStack
839  push (CR0_EM | CR0_TS | CR0_MP)
841  }
842 #else
843 #error Unknown Compiler
844 #endif
845 }
846 
847 //
848 // Emits the iret instruction for C code
849 //
852 VOID
854 {
855 #if defined(__GNUC__)
856  __asm__ __volatile__
857  (
858  "iret"
859  );
860 #elif defined(_MSC_VER)
861  __asm
862  {
863  iretd
864  }
865 #else
866 #error Unsupported compiler
867 #endif
868  UNREACHABLE;
869 }
870 
871 //
872 // Normally this is done by the HAL, but on x86 as an optimization, the kernel
873 // initiates the end by calling back into the HAL and exiting the trap here.
874 //
876 VOID
878  IN PKTRAP_FRAME TrapFrame)
879 {
880  /* Disable interrupts and end the interrupt */
881  _disable();
882  HalEndSystemInterrupt(Irql, TrapFrame);
883 
884  /* Exit the interrupt */
885  KiEoiHelper(TrapFrame);
886 }
887 
888 //
889 // PERF Code
890 //
892 VOID
894 {
897  DbgPrint("Boot took %I64u cycles!\n", BootCyclesEnd - BootCycles);
898  DbgPrint("Interrupts: %u System Calls: %u Context Switches: %u\n",
899  KeGetCurrentPrcb()->InterruptCount,
900  KeGetCurrentPrcb()->KeSystemCalls,
902 }
903 
905 PULONG
907 {
909 }
910 
911 #endif
VOID NTAPI ExpInterlockedPopEntrySListResume(VOID)
#define CR0_MP
Definition: asm.h:246
KV86_FRAME V86Frame
Definition: ke.h:163
struct _NT_TIB * Self
Definition: compat.h:380
#define MM_HIGHEST_USER_ADDRESS
Definition: armddk.h:17
#define IN
Definition: typedefs.h:38
INIT_FUNCTION BOOLEAN NTAPI KiIsNpxPresent(VOID)
Definition: cpu.c:1164
VOID NTAPI HalEndSystemInterrupt(IN KIRQL OldIrql, IN PKTRAP_FRAME TrapFrame)
Definition: pic.c:335
#define TRUE
Definition: types.h:120
BOOLEAN KiI386PentiumLockErrataPresent
Definition: cpu.c:40
UCHAR SkipSegments
Definition: ke.h:84
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:692
struct _Entry Entry
Definition: kefuncs.h:640
CHAR KiSystemCallExit2[]
#define __cdecl
Definition: accygwin.h:79
_In_ ULONG Mode
Definition: hubbusif.h:303
#define DbgPrint
Definition: loader.c:25
ULONG_PTR StartAddress
Definition: ke.h:173
FX_SAVE_AREA NpxArea
Definition: ke.h:162
ecx edi ebx edx edi decl ecx esi eax jecxz decl eax andl eax esi movl edx movl TEMP incl eax andl eax ecx incl ebx eax jnz xchgl ecx incl TEMP esi
Definition: synth_sse3d.h:103
INIT_FUNCTION ULONG_PTR NTAPI Ki386EnableFxsr(IN ULONG_PTR Context)
Definition: cpu.c:1055
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
USHORT BaseLow
Definition: ketypes.h:334
struct _KV8086_STACK_FRAME * PKV8086_STACK_FRAME
#define NPX_FRAME_LENGTH
Definition: asm.h:244
ULONGLONG BootCycles
Definition: kiinit.c:30
ULONG KiFastSystemCallDisable
Definition: cpu.c:26
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:628
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:125
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1062
ULONG KeI386EFlagsOrMaskV86
Definition: v86vdm.c:22
struct _KIPCR * PKIPCR
#define CR0_TS
Definition: asm.h:248
INIT_FUNCTION VOID NTAPI KiInitializeMTRR(IN BOOLEAN FinalCpu)
Definition: mtrr.c:22
INIT_FUNCTION VOID NTAPI KiInitializePAT(VOID)
Definition: patpge.c:61
VOID NTAPI Ki386AdjustEsp0(IN PKTRAP_FRAME TrapFrame)
Definition: exp.c:280
DECLSPEC_NORETURN VOID __cdecl KiTrap02(VOID)
Definition: traphdlr.c:461
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:1100
PVOID PcrTeb
Definition: ke.h:153
PPC_QUAL unsigned long long __rdtsc(void)
Definition: intrin_ppc.h:688
FORCEINLINE PVOID Ke386SanitizeDr(IN PVOID DrAddress, IN KPROCESSOR_MODE Mode)
Definition: ke.h:645
PKTRAP_FRAME TrapFrame
Definition: ketypes.h:1664
ULONG KeI386NpxPresent
Definition: cpu.c:31
#define KTRAP_FRAME_LENGTH
Definition: asm.h:126
Definition: ke.h:280
__INTRIN_INLINE unsigned long __readcr3(void)
Definition: intrin_x86.h:1706
union _KTRAP_EXIT_SKIP_BITS KTRAP_EXIT_SKIP_BITS
#define KTRAP_FRAME_ALIGN
Definition: asm.h:125
#define FASTCALL
Definition: nt_native.h:50
union _KTRAP_EXIT_SKIP_BITS * PKTRAP_EXIT_SKIP_BITS
_Out_ PKIRQL Irql
Definition: csq.h:179
union _KGDTENTRY::@2323 HighWord
DECLSPEC_NORETURN VOID FASTCALL KiEoiHelper(IN PKTRAP_FRAME TrapFrame)
Definition: traphdlr.c:126
struct _KGDTENTRY::@2323::@2324 Bytes
INIT_FUNCTION VOID FASTCALL Ki386InitializeTss(IN PKTSS Tss, IN PKIDTENTRY Idt, IN PKGDTENTRY Gdt)
Definition: cpu.c:799
#define DECLSPEC_NORETURN
Definition: ntbasedef.h:176
FORCEINLINE PVOID KeQueryInterruptHandler(IN ULONG Vector)
Definition: ke.h:268
ULONG KeI386FxsrPresent
Definition: cpu.c:31
#define EFLAGS_V86_MASK
Definition: ketypes.h:129
uint32_t ULONG_PTR
Definition: typedefs.h:63
UCHAR KIRQL
Definition: env_spec_w32.h:591
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
__INTRIN_INLINE void __writecr3(unsigned int Data)
Definition: intrin_x86.h:1675
VOID NTAPI INIT_FUNCTION KiSystemStartupBootStack(VOID)
Definition: krnlinit.c:57
__INTRIN_INLINE uintptr_t __readeflags(void)
Definition: intrin_x86.h:1555
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
PVOID ThreadStack
Definition: ke.h:151
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
UCHAR Reserved
Definition: ke.h:86
ULONG PagesCount
Definition: ke.h:174
NTKERNELAPI KIRQL NTAPI KfRaiseIrql(IN KIRQL NewIrql)
Definition: pic.c:187
__asm__("\t.globl GetPhys\n" "GetPhys:\t\n" "mflr 0\n\t" "stwu 0,-16(1)\n\t" "mfmsr 5\n\t" "andi. 6,5,0xffef\n\t" "mtmsr 6\n\t" "isync\n\t" "sync\n\t" "lwz 3,0(3)\n\t" "mtmsr 5\n\t" "isync\n\t" "sync\n\t" "lwz 0,0(1)\n\t" "addi 1,1,16\n\t" "mtlr 0\n\t" "blr")
FORCEINLINE PRKTHREAD KeGetCurrentThread(VOID)
Definition: ke.h:284
#define EFLAGS_USER_SANITIZE
Definition: ketypes.h:133
INIT_FUNCTION ULONG_PTR NTAPI Ki386EnableXMMIExceptions(IN ULONG_PTR Context)
Definition: cpu.c:1065
#define RPL_MASK
Definition: ketypes.h:69
unsigned char BOOLEAN
NTSTATUS NTAPI KiConvertToGuiThread(VOID)
struct _KV86_FRAME KV86_FRAME
smooth NULL
Definition: ftsmooth.c:416
static WCHAR Address[46]
Definition: ping.c:68
#define FORCEINLINE
Definition: ntbasedef.h:221
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
VOID NTAPI Ki386FreeIdentityMap(IN PLARGE_IDENTITY_MAP IdentityMap)
Definition: ketypes.h:787
FORCEINLINE BOOLEAN KeDisableInterrupts(VOID)
Definition: ke.h:176
FORCEINLINE VOID Ki386PerfEnd(VOID)
Definition: ke.h:893
ULONG KeI386XMMIPresent
Definition: cpu.c:30
FORCEINLINE VOID Ke386SetGdtEntryBase(PKGDTENTRY GdtEntry, PVOID BaseAddress)
Definition: ke.h:309
#define MAXIMUM_IDTVECTOR
Definition: asm.h:277
ULONGLONG BootCyclesEnd
Definition: kiinit.c:30
VOID __cdecl CopyParams(VOID)
UCHAR SkipPreviousMode
Definition: ke.h:83
ULONG KiMXCsrMask
Definition: cpu.c:28
VOID NTAPI ExpInterlockedPopEntrySListFault(VOID)
#define PtrToUlong(u)
Definition: config.h:107
INIT_FUNCTION VOID NTAPI KeI386VdmInitialize(VOID)
Definition: stubs.c:156
INIT_FUNCTION ULONG_PTR NTAPI Ki386EnableGlobalPage(IN ULONG_PTR Context)
Definition: patpge.c:23
FORCEINLINE PFX_SAVE_AREA KiGetThreadNpxArea(IN PKTHREAD Thread)
Definition: ke.h:600
#define Code
Definition: deflate.h:80
UCHAR KiDebugRegisterTrapOffsets[9]
FORCEINLINE VOID KiCheckForApcDelivery(IN PKTRAP_FRAME TrapFrame)
Definition: ke.h:777
FORCEINLINE VOID KeInvalidateTlbEntry(IN PVOID Address)
Definition: ke.h:201
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
ecx edi ebx edx edi decl ecx esi eax jecxz decl eax andl eax esi movl eax
Definition: synth_sse3d.h:85
ecx edi ebx edx edi decl ecx esi eax jecxz decl eax andl eax esi movl edx movl TEMP incl eax andl eax ecx incl ebx eax jnz xchgl ecx incl TEMP esp ecx subl ebx pushl ecx ecx edx ecx ecx mm0 mm4 mm0 mm4 mm1 mm5 mm1 mm5 mm2 mm6 mm2 mm6 mm3 mm7 mm3 mm7 paddd mm0 paddd mm4 paddd mm0 paddd mm4 paddd mm0 paddd mm4 movq mm1 movq mm5 mm1 mm5 paddd mm0 paddd mm4 mm0 mm4 packssdw mm0 packssdw mm4 mm1 punpckldq mm0 pand mm1 pand mm0 por mm1 movq edi esi edx edi decl ecx jnz popl ecx ecx jecxz mm0 mm0 mm1 mm1 mm2 mm2 mm3 mm3 paddd mm0 paddd mm0 paddd mm0 movq mm1 mm1 paddd mm0 mm0 packssdw mm0 movd eax movw edi esi edx edi
Definition: synth_sse3d.h:185
C_ASSERT(NPX_FRAME_LENGTH==sizeof(FX_SAVE_AREA))
INIT_FUNCTION ULONG_PTR NTAPI Ki386EnableTargetLargePage(IN ULONG_PTR Context)
Definition: patpge.c:70
uint64_t ULONGLONG
Definition: typedefs.h:65
#define APC_LEVEL
ULONG HardwareEsp
Definition: ketypes.h:268
ULONG KeI386CpuType
Definition: cpu.c:28
#define KGDT_R3_TEB
Definition: ketypes.h:80
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
VOID KiGetCacheInformation(VOID)
Definition: cpu.c:214
INIT_FUNCTION VOID NTAPI KiAmdK6InitializeMTRR(VOID)
Definition: mtrr.c:31
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
USHORT Offset
Definition: ketypes.h:384
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
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
USHORT ExtendedOffset
Definition: ketypes.h:387
PVOID ThreadTeb
Definition: ke.h:152
FORCEINLINE DECLSPEC_NORETURN VOID KiIret(VOID)
Definition: ke.h:853
unsigned char UCHAR
Definition: xmlstorage.h:181
ULONG KeI386CpuStep
Definition: cpu.c:29
NTSTATUS NTAPI Ke386GetGdtEntryThread(IN PKTHREAD Thread, IN ULONG Offset, IN PKGDTENTRY Descriptor)
Definition: ldt.c:26
VOID NTAPI Ki386SetupAndExitToV86Mode(OUT PTEB VdmTeb)
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:803
VOID FASTCALL Ki386BiosCallReturnAddress(IN PKTRAP_FRAME TrapFrame)
ULONG_PTR FASTCALL KiExitV86Mode(IN PKTRAP_FRAME TrapFrame)
Definition: v86vdm.c:468
PVOID Ki386IopmSaveArea
Definition: v86vdm.c:23
VOID KiSwitchToBootStack(IN ULONG_PTR InitialStack)
Definition: ke.h:815
NT_TIB NtTib
Definition: ke.h:284
struct _LARGE_IDENTITY_MAP LARGE_IDENTITY_MAP
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical 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:656
FORCEINLINE PULONG KiGetUserModeStackAddress(void)
Definition: ke.h:906
UCHAR KiDebugRegisterContextOffsets[9]
FORCEINLINE ULONG Ke386SanitizeSeg(IN ULONG Cs, IN KPROCESSOR_MODE Mode)
Definition: ke.h:611
INIT_FUNCTION VOID NTAPI KiSetCR0Bits(VOID)
Definition: cpu.c:728
FORCEINLINE PKPCR KeGetPcr(VOID)
Definition: ke.h:318
FORCEINLINE VOID KeRegisterInterruptHandler(IN ULONG Vector, IN PVOID Handler)
Definition: ke.h:242
KIDTENTRY KiIdt[MAXIMUM_IDTVECTOR+1]
Definition: except.c:50
#define _In_
Definition: no_sal2.h:204
PUSHORT GDT
Definition: ke.h:53
ULONG_PTR SIZE_T
Definition: typedefs.h:78
VOID __cdecl ReadBatch(VOID)
INIT_FUNCTION ULONG_PTR NTAPI Ki386EnableDE(IN ULONG_PTR Context)
Definition: cpu.c:1045
Definition: compat.h:484
FORCEINLINE DECLSPEC_NORETURN VOID KiDispatchException0Args(IN NTSTATUS Code, IN ULONG_PTR Address, IN PKTRAP_FRAME TrapFrame)
Definition: ke.h:663
struct _KV86_FRAME * PKV86_FRAME
FORCEINLINE DECLSPEC_NORETURN VOID KiDispatchException1Args(IN NTSTATUS Code, IN ULONG_PTR Address, IN ULONG P1, IN PKTRAP_FRAME TrapFrame)
Definition: ke.h:677
VOID __cdecl KiTrap08(VOID)
unsigned short USHORT
Definition: pedump.c:61
PHARDWARE_PTE TopLevelDirectory
Definition: ke.h:171
BOOLEAN NTAPI VdmDispatchPageFault(_In_ PKTRAP_FRAME TrapFrame)
Definition: vdmexec.c:367
PVOID PagesList[30]
Definition: ke.h:175
ULONG KeI386EFlagsAndMaskV86
Definition: v86vdm.c:21
NTKERNELAPI VOID NTAPI KfLowerIrql(IN KIRQL NewIrql)
Definition: pic.c:232
VOID NTAPI KiFlushNPXState(IN FLOATING_SAVE_AREA *SaveArea)
FORCEINLINE VOID KeRestoreInterrupts(BOOLEAN WereEnabled)
Definition: ke.h:191
UCHAR SkipVolatiles
Definition: ke.h:85
FORCEINLINE VOID KiRundownThread(IN PKTHREAD Thread)
Definition: ke.h:230
unsigned int * PULONG
Definition: retypes.h:1
VOID FORCEINLINE KiEndInterrupt(IN KIRQL Irql, IN PKTRAP_FRAME TrapFrame)
Definition: ke.h:295
BOOLEAN NTAPI VdmDispatchBop(IN PKTRAP_FRAME TrapFrame)
Definition: vdmexec.c:313
KDESCRIPTOR KiIdtDescriptor
Definition: except.c:51
FORCEINLINE VOID KeFlushProcessTb(VOID)
Definition: ke.h:209
__INTRIN_INLINE void __invlpg(void *Address)
Definition: intrin_x86.h:1865
INIT_FUNCTION VOID NTAPI KiI386PentiumLockErrataFixup(VOID)
Definition: cpu.c:1088
#define OUT
Definition: typedefs.h:39
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
unsigned int ULONG
Definition: retypes.h:1
CHAR KiSystemCallExitBranch[]
FORCEINLINE VOID KiSetTebBase(PKPCR Pcr, PVOID TebAddress)
Definition: ke.h:318
struct _LARGE_IDENTITY_MAP * PLARGE_IDENTITY_MAP
VOID __cdecl KiFastCallEntry(VOID)
#define ULONG_PTR
Definition: config.h:101
static void push(calc_node_t *op)
Definition: rpn_ieee.c:113
VOID KiSetProcessorType(VOID)
Definition: cpu.c:55
INIT_FUNCTION VOID NTAPI KiRestoreFastSyscallReturnState(VOID)
Definition: cpu.c:1011
BOOLEAN KeI386VirtualIntExtensions
Definition: v86vdm.c:24
PKIDTENTRY IDT
Definition: ketypes.h:756
CHAR KiSystemCallExit[]
INIT_FUNCTION BOOLEAN NTAPI KiIsNpxErrataPresent(VOID)
Definition: cpu.c:1205
VOID NTAPI KiDeliverApc(IN KPROCESSOR_MODE DeliveryMode, IN PKEXCEPTION_FRAME ExceptionFrame, IN PKTRAP_FRAME TrapFrame)
Definition: apc.c:302
#define KeGetContextSwitches(Prcb)
Definition: ke.h:56
base of all file and directory entries
Definition: entries.h:82
FORCEINLINE VOID KeSweepICache(IN PVOID BaseAddress, IN SIZE_T FlushSize)
Definition: ke.h:217
#define CR0_EM
Definition: asm.h:247
BOOLEAN FORCEINLINE KiUserTrap(IN PKTRAP_FRAME TrapFrame)
Definition: ke.h:305
KTRAP_FRAME TrapFrame
Definition: ke.h:161
#define EFLAGS_INTERRUPT_MASK
Definition: ketypes.h:126
jmp_buf jmp
Definition: mach.c:36
#define HalVectorToIDTEntry
Definition: halfuncs.h:51
_In_ PSTORAGE_PROPERTY_ID _Outptr_ PSTORAGE_DESCRIPTOR_HEADER * Descriptor
Definition: classpnp.h:966