]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/AcpiPlatformDxe/Xen.c
BaseTools: Library hashing fix and optimization for --hash feature
[mirror_edk2.git] / OvmfPkg / AcpiPlatformDxe / Xen.c
index d9bd2ef9d1311da0653fc875ff4dba25220e1a57..e4e47bf0e8626f9844d39fa8a4b197eb764c237e 100644 (file)
@@ -4,57 +4,20 @@
   Copyright (c) 2008 - 2012, Intel Corporation. All rights reserved.<BR>\r
   Copyright (c) 2012, Bei Guan <gbtju85@gmail.com>\r
 \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
 #include "AcpiPlatform.h"\r
 #include <Library/HobLib.h>\r
 #include <Guid/XenInfo.h>\r
+#include <Library/BaseLib.h>\r
 \r
 #define XEN_ACPI_PHYSICAL_ADDRESS         0x000EA020\r
 #define XEN_BIOS_PHYSICAL_END             0x000FFFFF\r
 \r
 EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER  *XenAcpiRsdpStructurePtr = NULL;\r
 \r
-/**\r
-  Calculates the checksum of the ACPI tables.\r
-\r
-  @param  Buffer    Address of the ACPI table.\r
-  @param  Size      Size of the ACPI table need to check.\r
-\r
-**/\r
-UINT8\r
-CalculateTableChecksum (\r
-  IN VOID       *Buffer,\r
-  IN UINTN      Size\r
-  )\r
-{\r
-  UINT8 Sum;\r
-  UINT8 *Ptr;\r
-\r
-  Sum = 0;\r
-  //\r
-  // Initialize pointer\r
-  //\r
-  Ptr = Buffer;\r
-\r
-  //\r
-  // Add all content of buffer\r
-  //\r
-  while ((Size--) != 0) {\r
-    Sum = (UINT8) (Sum + (*Ptr++));\r
-  }\r
-\r
-  return Sum;\r
-}\r
-\r
 /**\r
   This function detects if OVMF is running on Xen.\r
 \r
@@ -113,8 +76,8 @@ GetXenAcpiRsdp (
       // RSDP ACPI 1.0 checksum for 1.0/2.0/3.0 table.\r
       // This is only the first 20 bytes of the structure\r
       //\r
-      Sum = CalculateTableChecksum (\r
-              RsdpStructurePtr,\r
+      Sum = CalculateSum8 (\r
+              (CONST UINT8 *)RsdpStructurePtr,\r
               sizeof (EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER)\r
               );\r
       if (Sum != 0) {\r
@@ -125,8 +88,8 @@ GetXenAcpiRsdp (
         //\r
         // RSDP ACPI 2.0/3.0 checksum, this is the entire table\r
         //\r
-        Sum = CalculateTableChecksum (\r
-                RsdpStructurePtr,\r
+        Sum = CalculateSum8 (\r
+                (CONST UINT8 *)RsdpStructurePtr,\r
                 sizeof (EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER)\r
                 );\r
         if (Sum != 0) {\r
@@ -219,7 +182,7 @@ InstallXenTables (
       CurrentTableEntry = (VOID *) ((UINT8 *) Xsdt +\r
                             sizeof (EFI_ACPI_DESCRIPTION_HEADER) +\r
                             Index * sizeof (UINT64));\r
-      CurrentTablePointer = *(UINT64 *)CurrentTableEntry;\r
+      CurrentTablePointer = (UINTN) *(UINT64 *)CurrentTableEntry;\r
       CurrentTable = (EFI_ACPI_DESCRIPTION_HEADER *) CurrentTablePointer;\r
 \r
       //\r
@@ -332,8 +295,15 @@ InstallXenTables (
   }\r
 \r
   //\r
-  // Install DSDT table.\r
+  // Install DSDT table. If we reached this point without finding the DSDT,\r
+  // then we're out of sync with the hypervisor, and cannot continue.\r
   //\r
+  if (DsdtTable == NULL) {\r
+    DEBUG ((DEBUG_ERROR, "%a: no DSDT found\n", __FUNCTION__));\r
+    ASSERT (FALSE);\r
+    CpuDeadLoop ();\r
+  }\r
+\r
   Status = InstallAcpiTable (\r
              AcpiProtocol,\r
              DsdtTable,\r