Currently we only connect the root bus with bus number 0, by device path.
Soon we will possibly have several extra root buses, so connect all root
buses up-front (bus number zero and otherwise), by protocol GUID.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <ler...@redhat.com>
---
 OvmfPkg/Library/PlatformBdsLib/PlatformBdsLib.inf |  2 +-
 OvmfPkg/Library/PlatformBdsLib/BdsPlatform.h      | 25 +--------
 OvmfPkg/Library/PlatformBdsLib/BdsPlatform.c      | 53 ++++++--------------
 OvmfPkg/Library/PlatformBdsLib/PlatformData.c     | 13 -----
 4 files changed, 18 insertions(+), 75 deletions(-)

diff --git a/OvmfPkg/Library/PlatformBdsLib/PlatformBdsLib.inf 
b/OvmfPkg/Library/PlatformBdsLib/PlatformBdsLib.inf
index 5a28d78..ce29720 100644
--- a/OvmfPkg/Library/PlatformBdsLib/PlatformBdsLib.inf
+++ b/OvmfPkg/Library/PlatformBdsLib/PlatformBdsLib.inf
@@ -64,4 +64,4 @@
 
 [Protocols]
   gEfiDecompressProtocolGuid
-
+  gEfiPciRootBridgeIoProtocolGuid
diff --git a/OvmfPkg/Library/PlatformBdsLib/BdsPlatform.h 
b/OvmfPkg/Library/PlatformBdsLib/BdsPlatform.h
index 7006fb3..e3e950e 100644
--- a/OvmfPkg/Library/PlatformBdsLib/BdsPlatform.h
+++ b/OvmfPkg/Library/PlatformBdsLib/BdsPlatform.h
@@ -52,6 +52,7 @@ Abstract:
 #include <Protocol/PciIo.h>
 #include <Protocol/FirmwareVolume2.h>
 #include <Protocol/SimpleFileSystem.h>
+#include <Protocol/PciRootBridgeIo.h>
 
 #include <Guid/Acpi.h>
 #include <Guid/SmBios.h>
@@ -64,7 +65,6 @@ Abstract:
 extern BDS_CONSOLE_CONNECT_ENTRY  gPlatformConsole[];
 extern EFI_DEVICE_PATH_PROTOCOL   *gPlatformConnectSequence[];
 extern EFI_DEVICE_PATH_PROTOCOL   *gPlatformDriverOption[];
-extern EFI_DEVICE_PATH_PROTOCOL   *gPlatformRootBridges[];
 extern ACPI_HID_DEVICE_PATH       gPnpPs2KeyboardDeviceNode;
 extern ACPI_HID_DEVICE_PATH       gPnp16550ComPortDeviceNode;
 extern UART_DEVICE_PATH           gUartDeviceNode;
@@ -107,9 +107,6 @@ extern VENDOR_DEVICE_PATH         gTerminalTypeDeviceNode;
     0 \
   }
 
-#define gPciRootBridge \
-  PNPID_DEVICE_PATH_NODE(0x0A03)
-
 #define gPciIsaBridge \
   PCI_DEVICE_PATH_NODE(0, 0x1f)
 
@@ -152,16 +149,6 @@ extern VENDOR_DEVICE_PATH         gTerminalTypeDeviceNode;
     DEVICE_PATH_MESSAGING_PC_ANSI \
   }
 
-#define gEndEntire \
-  { \
-    END_DEVICE_PATH_TYPE, \
-    END_ENTIRE_DEVICE_PATH_SUBTYPE, \
-    { \
-      END_DEVICE_PATH_LENGTH, \
-      0 \
-    } \
-  }
-
 #define PCI_CLASS_SCC          0x07
 #define PCI_SUBCLASS_SERIAL    0x00
 #define PCI_IF_16550           0x02
@@ -172,14 +159,6 @@ extern VENDOR_DEVICE_PATH         gTerminalTypeDeviceNode;
 
 #define IS_PCI_ISA_PDECODE(_p)        IS_CLASS3 (_p, PCI_CLASS_BRIDGE, 
PCI_CLASS_BRIDGE_ISA_PDECODE, 0)
 
-//
-// Platform Root Bridge
-//
-typedef struct {
-  ACPI_HID_DEVICE_PATH      PciRootBridge;
-  EFI_DEVICE_PATH_PROTOCOL  End;
-} PLATFORM_ROOT_BRIDGE_DEVICE_PATH;
-
 typedef struct {
   ACPI_HID_DEVICE_PATH      PciRootBridge;
   PCI_DEVICE_PATH           IsaBridge;
@@ -223,8 +202,6 @@ typedef struct {
   EFI_DEVICE_PATH_PROTOCOL        End;
 } USB_CLASS_FORMAT_DEVICE_PATH;  
 
-extern PLATFORM_ROOT_BRIDGE_DEVICE_PATH  gPlatformRootBridge0;
-
 //
 // Platform BDS Functions
 //
diff --git a/OvmfPkg/Library/PlatformBdsLib/BdsPlatform.c 
b/OvmfPkg/Library/PlatformBdsLib/BdsPlatform.c
index e521f45..2254077 100644
--- a/OvmfPkg/Library/PlatformBdsLib/BdsPlatform.c
+++ b/OvmfPkg/Library/PlatformBdsLib/BdsPlatform.c
@@ -116,49 +116,27 @@ Returns:
 
 
 EFI_STATUS
+EFIAPI
 ConnectRootBridge (
-  VOID
+  IN EFI_HANDLE  RootBridgeHandle,
+  IN VOID        *Instance,
+  IN VOID        *Context
   )
-/*++
-
-Routine Description:
-
-  Connect RootBridge
-
-Arguments:
-
-  None.
-
-Returns:
-
-  EFI_SUCCESS             - Connect RootBridge successfully.
-  EFI_STATUS              - Connect RootBridge fail.
-
---*/
 {
-  EFI_STATUS                Status;
-  EFI_HANDLE                RootHandle;
+  EFI_STATUS Status;
 
   //
-  // Make all the PCI_IO protocols on PCI Seg 0 show up
+  // Make the PCI bus driver connect the root bridge, non-recursively. This
+  // will produce a number of child handles with PciIo on them.
   //
-  BdsLibConnectDevicePath (gPlatformRootBridges[0]);
-
-  Status = gBS->LocateDevicePath (
-                  &gEfiDevicePathProtocolGuid,
-                  &gPlatformRootBridges[0],
-                  &RootHandle
+  Status = gBS->ConnectController (
+                  RootBridgeHandle, // ControllerHandle
+                  NULL,             // DriverImageHandle
+                  NULL,             // RemainingDevicePath -- produce all
+                                    //   children
+                  FALSE             // Recursive
                   );
-  if (EFI_ERROR (Status)) {
-    return Status;
-  }
-
-  Status = gBS->ConnectController (RootHandle, NULL, NULL, FALSE);
-  if (EFI_ERROR (Status)) {
-    return Status;
-  }
-
-  return EFI_SUCCESS;
+  return Status;
 }
 
 
@@ -1216,7 +1194,8 @@ Returns:
 
   DEBUG ((EFI_D_INFO, "PlatformBdsPolicyBehavior\n"));
 
-  ConnectRootBridge ();
+  VisitAllInstancesOfProtocol (&gEfiPciRootBridgeIoProtocolGuid,
+    ConnectRootBridge, NULL);
 
   if (PcdGetBool (PcdOvmfFlashVariablesEnable)) {
     DEBUG ((EFI_D_INFO, "PlatformBdsPolicyBehavior: not restoring NvVars "
diff --git a/OvmfPkg/Library/PlatformBdsLib/PlatformData.c 
b/OvmfPkg/Library/PlatformBdsLib/PlatformData.c
index 1a30531..f69c1a8 100644
--- a/OvmfPkg/Library/PlatformBdsLib/PlatformData.c
+++ b/OvmfPkg/Library/PlatformBdsLib/PlatformData.c
@@ -26,19 +26,6 @@ UART_DEVICE_PATH           gUartDeviceNode            = 
gUart;
 VENDOR_DEVICE_PATH         gTerminalTypeDeviceNode    = gPcAnsiTerminal;
 
 //
-// Predefined platform root bridge
-//
-PLATFORM_ROOT_BRIDGE_DEVICE_PATH  gPlatformRootBridge0 = {
-  gPciRootBridge,
-  gEndEntire
-};
-
-EFI_DEVICE_PATH_PROTOCOL          *gPlatformRootBridges[] = {
-  (EFI_DEVICE_PATH_PROTOCOL *) &gPlatformRootBridge0,
-  NULL
-};
-
-//
 // Platform specific keyboard device path
 //
 
-- 
1.8.3.1



------------------------------------------------------------------------------
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to