]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg/QemuFwCfgLib: generalize InternalQemuFwCfgDmaBytes() to SKIP op
authorLaszlo Ersek <lersek@redhat.com>
Fri, 27 Jan 2017 04:49:03 +0000 (05:49 +0100)
committerLaszlo Ersek <lersek@redhat.com>
Mon, 30 Jan 2017 23:14:12 +0000 (00:14 +0100)
The fw_cfg DMA interface provides a simple method to skip over bytes in an
fw_cfg blob before reading or writing more bytes.
InternalQemuFwCfgDmaBytes() can support it easily, we just have to expose
the Control parameter more flexibly than the current "Write" BOOLEAN.

Cc: Jordan Justen <jordan.l.justen@intel.com>
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>
OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c

index a228c029dfb909edadb3247017264c182ea6f0e7..6b6b2c7726e161b40a064f375aa5269fe3223ee1 100644 (file)
@@ -47,32 +47,39 @@ QemuFwCfgSelectItem (
 \r
 \r
 /**\r
-  Transfer an array of bytes using the DMA interface.\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.\r
-  @param[in,out] Buffer  Buffer to read data into or write data from. May be\r
-                         NULL if Size is zero.\r
-  @param[in]     Write   TRUE if writing to fw_cfg from Buffer, FALSE if\r
-                         reading from fw_cfg into Buffer.\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
 VOID\r
 InternalQemuFwCfgDmaBytes (\r
   IN     UINT32   Size,\r
   IN OUT VOID     *Buffer OPTIONAL,\r
-  IN     BOOLEAN  Write\r
+  IN     UINT32   Control\r
   )\r
 {\r
   volatile FW_CFG_DMA_ACCESS Access;\r
   UINT32                     AccessHigh, AccessLow;\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
-  Access.Control = SwapBytes32 (\r
-                    Write ? FW_CFG_DMA_CTL_WRITE : FW_CFG_DMA_CTL_READ\r
-                    );\r
+  Access.Control = SwapBytes32 (Control);\r
   Access.Length  = SwapBytes32 (Size);\r
   Access.Address = SwapBytes64 ((UINTN)Buffer);\r
 \r
@@ -125,7 +132,7 @@ InternalQemuFwCfgReadBytes (
   )\r
 {\r
   if (InternalQemuFwCfgDmaIsAvailable () && Size <= MAX_UINT32) {\r
-    InternalQemuFwCfgDmaBytes ((UINT32)Size, Buffer, FALSE);\r
+    InternalQemuFwCfgDmaBytes ((UINT32)Size, Buffer, FW_CFG_DMA_CTL_READ);\r
     return;\r
   }\r
   IoReadFifo8 (0x511, Size, Buffer);\r
@@ -177,7 +184,7 @@ QemuFwCfgWriteBytes (
 {\r
   if (InternalQemuFwCfgIsAvailable ()) {\r
     if (InternalQemuFwCfgDmaIsAvailable () && Size <= MAX_UINT32) {\r
-      InternalQemuFwCfgDmaBytes ((UINT32)Size, Buffer, TRUE);\r
+      InternalQemuFwCfgDmaBytes ((UINT32)Size, Buffer, FW_CFG_DMA_CTL_WRITE);\r
       return;\r
     }\r
     IoWriteFifo8 (0x511, Size, Buffer);\r