]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/Include/IndustryStandard/VirtioGpu.h
OvmfPkg: Apply uncrustify changes
[mirror_edk2.git] / OvmfPkg / Include / IndustryStandard / VirtioGpu.h
CommitLineData
92dc5e9d
LE
1/** @file\r
2\r
3 Virtio GPU Device specific type and macro definitions.\r
4\r
5 At the time of this writing, the Virtio 1.0 specification has not\r
6 incorporated the GPU device yet. The following work-in-progress specification\r
7 is used as basis for the implementation:\r
8\r
9 - https://lists.oasis-open.org/archives/virtio-dev/201605/msg00002.html\r
10 - https://www.kraxel.org/virtio/\r
11\r
12 This header file is minimal, and only defines the types and macros that are\r
13 necessary for the OvmfPkg implementation.\r
14\r
15 Copyright (C) 2016, Red Hat, Inc.\r
16\r
b26f0cf9 17 SPDX-License-Identifier: BSD-2-Clause-Patent\r
92dc5e9d
LE
18\r
19**/\r
20\r
21#ifndef _VIRTIO_GPU_H_\r
22#define _VIRTIO_GPU_H_\r
23\r
24#include <IndustryStandard/Virtio.h>\r
25\r
26//\r
27// Queue number for sending control commands.\r
28//\r
ac0a286f 29#define VIRTIO_GPU_CONTROL_QUEUE 0\r
92dc5e9d
LE
30\r
31//\r
32// Command and response types.\r
33//\r
34typedef enum {\r
35 //\r
36 // Commands related to mode setup:\r
37 //\r
38 // - create/release a host-side 2D resource,\r
39 //\r
ac0a286f
MK
40 VirtioGpuCmdResourceCreate2d = 0x0101,\r
41 VirtioGpuCmdResourceUnref = 0x0102,\r
92dc5e9d
LE
42 //\r
43 // - attach/detach guest RAM to/from a host-side 2D resource,\r
44 //\r
45 VirtioGpuCmdResourceAttachBacking = 0x0106,\r
46 VirtioGpuCmdResourceDetachBacking = 0x0107,\r
47 //\r
48 // - assign/unassign a host-side 2D resource to/from a scanout ("head").\r
49 //\r
ac0a286f 50 VirtioGpuCmdSetScanout = 0x0103,\r
92dc5e9d
LE
51\r
52 //\r
53 // Commands related to drawing:\r
54 //\r
55 // - transfer a guest RAM update to the host-side 2D resource (does not imply\r
56 // host display refresh),\r
57 //\r
ac0a286f 58 VirtioGpuCmdTransferToHost2d = 0x0105,\r
92dc5e9d
LE
59 //\r
60 // - trigger a host display refresh from the 2D resource.\r
61 //\r
ac0a286f 62 VirtioGpuCmdResourceFlush = 0x0104,\r
92dc5e9d
LE
63\r
64 //\r
65 // Success code for all of the above commands.\r
66 //\r
ac0a286f 67 VirtioGpuRespOkNodata = 0x1100,\r
92dc5e9d
LE
68} VIRTIO_GPU_CONTROL_TYPE;\r
69\r
70//\r
71// Common request/response header.\r
72//\r
ac0a286f 73#define VIRTIO_GPU_FLAG_FENCE BIT0\r
92dc5e9d
LE
74\r
75#pragma pack (1)\r
76typedef struct {\r
77 //\r
78 // The guest sets Type to VirtioGpuCmd* in the requests. The host sets Type\r
79 // to VirtioGpuResp* in the responses.\r
80 //\r
ac0a286f 81 UINT32 Type;\r
92dc5e9d
LE
82\r
83 //\r
84 // Fencing forces the host to complete the command before producing a\r
85 // response.\r
86 //\r
ac0a286f
MK
87 UINT32 Flags;\r
88 UINT64 FenceId;\r
92dc5e9d
LE
89\r
90 //\r
91 // Unused.\r
92 //\r
ac0a286f
MK
93 UINT32 CtxId;\r
94 UINT32 Padding;\r
92dc5e9d
LE
95} VIRTIO_GPU_CONTROL_HEADER;\r
96#pragma pack ()\r
97\r
98//\r
99// Rectangle structure used by several operations.\r
100//\r
101#pragma pack (1)\r
102typedef struct {\r
ac0a286f
MK
103 UINT32 X;\r
104 UINT32 Y;\r
105 UINT32 Width;\r
106 UINT32 Height;\r
92dc5e9d
LE
107} VIRTIO_GPU_RECTANGLE;\r
108#pragma pack ()\r
109\r
110//\r
111// Request structure for VirtioGpuCmdResourceCreate2d.\r
112//\r
113typedef enum {\r
114 //\r
115 // 32-bit depth, BGRX component order, X component ignored.\r
116 //\r
117 VirtioGpuFormatB8G8R8X8Unorm = 2,\r
118} VIRTIO_GPU_FORMATS;\r
119\r
120#pragma pack (1)\r
121typedef struct {\r
ac0a286f
MK
122 VIRTIO_GPU_CONTROL_HEADER Header;\r
123 UINT32 ResourceId; // note: 0 is invalid\r
124 UINT32 Format; // from VIRTIO_GPU_FORMATS\r
125 UINT32 Width;\r
126 UINT32 Height;\r
92dc5e9d
LE
127} VIRTIO_GPU_RESOURCE_CREATE_2D;\r
128#pragma pack ()\r
129\r
130//\r
131// Request structure for VirtioGpuCmdResourceUnref.\r
132//\r
133#pragma pack (1)\r
134typedef struct {\r
ac0a286f
MK
135 VIRTIO_GPU_CONTROL_HEADER Header;\r
136 UINT32 ResourceId;\r
137 UINT32 Padding;\r
92dc5e9d
LE
138} VIRTIO_GPU_RESOURCE_UNREF;\r
139#pragma pack ()\r
140\r
141//\r
142// Request structure for VirtioGpuCmdResourceAttachBacking.\r
143//\r
144// The spec allows for a scatter-gather list, but for simplicity we hard-code a\r
145// single guest buffer.\r
146//\r
147#pragma pack (1)\r
148typedef struct {\r
ac0a286f
MK
149 UINT64 Addr;\r
150 UINT32 Length;\r
151 UINT32 Padding;\r
92dc5e9d
LE
152} VIRTIO_GPU_MEM_ENTRY;\r
153\r
154typedef struct {\r
ac0a286f
MK
155 VIRTIO_GPU_CONTROL_HEADER Header;\r
156 UINT32 ResourceId;\r
157 UINT32 NrEntries; // number of entries: constant 1\r
158 VIRTIO_GPU_MEM_ENTRY Entry;\r
92dc5e9d
LE
159} VIRTIO_GPU_RESOURCE_ATTACH_BACKING;\r
160#pragma pack ()\r
161\r
162//\r
163// Request structure for VirtioGpuCmdResourceDetachBacking.\r
164//\r
165#pragma pack (1)\r
166typedef struct {\r
ac0a286f
MK
167 VIRTIO_GPU_CONTROL_HEADER Header;\r
168 UINT32 ResourceId;\r
169 UINT32 Padding;\r
92dc5e9d
LE
170} VIRTIO_GPU_RESOURCE_DETACH_BACKING;\r
171#pragma pack ()\r
172\r
173//\r
174// Request structure for VirtioGpuCmdSetScanout.\r
175//\r
176#pragma pack (1)\r
177typedef struct {\r
ac0a286f
MK
178 VIRTIO_GPU_CONTROL_HEADER Header;\r
179 VIRTIO_GPU_RECTANGLE Rectangle;\r
180 UINT32 ScanoutId;\r
181 UINT32 ResourceId;\r
92dc5e9d
LE
182} VIRTIO_GPU_SET_SCANOUT;\r
183#pragma pack ()\r
184\r
185//\r
186// Request structure for VirtioGpuCmdTransferToHost2d.\r
187//\r
188#pragma pack (1)\r
189typedef struct {\r
ac0a286f
MK
190 VIRTIO_GPU_CONTROL_HEADER Header;\r
191 VIRTIO_GPU_RECTANGLE Rectangle;\r
192 UINT64 Offset;\r
193 UINT32 ResourceId;\r
194 UINT32 Padding;\r
92dc5e9d
LE
195} VIRTIO_GPU_CMD_TRANSFER_TO_HOST_2D;\r
196#pragma pack ()\r
197\r
198//\r
199// Request structure for VirtioGpuCmdResourceFlush.\r
200//\r
201#pragma pack (1)\r
202typedef struct {\r
ac0a286f
MK
203 VIRTIO_GPU_CONTROL_HEADER Header;\r
204 VIRTIO_GPU_RECTANGLE Rectangle;\r
205 UINT32 ResourceId;\r
206 UINT32 Padding;\r
92dc5e9d
LE
207} VIRTIO_GPU_RESOURCE_FLUSH;\r
208#pragma pack ()\r
209\r
210#endif // _VIRTIO_GPU_H_\r