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); @@ -304,6 +319,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