VirtualBox

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

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

headers.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 19.6 KB
Line 
1/* $Id: DevVGA.h 11166 2008-08-06 00:24:37Z 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 fHaveDirtyBits;
264 /** Pointer to vgaGCLFBAccessHandler(). */
265 RTRCPTR RCPtrLFBHandler;
266 /** Bitmap tracking dirty pages. */
267 uint32_t au32DirtyBitmap[VGA_VRAM_MAX / PAGE_SIZE / 32];
268 /** Pointer to the device instance - RC Ptr. */
269 PPDMDEVINSRC pDevInsRC;
270 /** Pointer to the device instance - R3 Ptr. */
271 PPDMDEVINSR3 pDevInsR3;
272 /** Pointer to the device instance - R0 Ptr. */
273 PPDMDEVINSR0 pDevInsR0;
274
275 /** The display port base interface. */
276 PDMIBASE Base;
277 /** The display port interface. */
278 PDMIDISPLAYPORT Port;
279 /** Pointer to base interface of the driver. */
280 R3PTRTYPE(PPDMIBASE) pDrvBase;
281 /** Pointer to display connector interface of the driver. */
282 R3PTRTYPE(PPDMIDISPLAYCONNECTOR) pDrv;
283 /** Refresh timer handle - HC. */
284 PTMTIMERR3 RefreshTimer;
285 /** Current refresh timer interval. */
286 uint32_t cMilliesRefreshInterval;
287
288 /** Whether to render the guest VRAM to the framebuffer memory. False only for some LFB modes. */
289 uint32_t fRenderVRAM;
290
291 /** The PCI device. */
292 PCIDEVICE Dev;
293
294 STAMPROFILE StatGCMemoryRead;
295 STAMPROFILE StatGCMemoryWrite;
296 STAMPROFILE StatGCIOPortRead;
297 STAMPROFILE StatGCIOPortWrite;
298
299#ifdef VBE_BYTEWISE_IO
300 /** VBE read/write data/index flags */
301 uint8_t fReadVBEData;
302 uint8_t fWriteVBEData;
303 uint8_t fReadVBEIndex;
304 uint8_t fWriteVBEIndex;
305 /** VBE write data/index one byte buffer */
306 uint8_t cbWriteVBEData;
307 uint8_t cbWriteVBEIndex;
308# ifdef VBE_NEW_DYN_LIST
309 /** VBE Extra Data write address one byte buffer */
310 uint8_t cbWriteVBEExtraAddress;
311 uint8_t Padding6; /**< Alignment padding. */
312# else
313 uint8_t Padding6[2]; /**< Alignment padding. */
314# endif
315#endif
316
317#ifdef VBE_NEW_DYN_LIST
318 /** The VBE BIOS extra data. */
319 R3PTRTYPE(uint8_t *) pu8VBEExtraData;
320 /** The size of the VBE BIOS extra data. */
321 uint16_t cbVBEExtraData;
322 /** The VBE BIOS current memory address. */
323 uint16_t u16VBEExtraAddress;
324 uint16_t Padding7[2]; /**< Alignment padding. */
325#endif
326 /** Current logo data offset. */
327 uint32_t offLogoData;
328 /** The size of the BIOS logo data. */
329 uint32_t cbLogo;
330 /** The BIOS logo data. */
331 R3PTRTYPE(uint8_t *) pu8Logo;
332 /** The name of the logo file. */
333 R3PTRTYPE(char *) pszLogoFile;
334 /** Bitmap image data. */
335 R3PTRTYPE(uint8_t *) pu8LogoBitmap;
336 /** Current logo command. */
337 uint16_t LogoCommand;
338 /** Bitmap width. */
339 uint16_t cxLogo;
340 /** Bitmap height. */
341 uint16_t cyLogo;
342 /** Bitmap planes. */
343 uint16_t cLogoPlanes;
344 /** Bitmap depth. */
345 uint16_t cLogoBits;
346 /** Bitmap compression. */
347 uint16_t LogoCompression;
348 /** Bitmap colors used. */
349 uint16_t cLogoUsedColors;
350 /** Palette size. */
351 uint16_t cLogoPalEntries;
352 /** Clear screen flag. */
353 uint8_t fLogoClearScreen;
354 uint8_t Padding8[7]; /**< Alignment padding. */
355 /** Palette data. */
356 uint32_t au32LogoPalette[256];
357#endif /* VBOX */
358} VGAState;
359#ifdef VBOX
360/** VGA state. */
361typedef VGAState VGASTATE;
362/** Pointer to the VGA state. */
363typedef VGASTATE *PVGASTATE;
364#endif
365
366#ifdef VBE_NEW_DYN_LIST
367/**
368 * VBE Bios Extra Data structure.
369 * @remark duplicated in vbe.h.
370 */
371typedef struct VBEHeader
372{
373 /** Signature (VBEHEADER_MAGIC). */
374 uint16_t u16Signature;
375 /** Data size. */
376 uint16_t cbData;
377} VBEHeader;
378
379/** VBE Extra Data. */
380typedef VBEHeader VBEHEADER;
381/** Pointer to the VBE Extra Data. */
382typedef VBEHEADER *PVBEHEADER;
383
384/** The value of the VBEHEADER::u16Signature field.
385 * @remark duplicated in vbe.h. */
386#define VBEHEADER_MAGIC 0x77CC
387
388/** The extra port which is used to read the mode list.
389 * @remark duplicated in vbe.h. */
390#define VBE_EXTRA_PORT 0x3b6
391
392/** The extra port which is used for debug printf.
393 * @remark duplicated in vbe.h. */
394#define VBE_PRINTF_PORT 0x3b7
395
396#endif /* VBE_NEW_DYN_LIST */
397
398#if !defined(VBOX) || defined(IN_RING3)
399static inline int c6_to_8(int v)
400{
401 int b;
402 v &= 0x3f;
403 b = v & 1;
404 return (v << 2) | (b << 1) | b;
405}
406#endif /* !VBOX || IN_RING3 */
407
408#ifndef VBOX
409void vga_common_init(VGAState *s, DisplayState *ds, uint8_t *vga_ram_base,
410 unsigned long vga_ram_offset, int vga_ram_size);
411uint32_t vga_mem_readb(void *opaque, target_phys_addr_t addr);
412void vga_mem_writeb(void *opaque, target_phys_addr_t addr, uint32_t val);
413void vga_invalidate_scanlines(VGAState *s, int y1, int y2);
414
415void vga_draw_cursor_line_8(uint8_t *d1, const uint8_t *src1,
416 int poffset, int w,
417 unsigned int color0, unsigned int color1,
418 unsigned int color_xor);
419void vga_draw_cursor_line_16(uint8_t *d1, const uint8_t *src1,
420 int poffset, int w,
421 unsigned int color0, unsigned int color1,
422 unsigned int color_xor);
423void vga_draw_cursor_line_32(uint8_t *d1, const uint8_t *src1,
424 int poffset, int w,
425 unsigned int color0, unsigned int color1,
426 unsigned int color_xor);
427
428extern const uint8_t sr_mask[8];
429extern const uint8_t gr_mask[16];
430#endif /* !VBOX */
431
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