---
MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.c
| 43 ++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git
a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.c
b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.c
index 5c93e2a7663c..a14c06e7f4e1 100644
---
a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.c
+++
b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.c
@@ -15,6 +15,8 @@
STATIC UINTN mUniqueIdCounter = 0;
EFI_CPU_ARCH_PROTOCOL *mCpu;
+STATIC VOID *mProtocolNotifyRegistration;
+
//
// We only support the following device types
//
@@ -250,6 +252,43 @@ STATIC EFI_DRIVER_BINDING_PROTOCOL gDriverBinding = {
NULL
};
+STATIC
+VOID
+EFIAPI
+NonDiscoverablePciDeviceProtocolNotify (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ EFI_STATUS Status;
+ EFI_HANDLE *Handles;
+ UINTN HandleCount;
+ UINTN Index;
+
+ Status = gBS->LocateHandleBuffer (ByRegisterNotify, NULL,
+ mProtocolNotifyRegistration, &HandleCount, &Handles);
+ if (EFI_ERROR (Status)) {
+ if (Status != EFI_NOT_FOUND) {
+ DEBUG ((DEBUG_WARN, "%a: LocateHandleBuffer() failed - %r\n",
+ __FUNCTION__, Status));
+ }
+ return;
+ }
+
+ for (Index = 0; Index < HandleCount; Index++) {
+ //
+ // Connect each newly registered gEdkiiNonDiscoverableDeviceProtocolGuid
+ // instance non-recursively to this driver specifically. This ensures that
+ // PCI I/O instances exist for each, regardless of whether ConnectAll() is
+ // used at any point.
+ //
+ Status = gBS->ConnectController (Handles[Index], gImageHandle, NULL,
FALSE);
+ DEBUG ((DEBUG_VERBOSE, "%a: ConnectController () returned %r\n",
+ __FUNCTION__, Status));
+ }
+ gBS->FreePool (Handles);
+}
+
/**
Entry point of this driver.
@@ -272,6 +311,10 @@ NonDiscoverablePciDeviceDxeEntryPoint (
Status = gBS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL, (VOID
**)&mCpu);
ASSERT_EFI_ERROR(Status);
+ EfiCreateProtocolNotifyEvent (&gEdkiiNonDiscoverableDeviceProtocolGuid,
+ TPL_CALLBACK, NonDiscoverablePciDeviceProtocolNotify, NULL,
+ &mProtocolNotifyRegistration);
+
return EfiLibInstallDriverBindingComponentName2 (
ImageHandle,
SystemTable,
--
2.17.1