summaryrefslogtreecommitdiffstats
path: root/ArmVirtPkg/Library
diff options
context:
space:
mode:
authorLaszlo Ersek <lersek@redhat.com>2017-01-27 06:56:19 +0100
committerLaszlo Ersek <lersek@redhat.com>2017-01-31 00:14:37 +0100
commit4175356fb4bfe89415677aed8fb4e6928ced2ff1 (patch)
tree88fa2b300476b533d9a4703deef683f54a30b2e9 /ArmVirtPkg/Library
parentfcca9f67fb81e77b2c76315bd26160772090fd75 (diff)
downloadedk2-4175356fb4bfe89415677aed8fb4e6928ced2ff1.tar.gz
edk2-4175356fb4bfe89415677aed8fb4e6928ced2ff1.tar.bz2
edk2-4175356fb4bfe89415677aed8fb4e6928ced2ff1.zip
ArmVirtPkg/QemuFwCfgLib: extract generic DmaTransferBytes() function
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>
Diffstat (limited to 'ArmVirtPkg/Library')
-rw-r--r--ArmVirtPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c42
1 files changed, 36 insertions, 6 deletions
diff --git a/ArmVirtPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c b/ArmVirtPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c
index 1b19893709..bd0f34720e 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