VirtualBox

source: vbox/trunk/src/VBox/Devices/Graphics/DevVGA.h@ 108793

Last change on this file since 108793 was 108641, checked in by vboxsync, 6 weeks ago

Removed 2D video acceleration (aka VHWA / VBOX_WITH_VIDEOHWACCEL). bugref:10756

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 29.7 KB
Line 
1/* $Id: DevVGA.h 108641 2025-03-20 12:48:42Z vboxsync $ */
2/** @file
3 * DevVGA - VBox VGA/VESA device, internal header.
4 */
5
6/*
7 * Copyright (C) 2006-2024 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 * --------------------------------------------------------------------
27 *
28 * This code is based on:
29 *
30 * QEMU internal VGA defines.
31 *
32 * Copyright (c) 2003-2004 Fabrice Bellard
33 *
34 * Permission is hereby granted, free of charge, to any person obtaining a copy
35 * of this software and associated documentation files (the "Software"), to deal
36 * in the Software without restriction, including without limitation the rights
37 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
38 * copies of the Software, and to permit persons to whom the Software is
39 * furnished to do so, subject to the following conditions:
40 *
41 * The above copyright notice and this permission notice shall be included in
42 * all copies or substantial portions of the Software.
43 *
44 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
45 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
46 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
47 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
48 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
49 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
50 * THE SOFTWARE.
51 */
52
53#ifndef VBOX_INCLUDED_SRC_Graphics_DevVGA_h
54#define VBOX_INCLUDED_SRC_Graphics_DevVGA_h
55#ifndef RT_WITHOUT_PRAGMA_ONCE
56# pragma once
57#endif
58
59#include <VBoxVideoVBE.h>
60#include <VBoxVideoVBEPrivate.h>
61
62#ifdef VBOX_WITH_HGSMI
63# include "HGSMI/HGSMIHost.h"
64#endif /* VBOX_WITH_HGSMI */
65#include "DevVGASavedState.h"
66
67#ifdef VBOX_WITH_VMSVGA
68# include "DevVGA-SVGA.h"
69#else
70# include <VBox/vmm/pdmifs.h>
71# include <VBox/vmm/stam.h>
72#endif
73
74#include <VBox/param.h> /* For VRAM ranges. */
75#ifdef VBOX_WITH_VMSVGA
76/* Make sure the param.h copy of the SVGA VRAM sizes matches the originals. */
77AssertCompile(VBOX_SVGA_VRAM_MIN_SIZE == SVGA_VRAM_MIN_SIZE);
78AssertCompile(VBOX_SVGA_VRAM_MIN_SIZE_3D == SVGA_VRAM_MIN_SIZE_3D);
79AssertCompile(VBOX_SVGA_VRAM_MAX_SIZE == SVGA_VRAM_MAX_SIZE);
80#endif
81
82#include <iprt/list.h>
83
84
85/** Use VBE bytewise I/O. Only needed for Windows Longhorn/Vista betas and backwards compatibility. */
86#define VBE_BYTEWISE_IO
87
88/** @name Macros dealing with partial ring-0/raw-mode VRAM mappings.
89 * @{ */
90/** The size of the VGA ring-0 and raw-mode mapping.
91 *
92 * This is supposed to be all the VGA memory accessible to the guest.
93 * The initial value was 256KB but NTAllInOne.iso appears to access more
94 * thus the limit was upped to 512KB.
95 *
96 * @todo Someone with some VGA knowhow should make a better guess at this value.
97 */
98#define VGA_MAPPING_SIZE _512K
99/** Enables partially mapping the VRAM into ring-0 rather than using the ring-3.
100 * The VGA_MAPPING_SIZE define sets the number of bytes that will be mapped. */
101#define VGA_WITH_PARTIAL_RING0_MAPPING
102
103/**
104 * Check buffer if an VRAM offset is within the right range or not.
105 */
106#if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0) || (defined(IN_RING0) && defined(VGA_WITH_PARTIAL_RING0_MAPPING))
107# define VERIFY_VRAM_WRITE_OFF_RETURN(pThis, off) \
108 do { \
109 if ((off) < VGA_MAPPING_SIZE) \
110 RT_UNTRUSTED_VALIDATED_FENCE(); \
111 else \
112 { \
113 AssertMsgReturn((off) < (pThis)->vram_size, ("%RX32 !< %RX32\n", (uint32_t)(off), (pThis)->vram_size), VINF_SUCCESS); \
114 Log2(("%Rfn[%d]: %RX32 -> R3\n", __PRETTY_FUNCTION__, __LINE__, (off))); \
115 return VINF_IOM_R3_MMIO_WRITE; \
116 } \
117 } while (0)
118#else
119# define VERIFY_VRAM_WRITE_OFF_RETURN(pThis, off) \
120 do { \
121 AssertMsgReturn((off) < (pThis)->vram_size, ("%RX32 !< %RX32\n", (uint32_t)(off), (pThis)->vram_size), VINF_SUCCESS); \
122 RT_UNTRUSTED_VALIDATED_FENCE(); \
123 } while (0)
124#endif
125
126/**
127 * Check buffer if an VRAM offset is within the right range or not.
128 */
129#if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0) || (defined(IN_RING0) && defined(VGA_WITH_PARTIAL_RING0_MAPPING))
130# define VERIFY_VRAM_READ_OFF_RETURN(pThis, off, rcVar) \
131 do { \
132 if ((off) < VGA_MAPPING_SIZE) \
133 RT_UNTRUSTED_VALIDATED_FENCE(); \
134 else \
135 { \
136 AssertMsgReturn((off) < (pThis)->vram_size, ("%RX32 !< %RX32\n", (uint32_t)(off), (pThis)->vram_size), 0xff); \
137 Log2(("%Rfn[%d]: %RX32 -> R3\n", __PRETTY_FUNCTION__, __LINE__, (off))); \
138 (rcVar) = VINF_IOM_R3_MMIO_READ; \
139 return 0; \
140 } \
141 } while (0)
142#else
143# define VERIFY_VRAM_READ_OFF_RETURN(pThis, off, rcVar) \
144 do { \
145 AssertMsgReturn((off) < (pThis)->vram_size, ("%RX32 !< %RX32\n", (uint32_t)(off), (pThis)->vram_size), 0xff); \
146 RT_UNTRUSTED_VALIDATED_FENCE(); \
147 NOREF(rcVar); \
148 } while (0)
149#endif
150/** @} */
151
152
153#define MSR_COLOR_EMULATION 0x01
154#define MSR_PAGE_SELECT 0x20
155
156#define ST01_V_RETRACE 0x08
157#define ST01_DISP_ENABLE 0x01
158
159/* bochs VBE support */
160#define CONFIG_BOCHS_VBE
161
162#ifdef CONFIG_BOCHS_VBE
163
164/* Cross reference with <VBoxVideoVBE.h> */
165#define VBE_DISPI_INDEX_NB_SAVED 0xb /* Old number of saved registers (vbe_regs array, see vga_load) */
166#define VBE_DISPI_INDEX_NB 0xd /* Total number of VBE registers */
167
168#define VGA_STATE_COMMON_BOCHS_VBE \
169 uint16_t vbe_index; \
170 uint16_t vbe_regs[VBE_DISPI_INDEX_NB]; \
171 uint16_t alignment[2]; /* pad to 64 bits */ \
172 uint32_t vbe_start_addr; \
173 uint32_t vbe_line_offset; \
174 uint32_t vbe_bank_max;
175
176#else
177
178#define VGA_STATE_COMMON_BOCHS_VBE
179
180#endif /* !CONFIG_BOCHS_VBE */
181
182#define CH_ATTR_SIZE (160 * 100)
183#define VGA_MAX_HEIGHT VBE_DISPI_MAX_YRES
184
185typedef struct vga_retrace_s {
186 unsigned frame_cclks; /* Character clocks per frame. */
187 unsigned frame_ns; /* Frame duration in ns. */
188 unsigned cclk_ns; /* Character clock duration in ns. */
189 unsigned vb_start; /* Vertical blanking start (scanline). */
190 unsigned vb_end; /* Vertical blanking end (scanline). */
191 unsigned vb_end_ns; /* Vertical blanking end time (length) in ns. */
192 unsigned vs_start; /* Vertical sync start (scanline). */
193 unsigned vs_end; /* Vertical sync end (scanline). */
194 unsigned vs_start_ns; /* Vertical sync start time in ns. */
195 unsigned vs_end_ns; /* Vertical sync end time in ns. */
196 unsigned h_total; /* Horizontal total (cclks per scanline). */
197 unsigned h_total_ns; /* Scanline duration in ns. */
198 unsigned hb_start; /* Horizontal blanking start (cclk). */
199 unsigned hb_end; /* Horizontal blanking end (cclk). */
200 unsigned hb_end_ns; /* Horizontal blanking end time (length) in ns. */
201 unsigned v_freq_hz; /* Vertical refresh rate to emulate. */
202} vga_retrace_s;
203
204#ifndef VBOX
205#define VGA_STATE_COMMON \
206 unsigned long vram_offset; \
207 unsigned int vram_size; \
208 uint32_t latch; \
209 uint8_t sr_index; \
210 uint8_t sr[256]; \
211 uint8_t gr_index; \
212 uint8_t gr[256]; \
213 uint8_t ar_index; \
214 uint8_t ar[21]; \
215 int ar_flip_flop; \
216 uint8_t cr_index; \
217 uint8_t cr[256]; /* CRT registers */ \
218 uint8_t msr; /* Misc Output Register */ \
219 uint8_t fcr; /* Feature Control Register */ \
220 uint8_t st00; /* status 0 */ \
221 uint8_t st01; /* status 1 */ \
222 uint8_t dac_state; \
223 uint8_t dac_sub_index; \
224 uint8_t dac_read_index; \
225 uint8_t dac_write_index; \
226 uint8_t dac_cache[3]; /* used when writing */ \
227 uint8_t palette[768]; \
228 int32_t bank_offset; \
229 int (*get_bpp)(struct VGAState *s); \
230 void (*get_offsets)(struct VGAState *s, \
231 uint32_t *pline_offset, \
232 uint32_t *pstart_addr, \
233 uint32_t *pline_compare); \
234 void (*get_resolution)(struct VGAState *s, \
235 int *pwidth, \
236 int *pheight); \
237 VGA_STATE_COMMON_BOCHS_VBE \
238 /* display refresh support */ \
239 DisplayState *ds; \
240 uint32_t font_offsets[2]; \
241 int graphic_mode; \
242 uint8_t shift_control; \
243 uint8_t double_scan; \
244 uint32_t line_offset; \
245 uint32_t line_compare; \
246 uint32_t start_addr; \
247 uint32_t plane_updated; \
248 uint8_t last_cw, last_ch; \
249 uint32_t last_width, last_height; /* in chars or pixels */ \
250 uint32_t last_scr_width, last_scr_height; /* in pixels */ \
251 uint8_t cursor_start, cursor_end; \
252 uint32_t cursor_offset; \
253 unsigned int (*rgb_to_pixel)(unsigned int r, \
254 unsigned int g, unsigned b); \
255 /* hardware mouse cursor support */ \
256 uint32_t invalidated_y_table[VGA_MAX_HEIGHT / 32]; \
257 void (*cursor_invalidate)(struct VGAState *s); \
258 void (*cursor_draw_line)(struct VGAState *s, uint8_t *d, int y); \
259 /* tell for each page if it has been updated since the last time */ \
260 uint32_t last_palette[256]; \
261 uint32_t last_ch_attr[CH_ATTR_SIZE]; /* XXX: make it dynamic */
262
263#else /* VBOX */
264
265/* bird: Since we've changed types, reordered members, done alignment
266 paddings and more, VGA_STATE_COMMON was added directly to the
267 struct to make it more readable and easier to handle. */
268
269struct VGAState;
270typedef int FNGETBPP(struct VGAState *s);
271typedef void FNGETOFFSETS(struct VGAState *s, uint32_t *pline_offset, uint32_t *pstart_addr, uint32_t *pline_compare);
272typedef void FNGETRESOLUTION(struct VGAState *s, int *pwidth, int *pheight);
273typedef unsigned int FNRGBTOPIXEL(unsigned int r, unsigned int g, unsigned b);
274typedef void FNCURSORINVALIDATE(struct VGAState *s);
275typedef void FNCURSORDRAWLINE(struct VGAState *s, uint8_t *d, int y);
276
277#endif /* VBOX */
278
279#ifdef VBOX_WITH_VDMA
280typedef struct VBOXVDMAHOST *PVBOXVDMAHOST;
281#endif
282
283/**
284 * The shared VGA state data.
285 */
286typedef struct VGAState
287{
288 uint32_t vram_size;
289 uint32_t latch;
290 uint8_t sr_index;
291 uint8_t sr[256];
292 uint8_t gr_index;
293 uint8_t gr[256];
294 uint8_t ar_index;
295 uint8_t ar[21];
296 int32_t ar_flip_flop;
297 uint8_t cr_index;
298 uint8_t cr[256]; /* CRT registers */
299 uint8_t msr; /* Misc Output Register */
300 uint8_t fcr; /* Feature Control Register */
301 uint8_t st00; /* status 0 */
302 uint8_t st01; /* status 1 */
303 uint8_t dac_state;
304 uint8_t dac_sub_index;
305 uint8_t dac_read_index;
306 uint8_t dac_write_index;
307 uint8_t dac_cache[3]; /* used when writing */
308 uint8_t palette[768];
309 int32_t bank_offset;
310 VGA_STATE_COMMON_BOCHS_VBE
311 /* display refresh support */
312 uint32_t font_offsets[2];
313 int32_t graphic_mode;
314 uint8_t shift_control;
315 uint8_t double_scan;
316 uint8_t padding1[2];
317 uint32_t line_offset;
318 uint32_t vga_addr_mask;
319 uint32_t padding1a;
320 uint32_t line_compare;
321 uint32_t start_addr;
322 uint32_t plane_updated;
323 uint8_t last_cw, last_ch;
324 uint8_t last_uline; \
325 bool last_blink; \
326 uint32_t last_width, last_height; /* in chars or pixels */
327 uint32_t last_scr_width, last_scr_height; /* in pixels */
328 uint32_t last_bpp;
329 uint8_t cursor_start, cursor_end;
330 bool last_cur_blink, last_chr_blink;
331 uint32_t cursor_offset;
332 /** hardware mouse cursor support */
333 uint32_t invalidated_y_table[VGA_MAX_HEIGHT / 32];
334 /** tell for each page if it has been updated since the last time */
335 uint32_t last_palette[256];
336 uint32_t last_ch_attr[CH_ATTR_SIZE]; /* XXX: make it dynamic */
337
338 /** end-of-common-state-marker */
339 uint32_t u32Marker;
340
341 /** Refresh timer handle - HC. */
342 TMTIMERHANDLE hRefreshTimer;
343
344#ifdef VBOX_WITH_VMSVGA
345 VMSVGASTATE svga;
346#endif
347
348 /** The number of monitors. */
349 uint32_t cMonitors;
350 /** Current refresh timer interval. */
351 uint32_t cMilliesRefreshInterval;
352 /** Bitmap tracking dirty pages. */
353 uint64_t bmDirtyBitmap[VGA_VRAM_MAX / GUEST_PAGE_SIZE / 64];
354 /** Bitmap tracking which VGA memory pages in the 0xa0000-0xbffff region has
355 * been remapped to allow direct access.
356 * @note It's quite possible that mapping in the 0xb0000-0xbffff isn't possible,
357 * but we're playing safe and cover the whole VGA MMIO region here. */
358 uint32_t bmPageRemappedVGA;
359
360 /** Flag indicating that there are dirty bits. This is used to optimize the handler resetting. */
361 bool fHasDirtyBits;
362 /** Whether to render the guest VRAM to the framebuffer memory. False only for some LFB modes. */
363 bool fRenderVRAM;
364 /** Whether 3D is enabled for the VM. */
365 bool f3DEnabled;
366 /** Set if state has been restored. */
367 bool fStateLoaded;
368 /** Flag whether to expose the legacy VGA interface to the guest. */
369 bool fLegacyVgaEnabled;
370#ifdef VBOX_WITH_VMSVGA
371 /* Whether the SVGA emulation is enabled or not. */
372 bool fVMSVGAEnabled;
373 bool fVMSVGA10;
374 bool fVMSVGAPciId;
375 bool fVMSVGAPciBarLayout;
376 /** Flag whether the SVGA3 interface is exposed to the guest. */
377 bool fVmSvga3;
378#else
379 bool afPadding4[5];
380#endif
381
382 struct {
383 uint32_t u32Padding1;
384 uint32_t iVRAM;
385#ifdef VBOX_WITH_VMSVGA
386 uint32_t iIO;
387 uint32_t iFIFO;
388#endif
389 } pciRegions;
390
391 /** The physical address the VRAM was assigned. */
392 RTGCPHYS GCPhysVRAM;
393 /** The critical section protect the instance data. */
394 PDMCRITSECT CritSect;
395
396 /* Keep track of ring 0 latched accesses to the VGA MMIO memory. */
397 uint64_t u64LastLatchedAccess;
398 uint32_t cLatchAccesses;
399 uint16_t uMaskLatchAccess;
400 uint16_t iMask;
401
402#ifdef VBE_BYTEWISE_IO
403 /** VBE read/write data/index flags */
404 uint8_t fReadVBEData;
405 uint8_t fWriteVBEData;
406 uint8_t fReadVBEIndex;
407 uint8_t fWriteVBEIndex;
408 /** VBE write data/index one byte buffer */
409 uint8_t cbWriteVBEData;
410 uint8_t cbWriteVBEIndex;
411 /** VBE Extra Data write address one byte buffer */
412 uint8_t cbWriteVBEExtraAddress;
413 uint8_t Padding5;
414#endif
415
416 /** Retrace emulation state */
417 bool fRealRetrace;
418 bool Padding6[HC_ARCH_BITS == 64 ? 7 : 3];
419 vga_retrace_s retrace_state;
420
421#ifdef VBOX_WITH_HGSMI
422 /** Base port in the assigned PCI I/O space. */
423 RTIOPORT IOPortBase;
424# ifdef VBOX_WITH_WDDM
425 uint8_t Padding10[2];
426 /** Specifies guest driver caps, i.e. whether it can handle IRQs from the
427 * adapter, the way it can handle async HGSMI command completion, etc. */
428 uint32_t fGuestCaps;
429 uint32_t fScanLineCfg;
430 uint32_t Padding11;
431# else
432 uint8_t Padding11[14];
433# endif
434
435 /** The critical section serializes the HGSMI IRQ setting/clearing. */
436 PDMCRITSECT CritSectIRQ;
437 /** VBVARaiseIRQ flags which were set when the guest was still processing previous IRQ. */
438 uint32_t fu32PendingGuestFlags;
439 uint32_t Padding12;
440#endif /* VBOX_WITH_HGSMI */
441
442 PDMLED Led3D;
443
444 struct {
445 volatile uint32_t cPending;
446 uint32_t Padding1;
447 union
448 {
449 RTLISTNODE PendingList;
450 /* make sure the structure sized cross different contexts correctly */
451 struct
452 {
453 R3PTRTYPE(void *) dummy1;
454 R3PTRTYPE(void *) dummy2;
455 } dummy;
456 };
457 } pendingVhwaCommands;
458
459 /** The MMIO handle of the legacy graphics buffer/regs at 0xa0000-0xbffff. */
460 PGMMMIO2HANDLE hMmioLegacy;
461
462 /** @name I/O ports for range 0x3c0-3cf.
463 * @{ */
464 IOMIOPORTHANDLE hIoPortAr;
465 IOMIOPORTHANDLE hIoPortMsrSt00;
466 IOMIOPORTHANDLE hIoPort3c3;
467 IOMIOPORTHANDLE hIoPortSr;
468 IOMIOPORTHANDLE hIoPortDac;
469 IOMIOPORTHANDLE hIoPortPos;
470 IOMIOPORTHANDLE hIoPortGr;
471 /** @} */
472
473 /** @name I/O ports for MDA 0x3b0-0x3bf (sparse)
474 * @{ */
475 IOMIOPORTHANDLE hIoPortMdaCrt;
476 IOMIOPORTHANDLE hIoPortMdaFcrSt;
477 /** @} */
478
479 /** @name I/O ports for CGA 0x3d0-0x3df (sparse)
480 * @{ */
481 IOMIOPORTHANDLE hIoPortCgaCrt;
482 IOMIOPORTHANDLE hIoPortCgaFcrSt;
483 /** @} */
484
485#ifdef VBOX_WITH_HGSMI
486 /** @name I/O ports for HGSMI 0x3b0-03b3 and 0x3d0-03d3 (ring-3 only)
487 * @{ */
488 IOMIOPORTHANDLE hIoPortHgsmiHost;
489 IOMIOPORTHANDLE hIoPortHgsmiGuest;
490 /** @} */
491#endif
492
493 /** @name I/O ports for Boch VBE 0x1ce-0x1cf
494 * @{ */
495 IOMIOPORTHANDLE hIoPortVbeIndex;
496 IOMIOPORTHANDLE hIoPortVbeData;
497 /** @} */
498
499 /** The BIOS printf I/O port. */
500 IOMIOPORTHANDLE hIoPortBios;
501 /** The VBE extra data I/O port. */
502 IOMIOPORTHANDLE hIoPortVbeExtra;
503 /** The logo command I/O port. */
504 IOMIOPORTHANDLE hIoPortCmdLogo;
505
506#ifdef VBOX_WITH_VMSVGA
507 /** VMSVGA: I/O port PCI region. */
508 IOMIOPORTHANDLE hIoPortVmSvga;
509 /** VMSVGA3: MMIO PCI region for the registers. */
510 IOMMMIOHANDLE hMmioSvga3;
511 /** VMSVGA: The MMIO2 handle of the FIFO PCI region. */
512 PGMMMIO2HANDLE hMmio2VmSvgaFifo;
513#endif
514 /** The MMIO2 handle of the VRAM. */
515 PGMMMIO2HANDLE hMmio2VRam;
516
517 STAMPROFILE StatRZMemoryRead;
518 STAMPROFILE StatR3MemoryRead;
519 STAMPROFILE StatRZMemoryWrite;
520 STAMPROFILE StatR3MemoryWrite;
521 STAMCOUNTER StatMapPage; /**< Counts IOMMmioMapMmio2Page calls. */
522 STAMCOUNTER StatMapReset; /**< Counts IOMMmioResetRegion calls. */
523 STAMCOUNTER StatUpdateDisp; /**< Counts vgaPortUpdateDisplay calls. */
524#ifdef VBOX_WITH_HGSMI
525 STAMCOUNTER StatHgsmiMdaCgaAccesses;
526#endif
527} VGAState;
528#ifdef VBOX
529/** VGA state. */
530typedef VGAState VGASTATE;
531/** Pointer to the VGA state. */
532typedef VGASTATE *PVGASTATE;
533AssertCompileMemberAlignment(VGASTATE, bank_offset, 8);
534AssertCompileMemberAlignment(VGASTATE, font_offsets, 8);
535AssertCompileMemberAlignment(VGASTATE, last_ch_attr, 8);
536AssertCompileMemberAlignment(VGASTATE, u32Marker, 8);
537AssertCompile(sizeof(uint64_t)/*bmPageMapBitmap*/ >= (_64K / GUEST_PAGE_SIZE / 8));
538#endif
539
540
541/**
542 * The VGA state data for ring-3 context.
543 */
544typedef struct VGASTATER3
545{
546 R3PTRTYPE(uint8_t *) pbVRam;
547 R3PTRTYPE(FNGETBPP *) get_bpp;
548 R3PTRTYPE(FNGETOFFSETS *) get_offsets;
549 R3PTRTYPE(FNGETRESOLUTION *) get_resolution;
550 R3PTRTYPE(FNRGBTOPIXEL *) rgb_to_pixel;
551 R3PTRTYPE(FNCURSORINVALIDATE *) cursor_invalidate;
552 R3PTRTYPE(FNCURSORDRAWLINE *) cursor_draw_line;
553
554 /** Pointer to the device instance.
555 * @note Only for getting our bearings in interface methods. */
556 PPDMDEVINSR3 pDevIns;
557#ifdef VBOX_WITH_HGSMI
558 R3PTRTYPE(PHGSMIINSTANCE) pHGSMI;
559#endif
560#ifdef VBOX_WITH_VDMA
561 R3PTRTYPE(PVBOXVDMAHOST) pVdma;
562#endif
563
564 /** LUN\#0: The display port base interface. */
565 PDMIBASE IBase;
566 /** LUN\#0: The display port interface. */
567 PDMIDISPLAYPORT IPort;
568 /** Status LUN: Leds interface. */
569 PDMILEDPORTS ILeds;
570
571 /** Pointer to base interface of the driver. */
572 R3PTRTYPE(PPDMIBASE) pDrvBase;
573 /** Pointer to display connector interface of the driver. */
574 R3PTRTYPE(PPDMIDISPLAYCONNECTOR) pDrv;
575
576 /** Status LUN: Partner of ILeds. */
577 R3PTRTYPE(PPDMILEDCONNECTORS) pLedsConnector;
578
579#ifdef VBOX_WITH_VMSVGA
580 /** The VMSVGA ring-3 state. */
581 VMSVGASTATER3 svga;
582#endif
583
584 /** The VGA BIOS ROM data. */
585 R3PTRTYPE(uint8_t *) pbVgaBios;
586 /** The size of the VGA BIOS ROM. */
587 uint64_t cbVgaBios;
588 /** The name of the VGA BIOS ROM file. */
589 R3PTRTYPE(char *) pszVgaBiosFile;
590
591 /** @name Logo data
592 * @{ */
593 /** Current logo data offset. */
594 uint32_t offLogoData;
595 /** The size of the BIOS logo data. */
596 uint32_t cbLogo;
597 /** Current logo command. */
598 uint16_t LogoCommand;
599 /** Bitmap width. */
600 uint16_t cxLogo;
601 /** Bitmap height. */
602 uint16_t cyLogo;
603 /** Bitmap planes. */
604 uint16_t cLogoPlanes;
605 /** Bitmap depth. */
606 uint16_t cLogoBits;
607 /** Bitmap compression. */
608 uint16_t LogoCompression;
609 /** Bitmap colors used. */
610 uint16_t cLogoUsedColors;
611 /** Palette size. */
612 uint16_t cLogoPalEntries;
613 /** Clear screen flag. */
614 uint8_t fLogoClearScreen;
615 bool fBootMenuInverse;
616 uint8_t Padding8[6];
617 /** Palette data. */
618 uint32_t au32LogoPalette[256];
619 /** The BIOS logo data. */
620 R3PTRTYPE(uint8_t *) pbLogo;
621 /** The name of the logo file. */
622 R3PTRTYPE(char *) pszLogoFile;
623 /** Bitmap image data. */
624 R3PTRTYPE(uint8_t *) pbLogoBitmap;
625 /** @} */
626
627 /** @name VBE extra data (modes)
628 * @{ */
629 /** The VBE BIOS extra data. */
630 R3PTRTYPE(uint8_t *) pbVBEExtraData;
631 /** The size of the VBE BIOS extra data. */
632 uint16_t cbVBEExtraData;
633 /** The VBE BIOS current memory address. */
634 uint16_t u16VBEExtraAddress;
635 uint16_t Padding7[2];
636 /** @} */
637
638} VGASTATER3;
639/** Pointer to the ring-3 VGA state. */
640typedef VGASTATER3 *PVGASTATER3;
641
642
643/**
644 * The VGA state data for ring-0 context.
645 */
646typedef struct VGASTATER0
647{
648 /** The R0 vram pointer. */
649 R0PTRTYPE(uint8_t *) pbVRam;
650#ifdef VBOX_WITH_VMSVGA
651 /** The VMSVGA ring-0 state. */
652 VMSVGASTATER0 svga;
653#endif
654} VGASTATER0;
655/** Pointer to the ring-0 VGA state. */
656typedef VGASTATER0 *PVGASTATER0;
657
658
659/**
660 * The VGA state data for raw-mode context.
661 */
662typedef struct VGASTATERC
663{
664 /** Pointer to the RC vram mapping. */
665 RCPTRTYPE(uint8_t *) pbVRam;
666} VGASTATERC;
667/** Pointer to the raw-mode VGA state. */
668typedef VGASTATERC *PVGASTATERC;
669
670
671/** The VGA state for the current context. */
672typedef CTX_SUFF(VGASTATE) VGASTATECC;
673/** Pointer to the VGA state for the current context. */
674typedef CTX_SUFF(PVGASTATE) PVGASTATECC;
675
676
677
678/** VBE Extra Data. */
679typedef VBEHeader VBEHEADER;
680/** Pointer to the VBE Extra Data. */
681typedef VBEHEADER *PVBEHEADER;
682
683#if !defined(VBOX) || defined(IN_RING3)
684static inline int c6_to_8(int v)
685{
686 int b;
687 v &= 0x3f;
688 b = v & 1;
689 return (v << 2) | (b << 1) | b;
690}
691#endif /* !VBOX || IN_RING3 */
692
693
694#ifdef VBOX_WITH_HGSMI
695int VBVAInit(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC);
696void VBVADestroy(PVGASTATECC pThisCC);
697int VBVAUpdateDisplay(PVGASTATE pThis, PVGASTATECC pThisCC);
698void VBVAReset(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC);
699void VBVAOnVBEChanged(PVGASTATE pThis, PVGASTATECC pThisCC);
700void VBVAOnResume(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC);
701
702bool VBVAIsPaused(PVGASTATECC pThisCC);
703#ifdef UNUSED_FUNCTION
704bool VBVAIsEnabled(PVGASTATECC pThisCC);
705#endif
706
707void VBVARaiseIrq(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC, uint32_t fFlags);
708
709int VBVAInfoScreen(PVGASTATE pThis, const VBVAINFOSCREEN RT_UNTRUSTED_VOLATILE_HOST *pScreen);
710#ifdef UNUSED_FUNCTION
711int VBVAGetInfoViewAndScreen(PVGASTATE pThis, PVGASTATECC pThisCC, uint32_t u32ViewIndex,
712 VBVAINFOVIEW *pView, VBVAINFOSCREEN *pScreen);
713#endif
714
715int vboxVBVASaveStateExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM);
716int vboxVBVALoadStateExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t u32Version);
717int vboxVBVALoadStateDone(PPDMDEVINS pDevIns);
718
719DECLCALLBACK(int) vbvaR3PortSendModeHint(PPDMIDISPLAYPORT pInterface, uint32_t cx, uint32_t cy, uint32_t cBPP,
720 uint32_t cDisplay, uint32_t dx, uint32_t dy, uint32_t fEnabled, uint32_t fNotifyGuest);
721
722# ifdef VBOX_WITH_VDMA
723typedef struct VBOXVDMAHOST *PVBOXVDMAHOST;
724int vboxVDMAConstruct(PVGASTATE pThis, PVGASTATECC pThisCC, uint32_t cPipeElements);
725void vboxVDMADestruct(PVBOXVDMAHOST pVdma);
726void vboxVDMAReset(PVBOXVDMAHOST pVdma);
727void vboxVDMAControl(PVBOXVDMAHOST pVdma, VBOXVDMA_CTL RT_UNTRUSTED_VOLATILE_GUEST *pCmd, uint32_t cbCmd);
728void vboxVDMACommand(PVBOXVDMAHOST pVdma, VBOXVDMACBUF_DR RT_UNTRUSTED_VOLATILE_GUEST *pCmd, uint32_t cbCmd);
729int vboxVDMASaveStateExecPrep(struct VBOXVDMAHOST *pVdma);
730int vboxVDMASaveStateExecDone(struct VBOXVDMAHOST *pVdma);
731int vboxVDMASaveStateExecPerform(PCPDMDEVHLPR3 pHlp, struct VBOXVDMAHOST *pVdma, PSSMHANDLE pSSM);
732int vboxVDMASaveLoadExecPerform(PCPDMDEVHLPR3 pHlp, struct VBOXVDMAHOST *pVdma, PSSMHANDLE pSSM, uint32_t u32Version);
733int vboxVDMASaveLoadDone(struct VBOXVDMAHOST *pVdma);
734# endif /* VBOX_WITH_VDMA */
735
736#endif /* VBOX_WITH_HGSMI */
737
738# ifdef VBOX_WITH_VMSVGA
739int vgaR3UnregisterVRAMHandler(PPDMDEVINS pDevIns, PVGASTATE pThis);
740int vgaR3RegisterVRAMHandler(PPDMDEVINS pDevIns, PVGASTATE pThis, uint64_t cbFrameBuffer);
741int vgaR3UpdateDisplay(PVGASTATE pThis, unsigned xStart, unsigned yStart, unsigned width, unsigned height);
742# endif
743
744#ifndef VBOX
745void vga_common_init(VGAState *s, DisplayState *ds, uint8_t *vga_ram_base,
746 unsigned long vga_ram_offset, int vga_ram_size);
747uint32_t vga_mem_readb(void *opaque, target_phys_addr_t addr);
748void vga_mem_writeb(void *opaque, target_phys_addr_t addr, uint32_t val);
749void vga_invalidate_scanlines(VGAState *s, int y1, int y2);
750
751void vga_draw_cursor_line_8(uint8_t *d1, const uint8_t *src1,
752 int poffset, int w,
753 unsigned int color0, unsigned int color1,
754 unsigned int color_xor);
755void vga_draw_cursor_line_16(uint8_t *d1, const uint8_t *src1,
756 int poffset, int w,
757 unsigned int color0, unsigned int color1,
758 unsigned int color_xor);
759void vga_draw_cursor_line_32(uint8_t *d1, const uint8_t *src1,
760 int poffset, int w,
761 unsigned int color0, unsigned int color1,
762 unsigned int color_xor);
763
764extern const uint8_t sr_mask[8];
765extern const uint8_t gr_mask[16];
766#endif /* !VBOX */
767
768#endif /* !VBOX_INCLUDED_SRC_Graphics_DevVGA_h */
769
Note: See TracBrowser for help on using the repository browser.

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