ReactOS 0.4.15-dev-5829-g6b6a045
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
8extern "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
36VOID
38{
39 Context->Eip = ProgramCounter;
40}
41
45{
46 return Context->Eax;
47}
48
50VOID
52{
53 Context->Eax = ReturnValue;
54}
55
59{
60 return Context->Ebp;
61}
62
64VOID
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//
209typedef struct _KV86_FRAME
210{
215
216//
217// Virtual Stack Frame
218//
220{
225
226//
227// Large Pages Support
228//
230{
237
238//
239// Floating Point Internal Context Structure
240//
242{
248
249/* Diable interrupts and return whether they were enabled before */
253{
254 ULONG Flags;
255 BOOLEAN Return;
256
257 /* Get EFLAGS and check if the interrupt bit is set */
259 Return = (Flags & EFLAGS_INTERRUPT_MASK) ? TRUE: FALSE;
260
261 /* Disable interrupts */
262 _disable();
263 return Return;
264}
265
266/* Restore previous interrupt state */
268VOID
270{
271 if (WereEnabled) _enable();
272}
273
274//
275// Registers an interrupt handler with an IDT vector
276//
278VOID
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//
303PVOID
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//
325VOID
327{
328 /* Invalidate the TLB entry for this address */
330}
331
333VOID
335{
336 /* Flush the TLB by resetting CR3 */
338}
339
341VOID
343 IN SIZE_T FlushSize)
344{
345 //
346 // Always sweep the whole cache
347 //
349 UNREFERENCED_PARAMETER(FlushSize);
350 __wbinvd();
351}
352
356{
357 /* Return the current thread */
358 return ((PKIPCR)KeGetPcr())->PrcbData.CurrentThread;
359}
360
362VOID
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
379VOID
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
388VOID
389KiSetTebBase(PKPCR Pcr, PNT_TIB TebAddress)
390{
391 Pcr->NtTib.Self = TebAddress;
392 Ke386SetGdtEntryBase(&Pcr->GDT[KGDT_R3_TEB / sizeof(KGDTENTRY)], TebAddress);
393}
394
395CODE_SEG("INIT")
396VOID
399 IN PKTSS Tss,
400 IN PKIDTENTRY Idt,
401 IN PKGDTENTRY Gdt
402);
403
404CODE_SEG("INIT")
405VOID
406NTAPI
408
409CODE_SEG("INIT")
410VOID
411NTAPI
413
414CODE_SEG("INIT")
416NTAPI
418 VOID
419);
420
421CODE_SEG("INIT")
423NTAPI
425 VOID
426);
427
428CODE_SEG("INIT")
429VOID
430NTAPI
432
433CODE_SEG("INIT")
434ULONG
435NTAPI
437
438VOID
439NTAPI
441
443NTAPI
448);
449
450VOID
451NTAPI
453 IN FLOATING_SAVE_AREA *SaveArea
454);
455
456VOID
457NTAPI
459 IN PKTRAP_FRAME TrapFrame
460);
461
462VOID
463NTAPI
465 OUT PTEB VdmTeb
466);
467
468CODE_SEG("INIT")
469VOID
470NTAPI
472 VOID
473);
474
475CODE_SEG("INIT")
477NTAPI
480);
481
482CODE_SEG("INIT")
484NTAPI
487);
488
490NTAPI
492 IN PLARGE_IDENTITY_MAP IdentityMap,
493 IN PVOID StartPtr,
495);
496
497VOID
498NTAPI
500 IN PLARGE_IDENTITY_MAP IdentityMap
501);
502
503VOID
504NTAPI
506 IN ULONG_PTR StartAddress,
507 IN ULONG Cr3
508);
509
510CODE_SEG("INIT")
511VOID
512NTAPI
514 VOID
515);
516
517CODE_SEG("INIT")
518VOID
519NTAPI
521 VOID
522);
523
524CODE_SEG("INIT")
525VOID
526NTAPI
528 IN BOOLEAN FinalCpu
529);
530
531CODE_SEG("INIT")
532VOID
533NTAPI
535 VOID
536);
537
538CODE_SEG("INIT")
539VOID
540NTAPI
542 VOID
543);
544
545CODE_SEG("INIT")
547NTAPI
550);
551
552CODE_SEG("INIT")
554NTAPI
557);
558
559CODE_SEG("INIT")
561NTAPI
564);
565
567NTAPI
569 IN PKTRAP_FRAME TrapFrame
570);
571
573NTAPI
575 _In_ PKTRAP_FRAME TrapFrame
576);
577
581 IN PKTRAP_FRAME TrapFrame,
583);
584
588 IN PKTRAP_FRAME TrapFrame
589);
590
592VOID
595 IN PKTRAP_FRAME TrapFrame
596);
597
598VOID
601 IN PKTRAP_FRAME TrapFrame
602);
603
607 IN PKTRAP_FRAME TrapFrame
608);
609
611VOID
612NTAPI
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
625NTAPI
627 VOID
628);
629
630//
631// Global x86 only Kernel data
632//
643extern ULONG KiMXCsrMask;
644extern ULONG KeI386CpuType;
645extern ULONG KeI386CpuStep;
658extern CHAR KiSystemCallExit[];
659extern 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//
681ULONG
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//
698ULONG
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//
715PVOID
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//
733VOID
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//
747VOID
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//
762VOID
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//
777NTAPI
779 _In_ PVOID Arguments,
780 _In_ ULONG StackBytes);
781
782
783//
784// Checks for pending APCs
785//
787VOID
789{
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//
823CODE_SEG("INIT")
826VOID
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
853 }
854#else
855#error Unknown Compiler
856#endif
857
859}
860
861//
862// Emits the iret instruction for C code
863//
866VOID
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
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//
890VOID
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//
906VOID
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
919PULONG
921{
922 return &(KeGetCurrentThread()->TrapFrame->HardwareEsp);
923}
924
925#ifdef __cplusplus
926} // extern "C"
927#endif
928
929#endif
unsigned char BOOLEAN
#define __cdecl
Definition: accygwin.h:79
UINT32 void void ** ReturnValue
Definition: acevents.h:216
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
DECLSPEC_NORETURN VOID NTAPI KiSystemStartupBootStack(VOID)
Definition: krnlinit.c:58
#define MM_HIGHEST_USER_ADDRESS
Definition: armddk.h:17
LONG NTSTATUS
Definition: precomp.h:26
_Out_ PKIRQL Irql
Definition: csq.h:179
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ULONG_PTR
Definition: config.h:101
#define PtrToUlong(u)
Definition: config.h:107
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define APC_LEVEL
Definition: env_spec_w32.h:695
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
VOID NTAPI HalEndSystemInterrupt(IN KIRQL OldIrql, IN PKTRAP_FRAME TrapFrame)
Definition: pic.c:335
VOID FASTCALL KfLowerIrql(IN KIRQL NewIrql)
Definition: pic.c:232
KIRQL FASTCALL KfRaiseIrql(IN KIRQL NewIrql)
Definition: pic.c:187
#define DbgPrint
Definition: hal.h:12
#define KeGetCurrentThread
Definition: hal.h:55
_In_ ULONG Mode
Definition: hubbusif.h:303
void __cdecl _disable(void)
Definition: intrin_arm.h:365
void __cdecl _enable(void)
Definition: intrin_arm.h:373
PPC_QUAL void __wbinvd(void)
Definition: intrin_ppc.h:759
PPC_QUAL unsigned long long __rdtsc(void)
Definition: intrin_ppc.h:688
__INTRIN_INLINE unsigned long __readcr3(void)
Definition: intrin_x86.h:1818
__INTRIN_INLINE uintptr_t __readeflags(void)
Definition: intrin_x86.h:1674
__INTRIN_INLINE void __invlpg(void *Address)
Definition: intrin_x86.h:1968
__INTRIN_INLINE void __writecr3(unsigned int Data)
Definition: intrin_x86.h:1794
#define C_ASSERT(e)
Definition: intsafe.h:73
static CODE_SEG("PAGE")
Definition: isapnp.c:1482
#define ASSERT(a)
Definition: mode.c:44
#define _In_
Definition: ms_sal.h:308
#define KernelMode
Definition: asm.h:34
#define CR0_MP
Definition: asm.h:246
#define CR0_EM
Definition: asm.h:247
#define UserMode
Definition: asm.h:35
#define KTRAP_FRAME_LENGTH
Definition: asm.h:126
#define MAXIMUM_IDTVECTOR
Definition: asm.h:280
#define KTRAP_FRAME_ALIGN
Definition: asm.h:125
#define CR0_TS
Definition: asm.h:248
#define EFLAGS_INTERRUPT_MASK
Definition: ketypes.h:126
#define EFLAGS_USER_SANITIZE
Definition: ketypes.h:137
#define EFLAGS_V86_MASK
Definition: ketypes.h:132
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1080
struct _KIPCR * PKIPCR
#define RPL_MASK
Definition: ketypes.h:69
#define HalVectorToIDTEntry
Definition: halfuncs.h:51
#define NPX_FRAME_LENGTH
Definition: asm.h:246
#define KGDT_R3_TEB
Definition: ketypes.h:81
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
#define FASTCALL
Definition: nt_native.h:50
#define UNREACHABLE
#define DECLSPEC_NORETURN
Definition: ntbasedef.h:176
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
FORCEINLINE ULONG_PTR KeGetTrapFrameFrameRegister(PKTRAP_FRAME TrapFrame)
Definition: ke.h:200
DECLSPEC_NORETURN VOID KiSwitchToBootStack(IN ULONG_PTR InitialStack)
Definition: ke.h:827
ULONG KeI386NpxPresent
Definition: cpu.c:25
#define KeGetContextSwitches(Prcb)
Definition: ke.h:216
FORCEINLINE ULONG_PTR KeGetContextFrameRegister(PCONTEXT Context)
Definition: ke.h:165
ULONG KeI386XMMIPresent
Definition: cpu.c:32
FORCEINLINE VOID KeInvalidateTlbEntry(IN PVOID Address)
Definition: ke.h:264
FORCEINLINE VOID KeFlushProcessTb(VOID)
Definition: ke.h:272
FORCEINLINE VOID KeSetContextFrameRegister(PCONTEXT Context, ULONG_PTR Frame)
Definition: ke.h:172
FORCEINLINE ULONG_PTR KeGetTrapFrameStackRegister(PKTRAP_FRAME TrapFrame)
Definition: ke.h:193
VOID KiGetCacheInformation(VOID)
Definition: cpu.c:239
FORCEINLINE BOOLEAN KeDisableInterrupts(VOID)
Definition: ke.h:239
ULONG KiGetFeatureBits(VOID)
Definition: cpu.c:150
FORCEINLINE PVOID KeQueryInterruptHandler(IN ULONG Vector)
Definition: ke.h:327
FORCEINLINE VOID KeRestoreInterrupts(BOOLEAN WereEnabled)
Definition: ke.h:254
ULONG KeI386CpuType
Definition: cpu.c:22
VOID KiSetProcessorType(VOID)
Definition: cpu.c:97
FORCEINLINE VOID KiRundownThread(IN PKTHREAD Thread)
Definition: ke.h:293
ULONG KeI386FxsrPresent
Definition: cpu.c:33
FORCEINLINE BOOLEAN KiUserTrap(IN PKTRAP_FRAME TrapFrame)
Definition: ke.h:364
FORCEINLINE VOID KeSweepICache(IN PVOID BaseAddress, IN SIZE_T FlushSize)
Definition: ke.h:280
FORCEINLINE VOID KeRegisterInterruptHandler(IN ULONG Vector, IN PVOID Handler)
Definition: ke.h:301
FORCEINLINE PULONG_PTR KiGetUserModeStackAddress(void)
Definition: ke.h:465
ULONG KeI386CpuStep
Definition: cpu.c:23
#define KeSetContextReturnRegister(Context, ReturnValue)
Definition: ke.h:43
#define Ki386PerfEnd()
Definition: ke.h:174
#define KiGetLinkedTrapFrame(x)
Definition: ke.h:177
#define KeSetContextPc(Context, ProgramCounter)
Definition: ke.h:34
#define KeGetContextPc(Context)
Definition: ke.h:31
#define KeGetContextReturnRegister(Context)
Definition: ke.h:40
#define KeGetTrapFramePc(TrapFrame)
Definition: ke.h:37
#define KiEndInterrupt(x, y)
Definition: ke.h:175
struct _LARGE_IDENTITY_MAP LARGE_IDENTITY_MAP
BOOLEAN NTAPI VdmDispatchPageFault(_In_ PKTRAP_FRAME TrapFrame)
Definition: vdmexec.c:367
PVOID Ki386IopmSaveArea
Definition: v86vdm.c:23
BOOLEAN NTAPI VdmDispatchBop(IN PKTRAP_FRAME TrapFrame)
Definition: vdmexec.c:313
FORCEINLINE ULONG Ke386SanitizeFlags(IN ULONG Eflags, IN KPROCESSOR_MODE Mode)
Definition: ke.h:699
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
VOID NTAPI KiInitializePAT(VOID)
Definition: patpge.c:61
VOID NTAPI ExpInterlockedPopEntrySListResume(VOID)
BOOLEAN FASTCALL KiVdmOpcodePrefix(IN PKTRAP_FRAME TrapFrame, IN ULONG Flags)
Definition: v86vdm.c:442
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
VOID FASTCALL Ki386InitializeTss(IN PKTSS Tss, IN PKIDTENTRY Idt, IN PKGDTENTRY Gdt)
Definition: cpu.c:799
BOOLEAN FASTCALL Ki386HandleOpcodeV86(IN PKTRAP_FRAME TrapFrame)
Definition: v86vdm.c:456
ULONG_PTR NTAPI Ki386EnableTargetLargePage(IN ULONG_PTR Context)
Definition: patpge.c:70
VOID NTAPI KiFlushNPXState(IN FLOATING_SAVE_AREA *SaveArea)
ULONG KiFastSystemCallDisable
Definition: cpu.c:28
struct _KV86_FRAME KV86_FRAME
VOID __cdecl KiTrap13(VOID)
UCHAR KiDebugRegisterContextOffsets[9]
VOID __cdecl KiTrap02(VOID)
UCHAR KiDebugRegisterTrapOffsets[9]
VOID __cdecl KiTrap08(VOID)
struct _KV8086_STACK_FRAME KV8086_STACK_FRAME
union _KTRAP_EXIT_SKIP_BITS * PKTRAP_EXIT_SKIP_BITS
BOOLEAN KeI386VirtualIntExtensions
Definition: v86vdm.c:24
struct _LARGE_IDENTITY_MAP * PLARGE_IDENTITY_MAP
ULONG KeI386EFlagsAndMaskV86
Definition: v86vdm.c:21
struct _FLOATING_SAVE_CONTEXT * PFLOATING_SAVE_CONTEXT
NTSTATUS NTAPI Ke386GetGdtEntryThread(IN PKTHREAD Thread, IN ULONG Offset, IN PKGDTENTRY Descriptor)
Definition: ldt.c:26
DECLSPEC_NORETURN VOID FASTCALL KiEoiHelper(IN PKTRAP_FRAME TrapFrame)
Definition: traphdlr.c:126
union _KTRAP_EXIT_SKIP_BITS KTRAP_EXIT_SKIP_BITS
VOID __cdecl KiFastCallEntry(VOID)
VOID NTAPI KiI386PentiumLockErrataFixup(VOID)
Definition: cpu.c:1088
BOOLEAN NTAPI KiIsNpxErrataPresent(VOID)
Definition: cpu.c:1159
CHAR KiSystemCallExitBranch[]
struct _KV86_FRAME * PKV86_FRAME
ULONG_PTR NTAPI Ki386EnableXMMIExceptions(IN ULONG_PTR Context)
Definition: cpu.c:1065
VOID NTAPI KiAmdK6InitializeMTRR(VOID)
Definition: mtrr.c:31
ULONG_PTR NTAPI Ki386EnableFxsr(IN ULONG_PTR Context)
Definition: cpu.c:1055
VOID __cdecl ReadBatch(VOID)
BOOLEAN NTAPI Ki386CreateIdentityMap(IN PLARGE_IDENTITY_MAP IdentityMap, IN PVOID StartPtr, IN ULONG Length)
FORCEINLINE DECLSPEC_NORETURN VOID KiDispatchException0Args(IN NTSTATUS Code, IN ULONG_PTR Address, IN PKTRAP_FRAME TrapFrame)
Definition: ke.h:734
ULONG KeI386EFlagsOrMaskV86
Definition: v86vdm.c:22
CHAR KiSystemCallExit[]
VOID NTAPI Ki386EnableCurrentLargePage(IN ULONG_PTR StartAddress, IN ULONG Cr3)
VOID NTAPI KiRestoreFastSyscallReturnState(VOID)
Definition: cpu.c:1011
FORCEINLINE VOID KiSetTebBase(PKPCR Pcr, PNT_TIB TebAddress)
Definition: ke.h:389
BOOLEAN KiI386PentiumLockErrataPresent
Definition: cpu.c:42
VOID __cdecl CopyParams(VOID)
ULONG_PTR NTAPI Ki386EnableGlobalPage(IN ULONG_PTR Context)
Definition: patpge.c:23
VOID NTAPI Ki386FreeIdentityMap(IN PLARGE_IDENTITY_MAP IdentityMap)
ULONG KiMXCsrMask
Definition: cpu.c:30
VOID NTAPI KiInitializeMTRR(IN BOOLEAN FinalCpu)
Definition: mtrr.c:22
NTSTATUS NTAPI KiSystemCallTrampoline(_In_ PVOID Handler, _In_ PVOID Arguments, _In_ ULONG StackBytes)
VOID NTAPI KiSetCR0Bits(VOID)
Definition: cpu.c:728
VOID NTAPI Ki386SetupAndExitToV86Mode(OUT PTEB VdmTeb)
FORCEINLINE DECLSPEC_NORETURN VOID KiDispatchException1Args(IN NTSTATUS Code, IN ULONG_PTR Address, IN ULONG P1, IN PKTRAP_FRAME TrapFrame)
Definition: ke.h:748
KIDTENTRY KiIdt[MAXIMUM_IDTVECTOR+1]
Definition: except.c:50
VOID NTAPI Ki386AdjustEsp0(IN PKTRAP_FRAME TrapFrame)
Definition: exp.c:280
FORCEINLINE PFX_SAVE_AREA KiGetThreadNpxArea(IN PKTHREAD Thread)
Definition: ke.h:671
FORCEINLINE PVOID Ke386SanitizeDr(IN PVOID DrAddress, IN KPROCESSOR_MODE Mode)
Definition: ke.h:716
ULONG_PTR FASTCALL KiExitV86Mode(IN PKTRAP_FRAME TrapFrame)
Definition: v86vdm.c:468
NTSTATUS NTAPI KiConvertToGuiThread(VOID)
struct _FLOATING_SAVE_CONTEXT FLOATING_SAVE_CONTEXT
FORCEINLINE DECLSPEC_NORETURN VOID KiIret(VOID)
Definition: ke.h:867
struct _KV8086_STACK_FRAME * PKV8086_STACK_FRAME
FORCEINLINE VOID Ke386SetGdtEntryBase(PKGDTENTRY GdtEntry, PVOID BaseAddress)
Definition: ke.h:380
CHAR KiSystemCallExit2[]
BOOLEAN NTAPI KiIsNpxPresent(VOID)
VOID FASTCALL Ki386BiosCallReturnAddress(IN PKTRAP_FRAME TrapFrame)
KDESCRIPTOR KiIdtDescriptor
Definition: except.c:51
ULONG_PTR NTAPI Ki386EnableDE(IN ULONG_PTR Context)
Definition: cpu.c:1045
FORCEINLINE ULONG Ke386SanitizeSeg(IN ULONG Cs, IN KPROCESSOR_MODE Mode)
Definition: ke.h:682
VOID NTAPI KeI386VdmInitialize(VOID)
Definition: vdmmain.c:42
FORCEINLINE VOID KiCheckForApcDelivery(IN PKTRAP_FRAME TrapFrame)
Definition: ke.h:788
VOID NTAPI ExpInterlockedPopEntrySListFault(VOID)
VOID NTAPI KiThreadStartup(VOID)
Definition: thrdini.c:63
ULONGLONG BootCyclesEnd
Definition: ke.h:153
ULONGLONG BootCycles
Definition: kiinit.c:37
VOID NTAPI KiDeliverApc(IN KPROCESSOR_MODE DeliveryMode, IN PKEXCEPTION_FRAME ExceptionFrame, IN PKTRAP_FRAME TrapFrame)
Definition: apc.c:302
unsigned short USHORT
Definition: pedump.c:61
static WCHAR Address[46]
Definition: ping.c:68
__asm__(".p2align 4, 0x90\n" ".seh_proc __seh2_global_filter_func\n" "__seh2_global_filter_func:\n" "\tpush %rbp\n" "\t.seh_pushreg %rbp\n" "\tsub $32, %rsp\n" "\t.seh_stackalloc 32\n" "\t.seh_endprologue\n" "\tmov %rdx, %rbp\n" "\tjmp *%rax\n" "__seh2_global_filter_func_exit:\n" "\t.p2align 4\n" "\tadd $32, %rsp\n" "\tpop %rbp\n" "\tret\n" "\t.seh_endproc")
static void push(calc_node_t *op)
Definition: rpn_ieee.c:113
#define KeGetPcr()
Definition: ke.h:26
base of all file and directory entries
Definition: entries.h:83
PKTHREAD CurrentThread
Definition: ke.h:243
PFX_SAVE_AREA PfxSaveArea
Definition: ke.h:246
PFX_SAVE_AREA Buffer
Definition: ke.h:245
KIRQL OldNpxIrql
Definition: ke.h:244
struct _KGDTENTRY::@2420::@2421 Bytes
USHORT BaseLow
Definition: ketypes.h:337
union _KGDTENTRY::@2420 HighWord
USHORT Offset
Definition: ketypes.h:387
USHORT ExtendedOffset
Definition: ketypes.h:390
PKIDTENTRY IDT
Definition: ketypes.h:759
Definition: ke.h:290
NT_TIB NtTib
Definition: ke.h:293
PUSHORT GDT
Definition: ke.h:54
ULONG TempEsp
Definition: ketypes.h:247
ULONG Ebp
Definition: ketypes.h:266
ULONG PreviousPreviousMode
Definition: ketypes.h:260
ULONG HardwareEsp
Definition: ketypes.h:271
ULONG Eip
Definition: ketypes.h:268
ULONG Edx
Definition: ketypes.h:257
Definition: ketypes.h:791
KTRAP_FRAME TrapFrame
Definition: ke.h:221
KV86_FRAME V86Frame
Definition: ke.h:223
FX_SAVE_AREA NpxArea
Definition: ke.h:222
PVOID ThreadTeb
Definition: ke.h:212
PVOID PcrTeb
Definition: ke.h:213
PVOID ThreadStack
Definition: ke.h:211
ULONG_PTR StartAddress
Definition: ke.h:233
PVOID PagesList[30]
Definition: ke.h:235
PHARDWARE_PTE TopLevelDirectory
Definition: ke.h:231
ULONG PagesCount
Definition: ke.h:234
struct _NT_TIB * Self
Definition: compat.h:720
Definition: compat.h:836
uint32_t * PULONG
Definition: typedefs.h:59
#define NTAPI
Definition: typedefs.h:36
ULONG_PTR SIZE_T
Definition: typedefs.h:80
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
uint64_t ULONGLONG
Definition: typedefs.h:67
#define OUT
Definition: typedefs.h:40
UCHAR SkipSegments
Definition: ke.h:144
UCHAR SkipPreviousMode
Definition: ke.h:143
UCHAR Reserved
Definition: ke.h:146
UCHAR SkipVolatiles
Definition: ke.h:145
_In_ UCHAR _In_ UCHAR _In_ ULONG Code
Definition: wdfdevice.h:1701
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:342
#define FORCEINLINE
Definition: wdftypes.h:67
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:792
CCHAR KPROCESSOR_MODE
Definition: ketypes.h:7
unsigned char UCHAR
Definition: xmlstorage.h:181
char CHAR
Definition: xmlstorage.h:175