From patchwork Fri Aug 19 12:49:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laszlo Ersek X-Patchwork-Id: 74242 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp295581qga; Fri, 19 Aug 2016 05:49:51 -0700 (PDT) X-Received: by 10.66.127.10 with SMTP id nc10mr13250190pab.109.1471610989124; Fri, 19 Aug 2016 05:49:49 -0700 (PDT) Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id iw9si8143293pac.266.2016.08.19.05.49.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Aug 2016 05:49:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id B2C201A1E14; Fri, 19 Aug 2016 05:49:48 -0700 (PDT) X-Original-To: edk2-devel@ml01.01.org Delivered-To: edk2-devel@ml01.01.org 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 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: [edk2] [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: , Cc: Jordan Justen , Ard Biesheuvel Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" 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=66 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(+) -- 2.9.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel 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_ #define _VIRTIO_1_0_H_ #include // +// Subsystem Device IDs (to be) introduced in VirtIo 1.0 +// +#define VIRTIO_SUBSYSTEM_GPU_DEVICE 16 + +// // Structures for parsing the VirtIo 1.0 specific PCI capabilities from the // config space // #pragma pack (1) typedef struct { UINT8 CapId; // Capability identifier (generic) 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 + + Virtio GPU Device specific type and macro definitions. + + At the time of this writing, the Virtio 1.0 specification has not + incorporated the GPU device yet. The following work-in-progress specification + is used as basis for the implementation: + + - https://lists.oasis-open.org/archives/virtio-dev/201605/msg00002.html + - https://www.kraxel.org/virtio/ + + This header file is minimal, and only defines the types and macros that are + necessary for the OvmfPkg implementation. + + Copyright (C) 2016, Red Hat, Inc. + + This program and the accompanying materials are licensed and made available + under the terms and conditions of the BSD License which accompanies this + distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT + WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef _VIRTIO_GPU_H_ +#define _VIRTIO_GPU_H_ + +#include + +// +// Queue number for sending control commands. +// +#define VIRTIO_GPU_CONTROL_QUEUE 0 + +// +// Command and response types. +// +typedef enum { + // + // Commands related to mode setup: + // + // - create/release a host-side 2D resource, + // + VirtioGpuCmdResourceCreate2d = 0x0101, + VirtioGpuCmdResourceUnref = 0x0102, + // + // - attach/detach guest RAM to/from a host-side 2D resource, + // + VirtioGpuCmdResourceAttachBacking = 0x0106, + VirtioGpuCmdResourceDetachBacking = 0x0107, + // + // - assign/unassign a host-side 2D resource to/from a scanout ("head"). + // + VirtioGpuCmdSetScanout = 0x0103, + + // + // Commands related to drawing: + // + // - transfer a guest RAM update to the host-side 2D resource (does not imply + // host display refresh), + // + VirtioGpuCmdTransferToHost2d = 0x0105, + // + // - trigger a host display refresh from the 2D resource. + // + VirtioGpuCmdResourceFlush = 0x0104, + + // + // Success code for all of the above commands. + // + VirtioGpuRespOkNodata = 0x1100, +} VIRTIO_GPU_CONTROL_TYPE; + +// +// Common request/response header. +// +#define VIRTIO_GPU_FLAG_FENCE BIT0 + +#pragma pack (1) +typedef struct { + // + // The guest sets Type to VirtioGpuCmd* in the requests. The host sets Type + // to VirtioGpuResp* in the responses. + // + UINT32 Type; + + // + // Fencing forces the host to complete the command before producing a + // response. + // + UINT32 Flags; + UINT64 FenceId; + + // + // Unused. + // + UINT32 CtxId; + UINT32 Padding; +} VIRTIO_GPU_CONTROL_HEADER; +#pragma pack () + +// +// Rectangle structure used by several operations. +// +#pragma pack (1) +typedef struct { + UINT32 X; + UINT32 Y; + UINT32 Width; + UINT32 Height; +} VIRTIO_GPU_RECTANGLE; +#pragma pack () + +// +// Request structure for VirtioGpuCmdResourceCreate2d. +// +typedef enum { + // + // 32-bit depth, BGRX component order, X component ignored. + // + VirtioGpuFormatB8G8R8X8Unorm = 2, +} VIRTIO_GPU_FORMATS; + +#pragma pack (1) +typedef struct { + VIRTIO_GPU_CONTROL_HEADER Header; + UINT32 ResourceId; // note: 0 is invalid + UINT32 Format; // from VIRTIO_GPU_FORMATS + UINT32 Width; + UINT32 Height; +} VIRTIO_GPU_RESOURCE_CREATE_2D; +#pragma pack () + +// +// Request structure for VirtioGpuCmdResourceUnref. +// +#pragma pack (1) +typedef struct { + VIRTIO_GPU_CONTROL_HEADER Header; + UINT32 ResourceId; + UINT32 Padding; +} VIRTIO_GPU_RESOURCE_UNREF; +#pragma pack () + +// +// Request structure for VirtioGpuCmdResourceAttachBacking. +// +// The spec allows for a scatter-gather list, but for simplicity we hard-code a +// single guest buffer. +// +#pragma pack (1) +typedef struct { + UINT64 Addr; + UINT32 Length; + UINT32 Padding; +} VIRTIO_GPU_MEM_ENTRY; + +typedef struct { + VIRTIO_GPU_CONTROL_HEADER Header; + UINT32 ResourceId; + UINT32 NrEntries; // number of entries: constant 1 + VIRTIO_GPU_MEM_ENTRY Entry; +} VIRTIO_GPU_RESOURCE_ATTACH_BACKING; +#pragma pack () + +// +// Request structure for VirtioGpuCmdResourceDetachBacking. +// +#pragma pack (1) +typedef struct { + VIRTIO_GPU_CONTROL_HEADER Header; + UINT32 ResourceId; + UINT32 Padding; +} VIRTIO_GPU_RESOURCE_DETACH_BACKING; +#pragma pack () + +// +// Request structure for VirtioGpuCmdSetScanout. +// +#pragma pack (1) +typedef struct { + VIRTIO_GPU_CONTROL_HEADER Header; + VIRTIO_GPU_RECTANGLE Rectangle; + UINT32 ScanoutId; + UINT32 ResourceId; +} VIRTIO_GPU_SET_SCANOUT; +#pragma pack () + +// +// Request structure for VirtioGpuCmdTransferToHost2d. +// +#pragma pack (1) +typedef struct { + VIRTIO_GPU_CONTROL_HEADER Header; + VIRTIO_GPU_RECTANGLE Rectangle; + UINT64 Offset; + UINT32 ResourceId; + UINT32 Padding; +} VIRTIO_GPU_CMD_TRANSFER_TO_HOST_2D; +#pragma pack () + +// +// Request structure for VirtioGpuCmdResourceFlush. +// +#pragma pack (1) +typedef struct { + VIRTIO_GPU_CONTROL_HEADER Header; + VIRTIO_GPU_RECTANGLE Rectangle; + UINT32 ResourceId; + UINT32 Padding; +} VIRTIO_GPU_RESOURCE_FLUSH; +#pragma pack () + +#endif // _VIRTIO_GPU_H_