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