]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/PciBusDxe: reference gFullEnumeration in one file
authorRuiyu Ni <ruiyu.ni@intel.com>
Mon, 22 Jan 2018 06:16:10 +0000 (14:16 +0800)
committerRuiyu Ni <ruiyu.ni@intel.com>
Wed, 24 Jan 2018 03:40:30 +0000 (11:40 +0800)
The patch is just a code cleanup with no functionality impact.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.c
MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c
MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.h

index 950cacc1203c28e10e5867c28eefc0280f2f4082..3bb5099bd3fff4e390d5f4a1478c50dda8195c3e 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 - 2016, 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
@@ -240,8 +240,9 @@ 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
   // Check RemainingDevicePath validation\r
@@ -321,12 +322,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
@@ -337,6 +360,7 @@ PciBusDriverBindingStart (
   //\r
   StartPciDevices (Controller);\r
 \r
+  gFullEnumeration = FALSE;\r
   return EFI_SUCCESS;\r
 }\r
 \r
index d31144739fc9a2c309d83b26f7ff3ea20a52bb52..f6aa327493fb32986bb6574022ce598fb307013a 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   PCI eunmeration implementation on entire PCI bus system for PCI Bus module.\r
 \r
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
 (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
@@ -19,7 +19,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
   This routine is used to enumerate entire pci bus system\r
   in a given platform.\r
 \r
-  @param Controller  Parent controller handle.\r
+  @param Controller          Parent controller handle.\r
+  @param HostBridgeHandle    Host bridge handle.\r
 \r
   @retval EFI_SUCCESS    PCI enumeration finished successfully.\r
   @retval other          Some error occurred when enumerating the pci bus system.\r
@@ -27,41 +28,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 **/\r
 EFI_STATUS\r
 PciEnumerator (\r
-  IN EFI_HANDLE                    Controller\r
+  IN EFI_HANDLE                    Controller,\r
+  IN EFI_HANDLE                    HostBridgeHandle\r
   )\r
 {\r
-  EFI_HANDLE                                        HostBridgeHandle;\r
   EFI_STATUS                                        Status;\r
   EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL  *PciResAlloc;\r
-  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL                   *PciRootBridgeIo;\r
-\r
-  //\r
-  // If PCI bus has already done the full enumeration, never do it again\r
-  //\r
-  if (!gFullEnumeration) {\r
-    return PciEnumeratorLight (Controller);\r
-  }\r
-\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
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Get the host bridge handle\r
-  //\r
-  HostBridgeHandle = PciRootBridgeIo->ParentHandle;\r
 \r
   //\r
   // Get the pci host bridge resource allocation protocol\r
@@ -132,8 +104,6 @@ PciEnumerator (
     return Status;\r
   }\r
 \r
-  gFullEnumeration = FALSE;\r
-\r
   Status = gBS->InstallProtocolInterface (\r
                   &HostBridgeHandle,\r
                   &gEfiPciEnumerationCompleteProtocolGuid,\r
index 46f56618d4a86a6b5456ea870fe3f0edc2d408bd..2df1fb0b94168ccc320b3faac841c19c68c882c4 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   PCI bus enumeration logic function declaration for PCI bus module.\r
 \r
-Copyright (c) 2006 - 2016, 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
@@ -21,7 +21,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
   This routine is used to enumerate entire pci bus system\r
   in a given platform.\r
 \r
-  @param Controller  Parent controller handle.\r
+  @param Controller          Parent controller handle.\r
+  @param HostBridgeHandle    Host bridge handle.\r
 \r
   @retval EFI_SUCCESS    PCI enumeration finished successfully.\r
   @retval other          Some error occurred when enumerating the pci bus system.\r
@@ -29,7 +30,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 **/\r
 EFI_STATUS\r
 PciEnumerator (\r
-  IN EFI_HANDLE                    Controller\r
+  IN EFI_HANDLE                    Controller,\r
+  IN EFI_HANDLE                    HostBridgeHandle\r
   );\r
 \r
 /**\r