TianoCore EDK2 master
Loading...
Searching...
No Matches
VirtioGpu.h
Go to the documentation of this file.
1
21#ifndef _VIRTIO_GPU_H_
22#define _VIRTIO_GPU_H_
23
25
26//
27// Queue number for sending control commands.
28//
29#define VIRTIO_GPU_CONTROL_QUEUE 0
30
31//
32// Command and response types.
33//
34typedef enum {
35 //
36 // Commands related to mode setup:
37 //
38 // - create/release a host-side 2D resource,
39 //
40 VirtioGpuCmdGetDisplayInfo = 0x0100,
41 VirtioGpuCmdResourceCreate2d = 0x0101,
42 VirtioGpuCmdResourceUnref = 0x0102,
43 //
44 // - attach/detach guest RAM to/from a host-side 2D resource,
45 //
46 VirtioGpuCmdResourceAttachBacking = 0x0106,
47 VirtioGpuCmdResourceDetachBacking = 0x0107,
48 //
49 // - assign/unassign a host-side 2D resource to/from a scanout ("head").
50 //
51 VirtioGpuCmdSetScanout = 0x0103,
52
53 //
54 // Commands related to drawing:
55 //
56 // - transfer a guest RAM update to the host-side 2D resource (does not imply
57 // host display refresh),
58 //
59 VirtioGpuCmdTransferToHost2d = 0x0105,
60 //
61 // - trigger a host display refresh from the 2D resource.
62 //
63 VirtioGpuCmdResourceFlush = 0x0104,
64
65 //
66 // Success code for all of the above commands.
67 //
68 VirtioGpuRespOkNodata = 0x1100,
69 VirtioGpuRespOkDisplayInfo = 0x1101,
70} VIRTIO_GPU_CONTROL_TYPE;
71
72//
73// Common request/response header.
74//
75#define VIRTIO_GPU_FLAG_FENCE BIT0
76
77#pragma pack (1)
78typedef struct {
79 //
80 // The guest sets Type to VirtioGpuCmd* in the requests. The host sets Type
81 // to VirtioGpuResp* in the responses.
82 //
83 UINT32 Type;
84
85 //
86 // Fencing forces the host to complete the command before producing a
87 // response.
88 //
89 UINT32 Flags;
90 UINT64 FenceId;
91
92 //
93 // Unused.
94 //
95 UINT32 CtxId;
96 UINT32 Padding;
98#pragma pack ()
99
100//
101// Rectangle structure used by several operations.
102//
103#pragma pack (1)
104typedef struct {
105 UINT32 X;
106 UINT32 Y;
107 UINT32 Width;
108 UINT32 Height;
110#pragma pack ()
111
112//
113// Request structure for VirtioGpuCmdResourceCreate2d.
114//
115typedef enum {
116 //
117 // 32-bit depth, BGRX component order, X component ignored.
118 //
119 VirtioGpuFormatB8G8R8X8Unorm = 2,
120} VIRTIO_GPU_FORMATS;
121
122#pragma pack (1)
123typedef struct {
125 UINT32 ResourceId; // note: 0 is invalid
126 UINT32 Format; // from VIRTIO_GPU_FORMATS
127 UINT32 Width;
128 UINT32 Height;
130#pragma pack ()
131
132//
133// Request structure for VirtioGpuCmdResourceUnref.
134//
135#pragma pack (1)
136typedef struct {
138 UINT32 ResourceId;
139 UINT32 Padding;
141#pragma pack ()
142
143//
144// Request structure for VirtioGpuCmdResourceAttachBacking.
145//
146// The spec allows for a scatter-gather list, but for simplicity we hard-code a
147// single guest buffer.
148//
149#pragma pack (1)
150typedef struct {
151 UINT64 Addr;
152 UINT32 Length;
153 UINT32 Padding;
155
156typedef struct {
158 UINT32 ResourceId;
159 UINT32 NrEntries; // number of entries: constant 1
162#pragma pack ()
163
164//
165// Request structure for VirtioGpuCmdResourceDetachBacking.
166//
167#pragma pack (1)
168typedef struct {
170 UINT32 ResourceId;
171 UINT32 Padding;
173#pragma pack ()
174
175//
176// Request structure for VirtioGpuCmdSetScanout.
177//
178#pragma pack (1)
179typedef struct {
181 VIRTIO_GPU_RECTANGLE Rectangle;
182 UINT32 ScanoutId;
183 UINT32 ResourceId;
185#pragma pack ()
186
187//
188// Request structure for VirtioGpuCmdTransferToHost2d.
189//
190#pragma pack (1)
191typedef struct {
193 VIRTIO_GPU_RECTANGLE Rectangle;
194 UINT64 Offset;
195 UINT32 ResourceId;
196 UINT32 Padding;
198#pragma pack ()
199
200//
201// Request structure for VirtioGpuCmdResourceFlush.
202//
203#pragma pack (1)
204typedef struct {
206 VIRTIO_GPU_RECTANGLE Rectangle;
207 UINT32 ResourceId;
208 UINT32 Padding;
210#pragma pack ()
211
212//
213// Response structure for VirtioGpuCmdGetDisplayInfo
214//
215#define VIRTIO_GPU_MAX_SCANOUTS 16
216#pragma pack (1)
217typedef struct {
219 struct {
220 VIRTIO_GPU_RECTANGLE Rectangle;
221 UINT32 Enabled;
222 UINT32 Flags;
223 } Pmodes[VIRTIO_GPU_MAX_SCANOUTS];
225#pragma pack ()
226
227#endif // _VIRTIO_GPU_H_