]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/Include/IndustryStandard/VirtioGpu.h
OvmfPkg/MemEncryptSevLib: find pages of initial SMRAM save state map
[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
17 This program and the accompanying materials are licensed and made available\r
18 under the terms and conditions of the BSD License which accompanies this\r
19 distribution. The full text of the license may be found at\r
20 http://opensource.org/licenses/bsd-license.php\r
21\r
22 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT\r
23 WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
24\r
25**/\r
26\r
27#ifndef _VIRTIO_GPU_H_\r
28#define _VIRTIO_GPU_H_\r
29\r
30#include <IndustryStandard/Virtio.h>\r
31\r
32//\r
33// Queue number for sending control commands.\r
34//\r
35#define VIRTIO_GPU_CONTROL_QUEUE 0\r
36\r
37//\r
38// Command and response types.\r
39//\r
40typedef enum {\r
41 //\r
42 // Commands related to mode setup:\r
43 //\r
44 // - create/release a host-side 2D resource,\r
45 //\r
46 VirtioGpuCmdResourceCreate2d = 0x0101,\r
47 VirtioGpuCmdResourceUnref = 0x0102,\r
48 //\r
49 // - attach/detach guest RAM to/from a host-side 2D resource,\r
50 //\r
51 VirtioGpuCmdResourceAttachBacking = 0x0106,\r
52 VirtioGpuCmdResourceDetachBacking = 0x0107,\r
53 //\r
54 // - assign/unassign a host-side 2D resource to/from a scanout ("head").\r
55 //\r
56 VirtioGpuCmdSetScanout = 0x0103,\r
57\r
58 //\r
59 // Commands related to drawing:\r
60 //\r
61 // - transfer a guest RAM update to the host-side 2D resource (does not imply\r
62 // host display refresh),\r
63 //\r
64 VirtioGpuCmdTransferToHost2d = 0x0105,\r
65 //\r
66 // - trigger a host display refresh from the 2D resource.\r
67 //\r
68 VirtioGpuCmdResourceFlush = 0x0104,\r
69\r
70 //\r
71 // Success code for all of the above commands.\r
72 //\r
73 VirtioGpuRespOkNodata = 0x1100,\r
74} VIRTIO_GPU_CONTROL_TYPE;\r
75\r
76//\r
77// Common request/response header.\r
78//\r
79#define VIRTIO_GPU_FLAG_FENCE BIT0\r
80\r
81#pragma pack (1)\r
82typedef struct {\r
83 //\r
84 // The guest sets Type to VirtioGpuCmd* in the requests. The host sets Type\r
85 // to VirtioGpuResp* in the responses.\r
86 //\r
87 UINT32 Type;\r
88\r
89 //\r
90 // Fencing forces the host to complete the command before producing a\r
91 // response.\r
92 //\r
93 UINT32 Flags;\r
94 UINT64 FenceId;\r
95\r
96 //\r
97 // Unused.\r
98 //\r
99 UINT32 CtxId;\r
100 UINT32 Padding;\r
101} VIRTIO_GPU_CONTROL_HEADER;\r
102#pragma pack ()\r
103\r
104//\r
105// Rectangle structure used by several operations.\r
106//\r
107#pragma pack (1)\r
108typedef struct {\r
109 UINT32 X;\r
110 UINT32 Y;\r
111 UINT32 Width;\r
112 UINT32 Height;\r
113} VIRTIO_GPU_RECTANGLE;\r
114#pragma pack ()\r
115\r
116//\r
117// Request structure for VirtioGpuCmdResourceCreate2d.\r
118//\r
119typedef enum {\r
120 //\r
121 // 32-bit depth, BGRX component order, X component ignored.\r
122 //\r
123 VirtioGpuFormatB8G8R8X8Unorm = 2,\r
124} VIRTIO_GPU_FORMATS;\r
125\r
126#pragma pack (1)\r
127typedef struct {\r
128 VIRTIO_GPU_CONTROL_HEADER Header;\r
129 UINT32 ResourceId; // note: 0 is invalid\r
130 UINT32 Format; // from VIRTIO_GPU_FORMATS\r
131 UINT32 Width;\r
132 UINT32 Height;\r
133} VIRTIO_GPU_RESOURCE_CREATE_2D;\r
134#pragma pack ()\r
135\r
136//\r
137// Request structure for VirtioGpuCmdResourceUnref.\r
138//\r
139#pragma pack (1)\r
140typedef struct {\r
141 VIRTIO_GPU_CONTROL_HEADER Header;\r
142 UINT32 ResourceId;\r
143 UINT32 Padding;\r
144} VIRTIO_GPU_RESOURCE_UNREF;\r
145#pragma pack ()\r
146\r
147//\r
148// Request structure for VirtioGpuCmdResourceAttachBacking.\r
149//\r
150// The spec allows for a scatter-gather list, but for simplicity we hard-code a\r
151// single guest buffer.\r
152//\r
153#pragma pack (1)\r
154typedef struct {\r
155 UINT64 Addr;\r
156 UINT32 Length;\r
157 UINT32 Padding;\r
158} VIRTIO_GPU_MEM_ENTRY;\r
159\r
160typedef struct {\r
161 VIRTIO_GPU_CONTROL_HEADER Header;\r
162 UINT32 ResourceId;\r
163 UINT32 NrEntries; // number of entries: constant 1\r
164 VIRTIO_GPU_MEM_ENTRY Entry;\r
165} VIRTIO_GPU_RESOURCE_ATTACH_BACKING;\r
166#pragma pack ()\r
167\r
168//\r
169// Request structure for VirtioGpuCmdResourceDetachBacking.\r
170//\r
171#pragma pack (1)\r
172typedef struct {\r
173 VIRTIO_GPU_CONTROL_HEADER Header;\r
174 UINT32 ResourceId;\r
175 UINT32 Padding;\r
176} VIRTIO_GPU_RESOURCE_DETACH_BACKING;\r
177#pragma pack ()\r
178\r
179//\r
180// Request structure for VirtioGpuCmdSetScanout.\r
181//\r
182#pragma pack (1)\r
183typedef struct {\r
184 VIRTIO_GPU_CONTROL_HEADER Header;\r
185 VIRTIO_GPU_RECTANGLE Rectangle;\r
186 UINT32 ScanoutId;\r
187 UINT32 ResourceId;\r
188} VIRTIO_GPU_SET_SCANOUT;\r
189#pragma pack ()\r
190\r
191//\r
192// Request structure for VirtioGpuCmdTransferToHost2d.\r
193//\r
194#pragma pack (1)\r
195typedef struct {\r
196 VIRTIO_GPU_CONTROL_HEADER Header;\r
197 VIRTIO_GPU_RECTANGLE Rectangle;\r
198 UINT64 Offset;\r
199 UINT32 ResourceId;\r
200 UINT32 Padding;\r
201} VIRTIO_GPU_CMD_TRANSFER_TO_HOST_2D;\r
202#pragma pack ()\r
203\r
204//\r
205// Request structure for VirtioGpuCmdResourceFlush.\r
206//\r
207#pragma pack (1)\r
208typedef struct {\r
209 VIRTIO_GPU_CONTROL_HEADER Header;\r
210 VIRTIO_GPU_RECTANGLE Rectangle;\r
211 UINT32 ResourceId;\r
212 UINT32 Padding;\r
213} VIRTIO_GPU_RESOURCE_FLUSH;\r
214#pragma pack ()\r
215\r
216#endif // _VIRTIO_GPU_H_\r