From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 9FE3681FBE for ; Fri, 27 Jan 2017 03:29:48 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx16.intmail.prod.int.phx2.redhat.com [10.5.11.28]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3B9368049A; Fri, 27 Jan 2017 11:29:49 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-16.ams2.redhat.com [10.36.116.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 436AA20E47F; Fri, 27 Jan 2017 11:29:48 +0000 (UTC) From: Laszlo Ersek To: edk2-devel-01 Cc: Jordan Justen Date: Fri, 27 Jan 2017 12:29:38 +0100 Message-Id: <20170127112942.19212-2-lersek@redhat.com> In-Reply-To: <20170127112942.19212-1-lersek@redhat.com> References: <20170127112942.19212-1-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.74 on 10.5.11.28 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 27 Jan 2017 11:29:49 +0000 (UTC) Subject: [PATCH 1/5] OvmfPkg/QemuFwCfgLib: generalize InternalQemuFwCfgDmaBytes() to SKIP op X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Jan 2017 11:29:48 -0000 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 Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=359 Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek --- OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c | 31 ++++++++++++-------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c index a228c029dfb9..6b6b2c7726e1 100644 --- a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c +++ b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c @@ -47,32 +47,39 @@ QemuFwCfgSelectItem ( /** - Transfer an array of bytes using the DMA interface. + Transfer an array of bytes, or skip a number of bytes, using the DMA + interface. - @param[in] Size Size in bytes to transfer. - @param[in,out] Buffer Buffer to read data into or write data from. May be - NULL if Size is zero. - @param[in] Write TRUE if writing to fw_cfg from Buffer, FALSE if - reading from fw_cfg into Buffer. + @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. **/ VOID InternalQemuFwCfgDmaBytes ( IN UINT32 Size, IN OUT VOID *Buffer OPTIONAL, - IN BOOLEAN Write + IN UINT32 Control ) { volatile FW_CFG_DMA_ACCESS Access; UINT32 AccessHigh, AccessLow; 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; } - Access.Control = SwapBytes32 ( - Write ? FW_CFG_DMA_CTL_WRITE : FW_CFG_DMA_CTL_READ - ); + Access.Control = SwapBytes32 (Control); Access.Length = SwapBytes32 (Size); Access.Address = SwapBytes64 ((UINTN)Buffer); @@ -125,7 +132,7 @@ InternalQemuFwCfgReadBytes ( ) { if (InternalQemuFwCfgDmaIsAvailable () && Size <= MAX_UINT32) { - InternalQemuFwCfgDmaBytes ((UINT32)Size, Buffer, FALSE); + InternalQemuFwCfgDmaBytes ((UINT32)Size, Buffer, FW_CFG_DMA_CTL_READ); return; } IoReadFifo8 (0x511, Size, Buffer); @@ -177,7 +184,7 @@ QemuFwCfgWriteBytes ( { if (InternalQemuFwCfgIsAvailable ()) { if (InternalQemuFwCfgDmaIsAvailable () && Size <= MAX_UINT32) { - InternalQemuFwCfgDmaBytes ((UINT32)Size, Buffer, TRUE); + InternalQemuFwCfgDmaBytes ((UINT32)Size, Buffer, FW_CFG_DMA_CTL_WRITE); return; } IoWriteFifo8 (0x511, Size, Buffer); -- 2.9.3