public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Zeng, Star" <star.zeng@intel.com>
To: "Ni, Ruiyu" <ruiyu.ni@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Kinney, Michael D" <michael.d.kinney@intel.com>,
	Younas khan <pmdyounaskhan786@gmail.com>,
	"Yao, Jiewen" <jiewen.yao@intel.com>,
	"Gao, Liming" <liming.gao@intel.com>,
	"Zeng, Star" <star.zeng@intel.com>
Subject: Re: [PATCH V2 1/6] MdePkg UefiLib: Add new EfiLocateXXXAcpiTable() APIs
Date: Mon, 17 Sep 2018 07:13:34 +0000	[thread overview]
Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103BBBA816@shsmsx102.ccr.corp.intel.com> (raw)
In-Reply-To: <2bfceb92-7940-426c-2615-21d54c9794c5@Intel.com>

Ray,

Thanks for the good feedbacks.
I can remove the ASSERT and update the description in the function header.
I can also merge ScanTableInRSDT and ScanTableInXSDT.

Thanks,
Star
-----Original Message-----
From: Ni, Ruiyu 
Sent: Friday, September 14, 2018 12:41 PM
To: Zeng, Star <star.zeng@intel.com>; edk2-devel@lists.01.org
Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Younas khan <pmdyounaskhan786@gmail.com>; Yao, Jiewen <jiewen.yao@intel.com>; Gao, Liming <liming.gao@intel.com>
Subject: Re: [edk2] [PATCH V2 1/6] MdePkg UefiLib: Add new EfiLocateXXXAcpiTable() APIs

Star,
I have two comments. see below.
On 9/13/2018 6:26 PM, Star Zeng wrote:
> https://bugzilla.tianocore.org/show_bug.cgi?id=967
> Request to add a library function for GetAcpiTable() in order to get 
> ACPI table using signature as input.
> 
> After evaluation, we found there are many duplicated code to find ACPI 
> table by signature in different modules.
> 
> This patch adds new EfiLocateXXXAcpiTable() APIs in UefiLib for the 
> request and also the following patch to remove the duplicated code.
> 
> Cc: Younas khan <pmdyounaskhan786@gmail.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Star Zeng <star.zeng@intel.com>
> ---
>   MdePkg/Include/Library/UefiLib.h   |  68 ++++++
>   MdePkg/Library/UefiLib/Acpi.c      | 488 +++++++++++++++++++++++++++++++++++++
>   MdePkg/Library/UefiLib/UefiLib.inf |   3 +
>   3 files changed, 559 insertions(+)
>   create mode 100644 MdePkg/Library/UefiLib/Acpi.c
> 
> diff --git a/MdePkg/Include/Library/UefiLib.h 
> b/MdePkg/Include/Library/UefiLib.h
> index f80067f11103..cf82ff4a920a 100644
> --- a/MdePkg/Include/Library/UefiLib.h
> +++ b/MdePkg/Include/Library/UefiLib.h
> @@ -26,6 +26,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
>   #ifndef __UEFI_LIB_H__
>   #define __UEFI_LIB_H__
>   
> +#include <IndustryStandard/Acpi.h>
> +
>   #include <Protocol/DriverBinding.h>
>   #include <Protocol/DriverConfiguration.h>
>   #include <Protocol/ComponentName.h>
> @@ -1595,4 +1597,70 @@ EfiOpenFileByDevicePath (
>     IN     UINT64                    OpenMode,
>     IN     UINT64                    Attributes
>     );
> +
> +/**
> +  This function locates next ACPI table in XSDT/RSDT based on 
> +Signature and
> +  previous returned Table.
> +
> +  If PreviousTable is NULL:
> +  This function will locate the first ACPI table in XSDT/RSDT based 
> + on  Signature in gEfiAcpi20TableGuid system configuration table 
> + first, and then  gEfiAcpi10TableGuid system configuration table.
> +  This function will locate in XSDT first, and then RSDT.
> +  For DSDT, this function will locate XDsdt in FADT first, and then 
> + Dsdt in  FADT.
> +  For FACS, this function will locate XFirmwareCtrl in FADT first, 
> + and then  FirmwareCtrl in FADT.
> +
> +  If PreviousTable is not NULL:
> +  1. If it could be located in XSDT in gEfiAcpi20TableGuid system configuration
> +     table, then this function will just locate next table in XSDT in
> +     gEfiAcpi20TableGuid system configuration table.
> +  2. If it could be located in RSDT in gEfiAcpi20TableGuid system configuration
> +     table, then this function will just locate next table in RSDT in
> +     gEfiAcpi20TableGuid system configuration table.
> +  3. If it could be located in RSDT in gEfiAcpi10TableGuid system configuration
> +     table, then this function will just locate next table in RSDT in
> +     gEfiAcpi10TableGuid system configuration table.
> +

1. I don't see difference between the case when PreviousTable is NULL or not. We don't need to distinguish between the two cases in above comments.


> +  If PreviousTable is not NULL and PreviousTable->Signature is not same with
> +  Signature, then ASSERT.
I'd suggest to return Invalid Parameter instead of assertion.

> +
> +  @param Signature          ACPI table signature.
> +  @param PreviousTable      Pointer to previous returned table to locate next
> +                            table, or NULL to locate first table.
> +
> +  @return Next ACPI table or NULL if not found.
> +
> +**/
> +EFI_ACPI_COMMON_HEADER *
> +EFIAPI
> +EfiLocateNextAcpiTable (
> +  IN UINT32                     Signature,
> +  IN EFI_ACPI_COMMON_HEADER     *PreviousTable OPTIONAL
> +  );
> +
> +/**
> +  This function locates first ACPI table in XSDT/RSDT based on Signature.
> +
> +  This function will locate the first ACPI table in XSDT/RSDT based on
> +  Signature in gEfiAcpi20TableGuid system configuration table first, and then
> +  gEfiAcpi10TableGuid system configuration table.
> +  This function will locate in XSDT first, and then RSDT.
> +  For DSDT, this function will locate XDsdt in FADT first, and then Dsdt in
> +  FADT.
> +  For FACS, this function will locate XFirmwareCtrl in FADT first, and then
> +  FirmwareCtrl in FADT.
> +
> +  @param Signature          ACPI table signature.
> +
> +  @return First ACPI table or NULL if not found.
> +
> +**/
> +EFI_ACPI_COMMON_HEADER *
> +EFIAPI
> +EfiLocateFirstAcpiTable (
> +  IN UINT32                     Signature
> +  );
> +
>   #endif
> diff --git a/MdePkg/Library/UefiLib/Acpi.c b/MdePkg/Library/UefiLib/Acpi.c
> new file mode 100644
> index 000000000000..0793bbdc787f
> --- /dev/null
> +++ b/MdePkg/Library/UefiLib/Acpi.c
> @@ -0,0 +1,488 @@
> +/** @file
> +  This module provides help function for finding ACPI table.
> +
> +  Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
> +  This program and the accompanying materials
> +  are licensed and made available under the terms and conditions of the BSD License
> +  which accompanies this distribution.  The full text of the license may be found at
> +  http://opensource.org/licenses/bsd-license.php.
> +
> +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +
> +**/
> +
> +#include "UefiLibInternal.h"
> +#include <IndustryStandard/Acpi.h>
> +#include <Guid/Acpi.h>
> +
> +/**
> +  This function scans ACPI table in RSDT.
> +
> +  @param Rsdt                   ACPI RSDT.
> +  @param Signature              ACPI table signature.
> +  @param PreviousTable          Pointer to previous returned table to locate
> +                                next table, or NULL to locate first table.
> +  @param PreviousTableLocated   Pointer to the indicator about whether the
> +                                previous returned table could be located, or
> +                                NULL if PreviousTable is NULL.
> +
> +  If PreviousTable is NULL and PreviousTableLocated is not NULL, then ASSERT().
> +  If PreviousTable is not NULL and PreviousTableLocated is NULL, then ASSERT().
> +
> +  @return ACPI table or NULL if not found.
> +
> +**/
> +EFI_ACPI_COMMON_HEADER *
> +ScanTableInRSDT (
> +  IN  EFI_ACPI_DESCRIPTION_HEADER   *Rsdt,
> +  IN  UINT32                        Signature,
> +  IN  EFI_ACPI_COMMON_HEADER        *PreviousTable, OPTIONAL
> +  OUT BOOLEAN                       *PreviousTableLocated OPTIONAL
> +  )
> +{
> +  UINTN                             Index;
> +  UINT32                            EntryCount;
> +  UINT32                            *EntryPtr;
> +  EFI_ACPI_COMMON_HEADER            *Table;
> +
> +  if (PreviousTableLocated != NULL) {
> +    ASSERT (PreviousTable != NULL);
> +    *PreviousTableLocated = FALSE;
> +  } else {
> +    ASSERT (PreviousTable == NULL);
> +  }
> +
> +  if (Rsdt == NULL) {
> +    return NULL;
> +  }
> +
> +  EntryCount = (Rsdt->Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER)) / sizeof(UINT32);
> +
> +  EntryPtr = (UINT32 *)(Rsdt + 1);
> +  for (Index = 0; Index < EntryCount; Index ++, EntryPtr ++) {
> +    Table = (EFI_ACPI_COMMON_HEADER *)((UINTN)(*EntryPtr));
> +    if (Table->Signature == Signature) {
> +      if (PreviousTable != NULL) {
> +        if (Table == PreviousTable) {
> +          *PreviousTableLocated = TRUE;
> +        } else if (*PreviousTableLocated) {
> +          //
> +          // Return next table.
> +          //
> +          return Table;
> +        }
> +      } else {
> +        //
> +        // Return first table.
> +        //
> +        return Table;
> +      }
> +    }
> +  }
> +
> +  return NULL;
> +}
> +
> +/**
> +  This function scans ACPI table in XSDT.
> +
> +  @param Xsdt                   ACPI XSDT.
> +  @param Signature              ACPI table signature.
> +  @param PreviousTable          Pointer to previous returned table to locate
> +                                next table, or NULL to locate first table.
> +  @param PreviousTableLocated   Pointer to the indicator about whether the
> +                                previous returned table could be located, or
> +                                NULL if PreviousTable is NULL.
> +
> +  If PreviousTable is NULL and PreviousTableLocated is not NULL, then ASSERT().
> +  If PreviousTable is not NULL and PreviousTableLocated is NULL, then ASSERT().
> +
> +  @return ACPI table or NULL if not found.
> +
> +**/
> +EFI_ACPI_COMMON_HEADER *
> +ScanTableInXSDT (
> +  IN  EFI_ACPI_DESCRIPTION_HEADER   *Xsdt,
> +  IN  UINT32                        Signature,
> +  IN  EFI_ACPI_COMMON_HEADER        *PreviousTable, OPTIONAL
> +  OUT BOOLEAN                       *PreviousTableLocated OPTIONAL
> +  )

2. Can we merge ScanTableInRSDT and ScanTableInXSDT?

> +{
> +  UINTN                             Index;
> +  UINT32                            EntryCount;
> +  UINT64                            EntryPtr;
> +  UINTN                             BasePtr;
> +  EFI_ACPI_COMMON_HEADER            *Table;
> +
> +  if (PreviousTableLocated != NULL) {
> +    ASSERT (PreviousTable != NULL);
> +    *PreviousTableLocated = FALSE;
> +  } else {
> +    ASSERT (PreviousTable == NULL);
> +  }
> +
> +  if (Xsdt == NULL) {
> +    return NULL;
> +  }
> +
> +  EntryCount = (Xsdt->Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER)) / sizeof(UINT64);
> +
> +  BasePtr = (UINTN)(Xsdt + 1);
> +  for (Index = 0; Index < EntryCount; Index ++) {
> +    CopyMem (&EntryPtr, (VOID *)(BasePtr + Index * sizeof(UINT64)), sizeof(UINT64));
> +    Table = (EFI_ACPI_COMMON_HEADER *)((UINTN)(EntryPtr));
> +    if (Table->Signature == Signature) {
> +      if (PreviousTable != NULL) {
> +        if (Table == PreviousTable) {
> +          *PreviousTableLocated = TRUE;
> +        } else if (*PreviousTableLocated) {
> +          //
> +          // Return next table.
> +          //
> +          return Table;
> +        }
> +      } else {
> +        //
> +        // Return first table.
> +        //
> +        return Table;
> +      }
> +
> +    }
> +  }
> +
> +  return NULL;
> +}
> +
> +/**
> +  To locate FACS in FADT.
> +
> +  @param Fadt   FADT table pointer.
> +
> +  @return FACS table pointer or NULL if not found.
> +
> +**/
> +EFI_ACPI_COMMON_HEADER *
> +LocateAcpiFacsFromFadt (
> +  IN EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE  *Fadt
> +  )
> +{
> +  EFI_ACPI_COMMON_HEADER                        *Facs;
> +  UINT64                                        Data64;
> +
> +  if (Fadt == NULL) {
> +    return NULL;
> +  }
> +
> +  if (Fadt->Header.Revision < EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE_REVISION) {
> +    Facs = (EFI_ACPI_COMMON_HEADER *)(UINTN)Fadt->FirmwareCtrl;
> +  } else {
> +    CopyMem (&Data64, &Fadt->XFirmwareCtrl, sizeof(UINT64));
> +    if (Data64 != 0) {
> +      Facs = (EFI_ACPI_COMMON_HEADER *)(UINTN)Data64;
> +    } else {
> +      Facs = (EFI_ACPI_COMMON_HEADER *)(UINTN)Fadt->FirmwareCtrl;
> +    }
> +  }
> +  return Facs;
> +}
> +
> +/**
> +  To locate DSDT in FADT.
> +
> +  @param Fadt   FADT table pointer.
> +
> +  @return DSDT table pointer or NULL if not found.
> +
> +**/
> +EFI_ACPI_COMMON_HEADER *
> +LocateAcpiDsdtFromFadt (
> +  IN EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE  *Fadt
> +  )
> +{
> +  EFI_ACPI_COMMON_HEADER                        *Dsdt;
> +  UINT64                                        Data64;
> +
> +  if (Fadt == NULL) {
> +    return NULL;
> +  }
> +
> +  if (Fadt->Header.Revision < EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE_REVISION) {
> +    Dsdt = (EFI_ACPI_COMMON_HEADER *)(UINTN)Fadt->Dsdt;
> +  } else {
> +    CopyMem (&Data64, &Fadt->XDsdt, sizeof(UINT64));
> +    if (Data64 != 0) {
> +      Dsdt = (EFI_ACPI_COMMON_HEADER *)(UINTN)Data64;
> +    } else {
> +      Dsdt = (EFI_ACPI_COMMON_HEADER *)(UINTN)Fadt->Dsdt;
> +    }
> +  }
> +  return Dsdt;
> +}
> +
> +/**
> +  To locate ACPI table in ACPI ConfigurationTable.
> +
> +  @param AcpiTableGuid          The GUID used to get ACPI ConfigurationTable.
> +  @param Signature              ACPI table signature.
> +  @param PreviousTable          Pointer to previous returned table to locate
> +                                next table, or NULL to locate first table.
> +  @param PreviousTableLocated   Pointer to the indicator to return whether the
> +                                previous returned table could be located or not,
> +                                or NULL if PreviousTable is NULL.
> +
> +  If PreviousTable is NULL and PreviousTableLocated is not NULL, then ASSERT().
> +  If PreviousTable is not NULL and PreviousTableLocated is NULL, then ASSERT().
> +  If AcpiGuid is NULL, then ASSERT().
> +
> +  @return ACPI table or NULL if not found.
> +
> +**/
> +EFI_ACPI_COMMON_HEADER *
> +LocateAcpiTableInAcpiConfigurationTable (
> +  IN  EFI_GUID                  *AcpiGuid,
> +  IN  UINT32                    Signature,
> +  IN  EFI_ACPI_COMMON_HEADER    *PreviousTable, OPTIONAL
> +  OUT BOOLEAN                   *PreviousTableLocated OPTIONAL
> +  )
> +{
> +  EFI_STATUS                                    Status;
> +  EFI_ACPI_COMMON_HEADER                        *Table;
> +  EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER  *Rsdp;
> +  EFI_ACPI_DESCRIPTION_HEADER                   *Rsdt;
> +  EFI_ACPI_DESCRIPTION_HEADER                   *Xsdt;
> +  EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE     *Fadt;
> +
> +  if (PreviousTableLocated != NULL) {
> +    ASSERT (PreviousTable != NULL);
> +    *PreviousTableLocated = FALSE;
> +  } else {
> +    ASSERT (PreviousTable == NULL);
> +  }
> +
> +  Rsdp = NULL;
> +  //
> +  // Get ACPI ConfigurationTable (RSD_PTR)
> +  //
> +  Status = EfiGetSystemConfigurationTable(AcpiGuid, (VOID **)&Rsdp);
> +  if (EFI_ERROR (Status) || (Rsdp == NULL)) {
> +    return NULL;
> +  }
> +
> +  Table = NULL;
> +
> +  //
> +  // Search XSDT
> +  //
> +  if (Rsdp->Revision >= EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION) {
> +    Xsdt = (EFI_ACPI_DESCRIPTION_HEADER *)(UINTN) Rsdp->XsdtAddress;
> +    if (Signature == EFI_ACPI_2_0_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE) {
> +      ASSERT (PreviousTable == NULL);
> +      //
> +      // It is to locate DSDT,
> +      // need to locate FADT first.
> +      //
> +      Fadt = (EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *) ScanTableInXSDT (
> +               Xsdt,
> +               EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE,
> +               NULL,
> +               NULL
> +               );
> +      Table = LocateAcpiDsdtFromFadt (Fadt);
> +    } else if (Signature == EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE) {
> +      ASSERT (PreviousTable == NULL);
> +      //
> +      // It is to locate FACS,
> +      // need to locate FADT first.
> +      //
> +      Fadt = (EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *) ScanTableInXSDT (
> +               Xsdt,
> +               EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE,
> +               NULL,
> +               NULL
> +               );
> +      Table = LocateAcpiFacsFromFadt (Fadt);
> +    } else {
> +      Table = ScanTableInXSDT (
> +                Xsdt,
> +                Signature,
> +                PreviousTable,
> +                PreviousTableLocated
> +                );
> +    }
> +  }
> +
> +  if (Table != NULL) {
> +    return Table;
> +  } else if ((PreviousTableLocated != NULL) &&
> +              *PreviousTableLocated) {
> +    //
> +    // PreviousTable could be located in XSDT,
> +    // but next table could not be located in XSDT.
> +    //
> +    return NULL;
> +  }
> +
> +  //
> +  // Search RSDT
> +  //
> +  Rsdt = (EFI_ACPI_DESCRIPTION_HEADER *)(UINTN) Rsdp->RsdtAddress;
> +  if (Signature == EFI_ACPI_2_0_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE) {
> +    ASSERT (PreviousTable == NULL);
> +    //
> +    // It is to locate DSDT,
> +    // need to locate FADT first.
> +    //
> +    Fadt = (EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *) ScanTableInRSDT (
> +             Rsdt,
> +             EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE,
> +             NULL,
> +             NULL
> +             );
> +    Table = LocateAcpiDsdtFromFadt (Fadt);
> +  } else if (Signature == EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE) {
> +    ASSERT (PreviousTable == NULL);
> +    //
> +    // It is to locate FACS,
> +    // need to locate FADT first.
> +    //
> +    Fadt = (EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *) ScanTableInRSDT (
> +             Rsdt,
> +             EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE,
> +             NULL,
> +             NULL
> +             );
> +    Table = LocateAcpiFacsFromFadt (Fadt);
> +  } else {
> +    Table = ScanTableInRSDT (
> +              Rsdt,
> +              Signature,
> +              PreviousTable,
> +              PreviousTableLocated
> +              );
> +  }
> +
> +  return Table;
> +}
> +
> +/**
> +  This function locates next ACPI table in XSDT/RSDT based on Signature and
> +  previous returned Table.
> +
> +  If PreviousTable is NULL:
> +  This function will locate the first ACPI table in XSDT/RSDT based on
> +  Signature in gEfiAcpi20TableGuid system configuration table first, and then
> +  gEfiAcpi10TableGuid system configuration table.
> +  This function will locate in XSDT first, and then RSDT.
> +  For DSDT, this function will locate XDsdt in FADT first, and then Dsdt in
> +  FADT.
> +  For FACS, this function will locate XFirmwareCtrl in FADT first, and then
> +  FirmwareCtrl in FADT.
> +
> +  If PreviousTable is not NULL:
> +  1. If it could be located in XSDT in gEfiAcpi20TableGuid system configuration
> +     table, then this function will just locate next table in XSDT in
> +     gEfiAcpi20TableGuid system configuration table.
> +  2. If it could be located in RSDT in gEfiAcpi20TableGuid system configuration
> +     table, then this function will just locate next table in RSDT in
> +     gEfiAcpi20TableGuid system configuration table.
> +  3. If it could be located in RSDT in gEfiAcpi10TableGuid system configuration
> +     table, then this function will just locate next table in RSDT in
> +     gEfiAcpi10TableGuid system configuration table.
> +
> +  If PreviousTable is not NULL and PreviousTable->Signature is not same with
> +  Signature, then ASSERT.
> +
> +  @param Signature          ACPI table signature.
> +  @param PreviousTable      Pointer to previous returned table to locate next
> +                            table, or NULL to locate first table.
> +
> +  @return Next ACPI table or NULL if not found.
> +
> +**/
> +EFI_ACPI_COMMON_HEADER *
> +EFIAPI
> +EfiLocateNextAcpiTable (
> +  IN UINT32                     Signature,
> +  IN EFI_ACPI_COMMON_HEADER     *PreviousTable OPTIONAL
> +  )
> +{
> +  EFI_ACPI_COMMON_HEADER        *Table;
> +  BOOLEAN                       TempPreviousTableLocated;
> +  BOOLEAN                       *PreviousTableLocated;
> +
> +  if (PreviousTable != NULL) {
> +    if (PreviousTable->Signature != Signature) {
> +      //
> +      // PreviousTable->Signature is not same with Signature.
> +      //
> +      ASSERT (FALSE);
> +      return NULL;
> +    } else if ((Signature == EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE) ||
> +               (Signature == EFI_ACPI_2_0_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE) ||
> +               (Signature == EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE)) {
> +      //
> +      // There is only one FADT/DSDT/FACS table,
> +      // so don't try to locate next one.
> +      //
> +      return NULL;
> +    }
> +
> +    PreviousTableLocated = &TempPreviousTableLocated;
> +    *PreviousTableLocated = FALSE;
> +  } else {
> +    PreviousTableLocated = NULL;
> +  }
> +
> +  Table = LocateAcpiTableInAcpiConfigurationTable (
> +            &gEfiAcpi20TableGuid,
> +            Signature,
> +            PreviousTable,
> +            PreviousTableLocated
> +            );
> +  if (Table != NULL) {
> +    return Table;
> +  } else if ((PreviousTableLocated != NULL) &&
> +              *PreviousTableLocated) {
> +    //
> +    // PreviousTable could be located in gEfiAcpi20TableGuid system
> +    // configuration table, but next table could not be located in
> +    // gEfiAcpi20TableGuid system configuration table.
> +    //
> +    return NULL;
> +  }
> +
> +  return LocateAcpiTableInAcpiConfigurationTable (
> +           &gEfiAcpi10TableGuid,
> +           Signature,
> +           PreviousTable,
> +           PreviousTableLocated
> +           );
> +}
> +
> +/**
> +  This function locates first ACPI table in XSDT/RSDT based on Signature.
> +
> +  This function will locate the first ACPI table in XSDT/RSDT based on
> +  Signature in gEfiAcpi20TableGuid system configuration table first, and then
> +  gEfiAcpi10TableGuid system configuration table.
> +  This function will locate in XSDT first, and then RSDT.
> +  For DSDT, this function will locate XDsdt in FADT first, and then Dsdt in
> +  FADT.
> +  For FACS, this function will locate XFirmwareCtrl in FADT first, and then
> +  FirmwareCtrl in FADT.
> +
> +  @param Signature          ACPI table signature.
> +
> +  @return First ACPI table or NULL if not found.
> +
> +**/
> +EFI_ACPI_COMMON_HEADER *
> +EFIAPI
> +EfiLocateFirstAcpiTable (
> +  IN UINT32                     Signature
> +  )
> +{
> +  return EfiLocateNextAcpiTable (Signature, NULL);
> +}
> diff --git a/MdePkg/Library/UefiLib/UefiLib.inf b/MdePkg/Library/UefiLib/UefiLib.inf
> index a6c739ef3d6d..aea20fe67153 100644
> --- a/MdePkg/Library/UefiLib/UefiLib.inf
> +++ b/MdePkg/Library/UefiLib/UefiLib.inf
> @@ -41,6 +41,7 @@ [Sources]
>     Console.c
>     UefiLib.c
>     UefiLibInternal.h
> +  Acpi.c
>   
>   
>   [Packages]
> @@ -62,6 +63,8 @@ [Guids]
>     gEfiEventReadyToBootGuid                      ## SOMETIMES_CONSUMES  ## Event
>     gEfiEventLegacyBootGuid                       ## SOMETIMES_CONSUMES  ## Event
>     gEfiGlobalVariableGuid                        ## SOMETIMES_CONSUMES  ## Variable
> +  gEfiAcpi20TableGuid                           ## SOMETIMES_CONSUMES  ## SystemTable
> +  gEfiAcpi10TableGuid                           ## SOMETIMES_CONSUMES  ## SystemTable
>   
>   [Protocols]
>     gEfiDriverBindingProtocolGuid                   ## SOMETIMES_PRODUCES
> 


-- 
Thanks,
Ray

  reply	other threads:[~2018-09-17  7:13 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-13 10:26 [PATCH V2 0/6] Add new EfiLocateXXXAcpiTable() APIs Star Zeng
2018-09-13 10:26 ` [PATCH V2 1/6] MdePkg UefiLib: " Star Zeng
2018-09-14  4:40   ` Ni, Ruiyu
2018-09-17  7:13     ` Zeng, Star [this message]
2018-09-13 10:26 ` [PATCH V2 2/6] IntelSiliconPkg IntelVTdDxe: Use new EfiLocateFirstAcpiTable() Star Zeng
2018-09-13 10:26 ` [PATCH V2 3/6] MdeModulePkg S3SaveStateDxe: " Star Zeng
2018-09-13 10:26 ` [PATCH V2 4/6] PcAtChipsetPkg PcRtc: " Star Zeng
2018-09-14  4:41   ` Ni, Ruiyu
2018-09-14  4:42     ` Ni, Ruiyu
2018-09-13 10:26 ` [PATCH V2 5/6] ShellPkg DpDynamicCommand: " Star Zeng
2018-09-17  6:54   ` Ni, Ruiyu
2018-09-13 10:27 ` [PATCH V2 6/6] UefiCpuPkg PiSmmCpuDxeSmm: " Star Zeng
2018-09-13 10:38   ` Laszlo Ersek
2018-09-14  0:19   ` Dong, Eric

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=0C09AFA07DD0434D9E2A0C6AEB0483103BBBA816@shsmsx102.ccr.corp.intel.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