]> git.proxmox.com Git - mirror_edk2.git/commitdiff
EmbeddedPkg/CoherentDmaLib: add support for non-1:1 DMA translation
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Wed, 30 Aug 2017 07:02:15 +0000 (08:02 +0100)
committerArd Biesheuvel <ard.biesheuvel@linaro.org>
Wed, 30 Aug 2017 13:13:20 +0000 (14:13 +0100)
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>
EmbeddedPkg/EmbeddedPkg.dec
EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.c
EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.inf

index e6861cb59c5bcfb0dabe45147fb0314eebebf2f1..0be102ad9c767d81a004c757f40a65063aab1d7a 100644 (file)
 \r
 [PcdsFixedAtBuild.common, PcdsDynamic.common]\r
   gEmbeddedTokenSpaceGuid.PcdFdtDevicePaths|L""|VOID*|0x00000055\r
+\r
+  #\r
+  # Value to add to a host address to obtain a device address, using\r
+  # unsigned 64-bit integer arithmetic. This means we can rely on\r
+  # truncation on overflow to specify negative offsets.\r
+  #\r
+  gEmbeddedTokenSpaceGuid.PcdDmaDeviceOffset|0x0|UINT64|0x0000058\r
index 4cbe349190a99c534ed124203cb5d4f2634706dd..564db83c901c0a80a78fed729c0d5caacabf6f42 100644 (file)
 #include <Library/MemoryAllocationLib.h>\r
 \r
 \r
+STATIC\r
+PHYSICAL_ADDRESS\r
+HostToDeviceAddress (\r
+  IN  VOID      *Address\r
+  )\r
+{\r
+  return (PHYSICAL_ADDRESS)(UINTN)Address + PcdGet64 (PcdDmaDeviceOffset);\r
+}\r
 \r
 /**\r
   Provides the DMA controller-specific addresses needed to access system memory.\r
@@ -50,7 +58,7 @@ DmaMap (
   OUT    VOID                           **Mapping\r
   )\r
 {\r
-  *DeviceAddress = (PHYSICAL_ADDRESS)(UINTN)HostAddress;\r
+  *DeviceAddress = HostToDeviceAddress (HostAddress);\r
   *Mapping = NULL;\r
   return EFI_SUCCESS;\r
 }\r
index c40a600cf6a3d2ec2fc3a7812c7dcda3e4ffd82c..f64d780e16edb4eb17d2745ff8b7f07e73843127 100644 (file)
@@ -31,3 +31,6 @@
 [LibraryClasses]\r
   DebugLib\r
   MemoryAllocationLib\r
+\r
+[Pcd]\r
+  gEmbeddedTokenSpaceGuid.PcdDmaDeviceOffset\r