]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/AcpiPlatformDxe/EntryPoint.c
MdeModulePkg: add ARM/AARCH64 requirements to .dsc
[mirror_edk2.git] / OvmfPkg / AcpiPlatformDxe / EntryPoint.c
index d782b610bd0814ab2914d6fc8d3033a532106c0b..1bfd31a0371a479a73a3999c4f85d470d0dd40bf 100644 (file)
@@ -13,6 +13,7 @@
   WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 **/\r
 \r
+#include <Guid/RootBridgesConnectedEventGroup.h>\r
 #include "AcpiPlatform.h"\r
 \r
 STATIC\r
@@ -33,6 +34,28 @@ FindAcpiTableProtocol (
   return AcpiTable;\r
 }\r
 \r
+\r
+STATIC\r
+VOID\r
+EFIAPI\r
+OnRootBridgesConnected (\r
+  IN EFI_EVENT Event,\r
+  IN VOID      *Context\r
+  )\r
+{\r
+  EFI_STATUS Status;\r
+\r
+  DEBUG ((EFI_D_INFO,\r
+    "%a: root bridges have been connected, 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
@@ -41,7 +64,33 @@ AcpiPlatformEntryPoint (
   )\r
 {\r
   EFI_STATUS Status;\r
+  EFI_EVENT  RootBridgesConnected;\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
+  // Otherwise, delay installing the ACPI tables until root bridges are\r
+  // connected. The entry point's return status will only reflect the callback\r
+  // setup. (Note that we're a DXE_DRIVER; our entry point function is invoked\r
+  // strictly before BDS is entered and can connect the root bridges.)\r
+  //\r
+  Status = gBS->CreateEventEx (EVT_NOTIFY_SIGNAL, TPL_CALLBACK,\r
+                  OnRootBridgesConnected, NULL /* Context */,\r
+                  &gRootBridgesConnectedEventGroupGuid, &RootBridgesConnected);\r
+  if (!EFI_ERROR (Status)) {\r
+    DEBUG ((EFI_D_INFO,\r
+      "%a: waiting for root bridges to be connected, registered callback\n",\r
+      __FUNCTION__));\r
+  }\r
 \r
-  Status = InstallAcpiTables (FindAcpiTableProtocol ());\r
   return Status;\r
 }\r