diff mbox

[edk2] MdeModulePkg: support for ACPI tables only above 4GB's

Message ID BY1PR12MB0520274ABD75B16F51C4D411F9870@BY1PR12MB0520.namprd12.prod.outlook.com
State New
Headers show

Commit Message

Duran, Leo March 29, 2016, 3:32 p.m. UTC
All,

Please ignore (do not review/apply) this patch, as it pertains to the proposed "PcdAcpiNo32BitAddressSupport".
I will follow-up with single line change that I found to be required.

Thanks,
Leo.

-----Original Message-----
From: Duran, Leo 

Sent: Thursday, March 24, 2016 3:30 PM
To: edk2-devel@lists.01.org
Cc: ard.biesheuvel@linaro.org; leif.lindholm@linaro.org; Leendert van Doorn; Duran, Leo
Subject: [PATCH] MdeModulePkg: support for ACPI tables only above 4GB's

From: Leendert van Doorn <leendert@paramecium.org>


Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Leo Duran <leo.duran@amd.com>

---
 MdeModulePkg/MdeModulePkg.dec                      |  6 ++++
 .../Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf   |  3 +-
 .../Acpi/AcpiTableDxe/AcpiTableProtocol.c          | 41 ++++++++++++++--------
 3 files changed, 35 insertions(+), 15 deletions(-)

       //
       // Update pointers in FADT.  If tables don't exist this will put NULL pointers there.
       //
-      AcpiTableInstance->Fadt1->FirmwareCtrl  = (UINT32) (UINTN) AcpiTableInstance->Facs1;
-      AcpiTableInstance->Fadt1->Dsdt          = (UINT32) (UINTN) AcpiTableInstance->Dsdt1;
+      if (!FeaturePcdGet (PcdAcpiNo32BitAddressSupport)) {
+        AcpiTableInstance->Fadt1->FirmwareCtrl  = (UINT32) (UINTN) AcpiTableInstance->Facs1;
+        AcpiTableInstance->Fadt1->Dsdt          = (UINT32) (UINTN) AcpiTableInstance->Dsdt1;
+      }
 
       //
       // RSDP OEM information is updated to match the FADT OEM information @@ -633,7 +637,8 @@ AddTableToList (
       // Note: If the FIRMWARE_CTRL is non-zero, then X_FIRMWARE_CTRL must be zero, and 
       // vice-versa.
       //
-      if ((UINT64)(UINTN)AcpiTableInstance->Facs3 < BASE_4GB) {
+      if (!FeaturePcdGet (PcdAcpiNo32BitAddressSupport) &&
+         (UINT64)(UINTN)AcpiTableInstance->Facs3 < BASE_4GB) {
         AcpiTableInstance->Fadt3->FirmwareCtrl  = (UINT32) (UINTN) AcpiTableInstance->Facs3;
         ZeroMem (&AcpiTableInstance->Fadt3->XFirmwareCtrl, sizeof (UINT64));
       } else {
@@ -645,7 +650,8 @@ AddTableToList (
           );
         AcpiTableInstance->Fadt3->FirmwareCtrl = 0;
       }
-      if ((UINT64)(UINTN)AcpiTableInstance->Dsdt3 < BASE_4GB) {
+      if (!FeaturePcdGet (PcdAcpiNo32BitAddressSupport) &&
+         (UINT64)(UINTN)AcpiTableInstance->Dsdt3 < BASE_4GB) {
         AcpiTableInstance->Fadt3->Dsdt  = (UINT32) (UINTN) AcpiTableInstance->Dsdt3;
         ZeroMem (&AcpiTableInstance->Fadt3->XDsdt, sizeof (UINT64));
       } else {
@@ -741,7 +747,8 @@ AddTableToList (
       // If FADT already exists, update table pointers.
       //
       if (AcpiTableInstance->Fadt1 != NULL) {
-        AcpiTableInstance->Fadt1->FirmwareCtrl = (UINT32) (UINTN) AcpiTableInstance->Facs1;
+        if (!FeaturePcdGet (PcdAcpiNo32BitAddressSupport))
+          AcpiTableInstance->Fadt1->FirmwareCtrl = (UINT32) (UINTN) 
+ AcpiTableInstance->Facs1;
 
         //
         // Checksum FADT table
@@ -769,7 +776,8 @@ AddTableToList (
         // Note: If the FIRMWARE_CTRL is non-zero, then X_FIRMWARE_CTRL must be zero, and 
         // vice-versa.
         //
-        if ((UINT64)(UINTN)AcpiTableInstance->Facs3 < BASE_4GB) {
+        if (!FeaturePcdGet (PcdAcpiNo32BitAddressSupport) &&
+            (UINT64)(UINTN)AcpiTableInstance->Facs3 < BASE_4GB) {
           AcpiTableInstance->Fadt3->FirmwareCtrl  = (UINT32) (UINTN) AcpiTableInstance->Facs3;
           ZeroMem (&AcpiTableInstance->Fadt3->XFirmwareCtrl, sizeof (UINT64));
         } else {
@@ -825,7 +833,8 @@ AddTableToList (
       // If FADT already exists, update table pointers.
       //
       if (AcpiTableInstance->Fadt1 != NULL) {
-        AcpiTableInstance->Fadt1->Dsdt = (UINT32) (UINTN) AcpiTableInstance->Dsdt1;
+        if (!FeaturePcdGet (PcdAcpiNo32BitAddressSupport))
+          AcpiTableInstance->Fadt1->Dsdt = (UINT32) (UINTN) 
+ AcpiTableInstance->Dsdt1;
 
         //
         // Checksum FADT table
@@ -849,7 +858,8 @@ AddTableToList (
       // If FADT already exists, update table pointers.
       //
       if (AcpiTableInstance->Fadt3 != NULL) {
-        if ((UINT64)(UINTN)AcpiTableInstance->Dsdt3 < BASE_4GB) {
+        if (!FeaturePcdGet (PcdAcpiNo32BitAddressSupport) &&
+           (UINT64)(UINTN)AcpiTableInstance->Dsdt3 < BASE_4GB) {
           AcpiTableInstance->Fadt3->Dsdt  = (UINT32) (UINTN) AcpiTableInstance->Dsdt3;
         }
         Buffer64                          = (UINT64) (UINTN) AcpiTableInstance->Dsdt3;
@@ -1645,7 +1655,8 @@ AcpiTableAcpiTableConstructor (
   // If ACPI v1.0b is among the ACPI versions we aim to support, we have to
   // ensure that all memory allocations are below 4 GB.
   //
-  if ((PcdGet32 (PcdAcpiExposedTableVersions) & EFI_ACPI_TABLE_VERSION_1_0B) != 0) {
+  if (!FeaturePcdGet (PcdAcpiNo32BitAddressSupport) &&
+     (PcdGet32 (PcdAcpiExposedTableVersions) & 
+ EFI_ACPI_TABLE_VERSION_1_0B) != 0) {
     mAcpiTableAllocType = AllocateMaxAddress;
   } else {
     mAcpiTableAllocType = AllocateAnyPages; @@ -1744,7 +1755,8 @@ AcpiTableAcpiTableConstructor (
     CopyMem (&AcpiTableInstance->Rsdp1->Signature, &CurrentData, sizeof (UINT64));
     CopyMem (AcpiTableInstance->Rsdp1->OemId, PcdGetPtr (PcdAcpiDefaultOemId), sizeof (AcpiTableInstance->Rsdp1->OemId));
     AcpiTableInstance->Rsdp1->Reserved    = EFI_ACPI_RESERVED_BYTE;
-    AcpiTableInstance->Rsdp1->RsdtAddress = (UINT32) (UINTN) AcpiTableInstance->Rsdt1;
+    if (!FeaturePcdGet (PcdAcpiNo32BitAddressSupport))
+      AcpiTableInstance->Rsdp1->RsdtAddress = (UINT32) (UINTN) 
+ AcpiTableInstance->Rsdt1;
   }
 
   CurrentData = EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER_SIGNATURE;
@@ -1752,7 +1764,8 @@ AcpiTableAcpiTableConstructor (
   CopyMem (AcpiTableInstance->Rsdp3->OemId, PcdGetPtr (PcdAcpiDefaultOemId), sizeof (AcpiTableInstance->Rsdp3->OemId));
   AcpiTableInstance->Rsdp3->Revision    = EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION;
   AcpiTableInstance->Rsdp3->Length      = sizeof (EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER);
-  if ((PcdGet32 (PcdAcpiExposedTableVersions) & EFI_ACPI_TABLE_VERSION_1_0B) != 0) {
+  if (!FeaturePcdGet (PcdAcpiNo32BitAddressSupport) &&
+     (PcdGet32 (PcdAcpiExposedTableVersions) & 
+ EFI_ACPI_TABLE_VERSION_1_0B) != 0) {
     AcpiTableInstance->Rsdp3->RsdtAddress = (UINT32) (UINTN) AcpiTableInstance->Rsdt3;
   }
   CurrentData = (UINT64) (UINTN) AcpiTableInstance->Xsdt;
--
1.9.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
diff mbox

Patch

diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index 1a20561..61db352 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -651,6 +651,12 @@ 
   # @Prompt Enable PEI StatusCode replay in DXE phase
   gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeReplayIn|FALSE|BOOLEAN|0x0001002d
 
+  ## Indicates if ACPI will create an RSDT and XSDT table.<BR><BR>  ## 
+ The RSDT contains 32-bit points and hence has to lie in 0-4GB 
+ memory.<BR>  ## Setting this to TRUE will only generate an XSDT with 
+ 64-bit pointers.<BR>  # @Prompt Enable ACPI 64-bit pointers.
+  
+ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiNo32BitAddressSupport|FALSE|BOOL
+ EAN|0x0001002e
+
   ## Indicates if ACPI SDT protocol will be installed.<BR><BR>
   #   TRUE  - Installs ACPI SDT protocol.<BR>
   #   FALSE - Does not install ACPI SDT protocol.<BR>
diff --git a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
index 3ec39c0..aff7599 100644
--- a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
+++ b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
@@ -60,7 +60,8 @@ 
   gEfiAcpiTableGuid                             ## PRODUCES ## SystemTable
 
 [FeaturePcd]
-  gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol  ## CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol      ## CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiNo32BitAddressSupport   ## CONSUMES
 
 [Pcd]
   gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemId            ## CONSUMES
diff --git a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c
index 7f95b9d..7872c2b 100644
--- a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c
+++ b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c
@@ -167,7 +167,8 @@  PublishTables (
   // Add the RSD_PTR to the system table and store that we have installed the
   // tables.
   //
-  if ((Version & EFI_ACPI_TABLE_VERSION_1_0B) != 0) {
+  if (!FeaturePcdGet (PcdAcpiNo32BitAddressSupport) &&
+     (Version & EFI_ACPI_TABLE_VERSION_1_0B) != 0) {
     Status = gBS->InstallConfigurationTable (&gEfiAcpi10TableGuid, AcpiTableInstance->Rsdp1);
     if (EFI_ERROR (Status)) {
       return EFI_ABORTED;
@@ -393,7 +394,8 @@  ReallocateAcpiTableBuffer (
   //
   // Update RSDP to point to the new Rsdt and Xsdt address.
   //
-  if ((PcdGet32 (PcdAcpiExposedTableVersions) & EFI_ACPI_TABLE_VERSION_1_0B) != 0) {
+  if (!FeaturePcdGet (PcdAcpiNo32BitAddressSupport) &&
+     (PcdGet32 (PcdAcpiExposedTableVersions) & 
+ EFI_ACPI_TABLE_VERSION_1_0B) != 0) {
     AcpiTableInstance->Rsdp1->RsdtAddress = (UINT32) (UINTN) AcpiTableInstance->Rsdt1;
     AcpiTableInstance->Rsdp3->RsdtAddress = (UINT32) (UINTN) AcpiTableInstance->Rsdt3;
   }
@@ -518,7 +520,7 @@  AddTableToList (
     //
     ASSERT ((EFI_PAGE_SIZE % 64) == 0);
     Status = gBS->AllocatePages (
-                    AllocateMaxAddress,
+                    mAcpiTableAllocType,
                     EfiACPIMemoryNVS,
                     CurrentTableList->NumberOfPages,
                     &CurrentTableList->PageAddress @@ -593,8 +595,10 @@ AddTableToList (