DevVGA.h revision 12686bbcc13404db8fc0d9ddafea5a519b5376cd
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * DevVGA - VBox VGA/VESA device, internal header.
b3eb676cebf5407921b8f535095ca7655edb9db3vboxsync * Copyright (C) 2006-2007 Oracle Corporation
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * available from http://www.virtualbox.org. This file is free software;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * you can redistribute it and/or modify it under the terms of the GNU
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * General Public License (GPL) as published by the Free Software
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * --------------------------------------------------------------------
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * This code is based on:
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync * QEMU internal VGA defines.
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync * Copyright (c) 2003-2004 Fabrice Bellard
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync * Permission is hereby granted, free of charge, to any person obtaining a copy
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * of this software and associated documentation files (the "Software"), to deal
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * in the Software without restriction, including without limitation the rights
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * copies of the Software, and to permit persons to whom the Software is
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * furnished to do so, subject to the following conditions:
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * The above copyright notice and this permission notice shall be included in
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * all copies or substantial portions of the Software.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * THE SOFTWARE.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** The default amount of VRAM. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** The maximum amount of VRAM. Limited by VBOX_MAX_ALLOC_PAGE_COUNT. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** The minimum amount of VRAM. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#endif /* VBOX_WITH_HGSMI */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/* bochs VBE support */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#define VBE_DISPI_INDEX_NB_SAVED 0xb /* Number of saved registers (vbe_regs array) */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#define VBE_DISPI_INDEX_NB 0xb /* Total number of VBE registers */
ea4433aedd4105e6599e57e0c5f6cb32a68e963cvboxsync/* The VBOX interface id. Indicates support for VBE_DISPI_INDEX_VBOX_VIDEO. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/* The VBOX interface id. Indicates support for VBVA shared memory interface. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#endif /* VBOX_WITH_HGSMI */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#endif /* VBOX */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#endif /* !CONFIG_BOCHS_VBE */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync unsigned long vram_offset; \
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync unsigned int vram_size; \
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /* display refresh support */ \
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint32_t last_width, last_height; /* in chars or pixels */ \
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint32_t last_scr_width, last_scr_height; /* in pixels */ \
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync unsigned int (*rgb_to_pixel)(unsigned int r, \
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync unsigned int g, unsigned b); \
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /* hardware mouse cursor support */ \
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint32_t invalidated_y_table[VGA_MAX_HEIGHT / 32]; \
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync void (*cursor_draw_line)(struct VGAState *s, uint8_t *d, int y); \
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /* tell for each page if it has been updated since the last time */ \
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint32_t last_ch_attr[CH_ATTR_SIZE]; /* XXX: make it dynamic */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#else /* VBOX */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsynctypedef void FNGETOFFSETS(struct VGAState *s, uint32_t *pline_offset, uint32_t *pstart_addr, uint32_t *pline_compare);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsynctypedef void FNGETRESOLUTION(struct VGAState *s, int *pwidth, int *pheight);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsynctypedef unsigned int FNRGBTOPIXEL(unsigned int r, unsigned int g, unsigned b);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsynctypedef void FNCURSORINVALIDATE(struct VGAState *s);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsynctypedef void FNCURSORDRAWLINE(struct VGAState *s, uint8_t *d, int y);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/* bird: vram_offset have been remove, function pointers declared external,
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync some type changes, and some padding have been added. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /* display refresh support */ \
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint32_t last_width, last_height; /* in chars or pixels */ \
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint32_t last_scr_width, last_scr_height; /* in pixels */ \
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /* hardware mouse cursor support */ \
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint32_t invalidated_y_table[VGA_MAX_HEIGHT / 32]; \
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync R3PTRTYPE(FNCURSORINVALIDATE *) cursor_invalidate; \
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /* tell for each page if it has been updated since the last time */ \
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint32_t last_ch_attr[CH_ATTR_SIZE]; /* XXX: make it dynamic */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#endif /* VBOX */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsynctypedef struct VGAState {
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** end-of-common-state-marker */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The physical address the VRAM was assigned. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The R0 vram pointer... */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Pointer to the GC vram mapping. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** LFB was updated flag. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Indicates if the GC extensions are enabled or not. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Indicates if the R0 extensions are enabled or not. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Flag indicating that there are dirty bits. This is used to optimize the handler resetting. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Flag indicating that the VGA memory in the 0xa0000-0xbffff region has been remapped to allow direct access. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Whether to render the guest VRAM to the framebuffer memory. False only for some LFB modes. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#endif /* VBOX_WITH_HGSMI */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Current refresh timer interval. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Refresh timer handle - HC. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Bitmap tracking dirty pages. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint32_t au32DirtyBitmap[VGA_VRAM_MAX / PAGE_SIZE / 32];
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Pointer to vgaGCLFBAccessHandler(). */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Pointer to the device instance - RC Ptr. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Pointer to the device instance - R3 Ptr. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Pointer to the device instance - R0 Ptr. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The critical section. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** LUN\#0: The display port base interface. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** LUN\#0: The display port interface. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#if defined(VBOX_WITH_HGSMI) && defined(VBOX_WITH_VIDEOHWACCEL)
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** LUN\#0: VBVA callbacks interface */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Pointer to base interface of the driver. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Pointer to display connector interface of the driver. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The PCI device. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync STAMCOUNTER StatMapPage; /**< Counts IOMMMIOMapMMIO2Page calls. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync STAMCOUNTER StatUpdateDisp; /**< Counts vgaPortUpdateDisplay calls. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /* Keep track of ring 0 latched accesses to the VGA MMIO memory. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** VBE write data/index one byte buffer */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** VBE Extra Data write address one byte buffer */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The VBE BIOS extra data. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The size of the VBE BIOS extra data. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The VBE BIOS current memory address. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Current logo data offset. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The size of the BIOS logo data. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The BIOS logo data. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The name of the logo file. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Bitmap image data. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Current logo command. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Bitmap width. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Bitmap height. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Bitmap planes. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Bitmap depth. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Bitmap compression. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Bitmap colors used. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Palette size. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Clear screen flag. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Palette data. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#endif /* VBOX */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Base port in the assigned PCI I/O space. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /* specifies guest driver caps, i.e. whether it can handle IRQs from the adapter,
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * the way it can handle async HGSMI command completion, etc. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#endif /* VBOX_WITH_HGSMI */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** VGA state. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** Pointer to the VGA state. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * VBE Bios Extra Data structure.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @remark duplicated in vbe.h.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsynctypedef struct VBEHeader
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Signature (VBEHEADER_MAGIC). */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Data size. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** VBE Extra Data. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** Pointer to the VBE Extra Data. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** The value of the VBEHEADER::u16Signature field.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @remark duplicated in vbe.h. */
ea4433aedd4105e6599e57e0c5f6cb32a68e963cvboxsync/** The extra port which is used to read the mode list.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @remark duplicated in vbe.h. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** The extra port which is used for debug printf.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @remark duplicated in vbe.h. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#endif /* VBE_NEW_DYN_LIST */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncstatic inline int c6_to_8(int v)
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#endif /* !VBOX || IN_RING3 */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/* @return host-guest flags that were set on reset
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * this allows the caller to make further cleaning when needed,
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * e.g. reset the IRQ */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncint vbvaVHWACommandCompleteAsynch(PPDMIDISPLAYVBVACALLBACKS pInterface, PVBOXVHWACMD pCmd);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncint vboxVBVASaveStatePrep (PPDMDEVINS pDevIns, PSSMHANDLE pSSM);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncint vboxVBVASaveStateExec (PPDMDEVINS pDevIns, PSSMHANDLE pSSM);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncint vboxVBVALoadStateExec (PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t u32Version);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncint vboxVBVALoadStateDone (PPDMDEVINS pDevIns, PSSMHANDLE pSSM);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncint vboxVDMAConstruct(PVGASTATE pVGAState, struct VBOXVDMAHOST **ppVdma, uint32_t cPipeElements);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncvoid vboxVDMAControl(PVBOXVDMAHOST pVdma, PVBOXVDMA_CTL pCmd);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncvoid vboxVDMACommand(PVBOXVDMAHOST pVdma, PVBOXVDMACBUF_DR pCmd);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync# endif /* VBOX_WITH_VDMA */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#endif /* VBOX_WITH_HGSMI */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncvoid vga_common_init(VGAState *s, DisplayState *ds, uint8_t *vga_ram_base,
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncuint32_t vga_mem_readb(void *opaque, target_phys_addr_t addr);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncvoid vga_mem_writeb(void *opaque, target_phys_addr_t addr, uint32_t val);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncvoid vga_invalidate_scanlines(VGAState *s, int y1, int y2);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncvoid vga_draw_cursor_line_8(uint8_t *d1, const uint8_t *src1,
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync unsigned int color_xor);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncvoid vga_draw_cursor_line_16(uint8_t *d1, const uint8_t *src1,
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync unsigned int color_xor);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncvoid vga_draw_cursor_line_32(uint8_t *d1, const uint8_t *src1,
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync unsigned int color_xor);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#endif /* !VBOX */