]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciBus.c
1. Impl PI 1.2 PCI part. Major changes include:
[mirror_edk2.git] / IntelFrameworkModulePkg / Bus / Pci / PciBusDxe / PciBus.c
diff --git a/IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciBus.c b/IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciBus.c
deleted file mode 100644 (file)
index 1a4adf5..0000000
+++ /dev/null
@@ -1,368 +0,0 @@
-/** @file\r
-  Driver Binding functions for PCI Bus module.\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
-EFI_DRIVER_BINDING_PROTOCOL                   gPciBusDriverBinding = {\r
-  PciBusDriverBindingSupported,\r
-  PciBusDriverBindingStart,\r
-  PciBusDriverBindingStop,\r
-  0xa,\r
-  NULL,\r
-  NULL\r
-};\r
-\r
-EFI_HANDLE                                    gPciHostBrigeHandles[PCI_MAX_HOST_BRIDGE_NUM];\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
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_PCI_HOTPLUG_REQUEST_PROTOCOL mPciHotPlugRequest = {\r
-  PciHotPlugRequestNotify\r
-};\r
-\r
-/**\r
-  The Entry Point for PCI Bus module. The user code starts with this function.\r
-\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
-  @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
-EFIAPI\r
-PciBusEntryPoint (\r
-  IN EFI_HANDLE         ImageHandle,\r
-  IN EFI_SYSTEM_TABLE   *SystemTable\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  EFI_HANDLE  Handle;\r
-\r
-  //\r
-  // Initializes PCI devices pool\r
-  //\r
-  InitializePciDevicePool ();\r
-\r
-  //\r
-  // Install driver model protocol(s).\r
-  //\r
-  Status = EfiLibInstallDriverBindingComponentName2 (\r
-             ImageHandle,\r
-             SystemTable,\r
-             &gPciBusDriverBinding,\r
-             ImageHandle,\r
-             &gPciBusComponentName,\r
-             &gPciBusComponentName2\r
-             );\r
-  ASSERT_EFI_ERROR (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
-/**\r
-  Test to see if this driver supports ControllerHandle. Any ControllerHandle\r
-  than contains a gEfiPciRootBridgeIoProtocolGuid protocol can be supported.\r
-\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
-                              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
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PciBusDriverBindingSupported (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
-  IN EFI_HANDLE                     Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
-  )\r
-{\r
-  EFI_STATUS                      Status;\r
-  EFI_DEVICE_PATH_PROTOCOL        *ParentDevicePath;\r
-  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo;\r
-  EFI_DEV_PATH_PTR                Node;\r
-\r
-  //\r
-  // Check RemainingDevicePath validation\r
-  //\r
-  if (RemainingDevicePath != NULL) {\r
-    //\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
-      //\r
-      // If RemainingDevicePath isn't the End of Device Path Node,\r
-      // check its validation\r
-      //\r
-      Node.DevPath = RemainingDevicePath;\r
-      if (Node.DevPath->Type != HARDWARE_DEVICE_PATH ||\r
-          Node.DevPath->SubType != HW_PCI_DP         ||\r
-          DevicePathNodeLength(Node.DevPath) != sizeof(PCI_DEVICE_PATH)) {\r
-        return EFI_UNSUPPORTED;\r
-      }\r
-    }\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
-                  (VOID **) &PciRootBridgeIo,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (Status == EFI_ALREADY_STARTED) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Close the I/O Abstraction(s) used to perform the supported test\r
-  //\r
-  gBS->CloseProtocol (\r
-        Controller,\r
-        &gEfiPciRootBridgeIoProtocolGuid,\r
-        This->DriverBindingHandle,\r
-        Controller\r
-        );\r
-\r
-  //\r
-  // Open the EFI Device Path protocol needed to perform the supported test\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  (VOID **) &ParentDevicePath,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (Status == EFI_ALREADY_STARTED) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Close protocol, don't use device path protocol in the Support() function\r
-  //\r
-  gBS->CloseProtocol (\r
-        Controller,\r
-        &gEfiDevicePathProtocolGuid,\r
-        This->DriverBindingHandle,\r
-        Controller\r
-        );\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Start this driver on ControllerHandle and enumerate Pci bus and start\r
-  all device under PCI bus.\r
-\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
-                               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
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PciBusDriverBindingStart (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  //\r
-  // Check RemainingDevicePath validation\r
-  //\r
-  if (RemainingDevicePath != NULL) {\r
-    //\r
-    // Check if RemainingDevicePath is the End of Device Path Node, \r
-    // if yes, return EFI_SUCCESS\r
-    //\r
-    if (IsDevicePathEnd (RemainingDevicePath)) {\r
-      return EFI_SUCCESS;\r
-    }\r
-  }\r
-\r
-  Status = gBS->LocateProtocol (\r
-                  &gEfiIncompatiblePciDeviceSupportProtocolGuid,\r
-                  NULL,\r
-                  (VOID **) &gEfiIncompatiblePciDeviceSupport\r
-                  );\r
-\r
-  //\r
-  // If PCI Platform protocol is available, get it now.\r
-  // If the platform implements this, it must be installed before BDS phase\r
-  //\r
-  gPciPlatformProtocol = NULL;\r
-  gBS->LocateProtocol (\r
-        &gEfiPciPlatformProtocolGuid,\r
-        NULL,\r
-        (VOID **) &gPciPlatformProtocol\r
-        );\r
-\r
-  gFullEnumeration = (BOOLEAN) ((SearchHostBridgeHandle (Controller) ? FALSE : TRUE));\r
-\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
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Start all the devices under the entire host bridge.\r
-  //\r
-  StartPciDevices (Controller);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Stop this driver on ControllerHandle. Support stoping any child handles\r
-  created by this driver.\r
-\r
-  @param  This              Protocol instance pointer.\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
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PciBusDriverBindingStop (\r
-  IN  EFI_DRIVER_BINDING_PROTOCOL   *This,\r
-  IN  EFI_HANDLE                    Controller,\r
-  IN  UINTN                         NumberOfChildren,\r
-  IN  EFI_HANDLE                    *ChildHandleBuffer\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  UINTN       Index;\r
-  BOOLEAN     AllChildrenStopped;\r
-\r
-  if (NumberOfChildren == 0) {\r
-    //\r
-    // Close the bus driver\r
-    //\r
-    gBS->CloseProtocol (\r
-          Controller,\r
-          &gEfiDevicePathProtocolGuid,\r
-          This->DriverBindingHandle,\r
-          Controller\r
-          );\r
-    gBS->CloseProtocol (\r
-          Controller,\r
-          &gEfiPciRootBridgeIoProtocolGuid,\r
-          This->DriverBindingHandle,\r
-          Controller\r
-          );\r
-\r
-    DestroyRootBridgeByHandle (\r
-      Controller\r
-      );\r
-\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  //\r
-  // Stop all the children\r
-  //\r
-\r
-  AllChildrenStopped = TRUE;\r
-\r
-  for (Index = 0; Index < NumberOfChildren; Index++) {\r
-\r
-    //\r
-    // De register all the pci device\r
-    //\r
-    Status = DeRegisterPciDevice (Controller, ChildHandleBuffer[Index]);\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      AllChildrenStopped = FALSE;\r
-    }\r
-  }\r
-\r
-  if (!AllChildrenStopped) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r