Propagate allocation failures from idle process and thread setup
This commit is contained in:
@@ -23,8 +23,8 @@ namespace KE
|
||||
public:
|
||||
STATIC XTAPI PKPROCESS GetIdleProcess(VOID);
|
||||
STATIC XTAPI PEPROCESS GetInitialProcess(VOID);
|
||||
STATIC XTAPI VOID InitializeIdleProcess(IN OUT PKPROCESS Process,
|
||||
IN PULONG_PTR DirectoryTable);
|
||||
STATIC XTAPI XTSTATUS InitializeIdleProcess(IN OUT PKPROCESS Process,
|
||||
IN PULONG_PTR DirectoryTable);
|
||||
STATIC XTAPI VOID InitializeProcess(IN OUT PKPROCESS Process,
|
||||
IN KPRIORITY Priority,
|
||||
IN PULONG_PTR DirectoryTable,
|
||||
|
||||
@@ -22,10 +22,10 @@ namespace KE
|
||||
|
||||
public:
|
||||
STATIC XTAPI PETHREAD GetInitialThread(VOID);
|
||||
STATIC XTAPI VOID InitializeIdleThread(IN PKPROCESS IdleProcess,
|
||||
IN OUT PKTHREAD IdleThread,
|
||||
IN PKPROCESSOR_CONTROL_BLOCK Prcb,
|
||||
IN PVOID Stack);
|
||||
STATIC XTAPI XTSTATUS InitializeIdleThread(IN PKPROCESS IdleProcess,
|
||||
IN OUT PKTHREAD IdleThread,
|
||||
IN PKPROCESSOR_CONTROL_BLOCK Prcb,
|
||||
IN PVOID Stack);
|
||||
STATIC XTAPI XTSTATUS InitializeThread(IN PKPROCESS Process,
|
||||
IN OUT PKTHREAD Thread,
|
||||
IN PKSYSTEM_ROUTINE SystemRoutine,
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace PS
|
||||
class Process
|
||||
{
|
||||
public:
|
||||
STATIC XTAPI VOID CreateIdleProcess(IN PKPROCESSOR_CONTROL_BLOCK Prcb);
|
||||
STATIC XTAPI XTSTATUS CreateIdleProcess(IN PKPROCESSOR_CONTROL_BLOCK Prcb);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -52,12 +52,13 @@ KE::KProcess::GetInitialProcess(VOID)
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTAPI
|
||||
VOID
|
||||
XTSTATUS
|
||||
KE::KProcess::InitializeIdleProcess(IN OUT PKPROCESS Process,
|
||||
IN PULONG_PTR DirectoryTable)
|
||||
{
|
||||
ULONG AffinitySize, MapSize;
|
||||
PACPI_SYSTEM_INFO SysInfo;
|
||||
XTSTATUS Status;
|
||||
|
||||
/* Retrieve hardware topology from ACPI */
|
||||
HL::Acpi::GetSystemInformation(&SysInfo);
|
||||
@@ -69,9 +70,21 @@ KE::KProcess::InitializeIdleProcess(IN OUT PKPROCESS Process,
|
||||
/* Align size to the 8-byte boundary */
|
||||
MapSize = (MapSize + 7) & ~7;
|
||||
|
||||
/* Allocate the process-level affinity structures */
|
||||
MM::Allocator::AllocatePool(NonPagedPool, MapSize, (PVOID*)&Process->Affinity);
|
||||
MM::Allocator::AllocatePool(NonPagedPool, MapSize, (PVOID*)&Process->ActiveProcessors);
|
||||
/* Allocate the process-level affinity structure */
|
||||
Status = MM::Allocator::AllocatePool(NonPagedPool, MapSize, (PVOID*)&Process->Affinity);
|
||||
if(Status != STATUS_SUCCESS)
|
||||
{
|
||||
/* Memory allocation failed, return the status code */
|
||||
return Status;
|
||||
}
|
||||
|
||||
/* Allocate the process-level active processors structure */
|
||||
Status = MM::Allocator::AllocatePool(NonPagedPool, MapSize, (PVOID*)&Process->ActiveProcessors);
|
||||
if(Status != STATUS_SUCCESS)
|
||||
{
|
||||
/* Memory allocation failed, return the status code */
|
||||
return Status;
|
||||
}
|
||||
|
||||
/* Zero the process-level affinity structures */
|
||||
RTL::Memory::ZeroMemory(Process->Affinity, MapSize);
|
||||
@@ -85,6 +98,9 @@ KE::KProcess::InitializeIdleProcess(IN OUT PKPROCESS Process,
|
||||
/* Initialize Idle process */
|
||||
KE::KProcess::InitializeProcess(Process, 0, DirectoryTable, FALSE);
|
||||
Process->Quantum = MAXCHAR;
|
||||
|
||||
/* Return success */
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -43,7 +43,7 @@ KE::KThread::GetInitialThread(VOID)
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTAPI
|
||||
VOID
|
||||
XTSTATUS
|
||||
KE::KThread::InitializeIdleThread(IN PKPROCESS IdleProcess,
|
||||
IN OUT PKTHREAD IdleThread,
|
||||
IN PKPROCESSOR_CONTROL_BLOCK Prcb,
|
||||
@@ -51,6 +51,7 @@ KE::KThread::InitializeIdleThread(IN PKPROCESS IdleProcess,
|
||||
{
|
||||
ULONG AffinitySize, CpuIndex, CpuTargetBit, MapSize;
|
||||
PACPI_SYSTEM_INFO SysInfo;
|
||||
XTSTATUS Status;
|
||||
|
||||
/* Retrieve hardware topology from ACPI */
|
||||
HL::Acpi::GetSystemInformation(&SysInfo);
|
||||
@@ -62,17 +63,34 @@ KE::KThread::InitializeIdleThread(IN PKPROCESS IdleProcess,
|
||||
/* Align size to the 8-byte boundary */
|
||||
MapSize = (MapSize + 7) & ~7;
|
||||
|
||||
/* Allocate the thread-level affinity structures */
|
||||
MM::Allocator::AllocatePool(NonPagedPool, MapSize, (PVOID*)&IdleThread->Affinity);
|
||||
MM::Allocator::AllocatePool(NonPagedPool, MapSize, (PVOID*)&IdleThread->UserAffinity);
|
||||
/* Allocate the thread-level affinity structure */
|
||||
Status = MM::Allocator::AllocatePool(NonPagedPool, MapSize, (PVOID*)&IdleThread->Affinity);
|
||||
if(Status != STATUS_SUCCESS)
|
||||
{
|
||||
/* Memory allocation failed, return the status code */
|
||||
return Status;
|
||||
}
|
||||
|
||||
/* Allocate the thread-level user affinity structure */
|
||||
Status = MM::Allocator::AllocatePool(NonPagedPool, MapSize, (PVOID*)&IdleThread->UserAffinity);
|
||||
if(Status != STATUS_SUCCESS)
|
||||
{
|
||||
/* Memory allocation failed, return the status code */
|
||||
return Status;
|
||||
}
|
||||
|
||||
/* Zero the thread-level affinity structures */
|
||||
RTL::Memory::ZeroMemory(IdleThread->Affinity, MapSize);
|
||||
RTL::Memory::ZeroMemory(IdleThread->UserAffinity, MapSize);
|
||||
|
||||
/* Initialize Idle thread */
|
||||
KE::KThread::InitializeThread(IdleProcess, IdleThread, NULLPTR, NULLPTR, NULLPTR,
|
||||
NULLPTR, NULLPTR, Stack, TRUE);
|
||||
Status = KE::KThread::InitializeThread(IdleProcess, IdleThread, NULLPTR, NULLPTR, NULLPTR,
|
||||
NULLPTR, NULLPTR, Stack, TRUE);
|
||||
if(Status != STATUS_SUCCESS)
|
||||
{
|
||||
/* Failed to initialize IDLE thread, return status code */
|
||||
return Status;
|
||||
}
|
||||
|
||||
/* Configure Idle thread scheduling parameters */
|
||||
IdleThread->NextProcessor = Prcb->CpuNumber;
|
||||
@@ -96,6 +114,9 @@ KE::KThread::InitializeIdleThread(IN PKPROCESS IdleProcess,
|
||||
|
||||
/* Register this CPU as active in the Idle Process */
|
||||
IdleProcess->ActiveProcessors->Bitmap[CpuIndex] |= ((KAFFINITY)1 << CpuTargetBit);
|
||||
|
||||
/* Return success */
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,12 +20,13 @@
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTAPI
|
||||
VOID
|
||||
XTSTATUS
|
||||
PS::Process::CreateIdleProcess(IN PKPROCESSOR_CONTROL_BLOCK Prcb)
|
||||
{
|
||||
ULONG_PTR PageDirectory[2];
|
||||
PKPROCESS IdleProcess;
|
||||
PKTHREAD IdleThread;
|
||||
XTSTATUS Status;
|
||||
|
||||
/* Get initial IDLE thread */
|
||||
IdleThread = Prcb->CurrentThread;
|
||||
@@ -37,7 +38,14 @@ PS::Process::CreateIdleProcess(IN PKPROCESSOR_CONTROL_BLOCK Prcb)
|
||||
PageDirectory[0] = 0;
|
||||
PageDirectory[1] = 0;
|
||||
|
||||
/* Initialize Idle process and Idle thread */
|
||||
KE::KProcess::InitializeIdleProcess(IdleProcess, PageDirectory);
|
||||
KE::KThread::InitializeIdleThread(IdleProcess, IdleThread, Prcb, AR::ProcessorSupport::GetBootStack());
|
||||
/* Initialize IDLE process */
|
||||
Status = KE::KProcess::InitializeIdleProcess(IdleProcess, PageDirectory);
|
||||
if(Status != STATUS_SUCCESS)
|
||||
{
|
||||
/* Failed to initialize IDLE process, return status code */
|
||||
return Status;
|
||||
}
|
||||
|
||||
/* Initialize IDLE thread */
|
||||
return KE::KThread::InitializeIdleThread(IdleProcess, IdleThread, Prcb, AR::ProcessorSupport::GetBootStack());
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ PS::Thread::CreateIdleThread(IN PKPROCESSOR_CONTROL_BLOCK Prcb,
|
||||
Status = MM::Allocator::AllocatePool(NonPagedPool, sizeof(ETHREAD), (PVOID*)&IdleThread);
|
||||
if(Status != STATUS_SUCCESS)
|
||||
{
|
||||
/* Allocation failed, return the status code */
|
||||
/* Memory allocation failed, return the status code */
|
||||
return Status;
|
||||
}
|
||||
|
||||
@@ -50,8 +50,5 @@ PS::Thread::CreateIdleThread(IN PKPROCESSOR_CONTROL_BLOCK Prcb,
|
||||
Prcb->IdleThread = &IdleThread->ThreadControlBlock;
|
||||
|
||||
/* Initialize the IDLE thread */
|
||||
KE::KThread::InitializeIdleThread(IdleProcess, &IdleThread->ThreadControlBlock, Prcb, Stack);
|
||||
|
||||
/* Return success */
|
||||
return STATUS_SUCCESS;
|
||||
return KE::KThread::InitializeIdleThread(IdleProcess, &IdleThread->ThreadControlBlock, Prcb, Stack);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user