From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail05.groups.io (mail05.groups.io [45.79.224.7]) by spool.mail.gandi.net (Postfix) with ESMTPS id B7B70941EF6 for ; Wed, 19 Jun 2024 22:07:15 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=CoNUwJoWt8qi87fdwJ02BBCJPPxw/hVTm4TlHZphnHY=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20240206; t=1718834835; v=1; b=p+LGrjT7/b42lcyNYM8n7mKm3MdhPM/WkqNThqwtRasCBvtXtlsWicWKlS0Bffz2pH1q4aYe rU9WygBgNkK+VqDZpEtGTeLyuhThBUTyunfiPJqLZsPPrUS7bMwEqQYkfR3hIBB4rd5uOLiesku UlOAoMqF6hc6g2qAfOxWC7bP1gaotGHNXhS4t+pC3V8p1XZ7DDPwdd3CwQf5war/tStDn122X3/ GiDOcEnEpRvJAjp1TNAsSPO/4vBC7sWuhI1JbMv3abj145ETwJdWjVQ/DtciD1rs3iJKgBaUivy zfyJy9KqaUIHgYIMFB5DG83E/vzgRhjiZzQBWjgeYLssw== X-Received: by 127.0.0.2 with SMTP id lULDYY7687511xi8ItnAuKTe; Wed, 19 Jun 2024 15:07:14 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.34050.1718834828752418673 for ; Wed, 19 Jun 2024 15:07:08 -0700 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 352FE1515; Wed, 19 Jun 2024 15:07:33 -0700 (PDT) X-Received: from e126645.home (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 83DE73F64C; Wed, 19 Jun 2024 15:07:05 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io Cc: Pierre Gondois , AbdulLateef Attar , Girish Mahadevan , Jeff Brasen , Jeshua Smith , Leif Lindholm , Meenakshi Aggarwal , Sami Mujawar , Sunil V L , Yeo Reum Yun , Pierre Gondois Subject: [edk2-devel] [staging/dynamictables-reorg PATCH 08/15] DynamicTablesPkg: DynamicTableManagerDxe: Refactor PresenceArray Date: Thu, 20 Jun 2024 00:06:22 +0200 Message-Id: <20240619220629.1994362-9-pierre.gondois@arm.com> In-Reply-To: <20240619220629.1994362-1-pierre.gondois@arm.com> References: <20240619220629.1994362-1-pierre.gondois@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Resent-Date: Wed, 19 Jun 2024 15:07:08 -0700 Resent-From: pierre.gondois@arm.com Reply-To: devel@edk2.groups.io,pierre.gondois@arm.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: YmOaBzF8LL04LXsaxcqB4wQYx7686176AA= Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=p+LGrjT7; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=arm.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io 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 --- .../Arm/ArmDynamicTableManagerDxe.c | 63 +++++++++++++++++ .../Common/CommonDynamicTableManagerDxe.c | 58 +++++++++++++++ .../DynamicTableManagerDxe.c | 70 ++++++------------- .../DynamicTableManagerDxe.h | 63 +++++++++++++++++ .../DynamicTableManagerDxe.inf | 7 ++ 5 files changed, 211 insertions(+), 50 deletions(-) create mode 100644 DynamicTablesPkg/Drivers/DynamicTableManagerDxe/Arm/Arm= DynamicTableManagerDxe.c create mode 100644 DynamicTablesPkg/Drivers/DynamicTableManagerDxe/Common/= CommonDynamicTableManagerDxe.c create mode 100644 DynamicTablesPkg/Drivers/DynamicTableManagerDxe/Dynamic= TableManagerDxe.h diff --git a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/Arm/ArmDynamic= TableManagerDxe.c b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/Arm/Arm= DynamicTableManagerDxe.c new file mode 100644 index 000000000000..4874fe883f95 --- /dev/null +++ b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/Arm/ArmDynamicTableMa= nagerDxe.c @@ -0,0 +1,63 @@ +/** @file=0D + ARM Dynamic Table Manager Dxe=0D +=0D + Copyright (c) 2017 - 2019, ARM Limited. All rights reserved.=0D +=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +=0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +=0D +// Module specific include files.=0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include "DynamicTableManagerDxe.h"=0D +=0D +///=0D +/// Array containing the ACPI tables to check.=0D +/// We require the FADT, MADT, GTDT and the DSDT tables to boot.=0D +/// This list also include optional ACPI tables: DBG2, SPCR.=0D +/// The FADT table must be placed at index 0.=0D +///=0D +STATIC ACPI_TABLE_PRESENCE_INFO mAcpiVerifyTables[] =3D {=0D + { EStdAcpiTableIdFadt, EFI_ACPI_6_2_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATU= RE, "FADT", TRUE, 0 },=0D + { EStdAcpiTableIdMadt, EFI_ACPI_6_2_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGN= ATURE, "MADT", TRUE, 0 },=0D + { EStdAcpiTableIdGtdt, EFI_ACPI_6_2_GENERIC_TIMER_DESCRIPTION_TABLE_SIGN= ATURE, "GTDT", TRUE, 0 },=0D + { EStdAcpiTableIdDsdt, EFI_ACPI_6_2_DIFFERENTIATED_SYSTEM_DESCRIPTION_TA= BLE_SIGNATURE, "DSDT", TRUE, 0 },=0D + { EStdAcpiTableIdDbg2, EFI_ACPI_6_2_DEBUG_PORT_2_TABLE_SIGNATURE, = "DBG2", FALSE, 0 },=0D + { EStdAcpiTableIdSpcr, EFI_ACPI_6_2_SERIAL_PORT_CONSOLE_REDIRECTION_TABL= E_SIGNATURE, "SPCR", FALSE, 0 },=0D +};=0D +=0D +/** Get the arch specific ACPI table presence information.=0D +=0D + @param [out] PresenceArray Array containing the ACPI tables to chec= k.=0D + @param [out] PresenceArrayCount Count of elements in the PresenceArray.= =0D + @param [out] FadtIndex Index of the FADT table in the PresenceA= rray.=0D + -1 if absent.=0D +=0D + @retval EFI_SUCCESS Success.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +GetAcpiTablePresenceInfo (=0D + OUT ACPI_TABLE_PRESENCE_INFO **PresenceArray,=0D + OUT UINT32 *PresenceArrayCount,=0D + OUT INT32 *FadtIndex=0D + )=0D +{=0D + *PresenceArray =3D mAcpiVerifyTables;=0D + *PresenceArrayCount =3D ARRAY_SIZE (mAcpiVerifyTables);=0D + *FadtIndex =3D ACPI_TABLE_VERIFY_FADT;=0D +=0D + return EFI_SUCCESS;=0D +}=0D diff --git a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/Common/CommonD= ynamicTableManagerDxe.c b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/C= ommon/CommonDynamicTableManagerDxe.c new file mode 100644 index 000000000000..cb6bf72f31ab --- /dev/null +++ b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/Common/CommonDynamicT= ableManagerDxe.c @@ -0,0 +1,58 @@ +/** @file=0D + Common Dynamic Table Manager Dxe=0D +=0D + Copyright (c) 2024, Arm Limited. All rights reserved.=0D +=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +=0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +=0D +// Module specific include files.=0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include "DynamicTableManagerDxe.h"=0D +=0D +///=0D +/// Array containing the ACPI tables to check.=0D +/// This is a dummy list only existing for build purpose.=0D +/// The FADT table must be placed at index 0.=0D +///=0D +ACPI_TABLE_PRESENCE_INFO mAcpiVerifyTables[] =3D {=0D + { EStdAcpiTableIdFadt, EFI_ACPI_6_2_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATU= RE, "FADT", TRUE, 0 },=0D +};=0D +=0D +/** Get the arch specific ACPI table presence information.=0D +=0D + @param [out] PresenceArray Array containing the ACPI tables to chec= k.=0D + @param [out] PresenceArrayCount Count of elements in the PresenceArray.= =0D + @param [out] FadtIndex Index of the FADT table in the PresenceA= rray.=0D + -1 if absent.=0D +=0D + @retval EFI_SUCCESS Success.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +GetAcpiTablePresenceInfo (=0D + OUT ACPI_TABLE_PRESENCE_INFO **PresenceArray,=0D + OUT UINT32 *PresenceArrayCount,=0D + OUT INT32 *FadtIndex=0D + )=0D +{=0D + // Dummy function.=0D + *PresenceArray =3D mAcpiVerifyTables;=0D + *PresenceArrayCount =3D ARRAY_SIZE (mAcpiVerifyTables);=0D + *FadtIndex =3D ACPI_TABLE_VERIFY_FADT;=0D +=0D + return EFI_SUCCESS;=0D +}=0D diff --git a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableMa= nagerDxe.c b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableMa= nagerDxe.c index 1e9b811c4017..dfccccb83954 100644 --- a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDx= e.c +++ b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDx= e.c @@ -23,57 +23,15 @@ #include =0D #include =0D =0D -///=0D -/// Bit definitions for acceptable ACPI table presence formats.=0D -/// Currently only ACPI tables present in the ACPI info list and=0D -/// already installed will count towards "Table Present" during=0D -/// verification routine.=0D -///=0D -#define ACPI_TABLE_PRESENT_INFO_LIST BIT0=0D -#define ACPI_TABLE_PRESENT_INSTALLED BIT1=0D -=0D -///=0D -/// Order of ACPI table being verified during presence inspection.=0D -///=0D -#define ACPI_TABLE_VERIFY_FADT 0=0D -#define ACPI_TABLE_VERIFY_MADT 1=0D -#define ACPI_TABLE_VERIFY_GTDT 2=0D -#define ACPI_TABLE_VERIFY_DSDT 3=0D -#define ACPI_TABLE_VERIFY_DBG2 4=0D -#define ACPI_TABLE_VERIFY_SPCR 5=0D -#define ACPI_TABLE_VERIFY_COUNT 6=0D -=0D -///=0D -/// Private data structure to verify the presence of mandatory=0D -/// or optional ACPI tables.=0D -///=0D -typedef struct {=0D - /// ESTD ID for the ACPI table of interest.=0D - ESTD_ACPI_TABLE_ID EstdTableId;=0D - /// Standard UINT32 ACPI signature.=0D - UINT32 AcpiTableSignature;=0D - /// 4 character ACPI table name (the 5th char8 is for null terminator).= =0D - CHAR8 AcpiTableName[sizeof (UINT32) + 1];=0D - /// Indicator on whether the ACPI table is required.=0D - BOOLEAN IsMandatory;=0D - /// Formats of verified presences, as defined by ACPI_TABLE_PRESENT_*=0D - /// This field should be initialized to 0 and will be populated during=0D - /// verification routine.=0D - UINT16 Presence;=0D -} ACPI_TABLE_PRESENCE_INFO;=0D +#include "DynamicTableManagerDxe.h"=0D =0D ///=0D /// We require the FADT, MADT, GTDT and the DSDT tables to boot.=0D /// This list also include optional ACPI tables: DBG2, SPCR.=0D ///=0D -ACPI_TABLE_PRESENCE_INFO mAcpiVerifyTables[ACPI_TABLE_VERIFY_COUNT] =3D {= =0D - { EStdAcpiTableIdFadt, EFI_ACPI_6_2_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATU= RE, "FADT", TRUE, 0 },=0D - { EStdAcpiTableIdMadt, EFI_ACPI_6_2_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGN= ATURE, "MADT", TRUE, 0 },=0D - { EStdAcpiTableIdGtdt, EFI_ACPI_6_2_GENERIC_TIMER_DESCRIPTION_TABLE_SIGN= ATURE, "GTDT", TRUE, 0 },=0D - { EStdAcpiTableIdDsdt, EFI_ACPI_6_2_DIFFERENTIATED_SYSTEM_DESCRIPTION_TA= BLE_SIGNATURE, "DSDT", TRUE, 0 },=0D - { EStdAcpiTableIdDbg2, EFI_ACPI_6_2_DEBUG_PORT_2_TABLE_SIGNATURE, = "DBG2", FALSE, 0 },=0D - { EStdAcpiTableIdSpcr, EFI_ACPI_6_2_SERIAL_PORT_CONSOLE_REDIRECTION_TABL= E_SIGNATURE, "SPCR", FALSE, 0 },=0D -};=0D +STATIC ACPI_TABLE_PRESENCE_INFO *mAcpiVerifyTables;=0D +STATIC UINT32 mAcpiVerifyTablesCount;=0D +STATIC INT32 mAcpiVerifyTablesFadtIndex;=0D =0D /** This macro expands to a function that retrieves the ACPI Table=0D List from the Configuration Manager.=0D @@ -472,7 +430,7 @@ VerifyMandatoryTablesArePresent ( =0D // Check against the statically initialized ACPI tables to see if they a= re in ACPI info list=0D while (AcpiTableCount-- !=3D 0) {=0D - for (Index =3D 0; Index < ACPI_TABLE_VERIFY_COUNT; Index++) {=0D + for (Index =3D 0; Index < mAcpiVerifyTablesCount; Index++) {=0D if (AcpiTableInfo[AcpiTableCount].AcpiTableSignature =3D=3D mAcpiVer= ifyTables[Index].AcpiTableSignature) {=0D mAcpiVerifyTables[Index].Presence |=3D ACPI_TABLE_PRESENT_INFO_LIS= T;=0D // Found this table, skip the rest.=0D @@ -491,7 +449,7 @@ VerifyMandatoryTablesArePresent ( return Status;=0D }=0D =0D - for (Index =3D 0; Index < ACPI_TABLE_VERIFY_COUNT; Index++) {=0D + for (Index =3D 0; Index < mAcpiVerifyTablesCount; Index++) {=0D Handle =3D 0;=0D InstalledTableIndex =3D 0;=0D do {=0D @@ -511,7 +469,7 @@ VerifyMandatoryTablesArePresent ( =0D // Reset the return Status value to EFI_SUCCESS. We do not fully care if= the table look up has failed.=0D Status =3D EFI_SUCCESS;=0D - for (Index =3D 0; Index < ACPI_TABLE_VERIFY_COUNT; Index++) {=0D + for (Index =3D 0; Index < mAcpiVerifyTablesCount; Index++) {=0D if (mAcpiVerifyTables[Index].Presence =3D=3D 0) {=0D if (mAcpiVerifyTables[Index].IsMandatory) {=0D DEBUG ((DEBUG_ERROR, "ERROR: %a Table not found.\n", mAcpiVerifyTa= bles[Index].AcpiTableName));=0D @@ -623,7 +581,9 @@ ProcessAcpiTables ( }=0D =0D // Add the FADT Table first.=0D - if ((mAcpiVerifyTables[ACPI_TABLE_VERIFY_FADT].Presence & ACPI_TABLE_PRE= SENT_INSTALLED) =3D=3D 0) {=0D + if ((mAcpiVerifyTablesFadtIndex >=3D 0) &&=0D + ((mAcpiVerifyTables[mAcpiVerifyTablesFadtIndex].Presence & ACPI_TABL= E_PRESENT_INSTALLED) =3D=3D 0))=0D + {=0D // FADT is not yet installed=0D for (Idx =3D 0; Idx < AcpiTableCount; Idx++) {=0D if (CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdFadt) =3D=3D=0D @@ -785,6 +745,16 @@ DynamicTableManagerDxeInitialize ( CfgMfrInfo->OemId[5]=0D ));=0D =0D + Status =3D GetAcpiTablePresenceInfo (=0D + &mAcpiVerifyTables,=0D + &mAcpiVerifyTablesCount,=0D + &mAcpiVerifyTablesFadtIndex=0D + );=0D + if (EFI_ERROR (Status)) {=0D + ASSERT_EFI_ERROR (Status);=0D + return Status;=0D + }=0D +=0D Status =3D ProcessAcpiTables (TableFactoryProtocol, CfgMgrProtocol);=0D if (EFI_ERROR (Status)) {=0D DEBUG ((=0D diff --git a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableMa= nagerDxe.h b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableMa= nagerDxe.h new file mode 100644 index 000000000000..a12a775af132 --- /dev/null +++ b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDx= e.h @@ -0,0 +1,63 @@ +/** @file=0D + Dynamic Table Manager Dxe=0D +=0D + Copyright (c) 2017 - 2024, ARM Limited. All rights reserved.=0D +=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +=0D +#ifndef DYNAMIC_TABLE_MANAGER_DXE_H_=0D +#define DYNAMIC_TABLE_MANAGER_DXE_H_=0D +=0D +#include =0D +=0D +///=0D +/// Bit definitions for acceptable ACPI table presence formats.=0D +/// Currently only ACPI tables present in the ACPI info list and=0D +/// already installed will count towards "Table Present" during=0D +/// verification routine.=0D +///=0D +#define ACPI_TABLE_PRESENT_INFO_LIST BIT0=0D +#define ACPI_TABLE_PRESENT_INSTALLED BIT1=0D +=0D +/// The FADT table must be placed at index 0 in mAcpiVerifyTables.=0D +#define ACPI_TABLE_VERIFY_FADT 0=0D +=0D +///=0D +/// Private data structure to verify the presence of mandatory=0D +/// or optional ACPI tables.=0D +///=0D +typedef struct {=0D + /// ESTD ID for the ACPI table of interest.=0D + ESTD_ACPI_TABLE_ID EstdTableId;=0D + /// Standard UINT32 ACPI signature.=0D + UINT32 AcpiTableSignature;=0D + /// 4 character ACPI table name (the 5th char8 is for null terminator).= =0D + CHAR8 AcpiTableName[sizeof (UINT32) + 1];=0D + /// Indicator on whether the ACPI table is required.=0D + BOOLEAN IsMandatory;=0D + /// Formats of verified presences, as defined by ACPI_TABLE_PRESENT_*=0D + /// This field should be initialized to 0 and will be populated during=0D + /// verification routine.=0D + UINT16 Presence;=0D +} ACPI_TABLE_PRESENCE_INFO;=0D +=0D +/** Get the arch specific ACPI table presence information.=0D +=0D + @param [out] PresenceArray Array containing the ACPI tables to chec= k.=0D + @param [out] PresenceArrayCount Count of elements in the PresenceArray.= =0D + @param [out] FadtIndex Index of the FADT table in the PresenceA= rray.=0D + -1 if absent.=0D +=0D + @retval EFI_SUCCESS Success.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +GetAcpiTablePresenceInfo (=0D + OUT ACPI_TABLE_PRESENCE_INFO **PresenceArray,=0D + OUT UINT32 *PresenceArrayCount,=0D + OUT INT32 *FadtIndex=0D + );=0D +=0D +#endif // DYNAMIC_TABLE_MANAGER_DXE_H_=0D diff --git a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableMa= nagerDxe.inf b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTable= ManagerDxe.inf index ad8b3d037c16..1b0b06d774de 100644 --- a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDx= e.inf +++ b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDx= e.inf @@ -22,6 +22,13 @@ [Defines] =0D [Sources]=0D DynamicTableManagerDxe.c=0D + DynamicTableManagerDxe.h=0D +=0D +[Sources.ARM, Sources.AARCH64]=0D + Arm/ArmDynamicTableManagerDxe.c=0D +=0D +[Sources.IA32, Sources.X64]=0D + Common/CommonDynamicTableManagerDxe.c=0D =0D [Packages]=0D MdePkg/MdePkg.dec=0D --=20 2.25.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#119640): https://edk2.groups.io/g/devel/message/119640 Mute This Topic: https://groups.io/mt/106770163/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-