From 0bcb80106762c65463b1eac4009a59980a65b351 Mon Sep 17 00:00:00 2001 From: Ard Biesheuvel Date: Wed, 30 Aug 2017 08:02:15 +0100 Subject: 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 Reviewed-by: Leif Lindholm --- EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.c | 10 +++++++++- EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.inf | 3 +++ 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'EmbeddedPkg/Library/CoherentDmaLib') diff --git a/EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.c b/EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.c index 4cbe349..564db83 100644 --- a/EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.c +++ b/EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.c @@ -19,6 +19,14 @@ #include +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; } diff --git a/EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.inf b/EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.inf index c40a600..f64d780 100644 --- a/EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.inf +++ b/EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.inf @@ -31,3 +31,6 @@ [LibraryClasses] DebugLib MemoryAllocationLib + +[Pcd] + gEmbeddedTokenSpaceGuid.PcdDmaDeviceOffset -- cgit v1.1