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 ULONG GetCurrentProcessorNumber(VOID);
|
||||||
STATIC XTAPI PKTHREAD GetCurrentThread(VOID);
|
STATIC XTAPI PKTHREAD GetCurrentThread(VOID);
|
||||||
STATIC XTAPI PKPROCESSOR_BLOCK GetProcessorBlock(IN ULONG CpuNumber);
|
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 RegisterHardwareId(IN ULONG HardwareId);
|
||||||
|
STATIC XTAPI VOID RegisterProcessorBlock(ULONG CpuNumber,
|
||||||
|
PKPROCESSOR_BLOCK ProcessorBlock);
|
||||||
STATIC XTAPI VOID SaveProcessorState(OUT PKPROCESSOR_STATE CpuState);
|
STATIC XTAPI VOID SaveProcessorState(OUT PKPROCESSOR_STATE CpuState);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ PKPROCESSOR_BLOCK
|
|||||||
KE::Processor::GetProcessorBlock(IN ULONG CpuNumber)
|
KE::Processor::GetProcessorBlock(IN ULONG CpuNumber)
|
||||||
{
|
{
|
||||||
/* Check if the requested CPU number is within dynamic bounds */
|
/* 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 */
|
/* Invalid CPU number, return NULLPTR */
|
||||||
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.
|
* 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.
|
* @return This routine returns a status code indicating the success or failure of the allocation.
|
||||||
*
|
*
|
||||||
* @since XT 1.0
|
* @since XT 1.0
|
||||||
*/
|
*/
|
||||||
XTAPI
|
XTAPI
|
||||||
XTSTATUS
|
XTSTATUS
|
||||||
KE::Processor::InitializeProcessorStructures(IN ULONG CpuCount)
|
KE::Processor::InitializeProcessorBlocks()
|
||||||
{
|
{
|
||||||
|
PACPI_SYSTEM_INFO SystemInfo;
|
||||||
XTSTATUS Status;
|
XTSTATUS Status;
|
||||||
|
|
||||||
/* Save number of CPUs installed */
|
/* Save number of CPUs installed */
|
||||||
InstalledCpus = CpuCount;
|
HL::Acpi::GetSystemInformation(&SystemInfo);
|
||||||
|
InstalledCpus = SystemInfo->CpuCount;
|
||||||
|
|
||||||
/* Allocate an array of pointers */
|
/* Allocate an array of pointers */
|
||||||
Status = MM::Allocator::AllocatePool(NonPagedPool,
|
Status = MM::Allocator::AllocatePool(NonPagedPool,
|
||||||
CpuCount * sizeof(PKPROCESSOR_BLOCK),
|
InstalledCpus * sizeof(PKPROCESSOR_BLOCK),
|
||||||
(PVOID*)&ProcessorBlocks);
|
(PVOID*)&ProcessorBlocks);
|
||||||
if(Status != STATUS_SUCCESS)
|
if(Status != STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
@@ -121,7 +120,7 @@ KE::Processor::InitializeProcessorStructures(IN ULONG CpuCount)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Zero the array initially */
|
/* Zero the array initially */
|
||||||
RTL::Memory::ZeroMemory(ProcessorBlocks, CpuCount * sizeof(PKPROCESSOR_BLOCK));
|
RTL::Memory::ZeroMemory(ProcessorBlocks, InstalledCpus * sizeof(PKPROCESSOR_BLOCK));
|
||||||
|
|
||||||
/* Return success */
|
/* Return success */
|
||||||
return STATUS_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.
|
* Saves the current processor state.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ PKPROCESSOR_BLOCK
|
|||||||
KE::Processor::GetProcessorBlock(IN ULONG CpuNumber)
|
KE::Processor::GetProcessorBlock(IN ULONG CpuNumber)
|
||||||
{
|
{
|
||||||
/* Check if the requested CPU number is within dynamic bounds */
|
/* 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 */
|
/* Invalid CPU number, return NULLPTR */
|
||||||
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.
|
* 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.
|
* @return This routine returns a status code indicating the success or failure of the allocation.
|
||||||
*
|
*
|
||||||
* @since XT 1.0
|
* @since XT 1.0
|
||||||
*/
|
*/
|
||||||
XTAPI
|
XTAPI
|
||||||
XTSTATUS
|
XTSTATUS
|
||||||
KE::Processor::InitializeProcessorStructures(IN ULONG CpuCount)
|
KE::Processor::InitializeProcessorBlocks()
|
||||||
{
|
{
|
||||||
|
PACPI_SYSTEM_INFO SystemInfo;
|
||||||
XTSTATUS Status;
|
XTSTATUS Status;
|
||||||
|
|
||||||
/* Save number of CPUs installed */
|
/* Save number of CPUs installed */
|
||||||
InstalledCpus = CpuCount;
|
HL::Acpi::GetSystemInformation(&SystemInfo);
|
||||||
|
InstalledCpus = SystemInfo->CpuCount;
|
||||||
|
|
||||||
/* Allocate an array of pointers */
|
/* Allocate an array of pointers */
|
||||||
Status = MM::Allocator::AllocatePool(NonPagedPool,
|
Status = MM::Allocator::AllocatePool(NonPagedPool,
|
||||||
CpuCount * sizeof(PKPROCESSOR_BLOCK),
|
InstalledCpus * sizeof(PKPROCESSOR_BLOCK),
|
||||||
(PVOID*)&ProcessorBlocks);
|
(PVOID*)&ProcessorBlocks);
|
||||||
if(Status != STATUS_SUCCESS)
|
if(Status != STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
@@ -121,7 +120,7 @@ KE::Processor::InitializeProcessorStructures(IN ULONG CpuCount)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Zero the array initially */
|
/* Zero the array initially */
|
||||||
RTL::Memory::ZeroMemory(ProcessorBlocks, CpuCount * sizeof(PKPROCESSOR_BLOCK));
|
RTL::Memory::ZeroMemory(ProcessorBlocks, InstalledCpus * sizeof(PKPROCESSOR_BLOCK));
|
||||||
|
|
||||||
/* Return success */
|
/* Return success */
|
||||||
return STATUS_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.
|
* Saves the current processor state.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user