2010-07-24 01:12:13 +00:00
|
|
|
/*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS kernel
|
2015-10-04 11:54:25 +00:00
|
|
|
* FILE: ntoskrnl/ke/amd64/thrdini.c
|
[NTOSKRNL/KE/AMD64]
- Fix stack alignment in KiSwitchToBootStack
- Handle ExceptionFrame == NULL in KeContextToTrapFrame and KeTrapFrameToContext
- Implement KiSwapContextInternal
- Fix KiSwapContext and KiThreadStartup
- Implement dispatching of user mode exceptions including in-paging of module data used by the kernel-debugger
- Implement KeInitializeInterrupt, KeConnectInterrupt, KeSynchronizeExecution
- Don't zero more than the actual PCR size in KiInitializePcr
- Add asm function KiInitializeSegments to initialize the segment selectors to proper values
- Initialize system call entrypoints in KiInitializeCpu
- Implement KiDpcInterruptHandler, KiIdleLoop, KiInitializeUserApc, KiSwapProcess, KiSystemCallHandler, KiInitializeContextThread, KiSwapContextResume
- Implement asm functions KiRetireDpcList, KiInterruptDispatch, KiSystemCallEntry64, KiZwSystemService
svn path=/trunk/; revision=55405
2012-02-04 11:32:13 +00:00
|
|
|
* PURPOSE: amd64 Thread Context Creation
|
|
|
|
* PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org)
|
|
|
|
* Alex Ionescu (alex@relsoft.net)
|
2010-07-24 01:12:13 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES ******************************************************************/
|
|
|
|
|
|
|
|
#include <ntoskrnl.h>
|
|
|
|
#define NDEBUG
|
|
|
|
#include <debug.h>
|
|
|
|
|
|
|
|
typedef struct _KUINIT_FRAME
|
|
|
|
{
|
2011-02-10 10:30:43 +00:00
|
|
|
KSWITCH_FRAME CtxSwitchFrame;
|
2010-07-24 01:12:13 +00:00
|
|
|
KSTART_FRAME StartFrame;
|
[NTOSKRNL/KE/AMD64]
- Fix stack alignment in KiSwitchToBootStack
- Handle ExceptionFrame == NULL in KeContextToTrapFrame and KeTrapFrameToContext
- Implement KiSwapContextInternal
- Fix KiSwapContext and KiThreadStartup
- Implement dispatching of user mode exceptions including in-paging of module data used by the kernel-debugger
- Implement KeInitializeInterrupt, KeConnectInterrupt, KeSynchronizeExecution
- Don't zero more than the actual PCR size in KiInitializePcr
- Add asm function KiInitializeSegments to initialize the segment selectors to proper values
- Initialize system call entrypoints in KiInitializeCpu
- Implement KiDpcInterruptHandler, KiIdleLoop, KiInitializeUserApc, KiSwapProcess, KiSystemCallHandler, KiInitializeContextThread, KiSwapContextResume
- Implement asm functions KiRetireDpcList, KiInterruptDispatch, KiSystemCallEntry64, KiZwSystemService
svn path=/trunk/; revision=55405
2012-02-04 11:32:13 +00:00
|
|
|
KEXCEPTION_FRAME ExceptionFrame;
|
2010-07-24 01:12:13 +00:00
|
|
|
KTRAP_FRAME TrapFrame;
|
|
|
|
//FX_SAVE_AREA FxSaveArea;
|
|
|
|
} KUINIT_FRAME, *PKUINIT_FRAME;
|
|
|
|
|
|
|
|
typedef struct _KKINIT_FRAME
|
|
|
|
{
|
2011-02-10 10:30:43 +00:00
|
|
|
KSWITCH_FRAME CtxSwitchFrame;
|
2010-07-24 01:12:13 +00:00
|
|
|
KSTART_FRAME StartFrame;
|
|
|
|
//FX_SAVE_AREA FxSaveArea;
|
|
|
|
} KKINIT_FRAME, *PKKINIT_FRAME;
|
|
|
|
|
|
|
|
/* FUNCTIONS *****************************************************************/
|
|
|
|
|
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
KiInitializeContextThread(IN PKTHREAD Thread,
|
|
|
|
IN PKSYSTEM_ROUTINE SystemRoutine,
|
|
|
|
IN PKSTART_ROUTINE StartRoutine,
|
|
|
|
IN PVOID StartContext,
|
[NTOSKRNL/KE/AMD64]
- Fix stack alignment in KiSwitchToBootStack
- Handle ExceptionFrame == NULL in KeContextToTrapFrame and KeTrapFrameToContext
- Implement KiSwapContextInternal
- Fix KiSwapContext and KiThreadStartup
- Implement dispatching of user mode exceptions including in-paging of module data used by the kernel-debugger
- Implement KeInitializeInterrupt, KeConnectInterrupt, KeSynchronizeExecution
- Don't zero more than the actual PCR size in KiInitializePcr
- Add asm function KiInitializeSegments to initialize the segment selectors to proper values
- Initialize system call entrypoints in KiInitializeCpu
- Implement KiDpcInterruptHandler, KiIdleLoop, KiInitializeUserApc, KiSwapProcess, KiSystemCallHandler, KiInitializeContextThread, KiSwapContextResume
- Implement asm functions KiRetireDpcList, KiInterruptDispatch, KiSystemCallEntry64, KiZwSystemService
svn path=/trunk/; revision=55405
2012-02-04 11:32:13 +00:00
|
|
|
IN PCONTEXT Context)
|
2010-07-24 01:12:13 +00:00
|
|
|
{
|
|
|
|
//PFX_SAVE_AREA FxSaveArea;
|
|
|
|
//PFXSAVE_FORMAT FxSaveFormat;
|
|
|
|
PKSTART_FRAME StartFrame;
|
2011-02-10 10:30:43 +00:00
|
|
|
PKSWITCH_FRAME CtxSwitchFrame;
|
2010-07-24 01:12:13 +00:00
|
|
|
PKTRAP_FRAME TrapFrame;
|
|
|
|
ULONG ContextFlags;
|
|
|
|
|
|
|
|
/* Check if this is a With-Context Thread */
|
[NTOSKRNL/KE/AMD64]
- Fix stack alignment in KiSwitchToBootStack
- Handle ExceptionFrame == NULL in KeContextToTrapFrame and KeTrapFrameToContext
- Implement KiSwapContextInternal
- Fix KiSwapContext and KiThreadStartup
- Implement dispatching of user mode exceptions including in-paging of module data used by the kernel-debugger
- Implement KeInitializeInterrupt, KeConnectInterrupt, KeSynchronizeExecution
- Don't zero more than the actual PCR size in KiInitializePcr
- Add asm function KiInitializeSegments to initialize the segment selectors to proper values
- Initialize system call entrypoints in KiInitializeCpu
- Implement KiDpcInterruptHandler, KiIdleLoop, KiInitializeUserApc, KiSwapProcess, KiSystemCallHandler, KiInitializeContextThread, KiSwapContextResume
- Implement asm functions KiRetireDpcList, KiInterruptDispatch, KiSystemCallEntry64, KiZwSystemService
svn path=/trunk/; revision=55405
2012-02-04 11:32:13 +00:00
|
|
|
if (Context)
|
2010-07-24 01:12:13 +00:00
|
|
|
{
|
|
|
|
PKUINIT_FRAME InitFrame;
|
[NTOSKRNL/KE/AMD64]
- Fix stack alignment in KiSwitchToBootStack
- Handle ExceptionFrame == NULL in KeContextToTrapFrame and KeTrapFrameToContext
- Implement KiSwapContextInternal
- Fix KiSwapContext and KiThreadStartup
- Implement dispatching of user mode exceptions including in-paging of module data used by the kernel-debugger
- Implement KeInitializeInterrupt, KeConnectInterrupt, KeSynchronizeExecution
- Don't zero more than the actual PCR size in KiInitializePcr
- Add asm function KiInitializeSegments to initialize the segment selectors to proper values
- Initialize system call entrypoints in KiInitializeCpu
- Implement KiDpcInterruptHandler, KiIdleLoop, KiInitializeUserApc, KiSwapProcess, KiSystemCallHandler, KiInitializeContextThread, KiSwapContextResume
- Implement asm functions KiRetireDpcList, KiInterruptDispatch, KiSystemCallEntry64, KiZwSystemService
svn path=/trunk/; revision=55405
2012-02-04 11:32:13 +00:00
|
|
|
|
|
|
|
/* Set up the Initial Frame */
|
|
|
|
InitFrame = ((PKUINIT_FRAME)Thread->InitialStack) - 1;
|
|
|
|
StartFrame = &InitFrame->StartFrame;
|
|
|
|
CtxSwitchFrame = &InitFrame->CtxSwitchFrame;
|
|
|
|
|
|
|
|
/* Save back the new value of the kernel stack. */
|
|
|
|
Thread->KernelStack = (PVOID)InitFrame;
|
|
|
|
|
|
|
|
/* Tell the thread it will run in User Mode */
|
|
|
|
Thread->PreviousMode = UserMode;
|
|
|
|
|
|
|
|
// FIXME Setup the Fx Area
|
2010-07-24 01:12:13 +00:00
|
|
|
|
|
|
|
/* Set the Thread's NPX State */
|
|
|
|
Thread->NpxState = 0xA;
|
2011-10-14 08:33:22 +00:00
|
|
|
Thread->Header.NpxIrql = PASSIVE_LEVEL;
|
2010-07-24 01:12:13 +00:00
|
|
|
|
[NTOSKRNL/KE/AMD64]
- Fix stack alignment in KiSwitchToBootStack
- Handle ExceptionFrame == NULL in KeContextToTrapFrame and KeTrapFrameToContext
- Implement KiSwapContextInternal
- Fix KiSwapContext and KiThreadStartup
- Implement dispatching of user mode exceptions including in-paging of module data used by the kernel-debugger
- Implement KeInitializeInterrupt, KeConnectInterrupt, KeSynchronizeExecution
- Don't zero more than the actual PCR size in KiInitializePcr
- Add asm function KiInitializeSegments to initialize the segment selectors to proper values
- Initialize system call entrypoints in KiInitializeCpu
- Implement KiDpcInterruptHandler, KiIdleLoop, KiInitializeUserApc, KiSwapProcess, KiSystemCallHandler, KiInitializeContextThread, KiSwapContextResume
- Implement asm functions KiRetireDpcList, KiInterruptDispatch, KiSystemCallEntry64, KiZwSystemService
svn path=/trunk/; revision=55405
2012-02-04 11:32:13 +00:00
|
|
|
/* Make sure, we have control registers, disable debug registers */
|
|
|
|
ASSERT((Context->ContextFlags & CONTEXT_CONTROL) == CONTEXT_CONTROL);
|
|
|
|
ContextFlags = Context->ContextFlags & ~CONTEXT_DEBUG_REGISTERS;
|
2010-07-24 01:12:13 +00:00
|
|
|
|
|
|
|
/* Setup the Trap Frame */
|
|
|
|
TrapFrame = &InitFrame->TrapFrame;
|
|
|
|
|
[NTOSKRNL/KE/AMD64]
- Fix stack alignment in KiSwitchToBootStack
- Handle ExceptionFrame == NULL in KeContextToTrapFrame and KeTrapFrameToContext
- Implement KiSwapContextInternal
- Fix KiSwapContext and KiThreadStartup
- Implement dispatching of user mode exceptions including in-paging of module data used by the kernel-debugger
- Implement KeInitializeInterrupt, KeConnectInterrupt, KeSynchronizeExecution
- Don't zero more than the actual PCR size in KiInitializePcr
- Add asm function KiInitializeSegments to initialize the segment selectors to proper values
- Initialize system call entrypoints in KiInitializeCpu
- Implement KiDpcInterruptHandler, KiIdleLoop, KiInitializeUserApc, KiSwapProcess, KiSystemCallHandler, KiInitializeContextThread, KiSwapContextResume
- Implement asm functions KiRetireDpcList, KiInterruptDispatch, KiSystemCallEntry64, KiZwSystemService
svn path=/trunk/; revision=55405
2012-02-04 11:32:13 +00:00
|
|
|
/* Zero out the trap frame */
|
|
|
|
RtlZeroMemory(TrapFrame, sizeof(KTRAP_FRAME));
|
|
|
|
|
2010-07-24 01:12:13 +00:00
|
|
|
/* Set up a trap frame from the context. */
|
|
|
|
KeContextToTrapFrame(Context,
|
|
|
|
NULL,
|
|
|
|
TrapFrame,
|
[NTOSKRNL/KE/AMD64]
- Fix stack alignment in KiSwitchToBootStack
- Handle ExceptionFrame == NULL in KeContextToTrapFrame and KeTrapFrameToContext
- Implement KiSwapContextInternal
- Fix KiSwapContext and KiThreadStartup
- Implement dispatching of user mode exceptions including in-paging of module data used by the kernel-debugger
- Implement KeInitializeInterrupt, KeConnectInterrupt, KeSynchronizeExecution
- Don't zero more than the actual PCR size in KiInitializePcr
- Add asm function KiInitializeSegments to initialize the segment selectors to proper values
- Initialize system call entrypoints in KiInitializeCpu
- Implement KiDpcInterruptHandler, KiIdleLoop, KiInitializeUserApc, KiSwapProcess, KiSystemCallHandler, KiInitializeContextThread, KiSwapContextResume
- Implement asm functions KiRetireDpcList, KiInterruptDispatch, KiSystemCallEntry64, KiZwSystemService
svn path=/trunk/; revision=55405
2012-02-04 11:32:13 +00:00
|
|
|
CONTEXT_AMD64 | ContextFlags,
|
2010-07-24 01:12:13 +00:00
|
|
|
UserMode);
|
|
|
|
|
|
|
|
/* Set SS, DS, ES's RPL Mask properly */
|
|
|
|
TrapFrame->SegSs |= RPL_MASK;
|
|
|
|
TrapFrame->SegDs |= RPL_MASK;
|
|
|
|
TrapFrame->SegEs |= RPL_MASK;
|
|
|
|
TrapFrame->Dr7 = 0;
|
|
|
|
|
|
|
|
/* Set the previous mode as user */
|
|
|
|
TrapFrame->PreviousMode = UserMode;
|
|
|
|
|
|
|
|
/* Terminate the Exception Handler List */
|
|
|
|
TrapFrame->ExceptionFrame = 0;
|
|
|
|
|
[NTOSKRNL/KE/AMD64]
- Fix stack alignment in KiSwitchToBootStack
- Handle ExceptionFrame == NULL in KeContextToTrapFrame and KeTrapFrameToContext
- Implement KiSwapContextInternal
- Fix KiSwapContext and KiThreadStartup
- Implement dispatching of user mode exceptions including in-paging of module data used by the kernel-debugger
- Implement KeInitializeInterrupt, KeConnectInterrupt, KeSynchronizeExecution
- Don't zero more than the actual PCR size in KiInitializePcr
- Add asm function KiInitializeSegments to initialize the segment selectors to proper values
- Initialize system call entrypoints in KiInitializeCpu
- Implement KiDpcInterruptHandler, KiIdleLoop, KiInitializeUserApc, KiSwapProcess, KiSystemCallHandler, KiInitializeContextThread, KiSwapContextResume
- Implement asm functions KiRetireDpcList, KiInterruptDispatch, KiSystemCallEntry64, KiZwSystemService
svn path=/trunk/; revision=55405
2012-02-04 11:32:13 +00:00
|
|
|
/* We return to ... */
|
|
|
|
StartFrame->Return = (ULONG64)KiServiceExit2;
|
2010-07-24 01:12:13 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PKKINIT_FRAME InitFrame;
|
|
|
|
|
[NTOSKRNL/KE/AMD64]
- Fix stack alignment in KiSwitchToBootStack
- Handle ExceptionFrame == NULL in KeContextToTrapFrame and KeTrapFrameToContext
- Implement KiSwapContextInternal
- Fix KiSwapContext and KiThreadStartup
- Implement dispatching of user mode exceptions including in-paging of module data used by the kernel-debugger
- Implement KeInitializeInterrupt, KeConnectInterrupt, KeSynchronizeExecution
- Don't zero more than the actual PCR size in KiInitializePcr
- Add asm function KiInitializeSegments to initialize the segment selectors to proper values
- Initialize system call entrypoints in KiInitializeCpu
- Implement KiDpcInterruptHandler, KiIdleLoop, KiInitializeUserApc, KiSwapProcess, KiSystemCallHandler, KiInitializeContextThread, KiSwapContextResume
- Implement asm functions KiRetireDpcList, KiInterruptDispatch, KiSystemCallEntry64, KiZwSystemService
svn path=/trunk/; revision=55405
2012-02-04 11:32:13 +00:00
|
|
|
/* Set up the Initial Frame for the system thread */
|
|
|
|
InitFrame = ((PKKINIT_FRAME)Thread->InitialStack) - 1;
|
|
|
|
StartFrame = &InitFrame->StartFrame;
|
|
|
|
CtxSwitchFrame = &InitFrame->CtxSwitchFrame;
|
2010-07-24 01:12:13 +00:00
|
|
|
|
[NTOSKRNL/KE/AMD64]
- Fix stack alignment in KiSwitchToBootStack
- Handle ExceptionFrame == NULL in KeContextToTrapFrame and KeTrapFrameToContext
- Implement KiSwapContextInternal
- Fix KiSwapContext and KiThreadStartup
- Implement dispatching of user mode exceptions including in-paging of module data used by the kernel-debugger
- Implement KeInitializeInterrupt, KeConnectInterrupt, KeSynchronizeExecution
- Don't zero more than the actual PCR size in KiInitializePcr
- Add asm function KiInitializeSegments to initialize the segment selectors to proper values
- Initialize system call entrypoints in KiInitializeCpu
- Implement KiDpcInterruptHandler, KiIdleLoop, KiInitializeUserApc, KiSwapProcess, KiSystemCallHandler, KiInitializeContextThread, KiSwapContextResume
- Implement asm functions KiRetireDpcList, KiInterruptDispatch, KiSystemCallEntry64, KiZwSystemService
svn path=/trunk/; revision=55405
2012-02-04 11:32:13 +00:00
|
|
|
/* Save back the new value of the kernel stack. */
|
|
|
|
Thread->KernelStack = (PVOID)InitFrame;
|
|
|
|
|
|
|
|
/* Tell the thread it will run in Kernel Mode */
|
|
|
|
Thread->PreviousMode = KernelMode;
|
|
|
|
|
|
|
|
// FIXME Setup the Fx Area
|
2010-07-24 01:12:13 +00:00
|
|
|
|
|
|
|
/* No NPX State */
|
|
|
|
Thread->NpxState = 0xA;
|
|
|
|
|
[NTOSKRNL/KE/AMD64]
- Fix stack alignment in KiSwitchToBootStack
- Handle ExceptionFrame == NULL in KeContextToTrapFrame and KeTrapFrameToContext
- Implement KiSwapContextInternal
- Fix KiSwapContext and KiThreadStartup
- Implement dispatching of user mode exceptions including in-paging of module data used by the kernel-debugger
- Implement KeInitializeInterrupt, KeConnectInterrupt, KeSynchronizeExecution
- Don't zero more than the actual PCR size in KiInitializePcr
- Add asm function KiInitializeSegments to initialize the segment selectors to proper values
- Initialize system call entrypoints in KiInitializeCpu
- Implement KiDpcInterruptHandler, KiIdleLoop, KiInitializeUserApc, KiSwapProcess, KiSystemCallHandler, KiInitializeContextThread, KiSwapContextResume
- Implement asm functions KiRetireDpcList, KiInterruptDispatch, KiSystemCallEntry64, KiZwSystemService
svn path=/trunk/; revision=55405
2012-02-04 11:32:13 +00:00
|
|
|
/* We have no return address! */
|
|
|
|
StartFrame->Return = 0;
|
|
|
|
}
|
2010-07-24 01:12:13 +00:00
|
|
|
|
[NTOSKRNL/KE/AMD64]
- Fix stack alignment in KiSwitchToBootStack
- Handle ExceptionFrame == NULL in KeContextToTrapFrame and KeTrapFrameToContext
- Implement KiSwapContextInternal
- Fix KiSwapContext and KiThreadStartup
- Implement dispatching of user mode exceptions including in-paging of module data used by the kernel-debugger
- Implement KeInitializeInterrupt, KeConnectInterrupt, KeSynchronizeExecution
- Don't zero more than the actual PCR size in KiInitializePcr
- Add asm function KiInitializeSegments to initialize the segment selectors to proper values
- Initialize system call entrypoints in KiInitializeCpu
- Implement KiDpcInterruptHandler, KiIdleLoop, KiInitializeUserApc, KiSwapProcess, KiSystemCallHandler, KiInitializeContextThread, KiSwapContextResume
- Implement asm functions KiRetireDpcList, KiInterruptDispatch, KiSystemCallEntry64, KiZwSystemService
svn path=/trunk/; revision=55405
2012-02-04 11:32:13 +00:00
|
|
|
/* Set up the Context Switch Frame */
|
|
|
|
CtxSwitchFrame->Return = (ULONG64)KiThreadStartup;
|
|
|
|
CtxSwitchFrame->ApcBypass = FALSE;
|
|
|
|
|
|
|
|
StartFrame->P1Home = (ULONG64)StartRoutine;
|
|
|
|
StartFrame->P2Home = (ULONG64)StartContext;
|
|
|
|
StartFrame->P3Home = 0;
|
|
|
|
StartFrame->P4Home = (ULONG64)SystemRoutine;
|
2015-05-02 23:12:19 +00:00
|
|
|
StartFrame->Reserved = 0;
|
[NTOSKRNL/KE/AMD64]
- Fix stack alignment in KiSwitchToBootStack
- Handle ExceptionFrame == NULL in KeContextToTrapFrame and KeTrapFrameToContext
- Implement KiSwapContextInternal
- Fix KiSwapContext and KiThreadStartup
- Implement dispatching of user mode exceptions including in-paging of module data used by the kernel-debugger
- Implement KeInitializeInterrupt, KeConnectInterrupt, KeSynchronizeExecution
- Don't zero more than the actual PCR size in KiInitializePcr
- Add asm function KiInitializeSegments to initialize the segment selectors to proper values
- Initialize system call entrypoints in KiInitializeCpu
- Implement KiDpcInterruptHandler, KiIdleLoop, KiInitializeUserApc, KiSwapProcess, KiSystemCallHandler, KiInitializeContextThread, KiSwapContextResume
- Implement asm functions KiRetireDpcList, KiInterruptDispatch, KiSystemCallEntry64, KiZwSystemService
svn path=/trunk/; revision=55405
2012-02-04 11:32:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN
|
|
|
|
KiSwapContextResume(
|
|
|
|
IN PKTHREAD NewThread,
|
|
|
|
IN PKTHREAD OldThread,
|
|
|
|
IN BOOLEAN ApcBypass)
|
|
|
|
{
|
|
|
|
PKIPCR Pcr = (PKIPCR)KeGetPcr();
|
|
|
|
PKPROCESS OldProcess, NewProcess;
|
|
|
|
|
|
|
|
/* Setup ring 0 stack pointer */
|
|
|
|
Pcr->TssBase->Rsp0 = (ULONG64)NewThread->InitialStack; // FIXME: NPX save area?
|
|
|
|
Pcr->Prcb.RspBase = Pcr->TssBase->Rsp0;
|
|
|
|
|
|
|
|
/* Now we are the new thread. Check if it's in a new process */
|
|
|
|
OldProcess = OldThread->ApcState.Process;
|
|
|
|
NewProcess = NewThread->ApcState.Process;
|
|
|
|
if (OldProcess != NewProcess)
|
|
|
|
{
|
|
|
|
/* Switch address space and flush TLB */
|
|
|
|
__writecr3(NewProcess->DirectoryTableBase[0]);
|
2010-07-24 01:12:13 +00:00
|
|
|
|
[NTOSKRNL/KE/AMD64]
- Fix stack alignment in KiSwitchToBootStack
- Handle ExceptionFrame == NULL in KeContextToTrapFrame and KeTrapFrameToContext
- Implement KiSwapContextInternal
- Fix KiSwapContext and KiThreadStartup
- Implement dispatching of user mode exceptions including in-paging of module data used by the kernel-debugger
- Implement KeInitializeInterrupt, KeConnectInterrupt, KeSynchronizeExecution
- Don't zero more than the actual PCR size in KiInitializePcr
- Add asm function KiInitializeSegments to initialize the segment selectors to proper values
- Initialize system call entrypoints in KiInitializeCpu
- Implement KiDpcInterruptHandler, KiIdleLoop, KiInitializeUserApc, KiSwapProcess, KiSystemCallHandler, KiInitializeContextThread, KiSwapContextResume
- Implement asm functions KiRetireDpcList, KiInterruptDispatch, KiSystemCallEntry64, KiZwSystemService
svn path=/trunk/; revision=55405
2012-02-04 11:32:13 +00:00
|
|
|
/* Set new TSS fields */
|
|
|
|
//Pcr->TssBase->IoMapBase = NewProcess->IopmOffset;
|
2010-07-24 01:12:13 +00:00
|
|
|
}
|
|
|
|
|
[NTOSKRNL/KE/AMD64]
- Fix stack alignment in KiSwitchToBootStack
- Handle ExceptionFrame == NULL in KeContextToTrapFrame and KeTrapFrameToContext
- Implement KiSwapContextInternal
- Fix KiSwapContext and KiThreadStartup
- Implement dispatching of user mode exceptions including in-paging of module data used by the kernel-debugger
- Implement KeInitializeInterrupt, KeConnectInterrupt, KeSynchronizeExecution
- Don't zero more than the actual PCR size in KiInitializePcr
- Add asm function KiInitializeSegments to initialize the segment selectors to proper values
- Initialize system call entrypoints in KiInitializeCpu
- Implement KiDpcInterruptHandler, KiIdleLoop, KiInitializeUserApc, KiSwapProcess, KiSystemCallHandler, KiInitializeContextThread, KiSwapContextResume
- Implement asm functions KiRetireDpcList, KiInterruptDispatch, KiSystemCallEntry64, KiZwSystemService
svn path=/trunk/; revision=55405
2012-02-04 11:32:13 +00:00
|
|
|
/* Set TEB pointer and GS base */
|
|
|
|
Pcr->NtTib.Self = (PVOID)NewThread->Teb;
|
|
|
|
if (NewThread->Teb)
|
|
|
|
{
|
|
|
|
/* This will switch the usermode gs */
|
|
|
|
__writemsr(MSR_GS_SWAP, (ULONG64)NewThread->Teb);
|
|
|
|
}
|
2010-07-24 01:12:13 +00:00
|
|
|
|
[NTOSKRNL/KE/AMD64]
- Fix stack alignment in KiSwitchToBootStack
- Handle ExceptionFrame == NULL in KeContextToTrapFrame and KeTrapFrameToContext
- Implement KiSwapContextInternal
- Fix KiSwapContext and KiThreadStartup
- Implement dispatching of user mode exceptions including in-paging of module data used by the kernel-debugger
- Implement KeInitializeInterrupt, KeConnectInterrupt, KeSynchronizeExecution
- Don't zero more than the actual PCR size in KiInitializePcr
- Add asm function KiInitializeSegments to initialize the segment selectors to proper values
- Initialize system call entrypoints in KiInitializeCpu
- Implement KiDpcInterruptHandler, KiIdleLoop, KiInitializeUserApc, KiSwapProcess, KiSystemCallHandler, KiInitializeContextThread, KiSwapContextResume
- Implement asm functions KiRetireDpcList, KiInterruptDispatch, KiSystemCallEntry64, KiZwSystemService
svn path=/trunk/; revision=55405
2012-02-04 11:32:13 +00:00
|
|
|
/* Increase context switch count */
|
|
|
|
Pcr->ContextSwitches++;
|
|
|
|
NewThread->ContextSwitches++;
|
2010-07-24 01:12:13 +00:00
|
|
|
|
[NTOSKRNL/KE/AMD64]
- Fix stack alignment in KiSwitchToBootStack
- Handle ExceptionFrame == NULL in KeContextToTrapFrame and KeTrapFrameToContext
- Implement KiSwapContextInternal
- Fix KiSwapContext and KiThreadStartup
- Implement dispatching of user mode exceptions including in-paging of module data used by the kernel-debugger
- Implement KeInitializeInterrupt, KeConnectInterrupt, KeSynchronizeExecution
- Don't zero more than the actual PCR size in KiInitializePcr
- Add asm function KiInitializeSegments to initialize the segment selectors to proper values
- Initialize system call entrypoints in KiInitializeCpu
- Implement KiDpcInterruptHandler, KiIdleLoop, KiInitializeUserApc, KiSwapProcess, KiSystemCallHandler, KiInitializeContextThread, KiSwapContextResume
- Implement asm functions KiRetireDpcList, KiInterruptDispatch, KiSystemCallEntry64, KiZwSystemService
svn path=/trunk/; revision=55405
2012-02-04 11:32:13 +00:00
|
|
|
/* DPCs shouldn't be active */
|
|
|
|
if (Pcr->Prcb.DpcRoutineActive)
|
|
|
|
{
|
|
|
|
/* Crash the machine */
|
|
|
|
KeBugCheckEx(ATTEMPTED_SWITCH_FROM_DPC,
|
|
|
|
(ULONG_PTR)OldThread,
|
|
|
|
(ULONG_PTR)NewThread,
|
|
|
|
(ULONG_PTR)OldThread->InitialStack,
|
|
|
|
0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Kernel APCs may be pending */
|
|
|
|
if (NewThread->ApcState.KernelApcPending)
|
|
|
|
{
|
|
|
|
/* Are APCs enabled? */
|
|
|
|
if (!NewThread->SpecialApcDisable)
|
|
|
|
{
|
|
|
|
/* Request APC delivery */
|
|
|
|
if (!ApcBypass)
|
|
|
|
HalRequestSoftwareInterrupt(APC_LEVEL);
|
|
|
|
else
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
2010-07-24 01:12:13 +00:00
|
|
|
|
[NTOSKRNL/KE/AMD64]
- Fix stack alignment in KiSwitchToBootStack
- Handle ExceptionFrame == NULL in KeContextToTrapFrame and KeTrapFrameToContext
- Implement KiSwapContextInternal
- Fix KiSwapContext and KiThreadStartup
- Implement dispatching of user mode exceptions including in-paging of module data used by the kernel-debugger
- Implement KeInitializeInterrupt, KeConnectInterrupt, KeSynchronizeExecution
- Don't zero more than the actual PCR size in KiInitializePcr
- Add asm function KiInitializeSegments to initialize the segment selectors to proper values
- Initialize system call entrypoints in KiInitializeCpu
- Implement KiDpcInterruptHandler, KiIdleLoop, KiInitializeUserApc, KiSwapProcess, KiSystemCallHandler, KiInitializeContextThread, KiSwapContextResume
- Implement asm functions KiRetireDpcList, KiInterruptDispatch, KiSystemCallEntry64, KiZwSystemService
svn path=/trunk/; revision=55405
2012-02-04 11:32:13 +00:00
|
|
|
/* Return stating that no kernel APCs are pending*/
|
|
|
|
return FALSE;
|
2010-07-24 01:12:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* EOF */
|
|
|
|
|
|
|
|
|