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