public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH 0/2] Let AcpiTableDxe driver install Acpi table from Hob
@ 2021-03-23  2:49 Zhiguang Liu
  2021-03-23  2:49 ` [PATCH 1/2] MdeModulePkg/ACPI: Install ACPI table from HOB Zhiguang Liu
  2021-03-23  2:49 ` [PATCH 2/2] UefiPayloadPkg: Remove code that installs APCI Zhiguang Liu
  0 siblings, 2 replies; 3+ messages in thread
From: Zhiguang Liu @ 2021-03-23  2:49 UTC (permalink / raw)
  To: devel
  Cc: Jian J Wang, Hao A Wu, Dandan Bi, Liming Gao, Maurice Ma,
	Guo Dong, Benjamin You, Ray Ni

If HOB contains APCI table information, entry point of AcpiTableDxe.inf
should parse the APCI table from HOB, and install these tables.
We assume the whole ACPI table (starting with EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER)
is contained by a single gEfiAcpiTableGuid HOB.
This way, for UefiPayloadPkg, there is no need to specially hanle acpi table.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Guo Dong <guo.dong@intel.com>
Cc: Benjamin You <benjamin.you@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Zhiguang Liu (2):
  MdeModulePkg/ACPI: Install ACPI table from HOB.
  UefiPayloadPkg: Remove code that installs APCI

 MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf    |   3 ++-
 MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c | 134 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------
 UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c                   |  13 ++-----------
 UefiPayloadPkg/BlSupportDxe/BlSupportDxe.h                   |   5 +----
 UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf                 |   5 ++---
 5 files changed, 133 insertions(+), 27 deletions(-)

-- 
2.30.0.windows.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] MdeModulePkg/ACPI: Install ACPI table from HOB.
  2021-03-23  2:49 [PATCH 0/2] Let AcpiTableDxe driver install Acpi table from Hob Zhiguang Liu
@ 2021-03-23  2:49 ` Zhiguang Liu
  2021-03-23  2:49 ` [PATCH 2/2] UefiPayloadPkg: Remove code that installs APCI Zhiguang Liu
  1 sibling, 0 replies; 3+ messages in thread
From: Zhiguang Liu @ 2021-03-23  2:49 UTC (permalink / raw)
  To: devel; +Cc: Jian J Wang, Hao A Wu, Dandan Bi, Liming Gao, Ray Ni

If HOB contains APCI table information, entry point of AcpiTableDxe.inf
should parse the APCI table from HOB, and install these tables.
We assume the whole ACPI table (starting with EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER)
is contained by a single gEfiAcpiTableGuid HOB.


Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
---
 MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf    |   3 ++-
 MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c | 134 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------
 2 files changed, 128 insertions(+), 9 deletions(-)

diff --git a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
index d341df439e..473127368d 100644
--- a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
+++ b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
@@ -4,7 +4,7 @@
 #  This driver initializes ACPI tables (Rsdp, Rsdt and Xsdt) and produces UEFI/PI
 #  services to install/uninstall/manage ACPI tables.
 #
-#  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
+#  Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.<BR>
 #  Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -51,6 +51,7 @@
   DebugLib
   BaseLib
   PcdLib
+  HobLib
 
 [Guids]
   gEfiAcpi10TableGuid                           ## PRODUCES ## SystemTable
diff --git a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c
index 5a2afdff27..6b58759620 100644
--- a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c
+++ b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c
@@ -1,7 +1,7 @@
 /** @file
   ACPI Table Protocol Implementation
 
-  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.<BR>
   Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -11,6 +11,8 @@
 // Includes
 //
 #include "AcpiTable.h"
+#include <Library/HobLib.h>
+
 //
 // The maximum number of tables that pre-allocated.
 //
@@ -30,6 +32,7 @@ STATIC EFI_ALLOCATE_TYPE      mAcpiTableAllocType;
   @param  Table                     Table to add.
   @param  Checksum                  Does the table require checksumming.
   @param  Version                   The version of the list to add the table to.
+  @param  IsFromHob                 True, if add Apci Table from Hob List.
   @param  Handle                    Pointer for returning the handle.
 
   @return EFI_SUCCESS               The function completed successfully.
@@ -44,6 +47,7 @@ AddTableToList (
   IN VOID                                 *Table,
   IN BOOLEAN                              Checksum,
   IN EFI_ACPI_TABLE_VERSION               Version,
+  IN BOOLEAN                              IsFromHob,
   OUT UINTN                               *Handle
   );
 
@@ -238,6 +242,7 @@ InstallAcpiTable (
              AcpiTableBufferConst,
              TRUE,
              Version,
+             FALSE,
              TableKey
              );
   if (!EFI_ERROR (Status)) {
@@ -472,6 +477,7 @@ FreeTableMemory (
   @param  Table                     Table to add.
   @param  Checksum                  Does the table require checksumming.
   @param  Version                   The version of the list to add the table to.
+  @param  IsFromHob                 True, if add Apci Table from Hob List.
   @param  Handle                    Pointer for returning the handle.
 
   @return EFI_SUCCESS               The function completed successfully.
@@ -487,6 +493,7 @@ AddTableToList (
   IN VOID                                 *Table,
   IN BOOLEAN                              Checksum,
   IN EFI_ACPI_TABLE_VERSION               Version,
+  IN BOOLEAN                              IsFromHob,
   OUT UINTN                               *Handle
   )
 {
@@ -552,13 +559,17 @@ AddTableToList (
     // could be updated by OS present agent. For example, BufferPtrAddress in
     // SMM communication ACPI table.
     //
-    ASSERT ((EFI_PAGE_SIZE % 64) == 0);
-    Status = gBS->AllocatePages (
-                    AllocateMaxAddress,
-                    EfiACPIMemoryNVS,
-                    EFI_SIZE_TO_PAGES (CurrentTableList->TableSize),
-                    &AllocPhysAddress
-                    );
+    if (IsFromHob){
+      AllocPhysAddress = (UINTN)Table;
+    } else {
+      ASSERT ((EFI_PAGE_SIZE % 64) == 0);
+      Status = gBS->AllocatePages (
+                      AllocateMaxAddress,
+                      EfiACPIMemoryNVS,
+                      EFI_SIZE_TO_PAGES (CurrentTableList->TableSize),
+                      &AllocPhysAddress
+                      );
+    }
   } else if (mAcpiTableAllocType == AllocateAnyPages) {
     //
     // If there is no allocation limit, there is also no need to use page
@@ -1689,6 +1700,111 @@ ChecksumCommonTables (
   return EFI_SUCCESS;
 }
 
+/**
+  This function will find Guid Hob gEfiAcpiTableGuid, and install Acpi table from it.
+
+  @param  AcpiTableInstance  Protocol instance private data.
+
+  @return EFI_SUCCESS        The function completed successfully.
+  @return EFI_NOT_FOUND      The function doesn't find the gEfiAcpiTableGuid Guid Hob.
+  @return EFI_ABORTED        The function could not complete successfully.
+
+**/
+EFI_STATUS
+InstallAcpiTableFromHob (
+  EFI_ACPI_TABLE_INSTANCE                   *AcpiTableInstance
+  )
+{
+  EFI_HOB_GUID_TYPE                             *GuidHob;
+  EFI_ACPI_TABLE_VERSION                        Version;
+  EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER  *Rsdp;
+  EFI_ACPI_DESCRIPTION_HEADER                   *Rsdt;
+  EFI_ACPI_DESCRIPTION_HEADER                   *ChildTable;
+  UINT64                                        ChildTableAddress;
+  UINTN                                         Count;
+  UINTN                                         Index;
+  UINTN                                         TableKey;
+  EFI_STATUS                                    Status;
+  UINTN                                         EntrySize;
+
+  TableKey = 0;
+  Version = PcdGet32 (PcdAcpiExposedTableVersions);
+
+  //
+  // HOB only contains the ACPI table in 2.0+ format.
+  //
+  GuidHob = GetFirstGuidHob (&gEfiAcpiTableGuid);
+  if (GuidHob == NULL) {
+    return EFI_NOT_FOUND;
+  }
+  Rsdp = (EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER*) (UINTN)(*((UINT64*)GET_GUID_HOB_DATA (GuidHob)));
+
+  //
+  // An ACPI-compatible OS must use the XSDT if present.
+  // It shouldn't happen that XsdtAddress points beyond 4G range in 32-bit environment.
+  //
+  ASSERT ((UINTN) Rsdp->XsdtAddress == Rsdp->XsdtAddress);
+
+  EntrySize = sizeof (UINT64);
+  Rsdt = (EFI_ACPI_DESCRIPTION_HEADER*) (UINTN) Rsdp->XsdtAddress;
+  if (Rsdt == NULL) {
+    //
+    // XsdtAddress is zero, then we use Rsdt which has 32 bit entry
+    //
+    Rsdt = (EFI_ACPI_DESCRIPTION_HEADER*) (UINTN) Rsdp->RsdtAddress;
+    EntrySize = sizeof (UINT32);
+  }
+  Count = (Rsdt->Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER))/EntrySize;
+
+  for (Index = 0; Index < Count; Index++){
+    ChildTableAddress = 0;
+    CopyMem(&ChildTableAddress, (VOID*)((UINTN) Rsdt + EntrySize * Index + sizeof (EFI_ACPI_DESCRIPTION_HEADER)), EntrySize);
+    //
+    // If the address is of UINT64 while this module runs at 32 bits,
+    // make sure the upper bits are all-zeros.
+    //
+    ASSERT (ChildTableAddress == (UINTN) ChildTableAddress);
+
+    ChildTable = (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) ChildTableAddress;
+    Status = AddTableToList (
+              AcpiTableInstance,
+              ChildTable,
+              TRUE,
+              Version,
+              TRUE,
+              &TableKey
+              );
+    if (ChildTable->Signature == EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE){
+      //
+      // Add the FACS and DSDT tables.
+      //
+      Status = AddTableToList (
+                AcpiTableInstance,
+                (VOID *) (UINTN)((EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE*)ChildTable)->FirmwareCtrl,
+                TRUE,
+                Version,
+                TRUE,
+                &TableKey
+                );
+      Status = AddTableToList (
+                AcpiTableInstance,
+                (VOID *) (UINTN)((EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE*)ChildTable)->Dsdt,
+                TRUE,
+                Version,
+                TRUE,
+                &TableKey
+                );
+    }
+  }
+  if (!EFI_ERROR (Status)) {
+    Status = PublishTables (
+              AcpiTableInstance,
+              Version
+              );
+  }
+  ASSERT_EFI_ERROR (Status);
+  return Status;
+}
 
 /**
   Constructor for the ACPI table protocol.  Initializes instance
@@ -1918,6 +2034,8 @@ AcpiTableAcpiTableConstructor (
 
   ChecksumCommonTables (AcpiTableInstance);
 
+  InstallAcpiTableFromHob (AcpiTableInstance);
+
   //
   // Completed successfully
   //
-- 
2.30.0.windows.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] UefiPayloadPkg: Remove code that installs APCI
  2021-03-23  2:49 [PATCH 0/2] Let AcpiTableDxe driver install Acpi table from Hob Zhiguang Liu
  2021-03-23  2:49 ` [PATCH 1/2] MdeModulePkg/ACPI: Install ACPI table from HOB Zhiguang Liu
@ 2021-03-23  2:49 ` Zhiguang Liu
  1 sibling, 0 replies; 3+ messages in thread
From: Zhiguang Liu @ 2021-03-23  2:49 UTC (permalink / raw)
  To: devel; +Cc: Maurice Ma, Guo Dong, Benjamin You, Ray Ni

MdeModulePkg\Universal\Acpi\AcpiTableDxe\AcpiTableDxe.inf is capable to install
ACPI table contained in HOB. All ACPI table shoulb be managed by that module.

Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Guo Dong <guo.dong@intel.com>
Cc: Benjamin You <benjamin.you@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
---
 UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c   | 13 ++-----------
 UefiPayloadPkg/BlSupportDxe/BlSupportDxe.h   |  5 +----
 UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf |  5 ++---
 3 files changed, 5 insertions(+), 18 deletions(-)

diff --git a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c
index a746d0581e..dfff8ecf0e 100644
--- a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c
+++ b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c
@@ -1,8 +1,8 @@
 /** @file
-  This driver will report some MMIO/IO resources to dxe core, extract smbios and acpi
+  This driver will report some MMIO/IO resources to dxe core, extract smbios
   tables from bootloader.
 
-  Copyright (c) 2014 - 2020, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.<BR>
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -120,15 +120,6 @@ BlDxeEntryPoint (
   ASSERT (GuidHob != NULL);
   SystemTableInfo = (SYSTEM_TABLE_INFO *)GET_GUID_HOB_DATA (GuidHob);
 
-  //
-  // Install Acpi Table
-  //
-  if (SystemTableInfo->AcpiTableBase != 0 && SystemTableInfo->AcpiTableSize != 0) {
-    DEBUG ((DEBUG_ERROR, "Install Acpi Table at 0x%lx, length 0x%x\n", SystemTableInfo->AcpiTableBase, SystemTableInfo->AcpiTableSize));
-    Status = gBS->InstallConfigurationTable (&gEfiAcpiTableGuid, (VOID *)(UINTN)SystemTableInfo->AcpiTableBase);
-    ASSERT_EFI_ERROR (Status);
-  }
-
   //
   // Install Smbios Table
   //
diff --git a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.h b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.h
index 512105fafd..3332a30eae 100644
--- a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.h
+++ b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.h
@@ -1,7 +1,7 @@
 /** @file
   The header file of bootloader support DXE.
 
-Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -19,12 +19,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include <Library/IoLib.h>
 #include <Library/HobLib.h>
 
-#include <Guid/Acpi.h>
 #include <Guid/SmBios.h>
 #include <Guid/SystemTableInfoGuid.h>
 #include <Guid/AcpiBoardInfoGuid.h>
 #include <Guid/GraphicsInfoHob.h>
 
-#include <IndustryStandard/Acpi.h>
-
 #endif
diff --git a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf
index cebc811355..ad4e0a57a1 100644
--- a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf
+++ b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf
@@ -1,9 +1,9 @@
 ## @file
 # Bootloader Support DXE Module
 #
-# Report some MMIO/IO resources to dxe core, extract smbios and acpi tables
+# Report some MMIO/IO resources to dxe core, extract smbios tables
 #
-#  Copyright (c) 2014 - 2020, Intel Corporation. All rights reserved.<BR>
+#  Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.<BR>
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -42,7 +42,6 @@
   HobLib
 
 [Guids]
-  gEfiAcpiTableGuid
   gEfiSmbiosTableGuid
   gUefiSystemTableInfoGuid
   gUefiAcpiBoardInfoGuid
-- 
2.30.0.windows.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-03-23  2:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-23  2:49 [PATCH 0/2] Let AcpiTableDxe driver install Acpi table from Hob Zhiguang Liu
2021-03-23  2:49 ` [PATCH 1/2] MdeModulePkg/ACPI: Install ACPI table from HOB Zhiguang Liu
2021-03-23  2:49 ` [PATCH 2/2] UefiPayloadPkg: Remove code that installs APCI Zhiguang Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox