]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg/IndustryStandard: add type definitions for the virtio GPU device
authorLaszlo Ersek <lersek@redhat.com>
Mon, 15 Aug 2016 14:26:29 +0000 (16:26 +0200)
committerLaszlo Ersek <lersek@redhat.com>
Thu, 1 Sep 2016 20:54:53 +0000 (22:54 +0200)
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>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
OvmfPkg/Include/IndustryStandard/Virtio10.h
OvmfPkg/Include/IndustryStandard/VirtioGpu.h [new file with mode: 0644]

index de692c1d1ee9bbfbef299a2ff3b6b4a494de241b..4c9b62a3cf59268358c8d4c12f72b6ac220c5830 100644 (file)
 \r
 #include <IndustryStandard/Virtio095.h>\r
 \r
+//\r
+// Subsystem Device IDs (to be) introduced in VirtIo 1.0\r
+//\r
+#define VIRTIO_SUBSYSTEM_GPU_DEVICE         16\r
+\r
 //\r
 // Structures for parsing the VirtIo 1.0 specific PCI capabilities from the\r
 // config space\r
diff --git a/OvmfPkg/Include/IndustryStandard/VirtioGpu.h b/OvmfPkg/Include/IndustryStandard/VirtioGpu.h
new file mode 100644 (file)
index 0000000..9c3516e
--- /dev/null
@@ -0,0 +1,216 @@
+/** @file\r
+\r
+  Virtio GPU Device specific type and macro definitions.\r
+\r
+  At the time of this writing, the Virtio 1.0 specification has not\r
+  incorporated the GPU device yet. The following work-in-progress specification\r
+  is used as basis for the implementation:\r
+\r
+  - https://lists.oasis-open.org/archives/virtio-dev/201605/msg00002.html\r
+  - https://www.kraxel.org/virtio/\r
+\r
+  This header file is minimal, and only defines the types and macros that are\r
+  necessary for the OvmfPkg implementation.\r
+\r
+  Copyright (C) 2016, Red Hat, Inc.\r
+\r
+  This program and the accompanying materials are licensed and made available\r
+  under the terms and conditions of the BSD License which accompanies this\r
+  distribution. The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT\r
+  WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef _VIRTIO_GPU_H_\r
+#define _VIRTIO_GPU_H_\r
+\r
+#include <IndustryStandard/Virtio.h>\r
+\r
+//\r
+// Queue number for sending control commands.\r
+//\r
+#define VIRTIO_GPU_CONTROL_QUEUE 0\r
+\r
+//\r
+// Command and response types.\r
+//\r
+typedef enum {\r
+  //\r
+  // Commands related to mode setup:\r
+  //\r
+  // - create/release a host-side 2D resource,\r
+  //\r
+  VirtioGpuCmdResourceCreate2d      = 0x0101,\r
+  VirtioGpuCmdResourceUnref         = 0x0102,\r
+  //\r
+  // - attach/detach guest RAM to/from a host-side 2D resource,\r
+  //\r
+  VirtioGpuCmdResourceAttachBacking = 0x0106,\r
+  VirtioGpuCmdResourceDetachBacking = 0x0107,\r
+  //\r
+  // - assign/unassign a host-side 2D resource to/from a scanout ("head").\r
+  //\r
+  VirtioGpuCmdSetScanout            = 0x0103,\r
+\r
+  //\r
+  // Commands related to drawing:\r
+  //\r
+  // - transfer a guest RAM update to the host-side 2D resource (does not imply\r
+  //   host display refresh),\r
+  //\r
+  VirtioGpuCmdTransferToHost2d      = 0x0105,\r
+  //\r
+  // - trigger a host display refresh from the 2D resource.\r
+  //\r
+  VirtioGpuCmdResourceFlush         = 0x0104,\r
+\r
+  //\r
+  // Success code for all of the above commands.\r
+  //\r
+  VirtioGpuRespOkNodata             = 0x1100,\r
+} VIRTIO_GPU_CONTROL_TYPE;\r
+\r
+//\r
+// Common request/response header.\r
+//\r
+#define VIRTIO_GPU_FLAG_FENCE BIT0\r
+\r
+#pragma pack (1)\r
+typedef struct {\r
+  //\r
+  // The guest sets Type to VirtioGpuCmd* in the requests. The host sets Type\r
+  // to VirtioGpuResp* in the responses.\r
+  //\r
+  UINT32 Type;\r
+\r
+  //\r
+  // Fencing forces the host to complete the command before producing a\r
+  // response.\r
+  //\r
+  UINT32 Flags;\r
+  UINT64 FenceId;\r
+\r
+  //\r
+  // Unused.\r
+  //\r
+  UINT32 CtxId;\r
+  UINT32 Padding;\r
+} VIRTIO_GPU_CONTROL_HEADER;\r
+#pragma pack ()\r
+\r
+//\r
+// Rectangle structure used by several operations.\r
+//\r
+#pragma pack (1)\r
+typedef struct {\r
+  UINT32 X;\r
+  UINT32 Y;\r
+  UINT32 Width;\r
+  UINT32 Height;\r
+} VIRTIO_GPU_RECTANGLE;\r
+#pragma pack ()\r
+\r
+//\r
+// Request structure for VirtioGpuCmdResourceCreate2d.\r
+//\r
+typedef enum {\r
+  //\r
+  // 32-bit depth, BGRX component order, X component ignored.\r
+  //\r
+  VirtioGpuFormatB8G8R8X8Unorm = 2,\r
+} VIRTIO_GPU_FORMATS;\r
+\r
+#pragma pack (1)\r
+typedef struct {\r
+  VIRTIO_GPU_CONTROL_HEADER Header;\r
+  UINT32                    ResourceId; // note: 0 is invalid\r
+  UINT32                    Format;     // from VIRTIO_GPU_FORMATS\r
+  UINT32                    Width;\r
+  UINT32                    Height;\r
+} VIRTIO_GPU_RESOURCE_CREATE_2D;\r
+#pragma pack ()\r
+\r
+//\r
+// Request structure for VirtioGpuCmdResourceUnref.\r
+//\r
+#pragma pack (1)\r
+typedef struct {\r
+  VIRTIO_GPU_CONTROL_HEADER Header;\r
+  UINT32                    ResourceId;\r
+  UINT32                    Padding;\r
+} VIRTIO_GPU_RESOURCE_UNREF;\r
+#pragma pack ()\r
+\r
+//\r
+// Request structure for VirtioGpuCmdResourceAttachBacking.\r
+//\r
+// The spec allows for a scatter-gather list, but for simplicity we hard-code a\r
+// single guest buffer.\r
+//\r
+#pragma pack (1)\r
+typedef struct {\r
+  UINT64 Addr;\r
+  UINT32 Length;\r
+  UINT32 Padding;\r
+} VIRTIO_GPU_MEM_ENTRY;\r
+\r
+typedef struct {\r
+  VIRTIO_GPU_CONTROL_HEADER Header;\r
+  UINT32                    ResourceId;\r
+  UINT32                    NrEntries;  // number of entries: constant 1\r
+  VIRTIO_GPU_MEM_ENTRY      Entry;\r
+} VIRTIO_GPU_RESOURCE_ATTACH_BACKING;\r
+#pragma pack ()\r
+\r
+//\r
+// Request structure for VirtioGpuCmdResourceDetachBacking.\r
+//\r
+#pragma pack (1)\r
+typedef struct {\r
+  VIRTIO_GPU_CONTROL_HEADER Header;\r
+  UINT32                    ResourceId;\r
+  UINT32                    Padding;\r
+} VIRTIO_GPU_RESOURCE_DETACH_BACKING;\r
+#pragma pack ()\r
+\r
+//\r
+// Request structure for VirtioGpuCmdSetScanout.\r
+//\r
+#pragma pack (1)\r
+typedef struct {\r
+  VIRTIO_GPU_CONTROL_HEADER Header;\r
+  VIRTIO_GPU_RECTANGLE      Rectangle;\r
+  UINT32                    ScanoutId;\r
+  UINT32                    ResourceId;\r
+} VIRTIO_GPU_SET_SCANOUT;\r
+#pragma pack ()\r
+\r
+//\r
+// Request structure for VirtioGpuCmdTransferToHost2d.\r
+//\r
+#pragma pack (1)\r
+typedef struct {\r
+  VIRTIO_GPU_CONTROL_HEADER Header;\r
+  VIRTIO_GPU_RECTANGLE      Rectangle;\r
+  UINT64                    Offset;\r
+  UINT32                    ResourceId;\r
+  UINT32                    Padding;\r
+}  VIRTIO_GPU_CMD_TRANSFER_TO_HOST_2D;\r
+#pragma pack ()\r
+\r
+//\r
+// Request structure for VirtioGpuCmdResourceFlush.\r
+//\r
+#pragma pack (1)\r
+typedef struct {\r
+  VIRTIO_GPU_CONTROL_HEADER Header;\r
+  VIRTIO_GPU_RECTANGLE      Rectangle;\r
+  UINT32                    ResourceId;\r
+  UINT32                    Padding;\r
+} VIRTIO_GPU_RESOURCE_FLUSH;\r
+#pragma pack ()\r
+\r
+#endif // _VIRTIO_GPU_H_\r