From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44055) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZNIvm-00033F-FF for qemu-devel@nongnu.org; Thu, 06 Aug 2015 07:01:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZNIvl-0006PH-6Q for qemu-devel@nongnu.org; Thu, 06 Aug 2015 07:01:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42216) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZNIvk-0006P3-NU for qemu-devel@nongnu.org; Thu, 06 Aug 2015 07:01:49 -0400 From: =?UTF-8?q?Marc=20Mar=C3=AD?= Date: Thu, 6 Aug 2015 13:01:15 +0200 Message-Id: <1438858878-29450-3-git-send-email-markmb@redhat.com> In-Reply-To: <1438858878-29450-1-git-send-email-markmb@redhat.com> References: <1438858816-29385-1-git-send-email-markmb@redhat.com> <1438858878-29450-1-git-send-email-markmb@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH 2/5] fw_cfg DMA interface documentation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Drew , Stefan Hajnoczi , Kevin O'Connor , Gerd Hoffmann , =?UTF-8?q?Marc=20Mar=C3=AD?= , Laszlo Add fw_cfg DMA interface specification in the documentation. Based on Gerd Hoffman's initial implementation. Signed-off-by: Marc Mar=C3=AD --- docs/specs/fw_cfg.txt | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/docs/specs/fw_cfg.txt b/docs/specs/fw_cfg.txt index 5bc7b96..dc8051e 100644 --- a/docs/specs/fw_cfg.txt +++ b/docs/specs/fw_cfg.txt @@ -76,6 +76,7 @@ increasing address order, similar to memcpy(). =20 Selector Register IOport: 0x510 Data Register IOport: 0x511 +DMA Address IOport: 0x512 =20 =3D=3D Firmware Configuration Items =3D=3D =20 @@ -89,8 +90,9 @@ present, the four bytes read will contain the character= s "QEMU". =3D=3D=3D Revision (Key 0x0001, FW_CFG_ID) =3D=3D=3D =20 A 32-bit little-endian unsigned int, this item is used as an interface -revision number, and is currently set to 1 by QEMU when fw_cfg is -initialized. +revision number. If it is set to 1, the interface is the traditional +selector / data interface. If it is set to 2, the DMA extension is +also present. =20 =3D=3D=3D File Directory (Key 0x0019, FW_CFG_FILE_DIR) =3D=3D=3D =20 @@ -132,6 +134,42 @@ Selector Reg. Range Usage In practice, the number of allowed firmware configuration items is given by the value of FW_CFG_MAX_ENTRY (see fw_cfg.h). =20 +=3D Guest-side DMA Interface =3D + +For revision value 2, the DMA interface is present. This does not replac= e +the existing fw_cfg interface, it is an add-on. + +When this interface is enabled the DMA Address register can be used to +write the address of a FWCfgDmaAccess structure: + +typedef struct FWCfgDmaAccess { + uint64_t address; + uint32_t length; + uint32_t control; +} FWCfgDmaAccess; + +If "control" has the bit 1 set (FW_CFG_DMA_CTL_READ), a read operation i= s +performed on the selected entry. "length" bytes of data in that fw_cfg +entry are copied to the address specified by "address". + +If the field "address" has value 0, the read is considered a skip, and +the data is not copied anywhere, but the offset is still incremented. + +To check result, read the control register: + error bit set -> something went wrong. + all bits cleared -> transfer finished successfully. + otherwise -> transfer still in progress (doesn't happen + today due to implementation not being async, + but may in the future). + +Target address goes up and transfer length goes down as the transfer +happens, so after a successful transfer the length register is zero +and the address register points right after the memory block written. + +If a partial transfer happened before an error occured the address and +length registers indicate how much data has been transfered +successfully. + =3D Host-side API =3D =20 The following functions are available to the QEMU programmer for adding --=20 2.4.3