]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c
Code scrub for PCI Bus module and PciIncompatibleDeviceSupportLib module.
[mirror_edk2.git] / IntelFrameworkModulePkg / Bus / Pci / PciBusDxe / PciDeviceSupport.c
index 4872e2206e34a87da1af4bf2d7140ab0d4fb317a..71a5cb3810c2c2b3c058a8ae5f67dfbab2843874 100644 (file)
@@ -1,14 +1,14 @@
 /** @file\r
   Supporting functions implementaion for PCI devices management.\r
 \r
-Copyright (c) 2006 - 2009, Intel Corporation                                                         \r
-All rights reserved. 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
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+Copyright (c) 2006 - 2009, Intel Corporation\r
+All rights reserved. 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
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
 **/\r
 \r
@@ -66,9 +66,9 @@ InsertPciDevice (
 \r
 /**\r
   Destroy root bridge and remove it from deivce tree.\r
-  \r
+\r
   @param RootBridge     The bridge want to be removed.\r
-  \r
+\r
 **/\r
 VOID\r
 DestroyRootBridge (\r
@@ -187,10 +187,10 @@ DestroyRootBridgeByHandle (
 }\r
 \r
 /**\r
-  This function registers the PCI IO device. \r
+  This function registers the PCI IO device.\r
 \r
-  It creates a handle for this PCI IO device (if the handle does not exist), attaches \r
-  appropriate protocols onto the handle, does necessary initialization, and sets up \r
+  It creates a handle for this PCI IO device (if the handle does not exist), attaches\r
+  appropriate protocols onto the handle, does necessary initialization, and sets up\r
   parent/child relationship with its bus controller.\r
 \r
   @param Controller     An EFI handle for the PCI bus controller.\r
@@ -198,7 +198,7 @@ DestroyRootBridgeByHandle (
   @param Handle         A pointer to hold the returned EFI handle for the PCI IO device.\r
 \r
   @retval EFI_SUCCESS   The PCI device is successfully registered.\r
-  @retval Others        An error occurred when registering the PCI device.\r
+  @retval other         An error occurred when registering the PCI device.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -244,7 +244,7 @@ RegisterPciDevice (
   if (!EFI_ERROR (Status)) {\r
     PciIoDevice->IsPciExp = TRUE;\r
   }\r
-  \r
+\r
   //\r
   // Force Interrupt line to "Unknown" or "No Connection"\r
   //\r
@@ -330,7 +330,7 @@ RegisterPciDevice (
 \r
   if (PciIoDevice->BusOverride) {\r
     //\r
-    // Install BusSpecificDriverOverride Protocol\r
+    // Install Bus Specific Driver Override Protocol\r
     //\r
     Status = gBS->InstallMultipleProtocolInterfaces (\r
                     &PciIoDevice->Handle,\r
@@ -437,7 +437,7 @@ RemoveAllPciDeviceOnBridge (
   @param Handle        PCI device handle.\r
 \r
   @retval EFI_SUCCESS  The PCI device is successfully de-registered.\r
-  @retval Others       An error occurred when de-registering the PCI device.\r
+  @retval other        An error occurred when de-registering the PCI device.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -503,7 +503,8 @@ DeRegisterPciDevice (
                     );\r
 \r
     //\r
-    // Un-install the device path protocol and pci io protocol\r
+    // Un-install the Device Path protocol and PCI I/O protocol\r
+    // and Bus Specific Driver Override protocol if needed.\r
     //\r
     if (PciIoDevice->BusOverride) {\r
       Status = gBS->UninstallMultipleProtocolInterfaces (\r
@@ -595,8 +596,8 @@ DeRegisterPciDevice (
 \r
   @retval EFI_NOT_READY   Device is not allocated.\r
   @retval EFI_UNSUPPORTED Device only support PCI-PCI bridge.\r
-  @retval EFI_NOT_FOUND   Can not find the specific device\r
-  @retval EFI_SUCCESS     Success to start Pci device on bridge\r
+  @retval EFI_NOT_FOUND   Can not find the specific device.\r
+  @retval EFI_SUCCESS     Success to start Pci device on bridge.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -625,7 +626,7 @@ StartPciDevicesOnBridge (
 \r
       Node.DevPath = RemainingDevicePath;\r
 \r
-      if (Node.Pci->Device != PciIoDevice->DeviceNumber || \r
+      if (Node.Pci->Device != PciIoDevice->DeviceNumber ||\r
           Node.Pci->Function != PciIoDevice->FunctionNumber) {\r
         CurrentLink = CurrentLink->ForwardLink;\r
         continue;\r
@@ -637,7 +638,7 @@ StartPciDevicesOnBridge (
       if (!PciIoDevice->Allocated) {\r
         return EFI_NOT_READY;\r
       }\r
-      \r
+\r
       //\r
       // Check if the current node has been registered before\r
       // If it is not, register it\r
@@ -655,7 +656,7 @@ StartPciDevicesOnBridge (
         ChildHandleBuffer[*NumberOfChildren] = PciIoDevice->Handle;\r
         (*NumberOfChildren)++;\r
       }\r
-      \r
+\r
       //\r
       // Get the next device path\r
       //\r
@@ -752,18 +753,21 @@ StartPciDevicesOnBridge (
 }\r
 \r
 /**\r
-  Start to manage all the PCI devices it found previously under \r
+  Start to manage all the PCI devices it found previously under\r
   the entire host bridge.\r
 \r
   @param Controller          The root bridge handle.\r
 \r
+  @retval EFI_NOT_READY   Device is not allocated.\r
+  @retval EFI_SUCCESS     Success to start Pci device on host bridge.\r
+\r
 **/\r
 EFI_STATUS\r
 StartPciDevices (\r
   IN EFI_HANDLE                         Controller\r
   )\r
-\r
 {\r
+  EFI_STATUS        Status;\r
   PCI_IO_DEVICE     *RootBridge;\r
   EFI_HANDLE        ThisHostBridge;\r
   LIST_ENTRY        *CurrentLink;\r
@@ -781,13 +785,16 @@ StartPciDevices (
     // Locate the right root bridge to start\r
     //\r
     if (RootBridge->PciRootBridgeIo->ParentHandle == ThisHostBridge) {\r
-      StartPciDevicesOnBridge (\r
-        RootBridge->Handle,\r
-        RootBridge,\r
-        NULL,\r
-        NULL,\r
-        NULL\r
-        );\r
+      Status = StartPciDevicesOnBridge (\r
+                  RootBridge->Handle,\r
+                  RootBridge,\r
+                  NULL,\r
+                  NULL,\r
+                  NULL\r
+                  );\r
+      if (EFI_ERROR (Status)) {\r
+        return Status;\r
+      }\r
     }\r
 \r
     CurrentLink = CurrentLink->ForwardLink;\r
@@ -913,10 +920,10 @@ GetRootBridgeByHandle (
 \r
 /**\r
   Judege whether Pci device existed.\r
-  \r
+\r
   @param Bridge       Parent bridege instance.\r
   @param PciIoDevice  Device instance.\r
-  \r
+\r
   @retval TRUE        Pci device existed.\r
   @retval FALSE       Pci device did not exist.\r
 \r
@@ -955,9 +962,9 @@ PciDeviceExisted (
 \r
 /**\r
   Get the active VGA device on the same segment.\r
-  \r
+\r
   @param VgaDevice    PCI IO instance for the VGA device.\r
-  \r
+\r
   @return The active VGA device on the same segment.\r
 \r
 **/\r
@@ -992,9 +999,9 @@ ActiveVGADeviceOnTheSameSegment (
 \r
 /**\r
   Get the active VGA device on the root bridge.\r
-  \r
+\r
   @param RootBridge  PCI IO instance for the root bridge.\r
-  \r
+\r
   @return The active VGA device.\r
 \r
 **/\r
@@ -1042,10 +1049,10 @@ ActiveVGADeviceOnTheRootBridge (
   @param RootBridge           Root bridege Io instance.\r
   @param RemainingDevicePath  Given searching device path.\r
   @param PciAddress           Buffer holding searched result.\r
-  \r
+\r
   @retval EFI_SUCCESS         PCI address was stored in PciAddress\r
   @retval EFI_NOT_FOUND       Can not find the specific device path.\r
-  \r
+\r
 **/\r
 EFI_STATUS\r
 GetHpcPciAddressFromRootBridge (\r