VirtualBox

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

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

DevVGA-SVGA: removed obsolete HostWindowId

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 16.1 KB
Line 
1/* $Id: DevVGA-SVGA.h 76249 2018-12-16 09:36:17Z 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 R3 FIFO pointer. */
166 R3PTRTYPE(uint32_t *) pFIFOR3;
167 /** The R0 FIFO pointer. */
168 R0PTRTYPE(uint32_t *) pFIFOR0;
169 /** R3 Opaque pointer to svga state. */
170 R3PTRTYPE(PVMSVGAR3STATE) pSvgaR3State;
171 /** R3 Opaque pointer to 3d state. */
172 R3PTRTYPE(PVMSVGA3DSTATE) p3dState;
173 /** The separate VGA frame buffer in svga mode.
174 * Unlike the the boch-based VGA device implementation, VMSVGA seems to have a
175 * separate frame buffer for VGA and allows concurrent use of both. The SVGA
176 * SDK is making use of this to do VGA text output while testing other things in
177 * SVGA mode, displaying the result by switching back to VGA text mode. So,
178 * when entering SVGA mode we copy the first part of the frame buffer here and
179 * direct VGA accesses here instead. It is copied back when leaving SVGA mode. */
180 R3PTRTYPE(uint8_t *) pbVgaFrameBufferR3;
181 /** R3 Opaque pointer to an external fifo cmd parameter. */
182 R3PTRTYPE(void * volatile) pvFIFOExtCmdParam;
183
184 /** Guest physical address of the FIFO memory range. */
185 RTGCPHYS GCPhysFIFO;
186 /** Size in bytes of the FIFO memory range.
187 * This may be smaller than cbFIFOConfig after restoring an old VM state. */
188 uint32_t cbFIFO;
189 /** The configured FIFO size. */
190 uint32_t cbFIFOConfig;
191 /** SVGA id. */
192 uint32_t u32SVGAId;
193 /** SVGA extensions enabled or not. */
194 uint32_t fEnabled;
195 /** SVGA memory area configured status. */
196 uint32_t fConfigured;
197 /** Device is busy handling FIFO requests (VMSVGA_BUSY_F_FIFO,
198 * VMSVGA_BUSY_F_EMT_FORCE). */
199 uint32_t volatile fBusy;
200#define VMSVGA_BUSY_F_FIFO RT_BIT_32(0) /**< The normal true/false busy FIFO bit. */
201#define VMSVGA_BUSY_F_EMT_FORCE RT_BIT_32(1) /**< Bit preventing race status flickering when EMT kicks the FIFO thread. */
202 /** Traces (dirty page detection) enabled or not. */
203 uint32_t fTraces;
204 /** Guest OS identifier. */
205 uint32_t u32GuestId;
206 /** Scratch region size (VMSVGAState::au32ScratchRegion). */
207 uint32_t cScratchRegion;
208 /** Irq status. */
209 uint32_t u32IrqStatus;
210 /** Irq mask. */
211 uint32_t u32IrqMask;
212 /** Pitch lock. */
213 uint32_t u32PitchLock;
214 /** Current GMR id. (SVGA_REG_GMR_ID) */
215 uint32_t u32CurrentGMRId;
216 /** Register caps. */
217 uint32_t u32RegCaps;
218 /** Physical address of command mmio range. */
219 RTIOPORT BasePort;
220 RTIOPORT Padding0;
221 /** Port io index register. */
222 uint32_t u32IndexReg;
223 /** The support driver session handle for use with FIFORequestSem. */
224 R3R0PTRTYPE(PSUPDRVSESSION) pSupDrvSession;
225 /** FIFO request semaphore. */
226 SUPSEMEVENT FIFORequestSem;
227 /** FIFO external command semaphore. */
228 R3PTRTYPE(RTSEMEVENT) FIFOExtCmdSem;
229 /** FIFO IO Thread. */
230 R3PTRTYPE(PPDMTHREAD) pFIFOIOThread;
231 /** The legacy GFB mode registers. If used, they correspond to screen 0. */
232 /** True when the guest modifies the GFB mode registers. */
233 bool fGFBRegisters;
234 bool afPadding[7];
235 uint32_t uWidth;
236 uint32_t uHeight;
237 uint32_t uBpp;
238 uint32_t cbScanline;
239 /** Maximum width supported. */
240 uint32_t u32MaxWidth;
241 /** Maximum height supported. */
242 uint32_t u32MaxHeight;
243 /** Viewport rectangle, i.e. what's currently visible of the target host
244 * window. This is usually (0,0)(uWidth,uHeight), but if the window is
245 * shrunk and scrolling applied, both the origin and size may differ. */
246 VMSVGAVIEWPORT viewport;
247 /** Action flags */
248 uint32_t u32ActionFlags;
249 /** SVGA 3d extensions enabled or not. */
250 bool f3DEnabled;
251 /** VRAM page monitoring enabled or not. */
252 bool fVRAMTracking;
253 /** External command to be executed in the FIFO thread. */
254 uint8_t volatile u8FIFOExtCommand;
255 /** Set by vmsvgaR3RunExtCmdOnFifoThread when it temporarily resumes the FIFO
256 * thread and does not want it do anything but the command. */
257 bool volatile fFifoExtCommandWakeup;
258#if defined(DEBUG_GMR_ACCESS) || defined(DEBUG_FIFO_ACCESS)
259 /** GMR debug access handler type handle. */
260 PGMPHYSHANDLERTYPE hGmrAccessHandlerType;
261 /** FIFO debug access handler type handle. */
262 PGMPHYSHANDLERTYPE hFifoAccessHandlerType;
263#endif
264 /** Number of GMRs. */
265 uint32_t cGMR;
266 uint32_t uScreenOffset; /* Used only for loading older saved states. */
267
268 /** Scratch array.
269 * Putting this at the end since it's big it probably not . */
270 uint32_t au32ScratchRegion[VMSVGA_SCRATCH_SIZE];
271
272 STAMCOUNTER StatRegBitsPerPixelWr;
273 STAMCOUNTER StatRegBusyWr;
274 STAMCOUNTER StatRegCursorXxxxWr;
275 STAMCOUNTER StatRegDepthWr;
276 STAMCOUNTER StatRegDisplayHeightWr;
277 STAMCOUNTER StatRegDisplayIdWr;
278 STAMCOUNTER StatRegDisplayIsPrimaryWr;
279 STAMCOUNTER StatRegDisplayPositionXWr;
280 STAMCOUNTER StatRegDisplayPositionYWr;
281 STAMCOUNTER StatRegDisplayWidthWr;
282 STAMCOUNTER StatRegEnableWr;
283 STAMCOUNTER StatRegGmrIdWr;
284 STAMCOUNTER StatRegGuestIdWr;
285 STAMCOUNTER StatRegHeightWr;
286 STAMCOUNTER StatRegIdWr;
287 STAMCOUNTER StatRegIrqMaskWr;
288 STAMCOUNTER StatRegNumDisplaysWr;
289 STAMCOUNTER StatRegNumGuestDisplaysWr;
290 STAMCOUNTER StatRegPaletteWr;
291 STAMCOUNTER StatRegPitchLockWr;
292 STAMCOUNTER StatRegPseudoColorWr;
293 STAMCOUNTER StatRegReadOnlyWr;
294 STAMCOUNTER StatRegScratchWr;
295 STAMCOUNTER StatRegSyncWr;
296 STAMCOUNTER StatRegTopWr;
297 STAMCOUNTER StatRegTracesWr;
298 STAMCOUNTER StatRegUnknownWr;
299 STAMCOUNTER StatRegWidthWr;
300
301 STAMCOUNTER StatRegBitsPerPixelRd;
302 STAMCOUNTER StatRegBlueMaskRd;
303 STAMCOUNTER StatRegBusyRd;
304 STAMCOUNTER StatRegBytesPerLineRd;
305 STAMCOUNTER StatRegCapabilitesRd;
306 STAMCOUNTER StatRegConfigDoneRd;
307 STAMCOUNTER StatRegCursorXxxxRd;
308 STAMCOUNTER StatRegDepthRd;
309 STAMCOUNTER StatRegDisplayHeightRd;
310 STAMCOUNTER StatRegDisplayIdRd;
311 STAMCOUNTER StatRegDisplayIsPrimaryRd;
312 STAMCOUNTER StatRegDisplayPositionXRd;
313 STAMCOUNTER StatRegDisplayPositionYRd;
314 STAMCOUNTER StatRegDisplayWidthRd;
315 STAMCOUNTER StatRegEnableRd;
316 STAMCOUNTER StatRegFbOffsetRd;
317 STAMCOUNTER StatRegFbSizeRd;
318 STAMCOUNTER StatRegFbStartRd;
319 STAMCOUNTER StatRegGmrIdRd;
320 STAMCOUNTER StatRegGmrMaxDescriptorLengthRd;
321 STAMCOUNTER StatRegGmrMaxIdsRd;
322 STAMCOUNTER StatRegGmrsMaxPagesRd;
323 STAMCOUNTER StatRegGreenMaskRd;
324 STAMCOUNTER StatRegGuestIdRd;
325 STAMCOUNTER StatRegHeightRd;
326 STAMCOUNTER StatRegHostBitsPerPixelRd;
327 STAMCOUNTER StatRegIdRd;
328 STAMCOUNTER StatRegIrqMaskRd;
329 STAMCOUNTER StatRegMaxHeightRd;
330 STAMCOUNTER StatRegMaxWidthRd;
331 STAMCOUNTER StatRegMemorySizeRd;
332 STAMCOUNTER StatRegMemRegsRd;
333 STAMCOUNTER StatRegMemSizeRd;
334 STAMCOUNTER StatRegMemStartRd;
335 STAMCOUNTER StatRegNumDisplaysRd;
336 STAMCOUNTER StatRegNumGuestDisplaysRd;
337 STAMCOUNTER StatRegPaletteRd;
338 STAMCOUNTER StatRegPitchLockRd;
339 STAMCOUNTER StatRegPsuedoColorRd;
340 STAMCOUNTER StatRegRedMaskRd;
341 STAMCOUNTER StatRegScratchRd;
342 STAMCOUNTER StatRegScratchSizeRd;
343 STAMCOUNTER StatRegSyncRd;
344 STAMCOUNTER StatRegTopRd;
345 STAMCOUNTER StatRegTracesRd;
346 STAMCOUNTER StatRegUnknownRd;
347 STAMCOUNTER StatRegVramSizeRd;
348 STAMCOUNTER StatRegWidthRd;
349 STAMCOUNTER StatRegWriteOnlyRd;
350} VMSVGAState;
351
352
353DECLCALLBACK(int) vmsvgaR3IORegionMap(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iRegion,
354 RTGCPHYS GCPhysAddress, RTGCPHYS cb, PCIADDRESSSPACE enmType);
355
356DECLCALLBACK(void) vmsvgaPortSetViewport(PPDMIDISPLAYPORT pInterface, uint32_t uScreenId,
357 uint32_t x, uint32_t y, uint32_t cx, uint32_t cy);
358
359int vmsvgaInit(PPDMDEVINS pDevIns);
360int vmsvgaReset(PPDMDEVINS pDevIns);
361int vmsvgaDestruct(PPDMDEVINS pDevIns);
362int vmsvgaLoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass);
363int vmsvgaLoadDone(PPDMDEVINS pDevIns);
364int vmsvgaSaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM);
365DECLCALLBACK(void) vmsvgaR3PowerOn(PPDMDEVINS pDevIns);
366DECLCALLBACK(void) vmsvgaR3PowerOff(PPDMDEVINS pDevIns);
367
368typedef struct VGAState *PVGASTATE;
369
370#ifdef IN_RING3
371VMSVGASCREENOBJECT *vmsvgaGetScreenObject(PVGASTATE pThis, uint32_t idScreen);
372int vmsvgaUpdateScreen(PVGASTATE pThis, VMSVGASCREENOBJECT *pScreen, int x, int y, int w, int h);
373#endif
374
375void vmsvgaGMRFree(PVGASTATE pThis, uint32_t idGMR);
376int vmsvgaGMRTransfer(PVGASTATE pThis, const SVGA3dTransferType enmTransferType,
377 uint8_t *pbHstBuf, uint32_t cbHstBuf, uint32_t offHst, int32_t cbHstPitch,
378 SVGAGuestPtr gstPtr, uint32_t offGst, int32_t cbGstPitch,
379 uint32_t cbWidth, uint32_t cHeight);
380
381void vmsvgaClipCopyBox(const SVGA3dSize *pSizeSrc,
382 const SVGA3dSize *pSizeDest,
383 SVGA3dCopyBox *pBox);
384void vmsvgaClipBox(const SVGA3dSize *pSize,
385 SVGA3dBox *pBox);
386void vmsvgaClipRect(SVGASignedRect const *pBound,
387 SVGASignedRect *pRect);
388
389#endif
390
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