vmwgfx: Update device headers for command buffers.
[linux-2.6-block.git] / drivers / gpu / drm / vmwgfx / svga_reg.h
CommitLineData
632f6117
JB
1/**********************************************************
2 * Copyright 1998-2009 VMware, Inc. All rights reserved.
3 *
4 * Permission is hereby granted, free of charge, to any person
5 * obtaining a copy of this software and associated documentation
6 * files (the "Software"), to deal in the Software without
7 * restriction, including without limitation the rights to use, copy,
8 * modify, merge, publish, distribute, sublicense, and/or sell copies
9 * of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
19 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 *
24 **********************************************************/
25
26/*
27 * svga_reg.h --
28 *
29 * Virtual hardware definitions for the VMware SVGA II device.
30 */
31
32#ifndef _SVGA_REG_H_
33#define _SVGA_REG_H_
34
35/*
36 * PCI device IDs.
37 */
632f6117
JB
38#define PCI_DEVICE_ID_VMWARE_SVGA2 0x0405
39
dcca2862
TH
40/*
41 * SVGA_REG_ENABLE bit definitions.
42 */
43#define SVGA_REG_ENABLE_DISABLE 0
44#define SVGA_REG_ENABLE_ENABLE 1
45#define SVGA_REG_ENABLE_HIDE 2
46#define SVGA_REG_ENABLE_ENABLE_HIDE (SVGA_REG_ENABLE_ENABLE |\
47 SVGA_REG_ENABLE_HIDE)
48
632f6117
JB
49/*
50 * Legal values for the SVGA_REG_CURSOR_ON register in old-fashioned
51 * cursor bypass mode. This is still supported, but no new guest
52 * drivers should use it.
53 */
54#define SVGA_CURSOR_ON_HIDE 0x0 /* Must be 0 to maintain backward compatibility */
55#define SVGA_CURSOR_ON_SHOW 0x1 /* Must be 1 to maintain backward compatibility */
56#define SVGA_CURSOR_ON_REMOVE_FROM_FB 0x2 /* Remove the cursor from the framebuffer because we need to see what's under it */
57#define SVGA_CURSOR_ON_RESTORE_TO_FB 0x3 /* Put the cursor back in the framebuffer so the user can see it */
58
59/*
60 * The maximum framebuffer size that can traced for e.g. guests in VESA mode.
61 * The changeMap in the monitor is proportional to this number. Therefore, we'd
62 * like to keep it as small as possible to reduce monitor overhead (using
63 * SVGA_VRAM_MAX_SIZE for this increases the size of the shared area by over
64 * 4k!).
65 *
66 * NB: For compatibility reasons, this value must be greater than 0xff0000.
67 * See bug 335072.
68 */
69#define SVGA_FB_MAX_TRACEABLE_SIZE 0x1000000
70
71#define SVGA_MAX_PSEUDOCOLOR_DEPTH 8
72#define SVGA_MAX_PSEUDOCOLORS (1 << SVGA_MAX_PSEUDOCOLOR_DEPTH)
73#define SVGA_NUM_PALETTE_REGS (3 * SVGA_MAX_PSEUDOCOLORS)
74
75#define SVGA_MAGIC 0x900000UL
76#define SVGA_MAKE_ID(ver) (SVGA_MAGIC << 8 | (ver))
77
78/* Version 2 let the address of the frame buffer be unsigned on Win32 */
79#define SVGA_VERSION_2 2
80#define SVGA_ID_2 SVGA_MAKE_ID(SVGA_VERSION_2)
81
82/* Version 1 has new registers starting with SVGA_REG_CAPABILITIES so
83 PALETTE_BASE has moved */
84#define SVGA_VERSION_1 1
85#define SVGA_ID_1 SVGA_MAKE_ID(SVGA_VERSION_1)
86
87/* Version 0 is the initial version */
88#define SVGA_VERSION_0 0
89#define SVGA_ID_0 SVGA_MAKE_ID(SVGA_VERSION_0)
90
91/* "Invalid" value for all SVGA IDs. (Version ID, screen object ID, surface ID...) */
92#define SVGA_ID_INVALID 0xFFFFFFFF
93
94/* Port offsets, relative to BAR0 */
95#define SVGA_INDEX_PORT 0x0
96#define SVGA_VALUE_PORT 0x1
97#define SVGA_BIOS_PORT 0x2
98#define SVGA_IRQSTATUS_PORT 0x8
99
100/*
101 * Interrupt source flags for IRQSTATUS_PORT and IRQMASK.
102 *
103 * Interrupts are only supported when the
104 * SVGA_CAP_IRQMASK capability is present.
105 */
106#define SVGA_IRQFLAG_ANY_FENCE 0x1 /* Any fence was passed */
107#define SVGA_IRQFLAG_FIFO_PROGRESS 0x2 /* Made forward progress in the FIFO */
108#define SVGA_IRQFLAG_FENCE_GOAL 0x4 /* SVGA_FIFO_FENCE_GOAL reached */
cb09bbcc
TH
109#define SVGA_IRQFLAG_COMMAND_BUFFER 0x8 /* Command buffer completed */
110#define SVGA_IRQFLAG_ERROR 0x10 /* Error while processing commands */
632f6117
JB
111
112/*
113 * Registers
114 */
115
116enum {
117 SVGA_REG_ID = 0,
118 SVGA_REG_ENABLE = 1,
119 SVGA_REG_WIDTH = 2,
120 SVGA_REG_HEIGHT = 3,
121 SVGA_REG_MAX_WIDTH = 4,
122 SVGA_REG_MAX_HEIGHT = 5,
123 SVGA_REG_DEPTH = 6,
124 SVGA_REG_BITS_PER_PIXEL = 7, /* Current bpp in the guest */
125 SVGA_REG_PSEUDOCOLOR = 8,
126 SVGA_REG_RED_MASK = 9,
127 SVGA_REG_GREEN_MASK = 10,
128 SVGA_REG_BLUE_MASK = 11,
129 SVGA_REG_BYTES_PER_LINE = 12,
130 SVGA_REG_FB_START = 13, /* (Deprecated) */
131 SVGA_REG_FB_OFFSET = 14,
132 SVGA_REG_VRAM_SIZE = 15,
133 SVGA_REG_FB_SIZE = 16,
134
135 /* ID 0 implementation only had the above registers, then the palette */
136
137 SVGA_REG_CAPABILITIES = 17,
138 SVGA_REG_MEM_START = 18, /* (Deprecated) */
139 SVGA_REG_MEM_SIZE = 19,
140 SVGA_REG_CONFIG_DONE = 20, /* Set when memory area configured */
141 SVGA_REG_SYNC = 21, /* See "FIFO Synchronization Registers" */
142 SVGA_REG_BUSY = 22, /* See "FIFO Synchronization Registers" */
143 SVGA_REG_GUEST_ID = 23, /* Set guest OS identifier */
144 SVGA_REG_CURSOR_ID = 24, /* (Deprecated) */
145 SVGA_REG_CURSOR_X = 25, /* (Deprecated) */
146 SVGA_REG_CURSOR_Y = 26, /* (Deprecated) */
147 SVGA_REG_CURSOR_ON = 27, /* (Deprecated) */
148 SVGA_REG_HOST_BITS_PER_PIXEL = 28, /* (Deprecated) */
149 SVGA_REG_SCRATCH_SIZE = 29, /* Number of scratch registers */
150 SVGA_REG_MEM_REGS = 30, /* Number of FIFO registers */
151 SVGA_REG_NUM_DISPLAYS = 31, /* (Deprecated) */
152 SVGA_REG_PITCHLOCK = 32, /* Fixed pitch for all modes */
153 SVGA_REG_IRQMASK = 33, /* Interrupt mask */
154
155 /* Legacy multi-monitor support */
156 SVGA_REG_NUM_GUEST_DISPLAYS = 34,/* Number of guest displays in X/Y direction */
157 SVGA_REG_DISPLAY_ID = 35, /* Display ID for the following display attributes */
158 SVGA_REG_DISPLAY_IS_PRIMARY = 36,/* Whether this is a primary display */
159 SVGA_REG_DISPLAY_POSITION_X = 37,/* The display position x */
160 SVGA_REG_DISPLAY_POSITION_Y = 38,/* The display position y */
161 SVGA_REG_DISPLAY_WIDTH = 39, /* The display's width */
162 SVGA_REG_DISPLAY_HEIGHT = 40, /* The display's height */
163
164 /* See "Guest memory regions" below. */
165 SVGA_REG_GMR_ID = 41,
166 SVGA_REG_GMR_DESCRIPTOR = 42,
167 SVGA_REG_GMR_MAX_IDS = 43,
168 SVGA_REG_GMR_MAX_DESCRIPTOR_LENGTH = 44,
169
170 SVGA_REG_TRACES = 45, /* Enable trace-based updates even when FIFO is on */
dcca2862
TH
171 SVGA_REG_GMRS_MAX_PAGES = 46, /* Maximum number of 4KB pages for all GMRs */
172 SVGA_REG_MEMORY_SIZE = 47, /* Total dedicated device memory excluding FIFO */
857aea1c
CL
173 SVGA_REG_COMMAND_LOW = 48, /* Lower 32 bits and submits commands */
174 SVGA_REG_COMMAND_HIGH = 49, /* Upper 32 bits of command buffer PA */
c1234db7
TH
175 SVGA_REG_MAX_PRIMARY_BOUNDING_BOX_MEM = 50, /* Max primary memory */
176 SVGA_REG_SUGGESTED_GBOBJECT_MEM_SIZE_KB = 51, /* Suggested limit on mob mem */
177 SVGA_REG_DEV_CAP = 52, /* Write dev cap index, read value */
857aea1c
CL
178 SVGA_REG_CMD_PREPEND_LOW = 53,
179 SVGA_REG_CMD_PREPEND_HIGH = 54,
180 SVGA_REG_SCREENTARGET_MAX_WIDTH = 55,
181 SVGA_REG_SCREENTARGET_MAX_HEIGHT = 56,
182 SVGA_REG_MOB_MAX_SIZE = 57,
183 SVGA_REG_TOP = 58, /* Must be 1 more than the last register */
632f6117
JB
184
185 SVGA_PALETTE_BASE = 1024, /* Base of SVGA color map */
186 /* Next 768 (== 256*3) registers exist for colormap */
187
188 SVGA_SCRATCH_BASE = SVGA_PALETTE_BASE + SVGA_NUM_PALETTE_REGS
189 /* Base of scratch registers */
190 /* Next reg[SVGA_REG_SCRATCH_SIZE] registers exist for scratch usage:
191 First 4 are reserved for VESA BIOS Extension; any remaining are for
192 the use of the current SVGA driver. */
193};
194
195
196/*
197 * Guest memory regions (GMRs):
198 *
199 * This is a new memory mapping feature available in SVGA devices
200 * which have the SVGA_CAP_GMR bit set. Previously, there were two
201 * fixed memory regions available with which to share data between the
202 * device and the driver: the FIFO ('MEM') and the framebuffer. GMRs
203 * are our name for an extensible way of providing arbitrary DMA
204 * buffers for use between the driver and the SVGA device. They are a
205 * new alternative to framebuffer memory, usable for both 2D and 3D
206 * graphics operations.
207 *
208 * Since GMR mapping must be done synchronously with guest CPU
209 * execution, we use a new pair of SVGA registers:
210 *
211 * SVGA_REG_GMR_ID --
212 *
213 * Read/write.
214 * This register holds the 32-bit ID (a small positive integer)
215 * of a GMR to create, delete, or redefine. Writing this register
216 * has no side-effects.
217 *
218 * SVGA_REG_GMR_DESCRIPTOR --
219 *
220 * Write-only.
221 * Writing this register will create, delete, or redefine the GMR
222 * specified by the above ID register. If this register is zero,
223 * the GMR is deleted. Any pointers into this GMR (including those
224 * currently being processed by FIFO commands) will be
225 * synchronously invalidated.
226 *
227 * If this register is nonzero, it must be the physical page
228 * number (PPN) of a data structure which describes the physical
229 * layout of the memory region this GMR should describe. The
230 * descriptor structure will be read synchronously by the SVGA
231 * device when this register is written. The descriptor need not
232 * remain allocated for the lifetime of the GMR.
233 *
234 * The guest driver should write SVGA_REG_GMR_ID first, then
235 * SVGA_REG_GMR_DESCRIPTOR.
236 *
237 * SVGA_REG_GMR_MAX_IDS --
238 *
239 * Read-only.
240 * The SVGA device may choose to support a maximum number of
241 * user-defined GMR IDs. This register holds the number of supported
242 * IDs. (The maximum supported ID plus 1)
243 *
244 * SVGA_REG_GMR_MAX_DESCRIPTOR_LENGTH --
245 *
246 * Read-only.
247 * The SVGA device may choose to put a limit on the total number
248 * of SVGAGuestMemDescriptor structures it will read when defining
249 * a single GMR.
250 *
251 * The descriptor structure is an array of SVGAGuestMemDescriptor
252 * structures. Each structure may do one of three things:
253 *
254 * - Terminate the GMR descriptor list.
255 * (ppn==0, numPages==0)
256 *
257 * - Add a PPN or range of PPNs to the GMR's virtual address space.
258 * (ppn != 0, numPages != 0)
259 *
260 * - Provide the PPN of the next SVGAGuestMemDescriptor, in order to
261 * support multi-page GMR descriptor tables without forcing the
262 * driver to allocate physically contiguous memory.
263 * (ppn != 0, numPages == 0)
264 *
265 * Note that each physical page of SVGAGuestMemDescriptor structures
266 * can describe at least 2MB of guest memory. If the driver needs to
267 * use more than one page of descriptor structures, it must use one of
268 * its SVGAGuestMemDescriptors to point to an additional page. The
269 * device will never automatically cross a page boundary.
270 *
271 * Once the driver has described a GMR, it is immediately available
272 * for use via any FIFO command that uses an SVGAGuestPtr structure.
273 * These pointers include a GMR identifier plus an offset into that
274 * GMR.
275 *
276 * The driver must check the SVGA_CAP_GMR bit before using the GMR
277 * registers.
278 */
279
280/*
281 * Special GMR IDs, allowing SVGAGuestPtrs to point to framebuffer
282 * memory as well. In the future, these IDs could even be used to
283 * allow legacy memory regions to be redefined by the guest as GMRs.
284 *
285 * Using the guest framebuffer (GFB) at BAR1 for general purpose DMA
286 * is being phased out. Please try to use user-defined GMRs whenever
287 * possible.
288 */
289#define SVGA_GMR_NULL ((uint32) -1)
8d3713ea 290#define SVGA_GMR_FRAMEBUFFER ((uint32) -2) /* Guest Framebuffer (GFB) */
632f6117
JB
291
292typedef
293struct SVGAGuestMemDescriptor {
294 uint32 ppn;
295 uint32 numPages;
296} SVGAGuestMemDescriptor;
297
298typedef
299struct SVGAGuestPtr {
300 uint32 gmrId;
301 uint32 offset;
302} SVGAGuestPtr;
303
cb09bbcc
TH
304/*
305 * Register based command buffers --
306 *
307 * Provide an SVGA device interface that allows the guest to submit
308 * command buffers to the SVGA device through an SVGA device register.
309 * The metadata for each command buffer is contained in the
310 * SVGACBHeader structure along with the return status codes.
311 *
312 * The SVGA device supports command buffers if
313 * SVGA_CAP_COMMAND_BUFFERS is set in the device caps register. The
314 * fifo must be enabled for command buffers to be submitted.
315 *
316 * Command buffers are submitted when the guest writing the 64 byte
317 * aligned physical address into the SVGA_REG_COMMAND_LOW and
318 * SVGA_REG_COMMAND_HIGH. SVGA_REG_COMMAND_HIGH contains the upper 32
319 * bits of the physical address. SVGA_REG_COMMAND_LOW contains the
320 * lower 32 bits of the physical address, since the command buffer
321 * headers are required to be 64 byte aligned the lower 6 bits are
322 * used for the SVGACBContext value. Writing to SVGA_REG_COMMAND_LOW
323 * submits the command buffer to the device and queues it for
324 * execution. The SVGA device supports at least
325 * SVGA_CB_MAX_QUEUED_PER_CONTEXT command buffers that can be queued
326 * per context and if that limit is reached the device will write the
327 * status SVGA_CB_STATUS_QUEUE_FULL to the status value of the command
328 * buffer header synchronously and not raise any IRQs.
329 *
330 * It is invalid to submit a command buffer without a valid physical
331 * address and results are undefined.
332 *
333 * The device guarantees that command buffers of size SVGA_CB_MAX_SIZE
334 * will be supported. If a larger command buffer is submitted results
335 * are unspecified and the device will either complete the command
336 * buffer or return an error.
337 *
338 * The device guarantees that any individual command in a command
339 * buffer can be up to SVGA_CB_MAX_COMMAND_SIZE in size which is
340 * enough to fit a 64x64 color-cursor definition. If the command is
341 * too large the device is allowed to process the command or return an
342 * error.
343 *
344 * The device context is a special SVGACBContext that allows for
345 * synchronous register like accesses with the flexibility of
346 * commands. There is a different command set defined by
347 * SVGADeviceContextCmdId. The commands in each command buffer is not
348 * allowed to straddle physical pages.
349 *
350 * The offset field which is available starting with the
351 * SVGA_CAP_CMD_BUFFERS_2 cap bit can be set by the guest to bias the
352 * start of command processing into the buffer. If an error is
353 * encountered the errorOffset will still be relative to the specific
354 * PA, not biased by the offset. When the command buffer is finished
355 * the guest should not read the offset field as there is no guarantee
356 * what it will set to.
357 */
358
359#define SVGA_CB_MAX_SIZE (512 * 1024) // 512 KB
360#define SVGA_CB_MAX_QUEUED_PER_CONTEXT 32
361#define SVGA_CB_MAX_COMMAND_SIZE (32 * 1024) // 32 KB
362
363#define SVGA_CB_CONTEXT_MASK 0x3f
364typedef enum {
365 SVGA_CB_CONTEXT_DEVICE = 0x3f,
366 SVGA_CB_CONTEXT_0 = 0x0,
367 SVGA_CB_CONTEXT_MAX = 0x1,
368} SVGACBContext;
369
370
371typedef enum {
372 /*
373 * The guest is supposed to write SVGA_CB_STATUS_NONE to the status
374 * field before submitting the command buffer header, the host will
375 * change the value when it is done with the command buffer.
376 */
377 SVGA_CB_STATUS_NONE = 0,
378
379 /*
380 * Written by the host when a command buffer completes successfully.
381 * The device raises an IRQ with SVGA_IRQFLAG_COMMAND_BUFFER unless
382 * the SVGA_CB_FLAG_NO_IRQ flag is set.
383 */
384 SVGA_CB_STATUS_COMPLETED = 1,
385
386 /*
387 * Written by the host synchronously with the command buffer
388 * submission to indicate the command buffer was not submitted. No
389 * IRQ is raised.
390 */
391 SVGA_CB_STATUS_QUEUE_FULL = 2,
392
393 /*
394 * Written by the host when an error was detected parsing a command
395 * in the command buffer, errorOffset is written to contain the
396 * offset to the first byte of the failing command. The device
397 * raises the IRQ with both SVGA_IRQFLAG_ERROR and
398 * SVGA_IRQFLAG_COMMAND_BUFFER. Some of the commands may have been
399 * processed.
400 */
401 SVGA_CB_STATUS_COMMAND_ERROR = 3,
402
403 /*
404 * Written by the host if there is an error parsing the command
405 * buffer header. The device raises the IRQ with both
406 * SVGA_IRQFLAG_ERROR and SVGA_IRQFLAG_COMMAND_BUFFER. The device
407 * did not processes any of the command buffer.
408 */
409 SVGA_CB_STATUS_CB_HEADER_ERROR = 4,
410
411 /*
412 * Written by the host if the guest requested the host to preempt
413 * the command buffer. The device will not raise any IRQs and the
414 * command buffer was not processed.
415 */
416 SVGA_CB_STATUS_PREEMPTED = 5,
417
418 /*
419 * Written by the host synchronously with the command buffer
420 * submission to indicate the the command buffer was not submitted
421 * due to an error. No IRQ is raised.
422 */
423 SVGA_CB_STATUS_SUBMISSION_ERROR = 6,
424} SVGACBStatus;
425
426typedef enum {
427 SVGA_CB_FLAG_NONE = 0,
428 SVGA_CB_FLAG_NO_IRQ = 1 << 0,
429 SVGA_CB_FLAG_DX_CONTEXT = 1 << 1,
430 SVGA_CB_FLAG_MOB = 1 << 2,
431} SVGACBFlags;
432
433typedef
434struct {
435 volatile SVGACBStatus status; /* Modified by device. */
436 volatile uint32 errorOffset; /* Modified by device. */
437 uint64 id;
438 SVGACBFlags flags;
439 uint32 length;
440 union {
441 PA pa;
442 struct {
443 SVGAMobId mobid;
444 uint32 mobOffset;
445 } mob;
446 } ptr;
447 uint32 offset; /* Valid if CMD_BUFFERS_2 cap set, must be zero otherwise,
448 * modified by device.
449 */
450 uint32 dxContext; /* Valid if DX_CONTEXT flag set, must be zero otherwise */
451 uint32 mustBeZero[6];
452}
453__attribute__((__packed__))
454SVGACBHeader;
455
456typedef enum {
457 SVGA_DC_CMD_NOP = 0,
458 SVGA_DC_CMD_START_STOP_CONTEXT = 1,
459 SVGA_DC_CMD_PREEMPT = 2,
460 SVGA_DC_CMD_MAX = 3,
461} SVGADeviceContextCmdId;
462
463
464typedef struct {
465 uint32 enable;
466 SVGACBContext context;
467} SVGADCCmdStartStop;
468
469/*
470 * SVGADCCmdPreempt --
471 *
472 * This command allows the guest to request that all command buffers
473 * on the specified context be preempted that can be. After execution
474 * of this command all command buffers that were preempted will
475 * already have SVGA_CB_STATUS_PREEMPTED written into the status
476 * field. The device might still be processing a command buffer,
477 * assuming execution of it started before the preemption request was
478 * received. Specifying the ignoreIDZero flag to TRUE will cause the
479 * device to not preempt command buffers with the id field in the
480 * command buffer header set to zero.
481 */
482
483typedef struct {
484 SVGACBContext context;
485 uint32 ignoreIDZero;
486} SVGADCCmdPreempt;
487
632f6117
JB
488
489/*
490 * SVGAGMRImageFormat --
491 *
492 * This is a packed representation of the source 2D image format
493 * for a GMR-to-screen blit. Currently it is defined as an encoding
494 * of the screen's color depth and bits-per-pixel, however, 16 bits
495 * are reserved for future use to identify other encodings (such as
496 * RGBA or higher-precision images).
497 *
498 * Currently supported formats:
499 *
500 * bpp depth Format Name
501 * --- ----- -----------
502 * 32 24 32-bit BGRX
503 * 24 24 24-bit BGR
504 * 16 16 RGB 5-6-5
505 * 16 15 RGB 5-5-5
506 *
507 */
508
509typedef
510struct SVGAGMRImageFormat {
511 union {
512 struct {
513 uint32 bitsPerPixel : 8;
514 uint32 colorDepth : 8;
8d3713ea 515 uint32 reserved : 16; /* Must be zero */
632f6117
JB
516 };
517
518 uint32 value;
519 };
520} SVGAGMRImageFormat;
521
8d3713ea
JB
522typedef
523struct SVGAGuestImage {
524 SVGAGuestPtr ptr;
525
526 /*
527 * A note on interpretation of pitch: This value of pitch is the
528 * number of bytes between vertically adjacent image
529 * blocks. Normally this is the number of bytes between the first
530 * pixel of two adjacent scanlines. With compressed textures,
531 * however, this may represent the number of bytes between
532 * compression blocks rather than between rows of pixels.
533 *
534 * XXX: Compressed textures currently must be tightly packed in guest memory.
535 *
536 * If the image is 1-dimensional, pitch is ignored.
537 *
538 * If 'pitch' is zero, the SVGA3D device calculates a pitch value
539 * assuming each row of blocks is tightly packed.
540 */
541 uint32 pitch;
542} SVGAGuestImage;
543
632f6117
JB
544/*
545 * SVGAColorBGRX --
546 *
547 * A 24-bit color format (BGRX), which does not depend on the
548 * format of the legacy guest framebuffer (GFB) or the current
549 * GMRFB state.
550 */
551
552typedef
553struct SVGAColorBGRX {
554 union {
555 struct {
556 uint32 b : 8;
557 uint32 g : 8;
558 uint32 r : 8;
8d3713ea 559 uint32 x : 8; /* Unused */
632f6117
JB
560 };
561
562 uint32 value;
563 };
564} SVGAColorBGRX;
565
566
567/*
568 * SVGASignedRect --
569 * SVGASignedPoint --
570 *
571 * Signed rectangle and point primitives. These are used by the new
572 * 2D primitives for drawing to Screen Objects, which can occupy a
573 * signed virtual coordinate space.
574 *
575 * SVGASignedRect specifies a half-open interval: the (left, top)
576 * pixel is part of the rectangle, but the (right, bottom) pixel is
577 * not.
578 */
579
580typedef
581struct SVGASignedRect {
582 int32 left;
583 int32 top;
584 int32 right;
585 int32 bottom;
586} SVGASignedRect;
587
588typedef
589struct SVGASignedPoint {
590 int32 x;
591 int32 y;
592} SVGASignedPoint;
593
594
595/*
596 * Capabilities
597 *
598 * Note the holes in the bitfield. Missing bits have been deprecated,
599 * and must not be reused. Those capabilities will never be reported
600 * by new versions of the SVGA device.
dcca2862
TH
601 *
602 * SVGA_CAP_GMR2 --
603 * Provides asynchronous commands to define and remap guest memory
604 * regions. Adds device registers SVGA_REG_GMRS_MAX_PAGES and
605 * SVGA_REG_MEMORY_SIZE.
606 *
607 * SVGA_CAP_SCREEN_OBJECT_2 --
608 * Allow screen object support, and require backing stores from the
609 * guest for each screen object.
632f6117
JB
610 */
611
612#define SVGA_CAP_NONE 0x00000000
613#define SVGA_CAP_RECT_COPY 0x00000002
614#define SVGA_CAP_CURSOR 0x00000020
8d3713ea
JB
615#define SVGA_CAP_CURSOR_BYPASS 0x00000040 /* Legacy (Use Cursor Bypass 3 instead) */
616#define SVGA_CAP_CURSOR_BYPASS_2 0x00000080 /* Legacy (Use Cursor Bypass 3 instead) */
632f6117
JB
617#define SVGA_CAP_8BIT_EMULATION 0x00000100
618#define SVGA_CAP_ALPHA_CURSOR 0x00000200
619#define SVGA_CAP_3D 0x00004000
620#define SVGA_CAP_EXTENDED_FIFO 0x00008000
8d3713ea 621#define SVGA_CAP_MULTIMON 0x00010000 /* Legacy multi-monitor support */
632f6117
JB
622#define SVGA_CAP_PITCHLOCK 0x00020000
623#define SVGA_CAP_IRQMASK 0x00040000
8d3713ea 624#define SVGA_CAP_DISPLAY_TOPOLOGY 0x00080000 /* Legacy multi-monitor support */
632f6117
JB
625#define SVGA_CAP_GMR 0x00100000
626#define SVGA_CAP_TRACES 0x00200000
dcca2862
TH
627#define SVGA_CAP_GMR2 0x00400000
628#define SVGA_CAP_SCREEN_OBJECT_2 0x00800000
c1234db7
TH
629#define SVGA_CAP_COMMAND_BUFFERS 0x01000000
630#define SVGA_CAP_DEAD1 0x02000000
631#define SVGA_CAP_CMD_BUFFERS_2 0x04000000
632#define SVGA_CAP_GBOBJECTS 0x08000000
cb09bbcc 633#define SVGA_CAP_CMD_BUFFERS_3 0x10000000
632f6117
JB
634
635/*
636 * FIFO register indices.
637 *
638 * The FIFO is a chunk of device memory mapped into guest physmem. It
639 * is always treated as 32-bit words.
640 *
641 * The guest driver gets to decide how to partition it between
642 * - FIFO registers (there are always at least 4, specifying where the
643 * following data area is and how much data it contains; there may be
644 * more registers following these, depending on the FIFO protocol
645 * version in use)
646 * - FIFO data, written by the guest and slurped out by the VMX.
647 * These indices are 32-bit word offsets into the FIFO.
648 */
649
650enum {
651 /*
652 * Block 1 (basic registers): The originally defined FIFO registers.
653 * These exist and are valid for all versions of the FIFO protocol.
654 */
655
656 SVGA_FIFO_MIN = 0,
657 SVGA_FIFO_MAX, /* The distance from MIN to MAX must be at least 10K */
658 SVGA_FIFO_NEXT_CMD,
659 SVGA_FIFO_STOP,
660
661 /*
662 * Block 2 (extended registers): Mandatory registers for the extended
663 * FIFO. These exist if the SVGA caps register includes
664 * SVGA_CAP_EXTENDED_FIFO; some of them are valid only if their
665 * associated capability bit is enabled.
666 *
667 * Note that when originally defined, SVGA_CAP_EXTENDED_FIFO implied
668 * support only for (FIFO registers) CAPABILITIES, FLAGS, and FENCE.
669 * This means that the guest has to test individually (in most cases
670 * using FIFO caps) for the presence of registers after this; the VMX
671 * can define "extended FIFO" to mean whatever it wants, and currently
672 * won't enable it unless there's room for that set and much more.
673 */
674
675 SVGA_FIFO_CAPABILITIES = 4,
676 SVGA_FIFO_FLAGS,
8d3713ea 677 /* Valid with SVGA_FIFO_CAP_FENCE: */
632f6117
JB
678 SVGA_FIFO_FENCE,
679
680 /*
681 * Block 3a (optional extended registers): Additional registers for the
682 * extended FIFO, whose presence isn't actually implied by
683 * SVGA_CAP_EXTENDED_FIFO; these exist if SVGA_FIFO_MIN is high enough to
684 * leave room for them.
685 *
686 * These in block 3a, the VMX currently considers mandatory for the
687 * extended FIFO.
688 */
689
8d3713ea 690 /* Valid if exists (i.e. if extended FIFO enabled): */
632f6117 691 SVGA_FIFO_3D_HWVERSION, /* See SVGA3dHardwareVersion in svga3d_reg.h */
8d3713ea 692 /* Valid with SVGA_FIFO_CAP_PITCHLOCK: */
632f6117
JB
693 SVGA_FIFO_PITCHLOCK,
694
8d3713ea 695 /* Valid with SVGA_FIFO_CAP_CURSOR_BYPASS_3: */
632f6117
JB
696 SVGA_FIFO_CURSOR_ON, /* Cursor bypass 3 show/hide register */
697 SVGA_FIFO_CURSOR_X, /* Cursor bypass 3 x register */
698 SVGA_FIFO_CURSOR_Y, /* Cursor bypass 3 y register */
699 SVGA_FIFO_CURSOR_COUNT, /* Incremented when any of the other 3 change */
700 SVGA_FIFO_CURSOR_LAST_UPDATED,/* Last time the host updated the cursor */
701
8d3713ea 702 /* Valid with SVGA_FIFO_CAP_RESERVE: */
632f6117
JB
703 SVGA_FIFO_RESERVED, /* Bytes past NEXT_CMD with real contents */
704
705 /*
8d3713ea 706 * Valid with SVGA_FIFO_CAP_SCREEN_OBJECT or SVGA_FIFO_CAP_SCREEN_OBJECT_2:
632f6117
JB
707 *
708 * By default this is SVGA_ID_INVALID, to indicate that the cursor
709 * coordinates are specified relative to the virtual root. If this
710 * is set to a specific screen ID, cursor position is reinterpreted
8d3713ea 711 * as a signed offset relative to that screen's origin.
632f6117
JB
712 */
713 SVGA_FIFO_CURSOR_SCREEN_ID,
714
8d3713ea
JB
715 /*
716 * Valid with SVGA_FIFO_CAP_DEAD
717 *
718 * An arbitrary value written by the host, drivers should not use it.
719 */
720 SVGA_FIFO_DEAD,
721
722 /*
723 * Valid with SVGA_FIFO_CAP_3D_HWVERSION_REVISED:
724 *
725 * Contains 3D HWVERSION (see SVGA3dHardwareVersion in svga3d_reg.h)
726 * on platforms that can enforce graphics resource limits.
727 */
728 SVGA_FIFO_3D_HWVERSION_REVISED,
729
632f6117
JB
730 /*
731 * XXX: The gap here, up until SVGA_FIFO_3D_CAPS, can be used for new
732 * registers, but this must be done carefully and with judicious use of
733 * capability bits, since comparisons based on SVGA_FIFO_MIN aren't
734 * enough to tell you whether the register exists: we've shipped drivers
735 * and products that used SVGA_FIFO_3D_CAPS but didn't know about some of
736 * the earlier ones. The actual order of introduction was:
737 * - PITCHLOCK
738 * - 3D_CAPS
739 * - CURSOR_* (cursor bypass 3)
740 * - RESERVED
741 * So, code that wants to know whether it can use any of the
742 * aforementioned registers, or anything else added after PITCHLOCK and
743 * before 3D_CAPS, needs to reason about something other than
744 * SVGA_FIFO_MIN.
745 */
746
747 /*
748 * 3D caps block space; valid with 3D hardware version >=
749 * SVGA3D_HWVERSION_WS6_B1.
750 */
751 SVGA_FIFO_3D_CAPS = 32,
752 SVGA_FIFO_3D_CAPS_LAST = 32 + 255,
753
754 /*
755 * End of VMX's current definition of "extended-FIFO registers".
756 * Registers before here are always enabled/disabled as a block; either
757 * the extended FIFO is enabled and includes all preceding registers, or
758 * it's disabled entirely.
759 *
760 * Block 3b (truly optional extended registers): Additional registers for
761 * the extended FIFO, which the VMX already knows how to enable and
762 * disable with correct granularity.
763 *
764 * Registers after here exist if and only if the guest SVGA driver
765 * sets SVGA_FIFO_MIN high enough to leave room for them.
766 */
767
8d3713ea 768 /* Valid if register exists: */
632f6117
JB
769 SVGA_FIFO_GUEST_3D_HWVERSION, /* Guest driver's 3D version */
770 SVGA_FIFO_FENCE_GOAL, /* Matching target for SVGA_IRQFLAG_FENCE_GOAL */
771 SVGA_FIFO_BUSY, /* See "FIFO Synchronization Registers" */
772
773 /*
774 * Always keep this last. This defines the maximum number of
775 * registers we know about. At power-on, this value is placed in
776 * the SVGA_REG_MEM_REGS register, and we expect the guest driver
777 * to allocate this much space in FIFO memory for registers.
778 */
779 SVGA_FIFO_NUM_REGS
780};
781
782
783/*
784 * Definition of registers included in extended FIFO support.
785 *
786 * The guest SVGA driver gets to allocate the FIFO between registers
787 * and data. It must always allocate at least 4 registers, but old
788 * drivers stopped there.
789 *
790 * The VMX will enable extended FIFO support if and only if the guest
791 * left enough room for all registers defined as part of the mandatory
792 * set for the extended FIFO.
793 *
794 * Note that the guest drivers typically allocate the FIFO only at
795 * initialization time, not at mode switches, so it's likely that the
796 * number of FIFO registers won't change without a reboot.
797 *
798 * All registers less than this value are guaranteed to be present if
799 * svgaUser->fifo.extended is set. Any later registers must be tested
800 * individually for compatibility at each use (in the VMX).
801 *
802 * This value is used only by the VMX, so it can change without
803 * affecting driver compatibility; keep it that way?
804 */
805#define SVGA_FIFO_EXTENDED_MANDATORY_REGS (SVGA_FIFO_3D_CAPS_LAST + 1)
806
807
808/*
809 * FIFO Synchronization Registers
810 *
811 * This explains the relationship between the various FIFO
812 * sync-related registers in IOSpace and in FIFO space.
813 *
814 * SVGA_REG_SYNC --
815 *
816 * The SYNC register can be used in two different ways by the guest:
817 *
818 * 1. If the guest wishes to fully sync (drain) the FIFO,
819 * it will write once to SYNC then poll on the BUSY
820 * register. The FIFO is sync'ed once BUSY is zero.
821 *
822 * 2. If the guest wants to asynchronously wake up the host,
823 * it will write once to SYNC without polling on BUSY.
824 * Ideally it will do this after some new commands have
825 * been placed in the FIFO, and after reading a zero
826 * from SVGA_FIFO_BUSY.
827 *
828 * (1) is the original behaviour that SYNC was designed to
829 * support. Originally, a write to SYNC would implicitly
830 * trigger a read from BUSY. This causes us to synchronously
831 * process the FIFO.
832 *
833 * This behaviour has since been changed so that writing SYNC
834 * will *not* implicitly cause a read from BUSY. Instead, it
835 * makes a channel call which asynchronously wakes up the MKS
836 * thread.
837 *
838 * New guests can use this new behaviour to implement (2)
839 * efficiently. This lets guests get the host's attention
840 * without waiting for the MKS to poll, which gives us much
841 * better CPU utilization on SMP hosts and on UP hosts while
842 * we're blocked on the host GPU.
843 *
844 * Old guests shouldn't notice the behaviour change. SYNC was
845 * never guaranteed to process the entire FIFO, since it was
846 * bounded to a particular number of CPU cycles. Old guests will
847 * still loop on the BUSY register until the FIFO is empty.
848 *
849 * Writing to SYNC currently has the following side-effects:
850 *
851 * - Sets SVGA_REG_BUSY to TRUE (in the monitor)
852 * - Asynchronously wakes up the MKS thread for FIFO processing
853 * - The value written to SYNC is recorded as a "reason", for
854 * stats purposes.
855 *
856 * If SVGA_FIFO_BUSY is available, drivers are advised to only
857 * write to SYNC if SVGA_FIFO_BUSY is FALSE. Drivers should set
858 * SVGA_FIFO_BUSY to TRUE after writing to SYNC. The MKS will
859 * eventually set SVGA_FIFO_BUSY on its own, but this approach
860 * lets the driver avoid sending multiple asynchronous wakeup
861 * messages to the MKS thread.
862 *
863 * SVGA_REG_BUSY --
864 *
865 * This register is set to TRUE when SVGA_REG_SYNC is written,
866 * and it reads as FALSE when the FIFO has been completely
867 * drained.
868 *
869 * Every read from this register causes us to synchronously
870 * process FIFO commands. There is no guarantee as to how many
871 * commands each read will process.
872 *
873 * CPU time spent processing FIFO commands will be billed to
874 * the guest.
875 *
876 * New drivers should avoid using this register unless they
877 * need to guarantee that the FIFO is completely drained. It
878 * is overkill for performing a sync-to-fence. Older drivers
879 * will use this register for any type of synchronization.
880 *
881 * SVGA_FIFO_BUSY --
882 *
883 * This register is a fast way for the guest driver to check
884 * whether the FIFO is already being processed. It reads and
885 * writes at normal RAM speeds, with no monitor intervention.
886 *
887 * If this register reads as TRUE, the host is guaranteeing that
888 * any new commands written into the FIFO will be noticed before
889 * the MKS goes back to sleep.
890 *
891 * If this register reads as FALSE, no such guarantee can be
892 * made.
893 *
894 * The guest should use this register to quickly determine
895 * whether or not it needs to wake up the host. If the guest
896 * just wrote a command or group of commands that it would like
897 * the host to begin processing, it should:
898 *
899 * 1. Read SVGA_FIFO_BUSY. If it reads as TRUE, no further
900 * action is necessary.
901 *
902 * 2. Write TRUE to SVGA_FIFO_BUSY. This informs future guest
903 * code that we've already sent a SYNC to the host and we
904 * don't need to send a duplicate.
905 *
906 * 3. Write a reason to SVGA_REG_SYNC. This will send an
907 * asynchronous wakeup to the MKS thread.
908 */
909
910
911/*
912 * FIFO Capabilities
913 *
914 * Fence -- Fence register and command are supported
915 * Accel Front -- Front buffer only commands are supported
916 * Pitch Lock -- Pitch lock register is supported
917 * Video -- SVGA Video overlay units are supported
918 * Escape -- Escape command is supported
919 *
920 * XXX: Add longer descriptions for each capability, including a list
921 * of the new features that each capability provides.
922 *
923 * SVGA_FIFO_CAP_SCREEN_OBJECT --
924 *
925 * Provides dynamic multi-screen rendering, for improved Unity and
926 * multi-monitor modes. With Screen Object, the guest can
927 * dynamically create and destroy 'screens', which can represent
928 * Unity windows or virtual monitors. Screen Object also provides
929 * strong guarantees that DMA operations happen only when
930 * guest-initiated. Screen Object deprecates the BAR1 guest
931 * framebuffer (GFB) and all commands that work only with the GFB.
932 *
933 * New registers:
934 * FIFO_CURSOR_SCREEN_ID, VIDEO_DATA_GMRID, VIDEO_DST_SCREEN_ID
935 *
936 * New 2D commands:
937 * DEFINE_SCREEN, DESTROY_SCREEN, DEFINE_GMRFB, BLIT_GMRFB_TO_SCREEN,
938 * BLIT_SCREEN_TO_GMRFB, ANNOTATION_FILL, ANNOTATION_COPY
939 *
940 * New 3D commands:
941 * BLIT_SURFACE_TO_SCREEN
942 *
943 * New guarantees:
944 *
945 * - The host will not read or write guest memory, including the GFB,
946 * except when explicitly initiated by a DMA command.
947 *
948 * - All DMA, including legacy DMA like UPDATE and PRESENT_READBACK,
949 * is guaranteed to complete before any subsequent FENCEs.
950 *
951 * - All legacy commands which affect a Screen (UPDATE, PRESENT,
952 * PRESENT_READBACK) as well as new Screen blit commands will
953 * all behave consistently as blits, and memory will be read
954 * or written in FIFO order.
955 *
956 * For example, if you PRESENT from one SVGA3D surface to multiple
957 * places on the screen, the data copied will always be from the
958 * SVGA3D surface at the time the PRESENT was issued in the FIFO.
959 * This was not necessarily true on devices without Screen Object.
960 *
961 * This means that on devices that support Screen Object, the
962 * PRESENT_READBACK command should not be necessary unless you
963 * actually want to read back the results of 3D rendering into
964 * system memory. (And for that, the BLIT_SCREEN_TO_GMRFB
965 * command provides a strict superset of functionality.)
966 *
967 * - When a screen is resized, either using Screen Object commands or
968 * legacy multimon registers, its contents are preserved.
8d3713ea
JB
969 *
970 * SVGA_FIFO_CAP_GMR2 --
971 *
972 * Provides new commands to define and remap guest memory regions (GMR).
973 *
974 * New 2D commands:
975 * DEFINE_GMR2, REMAP_GMR2.
976 *
977 * SVGA_FIFO_CAP_3D_HWVERSION_REVISED --
978 *
979 * Indicates new register SVGA_FIFO_3D_HWVERSION_REVISED exists.
980 * This register may replace SVGA_FIFO_3D_HWVERSION on platforms
981 * that enforce graphics resource limits. This allows the platform
982 * to clear SVGA_FIFO_3D_HWVERSION and disable 3D in legacy guest
983 * drivers that do not limit their resources.
984 *
985 * Note this is an alias to SVGA_FIFO_CAP_GMR2 because these indicators
986 * are codependent (and thus we use a single capability bit).
987 *
988 * SVGA_FIFO_CAP_SCREEN_OBJECT_2 --
989 *
990 * Modifies the DEFINE_SCREEN command to include a guest provided
991 * backing store in GMR memory and the bytesPerLine for the backing
992 * store. This capability requires the use of a backing store when
993 * creating screen objects. However if SVGA_FIFO_CAP_SCREEN_OBJECT
994 * is present then backing stores are optional.
995 *
996 * SVGA_FIFO_CAP_DEAD --
997 *
998 * Drivers should not use this cap bit. This cap bit can not be
999 * reused since some hosts already expose it.
632f6117
JB
1000 */
1001
1002#define SVGA_FIFO_CAP_NONE 0
1003#define SVGA_FIFO_CAP_FENCE (1<<0)
1004#define SVGA_FIFO_CAP_ACCELFRONT (1<<1)
1005#define SVGA_FIFO_CAP_PITCHLOCK (1<<2)
1006#define SVGA_FIFO_CAP_VIDEO (1<<3)
1007#define SVGA_FIFO_CAP_CURSOR_BYPASS_3 (1<<4)
1008#define SVGA_FIFO_CAP_ESCAPE (1<<5)
1009#define SVGA_FIFO_CAP_RESERVE (1<<6)
1010#define SVGA_FIFO_CAP_SCREEN_OBJECT (1<<7)
8d3713ea
JB
1011#define SVGA_FIFO_CAP_GMR2 (1<<8)
1012#define SVGA_FIFO_CAP_3D_HWVERSION_REVISED SVGA_FIFO_CAP_GMR2
1013#define SVGA_FIFO_CAP_SCREEN_OBJECT_2 (1<<9)
1014#define SVGA_FIFO_CAP_DEAD (1<<10)
632f6117
JB
1015
1016
1017/*
1018 * FIFO Flags
1019 *
1020 * Accel Front -- Driver should use front buffer only commands
1021 */
1022
1023#define SVGA_FIFO_FLAG_NONE 0
1024#define SVGA_FIFO_FLAG_ACCELFRONT (1<<0)
8d3713ea 1025#define SVGA_FIFO_FLAG_RESERVED (1<<31) /* Internal use only */
632f6117
JB
1026
1027/*
1028 * FIFO reservation sentinel value
1029 */
1030
1031#define SVGA_FIFO_RESERVED_UNKNOWN 0xffffffff
1032
1033
1034/*
1035 * Video overlay support
1036 */
1037
1038#define SVGA_NUM_OVERLAY_UNITS 32
1039
1040
1041/*
1042 * Video capabilities that the guest is currently using
1043 */
1044
1045#define SVGA_VIDEO_FLAG_COLORKEY 0x0001
1046
1047
1048/*
1049 * Offsets for the video overlay registers
1050 */
1051
1052enum {
1053 SVGA_VIDEO_ENABLED = 0,
1054 SVGA_VIDEO_FLAGS,
1055 SVGA_VIDEO_DATA_OFFSET,
1056 SVGA_VIDEO_FORMAT,
1057 SVGA_VIDEO_COLORKEY,
8d3713ea 1058 SVGA_VIDEO_SIZE, /* Deprecated */
632f6117
JB
1059 SVGA_VIDEO_WIDTH,
1060 SVGA_VIDEO_HEIGHT,
1061 SVGA_VIDEO_SRC_X,
1062 SVGA_VIDEO_SRC_Y,
1063 SVGA_VIDEO_SRC_WIDTH,
1064 SVGA_VIDEO_SRC_HEIGHT,
8d3713ea
JB
1065 SVGA_VIDEO_DST_X, /* Signed int32 */
1066 SVGA_VIDEO_DST_Y, /* Signed int32 */
632f6117
JB
1067 SVGA_VIDEO_DST_WIDTH,
1068 SVGA_VIDEO_DST_HEIGHT,
1069 SVGA_VIDEO_PITCH_1,
1070 SVGA_VIDEO_PITCH_2,
1071 SVGA_VIDEO_PITCH_3,
8d3713ea
JB
1072 SVGA_VIDEO_DATA_GMRID, /* Optional, defaults to SVGA_GMR_FRAMEBUFFER */
1073 SVGA_VIDEO_DST_SCREEN_ID, /* Optional, defaults to virtual coords (SVGA_ID_INVALID) */
632f6117
JB
1074 SVGA_VIDEO_NUM_REGS
1075};
1076
1077
1078/*
1079 * SVGA Overlay Units
1080 *
1081 * width and height relate to the entire source video frame.
1082 * srcX, srcY, srcWidth and srcHeight represent subset of the source
1083 * video frame to be displayed.
1084 */
1085
1086typedef struct SVGAOverlayUnit {
1087 uint32 enabled;
1088 uint32 flags;
1089 uint32 dataOffset;
1090 uint32 format;
1091 uint32 colorKey;
1092 uint32 size;
1093 uint32 width;
1094 uint32 height;
1095 uint32 srcX;
1096 uint32 srcY;
1097 uint32 srcWidth;
1098 uint32 srcHeight;
1099 int32 dstX;
1100 int32 dstY;
1101 uint32 dstWidth;
1102 uint32 dstHeight;
1103 uint32 pitches[3];
1104 uint32 dataGMRId;
1105 uint32 dstScreenId;
1106} SVGAOverlayUnit;
1107
1108
1109/*
1110 * SVGAScreenObject --
1111 *
1112 * This is a new way to represent a guest's multi-monitor screen or
1113 * Unity window. Screen objects are only supported if the
1114 * SVGA_FIFO_CAP_SCREEN_OBJECT capability bit is set.
1115 *
1116 * If Screen Objects are supported, they can be used to fully
1117 * replace the functionality provided by the framebuffer registers
1118 * (SVGA_REG_WIDTH, HEIGHT, etc.) and by SVGA_CAP_DISPLAY_TOPOLOGY.
1119 *
1120 * The screen object is a struct with guaranteed binary
1121 * compatibility. New flags can be added, and the struct may grow,
1122 * but existing fields must retain their meaning.
1123 *
8d3713ea
JB
1124 * Added with SVGA_FIFO_CAP_SCREEN_OBJECT_2 are required fields of
1125 * a SVGAGuestPtr that is used to back the screen contents. This
1126 * memory must come from the GFB. The guest is not allowed to
1127 * access the memory and doing so will have undefined results. The
1128 * backing store is required to be page aligned and the size is
1129 * padded to the next page boundry. The number of pages is:
1130 * (bytesPerLine * size.width * 4 + PAGE_SIZE - 1) / PAGE_SIZE
1131 *
1132 * The pitch in the backingStore is required to be at least large
1133 * enough to hold a 32bbp scanline. It is recommended that the
1134 * driver pad bytesPerLine for a potential performance win.
1135 *
1136 * The cloneCount field is treated as a hint from the guest that
1137 * the user wants this display to be cloned, countCount times. A
1138 * value of zero means no cloning should happen.
632f6117
JB
1139 */
1140
8d3713ea
JB
1141#define SVGA_SCREEN_MUST_BE_SET (1 << 0) /* Must be set or results undefined */
1142#define SVGA_SCREEN_HAS_ROOT SVGA_SCREEN_MUST_BE_SET /* Deprecated */
1143#define SVGA_SCREEN_IS_PRIMARY (1 << 1) /* Guest considers this screen to be 'primary' */
1144#define SVGA_SCREEN_FULLSCREEN_HINT (1 << 2) /* Guest is running a fullscreen app here */
1145
1146/*
1147 * Added with SVGA_FIFO_CAP_SCREEN_OBJECT_2. When the screen is
1148 * deactivated the base layer is defined to lose all contents and
1149 * become black. When a screen is deactivated the backing store is
1150 * optional. When set backingPtr and bytesPerLine will be ignored.
1151 */
1152#define SVGA_SCREEN_DEACTIVATE (1 << 3)
1153
1154/*
1155 * Added with SVGA_FIFO_CAP_SCREEN_OBJECT_2. When this flag is set
1156 * the screen contents will be outputted as all black to the user
1157 * though the base layer contents is preserved. The screen base layer
1158 * can still be read and written to like normal though the no visible
1159 * effect will be seen by the user. When the flag is changed the
1160 * screen will be blanked or redrawn to the current contents as needed
1161 * without any extra commands from the driver. This flag only has an
1162 * effect when the screen is not deactivated.
1163 */
1164#define SVGA_SCREEN_BLANKING (1 << 4)
632f6117
JB
1165
1166typedef
1167struct SVGAScreenObject {
8d3713ea 1168 uint32 structSize; /* sizeof(SVGAScreenObject) */
632f6117
JB
1169 uint32 id;
1170 uint32 flags;
1171 struct {
1172 uint32 width;
1173 uint32 height;
1174 } size;
1175 struct {
1176 int32 x;
1177 int32 y;
8d3713ea
JB
1178 } root;
1179
1180 /*
1181 * Added and required by SVGA_FIFO_CAP_SCREEN_OBJECT_2, optional
1182 * with SVGA_FIFO_CAP_SCREEN_OBJECT.
1183 */
1184 SVGAGuestImage backingStore;
1185 uint32 cloneCount;
632f6117
JB
1186} SVGAScreenObject;
1187
1188
1189/*
1190 * Commands in the command FIFO:
1191 *
1192 * Command IDs defined below are used for the traditional 2D FIFO
1193 * communication (not all commands are available for all versions of the
1194 * SVGA FIFO protocol).
1195 *
1196 * Note the holes in the command ID numbers: These commands have been
1197 * deprecated, and the old IDs must not be reused.
1198 *
1199 * Command IDs from 1000 to 1999 are reserved for use by the SVGA3D
1200 * protocol.
1201 *
1202 * Each command's parameters are described by the comments and
1203 * structs below.
1204 */
1205
1206typedef enum {
1207 SVGA_CMD_INVALID_CMD = 0,
1208 SVGA_CMD_UPDATE = 1,
1209 SVGA_CMD_RECT_COPY = 3,
1210 SVGA_CMD_DEFINE_CURSOR = 19,
1211 SVGA_CMD_DEFINE_ALPHA_CURSOR = 22,
1212 SVGA_CMD_UPDATE_VERBOSE = 25,
1213 SVGA_CMD_FRONT_ROP_FILL = 29,
1214 SVGA_CMD_FENCE = 30,
1215 SVGA_CMD_ESCAPE = 33,
1216 SVGA_CMD_DEFINE_SCREEN = 34,
1217 SVGA_CMD_DESTROY_SCREEN = 35,
1218 SVGA_CMD_DEFINE_GMRFB = 36,
1219 SVGA_CMD_BLIT_GMRFB_TO_SCREEN = 37,
1220 SVGA_CMD_BLIT_SCREEN_TO_GMRFB = 38,
1221 SVGA_CMD_ANNOTATION_FILL = 39,
1222 SVGA_CMD_ANNOTATION_COPY = 40,
dcca2862
TH
1223 SVGA_CMD_DEFINE_GMR2 = 41,
1224 SVGA_CMD_REMAP_GMR2 = 42,
632f6117
JB
1225 SVGA_CMD_MAX
1226} SVGAFifoCmdId;
1227
1228#define SVGA_CMD_MAX_ARGS 64
1229
1230
1231/*
1232 * SVGA_CMD_UPDATE --
1233 *
1234 * This is a DMA transfer which copies from the Guest Framebuffer
1235 * (GFB) at BAR1 + SVGA_REG_FB_OFFSET to any screens which
1236 * intersect with the provided virtual rectangle.
1237 *
1238 * This command does not support using arbitrary guest memory as a
1239 * data source- it only works with the pre-defined GFB memory.
1240 * This command also does not support signed virtual coordinates.
1241 * If you have defined screens (using SVGA_CMD_DEFINE_SCREEN) with
1242 * negative root x/y coordinates, the negative portion of those
1243 * screens will not be reachable by this command.
1244 *
1245 * This command is not necessary when using framebuffer
1246 * traces. Traces are automatically enabled if the SVGA FIFO is
1247 * disabled, and you may explicitly enable/disable traces using
1248 * SVGA_REG_TRACES. With traces enabled, any write to the GFB will
1249 * automatically act as if a subsequent SVGA_CMD_UPDATE was issued.
1250 *
1251 * Traces and SVGA_CMD_UPDATE are the only supported ways to render
1252 * pseudocolor screen updates. The newer Screen Object commands
1253 * only support true color formats.
1254 *
1255 * Availability:
1256 * Always available.
1257 */
1258
1259typedef
8d3713ea 1260struct SVGAFifoCmdUpdate {
632f6117
JB
1261 uint32 x;
1262 uint32 y;
1263 uint32 width;
1264 uint32 height;
1265} SVGAFifoCmdUpdate;
1266
1267
1268/*
1269 * SVGA_CMD_RECT_COPY --
1270 *
1271 * Perform a rectangular DMA transfer from one area of the GFB to
1272 * another, and copy the result to any screens which intersect it.
1273 *
1274 * Availability:
1275 * SVGA_CAP_RECT_COPY
1276 */
1277
1278typedef
8d3713ea 1279struct SVGAFifoCmdRectCopy {
632f6117
JB
1280 uint32 srcX;
1281 uint32 srcY;
1282 uint32 destX;
1283 uint32 destY;
1284 uint32 width;
1285 uint32 height;
1286} SVGAFifoCmdRectCopy;
1287
1288
1289/*
1290 * SVGA_CMD_DEFINE_CURSOR --
1291 *
1292 * Provide a new cursor image, as an AND/XOR mask.
1293 *
1294 * The recommended way to position the cursor overlay is by using
1295 * the SVGA_FIFO_CURSOR_* registers, supported by the
1296 * SVGA_FIFO_CAP_CURSOR_BYPASS_3 capability.
1297 *
1298 * Availability:
1299 * SVGA_CAP_CURSOR
1300 */
1301
1302typedef
8d3713ea
JB
1303struct SVGAFifoCmdDefineCursor {
1304 uint32 id; /* Reserved, must be zero. */
632f6117
JB
1305 uint32 hotspotX;
1306 uint32 hotspotY;
1307 uint32 width;
1308 uint32 height;
8d3713ea
JB
1309 uint32 andMaskDepth; /* Value must be 1 or equal to BITS_PER_PIXEL */
1310 uint32 xorMaskDepth; /* Value must be 1 or equal to BITS_PER_PIXEL */
632f6117
JB
1311 /*
1312 * Followed by scanline data for AND mask, then XOR mask.
1313 * Each scanline is padded to a 32-bit boundary.
1314 */
1315} SVGAFifoCmdDefineCursor;
1316
1317
1318/*
1319 * SVGA_CMD_DEFINE_ALPHA_CURSOR --
1320 *
1321 * Provide a new cursor image, in 32-bit BGRA format.
1322 *
1323 * The recommended way to position the cursor overlay is by using
1324 * the SVGA_FIFO_CURSOR_* registers, supported by the
1325 * SVGA_FIFO_CAP_CURSOR_BYPASS_3 capability.
1326 *
1327 * Availability:
1328 * SVGA_CAP_ALPHA_CURSOR
1329 */
1330
1331typedef
8d3713ea
JB
1332struct SVGAFifoCmdDefineAlphaCursor {
1333 uint32 id; /* Reserved, must be zero. */
632f6117
JB
1334 uint32 hotspotX;
1335 uint32 hotspotY;
1336 uint32 width;
1337 uint32 height;
1338 /* Followed by scanline data */
1339} SVGAFifoCmdDefineAlphaCursor;
1340
1341
1342/*
1343 * SVGA_CMD_UPDATE_VERBOSE --
1344 *
1345 * Just like SVGA_CMD_UPDATE, but also provide a per-rectangle
1346 * 'reason' value, an opaque cookie which is used by internal
1347 * debugging tools. Third party drivers should not use this
1348 * command.
1349 *
1350 * Availability:
1351 * SVGA_CAP_EXTENDED_FIFO
1352 */
1353
1354typedef
8d3713ea 1355struct SVGAFifoCmdUpdateVerbose {
632f6117
JB
1356 uint32 x;
1357 uint32 y;
1358 uint32 width;
1359 uint32 height;
1360 uint32 reason;
1361} SVGAFifoCmdUpdateVerbose;
1362
1363
1364/*
1365 * SVGA_CMD_FRONT_ROP_FILL --
1366 *
1367 * This is a hint which tells the SVGA device that the driver has
1368 * just filled a rectangular region of the GFB with a solid
1369 * color. Instead of reading these pixels from the GFB, the device
1370 * can assume that they all equal 'color'. This is primarily used
1371 * for remote desktop protocols.
1372 *
1373 * Availability:
1374 * SVGA_FIFO_CAP_ACCELFRONT
1375 */
1376
1377#define SVGA_ROP_COPY 0x03
1378
1379typedef
8d3713ea
JB
1380struct SVGAFifoCmdFrontRopFill {
1381 uint32 color; /* In the same format as the GFB */
632f6117
JB
1382 uint32 x;
1383 uint32 y;
1384 uint32 width;
1385 uint32 height;
8d3713ea 1386 uint32 rop; /* Must be SVGA_ROP_COPY */
632f6117
JB
1387} SVGAFifoCmdFrontRopFill;
1388
1389
1390/*
1391 * SVGA_CMD_FENCE --
1392 *
1393 * Insert a synchronization fence. When the SVGA device reaches
1394 * this command, it will copy the 'fence' value into the
1395 * SVGA_FIFO_FENCE register. It will also compare the fence against
1396 * SVGA_FIFO_FENCE_GOAL. If the fence matches the goal and the
1397 * SVGA_IRQFLAG_FENCE_GOAL interrupt is enabled, the device will
1398 * raise this interrupt.
1399 *
1400 * Availability:
1401 * SVGA_FIFO_FENCE for this command,
1402 * SVGA_CAP_IRQMASK for SVGA_FIFO_FENCE_GOAL.
1403 */
1404
1405typedef
1406struct {
1407 uint32 fence;
1408} SVGAFifoCmdFence;
1409
1410
1411/*
1412 * SVGA_CMD_ESCAPE --
1413 *
1414 * Send an extended or vendor-specific variable length command.
1415 * This is used for video overlay, third party plugins, and
1416 * internal debugging tools. See svga_escape.h
1417 *
1418 * Availability:
1419 * SVGA_FIFO_CAP_ESCAPE
1420 */
1421
1422typedef
8d3713ea 1423struct SVGAFifoCmdEscape {
632f6117
JB
1424 uint32 nsid;
1425 uint32 size;
1426 /* followed by 'size' bytes of data */
1427} SVGAFifoCmdEscape;
1428
1429
1430/*
1431 * SVGA_CMD_DEFINE_SCREEN --
1432 *
1433 * Define or redefine an SVGAScreenObject. See the description of
1434 * SVGAScreenObject above. The video driver is responsible for
1435 * generating new screen IDs. They should be small positive
1436 * integers. The virtual device will have an implementation
1437 * specific upper limit on the number of screen IDs
1438 * supported. Drivers are responsible for recycling IDs. The first
1439 * valid ID is zero.
1440 *
1441 * - Interaction with other registers:
1442 *
1443 * For backwards compatibility, when the GFB mode registers (WIDTH,
1444 * HEIGHT, PITCHLOCK, BITS_PER_PIXEL) are modified, the SVGA device
1445 * deletes all screens other than screen #0, and redefines screen
1446 * #0 according to the specified mode. Drivers that use
1447 * SVGA_CMD_DEFINE_SCREEN should destroy or redefine screen #0.
1448 *
1449 * If you use screen objects, do not use the legacy multi-mon
1450 * registers (SVGA_REG_NUM_GUEST_DISPLAYS, SVGA_REG_DISPLAY_*).
1451 *
1452 * Availability:
8d3713ea 1453 * SVGA_FIFO_CAP_SCREEN_OBJECT or SVGA_FIFO_CAP_SCREEN_OBJECT_2
632f6117
JB
1454 */
1455
1456typedef
1457struct {
8d3713ea 1458 SVGAScreenObject screen; /* Variable-length according to version */
632f6117
JB
1459} SVGAFifoCmdDefineScreen;
1460
1461
1462/*
1463 * SVGA_CMD_DESTROY_SCREEN --
1464 *
1465 * Destroy an SVGAScreenObject. Its ID is immediately available for
1466 * re-use.
1467 *
1468 * Availability:
8d3713ea 1469 * SVGA_FIFO_CAP_SCREEN_OBJECT or SVGA_FIFO_CAP_SCREEN_OBJECT_2
632f6117
JB
1470 */
1471
1472typedef
1473struct {
1474 uint32 screenId;
1475} SVGAFifoCmdDestroyScreen;
1476
1477
1478/*
1479 * SVGA_CMD_DEFINE_GMRFB --
1480 *
1481 * This command sets a piece of SVGA device state called the
1482 * Guest Memory Region Framebuffer, or GMRFB. The GMRFB is a
1483 * piece of light-weight state which identifies the location and
1484 * format of an image in guest memory or in BAR1. The GMRFB has
1485 * an arbitrary size, and it doesn't need to match the geometry
1486 * of the GFB or any screen object.
1487 *
1488 * The GMRFB can be redefined as often as you like. You could
1489 * always use the same GMRFB, you could redefine it before
1490 * rendering from a different guest screen, or you could even
1491 * redefine it before every blit.
1492 *
1493 * There are multiple ways to use this command. The simplest way is
1494 * to use it to move the framebuffer either to elsewhere in the GFB
1495 * (BAR1) memory region, or to a user-defined GMR. This lets a
1496 * driver use a framebuffer allocated entirely out of normal system
1497 * memory, which we encourage.
1498 *
1499 * Another way to use this command is to set up a ring buffer of
1500 * updates in GFB memory. If a driver wants to ensure that no
1501 * frames are skipped by the SVGA device, it is important that the
1502 * driver not modify the source data for a blit until the device is
1503 * done processing the command. One efficient way to accomplish
1504 * this is to use a ring of small DMA buffers. Each buffer is used
1505 * for one blit, then we move on to the next buffer in the
1506 * ring. The FENCE mechanism is used to protect each buffer from
1507 * re-use until the device is finished with that buffer's
1508 * corresponding blit.
1509 *
1510 * This command does not affect the meaning of SVGA_CMD_UPDATE.
1511 * UPDATEs always occur from the legacy GFB memory area. This
1512 * command has no support for pseudocolor GMRFBs. Currently only
1513 * true-color 15, 16, and 24-bit depths are supported. Future
1514 * devices may expose capabilities for additional framebuffer
1515 * formats.
1516 *
1517 * The default GMRFB value is undefined. Drivers must always send
1518 * this command at least once before performing any blit from the
1519 * GMRFB.
1520 *
1521 * Availability:
8d3713ea 1522 * SVGA_FIFO_CAP_SCREEN_OBJECT or SVGA_FIFO_CAP_SCREEN_OBJECT_2
632f6117
JB
1523 */
1524
1525typedef
1526struct {
1527 SVGAGuestPtr ptr;
1528 uint32 bytesPerLine;
1529 SVGAGMRImageFormat format;
1530} SVGAFifoCmdDefineGMRFB;
1531
1532
1533/*
1534 * SVGA_CMD_BLIT_GMRFB_TO_SCREEN --
1535 *
1536 * This is a guest-to-host blit. It performs a DMA operation to
1537 * copy a rectangular region of pixels from the current GMRFB to
1538 * one or more Screen Objects.
1539 *
1540 * The destination coordinate may be specified relative to a
1541 * screen's origin (if a screen ID is specified) or relative to the
1542 * virtual coordinate system's origin (if the screen ID is
1543 * SVGA_ID_INVALID). The actual destination may span zero or more
1544 * screens, in the case of a virtual destination rect or a rect
1545 * which extends off the edge of the specified screen.
1546 *
1547 * This command writes to the screen's "base layer": the underlying
1548 * framebuffer which exists below any cursor or video overlays. No
1549 * action is necessary to explicitly hide or update any overlays
1550 * which exist on top of the updated region.
1551 *
1552 * The SVGA device is guaranteed to finish reading from the GMRFB
1553 * by the time any subsequent FENCE commands are reached.
1554 *
1555 * This command consumes an annotation. See the
1556 * SVGA_CMD_ANNOTATION_* commands for details.
1557 *
1558 * Availability:
8d3713ea 1559 * SVGA_FIFO_CAP_SCREEN_OBJECT or SVGA_FIFO_CAP_SCREEN_OBJECT_2
632f6117
JB
1560 */
1561
1562typedef
1563struct {
1564 SVGASignedPoint srcOrigin;
1565 SVGASignedRect destRect;
1566 uint32 destScreenId;
1567} SVGAFifoCmdBlitGMRFBToScreen;
1568
1569
1570/*
1571 * SVGA_CMD_BLIT_SCREEN_TO_GMRFB --
1572 *
1573 * This is a host-to-guest blit. It performs a DMA operation to
1574 * copy a rectangular region of pixels from a single Screen Object
1575 * back to the current GMRFB.
1576 *
1577 * Usage note: This command should be used rarely. It will
1578 * typically be inefficient, but it is necessary for some types of
1579 * synchronization between 3D (GPU) and 2D (CPU) rendering into
1580 * overlapping areas of a screen.
1581 *
1582 * The source coordinate is specified relative to a screen's
1583 * origin. The provided screen ID must be valid. If any parameters
1584 * are invalid, the resulting pixel values are undefined.
1585 *
1586 * This command reads the screen's "base layer". Overlays like
1587 * video and cursor are not included, but any data which was sent
1588 * using a blit-to-screen primitive will be available, no matter
1589 * whether the data's original source was the GMRFB or the 3D
1590 * acceleration hardware.
1591 *
1592 * Note that our guest-to-host blits and host-to-guest blits aren't
1593 * symmetric in their current implementation. While the parameters
1594 * are identical, host-to-guest blits are a lot less featureful.
1595 * They do not support clipping: If the source parameters don't
1596 * fully fit within a screen, the blit fails. They must originate
1597 * from exactly one screen. Virtual coordinates are not directly
1598 * supported.
1599 *
1600 * Host-to-guest blits do support the same set of GMRFB formats
1601 * offered by guest-to-host blits.
1602 *
1603 * The SVGA device is guaranteed to finish writing to the GMRFB by
1604 * the time any subsequent FENCE commands are reached.
1605 *
1606 * Availability:
8d3713ea 1607 * SVGA_FIFO_CAP_SCREEN_OBJECT or SVGA_FIFO_CAP_SCREEN_OBJECT_2
632f6117
JB
1608 */
1609
1610typedef
1611struct {
1612 SVGASignedPoint destOrigin;
1613 SVGASignedRect srcRect;
1614 uint32 srcScreenId;
1615} SVGAFifoCmdBlitScreenToGMRFB;
1616
1617
1618/*
1619 * SVGA_CMD_ANNOTATION_FILL --
1620 *
1621 * This is a blit annotation. This command stores a small piece of
1622 * device state which is consumed by the next blit-to-screen
1623 * command. The state is only cleared by commands which are
1624 * specifically documented as consuming an annotation. Other
1625 * commands (such as ESCAPEs for debugging) may intervene between
1626 * the annotation and its associated blit.
1627 *
1628 * This annotation is a promise about the contents of the next
1629 * blit: The video driver is guaranteeing that all pixels in that
1630 * blit will have the same value, specified here as a color in
1631 * SVGAColorBGRX format.
1632 *
1633 * The SVGA device can still render the blit correctly even if it
1634 * ignores this annotation, but the annotation may allow it to
1635 * perform the blit more efficiently, for example by ignoring the
1636 * source data and performing a fill in hardware.
1637 *
1638 * This annotation is most important for performance when the
1639 * user's display is being remoted over a network connection.
1640 *
1641 * Availability:
8d3713ea 1642 * SVGA_FIFO_CAP_SCREEN_OBJECT or SVGA_FIFO_CAP_SCREEN_OBJECT_2
632f6117
JB
1643 */
1644
1645typedef
1646struct {
1647 SVGAColorBGRX color;
1648} SVGAFifoCmdAnnotationFill;
1649
1650
1651/*
1652 * SVGA_CMD_ANNOTATION_COPY --
1653 *
1654 * This is a blit annotation. See SVGA_CMD_ANNOTATION_FILL for more
1655 * information about annotations.
1656 *
1657 * This annotation is a promise about the contents of the next
1658 * blit: The video driver is guaranteeing that all pixels in that
1659 * blit will have the same value as those which already exist at an
1660 * identically-sized region on the same or a different screen.
1661 *
1662 * Note that the source pixels for the COPY in this annotation are
1663 * sampled before applying the anqnotation's associated blit. They
1664 * are allowed to overlap with the blit's destination pixels.
1665 *
1666 * The copy source rectangle is specified the same way as the blit
1667 * destination: it can be a rectangle which spans zero or more
1668 * screens, specified relative to either a screen or to the virtual
1669 * coordinate system's origin. If the source rectangle includes
1670 * pixels which are not from exactly one screen, the results are
1671 * undefined.
1672 *
1673 * Availability:
8d3713ea 1674 * SVGA_FIFO_CAP_SCREEN_OBJECT or SVGA_FIFO_CAP_SCREEN_OBJECT_2
632f6117
JB
1675 */
1676
1677typedef
1678struct {
1679 SVGASignedPoint srcOrigin;
1680 uint32 srcScreenId;
1681} SVGAFifoCmdAnnotationCopy;
1682
dcca2862
TH
1683
1684/*
1685 * SVGA_CMD_DEFINE_GMR2 --
1686 *
1687 * Define guest memory region v2. See the description of GMRs above.
1688 *
1689 * Availability:
1690 * SVGA_CAP_GMR2
1691 */
1692
1693typedef
1694struct {
1695 uint32 gmrId;
1696 uint32 numPages;
8d3713ea 1697} SVGAFifoCmdDefineGMR2;
dcca2862
TH
1698
1699
1700/*
1701 * SVGA_CMD_REMAP_GMR2 --
1702 *
1703 * Remap guest memory region v2. See the description of GMRs above.
1704 *
1705 * This command allows guest to modify a portion of an existing GMR by
1706 * invalidating it or reassigning it to different guest physical pages.
1707 * The pages are identified by physical page number (PPN). The pages
1708 * are assumed to be pinned and valid for DMA operations.
1709 *
1710 * Description of command flags:
1711 *
1712 * SVGA_REMAP_GMR2_VIA_GMR: If enabled, references a PPN list in a GMR.
1713 * The PPN list must not overlap with the remap region (this can be
1714 * handled trivially by referencing a separate GMR). If flag is
1715 * disabled, PPN list is appended to SVGARemapGMR command.
1716 *
1717 * SVGA_REMAP_GMR2_PPN64: If set, PPN list is in PPN64 format, otherwise
1718 * it is in PPN32 format.
1719 *
1720 * SVGA_REMAP_GMR2_SINGLE_PPN: If set, PPN list contains a single entry.
1721 * A single PPN can be used to invalidate a portion of a GMR or
1722 * map it to to a single guest scratch page.
1723 *
1724 * Availability:
1725 * SVGA_CAP_GMR2
1726 */
1727
1728typedef enum {
1729 SVGA_REMAP_GMR2_PPN32 = 0,
1730 SVGA_REMAP_GMR2_VIA_GMR = (1 << 0),
1731 SVGA_REMAP_GMR2_PPN64 = (1 << 1),
1732 SVGA_REMAP_GMR2_SINGLE_PPN = (1 << 2),
1733} SVGARemapGMR2Flags;
1734
1735typedef
1736struct {
1737 uint32 gmrId;
1738 SVGARemapGMR2Flags flags;
8d3713ea
JB
1739 uint32 offsetPages; /* offset in pages to begin remap */
1740 uint32 numPages; /* number of pages to remap */
dcca2862
TH
1741 /*
1742 * Followed by additional data depending on SVGARemapGMR2Flags.
1743 *
1744 * If flag SVGA_REMAP_GMR2_VIA_GMR is set, single SVGAGuestPtr follows.
1745 * Otherwise an array of page descriptors in PPN32 or PPN64 format
1746 * (according to flag SVGA_REMAP_GMR2_PPN64) follows. If flag
1747 * SVGA_REMAP_GMR2_SINGLE_PPN is set, array contains a single entry.
1748 */
8d3713ea 1749} SVGAFifoCmdRemapGMR2;
dcca2862 1750
632f6117 1751#endif