summaryrefslogtreecommitdiffstats
path: root/EmbeddedPkg
diff options
context:
space:
mode:
authorArd Biesheuvel <ard.biesheuvel@linaro.org>2017-08-30 08:02:15 +0100
committerArd Biesheuvel <ard.biesheuvel@linaro.org>2017-08-30 14:13:20 +0100
commit0bcb80106762c65463b1eac4009a59980a65b351 (patch)
tree961e89d5e4f33e1ed26645c4cd0e6b5eaebfe679 /EmbeddedPkg
parent7385d2543e2a0c9b601673f244a75635d7ff90da (diff)
downloadedk2-0bcb80106762c65463b1eac4009a59980a65b351.tar.gz
edk2-0bcb80106762c65463b1eac4009a59980a65b351.tar.bz2
edk2-0bcb80106762c65463b1eac4009a59980a65b351.zip
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>
Diffstat (limited to 'EmbeddedPkg')
-rw-r--r--EmbeddedPkg/EmbeddedPkg.dec7
-rw-r--r--EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.c10
-rw-r--r--EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.inf3
3 files changed, 19 insertions, 1 deletions
diff --git a/EmbeddedPkg/EmbeddedPkg.dec b/EmbeddedPkg/EmbeddedPkg.dec
index e6861cb59c..0be102ad9c 100644
--- a/EmbeddedPkg/EmbeddedPkg.dec
+++ b/EmbeddedPkg/EmbeddedPkg.dec
@@ -205,3 +205,10 @@
[PcdsFixedAtBuild.common, PcdsDynamic.common]
gEmbeddedTokenSpaceGuid.PcdFdtDevicePaths|L""|VOID*|0x00000055
+
+ #
+ # Value to add to a host address to obtain a device address, using
+ # unsigned 64-bit integer arithmetic. This means we can rely on
+ # truncation on overflow to specify negative offsets.
+ #
+ gEmbeddedTokenSpaceGuid.PcdDmaDeviceOffset|0x0|UINT64|0x0000058
diff --git a/EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.c b/EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.c
index 4cbe349190..564db83c90 100644
--- a/EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.c
+++ b/EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.c
@@ -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;
}
diff --git a/EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.inf b/EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.inf
index c40a600cf6..f64d780e16 100644
--- a/EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.inf
+++ b/EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.inf
@@ -31,3 +31,6 @@
[LibraryClasses]
DebugLib
MemoryAllocationLib
+
+[Pcd]
+ gEmbeddedTokenSpaceGuid.PcdDmaDeviceOffset