VirtualBox

source: vbox/trunk/src/VBox/Devices/Graphics/vmsvga_include/svga_reg.h@ 104786

Last change on this file since 104786 was 104786, checked in by vboxsync, 6 months ago

Main: Added a new include VBox/graphics.h to avoid dragging in a lot of other includes not needed in Main. bugref:​10693

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette