DevVGA.h revision 5cf075f1173d07b89c26db295070415dffc6109d
/* $Id$ */
/** @file
*/
/*
* Copyright (C) 2006-2007 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
* --------------------------------------------------------------------
*
* This code is based on:
*
* QEMU internal VGA defines.
*
* Copyright (c) 2003-2004 Fabrice Bellard
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifdef VBOX
/** The default amount of VRAM. */
# define VGA_VRAM_DEFAULT (_4M)
/** The maximum amount of VRAM. Limited by VBOX_MAX_ALLOC_PAGE_COUNT. */
/** The minimum amount of VRAM. */
# define VGA_VRAM_MIN (_1M)
#endif
#ifdef VBOX_WITH_HGSMI
# include "HGSMI/HGSMIHost.h"
#endif /* VBOX_WITH_HGSMI */
#include "DevVGASavedState.h"
#define MSR_COLOR_EMULATION 0x01
#define MSR_PAGE_SELECT 0x20
#define ST01_V_RETRACE 0x08
#define ST01_DISP_ENABLE 0x01
/* bochs VBE support */
#define CONFIG_BOCHS_VBE
#ifdef VBOX
#define VBE_DISPI_MAX_XRES 16384
#define VBE_DISPI_MAX_YRES 16384
#else
#define VBE_DISPI_MAX_XRES 1600
#define VBE_DISPI_MAX_YRES 1200
#endif
#define VBE_DISPI_MAX_BPP 32
#define VBE_DISPI_INDEX_ID 0x0
#define VBE_DISPI_INDEX_XRES 0x1
#define VBE_DISPI_INDEX_YRES 0x2
#define VBE_DISPI_INDEX_BPP 0x3
#define VBE_DISPI_INDEX_ENABLE 0x4
#define VBE_DISPI_INDEX_BANK 0x5
#define VBE_DISPI_INDEX_VIRT_WIDTH 0x6
#define VBE_DISPI_INDEX_VIRT_HEIGHT 0x7
#define VBE_DISPI_INDEX_X_OFFSET 0x8
#define VBE_DISPI_INDEX_Y_OFFSET 0x9
#define VBE_DISPI_INDEX_VBOX_VIDEO 0xa
#define VBE_DISPI_ID0 0xB0C0
#define VBE_DISPI_ID1 0xB0C1
#define VBE_DISPI_ID2 0xB0C2
#define VBE_DISPI_ID3 0xB0C3
#define VBE_DISPI_ID4 0xB0C4
#ifdef VBOX
/* The VBOX interface id. Indicates support for VBE_DISPI_INDEX_VBOX_VIDEO. */
#define VBE_DISPI_ID_VBOX_VIDEO 0xBE00
#ifdef VBOX_WITH_HGSMI
/* The VBOX interface id. Indicates support for VBVA shared memory interface. */
#define VBE_DISPI_ID_HGSMI 0xBE01
#endif /* VBOX_WITH_HGSMI */
#endif /* VBOX */
#define VBE_DISPI_DISABLED 0x00
#define VBE_DISPI_ENABLED 0x01
#define VBE_DISPI_GETCAPS 0x02
#define VBE_DISPI_8BIT_DAC 0x20
#define VBE_DISPI_LFB_ENABLED 0x40
#define VBE_DISPI_NOCLEARMEM 0x80
#define VBE_DISPI_LFB_PHYSICAL_ADDRESS 0xE0000000
#ifdef CONFIG_BOCHS_VBE
#define VGA_STATE_COMMON_BOCHS_VBE \
#else
#define VGA_STATE_COMMON_BOCHS_VBE
#endif /* !CONFIG_BOCHS_VBE */
#define VGA_MAX_HEIGHT VBE_DISPI_MAX_YRES
#ifndef VBOX
#define VGA_STATE_COMMON \
unsigned long vram_offset; \
unsigned int vram_size; \
int ar_flip_flop; \
void (*get_offsets)(struct VGAState *s, \
uint32_t *pline_offset, \
uint32_t *pstart_addr, \
uint32_t *pline_compare); \
void (*get_resolution)(struct VGAState *s, \
int *pwidth, \
int *pheight); \
/* display refresh support */ \
DisplayState *ds; \
int graphic_mode; \
unsigned int (*rgb_to_pixel)(unsigned int r, \
unsigned int g, unsigned b); \
/* hardware mouse cursor support */ \
void (*cursor_invalidate)(struct VGAState *s); \
/* tell for each page if it has been updated since the last time */ \
#else /* VBOX */
struct VGAState;
typedef void FNGETOFFSETS(struct VGAState *s, uint32_t *pline_offset, uint32_t *pstart_addr, uint32_t *pline_compare);
typedef unsigned int FNRGBTOPIXEL(unsigned int r, unsigned int g, unsigned b);
typedef void FNCURSORINVALIDATE(struct VGAState *s);
/* bird: vram_offset have been remove, function pointers declared external,
some type changes, and some padding have been added. */
#define VGA_STATE_COMMON \
/* display refresh support */ \
/* hardware mouse cursor support */ \
/* tell for each page if it has been updated since the last time */ \
#endif /* VBOX */
#ifdef VBOX_WITH_VDMA
typedef struct VBOXVDMAHOST *PVBOXVDMAHOST;
#endif
typedef struct VGAState {
#ifdef VBOX
/** end-of-common-state-marker */
/** The physical address the VRAM was assigned. */
/** The R0 vram pointer... */
/** Pointer to the GC vram mapping. */
/** LFB was updated flag. */
bool fLFBUpdated;
/** Indicates if the GC extensions are enabled or not. */
bool fGCEnabled;
/** Indicates if the R0 extensions are enabled or not. */
bool fR0Enabled;
/** Flag indicating that there are dirty bits. This is used to optimize the handler resetting. */
bool fHasDirtyBits;
/** Flag indicating that the VGA memory in the 0xa0000-0xbffff region has been remapped to allow direct access. */
bool fRemappedVGA;
/** Whether to render the guest VRAM to the framebuffer memory. False only for some LFB modes. */
bool fRenderVRAM;
bool Padding1[2];
#ifdef VBOX_WITH_HGSMI
#endif /* VBOX_WITH_HGSMI */
#ifdef VBOX_WITH_VDMA
#endif
/** Current refresh timer interval. */
/** Refresh timer handle - HC. */
/** Bitmap tracking dirty pages. */
/** Pointer to vgaGCLFBAccessHandler(). */
/** Pointer to the device instance - RC Ptr. */
/** Pointer to the device instance - R3 Ptr. */
/** Pointer to the device instance - R0 Ptr. */
/** The critical section. */
/** LUN\#0: The display port base interface. */
/** LUN\#0: The display port interface. */
#if defined(VBOX_WITH_HGSMI) && defined(VBOX_WITH_VIDEOHWACCEL)
/** LUN\#0: VBVA callbacks interface */
#else
# if HC_ARCH_BITS == 32
# endif
#endif
/** Pointer to base interface of the driver. */
/** Pointer to display connector interface of the driver. */
/** The PCI device. */
/* Keep track of ring 0 latched accesses to the VGA MMIO memory. */
#ifdef VBE_BYTEWISE_IO
# ifdef VBE_NEW_DYN_LIST
/** VBE Extra Data write address one byte buffer */
# else
# endif
#endif
#ifdef VBE_NEW_DYN_LIST
/** The VBE BIOS extra data. */
/** The size of the VBE BIOS extra data. */
/** The VBE BIOS current memory address. */
#endif
/** Current logo data offset. */
/** The size of the BIOS logo data. */
/** The BIOS logo data. */
/** The name of the logo file. */
R3PTRTYPE(char *) pszLogoFile;
/** Bitmap image data. */
/** Current logo command. */
/** Bitmap width. */
/** Bitmap height. */
/** Bitmap planes. */
/** Bitmap depth. */
/** Bitmap compression. */
/** Bitmap colors used. */
/** Palette size. */
/** Clear screen flag. */
/** Palette data. */
#endif /* VBOX */
#ifdef VBOX_WITH_HGSMI
/** Base port in the assigned PCI I/O space. */
#ifdef VBOX_WITH_WDDM
/* specifies guest driver caps, i.e. whether it can handle IRQs from the adapter,
* the way it can handle async HGSMI command completion, etc. */
#else
#endif
#endif /* VBOX_WITH_HGSMI */
} VGAState;
#ifdef VBOX
/** VGA state. */
/** Pointer to the VGA state. */
#endif
#ifdef VBE_NEW_DYN_LIST
/**
* VBE Bios Extra Data structure.
* @remark duplicated in vbe.h.
*/
typedef struct VBEHeader
{
/** Signature (VBEHEADER_MAGIC). */
/** Data size. */
} VBEHeader;
/** VBE Extra Data. */
/** Pointer to the VBE Extra Data. */
typedef VBEHEADER *PVBEHEADER;
/** The value of the VBEHEADER::u16Signature field.
* @remark duplicated in vbe.h. */
#define VBEHEADER_MAGIC 0x77CC
/** The extra port which is used to read the mode list.
* @remark duplicated in vbe.h. */
#define VBE_EXTRA_PORT 0x3b6
/** The extra port which is used for debug printf.
* @remark duplicated in vbe.h. */
#define VBE_PRINTF_PORT 0x3b7
#endif /* VBE_NEW_DYN_LIST */
static inline int c6_to_8(int v)
{
int b;
v &= 0x3f;
b = v & 1;
return (v << 2) | (b << 1) | b;
}
#endif /* !VBOX || IN_RING3 */
#ifdef VBOX_WITH_HGSMI
/* @return host-guest flags that were set on reset
* this allows the caller to make further cleaning when needed,
* e.g. reset the IRQ */
# ifdef VBOX_WITH_VIDEOHWACCEL
# endif
#ifdef VBOX_WITH_HGSMI
#define PPDMIDISPLAYVBVACALLBACKS_2_PVGASTATE(_pcb) ( (PVGASTATE)((uint8_t *)(_pcb) - RT_OFFSETOF(VGASTATE, IVBVACallbacks)) )
#endif
# ifdef VBOX_WITH_CRHGSMI
int vboxVDMACrHgsmiCommandCompleteAsync(PPDMIDISPLAYVBVACALLBACKS pInterface, PVBOXVDMACMD_CHROMIUM_CMD pCmd, int rc);
int vboxVDMACrHgsmiControlCompleteAsync(PPDMIDISPLAYVBVACALLBACKS pInterface, PVBOXVDMACMD_CHROMIUM_CTL pCmd, int rc);
# endif
# ifdef VBOX_WITH_VDMA
typedef struct VBOXVDMAHOST *PVBOXVDMAHOST;
# endif /* VBOX_WITH_VDMA */
#endif /* VBOX_WITH_HGSMI */
#ifndef VBOX
unsigned long vga_ram_offset, int vga_ram_size);
int poffset, int w,
unsigned int color_xor);
int poffset, int w,
unsigned int color_xor);
int poffset, int w,
unsigned int color_xor);
#endif /* !VBOX */