1 | /* $Id: DevVGA.h 71146 2018-02-28 09:54:40Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * DevVGA - VBox VGA/VESA device, internal header.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2017 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | * --------------------------------------------------------------------
|
---|
17 | *
|
---|
18 | * This code is based on:
|
---|
19 | *
|
---|
20 | * QEMU internal VGA defines.
|
---|
21 | *
|
---|
22 | * Copyright (c) 2003-2004 Fabrice Bellard
|
---|
23 | *
|
---|
24 | * Permission is hereby granted, free of charge, to any person obtaining a copy
|
---|
25 | * of this software and associated documentation files (the "Software"), to deal
|
---|
26 | * in the Software without restriction, including without limitation the rights
|
---|
27 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
---|
28 | * copies of the Software, and to permit persons to whom the Software is
|
---|
29 | * furnished to do so, subject to the following conditions:
|
---|
30 | *
|
---|
31 | * The above copyright notice and this permission notice shall be included in
|
---|
32 | * all copies or substantial portions of the Software.
|
---|
33 | *
|
---|
34 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
---|
35 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
---|
36 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
---|
37 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
---|
38 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
---|
39 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
---|
40 | * THE SOFTWARE.
|
---|
41 | */
|
---|
42 |
|
---|
43 | /** Use VBE bytewise I/O. Only needed for Windows Longhorn/Vista betas and backwards compatibility. */
|
---|
44 | #define VBE_BYTEWISE_IO
|
---|
45 |
|
---|
46 | #ifdef VBOX
|
---|
47 | /** The default amount of VRAM. */
|
---|
48 | # define VGA_VRAM_DEFAULT (_4M)
|
---|
49 | /** The maximum amount of VRAM. Limited by VBOX_MAX_ALLOC_PAGE_COUNT. */
|
---|
50 | # define VGA_VRAM_MAX (256 * _1M)
|
---|
51 | /** The minimum amount of VRAM. */
|
---|
52 | # define VGA_VRAM_MIN (_1M)
|
---|
53 | #endif
|
---|
54 |
|
---|
55 | #include <VBoxVideoVBE.h>
|
---|
56 | #include <VBoxVideoVBEPrivate.h>
|
---|
57 |
|
---|
58 | #ifdef VBOX_WITH_HGSMI
|
---|
59 | # include "HGSMI/HGSMIHost.h"
|
---|
60 | #endif /* VBOX_WITH_HGSMI */
|
---|
61 | #include "DevVGASavedState.h"
|
---|
62 |
|
---|
63 | #ifdef VBOX_WITH_VMSVGA
|
---|
64 | # include "DevVGA-SVGA.h"
|
---|
65 | #endif
|
---|
66 |
|
---|
67 | #include <iprt/list.h>
|
---|
68 |
|
---|
69 | #define MSR_COLOR_EMULATION 0x01
|
---|
70 | #define MSR_PAGE_SELECT 0x20
|
---|
71 |
|
---|
72 | #define ST01_V_RETRACE 0x08
|
---|
73 | #define ST01_DISP_ENABLE 0x01
|
---|
74 |
|
---|
75 | /* bochs VBE support */
|
---|
76 | #define CONFIG_BOCHS_VBE
|
---|
77 |
|
---|
78 | #ifdef CONFIG_BOCHS_VBE
|
---|
79 |
|
---|
80 | /* Cross reference with <VBoxVideoVBE.h> */
|
---|
81 | #define VBE_DISPI_INDEX_NB_SAVED 0xb /* Old number of saved registers (vbe_regs array, see vga_load) */
|
---|
82 | #define VBE_DISPI_INDEX_NB 0xd /* Total number of VBE registers */
|
---|
83 |
|
---|
84 | #define VGA_STATE_COMMON_BOCHS_VBE \
|
---|
85 | uint16_t vbe_index; \
|
---|
86 | uint16_t vbe_regs[VBE_DISPI_INDEX_NB]; \
|
---|
87 | uint16_t alignment[2]; /* pad to 64 bits */ \
|
---|
88 | uint32_t vbe_start_addr; \
|
---|
89 | uint32_t vbe_line_offset; \
|
---|
90 | uint32_t vbe_bank_max;
|
---|
91 |
|
---|
92 | #else
|
---|
93 |
|
---|
94 | #define VGA_STATE_COMMON_BOCHS_VBE
|
---|
95 |
|
---|
96 | #endif /* !CONFIG_BOCHS_VBE */
|
---|
97 |
|
---|
98 | #define CH_ATTR_SIZE (160 * 100)
|
---|
99 | #define VGA_MAX_HEIGHT VBE_DISPI_MAX_YRES
|
---|
100 |
|
---|
101 | typedef struct vga_retrace_s {
|
---|
102 | unsigned frame_cclks; /* Character clocks per frame. */
|
---|
103 | unsigned frame_ns; /* Frame duration in ns. */
|
---|
104 | unsigned cclk_ns; /* Character clock duration in ns. */
|
---|
105 | unsigned vb_start; /* Vertical blanking start (scanline). */
|
---|
106 | unsigned vb_end; /* Vertical blanking end (scanline). */
|
---|
107 | unsigned vb_end_ns; /* Vertical blanking end time (length) in ns. */
|
---|
108 | unsigned vs_start; /* Vertical sync start (scanline). */
|
---|
109 | unsigned vs_end; /* Vertical sync end (scanline). */
|
---|
110 | unsigned vs_start_ns; /* Vertical sync start time in ns. */
|
---|
111 | unsigned vs_end_ns; /* Vertical sync end time in ns. */
|
---|
112 | unsigned h_total; /* Horizontal total (cclks per scanline). */
|
---|
113 | unsigned h_total_ns; /* Scanline duration in ns. */
|
---|
114 | unsigned hb_start; /* Horizontal blanking start (cclk). */
|
---|
115 | unsigned hb_end; /* Horizontal blanking end (cclk). */
|
---|
116 | unsigned hb_end_ns; /* Horizontal blanking end time (length) in ns. */
|
---|
117 | unsigned v_freq_hz; /* Vertical refresh rate to emulate. */
|
---|
118 | } vga_retrace_s;
|
---|
119 |
|
---|
120 | #ifndef VBOX
|
---|
121 | #define VGA_STATE_COMMON \
|
---|
122 | uint8_t *vram_ptr; \
|
---|
123 | unsigned long vram_offset; \
|
---|
124 | unsigned int vram_size; \
|
---|
125 | uint32_t latch; \
|
---|
126 | uint8_t sr_index; \
|
---|
127 | uint8_t sr[256]; \
|
---|
128 | uint8_t gr_index; \
|
---|
129 | uint8_t gr[256]; \
|
---|
130 | uint8_t ar_index; \
|
---|
131 | uint8_t ar[21]; \
|
---|
132 | int ar_flip_flop; \
|
---|
133 | uint8_t cr_index; \
|
---|
134 | uint8_t cr[256]; /* CRT registers */ \
|
---|
135 | uint8_t msr; /* Misc Output Register */ \
|
---|
136 | uint8_t fcr; /* Feature Control Register */ \
|
---|
137 | uint8_t st00; /* status 0 */ \
|
---|
138 | uint8_t st01; /* status 1 */ \
|
---|
139 | uint8_t dac_state; \
|
---|
140 | uint8_t dac_sub_index; \
|
---|
141 | uint8_t dac_read_index; \
|
---|
142 | uint8_t dac_write_index; \
|
---|
143 | uint8_t dac_cache[3]; /* used when writing */ \
|
---|
144 | uint8_t palette[768]; \
|
---|
145 | int32_t bank_offset; \
|
---|
146 | int (*get_bpp)(struct VGAState *s); \
|
---|
147 | void (*get_offsets)(struct VGAState *s, \
|
---|
148 | uint32_t *pline_offset, \
|
---|
149 | uint32_t *pstart_addr, \
|
---|
150 | uint32_t *pline_compare); \
|
---|
151 | void (*get_resolution)(struct VGAState *s, \
|
---|
152 | int *pwidth, \
|
---|
153 | int *pheight); \
|
---|
154 | VGA_STATE_COMMON_BOCHS_VBE \
|
---|
155 | /* display refresh support */ \
|
---|
156 | DisplayState *ds; \
|
---|
157 | uint32_t font_offsets[2]; \
|
---|
158 | int graphic_mode; \
|
---|
159 | uint8_t shift_control; \
|
---|
160 | uint8_t double_scan; \
|
---|
161 | uint32_t line_offset; \
|
---|
162 | uint32_t line_compare; \
|
---|
163 | uint32_t start_addr; \
|
---|
164 | uint32_t plane_updated; \
|
---|
165 | uint8_t last_cw, last_ch; \
|
---|
166 | uint32_t last_width, last_height; /* in chars or pixels */ \
|
---|
167 | uint32_t last_scr_width, last_scr_height; /* in pixels */ \
|
---|
168 | uint8_t cursor_start, cursor_end; \
|
---|
169 | uint32_t cursor_offset; \
|
---|
170 | unsigned int (*rgb_to_pixel)(unsigned int r, \
|
---|
171 | unsigned int g, unsigned b); \
|
---|
172 | /* hardware mouse cursor support */ \
|
---|
173 | uint32_t invalidated_y_table[VGA_MAX_HEIGHT / 32]; \
|
---|
174 | void (*cursor_invalidate)(struct VGAState *s); \
|
---|
175 | void (*cursor_draw_line)(struct VGAState *s, uint8_t *d, int y); \
|
---|
176 | /* tell for each page if it has been updated since the last time */ \
|
---|
177 | uint32_t last_palette[256]; \
|
---|
178 | uint32_t last_ch_attr[CH_ATTR_SIZE]; /* XXX: make it dynamic */
|
---|
179 |
|
---|
180 | #else /* VBOX */
|
---|
181 |
|
---|
182 | /* bird: Since we've changed types, reordered members, done alignment
|
---|
183 | paddings and more, VGA_STATE_COMMON was added directly to the
|
---|
184 | struct to make it more readable and easier to handle. */
|
---|
185 |
|
---|
186 | struct VGAState;
|
---|
187 | typedef int FNGETBPP(struct VGAState *s);
|
---|
188 | typedef void FNGETOFFSETS(struct VGAState *s, uint32_t *pline_offset, uint32_t *pstart_addr, uint32_t *pline_compare);
|
---|
189 | typedef void FNGETRESOLUTION(struct VGAState *s, int *pwidth, int *pheight);
|
---|
190 | typedef unsigned int FNRGBTOPIXEL(unsigned int r, unsigned int g, unsigned b);
|
---|
191 | typedef void FNCURSORINVALIDATE(struct VGAState *s);
|
---|
192 | typedef void FNCURSORDRAWLINE(struct VGAState *s, uint8_t *d, int y);
|
---|
193 |
|
---|
194 | #endif /* VBOX */
|
---|
195 |
|
---|
196 | #ifdef VBOX_WITH_VDMA
|
---|
197 | typedef struct VBOXVDMAHOST *PVBOXVDMAHOST;
|
---|
198 | #endif
|
---|
199 |
|
---|
200 | #ifdef VBOX_WITH_VIDEOHWACCEL
|
---|
201 | #define VBOX_VHWA_MAX_PENDING_COMMANDS 1000
|
---|
202 |
|
---|
203 | typedef struct _VBOX_VHWA_PENDINGCMD
|
---|
204 | {
|
---|
205 | RTLISTNODE Node;
|
---|
206 | PVBOXVHWACMD pCommand;
|
---|
207 | } VBOX_VHWA_PENDINGCMD;
|
---|
208 | #endif
|
---|
209 |
|
---|
210 |
|
---|
211 | typedef struct VGAState {
|
---|
212 | #ifndef VBOX
|
---|
213 | VGA_STATE_COMMON
|
---|
214 | #else /* VBOX */
|
---|
215 | R3PTRTYPE(uint8_t *) vram_ptrR3;
|
---|
216 | R3PTRTYPE(FNGETBPP *) get_bpp;
|
---|
217 | R3PTRTYPE(FNGETOFFSETS *) get_offsets;
|
---|
218 | R3PTRTYPE(FNGETRESOLUTION *) get_resolution;
|
---|
219 | R3PTRTYPE(FNRGBTOPIXEL *) rgb_to_pixel;
|
---|
220 | R3PTRTYPE(FNCURSORINVALIDATE *) cursor_invalidate;
|
---|
221 | R3PTRTYPE(FNCURSORDRAWLINE *) cursor_draw_line;
|
---|
222 | RTR3PTR R3PtrCmnAlignment;
|
---|
223 | uint32_t vram_size;
|
---|
224 | uint32_t latch;
|
---|
225 | uint8_t sr_index;
|
---|
226 | uint8_t sr[256];
|
---|
227 | uint8_t gr_index;
|
---|
228 | uint8_t gr[256];
|
---|
229 | uint8_t ar_index;
|
---|
230 | uint8_t ar[21];
|
---|
231 | int32_t ar_flip_flop;
|
---|
232 | uint8_t cr_index;
|
---|
233 | uint8_t cr[256]; /* CRT registers */
|
---|
234 | uint8_t msr; /* Misc Output Register */
|
---|
235 | uint8_t fcr; /* Feature Control Register */
|
---|
236 | uint8_t st00; /* status 0 */
|
---|
237 | uint8_t st01; /* status 1 */
|
---|
238 | uint8_t dac_state;
|
---|
239 | uint8_t dac_sub_index;
|
---|
240 | uint8_t dac_read_index;
|
---|
241 | uint8_t dac_write_index;
|
---|
242 | uint8_t dac_cache[3]; /* used when writing */
|
---|
243 | uint8_t palette[768];
|
---|
244 | int32_t bank_offset;
|
---|
245 | VGA_STATE_COMMON_BOCHS_VBE
|
---|
246 | /* display refresh support */
|
---|
247 | uint32_t font_offsets[2];
|
---|
248 | int32_t graphic_mode;
|
---|
249 | uint8_t shift_control;
|
---|
250 | uint8_t double_scan;
|
---|
251 | uint8_t padding1[2];
|
---|
252 | uint32_t line_offset;
|
---|
253 | uint32_t vga_addr_mask;
|
---|
254 | uint32_t padding1a;
|
---|
255 | uint32_t line_compare;
|
---|
256 | uint32_t start_addr;
|
---|
257 | uint32_t plane_updated;
|
---|
258 | uint8_t last_cw, last_ch, padding2[2];
|
---|
259 | uint32_t last_width, last_height; /* in chars or pixels */
|
---|
260 | uint32_t last_scr_width, last_scr_height; /* in pixels */
|
---|
261 | uint32_t last_bpp;
|
---|
262 | uint8_t cursor_start, cursor_end;
|
---|
263 | bool last_cur_blink, last_chr_blink;
|
---|
264 | uint32_t cursor_offset;
|
---|
265 | /* hardware mouse cursor support */
|
---|
266 | uint32_t invalidated_y_table[VGA_MAX_HEIGHT / 32];
|
---|
267 | /* tell for each page if it has been updated since the last time */
|
---|
268 | uint32_t last_palette[256];
|
---|
269 | uint32_t last_ch_attr[CH_ATTR_SIZE]; /* XXX: make it dynamic */
|
---|
270 |
|
---|
271 | /** end-of-common-state-marker */
|
---|
272 | uint32_t u32Marker;
|
---|
273 |
|
---|
274 | /** Pointer to the device instance - RC Ptr. */
|
---|
275 | PPDMDEVINSRC pDevInsRC;
|
---|
276 | /** Pointer to the GC vram mapping. */
|
---|
277 | RCPTRTYPE(uint8_t *) vram_ptrRC;
|
---|
278 | uint32_t Padding1;
|
---|
279 |
|
---|
280 | /** Pointer to the device instance - R3 Ptr. */
|
---|
281 | PPDMDEVINSR3 pDevInsR3;
|
---|
282 | # ifdef VBOX_WITH_HGSMI
|
---|
283 | R3PTRTYPE(PHGSMIINSTANCE) pHGSMI;
|
---|
284 | # endif
|
---|
285 | # ifdef VBOX_WITH_VDMA
|
---|
286 | R3PTRTYPE(PVBOXVDMAHOST) pVdma;
|
---|
287 | # endif
|
---|
288 | /** LUN\#0: The display port base interface. */
|
---|
289 | PDMIBASE IBase;
|
---|
290 | /** LUN\#0: The display port interface. */
|
---|
291 | PDMIDISPLAYPORT IPort;
|
---|
292 | # if defined(VBOX_WITH_HGSMI) && (defined(VBOX_WITH_VIDEOHWACCEL) || defined(VBOX_WITH_CRHGSMI))
|
---|
293 | /** LUN\#0: VBVA callbacks interface */
|
---|
294 | PDMIDISPLAYVBVACALLBACKS IVBVACallbacks;
|
---|
295 | # else
|
---|
296 | RTR3PTR Padding2;
|
---|
297 | # endif
|
---|
298 | /** Status LUN: Leds interface. */
|
---|
299 | PDMILEDPORTS ILeds;
|
---|
300 |
|
---|
301 | /** Pointer to base interface of the driver. */
|
---|
302 | R3PTRTYPE(PPDMIBASE) pDrvBase;
|
---|
303 | /** Pointer to display connector interface of the driver. */
|
---|
304 | R3PTRTYPE(PPDMIDISPLAYCONNECTOR) pDrv;
|
---|
305 |
|
---|
306 | /** Status LUN: Partner of ILeds. */
|
---|
307 | R3PTRTYPE(PPDMILEDCONNECTORS) pLedsConnector;
|
---|
308 |
|
---|
309 | /** Refresh timer handle - HC. */
|
---|
310 | PTMTIMERR3 RefreshTimer;
|
---|
311 |
|
---|
312 | /** Pointer to the device instance - R0 Ptr. */
|
---|
313 | PPDMDEVINSR0 pDevInsR0;
|
---|
314 | /** The R0 vram pointer... */
|
---|
315 | R0PTRTYPE(uint8_t *) vram_ptrR0;
|
---|
316 |
|
---|
317 | # ifdef VBOX_WITH_VMSVGA
|
---|
318 | VMSVGAState svga;
|
---|
319 | # endif
|
---|
320 |
|
---|
321 | /** The number of monitors. */
|
---|
322 | uint32_t cMonitors;
|
---|
323 | /** Current refresh timer interval. */
|
---|
324 | uint32_t cMilliesRefreshInterval;
|
---|
325 | /** Bitmap tracking dirty pages. */
|
---|
326 | uint32_t au32DirtyBitmap[VGA_VRAM_MAX / PAGE_SIZE / 32];
|
---|
327 |
|
---|
328 | /** Flag indicating that there are dirty bits. This is used to optimize the handler resetting. */
|
---|
329 | bool fHasDirtyBits;
|
---|
330 | /** LFB was updated flag. */
|
---|
331 | bool fLFBUpdated;
|
---|
332 | /** Indicates if the GC extensions are enabled or not. */
|
---|
333 | bool fGCEnabled;
|
---|
334 | /** Indicates if the R0 extensions are enabled or not. */
|
---|
335 | bool fR0Enabled;
|
---|
336 | /** Flag indicating that the VGA memory in the 0xa0000-0xbffff region has been remapped to allow direct access. */
|
---|
337 | bool fRemappedVGA;
|
---|
338 | /** Whether to render the guest VRAM to the framebuffer memory. False only for some LFB modes. */
|
---|
339 | bool fRenderVRAM;
|
---|
340 | /** Whether 3D is enabled for the VM. */
|
---|
341 | bool f3DEnabled;
|
---|
342 | # ifdef VBOX_WITH_VMSVGA
|
---|
343 | /* Whether the SVGA emulation is enabled or not. */
|
---|
344 | bool fVMSVGAEnabled;
|
---|
345 | bool Padding4[0+4];
|
---|
346 | # else
|
---|
347 | bool Padding4[1+4];
|
---|
348 | # endif
|
---|
349 |
|
---|
350 | /** Physical access type for the linear frame buffer dirty page tracking. */
|
---|
351 | PGMPHYSHANDLERTYPE hLfbAccessHandlerType;
|
---|
352 |
|
---|
353 | /** The physical address the VRAM was assigned. */
|
---|
354 | RTGCPHYS GCPhysVRAM;
|
---|
355 | /** The critical section protect the instance data. */
|
---|
356 | PDMCRITSECT CritSect;
|
---|
357 | /** The PCI device. */
|
---|
358 | PDMPCIDEV Dev;
|
---|
359 |
|
---|
360 | STAMPROFILE StatRZMemoryRead;
|
---|
361 | STAMPROFILE StatR3MemoryRead;
|
---|
362 | STAMPROFILE StatRZMemoryWrite;
|
---|
363 | STAMPROFILE StatR3MemoryWrite;
|
---|
364 | STAMCOUNTER StatMapPage; /**< Counts IOMMMIOMapMMIO2Page calls. */
|
---|
365 | STAMCOUNTER StatUpdateDisp; /**< Counts vgaPortUpdateDisplay calls. */
|
---|
366 |
|
---|
367 | /* Keep track of ring 0 latched accesses to the VGA MMIO memory. */
|
---|
368 | uint64_t u64LastLatchedAccess;
|
---|
369 | uint32_t cLatchAccesses;
|
---|
370 | uint16_t uMaskLatchAccess;
|
---|
371 | uint16_t iMask;
|
---|
372 |
|
---|
373 | # ifdef VBE_BYTEWISE_IO
|
---|
374 | /** VBE read/write data/index flags */
|
---|
375 | uint8_t fReadVBEData;
|
---|
376 | uint8_t fWriteVBEData;
|
---|
377 | uint8_t fReadVBEIndex;
|
---|
378 | uint8_t fWriteVBEIndex;
|
---|
379 | /** VBE write data/index one byte buffer */
|
---|
380 | uint8_t cbWriteVBEData;
|
---|
381 | uint8_t cbWriteVBEIndex;
|
---|
382 | /** VBE Extra Data write address one byte buffer */
|
---|
383 | uint8_t cbWriteVBEExtraAddress;
|
---|
384 | uint8_t Padding5;
|
---|
385 | # endif
|
---|
386 |
|
---|
387 | /** Retrace emulation state */
|
---|
388 | bool fRealRetrace;
|
---|
389 | bool Padding6[HC_ARCH_BITS == 64 ? 7 : 3];
|
---|
390 | vga_retrace_s retrace_state;
|
---|
391 |
|
---|
392 | /** The VBE BIOS extra data. */
|
---|
393 | R3PTRTYPE(uint8_t *) pbVBEExtraData;
|
---|
394 | /** The size of the VBE BIOS extra data. */
|
---|
395 | uint16_t cbVBEExtraData;
|
---|
396 | /** The VBE BIOS current memory address. */
|
---|
397 | uint16_t u16VBEExtraAddress;
|
---|
398 | uint16_t Padding7[2];
|
---|
399 |
|
---|
400 | /** The BIOS logo data. */
|
---|
401 | R3PTRTYPE(uint8_t *) pbLogo;
|
---|
402 | /** The name of the logo file. */
|
---|
403 | R3PTRTYPE(char *) pszLogoFile;
|
---|
404 | /** Bitmap image data. */
|
---|
405 | R3PTRTYPE(uint8_t *) pbLogoBitmap;
|
---|
406 | /** Current logo data offset. */
|
---|
407 | uint32_t offLogoData;
|
---|
408 | /** The size of the BIOS logo data. */
|
---|
409 | uint32_t cbLogo;
|
---|
410 | /** Current logo command. */
|
---|
411 | uint16_t LogoCommand;
|
---|
412 | /** Bitmap width. */
|
---|
413 | uint16_t cxLogo;
|
---|
414 | /** Bitmap height. */
|
---|
415 | uint16_t cyLogo;
|
---|
416 | /** Bitmap planes. */
|
---|
417 | uint16_t cLogoPlanes;
|
---|
418 | /** Bitmap depth. */
|
---|
419 | uint16_t cLogoBits;
|
---|
420 | /** Bitmap compression. */
|
---|
421 | uint16_t LogoCompression;
|
---|
422 | /** Bitmap colors used. */
|
---|
423 | uint16_t cLogoUsedColors;
|
---|
424 | /** Palette size. */
|
---|
425 | uint16_t cLogoPalEntries;
|
---|
426 | /** Clear screen flag. */
|
---|
427 | uint8_t fLogoClearScreen;
|
---|
428 | bool fBootMenuInverse;
|
---|
429 | uint8_t Padding8[6];
|
---|
430 | /** Palette data. */
|
---|
431 | uint32_t au32LogoPalette[256];
|
---|
432 |
|
---|
433 | /** The VGA BIOS ROM data. */
|
---|
434 | R3PTRTYPE(uint8_t *) pbVgaBios;
|
---|
435 | /** The size of the VGA BIOS ROM. */
|
---|
436 | uint64_t cbVgaBios;
|
---|
437 | /** The name of the VGA BIOS ROM file. */
|
---|
438 | R3PTRTYPE(char *) pszVgaBiosFile;
|
---|
439 | # if HC_ARCH_BITS == 32
|
---|
440 | uint32_t Padding9;
|
---|
441 | # endif
|
---|
442 |
|
---|
443 | # ifdef VBOX_WITH_HGSMI
|
---|
444 | /** Base port in the assigned PCI I/O space. */
|
---|
445 | RTIOPORT IOPortBase;
|
---|
446 | # ifdef VBOX_WITH_WDDM
|
---|
447 | uint8_t Padding10[2];
|
---|
448 | /** Specifies guest driver caps, i.e. whether it can handle IRQs from the
|
---|
449 | * adapter, the way it can handle async HGSMI command completion, etc. */
|
---|
450 | uint32_t fGuestCaps;
|
---|
451 | uint32_t fScanLineCfg;
|
---|
452 | uint32_t fHostCursorCapabilities;
|
---|
453 | # else
|
---|
454 | uint8_t Padding11[14];
|
---|
455 | # endif
|
---|
456 |
|
---|
457 | /** The critical section serializes the HGSMI IRQ setting/clearing. */
|
---|
458 | PDMCRITSECT CritSectIRQ;
|
---|
459 | /** VBVARaiseIRQ flags which were set when the guest was still processing previous IRQ. */
|
---|
460 | uint32_t fu32PendingGuestFlags;
|
---|
461 | uint32_t Padding12;
|
---|
462 | # endif /* VBOX_WITH_HGSMI */
|
---|
463 |
|
---|
464 | PDMLED Led3D;
|
---|
465 |
|
---|
466 | struct {
|
---|
467 | volatile uint32_t cPending;
|
---|
468 | uint32_t Padding1;
|
---|
469 | union
|
---|
470 | {
|
---|
471 | RTLISTNODE PendingList;
|
---|
472 | /* make sure the structure sized cross different contexts correctly */
|
---|
473 | struct
|
---|
474 | {
|
---|
475 | R3PTRTYPE(void *) dummy1;
|
---|
476 | R3PTRTYPE(void *) dummy2;
|
---|
477 | } dummy;
|
---|
478 | };
|
---|
479 | } pendingVhwaCommands;
|
---|
480 | #endif /* VBOX */
|
---|
481 | } VGAState;
|
---|
482 | #ifdef VBOX
|
---|
483 | /** VGA state. */
|
---|
484 | typedef VGAState VGASTATE;
|
---|
485 | /** Pointer to the VGA state. */
|
---|
486 | typedef VGASTATE *PVGASTATE;
|
---|
487 | AssertCompileMemberAlignment(VGASTATE, bank_offset, 8);
|
---|
488 | AssertCompileMemberAlignment(VGASTATE, font_offsets, 8);
|
---|
489 | AssertCompileMemberAlignment(VGASTATE, last_ch_attr, 8);
|
---|
490 | AssertCompileMemberAlignment(VGASTATE, u32Marker, 8);
|
---|
491 | #endif
|
---|
492 |
|
---|
493 | /** VBE Extra Data. */
|
---|
494 | typedef VBEHeader VBEHEADER;
|
---|
495 | /** Pointer to the VBE Extra Data. */
|
---|
496 | typedef VBEHEADER *PVBEHEADER;
|
---|
497 |
|
---|
498 | #if !defined(VBOX) || defined(IN_RING3)
|
---|
499 | static inline int c6_to_8(int v)
|
---|
500 | {
|
---|
501 | int b;
|
---|
502 | v &= 0x3f;
|
---|
503 | b = v & 1;
|
---|
504 | return (v << 2) | (b << 1) | b;
|
---|
505 | }
|
---|
506 | #endif /* !VBOX || IN_RING3 */
|
---|
507 |
|
---|
508 |
|
---|
509 | #ifdef VBOX_WITH_HGSMI
|
---|
510 | int VBVAInit (PVGASTATE pVGAState);
|
---|
511 | void VBVADestroy (PVGASTATE pVGAState);
|
---|
512 | int VBVAUpdateDisplay (PVGASTATE pVGAState);
|
---|
513 | void VBVAReset (PVGASTATE pVGAState);
|
---|
514 | void VBVAPause (PVGASTATE pVGAState, bool fPause);
|
---|
515 | void VBVAOnVBEChanged(PVGASTATE pVGAState);
|
---|
516 | void VBVAOnResume(PVGASTATE pThis);
|
---|
517 |
|
---|
518 | bool VBVAIsPaused(PVGASTATE pVGAState);
|
---|
519 | bool VBVAIsEnabled(PVGASTATE pVGAState);
|
---|
520 |
|
---|
521 | void VBVARaiseIrq(PVGASTATE pVGAState, uint32_t fFlags);
|
---|
522 |
|
---|
523 | int VBVAInfoView(PVGASTATE pVGAState, const VBVAINFOVIEW *pView);
|
---|
524 | int VBVAInfoScreen(PVGASTATE pVGAState, const VBVAINFOSCREEN *pScreen);
|
---|
525 | int VBVAGetInfoViewAndScreen(PVGASTATE pVGAState, uint32_t u32ViewIndex, VBVAINFOVIEW *pView, VBVAINFOSCREEN *pScreen);
|
---|
526 |
|
---|
527 | /* @return host-guest flags that were set on reset
|
---|
528 | * this allows the caller to make further cleaning when needed,
|
---|
529 | * e.g. reset the IRQ */
|
---|
530 | uint32_t HGSMIReset(PHGSMIINSTANCE pIns);
|
---|
531 |
|
---|
532 | # ifdef VBOX_WITH_VIDEOHWACCEL
|
---|
533 | DECLCALLBACK(int) vbvaVHWACommandCompleteAsync(PPDMIDISPLAYVBVACALLBACKS pInterface, PVBOXVHWACMD pCmd);
|
---|
534 | int vbvaVHWAConstruct(PVGASTATE pVGAState);
|
---|
535 | int vbvaVHWAReset(PVGASTATE pVGAState);
|
---|
536 |
|
---|
537 | void vbvaTimerCb(PVGASTATE pVGAState);
|
---|
538 |
|
---|
539 | int vboxVBVASaveStatePrep(PPDMDEVINS pDevIns);
|
---|
540 | int vboxVBVASaveStateDone(PPDMDEVINS pDevIns);
|
---|
541 | # endif
|
---|
542 |
|
---|
543 | #ifdef VBOX_WITH_HGSMI
|
---|
544 | #define PPDMIDISPLAYVBVACALLBACKS_2_PVGASTATE(_pcb) ( (PVGASTATE)((uint8_t *)(_pcb) - RT_OFFSETOF(VGASTATE, IVBVACallbacks)) )
|
---|
545 | #endif
|
---|
546 |
|
---|
547 | # ifdef VBOX_WITH_CRHGSMI
|
---|
548 | DECLCALLBACK(int) vboxVDMACrHgsmiCommandCompleteAsync(PPDMIDISPLAYVBVACALLBACKS pInterface,
|
---|
549 | PVBOXVDMACMD_CHROMIUM_CMD pCmd, int rc);
|
---|
550 | DECLCALLBACK(int) vboxVDMACrHgsmiControlCompleteAsync(PPDMIDISPLAYVBVACALLBACKS pInterface,
|
---|
551 | PVBOXVDMACMD_CHROMIUM_CTL pCmd, int rc);
|
---|
552 | DECLCALLBACK(int) vboxCmdVBVACmdHostCtl(PPDMIDISPLAYVBVACALLBACKS pInterface,
|
---|
553 | struct VBOXCRCMDCTL* pCmd, uint32_t cbCmd,
|
---|
554 | PFNCRCTLCOMPLETION pfnCompletion,
|
---|
555 | void *pvCompletion);
|
---|
556 | DECLCALLBACK(int) vboxCmdVBVACmdHostCtlSync(PPDMIDISPLAYVBVACALLBACKS pInterface,
|
---|
557 | struct VBOXCRCMDCTL* pCmd, uint32_t cbCmd);
|
---|
558 | # endif
|
---|
559 |
|
---|
560 | int vboxVBVASaveStateExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM);
|
---|
561 | int vboxVBVALoadStateExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t u32Version);
|
---|
562 | int vboxVBVALoadStateDone(PPDMDEVINS pDevIns);
|
---|
563 |
|
---|
564 | DECLCALLBACK(int) vgaUpdateDisplayAll(PVGASTATE pThis, bool fFailOnResize);
|
---|
565 | DECLCALLBACK(int) vbvaPortSendModeHint(PPDMIDISPLAYPORT pInterface, uint32_t cx,
|
---|
566 | uint32_t cy, uint32_t cBPP,
|
---|
567 | uint32_t cDisplay, uint32_t dx,
|
---|
568 | uint32_t dy, uint32_t fEnabled,
|
---|
569 | uint32_t fNotifyGuest);
|
---|
570 | DECLCALLBACK(void) vbvaPortReportHostCursorCapabilities(PPDMIDISPLAYPORT pInterface, uint32_t fCapabilitiesAdded,
|
---|
571 | uint32_t fCapabilitiesRemoved);
|
---|
572 | DECLCALLBACK(void) vbvaPortReportHostCursorPosition(PPDMIDISPLAYPORT pInterface, uint32_t x, uint32_t y);
|
---|
573 |
|
---|
574 | # ifdef VBOX_WITH_VDMA
|
---|
575 | typedef struct VBOXVDMAHOST *PVBOXVDMAHOST;
|
---|
576 | int vboxVDMAConstruct(PVGASTATE pVGAState, uint32_t cPipeElements);
|
---|
577 | void vboxVDMADestruct(PVBOXVDMAHOST pVdma);
|
---|
578 | void vboxVDMAReset(PVBOXVDMAHOST pVdma);
|
---|
579 | void vboxVDMAControl(PVBOXVDMAHOST pVdma, PVBOXVDMA_CTL pCmd, uint32_t cbCmd);
|
---|
580 | void vboxVDMACommand(PVBOXVDMAHOST pVdma, PVBOXVDMACBUF_DR pCmd, uint32_t cbCmd);
|
---|
581 | int vboxVDMASaveStateExecPrep(struct VBOXVDMAHOST *pVdma);
|
---|
582 | int vboxVDMASaveStateExecDone(struct VBOXVDMAHOST *pVdma);
|
---|
583 | int vboxVDMASaveStateExecPerform(struct VBOXVDMAHOST *pVdma, PSSMHANDLE pSSM);
|
---|
584 | int vboxVDMASaveLoadExecPerform(struct VBOXVDMAHOST *pVdma, PSSMHANDLE pSSM, uint32_t u32Version);
|
---|
585 | int vboxVDMASaveLoadDone(struct VBOXVDMAHOST *pVdma);
|
---|
586 | # endif /* VBOX_WITH_VDMA */
|
---|
587 |
|
---|
588 | # ifdef VBOX_WITH_CRHGSMI
|
---|
589 | int vboxCmdVBVACmdSubmit(PVGASTATE pVGAState);
|
---|
590 | int vboxCmdVBVACmdFlush(PVGASTATE pVGAState);
|
---|
591 | int vboxCmdVBVACmdCtl(PVGASTATE pVGAState, VBOXCMDVBVA_CTL *pCtl, uint32_t cbCtl);
|
---|
592 | void vboxCmdVBVATimerRefresh(PVGASTATE pVGAState);
|
---|
593 | bool vboxCmdVBVAIsEnabled(PVGASTATE pVGAState);
|
---|
594 | # endif /* VBOX_WITH_CRHGSMI */
|
---|
595 | #endif /* VBOX_WITH_HGSMI */
|
---|
596 |
|
---|
597 | # ifdef VBOX_WITH_VMSVGA
|
---|
598 | int vgaR3RegisterVRAMHandler(PVGASTATE pVGAState, uint64_t cbFrameBuffer);
|
---|
599 | int vgaR3UnregisterVRAMHandler(PVGASTATE pVGAState);
|
---|
600 | int vgaR3UpdateDisplay(PVGASTATE pVGAState, unsigned xStart, unsigned yStart, unsigned width, unsigned height);
|
---|
601 | # endif
|
---|
602 |
|
---|
603 | #ifndef VBOX
|
---|
604 | void vga_common_init(VGAState *s, DisplayState *ds, uint8_t *vga_ram_base,
|
---|
605 | unsigned long vga_ram_offset, int vga_ram_size);
|
---|
606 | uint32_t vga_mem_readb(void *opaque, target_phys_addr_t addr);
|
---|
607 | void vga_mem_writeb(void *opaque, target_phys_addr_t addr, uint32_t val);
|
---|
608 | void vga_invalidate_scanlines(VGAState *s, int y1, int y2);
|
---|
609 |
|
---|
610 | void vga_draw_cursor_line_8(uint8_t *d1, const uint8_t *src1,
|
---|
611 | int poffset, int w,
|
---|
612 | unsigned int color0, unsigned int color1,
|
---|
613 | unsigned int color_xor);
|
---|
614 | void vga_draw_cursor_line_16(uint8_t *d1, const uint8_t *src1,
|
---|
615 | int poffset, int w,
|
---|
616 | unsigned int color0, unsigned int color1,
|
---|
617 | unsigned int color_xor);
|
---|
618 | void vga_draw_cursor_line_32(uint8_t *d1, const uint8_t *src1,
|
---|
619 | int poffset, int w,
|
---|
620 | unsigned int color0, unsigned int color1,
|
---|
621 | unsigned int color_xor);
|
---|
622 |
|
---|
623 | extern const uint8_t sr_mask[8];
|
---|
624 | extern const uint8_t gr_mask[16];
|
---|
625 | #endif /* !VBOX */
|
---|
626 |
|
---|