VirtualBox

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

Last change on this file since 106942 was 106188, checked in by vboxsync, 4 months ago

3D: Conditionally enable 3D backend in 2D mode if VMSVGA2dGBO extradata is set (experimental change for testing purposes). ​bugref:10580

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 26.2 KB
Line 
1/* $Id: DevVGA-SVGA.h 106188 2024-10-01 09:52:02Z vboxsync $ */
2/** @file
3 * VMware SVGA device
4 */
5/*
6 * Copyright (C) 2013-2024 Oracle and/or its affiliates.
7 *
8 * This file is part of VirtualBox base platform packages, as
9 * available from https://www.virtualbox.org.
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation, in version 3 of the
14 * License.
15 *
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, see <https://www.gnu.org/licenses>.
23 *
24 * SPDX-License-Identifier: GPL-3.0-only
25 */
26
27#ifndef VBOX_INCLUDED_SRC_Graphics_DevVGA_SVGA_h
28#define VBOX_INCLUDED_SRC_Graphics_DevVGA_SVGA_h
29#ifndef RT_WITHOUT_PRAGMA_ONCE
30# pragma once
31#endif
32
33#ifndef VBOX_WITH_VMSVGA
34# error "VBOX_WITH_VMSVGA is not defined"
35#endif
36
37#define VMSVGA_USE_EMT_HALT_CODE
38
39#include <VBox/pci.h>
40#include <VBox/vmm/pdmifs.h>
41#include <VBox/vmm/pdmthread.h>
42#include <VBox/vmm/stam.h>
43#ifdef VMSVGA_USE_EMT_HALT_CODE
44# include <VBox/vmm/vmapi.h>
45# include <VBox/vmm/vmcpuset.h>
46#endif
47
48#include <iprt/avl.h>
49#include <iprt/list.h>
50
51
52/*
53 * PCI device IDs.
54 */
55#ifndef PCI_VENDOR_ID_VMWARE
56# define PCI_VENDOR_ID_VMWARE 0x15AD
57#endif
58#ifndef PCI_DEVICE_ID_VMWARE_SVGA2
59# define PCI_DEVICE_ID_VMWARE_SVGA2 0x0405
60#endif
61#ifndef PCI_DEVICE_ID_VMWARE_SVGA3
62# define PCI_DEVICE_ID_VMWARE_SVGA3 0x0406
63#endif
64
65/* For "svga_overlay.h" */
66#ifndef TRUE
67# define TRUE 1
68#endif
69#ifndef FALSE
70# define FALSE 0
71#endif
72
73/* VMSVGA headers. */
74#include "vmsvga_headers_begin.h"
75#pragma pack(1) /* VMSVGA structures are '__packed'. */
76#include <svga3d_caps.h>
77#include <svga3d_reg.h>
78#include <svga3d_shaderdefs.h>
79#include <svga_escape.h>
80#include <svga_overlay.h>
81#include <vbsvga3d_dx.h>
82#pragma pack()
83#include "vmsvga_headers_end.h"
84
85/**@def FLOAT_FMT_STR
86 * Format string bits to go with FLOAT_FMT_ARGS. */
87#define FLOAT_FMT_STR "%s%u.%06u"
88/** @def FLOAT_FMT_ARGS
89 * Format arguments for a float value, corresponding to FLOAT_FMT_STR.
90 * @param r The floating point value to format. */
91#define FLOAT_FMT_ARGS(r) (r) >= 0.0f ? "" : "-", (unsigned)RT_ABS(r) \
92 , (unsigned)(RT_ABS((r) - (float)(unsigned)(r)) * 1000000.0f)
93
94/* Deprecated commands. They are not included in the VMSVGA headers anymore. */
95#define SVGA_CMD_RECT_FILL 2
96#define SVGA_CMD_DISPLAY_CURSOR 20
97#define SVGA_CMD_MOVE_CURSOR 21
98
99/*
100 * SVGA_CMD_RECT_FILL --
101 *
102 * Fill a rectangular area in the the GFB, and copy the result
103 * to any screens which intersect it.
104 *
105 * Deprecated?
106 *
107 * Availability:
108 * SVGA_CAP_RECT_FILL
109 */
110
111typedef
112struct {
113 uint32_t pixel;
114 uint32_t destX;
115 uint32_t destY;
116 uint32_t width;
117 uint32_t height;
118} SVGAFifoCmdRectFill;
119
120/*
121 * SVGA_CMD_DISPLAY_CURSOR --
122 *
123 * Turn the cursor on or off.
124 *
125 * Deprecated.
126 *
127 * Availability:
128 * SVGA_CAP_CURSOR?
129 */
130
131typedef
132struct {
133 uint32_t id; // Reserved, must be zero.
134 uint32_t state; // 0=off
135} SVGAFifoCmdDisplayCursor;
136
137/*
138 * SVGA_CMD_MOVE_CURSOR --
139 *
140 * Set the cursor position.
141 *
142 * Deprecated.
143 *
144 * Availability:
145 * SVGA_CAP_CURSOR?
146 */
147
148typedef
149struct {
150 SVGASignedPoint pos;
151} SVGAFifoCmdMoveCursor;
152
153
154/** Default FIFO size. */
155#define VMSVGA_FIFO_SIZE _2M
156/** The old FIFO size. */
157#define VMSVGA_FIFO_SIZE_OLD _128K
158
159/** Default scratch region size. */
160#define VMSVGA_SCRATCH_SIZE 0x100
161/** Surface memory available to the guest. */
162#define VMSVGA_SURFACE_SIZE (512*1024*1024)
163/** Maximum GMR pages. */
164#define VMSVGA_MAX_GMR_PAGES 0x100000
165/** Maximum nr of GMR ids. */
166#define VMSVGA_MAX_GMR_IDS _8K
167/** Maximum number of GMR descriptors. */
168#define VMSVGA_MAX_GMR_DESC_LOOP_COUNT VMSVGA_MAX_GMR_PAGES
169
170#define VMSVGA_VAL_UNINITIALIZED (unsigned)-1
171
172/** For validating X and width values.
173 * The code assumes it's at least an order of magnitude less than UINT32_MAX. */
174#define VMSVGA_MAX_X _1M
175/** For validating Y and height values.
176 * The code assumes it's at least an order of magnitude less than UINT32_MAX. */
177#define VMSVGA_MAX_Y _1M
178
179/* u32ActionFlags */
180#define VMSVGA_ACTION_CHANGEMODE_BIT 0
181#define VMSVGA_ACTION_CHANGEMODE RT_BIT(VMSVGA_ACTION_CHANGEMODE_BIT)
182
183
184#ifdef DEBUG
185/* Enable to log FIFO register accesses. */
186//# define DEBUG_FIFO_ACCESS
187/* Enable to log GMR page accesses. */
188//# define DEBUG_GMR_ACCESS
189#endif
190
191#define VMSVGA_FIFO_EXTCMD_NONE 0
192#define VMSVGA_FIFO_EXTCMD_TERMINATE 1
193#define VMSVGA_FIFO_EXTCMD_SAVESTATE 2
194#define VMSVGA_FIFO_EXTCMD_LOADSTATE 3
195#define VMSVGA_FIFO_EXTCMD_RESET 4
196#define VMSVGA_FIFO_EXTCMD_UPDATE_SURFACE_HEAP_BUFFERS 5
197#define VMSVGA_FIFO_EXTCMD_POWEROFF 6
198
199/** Size of the region to backup when switching into svga mode. */
200#define VMSVGA_VGA_FB_BACKUP_SIZE _512K
201
202/** @def VMSVGA_WITH_VGA_FB_BACKUP
203 * Enables correct VGA MMIO read/write handling when VMSVGA is enabled. It
204 * is SLOW and probably not entirely right, but it helps with getting 3dmark
205 * output and other stuff. */
206#define VMSVGA_WITH_VGA_FB_BACKUP 1
207
208/** @def VMSVGA_WITH_VGA_FB_BACKUP_AND_IN_RING3
209 * defined(VMSVGA_WITH_VGA_FB_BACKUP) && defined(IN_RING3) */
210#if (defined(VMSVGA_WITH_VGA_FB_BACKUP) && defined(IN_RING3)) || defined(DOXYGEN_RUNNING)
211# define VMSVGA_WITH_VGA_FB_BACKUP_AND_IN_RING3 1
212#else
213# undef VMSVGA_WITH_VGA_FB_BACKUP_AND_IN_RING3
214#endif
215
216/** @def VMSVGA_WITH_VGA_FB_BACKUP_AND_IN_RZ
217 * defined(VMSVGA_WITH_VGA_FB_BACKUP) && !defined(IN_RING3) */
218#if (defined(VMSVGA_WITH_VGA_FB_BACKUP) && !defined(IN_RING3)) || defined(DOXYGEN_RUNNING)
219# define VMSVGA_WITH_VGA_FB_BACKUP_AND_IN_RZ 1
220#else
221# undef VMSVGA_WITH_VGA_FB_BACKUP_AND_IN_RZ
222#endif
223
224
225typedef struct
226{
227 PSSMHANDLE pSSM;
228 uint32_t uVersion;
229 uint32_t uPass;
230} VMSVGA_STATE_LOAD;
231typedef VMSVGA_STATE_LOAD *PVMSVGA_STATE_LOAD;
232
233/** Host screen viewport.
234 * (4th quadrant with negated Y values - usual Windows and X11 world view.) */
235typedef struct VMSVGAVIEWPORT
236{
237 uint32_t x; /**< x coordinate (left). */
238 uint32_t y; /**< y coordinate (top). */
239 uint32_t cx; /**< width. */
240 uint32_t cy; /**< height. */
241 /** Right side coordinate (exclusive). Same as x + cx. */
242 uint32_t xRight;
243 /** First quadrant low y coordinate.
244 * Same as y + cy - 1 in window coordinates. */
245 uint32_t yLowWC;
246 /** First quadrant high y coordinate (exclusive) - yLowWC + cy.
247 * Same as y - 1 in window coordinates. */
248 uint32_t yHighWC;
249 /** Alignment padding. */
250 uint32_t uAlignment;
251} VMSVGAVIEWPORT;
252
253#ifdef VBOX_WITH_VMSVGA3D
254typedef struct VMSVGAHWSCREEN *PVMSVGAHWSCREEN;
255#endif
256
257/**
258 * Screen object state.
259 */
260typedef struct VMSVGASCREENOBJECT
261{
262 /** SVGA_SCREEN_* flags. */
263 uint32_t fuScreen;
264 /** The screen object id. */
265 uint32_t idScreen;
266 /** The screen dimensions. */
267 int32_t xOrigin;
268 int32_t yOrigin;
269 uint32_t cWidth;
270 uint32_t cHeight;
271 /** Offset of the screen buffer in the guest VRAM. */
272 uint32_t offVRAM;
273 /** Scanline pitch. */
274 uint32_t cbPitch;
275 /** Bits per pixel. */
276 uint32_t cBpp;
277 /** The physical DPI that the guest expects for this screen. Zero, if the guest is not DPI aware. */
278 uint32_t cDpi;
279 bool fDefined;
280 bool fModified;
281 void *pvScreenBitmap;
282#ifdef VBOX_WITH_VMSVGA3D
283 /** Pointer to the HW accelerated (3D) screen data. */
284 R3PTRTYPE(PVMSVGAHWSCREEN) pHwScreen;
285#endif
286} VMSVGASCREENOBJECT;
287
288/** Pointer to the private VMSVGA ring-3 state structure.
289 * @todo Still not entirely satisfired with the type name, but better than
290 * the previous lower/upper case only distinction. */
291typedef struct VMSVGAR3STATE *PVMSVGAR3STATE;
292/** Pointer to the private (implementation specific) VMSVGA3d state. */
293typedef struct VMSVGA3DSTATE *PVMSVGA3DSTATE;
294
295
296/**
297 * The VMSVGA device state.
298 *
299 * This instantatiated as VGASTATE::svga.
300 */
301typedef struct VMSVGAState
302{
303 /** Guest physical address of the FIFO memory range. */
304 RTGCPHYS GCPhysFIFO;
305 /** Size in bytes of the FIFO memory range.
306 * This may be smaller than cbFIFOConfig after restoring an old VM state. */
307 uint32_t cbFIFO;
308 /** The configured FIFO size. */
309 uint32_t cbFIFOConfig;
310 /** SVGA id. */
311 uint32_t u32SVGAId;
312 /** SVGA extensions enabled or not. */
313 uint32_t fEnabled;
314 /** SVGA memory area configured status. */
315 uint32_t fConfigured;
316 /** Device is busy handling FIFO requests (VMSVGA_BUSY_F_FIFO,
317 * VMSVGA_BUSY_F_EMT_FORCE). */
318 uint32_t volatile fBusy;
319#define VMSVGA_BUSY_F_FIFO RT_BIT_32(0) /**< The normal true/false busy FIFO bit. */
320#define VMSVGA_BUSY_F_EMT_FORCE RT_BIT_32(1) /**< Bit preventing race status flickering when EMT kicks the FIFO thread. */
321 /** Traces (dirty page detection) enabled or not. */
322 uint32_t fTraces;
323 /** Guest OS identifier. */
324 uint32_t u32GuestId;
325 /** Scratch region size (VMSVGAState::au32ScratchRegion). */
326 uint32_t cScratchRegion;
327 /** Irq status. */
328 uint32_t u32IrqStatus;
329 /** Irq mask. */
330 uint32_t u32IrqMask;
331 /** Pitch lock. */
332 uint32_t u32PitchLock;
333 /** Current GMR id. (SVGA_REG_GMR_ID) */
334 uint32_t u32CurrentGMRId;
335 /** SVGA device capabilities. */
336 uint32_t u32DeviceCaps;
337 uint32_t u32DeviceCaps2; /* Used to be I/O port base address and Padding0. */
338 /** Guest driver information (SVGA_REG_GUEST_DRIVER_*). */
339 uint32_t u32GuestDriverId;
340 uint32_t u32GuestDriverVer1;
341 uint32_t u32GuestDriverVer2;
342 uint32_t u32GuestDriverVer3;
343 /** The last fence received. */
344 uint32_t u32FenceLast;
345 /** Port io index register. */
346 uint32_t u32IndexReg;
347 /** FIFO request semaphore. */
348 SUPSEMEVENT hFIFORequestSem;
349 /** The last seen SVGA_FIFO_CURSOR_COUNT value.
350 * Used by the FIFO thread and its watchdog. */
351 uint32_t uLastCursorUpdateCount;
352 /** Indicates that the FIFO thread is sleeping and might need waking up. */
353 bool volatile fFIFOThreadSleeping;
354 /** The legacy GFB mode registers. If used, they correspond to screen 0. */
355 /** True when the guest modifies the GFB mode registers. */
356 bool fGFBRegisters;
357 /** SVGA 3D overlay enabled or not. */
358 bool f3DOverlayEnabled;
359 /** Indicates that the guest behaves incorrectly. */
360 bool volatile fBadGuest;
361 /** Whether the VirtualBox extensions for VMSVGA device (new commands and caps) are enabled. */
362 bool fVBoxExtensions;
363 /** Whether MSAA support is enabled. */
364 bool fVMSVGA3dMSAA;
365 bool fVMSVGA2dGBO;
366 bool afPadding[1];
367 uint32_t uWidth;
368 uint32_t uHeight;
369 uint32_t uBpp;
370 uint32_t cbScanline;
371 uint32_t uHostBpp;
372 /** Maximum width supported. */
373 uint32_t u32MaxWidth;
374 /** Maximum height supported. */
375 uint32_t u32MaxHeight;
376 /** Viewport rectangle, i.e. what's currently visible of the target host
377 * window. This is usually (0,0)(uWidth,uHeight), but if the window is
378 * shrunk and scrolling applied, both the origin and size may differ. */
379 VMSVGAVIEWPORT viewport;
380 /** Action flags */
381 uint32_t u32ActionFlags;
382 /** SVGA 3d extensions enabled or not. */
383 bool f3DEnabled;
384 /** VRAM page monitoring enabled or not. */
385 bool fVRAMTracking;
386 /** External command to be executed in the FIFO thread. */
387 uint8_t volatile u8FIFOExtCommand;
388 /** Set by vmsvgaR3RunExtCmdOnFifoThread when it temporarily resumes the FIFO
389 * thread and does not want it do anything but the command. */
390 bool volatile fFifoExtCommandWakeup;
391#ifdef DEBUG_GMR_ACCESS
392 /** GMR debug access handler type handle. */
393 PGMPHYSHANDLERTYPE hGmrAccessHandlerType;
394#endif
395#if defined(VMSVGA_USE_FIFO_ACCESS_HANDLER) || defined(DEBUG_FIFO_ACCESS)
396 /** FIFO debug access handler type handle. */
397 PGMPHYSHANDLERTYPE hFifoAccessHandlerType;
398#endif
399 /** Number of GMRs (VMSVGA_MAX_GMR_IDS, count of elements in VMSVGAR3STATE::paGMR array). */
400 uint32_t cGMR;
401 uint32_t uScreenOffset; /* Used only for loading older saved states. */
402
403 /** Legacy cursor state. */
404 uint32_t uCursorX;
405 uint32_t uCursorY;
406 uint32_t uCursorID;
407 uint32_t uCursorOn;
408
409 /** Scratch array.
410 * Putting this at the end since it's big it probably not . */
411 uint32_t au32ScratchRegion[VMSVGA_SCRATCH_SIZE];
412
413 /** Array of SVGA3D_DEVCAP values, which are accessed via SVGA_REG_DEV_CAP. */
414 uint32_t au32DevCaps[SVGA3D_DEVCAP_MAX];
415 /** Index written to the SVGA_REG_DEV_CAP register. */
416 uint32_t u32DevCapIndex;
417 /** Low 32 bit of a command buffer address written to the SVGA_REG_COMMAND_LOW register. */
418 uint32_t u32RegCommandLow;
419 /** High 32 bit of a command buffer address written to the SVGA_REG_COMMAND_HIGH register. */
420 uint32_t u32RegCommandHigh;
421
422 STAMCOUNTER StatRegBitsPerPixelWr;
423 STAMCOUNTER StatRegBusyWr;
424 STAMCOUNTER StatRegCursorXWr;
425 STAMCOUNTER StatRegCursorYWr;
426 STAMCOUNTER StatRegCursorIdWr;
427 STAMCOUNTER StatRegCursorOnWr;
428 STAMCOUNTER StatRegDepthWr;
429 STAMCOUNTER StatRegDisplayHeightWr;
430 STAMCOUNTER StatRegDisplayIdWr;
431 STAMCOUNTER StatRegDisplayIsPrimaryWr;
432 STAMCOUNTER StatRegDisplayPositionXWr;
433 STAMCOUNTER StatRegDisplayPositionYWr;
434 STAMCOUNTER StatRegDisplayWidthWr;
435 STAMCOUNTER StatRegEnableWr;
436 STAMCOUNTER StatRegGmrIdWr;
437 STAMCOUNTER StatRegGuestIdWr;
438 STAMCOUNTER StatRegHeightWr;
439 STAMCOUNTER StatRegIdWr;
440 STAMCOUNTER StatRegIrqMaskWr;
441 STAMCOUNTER StatRegNumDisplaysWr;
442 STAMCOUNTER StatRegNumGuestDisplaysWr;
443 STAMCOUNTER StatRegPaletteWr;
444 STAMCOUNTER StatRegPitchLockWr;
445 STAMCOUNTER StatRegPseudoColorWr;
446 STAMCOUNTER StatRegReadOnlyWr;
447 STAMCOUNTER StatRegScratchWr;
448 STAMCOUNTER StatRegSyncWr;
449 STAMCOUNTER StatRegTopWr;
450 STAMCOUNTER StatRegTracesWr;
451 STAMCOUNTER StatRegUnknownWr;
452 STAMCOUNTER StatRegWidthWr;
453 STAMCOUNTER StatRegCommandLowWr;
454 STAMCOUNTER StatRegCommandHighWr;
455 STAMCOUNTER StatRegDevCapWr;
456 STAMCOUNTER StatRegCmdPrependLowWr;
457 STAMCOUNTER StatRegCmdPrependHighWr;
458
459 STAMCOUNTER StatRegBitsPerPixelRd;
460 STAMCOUNTER StatRegBlueMaskRd;
461 STAMCOUNTER StatRegBusyRd;
462 STAMCOUNTER StatRegBytesPerLineRd;
463 STAMCOUNTER StatRegCapabilitesRd;
464 STAMCOUNTER StatRegConfigDoneRd;
465 STAMCOUNTER StatRegCursorXRd;
466 STAMCOUNTER StatRegCursorYRd;
467 STAMCOUNTER StatRegCursorIdRd;
468 STAMCOUNTER StatRegCursorOnRd;
469 STAMCOUNTER StatRegDepthRd;
470 STAMCOUNTER StatRegDisplayHeightRd;
471 STAMCOUNTER StatRegDisplayIdRd;
472 STAMCOUNTER StatRegDisplayIsPrimaryRd;
473 STAMCOUNTER StatRegDisplayPositionXRd;
474 STAMCOUNTER StatRegDisplayPositionYRd;
475 STAMCOUNTER StatRegDisplayWidthRd;
476 STAMCOUNTER StatRegEnableRd;
477 STAMCOUNTER StatRegFbOffsetRd;
478 STAMCOUNTER StatRegFbSizeRd;
479 STAMCOUNTER StatRegFbStartRd;
480 STAMCOUNTER StatRegGmrIdRd;
481 STAMCOUNTER StatRegGmrMaxDescriptorLengthRd;
482 STAMCOUNTER StatRegGmrMaxIdsRd;
483 STAMCOUNTER StatRegGmrsMaxPagesRd;
484 STAMCOUNTER StatRegGreenMaskRd;
485 STAMCOUNTER StatRegGuestIdRd;
486 STAMCOUNTER StatRegHeightRd;
487 STAMCOUNTER StatRegHostBitsPerPixelRd;
488 STAMCOUNTER StatRegIdRd;
489 STAMCOUNTER StatRegIrqMaskRd;
490 STAMCOUNTER StatRegMaxHeightRd;
491 STAMCOUNTER StatRegMaxWidthRd;
492 STAMCOUNTER StatRegMemorySizeRd;
493 STAMCOUNTER StatRegMemRegsRd;
494 STAMCOUNTER StatRegMemSizeRd;
495 STAMCOUNTER StatRegMemStartRd;
496 STAMCOUNTER StatRegNumDisplaysRd;
497 STAMCOUNTER StatRegNumGuestDisplaysRd;
498 STAMCOUNTER StatRegPaletteRd;
499 STAMCOUNTER StatRegPitchLockRd;
500 STAMCOUNTER StatRegPsuedoColorRd;
501 STAMCOUNTER StatRegRedMaskRd;
502 STAMCOUNTER StatRegScratchRd;
503 STAMCOUNTER StatRegScratchSizeRd;
504 STAMCOUNTER StatRegSyncRd;
505 STAMCOUNTER StatRegTopRd;
506 STAMCOUNTER StatRegTracesRd;
507 STAMCOUNTER StatRegUnknownRd;
508 STAMCOUNTER StatRegVramSizeRd;
509 STAMCOUNTER StatRegWidthRd;
510 STAMCOUNTER StatRegWriteOnlyRd;
511 STAMCOUNTER StatRegCommandLowRd;
512 STAMCOUNTER StatRegCommandHighRd;
513 STAMCOUNTER StatRegMaxPrimBBMemRd;
514 STAMCOUNTER StatRegGBMemSizeRd;
515 STAMCOUNTER StatRegDevCapRd;
516 STAMCOUNTER StatRegCmdPrependLowRd;
517 STAMCOUNTER StatRegCmdPrependHighRd;
518 STAMCOUNTER StatRegScrnTgtMaxWidthRd;
519 STAMCOUNTER StatRegScrnTgtMaxHeightRd;
520 STAMCOUNTER StatRegMobMaxSizeRd;
521} VMSVGAState, VMSVGASTATE;
522
523
524/**
525 * The VMSVGA device state for ring-3
526 *
527 * This instantatiated as VGASTATER3::svga.
528 */
529typedef struct VMSVGASTATER3
530{
531 /** The R3 FIFO pointer. */
532 R3PTRTYPE(uint32_t *) pau32FIFO;
533 /** R3 Opaque pointer to svga state. */
534 R3PTRTYPE(PVMSVGAR3STATE) pSvgaR3State;
535 /** R3 Opaque pointer to 3d state. */
536 R3PTRTYPE(PVMSVGA3DSTATE) p3dState;
537 /** The separate VGA frame buffer in svga mode.
538 * Unlike the the boch-based VGA device implementation, VMSVGA seems to have a
539 * separate frame buffer for VGA and allows concurrent use of both. The SVGA
540 * SDK is making use of this to do VGA text output while testing other things in
541 * SVGA mode, displaying the result by switching back to VGA text mode. So,
542 * when entering SVGA mode we copy the first part of the frame buffer here and
543 * direct VGA accesses here instead. It is copied back when leaving SVGA mode. */
544 R3PTRTYPE(uint8_t *) pbVgaFrameBufferR3;
545 /** R3 Opaque pointer to an external fifo cmd parameter. */
546 R3PTRTYPE(void * volatile) pvFIFOExtCmdParam;
547
548 /** FIFO external command semaphore. */
549 R3PTRTYPE(RTSEMEVENT) hFIFOExtCmdSem;
550 /** FIFO IO Thread. */
551 R3PTRTYPE(PPDMTHREAD) pFIFOIOThread;
552} VMSVGASTATER3;
553
554
555/**
556 * The VMSVGA device state for ring-0
557 *
558 * This instantatiated as VGASTATER0::svga.
559 */
560typedef struct VMSVGASTATER0
561{
562 /** The R0 FIFO pointer.
563 * @note This only points to the _first_ _page_ of the FIFO! */
564 R0PTRTYPE(uint32_t *) pau32FIFO;
565} VMSVGASTATER0;
566
567
568typedef struct VGAState *PVGASTATE;
569typedef struct VGASTATER3 *PVGASTATER3;
570typedef struct VGASTATER0 *PVGASTATER0;
571typedef struct VGASTATERC *PVGASTATERC;
572typedef CTX_SUFF(PVGASTATE) PVGASTATECC;
573
574DECLCALLBACK(int) vmsvgaR3PciIORegionFifoMapUnmap(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iRegion,
575 RTGCPHYS GCPhysAddress, RTGCPHYS cb, PCIADDRESSSPACE enmType);
576DECLCALLBACK(VBOXSTRICTRC) vmsvgaIORead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t *pu32, unsigned cb);
577DECLCALLBACK(VBOXSTRICTRC) vmsvgaIOWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t u32, unsigned cb);
578DECLCALLBACK(VBOXSTRICTRC) vmsvga3MmioRead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void *pv, unsigned cb);
579DECLCALLBACK(VBOXSTRICTRC) vmsvga3MmioWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void const *pv, unsigned cb);
580
581DECLCALLBACK(void) vmsvgaR3PortSetViewport(PPDMIDISPLAYPORT pInterface, uint32_t uScreenId,
582 uint32_t x, uint32_t y, uint32_t cx, uint32_t cy);
583DECLCALLBACK(void) vmsvgaR3PortReportMonitorPositions(PPDMIDISPLAYPORT pInterface, uint32_t cPositions, PCRTPOINT paPositions);
584
585int vmsvgaR3Init(PPDMDEVINS pDevIns);
586int vmsvgaR3Reset(PPDMDEVINS pDevIns);
587int vmsvgaR3Destruct(PPDMDEVINS pDevIns);
588int vmsvgaR3LoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass);
589int vmsvgaR3LoadDone(PPDMDEVINS pDevIns);
590int vmsvgaR3SaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM);
591DECLCALLBACK(void) vmsvgaR3PowerOn(PPDMDEVINS pDevIns);
592DECLCALLBACK(void) vmsvgaR3PowerOff(PPDMDEVINS pDevIns);
593void vmsvgaR3FifoWatchdogTimer(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC);
594
595#ifdef IN_RING3
596VMSVGASCREENOBJECT *vmsvgaR3GetScreenObject(PVGASTATECC pThisCC, uint32_t idScreen);
597int vmsvgaR3UpdateScreen(PVGASTATECC pThisCC, VMSVGASCREENOBJECT *pScreen, int x, int y, int w, int h);
598#endif
599
600int vmsvgaR3GmrTransfer(PVGASTATE pThis, PVGASTATECC pThisCC, const SVGA3dTransferType enmTransferType,
601 uint8_t *pbHstBuf, uint32_t cbHstBuf, uint32_t offHst, int32_t cbHstPitch,
602 SVGAGuestPtr gstPtr, uint32_t offGst, int32_t cbGstPitch,
603 uint32_t cbWidth, uint32_t cHeight);
604
605void vmsvgaR3ClipCopyBox(const SVGA3dSize *pSizeSrc, const SVGA3dSize *pSizeDest, SVGA3dCopyBox *pBox);
606void vmsvgaR3ClipBox(const SVGA3dSize *pSize, SVGA3dBox *pBox);
607void vmsvgaR3ClipRect(SVGASignedRect const *pBound, SVGASignedRect *pRect);
608void vmsvgaR3Clip3dRect(SVGA3dRect const *pBound, SVGA3dRect RT_UNTRUSTED_GUEST *pRect);
609
610/*
611 * GBO (Guest Backed Object).
612 * A GBO is a list of the guest pages. GBOs are used for VMSVGA MOBs (Memory OBjects)
613 * and Object Tables which the guest shares with the host.
614 *
615 * A GBO is similar to a GMR. Nevertheless I'll create a new code for GBOs in order
616 * to avoid tweaking and possibly breaking existing code. Moreover it will be probably possible to
617 * map the guest pages into the host R3 memory and access them directly.
618 */
619
620/* GBO descriptor. */
621typedef struct VMSVGAGBODESCRIPTOR
622{
623 RTGCPHYS GCPhys;
624 uint64_t cPages;
625} VMSVGAGBODESCRIPTOR, *PVMSVGAGBODESCRIPTOR;
626typedef VMSVGAGBODESCRIPTOR const *PCVMSVGAGBODESCRIPTOR;
627
628/* GBO.
629 */
630typedef struct VMSVGAGBO
631{
632 uint32_t fGboFlags;
633 uint32_t cTotalPages;
634 uint32_t cbTotal;
635 uint32_t cDescriptors;
636 PVMSVGAGBODESCRIPTOR paDescriptors;
637 void *pvHost; /* Pointer to cbTotal bytes on the host if VMSVGAGBO_F_HOST_BACKED is set. */
638} VMSVGAGBO, *PVMSVGAGBO;
639typedef VMSVGAGBO const *PCVMSVGAGBO;
640
641#define VMSVGAGBO_F_OBSOLETE_0x1 0x1
642#define VMSVGAGBO_F_HOST_BACKED 0x2
643
644#define VMSVGA_IS_GBO_CREATED(a_Gbo) ((a_Gbo)->paDescriptors != NULL)
645
646int vmsvgaR3OTableReadSurface(PVMSVGAR3STATE pSvgaR3State, uint32_t sid, SVGAOTableSurfaceEntry *pEntrySurface);
647
648/* MOB is also a GBO.
649 */
650typedef struct VMSVGAMOB
651{
652 AVLU32NODECORE Core; /* Key is the mobid. */
653 RTLISTNODE nodeLRU;
654 VMSVGAGBO Gbo;
655} VMSVGAMOB, *PVMSVGAMOB;
656typedef VMSVGAMOB const *PCVMSVGAMOB;
657
658PVMSVGAMOB vmsvgaR3MobGet(PVMSVGAR3STATE pSvgaR3State, SVGAMobId RT_UNTRUSTED_GUEST mobid);
659int vmsvgaR3MobWrite(PVMSVGAR3STATE pSvgaR3State, PVMSVGAMOB pMob, uint32_t off, void const *pvData, uint32_t cbData);
660int vmsvgaR3MobRead(PVMSVGAR3STATE pSvgaR3State, PVMSVGAMOB pMob, uint32_t off, void *pvData, uint32_t cbData);
661int vmsvgaR3MobBackingStoreCreate(PVMSVGAR3STATE pSvgaR3State, PVMSVGAMOB pMob, uint32_t cbValid);
662void vmsvgaR3MobBackingStoreDelete(PVMSVGAR3STATE pSvgaR3State, PVMSVGAMOB pMob);
663int vmsvgaR3MobBackingStoreWriteToGuest(PVMSVGAR3STATE pSvgaR3State, PVMSVGAMOB pMob);
664int vmsvgaR3MobBackingStoreReadFromGuest(PVMSVGAR3STATE pSvgaR3State, PVMSVGAMOB pMob);
665void *vmsvgaR3MobBackingStorePtr(PVMSVGAMOB pMob, uint32_t off);
666
667DECLINLINE(uint32_t) vmsvgaR3MobSize(PVMSVGAMOB pMob)
668{
669 if (pMob)
670 return pMob->Gbo.cbTotal;
671 return 0;
672}
673
674DECLINLINE(uint32_t) vmsvgaR3MobId(PVMSVGAMOB pMob)
675{
676 if (pMob)
677 return pMob->Core.Key;
678 return SVGA_ID_INVALID;
679}
680
681#ifdef DEBUG_sunlover
682#define DEBUG_BREAKPOINT_TEST() do { ASMBreakpoint(); } while (0)
683#else
684#define DEBUG_BREAKPOINT_TEST() do { } while (0)
685#endif
686
687#endif /* !VBOX_INCLUDED_SRC_Graphics_DevVGA_SVGA_h */
Note: See TracBrowser for help on using the repository browser.

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