VirtualBox

source: vbox/trunk/src/VBox/Devices/Graphics/DevVGA-SVGA.h@ 76196

Last change on this file since 76196 was 76181, checked in by vboxsync, 6 years ago

DevVGA-SVGA: process the three GMRFB related commands when VBOX_WITH_VMSVGA3D is not defined.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 16.2 KB
Line 
1/* $Id: DevVGA-SVGA.h 76181 2018-12-12 15:16:19Z vboxsync $ */
2/** @file
3 * VMware SVGA device
4 */
5/*
6 * Copyright (C) 2013-2017 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 */
16
17#ifndef ___DevVGA_SVGA_h___
18#define ___DevVGA_SVGA_h___
19
20#ifndef VBOX_WITH_VMSVGA
21# error "VBOX_WITH_VMSVGA is not defined"
22#endif
23
24#include <VBox/vmm/pdmthread.h>
25
26#include "vmsvga/svga3d_reg.h"
27
28/** Default FIFO size. */
29#define VMSVGA_FIFO_SIZE _2M
30/** The old FIFO size. */
31#define VMSVGA_FIFO_SIZE_OLD _128K
32
33/** Default scratch region size. */
34#define VMSVGA_SCRATCH_SIZE 0x100
35/** Surface memory available to the guest. */
36#define VMSVGA_SURFACE_SIZE (512*1024*1024)
37/** Maximum GMR pages. */
38#define VMSVGA_MAX_GMR_PAGES 0x100000
39/** Maximum nr of GMR ids. */
40#define VMSVGA_MAX_GMR_IDS _8K
41/** Maximum number of GMR descriptors. */
42#define VMSVGA_MAX_GMR_DESC_LOOP_COUNT VMSVGA_MAX_GMR_PAGES
43
44#define VMSVGA_VAL_UNINITIALIZED (unsigned)-1
45
46/** For validating X and width values.
47 * The code assumes it's at least an order of magnitude less than UINT32_MAX. */
48#define VMSVGA_MAX_X _1M
49/** For validating Y and height values.
50 * The code assumes it's at least an order of magnitude less than UINT32_MAX. */
51#define VMSVGA_MAX_Y _1M
52
53/* u32ActionFlags */
54#define VMSVGA_ACTION_CHANGEMODE_BIT 0
55#define VMSVGA_ACTION_CHANGEMODE RT_BIT(VMSVGA_ACTION_CHANGEMODE_BIT)
56
57
58#ifdef DEBUG
59/* Enable to log FIFO register accesses. */
60//# define DEBUG_FIFO_ACCESS
61/* Enable to log GMR page accesses. */
62//# define DEBUG_GMR_ACCESS
63#endif
64
65#define VMSVGA_FIFO_EXTCMD_NONE 0
66#define VMSVGA_FIFO_EXTCMD_TERMINATE 1
67#define VMSVGA_FIFO_EXTCMD_SAVESTATE 2
68#define VMSVGA_FIFO_EXTCMD_LOADSTATE 3
69#define VMSVGA_FIFO_EXTCMD_RESET 4
70#define VMSVGA_FIFO_EXTCMD_UPDATE_SURFACE_HEAP_BUFFERS 5
71
72/** Size of the region to backup when switching into svga mode. */
73#define VMSVGA_VGA_FB_BACKUP_SIZE _512K
74
75/** @def VMSVGA_WITH_VGA_FB_BACKUP
76 * Enables correct VGA MMIO read/write handling when VMSVGA is enabled. It
77 * is SLOW and probably not entirely right, but it helps with getting 3dmark
78 * output and other stuff. */
79#define VMSVGA_WITH_VGA_FB_BACKUP 1
80
81/** @def VMSVGA_WITH_VGA_FB_BACKUP_AND_IN_RING3
82 * defined(VMSVGA_WITH_VGA_FB_BACKUP) && defined(IN_RING3) */
83#if (defined(VMSVGA_WITH_VGA_FB_BACKUP) && defined(IN_RING3)) || defined(DOXYGEN_RUNNING)
84# define VMSVGA_WITH_VGA_FB_BACKUP_AND_IN_RING3 1
85#else
86# undef VMSVGA_WITH_VGA_FB_BACKUP_AND_IN_RING3
87#endif
88
89/** @def VMSVGA_WITH_VGA_FB_BACKUP_AND_IN_RZ
90 * defined(VMSVGA_WITH_VGA_FB_BACKUP) && !defined(IN_RING3) */
91#if (defined(VMSVGA_WITH_VGA_FB_BACKUP) && !defined(IN_RING3)) || defined(DOXYGEN_RUNNING)
92# define VMSVGA_WITH_VGA_FB_BACKUP_AND_IN_RZ 1
93#else
94# undef VMSVGA_WITH_VGA_FB_BACKUP_AND_IN_RZ
95#endif
96
97
98typedef struct
99{
100 PSSMHANDLE pSSM;
101 uint32_t uVersion;
102 uint32_t uPass;
103} VMSVGA_STATE_LOAD;
104typedef VMSVGA_STATE_LOAD *PVMSVGA_STATE_LOAD;
105
106/** Host screen viewport.
107 * (4th quadrant with negated Y values - usual Windows and X11 world view.) */
108typedef struct VMSVGAVIEWPORT
109{
110 uint32_t x; /**< x coordinate (left). */
111 uint32_t y; /**< y coordinate (top). */
112 uint32_t cx; /**< width. */
113 uint32_t cy; /**< height. */
114 /** Right side coordinate (exclusive). Same as x + cx. */
115 uint32_t xRight;
116 /** First quadrant low y coordinate.
117 * Same as y + cy - 1 in window coordinates. */
118 uint32_t yLowWC;
119 /** First quadrant high y coordinate (exclusive) - yLowWC + cy.
120 * Same as y - 1 in window coordinates. */
121 uint32_t yHighWC;
122 /** Alignment padding. */
123 uint32_t uAlignment;
124} VMSVGAVIEWPORT;
125
126/**
127 * Screen object state.
128 */
129typedef struct VMSVGASCREENOBJECT
130{
131 /** SVGA_SCREEN_* flags. */
132 uint32_t fuScreen;
133 /** The screen object id. */
134 uint32_t idScreen;
135 /** The screen dimensions. */
136 int32_t xOrigin;
137 int32_t yOrigin;
138 uint32_t cWidth;
139 uint32_t cHeight;
140 /** Offset of the screen buffer in the guest VRAM. */
141 uint32_t offVRAM;
142 /** Scanline pitch. */
143 uint32_t cbPitch;
144 /** Bits per pixel. */
145 uint32_t cBpp;
146 bool fDefined;
147 bool fModified;
148} VMSVGASCREENOBJECT;
149
150/** Pointer to the private VMSVGA ring-3 state structure.
151 * @todo Still not entirely satisfired with the type name, but better than
152 * the previous lower/upper case only distinction. */
153typedef struct VMSVGAR3STATE *PVMSVGAR3STATE;
154/** Pointer to the private (implementation specific) VMSVGA3d state. */
155typedef struct VMSVGA3DSTATE *PVMSVGA3DSTATE;
156
157
158/**
159 * The VMSVGA device state.
160 *
161 * This instantatiated as VGASTATE::svga.
162 */
163typedef struct VMSVGAState
164{
165 /** The host window handle */
166 uint64_t u64HostWindowId;
167 /** The R3 FIFO pointer. */
168 R3PTRTYPE(uint32_t *) pFIFOR3;
169 /** The R0 FIFO pointer. */
170 R0PTRTYPE(uint32_t *) pFIFOR0;
171 /** R3 Opaque pointer to svga state. */
172 R3PTRTYPE(PVMSVGAR3STATE) pSvgaR3State;
173 /** R3 Opaque pointer to 3d state. */
174 R3PTRTYPE(PVMSVGA3DSTATE) p3dState;
175 /** The separate VGA frame buffer in svga mode.
176 * Unlike the the boch-based VGA device implementation, VMSVGA seems to have a
177 * separate frame buffer for VGA and allows concurrent use of both. The SVGA
178 * SDK is making use of this to do VGA text output while testing other things in
179 * SVGA mode, displaying the result by switching back to VGA text mode. So,
180 * when entering SVGA mode we copy the first part of the frame buffer here and
181 * direct VGA accesses here instead. It is copied back when leaving SVGA mode. */
182 R3PTRTYPE(uint8_t *) pbVgaFrameBufferR3;
183 /** R3 Opaque pointer to an external fifo cmd parameter. */
184 R3PTRTYPE(void * volatile) pvFIFOExtCmdParam;
185
186 /** Guest physical address of the FIFO memory range. */
187 RTGCPHYS GCPhysFIFO;
188 /** Size in bytes of the FIFO memory range.
189 * This may be smaller than cbFIFOConfig after restoring an old VM state. */
190 uint32_t cbFIFO;
191 /** The configured FIFO size. */
192 uint32_t cbFIFOConfig;
193 /** SVGA id. */
194 uint32_t u32SVGAId;
195 /** SVGA extensions enabled or not. */
196 uint32_t fEnabled;
197 /** SVGA memory area configured status. */
198 uint32_t fConfigured;
199 /** Device is busy handling FIFO requests (VMSVGA_BUSY_F_FIFO,
200 * VMSVGA_BUSY_F_EMT_FORCE). */
201 uint32_t volatile fBusy;
202#define VMSVGA_BUSY_F_FIFO RT_BIT_32(0) /**< The normal true/false busy FIFO bit. */
203#define VMSVGA_BUSY_F_EMT_FORCE RT_BIT_32(1) /**< Bit preventing race status flickering when EMT kicks the FIFO thread. */
204 /** Traces (dirty page detection) enabled or not. */
205 uint32_t fTraces;
206 /** Guest OS identifier. */
207 uint32_t u32GuestId;
208 /** Scratch region size (VMSVGAState::au32ScratchRegion). */
209 uint32_t cScratchRegion;
210 /** Irq status. */
211 uint32_t u32IrqStatus;
212 /** Irq mask. */
213 uint32_t u32IrqMask;
214 /** Pitch lock. */
215 uint32_t u32PitchLock;
216 /** Current GMR id. (SVGA_REG_GMR_ID) */
217 uint32_t u32CurrentGMRId;
218 /** Register caps. */
219 uint32_t u32RegCaps;
220 /** Physical address of command mmio range. */
221 RTIOPORT BasePort;
222 RTIOPORT Padding0;
223 /** Port io index register. */
224 uint32_t u32IndexReg;
225 /** The support driver session handle for use with FIFORequestSem. */
226 R3R0PTRTYPE(PSUPDRVSESSION) pSupDrvSession;
227 /** FIFO request semaphore. */
228 SUPSEMEVENT FIFORequestSem;
229 /** FIFO external command semaphore. */
230 R3PTRTYPE(RTSEMEVENT) FIFOExtCmdSem;
231 /** FIFO IO Thread. */
232 R3PTRTYPE(PPDMTHREAD) pFIFOIOThread;
233 /** The legacy GFB mode registers. If used, they correspond to screen 0. */
234 /** True when the guest modifies the GFB mode registers. */
235 bool fGFBRegisters;
236 bool afPadding[7];
237 uint32_t uWidth;
238 uint32_t uHeight;
239 uint32_t uBpp;
240 uint32_t cbScanline;
241 /** Maximum width supported. */
242 uint32_t u32MaxWidth;
243 /** Maximum height supported. */
244 uint32_t u32MaxHeight;
245 /** Viewport rectangle, i.e. what's currently visible of the target host
246 * window. This is usually (0,0)(uWidth,uHeight), but if the window is
247 * shrunk and scrolling applied, both the origin and size may differ. */
248 VMSVGAVIEWPORT viewport;
249 /** Action flags */
250 uint32_t u32ActionFlags;
251 /** SVGA 3d extensions enabled or not. */
252 bool f3DEnabled;
253 /** VRAM page monitoring enabled or not. */
254 bool fVRAMTracking;
255 /** External command to be executed in the FIFO thread. */
256 uint8_t volatile u8FIFOExtCommand;
257 /** Set by vmsvgaR3RunExtCmdOnFifoThread when it temporarily resumes the FIFO
258 * thread and does not want it do anything but the command. */
259 bool volatile fFifoExtCommandWakeup;
260#if defined(DEBUG_GMR_ACCESS) || defined(DEBUG_FIFO_ACCESS)
261 /** GMR debug access handler type handle. */
262 PGMPHYSHANDLERTYPE hGmrAccessHandlerType;
263 /** FIFO debug access handler type handle. */
264 PGMPHYSHANDLERTYPE hFifoAccessHandlerType;
265#endif
266 /** Number of GMRs. */
267 uint32_t cGMR;
268 uint32_t uScreenOffset; /* Used only for loading older saved states. */
269
270 /** Scratch array.
271 * Putting this at the end since it's big it probably not . */
272 uint32_t au32ScratchRegion[VMSVGA_SCRATCH_SIZE];
273
274 STAMCOUNTER StatRegBitsPerPixelWr;
275 STAMCOUNTER StatRegBusyWr;
276 STAMCOUNTER StatRegCursorXxxxWr;
277 STAMCOUNTER StatRegDepthWr;
278 STAMCOUNTER StatRegDisplayHeightWr;
279 STAMCOUNTER StatRegDisplayIdWr;
280 STAMCOUNTER StatRegDisplayIsPrimaryWr;
281 STAMCOUNTER StatRegDisplayPositionXWr;
282 STAMCOUNTER StatRegDisplayPositionYWr;
283 STAMCOUNTER StatRegDisplayWidthWr;
284 STAMCOUNTER StatRegEnableWr;
285 STAMCOUNTER StatRegGmrIdWr;
286 STAMCOUNTER StatRegGuestIdWr;
287 STAMCOUNTER StatRegHeightWr;
288 STAMCOUNTER StatRegIdWr;
289 STAMCOUNTER StatRegIrqMaskWr;
290 STAMCOUNTER StatRegNumDisplaysWr;
291 STAMCOUNTER StatRegNumGuestDisplaysWr;
292 STAMCOUNTER StatRegPaletteWr;
293 STAMCOUNTER StatRegPitchLockWr;
294 STAMCOUNTER StatRegPseudoColorWr;
295 STAMCOUNTER StatRegReadOnlyWr;
296 STAMCOUNTER StatRegScratchWr;
297 STAMCOUNTER StatRegSyncWr;
298 STAMCOUNTER StatRegTopWr;
299 STAMCOUNTER StatRegTracesWr;
300 STAMCOUNTER StatRegUnknownWr;
301 STAMCOUNTER StatRegWidthWr;
302
303 STAMCOUNTER StatRegBitsPerPixelRd;
304 STAMCOUNTER StatRegBlueMaskRd;
305 STAMCOUNTER StatRegBusyRd;
306 STAMCOUNTER StatRegBytesPerLineRd;
307 STAMCOUNTER StatRegCapabilitesRd;
308 STAMCOUNTER StatRegConfigDoneRd;
309 STAMCOUNTER StatRegCursorXxxxRd;
310 STAMCOUNTER StatRegDepthRd;
311 STAMCOUNTER StatRegDisplayHeightRd;
312 STAMCOUNTER StatRegDisplayIdRd;
313 STAMCOUNTER StatRegDisplayIsPrimaryRd;
314 STAMCOUNTER StatRegDisplayPositionXRd;
315 STAMCOUNTER StatRegDisplayPositionYRd;
316 STAMCOUNTER StatRegDisplayWidthRd;
317 STAMCOUNTER StatRegEnableRd;
318 STAMCOUNTER StatRegFbOffsetRd;
319 STAMCOUNTER StatRegFbSizeRd;
320 STAMCOUNTER StatRegFbStartRd;
321 STAMCOUNTER StatRegGmrIdRd;
322 STAMCOUNTER StatRegGmrMaxDescriptorLengthRd;
323 STAMCOUNTER StatRegGmrMaxIdsRd;
324 STAMCOUNTER StatRegGmrsMaxPagesRd;
325 STAMCOUNTER StatRegGreenMaskRd;
326 STAMCOUNTER StatRegGuestIdRd;
327 STAMCOUNTER StatRegHeightRd;
328 STAMCOUNTER StatRegHostBitsPerPixelRd;
329 STAMCOUNTER StatRegIdRd;
330 STAMCOUNTER StatRegIrqMaskRd;
331 STAMCOUNTER StatRegMaxHeightRd;
332 STAMCOUNTER StatRegMaxWidthRd;
333 STAMCOUNTER StatRegMemorySizeRd;
334 STAMCOUNTER StatRegMemRegsRd;
335 STAMCOUNTER StatRegMemSizeRd;
336 STAMCOUNTER StatRegMemStartRd;
337 STAMCOUNTER StatRegNumDisplaysRd;
338 STAMCOUNTER StatRegNumGuestDisplaysRd;
339 STAMCOUNTER StatRegPaletteRd;
340 STAMCOUNTER StatRegPitchLockRd;
341 STAMCOUNTER StatRegPsuedoColorRd;
342 STAMCOUNTER StatRegRedMaskRd;
343 STAMCOUNTER StatRegScratchRd;
344 STAMCOUNTER StatRegScratchSizeRd;
345 STAMCOUNTER StatRegSyncRd;
346 STAMCOUNTER StatRegTopRd;
347 STAMCOUNTER StatRegTracesRd;
348 STAMCOUNTER StatRegUnknownRd;
349 STAMCOUNTER StatRegVramSizeRd;
350 STAMCOUNTER StatRegWidthRd;
351 STAMCOUNTER StatRegWriteOnlyRd;
352} VMSVGAState;
353
354
355DECLCALLBACK(int) vmsvgaR3IORegionMap(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iRegion,
356 RTGCPHYS GCPhysAddress, RTGCPHYS cb, PCIADDRESSSPACE enmType);
357
358DECLCALLBACK(void) vmsvgaPortSetViewport(PPDMIDISPLAYPORT pInterface, uint32_t uScreenId,
359 uint32_t x, uint32_t y, uint32_t cx, uint32_t cy);
360
361int vmsvgaInit(PPDMDEVINS pDevIns);
362int vmsvgaReset(PPDMDEVINS pDevIns);
363int vmsvgaDestruct(PPDMDEVINS pDevIns);
364int vmsvgaLoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass);
365int vmsvgaLoadDone(PPDMDEVINS pDevIns);
366int vmsvgaSaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM);
367DECLCALLBACK(void) vmsvgaR3PowerOn(PPDMDEVINS pDevIns);
368DECLCALLBACK(void) vmsvgaR3PowerOff(PPDMDEVINS pDevIns);
369
370typedef struct VGAState *PVGASTATE;
371
372#ifdef IN_RING3
373VMSVGASCREENOBJECT *vmsvgaGetScreenObject(PVGASTATE pThis, uint32_t idScreen);
374int vmsvgaUpdateScreen(PVGASTATE pThis, VMSVGASCREENOBJECT *pScreen, int x, int y, int w, int h);
375#endif
376
377void vmsvgaGMRFree(PVGASTATE pThis, uint32_t idGMR);
378int vmsvgaGMRTransfer(PVGASTATE pThis, const SVGA3dTransferType enmTransferType,
379 uint8_t *pbHstBuf, uint32_t cbHstBuf, uint32_t offHst, int32_t cbHstPitch,
380 SVGAGuestPtr gstPtr, uint32_t offGst, int32_t cbGstPitch,
381 uint32_t cbWidth, uint32_t cHeight);
382
383void vmsvgaClipCopyBox(const SVGA3dSize *pSizeSrc,
384 const SVGA3dSize *pSizeDest,
385 SVGA3dCopyBox *pBox);
386void vmsvgaClipBox(const SVGA3dSize *pSize,
387 SVGA3dBox *pBox);
388void vmsvgaClipRect(SVGASignedRect const *pBound,
389 SVGASignedRect *pRect);
390
391#endif
392
Note: See TracBrowser for help on using the repository browser.

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