mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-26 23:24:03 +02:00
DynamicTablesPkg: AcpiSratLib: Prepare to support other archs
Allow other architectures to reuse the AcpiSratLib by extracting the Arm specific part of the table generation. Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
This commit is contained in:
parent
acaf99827f
commit
c6e0eed072
@ -18,6 +18,13 @@
|
|||||||
|
|
||||||
[Sources]
|
[Sources]
|
||||||
SratGenerator.c
|
SratGenerator.c
|
||||||
|
SratGenerator.h
|
||||||
|
|
||||||
|
[Sources.ARM, Sources.AARCH64]
|
||||||
|
Arm/ArmSratGenerator.c
|
||||||
|
|
||||||
|
[Sources.IA32, Sources.X64]
|
||||||
|
SratGeneratorNull.c
|
||||||
|
|
||||||
[Packages]
|
[Packages]
|
||||||
EmbeddedPkg/EmbeddedPkg.dec
|
EmbeddedPkg/EmbeddedPkg.dec
|
||||||
|
@ -0,0 +1,262 @@
|
|||||||
|
/** @file
|
||||||
|
Arm SRAT Table Generator
|
||||||
|
|
||||||
|
Copyright (c) 2019 - 2020, Arm Limited. All rights reserved.
|
||||||
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
|
||||||
|
@par Reference(s):
|
||||||
|
- ACPI 6.3 Specification, January 2019
|
||||||
|
|
||||||
|
@par Glossary:
|
||||||
|
- Cm or CM - Configuration Manager
|
||||||
|
- Obj or OBJ - Object
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include <Library/AcpiLib.h>
|
||||||
|
#include <Library/BaseLib.h>
|
||||||
|
#include <Library/DebugLib.h>
|
||||||
|
#include <Library/MemoryAllocationLib.h>
|
||||||
|
#include <Protocol/AcpiTable.h>
|
||||||
|
|
||||||
|
// Module specific include files.
|
||||||
|
#include <AcpiTableGenerator.h>
|
||||||
|
#include <ConfigurationManagerObject.h>
|
||||||
|
#include <ConfigurationManagerHelper.h>
|
||||||
|
#include <Library/TableHelperLib.h>
|
||||||
|
#include <Protocol/ConfigurationManagerProtocol.h>
|
||||||
|
|
||||||
|
#include "SratGenerator.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
ARM standard SRAT Generator
|
||||||
|
|
||||||
|
Requirements:
|
||||||
|
The following Configuration Manager Object(s) are used by this Generator:
|
||||||
|
- EArmObjGicCInfo (REQUIRED)
|
||||||
|
- EArmObjGicItsInfo (OPTIONAL)
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** This macro expands to a function that retrieves the GIC
|
||||||
|
CPU interface Information from the Configuration Manager.
|
||||||
|
*/
|
||||||
|
GET_OBJECT_LIST (
|
||||||
|
EObjNameSpaceArm,
|
||||||
|
EArmObjGicCInfo,
|
||||||
|
CM_ARM_GICC_INFO
|
||||||
|
);
|
||||||
|
|
||||||
|
/** This macro expands to a function that retrieves the GIC
|
||||||
|
Interrupt Translation Service Information from the
|
||||||
|
Configuration Manager.
|
||||||
|
*/
|
||||||
|
GET_OBJECT_LIST (
|
||||||
|
EObjNameSpaceArm,
|
||||||
|
EArmObjGicItsInfo,
|
||||||
|
CM_ARM_GIC_ITS_INFO
|
||||||
|
);
|
||||||
|
|
||||||
|
/** Enum of the Arm specific CM objects required to
|
||||||
|
build the arch specific information of the SRAT table.
|
||||||
|
*/
|
||||||
|
typedef enum ArmSratSubTableType {
|
||||||
|
EArmGicCSubTableType,
|
||||||
|
EArmGicItsSubTableType,
|
||||||
|
EArmSubTableTypeMax,
|
||||||
|
} EARM_SRAT_SUB_TABLE_TYPE;
|
||||||
|
|
||||||
|
typedef struct SratSubTable {
|
||||||
|
/// Start offset of the arch specific sub-table.
|
||||||
|
UINT32 Offset;
|
||||||
|
|
||||||
|
/// Count
|
||||||
|
UINT32 Count;
|
||||||
|
|
||||||
|
/// Array of CmInfo objects of the relevant type.
|
||||||
|
VOID *CmInfo;
|
||||||
|
} SRAT_SUB_TABLE;
|
||||||
|
|
||||||
|
STATIC SRAT_SUB_TABLE mSratSubTable[EArmSubTableTypeMax];
|
||||||
|
|
||||||
|
/** Reserve arch sub-tables space.
|
||||||
|
|
||||||
|
@param [in] CfgMgrProtocol Pointer to the Configuration Manager
|
||||||
|
@param [in, out] ArchOffset On input, contains the offset where arch specific
|
||||||
|
sub-tables can be written. It is expected that
|
||||||
|
there enough space to write all the arch specific
|
||||||
|
sub-tables from this offset onward.
|
||||||
|
On ouput, contains the ending offset of the arch
|
||||||
|
specific sub-tables.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS Table generated successfully.
|
||||||
|
@retval EFI_INVALID_PARAMETER A parameter is invalid.
|
||||||
|
@retval EFI_NOT_FOUND The required object information is not found.
|
||||||
|
@retval EFI_BAD_BUFFER_SIZE The size returned by the Configuration
|
||||||
|
Manager is less than the Object size for the
|
||||||
|
requested object.
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
ArchReserveOffsets (
|
||||||
|
IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol,
|
||||||
|
IN OUT UINT32 *ArchOffset
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
ASSERT (CfgMgrProtocol != NULL);
|
||||||
|
ASSERT (ArchOffset != NULL);
|
||||||
|
|
||||||
|
Status = GetEArmObjGicCInfo (
|
||||||
|
CfgMgrProtocol,
|
||||||
|
CM_NULL_TOKEN,
|
||||||
|
(CM_ARM_GICC_INFO **)&mSratSubTable[EArmGicCSubTableType].CmInfo,
|
||||||
|
&mSratSubTable[EArmGicCSubTableType].Count
|
||||||
|
);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
DEBUG ((
|
||||||
|
DEBUG_ERROR,
|
||||||
|
"ERROR: SRAT: Failed to get GICC Info. Status = %r\n",
|
||||||
|
Status
|
||||||
|
));
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mSratSubTable[EArmGicCSubTableType].Count == 0) {
|
||||||
|
DEBUG ((
|
||||||
|
DEBUG_ERROR,
|
||||||
|
"ERROR: SRAT: GIC CPU Interface information not provided.\n"
|
||||||
|
));
|
||||||
|
ASSERT (0);
|
||||||
|
return EFI_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = GetEArmObjGicItsInfo (
|
||||||
|
CfgMgrProtocol,
|
||||||
|
CM_NULL_TOKEN,
|
||||||
|
(CM_ARM_GIC_ITS_INFO **)&mSratSubTable[EArmGicItsSubTableType].CmInfo,
|
||||||
|
&mSratSubTable[EArmGicItsSubTableType].Count
|
||||||
|
);
|
||||||
|
if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
|
||||||
|
DEBUG ((
|
||||||
|
DEBUG_ERROR,
|
||||||
|
"ERROR: SRAT: Failed to get GIC ITS Info. Status = %r\n",
|
||||||
|
Status
|
||||||
|
));
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
mSratSubTable[EArmGicCSubTableType].Offset = *ArchOffset;
|
||||||
|
*ArchOffset += (sizeof (EFI_ACPI_6_3_GICC_AFFINITY_STRUCTURE) *
|
||||||
|
mSratSubTable[EArmGicCSubTableType].Count);
|
||||||
|
|
||||||
|
if (mSratSubTable[EArmGicItsSubTableType].Count != 0) {
|
||||||
|
mSratSubTable[EArmGicItsSubTableType].Offset = *ArchOffset;
|
||||||
|
*ArchOffset += (sizeof (EFI_ACPI_6_3_GIC_ITS_AFFINITY_STRUCTURE) *
|
||||||
|
mSratSubTable[EArmGicItsSubTableType].Count);
|
||||||
|
}
|
||||||
|
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Add the GICC Affinity Structures in the SRAT Table.
|
||||||
|
|
||||||
|
@param [in] CfgMgrProtocol Pointer to the Configuration Manager
|
||||||
|
Protocol Interface.
|
||||||
|
@param [in] Srat Pointer to the SRAT Table.
|
||||||
|
**/
|
||||||
|
STATIC
|
||||||
|
VOID
|
||||||
|
EFIAPI
|
||||||
|
AddGICCAffinity (
|
||||||
|
IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol,
|
||||||
|
IN EFI_ACPI_6_3_SYSTEM_RESOURCE_AFFINITY_TABLE_HEADER *CONST Srat
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_ACPI_6_3_GICC_AFFINITY_STRUCTURE *GicCAff;
|
||||||
|
CM_ARM_GICC_INFO *GicCInfo;
|
||||||
|
|
||||||
|
GicCInfo = mSratSubTable[EArmGicCSubTableType].CmInfo;
|
||||||
|
GicCAff = (EFI_ACPI_6_3_GICC_AFFINITY_STRUCTURE *)((UINT8 *)Srat +
|
||||||
|
mSratSubTable[EArmGicCSubTableType].Offset);
|
||||||
|
|
||||||
|
while (mSratSubTable[EArmGicCSubTableType].Count-- != 0) {
|
||||||
|
DEBUG ((DEBUG_INFO, "SRAT: GicCAff = 0x%p\n", GicCAff));
|
||||||
|
|
||||||
|
GicCAff->Type = EFI_ACPI_6_3_GICC_AFFINITY;
|
||||||
|
GicCAff->Length = sizeof (EFI_ACPI_6_3_GICC_AFFINITY_STRUCTURE);
|
||||||
|
GicCAff->ProximityDomain = GicCInfo->ProximityDomain;
|
||||||
|
GicCAff->AcpiProcessorUid = GicCInfo->AcpiProcessorUid;
|
||||||
|
GicCAff->Flags = GicCInfo->AffinityFlags;
|
||||||
|
GicCAff->ClockDomain = GicCInfo->ClockDomain;
|
||||||
|
|
||||||
|
// Next
|
||||||
|
GicCAff++;
|
||||||
|
GicCInfo++;
|
||||||
|
}// while
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Add the GIC ITS Affinity Structures in the SRAT Table.
|
||||||
|
|
||||||
|
@param [in] CfgMgrProtocol Pointer to the Configuration Manager
|
||||||
|
Protocol Interface.
|
||||||
|
@param [in] Srat Pointer to the SRAT Table.
|
||||||
|
**/
|
||||||
|
STATIC
|
||||||
|
VOID
|
||||||
|
EFIAPI
|
||||||
|
AddGICItsAffinity (
|
||||||
|
IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol,
|
||||||
|
IN EFI_ACPI_6_3_SYSTEM_RESOURCE_AFFINITY_TABLE_HEADER *CONST Srat
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_ACPI_6_3_GIC_ITS_AFFINITY_STRUCTURE *GicItsAff;
|
||||||
|
CM_ARM_GIC_ITS_INFO *GicItsInfo;
|
||||||
|
|
||||||
|
GicItsInfo = mSratSubTable[EArmGicItsSubTableType].CmInfo;
|
||||||
|
GicItsAff = (EFI_ACPI_6_3_GIC_ITS_AFFINITY_STRUCTURE *)((UINT8 *)Srat +
|
||||||
|
mSratSubTable[EArmGicItsSubTableType].Offset);
|
||||||
|
|
||||||
|
while (mSratSubTable[EArmGicItsSubTableType].Count-- != 0) {
|
||||||
|
DEBUG ((DEBUG_INFO, "SRAT: GicItsAff = 0x%p\n", GicItsAff));
|
||||||
|
|
||||||
|
GicItsAff->Type = EFI_ACPI_6_3_GIC_ITS_AFFINITY;
|
||||||
|
GicItsAff->Length = sizeof (EFI_ACPI_6_3_GIC_ITS_AFFINITY_STRUCTURE);
|
||||||
|
GicItsAff->ProximityDomain = GicItsInfo->ProximityDomain;
|
||||||
|
GicItsAff->Reserved[0] = EFI_ACPI_RESERVED_BYTE;
|
||||||
|
GicItsAff->Reserved[1] = EFI_ACPI_RESERVED_BYTE;
|
||||||
|
GicItsAff->ItsId = GicItsInfo->GicItsId;
|
||||||
|
|
||||||
|
// Next
|
||||||
|
GicItsAff++;
|
||||||
|
GicItsInfo++;
|
||||||
|
}// while
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Add the arch specific sub-tables to the SRAT table.
|
||||||
|
|
||||||
|
These sub-tables are written in the space reserved beforehand.
|
||||||
|
|
||||||
|
@param [in] CfgMgrProtocol Pointer to the Configuration Manager
|
||||||
|
Protocol Interface.
|
||||||
|
@param [in] Srat Pointer to the SRAT Table.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS Table generated successfully.
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
AddArchObjects (
|
||||||
|
IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol,
|
||||||
|
IN EFI_ACPI_6_3_SYSTEM_RESOURCE_AFFINITY_TABLE_HEADER *CONST Srat
|
||||||
|
)
|
||||||
|
{
|
||||||
|
ASSERT (CfgMgrProtocol != NULL);
|
||||||
|
ASSERT (Srat != NULL);
|
||||||
|
|
||||||
|
AddGICCAffinity (CfgMgrProtocol, Srat);
|
||||||
|
|
||||||
|
if (mSratSubTable[EArmGicCSubTableType].Count != 0) {
|
||||||
|
AddGICItsAffinity (CfgMgrProtocol, Srat);
|
||||||
|
}
|
||||||
|
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
@ -25,38 +25,19 @@
|
|||||||
#include <Library/TableHelperLib.h>
|
#include <Library/TableHelperLib.h>
|
||||||
#include <Protocol/ConfigurationManagerProtocol.h>
|
#include <Protocol/ConfigurationManagerProtocol.h>
|
||||||
|
|
||||||
|
#include "SratGenerator.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
ARM standard SRAT Generator
|
Standard SRAT Generator
|
||||||
|
|
||||||
Requirements:
|
Requirements:
|
||||||
The following Configuration Manager Object(s) are used by this Generator:
|
The following Configuration Manager Object(s) are used by this Generator:
|
||||||
- EArmObjGicCInfo (REQUIRED)
|
|
||||||
- EArmObjGicItsInfo (OPTIONAL)
|
|
||||||
- EArchCommonObjMemoryAffinityInfo (OPTIONAL)
|
- EArchCommonObjMemoryAffinityInfo (OPTIONAL)
|
||||||
- EArchCommonObjGenericInitiatorAffinityInfo (OPTIONAL)
|
- EArchCommonObjGenericInitiatorAffinityInfo (OPTIONAL)
|
||||||
- EArchCommonObjDeviceHandleAcpi (OPTIONAL)
|
- EArchCommonObjDeviceHandleAcpi (OPTIONAL)
|
||||||
- EArchCommonObjDeviceHandlePci (OPTIONAL)
|
- EArchCommonObjDeviceHandlePci (OPTIONAL)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** This macro expands to a function that retrieves the GIC
|
|
||||||
CPU interface Information from the Configuration Manager.
|
|
||||||
*/
|
|
||||||
GET_OBJECT_LIST (
|
|
||||||
EObjNameSpaceArm,
|
|
||||||
EArmObjGicCInfo,
|
|
||||||
CM_ARM_GICC_INFO
|
|
||||||
);
|
|
||||||
|
|
||||||
/** This macro expands to a function that retrieves the GIC
|
|
||||||
Interrupt Translation Service Information from the
|
|
||||||
Configuration Manager.
|
|
||||||
*/
|
|
||||||
GET_OBJECT_LIST (
|
|
||||||
EObjNameSpaceArm,
|
|
||||||
EArmObjGicItsInfo,
|
|
||||||
CM_ARM_GIC_ITS_INFO
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This macro expands to a function that retrieves the Memory Affinity
|
This macro expands to a function that retrieves the Memory Affinity
|
||||||
information from the Configuration Manager.
|
information from the Configuration Manager.
|
||||||
@ -121,102 +102,6 @@ GetBdf (
|
|||||||
return Bdf;
|
return Bdf;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Add the GICC Affinity Structures in the SRAT Table.
|
|
||||||
|
|
||||||
@param [in] CfgMgrProtocol Pointer to the Configuration Manager
|
|
||||||
Protocol Interface.
|
|
||||||
@param [in] Srat Pointer to the SRAT Table.
|
|
||||||
@param [in] GicCAffOffset Offset of the GICC Affinity
|
|
||||||
information in the SRAT Table.
|
|
||||||
@param [in] GicCInfo Pointer to the GIC CPU Information list.
|
|
||||||
@param [in] GicCCount Count of GIC CPU Interfaces.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS Table generated successfully.
|
|
||||||
**/
|
|
||||||
STATIC
|
|
||||||
EFI_STATUS
|
|
||||||
AddGICCAffinity (
|
|
||||||
IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol,
|
|
||||||
IN EFI_ACPI_6_3_SYSTEM_RESOURCE_AFFINITY_TABLE_HEADER *CONST Srat,
|
|
||||||
IN CONST UINT32 GicCAffOffset,
|
|
||||||
IN CONST CM_ARM_GICC_INFO *GicCInfo,
|
|
||||||
IN UINT32 GicCCount
|
|
||||||
)
|
|
||||||
{
|
|
||||||
EFI_ACPI_6_3_GICC_AFFINITY_STRUCTURE *GicCAff;
|
|
||||||
|
|
||||||
ASSERT (Srat != NULL);
|
|
||||||
ASSERT (GicCInfo != NULL);
|
|
||||||
|
|
||||||
GicCAff = (EFI_ACPI_6_3_GICC_AFFINITY_STRUCTURE *)((UINT8 *)Srat +
|
|
||||||
GicCAffOffset);
|
|
||||||
|
|
||||||
while (GicCCount-- != 0) {
|
|
||||||
DEBUG ((DEBUG_INFO, "SRAT: GicCAff = 0x%p\n", GicCAff));
|
|
||||||
|
|
||||||
GicCAff->Type = EFI_ACPI_6_3_GICC_AFFINITY;
|
|
||||||
GicCAff->Length = sizeof (EFI_ACPI_6_3_GICC_AFFINITY_STRUCTURE);
|
|
||||||
GicCAff->ProximityDomain = GicCInfo->ProximityDomain;
|
|
||||||
GicCAff->AcpiProcessorUid = GicCInfo->AcpiProcessorUid;
|
|
||||||
GicCAff->Flags = GicCInfo->AffinityFlags;
|
|
||||||
GicCAff->ClockDomain = GicCInfo->ClockDomain;
|
|
||||||
|
|
||||||
// Next
|
|
||||||
GicCAff++;
|
|
||||||
GicCInfo++;
|
|
||||||
}// while
|
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Add the GIC ITS Affinity Structures in the SRAT Table.
|
|
||||||
|
|
||||||
@param [in] CfgMgrProtocol Pointer to the Configuration Manager
|
|
||||||
Protocol Interface.
|
|
||||||
@param [in] Srat Pointer to the SRAT Table.
|
|
||||||
@param [in] GicItsAffOffset Offset of the GIC ITS Affinity
|
|
||||||
information in the SRAT Table.
|
|
||||||
@param [in] GicItsInfo Pointer to the GIC ITS Information list.
|
|
||||||
@param [in] GicItsCount Count of GIC ITS.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS Table generated successfully.
|
|
||||||
**/
|
|
||||||
STATIC
|
|
||||||
EFI_STATUS
|
|
||||||
AddGICItsAffinity (
|
|
||||||
IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol,
|
|
||||||
IN EFI_ACPI_6_3_SYSTEM_RESOURCE_AFFINITY_TABLE_HEADER *CONST Srat,
|
|
||||||
IN CONST UINT32 GicItsAffOffset,
|
|
||||||
IN CONST CM_ARM_GIC_ITS_INFO *GicItsInfo,
|
|
||||||
IN UINT32 GicItsCount
|
|
||||||
)
|
|
||||||
{
|
|
||||||
EFI_ACPI_6_3_GIC_ITS_AFFINITY_STRUCTURE *GicItsAff;
|
|
||||||
|
|
||||||
ASSERT (Srat != NULL);
|
|
||||||
ASSERT (GicItsInfo != NULL);
|
|
||||||
|
|
||||||
GicItsAff = (EFI_ACPI_6_3_GIC_ITS_AFFINITY_STRUCTURE *)((UINT8 *)Srat +
|
|
||||||
GicItsAffOffset);
|
|
||||||
|
|
||||||
while (GicItsCount-- != 0) {
|
|
||||||
DEBUG ((DEBUG_INFO, "SRAT: GicItsAff = 0x%p\n", GicItsAff));
|
|
||||||
|
|
||||||
GicItsAff->Type = EFI_ACPI_6_3_GIC_ITS_AFFINITY;
|
|
||||||
GicItsAff->Length = sizeof (EFI_ACPI_6_3_GIC_ITS_AFFINITY_STRUCTURE);
|
|
||||||
GicItsAff->ProximityDomain = GicItsInfo->ProximityDomain;
|
|
||||||
GicItsAff->Reserved[0] = EFI_ACPI_RESERVED_BYTE;
|
|
||||||
GicItsAff->Reserved[1] = EFI_ACPI_RESERVED_BYTE;
|
|
||||||
GicItsAff->ItsId = GicItsInfo->GicItsId;
|
|
||||||
|
|
||||||
// Next
|
|
||||||
GicItsAff++;
|
|
||||||
GicItsInfo++;
|
|
||||||
}// while
|
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Add the Memory Affinity Structures in the SRAT Table.
|
/** Add the Memory Affinity Structures in the SRAT Table.
|
||||||
|
|
||||||
@param [in] CfgMgrProtocol Pointer to the Configuration Manager
|
@param [in] CfgMgrProtocol Pointer to the Configuration Manager
|
||||||
@ -455,18 +340,12 @@ BuildSratTable (
|
|||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
UINT32 TableSize;
|
UINT32 TableSize;
|
||||||
UINT32 GicCCount;
|
|
||||||
UINT32 GicItsCount;
|
|
||||||
UINT32 MemAffCount;
|
UINT32 MemAffCount;
|
||||||
UINT32 GenInitiatorAffCount;
|
UINT32 GenInitiatorAffCount;
|
||||||
|
|
||||||
UINT32 GicCAffOffset;
|
|
||||||
UINT32 GicItsAffOffset;
|
|
||||||
UINT32 MemAffOffset;
|
UINT32 MemAffOffset;
|
||||||
UINT32 GenInitiatorAffOffset;
|
UINT32 GenInitiatorAffOffset;
|
||||||
|
|
||||||
CM_ARM_GICC_INFO *GicCInfo;
|
|
||||||
CM_ARM_GIC_ITS_INFO *GicItsInfo;
|
|
||||||
CM_ARCH_COMMON_MEMORY_AFFINITY_INFO *MemAffInfo;
|
CM_ARCH_COMMON_MEMORY_AFFINITY_INFO *MemAffInfo;
|
||||||
CM_ARCH_COMMON_GENERIC_INITIATOR_AFFINITY_INFO *GenInitiatorAffInfo;
|
CM_ARCH_COMMON_GENERIC_INITIATOR_AFFINITY_INFO *GenInitiatorAffInfo;
|
||||||
|
|
||||||
@ -497,46 +376,6 @@ BuildSratTable (
|
|||||||
|
|
||||||
*Table = NULL;
|
*Table = NULL;
|
||||||
|
|
||||||
Status = GetEArmObjGicCInfo (
|
|
||||||
CfgMgrProtocol,
|
|
||||||
CM_NULL_TOKEN,
|
|
||||||
&GicCInfo,
|
|
||||||
&GicCCount
|
|
||||||
);
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
DEBUG ((
|
|
||||||
DEBUG_ERROR,
|
|
||||||
"ERROR: SRAT: Failed to get GICC Info. Status = %r\n",
|
|
||||||
Status
|
|
||||||
));
|
|
||||||
goto error_handler;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GicCCount == 0) {
|
|
||||||
DEBUG ((
|
|
||||||
DEBUG_ERROR,
|
|
||||||
"ERROR: SRAT: GIC CPU Interface information not provided.\n"
|
|
||||||
));
|
|
||||||
ASSERT (0);
|
|
||||||
Status = EFI_INVALID_PARAMETER;
|
|
||||||
goto error_handler;
|
|
||||||
}
|
|
||||||
|
|
||||||
Status = GetEArmObjGicItsInfo (
|
|
||||||
CfgMgrProtocol,
|
|
||||||
CM_NULL_TOKEN,
|
|
||||||
&GicItsInfo,
|
|
||||||
&GicItsCount
|
|
||||||
);
|
|
||||||
if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
|
|
||||||
DEBUG ((
|
|
||||||
DEBUG_ERROR,
|
|
||||||
"ERROR: SRAT: Failed to get GIC ITS Info. Status = %r\n",
|
|
||||||
Status
|
|
||||||
));
|
|
||||||
goto error_handler;
|
|
||||||
}
|
|
||||||
|
|
||||||
Status = GetEArchCommonObjMemoryAffinityInfo (
|
Status = GetEArchCommonObjMemoryAffinityInfo (
|
||||||
CfgMgrProtocol,
|
CfgMgrProtocol,
|
||||||
CM_NULL_TOKEN,
|
CM_NULL_TOKEN,
|
||||||
@ -571,13 +410,18 @@ BuildSratTable (
|
|||||||
// Calculate the size of the SRAT table
|
// Calculate the size of the SRAT table
|
||||||
TableSize = sizeof (EFI_ACPI_6_3_SYSTEM_RESOURCE_AFFINITY_TABLE_HEADER);
|
TableSize = sizeof (EFI_ACPI_6_3_SYSTEM_RESOURCE_AFFINITY_TABLE_HEADER);
|
||||||
|
|
||||||
GicCAffOffset = TableSize;
|
// Place the Arch specific subtables/structures first and
|
||||||
TableSize += (sizeof (EFI_ACPI_6_3_GICC_AFFINITY_STRUCTURE) * GicCCount);
|
// reserve the offsets. The common subtables/structures
|
||||||
|
// are placed next.
|
||||||
if (GicItsCount != 0) {
|
Status = ArchReserveOffsets (CfgMgrProtocol, &TableSize);
|
||||||
GicItsAffOffset = TableSize;
|
if (EFI_ERROR (Status)) {
|
||||||
TableSize += (sizeof (EFI_ACPI_6_3_GIC_ITS_AFFINITY_STRUCTURE) *
|
DEBUG ((
|
||||||
GicItsCount);
|
DEBUG_ERROR,
|
||||||
|
"ERROR: SRAT: Failed to reserve arch offsets."
|
||||||
|
" Status = %r\n",
|
||||||
|
Status
|
||||||
|
));
|
||||||
|
goto error_handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MemAffCount != 0) {
|
if (MemAffCount != 0) {
|
||||||
@ -636,40 +480,16 @@ BuildSratTable (
|
|||||||
Srat->Reserved1 = 1;
|
Srat->Reserved1 = 1;
|
||||||
Srat->Reserved2 = EFI_ACPI_RESERVED_QWORD;
|
Srat->Reserved2 = EFI_ACPI_RESERVED_QWORD;
|
||||||
|
|
||||||
Status = AddGICCAffinity (
|
Status = AddArchObjects (CfgMgrProtocol, Srat);
|
||||||
CfgMgrProtocol,
|
|
||||||
Srat,
|
|
||||||
GicCAffOffset,
|
|
||||||
GicCInfo,
|
|
||||||
GicCCount
|
|
||||||
);
|
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((
|
DEBUG ((
|
||||||
DEBUG_ERROR,
|
DEBUG_ERROR,
|
||||||
"ERROR: SRAT: Failed to add GICC Affinity structures. Status = %r\n",
|
"ERROR: SRAT: Failed to add arch objects header. Status = %r\n",
|
||||||
Status
|
Status
|
||||||
));
|
));
|
||||||
goto error_handler;
|
goto error_handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GicItsCount != 0) {
|
|
||||||
Status = AddGICItsAffinity (
|
|
||||||
CfgMgrProtocol,
|
|
||||||
Srat,
|
|
||||||
GicItsAffOffset,
|
|
||||||
GicItsInfo,
|
|
||||||
GicItsCount
|
|
||||||
);
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
DEBUG ((
|
|
||||||
DEBUG_ERROR,
|
|
||||||
"ERROR: SRAT: Failed to add GIC ITS Affinity structures. Status = %r\n",
|
|
||||||
Status
|
|
||||||
));
|
|
||||||
goto error_handler;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (MemAffCount != 0) {
|
if (MemAffCount != 0) {
|
||||||
Status = AddMemoryAffinity (
|
Status = AddMemoryAffinity (
|
||||||
CfgMgrProtocol,
|
CfgMgrProtocol,
|
||||||
|
@ -0,0 +1,59 @@
|
|||||||
|
/** @file
|
||||||
|
SRAT Table Generator
|
||||||
|
|
||||||
|
Copyright (c) 2019 - 2020, Arm Limited. All rights reserved.
|
||||||
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
|
||||||
|
@par Reference(s):
|
||||||
|
- ACPI 6.3 Specification, January 2019
|
||||||
|
|
||||||
|
@par Glossary:
|
||||||
|
- Cm or CM - Configuration Manager
|
||||||
|
- Obj or OBJ - Object
|
||||||
|
**/
|
||||||
|
|
||||||
|
#ifndef SRAT_GENERATOR_H_
|
||||||
|
#define SRAT_GENERATOR_H_
|
||||||
|
|
||||||
|
/** Reserve arch sub-tables space.
|
||||||
|
|
||||||
|
@param [in] CfgMgrProtocol Pointer to the Configuration Manager
|
||||||
|
@param [in, out] ArchOffset On input, contains the offset where arch specific
|
||||||
|
sub-tables can be written. It is expected that
|
||||||
|
there enough space to write all the arch specific
|
||||||
|
sub-tables from this offset onward.
|
||||||
|
On ouput, contains the ending offset of the arch
|
||||||
|
specific sub-tables.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS Table generated successfully.
|
||||||
|
@retval EFI_INVALID_PARAMETER A parameter is invalid.
|
||||||
|
@retval EFI_NOT_FOUND The required object information is not found.
|
||||||
|
@retval EFI_BAD_BUFFER_SIZE The size returned by the Configuration
|
||||||
|
Manager is less than the Object size for the
|
||||||
|
requested object.
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
ArchReserveOffsets (
|
||||||
|
IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol,
|
||||||
|
IN OUT UINT32 *ArchOffset
|
||||||
|
);
|
||||||
|
|
||||||
|
/** Add the arch specific sub-tables to the SRAT table.
|
||||||
|
|
||||||
|
These sub-tables are written in the space reserved beforehand.
|
||||||
|
|
||||||
|
@param [in] CfgMgrProtocol Pointer to the Configuration Manager
|
||||||
|
Protocol Interface.
|
||||||
|
@param [in] Srat Pointer to the SRAT Table.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS Table generated successfully.
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
AddArchObjects (
|
||||||
|
IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol,
|
||||||
|
IN EFI_ACPI_6_3_SYSTEM_RESOURCE_AFFINITY_TABLE_HEADER *CONST Srat
|
||||||
|
);
|
||||||
|
|
||||||
|
#endif // SRAT_GENERATOR_H_
|
@ -0,0 +1,79 @@
|
|||||||
|
/** @file
|
||||||
|
Common SRAT Table Generator
|
||||||
|
|
||||||
|
Copyright (c) 2019 - 2020, Arm Limited. All rights reserved.
|
||||||
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
|
||||||
|
@par Reference(s):
|
||||||
|
- ACPI 6.3 Specification, January 2019
|
||||||
|
|
||||||
|
@par Glossary:
|
||||||
|
- Cm or CM - Configuration Manager
|
||||||
|
- Obj or OBJ - Object
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include <Library/AcpiLib.h>
|
||||||
|
#include <Library/BaseLib.h>
|
||||||
|
#include <Library/DebugLib.h>
|
||||||
|
#include <Library/MemoryAllocationLib.h>
|
||||||
|
#include <Protocol/AcpiTable.h>
|
||||||
|
|
||||||
|
// Module specific include files.
|
||||||
|
#include <AcpiTableGenerator.h>
|
||||||
|
#include <ConfigurationManagerObject.h>
|
||||||
|
#include <ConfigurationManagerHelper.h>
|
||||||
|
#include <Library/TableHelperLib.h>
|
||||||
|
#include <Protocol/ConfigurationManagerProtocol.h>
|
||||||
|
|
||||||
|
#include "SratGenerator.h"
|
||||||
|
|
||||||
|
/** Reserve arch sub-tables space.
|
||||||
|
|
||||||
|
@param [in] CfgMgrProtocol Pointer to the Configuration Manager
|
||||||
|
@param [in, out] ArchOffset On input, contains the offset where arch specific
|
||||||
|
sub-tables can be written. It is expected that
|
||||||
|
there enough space to write all the arch specific
|
||||||
|
sub-tables from this offset onward.
|
||||||
|
On ouput, contains the ending offset of the arch
|
||||||
|
specific sub-tables.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS Table generated successfully.
|
||||||
|
@retval EFI_UNSUPPORTED Not supported.
|
||||||
|
@retval EFI_INVALID_PARAMETER A parameter is invalid.
|
||||||
|
@retval EFI_NOT_FOUND The required object information is not found.
|
||||||
|
@retval EFI_BAD_BUFFER_SIZE The size returned by the Configuration
|
||||||
|
Manager is less than the Object size for the
|
||||||
|
requested object.
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
ArchReserveOffsets (
|
||||||
|
IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol,
|
||||||
|
IN OUT UINT32 *ArchOffset
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// Not implemented.
|
||||||
|
return EFI_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Add the arch specific sub-tables to the SRAT table.
|
||||||
|
|
||||||
|
These sub-tables are written in the space reserved beforehand.
|
||||||
|
|
||||||
|
@param [in] CfgMgrProtocol Pointer to the Configuration Manager
|
||||||
|
Protocol Interface.
|
||||||
|
@param [in] Srat Pointer to the SRAT Table.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS Table generated successfully.
|
||||||
|
@retval EFI_UNSUPPORTED Not supported.
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
AddArchObjects (
|
||||||
|
IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol,
|
||||||
|
IN EFI_ACPI_6_3_SYSTEM_RESOURCE_AFFINITY_TABLE_HEADER *CONST Srat
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// Not implemented.
|
||||||
|
return EFI_UNSUPPORTED;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user