[edk2-devel] [PATCH] MinPlatformPkg: Check if Acpi table is already installed.

kavya posted 1 patch 2 years, 4 months ago
Failed in applying to current master (apply log)
There is a newer version of this series
Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
[edk2-devel] [PATCH] MinPlatformPkg: Check if Acpi table is already installed.
Posted by kavya 2 years, 4 months ago
Check if Acpi table is already installed by locating the first ACPI table
in XSDT/RSDT based on Signature

Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Eric Dong <eric.dong@intel.com>
Signed-off-by: kavya <k.kavyax.sravanthi@intel.com>
---
 Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c b/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c
index 785cf4c2f9..db58cbe6ce 100644
--- a/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c
+++ b/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c
@@ -1048,12 +1048,21 @@ InstallMcfgFromScratch (
 {
   EFI_STATUS                                                                            Status;
   EFI_ACPI_MEMORY_MAPPED_CONFIGURATION_BASE_ADDRESS_TABLE_HEADER                        *McfgTable;
+  EFI_ACPI_COMMON_HEADER                                                                *Mcfg;
   EFI_ACPI_MEMORY_MAPPED_ENHANCED_CONFIGURATION_SPACE_BASE_ADDRESS_ALLOCATION_STRUCTURE *Segment;
   UINTN                                                                                 Index;
   UINTN                                                                                 SegmentCount;
   PCI_SEGMENT_INFO                                                                      *PciSegmentInfo;
   UINTN                                                                                 TableHandle;
 
+  Mcfg = (EFI_ACPI_COMMON_HEADER *) EfiLocateFirstAcpiTable (
+                                      EFI_ACPI_3_0_PCI_EXPRESS_MEMORY_MAPPED_CONFIGURATION_SPACE_BASE_ADDRESS_DESCRIPTION_TABLE_SIGNATURE
+                                      );
+  if (Mcfg != NULL) {
+    DEBUG ((DEBUG_ERROR, "MCFG table already installed\n"));
+    return EFI_SUCCESS;
+  }
+
   PciSegmentInfo = GetPciSegmentInfo (&SegmentCount);
 
   McfgTable = AllocateZeroPool (
@@ -1365,6 +1374,7 @@ UpdateLocalTable (
 {
   EFI_STATUS                    Status;
   EFI_ACPI_COMMON_HEADER        *CurrentTable;
+  EFI_ACPI_COMMON_HEADER        *Table;
   EFI_ACPI_TABLE_VERSION        Version;
   UINTN                         TableHandle;
   UINTN                         Index;
@@ -1372,6 +1382,14 @@ UpdateLocalTable (
   for (Index = 0; Index < sizeof(mLocalTable)/sizeof(mLocalTable[0]); Index++) {
     CurrentTable = mLocalTable[Index];
 
+    Table = (EFI_ACPI_COMMON_HEADER *) EfiLocateFirstAcpiTable (CurrentTable->Signature);
+    if (Table != NULL) {
+      DEBUG ((DEBUG_ERROR, "Acpi table with signature=%c%c%c%c already installed\n",
+            ((CHAR8*)&CurrentTable->Signature)[0], ((CHAR8*)&CurrentTable->Signature)[1],
+            ((CHAR8*)&CurrentTable->Signature)[2], ((CHAR8*)&CurrentTable->Signature)[3]));
+      continue;
+    }
+
     PlatformUpdateTables (CurrentTable, &Version);
 
     TableHandle = 0;
-- 
2.16.2.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#84374): https://edk2.groups.io/g/devel/message/84374
Mute This Topic: https://groups.io/mt/87534774/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-


Re: [edk2-devel] [PATCH] MinPlatformPkg: Check if Acpi table is already installed.
Posted by Zhiguang Liu 2 years, 4 months ago
Hi Kavya,
One minor comment.
Please change the DEBUG_ERROR to DEBUG_INFO.
With this modification, you can keep my Reviewed-by.
Reviewed-by: Zhiguang Liu <zhiguang.liu@intel.com>

________________________________
From: devel@edk2.groups.io <devel@edk2.groups.io> on behalf of kavya <k.kavyax.sravanthi@intel.com>
Sent: Monday, December 6, 2021 13:35
To: devel@edk2.groups.io <devel@edk2.groups.io>
Cc: Sravanthi, K KavyaX <k.kavyax.sravanthi@intel.com>; Chiu, Chasel <chasel.chiu@intel.com>; Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>; Liming Gao <gaoliming@byosoft.com.cn>; Dong, Eric <eric.dong@intel.com>
Subject: [edk2-devel] [PATCH] MinPlatformPkg: Check if Acpi table is already installed.

Check if Acpi table is already installed by locating the first ACPI table
in XSDT/RSDT based on Signature

Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Eric Dong <eric.dong@intel.com>
Signed-off-by: kavya <k.kavyax.sravanthi@intel.com>
---
 Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c b/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c
index 785cf4c2f9..db58cbe6ce 100644
--- a/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c
+++ b/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c
@@ -1048,12 +1048,21 @@ InstallMcfgFromScratch (
 {
   EFI_STATUS                                                                            Status;
   EFI_ACPI_MEMORY_MAPPED_CONFIGURATION_BASE_ADDRESS_TABLE_HEADER                        *McfgTable;
+  EFI_ACPI_COMMON_HEADER                                                                *Mcfg;
   EFI_ACPI_MEMORY_MAPPED_ENHANCED_CONFIGURATION_SPACE_BASE_ADDRESS_ALLOCATION_STRUCTURE *Segment;
   UINTN                                                                                 Index;
   UINTN                                                                                 SegmentCount;
   PCI_SEGMENT_INFO                                                                      *PciSegmentInfo;
   UINTN                                                                                 TableHandle;

+  Mcfg = (EFI_ACPI_COMMON_HEADER *) EfiLocateFirstAcpiTable (
+                                      EFI_ACPI_3_0_PCI_EXPRESS_MEMORY_MAPPED_CONFIGURATION_SPACE_BASE_ADDRESS_DESCRIPTION_TABLE_SIGNATURE
+                                      );
+  if (Mcfg != NULL) {
+    DEBUG ((DEBUG_ERROR, "MCFG table already installed\n"));
+    return EFI_SUCCESS;
+  }
+
   PciSegmentInfo = GetPciSegmentInfo (&SegmentCount);

   McfgTable = AllocateZeroPool (
@@ -1365,6 +1374,7 @@ UpdateLocalTable (
 {
   EFI_STATUS                    Status;
   EFI_ACPI_COMMON_HEADER        *CurrentTable;
+  EFI_ACPI_COMMON_HEADER        *Table;
   EFI_ACPI_TABLE_VERSION        Version;
   UINTN                         TableHandle;
   UINTN                         Index;
@@ -1372,6 +1382,14 @@ UpdateLocalTable (
   for (Index = 0; Index < sizeof(mLocalTable)/sizeof(mLocalTable[0]); Index++) {
     CurrentTable = mLocalTable[Index];

+    Table = (EFI_ACPI_COMMON_HEADER *) EfiLocateFirstAcpiTable (CurrentTable->Signature);
+    if (Table != NULL) {
+      DEBUG ((DEBUG_ERROR, "Acpi table with signature=%c%c%c%c already installed\n",
+            ((CHAR8*)&CurrentTable->Signature)[0], ((CHAR8*)&CurrentTable->Signature)[1],
+            ((CHAR8*)&CurrentTable->Signature)[2], ((CHAR8*)&CurrentTable->Signature)[3]));
+      continue;
+    }
+
     PlatformUpdateTables (CurrentTable, &Version);

     TableHandle = 0;
--
2.16.2.windows.1








-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#84375): https://edk2.groups.io/g/devel/message/84375
Mute This Topic: https://groups.io/mt/87534774/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-