X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdeModulePkg%2FBus%2FPci%2FPciBusDxe%2FPciResourceSupport.c;h=560f8d8a756ab25eee39904903fd30c0c20db3f6;hb=cf81d5a680522259d2fdabcdb1bc4168e688de3f;hp=d8d988cbfc270b223503d34aad5ef50bcb589bef;hpb=41f3989842ae4f2eff46e0eadde5b2e37d0c99bc;p=mirror_edk2.git diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c index d8d988cbfc..560f8d8a75 100644 --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c @@ -1,7 +1,7 @@ /** @file PCI resouces support functions implemntation for PCI Bus module. -Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
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 @@ -196,6 +196,7 @@ CalculateApertureIo16 ( PCI_RESOURCE_NODE *Node; UINT64 Offset; EFI_PCI_PLATFORM_POLICY PciPolicy; + UINT64 PaddingAperture; if (!mPolicyDetermined) { // @@ -228,21 +229,27 @@ CalculateApertureIo16 ( mPolicyDetermined = TRUE; } - Aperture = 0; + Aperture = 0; + PaddingAperture = 0; if (Bridge == NULL) { return ; } - CurrentLink = Bridge->ChildList.ForwardLink; - // // Assume the bridge is aligned // - while (CurrentLink != &Bridge->ChildList) { + for ( CurrentLink = GetFirstNode (&Bridge->ChildList) + ; !IsNull (&Bridge->ChildList, CurrentLink) + ; CurrentLink = GetNextNode (&Bridge->ChildList, CurrentLink) + ) { Node = RESOURCE_NODE_FROM_LINK (CurrentLink); - + if (Node->ResourceUsage == PciResUsagePadding) { + ASSERT (PaddingAperture == 0); + PaddingAperture = Node->Length; + continue; + } // // Consider the aperture alignment // @@ -293,13 +300,10 @@ CalculateApertureIo16 ( // Increment aperture by the length of node // Aperture += Node->Length; - - CurrentLink = CurrentLink->ForwardLink; } // - // At last, adjust the aperture with the bridge's - // alignment + // Adjust the aperture with the bridge's alignment // Offset = Aperture & (Bridge->Alignment); @@ -319,6 +323,12 @@ CalculateApertureIo16 ( Bridge->Alignment = Node->Alignment; } } + + // + // Hotplug controller needs padding resources. + // Use the larger one between the padding resource and actual occupied resource. + // + Bridge->Length = MAX (Bridge->Length, PaddingAperture); } /** @@ -336,10 +346,11 @@ CalculateResourceAperture ( UINT64 Aperture; LIST_ENTRY *CurrentLink; PCI_RESOURCE_NODE *Node; - + UINT64 PaddingAperture; UINT64 Offset; - Aperture = 0; + Aperture = 0; + PaddingAperture = 0; if (Bridge == NULL) { return ; @@ -351,14 +362,20 @@ CalculateResourceAperture ( return ; } - CurrentLink = Bridge->ChildList.ForwardLink; - // // Assume the bridge is aligned // - while (CurrentLink != &Bridge->ChildList) { + for ( CurrentLink = GetFirstNode (&Bridge->ChildList) + ; !IsNull (&Bridge->ChildList, CurrentLink) + ; CurrentLink = GetNextNode (&Bridge->ChildList, CurrentLink) + ) { Node = RESOURCE_NODE_FROM_LINK (CurrentLink); + if (Node->ResourceUsage == PciResUsagePadding) { + ASSERT (PaddingAperture == 0); + PaddingAperture = Node->Length; + continue; + } // // Apply padding resource if available @@ -381,11 +398,6 @@ CalculateResourceAperture ( // Increment aperture by the length of node // Aperture += Node->Length; - - // - // Consider the aperture alignment - // - CurrentLink = CurrentLink->ForwardLink; } // @@ -407,7 +419,7 @@ CalculateResourceAperture ( } // - // At last, adjust the bridge's alignment to the first child's alignment + // Adjust the bridge's alignment to the first child's alignment // if the bridge has at least one child // CurrentLink = Bridge->ChildList.ForwardLink; @@ -417,6 +429,12 @@ CalculateResourceAperture ( Bridge->Alignment = Node->Alignment; } } + + // + // Hotplug controller needs padding resources. + // Use the larger one between the padding resource and actual occupied resource. + // + Bridge->Length = MAX (Bridge->Length, PaddingAperture); } /** @@ -1034,11 +1052,11 @@ DegradeResource ( IN PCI_RESOURCE_NODE *PMem64Node ) { - PCI_IO_DEVICE *Temp; + PCI_IO_DEVICE *PciIoDevice; LIST_ENTRY *ChildDeviceLink; LIST_ENTRY *ChildNodeLink; LIST_ENTRY *NextChildNodeLink; - PCI_RESOURCE_NODE *TempNode; + PCI_RESOURCE_NODE *ResourceNode; // // If any child device has both option ROM and 64-bit BAR, degrade its PMEM64/MEM64 @@ -1046,17 +1064,17 @@ DegradeResource ( // ChildDeviceLink = Bridge->ChildList.ForwardLink; while (ChildDeviceLink != NULL && ChildDeviceLink != &Bridge->ChildList) { - Temp = PCI_IO_DEVICE_FROM_LINK (ChildDeviceLink); - if (Temp->RomSize != 0) { + PciIoDevice = PCI_IO_DEVICE_FROM_LINK (ChildDeviceLink); + if (PciIoDevice->RomSize != 0) { if (!IsListEmpty (&Mem64Node->ChildList)) { ChildNodeLink = Mem64Node->ChildList.ForwardLink; while (ChildNodeLink != &Mem64Node->ChildList) { - TempNode = RESOURCE_NODE_FROM_LINK (ChildNodeLink); + ResourceNode = RESOURCE_NODE_FROM_LINK (ChildNodeLink); NextChildNodeLink = ChildNodeLink->ForwardLink; - if (TempNode->PciDev == Temp) { + if (ResourceNode->PciDev == PciIoDevice) { RemoveEntryList (ChildNodeLink); - InsertResourceNode (Mem32Node, TempNode); + InsertResourceNode (Mem32Node, ResourceNode); } ChildNodeLink = NextChildNodeLink; } @@ -1065,12 +1083,12 @@ DegradeResource ( if (!IsListEmpty (&PMem64Node->ChildList)) { ChildNodeLink = PMem64Node->ChildList.ForwardLink; while (ChildNodeLink != &PMem64Node->ChildList) { - TempNode = RESOURCE_NODE_FROM_LINK (ChildNodeLink); + ResourceNode = RESOURCE_NODE_FROM_LINK (ChildNodeLink); NextChildNodeLink = ChildNodeLink->ForwardLink; - if (TempNode->PciDev == Temp) { + if (ResourceNode->PciDev == PciIoDevice) { RemoveEntryList (ChildNodeLink); - InsertResourceNode (PMem32Node, TempNode); + InsertResourceNode (PMem32Node, ResourceNode); } ChildNodeLink = NextChildNodeLink; }