VirtualBox

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

Last change on this file since 13429 was 13429, checked in by vboxsync, 16 years ago

Correction

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 19.8 KB
Line 
1/* $Id: DevVGA.h 13429 2008-10-21 10:02:48Z vboxsync $ */
2/** @file
3 * DevVGA - VBox VGA/VESA device, internal header.
4 */
5
6/*
7 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 * --------------------------------------------------------------------
21 *
22 * This code is based on:
23 *
24 * QEMU internal VGA defines.
25 *
26 * Copyright (c) 2003-2004 Fabrice Bellard
27 *
28 * Permission is hereby granted, free of charge, to any person obtaining a copy
29 * of this software and associated documentation files (the "Software"), to deal
30 * in the Software without restriction, including without limitation the rights
31 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
32 * copies of the Software, and to permit persons to whom the Software is
33 * furnished to do so, subject to the following conditions:
34 *
35 * The above copyright notice and this permission notice shall be included in
36 * all copies or substantial portions of the Software.
37 *
38 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
39 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
40 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
41 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
42 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
43 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
44 * THE SOFTWARE.
45 */
46
47#define MSR_COLOR_EMULATION 0x01
48#define MSR_PAGE_SELECT 0x20
49
50#define ST01_V_RETRACE 0x08
51#define ST01_DISP_ENABLE 0x01
52
53/* bochs VBE support */
54#define CONFIG_BOCHS_VBE
55
56#ifdef VBOX
57#define VBE_DISPI_MAX_XRES 16384
58#define VBE_DISPI_MAX_YRES 16384
59#else
60#define VBE_DISPI_MAX_XRES 1600
61#define VBE_DISPI_MAX_YRES 1200
62#endif
63#define VBE_DISPI_MAX_BPP 32
64
65#define VBE_DISPI_INDEX_ID 0x0
66#define VBE_DISPI_INDEX_XRES 0x1
67#define VBE_DISPI_INDEX_YRES 0x2
68#define VBE_DISPI_INDEX_BPP 0x3
69#define VBE_DISPI_INDEX_ENABLE 0x4
70#define VBE_DISPI_INDEX_BANK 0x5
71#define VBE_DISPI_INDEX_VIRT_WIDTH 0x6
72#define VBE_DISPI_INDEX_VIRT_HEIGHT 0x7
73#define VBE_DISPI_INDEX_X_OFFSET 0x8
74#define VBE_DISPI_INDEX_Y_OFFSET 0x9
75#define VBE_DISPI_INDEX_VBOX_VIDEO 0xa
76#define VBE_DISPI_INDEX_NB 0xb
77
78#define VBE_DISPI_ID0 0xB0C0
79#define VBE_DISPI_ID1 0xB0C1
80#define VBE_DISPI_ID2 0xB0C2
81#define VBE_DISPI_ID3 0xB0C3
82#define VBE_DISPI_ID4 0xB0C4
83
84#ifdef VBOX
85/* The VBOX interface id. Indicates support for VBE_DISPI_INDEX_VBOX_VIDEO. */
86#define VBE_DISPI_ID_VBOX_VIDEO 0xBE00
87#endif /* VBOX */
88
89#define VBE_DISPI_DISABLED 0x00
90#define VBE_DISPI_ENABLED 0x01
91#define VBE_DISPI_GETCAPS 0x02
92#define VBE_DISPI_8BIT_DAC 0x20
93#define VBE_DISPI_LFB_ENABLED 0x40
94#define VBE_DISPI_NOCLEARMEM 0x80
95
96#define VBE_DISPI_LFB_PHYSICAL_ADDRESS 0xE0000000
97
98#ifdef CONFIG_BOCHS_VBE
99
100#define VGA_STATE_COMMON_BOCHS_VBE \
101 uint16_t vbe_index; \
102 uint16_t vbe_regs[VBE_DISPI_INDEX_NB]; \
103 uint32_t vbe_start_addr; \
104 uint32_t vbe_line_offset; \
105 uint32_t vbe_bank_mask;
106
107#else
108
109#define VGA_STATE_COMMON_BOCHS_VBE
110
111#endif /* !CONFIG_BOCHS_VBE */
112
113#define CH_ATTR_SIZE (160 * 100)
114#define VGA_MAX_HEIGHT VBE_DISPI_MAX_YRES
115
116#ifndef VBOX
117#define VGA_STATE_COMMON \
118 uint8_t *vram_ptr; \
119 unsigned long vram_offset; \
120 unsigned int vram_size; \
121 uint32_t latch; \
122 uint8_t sr_index; \
123 uint8_t sr[256]; \
124 uint8_t gr_index; \
125 uint8_t gr[256]; \
126 uint8_t ar_index; \
127 uint8_t ar[21]; \
128 int ar_flip_flop; \
129 uint8_t cr_index; \
130 uint8_t cr[256]; /* CRT registers */ \
131 uint8_t msr; /* Misc Output Register */ \
132 uint8_t fcr; /* Feature Control Register */ \
133 uint8_t st00; /* status 0 */ \
134 uint8_t st01; /* status 1 */ \
135 uint8_t dac_state; \
136 uint8_t dac_sub_index; \
137 uint8_t dac_read_index; \
138 uint8_t dac_write_index; \
139 uint8_t dac_cache[3]; /* used when writing */ \
140 uint8_t palette[768]; \
141 int32_t bank_offset; \
142 int (*get_bpp)(struct VGAState *s); \
143 void (*get_offsets)(struct VGAState *s, \
144 uint32_t *pline_offset, \
145 uint32_t *pstart_addr, \
146 uint32_t *pline_compare); \
147 void (*get_resolution)(struct VGAState *s, \
148 int *pwidth, \
149 int *pheight); \
150 VGA_STATE_COMMON_BOCHS_VBE \
151 /* display refresh support */ \
152 DisplayState *ds; \
153 uint32_t font_offsets[2]; \
154 int graphic_mode; \
155 uint8_t shift_control; \
156 uint8_t double_scan; \
157 uint32_t line_offset; \
158 uint32_t line_compare; \
159 uint32_t start_addr; \
160 uint32_t plane_updated; \
161 uint8_t last_cw, last_ch; \
162 uint32_t last_width, last_height; /* in chars or pixels */ \
163 uint32_t last_scr_width, last_scr_height; /* in pixels */ \
164 uint8_t cursor_start, cursor_end; \
165 uint32_t cursor_offset; \
166 unsigned int (*rgb_to_pixel)(unsigned int r, \
167 unsigned int g, unsigned b); \
168 /* hardware mouse cursor support */ \
169 uint32_t invalidated_y_table[VGA_MAX_HEIGHT / 32]; \
170 void (*cursor_invalidate)(struct VGAState *s); \
171 void (*cursor_draw_line)(struct VGAState *s, uint8_t *d, int y); \
172 /* tell for each page if it has been updated since the last time */ \
173 uint32_t last_palette[256]; \
174 uint32_t last_ch_attr[CH_ATTR_SIZE]; /* XXX: make it dynamic */
175
176#else /* VBOX */
177
178struct VGAState;
179typedef int FNGETBPP(struct VGAState *s);
180typedef void FNGETOFFSETS(struct VGAState *s, uint32_t *pline_offset, uint32_t *pstart_addr, uint32_t *pline_compare);
181typedef void FNGETRESOLUTION(struct VGAState *s, int *pwidth, int *pheight);
182typedef unsigned int FNRGBTOPIXEL(unsigned int r, unsigned int g, unsigned b);
183typedef void FNCURSORINVALIDATE(struct VGAState *s);
184typedef void FNCURSORDRAWLINE(struct VGAState *s, uint8_t *d, int y);
185
186/* bird: vram_offset have been remove, function pointers declared external,
187 some type changes, and some padding have been added. */
188#define VGA_STATE_COMMON \
189 R3PTRTYPE(uint8_t *) vram_ptrR3; \
190 uint32_t vram_size; \
191 uint32_t latch; \
192 uint8_t sr_index; \
193 uint8_t sr[256]; \
194 uint8_t gr_index; \
195 uint8_t gr[256]; \
196 uint8_t ar_index; \
197 uint8_t ar[21]; \
198 int32_t ar_flip_flop; \
199 uint8_t cr_index; \
200 uint8_t cr[256]; /* CRT registers */ \
201 uint8_t msr; /* Misc Output Register */ \
202 uint8_t fcr; /* Feature Control Register */ \
203 uint8_t st00; /* status 0 */ \
204 uint8_t st01; /* status 1 */ \
205 uint8_t dac_state; \
206 uint8_t dac_sub_index; \
207 uint8_t dac_read_index; \
208 uint8_t dac_write_index; \
209 uint8_t dac_cache[3]; /* used when writing */ \
210 uint8_t palette[768]; \
211 int32_t bank_offset; \
212 int32_t padding0; \
213 R3PTRTYPE(FNGETBPP *) get_bpp; \
214 R3PTRTYPE(FNGETOFFSETS *) get_offsets; \
215 R3PTRTYPE(FNGETRESOLUTION *) get_resolution; \
216 VGA_STATE_COMMON_BOCHS_VBE \
217 /* display refresh support */ \
218 uint32_t font_offsets[2]; \
219 int32_t graphic_mode; \
220 uint8_t shift_control; \
221 uint8_t double_scan; \
222 uint8_t padding1[2]; \
223 uint32_t line_offset; \
224 uint32_t line_compare; \
225 uint32_t start_addr; \
226 uint32_t plane_updated; \
227 uint8_t last_cw, last_ch, padding2[2]; \
228 uint32_t last_width, last_height; /* in chars or pixels */ \
229 uint32_t last_scr_width, last_scr_height; /* in pixels */ \
230 uint32_t last_bpp; \
231 uint8_t cursor_start, cursor_end, padding3[2]; \
232 uint32_t cursor_offset; \
233 uint32_t padding4; \
234 R3PTRTYPE(FNRGBTOPIXEL *) rgb_to_pixel; \
235 /* hardware mouse cursor support */ \
236 uint32_t invalidated_y_table[VGA_MAX_HEIGHT / 32]; \
237 R3PTRTYPE(FNCURSORINVALIDATE *) cursor_invalidate; \
238 R3PTRTYPE(FNCURSORDRAWLINE *) cursor_draw_line; \
239 /* tell for each page if it has been updated since the last time */ \
240 uint32_t last_palette[256]; \
241 uint32_t last_ch_attr[CH_ATTR_SIZE]; /* XXX: make it dynamic */
242
243#endif /* VBOX */
244
245typedef struct VGAState {
246 VGA_STATE_COMMON
247#ifdef VBOX
248 /** end-of-common-state-marker */
249 uint32_t u32Marker;
250 /** The physical address the VRAM was assigned. */
251 RTGCPHYS32 GCPhysVRAM;
252 /** The R0 vram pointer... */
253 R0PTRTYPE(uint8_t *) vram_ptrR0;
254 /** Pointer to the GC vram mapping. */
255 RCPTRTYPE(uint8_t *) vram_ptrRC;
256 /** LFB was updated flag. */
257 bool fLFBUpdated;
258 /** Indicates if the GC extensions are enabled or not. */
259 bool fGCEnabled;
260 /** Indicates if the R0 extensions are enabled or not. */
261 bool fR0Enabled;
262 /** Flag indicating that there are dirty bits. This is used to optimize the handler resetting. */
263 bool fHasDirtyBits;
264 /** Flag indicating that the VGA memory in the 0xa0000-0xbffff region has been remapped to allow direct access. */
265 bool fRemappedVGA;
266 /** Whether to render the guest VRAM to the framebuffer memory. False only for some LFB modes. */
267 bool fRenderVRAM;
268 bool padding9[2];
269
270 /** Pointer to vgaGCLFBAccessHandler(). */
271 RTRCPTR RCPtrLFBHandler;
272 /** Bitmap tracking dirty pages. */
273 uint32_t au32DirtyBitmap[VGA_VRAM_MAX / PAGE_SIZE / 32];
274 /** Pointer to the device instance - RC Ptr. */
275 PPDMDEVINSRC pDevInsRC;
276 /** Pointer to the device instance - R3 Ptr. */
277 PPDMDEVINSR3 pDevInsR3;
278 /** Pointer to the device instance - R0 Ptr. */
279 PPDMDEVINSR0 pDevInsR0;
280
281 /** The display port base interface. */
282 PDMIBASE Base;
283 /** The display port interface. */
284 PDMIDISPLAYPORT Port;
285 /** Pointer to base interface of the driver. */
286 R3PTRTYPE(PPDMIBASE) pDrvBase;
287 /** Pointer to display connector interface of the driver. */
288 R3PTRTYPE(PPDMIDISPLAYCONNECTOR) pDrv;
289 /** Refresh timer handle - HC. */
290 PTMTIMERR3 RefreshTimer;
291 /** Current refresh timer interval. */
292 uint32_t cMilliesRefreshInterval;
293
294 /** The PCI device. */
295 PCIDEVICE Dev;
296
297 STAMPROFILE StatGCMemoryRead;
298 STAMPROFILE StatGCMemoryWrite;
299 STAMPROFILE StatGCIOPortRead;
300 STAMPROFILE StatGCIOPortWrite;
301
302#ifdef VBE_BYTEWISE_IO
303 /** VBE read/write data/index flags */
304 uint8_t fReadVBEData;
305 uint8_t fWriteVBEData;
306 uint8_t fReadVBEIndex;
307 uint8_t fWriteVBEIndex;
308 /** VBE write data/index one byte buffer */
309 uint8_t cbWriteVBEData;
310 uint8_t cbWriteVBEIndex;
311# ifdef VBE_NEW_DYN_LIST
312 /** VBE Extra Data write address one byte buffer */
313 uint8_t cbWriteVBEExtraAddress;
314 uint8_t Padding6; /**< Alignment padding. */
315# else
316 uint8_t Padding6[2]; /**< Alignment padding. */
317# endif
318#endif
319
320#ifdef VBE_NEW_DYN_LIST
321 /** The VBE BIOS extra data. */
322 R3PTRTYPE(uint8_t *) pu8VBEExtraData;
323 /** The size of the VBE BIOS extra data. */
324 uint16_t cbVBEExtraData;
325 /** The VBE BIOS current memory address. */
326 uint16_t u16VBEExtraAddress;
327 uint16_t Padding7[2]; /**< Alignment padding. */
328#endif
329 /** Current logo data offset. */
330 uint32_t offLogoData;
331 /** The size of the BIOS logo data. */
332 uint32_t cbLogo;
333 /** The BIOS logo data. */
334 R3PTRTYPE(uint8_t *) pu8Logo;
335 /** The name of the logo file. */
336 R3PTRTYPE(char *) pszLogoFile;
337 /** Bitmap image data. */
338 R3PTRTYPE(uint8_t *) pu8LogoBitmap;
339 /** Current logo command. */
340 uint16_t LogoCommand;
341 /** Bitmap width. */
342 uint16_t cxLogo;
343 /** Bitmap height. */
344 uint16_t cyLogo;
345 /** Bitmap planes. */
346 uint16_t cLogoPlanes;
347 /** Bitmap depth. */
348 uint16_t cLogoBits;
349 /** Bitmap compression. */
350 uint16_t LogoCompression;
351 /** Bitmap colors used. */
352 uint16_t cLogoUsedColors;
353 /** Palette size. */
354 uint16_t cLogoPalEntries;
355 /** Clear screen flag. */
356 uint8_t fLogoClearScreen;
357 uint8_t Padding8[7]; /**< Alignment padding. */
358 /** Palette data. */
359 uint32_t au32LogoPalette[256];
360#endif /* VBOX */
361} VGAState;
362#ifdef VBOX
363/** VGA state. */
364typedef VGAState VGASTATE;
365/** Pointer to the VGA state. */
366typedef VGASTATE *PVGASTATE;
367#endif
368
369#ifdef VBE_NEW_DYN_LIST
370/**
371 * VBE Bios Extra Data structure.
372 * @remark duplicated in vbe.h.
373 */
374typedef struct VBEHeader
375{
376 /** Signature (VBEHEADER_MAGIC). */
377 uint16_t u16Signature;
378 /** Data size. */
379 uint16_t cbData;
380} VBEHeader;
381
382/** VBE Extra Data. */
383typedef VBEHeader VBEHEADER;
384/** Pointer to the VBE Extra Data. */
385typedef VBEHEADER *PVBEHEADER;
386
387/** The value of the VBEHEADER::u16Signature field.
388 * @remark duplicated in vbe.h. */
389#define VBEHEADER_MAGIC 0x77CC
390
391/** The extra port which is used to read the mode list.
392 * @remark duplicated in vbe.h. */
393#define VBE_EXTRA_PORT 0x3b6
394
395/** The extra port which is used for debug printf.
396 * @remark duplicated in vbe.h. */
397#define VBE_PRINTF_PORT 0x3b7
398
399#endif /* VBE_NEW_DYN_LIST */
400
401#if !defined(VBOX) || defined(IN_RING3)
402static inline int c6_to_8(int v)
403{
404 int b;
405 v &= 0x3f;
406 b = v & 1;
407 return (v << 2) | (b << 1) | b;
408}
409#endif /* !VBOX || IN_RING3 */
410
411#ifndef VBOX
412void vga_common_init(VGAState *s, DisplayState *ds, uint8_t *vga_ram_base,
413 unsigned long vga_ram_offset, int vga_ram_size);
414uint32_t vga_mem_readb(void *opaque, target_phys_addr_t addr);
415void vga_mem_writeb(void *opaque, target_phys_addr_t addr, uint32_t val);
416void vga_invalidate_scanlines(VGAState *s, int y1, int y2);
417
418void vga_draw_cursor_line_8(uint8_t *d1, const uint8_t *src1,
419 int poffset, int w,
420 unsigned int color0, unsigned int color1,
421 unsigned int color_xor);
422void vga_draw_cursor_line_16(uint8_t *d1, const uint8_t *src1,
423 int poffset, int w,
424 unsigned int color0, unsigned int color1,
425 unsigned int color_xor);
426void vga_draw_cursor_line_32(uint8_t *d1, const uint8_t *src1,
427 int poffset, int w,
428 unsigned int color0, unsigned int color1,
429 unsigned int color_xor);
430
431extern const uint8_t sr_mask[8];
432extern const uint8_t gr_mask[16];
433#endif /* !VBOX */
434
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