1 /* SPDX-License-Identifier: GPL-2.0 OR MIT */
2 /**********************************************************
3  * Copyright 1998-2021 VMware, Inc.
4  *
5  * Permission is hereby granted, free of charge, to any person
6  * obtaining a copy of this software and associated documentation
7  * files (the "Software"), to deal in the Software without
8  * restriction, including without limitation the rights to use, copy,
9  * modify, merge, publish, distribute, sublicense, and/or sell copies
10  * of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be
14  * included in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
20  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23  * SOFTWARE.
24  *
25  **********************************************************/
26 
27 /*
28  * svga_reg.h --
29  *
30  *    Virtual hardware definitions for the VMware SVGA II device.
31  */
32 
33 #ifndef _SVGA_REG_H_
34 #define _SVGA_REG_H_
35 #include <linux/pci_ids.h>
36 
37 #define INCLUDE_ALLOW_MODULE
38 #define INCLUDE_ALLOW_USERLEVEL
39 
40 #define INCLUDE_ALLOW_VMCORE
41 #include "includeCheck.h"
42 
43 #include "svga_types.h"
44 
45 /*
46  * SVGA_REG_ENABLE bit definitions.
47  */
48 typedef enum {
49    SVGA_REG_ENABLE_DISABLE = 0,
50    SVGA_REG_ENABLE_ENABLE = (1 << 0),
51    SVGA_REG_ENABLE_HIDE = (1 << 1),
52 } SvgaRegEnable;
53 
54 typedef uint32 SVGAMobId;
55 
56 /*
57  * Arbitrary and meaningless limits. Please ignore these when writing
58  * new drivers.
59  */
60 #define SVGA_MAX_WIDTH                  2560
61 #define SVGA_MAX_HEIGHT                 1600
62 
63 
64 #define SVGA_MAX_BITS_PER_PIXEL         32
65 #define SVGA_MAX_DEPTH                  24
66 #define SVGA_MAX_DISPLAYS               10
67 #define SVGA_MAX_SCREEN_SIZE            8192
68 #define SVGA_SCREEN_ROOT_LIMIT (SVGA_MAX_SCREEN_SIZE * SVGA_MAX_DISPLAYS)
69 
70 
71 /*
72  * Legal values for the SVGA_REG_CURSOR_ON register in old-fashioned
73  * cursor bypass mode.
74  */
75 #define SVGA_CURSOR_ON_HIDE            0x0
76 #define SVGA_CURSOR_ON_SHOW            0x1
77 
78 /*
79  * Remove the cursor from the framebuffer
80  * because we need to see what's under it
81  */
82 #define SVGA_CURSOR_ON_REMOVE_FROM_FB  0x2
83 
84 /* Put the cursor back in the framebuffer so the user can see it */
85 #define SVGA_CURSOR_ON_RESTORE_TO_FB   0x3
86 
87 /*
88  * The maximum framebuffer size that can traced for guests unless the
89  * SVGA_CAP_GBOBJECTS is set in SVGA_REG_CAPABILITIES.  In that case
90  * the full framebuffer can be traced independent of this limit.
91  */
92 #define SVGA_FB_MAX_TRACEABLE_SIZE      0x1000000
93 
94 #define SVGA_MAX_PSEUDOCOLOR_DEPTH      8
95 #define SVGA_MAX_PSEUDOCOLORS           (1 << SVGA_MAX_PSEUDOCOLOR_DEPTH)
96 #define SVGA_NUM_PALETTE_REGS           (3 * SVGA_MAX_PSEUDOCOLORS)
97 
98 #define SVGA_MAGIC         0x900000UL
99 #define SVGA_MAKE_ID(ver)  (SVGA_MAGIC << 8 | (ver))
100 
101 /* Version 3 has the control bar instead of the FIFO */
102 #define SVGA_VERSION_3     3
103 #define SVGA_ID_3          SVGA_MAKE_ID(SVGA_VERSION_3)
104 
105 /* Version 2 let the address of the frame buffer be unsigned on Win32 */
106 #define SVGA_VERSION_2     2
107 #define SVGA_ID_2          SVGA_MAKE_ID(SVGA_VERSION_2)
108 
109 /* Version 1 has new registers starting with SVGA_REG_CAPABILITIES so
110    PALETTE_BASE has moved */
111 #define SVGA_VERSION_1     1
112 #define SVGA_ID_1          SVGA_MAKE_ID(SVGA_VERSION_1)
113 
114 /* Version 0 is the initial version */
115 #define SVGA_VERSION_0     0
116 #define SVGA_ID_0          SVGA_MAKE_ID(SVGA_VERSION_0)
117 
118 /*
119  * "Invalid" value for all SVGA IDs.
120  * (Version ID, screen object ID, surface ID...)
121  */
122 #define SVGA_ID_INVALID    0xFFFFFFFF
123 
124 /* Port offsets, relative to BAR0 */
125 #define SVGA_INDEX_PORT         0x0
126 #define SVGA_VALUE_PORT         0x1
127 #define SVGA_BIOS_PORT          0x2
128 #define SVGA_IRQSTATUS_PORT     0x8
129 
130 /*
131  * Interrupt source flags for IRQSTATUS_PORT and IRQMASK.
132  *
133  * Interrupts are only supported when the
134  * SVGA_CAP_IRQMASK capability is present.
135  */
136 #define SVGA_IRQFLAG_ANY_FENCE            (1 << 0) /* Any fence was passed */
137 #define SVGA_IRQFLAG_FIFO_PROGRESS        (1 << 1) /* Made forward progress in the FIFO */
138 #define SVGA_IRQFLAG_FENCE_GOAL           (1 << 2) /* SVGA_FIFO_FENCE_GOAL reached */
139 #define SVGA_IRQFLAG_COMMAND_BUFFER       (1 << 3) /* Command buffer completed */
140 #define SVGA_IRQFLAG_ERROR                (1 << 4) /* Error while processing commands */
141 #define SVGA_IRQFLAG_MAX                  (1 << 5)
142 
143 /*
144  * The byte-size is the size of the actual cursor data,
145  * possibly after expanding it to the current bit depth.
146  *
147  * 40K is sufficient memory for two 32-bit planes for a 64 x 64 cursor.
148  *
149  * The dimension limit is a bound on the maximum width or height.
150  */
151 #define SVGA_MAX_CURSOR_CMD_BYTES  (40 * 1024)
152 #define SVGA_MAX_CURSOR_CMD_DIMENSION 1024
153 
154 /*
155  * Registers
156  */
157 
158 enum {
159    SVGA_REG_ID = 0,
160    SVGA_REG_ENABLE = 1,
161    SVGA_REG_WIDTH = 2,
162    SVGA_REG_HEIGHT = 3,
163    SVGA_REG_MAX_WIDTH = 4,
164    SVGA_REG_MAX_HEIGHT = 5,
165    SVGA_REG_DEPTH = 6,
166    SVGA_REG_BITS_PER_PIXEL = 7,       /* Current bpp in the guest */
167    SVGA_REG_PSEUDOCOLOR = 8,
168    SVGA_REG_RED_MASK = 9,
169    SVGA_REG_GREEN_MASK = 10,
170    SVGA_REG_BLUE_MASK = 11,
171    SVGA_REG_BYTES_PER_LINE = 12,
172    SVGA_REG_FB_START = 13,            /* (Deprecated) */
173    SVGA_REG_FB_OFFSET = 14,
174    SVGA_REG_VRAM_SIZE = 15,
175    SVGA_REG_FB_SIZE = 16,
176 
177    /* ID 0 implementation only had the above registers, then the palette */
178    SVGA_REG_ID_0_TOP = 17,
179 
180    SVGA_REG_CAPABILITIES = 17,
181    SVGA_REG_MEM_START = 18,           /* (Deprecated) */
182    SVGA_REG_MEM_SIZE = 19,
183    SVGA_REG_CONFIG_DONE = 20,         /* Set when memory area configured */
184    SVGA_REG_SYNC = 21,                /* See "FIFO Synchronization Registers" */
185    SVGA_REG_BUSY = 22,                /* See "FIFO Synchronization Registers" */
186    SVGA_REG_GUEST_ID = 23,            /* (Deprecated) */
187    SVGA_REG_DEAD = 24,                /* Drivers should never write this. */
188    SVGA_REG_CURSOR_X = 25,            /* (Deprecated) */
189    SVGA_REG_CURSOR_Y = 26,            /* (Deprecated) */
190    SVGA_REG_CURSOR_ON = 27,           /* (Deprecated) */
191    SVGA_REG_HOST_BITS_PER_PIXEL = 28, /* (Deprecated) */
192    SVGA_REG_SCRATCH_SIZE = 29,        /* Number of scratch registers */
193    SVGA_REG_MEM_REGS = 30,            /* Number of FIFO registers */
194    SVGA_REG_NUM_DISPLAYS = 31,        /* (Deprecated) */
195    SVGA_REG_PITCHLOCK = 32,           /* Fixed pitch for all modes */
196    SVGA_REG_IRQMASK = 33,             /* Interrupt mask */
197 
198    /* Legacy multi-monitor support */
199    SVGA_REG_NUM_GUEST_DISPLAYS = 34,/* Number of guest displays in X/Y direction */
200    SVGA_REG_DISPLAY_ID = 35,        /* Display ID for the following display attributes */
201    SVGA_REG_DISPLAY_IS_PRIMARY = 36,/* Whether this is a primary display */
202    SVGA_REG_DISPLAY_POSITION_X = 37,/* The display position x */
203    SVGA_REG_DISPLAY_POSITION_Y = 38,/* The display position y */
204    SVGA_REG_DISPLAY_WIDTH = 39,     /* The display's width */
205    SVGA_REG_DISPLAY_HEIGHT = 40,    /* The display's height */
206 
207    /* See "Guest memory regions" below. */
208    SVGA_REG_GMR_ID = 41,
209    SVGA_REG_GMR_DESCRIPTOR = 42,
210    SVGA_REG_GMR_MAX_IDS = 43,
211    SVGA_REG_GMR_MAX_DESCRIPTOR_LENGTH = 44,
212 
213    SVGA_REG_TRACES = 45,            /* Enable trace-based updates even when FIFO is on */
214    SVGA_REG_GMRS_MAX_PAGES = 46,    /* Maximum number of 4KB pages for all GMRs */
215    SVGA_REG_MEMORY_SIZE = 47,       /* Total dedicated device memory excluding FIFO */
216    SVGA_REG_COMMAND_LOW = 48,       /* Lower 32 bits and submits commands */
217    SVGA_REG_COMMAND_HIGH = 49,      /* Upper 32 bits of command buffer PA */
218 
219    /*
220     * Max primary memory.
221     * See SVGA_CAP_NO_BB_RESTRICTION.
222     */
223    SVGA_REG_MAX_PRIMARY_MEM = 50,
224    SVGA_REG_MAX_PRIMARY_BOUNDING_BOX_MEM = 50,
225 
226    /*
227     * Legacy version of SVGA_REG_GBOBJECT_MEM_SIZE_KB for drivers that
228     * don't know how to convert to a 64-bit byte value without overflowing.
229     * (See SVGA_REG_GBOBJECT_MEM_SIZE_KB).
230     */
231    SVGA_REG_SUGGESTED_GBOBJECT_MEM_SIZE_KB = 51,
232 
233    SVGA_REG_DEV_CAP = 52,           /* Write dev cap index, read value */
234    SVGA_REG_CMD_PREPEND_LOW = 53,
235    SVGA_REG_CMD_PREPEND_HIGH = 54,
236    SVGA_REG_SCREENTARGET_MAX_WIDTH = 55,
237    SVGA_REG_SCREENTARGET_MAX_HEIGHT = 56,
238    SVGA_REG_MOB_MAX_SIZE = 57,
239    SVGA_REG_BLANK_SCREEN_TARGETS = 58,
240    SVGA_REG_CAP2 = 59,
241    SVGA_REG_DEVEL_CAP = 60,
242 
243    /*
244     * Allow the guest to hint to the device which driver is running.
245     *
246     * This should not generally change device behavior, but might be
247     * convenient to work-around specific bugs in guest drivers.
248     *
249     * Drivers should first write their id value into SVGA_REG_GUEST_DRIVER_ID,
250     * and then fill out all of the version registers that they have defined.
251     *
252     * After the driver has written all of the registers, they should
253     * then write the value SVGA_REG_GUEST_DRIVER_ID_SUBMIT to the
254     * SVGA_REG_GUEST_DRIVER_ID register, to signal that they have finished.
255     *
256     * The SVGA_REG_GUEST_DRIVER_ID values are defined below by the
257     * SVGARegGuestDriverId enum.
258     *
259     * The SVGA_REG_GUEST_DRIVER_VERSION fields are driver-specific,
260     * but ideally should encode a monotonically increasing number that allows
261     * the device to perform inequality checks against ranges of driver versions.
262     */
263    SVGA_REG_GUEST_DRIVER_ID = 61,
264    SVGA_REG_GUEST_DRIVER_VERSION1 = 62,
265    SVGA_REG_GUEST_DRIVER_VERSION2 = 63,
266    SVGA_REG_GUEST_DRIVER_VERSION3 = 64,
267    SVGA_REG_CURSOR_MOBID = 65,
268    SVGA_REG_CURSOR_MAX_BYTE_SIZE = 66,
269    SVGA_REG_CURSOR_MAX_DIMENSION = 67,
270 
271    SVGA_REG_FIFO_CAPS = 68,
272    SVGA_REG_FENCE = 69,
273 
274    SVGA_REG_RESERVED1 = 70,
275    SVGA_REG_RESERVED2 = 71,
276    SVGA_REG_RESERVED3 = 72,
277    SVGA_REG_RESERVED4 = 73,
278    SVGA_REG_RESERVED5 = 74,
279    SVGA_REG_SCREENDMA = 75,
280 
281    /*
282     * The maximum amount of guest-backed objects that the device can have
283     * resident at a time. Guest-drivers should keep their working set size
284     * below this limit for best performance.
285     *
286     * Note that this value is in kilobytes, and not bytes, because the actual
287     * number of bytes might be larger than can fit in a 32-bit register.
288     *
289     * PLEASE USE A 64-BIT VALUE WHEN CONVERTING THIS INTO BYTES.
290     * (See SVGA_REG_SUGGESTED_GBOBJECT_MEM_SIZE_KB).
291     */
292    SVGA_REG_GBOBJECT_MEM_SIZE_KB = 76,
293 
294    /*
295     +    * These registers are for the addresses of the memory BARs for SVGA3
296     */
297    SVGA_REG_REGS_START_HIGH32 = 77,
298    SVGA_REG_REGS_START_LOW32 = 78,
299    SVGA_REG_FB_START_HIGH32 = 79,
300    SVGA_REG_FB_START_LOW32 = 80,
301 
302    /*
303     * A hint register that recommends which quality level the guest should
304     * currently use to define multisample surfaces.
305     *
306     * If the register is SVGA_REG_MSHINT_DISABLED,
307     * the guest is only allowed to use SVGA3D_MS_QUALITY_FULL.
308     *
309     * Otherwise, this is a live value that can change while the VM is
310     * powered on with the hint suggestion for which quality level the guest
311     * should be using.  Guests are free to ignore the hint and use either
312     * RESOLVE or FULL quality.
313     */
314    SVGA_REG_MSHINT = 81,
315 
316    SVGA_REG_IRQ_STATUS = 82,
317    SVGA_REG_DIRTY_TRACKING = 83,
318 
319    SVGA_REG_TOP = 84,               /* Must be 1 more than the last register */
320 
321    SVGA_PALETTE_BASE = 1024,        /* Base of SVGA color map */
322    /* Next 768 (== 256*3) registers exist for colormap */
323    SVGA_SCRATCH_BASE = SVGA_PALETTE_BASE + SVGA_NUM_PALETTE_REGS
324                                     /* Base of scratch registers */
325    /* Next reg[SVGA_REG_SCRATCH_SIZE] registers exist for scratch usage:
326       First 4 are reserved for VESA BIOS Extension; any remaining are for
327       the use of the current SVGA driver. */
328 };
329 
330 
331 /*
332  * Values for SVGA_REG_GUEST_DRIVER_ID.
333  */
334 typedef enum SVGARegGuestDriverId {
335    SVGA_REG_GUEST_DRIVER_ID_UNKNOWN = 0,
336    SVGA_REG_GUEST_DRIVER_ID_WDDM    = 1,
337    SVGA_REG_GUEST_DRIVER_ID_LINUX   = 2,
338    SVGA_REG_GUEST_DRIVER_ID_MAX,
339 
340    SVGA_REG_GUEST_DRIVER_ID_SUBMIT  = MAX_UINT32,
341 } SVGARegGuestDriverId;
342 
343 typedef enum SVGARegMSHint {
344    SVGA_REG_MSHINT_DISABLED = 0,
345    SVGA_REG_MSHINT_FULL     = 1,
346    SVGA_REG_MSHINT_RESOLVED = 2,
347 } SVGARegMSHint;
348 
349 typedef enum SVGARegDirtyTracking {
350    SVGA_REG_DIRTY_TRACKING_PER_IMAGE = 0,
351    SVGA_REG_DIRTY_TRACKING_PER_SURFACE = 1,
352 } SVGARegDirtyTracking;
353 
354 
355 /*
356  * Guest memory regions (GMRs):
357  *
358  * This is a new memory mapping feature available in SVGA devices
359  * which have the SVGA_CAP_GMR bit set. Previously, there were two
360  * fixed memory regions available with which to share data between the
361  * device and the driver: the FIFO ('MEM') and the framebuffer. GMRs
362  * are our name for an extensible way of providing arbitrary DMA
363  * buffers for use between the driver and the SVGA device. They are a
364  * new alternative to framebuffer memory, usable for both 2D and 3D
365  * graphics operations.
366  *
367  * Since GMR mapping must be done synchronously with guest CPU
368  * execution, we use a new pair of SVGA registers:
369  *
370  *   SVGA_REG_GMR_ID --
371  *
372  *     Read/write.
373  *     This register holds the 32-bit ID (a small positive integer)
374  *     of a GMR to create, delete, or redefine. Writing this register
375  *     has no side-effects.
376  *
377  *   SVGA_REG_GMR_DESCRIPTOR --
378  *
379  *     Write-only.
380  *     Writing this register will create, delete, or redefine the GMR
381  *     specified by the above ID register. If this register is zero,
382  *     the GMR is deleted. Any pointers into this GMR (including those
383  *     currently being processed by FIFO commands) will be
384  *     synchronously invalidated.
385  *
386  *     If this register is nonzero, it must be the physical page
387  *     number (PPN) of a data structure which describes the physical
388  *     layout of the memory region this GMR should describe. The
389  *     descriptor structure will be read synchronously by the SVGA
390  *     device when this register is written. The descriptor need not
391  *     remain allocated for the lifetime of the GMR.
392  *
393  *     The guest driver should write SVGA_REG_GMR_ID first, then
394  *     SVGA_REG_GMR_DESCRIPTOR.
395  *
396  *   SVGA_REG_GMR_MAX_IDS --
397  *
398  *     Read-only.
399  *     The SVGA device may choose to support a maximum number of
400  *     user-defined GMR IDs. This register holds the number of supported
401  *     IDs. (The maximum supported ID plus 1)
402  *
403  *   SVGA_REG_GMR_MAX_DESCRIPTOR_LENGTH --
404  *
405  *     Read-only.
406  *     The SVGA device may choose to put a limit on the total number
407  *     of SVGAGuestMemDescriptor structures it will read when defining
408  *     a single GMR.
409  *
410  * The descriptor structure is an array of SVGAGuestMemDescriptor
411  * structures. Each structure may do one of three things:
412  *
413  *   - Terminate the GMR descriptor list.
414  *     (ppn==0, numPages==0)
415  *
416  *   - Add a PPN or range of PPNs to the GMR's virtual address space.
417  *     (ppn != 0, numPages != 0)
418  *
419  *   - Provide the PPN of the next SVGAGuestMemDescriptor, in order to
420  *     support multi-page GMR descriptor tables without forcing the
421  *     driver to allocate physically contiguous memory.
422  *     (ppn != 0, numPages == 0)
423  *
424  * Note that each physical page of SVGAGuestMemDescriptor structures
425  * can describe at least 2MB of guest memory. If the driver needs to
426  * use more than one page of descriptor structures, it must use one of
427  * its SVGAGuestMemDescriptors to point to an additional page.  The
428  * device will never automatically cross a page boundary.
429  *
430  * Once the driver has described a GMR, it is immediately available
431  * for use via any FIFO command that uses an SVGAGuestPtr structure.
432  * These pointers include a GMR identifier plus an offset into that
433  * GMR.
434  *
435  * The driver must check the SVGA_CAP_GMR bit before using the GMR
436  * registers.
437  */
438 
439 /*
440  * Special GMR IDs, allowing SVGAGuestPtrs to point to framebuffer
441  * memory as well.  In the future, these IDs could even be used to
442  * allow legacy memory regions to be redefined by the guest as GMRs.
443  *
444  * Using the guest framebuffer (GFB) at BAR1 for general purpose DMA
445  * is being phased out. Please try to use user-defined GMRs whenever
446  * possible.
447  */
448 #define SVGA_GMR_NULL         ((uint32) -1)
449 #define SVGA_GMR_FRAMEBUFFER  ((uint32) -2)  /* Guest Framebuffer (GFB) */
450 
451 typedef
452 #include "vmware_pack_begin.h"
453 struct SVGAGuestMemDescriptor {
454    uint32 ppn;
455    uint32 numPages;
456 }
457 #include "vmware_pack_end.h"
458 SVGAGuestMemDescriptor;
459 
460 typedef
461 #include "vmware_pack_begin.h"
462 struct SVGAGuestPtr {
463    uint32 gmrId;
464    uint32 offset;
465 }
466 #include "vmware_pack_end.h"
467 SVGAGuestPtr;
468 
469 /*
470  * Register based command buffers --
471  *
472  * Provide an SVGA device interface that allows the guest to submit
473  * command buffers to the SVGA device through an SVGA device register.
474  * The metadata for each command buffer is contained in the
475  * SVGACBHeader structure along with the return status codes.
476  *
477  * The SVGA device supports command buffers if
478  * SVGA_CAP_COMMAND_BUFFERS is set in the device caps register.  The
479  * fifo must be enabled for command buffers to be submitted.
480  *
481  * Command buffers are submitted when the guest writing the 64 byte
482  * aligned physical address into the SVGA_REG_COMMAND_LOW and
483  * SVGA_REG_COMMAND_HIGH.  SVGA_REG_COMMAND_HIGH contains the upper 32
484  * bits of the physical address.  SVGA_REG_COMMAND_LOW contains the
485  * lower 32 bits of the physical address, since the command buffer
486  * headers are required to be 64 byte aligned the lower 6 bits are
487  * used for the SVGACBContext value.  Writing to SVGA_REG_COMMAND_LOW
488  * submits the command buffer to the device and queues it for
489  * execution.  The SVGA device supports at least
490  * SVGA_CB_MAX_QUEUED_PER_CONTEXT command buffers that can be queued
491  * per context and if that limit is reached the device will write the
492  * status SVGA_CB_STATUS_QUEUE_FULL to the status value of the command
493  * buffer header synchronously and not raise any IRQs.
494  *
495  * It is invalid to submit a command buffer without a valid physical
496  * address and results are undefined.
497  *
498  * The device guarantees that command buffers of size SVGA_CB_MAX_SIZE
499  * will be supported.  If a larger command buffer is submitted results
500  * are unspecified and the device will either complete the command
501  * buffer or return an error.
502  *
503  * The device guarantees that any individual command in a command
504  * buffer can be up to SVGA_CB_MAX_COMMAND_SIZE in size which is
505  * enough to fit a 64x64 color-cursor definition.  If the command is
506  * too large the device is allowed to process the command or return an
507  * error.
508  *
509  * The device context is a special SVGACBContext that allows for
510  * synchronous register like accesses with the flexibility of
511  * commands.  There is a different command set defined by
512  * SVGADeviceContextCmdId.  The commands in each command buffer is not
513  * allowed to straddle physical pages.
514  *
515  * The offset field which is available starting with the
516  * SVGA_CAP_CMD_BUFFERS_2 cap bit can be set by the guest to bias the
517  * start of command processing into the buffer.  If an error is
518  * encountered the errorOffset will still be relative to the specific
519  * PA, not biased by the offset.  When the command buffer is finished
520  * the guest should not read the offset field as there is no guarantee
521  * what it will set to.
522  *
523  * When the SVGA_CAP_HP_CMD_QUEUE cap bit is set a new command queue
524  * SVGA_CB_CONTEXT_1 is available.  Commands submitted to this queue
525  * will be executed as quickly as possible by the SVGA device
526  * potentially before already queued commands on SVGA_CB_CONTEXT_0.
527  * The SVGA device guarantees that any command buffers submitted to
528  * SVGA_CB_CONTEXT_0 will be executed after any _already_ submitted
529  * command buffers to SVGA_CB_CONTEXT_1.
530  */
531 
532 #define SVGA_CB_MAX_SIZE (512 * 1024)  /* 512 KB */
533 #define SVGA_CB_MAX_QUEUED_PER_CONTEXT 32
534 #define SVGA_CB_MAX_COMMAND_SIZE (32 * 1024) /* 32 KB */
535 
536 #define SVGA_CB_CONTEXT_MASK 0x3f
537 typedef enum {
538    SVGA_CB_CONTEXT_DEVICE = 0x3f,
539    SVGA_CB_CONTEXT_0      = 0x0,
540    SVGA_CB_CONTEXT_1      = 0x1, /* Supported with SVGA_CAP_HP_CMD_QUEUE */
541    SVGA_CB_CONTEXT_MAX    = 0x2,
542 } SVGACBContext;
543 
544 
545 typedef enum {
546    /*
547     * The guest is supposed to write SVGA_CB_STATUS_NONE to the status
548     * field before submitting the command buffer header, the host will
549     * change the value when it is done with the command buffer.
550     */
551    SVGA_CB_STATUS_NONE             = 0,
552 
553    /*
554     * Written by the host when a command buffer completes successfully.
555     * The device raises an IRQ with SVGA_IRQFLAG_COMMAND_BUFFER unless
556     * the SVGA_CB_FLAG_NO_IRQ flag is set.
557     */
558    SVGA_CB_STATUS_COMPLETED        = 1,
559 
560    /*
561     * Written by the host synchronously with the command buffer
562     * submission to indicate the command buffer was not submitted.  No
563     * IRQ is raised.
564     */
565    SVGA_CB_STATUS_QUEUE_FULL       = 2,
566 
567    /*
568     * Written by the host when an error was detected parsing a command
569     * in the command buffer, errorOffset is written to contain the
570     * offset to the first byte of the failing command.  The device
571     * raises the IRQ with both SVGA_IRQFLAG_ERROR and
572     * SVGA_IRQFLAG_COMMAND_BUFFER.  Some of the commands may have been
573     * processed.
574     */
575    SVGA_CB_STATUS_COMMAND_ERROR    = 3,
576 
577    /*
578     * Written by the host if there is an error parsing the command
579     * buffer header.  The device raises the IRQ with both
580     * SVGA_IRQFLAG_ERROR and SVGA_IRQFLAG_COMMAND_BUFFER.  The device
581     * did not processes any of the command buffer.
582     */
583    SVGA_CB_STATUS_CB_HEADER_ERROR  = 4,
584 
585    /*
586     * Written by the host if the guest requested the host to preempt
587     * the command buffer.  The device will not raise any IRQs and the
588     * command buffer was not processed.
589     */
590    SVGA_CB_STATUS_PREEMPTED        = 5,
591 
592    /*
593     * Written by the host synchronously with the command buffer
594     * submission to indicate the the command buffer was not submitted
595     * due to an error.  No IRQ is raised.
596     */
597    SVGA_CB_STATUS_SUBMISSION_ERROR = 6,
598 
599    /*
600     * Written by the host when the host finished a
601     * SVGA_DC_CMD_ASYNC_STOP_QUEUE request for this command buffer
602     * queue.  The offset of the first byte not processed is stored in
603     * the errorOffset field of the command buffer header.  All guest
604     * visible side effects of commands till that point are guaranteed
605     * to be finished before this is written.  The
606     * SVGA_IRQFLAG_COMMAND_BUFFER IRQ is raised as long as the
607     * SVGA_CB_FLAG_NO_IRQ is not set.
608     */
609    SVGA_CB_STATUS_PARTIAL_COMPLETE = 7,
610 } SVGACBStatus;
611 
612 typedef enum {
613    SVGA_CB_FLAG_NONE       = 0,
614    SVGA_CB_FLAG_NO_IRQ     = 1 << 0,
615    SVGA_CB_FLAG_DX_CONTEXT = 1 << 1,
616    SVGA_CB_FLAG_MOB        = 1 << 2,
617 } SVGACBFlags;
618 
619 typedef
620 #include "vmware_pack_begin.h"
621 struct {
622    volatile SVGACBStatus status; /* Modified by device. */
623    volatile uint32 errorOffset;  /* Modified by device. */
624    uint64 id;
625    SVGACBFlags flags;
626    uint32 length;
627    union {
628       PA pa;
629       struct {
630          SVGAMobId mobid;
631          uint32 mobOffset;
632       } mob;
633    } ptr;
634    uint32 offset; /* Valid if CMD_BUFFERS_2 cap set, must be zero otherwise,
635                    * modified by device.
636                    */
637    uint32 dxContext; /* Valid if DX_CONTEXT flag set, must be zero otherwise */
638    uint32 mustBeZero[6];
639 }
640 #include "vmware_pack_end.h"
641 SVGACBHeader;
642 
643 typedef enum {
644    SVGA_DC_CMD_NOP                   = 0,
645    SVGA_DC_CMD_START_STOP_CONTEXT    = 1,
646    SVGA_DC_CMD_PREEMPT               = 2,
647    SVGA_DC_CMD_START_QUEUE           = 3, /* Requires SVGA_CAP_HP_CMD_QUEUE */
648    SVGA_DC_CMD_ASYNC_STOP_QUEUE      = 4, /* Requires SVGA_CAP_HP_CMD_QUEUE */
649    SVGA_DC_CMD_EMPTY_CONTEXT_QUEUE   = 5, /* Requires SVGA_CAP_HP_CMD_QUEUE */
650    SVGA_DC_CMD_MAX                   = 6,
651 } SVGADeviceContextCmdId;
652 
653 /*
654  * Starts or stops both SVGA_CB_CONTEXT_0 and SVGA_CB_CONTEXT_1.
655  */
656 
657 typedef struct SVGADCCmdStartStop {
658    uint32 enable;
659    SVGACBContext context; /* Must be zero */
660 } SVGADCCmdStartStop;
661 
662 /*
663  * SVGADCCmdPreempt --
664  *
665  * This command allows the guest to request that all command buffers
666  * on SVGA_CB_CONTEXT_0 be preempted that can be.  After execution
667  * of this command all command buffers that were preempted will
668  * already have SVGA_CB_STATUS_PREEMPTED written into the status
669  * field.  The device might still be processing a command buffer,
670  * assuming execution of it started before the preemption request was
671  * received.  Specifying the ignoreIDZero flag to TRUE will cause the
672  * device to not preempt command buffers with the id field in the
673  * command buffer header set to zero.
674  */
675 
676 typedef struct SVGADCCmdPreempt {
677    SVGACBContext context; /* Must be zero */
678    uint32 ignoreIDZero;
679 } SVGADCCmdPreempt;
680 
681 /*
682  * Starts the requested command buffer processing queue.  Valid only
683  * if the SVGA_CAP_HP_CMD_QUEUE cap is set.
684  *
685  * For a command queue to be considered runnable it must be enabled
686  * and any corresponding higher priority queues must also be enabled.
687  * For example in order for command buffers to be processed on
688  * SVGA_CB_CONTEXT_0 both SVGA_CB_CONTEXT_0 and SVGA_CB_CONTEXT_1 must
689  * be enabled.  But for commands to be runnable on SVGA_CB_CONTEXT_1
690  * only that queue must be enabled.
691  */
692 
693 typedef struct SVGADCCmdStartQueue {
694    SVGACBContext context;
695 } SVGADCCmdStartQueue;
696 
697 /*
698  * Requests the SVGA device to stop processing the requested command
699  * buffer queue as soon as possible.  The guest knows the stop has
700  * completed when one of the following happens.
701  *
702  * 1) A command buffer status of SVGA_CB_STATUS_PARTIAL_COMPLETE is returned
703  * 2) A command buffer error is encountered with would stop the queue
704  *    regardless of the async stop request.
705  * 3) All command buffers that have been submitted complete successfully.
706  * 4) The stop completes synchronously if no command buffers are
707  *    active on the queue when it is issued.
708  *
709  * If the command queue is not in a runnable state there is no
710  * guarentee this async stop will finish.  For instance if the high
711  * priority queue is not enabled and a stop is requested on the low
712  * priority queue, the high priority queue must be reenabled to
713  * guarantee that the async stop will finish.
714  *
715  * This command along with SVGA_DC_CMD_EMPTY_CONTEXT_QUEUE can be used
716  * to implement mid command buffer preemption.
717  *
718  * Valid only if the SVGA_CAP_HP_CMD_QUEUE cap is set.
719  */
720 
721 typedef struct SVGADCCmdAsyncStopQueue {
722    SVGACBContext context;
723 } SVGADCCmdAsyncStopQueue;
724 
725 /*
726  * Requests the SVGA device to throw away any full command buffers on
727  * the requested command queue that have not been started.  For a
728  * driver to know which command buffers were thrown away a driver
729  * should only issue this command when the queue is stopped, for
730  * whatever reason.
731  */
732 
733 typedef struct SVGADCCmdEmptyQueue {
734    SVGACBContext context;
735 } SVGADCCmdEmptyQueue;
736 
737 
738 /*
739  * SVGAGMRImageFormat --
740  *
741  *    This is a packed representation of the source 2D image format
742  *    for a GMR-to-screen blit. Currently it is defined as an encoding
743  *    of the screen's color depth and bits-per-pixel, however, 16 bits
744  *    are reserved for future use to identify other encodings (such as
745  *    RGBA or higher-precision images).
746  *
747  *    Currently supported formats:
748  *
749  *       bpp depth  Format Name
750  *       --- -----  -----------
751  *        32    24  32-bit BGRX
752  *        24    24  24-bit BGR
753  *        16    16  RGB 5-6-5
754  *        16    15  RGB 5-5-5
755  *
756  */
757 
758 typedef struct SVGAGMRImageFormat {
759    union {
760       struct {
761          uint32 bitsPerPixel : 8;
762          uint32 colorDepth   : 8;
763          uint32 reserved     : 16;  /* Must be zero */
764       };
765 
766       uint32 value;
767    };
768 } SVGAGMRImageFormat;
769 
770 typedef
771 #include "vmware_pack_begin.h"
772 struct SVGAGuestImage {
773    SVGAGuestPtr         ptr;
774 
775    /*
776     * A note on interpretation of pitch: This value of pitch is the
777     * number of bytes between vertically adjacent image
778     * blocks. Normally this is the number of bytes between the first
779     * pixel of two adjacent scanlines. With compressed textures,
780     * however, this may represent the number of bytes between
781     * compression blocks rather than between rows of pixels.
782     *
783     * XXX: Compressed textures currently must be tightly packed in guest memory.
784     *
785     * If the image is 1-dimensional, pitch is ignored.
786     *
787     * If 'pitch' is zero, the SVGA3D device calculates a pitch value
788     * assuming each row of blocks is tightly packed.
789     */
790    uint32 pitch;
791 }
792 #include "vmware_pack_end.h"
793 SVGAGuestImage;
794 
795 /*
796  * SVGAColorBGRX --
797  *
798  *    A 24-bit color format (BGRX), which does not depend on the
799  *    format of the legacy guest framebuffer (GFB) or the current
800  *    GMRFB state.
801  */
802 
803 typedef struct SVGAColorBGRX {
804    union {
805       struct {
806          uint32 b : 8;
807          uint32 g : 8;
808          uint32 r : 8;
809 	 uint32 x : 8;  /* Unused */
810       };
811 
812       uint32 value;
813    };
814 } SVGAColorBGRX;
815 
816 
817 /*
818  * SVGASignedRect --
819  * SVGASignedPoint --
820  *
821  *    Signed rectangle and point primitives. These are used by the new
822  *    2D primitives for drawing to Screen Objects, which can occupy a
823  *    signed virtual coordinate space.
824  *
825  *    SVGASignedRect specifies a half-open interval: the (left, top)
826  *    pixel is part of the rectangle, but the (right, bottom) pixel is
827  *    not.
828  */
829 
830 typedef
831 #include "vmware_pack_begin.h"
832 struct {
833    int32  left;
834    int32  top;
835    int32  right;
836    int32  bottom;
837 }
838 #include "vmware_pack_end.h"
839 SVGASignedRect;
840 
841 typedef
842 #include "vmware_pack_begin.h"
843 struct {
844    int32  x;
845    int32  y;
846 }
847 #include "vmware_pack_end.h"
848 SVGASignedPoint;
849 
850 
851 /*
852  * SVGA Device Capabilities
853  *
854  * Note the holes in the bitfield. Missing bits have been deprecated,
855  * and must not be reused. Those capabilities will never be reported
856  * by new versions of the SVGA device.
857  *
858  * SVGA_CAP_IRQMASK --
859  *    Provides device interrupts.  Adds device register SVGA_REG_IRQMASK
860  *    to set interrupt mask and direct I/O port SVGA_IRQSTATUS_PORT to
861  *    set/clear pending interrupts.
862  *
863  * SVGA_CAP_GMR --
864  *    Provides synchronous mapping of guest memory regions (GMR).
865  *    Adds device registers SVGA_REG_GMR_ID, SVGA_REG_GMR_DESCRIPTOR,
866  *    SVGA_REG_GMR_MAX_IDS, and SVGA_REG_GMR_MAX_DESCRIPTOR_LENGTH.
867  *
868  * SVGA_CAP_TRACES --
869  *    Allows framebuffer trace-based updates even when FIFO is enabled.
870  *    Adds device register SVGA_REG_TRACES.
871  *
872  * SVGA_CAP_GMR2 --
873  *    Provides asynchronous commands to define and remap guest memory
874  *    regions.  Adds device registers SVGA_REG_GMRS_MAX_PAGES and
875  *    SVGA_REG_MEMORY_SIZE.
876  *
877  * SVGA_CAP_SCREEN_OBJECT_2 --
878  *    Allow screen object support, and require backing stores from the
879  *    guest for each screen object.
880  *
881  * SVGA_CAP_COMMAND_BUFFERS --
882  *    Enable register based command buffer submission.
883  *
884  * SVGA_CAP_DEAD1 --
885  *    This cap was incorrectly used by old drivers and should not be
886  *    reused.
887  *
888  * SVGA_CAP_CMD_BUFFERS_2 --
889  *    Enable support for the prepend command buffer submision
890  *    registers.  SVGA_REG_CMD_PREPEND_LOW and
891  *    SVGA_REG_CMD_PREPEND_HIGH.
892  *
893  * SVGA_CAP_GBOBJECTS --
894  *    Enable guest-backed objects and surfaces.
895  *
896  * SVGA_CAP_DX --
897  *    Enable support for DX commands, and command buffers in a mob.
898  *
899  * SVGA_CAP_HP_CMD_QUEUE --
900  *    Enable support for the high priority command queue, and the
901  *    ScreenCopy command.
902  *
903  * SVGA_CAP_NO_BB_RESTRICTION --
904  *    Allow ScreenTargets to be defined without regard to the 32-bpp
905  *    bounding-box memory restrictions. ie:
906  *
907  *    The summed memory usage of all screens (assuming they were defined as
908  *    32-bpp) must always be less than the value of the
909  *    SVGA_REG_MAX_PRIMARY_MEM register.
910  *
911  *    If this cap is not present, the 32-bpp bounding box around all screens
912  *    must additionally be under the value of the SVGA_REG_MAX_PRIMARY_MEM
913  *    register.
914  *
915  *    If the cap is present, the bounding box restriction is lifted (and only
916  *    the screen-sum limit applies).
917  *
918  *    (Note that this is a slight lie... there is still a sanity limit on any
919  *     dimension of the topology to be less than SVGA_SCREEN_ROOT_LIMIT, even
920  *     when SVGA_CAP_NO_BB_RESTRICTION is present, but that should be
921  *     large enough to express any possible topology without holes between
922  *     monitors.)
923  *
924  * SVGA_CAP_CAP2_REGISTER --
925  *    If this cap is present, the SVGA_REG_CAP2 register is supported.
926  */
927 
928 #define SVGA_CAP_NONE               0x00000000
929 #define SVGA_CAP_RECT_COPY          0x00000002
930 #define SVGA_CAP_CURSOR             0x00000020
931 #define SVGA_CAP_CURSOR_BYPASS      0x00000040
932 #define SVGA_CAP_CURSOR_BYPASS_2    0x00000080
933 #define SVGA_CAP_8BIT_EMULATION     0x00000100
934 #define SVGA_CAP_ALPHA_CURSOR       0x00000200
935 #define SVGA_CAP_3D                 0x00004000
936 #define SVGA_CAP_EXTENDED_FIFO      0x00008000
937 #define SVGA_CAP_MULTIMON           0x00010000
938 #define SVGA_CAP_PITCHLOCK          0x00020000
939 #define SVGA_CAP_IRQMASK            0x00040000
940 #define SVGA_CAP_DISPLAY_TOPOLOGY   0x00080000
941 #define SVGA_CAP_GMR                0x00100000
942 #define SVGA_CAP_TRACES             0x00200000
943 #define SVGA_CAP_GMR2               0x00400000
944 #define SVGA_CAP_SCREEN_OBJECT_2    0x00800000
945 #define SVGA_CAP_COMMAND_BUFFERS    0x01000000
946 #define SVGA_CAP_DEAD1              0x02000000
947 #define SVGA_CAP_CMD_BUFFERS_2      0x04000000
948 #define SVGA_CAP_GBOBJECTS          0x08000000
949 #define SVGA_CAP_DX                 0x10000000
950 #define SVGA_CAP_HP_CMD_QUEUE       0x20000000
951 #define SVGA_CAP_NO_BB_RESTRICTION  0x40000000
952 #define SVGA_CAP_CAP2_REGISTER      0x80000000
953 
954 /*
955  * The SVGA_REG_CAP2 register is an additional set of SVGA capability bits.
956  *
957  * SVGA_CAP2_GROW_OTABLE --
958  *      Allow the GrowOTable/DXGrowCOTable commands.
959  *
960  * SVGA_CAP2_INTRA_SURFACE_COPY --
961  *      Allow the IntraSurfaceCopy command.
962  *
963  * SVGA_CAP2_DX2 --
964  *      Allow the DefineGBSurface_v3, WholeSurfaceCopy, WriteZeroSurface, and
965  *      HintZeroSurface commands, and the SVGA_REG_GUEST_DRIVER_ID register.
966  *
967  * SVGA_CAP2_GB_MEMSIZE_2 --
968  *      Allow the SVGA_REG_GBOBJECT_MEM_SIZE_KB register.
969  *
970  * SVGA_CAP2_SCREENDMA_REG --
971  *      Allow the SVGA_REG_SCREENDMA register.
972  *
973  * SVGA_CAP2_OTABLE_PTDEPTH_2 --
974  *      Allow 2 level page tables for OTable commands.
975  *
976  * SVGA_CAP2_NON_MS_TO_MS_STRETCHBLT --
977  *      Allow a stretch blt from a non-multisampled surface to a multisampled
978  *      surface.
979  *
980  * SVGA_CAP2_CURSOR_MOB --
981  *      Allow the SVGA_REG_CURSOR_MOBID register.
982  *
983  * SVGA_CAP2_MSHINT --
984  *      Allow the SVGA_REG_MSHINT register.
985  *
986  * SVGA_CAP2_DX3 --
987  *      Allows the DefineGBSurface_v4 command.
988  *      Allows the DXDefineDepthStencilView_v2, DXDefineStreamOutputWithMob,
989  *      and DXBindStreamOutput commands if 3D is also available.
990  *      Allows the DXPredStagingCopy and DXStagingCopy commands if SM41
991  *      is also available.
992  *
993  * SVGA_CAP2_RESERVED --
994  *      Reserve the last bit for extending the SVGA capabilities to some
995  *      future mechanisms.
996  */
997 #define SVGA_CAP2_NONE                    0x00000000
998 #define SVGA_CAP2_GROW_OTABLE             0x00000001
999 #define SVGA_CAP2_INTRA_SURFACE_COPY      0x00000002
1000 #define SVGA_CAP2_DX2                     0x00000004
1001 #define SVGA_CAP2_GB_MEMSIZE_2            0x00000008
1002 #define SVGA_CAP2_SCREENDMA_REG           0x00000010
1003 #define SVGA_CAP2_OTABLE_PTDEPTH_2        0x00000020
1004 #define SVGA_CAP2_NON_MS_TO_MS_STRETCHBLT 0x00000040
1005 #define SVGA_CAP2_CURSOR_MOB              0x00000080
1006 #define SVGA_CAP2_MSHINT                  0x00000100
1007 #define SVGA_CAP2_DX3                     0x00000400
1008 #define SVGA_CAP2_RESERVED                0x80000000
1009 
1010 
1011 /*
1012  * The Guest can optionally read some SVGA device capabilities through
1013  * the backdoor with command BDOOR_CMD_GET_SVGA_CAPABILITIES before
1014  * the SVGA device is initialized.  The type of capability the guest
1015  * is requesting from the SVGABackdoorCapType enum should be placed in
1016  * the upper 16 bits of the backdoor command id (ECX).  On success the
1017  * the value of EBX will be set to BDOOR_MAGIC and EAX will be set to
1018  * the requested capability.  If the command is not supported then EBX
1019  * will be left unchanged and EAX will be set to -1.  Because it is
1020  * possible that -1 is the value of the requested cap the correct way
1021  * to check if the command was successful is to check if EBX was changed
1022  * to BDOOR_MAGIC making sure to initialize the register to something
1023  * else first.
1024  */
1025 
1026 typedef enum {
1027    SVGABackdoorCapDeviceCaps = 0,
1028    SVGABackdoorCapFifoCaps = 1,
1029    SVGABackdoorCap3dHWVersion = 2,
1030    SVGABackdoorCapDeviceCaps2 = 3,
1031    SVGABackdoorCapDevelCaps = 4,
1032    SVGABackdoorDevelRenderer = 5,
1033    SVGABackdoorCapMax = 6,
1034 } SVGABackdoorCapType;
1035 
1036 
1037 /*
1038  * FIFO register indices.
1039  *
1040  * The FIFO is a chunk of device memory mapped into guest physmem.  It
1041  * is always treated as 32-bit words.
1042  *
1043  * The guest driver gets to decide how to partition it between
1044  * - FIFO registers (there are always at least 4, specifying where the
1045  *   following data area is and how much data it contains; there may be
1046  *   more registers following these, depending on the FIFO protocol
1047  *   version in use)
1048  * - FIFO data, written by the guest and slurped out by the VMX.
1049  * These indices are 32-bit word offsets into the FIFO.
1050  */
1051 
1052 enum {
1053    /*
1054     * Block 1 (basic registers): The originally defined FIFO registers.
1055     * These exist and are valid for all versions of the FIFO protocol.
1056     */
1057 
1058    SVGA_FIFO_MIN = 0,
1059    SVGA_FIFO_MAX,       /* The distance from MIN to MAX must be at least 10K */
1060    SVGA_FIFO_NEXT_CMD,
1061    SVGA_FIFO_STOP,
1062 
1063    /*
1064     * Block 2 (extended registers): Mandatory registers for the extended
1065     * FIFO.  These exist if the SVGA caps register includes
1066     * SVGA_CAP_EXTENDED_FIFO; some of them are valid only if their
1067     * associated capability bit is enabled.
1068     *
1069     * Note that when originally defined, SVGA_CAP_EXTENDED_FIFO implied
1070     * support only for (FIFO registers) CAPABILITIES, FLAGS, and FENCE.
1071     * This means that the guest has to test individually (in most cases
1072     * using FIFO caps) for the presence of registers after this; the VMX
1073     * can define "extended FIFO" to mean whatever it wants, and currently
1074     * won't enable it unless there's room for that set and much more.
1075     */
1076 
1077    SVGA_FIFO_CAPABILITIES = 4,
1078    SVGA_FIFO_FLAGS,
1079    /* Valid with SVGA_FIFO_CAP_FENCE: */
1080    SVGA_FIFO_FENCE,
1081 
1082    /*
1083     * Block 3a (optional extended registers): Additional registers for the
1084     * extended FIFO, whose presence isn't actually implied by
1085     * SVGA_CAP_EXTENDED_FIFO; these exist if SVGA_FIFO_MIN is high enough to
1086     * leave room for them.
1087     *
1088     * These in block 3a, the VMX currently considers mandatory for the
1089     * extended FIFO.
1090     */
1091 
1092    /* Valid if exists (i.e. if extended FIFO enabled): */
1093    SVGA_FIFO_3D_HWVERSION,       /* See SVGA3dHardwareVersion in svga3d_reg.h */
1094    /* Valid with SVGA_FIFO_CAP_PITCHLOCK: */
1095    SVGA_FIFO_PITCHLOCK,
1096 
1097    /* Valid with SVGA_FIFO_CAP_CURSOR_BYPASS_3: */
1098    SVGA_FIFO_CURSOR_ON,          /* Cursor bypass 3 show/hide register */
1099    SVGA_FIFO_CURSOR_X,           /* Cursor bypass 3 x register */
1100    SVGA_FIFO_CURSOR_Y,           /* Cursor bypass 3 y register */
1101    SVGA_FIFO_CURSOR_COUNT,       /* Incremented when any of the other 3 change */
1102    SVGA_FIFO_CURSOR_LAST_UPDATED,/* Last time the host updated the cursor */
1103 
1104    /* Valid with SVGA_FIFO_CAP_RESERVE: */
1105    SVGA_FIFO_RESERVED,           /* Bytes past NEXT_CMD with real contents */
1106 
1107    /*
1108     * Valid with SVGA_FIFO_CAP_SCREEN_OBJECT or SVGA_FIFO_CAP_SCREEN_OBJECT_2:
1109     *
1110     * By default this is SVGA_ID_INVALID, to indicate that the cursor
1111     * coordinates are specified relative to the virtual root. If this
1112     * is set to a specific screen ID, cursor position is reinterpreted
1113     * as a signed offset relative to that screen's origin.
1114     */
1115    SVGA_FIFO_CURSOR_SCREEN_ID,
1116 
1117    /*
1118     * Valid with SVGA_FIFO_CAP_DEAD
1119     *
1120     * An arbitrary value written by the host, drivers should not use it.
1121     */
1122    SVGA_FIFO_DEAD,
1123 
1124    /*
1125     * Valid with SVGA_FIFO_CAP_3D_HWVERSION_REVISED:
1126     *
1127     * Contains 3D HWVERSION (see SVGA3dHardwareVersion in svga3d_reg.h)
1128     * on platforms that can enforce graphics resource limits.
1129     */
1130    SVGA_FIFO_3D_HWVERSION_REVISED,
1131 
1132    /*
1133     * XXX: The gap here, up until SVGA_FIFO_3D_CAPS, can be used for new
1134     * registers, but this must be done carefully and with judicious use of
1135     * capability bits, since comparisons based on SVGA_FIFO_MIN aren't
1136     * enough to tell you whether the register exists: we've shipped drivers
1137     * and products that used SVGA_FIFO_3D_CAPS but didn't know about some of
1138     * the earlier ones.  The actual order of introduction was:
1139     * - PITCHLOCK
1140     * - 3D_CAPS
1141     * - CURSOR_* (cursor bypass 3)
1142     * - RESERVED
1143     * So, code that wants to know whether it can use any of the
1144     * aforementioned registers, or anything else added after PITCHLOCK and
1145     * before 3D_CAPS, needs to reason about something other than
1146     * SVGA_FIFO_MIN.
1147     */
1148 
1149    /*
1150     * 3D caps block space; valid with 3D hardware version >=
1151     * SVGA3D_HWVERSION_WS6_B1.
1152     */
1153    SVGA_FIFO_3D_CAPS      = 32,
1154    SVGA_FIFO_3D_CAPS_LAST = 32 + 255,
1155 
1156    /*
1157     * End of VMX's current definition of "extended-FIFO registers".
1158     * Registers before here are always enabled/disabled as a block; either
1159     * the extended FIFO is enabled and includes all preceding registers, or
1160     * it's disabled entirely.
1161     *
1162     * Block 3b (truly optional extended registers): Additional registers for
1163     * the extended FIFO, which the VMX already knows how to enable and
1164     * disable with correct granularity.
1165     *
1166     * Registers after here exist if and only if the guest SVGA driver
1167     * sets SVGA_FIFO_MIN high enough to leave room for them.
1168     */
1169 
1170    /* Valid if register exists: */
1171    SVGA_FIFO_GUEST_3D_HWVERSION, /* Guest driver's 3D version */
1172    SVGA_FIFO_FENCE_GOAL,         /* Matching target for SVGA_IRQFLAG_FENCE_GOAL */
1173    SVGA_FIFO_BUSY,               /* See "FIFO Synchronization Registers" */
1174 
1175    /*
1176     * Always keep this last.  This defines the maximum number of
1177     * registers we know about.  At power-on, this value is placed in
1178     * the SVGA_REG_MEM_REGS register, and we expect the guest driver
1179     * to allocate this much space in FIFO memory for registers.
1180     */
1181     SVGA_FIFO_NUM_REGS
1182 };
1183 
1184 
1185 /*
1186  * Definition of registers included in extended FIFO support.
1187  *
1188  * The guest SVGA driver gets to allocate the FIFO between registers
1189  * and data.  It must always allocate at least 4 registers, but old
1190  * drivers stopped there.
1191  *
1192  * The VMX will enable extended FIFO support if and only if the guest
1193  * left enough room for all registers defined as part of the mandatory
1194  * set for the extended FIFO.
1195  *
1196  * Note that the guest drivers typically allocate the FIFO only at
1197  * initialization time, not at mode switches, so it's likely that the
1198  * number of FIFO registers won't change without a reboot.
1199  *
1200  * All registers less than this value are guaranteed to be present if
1201  * svgaUser->fifo.extended is set. Any later registers must be tested
1202  * individually for compatibility at each use (in the VMX).
1203  *
1204  * This value is used only by the VMX, so it can change without
1205  * affecting driver compatibility; keep it that way?
1206  */
1207 #define SVGA_FIFO_EXTENDED_MANDATORY_REGS  (SVGA_FIFO_3D_CAPS_LAST + 1)
1208 
1209 
1210 /*
1211  * FIFO Synchronization Registers
1212  *
1213  *  SVGA_REG_SYNC --
1214  *
1215  *       The SYNC register can be used by the guest driver to signal to the
1216  *       device that the guest driver is waiting for previously submitted
1217  *       commands to complete.
1218  *
1219  *       When the guest driver writes to the SYNC register, the device sets
1220  *       the BUSY register to TRUE, and starts processing the submitted commands
1221  *       (if it was not already doing so).  When all previously submitted
1222  *       commands are finished and the device is idle again, it sets the BUSY
1223  *       register back to FALSE.  (If the guest driver submits new commands
1224  *       after writing the SYNC register, the new commands are not guaranteed
1225  *       to have been procesesd.)
1226  *
1227  *       When guest drivers are submitting commands using the FIFO, the device
1228  *       periodically polls to check for new FIFO commands when idle, which may
1229  *       introduce a delay in command processing.  If the guest-driver wants
1230  *       the commands to be processed quickly (which it typically does), it
1231  *       should write SYNC after each batch of commands is committed to the
1232  *       FIFO to immediately wake up the device.  For even better performance,
1233  *       the guest can use the SVGA_FIFO_BUSY register to avoid these extra
1234  *       SYNC writes if the device is already active, using the technique known
1235  *       as "Ringing the Doorbell" (described below).  (Note that command
1236  *       buffer submission implicitly wakes up the device, and so doesn't
1237  *       suffer from this problem.)
1238  *
1239  *       The SYNC register can also be used in combination with BUSY to
1240  *       synchronously ensure that all SVGA commands are processed (with both
1241  *       the FIFO and command-buffers).  To do this, the guest driver should
1242  *       write to SYNC, and then loop reading BUSY until BUSY returns FALSE.
1243  *       This technique is known as a "Legacy Sync".
1244  *
1245  *  SVGA_REG_BUSY --
1246  *
1247  *       This register is set to TRUE when SVGA_REG_SYNC is written,
1248  *       and is set back to FALSE when the device has finished processing
1249  *       all commands and is idle again.
1250  *
1251  *       Every read from the BUSY reigster will block for an undefined
1252  *       amount of time (normally until the device finishes some interesting
1253  *       work unit), or the device is idle.
1254  *
1255  *       Guest drivers can also do a partial Legacy Sync to check for some
1256  *       particular condition, for instance by stopping early when a fence
1257  *       passes before BUSY has been set back to FALSE.  This is particularly
1258  *       useful if the guest-driver knows that it is blocked waiting on the
1259  *       device, because it will yield CPU time back to the host.
1260  *
1261  *  SVGA_FIFO_BUSY --
1262  *
1263  *       The SVGA_FIFO_BUSY register is a fast way for the guest driver to check
1264  *       whether the device is actively processing FIFO commands before writing
1265  *       the more expensive SYNC register.
1266  *
1267  *       If this register reads as TRUE, the device is actively processing
1268  *       FIFO commands.
1269  *
1270  *       If this register reads as FALSE, the device may not be actively
1271  *       processing commands, and the guest driver should try
1272  *       "Ringing the Doorbell".
1273  *
1274  *       To Ring the Doorbell, the guest should:
1275  *
1276  *       1. Have already written their batch of commands into the FIFO.
1277  *       2. Check if the SVGA_FIFO_BUSY register is available by reading
1278  *          SVGA_FIFO_MIN.
1279  *       3. Read SVGA_FIFO_BUSY.  If it reads as TRUE, the device is actively
1280  *          processing FIFO commands, and no further action is necessary.
1281  *       4. If SVGA_FIFO_BUSY was FALSE, write TRUE to SVGA_REG_SYNC.
1282  *
1283  *       For maximum performance, this procedure should be followed after
1284  *       every meaningful batch of commands has been written into the FIFO.
1285  *       (Normally when the underlying application signals it's finished a
1286  *       meaningful work unit by calling Flush.)
1287  */
1288 
1289 
1290 /*
1291  * FIFO Capabilities
1292  *
1293  *      Fence -- Fence register and command are supported
1294  *      Accel Front -- Front buffer only commands are supported
1295  *      Pitch Lock -- Pitch lock register is supported
1296  *      Video -- SVGA Video overlay units are supported
1297  *      Escape -- Escape command is supported
1298  *
1299  * SVGA_FIFO_CAP_SCREEN_OBJECT --
1300  *
1301  *    Provides dynamic multi-screen rendering, for improved Unity and
1302  *    multi-monitor modes. With Screen Object, the guest can
1303  *    dynamically create and destroy 'screens', which can represent
1304  *    Unity windows or virtual monitors. Screen Object also provides
1305  *    strong guarantees that DMA operations happen only when
1306  *    guest-initiated. Screen Object deprecates the BAR1 guest
1307  *    framebuffer (GFB) and all commands that work only with the GFB.
1308  *
1309  *    New registers:
1310  *       FIFO_CURSOR_SCREEN_ID, VIDEO_DATA_GMRID, VIDEO_DST_SCREEN_ID
1311  *
1312  *    New 2D commands:
1313  *       DEFINE_SCREEN, DESTROY_SCREEN, DEFINE_GMRFB, BLIT_GMRFB_TO_SCREEN,
1314  *       BLIT_SCREEN_TO_GMRFB, ANNOTATION_FILL, ANNOTATION_COPY
1315  *
1316  *    New 3D commands:
1317  *       BLIT_SURFACE_TO_SCREEN
1318  *
1319  *    New guarantees:
1320  *
1321  *       - The host will not read or write guest memory, including the GFB,
1322  *         except when explicitly initiated by a DMA command.
1323  *
1324  *       - All DMA, including legacy DMA like UPDATE and PRESENT_READBACK,
1325  *         is guaranteed to complete before any subsequent FENCEs.
1326  *
1327  *       - All legacy commands which affect a Screen (UPDATE, PRESENT,
1328  *         PRESENT_READBACK) as well as new Screen blit commands will
1329  *         all behave consistently as blits, and memory will be read
1330  *         or written in FIFO order.
1331  *
1332  *         For example, if you PRESENT from one SVGA3D surface to multiple
1333  *         places on the screen, the data copied will always be from the
1334  *         SVGA3D surface at the time the PRESENT was issued in the FIFO.
1335  *         This was not necessarily true on devices without Screen Object.
1336  *
1337  *         This means that on devices that support Screen Object, the
1338  *         PRESENT_READBACK command should not be necessary unless you
1339  *         actually want to read back the results of 3D rendering into
1340  *         system memory. (And for that, the BLIT_SCREEN_TO_GMRFB
1341  *         command provides a strict superset of functionality.)
1342  *
1343  *       - When a screen is resized, either using Screen Object commands or
1344  *         legacy multimon registers, its contents are preserved.
1345  *
1346  * SVGA_FIFO_CAP_GMR2 --
1347  *
1348  *    Provides new commands to define and remap guest memory regions (GMR).
1349  *
1350  *    New 2D commands:
1351  *       DEFINE_GMR2, REMAP_GMR2.
1352  *
1353  * SVGA_FIFO_CAP_3D_HWVERSION_REVISED --
1354  *
1355  *    Indicates new register SVGA_FIFO_3D_HWVERSION_REVISED exists.
1356  *    This register may replace SVGA_FIFO_3D_HWVERSION on platforms
1357  *    that enforce graphics resource limits.  This allows the platform
1358  *    to clear SVGA_FIFO_3D_HWVERSION and disable 3D in legacy guest
1359  *    drivers that do not limit their resources.
1360  *
1361  *    Note this is an alias to SVGA_FIFO_CAP_GMR2 because these indicators
1362  *    are codependent (and thus we use a single capability bit).
1363  *
1364  * SVGA_FIFO_CAP_SCREEN_OBJECT_2 --
1365  *
1366  *    Modifies the DEFINE_SCREEN command to include a guest provided
1367  *    backing store in GMR memory and the bytesPerLine for the backing
1368  *    store.  This capability requires the use of a backing store when
1369  *    creating screen objects.  However if SVGA_FIFO_CAP_SCREEN_OBJECT
1370  *    is present then backing stores are optional.
1371  *
1372  * SVGA_FIFO_CAP_DEAD --
1373  *
1374  *    Drivers should not use this cap bit.  This cap bit can not be
1375  *    reused since some hosts already expose it.
1376  */
1377 
1378 #define SVGA_FIFO_CAP_NONE                  0
1379 #define SVGA_FIFO_CAP_FENCE             (1<<0)
1380 #define SVGA_FIFO_CAP_ACCELFRONT        (1<<1)
1381 #define SVGA_FIFO_CAP_PITCHLOCK         (1<<2)
1382 #define SVGA_FIFO_CAP_VIDEO             (1<<3)
1383 #define SVGA_FIFO_CAP_CURSOR_BYPASS_3   (1<<4)
1384 #define SVGA_FIFO_CAP_ESCAPE            (1<<5)
1385 #define SVGA_FIFO_CAP_RESERVE           (1<<6)
1386 #define SVGA_FIFO_CAP_SCREEN_OBJECT     (1<<7)
1387 #define SVGA_FIFO_CAP_GMR2              (1<<8)
1388 #define SVGA_FIFO_CAP_3D_HWVERSION_REVISED  SVGA_FIFO_CAP_GMR2
1389 #define SVGA_FIFO_CAP_SCREEN_OBJECT_2   (1<<9)
1390 #define SVGA_FIFO_CAP_DEAD              (1<<10)
1391 
1392 
1393 /*
1394  * FIFO Flags
1395  *
1396  *      Accel Front -- Driver should use front buffer only commands
1397  */
1398 
1399 #define SVGA_FIFO_FLAG_NONE                 0
1400 #define SVGA_FIFO_FLAG_ACCELFRONT       (1<<0)
1401 #define SVGA_FIFO_FLAG_RESERVED        (1<<31) /* Internal use only */
1402 
1403 /*
1404  * FIFO reservation sentinel value
1405  */
1406 
1407 #define SVGA_FIFO_RESERVED_UNKNOWN      0xffffffff
1408 
1409 
1410 /*
1411  * ScreenDMA Register Values
1412  */
1413 
1414 #define SVGA_SCREENDMA_REG_UNDEFINED    0
1415 #define SVGA_SCREENDMA_REG_NOT_PRESENT  1
1416 #define SVGA_SCREENDMA_REG_PRESENT      2
1417 #define SVGA_SCREENDMA_REG_MAX          3
1418 
1419 /*
1420  * Video overlay support
1421  */
1422 
1423 #define SVGA_NUM_OVERLAY_UNITS 32
1424 
1425 
1426 /*
1427  * Video capabilities that the guest is currently using
1428  */
1429 
1430 #define SVGA_VIDEO_FLAG_COLORKEY        0x0001
1431 
1432 
1433 /*
1434  * Offsets for the video overlay registers
1435  */
1436 
1437 enum {
1438    SVGA_VIDEO_ENABLED = 0,
1439    SVGA_VIDEO_FLAGS,
1440    SVGA_VIDEO_DATA_OFFSET,
1441    SVGA_VIDEO_FORMAT,
1442    SVGA_VIDEO_COLORKEY,
1443    SVGA_VIDEO_SIZE,          /* Deprecated */
1444    SVGA_VIDEO_WIDTH,
1445    SVGA_VIDEO_HEIGHT,
1446    SVGA_VIDEO_SRC_X,
1447    SVGA_VIDEO_SRC_Y,
1448    SVGA_VIDEO_SRC_WIDTH,
1449    SVGA_VIDEO_SRC_HEIGHT,
1450    SVGA_VIDEO_DST_X,         /* Signed int32 */
1451    SVGA_VIDEO_DST_Y,         /* Signed int32 */
1452    SVGA_VIDEO_DST_WIDTH,
1453    SVGA_VIDEO_DST_HEIGHT,
1454    SVGA_VIDEO_PITCH_1,
1455    SVGA_VIDEO_PITCH_2,
1456    SVGA_VIDEO_PITCH_3,
1457    SVGA_VIDEO_DATA_GMRID,    /* Optional, defaults to SVGA_GMR_FRAMEBUFFER */
1458    SVGA_VIDEO_DST_SCREEN_ID, /* Optional, defaults to virtual coords */
1459                              /* (SVGA_ID_INVALID) */
1460    SVGA_VIDEO_NUM_REGS
1461 };
1462 
1463 
1464 /*
1465  * SVGA Overlay Units
1466  *
1467  *      width and height relate to the entire source video frame.
1468  *      srcX, srcY, srcWidth and srcHeight represent subset of the source
1469  *      video frame to be displayed.
1470  */
1471 
1472 typedef
1473 #include "vmware_pack_begin.h"
1474 struct SVGAOverlayUnit {
1475    uint32 enabled;
1476    uint32 flags;
1477    uint32 dataOffset;
1478    uint32 format;
1479    uint32 colorKey;
1480    uint32 size;
1481    uint32 width;
1482    uint32 height;
1483    uint32 srcX;
1484    uint32 srcY;
1485    uint32 srcWidth;
1486    uint32 srcHeight;
1487    int32  dstX;
1488    int32  dstY;
1489    uint32 dstWidth;
1490    uint32 dstHeight;
1491    uint32 pitches[3];
1492    uint32 dataGMRId;
1493    uint32 dstScreenId;
1494 }
1495 #include "vmware_pack_end.h"
1496 SVGAOverlayUnit;
1497 
1498 
1499 /*
1500  * Guest display topology
1501  *
1502  * XXX: This structure is not part of the SVGA device's interface, and
1503  * doesn't really belong here.
1504  */
1505 #define SVGA_INVALID_DISPLAY_ID ((uint32)-1)
1506 
1507 typedef struct SVGADisplayTopology {
1508    uint16 displayId;
1509    uint16 isPrimary;
1510    uint32 width;
1511    uint32 height;
1512    uint32 positionX;
1513    uint32 positionY;
1514 } SVGADisplayTopology;
1515 
1516 
1517 /*
1518  * SVGAScreenObject --
1519  *
1520  *    This is a new way to represent a guest's multi-monitor screen or
1521  *    Unity window. Screen objects are only supported if the
1522  *    SVGA_FIFO_CAP_SCREEN_OBJECT capability bit is set.
1523  *
1524  *    If Screen Objects are supported, they can be used to fully
1525  *    replace the functionality provided by the framebuffer registers
1526  *    (SVGA_REG_WIDTH, HEIGHT, etc.) and by SVGA_CAP_DISPLAY_TOPOLOGY.
1527  *
1528  *    The screen object is a struct with guaranteed binary
1529  *    compatibility. New flags can be added, and the struct may grow,
1530  *    but existing fields must retain their meaning.
1531  *
1532  *    Added with SVGA_FIFO_CAP_SCREEN_OBJECT_2 are required fields of
1533  *    a SVGAGuestPtr that is used to back the screen contents.  This
1534  *    memory must come from the GFB.  The guest is not allowed to
1535  *    access the memory and doing so will have undefined results.  The
1536  *    backing store is required to be page aligned and the size is
1537  *    padded to the next page boundry.  The number of pages is:
1538  *       (bytesPerLine * size.width * 4 + PAGE_SIZE - 1) / PAGE_SIZE
1539  *
1540  *    The pitch in the backingStore is required to be at least large
1541  *    enough to hold a 32bbp scanline.  It is recommended that the
1542  *    driver pad bytesPerLine for a potential performance win.
1543  *
1544  *    The cloneCount field is treated as a hint from the guest that
1545  *    the user wants this display to be cloned, countCount times.  A
1546  *    value of zero means no cloning should happen.
1547  */
1548 
1549 #define SVGA_SCREEN_MUST_BE_SET     (1 << 0)
1550 #define SVGA_SCREEN_HAS_ROOT SVGA_SCREEN_MUST_BE_SET /* Deprecated */
1551 #define SVGA_SCREEN_IS_PRIMARY      (1 << 1)
1552 #define SVGA_SCREEN_FULLSCREEN_HINT (1 << 2)
1553 
1554 /*
1555  * Added with SVGA_FIFO_CAP_SCREEN_OBJECT_2.  When the screen is
1556  * deactivated the base layer is defined to lose all contents and
1557  * become black.  When a screen is deactivated the backing store is
1558  * optional.  When set backingPtr and bytesPerLine will be ignored.
1559  */
1560 #define SVGA_SCREEN_DEACTIVATE  (1 << 3)
1561 
1562 /*
1563  * Added with SVGA_FIFO_CAP_SCREEN_OBJECT_2.  When this flag is set
1564  * the screen contents will be outputted as all black to the user
1565  * though the base layer contents is preserved.  The screen base layer
1566  * can still be read and written to like normal though the no visible
1567  * effect will be seen by the user.  When the flag is changed the
1568  * screen will be blanked or redrawn to the current contents as needed
1569  * without any extra commands from the driver.  This flag only has an
1570  * effect when the screen is not deactivated.
1571  */
1572 #define SVGA_SCREEN_BLANKING (1 << 4)
1573 
1574 typedef
1575 #include "vmware_pack_begin.h"
1576 struct {
1577    uint32 structSize;   /* sizeof(SVGAScreenObject) */
1578    uint32 id;
1579    uint32 flags;
1580    struct {
1581       uint32 width;
1582       uint32 height;
1583    } size;
1584    struct {
1585       int32 x;
1586       int32 y;
1587    } root;
1588 
1589    /*
1590     * Added and required by SVGA_FIFO_CAP_SCREEN_OBJECT_2, optional
1591     * with SVGA_FIFO_CAP_SCREEN_OBJECT.
1592     */
1593    SVGAGuestImage backingStore;
1594 
1595    /*
1596     * The cloneCount field is treated as a hint from the guest that
1597     * the user wants this display to be cloned, cloneCount times.
1598     *
1599     * A value of zero means no cloning should happen.
1600     */
1601    uint32 cloneCount;
1602 }
1603 #include "vmware_pack_end.h"
1604 SVGAScreenObject;
1605 
1606 
1607 /*
1608  *  Commands in the command FIFO:
1609  *
1610  *  Command IDs defined below are used for the traditional 2D FIFO
1611  *  communication (not all commands are available for all versions of the
1612  *  SVGA FIFO protocol).
1613  *
1614  *  Note the holes in the command ID numbers: These commands have been
1615  *  deprecated, and the old IDs must not be reused.
1616  *
1617  *  Command IDs from 1000 to 2999 are reserved for use by the SVGA3D
1618  *  protocol.
1619  *
1620  *  Each command's parameters are described by the comments and
1621  *  structs below.
1622  */
1623 
1624 typedef enum {
1625    SVGA_CMD_INVALID_CMD           = 0,
1626    SVGA_CMD_UPDATE                = 1,
1627    SVGA_CMD_RECT_COPY             = 3,
1628    SVGA_CMD_RECT_ROP_COPY         = 14,
1629    SVGA_CMD_DEFINE_CURSOR         = 19,
1630    SVGA_CMD_DEFINE_ALPHA_CURSOR   = 22,
1631    SVGA_CMD_UPDATE_VERBOSE        = 25,
1632    SVGA_CMD_FRONT_ROP_FILL        = 29,
1633    SVGA_CMD_FENCE                 = 30,
1634    SVGA_CMD_ESCAPE                = 33,
1635    SVGA_CMD_DEFINE_SCREEN         = 34,
1636    SVGA_CMD_DESTROY_SCREEN        = 35,
1637    SVGA_CMD_DEFINE_GMRFB          = 36,
1638    SVGA_CMD_BLIT_GMRFB_TO_SCREEN  = 37,
1639    SVGA_CMD_BLIT_SCREEN_TO_GMRFB  = 38,
1640    SVGA_CMD_ANNOTATION_FILL       = 39,
1641    SVGA_CMD_ANNOTATION_COPY       = 40,
1642    SVGA_CMD_DEFINE_GMR2           = 41,
1643    SVGA_CMD_REMAP_GMR2            = 42,
1644    SVGA_CMD_DEAD                  = 43,
1645    SVGA_CMD_DEAD_2                = 44,
1646    SVGA_CMD_NOP                   = 45,
1647    SVGA_CMD_NOP_ERROR             = 46,
1648    SVGA_CMD_MAX
1649 } SVGAFifoCmdId;
1650 
1651 #define SVGA_CMD_MAX_DATASIZE       (256 * 1024)
1652 #define SVGA_CMD_MAX_ARGS           64
1653 
1654 
1655 /*
1656  * SVGA_CMD_UPDATE --
1657  *
1658  *    This is a DMA transfer which copies from the Guest Framebuffer
1659  *    (GFB) at BAR1 + SVGA_REG_FB_OFFSET to any screens which
1660  *    intersect with the provided virtual rectangle.
1661  *
1662  *    This command does not support using arbitrary guest memory as a
1663  *    data source- it only works with the pre-defined GFB memory.
1664  *    This command also does not support signed virtual coordinates.
1665  *    If you have defined screens (using SVGA_CMD_DEFINE_SCREEN) with
1666  *    negative root x/y coordinates, the negative portion of those
1667  *    screens will not be reachable by this command.
1668  *
1669  *    This command is not necessary when using framebuffer
1670  *    traces. Traces are automatically enabled if the SVGA FIFO is
1671  *    disabled, and you may explicitly enable/disable traces using
1672  *    SVGA_REG_TRACES. With traces enabled, any write to the GFB will
1673  *    automatically act as if a subsequent SVGA_CMD_UPDATE was issued.
1674  *
1675  *    Traces and SVGA_CMD_UPDATE are the only supported ways to render
1676  *    pseudocolor screen updates. The newer Screen Object commands
1677  *    only support true color formats.
1678  *
1679  * Availability:
1680  *    Always available.
1681  */
1682 
1683 typedef
1684 #include "vmware_pack_begin.h"
1685 struct {
1686    uint32 x;
1687    uint32 y;
1688    uint32 width;
1689    uint32 height;
1690 }
1691 #include "vmware_pack_end.h"
1692 SVGAFifoCmdUpdate;
1693 
1694 
1695 /*
1696  * SVGA_CMD_RECT_COPY --
1697  *
1698  *    Perform a rectangular DMA transfer from one area of the GFB to
1699  *    another, and copy the result to any screens which intersect it.
1700  *
1701  * Availability:
1702  *    SVGA_CAP_RECT_COPY
1703  */
1704 
1705 typedef
1706 #include "vmware_pack_begin.h"
1707 struct {
1708    uint32 srcX;
1709    uint32 srcY;
1710    uint32 destX;
1711    uint32 destY;
1712    uint32 width;
1713    uint32 height;
1714 }
1715 #include "vmware_pack_end.h"
1716 SVGAFifoCmdRectCopy;
1717 
1718 
1719 /*
1720  * SVGA_CMD_RECT_ROP_COPY --
1721  *
1722  *    Perform a rectangular DMA transfer from one area of the GFB to
1723  *    another, and copy the result to any screens which intersect it.
1724  *    The value of ROP may only be SVGA_ROP_COPY, and this command is
1725  *    only supported for backwards compatibility reasons.
1726  *
1727  * Availability:
1728  *    SVGA_CAP_RECT_COPY
1729  */
1730 
1731 typedef
1732 #include "vmware_pack_begin.h"
1733 struct {
1734    uint32 srcX;
1735    uint32 srcY;
1736    uint32 destX;
1737    uint32 destY;
1738    uint32 width;
1739    uint32 height;
1740    uint32 rop;
1741 }
1742 #include "vmware_pack_end.h"
1743 SVGAFifoCmdRectRopCopy;
1744 
1745 
1746 /*
1747  * SVGA_CMD_DEFINE_CURSOR --
1748  *
1749  *    Provide a new cursor image, as an AND/XOR mask.
1750  *
1751  *    The recommended way to position the cursor overlay is by using
1752  *    the SVGA_FIFO_CURSOR_* registers, supported by the
1753  *    SVGA_FIFO_CAP_CURSOR_BYPASS_3 capability.
1754  *
1755  * Availability:
1756  *    SVGA_CAP_CURSOR
1757  */
1758 
1759 typedef
1760 #include "vmware_pack_begin.h"
1761 struct {
1762    uint32 id;             /* Reserved, must be zero. */
1763    uint32 hotspotX;
1764    uint32 hotspotY;
1765    uint32 width;
1766    uint32 height;
1767    uint32 andMaskDepth;   /* Value must be 1 or equal to BITS_PER_PIXEL */
1768    uint32 xorMaskDepth;   /* Value must be 1 or equal to BITS_PER_PIXEL */
1769    /*
1770     * Followed by scanline data for AND mask, then XOR mask.
1771     * Each scanline is padded to a 32-bit boundary.
1772    */
1773 }
1774 #include "vmware_pack_end.h"
1775 SVGAFifoCmdDefineCursor;
1776 
1777 
1778 /*
1779  * SVGA_CMD_DEFINE_ALPHA_CURSOR --
1780  *
1781  *    Provide a new cursor image, in 32-bit BGRA format.
1782  *
1783  *    The recommended way to position the cursor overlay is by using
1784  *    the SVGA_FIFO_CURSOR_* registers, supported by the
1785  *    SVGA_FIFO_CAP_CURSOR_BYPASS_3 capability.
1786  *
1787  * Availability:
1788  *    SVGA_CAP_ALPHA_CURSOR
1789  */
1790 
1791 typedef
1792 #include "vmware_pack_begin.h"
1793 struct {
1794    uint32 id;             /* Reserved, must be zero. */
1795    uint32 hotspotX;
1796    uint32 hotspotY;
1797    uint32 width;
1798    uint32 height;
1799    /* Followed by scanline data */
1800 }
1801 #include "vmware_pack_end.h"
1802 SVGAFifoCmdDefineAlphaCursor;
1803 
1804 
1805 /*
1806  *    Provide a new large cursor image, as an AND/XOR mask.
1807  *
1808  *    Should only be used for CursorMob functionality
1809  */
1810 
1811 typedef
1812 #include "vmware_pack_begin.h"
1813 struct {
1814    uint32 hotspotX;
1815    uint32 hotspotY;
1816    uint32 width;
1817    uint32 height;
1818    uint32 andMaskDepth;
1819    uint32 xorMaskDepth;
1820    /*
1821     * Followed by scanline data for AND mask, then XOR mask.
1822     * Each scanline is padded to a 32-bit boundary.
1823    */
1824 }
1825 #include "vmware_pack_end.h"
1826 SVGAGBColorCursorHeader;
1827 
1828 
1829 /*
1830  *    Provide a new large cursor image, in 32-bit BGRA format.
1831  *
1832  *    Should only be used for CursorMob functionality
1833  */
1834 
1835 typedef
1836 #include "vmware_pack_begin.h"
1837 struct {
1838    uint32 hotspotX;
1839    uint32 hotspotY;
1840    uint32 width;
1841    uint32 height;
1842    /* Followed by scanline data */
1843 }
1844 #include "vmware_pack_end.h"
1845 SVGAGBAlphaCursorHeader;
1846 
1847  /*
1848   * Define the SVGA guest backed cursor types
1849   */
1850 
1851 typedef enum {
1852    SVGA_COLOR_CURSOR       = 0,
1853    SVGA_ALPHA_CURSOR       = 1,
1854 } SVGAGBCursorType;
1855 
1856 /*
1857  *    Provide a new large cursor image.
1858  *
1859  *    Should only be used for CursorMob functionality
1860  */
1861 
1862 typedef
1863 #include "vmware_pack_begin.h"
1864 struct {
1865    SVGAGBCursorType type;
1866    union {
1867       SVGAGBColorCursorHeader colorHeader;
1868       SVGAGBAlphaCursorHeader alphaHeader;
1869    } header;
1870    uint32 sizeInBytes;
1871    /*
1872     * Followed by the cursor data
1873     */
1874 }
1875 #include "vmware_pack_end.h"
1876 SVGAGBCursorHeader;
1877 
1878 
1879 /*
1880  * SVGA_CMD_UPDATE_VERBOSE --
1881  *
1882  *    Just like SVGA_CMD_UPDATE, but also provide a per-rectangle
1883  *    'reason' value, an opaque cookie which is used by internal
1884  *    debugging tools. Third party drivers should not use this
1885  *    command.
1886  *
1887  * Availability:
1888  *    SVGA_CAP_EXTENDED_FIFO
1889  */
1890 
1891 typedef
1892 #include "vmware_pack_begin.h"
1893 struct {
1894    uint32 x;
1895    uint32 y;
1896    uint32 width;
1897    uint32 height;
1898    uint32 reason;
1899 }
1900 #include "vmware_pack_end.h"
1901 SVGAFifoCmdUpdateVerbose;
1902 
1903 
1904 /*
1905  * SVGA_CMD_FRONT_ROP_FILL --
1906  *
1907  *    This is a hint which tells the SVGA device that the driver has
1908  *    just filled a rectangular region of the GFB with a solid
1909  *    color. Instead of reading these pixels from the GFB, the device
1910  *    can assume that they all equal 'color'. This is primarily used
1911  *    for remote desktop protocols.
1912  *
1913  * Availability:
1914  *    SVGA_FIFO_CAP_ACCELFRONT
1915  */
1916 
1917 #define  SVGA_ROP_COPY                    0x03
1918 
1919 typedef
1920 #include "vmware_pack_begin.h"
1921 struct {
1922    uint32 color;     /* In the same format as the GFB */
1923    uint32 x;
1924    uint32 y;
1925    uint32 width;
1926    uint32 height;
1927    uint32 rop;       /* Must be SVGA_ROP_COPY */
1928 }
1929 #include "vmware_pack_end.h"
1930 SVGAFifoCmdFrontRopFill;
1931 
1932 
1933 /*
1934  * SVGA_CMD_FENCE --
1935  *
1936  *    Insert a synchronization fence.  When the SVGA device reaches
1937  *    this command, it will copy the 'fence' value into the
1938  *    SVGA_FIFO_FENCE register. It will also compare the fence against
1939  *    SVGA_FIFO_FENCE_GOAL. If the fence matches the goal and the
1940  *    SVGA_IRQFLAG_FENCE_GOAL interrupt is enabled, the device will
1941  *    raise this interrupt.
1942  *
1943  * Availability:
1944  *    SVGA_FIFO_FENCE for this command,
1945  *    SVGA_CAP_IRQMASK for SVGA_FIFO_FENCE_GOAL.
1946  */
1947 
1948 typedef
1949 #include "vmware_pack_begin.h"
1950 struct {
1951    uint32 fence;
1952 }
1953 #include "vmware_pack_end.h"
1954 SVGAFifoCmdFence;
1955 
1956 
1957 /*
1958  * SVGA_CMD_ESCAPE --
1959  *
1960  *    Send an extended or vendor-specific variable length command.
1961  *    This is used for video overlay, third party plugins, and
1962  *    internal debugging tools. See svga_escape.h
1963  *
1964  * Availability:
1965  *    SVGA_FIFO_CAP_ESCAPE
1966  */
1967 
1968 typedef
1969 #include "vmware_pack_begin.h"
1970 struct {
1971    uint32 nsid;
1972    uint32 size;
1973    /* followed by 'size' bytes of data */
1974 }
1975 #include "vmware_pack_end.h"
1976 SVGAFifoCmdEscape;
1977 
1978 
1979 /*
1980  * SVGA_CMD_DEFINE_SCREEN --
1981  *
1982  *    Define or redefine an SVGAScreenObject. See the description of
1983  *    SVGAScreenObject above.  The video driver is responsible for
1984  *    generating new screen IDs. They should be small positive
1985  *    integers. The virtual device will have an implementation
1986  *    specific upper limit on the number of screen IDs
1987  *    supported. Drivers are responsible for recycling IDs. The first
1988  *    valid ID is zero.
1989  *
1990  *    - Interaction with other registers:
1991  *
1992  *    For backwards compatibility, when the GFB mode registers (WIDTH,
1993  *    HEIGHT, PITCHLOCK, BITS_PER_PIXEL) are modified, the SVGA device
1994  *    deletes all screens other than screen #0, and redefines screen
1995  *    #0 according to the specified mode. Drivers that use
1996  *    SVGA_CMD_DEFINE_SCREEN should destroy or redefine screen #0.
1997  *
1998  *    If you use screen objects, do not use the legacy multi-mon
1999  *    registers (SVGA_REG_NUM_GUEST_DISPLAYS, SVGA_REG_DISPLAY_*).
2000  *
2001  * Availability:
2002  *    SVGA_FIFO_CAP_SCREEN_OBJECT or SVGA_FIFO_CAP_SCREEN_OBJECT_2
2003  */
2004 
2005 typedef
2006 #include "vmware_pack_begin.h"
2007 struct {
2008    SVGAScreenObject screen;   /* Variable-length according to version */
2009 }
2010 #include "vmware_pack_end.h"
2011 SVGAFifoCmdDefineScreen;
2012 
2013 
2014 /*
2015  * SVGA_CMD_DESTROY_SCREEN --
2016  *
2017  *    Destroy an SVGAScreenObject. Its ID is immediately available for
2018  *    re-use.
2019  *
2020  * Availability:
2021  *    SVGA_FIFO_CAP_SCREEN_OBJECT or SVGA_FIFO_CAP_SCREEN_OBJECT_2
2022  */
2023 
2024 typedef
2025 #include "vmware_pack_begin.h"
2026 struct {
2027    uint32 screenId;
2028 }
2029 #include "vmware_pack_end.h"
2030 SVGAFifoCmdDestroyScreen;
2031 
2032 
2033 /*
2034  * SVGA_CMD_DEFINE_GMRFB --
2035  *
2036  *    This command sets a piece of SVGA device state called the
2037  *    Guest Memory Region Framebuffer, or GMRFB. The GMRFB is a
2038  *    piece of light-weight state which identifies the location and
2039  *    format of an image in guest memory or in BAR1. The GMRFB has
2040  *    an arbitrary size, and it doesn't need to match the geometry
2041  *    of the GFB or any screen object.
2042  *
2043  *    The GMRFB can be redefined as often as you like. You could
2044  *    always use the same GMRFB, you could redefine it before
2045  *    rendering from a different guest screen, or you could even
2046  *    redefine it before every blit.
2047  *
2048  *    There are multiple ways to use this command. The simplest way is
2049  *    to use it to move the framebuffer either to elsewhere in the GFB
2050  *    (BAR1) memory region, or to a user-defined GMR. This lets a
2051  *    driver use a framebuffer allocated entirely out of normal system
2052  *    memory, which we encourage.
2053  *
2054  *    Another way to use this command is to set up a ring buffer of
2055  *    updates in GFB memory. If a driver wants to ensure that no
2056  *    frames are skipped by the SVGA device, it is important that the
2057  *    driver not modify the source data for a blit until the device is
2058  *    done processing the command. One efficient way to accomplish
2059  *    this is to use a ring of small DMA buffers. Each buffer is used
2060  *    for one blit, then we move on to the next buffer in the
2061  *    ring. The FENCE mechanism is used to protect each buffer from
2062  *    re-use until the device is finished with that buffer's
2063  *    corresponding blit.
2064  *
2065  *    This command does not affect the meaning of SVGA_CMD_UPDATE.
2066  *    UPDATEs always occur from the legacy GFB memory area. This
2067  *    command has no support for pseudocolor GMRFBs. Currently only
2068  *    true-color 15, 16, and 24-bit depths are supported. Future
2069  *    devices may expose capabilities for additional framebuffer
2070  *    formats.
2071  *
2072  *    The default GMRFB value is undefined. Drivers must always send
2073  *    this command at least once before performing any blit from the
2074  *    GMRFB.
2075  *
2076  * Availability:
2077  *    SVGA_FIFO_CAP_SCREEN_OBJECT or SVGA_FIFO_CAP_SCREEN_OBJECT_2
2078  */
2079 
2080 typedef
2081 #include "vmware_pack_begin.h"
2082 struct {
2083    SVGAGuestPtr        ptr;
2084    uint32              bytesPerLine;
2085    SVGAGMRImageFormat  format;
2086 }
2087 #include "vmware_pack_end.h"
2088 SVGAFifoCmdDefineGMRFB;
2089 
2090 
2091 /*
2092  * SVGA_CMD_BLIT_GMRFB_TO_SCREEN --
2093  *
2094  *    This is a guest-to-host blit. It performs a DMA operation to
2095  *    copy a rectangular region of pixels from the current GMRFB to
2096  *    a ScreenObject.
2097  *
2098  *    The destination coordinate may be specified relative to a
2099  *    screen's origin.  The provided screen ID must be valid.
2100  *
2101  *    The SVGA device is guaranteed to finish reading from the GMRFB
2102  *    by the time any subsequent FENCE commands are reached.
2103  *
2104  *    This command consumes an annotation. See the
2105  *    SVGA_CMD_ANNOTATION_* commands for details.
2106  *
2107  * Availability:
2108  *    SVGA_FIFO_CAP_SCREEN_OBJECT or SVGA_FIFO_CAP_SCREEN_OBJECT_2
2109  */
2110 
2111 typedef
2112 #include "vmware_pack_begin.h"
2113 struct {
2114    SVGASignedPoint  srcOrigin;
2115    SVGASignedRect   destRect;
2116    uint32           destScreenId;
2117 }
2118 #include "vmware_pack_end.h"
2119 SVGAFifoCmdBlitGMRFBToScreen;
2120 
2121 
2122 /*
2123  * SVGA_CMD_BLIT_SCREEN_TO_GMRFB --
2124  *
2125  *    This is a host-to-guest blit. It performs a DMA operation to
2126  *    copy a rectangular region of pixels from a single ScreenObject
2127  *    back to the current GMRFB.
2128  *
2129  *    The source coordinate is specified relative to a screen's
2130  *    origin.  The provided screen ID must be valid. If any parameters
2131  *    are invalid, the resulting pixel values are undefined.
2132  *
2133  *    The SVGA device is guaranteed to finish writing to the GMRFB by
2134  *    the time any subsequent FENCE commands are reached.
2135  *
2136  * Availability:
2137  *    SVGA_FIFO_CAP_SCREEN_OBJECT or SVGA_FIFO_CAP_SCREEN_OBJECT_2
2138  */
2139 
2140 typedef
2141 #include "vmware_pack_begin.h"
2142 struct {
2143    SVGASignedPoint  destOrigin;
2144    SVGASignedRect   srcRect;
2145    uint32           srcScreenId;
2146 }
2147 #include "vmware_pack_end.h"
2148 SVGAFifoCmdBlitScreenToGMRFB;
2149 
2150 
2151 /*
2152  * SVGA_CMD_ANNOTATION_FILL --
2153  *
2154  *    The annotation commands have been deprecated, should not be used
2155  *    by new drivers.  They used to provide performance hints to the SVGA
2156  *    device about the content of screen updates, but newer SVGA devices
2157  *    ignore these.
2158  *
2159  * Availability:
2160  *    SVGA_FIFO_CAP_SCREEN_OBJECT or SVGA_FIFO_CAP_SCREEN_OBJECT_2
2161  */
2162 
2163 typedef
2164 #include "vmware_pack_begin.h"
2165 struct {
2166    SVGAColorBGRX  color;
2167 }
2168 #include "vmware_pack_end.h"
2169 SVGAFifoCmdAnnotationFill;
2170 
2171 
2172 /*
2173  * SVGA_CMD_ANNOTATION_COPY --
2174  *
2175  *    The annotation commands have been deprecated, should not be used
2176  *    by new drivers.  They used to provide performance hints to the SVGA
2177  *    device about the content of screen updates, but newer SVGA devices
2178  *    ignore these.
2179  *
2180  * Availability:
2181  *    SVGA_FIFO_CAP_SCREEN_OBJECT or SVGA_FIFO_CAP_SCREEN_OBJECT_2
2182  */
2183 
2184 typedef
2185 #include "vmware_pack_begin.h"
2186 struct {
2187    SVGASignedPoint  srcOrigin;
2188    uint32           srcScreenId;
2189 }
2190 #include "vmware_pack_end.h"
2191 SVGAFifoCmdAnnotationCopy;
2192 
2193 
2194 /*
2195  * SVGA_CMD_DEFINE_GMR2 --
2196  *
2197  *    Define guest memory region v2.  See the description of GMRs above.
2198  *
2199  * Availability:
2200  *    SVGA_CAP_GMR2
2201  */
2202 
2203 typedef
2204 #include "vmware_pack_begin.h"
2205 struct {
2206    uint32 gmrId;
2207    uint32 numPages;
2208 }
2209 #include "vmware_pack_end.h"
2210 SVGAFifoCmdDefineGMR2;
2211 
2212 
2213 /*
2214  * SVGA_CMD_REMAP_GMR2 --
2215  *
2216  *    Remap guest memory region v2.  See the description of GMRs above.
2217  *
2218  *    This command allows guest to modify a portion of an existing GMR by
2219  *    invalidating it or reassigning it to different guest physical pages.
2220  *    The pages are identified by physical page number (PPN).  The pages
2221  *    are assumed to be pinned and valid for DMA operations.
2222  *
2223  *    Description of command flags:
2224  *
2225  *    SVGA_REMAP_GMR2_VIA_GMR: If enabled, references a PPN list in a GMR.
2226  *       The PPN list must not overlap with the remap region (this can be
2227  *       handled trivially by referencing a separate GMR).  If flag is
2228  *       disabled, PPN list is appended to SVGARemapGMR command.
2229  *
2230  *    SVGA_REMAP_GMR2_PPN64: If set, PPN list is in PPN64 format, otherwise
2231  *       it is in PPN32 format.
2232  *
2233  *    SVGA_REMAP_GMR2_SINGLE_PPN: If set, PPN list contains a single entry.
2234  *       A single PPN can be used to invalidate a portion of a GMR or
2235  *       map it to to a single guest scratch page.
2236  *
2237  * Availability:
2238  *    SVGA_CAP_GMR2
2239  */
2240 
2241 typedef enum {
2242    SVGA_REMAP_GMR2_PPN32         = 0,
2243    SVGA_REMAP_GMR2_VIA_GMR       = (1 << 0),
2244    SVGA_REMAP_GMR2_PPN64         = (1 << 1),
2245    SVGA_REMAP_GMR2_SINGLE_PPN    = (1 << 2),
2246 } SVGARemapGMR2Flags;
2247 
2248 typedef
2249 #include "vmware_pack_begin.h"
2250 struct {
2251    uint32 gmrId;
2252    SVGARemapGMR2Flags flags;
2253    uint32 offsetPages; /* offset in pages to begin remap */
2254    uint32 numPages; /* number of pages to remap */
2255    /*
2256     * Followed by additional data depending on SVGARemapGMR2Flags.
2257     *
2258     * If flag SVGA_REMAP_GMR2_VIA_GMR is set, single SVGAGuestPtr follows.
2259     * Otherwise an array of page descriptors in PPN32 or PPN64 format
2260     * (according to flag SVGA_REMAP_GMR2_PPN64) follows.  If flag
2261     * SVGA_REMAP_GMR2_SINGLE_PPN is set, array contains a single entry.
2262     */
2263 }
2264 #include "vmware_pack_end.h"
2265 SVGAFifoCmdRemapGMR2;
2266 
2267 
2268 /*
2269  * Size of SVGA device memory such as frame buffer and FIFO.
2270  */
2271 #define SVGA_VRAM_MIN_SIZE             (4 * 640 * 480) /* bytes */
2272 #define SVGA_VRAM_MIN_SIZE_3D       (16 * 1024 * 1024)
2273 #define SVGA_VRAM_MAX_SIZE         (128 * 1024 * 1024)
2274 #define SVGA_MEMORY_SIZE_MAX      (1024 * 1024 * 1024)
2275 #define SVGA_FIFO_SIZE_MAX           (2 * 1024 * 1024)
2276 #define SVGA_GRAPHICS_MEMORY_KB_MIN     (32 * 1024)
2277 #define SVGA_GRAPHICS_MEMORY_KB_MAX_2GB (2 * 1024 * 1024)
2278 #define SVGA_GRAPHICS_MEMORY_KB_MAX_3GB (3 * 1024 * 1024)
2279 #define SVGA_GRAPHICS_MEMORY_KB_MAX_4GB (4 * 1024 * 1024)
2280 #define SVGA_GRAPHICS_MEMORY_KB_MAX_8GB (8 * 1024 * 1024)
2281 #define SVGA_GRAPHICS_MEMORY_KB_DEFAULT (256 * 1024)
2282 
2283 #define SVGA_VRAM_SIZE_W2K          (64 * 1024 * 1024) /* 64 MB */
2284 
2285 #if defined(VMX86_SERVER)
2286 #define SVGA_VRAM_SIZE               (4 * 1024 * 1024)
2287 #define SVGA_VRAM_SIZE_3D           (64 * 1024 * 1024)
2288 #define SVGA_FIFO_SIZE                    (256 * 1024)
2289 #define SVGA_FIFO_SIZE_3D                 (516 * 1024)
2290 #define SVGA_MEMORY_SIZE_DEFAULT   (160 * 1024 * 1024)
2291 #define SVGA_AUTODETECT_DEFAULT                  FALSE
2292 #else
2293 #define SVGA_VRAM_SIZE              (16 * 1024 * 1024)
2294 #define SVGA_VRAM_SIZE_3D           SVGA_VRAM_MAX_SIZE
2295 #define SVGA_FIFO_SIZE               (2 * 1024 * 1024)
2296 #define SVGA_FIFO_SIZE_3D               SVGA_FIFO_SIZE
2297 #define SVGA_MEMORY_SIZE_DEFAULT   (768 * 1024 * 1024)
2298 #define SVGA_AUTODETECT_DEFAULT                   TRUE
2299 #endif
2300 
2301 #define SVGA_FIFO_SIZE_GBOBJECTS          (256 * 1024)
2302 #define SVGA_VRAM_SIZE_GBOBJECTS     (4 * 1024 * 1024)
2303 
2304 #define SVGA_PCI_REGS_PAGES                        (1)
2305 
2306 #endif
2307