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 9690C1A1E20 for ; Fri, 19 Aug 2016 05:49:46 -0700 (PDT) Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1453481227; Fri, 19 Aug 2016 12:49:46 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-13.phx2.redhat.com [10.3.116.13]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u7JCnaSj011583; Fri, 19 Aug 2016 08:49:45 -0400 From: Laszlo Ersek To: edk2-devel-01 Cc: Ard Biesheuvel , Jordan Justen Date: Fri, 19 Aug 2016 14:49:25 +0200 Message-Id: <20160819124932.29711-5-lersek@redhat.com> In-Reply-To: <20160819124932.29711-1-lersek@redhat.com> References: <20160819124932.29711-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 19 Aug 2016 12:49:46 +0000 (UTC) Subject: [PATCH 04/11] OvmfPkg/IndustryStandard: add type definitions for the virtio GPU device 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, 19 Aug 2016 12:49:46 -0000 Content-Transfer-Encoding: quoted-printable The GPU additions to VirtIo 1.0 are a work in progress. Mark the relevant URLs in the source code. Incorporate the absolute minimum from the WIP spec that is necessary for implementing a GOP driver. Add the VIRTIO_SUBSYSTEM_GPU_DEVICE macro to "IndustryStandard/Virtio10.h", since all other such macros (dating back to VirtIo 0.9.5) are part of "IndustryStandard/Virtio095.h". Cc: Ard Biesheuvel Cc: Jordan Justen Ref: https://tianocore.acgmultimedia.com/show_bug.cgi?id=3D66 Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek --- OvmfPkg/Include/IndustryStandard/Virtio10.h | 5 + OvmfPkg/Include/IndustryStandard/VirtioGpu.h | 216 ++++++++++++++++++++ 2 files changed, 221 insertions(+) diff --git a/OvmfPkg/Include/IndustryStandard/Virtio10.h b/OvmfPkg/Include/= IndustryStandard/Virtio10.h index de692c1d1ee9..4c9b62a3cf59 100644 --- a/OvmfPkg/Include/IndustryStandard/Virtio10.h +++ b/OvmfPkg/Include/IndustryStandard/Virtio10.h @@ -15,12 +15,17 @@ #ifndef _VIRTIO_1_0_H_=0D #define _VIRTIO_1_0_H_=0D =0D #include =0D =0D //=0D +// Subsystem Device IDs (to be) introduced in VirtIo 1.0=0D +//=0D +#define VIRTIO_SUBSYSTEM_GPU_DEVICE 16=0D +=0D +//=0D // Structures for parsing the VirtIo 1.0 specific PCI capabilities from th= e=0D // config space=0D //=0D #pragma pack (1)=0D typedef struct {=0D UINT8 CapId; // Capability identifier (generic)=0D diff --git a/OvmfPkg/Include/IndustryStandard/VirtioGpu.h b/OvmfPkg/Include= /IndustryStandard/VirtioGpu.h new file mode 100644 index 000000000000..9c3516e71ee3 --- /dev/null +++ b/OvmfPkg/Include/IndustryStandard/VirtioGpu.h @@ -0,0 +1,216 @@ +/** @file=0D +=0D + Virtio GPU Device specific type and macro definitions.=0D +=0D + At the time of this writing, the Virtio 1.0 specification has not=0D + incorporated the GPU device yet. The following work-in-progress specific= ation=0D + is used as basis for the implementation:=0D +=0D + - https://lists.oasis-open.org/archives/virtio-dev/201605/msg00002.html= =0D + - https://www.kraxel.org/virtio/=0D +=0D + This header file is minimal, and only defines the types and macros that = are=0D + necessary for the OvmfPkg implementation.=0D +=0D + Copyright (C) 2016, Red Hat, Inc.=0D +=0D + This program and the accompanying materials are licensed and made availa= ble=0D + under the terms and conditions of the BSD License which accompanies this= =0D + distribution. The full text of the license may be found at=0D + http://opensource.org/licenses/bsd-license.php=0D +=0D + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WI= THOUT=0D + WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.=0D +=0D +**/=0D +=0D +#ifndef _VIRTIO_GPU_H_=0D +#define _VIRTIO_GPU_H_=0D +=0D +#include =0D +=0D +//=0D +// Queue number for sending control commands.=0D +//=0D +#define VIRTIO_GPU_CONTROL_QUEUE 0=0D +=0D +//=0D +// Command and response types.=0D +//=0D +typedef enum {=0D + //=0D + // Commands related to mode setup:=0D + //=0D + // - create/release a host-side 2D resource,=0D + //=0D + VirtioGpuCmdResourceCreate2d =3D 0x0101,=0D + VirtioGpuCmdResourceUnref =3D 0x0102,=0D + //=0D + // - attach/detach guest RAM to/from a host-side 2D resource,=0D + //=0D + VirtioGpuCmdResourceAttachBacking =3D 0x0106,=0D + VirtioGpuCmdResourceDetachBacking =3D 0x0107,=0D + //=0D + // - assign/unassign a host-side 2D resource to/from a scanout ("head").= =0D + //=0D + VirtioGpuCmdSetScanout =3D 0x0103,=0D +=0D + //=0D + // Commands related to drawing:=0D + //=0D + // - transfer a guest RAM update to the host-side 2D resource (does not = imply=0D + // host display refresh),=0D + //=0D + VirtioGpuCmdTransferToHost2d =3D 0x0105,=0D + //=0D + // - trigger a host display refresh from the 2D resource.=0D + //=0D + VirtioGpuCmdResourceFlush =3D 0x0104,=0D +=0D + //=0D + // Success code for all of the above commands.=0D + //=0D + VirtioGpuRespOkNodata =3D 0x1100,=0D +} VIRTIO_GPU_CONTROL_TYPE;=0D +=0D +//=0D +// Common request/response header.=0D +//=0D +#define VIRTIO_GPU_FLAG_FENCE BIT0=0D +=0D +#pragma pack (1)=0D +typedef struct {=0D + //=0D + // The guest sets Type to VirtioGpuCmd* in the requests. The host sets T= ype=0D + // to VirtioGpuResp* in the responses.=0D + //=0D + UINT32 Type;=0D +=0D + //=0D + // Fencing forces the host to complete the command before producing a=0D + // response.=0D + //=0D + UINT32 Flags;=0D + UINT64 FenceId;=0D +=0D + //=0D + // Unused.=0D + //=0D + UINT32 CtxId;=0D + UINT32 Padding;=0D +} VIRTIO_GPU_CONTROL_HEADER;=0D +#pragma pack ()=0D +=0D +//=0D +// Rectangle structure used by several operations.=0D +//=0D +#pragma pack (1)=0D +typedef struct {=0D + UINT32 X;=0D + UINT32 Y;=0D + UINT32 Width;=0D + UINT32 Height;=0D +} VIRTIO_GPU_RECTANGLE;=0D +#pragma pack ()=0D +=0D +//=0D +// Request structure for VirtioGpuCmdResourceCreate2d.=0D +//=0D +typedef enum {=0D + //=0D + // 32-bit depth, BGRX component order, X component ignored.=0D + //=0D + VirtioGpuFormatB8G8R8X8Unorm =3D 2,=0D +} VIRTIO_GPU_FORMATS;=0D +=0D +#pragma pack (1)=0D +typedef struct {=0D + VIRTIO_GPU_CONTROL_HEADER Header;=0D + UINT32 ResourceId; // note: 0 is invalid=0D + UINT32 Format; // from VIRTIO_GPU_FORMATS=0D + UINT32 Width;=0D + UINT32 Height;=0D +} VIRTIO_GPU_RESOURCE_CREATE_2D;=0D +#pragma pack ()=0D +=0D +//=0D +// Request structure for VirtioGpuCmdResourceUnref.=0D +//=0D +#pragma pack (1)=0D +typedef struct {=0D + VIRTIO_GPU_CONTROL_HEADER Header;=0D + UINT32 ResourceId;=0D + UINT32 Padding;=0D +} VIRTIO_GPU_RESOURCE_UNREF;=0D +#pragma pack ()=0D +=0D +//=0D +// Request structure for VirtioGpuCmdResourceAttachBacking.=0D +//=0D +// The spec allows for a scatter-gather list, but for simplicity we hard-c= ode a=0D +// single guest buffer.=0D +//=0D +#pragma pack (1)=0D +typedef struct {=0D + UINT64 Addr;=0D + UINT32 Length;=0D + UINT32 Padding;=0D +} VIRTIO_GPU_MEM_ENTRY;=0D +=0D +typedef struct {=0D + VIRTIO_GPU_CONTROL_HEADER Header;=0D + UINT32 ResourceId;=0D + UINT32 NrEntries; // number of entries: constant 1=0D + VIRTIO_GPU_MEM_ENTRY Entry;=0D +} VIRTIO_GPU_RESOURCE_ATTACH_BACKING;=0D +#pragma pack ()=0D +=0D +//=0D +// Request structure for VirtioGpuCmdResourceDetachBacking.=0D +//=0D +#pragma pack (1)=0D +typedef struct {=0D + VIRTIO_GPU_CONTROL_HEADER Header;=0D + UINT32 ResourceId;=0D + UINT32 Padding;=0D +} VIRTIO_GPU_RESOURCE_DETACH_BACKING;=0D +#pragma pack ()=0D +=0D +//=0D +// Request structure for VirtioGpuCmdSetScanout.=0D +//=0D +#pragma pack (1)=0D +typedef struct {=0D + VIRTIO_GPU_CONTROL_HEADER Header;=0D + VIRTIO_GPU_RECTANGLE Rectangle;=0D + UINT32 ScanoutId;=0D + UINT32 ResourceId;=0D +} VIRTIO_GPU_SET_SCANOUT;=0D +#pragma pack ()=0D +=0D +//=0D +// Request structure for VirtioGpuCmdTransferToHost2d.=0D +//=0D +#pragma pack (1)=0D +typedef struct {=0D + VIRTIO_GPU_CONTROL_HEADER Header;=0D + VIRTIO_GPU_RECTANGLE Rectangle;=0D + UINT64 Offset;=0D + UINT32 ResourceId;=0D + UINT32 Padding;=0D +} VIRTIO_GPU_CMD_TRANSFER_TO_HOST_2D;=0D +#pragma pack ()=0D +=0D +//=0D +// Request structure for VirtioGpuCmdResourceFlush.=0D +//=0D +#pragma pack (1)=0D +typedef struct {=0D + VIRTIO_GPU_CONTROL_HEADER Header;=0D + VIRTIO_GPU_RECTANGLE Rectangle;=0D + UINT32 ResourceId;=0D + UINT32 Padding;=0D +} VIRTIO_GPU_RESOURCE_FLUSH;=0D +#pragma pack ()=0D +=0D +#endif // _VIRTIO_GPU_H_=0D --=20 2.9.2