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 SPDX-License-Identifier: BSD-2-Clause-Patent
21 #ifndef _VIRTIO_GPU_H_
22 #define _VIRTIO_GPU_H_
24 #include <IndustryStandard/Virtio.h>
27 // Queue number for sending control commands.
29 #define VIRTIO_GPU_CONTROL_QUEUE 0
32 // Command and response types.
36 // Commands related to mode setup:
38 // - create/release a host-side 2D resource,
40 VirtioGpuCmdResourceCreate2d
= 0x0101,
41 VirtioGpuCmdResourceUnref
= 0x0102,
43 // - attach/detach guest RAM to/from a host-side 2D resource,
45 VirtioGpuCmdResourceAttachBacking
= 0x0106,
46 VirtioGpuCmdResourceDetachBacking
= 0x0107,
48 // - assign/unassign a host-side 2D resource to/from a scanout ("head").
50 VirtioGpuCmdSetScanout
= 0x0103,
53 // Commands related to drawing:
55 // - transfer a guest RAM update to the host-side 2D resource (does not imply
56 // host display refresh),
58 VirtioGpuCmdTransferToHost2d
= 0x0105,
60 // - trigger a host display refresh from the 2D resource.
62 VirtioGpuCmdResourceFlush
= 0x0104,
65 // Success code for all of the above commands.
67 VirtioGpuRespOkNodata
= 0x1100,
68 } VIRTIO_GPU_CONTROL_TYPE
;
71 // Common request/response header.
73 #define VIRTIO_GPU_FLAG_FENCE BIT0
78 // The guest sets Type to VirtioGpuCmd* in the requests. The host sets Type
79 // to VirtioGpuResp* in the responses.
84 // Fencing forces the host to complete the command before producing a
95 } VIRTIO_GPU_CONTROL_HEADER
;
99 // Rectangle structure used by several operations.
107 } VIRTIO_GPU_RECTANGLE
;
111 // Request structure for VirtioGpuCmdResourceCreate2d.
115 // 32-bit depth, BGRX component order, X component ignored.
117 VirtioGpuFormatB8G8R8X8Unorm
= 2,
118 } VIRTIO_GPU_FORMATS
;
122 VIRTIO_GPU_CONTROL_HEADER Header
;
123 UINT32 ResourceId
; // note: 0 is invalid
124 UINT32 Format
; // from VIRTIO_GPU_FORMATS
127 } VIRTIO_GPU_RESOURCE_CREATE_2D
;
131 // Request structure for VirtioGpuCmdResourceUnref.
135 VIRTIO_GPU_CONTROL_HEADER Header
;
138 } VIRTIO_GPU_RESOURCE_UNREF
;
142 // Request structure for VirtioGpuCmdResourceAttachBacking.
144 // The spec allows for a scatter-gather list, but for simplicity we hard-code a
145 // single guest buffer.
152 } VIRTIO_GPU_MEM_ENTRY
;
155 VIRTIO_GPU_CONTROL_HEADER Header
;
157 UINT32 NrEntries
; // number of entries: constant 1
158 VIRTIO_GPU_MEM_ENTRY Entry
;
159 } VIRTIO_GPU_RESOURCE_ATTACH_BACKING
;
163 // Request structure for VirtioGpuCmdResourceDetachBacking.
167 VIRTIO_GPU_CONTROL_HEADER Header
;
170 } VIRTIO_GPU_RESOURCE_DETACH_BACKING
;
174 // Request structure for VirtioGpuCmdSetScanout.
178 VIRTIO_GPU_CONTROL_HEADER Header
;
179 VIRTIO_GPU_RECTANGLE Rectangle
;
182 } VIRTIO_GPU_SET_SCANOUT
;
186 // Request structure for VirtioGpuCmdTransferToHost2d.
190 VIRTIO_GPU_CONTROL_HEADER Header
;
191 VIRTIO_GPU_RECTANGLE Rectangle
;
195 } VIRTIO_GPU_CMD_TRANSFER_TO_HOST_2D
;
199 // Request structure for VirtioGpuCmdResourceFlush.
203 VIRTIO_GPU_CONTROL_HEADER Header
;
204 VIRTIO_GPU_RECTANGLE Rectangle
;
207 } VIRTIO_GPU_RESOURCE_FLUSH
;
210 #endif // _VIRTIO_GPU_H_