]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c
MdeModulePkg/PciBus: Revert "disable all BME when entering RT"
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / PciBusDxe / PciDeviceSupport.c
index 5ace222e602886df5eb8f3fceec17038ad9c1704..97bb971a5966a2d869d8da42b47cb4e5be386f27 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Supporting functions implementaion for PCI devices management.\r
 \r
-Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<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
@@ -214,6 +214,7 @@ RegisterPciDevice (
   UINT8               PciExpressCapRegOffset;\r
   EFI_PCI_IO_PROTOCOL *PciIo;\r
   UINT8               Data8;\r
+  BOOLEAN             HasEfiImage;\r
 \r
   //\r
   // Install the pciio protocol, device path protocol\r
@@ -281,7 +282,7 @@ RegisterPciDevice (
           PciIoDevice->BusNumber,\r
           PciIoDevice->DeviceNumber,\r
           PciIoDevice->FunctionNumber,\r
-          (UINT64) (UINTN) PciIoDevice->PciIo.RomImage,\r
+          PciIoDevice->PciIo.RomImage,\r
           PciIoDevice->PciIo.RomSize\r
           );\r
       }\r
@@ -307,14 +308,19 @@ RegisterPciDevice (
           PciIoDevice->BusNumber,\r
           PciIoDevice->DeviceNumber,\r
           PciIoDevice->FunctionNumber,\r
-          (UINT64) (UINTN) PciIoDevice->PciIo.RomImage,\r
+          PciIoDevice->PciIo.RomImage,\r
           PciIoDevice->PciIo.RomSize\r
           );\r
       }   \r
     }\r
   }\r
 \r
-  if (PciIoDevice->HasEfiOpRom) {\r
+  //\r
+  // Determine if there are EFI images in the option rom\r
+  //\r
+  HasEfiImage = ContainEfiImage (PciIoDevice->PciIo.RomImage, PciIoDevice->PciIo.RomSize);\r
+\r
+  if (HasEfiImage) {\r
     Status = gBS->InstallMultipleProtocolInterfaces (\r
                     &PciIoDevice->Handle,\r
                     &gEfiLoadFile2ProtocolGuid,\r
@@ -344,7 +350,7 @@ RegisterPciDevice (
     // The OpRom is got from platform in the above code\r
     // or loaded from device in the previous round of bus enumeration\r
     //\r
-    if (PciIoDevice->HasEfiOpRom) {\r
+    if (HasEfiImage) {\r
       ProcessOpRomImage (PciIoDevice);\r
     }\r
   }\r
@@ -368,7 +374,7 @@ RegisterPciDevice (
              &PciIoDevice->PciIo,\r
              NULL\r
              );\r
-      if (PciIoDevice->HasEfiOpRom) {\r
+      if (HasEfiImage) {\r
         gBS->UninstallMultipleProtocolInterfaces (\r
                &PciIoDevice->Handle,\r
                &gEfiLoadFile2ProtocolGuid,\r
@@ -705,7 +711,12 @@ StartPciDevicesOnBridge (
                              0,\r
                              &Supports\r
                              );\r
-        Supports &= (UINT64)EFI_PCI_DEVICE_ENABLE;\r
+        //\r
+        // By default every bridge's IO and MMIO spaces are enabled.\r
+        // Bridge's Bus Master will be enabled when any device behind it requests\r
+        // to enable Bus Master.\r
+        //\r
+        Supports &= (UINT64) (EFI_PCI_IO_ATTRIBUTE_IO | EFI_PCI_IO_ATTRIBUTE_MEMORY);\r
         PciIoDevice->PciIo.Attributes (\r
                              &(PciIoDevice->PciIo),\r
                              EfiPciIoAttributeOperationEnable,\r
@@ -757,7 +768,12 @@ StartPciDevicesOnBridge (
                              0,\r
                              &Supports\r
                              );\r
-        Supports &= (UINT64)EFI_PCI_DEVICE_ENABLE;\r
+        //\r
+        // By default every bridge's IO and MMIO spaces are enabled.\r
+        // Bridge's Bus Master will be enabled when any device behind it requests\r
+        // to enable Bus Master.\r
+        //\r
+        Supports &= (UINT64) (EFI_PCI_IO_ATTRIBUTE_IO | EFI_PCI_IO_ATTRIBUTE_MEMORY);\r
         PciIoDevice->PciIo.Attributes (\r
                              &(PciIoDevice->PciIo),\r
                              EfiPciIoAttributeOperationEnable,\r