VirtualBox

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

Last change on this file since 97405 was 96407, checked in by vboxsync, 2 years ago

scm copyright and license note update

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