]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg: AcpiPlatformDxe: make dependency on PCI enumeration dynamic
authorLaszlo Ersek <lersek@redhat.com>
Thu, 19 Feb 2015 23:46:27 +0000 (23:46 +0000)
committerjljusten <jljusten@Edk2>
Thu, 19 Feb 2015 23:46:27 +0000 (23:46 +0000)
SVN r16411 delayed ACPI table installation until PCI enumeration was
complete, because on QEMU the ACPI-related fw_cfg files should have been
downloaded only after PCI enumeration. Said commit implemented the
dependency by tightening the module's depex.

This patch replaces the EFI_PCI_ENUMERATION_COMPLETE_PROTOCOL depex with a
matching protocol registration callback. The depex was static, and it
could not handle dynamically discovered situations when the dependency
would turn out invalid.

Namely:

- At the moment, the depex in "QemuFwCfgAcpiPlatformDxe.inf" assumes
  that "ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc"
  lacks PCI support. However, PCI support is about to become run-time
  discoverable on that platform. If PCI support is missing, then
  ArmVirtualizationPkg will set PcdPciDisableBusEnumeration to TRUE.

  Hence, when PcdPciDisableBusEnumeration is TRUE, we invalidate the
  dependency by not registering the callback and installing the ACPI
  tables right away.

- InitializeXen() in "OvmfPkg/PlatformPei/Xen.c" sets
  PcdPciDisableBusEnumeration to TRUE. This causes
  PciBusDriverBindingStart() in "MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.c"
  to set gFullEnumeration to FALSE, which in turn makes PciEnumerator() in
  "MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c" branch to
  PciEnumeratorLight(). The installation of
  EFI_PCI_ENUMERATION_COMPLETE_PROTOCOL at the end of PciEnumerator() is
  not reached.

  Which means that starting with SVN r16411, AcpiPlatformDxe is never
  dispatched on Xen.

  Hence, when PcdPciDisableBusEnumeration is TRUE, we invalidate the
  dependency by not registering the callback and installing the ACPI
  tables right away.

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

OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf
OvmfPkg/AcpiPlatformDxe/EntryPoint.c
OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpiPlatformDxe.inf

index 0ba703dcecae1071101fac83514d5d85e989cf5b..055f3ad0ee0fcd4471d2b9087965bca9547a9342 100644 (file)
 \r
 [Protocols]\r
   gEfiAcpiTableProtocolGuid                     # PROTOCOL ALWAYS_CONSUMED\r
 \r
 [Protocols]\r
   gEfiAcpiTableProtocolGuid                     # PROTOCOL ALWAYS_CONSUMED\r
+  gEfiPciEnumerationCompleteProtocolGuid        # PROTOCOL SOMETIMES_CONSUMED\r
 \r
 [Guids]\r
   gEfiXenInfoGuid\r
 \r
 [Pcd]\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiTableStorageFile\r
 \r
 [Guids]\r
   gEfiXenInfoGuid\r
 \r
 [Pcd]\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiTableStorageFile\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration\r
   gUefiCpuPkgTokenSpaceGuid.PcdCpuLocalApicBaseAddress\r
   gPcAtChipsetPkgTokenSpaceGuid.Pcd8259LegacyModeEdgeLevel\r
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFdBaseAddress\r
 \r
 [Depex]\r
   gUefiCpuPkgTokenSpaceGuid.PcdCpuLocalApicBaseAddress\r
   gPcAtChipsetPkgTokenSpaceGuid.Pcd8259LegacyModeEdgeLevel\r
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFdBaseAddress\r
 \r
 [Depex]\r
-  gEfiAcpiTableProtocolGuid AND gEfiPciEnumerationCompleteProtocolGuid\r
-\r
+  gEfiAcpiTableProtocolGuid\r
index d782b610bd0814ab2914d6fc8d3033a532106c0b..d713b0d44b1b96f55caaa8f10166be8d1f3169b5 100644 (file)
@@ -13,6 +13,7 @@
   WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 **/\r
 \r
   WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 **/\r
 \r
+#include <Protocol/PciEnumerationComplete.h>\r
 #include "AcpiPlatform.h"\r
 \r
 STATIC\r
 #include "AcpiPlatform.h"\r
 \r
 STATIC\r
@@ -33,6 +34,27 @@ FindAcpiTableProtocol (
   return AcpiTable;\r
 }\r
 \r
   return AcpiTable;\r
 }\r
 \r
+\r
+STATIC\r
+VOID\r
+EFIAPI\r
+OnPciEnumerated (\r
+  IN EFI_EVENT Event,\r
+  IN VOID      *Context\r
+  )\r
+{\r
+  EFI_STATUS Status;\r
+\r
+  DEBUG ((EFI_D_INFO, "%a: PCI enumeration complete, installing ACPI tables\n",\r
+    __FUNCTION__));\r
+  Status = InstallAcpiTables (FindAcpiTableProtocol ());\r
+  if (EFI_ERROR (Status)) {\r
+    DEBUG ((EFI_D_ERROR, "%a: InstallAcpiTables: %r\n", __FUNCTION__, Status));\r
+  }\r
+  gBS->CloseEvent (Event);\r
+}\r
+\r
+\r
 EFI_STATUS\r
 EFIAPI\r
 AcpiPlatformEntryPoint (\r
 EFI_STATUS\r
 EFIAPI\r
 AcpiPlatformEntryPoint (\r
@@ -41,7 +63,54 @@ AcpiPlatformEntryPoint (
   )\r
 {\r
   EFI_STATUS Status;\r
   )\r
 {\r
   EFI_STATUS Status;\r
+  VOID       *Interface;\r
+  EFI_EVENT  PciEnumerated;\r
+  VOID       *Registration;\r
+\r
+  //\r
+  // If the platform doesn't support PCI, or PCI enumeration has been disabled,\r
+  // install the tables at once, and let the entry point's return code reflect\r
+  // the full functionality.\r
+  //\r
+  if (PcdGetBool (PcdPciDisableBusEnumeration)) {\r
+    DEBUG ((EFI_D_INFO, "%a: PCI or its enumeration disabled, installing "\r
+      "ACPI tables\n", __FUNCTION__));\r
+    return InstallAcpiTables (FindAcpiTableProtocol ());\r
+  }\r
+\r
+  //\r
+  // Similarly, if PCI enumeration has already completed, install the tables\r
+  // immediately.\r
+  //\r
+  Status = gBS->LocateProtocol (&gEfiPciEnumerationCompleteProtocolGuid,\r
+                  NULL /* Registration */, &Interface);\r
+  if (!EFI_ERROR (Status)) {\r
+    DEBUG ((EFI_D_INFO, "%a: PCI enumeration already complete, "\r
+      "installing ACPI tables\n", __FUNCTION__));\r
+    return InstallAcpiTables (FindAcpiTableProtocol ());\r
+  }\r
+  ASSERT (Status == EFI_NOT_FOUND);\r
+\r
+  //\r
+  // Otherwise, delay installing the ACPI tables until PCI enumeration\r
+  // completes. The entry point's return status will only reflect the callback\r
+  // setup.\r
+  //\r
+  Status = gBS->CreateEvent (EVT_NOTIFY_SIGNAL, TPL_CALLBACK, OnPciEnumerated,\r
+                  NULL /* Context */, &PciEnumerated);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  Status = gBS->RegisterProtocolNotify (\r
+                  &gEfiPciEnumerationCompleteProtocolGuid, PciEnumerated,\r
+                  &Registration);\r
+  if (EFI_ERROR (Status)) {\r
+    gBS->CloseEvent (PciEnumerated);\r
+  } else {\r
+    DEBUG ((EFI_D_INFO, "%a: PCI enumeration pending, registered callback\n",\r
+      __FUNCTION__));\r
+  }\r
 \r
 \r
-  Status = InstallAcpiTables (FindAcpiTableProtocol ());\r
   return Status;\r
 }\r
   return Status;\r
 }\r
index 13c8009ed2bd413e2bb7dc8a758b440fcbf71335..22ce165852f9c2dd41e665f5157d4aae9812d9f7 100644 (file)
@@ -33,6 +33,7 @@
 \r
 [Packages]\r
   MdePkg/MdePkg.dec\r
 \r
 [Packages]\r
   MdePkg/MdePkg.dec\r
+  MdeModulePkg/MdeModulePkg.dec\r
   OvmfPkg/OvmfPkg.dec\r
 \r
 [LibraryClasses]\r
   OvmfPkg/OvmfPkg.dec\r
 \r
 [LibraryClasses]\r
 \r
 [Protocols]\r
   gEfiAcpiTableProtocolGuid                     # PROTOCOL ALWAYS_CONSUMED\r
 \r
 [Protocols]\r
   gEfiAcpiTableProtocolGuid                     # PROTOCOL ALWAYS_CONSUMED\r
+  gEfiPciEnumerationCompleteProtocolGuid        # PROTOCOL SOMETIMES_CONSUMED\r
+\r
+[Pcd]\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration\r
 \r
 [Depex]\r
   gEfiAcpiTableProtocolGuid\r
 \r
 [Depex]\r
   gEfiAcpiTableProtocolGuid\r
-\r
-[Depex.IA32, Depex.X64]\r
-  gEfiPciEnumerationCompleteProtocolGuid\r