]> git.proxmox.com Git - mirror_edk2.git/blobdiff - DuetPkg/PciBusNoEnumerationDxe/PciEnumeratorSupport.c
OptionRomPkg: Removing ipf which is no longer supported from edk2.
[mirror_edk2.git] / DuetPkg / PciBusNoEnumerationDxe / PciEnumeratorSupport.c
index 01d991df89d7dcdbc04d73de9a8f16358745d1a6..ca300cf675f70d01163f2f0ba07fdd99767ecd55 100644 (file)
@@ -1,7 +1,8 @@
 /*++\r
 \r
-Copyright (c) 2005 - 2007, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
+Copyright (c) 2005 - 2016, 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
 which accompanies this distribution.  The full text of the license may be found at        \r
 http://opensource.org/licenses/bsd-license.php                                            \r
@@ -21,7 +22,7 @@ Revision History
 \r
 --*/\r
 \r
-#include "Pcibus.h"\r
+#include "PciBus.h"\r
 \r
 EFI_STATUS \r
 InitializePPB (\r
@@ -196,8 +197,9 @@ Returns:
   PCI_IO_DEVICE       *PciIoDevice;\r
   EFI_PCI_IO_PROTOCOL *PciIo;\r
 \r
-  Status  = EFI_SUCCESS;\r
-  SecBus  = 0;\r
+  Status      = EFI_SUCCESS;\r
+  SecBus      = 0;\r
+  PciIoDevice = NULL;\r
 \r
   for (Device = 0; Device <= PCI_MAX_DEVICE; Device++) {\r
 \r
@@ -215,6 +217,13 @@ Returns:
                 (UINT8) Func\r
                 );\r
 \r
+      if (EFI_ERROR (Status) && Func == 0) {\r
+        //\r
+        // go to next device if there is no Function 0\r
+        //\r
+        break;\r
+      }\r
+\r
       if (!EFI_ERROR (Status)) {\r
 \r
         //\r
@@ -248,13 +257,14 @@ Returns:
           }\r
               \r
           //\r
-          // Deep enumerate the next level bus\r
+          // If the PCI bridge is initialized then enumerate the next level bus\r
           //\r
-          Status = PciPciDeviceInfoCollector (\r
-                    PciIoDevice,\r
-                    (UINT8) (SecBus)\r
-                    );\r
-\r
+          if (SecBus != 0) {\r
+            Status = PciPciDeviceInfoCollector (\r
+                      PciIoDevice,\r
+                      (UINT8) (SecBus)\r
+                      );\r
+          }\r
         }\r
 \r
         if (Func == 0 && !IS_PCI_MULTI_FUNC (&Pci)) {\r
@@ -484,7 +494,7 @@ Returns:
 {\r
   PCI_IO_DEVICE                   *PciIoDevice;\r
   EFI_STATUS                      Status;\r
-  UINT32                          Value;\r
+  UINT                          Value;\r
   EFI_PCI_IO_PROTOCOL             *PciIo;\r
   UINT8                           Temp;\r
 \r
@@ -818,7 +828,7 @@ Returns:
     // will block forwarding 0x100-0x3ff for each 1KB in the \r
     // first 64KB I/O range.\r
     //\r
-    if (!BridgeControl & EFI_PCI_BRIDGE_CONTROL_ISA) {\r
+    if ((BridgeControl & EFI_PCI_BRIDGE_CONTROL_ISA) != 0) {\r
       PciIoDevice->Attributes |= EFI_PCI_IO_ATTRIBUTE_ISA_IO;\r
     } \r
 \r
@@ -864,16 +874,12 @@ Returns:
 --*/\r
 {\r
   UINT32      Value;\r
-  UINT64      BarValue64;\r
   UINT32      OriginalValue;\r
   UINT32      Mask;\r
-  UINT32      Data;\r
-  UINT8       Index;\r
   EFI_STATUS  Status;\r
 \r
   OriginalValue = 0;\r
   Value         = 0;\r
-  BarValue64    = 0;\r
 \r
   Status = BarExisted (\r
             PciIoDevice,\r
@@ -923,7 +929,7 @@ Returns:
     // Need to treat it as no-bar\r
     //\r
     if (PciIoDevice->PciBar[BarIndex].Length == 0) {\r
-      PciIoDevice->PciBar[BarIndex].BarType = 0;\r
+      PciIoDevice->PciBar[BarIndex].BarType = PciBarTypeUnknown;\r
     }\r
 \r
     PciIoDevice->PciBar[BarIndex].Prefetchable  = FALSE;\r
@@ -991,12 +997,7 @@ Returns:
       //\r
       // Fix the length to support some spefic 64 bit BAR\r
       //\r
-      Data  = Value;\r
-      Index = 0;\r
-      for (Data = Value; Data != 0; Data >>= 1) {\r
-       Index ++;\r
-      }\r
-      Value |= ((UINT32)(-1) << Index); \r
+      Value |= ((UINT32)(-1) << HighBitSet32 (Value)); \r
 \r
       //\r
       // Calculate the size of 64bit bar\r
@@ -1291,7 +1292,7 @@ Returns:
     return Status;\r
   }\r
 \r
-  while (PciGetBusRange (Descriptors, &MinBus, &MaxBus, NULL) == EFI_SUCCESS) {\r
+  while (PciGetBusRange (&Descriptors, &MinBus, &MaxBus, NULL) == EFI_SUCCESS) {\r
 \r
     //\r
     // Create a device node for root bridge device with a NULL host bridge controller handle\r
@@ -1335,7 +1336,7 @@ Returns:
 \r
 EFI_STATUS\r
 PciGetBusRange (\r
-  IN     EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR  *Descriptors,\r
+  IN     EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR  **Descriptors,\r
   OUT    UINT16                             *MinBus,\r
   OUT    UINT16                             *MaxBus,\r
   OUT    UINT16                             *BusRange\r
@@ -1360,23 +1361,23 @@ Returns:
 --*/\r
 {\r
 \r
-  while (Descriptors->Desc != ACPI_END_TAG_DESCRIPTOR) {\r
-    if (Descriptors->ResType == ACPI_ADDRESS_SPACE_TYPE_BUS) {\r
+  while ((*Descriptors)->Desc != ACPI_END_TAG_DESCRIPTOR) {\r
+    if ((*Descriptors)->ResType == ACPI_ADDRESS_SPACE_TYPE_BUS) {\r
       if (MinBus != NULL) {\r
-        *MinBus = (UINT16)Descriptors->AddrRangeMin;\r
+        *MinBus = (UINT16)(*Descriptors)->AddrRangeMin;\r
       }\r
 \r
       if (MaxBus != NULL) {\r
-        *MaxBus = (UINT16)Descriptors->AddrRangeMax;\r
+        *MaxBus = (UINT16)(*Descriptors)->AddrRangeMax;\r
       }\r
 \r
       if (BusRange != NULL) {\r
-        *BusRange = (UINT16)Descriptors->AddrLen;\r
+        *BusRange = (UINT16)(*Descriptors)->AddrLen;\r
       }\r
       return EFI_SUCCESS;\r
     }\r
 \r
-    Descriptors ++;\r
+    (*Descriptors)++;\r
   }\r
 \r
   return EFI_NOT_FOUND;\r