[PATCH 8/8] DynamicTablesPkg: Remove GET_OBJECT_LIST


Tomas Pilar (tpilar)
 

Replace macro-generated accessor functions in DynamicTables
generators with TableHelperLib helpers that are compatible
with v1.1 revision of Configuration Manager Protocol.

Cc: Sami Mujawar <Sami.Mujawar@...>
Cc: Alexei Fedorov <Alexei.Fedorov@...>
Signed-off-by: Tomas Pilar <tomas@...>
---
.../DynamicTableFactoryDxe.c | 1 -
.../DynamicTableManagerDxe.c | 34 +-
.../Include/ConfigurationManagerHelper.h | 126 --
.../Acpi/Arm/AcpiDbg2LibArm/Dbg2Generator.c | 34 +-
.../Acpi/Arm/AcpiFadtLibArm/FadtGenerator.c | 199 +---
.../Acpi/Arm/AcpiGtdtLibArm/GtdtGenerator.c | 234 ++--
.../Acpi/Arm/AcpiIortLibArm/IortGenerator.c | 1058 +++++------------
.../Acpi/Arm/AcpiMadtLibArm/MadtGenerator.c | 304 ++---
.../Acpi/Arm/AcpiMcfgLibArm/McfgGenerator.c | 100 +-
.../Acpi/Arm/AcpiPpttLibArm/PpttGenerator.c | 287 ++---
.../Acpi/Arm/AcpiRawLibArm/RawGenerator.c | 1 -
.../Acpi/Arm/AcpiSpcrLibArm/SpcrGenerator.c | 35 +-
.../Acpi/Arm/AcpiSratLibArm/SratGenerator.c | 437 +++----
13 files changed, 785 insertions(+), 2065 deletions(-)
delete mode 100644 DynamicTablesPkg/Include/ConfigurationManagerHelper.h

diff --git a/DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactoryDxe.c b/DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactoryDxe.c
index d1432348f0..b8f3e1c877 100644
--- a/DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactoryDxe.c
+++ b/DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactoryDxe.c
@@ -15,7 +15,6 @@
// Module specific include files.
#include <AcpiTableGenerator.h>
#include <ConfigurationManagerObject.h>
-#include <ConfigurationManagerHelper.h>
#include <DeviceTreeTableGenerator.h>
#include <Library/TableHelperLib.h>
#include <Protocol/ConfigurationManagerProtocol.h>
diff --git a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.c b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.c
index b194a38659..ae827fdf2c 100644
--- a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.c
+++ b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.c
@@ -8,6 +8,7 @@
**/

#include <Library/DebugLib.h>
+#include <Library/MemoryAllocationLib.h>
#include <Library/PcdLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Protocol/AcpiTable.h>
@@ -15,22 +16,12 @@
// Module specific include files.
#include <AcpiTableGenerator.h>
#include <ConfigurationManagerObject.h>
-#include <ConfigurationManagerHelper.h>
#include <DeviceTreeTableGenerator.h>
#include <Library/TableHelperLib.h>
#include <Protocol/ConfigurationManagerProtocol.h>
#include <Protocol/DynamicTableFactoryProtocol.h>
#include <SmbiosTableGenerator.h>

-/** This macro expands to a function that retrieves the ACPI Table
- List from the Configuration Manager.
-*/
-GET_OBJECT_LIST (
- EObjNameSpaceStandard,
- EStdObjAcpiTableList,
- CM_STD_OBJ_ACPI_TABLE_INFO
- )
-
/** A helper function to build and install a single ACPI table.

This is a helper function that invokes the Table generator interface
@@ -516,12 +507,7 @@ ProcessAcpiTables (
return Status;
}

- Status = GetEStdObjAcpiTableList (
- CfgMgrProtocol,
- CM_NULL_TOKEN,
- &AcpiTableInfo,
- &AcpiTableCount
- );
+ Status = CfgMgrCountObjects (EStdObjAcpiTableList, &AcpiTableCount);
if (EFI_ERROR (Status)) {
DEBUG ((
DEBUG_ERROR,
@@ -546,6 +532,9 @@ ProcessAcpiTables (
AcpiTableCount
));

+ CfgMgrGetObjects (
+ EStdObjAcpiTableList, CM_NULL_TOKEN, (VOID**)&AcpiTableInfo, &AcpiTableCount);
+
// Check if mandatory ACPI tables are present.
Status = VerifyMandatoryTablesArePresent (
AcpiTableInfo,
@@ -558,7 +547,7 @@ ProcessAcpiTables (
" Status = %r\n",
Status
));
- return Status;
+ goto EXIT;
}

// Add the FADT Table first.
@@ -578,7 +567,7 @@ ProcessAcpiTables (
" Status = %r\n",
Status
));
- return Status;
+ goto EXIT;
}
break;
}
@@ -626,10 +615,12 @@ ProcessAcpiTables (
" Status = %r\n",
Status
));
- return Status;
+ goto EXIT;
}
} // for

+EXIT:
+ FreePool(AcpiTableInfo);
return Status;
}

@@ -697,11 +688,6 @@ DynamicTableManagerDxeInitialize (

Status = CfgMgrGetInfo (&CfgMgrInfo);
if (EFI_ERROR (Status)) {
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: Failed to get Configuration Manager info. Status = %r\n",
- Status
- ));
return Status;
}

diff --git a/DynamicTablesPkg/Include/ConfigurationManagerHelper.h b/DynamicTablesPkg/Include/ConfigurationManagerHelper.h
deleted file mode 100644
index 29f34a0434..0000000000
--- a/DynamicTablesPkg/Include/ConfigurationManagerHelper.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/** @file
-
- Copyright (c) 2017 - 2019, ARM Limited. All rights reserved.
-
- SPDX-License-Identifier: BSD-2-Clause-Patent
-
- @par Glossary:
- - Cm or CM - Configuration Manager
- - Obj or OBJ - Object
-**/
-
-#ifndef CONFIGURATION_MANAGER_HELPER_H_
-#define CONFIGURATION_MANAGER_HELPER_H_
-
-/** The GET_OBJECT_LIST macro expands to a function that is used to retrieve
- an object or an object list from the Configuration Manager using the
- Configuration Manager Protocol interface.
-
- The macro expands to a function which has the following prototype:
-
- STATIC
- EFI_STATUS
- EFIAPI
- Get<CmObjectId> (
- IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol,
- IN CONST CM_OBJECT_TOKEN Token OPTIONAL,
- OUT Type ** List,
- OUT UINT32 * Count OPTIONAL
- );
-
- Generated function parameters:
- @param [in] CfgMgrProtocol Pointer to the Configuration Manager protocol
- interface.
- @param [in] Token Reference token for the Object.
- @param [out] List Pointer to the Object list.
- @param [out] Count Count of the objects returned in the list.
-
- Macro Parameters:
- @param [in] CmObjectNameSpace The Object Namespace
- @param [in] CmObjectId Object Id.
- @param [in] Type Structure used to describe the Object.
-
- @retval EFI_SUCCESS Success.
- @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.
-**/
-#define GET_OBJECT_LIST(CmObjectNameSpace, CmObjectId, Type) \
-STATIC \
-EFI_STATUS \
-EFIAPI \
-Get##CmObjectId ( \
- IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol, \
- IN CONST CM_OBJECT_TOKEN Token OPTIONAL, \
- OUT Type ** List, \
- OUT UINT32 * CONST Count OPTIONAL \
- ) \
-{ \
- EFI_STATUS Status; \
- CM_OBJ_DESCRIPTOR CmObjectDesc; \
- UINT32 ObjCount = 0; \
- if (List == NULL) { \
- Status = EFI_INVALID_PARAMETER; \
- DEBUG (( \
- DEBUG_ERROR, \
- "ERROR: Get" #CmObjectId ": Invalid out parameter for" \
- " object list. Status = %r\n", \
- Status \
- )); \
- goto error_handler; \
- } \
- Status = CfgMgrProtocol->GetObject ( \
- CfgMgrProtocol, \
- CREATE_CM_OBJECT_ID ( \
- CmObjectNameSpace, \
- CmObjectId \
- ), \
- Token, \
- &CmObjectDesc \
- ); \
- if (EFI_ERROR (Status)) { \
- DEBUG (( \
- DEBUG_INFO, \
- "INFO: Get" #CmObjectId ": Platform does not implement " \
- #CmObjectId ". Status = %r\n", \
- Status \
- )); \
- *List = NULL; \
- goto error_handler; \
- } \
- if (CmObjectDesc.ObjectId != \
- CREATE_CM_OBJECT_ID (CmObjectNameSpace, CmObjectId)) { \
- DEBUG (( \
- DEBUG_ERROR, \
- "ERROR: Get" #CmObjectId ": " #CmObjectId \
- ": Invalid ObjectId = 0x%x\n, expected Id = 0x%x\n", \
- CmObjectDesc.ObjectId, \
- CREATE_CM_OBJECT_ID (CmObjectNameSpace, CmObjectId) \
- )); \
- ASSERT (FALSE); \
- Status = EFI_INVALID_PARAMETER; \
- goto error_handler; \
- } \
- if (CmObjectDesc.Size < (sizeof (Type) * CmObjectDesc.Count)) { \
- DEBUG (( \
- DEBUG_ERROR, \
- "ERROR: Get" #CmObjectId ": " #CmObjectId \
- ": Buffer too small, size = 0x%x\n", \
- CmObjectDesc.Size \
- )); \
- ASSERT (FALSE); \
- Status = EFI_BAD_BUFFER_SIZE; \
- goto error_handler; \
- } \
- ObjCount = CmObjectDesc.Count; \
- *List = (Type*)CmObjectDesc.Data; \
-error_handler: \
- if (Count != NULL) { \
- *Count = ObjCount; \
- } \
- return Status; \
-}
-
-#endif // CONFIGURATION_MANAGER_HELPER_H_
diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiDbg2LibArm/Dbg2Generator.c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiDbg2LibArm/Dbg2Generator.c
index 21a7f9bf64..b6a1dc0ddf 100644
--- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiDbg2LibArm/Dbg2Generator.c
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiDbg2LibArm/Dbg2Generator.c
@@ -12,6 +12,7 @@
#include <IndustryStandard/DebugPort2Table.h>
#include <Library/AcpiLib.h>
#include <Library/DebugLib.h>
+#include <Library/MemoryAllocationLib.h>
#include <Library/PL011UartLib.h>
#include <Protocol/AcpiTable.h>
#include <Protocol/SerialIo.h>
@@ -19,7 +20,6 @@
// Module specific include files.
#include <AcpiTableGenerator.h>
#include <ConfigurationManagerObject.h>
-#include <ConfigurationManagerHelper.h>
#include <Library/TableHelperLib.h>
#include <Protocol/ConfigurationManagerProtocol.h>

@@ -166,15 +166,6 @@ DBG2_TABLE AcpiDbg2 = {

#pragma pack()

-/** This macro expands to a function that retrieves the Serial
- debug port information from the Configuration Manager
-*/
-GET_OBJECT_LIST (
- EObjNameSpaceArm,
- EArmObjSerialDebugPortInfo,
- CM_ARM_SERIAL_PORT_INFO
- );
-
/** Initialize the PL011/SBSA UART with the parameters obtained from
the Configuration Manager.

@@ -285,21 +276,14 @@ BuildDbg2Table (
return EFI_INVALID_PARAMETER;
}

+ // Pointers to allocated memory
*Table = NULL;

- Status = GetEArmObjSerialDebugPortInfo (
- CfgMgrProtocol,
- CM_NULL_TOKEN,
- &SerialPortInfo,
- NULL
- );
+ Status = CfgMgrGetSimpleObject (
+ EArmObjSerialDebugPortInfo, (VOID **)&SerialPortInfo);
+
if (EFI_ERROR (Status)) {
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: DBG2: Failed to get serial port information. Status = %r\n",
- Status
- ));
- goto error_handler;
+ return Status;
}

if (SerialPortInfo->BaseAddress == 0) {
@@ -335,11 +319,6 @@ BuildDbg2Table (
AcpiTableInfo,
sizeof (DBG2_TABLE));
if (EFI_ERROR (Status)) {
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: DBG2: Failed to add ACPI header. Status = %r\n",
- Status
- ));
goto error_handler;
}

@@ -372,6 +351,7 @@ BuildDbg2Table (
*Table = (EFI_ACPI_DESCRIPTION_HEADER*)&AcpiDbg2;

error_handler:
+ FreePool(SerialPortInfo);
return Status;
}

diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiFadtLibArm/FadtGenerator.c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiFadtLibArm/FadtGenerator.c
index febaca3dae..8b523b0e3d 100644
--- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiFadtLibArm/FadtGenerator.c
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiFadtLibArm/FadtGenerator.c
@@ -11,12 +11,12 @@

#include <Library/AcpiLib.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>

@@ -198,47 +198,8 @@ EFI_ACPI_6_3_FIXED_ACPI_DESCRIPTION_TABLE AcpiFadt = {

#pragma pack()

-/** This macro expands to a function that retrieves the Power
- Management Profile Information from the Configuration Manager.
-*/
-GET_OBJECT_LIST (
- EObjNameSpaceArm,
- EArmObjPowerManagementProfileInfo,
- CM_ARM_POWER_MANAGEMENT_PROFILE_INFO
- );
-
-/** This macro expands to a function that retrieves the Boot
- Architecture Information from the Configuration Manager.
-*/
-GET_OBJECT_LIST (
- EObjNameSpaceArm,
- EArmObjBootArchInfo,
- CM_ARM_BOOT_ARCH_INFO
- );
-
-/** This macro expands to a function that retrieves the Hypervisor
- Vendor ID from the Configuration Manager.
-*/
-GET_OBJECT_LIST (
- EObjNameSpaceArm,
- EArmObjHypervisorVendorIdentity,
- CM_ARM_HYPERVISOR_VENDOR_ID
- );
-
-/** This macro expands to a function that retrieves the Fixed
- feature flags for the platform from the Configuration Manager.
-*/
-GET_OBJECT_LIST (
- EObjNameSpaceArm,
- EArmObjFixedFeatureFlags,
- CM_ARM_FIXED_FEATURE_FLAGS
- );
-
/** Update the Power Management Profile information in the FADT Table.

- @param [in] CfgMgrProtocol Pointer to the Configuration Manager
- Protocol Interface.
-
@retval EFI_SUCCESS Success.
@retval EFI_INVALID_PARAMETER A parameter is invalid.
@retval EFI_NOT_FOUND The required object was not found.
@@ -249,30 +210,16 @@ GET_OBJECT_LIST (
STATIC
EFI_STATUS
EFIAPI
-FadtAddPmProfileInfo (
- IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol
-)
+FadtAddPmProfileInfo (VOID)
{
EFI_STATUS Status;
CM_ARM_POWER_MANAGEMENT_PROFILE_INFO * PmProfile;

- ASSERT (CfgMgrProtocol != NULL);
-
// Get the Power Management Profile from the Platform Configuration Manager
- Status = GetEArmObjPowerManagementProfileInfo (
- CfgMgrProtocol,
- CM_NULL_TOKEN,
- &PmProfile,
- NULL
- );
+ Status = CfgMgrGetSimpleObject (
+ EArmObjPowerManagementProfileInfo, (VOID **)&PmProfile);
if (EFI_ERROR (Status)) {
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: FADT: Failed to get Power Management Profile information." \
- " Status = %r\n",
- Status
- ));
- goto error_handler;
+ return Status;
}

DEBUG ((
@@ -283,15 +230,13 @@ FadtAddPmProfileInfo (

AcpiFadt.PreferredPmProfile = PmProfile->PowerManagementProfile;

-error_handler:
- return Status;
+ FreePool(PmProfile);
+
+ return EFI_SUCCESS;
}

/** Updates the Boot Architecture information in the FADT Table.

- @param [in] CfgMgrProtocol Pointer to the Configuration Manager
- Protocol Interface.
-
@retval EFI_SUCCESS Success.
@retval EFI_INVALID_PARAMETER A parameter is invalid.
@retval EFI_NOT_FOUND The required object was not found.
@@ -302,29 +247,15 @@ error_handler:
STATIC
EFI_STATUS
EFIAPI
-FadtAddBootArchInfo (
- IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol
-)
+FadtAddBootArchInfo (VOID)
{
EFI_STATUS Status;
CM_ARM_BOOT_ARCH_INFO * BootArchInfo;

- ASSERT (CfgMgrProtocol != NULL);
-
// Get the Boot Architecture flags from the Platform Configuration Manager
- Status = GetEArmObjBootArchInfo (
- CfgMgrProtocol,
- CM_NULL_TOKEN,
- &BootArchInfo,
- NULL
- );
+ Status = CfgMgrGetSimpleObject (EArmObjBootArchInfo, (VOID **)&BootArchInfo);
if (EFI_ERROR (Status)) {
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: FADT: Failed to get Boot Architecture flags. Status = %r\n",
- Status
- ));
- goto error_handler;
+ return Status;
}

DEBUG ((
@@ -335,15 +266,13 @@ FadtAddBootArchInfo (

AcpiFadt.ArmBootArch = BootArchInfo->BootArchFlags;

-error_handler:
- return Status;
+ FreePool(BootArchInfo);
+
+ return EFI_SUCCESS;
}

/** Update the Hypervisor Vendor ID in the FADT Table.

- @param [in] CfgMgrProtocol Pointer to the Configuration Manager
- Protocol Interface.
-
@retval EFI_SUCCESS Success.
@retval EFI_INVALID_PARAMETER A parameter is invalid.
@retval EFI_NOT_FOUND The required object was not found.
@@ -354,38 +283,16 @@ error_handler:
STATIC
EFI_STATUS
EFIAPI
-FadtAddHypervisorVendorId (
- IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol
-)
+FadtAddHypervisorVendorId (VOID)
{
EFI_STATUS Status;
CM_ARM_HYPERVISOR_VENDOR_ID * HypervisorVendorInfo;

- ASSERT (CfgMgrProtocol != NULL);
-
// Get the Hypervisor Vendor ID from the Platform Configuration Manager
- Status = GetEArmObjHypervisorVendorIdentity (
- CfgMgrProtocol,
- CM_NULL_TOKEN,
- &HypervisorVendorInfo,
- NULL
- );
+ Status = CfgMgrGetSimpleObject (
+ EArmObjHypervisorVendorIdentity, (VOID **) &HypervisorVendorInfo);
if (EFI_ERROR (Status)) {
- if (Status == EFI_NOT_FOUND) {
- DEBUG ((
- DEBUG_INFO,
- "INFO: FADT: Platform does not have a Hypervisor Vendor ID."
- "Status = %r\n",
- Status
- ));
- } else {
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: FADT: Failed to get Hypervisor Vendor ID. Status = %r\n",
- Status
- ));
- }
- goto error_handler;
+ return Status;
}

DEBUG ((
@@ -396,8 +303,9 @@ FadtAddHypervisorVendorId (

AcpiFadt.HypervisorVendorIdentity = HypervisorVendorInfo->HypervisorVendorId;

-error_handler:
- return Status;
+ FreePool (HypervisorVendorInfo);
+
+ return EFI_SUCCESS;
}

/** Update the Fixed Feature Flags in the FADT Table.
@@ -415,38 +323,17 @@ error_handler:
STATIC
EFI_STATUS
EFIAPI
-FadtAddFixedFeatureFlags (
- IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol
-)
+FadtAddFixedFeatureFlags (VOID)
{
EFI_STATUS Status;
CM_ARM_FIXED_FEATURE_FLAGS * FixedFeatureFlags;

- ASSERT (CfgMgrProtocol != NULL);
-
// Get the Fixed feature flags from the Platform Configuration Manager
- Status = GetEArmObjFixedFeatureFlags (
- CfgMgrProtocol,
- CM_NULL_TOKEN,
- &FixedFeatureFlags,
- NULL
- );
+
+ Status = CfgMgrGetSimpleObject (
+ EArmObjFixedFeatureFlags, (VOID **)&FixedFeatureFlags);
if (EFI_ERROR (Status)) {
- if (Status == EFI_NOT_FOUND) {
- DEBUG ((
- DEBUG_INFO,
- "INFO: FADT: Platform does not define additional Fixed feature flags."
- "Status = %r\n",
- Status
- ));
- } else {
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: FADT: Failed to get Fixed feature flags. Status = %r\n",
- Status
- ));
- }
- goto error_handler;
+ return Status;
}

DEBUG ((
@@ -467,8 +354,9 @@ FadtAddFixedFeatureFlags (
AcpiFadt.Flags |= (FixedFeatureFlags->Flags &
VALID_HARDWARE_REDUCED_FLAG_MASK);

-error_handler:
- return Status;
+ FreePool (FixedFeatureFlags);
+
+ return EFI_SUCCESS;
}

/** Construct the FADT table.
@@ -507,7 +395,6 @@ BuildFadtTable (

ASSERT (This != NULL);
ASSERT (AcpiTableInfo != NULL);
- ASSERT (CfgMgrProtocol != NULL);
ASSERT (Table != NULL);
ASSERT (AcpiTableInfo->TableGeneratorId == This->GeneratorID);
ASSERT (AcpiTableInfo->AcpiTableSignature == This->AcpiTableSignature);
@@ -533,30 +420,25 @@ BuildFadtTable (
AcpiTableInfo,
sizeof (EFI_ACPI_6_3_FIXED_ACPI_DESCRIPTION_TABLE));
if (EFI_ERROR (Status)) {
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: FADT: Failed to add ACPI header. Status = %r\n",
- Status
- ));
return Status;
}

// Update PmProfile Info
- Status = FadtAddPmProfileInfo (CfgMgrProtocol);
+ Status = FadtAddPmProfileInfo ();
if (EFI_ERROR (Status)) {
- goto error_handler;
+ return Status;
}

// Update BootArch Info
- Status = FadtAddBootArchInfo (CfgMgrProtocol);
+ Status = FadtAddBootArchInfo ();
if (EFI_ERROR (Status)) {
- goto error_handler;
+ return Status;
}

// Add the Hypervisor Vendor Id if present
// Note if no hypervisor is present the zero bytes
// will be placed in this field.
- Status = FadtAddHypervisorVendorId (CfgMgrProtocol);
+ Status = FadtAddHypervisorVendorId ();
if (EFI_ERROR (Status)) {
if (Status == EFI_NOT_FOUND) {
DEBUG ((
@@ -570,11 +452,11 @@ BuildFadtTable (
"ERROR: FADT: Error reading Hypervisor Vendor ID, Status = %r",
Status
));
- goto error_handler;
+ return Status;
}
}

- Status = FadtAddFixedFeatureFlags (CfgMgrProtocol);
+ Status = FadtAddFixedFeatureFlags ();
if (EFI_ERROR (Status)) {
if (Status == EFI_NOT_FOUND) {
DEBUG ((
@@ -582,20 +464,19 @@ BuildFadtTable (
"INFO: FADT: No Fixed feature flags found," \
" assuming no additional flags are defined for the platform.\n"
));
- Status = EFI_SUCCESS;
} else {
DEBUG ((
DEBUG_ERROR,
"ERROR: FADT: Error reading Fixed feature flags, Status = %r",
Status
));
- goto error_handler;
+ return Status;
}
}

- *Table = (EFI_ACPI_DESCRIPTION_HEADER*)&AcpiFadt;
-error_handler:
- return Status;
+ *Table = (EFI_ACPI_DESCRIPTION_HEADER *) &AcpiFadt;
+
+ return EFI_SUCCESS;
}

/** This macro defines the FADT Table Generator revision.
diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/GtdtGenerator.c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/GtdtGenerator.c
index 4af410fb5b..119265187a 100644
--- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/GtdtGenerator.c
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/GtdtGenerator.c
@@ -17,7 +17,6 @@
// Module specific include files.
#include <AcpiTableGenerator.h>
#include <ConfigurationManagerObject.h>
-#include <ConfigurationManagerHelper.h>
#include <Library/TableHelperLib.h>
#include <Protocol/ConfigurationManagerProtocol.h>

@@ -32,49 +31,11 @@ Requirements:
- EArmObjGTBlockTimerFrameInfo (OPTIONAL)
*/

-/** This macro expands to a function that retrieves the Generic
- Timer Information from the Configuration Manager.
-*/
-GET_OBJECT_LIST (
- EObjNameSpaceArm,
- EArmObjGenericTimerInfo,
- CM_ARM_GENERIC_TIMER_INFO
- );
-
-/** This macro expands to a function that retrieves the SBSA Generic
- Watchdog Timer Information from the Configuration Manager.
-*/
-GET_OBJECT_LIST (
- EObjNameSpaceArm,
- EArmObjPlatformGenericWatchdogInfo,
- CM_ARM_GENERIC_WATCHDOG_INFO
- );
-
-/** This macro expands to a function that retrieves the Platform Generic
- Timer Block Information from the Configuration Manager.
-*/
-GET_OBJECT_LIST (
- EObjNameSpaceArm,
- EArmObjPlatformGTBlockInfo,
- CM_ARM_GTBLOCK_INFO
- );
-
-/** This macro expands to a function that retrieves the Generic
- Timer Block Timer Frame Information from the Configuration Manager.
-*/
-GET_OBJECT_LIST (
- EObjNameSpaceArm,
- EArmObjGTBlockTimerFrameInfo,
- CM_ARM_GTBLOCK_TIMER_FRAME_INFO
- );
-
/** Add the Generic Timer Information to the GTDT table.

Also update the Platform Timer offset information if the platform
implements platform timers.

- @param [in] CfgMgrProtocol Pointer to the Configuration Manager
- Protocol Interface.
@param [in] Gtdt Pointer to the GTDT Table.
@param [in] PlatformTimerCount Platform timer count.
@param [in] AcpiTableRevision Acpi Revision targeted by the platform.
@@ -90,7 +51,6 @@ STATIC
EFI_STATUS
EFIAPI
AddGenericTimerInfo (
- IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol,
IN EFI_ACPI_6_3_GENERIC_TIMER_DESCRIPTION_TABLE * CONST Gtdt,
IN CONST UINT32 PlatformTimerCount,
IN CONST UINT32 AcpiTableRevision
@@ -99,24 +59,13 @@ AddGenericTimerInfo (
EFI_STATUS Status;
CM_ARM_GENERIC_TIMER_INFO * GenericTimerInfo;

- ASSERT (CfgMgrProtocol != NULL);
- ASSERT (Gtdt != NULL);
-
- Status = GetEArmObjGenericTimerInfo (
- CfgMgrProtocol,
- CM_NULL_TOKEN,
- &GenericTimerInfo,
- NULL
- );
+ ASSERT (Gtdt != NULL);

- if (EFI_ERROR (Status)) {
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: GTDT: Failed to get GenericTimerInfo. Status = %r\n",
- Status
- ));
- return Status;
- }
+ Status = CfgMgrGetSimpleObject (
+ EArmObjGenericTimerInfo, (VOID **)&GenericTimerInfo);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }

Gtdt->CntControlBasePhysicalAddress =
GenericTimerInfo->CounterControlBaseAddress;
@@ -140,7 +89,9 @@ AddGenericTimerInfo (
Gtdt->VirtualPL2TimerFlags = GenericTimerInfo->VirtualPL2TimerFlags;
}

- return Status;
+ FreePool (GenericTimerInfo);
+
+ return EFI_SUCCESS;
}

/** Add the SBSA Generic Watchdog Timers to the GTDT table.
@@ -148,26 +99,36 @@ AddGenericTimerInfo (
@param [in] Gtdt Pointer to the GTDT Table.
@param [in] WatchdogOffset Offset to the watchdog information in the
GTDT Table.
- @param [in] WatchdogInfoList Pointer to the watchdog information list.
- @param [in] WatchdogCount Platform timer count.
**/
STATIC
VOID
AddGenericWatchdogList (
IN EFI_ACPI_6_3_GENERIC_TIMER_DESCRIPTION_TABLE * CONST Gtdt,
- IN CONST UINT32 WatchdogOffset,
- IN CONST CM_ARM_GENERIC_WATCHDOG_INFO * WatchdogInfoList,
- IN UINT32 WatchdogCount
+ IN CONST UINT32 WatchdogOffset
)
{
EFI_ACPI_6_3_GTDT_SBSA_GENERIC_WATCHDOG_STRUCTURE * Watchdog;
+ UINT32 WatchdogCount;
+ VOID *WatchdogInfoList;
+ CM_ARM_GENERIC_WATCHDOG_INFO *Cursor;
+ EFI_STATUS Status;

ASSERT (Gtdt != NULL);
- ASSERT (WatchdogInfoList != NULL);
+
+ Status = CfgMgrGetObjects (
+ EArmObjPlatformGenericWatchdogInfo,
+ CM_NULL_TOKEN,
+ &WatchdogInfoList,
+ &WatchdogCount);
+
+ if (EFI_ERROR(Status)) {
+ return;
+ }

Watchdog = (EFI_ACPI_6_3_GTDT_SBSA_GENERIC_WATCHDOG_STRUCTURE *)
((UINT8*)Gtdt + WatchdogOffset);

+ Cursor = WatchdogInfoList;
while (WatchdogCount-- != 0) {
// Add watchdog entry
DEBUG ((DEBUG_INFO, "GTDT: Watchdog = 0x%p\n", Watchdog));
@@ -176,14 +137,16 @@ AddGenericWatchdogList (
sizeof (EFI_ACPI_6_3_GTDT_SBSA_GENERIC_WATCHDOG_STRUCTURE);
Watchdog->Reserved = EFI_ACPI_RESERVED_BYTE;
Watchdog->RefreshFramePhysicalAddress =
- WatchdogInfoList->RefreshFrameAddress;
+ Cursor->RefreshFrameAddress;
Watchdog->WatchdogControlFramePhysicalAddress =
- WatchdogInfoList->ControlFrameAddress;
- Watchdog->WatchdogTimerGSIV = WatchdogInfoList->TimerGSIV;
- Watchdog->WatchdogTimerFlags = WatchdogInfoList->Flags;
+ Cursor->ControlFrameAddress;
+ Watchdog->WatchdogTimerGSIV = Cursor->TimerGSIV;
+ Watchdog->WatchdogTimerFlags = Cursor->Flags;
Watchdog++;
- WatchdogInfoList++;
+ Cursor++;
} // for
+
+ FreePool (WatchdogInfoList);
}

/**
@@ -313,8 +276,6 @@ AddGTBlockTimerFrames (

/** Add the GT Block Timers in the GTDT Table.

- @param [in] CfgMgrProtocol Pointer to the Configuration Manager
- Protocol Interface.
@param [in] Gtdt Pointer to the GTDT Table.
@param [in] GTBlockOffset Offset of the GT Block
information in the GTDT Table.
@@ -328,7 +289,6 @@ AddGTBlockTimerFrames (
STATIC
EFI_STATUS
AddGTBlockList (
- IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol,
IN EFI_ACPI_6_3_GENERIC_TIMER_DESCRIPTION_TABLE * CONST Gtdt,
IN CONST UINT32 GTBlockOffset,
IN CONST CM_ARM_GTBLOCK_INFO * GTBlockInfo,
@@ -351,12 +311,11 @@ AddGTBlockList (
while (BlockTimerCount-- != 0) {
DEBUG ((DEBUG_INFO, "GTDT: GTBlock = 0x%p\n", GTBlock));

- Status = GetEArmObjGTBlockTimerFrameInfo (
- CfgMgrProtocol,
- GTBlockInfo->GTBlockTimerFrameToken,
- &GTBlockTimerFrameList,
- &GTBlockTimerFrameCount
- );
+ Status = CfgMgrGetObjects (
+ EArmObjGTBlockTimerFrameInfo,
+ GTBlockInfo->GTBlockTimerFrameToken,
+ NULL,
+ &GTBlockTimerFrameCount);
if (EFI_ERROR (Status) ||
(GTBlockTimerFrameCount != GTBlockInfo->GTBlockTimerFrameCount)) {
DEBUG ((
@@ -397,18 +356,20 @@ AddGTBlockList (
GtBlockFrame = (EFI_ACPI_6_3_GTDT_GT_BLOCK_TIMER_STRUCTURE*)
((UINT8*)GTBlock + GTBlock->GTBlockTimerOffset);

+ CfgMgrGetObjects (
+ EArmObjGTBlockTimerFrameInfo,
+ GTBlockInfo->GTBlockTimerFrameToken,
+ (VOID **)&GTBlockTimerFrameList,
+ &GTBlockTimerFrameCount);
+
// Add GT Block Timer frames
Status = AddGTBlockTimerFrames (
GtBlockFrame,
GTBlockTimerFrameList,
GTBlockTimerFrameCount
);
+ FreePool (GTBlockTimerFrameList);
if (EFI_ERROR (Status)) {
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: GTDT: Failed to add Generic Timer Frames. Status = %r\n",
- Status
- ));
return Status;
}

@@ -458,7 +419,6 @@ BuildGtdtTable (
UINT32 PlatformTimerCount;
UINT32 WatchdogCount;
UINT32 BlockTimerCount;
- CM_ARM_GENERIC_WATCHDOG_INFO * WatchdogInfoList;
CM_ARM_GTBLOCK_INFO * GTBlockInfo;
EFI_ACPI_6_3_GENERIC_TIMER_DESCRIPTION_TABLE * Gtdt;
UINT32 Idx;
@@ -467,7 +427,6 @@ BuildGtdtTable (

ASSERT (This != NULL);
ASSERT (AcpiTableInfo != NULL);
- ASSERT (CfgMgrProtocol != NULL);
ASSERT (Table != NULL);
ASSERT (AcpiTableInfo->TableGeneratorId == This->GeneratorID);
ASSERT (AcpiTableInfo->AcpiTableSignature == This->AcpiTableSignature);
@@ -485,46 +444,15 @@ BuildGtdtTable (
return EFI_INVALID_PARAMETER;
}

- *Table = NULL;
- Status = GetEArmObjPlatformGTBlockInfo (
- CfgMgrProtocol,
- CM_NULL_TOKEN,
- &GTBlockInfo,
- &BlockTimerCount
- );
- if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: GTDT: Failed to Get Platform GT Block Information." \
- " Status = %r\n",
- Status
- ));
- goto error_handler;
- }
-
- Status = GetEArmObjPlatformGenericWatchdogInfo (
- CfgMgrProtocol,
- CM_NULL_TOKEN,
- &WatchdogInfoList,
- &WatchdogCount
- );
+ Status = CfgMgrGetObjects (
+ EArmObjPlatformGTBlockInfo,
+ CM_NULL_TOKEN,
+ (VOID **)&GTBlockInfo,
+ &BlockTimerCount);
if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: GTDT: Failed to Get Platform Generic Watchdog Information." \
- " Status = %r\n",
- Status
- ));
- goto error_handler;
+ return Status;
}

- DEBUG ((
- DEBUG_INFO,
- "GTDT: BlockTimerCount = %d, WatchdogCount = %d\n",
- BlockTimerCount,
- WatchdogCount
- ));
-
// Calculate the GTDT Table Size
PlatformTimerCount = 0;
TableSize = sizeof (EFI_ACPI_6_3_GENERIC_TIMER_DESCRIPTION_TABLE);
@@ -558,6 +486,20 @@ BuildGtdtTable (
));
}

+ WatchdogCount = 0;
+ Status = CfgMgrCountObjects (
+ EArmObjPlatformGenericWatchdogInfo, &WatchdogCount);
+ if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
+ goto error_handler;
+ }
+
+ DEBUG ((
+ DEBUG_INFO,
+ "GTDT: BlockTimerCount = %d, WatchdogCount = %d\n",
+ BlockTimerCount,
+ WatchdogCount
+ ));
+
WatchdogOffset = 0;
if (WatchdogCount != 0) {
WatchdogOffset = TableSize;
@@ -572,20 +514,12 @@ BuildGtdtTable (
));
}

- *Table = (EFI_ACPI_DESCRIPTION_HEADER*)AllocateZeroPool (TableSize);
- if (*Table == NULL) {
+ Gtdt = AllocateZeroPool (TableSize);
+ if (Gtdt == NULL) {
Status = EFI_OUT_OF_RESOURCES;
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: GTDT: Failed to allocate memory for GTDT Table, Size = %d," \
- " Status = %r\n",
- TableSize,
- Status
- ));
goto error_handler;
}

- Gtdt = (EFI_ACPI_6_3_GENERIC_TIMER_DESCRIPTION_TABLE*)*Table;
DEBUG ((
DEBUG_INFO,
"GTDT: Gtdt = 0x%p TableSize = 0x%x\n",
@@ -595,20 +529,11 @@ BuildGtdtTable (

Status = AddAcpiHeader (This, &Gtdt->Header, AcpiTableInfo, TableSize);
if (EFI_ERROR (Status)) {
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: GTDT: Failed to add ACPI header. Status = %r\n",
- Status
- ));
goto error_handler;
}

Status = AddGenericTimerInfo (
- CfgMgrProtocol,
- Gtdt,
- PlatformTimerCount,
- AcpiTableInfo->AcpiTableRevision
- );
+ Gtdt, PlatformTimerCount, AcpiTableInfo->AcpiTableRevision);
if (EFI_ERROR (Status)) {
DEBUG ((
DEBUG_ERROR,
@@ -619,13 +544,7 @@ BuildGtdtTable (
}

if (BlockTimerCount != 0) {
- Status = AddGTBlockList (
- CfgMgrProtocol,
- Gtdt,
- GTBlockOffset,
- GTBlockInfo,
- BlockTimerCount
- );
+ Status = AddGTBlockList (Gtdt, GTBlockOffset, GTBlockInfo, BlockTimerCount);
if (EFI_ERROR (Status)) {
DEBUG ((
DEBUG_ERROR,
@@ -637,21 +556,19 @@ BuildGtdtTable (
}

if (WatchdogCount != 0) {
- AddGenericWatchdogList (
- Gtdt,
- WatchdogOffset,
- WatchdogInfoList,
- WatchdogCount
- );
+ AddGenericWatchdogList (Gtdt, WatchdogOffset);
}

+ FreePool (GTBlockInfo);
+
+ *Table = (EFI_ACPI_DESCRIPTION_HEADER *)Gtdt;
return Status;

error_handler:
- if (*Table != NULL) {
- FreePool (*Table);
- *Table = NULL;
+ if (Gtdt != NULL) {
+ FreePool (Gtdt);
}
+ FreePool (GTBlockInfo);
return Status;
}

@@ -677,7 +594,6 @@ FreeGtdtTableResources (
{
ASSERT (This != NULL);
ASSERT (AcpiTableInfo != NULL);
- ASSERT (CfgMgrProtocol != NULL);
ASSERT (AcpiTableInfo->TableGeneratorId == This->GeneratorID);
ASSERT (AcpiTableInfo->AcpiTableSignature == This->AcpiTableSignature);

diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.c
index 97f86ddb30..dc518238c7 100644
--- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.c
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.c
@@ -20,7 +20,6 @@
// Module specific include files.
#include <AcpiTableGenerator.h>
#include <ConfigurationManagerObject.h>
-#include <ConfigurationManagerHelper.h>
#include <Library/TableHelperLib.h>
#include <Protocol/ConfigurationManagerProtocol.h>

@@ -42,244 +41,82 @@ Requirements:
- EArmObjGicItsIdentifierArray
*/

-/** This macro expands to a function that retrieves the ITS
- Group node information from the Configuration Manager.
+/*
+ Function type that evaluates the size of a node and sets
+ the node pointer to the next node. Used in iteration over
+ node lists.
*/
-GET_OBJECT_LIST (
- EObjNameSpaceArm,
- EArmObjItsGroup,
- CM_ARM_ITS_GROUP_NODE
- );
-
-/** This macro expands to a function that retrieves the
- Named Component node information from the Configuration Manager.
-*/
-GET_OBJECT_LIST (
- EObjNameSpaceArm,
- EArmObjNamedComponent,
- CM_ARM_NAMED_COMPONENT_NODE
- );
-
-/** This macro expands to a function that retrieves the
- Root Complex node information from the Configuration Manager.
-*/
-GET_OBJECT_LIST (
- EObjNameSpaceArm,
- EArmObjRootComplex,
- CM_ARM_ROOT_COMPLEX_NODE
- );
-
-/** This macro expands to a function that retrieves the
- SMMU v1/v2 node information from the Configuration Manager.
-*/
-GET_OBJECT_LIST (
- EObjNameSpaceArm,
- EArmObjSmmuV1SmmuV2,
- CM_ARM_SMMUV1_SMMUV2_NODE
- );
-
-/** This macro expands to a function that retrieves the
- SMMU v3 node information from the Configuration Manager.
-*/
-GET_OBJECT_LIST (
- EObjNameSpaceArm,
- EArmObjSmmuV3,
- CM_ARM_SMMUV3_NODE
- );
-
-/** This macro expands to a function that retrieves the
- PMCG node information from the Configuration Manager.
-*/
-GET_OBJECT_LIST (
- EObjNameSpaceArm,
- EArmObjPmcg,
- CM_ARM_PMCG_NODE
- );
-
-/** This macro expands to a function that retrieves the
- ITS Identifier Array information from the Configuration Manager.
-*/
-GET_OBJECT_LIST (
- EObjNameSpaceArm,
- EArmObjGicItsIdentifierArray,
- CM_ARM_ITS_IDENTIFIER
- );
-
-/** This macro expands to a function that retrieves the
- Id Mapping Array information from the Configuration Manager.
-*/
-GET_OBJECT_LIST (
- EObjNameSpaceArm,
- EArmObjIdMappingArray,
- CM_ARM_ID_MAPPING
- );
-
-/** This macro expands to a function that retrieves the
- SMMU Interrupt Array information from the Configuration Manager.
-*/
-GET_OBJECT_LIST (
- EObjNameSpaceArm,
- EArmObjSmmuInterruptArray,
- CM_ARM_SMMU_INTERRUPT
- );
+typedef UINT32 (EFIAPI *INDEX_NODE)(VOID ** Node);

-/** Returns the size of the ITS Group node.
-
- @param [in] Node Pointer to ITS Group node.
+/** Returns the size of the ITS Group node, increments
+ to the next node.

+ @param [in,out] Ptr Pointer to ITS Group node.
@retval Size of the ITS Group Node.
**/
STATIC
UINT32
GetItsGroupNodeSize (
- IN CONST CM_ARM_ITS_GROUP_NODE * Node
+ IN OUT VOID ** Ptr
)
{
- ASSERT (Node != NULL);
+ ASSERT (Ptr != NULL && *Ptr != NULL);
+
+ CM_ARM_ITS_GROUP_NODE *Node = *Ptr;
+ *Ptr = Node + 1;

/* Size of ITS Group Node +
Size of ITS Identifier array
*/
- return (UINT32)(sizeof (EFI_ACPI_6_0_IO_REMAPPING_ITS_NODE) +
- (Node->ItsIdCount * sizeof (UINT32)));
-}
-
-/** Returns the total size required for the ITS Group nodes and
- updates the Node Indexer.
-
- This function calculates the size required for the node group
- and also populates the Node Indexer array with offsets for the
- individual nodes.
-
- @param [in] NodeStartOffset Offset from the start of the
- IORT where this node group starts.
- @param [in] NodeList Pointer to ITS Group node list.
- @param [in] NodeCount Count of the ITS Group nodes.
- @param [in, out] NodeIndexer Pointer to the next Node Indexer.
-
- @retval Total size of the ITS Group Nodes.
-**/
-STATIC
-UINT64
-GetSizeofItsGroupNodes (
- IN CONST UINT32 NodeStartOffset,
- IN CONST CM_ARM_ITS_GROUP_NODE * NodeList,
- IN UINT32 NodeCount,
- IN OUT IORT_NODE_INDEXER ** CONST NodeIndexer
- )
-{
- UINT64 Size;
-
- ASSERT (NodeList != NULL);
-
- Size = 0;
- while (NodeCount-- != 0) {
- (*NodeIndexer)->Token = NodeList->Token;
- (*NodeIndexer)->Object = (VOID*)NodeList;
- (*NodeIndexer)->Offset = (UINT32)(Size + NodeStartOffset);
- DEBUG ((
- DEBUG_INFO,
- "IORT: Node Indexer = %p, Token = %p, Object = %p, Offset = 0x%x\n",
- *NodeIndexer,
- (*NodeIndexer)->Token,
- (*NodeIndexer)->Object,
- (*NodeIndexer)->Offset
- ));
-
- Size += GetItsGroupNodeSize (NodeList);
- (*NodeIndexer)++;
- NodeList++;
- }
- return Size;
+ return (UINT32) (
+ sizeof (EFI_ACPI_6_0_IO_REMAPPING_ITS_NODE) +
+ (Node->ItsIdCount) * sizeof (UINT32));
}

-/** Returns the size of the Named Component node.
-
- @param [in] Node Pointer to Named Component node.
+/** Returns the size of the Named Component node and
+ point to the next node

+ @param [in,out] Ptr Pointer to Named Component node.
@retval Size of the Named Component node.
**/
STATIC
UINT32
GetNamedComponentNodeSize (
- IN CONST CM_ARM_NAMED_COMPONENT_NODE * Node
+ IN OUT VOID ** Ptr
)
{
- ASSERT (Node != NULL);
+ ASSERT (Ptr != NULL && *Ptr != NULL);
+
+ CM_ARM_NAMED_COMPONENT_NODE * Node = *Ptr;
+ *Ptr = Node + 1;

/* Size of Named Component node +
Size of ID mapping array +
Size of ASCII string + 'padding to 32-bit word aligned'.
*/
+
return (UINT32)(sizeof (EFI_ACPI_6_0_IO_REMAPPING_NAMED_COMP_NODE) +
- (Node->IdMappingCount *
+ ((Node->IdMappingCount *
sizeof (EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE)) +
- ALIGN_VALUE (AsciiStrSize (Node->ObjectName), 4));
-}
-
-/** Returns the total size required for the Named Component nodes and
- updates the Node Indexer.
-
- This function calculates the size required for the node group
- and also populates the Node Indexer array with offsets for the
- individual nodes.
-
- @param [in] NodeStartOffset Offset from the start of the
- IORT where this node group starts.
- @param [in] NodeList Pointer to Named Component node list.
- @param [in] NodeCount Count of the Named Component nodes.
- @param [in, out] NodeIndexer Pointer to the next Node Indexer.
-
- @retval Total size of the Named Component nodes.
-**/
-STATIC
-UINT64
-GetSizeofNamedComponentNodes (
- IN CONST UINT32 NodeStartOffset,
- IN CONST CM_ARM_NAMED_COMPONENT_NODE * NodeList,
- IN UINT32 NodeCount,
- IN OUT IORT_NODE_INDEXER ** CONST NodeIndexer
- )
-{
- UINT64 Size;
-
- ASSERT (NodeList != NULL);
-
- Size = 0;
- while (NodeCount-- != 0) {
- (*NodeIndexer)->Token = NodeList->Token;
- (*NodeIndexer)->Object = (VOID*)NodeList;
- (*NodeIndexer)->Offset = (UINT32)(Size + NodeStartOffset);
- DEBUG ((
- DEBUG_INFO,
- "IORT: Node Indexer = %p, Token = %p, Object = %p, Offset = 0x%x\n",
- *NodeIndexer,
- (*NodeIndexer)->Token,
- (*NodeIndexer)->Object,
- (*NodeIndexer)->Offset
- ));
-
- Size += GetNamedComponentNodeSize (NodeList);
- (*NodeIndexer)++;
- NodeList++;
- }
-
- return Size;
+ ALIGN_VALUE (AsciiStrSize (Node->ObjectName), 4)));
}

-/** Returns the size of the Root Complex node.
-
- @param [in] Node Pointer to Root Complex node.
+/** Returns the size of the Root Complex node and point
+ to the next node.

+ @param [in,out] Ptr Pointer to Root Complex node.
@retval Size of the Root Complex node.
**/
STATIC
UINT32
GetRootComplexNodeSize (
- IN CONST CM_ARM_ROOT_COMPLEX_NODE * Node
+ IN OUT VOID ** Ptr
)
{
- ASSERT (Node != NULL);
+ ASSERT (Ptr != NULL && *Ptr != NULL);
+
+ CM_ARM_ROOT_COMPLEX_NODE *Node = *Ptr;
+ *Ptr = Node + 1;

/* Size of Root Complex node +
Size of ID mapping array
@@ -289,69 +126,22 @@ GetRootComplexNodeSize (
sizeof (EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE)));
}

-/** Returns the total size required for the Root Complex nodes and
- updates the Node Indexer.
-
- This function calculates the size required for the node group
- and also populates the Node Indexer array with offsets for the
- individual nodes.
-
- @param [in] NodeStartOffset Offset from the start of the
- IORT where this node group starts.
- @param [in] NodeList Pointer to Root Complex node list.
- @param [in] NodeCount Count of the Root Complex nodes.
- @param [in, out] NodeIndexer Pointer to the next Node Indexer.
-
- @retval Total size of the Root Complex nodes.
-**/
-STATIC
-UINT64
-GetSizeofRootComplexNodes (
- IN CONST UINT32 NodeStartOffset,
- IN CONST CM_ARM_ROOT_COMPLEX_NODE * NodeList,
- IN UINT32 NodeCount,
- IN OUT IORT_NODE_INDEXER ** CONST NodeIndexer
- )
-{
- UINT64 Size;
-
- ASSERT (NodeList != NULL);
-
- Size = 0;
- while (NodeCount-- != 0) {
- (*NodeIndexer)->Token = NodeList->Token;
- (*NodeIndexer)->Object = (VOID*)NodeList;
- (*NodeIndexer)->Offset = (UINT32)(Size + NodeStartOffset);
- DEBUG ((
- DEBUG_INFO,
- "IORT: Node Indexer = %p, Token = %p, Object = %p, Offset = 0x%x\n",
- *NodeIndexer,
- (*NodeIndexer)->Token,
- (*NodeIndexer)->Object,
- (*NodeIndexer)->Offset
- ));
-
- Size += GetRootComplexNodeSize (NodeList);
- (*NodeIndexer)++;
- NodeList++;
- }
-
- return Size;
-}
-
-/** Returns the size of the SMMUv1/SMMUv2 node.
-
- @param [in] Node Pointer to SMMUv1/SMMUv2 node list.
+/** Returns the size of the SMMUv1/SMMUv2 node and point
+ to the next node.

+ @param [in,out] Ptr Pointer to SMMUv1/SMMUv2 node list.
@retval Size of the SMMUv1/SMMUv2 node.
**/
STATIC
UINT32
GetSmmuV1V2NodeSize (
- IN CONST CM_ARM_SMMUV1_SMMUV2_NODE * Node
+ IN OUT VOID **Ptr
)
{
- ASSERT (Node != NULL);
+ ASSERT (Ptr != NULL && *Ptr != NULL);
+
+ CM_ARM_SMMUV1_SMMUV2_NODE * Node = *Ptr;
+ *Ptr = Node + 1;

/* Size of SMMU v1/SMMU v2 node +
Size of ID mapping array +
@@ -367,68 +157,22 @@ GetSmmuV1V2NodeSize (
sizeof (EFI_ACPI_6_0_IO_REMAPPING_SMMU_INT)));
}

-/** Returns the total size required for the SMMUv1/SMMUv2 nodes and
- updates the Node Indexer.
-
- This function calculates the size required for the node group
- and also populates the Node Indexer array with offsets for the
- individual nodes.
-
- @param [in] NodeStartOffset Offset from the start of the
- IORT where this node group starts.
- @param [in] NodeList Pointer to SMMUv1/SMMUv2 node list.
- @param [in] NodeCount Count of the SMMUv1/SMMUv2 nodes.
- @param [in, out] NodeIndexer Pointer to the next Node Indexer.
-
- @retval Total size of the SMMUv1/SMMUv2 nodes.
-**/
-STATIC
-UINT64
-GetSizeofSmmuV1V2Nodes (
- IN CONST UINT32 NodeStartOffset,
- IN CONST CM_ARM_SMMUV1_SMMUV2_NODE * NodeList,
- IN UINT32 NodeCount,
- IN OUT IORT_NODE_INDEXER ** CONST NodeIndexer
- )
-{
- UINT64 Size;
-
- ASSERT (NodeList != NULL);
-
- Size = 0;
- while (NodeCount-- != 0) {
- (*NodeIndexer)->Token = NodeList->Token;
- (*NodeIndexer)->Object = (VOID*)NodeList;
- (*NodeIndexer)->Offset = (UINT32)(Size + NodeStartOffset);
- DEBUG ((
- DEBUG_INFO,
- "IORT: Node Indexer = %p, Token = %p, Object = %p, Offset = 0x%x\n",
- *NodeIndexer,
- (*NodeIndexer)->Token,
- (*NodeIndexer)->Object,
- (*NodeIndexer)->Offset
- ));
-
- Size += GetSmmuV1V2NodeSize (NodeList);
- (*NodeIndexer)++;
- NodeList++;
- }
- return Size;
-}
-
-/** Returns the size of the SMMUv3 node.
-
- @param [in] Node Pointer to SMMUv3 node list.
+/** Returns the size of the SMMUv3 node and point to the next
+ node.

+ @param [in,out] Ptr Pointer to SMMUv3 node list.
@retval Total size of the SMMUv3 nodes.
**/
STATIC
UINT32
GetSmmuV3NodeSize (
- IN CONST CM_ARM_SMMUV3_NODE * Node
+ IN OUT VOID ** Ptr
)
{
- ASSERT (Node != NULL);
+ ASSERT (Ptr != NULL && *Ptr != NULL);
+
+ CM_ARM_SMMUV3_NODE *Node = *Ptr;
+ *Ptr = Node + 1;

/* Size of SMMU v1/SMMU v2 node +
Size of ID mapping array
@@ -438,68 +182,22 @@ GetSmmuV3NodeSize (
sizeof (EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE)));
}

-/** Returns the total size required for the SMMUv3 nodes and
- updates the Node Indexer.
-
- This function calculates the size required for the node group
- and also populates the Node Indexer array with offsets for the
- individual nodes.
-
- @param [in] NodeStartOffset Offset from the start of the
- IORT where this node group starts.
- @param [in] NodeList Pointer to SMMUv3 node list.
- @param [in] NodeCount Count of the SMMUv3 nodes.
- @param [in, out] NodeIndexer Pointer to the next Node Indexer.
-
- @retval Total size of the SMMUv3 nodes.
-**/
-STATIC
-UINT64
-GetSizeofSmmuV3Nodes (
- IN CONST UINT32 NodeStartOffset,
- IN CONST CM_ARM_SMMUV3_NODE * NodeList,
- IN UINT32 NodeCount,
- IN OUT IORT_NODE_INDEXER ** CONST NodeIndexer
- )
-{
- UINT64 Size;
-
- ASSERT (NodeList != NULL);
-
- Size = 0;
- while (NodeCount-- != 0) {
- (*NodeIndexer)->Token = NodeList->Token;
- (*NodeIndexer)->Object = (VOID*)NodeList;
- (*NodeIndexer)->Offset = (UINT32)(Size + NodeStartOffset);
- DEBUG ((
- DEBUG_INFO,
- "IORT: Node Indexer = %p, Token = %p, Object = %p, Offset = 0x%x\n",
- *NodeIndexer,
- (*NodeIndexer)->Token,
- (*NodeIndexer)->Object,
- (*NodeIndexer)->Offset
- ));
-
- Size += GetSmmuV3NodeSize (NodeList);
- (*NodeIndexer)++;
- NodeList++;
- }
- return Size;
-}
-
-/** Returns the size of the PMCG node.
-
- @param [in] Node Pointer to PMCG node.
+/** Returns the size of the PMCG node and point to the next
+ node.

+ @param [in,out] Ptr Pointer to PMCG node.
@retval Size of the PMCG node.
**/
STATIC
UINT32
GetPmcgNodeSize (
- IN CONST CM_ARM_PMCG_NODE * Node
+ IN OUT VOID ** Ptr
)
{
- ASSERT (Node != NULL);
+ ASSERT (Ptr != NULL && *Ptr != NULL);
+
+ CM_ARM_PMCG_NODE * Node = *Ptr;
+ *Ptr = Node + 1;

/* Size of PMCG node +
Size of ID mapping array
@@ -509,38 +207,49 @@ GetPmcgNodeSize (
sizeof (EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE)));
}

-/** Returns the total size required for the PMCG nodes and
- updates the Node Indexer.
+/** Returns the total size required for a group of IORT nodes. The configuration
+ manager objects specified by object id must contain CM_OBJECT_TOKEN as
+ their first field.

This function calculates the size required for the node group
and also populates the Node Indexer array with offsets for the
individual nodes.

+ @param [in] ObjectId The configuration manager object id of
+ nodes that are to be summed.
@param [in] NodeStartOffset Offset from the start of the
IORT where this node group starts.
- @param [in] NodeList Pointer to PMCG node list.
- @param [in] NodeCount Count of the PMCG nodes.
@param [in, out] NodeIndexer Pointer to the next Node Indexer.
+ @param [in] GetNodeSize The function to determine the size of a single node
+ of the appropriate type determined by object id.

- @retval Total size of the PMCG nodes.
+ @retval Total size of the group of nodes
**/
STATIC
UINT64
-GetSizeofPmcgNodes (
- IN CONST UINT32 NodeStartOffset,
- IN CONST CM_ARM_PMCG_NODE * NodeList,
- IN UINT32 NodeCount,
- IN OUT IORT_NODE_INDEXER ** CONST NodeIndexer
+GetSizeOfNodes (
+ IN CONST CM_OBJECT_ID ObjectId,
+ IN CONST UINT32 NodeStartOffset,
+ IN OUT IORT_NODE_INDEXER ** CONST NodeIndexer,
+ IN CONST INDEX_NODE IndexNode
)
{
- UINT64 Size;
-
- ASSERT (NodeList != NULL);
+ UINT64 Size;
+ EFI_STATUS Status;
+ VOID *NodeList;
+ UINT32 NodeCount;
+ VOID *Cursor;
+
+ Status = CfgMgrGetObjects (ObjectId, CM_NULL_TOKEN, &NodeList, &NodeCount);
+ if (EFI_ERROR(Status)) {
+ return 0;
+ }

+ Cursor = NodeList;
Size = 0;
while (NodeCount-- != 0) {
- (*NodeIndexer)->Token = NodeList->Token;
- (*NodeIndexer)->Object = (VOID*)NodeList;
+ (*NodeIndexer)->Token = *(CM_OBJECT_TOKEN *) Cursor; // CM_OBJECT_TOKEN is always the first element of a node
+ (*NodeIndexer)->Object = Cursor;
(*NodeIndexer)->Offset = (UINT32)(Size + NodeStartOffset);
DEBUG ((
DEBUG_INFO,
@@ -551,10 +260,11 @@ GetSizeofPmcgNodes (
(*NodeIndexer)->Offset
));

- Size += GetPmcgNodeSize (NodeList);
+ Size += IndexNode (&Cursor);
(*NodeIndexer)++;
- NodeList++;
}
+
+ FreePool (NodeList);
return Size;
}

@@ -631,14 +341,14 @@ STATIC
EFI_STATUS
AddIdMappingArray (
IN CONST ACPI_TABLE_GENERATOR * CONST This,
- IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol,
IN EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE * IdMapArray,
IN UINT32 IdCount,
IN CONST CM_OBJECT_TOKEN IdMappingToken
)
{
EFI_STATUS Status;
- CM_ARM_ID_MAPPING * IdMappings;
+ VOID * IdMappings;
+ CM_ARM_ID_MAPPING * Cursor;
UINT32 IdMappingCount;
ACPI_IORT_GENERATOR * Generator;

@@ -647,18 +357,12 @@ AddIdMappingArray (
Generator = (ACPI_IORT_GENERATOR*)This;

// Get the Id Mapping Array
- Status = GetEArmObjIdMappingArray (
- CfgMgrProtocol,
- IdMappingToken,
- &IdMappings,
- &IdMappingCount
- );
+ Status = CfgMgrGetObjects (
+ EArmObjIdMappingArray,
+ IdMappingToken,
+ &IdMappings,
+ &IdMappingCount);
if (EFI_ERROR (Status)) {
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: IORT: Failed to get Id Mapping array. Status = %r\n",
- Status
- ));
return Status;
}

@@ -667,15 +371,17 @@ AddIdMappingArray (
DEBUG_ERROR,
"ERROR: IORT: Failed to get the required number of Id Mappings.\n"
));
- return EFI_NOT_FOUND;
+ Status = EFI_NOT_FOUND;
+ goto EXIT;
}

+ Cursor = IdMappings;
// Populate the Id Mapping array
while (IdCount-- != 0) {
Status = GetNodeOffsetReferencedByToken (
Generator->NodeIndexer,
Generator->IortNodeCount,
- IdMappings->OutputReferenceToken,
+ Cursor->OutputReferenceToken,
&IdMapArray->OutputReference
);
if (EFI_ERROR (Status)) {
@@ -684,22 +390,24 @@ AddIdMappingArray (
"ERROR: IORT: Failed to get Output Reference for ITS Identifier array."
"Reference Token = %p"
" Status = %r\n",
- IdMappings->OutputReferenceToken,
+ Cursor->OutputReferenceToken,
Status
));
- return Status;
+ goto EXIT;
}

- IdMapArray->InputBase = IdMappings->InputBase;
- IdMapArray->NumIds = IdMappings->NumIds;
- IdMapArray->OutputBase = IdMappings->OutputBase;
- IdMapArray->Flags = IdMappings->Flags;
+ IdMapArray->InputBase = Cursor->InputBase;
+ IdMapArray->NumIds = Cursor->NumIds;
+ IdMapArray->OutputBase = Cursor->OutputBase;
+ IdMapArray->Flags = Cursor->Flags;

IdMapArray++;
- IdMappings++;
+ Cursor++;
} // Id Mapping array

- return EFI_SUCCESS;
+EXIT:
+ FreePool (IdMappings);
+ return Status;
}

/** Update the ITS Group Node Information.
@@ -722,10 +430,9 @@ STATIC
EFI_STATUS
AddItsGroupNodes (
IN CONST ACPI_TABLE_GENERATOR * CONST This,
- IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol,
IN CONST EFI_ACPI_6_0_IO_REMAPPING_TABLE * Iort,
IN CONST UINT32 NodesStartOffset,
- IN CONST CM_ARM_ITS_GROUP_NODE * NodeList,
+ IN VOID * NodeList,
IN UINT32 NodeCount
)
{
@@ -736,6 +443,7 @@ AddItsGroupNodes (
UINT32 ItsIdentifierCount;
UINT32 IdIndex;
UINT64 NodeLength;
+ CM_ARM_ITS_GROUP_NODE *Node;

ASSERT (Iort != NULL);

@@ -743,7 +451,8 @@ AddItsGroupNodes (
NodesStartOffset);

while (NodeCount-- != 0) {
- NodeLength = GetItsGroupNodeSize (NodeList);
+ Node = (CM_ARM_ITS_GROUP_NODE *) NodeList;
+ NodeLength = GetItsGroupNodeSize (&NodeList); // Advances NodeList
if (NodeLength > MAX_UINT16) {
Status = EFI_INVALID_PARAMETER;
DEBUG ((
@@ -765,22 +474,16 @@ AddItsGroupNodes (
ItsGroupNode->Node.IdReference = 0;

// IORT specific data
- ItsGroupNode->NumItsIdentifiers = NodeList->ItsIdCount;
+ ItsGroupNode->NumItsIdentifiers = Node->ItsIdCount;
ItsIds = (UINT32*)((UINT8*)ItsGroupNode +
sizeof (EFI_ACPI_6_0_IO_REMAPPING_ITS_NODE));

- Status = GetEArmObjGicItsIdentifierArray (
- CfgMgrProtocol,
- NodeList->ItsIdToken,
- &ItsIdentifier,
- &ItsIdentifierCount
- );
+ Status = CfgMgrGetObjects (
+ EArmObjGicItsIdentifierArray,
+ Node->ItsIdToken,
+ (VOID **)&ItsIdentifier,
+ &ItsIdentifierCount);
if (EFI_ERROR (Status)) {
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: IORT: Failed to get ITS Identifier array. Status = %r\n",
- Status
- ));
return Status;
}

@@ -789,7 +492,8 @@ AddItsGroupNodes (
DEBUG_ERROR,
"ERROR: IORT: Failed to get the required number of ITS Identifiers.\n"
));
- return EFI_NOT_FOUND;
+ Status = EFI_NOT_FOUND;
+ goto EXIT;
}

// Populate the ITS identifier array
@@ -800,10 +504,11 @@ AddItsGroupNodes (
// Next IORT Group Node
ItsGroupNode = (EFI_ACPI_6_0_IO_REMAPPING_ITS_NODE*)((UINT8*)ItsGroupNode +
ItsGroupNode->Node.Length);
- NodeList++;
} // IORT Group Node

- return EFI_SUCCESS;
+EXIT:
+ FreePool (ItsIdentifier);
+ return Status;
}

/** Update the Named Component Node Information.
@@ -812,8 +517,6 @@ AddItsGroupNodes (
table.

@param [in] This Pointer to the table Generator.
- @param [in] CfgMgrProtocol Pointer to the Configuration Manager
- Protocol Interface.
@param [in] Iort Pointer to IORT table structure.
@param [in] NodesStartOffset Offset for the start of the Named
Component Nodes.
@@ -829,10 +532,9 @@ STATIC
EFI_STATUS
AddNamedComponentNodes (
IN CONST ACPI_TABLE_GENERATOR * CONST This,
- IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol,
IN CONST EFI_ACPI_6_0_IO_REMAPPING_TABLE * Iort,
IN CONST UINT32 NodesStartOffset,
- IN CONST CM_ARM_NAMED_COMPONENT_NODE * NodeList,
+ IN VOID * NodeList,
IN UINT32 NodeCount
)
{
@@ -842,6 +544,7 @@ AddNamedComponentNodes (
CHAR8 * ObjectName;
UINTN ObjectNameLength;
UINT64 NodeLength;
+ CM_ARM_NAMED_COMPONENT_NODE * Node;

ASSERT (Iort != NULL);

@@ -849,7 +552,8 @@ AddNamedComponentNodes (
NodesStartOffset);

while (NodeCount-- != 0) {
- NodeLength = GetNamedComponentNodeSize (NodeList);
+ Node = (CM_ARM_NAMED_COMPONENT_NODE*) NodeList;
+ NodeLength = GetNamedComponentNodeSize (&NodeList); // Advances NodeList
if (NodeLength > MAX_UINT16) {
Status = EFI_INVALID_PARAMETER;
DEBUG ((
@@ -867,20 +571,20 @@ AddNamedComponentNodes (
NcNode->Node.Length = (UINT16)NodeLength;
NcNode->Node.Revision = 2;
NcNode->Node.Reserved = EFI_ACPI_RESERVED_DWORD;
- NcNode->Node.NumIdMappings = NodeList->IdMappingCount;
+ NcNode->Node.NumIdMappings = Node->IdMappingCount;

- ObjectNameLength = AsciiStrLen (NodeList->ObjectName) + 1;
+ ObjectNameLength = AsciiStrLen (Node->ObjectName) + 1;
NcNode->Node.IdReference =
(UINT32)(sizeof (EFI_ACPI_6_0_IO_REMAPPING_NAMED_COMP_NODE) +
(ALIGN_VALUE (ObjectNameLength, 4)));

// Named Component specific data
- NcNode->Flags = NodeList->Flags;
- NcNode->CacheCoherent = NodeList->CacheCoherent;
- NcNode->AllocationHints = NodeList->AllocationHints;
+ NcNode->Flags = Node->Flags;
+ NcNode->CacheCoherent = Node->CacheCoherent;
+ NcNode->AllocationHints = Node->AllocationHints;
NcNode->Reserved = EFI_ACPI_RESERVED_WORD;
- NcNode->MemoryAccessFlags = NodeList->MemoryAccessFlags;
- NcNode->AddressSizeLimit = NodeList->AddressSizeLimit;
+ NcNode->MemoryAccessFlags = Node->MemoryAccessFlags;
+ NcNode->AddressSizeLimit = Node->AddressSizeLimit;

// Copy the object name
ObjectName = (CHAR8*)((UINT8*)NcNode +
@@ -888,7 +592,7 @@ AddNamedComponentNodes (
Status = AsciiStrCpyS (
ObjectName,
ObjectNameLength,
- NodeList->ObjectName
+ Node->ObjectName
);
if (EFI_ERROR (Status)) {
DEBUG ((
@@ -899,19 +603,14 @@ AddNamedComponentNodes (
return Status;
}

- if ((NodeList->IdMappingCount > 0) &&
- (NodeList->IdMappingToken != CM_NULL_TOKEN)) {
+ if ((Node->IdMappingCount > 0) &&
+ (Node->IdMappingToken != CM_NULL_TOKEN)) {
// Ids for Named Component
IdMapArray = (EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE*)((UINT8*)NcNode +
NcNode->Node.IdReference);

Status = AddIdMappingArray (
- This,
- CfgMgrProtocol,
- IdMapArray,
- NodeList->IdMappingCount,
- NodeList->IdMappingToken
- );
+ This, IdMapArray, Node->IdMappingCount, Node->IdMappingToken);
if (EFI_ERROR (Status)) {
DEBUG ((
DEBUG_ERROR,
@@ -925,7 +624,6 @@ AddNamedComponentNodes (
// Next Named Component Node
NcNode = (EFI_ACPI_6_0_IO_REMAPPING_NAMED_COMP_NODE*)((UINT8*)NcNode +
NcNode->Node.Length);
- NodeList++;
} // Named Component Node

return EFI_SUCCESS;
@@ -936,8 +634,6 @@ AddNamedComponentNodes (
This function updates the Root Complex node information in the IORT table.

@param [in] This Pointer to the table Generator.
- @param [in] CfgMgrProtocol Pointer to the Configuration Manager
- Protocol Interface.
@param [in] Iort Pointer to IORT table structure.
@param [in] NodesStartOffset Offset for the start of the Root Complex
Nodes.
@@ -953,10 +649,9 @@ STATIC
EFI_STATUS
AddRootComplexNodes (
IN CONST ACPI_TABLE_GENERATOR * CONST This,
- IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol,
IN CONST EFI_ACPI_6_0_IO_REMAPPING_TABLE * Iort,
IN CONST UINT32 NodesStartOffset,
- IN CONST CM_ARM_ROOT_COMPLEX_NODE * NodeList,
+ IN VOID * NodeList,
IN UINT32 NodeCount
)
{
@@ -964,6 +659,7 @@ AddRootComplexNodes (
EFI_ACPI_6_0_IO_REMAPPING_RC_NODE * RcNode;
EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE * IdMapArray;
UINT64 NodeLength;
+ CM_ARM_ROOT_COMPLEX_NODE * Node;

ASSERT (Iort != NULL);

@@ -971,7 +667,8 @@ AddRootComplexNodes (
NodesStartOffset);

while (NodeCount-- != 0) {
- NodeLength = GetRootComplexNodeSize (NodeList);
+ Node = (CM_ARM_ROOT_COMPLEX_NODE *) NodeList;
+ NodeLength = GetRootComplexNodeSize (&NodeList); // Advances NodeList
if (NodeLength > MAX_UINT16) {
Status = EFI_INVALID_PARAMETER;
DEBUG ((
@@ -989,33 +686,28 @@ AddRootComplexNodes (
RcNode->Node.Length = (UINT16)NodeLength;
RcNode->Node.Revision = 1;
RcNode->Node.Reserved = EFI_ACPI_RESERVED_DWORD;
- RcNode->Node.NumIdMappings = NodeList->IdMappingCount;
+ RcNode->Node.NumIdMappings = Node->IdMappingCount;
RcNode->Node.IdReference = sizeof (EFI_ACPI_6_0_IO_REMAPPING_RC_NODE);

// Root Complex specific data
- RcNode->CacheCoherent = NodeList->CacheCoherent;
- RcNode->AllocationHints = NodeList->AllocationHints;
+ RcNode->CacheCoherent = Node->CacheCoherent;
+ RcNode->AllocationHints = Node->AllocationHints;
RcNode->Reserved = EFI_ACPI_RESERVED_WORD;
- RcNode->MemoryAccessFlags = NodeList->MemoryAccessFlags;
- RcNode->AtsAttribute = NodeList->AtsAttribute;
- RcNode->PciSegmentNumber = NodeList->PciSegmentNumber;
- RcNode->MemoryAddressSize = NodeList->MemoryAddressSize;
+ RcNode->MemoryAccessFlags = Node->MemoryAccessFlags;
+ RcNode->AtsAttribute = Node->AtsAttribute;
+ RcNode->PciSegmentNumber = Node->PciSegmentNumber;
+ RcNode->MemoryAddressSize = Node->MemoryAddressSize;
RcNode->Reserved1[0] = EFI_ACPI_RESERVED_BYTE;
RcNode->Reserved1[1] = EFI_ACPI_RESERVED_BYTE;
RcNode->Reserved1[2] = EFI_ACPI_RESERVED_BYTE;

- if ((NodeList->IdMappingCount > 0) &&
- (NodeList->IdMappingToken != CM_NULL_TOKEN)) {
+ if ((Node->IdMappingCount > 0) &&
+ (Node->IdMappingToken != CM_NULL_TOKEN)) {
// Ids for Root Complex
IdMapArray = (EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE*)((UINT8*)RcNode +
RcNode->Node.IdReference);
Status = AddIdMappingArray (
- This,
- CfgMgrProtocol,
- IdMapArray,
- NodeList->IdMappingCount,
- NodeList->IdMappingToken
- );
+ This, IdMapArray, Node->IdMappingCount, Node->IdMappingToken);
if (EFI_ERROR (Status)) {
DEBUG ((
DEBUG_ERROR,
@@ -1029,7 +721,6 @@ AddRootComplexNodes (
// Next Root Complex Node
RcNode = (EFI_ACPI_6_0_IO_REMAPPING_RC_NODE*)((UINT8*)RcNode +
RcNode->Node.Length);
- NodeList++;
} // Root Complex Node

return EFI_SUCCESS;
@@ -1040,8 +731,6 @@ AddRootComplexNodes (
This function retrieves the InterruptArray object referenced by the
InterruptToken and updates the SMMU InterruptArray.

- @param [in] CfgMgrProtocol Pointer to the Configuration Manager
- Protocol Interface.
@param [in, out] InterruptArray Pointer to an array of Interrupts.
@param [in] InterruptCount Number of entries in the InterruptArray.
@param [in] InterruptToken Reference Token for retrieving the SMMU
@@ -1054,31 +743,25 @@ AddRootComplexNodes (
STATIC
EFI_STATUS
AddSmmuInterrruptArray (
- IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol,
IN OUT EFI_ACPI_6_0_IO_REMAPPING_SMMU_INT * InterruptArray,
IN UINT32 InterruptCount,
IN CONST CM_OBJECT_TOKEN InterruptToken
)
{
EFI_STATUS Status;
- CM_ARM_SMMU_INTERRUPT * SmmuInterrupt;
+ CM_ARM_SMMU_INTERRUPT * Cursor;
+ VOID * SmmuInterrupt;
UINT32 SmmuInterruptCount;

ASSERT (InterruptArray != NULL);

// Get the SMMU Interrupt Array
- Status = GetEArmObjSmmuInterruptArray (
- CfgMgrProtocol,
- InterruptToken,
- &SmmuInterrupt,
- &SmmuInterruptCount
- );
+ Status = CfgMgrGetObjects (
+ EArmObjSmmuInterruptArray,
+ InterruptToken,
+ &SmmuInterrupt,
+ &SmmuInterruptCount);
if (EFI_ERROR (Status)) {
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: IORT: Failed to get SMMU Interrupt array. Status = %r\n",
- Status
- ));
return Status;
}

@@ -1087,25 +770,27 @@ AddSmmuInterrruptArray (
DEBUG_ERROR,
"ERROR: IORT: Failed to get the required number of SMMU Interrupts.\n"
));
- return EFI_NOT_FOUND;
+ Status = EFI_NOT_FOUND;
+ goto EXIT;
}

+ Cursor = SmmuInterrupt;
// Populate the Id Mapping array
while (InterruptCount-- != 0) {
- InterruptArray->Interrupt = SmmuInterrupt->Interrupt;
- InterruptArray->InterruptFlags = SmmuInterrupt->Flags;
+ InterruptArray->Interrupt = Cursor->Interrupt;
+ InterruptArray->InterruptFlags = Cursor->Flags;
InterruptArray++;
- SmmuInterrupt++;
+ Cursor++;
} // Id Mapping array

+EXIT:
+ FreePool (SmmuInterrupt);
return EFI_SUCCESS;
}

/** Update the SMMU v1/v2 Node Information.

@param [in] This Pointer to the table Generator.
- @param [in] CfgMgrProtocol Pointer to the Configuration Manager
- Protocol Interface.
@param [in] Iort Pointer to IORT table structure.
@param [in] NodesStartOffset Offset for the start of the SMMU v1/v2
Nodes.
@@ -1121,10 +806,9 @@ STATIC
EFI_STATUS
AddSmmuV1V2Nodes (
IN CONST ACPI_TABLE_GENERATOR * CONST This,
- IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol,
IN CONST EFI_ACPI_6_0_IO_REMAPPING_TABLE * Iort,
IN CONST UINT32 NodesStartOffset,
- IN CONST CM_ARM_SMMUV1_SMMUV2_NODE * NodeList,
+ IN VOID * NodeList,
IN UINT32 NodeCount
)
{
@@ -1135,6 +819,7 @@ AddSmmuV1V2Nodes (
EFI_ACPI_6_0_IO_REMAPPING_SMMU_INT * ContextInterruptArray;
EFI_ACPI_6_0_IO_REMAPPING_SMMU_INT * PmuInterruptArray;
UINT64 NodeLength;
+ CM_ARM_SMMUV1_SMMUV2_NODE * Node;

ASSERT (Iort != NULL);

@@ -1142,7 +827,8 @@ AddSmmuV1V2Nodes (
NodesStartOffset);

while (NodeCount-- != 0) {
- NodeLength = GetSmmuV1V2NodeSize (NodeList);
+ Node = (CM_ARM_SMMUV1_SMMUV2_NODE*) NodeList;
+ NodeLength = GetSmmuV1V2NodeSize (&NodeList); // Advances NodeList
if (NodeLength > MAX_UINT16) {
Status = EFI_INVALID_PARAMETER;
DEBUG ((
@@ -1159,25 +845,25 @@ AddSmmuV1V2Nodes (
SmmuNode->Node.Length = (UINT16)NodeLength;
SmmuNode->Node.Revision = 0;
SmmuNode->Node.Reserved = EFI_ACPI_RESERVED_DWORD;
- SmmuNode->Node.NumIdMappings = NodeList->IdMappingCount;
+ SmmuNode->Node.NumIdMappings = Node->IdMappingCount;
SmmuNode->Node.IdReference = sizeof (EFI_ACPI_6_0_IO_REMAPPING_SMMU_NODE) +
- (NodeList->ContextInterruptCount *
+ (Node->ContextInterruptCount *
sizeof (EFI_ACPI_6_0_IO_REMAPPING_SMMU_INT)) +
- (NodeList->PmuInterruptCount *
+ (Node->PmuInterruptCount *
sizeof (EFI_ACPI_6_0_IO_REMAPPING_SMMU_INT));

// SMMU v1/v2 specific data
- SmmuNode->Base = NodeList->BaseAddress;
- SmmuNode->Span = NodeList->Span;
- SmmuNode->Model = NodeList->Model;
- SmmuNode->Flags = NodeList->Flags;
+ SmmuNode->Base = Node->BaseAddress;
+ SmmuNode->Span = Node->Span;
+ SmmuNode->Model = Node->Model;
+ SmmuNode->Flags = Node->Flags;

// Reference to Global Interrupt Array
SmmuNode->GlobalInterruptArrayRef =
OFFSET_OF (EFI_ACPI_6_0_IO_REMAPPING_SMMU_NODE, SMMU_NSgIrpt);

// Context Interrupt
- SmmuNode->NumContextInterrupts = NodeList->ContextInterruptCount;
+ SmmuNode->NumContextInterrupts = Node->ContextInterruptCount;
SmmuNode->ContextInterruptArrayRef =
sizeof (EFI_ACPI_6_0_IO_REMAPPING_SMMU_NODE);
ContextInterruptArray =
@@ -1185,26 +871,24 @@ AddSmmuV1V2Nodes (
sizeof (EFI_ACPI_6_0_IO_REMAPPING_SMMU_NODE));

// PMU Interrupt
- SmmuNode->NumPmuInterrupts = NodeList->PmuInterruptCount;
+ SmmuNode->NumPmuInterrupts = Node->PmuInterruptCount;
SmmuNode->PmuInterruptArrayRef = SmmuNode->ContextInterruptArrayRef +
- (NodeList->ContextInterruptCount *
+ (Node->ContextInterruptCount *
sizeof (EFI_ACPI_6_0_IO_REMAPPING_SMMU_INT));
PmuInterruptArray =
(EFI_ACPI_6_0_IO_REMAPPING_SMMU_INT*)((UINT8*)SmmuNode +
SmmuNode->PmuInterruptArrayRef);

- SmmuNode->SMMU_NSgIrpt = NodeList->SMMU_NSgIrpt;
- SmmuNode->SMMU_NSgIrptFlags = NodeList->SMMU_NSgIrptFlags;
- SmmuNode->SMMU_NSgCfgIrpt = NodeList->SMMU_NSgCfgIrpt;
- SmmuNode->SMMU_NSgCfgIrptFlags = NodeList->SMMU_NSgCfgIrptFlags;
+ SmmuNode->SMMU_NSgIrpt = Node->SMMU_NSgIrpt;
+ SmmuNode->SMMU_NSgIrptFlags = Node->SMMU_NSgIrptFlags;
+ SmmuNode->SMMU_NSgCfgIrpt = Node->SMMU_NSgCfgIrpt;
+ SmmuNode->SMMU_NSgCfgIrptFlags = Node->SMMU_NSgCfgIrptFlags;

// Add Context Interrupt Array
Status = AddSmmuInterrruptArray (
- CfgMgrProtocol,
- ContextInterruptArray,
- SmmuNode->NumContextInterrupts,
- NodeList->ContextInterruptToken
- );
+ ContextInterruptArray,
+ SmmuNode->NumContextInterrupts,
+ Node->ContextInterruptToken);
if (EFI_ERROR (Status)) {
DEBUG ((
DEBUG_ERROR,
@@ -1216,13 +900,11 @@ AddSmmuV1V2Nodes (

// Add PMU Interrupt Array
if ((SmmuNode->NumPmuInterrupts > 0) &&
- (NodeList->PmuInterruptToken != CM_NULL_TOKEN)) {
+ (Node->PmuInterruptToken != CM_NULL_TOKEN)) {
Status = AddSmmuInterrruptArray (
- CfgMgrProtocol,
- PmuInterruptArray,
- SmmuNode->NumPmuInterrupts,
- NodeList->PmuInterruptToken
- );
+ PmuInterruptArray,
+ SmmuNode->NumPmuInterrupts,
+ Node->PmuInterruptToken);
if (EFI_ERROR (Status)) {
DEBUG ((
DEBUG_ERROR,
@@ -1233,18 +915,13 @@ AddSmmuV1V2Nodes (
}
}

- if ((NodeList->IdMappingCount > 0) &&
- (NodeList->IdMappingToken != CM_NULL_TOKEN)) {
+ if ((Node->IdMappingCount > 0) &&
+ (Node->IdMappingToken != CM_NULL_TOKEN)) {
// Ids for SMMU v1/v2 Node
IdMapArray = (EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE*)((UINT8*)SmmuNode +
SmmuNode->Node.IdReference);
Status = AddIdMappingArray (
- This,
- CfgMgrProtocol,
- IdMapArray,
- NodeList->IdMappingCount,
- NodeList->IdMappingToken
- );
+ This, IdMapArray, Node->IdMappingCount, Node->IdMappingToken);
if (EFI_ERROR (Status)) {
DEBUG ((
DEBUG_ERROR,
@@ -1257,7 +934,6 @@ AddSmmuV1V2Nodes (
// Next SMMU v1/v2 Node
SmmuNode = (EFI_ACPI_6_0_IO_REMAPPING_SMMU_NODE*)((UINT8*)SmmuNode +
SmmuNode->Node.Length);
- NodeList++;
} // SMMU v1/v2 Node

return EFI_SUCCESS;
@@ -1268,8 +944,6 @@ AddSmmuV1V2Nodes (
This function updates the SMMUv3 node information in the IORT table.

@param [in] This Pointer to the table Generator.
- @param [in] CfgMgrProtocol Pointer to the Configuration Manager
- Protocol Interface.
@param [in] Iort Pointer to IORT table structure.
@param [in] NodesStartOffset Offset for the start of the SMMUv3 Nodes.
@param [in] NodeList Pointer to an array of SMMUv3 Node Objects.
@@ -1283,10 +957,9 @@ STATIC
EFI_STATUS
AddSmmuV3Nodes (
IN CONST ACPI_TABLE_GENERATOR * CONST This,
- IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol,
IN CONST EFI_ACPI_6_0_IO_REMAPPING_TABLE * Iort,
IN CONST UINT32 NodesStartOffset,
- IN CONST CM_ARM_SMMUV3_NODE * NodeList,
+ IN VOID * NodeList,
IN UINT32 NodeCount
)
{
@@ -1294,6 +967,7 @@ AddSmmuV3Nodes (
EFI_ACPI_6_0_IO_REMAPPING_SMMU3_NODE * SmmuV3Node;
EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE * IdMapArray;
UINT64 NodeLength;
+ CM_ARM_SMMUV3_NODE * Node;

ASSERT (Iort != NULL);

@@ -1301,7 +975,8 @@ AddSmmuV3Nodes (
NodesStartOffset);

while (NodeCount-- != 0) {
- NodeLength = GetSmmuV3NodeSize (NodeList);
+ Node = (CM_ARM_SMMUV3_NODE*) NodeList;
+ NodeLength = GetSmmuV3NodeSize (&NodeList); // Advances NodeList
if (NodeLength > MAX_UINT16) {
Status = EFI_INVALID_PARAMETER;
DEBUG ((
@@ -1318,24 +993,24 @@ AddSmmuV3Nodes (
SmmuV3Node->Node.Length = (UINT16)NodeLength;
SmmuV3Node->Node.Revision = 2;
SmmuV3Node->Node.Reserved = EFI_ACPI_RESERVED_DWORD;
- SmmuV3Node->Node.NumIdMappings = NodeList->IdMappingCount;
+ SmmuV3Node->Node.NumIdMappings = Node->IdMappingCount;
SmmuV3Node->Node.IdReference =
sizeof (EFI_ACPI_6_0_IO_REMAPPING_SMMU3_NODE);

// SMMUv3 specific data
- SmmuV3Node->Base = NodeList->BaseAddress;
- SmmuV3Node->Flags = NodeList->Flags;
+ SmmuV3Node->Base = Node->BaseAddress;
+ SmmuV3Node->Flags = Node->Flags;
SmmuV3Node->Reserved = EFI_ACPI_RESERVED_WORD;
- SmmuV3Node->VatosAddress = NodeList->VatosAddress;
- SmmuV3Node->Model = NodeList->Model;
- SmmuV3Node->Event = NodeList->EventInterrupt;
- SmmuV3Node->Pri = NodeList->PriInterrupt;
- SmmuV3Node->Gerr = NodeList->GerrInterrupt;
- SmmuV3Node->Sync = NodeList->SyncInterrupt;
+ SmmuV3Node->VatosAddress = Node->VatosAddress;
+ SmmuV3Node->Model = Node->Model;
+ SmmuV3Node->Event = Node->EventInterrupt;
+ SmmuV3Node->Pri = Node->PriInterrupt;
+ SmmuV3Node->Gerr = Node->GerrInterrupt;
+ SmmuV3Node->Sync = Node->SyncInterrupt;

if ((SmmuV3Node->Flags & EFI_ACPI_IORT_SMMUv3_FLAG_PROXIMITY_DOMAIN) != 0) {
// The Proximity Domain Valid flag is set to 1
- SmmuV3Node->ProximityDomain = NodeList->ProximityDomain;
+ SmmuV3Node->ProximityDomain = Node->ProximityDomain;
} else {
SmmuV3Node->ProximityDomain = 0;
}
@@ -1346,21 +1021,16 @@ AddSmmuV3Nodes (
// the DeviceID mapping index field is ignored.
SmmuV3Node->DeviceIdMappingIndex = 0;
} else {
- SmmuV3Node->DeviceIdMappingIndex = NodeList->DeviceIdMappingIndex;
+ SmmuV3Node->DeviceIdMappingIndex = Node->DeviceIdMappingIndex;
}

- if ((NodeList->IdMappingCount > 0) &&
- (NodeList->IdMappingToken != CM_NULL_TOKEN)) {
+ if ((Node->IdMappingCount > 0) &&
+ (Node->IdMappingToken != CM_NULL_TOKEN)) {
// Ids for SMMUv3 node
IdMapArray = (EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE*)((UINT8*)SmmuV3Node +
SmmuV3Node->Node.IdReference);
Status = AddIdMappingArray (
- This,
- CfgMgrProtocol,
- IdMapArray,
- NodeList->IdMappingCount,
- NodeList->IdMappingToken
- );
+ This, IdMapArray, Node->IdMappingCount, Node->IdMappingToken);
if (EFI_ERROR (Status)) {
DEBUG ((
DEBUG_ERROR,
@@ -1374,7 +1044,6 @@ AddSmmuV3Nodes (
// Next SMMUv3 Node
SmmuV3Node = (EFI_ACPI_6_0_IO_REMAPPING_SMMU3_NODE*)((UINT8*)SmmuV3Node +
SmmuV3Node->Node.Length);
- NodeList++;
} // SMMUv3 Node

return EFI_SUCCESS;
@@ -1385,8 +1054,6 @@ AddSmmuV3Nodes (
This function updates the PMCG node information in the IORT table.

@param [in] This Pointer to the table Generator.
- @param [in] CfgMgrProtocol Pointer to the Configuration Manager
- Protocol Interface.
@param [in] Iort Pointer to IORT table structure.
@param [in] NodesStartOffset Offset for the start of the PMCG Nodes.
@param [in] NodeList Pointer to an array of PMCG Node Objects.
@@ -1400,10 +1067,9 @@ STATIC
EFI_STATUS
AddPmcgNodes (
IN CONST ACPI_TABLE_GENERATOR * CONST This,
- IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol,
IN CONST EFI_ACPI_6_0_IO_REMAPPING_TABLE * Iort,
IN CONST UINT32 NodesStartOffset,
- IN CONST CM_ARM_PMCG_NODE * NodeList,
+ IN VOID * NodeList,
IN UINT32 NodeCount
)
{
@@ -1412,6 +1078,7 @@ AddPmcgNodes (
EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE * IdMapArray;
ACPI_IORT_GENERATOR * Generator;
UINT64 NodeLength;
+ CM_ARM_PMCG_NODE * Node;

ASSERT (Iort != NULL);

@@ -1420,7 +1087,8 @@ AddPmcgNodes (
NodesStartOffset);

while (NodeCount-- != 0) {
- NodeLength = GetPmcgNodeSize (NodeList);
+ Node = (CM_ARM_PMCG_NODE*) NodeList;
+ NodeLength = GetPmcgNodeSize (&NodeList); // Advances NodeList
if (NodeLength > MAX_UINT16) {
Status = EFI_INVALID_PARAMETER;
DEBUG ((
@@ -1437,18 +1105,18 @@ AddPmcgNodes (
PmcgNode->Node.Length = (UINT16)NodeLength;
PmcgNode->Node.Revision = 1;
PmcgNode->Node.Reserved = EFI_ACPI_RESERVED_DWORD;
- PmcgNode->Node.NumIdMappings = NodeList->IdMappingCount;
+ PmcgNode->Node.NumIdMappings = Node->IdMappingCount;
PmcgNode->Node.IdReference = sizeof (EFI_ACPI_6_0_IO_REMAPPING_PMCG_NODE);

// PMCG specific data
- PmcgNode->Base = NodeList->BaseAddress;
- PmcgNode->OverflowInterruptGsiv = NodeList->OverflowInterrupt;
- PmcgNode->Page1Base = NodeList->Page1BaseAddress;
+ PmcgNode->Base = Node->BaseAddress;
+ PmcgNode->OverflowInterruptGsiv = Node->OverflowInterrupt;
+ PmcgNode->Page1Base = Node->Page1BaseAddress;

Status = GetNodeOffsetReferencedByToken (
Generator->NodeIndexer,
Generator->IortNodeCount,
- NodeList->ReferenceToken,
+ Node->ReferenceToken,
&PmcgNode->NodeReference
);
if (EFI_ERROR (Status)) {
@@ -1457,25 +1125,20 @@ AddPmcgNodes (
"ERROR: IORT: Failed to get Output Reference for PMCG Node."
"Reference Token = %p"
" Status = %r\n",
- NodeList->ReferenceToken,
+ Node->ReferenceToken,
Status
));
return Status;
}

- if ((NodeList->IdMappingCount > 0) &&
- (NodeList->IdMappingToken != CM_NULL_TOKEN)) {
+ if ((Node->IdMappingCount > 0) &&
+ (Node->IdMappingToken != CM_NULL_TOKEN)) {
// Ids for PMCG node
IdMapArray = (EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE*)((UINT8*)PmcgNode +
PmcgNode->Node.IdReference);

Status = AddIdMappingArray (
- This,
- CfgMgrProtocol,
- IdMapArray,
- NodeList->IdMappingCount,
- NodeList->IdMappingToken
- );
+ This, IdMapArray, Node->IdMappingCount, Node->IdMappingToken);
if (EFI_ERROR (Status)) {
DEBUG ((
DEBUG_ERROR,
@@ -1489,7 +1152,6 @@ AddPmcgNodes (
// Next PMCG Node
PmcgNode = (EFI_ACPI_6_0_IO_REMAPPING_PMCG_NODE*)((UINT8*)PmcgNode +
PmcgNode->Node.Length);
- NodeList++;
} // PMCG Node

return EFI_SUCCESS;
@@ -1547,20 +1209,13 @@ BuildIortTable (
UINT32 SmmuV3Offset;
UINT32 PmcgOffset;

- CM_ARM_ITS_GROUP_NODE * ItsGroupNodeList;
- CM_ARM_NAMED_COMPONENT_NODE * NamedComponentNodeList;
- CM_ARM_ROOT_COMPLEX_NODE * RootComplexNodeList;
- CM_ARM_SMMUV1_SMMUV2_NODE * SmmuV1V2NodeList;
- CM_ARM_SMMUV3_NODE * SmmuV3NodeList;
- CM_ARM_PMCG_NODE * PmcgNodeList;
-
+ VOID * NodeList;
EFI_ACPI_6_0_IO_REMAPPING_TABLE * Iort;
IORT_NODE_INDEXER * NodeIndexer;
ACPI_IORT_GENERATOR * Generator;

ASSERT (This != NULL);
ASSERT (AcpiTableInfo != NULL);
- ASSERT (CfgMgrProtocol != NULL);
ASSERT (Table != NULL);
ASSERT (AcpiTableInfo->TableGeneratorId == This->GeneratorID);
ASSERT (AcpiTableInfo->AcpiTableSignature == This->AcpiTableSignature);
@@ -1579,136 +1234,68 @@ BuildIortTable (
}

Generator = (ACPI_IORT_GENERATOR*)This;
+
+ // Pointers to allocated memory
*Table = NULL;

// Get the ITS group node info
- Status = GetEArmObjItsGroup (
- CfgMgrProtocol,
- CM_NULL_TOKEN,
- &ItsGroupNodeList,
- &ItsGroupNodeCount
- );
+ Status = CfgMgrCountObjects (EArmObjItsGroup, &ItsGroupNodeCount);
if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: IORT: Failed to get ITS Group Node Info. Status = %r\n",
- Status
- ));
- goto error_handler;
+ return Status;
}

// Add the ITS group node count
IortNodeCount = ItsGroupNodeCount;

// Get the Named component node info
- Status = GetEArmObjNamedComponent (
- CfgMgrProtocol,
- CM_NULL_TOKEN,
- &NamedComponentNodeList,
- &NamedComponentNodeCount
- );
+ Status = CfgMgrCountObjects (EArmObjNamedComponent, &NamedComponentNodeCount);
if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: IORT: Failed to get Named Component Node Info. Status = %r\n",
- Status
- ));
- goto error_handler;
+ return Status;
}

// Add the Named Component group count
IortNodeCount += NamedComponentNodeCount;

// Get the Root complex node info
- Status = GetEArmObjRootComplex (
- CfgMgrProtocol,
- CM_NULL_TOKEN,
- &RootComplexNodeList,
- &RootComplexNodeCount
- );
+ Status = CfgMgrCountObjects (EArmObjRootComplex, &RootComplexNodeCount);
if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: IORT: Failed to get Root Complex Node Info. Status = %r\n",
- Status
- ));
- goto error_handler;
+ return Status;
}

// Add the Root Complex node count
IortNodeCount += RootComplexNodeCount;

// Get the SMMU v1/v2 node info
- Status = GetEArmObjSmmuV1SmmuV2 (
- CfgMgrProtocol,
- CM_NULL_TOKEN,
- &SmmuV1V2NodeList,
- &SmmuV1V2NodeCount
- );
+ Status = CfgMgrCountObjects (EArmObjSmmuV1SmmuV2, &SmmuV1V2NodeCount);
if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: IORT: Failed to get SMMUv1/SMMUv2 Node Info. Status = %r\n",
- Status
- ));
- goto error_handler;
+ return Status;
}

// Add the SMMU v1/v2 node count
IortNodeCount += SmmuV1V2NodeCount;

// Get the SMMUv3 node info
- Status = GetEArmObjSmmuV3 (
- CfgMgrProtocol,
- CM_NULL_TOKEN,
- &SmmuV3NodeList,
- &SmmuV3NodeCount
- );
+ Status = CfgMgrCountObjects (EArmObjSmmuV3, &SmmuV3NodeCount);
if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: IORT: Failed to get SMMUv3 Node Info. Status = %r\n",
- Status
- ));
- goto error_handler;
+ return Status;
}

// Add the SMMUv3 node count
IortNodeCount += SmmuV3NodeCount;

// Get the PMCG node info
- Status = GetEArmObjPmcg (
- CfgMgrProtocol,
- CM_NULL_TOKEN,
- &PmcgNodeList,
- &PmcgNodeCount
- );
+ Status = CfgMgrCountObjects (EArmObjPmcg, &PmcgNodeCount);
if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: IORT: Failed to get PMCG Node Info. Status = %r\n",
- Status
- ));
- goto error_handler;
+ return Status;
}

// Add the PMCG node count
IortNodeCount += PmcgNodeCount;

// Allocate Node Indexer array
- NodeIndexer = (IORT_NODE_INDEXER*)AllocateZeroPool (
- (sizeof (IORT_NODE_INDEXER) *
- IortNodeCount)
- );
+ NodeIndexer = AllocateZeroPool ((sizeof (IORT_NODE_INDEXER) * IortNodeCount));
if (NodeIndexer == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: IORT: Failed to allocate memory for Node Indexer" \
- " Status = %r\n",
- Status
- ));
- goto error_handler;
+ return EFI_OUT_OF_RESOURCES;
}

DEBUG ((DEBUG_INFO, "INFO: NodeIndexer = %p\n", NodeIndexer));
@@ -1721,13 +1308,10 @@ BuildIortTable (
// ITS Group Nodes
if (ItsGroupNodeCount > 0) {
ItsGroupOffset = (UINT32)TableSize;
- // Size of ITS Group node list.
- NodeSize = GetSizeofItsGroupNodes (
- ItsGroupOffset,
- ItsGroupNodeList,
- ItsGroupNodeCount,
- &NodeIndexer
- );
+
+ NodeSize = GetSizeOfNodes (
+ EArmObjItsGroup, ItsGroupOffset, &NodeIndexer, GetItsGroupNodeSize);
+
if (NodeSize > MAX_UINT32) {
Status = EFI_INVALID_PARAMETER;
DEBUG ((
@@ -1751,13 +1335,13 @@ BuildIortTable (
// Named Component Nodes
if (NamedComponentNodeCount > 0) {
NamedComponentOffset = (UINT32)TableSize;
- // Size of Named Component node list.
- NodeSize = GetSizeofNamedComponentNodes (
- NamedComponentOffset,
- NamedComponentNodeList,
- NamedComponentNodeCount,
- &NodeIndexer
- );
+
+ NodeSize = GetSizeOfNodes (
+ EArmObjNamedComponent,
+ NamedComponentOffset,
+ &NodeIndexer,
+ GetNamedComponentNodeSize);
+
if (NodeSize > MAX_UINT32) {
Status = EFI_INVALID_PARAMETER;
DEBUG ((
@@ -1781,13 +1365,13 @@ BuildIortTable (
// Root Complex Nodes
if (RootComplexNodeCount > 0) {
RootComplexOffset = (UINT32)TableSize;
- // Size of Root Complex node list.
- NodeSize = GetSizeofRootComplexNodes (
- RootComplexOffset,
- RootComplexNodeList,
- RootComplexNodeCount,
- &NodeIndexer
- );
+
+ NodeSize = GetSizeOfNodes (
+ EArmObjRootComplex,
+ RootComplexOffset,
+ &NodeIndexer,
+ GetRootComplexNodeSize);
+
if (NodeSize > MAX_UINT32) {
Status = EFI_INVALID_PARAMETER;
DEBUG ((
@@ -1811,13 +1395,9 @@ BuildIortTable (
// SMMUv1/SMMUv2 Nodes
if (SmmuV1V2NodeCount > 0) {
SmmuV1V2Offset = (UINT32)TableSize;
- // Size of SMMUv1/SMMUv2 node list.
- NodeSize = GetSizeofSmmuV1V2Nodes (
- SmmuV1V2Offset,
- SmmuV1V2NodeList,
- SmmuV1V2NodeCount,
- &NodeIndexer
- );
+
+ NodeSize = GetSizeOfNodes (
+ EArmObjSmmuV1SmmuV2, SmmuV1V2Offset, &NodeIndexer, GetSmmuV1V2NodeSize);
if (NodeSize > MAX_UINT32) {
Status = EFI_INVALID_PARAMETER;
DEBUG ((
@@ -1841,13 +1421,9 @@ BuildIortTable (
// SMMUv3 Nodes
if (SmmuV3NodeCount > 0) {
SmmuV3Offset = (UINT32)TableSize;
- // Size of SMMUv3 node list.
- NodeSize = GetSizeofSmmuV3Nodes (
- SmmuV3Offset,
- SmmuV3NodeList,
- SmmuV3NodeCount,
- &NodeIndexer
- );
+
+ NodeSize = GetSizeOfNodes (
+ EArmObjSmmuV3, SmmuV3Offset, &NodeIndexer, GetSmmuV3NodeSize);
if (NodeSize > MAX_UINT32) {
Status = EFI_INVALID_PARAMETER;
DEBUG ((
@@ -1871,13 +1447,9 @@ BuildIortTable (
// PMCG Nodes
if (PmcgNodeCount > 0) {
PmcgOffset = (UINT32)TableSize;
- // Size of PMCG node list.
- NodeSize = GetSizeofPmcgNodes (
- PmcgOffset,
- PmcgNodeList,
- PmcgNodeCount,
- &NodeIndexer
- );
+
+ NodeSize = GetSizeOfNodes (
+ EArmObjPmcg, PmcgOffset, &NodeIndexer, GetPmcgNodeSize);
if (NodeSize > MAX_UINT32) {
Status = EFI_INVALID_PARAMETER;
DEBUG ((
@@ -1920,21 +1492,12 @@ BuildIortTable (
}

// Allocate the Buffer for IORT table
- *Table = (EFI_ACPI_DESCRIPTION_HEADER*)AllocateZeroPool (TableSize);
- if (*Table == NULL) {
+ Iort = AllocateZeroPool (TableSize);
+ if (Iort == NULL) {
Status = EFI_OUT_OF_RESOURCES;
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: IORT: Failed to allocate memory for IORT Table, Size = %d," \
- " Status = %r\n",
- TableSize,
- Status
- ));
goto error_handler;
}

- Iort = (EFI_ACPI_6_0_IO_REMAPPING_TABLE*)*Table;
-
DEBUG ((
DEBUG_INFO,
"IORT: Iort = 0x%p TableSize = 0x%lx\n",
@@ -1944,11 +1507,6 @@ BuildIortTable (

Status = AddAcpiHeader (This, &Iort->Header, AcpiTableInfo, (UINT32) TableSize);
if (EFI_ERROR (Status)) {
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: IORT: Failed to add ACPI header. Status = %r\n",
- Status
- ));
goto error_handler;
}

@@ -1958,14 +1516,10 @@ BuildIortTable (
Iort->Reserved = EFI_ACPI_RESERVED_DWORD;

if (ItsGroupNodeCount > 0) {
+ CfgMgrGetSimpleObject(EArmObjItsGroup, &NodeList);
Status = AddItsGroupNodes (
- This,
- CfgMgrProtocol,
- Iort,
- ItsGroupOffset,
- ItsGroupNodeList,
- ItsGroupNodeCount
- );
+ This, Iort, ItsGroupOffset, NodeList, ItsGroupNodeCount);
+ FreePool (NodeList);
if (EFI_ERROR (Status)) {
DEBUG ((
DEBUG_ERROR,
@@ -1977,14 +1531,10 @@ BuildIortTable (
}

if (NamedComponentNodeCount > 0) {
+ CfgMgrGetSimpleObject(EArmObjNamedComponent, &NodeList);
Status = AddNamedComponentNodes (
- This,
- CfgMgrProtocol,
- Iort,
- NamedComponentOffset,
- NamedComponentNodeList,
- NamedComponentNodeCount
- );
+ This, Iort, NamedComponentOffset, NodeList, NamedComponentNodeCount);
+ FreePool (NodeList);
if (EFI_ERROR (Status)) {
DEBUG ((
DEBUG_ERROR,
@@ -1996,14 +1546,10 @@ BuildIortTable (
}

if (RootComplexNodeCount > 0) {
+ CfgMgrGetSimpleObject(EArmObjRootComplex, &NodeList);
Status = AddRootComplexNodes (
- This,
- CfgMgrProtocol,
- Iort,
- RootComplexOffset,
- RootComplexNodeList,
- RootComplexNodeCount
- );
+ This, Iort, RootComplexOffset, NodeList, RootComplexNodeCount);
+ FreePool (NodeList);
if (EFI_ERROR (Status)) {
DEBUG ((
DEBUG_ERROR,
@@ -2015,14 +1561,10 @@ BuildIortTable (
}

if (SmmuV1V2NodeCount > 0) {
+ CfgMgrGetSimpleObject(EArmObjSmmuV1SmmuV2, &NodeList);
Status = AddSmmuV1V2Nodes (
- This,
- CfgMgrProtocol,
- Iort,
- SmmuV1V2Offset,
- SmmuV1V2NodeList,
- SmmuV1V2NodeCount
- );
+ This, Iort, SmmuV1V2Offset, NodeList, SmmuV1V2NodeCount);
+ FreePool (NodeList);
if (EFI_ERROR (Status)) {
DEBUG ((
DEBUG_ERROR,
@@ -2034,14 +1576,10 @@ BuildIortTable (
}

if (SmmuV3NodeCount > 0) {
+ CfgMgrGetSimpleObject(EArmObjSmmuV3, &NodeList);
Status = AddSmmuV3Nodes (
- This,
- CfgMgrProtocol,
- Iort,
- SmmuV3Offset,
- SmmuV3NodeList,
- SmmuV3NodeCount
- );
+ This, Iort, SmmuV3Offset, NodeList, SmmuV3NodeCount);
+ FreePool (NodeList);
if (EFI_ERROR (Status)) {
DEBUG ((
DEBUG_ERROR,
@@ -2053,14 +1591,9 @@ BuildIortTable (
}

if (PmcgNodeCount > 0) {
- Status = AddPmcgNodes (
- This,
- CfgMgrProtocol,
- Iort,
- PmcgOffset,
- PmcgNodeList,
- PmcgNodeCount
- );
+ CfgMgrGetSimpleObject(EArmObjPmcg, &NodeList);
+ Status = AddPmcgNodes (This, Iort, PmcgOffset, NodeList, PmcgNodeCount);
+ FreePool (NodeList);
if (EFI_ERROR (Status)) {
DEBUG ((
DEBUG_ERROR,
@@ -2071,6 +1604,8 @@ BuildIortTable (
}
}

+ *Table = (EFI_ACPI_DESCRIPTION_HEADER*) Iort;
+
return EFI_SUCCESS;

error_handler:
@@ -2078,11 +1613,10 @@ error_handler:
FreePool (Generator->NodeIndexer);
Generator->NodeIndexer = NULL;
}
-
- if (*Table != NULL) {
- FreePool (*Table);
- *Table = NULL;
+ if (Iort != NULL) {
+ FreePool (Iort);
}
+
return Status;
}

diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiMadtLibArm/MadtGenerator.c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiMadtLibArm/MadtGenerator.c
index ab42c96b06..0d75a24724 100644
--- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiMadtLibArm/MadtGenerator.c
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiMadtLibArm/MadtGenerator.c
@@ -17,7 +17,6 @@
// Module specific include files.
#include <AcpiTableGenerator.h>
#include <ConfigurationManagerObject.h>
-#include <ConfigurationManagerHelper.h>
#include <Library/TableHelperLib.h>
#include <Protocol/ConfigurationManagerProtocol.h>

@@ -33,54 +32,6 @@ Requirements:
- 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
- Distributor Information from the Configuration Manager.
-*/
-
-GET_OBJECT_LIST (
- EObjNameSpaceArm,
- EArmObjGicDInfo,
- CM_ARM_GICD_INFO
- );
-
-/** This macro expands to a function that retrieves the GIC
- MSI Frame Information from the Configuration Manager.
-*/
-GET_OBJECT_LIST (
- EObjNameSpaceArm,
- EArmObjGicMsiFrameInfo,
- CM_ARM_GIC_MSI_FRAME_INFO
- );
-
-/** This macro expands to a function that retrieves the GIC
- Redistributor Information from the Configuration Manager.
-*/
-
-GET_OBJECT_LIST (
- EObjNameSpaceArm,
- EArmObjGicRedistributorInfo,
- CM_ARM_GIC_REDIST_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 function updates the GIC CPU Interface Information in the
EFI_ACPI_6_3_GIC_STRUCTURE structure.

@@ -215,15 +166,21 @@ STATIC
EFI_STATUS
AddGICCList (
IN EFI_ACPI_6_3_GIC_STRUCTURE * Gicc,
- IN CONST CM_ARM_GICC_INFO * GicCInfo,
- IN UINT32 GicCCount,
IN CONST UINT8 MadtRev
)
{
BOOLEAN IsAcpiProcUidDuplicated;
+ CM_ARM_GICC_INFO *Cursor;
+ VOID *GicCInfo;
+ UINT32 GicCCount;

ASSERT (Gicc != NULL);
- ASSERT (GicCInfo != NULL);
+
+ EFI_STATUS Status =
+ CfgMgrGetObjects (EArmObjGicCInfo, CM_NULL_TOKEN, &GicCInfo, &GicCCount);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }

IsAcpiProcUidDuplicated = FindDuplicateValue (
GicCInfo,
@@ -234,31 +191,40 @@ AddGICCList (
// Duplicate ACPI Processor UID was found so the GICC info provided
// is invalid
if (IsAcpiProcUidDuplicated) {
+ FreePool (GicCInfo);
return EFI_INVALID_PARAMETER;
}

+ Cursor = GicCInfo;
while (GicCCount-- != 0) {
- AddGICC (Gicc++, GicCInfo++, MadtRev);
+ AddGICC (Gicc++, Cursor++, MadtRev);
}

+ FreePool (GicCInfo);
return EFI_SUCCESS;
}

/** Update the GIC Distributor Information in the MADT Table.

@param [in] Gicd Pointer to GIC Distributor structure.
- @param [in] GicDInfo Pointer to the GIC Distributor Information.
**/
STATIC
VOID
AddGICD (
- EFI_ACPI_6_3_GIC_DISTRIBUTOR_STRUCTURE * CONST Gicd,
- CONST CM_ARM_GICD_INFO * CONST GicDInfo
-)
+ EFI_ACPI_6_3_GIC_DISTRIBUTOR_STRUCTURE * CONST Gicd
+ )
{
+ EFI_STATUS Status;
+ CM_ARM_GICD_INFO *GicDInfo;
+
ASSERT (Gicd != NULL);
ASSERT (GicDInfo != NULL);

+ Status = CfgMgrGetSimpleObject (EArmObjGicDInfo, (VOID **)&GicDInfo);
+ if (EFI_ERROR (Status)) {
+ return;
+ }
+
// UINT8 Type
Gicd->Type = EFI_ACPI_6_3_GICD;
// UINT8 Length
@@ -279,6 +245,8 @@ AddGICD (
Gicd->Reserved2[0] = EFI_ACPI_RESERVED_BYTE;
Gicd->Reserved2[1] = EFI_ACPI_RESERVED_BYTE;
Gicd->Reserved2[2] = EFI_ACPI_RESERVED_BYTE;
+
+ FreePool (GicDInfo);
}

/** Update the GIC MSI Frame Information.
@@ -310,23 +278,32 @@ AddGICMsiFrame (
/** Add the GIC MSI Frame Information to the MADT Table.

@param [in] GicMsiFrame Pointer to GIC MSI Frame structure list.
- @param [in] GicMsiFrameInfo Pointer to the GIC MSI Frame info list.
- @param [in] GicMsiFrameCount Count of GIC MSI Frames.
**/
STATIC
VOID
AddGICMsiFrameInfoList (
- IN EFI_ACPI_6_3_GIC_MSI_FRAME_STRUCTURE * GicMsiFrame,
- IN CONST CM_ARM_GIC_MSI_FRAME_INFO * GicMsiFrameInfo,
- IN UINT32 GicMsiFrameCount
-)
+ IN EFI_ACPI_6_3_GIC_MSI_FRAME_STRUCTURE * GicMsiFrame
+ )
{
+ EFI_STATUS Status;
+ VOID *GicMsiInfo;
+ CM_ARM_GIC_MSI_FRAME_INFO *Cursor;
+ UINT32 GicMsiCount;
+
ASSERT (GicMsiFrame != NULL);
- ASSERT (GicMsiFrameInfo != NULL);

- while (GicMsiFrameCount-- != 0) {
- AddGICMsiFrame (GicMsiFrame++, GicMsiFrameInfo++);
+ Status = CfgMgrGetObjects (
+ EArmObjGicMsiFrameInfo, CM_NULL_TOKEN, &GicMsiInfo, &GicMsiCount);
+ if (EFI_ERROR(Status)) {
+ return;
+ }
+
+ Cursor = GicMsiInfo;
+ while (GicMsiCount-- != 0) {
+ AddGICMsiFrame (GicMsiFrame++, Cursor++);
}
+
+ FreePool (GicMsiInfo);
}

/** Update the GIC Redistributor Information.
@@ -355,23 +332,32 @@ AddGICRedistributor (
/** Add the GIC Redistributor Information to the MADT Table.

@param [in] Gicr Pointer to GIC Redistributor structure list.
- @param [in] GicRInfo Pointer to the GIC Distributor info list.
- @param [in] GicRCount Count of GIC Distributors.
**/
STATIC
VOID
AddGICRedistributorList (
- IN EFI_ACPI_6_3_GICR_STRUCTURE * Gicr,
- IN CONST CM_ARM_GIC_REDIST_INFO * GicRInfo,
- IN UINT32 GicRCount
+ IN EFI_ACPI_6_3_GICR_STRUCTURE * Gicr
)
{
+ CM_ARM_GIC_REDIST_INFO *Cursor;
+ VOID *GicRInfo;
+ UINT32 GicRCount;
+ EFI_STATUS Status;
+
ASSERT (Gicr != NULL);
- ASSERT (GicRInfo != NULL);

+ Status = CfgMgrGetObjects (
+ EArmObjGicRedistributorInfo, CM_NULL_TOKEN, &GicRInfo, &GicRCount);
+ if (EFI_ERROR (Status)) {
+ return;
+ }
+
+ Cursor = GicRInfo;
while (GicRCount-- != 0) {
- AddGICRedistributor (Gicr++, GicRInfo++);
+ AddGICRedistributor (Gicr++, Cursor++);
}
+
+ FreePool (GicRInfo);
}

/** Update the GIC Interrupt Translation Service Information
@@ -401,23 +387,32 @@ AddGICInterruptTranslationService (
to the MADT Table.

@param [in] GicIts Pointer to GIC ITS structure list.
- @param [in] GicItsInfo Pointer to the GIC ITS list.
- @param [in] GicItsCount Count of GIC ITS.
**/
STATIC
VOID
AddGICItsList (
- IN EFI_ACPI_6_3_GIC_ITS_STRUCTURE * GicIts,
- IN CONST CM_ARM_GIC_ITS_INFO * GicItsInfo,
- IN UINT32 GicItsCount
+ IN EFI_ACPI_6_3_GIC_ITS_STRUCTURE * GicIts
)
{
+ CM_ARM_GIC_ITS_INFO *Cursor;
+ VOID *GicItsInfo;
+ UINT32 GicItsCount;
+ EFI_STATUS Status;
+
ASSERT (GicIts != NULL);
- ASSERT (GicItsInfo != NULL);

+ Status = CfgMgrGetObjects (
+ EArmObjGicItsInfo, CM_NULL_TOKEN, &GicItsInfo, &GicItsCount);
+ if (EFI_ERROR(Status)) {
+ return;
+ }
+
+ Cursor = GicItsInfo;
while (GicItsCount-- != 0) {
- AddGICInterruptTranslationService (GicIts++, GicItsInfo++);
+ AddGICInterruptTranslationService (GicIts++, Cursor++);
}
+
+ FreePool (GicItsInfo);
}

/** Construct the MADT ACPI table.
@@ -454,16 +449,13 @@ BuildMadtTable (
{
EFI_STATUS Status;
UINT32 TableSize;
+
UINT32 GicCCount;
UINT32 GicDCount;
UINT32 GicMSICount;
UINT32 GicRedistCount;
UINT32 GicItsCount;
- CM_ARM_GICC_INFO * GicCInfo;
- CM_ARM_GICD_INFO * GicDInfo;
- CM_ARM_GIC_MSI_FRAME_INFO * GicMSIInfo;
- CM_ARM_GIC_REDIST_INFO * GicRedistInfo;
- CM_ARM_GIC_ITS_INFO * GicItsInfo;
+
UINT32 GicCOffset;
UINT32 GicDOffset;
UINT32 GicMSIOffset;
@@ -474,7 +466,6 @@ BuildMadtTable (

ASSERT (This != NULL);
ASSERT (AcpiTableInfo != NULL);
- ASSERT (CfgMgrProtocol != NULL);
ASSERT (Table != NULL);
ASSERT (AcpiTableInfo->TableGeneratorId == This->GeneratorID);
ASSERT (AcpiTableInfo->AcpiTableSignature == This->AcpiTableSignature);
@@ -492,21 +483,12 @@ BuildMadtTable (
return EFI_INVALID_PARAMETER;
}

+ // Allocated memory pointers
*Table = NULL;

- Status = GetEArmObjGicCInfo (
- CfgMgrProtocol,
- CM_NULL_TOKEN,
- &GicCInfo,
- &GicCCount
- );
- if (EFI_ERROR (Status)) {
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: MADT: Failed to get GICC Info. Status = %r\n",
- Status
- ));
- goto error_handler;
+ Status = CfgMgrCountObjects (EArmObjGicCInfo, &GicCCount);
+ if (EFI_ERROR(Status)) {
+ return Status;
}

if (GicCCount == 0) {
@@ -515,23 +497,12 @@ BuildMadtTable (
"ERROR: MADT: GIC CPU Interface information not provided.\n"
));
ASSERT (GicCCount != 0);
- Status = EFI_INVALID_PARAMETER;
- goto error_handler;
+ return EFI_INVALID_PARAMETER;
}

- Status = GetEArmObjGicDInfo (
- CfgMgrProtocol,
- CM_NULL_TOKEN,
- &GicDInfo,
- &GicDCount
- );
+ Status = CfgMgrCountObjects (EArmObjGicDInfo, &GicDCount);
if (EFI_ERROR (Status)) {
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: MADT: Failed to get GICD Info. Status = %r\n",
- Status
- ));
- goto error_handler;
+ return Status;
}

if (GicDCount == 0) {
@@ -540,8 +511,7 @@ BuildMadtTable (
"ERROR: MADT: GIC Distributor information not provided.\n"
));
ASSERT (GicDCount != 0);
- Status = EFI_INVALID_PARAMETER;
- goto error_handler;
+ return EFI_INVALID_PARAMETER;
}

if (GicDCount > 1) {
@@ -552,53 +522,22 @@ BuildMadtTable (
GicDCount
));
ASSERT (GicDCount <= 1);
- Status = EFI_INVALID_PARAMETER;
- goto error_handler;
+ return EFI_INVALID_PARAMETER;
}

- Status = GetEArmObjGicMsiFrameInfo (
- CfgMgrProtocol,
- CM_NULL_TOKEN,
- &GicMSIInfo,
- &GicMSICount
- );
+ Status = CfgMgrCountObjects (EArmObjGicMsiFrameInfo, &GicMSICount);
if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: MADT: Failed to get GIC MSI Info. Status = %r\n",
- Status
- ));
- goto error_handler;
+ return Status;
}

- Status = GetEArmObjGicRedistributorInfo (
- CfgMgrProtocol,
- CM_NULL_TOKEN,
- &GicRedistInfo,
- &GicRedistCount
- );
+ Status = CfgMgrCountObjects (EArmObjGicRedistributorInfo, &GicRedistCount);
if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: MADT: Failed to get GIC Redistributor Info. Status = %r\n",
- Status
- ));
- goto error_handler;
+ return Status;
}

- Status = GetEArmObjGicItsInfo (
- CfgMgrProtocol,
- CM_NULL_TOKEN,
- &GicItsInfo,
- &GicItsCount
- );
+ Status = CfgMgrCountObjects (EArmObjGicItsInfo, &GicItsCount);
if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: MADT: Failed to get GIC ITS Info. Status = %r\n",
- Status
- ));
- goto error_handler;
+ return Status;
}

TableSize = sizeof (EFI_ACPI_6_3_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER);
@@ -619,21 +558,11 @@ BuildMadtTable (
TableSize += (sizeof (EFI_ACPI_6_3_GIC_ITS_STRUCTURE) * GicItsCount);

// Allocate the Buffer for MADT table
- *Table = (EFI_ACPI_DESCRIPTION_HEADER*)AllocateZeroPool (TableSize);
- if (*Table == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: MADT: Failed to allocate memory for MADT Table, Size = %d," \
- " Status = %r\n",
- TableSize,
- Status
- ));
- goto error_handler;
+ Madt = AllocateZeroPool (TableSize);
+ if (Madt == NULL) {
+ return EFI_OUT_OF_RESOURCES;
}

- Madt = (EFI_ACPI_6_3_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER*)*Table;
-
DEBUG ((
DEBUG_INFO,
"MADT: Madt = 0x%p TableSize = 0x%x\n",
@@ -643,20 +572,13 @@ BuildMadtTable (

Status = AddAcpiHeader (This, &Madt->Header, AcpiTableInfo, TableSize);
if (EFI_ERROR (Status)) {
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: MADT: Failed to add ACPI header. Status = %r\n",
- Status
- ));
goto error_handler;
}

Status = AddGICCList (
- (EFI_ACPI_6_3_GIC_STRUCTURE*)((UINT8*)Madt + GicCOffset),
- GicCInfo,
- GicCCount,
- Madt->Header.Revision
- );
+ (EFI_ACPI_6_3_GIC_STRUCTURE *)((UINT8 *)Madt + GicCOffset),
+ Madt->Header.Revision);
+
if (EFI_ERROR (Status)) {
DEBUG ((
DEBUG_ERROR,
@@ -666,42 +588,25 @@ BuildMadtTable (
goto error_handler;
}

- AddGICD (
- (EFI_ACPI_6_3_GIC_DISTRIBUTOR_STRUCTURE*)((UINT8*)Madt + GicDOffset),
- GicDInfo
- );
+ AddGICD ((VOID *)((UINT8 *)Madt + GicDOffset));

if (GicMSICount != 0) {
- AddGICMsiFrameInfoList (
- (EFI_ACPI_6_3_GIC_MSI_FRAME_STRUCTURE*)((UINT8*)Madt + GicMSIOffset),
- GicMSIInfo,
- GicMSICount
- );
+ AddGICMsiFrameInfoList ((VOID *)((UINT8 *)Madt + GicMSIOffset));
}

if (GicRedistCount != 0) {
- AddGICRedistributorList (
- (EFI_ACPI_6_3_GICR_STRUCTURE*)((UINT8*)Madt + GicRedistOffset),
- GicRedistInfo,
- GicRedistCount
- );
+ AddGICRedistributorList ((VOID *)((UINT8 *)Madt + GicRedistOffset));
}

if (GicItsCount != 0) {
- AddGICItsList (
- (EFI_ACPI_6_3_GIC_ITS_STRUCTURE*)((UINT8*)Madt + GicItsOffset),
- GicItsInfo,
- GicItsCount
- );
+ AddGICItsList ((VOID *)((UINT8 *)Madt + GicItsOffset));
}

+ *Table = (EFI_ACPI_DESCRIPTION_HEADER*)Madt;
return EFI_SUCCESS;

error_handler:
- if (*Table != NULL) {
- FreePool (*Table);
- *Table = NULL;
- }
+ FreePool (Madt);
return Status;
}

@@ -727,7 +632,6 @@ FreeMadtTableResources (
{
ASSERT (This != NULL);
ASSERT (AcpiTableInfo != NULL);
- ASSERT (CfgMgrProtocol != NULL);
ASSERT (AcpiTableInfo->TableGeneratorId == This->GeneratorID);
ASSERT (AcpiTableInfo->AcpiTableSignature == This->AcpiTableSignature);

diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiMcfgLibArm/McfgGenerator.c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiMcfgLibArm/McfgGenerator.c
index a486e2297a..0283ea11f5 100644
--- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiMcfgLibArm/McfgGenerator.c
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiMcfgLibArm/McfgGenerator.c
@@ -18,7 +18,6 @@
// Module specific include files.
#include <AcpiTableGenerator.h>
#include <ConfigurationManagerObject.h>
-#include <ConfigurationManagerHelper.h>
#include <Library/TableHelperLib.h>
#include <Protocol/ConfigurationManagerProtocol.h>

@@ -48,50 +47,52 @@ typedef

#pragma pack()

-/** Retrieve the PCI Configuration Space Information.
-*/
-GET_OBJECT_LIST (
- EObjNameSpaceArm,
- EArmObjPciConfigSpaceInfo,
- CM_ARM_PCI_CONFIG_SPACE_INFO
- );
-
/** Add the PCI Enhanced Configuration Space Information to the MCFG Table.

@param [in] Mcfg Pointer to MCFG Table.
@param [in] PciCfgSpaceOffset Offset for the PCI Configuration Space
Info structure in the MCFG Table.
- @param [in] PciCfgSpaceInfoList Pointer to the PCI Configuration Space
- Info List.
- @param [in] PciCfgSpaceCount Count of PCI Configuration Space Info.
**/
STATIC
VOID
AddPciConfigurationSpaceList (
IN MCFG_TABLE * CONST Mcfg,
- IN CONST UINT32 PciCfgSpaceOffset,
- IN CONST CM_ARM_PCI_CONFIG_SPACE_INFO * PciCfgSpaceInfoList,
- IN UINT32 PciCfgSpaceCount
+ IN CONST UINT32 PciCfgSpaceOffset
)
{
- MCFG_CFG_SPACE_ADDR * PciCfgSpace;
+ MCFG_CFG_SPACE_ADDR *PciCfgSpace;
+ CM_ARM_PCI_CONFIG_SPACE_INFO *Cursor;
+ VOID *PciCfgSpaceInfoList;
+ UINT32 PciCfgSpaceCount;
+ EFI_STATUS Status;

ASSERT (Mcfg != NULL);
- ASSERT (PciCfgSpaceInfoList != NULL);
+
+ Status = CfgMgrGetObjects (
+ EArmObjPciConfigSpaceInfo,
+ CM_NULL_TOKEN,
+ &PciCfgSpaceInfoList,
+ &PciCfgSpaceCount);
+ if (EFI_ERROR (Status)) {
+ return;
+ }

PciCfgSpace = (MCFG_CFG_SPACE_ADDR *)((UINT8*)Mcfg + PciCfgSpaceOffset);

+ Cursor = PciCfgSpaceInfoList;
while (PciCfgSpaceCount-- != 0) {
// Add PCI Configuration Space entry
- PciCfgSpace->BaseAddress = PciCfgSpaceInfoList->BaseAddress;
+ PciCfgSpace->BaseAddress = Cursor->BaseAddress;
PciCfgSpace->PciSegmentGroupNumber =
- PciCfgSpaceInfoList->PciSegmentGroupNumber;
- PciCfgSpace->StartBusNumber = PciCfgSpaceInfoList->StartBusNumber;
- PciCfgSpace->EndBusNumber = PciCfgSpaceInfoList->EndBusNumber;
+ Cursor->PciSegmentGroupNumber;
+ PciCfgSpace->StartBusNumber = Cursor->StartBusNumber;
+ PciCfgSpace->EndBusNumber = Cursor->EndBusNumber;
PciCfgSpace->Reserved = EFI_ACPI_RESERVED_DWORD;
PciCfgSpace++;
- PciCfgSpaceInfoList++;
+ Cursor++;
}
+
+ FreePool (PciCfgSpaceInfoList);
}

/** Construct the MCFG ACPI table.
@@ -152,20 +153,14 @@ BuildMcfgTable (
return EFI_INVALID_PARAMETER;
}

+ // Pointers to allocated memory
*Table = NULL;
- Status = GetEArmObjPciConfigSpaceInfo (
- CfgMgrProtocol,
- CM_NULL_TOKEN,
- &PciConfigSpaceInfoList,
- &ConfigurationSpaceCount
- );
+ PciConfigSpaceInfoList = NULL;
+
+ Status =
+ CfgMgrCountObjects (EArmObjPciConfigSpaceInfo, &ConfigurationSpaceCount);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR,
- "ERROR: MCFG: Failed to get PCI Configuration Space Information." \
- " Status = %r\n",
- Status
- ));
- goto error_handler;
+ return Status;
}

if (ConfigurationSpaceCount == 0) {
@@ -174,9 +169,8 @@ BuildMcfgTable (
"ERROR: MCFG: Configuration Space Count = %d\n",
ConfigurationSpaceCount
));
- Status = EFI_INVALID_PARAMETER;
ASSERT (ConfigurationSpaceCount != 0);
- goto error_handler;
+ return EFI_INVALID_PARAMETER;
}

DEBUG ((
@@ -189,20 +183,11 @@ BuildMcfgTable (
TableSize = sizeof (MCFG_TABLE) +
((sizeof (MCFG_CFG_SPACE_ADDR) * ConfigurationSpaceCount));

- *Table = (EFI_ACPI_DESCRIPTION_HEADER*)AllocateZeroPool (TableSize);
- if (*Table == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: MCFG: Failed to allocate memory for MCFG Table, Size = %d," \
- " Status = %r\n",
- TableSize,
- Status
- ));
- goto error_handler;
+ Mcfg = AllocateZeroPool (TableSize);
+ if (Mcfg == NULL) {
+ return EFI_OUT_OF_RESOURCES;
}

- Mcfg = (MCFG_TABLE*)*Table;
DEBUG ((
DEBUG_INFO,
"MCFG: Mcfg = 0x%p TableSize = 0x%x\n",
@@ -212,30 +197,19 @@ BuildMcfgTable (

Status = AddAcpiHeader (This, &Mcfg->Header, AcpiTableInfo, TableSize);
if (EFI_ERROR (Status)) {
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: MCFG: Failed to add ACPI header. Status = %r\n",
- Status
- ));
goto error_handler;
}

Mcfg->Reserved = EFI_ACPI_RESERVED_QWORD;

- AddPciConfigurationSpaceList (
- Mcfg,
- sizeof (MCFG_TABLE),
- PciConfigSpaceInfoList,
- ConfigurationSpaceCount
- );
+ AddPciConfigurationSpaceList (Mcfg, sizeof (MCFG_TABLE));
+
+ *Table = (EFI_ACPI_DESCRIPTION_HEADER*) Mcfg;

return EFI_SUCCESS;

error_handler:
- if (*Table != NULL) {
- FreePool (*Table);
- *Table = NULL;
- }
+ FreePool (Mcfg);
return Status;
}

diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiPpttLibArm/PpttGenerator.c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiPpttLibArm/PpttGenerator.c
index 99eb6e0929..0722b469f0 100644
--- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiPpttLibArm/PpttGenerator.c
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiPpttLibArm/PpttGenerator.c
@@ -21,7 +21,6 @@
// Module specific include files.
#include <AcpiTableGenerator.h>
#include <ConfigurationManagerObject.h>
-#include <ConfigurationManagerHelper.h>
#include <Library/TableHelperLib.h>
#include <Protocol/ConfigurationManagerProtocol.h>

@@ -39,56 +38,6 @@
- EArmObjGicCInfo (REQUIRED)
*/

-/**
- This macro expands to a function that retrieves the Processor Hierarchy
- information from the Configuration Manager.
-*/
-GET_OBJECT_LIST (
- EObjNameSpaceArm,
- EArmObjProcHierarchyInfo,
- CM_ARM_PROC_HIERARCHY_INFO
- );
-
-/**
- This macro expands to a function that retrieves the cache information
- from the Configuration Manager.
-*/
-GET_OBJECT_LIST (
- EObjNameSpaceArm,
- EArmObjCacheInfo,
- CM_ARM_CACHE_INFO
- );
-
-/**
- This macro expands to a function that retrieves the ID information for
- Processor Hierarchy Nodes from the Configuration Manager.
-*/
-GET_OBJECT_LIST (
- EObjNameSpaceArm,
- EArmObjProcNodeIdInfo,
- CM_ARM_PROC_NODE_ID_INFO
- );
-
-/**
- This macro expands to a function that retrieves the cross-CM-object-
- reference information from the Configuration Manager.
-*/
-GET_OBJECT_LIST (
- EObjNameSpaceArm,
- EArmObjCmRef,
- CM_ARM_OBJ_REF
- );
-
-/**
- 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
- );
-
/**
Returns the size of the PPTT Processor Hierarchy Node (Type 0) given a
Processor Hierarchy Info CM object.
@@ -279,8 +228,6 @@ DetectCyclesInTopology (
Update the array of private resources for a given Processor Hierarchy Node.

@param [in] Generator Pointer to the PPTT Generator.
- @param [in] CfgMgrProtocol Pointer to the Configuration Manager
- Protocol Interface.
@param [in] PrivResArray Pointer to the array of private resources.
@param [in] PrivResCount Number of private resources.
@param [in] PrivResArrayToken Reference Token for the CM_ARM_OBJ_REF
@@ -294,20 +241,19 @@ STATIC
EFI_STATUS
AddPrivateResources (
IN CONST ACPI_PPTT_GENERATOR * CONST Generator,
- IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol,
IN UINT32 * PrivResArray,
IN UINT32 PrivResCount,
IN CONST CM_OBJECT_TOKEN PrivResArrayToken
)
{
EFI_STATUS Status;
- CM_ARM_OBJ_REF * CmObjRefs;
+ CM_ARM_OBJ_REF * Cursor;
+ VOID * CmObjRefs;
UINT32 CmObjRefCount;
PPTT_NODE_INDEXER * PpttNodeFound;

ASSERT (
(Generator != NULL) &&
- (CfgMgrProtocol != NULL) &&
(PrivResArray != NULL) &&
(PrivResCount != 0)
);
@@ -327,12 +273,8 @@ AddPrivateResources (

CmObjRefCount = 0;
// Get the CM Object References
- Status = GetEArmObjCmRef (
- CfgMgrProtocol,
- PrivResArrayToken,
- &CmObjRefs,
- &CmObjRefCount
- );
+ Status = CfgMgrGetObjects (
+ EArmObjCmRef, PrivResArrayToken, (VOID **)&CmObjRefs, &CmObjRefCount);
if (EFI_ERROR (Status)) {
DEBUG ((
DEBUG_ERROR,
@@ -356,11 +298,12 @@ AddPrivateResources (
PrivResArrayToken,
Status
));
- return Status;
+ goto EXIT;
}

+ Cursor = CmObjRefs;
while (PrivResCount-- != 0) {
- if (CmObjRefs->ReferenceToken == CM_NULL_TOKEN) {
+ if (Cursor->ReferenceToken == CM_NULL_TOKEN) {
Status = EFI_INVALID_PARAMETER;
DEBUG ((
DEBUG_ERROR,
@@ -368,7 +311,7 @@ AddPrivateResources (
"private resource. Status = %r\n",
Status
));
- return Status;
+ goto EXIT;
}

// The Node indexer has the Processor hierarchy nodes at the begining
@@ -378,7 +321,7 @@ AddPrivateResources (
Generator->CacheStructIndexedList,
(Generator->ProcTopologyStructCount -
Generator->ProcHierarchyNodeCount),
- CmObjRefs->ReferenceToken,
+ Cursor->ReferenceToken,
&PpttNodeFound
);
if (EFI_ERROR (Status)) {
@@ -386,19 +329,21 @@ AddPrivateResources (
DEBUG_ERROR,
"ERROR: PPTT: Failed to get a private resource with Token = %p from " \
"Node Indexer. Status = %r\n",
- CmObjRefs->ReferenceToken,
+ Cursor->ReferenceToken,
Status
));
- return Status;
+ goto EXIT;
}

// Update the offset of the private resources in the Processor
// Hierarchy Node structure
*(PrivResArray++) = PpttNodeFound->Offset;
- CmObjRefs++;
+ Cursor++;
}

- return EFI_SUCCESS;
+EXIT:
+ FreePool (CmObjRefs);
+ return Status;
}

/**
@@ -485,7 +430,6 @@ STATIC
EFI_STATUS
AddProcHierarchyNodes (
IN CONST ACPI_PPTT_GENERATOR * CONST Generator,
- IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol,
IN CONST EFI_ACPI_6_3_PROCESSOR_PROPERTIES_TOPOLOGY_TABLE_HEADER * Pptt,
IN CONST UINT32 NodesStartOffset
)
@@ -508,7 +452,6 @@ AddProcHierarchyNodes (

ASSERT (
(Generator != NULL) &&
- (CfgMgrProtocol != NULL) &&
(Pptt != NULL)
);

@@ -533,6 +476,9 @@ AddProcHierarchyNodes (

UniqueGicCRefCount = 0;

+ // Pointers to allocated memory
+ GicCInfoList = NULL;
+
while (NodeCount-- != 0) {
ProcInfoNode = (CM_ARM_PROC_HIERARCHY_INFO*)ProcNodeIterator->Object;

@@ -632,12 +578,11 @@ AddProcHierarchyNodes (
));
return Status;
} else {
- Status = GetEArmObjGicCInfo (
- CfgMgrProtocol,
- ProcInfoNode->GicCToken,
- &GicCInfoList,
- &GicCInfoCount
- );
+ Status = CfgMgrGetObjects (
+ EArmObjGicCInfo,
+ ProcInfoNode->GicCToken,
+ (VOID **)&GicCInfoList,
+ &GicCInfoCount);
if (EFI_ERROR (Status)) {
DEBUG ((
DEBUG_ERROR,
@@ -664,6 +609,7 @@ AddProcHierarchyNodes (
ProcInfoNode->Token,
Status
));
+ FreePool (GicCInfoList);
return Status;
}

@@ -673,6 +619,7 @@ AddProcHierarchyNodes (
// Increment the reference count for the number of
// Unique GICC objects that were retrieved.
UniqueGicCRefCount++;
+ FreePool (GicCInfoList);
}

ProcStruct->NumberOfPrivateResources = ProcInfoNode->NoOfPrivateResources;
@@ -683,7 +630,6 @@ AddProcHierarchyNodes (
// Populate the private resources array
Status = AddPrivateResources (
Generator,
- CfgMgrProtocol,
PrivateResources,
ProcStruct->NumberOfPrivateResources,
ProcInfoNode->PrivateResourcesArrayToken
@@ -707,18 +653,8 @@ AddProcHierarchyNodes (

// Knowing the total number of GICC references made and that all GICC Token
// references are unique, we can test if no GICC instances have been left out.
- Status = GetEArmObjGicCInfo (
- CfgMgrProtocol,
- CM_NULL_TOKEN,
- &GicCInfoList,
- &GicCInfoCount
- );
+ Status = CfgMgrCountObjects (EArmObjGicCInfo, &GicCInfoCount);
if (EFI_ERROR (Status)) {
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: PPTT: Failed to get GICC Info. Status = %r\n",
- Status
- ));
return Status;
}

@@ -749,8 +685,6 @@ AddProcHierarchyNodes (
the Configuration Manager and adds this information to the PPTT table.

@param [in] Generator Pointer to the PPTT Generator.
- @param [in] CfgMgrProtocol Pointer to the Configuration Manager
- Protocol Interface.
@param [in] Pptt Pointer to PPTT table structure.
@param [in] NodesStartOffset Offset from the start of PPTT table to the
start of Cache Type Structures.
@@ -763,7 +697,6 @@ STATIC
EFI_STATUS
AddCacheTypeStructures (
IN CONST ACPI_PPTT_GENERATOR * CONST Generator,
- IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol,
IN CONST EFI_ACPI_6_3_PROCESSOR_PROPERTIES_TOPOLOGY_TABLE_HEADER * Pptt,
IN CONST UINT32 NodesStartOffset
)
@@ -775,11 +708,8 @@ AddCacheTypeStructures (
PPTT_NODE_INDEXER * CacheNodeIterator;
UINT32 NodeCount;

- ASSERT (
- (Generator != NULL) &&
- (CfgMgrProtocol != NULL) &&
- (Pptt != NULL)
- );
+ ASSERT (Generator != NULL);
+ ASSERT (Pptt != NULL);

CacheStruct = (EFI_ACPI_6_3_PPTT_STRUCTURE_CACHE*)((UINT8*)Pptt +
NodesStartOffset);
@@ -971,8 +901,6 @@ AddCacheTypeStructures (
the Configuration Manager and and adds this information to the PPTT table.

@param [in] Generator Pointer to the PPTT Generator.
- @param [in] CfgMgrProtocol Pointer to the Configuration Manager
- Protocol Interface.
@param [in] Pptt Pointer to PPTT table structure.
@param [in] NodesStartOffset Offset from the start of PPTT table to the
start of ID Type Structures.
@@ -985,7 +913,6 @@ STATIC
EFI_STATUS
AddIdTypeStructures (
IN CONST ACPI_PPTT_GENERATOR * CONST Generator,
- IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol,
IN CONST EFI_ACPI_6_3_PROCESSOR_PROPERTIES_TOPOLOGY_TABLE_HEADER * Pptt,
IN CONST UINT32 NodesStartOffset
)
@@ -998,7 +925,6 @@ AddIdTypeStructures (

ASSERT (
(Generator != NULL) &&
- (CfgMgrProtocol != NULL) &&
(Pptt != NULL)
);

@@ -1074,10 +1000,7 @@ BuildPpttTable (
UINT32 CacheStructOffset;
UINT32 IdStructOffset;

- CM_ARM_PROC_HIERARCHY_INFO * ProcHierarchyNodeList;
- CM_ARM_CACHE_INFO * CacheStructList;
- CM_ARM_PROC_NODE_ID_INFO * IdStructList;
-
+ VOID * NodeList;
ACPI_PPTT_GENERATOR * Generator;

// Pointer to the Node Indexer array
@@ -1088,7 +1011,6 @@ BuildPpttTable (
ASSERT (
(This != NULL) &&
(AcpiTableInfo != NULL) &&
- (CfgMgrProtocol != NULL) &&
(Table != NULL) &&
(AcpiTableInfo->TableGeneratorId == This->GeneratorID) &&
(AcpiTableInfo->AcpiTableSignature == This->AcpiTableSignature)
@@ -1108,23 +1030,12 @@ BuildPpttTable (
}

Generator = (ACPI_PPTT_GENERATOR*)This;
- *Table = NULL;

// Get the processor hierarchy info and update the processor topology
// structure count with Processor Hierarchy Nodes (Type 0)
- Status = GetEArmObjProcHierarchyInfo (
- CfgMgrProtocol,
- CM_NULL_TOKEN,
- &ProcHierarchyNodeList,
- &ProcHierarchyNodeCount
- );
+ Status = CfgMgrCountObjects (EArmObjProcHierarchyInfo, &ProcHierarchyNodeCount);
if (EFI_ERROR (Status)) {
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: PPTT: Failed to get processor hierarchy info. Status = %r\n",
- Status
- ));
- goto error_handler;
+ return Status;
}

ProcTopologyStructCount = ProcHierarchyNodeCount;
@@ -1132,19 +1043,9 @@ BuildPpttTable (

// Get the cache info and update the processor topology structure count with
// Cache Type Structures (Type 1)
- Status = GetEArmObjCacheInfo (
- CfgMgrProtocol,
- CM_NULL_TOKEN,
- &CacheStructList,
- &CacheStructCount
- );
+ Status = CfgMgrCountObjects (EArmObjCacheInfo, &CacheStructCount);
if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: PPTT: Failed to get cache info. Status = %r\n",
- Status
- ));
- goto error_handler;
+ return Status;
}

ProcTopologyStructCount += CacheStructCount;
@@ -1152,38 +1053,18 @@ BuildPpttTable (

// Get the processor hierarchy node ID info and update the processor topology
// structure count with ID Structures (Type 2)
- Status = GetEArmObjProcNodeIdInfo (
- CfgMgrProtocol,
- CM_NULL_TOKEN,
- &IdStructList,
- &IdStructCount
- );
+ Status = CfgMgrCountObjects (EArmObjProcNodeIdInfo, &IdStructCount);
if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: PPTT: Failed to get processor hierarchy node ID info. " \
- "Status = %r\n",
- Status
- ));
- goto error_handler;
+ return Status;
}

ProcTopologyStructCount += IdStructCount;
Generator->IdStructCount = IdStructCount;

// Allocate Node Indexer array
- NodeIndexer = (PPTT_NODE_INDEXER*)AllocateZeroPool (
- sizeof (PPTT_NODE_INDEXER) *
- ProcTopologyStructCount
- );
+ NodeIndexer = AllocateZeroPool (sizeof (PPTT_NODE_INDEXER) * ProcTopologyStructCount);
if (NodeIndexer == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: PPTT: Failed to allocate memory for Node Indexer. Status = %r\n ",
- Status
- ));
- goto error_handler;
+ return EFI_OUT_OF_RESOURCES;
}

DEBUG ((DEBUG_INFO, "INFO: NodeIndexer = %p\n", NodeIndexer));
@@ -1197,12 +1078,14 @@ BuildPpttTable (
if (Generator->ProcHierarchyNodeCount != 0) {
ProcHierarchyNodeOffset = TableSize;
Generator->ProcHierarchyNodeIndexedList = NodeIndexer;
+
+ CfgMgrGetSimpleObject(EArmObjProcHierarchyInfo, &NodeList);
TableSize += GetSizeofProcHierarchyNodes (
- ProcHierarchyNodeOffset,
- ProcHierarchyNodeList,
- Generator->ProcHierarchyNodeCount,
- &NodeIndexer
- );
+ ProcHierarchyNodeOffset,
+ NodeList,
+ Generator->ProcHierarchyNodeCount,
+ &NodeIndexer);
+ FreePool (NodeList);

DEBUG ((
DEBUG_INFO,
@@ -1220,33 +1103,32 @@ BuildPpttTable (
if (Generator->CacheStructCount != 0) {
CacheStructOffset = TableSize;
Generator->CacheStructIndexedList = NodeIndexer;
+
+ CfgMgrGetSimpleObject(EArmObjCacheInfo, &NodeList);
TableSize += GetSizeofCacheTypeStructs (
- CacheStructOffset,
- CacheStructList,
- Generator->CacheStructCount,
- &NodeIndexer
- );
- DEBUG ((
- DEBUG_INFO,
- " CacheStructCount = %d\n" \
- " CacheStructOffset = 0x%x\n" \
- " CacheStructIndexedList = 0x%p\n",
- Generator->CacheStructCount,
- CacheStructOffset,
- Generator->CacheStructIndexedList
- ));
+ CacheStructOffset, NodeList, Generator->CacheStructCount, &NodeIndexer);
+ FreePool (NodeList);
+
+ DEBUG (
+ (DEBUG_INFO,
+ " CacheStructCount = %d\n"
+ " CacheStructOffset = 0x%x\n"
+ " CacheStructIndexedList = 0x%p\n",
+ Generator->CacheStructCount,
+ CacheStructOffset,
+ Generator->CacheStructIndexedList));
}

// Include the size of ID Type Structures and index them
if (Generator->IdStructCount != 0) {
IdStructOffset = TableSize;
Generator->IdStructIndexedList = NodeIndexer;
+
+ CfgMgrGetSimpleObject (EArmObjProcNodeIdInfo, &NodeList);
TableSize += GetSizeofIdStructs (
- IdStructOffset,
- IdStructList,
- Generator->IdStructCount,
- &NodeIndexer
- );
+ IdStructOffset, NodeList, Generator->IdStructCount, &NodeIndexer);
+ FreePool (NodeList);
+
DEBUG ((
DEBUG_INFO,
" IdStructCount = %d\n" \
@@ -1268,21 +1150,12 @@ BuildPpttTable (
));

// Allocate the Buffer for the PPTT table
- *Table = (EFI_ACPI_DESCRIPTION_HEADER*)AllocateZeroPool (TableSize);
- if (*Table == NULL) {
+ Pptt = AllocateZeroPool (TableSize);
+ if (Pptt == NULL) {
Status = EFI_OUT_OF_RESOURCES;
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: PPTT: Failed to allocate memory for PPTT Table. " \
- "Size = %d. Status = %r\n",
- TableSize,
- Status
- ));
goto error_handler;
}

- Pptt = (EFI_ACPI_6_3_PROCESSOR_PROPERTIES_TOPOLOGY_TABLE_HEADER*)*Table;
-
DEBUG ((
DEBUG_INFO,
"PPTT: Pptt = 0x%p. TableSize = 0x%x\n",
@@ -1293,22 +1166,12 @@ BuildPpttTable (
// Add ACPI header
Status = AddAcpiHeader (This, &Pptt->Header, AcpiTableInfo, TableSize);
if (EFI_ERROR (Status)) {
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: PPTT: Failed to add ACPI header. Status = %r\n",
- Status
- ));
goto error_handler;
}

// Add Processor Hierarchy Nodes (Type 0) to the generated table
if (Generator->ProcHierarchyNodeCount != 0) {
- Status = AddProcHierarchyNodes (
- Generator,
- CfgMgrProtocol,
- Pptt,
- ProcHierarchyNodeOffset
- );
+ Status = AddProcHierarchyNodes (Generator, Pptt, ProcHierarchyNodeOffset);
if (EFI_ERROR (Status)) {
DEBUG ((
DEBUG_ERROR,
@@ -1321,12 +1184,7 @@ BuildPpttTable (

// Add Cache Type Structures (Type 1) to the generated table
if (Generator->CacheStructCount != 0) {
- Status = AddCacheTypeStructures (
- Generator,
- CfgMgrProtocol,
- Pptt,
- CacheStructOffset
- );
+ Status = AddCacheTypeStructures (Generator, Pptt, CacheStructOffset);
if (EFI_ERROR (Status)) {
DEBUG ((
DEBUG_ERROR,
@@ -1339,12 +1197,7 @@ BuildPpttTable (

// Add ID Type Structures (Type 2) to the generated table
if (Generator->IdStructCount != 0) {
- Status = AddIdTypeStructures (
- Generator,
- CfgMgrProtocol,
- Pptt,
- IdStructOffset
- );
+ Status = AddIdTypeStructures (Generator, Pptt, IdStructOffset);
if (EFI_ERROR (Status)) {
DEBUG ((
DEBUG_ERROR,
@@ -1366,6 +1219,7 @@ BuildPpttTable (
goto error_handler;
}

+ *Table = (EFI_ACPI_DESCRIPTION_HEADER*)Pptt;
return Status;

error_handler:
@@ -1374,9 +1228,8 @@ error_handler:
Generator->NodeIndexer = NULL;
}

- if (*Table != NULL) {
- FreePool (*Table);
- *Table = NULL;
+ if (Pptt != NULL) {
+ FreePool (Pptt);
}

return Status;
diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiRawLibArm/RawGenerator.c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiRawLibArm/RawGenerator.c
index 2facfaa048..2a8e392d84 100644
--- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiRawLibArm/RawGenerator.c
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiRawLibArm/RawGenerator.c
@@ -12,7 +12,6 @@
// Module specific include files.
#include <AcpiTableGenerator.h>
#include <ConfigurationManagerObject.h>
-#include <ConfigurationManagerHelper.h>
#include <Library/TableHelperLib.h>
#include <Protocol/ConfigurationManagerProtocol.h>

diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/SpcrGenerator.c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/SpcrGenerator.c
index 46f53f819a..0a7e9da96e 100644
--- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/SpcrGenerator.c
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/SpcrGenerator.c
@@ -14,12 +14,12 @@
#include <IndustryStandard/SerialPortConsoleRedirectionTable.h>
#include <Library/AcpiLib.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>

@@ -83,15 +83,6 @@ EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE AcpiSpcr = {

#pragma pack()

-/** This macro expands to a function that retrieves the Serial
- Port Information from the Configuration Manager.
-*/
-GET_OBJECT_LIST (
- EObjNameSpaceArm,
- EArmObjSerialConsolePortInfo,
- CM_ARM_SERIAL_PORT_INFO
- )
-
/** Construct the SPCR ACPI table.

This function invokes the Configuration Manager protocol interface
@@ -131,7 +122,6 @@ BuildSpcrTable (

ASSERT (This != NULL);
ASSERT (AcpiTableInfo != NULL);
- ASSERT (CfgMgrProtocol != NULL);
ASSERT (Table != NULL);
ASSERT (AcpiTableInfo->TableGeneratorId == This->GeneratorID);
ASSERT (AcpiTableInfo->AcpiTableSignature == This->AcpiTableSignature);
@@ -149,21 +139,10 @@ BuildSpcrTable (
return EFI_INVALID_PARAMETER;
}

- *Table = NULL;
-
- Status = GetEArmObjSerialConsolePortInfo (
- CfgMgrProtocol,
- CM_NULL_TOKEN,
- &SerialPortInfo,
- NULL
- );
+ Status = CfgMgrGetSimpleObject (
+ EArmObjSerialConsolePortInfo, (VOID **)&SerialPortInfo);
if (EFI_ERROR (Status)) {
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: SPCR: Failed to get serial port information. Status = %r\n",
- Status
- ));
- goto error_handler;
+ return Status;
}

if (SerialPortInfo->BaseAddress == 0) {
@@ -207,11 +186,6 @@ BuildSpcrTable (
AcpiTableInfo,
sizeof (EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE));
if (EFI_ERROR (Status)) {
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: SPCR: Failed to add ACPI header. Status = %r\n",
- Status
- ));
goto error_handler;
}

@@ -268,6 +242,7 @@ BuildSpcrTable (
*Table = (EFI_ACPI_DESCRIPTION_HEADER*)&AcpiSpcr;

error_handler:
+ FreePool (SerialPortInfo);
return Status;
}

diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSratLibArm/SratGenerator.c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSratLibArm/SratGenerator.c
index fda0837f32..28cc8f9e8e 100644
--- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSratLibArm/SratGenerator.c
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSratLibArm/SratGenerator.c
@@ -21,7 +21,6 @@
// Module specific include files.
#include <AcpiTableGenerator.h>
#include <ConfigurationManagerObject.h>
-#include <ConfigurationManagerHelper.h>
#include <Library/TableHelperLib.h>
#include <Protocol/ConfigurationManagerProtocol.h>

@@ -38,65 +37,6 @@
- EArmObjDeviceHandlePci (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
- information from the Configuration Manager.
-*/
-GET_OBJECT_LIST (
- EObjNameSpaceArm,
- EArmObjMemoryAffinityInfo,
- CM_ARM_MEMORY_AFFINITY_INFO
- );
-
-/**
- This macro expands to a function that retrieves the Generic Initiator Affinity
- information from the Configuration Manager.
-*/
-GET_OBJECT_LIST (
- EObjNameSpaceArm,
- EArmObjGenericInitiatorAffinityInfo,
- CM_ARM_GENERIC_INITIATOR_AFFINITY_INFO
- );
-
-/**
- This macro expands to a function that retrieves the ACPI Device Handle
- information from the Configuration Manager.
-*/
-GET_OBJECT_LIST (
- EObjNameSpaceArm,
- EArmObjDeviceHandleAcpi,
- CM_ARM_DEVICE_HANDLE_ACPI
- );
-
-/**
- This macro expands to a function that retrieves the PCI Device Handle
- information from the Configuration Manager.
-*/
-GET_OBJECT_LIST (
- EObjNameSpaceArm,
- EArmObjDeviceHandlePci,
- CM_ARM_DEVICE_HANDLE_PCI
- );
-

/** Return the PCI Device information in BDF format

@@ -123,147 +63,163 @@ GetBdf (

/** 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
+ IN CONST UINT32 GicCAffOffset
)
{
- EFI_ACPI_6_3_GICC_AFFINITY_STRUCTURE * GicCAff;
+ EFI_ACPI_6_3_GICC_AFFINITY_STRUCTURE *GicCAff;
+ VOID *GicCInfo;
+ CM_ARM_GICC_INFO *Cursor;
+ UINT32 GicCCount;
+ EFI_STATUS Status;

ASSERT (Srat != NULL);
- ASSERT (GicCInfo != NULL);
+
+ Status =
+ CfgMgrGetObjects (EArmObjGicCInfo, CM_NULL_TOKEN, &GicCInfo, &GicCCount);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }

GicCAff = (EFI_ACPI_6_3_GICC_AFFINITY_STRUCTURE *)((UINT8*)Srat +
GicCAffOffset);

+ Cursor = GicCInfo;
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;
+ GicCAff->ProximityDomain = Cursor->ProximityDomain;
+ GicCAff->AcpiProcessorUid = Cursor->AcpiProcessorUid;
+ GicCAff->Flags = Cursor->AffinityFlags;
+ GicCAff->ClockDomain = Cursor->ClockDomain;

// Next
GicCAff++;
- GicCInfo++;
+ Cursor++;
}// while
+
+ FreePool (GicCInfo);
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
+ IN CONST UINT32 GicItsAffOffset
)
{
- EFI_ACPI_6_3_GIC_ITS_AFFINITY_STRUCTURE * GicItsAff;
+ EFI_ACPI_6_3_GIC_ITS_AFFINITY_STRUCTURE *GicItsAff;
+ CM_ARM_GIC_ITS_INFO *Cursor;
+ VOID *GicItsInfo;
+ UINT32 GicItsCount;
+ EFI_STATUS Status;

ASSERT (Srat != NULL);
- ASSERT (GicItsInfo != NULL);
+
+ Status = CfgMgrGetObjects (
+ EArmObjGicItsInfo, CM_NULL_TOKEN, (VOID **)&GicItsInfo, &GicItsCount);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }

GicItsAff = (EFI_ACPI_6_3_GIC_ITS_AFFINITY_STRUCTURE *)((UINT8*)Srat +
GicItsAffOffset);

+ Cursor = GicItsInfo;
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->ProximityDomain = Cursor->ProximityDomain;
GicItsAff->Reserved[0] = EFI_ACPI_RESERVED_BYTE;
GicItsAff->Reserved[1] = EFI_ACPI_RESERVED_BYTE;
- GicItsAff->ItsId = GicItsInfo->GicItsId;
+ GicItsAff->ItsId = Cursor->GicItsId;

// Next
GicItsAff++;
- GicItsInfo++;
+ Cursor++;
}// while
+
+ FreePool (GicItsInfo);
return EFI_SUCCESS;
}

/** Add the Memory 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] MemAffOffset Offset of the Memory Affinity
information in the SRAT Table.
- @param [in] MemAffInfo Pointer to the Memory Affinity Information list.
- @param [in] MemAffCount Count of Memory Affinity objects.

@retval EFI_SUCCESS Table generated successfully.
**/
STATIC
EFI_STATUS
AddMemoryAffinity (
- IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol,
IN EFI_ACPI_6_3_SYSTEM_RESOURCE_AFFINITY_TABLE_HEADER * CONST Srat,
- IN CONST UINT32 MemAffOffset,
- IN CONST CM_ARM_MEMORY_AFFINITY_INFO * MemAffInfo,
- IN UINT32 MemAffCount
+ IN CONST UINT32 MemAffOffset
)
{
- EFI_ACPI_6_3_MEMORY_AFFINITY_STRUCTURE * MemAff;
+ EFI_ACPI_6_3_MEMORY_AFFINITY_STRUCTURE *MemAff;
+ CM_ARM_MEMORY_AFFINITY_INFO *Cursor;
+ VOID *MemAffInfo;
+ UINT32 MemAffCount;
+ EFI_STATUS Status;

ASSERT (Srat != NULL);
- ASSERT (MemAffInfo != NULL);
+
+ Status = CfgMgrGetObjects (
+ EArmObjMemoryAffinityInfo, CM_NULL_TOKEN, &MemAffInfo, &MemAffCount);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }

MemAff = (EFI_ACPI_6_3_MEMORY_AFFINITY_STRUCTURE *)((UINT8*)Srat +
MemAffOffset);

+
+ Cursor = MemAffInfo;
while (MemAffCount-- != 0) {
DEBUG ((DEBUG_INFO, "SRAT: MemAff = 0x%p\n", MemAff));

MemAff->Type = EFI_ACPI_6_3_MEMORY_AFFINITY;
MemAff->Length = sizeof (EFI_ACPI_6_3_MEMORY_AFFINITY_STRUCTURE);
- MemAff->ProximityDomain = MemAffInfo->ProximityDomain;
+ MemAff->ProximityDomain = Cursor->ProximityDomain;
MemAff->Reserved1 = EFI_ACPI_RESERVED_WORD;
- MemAff->AddressBaseLow = (UINT32)(MemAffInfo->BaseAddress & MAX_UINT32);
- MemAff->AddressBaseHigh = (UINT32)(MemAffInfo->BaseAddress >> 32);
- MemAff->LengthLow = (UINT32)(MemAffInfo->Length & MAX_UINT32);
- MemAff->LengthHigh = (UINT32)(MemAffInfo->Length >> 32);
+ MemAff->AddressBaseLow = (UINT32)(Cursor->BaseAddress & MAX_UINT32);
+ MemAff->AddressBaseHigh = (UINT32)(Cursor->BaseAddress >> 32);
+ MemAff->LengthLow = (UINT32)(Cursor->Length & MAX_UINT32);
+ MemAff->LengthHigh = (UINT32)(Cursor->Length >> 32);
MemAff->Reserved2 = EFI_ACPI_RESERVED_DWORD;
- MemAff->Flags = MemAffInfo->Flags;
+ MemAff->Flags = Cursor->Flags;
MemAff->Reserved3 = EFI_ACPI_RESERVED_QWORD;

// Next
MemAff++;
- MemAffInfo++;
+ Cursor++;
}// while
+
+ FreePool (MemAffInfo);
return EFI_SUCCESS;
}

@@ -290,11 +246,8 @@ AddMemoryAffinity (
STATIC
EFI_STATUS
AddGenericInitiatorAffinity (
- IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol,
IN EFI_ACPI_6_3_SYSTEM_RESOURCE_AFFINITY_TABLE_HEADER * CONST Srat,
- IN CONST UINT32 GenInitAffOff,
- IN CONST CM_ARM_GENERIC_INITIATOR_AFFINITY_INFO * GenInitAffInfo,
- IN UINT32 GenInitAffCount
+ IN CONST UINT32 GenInitAffOff
)
{
EFI_STATUS Status;
@@ -302,13 +255,25 @@ AddGenericInitiatorAffinity (
CM_ARM_DEVICE_HANDLE_ACPI * DeviceHandleAcpi;
CM_ARM_DEVICE_HANDLE_PCI * DeviceHandlePci;
UINT32 DeviceHandleCount;
+ CM_ARM_GENERIC_INITIATOR_AFFINITY_INFO * Cursor;
+ VOID * GenInitAffInfo;
+ UINT32 GenInitAffCount;

ASSERT (Srat != NULL);
- ASSERT (GenInitAffInfo != NULL);
+
+ Status = CfgMgrGetObjects (
+ EArmObjGenericInitiatorAffinityInfo,
+ CM_NULL_TOKEN,
+ &GenInitAffInfo,
+ &GenInitAffCount);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }

GenInitAff = (EFI_ACPI_6_3_GENERIC_INITIATOR_AFFINITY_STRUCTURE *)(
(UINT8*)Srat + GenInitAffOff);

+ Cursor = GenInitAffInfo;
while (GenInitAffCount-- != 0) {
DEBUG ((DEBUG_INFO, "SRAT: GenInitAff = 0x%p\n", GenInitAff));

@@ -316,35 +281,35 @@ AddGenericInitiatorAffinity (
GenInitAff->Length =
sizeof (EFI_ACPI_6_3_GENERIC_INITIATOR_AFFINITY_STRUCTURE);
GenInitAff->Reserved1 = EFI_ACPI_RESERVED_WORD;
- GenInitAff->DeviceHandleType = GenInitAffInfo->DeviceHandleType;
- GenInitAff->ProximityDomain = GenInitAffInfo->ProximityDomain;
+ GenInitAff->DeviceHandleType = Cursor->DeviceHandleType;
+ GenInitAff->ProximityDomain = Cursor->ProximityDomain;

- if (GenInitAffInfo->DeviceHandleToken == CM_NULL_TOKEN) {
+ if (Cursor->DeviceHandleToken == CM_NULL_TOKEN) {
DEBUG ((
DEBUG_ERROR,
"ERROR: SRAT: Invalid Device Handle Token.\n"
));
ASSERT (0);
- return EFI_INVALID_PARAMETER;
+ Status = EFI_INVALID_PARAMETER;
+ goto EXIT;
}

- if (GenInitAffInfo->DeviceHandleType == EFI_ACPI_6_3_ACPI_DEVICE_HANDLE) {
- Status = GetEArmObjDeviceHandleAcpi (
- CfgMgrProtocol,
- GenInitAffInfo->DeviceHandleToken,
- &DeviceHandleAcpi,
- &DeviceHandleCount
- );
+ if (Cursor->DeviceHandleType == EFI_ACPI_6_3_ACPI_DEVICE_HANDLE) {
+ Status = CfgMgrGetObjects (
+ EArmObjDeviceHandleAcpi,
+ Cursor->DeviceHandleToken,
+ (VOID **) &DeviceHandleAcpi,
+ &DeviceHandleCount);
if (EFI_ERROR (Status)) {
DEBUG ((
DEBUG_ERROR,
"ERROR: SRAT: Failed to get ACPI Device Handle Inf."
" DeviceHandleToken = %p."
" Status = %r\n",
- GenInitAffInfo->DeviceHandleToken,
+ Cursor->DeviceHandleToken,
Status
));
- return Status;
+ goto EXIT;
}

// We are expecting only one device handle.
@@ -357,24 +322,24 @@ AddGenericInitiatorAffinity (
GenInitAff->DeviceHandle.Acpi.Reserved[1] = EFI_ACPI_RESERVED_BYTE;
GenInitAff->DeviceHandle.Acpi.Reserved[2] = EFI_ACPI_RESERVED_BYTE;
GenInitAff->DeviceHandle.Acpi.Reserved[3] = EFI_ACPI_RESERVED_BYTE;
- } else if (GenInitAffInfo->DeviceHandleType ==
+ FreePool (DeviceHandleAcpi);
+ } else if (Cursor->DeviceHandleType ==
EFI_ACPI_6_3_PCI_DEVICE_HANDLE) {
- Status = GetEArmObjDeviceHandlePci (
- CfgMgrProtocol,
- GenInitAffInfo->DeviceHandleToken,
- &DeviceHandlePci,
- &DeviceHandleCount
- );
+ Status = CfgMgrGetObjects (
+ EArmObjDeviceHandlePci,
+ Cursor->DeviceHandleToken,
+ (VOID **) &DeviceHandlePci,
+ &DeviceHandleCount);
if (EFI_ERROR (Status)) {
DEBUG ((
DEBUG_ERROR,
"ERROR: SRAT: Failed to get ACPI Device Handle Inf."
" DeviceHandleToken = %p."
" Status = %r\n",
- GenInitAffInfo->DeviceHandleToken,
+ Cursor->DeviceHandleToken,
Status
));
- return Status;
+ goto EXIT;
}

// We are expecting only one device handle
@@ -384,6 +349,8 @@ AddGenericInitiatorAffinity (
GenInitAff->DeviceHandle.Pci.PciSegment = DeviceHandlePci->SegmentNumber;
GenInitAff->DeviceHandle.Pci.PciBdfNumber = GetBdf (DeviceHandlePci);

+ FreePool (DeviceHandlePci);
+
GenInitAff->DeviceHandle.Pci.Reserved[0] = EFI_ACPI_RESERVED_BYTE;
GenInitAff->DeviceHandle.Pci.Reserved[1] = EFI_ACPI_RESERVED_BYTE;
GenInitAff->DeviceHandle.Pci.Reserved[2] = EFI_ACPI_RESERVED_BYTE;
@@ -405,15 +372,18 @@ AddGenericInitiatorAffinity (
return EFI_INVALID_PARAMETER;
}

- GenInitAff->Flags = GenInitAffInfo->Flags;
+ GenInitAff->Flags = Cursor->Flags;
GenInitAff->Reserved2[0] = EFI_ACPI_RESERVED_BYTE;
GenInitAff->Reserved2[1] = EFI_ACPI_RESERVED_BYTE;

// Next
GenInitAff++;
- GenInitAffInfo++;
+ Cursor++;
}// while
- return EFI_SUCCESS;
+
+EXIT:
+ FreePool (GenInitAffInfo);
+ return Status;
}

/** Construct the SRAT ACPI table.
@@ -450,6 +420,7 @@ BuildSratTable (
)
{
EFI_STATUS Status;
+
UINT32 TableSize;
UINT32 GicCCount;
UINT32 GicItsCount;
@@ -461,21 +432,13 @@ BuildSratTable (
UINT32 MemAffOffset;
UINT32 GenInitiatorAffOffset;

- CM_ARM_GICC_INFO * GicCInfo;
- CM_ARM_GIC_ITS_INFO * GicItsInfo;
- CM_ARM_MEMORY_AFFINITY_INFO * MemAffInfo;
- CM_ARM_GENERIC_INITIATOR_AFFINITY_INFO * GenInitiatorAffInfo;
-
EFI_ACPI_6_3_SYSTEM_RESOURCE_AFFINITY_TABLE_HEADER * Srat;

- ASSERT (
- (This != NULL) &&
- (AcpiTableInfo != NULL) &&
- (CfgMgrProtocol != NULL) &&
- (Table != NULL) &&
- (AcpiTableInfo->TableGeneratorId == This->GeneratorID) &&
- (AcpiTableInfo->AcpiTableSignature == This->AcpiTableSignature)
- );
+ ASSERT (This != NULL);
+ ASSERT (AcpiTableInfo != NULL);
+ ASSERT (Table != NULL);
+ ASSERT (AcpiTableInfo->TableGeneratorId == This->GeneratorID);
+ ASSERT (AcpiTableInfo->AcpiTableSignature == This->AcpiTableSignature);

if ((AcpiTableInfo->AcpiTableRevision < This->MinAcpiTableRevision) ||
(AcpiTableInfo->AcpiTableRevision > This->AcpiTableRevision)) {
@@ -490,21 +453,9 @@ BuildSratTable (
return EFI_INVALID_PARAMETER;
}

- *Table = NULL;
-
- Status = GetEArmObjGicCInfo (
- CfgMgrProtocol,
- CM_NULL_TOKEN,
- &GicCInfo,
- &GicCCount
- );
+ Status = CfgMgrCountObjects (EArmObjGicCInfo, &GicCCount);
if (EFI_ERROR (Status)) {
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: SRAT: Failed to get GICC Info. Status = %r\n",
- Status
- ));
- goto error_handler;
+ return Status;
}

if (GicCCount == 0) {
@@ -513,54 +464,23 @@ BuildSratTable (
"ERROR: SRAT: GIC CPU Interface information not provided.\n"
));
ASSERT (0);
- Status = EFI_INVALID_PARAMETER;
- goto error_handler;
+ return EFI_INVALID_PARAMETER;
}

- Status = GetEArmObjGicItsInfo (
- CfgMgrProtocol,
- CM_NULL_TOKEN,
- &GicItsInfo,
- &GicItsCount
- );
+ Status = CfgMgrCountObjects (EArmObjGicItsInfo, &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;
+ return Status;
}

- Status = GetEArmObjMemoryAffinityInfo (
- CfgMgrProtocol,
- CM_NULL_TOKEN,
- &MemAffInfo,
- &MemAffCount
- );
+ Status = CfgMgrCountObjects (EArmObjMemoryAffinityInfo, &MemAffCount);
if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: SRAT: Failed to get Memory Affinity Info. Status = %r\n",
- Status
- ));
- goto error_handler;
+ return Status;
}

- Status = GetEArmObjGenericInitiatorAffinityInfo (
- CfgMgrProtocol,
- CM_NULL_TOKEN,
- &GenInitiatorAffInfo,
- &GenInitiatorAffCount
- );
+ Status = CfgMgrCountObjects (
+ EArmObjGenericInitiatorAffinityInfo, &GenInitiatorAffCount);
if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: SRAT: Failed to get Generic Initiator Affinity Info."
- " Status = %r\n",
- Status
- ));
- goto error_handler;
+ return Status;
}

// Calculate the size of the SRAT table
@@ -588,35 +508,15 @@ BuildSratTable (
}

// Allocate the Buffer for SRAT table
- *Table = (EFI_ACPI_DESCRIPTION_HEADER*)AllocateZeroPool (TableSize);
- if (*Table == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: SRAT: Failed to allocate memory for SRAT Table, Size = %d," \
- " Status = %r\n",
- TableSize,
- Status
- ));
- goto error_handler;
+ Srat = AllocateZeroPool (TableSize);
+ if (Srat == NULL) {
+ return EFI_OUT_OF_RESOURCES;
}

- Srat = (EFI_ACPI_6_3_SYSTEM_RESOURCE_AFFINITY_TABLE_HEADER*)*Table;
-
- DEBUG ((
- DEBUG_INFO,
- "SRAT: Srat = 0x%p TableSize = 0x%x\n",
- Srat,
- TableSize
- ));
+ DEBUG ((DEBUG_INFO, "SRAT: Srat = 0x%p TableSize = 0x%x\n", Srat, TableSize));

Status = AddAcpiHeader (This, &Srat->Header, AcpiTableInfo, TableSize);
if (EFI_ERROR (Status)) {
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: SRAT: Failed to add ACPI header. Status = %r\n",
- Status
- ));
goto error_handler;
}

@@ -625,86 +525,33 @@ BuildSratTable (
Srat->Reserved1 = 1;
Srat->Reserved2 = EFI_ACPI_RESERVED_QWORD;

- Status = AddGICCAffinity (
- CfgMgrProtocol,
- Srat,
- GicCAffOffset,
- GicCInfo,
- GicCCount
- );
- if (EFI_ERROR (Status)) {
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: SRAT: Failed to add GICC Affinity structures. Status = %r\n",
- Status
- ));
- goto error_handler;
- }
+ AddGICCAffinity (Srat, GicCAffOffset);

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;
- }
+ AddGICItsAffinity (Srat, GicItsAffOffset);
}

if (MemAffCount != 0) {
- Status = AddMemoryAffinity (
- CfgMgrProtocol,
- Srat,
- MemAffOffset,
- MemAffInfo,
- MemAffCount
- );
- if (EFI_ERROR (Status)) {
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: SRAT: Failed to add Memory Affinity structures. Status = %r\n",
- Status
- ));
- goto error_handler;
- }
+ AddMemoryAffinity (Srat, MemAffOffset);
}

if (GenInitiatorAffCount != 0) {
- Status = AddGenericInitiatorAffinity (
- CfgMgrProtocol,
- Srat,
- GenInitiatorAffOffset,
- GenInitiatorAffInfo,
- GenInitiatorAffCount
- );
+ Status = AddGenericInitiatorAffinity (Srat, GenInitiatorAffOffset);
if (EFI_ERROR (Status)) {
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: SRAT: Failed to add Generic Initiator Affinity structures."
- " Status = %r\n",
- Status
- ));
+ DEBUG (
+ (DEBUG_ERROR,
+ "ERROR: SRAT: Failed to add Generic Initiator Affinity structures."
+ " Status = %r\n",
+ Status));
goto error_handler;
}
}

+ *Table = (EFI_ACPI_DESCRIPTION_HEADER*)Srat;
return Status;

error_handler:
-
- if (*Table != NULL) {
- FreePool (*Table);
- *Table = NULL;
- }
-
+ FreePool (Srat);
return Status;
}

@@ -728,13 +575,11 @@ FreeSratTableResources (
IN OUT EFI_ACPI_DESCRIPTION_HEADER ** CONST Table
)
{
- ASSERT (
- (This != NULL) &&
- (AcpiTableInfo != NULL) &&
- (CfgMgrProtocol != NULL) &&
- (AcpiTableInfo->TableGeneratorId == This->GeneratorID) &&
- (AcpiTableInfo->AcpiTableSignature == This->AcpiTableSignature)
- );
+ ASSERT (This != NULL);
+ ASSERT (AcpiTableInfo != NULL);
+ ASSERT (CfgMgrProtocol != NULL);
+ ASSERT (AcpiTableInfo->TableGeneratorId == This->GeneratorID);
+ ASSERT (AcpiTableInfo->AcpiTableSignature == This->AcpiTableSignature);

if ((Table == NULL) || (*Table == NULL)) {
DEBUG ((DEBUG_ERROR, "ERROR: SRAT: Invalid Table Pointer\n"));
--
2.25.1

Join devel@edk2.groups.io to automatically receive all group messages.