Refactor processor block initialization and add registration function
All checks were successful
All checks were successful
This commit is contained in:
@@ -27,8 +27,10 @@ namespace KE
|
||||
STATIC XTAPI ULONG GetCurrentProcessorNumber(VOID);
|
||||
STATIC XTAPI PKTHREAD GetCurrentThread(VOID);
|
||||
STATIC XTAPI PKPROCESSOR_BLOCK GetProcessorBlock(IN ULONG CpuNumber);
|
||||
STATIC XTAPI XTSTATUS InitializeProcessorStructures(IN ULONG CpuCount);
|
||||
STATIC XTAPI XTSTATUS InitializeProcessorBlocks();
|
||||
STATIC XTAPI VOID RegisterHardwareId(IN ULONG HardwareId);
|
||||
STATIC XTAPI VOID RegisterProcessorBlock(ULONG CpuNumber,
|
||||
PKPROCESSOR_BLOCK ProcessorBlock);
|
||||
STATIC XTAPI VOID SaveProcessorState(OUT PKPROCESSOR_STATE CpuState);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ PKPROCESSOR_BLOCK
|
||||
KE::Processor::GetProcessorBlock(IN ULONG CpuNumber)
|
||||
{
|
||||
/* Check if the requested CPU number is within dynamic bounds */
|
||||
if(ProcessorBlocks == NULLPTR || CpuNumber >= InstalledCpus)
|
||||
if(CpuNumber >= InstalledCpus || ProcessorBlocks == NULLPTR || ProcessorBlocks[CpuNumber] == NULLPTR)
|
||||
{
|
||||
/* Invalid CPU number, return NULLPTR */
|
||||
return NULLPTR;
|
||||
@@ -94,25 +94,24 @@ KE::Processor::GetProcessorBlock(IN ULONG CpuNumber)
|
||||
/**
|
||||
* Initializes the global processor structures by allocating an array of processor block pointers.
|
||||
*
|
||||
* @param CpuCount
|
||||
* Supplies the total number of processors present in the system.
|
||||
*
|
||||
* @return This routine returns a status code indicating the success or failure of the allocation.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTAPI
|
||||
XTSTATUS
|
||||
KE::Processor::InitializeProcessorStructures(IN ULONG CpuCount)
|
||||
KE::Processor::InitializeProcessorBlocks()
|
||||
{
|
||||
PACPI_SYSTEM_INFO SystemInfo;
|
||||
XTSTATUS Status;
|
||||
|
||||
/* Save number of CPUs installed */
|
||||
InstalledCpus = CpuCount;
|
||||
HL::Acpi::GetSystemInformation(&SystemInfo);
|
||||
InstalledCpus = SystemInfo->CpuCount;
|
||||
|
||||
/* Allocate an array of pointers */
|
||||
Status = MM::Allocator::AllocatePool(NonPagedPool,
|
||||
CpuCount * sizeof(PKPROCESSOR_BLOCK),
|
||||
InstalledCpus * sizeof(PKPROCESSOR_BLOCK),
|
||||
(PVOID*)&ProcessorBlocks);
|
||||
if(Status != STATUS_SUCCESS)
|
||||
{
|
||||
@@ -121,7 +120,7 @@ KE::Processor::InitializeProcessorStructures(IN ULONG CpuCount)
|
||||
}
|
||||
|
||||
/* Zero the array initially */
|
||||
RTL::Memory::ZeroMemory(ProcessorBlocks, CpuCount * sizeof(PKPROCESSOR_BLOCK));
|
||||
RTL::Memory::ZeroMemory(ProcessorBlocks, InstalledCpus * sizeof(PKPROCESSOR_BLOCK));
|
||||
|
||||
/* Return success */
|
||||
return STATUS_SUCCESS;
|
||||
@@ -152,6 +151,32 @@ KE::Processor::RegisterHardwareId(IN ULONG HardwareId)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers or deregisters a processor block in the global CPU table.
|
||||
*
|
||||
* @param CpuNumber
|
||||
* Specifies the logical processor number.
|
||||
*
|
||||
* @param ProcessorBlock
|
||||
* Supplies a pointer to the processor block.
|
||||
*
|
||||
* @return This routine does not return any value.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTAPI
|
||||
VOID
|
||||
KE::Processor::RegisterProcessorBlock(ULONG CpuNumber,
|
||||
PKPROCESSOR_BLOCK ProcessorBlock)
|
||||
{
|
||||
/* Check if the requested CPU number is within dynamic bounds */
|
||||
if(ProcessorBlocks != NULLPTR && CpuNumber < InstalledCpus)
|
||||
{
|
||||
/* Register processor block */
|
||||
ProcessorBlocks[CpuNumber] = ProcessorBlock;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the current processor state.
|
||||
*
|
||||
|
||||
@@ -81,7 +81,7 @@ PKPROCESSOR_BLOCK
|
||||
KE::Processor::GetProcessorBlock(IN ULONG CpuNumber)
|
||||
{
|
||||
/* Check if the requested CPU number is within dynamic bounds */
|
||||
if(ProcessorBlocks == NULLPTR || CpuNumber >= InstalledCpus)
|
||||
if(CpuNumber >= InstalledCpus || ProcessorBlocks == NULLPTR || ProcessorBlocks[CpuNumber] == NULLPTR)
|
||||
{
|
||||
/* Invalid CPU number, return NULLPTR */
|
||||
return NULLPTR;
|
||||
@@ -94,25 +94,24 @@ KE::Processor::GetProcessorBlock(IN ULONG CpuNumber)
|
||||
/**
|
||||
* Initializes the global processor structures by allocating an array of processor block pointers.
|
||||
*
|
||||
* @param CpuCount
|
||||
* Supplies the total number of processors present in the system.
|
||||
*
|
||||
* @return This routine returns a status code indicating the success or failure of the allocation.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTAPI
|
||||
XTSTATUS
|
||||
KE::Processor::InitializeProcessorStructures(IN ULONG CpuCount)
|
||||
KE::Processor::InitializeProcessorBlocks()
|
||||
{
|
||||
PACPI_SYSTEM_INFO SystemInfo;
|
||||
XTSTATUS Status;
|
||||
|
||||
/* Save number of CPUs installed */
|
||||
InstalledCpus = CpuCount;
|
||||
HL::Acpi::GetSystemInformation(&SystemInfo);
|
||||
InstalledCpus = SystemInfo->CpuCount;
|
||||
|
||||
/* Allocate an array of pointers */
|
||||
Status = MM::Allocator::AllocatePool(NonPagedPool,
|
||||
CpuCount * sizeof(PKPROCESSOR_BLOCK),
|
||||
InstalledCpus * sizeof(PKPROCESSOR_BLOCK),
|
||||
(PVOID*)&ProcessorBlocks);
|
||||
if(Status != STATUS_SUCCESS)
|
||||
{
|
||||
@@ -121,7 +120,7 @@ KE::Processor::InitializeProcessorStructures(IN ULONG CpuCount)
|
||||
}
|
||||
|
||||
/* Zero the array initially */
|
||||
RTL::Memory::ZeroMemory(ProcessorBlocks, CpuCount * sizeof(PKPROCESSOR_BLOCK));
|
||||
RTL::Memory::ZeroMemory(ProcessorBlocks, InstalledCpus * sizeof(PKPROCESSOR_BLOCK));
|
||||
|
||||
/* Return success */
|
||||
return STATUS_SUCCESS;
|
||||
@@ -152,6 +151,32 @@ KE::Processor::RegisterHardwareId(IN ULONG HardwareId)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers or deregisters a processor block in the global CPU table.
|
||||
*
|
||||
* @param CpuNumber
|
||||
* Specifies the logical processor number.
|
||||
*
|
||||
* @param ProcessorBlock
|
||||
* Supplies a pointer to the processor block.
|
||||
*
|
||||
* @return This routine does not return any value.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTAPI
|
||||
VOID
|
||||
KE::Processor::RegisterProcessorBlock(ULONG CpuNumber,
|
||||
PKPROCESSOR_BLOCK ProcessorBlock)
|
||||
{
|
||||
/* Check if the requested CPU number is within dynamic bounds */
|
||||
if(ProcessorBlocks != NULLPTR && CpuNumber < InstalledCpus)
|
||||
{
|
||||
/* Register processor block */
|
||||
ProcessorBlocks[CpuNumber] = ProcessorBlock;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the current processor state.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user