Path: blob/21.2-virgl/src/gallium/drivers/svga/include/svga_reg.h
4574 views
/**********************************************************1* Copyright 1998-2015 VMware, Inc. All rights reserved.2*3* Permission is hereby granted, free of charge, to any person4* obtaining a copy of this software and associated documentation5* files (the "Software"), to deal in the Software without6* restriction, including without limitation the rights to use, copy,7* modify, merge, publish, distribute, sublicense, and/or sell copies8* of the Software, and to permit persons to whom the Software is9* furnished to do so, subject to the following conditions:10*11* The above copyright notice and this permission notice shall be12* included in all copies or substantial portions of the Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,15* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF16* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND17* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS18* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN19* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN20* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE21* SOFTWARE.22*23**********************************************************/2425/*26* svga_reg.h --27*28* Virtual hardware definitions for the VMware SVGA II device.29*/3031#ifndef _SVGA_REG_H_32#define _SVGA_REG_H_3334#include "svga_types.h"3536/*37* SVGA_REG_ENABLE bit definitions.38*/39typedef enum {40SVGA_REG_ENABLE_DISABLE = 0,41SVGA_REG_ENABLE_ENABLE = (1 << 0),42SVGA_REG_ENABLE_HIDE = (1 << 1),43} SvgaRegEnable;4445typedef uint32 SVGAMobId;4647/*48* Arbitrary and meaningless limits. Please ignore these when writing49* new drivers.50*/51#define SVGA_MAX_WIDTH 256052#define SVGA_MAX_HEIGHT 160053#define SVGA_MAX_BITS_PER_PIXEL 3254#define SVGA_MAX_DEPTH 2455#define SVGA_MAX_DISPLAYS 105657/*58* Legal values for the SVGA_REG_CURSOR_ON register in old-fashioned59* cursor bypass mode. This is still supported, but no new guest60* drivers should use it.61*/62#define SVGA_CURSOR_ON_HIDE 0x0 /* Must be 0 to maintain backward compatibility */63#define SVGA_CURSOR_ON_SHOW 0x1 /* Must be 1 to maintain backward compatibility */64#define SVGA_CURSOR_ON_REMOVE_FROM_FB 0x2 /* Remove the cursor from the framebuffer because we need to see what's under it */65#define SVGA_CURSOR_ON_RESTORE_TO_FB 0x3 /* Put the cursor back in the framebuffer so the user can see it */6667/*68* The maximum framebuffer size that can traced for e.g. guests in VESA mode.69* The changeMap in the monitor is proportional to this number. Therefore, we'd70* like to keep it as small as possible to reduce monitor overhead (using71* SVGA_VRAM_MAX_SIZE for this increases the size of the shared area by over72* 4k!).73*74* NB: For compatibility reasons, this value must be greater than 0xff0000.75* See bug 335072.76*/77#define SVGA_FB_MAX_TRACEABLE_SIZE 0x10000007879#define SVGA_MAX_PSEUDOCOLOR_DEPTH 880#define SVGA_MAX_PSEUDOCOLORS (1 << SVGA_MAX_PSEUDOCOLOR_DEPTH)81#define SVGA_NUM_PALETTE_REGS (3 * SVGA_MAX_PSEUDOCOLORS)8283#define SVGA_MAGIC 0x900000UL84#define SVGA_MAKE_ID(ver) (SVGA_MAGIC << 8 | (ver))8586/* Version 2 let the address of the frame buffer be unsigned on Win32 */87#define SVGA_VERSION_2 288#define SVGA_ID_2 SVGA_MAKE_ID(SVGA_VERSION_2)8990/* Version 1 has new registers starting with SVGA_REG_CAPABILITIES so91PALETTE_BASE has moved */92#define SVGA_VERSION_1 193#define SVGA_ID_1 SVGA_MAKE_ID(SVGA_VERSION_1)9495/* Version 0 is the initial version */96#define SVGA_VERSION_0 097#define SVGA_ID_0 SVGA_MAKE_ID(SVGA_VERSION_0)9899/* "Invalid" value for all SVGA IDs. (Version ID, screen object ID, surface ID...) */100#define SVGA_ID_INVALID 0xFFFFFFFF101102/* Port offsets, relative to BAR0 */103#define SVGA_INDEX_PORT 0x0104#define SVGA_VALUE_PORT 0x1105#define SVGA_BIOS_PORT 0x2106#define SVGA_IRQSTATUS_PORT 0x8107108/*109* Interrupt source flags for IRQSTATUS_PORT and IRQMASK.110*111* Interrupts are only supported when the112* SVGA_CAP_IRQMASK capability is present.113*/114#define SVGA_IRQFLAG_ANY_FENCE 0x1 /* Any fence was passed */115#define SVGA_IRQFLAG_FIFO_PROGRESS 0x2 /* Made forward progress in the FIFO */116#define SVGA_IRQFLAG_FENCE_GOAL 0x4 /* SVGA_FIFO_FENCE_GOAL reached */117#define SVGA_IRQFLAG_COMMAND_BUFFER 0x8 /* Command buffer completed */118#define SVGA_IRQFLAG_ERROR 0x10 /* Error while processing commands */119120/*121* Registers122*/123124enum {125SVGA_REG_ID = 0,126SVGA_REG_ENABLE = 1,127SVGA_REG_WIDTH = 2,128SVGA_REG_HEIGHT = 3,129SVGA_REG_MAX_WIDTH = 4,130SVGA_REG_MAX_HEIGHT = 5,131SVGA_REG_DEPTH = 6,132SVGA_REG_BITS_PER_PIXEL = 7, /* Current bpp in the guest */133SVGA_REG_PSEUDOCOLOR = 8,134SVGA_REG_RED_MASK = 9,135SVGA_REG_GREEN_MASK = 10,136SVGA_REG_BLUE_MASK = 11,137SVGA_REG_BYTES_PER_LINE = 12,138SVGA_REG_FB_START = 13, /* (Deprecated) */139SVGA_REG_FB_OFFSET = 14,140SVGA_REG_VRAM_SIZE = 15,141SVGA_REG_FB_SIZE = 16,142143/* ID 0 implementation only had the above registers, then the palette */144SVGA_REG_ID_0_TOP = 17,145146SVGA_REG_CAPABILITIES = 17,147SVGA_REG_MEM_START = 18, /* (Deprecated) */148SVGA_REG_MEM_SIZE = 19,149SVGA_REG_CONFIG_DONE = 20, /* Set when memory area configured */150SVGA_REG_SYNC = 21, /* See "FIFO Synchronization Registers" */151SVGA_REG_BUSY = 22, /* See "FIFO Synchronization Registers" */152SVGA_REG_GUEST_ID = 23, /* Set guest OS identifier */153SVGA_REG_CURSOR_ID = 24, /* (Deprecated) */154SVGA_REG_CURSOR_X = 25, /* (Deprecated) */155SVGA_REG_CURSOR_Y = 26, /* (Deprecated) */156SVGA_REG_CURSOR_ON = 27, /* (Deprecated) */157SVGA_REG_HOST_BITS_PER_PIXEL = 28, /* (Deprecated) */158SVGA_REG_SCRATCH_SIZE = 29, /* Number of scratch registers */159SVGA_REG_MEM_REGS = 30, /* Number of FIFO registers */160SVGA_REG_NUM_DISPLAYS = 31, /* (Deprecated) */161SVGA_REG_PITCHLOCK = 32, /* Fixed pitch for all modes */162SVGA_REG_IRQMASK = 33, /* Interrupt mask */163164/* Legacy multi-monitor support */165SVGA_REG_NUM_GUEST_DISPLAYS = 34,/* Number of guest displays in X/Y direction */166SVGA_REG_DISPLAY_ID = 35, /* Display ID for the following display attributes */167SVGA_REG_DISPLAY_IS_PRIMARY = 36,/* Whether this is a primary display */168SVGA_REG_DISPLAY_POSITION_X = 37,/* The display position x */169SVGA_REG_DISPLAY_POSITION_Y = 38,/* The display position y */170SVGA_REG_DISPLAY_WIDTH = 39, /* The display's width */171SVGA_REG_DISPLAY_HEIGHT = 40, /* The display's height */172173/* See "Guest memory regions" below. */174SVGA_REG_GMR_ID = 41,175SVGA_REG_GMR_DESCRIPTOR = 42,176SVGA_REG_GMR_MAX_IDS = 43,177SVGA_REG_GMR_MAX_DESCRIPTOR_LENGTH = 44,178179SVGA_REG_TRACES = 45, /* Enable trace-based updates even when FIFO is on */180SVGA_REG_GMRS_MAX_PAGES = 46, /* Maximum number of 4KB pages for all GMRs */181SVGA_REG_MEMORY_SIZE = 47, /* Total dedicated device memory excluding FIFO */182SVGA_REG_COMMAND_LOW = 48, /* Lower 32 bits and submits commands */183SVGA_REG_COMMAND_HIGH = 49, /* Upper 32 bits of command buffer PA */184SVGA_REG_MAX_PRIMARY_BOUNDING_BOX_MEM = 50, /* Max primary memory */185SVGA_REG_SUGGESTED_GBOBJECT_MEM_SIZE_KB = 51, /* Suggested limit on mob mem */186SVGA_REG_DEV_CAP = 52, /* Write dev cap index, read value */187SVGA_REG_CMD_PREPEND_LOW = 53,188SVGA_REG_iCMD_PREPEND_HIGH = 54,189SVGA_REG_SCREENTARGET_MAX_WIDTH = 55,190SVGA_REG_SCREENTARGET_MAX_HEIGHT = 56,191SVGA_REG_MOB_MAX_SIZE = 57,192SVGA_REG_BLANK_SCREEN_TARGETS = 58,193SVGA_REG_CAP2 = 59,194SVGA_REG_TOP = 60, /* Must be 1 more than the last register */195196SVGA_PALETTE_BASE = 1024, /* Base of SVGA color map */197/* Next 768 (== 256*3) registers exist for colormap */198SVGA_SCRATCH_BASE = SVGA_PALETTE_BASE + SVGA_NUM_PALETTE_REGS199/* Base of scratch registers */200/* Next reg[SVGA_REG_SCRATCH_SIZE] registers exist for scratch usage:201First 4 are reserved for VESA BIOS Extension; any remaining are for202the use of the current SVGA driver. */203};204205/*206* Guest memory regions (GMRs):207*208* This is a new memory mapping feature available in SVGA devices209* which have the SVGA_CAP_GMR bit set. Previously, there were two210* fixed memory regions available with which to share data between the211* device and the driver: the FIFO ('MEM') and the framebuffer. GMRs212* are our name for an extensible way of providing arbitrary DMA213* buffers for use between the driver and the SVGA device. They are a214* new alternative to framebuffer memory, usable for both 2D and 3D215* graphics operations.216*217* Since GMR mapping must be done synchronously with guest CPU218* execution, we use a new pair of SVGA registers:219*220* SVGA_REG_GMR_ID --221*222* Read/write.223* This register holds the 32-bit ID (a small positive integer)224* of a GMR to create, delete, or redefine. Writing this register225* has no side-effects.226*227* SVGA_REG_GMR_DESCRIPTOR --228*229* Write-only.230* Writing this register will create, delete, or redefine the GMR231* specified by the above ID register. If this register is zero,232* the GMR is deleted. Any pointers into this GMR (including those233* currently being processed by FIFO commands) will be234* synchronously invalidated.235*236* If this register is nonzero, it must be the physical page237* number (PPN) of a data structure which describes the physical238* layout of the memory region this GMR should describe. The239* descriptor structure will be read synchronously by the SVGA240* device when this register is written. The descriptor need not241* remain allocated for the lifetime of the GMR.242*243* The guest driver should write SVGA_REG_GMR_ID first, then244* SVGA_REG_GMR_DESCRIPTOR.245*246* SVGA_REG_GMR_MAX_IDS --247*248* Read-only.249* The SVGA device may choose to support a maximum number of250* user-defined GMR IDs. This register holds the number of supported251* IDs. (The maximum supported ID plus 1)252*253* SVGA_REG_GMR_MAX_DESCRIPTOR_LENGTH --254*255* Read-only.256* The SVGA device may choose to put a limit on the total number257* of SVGAGuestMemDescriptor structures it will read when defining258* a single GMR.259*260* The descriptor structure is an array of SVGAGuestMemDescriptor261* structures. Each structure may do one of three things:262*263* - Terminate the GMR descriptor list.264* (ppn==0, numPages==0)265*266* - Add a PPN or range of PPNs to the GMR's virtual address space.267* (ppn != 0, numPages != 0)268*269* - Provide the PPN of the next SVGAGuestMemDescriptor, in order to270* support multi-page GMR descriptor tables without forcing the271* driver to allocate physically contiguous memory.272* (ppn != 0, numPages == 0)273*274* Note that each physical page of SVGAGuestMemDescriptor structures275* can describe at least 2MB of guest memory. If the driver needs to276* use more than one page of descriptor structures, it must use one of277* its SVGAGuestMemDescriptors to point to an additional page. The278* device will never automatically cross a page boundary.279*280* Once the driver has described a GMR, it is immediately available281* for use via any FIFO command that uses an SVGAGuestPtr structure.282* These pointers include a GMR identifier plus an offset into that283* GMR.284*285* The driver must check the SVGA_CAP_GMR bit before using the GMR286* registers.287*/288289/*290* Special GMR IDs, allowing SVGAGuestPtrs to point to framebuffer291* memory as well. In the future, these IDs could even be used to292* allow legacy memory regions to be redefined by the guest as GMRs.293*294* Using the guest framebuffer (GFB) at BAR1 for general purpose DMA295* is being phased out. Please try to use user-defined GMRs whenever296* possible.297*/298#define SVGA_GMR_NULL ((uint32) -1)299#define SVGA_GMR_FRAMEBUFFER ((uint32) -2) // Guest Framebuffer (GFB)300301typedef302struct SVGAGuestMemDescriptor {303uint32 ppn;304uint32 numPages;305} SVGAGuestMemDescriptor;306307typedef308struct SVGAGuestPtr {309uint32 gmrId;310uint32 offset;311} SVGAGuestPtr;312313/*314* Register based command buffers --315*316* Provide an SVGA device interface that allows the guest to submit317* command buffers to the SVGA device through an SVGA device register.318* The metadata for each command buffer is contained in the319* SVGACBHeader structure along with the return status codes.320*321* The SVGA device supports command buffers if322* SVGA_CAP_COMMAND_BUFFERS is set in the device caps register. The323* fifo must be enabled for command buffers to be submitted.324*325* Command buffers are submitted when the guest writing the 64 byte326* aligned physical address into the SVGA_REG_COMMAND_LOW and327* SVGA_REG_COMMAND_HIGH. SVGA_REG_COMMAND_HIGH contains the upper 32328* bits of the physical address. SVGA_REG_COMMAND_LOW contains the329* lower 32 bits of the physical address, since the command buffer330* headers are required to be 64 byte aligned the lower 6 bits are331* used for the SVGACBContext value. Writing to SVGA_REG_COMMAND_LOW332* submits the command buffer to the device and queues it for333* execution. The SVGA device supports at least334* SVGA_CB_MAX_QUEUED_PER_CONTEXT command buffers that can be queued335* per context and if that limit is reached the device will write the336* status SVGA_CB_STATUS_QUEUE_FULL to the status value of the command337* buffer header synchronously and not raise any IRQs.338*339* It is invalid to submit a command buffer without a valid physical340* address and results are undefined.341*342* The device guarantees that command buffers of size SVGA_CB_MAX_SIZE343* will be supported. If a larger command buffer is submitted results344* are unspecified and the device will either complete the command345* buffer or return an error.346*347* The device guarantees that any individual command in a command348* buffer can be up to SVGA_CB_MAX_COMMAND_SIZE in size which is349* enough to fit a 64x64 color-cursor definition. If the command is350* too large the device is allowed to process the command or return an351* error.352*353* The device context is a special SVGACBContext that allows for354* synchronous register like accesses with the flexibility of355* commands. There is a different command set defined by356* SVGADeviceContextCmdId. The commands in each command buffer is not357* allowed to straddle physical pages.358*/359360#define SVGA_CB_MAX_SIZE (512 * 1024) // 512 KB361#define SVGA_CB_MAX_QUEUED_PER_CONTEXT 32362#define SVGA_CB_MAX_COMMAND_SIZE (32 * 1024) // 32 KB363364#define SVGA_CB_CONTEXT_MASK 0x3f365typedef enum {366SVGA_CB_CONTEXT_DEVICE = 0x3f,367SVGA_CB_CONTEXT_0 = 0x0,368SVGA_CB_CONTEXT_MAX = 0x1,369} SVGACBContext;370371372typedef enum {373/*374* The guest is supposed to write SVGA_CB_STATUS_NONE to the status375* field before submitting the command buffer header, the host will376* change the value when it is done with the command buffer.377*/378SVGA_CB_STATUS_NONE = 0,379380/*381* Written by the host when a command buffer completes successfully.382* The device raises an IRQ with SVGA_IRQFLAG_COMMAND_BUFFER unless383* the SVGA_CB_FLAG_NO_IRQ flag is set.384*/385SVGA_CB_STATUS_COMPLETED = 1,386387/*388* Written by the host synchronously with the command buffer389* submission to indicate the command buffer was not submitted. No390* IRQ is raised.391*/392SVGA_CB_STATUS_QUEUE_FULL = 2,393394/*395* Written by the host when an error was detected parsing a command396* in the command buffer, errorOffset is written to contain the397* offset to the first byte of the failing command. The device398* raises the IRQ with both SVGA_IRQFLAG_ERROR and399* SVGA_IRQFLAG_COMMAND_BUFFER. Some of the commands may have been400* processed.401*/402SVGA_CB_STATUS_COMMAND_ERROR = 3,403404/*405* Written by the host if there is an error parsing the command406* buffer header. The device raises the IRQ with both407* SVGA_IRQFLAG_ERROR and SVGA_IRQFLAG_COMMAND_BUFFER. The device408* did not processes any of the command buffer.409*/410SVGA_CB_STATUS_CB_HEADER_ERROR = 4,411412/*413* Written by the host if the guest requested the host to preempt414* the command buffer. The device will not raise any IRQs and the415* command buffer was not processed.416*/417SVGA_CB_STATUS_PREEMPTED = 5,418} SVGACBStatus;419420typedef enum {421SVGA_CB_FLAG_NONE = 0,422SVGA_CB_FLAG_NO_IRQ = 1 << 0,423} SVGACBFlags;424425typedef426struct {427volatile SVGACBStatus status;428volatile uint32 errorOffset;429uint64 id;430SVGACBFlags flags;431uint32 length;432union {433PA pa;434} ptr;435uint32 mustBeZero[8];436} SVGACBHeader;437438typedef enum {439SVGA_DC_CMD_NOP = 0,440SVGA_DC_CMD_START_STOP_CONTEXT = 1,441SVGA_DC_CMD_PREEMPT = 2,442SVGA_DC_CMD_MAX = 3,443SVGA_DC_CMD_FORCE_UINT = MAX_UINT32,444} SVGADeviceContextCmdId;445446typedef struct {447uint32 enable;448SVGACBContext context;449} SVGADCCmdStartStop;450451/*452* SVGADCCmdPreempt --453*454* This command allows the guest to request that all command buffers455* on the specified context be preempted that can be. After execution456* of this command all command buffers that were preempted will457* already have SVGA_CB_STATUS_PREEMPTED written into the status458* field. The device might still be processing a command buffer,459* assuming execution of it started before the preemption request was460* received. Specifying the ignoreIDZero flag to TRUE will cause the461* device to not preempt command buffers with the id field in the462* command buffer header set to zero.463*/464465typedef struct {466SVGACBContext context;467uint32 ignoreIDZero;468} SVGADCCmdPreempt;469470471/*472* SVGAGMRImageFormat --473*474* This is a packed representation of the source 2D image format475* for a GMR-to-screen blit. Currently it is defined as an encoding476* of the screen's color depth and bits-per-pixel, however, 16 bits477* are reserved for future use to identify other encodings (such as478* RGBA or higher-precision images).479*480* Currently supported formats:481*482* bpp depth Format Name483* --- ----- -----------484* 32 24 32-bit BGRX485* 24 24 24-bit BGR486* 16 16 RGB 5-6-5487* 16 15 RGB 5-5-5488*489*/490491typedef struct SVGAGMRImageFormat {492union {493struct {494uint32 bitsPerPixel : 8;495uint32 colorDepth : 8;496uint32 reserved : 16; /* Must be zero */497};498499uint32 value;500};501} SVGAGMRImageFormat;502503typedef504struct SVGAGuestImage {505SVGAGuestPtr ptr;506507/*508* A note on interpretation of pitch: This value of pitch is the509* number of bytes between vertically adjacent image510* blocks. Normally this is the number of bytes between the first511* pixel of two adjacent scanlines. With compressed textures,512* however, this may represent the number of bytes between513* compression blocks rather than between rows of pixels.514*515* XXX: Compressed textures currently must be tightly packed in guest memory.516*517* If the image is 1-dimensional, pitch is ignored.518*519* If 'pitch' is zero, the SVGA3D device calculates a pitch value520* assuming each row of blocks is tightly packed.521*/522uint32 pitch;523} SVGAGuestImage;524525/*526* SVGAColorBGRX --527*528* A 24-bit color format (BGRX), which does not depend on the529* format of the legacy guest framebuffer (GFB) or the current530* GMRFB state.531*/532533typedef struct SVGAColorBGRX {534union {535struct {536uint32 b : 8;537uint32 g : 8;538uint32 r : 8;539uint32 x : 8; /* Unused */540};541542uint32 value;543};544} SVGAColorBGRX;545546547/*548* SVGASignedRect --549* SVGASignedPoint --550*551* Signed rectangle and point primitives. These are used by the new552* 2D primitives for drawing to Screen Objects, which can occupy a553* signed virtual coordinate space.554*555* SVGASignedRect specifies a half-open interval: the (left, top)556* pixel is part of the rectangle, but the (right, bottom) pixel is557* not.558*/559560typedef561struct {562int32 left;563int32 top;564int32 right;565int32 bottom;566} SVGASignedRect;567568typedef569struct {570int32 x;571int32 y;572} SVGASignedPoint;573574575/*576* SVGA Device Capabilities577*578* Note the holes in the bitfield. Missing bits have been deprecated,579* and must not be reused. Those capabilities will never be reported580* by new versions of the SVGA device.581*582* XXX: Add longer descriptions for each capability, including a list583* of the new features that each capability provides.584*585* SVGA_CAP_IRQMASK --586* Provides device interrupts. Adds device register SVGA_REG_IRQMASK587* to set interrupt mask and direct I/O port SVGA_IRQSTATUS_PORT to588* set/clear pending interrupts.589*590* SVGA_CAP_GMR --591* Provides synchronous mapping of guest memory regions (GMR).592* Adds device registers SVGA_REG_GMR_ID, SVGA_REG_GMR_DESCRIPTOR,593* SVGA_REG_GMR_MAX_IDS, and SVGA_REG_GMR_MAX_DESCRIPTOR_LENGTH.594*595* SVGA_CAP_TRACES --596* Allows framebuffer trace-based updates even when FIFO is enabled.597* Adds device register SVGA_REG_TRACES.598*599* SVGA_CAP_GMR2 --600* Provides asynchronous commands to define and remap guest memory601* regions. Adds device registers SVGA_REG_GMRS_MAX_PAGES and602* SVGA_REG_MEMORY_SIZE.603*604* SVGA_CAP_SCREEN_OBJECT_2 --605* Allow screen object support, and require backing stores from the606* guest for each screen object.607*608* SVGA_CAP_COMMAND_BUFFERS --609* Enable register based command buffer submission.610*611* SVGA_CAP_DEAD1 --612* This cap was incorrectly used by old drivers and should not be613* reused.614*615* SVGA_CAP_CMD_BUFFERS_2 --616* Enable support for the prepend command buffer submission617* registers. SVGA_REG_CMD_PREPEND_LOW and618* SVGA_REG_CMD_PREPEND_HIGH.619*620* SVGA_CAP_GBOBJECTS --621* Enable guest-backed objects and surfaces.622*623* SVGA_CAP_CMD_BUFFERS_3 --624* Enable support for command buffers in a mob.625*/626627#define SVGA_CAP_NONE 0x00000000628#define SVGA_CAP_RECT_COPY 0x00000002629#define SVGA_CAP_CURSOR 0x00000020630#define SVGA_CAP_CURSOR_BYPASS 0x00000040631#define SVGA_CAP_CURSOR_BYPASS_2 0x00000080632#define SVGA_CAP_8BIT_EMULATION 0x00000100633#define SVGA_CAP_ALPHA_CURSOR 0x00000200634#define SVGA_CAP_3D 0x00004000635#define SVGA_CAP_EXTENDED_FIFO 0x00008000636#define SVGA_CAP_MULTIMON 0x00010000637#define SVGA_CAP_PITCHLOCK 0x00020000638#define SVGA_CAP_IRQMASK 0x00040000639#define SVGA_CAP_DISPLAY_TOPOLOGY 0x00080000640#define SVGA_CAP_GMR 0x00100000641#define SVGA_CAP_TRACES 0x00200000642#define SVGA_CAP_GMR2 0x00400000643#define SVGA_CAP_SCREEN_OBJECT_2 0x00800000644#define SVGA_CAP_COMMAND_BUFFERS 0x01000000645#define SVGA_CAP_DEAD1 0x02000000646#define SVGA_CAP_CMD_BUFFERS_2 0x04000000647#define SVGA_CAP_GBOBJECTS 0x08000000648#define SVGA_CAP_CMD_BUFFERS_3 0x10000000649650#define SVGA_CAP_CAP2_REGISTER 0x80000000651652653/*654* The SVGA_REG_CAP2 register is an additional set of SVGA capability bits.655*656* SVGA_CAP2_GROW_OTABLE --657* Allow the GrowOTable/DXGrowCOTable commands.658*659* SVGA_CAP2_INTRA_SURFACE_COPY --660* Allow the IntraSurfaceCopy command.661*662* SVGA_CAP2_RESERVED --663* Reserve the last bit for extending the SVGA capabilities to some664* future mechanisms.665*/666#define SVGA_CAP2_NONE 0x00000000667#define SVGA_CAP2_GROW_OTABLE 0x00000001668#define SVGA_CAP2_INTRA_SURFACE_COPY 0x00000002669#define SVGA_CAP2_RESERVED 0x80000000670671/*672* The Guest can optionally read some SVGA device capabilities through673* the backdoor with command BDOOR_CMD_GET_SVGA_CAPABILITIES before674* the SVGA device is initialized. The type of capability the guest675* is requesting from the SVGABackdoorCapType enum should be placed in676* the upper 16 bits of the backdoor command id (ECX). On success the677* the value of EBX will be set to BDOOR_MAGIC and EAX will be set to678* the requested capability. If the command is not supported then EBX679* will be left unchanged and EAX will be set to -1. Because it is680* possible that -1 is the value of the requested cap the correct way681* to check if the command was successful is to check if EBX was changed682* to BDOOR_MAGIC making sure to initialize the register to something683* else first.684*/685686typedef enum {687SVGABackdoorCapDeviceCaps = 0,688SVGABackdoorCapFifoCaps = 1,689SVGABackdoorCap3dHWVersion = 2,690SVGABackdoorCapMax = 3,691} SVGABackdoorCapType;692693694/*695* FIFO register indices.696*697* The FIFO is a chunk of device memory mapped into guest physmem. It698* is always treated as 32-bit words.699*700* The guest driver gets to decide how to partition it between701* - FIFO registers (there are always at least 4, specifying where the702* following data area is and how much data it contains; there may be703* more registers following these, depending on the FIFO protocol704* version in use)705* - FIFO data, written by the guest and slurped out by the VMX.706* These indices are 32-bit word offsets into the FIFO.707*/708709enum {710/*711* Block 1 (basic registers): The originally defined FIFO registers.712* These exist and are valid for all versions of the FIFO protocol.713*/714715SVGA_FIFO_MIN = 0,716SVGA_FIFO_MAX, /* The distance from MIN to MAX must be at least 10K */717SVGA_FIFO_NEXT_CMD,718SVGA_FIFO_STOP,719720/*721* Block 2 (extended registers): Mandatory registers for the extended722* FIFO. These exist if the SVGA caps register includes723* SVGA_CAP_EXTENDED_FIFO; some of them are valid only if their724* associated capability bit is enabled.725*726* Note that when originally defined, SVGA_CAP_EXTENDED_FIFO implied727* support only for (FIFO registers) CAPABILITIES, FLAGS, and FENCE.728* This means that the guest has to test individually (in most cases729* using FIFO caps) for the presence of registers after this; the VMX730* can define "extended FIFO" to mean whatever it wants, and currently731* won't enable it unless there's room for that set and much more.732*/733734SVGA_FIFO_CAPABILITIES = 4,735SVGA_FIFO_FLAGS,736/* Valid with SVGA_FIFO_CAP_FENCE: */737SVGA_FIFO_FENCE,738739/*740* Block 3a (optional extended registers): Additional registers for the741* extended FIFO, whose presence isn't actually implied by742* SVGA_CAP_EXTENDED_FIFO; these exist if SVGA_FIFO_MIN is high enough to743* leave room for them.744*745* These in block 3a, the VMX currently considers mandatory for the746* extended FIFO.747*/748749/* Valid if exists (i.e. if extended FIFO enabled): */750SVGA_FIFO_3D_HWVERSION, /* See SVGA3dHardwareVersion in svga3d_reg.h */751/* Valid with SVGA_FIFO_CAP_PITCHLOCK: */752SVGA_FIFO_PITCHLOCK,753754/* Valid with SVGA_FIFO_CAP_CURSOR_BYPASS_3: */755SVGA_FIFO_CURSOR_ON, /* Cursor bypass 3 show/hide register */756SVGA_FIFO_CURSOR_X, /* Cursor bypass 3 x register */757SVGA_FIFO_CURSOR_Y, /* Cursor bypass 3 y register */758SVGA_FIFO_CURSOR_COUNT, /* Incremented when any of the other 3 change */759SVGA_FIFO_CURSOR_LAST_UPDATED,/* Last time the host updated the cursor */760761/* Valid with SVGA_FIFO_CAP_RESERVE: */762SVGA_FIFO_RESERVED, /* Bytes past NEXT_CMD with real contents */763764/*765* Valid with SVGA_FIFO_CAP_SCREEN_OBJECT or SVGA_FIFO_CAP_SCREEN_OBJECT_2:766*767* By default this is SVGA_ID_INVALID, to indicate that the cursor768* coordinates are specified relative to the virtual root. If this769* is set to a specific screen ID, cursor position is reinterpreted770* as a signed offset relative to that screen's origin.771*/772SVGA_FIFO_CURSOR_SCREEN_ID,773774/*775* Valid with SVGA_FIFO_CAP_DEAD776*777* An arbitrary value written by the host, drivers should not use it.778*/779SVGA_FIFO_DEAD,780781/*782* Valid with SVGA_FIFO_CAP_3D_HWVERSION_REVISED:783*784* Contains 3D HWVERSION (see SVGA3dHardwareVersion in svga3d_reg.h)785* on platforms that can enforce graphics resource limits.786*/787SVGA_FIFO_3D_HWVERSION_REVISED,788789/*790* XXX: The gap here, up until SVGA_FIFO_3D_CAPS, can be used for new791* registers, but this must be done carefully and with judicious use of792* capability bits, since comparisons based on SVGA_FIFO_MIN aren't793* enough to tell you whether the register exists: we've shipped drivers794* and products that used SVGA_FIFO_3D_CAPS but didn't know about some of795* the earlier ones. The actual order of introduction was:796* - PITCHLOCK797* - 3D_CAPS798* - CURSOR_* (cursor bypass 3)799* - RESERVED800* So, code that wants to know whether it can use any of the801* aforementioned registers, or anything else added after PITCHLOCK and802* before 3D_CAPS, needs to reason about something other than803* SVGA_FIFO_MIN.804*/805806/*807* 3D caps block space; valid with 3D hardware version >=808* SVGA3D_HWVERSION_WS6_B1.809*/810SVGA_FIFO_3D_CAPS = 32,811SVGA_FIFO_3D_CAPS_LAST = 32 + 255,812813/*814* End of VMX's current definition of "extended-FIFO registers".815* Registers before here are always enabled/disabled as a block; either816* the extended FIFO is enabled and includes all preceding registers, or817* it's disabled entirely.818*819* Block 3b (truly optional extended registers): Additional registers for820* the extended FIFO, which the VMX already knows how to enable and821* disable with correct granularity.822*823* Registers after here exist if and only if the guest SVGA driver824* sets SVGA_FIFO_MIN high enough to leave room for them.825*/826827/* Valid if register exists: */828SVGA_FIFO_GUEST_3D_HWVERSION, /* Guest driver's 3D version */829SVGA_FIFO_FENCE_GOAL, /* Matching target for SVGA_IRQFLAG_FENCE_GOAL */830SVGA_FIFO_BUSY, /* See "FIFO Synchronization Registers" */831832/*833* Always keep this last. This defines the maximum number of834* registers we know about. At power-on, this value is placed in835* the SVGA_REG_MEM_REGS register, and we expect the guest driver836* to allocate this much space in FIFO memory for registers.837*/838SVGA_FIFO_NUM_REGS839};840841842/*843* Definition of registers included in extended FIFO support.844*845* The guest SVGA driver gets to allocate the FIFO between registers846* and data. It must always allocate at least 4 registers, but old847* drivers stopped there.848*849* The VMX will enable extended FIFO support if and only if the guest850* left enough room for all registers defined as part of the mandatory851* set for the extended FIFO.852*853* Note that the guest drivers typically allocate the FIFO only at854* initialization time, not at mode switches, so it's likely that the855* number of FIFO registers won't change without a reboot.856*857* All registers less than this value are guaranteed to be present if858* svgaUser->fifo.extended is set. Any later registers must be tested859* individually for compatibility at each use (in the VMX).860*861* This value is used only by the VMX, so it can change without862* affecting driver compatibility; keep it that way?863*/864#define SVGA_FIFO_EXTENDED_MANDATORY_REGS (SVGA_FIFO_3D_CAPS_LAST + 1)865866867/*868* FIFO Synchronization Registers869*870* This explains the relationship between the various FIFO871* sync-related registers in IOSpace and in FIFO space.872*873* SVGA_REG_SYNC --874*875* The SYNC register can be used in two different ways by the guest:876*877* 1. If the guest wishes to fully sync (drain) the FIFO,878* it will write once to SYNC then poll on the BUSY879* register. The FIFO is synced once BUSY is zero.880*881* 2. If the guest wants to asynchronously wake up the host,882* it will write once to SYNC without polling on BUSY.883* Ideally it will do this after some new commands have884* been placed in the FIFO, and after reading a zero885* from SVGA_FIFO_BUSY.886*887* (1) is the original behaviour that SYNC was designed to888* support. Originally, a write to SYNC would implicitly889* trigger a read from BUSY. This causes us to synchronously890* process the FIFO.891*892* This behaviour has since been changed so that writing SYNC893* will *not* implicitly cause a read from BUSY. Instead, it894* makes a channel call which asynchronously wakes up the MKS895* thread.896*897* New guests can use this new behaviour to implement (2)898* efficiently. This lets guests get the host's attention899* without waiting for the MKS to poll, which gives us much900* better CPU utilization on SMP hosts and on UP hosts while901* we're blocked on the host GPU.902*903* Old guests shouldn't notice the behaviour change. SYNC was904* never guaranteed to process the entire FIFO, since it was905* bounded to a particular number of CPU cycles. Old guests will906* still loop on the BUSY register until the FIFO is empty.907*908* Writing to SYNC currently has the following side-effects:909*910* - Sets SVGA_REG_BUSY to TRUE (in the monitor)911* - Asynchronously wakes up the MKS thread for FIFO processing912* - The value written to SYNC is recorded as a "reason", for913* stats purposes.914*915* If SVGA_FIFO_BUSY is available, drivers are advised to only916* write to SYNC if SVGA_FIFO_BUSY is FALSE. Drivers should set917* SVGA_FIFO_BUSY to TRUE after writing to SYNC. The MKS will918* eventually set SVGA_FIFO_BUSY on its own, but this approach919* lets the driver avoid sending multiple asynchronous wakeup920* messages to the MKS thread.921*922* SVGA_REG_BUSY --923*924* This register is set to TRUE when SVGA_REG_SYNC is written,925* and it reads as FALSE when the FIFO has been completely926* drained.927*928* Every read from this register causes us to synchronously929* process FIFO commands. There is no guarantee as to how many930* commands each read will process.931*932* CPU time spent processing FIFO commands will be billed to933* the guest.934*935* New drivers should avoid using this register unless they936* need to guarantee that the FIFO is completely drained. It937* is overkill for performing a sync-to-fence. Older drivers938* will use this register for any type of synchronization.939*940* SVGA_FIFO_BUSY --941*942* This register is a fast way for the guest driver to check943* whether the FIFO is already being processed. It reads and944* writes at normal RAM speeds, with no monitor intervention.945*946* If this register reads as TRUE, the host is guaranteeing that947* any new commands written into the FIFO will be noticed before948* the MKS goes back to sleep.949*950* If this register reads as FALSE, no such guarantee can be951* made.952*953* The guest should use this register to quickly determine954* whether or not it needs to wake up the host. If the guest955* just wrote a command or group of commands that it would like956* the host to begin processing, it should:957*958* 1. Read SVGA_FIFO_BUSY. If it reads as TRUE, no further959* action is necessary.960*961* 2. Write TRUE to SVGA_FIFO_BUSY. This informs future guest962* code that we've already sent a SYNC to the host and we963* don't need to send a duplicate.964*965* 3. Write a reason to SVGA_REG_SYNC. This will send an966* asynchronous wakeup to the MKS thread.967*/968969970/*971* FIFO Capabilities972*973* Fence -- Fence register and command are supported974* Accel Front -- Front buffer only commands are supported975* Pitch Lock -- Pitch lock register is supported976* Video -- SVGA Video overlay units are supported977* Escape -- Escape command is supported978*979* XXX: Add longer descriptions for each capability, including a list980* of the new features that each capability provides.981*982* SVGA_FIFO_CAP_SCREEN_OBJECT --983*984* Provides dynamic multi-screen rendering, for improved Unity and985* multi-monitor modes. With Screen Object, the guest can986* dynamically create and destroy 'screens', which can represent987* Unity windows or virtual monitors. Screen Object also provides988* strong guarantees that DMA operations happen only when989* guest-initiated. Screen Object deprecates the BAR1 guest990* framebuffer (GFB) and all commands that work only with the GFB.991*992* New registers:993* FIFO_CURSOR_SCREEN_ID, VIDEO_DATA_GMRID, VIDEO_DST_SCREEN_ID994*995* New 2D commands:996* DEFINE_SCREEN, DESTROY_SCREEN, DEFINE_GMRFB, BLIT_GMRFB_TO_SCREEN,997* BLIT_SCREEN_TO_GMRFB, ANNOTATION_FILL, ANNOTATION_COPY998*999* New 3D commands:1000* BLIT_SURFACE_TO_SCREEN1001*1002* New guarantees:1003*1004* - The host will not read or write guest memory, including the GFB,1005* except when explicitly initiated by a DMA command.1006*1007* - All DMA, including legacy DMA like UPDATE and PRESENT_READBACK,1008* is guaranteed to complete before any subsequent FENCEs.1009*1010* - All legacy commands which affect a Screen (UPDATE, PRESENT,1011* PRESENT_READBACK) as well as new Screen blit commands will1012* all behave consistently as blits, and memory will be read1013* or written in FIFO order.1014*1015* For example, if you PRESENT from one SVGA3D surface to multiple1016* places on the screen, the data copied will always be from the1017* SVGA3D surface at the time the PRESENT was issued in the FIFO.1018* This was not necessarily true on devices without Screen Object.1019*1020* This means that on devices that support Screen Object, the1021* PRESENT_READBACK command should not be necessary unless you1022* actually want to read back the results of 3D rendering into1023* system memory. (And for that, the BLIT_SCREEN_TO_GMRFB1024* command provides a strict superset of functionality.)1025*1026* - When a screen is resized, either using Screen Object commands or1027* legacy multimon registers, its contents are preserved.1028*1029* SVGA_FIFO_CAP_GMR2 --1030*1031* Provides new commands to define and remap guest memory regions (GMR).1032*1033* New 2D commands:1034* DEFINE_GMR2, REMAP_GMR2.1035*1036* SVGA_FIFO_CAP_3D_HWVERSION_REVISED --1037*1038* Indicates new register SVGA_FIFO_3D_HWVERSION_REVISED exists.1039* This register may replace SVGA_FIFO_3D_HWVERSION on platforms1040* that enforce graphics resource limits. This allows the platform1041* to clear SVGA_FIFO_3D_HWVERSION and disable 3D in legacy guest1042* drivers that do not limit their resources.1043*1044* Note this is an alias to SVGA_FIFO_CAP_GMR2 because these indicators1045* are codependent (and thus we use a single capability bit).1046*1047* SVGA_FIFO_CAP_SCREEN_OBJECT_2 --1048*1049* Modifies the DEFINE_SCREEN command to include a guest provided1050* backing store in GMR memory and the bytesPerLine for the backing1051* store. This capability requires the use of a backing store when1052* creating screen objects. However if SVGA_FIFO_CAP_SCREEN_OBJECT1053* is present then backing stores are optional.1054*1055* SVGA_FIFO_CAP_DEAD --1056*1057* Drivers should not use this cap bit. This cap bit can not be1058* reused since some hosts already expose it.1059*/10601061#define SVGA_FIFO_CAP_NONE 01062#define SVGA_FIFO_CAP_FENCE (1<<0)1063#define SVGA_FIFO_CAP_ACCELFRONT (1<<1)1064#define SVGA_FIFO_CAP_PITCHLOCK (1<<2)1065#define SVGA_FIFO_CAP_VIDEO (1<<3)1066#define SVGA_FIFO_CAP_CURSOR_BYPASS_3 (1<<4)1067#define SVGA_FIFO_CAP_ESCAPE (1<<5)1068#define SVGA_FIFO_CAP_RESERVE (1<<6)1069#define SVGA_FIFO_CAP_SCREEN_OBJECT (1<<7)1070#define SVGA_FIFO_CAP_GMR2 (1<<8)1071#define SVGA_FIFO_CAP_3D_HWVERSION_REVISED SVGA_FIFO_CAP_GMR21072#define SVGA_FIFO_CAP_SCREEN_OBJECT_2 (1<<9)1073#define SVGA_FIFO_CAP_DEAD (1<<10)107410751076/*1077* FIFO Flags1078*1079* Accel Front -- Driver should use front buffer only commands1080*/10811082#define SVGA_FIFO_FLAG_NONE 01083#define SVGA_FIFO_FLAG_ACCELFRONT (1<<0)1084#define SVGA_FIFO_FLAG_RESERVED (1<<31) /* Internal use only */10851086/*1087* FIFO reservation sentinel value1088*/10891090#define SVGA_FIFO_RESERVED_UNKNOWN 0xffffffff109110921093/*1094* Video overlay support1095*/10961097#define SVGA_NUM_OVERLAY_UNITS 32109810991100/*1101* Video capabilities that the guest is currently using1102*/11031104#define SVGA_VIDEO_FLAG_COLORKEY 0x0001110511061107/*1108* Offsets for the video overlay registers1109*/11101111enum {1112SVGA_VIDEO_ENABLED = 0,1113SVGA_VIDEO_FLAGS,1114SVGA_VIDEO_DATA_OFFSET,1115SVGA_VIDEO_FORMAT,1116SVGA_VIDEO_COLORKEY,1117SVGA_VIDEO_SIZE, /* Deprecated */1118SVGA_VIDEO_WIDTH,1119SVGA_VIDEO_HEIGHT,1120SVGA_VIDEO_SRC_X,1121SVGA_VIDEO_SRC_Y,1122SVGA_VIDEO_SRC_WIDTH,1123SVGA_VIDEO_SRC_HEIGHT,1124SVGA_VIDEO_DST_X, /* Signed int32 */1125SVGA_VIDEO_DST_Y, /* Signed int32 */1126SVGA_VIDEO_DST_WIDTH,1127SVGA_VIDEO_DST_HEIGHT,1128SVGA_VIDEO_PITCH_1,1129SVGA_VIDEO_PITCH_2,1130SVGA_VIDEO_PITCH_3,1131SVGA_VIDEO_DATA_GMRID, /* Optional, defaults to SVGA_GMR_FRAMEBUFFER */1132SVGA_VIDEO_DST_SCREEN_ID, /* Optional, defaults to virtual coords */1133/* (SVGA_ID_INVALID) */1134SVGA_VIDEO_NUM_REGS1135};113611371138/*1139* SVGA Overlay Units1140*1141* width and height relate to the entire source video frame.1142* srcX, srcY, srcWidth and srcHeight represent subset of the source1143* video frame to be displayed.1144*/11451146typedef struct SVGAOverlayUnit {1147uint32 enabled;1148uint32 flags;1149uint32 dataOffset;1150uint32 format;1151uint32 colorKey;1152uint32 size;1153uint32 width;1154uint32 height;1155uint32 srcX;1156uint32 srcY;1157uint32 srcWidth;1158uint32 srcHeight;1159int32 dstX;1160int32 dstY;1161uint32 dstWidth;1162uint32 dstHeight;1163uint32 pitches[3];1164uint32 dataGMRId;1165uint32 dstScreenId;1166} SVGAOverlayUnit;116711681169/*1170* Guest display topology1171*1172* XXX: This structure is not part of the SVGA device's interface, and1173* doesn't really belong here.1174*/1175#define SVGA_INVALID_DISPLAY_ID ((uint32)-1)11761177typedef struct SVGADisplayTopology {1178uint16 displayId;1179uint16 isPrimary;1180uint32 width;1181uint32 height;1182uint32 positionX;1183uint32 positionY;1184} SVGADisplayTopology;118511861187/*1188* SVGAScreenObject --1189*1190* This is a new way to represent a guest's multi-monitor screen or1191* Unity window. Screen objects are only supported if the1192* SVGA_FIFO_CAP_SCREEN_OBJECT capability bit is set.1193*1194* If Screen Objects are supported, they can be used to fully1195* replace the functionality provided by the framebuffer registers1196* (SVGA_REG_WIDTH, HEIGHT, etc.) and by SVGA_CAP_DISPLAY_TOPOLOGY.1197*1198* The screen object is a struct with guaranteed binary1199* compatibility. New flags can be added, and the struct may grow,1200* but existing fields must retain their meaning.1201*1202* Added with SVGA_FIFO_CAP_SCREEN_OBJECT_2 are required fields of1203* a SVGAGuestPtr that is used to back the screen contents. This1204* memory must come from the GFB. The guest is not allowed to1205* access the memory and doing so will have undefined results. The1206* backing store is required to be page aligned and the size is1207* padded to the next page boundary. The number of pages is:1208* (bytesPerLine * size.width * 4 + PAGE_SIZE - 1) / PAGE_SIZE1209*1210* The pitch in the backingStore is required to be at least large1211* enough to hold a 32bbp scanline. It is recommended that the1212* driver pad bytesPerLine for a potential performance win.1213*1214* The cloneCount field is treated as a hint from the guest that1215* the user wants this display to be cloned, countCount times. A1216* value of zero means no cloning should happen.1217*/12181219#define SVGA_SCREEN_MUST_BE_SET (1 << 0)1220#define SVGA_SCREEN_HAS_ROOT SVGA_SCREEN_MUST_BE_SET /* Deprecated */1221#define SVGA_SCREEN_IS_PRIMARY (1 << 1)1222#define SVGA_SCREEN_FULLSCREEN_HINT (1 << 2)12231224/*1225* Added with SVGA_FIFO_CAP_SCREEN_OBJECT_2. When the screen is1226* deactivated the base layer is defined to lose all contents and1227* become black. When a screen is deactivated the backing store is1228* optional. When set backingPtr and bytesPerLine will be ignored.1229*/1230#define SVGA_SCREEN_DEACTIVATE (1 << 3)12311232/*1233* Added with SVGA_FIFO_CAP_SCREEN_OBJECT_2. When this flag is set1234* the screen contents will be outputted as all black to the user1235* though the base layer contents is preserved. The screen base layer1236* can still be read and written to like normal though the no visible1237* effect will be seen by the user. When the flag is changed the1238* screen will be blanked or redrawn to the current contents as needed1239* without any extra commands from the driver. This flag only has an1240* effect when the screen is not deactivated.1241*/1242#define SVGA_SCREEN_BLANKING (1 << 4)12431244typedef1245struct {1246uint32 structSize; /* sizeof(SVGAScreenObject) */1247uint32 id;1248uint32 flags;1249struct {1250uint32 width;1251uint32 height;1252} size;1253struct {1254int32 x;1255int32 y;1256} root;12571258/*1259* Added and required by SVGA_FIFO_CAP_SCREEN_OBJECT_2, optional1260* with SVGA_FIFO_CAP_SCREEN_OBJECT.1261*/1262SVGAGuestImage backingStore;12631264/*1265* The cloneCount field is treated as a hint from the guest that1266* the user wants this display to be cloned, cloneCount times.1267*1268* A value of zero means no cloning should happen.1269*/1270uint32 cloneCount;1271} SVGAScreenObject;127212731274/*1275* Commands in the command FIFO:1276*1277* Command IDs defined below are used for the traditional 2D FIFO1278* communication (not all commands are available for all versions of the1279* SVGA FIFO protocol).1280*1281* Note the holes in the command ID numbers: These commands have been1282* deprecated, and the old IDs must not be reused.1283*1284* Command IDs from 1000 to 2999 are reserved for use by the SVGA3D1285* protocol.1286*1287* Each command's parameters are described by the comments and1288* structs below.1289*/12901291typedef enum {1292SVGA_CMD_INVALID_CMD = 0,1293SVGA_CMD_UPDATE = 1,1294SVGA_CMD_RECT_COPY = 3,1295SVGA_CMD_RECT_ROP_COPY = 14,1296SVGA_CMD_DEFINE_CURSOR = 19,1297SVGA_CMD_DEFINE_ALPHA_CURSOR = 22,1298SVGA_CMD_UPDATE_VERBOSE = 25,1299SVGA_CMD_FRONT_ROP_FILL = 29,1300SVGA_CMD_FENCE = 30,1301SVGA_CMD_ESCAPE = 33,1302SVGA_CMD_DEFINE_SCREEN = 34,1303SVGA_CMD_DESTROY_SCREEN = 35,1304SVGA_CMD_DEFINE_GMRFB = 36,1305SVGA_CMD_BLIT_GMRFB_TO_SCREEN = 37,1306SVGA_CMD_BLIT_SCREEN_TO_GMRFB = 38,1307SVGA_CMD_ANNOTATION_FILL = 39,1308SVGA_CMD_ANNOTATION_COPY = 40,1309SVGA_CMD_DEFINE_GMR2 = 41,1310SVGA_CMD_REMAP_GMR2 = 42,1311SVGA_CMD_DEAD = 43,1312SVGA_CMD_DEAD_2 = 44,1313SVGA_CMD_NOP = 45,1314SVGA_CMD_NOP_ERROR = 46,1315SVGA_CMD_MAX1316} SVGAFifoCmdId;13171318#define SVGA_CMD_MAX_DATASIZE (256 * 1024)1319#define SVGA_CMD_MAX_ARGS 641320#define SVGA_CB_MAX_COMMAND_SIZE (32 * 1024) // 32 KB132113221323/*1324* SVGA_CMD_UPDATE --1325*1326* This is a DMA transfer which copies from the Guest Framebuffer1327* (GFB) at BAR1 + SVGA_REG_FB_OFFSET to any screens which1328* intersect with the provided virtual rectangle.1329*1330* This command does not support using arbitrary guest memory as a1331* data source- it only works with the pre-defined GFB memory.1332* This command also does not support signed virtual coordinates.1333* If you have defined screens (using SVGA_CMD_DEFINE_SCREEN) with1334* negative root x/y coordinates, the negative portion of those1335* screens will not be reachable by this command.1336*1337* This command is not necessary when using framebuffer1338* traces. Traces are automatically enabled if the SVGA FIFO is1339* disabled, and you may explicitly enable/disable traces using1340* SVGA_REG_TRACES. With traces enabled, any write to the GFB will1341* automatically act as if a subsequent SVGA_CMD_UPDATE was issued.1342*1343* Traces and SVGA_CMD_UPDATE are the only supported ways to render1344* pseudocolor screen updates. The newer Screen Object commands1345* only support true color formats.1346*1347* Availability:1348* Always available.1349*/13501351typedef1352struct {1353uint32 x;1354uint32 y;1355uint32 width;1356uint32 height;1357} SVGAFifoCmdUpdate;135813591360/*1361* SVGA_CMD_RECT_COPY --1362*1363* Perform a rectangular DMA transfer from one area of the GFB to1364* another, and copy the result to any screens which intersect it.1365*1366* Availability:1367* SVGA_CAP_RECT_COPY1368*/13691370typedef1371struct {1372uint32 srcX;1373uint32 srcY;1374uint32 destX;1375uint32 destY;1376uint32 width;1377uint32 height;1378} SVGAFifoCmdRectCopy;137913801381/*1382* SVGA_CMD_RECT_ROP_COPY --1383*1384* Perform a rectangular DMA transfer from one area of the GFB to1385* another, and copy the result to any screens which intersect it.1386* The value of ROP may only be SVGA_ROP_COPY, and this command is1387* only supported for backwards compatibility reasons.1388*1389* Availability:1390* SVGA_CAP_RECT_COPY1391*/13921393typedef1394struct {1395uint32 srcX;1396uint32 srcY;1397uint32 destX;1398uint32 destY;1399uint32 width;1400uint32 height;1401uint32 rop;1402} SVGAFifoCmdRectRopCopy;140314041405/*1406* SVGA_CMD_DEFINE_CURSOR --1407*1408* Provide a new cursor image, as an AND/XOR mask.1409*1410* The recommended way to position the cursor overlay is by using1411* the SVGA_FIFO_CURSOR_* registers, supported by the1412* SVGA_FIFO_CAP_CURSOR_BYPASS_3 capability.1413*1414* Availability:1415* SVGA_CAP_CURSOR1416*/14171418typedef1419struct {1420uint32 id; /* Reserved, must be zero. */1421uint32 hotspotX;1422uint32 hotspotY;1423uint32 width;1424uint32 height;1425uint32 andMaskDepth; /* Value must be 1 or equal to BITS_PER_PIXEL */1426uint32 xorMaskDepth; /* Value must be 1 or equal to BITS_PER_PIXEL */1427/*1428* Followed by scanline data for AND mask, then XOR mask.1429* Each scanline is padded to a 32-bit boundary.1430*/1431} SVGAFifoCmdDefineCursor;143214331434/*1435* SVGA_CMD_DEFINE_ALPHA_CURSOR --1436*1437* Provide a new cursor image, in 32-bit BGRA format.1438*1439* The recommended way to position the cursor overlay is by using1440* the SVGA_FIFO_CURSOR_* registers, supported by the1441* SVGA_FIFO_CAP_CURSOR_BYPASS_3 capability.1442*1443* Availability:1444* SVGA_CAP_ALPHA_CURSOR1445*/14461447typedef1448struct {1449uint32 id; /* Reserved, must be zero. */1450uint32 hotspotX;1451uint32 hotspotY;1452uint32 width;1453uint32 height;1454/* Followed by scanline data */1455} SVGAFifoCmdDefineAlphaCursor;145614571458/*1459* SVGA_CMD_UPDATE_VERBOSE --1460*1461* Just like SVGA_CMD_UPDATE, but also provide a per-rectangle1462* 'reason' value, an opaque cookie which is used by internal1463* debugging tools. Third party drivers should not use this1464* command.1465*1466* Availability:1467* SVGA_CAP_EXTENDED_FIFO1468*/14691470typedef1471struct {1472uint32 x;1473uint32 y;1474uint32 width;1475uint32 height;1476uint32 reason;1477} SVGAFifoCmdUpdateVerbose;147814791480/*1481* SVGA_CMD_FRONT_ROP_FILL --1482*1483* This is a hint which tells the SVGA device that the driver has1484* just filled a rectangular region of the GFB with a solid1485* color. Instead of reading these pixels from the GFB, the device1486* can assume that they all equal 'color'. This is primarily used1487* for remote desktop protocols.1488*1489* Availability:1490* SVGA_FIFO_CAP_ACCELFRONT1491*/14921493#define SVGA_ROP_COPY 0x0314941495typedef1496struct {1497uint32 color; /* In the same format as the GFB */1498uint32 x;1499uint32 y;1500uint32 width;1501uint32 height;1502uint32 rop; /* Must be SVGA_ROP_COPY */1503} SVGAFifoCmdFrontRopFill;150415051506/*1507* SVGA_CMD_FENCE --1508*1509* Insert a synchronization fence. When the SVGA device reaches1510* this command, it will copy the 'fence' value into the1511* SVGA_FIFO_FENCE register. It will also compare the fence against1512* SVGA_FIFO_FENCE_GOAL. If the fence matches the goal and the1513* SVGA_IRQFLAG_FENCE_GOAL interrupt is enabled, the device will1514* raise this interrupt.1515*1516* Availability:1517* SVGA_FIFO_FENCE for this command,1518* SVGA_CAP_IRQMASK for SVGA_FIFO_FENCE_GOAL.1519*/15201521typedef1522struct {1523uint32 fence;1524} SVGAFifoCmdFence;152515261527/*1528* SVGA_CMD_ESCAPE --1529*1530* Send an extended or vendor-specific variable length command.1531* This is used for video overlay, third party plugins, and1532* internal debugging tools. See svga_escape.h1533*1534* Availability:1535* SVGA_FIFO_CAP_ESCAPE1536*/15371538typedef1539struct {1540uint32 nsid;1541uint32 size;1542/* followed by 'size' bytes of data */1543} SVGAFifoCmdEscape;154415451546/*1547* SVGA_CMD_DEFINE_SCREEN --1548*1549* Define or redefine an SVGAScreenObject. See the description of1550* SVGAScreenObject above. The video driver is responsible for1551* generating new screen IDs. They should be small positive1552* integers. The virtual device will have an implementation1553* specific upper limit on the number of screen IDs1554* supported. Drivers are responsible for recycling IDs. The first1555* valid ID is zero.1556*1557* - Interaction with other registers:1558*1559* For backwards compatibility, when the GFB mode registers (WIDTH,1560* HEIGHT, PITCHLOCK, BITS_PER_PIXEL) are modified, the SVGA device1561* deletes all screens other than screen #0, and redefines screen1562* #0 according to the specified mode. Drivers that use1563* SVGA_CMD_DEFINE_SCREEN should destroy or redefine screen #0.1564*1565* If you use screen objects, do not use the legacy multi-mon1566* registers (SVGA_REG_NUM_GUEST_DISPLAYS, SVGA_REG_DISPLAY_*).1567*1568* Availability:1569* SVGA_FIFO_CAP_SCREEN_OBJECT or SVGA_FIFO_CAP_SCREEN_OBJECT_21570*/15711572typedef1573struct {1574SVGAScreenObject screen; /* Variable-length according to version */1575} SVGAFifoCmdDefineScreen;157615771578/*1579* SVGA_CMD_DESTROY_SCREEN --1580*1581* Destroy an SVGAScreenObject. Its ID is immediately available for1582* re-use.1583*1584* Availability:1585* SVGA_FIFO_CAP_SCREEN_OBJECT or SVGA_FIFO_CAP_SCREEN_OBJECT_21586*/15871588typedef1589struct {1590uint32 screenId;1591} SVGAFifoCmdDestroyScreen;159215931594/*1595* SVGA_CMD_DEFINE_GMRFB --1596*1597* This command sets a piece of SVGA device state called the1598* Guest Memory Region Framebuffer, or GMRFB. The GMRFB is a1599* piece of light-weight state which identifies the location and1600* format of an image in guest memory or in BAR1. The GMRFB has1601* an arbitrary size, and it doesn't need to match the geometry1602* of the GFB or any screen object.1603*1604* The GMRFB can be redefined as often as you like. You could1605* always use the same GMRFB, you could redefine it before1606* rendering from a different guest screen, or you could even1607* redefine it before every blit.1608*1609* There are multiple ways to use this command. The simplest way is1610* to use it to move the framebuffer either to elsewhere in the GFB1611* (BAR1) memory region, or to a user-defined GMR. This lets a1612* driver use a framebuffer allocated entirely out of normal system1613* memory, which we encourage.1614*1615* Another way to use this command is to set up a ring buffer of1616* updates in GFB memory. If a driver wants to ensure that no1617* frames are skipped by the SVGA device, it is important that the1618* driver not modify the source data for a blit until the device is1619* done processing the command. One efficient way to accomplish1620* this is to use a ring of small DMA buffers. Each buffer is used1621* for one blit, then we move on to the next buffer in the1622* ring. The FENCE mechanism is used to protect each buffer from1623* re-use until the device is finished with that buffer's1624* corresponding blit.1625*1626* This command does not affect the meaning of SVGA_CMD_UPDATE.1627* UPDATEs always occur from the legacy GFB memory area. This1628* command has no support for pseudocolor GMRFBs. Currently only1629* true-color 15, 16, and 24-bit depths are supported. Future1630* devices may expose capabilities for additional framebuffer1631* formats.1632*1633* The default GMRFB value is undefined. Drivers must always send1634* this command at least once before performing any blit from the1635* GMRFB.1636*1637* Availability:1638* SVGA_FIFO_CAP_SCREEN_OBJECT or SVGA_FIFO_CAP_SCREEN_OBJECT_21639*/16401641typedef1642struct {1643SVGAGuestPtr ptr;1644uint32 bytesPerLine;1645SVGAGMRImageFormat format;1646} SVGAFifoCmdDefineGMRFB;164716481649/*1650* SVGA_CMD_BLIT_GMRFB_TO_SCREEN --1651*1652* This is a guest-to-host blit. It performs a DMA operation to1653* copy a rectangular region of pixels from the current GMRFB to1654* one or more Screen Objects.1655*1656* The destination coordinate may be specified relative to a1657* screen's origin (if a screen ID is specified) or relative to the1658* virtual coordinate system's origin (if the screen ID is1659* SVGA_ID_INVALID). The actual destination may span zero or more1660* screens, in the case of a virtual destination rect or a rect1661* which extends off the edge of the specified screen.1662*1663* This command writes to the screen's "base layer": the underlying1664* framebuffer which exists below any cursor or video overlays. No1665* action is necessary to explicitly hide or update any overlays1666* which exist on top of the updated region.1667*1668* The SVGA device is guaranteed to finish reading from the GMRFB1669* by the time any subsequent FENCE commands are reached.1670*1671* This command consumes an annotation. See the1672* SVGA_CMD_ANNOTATION_* commands for details.1673*1674* Availability:1675* SVGA_FIFO_CAP_SCREEN_OBJECT or SVGA_FIFO_CAP_SCREEN_OBJECT_21676*/16771678typedef1679struct {1680SVGASignedPoint srcOrigin;1681SVGASignedRect destRect;1682uint32 destScreenId;1683} SVGAFifoCmdBlitGMRFBToScreen;168416851686/*1687* SVGA_CMD_BLIT_SCREEN_TO_GMRFB --1688*1689* This is a host-to-guest blit. It performs a DMA operation to1690* copy a rectangular region of pixels from a single Screen Object1691* back to the current GMRFB.1692*1693* Usage note: This command should be used rarely. It will1694* typically be inefficient, but it is necessary for some types of1695* synchronization between 3D (GPU) and 2D (CPU) rendering into1696* overlapping areas of a screen.1697*1698* The source coordinate is specified relative to a screen's1699* origin. The provided screen ID must be valid. If any parameters1700* are invalid, the resulting pixel values are undefined.1701*1702* This command reads the screen's "base layer". Overlays like1703* video and cursor are not included, but any data which was sent1704* using a blit-to-screen primitive will be available, no matter1705* whether the data's original source was the GMRFB or the 3D1706* acceleration hardware.1707*1708* Note that our guest-to-host blits and host-to-guest blits aren't1709* symmetric in their current implementation. While the parameters1710* are identical, host-to-guest blits are a lot less featureful.1711* They do not support clipping: If the source parameters don't1712* fully fit within a screen, the blit fails. They must originate1713* from exactly one screen. Virtual coordinates are not directly1714* supported.1715*1716* Host-to-guest blits do support the same set of GMRFB formats1717* offered by guest-to-host blits.1718*1719* The SVGA device is guaranteed to finish writing to the GMRFB by1720* the time any subsequent FENCE commands are reached.1721*1722* Availability:1723* SVGA_FIFO_CAP_SCREEN_OBJECT or SVGA_FIFO_CAP_SCREEN_OBJECT_21724*/17251726typedef1727struct {1728SVGASignedPoint destOrigin;1729SVGASignedRect srcRect;1730uint32 srcScreenId;1731} SVGAFifoCmdBlitScreenToGMRFB;173217331734/*1735* SVGA_CMD_ANNOTATION_FILL --1736*1737* This is a blit annotation. This command stores a small piece of1738* device state which is consumed by the next blit-to-screen1739* command. The state is only cleared by commands which are1740* specifically documented as consuming an annotation. Other1741* commands (such as ESCAPEs for debugging) may intervene between1742* the annotation and its associated blit.1743*1744* This annotation is a promise about the contents of the next1745* blit: The video driver is guaranteeing that all pixels in that1746* blit will have the same value, specified here as a color in1747* SVGAColorBGRX format.1748*1749* The SVGA device can still render the blit correctly even if it1750* ignores this annotation, but the annotation may allow it to1751* perform the blit more efficiently, for example by ignoring the1752* source data and performing a fill in hardware.1753*1754* This annotation is most important for performance when the1755* user's display is being remoted over a network connection.1756*1757* Availability:1758* SVGA_FIFO_CAP_SCREEN_OBJECT or SVGA_FIFO_CAP_SCREEN_OBJECT_21759*/17601761typedef1762struct {1763SVGAColorBGRX color;1764} SVGAFifoCmdAnnotationFill;176517661767/*1768* SVGA_CMD_ANNOTATION_COPY --1769*1770* This is a blit annotation. See SVGA_CMD_ANNOTATION_FILL for more1771* information about annotations.1772*1773* This annotation is a promise about the contents of the next1774* blit: The video driver is guaranteeing that all pixels in that1775* blit will have the same value as those which already exist at an1776* identically-sized region on the same or a different screen.1777*1778* Note that the source pixels for the COPY in this annotation are1779* sampled before applying the annotation's associated blit. They1780* are allowed to overlap with the blit's destination pixels.1781*1782* The copy source rectangle is specified the same way as the blit1783* destination: it can be a rectangle which spans zero or more1784* screens, specified relative to either a screen or to the virtual1785* coordinate system's origin. If the source rectangle includes1786* pixels which are not from exactly one screen, the results are1787* undefined.1788*1789* Availability:1790* SVGA_FIFO_CAP_SCREEN_OBJECT or SVGA_FIFO_CAP_SCREEN_OBJECT_21791*/17921793typedef1794struct {1795SVGASignedPoint srcOrigin;1796uint32 srcScreenId;1797} SVGAFifoCmdAnnotationCopy;179817991800/*1801* SVGA_CMD_DEFINE_GMR2 --1802*1803* Define guest memory region v2. See the description of GMRs above.1804*1805* Availability:1806* SVGA_CAP_GMR21807*/18081809typedef1810struct {1811uint32 gmrId;1812uint32 numPages;1813} SVGAFifoCmdDefineGMR2;181418151816/*1817* SVGA_CMD_REMAP_GMR2 --1818*1819* Remap guest memory region v2. See the description of GMRs above.1820*1821* This command allows guest to modify a portion of an existing GMR by1822* invalidating it or reassigning it to different guest physical pages.1823* The pages are identified by physical page number (PPN). The pages1824* are assumed to be pinned and valid for DMA operations.1825*1826* Description of command flags:1827*1828* SVGA_REMAP_GMR2_VIA_GMR: If enabled, references a PPN list in a GMR.1829* The PPN list must not overlap with the remap region (this can be1830* handled trivially by referencing a separate GMR). If flag is1831* disabled, PPN list is appended to SVGARemapGMR command.1832*1833* SVGA_REMAP_GMR2_PPN64: If set, PPN list is in PPN64 format, otherwise1834* it is in PPN32 format.1835*1836* SVGA_REMAP_GMR2_SINGLE_PPN: If set, PPN list contains a single entry.1837* A single PPN can be used to invalidate a portion of a GMR or1838* map it to to a single guest scratch page.1839*1840* Availability:1841* SVGA_CAP_GMR21842*/18431844typedef enum {1845SVGA_REMAP_GMR2_PPN32 = 0,1846SVGA_REMAP_GMR2_VIA_GMR = (1 << 0),1847SVGA_REMAP_GMR2_PPN64 = (1 << 1),1848SVGA_REMAP_GMR2_SINGLE_PPN = (1 << 2),1849} SVGARemapGMR2Flags;18501851typedef1852struct {1853uint32 gmrId;1854SVGARemapGMR2Flags flags;1855uint32 offsetPages; /* offset in pages to begin remap */1856uint32 numPages; /* number of pages to remap */1857/*1858* Followed by additional data depending on SVGARemapGMR2Flags.1859*1860* If flag SVGA_REMAP_GMR2_VIA_GMR is set, single SVGAGuestPtr follows.1861* Otherwise an array of page descriptors in PPN32 or PPN64 format1862* (according to flag SVGA_REMAP_GMR2_PPN64) follows. If flag1863* SVGA_REMAP_GMR2_SINGLE_PPN is set, array contains a single entry.1864*/1865} SVGAFifoCmdRemapGMR2;186618671868/*1869* Size of SVGA device memory such as frame buffer and FIFO.1870*/1871#define SVGA_VRAM_MIN_SIZE (4 * 640 * 480) /* bytes */1872#define SVGA_VRAM_MIN_SIZE_3D (16 * 1024 * 1024)1873#define SVGA_VRAM_MAX_SIZE (128 * 1024 * 1024)1874#define SVGA_MEMORY_SIZE_MAX (1024 * 1024 * 1024)1875#define SVGA_FIFO_SIZE_MAX (2 * 1024 * 1024)1876#define SVGA_GRAPHICS_MEMORY_KB_MIN (32 * 1024)1877#define SVGA_GRAPHICS_MEMORY_KB_MAX (2 * 1024 * 1024)1878#define SVGA_GRAPHICS_MEMORY_KB_DEFAULT (256 * 1024)18791880#define SVGA_VRAM_SIZE_W2K (64 * 1024 * 1024) /* 64 MB */18811882/*1883* To simplify autoDetect display configuration, support a minimum of1884* two 1920x1200 monitors, 32bpp, side-by-side, optionally rotated:1885* numDisplays = 21886* maxWidth = numDisplay * 1920 = 38401887* maxHeight = rotated width of single monitor = 19201888* vramSize = maxWidth * maxHeight * 4 = 294912001889*/1890#define SVGA_VRAM_SIZE_AUTODETECT (32 * 1024 * 1024)18911892#if defined(VMX86_SERVER)1893#define SVGA_VRAM_SIZE (4 * 1024 * 1024)1894#define SVGA_VRAM_SIZE_3D (64 * 1024 * 1024)1895#define SVGA_FIFO_SIZE (256 * 1024)1896#define SVGA_FIFO_SIZE_3D (516 * 1024)1897#define SVGA_MEMORY_SIZE_DEFAULT (160 * 1024 * 1024)1898#define SVGA_AUTODETECT_DEFAULT FALSE1899#else1900#define SVGA_VRAM_SIZE (16 * 1024 * 1024)1901#define SVGA_VRAM_SIZE_3D SVGA_VRAM_MAX_SIZE1902#define SVGA_FIFO_SIZE (2 * 1024 * 1024)1903#define SVGA_FIFO_SIZE_3D SVGA_FIFO_SIZE1904#define SVGA_MEMORY_SIZE_DEFAULT (768 * 1024 * 1024)1905#define SVGA_AUTODETECT_DEFAULT TRUE1906#endif19071908#endif190919101911