Define a new PCD PcdPciDegradeIfOptionRomPresent to enable or disable
the policy of PCI BAR resource degradation from 64-bit to 32-bit based
on the presence of a PCI OptionROM. Default is TRUE to keep backwards
compatibility with existing code.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Samer El-Haj-Mahmoud <[email protected]>
---
 MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf       |  2 +
 .../Bus/Pci/PciBusDxe/PciResourceSupport.c         | 71 +++++++++++-----------
 MdeModulePkg/MdeModulePkg.dec                      |  5 ++
 3 files changed, 44 insertions(+), 34 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf 
b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
index 330ccc8..673a3bb 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
@@ -3,6 +3,7 @@
 #  Please use PCD feature flag PcdPciBusHotplugDeviceSupport to enable hot 
plug supporting.
 #
 #  Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
+#  (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>
 #
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD 
License
@@ -107,6 +108,7 @@
   gEfiMdeModulePkgTokenSpaceGuid.PcdAriSupport                  ## CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdMrIovSupport                ## CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration    ## 
SOMETIMES_CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdPciDegradeIfOptionRomPresent## CONSUMES
 
 [UserExtensions.TianoCore."ExtraFiles"]
   PciBusDxeExtra.uni
diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c 
b/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c
index e12d59f..ee813d0 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c
@@ -2,6 +2,7 @@
   PCI resouces support functions implemntation for PCI Bus module.
 
 Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
+(C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -1058,44 +1059,46 @@ DegradeResource (
   LIST_ENTRY           *NextChildNodeLink;
   PCI_RESOURCE_NODE    *TempNode;
 
-  //
-  // If any child device has both option ROM and 64-bit BAR, degrade its 
PMEM64/MEM64
-  // requests in case that if a legacy option ROM image can not access 64-bit 
resources.
-  //
-  ChildDeviceLink = Bridge->ChildList.ForwardLink;
-  while (ChildDeviceLink != NULL && ChildDeviceLink != &Bridge->ChildList) {
-    Temp = PCI_IO_DEVICE_FROM_LINK (ChildDeviceLink);
-    if (Temp->RomSize != 0) {
-      if (!IsListEmpty (&Mem64Node->ChildList)) {      
-        ChildNodeLink = Mem64Node->ChildList.ForwardLink;
-        while (ChildNodeLink != &Mem64Node->ChildList) {
-          TempNode = RESOURCE_NODE_FROM_LINK (ChildNodeLink);
-          NextChildNodeLink = ChildNodeLink->ForwardLink;
-
-          if (TempNode->PciDev == Temp) {
-            RemoveEntryList (ChildNodeLink);
-            InsertResourceNode (Mem32Node, TempNode);
-          }
-          ChildNodeLink = NextChildNodeLink;
-        }        
-      }
+  if (PcdGetBool (PcdPciDegradeIfOptionRomPresent)) {
+    //
+    // If any child device has both option ROM and 64-bit BAR, degrade its 
PMEM64/MEM64
+    // requests in case that if a legacy option ROM image can not access 
64-bit resources.
+    //
+    ChildDeviceLink = Bridge->ChildList.ForwardLink;
+    while (ChildDeviceLink != NULL && ChildDeviceLink != &Bridge->ChildList) {
+      Temp = PCI_IO_DEVICE_FROM_LINK (ChildDeviceLink);
+      if (Temp->RomSize != 0) {
+        if (!IsListEmpty (&Mem64Node->ChildList)) {      
+          ChildNodeLink = Mem64Node->ChildList.ForwardLink;
+          while (ChildNodeLink != &Mem64Node->ChildList) {
+            TempNode = RESOURCE_NODE_FROM_LINK (ChildNodeLink);
+            NextChildNodeLink = ChildNodeLink->ForwardLink;
+
+            if (TempNode->PciDev == Temp) {
+              RemoveEntryList (ChildNodeLink);
+              InsertResourceNode (Mem32Node, TempNode);
+            }
+            ChildNodeLink = NextChildNodeLink;
+          }        
+        }
 
-      if (!IsListEmpty (&PMem64Node->ChildList)) {      
-        ChildNodeLink = PMem64Node->ChildList.ForwardLink;
-        while (ChildNodeLink != &PMem64Node->ChildList) {
-          TempNode = RESOURCE_NODE_FROM_LINK (ChildNodeLink);
-          NextChildNodeLink = ChildNodeLink->ForwardLink;
+        if (!IsListEmpty (&PMem64Node->ChildList)) {      
+          ChildNodeLink = PMem64Node->ChildList.ForwardLink;
+          while (ChildNodeLink != &PMem64Node->ChildList) {
+            TempNode = RESOURCE_NODE_FROM_LINK (ChildNodeLink);
+            NextChildNodeLink = ChildNodeLink->ForwardLink;
+
+            if (TempNode->PciDev == Temp) {
+              RemoveEntryList (ChildNodeLink);
+              InsertResourceNode (PMem32Node, TempNode);
+            }
+            ChildNodeLink = NextChildNodeLink;
+          }        
+        }
 
-          if (TempNode->PciDev == Temp) {
-            RemoveEntryList (ChildNodeLink);
-            InsertResourceNode (PMem32Node, TempNode);
-          }
-          ChildNodeLink = NextChildNodeLink;
-        }        
       }
-
+      ChildDeviceLink = ChildDeviceLink->ForwardLink;
     }
-    ChildDeviceLink = ChildDeviceLink->ForwardLink;
   }
 
   //
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 5ec37c5..22ab776 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -4,6 +4,7 @@
 # and libraries instances, which are used for those modules.
 #
 # Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>
+# (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>
 # This program and the accompanying materials are licensed and made available 
under 
 # the terms and conditions of the BSD License that accompanies this 
distribution.  
 # The full text of the license may be found at
@@ -1432,6 +1433,10 @@
   # @Prompt Set NX for stack.
   gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack|FALSE|BOOLEAN|0x0001006f
 
+  ## Specify the PCI resource if option ROM is present.
+  # If this PCD is set to TRUE. Degraded from MMIO64 to 32.
+  
gEfiMdeModulePkgTokenSpaceGuid.PcdPciDegradeIfOptionRomPresent|TRUE|BOOLEAN|0x00010080
+
 [PcdsPatchableInModule]
   ## Specify memory size with page number for PEI code when
   #  Loading Module at Fixed Address feature is enabled.
-- 
2.6.3.windows.1

_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to