]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmVirtPkg/QemuFwCfgLib: extract generic DmaTransferBytes() function
authorLaszlo Ersek <lersek@redhat.com>
Fri, 27 Jan 2017 05:56:19 +0000 (06:56 +0100)
committerLaszlo Ersek <lersek@redhat.com>
Mon, 30 Jan 2017 23:14:37 +0000 (00:14 +0100)
The DmaReadBytes() function that we currently use only for reading --
through the InternalQemuFwCfgReadBytes function pointer, in case the DMA
interface is available -- is suitable with minimal changes for two more
operations provided by the DMA interface, WRITE and SKIP. Expose the
Control parameter in the function prototype, rename the function to
DmaTransferBytes(), and rebase DmaReadBytes() to it.

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=359
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
ArmVirtPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c

index 1b19893709fcdc408d423ce1834c4e41fb48c96f..bd0f34720eec3465b7d4cef68d0de1dc241b7643 100644 (file)
@@ -250,26 +250,41 @@ MmioReadBytes (
 \r
 \r
 /**\r
-  Fast READ_BYTES_FUNCTION.\r
+  Transfer an array of bytes, or skip a number of bytes, using the DMA\r
+  interface.\r
+\r
+  @param[in]     Size     Size in bytes to transfer or skip.\r
+\r
+  @param[in,out] Buffer   Buffer to read data into or write data from. Ignored,\r
+                          and may be NULL, if Size is zero, or Control is\r
+                          FW_CFG_DMA_CTL_SKIP.\r
+\r
+  @param[in]     Control  One of the following:\r
+                          FW_CFG_DMA_CTL_WRITE - write to fw_cfg from Buffer.\r
+                          FW_CFG_DMA_CTL_READ  - read from fw_cfg into Buffer.\r
+                          FW_CFG_DMA_CTL_SKIP  - skip bytes in fw_cfg.\r
 **/\r
 STATIC\r
 VOID\r
-EFIAPI\r
-DmaReadBytes (\r
-  IN UINTN Size,\r
-  IN VOID  *Buffer OPTIONAL\r
+DmaTransferBytes (\r
+  IN     UINTN  Size,\r
+  IN OUT VOID   *Buffer OPTIONAL,\r
+  IN     UINT32 Control\r
   )\r
 {\r
   volatile FW_CFG_DMA_ACCESS Access;\r
   UINT32                     Status;\r
 \r
+  ASSERT (Control == FW_CFG_DMA_CTL_WRITE || Control == FW_CFG_DMA_CTL_READ ||\r
+    Control == FW_CFG_DMA_CTL_SKIP);\r
+\r
   if (Size == 0) {\r
     return;\r
   }\r
 \r
   ASSERT (Size <= MAX_UINT32);\r
 \r
-  Access.Control = SwapBytes32 (FW_CFG_DMA_CTL_READ);\r
+  Access.Control = SwapBytes32 (Control);\r
   Access.Length  = SwapBytes32 ((UINT32)Size);\r
   Access.Address = SwapBytes64 ((UINT64)(UINTN)Buffer);\r
 \r
@@ -304,6 +319,21 @@ DmaReadBytes (
 }\r
 \r
 \r
+/**\r
+  Fast READ_BYTES_FUNCTION.\r
+**/\r
+STATIC\r
+VOID\r
+EFIAPI\r
+DmaReadBytes (\r
+  IN UINTN Size,\r
+  IN VOID  *Buffer OPTIONAL\r
+  )\r
+{\r
+  DmaTransferBytes (Size, Buffer, FW_CFG_DMA_CTL_READ);\r
+}\r
+\r
+\r
 /**\r
   Reads firmware configuration bytes into a buffer\r
 \r