\r
STATIC EFI_CPU_ARCH_PROTOCOL *mCpu;\r
\r
+STATIC\r
+PHYSICAL_ADDRESS\r
+HostToDeviceAddress (\r
+ IN PHYSICAL_ADDRESS HostAddress\r
+ )\r
+{\r
+ return HostAddress + PcdGet64 (PcdArmDmaDeviceOffset);\r
+}\r
+\r
/**\r
Provides the DMA controller-specific addresses needed to access system memory.\r
\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
- *DeviceAddress = ConvertToPhysicalAddress (HostAddress);\r
+ //\r
+ // The debug implementation of UncachedMemoryAllocationLib in ArmPkg returns\r
+ // a virtual uncached alias, and unmaps the cached ID mapping of the buffer,\r
+ // in order to catch inadvertent references to the cached mapping.\r
+ // Since HostToDeviceAddress () expects ID mapped input addresses, convert\r
+ // the host address to an ID mapped address first.\r
+ //\r
+ *DeviceAddress = HostToDeviceAddress (ConvertToPhysicalAddress (HostAddress));\r
\r
// Remember range so we can flush on the other side\r
Map = AllocatePool (sizeof (MAP_INFO_INSTANCE));\r
CopyMem (Buffer, HostAddress, *NumberOfBytes);\r
}\r
\r
- *DeviceAddress = ConvertToPhysicalAddress ((UINTN)Buffer);\r
+ *DeviceAddress = HostToDeviceAddress (ConvertToPhysicalAddress ((UINTN)Buffer));\r
Map->BufferAddress = Buffer;\r
} else {\r
Map->DoubleBuffer = FALSE;\r