X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdeModulePkg%2FBus%2FPci%2FPciBusDxe%2FPciIo.c;h=62179eb44bbdbf9d4f57d34dc11f68f13444a182;hb=dc080d3b61e570e7a3163fc24afa6f8388d0c0bf;hp=3b3b53abced5493ad2abd7d4c74f1f3d037ac972;hpb=11a6cc5bda811513d2fbe47d8cb1a70b48077800;p=mirror_edk2.git diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c index 3b3b53abce..62179eb44b 100644 --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c @@ -1,7 +1,7 @@ /** @file EFI PCI IO protocol functions implementation for PCI Bus module. -Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2017, 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 @@ -1081,7 +1081,7 @@ PciIoUnmap ( /** Allocates pages that are suitable for an EfiPciIoOperationBusMasterCommonBuffer - mapping. + or EfiPciOperationBusMasterCommonBuffer64 mapping. @param This A pointer to the EFI_PCI_IO_PROTOCOL instance. @param Type This parameter is not used and must be ignored. @@ -1094,7 +1094,7 @@ PciIoUnmap ( @retval EFI_SUCCESS The requested memory pages were allocated. @retval EFI_UNSUPPORTED Attributes is unsupported. The only legal attribute bits are - MEMORY_WRITE_COMBINE and MEMORY_CACHED. + MEMORY_WRITE_COMBINE, MEMORY_CACHED and DUAL_ADDRESS_CYCLE. @retval EFI_INVALID_PARAMETER One or more parameters are invalid. @retval EFI_OUT_OF_RESOURCES The memory pages could not be allocated. @@ -1812,10 +1812,14 @@ GetMmioAddressTranslationOffset ( return (UINT64) -1; } + // According to UEFI 2.7, EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL::Configuration() + // returns host address instead of device address, while AddrTranslationOffset + // is not zero, and device address = host address + AddrTranslationOffset, so + // we convert host address to device address for range compare. while (Configuration->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR) { if ((Configuration->ResType == ACPI_ADDRESS_SPACE_TYPE_MEM) && - (Configuration->AddrRangeMin <= AddrRangeMin) && - (Configuration->AddrRangeMin + Configuration->AddrLen >= AddrRangeMin + AddrLen) + (Configuration->AddrRangeMin + Configuration->AddrTranslationOffset <= AddrRangeMin) && + (Configuration->AddrRangeMin + Configuration->AddrLen + Configuration->AddrTranslationOffset >= AddrRangeMin + AddrLen) ) { return Configuration->AddrTranslationOffset; } @@ -1838,12 +1842,12 @@ GetMmioAddressTranslationOffset ( base address for resource range. The legal range for this field is 0..5. @param Supports A pointer to the mask of attributes that this PCI controller supports setting for this BAR with SetBarAttributes(). - @param Resources A pointer to the ACPI 2.0 resource descriptors that describe the current + @param Resources A pointer to the resource descriptors that describe the current configuration of this BAR of the PCI controller. @retval EFI_SUCCESS If Supports is not NULL, then the attributes that the PCI controller supports are returned in Supports. If Resources - is not NULL, then the ACPI 2.0 resource descriptors that the PCI + is not NULL, then the resource descriptors that the PCI controller is currently using are returned in Resources. @retval EFI_INVALID_PARAMETER Both Supports and Attributes are NULL. @retval EFI_UNSUPPORTED BarIndex not valid for this PCI controller. @@ -1968,6 +1972,10 @@ PciIoGetBarAttributes ( return EFI_UNSUPPORTED; } } + + // According to UEFI spec 2.7, we need return host address for + // PciIo->GetBarAttributes, and host address = device address - translation. + Descriptor->AddrRangeMin -= Descriptor->AddrTranslationOffset; } return EFI_SUCCESS;