public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Laszlo Ersek <lersek@redhat.com>
To: edk2-devel-01 <edk2-devel@ml01.01.org>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>,
	Jordan Justen <jordan.l.justen@intel.com>
Subject: [PATCH 04/11] OvmfPkg/IndustryStandard: add type definitions for the virtio GPU device
Date: Fri, 19 Aug 2016 14:49:25 +0200	[thread overview]
Message-ID: <20160819124932.29711-5-lersek@redhat.com> (raw)
In-Reply-To: <20160819124932.29711-1-lersek@redhat.com>

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 <ard.biesheuvel@linaro.org>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Ref: https://tianocore.acgmultimedia.com/show_bug.cgi?id=66
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 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_
 #define _VIRTIO_1_0_H_
 
 #include <IndustryStandard/Virtio095.h>
 
 //
+// 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 <IndustryStandard/Virtio.h>
+
+//
+// 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_
-- 
2.9.2




  parent reply	other threads:[~2016-08-19 12:49 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-19 12:49 [PATCH 00/11] OvmfPkg, ArmVirtPkg: GOP driver for the VirtIo GPU (virtio-gpu-pci) Laszlo Ersek
2016-08-19 12:49 ` [PATCH 01/11] OvmfPkg/QemuVideoDxe: don't incorrectly bind virtio-gpu-pci Laszlo Ersek
2016-08-19 12:49 ` [PATCH 02/11] OvmfPkg/Virtio10Dxe: don't bind virtio-vga Laszlo Ersek
2016-08-19 12:49 ` [PATCH 03/11] OvmfPkg/PlatformBootManagerLib: relax device class requirement for ConOut Laszlo Ersek
2016-08-19 12:49 ` Laszlo Ersek [this message]
2016-08-19 12:49 ` [PATCH 05/11] OvmfPkg/VirtioGpuDxe: introduce with Component Name 2 and Driver Binding Laszlo Ersek
2016-08-19 12:49 ` [PATCH 06/11] OvmfPkg: include VirtioGpuDxe in the platform DSC/FDF files Laszlo Ersek
2016-08-19 12:49 ` [PATCH 07/11] ArmVirtPkg/ArmVirtQemu: " Laszlo Ersek
2016-08-19 13:14   ` Ard Biesheuvel
2016-08-19 12:49 ` [PATCH 08/11] OvmfPkg/VirtioGpuDxe: initialize and tear down VirtIo GPU device Laszlo Ersek
2016-08-19 12:49 ` [PATCH 09/11] OvmfPkg/VirtioGpuDxe: provide functions for sending VirtIo GPU commands Laszlo Ersek
2016-08-19 12:49 ` [PATCH 10/11] OvmfPkg/VirtioGpuDxe: implement EFI_GRAPHICS_OUTPUT_PROTOCOL Laszlo Ersek
2016-08-19 12:49 ` [PATCH 11/11] ArmVirtPkg: remove PcdKludgeMapPciMmioAsCached Laszlo Ersek
2016-08-19 13:16   ` Ard Biesheuvel
2016-08-19 13:06 ` [PATCH 00/11] OvmfPkg, ArmVirtPkg: GOP driver for the VirtIo GPU (virtio-gpu-pci) Ard Biesheuvel
2016-08-19 14:25   ` Laszlo Ersek
2016-08-31 20:43     ` Jordan Justen
2016-09-01  7:44       ` Ard Biesheuvel
2016-09-01 16:48         ` Laszlo Ersek
2016-09-01 16:29       ` Laszlo Ersek
2016-09-01 18:03         ` Jordan Justen
2016-09-01 18:46           ` Laszlo Ersek
2016-09-01 19:52             ` Jordan Justen
2016-09-01 20:23               ` Ard Biesheuvel
2016-09-01 20:26                 ` Ard Biesheuvel
2016-09-01 20:52                 ` Jordan Justen
2016-09-01 20:44               ` Laszlo Ersek
2016-09-05 14:17               ` Gerd Hoffmann
2016-08-30 15:07 ` Laszlo Ersek
2016-09-01 20:32 ` Jordan Justen
2016-09-01 21:07   ` Laszlo Ersek
2016-09-01 22:02 ` Laszlo Ersek
     [not found]   ` <57CD6463.90903@suse.de>
2016-09-05 12:56     ` Laszlo Ersek
     [not found]       ` <57CD6C25.7000406@suse.de>
2016-09-05 13:17         ` Laszlo Ersek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160819124932.29711-5-lersek@redhat.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox