Introduce PS subsystem with IDLE process and thread creation
This commit is contained in:
43
xtoskrnl/ps/process.cc
Normal file
43
xtoskrnl/ps/process.cc
Normal file
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* PROJECT: ExectOS
|
||||
* COPYRIGHT: See COPYING.md in the top level directory
|
||||
* FILE: xtoskrnl/po/process.cc
|
||||
* DESCRIPTION: Process Management
|
||||
* DEVELOPERS: Aiken Harris <harraiken91@gmail.com>
|
||||
*/
|
||||
|
||||
#include <xtos.hh>
|
||||
|
||||
|
||||
/**
|
||||
* Creates the global IDLE process.
|
||||
*
|
||||
* @param Prcb
|
||||
* Supplies a pointer to the Processor Control Block of the Bootstrap Processor.
|
||||
*
|
||||
* @return This routine does not return any value.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTAPI
|
||||
VOID
|
||||
PS::Process::CreateIdleProcess(IN PKPROCESSOR_CONTROL_BLOCK Prcb)
|
||||
{
|
||||
ULONG_PTR PageDirectory[2];
|
||||
PKPROCESS IdleProcess;
|
||||
PKTHREAD IdleThread;
|
||||
|
||||
/* Get initial IDLE thread */
|
||||
IdleThread = Prcb->CurrentThread;
|
||||
|
||||
/* Get initial IDLE process */
|
||||
IdleProcess = IdleThread->ApcState.Process;
|
||||
|
||||
/* Setup placeholder for page directory entries */
|
||||
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());
|
||||
}
|
||||
60
xtoskrnl/ps/thread.cc
Normal file
60
xtoskrnl/ps/thread.cc
Normal file
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* PROJECT: ExectOS
|
||||
* COPYRIGHT: See COPYING.md in the top level directory
|
||||
* FILE: xtoskrnl/po/thread.cc
|
||||
* DESCRIPTION: Thread Management
|
||||
* DEVELOPERS: Aiken Harris <harraiken91@gmail.com>
|
||||
*/
|
||||
|
||||
#include <xtos.hh>
|
||||
|
||||
|
||||
/**
|
||||
* Allocates and initializes a per-processor IDLE thread for an Application Processor (AP).
|
||||
*
|
||||
* @param Prcb
|
||||
* Supplies a pointer to the Processor Control Block of the target processor.
|
||||
*
|
||||
* @param Stack
|
||||
* Supplies a pointer to the pre-allocated kernel stack for the new idle thread.
|
||||
*
|
||||
* @return This routine returns a status code indicating the success or failure of the operation.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTAPI
|
||||
XTSTATUS
|
||||
PS::Thread::CreateIdleThread(IN PKPROCESSOR_CONTROL_BLOCK Prcb,
|
||||
IN PVOID Stack)
|
||||
{
|
||||
PKPROCESS IdleProcess;
|
||||
PETHREAD IdleThread;
|
||||
XTSTATUS Status;
|
||||
|
||||
/* Retrieve the global IDLE process container */
|
||||
IdleProcess = KE::KProcess::GetIdleProcess();
|
||||
|
||||
/* Allocate the Executive Thread object */
|
||||
Status = MM::Allocator::AllocatePool(NonPagedPool, sizeof(ETHREAD), (PVOID*)&IdleThread);
|
||||
if(Status != STATUS_SUCCESS)
|
||||
{
|
||||
/* Allocation failed, return the status code */
|
||||
return Status;
|
||||
}
|
||||
|
||||
/* Zero the allocated memory to prevent uninitialized data */
|
||||
RTL::Memory::ZeroMemory(IdleThread, sizeof(ETHREAD));
|
||||
|
||||
/* Register the new thread within the Processor Control Block */
|
||||
Prcb->CurrentThread = &IdleThread->ThreadControlBlock;
|
||||
Prcb->IdleThread = &IdleThread->ThreadControlBlock;
|
||||
|
||||
/* Initialize the IDLE thread */
|
||||
KE::KThread::InitializeIdleThread(IdleProcess,
|
||||
&IdleThread->ThreadControlBlock,
|
||||
Prcb,
|
||||
Stack);
|
||||
|
||||
/* Return success */
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
Reference in New Issue
Block a user