]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/AcpiPlatformDxe/AcpiPlatform.c
Revert "OvmfPkg: link SM3 support into Tcg2Pei and Tcg2Dxe"
[mirror_edk2.git] / OvmfPkg / AcpiPlatformDxe / AcpiPlatform.c
index 0b05942f71cd34f05e48fa2cbc31483357304511..2b529d58a15c663cabefd7de1947de0e3649e37f 100644 (file)
@@ -2,13 +2,7 @@
   OVMF ACPI Platform Driver\r
 \r
   Copyright (c) 2008 - 2012, Intel Corporation. All rights reserved.<BR>\r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -78,12 +72,9 @@ LocateFvInstanceWithTables (
     return Status;\r
   }\r
 \r
-\r
-\r
   //\r
   // Looking for FV with ACPI storage file\r
   //\r
-\r
   for (Index = 0; Index < NumberOfHandles; Index++) {\r
     //\r
     // Get the protocol on this handle\r
@@ -133,83 +124,48 @@ LocateFvInstanceWithTables (
 \r
 \r
 /**\r
-  This function calculates and updates an UINT8 checksum.\r
-\r
-  @param  Buffer          Pointer to buffer to checksum\r
-  @param  Size            Number of bytes to checksum\r
-\r
-**/\r
-VOID\r
-AcpiPlatformChecksum (\r
-  IN UINT8      *Buffer,\r
-  IN UINTN      Size\r
-  )\r
-{\r
-  UINTN ChecksumOffset;\r
-\r
-  ChecksumOffset = OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER, Checksum);\r
+  Find ACPI tables in an FV and install them. \r
 \r
-  //\r
-  // Set checksum to 0 first\r
-  //\r
-  Buffer[ChecksumOffset] = 0;\r
+  This is now a fall-back path. Normally, we will search for tables provided\r
+  by the VMM first.\r
 \r
-  //\r
-  // Update checksum value\r
-  //\r
-  Buffer[ChecksumOffset] = CalculateCheckSum8(Buffer, Size);\r
-}\r
+  If that fails, we use this function to load the ACPI tables from an FV. The\r
+  sources for the FV based tables is located under OvmfPkg/AcpiTables.\r
 \r
-\r
-/**\r
-  Entrypoint of Acpi Platform driver.\r
-\r
-  @param  ImageHandle\r
-  @param  SystemTable\r
-\r
-  @return EFI_SUCCESS\r
-  @return EFI_LOAD_ERROR\r
-  @return EFI_OUT_OF_RESOURCES\r
+  @param  AcpiTable     Protocol instance pointer    \r
 \r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
-AcpiPlatformEntryPoint (\r
-  IN EFI_HANDLE         ImageHandle,\r
-  IN EFI_SYSTEM_TABLE   *SystemTable\r
+InstallOvmfFvTables (\r
+  IN  EFI_ACPI_TABLE_PROTOCOL     *AcpiTable\r
   )\r
 {\r
-  EFI_STATUS                         Status;\r
-  EFI_ACPI_TABLE_PROTOCOL            *AcpiTable;\r
-  EFI_FIRMWARE_VOLUME2_PROTOCOL      *FwVol;\r
-  INTN                               Instance;\r
-  EFI_ACPI_COMMON_HEADER             *CurrentTable;\r
-  UINTN                              TableHandle;\r
-  UINT32                             FvStatus;\r
-  UINTN                              TableSize;\r
-  UINTN                              Size;\r
-  EFI_ACPI_TABLE_INSTALL_ACPI_TABLE  TableInstallFunction;\r
+  EFI_STATUS                           Status;\r
+  EFI_FIRMWARE_VOLUME2_PROTOCOL        *FwVol;\r
+  INTN                                 Instance;\r
+  EFI_ACPI_COMMON_HEADER               *CurrentTable;\r
+  UINTN                                TableHandle;\r
+  UINT32                               FvStatus;\r
+  UINTN                                TableSize;\r
+  UINTN                                Size;\r
+  EFI_ACPI_TABLE_INSTALL_ACPI_TABLE    TableInstallFunction;\r
 \r
   Instance     = 0;\r
   CurrentTable = NULL;\r
   TableHandle  = 0;\r
 \r
-  //\r
-  // Find the AcpiTable protocol\r
-  //\r
-  Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID**)&AcpiTable);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_ABORTED;\r
-  }\r
-\r
   if (QemuDetected ()) {\r
     TableInstallFunction = QemuInstallAcpiTable;\r
-  } else if (XenDetected ()) {\r
-    TableInstallFunction = XenInstallAcpiTable;\r
   } else {\r
     TableInstallFunction = InstallAcpiTable;\r
   }\r
 \r
+  //\r
+  // set FwVol (and use an ASSERT() below) to suppress incorrect\r
+  // compiler/analyzer warnings\r
+  //\r
+  FwVol = NULL;\r
   //\r
   // Locate the firmware volume protocol\r
   //\r
@@ -217,6 +173,8 @@ AcpiPlatformEntryPoint (
   if (EFI_ERROR (Status)) {\r
     return EFI_ABORTED;\r
   }\r
+  ASSERT (FwVol != NULL);\r
+\r
   //\r
   // Read tables from the storage file.\r
   //\r
@@ -231,7 +189,7 @@ AcpiPlatformEntryPoint (
                       &Size,\r
                       &FvStatus\r
                       );\r
-    if (!EFI_ERROR(Status)) {\r
+    if (!EFI_ERROR (Status)) {\r
       //\r
       // Add the table\r
       //\r
@@ -240,11 +198,6 @@ AcpiPlatformEntryPoint (
       TableSize = ((EFI_ACPI_DESCRIPTION_HEADER *) CurrentTable)->Length;\r
       ASSERT (Size >= TableSize);\r
 \r
-      //\r
-      // Checksum ACPI table\r
-      //\r
-      AcpiPlatformChecksum ((UINT8*)CurrentTable, TableSize);\r
-\r
       //\r
       // Install ACPI table\r
       //\r
@@ -275,3 +228,35 @@ AcpiPlatformEntryPoint (
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Effective entrypoint of Acpi Platform driver.\r
+\r
+  @param  ImageHandle\r
+  @param  SystemTable\r
+\r
+  @return EFI_SUCCESS\r
+  @return EFI_LOAD_ERROR\r
+  @return EFI_OUT_OF_RESOURCES\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+InstallAcpiTables (\r
+  IN   EFI_ACPI_TABLE_PROTOCOL       *AcpiTable\r
+  )\r
+{\r
+  EFI_STATUS                         Status;\r
+\r
+  if (XenDetected ()) {\r
+    Status = InstallXenTables (AcpiTable);\r
+  } else {\r
+    Status = InstallQemuFwCfgTables (AcpiTable);\r
+  }\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    Status = InstallOvmfFvTables (AcpiTable);\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r