public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Laszlo Ersek <lersek@redhat.com>
To: edk2-devel-01 <edk2-devel@lists.01.org>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Subject: [PATCH 3/5] ArmVirtPkg/QemuFwCfgLib: extract generic DmaTransferBytes() function
Date: Fri, 27 Jan 2017 12:29:40 +0100	[thread overview]
Message-ID: <20170127112942.19212-4-lersek@redhat.com> (raw)
In-Reply-To: <20170127112942.19212-1-lersek@redhat.com>

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>
---
 ArmVirtPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c | 42 +++++++++++++++++---
 1 file changed, 36 insertions(+), 6 deletions(-)

diff --git a/ArmVirtPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c b/ArmVirtPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c
index 1b19893709fc..bd0f34720eec 100644
--- a/ArmVirtPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c
+++ b/ArmVirtPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c
@@ -250,26 +250,41 @@ MmioReadBytes (
 
 
 /**
-  Fast READ_BYTES_FUNCTION.
+  Transfer an array of bytes, or skip a number of bytes, using the DMA
+  interface.
+
+  @param[in]     Size     Size in bytes to transfer or skip.
+
+  @param[in,out] Buffer   Buffer to read data into or write data from. Ignored,
+                          and may be NULL, if Size is zero, or Control is
+                          FW_CFG_DMA_CTL_SKIP.
+
+  @param[in]     Control  One of the following:
+                          FW_CFG_DMA_CTL_WRITE - write to fw_cfg from Buffer.
+                          FW_CFG_DMA_CTL_READ  - read from fw_cfg into Buffer.
+                          FW_CFG_DMA_CTL_SKIP  - skip bytes in fw_cfg.
 **/
 STATIC
 VOID
-EFIAPI
-DmaReadBytes (
-  IN UINTN Size,
-  IN VOID  *Buffer OPTIONAL
+DmaTransferBytes (
+  IN     UINTN  Size,
+  IN OUT VOID   *Buffer OPTIONAL,
+  IN     UINT32 Control
   )
 {
   volatile FW_CFG_DMA_ACCESS Access;
   UINT32                     Status;
 
+  ASSERT (Control == FW_CFG_DMA_CTL_WRITE || Control == FW_CFG_DMA_CTL_READ ||
+    Control == FW_CFG_DMA_CTL_SKIP);
+
   if (Size == 0) {
     return;
   }
 
   ASSERT (Size <= MAX_UINT32);
 
-  Access.Control = SwapBytes32 (FW_CFG_DMA_CTL_READ);
+  Access.Control = SwapBytes32 (Control);
   Access.Length  = SwapBytes32 ((UINT32)Size);
   Access.Address = SwapBytes64 ((UINT64)(UINTN)Buffer);
 
@@ -305,6 +320,21 @@ DmaReadBytes (
 
 
 /**
+  Fast READ_BYTES_FUNCTION.
+**/
+STATIC
+VOID
+EFIAPI
+DmaReadBytes (
+  IN UINTN Size,
+  IN VOID  *Buffer OPTIONAL
+  )
+{
+  DmaTransferBytes (Size, Buffer, FW_CFG_DMA_CTL_READ);
+}
+
+
+/**
   Reads firmware configuration bytes into a buffer
 
   If called multiple times, then the data read will continue at the offset of
-- 
2.9.3




  parent reply	other threads:[~2017-01-27 11:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-27 11:29 [PATCH 0/5] OvmfPkg, ArmVirtPkg: QemuFwCfgLib: partial rewrite of fw_cfg files Laszlo Ersek
2017-01-27 11:29 ` [PATCH 1/5] OvmfPkg/QemuFwCfgLib: generalize InternalQemuFwCfgDmaBytes() to SKIP op Laszlo Ersek
2017-01-27 11:29 ` [PATCH 2/5] OvmfPkg/QemuFwCfgLib: add QemuFwCfgSkipBytes() Laszlo Ersek
2017-01-27 11:29 ` Laszlo Ersek [this message]
2017-01-27 11:29 ` [PATCH 4/5] ArmVirtPkg/QemuFwCfgLib: use DMA for QemuFwCfgWriteBytes() if available Laszlo Ersek
2017-01-27 11:29 ` [PATCH 5/5] ArmVirtPkg/QemuFwCfgLib: implement QemuFwCfgSkipBytes() API Laszlo Ersek
2017-01-27 18:25 ` [PATCH 0/5] OvmfPkg, ArmVirtPkg: QemuFwCfgLib: partial rewrite of fw_cfg files Ard Biesheuvel
2017-01-30 23:07 ` Jordan Justen
2017-01-30 23:18   ` Laszlo Ersek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170127112942.19212-4-lersek@redhat.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox