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