]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c
MdeModulePkg/PciBus: convert host address to device address
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / PciBusDxe / PciIo.c
index 190f4b0dc7ededab935a0b617327298608e42999..fef3eceb7f62eee18c338ee2d1dcab20b28286a6 100644 (file)
@@ -1812,10 +1812,14 @@ GetMmioAddressTranslationOffset (
     return (UINT64) -1;\r
   }\r
 \r
+  // According to UEFI 2.7, EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL::Configuration()\r
+  // returns host address instead of device address, while AddrTranslationOffset\r
+  // is not zero, and device address = host address + AddrTranslationOffset, so\r
+  // we convert host address to device address for range compare.\r
   while (Configuration->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR) {\r
     if ((Configuration->ResType == ACPI_ADDRESS_SPACE_TYPE_MEM) &&\r
-        (Configuration->AddrRangeMin <= AddrRangeMin) &&\r
-        (Configuration->AddrRangeMin + Configuration->AddrLen >= AddrRangeMin + AddrLen)\r
+        (Configuration->AddrRangeMin + Configuration->AddrTranslationOffset <= AddrRangeMin) &&\r
+        (Configuration->AddrRangeMin + Configuration->AddrLen + Configuration->AddrTranslationOffset >= AddrRangeMin + AddrLen)\r
         ) {\r
       return Configuration->AddrTranslationOffset;\r
     }\r