]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c
MdeModulePkg: Update PciEnumeratorSupport to ignore OptionRom if needed
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / PciBusDxe / PciEnumeratorSupport.c
index ed7f2d4ac66d614e78020dfed820fdd59f5980af..509f828b621d07258cb864ab328327fc5d35285e 100644 (file)
@@ -220,8 +220,10 @@ PciSearchDevice (
   )\r
 {\r
   PCI_IO_DEVICE  *PciIoDevice;\r
+  BOOLEAN        IgnoreOptionRom;\r
 \r
-  PciIoDevice = NULL;\r
+  PciIoDevice     = NULL;\r
+  IgnoreOptionRom = FALSE;\r
 \r
   DEBUG ((\r
     DEBUG_INFO,\r
@@ -285,7 +287,7 @@ PciSearchDevice (
   //\r
   // Update the bar information for this PCI device so as to support some specific device\r
   //\r
-  UpdatePciInfo (PciIoDevice);\r
+  UpdatePciInfo (PciIoDevice, &IgnoreOptionRom);\r
 \r
   if (PciIoDevice->DevicePath == NULL) {\r
     return EFI_OUT_OF_RESOURCES;\r
@@ -295,7 +297,7 @@ PciSearchDevice (
   // Detect this function has option rom\r
   //\r
   if (gFullEnumeration) {\r
-    if (!IS_CARDBUS_BRIDGE (Pci)) {\r
+    if (!IS_CARDBUS_BRIDGE (Pci) && !IgnoreOptionRom) {\r
       GetOpRomInfo (PciIoDevice);\r
     }\r
 \r
@@ -1310,6 +1312,7 @@ DetermineDeviceAttribute (
 \r
   @param PciIoDevice      Input Pci device instance. Output Pci device instance with updated\r
                           Bar information.\r
+  @param IgnoreOptionRom  Output If the option rom of incompatible device need to be ignored.\r
 \r
   @retval EFI_SUCCESS     Successfully updated bar information.\r
   @retval EFI_UNSUPPORTED Given PCI device doesn't belong to incompatible PCI device list.\r
@@ -1317,7 +1320,8 @@ DetermineDeviceAttribute (
 **/\r
 EFI_STATUS\r
 UpdatePciInfo (\r
-  IN OUT PCI_IO_DEVICE  *PciIoDevice\r
+  IN OUT PCI_IO_DEVICE  *PciIoDevice,\r
+  OUT BOOLEAN           *IgnoreOptionRom\r
   )\r
 {\r
   EFI_STATUS                         Status;\r
@@ -1374,6 +1378,17 @@ UpdatePciInfo (
       break;\r
     }\r
 \r
+    //\r
+    // According to "Table 20. ACPI 2.0 & 3.0 QWORD Address Space Descriptor Usage"\r
+    // in PI Spec 1.7, Type-specific flags can be set to 0 when Address Translation\r
+    // Offset == 6 to skip device option ROM (do not probe option rom BAR).\r
+    //\r
+    if (((Ptr->AddrTranslationOffset == PCI_MAX_BAR) && (Ptr->SpecificFlag == 0))) {\r
+      *IgnoreOptionRom = TRUE;\r
+      Ptr++;\r
+      continue;\r
+    }\r
+\r
     for (BarIndex = 0; BarIndex < PCI_MAX_BAR; BarIndex++) {\r
       if ((Ptr->AddrTranslationOffset != MAX_UINT64) &&\r
           (Ptr->AddrTranslationOffset != MAX_UINT8) &&\r
@@ -2115,6 +2130,27 @@ AuthenticatePciDevice (
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Checks if PCI device is Root Bridge.\r
+\r
+  @param PciIoDevice       Instance of PCI device\r
+\r
+  @retval TRUE             Device is Root Bridge\r
+  @retval FALSE            Device is not Root Bridge\r
+\r
+**/\r
+BOOLEAN\r
+IsRootBridge (\r
+  IN PCI_IO_DEVICE  *PciIoDevice\r
+  )\r
+{\r
+  if (PciIoDevice->Parent == NULL) {\r
+    return TRUE;\r
+  } else {\r
+    return FALSE;\r
+  }\r
+}\r
+\r
 /**\r
   Create and initialize general PCI I/O device instance for\r
   PCI device/bridge device/hotplug bridge device.\r
@@ -2217,7 +2253,10 @@ CreatePciIoDevice (
     return NULL;\r
   }\r
 \r
-  if (PcdGetBool (PcdAriSupport)) {\r
+  //\r
+  // Check if device's parent is not Root Bridge\r
+  //\r
+  if (PcdGetBool (PcdAriSupport) && !IsRootBridge (Bridge)) {\r
     //\r
     // Check if the device is an ARI device.\r
     //\r