]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/AcpiPlatformDxe/EntryPoint.c
OvmfPkg: Apply uncrustify changes
[mirror_edk2.git] / OvmfPkg / AcpiPlatformDxe / EntryPoint.c
index d782b610bd0814ab2914d6fc8d3033a532106c0b..143e860fe187c2f2b6c84d2769fc41306d9171be 100644 (file)
@@ -4,15 +4,15 @@
   Copyright (C) 2015, Red Hat, Inc.\r
   Copyright (c) 2008 - 2015, Intel Corporation. All rights reserved.<BR>\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
+#include <Guid/RootBridgesConnectedEventGroup.h> // gRootBridgesConnectedEve...\r
+#include <Library/DebugLib.h>                    // DEBUG()\r
+#include <Library/PcdLib.h>                      // PcdGetBool()\r
+#include <Library/UefiBootServicesTableLib.h>    // gBS\r
+#include <Protocol/AcpiTable.h>                  // EFI_ACPI_TABLE_PROTOCOL\r
+\r
 #include "AcpiPlatform.h"\r
 \r
 STATIC\r
@@ -21,27 +21,87 @@ FindAcpiTableProtocol (
   VOID\r
   )\r
 {\r
-  EFI_STATUS              Status;\r
-  EFI_ACPI_TABLE_PROTOCOL *AcpiTable;\r
+  EFI_STATUS               Status;\r
+  EFI_ACPI_TABLE_PROTOCOL  *AcpiTable;\r
 \r
   Status = gBS->LocateProtocol (\r
                   &gEfiAcpiTableProtocolGuid,\r
                   NULL,\r
-                  (VOID**)&AcpiTable\r
+                  (VOID **)&AcpiTable\r
                   );\r
   ASSERT_EFI_ERROR (Status);\r
   return AcpiTable;\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 ((\r
+    DEBUG_INFO,\r
+    "%a: root bridges have been connected, installing ACPI tables\n",\r
+    __FUNCTION__\r
+    ));\r
+  Status = InstallAcpiTables (FindAcpiTableProtocol ());\r
+  if (EFI_ERROR (Status)) {\r
+    DEBUG ((DEBUG_ERROR, "%a: InstallAcpiTables: %r\n", __FUNCTION__, Status));\r
+  }\r
+\r
+  gBS->CloseEvent (Event);\r
+}\r
+\r
 EFI_STATUS\r
 EFIAPI\r
 AcpiPlatformEntryPoint (\r
-  IN EFI_HANDLE         ImageHandle,\r
-  IN EFI_SYSTEM_TABLE   *SystemTable\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
   )\r
 {\r
-  EFI_STATUS Status;\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 ((\r
+      DEBUG_INFO,\r
+      "%a: PCI or its enumeration disabled, installing "\r
+      "ACPI tables\n",\r
+      __FUNCTION__\r
+      ));\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 (\r
+                  EVT_NOTIFY_SIGNAL,\r
+                  TPL_CALLBACK,\r
+                  OnRootBridgesConnected,\r
+                  NULL /* Context */,\r
+                  &gRootBridgesConnectedEventGroupGuid,\r
+                  &RootBridgesConnected\r
+                  );\r
+  if (!EFI_ERROR (Status)) {\r
+    DEBUG ((\r
+      DEBUG_INFO,\r
+      "%a: waiting for root bridges to be connected, registered callback\n",\r
+      __FUNCTION__\r
+      ));\r
+  }\r
 \r
-  Status = InstallAcpiTables (FindAcpiTableProtocol ());\r
   return Status;\r
 }\r