Get system information based on the ACPI (currently only number of CPUs)
This commit is contained in:
parent
829fc49aac
commit
658cb2d3c8
@ -254,6 +254,65 @@ HlpInitializeAcpiSystemDescriptionTable(OUT PACPI_DESCRIPTION_HEADER *AcpiTable)
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes System Information structure based on the ACPI provided data.
|
||||
*
|
||||
* @return This routine returns a status code.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTAPI
|
||||
XTSTATUS
|
||||
HlpInitializeAcpiSystemInformation(VOID)
|
||||
{
|
||||
PUCHAR MadtTable;
|
||||
PACPI_MADT Madt;
|
||||
XTSTATUS Status;
|
||||
ULONG CpuCount;
|
||||
|
||||
/* Zero the ACPI system information structure */
|
||||
RtlZeroMemory(&HlpAcpiSystemInfo, sizeof(ACPI_SYSTEM_INFO));
|
||||
|
||||
/* Get Multi-APIC Description Table (MADT) */
|
||||
Status = HlGetAcpiTable(ACPI_MADT_SIGNATURE, (PACPI_DESCRIPTION_HEADER*)&Madt);
|
||||
if(Status != STATUS_SUCCESS)
|
||||
{
|
||||
/* Failed to get MADT, return error */
|
||||
return STATUS_NOT_FOUND;
|
||||
}
|
||||
|
||||
/* Set APIC table traverse pointer and initialize number of CPUs */
|
||||
MadtTable = (PUCHAR)Madt->ApicTables;
|
||||
CpuCount = 0;
|
||||
|
||||
/* Traverse all MADT tables to get number of processors */
|
||||
while(MadtTable <= ((PUCHAR)Madt + Madt->Header.Length))
|
||||
{
|
||||
/* Check if this is a local APIC subtable */
|
||||
if((((PACPI_MADT_TABLE_LOCAL_APIC)MadtTable)->Header.Type == ACPI_MADT_LOCAL_APIC) &&
|
||||
(((PACPI_MADT_TABLE_LOCAL_APIC)MadtTable)->Header.Length == sizeof(ACPI_MADT_TABLE_LOCAL_APIC)))
|
||||
{
|
||||
/* Make sure, this CPU can be enabled */
|
||||
if(((PACPI_MADT_TABLE_LOCAL_APIC)MadtTable)->LapicFlags & ACPI_MADT_PLAOC_ENABLED)
|
||||
{
|
||||
/* Increment number of CPUs */
|
||||
CpuCount++;
|
||||
}
|
||||
|
||||
/* Go to the next MADT table */
|
||||
MadtTable += ((PACPI_MADT_TABLE_LOCAL_APIC)MadtTable)->Header.Length;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Any other MADT table, try to go to the next one byte-by-byte */
|
||||
MadtTable += 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Return success */
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the ACPI Timer.
|
||||
*
|
||||
|
@ -15,6 +15,9 @@ LIST_ENTRY HlpAcpiCacheList;
|
||||
/* ACPI Root System Description Pointer (RSDP) */
|
||||
PACPI_RSDP HlpAcpiRsdp;
|
||||
|
||||
/* ACPI system information */
|
||||
ACPI_SYSTEM_INFO HlpAcpiSystemInfo;
|
||||
|
||||
/* ACPI timer information */
|
||||
ACPI_TIMER_INFO HlpAcpiTimerInfo;
|
||||
|
||||
|
@ -29,6 +29,13 @@ HlInitializeSystem(VOID)
|
||||
return Status;
|
||||
}
|
||||
|
||||
/* Get system information from ACPI */
|
||||
Status = HlpInitializeAcpiSystemInformation();
|
||||
if(Status != STATUS_SUCCESS)
|
||||
{
|
||||
return Status;
|
||||
}
|
||||
|
||||
/* Return success */
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
@ -18,6 +18,9 @@ EXTERN LIST_ENTRY HlpAcpiCacheList;
|
||||
/* ACPI Root System Description Pointer (RSDP) */
|
||||
EXTERN PACPI_RSDP HlpAcpiRsdp;
|
||||
|
||||
/* ACPI system information */
|
||||
EXTERN ACPI_SYSTEM_INFO HlpAcpiSystemInfo;
|
||||
|
||||
/* ACPI timer information */
|
||||
EXTERN ACPI_TIMER_INFO HlpAcpiTimerInfo;
|
||||
|
||||
|
@ -99,6 +99,10 @@ XTAPI
|
||||
XTSTATUS
|
||||
HlpInitializeAcpiSystemDescriptionTable(OUT PACPI_DESCRIPTION_HEADER *AcpiTable);
|
||||
|
||||
XTAPI
|
||||
XTSTATUS
|
||||
HlpInitializeAcpiSystemInformation(VOID);
|
||||
|
||||
XTAPI
|
||||
XTSTATUS
|
||||
HlpInitializeAcpiTimer(VOID);
|
||||
|
Loading…
Reference in New Issue
Block a user