]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.c
MdeModulePkg: Clean up source files
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / PciBusDxe / PciBus.c
index beecf79a35325dee57a1ca1cd04e2452c35ca87b..9ae45cca9be926081a7de55f5b69748952c26410 100644 (file)
@@ -8,7 +8,7 @@
   PCI Root Bridges. So it means platform needs install PCI Root Bridge IO protocol for each\r
   PCI Root Bus and install PCI Host Bridge Resource Allocation Protocol.\r
 \r
-Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -34,7 +34,7 @@ EFI_DRIVER_BINDING_PROTOCOL                   gPciBusDriverBinding = {
 };\r
 \r
 EFI_HANDLE                                    gPciHostBrigeHandles[PCI_MAX_HOST_BRIDGE_NUM];\r
-EFI_INCOMPATIBLE_PCI_DEVICE_SUPPORT_PROTOCOL  *gEfiIncompatiblePciDeviceSupport = NULL;\r
+EFI_INCOMPATIBLE_PCI_DEVICE_SUPPORT_PROTOCOL  *gIncompatiblePciDeviceSupport = NULL;\r
 UINTN                                         gPciHostBridgeNumber = 0;\r
 BOOLEAN                                       gFullEnumeration     = TRUE;\r
 UINT64                                        gAllOne              = 0xFFFFFFFFFFFFFFFFULL;\r
@@ -42,6 +42,7 @@ UINT64                                        gAllZero             = 0;
 \r
 EFI_PCI_PLATFORM_PROTOCOL                     *gPciPlatformProtocol;\r
 EFI_PCI_OVERRIDE_PROTOCOL                     *gPciOverrideProtocol;\r
+EDKII_IOMMU_PROTOCOL                          *mIoMmuProtocol;\r
 \r
 \r
 GLOBAL_REMOVE_IF_UNREFERENCED EFI_PCI_HOTPLUG_REQUEST_PROTOCOL mPciHotPlugRequest = {\r
@@ -113,7 +114,7 @@ PciBusEntryPoint (
 \r
   @param  This                Protocol instance pointer.\r
   @param  Controller          Handle of device to test.\r
-  @param  RemainingDevicePath Optional parameter use to pick a specific child.\r
+  @param  RemainingDevicePath Optional parameter use to pick a specific child\r
                               device to start.\r
 \r
   @retval EFI_SUCCESS         This driver supports this device.\r
@@ -139,7 +140,7 @@ PciBusDriverBindingSupported (
   //\r
   if (RemainingDevicePath != NULL) {\r
     //\r
-    // Check if RemainingDevicePath is the End of Device Path Node, \r
+    // Check if RemainingDevicePath is the End of Device Path Node,\r
     // if yes, go on checking other conditions\r
     //\r
     if (!IsDevicePathEnd (RemainingDevicePath)) {\r
@@ -223,7 +224,7 @@ PciBusDriverBindingSupported (
 \r
   @param  This                 Protocol instance pointer.\r
   @param  Controller           Handle of device to bind driver to.\r
-  @param  RemainingDevicePath  Optional parameter use to pick a specific child.\r
+  @param  RemainingDevicePath  Optional parameter use to pick a specific child\r
                                device to start.\r
 \r
   @retval EFI_SUCCESS          This driver is added to ControllerHandle.\r
@@ -239,15 +240,21 @@ PciBusDriverBindingStart (
   IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
   )\r
 {\r
-  EFI_STATUS                Status;\r
-  EFI_DEVICE_PATH_PROTOCOL  *ParentDevicePath;\r
+  EFI_STATUS                      Status;\r
+  EFI_DEVICE_PATH_PROTOCOL        *ParentDevicePath;\r
+  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo;\r
+\r
+  //\r
+  // Initialize PciRootBridgeIo to suppress incorrect compiler warning.\r
+  //\r
+  PciRootBridgeIo = NULL;\r
 \r
   //\r
   // Check RemainingDevicePath validation\r
   //\r
   if (RemainingDevicePath != NULL) {\r
     //\r
-    // Check if RemainingDevicePath is the End of Device Path Node, \r
+    // Check if RemainingDevicePath is the End of Device Path Node,\r
     // if yes, return EFI_SUCCESS\r
     //\r
     if (IsDevicePathEnd (RemainingDevicePath)) {\r
@@ -258,7 +265,7 @@ PciBusDriverBindingStart (
   gBS->LocateProtocol (\r
          &gEfiIncompatiblePciDeviceSupportProtocolGuid,\r
          NULL,\r
-         (VOID **) &gEfiIncompatiblePciDeviceSupport\r
+         (VOID **) &gIncompatiblePciDeviceSupport\r
          );\r
 \r
   //\r
@@ -275,14 +282,22 @@ PciBusDriverBindingStart (
   //\r
   // If PCI Platform protocol doesn't exist, try to Pci Override Protocol.\r
   //\r
-  if (gPciPlatformProtocol == NULL) { \r
+  if (gPciPlatformProtocol == NULL) {\r
     gPciOverrideProtocol = NULL;\r
     gBS->LocateProtocol (\r
           &gEfiPciOverrideProtocolGuid,\r
           NULL,\r
           (VOID **) &gPciOverrideProtocol\r
           );\r
-  }  \r
+  }\r
+\r
+  if (mIoMmuProtocol == NULL) {\r
+    gBS->LocateProtocol (\r
+          &gEdkiiIoMmuProtocolGuid,\r
+          NULL,\r
+          (VOID **) &mIoMmuProtocol\r
+          );\r
+  }\r
 \r
   if (PcdGetBool (PcdPciDisableBusEnumeration)) {\r
     gFullEnumeration = FALSE;\r
@@ -300,7 +315,7 @@ PciBusDriverBindingStart (
                   This->DriverBindingHandle,\r
                   Controller,\r
                   EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                  );  \r
+                  );\r
   ASSERT_EFI_ERROR (Status);\r
 \r
   //\r
@@ -312,12 +327,34 @@ PciBusDriverBindingStart (
     ParentDevicePath\r
     );\r
 \r
+  Status = EFI_SUCCESS;\r
   //\r
   // Enumerate the entire host bridge\r
   // After enumeration, a database that records all the device information will be created\r
   //\r
   //\r
-  Status = PciEnumerator (Controller);\r
+  if (gFullEnumeration) {\r
+    //\r
+    // Get the rootbridge Io protocol to find the host bridge handle\r
+    //\r
+    Status = gBS->OpenProtocol (\r
+                    Controller,\r
+                    &gEfiPciRootBridgeIoProtocolGuid,\r
+                    (VOID **) &PciRootBridgeIo,\r
+                    gPciBusDriverBinding.DriverBindingHandle,\r
+                    Controller,\r
+                    EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                    );\r
+\r
+    if (!EFI_ERROR (Status)) {\r
+      Status = PciEnumerator (Controller, PciRootBridgeIo->ParentHandle);\r
+    }\r
+  } else {\r
+    //\r
+    // If PCI bus has already done the full enumeration, never do it again\r
+    //\r
+    Status = PciEnumeratorLight (Controller);\r
+  }\r
 \r
   if (EFI_ERROR (Status)) {\r
     return Status;\r
@@ -328,11 +365,23 @@ PciBusDriverBindingStart (
   //\r
   StartPciDevices (Controller);\r
 \r
-  return EFI_SUCCESS;\r
+  if (gFullEnumeration) {\r
+    gFullEnumeration = FALSE;\r
+\r
+    Status = gBS->InstallProtocolInterface (\r
+                    &PciRootBridgeIo->ParentHandle,\r
+                    &gEfiPciEnumerationCompleteProtocolGuid,\r
+                    EFI_NATIVE_INTERFACE,\r
+                    NULL\r
+                    );\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+\r
+  return Status;\r
 }\r
 \r
 /**\r
-  Stop this driver on ControllerHandle. Support stoping any child handles\r
+  Stop this driver on ControllerHandle. Support stopping any child handles\r
   created by this driver.\r
 \r
   @param  This              Protocol instance pointer.\r