summaryrefslogtreecommitdiffstats
path: root/DynamicTablesPkg
diff options
context:
space:
mode:
authorPierre Gondois <pierre.gondois@arm.com>2024-06-10 14:00:00 +0200
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2024-07-29 13:44:55 +0000
commit47b830db58cec598ebb144a46054c357401a8441 (patch)
treef0f1ddafdc658f33830006077bd61080d61e2f2f /DynamicTablesPkg
parentdfd867bd8381d1bc6ee4ea9e6f5ea65116e4b452 (diff)
downloadedk2-47b830db58cec598ebb144a46054c357401a8441.tar.gz
edk2-47b830db58cec598ebb144a46054c357401a8441.tar.bz2
edk2-47b830db58cec598ebb144a46054c357401a8441.zip
DynamicTablesPkg: DynamicTableManagerDxe: Refactor PresenceArray
Mandatory ACPI tables depend on the architectures. Different architectures might also want to check other tables. Move mAcpiVerifyTables containing the list of ACPI tables to check to an arch specific file and introduce GetAcpiTablePresenceInfo() to get get the relevant information from the array. Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
Diffstat (limited to 'DynamicTablesPkg')
-rw-r--r--DynamicTablesPkg/Drivers/DynamicTableManagerDxe/Arm/ArmDynamicTableManager.c63
-rw-r--r--DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.c70
-rw-r--r--DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.h63
-rw-r--r--DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf7
-rw-r--r--DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerNull.c59
5 files changed, 212 insertions, 50 deletions
diff --git a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/Arm/ArmDynamicTableManager.c b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/Arm/ArmDynamicTableManager.c
new file mode 100644
index 0000000000..4874fe883f
--- /dev/null
+++ b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/Arm/ArmDynamicTableManager.c
@@ -0,0 +1,63 @@
+/** @file
+ ARM Dynamic Table Manager Dxe
+
+ Copyright (c) 2017 - 2019, ARM Limited. All rights reserved.
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Library/DebugLib.h>
+#include <Library/PcdLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Protocol/AcpiSystemDescriptionTable.h>
+#include <Protocol/AcpiTable.h>
+
+// 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 "DynamicTableManagerDxe.h"
+
+///
+/// Array containing the ACPI tables to check.
+/// We require the FADT, MADT, GTDT and the DSDT tables to boot.
+/// This list also include optional ACPI tables: DBG2, SPCR.
+/// The FADT table must be placed at index 0.
+///
+STATIC ACPI_TABLE_PRESENCE_INFO mAcpiVerifyTables[] = {
+ { EStdAcpiTableIdFadt, EFI_ACPI_6_2_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE, "FADT", TRUE, 0 },
+ { EStdAcpiTableIdMadt, EFI_ACPI_6_2_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE, "MADT", TRUE, 0 },
+ { EStdAcpiTableIdGtdt, EFI_ACPI_6_2_GENERIC_TIMER_DESCRIPTION_TABLE_SIGNATURE, "GTDT", TRUE, 0 },
+ { EStdAcpiTableIdDsdt, EFI_ACPI_6_2_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE, "DSDT", TRUE, 0 },
+ { EStdAcpiTableIdDbg2, EFI_ACPI_6_2_DEBUG_PORT_2_TABLE_SIGNATURE, "DBG2", FALSE, 0 },
+ { EStdAcpiTableIdSpcr, EFI_ACPI_6_2_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE, "SPCR", FALSE, 0 },
+};
+
+/** Get the arch specific ACPI table presence information.
+
+ @param [out] PresenceArray Array containing the ACPI tables to check.
+ @param [out] PresenceArrayCount Count of elements in the PresenceArray.
+ @param [out] FadtIndex Index of the FADT table in the PresenceArray.
+ -1 if absent.
+
+ @retval EFI_SUCCESS Success.
+**/
+EFI_STATUS
+EFIAPI
+GetAcpiTablePresenceInfo (
+ OUT ACPI_TABLE_PRESENCE_INFO **PresenceArray,
+ OUT UINT32 *PresenceArrayCount,
+ OUT INT32 *FadtIndex
+ )
+{
+ *PresenceArray = mAcpiVerifyTables;
+ *PresenceArrayCount = ARRAY_SIZE (mAcpiVerifyTables);
+ *FadtIndex = ACPI_TABLE_VERIFY_FADT;
+
+ return EFI_SUCCESS;
+}
diff --git a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.c b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.c
index 1e9b811c40..dfccccb839 100644
--- a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.c
+++ b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.c
@@ -23,57 +23,15 @@
#include <Protocol/DynamicTableFactoryProtocol.h>
#include <SmbiosTableGenerator.h>
-///
-/// Bit definitions for acceptable ACPI table presence formats.
-/// Currently only ACPI tables present in the ACPI info list and
-/// already installed will count towards "Table Present" during
-/// verification routine.
-///
-#define ACPI_TABLE_PRESENT_INFO_LIST BIT0
-#define ACPI_TABLE_PRESENT_INSTALLED BIT1
-
-///
-/// Order of ACPI table being verified during presence inspection.
-///
-#define ACPI_TABLE_VERIFY_FADT 0
-#define ACPI_TABLE_VERIFY_MADT 1
-#define ACPI_TABLE_VERIFY_GTDT 2
-#define ACPI_TABLE_VERIFY_DSDT 3
-#define ACPI_TABLE_VERIFY_DBG2 4
-#define ACPI_TABLE_VERIFY_SPCR 5
-#define ACPI_TABLE_VERIFY_COUNT 6
-
-///
-/// Private data structure to verify the presence of mandatory
-/// or optional ACPI tables.
-///
-typedef struct {
- /// ESTD ID for the ACPI table of interest.
- ESTD_ACPI_TABLE_ID EstdTableId;
- /// Standard UINT32 ACPI signature.
- UINT32 AcpiTableSignature;
- /// 4 character ACPI table name (the 5th char8 is for null terminator).
- CHAR8 AcpiTableName[sizeof (UINT32) + 1];
- /// Indicator on whether the ACPI table is required.
- BOOLEAN IsMandatory;
- /// Formats of verified presences, as defined by ACPI_TABLE_PRESENT_*
- /// This field should be initialized to 0 and will be populated during
- /// verification routine.
- UINT16 Presence;
-} ACPI_TABLE_PRESENCE_INFO;
+#include "DynamicTableManagerDxe.h"
///
/// We require the FADT, MADT, GTDT and the DSDT tables to boot.
/// This list also include optional ACPI tables: DBG2, SPCR.
///
-ACPI_TABLE_PRESENCE_INFO mAcpiVerifyTables[ACPI_TABLE_VERIFY_COUNT] = {
- { EStdAcpiTableIdFadt, EFI_ACPI_6_2_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE, "FADT", TRUE, 0 },
- { EStdAcpiTableIdMadt, EFI_ACPI_6_2_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE, "MADT", TRUE, 0 },
- { EStdAcpiTableIdGtdt, EFI_ACPI_6_2_GENERIC_TIMER_DESCRIPTION_TABLE_SIGNATURE, "GTDT", TRUE, 0 },
- { EStdAcpiTableIdDsdt, EFI_ACPI_6_2_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE, "DSDT", TRUE, 0 },
- { EStdAcpiTableIdDbg2, EFI_ACPI_6_2_DEBUG_PORT_2_TABLE_SIGNATURE, "DBG2", FALSE, 0 },
- { EStdAcpiTableIdSpcr, EFI_ACPI_6_2_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE, "SPCR", FALSE, 0 },
-};
+STATIC ACPI_TABLE_PRESENCE_INFO *mAcpiVerifyTables;
+STATIC UINT32 mAcpiVerifyTablesCount;
+STATIC INT32 mAcpiVerifyTablesFadtIndex;
/** This macro expands to a function that retrieves the ACPI Table
List from the Configuration Manager.
@@ -472,7 +430,7 @@ VerifyMandatoryTablesArePresent (
// Check against the statically initialized ACPI tables to see if they are in ACPI info list
while (AcpiTableCount-- != 0) {
- for (Index = 0; Index < ACPI_TABLE_VERIFY_COUNT; Index++) {
+ for (Index = 0; Index < mAcpiVerifyTablesCount; Index++) {
if (AcpiTableInfo[AcpiTableCount].AcpiTableSignature == mAcpiVerifyTables[Index].AcpiTableSignature) {
mAcpiVerifyTables[Index].Presence |= ACPI_TABLE_PRESENT_INFO_LIST;
// Found this table, skip the rest.
@@ -491,7 +449,7 @@ VerifyMandatoryTablesArePresent (
return Status;
}
- for (Index = 0; Index < ACPI_TABLE_VERIFY_COUNT; Index++) {
+ for (Index = 0; Index < mAcpiVerifyTablesCount; Index++) {
Handle = 0;
InstalledTableIndex = 0;
do {
@@ -511,7 +469,7 @@ VerifyMandatoryTablesArePresent (
// Reset the return Status value to EFI_SUCCESS. We do not fully care if the table look up has failed.
Status = EFI_SUCCESS;
- for (Index = 0; Index < ACPI_TABLE_VERIFY_COUNT; Index++) {
+ for (Index = 0; Index < mAcpiVerifyTablesCount; Index++) {
if (mAcpiVerifyTables[Index].Presence == 0) {
if (mAcpiVerifyTables[Index].IsMandatory) {
DEBUG ((DEBUG_ERROR, "ERROR: %a Table not found.\n", mAcpiVerifyTables[Index].AcpiTableName));
@@ -623,7 +581,9 @@ ProcessAcpiTables (
}
// Add the FADT Table first.
- if ((mAcpiVerifyTables[ACPI_TABLE_VERIFY_FADT].Presence & ACPI_TABLE_PRESENT_INSTALLED) == 0) {
+ if ((mAcpiVerifyTablesFadtIndex >= 0) &&
+ ((mAcpiVerifyTables[mAcpiVerifyTablesFadtIndex].Presence & ACPI_TABLE_PRESENT_INSTALLED) == 0))
+ {
// FADT is not yet installed
for (Idx = 0; Idx < AcpiTableCount; Idx++) {
if (CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdFadt) ==
@@ -785,6 +745,16 @@ DynamicTableManagerDxeInitialize (
CfgMfrInfo->OemId[5]
));
+ Status = GetAcpiTablePresenceInfo (
+ &mAcpiVerifyTables,
+ &mAcpiVerifyTablesCount,
+ &mAcpiVerifyTablesFadtIndex
+ );
+ if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
+ return Status;
+ }
+
Status = ProcessAcpiTables (TableFactoryProtocol, CfgMgrProtocol);
if (EFI_ERROR (Status)) {
DEBUG ((
diff --git a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.h b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.h
new file mode 100644
index 0000000000..a12a775af1
--- /dev/null
+++ b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.h
@@ -0,0 +1,63 @@
+/** @file
+ Dynamic Table Manager Dxe
+
+ Copyright (c) 2017 - 2024, ARM Limited. All rights reserved.
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef DYNAMIC_TABLE_MANAGER_DXE_H_
+#define DYNAMIC_TABLE_MANAGER_DXE_H_
+
+#include <AcpiTableGenerator.h>
+
+///
+/// Bit definitions for acceptable ACPI table presence formats.
+/// Currently only ACPI tables present in the ACPI info list and
+/// already installed will count towards "Table Present" during
+/// verification routine.
+///
+#define ACPI_TABLE_PRESENT_INFO_LIST BIT0
+#define ACPI_TABLE_PRESENT_INSTALLED BIT1
+
+/// The FADT table must be placed at index 0 in mAcpiVerifyTables.
+#define ACPI_TABLE_VERIFY_FADT 0
+
+///
+/// Private data structure to verify the presence of mandatory
+/// or optional ACPI tables.
+///
+typedef struct {
+ /// ESTD ID for the ACPI table of interest.
+ ESTD_ACPI_TABLE_ID EstdTableId;
+ /// Standard UINT32 ACPI signature.
+ UINT32 AcpiTableSignature;
+ /// 4 character ACPI table name (the 5th char8 is for null terminator).
+ CHAR8 AcpiTableName[sizeof (UINT32) + 1];
+ /// Indicator on whether the ACPI table is required.
+ BOOLEAN IsMandatory;
+ /// Formats of verified presences, as defined by ACPI_TABLE_PRESENT_*
+ /// This field should be initialized to 0 and will be populated during
+ /// verification routine.
+ UINT16 Presence;
+} ACPI_TABLE_PRESENCE_INFO;
+
+/** Get the arch specific ACPI table presence information.
+
+ @param [out] PresenceArray Array containing the ACPI tables to check.
+ @param [out] PresenceArrayCount Count of elements in the PresenceArray.
+ @param [out] FadtIndex Index of the FADT table in the PresenceArray.
+ -1 if absent.
+
+ @retval EFI_SUCCESS Success.
+**/
+EFI_STATUS
+EFIAPI
+GetAcpiTablePresenceInfo (
+ OUT ACPI_TABLE_PRESENCE_INFO **PresenceArray,
+ OUT UINT32 *PresenceArrayCount,
+ OUT INT32 *FadtIndex
+ );
+
+#endif // DYNAMIC_TABLE_MANAGER_DXE_H_
diff --git a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf
index ad8b3d037c..00d03e75be 100644
--- a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf
+++ b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf
@@ -22,6 +22,13 @@
[Sources]
DynamicTableManagerDxe.c
+ DynamicTableManagerDxe.h
+
+[Sources.ARM, Sources.AARCH64]
+ Arm/ArmDynamicTableManager.c
+
+[Sources.IA32, Sources.X64]
+ DynamicTableManagerNull.c
[Packages]
MdePkg/MdePkg.dec
diff --git a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerNull.c b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerNull.c
new file mode 100644
index 0000000000..d9b727468a
--- /dev/null
+++ b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerNull.c
@@ -0,0 +1,59 @@
+/** @file
+ Common Dynamic Table Manager Dxe
+
+ Copyright (c) 2024, Arm Limited. All rights reserved.
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Library/DebugLib.h>
+#include <Library/PcdLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Protocol/AcpiSystemDescriptionTable.h>
+#include <Protocol/AcpiTable.h>
+
+// 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 "DynamicTableManagerDxe.h"
+
+///
+/// Array containing the ACPI tables to check.
+/// This is a dummy list only existing for build purpose.
+/// The FADT table must be placed at index 0.
+///
+ACPI_TABLE_PRESENCE_INFO mAcpiVerifyTables[] = {
+ { EStdAcpiTableIdFadt, EFI_ACPI_6_2_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE, "FADT", TRUE, 0 },
+};
+
+/** Get the arch specific ACPI table presence information.
+
+ @param [out] PresenceArray Array containing the ACPI tables to check.
+ @param [out] PresenceArrayCount Count of elements in the PresenceArray.
+ @param [out] FadtIndex Index of the FADT table in the PresenceArray.
+ -1 if absent.
+
+ @retval EFI_SUCCESS Success.
+ @retval EFI_UNSUPPORTED Unsupported.
+**/
+EFI_STATUS
+EFIAPI
+GetAcpiTablePresenceInfo (
+ OUT ACPI_TABLE_PRESENCE_INFO **PresenceArray,
+ OUT UINT32 *PresenceArrayCount,
+ OUT INT32 *FadtIndex
+ )
+{
+ // Dummy function - Not Implemented.
+ *PresenceArray = mAcpiVerifyTables;
+ *PresenceArrayCount = ARRAY_SIZE (mAcpiVerifyTables);
+ *FadtIndex = ACPI_TABLE_VERIFY_FADT;
+
+ return EFI_UNSUPPORTED;
+}