Bring CoherentDmaLib in line with ArmDmaLib, and add support for
defining a static offset between the host's and the bus master's
view of memory.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
\r
[PcdsFixedAtBuild.common, PcdsDynamic.common]\r
gEmbeddedTokenSpaceGuid.PcdFdtDevicePaths|L""|VOID*|0x00000055\r
+\r
+ #\r
+ # Value to add to a host address to obtain a device address, using\r
+ # unsigned 64-bit integer arithmetic. This means we can rely on\r
+ # truncation on overflow to specify negative offsets.\r
+ #\r
+ gEmbeddedTokenSpaceGuid.PcdDmaDeviceOffset|0x0|UINT64|0x0000058\r
#include <Library/MemoryAllocationLib.h>\r
\r
\r
+STATIC\r
+PHYSICAL_ADDRESS\r
+HostToDeviceAddress (\r
+ IN VOID *Address\r
+ )\r
+{\r
+ return (PHYSICAL_ADDRESS)(UINTN)Address + PcdGet64 (PcdDmaDeviceOffset);\r
+}\r
\r
/**\r
Provides the DMA controller-specific addresses needed to access system memory.\r
OUT VOID **Mapping\r
)\r
{\r
- *DeviceAddress = (PHYSICAL_ADDRESS)(UINTN)HostAddress;\r
+ *DeviceAddress = HostToDeviceAddress (HostAddress);\r
*Mapping = NULL;\r
return EFI_SUCCESS;\r
}\r
[LibraryClasses]\r
DebugLib\r
MemoryAllocationLib\r
+\r
+[Pcd]\r
+ gEmbeddedTokenSpaceGuid.PcdDmaDeviceOffset\r