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 VirtioGpuCmdGetDisplayInfo
= 0x0100,
41 VirtioGpuCmdResourceCreate2d
= 0x0101,
42 VirtioGpuCmdResourceUnref
= 0x0102,
44 // - attach/detach guest RAM to/from a host-side 2D resource,
46 VirtioGpuCmdResourceAttachBacking
= 0x0106,
47 VirtioGpuCmdResourceDetachBacking
= 0x0107,
49 // - assign/unassign a host-side 2D resource to/from a scanout ("head").
51 VirtioGpuCmdSetScanout
= 0x0103,
54 // Commands related to drawing:
56 // - transfer a guest RAM update to the host-side 2D resource (does not imply
57 // host display refresh),
59 VirtioGpuCmdTransferToHost2d
= 0x0105,
61 // - trigger a host display refresh from the 2D resource.
63 VirtioGpuCmdResourceFlush
= 0x0104,
66 // Success code for all of the above commands.
68 VirtioGpuRespOkNodata
= 0x1100,
69 VirtioGpuRespOkDisplayInfo
= 0x1101,
70 } VIRTIO_GPU_CONTROL_TYPE
;
73 // Common request/response header.
75 #define VIRTIO_GPU_FLAG_FENCE BIT0
80 // The guest sets Type to VirtioGpuCmd* in the requests. The host sets Type
81 // to VirtioGpuResp* in the responses.
86 // Fencing forces the host to complete the command before producing a
97 } VIRTIO_GPU_CONTROL_HEADER
;
101 // Rectangle structure used by several operations.
109 } VIRTIO_GPU_RECTANGLE
;
113 // Request structure for VirtioGpuCmdResourceCreate2d.
117 // 32-bit depth, BGRX component order, X component ignored.
119 VirtioGpuFormatB8G8R8X8Unorm
= 2,
120 } VIRTIO_GPU_FORMATS
;
124 VIRTIO_GPU_CONTROL_HEADER Header
;
125 UINT32 ResourceId
; // note: 0 is invalid
126 UINT32 Format
; // from VIRTIO_GPU_FORMATS
129 } VIRTIO_GPU_RESOURCE_CREATE_2D
;
133 // Request structure for VirtioGpuCmdResourceUnref.
137 VIRTIO_GPU_CONTROL_HEADER Header
;
140 } VIRTIO_GPU_RESOURCE_UNREF
;
144 // Request structure for VirtioGpuCmdResourceAttachBacking.
146 // The spec allows for a scatter-gather list, but for simplicity we hard-code a
147 // single guest buffer.
154 } VIRTIO_GPU_MEM_ENTRY
;
157 VIRTIO_GPU_CONTROL_HEADER Header
;
159 UINT32 NrEntries
; // number of entries: constant 1
160 VIRTIO_GPU_MEM_ENTRY Entry
;
161 } VIRTIO_GPU_RESOURCE_ATTACH_BACKING
;
165 // Request structure for VirtioGpuCmdResourceDetachBacking.
169 VIRTIO_GPU_CONTROL_HEADER Header
;
172 } VIRTIO_GPU_RESOURCE_DETACH_BACKING
;
176 // Request structure for VirtioGpuCmdSetScanout.
180 VIRTIO_GPU_CONTROL_HEADER Header
;
181 VIRTIO_GPU_RECTANGLE Rectangle
;
184 } VIRTIO_GPU_SET_SCANOUT
;
188 // Request structure for VirtioGpuCmdTransferToHost2d.
192 VIRTIO_GPU_CONTROL_HEADER Header
;
193 VIRTIO_GPU_RECTANGLE Rectangle
;
197 } VIRTIO_GPU_CMD_TRANSFER_TO_HOST_2D
;
201 // Request structure for VirtioGpuCmdResourceFlush.
205 VIRTIO_GPU_CONTROL_HEADER Header
;
206 VIRTIO_GPU_RECTANGLE Rectangle
;
209 } VIRTIO_GPU_RESOURCE_FLUSH
;
213 // Response structure for VirtioGpuCmdGetDisplayInfo
215 #define VIRTIO_GPU_MAX_SCANOUTS 16
218 VIRTIO_GPU_CONTROL_HEADER Header
;
220 VIRTIO_GPU_RECTANGLE Rectangle
;
223 } Pmodes
[VIRTIO_GPU_MAX_SCANOUTS
];
224 } VIRTIO_GPU_RESP_DISPLAY_INFO
;
227 #endif // _VIRTIO_GPU_H_