summaryrefslogtreecommitdiffstats
path: root/EmbeddedPkg
diff options
context:
space:
mode:
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