]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg: AcpiPlatformDxe: pass FwCfgFile to InstallQemuLinkedTables()
authorLaszlo Ersek <lersek@redhat.com>
Thu, 19 Jun 2014 06:13:12 +0000 (06:13 +0000)
committerjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 19 Jun 2014 06:13:12 +0000 (06:13 +0000)
Split InstallQemuLinkedTables() in two:
- the function now takes the name of the fw_cfg file (from which ACPI
  tables are to be extracted) as a parameter,

- the new function InstallAllQemuLinkedTables() calls the former with
  fw_cfg file names, and cumulatively tracks the ACPI tables installed by
  all invocations of the former.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15572 6f19259b-4bc3-4df7-8a09-765794883524

OvmfPkg/AcpiPlatformDxe/AcpiPlatform.c
OvmfPkg/AcpiPlatformDxe/AcpiPlatform.h
OvmfPkg/AcpiPlatformDxe/Qemu.c

index 084c3931d08cff4e6cb8fbee3b909f17862bcbf4..11f0ca8594025069556e78000ef07b3ec8df6670 100644 (file)
@@ -257,7 +257,7 @@ AcpiPlatformEntryPoint (
   if (XenDetected ()) {\r
     Status = InstallXenTables (AcpiTable);\r
   } else {\r
-    Status = InstallQemuLinkedTables (AcpiTable);\r
+    Status = InstallAllQemuLinkedTables (AcpiTable);\r
   }\r
 \r
   if (EFI_ERROR (Status)) {\r
index c643fa13d41c48137e183ee217a6c667efc2f475..e75723384587c9c1c6461a423723c810ee31b119 100644 (file)
@@ -63,7 +63,7 @@ InstallXenTables (
 \r
 EFI_STATUS\r
 EFIAPI\r
-InstallQemuLinkedTables (\r
+InstallAllQemuLinkedTables (\r
   IN   EFI_ACPI_TABLE_PROTOCOL       *AcpiProtocol\r
   );\r
 #endif\r
index e62467a5bc3bafe02a3007a639c127b6b04f93e9..df912c20f80fb0815c8eefe51144922e6fa6f574 100644 (file)
@@ -3,7 +3,7 @@
 \r
   Copyright (c) 2008 - 2012, Intel Corporation. All rights reserved.<BR>\r
 \r
-  Copyright (C) 2012, Red Hat, Inc.\r
+  Copyright (C) 2012-2014, Red Hat, Inc.\r
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
@@ -516,50 +516,78 @@ QemuInstallAcpiTable (
 }\r
 \r
 \r
+//\r
+// We'll be saving the keys of installed tables so that we can roll them back\r
+// in case of failure. 128 tables should be enough for anyone (TM).\r
+//\r
+#define INSTALLED_TABLES_MAX 128\r
+\r
 /**\r
-  Download the ACPI table data file from QEMU and interpret it.\r
+  Download one ACPI table data file from QEMU and interpret it.\r
 \r
-  @param[in] AcpiProtocol  The ACPI table protocol used to install tables.\r
+  @param[in] FwCfgFile         The NUL-terminated name of the fw_cfg file to\r
+                               download and interpret.\r
 \r
-  @retval  EFI_UNSUPPORTED       Firmware configuration is unavailable.\r
+  @param[in] AcpiProtocol      The ACPI table protocol used to install tables.\r
 \r
-  @retval  EFI_NOT_FOUND         The host doesn't export the required fw_cfg\r
-                                 files.\r
+  @param[in,out] InstalledKey  On input, an array of INSTALLED_TABLES_MAX UINTN\r
+                               elements, allocated by the caller. On output,\r
+                               the function will have stored (appended) the\r
+                               AcpiProtocol-internal keys of the ACPI tables\r
+                               that the function has installed from the fw_cfg\r
+                               file. The array reflects installed tables even\r
+                               if the function returns with an error.\r
 \r
-  @retval  EFI_OUT_OF_RESOURCES  Memory allocation failed.\r
+  @param[in,out] NumInstalled  On input, the number of entries already used in\r
+                               InstalledKey; it must be in [0,\r
+                               INSTALLED_TABLES_MAX] inclusive. On output, the\r
+                               parameter is updated to the new cumulative count\r
+                               of the keys stored in InstalledKey; the value\r
+                               reflects installed tables even if the function\r
+                               returns with an error.\r
 \r
-  @retval  EFI_PROTOCOL_ERROR    Found truncated or invalid ACPI table header\r
-                                 in the fw_cfg contents.\r
+  @retval  EFI_INVALID_PARAMETER  NumInstalled is outside the allowed range on\r
+                                  input.\r
 \r
-  @return                        Status codes returned by\r
-                                 AcpiProtocol->InstallAcpiTable().\r
+  @retval  EFI_UNSUPPORTED        Firmware configuration is unavailable.\r
 \r
-**/\r
+  @retval  EFI_NOT_FOUND          The host doesn't export the requested fw_cfg\r
+                                  file.\r
 \r
-//\r
-// We'll be saving the keys of installed tables so that we can roll them back\r
-// in case of failure. 128 tables should be enough for anyone (TM).\r
-//\r
-#define INSTALLED_TABLES_MAX 128\r
+  @retval  EFI_OUT_OF_RESOURCES   Memory allocation failed, or no more room in\r
+                                  InstalledKey.\r
+\r
+  @retval  EFI_PROTOCOL_ERROR     Found truncated or invalid ACPI table header\r
+                                  in the fw_cfg contents.\r
 \r
+  @return                         Status codes returned by\r
+                                  AcpiProtocol->InstallAcpiTable().\r
+\r
+**/\r
+\r
+STATIC\r
 EFI_STATUS\r
-EFIAPI\r
 InstallQemuLinkedTables (\r
-  IN   EFI_ACPI_TABLE_PROTOCOL       *AcpiProtocol\r
+  IN     CONST CHAR8             *FwCfgFile,\r
+  IN     EFI_ACPI_TABLE_PROTOCOL *AcpiProtocol,\r
+  IN OUT UINTN                   InstalledKey[INSTALLED_TABLES_MAX],\r
+  IN OUT INT32                   *NumInstalled\r
   )\r
 {\r
   EFI_STATUS           Status;\r
   FIRMWARE_CONFIG_ITEM TablesFile;\r
   UINTN                TablesFileSize;\r
   UINT8                *Tables;\r
-  UINTN                *InstalledKey;\r
   UINTN                Processed;\r
-  INT32                Installed;\r
 \r
-  Status = QemuFwCfgFindFile ("etc/acpi/tables", &TablesFile, &TablesFileSize);\r
+  if (*NumInstalled < 0 || *NumInstalled > INSTALLED_TABLES_MAX) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  Status = QemuFwCfgFindFile (FwCfgFile, &TablesFile, &TablesFileSize);\r
   if (EFI_ERROR (Status)) {\r
-    DEBUG ((EFI_D_INFO, "%a: \"etc/acpi/tables\" interface unavailable: %r\n",\r
-      __FUNCTION__, Status));\r
+    DEBUG ((EFI_D_ERROR, "%a: \"%a\" unavailable: %r\n", __FUNCTION__,\r
+      FwCfgFile, Status));\r
     return Status;\r
   }\r
 \r
@@ -571,14 +599,7 @@ InstallQemuLinkedTables (
   QemuFwCfgSelectItem (TablesFile);\r
   QemuFwCfgReadBytes (TablesFileSize, Tables);\r
 \r
-  InstalledKey = AllocatePool (INSTALLED_TABLES_MAX * sizeof *InstalledKey);\r
-  if (InstalledKey == NULL) {\r
-    Status = EFI_OUT_OF_RESOURCES;\r
-    goto FreeTables;\r
-  }\r
-\r
   Processed = 0;\r
-  Installed = 0;\r
   while (Processed < TablesFileSize) {\r
     UINTN                       Remaining;\r
     EFI_ACPI_DESCRIPTION_HEADER *Probe;\r
@@ -595,9 +616,9 @@ InstallQemuLinkedTables (
       break;\r
     }\r
 \r
-    DEBUG ((EFI_D_VERBOSE, "%a: offset 0x%016Lx:"\r
+    DEBUG ((EFI_D_VERBOSE, "%a: \"%a\" offset 0x%016Lx:"\r
       " Signature=\"%-4.4a\" Length=0x%08x\n",\r
-      __FUNCTION__, (UINT64) Processed,\r
+      __FUNCTION__, FwCfgFile, (UINT64) Processed,\r
       (CONST CHAR8 *) &Probe->Signature, Probe->Length));\r
 \r
     //\r
@@ -607,7 +628,7 @@ InstallQemuLinkedTables (
                         EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE &&\r
         Probe->Signature !=\r
                     EFI_ACPI_2_0_EXTENDED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE) {\r
-      if (Installed == INSTALLED_TABLES_MAX) {\r
+      if (*NumInstalled == INSTALLED_TABLES_MAX) {\r
         DEBUG ((EFI_D_ERROR, "%a: can't install more than %d tables\n",\r
           __FUNCTION__, INSTALLED_TABLES_MAX));\r
         Status = EFI_OUT_OF_RESOURCES;\r
@@ -615,16 +636,16 @@ InstallQemuLinkedTables (
       }\r
 \r
       Status = AcpiProtocol->InstallAcpiTable (AcpiProtocol, Probe,\r
-                 Probe->Length, &InstalledKey[Installed]);\r
+                 Probe->Length, &InstalledKey[*NumInstalled]);\r
       if (EFI_ERROR (Status)) {\r
         DEBUG ((EFI_D_ERROR,\r
-          "%a: failed to install table \"%-4.4a\" at offset 0x%Lx: %r\n",\r
-          __FUNCTION__, (CONST CHAR8 *) &Probe->Signature, (UINT64) Processed,\r
-          Status));\r
+          "%a: failed to install table \"%-4.4a\" at \"%a\" offset 0x%Lx: "\r
+          "%r\n", __FUNCTION__, (CONST CHAR8 *)&Probe->Signature, FwCfgFile,\r
+          (UINT64) Processed, Status));\r
         break;\r
       }\r
 \r
-      ++Installed;\r
+      ++*NumInstalled;\r
     }\r
 \r
     Processed += Probe->Length;\r
@@ -642,16 +663,62 @@ InstallQemuLinkedTables (
     }\r
     if (Processed < TablesFileSize) {\r
       DEBUG ((EFI_D_ERROR, "%a: truncated or invalid ACPI table header at "\r
-        "offset 0x%Lx\n", __FUNCTION__, (UINT64) ErrorLocation));\r
+        "\"%a\" offset 0x%Lx\n", __FUNCTION__, FwCfgFile,\r
+        (UINT64)ErrorLocation));\r
     }\r
   }\r
 \r
   if (Processed == TablesFileSize) {\r
-    DEBUG ((EFI_D_INFO, "%a: installed %d tables\n", __FUNCTION__, Installed));\r
     Status = EFI_SUCCESS;\r
   } else {\r
     ASSERT (EFI_ERROR (Status));\r
+  }\r
 \r
+  FreePool (Tables);\r
+  return Status;\r
+}\r
+\r
+/**\r
+  Download all ACPI table data files from QEMU and interpret them.\r
+\r
+  @param[in] AcpiProtocol  The ACPI table protocol used to install tables.\r
+\r
+  @retval  EFI_UNSUPPORTED       Firmware configuration is unavailable.\r
+\r
+  @retval  EFI_NOT_FOUND         The host doesn't export the required fw_cfg\r
+                                 files.\r
+\r
+  @retval  EFI_OUT_OF_RESOURCES  Memory allocation failed, or more than\r
+                                 INSTALLED_TABLES_MAX tables found.\r
+\r
+  @retval  EFI_PROTOCOL_ERROR    Found truncated or invalid ACPI table header\r
+                                 in the fw_cfg contents.\r
+\r
+  @return                        Status codes returned by\r
+                                 AcpiProtocol->InstallAcpiTable().\r
+\r
+**/\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+InstallAllQemuLinkedTables (\r
+  IN   EFI_ACPI_TABLE_PROTOCOL       *AcpiProtocol\r
+  )\r
+{\r
+  UINTN                *InstalledKey;\r
+  INT32                Installed;\r
+  EFI_STATUS           Status;\r
+\r
+  InstalledKey = AllocatePool (INSTALLED_TABLES_MAX * sizeof *InstalledKey);\r
+  if (InstalledKey == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+  Installed = 0;\r
+\r
+  Status = InstallQemuLinkedTables ("etc/acpi/tables", AcpiProtocol,\r
+             InstalledKey, &Installed);\r
+  if (EFI_ERROR (Status)) {\r
+    ASSERT (Status != EFI_INVALID_PARAMETER);\r
     //\r
     // Roll back partial installation.\r
     //\r
@@ -659,12 +726,10 @@ InstallQemuLinkedTables (
       --Installed;\r
       AcpiProtocol->UninstallAcpiTable (AcpiProtocol, InstalledKey[Installed]);\r
     }\r
+  } else {\r
+    DEBUG ((EFI_D_INFO, "%a: installed %d tables\n", __FUNCTION__, Installed));\r
   }\r
 \r
   FreePool (InstalledKey);\r
-\r
-FreeTables:\r
-  FreePool (Tables);\r
-\r
   return Status;\r
 }\r