VirtualBox

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

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