DevVGA.h revision 359416647a711739d1b14addbf399178949a1a60
/* $Id$ */
/** @file
*/
/*
* Copyright (C) 2006-2013 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.
*/
/** Use VBE bytewise I/O. Only needed for Windows Longhorn/Vista betas and backwards compatibility. */
#define VBE_BYTEWISE_IO
/** Use VBE new dynamic mode list.
* If this is not defined, no checks are carried out to see if the modes all
* fit into the framebuffer! See the VRAM_SIZE_FIX define. */
#define VBE_NEW_DYN_LIST
#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"
#ifdef VBOX_WITH_VMSVGA
# include "DevVGA-SVGA.h"
#endif
#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 CONFIG_BOCHS_VBE
/* Cross reference with <VBox/Hardware/VBoxVideoVBE.h> */
#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
typedef struct vga_retrace_s {
unsigned frame_cclks; /* Character clocks per frame. */
unsigned frame_ns; /* Frame duration in ns. */
unsigned cclk_ns; /* Character clock duration in ns. */
unsigned vb_start; /* Vertical blanking start (scanline). */
unsigned vb_end; /* Vertical blanking end (scanline). */
unsigned vb_end_ns; /* Vertical blanking end time (length) in ns. */
unsigned vs_start; /* Vertical sync start (scanline). */
unsigned vs_end; /* Vertical sync end (scanline). */
unsigned vs_start_ns; /* Vertical sync start time in ns. */
unsigned vs_end_ns; /* Vertical sync end time in ns. */
unsigned h_total; /* Horizontal total (cclks per scanline). */
unsigned h_total_ns; /* Scanline duration in ns. */
unsigned hb_start; /* Horizontal blanking start (cclk). */
unsigned hb_end; /* Horizontal blanking end (cclk). */
unsigned hb_end_ns; /* Horizontal blanking end time (length) in ns. */
unsigned v_freq_hz; /* Vertical refresh rate to emulate. */
#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 */
/* bird: Since we've changed types, reordered members, done alignment
paddings and more, VGA_STATE_COMMON was added directly to the
struct to make it more readable and easier to handle. */
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);
#endif /* VBOX */
#ifdef VBOX_WITH_VDMA
typedef struct VBOXVDMAHOST *PVBOXVDMAHOST;
#endif
#ifdef VBOX_WITH_VIDEOHWACCEL
#define VBOX_VHWA_MAX_PENDING_COMMANDS 1000
typedef struct _VBOX_VHWA_PENDINGCMD
{
#endif
typedef struct VGAState {
#ifndef VBOX
#else /* VBOX */
/* display refresh support */
/* hardware mouse cursor support */
/* tell for each page if it has been updated since the last time */
/** end-of-common-state-marker */
/** Pointer to the device instance - RC Ptr. */
/** Pointer to the GC vram mapping. */
/** Pointer to the device instance - R3 Ptr. */
# ifdef VBOX_WITH_HGSMI
# endif
# ifdef VBOX_WITH_VDMA
# endif
/** LUN\#0: The display port base interface. */
/** LUN\#0: The display port interface. */
/** LUN\#0: VBVA callbacks interface */
# endif
/** Status LUN\#0: Leds interface. */
#if HC_ARCH_BITS == 32
#endif
/** Pointer to base interface of the driver. */
/** Pointer to display connector interface of the driver. */
/** Status LUN: Partner of ILeds. */
/** Status LUN: Media Notifys. */
/** Refresh timer handle - HC. */
/** Pointer to the device instance - R0 Ptr. */
/** The R0 vram pointer... */
#ifdef VBOX_WITH_VMSVGA
struct
{
/** The host window handle */
/** The R3 FIFO pointer. */
/** The R0 FIFO pointer. */
/** R3 Opaque pointer to svga state. */
R3PTRTYPE(void *) pSVGAState;
/** R3 Opaque pointer to 3d state. */
/** R3 Opaque pointer to a copy of the first 32k of the framebuffer before switching into svga mode. */
R3PTRTYPE(void *) pFrameBufferBackup;
#if HC_ARCH_BITS == 32
#endif
/** Guest physical address of the FIFO memory range. */
/** Size in bytes of the FIFO memory range. */
/** SVGA id. */
/** SVGA extensions enabled or not. */
/** SVGA memory area configured status. */
/** Device is busy handling FIFO requests. */
/** Traces (dirty page detection) enabled or not. */
/** Guest OS identifier. */
/** Scratch region size. */
/** Scratch array. */
/** Irq status. */
/** Irq mask. */
/** Pitch lock. */
/** Current GMR id. (SVGA_REG_GMR_ID) */
/** Register caps. */
/** Physical address of command mmio range. */
/** Port io index register. */
/** FIFO request semaphore. */
/** FIFO IO Thread. */
/** Maximum width supported. */
/** Maximum height supported. */
/** Action flags */
/** SVGA 3d extensions enabled or not. */
bool f3DEnabled;
/** VRAM page monitoring enabled or not. */
bool fVRAMTracking;
bool Padding6[2];
} svga;
#endif
/** The number of monitors. */
/** Current refresh timer interval. */
/** Bitmap tracking dirty pages. */
/** Flag indicating that there are dirty bits. This is used to optimize the handler resetting. */
bool fHasDirtyBits;
/** 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 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;
#ifdef VBOX_WITH_VMSVGA
/* Whether the SVGA emulation is enabled or not. */
bool fVMSVGAEnabled;
bool Padding1[1];
#else
bool Padding1[2];
#endif
/** The physical address the VRAM was assigned. */
/** The critical section protect the instance data. */
/** 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
/** Retrace emulation state */
bool fRealRetrace;
# 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
/** The BIOS logo data. */
/** The name of the logo file. */
R3PTRTYPE(char *) pszLogoFile;
/** Bitmap image data. */
/** Current logo data offset. */
/** The size of the BIOS logo data. */
/** Current logo command. */
/** Bitmap width. */
/** Bitmap height. */
/** Bitmap planes. */
/** Bitmap depth. */
/** Bitmap compression. */
/** Bitmap colors used. */
/** Palette size. */
/** Clear screen flag. */
/** Palette data. */
/** The VGA BIOS ROM data. */
/** The size of the VGA BIOS ROM. */
/** The name of the VGA BIOS ROM file. */
R3PTRTYPE(char *) pszVgaBiosFile;
# 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 */
struct {
union
{
/* make sure the structure sized cross different contexts correctly */
struct
{
} dummy;
};
#endif /* VBOX */
} 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
int VBVAGetInfoViewAndScreen(PVGASTATE pVGAState, uint32_t u32ViewIndex, VBVAINFOVIEW *pView, VBVAINFOSCREEN *pScreen);
/* @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);
void *pvCompletion);
# endif
# ifdef VBOX_WITH_VDMA
typedef struct VBOXVDMAHOST *PVBOXVDMAHOST;
# endif /* VBOX_WITH_VDMA */
# ifdef VBOX_WITH_CRHGSMI
# endif /* VBOX_WITH_CRHGSMI */
#endif /* VBOX_WITH_HGSMI */
# ifdef VBOX_WITH_VMSVGA
int vgaR3UpdateDisplay(PVGASTATE pVGAState, unsigned xStart, unsigned yStart, unsigned width, unsigned height);
# endif
#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 */