DevVGA.cpp revision e587bf644dae7de0d6281ba78d31409f87160c89
/* $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 VGA Emulator.
*
* Copyright (c) 2003 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.
*/
/*******************************************************************************
* Defined Constants And Macros *
*******************************************************************************/
/* WARNING!!! All defines that affetc VGAState should be placed to DevVGA.h !!!
* NEVER place them here as this would lead to VGAState inconsistency
* across different .cpp files !!!
*/
/** The size of the VGA GC mapping.
* This is supposed to be all the VGA memory accessible to the guest.
* The initial value was 256KB but NTAllInOne.iso appears to access more
* thus the limit was upped to 512KB.
*
* @todo Someone with some VGA knowhow should make a better guess at this value.
*/
#define VGA_MAPPING_SIZE _512K
#ifdef VBOX_WITH_HGSMI
#endif /* VBOX_WITH_HGSMI */
/** Converts a vga adaptor state pointer to a device instance pointer. */
/** Check that the video modes fit into virtual video memory.
* Only works when VBE_NEW_DYN_LIST is defined! */
#define VRAM_SIZE_FIX
/** Check buffer if an VRAM offset is within the right range or not. */
#if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0)
do { \
if ((off) >= VGA_MAPPING_SIZE) \
{ \
AssertMsgReturn((off) < (pThis)->vram_size, ("%RX32 !< %RX32\n", (uint32_t)(off), (pThis)->vram_size), VINF_SUCCESS); \
return VINF_IOM_HC_MMIO_WRITE; \
} \
} while (0)
#else
AssertMsgReturn((off) < (pThis)->vram_size, ("%RX32 !< %RX32\n", (uint32_t)(off), (pThis)->vram_size), VINF_SUCCESS)
#endif
/** Check buffer if an VRAM offset is within the right range or not. */
#if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0)
do { \
if ((off) >= VGA_MAPPING_SIZE) \
{ \
AssertMsgReturn((off) < (pThis)->vram_size, ("%RX32 !< %RX32\n", (uint32_t)(off), (pThis)->vram_size), 0xff); \
(rcVar) = VINF_IOM_HC_MMIO_READ; \
return 0; \
} \
} while (0)
#else
AssertMsgReturn((off) < (pThis)->vram_size, ("%RX32 !< %RX32\n", (uint32_t)(off), (pThis)->vram_size), 0xff)
#endif
/*******************************************************************************
* Header Files *
*******************************************************************************/
#define LOG_GROUP LOG_GROUP_DEV_VGA
#ifdef IN_RING3
#endif /* IN_RING3 */
#include <VBox/VBoxVideo.h>
#include <VBox/bioslogo.h>
/* should go BEFORE any other DevVGA include to make all DevVGA.h config defines be visible */
#include "DevVGA.h"
# include "DevVGAModes.h"
# include <stdio.h> /* sscan */
#endif
#include "vl_vbox.h"
#include "VBoxDD.h"
#include "VBoxDD2.h"
/*******************************************************************************
* Structures and Typedefs *
*******************************************************************************/
#pragma pack(1)
/** BMP File Format Bitmap Header. */
typedef struct
{
} BMPINFO;
/** Pointer to a bitmap header*/
/** OS/2 1.x Information Header Format. */
typedef struct
{
} OS2HDR;
/** Pointer to a OS/2 1.x header format */
/** OS/2 2.0 Information Header Format. */
typedef struct
{
} OS22HDR;
/** Pointer to a OS/2 2.0 header format */
/** Windows 3.x Information Header Format. */
typedef struct
{
} WINHDR;
/** Pointer to a Windows 3.x header format */
#pragma pack()
#define BMP_ID 0x4D42
/** @name BMP compressions.
* @{ */
#define BMP_COMPRESS_NONE 0
#define BMP_COMPRESS_RLE8 1
#define BMP_COMPRESS_RLE4 2
/** @} */
/** @name BMP header sizes.
* @{ */
#define BMP_HEADER_OS21 12
#define BMP_HEADER_OS22 64
#define BMP_HEADER_WIN3 40
/** @} */
/** The BIOS boot menu text position, X. */
#define LOGO_F12TEXT_X 304
/** The BIOS boot menu text position, Y. */
#define LOGO_F12TEXT_Y 464
/** Width of the "Press F12 to select boot device." bitmap.
Anything that exceeds the limit of F12BootText below is filled with
background. */
#define LOGO_F12TEXT_WIDTH 286
/** Height of the boot device selection bitmap, see LOGO_F12TEXT_WIDTH. */
#define LOGO_F12TEXT_HEIGHT 12
/** The BIOS logo delay time (msec). */
#define LOGO_DELAY_TIME 2000
#define LOGO_MAX_WIDTH 640
#define LOGO_MAX_HEIGHT 480
/*******************************************************************************
* Global Variables *
*******************************************************************************/
/* "Press F12 to select boot device." bitmap. */
static const uint8_t g_abLogoF12BootText[] =
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x07, 0x0F, 0x7C,
0xF8, 0xF0, 0x01, 0xE0, 0x81, 0x9F, 0x3F, 0x00, 0x70, 0xF8, 0x00, 0xE0, 0xC3,
0x07, 0x0F, 0x1F, 0x3E, 0x70, 0x00, 0xF0, 0xE1, 0xC3, 0x07, 0x0E, 0x00, 0x6E,
0x7C, 0x60, 0xE0, 0xE1, 0xC3, 0x07, 0xC6, 0x80, 0x81, 0x31, 0x63, 0xC6, 0x00,
0x30, 0x80, 0x61, 0x0C, 0x00, 0x36, 0x63, 0x00, 0x8C, 0x19, 0x83, 0x61, 0xCC,
0x18, 0x36, 0x00, 0xCC, 0x8C, 0x19, 0xC3, 0x06, 0xC0, 0x8C, 0x31, 0x3C, 0x30,
0x8C, 0x19, 0x83, 0x31, 0x60, 0x60, 0x00, 0x0C, 0x18, 0x00, 0x0C, 0x60, 0x18,
0x00, 0x80, 0xC1, 0x18, 0x00, 0x30, 0x06, 0x60, 0x18, 0x30, 0x80, 0x01, 0x00,
0x33, 0x63, 0xC6, 0x30, 0x00, 0x30, 0x63, 0x80, 0x19, 0x0C, 0x03, 0x06, 0x00,
0x0C, 0x18, 0x18, 0xC0, 0x81, 0x03, 0x00, 0x03, 0x18, 0x0C, 0x00, 0x60, 0x30,
0x06, 0x00, 0x87, 0x01, 0x18, 0x06, 0x0C, 0x60, 0x00, 0xC0, 0xCC, 0x98, 0x31,
0x0C, 0x00, 0xCC, 0x18, 0x30, 0x0C, 0xC3, 0x80, 0x01, 0x00, 0x03, 0x66, 0xFE,
0x18, 0x30, 0x00, 0xC0, 0x02, 0x06, 0x06, 0x00, 0x18, 0x8C, 0x01, 0x60, 0xE0,
0x0F, 0x86, 0x3F, 0x03, 0x18, 0x00, 0x30, 0x33, 0x66, 0x0C, 0x03, 0x00, 0x33,
0xFE, 0x0C, 0xC3, 0x30, 0xE0, 0x0F, 0xC0, 0x87, 0x9B, 0x31, 0x63, 0xC6, 0x00,
0xF0, 0x80, 0x01, 0x03, 0x00, 0x06, 0x63, 0x00, 0x8C, 0x19, 0x83, 0x61, 0xCC,
0x18, 0x06, 0x00, 0x6C, 0x8C, 0x19, 0xC3, 0x00, 0x80, 0x8D, 0x31, 0xC3, 0x30,
0x8C, 0x19, 0x03, 0x30, 0xB3, 0xC3, 0x87, 0x0F, 0x1F, 0x00, 0x2C, 0x60, 0x80,
0x01, 0xE0, 0x87, 0x0F, 0x00, 0x3E, 0x7C, 0x60, 0xF0, 0xE1, 0xE3, 0x07, 0x00,
0x0F, 0x3E, 0x7C, 0xFC, 0x00, 0xC0, 0xC3, 0xC7, 0x30, 0x0E, 0x3E, 0x7C, 0x00,
0xCC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x1E, 0xC0, 0x00, 0x60, 0x00,
0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x60, 0x00, 0xC0, 0x00, 0x00, 0x00,
0x0C, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00,
0x00, 0x00, 0x00, 0xC0, 0x0C, 0x87, 0x31, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00,
0x00, 0x06, 0x00, 0x00, 0x18, 0x00, 0x30, 0x00, 0x00, 0x00, 0x03, 0x00, 0x30,
0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0xE0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
0xF8, 0x83, 0xC1, 0x07, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x01, 0x00,
0x00, 0x04, 0x00, 0x0E, 0x00, 0x00, 0x80, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x30,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
#ifndef VBOX_DEVICE_STRUCT_TESTCASE
/**
* Set a VRAM page dirty.
*
* @param pThis VGA instance data.
* @param offVRAM The VRAM offset of the page to set.
*/
{
AssertMsg(offVRAM < pThis->vram_size, ("offVRAM = %p, pThis->vram_size = %p\n", offVRAM, pThis->vram_size));
pThis->fHasDirtyBits = true;
}
/**
* Tests if a VRAM page is dirty.
*
* @returns true if dirty.
* @returns false if clean.
* @param pThis VGA instance data.
* @param offVRAM The VRAM offset of the page to check.
*/
{
AssertMsg(offVRAM < pThis->vram_size, ("offVRAM = %p, pThis->vram_size = %p\n", offVRAM, pThis->vram_size));
}
/**
* Reset dirty flags in a give range.
*
* @param pThis VGA instance data.
* @param offVRAMStart Offset into the VRAM buffer of the first page.
* @param offVRAMEnd Offset into the VRAM buffer of the last page - exclusive.
*/
{
}
/* force some bits to zero */
(uint8_t)~0xfc,
(uint8_t)~0xc2,
(uint8_t)~0xf0,
(uint8_t)~0xc0,
(uint8_t)~0xf1,
(uint8_t)~0xff,
(uint8_t)~0xff,
(uint8_t)~0x00,
};
};
((uint32_t)( \
#ifdef WORDS_BIGENDIAN
#else
#define PAT(x) (x)
#endif
#ifdef WORDS_BIGENDIAN
#define BIG 1
#else
#define BIG 0
#endif
#ifdef WORDS_BIGENDIAN
#else
#endif
PAT(0x00000000),
PAT(0x000000ff),
PAT(0x0000ff00),
PAT(0x0000ffff),
PAT(0x00ff0000),
PAT(0x00ff00ff),
PAT(0x00ffff00),
PAT(0x00ffffff),
PAT(0xff000000),
PAT(0xff0000ff),
PAT(0xff00ff00),
PAT(0xff00ffff),
PAT(0xffff0000),
PAT(0xffff00ff),
PAT(0xffffff00),
PAT(0xffffffff),
};
#ifdef WORDS_BIGENDIAN
#define PAT(x) (x)
#else
#endif
PAT(0x00000000),
PAT(0x000000ff),
PAT(0x0000ff00),
PAT(0x0000ffff),
PAT(0x00ff0000),
PAT(0x00ff00ff),
PAT(0x00ffff00),
PAT(0x00ffffff),
PAT(0xff000000),
PAT(0xff0000ff),
PAT(0xff00ff00),
PAT(0xff00ffff),
PAT(0xffff0000),
PAT(0xffff00ff),
PAT(0xffffff00),
PAT(0xffffffff),
};
PAT(0x00000000),
PAT(0x0000ffff),
PAT(0xffff0000),
PAT(0xffffffff),
};
#if defined(IN_RING3)
#endif /* IN_RING3 */
/* Update the values needed for calculating Vertical Retrace and
* Display Enable status bits more or less accurately. The Display Enable
* bit is set (indicating *disabled* display signal) when either the
* horizontal (hblank) or vertical (vblank) blanking is active. The
* Vertical Retrace bit is set when vertical retrace (vsync) is active.
* Unless the CRTC is horribly misprogrammed, vsync implies vblank.
*/
static void vga_update_retrace_state(VGAState *s)
{
vga_retrace_s *r = &s->retrace_state;
/* Calculate the blanking and sync widths. The way it's implemented in
* the VGA with limited-width compare counters is quite a piece of work.
*/
/* Calculate the dot and character clock rates. */
/* Calculate the number of cclks per entire frame. */
if (r->v_freq_hz) { /* Could be set to emulate a specific rate. */
} else {
}
r->h_total = htotal_cclks;
r->vb_start = vblank_start_line;
r->vs_start = vsync_start_line;
/* Calculate timings in nanoseconds. For easier comparisons, the frame
* is considered to start at the beginning of the vertical and horizontal
* blanking period.
*/
}
{
vga_retrace_s *r = &s->retrace_state;
if (r->frame_ns) {
unsigned cur_frame_ns, cur_line_ns;
/* Determine the time within the frame. */
/* See if we're in the vertical blanking period... */
if (cur_frame_ns < r->vb_end_ns) {
val |= ST01_DISP_ENABLE;
/* ... and additionally in the vertical sync period. */
val |= ST01_V_RETRACE;
} else {
/* Determine the time within the current scanline. */
/* See if we're in the horizontal blanking period. */
if (cur_line_ns < r->hb_end_ns)
val |= ST01_DISP_ENABLE;
}
return val;
} else {
}
}
{
if (s->msr & MSR_COLOR_EMULATION) {
/* Color */
} else {
/* Monochrome */
}
}
{
/* check port range access depending on color/monochrome mode */
if (vga_ioport_invalid(s, addr)) {
val = 0xff;
Log(("VGA: following read ignored\n"));
} else {
switch(addr) {
case 0x3c0:
if (s->ar_flip_flop == 0) {
} else {
val = 0;
}
break;
case 0x3c1:
if (index < 21)
else
val = 0;
break;
case 0x3c2:
break;
case 0x3c4:
break;
case 0x3c5:
break;
case 0x3c7:
break;
case 0x3c8:
val = s->dac_write_index;
break;
case 0x3c9:
if (++s->dac_sub_index == 3) {
s->dac_sub_index = 0;
s->dac_read_index++;
}
break;
case 0x3ca:
break;
case 0x3cc:
break;
case 0x3ce:
break;
case 0x3cf:
break;
case 0x3b4:
case 0x3d4:
break;
case 0x3b5:
case 0x3d5:
break;
case 0x3ba:
case 0x3da:
s->ar_flip_flop = 0;
break;
default:
val = 0x00;
break;
}
}
return val;
}
{
int index;
/* check port range access depending on color/monochrome mode */
if (vga_ioport_invalid(s, addr)) {
Log(("VGA: previous write ignored\n"));
return;
}
switch(addr) {
case 0x3c0:
if (s->ar_flip_flop == 0) {
val &= 0x3f;
} else {
switch(index) {
case 0x00: case 0x01: case 0x02: case 0x03: case 0x04: case 0x05: case 0x06: case 0x07:
case 0x08: case 0x09: case 0x0a: case 0x0b: case 0x0c: case 0x0d: case 0x0e: case 0x0f:
break;
case 0x10:
break;
case 0x11:
break;
case 0x12:
break;
case 0x13:
break;
case 0x14:
break;
default:
break;
}
}
s->ar_flip_flop ^= 1;
break;
case 0x3c2:
if (s->fRealRetrace)
break;
case 0x3c4:
break;
case 0x3c5:
#ifndef IN_RC
/* The VGA region is (could be) affected by this change; reset all aliases we've created. */
{
if (s->fRemappedVGA)
{
s->fRemappedVGA = false;
}
}
#endif
break;
case 0x3c7:
s->dac_read_index = val;
s->dac_sub_index = 0;
s->dac_state = 3;
break;
case 0x3c8:
s->dac_write_index = val;
s->dac_sub_index = 0;
s->dac_state = 0;
break;
case 0x3c9:
if (++s->dac_sub_index == 3) {
s->dac_sub_index = 0;
s->dac_write_index++;
}
break;
case 0x3ce:
break;
case 0x3cf:
#ifndef IN_RC
/* The VGA region is (could be) affected by this change; reset all aliases we've created. */
{
if (s->fRemappedVGA)
{
s->fRemappedVGA = false;
}
}
#endif
break;
case 0x3b4:
case 0x3d4:
break;
case 0x3b5:
case 0x3d5:
/* handle CR0-7 protection */
/* can always write bit 4 of CR7 */
if (s->cr_index == 7)
return;
}
if (s->fRealRetrace) {
/* The following registers are only updated during a mode set. */
switch(s->cr_index) {
case 0x00:
case 0x02:
case 0x03:
case 0x05:
case 0x06:
case 0x07:
case 0x09:
case 0x10:
case 0x11:
case 0x15:
case 0x16:
break;
}
}
break;
case 0x3ba:
case 0x3da:
break;
}
}
#ifdef CONFIG_BOCHS_VBE
{
return val;
}
{
if (s->vbe_index < VBE_DISPI_INDEX_NB) {
switch(s->vbe_index) {
/* XXX: do not hardcode ? */
case VBE_DISPI_INDEX_XRES:
break;
case VBE_DISPI_INDEX_YRES:
break;
case VBE_DISPI_INDEX_BPP:
break;
default:
break;
}
} else {
switch(s->vbe_index) {
/* Reading from the port means that the old additions are requesting the number of monitors. */
val = 1;
break;
default:
break;
}
}
} else {
val = 0;
}
return val;
}
/* Calculate scanline pitch based on bit depth and width in pixels. */
{
if (bpp <= 4)
else
/* Align the pitch to some sensible value. */
if (aligned_pitch != pitch)
return aligned_pitch;
}
/* Calculate line width in pixels based on bit depth and pitch. */
{
if (bpp <= 4)
else
return width;
}
{
return; /* Not enough data has been set yet. */
if (!cbLinePitch)
Assert(cbLinePitch != 0);
if (!fVirtHeightOnly)
{
if (cBPP == 4)
else
offStart >>= 2;
}
/* The VBE_DISPI_INDEX_VIRT_HEIGHT is used to prevent setting resolution bigger than VRAM permits
* it is used instead of VBE_DISPI_INDEX_YRES *only* in case
* s->vbe_regs[VBE_DISPI_INDEX_VIRT_HEIGHT] < s->vbe_regs[VBE_DISPI_INDEX_YRES]
* We can not simply do s->vbe_regs[VBE_DISPI_INDEX_VIRT_HEIGHT] = cVirtHeight since
* the cVirtHeight we calculated can exceed the 16bit value range
* instead we'll check if it's bigger than s->vbe_regs[VBE_DISPI_INDEX_YRES], and if yes,
* assign the s->vbe_regs[VBE_DISPI_INDEX_VIRT_HEIGHT] with a dummy UINT16_MAX value
* that is always bigger than s->vbe_regs[VBE_DISPI_INDEX_YRES]
* to just ensure the s->vbe_regs[VBE_DISPI_INDEX_YRES] is always used */
s->vbe_regs[VBE_DISPI_INDEX_VIRT_HEIGHT] = (cVirtHeight >= (uint32_t)s->vbe_regs[VBE_DISPI_INDEX_YRES]) ? UINT16_MAX : (uint16_t)cVirtHeight;
}
{
}
{
if (s->vbe_index <= VBE_DISPI_INDEX_NB) {
bool fRecalculate = false;
switch(s->vbe_index) {
case VBE_DISPI_INDEX_ID:
if (val == VBE_DISPI_ID0 ||
val == VBE_DISPI_ID1 ||
val == VBE_DISPI_ID2 ||
val == VBE_DISPI_ID3 ||
val == VBE_DISPI_ID4) {
}
if (val == VBE_DISPI_ID_VBOX_VIDEO) {
} else if (val == VBE_DISPI_ID_ANYX) {
}
#ifdef VBOX_WITH_HGSMI
else if (val == VBE_DISPI_ID_HGSMI) {
}
#endif /* VBOX_WITH_HGSMI */
break;
case VBE_DISPI_INDEX_XRES:
if (val <= VBE_DISPI_MAX_XRES)
{
fRecalculate = true;
}
break;
case VBE_DISPI_INDEX_YRES:
if (val <= VBE_DISPI_MAX_YRES)
break;
case VBE_DISPI_INDEX_BPP:
if (val == 0)
val = 8;
fRecalculate = true;
}
break;
case VBE_DISPI_INDEX_BANK:
else
max_bank = s->vbe_bank_max;
/* Old software may pass garbage in the high byte of bank. If the maximum
* bank fits into a single byte, toss the high byte the user supplied.
*/
if (max_bank < 0x100)
val &= 0xff;
#ifndef IN_RC
/* The VGA region is (could be) affected by this change; reset all aliases we've created. */
if (s->fRemappedVGA)
{
s->fRemappedVGA = false;
}
#endif
break;
case VBE_DISPI_INDEX_ENABLE:
#ifndef IN_RING3
return VINF_IOM_HC_IOPORT_WRITE;
#else
if ((val & VBE_DISPI_ENABLED) &&
int h, shift_control;
/* Check the values before we screw up with a resolution which is too big or small. */
else
if (!cVirtWidth)
if ( !cVirtWidth
|| !s->vbe_regs[VBE_DISPI_INDEX_YRES]
{
AssertMsgFailed(("VIRT WIDTH=%d YRES=%d cb=%d vram_size=%d\n",
return VINF_SUCCESS; /* Note: silent failure like before */
}
/* When VBE interface is enabled, it is reset. */
s->vbe_regs[VBE_DISPI_INDEX_X_OFFSET] = 0;
s->vbe_regs[VBE_DISPI_INDEX_Y_OFFSET] = 0;
fRecalculate = true;
/* clear the screen (should be done in BIOS) */
if (!(val & VBE_DISPI_NOCLEARMEM)) {
cY * cbLinePitch);
}
/* we initialize the VGA graphic mode (should be done
in BIOS) */
/* width */
/* height (only meaningful if < 1024) */
s->cr[0x12] = h;
((h >> 7) & 0x02) | ((h >> 3) & 0x40);
/* line compare to 1023 */
shift_control = 0;
} else {
shift_control = 2;
}
/* sunlover 30.05.2007
* The ar_index remains with bit 0x20 cleared after a switch from fullscreen
* DOS mode on Windows XP guest. That leads to GMODE_BLANK in vga_update_display.
* But the VBE mode is graphics, so not a blank anymore.
*/
s->ar_index |= 0x20;
} else {
/* XXX: the bios should do that */
/* sunlover 21.12.2006
* Here is probably more to reset. When this was executed in GC
* then the *update* functions could not detect a mode change.
* Or may be these update function should take the s->vbe_regs[s->vbe_index]
* into account when detecting a mode change.
*
* The 'mode reset not detected' problem is now fixed by executing the
* VBE_DISPI_INDEX_ENABLE case always in RING3 in order to call the
* LFBChange callback.
*/
s->bank_offset = 0;
}
/*
* LFB video mode is either disabled or changed. This notification
* is used by the display to disable VBVA.
*/
/* The VGA region is (could be) affected by this change; reset all aliases we've created. */
if (s->fRemappedVGA)
{
s->fRemappedVGA = false;
}
break;
#endif /* IN_RING3 */
case VBE_DISPI_INDEX_X_OFFSET:
case VBE_DISPI_INDEX_Y_OFFSET:
{
fRecalculate = true;
}
break;
#ifndef IN_RING3
return VINF_IOM_HC_IOPORT_WRITE;
#else
/* Changes in the VGA device are minimal. The device is bypassed. The driver does all work. */
if (val == VBOX_VIDEO_DISABLE_ADAPTER_MEMORY)
{
}
else if (val == VBOX_VIDEO_INTERPRET_ADAPTER_MEMORY)
{
}
{
}
#endif /* IN_RING3 */
break;
default:
break;
}
if (fRecalculate)
{
recaltulate_data(s, false);
}
}
return VINF_SUCCESS;
}
#endif
/* called for accesses between 0xa0000 and 0xc0000 */
{
int memory_map_mode, plane;
/* convert to VGA memory offset */
addr &= 0x1ffff;
switch(memory_map_mode) {
case 0:
break;
case 1:
if (addr >= 0x10000)
return 0xff;
addr += s->bank_offset;
break;
case 2:
addr -= 0x10000;
if (addr >= 0x8000)
return 0xff;
break;
default:
case 3:
addr -= 0x18000;
if (addr >= 0x8000)
return 0xff;
break;
}
/* chain 4 mode : simplest access */
# ifndef IN_RC
/* If all planes are accessible, then map the page to the frame buffer and make it writable. */
&& !vga_is_dirty(s, addr))
{
/** @todo only allow read access (doesn't work now) */
STAM_COUNTER_INC(&s->StatMapPage);
IOMMMIOMapMMIO2Page(PDMDevHlpGetVM(s->CTX_SUFF(pDevIns)), GCPhys, s->GCPhysVRAM + addr, X86_PTE_RW|X86_PTE_P);
/* Set as dirty as write accesses won't be noticed now. */
vga_set_dirty(s, addr);
s->fRemappedVGA = true;
}
# endif /* IN_RC */
/* See the comment for a similar line in vga_mem_writeb. */
} else {
/* standard VGA latched access */
/* read mode 0 */
} else {
/* read mode 1 */
}
}
return ret;
}
/* called for accesses between 0xa0000 and 0xc0000 */
{
/* convert to VGA memory offset */
addr &= 0x1ffff;
switch(memory_map_mode) {
case 0:
break;
case 1:
if (addr >= 0x10000)
return VINF_SUCCESS;
addr += s->bank_offset;
break;
case 2:
addr -= 0x10000;
if (addr >= 0x8000)
return VINF_SUCCESS;
break;
default:
case 3:
addr -= 0x18000;
if (addr >= 0x8000)
return VINF_SUCCESS;
break;
}
/* chain 4 mode : simplest access */
# ifndef IN_RC
/* If all planes are accessible, then map the page to the frame buffer and make it writable. */
&& !vga_is_dirty(s, addr))
{
STAM_COUNTER_INC(&s->StatMapPage);
IOMMMIOMapMMIO2Page(PDMDevHlpGetVM(s->CTX_SUFF(pDevIns)), GCPhys, s->GCPhysVRAM + addr, X86_PTE_RW | X86_PTE_P);
s->fRemappedVGA = true;
}
# endif /* IN_RC */
vga_set_dirty(s, addr);
}
/* 'addr' is offset in a plane, bit 0 selects the plane.
* Mask the bit 0, convert plane index to vram offset,
* that is multiply by the number of planes,
* and select the plane byte in the vram offset.
*/
vga_set_dirty(s, addr);
}
} else {
/* standard VGA latched access */
#ifdef IN_RING0
{
{
/* About 1000 (or more) accesses per 10 ms will trigger a reschedule
* to the recompiler
*/
{
s->u64LastLatchedAccess = 0;
return VINF_EM_RAW_EMULATE_IO_BLOCK;
}
if (s->u64LastLatchedAccess)
{
Log2(("Reset mask (was %d) delta %RX64 (limit %x)\n", s->iMask, u64CurTime - s->u64LastLatchedAccess, s_aDelta[s->iMask]));
if (s->iMask)
s->iMask--;
}
}
else
{
s->u64LastLatchedAccess = 0;
s->iMask = 0;
s->cLatchAccesses = 0;
}
}
#endif
switch(write_mode) {
default:
case 0:
/* rotate */
break;
case 1:
goto do_write;
case 2:
break;
case 3:
/* rotate */
break;
}
/* apply logical operation */
switch(func_select) {
case 0:
default:
/* nothing to do */
break;
case 1:
/* and */
break;
case 2:
/* or */
break;
case 3:
/* xor */
break;
}
/* apply bit mask */
/* mask data according to sr[2] */
(val & write_mask);
Log3(("vga: latch: [0x%x] mask=0x%08x val=0x%08x\n",
}
return VINF_SUCCESS;
}
#if defined(IN_RING3)
int dscan);
static inline unsigned int rgb_to_pixel8(unsigned int r, unsigned int g, unsigned b)
{
return ((r >> 5) << 5) | ((g >> 5) << 2) | (b >> 6);
}
static inline unsigned int rgb_to_pixel15(unsigned int r, unsigned int g, unsigned b)
{
return ((r >> 3) << 10) | ((g >> 3) << 5) | (b >> 3);
}
static inline unsigned int rgb_to_pixel16(unsigned int r, unsigned int g, unsigned b)
{
return ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3);
}
static inline unsigned int rgb_to_pixel32(unsigned int r, unsigned int g, unsigned b)
{
return (r << 16) | (g << 8) | b;
}
#define DEPTH 8
#include "DevVGATmpl.h"
#define DEPTH 15
#include "DevVGATmpl.h"
#define DEPTH 16
#include "DevVGATmpl.h"
#define DEPTH 32
#include "DevVGATmpl.h"
static unsigned int rgb_to_pixel8_dup(unsigned int r, unsigned int g, unsigned b)
{
unsigned int col;
col = rgb_to_pixel8(r, g, b);
return col;
}
static unsigned int rgb_to_pixel15_dup(unsigned int r, unsigned int g, unsigned b)
{
unsigned int col;
col = rgb_to_pixel15(r, g, b);
return col;
}
static unsigned int rgb_to_pixel16_dup(unsigned int r, unsigned int g, unsigned b)
{
unsigned int col;
col = rgb_to_pixel16(r, g, b);
return col;
}
static unsigned int rgb_to_pixel32_dup(unsigned int r, unsigned int g, unsigned b)
{
unsigned int col;
col = rgb_to_pixel32(r, g, b);
return col;
}
/* return true if the palette was modified */
static int update_palette16(VGAState *s)
{
int full_update, i;
full_update = 0;
palette = s->last_palette;
for(i = 0; i < 16; i++) {
v = s->ar[i];
else
v = v * 3;
full_update = 1;
}
}
return full_update;
}
/* return true if the palette was modified */
static int update_palette256(VGAState *s)
{
int full_update, i;
int wide_dac;
full_update = 0;
palette = s->last_palette;
v = 0;
== (VBE_DISPI_ENABLED | VBE_DISPI_8BIT_DAC);
for(i = 0; i < 256; i++) {
if (wide_dac)
s->palette[v + 1],
s->palette[v + 2]);
else
full_update = 1;
}
v += 3;
}
return full_update;
}
static void vga_get_offsets(VGAState *s,
{
#ifdef CONFIG_BOCHS_VBE
line_offset = s->vbe_line_offset;
start_addr = s->vbe_start_addr;
line_compare = 65535;
} else
#endif
{
/* compute line_offset in bytes */
line_offset <<= 3;
{
line_offset *= 2;
}
/* starting address */
/* line compare */
}
}
/* update start_addr and line_offset. Return TRUE if modified */
static int update_basic_params(VGAState *s)
{
int full_update;
full_update = 0;
if (line_offset != s->line_offset ||
start_addr != s->start_addr ||
line_compare != s->line_compare) {
s->line_offset = line_offset;
s->start_addr = start_addr;
s->line_compare = line_compare;
full_update = 1;
}
return full_update;
}
static inline int get_depth_index(int depth)
{
switch(depth) {
default:
case 8:
return 0;
case 15:
return 1;
case 16:
return 2;
case 32:
return 3;
}
}
};
};
};
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
};
/*
* Text mode update
* Missing:
* - underline
* - flashing
*/
{
full_update |= update_palette16(s);
palette = s->last_palette;
/* compute font data address (in plane 2) */
v = s->sr[3];
if (offset != s->font_offsets[0]) {
s->font_offsets[0] = offset;
full_update = 1;
}
full_update = 1;
}
/* if the plane 2 was modified since the last display, it
indicates the font may have been modified */
s->plane_updated = 0;
full_update = 1;
}
full_update |= update_basic_params(s);
line_offset = s->line_offset;
s1 = s->CTX_SUFF(vram_ptr) + (s->start_addr * 8); /** @todo r=bird: Add comment why we do *8 instead of *4, it's not so obvious... */
/* double scanning - not for 9-wide modes */
/* total width & height */
cw = 8;
cw = 9;
/* ugly hack for CGA 160x100x16 - explain me the logic */
height = 100;
} else {
}
/* better than nothing: exit if transient size is too big */
return VINF_SUCCESS;
}
if (fFailOnResize)
{
/* The caller does not want to call the pfnResize. */
return VERR_TRY_AGAIN;
}
/* For text modes the direct use of guest VRAM is not implemented, so bpp and cbLine are 0 here. */
s->last_width = width;
s->last_height = height;
full_update = 1;
if (rc == VINF_VGA_RESIZE_IN_PROGRESS)
return rc;
}
if (cursor_offset != s->cursor_offset ||
/* if the cursor position changed, we update the old and new
chars */
if (s->cursor_offset < CH_ATTR_SIZE)
s->last_ch_attr[s->cursor_offset] = ~0;
if (cursor_offset < CH_ATTR_SIZE)
s->last_ch_attr[cursor_offset] = ~0;
s->cursor_offset = cursor_offset;
}
if (cw == 16)
else
ch_attr_ptr = s->last_ch_attr;
cy_start = -1;
cx_max_upd = -1;
cx_min_upd = width;
cx_max = -1;
if (reset_dirty)
*ch_attr_ptr = ch_attr;
#ifdef WORDS_BIGENDIAN
#else
#endif
if (cw != 9) {
} else {
dup9 = 0;
dup9 = 1;
}
if (src == cursor_ptr &&
int line_start, line_last, h;
/* draw the cursor */
/* XXX: check that */
if (cw != 9) {
} else {
}
}
}
}
ch_attr_ptr++;
}
if (cx_max != -1) {
/* Keep track of the bounding rectangle for updates. */
if (cy_start == -1)
if (cx_min_upd > cx_min)
cx_min_upd = cx_min;
if (cx_max_upd < cx_max)
cx_max_upd = cx_max;
} else if (cy_start >= 0) {
/* Flush updates to display. */
cy_start = -1;
cx_max_upd = -1;
cx_min_upd = width;
}
s1 += line_offset;
}
if (cy_start >= 0)
/* Flush any remaining changes to display. */
return VINF_SUCCESS;
}
enum {
};
};
static int vga_get_bpp(VGAState *s)
{
int ret;
#ifdef CONFIG_BOCHS_VBE
} else
#endif
{
ret = 0;
}
return ret;
}
{
#ifdef CONFIG_BOCHS_VBE
} else
#endif
{
}
}
/**
* Performs the display driver resizing when in graphics mode.
*
* This will recalc / update any status data depending on the driver
* properties (bit depth mostly).
*
* @returns VINF_SUCCESS on success.
* @returns VINF_VGA_RESIZE_IN_PROGRESS if the operation wasn't complete.
* @param s Pointer to the vga status.
* @param cx The width.
* @param cy The height.
*/
{
int rc;
#if 0 //def VBOX_WITH_VDMA
/* @todo: we get a second resize here when VBVA is on, while we actually should not */
/* do not do pfnResize in case VBVA is on since all mode changes are performed over VBVA
* we are checking for VDMA state here to ensure this code works only for WDDM driver,
* although we should avoid calling pfnResize for XPDM as well, since pfnResize is actually an extra resize
* event and generally only pfnVBVAxxx calls should be used with HGSMI + VBVA
*
* The reason for doing this for WDDM driver only now is to avoid regressions of the current code */
rc = VINF_SUCCESS;
else
#endif
{
/* Skip the resize if the values are not valid. */
/* Take into account the programmed start address (in DWORDs) of the visible screen. */
rc = s->pDrv->pfnResize(s->pDrv, cBits, s->CTX_SUFF(vram_ptr) + s->start_addr * 4, s->line_offset, cx, cy);
else
{
/* Change nothing in the VGA state. Lets hope the guest will eventually programm correct values. */
return VERR_TRY_AGAIN;
}
}
/* last stuff */
s->last_scr_width = cx;
s->last_scr_height = cy;
s->last_width = cx;
s->last_height = cy;
if (rc == VINF_VGA_RESIZE_IN_PROGRESS)
return rc;
/* update palette */
{
case 16:
default: s->rgb_to_pixel = rgb_to_pixel16_dup; break;
}
if (s->shift_control == 0)
update_palette16(s);
else if (s->shift_control == 1)
update_palette16(s);
return VINF_SUCCESS;
}
/*
* graphic modes
*/
{
int disp_width, multi_run;
uint8_t *d;
int offsets_changed;
disp_width = width;
if (shift_control != s->shift_control ||
double_scan != s->double_scan) {
full_update = 1;
s->shift_control = shift_control;
s->double_scan = double_scan;
}
if (shift_control == 0) {
full_update |= update_palette16(s);
v = VGA_DRAW_LINE4D2;
disp_width <<= 1;
} else {
v = VGA_DRAW_LINE4;
}
bits = 4;
} else if (shift_control == 1) {
full_update |= update_palette16(s);
v = VGA_DRAW_LINE2D2;
disp_width <<= 1;
} else {
v = VGA_DRAW_LINE2;
}
bits = 4;
} else {
switch(s->get_bpp(s)) {
default:
case 0:
full_update |= update_palette256(s);
v = VGA_DRAW_LINE8D2;
bits = 4;
break;
case 8:
full_update |= update_palette256(s);
v = VGA_DRAW_LINE8;
bits = 8;
break;
case 15:
v = VGA_DRAW_LINE15;
bits = 16;
break;
case 16:
v = VGA_DRAW_LINE16;
bits = 16;
break;
case 24:
v = VGA_DRAW_LINE24;
bits = 24;
break;
case 32:
v = VGA_DRAW_LINE32;
bits = 32;
break;
}
}
if ( disp_width != (int)s->last_width
|| height != (int)s->last_height
|| (offsets_changed && !s->fRenderVRAM))
{
if (fFailOnResize)
{
/* The caller does not want to call the pfnResize. */
return VERR_TRY_AGAIN;
}
if (rc != VINF_SUCCESS) /* Return any rc, particularly VINF_VGA_RESIZE_IN_PROGRESS, to the caller. */
return rc;
full_update = 1;
}
if (s->cursor_invalidate)
s->cursor_invalidate(s);
line_offset = s->line_offset;
#if 0
Log(("w=%d h=%d v=%d line_offset=%d cr[0x09]=0x%02x cr[0x17]=0x%02x linecmp=%d sr[0x01]=0x%02x\n",
#endif
y_start = -1;
page_min = 0x7fffffff;
page_max = -1;
y1 = 0;
for(y = 0; y < height; y++) {
* shifted left by two compared to VGA specs.
*/
}
}
/* if wide line, can use another page */
}
/* explicit invalidation for the hardware cursor */
if (update) {
if (y_start < 0)
y_start = y;
if (s->fRenderVRAM)
if (s->cursor_draw_line)
s->cursor_draw_line(s, d, y);
} else {
if (y_start >= 0) {
/* flush to display */
y_start = -1;
}
}
if (!multi_run) {
y1++;
if (y2 == 0) {
addr1 += line_offset;
} else {
--y2;
}
} else {
multi_run--;
}
/* line compare acts on the displayed lines */
if ((uint32_t)y == s->line_compare)
addr1 = 0;
d += linesize;
}
if (y_start >= 0) {
/* flush to display */
}
/* reset modified pages */
}
return VINF_SUCCESS;
}
{
int i, w, val;
uint8_t *d;
return;
if (!full_update)
return;
if (s->last_scr_width <= 0 || s->last_scr_height <= 0)
return;
val = s->rgb_to_pixel(0, 0, 0);
else
val = 0;
for(i = 0; i < (int)s->last_scr_height; i++) {
d += cbScanline;
}
}
static DECLCALLBACK(void) voidUpdateRect(PPDMIDISPLAYCONNECTOR pInterface, uint32_t x, uint32_t y, uint32_t cx, uint32_t cy)
{
}
#define GMODE_TEXT 0
#define GMODE_GRAPH 1
#define GMODE_BLANK 2
{
int rc = VINF_SUCCESS;
int full_update, graphic_mode;
/* nothing to do */
} else {
case 8:
break;
case 15:
break;
default:
case 16:
break;
case 32:
break;
}
if (fUpdateAll) {
/* A full update is requested. Special processing for a "blank" mode is required, because
* the request must process all pending resolution changes.
*
* Appropriate vga_draw_graphic or vga_draw_text function, which checks the resolution change,
* must be called even if the screen has been blanked, but then the function should do no actual
* screen update. To do this, pfnUpdateRect is replaced with a nop.
*/
typedef DECLCALLBACK(void) FNUPDATERECT(PPDMIDISPLAYCONNECTOR pInterface, uint32_t x, uint32_t y, uint32_t cx, uint32_t cy);
typedef FNUPDATERECT *PFNUPDATERECT;
/* Detect the "screen blank" conditions. */
int fBlank = 0;
fBlank = 1;
}
if (fBlank) {
/* Provide a void pfnUpdateRect callback. */
if (s->pDrv) {
}
}
/* Do a complete redraw, which will pick up a new screen resolution. */
s->graphic_mode = GMODE_GRAPH;
} else {
s->graphic_mode = GMODE_TEXT;
}
if (fBlank) {
/* Set the current mode and restore the callback. */
s->graphic_mode = GMODE_BLANK;
if (s->pDrv) {
}
}
return rc;
}
full_update = 0;
} else {
}
if (graphic_mode != s->graphic_mode) {
s->graphic_mode = graphic_mode;
full_update = 1;
}
switch(graphic_mode) {
case GMODE_TEXT:
break;
case GMODE_GRAPH:
break;
case GMODE_BLANK:
default:
break;
}
}
return rc;
}
{
int i;
qemu_put_be32s(f, &s->latch);
qemu_put_8s(f, &s->sr_index);
qemu_put_8s(f, &s->gr_index);
qemu_put_8s(f, &s->ar_index);
qemu_put_be32s(f, &s->ar_flip_flop);
qemu_put_8s(f, &s->cr_index);
qemu_put_8s(f, &s->msr);
qemu_put_8s(f, &s->fcr);
qemu_put_8s(f, &s->st00);
qemu_put_8s(f, &s->st01);
qemu_put_8s(f, &s->dac_state);
qemu_put_8s(f, &s->dac_sub_index);
qemu_put_8s(f, &s->dac_read_index);
qemu_put_8s(f, &s->dac_write_index);
qemu_put_be32s(f, &s->bank_offset);
#ifdef CONFIG_BOCHS_VBE
qemu_put_byte(f, 1);
qemu_put_be16s(f, &s->vbe_index);
for(i = 0; i < VBE_DISPI_INDEX_NB_SAVED; i++)
qemu_put_be16s(f, &s->vbe_regs[i]);
qemu_put_be32s(f, &s->vbe_start_addr);
qemu_put_be32s(f, &s->vbe_line_offset);
#else
qemu_put_byte(f, 0);
#endif
}
{
int is_vbe, i;
qemu_get_be32s(f, &s->latch);
qemu_get_8s(f, &s->sr_index);
qemu_get_8s(f, &s->gr_index);
qemu_get_8s(f, &s->ar_index);
qemu_get_8s(f, &s->cr_index);
qemu_get_8s(f, &s->msr);
qemu_get_8s(f, &s->fcr);
qemu_get_8s(f, &s->st00);
qemu_get_8s(f, &s->st01);
qemu_get_8s(f, &s->dac_state);
qemu_get_8s(f, &s->dac_sub_index);
qemu_get_8s(f, &s->dac_read_index);
qemu_get_8s(f, &s->dac_write_index);
is_vbe = qemu_get_byte(f);
#ifdef CONFIG_BOCHS_VBE
if (!is_vbe)
{
Log(("vga_load: !is_vbe !!\n"));
}
qemu_get_be16s(f, &s->vbe_index);
for(i = 0; i < VBE_DISPI_INDEX_NB_SAVED; i++)
qemu_get_be16s(f, &s->vbe_regs[i]);
recaltulate_data(s, false); /* <- re-calculate the s->vbe_regs[VBE_DISPI_INDEX_VIRT_HEIGHT] since it might be invalid */
qemu_get_be32s(f, &s->vbe_start_addr);
qemu_get_be32s(f, &s->vbe_line_offset);
if (version_id < 2)
qemu_get_be32s(f, &u32Dummy);
#else
if (is_vbe)
{
Log(("vga_load: is_vbe !!\n"));
}
#endif
/* force refresh */
s->graphic_mode = -1;
return 0;
}
/* see vgaR3Construct */
static void vga_init_expand(void)
{
int i, j, v, b;
for(i = 0;i < 256; i++) {
v = 0;
for(j = 0; j < 8; j++) {
v |= ((i >> j) & 1) << (j * 4);
}
expand4[i] = v;
v = 0;
for(j = 0; j < 4; j++) {
v |= ((i >> (2 * j)) & 3) << (j * 4);
}
expand2[i] = v;
}
for(i = 0; i < 16; i++) {
v = 0;
for(j = 0; j < 4; j++) {
b = ((i >> j) & 1);
v |= b << (2 * j);
v |= b << (2 * j + 1);
}
expand4to8[i] = v;
}
}
#endif /* !IN_RING0 */
/* -=-=-=-=-=- all contexts -=-=-=-=-=- */
/**
* Port I/O Handler for VGA OUT operations.
*
* @returns VBox status code.
*
* @param pDevIns The device instance.
* @param pvUser User argument - ignored.
* @param Port Port number used for the IN operation.
* @param u32 The value to output.
* @param cb The value size in bytes.
*/
PDMBOTHCBDECL(int) vgaIOPortWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
{
if (rc != VINF_SUCCESS)
return rc;
if (cb == 1)
else if (cb == 2)
{
}
PDMCritSectLeave(&s->lock);
return VINF_SUCCESS;
}
/**
* Port I/O Handler for VGA IN operations.
*
* @returns VBox status code.
*
* @param pDevIns The device instance.
* @param pvUser User argument - ignored.
* @param Port Port number used for the IN operation.
* @param pu32 Where to store the result.
* @param cb Number of bytes read.
*/
PDMBOTHCBDECL(int) vgaIOPortRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
{
if (rc != VINF_SUCCESS)
return rc;
if (cb == 1)
{
rc = VINF_SUCCESS;
}
else if (cb == 2)
{
rc = VINF_SUCCESS;
}
PDMCritSectLeave(&s->lock);
return rc;
}
/**
* Port I/O Handler for VBE OUT operations.
*
* @returns VBox status code.
*
* @param pDevIns The device instance.
* @param pvUser User argument - ignored.
* @param Port Port number used for the IN operation.
* @param u32 The value to output.
* @param cb The value size in bytes.
*/
PDMBOTHCBDECL(int) vgaIOPortWriteVBEData(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
{
if (rc != VINF_SUCCESS)
return rc;
#ifndef IN_RING3
/*
* This has to be done on the host in order to execute the connector callbacks.
*/
if ( s->vbe_index == VBE_DISPI_INDEX_ENABLE
|| s->vbe_index == VBE_DISPI_INDEX_VBOX_VIDEO)
{
Log(("vgaIOPortWriteVBEData: VBE_DISPI_INDEX_ENABLE - Switching to host...\n"));
PDMCritSectLeave(&s->lock);
return VINF_IOM_HC_IOPORT_WRITE;
}
#endif
#ifdef VBE_BYTEWISE_IO
if (cb == 1)
{
if (!s->fWriteVBEData)
{
if ( (s->vbe_index == VBE_DISPI_INDEX_ENABLE)
&& (u32 & VBE_DISPI_ENABLED))
{
s->fWriteVBEData = false;
PDMCritSectLeave(&s->lock);
return rc;
}
else
{
s->fWriteVBEData = true;
PDMCritSectLeave(&s->lock);
return VINF_SUCCESS;
}
}
else
{
s->fWriteVBEData = false;
cb = 2;
}
}
#endif
{
//#ifdef IN_RC
// /*
// * The VBE_DISPI_INDEX_ENABLE memsets the entire frame buffer.
// * Since we're not mapping the entire framebuffer any longer that
// * has to be done on the host.
// */
// if ( (s->vbe_index == VBE_DISPI_INDEX_ENABLE)
// && (u32 & VBE_DISPI_ENABLED))
// {
// Log(("vgaIOPortWriteVBEData: VBE_DISPI_INDEX_ENABLE & VBE_DISPI_ENABLED - Switching to host...\n"));
// return VINF_IOM_HC_IOPORT_WRITE;
// }
//#endif
PDMCritSectLeave(&s->lock);
return rc;
}
else
PDMCritSectLeave(&s->lock);
return VINF_SUCCESS;
}
/**
* Port I/O Handler for VBE OUT operations.
*
* @returns VBox status code.
*
* @param pDevIns The device instance.
* @param pvUser User argument - ignored.
* @param Port Port number used for the IN operation.
* @param u32 The value to output.
* @param cb The value size in bytes.
*/
PDMBOTHCBDECL(int) vgaIOPortWriteVBEIndex(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
{
if (rc != VINF_SUCCESS)
return rc;
#ifdef VBE_BYTEWISE_IO
if (cb == 1)
{
if (!s->fWriteVBEIndex)
{
s->fWriteVBEIndex = true;
PDMCritSectLeave(&s->lock);
return VINF_SUCCESS;
}
else
{
s->fWriteVBEIndex = false;
PDMCritSectLeave(&s->lock);
return VINF_SUCCESS;
}
}
else
#endif
if (cb == 2)
else
PDMCritSectLeave(&s->lock);
return VINF_SUCCESS;
}
/**
* Port I/O Handler for VBE IN operations.
*
* @returns VBox status code.
*
* @param pDevIns The device instance.
* @param pvUser User argument - ignored.
* @param Port Port number used for the IN operation.
* @param pu32 Where to store the result.
* @param cb Number of bytes to read.
*/
PDMBOTHCBDECL(int) vgaIOPortReadVBEData(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
{
if (rc != VINF_SUCCESS)
return rc;
#ifdef VBE_BYTEWISE_IO
if (cb == 1)
{
if (!s->fReadVBEData)
{
s->fReadVBEData = true;
PDMCritSectLeave(&s->lock);
return VINF_SUCCESS;
}
else
{
s->fReadVBEData = false;
PDMCritSectLeave(&s->lock);
return VINF_SUCCESS;
}
}
else
#endif
if (cb == 2)
{
PDMCritSectLeave(&s->lock);
return VINF_SUCCESS;
}
else if (cb == 4)
{
/* Quick hack for getting the vram size. */
PDMCritSectLeave(&s->lock);
return VINF_SUCCESS;
}
PDMCritSectLeave(&s->lock);
return VERR_IOM_IOPORT_UNUSED;
}
/**
* Port I/O Handler for VBE IN operations.
*
* @returns VBox status code.
*
* @param pDevIns The device instance.
* @param pvUser User argument - ignored.
* @param Port Port number used for the IN operation.
* @param pu32 Where to store the result.
* @param cb Number of bytes to read.
*/
PDMBOTHCBDECL(int) vgaIOPortReadVBEIndex(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
{
if (rc != VINF_SUCCESS)
return rc;
#ifdef VBE_BYTEWISE_IO
if (cb == 1)
{
if (!s->fReadVBEIndex)
{
s->fReadVBEIndex = true;
PDMCritSectLeave(&s->lock);
return VINF_SUCCESS;
}
else
{
s->fReadVBEIndex = false;
PDMCritSectLeave(&s->lock);
return VINF_SUCCESS;
}
}
else
#endif
if (cb == 2)
{
PDMCritSectLeave(&s->lock);
return VINF_SUCCESS;
}
PDMCritSectLeave(&s->lock);
return VERR_IOM_IOPORT_UNUSED;
}
#ifdef VBOX_WITH_HGSMI
#ifdef IN_RING3
/**
* Port I/O Handler for HGSMI OUT operations.
*
* @returns VBox status code.
*
* @param pDevIns The device instance.
* @param pvUser User argument - ignored.
* @param Port Port number used for the operation.
* @param u32 The value to output.
* @param cb The value size in bytes.
*/
static DECLCALLBACK(int) vgaR3IOPortHGSMIWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
{
if (rc != VINF_SUCCESS)
return rc;
if (cb == 4)
{
switch (Port)
{
case VGA_PORT_HGSMI_HOST: /* Host */
{
if(u32 == HGSMIOFFSET_VOID)
{
}
else
#endif
{
}
} break;
case VGA_PORT_HGSMI_GUEST: /* Guest */
{
} break;
default:
{
#ifdef DEBUG_sunlover
#endif
} break;
}
}
else
{
#ifdef DEBUG_sunlover
#endif
}
PDMCritSectLeave(&s->lock);
return VINF_SUCCESS;
}
/**
* Port I/O Handler for HGSMI IN operations.
*
* @returns VBox status code.
*
* @param pDevIns The device instance.
* @param pvUser User argument - ignored.
* @param Port Port number used for the operation.
* @param pu32 Where to store the result.
* @param cb Number of bytes to read.
*/
static DECLCALLBACK(int) vgaR3IOPortHGSMIRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
{
if (rc != VINF_SUCCESS)
return rc;
if (cb == 4)
{
switch (Port)
{
case VGA_PORT_HGSMI_HOST: /* Host */
{
} break;
case VGA_PORT_HGSMI_GUEST: /* Guest */
{
} break;
default:
{
#ifdef DEBUG_sunlover
#endif
} break;
}
}
else
{
#ifdef DEBUG_sunlover
#endif
}
PDMCritSectLeave(&s->lock);
return rc;
}
#endif /* IN_RING3 */
#endif /* VBOX_WITH_HGSMI */
/* -=-=-=-=-=- Guest Context -=-=-=-=-=- */
/*
* Internal. For use inside VGAGCMemoryFillWrite only.
* Macro for apply logical operation and bit mask.
*/
/* apply logical operation */ \
{ \
case 0: \
default: \
/* nothing to do */ \
break; \
case 1: \
/* and */ \
break; \
case 2: \
/* or */ \
break; \
case 3: \
/* xor */ \
break; \
} \
/* apply bit mask */ \
/**
* Legacy VGA memory (0xa0000 - 0xbffff) write hook, to be called from IOM and from the inside of VGADeviceGC.cpp.
* This is the advanced version of vga_mem_writeb function.
*
* @returns VBox status code.
* @param pThis VGA device structure
* @param pvUser User argument - ignored.
* @param GCPhysAddr Physical address of memory to write.
* @param u32Item Data to write, up to 4 bytes.
* @param cbItem Size of data Item, only 1/2/4 bytes is allowed for now.
* @param cItems Number of data items to write.
*/
static int vgaInternalMMIOFill(PVGASTATE pThis, void *pvUser, RTGCPHYS GCPhysAddr, uint32_t u32Item, unsigned cbItem, unsigned cItems)
{
uint32_t b;
unsigned i;
for (i = 0; i < cbItem; i++)
{
u32Item >>= 8;
}
/* convert to VGA memory offset */
/// @todo add check for the end of region
GCPhysAddr &= 0x1ffff;
case 0:
break;
case 1:
if (GCPhysAddr >= 0x10000)
return VINF_SUCCESS;
break;
case 2:
GCPhysAddr -= 0x10000;
if (GCPhysAddr >= 0x8000)
return VINF_SUCCESS;
break;
default:
case 3:
GCPhysAddr -= 0x18000;
if (GCPhysAddr >= 0x8000)
return VINF_SUCCESS;
break;
}
/* chain 4 mode : simplest access */
while (cItems-- > 0)
for (i = 0; i < cbItem; i++)
{
{
}
GCPhysAddr++;
}
while (cItems-- > 0)
for (i = 0; i < cbItem; i++)
{
}
GCPhysAddr++;
}
} else {
/* standard VGA latched access */
default:
case 0:
/* rotate */
for (i = 0; i < cbItem; i++)
{
}
break;
case 1:
for (i = 0; i < cbItem; i++)
break;
case 2:
for (i = 0; i < cbItem; i++)
{
}
break;
case 3:
/* rotate */
for (i = 0; i < cbItem; i++)
{
}
break;
}
/* mask data according to sr[2] */
/* actually write data */
if (cbItem == 1)
{
/* The most frequently case is 1 byte I/O. */
while (cItems-- > 0)
{
((uint32_t *)pThis->CTX_SUFF(vram_ptr))[GCPhysAddr] = (((uint32_t *)pThis->CTX_SUFF(vram_ptr))[GCPhysAddr] & ~write_mask) | (aVal[0] & write_mask);
GCPhysAddr++;
}
}
else if (cbItem == 2)
{
/* The second case is 2 bytes I/O. */
while (cItems-- > 0)
{
((uint32_t *)pThis->CTX_SUFF(vram_ptr))[GCPhysAddr] = (((uint32_t *)pThis->CTX_SUFF(vram_ptr))[GCPhysAddr] & ~write_mask) | (aVal[0] & write_mask);
GCPhysAddr++;
((uint32_t *)pThis->CTX_SUFF(vram_ptr))[GCPhysAddr] = (((uint32_t *)pThis->CTX_SUFF(vram_ptr))[GCPhysAddr] & ~write_mask) | (aVal[1] & write_mask);
GCPhysAddr++;
}
}
else
{
/* And the rest is 4 bytes. */
while (cItems-- > 0)
for (i = 0; i < cbItem; i++)
{
((uint32_t *)pThis->CTX_SUFF(vram_ptr))[GCPhysAddr] = (((uint32_t *)pThis->CTX_SUFF(vram_ptr))[GCPhysAddr] & ~write_mask) | (aVal[i] & write_mask);
GCPhysAddr++;
}
}
}
return VINF_SUCCESS;
}
/**
* Legacy VGA memory (0xa0000 - 0xbffff) write hook, to be called from IOM and from the inside of VGADeviceGC.cpp.
* This is the advanced version of vga_mem_writeb function.
*
* @returns VBox status code.
* @param pDevIns Pointer device instance.
* @param pvUser User argument - ignored.
* @param GCPhysAddr Physical address of memory to write.
* @param u32Item Data to write, up to 4 bytes.
* @param cbItem Size of data Item, only 1/2/4 bytes is allowed for now.
* @param cItems Number of data items to write.
*/
PDMBOTHCBDECL(int) vgaMMIOFill(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, uint32_t u32Item, unsigned cbItem, unsigned cItems)
{
if (rc != VINF_SUCCESS)
return rc;
return rc;
}
/**
* Legacy VGA memory (0xa0000 - 0xbffff) read hook, to be called from IOM.
*
* @returns VBox status code.
* @param pDevIns Pointer device instance.
* @param pvUser User argument - ignored.
* @param GCPhysAddr Physical address of memory to read.
* @param pv Where to store read data.
* @param cb Bytes to read.
*/
PDMBOTHCBDECL(int) vgaMMIORead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb)
{
if (rc != VINF_SUCCESS)
return rc;
switch (cb)
{
case 1:
case 2:
break;
case 4:
break;
case 8:
break;
default:
{
while (cb-- > 0)
{
break;
}
}
}
return rc;
}
/**
* Legacy VGA memory (0xa0000 - 0xbffff) write hook, to be called from IOM.
*
* @returns VBox status code.
* @param pDevIns Pointer device instance.
* @param pvUser User argument - ignored.
* @param GCPhysAddr Physical address of memory to write.
* @param pv Pointer to data.
* @param cb Bytes to write.
*/
PDMBOTHCBDECL(int) vgaMMIOWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void const *pv, unsigned cb)
{
if (rc != VINF_SUCCESS)
return rc;
switch (cb)
{
case 1:
break;
#if 1
case 2:
break;
case 4:
break;
case 8:
break;
#else
case 2:
break;
case 4:
break;
case 8:
break;
#endif
default:
break;
}
return rc;
}
/**
* Handle LFB access.
* @returns VBox status code.
* @param pVM VM handle.
* @param pThis VGA device instance data.
* @param GCPhys The access physical address.
* @param GCPtr The access virtual address (only GC).
*/
{
if (rc != VINF_SUCCESS)
return rc;
/*
* Set page dirty bit.
*/
pThis->fLFBUpdated = true;
/*
* Turn of the write handler for this particular page and make it R/W.
* Then return telling the caller to restart the guest instruction.
* ASSUME: the guest always maps video memory RW.
*/
if (RT_SUCCESS(rc))
{
#ifndef IN_RING3
/* In the SMP case the page table might be removed while we wait for the PGM lock in the trap handler. */
|| rc == VERR_PAGE_NOT_PRESENT,
rc);
#else /* IN_RING3 : We don't have any virtual page address of the access here. */
#endif
return VINF_SUCCESS;
}
return rc;
}
#ifdef IN_RC
/**
* #PF Handler for VBE LFB access.
*
* @returns VBox status code (appropriate for GC return).
* @param pVM VM Handle.
* @param uErrorCode CPU Error code.
* @param pRegFrame Trap register frame.
* @param pvFault The fault address (cr2).
* @param GCPhysFault The GC physical address corresponding to pvFault.
* @param pvUser User argument, ignored.
*/
PDMBOTHCBDECL(int) vgaGCLFBAccessHandler(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, RTGCPHYS GCPhysFault, void *pvUser)
{
}
/**
* #PF Handler for VBE LFB access.
*
* @returns VBox status code (appropriate for GC return).
* @param pVM VM Handle.
* @param uErrorCode CPU Error code.
* @param pRegFrame Trap register frame.
* @param pvFault The fault address (cr2).
* @param GCPhysFault The GC physical address corresponding to pvFault.
* @param pvUser User argument, ignored.
*/
PDMBOTHCBDECL(int) vgaR0LFBAccessHandler(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, RTGCPHYS GCPhysFault, void *pvUser)
{
}
#else /* IN_RING3 */
/**
* HC access handler for the LFB.
*
* @returns VINF_SUCCESS if the handler have carried out the operation.
* @returns VINF_PGM_HANDLER_DO_DEFAULT if the caller should carry out the access operation.
* @param pVM VM Handle.
* @param GCPhys The physical address the guest is writing to.
* @param pvPhys The HC mapping of that address.
* @param enmAccessType The access type.
* @param pvUser User argument.
*/
static DECLCALLBACK(int) vgaR3LFBAccessHandler(PVM pVM, RTGCPHYS GCPhys, void *pvPhys, void *pvBuf, size_t cbBuf, PGMACCESSTYPE enmAccessType, void *pvUser)
{
int rc;
if (RT_SUCCESS(rc))
return VINF_PGM_HANDLER_DO_DEFAULT;
return rc;
}
#endif /* IN_RING3 */
/**
* Port I/O Handler for VGA BIOS IN operations.
*
* @returns VBox status code.
*
* @param pDevIns The device instance.
* @param pvUser User argument - ignored.
* @param Port Port number used for the IN operation.
* @param pu32 Where to store the result.
* @param cb Number of bytes read.
*/
PDMBOTHCBDECL(int) vgaIOPortReadBIOS(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
{
return VERR_IOM_IOPORT_UNUSED;
}
/**
* Port I/O Handler for VGA BIOS OUT operations.
*
* @returns VBox status code.
*
* @param pDevIns The device instance.
* @param pvUser User argument - ignored.
* @param Port Port number used for the IN operation.
* @param u32 The value to output.
* @param cb The value size in bytes.
*/
PDMBOTHCBDECL(int) vgaIOPortWriteBIOS(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
{
static int lastWasNotNewline = 0; /* We are only called in a single-threaded way */
if (rc != VINF_SUCCESS)
return rc;
/*
* VGA BIOS char printing.
*/
if ( cb == 1
&& Port == VBE_PRINTF_PORT)
{
#if 0
switch (u32)
{
default:
}
#else
if (lastWasNotNewline == 0)
Log(("vgabios: "));
if (u32 == '\n')
lastWasNotNewline = 0;
else
lastWasNotNewline = 1;
#endif
return VINF_SUCCESS;
}
/* not in use. */
return VERR_IOM_IOPORT_UNUSED;
}
/* -=-=-=-=-=- Ring 3 -=-=-=-=-=- */
#ifdef IN_RING3
# ifdef VBE_NEW_DYN_LIST
/**
* Port I/O Handler for VBE Extra OUT operations.
*
* @returns VBox status code.
*
* @param pDevIns The device instance.
* @param pvUser User argument - ignored.
* @param Port Port number used for the IN operation.
* @param u32 The value to output.
* @param cb The value size in bytes.
*/
PDMBOTHCBDECL(int) vbeIOPortWriteVBEExtra(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
{
if (rc != VINF_SUCCESS)
return rc;
if (cb == 2)
{
}
else
return VINF_SUCCESS;
}
/**
* Port I/O Handler for VBE Extra IN operations.
*
* @returns VBox status code.
*
* @param pDevIns The device instance.
* @param pvUser User argument - ignored.
* @param Port Port number used for the IN operation.
* @param pu32 Where to store the result.
* @param cb Number of bytes read.
*/
PDMBOTHCBDECL(int) vbeIOPortReadVBEExtra(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
{
if (rc != VINF_SUCCESS)
return rc;
{
Log(("vbeIOPortReadVBEExtra: Requested number of 64k video banks\n"));
rc = VINF_SUCCESS;
}
else
{
*pu32 = 0;
Log(("vbeIOPortReadVBEExtra: Requested address is out of VBE data!!! Address=%#x(%d) cbVBEExtraData=%#x(%d)\n",
pThis->u16VBEExtraAddress, pThis->u16VBEExtraAddress, pThis->cbVBEExtraData, pThis->cbVBEExtraData));
rc = VINF_SUCCESS;
}
else
if (cb == 1)
{
rc = VINF_SUCCESS;
}
else
if (cb == 2)
{
rc = VINF_SUCCESS;
}
else
{
}
return rc;
}
# endif /* VBE_NEW_DYN_LIST */
/**
* Parse the logo bitmap data at init time.
*
* @returns VBox status code.
*
* @param pThis The VGA instance data.
*/
{
uint16_t i;
/*
* Get bitmap header data
*/
{
{
case BMP_HEADER_OS21:
pThis->cLogoUsedColors = 0;
break;
case BMP_HEADER_OS22:
break;
case BMP_HEADER_WIN3:
break;
default:
AssertMsgFailed(("Unsupported bitmap header.\n"));
break;
}
{
return VERR_INVALID_PARAMETER;
}
{
return VERR_INVALID_PARAMETER;
}
{
return VERR_INVALID_PARAMETER;
}
{
return VERR_INVALID_PARAMETER;
}
{
return VERR_INVALID_PARAMETER;
}
/*
* Read bitmap palette
*/
if (!pThis->cLogoUsedColors)
else
if (pThis->cLogoPalEntries)
{
const uint8_t *pu8Pal = pThis->pu8Logo + sizeof(LOGOHDR) + sizeof(BMPINFO) + pWinHdr->Size; /* ASSUMES Size location (safe) */
for (i = 0; i < pThis->cLogoPalEntries; i++)
{
uint16_t j;
for (j = 0; j < 3; j++)
{
u32Pal <<= 8;
u32Pal |= b;
}
pu8Pal++; /* skip unused byte */
}
}
/*
* Bitmap data offset
*/
}
return VINF_SUCCESS;
}
/**
* Show logo bitmap data.
*
* @returns VBox status code.
*
* @param cbDepth Logo depth.
* @param xLogo Logo X position.
* @param yLogo Logo Y position.
* @param cxLogo Logo width.
* @param cyLogo Logo height.
* @param pu32Palette Palette data.
* @param pu8Src Source buffer.
* @param pu8Dst Destination buffer.
*/
static void vbeShowBitmap(uint16_t cBits, uint16_t xLogo, uint16_t yLogo, uint16_t cxLogo, uint16_t cyLogo, uint8_t iStep,
{
uint16_t i;
size_t cbPadBytes = 0;
switch (cBits)
{
case 1:
cbPadBytes = 0;
break;
case 4:
cbPadBytes = 0;
cbPadBytes = 3;
cbPadBytes = 2;
else
cbPadBytes = 1;
break;
case 8:
break;
case 24:
break;
}
uint8_t j = 0, c = 0;
while (cyLeft-- > 0)
{
if (cBits != 1)
j = 0;
for (i = 0; i < cxLogo; i++)
{
switch (cBits)
{
case 1:
{
if (!j)
c = *pu8Src++;
c >>= 1;
if (pix)
{
*pu8TmpPtr++;
}
else
{
pu8TmpPtr += 4;
}
j = (j + 1) % 8;
break;
}
case 4:
{
if (!j)
c = *pu8Src++;
c <<= 4;
*pu8TmpPtr++;
j = (j + 1) % 2;
break;
}
case 8:
{
*pu8TmpPtr++;
break;
}
case 24:
*pu8TmpPtr++;
break;
}
}
pu8Src += cbPadBytes;
}
}
/**
* Port I/O Handler for BIOS Logo OUT operations.
*
* @returns VBox status code.
*
* @param pDevIns The device instance.
* @param pvUser User argument - ignored.
* @param Port Port number used for the IN operation.
* @param u32 The value to output.
* @param cb The value size in bytes.
*/
PDMBOTHCBDECL(int) vbeIOPortWriteCMDLogo(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
{
if (cb == 2)
{
/* Get the logo command */
switch (u32 & 0xFF00)
{
case LOGO_CMD_SET_OFFSET:
break;
case LOGO_CMD_SHOW_BMP:
{
/* Check VRAM size */
break;
else
/* Clear screen - except on power on... */
if (!pThis->fLogoClearScreen)
{
/* Clear vram */
for (int i = 0; i < LOGO_MAX_WIDTH; i++)
{
for (int j = 0; j < LOGO_MAX_HEIGHT; j++)
*pu32TmpPtr++ = 0;
}
pThis->fLogoClearScreen = true;
}
/* Show the bitmap. */
/* Show the 'Press F12...' text. */
&g_abLogoF12BootText[0], pu8Dst);
/* Blit the offscreen buffer. */
{
for (int i = 0; i < LOGO_MAX_WIDTH; i++)
{
for (int j = 0; j < LOGO_MAX_HEIGHT; j++)
*pu32TmpDst++ = *pu32TmpSrc++;
}
}
/* Set the dirty flags. */
while (offDirty <= LOGO_MAX_SIZE)
{
}
break;
}
default:
break;
}
return VINF_SUCCESS;
}
return VINF_SUCCESS;
}
/**
* Port I/O Handler for BIOS Logo IN operations.
*
* @returns VBox status code.
*
* @param pDevIns The device instance.
* @param pvUser User argument - ignored.
* @param Port Port number used for the IN operation.
* @param pu32 Where to store the result.
* @param cb Number of bytes read.
*/
PDMBOTHCBDECL(int) vbeIOPortReadCMDLogo(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
{
PRTUINT64U p;
{
Log(("vbeIOPortReadCMDLogo: Requested address is out of Logo data!!! offLogoData=%#x(%d) cbLogo=%#x(%d)\n",
return VINF_SUCCESS;
}
switch (cb)
{
//case 8: *pu32 = p->au64[0]; break;
default: AssertFailed(); break;
}
Log(("vbeIOPortReadCMDLogo: LogoOffset=%#x(%d) cb=%#x %.*Rhxs\n", pThis->offLogoData, pThis->offLogoData, cb, cb, pu32));
return VINF_SUCCESS;
}
/**
* Info handler, device version. Dumps several interesting bits of the
* VGA state that are difficult to decode from the registers.
*
* @param pDevIns Device instance which registered the info.
* @param pHlp Callback functions for doing output.
* @param pszArgs Argument string. Optional and specific to the handler.
*/
{
int is_graph, double_scan;
int w, h, char_height, char_dots;
vga_retrace_s *r = &s->retrace_state;
h = val;
if (!is_graph)
{
char_height = val;
}
if (s->fRealRetrace)
{
}
}
/**
* Info handler, device version. Dumps VGA memory formatted as
* ASCII text, no attributes. Only looks at the first page.
*
* @param pDevIns Device instance which registered the info.
* @param pHlp Callback functions for doing output.
* @param pszArgs Argument string. Optional and specific to the handler.
*/
{
{
if (pbSrc)
{
/*
* Figure out the display size and where the text is.
*
* Note! We're cutting quite a few corners here and this code could
* do with some brushing up. Dumping from the start of the
* frame buffer is done intentionally so that we're more
* likely to obtain the full scrollback of a linux panic.
*/
if (!cbLine)
if (uLines < 25)
uLines = 25;
{
/*
* Do the dumping.
*/
{
{
if (RT_C_IS_PRINT(*pbSrc))
else
}
}
}
else
}
else
}
else
}
/**
* Info handler, device version. Dumps VGA Sequencer registers.
*
* @param pDevIns Device instance which registered the info.
* @param pHlp Callback functions for doing output.
* @param pszArgs Argument string. Optional and specific to the handler.
*/
{
unsigned i;
for (i = 0; i < 5; ++i)
{
}
}
/**
* Info handler, device version. Dumps VGA CRTC registers.
*
* @param pDevIns Device instance which registered the info.
* @param pHlp Callback functions for doing output.
* @param pszArgs Argument string. Optional and specific to the handler.
*/
{
unsigned i;
for (i = 0; i < 10; ++i)
{
}
for (i = 10; i < 20; ++i)
{
}
for (i = 20; i < 25; ++i)
{
}
}
/**
* Info handler, device version. Dumps VGA Graphics Controller registers.
*
* @param pDevIns Device instance which registered the info.
* @param pHlp Callback functions for doing output.
* @param pszArgs Argument string. Optional and specific to the handler.
*/
{
unsigned i;
for (i = 0; i < 9; ++i)
{
}
}
/**
* Info handler, device version. Dumps VGA Sequencer registers.
*
* @param pDevIns Device instance which registered the info.
* @param pHlp Callback functions for doing output.
* @param pszArgs Argument string. Optional and specific to the handler.
*/
{
unsigned i;
for (i = 0; i < 0x10; ++i)
{
}
for (i = 0x10; i <= 0x14; ++i)
{
}
}
/**
* Info handler, device version. Dumps VGA DAC registers.
*
* @param pDevIns Device instance which registered the info.
* @param pHlp Callback functions for doing output.
* @param pszArgs Argument string. Optional and specific to the handler.
*/
{
unsigned i;
for (i = 0; i < 0x100; ++i)
{
}
}
/**
* Info handler, device version. Dumps VBE registers.
*
* @param pDevIns Device instance which registered the info.
* @param pHlp Callback functions for doing output.
* @param pszArgs Argument string. Optional and specific to the handler.
*/
{
{
return;
}
s->vbe_regs[VBE_DISPI_INDEX_BPP]);
}
/* -=-=-=-=-=- Ring 3: IBase -=-=-=-=-=- */
/**
* @interface_method_impl{PDMIBASE,pfnQueryInterface}
*/
{
#endif
return NULL;
}
/* -=-=-=-=-=- Ring 3: Dummy IDisplayConnector -=-=-=-=-=- */
/**
* Resize the display.
* This is called when the resolution changes. This usually happens on
* request from the guest os, but may also happen as the result of a reset.
*
* @param pInterface Pointer to this interface.
* @param cx New display width.
* @param cy New display height
* @thread The emulation thread.
*/
static DECLCALLBACK(int) vgaDummyResize(PPDMIDISPLAYCONNECTOR pInterface, uint32_t bpp, void *pvVRAM, uint32_t cbLine, uint32_t cx, uint32_t cy)
{
return VINF_SUCCESS;
}
/**
* Update a rectangle of the display.
* PDMIDISPLAYPORT::pfnUpdateDisplay is the caller.
*
* @param pInterface Pointer to this interface.
* @param x The upper left corner x coordinate of the rectangle.
* @param y The upper left corner y coordinate of the rectangle.
* @param cx The width of the rectangle.
* @param cy The height of the rectangle.
* @thread The emulation thread.
*/
static DECLCALLBACK(void) vgaDummyUpdateRect(PPDMIDISPLAYCONNECTOR pInterface, uint32_t x, uint32_t y, uint32_t cx, uint32_t cy)
{
}
/**
* Refresh the display.
*
* The interval between these calls is set by
* PDMIDISPLAYPORT::pfnSetRefreshRate(). The driver should call
* PDMIDISPLAYPORT::pfnUpdateDisplay() if it wishes to refresh the
* display. PDMIDISPLAYPORT::pfnUpdateDisplay calls pfnUpdateRect with
* the changed rectangles.
*
* @param pInterface Pointer to this interface.
* @thread The emulation thread.
*/
{
}
/* -=-=-=-=-=- Ring 3: IDisplayPort -=-=-=-=-=- */
/** Converts a display port interface pointer to a vga state pointer. */
#define IDISPLAYPORT_2_VGASTATE(pInterface) ( (PVGASTATE)((uintptr_t)pInterface - RT_OFFSETOF(VGASTATE, IPort)) )
/**
* Update the display with any changed regions.
*
* @param pInterface Pointer to this interface.
* @see PDMIKEYBOARDPORT::pfnUpdateDisplay() for details.
*/
{
#ifndef VBOX_WITH_HGSMI
/* This should be called only in non VBVA mode. */
#else
{
return VINF_SUCCESS;
}
#endif /* VBOX_WITH_HGSMI */
{
pThis->fHasDirtyBits = false;
}
if (pThis->fRemappedVGA)
{
pThis->fRemappedVGA = false;
}
if (rc != VINF_SUCCESS)
{
return rc;
}
return VINF_SUCCESS;
}
/* Internal worker called under pThis->lock. */
{
/* The dirty bits array has been just cleared, reset handlers as well. */
{
}
if (pThis->fRemappedVGA)
{
pThis->fRemappedVGA = false;
}
return vga_update_display(pThis, true, false, true);
}
/**
* Update the entire display.
*
* @param pInterface Pointer to this interface.
* @see PDMIKEYBOARDPORT::pfnUpdateDisplayAll() for details.
*/
{
/* This is called both in VBVA mode and normal modes. */
#ifdef DEBUG_sunlover
LogFlow(("vgaPortUpdateDisplayAll\n"));
#endif /* DEBUG_sunlover */
return rc;
}
/**
* Sets the refresh rate and restart the timer.
*
* @returns VBox status code.
* @param pInterface Pointer to this interface.
* @param cMilliesInterval Number of millis between two refreshes.
* @see PDMIKEYBOARDPORT::pfnSetRefreshRate() for details.
*/
static DECLCALLBACK(int) vgaPortSetRefreshRate(PPDMIDISPLAYPORT pInterface, uint32_t cMilliesInterval)
{
if (cMilliesInterval)
}
/** @copydoc PDMIDISPLAYPORT::pfnQueryColorDepth */
{
if (!pcBits)
return VERR_INVALID_PARAMETER;
return VINF_SUCCESS;
}
/**
* Create a 32-bbp screenshot of the display. Size of the bitmap scanline in bytes is 4*width.
*
* @param pInterface Pointer to this interface.
* @param ppu8Data Where to store the pointer to the allocated buffer.
* @param pcbData Where to store the actual size of the bitmap.
* @param pcx Where to store the width of the bitmap.
* @param pcy Where to store the height of the bitmap.
* @see PDMIDISPLAYPORT::pfnTakeScreenshot() for details.
*/
static DECLCALLBACK(int) vgaPortTakeScreenshot(PPDMIDISPLAYPORT pInterface, uint8_t **ppu8Data, size_t *pcbData, uint32_t *pcx, uint32_t *pcy)
{
LogFlow(("vgaPortTakeScreenshot: ppu8Data=%p pcbData=%p pcx=%p pcy=%p\n", ppu8Data, pcbData, pcx, pcy));
/*
* Validate input.
*/
return VERR_INVALID_PARAMETER;
/*
* Get screenshot. This function will fail if a resize is required.
* So there is not need to do a 'updateDisplayAll' before taking screenshot.
*/
/*
* The display connector interface is temporarily replaced with the fake one.
*/
/*
* Allocate the buffer for 32 bits per pixel bitmap.
*/
/* The size can't be zero or greater than the size of the VRAM.
* Inconsistent VGA device state can cause the incorrect size values.
*/
{
{
rc = VERR_NO_MEMORY;
}
else
{
/*
* Only 3 methods, assigned below, will be called during the screenshot update.
* All other are already set to NULL.
*/
/* Save & replace state data. */
/* Make the screenshot.
*
* The second parameter is 'false' because the current display state is being rendered to an
* external buffer using a fake connector. That is if display is blanked, we expect a black
* screen in the external buffer.
* If there is a pending resize, the function will fail.
*/
/* Restore. */
if (rc == VINF_SUCCESS)
{
/*
* Return the result.
*/
*pcbData = cbRequired;
}
else
{
/* If we do not return a success, then the data buffer must be freed. */
}
}
}
else
LogFlow(("vgaPortTakeScreenshot: returns %Rrc (cbData=%d cx=%d cy=%d)\n", rc, cbRequired, Connector.cx, Connector.cy));
return rc;
}
/**
* Free a screenshot buffer allocated in vgaPortTakeScreenshot.
*
* @param pInterface Pointer to this interface.
* @param pu8Data Pointer returned by vgaPortTakeScreenshot.
* @see PDMIDISPLAYPORT::pfnFreeScreenshot() for details.
*/
{
}
/**
* Copy bitmap to the display.
*
* @param pInterface Pointer to this interface.
* @param pvData Pointer to the bitmap bits.
* @param x The upper left corner x coordinate of the destination rectangle.
* @param y The upper left corner y coordinate of the destination rectangle.
* @param cx The width of the source and destination rectangles.
* @param cy The height of the source and destination rectangles.
* @see PDMIDISPLAYPORT::pfnDisplayBlt() for details.
*/
static DECLCALLBACK(int) vgaPortDisplayBlt(PPDMIDISPLAYPORT pInterface, const void *pvData, uint32_t x, uint32_t y, uint32_t cx, uint32_t cy)
{
int rc = VINF_SUCCESS;
/*
* Validate input.
*/
if ( pvData
{
/*
* Determine bytes per pixel in the destination buffer.
*/
size_t cbPixelDst = 0;
{
case 8:
cbPixelDst = 1;
break;
case 15:
case 16:
cbPixelDst = 2;
break;
case 24:
cbPixelDst = 3;
break;
case 32:
cbPixelDst = 4;
break;
default:
break;
}
if (RT_SUCCESS(rc))
{
/*
* The blitting loop.
*/
vga_draw_line_func *pfnVgaDrawLine = vga_draw_line_table[VGA_DRAW_LINE32 * 4 + get_depth_index(pThis->pDrv->cBits)];
while (cyLeft-- > 0)
{
}
/*
* Invalidate the area.
*/
}
}
else
return rc;
}
static DECLCALLBACK(void) vgaPortUpdateDisplayRect (PPDMIDISPLAYPORT pInterface, int32_t x, int32_t y, uint32_t w, uint32_t h)
{
uint32_t v;
#ifdef DEBUG_sunlover
LogFlow(("vgaPortUpdateDisplayRect: %d,%d %dx%d\n", x, y, w, h));
#endif /* DEBUG_sunlover */
/* Check if there is something to do at all. */
if (!s->fRenderVRAM)
{
/* The framebuffer uses the guest VRAM directly. */
#ifdef DEBUG_sunlover
LogFlow(("vgaPortUpdateDisplayRect: nothing to do fRender is false.\n"));
#endif /* DEBUG_sunlover */
return;
}
/* Correct negative x and y coordinates. */
if (x < 0)
{
x += w; /* Compute xRight which is also the new width. */
w = (x < 0) ? 0 : x;
x = 0;
}
if (y < 0)
{
y += h; /* Compute yBottom, which is also the new height. */
h = (y < 0) ? 0 : y;
y = 0;
}
/* Also check if coords are greater than the display resolution. */
{
// x < 0 is not possible here
}
{
// y < 0 is not possible here
}
#ifdef DEBUG_sunlover
LogFlow(("vgaPortUpdateDisplayRect: %d,%d %dx%d (corrected coords)\n", x, y, w, h));
#endif /* DEBUG_sunlover */
/* Check if there is something to do at all. */
if (w == 0 || h == 0)
{
/* Empty rectangle. */
#ifdef DEBUG_sunlover
LogFlow(("vgaPortUpdateDisplayRect: nothing to do: %dx%d\n", w, h));
#endif /* DEBUG_sunlover */
PDMCritSectLeave(&s->lock);
return;
}
/** @todo This method should be made universal and not only for VBVA.
* changed.
*/
/* Choose the rendering function. */
switch(s->get_bpp(s))
{
default:
case 0:
/* A LFB mode is already disabled, but the callback is still called
* by Display because VBVA buffer is being flushed.
* Nothing to do, just return.
*/
PDMCritSectLeave(&s->lock);
return;
case 8:
v = VGA_DRAW_LINE8;
break;
case 15:
v = VGA_DRAW_LINE15;
break;
case 16:
v = VGA_DRAW_LINE16;
break;
case 24:
v = VGA_DRAW_LINE24;
break;
case 32:
v = VGA_DRAW_LINE32;
break;
}
/* Compute source and destination addresses and pitches. */
/* Assume that rendering is performed only on visible part of VRAM.
* This is true because coordinates were verified.
*/
pu8Src = s->vram_ptrR3;
/* Render VRAM to framebuffer. */
#ifdef DEBUG_sunlover
LogFlow(("vgaPortUpdateDisplayRect: dst: %p, %d, %d. src: %p, %d, %d\n", pu8Dst, cbLineDst, cbPixelDst, pu8Src, cbLineSrc, cbPixelSrc));
#endif /* DEBUG_sunlover */
while (h-- > 0)
{
}
PDMCritSectLeave(&s->lock);
#ifdef DEBUG_sunlover
LogFlow(("vgaPortUpdateDisplayRect: completed.\n"));
#endif /* DEBUG_sunlover */
}
uint32_t w,
uint32_t h,
{
uint32_t v;
#ifdef DEBUG_sunlover
#endif /* DEBUG_sunlover */
uint32_t wCorrected = w;
uint32_t hCorrected = h;
/* Correct source coordinates to be within the source bitmap. */
if (xSrcCorrected < 0)
{
xSrcCorrected = 0;
}
if (ySrcCorrected < 0)
{
ySrcCorrected = 0;
}
/* Also check if coords are greater than the display resolution. */
{
/* xSrcCorrected < 0 is not possible here */
}
{
/* y < 0 is not possible here */
}
#ifdef DEBUG_sunlover
LogFlow(("vgaPortCopyRect: %d,%d %dx%d (corrected coords)\n", xSrcCorrected, ySrcCorrected, wCorrected, hCorrected));
#endif /* DEBUG_sunlover */
/* Check if there is something to do at all. */
if (wCorrected == 0 || hCorrected == 0)
{
/* Empty rectangle. */
#ifdef DEBUG_sunlover
#endif /* DEBUG_sunlover */
return VINF_SUCCESS;
}
/* Check that the corrected source rectangle is within the destination.
* Note: source rectangle is adjusted, but the target must be large enough.
*/
if ( xDst < 0
|| yDst < 0
{
return VERR_INVALID_PARAMETER;
}
/* Choose the rendering function. */
switch(u32SrcBitsPerPixel)
{
default:
case 0:
/* Nothing to do, just return. */
return VINF_SUCCESS;
case 8:
v = VGA_DRAW_LINE8;
break;
case 15:
v = VGA_DRAW_LINE15;
break;
case 16:
v = VGA_DRAW_LINE16;
break;
case 24:
v = VGA_DRAW_LINE24;
break;
case 32:
v = VGA_DRAW_LINE32;
break;
}
/* Compute source and destination addresses and pitches. */
#ifdef DEBUG_sunlover
LogFlow(("vgaPortCopyRect: dst: %p, %d, %d. src: %p, %d, %d\n", pu8DstPtr, cbLineDst, cbPixelDst, pu8SrcPtr, cbLineSrc, cbPixelSrc));
#endif /* DEBUG_sunlover */
while (hCorrected-- > 0)
{
}
PDMCritSectLeave(&s->lock);
#ifdef DEBUG_sunlover
LogFlow(("vgaPortCopyRect: completed.\n"));
#endif /* DEBUG_sunlover */
return VINF_SUCCESS;
}
{
s->fRenderVRAM = fRender;
}
{
if (pThis->cMilliesRefreshInterval)
}
/* -=-=-=-=-=- Ring 3: PCI Device -=-=-=-=-=- */
/**
*
* @return VBox status code.
* @param pPciDev Pointer to PCI device. Use pPciDev->pDevIns to get the device instance.
* @param iRegion The region number.
* @param GCPhysAddress Physical address of the region. If iType is PCI_ADDRESS_SPACE_IO, this is an
* I/O port, else it's a physical address.
* This address is *NOT* relative to pci_mem_base like earlier!
* @param enmType One of the PCI_ADDRESS_SPACE_* values.
*/
static DECLCALLBACK(int) vgaR3IORegionMap(PPCIDEVICE pPciDev, /*unsigned*/ int iRegion, RTGCPHYS GCPhysAddress, uint32_t cb, PCIADDRESSSPACE enmType)
{
int rc;
LogFlow(("vgaR3IORegionMap: iRegion=%d GCPhysAddress=%RGp cb=%#x enmType=%d\n", iRegion, GCPhysAddress, cb, enmType));
if (GCPhysAddress != NIL_RTGCPHYS)
{
/*
* Mapping the VRAM.
*/
if (RT_SUCCESS(rc))
{
"VGA LFB");
if (RT_SUCCESS(rc))
}
}
else
{
/*
* Unmapping of the VRAM in progress.
* Deregister the access handler so PGM doesn't get upset.
*/
pThis->GCPhysVRAM = 0;
}
return rc;
}
/* -=-=-=-=-=- Ring3: Misc Wrappers & Sidekicks -=-=-=-=-=- */
/**
* Saves a important bits of the VGA device config.
*
* @param pThis The VGA instance data.
* @param pSSM The saved state handle.
*/
{
}
/**
* @copydoc FNSSMDEVLIVEEXEC
*/
{
return VINF_SSM_DONT_CALL_AGAIN;
}
/**
* @copydoc FNSSMDEVSAVEPREP
*/
{
#ifdef VBOX_WITH_VIDEOHWACCEL
#else
return VINF_SUCCESS;
#endif
}
{
#ifdef VBOX_WITH_VIDEOHWACCEL
#else
return VINF_SUCCESS;
#endif
}
/**
* @copydoc FNSSMDEVSAVEEXEC
*/
{
#ifdef VBOX_WITH_VDMA
#endif
#ifdef VBOX_WITH_HGSMI
SSMR3PutBool(pSSM, true);
# ifdef VBOX_WITH_VDMA
# endif
return rc;
#else
SSMR3PutBool(pSSM, false);
return VINF_SUCCESS;
#endif
}
/**
* @copydoc FNSSMDEVSAVEEXEC
*/
static DECLCALLBACK(int) vgaR3LoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)
{
int rc;
{
/* Check the config */
return SSMR3SetCfgError(pSSM, RT_SRC_POS, N_("VRAM size changed: config=%#x state=%#x"), pThis->vram_size, cbVRam);
return SSMR3SetCfgError(pSSM, RT_SRC_POS, N_("Monitor count changed: config=%u state=%u"), pThis->cMonitors, cMonitors);
}
if (uPass == SSM_PASS_FINAL)
{
if (RT_FAILURE(rc))
return rc;
{
}
if (fWithHgsmi)
{
#ifdef VBOX_WITH_HGSMI
#else
return SSMR3SetCfgError(pSSM, RT_SRC_POS, N_("HGSMI is not compiled in, but it is present in the saved state"));
#endif
}
}
return VINF_SUCCESS;
}
/**
* @copydoc FNSSMDEVLOADDONE
*/
{
#ifdef VBOX_WITH_HGSMI
#else
return VINF_SUCCESS;
#endif
}
/* -=-=-=-=-=- Ring 3: Device callbacks -=-=-=-=-=- */
/**
* Reset notification.
*
* @returns VBox status.
* @param pDevIns The device instance data.
*/
{
char *pchStart;
char *pchEnd;
LogFlow(("vgaReset\n"));
#ifdef VBOX_WITH_HGSMI
#endif /* VBOX_WITH_HGSMI */
/* Clear the VRAM ourselves. */
/*
* Zero most of it.
*
* Unlike vga_reset we're leaving out a few members which we believe
* must remain unchanged....
*/
/* 1st part. */
/* 2nd part. */
/*
* Restore and re-init some bits.
*/
#ifdef CONFIG_BOCHS_VBE
#endif /* CONFIG_BOCHS_VBE */
/*
* Reset the LBF mapping.
*/
pThis->fLFBUpdated = false;
if ( ( pThis->fGCEnabled
|| pThis->fR0Enabled)
&& pThis->GCPhysVRAM
{
}
if (pThis->fRemappedVGA)
{
pThis->fRemappedVGA = false;
}
/*
* Reset the logo data.
*/
pThis->offLogoData = 0;
/* notify port handler */
/* Reset latched access mask. */
pThis->cLatchAccesses = 0;
pThis->u64LastLatchedAccess = 0;
/* Reset retrace emulation. */
}
/**
* Device relocation callback.
*
* @param pDevIns Pointer to the device instance.
* @param offDelta The relocation delta relative to the old location.
*
* @see FNPDMDEVRELOCATE for details.
*/
{
if (offDelta)
{
}
}
/**
* Attach command.
*
* This is called to let the device attach to a driver for a specified LUN
* during runtime. This is not called during VM construction, the device
* constructor have to attach to all the available drivers.
*
* This is like plugging in the monitor after turning on the PC.
*
* @returns VBox status code.
* @param pDevIns The device instance.
* @param iLUN The logical unit which is being detached.
* @param fFlags Flags, combination of the PDMDEVATT_FLAGS_* \#defines.
*/
{
("VGA device does not support hotplugging\n"),
switch (iLUN)
{
/* LUN #0: Display port. */
case 0:
{
if (RT_SUCCESS(rc))
{
{
/* pThis->pDrv->pu8Data can be NULL when there is no framebuffer. */
rc = VINF_SUCCESS;
else
{
}
#ifdef VBOX_WITH_VIDEOHWACCEL
if(rc == VINF_SUCCESS)
{
if (rc != VERR_NOT_IMPLEMENTED)
}
#endif
}
else
{
}
}
else if (rc == VERR_PDM_NO_ATTACHED_DRIVER)
{
Log(("%s/%d: warning: no driver attached to LUN #0!\n", pDevIns->pReg->szName, pDevIns->iInstance));
rc = VINF_SUCCESS;
}
else
return rc;
}
default:
return VERR_PDM_NO_SUCH_LUN;
}
}
/**
* Detach notification.
*
* This is called when a driver is detaching itself from a LUN of the device.
* The device should adjust it's state to reflect this.
*
* This is like unplugging the monitor while the PC is still running.
*
* @param pDevIns The device instance.
* @param iLUN The logical unit which is being detached.
* @param fFlags Flags, combination of the PDMDEVATT_FLAGS_* \#defines.
*/
{
/*
* Reset the interfaces and update the controller state.
*/
("VGA device does not support hotplugging\n"));
switch (iLUN)
{
/* LUN #0: Display port. */
case 0:
break;
default:
break;
}
}
/**
* Destruct a device instance.
*
* Most VM resources are freed by the VM. This callback is provided so that any non-VM
* resources can be freed correctly.
*
* @param pDevIns The device instance data.
*/
{
#ifdef VBE_NEW_DYN_LIST
LogFlow(("vgaR3Destruct:\n"));
#ifdef VBOX_WITH_VDMA
#endif
/*
* Free MM heap pointers.
*/
if (pThis->pu8VBEExtraData)
{
}
#endif
if (pThis->pu8VgaBios)
{
}
if (pThis->pszVgaBiosFile)
{
}
if (pThis->pszLogoFile)
{
}
return VINF_SUCCESS;
}
/**
* Adjust VBE mode information
*
* Depending on the configured VRAM size, certain parts of VBE mode
* information must be updated.
*
* @param pThis The device instance data.
* @param pMode The mode information structure.
*/
{
int maxPage;
int bpl;
/* For 4bpp modes, the planes are "stacked" on top of each other. */
/* The "number of image pages" is really the max page index... */
if (maxPage > 255)
}
/**
* @interface_method_impl{PDMDEVREG,pfnConstruct}
*/
{
static bool s_fExpandDone = false;
int rc;
unsigned i;
#ifdef VBE_NEW_DYN_LIST
unsigned cb;
#endif
/*
* Init static data.
*/
if (!s_fExpandDone)
{
s_fExpandDone = true;
}
/*
* Validate configuration.
*/
"MonitorCount\0"
"GCEnabled\0"
"R0Enabled\0"
"FadeIn\0"
"FadeOut\0"
"LogoTime\0"
"LogoFile\0"
"ShowBootMenu\0"
"BiosRom\0"
"RealRetrace\0"
"CustomVideoModes\0"
"HeightReduction\0"
"CustomVideoMode1\0"
"CustomVideoMode2\0"
"CustomVideoMode3\0"
"CustomVideoMode4\0"
"CustomVideoMode5\0"
"CustomVideoMode6\0"
"CustomVideoMode7\0"
"CustomVideoMode8\0"
"CustomVideoMode9\0"
"CustomVideoMode10\0"
"CustomVideoMode11\0"
"CustomVideoMode12\0"
"CustomVideoMode13\0"
"CustomVideoMode14\0"
"CustomVideoMode15\0"
"CustomVideoMode16\0"
"MaxBiosXRes\0"
"MaxBiosYRes\0"))
N_("Invalid configuration for vga device"));
/*
* Init state data.
*/
if (pThis->vram_size & (_256K - 1)) /* Make sure there are no partial banks even in planar modes. */
Log(("VGA: VRamSize=%#x fGCenabled=%RTbool fR0Enabled=%RTbool\n", pThis->vram_size, pThis->fGCEnabled, pThis->fR0Enabled));
/* The PCI devices configuration. */
#if defined(VBOX_WITH_HGSMI) && (defined(VBOX_WITH_VIDEOHWACCEL) || defined(VBOX_WITH_VDMA) || defined(VBOX_WITH_WDDM))
#endif
/* The LBF access handler - error handling is better here than in the map function. */
rc = PDMR3LdrGetSymbolRCLazy(pVM, pDevIns->pReg->szRCMod, NULL, "vgaGCLFBAccessHandler", &pThis->RCPtrLFBHandler);
if (RT_FAILURE(rc))
{
AssertReleaseMsgFailed(("PDMR3LdrGetSymbolRC(, %s, \"vgaGCLFBAccessHandler\",) -> %Rrc\n", pDevIns->pReg->szRCMod, rc));
return rc;
}
/* the interfaces. */
#if defined(VBOX_WITH_HGSMI)
# if defined(VBOX_WITH_VIDEOHWACCEL)
# endif
#if defined(VBOX_WITH_CRHGSMI)
# endif
#endif
/*
* Allocate the VRAM and map the first 512KB of it into GC so we can speed up VGA support.
*/
rc = PDMDevHlpMMIO2Register(pDevIns, 0 /* iRegion */, pThis->vram_size, 0, (void **)&pThis->vram_ptrR3, "VRam");
pThis->vram_ptrR0 = (RTR0PTR)pThis->vram_ptrR3; /** @todo #1865 Map parts into R0 or just use PGM access (Mac only). */
if (pThis->fGCEnabled)
{
RTRCPTR pRCMapping = 0;
rc = PDMDevHlpMMHyperMapMMIO2(pDevIns, 0 /* iRegion */, 0 /* off */, VGA_MAPPING_SIZE, "VGA VRam", &pRCMapping);
AssertLogRelMsgRCReturn(rc, ("PDMDevHlpMMHyperMapMMIO2(%#x,) -> %Rrc\n", VGA_MAPPING_SIZE, rc), rc);
}
#if defined(VBOX_WITH_2X_4GB_ADDR_SPACE)
if (pThis->fR0Enabled)
{
RTR0PTR pR0Mapping = 0;
rc = PDMDevHlpMMIO2MapKernel(pDevIns, 0 /* iRegion */, 0 /* off */, VGA_MAPPING_SIZE, "VGA VRam", &pR0Mapping);
}
#endif
/*
* Register I/O ports, ROM and save state.
*/
rc = PDMDevHlpIOPortRegister(pDevIns, 0x3c0, 16, NULL, vgaIOPortWrite, vgaIOPortRead, NULL, NULL, "VGA - 3c0");
if (RT_FAILURE(rc))
return rc;
rc = PDMDevHlpIOPortRegister(pDevIns, 0x3b4, 2, NULL, vgaIOPortWrite, vgaIOPortRead, NULL, NULL, "VGA - 3b4");
if (RT_FAILURE(rc))
return rc;
rc = PDMDevHlpIOPortRegister(pDevIns, 0x3ba, 1, NULL, vgaIOPortWrite, vgaIOPortRead, NULL, NULL, "VGA - 3ba");
if (RT_FAILURE(rc))
return rc;
rc = PDMDevHlpIOPortRegister(pDevIns, 0x3d4, 2, NULL, vgaIOPortWrite, vgaIOPortRead, NULL, NULL, "VGA - 3d4");
if (RT_FAILURE(rc))
return rc;
rc = PDMDevHlpIOPortRegister(pDevIns, 0x3da, 1, NULL, vgaIOPortWrite, vgaIOPortRead, NULL, NULL, "VGA - 3da");
if (RT_FAILURE(rc))
return rc;
#ifdef VBOX_WITH_HGSMI
/* Use reserved VGA IO ports for HGSMI. */
rc = PDMDevHlpIOPortRegister(pDevIns, VGA_PORT_HGSMI_HOST, 4, NULL, vgaR3IOPortHGSMIWrite, vgaR3IOPortHGSMIRead, NULL, NULL, "VGA - 3b0 (HGSMI host)");
if (RT_FAILURE(rc))
return rc;
rc = PDMDevHlpIOPortRegister(pDevIns, VGA_PORT_HGSMI_GUEST, 4, NULL, vgaR3IOPortHGSMIWrite, vgaR3IOPortHGSMIRead, NULL, NULL, "VGA - 3d0 (HGSMI guest)");
if (RT_FAILURE(rc))
return rc;
#endif /* VBOX_WITH_HGSMI */
#ifdef CONFIG_BOCHS_VBE
rc = PDMDevHlpIOPortRegister(pDevIns, 0x1ce, 1, NULL, vgaIOPortWriteVBEIndex, vgaIOPortReadVBEIndex, NULL, NULL, "VGA/VBE - Index");
if (RT_FAILURE(rc))
return rc;
rc = PDMDevHlpIOPortRegister(pDevIns, 0x1cf, 1, NULL, vgaIOPortWriteVBEData, vgaIOPortReadVBEData, NULL, NULL, "VGA/VBE - Data");
if (RT_FAILURE(rc))
return rc;
#endif /* CONFIG_BOCHS_VBE */
/* guest context extension */
if (pThis->fGCEnabled)
{
rc = PDMDevHlpIOPortRegisterRC(pDevIns, 0x3c0, 16, 0, "vgaIOPortWrite", "vgaIOPortRead", NULL, NULL, "VGA - 3c0 (GC)");
if (RT_FAILURE(rc))
return rc;
rc = PDMDevHlpIOPortRegisterRC(pDevIns, 0x3b4, 2, 0, "vgaIOPortWrite", "vgaIOPortRead", NULL, NULL, "VGA - 3b4 (GC)");
if (RT_FAILURE(rc))
return rc;
rc = PDMDevHlpIOPortRegisterRC(pDevIns, 0x3ba, 1, 0, "vgaIOPortWrite", "vgaIOPortRead", NULL, NULL, "VGA - 3ba (GC)");
if (RT_FAILURE(rc))
return rc;
rc = PDMDevHlpIOPortRegisterRC(pDevIns, 0x3d4, 2, 0, "vgaIOPortWrite", "vgaIOPortRead", NULL, NULL, "VGA - 3d4 (GC)");
if (RT_FAILURE(rc))
return rc;
rc = PDMDevHlpIOPortRegisterRC(pDevIns, 0x3da, 1, 0, "vgaIOPortWrite", "vgaIOPortRead", NULL, NULL, "VGA - 3da (GC)");
if (RT_FAILURE(rc))
return rc;
#ifdef CONFIG_BOCHS_VBE
rc = PDMDevHlpIOPortRegisterRC(pDevIns, 0x1ce, 1, 0, "vgaIOPortWriteVBEIndex", "vgaIOPortReadVBEIndex", NULL, NULL, "VGA/VBE - Index (GC)");
if (RT_FAILURE(rc))
return rc;
rc = PDMDevHlpIOPortRegisterRC(pDevIns, 0x1cf, 1, 0, "vgaIOPortWriteVBEData", "vgaIOPortReadVBEData", NULL, NULL, "VGA/VBE - Data (GC)");
if (RT_FAILURE(rc))
return rc;
#endif /* CONFIG_BOCHS_VBE */
}
/* R0 context extension */
if (pThis->fR0Enabled)
{
rc = PDMDevHlpIOPortRegisterR0(pDevIns, 0x3c0, 16, 0, "vgaIOPortWrite", "vgaIOPortRead", NULL, NULL, "VGA - 3c0 (GC)");
if (RT_FAILURE(rc))
return rc;
rc = PDMDevHlpIOPortRegisterR0(pDevIns, 0x3b4, 2, 0, "vgaIOPortWrite", "vgaIOPortRead", NULL, NULL, "VGA - 3b4 (GC)");
if (RT_FAILURE(rc))
return rc;
rc = PDMDevHlpIOPortRegisterR0(pDevIns, 0x3ba, 1, 0, "vgaIOPortWrite", "vgaIOPortRead", NULL, NULL, "VGA - 3ba (GC)");
if (RT_FAILURE(rc))
return rc;
rc = PDMDevHlpIOPortRegisterR0(pDevIns, 0x3d4, 2, 0, "vgaIOPortWrite", "vgaIOPortRead", NULL, NULL, "VGA - 3d4 (GC)");
if (RT_FAILURE(rc))
return rc;
rc = PDMDevHlpIOPortRegisterR0(pDevIns, 0x3da, 1, 0, "vgaIOPortWrite", "vgaIOPortRead", NULL, NULL, "VGA - 3da (GC)");
if (RT_FAILURE(rc))
return rc;
#ifdef CONFIG_BOCHS_VBE
rc = PDMDevHlpIOPortRegisterR0(pDevIns, 0x1ce, 1, 0, "vgaIOPortWriteVBEIndex", "vgaIOPortReadVBEIndex", NULL, NULL, "VGA/VBE - Index (GC)");
if (RT_FAILURE(rc))
return rc;
rc = PDMDevHlpIOPortRegisterR0(pDevIns, 0x1cf, 1, 0, "vgaIOPortWriteVBEData", "vgaIOPortReadVBEData", NULL, NULL, "VGA/VBE - Data (GC)");
if (RT_FAILURE(rc))
return rc;
#endif /* CONFIG_BOCHS_VBE */
}
/* vga mmio */
rc = PDMDevHlpMMIORegister(pDevIns, 0x000a0000, 0x00020000, 0, vgaMMIOWrite, vgaMMIORead, vgaMMIOFill, "VGA - VGA Video Buffer");
if (RT_FAILURE(rc))
return rc;
if (pThis->fGCEnabled)
{
rc = PDMDevHlpMMIORegisterRC(pDevIns, 0x000a0000, 0x00020000, 0, "vgaMMIOWrite", "vgaMMIORead", "vgaMMIOFill");
if (RT_FAILURE(rc))
return rc;
}
if (pThis->fR0Enabled)
{
rc = PDMDevHlpMMIORegisterR0(pDevIns, 0x000a0000, 0x00020000, 0, "vgaMMIOWrite", "vgaMMIORead", "vgaMMIOFill");
if (RT_FAILURE(rc))
return rc;
}
/* vga bios */
rc = PDMDevHlpIOPortRegister(pDevIns, VBE_PRINTF_PORT, 1, NULL, vgaIOPortWriteBIOS, vgaIOPortReadBIOS, NULL, NULL, "VGA BIOS debug/panic");
if (RT_FAILURE(rc))
return rc;
if (pThis->fR0Enabled)
{
rc = PDMDevHlpIOPortRegisterR0(pDevIns, VBE_PRINTF_PORT, 1, 0, "vgaIOPortWriteBIOS", "vgaIOPortReadBIOS", NULL, NULL, "VGA BIOS debug/panic");
if (RT_FAILURE(rc))
return rc;
}
/*
* Get the VGA BIOS ROM file name.
*/
if (rc == VERR_CFGM_VALUE_NOT_FOUND)
{
rc = VINF_SUCCESS;
}
else if (RT_FAILURE(rc))
N_("Configuration error: Querying \"BiosRom\" as a string failed"));
else if (!*pThis->pszVgaBiosFile)
{
}
/*
* Determine the VGA BIOS ROM size, open specified ROM file in the process.
*/
if (pThis->pszVgaBiosFile)
{
if (RT_SUCCESS(rc))
{
if (RT_SUCCESS(rc))
{
}
}
if (RT_FAILURE(rc))
{
/*
* In case of failure simply fall back to the built-in VGA BIOS ROM.
*/
Log(("vgaConstruct: Failed to open VGA BIOS ROM file '%s', rc=%Rrc!\n", pThis->pszVgaBiosFile, rc));
}
}
/*
* Attempt to get the VGA BIOS ROM data from file.
*/
if (pThis->pszVgaBiosFile)
{
/*
* Allocate buffer for the VGA BIOS ROM data.
*/
if (pThis->pu8VgaBios)
{
if (RT_FAILURE(rc))
{
}
rc = VINF_SUCCESS;
}
else
rc = VERR_NO_MEMORY;
}
else
/* cleanup */
if (FileVgaBios != NIL_RTFILE)
/* If we were unable to get the data from file for whatever reason, fall
back to the built-in ROM image. */
{
}
else
{
}
AssertReleaseMsg(g_cbVgaBiosBinary <= _64K && g_cbVgaBiosBinary >= 32*_1K, ("g_cbVgaBiosBinary=%#x\n", g_cbVgaBiosBinary));
AssertReleaseMsg(RT_ALIGN_Z(g_cbVgaBiosBinary, PAGE_SIZE) == g_cbVgaBiosBinary, ("g_cbVgaBiosBinary=%#x\n", g_cbVgaBiosBinary));
fFlags, "VGA BIOS");
if (RT_FAILURE(rc))
return rc;
/* save */
if (RT_FAILURE(rc))
return rc;
/* PCI */
if (RT_FAILURE(rc))
return rc;
/*AssertMsg(pThis->Dev.devfn == 16 || iInstance != 0, ("pThis->Dev.devfn=%d\n", pThis->Dev.devfn));*/
Log(("!!WARNING!!: pThis->dev.devfn=%d (ignore if testcase or not started by Main)\n", pThis->Dev.devfn));
rc = PDMDevHlpPCIIORegionRegister(pDevIns, 0 /* iRegion */, pThis->vram_size, PCI_ADDRESS_SPACE_MEM_PREFETCH, vgaR3IORegionMap);
if (RT_FAILURE(rc))
return rc;
/* Initialize the PDM lock. */
if (RT_FAILURE(rc))
{
return rc;
}
/*
* Create the refresh timer.
*/
if (RT_FAILURE(rc))
return rc;
/*
* Attach to the display.
*/
if (RT_FAILURE(rc))
return rc;
/*
* Initialize the retrace flag.
*/
#ifdef VBE_NEW_DYN_LIST
/*
* Compute buffer size for the VBE BIOS Extra Data.
*/
else
cyReduction = 0;
else
cCustomModes = 0;
/*
* Allocate and initialize buffer for the VBE BIOS Extra Data.
*/
if (!pThis->pu8VBEExtraData)
return VERR_NO_MEMORY;
# ifndef VRAM_SIZE_FIX
# else /* VRAM_SIZE_FIX defined */
for (i = 0; i < MODE_INFO_SIZE; i++)
{
pixelWidth = 2;
else
* pixelWidth;
continue;
continue;
*pCurMode = mode_info_list[i];
pCurMode++;
}
# endif /* VRAM_SIZE_FIX defined */
/*
* Copy default modes with subtracted YResolution.
*/
if (cyReduction)
{
# ifndef VRAM_SIZE_FIX
{
}
# else /* VRAM_SIZE_FIX defined */
for (i = 0; i < MODE_INFO_SIZE; i++, pDefMode++)
{
pixelWidth = 2;
else
continue;
continue;
pCurMode++;
}
# endif /* VRAM_SIZE_FIX defined */
}
/*
* Add custom modes.
*/
if (cCustomModes)
{
for (i = 1; i <= cCustomModes; i++)
{
char szExtraDataKey[sizeof("CustomVideoModeXX")];
char *pszExtraData = NULL;
/* query and decode the custom mode string. */
if (RT_SUCCESS(rc))
{
if ( cParams != 3
{
AssertMsgFailed(("Configuration error: Invalid mode data '%s' for '%s'! cBits=%d\n", pszExtraData, szExtraDataKey, cBits));
return VERR_VGA_INVALID_CUSTOM_MODE;
}
# ifdef VRAM_SIZE_FIX
{
AssertMsgFailed(("Configuration error: custom video mode %dx%dx%dbits is too large for the virtual video memory of %dMb. Please increase the video memory size.\n",
return VERR_VGA_INVALID_CUSTOM_MODE;
}
# endif /* VRAM_SIZE_FIX defined */
/* Use defaults from max@bpp mode. */
switch (cBits)
{
case 16:
break;
case 24:
break;
case 32:
break;
default: /* gcc, shut up! */
AssertMsgFailed(("gone postal!\n"));
continue;
}
/* mode_info_list is not terminated */
pDefMode++;
Assert(j < MODE_INFO_SIZE);
/* adjust defaults */
/* commit it */
pCurMode++;
}
else if (rc != VERR_CFGM_VALUE_NOT_FOUND)
{
return rc;
}
} /* foreach custom mode key */
}
/*
* Add the "End of list" mode.
*/
/*
* Register I/O Port for the VBE BIOS Extra Data.
*/
rc = PDMDevHlpIOPortRegister(pDevIns, VBE_EXTRA_PORT, 1, NULL, vbeIOPortWriteVBEExtra, vbeIOPortReadVBEExtra, NULL, NULL, "VBE BIOS Extra Data");
if (RT_FAILURE(rc))
return rc;
#endif /* VBE_NEW_DYN_LIST */
/*
* Register I/O Port for the BIOS Logo.
*/
rc = PDMDevHlpIOPortRegister(pDevIns, LOGO_IO_PORT, 1, NULL, vbeIOPortWriteCMDLogo, vbeIOPortReadCMDLogo, NULL, NULL, "BIOS Logo");
if (RT_FAILURE(rc))
return rc;
/*
* Register debugger info callbacks.
*/
PDMDevHlpDBGFInfoRegister(pDevIns, "vgatext", "Display VGA memory formatted as text.", vgaInfoText);
/*
* Construct the logo header.
*/
if (rc == VERR_CFGM_VALUE_NOT_FOUND)
else if (RT_FAILURE(rc))
N_("Configuration error: Querying \"FadeIn\" as integer failed"));
if (rc == VERR_CFGM_VALUE_NOT_FOUND)
else if (RT_FAILURE(rc))
N_("Configuration error: Querying \"FadeOut\" as integer failed"));
if (rc == VERR_CFGM_VALUE_NOT_FOUND)
LogoHdr.u16LogoMillies = 0;
else if (RT_FAILURE(rc))
N_("Configuration error: Querying \"LogoTime\" as integer failed"));
if (rc == VERR_CFGM_VALUE_NOT_FOUND)
LogoHdr.fu8ShowBootMenu = 0;
else if (RT_FAILURE(rc))
N_("Configuration error: Querying \"ShowBootMenu\" as integer failed"));
#if defined(DEBUG) && !defined(DEBUG_sunlover)
/* Disable the logo abd menu if all default settings. */
&& LogoHdr.u16LogoMillies == 0
#endif
/* Delay the logo a little bit */
/*
* Get the Logo file name.
*/
if (rc == VERR_CFGM_VALUE_NOT_FOUND)
else if (RT_FAILURE(rc))
N_("Configuration error: Querying \"LogoFile\" as a string failed"));
else if (!*pThis->pszLogoFile)
{
}
/*
* Determine the logo size, open any specified logo file in the process.
*/
if (pThis->pszLogoFile)
{
if (RT_SUCCESS(rc))
{
if (RT_SUCCESS(rc))
{
else
}
}
if (RT_FAILURE(rc))
{
/*
* Ignore failure and fall back to the default logo.
*/
if (FileLogo != NIL_RTFILE)
}
}
/*
* Disable graphic splash screen if it doesn't fit into VRAM.
*/
/*
* Allocate buffer for the logo data.
* RT_MAX() is applied to let us fall back to default logo on read failure.
*/
pThis->pu8Logo = (uint8_t *)PDMDevHlpMMHeapAlloc(pDevIns, RT_MAX(pThis->cbLogo, g_cbVgaDefBiosLogo + sizeof(LogoHdr)));
{
/*
* Write the logo header.
*/
/*
* Write the logo bitmap.
*/
if (pThis->pszLogoFile)
{
if (RT_FAILURE(rc))
{
}
}
else
if (RT_FAILURE(rc))
{
}
if (RT_FAILURE(rc))
rc = VINF_SUCCESS;
}
else
rc = VERR_NO_MEMORY;
/*
* Cleanup.
*/
if (FileLogo != NIL_RTFILE)
#ifdef VBOX_WITH_HGSMI
#endif /* VBOX_WITH_HGSMI */
#ifdef VBOX_WITH_VDMA
if(rc == VINF_SUCCESS)
{
}
#endif
/*
* Statistics.
*/
STAM_REG(pVM, &pThis->StatRZMemoryRead, STAMTYPE_PROFILE, "/Devices/VGA/RZ/MMIO-Read", STAMUNIT_TICKS_PER_CALL, "Profiling of the VGAGCMemoryRead() body.");
STAM_REG(pVM, &pThis->StatR3MemoryRead, STAMTYPE_PROFILE, "/Devices/VGA/R3/MMIO-Read", STAMUNIT_TICKS_PER_CALL, "Profiling of the VGAGCMemoryRead() body.");
STAM_REG(pVM, &pThis->StatRZMemoryWrite, STAMTYPE_PROFILE, "/Devices/VGA/RZ/MMIO-Write", STAMUNIT_TICKS_PER_CALL, "Profiling of the VGAGCMemoryWrite() body.");
STAM_REG(pVM, &pThis->StatR3MemoryWrite, STAMTYPE_PROFILE, "/Devices/VGA/R3/MMIO-Write", STAMUNIT_TICKS_PER_CALL, "Profiling of the VGAGCMemoryWrite() body.");
STAM_REG(pVM, &pThis->StatMapPage, STAMTYPE_COUNTER, "/Devices/VGA/MapPageCalls", STAMUNIT_OCCURENCES, "Calls to IOMMMIOMapMMIO2Page.");
STAM_REG(pVM, &pThis->StatUpdateDisp, STAMTYPE_COUNTER, "/Devices/VGA/UpdateDisplay", STAMUNIT_OCCURENCES, "Calls to vgaPortUpdateDisplay().");
/* Init latched access mask. */
return rc;
}
/**
* The device registration structure.
*/
const PDMDEVREG g_DeviceVga =
{
/* u32Version */
/* szName */
"vga",
/* szRCMod */
"VBoxDDGC.gc",
/* szR0Mod */
"VBoxDDR0.r0",
/* pszDescription */
"VGA Adaptor with VESA extensions.",
/* fFlags */
/* fClass */
/* cMaxInstances */
1,
/* cbInstance */
sizeof(VGASTATE),
/* pfnConstruct */
/* pfnDestruct */
/* pfnRelocate */
/* pfnIOCtl */
NULL,
/* pfnPowerOn */
NULL,
/* pfnReset */
/* pfnSuspend */
NULL,
/* pfnResume */
NULL,
/* pfnAttach */
/* pfnDetach */
/* pfnQueryInterface */
NULL,
/* pfnInitComplete */
NULL,
/* pfnPowerOff */
NULL,
/* pfnSoftReset */
NULL,
/* u32VersionEnd */
};
#endif /* !IN_RING3 */
#endif /* !VBOX_DEVICE_STRUCT_TESTCASE */
/*
* Local Variables:
* nuke-trailing-whitespace-p:nil
* End:
*/