public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "PierreGondois" <pierre.gondois@arm.com>
To: devel@edk2.groups.io, kuqin12@gmail.com
Cc: Sami Mujawar <Sami.Mujawar@arm.com>,
	Alexei Fedorov <Alexei.Fedorov@arm.com>,
	Joe Lopez <joelopez@microsoft.com>
Subject: Re: [edk2-devel] [PATCH v1 4/6] DynamicTablesPkg: DynamicTableManagerDxe: Added check for installed tables
Date: Wed, 20 Jul 2022 15:36:54 +0200	[thread overview]
Message-ID: <757b4f8a-4ad3-b140-3623-9e00dce62196@arm.com> (raw)
In-Reply-To: <20220719002254.1891-5-kuqin12@gmail.com>

Hello Kun,

On 7/19/22 02:22, Kun Qin via groups.io wrote:
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3997
> 
> This change added an extra step to allow check for installed ACPI tables.
> 
> For FADT, MADT, GTDT, DSDT and DBG2 tables, either pre-installed or
> supplied through AcpiTableInfo can be accepted.
> 
> An extra check for FADT ACPI table existence during installation step is
> also added.
> 
> Cc: Sami Mujawar <Sami.Mujawar@arm.com>
> Cc: Alexei Fedorov <Alexei.Fedorov@arm.com>
> 
> Co-authored-by: Joe Lopez <joelopez@microsoft.com>
> Signed-off-by: Kun Qin <kuqin12@gmail.com>
> ---
>   DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.c   | 200 ++++++++++++++++----
>   DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf |   1 +
>   2 files changed, 167 insertions(+), 34 deletions(-)
> 
> diff --git a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.c b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.c
> index ed62299f9bbd..ac5fe0bed91b 100644
> --- a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.c
> +++ b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.c
> @@ -11,6 +11,7 @@
>   #include <Library/PcdLib.h>
>   #include <Library/UefiBootServicesTableLib.h>
>   #include <Protocol/AcpiTable.h>
> +#include <Protocol/AcpiSystemDescriptionTable.h>
>   
>   // Module specific include files.
>   #include <AcpiTableGenerator.h>
> @@ -387,6 +388,57 @@ BuildAndInstallAcpiTable (
>     return Status;
>   }
>   

[snip]

> -  if (!Dbg2Found) {
> +  Handle = 0;
> +  Status = LocateAcpiTableBySignature (
> +             EFI_ACPI_6_2_DEBUG_PORT_2_TABLE_SIGNATURE,
> +             &DummyHeader,
> +             &Handle
> +             );
> +  if (EFI_ERROR (Status) && !Dbg2Found) {
>       DEBUG ((DEBUG_WARN, "WARNING: DBG2 Table not found.\n"));
> +  } else if (!EFI_ERROR (Status) && Dbg2Found) {
> +    DEBUG ((DEBUG_ERROR, "ERROR: DBG2 Table found while already published.\n"));
> +    Status = EFI_ALREADY_STARTED;
> +  } else {
> +    Dbg2Found = TRUE;
>     }
>   
> -  if (!SpcrFound) {
> +  Handle = 0;
> +  Status = LocateAcpiTableBySignature (
> +             EFI_ACPI_6_2_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE,
> +             &DummyHeader,
> +             &Handle
> +             );
> +  if (EFI_ERROR (Status) && !SpcrFound) {
>       DEBUG ((DEBUG_WARN, "WARNING: SPCR Table not found.\n"));
> +  } else if (!EFI_ERROR (Status) && SpcrFound) {
> +    DEBUG ((DEBUG_ERROR, "ERROR: SPCR Table found while already published.\n"));
> +    Status = EFI_ALREADY_STARTED;
> +  } else {
> +    SpcrFound = TRUE;
>     }

Since there are many tables, maybe it would be good to factorize the code and
create a static array containing all the tables that are mandatory, and containing:
1. the ESTD_ACPI_TABLE_ID of the table
2. the table signature (*_DESCRIPTION_TABLE_SIGNATURE)
3. the table name (for printing)
4. whether the table was found (dynamically populated)
(maybe other fields would be required)

Like this we could have 2 loops in VerifyMandatoryTablesArePresent(),
one going through AcpiTableInfo[AcpiTableCount].AcpiTableSignature,
and a second one going through the already installed tables (AcpiSdt->GetAcpiTable (Index, ...))

This should also allow to simplify the code for installing the FADT aswell
and code of LocateAcpiTableBySignature() would be included in VerifyMandatoryTablesArePresent().

Also, I think you will have to rebase your patches on the latest master and
do the same thing as
6cda306da1dd DynamicTablesPkg: AcpiSsdtPcieLibArm: Correct translation value
does.

Regards,
Pierre

  parent reply	other threads:[~2022-07-20 13:37 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-19  0:22 [PATCH v1 0/6] Enhance DynamicTablesPkg modules Kun Qin
2022-07-19  0:22 ` [PATCH v1 1/6] DynamicTablesPkg: DynamicPlatRepoLib: Added MemoryAllocationLib to inf Kun Qin
2022-07-20 10:03   ` Sami Mujawar
2022-07-19  0:22 ` [PATCH v1 2/6] DynamicTablesPkg: DynamicPlatRepoLib: Fix incorrect dereferencing Kun Qin
2022-07-20 10:06   ` Sami Mujawar
2022-07-19  0:22 ` [PATCH v1 3/6] DynamicTablesPkg: DynamicPlatRepoLib: Adding more token fixers Kun Qin
2022-07-20 10:39   ` Sami Mujawar
2022-07-19  0:22 ` [PATCH v1 4/6] DynamicTablesPkg: DynamicTableManagerDxe: Added check for installed tables Kun Qin
2022-07-20 11:00   ` Sami Mujawar
2022-07-21  1:48     ` Kun Qin
2022-07-20 13:36   ` PierreGondois [this message]
2022-07-19  0:22 ` [PATCH v1 5/6] DynamicTablesPkg: AcpiSsdtPcieLibArm: Added function to reserve ECAM space Kun Qin
2022-07-20 13:36   ` [edk2-devel] " PierreGondois
2022-07-19  0:22 ` [PATCH v1 6/6] DynamicTablesPkg: AcpiSsdtPcieLibArm: Added case handling for PCI config Kun Qin
2022-07-20 13:38 ` [edk2-devel] [PATCH v1 0/6] Enhance DynamicTablesPkg modules PierreGondois
2022-07-21  1:45   ` Kun Qin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=757b4f8a-4ad3-b140-3623-9e00dce62196@arm.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox