]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpi.c
OvmfPkg/Library/ResetSystemLib: Fix Microvm VS2019 NOOPT build issue
[mirror_edk2.git] / OvmfPkg / AcpiPlatformDxe / QemuFwCfgAcpi.c
index a0b1cfd2be05e9e9a08fbe5f5bd0b377f7ad3662..df800b149275e0fb16d0d5605640134537c7e2f7 100644 (file)
@@ -4,27 +4,22 @@
   Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.<BR>\r
   Copyright (C) 2012-2014, Red Hat, Inc.\r
 \r
-  This program and the accompanying materials are licensed and made available\r
-  under the terms and conditions of the BSD License which accompanies this\r
-  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, WITHOUT\r
-  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 "QemuLoader.h"\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/QemuFwCfgLib.h>\r
-#include <Library/QemuFwCfgS3Lib.h>\r
-#include <Library/DxeServicesTableLib.h>\r
-#include <Library/PcdLib.h>\r
-#include <Library/OrderedCollectionLib.h>\r
-#include <IndustryStandard/Acpi.h>\r
+#include <IndustryStandard/Acpi.h>            // EFI_ACPI_DESCRIPTION_HEADER\r
+#include <IndustryStandard/QemuLoader.h>      // QEMU_LOADER_FNAME_SIZE\r
+#include <Library/BaseLib.h>                  // AsciiStrCmp()\r
+#include <Library/BaseMemoryLib.h>            // CopyMem()\r
+#include <Library/DebugLib.h>                 // DEBUG()\r
+#include <Library/MemoryAllocationLib.h>      // AllocatePool()\r
+#include <Library/OrderedCollectionLib.h>     // OrderedCollectionMin()\r
+#include <Library/QemuFwCfgLib.h>             // QemuFwCfgFindFile()\r
+#include <Library/QemuFwCfgS3Lib.h>           // QemuFwCfgS3Enabled()\r
+#include <Library/UefiBootServicesTableLib.h> // gBS\r
 \r
+#include "AcpiPlatform.h"\r
 \r
 //\r
 // The user structure for the ordered collection that will track the fw_cfg\r
@@ -335,19 +330,19 @@ ProcessCmdAllocate (
   BLOB                 *Blob;\r
 \r
   if (Allocate->File[QEMU_LOADER_FNAME_SIZE - 1] != '\0') {\r
-    DEBUG ((EFI_D_ERROR, "%a: malformed file name\n", __FUNCTION__));\r
+    DEBUG ((DEBUG_ERROR, "%a: malformed file name\n", __FUNCTION__));\r
     return EFI_PROTOCOL_ERROR;\r
   }\r
 \r
   if (Allocate->Alignment > EFI_PAGE_SIZE) {\r
-    DEBUG ((EFI_D_ERROR, "%a: unsupported alignment 0x%x\n", __FUNCTION__,\r
+    DEBUG ((DEBUG_ERROR, "%a: unsupported alignment 0x%x\n", __FUNCTION__,\r
       Allocate->Alignment));\r
     return EFI_UNSUPPORTED;\r
   }\r
 \r
   Status = QemuFwCfgFindFile ((CHAR8 *)Allocate->File, &FwCfgItem, &FwCfgSize);\r
   if (EFI_ERROR (Status)) {\r
-    DEBUG ((EFI_D_ERROR, "%a: QemuFwCfgFindFile(\"%a\"): %r\n", __FUNCTION__,\r
+    DEBUG ((DEBUG_ERROR, "%a: QemuFwCfgFindFile(\"%a\"): %r\n", __FUNCTION__,\r
       Allocate->File, Status));\r
     return Status;\r
   }\r
@@ -378,7 +373,7 @@ ProcessCmdAllocate (
 \r
   Status = OrderedCollectionInsert (Tracker, NULL, Blob);\r
   if (Status == RETURN_ALREADY_STARTED) {\r
-    DEBUG ((EFI_D_ERROR, "%a: duplicated file \"%a\"\n", __FUNCTION__,\r
+    DEBUG ((DEBUG_ERROR, "%a: duplicated file \"%a\"\n", __FUNCTION__,\r
       Allocate->File));\r
     Status = EFI_PROTOCOL_ERROR;\r
   }\r
@@ -390,7 +385,7 @@ ProcessCmdAllocate (
   QemuFwCfgReadBytes (FwCfgSize, Blob->Base);\r
   ZeroMem (Blob->Base + Blob->Size, EFI_PAGES_TO_SIZE (NumPages) - Blob->Size);\r
 \r
-  DEBUG ((EFI_D_VERBOSE, "%a: File=\"%a\" Alignment=0x%x Zone=%d Size=0x%Lx "\r
+  DEBUG ((DEBUG_VERBOSE, "%a: File=\"%a\" Alignment=0x%x Zone=%d Size=0x%Lx "\r
     "Address=0x%Lx\n", __FUNCTION__, Allocate->File, Allocate->Alignment,\r
     Allocate->Zone, (UINT64)Blob->Size, (UINT64)(UINTN)Blob->Base));\r
   return EFI_SUCCESS;\r
@@ -438,14 +433,14 @@ ProcessCmdAddPointer (
 \r
   if (AddPointer->PointerFile[QEMU_LOADER_FNAME_SIZE - 1] != '\0' ||\r
       AddPointer->PointeeFile[QEMU_LOADER_FNAME_SIZE - 1] != '\0') {\r
-    DEBUG ((EFI_D_ERROR, "%a: malformed file name\n", __FUNCTION__));\r
+    DEBUG ((DEBUG_ERROR, "%a: malformed file name\n", __FUNCTION__));\r
     return EFI_PROTOCOL_ERROR;\r
   }\r
 \r
   TrackerEntry = OrderedCollectionFind (Tracker, AddPointer->PointerFile);\r
   TrackerEntry2 = OrderedCollectionFind (Tracker, AddPointer->PointeeFile);\r
   if (TrackerEntry == NULL || TrackerEntry2 == NULL) {\r
-    DEBUG ((EFI_D_ERROR, "%a: invalid blob reference(s) \"%a\" / \"%a\"\n",\r
+    DEBUG ((DEBUG_ERROR, "%a: invalid blob reference(s) \"%a\" / \"%a\"\n",\r
       __FUNCTION__, AddPointer->PointerFile, AddPointer->PointeeFile));\r
     return EFI_PROTOCOL_ERROR;\r
   }\r
@@ -456,7 +451,7 @@ ProcessCmdAddPointer (
        AddPointer->PointerSize != 4 && AddPointer->PointerSize != 8) ||\r
       Blob->Size < AddPointer->PointerSize ||\r
       Blob->Size - AddPointer->PointerSize < AddPointer->PointerOffset) {\r
-    DEBUG ((EFI_D_ERROR, "%a: invalid pointer location or size in \"%a\"\n",\r
+    DEBUG ((DEBUG_ERROR, "%a: invalid pointer location or size in \"%a\"\n",\r
       __FUNCTION__, AddPointer->PointerFile));\r
     return EFI_PROTOCOL_ERROR;\r
   }\r
@@ -465,7 +460,7 @@ ProcessCmdAddPointer (
   PointerValue = 0;\r
   CopyMem (&PointerValue, PointerField, AddPointer->PointerSize);\r
   if (PointerValue >= Blob2->Size) {\r
-    DEBUG ((EFI_D_ERROR, "%a: invalid pointer value in \"%a\"\n", __FUNCTION__,\r
+    DEBUG ((DEBUG_ERROR, "%a: invalid pointer value in \"%a\"\n", __FUNCTION__,\r
       AddPointer->PointerFile));\r
     return EFI_PROTOCOL_ERROR;\r
   }\r
@@ -479,14 +474,14 @@ ProcessCmdAddPointer (
   PointerValue += (UINT64)(UINTN)Blob2->Base;\r
   if (AddPointer->PointerSize < 8 &&\r
       RShiftU64 (PointerValue, AddPointer->PointerSize * 8) != 0) {\r
-    DEBUG ((EFI_D_ERROR, "%a: relocated pointer value unrepresentable in "\r
+    DEBUG ((DEBUG_ERROR, "%a: relocated pointer value unrepresentable in "\r
       "\"%a\"\n", __FUNCTION__, AddPointer->PointerFile));\r
     return EFI_PROTOCOL_ERROR;\r
   }\r
 \r
   CopyMem (PointerField, &PointerValue, AddPointer->PointerSize);\r
 \r
-  DEBUG ((EFI_D_VERBOSE, "%a: PointerFile=\"%a\" PointeeFile=\"%a\" "\r
+  DEBUG ((DEBUG_VERBOSE, "%a: PointerFile=\"%a\" PointeeFile=\"%a\" "\r
     "PointerOffset=0x%x PointerSize=%d\n", __FUNCTION__,\r
     AddPointer->PointerFile, AddPointer->PointeeFile,\r
     AddPointer->PointerOffset, AddPointer->PointerSize));\r
@@ -521,13 +516,13 @@ ProcessCmdAddChecksum (
   BLOB                     *Blob;\r
 \r
   if (AddChecksum->File[QEMU_LOADER_FNAME_SIZE - 1] != '\0') {\r
-    DEBUG ((EFI_D_ERROR, "%a: malformed file name\n", __FUNCTION__));\r
+    DEBUG ((DEBUG_ERROR, "%a: malformed file name\n", __FUNCTION__));\r
     return EFI_PROTOCOL_ERROR;\r
   }\r
 \r
   TrackerEntry = OrderedCollectionFind (Tracker, AddChecksum->File);\r
   if (TrackerEntry == NULL) {\r
-    DEBUG ((EFI_D_ERROR, "%a: invalid blob reference \"%a\"\n", __FUNCTION__,\r
+    DEBUG ((DEBUG_ERROR, "%a: invalid blob reference \"%a\"\n", __FUNCTION__,\r
       AddChecksum->File));\r
     return EFI_PROTOCOL_ERROR;\r
   }\r
@@ -536,7 +531,7 @@ ProcessCmdAddChecksum (
   if (Blob->Size <= AddChecksum->ResultOffset ||\r
       Blob->Size < AddChecksum->Length ||\r
       Blob->Size - AddChecksum->Length < AddChecksum->Start) {\r
-    DEBUG ((EFI_D_ERROR, "%a: invalid checksum range in \"%a\"\n",\r
+    DEBUG ((DEBUG_ERROR, "%a: invalid checksum range in \"%a\"\n",\r
       __FUNCTION__, AddChecksum->File));\r
     return EFI_PROTOCOL_ERROR;\r
   }\r
@@ -545,7 +540,7 @@ ProcessCmdAddChecksum (
                                            Blob->Base + AddChecksum->Start,\r
                                            AddChecksum->Length\r
                                            );\r
-  DEBUG ((EFI_D_VERBOSE, "%a: File=\"%a\" ResultOffset=0x%x Start=0x%x "\r
+  DEBUG ((DEBUG_VERBOSE, "%a: File=\"%a\" ResultOffset=0x%x Start=0x%x "\r
     "Length=0x%x\n", __FUNCTION__, AddChecksum->File,\r
     AddChecksum->ResultOffset, AddChecksum->Start, AddChecksum->Length));\r
   return EFI_SUCCESS;\r
@@ -854,7 +849,7 @@ Process2ndPassCmdAddPointer (
   }\r
 \r
   Blob2Remaining -= (UINTN) PointerValue;\r
-  DEBUG ((EFI_D_VERBOSE, "%a: checking for ACPI header in \"%a\" at 0x%Lx "\r
+  DEBUG ((DEBUG_VERBOSE, "%a: checking for ACPI header in \"%a\" at 0x%Lx "\r
     "(remaining: 0x%Lx): ", __FUNCTION__, AddPointer->PointeeFile,\r
     PointerValue, (UINT64)Blob2Remaining));\r
 \r
@@ -870,7 +865,7 @@ Process2ndPassCmdAddPointer (
         Facs->Length <= Blob2Remaining &&\r
         Facs->Signature ==\r
                 EFI_ACPI_1_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE) {\r
-      DEBUG ((EFI_D_VERBOSE, "found \"%-4.4a\" size 0x%x\n",\r
+      DEBUG ((DEBUG_VERBOSE, "found \"%-4.4a\" size 0x%x\n",\r
         (CONST CHAR8 *)&Facs->Signature, Facs->Length));\r
       TableSize = Facs->Length;\r
     }\r
@@ -890,7 +885,7 @@ Process2ndPassCmdAddPointer (
       // - Length field consistent with both ACPI and containing blob size\r
       // - checksum is correct\r
       //\r
-      DEBUG ((EFI_D_VERBOSE, "found \"%-4.4a\" size 0x%x\n",\r
+      DEBUG ((DEBUG_VERBOSE, "found \"%-4.4a\" size 0x%x\n",\r
         (CONST CHAR8 *)&Header->Signature, Header->Length));\r
       TableSize = Header->Length;\r
 \r
@@ -907,13 +902,13 @@ Process2ndPassCmdAddPointer (
   }\r
 \r
   if (TableSize == 0) {\r
-    DEBUG ((EFI_D_VERBOSE, "not found; marking fw_cfg blob as opaque\n"));\r
+    DEBUG ((DEBUG_VERBOSE, "not found; marking fw_cfg blob as opaque\n"));\r
     Blob2->HostsOnlyTableData = FALSE;\r
     return EFI_SUCCESS;\r
   }\r
 \r
   if (*NumInstalled == INSTALLED_TABLES_MAX) {\r
-    DEBUG ((EFI_D_ERROR, "%a: can't install more than %d tables\n",\r
+    DEBUG ((DEBUG_ERROR, "%a: can't install more than %d tables\n",\r
       __FUNCTION__, INSTALLED_TABLES_MAX));\r
     Status = EFI_OUT_OF_RESOURCES;\r
     goto RollbackSeenPointer;\r
@@ -923,7 +918,7 @@ Process2ndPassCmdAddPointer (
                            (VOID *)(UINTN)PointerValue, TableSize,\r
                            &InstalledKey[*NumInstalled]);\r
   if (EFI_ERROR (Status)) {\r
-    DEBUG ((EFI_D_ERROR, "%a: InstallAcpiTable(): %r\n", __FUNCTION__,\r
+    DEBUG ((DEBUG_ERROR, "%a: InstallAcpiTable(): %r\n", __FUNCTION__,\r
       Status));\r
     goto RollbackSeenPointer;\r
   }\r
@@ -986,7 +981,7 @@ InstallQemuFwCfgTables (
     return Status;\r
   }\r
   if (FwCfgSize % sizeof *LoaderEntry != 0) {\r
-    DEBUG ((EFI_D_ERROR, "%a: \"etc/table-loader\" has invalid size 0x%Lx\n",\r
+    DEBUG ((DEBUG_ERROR, "%a: \"etc/table-loader\" has invalid size 0x%Lx\n",\r
       __FUNCTION__, (UINT64)FwCfgSize));\r
     return EFI_PROTOCOL_ERROR;\r
   }\r
@@ -1066,7 +1061,7 @@ InstallQemuFwCfgTables (
         break;\r
 \r
     default:\r
-      DEBUG ((EFI_D_VERBOSE, "%a: unknown loader command: 0x%x\n",\r
+      DEBUG ((DEBUG_VERBOSE, "%a: unknown loader command: 0x%x\n",\r
         __FUNCTION__, LoaderEntry->Type));\r
       break;\r
     }\r
@@ -1119,7 +1114,7 @@ InstallQemuFwCfgTables (
       goto UninstallAcpiTables;\r
     }\r
     //\r
-    // Ownership of S3Context has been transfered.\r
+    // Ownership of S3Context has been transferred.\r
     //\r
     S3Context = NULL;\r
   }\r
@@ -1134,7 +1129,7 @@ UninstallAcpiTables:
       AcpiProtocol->UninstallAcpiTable (AcpiProtocol, InstalledKey[Installed]);\r
     }\r
   } else {\r
-    DEBUG ((EFI_D_INFO, "%a: installed %d tables\n", __FUNCTION__, Installed));\r
+    DEBUG ((DEBUG_INFO, "%a: installed %d tables\n", __FUNCTION__, Installed));\r
   }\r
 \r
   for (SeenPointerEntry = OrderedCollectionMin (SeenPointers);\r
@@ -1178,7 +1173,7 @@ RollbackWritePointersAndFreeTracker:
     Blob = UserStruct;\r
 \r
     if (EFI_ERROR (Status) || Blob->HostsOnlyTableData) {\r
-      DEBUG ((EFI_D_VERBOSE, "%a: freeing \"%a\"\n", __FUNCTION__,\r
+      DEBUG ((DEBUG_VERBOSE, "%a: freeing \"%a\"\n", __FUNCTION__,\r
         Blob->File));\r
       gBS->FreePages ((UINTN)Blob->Base, EFI_SIZE_TO_PAGES (Blob->Size));\r
     }\r