3 Virtio GPU Device specific type and macro definitions.
5 At the time of this writing, the Virtio 1.0 specification has not
6 incorporated the GPU device yet. The following work-in-progress specification
7 is used as basis for the implementation:
9 - https://lists.oasis-open.org/archives/virtio-dev/201605/msg00002.html
10 - https://www.kraxel.org/virtio/
12 This header file is minimal, and only defines the types and macros that are
13 necessary for the OvmfPkg implementation.
15 Copyright (C) 2016, Red Hat, Inc.
17 This program and the accompanying materials are licensed and made available
18 under the terms and conditions of the BSD License which accompanies this
19 distribution. The full text of the license may be found at
20 http://opensource.org/licenses/bsd-license.php
22 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
23 WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
27 #ifndef _VIRTIO_GPU_H_
28 #define _VIRTIO_GPU_H_
30 #include <IndustryStandard/Virtio.h>
33 // Queue number for sending control commands.
35 #define VIRTIO_GPU_CONTROL_QUEUE 0
38 // Command and response types.
42 // Commands related to mode setup:
44 // - create/release a host-side 2D resource,
46 VirtioGpuCmdResourceCreate2d
= 0x0101,
47 VirtioGpuCmdResourceUnref
= 0x0102,
49 // - attach/detach guest RAM to/from a host-side 2D resource,
51 VirtioGpuCmdResourceAttachBacking
= 0x0106,
52 VirtioGpuCmdResourceDetachBacking
= 0x0107,
54 // - assign/unassign a host-side 2D resource to/from a scanout ("head").
56 VirtioGpuCmdSetScanout
= 0x0103,
59 // Commands related to drawing:
61 // - transfer a guest RAM update to the host-side 2D resource (does not imply
62 // host display refresh),
64 VirtioGpuCmdTransferToHost2d
= 0x0105,
66 // - trigger a host display refresh from the 2D resource.
68 VirtioGpuCmdResourceFlush
= 0x0104,
71 // Success code for all of the above commands.
73 VirtioGpuRespOkNodata
= 0x1100,
74 } VIRTIO_GPU_CONTROL_TYPE
;
77 // Common request/response header.
79 #define VIRTIO_GPU_FLAG_FENCE BIT0
84 // The guest sets Type to VirtioGpuCmd* in the requests. The host sets Type
85 // to VirtioGpuResp* in the responses.
90 // Fencing forces the host to complete the command before producing a
101 } VIRTIO_GPU_CONTROL_HEADER
;
105 // Rectangle structure used by several operations.
113 } VIRTIO_GPU_RECTANGLE
;
117 // Request structure for VirtioGpuCmdResourceCreate2d.
121 // 32-bit depth, BGRX component order, X component ignored.
123 VirtioGpuFormatB8G8R8X8Unorm
= 2,
124 } VIRTIO_GPU_FORMATS
;
128 VIRTIO_GPU_CONTROL_HEADER Header
;
129 UINT32 ResourceId
; // note: 0 is invalid
130 UINT32 Format
; // from VIRTIO_GPU_FORMATS
133 } VIRTIO_GPU_RESOURCE_CREATE_2D
;
137 // Request structure for VirtioGpuCmdResourceUnref.
141 VIRTIO_GPU_CONTROL_HEADER Header
;
144 } VIRTIO_GPU_RESOURCE_UNREF
;
148 // Request structure for VirtioGpuCmdResourceAttachBacking.
150 // The spec allows for a scatter-gather list, but for simplicity we hard-code a
151 // single guest buffer.
158 } VIRTIO_GPU_MEM_ENTRY
;
161 VIRTIO_GPU_CONTROL_HEADER Header
;
163 UINT32 NrEntries
; // number of entries: constant 1
164 VIRTIO_GPU_MEM_ENTRY Entry
;
165 } VIRTIO_GPU_RESOURCE_ATTACH_BACKING
;
169 // Request structure for VirtioGpuCmdResourceDetachBacking.
173 VIRTIO_GPU_CONTROL_HEADER Header
;
176 } VIRTIO_GPU_RESOURCE_DETACH_BACKING
;
180 // Request structure for VirtioGpuCmdSetScanout.
184 VIRTIO_GPU_CONTROL_HEADER Header
;
185 VIRTIO_GPU_RECTANGLE Rectangle
;
188 } VIRTIO_GPU_SET_SCANOUT
;
192 // Request structure for VirtioGpuCmdTransferToHost2d.
196 VIRTIO_GPU_CONTROL_HEADER Header
;
197 VIRTIO_GPU_RECTANGLE Rectangle
;
201 } VIRTIO_GPU_CMD_TRANSFER_TO_HOST_2D
;
205 // Request structure for VirtioGpuCmdResourceFlush.
209 VIRTIO_GPU_CONTROL_HEADER Header
;
210 VIRTIO_GPU_RECTANGLE Rectangle
;
213 } VIRTIO_GPU_RESOURCE_FLUSH
;
216 #endif // _VIRTIO_GPU_H_