]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/Include/IndustryStandard/VirtioGpu.h
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[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
18212291 40 VirtioGpuCmdGetDisplayInfo = 0x0100,\r
ac0a286f
MK
41 VirtioGpuCmdResourceCreate2d = 0x0101,\r
42 VirtioGpuCmdResourceUnref = 0x0102,\r
92dc5e9d
LE
43 //\r
44 // - attach/detach guest RAM to/from a host-side 2D resource,\r
45 //\r
46 VirtioGpuCmdResourceAttachBacking = 0x0106,\r
47 VirtioGpuCmdResourceDetachBacking = 0x0107,\r
48 //\r
49 // - assign/unassign a host-side 2D resource to/from a scanout ("head").\r
50 //\r
ac0a286f 51 VirtioGpuCmdSetScanout = 0x0103,\r
92dc5e9d
LE
52\r
53 //\r
54 // Commands related to drawing:\r
55 //\r
56 // - transfer a guest RAM update to the host-side 2D resource (does not imply\r
57 // host display refresh),\r
58 //\r
ac0a286f 59 VirtioGpuCmdTransferToHost2d = 0x0105,\r
92dc5e9d
LE
60 //\r
61 // - trigger a host display refresh from the 2D resource.\r
62 //\r
ac0a286f 63 VirtioGpuCmdResourceFlush = 0x0104,\r
92dc5e9d
LE
64\r
65 //\r
66 // Success code for all of the above commands.\r
67 //\r
18212291
GH
68 VirtioGpuRespOkNodata = 0x1100,\r
69 VirtioGpuRespOkDisplayInfo = 0x1101,\r
92dc5e9d
LE
70} VIRTIO_GPU_CONTROL_TYPE;\r
71\r
72//\r
73// Common request/response header.\r
74//\r
ac0a286f 75#define VIRTIO_GPU_FLAG_FENCE BIT0\r
92dc5e9d
LE
76\r
77#pragma pack (1)\r
78typedef struct {\r
79 //\r
80 // The guest sets Type to VirtioGpuCmd* in the requests. The host sets Type\r
81 // to VirtioGpuResp* in the responses.\r
82 //\r
ac0a286f 83 UINT32 Type;\r
92dc5e9d
LE
84\r
85 //\r
86 // Fencing forces the host to complete the command before producing a\r
87 // response.\r
88 //\r
ac0a286f
MK
89 UINT32 Flags;\r
90 UINT64 FenceId;\r
92dc5e9d
LE
91\r
92 //\r
93 // Unused.\r
94 //\r
ac0a286f
MK
95 UINT32 CtxId;\r
96 UINT32 Padding;\r
92dc5e9d
LE
97} VIRTIO_GPU_CONTROL_HEADER;\r
98#pragma pack ()\r
99\r
100//\r
101// Rectangle structure used by several operations.\r
102//\r
103#pragma pack (1)\r
104typedef struct {\r
ac0a286f
MK
105 UINT32 X;\r
106 UINT32 Y;\r
107 UINT32 Width;\r
108 UINT32 Height;\r
92dc5e9d
LE
109} VIRTIO_GPU_RECTANGLE;\r
110#pragma pack ()\r
111\r
112//\r
113// Request structure for VirtioGpuCmdResourceCreate2d.\r
114//\r
115typedef enum {\r
116 //\r
117 // 32-bit depth, BGRX component order, X component ignored.\r
118 //\r
119 VirtioGpuFormatB8G8R8X8Unorm = 2,\r
120} VIRTIO_GPU_FORMATS;\r
121\r
122#pragma pack (1)\r
123typedef struct {\r
ac0a286f
MK
124 VIRTIO_GPU_CONTROL_HEADER Header;\r
125 UINT32 ResourceId; // note: 0 is invalid\r
126 UINT32 Format; // from VIRTIO_GPU_FORMATS\r
127 UINT32 Width;\r
128 UINT32 Height;\r
92dc5e9d
LE
129} VIRTIO_GPU_RESOURCE_CREATE_2D;\r
130#pragma pack ()\r
131\r
132//\r
133// Request structure for VirtioGpuCmdResourceUnref.\r
134//\r
135#pragma pack (1)\r
136typedef struct {\r
ac0a286f
MK
137 VIRTIO_GPU_CONTROL_HEADER Header;\r
138 UINT32 ResourceId;\r
139 UINT32 Padding;\r
92dc5e9d
LE
140} VIRTIO_GPU_RESOURCE_UNREF;\r
141#pragma pack ()\r
142\r
143//\r
144// Request structure for VirtioGpuCmdResourceAttachBacking.\r
145//\r
146// The spec allows for a scatter-gather list, but for simplicity we hard-code a\r
147// single guest buffer.\r
148//\r
149#pragma pack (1)\r
150typedef struct {\r
ac0a286f
MK
151 UINT64 Addr;\r
152 UINT32 Length;\r
153 UINT32 Padding;\r
92dc5e9d
LE
154} VIRTIO_GPU_MEM_ENTRY;\r
155\r
156typedef struct {\r
ac0a286f
MK
157 VIRTIO_GPU_CONTROL_HEADER Header;\r
158 UINT32 ResourceId;\r
159 UINT32 NrEntries; // number of entries: constant 1\r
160 VIRTIO_GPU_MEM_ENTRY Entry;\r
92dc5e9d
LE
161} VIRTIO_GPU_RESOURCE_ATTACH_BACKING;\r
162#pragma pack ()\r
163\r
164//\r
165// Request structure for VirtioGpuCmdResourceDetachBacking.\r
166//\r
167#pragma pack (1)\r
168typedef struct {\r
ac0a286f
MK
169 VIRTIO_GPU_CONTROL_HEADER Header;\r
170 UINT32 ResourceId;\r
171 UINT32 Padding;\r
92dc5e9d
LE
172} VIRTIO_GPU_RESOURCE_DETACH_BACKING;\r
173#pragma pack ()\r
174\r
175//\r
176// Request structure for VirtioGpuCmdSetScanout.\r
177//\r
178#pragma pack (1)\r
179typedef struct {\r
ac0a286f
MK
180 VIRTIO_GPU_CONTROL_HEADER Header;\r
181 VIRTIO_GPU_RECTANGLE Rectangle;\r
182 UINT32 ScanoutId;\r
183 UINT32 ResourceId;\r
92dc5e9d
LE
184} VIRTIO_GPU_SET_SCANOUT;\r
185#pragma pack ()\r
186\r
187//\r
188// Request structure for VirtioGpuCmdTransferToHost2d.\r
189//\r
190#pragma pack (1)\r
191typedef struct {\r
ac0a286f
MK
192 VIRTIO_GPU_CONTROL_HEADER Header;\r
193 VIRTIO_GPU_RECTANGLE Rectangle;\r
194 UINT64 Offset;\r
195 UINT32 ResourceId;\r
196 UINT32 Padding;\r
92dc5e9d
LE
197} VIRTIO_GPU_CMD_TRANSFER_TO_HOST_2D;\r
198#pragma pack ()\r
199\r
200//\r
201// Request structure for VirtioGpuCmdResourceFlush.\r
202//\r
203#pragma pack (1)\r
204typedef struct {\r
ac0a286f
MK
205 VIRTIO_GPU_CONTROL_HEADER Header;\r
206 VIRTIO_GPU_RECTANGLE Rectangle;\r
207 UINT32 ResourceId;\r
208 UINT32 Padding;\r
92dc5e9d
LE
209} VIRTIO_GPU_RESOURCE_FLUSH;\r
210#pragma pack ()\r
211\r
18212291
GH
212//\r
213// Response structure for VirtioGpuCmdGetDisplayInfo\r
214//\r
215#define VIRTIO_GPU_MAX_SCANOUTS 16\r
216#pragma pack (1)\r
217typedef struct {\r
218 VIRTIO_GPU_CONTROL_HEADER Header;\r
219 struct {\r
220 VIRTIO_GPU_RECTANGLE Rectangle;\r
221 UINT32 Enabled;\r
222 UINT32 Flags;\r
223 } Pmodes[VIRTIO_GPU_MAX_SCANOUTS];\r
224} VIRTIO_GPU_RESP_DISPLAY_INFO;\r
225#pragma pack ()\r
226\r
92dc5e9d 227#endif // _VIRTIO_GPU_H_\r