]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/AcpiPlatformDxe/Qemu.c
OvmfPkg: AcpiPlatformDxe: remove current ACPI table loader
[mirror_edk2.git] / OvmfPkg / AcpiPlatformDxe / Qemu.c
index 70f3ff6426697041bb49b58bd6dcea868315af7a..ef2ba114b64296923512bd032412daad45d4ae1b 100644 (file)
@@ -517,272 +517,6 @@ QemuInstallAcpiTable (
 }\r
 \r
 \r
-/**\r
-  Check if an array of bytes starts with an RSD PTR structure.\r
-\r
-  Checksum is ignored.\r
-\r
-  @param[in] Buffer     The array to check.\r
-\r
-  @param[in] Size       Number of bytes in Buffer.\r
-\r
-  @param[out] RsdpSize  If the function returns EFI_SUCCESS, this parameter\r
-                        contains the size of the detected RSD PTR structure.\r
-\r
-  @retval  EFI_SUCCESS         RSD PTR structure detected at the beginning of\r
-                               Buffer, and its advertised size does not exceed\r
-                               Size.\r
-\r
-  @retval  EFI_PROTOCOL_ERROR  RSD PTR structure detected at the beginning of\r
-                               Buffer, but it has inconsistent size.\r
-\r
-  @retval  EFI_NOT_FOUND       RSD PTR structure not found.\r
-\r
-**/\r
-\r
-STATIC\r
-EFI_STATUS\r
-CheckRsdp (\r
-  IN  CONST VOID *Buffer,\r
-  IN  UINTN      Size,\r
-  OUT UINTN      *RsdpSize\r
-  )\r
-{\r
-  CONST UINT64                                       *Signature;\r
-  CONST EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp1;\r
-  CONST EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp2;\r
-\r
-  if (Size < sizeof *Signature) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-  Signature = Buffer;\r
-\r
-  if (*Signature != EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER_SIGNATURE) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  //\r
-  // Signature found -- from this point on we can only report\r
-  // EFI_PROTOCOL_ERROR or EFI_SUCCESS.\r
-  //\r
-  if (Size < sizeof *Rsdp1) {\r
-    return EFI_PROTOCOL_ERROR;\r
-  }\r
-  Rsdp1 = Buffer;\r
-\r
-  if (Rsdp1->Reserved == 0) {\r
-    //\r
-    // ACPI 1.0 doesn't include the Length field\r
-    //\r
-    *RsdpSize = sizeof *Rsdp1;\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  if (Size < sizeof *Rsdp2) {\r
-    return EFI_PROTOCOL_ERROR;\r
-  }\r
-  Rsdp2 = Buffer;\r
-\r
-  if (Size < Rsdp2->Length || Rsdp2->Length < sizeof *Rsdp2) {\r
-    return EFI_PROTOCOL_ERROR;\r
-  }\r
-\r
-  *RsdpSize = Rsdp2->Length;\r
-  return EFI_SUCCESS;\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 one ACPI table data file from QEMU and interpret it.\r
-\r
-  @param[in] FwCfgFile         The NUL-terminated name of the fw_cfg file to\r
-                               download and interpret.\r
-\r
-  @param[in] AcpiProtocol      The ACPI table protocol used to install tables.\r
-\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
-  @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_INVALID_PARAMETER  NumInstalled is outside the allowed range on\r
-                                  input.\r
-\r
-  @retval  EFI_UNSUPPORTED        Firmware configuration is unavailable.\r
-\r
-  @retval  EFI_NOT_FOUND          The host doesn't export the requested fw_cfg\r
-                                  file.\r
-\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
-InstallQemuLinkedTables (\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                Processed;\r
-\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_ERROR, "%a: \"%a\" unavailable: %r\n", __FUNCTION__,\r
-      FwCfgFile, Status));\r
-    return Status;\r
-  }\r
-\r
-  Tables = AllocatePool (TablesFileSize);\r
-  if (Tables == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  QemuFwCfgSelectItem (TablesFile);\r
-  QemuFwCfgReadBytes (TablesFileSize, Tables);\r
-\r
-  Processed = 0;\r
-  while (Processed < TablesFileSize) {\r
-    UINTN                       Remaining;\r
-    UINTN                       RsdpSize;\r
-    EFI_ACPI_DESCRIPTION_HEADER *Probe;\r
-\r
-    Remaining = TablesFileSize - Processed;\r
-\r
-    //\r
-    // See if we're looking at an RSD PTR structure.\r
-    //\r
-    RsdpSize = 0;\r
-    Status = CheckRsdp (Tables + Processed, Remaining, &RsdpSize);\r
-    if (Status == EFI_PROTOCOL_ERROR) {\r
-      //\r
-      // RSD PTR found but its size is inconsistent; abort processing. (Note\r
-      // that "RSD PTR found" excludes the NUL-padding case by definition.)\r
-      //\r
-      break;\r
-    }\r
-    if (!EFI_ERROR (Status)) {\r
-      //\r
-      // Consistent RSD PTR found, skip it.\r
-      //\r
-      DEBUG ((EFI_D_VERBOSE, "%a: \"%a\" offset 0x%016Lx: RSD PTR "\r
-        "Length=0x%08x\n", __FUNCTION__, FwCfgFile, (UINT64)Processed,\r
-        (UINT32)RsdpSize));\r
-      Processed += RsdpSize;\r
-      continue;\r
-    }\r
-    ASSERT (Status == EFI_NOT_FOUND);\r
-\r
-    //\r
-    // What we're looking at is not an RSD PTR structure; attempt to parse it\r
-    // as an ACPI table.\r
-    //\r
-    if (Remaining < sizeof *Probe) {\r
-      Status = EFI_PROTOCOL_ERROR;\r
-      break;\r
-    }\r
-\r
-    Probe = (EFI_ACPI_DESCRIPTION_HEADER *) (Tables + Processed);\r
-    if (Remaining < Probe->Length || Probe->Length < sizeof *Probe) {\r
-      Status = EFI_PROTOCOL_ERROR;\r
-      break;\r
-    }\r
-\r
-    DEBUG ((EFI_D_VERBOSE, "%a: \"%a\" offset 0x%016Lx:"\r
-      " Signature=\"%-4.4a\" Length=0x%08x\n",\r
-      __FUNCTION__, FwCfgFile, (UINT64) Processed,\r
-      (CONST CHAR8 *) &Probe->Signature, Probe->Length));\r
-\r
-    //\r
-    // skip automatically handled "root" tables: RSDT, XSDT\r
-    //\r
-    if (Probe->Signature !=\r
-                        EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE &&\r
-        Probe->Signature !=\r
-                    EFI_ACPI_2_0_EXTENDED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE) {\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
-        break;\r
-      }\r
-\r
-      Status = AcpiProtocol->InstallAcpiTable (AcpiProtocol, Probe,\r
-                 Probe->Length, &InstalledKey[*NumInstalled]);\r
-      if (EFI_ERROR (Status)) {\r
-        DEBUG ((EFI_D_ERROR,\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
-      ++*NumInstalled;\r
-    }\r
-\r
-    Processed += Probe->Length;\r
-  }\r
-\r
-  //\r
-  // NUL-padding at the end is accepted\r
-  //\r
-  if (Status == EFI_PROTOCOL_ERROR) {\r
-    UINTN ErrorLocation;\r
-\r
-    ErrorLocation = Processed;\r
-    while (Processed < TablesFileSize && Tables[Processed] == '\0') {\r
-      ++Processed;\r
-    }\r
-    if (Processed < TablesFileSize) {\r
-      DEBUG ((EFI_D_ERROR, "%a: truncated or invalid ACPI table header at "\r
-        "\"%a\" offset 0x%Lx\n", __FUNCTION__, FwCfgFile,\r
-        (UINT64)ErrorLocation));\r
-    }\r
-  }\r
-\r
-  if (Processed == TablesFileSize) {\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
@@ -809,75 +543,5 @@ InstallAllQemuLinkedTables (
   IN   EFI_ACPI_TABLE_PROTOCOL       *AcpiProtocol\r
   )\r
 {\r
-  UINTN                *InstalledKey;\r
-  INT32                Installed;\r
-  EFI_STATUS           Status;\r
-  FIRMWARE_CONFIG_ITEM LoaderItem;\r
-  UINTN                LoaderSize;\r
-  UINT8                *Loader;\r
-  QEMU_LOADER_ENTRY    *Entry, *End;\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 = QemuFwCfgFindFile ("etc/table-loader", &LoaderItem, &LoaderSize);\r
-  if (EFI_ERROR (Status)) {\r
-    goto FreeInstalledKey;\r
-  }\r
-  if (LoaderSize % sizeof *Entry != 0) {\r
-    Status = EFI_PROTOCOL_ERROR;\r
-    goto FreeInstalledKey;\r
-  }\r
-\r
-  Loader = AllocatePool (LoaderSize);\r
-  if (Loader == NULL) {\r
-    Status = EFI_OUT_OF_RESOURCES;\r
-    goto FreeInstalledKey;\r
-  }\r
-\r
-  QemuFwCfgSelectItem (LoaderItem);\r
-  QemuFwCfgReadBytes (LoaderSize, Loader);\r
-\r
-  Entry = (QEMU_LOADER_ENTRY *)Loader;\r
-  End   = (QEMU_LOADER_ENTRY *)(Loader + LoaderSize);\r
-  while (Entry < End) {\r
-    if (Entry->Type == QemuLoaderCmdAllocate) {\r
-      QEMU_LOADER_ALLOCATE *Allocate;\r
-\r
-      Allocate = &Entry->Command.Allocate;\r
-      if (Allocate->File[sizeof Allocate->File - 1] != '\0') {\r
-        Status = EFI_PROTOCOL_ERROR;\r
-        break;\r
-      }\r
-\r
-      Status = InstallQemuLinkedTables ((CHAR8 *)Allocate->File, AcpiProtocol,\r
-                 InstalledKey, &Installed);\r
-      if (EFI_ERROR (Status)) {\r
-        ASSERT (Status != EFI_INVALID_PARAMETER);\r
-        break;\r
-      }\r
-    }\r
-    ++Entry;\r
-  }\r
-\r
-  FreePool (Loader);\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    //\r
-    // Roll back partial installation.\r
-    //\r
-    while (Installed > 0) {\r
-      --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
-FreeInstalledKey:\r
-  FreePool (InstalledKey);\r
-  return Status;\r
+  return EFI_NOT_FOUND;\r
 }\r