don't receive the previous mode before the current thread was created, this should finally fix the boot.

svn path=/trunk/; revision=14044
This commit is contained in:
Thomas Bluemel 2005-03-14 01:47:18 +00:00
parent 78dbb934c2
commit 865a496525
5 changed files with 21 additions and 8 deletions

View file

@ -455,6 +455,7 @@ NTSTATUS
PsInitializeThread(PEPROCESS Process, PsInitializeThread(PEPROCESS Process,
PETHREAD* ThreadPtr, PETHREAD* ThreadPtr,
POBJECT_ATTRIBUTES ObjectAttributes, POBJECT_ATTRIBUTES ObjectAttributes,
KPROCESSOR_MODE AccessMode,
BOOLEAN First); BOOLEAN First);
PACCESS_TOKEN PsReferenceEffectiveToken(PETHREAD Thread, PACCESS_TOKEN PsReferenceEffectiveToken(PETHREAD Thread,
@ -532,6 +533,8 @@ VOID
PsApplicationProcessorInit(VOID); PsApplicationProcessorInit(VOID);
VOID VOID
PsPrepareForApplicationProcessorInit(ULONG Id); PsPrepareForApplicationProcessorInit(ULONG Id);
VOID
PsInitReaperThread(VOID);
VOID STDCALL VOID STDCALL
PsIdleThreadMain(PVOID Context); PsIdleThreadMain(PVOID Context);

View file

@ -399,17 +399,15 @@ NTSTATUS
PsInitializeThread(PEPROCESS Process, PsInitializeThread(PEPROCESS Process,
PETHREAD* ThreadPtr, PETHREAD* ThreadPtr,
POBJECT_ATTRIBUTES ObjectAttributes, POBJECT_ATTRIBUTES ObjectAttributes,
KPROCESSOR_MODE AccessMode,
BOOLEAN First) BOOLEAN First)
{ {
PETHREAD Thread; PETHREAD Thread;
NTSTATUS Status; NTSTATUS Status;
KPROCESSOR_MODE PreviousMode;
KIRQL oldIrql; KIRQL oldIrql;
PAGED_CODE(); PAGED_CODE();
PreviousMode = ExGetPreviousMode();
if (Process == NULL) if (Process == NULL)
{ {
Process = PsInitialSystemProcess; Process = PsInitialSystemProcess;
@ -418,7 +416,7 @@ PsInitializeThread(PEPROCESS Process,
/* /*
* Create and initialize thread * Create and initialize thread
*/ */
Status = ObCreateObject(PreviousMode, Status = ObCreateObject(AccessMode,
PsThreadType, PsThreadType,
ObjectAttributes, ObjectAttributes,
KernelMode, KernelMode,
@ -730,6 +728,7 @@ NtCreateThread(OUT PHANDLE ThreadHandle,
Status = PsInitializeThread(Process, Status = PsInitializeThread(Process,
&Thread, &Thread,
ObjectAttributes, ObjectAttributes,
PreviousMode,
FALSE); FALSE);
ObDereferenceObject(Process); ObDereferenceObject(Process);
@ -877,6 +876,7 @@ PsCreateSystemThread(PHANDLE ThreadHandle,
Status = PsInitializeThread(NULL, Status = PsInitializeThread(NULL,
&Thread, &Thread,
ObjectAttributes, ObjectAttributes,
KernelMode,
FALSE); FALSE);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {

View file

@ -57,6 +57,7 @@ PsInitIdleThread(VOID)
Status = PsInitializeThread(NULL, Status = PsInitializeThread(NULL,
&IdleThread, &IdleThread,
NULL, NULL,
KernelMode,
FALSE); FALSE);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {

View file

@ -30,6 +30,7 @@ PiInitProcessManager(VOID)
PsInitProcessManagment(); PsInitProcessManagment();
PsInitThreadManagment(); PsInitThreadManagment();
PsInitIdleThread(); PsInitIdleThread();
PsInitReaperThread();
PsInitialiseSuspendImplementation(); PsInitialiseSuspendImplementation();
PsInitialiseW32Call(); PsInitialiseW32Call();
} }

View file

@ -709,6 +709,7 @@ PsPrepareForApplicationProcessorInit(ULONG Id)
PsInitializeThread(NULL, PsInitializeThread(NULL,
&IdleThread, &IdleThread,
NULL, NULL,
KernelMode,
FALSE); FALSE);
IdleThread->Tcb.State = THREAD_STATE_RUNNING; IdleThread->Tcb.State = THREAD_STATE_RUNNING;
IdleThread->Tcb.FreezeCount = 0; IdleThread->Tcb.FreezeCount = 0;
@ -731,10 +732,8 @@ PsInitThreadManagment(VOID)
* FUNCTION: Initialize thread managment * FUNCTION: Initialize thread managment
*/ */
{ {
PETHREAD FirstThread, ReaperThread; PETHREAD FirstThread;
ULONG i; ULONG i;
KIRQL oldIrql;
NTSTATUS Status;
for (i=0; i < MAXIMUM_PRIORITY; i++) for (i=0; i < MAXIMUM_PRIORITY; i++)
{ {
@ -766,7 +765,7 @@ PsInitThreadManagment(VOID)
ObpCreateTypeObject(PsThreadType); ObpCreateTypeObject(PsThreadType);
PsInitializeThread(NULL, &FirstThread, NULL, TRUE); PsInitializeThread(NULL, &FirstThread, NULL, KernelMode, TRUE);
FirstThread->Tcb.State = THREAD_STATE_RUNNING; FirstThread->Tcb.State = THREAD_STATE_RUNNING;
FirstThread->Tcb.FreezeCount = 0; FirstThread->Tcb.FreezeCount = 0;
FirstThread->Tcb.UserAffinity = (1 << 0); /* Set the affinity of the first thread to the boot processor */ FirstThread->Tcb.UserAffinity = (1 << 0); /* Set the affinity of the first thread to the boot processor */
@ -776,7 +775,15 @@ PsInitThreadManagment(VOID)
DPRINT("FirstThread %x\n",FirstThread); DPRINT("FirstThread %x\n",FirstThread);
DoneInitYet = TRUE; DoneInitYet = TRUE;
}
VOID
PsInitReaperThread(VOID)
{
PETHREAD ReaperThread;
KIRQL oldIrql;
NTSTATUS Status;
/* /*
* Create the reaper thread * Create the reaper thread
*/ */
@ -785,6 +792,7 @@ PsInitThreadManagment(VOID)
Status = PsInitializeThread(NULL, Status = PsInitializeThread(NULL,
&ReaperThread, &ReaperThread,
NULL, NULL,
KernelMode,
FALSE); FALSE);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {