diff options
author | Ard Biesheuvel <ard.biesheuvel@linaro.org> | 2016-11-12 14:02:28 +0100 |
---|---|---|
committer | Leif Lindholm <leif.lindholm@linaro.org> | 2016-11-30 16:43:14 +0000 |
commit | bfe34275a9bf56a7f8ea9d19fe10cbbee599148d (patch) | |
tree | 9d9997bc52c2e3c450c3d85a0d6365657ddc149f /ArmPkg/Library | |
parent | df8c2668d7277030cf98e7b218549e0466fa5f6b (diff) | |
download | edk2-platforms-bfe34275a9bf56a7f8ea9d19fe10cbbee599148d.tar.xz |
ArmPkg/ArmDmaLib: add support for fixed host-to-device DMA offset
Some devices, such as the Raspberry Pi3, have a fixed offset between memory
addresses as seen by the host and as seen by the other bus masters. So add
a new PCD that allows this fixed offset to be recorded, and to be used when
returning device addresses from the DmaLib mapping routines.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Tested-by: Ryan Harkin <ryan.harkin@linaro.org>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
Diffstat (limited to 'ArmPkg/Library')
-rw-r--r-- | ArmPkg/Library/ArmDmaLib/ArmDmaLib.c | 20 | ||||
-rw-r--r-- | ArmPkg/Library/ArmDmaLib/ArmDmaLib.inf | 1 |
2 files changed, 19 insertions, 2 deletions
diff --git a/ArmPkg/Library/ArmDmaLib/ArmDmaLib.c b/ArmPkg/Library/ArmDmaLib/ArmDmaLib.c index f39d30c44e..acc106bcf4 100644 --- a/ArmPkg/Library/ArmDmaLib/ArmDmaLib.c +++ b/ArmPkg/Library/ArmDmaLib/ArmDmaLib.c @@ -37,6 +37,15 @@ typedef struct { STATIC EFI_CPU_ARCH_PROTOCOL *mCpu;
+STATIC
+PHYSICAL_ADDRESS
+HostToDeviceAddress (
+ IN PHYSICAL_ADDRESS HostAddress
+ )
+{
+ return HostAddress + PcdGet64 (PcdArmDmaDeviceOffset);
+}
+
/**
Provides the DMA controller-specific addresses needed to access system memory.
@@ -80,7 +89,14 @@ DmaMap ( return EFI_INVALID_PARAMETER;
}
- *DeviceAddress = ConvertToPhysicalAddress (HostAddress);
+ //
+ // The debug implementation of UncachedMemoryAllocationLib in ArmPkg returns
+ // a virtual uncached alias, and unmaps the cached ID mapping of the buffer,
+ // in order to catch inadvertent references to the cached mapping.
+ // Since HostToDeviceAddress () expects ID mapped input addresses, convert
+ // the host address to an ID mapped address first.
+ //
+ *DeviceAddress = HostToDeviceAddress (ConvertToPhysicalAddress (HostAddress));
// Remember range so we can flush on the other side
Map = AllocatePool (sizeof (MAP_INFO_INSTANCE));
@@ -126,7 +142,7 @@ DmaMap ( CopyMem (Buffer, HostAddress, *NumberOfBytes);
}
- *DeviceAddress = ConvertToPhysicalAddress ((UINTN)Buffer);
+ *DeviceAddress = HostToDeviceAddress (ConvertToPhysicalAddress ((UINTN)Buffer));
Map->BufferAddress = Buffer;
} else {
Map->DoubleBuffer = FALSE;
diff --git a/ArmPkg/Library/ArmDmaLib/ArmDmaLib.inf b/ArmPkg/Library/ArmDmaLib/ArmDmaLib.inf index 31de3cfd82..9b7dad114b 100644 --- a/ArmPkg/Library/ArmDmaLib/ArmDmaLib.inf +++ b/ArmPkg/Library/ArmDmaLib/ArmDmaLib.inf @@ -44,6 +44,7 @@ [Guids]
[Pcd]
+ gArmTokenSpaceGuid.PcdArmDmaDeviceOffset
[Depex]
gEfiCpuArchProtocolGuid
|