ReactOS  0.4.15-dev-5446-g3f3714b
thrdini.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS kernel
4  * FILE: ntoskrnl/ke/i386/thrdini.c
5  * PURPOSE: i386 Thread Context Creation
6  * PROGRAMMER: Alex Ionescu (alex@relsoft.net)
7  */
8 
9 /* INCLUDES ******************************************************************/
10 
11 #include <ntoskrnl.h>
12 #define NDEBUG
13 #include <debug.h>
14 
15 typedef struct _KSWITCHFRAME
16 {
19  PVOID RetAddr;
21 
22 typedef struct _KSTART_FRAME
23 {
29 
30 typedef struct _KUINIT_FRAME
31 {
37 
38 typedef struct _KKINIT_FRAME
39 {
44 
45 VOID
48  IN PKTHREAD OldThread,
49  IN PKTHREAD NewThread
50 );
51 
52 VOID
55  IN PKPRCB Prcb,
56  IN PVOID DpcStack
57 );
58 
59 /* FUNCTIONS *****************************************************************/
60 
61 VOID
62 NTAPI
64 {
65  PKTRAP_FRAME TrapFrame;
66  PKSTART_FRAME StartFrame;
67  PKUINIT_FRAME InitFrame;
68 
69  /* Get the start and trap frames */
70  InitFrame = KeGetCurrentThread()->KernelStack;
71  StartFrame = &InitFrame->StartFrame;
72  TrapFrame = &InitFrame->TrapFrame;
73 
74  /* Lower to APC level */
76 
77  /* Call the system routine */
78  StartFrame->SystemRoutine(StartFrame->StartRoutine, StartFrame->StartContext);
79 
80  /* If we returned, we better be a user thread */
81  if (!StartFrame->UserThread)
82  {
83  KeBugCheck(NO_USER_MODE_CONTEXT);
84  }
85 
86  /* Exit to user-mode */
87  KiServiceExit2(TrapFrame);
88 }
89 
90 VOID
91 NTAPI
93  IN PKSYSTEM_ROUTINE SystemRoutine,
95  IN PVOID StartContext,
97 {
98  PFX_SAVE_AREA FxSaveArea;
99  PFXSAVE_FORMAT FxSaveFormat;
100  PKSTART_FRAME StartFrame;
101  PKSWITCHFRAME CtxSwitchFrame;
102  PKTRAP_FRAME TrapFrame;
103  CONTEXT LocalContext;
105  ULONG ContextFlags;
106 
107  /* Check if this is a With-Context Thread */
108  if (ContextPointer)
109  {
110  /* Set up the Initial Frame */
111  PKUINIT_FRAME InitFrame;
112  InitFrame = (PKUINIT_FRAME)((ULONG_PTR)Thread->InitialStack -
113  sizeof(KUINIT_FRAME));
114 
115  /* Copy over the context we got */
116  RtlCopyMemory(&LocalContext, ContextPointer, sizeof(CONTEXT));
117  Context = &LocalContext;
118  ContextFlags = CONTEXT_CONTROL;
119 
120  /* Zero out the trap frame and save area */
121  RtlZeroMemory(&InitFrame->TrapFrame,
122  KTRAP_FRAME_LENGTH + sizeof(FX_SAVE_AREA));
123 
124  /* Setup the Fx Area */
125  FxSaveArea = &InitFrame->FxSaveArea;
126 
127  /* Check if we support FXsr */
128  if (KeI386FxsrPresent)
129  {
130  /* Get the FX Save Format Area */
131  FxSaveFormat = (PFXSAVE_FORMAT)Context->ExtendedRegisters;
132 
133  /* Set an initial state */
134  FxSaveFormat->ControlWord = 0x27F;
135  FxSaveFormat->StatusWord = 0;
136  FxSaveFormat->TagWord = 0;
137  FxSaveFormat->ErrorOffset = 0;
138  FxSaveFormat->ErrorSelector = 0;
139  FxSaveFormat->DataOffset = 0;
140  FxSaveFormat->DataSelector = 0;
141  FxSaveFormat->MXCsr = 0x1F80;
142  }
143  else
144  {
145  /* Setup the regular save area */
146  Context->FloatSave.ControlWord = 0x27F;
147  Context->FloatSave.StatusWord = 0;
148  Context->FloatSave.TagWord = -1;
149  Context->FloatSave.ErrorOffset = 0;
150  Context->FloatSave.ErrorSelector = 0;
151  Context->FloatSave.DataOffset =0;
152  Context->FloatSave.DataSelector = 0;
153  }
154 
155  /* Set an intial NPX State */
156  Context->FloatSave.Cr0NpxState = 0;
157  FxSaveArea->Cr0NpxState = 0;
158  FxSaveArea->NpxSavedCpu = 0;
159 
160  /* Now set the context flags depending on XMM support */
162 
163  /* Set the Thread's NPX State */
164  Thread->NpxState = NPX_STATE_NOT_LOADED;
165  Thread->Header.NpxIrql = PASSIVE_LEVEL;
166 
167  /* Disable any debug registers */
168  Context->ContextFlags &= ~CONTEXT_DEBUG_REGISTERS;
169 
170  /* Setup the Trap Frame */
171  TrapFrame = &InitFrame->TrapFrame;
172 
173  /* Set up a trap frame from the context. */
175  NULL,
176  TrapFrame,
177  Context->ContextFlags | ContextFlags,
178  UserMode);
179 
180  /* Set SS, DS, ES's RPL Mask properly */
181  TrapFrame->HardwareSegSs |= RPL_MASK;
182  TrapFrame->SegDs |= RPL_MASK;
183  TrapFrame->SegEs |= RPL_MASK;
184  TrapFrame->Dr7 = 0;
185 
186  /* Set the debug mark */
187  TrapFrame->DbgArgMark = 0xBADB0D00;
188 
189  /* Set the previous mode as user */
190  TrapFrame->PreviousPreviousMode = UserMode;
191 
192  /* Terminate the Exception Handler List */
193  TrapFrame->ExceptionList = EXCEPTION_CHAIN_END;
194 
195  /* Setup the Stack for KiThreadStartup and Context Switching */
196  StartFrame = &InitFrame->StartFrame;
197  CtxSwitchFrame = &InitFrame->CtxSwitchFrame;
198 
199  /* Tell the thread it will run in User Mode */
200  Thread->PreviousMode = UserMode;
201 
202  /* Tell KiThreadStartup of that too */
203  StartFrame->UserThread = TRUE;
204  }
205  else
206  {
207  /* Set up the Initial Frame for the system thread */
208  PKKINIT_FRAME InitFrame;
209  InitFrame = (PKKINIT_FRAME)((ULONG_PTR)Thread->InitialStack -
210  sizeof(KKINIT_FRAME));
211 
212  /* Setup the Fx Area */
213  FxSaveArea = &InitFrame->FxSaveArea;
214  RtlZeroMemory(FxSaveArea, sizeof(FX_SAVE_AREA));
215 
216  /* Check if we have Fxsr support */
217  if (KeI386FxsrPresent)
218  {
219  /* Set the stub FX area */
220  FxSaveArea->U.FxArea.ControlWord = 0x27F;
221  FxSaveArea->U.FxArea.MXCsr = 0x1F80;
222  }
223  else
224  {
225  /* Set the stub FN area */
226  FxSaveArea->U.FnArea.ControlWord = 0x27F;
227  FxSaveArea->U.FnArea.TagWord = -1;
228  }
229 
230  /* No NPX State */
231  Thread->NpxState = NPX_STATE_NOT_LOADED;
232 
233  /* Setup the Stack for KiThreadStartup and Context Switching */
234  StartFrame = &InitFrame->StartFrame;
235  CtxSwitchFrame = &InitFrame->CtxSwitchFrame;
236 
237  /* Tell the thread it will run in Kernel Mode */
238  Thread->PreviousMode = KernelMode;
239 
240  /* Tell KiThreadStartup of that too */
241  StartFrame->UserThread = FALSE;
242  }
243 
244  /* Now setup the remaining data for KiThreadStartup */
245  StartFrame->StartContext = StartContext;
246  StartFrame->StartRoutine = StartRoutine;
247  StartFrame->SystemRoutine = SystemRoutine;
248 
249  /* And set up the Context Switch Frame */
250  CtxSwitchFrame->RetAddr = KiThreadStartup;
251  CtxSwitchFrame->ApcBypassDisable = TRUE;
252  CtxSwitchFrame->ExceptionList = EXCEPTION_CHAIN_END;
253 
254  /* Save back the new value of the kernel stack. */
255  Thread->KernelStack = (PVOID)CtxSwitchFrame;
256 }
257 
259 VOID
261 {
262  PKPRCB Prcb = KeGetCurrentPrcb();
263  PKTHREAD OldThread, NewThread;
264 
265  /* Now loop forever */
266  while (TRUE)
267  {
268  /* Start of the idle loop: disable interrupts */
269  _enable();
270  YieldProcessor();
271  YieldProcessor();
272  _disable();
273 
274  /* Check for pending timers, pending DPCs, or pending ready threads */
275  if ((Prcb->DpcData[0].DpcQueueDepth) ||
276  (Prcb->TimerRequest) ||
277  (Prcb->DeferredReadyListHead.Next))
278  {
279  /* Quiesce the DPC software interrupt */
281 
282  /* Handle it */
283  KiRetireDpcList(Prcb);
284  }
285 
286  /* Check if a new thread is scheduled for execution */
287  if (Prcb->NextThread)
288  {
289  /* Enable interrupts */
290  _enable();
291 
292  /* Capture current thread data */
293  OldThread = Prcb->CurrentThread;
294  NewThread = Prcb->NextThread;
295 
296  /* Set new thread data */
297  Prcb->NextThread = NULL;
298  Prcb->CurrentThread = NewThread;
299 
300  /* The thread is now running */
301  NewThread->State = Running;
302 
303  /* Switch away from the idle thread */
304  KiSwapContext(APC_LEVEL, OldThread);
305  }
306  else
307  {
308  /* Continue staying idle. Note the HAL returns with interrupts on */
309  Prcb->PowerState.IdleFunction(&Prcb->PowerState);
310  }
311  }
312 }
313 
314 BOOLEAN
315 FASTCALL
317  IN PKSWITCHFRAME SwitchFrame)
318 {
319  PKIPCR Pcr = (PKIPCR)KeGetPcr();
320  PKPROCESS OldProcess, NewProcess;
321  PKTHREAD NewThread;
322 
323  /* We are on the new thread stack now */
324  NewThread = Pcr->PrcbData.CurrentThread;
325 
326  /* Now we are the new thread. Check if it's in a new process */
327  OldProcess = OldThread->ApcState.Process;
328  NewProcess = NewThread->ApcState.Process;
329  if (OldProcess != NewProcess)
330  {
331  /* Check if there is a different LDT */
332  if (*(PULONGLONG)&OldProcess->LdtDescriptor != *(PULONGLONG)&NewProcess->LdtDescriptor)
333  {
334  if (NewProcess->LdtDescriptor.LimitLow)
335  {
337  ((PULONG)&NewProcess->LdtDescriptor)[0],
338  ((PULONG)&NewProcess->LdtDescriptor)[1]);
339  Ke386SetLocalDescriptorTable(KGDT_LDT);
340  }
341  else
342  {
343  Ke386SetLocalDescriptorTable(0);
344  }
345  }
346 
347  /* Switch address space and flush TLB */
348  __writecr3(NewProcess->DirectoryTableBase[0]);
349  }
350 
351  /* Clear GS */
352  Ke386SetGs(0);
353 
354  /* Set the TEB */
355  KiSetTebBase((PKPCR)Pcr, &NewThread->Teb->NtTib);
356 
357  /* Set new TSS fields */
358  Pcr->TSS->Esp0 = (ULONG_PTR)NewThread->InitialStack;
359  if (!((KeGetTrapFrame(NewThread))->EFlags & EFLAGS_V86_MASK))
360  {
361  Pcr->TSS->Esp0 -= sizeof(KTRAP_FRAME) - FIELD_OFFSET(KTRAP_FRAME, V86Es);
362  }
363  Pcr->TSS->Esp0 -= NPX_FRAME_LENGTH;
364  Pcr->TSS->IoMapBase = NewProcess->IopmOffset;
365 
366  /* Increase thread context switches */
367  NewThread->ContextSwitches++;
368 
369  /* Load data from switch frame */
370  Pcr->NtTib.ExceptionList = SwitchFrame->ExceptionList;
371 
372  /* DPCs shouldn't be active */
373  if (Pcr->PrcbData.DpcRoutineActive)
374  {
375  /* Crash the machine */
376  KeBugCheckEx(ATTEMPTED_SWITCH_FROM_DPC,
377  (ULONG_PTR)OldThread,
378  (ULONG_PTR)NewThread,
379  (ULONG_PTR)OldThread->InitialStack,
380  0);
381  }
382 
383  /* Kernel APCs may be pending */
384  if (NewThread->ApcState.KernelApcPending)
385  {
386  /* Are APCs enabled? */
387  if (!NewThread->SpecialApcDisable)
388  {
389  /* Request APC delivery */
390  if (SwitchFrame->ApcBypassDisable)
392  else
393  return TRUE;
394  }
395  }
396 
397  /* Return stating that no kernel APCs are pending*/
398  return FALSE;
399 }
400 
401 VOID
402 FASTCALL
404  IN ULONG_PTR OldThreadAndApcFlag)
405 {
406  PKIPCR Pcr = (PKIPCR)KeGetPcr();
407  PKTHREAD OldThread, NewThread;
408  ULONG Cr0, NewCr0;
409 
410  /* Save APC bypass disable */
411  SwitchFrame->ApcBypassDisable = OldThreadAndApcFlag & 3;
412  SwitchFrame->ExceptionList = Pcr->NtTib.ExceptionList;
413 
414  /* Increase context switch count and check if tracing is enabled */
415  Pcr->ContextSwitches++;
416  if (Pcr->PerfGlobalGroupMask)
417  {
418  /* We don't support this yet on x86 either */
419  DPRINT1("WMI Tracing not supported\n");
420  ASSERT(FALSE);
421  }
422 
423  /* Get thread pointers */
424  OldThread = (PKTHREAD)(OldThreadAndApcFlag & ~3);
425  NewThread = Pcr->PrcbData.CurrentThread;
426 
427  /* Get the old thread and set its kernel stack */
428  OldThread->KernelStack = SwitchFrame;
429 
430  /* ISRs can change FPU state, so disable interrupts while checking */
431  _disable();
432 
433  /* Get current and new CR0 and check if they've changed */
434  Cr0 = __readcr0();
435  NewCr0 = NewThread->NpxState |
436  (Cr0 & ~(CR0_MP | CR0_EM | CR0_TS)) |
437  KiGetThreadNpxArea(NewThread)->Cr0NpxState;
438  if (Cr0 != NewCr0) __writecr0(NewCr0);
439 
440  /* Now enable interrupts and do the switch */
441  _enable();
442  KiSwitchThreads(OldThread, NewThread->KernelStack);
443 }
444 
445 VOID
446 NTAPI
448 {
449  PKIPCR Pcr = (PKIPCR)KeGetPcr();
450  PKPRCB Prcb = &Pcr->PrcbData;
451  PVOID OldHandler;
452  PKTHREAD NewThread, OldThread;
453 
454  /* Disable interrupts */
455  _disable();
456 
457  /* Check for pending timers, pending DPCs, or pending ready threads */
458  if ((Prcb->DpcData[0].DpcQueueDepth) ||
459  (Prcb->TimerRequest) ||
460  (Prcb->DeferredReadyListHead.Next))
461  {
462  /* Switch to safe execution context */
463  OldHandler = Pcr->NtTib.ExceptionList;
465 
466  /* Retire DPCs while under the DPC stack */
467  KiRetireDpcListInDpcStack(Prcb, Prcb->DpcStack);
468 
469  /* Restore context */
470  Pcr->NtTib.ExceptionList = OldHandler;
471  }
472 
473  /* Re-enable interrupts */
474  _enable();
475 
476  /* Check for quantum end */
477  if (Prcb->QuantumEnd)
478  {
479  /* Handle quantum end */
480  Prcb->QuantumEnd = FALSE;
481  KiQuantumEnd();
482  }
483  else if (Prcb->NextThread)
484  {
485  /* Capture current thread data */
486  OldThread = Prcb->CurrentThread;
487  NewThread = Prcb->NextThread;
488 
489  /* Set new thread data */
490  Prcb->NextThread = NULL;
491  Prcb->CurrentThread = NewThread;
492 
493  /* The thread is now running */
494  NewThread->State = Running;
495  OldThread->WaitReason = WrDispatchInt;
496 
497  /* Make the old thread ready */
498  KxQueueReadyThread(OldThread, Prcb);
499 
500  /* Swap to the new thread */
501  KiSwapContext(APC_LEVEL, OldThread);
502  }
503 }
504 
505 
506 /* EOF */
VOID NTAPI KeContextToTrapFrame(PCONTEXT Context, PKEXCEPTION_FRAME ExeptionFrame, PKTRAP_FRAME TrapFrame, ULONG ContextFlags, KPROCESSOR_MODE PreviousMode)
#define CR0_EM
Definition: asm.h:247
VOID FASTCALL KiSwapContextEntry(IN PKSWITCHFRAME SwitchFrame, IN ULONG_PTR OldThreadAndApcFlag)
Definition: thrdini.c:262
KSWITCHFRAME CtxSwitchFrame
Definition: thrdini.c:32
#define CONTEXT_CONTROL
Definition: nt_native.h:1369
#define IN
Definition: typedefs.h:39
ULONG DbgArgMark
Definition: ketypes.h:244
#define CONTEXT_EXTENDED_REGISTERS
#define NPX_FRAME_LENGTH
Definition: asm.h:246
ULONG_PTR DirectoryTableBase
Definition: ketypes.h:2027
union _FX_SAVE_AREA::@2412 U
SHORT SpecialApcDisable
Definition: ketypes.h:1821
_In_ ULONG _In_opt_ POBJECT_ATTRIBUTES _In_opt_ HANDLE _Out_opt_ PCLIENT_ID _In_ PKSTART_ROUTINE StartRoutine
Definition: psfuncs.h:87
KDPC_DATA DpcData[2]
Definition: ketypes.h:681
#define TRUE
Definition: types.h:120
__in PVOID ContextPointer
Definition: handleapi.cpp:679
PKSTART_ROUTINE StartRoutine
Definition: thrdini.c:25
ULONG TagWord
Definition: ketypes.h:418
ULONG MXCsr
Definition: ketypes.h:436
USHORT IopmOffset
Definition: ketypes.h:2036
void __cdecl _enable(void)
Definition: intrin_arm.h:373
ULONG ErrorSelector
Definition: ketypes.h:433
struct _FXSAVE_FORMAT * PFXSAVE_FORMAT
USHORT ControlWord
Definition: ketypes.h:428
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1080
struct _KIPCR * PKIPCR
#define CONTEXT_FLOATING_POINT
Definition: nt_native.h:1372
ULONG HardwareSegSs
Definition: ketypes.h:272
VOID NTAPI KiQuantumEnd(VOID)
PKSYSTEM_ROUTINE SystemRoutine
Definition: thrdini.c:24
Definition: ke.h:289
PROCESSOR_POWER_STATE PowerState
Definition: ketypes.h:800
UCHAR QuantumEnd
Definition: ketypes.h:701
BOOLEAN ApcBypassDisable
Definition: thrdini.c:20
if(dx==0 &&dy==0)
Definition: linetemp.h:174
VOID NTAPI KiInitializeContextThread(IN PKTHREAD Thread, IN PKSYSTEM_ROUTINE SystemRoutine, IN PKSTART_ROUTINE StartRoutine, IN PVOID StartContext, IN PCONTEXT Context)
Definition: thrdini.c:40
USHORT StatusWord
Definition: ketypes.h:429
#define FASTCALL
Definition: nt_native.h:50
struct _KTHREAD * NextThread
Definition: ketypes.h:572
#define DECLSPEC_NORETURN
Definition: ntbasedef.h:176
#define KeGetPcr()
Definition: ke.h:26
ULONG KeI386FxsrPresent
Definition: cpu.c:33
#define EFLAGS_V86_MASK
Definition: ketypes.h:132
KSWITCH_FRAME CtxSwitchFrame
Definition: thrdini.c:22
uint32_t ULONG_PTR
Definition: typedefs.h:65
BOOLEAN FASTCALL KiSwapContext(IN KIRQL WaitIrql, IN PKTHREAD CurrentThread)
FORCEINLINE VOID YieldProcessor(VOID)
Definition: ke.h:32
VOID NTAPI KiThreadStartup(VOID)
Definition: thrdini.c:63
struct _KSWITCHFRAME * PKSWITCHFRAME
struct _KTHREAD * PKTHREAD
Definition: nt_native.h:28
__INTRIN_INLINE void __writecr3(unsigned int Data)
Definition: intrin_x86.h:1794
struct _KTRAP_FRAME KTRAP_FRAME
#define KGDT_LDT
Definition: ketypes.h:83
VOID(NTAPI * PKSYSTEM_ROUTINE)(PKSTART_ROUTINE StartRoutine, PVOID StartContext)
Definition: ketypes.h:677
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
#define FALSE
Definition: types.h:117
KSTART_ROUTINE * PKSTART_ROUTINE
Definition: ketypes.h:487
VOID KeSetGdtSelector(ULONG Entry, ULONG Value1, ULONG Value2)
Definition: ldt.c:107
DECLSPEC_NORETURN VOID NTAPI KeBugCheck(ULONG BugCheckCode)
Definition: bug.c:1427
KSTART_FRAME StartFrame
Definition: thrdini.c:23
KAPC_STATE ApcState
Definition: ketypes.h:1718
PVOID RetAddr
Definition: thrdini.c:21
USHORT SegEs
Definition: ketypes.h:370
VOID FASTCALL KiRetireDpcListInDpcStack(IN PKPRCB Prcb, IN PVOID DpcStack)
FX_SAVE_AREA FxSaveArea
Definition: thrdini.c:42
struct _KTHREAD * CurrentThread
Definition: ketypes.h:571
#define RPL_MASK
Definition: ketypes.h:69
unsigned char BOOLEAN
__INTRIN_INLINE void __writecr0(unsigned int Data)
Definition: intrin_x86.h:1789
ULONG Cr0NpxState
Definition: ketypes.h:452
USHORT TagWord
Definition: ketypes.h:430
KSWITCH_FRAME CtxSwitchFrame
Definition: thrdini.c:31
PVOID KernelStack
Definition: ketypes.h:1615
struct _KSTART_FRAME KSTART_FRAME
DECLSPEC_NORETURN VOID KiIdleLoop(VOID)
Definition: thrdini.c:153
void * PVOID
Definition: retypes.h:9
UCHAR WaitReason
Definition: ketypes.h:1904
FORCEINLINE PFX_SAVE_AREA KiGetThreadNpxArea(IN PKTHREAD Thread)
Definition: ke.h:671
ULONG64 NpxState
Definition: ketypes.h:2008
UINT64 TimerRequest
Definition: ketypes.h:696
#define ASSERT(a)
Definition: mode.c:44
ULONG NpxSavedCpu
Definition: ketypes.h:451
KPRCB PrcbData
Definition: ketypes.h:777
struct _EXCEPTION_REGISTRATION_RECORD * ExceptionList
Definition: compat.h:711
KTRAP_FRAME TrapFrame
Definition: thrdini.c:25
ULONG DataOffset
Definition: ketypes.h:434
struct _KKINIT_FRAME KKINIT_FRAME
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2652
struct _EXCEPTION_REGISTRATION_RECORD FAR * ExceptionList
Definition: ketypes.h:261
ULONG ControlWord
Definition: ketypes.h:416
struct _SINGLE_LIST_ENTRY * Next
Definition: ntbasedef.h:629
ULONG DataSelector
Definition: ketypes.h:435
VOID NTAPI KiDispatchInterrupt(VOID)
Definition: thrdini.c:295
#define CONTEXT_DEBUG_REGISTERS
Definition: nt_native.h:1373
struct _KUINIT_FRAME * PKUINIT_FRAME
NT_TIB NtTib
Definition: ke.h:293
USHORT SegDs
Definition: ketypes.h:369
__INTRIN_INLINE unsigned long __readcr0(void)
Definition: intrin_x86.h:1804
KSTART_FRAME StartFrame
Definition: thrdini.c:32
struct _KUINIT_FRAME KUINIT_FRAME
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
ULONG ErrorOffset
Definition: ketypes.h:432
struct _KSTART_FRAME * PKSTART_FRAME
struct _KKINIT_FRAME * PKKINIT_FRAME
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
ULONG PreviousPreviousMode
Definition: ketypes.h:260
SINGLE_LIST_ENTRY DeferredReadyListHead
Definition: ketypes.h:633
VOID FASTCALL HalRequestSoftwareInterrupt(IN KIRQL Irql)
Definition: pic.c:271
struct _KTSS * TSS
Definition: ke.h:55
VOID FASTCALL KiSwitchThreads(IN PKTHREAD OldThread, IN PKTHREAD NewThread)
volatile ULONG DpcQueueDepth
Definition: ketypes.h:798
BOOLEAN FASTCALL KiSwapContextExit(IN PKTHREAD OldThread, IN PKSWITCHFRAME SwitchFrame)
Definition: thrdini.c:209
VOID FASTCALL KfLowerIrql(IN KIRQL NewIrql)
Definition: pic.c:232
PVOID StartContext
Definition: thrdini.c:26
FORCEINLINE VOID KiSetTebBase(PKPCR Pcr, PNT_TIB TebAddress)
Definition: ke.h:389
#define EXCEPTION_CHAIN_END
Definition: rtltypes.h:63
PVOID ExceptionList
Definition: thrdini.c:19
PVOID DpcStack
Definition: ketypes.h:682
#define CR0_TS
Definition: asm.h:248
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define KiServiceExit2
Definition: ke.h:5
unsigned int * PULONG
Definition: retypes.h:1
#define NULL
Definition: types.h:112
FNSAVE_FORMAT FnArea
Definition: ketypes.h:448
PVOID Teb
Definition: ketypes.h:1747
#define DPRINT1
Definition: precomp.h:8
ULONG ContextSwitches
Definition: ketypes.h:897
#define NPX_STATE_NOT_LOADED
Definition: asm.h:264
PPROCESSOR_IDLE_FUNCTION IdleFunction
Definition: potypes.h:68
PVOID PerfGlobalGroupMask
Definition: ketypes.h:745
VOID FASTCALL HalClearSoftwareInterrupt(IN KIRQL Irql)
Definition: pic.c:282
__GNU_EXTENSION typedef unsigned __int64 * PULONGLONG
Definition: ntbasedef.h:383
FX_SAVE_AREA FxSaveArea
Definition: thrdini.c:35
volatile UCHAR State
Definition: ketypes.h:1729
void __cdecl _disable(void)
Definition: intrin_arm.h:365
unsigned int ULONG
Definition: retypes.h:1
ULONG ContextSwitches
Definition: ketypes.h:1728
struct _KSWITCHFRAME KSWITCHFRAME
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define ULONG_PTR
Definition: config.h:101
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define KTRAP_FRAME_LENGTH
Definition: asm.h:126
UINT64 Dr7
Definition: ketypes.h:352
NT_TIB NtTib
Definition: ketypes.h:862
#define KeGetCurrentThread
Definition: hal.h:55
BOOLEAN UserThread
Definition: thrdini.c:27
#define CR0_MP
Definition: asm.h:246
FXSAVE_FORMAT FxArea
Definition: ketypes.h:449
PVOID InitialStack
Definition: ketypes.h:1604
#define KeGetTrapFrame(Thread)
Definition: ke.h:208
#define APC_LEVEL
Definition: env_spec_w32.h:695
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
Definition: rtlcompat.c:108
VOID FASTCALL KiRetireDpcList(IN PKPRCB Prcb)
Definition: dpc.c:562
KSWITCHFRAME CtxSwitchFrame
Definition: thrdini.c:40