EmbeddedPkg/CoherentDmaLib: add support for non-1:1 DMA translation

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>
This commit is contained in:
Ard Biesheuvel
2017-08-30 08:02:15 +01:00
parent 7385d2543e
commit 0bcb801067
3 changed files with 19 additions and 1 deletions

View File

@@ -19,6 +19,14 @@
#include <Library/MemoryAllocationLib.h>
STATIC
PHYSICAL_ADDRESS
HostToDeviceAddress (
IN VOID *Address
)
{
return (PHYSICAL_ADDRESS)(UINTN)Address + PcdGet64 (PcdDmaDeviceOffset);
}
/**
Provides the DMA controller-specific addresses needed to access system memory.
@@ -50,7 +58,7 @@ DmaMap (
OUT VOID **Mapping
)
{
*DeviceAddress = (PHYSICAL_ADDRESS)(UINTN)HostAddress;
*DeviceAddress = HostToDeviceAddress (HostAddress);
*Mapping = NULL;
return EFI_SUCCESS;
}