]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciBus.c
Code scrub for PCI Bus module and PciIncompatibleDeviceSupportLib module.
[mirror_edk2.git] / IntelFrameworkModulePkg / Bus / Pci / PciBusDxe / PciBus.c
index 304a543f4485ea0ff5df42eabe08fdee6f77e6da..7af1b10f7ed09cd0858af3f38eba74590a025d26 100644 (file)
@@ -1,24 +1,29 @@
-/**@file\r
-   Driver Binding functions for PCI bus module.\r
-   \r
-Copyright (c) 2006, 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
+/** @file\r
+  Driver Binding functions for PCI Bus module.\r
 \r
-**/\r
+  Single PCI bus driver instance will manager all PCI Root Bridges in one EFI based firmware,\r
+  since all PCI Root Bridges' resources need to be managed together.\r
+  Supported() function will try to get PCI Root Bridge IO Protocol.\r
+  Start() function will get PCI Host Bridge Resource Allocation Protocol to manage all\r
+  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 - 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
 #include "PciBus.h"\r
 \r
 //\r
 // PCI Bus Driver Global Variables\r
 //\r
-\r
 EFI_DRIVER_BINDING_PROTOCOL                   gPciBusDriverBinding = {\r
   PciBusDriverBindingSupported,\r
   PciBusDriverBindingStart,\r
@@ -28,26 +33,32 @@ EFI_DRIVER_BINDING_PROTOCOL                   gPciBusDriverBinding = {
   NULL\r
 };\r
 \r
-EFI_INCOMPATIBLE_PCI_DEVICE_SUPPORT_PROTOCOL  *gEfiIncompatiblePciDeviceSupport = NULL;\r
 EFI_HANDLE                                    gPciHostBrigeHandles[PCI_MAX_HOST_BRIDGE_NUM];\r
-UINTN                                         gPciHostBridgeNumber;\r
-BOOLEAN                                       gFullEnumeration;\r
-UINT64                                        gAllOne   = 0xFFFFFFFFFFFFFFFFULL;\r
-UINT64                                        gAllZero  = 0;\r
+EFI_INCOMPATIBLE_PCI_DEVICE_SUPPORT_PROTOCOL  *gEfiIncompatiblePciDeviceSupport = NULL;\r
+UINTN                                         gPciHostBridgeNumber = 0;\r
+BOOLEAN                                       gFullEnumeration     = TRUE;\r
+UINT64                                        gAllOne              = 0xFFFFFFFFFFFFFFFFULL;\r
+UINT64                                        gAllZero             = 0;\r
 \r
 EFI_PCI_PLATFORM_PROTOCOL                     *gPciPlatformProtocol;\r
 \r
-//\r
-// PCI Bus Driver Support Functions\r
-//\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_PCI_HOTPLUG_REQUEST_PROTOCOL mPciHotPlugRequest = {\r
+  PciHotPlugRequestNotify\r
+};\r
+\r
 /**\r
-  Initialize the global variables\r
-  publish the driver binding protocol\r
+  The Entry Point for PCI Bus module. The user code starts with this function.\r
 \r
-  @param[IN] ImageHandle,\r
-  @param[IN] *SystemTable\r
+  Installs driver module protocols and. Creates virtual device handles for ConIn,\r
+  ConOut, and StdErr. Installs Simple Text In protocol, Simple Text In Ex protocol,\r
+  Simple Pointer protocol, Absolute Pointer protocol on those virtual handlers.\r
+  Installs Graphics Output protocol and/or UGA Draw protocol if needed.\r
 \r
-  @retval status of installing driver binding component name protocol.\r
+  @param[in] ImageHandle    The firmware allocated handle for the EFI image.\r
+  @param[in] SystemTable    A pointer to the EFI System Table.\r
+\r
+  @retval EFI_SUCCESS       The entry point is executed successfully.\r
+  @retval other             Some error occurred when executing this entry point.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -58,13 +69,13 @@ PciBusEntryPoint (
   )\r
 {\r
   EFI_STATUS  Status;\r
+  EFI_HANDLE  Handle;\r
 \r
+  //\r
+  // Initializes PCI devices pool\r
+  //\r
   InitializePciDevicePool ();\r
 \r
-  gFullEnumeration      = TRUE;\r
-\r
-  gPciHostBridgeNumber  = 0;\r
-  \r
   //\r
   // Install driver model protocol(s).\r
   //\r
@@ -78,8 +89,19 @@ PciBusEntryPoint (
              );\r
   ASSERT_EFI_ERROR (Status);\r
 \r
-  InstallHotPlugRequestProtocol (&Status);\r
-  \r
+  if (FeaturePcdGet (PcdPciBusHotplugDeviceSupport)) {\r
+    //\r
+    // If Hot Plug is supported, install EFI PCI Hot Plug Request protocol.\r
+    //\r
+    Handle = NULL;\r
+    Status = gBS->InstallProtocolInterface (\r
+                    &Handle,\r
+                    &gEfiPciHotPlugRequestProtocolGuid,\r
+                    EFI_NATIVE_INTERFACE,\r
+                    &mPciHotPlugRequest\r
+                    );\r
+  }\r
+\r
   return Status;\r
 }\r
 \r
@@ -88,13 +110,13 @@ PciBusEntryPoint (
   than contains a gEfiPciRootBridgeIoProtocolGuid protocol can be supported.\r
 \r
   @param  This                Protocol instance pointer.\r
-  @param  ControllerHandle    Handle of device to test\r
-  @param  RemainingDevicePath Optional parameter use to pick a specific child\r
+  @param  Controller          Handle of device to test.\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
-  @retval EFI_ALREADY_STARTED This driver is already running on this device\r
-  @retval other               This driver does not support this device\r
+  @retval EFI_SUCCESS         This driver supports this device.\r
+  @retval EFI_ALREADY_STARTED This driver is already running on this device.\r
+  @retval other               This driver does not support this device.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -144,6 +166,9 @@ PciBusDriverBindingSupported (
         Controller\r
         );\r
 \r
+  //\r
+  // Check if Pci Root Bridge IO protocol is installed by platform\r
+  //\r
   Status = gBS->OpenProtocol (\r
                   Controller,\r
                   &gEfiPciRootBridgeIoProtocolGuid,\r
@@ -175,13 +200,13 @@ PciBusDriverBindingSupported (
   all device under PCI bus.\r
 \r
   @param  This                 Protocol instance pointer.\r
-  @param  ControllerHandle     Handle of device to bind driver to\r
-  @param  RemainingDevicePath  Optional parameter use to pick a specific child\r
+  @param  Controller           Handle of device to bind driver to.\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
-  @retval EFI_ALREADY_STARTED  This driver is already running on ControllerHandle\r
-  @retval other                This driver does not support this device\r
+  @retval EFI_SUCCESS          This driver is added to ControllerHandle.\r
+  @retval EFI_ALREADY_STARTED  This driver is already running on ControllerHandle.\r
+  @retval other                This driver does not support this device.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -223,7 +248,7 @@ PciBusDriverBindingStart (
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
-  \r
+\r
   //\r
   // Start all the devices under the entire host bridge.\r
   //\r
@@ -237,13 +262,13 @@ PciBusDriverBindingStart (
   created by this driver.\r
 \r
   @param  This              Protocol instance pointer.\r
-  @param  ControllerHandle  Handle of device to stop driver on\r
+  @param  Controller        Handle of device to stop driver on.\r
   @param  NumberOfChildren  Number of Handles in ChildHandleBuffer. If number of\r
                             children is zero stop the entire bus driver.\r
   @param  ChildHandleBuffer List of Child Handles to Stop.\r
 \r
-  @retval EFI_SUCCESS       This driver is removed ControllerHandle\r
-  @retval other             This driver was not removed from this device\r
+  @retval EFI_SUCCESS       This driver is removed ControllerHandle.\r
+  @retval other             This driver was not removed from this device.\r
 \r
 **/\r
 EFI_STATUS\r