Wire thread startup frame to return to user-mode switch or system thread exit handler
This commit is contained in:
@@ -38,6 +38,7 @@ namespace KE
|
||||
STATIC XTAPI VOID StartThread(IN PKTHREAD Thread);
|
||||
|
||||
private:
|
||||
STATIC XTAPI VOID HandleSystemThreadExit(VOID);
|
||||
STATIC XTAPI VOID InitializeThreadContext(IN PKTHREAD Thread,
|
||||
IN PKSYSTEM_ROUTINE SystemRoutine,
|
||||
IN PKSTART_ROUTINE StartRoutine,
|
||||
@@ -53,6 +54,7 @@ namespace KE
|
||||
STATIC XTAPI VOID SuspendThread(IN PVOID NormalContext,
|
||||
IN PVOID SystemArgument1,
|
||||
IN PVOID SystemArgument2);
|
||||
STATIC XTAPI VOID SwitchToUserMode(VOID);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -105,6 +105,9 @@ KE::KThread::InitializeThreadContext(IN PKTHREAD Thread,
|
||||
ThreadFrame->ExceptionFrame.P2Home = (ULONGLONG)StartRoutine;
|
||||
ThreadFrame->ExceptionFrame.P3Home = (ULONGLONG)SystemRoutine;
|
||||
ThreadFrame->ExceptionFrame.P4Home = (ULONGLONG)SystemRoutine;
|
||||
|
||||
/* Set the routine that will handle the thread finishing its initialization and transition it to UserMode */
|
||||
ThreadFrame->StartFrame.Return = (ULONG64)SwitchToUserMode;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -113,6 +116,9 @@ KE::KThread::InitializeThreadContext(IN PKTHREAD Thread,
|
||||
|
||||
/* Disable floating point state */
|
||||
Thread->NpxState = NPX_STATE_UNUSED;
|
||||
|
||||
/* Set the routine that will handle a system thread that unexpectedly finished its execution */
|
||||
ThreadFrame->StartFrame.Return = (ULONG64)HandleSystemThreadExit;
|
||||
}
|
||||
|
||||
/* Initialize thread startup information */
|
||||
|
||||
@@ -99,6 +99,9 @@ KE::KThread::InitializeThreadContext(IN PKTHREAD Thread,
|
||||
ThreadFrame->TrapFrame.SegDs |= RPL_MASK;
|
||||
ThreadFrame->TrapFrame.SegEs |= RPL_MASK;
|
||||
ThreadFrame->TrapFrame.SegSs |= RPL_MASK;
|
||||
|
||||
/* Set the routine that will handle the thread finishing its initialization and transition it to UserMode */
|
||||
ThreadFrame->StartFrame.Return = (ULONG)SwitchToUserMode;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -112,6 +115,9 @@ KE::KThread::InitializeThreadContext(IN PKTHREAD Thread,
|
||||
/* Set initial floating point state */
|
||||
ThreadFrame->NpxFrame.FxArea.ControlWord = 0x27F;
|
||||
ThreadFrame->NpxFrame.FxArea.MxCsr = 0x1F80;
|
||||
|
||||
/* Set the routine that will handle a system thread that unexpectedly finished its execution */
|
||||
ThreadFrame->StartFrame.Return = (ULONG)HandleSystemThreadExit;
|
||||
}
|
||||
|
||||
/* Initialize thread startup information */
|
||||
|
||||
@@ -23,6 +23,19 @@ KE::KThread::GetInitialThread(VOID)
|
||||
return &InitialThread;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles an unexpected system thread exit.
|
||||
*
|
||||
* @return This routine does not return any value.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTAPI
|
||||
VOID
|
||||
KE::KThread::HandleSystemThreadExit(VOID)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes an Idle Thread.
|
||||
*
|
||||
@@ -369,3 +382,16 @@ KE::KThread::SuspendThread(IN PVOID NormalContext,
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Switches a new thread into User Mode.
|
||||
*
|
||||
* @return This routine does not return any value.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTAPI
|
||||
VOID
|
||||
KE::KThread::SwitchToUserMode(VOID)
|
||||
{
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user