]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Produce all the PciIo & Dpath protocol for all the pci devices under the current...
authorqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 19 Feb 2008 04:17:05 +0000 (04:17 +0000)
committerqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 19 Feb 2008 04:17:05 +0000 (04:17 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4703 6f19259b-4bc3-4df7-8a09-765794883524

IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c
IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.h
IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c
IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c
IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/pcibus.c

index 7a1d30e07c4711722eb91d3fa14f37ca0edf82c2..d19ee04bf4c5567e7847161277514f6807164233 100644 (file)
@@ -335,44 +335,48 @@ Returns:
   PciIoWrite (PciIo, EfiPciIoWidthUint8, 0x3C, 1, &Data8);\r
 \r
   //\r
-  // Process Platform OpRom\r
+  // Process OpRom\r
   //\r
-  if (gPciPlatformProtocol != NULL && !PciIoDevice->AllOpRomProcessed) {\r
+  if (!PciIoDevice->AllOpRomProcessed) {\r
     PciIoDevice->AllOpRomProcessed = TRUE;\r
 \r
-    Status = gPciPlatformProtocol->GetPciRom (\r
-                                     gPciPlatformProtocol,\r
-                                     PciIoDevice->Handle,\r
-                                     &PlatformOpRomBuffer,\r
-                                     &PlatformOpRomSize\r
-                                     );\r
-\r
-    if (!EFI_ERROR (Status)) {\r
-\r
-      //\r
-      // Have Platform OpRom\r
-      //\r
-      PciIoDevice->RomSize        = PlatformOpRomSize;\r
-      PciIoDevice->PciIo.RomSize  = PlatformOpRomSize;\r
-      PciIoDevice->PciIo.RomImage = PlatformOpRomBuffer;\r
-\r
-      //\r
-      // For OpROM read from gPciPlatformProtocol:\r
-      //     Add the Rom Image to internal database for later PCI light enumeration\r
-      //\r
-      PciRomAddImageMapping (\r
-        NULL,\r
-        PciIoDevice->PciRootBridgeIo->SegmentNumber,\r
-        PciIoDevice->BusNumber,\r
-        PciIoDevice->DeviceNumber,\r
-        PciIoDevice->FunctionNumber,\r
-        (UINT64) (UINTN) PciIoDevice->PciIo.RomImage,\r
-        PciIoDevice->PciIo.RomSize\r
-        );\r
+    //\r
+    // Get the OpRom provided by platform\r
+    //\r
+    if (gPciPlatformProtocol != NULL) {\r
+      Status = gPciPlatformProtocol->GetPciRom (\r
+                                       gPciPlatformProtocol,\r
+                                       PciIoDevice->Handle,\r
+                                       &PlatformOpRomBuffer,\r
+                                       &PlatformOpRomSize\r
+                                       );\r
+      if (!EFI_ERROR (Status)) {\r
+        PciIoDevice->RomSize        = PlatformOpRomSize;\r
+        PciIoDevice->PciIo.RomSize  = PlatformOpRomSize;\r
+        PciIoDevice->PciIo.RomImage = PlatformOpRomBuffer;\r
+        //\r
+        // For OpROM read from gPciPlatformProtocol:\r
+        //   Add the Rom Image to internal database for later PCI light enumeration\r
+        //\r
+        PciRomAddImageMapping (\r
+          NULL,\r
+          PciIoDevice->PciRootBridgeIo->SegmentNumber,\r
+          PciIoDevice->BusNumber,\r
+          PciIoDevice->DeviceNumber,\r
+          PciIoDevice->FunctionNumber,\r
+          (UINT64) (UINTN) PciIoDevice->PciIo.RomImage,\r
+          PciIoDevice->PciIo.RomSize\r
+          );\r
+        \r
+      }\r
+    }\r
 \r
-      //\r
-      // Process Image\r
-      //\r
+    //\r
+    // Dispatch the EFI OpRom for the PCI device.\r
+    // The OpRom is got from platform in the above code\r
+    //   or loaded from device in previous bus enumeration\r
+    //\r
+    if (PciIoDevice->RomSize > 0) {\r
       ProcessOpRomImage (PciIoDevice);\r
     }\r
   }\r
@@ -659,7 +663,6 @@ Returns:
 // TODO:    EFI_UNSUPPORTED - add return value to function comment\r
 // TODO:    EFI_NOT_FOUND - add return value to function comment\r
 {\r
-  PCI_IO_DEVICE             *Temp;\r
   PCI_IO_DEVICE             *PciIoDevice;\r
   EFI_DEV_PATH_PTR          Node;\r
   EFI_DEVICE_PATH_PROTOCOL  *CurrentDevicePath;\r
@@ -671,13 +674,13 @@ Returns:
 \r
   while (CurrentLink && CurrentLink != &RootBridge->ChildList) {\r
 \r
-    Temp = PCI_IO_DEVICE_FROM_LINK (CurrentLink);\r
+    PciIoDevice = PCI_IO_DEVICE_FROM_LINK (CurrentLink);\r
     if (RemainingDevicePath != NULL) {\r
 \r
       Node.DevPath = RemainingDevicePath;\r
 \r
-      if (Node.Pci->Device != Temp->DeviceNumber ||\r
-          Node.Pci->Function != Temp->FunctionNumber) {\r
+      if (Node.Pci->Device != PciIoDevice->DeviceNumber || \r
+          Node.Pci->Function != PciIoDevice->FunctionNumber) {\r
         CurrentLink = CurrentLink->ForwardLink;\r
         continue;\r
       }\r
@@ -685,30 +688,28 @@ Returns:
       //\r
       // Check if the device has been assigned with required resource\r
       //\r
-      if (!Temp->Allocated) {\r
+      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
       //\r
-      if (!Temp->Registered) {\r
-        PciIoDevice = Temp;\r
-\r
+      if (!PciIoDevice->Registered) {\r
         Status = RegisterPciDevice (\r
-                  Controller,\r
-                  PciIoDevice,\r
-                  NULL\r
-                  );\r
+                   Controller,\r
+                   PciIoDevice,\r
+                   NULL\r
+                   );\r
 \r
       }\r
 \r
-      if (NumberOfChildren != NULL && ChildHandleBuffer != NULL && Temp->Registered) {\r
-        ChildHandleBuffer[*NumberOfChildren] = Temp->Handle;\r
+      if (NumberOfChildren != NULL && ChildHandleBuffer != NULL && PciIoDevice->Registered) {\r
+        ChildHandleBuffer[*NumberOfChildren] = PciIoDevice->Handle;\r
         (*NumberOfChildren)++;\r
       }\r
-\r
+      \r
       //\r
       // Get the next device path\r
       //\r
@@ -720,28 +721,28 @@ Returns:
       //\r
       // If it is a PPB\r
       //\r
-      if (!IsListEmpty (&Temp->ChildList)) {\r
+      if (!IsListEmpty (&PciIoDevice->ChildList)) {\r
         Status = StartPciDevicesOnBridge (\r
-                  Controller,\r
-                  Temp,\r
-                  CurrentDevicePath,\r
-                  NumberOfChildren,\r
-                  ChildHandleBuffer\r
-                  );\r
-\r
-        Temp->PciIo.Attributes (\r
-                      &(Temp->PciIo),\r
-                      EfiPciIoAttributeOperationSupported,\r
-                      0,\r
-                      &Supports\r
-                      );\r
+                   Controller,\r
+                   PciIoDevice,\r
+                   CurrentDevicePath,\r
+                   NumberOfChildren,\r
+                   ChildHandleBuffer\r
+                   );\r
+\r
+        PciIoDevice->PciIo.Attributes (\r
+                             &(PciIoDevice->PciIo),\r
+                             EfiPciIoAttributeOperationSupported,\r
+                             0,\r
+                             &Supports\r
+                             );\r
         Supports &= EFI_PCI_DEVICE_ENABLE;\r
-        Temp->PciIo.Attributes (\r
-                      &(Temp->PciIo),\r
-                      EfiPciIoAttributeOperationEnable,\r
-                      Supports,\r
-                      NULL\r
-                      );\r
+        PciIoDevice->PciIo.Attributes (\r
+                             &(PciIoDevice->PciIo),\r
+                             EfiPciIoAttributeOperationEnable,\r
+                             Supports,\r
+                             NULL\r
+                             );\r
 \r
         return Status;\r
       } else {\r
@@ -759,50 +760,46 @@ Returns:
       // try to enable all the pci devices under this bridge\r
       //\r
 \r
-      if (!Temp->Registered && Temp->Allocated) {\r
-\r
-        PciIoDevice = Temp;\r
-\r
+      if (!PciIoDevice->Registered && PciIoDevice->Allocated) {\r
         Status = RegisterPciDevice (\r
-                  Controller,\r
-                  PciIoDevice,\r
-                  NULL\r
-                  );\r
+                   Controller,\r
+                   PciIoDevice,\r
+                   NULL\r
+                   );\r
 \r
       }\r
 \r
-      if (NumberOfChildren != NULL && ChildHandleBuffer != NULL && Temp->Registered) {\r
-        ChildHandleBuffer[*NumberOfChildren] = Temp->Handle;\r
+      if (NumberOfChildren != NULL && ChildHandleBuffer != NULL && PciIoDevice->Registered) {\r
+        ChildHandleBuffer[*NumberOfChildren] = PciIoDevice->Handle;\r
         (*NumberOfChildren)++;\r
       }\r
 \r
-      if (!IsListEmpty (&Temp->ChildList)) {\r
+      if (!IsListEmpty (&PciIoDevice->ChildList)) {\r
         Status = StartPciDevicesOnBridge (\r
-                  Controller,\r
-                  Temp,\r
-                  RemainingDevicePath,\r
-                  NumberOfChildren,\r
-                  ChildHandleBuffer\r
-                  );\r
-\r
-        Temp->PciIo.Attributes (\r
-                      &(Temp->PciIo),\r
-                      EfiPciIoAttributeOperationSupported,\r
-                      0,\r
-                      &Supports\r
-                      );\r
+                   Controller,\r
+                   PciIoDevice,\r
+                   RemainingDevicePath,\r
+                   NumberOfChildren,\r
+                   ChildHandleBuffer\r
+                   );\r
+\r
+        PciIoDevice->PciIo.Attributes (\r
+                             &(PciIoDevice->PciIo),\r
+                             EfiPciIoAttributeOperationSupported,\r
+                             0,\r
+                             &Supports\r
+                             );\r
         Supports &= EFI_PCI_DEVICE_ENABLE;\r
-        Temp->PciIo.Attributes (\r
-                      &(Temp->PciIo),\r
-                      EfiPciIoAttributeOperationEnable,\r
-                      Supports,\r
-                      NULL\r
-                      );\r
+        PciIoDevice->PciIo.Attributes (\r
+                             &(PciIoDevice->PciIo),\r
+                             EfiPciIoAttributeOperationEnable,\r
+                             Supports,\r
+                             NULL\r
+                             );\r
 \r
       }\r
 \r
       CurrentLink = CurrentLink->ForwardLink;\r
-      continue;\r
     }\r
   }\r
 \r
@@ -811,46 +808,31 @@ Returns:
 \r
 EFI_STATUS\r
 StartPciDevices (\r
-  IN EFI_HANDLE                         Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL           *RemainingDevicePath\r
+  IN EFI_HANDLE                         Controller\r
   )\r
 /*++\r
 \r
 Routine Description:\r
 \r
-  Start to manage the PCI device according to RemainingDevicePath\r
-  If RemainingDevicePath == NULL, the PCI bus driver will start\r
-  to manage all the PCI devices it found previously\r
+  Start to manage all the PCI devices it found previously under \r
+  the entire host bridge.\r
 \r
 Arguments:\r
-  Controller          - An efi handle.\r
-  RemainingDevicePath - A pointer to the EFI_DEVICE_PATH_PROTOCOL.\r
+  Controller          - root bridge handle.\r
 \r
 Returns:\r
 \r
   None\r
 \r
 --*/\r
-// TODO:    EFI_UNSUPPORTED - add return value to function comment\r
-// TODO:    EFI_SUCCESS - add return value to function comment\r
 {\r
-  EFI_DEV_PATH_PTR  Node;\r
   PCI_IO_DEVICE     *RootBridge;\r
+  EFI_HANDLE        ThisHostBridge;\r
   LIST_ENTRY        *CurrentLink;\r
 \r
-  if (RemainingDevicePath != NULL) {\r
-\r
-    //\r
-    // Check if the RemainingDevicePath is valid\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
-        ) {\r
-      return EFI_UNSUPPORTED;\r
-    }\r
-  }\r
+  RootBridge = GetRootBridgeByHandle (Controller);\r
+  ASSERT (RootBridge != NULL);\r
+  ThisHostBridge = RootBridge->PciRootBridgeIo->ParentHandle;\r
 \r
   CurrentLink = gPciDevicePool.ForwardLink;\r
 \r
@@ -860,11 +842,11 @@ Returns:
     //\r
     // Locate the right root bridge to start\r
     //\r
-    if (RootBridge->Handle == Controller) {\r
+    if (RootBridge->PciRootBridgeIo->ParentHandle == ThisHostBridge) {\r
       StartPciDevicesOnBridge (\r
-        Controller,\r
+        RootBridge->Handle,\r
         RootBridge,\r
-        RemainingDevicePath,\r
+        NULL,\r
         NULL,\r
         NULL\r
         );\r
@@ -1007,40 +989,6 @@ Returns:
   return NULL;\r
 }\r
 \r
-BOOLEAN\r
-RootBridgeExisted (\r
-  IN EFI_HANDLE RootBridgeHandle\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This function searches if RootBridgeHandle has already existed\r
-  in current device pool.\r
-\r
-  If so, it means the given root bridge has been already enumerated.\r
-\r
-Arguments:\r
-\r
-  RootBridgeHandle   - An efi handle.\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  PCI_IO_DEVICE *Bridge;\r
-\r
-  Bridge = GetRootBridgeByHandle (RootBridgeHandle);\r
-\r
-  if (Bridge != NULL) {\r
-    return TRUE;\r
-  }\r
-\r
-  return FALSE;\r
-}\r
-\r
 BOOLEAN\r
 PciDeviceExisted (\r
   IN PCI_IO_DEVICE    *Bridge,\r
index 50091750626a6180e6803c2e36b96ed9a2fdbdf7..b32dfe214a14f6f59f14fffd01855b460fa2c9d7 100644 (file)
@@ -244,8 +244,7 @@ Returns:
 \r
 EFI_STATUS\r
 StartPciDevices (\r
-  IN EFI_HANDLE                         Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL           *RemainingDevicePath\r
+  IN EFI_HANDLE                         Controller\r
   )\r
 /*++\r
 \r
@@ -256,7 +255,6 @@ Routine Description:
 Arguments:\r
 \r
   Controller          - TODO: add argument description\r
-  RemainingDevicePath - TODO: add argument description\r
 \r
 Returns:\r
 \r
index e0b6694ba2fa174bc0914ce82ccf840c19e1f7bf..b5b35687a644dc14befa49d875afe068922b9966 100644 (file)
@@ -52,13 +52,6 @@ Returns:
     return PciEnumeratorLight (Controller);\r
   }\r
 \r
-  //\r
-  // If this host bridge has been already enumerated, then return successfully\r
-  //\r
-  if (RootBridgeExisted (Controller)) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
   //\r
   // Get the rootbridge Io protocol to find the host bridge handle\r
   //\r
@@ -277,7 +270,6 @@ Returns:
 {\r
   LIST_ENTRY      *CurrentLink;\r
   PCI_IO_DEVICE   *Temp;\r
-  EFI_STATUS      Status;\r
 \r
   //\r
   // Go through bridges to reach all devices\r
@@ -290,7 +282,7 @@ Returns:
       //\r
       // Go further to process the option rom under this bridge\r
       //\r
-      Status = ProcessOptionRom (Temp, RomBase, MaxLength);\r
+      ProcessOptionRom (Temp, RomBase, MaxLength);\r
     }\r
 \r
     if (Temp->RomSize != 0 && Temp->RomSize <= MaxLength) {\r
@@ -298,10 +290,7 @@ Returns:
       //\r
       // Load and process the option rom\r
       //\r
-      Status = LoadOpRomImage (Temp, RomBase);\r
-      if (Status == EFI_SUCCESS) {\r
-        Status = ProcessOpRomImage (Temp);\r
-      }\r
+      LoadOpRomImage (Temp, RomBase);\r
     }\r
 \r
     CurrentLink = CurrentLink->ForwardLink;\r
index be316effdc8bc52e19fe5a9d8d6eece3f14b47ba..048e30c8a3e5c8f4140719da89712e059d27ffe0 100644 (file)
@@ -1000,6 +1000,12 @@ Returns:
     }\r
 \r
     PciRomGetImageMapping (Temp);\r
+\r
+    //\r
+    // The OpRom has already been processed in the first round\r
+    //\r
+    Temp->AllOpRomProcessed = TRUE;\r
+\r
     CurrentLink = CurrentLink->ForwardLink;\r
   }\r
 \r
@@ -1856,6 +1862,7 @@ Routine Description:
 \r
   This routine is used to enumerate entire pci bus system\r
   in a given platform\r
+  It is only called on the second start on the same Root Bridge.\r
 \r
 Arguments:\r
 \r
@@ -1881,9 +1888,9 @@ Returns:
   Descriptors = NULL;\r
 \r
   //\r
-  // If this host bridge has been already enumerated, then return successfully\r
+  // If this root bridge has been already enumerated, then return successfully\r
   //\r
-  if (RootBridgeExisted (Controller)) {\r
+  if (GetRootBridgeByHandle (Controller) != NULL) {\r
     return EFI_SUCCESS;\r
   }\r
 \r
index a8e50fcb284e8affaa0dc4a5cda90618b6ab6e17..94f29157e8e327af331bf480d6f59bba406c91f0 100644 (file)
@@ -245,13 +245,11 @@ Returns:
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
-\r
+  \r
   //\r
-  // Enable PCI device specified by remaining device path. BDS or other driver can call the\r
-  // start more than once.\r
+  // Start all the devices under the entire host bridge.\r
   //\r
-\r
-  StartPciDevices (Controller, RemainingDevicePath);\r
+  StartPciDevices (Controller);\r
 \r
   return EFI_SUCCESS;\r
 }\r