1 | /* $Id: DevVGA-SVGA.cpp 105182 2024-07-08 11:44:04Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VMware SVGA device.
|
---|
4 | *
|
---|
5 | * Logging levels guidelines for this and related files:
|
---|
6 | * - Log() for normal bits.
|
---|
7 | * - LogFlow() for more info.
|
---|
8 | * - Log2 for hex dump of cursor data.
|
---|
9 | * - Log3 for hex dump of shader code.
|
---|
10 | * - Log4 for hex dumps of 3D data.
|
---|
11 | * - Log5 for info about GMR pages.
|
---|
12 | * - Log6 for DX shaders.
|
---|
13 | * - Log7 for SVGA command dump.
|
---|
14 | * - Log8 for content of constant and vertex buffers.
|
---|
15 | * - LogRel for the usual important stuff.
|
---|
16 | * - LogRel2 for cursor.
|
---|
17 | * - LogRel3 for 3D performance data.
|
---|
18 | * - LogRel4 for HW accelerated graphics output.
|
---|
19 | */
|
---|
20 |
|
---|
21 | /*
|
---|
22 | * Copyright (C) 2013-2023 Oracle and/or its affiliates.
|
---|
23 | *
|
---|
24 | * This file is part of VirtualBox base platform packages, as
|
---|
25 | * available from https://www.virtualbox.org.
|
---|
26 | *
|
---|
27 | * This program is free software; you can redistribute it and/or
|
---|
28 | * modify it under the terms of the GNU General Public License
|
---|
29 | * as published by the Free Software Foundation, in version 3 of the
|
---|
30 | * License.
|
---|
31 | *
|
---|
32 | * This program is distributed in the hope that it will be useful, but
|
---|
33 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
34 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
35 | * General Public License for more details.
|
---|
36 | *
|
---|
37 | * You should have received a copy of the GNU General Public License
|
---|
38 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
39 | *
|
---|
40 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
41 | */
|
---|
42 |
|
---|
43 |
|
---|
44 | /** @page pg_dev_vmsvga VMSVGA - VMware SVGA II Device Emulation
|
---|
45 | *
|
---|
46 | * This device emulation was contributed by trivirt AG. It offers an
|
---|
47 | * alternative to our Bochs based VGA graphics and 3d emulations. This is
|
---|
48 | * valuable for Xorg based guests, as there is driver support shipping with Xorg
|
---|
49 | * since it forked from XFree86.
|
---|
50 | *
|
---|
51 | *
|
---|
52 | * @section sec_dev_vmsvga_sdk The VMware SDK
|
---|
53 | *
|
---|
54 | * This is officially deprecated now, however it's still quite useful,
|
---|
55 | * especially for getting the old features working:
|
---|
56 | * http://vmware-svga.sourceforge.net/
|
---|
57 | *
|
---|
58 | * They currently point developers at the following resources.
|
---|
59 | * - http://cgit.freedesktop.org/xorg/driver/xf86-video-vmware/
|
---|
60 | * - http://cgit.freedesktop.org/mesa/mesa/tree/src/gallium/drivers/svga/
|
---|
61 | * - http://cgit.freedesktop.org/mesa/vmwgfx/
|
---|
62 | *
|
---|
63 | * @subsection subsec_dev_vmsvga_sdk_results Test results
|
---|
64 | *
|
---|
65 | * Test results:
|
---|
66 | * - 2dmark.img:
|
---|
67 | * + todo
|
---|
68 | * - backdoor-tclo.img:
|
---|
69 | * + todo
|
---|
70 | * - blit-cube.img:
|
---|
71 | * + todo
|
---|
72 | * - bunnies.img:
|
---|
73 | * + todo
|
---|
74 | * - cube.img:
|
---|
75 | * + todo
|
---|
76 | * - cubemark.img:
|
---|
77 | * + todo
|
---|
78 | * - dynamic-vertex-stress.img:
|
---|
79 | * + todo
|
---|
80 | * - dynamic-vertex.img:
|
---|
81 | * + todo
|
---|
82 | * - fence-stress.img:
|
---|
83 | * + todo
|
---|
84 | * - gmr-test.img:
|
---|
85 | * + todo
|
---|
86 | * - half-float-test.img:
|
---|
87 | * + todo
|
---|
88 | * - noscreen-cursor.img:
|
---|
89 | * - The CURSOR I/O and FIFO registers are not implemented, so the mouse
|
---|
90 | * cursor doesn't show. (Hacking the GUI a little, would make the cursor
|
---|
91 | * visible though.)
|
---|
92 | * - Cursor animation via the palette doesn't work.
|
---|
93 | * - During debugging, it turns out that the framebuffer content seems to
|
---|
94 | * be halfways ignore or something (memset(fb, 0xcc, lots)).
|
---|
95 | * - Trouble with way to small FIFO and the 256x256 cursor fails. Need to
|
---|
96 | * grow it 0x10 fold (128KB -> 2MB like in WS10).
|
---|
97 | * - null.img:
|
---|
98 | * + todo
|
---|
99 | * - pong.img:
|
---|
100 | * + todo
|
---|
101 | * - presentReadback.img:
|
---|
102 | * + todo
|
---|
103 | * - resolution-set.img:
|
---|
104 | * + todo
|
---|
105 | * - rt-gamma-test.img:
|
---|
106 | * + todo
|
---|
107 | * - screen-annotation.img:
|
---|
108 | * + todo
|
---|
109 | * - screen-cursor.img:
|
---|
110 | * + todo
|
---|
111 | * - screen-dma-coalesce.img:
|
---|
112 | * + todo
|
---|
113 | * - screen-gmr-discontig.img:
|
---|
114 | * + todo
|
---|
115 | * - screen-gmr-remap.img:
|
---|
116 | * + todo
|
---|
117 | * - screen-multimon.img:
|
---|
118 | * + todo
|
---|
119 | * - screen-present-clip.img:
|
---|
120 | * + todo
|
---|
121 | * - screen-render-test.img:
|
---|
122 | * + todo
|
---|
123 | * - screen-simple.img:
|
---|
124 | * + todo
|
---|
125 | * - screen-text.img:
|
---|
126 | * + todo
|
---|
127 | * - simple-shaders.img:
|
---|
128 | * + todo
|
---|
129 | * - simple_blit.img:
|
---|
130 | * + todo
|
---|
131 | * - tiny-2d-updates.img:
|
---|
132 | * + todo
|
---|
133 | * - video-formats.img:
|
---|
134 | * + todo
|
---|
135 | * - video-sync.img:
|
---|
136 | * + todo
|
---|
137 | *
|
---|
138 | */
|
---|
139 |
|
---|
140 |
|
---|
141 | /*********************************************************************************************************************************
|
---|
142 | * Header Files *
|
---|
143 | *********************************************************************************************************************************/
|
---|
144 | #define LOG_GROUP LOG_GROUP_DEV_VMSVGA
|
---|
145 | #include <VBox/vmm/pdmdev.h>
|
---|
146 | #include <VBox/version.h>
|
---|
147 | #include <VBox/err.h>
|
---|
148 | #include <VBox/log.h>
|
---|
149 | #include <VBox/vmm/pgm.h>
|
---|
150 | #include <VBox/sup.h>
|
---|
151 |
|
---|
152 | #include <iprt/assert.h>
|
---|
153 | #include <iprt/semaphore.h>
|
---|
154 | #include <iprt/uuid.h>
|
---|
155 | #ifdef IN_RING3
|
---|
156 | # include <iprt/ctype.h>
|
---|
157 | # include <iprt/mem.h>
|
---|
158 | # ifdef VBOX_STRICT
|
---|
159 | # include <iprt/time.h>
|
---|
160 | # endif
|
---|
161 | #endif
|
---|
162 |
|
---|
163 | #include <VBox/AssertGuest.h>
|
---|
164 | #include <VBox/VMMDev.h>
|
---|
165 | #include <VBoxVideo.h>
|
---|
166 | #include <VBox/bioslogo.h>
|
---|
167 |
|
---|
168 | #ifdef LOG_ENABLED
|
---|
169 | #include "svgadump/svga_dump.h"
|
---|
170 | #endif
|
---|
171 |
|
---|
172 | /* should go BEFORE any other DevVGA include to make all DevVGA.h config defines be visible */
|
---|
173 | #include "DevVGA.h"
|
---|
174 |
|
---|
175 | /* Should be included after DevVGA.h/DevVGA-SVGA.h to pick all defines. */
|
---|
176 | #ifdef VBOX_WITH_VMSVGA3D
|
---|
177 | # include "DevVGA-SVGA3d.h"
|
---|
178 | # ifdef RT_OS_DARWIN
|
---|
179 | # include "DevVGA-SVGA3d-cocoa.h"
|
---|
180 | # endif
|
---|
181 | # ifdef RT_OS_LINUX
|
---|
182 | # ifdef IN_RING3
|
---|
183 | # include "DevVGA-SVGA3d-glLdr.h"
|
---|
184 | # endif
|
---|
185 | # endif
|
---|
186 | #endif
|
---|
187 | #ifdef IN_RING3
|
---|
188 | #include "DevVGA-SVGA-internal.h"
|
---|
189 | #endif
|
---|
190 |
|
---|
191 |
|
---|
192 | /*********************************************************************************************************************************
|
---|
193 | * Defined Constants And Macros *
|
---|
194 | *********************************************************************************************************************************/
|
---|
195 | /**
|
---|
196 | * Macro for checking if a fixed FIFO register is valid according to the
|
---|
197 | * current FIFO configuration.
|
---|
198 | *
|
---|
199 | * @returns true / false.
|
---|
200 | * @param a_iIndex The fifo register index (like SVGA_FIFO_CAPABILITIES).
|
---|
201 | * @param a_offFifoMin A valid SVGA_FIFO_MIN value.
|
---|
202 | */
|
---|
203 | #define VMSVGA_IS_VALID_FIFO_REG(a_iIndex, a_offFifoMin) ( ((a_iIndex) + 1) * sizeof(uint32_t) <= (a_offFifoMin) )
|
---|
204 |
|
---|
205 |
|
---|
206 | /*********************************************************************************************************************************
|
---|
207 | * Structures and Typedefs *
|
---|
208 | *********************************************************************************************************************************/
|
---|
209 |
|
---|
210 |
|
---|
211 | /*********************************************************************************************************************************
|
---|
212 | * Internal Functions *
|
---|
213 | *********************************************************************************************************************************/
|
---|
214 | #ifdef IN_RING3
|
---|
215 | # if defined(VMSVGA_USE_FIFO_ACCESS_HANDLER) || defined(DEBUG_FIFO_ACCESS)
|
---|
216 | static FNPGMPHYSHANDLER vmsvgaR3FifoAccessHandler;
|
---|
217 | # endif
|
---|
218 | # ifdef DEBUG_GMR_ACCESS
|
---|
219 | static FNPGMPHYSHANDLER vmsvgaR3GmrAccessHandler;
|
---|
220 | # endif
|
---|
221 | #endif
|
---|
222 |
|
---|
223 |
|
---|
224 | /*********************************************************************************************************************************
|
---|
225 | * Global Variables *
|
---|
226 | *********************************************************************************************************************************/
|
---|
227 | #ifdef IN_RING3
|
---|
228 |
|
---|
229 | /**
|
---|
230 | * SSM descriptor table for the VMSVGAGMRDESCRIPTOR structure.
|
---|
231 | */
|
---|
232 | static SSMFIELD const g_aVMSVGAGMRDESCRIPTORFields[] =
|
---|
233 | {
|
---|
234 | SSMFIELD_ENTRY_GCPHYS( VMSVGAGMRDESCRIPTOR, GCPhys),
|
---|
235 | SSMFIELD_ENTRY( VMSVGAGMRDESCRIPTOR, numPages),
|
---|
236 | SSMFIELD_ENTRY_TERM()
|
---|
237 | };
|
---|
238 |
|
---|
239 | /**
|
---|
240 | * SSM descriptor table for the GMR structure.
|
---|
241 | */
|
---|
242 | static SSMFIELD const g_aGMRFields[] =
|
---|
243 | {
|
---|
244 | SSMFIELD_ENTRY( GMR, cMaxPages),
|
---|
245 | SSMFIELD_ENTRY( GMR, cbTotal),
|
---|
246 | SSMFIELD_ENTRY( GMR, numDescriptors),
|
---|
247 | SSMFIELD_ENTRY_IGN_HCPTR( GMR, paDesc),
|
---|
248 | SSMFIELD_ENTRY_TERM()
|
---|
249 | };
|
---|
250 |
|
---|
251 | /**
|
---|
252 | * SSM descriptor table for the VMSVGASCREENOBJECT structure.
|
---|
253 | */
|
---|
254 | static SSMFIELD const g_aVMSVGASCREENOBJECTFields[] =
|
---|
255 | {
|
---|
256 | SSMFIELD_ENTRY( VMSVGASCREENOBJECT, fuScreen),
|
---|
257 | SSMFIELD_ENTRY( VMSVGASCREENOBJECT, idScreen),
|
---|
258 | SSMFIELD_ENTRY( VMSVGASCREENOBJECT, xOrigin),
|
---|
259 | SSMFIELD_ENTRY( VMSVGASCREENOBJECT, yOrigin),
|
---|
260 | SSMFIELD_ENTRY( VMSVGASCREENOBJECT, cWidth),
|
---|
261 | SSMFIELD_ENTRY( VMSVGASCREENOBJECT, cHeight),
|
---|
262 | SSMFIELD_ENTRY( VMSVGASCREENOBJECT, offVRAM),
|
---|
263 | SSMFIELD_ENTRY( VMSVGASCREENOBJECT, cbPitch),
|
---|
264 | SSMFIELD_ENTRY( VMSVGASCREENOBJECT, cBpp),
|
---|
265 | SSMFIELD_ENTRY( VMSVGASCREENOBJECT, fDefined),
|
---|
266 | SSMFIELD_ENTRY( VMSVGASCREENOBJECT, fModified),
|
---|
267 | SSMFIELD_ENTRY_VER( VMSVGASCREENOBJECT, cDpi, VGA_SAVEDSTATE_VERSION_VMSVGA_MIPLEVELS),
|
---|
268 | SSMFIELD_ENTRY_TERM()
|
---|
269 | };
|
---|
270 |
|
---|
271 | /**
|
---|
272 | * SSM descriptor table for the VMSVGAR3STATE structure.
|
---|
273 | */
|
---|
274 | static SSMFIELD const g_aVMSVGAR3STATEFields[] =
|
---|
275 | {
|
---|
276 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, paGMR),
|
---|
277 | SSMFIELD_ENTRY( VMSVGAR3STATE, GMRFB),
|
---|
278 | SSMFIELD_ENTRY( VMSVGAR3STATE, Cursor.fActive),
|
---|
279 | SSMFIELD_ENTRY( VMSVGAR3STATE, Cursor.xHotspot),
|
---|
280 | SSMFIELD_ENTRY( VMSVGAR3STATE, Cursor.yHotspot),
|
---|
281 | SSMFIELD_ENTRY( VMSVGAR3STATE, Cursor.width),
|
---|
282 | SSMFIELD_ENTRY( VMSVGAR3STATE, Cursor.height),
|
---|
283 | SSMFIELD_ENTRY( VMSVGAR3STATE, Cursor.cbData),
|
---|
284 | SSMFIELD_ENTRY_IGN_HCPTR( VMSVGAR3STATE, Cursor.pData),
|
---|
285 | SSMFIELD_ENTRY( VMSVGAR3STATE, colorAnnotation),
|
---|
286 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, cBusyDelayedEmts),
|
---|
287 | #ifdef VMSVGA_USE_EMT_HALT_CODE
|
---|
288 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, BusyDelayedEmts),
|
---|
289 | #else
|
---|
290 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, hBusyDelayedEmts),
|
---|
291 | #endif
|
---|
292 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatBusyDelayEmts),
|
---|
293 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3Cmd3dPresentProf),
|
---|
294 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3Cmd3dDrawPrimitivesProf),
|
---|
295 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3Cmd3dSurfaceDmaProf),
|
---|
296 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3Cmd3dBlitSurfaceToScreenProf),
|
---|
297 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3CmdDefineGmr2),
|
---|
298 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3CmdDefineGmr2Free),
|
---|
299 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3CmdDefineGmr2Modify),
|
---|
300 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3CmdRemapGmr2),
|
---|
301 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3CmdRemapGmr2Modify),
|
---|
302 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3CmdInvalidCmd),
|
---|
303 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3CmdFence),
|
---|
304 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3CmdUpdate),
|
---|
305 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3CmdUpdateVerbose),
|
---|
306 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3CmdDefineCursor),
|
---|
307 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3CmdDefineAlphaCursor),
|
---|
308 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3CmdMoveCursor),
|
---|
309 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3CmdDisplayCursor),
|
---|
310 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3CmdRectFill),
|
---|
311 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3CmdRectCopy),
|
---|
312 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3CmdRectRopCopy),
|
---|
313 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3CmdEscape),
|
---|
314 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3CmdDefineScreen),
|
---|
315 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3CmdDestroyScreen),
|
---|
316 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3CmdDefineGmrFb),
|
---|
317 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3CmdBlitGmrFbToScreen),
|
---|
318 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3CmdBlitScreentoGmrFb),
|
---|
319 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3CmdAnnotationFill),
|
---|
320 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3CmdAnnotationCopy),
|
---|
321 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3Cmd3dSurfaceDefine),
|
---|
322 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3Cmd3dSurfaceDefineV2),
|
---|
323 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3Cmd3dSurfaceDestroy),
|
---|
324 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3Cmd3dSurfaceCopy),
|
---|
325 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3Cmd3dSurfaceStretchBlt),
|
---|
326 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3Cmd3dSurfaceDma),
|
---|
327 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3Cmd3dSurfaceScreen),
|
---|
328 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3Cmd3dContextDefine),
|
---|
329 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3Cmd3dContextDestroy),
|
---|
330 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3Cmd3dSetTransform),
|
---|
331 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3Cmd3dSetZRange),
|
---|
332 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3Cmd3dSetRenderState),
|
---|
333 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3Cmd3dSetRenderTarget),
|
---|
334 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3Cmd3dSetTextureState),
|
---|
335 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3Cmd3dSetMaterial),
|
---|
336 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3Cmd3dSetLightData),
|
---|
337 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3Cmd3dSetLightEnable),
|
---|
338 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3Cmd3dSetViewPort),
|
---|
339 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3Cmd3dSetClipPlane),
|
---|
340 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3Cmd3dClear),
|
---|
341 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3Cmd3dPresent),
|
---|
342 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3Cmd3dPresentReadBack),
|
---|
343 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3Cmd3dShaderDefine),
|
---|
344 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3Cmd3dShaderDestroy),
|
---|
345 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3Cmd3dSetShader),
|
---|
346 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3Cmd3dSetShaderConst),
|
---|
347 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3Cmd3dDrawPrimitives),
|
---|
348 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3Cmd3dSetScissorRect),
|
---|
349 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3Cmd3dBeginQuery),
|
---|
350 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3Cmd3dEndQuery),
|
---|
351 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3Cmd3dWaitForQuery),
|
---|
352 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3Cmd3dGenerateMipmaps),
|
---|
353 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3Cmd3dActivateSurface),
|
---|
354 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3Cmd3dDeactivateSurface),
|
---|
355 |
|
---|
356 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3RegConfigDoneWr),
|
---|
357 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3RegGmrDescriptorWr),
|
---|
358 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3RegGmrDescriptorWrErrors),
|
---|
359 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatR3RegGmrDescriptorWrFree),
|
---|
360 |
|
---|
361 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatFifoCommands),
|
---|
362 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatFifoErrors),
|
---|
363 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatFifoUnkCmds),
|
---|
364 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatFifoTodoTimeout),
|
---|
365 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatFifoTodoWoken),
|
---|
366 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatFifoStalls),
|
---|
367 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatFifoExtendedSleep),
|
---|
368 | # if defined(VMSVGA_USE_FIFO_ACCESS_HANDLER) || defined(DEBUG_FIFO_ACCESS)
|
---|
369 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatFifoAccessHandler),
|
---|
370 | # endif
|
---|
371 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatFifoCursorFetchAgain),
|
---|
372 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatFifoCursorNoChange),
|
---|
373 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatFifoCursorPosition),
|
---|
374 | SSMFIELD_ENTRY_IGNORE( VMSVGAR3STATE, StatFifoCursorVisiblity),
|
---|
375 |
|
---|
376 | SSMFIELD_ENTRY_TERM()
|
---|
377 | };
|
---|
378 |
|
---|
379 | /**
|
---|
380 | * SSM descriptor table for the VGAState.svga structure.
|
---|
381 | */
|
---|
382 | static SSMFIELD const g_aVGAStateSVGAFields[] =
|
---|
383 | {
|
---|
384 | SSMFIELD_ENTRY_IGN_GCPHYS( VMSVGAState, GCPhysFIFO),
|
---|
385 | SSMFIELD_ENTRY_IGNORE( VMSVGAState, cbFIFO),
|
---|
386 | SSMFIELD_ENTRY_IGNORE( VMSVGAState, cbFIFOConfig),
|
---|
387 | SSMFIELD_ENTRY( VMSVGAState, u32SVGAId),
|
---|
388 | SSMFIELD_ENTRY( VMSVGAState, fEnabled),
|
---|
389 | SSMFIELD_ENTRY( VMSVGAState, fConfigured),
|
---|
390 | SSMFIELD_ENTRY( VMSVGAState, fBusy),
|
---|
391 | SSMFIELD_ENTRY( VMSVGAState, fTraces),
|
---|
392 | SSMFIELD_ENTRY( VMSVGAState, u32GuestId),
|
---|
393 | SSMFIELD_ENTRY( VMSVGAState, cScratchRegion),
|
---|
394 | SSMFIELD_ENTRY( VMSVGAState, au32ScratchRegion),
|
---|
395 | SSMFIELD_ENTRY( VMSVGAState, u32IrqStatus),
|
---|
396 | SSMFIELD_ENTRY( VMSVGAState, u32IrqMask),
|
---|
397 | SSMFIELD_ENTRY( VMSVGAState, u32PitchLock),
|
---|
398 | SSMFIELD_ENTRY( VMSVGAState, u32CurrentGMRId),
|
---|
399 | SSMFIELD_ENTRY( VMSVGAState, u32DeviceCaps),
|
---|
400 | SSMFIELD_ENTRY_VER( VMSVGAState, u32DeviceCaps2, VGA_SAVEDSTATE_VERSION_VMSVGA_REG_CAP2),
|
---|
401 | SSMFIELD_ENTRY_VER( VMSVGAState, u32GuestDriverId, VGA_SAVEDSTATE_VERSION_VMSVGA_REG_CAP2),
|
---|
402 | SSMFIELD_ENTRY_VER( VMSVGAState, u32GuestDriverVer1, VGA_SAVEDSTATE_VERSION_VMSVGA_REG_CAP2),
|
---|
403 | SSMFIELD_ENTRY_VER( VMSVGAState, u32GuestDriverVer2, VGA_SAVEDSTATE_VERSION_VMSVGA_REG_CAP2),
|
---|
404 | SSMFIELD_ENTRY_VER( VMSVGAState, u32GuestDriverVer3, VGA_SAVEDSTATE_VERSION_VMSVGA_REG_CAP2),
|
---|
405 | SSMFIELD_ENTRY_VER( VMSVGAState, u32FenceLast, VGA_SAVEDSTATE_VERSION_VMSVGA_SVGA3),
|
---|
406 | SSMFIELD_ENTRY( VMSVGAState, u32IndexReg),
|
---|
407 | SSMFIELD_ENTRY_IGNORE( VMSVGAState, hFIFORequestSem),
|
---|
408 | SSMFIELD_ENTRY_IGNORE( VMSVGAState, uLastCursorUpdateCount),
|
---|
409 | SSMFIELD_ENTRY_IGNORE( VMSVGAState, fFIFOThreadSleeping),
|
---|
410 | SSMFIELD_ENTRY_VER( VMSVGAState, fGFBRegisters, VGA_SAVEDSTATE_VERSION_VMSVGA_SCREENS),
|
---|
411 | SSMFIELD_ENTRY( VMSVGAState, uWidth),
|
---|
412 | SSMFIELD_ENTRY( VMSVGAState, uHeight),
|
---|
413 | SSMFIELD_ENTRY( VMSVGAState, uBpp),
|
---|
414 | SSMFIELD_ENTRY( VMSVGAState, cbScanline),
|
---|
415 | SSMFIELD_ENTRY_VER( VMSVGAState, uScreenOffset, VGA_SAVEDSTATE_VERSION_VMSVGA),
|
---|
416 | SSMFIELD_ENTRY_VER( VMSVGAState, uCursorX, VGA_SAVEDSTATE_VERSION_VMSVGA_CURSOR),
|
---|
417 | SSMFIELD_ENTRY_VER( VMSVGAState, uCursorY, VGA_SAVEDSTATE_VERSION_VMSVGA_CURSOR),
|
---|
418 | SSMFIELD_ENTRY_VER( VMSVGAState, uCursorID, VGA_SAVEDSTATE_VERSION_VMSVGA_CURSOR),
|
---|
419 | SSMFIELD_ENTRY_VER( VMSVGAState, uCursorOn, VGA_SAVEDSTATE_VERSION_VMSVGA_CURSOR),
|
---|
420 | SSMFIELD_ENTRY( VMSVGAState, u32MaxWidth),
|
---|
421 | SSMFIELD_ENTRY( VMSVGAState, u32MaxHeight),
|
---|
422 | SSMFIELD_ENTRY( VMSVGAState, u32ActionFlags),
|
---|
423 | SSMFIELD_ENTRY( VMSVGAState, f3DEnabled),
|
---|
424 | SSMFIELD_ENTRY( VMSVGAState, fVRAMTracking),
|
---|
425 | SSMFIELD_ENTRY_IGNORE( VMSVGAState, u8FIFOExtCommand),
|
---|
426 | SSMFIELD_ENTRY_IGNORE( VMSVGAState, fFifoExtCommandWakeup),
|
---|
427 | SSMFIELD_ENTRY_IGNORE( VMSVGAState, cGMR),
|
---|
428 | SSMFIELD_ENTRY_VER( VMSVGAState, au32DevCaps, VGA_SAVEDSTATE_VERSION_VMSVGA_DX),
|
---|
429 | SSMFIELD_ENTRY_VER( VMSVGAState, u32DevCapIndex, VGA_SAVEDSTATE_VERSION_VMSVGA_DX),
|
---|
430 | SSMFIELD_ENTRY_VER( VMSVGAState, u32RegCommandLow, VGA_SAVEDSTATE_VERSION_VMSVGA_DX),
|
---|
431 | SSMFIELD_ENTRY_VER( VMSVGAState, u32RegCommandHigh, VGA_SAVEDSTATE_VERSION_VMSVGA_DX),
|
---|
432 |
|
---|
433 | SSMFIELD_ENTRY_TERM()
|
---|
434 | };
|
---|
435 | #endif /* IN_RING3 */
|
---|
436 |
|
---|
437 |
|
---|
438 | /*********************************************************************************************************************************
|
---|
439 | * Internal Functions *
|
---|
440 | *********************************************************************************************************************************/
|
---|
441 | #ifdef IN_RING3
|
---|
442 | static void vmsvgaR3SetTraces(PPDMDEVINS pDevIns, PVGASTATE pThis, bool fTraces);
|
---|
443 | static int vmsvgaR3LoadExecFifo(PCPDMDEVHLPR3 pHlp, PVGASTATE pThis, PVGASTATECC pThisCC, PSSMHANDLE pSSM,
|
---|
444 | uint32_t uVersion, uint32_t uPass);
|
---|
445 | static int vmsvgaR3SaveExecFifo(PCPDMDEVHLPR3 pHlp, PVGASTATECC pThisCC, PSSMHANDLE pSSM);
|
---|
446 | static void vmsvgaR3CmdBufSubmit(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC, RTGCPHYS GCPhysCB, SVGACBContext CBCtx);
|
---|
447 | static void vmsvgaR3PowerOnDevice(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC, bool fLoadState);
|
---|
448 | #endif /* IN_RING3 */
|
---|
449 |
|
---|
450 |
|
---|
451 | #define SVGA_CASE_ID2STR(idx) case idx: return #idx
|
---|
452 | #if defined(LOG_ENABLED)
|
---|
453 | /**
|
---|
454 | * Index register string name lookup
|
---|
455 | *
|
---|
456 | * @returns Index register string or "UNKNOWN"
|
---|
457 | * @param pThis The shared VGA/VMSVGA state.
|
---|
458 | * @param idxReg The index register.
|
---|
459 | */
|
---|
460 | static const char *vmsvgaIndexToString(PVGASTATE pThis, uint32_t idxReg)
|
---|
461 | {
|
---|
462 | AssertCompile(SVGA_REG_TOP == 84); /* Ensure that the correct headers are used. */
|
---|
463 | switch (idxReg)
|
---|
464 | {
|
---|
465 | SVGA_CASE_ID2STR(SVGA_REG_ID);
|
---|
466 | SVGA_CASE_ID2STR(SVGA_REG_ENABLE);
|
---|
467 | SVGA_CASE_ID2STR(SVGA_REG_WIDTH);
|
---|
468 | SVGA_CASE_ID2STR(SVGA_REG_HEIGHT);
|
---|
469 | SVGA_CASE_ID2STR(SVGA_REG_MAX_WIDTH);
|
---|
470 | SVGA_CASE_ID2STR(SVGA_REG_MAX_HEIGHT);
|
---|
471 | SVGA_CASE_ID2STR(SVGA_REG_DEPTH);
|
---|
472 | SVGA_CASE_ID2STR(SVGA_REG_BITS_PER_PIXEL); /* Current bpp in the guest */
|
---|
473 | SVGA_CASE_ID2STR(SVGA_REG_PSEUDOCOLOR);
|
---|
474 | SVGA_CASE_ID2STR(SVGA_REG_RED_MASK);
|
---|
475 | SVGA_CASE_ID2STR(SVGA_REG_GREEN_MASK);
|
---|
476 | SVGA_CASE_ID2STR(SVGA_REG_BLUE_MASK);
|
---|
477 | SVGA_CASE_ID2STR(SVGA_REG_BYTES_PER_LINE);
|
---|
478 | SVGA_CASE_ID2STR(SVGA_REG_FB_START); /* (Deprecated) */
|
---|
479 | SVGA_CASE_ID2STR(SVGA_REG_FB_OFFSET);
|
---|
480 | SVGA_CASE_ID2STR(SVGA_REG_VRAM_SIZE);
|
---|
481 | SVGA_CASE_ID2STR(SVGA_REG_FB_SIZE);
|
---|
482 |
|
---|
483 | /* ID 0 implementation only had the above registers, then the palette */
|
---|
484 | SVGA_CASE_ID2STR(SVGA_REG_CAPABILITIES);
|
---|
485 | SVGA_CASE_ID2STR(SVGA_REG_MEM_START); /* (Deprecated) */
|
---|
486 | SVGA_CASE_ID2STR(SVGA_REG_MEM_SIZE);
|
---|
487 | SVGA_CASE_ID2STR(SVGA_REG_CONFIG_DONE); /* Set when memory area configured */
|
---|
488 | SVGA_CASE_ID2STR(SVGA_REG_SYNC); /* See "FIFO Synchronization Registers" */
|
---|
489 | SVGA_CASE_ID2STR(SVGA_REG_BUSY); /* See "FIFO Synchronization Registers" */
|
---|
490 | SVGA_CASE_ID2STR(SVGA_REG_GUEST_ID); /* Set guest OS identifier */
|
---|
491 | SVGA_CASE_ID2STR(SVGA_REG_DEAD); /* (Deprecated) SVGA_REG_CURSOR_ID. */
|
---|
492 | SVGA_CASE_ID2STR(SVGA_REG_CURSOR_X); /* (Deprecated) */
|
---|
493 | SVGA_CASE_ID2STR(SVGA_REG_CURSOR_Y); /* (Deprecated) */
|
---|
494 | SVGA_CASE_ID2STR(SVGA_REG_CURSOR_ON); /* (Deprecated) */
|
---|
495 | SVGA_CASE_ID2STR(SVGA_REG_HOST_BITS_PER_PIXEL); /* (Deprecated) */
|
---|
496 | SVGA_CASE_ID2STR(SVGA_REG_SCRATCH_SIZE); /* Number of scratch registers */
|
---|
497 | SVGA_CASE_ID2STR(SVGA_REG_MEM_REGS); /* Number of FIFO registers */
|
---|
498 | SVGA_CASE_ID2STR(SVGA_REG_NUM_DISPLAYS); /* (Deprecated) */
|
---|
499 | SVGA_CASE_ID2STR(SVGA_REG_PITCHLOCK); /* Fixed pitch for all modes */
|
---|
500 | SVGA_CASE_ID2STR(SVGA_REG_IRQMASK); /* Interrupt mask */
|
---|
501 |
|
---|
502 | /* Legacy multi-monitor support */
|
---|
503 | SVGA_CASE_ID2STR(SVGA_REG_NUM_GUEST_DISPLAYS); /* Number of guest displays in X/Y direction */
|
---|
504 | SVGA_CASE_ID2STR(SVGA_REG_DISPLAY_ID); /* Display ID for the following display attributes */
|
---|
505 | SVGA_CASE_ID2STR(SVGA_REG_DISPLAY_IS_PRIMARY); /* Whether this is a primary display */
|
---|
506 | SVGA_CASE_ID2STR(SVGA_REG_DISPLAY_POSITION_X); /* The display position x */
|
---|
507 | SVGA_CASE_ID2STR(SVGA_REG_DISPLAY_POSITION_Y); /* The display position y */
|
---|
508 | SVGA_CASE_ID2STR(SVGA_REG_DISPLAY_WIDTH); /* The display's width */
|
---|
509 | SVGA_CASE_ID2STR(SVGA_REG_DISPLAY_HEIGHT); /* The display's height */
|
---|
510 |
|
---|
511 | SVGA_CASE_ID2STR(SVGA_REG_GMR_ID);
|
---|
512 | SVGA_CASE_ID2STR(SVGA_REG_GMR_DESCRIPTOR);
|
---|
513 | SVGA_CASE_ID2STR(SVGA_REG_GMR_MAX_IDS);
|
---|
514 | SVGA_CASE_ID2STR(SVGA_REG_GMR_MAX_DESCRIPTOR_LENGTH);
|
---|
515 |
|
---|
516 | SVGA_CASE_ID2STR(SVGA_REG_TRACES); /* Enable trace-based updates even when FIFO is on */
|
---|
517 | SVGA_CASE_ID2STR(SVGA_REG_GMRS_MAX_PAGES); /* Maximum number of 4KB pages for all GMRs */
|
---|
518 | SVGA_CASE_ID2STR(SVGA_REG_MEMORY_SIZE); /* Total dedicated device memory excluding FIFO */
|
---|
519 | SVGA_CASE_ID2STR(SVGA_REG_COMMAND_LOW); /* Lower 32 bits and submits commands */
|
---|
520 | SVGA_CASE_ID2STR(SVGA_REG_COMMAND_HIGH); /* Upper 32 bits of command buffer PA */
|
---|
521 | SVGA_CASE_ID2STR(SVGA_REG_MAX_PRIMARY_BOUNDING_BOX_MEM); /* Max primary memory */
|
---|
522 | SVGA_CASE_ID2STR(SVGA_REG_SUGGESTED_GBOBJECT_MEM_SIZE_KB); /* Suggested limit on mob mem */
|
---|
523 | SVGA_CASE_ID2STR(SVGA_REG_DEV_CAP); /* Write dev cap index, read value */
|
---|
524 | SVGA_CASE_ID2STR(SVGA_REG_CMD_PREPEND_LOW);
|
---|
525 | SVGA_CASE_ID2STR(SVGA_REG_CMD_PREPEND_HIGH);
|
---|
526 | SVGA_CASE_ID2STR(SVGA_REG_SCREENTARGET_MAX_WIDTH);
|
---|
527 | SVGA_CASE_ID2STR(SVGA_REG_SCREENTARGET_MAX_HEIGHT);
|
---|
528 | SVGA_CASE_ID2STR(SVGA_REG_MOB_MAX_SIZE);
|
---|
529 | SVGA_CASE_ID2STR(SVGA_REG_BLANK_SCREEN_TARGETS);
|
---|
530 | SVGA_CASE_ID2STR(SVGA_REG_CAP2);
|
---|
531 | SVGA_CASE_ID2STR(SVGA_REG_DEVEL_CAP);
|
---|
532 | SVGA_CASE_ID2STR(SVGA_REG_GUEST_DRIVER_ID);
|
---|
533 | SVGA_CASE_ID2STR(SVGA_REG_GUEST_DRIVER_VERSION1);
|
---|
534 | SVGA_CASE_ID2STR(SVGA_REG_GUEST_DRIVER_VERSION2);
|
---|
535 | SVGA_CASE_ID2STR(SVGA_REG_GUEST_DRIVER_VERSION3);
|
---|
536 | SVGA_CASE_ID2STR(SVGA_REG_CURSOR_MOBID);
|
---|
537 | SVGA_CASE_ID2STR(SVGA_REG_CURSOR_MAX_BYTE_SIZE);
|
---|
538 | SVGA_CASE_ID2STR(SVGA_REG_CURSOR_MAX_DIMENSION);
|
---|
539 | SVGA_CASE_ID2STR(SVGA_REG_FIFO_CAPS);
|
---|
540 | SVGA_CASE_ID2STR(SVGA_REG_FENCE);
|
---|
541 | SVGA_CASE_ID2STR(SVGA_REG_RESERVED1);
|
---|
542 | SVGA_CASE_ID2STR(SVGA_REG_RESERVED2);
|
---|
543 | SVGA_CASE_ID2STR(SVGA_REG_RESERVED3);
|
---|
544 | SVGA_CASE_ID2STR(SVGA_REG_RESERVED4);
|
---|
545 | SVGA_CASE_ID2STR(SVGA_REG_RESERVED5);
|
---|
546 | SVGA_CASE_ID2STR(SVGA_REG_SCREENDMA);
|
---|
547 | SVGA_CASE_ID2STR(SVGA_REG_GBOBJECT_MEM_SIZE_KB);
|
---|
548 | SVGA_CASE_ID2STR(SVGA_REG_REGS_START_HIGH32);
|
---|
549 | SVGA_CASE_ID2STR(SVGA_REG_REGS_START_LOW32);
|
---|
550 | SVGA_CASE_ID2STR(SVGA_REG_FB_START_HIGH32);
|
---|
551 | SVGA_CASE_ID2STR(SVGA_REG_FB_START_LOW32);
|
---|
552 | SVGA_CASE_ID2STR(SVGA_REG_MSHINT);
|
---|
553 | SVGA_CASE_ID2STR(SVGA_REG_IRQ_STATUS);
|
---|
554 | SVGA_CASE_ID2STR(SVGA_REG_DIRTY_TRACKING);
|
---|
555 | SVGA_CASE_ID2STR(SVGA_REG_TOP); /* Must be 1 more than the last register */
|
---|
556 |
|
---|
557 | default:
|
---|
558 | if (idxReg - (uint32_t)SVGA_SCRATCH_BASE < pThis->svga.cScratchRegion)
|
---|
559 | return "SVGA_SCRATCH_BASE reg";
|
---|
560 | if (idxReg - (uint32_t)SVGA_PALETTE_BASE < (uint32_t)SVGA_NUM_PALETTE_REGS)
|
---|
561 | return "SVGA_PALETTE_BASE reg";
|
---|
562 | return "UNKNOWN";
|
---|
563 | }
|
---|
564 | }
|
---|
565 | #endif /* LOG_ENABLED */
|
---|
566 |
|
---|
567 | #if defined(LOG_ENABLED) || (defined(IN_RING3) && defined(VBOX_WITH_VMSVGA3D))
|
---|
568 | static const char *vmsvgaDevCapIndexToString(SVGA3dDevCapIndex idxDevCap)
|
---|
569 | {
|
---|
570 | AssertCompile(SVGA3D_DEVCAP_MAX == 260);
|
---|
571 | switch (idxDevCap)
|
---|
572 | {
|
---|
573 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_INVALID);
|
---|
574 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_3D);
|
---|
575 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_MAX_LIGHTS);
|
---|
576 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_MAX_TEXTURES);
|
---|
577 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_MAX_CLIP_PLANES);
|
---|
578 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_VERTEX_SHADER_VERSION);
|
---|
579 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_VERTEX_SHADER);
|
---|
580 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_FRAGMENT_SHADER_VERSION);
|
---|
581 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_FRAGMENT_SHADER);
|
---|
582 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_MAX_RENDER_TARGETS);
|
---|
583 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_S23E8_TEXTURES);
|
---|
584 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_S10E5_TEXTURES);
|
---|
585 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_MAX_FIXED_VERTEXBLEND);
|
---|
586 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_D16_BUFFER_FORMAT);
|
---|
587 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_D24S8_BUFFER_FORMAT);
|
---|
588 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_D24X8_BUFFER_FORMAT);
|
---|
589 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_QUERY_TYPES);
|
---|
590 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_TEXTURE_GRADIENT_SAMPLING);
|
---|
591 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_MAX_POINT_SIZE);
|
---|
592 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_MAX_SHADER_TEXTURES);
|
---|
593 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_MAX_TEXTURE_WIDTH);
|
---|
594 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_MAX_TEXTURE_HEIGHT);
|
---|
595 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_MAX_VOLUME_EXTENT);
|
---|
596 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_MAX_TEXTURE_REPEAT);
|
---|
597 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_MAX_TEXTURE_ASPECT_RATIO);
|
---|
598 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_MAX_TEXTURE_ANISOTROPY);
|
---|
599 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_MAX_PRIMITIVE_COUNT);
|
---|
600 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_MAX_VERTEX_INDEX);
|
---|
601 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_MAX_VERTEX_SHADER_INSTRUCTIONS);
|
---|
602 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_MAX_FRAGMENT_SHADER_INSTRUCTIONS);
|
---|
603 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_MAX_VERTEX_SHADER_TEMPS);
|
---|
604 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_MAX_FRAGMENT_SHADER_TEMPS);
|
---|
605 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_TEXTURE_OPS);
|
---|
606 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_SURFACEFMT_X8R8G8B8);
|
---|
607 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_SURFACEFMT_A8R8G8B8);
|
---|
608 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_SURFACEFMT_A2R10G10B10);
|
---|
609 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_SURFACEFMT_X1R5G5B5);
|
---|
610 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_SURFACEFMT_A1R5G5B5);
|
---|
611 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_SURFACEFMT_A4R4G4B4);
|
---|
612 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_SURFACEFMT_R5G6B5);
|
---|
613 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_SURFACEFMT_LUMINANCE16);
|
---|
614 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_SURFACEFMT_LUMINANCE8_ALPHA8);
|
---|
615 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_SURFACEFMT_ALPHA8);
|
---|
616 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_SURFACEFMT_LUMINANCE8);
|
---|
617 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_SURFACEFMT_Z_D16);
|
---|
618 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_SURFACEFMT_Z_D24S8);
|
---|
619 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_SURFACEFMT_Z_D24X8);
|
---|
620 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_SURFACEFMT_DXT1);
|
---|
621 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_SURFACEFMT_DXT2);
|
---|
622 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_SURFACEFMT_DXT3);
|
---|
623 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_SURFACEFMT_DXT4);
|
---|
624 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_SURFACEFMT_DXT5);
|
---|
625 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_SURFACEFMT_BUMPX8L8V8U8);
|
---|
626 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_SURFACEFMT_A2W10V10U10);
|
---|
627 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_SURFACEFMT_BUMPU8V8);
|
---|
628 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_SURFACEFMT_Q8W8V8U8);
|
---|
629 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_SURFACEFMT_CxV8U8);
|
---|
630 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_SURFACEFMT_R_S10E5);
|
---|
631 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_SURFACEFMT_R_S23E8);
|
---|
632 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_SURFACEFMT_RG_S10E5);
|
---|
633 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_SURFACEFMT_RG_S23E8);
|
---|
634 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_SURFACEFMT_ARGB_S10E5);
|
---|
635 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_SURFACEFMT_ARGB_S23E8);
|
---|
636 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_MISSING62);
|
---|
637 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_MAX_VERTEX_SHADER_TEXTURES);
|
---|
638 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_MAX_SIMULTANEOUS_RENDER_TARGETS);
|
---|
639 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_SURFACEFMT_V16U16);
|
---|
640 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_SURFACEFMT_G16R16);
|
---|
641 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_SURFACEFMT_A16B16G16R16);
|
---|
642 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_SURFACEFMT_UYVY);
|
---|
643 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_SURFACEFMT_YUY2);
|
---|
644 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DEAD4); /* SVGA3D_DEVCAP_MULTISAMPLE_NONMASKABLESAMPLES */
|
---|
645 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DEAD5); /* SVGA3D_DEVCAP_MULTISAMPLE_MASKABLESAMPLES */
|
---|
646 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DEAD7); /* SVGA3D_DEVCAP_ALPHATOCOVERAGE */
|
---|
647 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DEAD6); /* SVGA3D_DEVCAP_SUPERSAMPLE */
|
---|
648 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_AUTOGENMIPMAPS);
|
---|
649 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_SURFACEFMT_NV12);
|
---|
650 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DEAD10); /* SVGA3D_DEVCAP_SURFACEFMT_AYUV */
|
---|
651 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_MAX_CONTEXT_IDS);
|
---|
652 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_MAX_SURFACE_IDS);
|
---|
653 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_SURFACEFMT_Z_DF16);
|
---|
654 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_SURFACEFMT_Z_DF24);
|
---|
655 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_SURFACEFMT_Z_D24S8_INT);
|
---|
656 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_SURFACEFMT_ATI1);
|
---|
657 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_SURFACEFMT_ATI2);
|
---|
658 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DEAD1);
|
---|
659 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DEAD8); /* SVGA3D_DEVCAP_VIDEO_DECODE */
|
---|
660 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DEAD9); /* SVGA3D_DEVCAP_VIDEO_PROCESS */
|
---|
661 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_LINE_AA);
|
---|
662 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_LINE_STIPPLE);
|
---|
663 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_MAX_LINE_WIDTH);
|
---|
664 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_MAX_AA_LINE_WIDTH);
|
---|
665 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_SURFACEFMT_YV12);
|
---|
666 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DEAD3); /* Old SVGA3D_DEVCAP_LOGICOPS */
|
---|
667 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_TS_COLOR_KEY);
|
---|
668 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DEAD2);
|
---|
669 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXCONTEXT);
|
---|
670 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DEAD11); /* SVGA3D_DEVCAP_MAX_TEXTURE_ARRAY_SIZE */
|
---|
671 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DX_MAX_VERTEXBUFFERS);
|
---|
672 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DX_MAX_CONSTANT_BUFFERS);
|
---|
673 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DX_PROVOKING_VERTEX);
|
---|
674 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_X8R8G8B8);
|
---|
675 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_A8R8G8B8);
|
---|
676 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R5G6B5);
|
---|
677 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_X1R5G5B5);
|
---|
678 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_A1R5G5B5);
|
---|
679 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_A4R4G4B4);
|
---|
680 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_Z_D32);
|
---|
681 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_Z_D16);
|
---|
682 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_Z_D24S8);
|
---|
683 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_Z_D15S1);
|
---|
684 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_LUMINANCE8);
|
---|
685 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_LUMINANCE4_ALPHA4);
|
---|
686 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_LUMINANCE16);
|
---|
687 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_LUMINANCE8_ALPHA8);
|
---|
688 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_DXT1);
|
---|
689 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_DXT2);
|
---|
690 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_DXT3);
|
---|
691 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_DXT4);
|
---|
692 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_DXT5);
|
---|
693 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_BUMPU8V8);
|
---|
694 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_BUMPL6V5U5);
|
---|
695 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_BUMPX8L8V8U8);
|
---|
696 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_FORMAT_DEAD1);
|
---|
697 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_ARGB_S10E5);
|
---|
698 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_ARGB_S23E8);
|
---|
699 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_A2R10G10B10);
|
---|
700 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_V8U8);
|
---|
701 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_Q8W8V8U8);
|
---|
702 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_CxV8U8);
|
---|
703 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_X8L8V8U8);
|
---|
704 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_A2W10V10U10);
|
---|
705 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_ALPHA8);
|
---|
706 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R_S10E5);
|
---|
707 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R_S23E8);
|
---|
708 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_RG_S10E5);
|
---|
709 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_RG_S23E8);
|
---|
710 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_BUFFER);
|
---|
711 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_Z_D24X8);
|
---|
712 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_V16U16);
|
---|
713 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_G16R16);
|
---|
714 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_A16B16G16R16);
|
---|
715 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_UYVY);
|
---|
716 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_YUY2);
|
---|
717 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_NV12);
|
---|
718 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_FORMAT_DEAD2); /* SVGA3D_DEVCAP_DXFMT_AYUV */
|
---|
719 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R32G32B32A32_TYPELESS);
|
---|
720 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R32G32B32A32_UINT);
|
---|
721 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R32G32B32A32_SINT);
|
---|
722 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R32G32B32_TYPELESS);
|
---|
723 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R32G32B32_FLOAT);
|
---|
724 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R32G32B32_UINT);
|
---|
725 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R32G32B32_SINT);
|
---|
726 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R16G16B16A16_TYPELESS);
|
---|
727 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R16G16B16A16_UINT);
|
---|
728 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R16G16B16A16_SNORM);
|
---|
729 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R16G16B16A16_SINT);
|
---|
730 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R32G32_TYPELESS);
|
---|
731 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R32G32_UINT);
|
---|
732 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R32G32_SINT);
|
---|
733 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R32G8X24_TYPELESS);
|
---|
734 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_D32_FLOAT_S8X24_UINT);
|
---|
735 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R32_FLOAT_X8X24);
|
---|
736 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_X32_G8X24_UINT);
|
---|
737 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R10G10B10A2_TYPELESS);
|
---|
738 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R10G10B10A2_UINT);
|
---|
739 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R11G11B10_FLOAT);
|
---|
740 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R8G8B8A8_TYPELESS);
|
---|
741 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R8G8B8A8_UNORM);
|
---|
742 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R8G8B8A8_UNORM_SRGB);
|
---|
743 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R8G8B8A8_UINT);
|
---|
744 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R8G8B8A8_SINT);
|
---|
745 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R16G16_TYPELESS);
|
---|
746 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R16G16_UINT);
|
---|
747 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R16G16_SINT);
|
---|
748 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R32_TYPELESS);
|
---|
749 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_D32_FLOAT);
|
---|
750 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R32_UINT);
|
---|
751 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R32_SINT);
|
---|
752 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R24G8_TYPELESS);
|
---|
753 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_D24_UNORM_S8_UINT);
|
---|
754 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R24_UNORM_X8);
|
---|
755 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_X24_G8_UINT);
|
---|
756 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R8G8_TYPELESS);
|
---|
757 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R8G8_UNORM);
|
---|
758 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R8G8_UINT);
|
---|
759 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R8G8_SINT);
|
---|
760 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R16_TYPELESS);
|
---|
761 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R16_UNORM);
|
---|
762 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R16_UINT);
|
---|
763 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R16_SNORM);
|
---|
764 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R16_SINT);
|
---|
765 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R8_TYPELESS);
|
---|
766 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R8_UNORM);
|
---|
767 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R8_UINT);
|
---|
768 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R8_SNORM);
|
---|
769 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R8_SINT);
|
---|
770 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_P8);
|
---|
771 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R9G9B9E5_SHAREDEXP);
|
---|
772 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R8G8_B8G8_UNORM);
|
---|
773 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_G8R8_G8B8_UNORM);
|
---|
774 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_BC1_TYPELESS);
|
---|
775 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_BC1_UNORM_SRGB);
|
---|
776 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_BC2_TYPELESS);
|
---|
777 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_BC2_UNORM_SRGB);
|
---|
778 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_BC3_TYPELESS);
|
---|
779 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_BC3_UNORM_SRGB);
|
---|
780 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_BC4_TYPELESS);
|
---|
781 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_ATI1);
|
---|
782 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_BC4_SNORM);
|
---|
783 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_BC5_TYPELESS);
|
---|
784 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_ATI2);
|
---|
785 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_BC5_SNORM);
|
---|
786 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R10G10B10_XR_BIAS_A2_UNORM);
|
---|
787 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_B8G8R8A8_TYPELESS);
|
---|
788 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_B8G8R8A8_UNORM_SRGB);
|
---|
789 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_B8G8R8X8_TYPELESS);
|
---|
790 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_B8G8R8X8_UNORM_SRGB);
|
---|
791 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_Z_DF16);
|
---|
792 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_Z_DF24);
|
---|
793 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_Z_D24S8_INT);
|
---|
794 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_YV12);
|
---|
795 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R32G32B32A32_FLOAT);
|
---|
796 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R16G16B16A16_FLOAT);
|
---|
797 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R16G16B16A16_UNORM);
|
---|
798 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R32G32_FLOAT);
|
---|
799 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R10G10B10A2_UNORM);
|
---|
800 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R8G8B8A8_SNORM);
|
---|
801 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R16G16_FLOAT);
|
---|
802 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R16G16_UNORM);
|
---|
803 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R16G16_SNORM);
|
---|
804 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R32_FLOAT);
|
---|
805 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R8G8_SNORM);
|
---|
806 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_R16_FLOAT);
|
---|
807 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_D16_UNORM);
|
---|
808 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_A8_UNORM);
|
---|
809 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_BC1_UNORM);
|
---|
810 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_BC2_UNORM);
|
---|
811 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_BC3_UNORM);
|
---|
812 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_B5G6R5_UNORM);
|
---|
813 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_B5G5R5A1_UNORM);
|
---|
814 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_B8G8R8A8_UNORM);
|
---|
815 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_B8G8R8X8_UNORM);
|
---|
816 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_BC4_UNORM);
|
---|
817 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_BC5_UNORM);
|
---|
818 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_SM41);
|
---|
819 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_MULTISAMPLE_2X);
|
---|
820 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_MULTISAMPLE_4X);
|
---|
821 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_MS_FULL_QUALITY);
|
---|
822 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_LOGICOPS);
|
---|
823 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_LOGIC_BLENDOPS);
|
---|
824 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_RESERVED_1);
|
---|
825 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_BC6H_TYPELESS);
|
---|
826 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_BC6H_UF16);
|
---|
827 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_BC6H_SF16);
|
---|
828 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_BC7_TYPELESS);
|
---|
829 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_BC7_UNORM);
|
---|
830 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_DXFMT_BC7_UNORM_SRGB);
|
---|
831 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_RESERVED_2);
|
---|
832 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_SM5);
|
---|
833 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_MULTISAMPLE_8X);
|
---|
834 |
|
---|
835 | SVGA_CASE_ID2STR(SVGA3D_DEVCAP_MAX);
|
---|
836 |
|
---|
837 | default:
|
---|
838 | break;
|
---|
839 | }
|
---|
840 | return "UNKNOWN";
|
---|
841 | }
|
---|
842 | #endif /* defined(LOG_ENABLED) || (defined(IN_RING3) && defined(VBOX_WITH_VMSVGA3D)) */
|
---|
843 | #undef SVGA_CASE_ID2STR
|
---|
844 |
|
---|
845 |
|
---|
846 | #ifdef IN_RING3
|
---|
847 |
|
---|
848 | /**
|
---|
849 | * @interface_method_impl{PDMIDISPLAYPORT,pfnSetViewport}
|
---|
850 | */
|
---|
851 | DECLCALLBACK(void) vmsvgaR3PortSetViewport(PPDMIDISPLAYPORT pInterface, uint32_t idScreen, uint32_t x, uint32_t y, uint32_t cx, uint32_t cy)
|
---|
852 | {
|
---|
853 | PVGASTATECC pThisCC = RT_FROM_MEMBER(pInterface, VGASTATECC, IPort);
|
---|
854 | PVGASTATE pThis = PDMDEVINS_2_DATA(pThisCC->pDevIns, PVGASTATE);
|
---|
855 |
|
---|
856 | Log(("vmsvgaPortSetViewPort: screen %d (%d,%d)(%d,%d)\n", idScreen, x, y, cx, cy));
|
---|
857 | VMSVGAVIEWPORT const OldViewport = pThis->svga.viewport;
|
---|
858 |
|
---|
859 | /** @todo Test how it interacts with multiple screen objects. */
|
---|
860 | VMSVGASCREENOBJECT *pScreen = vmsvgaR3GetScreenObject(pThisCC, idScreen);
|
---|
861 | uint32_t const uWidth = pScreen ? pScreen->cWidth : 0;
|
---|
862 | uint32_t const uHeight = pScreen ? pScreen->cHeight : 0;
|
---|
863 |
|
---|
864 | if (x < uWidth)
|
---|
865 | {
|
---|
866 | pThis->svga.viewport.x = x;
|
---|
867 | pThis->svga.viewport.cx = RT_MIN(cx, uWidth - x);
|
---|
868 | pThis->svga.viewport.xRight = x + pThis->svga.viewport.cx;
|
---|
869 | }
|
---|
870 | else
|
---|
871 | {
|
---|
872 | pThis->svga.viewport.x = uWidth;
|
---|
873 | pThis->svga.viewport.cx = 0;
|
---|
874 | pThis->svga.viewport.xRight = uWidth;
|
---|
875 | }
|
---|
876 | if (y < uHeight)
|
---|
877 | {
|
---|
878 | pThis->svga.viewport.y = y;
|
---|
879 | pThis->svga.viewport.cy = RT_MIN(cy, uHeight - y);
|
---|
880 | pThis->svga.viewport.yLowWC = uHeight - y - pThis->svga.viewport.cy;
|
---|
881 | pThis->svga.viewport.yHighWC = uHeight - y;
|
---|
882 | }
|
---|
883 | else
|
---|
884 | {
|
---|
885 | pThis->svga.viewport.y = uHeight;
|
---|
886 | pThis->svga.viewport.cy = 0;
|
---|
887 | pThis->svga.viewport.yLowWC = 0;
|
---|
888 | pThis->svga.viewport.yHighWC = 0;
|
---|
889 | }
|
---|
890 |
|
---|
891 | # ifdef VBOX_WITH_VMSVGA3D
|
---|
892 | /*
|
---|
893 | * Now inform the 3D backend.
|
---|
894 | */
|
---|
895 | if (pThis->svga.f3DEnabled)
|
---|
896 | vmsvga3dUpdateHostScreenViewport(pThisCC, idScreen, &OldViewport);
|
---|
897 | # else
|
---|
898 | RT_NOREF(OldViewport);
|
---|
899 | # endif
|
---|
900 | }
|
---|
901 |
|
---|
902 |
|
---|
903 | /**
|
---|
904 | * Updating screen information in API
|
---|
905 | *
|
---|
906 | * @param pThis The The shared VGA/VMSVGA instance data.
|
---|
907 | * @param pThisCC The VGA/VMSVGA state for ring-3.
|
---|
908 | */
|
---|
909 | static void vmsvgaR3VBVAResize(PVGASTATE pThis, PVGASTATECC pThisCC)
|
---|
910 | {
|
---|
911 | int rc;
|
---|
912 |
|
---|
913 | PVMSVGAR3STATE pSVGAState = pThisCC->svga.pSvgaR3State;
|
---|
914 |
|
---|
915 | for (unsigned iScreen = 0; iScreen < RT_ELEMENTS(pSVGAState->aScreens); ++iScreen)
|
---|
916 | {
|
---|
917 | VMSVGASCREENOBJECT *pScreen = &pSVGAState->aScreens[iScreen];
|
---|
918 | if (!pScreen->fModified)
|
---|
919 | continue;
|
---|
920 |
|
---|
921 | pScreen->fModified = false;
|
---|
922 |
|
---|
923 | VBVAINFOVIEW view;
|
---|
924 | RT_ZERO(view);
|
---|
925 | view.u32ViewIndex = pScreen->idScreen;
|
---|
926 | // view.u32ViewOffset = 0;
|
---|
927 | view.u32ViewSize = pThis->vram_size;
|
---|
928 | view.u32MaxScreenSize = pThis->vram_size;
|
---|
929 |
|
---|
930 | VBVAINFOSCREEN screen;
|
---|
931 | RT_ZERO(screen);
|
---|
932 | screen.u32ViewIndex = pScreen->idScreen;
|
---|
933 |
|
---|
934 | if (pScreen->fDefined)
|
---|
935 | {
|
---|
936 | if ( pScreen->cWidth == VMSVGA_VAL_UNINITIALIZED
|
---|
937 | || pScreen->cHeight == VMSVGA_VAL_UNINITIALIZED
|
---|
938 | || pScreen->cBpp == VMSVGA_VAL_UNINITIALIZED)
|
---|
939 | {
|
---|
940 | Assert(pThis->svga.fGFBRegisters);
|
---|
941 | continue;
|
---|
942 | }
|
---|
943 |
|
---|
944 | screen.i32OriginX = pScreen->xOrigin;
|
---|
945 | screen.i32OriginY = pScreen->yOrigin;
|
---|
946 | screen.u32StartOffset = pScreen->offVRAM;
|
---|
947 | screen.u32LineSize = pScreen->cbPitch;
|
---|
948 | screen.u32Width = pScreen->cWidth;
|
---|
949 | screen.u32Height = pScreen->cHeight;
|
---|
950 | screen.u16BitsPerPixel = pScreen->cBpp;
|
---|
951 | if (!(pScreen->fuScreen & SVGA_SCREEN_DEACTIVATE))
|
---|
952 | screen.u16Flags = VBVA_SCREEN_F_ACTIVE;
|
---|
953 | if (pScreen->fuScreen & SVGA_SCREEN_BLANKING)
|
---|
954 | screen.u16Flags |= VBVA_SCREEN_F_BLANK2;
|
---|
955 | }
|
---|
956 | else
|
---|
957 | {
|
---|
958 | /* Screen is destroyed. */
|
---|
959 | screen.u16Flags = VBVA_SCREEN_F_DISABLED;
|
---|
960 | }
|
---|
961 |
|
---|
962 | void *pvVRAM = pScreen->pvScreenBitmap ? pScreen->pvScreenBitmap : pThisCC->pbVRam;
|
---|
963 | rc = pThisCC->pDrv->pfnVBVAResize(pThisCC->pDrv, &view, &screen, pvVRAM, /*fResetInputMapping=*/ true);
|
---|
964 | AssertRC(rc);
|
---|
965 | }
|
---|
966 | }
|
---|
967 |
|
---|
968 |
|
---|
969 | /**
|
---|
970 | * @interface_method_impl{PDMIDISPLAYPORT,pfnReportMonitorPositions}
|
---|
971 | *
|
---|
972 | * Used to update screen offsets (positions) since appearently vmwgfx fails to
|
---|
973 | * pass correct offsets thru FIFO.
|
---|
974 | */
|
---|
975 | DECLCALLBACK(void) vmsvgaR3PortReportMonitorPositions(PPDMIDISPLAYPORT pInterface, uint32_t cPositions, PCRTPOINT paPositions)
|
---|
976 | {
|
---|
977 | PVGASTATECC pThisCC = RT_FROM_MEMBER(pInterface, VGASTATECC, IPort);
|
---|
978 | PVGASTATE pThis = PDMDEVINS_2_DATA(pThisCC->pDevIns, PVGASTATE);
|
---|
979 | PVMSVGAR3STATE pSVGAState = pThisCC->svga.pSvgaR3State;
|
---|
980 |
|
---|
981 | AssertReturnVoid(pSVGAState);
|
---|
982 |
|
---|
983 | /* We assume cPositions is the # of outputs Xserver reports and paPositions is (-1, -1) for disabled monitors. */
|
---|
984 | cPositions = RT_MIN(cPositions, RT_ELEMENTS(pSVGAState->aScreens));
|
---|
985 | for (uint32_t i = 0; i < cPositions; ++i)
|
---|
986 | {
|
---|
987 | if ( pSVGAState->aScreens[i].xOrigin == paPositions[i].x
|
---|
988 | && pSVGAState->aScreens[i].yOrigin == paPositions[i].y)
|
---|
989 | continue;
|
---|
990 |
|
---|
991 | if (paPositions[i].x == -1)
|
---|
992 | continue;
|
---|
993 | if (paPositions[i].y == -1)
|
---|
994 | continue;
|
---|
995 |
|
---|
996 | pSVGAState->aScreens[i].xOrigin = paPositions[i].x;
|
---|
997 | pSVGAState->aScreens[i].yOrigin = paPositions[i].y;
|
---|
998 | pSVGAState->aScreens[i].fModified = true;
|
---|
999 | }
|
---|
1000 |
|
---|
1001 | vmsvgaR3VBVAResize(pThis, pThisCC);
|
---|
1002 | }
|
---|
1003 |
|
---|
1004 | #endif /* IN_RING3 */
|
---|
1005 |
|
---|
1006 | /**
|
---|
1007 | * Read port register
|
---|
1008 | *
|
---|
1009 | * @returns VBox status code.
|
---|
1010 | * @param pDevIns The device instance.
|
---|
1011 | * @param pThis The shared VGA/VMSVGA state.
|
---|
1012 | * @param idxReg The register index being read.
|
---|
1013 | * @param pu32 Where to store the read value
|
---|
1014 | */
|
---|
1015 | static int vmsvgaReadPort(PPDMDEVINS pDevIns, PVGASTATE pThis, uint32_t idxReg, uint32_t *pu32)
|
---|
1016 | {
|
---|
1017 | #ifdef IN_RING3
|
---|
1018 | PVGASTATER3 pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC);
|
---|
1019 | #endif
|
---|
1020 | int rc = VINF_SUCCESS;
|
---|
1021 | *pu32 = 0;
|
---|
1022 |
|
---|
1023 | /* We must adjust the register number if we're in SVGA_ID_0 mode because the PALETTE range moved. */
|
---|
1024 | if ( idxReg >= SVGA_REG_ID_0_TOP
|
---|
1025 | && pThis->svga.u32SVGAId == SVGA_ID_0)
|
---|
1026 | {
|
---|
1027 | idxReg += SVGA_PALETTE_BASE - SVGA_REG_ID_0_TOP;
|
---|
1028 | Log(("vmsvgaReadPort: SVGA_ID_0 reg adj %#x -> %#x\n", pThis->svga.u32IndexReg, idxReg));
|
---|
1029 | }
|
---|
1030 |
|
---|
1031 | switch (idxReg)
|
---|
1032 | {
|
---|
1033 | case SVGA_REG_ID:
|
---|
1034 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegIdRd);
|
---|
1035 | *pu32 = pThis->svga.u32SVGAId;
|
---|
1036 | break;
|
---|
1037 |
|
---|
1038 | case SVGA_REG_ENABLE:
|
---|
1039 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegEnableRd);
|
---|
1040 | *pu32 = pThis->svga.fEnabled;
|
---|
1041 | break;
|
---|
1042 |
|
---|
1043 | case SVGA_REG_WIDTH:
|
---|
1044 | {
|
---|
1045 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegWidthRd);
|
---|
1046 | if ( pThis->svga.fEnabled
|
---|
1047 | && pThis->svga.uWidth != VMSVGA_VAL_UNINITIALIZED)
|
---|
1048 | *pu32 = pThis->svga.uWidth;
|
---|
1049 | else
|
---|
1050 | {
|
---|
1051 | #ifndef IN_RING3
|
---|
1052 | rc = VINF_IOM_R3_IOPORT_READ;
|
---|
1053 | #else
|
---|
1054 | *pu32 = pThisCC->pDrv->cx;
|
---|
1055 | #endif
|
---|
1056 | }
|
---|
1057 | break;
|
---|
1058 | }
|
---|
1059 |
|
---|
1060 | case SVGA_REG_HEIGHT:
|
---|
1061 | {
|
---|
1062 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegHeightRd);
|
---|
1063 | if ( pThis->svga.fEnabled
|
---|
1064 | && pThis->svga.uHeight != VMSVGA_VAL_UNINITIALIZED)
|
---|
1065 | *pu32 = pThis->svga.uHeight;
|
---|
1066 | else
|
---|
1067 | {
|
---|
1068 | #ifndef IN_RING3
|
---|
1069 | rc = VINF_IOM_R3_IOPORT_READ;
|
---|
1070 | #else
|
---|
1071 | *pu32 = pThisCC->pDrv->cy;
|
---|
1072 | #endif
|
---|
1073 | }
|
---|
1074 | break;
|
---|
1075 | }
|
---|
1076 |
|
---|
1077 | case SVGA_REG_MAX_WIDTH:
|
---|
1078 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegMaxWidthRd);
|
---|
1079 | *pu32 = pThis->svga.u32MaxWidth;
|
---|
1080 | break;
|
---|
1081 |
|
---|
1082 | case SVGA_REG_MAX_HEIGHT:
|
---|
1083 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegMaxHeightRd);
|
---|
1084 | *pu32 = pThis->svga.u32MaxHeight;
|
---|
1085 | break;
|
---|
1086 |
|
---|
1087 | case SVGA_REG_DEPTH:
|
---|
1088 | /* This returns the color depth of the current mode. */
|
---|
1089 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegDepthRd);
|
---|
1090 | switch (pThis->svga.uBpp)
|
---|
1091 | {
|
---|
1092 | case 15:
|
---|
1093 | case 16:
|
---|
1094 | case 24:
|
---|
1095 | *pu32 = pThis->svga.uBpp;
|
---|
1096 | break;
|
---|
1097 |
|
---|
1098 | default:
|
---|
1099 | case 32:
|
---|
1100 | *pu32 = 24; /* The upper 8 bits are either alpha bits or not used. */
|
---|
1101 | break;
|
---|
1102 | }
|
---|
1103 | break;
|
---|
1104 |
|
---|
1105 | case SVGA_REG_HOST_BITS_PER_PIXEL: /* (Deprecated) */
|
---|
1106 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegHostBitsPerPixelRd);
|
---|
1107 | *pu32 = pThis->svga.uHostBpp;
|
---|
1108 | break;
|
---|
1109 |
|
---|
1110 | case SVGA_REG_BITS_PER_PIXEL: /* Current bpp in the guest */
|
---|
1111 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegBitsPerPixelRd);
|
---|
1112 | *pu32 = pThis->svga.uBpp;
|
---|
1113 | break;
|
---|
1114 |
|
---|
1115 | case SVGA_REG_PSEUDOCOLOR:
|
---|
1116 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegPsuedoColorRd);
|
---|
1117 | *pu32 = pThis->svga.uBpp == 8; /* See section 6 "Pseudocolor" in svga_interface.txt. */
|
---|
1118 | break;
|
---|
1119 |
|
---|
1120 | case SVGA_REG_RED_MASK:
|
---|
1121 | case SVGA_REG_GREEN_MASK:
|
---|
1122 | case SVGA_REG_BLUE_MASK:
|
---|
1123 | {
|
---|
1124 | uint32_t uBpp;
|
---|
1125 |
|
---|
1126 | if (pThis->svga.fEnabled)
|
---|
1127 | uBpp = pThis->svga.uBpp;
|
---|
1128 | else
|
---|
1129 | uBpp = pThis->svga.uHostBpp;
|
---|
1130 |
|
---|
1131 | uint32_t u32RedMask, u32GreenMask, u32BlueMask;
|
---|
1132 | switch (uBpp)
|
---|
1133 | {
|
---|
1134 | case 8:
|
---|
1135 | u32RedMask = 0x07;
|
---|
1136 | u32GreenMask = 0x38;
|
---|
1137 | u32BlueMask = 0xc0;
|
---|
1138 | break;
|
---|
1139 |
|
---|
1140 | case 15:
|
---|
1141 | u32RedMask = 0x0000001f;
|
---|
1142 | u32GreenMask = 0x000003e0;
|
---|
1143 | u32BlueMask = 0x00007c00;
|
---|
1144 | break;
|
---|
1145 |
|
---|
1146 | case 16:
|
---|
1147 | u32RedMask = 0x0000001f;
|
---|
1148 | u32GreenMask = 0x000007e0;
|
---|
1149 | u32BlueMask = 0x0000f800;
|
---|
1150 | break;
|
---|
1151 |
|
---|
1152 | case 24:
|
---|
1153 | case 32:
|
---|
1154 | default:
|
---|
1155 | u32RedMask = 0x00ff0000;
|
---|
1156 | u32GreenMask = 0x0000ff00;
|
---|
1157 | u32BlueMask = 0x000000ff;
|
---|
1158 | break;
|
---|
1159 | }
|
---|
1160 | switch (idxReg)
|
---|
1161 | {
|
---|
1162 | case SVGA_REG_RED_MASK:
|
---|
1163 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegRedMaskRd);
|
---|
1164 | *pu32 = u32RedMask;
|
---|
1165 | break;
|
---|
1166 |
|
---|
1167 | case SVGA_REG_GREEN_MASK:
|
---|
1168 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegGreenMaskRd);
|
---|
1169 | *pu32 = u32GreenMask;
|
---|
1170 | break;
|
---|
1171 |
|
---|
1172 | case SVGA_REG_BLUE_MASK:
|
---|
1173 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegBlueMaskRd);
|
---|
1174 | *pu32 = u32BlueMask;
|
---|
1175 | break;
|
---|
1176 | }
|
---|
1177 | break;
|
---|
1178 | }
|
---|
1179 |
|
---|
1180 | case SVGA_REG_BYTES_PER_LINE:
|
---|
1181 | {
|
---|
1182 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegBytesPerLineRd);
|
---|
1183 | if ( pThis->svga.fEnabled
|
---|
1184 | && pThis->svga.cbScanline)
|
---|
1185 | *pu32 = pThis->svga.cbScanline;
|
---|
1186 | else
|
---|
1187 | {
|
---|
1188 | #ifndef IN_RING3
|
---|
1189 | rc = VINF_IOM_R3_IOPORT_READ;
|
---|
1190 | #else
|
---|
1191 | *pu32 = pThisCC->pDrv->cbScanline;
|
---|
1192 | #endif
|
---|
1193 | }
|
---|
1194 | break;
|
---|
1195 | }
|
---|
1196 |
|
---|
1197 | case SVGA_REG_VRAM_SIZE: /* VRAM size */
|
---|
1198 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegVramSizeRd);
|
---|
1199 | *pu32 = pThis->vram_size;
|
---|
1200 | break;
|
---|
1201 |
|
---|
1202 | case SVGA_REG_FB_START: /* Frame buffer physical address. */
|
---|
1203 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegFbStartRd);
|
---|
1204 | Assert(pThis->GCPhysVRAM <= 0xffffffff);
|
---|
1205 | *pu32 = pThis->GCPhysVRAM;
|
---|
1206 | break;
|
---|
1207 |
|
---|
1208 | case SVGA_REG_FB_OFFSET: /* Offset of the frame buffer in VRAM */
|
---|
1209 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegFbOffsetRd);
|
---|
1210 | /* Always zero in our case. */
|
---|
1211 | *pu32 = 0;
|
---|
1212 | break;
|
---|
1213 |
|
---|
1214 | case SVGA_REG_FB_SIZE: /* Frame buffer size */
|
---|
1215 | {
|
---|
1216 | #ifndef IN_RING3
|
---|
1217 | rc = VINF_IOM_R3_IOPORT_READ;
|
---|
1218 | #else
|
---|
1219 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegFbSizeRd);
|
---|
1220 |
|
---|
1221 | /* VMWare testcases want at least 4 MB in case the hardware is disabled. */
|
---|
1222 | if ( pThis->svga.fEnabled
|
---|
1223 | && pThis->svga.uHeight != VMSVGA_VAL_UNINITIALIZED)
|
---|
1224 | {
|
---|
1225 | /* Hardware enabled; return real framebuffer size .*/
|
---|
1226 | *pu32 = (uint32_t)pThis->svga.uHeight * pThis->svga.cbScanline;
|
---|
1227 | }
|
---|
1228 | else
|
---|
1229 | *pu32 = RT_MAX(0x100000, (uint32_t)pThisCC->pDrv->cy * pThisCC->pDrv->cbScanline);
|
---|
1230 |
|
---|
1231 | *pu32 = RT_MIN(pThis->vram_size, *pu32);
|
---|
1232 | Log(("h=%d w=%d bpp=%d\n", pThisCC->pDrv->cy, pThisCC->pDrv->cx, pThisCC->pDrv->cBits));
|
---|
1233 | #endif
|
---|
1234 | break;
|
---|
1235 | }
|
---|
1236 |
|
---|
1237 | case SVGA_REG_CAPABILITIES:
|
---|
1238 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegCapabilitesRd);
|
---|
1239 | *pu32 = pThis->svga.u32DeviceCaps;
|
---|
1240 | break;
|
---|
1241 |
|
---|
1242 | case SVGA_REG_MEM_START: /* FIFO start */
|
---|
1243 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegMemStartRd);
|
---|
1244 | Assert(pThis->svga.GCPhysFIFO <= 0xffffffff);
|
---|
1245 | *pu32 = pThis->svga.GCPhysFIFO;
|
---|
1246 | break;
|
---|
1247 |
|
---|
1248 | case SVGA_REG_MEM_SIZE: /* FIFO size */
|
---|
1249 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegMemSizeRd);
|
---|
1250 | *pu32 = pThis->svga.cbFIFO;
|
---|
1251 | break;
|
---|
1252 |
|
---|
1253 | case SVGA_REG_CONFIG_DONE: /* Set when memory area configured */
|
---|
1254 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegConfigDoneRd);
|
---|
1255 | *pu32 = pThis->svga.fConfigured;
|
---|
1256 | break;
|
---|
1257 |
|
---|
1258 | case SVGA_REG_SYNC: /* See "FIFO Synchronization Registers" */
|
---|
1259 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegSyncRd);
|
---|
1260 | *pu32 = 0;
|
---|
1261 | break;
|
---|
1262 |
|
---|
1263 | case SVGA_REG_BUSY: /* See "FIFO Synchronization Registers" */
|
---|
1264 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegBusyRd);
|
---|
1265 | if (pThis->svga.fBusy)
|
---|
1266 | {
|
---|
1267 | #ifndef IN_RING3
|
---|
1268 | /* Go to ring-3 and halt the CPU. */
|
---|
1269 | rc = VINF_IOM_R3_IOPORT_READ;
|
---|
1270 | RT_NOREF(pDevIns);
|
---|
1271 | break;
|
---|
1272 | #else /* IN_RING3 */
|
---|
1273 | # if defined(VMSVGA_USE_EMT_HALT_CODE)
|
---|
1274 | /* The guest is basically doing a HLT via the device here, but with
|
---|
1275 | a special wake up condition on FIFO completion. */
|
---|
1276 | PVMSVGAR3STATE pSVGAState = pThisCC->svga.pSvgaR3State;
|
---|
1277 | STAM_REL_PROFILE_START(&pSVGAState->StatBusyDelayEmts, EmtDelay);
|
---|
1278 | VMCPUID idCpu = PDMDevHlpGetCurrentCpuId(pDevIns);
|
---|
1279 | VMCPUSET_ATOMIC_ADD(&pSVGAState->BusyDelayedEmts, idCpu);
|
---|
1280 | ASMAtomicIncU32(&pSVGAState->cBusyDelayedEmts);
|
---|
1281 | if (pThis->svga.fBusy)
|
---|
1282 | {
|
---|
1283 | PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect); /* hack around lock order issue. */
|
---|
1284 | rc = PDMDevHlpVMWaitForDeviceReady(pDevIns, idCpu);
|
---|
1285 | int const rcLock = PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED);
|
---|
1286 | PDM_CRITSECT_RELEASE_ASSERT_RC_DEV(pDevIns, &pThis->CritSect, rcLock);
|
---|
1287 | }
|
---|
1288 | ASMAtomicDecU32(&pSVGAState->cBusyDelayedEmts);
|
---|
1289 | VMCPUSET_ATOMIC_DEL(&pSVGAState->BusyDelayedEmts, idCpu);
|
---|
1290 | # else
|
---|
1291 |
|
---|
1292 | /* Delay the EMT a bit so the FIFO and others can get some work done.
|
---|
1293 | This used to be a crude 50 ms sleep. The current code tries to be
|
---|
1294 | more efficient, but the consept is still very crude. */
|
---|
1295 | PVMSVGAR3STATE pSVGAState = pThisCC->svga.pSvgaR3State;
|
---|
1296 | STAM_REL_PROFILE_START(&pSVGAState->StatBusyDelayEmts, EmtDelay);
|
---|
1297 | RTThreadYield();
|
---|
1298 | if (pThis->svga.fBusy)
|
---|
1299 | {
|
---|
1300 | uint32_t cRefs = ASMAtomicIncU32(&pSVGAState->cBusyDelayedEmts);
|
---|
1301 |
|
---|
1302 | if (pThis->svga.fBusy && cRefs == 1)
|
---|
1303 | RTSemEventMultiReset(pSVGAState->hBusyDelayedEmts);
|
---|
1304 | if (pThis->svga.fBusy)
|
---|
1305 | {
|
---|
1306 | /** @todo If this code is going to stay, we need to call into the halt/wait
|
---|
1307 | * code in VMEmt.cpp here, otherwise all kind of EMT interaction will
|
---|
1308 | * suffer when the guest is polling on a busy FIFO. */
|
---|
1309 | uint64_t uIgnored1, uIgnored2;
|
---|
1310 | uint64_t cNsMaxWait = TMVirtualSyncGetNsToDeadline(PDMDevHlpGetVM(pDevIns), &uIgnored1, &uIgnored2);
|
---|
1311 | if (cNsMaxWait >= RT_NS_100US)
|
---|
1312 | RTSemEventMultiWaitEx(pSVGAState->hBusyDelayedEmts,
|
---|
1313 | RTSEMWAIT_FLAGS_NANOSECS | RTSEMWAIT_FLAGS_RELATIVE | RTSEMWAIT_FLAGS_NORESUME,
|
---|
1314 | RT_MIN(cNsMaxWait, RT_NS_10MS));
|
---|
1315 | }
|
---|
1316 |
|
---|
1317 | ASMAtomicDecU32(&pSVGAState->cBusyDelayedEmts);
|
---|
1318 | }
|
---|
1319 | STAM_REL_PROFILE_STOP(&pSVGAState->StatBusyDelayEmts, EmtDelay);
|
---|
1320 | # endif
|
---|
1321 | *pu32 = pThis->svga.fBusy != 0;
|
---|
1322 | #endif /* IN_RING3 */
|
---|
1323 | }
|
---|
1324 | else
|
---|
1325 | *pu32 = false;
|
---|
1326 | break;
|
---|
1327 |
|
---|
1328 | case SVGA_REG_GUEST_ID: /* Set guest OS identifier */
|
---|
1329 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegGuestIdRd);
|
---|
1330 | *pu32 = pThis->svga.u32GuestId;
|
---|
1331 | break;
|
---|
1332 |
|
---|
1333 | case SVGA_REG_SCRATCH_SIZE: /* Number of scratch registers */
|
---|
1334 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegScratchSizeRd);
|
---|
1335 | *pu32 = pThis->svga.cScratchRegion;
|
---|
1336 | break;
|
---|
1337 |
|
---|
1338 | case SVGA_REG_MEM_REGS: /* Number of FIFO registers */
|
---|
1339 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegMemRegsRd);
|
---|
1340 | *pu32 = SVGA_FIFO_NUM_REGS;
|
---|
1341 | break;
|
---|
1342 |
|
---|
1343 | case SVGA_REG_PITCHLOCK: /* Fixed pitch for all modes */
|
---|
1344 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegPitchLockRd);
|
---|
1345 | *pu32 = pThis->svga.u32PitchLock;
|
---|
1346 | break;
|
---|
1347 |
|
---|
1348 | case SVGA_REG_IRQMASK: /* Interrupt mask */
|
---|
1349 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegIrqMaskRd);
|
---|
1350 | *pu32 = pThis->svga.u32IrqMask;
|
---|
1351 | break;
|
---|
1352 |
|
---|
1353 | /* See "Guest memory regions" below. */
|
---|
1354 | case SVGA_REG_GMR_ID:
|
---|
1355 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegGmrIdRd);
|
---|
1356 | *pu32 = pThis->svga.u32CurrentGMRId;
|
---|
1357 | break;
|
---|
1358 |
|
---|
1359 | case SVGA_REG_GMR_DESCRIPTOR:
|
---|
1360 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegWriteOnlyRd);
|
---|
1361 | /* Write only */
|
---|
1362 | *pu32 = 0;
|
---|
1363 | break;
|
---|
1364 |
|
---|
1365 | case SVGA_REG_GMR_MAX_IDS:
|
---|
1366 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegGmrMaxIdsRd);
|
---|
1367 | *pu32 = pThis->svga.cGMR;
|
---|
1368 | break;
|
---|
1369 |
|
---|
1370 | case SVGA_REG_GMR_MAX_DESCRIPTOR_LENGTH:
|
---|
1371 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegGmrMaxDescriptorLengthRd);
|
---|
1372 | *pu32 = VMSVGA_MAX_GMR_PAGES;
|
---|
1373 | break;
|
---|
1374 |
|
---|
1375 | case SVGA_REG_TRACES: /* Enable trace-based updates even when FIFO is on */
|
---|
1376 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegTracesRd);
|
---|
1377 | *pu32 = pThis->svga.fTraces;
|
---|
1378 | break;
|
---|
1379 |
|
---|
1380 | case SVGA_REG_GMRS_MAX_PAGES: /* Maximum number of 4KB pages for all GMRs */
|
---|
1381 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegGmrsMaxPagesRd);
|
---|
1382 | *pu32 = VMSVGA_MAX_GMR_PAGES;
|
---|
1383 | break;
|
---|
1384 |
|
---|
1385 | case SVGA_REG_MEMORY_SIZE: /* Total dedicated device memory excluding FIFO */
|
---|
1386 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegMemorySizeRd);
|
---|
1387 | *pu32 = VMSVGA_SURFACE_SIZE;
|
---|
1388 | break;
|
---|
1389 |
|
---|
1390 | case SVGA_REG_TOP: /* Must be 1 more than the last register */
|
---|
1391 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegTopRd);
|
---|
1392 | break;
|
---|
1393 |
|
---|
1394 | /* Mouse cursor support. */
|
---|
1395 | case SVGA_REG_DEAD: /* SVGA_REG_CURSOR_ID */
|
---|
1396 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegCursorIdRd);
|
---|
1397 | *pu32 = pThis->svga.uCursorID;
|
---|
1398 | break;
|
---|
1399 |
|
---|
1400 | case SVGA_REG_CURSOR_X:
|
---|
1401 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegCursorXRd);
|
---|
1402 | *pu32 = pThis->svga.uCursorX;
|
---|
1403 | break;
|
---|
1404 |
|
---|
1405 | case SVGA_REG_CURSOR_Y:
|
---|
1406 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegCursorYRd);
|
---|
1407 | *pu32 = pThis->svga.uCursorY;
|
---|
1408 | break;
|
---|
1409 |
|
---|
1410 | case SVGA_REG_CURSOR_ON:
|
---|
1411 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegCursorOnRd);
|
---|
1412 | *pu32 = pThis->svga.uCursorOn;
|
---|
1413 | break;
|
---|
1414 |
|
---|
1415 | /* Legacy multi-monitor support */
|
---|
1416 | case SVGA_REG_NUM_GUEST_DISPLAYS:/* Number of guest displays in X/Y direction */
|
---|
1417 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegNumGuestDisplaysRd);
|
---|
1418 | *pu32 = 1;
|
---|
1419 | break;
|
---|
1420 |
|
---|
1421 | case SVGA_REG_DISPLAY_ID: /* Display ID for the following display attributes */
|
---|
1422 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegDisplayIdRd);
|
---|
1423 | *pu32 = 0;
|
---|
1424 | break;
|
---|
1425 |
|
---|
1426 | case SVGA_REG_DISPLAY_IS_PRIMARY:/* Whether this is a primary display */
|
---|
1427 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegDisplayIsPrimaryRd);
|
---|
1428 | *pu32 = 0;
|
---|
1429 | break;
|
---|
1430 |
|
---|
1431 | case SVGA_REG_DISPLAY_POSITION_X:/* The display position x */
|
---|
1432 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegDisplayPositionXRd);
|
---|
1433 | *pu32 = 0;
|
---|
1434 | break;
|
---|
1435 |
|
---|
1436 | case SVGA_REG_DISPLAY_POSITION_Y:/* The display position y */
|
---|
1437 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegDisplayPositionYRd);
|
---|
1438 | *pu32 = 0;
|
---|
1439 | break;
|
---|
1440 |
|
---|
1441 | case SVGA_REG_DISPLAY_WIDTH: /* The display's width */
|
---|
1442 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegDisplayWidthRd);
|
---|
1443 | *pu32 = pThis->svga.uWidth;
|
---|
1444 | break;
|
---|
1445 |
|
---|
1446 | case SVGA_REG_DISPLAY_HEIGHT: /* The display's height */
|
---|
1447 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegDisplayHeightRd);
|
---|
1448 | *pu32 = pThis->svga.uHeight;
|
---|
1449 | break;
|
---|
1450 |
|
---|
1451 | case SVGA_REG_NUM_DISPLAYS: /* (Deprecated) */
|
---|
1452 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegNumDisplaysRd);
|
---|
1453 | /* We must return something sensible here otherwise the Linux driver
|
---|
1454 | will take a legacy code path without 3d support. This number also
|
---|
1455 | limits how many screens Linux guests will allow. */
|
---|
1456 | *pu32 = pThis->cMonitors;
|
---|
1457 | break;
|
---|
1458 |
|
---|
1459 | /*
|
---|
1460 | * SVGA_CAP_GBOBJECTS+ registers.
|
---|
1461 | */
|
---|
1462 | case SVGA_REG_COMMAND_LOW:
|
---|
1463 | /* Lower 32 bits of command buffer physical address. */
|
---|
1464 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegCommandLowRd);
|
---|
1465 | *pu32 = pThis->svga.u32RegCommandLow;
|
---|
1466 | break;
|
---|
1467 |
|
---|
1468 | case SVGA_REG_COMMAND_HIGH:
|
---|
1469 | /* Upper 32 bits of command buffer PA. */
|
---|
1470 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegCommandHighRd);
|
---|
1471 | *pu32 = pThis->svga.u32RegCommandHigh;
|
---|
1472 | break;
|
---|
1473 |
|
---|
1474 | case SVGA_REG_MAX_PRIMARY_BOUNDING_BOX_MEM:
|
---|
1475 | /* Max primary (screen) memory. */
|
---|
1476 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegMaxPrimBBMemRd);
|
---|
1477 | *pu32 = pThis->vram_size; /** @todo Maybe half VRAM? */
|
---|
1478 | break;
|
---|
1479 |
|
---|
1480 | case SVGA_REG_SUGGESTED_GBOBJECT_MEM_SIZE_KB:
|
---|
1481 | /* Suggested limit on mob mem (i.e. size of the guest mapped VRAM in KB) */
|
---|
1482 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegGBMemSizeRd);
|
---|
1483 | *pu32 = pThis->vram_size / 1024;
|
---|
1484 | break;
|
---|
1485 |
|
---|
1486 | case SVGA_REG_DEV_CAP:
|
---|
1487 | /* Write dev cap index, read value */
|
---|
1488 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegDevCapRd);
|
---|
1489 | if (pThis->svga.u32DevCapIndex < RT_ELEMENTS(pThis->svga.au32DevCaps))
|
---|
1490 | {
|
---|
1491 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
1492 | *pu32 = pThis->svga.au32DevCaps[pThis->svga.u32DevCapIndex];
|
---|
1493 | }
|
---|
1494 | else
|
---|
1495 | *pu32 = 0;
|
---|
1496 | break;
|
---|
1497 |
|
---|
1498 | case SVGA_REG_CMD_PREPEND_LOW:
|
---|
1499 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegCmdPrependLowRd);
|
---|
1500 | *pu32 = 0; /* Not supported. */
|
---|
1501 | break;
|
---|
1502 |
|
---|
1503 | case SVGA_REG_CMD_PREPEND_HIGH:
|
---|
1504 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegCmdPrependHighRd);
|
---|
1505 | *pu32 = 0; /* Not supported. */
|
---|
1506 | break;
|
---|
1507 |
|
---|
1508 | case SVGA_REG_SCREENTARGET_MAX_WIDTH:
|
---|
1509 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegScrnTgtMaxWidthRd);
|
---|
1510 | *pu32 = pThis->svga.u32MaxWidth;
|
---|
1511 | break;
|
---|
1512 |
|
---|
1513 | case SVGA_REG_SCREENTARGET_MAX_HEIGHT:
|
---|
1514 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegScrnTgtMaxHeightRd);
|
---|
1515 | *pu32 = pThis->svga.u32MaxHeight;
|
---|
1516 | break;
|
---|
1517 |
|
---|
1518 | case SVGA_REG_MOB_MAX_SIZE:
|
---|
1519 | /* Essentially the max texture size */
|
---|
1520 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegMobMaxSizeRd);
|
---|
1521 | *pu32 = _128M; /** @todo Some actual value. Probably the mapped VRAM size. */
|
---|
1522 | break;
|
---|
1523 |
|
---|
1524 | case SVGA_REG_BLANK_SCREEN_TARGETS:
|
---|
1525 | /// @todo STAM_REL_COUNTER_INC(&pThis->svga.aStatRegRd[idxReg]);
|
---|
1526 | *pu32 = 0; /* Not supported. */
|
---|
1527 | break;
|
---|
1528 |
|
---|
1529 | case SVGA_REG_CAP2:
|
---|
1530 | *pu32 = pThis->svga.u32DeviceCaps2;
|
---|
1531 | break;
|
---|
1532 |
|
---|
1533 | case SVGA_REG_DEVEL_CAP:
|
---|
1534 | *pu32 = 0; /* Not supported. */
|
---|
1535 | break;
|
---|
1536 |
|
---|
1537 | /*
|
---|
1538 | * SVGA_REG_GUEST_DRIVER_* registers require SVGA_CAP2_DX2.
|
---|
1539 | */
|
---|
1540 | case SVGA_REG_GUEST_DRIVER_ID:
|
---|
1541 | *pu32 = pThis->svga.u32GuestDriverId;
|
---|
1542 | break;
|
---|
1543 |
|
---|
1544 | case SVGA_REG_GUEST_DRIVER_VERSION1:
|
---|
1545 | *pu32 = pThis->svga.u32GuestDriverVer1;
|
---|
1546 | break;
|
---|
1547 |
|
---|
1548 | case SVGA_REG_GUEST_DRIVER_VERSION2:
|
---|
1549 | *pu32 = pThis->svga.u32GuestDriverVer2;
|
---|
1550 | break;
|
---|
1551 |
|
---|
1552 | case SVGA_REG_GUEST_DRIVER_VERSION3:
|
---|
1553 | *pu32 = pThis->svga.u32GuestDriverVer3;
|
---|
1554 | break;
|
---|
1555 |
|
---|
1556 | /*
|
---|
1557 | * SVGA_REG_CURSOR_ registers require SVGA_CAP2_CURSOR_MOB which the device does not support currently.
|
---|
1558 | */
|
---|
1559 | case SVGA_REG_CURSOR_MOBID:
|
---|
1560 | *pu32 = SVGA_ID_INVALID;
|
---|
1561 | break;
|
---|
1562 |
|
---|
1563 | case SVGA_REG_CURSOR_MAX_BYTE_SIZE:
|
---|
1564 | *pu32 = 0;
|
---|
1565 | break;
|
---|
1566 |
|
---|
1567 | case SVGA_REG_CURSOR_MAX_DIMENSION:
|
---|
1568 | *pu32 = 0;
|
---|
1569 | break;
|
---|
1570 |
|
---|
1571 | case SVGA_REG_FIFO_CAPS:
|
---|
1572 | {
|
---|
1573 | if (pThis->fVmSvga3)
|
---|
1574 | *pu32 = SVGA_FIFO_CAP_FENCE
|
---|
1575 | | SVGA_FIFO_CAP_PITCHLOCK
|
---|
1576 | | SVGA_FIFO_CAP_CURSOR_BYPASS_3
|
---|
1577 | | SVGA_FIFO_CAP_RESERVE
|
---|
1578 | | SVGA_FIFO_CAP_GMR2
|
---|
1579 | | SVGA_FIFO_CAP_3D_HWVERSION_REVISED
|
---|
1580 | | SVGA_FIFO_CAP_SCREEN_OBJECT_2;
|
---|
1581 | else
|
---|
1582 | *pu32 = 0;
|
---|
1583 | break;
|
---|
1584 | }
|
---|
1585 | case SVGA_REG_FENCE:
|
---|
1586 | {
|
---|
1587 | if (pThis->fVmSvga3)
|
---|
1588 | *pu32 = pThis->svga.u32FenceLast;
|
---|
1589 | else
|
---|
1590 | *pu32 = 0;
|
---|
1591 | break;
|
---|
1592 | }
|
---|
1593 |
|
---|
1594 | case SVGA_REG_RESERVED1: /* SVGA_REG_RESERVED* correspond to SVGA_REG_CURSOR4_*. Require SVGA_CAP2_EXTRA_REGS. */
|
---|
1595 | case SVGA_REG_RESERVED2:
|
---|
1596 | case SVGA_REG_RESERVED3:
|
---|
1597 | case SVGA_REG_RESERVED4:
|
---|
1598 | case SVGA_REG_RESERVED5:
|
---|
1599 | case SVGA_REG_SCREENDMA:
|
---|
1600 | *pu32 = 0; /* Not supported. */
|
---|
1601 | break;
|
---|
1602 |
|
---|
1603 | case SVGA_REG_GBOBJECT_MEM_SIZE_KB:
|
---|
1604 | /** @todo "The maximum amount of guest-backed objects that the device can have resident at a time" */
|
---|
1605 | *pu32 = _1G / _1K;
|
---|
1606 | break;
|
---|
1607 |
|
---|
1608 | case SVGA_REG_IRQ_STATUS:
|
---|
1609 | {
|
---|
1610 | if (pThis->fVmSvga3)
|
---|
1611 | *pu32 = pThis->svga.u32IrqStatus;
|
---|
1612 | else
|
---|
1613 | *pu32 = 0;
|
---|
1614 | break;
|
---|
1615 | }
|
---|
1616 |
|
---|
1617 | default:
|
---|
1618 | {
|
---|
1619 | uint32_t offReg;
|
---|
1620 | if ((offReg = idxReg - SVGA_SCRATCH_BASE) < pThis->svga.cScratchRegion)
|
---|
1621 | {
|
---|
1622 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegScratchRd);
|
---|
1623 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
1624 | *pu32 = pThis->svga.au32ScratchRegion[offReg];
|
---|
1625 | }
|
---|
1626 | else if ((offReg = idxReg - SVGA_PALETTE_BASE) < (uint32_t)SVGA_NUM_PALETTE_REGS)
|
---|
1627 | {
|
---|
1628 | /* Note! Using last_palette rather than palette here to preserve the VGA one. */
|
---|
1629 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegPaletteRd);
|
---|
1630 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
1631 | uint32_t u32 = pThis->last_palette[offReg / 3];
|
---|
1632 | switch (offReg % 3)
|
---|
1633 | {
|
---|
1634 | case 0: *pu32 = (u32 >> 16) & 0xff; break; /* red */
|
---|
1635 | case 1: *pu32 = (u32 >> 8) & 0xff; break; /* green */
|
---|
1636 | case 2: *pu32 = u32 & 0xff; break; /* blue */
|
---|
1637 | }
|
---|
1638 | }
|
---|
1639 | else
|
---|
1640 | {
|
---|
1641 | #if !defined(IN_RING3) && defined(VBOX_STRICT)
|
---|
1642 | rc = VINF_IOM_R3_IOPORT_READ;
|
---|
1643 | #else
|
---|
1644 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegUnknownRd);
|
---|
1645 |
|
---|
1646 | /* Do not assert. The guest might be reading all registers. */
|
---|
1647 | LogFunc(("Unknown reg=%#x\n", idxReg));
|
---|
1648 | #endif
|
---|
1649 | }
|
---|
1650 | break;
|
---|
1651 | }
|
---|
1652 | }
|
---|
1653 | LogFlow(("vmsvgaReadPort index=%s (%d) val=%#x rc=%x\n", vmsvgaIndexToString(pThis, idxReg), idxReg, *pu32, rc));
|
---|
1654 | return rc;
|
---|
1655 | }
|
---|
1656 |
|
---|
1657 | #ifdef IN_RING3
|
---|
1658 | /**
|
---|
1659 | * Apply the current resolution settings to change the video mode.
|
---|
1660 | *
|
---|
1661 | * @returns VBox status code.
|
---|
1662 | * @param pThis The shared VGA state.
|
---|
1663 | * @param pThisCC The ring-3 VGA state.
|
---|
1664 | */
|
---|
1665 | int vmsvgaR3ChangeMode(PVGASTATE pThis, PVGASTATECC pThisCC)
|
---|
1666 | {
|
---|
1667 | /* Always do changemode on FIFO thread. */
|
---|
1668 | Assert(RTThreadSelf() == pThisCC->svga.pFIFOIOThread->Thread);
|
---|
1669 |
|
---|
1670 | PVMSVGAR3STATE pSVGAState = pThisCC->svga.pSvgaR3State;
|
---|
1671 |
|
---|
1672 | pThisCC->pDrv->pfnLFBModeChange(pThisCC->pDrv, true);
|
---|
1673 |
|
---|
1674 | if (pThis->svga.fGFBRegisters)
|
---|
1675 | {
|
---|
1676 | /* "For backwards compatibility, when the GFB mode registers (WIDTH,
|
---|
1677 | * HEIGHT, PITCHLOCK, BITS_PER_PIXEL) are modified, the SVGA device
|
---|
1678 | * deletes all screens other than screen #0, and redefines screen
|
---|
1679 | * #0 according to the specified mode. Drivers that use
|
---|
1680 | * SVGA_CMD_DEFINE_SCREEN should destroy or redefine screen #0."
|
---|
1681 | */
|
---|
1682 |
|
---|
1683 | VMSVGASCREENOBJECT *pScreen = &pSVGAState->aScreens[0];
|
---|
1684 | Assert(pScreen->idScreen == 0);
|
---|
1685 |
|
---|
1686 | if ( pScreen->cWidth == VMSVGA_VAL_UNINITIALIZED
|
---|
1687 | || pScreen->cHeight == VMSVGA_VAL_UNINITIALIZED
|
---|
1688 | || pScreen->cBpp == VMSVGA_VAL_UNINITIALIZED)
|
---|
1689 | {
|
---|
1690 | /* Do not apply the change if the guest has not finished updating registers.
|
---|
1691 | * This is necessary in order to make a full mode change, including freeing
|
---|
1692 | * pvScreenBitmap buffers for screen 0 if necessary.
|
---|
1693 | */
|
---|
1694 | return VINF_SUCCESS;
|
---|
1695 | }
|
---|
1696 |
|
---|
1697 | /* Remember screen bitmap buffers to be freed. */
|
---|
1698 | void * apvOldScreenBitmap[RT_ELEMENTS(pSVGAState->aScreens)];
|
---|
1699 | RT_ZERO(apvOldScreenBitmap);
|
---|
1700 |
|
---|
1701 | pScreen->fDefined = true;
|
---|
1702 | pScreen->fModified = true;
|
---|
1703 | pScreen->fuScreen = SVGA_SCREEN_MUST_BE_SET | SVGA_SCREEN_IS_PRIMARY;
|
---|
1704 | pScreen->xOrigin = 0;
|
---|
1705 | pScreen->yOrigin = 0;
|
---|
1706 | pScreen->offVRAM = 0;
|
---|
1707 | pScreen->cbPitch = pThis->svga.cbScanline;
|
---|
1708 | pScreen->cWidth = pThis->svga.uWidth;
|
---|
1709 | pScreen->cHeight = pThis->svga.uHeight;
|
---|
1710 | pScreen->cBpp = pThis->svga.uBpp;
|
---|
1711 | pScreen->cDpi = 0; /* GFB mode does not support dpi. */
|
---|
1712 | /* GFB mode uses the guest VRAM. The screen bitmap must be deallocated after 'vmsvgaR3VBVAResize'. */
|
---|
1713 | apvOldScreenBitmap[0] = pScreen->pvScreenBitmap;
|
---|
1714 | /* Set pvScreenBitmap to zero because if it is not, then vmsvgaR3VBVAResize uses it as VRAM address. */
|
---|
1715 | pScreen->pvScreenBitmap = 0;
|
---|
1716 |
|
---|
1717 | for (unsigned iScreen = 1; iScreen < RT_ELEMENTS(pSVGAState->aScreens); ++iScreen)
|
---|
1718 | {
|
---|
1719 | /* Delete screen. */
|
---|
1720 | pScreen = &pSVGAState->aScreens[iScreen];
|
---|
1721 | if (pScreen->fDefined)
|
---|
1722 | {
|
---|
1723 | pScreen->fModified = true;
|
---|
1724 | pScreen->fDefined = false;
|
---|
1725 |
|
---|
1726 | #ifdef VBOX_WITH_VMSVGA3D
|
---|
1727 | if (RT_LIKELY(pThis->svga.f3DEnabled))
|
---|
1728 | vmsvga3dDestroyScreen(pThisCC, pScreen);
|
---|
1729 | #endif
|
---|
1730 | apvOldScreenBitmap[iScreen] = pScreen->pvScreenBitmap;
|
---|
1731 | pScreen->pvScreenBitmap = 0;
|
---|
1732 | }
|
---|
1733 | }
|
---|
1734 |
|
---|
1735 | vmsvgaR3VBVAResize(pThis, pThisCC);
|
---|
1736 |
|
---|
1737 | /* Deallocate screen bitmaps for all screens because GFB mode uses the guest VRAM. */
|
---|
1738 | for (unsigned iScreen = 0; iScreen < RT_ELEMENTS(apvOldScreenBitmap); ++iScreen)
|
---|
1739 | RTMemFree(apvOldScreenBitmap[iScreen]);
|
---|
1740 | }
|
---|
1741 | else
|
---|
1742 | {
|
---|
1743 | /* "If Screen Objects are supported, they can be used to fully
|
---|
1744 | * replace the functionality provided by the framebuffer registers
|
---|
1745 | * (SVGA_REG_WIDTH, HEIGHT, etc.) and by SVGA_CAP_DISPLAY_TOPOLOGY."
|
---|
1746 | */
|
---|
1747 | pThis->svga.uWidth = VMSVGA_VAL_UNINITIALIZED;
|
---|
1748 | pThis->svga.uHeight = VMSVGA_VAL_UNINITIALIZED;
|
---|
1749 | pThis->svga.uBpp = pThis->svga.uHostBpp;
|
---|
1750 |
|
---|
1751 | vmsvgaR3VBVAResize(pThis, pThisCC);
|
---|
1752 | }
|
---|
1753 |
|
---|
1754 | /* Last stuff. For the VGA device screenshot. */
|
---|
1755 | pThis->last_bpp = pSVGAState->aScreens[0].cBpp;
|
---|
1756 | pThis->last_scr_width = pSVGAState->aScreens[0].cWidth;
|
---|
1757 | pThis->last_scr_height = pSVGAState->aScreens[0].cHeight;
|
---|
1758 | pThis->last_width = pSVGAState->aScreens[0].cWidth;
|
---|
1759 | pThis->last_height = pSVGAState->aScreens[0].cHeight;
|
---|
1760 |
|
---|
1761 | /* vmsvgaPortSetViewPort not called after state load; set sensible defaults. */
|
---|
1762 | if ( pThis->svga.viewport.cx == 0
|
---|
1763 | && pThis->svga.viewport.cy == 0)
|
---|
1764 | {
|
---|
1765 | pThis->svga.viewport.cx = pSVGAState->aScreens[0].cWidth;
|
---|
1766 | pThis->svga.viewport.xRight = pSVGAState->aScreens[0].cWidth;
|
---|
1767 | pThis->svga.viewport.cy = pSVGAState->aScreens[0].cHeight;
|
---|
1768 | pThis->svga.viewport.yHighWC = pSVGAState->aScreens[0].cHeight;
|
---|
1769 | pThis->svga.viewport.yLowWC = 0;
|
---|
1770 | }
|
---|
1771 |
|
---|
1772 | return VINF_SUCCESS;
|
---|
1773 | }
|
---|
1774 |
|
---|
1775 | int vmsvgaR3UpdateScreen(PVGASTATECC pThisCC, VMSVGASCREENOBJECT *pScreen, int x, int y, int w, int h)
|
---|
1776 | {
|
---|
1777 | ASSERT_GUEST_LOGREL_MSG_RETURN(w > 0 && h > 0,
|
---|
1778 | ("vmsvgaR3UpdateScreen: screen %d (%d,%d) %dx%d: Invalid height and/or width supplied.\n",
|
---|
1779 | pScreen->idScreen, x, y, w, h),
|
---|
1780 | VERR_INVALID_PARAMETER);
|
---|
1781 |
|
---|
1782 | VBVACMDHDR cmd;
|
---|
1783 | cmd.x = (int16_t)(pScreen->xOrigin + x);
|
---|
1784 | cmd.y = (int16_t)(pScreen->yOrigin + y);
|
---|
1785 | cmd.w = (uint16_t)w;
|
---|
1786 | cmd.h = (uint16_t)h;
|
---|
1787 |
|
---|
1788 | pThisCC->pDrv->pfnVBVAUpdateBegin(pThisCC->pDrv, pScreen->idScreen);
|
---|
1789 | pThisCC->pDrv->pfnVBVAUpdateProcess(pThisCC->pDrv, pScreen->idScreen, &cmd, sizeof(cmd));
|
---|
1790 | pThisCC->pDrv->pfnVBVAUpdateEnd(pThisCC->pDrv, pScreen->idScreen,
|
---|
1791 | pScreen->xOrigin + x, pScreen->yOrigin + y, w, h);
|
---|
1792 |
|
---|
1793 | return VINF_SUCCESS;
|
---|
1794 | }
|
---|
1795 |
|
---|
1796 | #endif /* IN_RING3 */
|
---|
1797 | #if defined(IN_RING0) || defined(IN_RING3)
|
---|
1798 |
|
---|
1799 | /**
|
---|
1800 | * Safely updates the SVGA_FIFO_BUSY register (in shared memory).
|
---|
1801 | *
|
---|
1802 | * @param pThis The shared VGA/VMSVGA instance data.
|
---|
1803 | * @param pThisCC The VGA/VMSVGA state for the current context.
|
---|
1804 | * @param fState The busy state.
|
---|
1805 | */
|
---|
1806 | DECLINLINE(void) vmsvgaHCSafeFifoBusyRegUpdate(PVGASTATE pThis, PVGASTATECC pThisCC, bool fState)
|
---|
1807 | {
|
---|
1808 | ASMAtomicWriteU32(&pThisCC->svga.pau32FIFO[SVGA_FIFO_BUSY], fState);
|
---|
1809 |
|
---|
1810 | if (RT_UNLIKELY(fState != (pThis->svga.fBusy != 0)))
|
---|
1811 | {
|
---|
1812 | /* Race / unfortunately scheduling. Highly unlikly. */
|
---|
1813 | uint32_t cLoops = 64;
|
---|
1814 | do
|
---|
1815 | {
|
---|
1816 | ASMNopPause();
|
---|
1817 | fState = (pThis->svga.fBusy != 0);
|
---|
1818 | ASMAtomicWriteU32(&pThisCC->svga.pau32FIFO[SVGA_FIFO_BUSY], fState != 0);
|
---|
1819 | } while (cLoops-- > 0 && fState != (pThis->svga.fBusy != 0));
|
---|
1820 | }
|
---|
1821 | }
|
---|
1822 |
|
---|
1823 |
|
---|
1824 | /**
|
---|
1825 | * Update the scanline pitch in response to the guest changing mode
|
---|
1826 | * width/bpp.
|
---|
1827 | *
|
---|
1828 | * @param pThis The shared VGA/VMSVGA state.
|
---|
1829 | * @param pThisCC The VGA/VMSVGA state for the current context.
|
---|
1830 | */
|
---|
1831 | DECLINLINE(void) vmsvgaHCUpdatePitch(PVGASTATE pThis, PVGASTATECC pThisCC)
|
---|
1832 | {
|
---|
1833 | uint32_t RT_UNTRUSTED_VOLATILE_GUEST *pFIFO = pThisCC->svga.pau32FIFO;
|
---|
1834 | uint32_t uFifoPitchLock = pThis->fVmSvga3 ? 0 : pFIFO[SVGA_FIFO_PITCHLOCK];
|
---|
1835 | uint32_t uRegPitchLock = pThis->svga.u32PitchLock;
|
---|
1836 | uint32_t uFifoMin = pThis->fVmSvga3 ? 0 : pFIFO[SVGA_FIFO_MIN];
|
---|
1837 |
|
---|
1838 | /* The SVGA_FIFO_PITCHLOCK register is only valid if SVGA_FIFO_MIN points past
|
---|
1839 | * it. If SVGA_FIFO_MIN is small, there may well be data at the SVGA_FIFO_PITCHLOCK
|
---|
1840 | * location but it has a different meaning.
|
---|
1841 | */
|
---|
1842 | if ((uFifoMin / sizeof(uint32_t)) <= SVGA_FIFO_PITCHLOCK)
|
---|
1843 | uFifoPitchLock = 0;
|
---|
1844 |
|
---|
1845 | /* Sanitize values. */
|
---|
1846 | if ((uFifoPitchLock < 200) || (uFifoPitchLock > 32768))
|
---|
1847 | uFifoPitchLock = 0;
|
---|
1848 | if ((uRegPitchLock < 200) || (uRegPitchLock > 32768))
|
---|
1849 | uRegPitchLock = 0;
|
---|
1850 |
|
---|
1851 | /* Prefer the register value to the FIFO value.*/
|
---|
1852 | if (uRegPitchLock)
|
---|
1853 | pThis->svga.cbScanline = uRegPitchLock;
|
---|
1854 | else if (uFifoPitchLock)
|
---|
1855 | pThis->svga.cbScanline = uFifoPitchLock;
|
---|
1856 | else
|
---|
1857 | pThis->svga.cbScanline = (uint32_t)pThis->svga.uWidth * (RT_ALIGN(pThis->svga.uBpp, 8) / 8);
|
---|
1858 |
|
---|
1859 | if ((uFifoMin / sizeof(uint32_t)) <= SVGA_FIFO_PITCHLOCK)
|
---|
1860 | pThis->svga.u32PitchLock = pThis->svga.cbScanline;
|
---|
1861 | }
|
---|
1862 |
|
---|
1863 | #endif /* IN_RING0 || IN_RING3 */
|
---|
1864 |
|
---|
1865 | #ifdef IN_RING3
|
---|
1866 |
|
---|
1867 | /**
|
---|
1868 | * Sends cursor position and visibility information from legacy
|
---|
1869 | * SVGA registers to the front-end.
|
---|
1870 | */
|
---|
1871 | static void vmsvgaR3RegUpdateCursor(PVGASTATECC pThisCC, PVGASTATE pThis, uint32_t uCursorOn)
|
---|
1872 | {
|
---|
1873 | /*
|
---|
1874 | * Writing the X/Y/ID registers does not trigger changes; only writing the
|
---|
1875 | * SVGA_REG_CURSOR_ON register does. That minimizes the overhead.
|
---|
1876 | * We boldly assume that guests aren't stupid and aren't writing the CURSOR_ON
|
---|
1877 | * register if they don't have to.
|
---|
1878 | */
|
---|
1879 | uint32_t x, y, idScreen;
|
---|
1880 | uint32_t fFlags = VBVA_CURSOR_VALID_DATA;
|
---|
1881 |
|
---|
1882 | x = pThis->svga.uCursorX;
|
---|
1883 | y = pThis->svga.uCursorY;
|
---|
1884 | idScreen = SVGA_ID_INVALID; /* The old register interface is single screen only. */
|
---|
1885 |
|
---|
1886 | /* The original values for SVGA_REG_CURSOR_ON were off (0) and on (1); later, the values
|
---|
1887 | * were extended as follows:
|
---|
1888 | *
|
---|
1889 | * SVGA_CURSOR_ON_HIDE 0
|
---|
1890 | * SVGA_CURSOR_ON_SHOW 1
|
---|
1891 | * SVGA_CURSOR_ON_REMOVE_FROM_FB 2 - cursor on but not in the framebuffer
|
---|
1892 | * SVGA_CURSOR_ON_RESTORE_TO_FB 3 - cursor on, possibly in the framebuffer
|
---|
1893 | *
|
---|
1894 | * Since we never draw the cursor into the guest's framebuffer, we do not need to
|
---|
1895 | * distinguish between the non-zero values but still remember them.
|
---|
1896 | */
|
---|
1897 | if (RT_BOOL(pThis->svga.uCursorOn) != RT_BOOL(uCursorOn))
|
---|
1898 | {
|
---|
1899 | LogRel2(("vmsvgaR3RegUpdateCursor: uCursorOn %d prev CursorOn %d (%d,%d)\n", uCursorOn, pThis->svga.uCursorOn, x, y));
|
---|
1900 | pThisCC->pDrv->pfnVBVAMousePointerShape(pThisCC->pDrv, RT_BOOL(uCursorOn), false, 0, 0, 0, 0, NULL);
|
---|
1901 | }
|
---|
1902 | pThis->svga.uCursorOn = uCursorOn;
|
---|
1903 | pThisCC->pDrv->pfnVBVAReportCursorPosition(pThisCC->pDrv, fFlags, idScreen, x, y);
|
---|
1904 | }
|
---|
1905 |
|
---|
1906 | #endif /* IN_RING3 */
|
---|
1907 |
|
---|
1908 |
|
---|
1909 | /**
|
---|
1910 | * Write port register
|
---|
1911 | *
|
---|
1912 | * @returns Strict VBox status code.
|
---|
1913 | * @param pDevIns The device instance.
|
---|
1914 | * @param pThis The shared VGA/VMSVGA state.
|
---|
1915 | * @param pThisCC The VGA/VMSVGA state for the current context.
|
---|
1916 | * @param idxReg Rge register index being written.
|
---|
1917 | * @param u32 Value to write
|
---|
1918 | */
|
---|
1919 | static VBOXSTRICTRC vmsvgaWritePort(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC, uint32_t idxReg, uint32_t u32)
|
---|
1920 | {
|
---|
1921 | #ifdef IN_RING3
|
---|
1922 | PVMSVGAR3STATE pSVGAState = pThisCC->svga.pSvgaR3State;
|
---|
1923 | #endif
|
---|
1924 | VBOXSTRICTRC rc = VINF_SUCCESS;
|
---|
1925 | RT_NOREF(pThisCC);
|
---|
1926 |
|
---|
1927 | /* We must adjust the register number if we're in SVGA_ID_0 mode because the PALETTE range moved. */
|
---|
1928 | if ( idxReg >= SVGA_REG_ID_0_TOP
|
---|
1929 | && pThis->svga.u32SVGAId == SVGA_ID_0)
|
---|
1930 | {
|
---|
1931 | idxReg += SVGA_PALETTE_BASE - SVGA_REG_ID_0_TOP;
|
---|
1932 | Log(("vmsvgaWritePort: SVGA_ID_0 reg adj %#x -> %#x\n", pThis->svga.u32IndexReg, idxReg));
|
---|
1933 | }
|
---|
1934 | #ifdef LOG_ENABLED
|
---|
1935 | if (idxReg != SVGA_REG_DEV_CAP)
|
---|
1936 | LogFlow(("vmsvgaWritePort index=%s (%d) val=%#x\n", vmsvgaIndexToString(pThis, idxReg), idxReg, u32));
|
---|
1937 | else
|
---|
1938 | LogFlow(("vmsvgaWritePort index=%s (%d) val=%s (%d)\n", vmsvgaIndexToString(pThis, idxReg), idxReg, vmsvgaDevCapIndexToString((SVGA3dDevCapIndex)u32), u32));
|
---|
1939 | #endif
|
---|
1940 | /* Check if the guest uses legacy registers. See vmsvgaR3ChangeMode */
|
---|
1941 | switch (idxReg)
|
---|
1942 | {
|
---|
1943 | case SVGA_REG_WIDTH:
|
---|
1944 | case SVGA_REG_HEIGHT:
|
---|
1945 | case SVGA_REG_PITCHLOCK:
|
---|
1946 | case SVGA_REG_BITS_PER_PIXEL:
|
---|
1947 | pThis->svga.fGFBRegisters = true;
|
---|
1948 | break;
|
---|
1949 | default:
|
---|
1950 | break;
|
---|
1951 | }
|
---|
1952 |
|
---|
1953 | switch (idxReg)
|
---|
1954 | {
|
---|
1955 | case SVGA_REG_ID:
|
---|
1956 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegIdWr);
|
---|
1957 | if ( u32 == SVGA_ID_0
|
---|
1958 | || u32 == SVGA_ID_1
|
---|
1959 | || u32 == SVGA_ID_2
|
---|
1960 | || u32 == SVGA_ID_3)
|
---|
1961 | pThis->svga.u32SVGAId = u32;
|
---|
1962 | else
|
---|
1963 | PDMDevHlpDBGFStop(pDevIns, RT_SRC_POS, "Trying to set SVGA_REG_ID to %#x (%d)\n", u32, u32);
|
---|
1964 | break;
|
---|
1965 |
|
---|
1966 | case SVGA_REG_ENABLE:
|
---|
1967 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegEnableWr);
|
---|
1968 | #ifdef IN_RING3
|
---|
1969 | if ( (u32 & SVGA_REG_ENABLE_ENABLE)
|
---|
1970 | && pThis->svga.fEnabled == false)
|
---|
1971 | {
|
---|
1972 | /* Make a backup copy of the first 512kb in order to save font data etc. */
|
---|
1973 | /** @todo should probably swap here, rather than copy + zero */
|
---|
1974 | memcpy(pThisCC->svga.pbVgaFrameBufferR3, pThisCC->pbVRam, VMSVGA_VGA_FB_BACKUP_SIZE);
|
---|
1975 | memset(pThisCC->pbVRam, 0, VMSVGA_VGA_FB_BACKUP_SIZE);
|
---|
1976 | }
|
---|
1977 |
|
---|
1978 | pThis->svga.fEnabled = u32;
|
---|
1979 | if (pThis->svga.fEnabled)
|
---|
1980 | {
|
---|
1981 | if ( pThis->svga.uWidth == VMSVGA_VAL_UNINITIALIZED
|
---|
1982 | && pThis->svga.uHeight == VMSVGA_VAL_UNINITIALIZED)
|
---|
1983 | {
|
---|
1984 | /* Keep the current mode. */
|
---|
1985 | pThis->svga.uWidth = pThisCC->pDrv->cx;
|
---|
1986 | pThis->svga.uHeight = pThisCC->pDrv->cy;
|
---|
1987 | pThis->svga.uBpp = (pThisCC->pDrv->cBits + 7) & ~7;
|
---|
1988 | vmsvgaHCUpdatePitch(pThis, pThisCC);
|
---|
1989 | }
|
---|
1990 |
|
---|
1991 | if ( pThis->svga.uWidth != VMSVGA_VAL_UNINITIALIZED
|
---|
1992 | && pThis->svga.uHeight != VMSVGA_VAL_UNINITIALIZED)
|
---|
1993 | ASMAtomicOrU32(&pThis->svga.u32ActionFlags, VMSVGA_ACTION_CHANGEMODE);
|
---|
1994 | # ifdef LOG_ENABLED
|
---|
1995 | if (!pThis->fVmSvga3)
|
---|
1996 | {
|
---|
1997 | uint32_t *pFIFO = pThisCC->svga.pau32FIFO;
|
---|
1998 | Log(("configured=%d busy=%d\n", pThis->svga.fConfigured, pFIFO[SVGA_FIFO_BUSY]));
|
---|
1999 | Log(("next %x stop %x\n", pFIFO[SVGA_FIFO_NEXT_CMD], pFIFO[SVGA_FIFO_STOP]));
|
---|
2000 | }
|
---|
2001 | # endif
|
---|
2002 |
|
---|
2003 | /* Disable or enable dirty page tracking according to the current fTraces value. */
|
---|
2004 | vmsvgaR3SetTraces(pDevIns, pThis, !!pThis->svga.fTraces);
|
---|
2005 |
|
---|
2006 | /* bird: Whatever this is was added to make screenshot work, ask sunlover should explain... */
|
---|
2007 | for (uint32_t idScreen = 0; idScreen < pThis->cMonitors; ++idScreen)
|
---|
2008 | pThisCC->pDrv->pfnVBVAEnable(pThisCC->pDrv, idScreen, NULL /*pHostFlags*/);
|
---|
2009 |
|
---|
2010 | /* Make the cursor visible again as needed. */
|
---|
2011 | if (pSVGAState->Cursor.fActive)
|
---|
2012 | pThisCC->pDrv->pfnVBVAMousePointerShape(pThisCC->pDrv, true /*fVisible*/, false, 0, 0, 0, 0, NULL);
|
---|
2013 | }
|
---|
2014 | else
|
---|
2015 | {
|
---|
2016 | /* Make sure the cursor is off. */
|
---|
2017 | if (pSVGAState->Cursor.fActive)
|
---|
2018 | pThisCC->pDrv->pfnVBVAMousePointerShape(pThisCC->pDrv, false /*fVisible*/, false, 0, 0, 0, 0, NULL);
|
---|
2019 |
|
---|
2020 | /* Restore the text mode backup. */
|
---|
2021 | memcpy(pThisCC->pbVRam, pThisCC->svga.pbVgaFrameBufferR3, VMSVGA_VGA_FB_BACKUP_SIZE);
|
---|
2022 |
|
---|
2023 | pThisCC->pDrv->pfnLFBModeChange(pThisCC->pDrv, false);
|
---|
2024 |
|
---|
2025 | /* Enable dirty page tracking again when going into legacy mode. */
|
---|
2026 | vmsvgaR3SetTraces(pDevIns, pThis, true);
|
---|
2027 |
|
---|
2028 | /* bird: Whatever this is was added to make screenshot work, ask sunlover should explain... */
|
---|
2029 | for (uint32_t idScreen = 0; idScreen < pThis->cMonitors; ++idScreen)
|
---|
2030 | pThisCC->pDrv->pfnVBVADisable(pThisCC->pDrv, idScreen);
|
---|
2031 |
|
---|
2032 | /* Clear the pitch lock. */
|
---|
2033 | pThis->svga.u32PitchLock = 0;
|
---|
2034 | }
|
---|
2035 | #else /* !IN_RING3 */
|
---|
2036 | rc = VINF_IOM_R3_IOPORT_WRITE;
|
---|
2037 | #endif /* !IN_RING3 */
|
---|
2038 | break;
|
---|
2039 |
|
---|
2040 | case SVGA_REG_WIDTH:
|
---|
2041 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegWidthWr);
|
---|
2042 | if (u32 != pThis->svga.uWidth)
|
---|
2043 | {
|
---|
2044 | if (u32 <= pThis->svga.u32MaxWidth)
|
---|
2045 | {
|
---|
2046 | #if defined(IN_RING3) || defined(IN_RING0)
|
---|
2047 | pThis->svga.uWidth = u32;
|
---|
2048 | vmsvgaHCUpdatePitch(pThis, pThisCC);
|
---|
2049 | if (pThis->svga.fEnabled)
|
---|
2050 | ASMAtomicOrU32(&pThis->svga.u32ActionFlags, VMSVGA_ACTION_CHANGEMODE);
|
---|
2051 | #else
|
---|
2052 | rc = VINF_IOM_R3_IOPORT_WRITE;
|
---|
2053 | #endif
|
---|
2054 | }
|
---|
2055 | else
|
---|
2056 | Log(("SVGA_REG_WIDTH: New value is out of bounds: %u, max %u\n", u32, pThis->svga.u32MaxWidth));
|
---|
2057 | }
|
---|
2058 | /* else: nop */
|
---|
2059 | break;
|
---|
2060 |
|
---|
2061 | case SVGA_REG_HEIGHT:
|
---|
2062 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegHeightWr);
|
---|
2063 | if (u32 != pThis->svga.uHeight)
|
---|
2064 | {
|
---|
2065 | if (u32 <= pThis->svga.u32MaxHeight)
|
---|
2066 | {
|
---|
2067 | pThis->svga.uHeight = u32;
|
---|
2068 | if (pThis->svga.fEnabled)
|
---|
2069 | ASMAtomicOrU32(&pThis->svga.u32ActionFlags, VMSVGA_ACTION_CHANGEMODE);
|
---|
2070 | }
|
---|
2071 | else
|
---|
2072 | Log(("SVGA_REG_HEIGHT: New value is out of bounds: %u, max %u\n", u32, pThis->svga.u32MaxHeight));
|
---|
2073 | }
|
---|
2074 | /* else: nop */
|
---|
2075 | break;
|
---|
2076 |
|
---|
2077 | case SVGA_REG_DEPTH:
|
---|
2078 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegDepthWr);
|
---|
2079 | /** @todo read-only?? */
|
---|
2080 | break;
|
---|
2081 |
|
---|
2082 | case SVGA_REG_BITS_PER_PIXEL: /* Current bpp in the guest */
|
---|
2083 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegBitsPerPixelWr);
|
---|
2084 | if (pThis->svga.uBpp != u32)
|
---|
2085 | {
|
---|
2086 | if (u32 <= 32)
|
---|
2087 | {
|
---|
2088 | #if defined(IN_RING3) || defined(IN_RING0)
|
---|
2089 | pThis->svga.uBpp = u32;
|
---|
2090 | vmsvgaHCUpdatePitch(pThis, pThisCC);
|
---|
2091 | if (pThis->svga.fEnabled)
|
---|
2092 | ASMAtomicOrU32(&pThis->svga.u32ActionFlags, VMSVGA_ACTION_CHANGEMODE);
|
---|
2093 | #else
|
---|
2094 | rc = VINF_IOM_R3_IOPORT_WRITE;
|
---|
2095 | #endif
|
---|
2096 | }
|
---|
2097 | else
|
---|
2098 | Log(("SVGA_REG_BITS_PER_PIXEL: New value is out of bounds: %u, max 32\n", u32));
|
---|
2099 | }
|
---|
2100 | /* else: nop */
|
---|
2101 | break;
|
---|
2102 |
|
---|
2103 | case SVGA_REG_PSEUDOCOLOR:
|
---|
2104 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegPseudoColorWr);
|
---|
2105 | break;
|
---|
2106 |
|
---|
2107 | case SVGA_REG_CONFIG_DONE: /* Set when memory area configured */
|
---|
2108 | #ifdef IN_RING3
|
---|
2109 | STAM_REL_COUNTER_INC(&pSVGAState->StatR3RegConfigDoneWr);
|
---|
2110 | pThis->svga.fConfigured = u32;
|
---|
2111 | /* Disabling the FIFO enables tracing (dirty page detection) by default. */
|
---|
2112 | if (!pThis->svga.fConfigured)
|
---|
2113 | pThis->svga.fTraces = true;
|
---|
2114 | vmsvgaR3SetTraces(pDevIns, pThis, !!pThis->svga.fTraces);
|
---|
2115 | #else
|
---|
2116 | rc = VINF_IOM_R3_IOPORT_WRITE;
|
---|
2117 | #endif
|
---|
2118 | break;
|
---|
2119 |
|
---|
2120 | case SVGA_REG_SYNC: /* See "FIFO Synchronization Registers" */
|
---|
2121 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegSyncWr);
|
---|
2122 | if ( pThis->svga.fEnabled
|
---|
2123 | && pThis->svga.fConfigured)
|
---|
2124 | {
|
---|
2125 | #if defined(IN_RING3) || defined(IN_RING0)
|
---|
2126 | Log(("SVGA_REG_SYNC: SVGA_FIFO_BUSY=%d\n", pThisCC->svga.pau32FIFO[SVGA_FIFO_BUSY]));
|
---|
2127 | /*
|
---|
2128 | * The VMSVGA_BUSY_F_EMT_FORCE flag makes sure we will check if the FIFO is empty
|
---|
2129 | * at least once; VMSVGA_BUSY_F_FIFO alone does not ensure that.
|
---|
2130 | */
|
---|
2131 | ASMAtomicWriteU32(&pThis->svga.fBusy, VMSVGA_BUSY_F_EMT_FORCE | VMSVGA_BUSY_F_FIFO);
|
---|
2132 | if (VMSVGA_IS_VALID_FIFO_REG(SVGA_FIFO_BUSY, pThisCC->svga.pau32FIFO[SVGA_FIFO_MIN]))
|
---|
2133 | vmsvgaHCSafeFifoBusyRegUpdate(pThis, pThisCC, true);
|
---|
2134 |
|
---|
2135 | /* Kick the FIFO thread to start processing commands again. */
|
---|
2136 | PDMDevHlpSUPSemEventSignal(pDevIns, pThis->svga.hFIFORequestSem);
|
---|
2137 | #else
|
---|
2138 | rc = VINF_IOM_R3_IOPORT_WRITE;
|
---|
2139 | #endif
|
---|
2140 | }
|
---|
2141 | /* else nothing to do. */
|
---|
2142 | else
|
---|
2143 | Log(("Sync ignored enabled=%d configured=%d\n", pThis->svga.fEnabled, pThis->svga.fConfigured));
|
---|
2144 |
|
---|
2145 | break;
|
---|
2146 |
|
---|
2147 | case SVGA_REG_BUSY: /* See "FIFO Synchronization Registers" (read-only) */
|
---|
2148 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegBusyWr);
|
---|
2149 | break;
|
---|
2150 |
|
---|
2151 | case SVGA_REG_GUEST_ID: /* Set guest OS identifier */
|
---|
2152 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegGuestIdWr);
|
---|
2153 | pThis->svga.u32GuestId = u32;
|
---|
2154 | break;
|
---|
2155 |
|
---|
2156 | case SVGA_REG_PITCHLOCK: /* Fixed pitch for all modes */
|
---|
2157 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegPitchLockWr);
|
---|
2158 | pThis->svga.u32PitchLock = u32;
|
---|
2159 | /* Should this also update the FIFO pitch lock? Unclear. */
|
---|
2160 | break;
|
---|
2161 |
|
---|
2162 | case SVGA_REG_IRQMASK: /* Interrupt mask */
|
---|
2163 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegIrqMaskWr);
|
---|
2164 | pThis->svga.u32IrqMask = u32;
|
---|
2165 |
|
---|
2166 | /* Irq pending after the above change? */
|
---|
2167 | if (pThis->svga.u32IrqStatus & u32)
|
---|
2168 | {
|
---|
2169 | Log(("SVGA_REG_IRQMASK: Trigger interrupt with status %x\n", pThis->svga.u32IrqStatus));
|
---|
2170 | PDMDevHlpPCISetIrqNoWait(pDevIns, 0, 1);
|
---|
2171 | }
|
---|
2172 | else
|
---|
2173 | PDMDevHlpPCISetIrqNoWait(pDevIns, 0, 0);
|
---|
2174 | break;
|
---|
2175 |
|
---|
2176 | /* Mouse cursor support */
|
---|
2177 | case SVGA_REG_DEAD: /* SVGA_REG_CURSOR_ID */
|
---|
2178 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegCursorIdWr);
|
---|
2179 | pThis->svga.uCursorID = u32;
|
---|
2180 | break;
|
---|
2181 |
|
---|
2182 | case SVGA_REG_CURSOR_X:
|
---|
2183 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegCursorXWr);
|
---|
2184 | pThis->svga.uCursorX = u32;
|
---|
2185 | break;
|
---|
2186 |
|
---|
2187 | case SVGA_REG_CURSOR_Y:
|
---|
2188 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegCursorYWr);
|
---|
2189 | pThis->svga.uCursorY = u32;
|
---|
2190 | break;
|
---|
2191 |
|
---|
2192 | case SVGA_REG_CURSOR_ON:
|
---|
2193 | #ifdef IN_RING3
|
---|
2194 | /* The cursor is only updated when SVGA_REG_CURSOR_ON is written. */
|
---|
2195 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegCursorOnWr);
|
---|
2196 | vmsvgaR3RegUpdateCursor(pThisCC, pThis, u32);
|
---|
2197 | #else
|
---|
2198 | rc = VINF_IOM_R3_IOPORT_WRITE;
|
---|
2199 | #endif
|
---|
2200 | break;
|
---|
2201 |
|
---|
2202 | /* Legacy multi-monitor support */
|
---|
2203 | case SVGA_REG_NUM_GUEST_DISPLAYS:/* Number of guest displays in X/Y direction */
|
---|
2204 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegNumGuestDisplaysWr);
|
---|
2205 | break;
|
---|
2206 | case SVGA_REG_DISPLAY_ID: /* Display ID for the following display attributes */
|
---|
2207 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegDisplayIdWr);
|
---|
2208 | break;
|
---|
2209 | case SVGA_REG_DISPLAY_IS_PRIMARY:/* Whether this is a primary display */
|
---|
2210 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegDisplayIsPrimaryWr);
|
---|
2211 | break;
|
---|
2212 | case SVGA_REG_DISPLAY_POSITION_X:/* The display position x */
|
---|
2213 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegDisplayPositionXWr);
|
---|
2214 | break;
|
---|
2215 | case SVGA_REG_DISPLAY_POSITION_Y:/* The display position y */
|
---|
2216 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegDisplayPositionYWr);
|
---|
2217 | break;
|
---|
2218 | case SVGA_REG_DISPLAY_WIDTH: /* The display's width */
|
---|
2219 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegDisplayWidthWr);
|
---|
2220 | break;
|
---|
2221 | case SVGA_REG_DISPLAY_HEIGHT: /* The display's height */
|
---|
2222 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegDisplayHeightWr);
|
---|
2223 | break;
|
---|
2224 | #ifdef VBOX_WITH_VMSVGA3D
|
---|
2225 | /* See "Guest memory regions" below. */
|
---|
2226 | case SVGA_REG_GMR_ID:
|
---|
2227 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegGmrIdWr);
|
---|
2228 | pThis->svga.u32CurrentGMRId = u32;
|
---|
2229 | break;
|
---|
2230 |
|
---|
2231 | case SVGA_REG_GMR_DESCRIPTOR:
|
---|
2232 | # ifndef IN_RING3
|
---|
2233 | rc = VINF_IOM_R3_IOPORT_WRITE;
|
---|
2234 | break;
|
---|
2235 | # else /* IN_RING3 */
|
---|
2236 | {
|
---|
2237 | STAM_REL_COUNTER_INC(&pSVGAState->StatR3RegGmrDescriptorWr);
|
---|
2238 |
|
---|
2239 | /* Validate current GMR id. */
|
---|
2240 | uint32_t idGMR = pThis->svga.u32CurrentGMRId;
|
---|
2241 | AssertBreak(idGMR < pThis->svga.cGMR);
|
---|
2242 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
2243 |
|
---|
2244 | /* Free the old GMR if present. */
|
---|
2245 | vmsvgaR3GmrFree(pThisCC, idGMR);
|
---|
2246 |
|
---|
2247 | /* Just undefine the GMR? */
|
---|
2248 | RTGCPHYS GCPhys = (RTGCPHYS)u32 << GUEST_PAGE_SHIFT;
|
---|
2249 | if (GCPhys == 0)
|
---|
2250 | {
|
---|
2251 | STAM_REL_COUNTER_INC(&pSVGAState->StatR3RegGmrDescriptorWrFree);
|
---|
2252 | break;
|
---|
2253 | }
|
---|
2254 |
|
---|
2255 |
|
---|
2256 | /* Never cross a page boundary automatically. */
|
---|
2257 | const uint32_t cMaxPages = RT_MIN(VMSVGA_MAX_GMR_PAGES, UINT32_MAX / X86_PAGE_SIZE);
|
---|
2258 | uint32_t cPagesTotal = 0;
|
---|
2259 | uint32_t iDesc = 0;
|
---|
2260 | PVMSVGAGMRDESCRIPTOR paDescs = NULL;
|
---|
2261 | uint32_t cLoops = 0;
|
---|
2262 | RTGCPHYS GCPhysBase = GCPhys;
|
---|
2263 | while ((GCPhys >> GUEST_PAGE_SHIFT) == (GCPhysBase >> GUEST_PAGE_SHIFT))
|
---|
2264 | {
|
---|
2265 | /* Read descriptor. */
|
---|
2266 | SVGAGuestMemDescriptor desc;
|
---|
2267 | rc = PDMDevHlpPCIPhysRead(pDevIns, GCPhys, &desc, sizeof(desc));
|
---|
2268 | AssertRCBreak(VBOXSTRICTRC_VAL(rc));
|
---|
2269 |
|
---|
2270 | if (desc.numPages != 0)
|
---|
2271 | {
|
---|
2272 | AssertBreakStmt(desc.numPages <= cMaxPages, rc = VERR_OUT_OF_RANGE);
|
---|
2273 | cPagesTotal += desc.numPages;
|
---|
2274 | AssertBreakStmt(cPagesTotal <= cMaxPages, rc = VERR_OUT_OF_RANGE);
|
---|
2275 |
|
---|
2276 | if ((iDesc & 15) == 0)
|
---|
2277 | {
|
---|
2278 | void *pvNew = RTMemRealloc(paDescs, (iDesc + 16) * sizeof(VMSVGAGMRDESCRIPTOR));
|
---|
2279 | AssertBreakStmt(pvNew, rc = VERR_NO_MEMORY);
|
---|
2280 | paDescs = (PVMSVGAGMRDESCRIPTOR)pvNew;
|
---|
2281 | }
|
---|
2282 |
|
---|
2283 | paDescs[iDesc].GCPhys = (RTGCPHYS)desc.ppn << GUEST_PAGE_SHIFT;
|
---|
2284 | paDescs[iDesc++].numPages = desc.numPages;
|
---|
2285 |
|
---|
2286 | /* Continue with the next descriptor. */
|
---|
2287 | GCPhys += sizeof(desc);
|
---|
2288 | }
|
---|
2289 | else if (desc.ppn == 0)
|
---|
2290 | break; /* terminator */
|
---|
2291 | else /* Pointer to the next physical page of descriptors. */
|
---|
2292 | GCPhys = GCPhysBase = (RTGCPHYS)desc.ppn << GUEST_PAGE_SHIFT;
|
---|
2293 |
|
---|
2294 | cLoops++;
|
---|
2295 | AssertBreakStmt(cLoops < VMSVGA_MAX_GMR_DESC_LOOP_COUNT, rc = VERR_OUT_OF_RANGE);
|
---|
2296 | }
|
---|
2297 |
|
---|
2298 | AssertStmt(iDesc > 0 || RT_FAILURE_NP(rc), rc = VERR_OUT_OF_RANGE);
|
---|
2299 | if (RT_SUCCESS(rc))
|
---|
2300 | {
|
---|
2301 | /* Commit the GMR. */
|
---|
2302 | pSVGAState->paGMR[idGMR].paDesc = paDescs;
|
---|
2303 | pSVGAState->paGMR[idGMR].numDescriptors = iDesc;
|
---|
2304 | pSVGAState->paGMR[idGMR].cMaxPages = cPagesTotal;
|
---|
2305 | pSVGAState->paGMR[idGMR].cbTotal = cPagesTotal * GUEST_PAGE_SIZE;
|
---|
2306 | Assert((pSVGAState->paGMR[idGMR].cbTotal >> GUEST_PAGE_SHIFT) == cPagesTotal);
|
---|
2307 | Log(("Defined new gmr %x numDescriptors=%d cbTotal=%x (%#x pages)\n",
|
---|
2308 | idGMR, iDesc, pSVGAState->paGMR[idGMR].cbTotal, cPagesTotal));
|
---|
2309 | }
|
---|
2310 | else
|
---|
2311 | {
|
---|
2312 | RTMemFree(paDescs);
|
---|
2313 | STAM_REL_COUNTER_INC(&pSVGAState->StatR3RegGmrDescriptorWrErrors);
|
---|
2314 | }
|
---|
2315 | break;
|
---|
2316 | }
|
---|
2317 | # endif /* IN_RING3 */
|
---|
2318 | #endif // VBOX_WITH_VMSVGA3D
|
---|
2319 |
|
---|
2320 | case SVGA_REG_TRACES: /* Enable trace-based updates even when FIFO is on */
|
---|
2321 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegTracesWr);
|
---|
2322 | if (pThis->svga.fTraces == u32)
|
---|
2323 | break; /* nothing to do */
|
---|
2324 |
|
---|
2325 | #ifdef IN_RING3
|
---|
2326 | vmsvgaR3SetTraces(pDevIns, pThis, !!u32);
|
---|
2327 | #else
|
---|
2328 | rc = VINF_IOM_R3_IOPORT_WRITE;
|
---|
2329 | #endif
|
---|
2330 | break;
|
---|
2331 |
|
---|
2332 | case SVGA_REG_TOP: /* Must be 1 more than the last register */
|
---|
2333 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegTopWr);
|
---|
2334 | break;
|
---|
2335 |
|
---|
2336 | case SVGA_REG_NUM_DISPLAYS: /* (Deprecated) */
|
---|
2337 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegNumDisplaysWr);
|
---|
2338 | Log(("Write to deprecated register %x - val %x ignored\n", idxReg, u32));
|
---|
2339 | break;
|
---|
2340 |
|
---|
2341 | /*
|
---|
2342 | * SVGA_CAP_GBOBJECTS+ registers.
|
---|
2343 | */
|
---|
2344 | case SVGA_REG_COMMAND_LOW:
|
---|
2345 | {
|
---|
2346 | /* Lower 32 bits of command buffer physical address and submit the command buffer. */
|
---|
2347 | #ifdef IN_RING3
|
---|
2348 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegCommandLowWr);
|
---|
2349 | pThis->svga.u32RegCommandLow = u32;
|
---|
2350 |
|
---|
2351 | /* "lower 6 bits are used for the SVGACBContext" */
|
---|
2352 | RTGCPHYS GCPhysCB = pThis->svga.u32RegCommandHigh;
|
---|
2353 | GCPhysCB <<= 32;
|
---|
2354 | GCPhysCB |= pThis->svga.u32RegCommandLow & ~SVGA_CB_CONTEXT_MASK;
|
---|
2355 | SVGACBContext const CBCtx = (SVGACBContext)(pThis->svga.u32RegCommandLow & SVGA_CB_CONTEXT_MASK);
|
---|
2356 | vmsvgaR3CmdBufSubmit(pDevIns, pThis, pThisCC, GCPhysCB, CBCtx);
|
---|
2357 | #else
|
---|
2358 | rc = VINF_IOM_R3_IOPORT_WRITE;
|
---|
2359 | #endif
|
---|
2360 | break;
|
---|
2361 | }
|
---|
2362 |
|
---|
2363 | case SVGA_REG_COMMAND_HIGH:
|
---|
2364 | /* Upper 32 bits of command buffer PA. */
|
---|
2365 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegCommandHighWr);
|
---|
2366 | pThis->svga.u32RegCommandHigh = u32;
|
---|
2367 | break;
|
---|
2368 |
|
---|
2369 | case SVGA_REG_DEV_CAP:
|
---|
2370 | /* Write dev cap index, read value */
|
---|
2371 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegDevCapWr);
|
---|
2372 | pThis->svga.u32DevCapIndex = u32;
|
---|
2373 | break;
|
---|
2374 |
|
---|
2375 | case SVGA_REG_CMD_PREPEND_LOW:
|
---|
2376 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegCmdPrependLowWr);
|
---|
2377 | /* Not supported. */
|
---|
2378 | break;
|
---|
2379 |
|
---|
2380 | case SVGA_REG_CMD_PREPEND_HIGH:
|
---|
2381 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegCmdPrependHighWr);
|
---|
2382 | /* Not supported. */
|
---|
2383 | break;
|
---|
2384 |
|
---|
2385 | case SVGA_REG_GUEST_DRIVER_ID:
|
---|
2386 | if (u32 != SVGA_REG_GUEST_DRIVER_ID_SUBMIT)
|
---|
2387 | pThis->svga.u32GuestDriverId = u32;
|
---|
2388 | break;
|
---|
2389 |
|
---|
2390 | case SVGA_REG_GUEST_DRIVER_VERSION1:
|
---|
2391 | pThis->svga.u32GuestDriverVer1 = u32;
|
---|
2392 | break;
|
---|
2393 |
|
---|
2394 | case SVGA_REG_GUEST_DRIVER_VERSION2:
|
---|
2395 | pThis->svga.u32GuestDriverVer2 = u32;
|
---|
2396 | break;
|
---|
2397 |
|
---|
2398 | case SVGA_REG_GUEST_DRIVER_VERSION3:
|
---|
2399 | pThis->svga.u32GuestDriverVer3 = u32;
|
---|
2400 | break;
|
---|
2401 |
|
---|
2402 | case SVGA_REG_CURSOR_MOBID:
|
---|
2403 | /* Not supported, ignore. See correspondent comments in vmsvgaReadPort. */
|
---|
2404 | break;
|
---|
2405 |
|
---|
2406 | case SVGA_REG_FB_START:
|
---|
2407 | case SVGA_REG_MEM_START:
|
---|
2408 | case SVGA_REG_HOST_BITS_PER_PIXEL:
|
---|
2409 | case SVGA_REG_MAX_WIDTH:
|
---|
2410 | case SVGA_REG_MAX_HEIGHT:
|
---|
2411 | case SVGA_REG_VRAM_SIZE:
|
---|
2412 | case SVGA_REG_FB_SIZE:
|
---|
2413 | case SVGA_REG_CAPABILITIES:
|
---|
2414 | case SVGA_REG_MEM_SIZE:
|
---|
2415 | case SVGA_REG_SCRATCH_SIZE: /* Number of scratch registers */
|
---|
2416 | case SVGA_REG_MEM_REGS: /* Number of FIFO registers */
|
---|
2417 | case SVGA_REG_BYTES_PER_LINE:
|
---|
2418 | case SVGA_REG_FB_OFFSET:
|
---|
2419 | case SVGA_REG_RED_MASK:
|
---|
2420 | case SVGA_REG_GREEN_MASK:
|
---|
2421 | case SVGA_REG_BLUE_MASK:
|
---|
2422 | case SVGA_REG_GMRS_MAX_PAGES: /* Maximum number of 4KB pages for all GMRs */
|
---|
2423 | case SVGA_REG_MEMORY_SIZE: /* Total dedicated device memory excluding FIFO */
|
---|
2424 | case SVGA_REG_GMR_MAX_IDS:
|
---|
2425 | case SVGA_REG_GMR_MAX_DESCRIPTOR_LENGTH:
|
---|
2426 | case SVGA_REG_MAX_PRIMARY_BOUNDING_BOX_MEM:
|
---|
2427 | case SVGA_REG_SUGGESTED_GBOBJECT_MEM_SIZE_KB:
|
---|
2428 | case SVGA_REG_SCREENTARGET_MAX_WIDTH:
|
---|
2429 | case SVGA_REG_SCREENTARGET_MAX_HEIGHT:
|
---|
2430 | case SVGA_REG_MOB_MAX_SIZE:
|
---|
2431 | case SVGA_REG_BLANK_SCREEN_TARGETS:
|
---|
2432 | case SVGA_REG_CAP2:
|
---|
2433 | case SVGA_REG_DEVEL_CAP:
|
---|
2434 | case SVGA_REG_CURSOR_MAX_BYTE_SIZE:
|
---|
2435 | case SVGA_REG_CURSOR_MAX_DIMENSION:
|
---|
2436 | case SVGA_REG_FIFO_CAPS:
|
---|
2437 | case SVGA_REG_FENCE:
|
---|
2438 | case SVGA_REG_RESERVED1:
|
---|
2439 | case SVGA_REG_RESERVED2:
|
---|
2440 | case SVGA_REG_RESERVED3:
|
---|
2441 | case SVGA_REG_RESERVED4:
|
---|
2442 | case SVGA_REG_RESERVED5:
|
---|
2443 | case SVGA_REG_SCREENDMA:
|
---|
2444 | case SVGA_REG_GBOBJECT_MEM_SIZE_KB:
|
---|
2445 | /* Read only - ignore. */
|
---|
2446 | Log(("Write to R/O register %x - val %x ignored\n", idxReg, u32));
|
---|
2447 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegReadOnlyWr);
|
---|
2448 | break;
|
---|
2449 |
|
---|
2450 | case SVGA_REG_IRQ_STATUS:
|
---|
2451 | {
|
---|
2452 | if (pThis->fVmSvga3)
|
---|
2453 | {
|
---|
2454 | LogFlow(("vmsvga3MmioWrite SVGA_IRQSTATUS_PORT %x: status %x -> %x\n", u32, pThis->svga.u32IrqStatus, pThis->svga.u32IrqStatus & ~u32));
|
---|
2455 | ASMAtomicAndU32(&pThis->svga.u32IrqStatus, ~u32);
|
---|
2456 | /* Clear the irq in case all events have been cleared. */
|
---|
2457 | if (!(pThis->svga.u32IrqStatus & pThis->svga.u32IrqMask))
|
---|
2458 | {
|
---|
2459 | Log(("vmsvga3MmioWrite SVGA_IRQSTATUS_PORT: clearing IRQ\n"));
|
---|
2460 | PDMDevHlpPCISetIrqNoWait(pDevIns, 0, 0);
|
---|
2461 | }
|
---|
2462 | }
|
---|
2463 | break;
|
---|
2464 | }
|
---|
2465 |
|
---|
2466 | default:
|
---|
2467 | {
|
---|
2468 | uint32_t offReg;
|
---|
2469 | if ((offReg = idxReg - SVGA_SCRATCH_BASE) < pThis->svga.cScratchRegion)
|
---|
2470 | {
|
---|
2471 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
2472 | pThis->svga.au32ScratchRegion[offReg] = u32;
|
---|
2473 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegScratchWr);
|
---|
2474 | }
|
---|
2475 | else if ((offReg = idxReg - SVGA_PALETTE_BASE) < (uint32_t)SVGA_NUM_PALETTE_REGS)
|
---|
2476 | {
|
---|
2477 | /* Note! Using last_palette rather than palette here to preserve the VGA one.
|
---|
2478 | Btw, see rgb_to_pixel32. */
|
---|
2479 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegPaletteWr);
|
---|
2480 | u32 &= 0xff;
|
---|
2481 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
2482 | uint32_t uRgb = pThis->last_palette[offReg / 3];
|
---|
2483 | switch (offReg % 3)
|
---|
2484 | {
|
---|
2485 | case 0: uRgb = (uRgb & UINT32_C(0x0000ffff)) | (u32 << 16); break; /* red */
|
---|
2486 | case 1: uRgb = (uRgb & UINT32_C(0x00ff00ff)) | (u32 << 8); break; /* green */
|
---|
2487 | case 2: uRgb = (uRgb & UINT32_C(0x00ffff00)) | u32 ; break; /* blue */
|
---|
2488 | }
|
---|
2489 | pThis->last_palette[offReg / 3] = uRgb;
|
---|
2490 | }
|
---|
2491 | else
|
---|
2492 | {
|
---|
2493 | #if !defined(IN_RING3) && defined(VBOX_STRICT)
|
---|
2494 | rc = VINF_IOM_R3_IOPORT_WRITE;
|
---|
2495 | #else
|
---|
2496 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegUnknownWr);
|
---|
2497 | AssertMsgFailed(("reg=%#x u32=%#x\n", idxReg, u32));
|
---|
2498 | #endif
|
---|
2499 | }
|
---|
2500 | break;
|
---|
2501 | }
|
---|
2502 | }
|
---|
2503 | return rc;
|
---|
2504 | }
|
---|
2505 |
|
---|
2506 | /**
|
---|
2507 | * @callback_method_impl{FNIOMIOPORTNEWIN}
|
---|
2508 | */
|
---|
2509 | DECLCALLBACK(VBOXSTRICTRC) vmsvgaIORead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t *pu32, unsigned cb)
|
---|
2510 | {
|
---|
2511 | PVGASTATE pThis = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
|
---|
2512 | RT_NOREF_PV(pvUser);
|
---|
2513 |
|
---|
2514 | /* Only dword accesses. */
|
---|
2515 | if (cb == 4)
|
---|
2516 | {
|
---|
2517 | switch (offPort)
|
---|
2518 | {
|
---|
2519 | case SVGA_INDEX_PORT:
|
---|
2520 | *pu32 = pThis->svga.u32IndexReg;
|
---|
2521 | break;
|
---|
2522 |
|
---|
2523 | case SVGA_VALUE_PORT:
|
---|
2524 | {
|
---|
2525 | /* Rough index register validation. */
|
---|
2526 | uint32_t idxReg = pThis->svga.u32IndexReg;
|
---|
2527 | #if !defined(IN_RING3) && defined(VBOX_STRICT)
|
---|
2528 | ASSERT_GUEST_MSG_RETURN(idxReg < SVGA_SCRATCH_BASE + pThis->svga.cScratchRegion, ("idxReg=%#x\n", idxReg),
|
---|
2529 | VINF_IOM_R3_IOPORT_READ);
|
---|
2530 | #else
|
---|
2531 | ASSERT_GUEST_MSG_STMT_RETURN(idxReg < SVGA_SCRATCH_BASE + pThis->svga.cScratchRegion, ("idxReg=%#x\n", idxReg),
|
---|
2532 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegUnknownRd),
|
---|
2533 | VINF_SUCCESS);
|
---|
2534 | #endif
|
---|
2535 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
2536 |
|
---|
2537 | return vmsvgaReadPort(pDevIns, pThis, idxReg, pu32);
|
---|
2538 | }
|
---|
2539 |
|
---|
2540 | case SVGA_BIOS_PORT:
|
---|
2541 | Log(("Ignoring BIOS port read\n"));
|
---|
2542 | *pu32 = 0;
|
---|
2543 | break;
|
---|
2544 |
|
---|
2545 | case SVGA_IRQSTATUS_PORT:
|
---|
2546 | LogFlow(("vmsvgaIORead: SVGA_IRQSTATUS_PORT %x\n", pThis->svga.u32IrqStatus));
|
---|
2547 | *pu32 = pThis->svga.u32IrqStatus;
|
---|
2548 | break;
|
---|
2549 |
|
---|
2550 | default:
|
---|
2551 | ASSERT_GUEST_MSG_FAILED(("vmsvgaIORead: Unknown register %u was read from.\n", offPort));
|
---|
2552 | *pu32 = UINT32_MAX;
|
---|
2553 | break;
|
---|
2554 | }
|
---|
2555 | }
|
---|
2556 | else
|
---|
2557 | {
|
---|
2558 | Log(("Ignoring non-dword I/O port read at %x cb=%d\n", offPort, cb));
|
---|
2559 | *pu32 = UINT32_MAX;
|
---|
2560 | }
|
---|
2561 | return VINF_SUCCESS;
|
---|
2562 | }
|
---|
2563 |
|
---|
2564 | /**
|
---|
2565 | * @callback_method_impl{FNIOMIOPORTNEWOUT}
|
---|
2566 | */
|
---|
2567 | DECLCALLBACK(VBOXSTRICTRC) vmsvgaIOWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t u32, unsigned cb)
|
---|
2568 | {
|
---|
2569 | PVGASTATE pThis = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
|
---|
2570 | PVGASTATECC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC);
|
---|
2571 | RT_NOREF_PV(pvUser);
|
---|
2572 |
|
---|
2573 | /* Only dword accesses. */
|
---|
2574 | if (cb == 4)
|
---|
2575 | switch (offPort)
|
---|
2576 | {
|
---|
2577 | case SVGA_INDEX_PORT:
|
---|
2578 | pThis->svga.u32IndexReg = u32;
|
---|
2579 | break;
|
---|
2580 |
|
---|
2581 | case SVGA_VALUE_PORT:
|
---|
2582 | {
|
---|
2583 | /* Rough index register validation. */
|
---|
2584 | uint32_t idxReg = pThis->svga.u32IndexReg;
|
---|
2585 | #if !defined(IN_RING3) && defined(VBOX_STRICT)
|
---|
2586 | ASSERT_GUEST_MSG_RETURN(idxReg < SVGA_SCRATCH_BASE + pThis->svga.cScratchRegion, ("idxReg=%#x\n", idxReg),
|
---|
2587 | VINF_IOM_R3_IOPORT_WRITE);
|
---|
2588 | #else
|
---|
2589 | ASSERT_GUEST_MSG_STMT_RETURN(idxReg < SVGA_SCRATCH_BASE + pThis->svga.cScratchRegion, ("idxReg=%#x\n", idxReg),
|
---|
2590 | STAM_REL_COUNTER_INC(&pThis->svga.StatRegUnknownWr),
|
---|
2591 | VINF_SUCCESS);
|
---|
2592 | #endif
|
---|
2593 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
2594 |
|
---|
2595 | return vmsvgaWritePort(pDevIns, pThis, pThisCC, idxReg, u32);
|
---|
2596 | }
|
---|
2597 |
|
---|
2598 | case SVGA_BIOS_PORT:
|
---|
2599 | Log(("Ignoring BIOS port write (val=%x)\n", u32));
|
---|
2600 | break;
|
---|
2601 |
|
---|
2602 | case SVGA_IRQSTATUS_PORT:
|
---|
2603 | LogFlow(("vmsvgaIOWrite SVGA_IRQSTATUS_PORT %x: status %x -> %x\n", u32, pThis->svga.u32IrqStatus, pThis->svga.u32IrqStatus & ~u32));
|
---|
2604 | ASMAtomicAndU32(&pThis->svga.u32IrqStatus, ~u32);
|
---|
2605 | /* Clear the irq in case all events have been cleared. */
|
---|
2606 | if (!(pThis->svga.u32IrqStatus & pThis->svga.u32IrqMask))
|
---|
2607 | {
|
---|
2608 | Log(("vmsvgaIOWrite SVGA_IRQSTATUS_PORT: clearing IRQ\n"));
|
---|
2609 | PDMDevHlpPCISetIrqNoWait(pDevIns, 0, 0);
|
---|
2610 | }
|
---|
2611 | break;
|
---|
2612 |
|
---|
2613 | default:
|
---|
2614 | ASSERT_GUEST_MSG_FAILED(("vmsvgaIOWrite: Unknown register %u was written to, value %#x LB %u.\n", offPort, u32, cb));
|
---|
2615 | break;
|
---|
2616 | }
|
---|
2617 | else
|
---|
2618 | Log(("Ignoring non-dword write at %x val=%x cb=%d\n", offPort, u32, cb));
|
---|
2619 |
|
---|
2620 | return VINF_SUCCESS;
|
---|
2621 | }
|
---|
2622 |
|
---|
2623 | /**
|
---|
2624 | * @callback_method_impl{FNIOMMMIONEWREAD}
|
---|
2625 | */
|
---|
2626 | DECLCALLBACK(VBOXSTRICTRC) vmsvga3MmioRead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void *pv, unsigned cb)
|
---|
2627 | {
|
---|
2628 | PVGASTATE pThis = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
|
---|
2629 | RT_NOREF_PV(pvUser);
|
---|
2630 |
|
---|
2631 | /* Only dword accesses. */
|
---|
2632 | VBOXSTRICTRC rcStrict;
|
---|
2633 | if (cb == sizeof(uint32_t))
|
---|
2634 | {
|
---|
2635 | rcStrict = vmsvgaReadPort(pDevIns, pThis, (uint32_t)(off / sizeof(uint32_t)), (uint32_t *)pv);
|
---|
2636 | if (rcStrict == VINF_IOM_R3_IOPORT_READ)
|
---|
2637 | rcStrict = VINF_IOM_R3_MMIO_READ;
|
---|
2638 | }
|
---|
2639 | else
|
---|
2640 | {
|
---|
2641 | Log(("Ignoring non-dword I/O port read at %x cb=%d\n", off, cb));
|
---|
2642 | rcStrict = VINF_IOM_MMIO_UNUSED_00;
|
---|
2643 | }
|
---|
2644 | return rcStrict;
|
---|
2645 | }
|
---|
2646 |
|
---|
2647 | /**
|
---|
2648 | * @callback_method_impl{FNIOMMMIONEWWRITE}
|
---|
2649 | */
|
---|
2650 | DECLCALLBACK(VBOXSTRICTRC) vmsvga3MmioWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void const *pv, unsigned cb)
|
---|
2651 | {
|
---|
2652 | PVGASTATE pThis = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
|
---|
2653 | PVGASTATECC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC);
|
---|
2654 | RT_NOREF_PV(pvUser);
|
---|
2655 |
|
---|
2656 | /* Only dword accesses. */
|
---|
2657 | VBOXSTRICTRC rcStrict;
|
---|
2658 | if (cb == sizeof(uint32_t))
|
---|
2659 | {
|
---|
2660 | rcStrict = vmsvgaWritePort(pDevIns, pThis, pThisCC, (uint32_t)(off / sizeof(uint32_t)), *(uint32_t *)pv);
|
---|
2661 | if (rcStrict == VINF_IOM_R3_IOPORT_WRITE)
|
---|
2662 | rcStrict = VINF_IOM_R3_MMIO_WRITE;
|
---|
2663 | }
|
---|
2664 | else
|
---|
2665 | {
|
---|
2666 | Log(("Ignoring non-dword write at %x cb=%d\n", off, cb));
|
---|
2667 | rcStrict = VINF_SUCCESS;
|
---|
2668 | }
|
---|
2669 |
|
---|
2670 | return rcStrict;
|
---|
2671 | }
|
---|
2672 |
|
---|
2673 | #ifdef IN_RING3
|
---|
2674 |
|
---|
2675 | # ifdef DEBUG_FIFO_ACCESS
|
---|
2676 | /**
|
---|
2677 | * Handle FIFO memory access.
|
---|
2678 | * @returns VBox status code.
|
---|
2679 | * @param pVM VM handle.
|
---|
2680 | * @param pThis The shared VGA/VMSVGA instance data.
|
---|
2681 | * @param GCPhys The access physical address.
|
---|
2682 | * @param fWriteAccess Read or write access
|
---|
2683 | */
|
---|
2684 | static int vmsvgaR3DebugFifoAccess(PVM pVM, PVGASTATE pThis, RTGCPHYS GCPhys, bool fWriteAccess)
|
---|
2685 | {
|
---|
2686 | RT_NOREF(pVM);
|
---|
2687 | RTGCPHYS GCPhysOffset = GCPhys - pThis->svga.GCPhysFIFO;
|
---|
2688 | uint32_t *pFIFO = pThisCC->svga.pau32FIFO;
|
---|
2689 |
|
---|
2690 | switch (GCPhysOffset >> 2)
|
---|
2691 | {
|
---|
2692 | case SVGA_FIFO_MIN:
|
---|
2693 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_MIN = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2694 | break;
|
---|
2695 | case SVGA_FIFO_MAX:
|
---|
2696 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_MAX = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2697 | break;
|
---|
2698 | case SVGA_FIFO_NEXT_CMD:
|
---|
2699 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_NEXT_CMD = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2700 | break;
|
---|
2701 | case SVGA_FIFO_STOP:
|
---|
2702 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_STOP = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2703 | break;
|
---|
2704 | case SVGA_FIFO_CAPABILITIES:
|
---|
2705 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_CAPABILITIES = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2706 | break;
|
---|
2707 | case SVGA_FIFO_FLAGS:
|
---|
2708 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_FLAGS = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2709 | break;
|
---|
2710 | case SVGA_FIFO_FENCE:
|
---|
2711 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_FENCE = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2712 | break;
|
---|
2713 | case SVGA_FIFO_3D_HWVERSION:
|
---|
2714 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_HWVERSION = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2715 | break;
|
---|
2716 | case SVGA_FIFO_PITCHLOCK:
|
---|
2717 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_PITCHLOCK = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2718 | break;
|
---|
2719 | case SVGA_FIFO_CURSOR_ON:
|
---|
2720 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_CURSOR_ON = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2721 | break;
|
---|
2722 | case SVGA_FIFO_CURSOR_X:
|
---|
2723 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_CURSOR_X = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2724 | break;
|
---|
2725 | case SVGA_FIFO_CURSOR_Y:
|
---|
2726 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_CURSOR_Y = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2727 | break;
|
---|
2728 | case SVGA_FIFO_CURSOR_COUNT:
|
---|
2729 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_CURSOR_COUNT = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2730 | break;
|
---|
2731 | case SVGA_FIFO_CURSOR_LAST_UPDATED:
|
---|
2732 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_CURSOR_LAST_UPDATED = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2733 | break;
|
---|
2734 | case SVGA_FIFO_RESERVED:
|
---|
2735 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_RESERVED = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2736 | break;
|
---|
2737 | case SVGA_FIFO_CURSOR_SCREEN_ID:
|
---|
2738 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_CURSOR_SCREEN_ID = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2739 | break;
|
---|
2740 | case SVGA_FIFO_DEAD:
|
---|
2741 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_DEAD = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2742 | break;
|
---|
2743 | case SVGA_FIFO_3D_HWVERSION_REVISED:
|
---|
2744 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_HWVERSION_REVISED = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2745 | break;
|
---|
2746 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_3D:
|
---|
2747 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_3D = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2748 | break;
|
---|
2749 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_MAX_LIGHTS:
|
---|
2750 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_MAX_LIGHTS = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2751 | break;
|
---|
2752 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_MAX_TEXTURES:
|
---|
2753 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_MAX_TEXTURES = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2754 | break;
|
---|
2755 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_MAX_CLIP_PLANES:
|
---|
2756 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_MAX_CLIP_PLANES = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2757 | break;
|
---|
2758 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_VERTEX_SHADER_VERSION:
|
---|
2759 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_VERTEX_SHADER_VERSION = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2760 | break;
|
---|
2761 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_VERTEX_SHADER:
|
---|
2762 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_VERTEX_SHADER = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2763 | break;
|
---|
2764 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_FRAGMENT_SHADER_VERSION:
|
---|
2765 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_FRAGMENT_SHADER_VERSION = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2766 | break;
|
---|
2767 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_FRAGMENT_SHADER:
|
---|
2768 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_FRAGMENT_SHADER = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2769 | break;
|
---|
2770 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_MAX_RENDER_TARGETS:
|
---|
2771 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_MAX_RENDER_TARGETS = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2772 | break;
|
---|
2773 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_S23E8_TEXTURES:
|
---|
2774 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_S23E8_TEXTURES = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2775 | break;
|
---|
2776 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_S10E5_TEXTURES:
|
---|
2777 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_S10E5_TEXTURES = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2778 | break;
|
---|
2779 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_MAX_FIXED_VERTEXBLEND:
|
---|
2780 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_MAX_FIXED_VERTEXBLEND = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2781 | break;
|
---|
2782 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_D16_BUFFER_FORMAT:
|
---|
2783 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_D16_BUFFER_FORMAT = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2784 | break;
|
---|
2785 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_D24S8_BUFFER_FORMAT:
|
---|
2786 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_D24S8_BUFFER_FORMAT = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2787 | break;
|
---|
2788 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_D24X8_BUFFER_FORMAT:
|
---|
2789 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_D24X8_BUFFER_FORMAT = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2790 | break;
|
---|
2791 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_QUERY_TYPES:
|
---|
2792 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_QUERY_TYPES = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2793 | break;
|
---|
2794 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_TEXTURE_GRADIENT_SAMPLING:
|
---|
2795 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_TEXTURE_GRADIENT_SAMPLING = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2796 | break;
|
---|
2797 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_MAX_POINT_SIZE:
|
---|
2798 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_MAX_POINT_SIZE = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2799 | break;
|
---|
2800 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_MAX_SHADER_TEXTURES:
|
---|
2801 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_MAX_SHADER_TEXTURES = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2802 | break;
|
---|
2803 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_MAX_TEXTURE_WIDTH:
|
---|
2804 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_MAX_TEXTURE_WIDTH = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2805 | break;
|
---|
2806 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_MAX_TEXTURE_HEIGHT:
|
---|
2807 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_MAX_TEXTURE_HEIGHT = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2808 | break;
|
---|
2809 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_MAX_VOLUME_EXTENT:
|
---|
2810 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_MAX_VOLUME_EXTENT = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2811 | break;
|
---|
2812 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_MAX_TEXTURE_REPEAT:
|
---|
2813 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_MAX_TEXTURE_REPEAT = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2814 | break;
|
---|
2815 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_MAX_TEXTURE_ASPECT_RATIO:
|
---|
2816 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_MAX_TEXTURE_ASPECT_RATIO = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2817 | break;
|
---|
2818 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_MAX_TEXTURE_ANISOTROPY:
|
---|
2819 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_MAX_TEXTURE_ANISOTROPY = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2820 | break;
|
---|
2821 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_MAX_PRIMITIVE_COUNT:
|
---|
2822 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_MAX_PRIMITIVE_COUNT = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2823 | break;
|
---|
2824 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_MAX_VERTEX_INDEX:
|
---|
2825 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_MAX_VERTEX_INDEX = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2826 | break;
|
---|
2827 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_MAX_VERTEX_SHADER_INSTRUCTIONS:
|
---|
2828 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_MAX_VERTEX_SHADER_INSTRUCTIONS = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2829 | break;
|
---|
2830 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_MAX_FRAGMENT_SHADER_INSTRUCTIONS:
|
---|
2831 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_MAX_FRAGMENT_SHADER_INSTRUCTIONS = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2832 | break;
|
---|
2833 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_MAX_VERTEX_SHADER_TEMPS:
|
---|
2834 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_MAX_VERTEX_SHADER_TEMPS = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2835 | break;
|
---|
2836 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_MAX_FRAGMENT_SHADER_TEMPS:
|
---|
2837 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_MAX_FRAGMENT_SHADER_TEMPS = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2838 | break;
|
---|
2839 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_TEXTURE_OPS:
|
---|
2840 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_TEXTURE_OPS = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2841 | break;
|
---|
2842 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_SURFACEFMT_X8R8G8B8:
|
---|
2843 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_SURFACEFMT_X8R8G8B8 = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2844 | break;
|
---|
2845 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_SURFACEFMT_A8R8G8B8:
|
---|
2846 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_SURFACEFMT_A8R8G8B8 = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2847 | break;
|
---|
2848 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_SURFACEFMT_A2R10G10B10:
|
---|
2849 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_SURFACEFMT_A2R10G10B10 = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2850 | break;
|
---|
2851 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_SURFACEFMT_X1R5G5B5:
|
---|
2852 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_SURFACEFMT_X1R5G5B5 = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2853 | break;
|
---|
2854 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_SURFACEFMT_A1R5G5B5:
|
---|
2855 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_SURFACEFMT_A1R5G5B5 = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2856 | break;
|
---|
2857 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_SURFACEFMT_A4R4G4B4:
|
---|
2858 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_SURFACEFMT_A4R4G4B4 = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2859 | break;
|
---|
2860 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_SURFACEFMT_R5G6B5:
|
---|
2861 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_SURFACEFMT_R5G6B5 = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2862 | break;
|
---|
2863 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_SURFACEFMT_LUMINANCE16:
|
---|
2864 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_SURFACEFMT_LUMINANCE16 = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2865 | break;
|
---|
2866 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_SURFACEFMT_LUMINANCE8_ALPHA8:
|
---|
2867 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_SURFACEFMT_LUMINANCE8_ALPHA8 = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2868 | break;
|
---|
2869 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_SURFACEFMT_ALPHA8:
|
---|
2870 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_SURFACEFMT_ALPHA8 = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2871 | break;
|
---|
2872 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_SURFACEFMT_LUMINANCE8:
|
---|
2873 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_SURFACEFMT_LUMINANCE8 = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2874 | break;
|
---|
2875 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_SURFACEFMT_Z_D16:
|
---|
2876 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_SURFACEFMT_Z_D16 = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2877 | break;
|
---|
2878 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_SURFACEFMT_Z_D24S8:
|
---|
2879 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_SURFACEFMT_Z_D24S8 = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2880 | break;
|
---|
2881 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_SURFACEFMT_Z_D24X8:
|
---|
2882 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_SURFACEFMT_Z_D24X8 = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2883 | break;
|
---|
2884 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_SURFACEFMT_DXT1:
|
---|
2885 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_SURFACEFMT_DXT1 = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2886 | break;
|
---|
2887 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_SURFACEFMT_DXT2:
|
---|
2888 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_SURFACEFMT_DXT2 = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2889 | break;
|
---|
2890 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_SURFACEFMT_DXT3:
|
---|
2891 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_SURFACEFMT_DXT3 = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2892 | break;
|
---|
2893 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_SURFACEFMT_DXT4:
|
---|
2894 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_SURFACEFMT_DXT4 = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2895 | break;
|
---|
2896 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_SURFACEFMT_DXT5:
|
---|
2897 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_SURFACEFMT_DXT5 = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2898 | break;
|
---|
2899 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_SURFACEFMT_BUMPX8L8V8U8:
|
---|
2900 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_SURFACEFMT_BUMPX8L8V8U8 = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2901 | break;
|
---|
2902 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_SURFACEFMT_A2W10V10U10:
|
---|
2903 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_SURFACEFMT_A2W10V10U10 = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2904 | break;
|
---|
2905 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_SURFACEFMT_BUMPU8V8:
|
---|
2906 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_SURFACEFMT_BUMPU8V8 = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2907 | break;
|
---|
2908 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_SURFACEFMT_Q8W8V8U8:
|
---|
2909 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_SURFACEFMT_Q8W8V8U8 = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2910 | break;
|
---|
2911 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_SURFACEFMT_CxV8U8:
|
---|
2912 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_SURFACEFMT_CxV8U8 = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2913 | break;
|
---|
2914 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_SURFACEFMT_R_S10E5:
|
---|
2915 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_SURFACEFMT_R_S10E5 = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2916 | break;
|
---|
2917 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_SURFACEFMT_R_S23E8:
|
---|
2918 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_SURFACEFMT_R_S23E8 = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2919 | break;
|
---|
2920 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_SURFACEFMT_RG_S10E5:
|
---|
2921 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_SURFACEFMT_RG_S10E5 = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2922 | break;
|
---|
2923 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_SURFACEFMT_RG_S23E8:
|
---|
2924 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_SURFACEFMT_RG_S23E8 = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2925 | break;
|
---|
2926 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_SURFACEFMT_ARGB_S10E5:
|
---|
2927 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_SURFACEFMT_ARGB_S10E5 = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2928 | break;
|
---|
2929 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_SURFACEFMT_ARGB_S23E8:
|
---|
2930 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_SURFACEFMT_ARGB_S23E8 = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2931 | break;
|
---|
2932 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_MAX_VERTEX_SHADER_TEXTURES:
|
---|
2933 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_MAX_VERTEX_SHADER_TEXTURES = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2934 | break;
|
---|
2935 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_MAX_SIMULTANEOUS_RENDER_TARGETS:
|
---|
2936 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_MAX_SIMULTANEOUS_RENDER_TARGETS = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2937 | break;
|
---|
2938 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_SURFACEFMT_V16U16:
|
---|
2939 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_SURFACEFMT_V16U16 = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2940 | break;
|
---|
2941 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_SURFACEFMT_G16R16:
|
---|
2942 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_SURFACEFMT_G16R16 = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2943 | break;
|
---|
2944 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_SURFACEFMT_A16B16G16R16:
|
---|
2945 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_SURFACEFMT_A16B16G16R16 = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2946 | break;
|
---|
2947 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_SURFACEFMT_UYVY:
|
---|
2948 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_SURFACEFMT_UYVY = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2949 | break;
|
---|
2950 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_SURFACEFMT_YUY2:
|
---|
2951 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_SURFACEFMT_YUY2 = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2952 | break;
|
---|
2953 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_DEAD4: /* SVGA3D_DEVCAP_MULTISAMPLE_NONMASKABLESAMPLES */
|
---|
2954 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_DEAD4 (SVGA3D_DEVCAP_MULTISAMPLE_NONMASKABLESAMPLES) = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2955 | break;
|
---|
2956 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_DEAD5: /* SVGA3D_DEVCAP_MULTISAMPLE_MASKABLESAMPLES */
|
---|
2957 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_DEAD5 (SVGA3D_DEVCAP_MULTISAMPLE_MASKABLESAMPLES) = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2958 | break;
|
---|
2959 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_DEAD7: /* SVGA3D_DEVCAP_ALPHATOCOVERAGE */
|
---|
2960 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_DEAD7 (SVGA3D_DEVCAP_ALPHATOCOVERAGE) = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2961 | break;
|
---|
2962 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_DEAD6: /* SVGA3D_DEVCAP_SUPERSAMPLE */
|
---|
2963 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_DEAD6 (SVGA3D_DEVCAP_SUPERSAMPLE) = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2964 | break;
|
---|
2965 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_AUTOGENMIPMAPS:
|
---|
2966 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_AUTOGENMIPMAPS = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2967 | break;
|
---|
2968 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_SURFACEFMT_NV12:
|
---|
2969 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_SURFACEFMT_NV12 = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2970 | break;
|
---|
2971 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_DEAD10: /* SVGA3D_DEVCAP_SURFACEFMT_AYUV */
|
---|
2972 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_DEAD10 (SVGA3D_DEVCAP_SURFACEFMT_AYUV) = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2973 | break;
|
---|
2974 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_MAX_CONTEXT_IDS:
|
---|
2975 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_MAX_CONTEXT_IDS = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2976 | break;
|
---|
2977 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_MAX_SURFACE_IDS:
|
---|
2978 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_MAX_SURFACE_IDS = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2979 | break;
|
---|
2980 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_SURFACEFMT_Z_DF16:
|
---|
2981 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_SURFACEFMT_Z_DF16 = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2982 | break;
|
---|
2983 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_SURFACEFMT_Z_DF24:
|
---|
2984 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_SURFACEFMT_Z_DF24 = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2985 | break;
|
---|
2986 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_SURFACEFMT_Z_D24S8_INT:
|
---|
2987 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_SURFACEFMT_Z_D24S8_INT = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2988 | break;
|
---|
2989 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_SURFACEFMT_ATI1:
|
---|
2990 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_SURFACEFMT_ATI1 = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2991 | break;
|
---|
2992 | case SVGA_FIFO_3D_CAPS + SVGA3D_DEVCAP_SURFACEFMT_ATI2:
|
---|
2993 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS SVGA3D_DEVCAP_SURFACEFMT_ATI2 = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2994 | break;
|
---|
2995 | case SVGA_FIFO_3D_CAPS_LAST:
|
---|
2996 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_3D_CAPS_LAST = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
2997 | break;
|
---|
2998 | case SVGA_FIFO_GUEST_3D_HWVERSION:
|
---|
2999 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_GUEST_3D_HWVERSION = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
3000 | break;
|
---|
3001 | case SVGA_FIFO_FENCE_GOAL:
|
---|
3002 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_FENCE_GOAL = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
3003 | break;
|
---|
3004 | case SVGA_FIFO_BUSY:
|
---|
3005 | Log(("vmsvgaFIFOAccess [0x%x]: %s SVGA_FIFO_BUSY = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", pFIFO[GCPhysOffset >> 2]));
|
---|
3006 | break;
|
---|
3007 | default:
|
---|
3008 | Log(("vmsvgaFIFOAccess [0x%x]: %s access at offset %x = %x\n", GCPhysOffset >> 2, (fWriteAccess) ? "WRITE" : "READ", GCPhysOffset, pFIFO[GCPhysOffset >> 2]));
|
---|
3009 | break;
|
---|
3010 | }
|
---|
3011 |
|
---|
3012 | return VINF_EM_RAW_EMULATE_INSTR;
|
---|
3013 | }
|
---|
3014 | # endif /* DEBUG_FIFO_ACCESS */
|
---|
3015 |
|
---|
3016 | # if defined(VMSVGA_USE_FIFO_ACCESS_HANDLER) || defined(DEBUG_FIFO_ACCESS)
|
---|
3017 | /**
|
---|
3018 | * HC access handler for the FIFO.
|
---|
3019 | *
|
---|
3020 | * @returns VINF_SUCCESS if the handler have carried out the operation.
|
---|
3021 | * @returns VINF_PGM_HANDLER_DO_DEFAULT if the caller should carry out the access operation.
|
---|
3022 | * @param pVM VM Handle.
|
---|
3023 | * @param pVCpu The cross context CPU structure for the calling EMT.
|
---|
3024 | * @param GCPhys The physical address the guest is writing to.
|
---|
3025 | * @param pvPhys The HC mapping of that address.
|
---|
3026 | * @param pvBuf What the guest is reading/writing.
|
---|
3027 | * @param cbBuf How much it's reading/writing.
|
---|
3028 | * @param enmAccessType The access type.
|
---|
3029 | * @param enmOrigin Who is making the access.
|
---|
3030 | * @param pvUser User argument.
|
---|
3031 | */
|
---|
3032 | static DECLCALLBACK(VBOXSTRICTRC)
|
---|
3033 | vmsvgaR3FifoAccessHandler(PVM pVM, PVMCPU pVCpu, RTGCPHYS GCPhys, void *pvPhys, void *pvBuf, size_t cbBuf,
|
---|
3034 | PGMACCESSTYPE enmAccessType, PGMACCESSORIGIN enmOrigin, void *pvUser)
|
---|
3035 | {
|
---|
3036 | NOREF(pVCpu); NOREF(pvPhys); NOREF(pvBuf); NOREF(cbBuf); NOREF(enmOrigin); NOREF(enmAccessType); NOREF(GCPhys);
|
---|
3037 | PVGASTATE pThis = (PVGASTATE)pvUser;
|
---|
3038 | AssertPtr(pThis);
|
---|
3039 |
|
---|
3040 | # ifdef VMSVGA_USE_FIFO_ACCESS_HANDLER
|
---|
3041 | /*
|
---|
3042 | * Wake up the FIFO thread as it might have work to do now.
|
---|
3043 | */
|
---|
3044 | int rc = PDMDevHlpSUPSemEventSignal(pDevIns, pThis->svga.hFIFORequestSem);
|
---|
3045 | AssertLogRelRC(rc);
|
---|
3046 | # endif
|
---|
3047 |
|
---|
3048 | # ifdef DEBUG_FIFO_ACCESS
|
---|
3049 | /*
|
---|
3050 | * When in debug-fifo-access mode, we do not disable the access handler,
|
---|
3051 | * but leave it on as we wish to catch all access.
|
---|
3052 | */
|
---|
3053 | Assert(GCPhys >= pThis->svga.GCPhysFIFO);
|
---|
3054 | rc = vmsvgaR3DebugFifoAccess(pVM, pThis, GCPhys, enmAccessType == PGMACCESSTYPE_WRITE);
|
---|
3055 | # elif defined(VMSVGA_USE_FIFO_ACCESS_HANDLER)
|
---|
3056 | /*
|
---|
3057 | * Temporarily disable the access handler now that we've kicked the FIFO thread.
|
---|
3058 | */
|
---|
3059 | STAM_REL_COUNTER_INC(&pThisCC->svga.pSvgaR3State->StatFifoAccessHandler);
|
---|
3060 | rc = PGMHandlerPhysicalPageTempOff(pVM, pThis->svga.GCPhysFIFO, pThis->svga.GCPhysFIFO);
|
---|
3061 | # endif
|
---|
3062 | if (RT_SUCCESS(rc))
|
---|
3063 | return VINF_PGM_HANDLER_DO_DEFAULT;
|
---|
3064 | AssertMsg(rc <= VINF_SUCCESS, ("rc=%Rrc\n", rc));
|
---|
3065 | return rc;
|
---|
3066 | }
|
---|
3067 | # endif /* VMSVGA_USE_FIFO_ACCESS_HANDLER || DEBUG_FIFO_ACCESS */
|
---|
3068 |
|
---|
3069 | #endif /* IN_RING3 */
|
---|
3070 |
|
---|
3071 | #ifdef DEBUG_GMR_ACCESS
|
---|
3072 | # ifdef IN_RING3
|
---|
3073 |
|
---|
3074 | /**
|
---|
3075 | * HC access handler for GMRs.
|
---|
3076 | *
|
---|
3077 | * @returns VINF_SUCCESS if the handler have carried out the operation.
|
---|
3078 | * @returns VINF_PGM_HANDLER_DO_DEFAULT if the caller should carry out the access operation.
|
---|
3079 | * @param pVM VM Handle.
|
---|
3080 | * @param pVCpu The cross context CPU structure for the calling EMT.
|
---|
3081 | * @param GCPhys The physical address the guest is writing to.
|
---|
3082 | * @param pvPhys The HC mapping of that address.
|
---|
3083 | * @param pvBuf What the guest is reading/writing.
|
---|
3084 | * @param cbBuf How much it's reading/writing.
|
---|
3085 | * @param enmAccessType The access type.
|
---|
3086 | * @param enmOrigin Who is making the access.
|
---|
3087 | * @param pvUser User argument.
|
---|
3088 | */
|
---|
3089 | static DECLCALLBACK(VBOXSTRICTRC)
|
---|
3090 | vmsvgaR3GmrAccessHandler(PVM pVM, PVMCPU pVCpu, RTGCPHYS GCPhys, void *pvPhys, void *pvBuf, size_t cbBuf,
|
---|
3091 | PGMACCESSTYPE enmAccessType, PGMACCESSORIGIN enmOrigin, void *pvUser)
|
---|
3092 | {
|
---|
3093 | PVGASTATE pThis = (PVGASTATE)pvUser;
|
---|
3094 | Assert(pThis);
|
---|
3095 | PVMSVGAR3STATE pSVGAState = pThisCC->svga.pSvgaR3State;
|
---|
3096 | NOREF(pVCpu); NOREF(pvPhys); NOREF(pvBuf); NOREF(cbBuf); NOREF(enmAccessType); NOREF(enmOrigin);
|
---|
3097 |
|
---|
3098 | Log(("vmsvgaR3GmrAccessHandler: GMR access to page %RGp\n", GCPhys));
|
---|
3099 |
|
---|
3100 | for (uint32_t i = 0; i < pThis->svga.cGMR; ++i)
|
---|
3101 | {
|
---|
3102 | PGMR pGMR = &pSVGAState->paGMR[i];
|
---|
3103 |
|
---|
3104 | if (pGMR->numDescriptors)
|
---|
3105 | {
|
---|
3106 | for (uint32_t j = 0; j < pGMR->numDescriptors; j++)
|
---|
3107 | {
|
---|
3108 | if ( GCPhys >= pGMR->paDesc[j].GCPhys
|
---|
3109 | && GCPhys < pGMR->paDesc[j].GCPhys + pGMR->paDesc[j].numPages * GUEST_PAGE_SIZE)
|
---|
3110 | {
|
---|
3111 | /*
|
---|
3112 | * Turn off the write handler for this particular page and make it R/W.
|
---|
3113 | * Then return telling the caller to restart the guest instruction.
|
---|
3114 | */
|
---|
3115 | int rc = PGMHandlerPhysicalPageTempOff(pVM, pGMR->paDesc[j].GCPhys, GCPhys);
|
---|
3116 | AssertRC(rc);
|
---|
3117 | return VINF_PGM_HANDLER_DO_DEFAULT;
|
---|
3118 | }
|
---|
3119 | }
|
---|
3120 | }
|
---|
3121 | }
|
---|
3122 |
|
---|
3123 | return VINF_PGM_HANDLER_DO_DEFAULT;
|
---|
3124 | }
|
---|
3125 |
|
---|
3126 | /** Callback handler for VMR3ReqCallWaitU */
|
---|
3127 | static DECLCALLBACK(int) vmsvgaR3RegisterGmr(PPDMDEVINS pDevIns, uint32_t gmrId)
|
---|
3128 | {
|
---|
3129 | PVGASTATE pThis = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
|
---|
3130 | PVMSVGAR3STATE pSVGAState = pThisCC->svga.pSvgaR3State;
|
---|
3131 | PGMR pGMR = &pSVGAState->paGMR[gmrId];
|
---|
3132 | int rc;
|
---|
3133 |
|
---|
3134 | for (uint32_t i = 0; i < pGMR->numDescriptors; i++)
|
---|
3135 | {
|
---|
3136 | rc = PDMDevHlpPGMHandlerPhysicalRegister(pDevIns, pGMR->paDesc[i].GCPhys,
|
---|
3137 | pGMR->paDesc[i].GCPhys + pGMR->paDesc[i].numPages * GUEST_PAGE_SIZE - 1,
|
---|
3138 | pThis->svga.hGmrAccessHandlerType, pThis, NIL_RTR0PTR, NIL_RTRCPTR, "VMSVGA GMR");
|
---|
3139 | AssertRC(rc);
|
---|
3140 | }
|
---|
3141 | return VINF_SUCCESS;
|
---|
3142 | }
|
---|
3143 |
|
---|
3144 | /** Callback handler for VMR3ReqCallWaitU */
|
---|
3145 | static DECLCALLBACK(int) vmsvgaR3DeregisterGmr(PPDMDEVINS pDevIns, uint32_t gmrId)
|
---|
3146 | {
|
---|
3147 | PVGASTATE pThis = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
|
---|
3148 | PVMSVGAR3STATE pSVGAState = pThisCC->svga.pSvgaR3State;
|
---|
3149 | PGMR pGMR = &pSVGAState->paGMR[gmrId];
|
---|
3150 |
|
---|
3151 | for (uint32_t i = 0; i < pGMR->numDescriptors; i++)
|
---|
3152 | {
|
---|
3153 | int rc = PDMDevHlpPGMHandlerPhysicalDeregister(pDevIns, pGMR->paDesc[i].GCPhys);
|
---|
3154 | AssertRC(rc);
|
---|
3155 | }
|
---|
3156 | return VINF_SUCCESS;
|
---|
3157 | }
|
---|
3158 |
|
---|
3159 | /** Callback handler for VMR3ReqCallWaitU */
|
---|
3160 | static DECLCALLBACK(int) vmsvgaR3ResetGmrHandlers(PVGASTATE pThis)
|
---|
3161 | {
|
---|
3162 | PVMSVGAR3STATE pSVGAState = pThisCC->svga.pSvgaR3State;
|
---|
3163 |
|
---|
3164 | for (uint32_t i = 0; i < pThis->svga.cGMR; ++i)
|
---|
3165 | {
|
---|
3166 | PGMR pGMR = &pSVGAState->paGMR[i];
|
---|
3167 |
|
---|
3168 | if (pGMR->numDescriptors)
|
---|
3169 | {
|
---|
3170 | for (uint32_t j = 0; j < pGMR->numDescriptors; j++)
|
---|
3171 | {
|
---|
3172 | int rc = PDMDevHlpPGMHandlerPhysicalReset(pDevIns, pGMR->paDesc[j].GCPhys);
|
---|
3173 | AssertRC(rc);
|
---|
3174 | }
|
---|
3175 | }
|
---|
3176 | }
|
---|
3177 | return VINF_SUCCESS;
|
---|
3178 | }
|
---|
3179 |
|
---|
3180 | # endif /* IN_RING3 */
|
---|
3181 | #endif /* DEBUG_GMR_ACCESS */
|
---|
3182 |
|
---|
3183 | /* -=-=-=-=-=- Ring 3 -=-=-=-=-=- */
|
---|
3184 |
|
---|
3185 | #ifdef IN_RING3
|
---|
3186 |
|
---|
3187 |
|
---|
3188 | /*
|
---|
3189 | *
|
---|
3190 | * Command buffer submission.
|
---|
3191 | *
|
---|
3192 | * Guest submits a buffer by writing to SVGA_REG_COMMAND_LOW register.
|
---|
3193 | *
|
---|
3194 | * EMT thread appends a command buffer to the context queue (VMSVGACMDBUFCTX::listSubmitted)
|
---|
3195 | * and wakes up the FIFO thread.
|
---|
3196 | *
|
---|
3197 | * FIFO thread fetches the command buffer from the queue, processes the commands and writes
|
---|
3198 | * the buffer header back to the guest memory.
|
---|
3199 | *
|
---|
3200 | * If buffers are preempted, then the EMT thread removes all buffers from the context queue.
|
---|
3201 | *
|
---|
3202 | */
|
---|
3203 |
|
---|
3204 |
|
---|
3205 | /** Update a command buffer header 'status' and 'errorOffset' fields in the guest memory.
|
---|
3206 | *
|
---|
3207 | * @param pDevIns The device instance.
|
---|
3208 | * @param GCPhysCB Guest physical address of the command buffer header.
|
---|
3209 | * @param status Command buffer status (SVGA_CB_STATUS_*).
|
---|
3210 | * @param errorOffset Offset to the first byte of the failing command for SVGA_CB_STATUS_COMMAND_ERROR.
|
---|
3211 | * errorOffset is ignored if the status is not SVGA_CB_STATUS_COMMAND_ERROR.
|
---|
3212 | * @thread FIFO or EMT.
|
---|
3213 | */
|
---|
3214 | static void vmsvgaR3CmdBufWriteStatus(PPDMDEVINS pDevIns, RTGCPHYS GCPhysCB, SVGACBStatus status, uint32_t errorOffset)
|
---|
3215 | {
|
---|
3216 | SVGACBHeader hdr;
|
---|
3217 | hdr.status = status;
|
---|
3218 | hdr.errorOffset = errorOffset;
|
---|
3219 | AssertCompile( RT_OFFSETOF(SVGACBHeader, status) == 0
|
---|
3220 | && RT_OFFSETOF(SVGACBHeader, errorOffset) == 4
|
---|
3221 | && RT_OFFSETOF(SVGACBHeader, id) == 8);
|
---|
3222 | size_t const cbWrite = status == SVGA_CB_STATUS_COMMAND_ERROR
|
---|
3223 | ? RT_UOFFSET_AFTER(SVGACBHeader, errorOffset) /* Both 'status' and 'errorOffset' fields. */
|
---|
3224 | : RT_UOFFSET_AFTER(SVGACBHeader, status); /* Only 'status' field. */
|
---|
3225 | PDMDevHlpPCIPhysWrite(pDevIns, GCPhysCB, &hdr, cbWrite);
|
---|
3226 | }
|
---|
3227 |
|
---|
3228 |
|
---|
3229 | /** Raise an IRQ.
|
---|
3230 | *
|
---|
3231 | * @param pDevIns The device instance.
|
---|
3232 | * @param pThis The shared VGA/VMSVGA state.
|
---|
3233 | * @param u32IrqStatus SVGA_IRQFLAG_* bits.
|
---|
3234 | * @thread FIFO or EMT.
|
---|
3235 | */
|
---|
3236 | static void vmsvgaR3CmdBufRaiseIRQ(PPDMDEVINS pDevIns, PVGASTATE pThis, uint32_t u32IrqStatus)
|
---|
3237 | {
|
---|
3238 | int const rcLock = PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED);
|
---|
3239 | PDM_CRITSECT_RELEASE_ASSERT_RC_DEV(pDevIns, &pThis->CritSect, rcLock);
|
---|
3240 |
|
---|
3241 | if (pThis->svga.u32IrqMask & u32IrqStatus)
|
---|
3242 | {
|
---|
3243 | LogFunc(("Trigger interrupt with status %#x\n", u32IrqStatus));
|
---|
3244 | ASMAtomicOrU32(&pThis->svga.u32IrqStatus, u32IrqStatus);
|
---|
3245 | PDMDevHlpPCISetIrq(pDevIns, 0, 1);
|
---|
3246 | }
|
---|
3247 |
|
---|
3248 | PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect);
|
---|
3249 | }
|
---|
3250 |
|
---|
3251 |
|
---|
3252 | /** Allocate a command buffer structure.
|
---|
3253 | *
|
---|
3254 | * @param pCmdBufCtx The command buffer context which must allocate the buffer.
|
---|
3255 | * @return Pointer to the allocated command buffer structure.
|
---|
3256 | */
|
---|
3257 | static PVMSVGACMDBUF vmsvgaR3CmdBufAlloc(PVMSVGACMDBUFCTX pCmdBufCtx)
|
---|
3258 | {
|
---|
3259 | if (!pCmdBufCtx)
|
---|
3260 | return NULL;
|
---|
3261 |
|
---|
3262 | PVMSVGACMDBUF pCmdBuf = (PVMSVGACMDBUF)RTMemAllocZ(sizeof(*pCmdBuf));
|
---|
3263 | if (pCmdBuf)
|
---|
3264 | {
|
---|
3265 | // RT_ZERO(pCmdBuf->nodeBuffer);
|
---|
3266 | pCmdBuf->pCmdBufCtx = pCmdBufCtx;
|
---|
3267 | // pCmdBuf->GCPhysCB = 0;
|
---|
3268 | // RT_ZERO(pCmdBuf->hdr);
|
---|
3269 | // pCmdBuf->pvCommands = NULL;
|
---|
3270 | }
|
---|
3271 |
|
---|
3272 | return pCmdBuf;
|
---|
3273 | }
|
---|
3274 |
|
---|
3275 |
|
---|
3276 | /** Free a command buffer structure.
|
---|
3277 | *
|
---|
3278 | * @param pCmdBuf The command buffer pointer.
|
---|
3279 | */
|
---|
3280 | static void vmsvgaR3CmdBufFree(PVMSVGACMDBUF pCmdBuf)
|
---|
3281 | {
|
---|
3282 | if (pCmdBuf)
|
---|
3283 | RTMemFree(pCmdBuf->pvCommands);
|
---|
3284 | RTMemFree(pCmdBuf);
|
---|
3285 | }
|
---|
3286 |
|
---|
3287 |
|
---|
3288 | /** Initialize a command buffer context.
|
---|
3289 | *
|
---|
3290 | * @param pCmdBufCtx The command buffer context.
|
---|
3291 | */
|
---|
3292 | static void vmsvgaR3CmdBufCtxInit(PVMSVGACMDBUFCTX pCmdBufCtx)
|
---|
3293 | {
|
---|
3294 | RTListInit(&pCmdBufCtx->listSubmitted);
|
---|
3295 | pCmdBufCtx->cSubmitted = 0;
|
---|
3296 | }
|
---|
3297 |
|
---|
3298 |
|
---|
3299 | /** Destroy a command buffer context.
|
---|
3300 | *
|
---|
3301 | * @param pCmdBufCtx The command buffer context pointer.
|
---|
3302 | */
|
---|
3303 | static void vmsvgaR3CmdBufCtxTerm(PVMSVGACMDBUFCTX pCmdBufCtx)
|
---|
3304 | {
|
---|
3305 | if (!pCmdBufCtx)
|
---|
3306 | return;
|
---|
3307 |
|
---|
3308 | if (pCmdBufCtx->listSubmitted.pNext)
|
---|
3309 | {
|
---|
3310 | /* If the list has been initialized. */
|
---|
3311 | PVMSVGACMDBUF pIter, pNext;
|
---|
3312 | RTListForEachSafe(&pCmdBufCtx->listSubmitted, pIter, pNext, VMSVGACMDBUF, nodeBuffer)
|
---|
3313 | {
|
---|
3314 | RTListNodeRemove(&pIter->nodeBuffer);
|
---|
3315 | --pCmdBufCtx->cSubmitted;
|
---|
3316 | vmsvgaR3CmdBufFree(pIter);
|
---|
3317 | }
|
---|
3318 | }
|
---|
3319 | Assert(pCmdBufCtx->cSubmitted == 0);
|
---|
3320 | pCmdBufCtx->cSubmitted = 0;
|
---|
3321 | }
|
---|
3322 |
|
---|
3323 |
|
---|
3324 | /** Handles SVGA_DC_CMD_START_STOP_CONTEXT command.
|
---|
3325 | *
|
---|
3326 | * @param pSvgaR3State VMSVGA R3 state.
|
---|
3327 | * @param pCmd The command data.
|
---|
3328 | * @return SVGACBStatus code.
|
---|
3329 | * @thread EMT
|
---|
3330 | */
|
---|
3331 | static SVGACBStatus vmsvgaR3CmdBufDCStartStop(PVMSVGAR3STATE pSvgaR3State, SVGADCCmdStartStop const *pCmd)
|
---|
3332 | {
|
---|
3333 | /* Create or destroy a regular command buffer context. */
|
---|
3334 | if (pCmd->context >= RT_ELEMENTS(pSvgaR3State->apCmdBufCtxs))
|
---|
3335 | return SVGA_CB_STATUS_COMMAND_ERROR;
|
---|
3336 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
3337 |
|
---|
3338 | SVGACBStatus CBStatus = SVGA_CB_STATUS_COMPLETED;
|
---|
3339 |
|
---|
3340 | int rc = RTCritSectEnter(&pSvgaR3State->CritSectCmdBuf);
|
---|
3341 | AssertRC(rc);
|
---|
3342 | if (pCmd->enable)
|
---|
3343 | {
|
---|
3344 | pSvgaR3State->apCmdBufCtxs[pCmd->context] = (PVMSVGACMDBUFCTX)RTMemAlloc(sizeof(VMSVGACMDBUFCTX));
|
---|
3345 | if (pSvgaR3State->apCmdBufCtxs[pCmd->context])
|
---|
3346 | vmsvgaR3CmdBufCtxInit(pSvgaR3State->apCmdBufCtxs[pCmd->context]);
|
---|
3347 | else
|
---|
3348 | CBStatus = SVGA_CB_STATUS_QUEUE_FULL;
|
---|
3349 | }
|
---|
3350 | else
|
---|
3351 | {
|
---|
3352 | vmsvgaR3CmdBufCtxTerm(pSvgaR3State->apCmdBufCtxs[pCmd->context]);
|
---|
3353 | RTMemFree(pSvgaR3State->apCmdBufCtxs[pCmd->context]);
|
---|
3354 | pSvgaR3State->apCmdBufCtxs[pCmd->context] = NULL;
|
---|
3355 | }
|
---|
3356 | RTCritSectLeave(&pSvgaR3State->CritSectCmdBuf);
|
---|
3357 |
|
---|
3358 | return CBStatus;
|
---|
3359 | }
|
---|
3360 |
|
---|
3361 |
|
---|
3362 | /** Handles SVGA_DC_CMD_PREEMPT command.
|
---|
3363 | *
|
---|
3364 | * @param pDevIns The device instance.
|
---|
3365 | * @param pSvgaR3State VMSVGA R3 state.
|
---|
3366 | * @param pCmd The command data.
|
---|
3367 | * @return SVGACBStatus code.
|
---|
3368 | * @thread EMT
|
---|
3369 | */
|
---|
3370 | static SVGACBStatus vmsvgaR3CmdBufDCPreempt(PPDMDEVINS pDevIns, PVMSVGAR3STATE pSvgaR3State, SVGADCCmdPreempt const *pCmd)
|
---|
3371 | {
|
---|
3372 | /* Remove buffers from the processing queue of the specified context. */
|
---|
3373 | if (pCmd->context >= RT_ELEMENTS(pSvgaR3State->apCmdBufCtxs))
|
---|
3374 | return SVGA_CB_STATUS_COMMAND_ERROR;
|
---|
3375 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
3376 |
|
---|
3377 | PVMSVGACMDBUFCTX const pCmdBufCtx = pSvgaR3State->apCmdBufCtxs[pCmd->context];
|
---|
3378 | RTLISTANCHOR listPreempted;
|
---|
3379 |
|
---|
3380 | int rc = RTCritSectEnter(&pSvgaR3State->CritSectCmdBuf);
|
---|
3381 | AssertRC(rc);
|
---|
3382 | if (pCmd->ignoreIDZero)
|
---|
3383 | {
|
---|
3384 | RTListInit(&listPreempted);
|
---|
3385 |
|
---|
3386 | PVMSVGACMDBUF pIter, pNext;
|
---|
3387 | RTListForEachSafe(&pCmdBufCtx->listSubmitted, pIter, pNext, VMSVGACMDBUF, nodeBuffer)
|
---|
3388 | {
|
---|
3389 | if (pIter->hdr.id == 0)
|
---|
3390 | continue;
|
---|
3391 |
|
---|
3392 | RTListNodeRemove(&pIter->nodeBuffer);
|
---|
3393 | --pCmdBufCtx->cSubmitted;
|
---|
3394 | RTListAppend(&listPreempted, &pIter->nodeBuffer);
|
---|
3395 | }
|
---|
3396 | }
|
---|
3397 | else
|
---|
3398 | {
|
---|
3399 | RTListMove(&listPreempted, &pCmdBufCtx->listSubmitted);
|
---|
3400 | pCmdBufCtx->cSubmitted = 0;
|
---|
3401 | }
|
---|
3402 | RTCritSectLeave(&pSvgaR3State->CritSectCmdBuf);
|
---|
3403 |
|
---|
3404 | PVMSVGACMDBUF pIter, pNext;
|
---|
3405 | RTListForEachSafe(&listPreempted, pIter, pNext, VMSVGACMDBUF, nodeBuffer)
|
---|
3406 | {
|
---|
3407 | RTListNodeRemove(&pIter->nodeBuffer);
|
---|
3408 | vmsvgaR3CmdBufWriteStatus(pDevIns, pIter->GCPhysCB, SVGA_CB_STATUS_PREEMPTED, 0);
|
---|
3409 | LogFunc(("Preempted %RX64\n", pIter->GCPhysCB));
|
---|
3410 | vmsvgaR3CmdBufFree(pIter);
|
---|
3411 | }
|
---|
3412 |
|
---|
3413 | return SVGA_CB_STATUS_COMPLETED;
|
---|
3414 | }
|
---|
3415 |
|
---|
3416 |
|
---|
3417 | /** @def VMSVGA_INC_CMD_SIZE_BREAK
|
---|
3418 | * Increments the size of the command cbCmd by a_cbMore.
|
---|
3419 | * Checks that the command buffer has at least cbCmd bytes. Will break out of the switch if it doesn't.
|
---|
3420 | * Used by vmsvgaR3CmdBufProcessDC and vmsvgaR3CmdBufProcessCommands.
|
---|
3421 | */
|
---|
3422 | #define VMSVGA_INC_CMD_SIZE_BREAK(a_cbMore) \
|
---|
3423 | if (1) { \
|
---|
3424 | cbCmd += (a_cbMore); \
|
---|
3425 | ASSERT_GUEST_MSG_STMT_BREAK(cbRemain >= cbCmd, ("size=%#x remain=%#zx\n", cbCmd, (size_t)cbRemain), CBstatus = SVGA_CB_STATUS_COMMAND_ERROR); \
|
---|
3426 | RT_UNTRUSTED_VALIDATED_FENCE(); \
|
---|
3427 | } else do {} while (0)
|
---|
3428 |
|
---|
3429 |
|
---|
3430 | /** Processes Device Context command buffer.
|
---|
3431 | *
|
---|
3432 | * @param pDevIns The device instance.
|
---|
3433 | * @param pSvgaR3State VMSVGA R3 state.
|
---|
3434 | * @param pvCommands Pointer to the command buffer.
|
---|
3435 | * @param cbCommands Size of the command buffer.
|
---|
3436 | * @param poffNextCmd Where to store the offset of the first unprocessed command.
|
---|
3437 | * @return SVGACBStatus code.
|
---|
3438 | * @thread EMT
|
---|
3439 | */
|
---|
3440 | static SVGACBStatus vmsvgaR3CmdBufProcessDC(PPDMDEVINS pDevIns, PVMSVGAR3STATE pSvgaR3State, void const *pvCommands, uint32_t cbCommands, uint32_t *poffNextCmd)
|
---|
3441 | {
|
---|
3442 | SVGACBStatus CBstatus = SVGA_CB_STATUS_COMPLETED;
|
---|
3443 |
|
---|
3444 | uint8_t const *pu8Cmd = (uint8_t *)pvCommands;
|
---|
3445 | uint32_t cbRemain = cbCommands;
|
---|
3446 | while (cbRemain)
|
---|
3447 | {
|
---|
3448 | /* Command identifier is a 32 bit value. */
|
---|
3449 | if (cbRemain < sizeof(uint32_t))
|
---|
3450 | {
|
---|
3451 | CBstatus = SVGA_CB_STATUS_COMMAND_ERROR;
|
---|
3452 | break;
|
---|
3453 | }
|
---|
3454 |
|
---|
3455 | /* Fetch the command id. */
|
---|
3456 | uint32_t const cmdId = *(uint32_t *)pu8Cmd;
|
---|
3457 | uint32_t cbCmd = sizeof(uint32_t);
|
---|
3458 | switch (cmdId)
|
---|
3459 | {
|
---|
3460 | case SVGA_DC_CMD_NOP:
|
---|
3461 | {
|
---|
3462 | /* NOP */
|
---|
3463 | break;
|
---|
3464 | }
|
---|
3465 |
|
---|
3466 | case SVGA_DC_CMD_START_STOP_CONTEXT:
|
---|
3467 | {
|
---|
3468 | SVGADCCmdStartStop *pCmd = (SVGADCCmdStartStop *)&pu8Cmd[cbCmd];
|
---|
3469 | VMSVGA_INC_CMD_SIZE_BREAK(sizeof(*pCmd));
|
---|
3470 | CBstatus = vmsvgaR3CmdBufDCStartStop(pSvgaR3State, pCmd);
|
---|
3471 | break;
|
---|
3472 | }
|
---|
3473 |
|
---|
3474 | case SVGA_DC_CMD_PREEMPT:
|
---|
3475 | {
|
---|
3476 | SVGADCCmdPreempt *pCmd = (SVGADCCmdPreempt *)&pu8Cmd[cbCmd];
|
---|
3477 | VMSVGA_INC_CMD_SIZE_BREAK(sizeof(*pCmd));
|
---|
3478 | CBstatus = vmsvgaR3CmdBufDCPreempt(pDevIns, pSvgaR3State, pCmd);
|
---|
3479 | break;
|
---|
3480 | }
|
---|
3481 |
|
---|
3482 | default:
|
---|
3483 | {
|
---|
3484 | /* Unsupported command. */
|
---|
3485 | CBstatus = SVGA_CB_STATUS_COMMAND_ERROR;
|
---|
3486 | break;
|
---|
3487 | }
|
---|
3488 | }
|
---|
3489 |
|
---|
3490 | if (CBstatus != SVGA_CB_STATUS_COMPLETED)
|
---|
3491 | break;
|
---|
3492 |
|
---|
3493 | pu8Cmd += cbCmd;
|
---|
3494 | cbRemain -= cbCmd;
|
---|
3495 | }
|
---|
3496 |
|
---|
3497 | Assert(cbRemain <= cbCommands);
|
---|
3498 | *poffNextCmd = cbCommands - cbRemain;
|
---|
3499 | return CBstatus;
|
---|
3500 | }
|
---|
3501 |
|
---|
3502 |
|
---|
3503 | /** Submits a device context command buffer for synchronous processing.
|
---|
3504 | *
|
---|
3505 | * @param pDevIns The device instance.
|
---|
3506 | * @param pThisCC The VGA/VMSVGA state for the current context.
|
---|
3507 | * @param ppCmdBuf Pointer to the command buffer pointer.
|
---|
3508 | * The function can set the command buffer pointer to NULL to prevent deallocation by the caller.
|
---|
3509 | * @param poffNextCmd Where to store the offset of the first unprocessed command.
|
---|
3510 | * @return SVGACBStatus code.
|
---|
3511 | * @thread EMT
|
---|
3512 | */
|
---|
3513 | static SVGACBStatus vmsvgaR3CmdBufSubmitDC(PPDMDEVINS pDevIns, PVGASTATECC pThisCC, PVMSVGACMDBUF *ppCmdBuf, uint32_t *poffNextCmd)
|
---|
3514 | {
|
---|
3515 | /* Synchronously process the device context commands. */
|
---|
3516 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
3517 | return vmsvgaR3CmdBufProcessDC(pDevIns, pSvgaR3State, (*ppCmdBuf)->pvCommands, (*ppCmdBuf)->hdr.length, poffNextCmd);
|
---|
3518 | }
|
---|
3519 |
|
---|
3520 | /** Submits a command buffer for asynchronous processing by the FIFO thread.
|
---|
3521 | *
|
---|
3522 | * @param pDevIns The device instance.
|
---|
3523 | * @param pThis The shared VGA/VMSVGA state.
|
---|
3524 | * @param pThisCC The VGA/VMSVGA state for the current context.
|
---|
3525 | * @param ppCmdBuf Pointer to the command buffer pointer.
|
---|
3526 | * The function can set the command buffer pointer to NULL to prevent deallocation by the caller.
|
---|
3527 | * @return SVGACBStatus code.
|
---|
3528 | * @thread EMT
|
---|
3529 | */
|
---|
3530 | static SVGACBStatus vmsvgaR3CmdBufSubmitCtx(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC, PVMSVGACMDBUF *ppCmdBuf)
|
---|
3531 | {
|
---|
3532 | /* Command buffer submission. */
|
---|
3533 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
3534 |
|
---|
3535 | SVGACBStatus CBstatus = SVGA_CB_STATUS_NONE;
|
---|
3536 |
|
---|
3537 | PVMSVGACMDBUF const pCmdBuf = *ppCmdBuf;
|
---|
3538 | PVMSVGACMDBUFCTX const pCmdBufCtx = pCmdBuf->pCmdBufCtx;
|
---|
3539 |
|
---|
3540 | int rc = RTCritSectEnter(&pSvgaR3State->CritSectCmdBuf);
|
---|
3541 | AssertRC(rc);
|
---|
3542 |
|
---|
3543 | if (RT_LIKELY(pCmdBufCtx->cSubmitted < SVGA_CB_MAX_QUEUED_PER_CONTEXT))
|
---|
3544 | {
|
---|
3545 | RTListAppend(&pCmdBufCtx->listSubmitted, &pCmdBuf->nodeBuffer);
|
---|
3546 | ++pCmdBufCtx->cSubmitted;
|
---|
3547 | *ppCmdBuf = NULL; /* Consume the buffer. */
|
---|
3548 | ASMAtomicWriteU32(&pThisCC->svga.pSvgaR3State->fCmdBuf, 1);
|
---|
3549 | }
|
---|
3550 | else
|
---|
3551 | CBstatus = SVGA_CB_STATUS_QUEUE_FULL;
|
---|
3552 |
|
---|
3553 | RTCritSectLeave(&pSvgaR3State->CritSectCmdBuf);
|
---|
3554 |
|
---|
3555 | /* Inform the FIFO thread. */
|
---|
3556 | if (*ppCmdBuf == NULL)
|
---|
3557 | PDMDevHlpSUPSemEventSignal(pDevIns, pThis->svga.hFIFORequestSem);
|
---|
3558 |
|
---|
3559 | return CBstatus;
|
---|
3560 | }
|
---|
3561 |
|
---|
3562 |
|
---|
3563 | /** SVGA_REG_COMMAND_LOW write handler.
|
---|
3564 | * Submits a command buffer to the FIFO thread or processes a device context command.
|
---|
3565 | *
|
---|
3566 | * @param pDevIns The device instance.
|
---|
3567 | * @param pThis The shared VGA/VMSVGA state.
|
---|
3568 | * @param pThisCC The VGA/VMSVGA state for the current context.
|
---|
3569 | * @param GCPhysCB Guest physical address of the command buffer header.
|
---|
3570 | * @param CBCtx Context the command buffer is submitted to.
|
---|
3571 | * @thread EMT
|
---|
3572 | */
|
---|
3573 | static void vmsvgaR3CmdBufSubmit(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC, RTGCPHYS GCPhysCB, SVGACBContext CBCtx)
|
---|
3574 | {
|
---|
3575 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
3576 |
|
---|
3577 | SVGACBStatus CBstatus = SVGA_CB_STATUS_NONE;
|
---|
3578 | uint32_t offNextCmd = 0;
|
---|
3579 | uint32_t fIRQ = 0;
|
---|
3580 |
|
---|
3581 | /* Get the context if the device has the capability. */
|
---|
3582 | PVMSVGACMDBUFCTX pCmdBufCtx = NULL;
|
---|
3583 | if (pThis->svga.u32DeviceCaps & SVGA_CAP_COMMAND_BUFFERS)
|
---|
3584 | {
|
---|
3585 | if (RT_LIKELY(CBCtx < RT_ELEMENTS(pSvgaR3State->apCmdBufCtxs)))
|
---|
3586 | pCmdBufCtx = pSvgaR3State->apCmdBufCtxs[CBCtx];
|
---|
3587 | else if (CBCtx == SVGA_CB_CONTEXT_DEVICE)
|
---|
3588 | pCmdBufCtx = &pSvgaR3State->CmdBufCtxDC;
|
---|
3589 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
3590 | }
|
---|
3591 |
|
---|
3592 | /* Allocate a new command buffer. */
|
---|
3593 | PVMSVGACMDBUF pCmdBuf = vmsvgaR3CmdBufAlloc(pCmdBufCtx);
|
---|
3594 | if (RT_LIKELY(pCmdBuf))
|
---|
3595 | {
|
---|
3596 | pCmdBuf->GCPhysCB = GCPhysCB;
|
---|
3597 |
|
---|
3598 | int rc = PDMDevHlpPCIPhysRead(pDevIns, GCPhysCB, &pCmdBuf->hdr, sizeof(pCmdBuf->hdr));
|
---|
3599 | if (RT_SUCCESS(rc))
|
---|
3600 | {
|
---|
3601 | LogFunc(("status %RX32 errorOffset %RX32 id %RX64 flags %RX32 length %RX32 ptr %RX64 offset %RX32 dxContext %RX32 (%RX32 %RX32 %RX32 %RX32 %RX32 %RX32)\n",
|
---|
3602 | pCmdBuf->hdr.status,
|
---|
3603 | pCmdBuf->hdr.errorOffset,
|
---|
3604 | pCmdBuf->hdr.id,
|
---|
3605 | pCmdBuf->hdr.flags,
|
---|
3606 | pCmdBuf->hdr.length,
|
---|
3607 | pCmdBuf->hdr.ptr.pa,
|
---|
3608 | pCmdBuf->hdr.offset,
|
---|
3609 | pCmdBuf->hdr.dxContext,
|
---|
3610 | pCmdBuf->hdr.mustBeZero[0],
|
---|
3611 | pCmdBuf->hdr.mustBeZero[1],
|
---|
3612 | pCmdBuf->hdr.mustBeZero[2],
|
---|
3613 | pCmdBuf->hdr.mustBeZero[3],
|
---|
3614 | pCmdBuf->hdr.mustBeZero[4],
|
---|
3615 | pCmdBuf->hdr.mustBeZero[5]));
|
---|
3616 |
|
---|
3617 | /* Verify the command buffer header. */
|
---|
3618 | if (RT_LIKELY( pCmdBuf->hdr.status == SVGA_CB_STATUS_NONE
|
---|
3619 | && (pCmdBuf->hdr.flags & ~(SVGA_CB_FLAG_NO_IRQ | SVGA_CB_FLAG_DX_CONTEXT)) == 0 /* No unexpected flags. */
|
---|
3620 | && pCmdBuf->hdr.length <= SVGA_CB_MAX_SIZE))
|
---|
3621 | {
|
---|
3622 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
3623 |
|
---|
3624 | /* Read the command buffer content. */
|
---|
3625 | pCmdBuf->pvCommands = RTMemAlloc(pCmdBuf->hdr.length);
|
---|
3626 | if (pCmdBuf->pvCommands)
|
---|
3627 | {
|
---|
3628 | RTGCPHYS const GCPhysCmd = (RTGCPHYS)pCmdBuf->hdr.ptr.pa;
|
---|
3629 | rc = PDMDevHlpPCIPhysRead(pDevIns, GCPhysCmd, pCmdBuf->pvCommands, pCmdBuf->hdr.length);
|
---|
3630 | if (RT_SUCCESS(rc))
|
---|
3631 | {
|
---|
3632 | /* Submit the buffer. Device context buffers will be processed synchronously. */
|
---|
3633 | if (RT_LIKELY(CBCtx < RT_ELEMENTS(pSvgaR3State->apCmdBufCtxs)))
|
---|
3634 | /* This usually processes the CB async and sets pCmbBuf to NULL. */
|
---|
3635 | CBstatus = vmsvgaR3CmdBufSubmitCtx(pDevIns, pThis, pThisCC, &pCmdBuf);
|
---|
3636 | else
|
---|
3637 | CBstatus = vmsvgaR3CmdBufSubmitDC(pDevIns, pThisCC, &pCmdBuf, &offNextCmd);
|
---|
3638 | }
|
---|
3639 | else
|
---|
3640 | {
|
---|
3641 | ASSERT_GUEST_MSG_FAILED(("Failed to read commands at %RGp\n", GCPhysCmd));
|
---|
3642 | CBstatus = SVGA_CB_STATUS_CB_HEADER_ERROR;
|
---|
3643 | fIRQ = SVGA_IRQFLAG_ERROR | SVGA_IRQFLAG_COMMAND_BUFFER;
|
---|
3644 | }
|
---|
3645 | }
|
---|
3646 | else
|
---|
3647 | {
|
---|
3648 | /* No memory for commands. */
|
---|
3649 | CBstatus = SVGA_CB_STATUS_QUEUE_FULL;
|
---|
3650 | }
|
---|
3651 | }
|
---|
3652 | else
|
---|
3653 | {
|
---|
3654 | ASSERT_GUEST_MSG_FAILED(("Invalid buffer header\n"));
|
---|
3655 | CBstatus = SVGA_CB_STATUS_CB_HEADER_ERROR;
|
---|
3656 | fIRQ = SVGA_IRQFLAG_ERROR | SVGA_IRQFLAG_COMMAND_BUFFER;
|
---|
3657 | }
|
---|
3658 | }
|
---|
3659 | else
|
---|
3660 | {
|
---|
3661 | LogFunc(("Failed to read buffer header at %RGp\n", GCPhysCB));
|
---|
3662 | ASSERT_GUEST_FAILED();
|
---|
3663 | /* Do not attempt to write the status. */
|
---|
3664 | }
|
---|
3665 |
|
---|
3666 | /* Free the buffer if pfnCmdBufSubmit did not consume it. */
|
---|
3667 | vmsvgaR3CmdBufFree(pCmdBuf);
|
---|
3668 | }
|
---|
3669 | else
|
---|
3670 | {
|
---|
3671 | LogFunc(("Can't allocate buffer for context id %#x\n", CBCtx));
|
---|
3672 | AssertFailed();
|
---|
3673 | CBstatus = SVGA_CB_STATUS_QUEUE_FULL;
|
---|
3674 | }
|
---|
3675 |
|
---|
3676 | if (CBstatus != SVGA_CB_STATUS_NONE)
|
---|
3677 | {
|
---|
3678 | LogFunc(("Write status %#x, offNextCmd %#x, fIRQ %#x\n", CBstatus, offNextCmd, fIRQ));
|
---|
3679 | vmsvgaR3CmdBufWriteStatus(pDevIns, GCPhysCB, CBstatus, offNextCmd);
|
---|
3680 | if (fIRQ)
|
---|
3681 | vmsvgaR3CmdBufRaiseIRQ(pDevIns, pThis, fIRQ);
|
---|
3682 | }
|
---|
3683 | }
|
---|
3684 |
|
---|
3685 |
|
---|
3686 | /** Checks if there are some buffers to be processed.
|
---|
3687 | *
|
---|
3688 | * @param pThisCC The VGA/VMSVGA state for the current context.
|
---|
3689 | * @return true if buffers must be processed.
|
---|
3690 | * @thread FIFO
|
---|
3691 | */
|
---|
3692 | static bool vmsvgaR3CmdBufHasWork(PVGASTATECC pThisCC)
|
---|
3693 | {
|
---|
3694 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
3695 | return RT_BOOL(ASMAtomicReadU32(&pSvgaR3State->fCmdBuf));
|
---|
3696 | }
|
---|
3697 |
|
---|
3698 |
|
---|
3699 | /** Processes a command buffer.
|
---|
3700 | *
|
---|
3701 | * @param pDevIns The device instance.
|
---|
3702 | * @param pThis The shared VGA/VMSVGA state.
|
---|
3703 | * @param pThisCC The VGA/VMSVGA state for the current context.
|
---|
3704 | * @param idDXContext VGPU10 DX context of the commands or SVGA3D_INVALID_ID if they are not for a specific context.
|
---|
3705 | * @param pvCommands Pointer to the command buffer.
|
---|
3706 | * @param cbCommands Size of the command buffer.
|
---|
3707 | * @param poffNextCmd Where to store the offset of the first unprocessed command.
|
---|
3708 | * @param pu32IrqStatus Where to store SVGA_IRQFLAG_ if the IRQ is generated by the last command in the buffer.
|
---|
3709 | * @return SVGACBStatus code.
|
---|
3710 | * @thread FIFO
|
---|
3711 | */
|
---|
3712 | static SVGACBStatus vmsvgaR3CmdBufProcessCommands(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC, uint32_t idDXContext, void const *pvCommands, uint32_t cbCommands, uint32_t *poffNextCmd, uint32_t *pu32IrqStatus)
|
---|
3713 | {
|
---|
3714 | # ifndef VBOX_WITH_VMSVGA3D
|
---|
3715 | RT_NOREF(idDXContext);
|
---|
3716 | # endif
|
---|
3717 | SVGACBStatus CBstatus = SVGA_CB_STATUS_COMPLETED;
|
---|
3718 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
3719 |
|
---|
3720 | # ifdef VBOX_WITH_VMSVGA3D
|
---|
3721 | # ifdef VMSVGA3D_DX
|
---|
3722 | /* Commands submitted for the SVGA3D_INVALID_ID context do not affect pipeline. So ignore them. */
|
---|
3723 | if (idDXContext != SVGA3D_INVALID_ID)
|
---|
3724 | {
|
---|
3725 | if (pSvgaR3State->idDXContextCurrent != idDXContext)
|
---|
3726 | {
|
---|
3727 | LogFlow(("DXCTX: buffer %d->%d\n", pSvgaR3State->idDXContextCurrent, idDXContext));
|
---|
3728 | vmsvga3dDXSwitchContext(pThisCC, idDXContext);
|
---|
3729 | pSvgaR3State->idDXContextCurrent = idDXContext;
|
---|
3730 | }
|
---|
3731 | }
|
---|
3732 | # endif
|
---|
3733 | # endif
|
---|
3734 |
|
---|
3735 | uint32_t RT_UNTRUSTED_VOLATILE_GUEST * const pFIFO = pThisCC->svga.pau32FIFO;
|
---|
3736 |
|
---|
3737 | uint8_t const *pu8Cmd = (uint8_t *)pvCommands;
|
---|
3738 | uint32_t cbRemain = cbCommands;
|
---|
3739 | while (cbRemain)
|
---|
3740 | {
|
---|
3741 | /* Command identifier is a 32 bit value. */
|
---|
3742 | if (cbRemain < sizeof(uint32_t))
|
---|
3743 | {
|
---|
3744 | CBstatus = SVGA_CB_STATUS_COMMAND_ERROR;
|
---|
3745 | break;
|
---|
3746 | }
|
---|
3747 |
|
---|
3748 | /* Fetch the command id.
|
---|
3749 | * 'cmdId' is actually a SVGAFifoCmdId. It is treated as uint32_t in order to avoid a compiler
|
---|
3750 | * warning. Because we support some obsolete and deprecated commands, which are not included in
|
---|
3751 | * the SVGAFifoCmdId enum in the VMSVGA headers anymore.
|
---|
3752 | */
|
---|
3753 | uint32_t const cmdId = *(uint32_t *)pu8Cmd;
|
---|
3754 | uint32_t cbCmd = sizeof(uint32_t);
|
---|
3755 |
|
---|
3756 | LogFunc(("[cid=%d] %s %d\n", (int32_t)idDXContext, vmsvgaR3FifoCmdToString(cmdId), cmdId));
|
---|
3757 | # ifdef LOG_ENABLED
|
---|
3758 | # ifdef VBOX_WITH_VMSVGA3D
|
---|
3759 | if ( (cmdId >= SVGA_3D_CMD_BASE && cmdId < SVGA_3D_CMD_MAX)
|
---|
3760 | || (cmdId >= VBSVGA_3D_CMD_BASE && cmdId < VBSVGA_3D_CMD_MAX))
|
---|
3761 | {
|
---|
3762 | SVGA3dCmdHeader const *header = (SVGA3dCmdHeader *)pu8Cmd;
|
---|
3763 | svga_dump_command(cmdId, (uint8_t *)&header[1], header->size);
|
---|
3764 | }
|
---|
3765 | else if (cmdId == SVGA_CMD_FENCE)
|
---|
3766 | {
|
---|
3767 | Log7(("\tSVGA_CMD_FENCE\n"));
|
---|
3768 | Log7(("\t\t0x%08x\n", ((uint32_t *)pu8Cmd)[1]));
|
---|
3769 | }
|
---|
3770 | # endif
|
---|
3771 | # endif
|
---|
3772 |
|
---|
3773 | /* At the end of the switch cbCmd is equal to the total length of the command including the cmdId.
|
---|
3774 | * I.e. pu8Cmd + cbCmd must point to the next command.
|
---|
3775 | * However if CBstatus is set to anything but SVGA_CB_STATUS_COMPLETED in the switch, then
|
---|
3776 | * the cbCmd value is ignored (and pu8Cmd still points to the failed command).
|
---|
3777 | */
|
---|
3778 | /** @todo This code is very similar to the FIFO loop command processing. Think about merging. */
|
---|
3779 | LogFlow(("cmdId=%u\n", cmdId));
|
---|
3780 | switch (cmdId)
|
---|
3781 | {
|
---|
3782 | case SVGA_CMD_INVALID_CMD:
|
---|
3783 | {
|
---|
3784 | /* Nothing to do. */
|
---|
3785 | STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3CmdInvalidCmd);
|
---|
3786 | break;
|
---|
3787 | }
|
---|
3788 |
|
---|
3789 | case SVGA_CMD_FENCE:
|
---|
3790 | {
|
---|
3791 | SVGAFifoCmdFence *pCmd = (SVGAFifoCmdFence *)&pu8Cmd[cbCmd];
|
---|
3792 | VMSVGA_INC_CMD_SIZE_BREAK(sizeof(*pCmd));
|
---|
3793 | STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3CmdFence);
|
---|
3794 | Log(("SVGA_CMD_FENCE %#x\n", pCmd->fence));
|
---|
3795 |
|
---|
3796 | if (pThis->fVmSvga3)
|
---|
3797 | {
|
---|
3798 | pThis->svga.u32FenceLast = pCmd->fence;
|
---|
3799 |
|
---|
3800 | if (pThis->svga.u32IrqMask & SVGA_IRQFLAG_ANY_FENCE)
|
---|
3801 | {
|
---|
3802 | Log(("any fence irq\n"));
|
---|
3803 | *pu32IrqStatus |= SVGA_IRQFLAG_ANY_FENCE;
|
---|
3804 | }
|
---|
3805 | else if (pThis->svga.u32IrqMask & SVGA_IRQFLAG_FENCE_GOAL)
|
---|
3806 | {
|
---|
3807 | Log(("fence goal reached irq (fence=%#x)\n", pCmd->fence));
|
---|
3808 | *pu32IrqStatus |= SVGA_IRQFLAG_FENCE_GOAL;
|
---|
3809 | }
|
---|
3810 | }
|
---|
3811 | else
|
---|
3812 | {
|
---|
3813 | uint32_t const offFifoMin = pFIFO[SVGA_FIFO_MIN];
|
---|
3814 | if (VMSVGA_IS_VALID_FIFO_REG(SVGA_FIFO_FENCE, offFifoMin))
|
---|
3815 | {
|
---|
3816 | pFIFO[SVGA_FIFO_FENCE] = pCmd->fence;
|
---|
3817 |
|
---|
3818 | if (pThis->svga.u32IrqMask & SVGA_IRQFLAG_ANY_FENCE)
|
---|
3819 | {
|
---|
3820 | Log(("any fence irq\n"));
|
---|
3821 | *pu32IrqStatus |= SVGA_IRQFLAG_ANY_FENCE;
|
---|
3822 | }
|
---|
3823 | else if ( VMSVGA_IS_VALID_FIFO_REG(SVGA_FIFO_FENCE_GOAL, offFifoMin)
|
---|
3824 | && (pThis->svga.u32IrqMask & SVGA_IRQFLAG_FENCE_GOAL)
|
---|
3825 | && pFIFO[SVGA_FIFO_FENCE_GOAL] == pCmd->fence)
|
---|
3826 | {
|
---|
3827 | Log(("fence goal reached irq (fence=%#x)\n", pCmd->fence));
|
---|
3828 | *pu32IrqStatus |= SVGA_IRQFLAG_FENCE_GOAL;
|
---|
3829 | }
|
---|
3830 | }
|
---|
3831 | else
|
---|
3832 | Log(("SVGA_CMD_FENCE is bogus when offFifoMin is %#x!\n", offFifoMin));
|
---|
3833 | }
|
---|
3834 | break;
|
---|
3835 | }
|
---|
3836 |
|
---|
3837 | case SVGA_CMD_UPDATE:
|
---|
3838 | {
|
---|
3839 | SVGAFifoCmdUpdate *pCmd = (SVGAFifoCmdUpdate *)&pu8Cmd[cbCmd];
|
---|
3840 | VMSVGA_INC_CMD_SIZE_BREAK(sizeof(*pCmd));
|
---|
3841 | vmsvgaR3CmdUpdate(pThis, pThisCC, pCmd);
|
---|
3842 | break;
|
---|
3843 | }
|
---|
3844 |
|
---|
3845 | case SVGA_CMD_UPDATE_VERBOSE:
|
---|
3846 | {
|
---|
3847 | SVGAFifoCmdUpdateVerbose *pCmd = (SVGAFifoCmdUpdateVerbose *)&pu8Cmd[cbCmd];
|
---|
3848 | VMSVGA_INC_CMD_SIZE_BREAK(sizeof(*pCmd));
|
---|
3849 | vmsvgaR3CmdUpdateVerbose(pThis, pThisCC, pCmd);
|
---|
3850 | break;
|
---|
3851 | }
|
---|
3852 |
|
---|
3853 | case SVGA_CMD_DEFINE_CURSOR:
|
---|
3854 | {
|
---|
3855 | /* Followed by bitmap data. */
|
---|
3856 | SVGAFifoCmdDefineCursor *pCmd = (SVGAFifoCmdDefineCursor *)&pu8Cmd[cbCmd];
|
---|
3857 | VMSVGA_INC_CMD_SIZE_BREAK(sizeof(*pCmd));
|
---|
3858 |
|
---|
3859 | /* Figure out the size of the bitmap data. */
|
---|
3860 | ASSERT_GUEST_STMT_BREAK(pCmd->height < 2048 && pCmd->width < 2048, CBstatus = SVGA_CB_STATUS_COMMAND_ERROR);
|
---|
3861 | ASSERT_GUEST_STMT_BREAK(pCmd->andMaskDepth <= 32, CBstatus = SVGA_CB_STATUS_COMMAND_ERROR);
|
---|
3862 | ASSERT_GUEST_STMT_BREAK(pCmd->xorMaskDepth <= 32, CBstatus = SVGA_CB_STATUS_COMMAND_ERROR);
|
---|
3863 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
3864 |
|
---|
3865 | uint32_t const cbAndLine = RT_ALIGN_32(pCmd->width * (pCmd->andMaskDepth + (pCmd->andMaskDepth == 15)), 32) / 8;
|
---|
3866 | uint32_t const cbAndMask = cbAndLine * pCmd->height;
|
---|
3867 | uint32_t const cbXorLine = RT_ALIGN_32(pCmd->width * (pCmd->xorMaskDepth + (pCmd->xorMaskDepth == 15)), 32) / 8;
|
---|
3868 | uint32_t const cbXorMask = cbXorLine * pCmd->height;
|
---|
3869 |
|
---|
3870 | VMSVGA_INC_CMD_SIZE_BREAK(cbAndMask + cbXorMask);
|
---|
3871 | vmsvgaR3CmdDefineCursor(pThis, pThisCC, pCmd);
|
---|
3872 | break;
|
---|
3873 | }
|
---|
3874 |
|
---|
3875 | case SVGA_CMD_DEFINE_ALPHA_CURSOR:
|
---|
3876 | {
|
---|
3877 | /* Followed by bitmap data. */
|
---|
3878 | SVGAFifoCmdDefineAlphaCursor *pCmd = (SVGAFifoCmdDefineAlphaCursor *)&pu8Cmd[cbCmd];
|
---|
3879 | VMSVGA_INC_CMD_SIZE_BREAK(sizeof(*pCmd));
|
---|
3880 |
|
---|
3881 | /* Figure out the size of the bitmap data. */
|
---|
3882 | ASSERT_GUEST_STMT_BREAK(pCmd->height < 2048 && pCmd->width < 2048, CBstatus = SVGA_CB_STATUS_COMMAND_ERROR);
|
---|
3883 |
|
---|
3884 | VMSVGA_INC_CMD_SIZE_BREAK(pCmd->width * pCmd->height * sizeof(uint32_t)); /* 32-bit BRGA format */
|
---|
3885 | vmsvgaR3CmdDefineAlphaCursor(pThis, pThisCC, pCmd);
|
---|
3886 | break;
|
---|
3887 | }
|
---|
3888 |
|
---|
3889 | case SVGA_CMD_MOVE_CURSOR:
|
---|
3890 | {
|
---|
3891 | /* Deprecated; there should be no driver which *requires* this command. However, if
|
---|
3892 | * we do ecncounter this command, it might be useful to not get the FIFO completely out of
|
---|
3893 | * alignment.
|
---|
3894 | * May be issued by guest if SVGA_CAP_CURSOR_BYPASS is missing.
|
---|
3895 | */
|
---|
3896 | SVGAFifoCmdMoveCursor *pCmd = (SVGAFifoCmdMoveCursor *)&pu8Cmd[cbCmd];
|
---|
3897 | VMSVGA_INC_CMD_SIZE_BREAK(sizeof(*pCmd));
|
---|
3898 | vmsvgaR3CmdMoveCursor(pThis, pThisCC, pCmd);
|
---|
3899 | break;
|
---|
3900 | }
|
---|
3901 |
|
---|
3902 | case SVGA_CMD_DISPLAY_CURSOR:
|
---|
3903 | {
|
---|
3904 | /* Deprecated; there should be no driver which *requires* this command. However, if
|
---|
3905 | * we do ecncounter this command, it might be useful to not get the FIFO completely out of
|
---|
3906 | * alignment.
|
---|
3907 | * May be issued by guest if SVGA_CAP_CURSOR_BYPASS is missing.
|
---|
3908 | */
|
---|
3909 | SVGAFifoCmdDisplayCursor *pCmd = (SVGAFifoCmdDisplayCursor *)&pu8Cmd[cbCmd];
|
---|
3910 | VMSVGA_INC_CMD_SIZE_BREAK(sizeof(*pCmd));
|
---|
3911 | vmsvgaR3CmdDisplayCursor(pThis, pThisCC, pCmd);
|
---|
3912 | break;
|
---|
3913 | }
|
---|
3914 |
|
---|
3915 | case SVGA_CMD_RECT_FILL:
|
---|
3916 | {
|
---|
3917 | SVGAFifoCmdRectFill *pCmd = (SVGAFifoCmdRectFill *)&pu8Cmd[cbCmd];
|
---|
3918 | VMSVGA_INC_CMD_SIZE_BREAK(sizeof(*pCmd));
|
---|
3919 | vmsvgaR3CmdRectFill(pThis, pThisCC, pCmd);
|
---|
3920 | break;
|
---|
3921 | }
|
---|
3922 |
|
---|
3923 | case SVGA_CMD_RECT_COPY:
|
---|
3924 | {
|
---|
3925 | SVGAFifoCmdRectCopy *pCmd = (SVGAFifoCmdRectCopy *)&pu8Cmd[cbCmd];
|
---|
3926 | VMSVGA_INC_CMD_SIZE_BREAK(sizeof(*pCmd));
|
---|
3927 | vmsvgaR3CmdRectCopy(pThis, pThisCC, pCmd);
|
---|
3928 | break;
|
---|
3929 | }
|
---|
3930 |
|
---|
3931 | case SVGA_CMD_RECT_ROP_COPY:
|
---|
3932 | {
|
---|
3933 | SVGAFifoCmdRectRopCopy *pCmd = (SVGAFifoCmdRectRopCopy *)&pu8Cmd[cbCmd];
|
---|
3934 | VMSVGA_INC_CMD_SIZE_BREAK(sizeof(*pCmd));
|
---|
3935 | vmsvgaR3CmdRectRopCopy(pThis, pThisCC, pCmd);
|
---|
3936 | break;
|
---|
3937 | }
|
---|
3938 |
|
---|
3939 | case SVGA_CMD_ESCAPE:
|
---|
3940 | {
|
---|
3941 | /* Followed by 'size' bytes of data. */
|
---|
3942 | SVGAFifoCmdEscape *pCmd = (SVGAFifoCmdEscape *)&pu8Cmd[cbCmd];
|
---|
3943 | VMSVGA_INC_CMD_SIZE_BREAK(sizeof(*pCmd));
|
---|
3944 |
|
---|
3945 | ASSERT_GUEST_STMT_BREAK(pCmd->size < pThis->svga.cbFIFO - sizeof(SVGAFifoCmdEscape), CBstatus = SVGA_CB_STATUS_COMMAND_ERROR);
|
---|
3946 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
3947 |
|
---|
3948 | VMSVGA_INC_CMD_SIZE_BREAK(pCmd->size);
|
---|
3949 | vmsvgaR3CmdEscape(pThis, pThisCC, pCmd);
|
---|
3950 | break;
|
---|
3951 | }
|
---|
3952 | # ifdef VBOX_WITH_VMSVGA3D
|
---|
3953 | case SVGA_CMD_DEFINE_GMR2:
|
---|
3954 | {
|
---|
3955 | SVGAFifoCmdDefineGMR2 *pCmd = (SVGAFifoCmdDefineGMR2 *)&pu8Cmd[cbCmd];
|
---|
3956 | VMSVGA_INC_CMD_SIZE_BREAK(sizeof(*pCmd));
|
---|
3957 | vmsvgaR3CmdDefineGMR2(pThis, pThisCC, pCmd);
|
---|
3958 | break;
|
---|
3959 | }
|
---|
3960 |
|
---|
3961 | case SVGA_CMD_REMAP_GMR2:
|
---|
3962 | {
|
---|
3963 | /* Followed by page descriptors or guest ptr. */
|
---|
3964 | SVGAFifoCmdRemapGMR2 *pCmd = (SVGAFifoCmdRemapGMR2 *)&pu8Cmd[cbCmd];
|
---|
3965 | VMSVGA_INC_CMD_SIZE_BREAK(sizeof(*pCmd));
|
---|
3966 |
|
---|
3967 | /* Calculate the size of what comes after next and fetch it. */
|
---|
3968 | uint32_t cbMore = 0;
|
---|
3969 | if (pCmd->flags & SVGA_REMAP_GMR2_VIA_GMR)
|
---|
3970 | cbMore = sizeof(SVGAGuestPtr);
|
---|
3971 | else
|
---|
3972 | {
|
---|
3973 | uint32_t const cbPageDesc = (pCmd->flags & SVGA_REMAP_GMR2_PPN64) ? sizeof(uint64_t) : sizeof(uint32_t);
|
---|
3974 | if (pCmd->flags & SVGA_REMAP_GMR2_SINGLE_PPN)
|
---|
3975 | {
|
---|
3976 | cbMore = cbPageDesc;
|
---|
3977 | pCmd->numPages = 1;
|
---|
3978 | }
|
---|
3979 | else
|
---|
3980 | {
|
---|
3981 | ASSERT_GUEST_STMT_BREAK(pCmd->numPages <= pThis->svga.cbFIFO / cbPageDesc, CBstatus = SVGA_CB_STATUS_COMMAND_ERROR);
|
---|
3982 | cbMore = cbPageDesc * pCmd->numPages;
|
---|
3983 | }
|
---|
3984 | }
|
---|
3985 | VMSVGA_INC_CMD_SIZE_BREAK(cbMore);
|
---|
3986 | vmsvgaR3CmdRemapGMR2(pThis, pThisCC, pCmd);
|
---|
3987 | # ifdef DEBUG_GMR_ACCESS
|
---|
3988 | VMR3ReqCallWaitU(PDMDevHlpGetUVM(pDevIns), VMCPUID_ANY, (PFNRT)vmsvgaR3RegisterGmr, 2, pDevIns, pCmd->gmrId);
|
---|
3989 | # endif
|
---|
3990 | break;
|
---|
3991 | }
|
---|
3992 | # endif /* VBOX_WITH_VMSVGA3D */
|
---|
3993 | case SVGA_CMD_DEFINE_SCREEN:
|
---|
3994 | {
|
---|
3995 | /* The size of this command is specified by the guest and depends on capabilities. */
|
---|
3996 | SVGAFifoCmdDefineScreen *pCmd = (SVGAFifoCmdDefineScreen *)&pu8Cmd[cbCmd];
|
---|
3997 | VMSVGA_INC_CMD_SIZE_BREAK(sizeof(pCmd->screen.structSize));
|
---|
3998 | ASSERT_GUEST_STMT_BREAK(pCmd->screen.structSize < pThis->svga.cbFIFO, CBstatus = SVGA_CB_STATUS_COMMAND_ERROR);
|
---|
3999 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
4000 |
|
---|
4001 | VMSVGA_INC_CMD_SIZE_BREAK(RT_MAX(sizeof(pCmd->screen.structSize), pCmd->screen.structSize) - sizeof(pCmd->screen.structSize));
|
---|
4002 | vmsvgaR3CmdDefineScreen(pThis, pThisCC, pCmd);
|
---|
4003 | break;
|
---|
4004 | }
|
---|
4005 |
|
---|
4006 | case SVGA_CMD_DESTROY_SCREEN:
|
---|
4007 | {
|
---|
4008 | SVGAFifoCmdDestroyScreen *pCmd = (SVGAFifoCmdDestroyScreen *)&pu8Cmd[cbCmd];
|
---|
4009 | VMSVGA_INC_CMD_SIZE_BREAK(sizeof(*pCmd));
|
---|
4010 | vmsvgaR3CmdDestroyScreen(pThis, pThisCC, pCmd);
|
---|
4011 | break;
|
---|
4012 | }
|
---|
4013 |
|
---|
4014 | case SVGA_CMD_DEFINE_GMRFB:
|
---|
4015 | {
|
---|
4016 | SVGAFifoCmdDefineGMRFB *pCmd = (SVGAFifoCmdDefineGMRFB *)&pu8Cmd[cbCmd];
|
---|
4017 | VMSVGA_INC_CMD_SIZE_BREAK(sizeof(*pCmd));
|
---|
4018 | vmsvgaR3CmdDefineGMRFB(pThis, pThisCC, pCmd);
|
---|
4019 | break;
|
---|
4020 | }
|
---|
4021 |
|
---|
4022 | case SVGA_CMD_BLIT_GMRFB_TO_SCREEN:
|
---|
4023 | {
|
---|
4024 | SVGAFifoCmdBlitGMRFBToScreen *pCmd = (SVGAFifoCmdBlitGMRFBToScreen *)&pu8Cmd[cbCmd];
|
---|
4025 | VMSVGA_INC_CMD_SIZE_BREAK(sizeof(*pCmd));
|
---|
4026 | vmsvgaR3CmdBlitGMRFBToScreen(pThis, pThisCC, pCmd);
|
---|
4027 | break;
|
---|
4028 | }
|
---|
4029 |
|
---|
4030 | case SVGA_CMD_BLIT_SCREEN_TO_GMRFB:
|
---|
4031 | {
|
---|
4032 | SVGAFifoCmdBlitScreenToGMRFB *pCmd = (SVGAFifoCmdBlitScreenToGMRFB *)&pu8Cmd[cbCmd];
|
---|
4033 | VMSVGA_INC_CMD_SIZE_BREAK(sizeof(*pCmd));
|
---|
4034 | vmsvgaR3CmdBlitScreenToGMRFB(pThis, pThisCC, pCmd);
|
---|
4035 | break;
|
---|
4036 | }
|
---|
4037 |
|
---|
4038 | case SVGA_CMD_ANNOTATION_FILL:
|
---|
4039 | {
|
---|
4040 | SVGAFifoCmdAnnotationFill *pCmd = (SVGAFifoCmdAnnotationFill *)&pu8Cmd[cbCmd];
|
---|
4041 | VMSVGA_INC_CMD_SIZE_BREAK(sizeof(*pCmd));
|
---|
4042 | vmsvgaR3CmdAnnotationFill(pThis, pThisCC, pCmd);
|
---|
4043 | break;
|
---|
4044 | }
|
---|
4045 |
|
---|
4046 | case SVGA_CMD_ANNOTATION_COPY:
|
---|
4047 | {
|
---|
4048 | SVGAFifoCmdAnnotationCopy *pCmd = (SVGAFifoCmdAnnotationCopy *)&pu8Cmd[cbCmd];
|
---|
4049 | VMSVGA_INC_CMD_SIZE_BREAK(sizeof(*pCmd));
|
---|
4050 | vmsvgaR3CmdAnnotationCopy(pThis, pThisCC, pCmd);
|
---|
4051 | break;
|
---|
4052 | }
|
---|
4053 |
|
---|
4054 | default:
|
---|
4055 | {
|
---|
4056 | # ifdef VBOX_WITH_VMSVGA3D
|
---|
4057 | if ( (cmdId >= SVGA_3D_CMD_BASE && cmdId < SVGA_3D_CMD_MAX)
|
---|
4058 | || ( pThis->svga.fVBoxExtensions
|
---|
4059 | && (cmdId >= VBSVGA_3D_CMD_BASE && cmdId < VBSVGA_3D_CMD_MAX)))
|
---|
4060 | {
|
---|
4061 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
4062 |
|
---|
4063 | /* All 3d commands start with a common header, which defines the identifier and the size
|
---|
4064 | * of the command. The identifier has been already read. Fetch the size.
|
---|
4065 | */
|
---|
4066 | uint32_t const *pcbMore = (uint32_t const *)&pu8Cmd[cbCmd];
|
---|
4067 | VMSVGA_INC_CMD_SIZE_BREAK(sizeof(*pcbMore));
|
---|
4068 | VMSVGA_INC_CMD_SIZE_BREAK(*pcbMore);
|
---|
4069 | if (RT_LIKELY(pThis->svga.f3DEnabled))
|
---|
4070 | { /* likely */ }
|
---|
4071 | else
|
---|
4072 | {
|
---|
4073 | LogRelMax(8, ("VMSVGA: 3D disabled, command %d skipped\n", cmdId));
|
---|
4074 | break;
|
---|
4075 | }
|
---|
4076 |
|
---|
4077 | /* Command data begins after the 32 bit command length. */
|
---|
4078 | int rc = vmsvgaR3Process3dCmd(pThis, pThisCC, idDXContext, (SVGAFifo3dCmdId)cmdId, *pcbMore, pcbMore + 1);
|
---|
4079 | if (RT_SUCCESS(rc))
|
---|
4080 | { /* likely */ }
|
---|
4081 | else
|
---|
4082 | {
|
---|
4083 | CBstatus = SVGA_CB_STATUS_COMMAND_ERROR;
|
---|
4084 | break;
|
---|
4085 | }
|
---|
4086 | }
|
---|
4087 | else
|
---|
4088 | # endif /* VBOX_WITH_VMSVGA3D */
|
---|
4089 | {
|
---|
4090 | /* Unsupported command. */
|
---|
4091 | STAM_REL_COUNTER_INC(&pSvgaR3State->StatFifoUnkCmds);
|
---|
4092 | ASSERT_GUEST_MSG_FAILED(("cmdId=%d\n", cmdId));
|
---|
4093 | LogRelMax(16, ("VMSVGA: unsupported command %d\n", cmdId));
|
---|
4094 | CBstatus = SVGA_CB_STATUS_COMMAND_ERROR;
|
---|
4095 | break;
|
---|
4096 | }
|
---|
4097 | }
|
---|
4098 | }
|
---|
4099 |
|
---|
4100 | if (CBstatus != SVGA_CB_STATUS_COMPLETED)
|
---|
4101 | break;
|
---|
4102 |
|
---|
4103 | pu8Cmd += cbCmd;
|
---|
4104 | cbRemain -= cbCmd;
|
---|
4105 |
|
---|
4106 | /* If this is not the last command in the buffer, then generate IRQ, if required.
|
---|
4107 | * This avoids a double call to vmsvgaR3CmdBufRaiseIRQ if FENCE is the last command
|
---|
4108 | * in the buffer (usually the case).
|
---|
4109 | */
|
---|
4110 | if (RT_LIKELY(!(cbRemain && *pu32IrqStatus)))
|
---|
4111 | { /* likely */ }
|
---|
4112 | else
|
---|
4113 | {
|
---|
4114 | vmsvgaR3CmdBufRaiseIRQ(pDevIns, pThis, *pu32IrqStatus);
|
---|
4115 | *pu32IrqStatus = 0;
|
---|
4116 | }
|
---|
4117 | }
|
---|
4118 |
|
---|
4119 | Assert(cbRemain <= cbCommands);
|
---|
4120 | *poffNextCmd = cbCommands - cbRemain;
|
---|
4121 | return CBstatus;
|
---|
4122 | }
|
---|
4123 |
|
---|
4124 |
|
---|
4125 | /** Process command buffers.
|
---|
4126 | *
|
---|
4127 | * @param pDevIns The device instance.
|
---|
4128 | * @param pThis The shared VGA/VMSVGA state.
|
---|
4129 | * @param pThisCC The VGA/VMSVGA state for the current context.
|
---|
4130 | * @param pThread Handle of the FIFO thread.
|
---|
4131 | * @thread FIFO
|
---|
4132 | */
|
---|
4133 | static void vmsvgaR3CmdBufProcessBuffers(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC, PPDMTHREAD pThread)
|
---|
4134 | {
|
---|
4135 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
4136 |
|
---|
4137 | for (;;)
|
---|
4138 | {
|
---|
4139 | if (pThread->enmState != PDMTHREADSTATE_RUNNING)
|
---|
4140 | break;
|
---|
4141 |
|
---|
4142 | /* See if there is a submitted buffer. */
|
---|
4143 | PVMSVGACMDBUF pCmdBuf = NULL;
|
---|
4144 |
|
---|
4145 | int rc = RTCritSectEnter(&pSvgaR3State->CritSectCmdBuf);
|
---|
4146 | AssertRC(rc);
|
---|
4147 |
|
---|
4148 | /* It seems that a higher queue index has a higher priority.
|
---|
4149 | * See SVGACBContext in svga_reg.h from latest vmwgfx Linux driver.
|
---|
4150 | */
|
---|
4151 | for (unsigned i = RT_ELEMENTS(pSvgaR3State->apCmdBufCtxs); i > 0; --i)
|
---|
4152 | {
|
---|
4153 | PVMSVGACMDBUFCTX pCmdBufCtx = pSvgaR3State->apCmdBufCtxs[i - 1];
|
---|
4154 | if (pCmdBufCtx)
|
---|
4155 | {
|
---|
4156 | pCmdBuf = RTListRemoveFirst(&pCmdBufCtx->listSubmitted, VMSVGACMDBUF, nodeBuffer);
|
---|
4157 | if (pCmdBuf)
|
---|
4158 | {
|
---|
4159 | Assert(pCmdBufCtx->cSubmitted > 0);
|
---|
4160 | --pCmdBufCtx->cSubmitted;
|
---|
4161 | break;
|
---|
4162 | }
|
---|
4163 | }
|
---|
4164 | }
|
---|
4165 |
|
---|
4166 | if (!pCmdBuf)
|
---|
4167 | {
|
---|
4168 | ASMAtomicWriteU32(&pSvgaR3State->fCmdBuf, 0);
|
---|
4169 | RTCritSectLeave(&pSvgaR3State->CritSectCmdBuf);
|
---|
4170 | break;
|
---|
4171 | }
|
---|
4172 |
|
---|
4173 | RTCritSectLeave(&pSvgaR3State->CritSectCmdBuf);
|
---|
4174 |
|
---|
4175 | SVGACBStatus CBstatus = SVGA_CB_STATUS_NONE;
|
---|
4176 | uint32_t offNextCmd = 0;
|
---|
4177 | uint32_t u32IrqStatus = 0;
|
---|
4178 | uint32_t const idDXContext = RT_BOOL(pCmdBuf->hdr.flags & SVGA_CB_FLAG_DX_CONTEXT)
|
---|
4179 | ? pCmdBuf->hdr.dxContext
|
---|
4180 | : SVGA3D_INVALID_ID;
|
---|
4181 | /* Process one buffer. */
|
---|
4182 | CBstatus = vmsvgaR3CmdBufProcessCommands(pDevIns, pThis, pThisCC, idDXContext, pCmdBuf->pvCommands, pCmdBuf->hdr.length, &offNextCmd, &u32IrqStatus);
|
---|
4183 |
|
---|
4184 | if (!RT_BOOL(pCmdBuf->hdr.flags & SVGA_CB_FLAG_NO_IRQ))
|
---|
4185 | u32IrqStatus |= SVGA_IRQFLAG_COMMAND_BUFFER;
|
---|
4186 | if (CBstatus == SVGA_CB_STATUS_COMMAND_ERROR)
|
---|
4187 | u32IrqStatus |= SVGA_IRQFLAG_ERROR;
|
---|
4188 |
|
---|
4189 | vmsvgaR3CmdBufWriteStatus(pDevIns, pCmdBuf->GCPhysCB, CBstatus, offNextCmd);
|
---|
4190 | if (u32IrqStatus)
|
---|
4191 | vmsvgaR3CmdBufRaiseIRQ(pDevIns, pThis, u32IrqStatus);
|
---|
4192 |
|
---|
4193 | vmsvgaR3CmdBufFree(pCmdBuf);
|
---|
4194 | }
|
---|
4195 | }
|
---|
4196 |
|
---|
4197 |
|
---|
4198 | /**
|
---|
4199 | * Worker for vmsvgaR3FifoThread that handles an external command.
|
---|
4200 | *
|
---|
4201 | * @param pDevIns The device instance.
|
---|
4202 | * @param pThis The shared VGA/VMSVGA instance data.
|
---|
4203 | * @param pThisCC The VGA/VMSVGA state for ring-3.
|
---|
4204 | */
|
---|
4205 | static void vmsvgaR3FifoHandleExtCmd(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC)
|
---|
4206 | {
|
---|
4207 | uint8_t uExtCmd = pThis->svga.u8FIFOExtCommand;
|
---|
4208 | switch (pThis->svga.u8FIFOExtCommand)
|
---|
4209 | {
|
---|
4210 | case VMSVGA_FIFO_EXTCMD_RESET:
|
---|
4211 | Log(("vmsvgaR3FifoLoop: reset the fifo thread.\n"));
|
---|
4212 | Assert(pThisCC->svga.pvFIFOExtCmdParam == NULL);
|
---|
4213 |
|
---|
4214 | vmsvgaR3ResetScreens(pThis, pThisCC);
|
---|
4215 | # ifdef VBOX_WITH_VMSVGA3D
|
---|
4216 | /* The 3d subsystem must be reset from the fifo thread. */
|
---|
4217 | if (pThis->svga.f3DEnabled)
|
---|
4218 | vmsvga3dReset(pThisCC);
|
---|
4219 | # endif
|
---|
4220 | vmsvgaR3ResetSvgaState(pThis, pThisCC);
|
---|
4221 | break;
|
---|
4222 |
|
---|
4223 | case VMSVGA_FIFO_EXTCMD_POWEROFF:
|
---|
4224 | Log(("vmsvgaR3FifoLoop: power off.\n"));
|
---|
4225 | Assert(pThisCC->svga.pvFIFOExtCmdParam == NULL);
|
---|
4226 |
|
---|
4227 | /* The screens must be reset on the FIFO thread, because they may use 3D resources. */
|
---|
4228 | vmsvgaR3ResetScreens(pThis, pThisCC);
|
---|
4229 | break;
|
---|
4230 |
|
---|
4231 | case VMSVGA_FIFO_EXTCMD_TERMINATE:
|
---|
4232 | Log(("vmsvgaR3FifoLoop: terminate the fifo thread.\n"));
|
---|
4233 | Assert(pThisCC->svga.pvFIFOExtCmdParam == NULL);
|
---|
4234 |
|
---|
4235 | # ifdef VBOX_WITH_VMSVGA3D
|
---|
4236 | /* The 3d subsystem must be shut down from the fifo thread. */
|
---|
4237 | if (pThis->svga.f3DEnabled)
|
---|
4238 | vmsvga3dTerminate(pThisCC);
|
---|
4239 | # endif
|
---|
4240 | vmsvgaR3TerminateSvgaState(pThis, pThisCC);
|
---|
4241 | break;
|
---|
4242 |
|
---|
4243 | case VMSVGA_FIFO_EXTCMD_SAVESTATE:
|
---|
4244 | {
|
---|
4245 | Log(("vmsvgaR3FifoLoop: VMSVGA_FIFO_EXTCMD_SAVESTATE.\n"));
|
---|
4246 | PSSMHANDLE pSSM = (PSSMHANDLE)pThisCC->svga.pvFIFOExtCmdParam;
|
---|
4247 | AssertLogRelMsgBreak(RT_VALID_PTR(pSSM), ("pSSM=%p\n", pSSM));
|
---|
4248 | vmsvgaR3SaveExecFifo(pDevIns->pHlpR3, pThisCC, pSSM);
|
---|
4249 | # ifdef VBOX_WITH_VMSVGA3D
|
---|
4250 | if (pThis->svga.f3DEnabled)
|
---|
4251 | {
|
---|
4252 | if (vmsvga3dIsLegacyBackend(pThisCC))
|
---|
4253 | vmsvga3dSaveExec(pDevIns, pThisCC, pSSM);
|
---|
4254 | # ifdef VMSVGA3D_DX
|
---|
4255 | else
|
---|
4256 | vmsvga3dDXSaveExec(pDevIns, pThisCC, pSSM);
|
---|
4257 | # endif
|
---|
4258 | }
|
---|
4259 | # endif
|
---|
4260 | break;
|
---|
4261 | }
|
---|
4262 |
|
---|
4263 | case VMSVGA_FIFO_EXTCMD_LOADSTATE:
|
---|
4264 | {
|
---|
4265 | Log(("vmsvgaR3FifoLoop: VMSVGA_FIFO_EXTCMD_LOADSTATE.\n"));
|
---|
4266 | PVMSVGA_STATE_LOAD pLoadState = (PVMSVGA_STATE_LOAD)pThisCC->svga.pvFIFOExtCmdParam;
|
---|
4267 | AssertLogRelMsgBreak(RT_VALID_PTR(pLoadState), ("pLoadState=%p\n", pLoadState));
|
---|
4268 | vmsvgaR3LoadExecFifo(pDevIns->pHlpR3, pThis, pThisCC, pLoadState->pSSM, pLoadState->uVersion, pLoadState->uPass);
|
---|
4269 | # ifdef VBOX_WITH_VMSVGA3D
|
---|
4270 | if (pThis->svga.f3DEnabled)
|
---|
4271 | {
|
---|
4272 | /* The following RT_OS_DARWIN code was in vmsvga3dLoadExec and therefore must be executed before each vmsvga3dLoadExec invocation. */
|
---|
4273 | # ifndef RT_OS_DARWIN /** @todo r=bird: this is normally done on the EMT, so for DARWIN we do that when loading saved state too now. See DevVGA-SVGA.cpp */
|
---|
4274 | /* Must initialize now as the recreation calls below rely on an initialized 3d subsystem. */
|
---|
4275 | vmsvgaR3PowerOnDevice(pDevIns, pThis, pThisCC, /*fLoadState=*/ true);
|
---|
4276 | # endif
|
---|
4277 |
|
---|
4278 | if (vmsvga3dIsLegacyBackend(pThisCC))
|
---|
4279 | vmsvga3dLoadExec(pDevIns, pThis, pThisCC, pLoadState->pSSM, pLoadState->uVersion, pLoadState->uPass);
|
---|
4280 | # ifdef VMSVGA3D_DX
|
---|
4281 | else
|
---|
4282 | vmsvga3dDXLoadExec(pDevIns, pThis, pThisCC, pLoadState->pSSM, pLoadState->uVersion, pLoadState->uPass);
|
---|
4283 | # endif
|
---|
4284 | }
|
---|
4285 | # endif
|
---|
4286 | break;
|
---|
4287 | }
|
---|
4288 |
|
---|
4289 | case VMSVGA_FIFO_EXTCMD_UPDATE_SURFACE_HEAP_BUFFERS:
|
---|
4290 | {
|
---|
4291 | # ifdef VBOX_WITH_VMSVGA3D
|
---|
4292 | uint32_t sid = (uint32_t)(uintptr_t)pThisCC->svga.pvFIFOExtCmdParam;
|
---|
4293 | Log(("vmsvgaR3FifoLoop: VMSVGA_FIFO_EXTCMD_UPDATE_SURFACE_HEAP_BUFFERS sid=%#x\n", sid));
|
---|
4294 | vmsvga3dUpdateHeapBuffersForSurfaces(pThisCC, sid);
|
---|
4295 | # endif
|
---|
4296 | break;
|
---|
4297 | }
|
---|
4298 |
|
---|
4299 |
|
---|
4300 | default:
|
---|
4301 | AssertLogRelMsgFailed(("uExtCmd=%#x pvFIFOExtCmdParam=%p\n", uExtCmd, pThisCC->svga.pvFIFOExtCmdParam));
|
---|
4302 | break;
|
---|
4303 | }
|
---|
4304 |
|
---|
4305 | /*
|
---|
4306 | * Signal the end of the external command.
|
---|
4307 | */
|
---|
4308 | pThisCC->svga.pvFIFOExtCmdParam = NULL;
|
---|
4309 | pThis->svga.u8FIFOExtCommand = VMSVGA_FIFO_EXTCMD_NONE;
|
---|
4310 | ASMMemoryFence(); /* paranoia^2 */
|
---|
4311 | int rc = RTSemEventSignal(pThisCC->svga.hFIFOExtCmdSem);
|
---|
4312 | AssertLogRelRC(rc);
|
---|
4313 | }
|
---|
4314 |
|
---|
4315 | /**
|
---|
4316 | * Worker for vmsvgaR3Destruct, vmsvgaR3Reset, vmsvgaR3Save and vmsvgaR3Load for
|
---|
4317 | * doing a job on the FIFO thread (even when it's officially suspended).
|
---|
4318 | *
|
---|
4319 | * @returns VBox status code (fully asserted).
|
---|
4320 | * @param pDevIns The device instance.
|
---|
4321 | * @param pThis The shared VGA/VMSVGA instance data.
|
---|
4322 | * @param pThisCC The VGA/VMSVGA state for ring-3.
|
---|
4323 | * @param uExtCmd The command to execute on the FIFO thread.
|
---|
4324 | * @param pvParam Pointer to command parameters.
|
---|
4325 | * @param cMsWait The time to wait for the command, given in
|
---|
4326 | * milliseconds.
|
---|
4327 | */
|
---|
4328 | static int vmsvgaR3RunExtCmdOnFifoThread(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC,
|
---|
4329 | uint8_t uExtCmd, void *pvParam, RTMSINTERVAL cMsWait)
|
---|
4330 | {
|
---|
4331 | Assert(cMsWait >= RT_MS_1SEC * 5);
|
---|
4332 | AssertLogRelMsg(pThis->svga.u8FIFOExtCommand == VMSVGA_FIFO_EXTCMD_NONE,
|
---|
4333 | ("old=%d new=%d\n", pThis->svga.u8FIFOExtCommand, uExtCmd));
|
---|
4334 |
|
---|
4335 | int rc;
|
---|
4336 | PPDMTHREAD pThread = pThisCC->svga.pFIFOIOThread;
|
---|
4337 | PDMTHREADSTATE enmState = pThread->enmState;
|
---|
4338 | if (enmState == PDMTHREADSTATE_SUSPENDED)
|
---|
4339 | {
|
---|
4340 | /*
|
---|
4341 | * The thread is suspended, we have to temporarily wake it up so it can
|
---|
4342 | * perform the task.
|
---|
4343 | * (We ASSUME not racing code here, both wrt thread state and ext commands.)
|
---|
4344 | */
|
---|
4345 | Log(("vmsvgaR3RunExtCmdOnFifoThread: uExtCmd=%d enmState=SUSPENDED\n", uExtCmd));
|
---|
4346 | /* Post the request. */
|
---|
4347 | pThis->svga.fFifoExtCommandWakeup = true;
|
---|
4348 | pThisCC->svga.pvFIFOExtCmdParam = pvParam;
|
---|
4349 | pThis->svga.u8FIFOExtCommand = uExtCmd;
|
---|
4350 | ASMMemoryFence(); /* paranoia^3 */
|
---|
4351 |
|
---|
4352 | /* Resume the thread. */
|
---|
4353 | rc = PDMDevHlpThreadResume(pDevIns, pThread);
|
---|
4354 | AssertLogRelRC(rc);
|
---|
4355 | if (RT_SUCCESS(rc))
|
---|
4356 | {
|
---|
4357 | /* Wait. Take care in case the semaphore was already posted (same as below). */
|
---|
4358 | rc = RTSemEventWait(pThisCC->svga.hFIFOExtCmdSem, cMsWait);
|
---|
4359 | if ( rc == VINF_SUCCESS
|
---|
4360 | && pThis->svga.u8FIFOExtCommand == uExtCmd)
|
---|
4361 | rc = RTSemEventWait(pThisCC->svga.hFIFOExtCmdSem, cMsWait);
|
---|
4362 | AssertLogRelMsg(pThis->svga.u8FIFOExtCommand != uExtCmd || RT_FAILURE_NP(rc),
|
---|
4363 | ("%#x %Rrc\n", pThis->svga.u8FIFOExtCommand, rc));
|
---|
4364 |
|
---|
4365 | /* suspend the thread */
|
---|
4366 | pThis->svga.fFifoExtCommandWakeup = false;
|
---|
4367 | int rc2 = PDMDevHlpThreadSuspend(pDevIns, pThread);
|
---|
4368 | AssertLogRelRC(rc2);
|
---|
4369 | if (RT_FAILURE(rc2) && RT_SUCCESS(rc))
|
---|
4370 | rc = rc2;
|
---|
4371 | }
|
---|
4372 | pThis->svga.fFifoExtCommandWakeup = false;
|
---|
4373 | pThisCC->svga.pvFIFOExtCmdParam = NULL;
|
---|
4374 | }
|
---|
4375 | else if (enmState == PDMTHREADSTATE_RUNNING)
|
---|
4376 | {
|
---|
4377 | /*
|
---|
4378 | * The thread is running, should only happen during reset and vmsvga3dsfc.
|
---|
4379 | * We ASSUME not racing code here, both wrt thread state and ext commands.
|
---|
4380 | */
|
---|
4381 | Log(("vmsvgaR3RunExtCmdOnFifoThread: uExtCmd=%d enmState=RUNNING\n", uExtCmd));
|
---|
4382 | Assert(uExtCmd == VMSVGA_FIFO_EXTCMD_RESET || uExtCmd == VMSVGA_FIFO_EXTCMD_UPDATE_SURFACE_HEAP_BUFFERS || uExtCmd == VMSVGA_FIFO_EXTCMD_POWEROFF);
|
---|
4383 |
|
---|
4384 | /* Post the request. */
|
---|
4385 | pThisCC->svga.pvFIFOExtCmdParam = pvParam;
|
---|
4386 | pThis->svga.u8FIFOExtCommand = uExtCmd;
|
---|
4387 | ASMMemoryFence(); /* paranoia^2 */
|
---|
4388 | rc = PDMDevHlpSUPSemEventSignal(pDevIns, pThis->svga.hFIFORequestSem);
|
---|
4389 | AssertLogRelRC(rc);
|
---|
4390 |
|
---|
4391 | /* Wait. Take care in case the semaphore was already posted (same as above). */
|
---|
4392 | rc = RTSemEventWait(pThisCC->svga.hFIFOExtCmdSem, cMsWait);
|
---|
4393 | if ( rc == VINF_SUCCESS
|
---|
4394 | && pThis->svga.u8FIFOExtCommand == uExtCmd)
|
---|
4395 | rc = RTSemEventWait(pThisCC->svga.hFIFOExtCmdSem, cMsWait); /* it was already posted, retry the wait. */
|
---|
4396 | AssertLogRelMsg(pThis->svga.u8FIFOExtCommand != uExtCmd || RT_FAILURE_NP(rc),
|
---|
4397 | ("%#x %Rrc\n", pThis->svga.u8FIFOExtCommand, rc));
|
---|
4398 |
|
---|
4399 | pThisCC->svga.pvFIFOExtCmdParam = NULL;
|
---|
4400 | }
|
---|
4401 | else
|
---|
4402 | {
|
---|
4403 | /*
|
---|
4404 | * Something is wrong with the thread!
|
---|
4405 | */
|
---|
4406 | AssertLogRelMsgFailed(("uExtCmd=%d enmState=%d\n", uExtCmd, enmState));
|
---|
4407 | rc = VERR_INVALID_STATE;
|
---|
4408 | }
|
---|
4409 | return rc;
|
---|
4410 | }
|
---|
4411 |
|
---|
4412 |
|
---|
4413 | /**
|
---|
4414 | * Marks the FIFO non-busy, notifying any waiting EMTs.
|
---|
4415 | *
|
---|
4416 | * @param pDevIns The device instance.
|
---|
4417 | * @param pThis The shared VGA/VMSVGA instance data.
|
---|
4418 | * @param pThisCC The VGA/VMSVGA state for ring-3.
|
---|
4419 | * @param pSVGAState Pointer to the ring-3 only SVGA state data.
|
---|
4420 | * @param offFifoMin The start byte offset of the command FIFO.
|
---|
4421 | */
|
---|
4422 | static void vmsvgaR3FifoSetNotBusy(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC, PVMSVGAR3STATE pSVGAState, uint32_t offFifoMin)
|
---|
4423 | {
|
---|
4424 | ASMAtomicAndU32(&pThis->svga.fBusy, ~(VMSVGA_BUSY_F_FIFO | VMSVGA_BUSY_F_EMT_FORCE));
|
---|
4425 | if (VMSVGA_IS_VALID_FIFO_REG(SVGA_FIFO_BUSY, offFifoMin))
|
---|
4426 | vmsvgaHCSafeFifoBusyRegUpdate(pThis, pThisCC, pThis->svga.fBusy != 0);
|
---|
4427 |
|
---|
4428 | /* Wake up any waiting EMTs. */
|
---|
4429 | if (pSVGAState->cBusyDelayedEmts > 0)
|
---|
4430 | {
|
---|
4431 | # ifdef VMSVGA_USE_EMT_HALT_CODE
|
---|
4432 | VMCPUID idCpu = VMCpuSetFindLastPresentInternal(&pSVGAState->BusyDelayedEmts);
|
---|
4433 | if (idCpu != NIL_VMCPUID)
|
---|
4434 | {
|
---|
4435 | PDMDevHlpVMNotifyCpuDeviceReady(pDevIns, idCpu);
|
---|
4436 | while (idCpu-- > 0)
|
---|
4437 | if (VMCPUSET_IS_PRESENT(&pSVGAState->BusyDelayedEmts, idCpu))
|
---|
4438 | PDMDevHlpVMNotifyCpuDeviceReady(pDevIns, idCpu);
|
---|
4439 | }
|
---|
4440 | # else
|
---|
4441 | int rc2 = RTSemEventMultiSignal(pSVGAState->hBusyDelayedEmts);
|
---|
4442 | AssertRC(rc2);
|
---|
4443 | # endif
|
---|
4444 | }
|
---|
4445 | }
|
---|
4446 |
|
---|
4447 | /**
|
---|
4448 | * Reads (more) payload into the command buffer.
|
---|
4449 | *
|
---|
4450 | * @returns pbBounceBuf on success
|
---|
4451 | * @retval (void *)1 if the thread was requested to stop.
|
---|
4452 | * @retval NULL on FIFO error.
|
---|
4453 | *
|
---|
4454 | * @param cbPayloadReq The number of bytes of payload requested.
|
---|
4455 | * @param pFIFO The FIFO.
|
---|
4456 | * @param offCurrentCmd The FIFO byte offset of the current command.
|
---|
4457 | * @param offFifoMin The start byte offset of the command FIFO.
|
---|
4458 | * @param offFifoMax The end byte offset of the command FIFO.
|
---|
4459 | * @param pbBounceBuf The bounch buffer. Same size as the entire FIFO, so
|
---|
4460 | * always sufficient size.
|
---|
4461 | * @param pcbAlreadyRead How much payload we've already read into the bounce
|
---|
4462 | * buffer. (We will NEVER re-read anything.)
|
---|
4463 | * @param pThread The calling PDM thread handle.
|
---|
4464 | * @param pThis The shared VGA/VMSVGA instance data.
|
---|
4465 | * @param pSVGAState Pointer to the ring-3 only SVGA state data. For
|
---|
4466 | * statistics collection.
|
---|
4467 | * @param pDevIns The device instance.
|
---|
4468 | */
|
---|
4469 | static void *vmsvgaR3FifoGetCmdPayload(uint32_t cbPayloadReq, uint32_t RT_UNTRUSTED_VOLATILE_GUEST *pFIFO,
|
---|
4470 | uint32_t offCurrentCmd, uint32_t offFifoMin, uint32_t offFifoMax,
|
---|
4471 | uint8_t *pbBounceBuf, uint32_t *pcbAlreadyRead,
|
---|
4472 | PPDMTHREAD pThread, PVGASTATE pThis, PVMSVGAR3STATE pSVGAState, PPDMDEVINS pDevIns)
|
---|
4473 | {
|
---|
4474 | Assert(pbBounceBuf);
|
---|
4475 | Assert(pcbAlreadyRead);
|
---|
4476 | Assert(offFifoMin < offFifoMax);
|
---|
4477 | Assert(offCurrentCmd >= offFifoMin && offCurrentCmd < offFifoMax);
|
---|
4478 | Assert(offFifoMax <= pThis->svga.cbFIFO);
|
---|
4479 |
|
---|
4480 | /*
|
---|
4481 | * Check if the requested payload size has already been satisfied .
|
---|
4482 | * .
|
---|
4483 | * When called to read more, the caller is responsible for making sure the .
|
---|
4484 | * new command size (cbRequsted) never is smaller than what has already .
|
---|
4485 | * been read.
|
---|
4486 | */
|
---|
4487 | uint32_t cbAlreadyRead = *pcbAlreadyRead;
|
---|
4488 | if (cbPayloadReq <= cbAlreadyRead)
|
---|
4489 | {
|
---|
4490 | AssertLogRelReturn(cbPayloadReq == cbAlreadyRead, NULL);
|
---|
4491 | return pbBounceBuf;
|
---|
4492 | }
|
---|
4493 |
|
---|
4494 | /*
|
---|
4495 | * Commands bigger than the fifo buffer are invalid.
|
---|
4496 | */
|
---|
4497 | uint32_t const cbFifoCmd = offFifoMax - offFifoMin;
|
---|
4498 | AssertMsgReturnStmt(cbPayloadReq <= cbFifoCmd, ("cbPayloadReq=%#x cbFifoCmd=%#x\n", cbPayloadReq, cbFifoCmd),
|
---|
4499 | STAM_REL_COUNTER_INC(&pSVGAState->StatFifoErrors),
|
---|
4500 | NULL);
|
---|
4501 |
|
---|
4502 | /*
|
---|
4503 | * Move offCurrentCmd past the command dword.
|
---|
4504 | */
|
---|
4505 | offCurrentCmd += sizeof(uint32_t);
|
---|
4506 | if (offCurrentCmd >= offFifoMax)
|
---|
4507 | offCurrentCmd = offFifoMin;
|
---|
4508 |
|
---|
4509 | /*
|
---|
4510 | * Do we have sufficient payload data available already?
|
---|
4511 | * The host should not read beyond [SVGA_FIFO_NEXT_CMD], therefore '>=' in the condition below.
|
---|
4512 | */
|
---|
4513 | uint32_t cbAfter, cbBefore;
|
---|
4514 | uint32_t offNextCmd = pFIFO[SVGA_FIFO_NEXT_CMD];
|
---|
4515 | RT_UNTRUSTED_NONVOLATILE_COPY_FENCE();
|
---|
4516 | if (offNextCmd >= offCurrentCmd)
|
---|
4517 | {
|
---|
4518 | if (RT_LIKELY(offNextCmd < offFifoMax))
|
---|
4519 | cbAfter = offNextCmd - offCurrentCmd;
|
---|
4520 | else
|
---|
4521 | {
|
---|
4522 | STAM_REL_COUNTER_INC(&pSVGAState->StatFifoErrors);
|
---|
4523 | LogRelMax(16, ("vmsvgaR3FifoGetCmdPayload: Invalid offNextCmd=%#x (offFifoMin=%#x offFifoMax=%#x)\n",
|
---|
4524 | offNextCmd, offFifoMin, offFifoMax));
|
---|
4525 | cbAfter = offFifoMax - offCurrentCmd;
|
---|
4526 | }
|
---|
4527 | cbBefore = 0;
|
---|
4528 | }
|
---|
4529 | else
|
---|
4530 | {
|
---|
4531 | cbAfter = offFifoMax - offCurrentCmd;
|
---|
4532 | if (offNextCmd >= offFifoMin)
|
---|
4533 | cbBefore = offNextCmd - offFifoMin;
|
---|
4534 | else
|
---|
4535 | {
|
---|
4536 | STAM_REL_COUNTER_INC(&pSVGAState->StatFifoErrors);
|
---|
4537 | LogRelMax(16, ("vmsvgaR3FifoGetCmdPayload: Invalid offNextCmd=%#x (offFifoMin=%#x offFifoMax=%#x)\n",
|
---|
4538 | offNextCmd, offFifoMin, offFifoMax));
|
---|
4539 | cbBefore = 0;
|
---|
4540 | }
|
---|
4541 | }
|
---|
4542 | if (cbAfter + cbBefore < cbPayloadReq)
|
---|
4543 | {
|
---|
4544 | /*
|
---|
4545 | * Insufficient, must wait for it to arrive.
|
---|
4546 | */
|
---|
4547 | /** @todo Should clear the busy flag here to maybe encourage the guest to wake us up. */
|
---|
4548 | STAM_REL_PROFILE_START(&pSVGAState->StatFifoStalls, Stall);
|
---|
4549 | for (uint32_t i = 0;; i++)
|
---|
4550 | {
|
---|
4551 | if (pThread->enmState != PDMTHREADSTATE_RUNNING)
|
---|
4552 | {
|
---|
4553 | STAM_REL_PROFILE_STOP(&pSVGAState->StatFifoStalls, Stall);
|
---|
4554 | return (void *)(uintptr_t)1;
|
---|
4555 | }
|
---|
4556 | Log(("Guest still copying (%x vs %x) current %x next %x stop %x loop %u; sleep a bit\n",
|
---|
4557 | cbPayloadReq, cbAfter + cbBefore, offCurrentCmd, offNextCmd, pFIFO[SVGA_FIFO_STOP], i));
|
---|
4558 |
|
---|
4559 | PDMDevHlpSUPSemEventWaitNoResume(pDevIns, pThis->svga.hFIFORequestSem, i < 16 ? 1 : 2);
|
---|
4560 |
|
---|
4561 | offNextCmd = pFIFO[SVGA_FIFO_NEXT_CMD];
|
---|
4562 | RT_UNTRUSTED_NONVOLATILE_COPY_FENCE();
|
---|
4563 | if (offNextCmd >= offCurrentCmd)
|
---|
4564 | {
|
---|
4565 | cbAfter = RT_MIN(offNextCmd, offFifoMax) - offCurrentCmd;
|
---|
4566 | cbBefore = 0;
|
---|
4567 | }
|
---|
4568 | else
|
---|
4569 | {
|
---|
4570 | cbAfter = offFifoMax - offCurrentCmd;
|
---|
4571 | cbBefore = RT_MAX(offNextCmd, offFifoMin) - offFifoMin;
|
---|
4572 | }
|
---|
4573 |
|
---|
4574 | if (cbAfter + cbBefore >= cbPayloadReq)
|
---|
4575 | break;
|
---|
4576 | }
|
---|
4577 | STAM_REL_PROFILE_STOP(&pSVGAState->StatFifoStalls, Stall);
|
---|
4578 | }
|
---|
4579 |
|
---|
4580 | /*
|
---|
4581 | * Copy out the memory and update what pcbAlreadyRead points to.
|
---|
4582 | */
|
---|
4583 | if (cbAfter >= cbPayloadReq)
|
---|
4584 | memcpy(pbBounceBuf + cbAlreadyRead,
|
---|
4585 | (uint8_t *)pFIFO + offCurrentCmd + cbAlreadyRead,
|
---|
4586 | cbPayloadReq - cbAlreadyRead);
|
---|
4587 | else
|
---|
4588 | {
|
---|
4589 | LogFlow(("Split data buffer at %x (%u-%u)\n", offCurrentCmd, cbAfter, cbBefore));
|
---|
4590 | if (cbAlreadyRead < cbAfter)
|
---|
4591 | {
|
---|
4592 | memcpy(pbBounceBuf + cbAlreadyRead,
|
---|
4593 | (uint8_t *)pFIFO + offCurrentCmd + cbAlreadyRead,
|
---|
4594 | cbAfter - cbAlreadyRead);
|
---|
4595 | cbAlreadyRead = cbAfter;
|
---|
4596 | }
|
---|
4597 | memcpy(pbBounceBuf + cbAlreadyRead,
|
---|
4598 | (uint8_t *)pFIFO + offFifoMin + cbAlreadyRead - cbAfter,
|
---|
4599 | cbPayloadReq - cbAlreadyRead);
|
---|
4600 | }
|
---|
4601 | *pcbAlreadyRead = cbPayloadReq;
|
---|
4602 | RT_UNTRUSTED_NONVOLATILE_COPY_FENCE();
|
---|
4603 | return pbBounceBuf;
|
---|
4604 | }
|
---|
4605 |
|
---|
4606 |
|
---|
4607 | /**
|
---|
4608 | * Sends cursor position and visibility information from the FIFO to the front-end.
|
---|
4609 | * @returns SVGA_FIFO_CURSOR_COUNT value used.
|
---|
4610 | */
|
---|
4611 | static uint32_t
|
---|
4612 | vmsvgaR3FifoUpdateCursor(PVGASTATECC pThisCC, PVMSVGAR3STATE pSVGAState, uint32_t RT_UNTRUSTED_VOLATILE_GUEST *pFIFO,
|
---|
4613 | uint32_t offFifoMin, uint32_t uCursorUpdateCount,
|
---|
4614 | uint32_t *pxLast, uint32_t *pyLast, uint32_t *pfLastVisible)
|
---|
4615 | {
|
---|
4616 | /*
|
---|
4617 | * Check if the cursor update counter has changed and try get a stable
|
---|
4618 | * set of values if it has. This is race-prone, especially consindering
|
---|
4619 | * the screen ID, but little we can do about that.
|
---|
4620 | */
|
---|
4621 | uint32_t x, y, fVisible, idScreen;
|
---|
4622 | for (uint32_t i = 0; ; i++)
|
---|
4623 | {
|
---|
4624 | x = pFIFO[SVGA_FIFO_CURSOR_X];
|
---|
4625 | y = pFIFO[SVGA_FIFO_CURSOR_Y];
|
---|
4626 | fVisible = pFIFO[SVGA_FIFO_CURSOR_ON];
|
---|
4627 | idScreen = VMSVGA_IS_VALID_FIFO_REG(SVGA_FIFO_CURSOR_SCREEN_ID, offFifoMin)
|
---|
4628 | ? pFIFO[SVGA_FIFO_CURSOR_SCREEN_ID] : SVGA_ID_INVALID;
|
---|
4629 | if ( uCursorUpdateCount == pFIFO[SVGA_FIFO_CURSOR_COUNT]
|
---|
4630 | || i > 3)
|
---|
4631 | break;
|
---|
4632 | if (i == 0)
|
---|
4633 | STAM_REL_COUNTER_INC(&pSVGAState->StatFifoCursorFetchAgain);
|
---|
4634 | ASMNopPause();
|
---|
4635 | uCursorUpdateCount = pFIFO[SVGA_FIFO_CURSOR_COUNT];
|
---|
4636 | }
|
---|
4637 |
|
---|
4638 | /*
|
---|
4639 | * Check if anything has changed, as calling into pDrv is not light-weight.
|
---|
4640 | */
|
---|
4641 | if ( *pxLast == x
|
---|
4642 | && *pyLast == y
|
---|
4643 | && (idScreen != SVGA_ID_INVALID || *pfLastVisible == fVisible))
|
---|
4644 | STAM_REL_COUNTER_INC(&pSVGAState->StatFifoCursorNoChange);
|
---|
4645 | else
|
---|
4646 | {
|
---|
4647 | /*
|
---|
4648 | * Detected changes.
|
---|
4649 | *
|
---|
4650 | * We handle global, not per-screen visibility information by sending
|
---|
4651 | * pfnVBVAMousePointerShape without shape data.
|
---|
4652 | */
|
---|
4653 | *pxLast = x;
|
---|
4654 | *pyLast = y;
|
---|
4655 | uint32_t fFlags = VBVA_CURSOR_VALID_DATA;
|
---|
4656 | if (idScreen != SVGA_ID_INVALID)
|
---|
4657 | fFlags |= VBVA_CURSOR_SCREEN_RELATIVE;
|
---|
4658 | else if (*pfLastVisible != fVisible)
|
---|
4659 | {
|
---|
4660 | LogRel2(("vmsvgaR3FifoUpdateCursor: fVisible %d fLastVisible %d (%d,%d)\n", fVisible, *pfLastVisible, x, y));
|
---|
4661 | *pfLastVisible = fVisible;
|
---|
4662 | pThisCC->pDrv->pfnVBVAMousePointerShape(pThisCC->pDrv, RT_BOOL(fVisible), false, 0, 0, 0, 0, NULL);
|
---|
4663 | STAM_REL_COUNTER_INC(&pSVGAState->StatFifoCursorVisiblity);
|
---|
4664 | }
|
---|
4665 | pThisCC->pDrv->pfnVBVAReportCursorPosition(pThisCC->pDrv, fFlags, idScreen, x, y);
|
---|
4666 | STAM_REL_COUNTER_INC(&pSVGAState->StatFifoCursorPosition);
|
---|
4667 | }
|
---|
4668 |
|
---|
4669 | /*
|
---|
4670 | * Update done. Signal this to the guest.
|
---|
4671 | */
|
---|
4672 | pFIFO[SVGA_FIFO_CURSOR_LAST_UPDATED] = uCursorUpdateCount;
|
---|
4673 |
|
---|
4674 | return uCursorUpdateCount;
|
---|
4675 | }
|
---|
4676 |
|
---|
4677 |
|
---|
4678 | /**
|
---|
4679 | * Checks if there is work to be done, either cursor updating or FIFO commands.
|
---|
4680 | *
|
---|
4681 | * @returns true if pending work, false if not.
|
---|
4682 | * @param pThisCC The VGA/VMSVGA state for ring-3.
|
---|
4683 | * @param uLastCursorCount The last cursor update counter value.
|
---|
4684 | */
|
---|
4685 | DECLINLINE(bool) vmsvgaR3FifoHasWork(PVGASTATECC pThisCC, uint32_t uLastCursorCount)
|
---|
4686 | {
|
---|
4687 | /* If FIFO does not exist than there is nothing to do. Command buffers also require the enabled FIFO. */
|
---|
4688 | uint32_t RT_UNTRUSTED_VOLATILE_GUEST * const pFIFO = pThisCC->svga.pau32FIFO;
|
---|
4689 | AssertReturn(pFIFO, false);
|
---|
4690 |
|
---|
4691 | if (vmsvgaR3CmdBufHasWork(pThisCC))
|
---|
4692 | return true;
|
---|
4693 |
|
---|
4694 | if (pFIFO[SVGA_FIFO_NEXT_CMD] != pFIFO[SVGA_FIFO_STOP])
|
---|
4695 | return true;
|
---|
4696 |
|
---|
4697 | if ( uLastCursorCount != pFIFO[SVGA_FIFO_CURSOR_COUNT]
|
---|
4698 | && VMSVGA_IS_VALID_FIFO_REG(SVGA_FIFO_CURSOR_LAST_UPDATED, pFIFO[SVGA_FIFO_MIN]))
|
---|
4699 | return true;
|
---|
4700 |
|
---|
4701 | return false;
|
---|
4702 | }
|
---|
4703 |
|
---|
4704 |
|
---|
4705 | /**
|
---|
4706 | * Called by the VGA refresh timer to wake up the FIFO thread when needed.
|
---|
4707 | *
|
---|
4708 | * @param pDevIns The device instance.
|
---|
4709 | * @param pThis The shared VGA/VMSVGA instance data.
|
---|
4710 | * @param pThisCC The VGA/VMSVGA state for ring-3.
|
---|
4711 | */
|
---|
4712 | void vmsvgaR3FifoWatchdogTimer(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC)
|
---|
4713 | {
|
---|
4714 | /* Caller already checked pThis->svga.fFIFOThreadSleeping, so we only have
|
---|
4715 | to recheck it before doing the signalling. */
|
---|
4716 | if ( (pThis->fVmSvga3 || vmsvgaR3FifoHasWork(pThisCC, ASMAtomicReadU32(&pThis->svga.uLastCursorUpdateCount)))
|
---|
4717 | && pThis->svga.fFIFOThreadSleeping
|
---|
4718 | && !ASMAtomicReadBool(&pThis->svga.fBadGuest))
|
---|
4719 | {
|
---|
4720 | int rc = PDMDevHlpSUPSemEventSignal(pDevIns, pThis->svga.hFIFORequestSem);
|
---|
4721 | AssertRC(rc);
|
---|
4722 | STAM_REL_COUNTER_INC(&pThisCC->svga.pSvgaR3State->StatFifoWatchdogWakeUps);
|
---|
4723 | }
|
---|
4724 | }
|
---|
4725 |
|
---|
4726 |
|
---|
4727 | /**
|
---|
4728 | * Called by the FIFO thread to process pending actions.
|
---|
4729 | *
|
---|
4730 | * @param pDevIns The device instance.
|
---|
4731 | * @param pThis The shared VGA/VMSVGA instance data.
|
---|
4732 | * @param pThisCC The VGA/VMSVGA state for ring-3.
|
---|
4733 | */
|
---|
4734 | static void vmsvgaR3FifoPendingActions(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC)
|
---|
4735 | {
|
---|
4736 | RT_NOREF(pDevIns);
|
---|
4737 |
|
---|
4738 | /* Currently just mode changes. */
|
---|
4739 | if (ASMBitTestAndClear(&pThis->svga.u32ActionFlags, VMSVGA_ACTION_CHANGEMODE_BIT))
|
---|
4740 | {
|
---|
4741 | vmsvgaR3ChangeMode(pThis, pThisCC);
|
---|
4742 | # ifdef VBOX_WITH_VMSVGA3D
|
---|
4743 | if (pThisCC->svga.p3dState != NULL)
|
---|
4744 | vmsvga3dChangeMode(pThisCC);
|
---|
4745 | # endif
|
---|
4746 | }
|
---|
4747 | }
|
---|
4748 |
|
---|
4749 |
|
---|
4750 | /*
|
---|
4751 | * These two macros are put outside vmsvgaR3FifoLoop because doxygen gets confused,
|
---|
4752 | * even the latest version, and thinks we're documenting vmsvgaR3FifoLoop. Sigh.
|
---|
4753 | */
|
---|
4754 | /** @def VMSVGAFIFO_GET_CMD_BUFFER_BREAK
|
---|
4755 | * Macro for shortening calls to vmsvgaR3FifoGetCmdPayload.
|
---|
4756 | *
|
---|
4757 | * Will break out of the switch on failure.
|
---|
4758 | * Will restart and quit the loop if the thread was requested to stop.
|
---|
4759 | *
|
---|
4760 | * @param a_PtrVar Request variable pointer.
|
---|
4761 | * @param a_Type Request typedef (not pointer) for casting.
|
---|
4762 | * @param a_cbPayloadReq How much payload to fetch.
|
---|
4763 | * @remarks Accesses a bunch of variables in the current scope!
|
---|
4764 | */
|
---|
4765 | # define VMSVGAFIFO_GET_CMD_BUFFER_BREAK(a_PtrVar, a_Type, a_cbPayloadReq) \
|
---|
4766 | if (1) { \
|
---|
4767 | (a_PtrVar) = (a_Type *)vmsvgaR3FifoGetCmdPayload((a_cbPayloadReq), pFIFO, offCurrentCmd, offFifoMin, offFifoMax, \
|
---|
4768 | pbBounceBuf, &cbPayload, pThread, pThis, pSVGAState, pDevIns); \
|
---|
4769 | if (RT_UNLIKELY((uintptr_t)(a_PtrVar) < 2)) { if ((uintptr_t)(a_PtrVar) == 1) continue; break; } \
|
---|
4770 | RT_UNTRUSTED_NONVOLATILE_COPY_FENCE(); \
|
---|
4771 | } else do {} while (0)
|
---|
4772 | /* @def VMSVGAFIFO_GET_MORE_CMD_BUFFER_BREAK
|
---|
4773 | * Macro for shortening calls to vmsvgaR3FifoGetCmdPayload for refetching the
|
---|
4774 | * buffer after figuring out the actual command size.
|
---|
4775 | *
|
---|
4776 | * Will break out of the switch on failure.
|
---|
4777 | *
|
---|
4778 | * @param a_PtrVar Request variable pointer.
|
---|
4779 | * @param a_Type Request typedef (not pointer) for casting.
|
---|
4780 | * @param a_cbPayloadReq How much payload to fetch.
|
---|
4781 | * @remarks Accesses a bunch of variables in the current scope!
|
---|
4782 | */
|
---|
4783 | # define VMSVGAFIFO_GET_MORE_CMD_BUFFER_BREAK(a_PtrVar, a_Type, a_cbPayloadReq) \
|
---|
4784 | if (1) { \
|
---|
4785 | VMSVGAFIFO_GET_CMD_BUFFER_BREAK(a_PtrVar, a_Type, a_cbPayloadReq); \
|
---|
4786 | } else do {} while (0)
|
---|
4787 |
|
---|
4788 | /**
|
---|
4789 | * @callback_method_impl{PFNPDMTHREADDEV, The async FIFO handling thread.}
|
---|
4790 | */
|
---|
4791 | static DECLCALLBACK(int) vmsvgaR3FifoLoop(PPDMDEVINS pDevIns, PPDMTHREAD pThread)
|
---|
4792 | {
|
---|
4793 | PVGASTATE pThis = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
|
---|
4794 | PVGASTATER3 pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC);
|
---|
4795 | PVMSVGAR3STATE pSVGAState = pThisCC->svga.pSvgaR3State;
|
---|
4796 | int rc;
|
---|
4797 |
|
---|
4798 | if (pThread->enmState == PDMTHREADSTATE_INITIALIZING)
|
---|
4799 | return VINF_SUCCESS;
|
---|
4800 |
|
---|
4801 | /*
|
---|
4802 | * Special mode where we only execute an external command and the go back
|
---|
4803 | * to being suspended. Currently, all ext cmds ends up here, with the reset
|
---|
4804 | * one also being eligble for runtime execution further down as well.
|
---|
4805 | */
|
---|
4806 | if (pThis->svga.fFifoExtCommandWakeup)
|
---|
4807 | {
|
---|
4808 | vmsvgaR3FifoHandleExtCmd(pDevIns, pThis, pThisCC);
|
---|
4809 | while (pThread->enmState == PDMTHREADSTATE_RUNNING)
|
---|
4810 | if (pThis->svga.u8FIFOExtCommand == VMSVGA_FIFO_EXTCMD_NONE)
|
---|
4811 | PDMDevHlpSUPSemEventWaitNoResume(pDevIns, pThis->svga.hFIFORequestSem, RT_MS_1MIN);
|
---|
4812 | else
|
---|
4813 | vmsvgaR3FifoHandleExtCmd(pDevIns, pThis, pThisCC);
|
---|
4814 | return VINF_SUCCESS;
|
---|
4815 | }
|
---|
4816 |
|
---|
4817 |
|
---|
4818 | /*
|
---|
4819 | * Signal the semaphore to make sure we don't wait for 250ms after a
|
---|
4820 | * suspend & resume scenario (see vmsvgaR3FifoGetCmdPayload).
|
---|
4821 | */
|
---|
4822 | PDMDevHlpSUPSemEventSignal(pDevIns, pThis->svga.hFIFORequestSem);
|
---|
4823 |
|
---|
4824 | /*
|
---|
4825 | * Allocate a bounce buffer for command we get from the FIFO.
|
---|
4826 | * (All code must return via the end of the function to free this buffer.)
|
---|
4827 | */
|
---|
4828 | uint8_t *pbBounceBuf = (uint8_t *)RTMemAllocZ(pThis->svga.cbFIFO);
|
---|
4829 | AssertReturn(pbBounceBuf, VERR_NO_MEMORY);
|
---|
4830 |
|
---|
4831 | /*
|
---|
4832 | * Polling/sleep interval config.
|
---|
4833 | *
|
---|
4834 | * We wait for an a short interval if the guest has recently given us work
|
---|
4835 | * to do, but the interval increases the longer we're kept idle. Once we've
|
---|
4836 | * reached the refresh timer interval, we'll switch to extended waits,
|
---|
4837 | * depending on it or the guest to kick us into action when needed.
|
---|
4838 | *
|
---|
4839 | * Should the refresh time go fishing, we'll just continue increasing the
|
---|
4840 | * sleep length till we reaches the 250 ms max after about 16 seconds.
|
---|
4841 | */
|
---|
4842 | RTMSINTERVAL const cMsMinSleep = 16;
|
---|
4843 | RTMSINTERVAL const cMsIncSleep = 2;
|
---|
4844 | RTMSINTERVAL const cMsMaxSleep = 250;
|
---|
4845 | RTMSINTERVAL const cMsExtendedSleep = 15 * RT_MS_1SEC; /* Regular paranoia dictates that this cannot be indefinite. */
|
---|
4846 | RTMSINTERVAL cMsSleep = cMsMaxSleep;
|
---|
4847 |
|
---|
4848 | /*
|
---|
4849 | * Cursor update state (SVGA_FIFO_CAP_CURSOR_BYPASS_3).
|
---|
4850 | *
|
---|
4851 | * Initialize with values that will detect an update from the guest.
|
---|
4852 | * Make sure that if the guest never updates the cursor position, then the device does not report it.
|
---|
4853 | * The guest has to change the value of uLastCursorUpdateCount, when the cursor position is actually updated.
|
---|
4854 | * xLastCursor, yLastCursor and fLastCursorVisible are set to report the first update.
|
---|
4855 | */
|
---|
4856 | uint32_t RT_UNTRUSTED_VOLATILE_GUEST * const pFIFO = pThisCC->svga.pau32FIFO;
|
---|
4857 | pThis->svga.uLastCursorUpdateCount = pFIFO[SVGA_FIFO_CURSOR_COUNT];
|
---|
4858 | uint32_t xLastCursor = ~pFIFO[SVGA_FIFO_CURSOR_X];
|
---|
4859 | uint32_t yLastCursor = ~pFIFO[SVGA_FIFO_CURSOR_Y];
|
---|
4860 | uint32_t fLastCursorVisible = ~pFIFO[SVGA_FIFO_CURSOR_ON];
|
---|
4861 |
|
---|
4862 | /*
|
---|
4863 | * The FIFO loop.
|
---|
4864 | */
|
---|
4865 | LogFlow(("vmsvgaR3FifoLoop: started loop\n"));
|
---|
4866 | bool fBadOrDisabledFifo = ASMAtomicReadBool(&pThis->svga.fBadGuest);
|
---|
4867 | while (pThread->enmState == PDMTHREADSTATE_RUNNING)
|
---|
4868 | {
|
---|
4869 | # if defined(RT_OS_DARWIN) && defined(VBOX_WITH_VMSVGA3D)
|
---|
4870 | /*
|
---|
4871 | * Should service the run loop every so often.
|
---|
4872 | */
|
---|
4873 | if (pThis->svga.f3DEnabled)
|
---|
4874 | vmsvga3dCocoaServiceRunLoop();
|
---|
4875 | # endif
|
---|
4876 |
|
---|
4877 | /* First check any pending actions. */
|
---|
4878 | vmsvgaR3FifoPendingActions(pDevIns, pThis, pThisCC);
|
---|
4879 |
|
---|
4880 | /*
|
---|
4881 | * Unless there's already work pending, go to sleep for a short while.
|
---|
4882 | * (See polling/sleep interval config above.)
|
---|
4883 | */
|
---|
4884 | if ( fBadOrDisabledFifo
|
---|
4885 | || !vmsvgaR3FifoHasWork(pThisCC, pThis->svga.uLastCursorUpdateCount))
|
---|
4886 | {
|
---|
4887 | ASMAtomicWriteBool(&pThis->svga.fFIFOThreadSleeping, true);
|
---|
4888 | Assert(pThis->cMilliesRefreshInterval > 0);
|
---|
4889 | if (cMsSleep < pThis->cMilliesRefreshInterval)
|
---|
4890 | rc = PDMDevHlpSUPSemEventWaitNoResume(pDevIns, pThis->svga.hFIFORequestSem, cMsSleep);
|
---|
4891 | else
|
---|
4892 | {
|
---|
4893 | # ifdef VMSVGA_USE_FIFO_ACCESS_HANDLER
|
---|
4894 | int rc2 = PDMDevHlpPGMHandlerPhysicalReset(pDevIns, pThis->svga.GCPhysFIFO);
|
---|
4895 | AssertRC(rc2); /* No break. Racing EMTs unmapping and remapping the region. */
|
---|
4896 | # endif
|
---|
4897 | if ( !fBadOrDisabledFifo
|
---|
4898 | && vmsvgaR3FifoHasWork(pThisCC, pThis->svga.uLastCursorUpdateCount))
|
---|
4899 | rc = VINF_SUCCESS;
|
---|
4900 | else
|
---|
4901 | {
|
---|
4902 | STAM_REL_PROFILE_START(&pSVGAState->StatFifoExtendedSleep, Acc);
|
---|
4903 | rc = PDMDevHlpSUPSemEventWaitNoResume(pDevIns, pThis->svga.hFIFORequestSem, cMsExtendedSleep);
|
---|
4904 | STAM_REL_PROFILE_STOP(&pSVGAState->StatFifoExtendedSleep, Acc);
|
---|
4905 | }
|
---|
4906 | }
|
---|
4907 | ASMAtomicWriteBool(&pThis->svga.fFIFOThreadSleeping, false);
|
---|
4908 | AssertBreak(RT_SUCCESS(rc) || rc == VERR_TIMEOUT || rc == VERR_INTERRUPTED);
|
---|
4909 | if (pThread->enmState != PDMTHREADSTATE_RUNNING)
|
---|
4910 | {
|
---|
4911 | LogFlow(("vmsvgaR3FifoLoop: thread state %x\n", pThread->enmState));
|
---|
4912 | break;
|
---|
4913 | }
|
---|
4914 | }
|
---|
4915 | else
|
---|
4916 | rc = VINF_SUCCESS;
|
---|
4917 | fBadOrDisabledFifo = ASMAtomicReadBool(&pThis->svga.fBadGuest);
|
---|
4918 | if (rc == VERR_TIMEOUT)
|
---|
4919 | {
|
---|
4920 | if (!vmsvgaR3FifoHasWork(pThisCC, pThis->svga.uLastCursorUpdateCount))
|
---|
4921 | {
|
---|
4922 | cMsSleep = RT_MIN(cMsSleep + cMsIncSleep, cMsMaxSleep);
|
---|
4923 | continue;
|
---|
4924 | }
|
---|
4925 | STAM_REL_COUNTER_INC(&pSVGAState->StatFifoTodoTimeout);
|
---|
4926 |
|
---|
4927 | Log(("vmsvgaR3FifoLoop: timeout\n"));
|
---|
4928 | }
|
---|
4929 | else if (vmsvgaR3FifoHasWork(pThisCC, pThis->svga.uLastCursorUpdateCount))
|
---|
4930 | STAM_REL_COUNTER_INC(&pSVGAState->StatFifoTodoWoken);
|
---|
4931 | cMsSleep = cMsMinSleep;
|
---|
4932 |
|
---|
4933 | Log(("vmsvgaR3FifoLoop: enabled=%d configured=%d busy=%d\n", pThis->svga.fEnabled, pThis->svga.fConfigured, pFIFO[SVGA_FIFO_BUSY]));
|
---|
4934 | Log(("vmsvgaR3FifoLoop: min %x max %x\n", pFIFO[SVGA_FIFO_MIN], pFIFO[SVGA_FIFO_MAX]));
|
---|
4935 | Log(("vmsvgaR3FifoLoop: next %x stop %x\n", pFIFO[SVGA_FIFO_NEXT_CMD], pFIFO[SVGA_FIFO_STOP]));
|
---|
4936 |
|
---|
4937 | /*
|
---|
4938 | * Handle external commands (currently only reset).
|
---|
4939 | */
|
---|
4940 | if (pThis->svga.u8FIFOExtCommand != VMSVGA_FIFO_EXTCMD_NONE)
|
---|
4941 | {
|
---|
4942 | vmsvgaR3FifoHandleExtCmd(pDevIns, pThis, pThisCC);
|
---|
4943 | continue;
|
---|
4944 | }
|
---|
4945 |
|
---|
4946 | /*
|
---|
4947 | * If guest misbehaves, then do nothing.
|
---|
4948 | */
|
---|
4949 | if (ASMAtomicReadBool(&pThis->svga.fBadGuest))
|
---|
4950 | {
|
---|
4951 | vmsvgaR3FifoSetNotBusy(pDevIns, pThis, pThisCC, pSVGAState, pFIFO[SVGA_FIFO_MIN]);
|
---|
4952 | cMsSleep = cMsExtendedSleep;
|
---|
4953 | LogRelMax(1, ("VMSVGA: FIFO processing stopped because of the guest misbehavior\n"));
|
---|
4954 | continue;
|
---|
4955 | }
|
---|
4956 |
|
---|
4957 | /*
|
---|
4958 | * The device must be enabled and configured.
|
---|
4959 | */
|
---|
4960 | if ( !pThis->svga.fEnabled
|
---|
4961 | || !pThis->svga.fConfigured)
|
---|
4962 | {
|
---|
4963 | vmsvgaR3FifoSetNotBusy(pDevIns, pThis, pThisCC, pSVGAState, pFIFO[SVGA_FIFO_MIN]);
|
---|
4964 | fBadOrDisabledFifo = true;
|
---|
4965 | cMsSleep = cMsMaxSleep; /* cheat */
|
---|
4966 | continue;
|
---|
4967 | }
|
---|
4968 |
|
---|
4969 | /*
|
---|
4970 | * Get and check the min/max values. We ASSUME that they will remain
|
---|
4971 | * unchanged while we process requests. A further ASSUMPTION is that
|
---|
4972 | * the guest won't mess with SVGA_FIFO_NEXT_CMD while we're busy, so
|
---|
4973 | * we don't read it back while in the loop.
|
---|
4974 | */
|
---|
4975 | uint32_t const offFifoMin = pFIFO[SVGA_FIFO_MIN];
|
---|
4976 | uint32_t const offFifoMax = pFIFO[SVGA_FIFO_MAX];
|
---|
4977 | uint32_t offCurrentCmd = pFIFO[SVGA_FIFO_STOP];
|
---|
4978 | RT_UNTRUSTED_NONVOLATILE_COPY_FENCE();
|
---|
4979 | if (RT_UNLIKELY( !VMSVGA_IS_VALID_FIFO_REG(SVGA_FIFO_STOP, offFifoMin)
|
---|
4980 | || offFifoMax <= offFifoMin
|
---|
4981 | || offFifoMax > pThis->svga.cbFIFO
|
---|
4982 | || (offFifoMax & 3) != 0
|
---|
4983 | || (offFifoMin & 3) != 0
|
---|
4984 | || offCurrentCmd < offFifoMin
|
---|
4985 | || offCurrentCmd > offFifoMax))
|
---|
4986 | {
|
---|
4987 | STAM_REL_COUNTER_INC(&pSVGAState->StatFifoErrors);
|
---|
4988 | LogRelMax(8, ("vmsvgaR3FifoLoop: Bad fifo: min=%#x stop=%#x max=%#x\n", offFifoMin, offCurrentCmd, offFifoMax));
|
---|
4989 | vmsvgaR3FifoSetNotBusy(pDevIns, pThis, pThisCC, pSVGAState, offFifoMin);
|
---|
4990 | fBadOrDisabledFifo = true;
|
---|
4991 | continue;
|
---|
4992 | }
|
---|
4993 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
4994 | if (RT_UNLIKELY(offCurrentCmd & 3))
|
---|
4995 | {
|
---|
4996 | STAM_REL_COUNTER_INC(&pSVGAState->StatFifoErrors);
|
---|
4997 | LogRelMax(8, ("vmsvgaR3FifoLoop: Misaligned offCurrentCmd=%#x?\n", offCurrentCmd));
|
---|
4998 | offCurrentCmd &= ~UINT32_C(3);
|
---|
4999 | }
|
---|
5000 |
|
---|
5001 | /*
|
---|
5002 | * Update the cursor position before we start on the FIFO commands.
|
---|
5003 | */
|
---|
5004 | /** @todo do we need to check whether the guest disabled the SVGA_FIFO_CAP_CURSOR_BYPASS_3 capability here? */
|
---|
5005 | if (VMSVGA_IS_VALID_FIFO_REG(SVGA_FIFO_CURSOR_LAST_UPDATED, offFifoMin))
|
---|
5006 | {
|
---|
5007 | uint32_t const uCursorUpdateCount = pFIFO[SVGA_FIFO_CURSOR_COUNT];
|
---|
5008 | if (uCursorUpdateCount == pThis->svga.uLastCursorUpdateCount)
|
---|
5009 | { /* halfways likely */ }
|
---|
5010 | else
|
---|
5011 | {
|
---|
5012 | uint32_t const uNewCount = vmsvgaR3FifoUpdateCursor(pThisCC, pSVGAState, pFIFO, offFifoMin, uCursorUpdateCount,
|
---|
5013 | &xLastCursor, &yLastCursor, &fLastCursorVisible);
|
---|
5014 | ASMAtomicWriteU32(&pThis->svga.uLastCursorUpdateCount, uNewCount);
|
---|
5015 | }
|
---|
5016 | }
|
---|
5017 |
|
---|
5018 | /*
|
---|
5019 | * Mark the FIFO as busy.
|
---|
5020 | */
|
---|
5021 | ASMAtomicWriteU32(&pThis->svga.fBusy, VMSVGA_BUSY_F_FIFO); // Clears VMSVGA_BUSY_F_EMT_FORCE!
|
---|
5022 | if (VMSVGA_IS_VALID_FIFO_REG(SVGA_FIFO_BUSY, offFifoMin))
|
---|
5023 | ASMAtomicWriteU32(&pFIFO[SVGA_FIFO_BUSY], true);
|
---|
5024 |
|
---|
5025 | /*
|
---|
5026 | * Process all submitted command buffers.
|
---|
5027 | */
|
---|
5028 | vmsvgaR3CmdBufProcessBuffers(pDevIns, pThis, pThisCC, pThread);
|
---|
5029 |
|
---|
5030 | /*
|
---|
5031 | * Execute all queued FIFO commands.
|
---|
5032 | * Quit if pending external command or changes in the thread state.
|
---|
5033 | */
|
---|
5034 | bool fDone = false;
|
---|
5035 | while ( !(fDone = (pFIFO[SVGA_FIFO_NEXT_CMD] == offCurrentCmd))
|
---|
5036 | && pThread->enmState == PDMTHREADSTATE_RUNNING)
|
---|
5037 | {
|
---|
5038 | uint32_t cbPayload = 0;
|
---|
5039 | uint32_t u32IrqStatus = 0;
|
---|
5040 |
|
---|
5041 | Assert(offCurrentCmd < offFifoMax && offCurrentCmd >= offFifoMin);
|
---|
5042 |
|
---|
5043 | /* First check any pending actions. */
|
---|
5044 | vmsvgaR3FifoPendingActions(pDevIns, pThis, pThisCC);
|
---|
5045 |
|
---|
5046 | /* Check for pending external commands (reset). */
|
---|
5047 | if (pThis->svga.u8FIFOExtCommand != VMSVGA_FIFO_EXTCMD_NONE)
|
---|
5048 | break;
|
---|
5049 |
|
---|
5050 | /*
|
---|
5051 | * Process the command.
|
---|
5052 | */
|
---|
5053 | /* 'enmCmdId' is actually a SVGAFifoCmdId. It is treated as uint32_t in order to avoid a compiler
|
---|
5054 | * warning. Because we implement some obsolete and deprecated commands, which are not included in
|
---|
5055 | * the SVGAFifoCmdId enum in the VMSVGA headers anymore.
|
---|
5056 | */
|
---|
5057 | uint32_t const enmCmdId = pFIFO[offCurrentCmd / sizeof(uint32_t)];
|
---|
5058 | RT_UNTRUSTED_NONVOLATILE_COPY_FENCE();
|
---|
5059 | LogFlow(("vmsvgaR3FifoLoop: FIFO command (iCmd=0x%x) %s %d\n",
|
---|
5060 | offCurrentCmd / sizeof(uint32_t), vmsvgaR3FifoCmdToString(enmCmdId), enmCmdId));
|
---|
5061 | switch (enmCmdId)
|
---|
5062 | {
|
---|
5063 | case SVGA_CMD_INVALID_CMD:
|
---|
5064 | /* Nothing to do. */
|
---|
5065 | STAM_REL_COUNTER_INC(&pSVGAState->StatR3CmdInvalidCmd);
|
---|
5066 | break;
|
---|
5067 |
|
---|
5068 | case SVGA_CMD_FENCE:
|
---|
5069 | {
|
---|
5070 | SVGAFifoCmdFence *pCmdFence;
|
---|
5071 | VMSVGAFIFO_GET_CMD_BUFFER_BREAK(pCmdFence, SVGAFifoCmdFence, sizeof(*pCmdFence));
|
---|
5072 | STAM_REL_COUNTER_INC(&pSVGAState->StatR3CmdFence);
|
---|
5073 | if (VMSVGA_IS_VALID_FIFO_REG(SVGA_FIFO_FENCE, offFifoMin))
|
---|
5074 | {
|
---|
5075 | Log(("vmsvgaR3FifoLoop: SVGA_CMD_FENCE %#x\n", pCmdFence->fence));
|
---|
5076 | pFIFO[SVGA_FIFO_FENCE] = pCmdFence->fence;
|
---|
5077 |
|
---|
5078 | if (pThis->svga.u32IrqMask & SVGA_IRQFLAG_ANY_FENCE)
|
---|
5079 | {
|
---|
5080 | Log(("vmsvgaR3FifoLoop: any fence irq\n"));
|
---|
5081 | u32IrqStatus |= SVGA_IRQFLAG_ANY_FENCE;
|
---|
5082 | }
|
---|
5083 | else
|
---|
5084 | if ( VMSVGA_IS_VALID_FIFO_REG(SVGA_FIFO_FENCE_GOAL, offFifoMin)
|
---|
5085 | && (pThis->svga.u32IrqMask & SVGA_IRQFLAG_FENCE_GOAL)
|
---|
5086 | && pFIFO[SVGA_FIFO_FENCE_GOAL] == pCmdFence->fence)
|
---|
5087 | {
|
---|
5088 | Log(("vmsvgaR3FifoLoop: fence goal reached irq (fence=%#x)\n", pCmdFence->fence));
|
---|
5089 | u32IrqStatus |= SVGA_IRQFLAG_FENCE_GOAL;
|
---|
5090 | }
|
---|
5091 | }
|
---|
5092 | else
|
---|
5093 | Log(("SVGA_CMD_FENCE is bogus when offFifoMin is %#x!\n", offFifoMin));
|
---|
5094 | break;
|
---|
5095 | }
|
---|
5096 |
|
---|
5097 | case SVGA_CMD_UPDATE:
|
---|
5098 | {
|
---|
5099 | SVGAFifoCmdUpdate *pCmd;
|
---|
5100 | VMSVGAFIFO_GET_CMD_BUFFER_BREAK(pCmd, SVGAFifoCmdUpdate, sizeof(*pCmd));
|
---|
5101 | vmsvgaR3CmdUpdate(pThis, pThisCC, pCmd);
|
---|
5102 | break;
|
---|
5103 | }
|
---|
5104 |
|
---|
5105 | case SVGA_CMD_UPDATE_VERBOSE:
|
---|
5106 | {
|
---|
5107 | SVGAFifoCmdUpdateVerbose *pCmd;
|
---|
5108 | VMSVGAFIFO_GET_CMD_BUFFER_BREAK(pCmd, SVGAFifoCmdUpdateVerbose, sizeof(*pCmd));
|
---|
5109 | vmsvgaR3CmdUpdateVerbose(pThis, pThisCC, pCmd);
|
---|
5110 | break;
|
---|
5111 | }
|
---|
5112 |
|
---|
5113 | case SVGA_CMD_DEFINE_CURSOR:
|
---|
5114 | {
|
---|
5115 | /* Followed by bitmap data. */
|
---|
5116 | SVGAFifoCmdDefineCursor *pCmd;
|
---|
5117 | VMSVGAFIFO_GET_CMD_BUFFER_BREAK(pCmd, SVGAFifoCmdDefineCursor, sizeof(*pCmd));
|
---|
5118 |
|
---|
5119 | /* Figure out the size of the bitmap data. */
|
---|
5120 | ASSERT_GUEST_BREAK(pCmd->height < 2048 && pCmd->width < 2048);
|
---|
5121 | ASSERT_GUEST_BREAK(pCmd->andMaskDepth <= 32);
|
---|
5122 | ASSERT_GUEST_BREAK(pCmd->xorMaskDepth <= 32);
|
---|
5123 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
5124 |
|
---|
5125 | uint32_t const cbAndLine = RT_ALIGN_32(pCmd->width * (pCmd->andMaskDepth + (pCmd->andMaskDepth == 15)), 32) / 8;
|
---|
5126 | uint32_t const cbAndMask = cbAndLine * pCmd->height;
|
---|
5127 | uint32_t const cbXorLine = RT_ALIGN_32(pCmd->width * (pCmd->xorMaskDepth + (pCmd->xorMaskDepth == 15)), 32) / 8;
|
---|
5128 | uint32_t const cbXorMask = cbXorLine * pCmd->height;
|
---|
5129 |
|
---|
5130 | uint32_t const cbCmd = sizeof(SVGAFifoCmdDefineCursor) + cbAndMask + cbXorMask;
|
---|
5131 | VMSVGAFIFO_GET_MORE_CMD_BUFFER_BREAK(pCmd, SVGAFifoCmdDefineCursor, cbCmd);
|
---|
5132 | vmsvgaR3CmdDefineCursor(pThis, pThisCC, pCmd);
|
---|
5133 | break;
|
---|
5134 | }
|
---|
5135 |
|
---|
5136 | case SVGA_CMD_DEFINE_ALPHA_CURSOR:
|
---|
5137 | {
|
---|
5138 | /* Followed by bitmap data. */
|
---|
5139 | SVGAFifoCmdDefineAlphaCursor *pCmd;
|
---|
5140 | VMSVGAFIFO_GET_CMD_BUFFER_BREAK(pCmd, SVGAFifoCmdDefineAlphaCursor, sizeof(*pCmd));
|
---|
5141 |
|
---|
5142 | /* Figure out the size of the bitmap data. */
|
---|
5143 | ASSERT_GUEST_BREAK(pCmd->height < 2048 && pCmd->width < 2048);
|
---|
5144 |
|
---|
5145 | uint32_t const cbCmd = sizeof(SVGAFifoCmdDefineAlphaCursor) + pCmd->width * pCmd->height * sizeof(uint32_t) /* 32-bit BRGA format */;
|
---|
5146 | VMSVGAFIFO_GET_MORE_CMD_BUFFER_BREAK(pCmd, SVGAFifoCmdDefineAlphaCursor, cbCmd);
|
---|
5147 | vmsvgaR3CmdDefineAlphaCursor(pThis, pThisCC, pCmd);
|
---|
5148 | break;
|
---|
5149 | }
|
---|
5150 |
|
---|
5151 | case SVGA_CMD_MOVE_CURSOR:
|
---|
5152 | {
|
---|
5153 | /* Deprecated; there should be no driver which *requires* this command. However, if
|
---|
5154 | * we do ecncounter this command, it might be useful to not get the FIFO completely out of
|
---|
5155 | * alignment.
|
---|
5156 | * May be issued by guest if SVGA_CAP_CURSOR_BYPASS is missing.
|
---|
5157 | */
|
---|
5158 | SVGAFifoCmdMoveCursor *pCmd;
|
---|
5159 | VMSVGAFIFO_GET_CMD_BUFFER_BREAK(pCmd, SVGAFifoCmdMoveCursor, sizeof(*pCmd));
|
---|
5160 | vmsvgaR3CmdMoveCursor(pThis, pThisCC, pCmd);
|
---|
5161 | break;
|
---|
5162 | }
|
---|
5163 |
|
---|
5164 | case SVGA_CMD_DISPLAY_CURSOR:
|
---|
5165 | {
|
---|
5166 | /* Deprecated; there should be no driver which *requires* this command. However, if
|
---|
5167 | * we do ecncounter this command, it might be useful to not get the FIFO completely out of
|
---|
5168 | * alignment.
|
---|
5169 | * May be issued by guest if SVGA_CAP_CURSOR_BYPASS is missing.
|
---|
5170 | */
|
---|
5171 | SVGAFifoCmdDisplayCursor *pCmd;
|
---|
5172 | VMSVGAFIFO_GET_CMD_BUFFER_BREAK(pCmd, SVGAFifoCmdDisplayCursor, sizeof(*pCmd));
|
---|
5173 | vmsvgaR3CmdDisplayCursor(pThis, pThisCC, pCmd);
|
---|
5174 | break;
|
---|
5175 | }
|
---|
5176 |
|
---|
5177 | case SVGA_CMD_RECT_FILL:
|
---|
5178 | {
|
---|
5179 | SVGAFifoCmdRectFill *pCmd;
|
---|
5180 | VMSVGAFIFO_GET_CMD_BUFFER_BREAK(pCmd, SVGAFifoCmdRectFill, sizeof(*pCmd));
|
---|
5181 | vmsvgaR3CmdRectFill(pThis, pThisCC, pCmd);
|
---|
5182 | break;
|
---|
5183 | }
|
---|
5184 |
|
---|
5185 | case SVGA_CMD_RECT_COPY:
|
---|
5186 | {
|
---|
5187 | SVGAFifoCmdRectCopy *pCmd;
|
---|
5188 | VMSVGAFIFO_GET_CMD_BUFFER_BREAK(pCmd, SVGAFifoCmdRectCopy, sizeof(*pCmd));
|
---|
5189 | vmsvgaR3CmdRectCopy(pThis, pThisCC, pCmd);
|
---|
5190 | break;
|
---|
5191 | }
|
---|
5192 |
|
---|
5193 | case SVGA_CMD_RECT_ROP_COPY:
|
---|
5194 | {
|
---|
5195 | SVGAFifoCmdRectRopCopy *pCmd;
|
---|
5196 | VMSVGAFIFO_GET_CMD_BUFFER_BREAK(pCmd, SVGAFifoCmdRectRopCopy, sizeof(*pCmd));
|
---|
5197 | vmsvgaR3CmdRectRopCopy(pThis, pThisCC, pCmd);
|
---|
5198 | break;
|
---|
5199 | }
|
---|
5200 |
|
---|
5201 | case SVGA_CMD_ESCAPE:
|
---|
5202 | {
|
---|
5203 | /* Followed by 'size' bytes of data. */
|
---|
5204 | SVGAFifoCmdEscape *pCmd;
|
---|
5205 | VMSVGAFIFO_GET_CMD_BUFFER_BREAK(pCmd, SVGAFifoCmdEscape, sizeof(*pCmd));
|
---|
5206 |
|
---|
5207 | ASSERT_GUEST_BREAK(pCmd->size < pThis->svga.cbFIFO - sizeof(SVGAFifoCmdEscape));
|
---|
5208 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
5209 |
|
---|
5210 | uint32_t const cbCmd = sizeof(SVGAFifoCmdEscape) + pCmd->size;
|
---|
5211 | VMSVGAFIFO_GET_MORE_CMD_BUFFER_BREAK(pCmd, SVGAFifoCmdEscape, cbCmd);
|
---|
5212 | vmsvgaR3CmdEscape(pThis, pThisCC, pCmd);
|
---|
5213 | break;
|
---|
5214 | }
|
---|
5215 | # ifdef VBOX_WITH_VMSVGA3D
|
---|
5216 | case SVGA_CMD_DEFINE_GMR2:
|
---|
5217 | {
|
---|
5218 | SVGAFifoCmdDefineGMR2 *pCmd;
|
---|
5219 | VMSVGAFIFO_GET_CMD_BUFFER_BREAK(pCmd, SVGAFifoCmdDefineGMR2, sizeof(*pCmd));
|
---|
5220 | vmsvgaR3CmdDefineGMR2(pThis, pThisCC, pCmd);
|
---|
5221 | break;
|
---|
5222 | }
|
---|
5223 |
|
---|
5224 | case SVGA_CMD_REMAP_GMR2:
|
---|
5225 | {
|
---|
5226 | /* Followed by page descriptors or guest ptr. */
|
---|
5227 | SVGAFifoCmdRemapGMR2 *pCmd;
|
---|
5228 | VMSVGAFIFO_GET_CMD_BUFFER_BREAK(pCmd, SVGAFifoCmdRemapGMR2, sizeof(*pCmd));
|
---|
5229 |
|
---|
5230 | /* Calculate the size of what comes after next and fetch it. */
|
---|
5231 | uint32_t cbCmd = sizeof(SVGAFifoCmdRemapGMR2);
|
---|
5232 | if (pCmd->flags & SVGA_REMAP_GMR2_VIA_GMR)
|
---|
5233 | cbCmd += sizeof(SVGAGuestPtr);
|
---|
5234 | else
|
---|
5235 | {
|
---|
5236 | uint32_t const cbPageDesc = (pCmd->flags & SVGA_REMAP_GMR2_PPN64) ? sizeof(uint64_t) : sizeof(uint32_t);
|
---|
5237 | if (pCmd->flags & SVGA_REMAP_GMR2_SINGLE_PPN)
|
---|
5238 | {
|
---|
5239 | cbCmd += cbPageDesc;
|
---|
5240 | pCmd->numPages = 1;
|
---|
5241 | }
|
---|
5242 | else
|
---|
5243 | {
|
---|
5244 | ASSERT_GUEST_BREAK(pCmd->numPages <= pThis->svga.cbFIFO / cbPageDesc);
|
---|
5245 | cbCmd += cbPageDesc * pCmd->numPages;
|
---|
5246 | }
|
---|
5247 | }
|
---|
5248 | VMSVGAFIFO_GET_MORE_CMD_BUFFER_BREAK(pCmd, SVGAFifoCmdRemapGMR2, cbCmd);
|
---|
5249 | vmsvgaR3CmdRemapGMR2(pThis, pThisCC, pCmd);
|
---|
5250 | # ifdef DEBUG_GMR_ACCESS
|
---|
5251 | VMR3ReqCallWaitU(PDMDevHlpGetUVM(pDevIns), VMCPUID_ANY, (PFNRT)vmsvgaR3RegisterGmr, 2, pDevIns, pCmd->gmrId);
|
---|
5252 | # endif
|
---|
5253 | break;
|
---|
5254 | }
|
---|
5255 | # endif // VBOX_WITH_VMSVGA3D
|
---|
5256 | case SVGA_CMD_DEFINE_SCREEN:
|
---|
5257 | {
|
---|
5258 | /* The size of this command is specified by the guest and depends on capabilities. */
|
---|
5259 | Assert(pFIFO[SVGA_FIFO_CAPABILITIES] & SVGA_FIFO_CAP_SCREEN_OBJECT_2);
|
---|
5260 |
|
---|
5261 | SVGAFifoCmdDefineScreen *pCmd;
|
---|
5262 | VMSVGAFIFO_GET_CMD_BUFFER_BREAK(pCmd, SVGAFifoCmdDefineScreen, sizeof(pCmd->screen.structSize));
|
---|
5263 | AssertBreak(pCmd->screen.structSize < pThis->svga.cbFIFO);
|
---|
5264 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
5265 |
|
---|
5266 | RT_BZERO(&pCmd->screen.id, sizeof(*pCmd) - RT_OFFSETOF(SVGAFifoCmdDefineScreen, screen.id));
|
---|
5267 | VMSVGAFIFO_GET_MORE_CMD_BUFFER_BREAK(pCmd, SVGAFifoCmdDefineScreen, RT_MAX(sizeof(pCmd->screen.structSize), pCmd->screen.structSize));
|
---|
5268 | vmsvgaR3CmdDefineScreen(pThis, pThisCC, pCmd);
|
---|
5269 | break;
|
---|
5270 | }
|
---|
5271 |
|
---|
5272 | case SVGA_CMD_DESTROY_SCREEN:
|
---|
5273 | {
|
---|
5274 | SVGAFifoCmdDestroyScreen *pCmd;
|
---|
5275 | VMSVGAFIFO_GET_CMD_BUFFER_BREAK(pCmd, SVGAFifoCmdDestroyScreen, sizeof(*pCmd));
|
---|
5276 | vmsvgaR3CmdDestroyScreen(pThis, pThisCC, pCmd);
|
---|
5277 | break;
|
---|
5278 | }
|
---|
5279 |
|
---|
5280 | case SVGA_CMD_DEFINE_GMRFB:
|
---|
5281 | {
|
---|
5282 | SVGAFifoCmdDefineGMRFB *pCmd;
|
---|
5283 | VMSVGAFIFO_GET_CMD_BUFFER_BREAK(pCmd, SVGAFifoCmdDefineGMRFB, sizeof(*pCmd));
|
---|
5284 | vmsvgaR3CmdDefineGMRFB(pThis, pThisCC, pCmd);
|
---|
5285 | break;
|
---|
5286 | }
|
---|
5287 |
|
---|
5288 | case SVGA_CMD_BLIT_GMRFB_TO_SCREEN:
|
---|
5289 | {
|
---|
5290 | SVGAFifoCmdBlitGMRFBToScreen *pCmd;
|
---|
5291 | VMSVGAFIFO_GET_CMD_BUFFER_BREAK(pCmd, SVGAFifoCmdBlitGMRFBToScreen, sizeof(*pCmd));
|
---|
5292 | vmsvgaR3CmdBlitGMRFBToScreen(pThis, pThisCC, pCmd);
|
---|
5293 | break;
|
---|
5294 | }
|
---|
5295 |
|
---|
5296 | case SVGA_CMD_BLIT_SCREEN_TO_GMRFB:
|
---|
5297 | {
|
---|
5298 | SVGAFifoCmdBlitScreenToGMRFB *pCmd;
|
---|
5299 | VMSVGAFIFO_GET_CMD_BUFFER_BREAK(pCmd, SVGAFifoCmdBlitScreenToGMRFB, sizeof(*pCmd));
|
---|
5300 | vmsvgaR3CmdBlitScreenToGMRFB(pThis, pThisCC, pCmd);
|
---|
5301 | break;
|
---|
5302 | }
|
---|
5303 |
|
---|
5304 | case SVGA_CMD_ANNOTATION_FILL:
|
---|
5305 | {
|
---|
5306 | SVGAFifoCmdAnnotationFill *pCmd;
|
---|
5307 | VMSVGAFIFO_GET_CMD_BUFFER_BREAK(pCmd, SVGAFifoCmdAnnotationFill, sizeof(*pCmd));
|
---|
5308 | vmsvgaR3CmdAnnotationFill(pThis, pThisCC, pCmd);
|
---|
5309 | break;
|
---|
5310 | }
|
---|
5311 |
|
---|
5312 | case SVGA_CMD_ANNOTATION_COPY:
|
---|
5313 | {
|
---|
5314 | SVGAFifoCmdAnnotationCopy *pCmd;
|
---|
5315 | VMSVGAFIFO_GET_CMD_BUFFER_BREAK(pCmd, SVGAFifoCmdAnnotationCopy, sizeof(*pCmd));
|
---|
5316 | vmsvgaR3CmdAnnotationCopy(pThis, pThisCC, pCmd);
|
---|
5317 | break;
|
---|
5318 | }
|
---|
5319 |
|
---|
5320 | default:
|
---|
5321 | # ifdef VBOX_WITH_VMSVGA3D
|
---|
5322 | if ( ((int)enmCmdId >= SVGA_3D_CMD_BASE && (int)enmCmdId < SVGA_3D_CMD_MAX)
|
---|
5323 | || ( pThis->svga.fVBoxExtensions
|
---|
5324 | && ((int)enmCmdId >= VBSVGA_3D_CMD_BASE && (int)enmCmdId < VBSVGA_3D_CMD_MAX)))
|
---|
5325 | {
|
---|
5326 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
5327 |
|
---|
5328 | /* All 3d commands start with a common header, which defines the identifier and the size
|
---|
5329 | * of the command. The identifier has been already read from FIFO. Fetch the size.
|
---|
5330 | */
|
---|
5331 | uint32_t *pcbCmd;
|
---|
5332 | VMSVGAFIFO_GET_CMD_BUFFER_BREAK(pcbCmd, uint32_t, sizeof(*pcbCmd));
|
---|
5333 | uint32_t const cbCmd = *pcbCmd;
|
---|
5334 | AssertBreak(cbCmd < pThis->svga.cbFIFO);
|
---|
5335 | uint32_t *pu32Cmd;
|
---|
5336 | VMSVGAFIFO_GET_MORE_CMD_BUFFER_BREAK(pu32Cmd, uint32_t, sizeof(*pcbCmd) + cbCmd);
|
---|
5337 | pu32Cmd++; /* Skip the command size. */
|
---|
5338 |
|
---|
5339 | if (RT_LIKELY(pThis->svga.f3DEnabled))
|
---|
5340 | { /* likely */ }
|
---|
5341 | else
|
---|
5342 | {
|
---|
5343 | LogRelMax(8, ("VMSVGA: 3D disabled, command %d skipped\n", enmCmdId));
|
---|
5344 | break;
|
---|
5345 | }
|
---|
5346 |
|
---|
5347 | vmsvgaR3Process3dCmd(pThis, pThisCC, SVGA3D_INVALID_ID, (SVGAFifo3dCmdId)enmCmdId, cbCmd, pu32Cmd);
|
---|
5348 | }
|
---|
5349 | else
|
---|
5350 | # endif // VBOX_WITH_VMSVGA3D
|
---|
5351 | {
|
---|
5352 | STAM_REL_COUNTER_INC(&pSVGAState->StatFifoUnkCmds);
|
---|
5353 | AssertMsgFailed(("enmCmdId=%d\n", enmCmdId));
|
---|
5354 | LogRelMax(16, ("VMSVGA: unsupported command %d\n", enmCmdId));
|
---|
5355 | }
|
---|
5356 | }
|
---|
5357 |
|
---|
5358 | /* Go to the next slot */
|
---|
5359 | Assert(cbPayload + sizeof(uint32_t) <= offFifoMax - offFifoMin);
|
---|
5360 | offCurrentCmd += RT_ALIGN_32(cbPayload + sizeof(uint32_t), sizeof(uint32_t));
|
---|
5361 | if (offCurrentCmd >= offFifoMax)
|
---|
5362 | {
|
---|
5363 | offCurrentCmd -= offFifoMax - offFifoMin;
|
---|
5364 | Assert(offCurrentCmd >= offFifoMin);
|
---|
5365 | Assert(offCurrentCmd < offFifoMax);
|
---|
5366 | }
|
---|
5367 | ASMAtomicWriteU32(&pFIFO[SVGA_FIFO_STOP], offCurrentCmd);
|
---|
5368 | STAM_REL_COUNTER_INC(&pSVGAState->StatFifoCommands);
|
---|
5369 |
|
---|
5370 | /*
|
---|
5371 | * Raise IRQ if required. Must enter the critical section here
|
---|
5372 | * before making final decisions here, otherwise cubebench and
|
---|
5373 | * others may end up waiting forever.
|
---|
5374 | */
|
---|
5375 | if ( u32IrqStatus
|
---|
5376 | || (pThis->svga.u32IrqMask & SVGA_IRQFLAG_FIFO_PROGRESS))
|
---|
5377 | {
|
---|
5378 | int const rcLock = PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED);
|
---|
5379 | PDM_CRITSECT_RELEASE_ASSERT_RC_DEV(pDevIns, &pThis->CritSect, rcLock);
|
---|
5380 |
|
---|
5381 | /* FIFO progress might trigger an interrupt. */
|
---|
5382 | if (pThis->svga.u32IrqMask & SVGA_IRQFLAG_FIFO_PROGRESS)
|
---|
5383 | {
|
---|
5384 | Log(("vmsvgaR3FifoLoop: fifo progress irq\n"));
|
---|
5385 | u32IrqStatus |= SVGA_IRQFLAG_FIFO_PROGRESS;
|
---|
5386 | }
|
---|
5387 |
|
---|
5388 | /* Unmasked IRQ pending? */
|
---|
5389 | if (pThis->svga.u32IrqMask & u32IrqStatus)
|
---|
5390 | {
|
---|
5391 | Log(("vmsvgaR3FifoLoop: Trigger interrupt with status %x\n", u32IrqStatus));
|
---|
5392 | ASMAtomicOrU32(&pThis->svga.u32IrqStatus, u32IrqStatus);
|
---|
5393 | PDMDevHlpPCISetIrq(pDevIns, 0, 1);
|
---|
5394 | }
|
---|
5395 |
|
---|
5396 | PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect);
|
---|
5397 | }
|
---|
5398 | }
|
---|
5399 |
|
---|
5400 | /* If really done, clear the busy flag. */
|
---|
5401 | if (fDone)
|
---|
5402 | {
|
---|
5403 | Log(("vmsvgaR3FifoLoop: emptied the FIFO next=%x stop=%x\n", pFIFO[SVGA_FIFO_NEXT_CMD], offCurrentCmd));
|
---|
5404 | vmsvgaR3FifoSetNotBusy(pDevIns, pThis, pThisCC, pSVGAState, offFifoMin);
|
---|
5405 | }
|
---|
5406 | }
|
---|
5407 |
|
---|
5408 | /*
|
---|
5409 | * Free the bounce buffer. (There are no returns above!)
|
---|
5410 | */
|
---|
5411 | RTMemFree(pbBounceBuf);
|
---|
5412 |
|
---|
5413 | return VINF_SUCCESS;
|
---|
5414 | }
|
---|
5415 |
|
---|
5416 | #undef VMSVGAFIFO_GET_MORE_CMD_BUFFER_BREAK
|
---|
5417 | #undef VMSVGAFIFO_GET_CMD_BUFFER_BREAK
|
---|
5418 |
|
---|
5419 | /**
|
---|
5420 | * @callback_method_impl{PFNPDMTHREADDEV, The async FIFO handling thread.}
|
---|
5421 | */
|
---|
5422 | static DECLCALLBACK(int) vmsvgaR3CmdBufLoop(PPDMDEVINS pDevIns, PPDMTHREAD pThread)
|
---|
5423 | {
|
---|
5424 | PVGASTATE pThis = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
|
---|
5425 | PVGASTATER3 pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC);
|
---|
5426 | PVMSVGAR3STATE pSVGAState = pThisCC->svga.pSvgaR3State;
|
---|
5427 | int rc;
|
---|
5428 |
|
---|
5429 | if (pThread->enmState == PDMTHREADSTATE_INITIALIZING)
|
---|
5430 | return VINF_SUCCESS;
|
---|
5431 |
|
---|
5432 | /*
|
---|
5433 | * Special mode where we only execute an external command and the go back
|
---|
5434 | * to being suspended. Currently, all ext cmds ends up here, with the reset
|
---|
5435 | * one also being eligble for runtime execution further down as well.
|
---|
5436 | */
|
---|
5437 | if (pThis->svga.fFifoExtCommandWakeup)
|
---|
5438 | {
|
---|
5439 | vmsvgaR3FifoHandleExtCmd(pDevIns, pThis, pThisCC);
|
---|
5440 | while (pThread->enmState == PDMTHREADSTATE_RUNNING)
|
---|
5441 | if (pThis->svga.u8FIFOExtCommand == VMSVGA_FIFO_EXTCMD_NONE)
|
---|
5442 | PDMDevHlpSUPSemEventWaitNoResume(pDevIns, pThis->svga.hFIFORequestSem, RT_MS_1MIN);
|
---|
5443 | else
|
---|
5444 | vmsvgaR3FifoHandleExtCmd(pDevIns, pThis, pThisCC);
|
---|
5445 | return VINF_SUCCESS;
|
---|
5446 | }
|
---|
5447 |
|
---|
5448 |
|
---|
5449 | /*
|
---|
5450 | * Signal the semaphore to make sure we don't wait for 250ms after a
|
---|
5451 | * suspend & resume scenario (see vmsvgaR3FifoGetCmdPayload).
|
---|
5452 | */
|
---|
5453 | PDMDevHlpSUPSemEventSignal(pDevIns, pThis->svga.hFIFORequestSem);
|
---|
5454 |
|
---|
5455 | /*
|
---|
5456 | * Polling/sleep interval config.
|
---|
5457 | *
|
---|
5458 | * We wait for an a short interval if the guest has recently given us work
|
---|
5459 | * to do, but the interval increases the longer we're kept idle. Once we've
|
---|
5460 | * reached the refresh timer interval, we'll switch to extended waits,
|
---|
5461 | * depending on it or the guest to kick us into action when needed.
|
---|
5462 | *
|
---|
5463 | * Should the refresh time go fishing, we'll just continue increasing the
|
---|
5464 | * sleep length till we reaches the 250 ms max after about 16 seconds.
|
---|
5465 | */
|
---|
5466 | RTMSINTERVAL const cMsMinSleep = 16;
|
---|
5467 | RTMSINTERVAL const cMsMaxSleep = 250;
|
---|
5468 | RTMSINTERVAL const cMsExtendedSleep = 15 * RT_MS_1SEC; /* Regular paranoia dictates that this cannot be indefinite. */
|
---|
5469 | RTMSINTERVAL cMsSleep = cMsMaxSleep;
|
---|
5470 |
|
---|
5471 | /*
|
---|
5472 | * The FIFO loop.
|
---|
5473 | */
|
---|
5474 | LogFlow(("vmsvgaR3CmdBufLoop: started loop\n"));
|
---|
5475 | bool fBadOrDisabledFifo = ASMAtomicReadBool(&pThis->svga.fBadGuest);
|
---|
5476 | while (pThread->enmState == PDMTHREADSTATE_RUNNING)
|
---|
5477 | {
|
---|
5478 | /* First check any pending actions. */
|
---|
5479 | vmsvgaR3FifoPendingActions(pDevIns, pThis, pThisCC);
|
---|
5480 |
|
---|
5481 | /*
|
---|
5482 | * Unless there's already work pending, go to sleep for a short while.
|
---|
5483 | * (See polling/sleep interval config above.)
|
---|
5484 | */
|
---|
5485 | ASMAtomicWriteBool(&pThis->svga.fFIFOThreadSleeping, true);
|
---|
5486 | Assert(pThis->cMilliesRefreshInterval > 0);
|
---|
5487 | if (cMsSleep < pThis->cMilliesRefreshInterval)
|
---|
5488 | rc = PDMDevHlpSUPSemEventWaitNoResume(pDevIns, pThis->svga.hFIFORequestSem, cMsSleep);
|
---|
5489 | else
|
---|
5490 | {
|
---|
5491 | STAM_REL_PROFILE_START(&pSVGAState->StatFifoExtendedSleep, Acc);
|
---|
5492 | rc = PDMDevHlpSUPSemEventWaitNoResume(pDevIns, pThis->svga.hFIFORequestSem, cMsExtendedSleep);
|
---|
5493 | STAM_REL_PROFILE_STOP(&pSVGAState->StatFifoExtendedSleep, Acc);
|
---|
5494 | }
|
---|
5495 | ASMAtomicWriteBool(&pThis->svga.fFIFOThreadSleeping, false);
|
---|
5496 | AssertBreak(RT_SUCCESS(rc) || rc == VERR_TIMEOUT || rc == VERR_INTERRUPTED);
|
---|
5497 | if (pThread->enmState != PDMTHREADSTATE_RUNNING)
|
---|
5498 | {
|
---|
5499 | LogFlow(("vmsvgaR3CmdBufLoop: thread state %x\n", pThread->enmState));
|
---|
5500 | break;
|
---|
5501 | }
|
---|
5502 |
|
---|
5503 | fBadOrDisabledFifo = ASMAtomicReadBool(&pThis->svga.fBadGuest);
|
---|
5504 | cMsSleep = cMsMinSleep;
|
---|
5505 |
|
---|
5506 | Log(("vmsvgaR3CmdBufLoop: enabled=%d configured=%d\n", pThis->svga.fEnabled, pThis->svga.fConfigured));
|
---|
5507 |
|
---|
5508 | /*
|
---|
5509 | * Handle external commands (currently only reset).
|
---|
5510 | */
|
---|
5511 | if (pThis->svga.u8FIFOExtCommand != VMSVGA_FIFO_EXTCMD_NONE)
|
---|
5512 | {
|
---|
5513 | vmsvgaR3FifoHandleExtCmd(pDevIns, pThis, pThisCC);
|
---|
5514 | continue;
|
---|
5515 | }
|
---|
5516 |
|
---|
5517 | /*
|
---|
5518 | * If guest misbehaves, then do nothing.
|
---|
5519 | */
|
---|
5520 | if (ASMAtomicReadBool(&pThis->svga.fBadGuest))
|
---|
5521 | {
|
---|
5522 | cMsSleep = cMsExtendedSleep;
|
---|
5523 | LogRelMax(1, ("VMSVGA: FIFO processing stopped because of the guest misbehavior\n"));
|
---|
5524 | continue;
|
---|
5525 | }
|
---|
5526 |
|
---|
5527 | /*
|
---|
5528 | * The device must be enabled and configured.
|
---|
5529 | */
|
---|
5530 | if ( !pThis->svga.fEnabled
|
---|
5531 | || !pThis->svga.fConfigured)
|
---|
5532 | {
|
---|
5533 | fBadOrDisabledFifo = true;
|
---|
5534 | cMsSleep = cMsMaxSleep; /* cheat */
|
---|
5535 | continue;
|
---|
5536 | }
|
---|
5537 |
|
---|
5538 | /*
|
---|
5539 | * Process all submitted command buffers.
|
---|
5540 | */
|
---|
5541 | vmsvgaR3CmdBufProcessBuffers(pDevIns, pThis, pThisCC, pThread);
|
---|
5542 | }
|
---|
5543 |
|
---|
5544 | return VINF_SUCCESS;
|
---|
5545 | }
|
---|
5546 |
|
---|
5547 |
|
---|
5548 | /**
|
---|
5549 | * @callback_method_impl{PFNPDMTHREADWAKEUPDEV,
|
---|
5550 | * Unblock the FIFO I/O thread so it can respond to a state change.}
|
---|
5551 | */
|
---|
5552 | static DECLCALLBACK(int) vmsvgaR3FifoLoopWakeUp(PPDMDEVINS pDevIns, PPDMTHREAD pThread)
|
---|
5553 | {
|
---|
5554 | RT_NOREF(pDevIns);
|
---|
5555 | PVGASTATE pThis = (PVGASTATE)pThread->pvUser;
|
---|
5556 | Log(("vmsvgaR3FifoLoopWakeUp\n"));
|
---|
5557 | return PDMDevHlpSUPSemEventSignal(pDevIns, pThis->svga.hFIFORequestSem);
|
---|
5558 | }
|
---|
5559 |
|
---|
5560 | /**
|
---|
5561 | * Enables or disables dirty page tracking for the framebuffer
|
---|
5562 | *
|
---|
5563 | * @param pDevIns The device instance.
|
---|
5564 | * @param pThis The shared VGA/VMSVGA instance data.
|
---|
5565 | * @param fTraces Enable/disable traces
|
---|
5566 | */
|
---|
5567 | static void vmsvgaR3SetTraces(PPDMDEVINS pDevIns, PVGASTATE pThis, bool fTraces)
|
---|
5568 | {
|
---|
5569 | if ( (!pThis->svga.fConfigured || !pThis->svga.fEnabled)
|
---|
5570 | && !fTraces)
|
---|
5571 | {
|
---|
5572 | //Assert(pThis->svga.fTraces);
|
---|
5573 | Log(("vmsvgaR3SetTraces: *not* allowed to disable dirty page tracking when the device is in legacy mode.\n"));
|
---|
5574 | return;
|
---|
5575 | }
|
---|
5576 |
|
---|
5577 | pThis->svga.fTraces = fTraces;
|
---|
5578 | if (pThis->svga.fTraces)
|
---|
5579 | {
|
---|
5580 | unsigned cbFrameBuffer = pThis->vram_size;
|
---|
5581 |
|
---|
5582 | Log(("vmsvgaR3SetTraces: enable dirty page handling for the frame buffer only (%x bytes)\n", 0));
|
---|
5583 | /** @todo How does this work with screens? */
|
---|
5584 | if (pThis->svga.uHeight != VMSVGA_VAL_UNINITIALIZED)
|
---|
5585 | {
|
---|
5586 | # if 0 //ifndef DEBUG_bird /* BB-10.3.1 triggers this as it initializes everything to zero. Better just ignore it. */
|
---|
5587 | Assert(pThis->svga.cbScanline);
|
---|
5588 | # endif
|
---|
5589 | /* Hardware enabled; return real framebuffer size .*/
|
---|
5590 | cbFrameBuffer = (uint32_t)pThis->svga.uHeight * pThis->svga.cbScanline;
|
---|
5591 | cbFrameBuffer = RT_ALIGN(cbFrameBuffer, GUEST_PAGE_SIZE);
|
---|
5592 | }
|
---|
5593 |
|
---|
5594 | if (!pThis->svga.fVRAMTracking)
|
---|
5595 | {
|
---|
5596 | Log(("vmsvgaR3SetTraces: enable frame buffer dirty page tracking. (%x bytes; vram %x)\n", cbFrameBuffer, pThis->vram_size));
|
---|
5597 | vgaR3RegisterVRAMHandler(pDevIns, pThis, cbFrameBuffer);
|
---|
5598 | pThis->svga.fVRAMTracking = true;
|
---|
5599 | }
|
---|
5600 | }
|
---|
5601 | else
|
---|
5602 | {
|
---|
5603 | if (pThis->svga.fVRAMTracking)
|
---|
5604 | {
|
---|
5605 | Log(("vmsvgaR3SetTraces: disable frame buffer dirty page tracking\n"));
|
---|
5606 | vgaR3UnregisterVRAMHandler(pDevIns, pThis);
|
---|
5607 | pThis->svga.fVRAMTracking = false;
|
---|
5608 | }
|
---|
5609 | }
|
---|
5610 | }
|
---|
5611 |
|
---|
5612 | /**
|
---|
5613 | * @callback_method_impl{FNPCIIOREGIONMAP}
|
---|
5614 | */
|
---|
5615 | DECLCALLBACK(int) vmsvgaR3PciIORegionFifoMapUnmap(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iRegion,
|
---|
5616 | RTGCPHYS GCPhysAddress, RTGCPHYS cb, PCIADDRESSSPACE enmType)
|
---|
5617 | {
|
---|
5618 | PVGASTATE pThis = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
|
---|
5619 | int rc;
|
---|
5620 | RT_NOREF(pPciDev);
|
---|
5621 | Assert(pPciDev == pDevIns->apPciDevs[0]);
|
---|
5622 |
|
---|
5623 | Log(("vmsvgaR3PciIORegionFifoMapUnmap: iRegion=%d GCPhysAddress=%RGp cb=%RGp enmType=%d\n", iRegion, GCPhysAddress, cb, enmType));
|
---|
5624 | AssertReturn( iRegion == pThis->pciRegions.iFIFO
|
---|
5625 | && ( enmType == PCI_ADDRESS_SPACE_MEM
|
---|
5626 | || (enmType == PCI_ADDRESS_SPACE_MEM_PREFETCH /* got wrong in 6.1.0RC1 */ && pThis->fStateLoaded))
|
---|
5627 | , VERR_INTERNAL_ERROR);
|
---|
5628 | if (GCPhysAddress != NIL_RTGCPHYS)
|
---|
5629 | {
|
---|
5630 | /*
|
---|
5631 | * Mapping the FIFO RAM.
|
---|
5632 | */
|
---|
5633 | AssertLogRelMsg(cb == pThis->svga.cbFIFO, ("cb=%#RGp cbFIFO=%#x\n", cb, pThis->svga.cbFIFO));
|
---|
5634 | rc = PDMDevHlpMmio2Map(pDevIns, pThis->hMmio2VmSvgaFifo, GCPhysAddress);
|
---|
5635 | AssertRC(rc);
|
---|
5636 |
|
---|
5637 | # if defined(VMSVGA_USE_FIFO_ACCESS_HANDLER) || defined(DEBUG_FIFO_ACCESS)
|
---|
5638 | if (RT_SUCCESS(rc))
|
---|
5639 | {
|
---|
5640 | rc = PDMDevHlpPGMHandlerPhysicalRegister(pDevIns, GCPhysAddress,
|
---|
5641 | # ifdef DEBUG_FIFO_ACCESS
|
---|
5642 | GCPhysAddress + (pThis->svga.cbFIFO - 1),
|
---|
5643 | # else
|
---|
5644 | GCPhysAddress + GUEST_PAGE_SIZE - 1,
|
---|
5645 | # endif
|
---|
5646 | pThis->svga.hFifoAccessHandlerType, pThis, NIL_RTR0PTR, NIL_RTRCPTR,
|
---|
5647 | "VMSVGA FIFO");
|
---|
5648 | AssertRC(rc);
|
---|
5649 | }
|
---|
5650 | # endif
|
---|
5651 | if (RT_SUCCESS(rc))
|
---|
5652 | {
|
---|
5653 | pThis->svga.GCPhysFIFO = GCPhysAddress;
|
---|
5654 | Log(("vmsvgaR3IORegionMap: GCPhysFIFO=%RGp cbFIFO=%#x\n", GCPhysAddress, pThis->svga.cbFIFO));
|
---|
5655 | }
|
---|
5656 | rc = VINF_PCI_MAPPING_DONE; /* caller only cares about this status, so it is okay that we overwrite errors here. */
|
---|
5657 | }
|
---|
5658 | else
|
---|
5659 | {
|
---|
5660 | Assert(pThis->svga.GCPhysFIFO);
|
---|
5661 | # if defined(VMSVGA_USE_FIFO_ACCESS_HANDLER) || defined(DEBUG_FIFO_ACCESS)
|
---|
5662 | rc = PDMDevHlpPGMHandlerPhysicalDeregister(pDevIns, pThis->svga.GCPhysFIFO);
|
---|
5663 | AssertRC(rc);
|
---|
5664 | # else
|
---|
5665 | rc = VINF_SUCCESS;
|
---|
5666 | # endif
|
---|
5667 | pThis->svga.GCPhysFIFO = 0;
|
---|
5668 | }
|
---|
5669 | return rc;
|
---|
5670 | }
|
---|
5671 |
|
---|
5672 | # ifdef VBOX_WITH_VMSVGA3D
|
---|
5673 |
|
---|
5674 | /**
|
---|
5675 | * Used by vmsvga3dInfoSurfaceWorker to make the FIFO thread to save one or all
|
---|
5676 | * surfaces to VMSVGA3DMIPMAPLEVEL::pSurfaceData heap buffers.
|
---|
5677 | *
|
---|
5678 | * @param pDevIns The device instance.
|
---|
5679 | * @param pThis The The shared VGA/VMSVGA instance data.
|
---|
5680 | * @param pThisCC The VGA/VMSVGA state for ring-3.
|
---|
5681 | * @param sid Either UINT32_MAX or the ID of a specific surface. If
|
---|
5682 | * UINT32_MAX is used, all surfaces are processed.
|
---|
5683 | */
|
---|
5684 | void vmsvgaR33dSurfaceUpdateHeapBuffersOnFifoThread(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC, uint32_t sid)
|
---|
5685 | {
|
---|
5686 | vmsvgaR3RunExtCmdOnFifoThread(pDevIns, pThis, pThisCC, VMSVGA_FIFO_EXTCMD_UPDATE_SURFACE_HEAP_BUFFERS, (void *)(uintptr_t)sid,
|
---|
5687 | sid == UINT32_MAX ? 10 * RT_MS_1SEC : RT_MS_1MIN);
|
---|
5688 | }
|
---|
5689 |
|
---|
5690 |
|
---|
5691 | /**
|
---|
5692 | * @callback_method_impl{FNDBGFHANDLERDEV, "vmsvga3dsfc"}
|
---|
5693 | */
|
---|
5694 | static DECLCALLBACK(void) vmsvgaR3Info3dSurface(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs)
|
---|
5695 | {
|
---|
5696 | /* There might be a specific surface ID at the start of the
|
---|
5697 | arguments, if not show all surfaces. */
|
---|
5698 | uint32_t sid = UINT32_MAX;
|
---|
5699 | if (pszArgs)
|
---|
5700 | pszArgs = RTStrStripL(pszArgs);
|
---|
5701 | if (pszArgs && RT_C_IS_DIGIT(*pszArgs))
|
---|
5702 | sid = RTStrToUInt32(pszArgs);
|
---|
5703 |
|
---|
5704 | /* Verbose or terse display, we default to verbose. */
|
---|
5705 | bool fVerbose = true;
|
---|
5706 | if (RTStrIStr(pszArgs, "terse"))
|
---|
5707 | fVerbose = false;
|
---|
5708 |
|
---|
5709 | /* The size of the ascii art (x direction, y is 3/4 of x). */
|
---|
5710 | uint32_t cxAscii = 80;
|
---|
5711 | if (RTStrIStr(pszArgs, "gigantic"))
|
---|
5712 | cxAscii = 300;
|
---|
5713 | else if (RTStrIStr(pszArgs, "huge"))
|
---|
5714 | cxAscii = 180;
|
---|
5715 | else if (RTStrIStr(pszArgs, "big"))
|
---|
5716 | cxAscii = 132;
|
---|
5717 | else if (RTStrIStr(pszArgs, "normal"))
|
---|
5718 | cxAscii = 80;
|
---|
5719 | else if (RTStrIStr(pszArgs, "medium"))
|
---|
5720 | cxAscii = 64;
|
---|
5721 | else if (RTStrIStr(pszArgs, "small"))
|
---|
5722 | cxAscii = 48;
|
---|
5723 | else if (RTStrIStr(pszArgs, "tiny"))
|
---|
5724 | cxAscii = 24;
|
---|
5725 |
|
---|
5726 | /* Y invert the image when producing the ASCII art. */
|
---|
5727 | bool fInvY = false;
|
---|
5728 | if (RTStrIStr(pszArgs, "invy"))
|
---|
5729 | fInvY = true;
|
---|
5730 |
|
---|
5731 | vmsvga3dInfoSurfaceWorker(pDevIns, PDMDEVINS_2_DATA(pDevIns, PVGASTATE), PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC),
|
---|
5732 | pHlp, sid, fVerbose, cxAscii, fInvY, NULL);
|
---|
5733 | }
|
---|
5734 |
|
---|
5735 |
|
---|
5736 | /**
|
---|
5737 | * @callback_method_impl{FNDBGFHANDLERDEV, "vmsvga3dsurf"}
|
---|
5738 | */
|
---|
5739 | static DECLCALLBACK(void) vmsvgaR3Info3dSurfaceBmp(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs)
|
---|
5740 | {
|
---|
5741 | /* pszArg = "sid[>dir]"
|
---|
5742 | * Writes %dir%/info-S-sidI.bmp, where S - sequential bitmap number, I - decimal surface id.
|
---|
5743 | */
|
---|
5744 | char *pszBitmapPath = NULL;
|
---|
5745 | uint32_t sid = UINT32_MAX;
|
---|
5746 | if (pszArgs)
|
---|
5747 | pszArgs = RTStrStripL(pszArgs);
|
---|
5748 | if (pszArgs && RT_C_IS_DIGIT(*pszArgs))
|
---|
5749 | RTStrToUInt32Ex(pszArgs, &pszBitmapPath, 0, &sid);
|
---|
5750 | if ( pszBitmapPath
|
---|
5751 | && *pszBitmapPath == '>')
|
---|
5752 | ++pszBitmapPath;
|
---|
5753 |
|
---|
5754 | const bool fVerbose = true;
|
---|
5755 | const uint32_t cxAscii = 0; /* No ASCII */
|
---|
5756 | const bool fInvY = false; /* Do not invert. */
|
---|
5757 | vmsvga3dInfoSurfaceWorker(pDevIns, PDMDEVINS_2_DATA(pDevIns, PVGASTATE), PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC),
|
---|
5758 | pHlp, sid, fVerbose, cxAscii, fInvY, pszBitmapPath);
|
---|
5759 | }
|
---|
5760 |
|
---|
5761 | /**
|
---|
5762 | * @callback_method_impl{FNDBGFHANDLERDEV, "vmsvga3dctx"}
|
---|
5763 | */
|
---|
5764 | static DECLCALLBACK(void) vmsvgaR3Info3dContext(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs)
|
---|
5765 | {
|
---|
5766 | /* There might be a specific surface ID at the start of the
|
---|
5767 | arguments, if not show all contexts. */
|
---|
5768 | uint32_t sid = UINT32_MAX;
|
---|
5769 | if (pszArgs)
|
---|
5770 | pszArgs = RTStrStripL(pszArgs);
|
---|
5771 | if (pszArgs && RT_C_IS_DIGIT(*pszArgs))
|
---|
5772 | sid = RTStrToUInt32(pszArgs);
|
---|
5773 |
|
---|
5774 | /* Verbose or terse display, we default to verbose. */
|
---|
5775 | bool fVerbose = true;
|
---|
5776 | if (RTStrIStr(pszArgs, "terse"))
|
---|
5777 | fVerbose = false;
|
---|
5778 |
|
---|
5779 | vmsvga3dInfoContextWorker(PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC), pHlp, sid, fVerbose);
|
---|
5780 | }
|
---|
5781 | # endif /* VBOX_WITH_VMSVGA3D */
|
---|
5782 |
|
---|
5783 | /**
|
---|
5784 | * @callback_method_impl{FNDBGFHANDLERDEV, "vmsvga"}
|
---|
5785 | */
|
---|
5786 | static DECLCALLBACK(void) vmsvgaR3Info(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs)
|
---|
5787 | {
|
---|
5788 | PVGASTATE pThis = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
|
---|
5789 | PVGASTATECC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC);
|
---|
5790 | PVMSVGAR3STATE pSVGAState = pThisCC->svga.pSvgaR3State;
|
---|
5791 | uint32_t RT_UNTRUSTED_VOLATILE_GUEST *pFIFO = pThisCC->svga.pau32FIFO;
|
---|
5792 | RT_NOREF(pszArgs);
|
---|
5793 |
|
---|
5794 | pHlp->pfnPrintf(pHlp, "Extension enabled: %RTbool\n", pThis->svga.fEnabled);
|
---|
5795 | pHlp->pfnPrintf(pHlp, "Configured: %RTbool\n", pThis->svga.fConfigured);
|
---|
5796 | pHlp->pfnPrintf(pHlp, "Base I/O port: %#x\n",
|
---|
5797 | pThis->hIoPortVmSvga != NIL_IOMIOPORTHANDLE
|
---|
5798 | ? PDMDevHlpIoPortGetMappingAddress(pDevIns, pThis->hIoPortVmSvga) : UINT32_MAX);
|
---|
5799 | pHlp->pfnPrintf(pHlp, "FIFO address: %RGp\n", pThis->svga.GCPhysFIFO);
|
---|
5800 | pHlp->pfnPrintf(pHlp, "FIFO size: %u (%#x)\n", pThis->svga.cbFIFO, pThis->svga.cbFIFO);
|
---|
5801 | pHlp->pfnPrintf(pHlp, "FIFO external cmd: %#x\n", pThis->svga.u8FIFOExtCommand);
|
---|
5802 | pHlp->pfnPrintf(pHlp, "FIFO extcmd wakeup: %u\n", pThis->svga.fFifoExtCommandWakeup);
|
---|
5803 | if (pFIFO)
|
---|
5804 | pHlp->pfnPrintf(pHlp, "FIFO min/max: %u/%u\n", pFIFO[SVGA_FIFO_MIN], pFIFO[SVGA_FIFO_MAX]);
|
---|
5805 | pHlp->pfnPrintf(pHlp, "Busy: %#x\n", pThis->svga.fBusy);
|
---|
5806 | pHlp->pfnPrintf(pHlp, "Traces: %RTbool (effective: %RTbool)\n", pThis->svga.fTraces, pThis->svga.fVRAMTracking);
|
---|
5807 | pHlp->pfnPrintf(pHlp, "Guest ID: %#x (%d)\n", pThis->svga.u32GuestId, pThis->svga.u32GuestId);
|
---|
5808 | pHlp->pfnPrintf(pHlp, "IRQ status: %#x\n", pThis->svga.u32IrqStatus);
|
---|
5809 | pHlp->pfnPrintf(pHlp, "IRQ mask: %#x\n", pThis->svga.u32IrqMask);
|
---|
5810 | pHlp->pfnPrintf(pHlp, "Pitch lock: %#x (FIFO:%#x)\n", pThis->svga.u32PitchLock, pFIFO ? pFIFO[SVGA_FIFO_PITCHLOCK] : 0);
|
---|
5811 | pHlp->pfnPrintf(pHlp, "Current GMR ID: %#x\n", pThis->svga.u32CurrentGMRId);
|
---|
5812 | pHlp->pfnPrintf(pHlp, "Device Capabilites: %#x\n", pThis->svga.u32DeviceCaps);
|
---|
5813 | pHlp->pfnPrintf(pHlp, "Device Cap2: %#x\n", pThis->svga.u32DeviceCaps2);
|
---|
5814 | pHlp->pfnPrintf(pHlp, "Guest driver id: %#x\n", pThis->svga.u32GuestDriverId);
|
---|
5815 | pHlp->pfnPrintf(pHlp, "Guest driver ver1: %#x\n", pThis->svga.u32GuestDriverVer1);
|
---|
5816 | pHlp->pfnPrintf(pHlp, "Guest driver ver2: %#x\n", pThis->svga.u32GuestDriverVer2);
|
---|
5817 | pHlp->pfnPrintf(pHlp, "Guest driver ver3: %#x\n", pThis->svga.u32GuestDriverVer3);
|
---|
5818 | pHlp->pfnPrintf(pHlp, "Index reg: %#x\n", pThis->svga.u32IndexReg);
|
---|
5819 | pHlp->pfnPrintf(pHlp, "Action flags: %#x\n", pThis->svga.u32ActionFlags);
|
---|
5820 | pHlp->pfnPrintf(pHlp, "Max display size: %ux%u\n", pThis->svga.u32MaxWidth, pThis->svga.u32MaxHeight);
|
---|
5821 | pHlp->pfnPrintf(pHlp, "Display size: %ux%u %ubpp\n", pThis->svga.uWidth, pThis->svga.uHeight, pThis->svga.uBpp);
|
---|
5822 | pHlp->pfnPrintf(pHlp, "Scanline: %u (%#x)\n", pThis->svga.cbScanline, pThis->svga.cbScanline);
|
---|
5823 | pHlp->pfnPrintf(pHlp, "Viewport position: %ux%u\n", pThis->svga.viewport.x, pThis->svga.viewport.y);
|
---|
5824 | pHlp->pfnPrintf(pHlp, "Viewport size: %ux%u\n", pThis->svga.viewport.cx, pThis->svga.viewport.cy);
|
---|
5825 |
|
---|
5826 | pHlp->pfnPrintf(pHlp, "Cursor active: %RTbool\n", pSVGAState->Cursor.fActive);
|
---|
5827 | pHlp->pfnPrintf(pHlp, "Cursor hotspot: %ux%u\n", pSVGAState->Cursor.xHotspot, pSVGAState->Cursor.yHotspot);
|
---|
5828 | pHlp->pfnPrintf(pHlp, "Cursor size: %ux%u\n", pSVGAState->Cursor.width, pSVGAState->Cursor.height);
|
---|
5829 | pHlp->pfnPrintf(pHlp, "Cursor byte size: %u (%#x)\n", pSVGAState->Cursor.cbData, pSVGAState->Cursor.cbData);
|
---|
5830 | if (pFIFO)
|
---|
5831 | {
|
---|
5832 | pHlp->pfnPrintf(pHlp, "FIFO cursor: state %u, screen %d\n", pFIFO[SVGA_FIFO_CURSOR_ON], pFIFO[SVGA_FIFO_CURSOR_SCREEN_ID]);
|
---|
5833 | pHlp->pfnPrintf(pHlp, "FIFO cursor at: %u,%u\n", pFIFO[SVGA_FIFO_CURSOR_X], pFIFO[SVGA_FIFO_CURSOR_Y]);
|
---|
5834 | }
|
---|
5835 | pHlp->pfnPrintf(pHlp, "Legacy cursor: ID %u, state %u\n", pThis->svga.uCursorID, pThis->svga.uCursorOn);
|
---|
5836 | pHlp->pfnPrintf(pHlp, "Legacy cursor at: %u,%u\n", pThis->svga.uCursorX, pThis->svga.uCursorY);
|
---|
5837 |
|
---|
5838 | # ifdef VBOX_WITH_VMSVGA3D
|
---|
5839 | pHlp->pfnPrintf(pHlp, "3D enabled: %RTbool\n", pThis->svga.f3DEnabled);
|
---|
5840 | # endif
|
---|
5841 | if (pThisCC->pDrv)
|
---|
5842 | {
|
---|
5843 | pHlp->pfnPrintf(pHlp, "Driver mode: %ux%u %ubpp\n", pThisCC->pDrv->cx, pThisCC->pDrv->cy, pThisCC->pDrv->cBits);
|
---|
5844 | pHlp->pfnPrintf(pHlp, "Driver pitch: %u (%#x)\n", pThisCC->pDrv->cbScanline, pThisCC->pDrv->cbScanline);
|
---|
5845 | }
|
---|
5846 |
|
---|
5847 | /* Dump screen information. */
|
---|
5848 | for (unsigned iScreen = 0; iScreen < RT_ELEMENTS(pSVGAState->aScreens); ++iScreen)
|
---|
5849 | {
|
---|
5850 | VMSVGASCREENOBJECT *pScreen = vmsvgaR3GetScreenObject(pThisCC, iScreen);
|
---|
5851 | if (pScreen)
|
---|
5852 | {
|
---|
5853 | pHlp->pfnPrintf(pHlp, "Screen %u defined (ID %u):\n", iScreen, pScreen->idScreen);
|
---|
5854 | pHlp->pfnPrintf(pHlp, " %u x %u x %ubpp @ %u, %u\n", pScreen->cWidth, pScreen->cHeight,
|
---|
5855 | pScreen->cBpp, pScreen->xOrigin, pScreen->yOrigin);
|
---|
5856 | pHlp->pfnPrintf(pHlp, " Pitch %u bytes, VRAM offset %X\n", pScreen->cbPitch, pScreen->offVRAM);
|
---|
5857 | pHlp->pfnPrintf(pHlp, " Flags %X", pScreen->fuScreen);
|
---|
5858 | if (pScreen->fuScreen != SVGA_SCREEN_MUST_BE_SET)
|
---|
5859 | {
|
---|
5860 | pHlp->pfnPrintf(pHlp, " (");
|
---|
5861 | if (pScreen->fuScreen & SVGA_SCREEN_IS_PRIMARY)
|
---|
5862 | pHlp->pfnPrintf(pHlp, " IS_PRIMARY");
|
---|
5863 | if (pScreen->fuScreen & SVGA_SCREEN_FULLSCREEN_HINT)
|
---|
5864 | pHlp->pfnPrintf(pHlp, " FULLSCREEN_HINT");
|
---|
5865 | if (pScreen->fuScreen & SVGA_SCREEN_DEACTIVATE)
|
---|
5866 | pHlp->pfnPrintf(pHlp, " DEACTIVATE");
|
---|
5867 | if (pScreen->fuScreen & SVGA_SCREEN_BLANKING)
|
---|
5868 | pHlp->pfnPrintf(pHlp, " BLANKING");
|
---|
5869 | pHlp->pfnPrintf(pHlp, " )");
|
---|
5870 | }
|
---|
5871 | pHlp->pfnPrintf(pHlp, ", %smodified\n", pScreen->fModified ? "" : "not ");
|
---|
5872 | }
|
---|
5873 | }
|
---|
5874 |
|
---|
5875 | }
|
---|
5876 |
|
---|
5877 | static int vmsvgaR3LoadBufCtx(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC, PSSMHANDLE pSSM, PVMSVGACMDBUFCTX pBufCtx, SVGACBContext CBCtx)
|
---|
5878 | {
|
---|
5879 | PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3;
|
---|
5880 | PVMSVGAR3STATE pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
5881 |
|
---|
5882 | uint32_t cSubmitted;
|
---|
5883 | int rc = pHlp->pfnSSMGetU32(pSSM, &cSubmitted);
|
---|
5884 | AssertLogRelRCReturn(rc, rc);
|
---|
5885 |
|
---|
5886 | for (uint32_t i = 0; i < cSubmitted; ++i)
|
---|
5887 | {
|
---|
5888 | PVMSVGACMDBUF pCmdBuf = vmsvgaR3CmdBufAlloc(pBufCtx);
|
---|
5889 | AssertPtrReturn(pCmdBuf, VERR_NO_MEMORY);
|
---|
5890 |
|
---|
5891 | pHlp->pfnSSMGetGCPhys(pSSM, &pCmdBuf->GCPhysCB);
|
---|
5892 |
|
---|
5893 | uint32_t u32;
|
---|
5894 | rc = pHlp->pfnSSMGetU32(pSSM, &u32);
|
---|
5895 | AssertRCReturn(rc, rc);
|
---|
5896 | AssertReturn(u32 == sizeof(SVGACBHeader), VERR_INVALID_STATE);
|
---|
5897 | pHlp->pfnSSMGetMem(pSSM, &pCmdBuf->hdr, sizeof(SVGACBHeader));
|
---|
5898 |
|
---|
5899 | rc = pHlp->pfnSSMGetU32(pSSM, &u32);
|
---|
5900 | AssertRCReturn(rc, rc);
|
---|
5901 | AssertReturn(u32 == pCmdBuf->hdr.length, VERR_INVALID_STATE);
|
---|
5902 |
|
---|
5903 | if (pCmdBuf->hdr.length)
|
---|
5904 | {
|
---|
5905 | pCmdBuf->pvCommands = RTMemAlloc(pCmdBuf->hdr.length);
|
---|
5906 | AssertPtrReturn(pCmdBuf->pvCommands, VERR_NO_MEMORY);
|
---|
5907 |
|
---|
5908 | rc = pHlp->pfnSSMGetMem(pSSM, pCmdBuf->pvCommands, pCmdBuf->hdr.length);
|
---|
5909 | AssertRCReturn(rc, rc);
|
---|
5910 | }
|
---|
5911 |
|
---|
5912 | if (RT_LIKELY(CBCtx < RT_ELEMENTS(pSvgaR3State->apCmdBufCtxs)))
|
---|
5913 | {
|
---|
5914 | vmsvgaR3CmdBufSubmitCtx(pDevIns, pThis, pThisCC, &pCmdBuf);
|
---|
5915 | }
|
---|
5916 | else
|
---|
5917 | {
|
---|
5918 | uint32_t offNextCmd = 0;
|
---|
5919 | vmsvgaR3CmdBufSubmitDC(pDevIns, pThisCC, &pCmdBuf, &offNextCmd);
|
---|
5920 | }
|
---|
5921 |
|
---|
5922 | /* Free the buffer if CmdBufSubmit* did not consume it. */
|
---|
5923 | vmsvgaR3CmdBufFree(pCmdBuf);
|
---|
5924 | }
|
---|
5925 | return rc;
|
---|
5926 | }
|
---|
5927 |
|
---|
5928 | static int vmsvgaR3LoadCommandBuffers(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC, PSSMHANDLE pSSM)
|
---|
5929 | {
|
---|
5930 | PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3;
|
---|
5931 | PVMSVGAR3STATE pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
5932 |
|
---|
5933 | bool f;
|
---|
5934 | uint32_t u32;
|
---|
5935 |
|
---|
5936 | /* Device context command buffers. */
|
---|
5937 | int rc = vmsvgaR3LoadBufCtx(pDevIns, pThis, pThisCC, pSSM, &pSvgaR3State->CmdBufCtxDC, SVGA_CB_CONTEXT_MAX);
|
---|
5938 | AssertLogRelRCReturn(rc, rc);
|
---|
5939 |
|
---|
5940 | /* DX contexts command buffers. */
|
---|
5941 | uint32_t cBufCtx;
|
---|
5942 | rc = pHlp->pfnSSMGetU32(pSSM, &cBufCtx);
|
---|
5943 | AssertLogRelRCReturn(rc, rc);
|
---|
5944 | AssertReturn(cBufCtx == RT_ELEMENTS(pSvgaR3State->apCmdBufCtxs), VERR_INVALID_STATE);
|
---|
5945 | for (uint32_t j = 0; j < cBufCtx; ++j)
|
---|
5946 | {
|
---|
5947 | rc = pHlp->pfnSSMGetBool(pSSM, &f);
|
---|
5948 | AssertLogRelRCReturn(rc, rc);
|
---|
5949 | if (f)
|
---|
5950 | {
|
---|
5951 | pSvgaR3State->apCmdBufCtxs[j] = (PVMSVGACMDBUFCTX)RTMemAlloc(sizeof(VMSVGACMDBUFCTX));
|
---|
5952 | AssertPtrReturn(pSvgaR3State->apCmdBufCtxs[j], VERR_NO_MEMORY);
|
---|
5953 | vmsvgaR3CmdBufCtxInit(pSvgaR3State->apCmdBufCtxs[j]);
|
---|
5954 |
|
---|
5955 | rc = vmsvgaR3LoadBufCtx(pDevIns, pThis, pThisCC, pSSM, pSvgaR3State->apCmdBufCtxs[j], (SVGACBContext)j);
|
---|
5956 | AssertLogRelRCReturn(rc, rc);
|
---|
5957 | }
|
---|
5958 | }
|
---|
5959 |
|
---|
5960 | rc = pHlp->pfnSSMGetU32(pSSM, &u32);
|
---|
5961 | pSvgaR3State->fCmdBuf = u32;
|
---|
5962 | return rc;
|
---|
5963 | }
|
---|
5964 |
|
---|
5965 | static int vmsvgaR3LoadGbo(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, VMSVGAGBO *pGbo)
|
---|
5966 | {
|
---|
5967 | PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3;
|
---|
5968 |
|
---|
5969 | int rc;
|
---|
5970 | pHlp->pfnSSMGetU32(pSSM, &pGbo->fGboFlags);
|
---|
5971 | pHlp->pfnSSMGetU32(pSSM, &pGbo->cTotalPages);
|
---|
5972 | pHlp->pfnSSMGetU32(pSSM, &pGbo->cbTotal);
|
---|
5973 | rc = pHlp->pfnSSMGetU32(pSSM, &pGbo->cDescriptors);
|
---|
5974 | AssertRCReturn(rc, rc);
|
---|
5975 |
|
---|
5976 | if (pGbo->cDescriptors)
|
---|
5977 | {
|
---|
5978 | pGbo->paDescriptors = (PVMSVGAGBODESCRIPTOR)RTMemAllocZ(pGbo->cDescriptors * sizeof(VMSVGAGBODESCRIPTOR));
|
---|
5979 | AssertPtrReturn(pGbo->paDescriptors, VERR_NO_MEMORY);
|
---|
5980 | }
|
---|
5981 |
|
---|
5982 | for (uint32_t iDesc = 0; iDesc < pGbo->cDescriptors; ++iDesc)
|
---|
5983 | {
|
---|
5984 | PVMSVGAGBODESCRIPTOR pDesc = &pGbo->paDescriptors[iDesc];
|
---|
5985 | pHlp->pfnSSMGetGCPhys(pSSM, &pDesc->GCPhys);
|
---|
5986 | rc = pHlp->pfnSSMGetU64(pSSM, &pDesc->cPages);
|
---|
5987 | }
|
---|
5988 |
|
---|
5989 | if (pGbo->fGboFlags & VMSVGAGBO_F_HOST_BACKED)
|
---|
5990 | {
|
---|
5991 | pGbo->pvHost = RTMemAlloc(pGbo->cbTotal);
|
---|
5992 | AssertPtrReturn(pGbo->pvHost, VERR_NO_MEMORY);
|
---|
5993 | rc = pHlp->pfnSSMGetMem(pSSM, pGbo->pvHost, pGbo->cbTotal);
|
---|
5994 | }
|
---|
5995 |
|
---|
5996 | return rc;
|
---|
5997 | }
|
---|
5998 |
|
---|
5999 | /**
|
---|
6000 | * Portion of VMSVGA state which must be loaded oin the FIFO thread.
|
---|
6001 | */
|
---|
6002 | static int vmsvgaR3LoadExecFifo(PCPDMDEVHLPR3 pHlp, PVGASTATE pThis, PVGASTATECC pThisCC,
|
---|
6003 | PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)
|
---|
6004 | {
|
---|
6005 | RT_NOREF(uPass);
|
---|
6006 |
|
---|
6007 | PVMSVGAR3STATE pSVGAState = pThisCC->svga.pSvgaR3State;
|
---|
6008 | int rc;
|
---|
6009 |
|
---|
6010 | if (uVersion >= VGA_SAVEDSTATE_VERSION_VMSVGA_SCREENS)
|
---|
6011 | {
|
---|
6012 | uint32_t cScreens = 0;
|
---|
6013 | rc = pHlp->pfnSSMGetU32(pSSM, &cScreens);
|
---|
6014 | AssertRCReturn(rc, rc);
|
---|
6015 | AssertLogRelMsgReturn(cScreens <= _64K, /* big enough */
|
---|
6016 | ("cScreens=%#x\n", cScreens),
|
---|
6017 | VERR_SSM_DATA_UNIT_FORMAT_CHANGED);
|
---|
6018 |
|
---|
6019 | for (uint32_t i = 0; i < cScreens; ++i)
|
---|
6020 | {
|
---|
6021 | VMSVGASCREENOBJECT screen;
|
---|
6022 | RT_ZERO(screen);
|
---|
6023 |
|
---|
6024 | rc = pHlp->pfnSSMGetStructEx(pSSM, &screen, sizeof(screen), 0, g_aVMSVGASCREENOBJECTFields, NULL);
|
---|
6025 | AssertLogRelRCReturn(rc, rc);
|
---|
6026 |
|
---|
6027 | if (screen.idScreen < RT_ELEMENTS(pSVGAState->aScreens))
|
---|
6028 | {
|
---|
6029 | VMSVGASCREENOBJECT *pScreen = &pSVGAState->aScreens[screen.idScreen];
|
---|
6030 | *pScreen = screen;
|
---|
6031 | pScreen->fModified = true;
|
---|
6032 |
|
---|
6033 | if (uVersion >= VGA_SAVEDSTATE_VERSION_VMSVGA_DX)
|
---|
6034 | {
|
---|
6035 | uint32_t u32;
|
---|
6036 | pHlp->pfnSSMGetU32(pSSM, &u32); /* Size of screen bitmap. */
|
---|
6037 | AssertLogRelRCReturn(rc, rc);
|
---|
6038 | if (u32)
|
---|
6039 | {
|
---|
6040 | pScreen->pvScreenBitmap = RTMemAlloc(u32);
|
---|
6041 | AssertPtrReturn(pScreen->pvScreenBitmap, VERR_NO_MEMORY);
|
---|
6042 |
|
---|
6043 | pHlp->pfnSSMGetMem(pSSM, pScreen->pvScreenBitmap, u32);
|
---|
6044 | }
|
---|
6045 | }
|
---|
6046 | }
|
---|
6047 | else
|
---|
6048 | {
|
---|
6049 | LogRel(("VGA: ignored screen object %d\n", screen.idScreen));
|
---|
6050 | }
|
---|
6051 | }
|
---|
6052 | }
|
---|
6053 | else
|
---|
6054 | {
|
---|
6055 | /* Try to setup at least the first screen. */
|
---|
6056 | VMSVGASCREENOBJECT *pScreen = &pSVGAState->aScreens[0];
|
---|
6057 | Assert(pScreen->idScreen == 0);
|
---|
6058 | pScreen->fDefined = true;
|
---|
6059 | pScreen->fModified = true;
|
---|
6060 | pScreen->fuScreen = SVGA_SCREEN_MUST_BE_SET | SVGA_SCREEN_IS_PRIMARY;
|
---|
6061 | pScreen->xOrigin = 0;
|
---|
6062 | pScreen->yOrigin = 0;
|
---|
6063 | pScreen->offVRAM = pThis->svga.uScreenOffset;
|
---|
6064 | pScreen->cbPitch = pThis->svga.cbScanline;
|
---|
6065 | pScreen->cWidth = pThis->svga.uWidth;
|
---|
6066 | pScreen->cHeight = pThis->svga.uHeight;
|
---|
6067 | pScreen->cBpp = pThis->svga.uBpp;
|
---|
6068 | }
|
---|
6069 |
|
---|
6070 | return VINF_SUCCESS;
|
---|
6071 | }
|
---|
6072 |
|
---|
6073 | /**
|
---|
6074 | * @copydoc FNSSMDEVLOADEXEC
|
---|
6075 | */
|
---|
6076 | int vmsvgaR3LoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)
|
---|
6077 | {
|
---|
6078 | RT_NOREF(uPass);
|
---|
6079 | PVGASTATE pThis = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
|
---|
6080 | PVGASTATECC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC);
|
---|
6081 | PVMSVGAR3STATE pSVGAState = pThisCC->svga.pSvgaR3State;
|
---|
6082 | PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3;
|
---|
6083 | int rc;
|
---|
6084 |
|
---|
6085 | /* Load our part of the VGAState */
|
---|
6086 | rc = pHlp->pfnSSMGetStructEx(pSSM, &pThis->svga, sizeof(pThis->svga), 0, g_aVGAStateSVGAFields, NULL);
|
---|
6087 | AssertRCReturn(rc, rc);
|
---|
6088 |
|
---|
6089 | /* Load the VGA framebuffer. */
|
---|
6090 | AssertCompile(VMSVGA_VGA_FB_BACKUP_SIZE >= _32K);
|
---|
6091 | uint32_t cbVgaFramebuffer = _32K;
|
---|
6092 | if (uVersion >= VGA_SAVEDSTATE_VERSION_VMSVGA_VGA_FB_FIX)
|
---|
6093 | {
|
---|
6094 | rc = pHlp->pfnSSMGetU32(pSSM, &cbVgaFramebuffer);
|
---|
6095 | AssertRCReturn(rc, rc);
|
---|
6096 | AssertLogRelMsgReturn(cbVgaFramebuffer <= _4M && cbVgaFramebuffer >= _32K && RT_IS_POWER_OF_TWO(cbVgaFramebuffer),
|
---|
6097 | ("cbVgaFramebuffer=%#x - expected 32KB..4MB, power of two\n", cbVgaFramebuffer),
|
---|
6098 | VERR_SSM_DATA_UNIT_FORMAT_CHANGED);
|
---|
6099 | AssertCompile(VMSVGA_VGA_FB_BACKUP_SIZE <= _4M);
|
---|
6100 | AssertCompile(RT_IS_POWER_OF_TWO(VMSVGA_VGA_FB_BACKUP_SIZE));
|
---|
6101 | }
|
---|
6102 | rc = pHlp->pfnSSMGetMem(pSSM, pThisCC->svga.pbVgaFrameBufferR3, RT_MIN(cbVgaFramebuffer, VMSVGA_VGA_FB_BACKUP_SIZE));
|
---|
6103 | AssertRCReturn(rc, rc);
|
---|
6104 | if (cbVgaFramebuffer > VMSVGA_VGA_FB_BACKUP_SIZE)
|
---|
6105 | pHlp->pfnSSMSkip(pSSM, cbVgaFramebuffer - VMSVGA_VGA_FB_BACKUP_SIZE);
|
---|
6106 | else if (cbVgaFramebuffer < VMSVGA_VGA_FB_BACKUP_SIZE)
|
---|
6107 | RT_BZERO(&pThisCC->svga.pbVgaFrameBufferR3[cbVgaFramebuffer], VMSVGA_VGA_FB_BACKUP_SIZE - cbVgaFramebuffer);
|
---|
6108 |
|
---|
6109 | /* Load the VMSVGA state. */
|
---|
6110 | rc = pHlp->pfnSSMGetStructEx(pSSM, pSVGAState, sizeof(*pSVGAState), 0, g_aVMSVGAR3STATEFields, NULL);
|
---|
6111 | AssertRCReturn(rc, rc);
|
---|
6112 |
|
---|
6113 | /* Load the active cursor bitmaps. */
|
---|
6114 | if (pSVGAState->Cursor.fActive)
|
---|
6115 | {
|
---|
6116 | pSVGAState->Cursor.pData = RTMemAlloc(pSVGAState->Cursor.cbData);
|
---|
6117 | AssertReturn(pSVGAState->Cursor.pData, VERR_NO_MEMORY);
|
---|
6118 |
|
---|
6119 | rc = pHlp->pfnSSMGetMem(pSSM, pSVGAState->Cursor.pData, pSVGAState->Cursor.cbData);
|
---|
6120 | AssertRCReturn(rc, rc);
|
---|
6121 | }
|
---|
6122 |
|
---|
6123 | /* Load the GMR state. */
|
---|
6124 | uint32_t cGMR = 256; /* Hardcoded in previous saved state versions. */
|
---|
6125 | if (uVersion >= VGA_SAVEDSTATE_VERSION_VMSVGA_GMR_COUNT)
|
---|
6126 | {
|
---|
6127 | rc = pHlp->pfnSSMGetU32(pSSM, &cGMR);
|
---|
6128 | AssertRCReturn(rc, rc);
|
---|
6129 | /* Numbers of GMRs was never less than 256. 1MB is a large arbitrary limit. */
|
---|
6130 | AssertLogRelMsgReturn(cGMR <= _1M && cGMR >= 256,
|
---|
6131 | ("cGMR=%#x - expected 256B..1MB\n", cGMR),
|
---|
6132 | VERR_SSM_DATA_UNIT_FORMAT_CHANGED);
|
---|
6133 | }
|
---|
6134 |
|
---|
6135 | if (pThis->svga.cGMR != cGMR)
|
---|
6136 | {
|
---|
6137 | /* Reallocate GMR array. */
|
---|
6138 | Assert(pSVGAState->paGMR != NULL);
|
---|
6139 | RTMemFree(pSVGAState->paGMR);
|
---|
6140 | pSVGAState->paGMR = (PGMR)RTMemAllocZ(cGMR * sizeof(GMR));
|
---|
6141 | AssertReturn(pSVGAState->paGMR, VERR_NO_MEMORY);
|
---|
6142 | pThis->svga.cGMR = cGMR;
|
---|
6143 | }
|
---|
6144 |
|
---|
6145 | for (uint32_t i = 0; i < cGMR; ++i)
|
---|
6146 | {
|
---|
6147 | PGMR pGMR = &pSVGAState->paGMR[i];
|
---|
6148 |
|
---|
6149 | rc = pHlp->pfnSSMGetStructEx(pSSM, pGMR, sizeof(*pGMR), 0, g_aGMRFields, NULL);
|
---|
6150 | AssertRCReturn(rc, rc);
|
---|
6151 |
|
---|
6152 | if (pGMR->numDescriptors)
|
---|
6153 | {
|
---|
6154 | Assert(pGMR->cMaxPages || pGMR->cbTotal);
|
---|
6155 | pGMR->paDesc = (PVMSVGAGMRDESCRIPTOR)RTMemAllocZ(pGMR->numDescriptors * sizeof(VMSVGAGMRDESCRIPTOR));
|
---|
6156 | AssertReturn(pGMR->paDesc, VERR_NO_MEMORY);
|
---|
6157 |
|
---|
6158 | for (uint32_t j = 0; j < pGMR->numDescriptors; ++j)
|
---|
6159 | {
|
---|
6160 | rc = pHlp->pfnSSMGetStructEx(pSSM, &pGMR->paDesc[j], sizeof(pGMR->paDesc[j]), 0, g_aVMSVGAGMRDESCRIPTORFields, NULL);
|
---|
6161 | AssertRCReturn(rc, rc);
|
---|
6162 | }
|
---|
6163 | }
|
---|
6164 | }
|
---|
6165 |
|
---|
6166 | if (uVersion >= VGA_SAVEDSTATE_VERSION_VMSVGA_DX)
|
---|
6167 | {
|
---|
6168 | bool f;
|
---|
6169 | uint32_t u32;
|
---|
6170 |
|
---|
6171 | if (uVersion >= VGA_SAVEDSTATE_VERSION_VMSVGA_DX_CMDBUF)
|
---|
6172 | {
|
---|
6173 | /* Command buffers are saved independently from VGPU10. */
|
---|
6174 | rc = pHlp->pfnSSMGetBool(pSSM, &f);
|
---|
6175 | AssertLogRelRCReturn(rc, rc);
|
---|
6176 | if (f)
|
---|
6177 | {
|
---|
6178 | rc = vmsvgaR3LoadCommandBuffers(pDevIns, pThis, pThisCC, pSSM);
|
---|
6179 | AssertLogRelRCReturn(rc, rc);
|
---|
6180 | }
|
---|
6181 | }
|
---|
6182 |
|
---|
6183 | rc = pHlp->pfnSSMGetBool(pSSM, &f);
|
---|
6184 | AssertLogRelRCReturn(rc, rc);
|
---|
6185 | pThis->fVMSVGA10 = f;
|
---|
6186 |
|
---|
6187 | if (pThis->fVMSVGA10)
|
---|
6188 | {
|
---|
6189 | if (uVersion < VGA_SAVEDSTATE_VERSION_VMSVGA_DX_CMDBUF)
|
---|
6190 | {
|
---|
6191 | rc = vmsvgaR3LoadCommandBuffers(pDevIns, pThis, pThisCC, pSSM);
|
---|
6192 | AssertLogRelRCReturn(rc, rc);
|
---|
6193 | }
|
---|
6194 |
|
---|
6195 | /*
|
---|
6196 | * OTables GBOs.
|
---|
6197 | */
|
---|
6198 | rc = pHlp->pfnSSMGetU32(pSSM, &u32);
|
---|
6199 | AssertLogRelRCReturn(rc, rc);
|
---|
6200 | AssertReturn(u32 == SVGA_OTABLE_MAX, VERR_INVALID_STATE);
|
---|
6201 | for (int i = 0; i < SVGA_OTABLE_MAX; ++i)
|
---|
6202 | {
|
---|
6203 | VMSVGAGBO *pGbo = &pSVGAState->aGboOTables[i];
|
---|
6204 | rc = vmsvgaR3LoadGbo(pDevIns, pSSM, pGbo);
|
---|
6205 | AssertRCReturn(rc, rc);
|
---|
6206 | }
|
---|
6207 |
|
---|
6208 | /*
|
---|
6209 | * MOBs.
|
---|
6210 | */
|
---|
6211 | for (;;)
|
---|
6212 | {
|
---|
6213 | rc = pHlp->pfnSSMGetU32(pSSM, &u32); /* MOB id. */
|
---|
6214 | AssertRCReturn(rc, rc);
|
---|
6215 | if (u32 == SVGA_ID_INVALID)
|
---|
6216 | break;
|
---|
6217 |
|
---|
6218 | PVMSVGAMOB pMob = (PVMSVGAMOB)RTMemAllocZ(sizeof(*pMob));
|
---|
6219 | AssertPtrReturn(pMob, VERR_NO_MEMORY);
|
---|
6220 |
|
---|
6221 | rc = vmsvgaR3LoadGbo(pDevIns, pSSM, &pMob->Gbo);
|
---|
6222 | AssertRCReturn(rc, rc);
|
---|
6223 |
|
---|
6224 | pMob->Core.Key = u32;
|
---|
6225 | if (RTAvlU32Insert(&pSVGAState->MOBTree, &pMob->Core))
|
---|
6226 | RTListPrepend(&pSVGAState->MOBLRUList, &pMob->nodeLRU);
|
---|
6227 | else
|
---|
6228 | AssertFailedReturn(VERR_NO_MEMORY);
|
---|
6229 | }
|
---|
6230 |
|
---|
6231 | # ifdef VMSVGA3D_DX
|
---|
6232 | if (pThis->svga.f3DEnabled)
|
---|
6233 | {
|
---|
6234 | pHlp->pfnSSMGetU32(pSSM, &pSVGAState->idDXContextCurrent);
|
---|
6235 | }
|
---|
6236 | # endif
|
---|
6237 | }
|
---|
6238 | }
|
---|
6239 |
|
---|
6240 | # ifdef RT_OS_DARWIN /** @todo r=bird: this is normally done on the EMT, so for DARWIN we do that when loading saved state too now. See DevVGA-SVGA3d-shared.h. */
|
---|
6241 | vmsvgaR3PowerOnDevice(pDevIns, pThis, pThisCC, /*fLoadState=*/ true);
|
---|
6242 | # endif
|
---|
6243 |
|
---|
6244 | VMSVGA_STATE_LOAD LoadState;
|
---|
6245 | LoadState.pSSM = pSSM;
|
---|
6246 | LoadState.uVersion = uVersion;
|
---|
6247 | LoadState.uPass = uPass;
|
---|
6248 | rc = vmsvgaR3RunExtCmdOnFifoThread(pDevIns, pThis, pThisCC, VMSVGA_FIFO_EXTCMD_LOADSTATE, &LoadState, RT_INDEFINITE_WAIT);
|
---|
6249 | AssertLogRelRCReturn(rc, rc);
|
---|
6250 |
|
---|
6251 | return VINF_SUCCESS;
|
---|
6252 | }
|
---|
6253 |
|
---|
6254 | /**
|
---|
6255 | * Reinit the video mode after the state has been loaded.
|
---|
6256 | */
|
---|
6257 | int vmsvgaR3LoadDone(PPDMDEVINS pDevIns)
|
---|
6258 | {
|
---|
6259 | PVGASTATE pThis = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
|
---|
6260 | PVGASTATECC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC);
|
---|
6261 | PVMSVGAR3STATE pSVGAState = pThisCC->svga.pSvgaR3State;
|
---|
6262 |
|
---|
6263 | /* VMSVGA is working via VBVA interface, therefore it needs to be
|
---|
6264 | * enabled on saved state restore. See @bugref{10071#c7}. */
|
---|
6265 | if (pThis->svga.fEnabled)
|
---|
6266 | {
|
---|
6267 | for (uint32_t idScreen = 0; idScreen < pThis->cMonitors; ++idScreen)
|
---|
6268 | pThisCC->pDrv->pfnVBVAEnable(pThisCC->pDrv, idScreen, NULL /*pHostFlags*/);
|
---|
6269 | }
|
---|
6270 |
|
---|
6271 | /* Set the active cursor. */
|
---|
6272 | if (pSVGAState->Cursor.fActive)
|
---|
6273 | {
|
---|
6274 | /* We don't store the alpha flag, but we can take a guess that if
|
---|
6275 | * the old register interface was used, the cursor was B&W.
|
---|
6276 | */
|
---|
6277 | bool fAlpha = pThis->svga.uCursorOn ? false : true;
|
---|
6278 |
|
---|
6279 | int rc = pThisCC->pDrv->pfnVBVAMousePointerShape(pThisCC->pDrv,
|
---|
6280 | true /*fVisible*/,
|
---|
6281 | fAlpha,
|
---|
6282 | pSVGAState->Cursor.xHotspot,
|
---|
6283 | pSVGAState->Cursor.yHotspot,
|
---|
6284 | pSVGAState->Cursor.width,
|
---|
6285 | pSVGAState->Cursor.height,
|
---|
6286 | pSVGAState->Cursor.pData);
|
---|
6287 | AssertRC(rc);
|
---|
6288 |
|
---|
6289 | if (pThis->svga.uCursorOn)
|
---|
6290 | pThisCC->pDrv->pfnVBVAReportCursorPosition(pThisCC->pDrv, VBVA_CURSOR_VALID_DATA, SVGA_ID_INVALID, pThis->svga.uCursorX, pThis->svga.uCursorY);
|
---|
6291 | }
|
---|
6292 |
|
---|
6293 | /* If the VRAM handler should not be registered, we have to explicitly
|
---|
6294 | * unregister it here!
|
---|
6295 | */
|
---|
6296 | if (!pThis->svga.fVRAMTracking)
|
---|
6297 | {
|
---|
6298 | vgaR3UnregisterVRAMHandler(pDevIns, pThis);
|
---|
6299 | }
|
---|
6300 |
|
---|
6301 | /* Let the FIFO thread deal with changing the mode. */
|
---|
6302 | ASMAtomicOrU32(&pThis->svga.u32ActionFlags, VMSVGA_ACTION_CHANGEMODE);
|
---|
6303 |
|
---|
6304 | return VINF_SUCCESS;
|
---|
6305 | }
|
---|
6306 |
|
---|
6307 | static int vmsvgaR3SaveBufCtx(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, PVMSVGACMDBUFCTX pBufCtx)
|
---|
6308 | {
|
---|
6309 | PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3;
|
---|
6310 |
|
---|
6311 | int rc = pHlp->pfnSSMPutU32(pSSM, pBufCtx->cSubmitted);
|
---|
6312 | AssertLogRelRCReturn(rc, rc);
|
---|
6313 | if (pBufCtx->cSubmitted)
|
---|
6314 | {
|
---|
6315 | PVMSVGACMDBUF pIter;
|
---|
6316 | RTListForEach(&pBufCtx->listSubmitted, pIter, VMSVGACMDBUF, nodeBuffer)
|
---|
6317 | {
|
---|
6318 | pHlp->pfnSSMPutGCPhys(pSSM, pIter->GCPhysCB);
|
---|
6319 | pHlp->pfnSSMPutU32(pSSM, sizeof(SVGACBHeader));
|
---|
6320 | pHlp->pfnSSMPutMem(pSSM, &pIter->hdr, sizeof(SVGACBHeader));
|
---|
6321 | pHlp->pfnSSMPutU32(pSSM, pIter->hdr.length);
|
---|
6322 | if (pIter->hdr.length)
|
---|
6323 | rc = pHlp->pfnSSMPutMem(pSSM, pIter->pvCommands, pIter->hdr.length);
|
---|
6324 | AssertLogRelRCReturn(rc, rc);
|
---|
6325 | }
|
---|
6326 | }
|
---|
6327 | return rc;
|
---|
6328 | }
|
---|
6329 |
|
---|
6330 | static int vmsvgaR3SaveGbo(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, VMSVGAGBO *pGbo)
|
---|
6331 | {
|
---|
6332 | PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3;
|
---|
6333 |
|
---|
6334 | int rc;
|
---|
6335 | pHlp->pfnSSMPutU32(pSSM, pGbo->fGboFlags);
|
---|
6336 | pHlp->pfnSSMPutU32(pSSM, pGbo->cTotalPages);
|
---|
6337 | pHlp->pfnSSMPutU32(pSSM, pGbo->cbTotal);
|
---|
6338 | rc = pHlp->pfnSSMPutU32(pSSM, pGbo->cDescriptors);
|
---|
6339 | for (uint32_t iDesc = 0; iDesc < pGbo->cDescriptors; ++iDesc)
|
---|
6340 | {
|
---|
6341 | PVMSVGAGBODESCRIPTOR pDesc = &pGbo->paDescriptors[iDesc];
|
---|
6342 | pHlp->pfnSSMPutGCPhys(pSSM, pDesc->GCPhys);
|
---|
6343 | rc = pHlp->pfnSSMPutU64(pSSM, pDesc->cPages);
|
---|
6344 | }
|
---|
6345 | if (pGbo->fGboFlags & VMSVGAGBO_F_HOST_BACKED)
|
---|
6346 | rc = pHlp->pfnSSMPutMem(pSSM, pGbo->pvHost, pGbo->cbTotal);
|
---|
6347 | return rc;
|
---|
6348 | }
|
---|
6349 |
|
---|
6350 | /**
|
---|
6351 | * Portion of SVGA state which must be saved in the FIFO thread.
|
---|
6352 | */
|
---|
6353 | static int vmsvgaR3SaveExecFifo(PCPDMDEVHLPR3 pHlp, PVGASTATECC pThisCC, PSSMHANDLE pSSM)
|
---|
6354 | {
|
---|
6355 | PVMSVGAR3STATE pSVGAState = pThisCC->svga.pSvgaR3State;
|
---|
6356 | int rc;
|
---|
6357 |
|
---|
6358 | /* Save the screen objects. */
|
---|
6359 | /* Count defined screen object. */
|
---|
6360 | uint32_t cScreens = 0;
|
---|
6361 | for (uint32_t i = 0; i < RT_ELEMENTS(pSVGAState->aScreens); ++i)
|
---|
6362 | {
|
---|
6363 | if (pSVGAState->aScreens[i].fDefined)
|
---|
6364 | ++cScreens;
|
---|
6365 | }
|
---|
6366 |
|
---|
6367 | rc = pHlp->pfnSSMPutU32(pSSM, cScreens);
|
---|
6368 | AssertLogRelRCReturn(rc, rc);
|
---|
6369 |
|
---|
6370 | for (uint32_t i = 0; i < RT_ELEMENTS(pSVGAState->aScreens); ++i)
|
---|
6371 | {
|
---|
6372 | VMSVGASCREENOBJECT *pScreen = &pSVGAState->aScreens[i];
|
---|
6373 | if (!pScreen->fDefined)
|
---|
6374 | continue;
|
---|
6375 |
|
---|
6376 | rc = pHlp->pfnSSMPutStructEx(pSSM, pScreen, sizeof(*pScreen), 0, g_aVMSVGASCREENOBJECTFields, NULL);
|
---|
6377 | AssertLogRelRCReturn(rc, rc);
|
---|
6378 |
|
---|
6379 | /*
|
---|
6380 | * VGA_SAVEDSTATE_VERSION_VMSVGA_DX
|
---|
6381 | */
|
---|
6382 | if (pScreen->pvScreenBitmap)
|
---|
6383 | {
|
---|
6384 | uint32_t const cbScreenBitmap = pScreen->cHeight * pScreen->cbPitch;
|
---|
6385 | pHlp->pfnSSMPutU32(pSSM, cbScreenBitmap);
|
---|
6386 | pHlp->pfnSSMPutMem(pSSM, pScreen->pvScreenBitmap, cbScreenBitmap);
|
---|
6387 | }
|
---|
6388 | else
|
---|
6389 | pHlp->pfnSSMPutU32(pSSM, 0);
|
---|
6390 | }
|
---|
6391 | return VINF_SUCCESS;
|
---|
6392 | }
|
---|
6393 |
|
---|
6394 | /**
|
---|
6395 | * @copydoc FNSSMDEVSAVEEXEC
|
---|
6396 | */
|
---|
6397 | int vmsvgaR3SaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM)
|
---|
6398 | {
|
---|
6399 | PVGASTATE pThis = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
|
---|
6400 | PVGASTATECC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC);
|
---|
6401 | PVMSVGAR3STATE pSVGAState = pThisCC->svga.pSvgaR3State;
|
---|
6402 | PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3;
|
---|
6403 | int rc;
|
---|
6404 |
|
---|
6405 | /* Save our part of the VGAState */
|
---|
6406 | rc = pHlp->pfnSSMPutStructEx(pSSM, &pThis->svga, sizeof(pThis->svga), 0, g_aVGAStateSVGAFields, NULL);
|
---|
6407 | AssertLogRelRCReturn(rc, rc);
|
---|
6408 |
|
---|
6409 | /* Save the framebuffer backup. */
|
---|
6410 | rc = pHlp->pfnSSMPutU32(pSSM, VMSVGA_VGA_FB_BACKUP_SIZE);
|
---|
6411 | rc = pHlp->pfnSSMPutMem(pSSM, pThisCC->svga.pbVgaFrameBufferR3, VMSVGA_VGA_FB_BACKUP_SIZE);
|
---|
6412 | AssertLogRelRCReturn(rc, rc);
|
---|
6413 |
|
---|
6414 | /* Save the VMSVGA state. */
|
---|
6415 | rc = pHlp->pfnSSMPutStructEx(pSSM, pSVGAState, sizeof(*pSVGAState), 0, g_aVMSVGAR3STATEFields, NULL);
|
---|
6416 | AssertLogRelRCReturn(rc, rc);
|
---|
6417 |
|
---|
6418 | /* Save the active cursor bitmaps. */
|
---|
6419 | if (pSVGAState->Cursor.fActive)
|
---|
6420 | {
|
---|
6421 | rc = pHlp->pfnSSMPutMem(pSSM, pSVGAState->Cursor.pData, pSVGAState->Cursor.cbData);
|
---|
6422 | AssertLogRelRCReturn(rc, rc);
|
---|
6423 | }
|
---|
6424 |
|
---|
6425 | /* Save the GMR state */
|
---|
6426 | rc = pHlp->pfnSSMPutU32(pSSM, pThis->svga.cGMR);
|
---|
6427 | AssertLogRelRCReturn(rc, rc);
|
---|
6428 | for (uint32_t i = 0; i < pThis->svga.cGMR; ++i)
|
---|
6429 | {
|
---|
6430 | PGMR pGMR = &pSVGAState->paGMR[i];
|
---|
6431 |
|
---|
6432 | rc = pHlp->pfnSSMPutStructEx(pSSM, pGMR, sizeof(*pGMR), 0, g_aGMRFields, NULL);
|
---|
6433 | AssertLogRelRCReturn(rc, rc);
|
---|
6434 |
|
---|
6435 | for (uint32_t j = 0; j < pGMR->numDescriptors; ++j)
|
---|
6436 | {
|
---|
6437 | rc = pHlp->pfnSSMPutStructEx(pSSM, &pGMR->paDesc[j], sizeof(pGMR->paDesc[j]), 0, g_aVMSVGAGMRDESCRIPTORFields, NULL);
|
---|
6438 | AssertLogRelRCReturn(rc, rc);
|
---|
6439 | }
|
---|
6440 | }
|
---|
6441 |
|
---|
6442 | /*
|
---|
6443 | * VGA_SAVEDSTATE_VERSION_VMSVGA_DX+
|
---|
6444 | */
|
---|
6445 | if (pThis->svga.u32DeviceCaps & SVGA_CAP_COMMAND_BUFFERS)
|
---|
6446 | {
|
---|
6447 | rc = pHlp->pfnSSMPutBool(pSSM, true);
|
---|
6448 | AssertLogRelRCReturn(rc, rc);
|
---|
6449 |
|
---|
6450 | /* Device context command buffers. */
|
---|
6451 | rc = vmsvgaR3SaveBufCtx(pDevIns, pSSM, &pSVGAState->CmdBufCtxDC);
|
---|
6452 | AssertRCReturn(rc, rc);
|
---|
6453 |
|
---|
6454 | /* DX contexts command buffers. */
|
---|
6455 | rc = pHlp->pfnSSMPutU32(pSSM, RT_ELEMENTS(pSVGAState->apCmdBufCtxs));
|
---|
6456 | AssertLogRelRCReturn(rc, rc);
|
---|
6457 | for (unsigned i = 0; i < RT_ELEMENTS(pSVGAState->apCmdBufCtxs); ++i)
|
---|
6458 | {
|
---|
6459 | if (pSVGAState->apCmdBufCtxs[i])
|
---|
6460 | {
|
---|
6461 | pHlp->pfnSSMPutBool(pSSM, true);
|
---|
6462 | rc = vmsvgaR3SaveBufCtx(pDevIns, pSSM, pSVGAState->apCmdBufCtxs[i]);
|
---|
6463 | AssertRCReturn(rc, rc);
|
---|
6464 | }
|
---|
6465 | else
|
---|
6466 | pHlp->pfnSSMPutBool(pSSM, false);
|
---|
6467 | }
|
---|
6468 |
|
---|
6469 | rc = pHlp->pfnSSMPutU32(pSSM, pSVGAState->fCmdBuf);
|
---|
6470 | AssertRCReturn(rc, rc);
|
---|
6471 | }
|
---|
6472 | else
|
---|
6473 | {
|
---|
6474 | rc = pHlp->pfnSSMPutBool(pSSM, false);
|
---|
6475 | AssertLogRelRCReturn(rc, rc);
|
---|
6476 | }
|
---|
6477 |
|
---|
6478 | rc = pHlp->pfnSSMPutBool(pSSM, pThis->fVMSVGA10);
|
---|
6479 | AssertLogRelRCReturn(rc, rc);
|
---|
6480 |
|
---|
6481 | if (pThis->fVMSVGA10)
|
---|
6482 | {
|
---|
6483 | /*
|
---|
6484 | * OTables GBOs.
|
---|
6485 | */
|
---|
6486 | pHlp->pfnSSMPutU32(pSSM, SVGA_OTABLE_MAX);
|
---|
6487 | for (int i = 0; i < SVGA_OTABLE_MAX; ++i)
|
---|
6488 | {
|
---|
6489 | VMSVGAGBO *pGbo = &pSVGAState->aGboOTables[i];
|
---|
6490 | rc = vmsvgaR3SaveGbo(pDevIns, pSSM, pGbo);
|
---|
6491 | AssertRCReturn(rc, rc);
|
---|
6492 | }
|
---|
6493 |
|
---|
6494 | /*
|
---|
6495 | * MOBs.
|
---|
6496 | */
|
---|
6497 | PVMSVGAMOB pIter;
|
---|
6498 | RTListForEach(&pSVGAState->MOBLRUList, pIter, VMSVGAMOB, nodeLRU)
|
---|
6499 | {
|
---|
6500 | pHlp->pfnSSMPutU32(pSSM, pIter->Core.Key); /* MOB id. */
|
---|
6501 | rc = vmsvgaR3SaveGbo(pDevIns, pSSM, &pIter->Gbo);
|
---|
6502 | AssertRCReturn(rc, rc);
|
---|
6503 | }
|
---|
6504 |
|
---|
6505 | pHlp->pfnSSMPutU32(pSSM, SVGA_ID_INVALID); /* End marker. */
|
---|
6506 |
|
---|
6507 | # ifdef VMSVGA3D_DX
|
---|
6508 | if (pThis->svga.f3DEnabled)
|
---|
6509 | {
|
---|
6510 | pHlp->pfnSSMPutU32(pSSM, pSVGAState->idDXContextCurrent);
|
---|
6511 | }
|
---|
6512 | # endif
|
---|
6513 | }
|
---|
6514 |
|
---|
6515 | /*
|
---|
6516 | * Must save some state (3D in particular) in the FIFO thread.
|
---|
6517 | */
|
---|
6518 | rc = vmsvgaR3RunExtCmdOnFifoThread(pDevIns, pThis, pThisCC, VMSVGA_FIFO_EXTCMD_SAVESTATE, pSSM, RT_INDEFINITE_WAIT);
|
---|
6519 | AssertLogRelRCReturn(rc, rc);
|
---|
6520 |
|
---|
6521 | return VINF_SUCCESS;
|
---|
6522 | }
|
---|
6523 |
|
---|
6524 | /**
|
---|
6525 | * Destructor for PVMSVGAR3STATE structure. The structure is not deallocated.
|
---|
6526 | *
|
---|
6527 | * @param pThis The shared VGA/VMSVGA instance data.
|
---|
6528 | * @param pThisCC The device context.
|
---|
6529 | */
|
---|
6530 | static void vmsvgaR3StateTerm(PVGASTATE pThis, PVGASTATECC pThisCC)
|
---|
6531 | {
|
---|
6532 | PVMSVGAR3STATE pSVGAState = pThisCC->svga.pSvgaR3State;
|
---|
6533 |
|
---|
6534 | # ifndef VMSVGA_USE_EMT_HALT_CODE
|
---|
6535 | if (pSVGAState->hBusyDelayedEmts != NIL_RTSEMEVENTMULTI)
|
---|
6536 | {
|
---|
6537 | RTSemEventMultiDestroy(pSVGAState->hBusyDelayedEmts);
|
---|
6538 | pSVGAState->hBusyDelayedEmts = NIL_RTSEMEVENT;
|
---|
6539 | }
|
---|
6540 | # endif
|
---|
6541 |
|
---|
6542 | if (pSVGAState->Cursor.fActive)
|
---|
6543 | {
|
---|
6544 | RTMemFreeZ(pSVGAState->Cursor.pData, pSVGAState->Cursor.cbData);
|
---|
6545 | pSVGAState->Cursor.pData = NULL;
|
---|
6546 | pSVGAState->Cursor.fActive = false;
|
---|
6547 | }
|
---|
6548 |
|
---|
6549 | if (pSVGAState->paGMR)
|
---|
6550 | {
|
---|
6551 | for (unsigned i = 0; i < pThis->svga.cGMR; ++i)
|
---|
6552 | if (pSVGAState->paGMR[i].paDesc)
|
---|
6553 | RTMemFree(pSVGAState->paGMR[i].paDesc);
|
---|
6554 |
|
---|
6555 | RTMemFree(pSVGAState->paGMR);
|
---|
6556 | pSVGAState->paGMR = NULL;
|
---|
6557 | }
|
---|
6558 |
|
---|
6559 | if (RTCritSectIsInitialized(&pSVGAState->CritSectCmdBuf))
|
---|
6560 | {
|
---|
6561 | RTCritSectEnter(&pSVGAState->CritSectCmdBuf);
|
---|
6562 | for (unsigned i = 0; i < RT_ELEMENTS(pSVGAState->apCmdBufCtxs); ++i)
|
---|
6563 | {
|
---|
6564 | vmsvgaR3CmdBufCtxTerm(pSVGAState->apCmdBufCtxs[i]);
|
---|
6565 | RTMemFree(pSVGAState->apCmdBufCtxs[i]);
|
---|
6566 | pSVGAState->apCmdBufCtxs[i] = NULL;
|
---|
6567 | }
|
---|
6568 | vmsvgaR3CmdBufCtxTerm(&pSVGAState->CmdBufCtxDC);
|
---|
6569 | RTCritSectLeave(&pSVGAState->CritSectCmdBuf);
|
---|
6570 | RTCritSectDelete(&pSVGAState->CritSectCmdBuf);
|
---|
6571 | }
|
---|
6572 | }
|
---|
6573 |
|
---|
6574 | /**
|
---|
6575 | * Constructor for PVMSVGAR3STATE structure.
|
---|
6576 | *
|
---|
6577 | * @returns VBox status code.
|
---|
6578 | * @param pDevIns The PDM device instance.
|
---|
6579 | * @param pThis The shared VGA/VMSVGA instance data.
|
---|
6580 | * @param pSVGAState Pointer to the structure. It is already allocated.
|
---|
6581 | */
|
---|
6582 | static int vmsvgaR3StateInit(PPDMDEVINS pDevIns, PVGASTATE pThis, PVMSVGAR3STATE pSVGAState)
|
---|
6583 | {
|
---|
6584 | int rc = VINF_SUCCESS;
|
---|
6585 |
|
---|
6586 | pSVGAState->pDevIns = pDevIns;
|
---|
6587 |
|
---|
6588 | pSVGAState->paGMR = (PGMR)RTMemAllocZ(pThis->svga.cGMR * sizeof(GMR));
|
---|
6589 | AssertReturn(pSVGAState->paGMR, VERR_NO_MEMORY);
|
---|
6590 |
|
---|
6591 | # ifndef VMSVGA_USE_EMT_HALT_CODE
|
---|
6592 | /* Create semaphore for delaying EMTs wait for the FIFO to stop being busy. */
|
---|
6593 | rc = RTSemEventMultiCreate(&pSVGAState->hBusyDelayedEmts);
|
---|
6594 | AssertRCReturn(rc, rc);
|
---|
6595 | # endif
|
---|
6596 |
|
---|
6597 | rc = RTCritSectInit(&pSVGAState->CritSectCmdBuf);
|
---|
6598 | AssertRCReturn(rc, rc);
|
---|
6599 |
|
---|
6600 | /* Init screen ids which are constant and allow to use a pointer to aScreens element and know its index. */
|
---|
6601 | for (uint32_t i = 0; i < RT_ELEMENTS(pSVGAState->aScreens); ++i)
|
---|
6602 | pSVGAState->aScreens[i].idScreen = i;
|
---|
6603 |
|
---|
6604 | vmsvgaR3CmdBufCtxInit(&pSVGAState->CmdBufCtxDC);
|
---|
6605 |
|
---|
6606 | RTListInit(&pSVGAState->MOBLRUList);
|
---|
6607 | # ifdef VBOX_WITH_VMSVGA3D
|
---|
6608 | # ifdef VMSVGA3D_DX
|
---|
6609 | pSVGAState->idDXContextCurrent = SVGA3D_INVALID_ID;
|
---|
6610 | # endif
|
---|
6611 | # endif
|
---|
6612 | return rc;
|
---|
6613 | }
|
---|
6614 |
|
---|
6615 | # ifdef VBOX_WITH_VMSVGA3D
|
---|
6616 | static void vmsvga3dR3Free3dInterfaces(PVGASTATECC pThisCC)
|
---|
6617 | {
|
---|
6618 | PVMSVGAR3STATE pSVGAState = pThisCC->svga.pSvgaR3State;
|
---|
6619 |
|
---|
6620 | RTMemFree(pSVGAState->pFuncsMap);
|
---|
6621 | pSVGAState->pFuncsMap = NULL;
|
---|
6622 | RTMemFree(pSVGAState->pFuncsGBO);
|
---|
6623 | pSVGAState->pFuncsGBO = NULL;
|
---|
6624 | RTMemFree(pSVGAState->pFuncsDX);
|
---|
6625 | pSVGAState->pFuncsDX = NULL;
|
---|
6626 | RTMemFree(pSVGAState->pFuncsDXVideo);
|
---|
6627 | pSVGAState->pFuncsDXVideo = NULL;
|
---|
6628 | RTMemFree(pSVGAState->pFuncsVGPU9);
|
---|
6629 | pSVGAState->pFuncsVGPU9 = NULL;
|
---|
6630 | RTMemFree(pSVGAState->pFuncs3D);
|
---|
6631 | pSVGAState->pFuncs3D = NULL;
|
---|
6632 | }
|
---|
6633 |
|
---|
6634 | /* This structure is used only by vmsvgaR3Init3dInterfaces */
|
---|
6635 | typedef struct VMSVGA3DINTERFACE
|
---|
6636 | {
|
---|
6637 | char const *pcszName;
|
---|
6638 | uint32_t cbFuncs;
|
---|
6639 | void **ppvFuncs;
|
---|
6640 | } VMSVGA3DINTERFACE;
|
---|
6641 |
|
---|
6642 | extern VMSVGA3DBACKENDDESC const g_BackendLegacy;
|
---|
6643 | #if defined(VMSVGA3D_DX_BACKEND)
|
---|
6644 | extern VMSVGA3DBACKENDDESC const g_BackendDX;
|
---|
6645 | #endif
|
---|
6646 |
|
---|
6647 | /**
|
---|
6648 | * Initializes the optional host 3D backend interfaces.
|
---|
6649 | *
|
---|
6650 | * @returns VBox status code.
|
---|
6651 | * @param pThisCC The VGA/VMSVGA state for ring-3.
|
---|
6652 | */
|
---|
6653 | static int vmsvgaR3Init3dInterfaces(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC)
|
---|
6654 | {
|
---|
6655 | #ifndef VMSVGA3D_DX
|
---|
6656 | RT_NOREF(pThis);
|
---|
6657 | #endif
|
---|
6658 |
|
---|
6659 | PVMSVGAR3STATE pSVGAState = pThisCC->svga.pSvgaR3State;
|
---|
6660 |
|
---|
6661 | #define ENTRY_3D_INTERFACE(a_Name, a_Field) { VMSVGA3D_BACKEND_INTERFACE_NAME_##a_Name, sizeof(VMSVGA3DBACKENDFUNCS##a_Name), (void **)&pSVGAState->a_Field }
|
---|
6662 | VMSVGA3DINTERFACE a3dInterface[] =
|
---|
6663 | {
|
---|
6664 | ENTRY_3D_INTERFACE(3D, pFuncs3D),
|
---|
6665 | ENTRY_3D_INTERFACE(VGPU9, pFuncsVGPU9),
|
---|
6666 | ENTRY_3D_INTERFACE(DX, pFuncsDX),
|
---|
6667 | ENTRY_3D_INTERFACE(DXVIDEO, pFuncsDXVideo),
|
---|
6668 | ENTRY_3D_INTERFACE(MAP, pFuncsMap),
|
---|
6669 | ENTRY_3D_INTERFACE(GBO, pFuncsGBO),
|
---|
6670 | };
|
---|
6671 | #undef ENTRY_3D_INTERFACE
|
---|
6672 |
|
---|
6673 | VMSVGA3DBACKENDDESC const *pBackend = NULL;
|
---|
6674 | #if defined(VMSVGA3D_DX_BACKEND)
|
---|
6675 | if (pThis->fVMSVGA10)
|
---|
6676 | pBackend = &g_BackendDX;
|
---|
6677 | else
|
---|
6678 | #endif
|
---|
6679 | pBackend = &g_BackendLegacy;
|
---|
6680 |
|
---|
6681 | int rc = VINF_SUCCESS;
|
---|
6682 | for (uint32_t i = 0; i < RT_ELEMENTS(a3dInterface); ++i)
|
---|
6683 | {
|
---|
6684 | VMSVGA3DINTERFACE *p = &a3dInterface[i];
|
---|
6685 |
|
---|
6686 | int rc2 = pBackend->pfnQueryInterface(pThisCC, p->pcszName, NULL, p->cbFuncs);
|
---|
6687 | if (RT_SUCCESS(rc2))
|
---|
6688 | {
|
---|
6689 | *p->ppvFuncs = RTMemAllocZ(p->cbFuncs);
|
---|
6690 | AssertBreakStmt(*p->ppvFuncs, rc = VERR_NO_MEMORY);
|
---|
6691 |
|
---|
6692 | pBackend->pfnQueryInterface(pThisCC, p->pcszName, *p->ppvFuncs, p->cbFuncs);
|
---|
6693 | }
|
---|
6694 | }
|
---|
6695 |
|
---|
6696 | if (RT_SUCCESS(rc))
|
---|
6697 | {
|
---|
6698 | rc = vmsvga3dInit(pDevIns, pThis, pThisCC);
|
---|
6699 | if (RT_SUCCESS(rc))
|
---|
6700 | return VINF_SUCCESS;
|
---|
6701 | }
|
---|
6702 |
|
---|
6703 | vmsvga3dR3Free3dInterfaces(pThisCC);
|
---|
6704 | return rc;
|
---|
6705 | }
|
---|
6706 | # endif /* VBOX_WITH_VMSVGA3D */
|
---|
6707 |
|
---|
6708 | /**
|
---|
6709 | * Compute the host capabilities: device and FIFO.
|
---|
6710 | *
|
---|
6711 | * Depends on 3D backend initialization.
|
---|
6712 | *
|
---|
6713 | * @param pThis The shared VGA/VMSVGA instance data.
|
---|
6714 | * @param pThisCC The VGA/VMSVGA state for ring-3.
|
---|
6715 | * @param pu32DeviceCaps Device capabilities (SVGA_CAP_*).
|
---|
6716 | * @param pu32DeviceCaps2 Device capabilities (SVGA_CAP2_*).
|
---|
6717 | * @param pu32FIFOCaps FIFO capabilities (SVGA_FIFO_CAPS_*).
|
---|
6718 | */
|
---|
6719 | static void vmsvgaR3GetCaps(PVGASTATE pThis, PVGASTATECC pThisCC, uint32_t *pu32DeviceCaps, uint32_t *pu32DeviceCaps2, uint32_t *pu32FIFOCaps)
|
---|
6720 | {
|
---|
6721 | #ifndef VBOX_WITH_VMSVGA3D
|
---|
6722 | RT_NOREF(pThisCC);
|
---|
6723 | #endif
|
---|
6724 |
|
---|
6725 | /* Device caps. */
|
---|
6726 | *pu32DeviceCaps = SVGA_CAP_GMR
|
---|
6727 | | SVGA_CAP_GMR2
|
---|
6728 | | SVGA_CAP_CURSOR
|
---|
6729 | | SVGA_CAP_CURSOR_BYPASS
|
---|
6730 | | SVGA_CAP_CURSOR_BYPASS_2
|
---|
6731 | | SVGA_CAP_EXTENDED_FIFO
|
---|
6732 | | SVGA_CAP_IRQMASK
|
---|
6733 | | SVGA_CAP_PITCHLOCK
|
---|
6734 | | SVGA_CAP_RECT_COPY
|
---|
6735 | | SVGA_CAP_TRACES
|
---|
6736 | | SVGA_CAP_SCREEN_OBJECT_2
|
---|
6737 | | SVGA_CAP_ALPHA_CURSOR;
|
---|
6738 |
|
---|
6739 | *pu32DeviceCaps |= SVGA_CAP_COMMAND_BUFFERS /* Enable register based command buffer submission. */
|
---|
6740 | ;
|
---|
6741 |
|
---|
6742 | *pu32DeviceCaps2 = SVGA_CAP2_NONE;
|
---|
6743 |
|
---|
6744 | /* VGPU10 capabilities. */
|
---|
6745 | if (pThis->fVMSVGA10)
|
---|
6746 | {
|
---|
6747 | # ifdef VBOX_WITH_VMSVGA3D
|
---|
6748 | if (pThisCC->svga.pSvgaR3State->pFuncsGBO)
|
---|
6749 | *pu32DeviceCaps |= SVGA_CAP_GBOBJECTS; /* Enable guest-backed objects and surfaces. */
|
---|
6750 | if (pThisCC->svga.pSvgaR3State->pFuncsDX)
|
---|
6751 | {
|
---|
6752 | *pu32DeviceCaps |= SVGA_CAP_DX /* DX commands, and command buffers in a mob. */
|
---|
6753 | | SVGA_CAP_CAP2_REGISTER /* Extended capabilities. */
|
---|
6754 | ;
|
---|
6755 |
|
---|
6756 | if (*pu32DeviceCaps & SVGA_CAP_CAP2_REGISTER)
|
---|
6757 | *pu32DeviceCaps2 |= SVGA_CAP2_GROW_OTABLE /* "Allow the GrowOTable/DXGrowCOTable commands" */
|
---|
6758 | | SVGA_CAP2_INTRA_SURFACE_COPY /* "IntraSurfaceCopy command" */
|
---|
6759 | | SVGA_CAP2_DX2 /* Shader Model 4.1.
|
---|
6760 | * "Allow the DefineGBSurface_v3, WholeSurfaceCopy, WriteZeroSurface, and
|
---|
6761 | * HintZeroSurface commands, and the SVGA_REG_GUEST_DRIVER_ID register."
|
---|
6762 | */
|
---|
6763 | | SVGA_CAP2_GB_MEMSIZE_2 /* "Allow the SVGA_REG_GBOBJECT_MEM_SIZE_KB register" */
|
---|
6764 | | SVGA_CAP2_OTABLE_PTDEPTH_2
|
---|
6765 | | SVGA_CAP2_DX3 /* Shader Model 5.
|
---|
6766 | * DefineGBSurface_v4, etc
|
---|
6767 | */
|
---|
6768 | ;
|
---|
6769 | }
|
---|
6770 | # endif
|
---|
6771 | }
|
---|
6772 |
|
---|
6773 | # ifdef VBOX_WITH_VMSVGA3D
|
---|
6774 | if (pThisCC->svga.pSvgaR3State->pFuncs3D)
|
---|
6775 | *pu32DeviceCaps |= SVGA_CAP_3D;
|
---|
6776 | # endif
|
---|
6777 |
|
---|
6778 | /* FIFO capabilities. */
|
---|
6779 | if (!pThis->fVmSvga3)
|
---|
6780 | *pu32FIFOCaps = SVGA_FIFO_CAP_FENCE
|
---|
6781 | | SVGA_FIFO_CAP_PITCHLOCK
|
---|
6782 | | SVGA_FIFO_CAP_CURSOR_BYPASS_3
|
---|
6783 | | SVGA_FIFO_CAP_RESERVE
|
---|
6784 | | SVGA_FIFO_CAP_GMR2
|
---|
6785 | | SVGA_FIFO_CAP_3D_HWVERSION_REVISED
|
---|
6786 | | SVGA_FIFO_CAP_SCREEN_OBJECT_2;
|
---|
6787 | }
|
---|
6788 |
|
---|
6789 | /** Initialize the FIFO on power on and reset.
|
---|
6790 | *
|
---|
6791 | * @param pThis The shared VGA/VMSVGA instance data.
|
---|
6792 | * @param pThisCC The VGA/VMSVGA state for ring-3.
|
---|
6793 | */
|
---|
6794 | static void vmsvgaR3InitFIFO(PVGASTATE pThis, PVGASTATECC pThisCC)
|
---|
6795 | {
|
---|
6796 | RT_BZERO(pThisCC->svga.pau32FIFO, pThis->svga.cbFIFO);
|
---|
6797 |
|
---|
6798 | /* Valid with SVGA_FIFO_CAP_SCREEN_OBJECT_2 */
|
---|
6799 | pThisCC->svga.pau32FIFO[SVGA_FIFO_CURSOR_SCREEN_ID] = SVGA_ID_INVALID;
|
---|
6800 | }
|
---|
6801 |
|
---|
6802 | # ifdef VBOX_WITH_VMSVGA3D
|
---|
6803 | /**
|
---|
6804 | * Initializes the host 3D capabilities (pThis->svga.au32DevCaps).
|
---|
6805 | *
|
---|
6806 | * @returns VBox status code.
|
---|
6807 | * @param pThis The shared VGA/VMSVGA instance data.
|
---|
6808 | * @param pThisCC The VGA/VMSVGA state for ring-3.
|
---|
6809 | */
|
---|
6810 | static void vmsvgaR3Init3DCaps(PVGASTATE pThis, PVGASTATECC pThisCC)
|
---|
6811 | {
|
---|
6812 | /* Query the capabilities and store them in the pThis->svga.au32DevCaps array. */
|
---|
6813 | bool const fSavedBuffering = RTLogRelSetBuffering(true);
|
---|
6814 |
|
---|
6815 | for (unsigned i = 0; i < RT_ELEMENTS(pThis->svga.au32DevCaps); ++i)
|
---|
6816 | {
|
---|
6817 | uint32_t val = 0;
|
---|
6818 | int rc = vmsvga3dQueryCaps(pThisCC, (SVGA3dDevCapIndex)i, &val);
|
---|
6819 | if (RT_SUCCESS(rc))
|
---|
6820 | {
|
---|
6821 | if (!pThis->svga.fVBoxExtensions)
|
---|
6822 | {
|
---|
6823 | /* Hide extended VBoxSVGA capabilities. */
|
---|
6824 | if (i == SVGA3D_DEVCAP_3D)
|
---|
6825 | val &= VBSVGA3D_CAP_3D;
|
---|
6826 | }
|
---|
6827 | pThis->svga.au32DevCaps[i] = val;
|
---|
6828 | }
|
---|
6829 | else
|
---|
6830 | pThis->svga.au32DevCaps[i] = 0;
|
---|
6831 |
|
---|
6832 | /* LogRel the capability value. */
|
---|
6833 | if (i < SVGA3D_DEVCAP_MAX)
|
---|
6834 | {
|
---|
6835 | char const *pszDevCapName = &vmsvgaDevCapIndexToString((SVGA3dDevCapIndex)i)[sizeof("SVGA3D_DEVCAP")];
|
---|
6836 | if (RT_SUCCESS(rc))
|
---|
6837 | {
|
---|
6838 | if ( i == SVGA3D_DEVCAP_MAX_POINT_SIZE
|
---|
6839 | || i == SVGA3D_DEVCAP_MAX_LINE_WIDTH
|
---|
6840 | || i == SVGA3D_DEVCAP_MAX_AA_LINE_WIDTH)
|
---|
6841 | {
|
---|
6842 | float const fval = *(float *)&val;
|
---|
6843 | LogRel(("VMSVGA3d: cap[%u]=" FLOAT_FMT_STR " {%s}\n", i, FLOAT_FMT_ARGS(fval), pszDevCapName));
|
---|
6844 | }
|
---|
6845 | else
|
---|
6846 | LogRel(("VMSVGA3d: cap[%u]=%#010x {%s}\n", i, val, pszDevCapName));
|
---|
6847 | }
|
---|
6848 | else
|
---|
6849 | LogRel(("VMSVGA3d: cap[%u]=failed rc=%Rrc {%s}\n", i, rc, pszDevCapName));
|
---|
6850 | }
|
---|
6851 | else
|
---|
6852 | LogRel(("VMSVGA3d: new cap[%u]=%#010x rc=%Rrc\n", i, val, rc));
|
---|
6853 | }
|
---|
6854 |
|
---|
6855 | RTLogRelSetBuffering(fSavedBuffering);
|
---|
6856 | }
|
---|
6857 |
|
---|
6858 |
|
---|
6859 | /**
|
---|
6860 | * Write the host 3D capabilities to FIFO memory.
|
---|
6861 | * Must be called after vmsvgaR3Init3DCaps.
|
---|
6862 | *
|
---|
6863 | * @returns VBox status code.
|
---|
6864 | * @param pThis The shared VGA/VMSVGA instance data.
|
---|
6865 | * @param pThisCC The VGA/VMSVGA state for ring-3.
|
---|
6866 | */
|
---|
6867 | static void vmsvgaR3InitFIFO3D(PVGASTATE pThis, PVGASTATECC pThisCC)
|
---|
6868 | {
|
---|
6869 | /* 3d hardware version; latest and greatest */
|
---|
6870 | pThisCC->svga.pau32FIFO[SVGA_FIFO_3D_HWVERSION_REVISED] = SVGA3D_HWVERSION_CURRENT;
|
---|
6871 | pThisCC->svga.pau32FIFO[SVGA_FIFO_3D_HWVERSION] = SVGA3D_HWVERSION_CURRENT;
|
---|
6872 |
|
---|
6873 | /* Fill out 3d capabilities up to SVGA3D_DEVCAP_SURFACEFMT_ATI2 in the FIFO memory.
|
---|
6874 | * SVGA3D_DEVCAP_SURFACEFMT_ATI2 is the last capabiltiy for pre-SVGA_CAP_GBOBJECTS hardware.
|
---|
6875 | * If the VMSVGA device supports SVGA_CAP_GBOBJECTS capability, then the guest has to use SVGA_REG_DEV_CAP
|
---|
6876 | * register to query the devcaps. Older guests will still try to read the devcaps from FIFO.
|
---|
6877 | */
|
---|
6878 | SVGA3dCapsRecord *pCaps;
|
---|
6879 | SVGA3dCapPair *pData;
|
---|
6880 |
|
---|
6881 | pCaps = (SVGA3dCapsRecord *)&pThisCC->svga.pau32FIFO[SVGA_FIFO_3D_CAPS];
|
---|
6882 | pCaps->header.type = SVGA3DCAPS_RECORD_DEVCAPS;
|
---|
6883 | pData = (SVGA3dCapPair *)&pCaps->data;
|
---|
6884 |
|
---|
6885 | AssertCompile(SVGA3D_DEVCAP_DEAD1 == SVGA3D_DEVCAP_SURFACEFMT_ATI2 + 1);
|
---|
6886 | for (unsigned i = 0; i < SVGA3D_DEVCAP_DEAD1; ++i)
|
---|
6887 | {
|
---|
6888 | pData[i][0] = i;
|
---|
6889 | pData[i][1] = pThis->svga.au32DevCaps[i];
|
---|
6890 | }
|
---|
6891 | pCaps->header.length = (sizeof(pCaps->header) + SVGA3D_DEVCAP_DEAD1 * sizeof(SVGA3dCapPair)) / sizeof(uint32_t);
|
---|
6892 | pCaps = (SVGA3dCapsRecord *)((uint32_t *)pCaps + pCaps->header.length);
|
---|
6893 |
|
---|
6894 | /* Mark end of record array (a zero word). */
|
---|
6895 | pCaps->header.length = 0;
|
---|
6896 | }
|
---|
6897 | # endif /* VBOX_WITH_VMSVGA3D */
|
---|
6898 |
|
---|
6899 | /**
|
---|
6900 | * Resets the SVGA hardware state
|
---|
6901 | *
|
---|
6902 | * @returns VBox status code.
|
---|
6903 | * @param pDevIns The device instance.
|
---|
6904 | */
|
---|
6905 | int vmsvgaR3Reset(PPDMDEVINS pDevIns)
|
---|
6906 | {
|
---|
6907 | PVGASTATE pThis = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
|
---|
6908 | PVGASTATECC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC);
|
---|
6909 | PVMSVGAR3STATE pSVGAState = pThisCC->svga.pSvgaR3State;
|
---|
6910 |
|
---|
6911 | /* Reset before init? */
|
---|
6912 | if (!pSVGAState)
|
---|
6913 | return VINF_SUCCESS;
|
---|
6914 |
|
---|
6915 | Log(("vmsvgaR3Reset\n"));
|
---|
6916 |
|
---|
6917 | if (!pThis->fVmSvga3)
|
---|
6918 | {
|
---|
6919 | /* Reset the FIFO processing as well as the 3d state (if we have one). */
|
---|
6920 | pThisCC->svga.pau32FIFO[SVGA_FIFO_NEXT_CMD] = pThisCC->svga.pau32FIFO[SVGA_FIFO_STOP] = 0; /** @todo should probably let the FIFO thread do this ... */
|
---|
6921 | }
|
---|
6922 |
|
---|
6923 | PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect); /* Hack around lock order issue. FIFO thread might take the lock. */
|
---|
6924 |
|
---|
6925 | int rc = vmsvgaR3RunExtCmdOnFifoThread(pDevIns, pThis, pThisCC, VMSVGA_FIFO_EXTCMD_RESET, NULL /*pvParam*/, 60000 /*ms*/);
|
---|
6926 | AssertLogRelRC(rc);
|
---|
6927 |
|
---|
6928 | int const rcLock = PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED);
|
---|
6929 | PDM_CRITSECT_RELEASE_ASSERT_RC_DEV(pDevIns, &pThis->CritSect, rcLock);
|
---|
6930 |
|
---|
6931 | /* Reset other stuff. */
|
---|
6932 | pThis->svga.cScratchRegion = VMSVGA_SCRATCH_SIZE;
|
---|
6933 | RT_ZERO(pThis->svga.au32ScratchRegion);
|
---|
6934 |
|
---|
6935 | ASMAtomicWriteBool(&pThis->svga.fBadGuest, false);
|
---|
6936 |
|
---|
6937 | vmsvgaR3StateTerm(pThis, pThisCC);
|
---|
6938 | vmsvgaR3StateInit(pDevIns, pThis, pThisCC->svga.pSvgaR3State);
|
---|
6939 |
|
---|
6940 | RT_BZERO(pThisCC->svga.pbVgaFrameBufferR3, VMSVGA_VGA_FB_BACKUP_SIZE);
|
---|
6941 |
|
---|
6942 | if (!pThis->fVmSvga3)
|
---|
6943 | vmsvgaR3InitFIFO(pThis, pThisCC);
|
---|
6944 |
|
---|
6945 | /* Initialize FIFO and register capabilities. */
|
---|
6946 | vmsvgaR3GetCaps(pThis, pThisCC, &pThis->svga.u32DeviceCaps, &pThis->svga.u32DeviceCaps2, &pThisCC->svga.pau32FIFO[SVGA_FIFO_CAPABILITIES]);
|
---|
6947 |
|
---|
6948 | # ifdef VBOX_WITH_VMSVGA3D
|
---|
6949 | if (pThis->svga.f3DEnabled)
|
---|
6950 | {
|
---|
6951 | vmsvgaR3Init3DCaps(pThis, pThisCC);
|
---|
6952 | if (!pThis->fVmSvga3)
|
---|
6953 | vmsvgaR3InitFIFO3D(pThis, pThisCC);
|
---|
6954 | }
|
---|
6955 | # endif
|
---|
6956 |
|
---|
6957 | /* VRAM tracking is enabled by default during bootup. */
|
---|
6958 | pThis->svga.fVRAMTracking = true;
|
---|
6959 | pThis->svga.fEnabled = false;
|
---|
6960 |
|
---|
6961 | /* Invalidate current settings. */
|
---|
6962 | pThis->svga.uWidth = VMSVGA_VAL_UNINITIALIZED;
|
---|
6963 | pThis->svga.uHeight = VMSVGA_VAL_UNINITIALIZED;
|
---|
6964 | pThis->svga.uBpp = pThis->svga.uHostBpp;
|
---|
6965 | pThis->svga.cbScanline = 0;
|
---|
6966 | pThis->svga.u32PitchLock = 0;
|
---|
6967 |
|
---|
6968 | return rc;
|
---|
6969 | }
|
---|
6970 |
|
---|
6971 | /**
|
---|
6972 | * Cleans up the SVGA hardware state
|
---|
6973 | *
|
---|
6974 | * @returns VBox status code.
|
---|
6975 | * @param pDevIns The device instance.
|
---|
6976 | */
|
---|
6977 | int vmsvgaR3Destruct(PPDMDEVINS pDevIns)
|
---|
6978 | {
|
---|
6979 | PVGASTATE pThis = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
|
---|
6980 | PVGASTATECC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC);
|
---|
6981 |
|
---|
6982 | /*
|
---|
6983 | * Ask the FIFO thread to terminate the 3d state and then terminate it.
|
---|
6984 | */
|
---|
6985 | if (pThisCC->svga.pFIFOIOThread)
|
---|
6986 | {
|
---|
6987 | int rc = vmsvgaR3RunExtCmdOnFifoThread(pDevIns, pThis, pThisCC, VMSVGA_FIFO_EXTCMD_TERMINATE,
|
---|
6988 | NULL /*pvParam*/, 30000 /*ms*/);
|
---|
6989 | AssertLogRelRC(rc);
|
---|
6990 |
|
---|
6991 | rc = PDMDevHlpThreadDestroy(pDevIns, pThisCC->svga.pFIFOIOThread, NULL);
|
---|
6992 | AssertLogRelRC(rc);
|
---|
6993 | pThisCC->svga.pFIFOIOThread = NULL;
|
---|
6994 | }
|
---|
6995 |
|
---|
6996 | /*
|
---|
6997 | * Destroy the special SVGA state.
|
---|
6998 | */
|
---|
6999 | if (pThisCC->svga.pSvgaR3State)
|
---|
7000 | {
|
---|
7001 | vmsvgaR3StateTerm(pThis, pThisCC);
|
---|
7002 |
|
---|
7003 | # ifdef VBOX_WITH_VMSVGA3D
|
---|
7004 | vmsvga3dR3Free3dInterfaces(pThisCC);
|
---|
7005 | # endif
|
---|
7006 |
|
---|
7007 | RTMemFree(pThisCC->svga.pSvgaR3State);
|
---|
7008 | pThisCC->svga.pSvgaR3State = NULL;
|
---|
7009 | }
|
---|
7010 |
|
---|
7011 | /*
|
---|
7012 | * Free our resources residing in the VGA state.
|
---|
7013 | */
|
---|
7014 | if (pThisCC->svga.pbVgaFrameBufferR3)
|
---|
7015 | {
|
---|
7016 | RTMemFree(pThisCC->svga.pbVgaFrameBufferR3);
|
---|
7017 | pThisCC->svga.pbVgaFrameBufferR3 = NULL;
|
---|
7018 | }
|
---|
7019 | if (pThisCC->svga.hFIFOExtCmdSem != NIL_RTSEMEVENT)
|
---|
7020 | {
|
---|
7021 | RTSemEventDestroy(pThisCC->svga.hFIFOExtCmdSem);
|
---|
7022 | pThisCC->svga.hFIFOExtCmdSem = NIL_RTSEMEVENT;
|
---|
7023 | }
|
---|
7024 | if (pThis->svga.hFIFORequestSem != NIL_SUPSEMEVENT)
|
---|
7025 | {
|
---|
7026 | PDMDevHlpSUPSemEventClose(pDevIns, pThis->svga.hFIFORequestSem);
|
---|
7027 | pThis->svga.hFIFORequestSem = NIL_SUPSEMEVENT;
|
---|
7028 | }
|
---|
7029 |
|
---|
7030 | return VINF_SUCCESS;
|
---|
7031 | }
|
---|
7032 |
|
---|
7033 | static DECLCALLBACK(size_t) vmsvga3dFloatFormat(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput,
|
---|
7034 | const char *pszType, void const *pvValue,
|
---|
7035 | int cchWidth, int cchPrecision, unsigned fFlags, void *pvUser)
|
---|
7036 | {
|
---|
7037 | RT_NOREF(pszType, cchWidth, cchPrecision, fFlags, pvUser);
|
---|
7038 | double const v = *(double *)&pvValue;
|
---|
7039 | return RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, FLOAT_FMT_STR, FLOAT_FMT_ARGS(v));
|
---|
7040 | }
|
---|
7041 |
|
---|
7042 | /**
|
---|
7043 | * Initialize the SVGA hardware state
|
---|
7044 | *
|
---|
7045 | * @returns VBox status code.
|
---|
7046 | * @param pDevIns The device instance.
|
---|
7047 | */
|
---|
7048 | int vmsvgaR3Init(PPDMDEVINS pDevIns)
|
---|
7049 | {
|
---|
7050 | PVGASTATE pThis = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
|
---|
7051 | PVGASTATECC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC);
|
---|
7052 | PVMSVGAR3STATE pSVGAState;
|
---|
7053 | int rc;
|
---|
7054 |
|
---|
7055 | rc = RTStrFormatTypeRegister("float", vmsvga3dFloatFormat, NULL);
|
---|
7056 | AssertMsgReturn(RT_SUCCESS(rc) || rc == VERR_ALREADY_EXISTS, ("%Rrc\n", rc), rc);
|
---|
7057 |
|
---|
7058 | pThis->svga.cScratchRegion = VMSVGA_SCRATCH_SIZE;
|
---|
7059 | memset(pThis->svga.au32ScratchRegion, 0, sizeof(pThis->svga.au32ScratchRegion));
|
---|
7060 |
|
---|
7061 | pThis->svga.cGMR = VMSVGA_MAX_GMR_IDS;
|
---|
7062 |
|
---|
7063 | /* Necessary for creating a backup of the text mode frame buffer when switching into svga mode. */
|
---|
7064 | pThisCC->svga.pbVgaFrameBufferR3 = (uint8_t *)RTMemAllocZ(VMSVGA_VGA_FB_BACKUP_SIZE);
|
---|
7065 | AssertReturn(pThisCC->svga.pbVgaFrameBufferR3, VERR_NO_MEMORY);
|
---|
7066 |
|
---|
7067 | /* Create event semaphore. */
|
---|
7068 | rc = PDMDevHlpSUPSemEventCreate(pDevIns, &pThis->svga.hFIFORequestSem);
|
---|
7069 | AssertRCReturn(rc, rc);
|
---|
7070 |
|
---|
7071 | /* Create event semaphore. */
|
---|
7072 | rc = RTSemEventCreate(&pThisCC->svga.hFIFOExtCmdSem);
|
---|
7073 | AssertRCReturn(rc, rc);
|
---|
7074 |
|
---|
7075 | pThisCC->svga.pSvgaR3State = (PVMSVGAR3STATE)RTMemAllocZ(sizeof(VMSVGAR3STATE));
|
---|
7076 | AssertReturn(pThisCC->svga.pSvgaR3State, VERR_NO_MEMORY);
|
---|
7077 |
|
---|
7078 | rc = vmsvgaR3StateInit(pDevIns, pThis, pThisCC->svga.pSvgaR3State);
|
---|
7079 | AssertMsgRCReturn(rc, ("Failed to create pSvgaR3State.\n"), rc);
|
---|
7080 |
|
---|
7081 | pSVGAState = pThisCC->svga.pSvgaR3State;
|
---|
7082 |
|
---|
7083 | /* VRAM tracking is enabled by default during bootup. */
|
---|
7084 | pThis->svga.fVRAMTracking = true;
|
---|
7085 |
|
---|
7086 | /* Set up the host bpp. This value is as a default for the programmable
|
---|
7087 | * bpp value. On old implementations, SVGA_REG_HOST_BITS_PER_PIXEL did not
|
---|
7088 | * exist and SVGA_REG_BITS_PER_PIXEL was read-only, returning what was later
|
---|
7089 | * separated as SVGA_REG_HOST_BITS_PER_PIXEL.
|
---|
7090 | *
|
---|
7091 | * NB: The driver cBits value is currently constant for the lifetime of the
|
---|
7092 | * VM. If that changes, the host bpp logic might need revisiting.
|
---|
7093 | */
|
---|
7094 | pThis->svga.uHostBpp = (pThisCC->pDrv->cBits + 7) & ~7;
|
---|
7095 |
|
---|
7096 | /* Invalidate current settings. */
|
---|
7097 | pThis->svga.uWidth = VMSVGA_VAL_UNINITIALIZED;
|
---|
7098 | pThis->svga.uHeight = VMSVGA_VAL_UNINITIALIZED;
|
---|
7099 | pThis->svga.uBpp = pThis->svga.uHostBpp;
|
---|
7100 | pThis->svga.cbScanline = 0;
|
---|
7101 |
|
---|
7102 | pThis->svga.u32MaxWidth = VBE_DISPI_MAX_XRES;
|
---|
7103 | pThis->svga.u32MaxHeight = VBE_DISPI_MAX_YRES;
|
---|
7104 | while (pThis->svga.u32MaxWidth * pThis->svga.u32MaxHeight * 4 /* 32 bpp */ > pThis->vram_size)
|
---|
7105 | {
|
---|
7106 | pThis->svga.u32MaxWidth -= 256;
|
---|
7107 | pThis->svga.u32MaxHeight -= 256;
|
---|
7108 | }
|
---|
7109 | Log(("VMSVGA: Maximum size (%d,%d)\n", pThis->svga.u32MaxWidth, pThis->svga.u32MaxHeight));
|
---|
7110 |
|
---|
7111 | /* VBox commands and capabilities are always enabled for VirtualBox PCI device. */
|
---|
7112 | pThis->svga.fVBoxExtensions = !pThis->fVMSVGAPciId;
|
---|
7113 |
|
---|
7114 | # ifdef DEBUG_GMR_ACCESS
|
---|
7115 | /* Register the GMR access handler type. */
|
---|
7116 | rc = PDMDevHlpPGMHandlerPhysicalTypeRegister(pDevIns, PGMPHYSHANDLERKIND_WRITE, vmsvgaR3GmrAccessHandler,
|
---|
7117 | "VMSVGA GMR", &pThis->svga.hGmrAccessHandlerType);
|
---|
7118 | AssertRCReturn(rc, rc);
|
---|
7119 | # endif
|
---|
7120 |
|
---|
7121 | # if defined(VMSVGA_USE_FIFO_ACCESS_HANDLER) || defined(DEBUG_FIFO_ACCESS)
|
---|
7122 | /* Register the FIFO access handler type. In addition to debugging FIFO
|
---|
7123 | access, this is also used to facilitate extended fifo thread sleeps. */
|
---|
7124 | rc = PDMDevHlpPGMHandlerPhysicalTypeRegister(pDevIns,
|
---|
7125 | # ifdef DEBUG_FIFO_ACCESS
|
---|
7126 | PGMPHYSHANDLERKIND_ALL,
|
---|
7127 | # else
|
---|
7128 | PGMPHYSHANDLERKIND_WRITE,
|
---|
7129 | # endif
|
---|
7130 | vmsvgaR3FifoAccessHandler,
|
---|
7131 | "VMSVGA FIFO", &pThis->svga.hFifoAccessHandlerType);
|
---|
7132 | AssertRCReturn(rc, rc);
|
---|
7133 | # endif
|
---|
7134 |
|
---|
7135 | /* Create the async IO thread. */
|
---|
7136 | if (pThis->fVmSvga3)
|
---|
7137 | {
|
---|
7138 | /*
|
---|
7139 | * For SVGA 3 we use a different command processing loop because the standard FIFO loop would get riddled with
|
---|
7140 | * if (pThis->fVmsvga3) otherwise
|
---|
7141 | */
|
---|
7142 | rc = PDMDevHlpThreadCreate(pDevIns, &pThisCC->svga.pFIFOIOThread, pThis, vmsvgaR3CmdBufLoop, vmsvgaR3FifoLoopWakeUp, 0,
|
---|
7143 | RTTHREADTYPE_IO, "VMSVGA CMD");
|
---|
7144 | }
|
---|
7145 | else
|
---|
7146 | rc = PDMDevHlpThreadCreate(pDevIns, &pThisCC->svga.pFIFOIOThread, pThis, vmsvgaR3FifoLoop, vmsvgaR3FifoLoopWakeUp, 0,
|
---|
7147 | RTTHREADTYPE_IO, "VMSVGA FIFO");
|
---|
7148 | if (RT_FAILURE(rc))
|
---|
7149 | {
|
---|
7150 | AssertMsgFailed(("%s: Async IO Thread creation for FIFO handling failed rc=%d\n", __FUNCTION__, rc));
|
---|
7151 | return rc;
|
---|
7152 | }
|
---|
7153 |
|
---|
7154 | /*
|
---|
7155 | * Statistics.
|
---|
7156 | */
|
---|
7157 | # define REG_CNT(a_pvSample, a_pszName, a_pszDesc) \
|
---|
7158 | PDMDevHlpSTAMRegister(pDevIns, (a_pvSample), STAMTYPE_COUNTER, a_pszName, STAMUNIT_OCCURENCES, a_pszDesc)
|
---|
7159 | # define REG_PRF(a_pvSample, a_pszName, a_pszDesc) \
|
---|
7160 | PDMDevHlpSTAMRegister(pDevIns, (a_pvSample), STAMTYPE_PROFILE, a_pszName, STAMUNIT_TICKS_PER_CALL, a_pszDesc)
|
---|
7161 | # ifdef VBOX_WITH_STATISTICS
|
---|
7162 | REG_PRF(&pSVGAState->StatR3Cmd3dDrawPrimitivesProf, "VMSVGA/Cmd/3dDrawPrimitivesProf", "Profiling of SVGA_3D_CMD_DRAW_PRIMITIVES.");
|
---|
7163 | REG_PRF(&pSVGAState->StatR3Cmd3dPresentProf, "VMSVGA/Cmd/3dPresentProfBoth", "Profiling of SVGA_3D_CMD_PRESENT and SVGA_3D_CMD_PRESENT_READBACK.");
|
---|
7164 | REG_PRF(&pSVGAState->StatR3Cmd3dSurfaceDmaProf, "VMSVGA/Cmd/3dSurfaceDmaProf", "Profiling of SVGA_3D_CMD_SURFACE_DMA.");
|
---|
7165 | # endif
|
---|
7166 | REG_PRF(&pSVGAState->StatR3Cmd3dBlitSurfaceToScreenProf, "VMSVGA/Cmd/3dBlitSurfaceToScreenProf", "Profiling of SVGA_3D_CMD_BLIT_SURFACE_TO_SCREEN.");
|
---|
7167 | REG_CNT(&pSVGAState->StatR3Cmd3dActivateSurface, "VMSVGA/Cmd/3dActivateSurface", "SVGA_3D_CMD_ACTIVATE_SURFACE");
|
---|
7168 | REG_CNT(&pSVGAState->StatR3Cmd3dBeginQuery, "VMSVGA/Cmd/3dBeginQuery", "SVGA_3D_CMD_BEGIN_QUERY");
|
---|
7169 | REG_CNT(&pSVGAState->StatR3Cmd3dClear, "VMSVGA/Cmd/3dClear", "SVGA_3D_CMD_CLEAR");
|
---|
7170 | REG_CNT(&pSVGAState->StatR3Cmd3dContextDefine, "VMSVGA/Cmd/3dContextDefine", "SVGA_3D_CMD_CONTEXT_DEFINE");
|
---|
7171 | REG_CNT(&pSVGAState->StatR3Cmd3dContextDestroy, "VMSVGA/Cmd/3dContextDestroy", "SVGA_3D_CMD_CONTEXT_DESTROY");
|
---|
7172 | REG_CNT(&pSVGAState->StatR3Cmd3dDeactivateSurface, "VMSVGA/Cmd/3dDeactivateSurface", "SVGA_3D_CMD_DEACTIVATE_SURFACE");
|
---|
7173 | REG_CNT(&pSVGAState->StatR3Cmd3dDrawPrimitives, "VMSVGA/Cmd/3dDrawPrimitives", "SVGA_3D_CMD_DRAW_PRIMITIVES");
|
---|
7174 | REG_CNT(&pSVGAState->StatR3Cmd3dEndQuery, "VMSVGA/Cmd/3dEndQuery", "SVGA_3D_CMD_END_QUERY");
|
---|
7175 | REG_CNT(&pSVGAState->StatR3Cmd3dGenerateMipmaps, "VMSVGA/Cmd/3dGenerateMipmaps", "SVGA_3D_CMD_GENERATE_MIPMAPS");
|
---|
7176 | REG_CNT(&pSVGAState->StatR3Cmd3dPresent, "VMSVGA/Cmd/3dPresent", "SVGA_3D_CMD_PRESENT");
|
---|
7177 | REG_CNT(&pSVGAState->StatR3Cmd3dPresentReadBack, "VMSVGA/Cmd/3dPresentReadBack", "SVGA_3D_CMD_PRESENT_READBACK");
|
---|
7178 | REG_CNT(&pSVGAState->StatR3Cmd3dSetClipPlane, "VMSVGA/Cmd/3dSetClipPlane", "SVGA_3D_CMD_SETCLIPPLANE");
|
---|
7179 | REG_CNT(&pSVGAState->StatR3Cmd3dSetLightData, "VMSVGA/Cmd/3dSetLightData", "SVGA_3D_CMD_SETLIGHTDATA");
|
---|
7180 | REG_CNT(&pSVGAState->StatR3Cmd3dSetLightEnable, "VMSVGA/Cmd/3dSetLightEnable", "SVGA_3D_CMD_SETLIGHTENABLE");
|
---|
7181 | REG_CNT(&pSVGAState->StatR3Cmd3dSetMaterial, "VMSVGA/Cmd/3dSetMaterial", "SVGA_3D_CMD_SETMATERIAL");
|
---|
7182 | REG_CNT(&pSVGAState->StatR3Cmd3dSetRenderState, "VMSVGA/Cmd/3dSetRenderState", "SVGA_3D_CMD_SETRENDERSTATE");
|
---|
7183 | REG_CNT(&pSVGAState->StatR3Cmd3dSetRenderTarget, "VMSVGA/Cmd/3dSetRenderTarget", "SVGA_3D_CMD_SETRENDERTARGET");
|
---|
7184 | REG_CNT(&pSVGAState->StatR3Cmd3dSetScissorRect, "VMSVGA/Cmd/3dSetScissorRect", "SVGA_3D_CMD_SETSCISSORRECT");
|
---|
7185 | REG_CNT(&pSVGAState->StatR3Cmd3dSetShader, "VMSVGA/Cmd/3dSetShader", "SVGA_3D_CMD_SET_SHADER");
|
---|
7186 | REG_CNT(&pSVGAState->StatR3Cmd3dSetShaderConst, "VMSVGA/Cmd/3dSetShaderConst", "SVGA_3D_CMD_SET_SHADER_CONST");
|
---|
7187 | REG_CNT(&pSVGAState->StatR3Cmd3dSetTextureState, "VMSVGA/Cmd/3dSetTextureState", "SVGA_3D_CMD_SETTEXTURESTATE");
|
---|
7188 | REG_CNT(&pSVGAState->StatR3Cmd3dSetTransform, "VMSVGA/Cmd/3dSetTransform", "SVGA_3D_CMD_SETTRANSFORM");
|
---|
7189 | REG_CNT(&pSVGAState->StatR3Cmd3dSetViewPort, "VMSVGA/Cmd/3dSetViewPort", "SVGA_3D_CMD_SETVIEWPORT");
|
---|
7190 | REG_CNT(&pSVGAState->StatR3Cmd3dSetZRange, "VMSVGA/Cmd/3dSetZRange", "SVGA_3D_CMD_SETZRANGE");
|
---|
7191 | REG_CNT(&pSVGAState->StatR3Cmd3dShaderDefine, "VMSVGA/Cmd/3dShaderDefine", "SVGA_3D_CMD_SHADER_DEFINE");
|
---|
7192 | REG_CNT(&pSVGAState->StatR3Cmd3dShaderDestroy, "VMSVGA/Cmd/3dShaderDestroy", "SVGA_3D_CMD_SHADER_DESTROY");
|
---|
7193 | REG_CNT(&pSVGAState->StatR3Cmd3dSurfaceCopy, "VMSVGA/Cmd/3dSurfaceCopy", "SVGA_3D_CMD_SURFACE_COPY");
|
---|
7194 | REG_CNT(&pSVGAState->StatR3Cmd3dSurfaceDefine, "VMSVGA/Cmd/3dSurfaceDefine", "SVGA_3D_CMD_SURFACE_DEFINE");
|
---|
7195 | REG_CNT(&pSVGAState->StatR3Cmd3dSurfaceDefineV2, "VMSVGA/Cmd/3dSurfaceDefineV2", "SVGA_3D_CMD_SURFACE_DEFINE_V2");
|
---|
7196 | REG_CNT(&pSVGAState->StatR3Cmd3dSurfaceDestroy, "VMSVGA/Cmd/3dSurfaceDestroy", "SVGA_3D_CMD_SURFACE_DESTROY");
|
---|
7197 | REG_CNT(&pSVGAState->StatR3Cmd3dSurfaceDma, "VMSVGA/Cmd/3dSurfaceDma", "SVGA_3D_CMD_SURFACE_DMA");
|
---|
7198 | REG_CNT(&pSVGAState->StatR3Cmd3dSurfaceScreen, "VMSVGA/Cmd/3dSurfaceScreen", "SVGA_3D_CMD_SURFACE_SCREEN");
|
---|
7199 | REG_CNT(&pSVGAState->StatR3Cmd3dSurfaceStretchBlt, "VMSVGA/Cmd/3dSurfaceStretchBlt", "SVGA_3D_CMD_SURFACE_STRETCHBLT");
|
---|
7200 | REG_CNT(&pSVGAState->StatR3Cmd3dWaitForQuery, "VMSVGA/Cmd/3dWaitForQuery", "SVGA_3D_CMD_WAIT_FOR_QUERY");
|
---|
7201 | REG_CNT(&pSVGAState->StatR3CmdAnnotationCopy, "VMSVGA/Cmd/AnnotationCopy", "SVGA_CMD_ANNOTATION_COPY");
|
---|
7202 | REG_CNT(&pSVGAState->StatR3CmdAnnotationFill, "VMSVGA/Cmd/AnnotationFill", "SVGA_CMD_ANNOTATION_FILL");
|
---|
7203 | REG_CNT(&pSVGAState->StatR3CmdBlitGmrFbToScreen, "VMSVGA/Cmd/BlitGmrFbToScreen", "SVGA_CMD_BLIT_GMRFB_TO_SCREEN");
|
---|
7204 | REG_CNT(&pSVGAState->StatR3CmdBlitScreentoGmrFb, "VMSVGA/Cmd/BlitScreentoGmrFb", "SVGA_CMD_BLIT_SCREEN_TO_GMRFB");
|
---|
7205 | REG_CNT(&pSVGAState->StatR3CmdDefineAlphaCursor, "VMSVGA/Cmd/DefineAlphaCursor", "SVGA_CMD_DEFINE_ALPHA_CURSOR");
|
---|
7206 | REG_CNT(&pSVGAState->StatR3CmdDefineCursor, "VMSVGA/Cmd/DefineCursor", "SVGA_CMD_DEFINE_CURSOR");
|
---|
7207 | REG_CNT(&pSVGAState->StatR3CmdMoveCursor, "VMSVGA/Cmd/MoveCursor", "SVGA_CMD_MOVE_CURSOR");
|
---|
7208 | REG_CNT(&pSVGAState->StatR3CmdDisplayCursor, "VMSVGA/Cmd/DisplayCursor", "SVGA_CMD_DISPLAY_CURSOR");
|
---|
7209 | REG_CNT(&pSVGAState->StatR3CmdRectFill, "VMSVGA/Cmd/RectFill", "SVGA_CMD_RECT_FILL");
|
---|
7210 | REG_CNT(&pSVGAState->StatR3CmdRectCopy, "VMSVGA/Cmd/RectCopy", "SVGA_CMD_RECT_COPY");
|
---|
7211 | REG_CNT(&pSVGAState->StatR3CmdRectRopCopy, "VMSVGA/Cmd/RectRopCopy", "SVGA_CMD_RECT_ROP_COPY");
|
---|
7212 | REG_CNT(&pSVGAState->StatR3CmdDefineGmr2, "VMSVGA/Cmd/DefineGmr2", "SVGA_CMD_DEFINE_GMR2");
|
---|
7213 | REG_CNT(&pSVGAState->StatR3CmdDefineGmr2Free, "VMSVGA/Cmd/DefineGmr2/Free", "Number of SVGA_CMD_DEFINE_GMR2 commands that only frees.");
|
---|
7214 | REG_CNT(&pSVGAState->StatR3CmdDefineGmr2Modify, "VMSVGA/Cmd/DefineGmr2/Modify", "Number of SVGA_CMD_DEFINE_GMR2 commands that redefines a non-free GMR.");
|
---|
7215 | REG_CNT(&pSVGAState->StatR3CmdDefineGmrFb, "VMSVGA/Cmd/DefineGmrFb", "SVGA_CMD_DEFINE_GMRFB");
|
---|
7216 | REG_CNT(&pSVGAState->StatR3CmdDefineScreen, "VMSVGA/Cmd/DefineScreen", "SVGA_CMD_DEFINE_SCREEN");
|
---|
7217 | REG_CNT(&pSVGAState->StatR3CmdDestroyScreen, "VMSVGA/Cmd/DestroyScreen", "SVGA_CMD_DESTROY_SCREEN");
|
---|
7218 | REG_CNT(&pSVGAState->StatR3CmdEscape, "VMSVGA/Cmd/Escape", "SVGA_CMD_ESCAPE");
|
---|
7219 | REG_CNT(&pSVGAState->StatR3CmdFence, "VMSVGA/Cmd/Fence", "SVGA_CMD_FENCE");
|
---|
7220 | REG_CNT(&pSVGAState->StatR3CmdInvalidCmd, "VMSVGA/Cmd/InvalidCmd", "SVGA_CMD_INVALID_CMD");
|
---|
7221 | REG_CNT(&pSVGAState->StatR3CmdRemapGmr2, "VMSVGA/Cmd/RemapGmr2", "SVGA_CMD_REMAP_GMR2");
|
---|
7222 | REG_CNT(&pSVGAState->StatR3CmdRemapGmr2Modify, "VMSVGA/Cmd/RemapGmr2/Modify", "Number of SVGA_CMD_REMAP_GMR2 commands that modifies rather than complete the definition of a GMR.");
|
---|
7223 | REG_CNT(&pSVGAState->StatR3CmdUpdate, "VMSVGA/Cmd/Update", "SVGA_CMD_UPDATE");
|
---|
7224 | REG_CNT(&pSVGAState->StatR3CmdUpdateVerbose, "VMSVGA/Cmd/UpdateVerbose", "SVGA_CMD_UPDATE_VERBOSE");
|
---|
7225 |
|
---|
7226 | REG_CNT(&pSVGAState->StatR3RegConfigDoneWr, "VMSVGA/Reg/ConfigDoneWrite", "SVGA_REG_CONFIG_DONE writes");
|
---|
7227 | REG_CNT(&pSVGAState->StatR3RegGmrDescriptorWr, "VMSVGA/Reg/GmrDescriptorWrite", "SVGA_REG_GMR_DESCRIPTOR writes");
|
---|
7228 | REG_CNT(&pSVGAState->StatR3RegGmrDescriptorWrErrors, "VMSVGA/Reg/GmrDescriptorWrite/Errors", "Number of erroneous SVGA_REG_GMR_DESCRIPTOR commands.");
|
---|
7229 | REG_CNT(&pSVGAState->StatR3RegGmrDescriptorWrFree, "VMSVGA/Reg/GmrDescriptorWrite/Free", "Number of SVGA_REG_GMR_DESCRIPTOR commands only freeing the GMR.");
|
---|
7230 | REG_CNT(&pThis->svga.StatRegBitsPerPixelWr, "VMSVGA/Reg/BitsPerPixelWrite", "SVGA_REG_BITS_PER_PIXEL writes.");
|
---|
7231 | REG_CNT(&pThis->svga.StatRegBusyWr, "VMSVGA/Reg/BusyWrite", "SVGA_REG_BUSY writes.");
|
---|
7232 | REG_CNT(&pThis->svga.StatRegCursorXWr, "VMSVGA/Reg/CursorXWrite", "SVGA_REG_CURSOR_X writes.");
|
---|
7233 | REG_CNT(&pThis->svga.StatRegCursorYWr, "VMSVGA/Reg/CursorYWrite", "SVGA_REG_CURSOR_Y writes.");
|
---|
7234 | REG_CNT(&pThis->svga.StatRegCursorIdWr, "VMSVGA/Reg/CursorIdWrite", "SVGA_REG_DEAD (SVGA_REG_CURSOR_ID) writes.");
|
---|
7235 | REG_CNT(&pThis->svga.StatRegCursorOnWr, "VMSVGA/Reg/CursorOnWrite", "SVGA_REG_CURSOR_ON writes.");
|
---|
7236 | REG_CNT(&pThis->svga.StatRegDepthWr, "VMSVGA/Reg/DepthWrite", "SVGA_REG_DEPTH writes.");
|
---|
7237 | REG_CNT(&pThis->svga.StatRegDisplayHeightWr, "VMSVGA/Reg/DisplayHeightWrite", "SVGA_REG_DISPLAY_HEIGHT writes.");
|
---|
7238 | REG_CNT(&pThis->svga.StatRegDisplayIdWr, "VMSVGA/Reg/DisplayIdWrite", "SVGA_REG_DISPLAY_ID writes.");
|
---|
7239 | REG_CNT(&pThis->svga.StatRegDisplayIsPrimaryWr, "VMSVGA/Reg/DisplayIsPrimaryWrite", "SVGA_REG_DISPLAY_IS_PRIMARY writes.");
|
---|
7240 | REG_CNT(&pThis->svga.StatRegDisplayPositionXWr, "VMSVGA/Reg/DisplayPositionXWrite", "SVGA_REG_DISPLAY_POSITION_X writes.");
|
---|
7241 | REG_CNT(&pThis->svga.StatRegDisplayPositionYWr, "VMSVGA/Reg/DisplayPositionYWrite", "SVGA_REG_DISPLAY_POSITION_Y writes.");
|
---|
7242 | REG_CNT(&pThis->svga.StatRegDisplayWidthWr, "VMSVGA/Reg/DisplayWidthWrite", "SVGA_REG_DISPLAY_WIDTH writes.");
|
---|
7243 | REG_CNT(&pThis->svga.StatRegEnableWr, "VMSVGA/Reg/EnableWrite", "SVGA_REG_ENABLE writes.");
|
---|
7244 | REG_CNT(&pThis->svga.StatRegGmrIdWr, "VMSVGA/Reg/GmrIdWrite", "SVGA_REG_GMR_ID writes.");
|
---|
7245 | REG_CNT(&pThis->svga.StatRegGuestIdWr, "VMSVGA/Reg/GuestIdWrite", "SVGA_REG_GUEST_ID writes.");
|
---|
7246 | REG_CNT(&pThis->svga.StatRegHeightWr, "VMSVGA/Reg/HeightWrite", "SVGA_REG_HEIGHT writes.");
|
---|
7247 | REG_CNT(&pThis->svga.StatRegIdWr, "VMSVGA/Reg/IdWrite", "SVGA_REG_ID writes.");
|
---|
7248 | REG_CNT(&pThis->svga.StatRegIrqMaskWr, "VMSVGA/Reg/IrqMaskWrite", "SVGA_REG_IRQMASK writes.");
|
---|
7249 | REG_CNT(&pThis->svga.StatRegNumDisplaysWr, "VMSVGA/Reg/NumDisplaysWrite", "SVGA_REG_NUM_DISPLAYS writes.");
|
---|
7250 | REG_CNT(&pThis->svga.StatRegNumGuestDisplaysWr, "VMSVGA/Reg/NumGuestDisplaysWrite", "SVGA_REG_NUM_GUEST_DISPLAYS writes.");
|
---|
7251 | REG_CNT(&pThis->svga.StatRegPaletteWr, "VMSVGA/Reg/PaletteWrite", "SVGA_PALETTE_XXXX writes.");
|
---|
7252 | REG_CNT(&pThis->svga.StatRegPitchLockWr, "VMSVGA/Reg/PitchLockWrite", "SVGA_REG_PITCHLOCK writes.");
|
---|
7253 | REG_CNT(&pThis->svga.StatRegPseudoColorWr, "VMSVGA/Reg/PseudoColorWrite", "SVGA_REG_PSEUDOCOLOR writes.");
|
---|
7254 | REG_CNT(&pThis->svga.StatRegReadOnlyWr, "VMSVGA/Reg/ReadOnlyWrite", "Read-only SVGA_REG_XXXX writes.");
|
---|
7255 | REG_CNT(&pThis->svga.StatRegScratchWr, "VMSVGA/Reg/ScratchWrite", "SVGA_REG_SCRATCH_XXXX writes.");
|
---|
7256 | REG_CNT(&pThis->svga.StatRegSyncWr, "VMSVGA/Reg/SyncWrite", "SVGA_REG_SYNC writes.");
|
---|
7257 | REG_CNT(&pThis->svga.StatRegTopWr, "VMSVGA/Reg/TopWrite", "SVGA_REG_TOP writes.");
|
---|
7258 | REG_CNT(&pThis->svga.StatRegTracesWr, "VMSVGA/Reg/TracesWrite", "SVGA_REG_TRACES writes.");
|
---|
7259 | REG_CNT(&pThis->svga.StatRegUnknownWr, "VMSVGA/Reg/UnknownWrite", "Writes to unknown register.");
|
---|
7260 | REG_CNT(&pThis->svga.StatRegWidthWr, "VMSVGA/Reg/WidthWrite", "SVGA_REG_WIDTH writes.");
|
---|
7261 | REG_CNT(&pThis->svga.StatRegCommandLowWr, "VMSVGA/Reg/CommandLowWrite", "SVGA_REG_COMMAND_LOW writes.");
|
---|
7262 | REG_CNT(&pThis->svga.StatRegCommandHighWr, "VMSVGA/Reg/CommandHighWrite", "SVGA_REG_COMMAND_HIGH writes.");
|
---|
7263 | REG_CNT(&pThis->svga.StatRegDevCapWr, "VMSVGA/Reg/DevCapWrite", "SVGA_REG_DEV_CAP writes.");
|
---|
7264 | REG_CNT(&pThis->svga.StatRegCmdPrependLowWr, "VMSVGA/Reg/CmdPrependLowWrite", "SVGA_REG_CMD_PREPEND_LOW writes.");
|
---|
7265 | REG_CNT(&pThis->svga.StatRegCmdPrependHighWr, "VMSVGA/Reg/CmdPrependHighWrite", "SVGA_REG_CMD_PREPEND_HIGH writes.");
|
---|
7266 |
|
---|
7267 | REG_CNT(&pThis->svga.StatRegBitsPerPixelRd, "VMSVGA/Reg/BitsPerPixelRead", "SVGA_REG_BITS_PER_PIXEL reads.");
|
---|
7268 | REG_CNT(&pThis->svga.StatRegBlueMaskRd, "VMSVGA/Reg/BlueMaskRead", "SVGA_REG_BLUE_MASK reads.");
|
---|
7269 | REG_CNT(&pThis->svga.StatRegBusyRd, "VMSVGA/Reg/BusyRead", "SVGA_REG_BUSY reads.");
|
---|
7270 | REG_CNT(&pThis->svga.StatRegBytesPerLineRd, "VMSVGA/Reg/BytesPerLineRead", "SVGA_REG_BYTES_PER_LINE reads.");
|
---|
7271 | REG_CNT(&pThis->svga.StatRegCapabilitesRd, "VMSVGA/Reg/CapabilitesRead", "SVGA_REG_CAPABILITIES reads.");
|
---|
7272 | REG_CNT(&pThis->svga.StatRegConfigDoneRd, "VMSVGA/Reg/ConfigDoneRead", "SVGA_REG_CONFIG_DONE reads.");
|
---|
7273 | REG_CNT(&pThis->svga.StatRegCursorXRd, "VMSVGA/Reg/CursorXRead", "SVGA_REG_CURSOR_X reads.");
|
---|
7274 | REG_CNT(&pThis->svga.StatRegCursorYRd, "VMSVGA/Reg/CursorYRead", "SVGA_REG_CURSOR_Y reads.");
|
---|
7275 | REG_CNT(&pThis->svga.StatRegCursorIdRd, "VMSVGA/Reg/CursorIdRead", "SVGA_REG_DEAD (SVGA_REG_CURSOR_ID) reads.");
|
---|
7276 | REG_CNT(&pThis->svga.StatRegCursorOnRd, "VMSVGA/Reg/CursorOnRead", "SVGA_REG_CURSOR_ON reads.");
|
---|
7277 | REG_CNT(&pThis->svga.StatRegDepthRd, "VMSVGA/Reg/DepthRead", "SVGA_REG_DEPTH reads.");
|
---|
7278 | REG_CNT(&pThis->svga.StatRegDisplayHeightRd, "VMSVGA/Reg/DisplayHeightRead", "SVGA_REG_DISPLAY_HEIGHT reads.");
|
---|
7279 | REG_CNT(&pThis->svga.StatRegDisplayIdRd, "VMSVGA/Reg/DisplayIdRead", "SVGA_REG_DISPLAY_ID reads.");
|
---|
7280 | REG_CNT(&pThis->svga.StatRegDisplayIsPrimaryRd, "VMSVGA/Reg/DisplayIsPrimaryRead", "SVGA_REG_DISPLAY_IS_PRIMARY reads.");
|
---|
7281 | REG_CNT(&pThis->svga.StatRegDisplayPositionXRd, "VMSVGA/Reg/DisplayPositionXRead", "SVGA_REG_DISPLAY_POSITION_X reads.");
|
---|
7282 | REG_CNT(&pThis->svga.StatRegDisplayPositionYRd, "VMSVGA/Reg/DisplayPositionYRead", "SVGA_REG_DISPLAY_POSITION_Y reads.");
|
---|
7283 | REG_CNT(&pThis->svga.StatRegDisplayWidthRd, "VMSVGA/Reg/DisplayWidthRead", "SVGA_REG_DISPLAY_WIDTH reads.");
|
---|
7284 | REG_CNT(&pThis->svga.StatRegEnableRd, "VMSVGA/Reg/EnableRead", "SVGA_REG_ENABLE reads.");
|
---|
7285 | REG_CNT(&pThis->svga.StatRegFbOffsetRd, "VMSVGA/Reg/FbOffsetRead", "SVGA_REG_FB_OFFSET reads.");
|
---|
7286 | REG_CNT(&pThis->svga.StatRegFbSizeRd, "VMSVGA/Reg/FbSizeRead", "SVGA_REG_FB_SIZE reads.");
|
---|
7287 | REG_CNT(&pThis->svga.StatRegFbStartRd, "VMSVGA/Reg/FbStartRead", "SVGA_REG_FB_START reads.");
|
---|
7288 | REG_CNT(&pThis->svga.StatRegGmrIdRd, "VMSVGA/Reg/GmrIdRead", "SVGA_REG_GMR_ID reads.");
|
---|
7289 | REG_CNT(&pThis->svga.StatRegGmrMaxDescriptorLengthRd, "VMSVGA/Reg/GmrMaxDescriptorLengthRead", "SVGA_REG_GMR_MAX_DESCRIPTOR_LENGTH reads.");
|
---|
7290 | REG_CNT(&pThis->svga.StatRegGmrMaxIdsRd, "VMSVGA/Reg/GmrMaxIdsRead", "SVGA_REG_GMR_MAX_IDS reads.");
|
---|
7291 | REG_CNT(&pThis->svga.StatRegGmrsMaxPagesRd, "VMSVGA/Reg/GmrsMaxPagesRead", "SVGA_REG_GMRS_MAX_PAGES reads.");
|
---|
7292 | REG_CNT(&pThis->svga.StatRegGreenMaskRd, "VMSVGA/Reg/GreenMaskRead", "SVGA_REG_GREEN_MASK reads.");
|
---|
7293 | REG_CNT(&pThis->svga.StatRegGuestIdRd, "VMSVGA/Reg/GuestIdRead", "SVGA_REG_GUEST_ID reads.");
|
---|
7294 | REG_CNT(&pThis->svga.StatRegHeightRd, "VMSVGA/Reg/HeightRead", "SVGA_REG_HEIGHT reads.");
|
---|
7295 | REG_CNT(&pThis->svga.StatRegHostBitsPerPixelRd, "VMSVGA/Reg/HostBitsPerPixelRead", "SVGA_REG_HOST_BITS_PER_PIXEL reads.");
|
---|
7296 | REG_CNT(&pThis->svga.StatRegIdRd, "VMSVGA/Reg/IdRead", "SVGA_REG_ID reads.");
|
---|
7297 | REG_CNT(&pThis->svga.StatRegIrqMaskRd, "VMSVGA/Reg/IrqMaskRead", "SVGA_REG_IRQ_MASK reads.");
|
---|
7298 | REG_CNT(&pThis->svga.StatRegMaxHeightRd, "VMSVGA/Reg/MaxHeightRead", "SVGA_REG_MAX_HEIGHT reads.");
|
---|
7299 | REG_CNT(&pThis->svga.StatRegMaxWidthRd, "VMSVGA/Reg/MaxWidthRead", "SVGA_REG_MAX_WIDTH reads.");
|
---|
7300 | REG_CNT(&pThis->svga.StatRegMemorySizeRd, "VMSVGA/Reg/MemorySizeRead", "SVGA_REG_MEMORY_SIZE reads.");
|
---|
7301 | REG_CNT(&pThis->svga.StatRegMemRegsRd, "VMSVGA/Reg/MemRegsRead", "SVGA_REG_MEM_REGS reads.");
|
---|
7302 | REG_CNT(&pThis->svga.StatRegMemSizeRd, "VMSVGA/Reg/MemSizeRead", "SVGA_REG_MEM_SIZE reads.");
|
---|
7303 | REG_CNT(&pThis->svga.StatRegMemStartRd, "VMSVGA/Reg/MemStartRead", "SVGA_REG_MEM_START reads.");
|
---|
7304 | REG_CNT(&pThis->svga.StatRegNumDisplaysRd, "VMSVGA/Reg/NumDisplaysRead", "SVGA_REG_NUM_DISPLAYS reads.");
|
---|
7305 | REG_CNT(&pThis->svga.StatRegNumGuestDisplaysRd, "VMSVGA/Reg/NumGuestDisplaysRead", "SVGA_REG_NUM_GUEST_DISPLAYS reads.");
|
---|
7306 | REG_CNT(&pThis->svga.StatRegPaletteRd, "VMSVGA/Reg/PaletteRead", "SVGA_REG_PLAETTE_XXXX reads.");
|
---|
7307 | REG_CNT(&pThis->svga.StatRegPitchLockRd, "VMSVGA/Reg/PitchLockRead", "SVGA_REG_PITCHLOCK reads.");
|
---|
7308 | REG_CNT(&pThis->svga.StatRegPsuedoColorRd, "VMSVGA/Reg/PsuedoColorRead", "SVGA_REG_PSEUDOCOLOR reads.");
|
---|
7309 | REG_CNT(&pThis->svga.StatRegRedMaskRd, "VMSVGA/Reg/RedMaskRead", "SVGA_REG_RED_MASK reads.");
|
---|
7310 | REG_CNT(&pThis->svga.StatRegScratchRd, "VMSVGA/Reg/ScratchRead", "SVGA_REG_SCRATCH reads.");
|
---|
7311 | REG_CNT(&pThis->svga.StatRegScratchSizeRd, "VMSVGA/Reg/ScratchSizeRead", "SVGA_REG_SCRATCH_SIZE reads.");
|
---|
7312 | REG_CNT(&pThis->svga.StatRegSyncRd, "VMSVGA/Reg/SyncRead", "SVGA_REG_SYNC reads.");
|
---|
7313 | REG_CNT(&pThis->svga.StatRegTopRd, "VMSVGA/Reg/TopRead", "SVGA_REG_TOP reads.");
|
---|
7314 | REG_CNT(&pThis->svga.StatRegTracesRd, "VMSVGA/Reg/TracesRead", "SVGA_REG_TRACES reads.");
|
---|
7315 | REG_CNT(&pThis->svga.StatRegUnknownRd, "VMSVGA/Reg/UnknownRead", "SVGA_REG_UNKNOWN reads.");
|
---|
7316 | REG_CNT(&pThis->svga.StatRegVramSizeRd, "VMSVGA/Reg/VramSizeRead", "SVGA_REG_VRAM_SIZE reads.");
|
---|
7317 | REG_CNT(&pThis->svga.StatRegWidthRd, "VMSVGA/Reg/WidthRead", "SVGA_REG_WIDTH reads.");
|
---|
7318 | REG_CNT(&pThis->svga.StatRegWriteOnlyRd, "VMSVGA/Reg/WriteOnlyRead", "Write-only SVGA_REG_XXXX reads.");
|
---|
7319 | REG_CNT(&pThis->svga.StatRegCommandLowRd, "VMSVGA/Reg/CommandLowRead", "SVGA_REG_COMMAND_LOW reads.");
|
---|
7320 | REG_CNT(&pThis->svga.StatRegCommandHighRd, "VMSVGA/Reg/CommandHighRead", "SVGA_REG_COMMAND_HIGH reads.");
|
---|
7321 | REG_CNT(&pThis->svga.StatRegMaxPrimBBMemRd, "VMSVGA/Reg/MaxPrimBBMemRead", "SVGA_REG_MAX_PRIMARY_BOUNDING_BOX_MEM reads.");
|
---|
7322 | REG_CNT(&pThis->svga.StatRegGBMemSizeRd, "VMSVGA/Reg/GBMemSizeRead", "SVGA_REG_SUGGESTED_GBOBJECT_MEM_SIZE_KB reads.");
|
---|
7323 | REG_CNT(&pThis->svga.StatRegDevCapRd, "VMSVGA/Reg/DevCapRead", "SVGA_REG_DEV_CAP reads.");
|
---|
7324 | REG_CNT(&pThis->svga.StatRegCmdPrependLowRd, "VMSVGA/Reg/CmdPrependLowRead", "SVGA_REG_CMD_PREPEND_LOW reads.");
|
---|
7325 | REG_CNT(&pThis->svga.StatRegCmdPrependHighRd, "VMSVGA/Reg/CmdPrependHighRead", "SVGA_REG_CMD_PREPEND_HIGH reads.");
|
---|
7326 | REG_CNT(&pThis->svga.StatRegScrnTgtMaxWidthRd, "VMSVGA/Reg/ScrnTgtMaxWidthRead", "SVGA_REG_SCREENTARGET_MAX_WIDTH reads.");
|
---|
7327 | REG_CNT(&pThis->svga.StatRegScrnTgtMaxHeightRd, "VMSVGA/Reg/ScrnTgtMaxHeightRead", "SVGA_REG_SCREENTARGET_MAX_HEIGHT reads.");
|
---|
7328 | REG_CNT(&pThis->svga.StatRegMobMaxSizeRd, "VMSVGA/Reg/MobMaxSizeRead", "SVGA_REG_MOB_MAX_SIZE reads.");
|
---|
7329 |
|
---|
7330 | REG_PRF(&pSVGAState->StatBusyDelayEmts, "VMSVGA/EmtDelayOnBusyFifo", "Time we've delayed EMTs because of busy FIFO thread.");
|
---|
7331 | REG_CNT(&pSVGAState->StatFifoCommands, "VMSVGA/FifoCommands", "FIFO command counter.");
|
---|
7332 | REG_CNT(&pSVGAState->StatFifoErrors, "VMSVGA/FifoErrors", "FIFO error counter.");
|
---|
7333 | REG_CNT(&pSVGAState->StatFifoUnkCmds, "VMSVGA/FifoUnknownCommands", "FIFO unknown command counter.");
|
---|
7334 | REG_CNT(&pSVGAState->StatFifoTodoTimeout, "VMSVGA/FifoTodoTimeout", "Number of times we discovered pending work after a wait timeout.");
|
---|
7335 | REG_CNT(&pSVGAState->StatFifoTodoWoken, "VMSVGA/FifoTodoWoken", "Number of times we discovered pending work after being woken up.");
|
---|
7336 | REG_PRF(&pSVGAState->StatFifoStalls, "VMSVGA/FifoStalls", "Profiling of FIFO stalls (waiting for guest to finish copying data).");
|
---|
7337 | REG_PRF(&pSVGAState->StatFifoExtendedSleep, "VMSVGA/FifoExtendedSleep", "Profiling FIFO sleeps relying on the refresh timer and/or access handler.");
|
---|
7338 | # if defined(VMSVGA_USE_FIFO_ACCESS_HANDLER) || defined(DEBUG_FIFO_ACCESS)
|
---|
7339 | REG_CNT(&pSVGAState->StatFifoAccessHandler, "VMSVGA/FifoAccessHandler", "Number of times the FIFO access handler triggered.");
|
---|
7340 | # endif
|
---|
7341 | REG_CNT(&pSVGAState->StatFifoCursorFetchAgain, "VMSVGA/FifoCursorFetchAgain", "Times the cursor update counter changed while reading.");
|
---|
7342 | REG_CNT(&pSVGAState->StatFifoCursorNoChange, "VMSVGA/FifoCursorNoChange", "No cursor position change event though the update counter was modified.");
|
---|
7343 | REG_CNT(&pSVGAState->StatFifoCursorPosition, "VMSVGA/FifoCursorPosition", "Cursor position and visibility changes.");
|
---|
7344 | REG_CNT(&pSVGAState->StatFifoCursorVisiblity, "VMSVGA/FifoCursorVisiblity", "Cursor visibility changes.");
|
---|
7345 | REG_CNT(&pSVGAState->StatFifoWatchdogWakeUps, "VMSVGA/FifoWatchdogWakeUps", "Number of times the FIFO refresh poller/watchdog woke up the FIFO thread.");
|
---|
7346 |
|
---|
7347 | # undef REG_CNT
|
---|
7348 | # undef REG_PRF
|
---|
7349 |
|
---|
7350 | /*
|
---|
7351 | * Info handlers.
|
---|
7352 | */
|
---|
7353 | PDMDevHlpDBGFInfoRegister(pDevIns, "vmsvga", "Basic VMSVGA device state details", vmsvgaR3Info);
|
---|
7354 | # ifdef VBOX_WITH_VMSVGA3D
|
---|
7355 | PDMDevHlpDBGFInfoRegister(pDevIns, "vmsvga3dctx", "VMSVGA 3d context details. Accepts 'terse'.", vmsvgaR3Info3dContext);
|
---|
7356 | PDMDevHlpDBGFInfoRegister(pDevIns, "vmsvga3dsfc",
|
---|
7357 | "VMSVGA 3d surface details. "
|
---|
7358 | "Accepts 'terse', 'invy', and one of 'tiny', 'medium', 'normal', 'big', 'huge', or 'gigantic'.",
|
---|
7359 | vmsvgaR3Info3dSurface);
|
---|
7360 | PDMDevHlpDBGFInfoRegister(pDevIns, "vmsvga3dsurf",
|
---|
7361 | "VMSVGA 3d surface details and bitmap: "
|
---|
7362 | "sid[>dir]",
|
---|
7363 | vmsvgaR3Info3dSurfaceBmp);
|
---|
7364 | # endif
|
---|
7365 |
|
---|
7366 | return VINF_SUCCESS;
|
---|
7367 | }
|
---|
7368 |
|
---|
7369 | /* Initialize 3D backend, set device capabilities and call pfnPowerOn callback of 3D backend.
|
---|
7370 | *
|
---|
7371 | * @param pDevIns The device instance.
|
---|
7372 | * @param pThis The shared VGA/VMSVGA instance data.
|
---|
7373 | * @param pThisCC The VGA/VMSVGA state for ring-3.
|
---|
7374 | * @param fLoadState Whether saved state is being loaded.
|
---|
7375 | */
|
---|
7376 | static void vmsvgaR3PowerOnDevice(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC, bool fLoadState)
|
---|
7377 | {
|
---|
7378 | # ifdef VBOX_WITH_VMSVGA3D
|
---|
7379 | if (pThis->svga.f3DEnabled)
|
---|
7380 | {
|
---|
7381 | /* Load a 3D backend. */
|
---|
7382 | int rc = vmsvgaR3Init3dInterfaces(pDevIns, pThis, pThisCC);
|
---|
7383 | if (RT_FAILURE(rc))
|
---|
7384 | {
|
---|
7385 | LogRel(("VMSVGA3d: 3D support disabled! (vmsvga3dInit -> %Rrc)\n", rc));
|
---|
7386 | pThis->svga.f3DEnabled = false;
|
---|
7387 | }
|
---|
7388 | }
|
---|
7389 | # endif
|
---|
7390 |
|
---|
7391 | # if defined(VBOX_WITH_VMSVGA3D) && defined(RT_OS_LINUX)
|
---|
7392 | if (pThis->svga.f3DEnabled)
|
---|
7393 | {
|
---|
7394 | /* The FIFO thread may use X API for accelerated screen output. */
|
---|
7395 | /* This must be done after backend initialization by vmsvgaR3Init3dInterfaces,
|
---|
7396 | * because it dynamically resolves XInitThreads.
|
---|
7397 | */
|
---|
7398 | XInitThreads();
|
---|
7399 | }
|
---|
7400 | # endif
|
---|
7401 |
|
---|
7402 | if (!fLoadState)
|
---|
7403 | {
|
---|
7404 | if (!pThis->fVmSvga3)
|
---|
7405 | vmsvgaR3InitFIFO(pThis, pThisCC);
|
---|
7406 | vmsvgaR3GetCaps(pThis, pThisCC, &pThis->svga.u32DeviceCaps, &pThis->svga.u32DeviceCaps2, &pThisCC->svga.pau32FIFO[SVGA_FIFO_CAPABILITIES]);
|
---|
7407 | }
|
---|
7408 | # ifdef DEBUG
|
---|
7409 | else
|
---|
7410 | {
|
---|
7411 | /* If saved state is being loaded then FIFO and caps are already restored. */
|
---|
7412 | uint32_t u32DeviceCaps = 0;
|
---|
7413 | uint32_t u32DeviceCaps2 = 0;
|
---|
7414 | uint32_t u32FIFOCaps = 0;
|
---|
7415 | vmsvgaR3GetCaps(pThis, pThisCC, &u32DeviceCaps, &u32DeviceCaps2, &u32FIFOCaps);
|
---|
7416 |
|
---|
7417 | /* Capabilities should not change normally.
|
---|
7418 | * However the saved state might have a subset of currently implemented caps.
|
---|
7419 | */
|
---|
7420 | Assert( (pThis->svga.u32DeviceCaps & u32DeviceCaps) == pThis->svga.u32DeviceCaps
|
---|
7421 | && (pThis->svga.u32DeviceCaps2 & u32DeviceCaps2) == pThis->svga.u32DeviceCaps2
|
---|
7422 | && ( pThis->fVmSvga3
|
---|
7423 | || (pThisCC->svga.pau32FIFO[SVGA_FIFO_CAPABILITIES] & u32FIFOCaps) == pThisCC->svga.pau32FIFO[SVGA_FIFO_CAPABILITIES]));
|
---|
7424 | }
|
---|
7425 | #endif
|
---|
7426 |
|
---|
7427 | # ifdef VBOX_WITH_VMSVGA3D
|
---|
7428 | if (pThis->svga.f3DEnabled)
|
---|
7429 | {
|
---|
7430 | PVMSVGAR3STATE pSVGAState = pThisCC->svga.pSvgaR3State;
|
---|
7431 | int rc = pSVGAState->pFuncs3D->pfnPowerOn(pDevIns, pThis, pThisCC);
|
---|
7432 | if (RT_SUCCESS(rc))
|
---|
7433 | {
|
---|
7434 | /* Initialize 3D capabilities. */
|
---|
7435 | vmsvgaR3Init3DCaps(pThis, pThisCC);
|
---|
7436 | if (!pThis->fVmSvga3)
|
---|
7437 | vmsvgaR3InitFIFO3D(pThis, pThisCC);
|
---|
7438 | }
|
---|
7439 | else
|
---|
7440 | {
|
---|
7441 | LogRel(("VMSVGA3d: 3D support disabled! (vmsvga3dPowerOn -> %Rrc)\n", rc));
|
---|
7442 | pThis->svga.f3DEnabled = false;
|
---|
7443 | }
|
---|
7444 | }
|
---|
7445 | # else /* !VBOX_WITH_VMSVGA3D */
|
---|
7446 | RT_NOREF(pDevIns);
|
---|
7447 | # endif /* !VBOX_WITH_VMSVGA3D */
|
---|
7448 | }
|
---|
7449 |
|
---|
7450 |
|
---|
7451 | /**
|
---|
7452 | * Power On notification.
|
---|
7453 | *
|
---|
7454 | * @param pDevIns The device instance data.
|
---|
7455 | *
|
---|
7456 | * @remarks Caller enters the device critical section.
|
---|
7457 | */
|
---|
7458 | DECLCALLBACK(void) vmsvgaR3PowerOn(PPDMDEVINS pDevIns)
|
---|
7459 | {
|
---|
7460 | PVGASTATE pThis = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
|
---|
7461 | PVGASTATECC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC);
|
---|
7462 |
|
---|
7463 | vmsvgaR3PowerOnDevice(pDevIns, pThis, pThisCC, /*fLoadState=*/ false);
|
---|
7464 | }
|
---|
7465 |
|
---|
7466 | /**
|
---|
7467 | * Power Off notification.
|
---|
7468 | *
|
---|
7469 | * @param pDevIns The device instance data.
|
---|
7470 | *
|
---|
7471 | * @remarks Caller enters the device critical section.
|
---|
7472 | */
|
---|
7473 | DECLCALLBACK(void) vmsvgaR3PowerOff(PPDMDEVINS pDevIns)
|
---|
7474 | {
|
---|
7475 | PVGASTATE pThis = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
|
---|
7476 | PVGASTATECC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC);
|
---|
7477 |
|
---|
7478 | /*
|
---|
7479 | * Notify the FIFO thread.
|
---|
7480 | */
|
---|
7481 | if (pThisCC->svga.pFIFOIOThread)
|
---|
7482 | {
|
---|
7483 | /* Hack around a deadlock:
|
---|
7484 | * - the caller holds the device critsect;
|
---|
7485 | * - FIFO thread may attempt to enter the critsect too (when raising an IRQ).
|
---|
7486 | */
|
---|
7487 | PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect);
|
---|
7488 |
|
---|
7489 | int rc = vmsvgaR3RunExtCmdOnFifoThread(pDevIns, pThis, pThisCC, VMSVGA_FIFO_EXTCMD_POWEROFF,
|
---|
7490 | NULL /*pvParam*/, 30000 /*ms*/);
|
---|
7491 | AssertLogRelRC(rc);
|
---|
7492 |
|
---|
7493 | int const rcLock = PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED);
|
---|
7494 | PDM_CRITSECT_RELEASE_ASSERT_RC_DEV(pDevIns, &pThis->CritSect, rcLock);
|
---|
7495 | }
|
---|
7496 | }
|
---|
7497 |
|
---|
7498 | #endif /* IN_RING3 */
|
---|