VirtualBox

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

Last change on this file since 100690 was 100690, checked in by vboxsync, 19 months ago

Devices/Graphics: Add support for the SVGA3 interface required for ARM, bugref:10458

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