- Partial revert of r20462/63. New HAL/Po/Ki code remains, but restored the original PsIdleThread code. I know what the bug is but I'm too tired to fix it, so I'd rather revert the broken part.

- Install + 2nd stage + boot to desktop will not work in qemu, kernel-kqemu and vmware (all wax and I tested).

svn path=/trunk/; revision=24079
This commit is contained in:
Alex Ionescu
2006-09-12 05:37:14 +00:00
parent 978da5c0af
commit 6b1e4db5b5
3 changed files with 118 additions and 70 deletions
+1
View File
@@ -292,6 +292,7 @@
</directory>
<directory name="ps">
<file>debug.c</file>
<file>idle.c</file>
<file>job.c</file>
<file>kill.c</file>
<file>notify.c</file>
+115
View File
@@ -0,0 +1,115 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/ps/idle.c
* PURPOSE: Using idle time
*
* PROGRAMMERS: Alex Ionescu ([email protected])
* David Welch ([email protected])
*/
/* INCLUDES *****************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <internal/debug.h>
#if defined (ALLOC_PRAGMA)
#pragma alloc_text(INIT, PsInitIdleThread)
#endif
/* FUNCTIONS *****************************************************************/
/** System idle thread procedure
*
*/
VOID STDCALL
PsIdleThreadMain(PVOID Context)
{
KIRQL oldlvl;
PKPRCB Prcb = KeGetCurrentPrcb();
for(;;)
{
if (Prcb->DpcData[0].DpcQueueDepth > 0)
{
KeRaiseIrql(DISPATCH_LEVEL,&oldlvl);
KiDispatchInterrupt();
KeLowerIrql(oldlvl);
}
NtYieldExecution();
Ke386HaltProcessor();
}
}
/*
* HACK-O-RAMA
* Antique vestigial code left alive for the sole purpose of First/Idle Thread
* creation until I can merge my fix for properly creating them.
*/
NTSTATUS
NTAPI
PsInitializeIdleOrFirstThread(PEPROCESS Process,
PETHREAD* ThreadPtr,
PKSTART_ROUTINE StartRoutine,
KPROCESSOR_MODE AccessMode,
BOOLEAN First)
{
PETHREAD Thread;
PVOID KernelStack;
Thread = ExAllocatePool(NonPagedPool, sizeof(ETHREAD));
RtlZeroMemory(Thread, sizeof(ETHREAD));
Thread->ThreadsProcess = Process;
if (First)
{
KernelStack = P0BootStack;
}
else
{
KernelStack = (PVOID)((ULONG_PTR)MmCreateKernelStack(FALSE) +
KERNEL_STACK_SIZE);
}
KeInitializeThread(&Process->Pcb,
&Thread->Tcb,
PspSystemThreadStartup,
StartRoutine,
NULL,
NULL,
NULL,
KernelStack);
InitializeListHead(&Thread->IrpList);
*ThreadPtr = Thread;
return STATUS_SUCCESS;
}
/*
* HACK-O-RAMA
* Antique vestigial code left alive for the sole purpose of First/Idle Thread
* creation until I can merge my fix for properly creating them.
*/
VOID
INIT_FUNCTION
NTAPI
PsInitIdleThread(VOID)
{
PETHREAD IdleThread;
KIRQL oldIrql;
PsInitializeIdleOrFirstThread(PsIdleProcess,
&IdleThread,
PsIdleThreadMain,
KernelMode,
FALSE);
oldIrql = KiAcquireDispatcherLock ();
KiReadyThread(&IdleThread->Tcb);
KiReleaseDispatcherLock(oldIrql);
KeGetCurrentPrcb()->IdleThread = &IdleThread->Tcb;
KeSetPriorityThread(&IdleThread->Tcb, LOW_PRIORITY);
KeSetAffinityThread(&IdleThread->Tcb, 1 << 0);
}
+2 -70
View File
@@ -64,74 +64,6 @@ NTSTATUS STDCALL INIT_FUNCTION PspLookupKernelUserEntryPoints(VOID);
/* FUNCTIONS ***************************************************************/
VOID
FASTCALL
KiIdleLoop(VOID);
/* FUNCTIONS *****************************************************************/
/*
* HACK-O-RAMA
* Antique vestigial code left alive for the sole purpose of First/Idle Thread
* creation until I can merge my fix for properly creating them.
*/
VOID
INIT_FUNCTION
NTAPI
PsInitHackThread(VOID)
{
PETHREAD IdleThread;
KIRQL oldIrql;
IdleThread = ExAllocatePool(NonPagedPool, sizeof(ETHREAD));
RtlZeroMemory(IdleThread, sizeof(ETHREAD));
IdleThread->ThreadsProcess = PsIdleProcess;
KeInitializeThread(&PsIdleProcess->Pcb,
&IdleThread->Tcb,
PspSystemThreadStartup,
(PVOID)KiIdleLoop,
NULL,
NULL,
NULL,
P0BootStack);
InitializeListHead(&IdleThread->IrpList);
oldIrql = KiAcquireDispatcherLock ();
KiReadyThread(&IdleThread->Tcb);
KiReleaseDispatcherLock(oldIrql);
KeGetCurrentPrcb()->IdleThread = &IdleThread->Tcb;
KeSetPriorityThread(&IdleThread->Tcb, LOW_PRIORITY);
KeSetAffinityThread(&IdleThread->Tcb, 1 << 0);
}
/*
* HACK-O-RAMA
* Antique vestigial code left alive for the sole purpose of First/Idle Thread
* creation until I can merge my fix for properly creating them.
*/
VOID
INIT_FUNCTION
NTAPI
PsInitHackThread2(IN PETHREAD *Hack)
{
PETHREAD IdleThread;
IdleThread = ExAllocatePool(NonPagedPool, sizeof(ETHREAD));
RtlZeroMemory(IdleThread, sizeof(ETHREAD));
IdleThread->ThreadsProcess = PsInitialSystemProcess;
KeInitializeThread(&PsInitialSystemProcess->Pcb,
&IdleThread->Tcb,
PspSystemThreadStartup,
NULL,
NULL,
NULL,
NULL,
P0BootStack);
InitializeListHead(&IdleThread->IrpList);
*Hack = IdleThread;
}
VOID
INIT_FUNCTION
NTAPI
@@ -140,7 +72,7 @@ PiInitProcessManager(VOID)
PsInitJobManagment();
PsInitProcessManagment();
PsInitThreadManagment();
PsInitHackThread();
PsInitIdleThread();
}
VOID
@@ -183,7 +115,7 @@ PsInitThreadManagment(VOID)
ObjectTypeInitializer.DeleteProcedure = PspDeleteThread;
ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &PsThreadType);
PsInitHackThread2(&FirstThread);
PsInitializeIdleOrFirstThread(PsInitialSystemProcess, &FirstThread, NULL, KernelMode, TRUE);
FirstThread->Tcb.State = Running;
FirstThread->Tcb.FreezeCount = 0;
FirstThread->Tcb.UserAffinity = (1 << 0); /* Set the affinity of the first thread to the boot processor */