+ 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