DynamicTablesPkg: Add ACPI 6.3 SPE support to MADT generator

The Dynamic Tables Framework now supports generating Multiple APIC
Description Table (MADT) revision 5 for ARM platforms while maintaining
backward-compatibility with ACPI 6.2.

The relevant change is the enablement of the Statistical Profiling
Extension (SPE).

Signed-off-by: Krzysztof Koch <krzysztof.koch@arm.com>
Reviewed-by: Alexei Fedorov <Alexei.Fedorov@arm.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
This commit is contained in:
Krzysztof Koch 2019-04-09 14:44:37 +01:00 committed by Sami Mujawar
parent ccc97f6df4
commit 5506701f79
2 changed files with 66 additions and 46 deletions

View File

@ -155,6 +155,13 @@ typedef struct CmArmGicCInfo {
ACPI Specification. ACPI Specification.
*/ */
UINT8 ProcessorPowerEfficiencyClass; UINT8 ProcessorPowerEfficiencyClass;
/** Statistical Profiling Extension buffer overflow GSIV. Zero if
unsupported by this processor. This field was introduced in
ACPI 6.3 (MADT revision 5) and is therefore ignored when
generating MADT revision 4 or lower.
*/
UINT16 SpeOverflowInterrupt;
} CM_ARM_GICC_INFO; } CM_ARM_GICC_INFO;
/** A structure that describes the /** A structure that describes the

View File

@ -5,7 +5,7 @@
SPDX-License-Identifier: BSD-2-Clause-Patent SPDX-License-Identifier: BSD-2-Clause-Patent
@par Reference(s): @par Reference(s):
- ACPI 6.2 Specification - Errata A, September 2017 - ACPI 6.3 Specification - January 2019
**/ **/
@ -82,25 +82,27 @@ GET_OBJECT_LIST (
); );
/** This function updates the GIC CPU Interface Information in the /** This function updates the GIC CPU Interface Information in the
EFI_ACPI_6_2_GIC_STRUCTURE structure. EFI_ACPI_6_3_GIC_STRUCTURE structure.
@param [in] Gicc Pointer to GIC CPU Interface structure. @param [in] Gicc Pointer to GIC CPU Interface structure.
@param [in] GicCInfo Pointer to the GIC CPU Interface Information. @param [in] GicCInfo Pointer to the GIC CPU Interface Information.
@param [in] MadtRev MADT table revision.
**/ **/
STATIC STATIC
VOID VOID
AddGICC ( AddGICC (
IN EFI_ACPI_6_2_GIC_STRUCTURE * CONST Gicc, IN EFI_ACPI_6_3_GIC_STRUCTURE * CONST Gicc,
IN CONST CM_ARM_GICC_INFO * CONST GicCInfo IN CONST CM_ARM_GICC_INFO * CONST GicCInfo,
IN CONST UINT8 MadtRev
) )
{ {
ASSERT (Gicc != NULL); ASSERT (Gicc != NULL);
ASSERT (GicCInfo != NULL); ASSERT (GicCInfo != NULL);
// UINT8 Type // UINT8 Type
Gicc->Type = EFI_ACPI_6_2_GIC; Gicc->Type = EFI_ACPI_6_3_GIC;
// UINT8 Length // UINT8 Length
Gicc->Length = sizeof (EFI_ACPI_6_2_GIC_STRUCTURE); Gicc->Length = sizeof (EFI_ACPI_6_3_GIC_STRUCTURE);
// UINT16 Reserved // UINT16 Reserved
Gicc->Reserved = EFI_ACPI_RESERVED_WORD; Gicc->Reserved = EFI_ACPI_RESERVED_WORD;
@ -134,10 +136,18 @@ AddGICC (
// UINT8 ProcessorPowerEfficiencyClass // UINT8 ProcessorPowerEfficiencyClass
Gicc->ProcessorPowerEfficiencyClass = Gicc->ProcessorPowerEfficiencyClass =
GicCInfo->ProcessorPowerEfficiencyClass; GicCInfo->ProcessorPowerEfficiencyClass;
// UINT8 Reserved2[3] // UINT8 Reserved2
Gicc->Reserved2[0] = EFI_ACPI_RESERVED_BYTE; Gicc->Reserved2 = EFI_ACPI_RESERVED_BYTE;
Gicc->Reserved2[1] = EFI_ACPI_RESERVED_BYTE;
Gicc->Reserved2[2] = EFI_ACPI_RESERVED_BYTE; // UINT16 SpeOverflowInterrupt
if (MadtRev > EFI_ACPI_6_2_MULTIPLE_APIC_DESCRIPTION_TABLE_REVISION) {
Gicc->SpeOverflowInterrupt = GicCInfo->SpeOverflowInterrupt;
} else {
// Setting SpeOverflowInterrupt to 0 ensures backward compatibility with
// ACPI 6.2 by also clearing the Reserved2[1] and Reserved2[2] fields
// in EFI_ACPI_6_2_GIC_STRUCTURE.
Gicc->SpeOverflowInterrupt = 0;
}
} }
/** /**
@ -193,6 +203,7 @@ IsAcpiUidEqual (
@param [in] Gicc Pointer to GIC CPU Interface structure list. @param [in] Gicc Pointer to GIC CPU Interface structure list.
@param [in] GicCInfo Pointer to the GIC CPU Information list. @param [in] GicCInfo Pointer to the GIC CPU Information list.
@param [in] GicCCount Count of GIC CPU Interfaces. @param [in] GicCCount Count of GIC CPU Interfaces.
@param [in] MadtRev MADT table revision.
@retval EFI_SUCCESS GIC CPU Interface Information was added @retval EFI_SUCCESS GIC CPU Interface Information was added
successfully. successfully.
@ -203,9 +214,10 @@ IsAcpiUidEqual (
STATIC STATIC
EFI_STATUS EFI_STATUS
AddGICCList ( AddGICCList (
IN EFI_ACPI_6_2_GIC_STRUCTURE * Gicc, IN EFI_ACPI_6_3_GIC_STRUCTURE * Gicc,
IN CONST CM_ARM_GICC_INFO * GicCInfo, IN CONST CM_ARM_GICC_INFO * GicCInfo,
IN UINT32 GicCCount IN UINT32 GicCCount,
IN CONST UINT8 MadtRev
) )
{ {
BOOLEAN IsAcpiProcUidDuplicated; BOOLEAN IsAcpiProcUidDuplicated;
@ -226,7 +238,7 @@ AddGICCList (
} }
while (GicCCount-- != 0) { while (GicCCount-- != 0) {
AddGICC (Gicc++, GicCInfo++); AddGICC (Gicc++, GicCInfo++, MadtRev);
} }
return EFI_SUCCESS; return EFI_SUCCESS;
@ -240,7 +252,7 @@ AddGICCList (
STATIC STATIC
VOID VOID
AddGICD ( AddGICD (
EFI_ACPI_6_2_GIC_DISTRIBUTOR_STRUCTURE * CONST Gicd, EFI_ACPI_6_3_GIC_DISTRIBUTOR_STRUCTURE * CONST Gicd,
CONST CM_ARM_GICD_INFO * CONST GicDInfo CONST CM_ARM_GICD_INFO * CONST GicDInfo
) )
{ {
@ -248,9 +260,9 @@ AddGICD (
ASSERT (GicDInfo != NULL); ASSERT (GicDInfo != NULL);
// UINT8 Type // UINT8 Type
Gicd->Type = EFI_ACPI_6_2_GICD; Gicd->Type = EFI_ACPI_6_3_GICD;
// UINT8 Length // UINT8 Length
Gicd->Length = sizeof (EFI_ACPI_6_2_GIC_DISTRIBUTOR_STRUCTURE); Gicd->Length = sizeof (EFI_ACPI_6_3_GIC_DISTRIBUTOR_STRUCTURE);
// UINT16 Reserved // UINT16 Reserved
Gicd->Reserved1 = EFI_ACPI_RESERVED_WORD; Gicd->Reserved1 = EFI_ACPI_RESERVED_WORD;
// UINT32 Identifier // UINT32 Identifier
@ -277,15 +289,15 @@ AddGICD (
STATIC STATIC
VOID VOID
AddGICMsiFrame ( AddGICMsiFrame (
IN EFI_ACPI_6_2_GIC_MSI_FRAME_STRUCTURE * CONST GicMsiFrame, IN EFI_ACPI_6_3_GIC_MSI_FRAME_STRUCTURE * CONST GicMsiFrame,
IN CONST CM_ARM_GIC_MSI_FRAME_INFO * CONST GicMsiFrameInfo IN CONST CM_ARM_GIC_MSI_FRAME_INFO * CONST GicMsiFrameInfo
) )
{ {
ASSERT (GicMsiFrame != NULL); ASSERT (GicMsiFrame != NULL);
ASSERT (GicMsiFrameInfo != NULL); ASSERT (GicMsiFrameInfo != NULL);
GicMsiFrame->Type = EFI_ACPI_6_2_GIC_MSI_FRAME; GicMsiFrame->Type = EFI_ACPI_6_3_GIC_MSI_FRAME;
GicMsiFrame->Length = sizeof (EFI_ACPI_6_2_GIC_MSI_FRAME_STRUCTURE); GicMsiFrame->Length = sizeof (EFI_ACPI_6_3_GIC_MSI_FRAME_STRUCTURE);
GicMsiFrame->Reserved1 = EFI_ACPI_RESERVED_WORD; GicMsiFrame->Reserved1 = EFI_ACPI_RESERVED_WORD;
GicMsiFrame->GicMsiFrameId = GicMsiFrameInfo->GicMsiFrameId; GicMsiFrame->GicMsiFrameId = GicMsiFrameInfo->GicMsiFrameId;
GicMsiFrame->PhysicalBaseAddress = GicMsiFrameInfo->PhysicalBaseAddress; GicMsiFrame->PhysicalBaseAddress = GicMsiFrameInfo->PhysicalBaseAddress;
@ -304,7 +316,7 @@ AddGICMsiFrame (
STATIC STATIC
VOID VOID
AddGICMsiFrameInfoList ( AddGICMsiFrameInfoList (
IN EFI_ACPI_6_2_GIC_MSI_FRAME_STRUCTURE * GicMsiFrame, IN EFI_ACPI_6_3_GIC_MSI_FRAME_STRUCTURE * GicMsiFrame,
IN CONST CM_ARM_GIC_MSI_FRAME_INFO * GicMsiFrameInfo, IN CONST CM_ARM_GIC_MSI_FRAME_INFO * GicMsiFrameInfo,
IN UINT32 GicMsiFrameCount IN UINT32 GicMsiFrameCount
) )
@ -325,15 +337,15 @@ AddGICMsiFrameInfoList (
STATIC STATIC
VOID VOID
AddGICRedistributor ( AddGICRedistributor (
IN EFI_ACPI_6_2_GICR_STRUCTURE * CONST Gicr, IN EFI_ACPI_6_3_GICR_STRUCTURE * CONST Gicr,
IN CONST CM_ARM_GIC_REDIST_INFO * CONST GicRedisributorInfo IN CONST CM_ARM_GIC_REDIST_INFO * CONST GicRedisributorInfo
) )
{ {
ASSERT (Gicr != NULL); ASSERT (Gicr != NULL);
ASSERT (GicRedisributorInfo != NULL); ASSERT (GicRedisributorInfo != NULL);
Gicr->Type = EFI_ACPI_6_2_GICR; Gicr->Type = EFI_ACPI_6_3_GICR;
Gicr->Length = sizeof (EFI_ACPI_6_2_GICR_STRUCTURE); Gicr->Length = sizeof (EFI_ACPI_6_3_GICR_STRUCTURE);
Gicr->Reserved = EFI_ACPI_RESERVED_WORD; Gicr->Reserved = EFI_ACPI_RESERVED_WORD;
Gicr->DiscoveryRangeBaseAddress = Gicr->DiscoveryRangeBaseAddress =
GicRedisributorInfo->DiscoveryRangeBaseAddress; GicRedisributorInfo->DiscoveryRangeBaseAddress;
@ -349,7 +361,7 @@ AddGICRedistributor (
STATIC STATIC
VOID VOID
AddGICRedistributorList ( AddGICRedistributorList (
IN EFI_ACPI_6_2_GICR_STRUCTURE * Gicr, IN EFI_ACPI_6_3_GICR_STRUCTURE * Gicr,
IN CONST CM_ARM_GIC_REDIST_INFO * GicRInfo, IN CONST CM_ARM_GIC_REDIST_INFO * GicRInfo,
IN UINT32 GicRCount IN UINT32 GicRCount
) )
@ -370,15 +382,15 @@ AddGICRedistributorList (
STATIC STATIC
VOID VOID
AddGICInterruptTranslationService ( AddGICInterruptTranslationService (
IN EFI_ACPI_6_2_GIC_ITS_STRUCTURE * CONST GicIts, IN EFI_ACPI_6_3_GIC_ITS_STRUCTURE * CONST GicIts,
IN CONST CM_ARM_GIC_ITS_INFO * CONST GicItsInfo IN CONST CM_ARM_GIC_ITS_INFO * CONST GicItsInfo
) )
{ {
ASSERT (GicIts != NULL); ASSERT (GicIts != NULL);
ASSERT (GicItsInfo != NULL); ASSERT (GicItsInfo != NULL);
GicIts->Type = EFI_ACPI_6_2_GIC_ITS; GicIts->Type = EFI_ACPI_6_3_GIC_ITS;
GicIts->Length = sizeof (EFI_ACPI_6_2_GIC_ITS_STRUCTURE); GicIts->Length = sizeof (EFI_ACPI_6_3_GIC_ITS_STRUCTURE);
GicIts->Reserved = EFI_ACPI_RESERVED_WORD; GicIts->Reserved = EFI_ACPI_RESERVED_WORD;
GicIts->GicItsId = GicItsInfo->GicItsId; GicIts->GicItsId = GicItsInfo->GicItsId;
GicIts->PhysicalBaseAddress = GicItsInfo->PhysicalBaseAddress; GicIts->PhysicalBaseAddress = GicItsInfo->PhysicalBaseAddress;
@ -395,7 +407,7 @@ AddGICInterruptTranslationService (
STATIC STATIC
VOID VOID
AddGICItsList ( AddGICItsList (
IN EFI_ACPI_6_2_GIC_ITS_STRUCTURE * GicIts, IN EFI_ACPI_6_3_GIC_ITS_STRUCTURE * GicIts,
IN CONST CM_ARM_GIC_ITS_INFO * GicItsInfo, IN CONST CM_ARM_GIC_ITS_INFO * GicItsInfo,
IN UINT32 GicItsCount IN UINT32 GicItsCount
) )
@ -458,7 +470,7 @@ BuildMadtTable (
UINT32 GicRedistOffset; UINT32 GicRedistOffset;
UINT32 GicItsOffset; UINT32 GicItsOffset;
EFI_ACPI_6_2_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER * Madt; EFI_ACPI_6_3_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER * Madt;
ASSERT (This != NULL); ASSERT (This != NULL);
ASSERT (AcpiTableInfo != NULL); ASSERT (AcpiTableInfo != NULL);
@ -589,22 +601,22 @@ BuildMadtTable (
goto error_handler; goto error_handler;
} }
TableSize = sizeof (EFI_ACPI_6_2_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER); TableSize = sizeof (EFI_ACPI_6_3_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER);
GicCOffset = TableSize; GicCOffset = TableSize;
TableSize += (sizeof (EFI_ACPI_6_2_GIC_STRUCTURE) * GicCCount); TableSize += (sizeof (EFI_ACPI_6_3_GIC_STRUCTURE) * GicCCount);
GicDOffset = TableSize; GicDOffset = TableSize;
TableSize += (sizeof (EFI_ACPI_6_2_GIC_DISTRIBUTOR_STRUCTURE) * GicDCount); TableSize += (sizeof (EFI_ACPI_6_3_GIC_DISTRIBUTOR_STRUCTURE) * GicDCount);
GicMSIOffset = TableSize; GicMSIOffset = TableSize;
TableSize += (sizeof (EFI_ACPI_6_2_GIC_MSI_FRAME_STRUCTURE) * GicMSICount); TableSize += (sizeof (EFI_ACPI_6_3_GIC_MSI_FRAME_STRUCTURE) * GicMSICount);
GicRedistOffset = TableSize; GicRedistOffset = TableSize;
TableSize += (sizeof (EFI_ACPI_6_2_GICR_STRUCTURE) * GicRedistCount); TableSize += (sizeof (EFI_ACPI_6_3_GICR_STRUCTURE) * GicRedistCount);
GicItsOffset = TableSize; GicItsOffset = TableSize;
TableSize += (sizeof (EFI_ACPI_6_2_GIC_ITS_STRUCTURE) * GicItsCount); TableSize += (sizeof (EFI_ACPI_6_3_GIC_ITS_STRUCTURE) * GicItsCount);
// Allocate the Buffer for MADT table // Allocate the Buffer for MADT table
*Table = (EFI_ACPI_DESCRIPTION_HEADER*)AllocateZeroPool (TableSize); *Table = (EFI_ACPI_DESCRIPTION_HEADER*)AllocateZeroPool (TableSize);
@ -620,7 +632,7 @@ BuildMadtTable (
goto error_handler; goto error_handler;
} }
Madt = (EFI_ACPI_6_2_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER*)*Table; Madt = (EFI_ACPI_6_3_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER*)*Table;
DEBUG (( DEBUG ((
DEBUG_INFO, DEBUG_INFO,
@ -646,9 +658,10 @@ BuildMadtTable (
} }
Status = AddGICCList ( Status = AddGICCList (
(EFI_ACPI_6_2_GIC_STRUCTURE*)((UINT8*)Madt + GicCOffset), (EFI_ACPI_6_3_GIC_STRUCTURE*)((UINT8*)Madt + GicCOffset),
GicCInfo, GicCInfo,
GicCCount GicCCount,
Madt->Header.Revision
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG (( DEBUG ((
@ -660,13 +673,13 @@ BuildMadtTable (
} }
AddGICD ( AddGICD (
(EFI_ACPI_6_2_GIC_DISTRIBUTOR_STRUCTURE*)((UINT8*)Madt + GicDOffset), (EFI_ACPI_6_3_GIC_DISTRIBUTOR_STRUCTURE*)((UINT8*)Madt + GicDOffset),
GicDInfo GicDInfo
); );
if (GicMSICount != 0) { if (GicMSICount != 0) {
AddGICMsiFrameInfoList ( AddGICMsiFrameInfoList (
(EFI_ACPI_6_2_GIC_MSI_FRAME_STRUCTURE*)((UINT8*)Madt + GicMSIOffset), (EFI_ACPI_6_3_GIC_MSI_FRAME_STRUCTURE*)((UINT8*)Madt + GicMSIOffset),
GicMSIInfo, GicMSIInfo,
GicMSICount GicMSICount
); );
@ -674,7 +687,7 @@ BuildMadtTable (
if (GicRedistCount != 0) { if (GicRedistCount != 0) {
AddGICRedistributorList ( AddGICRedistributorList (
(EFI_ACPI_6_2_GICR_STRUCTURE*)((UINT8*)Madt + GicRedistOffset), (EFI_ACPI_6_3_GICR_STRUCTURE*)((UINT8*)Madt + GicRedistOffset),
GicRedistInfo, GicRedistInfo,
GicRedistCount GicRedistCount
); );
@ -682,7 +695,7 @@ BuildMadtTable (
if (GicItsCount != 0) { if (GicItsCount != 0) {
AddGICItsList ( AddGICItsList (
(EFI_ACPI_6_2_GIC_ITS_STRUCTURE*)((UINT8*)Madt + GicItsOffset), (EFI_ACPI_6_3_GIC_ITS_STRUCTURE*)((UINT8*)Madt + GicItsOffset),
GicItsInfo, GicItsInfo,
GicItsCount GicItsCount
); );
@ -749,9 +762,9 @@ ACPI_TABLE_GENERATOR MadtGenerator = {
// Generator Description // Generator Description
L"ACPI.STD.MADT.GENERATOR", L"ACPI.STD.MADT.GENERATOR",
// ACPI Table Signature // ACPI Table Signature
EFI_ACPI_6_2_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE, EFI_ACPI_6_3_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE,
// ACPI Table Revision supported by this Generator // ACPI Table Revision supported by this Generator
EFI_ACPI_6_2_MULTIPLE_APIC_DESCRIPTION_TABLE_REVISION, EFI_ACPI_6_3_MULTIPLE_APIC_DESCRIPTION_TABLE_REVISION,
// Minimum supported ACPI Table Revision // Minimum supported ACPI Table Revision
EFI_ACPI_6_2_MULTIPLE_APIC_DESCRIPTION_TABLE_REVISION, EFI_ACPI_6_2_MULTIPLE_APIC_DESCRIPTION_TABLE_REVISION,
// Creator ID // Creator ID