]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c
Clean ISA_IO/ISA_IO_16 and VGA_IO/VGA_IO_16 attribute usage in PCI bus driver/PCI...
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / PciBusDxe / PciResourceSupport.c
index cca365370faf9a9ffaa727e0316b08e9f011b7f5..6fa4001a6265d936fb59135e47d9f2a162d7f1a8 100644 (file)
@@ -14,6 +14,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #include "PciBus.h"\r
 \r
+//\r
+// The default policy for the PCI bus driver is NOT to reserve I/O ranges for both ISA aliases and VGA aliases.\r
+//\r
+BOOLEAN mReserveIsaAliases = FALSE;\r
+BOOLEAN mReserveVgaAliases = FALSE;\r
+BOOLEAN mPolicyDetermined  = FALSE;\r
+\r
 /**\r
   The function is used to skip VGA range.\r
 \r
@@ -188,46 +195,37 @@ CalculateApertureIo16 (
   LIST_ENTRY              *CurrentLink;\r
   PCI_RESOURCE_NODE       *Node;\r
   UINT64                  Offset;\r
-  BOOLEAN                 IsaEnable;\r
-  BOOLEAN                 VGAEnable;\r
   EFI_PCI_PLATFORM_POLICY PciPolicy;\r
 \r
-  //\r
-  // Always assume there is ISA device and VGA device on the platform\r
-  // will be customized later\r
-  //\r
-  IsaEnable = FALSE;\r
-  VGAEnable = FALSE;\r
+  if (!mPolicyDetermined) {\r
+    //\r
+    // Check PciPlatform policy\r
+    //\r
+    Status = EFI_NOT_FOUND;\r
+    PciPolicy = 0;\r
+    if (gPciPlatformProtocol != NULL) {\r
+      Status = gPciPlatformProtocol->GetPlatformPolicy (\r
+                                       gPciPlatformProtocol,\r
+                                       &PciPolicy\r
+                                       );\r
+    }\r
 \r
-  //\r
-  // Check PciPlatform policy\r
-  //\r
-  if (gPciPlatformProtocol != NULL) {\r
-    Status = gPciPlatformProtocol->GetPlatformPolicy (\r
-                                     gPciPlatformProtocol,\r
-                                     &PciPolicy\r
-                                     );\r
-    if (!EFI_ERROR (Status)) {\r
-      if ((PciPolicy & EFI_RESERVE_ISA_IO_ALIAS) != 0) {\r
-        IsaEnable = TRUE;\r
-      }\r
-      if ((PciPolicy & EFI_RESERVE_VGA_IO_ALIAS) != 0) {\r
-        VGAEnable = TRUE;\r
-      }\r
+    if (EFI_ERROR (Status) && gPciOverrideProtocol != NULL) {\r
+      Status = gPciOverrideProtocol->GetPlatformPolicy (\r
+                                       gPciOverrideProtocol,\r
+                                       &PciPolicy\r
+                                       );\r
     }\r
-  } else if (gPciOverrideProtocol != NULL) {\r
-    Status = gPciOverrideProtocol->GetPlatformPolicy (\r
-                                     gPciOverrideProtocol,\r
-                                     &PciPolicy\r
-                                     );\r
+\r
     if (!EFI_ERROR (Status)) {\r
       if ((PciPolicy & EFI_RESERVE_ISA_IO_ALIAS) != 0) {\r
-        IsaEnable = TRUE;\r
+        mReserveIsaAliases = TRUE;\r
       }\r
       if ((PciPolicy & EFI_RESERVE_VGA_IO_ALIAS) != 0) {\r
-        VGAEnable = TRUE;\r
+        mReserveVgaAliases = TRUE;\r
       }\r
     }\r
+    mPolicyDetermined = TRUE;\r
   }\r
 \r
   Aperture = 0;\r
@@ -261,13 +259,13 @@ CalculateApertureIo16 (
     // If both of them are enabled, then the IO resource would\r
     // become too limited to meet the requirement of most of devices.\r
     //\r
-    if (IsaEnable || VGAEnable) {\r
+    if (mReserveIsaAliases || mReserveVgaAliases) {\r
       if (!IS_PCI_BRIDGE (&(Node->PciDev->Pci)) && !IS_CARDBUS_BRIDGE (&(Node->PciDev->Pci))) {\r
         //\r
         // Check if there is need to support ISA/VGA decoding\r
         // If so, we need to avoid isa/vga aliasing range\r
         //\r
-        if (IsaEnable) {\r
+        if (mReserveIsaAliases) {\r
           SkipIsaAliasAperture (\r
             &Aperture,\r
             Node->Length\r
@@ -276,7 +274,7 @@ CalculateApertureIo16 (
           if (Offset != 0) {\r
             Aperture = Aperture + (Node->Alignment + 1) - Offset;\r
           }\r
-        } else if (VGAEnable) {\r
+        } else if (mReserveVgaAliases) {\r
           SkipVGAAperture (\r
             &Aperture,\r
             Node->Length\r