- moved the pcivga code to vga.cc and removed the now obsolete plugin device
This commit is contained in:
parent
da42a100eb
commit
ca2e44c0c4
@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (C) 2001-2011 The Bochs Project
|
||||
// Copyright (C) 2001-2012 The Bochs Project
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
@ -190,7 +190,6 @@
|
||||
#define BX_USE_PCI_SMF 1 // PCI
|
||||
#define BX_USE_P2I_SMF 1 // PCI-to-ISA bridge
|
||||
#define BX_USE_PIDE_SMF 1 // PCI-IDE
|
||||
#define BX_USE_PCIVGA_SMF 1 // PCI-VGA
|
||||
#define BX_USE_PCIDEV_SMF 1 // PCI-DEV
|
||||
#define BX_USE_USB_UHCI_SMF 1 // USB UHCI hub
|
||||
#define BX_USE_USB_OHCI_SMF 1 // USB OHCI hub
|
||||
@ -214,7 +213,7 @@
|
||||
|| !BX_USE_PAR_SMF || !BX_USE_PIC_SMF || !BX_USE_PIT_SMF \
|
||||
|| !BX_USE_SER_SMF || !BX_USE_UM_SMF || !BX_USE_VGA_SMF \
|
||||
|| !BX_USE_SB16_SMF || !BX_USE_ES1370_SMF || !BX_USE_DEV_SMF \
|
||||
|| !BX_USE_PCI_SMF || !BX_USE_P2I_SMF || !BX_USE_PCIVGA_SMF \
|
||||
|| !BX_USE_PCI_SMF || !BX_USE_P2I_SMF \
|
||||
|| !BX_USE_USB_UHCI_SMF || !BX_USE_USB_OHCI_SMF || !BX_USE_USB_XHCI_SMF \
|
||||
|| !BX_USE_PCIPNIC_SMF || !BX_USE_PIDE_SMF || !BX_USE_ACPI_SMF \
|
||||
|| !BX_USE_NE2K_SMF || !BX_USE_EFI_SMF || !BX_USE_GAMEPORT_SMF \
|
||||
|
@ -663,7 +663,7 @@ AC_ARG_ENABLE(pci,
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(BX_SUPPORT_PCI, 1)
|
||||
pci=1
|
||||
PCI_OBJ='pci.o pci2isa.o pci_ide.o pcivga.o acpi.o'
|
||||
PCI_OBJ='pci.o pci2isa.o pci_ide.o acpi.o'
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
AC_DEFINE(BX_SUPPORT_PCI, 0)
|
||||
|
@ -303,11 +303,6 @@ pci_ide.o: pci_ide.@CPP_SUFFIX@ iodev.h ../bochs.h ../config.h ../osdep.h \
|
||||
../cpudb.h ../gui/paramtree.h ../memory/memory.h ../pc_system.h \
|
||||
../gui/gui.h ../instrument/stubs/instrument.h ../plugin.h ../extplugin.h \
|
||||
../ltdl.h ../param_names.h pci.h pci_ide.h
|
||||
pcivga.o: pcivga.@CPP_SUFFIX@ iodev.h ../bochs.h ../config.h ../osdep.h \
|
||||
../bx_debug/debug.h ../config.h ../osdep.h ../gui/siminterface.h \
|
||||
../cpudb.h ../gui/paramtree.h ../memory/memory.h ../pc_system.h \
|
||||
../gui/gui.h ../instrument/stubs/instrument.h ../plugin.h ../extplugin.h \
|
||||
../ltdl.h ../param_names.h pci.h pcivga.h
|
||||
pic.o: pic.@CPP_SUFFIX@ iodev.h ../bochs.h ../config.h ../osdep.h \
|
||||
../bx_debug/debug.h ../config.h ../osdep.h ../gui/siminterface.h \
|
||||
../cpudb.h ../gui/paramtree.h ../memory/memory.h ../pc_system.h \
|
||||
@ -503,11 +498,6 @@ pci_ide.lo: pci_ide.@CPP_SUFFIX@ iodev.h ../bochs.h ../config.h ../osdep.h \
|
||||
../cpudb.h ../gui/paramtree.h ../memory/memory.h ../pc_system.h \
|
||||
../gui/gui.h ../instrument/stubs/instrument.h ../plugin.h ../extplugin.h \
|
||||
../ltdl.h ../param_names.h pci.h pci_ide.h
|
||||
pcivga.lo: pcivga.@CPP_SUFFIX@ iodev.h ../bochs.h ../config.h ../osdep.h \
|
||||
../bx_debug/debug.h ../config.h ../osdep.h ../gui/siminterface.h \
|
||||
../cpudb.h ../gui/paramtree.h ../memory/memory.h ../pc_system.h \
|
||||
../gui/gui.h ../instrument/stubs/instrument.h ../plugin.h ../extplugin.h \
|
||||
../ltdl.h ../param_names.h pci.h pcivga.h
|
||||
pic.lo: pic.@CPP_SUFFIX@ iodev.h ../bochs.h ../config.h ../osdep.h \
|
||||
../bx_debug/debug.h ../config.h ../osdep.h ../gui/siminterface.h \
|
||||
../cpudb.h ../gui/paramtree.h ../memory/memory.h ../pc_system.h \
|
||||
|
@ -222,15 +222,6 @@ void bx_devices_c::init(BX_MEM_C *newmem)
|
||||
if (is_parallel_enabled())
|
||||
PLUG_load_plugin(parallel, PLUGTYPE_OPTIONAL);
|
||||
|
||||
#if BX_SUPPORT_PCI
|
||||
if (SIM->get_param_bool(BXPN_I440FX_SUPPORT)->get()) {
|
||||
if ((DEV_is_pci_device("pcivga")) &&
|
||||
((!strlen(vga_ext)) || (!strcmp(vga_ext, "none")) || (!strcmp(vga_ext, "vbe")))) {
|
||||
PLUG_load_plugin(pcivga, PLUGTYPE_STANDARD);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// system hardware
|
||||
register_io_read_handler(this, &read_handler, 0x0092,
|
||||
"Port 92h System Control", 1);
|
||||
|
@ -264,9 +264,6 @@ public:
|
||||
virtual void trigger_timer(void *this_ptr) {
|
||||
STUBFUNC(vga, trigger_timer);
|
||||
}
|
||||
virtual bx_bool vbe_set_base_addr(Bit32u *addr, Bit8u *pci_conf) {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
class BOCHSAPI bx_pci_bridge_stub_c : public bx_devmodel_c, public bx_pci_device_stub_c {
|
||||
|
@ -1,257 +0,0 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id$
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2002,2003 Mike Nordell
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
//
|
||||
// Experimental PCI VGA adapter
|
||||
//
|
||||
|
||||
// Note: This "driver" was created for the SOLE PURPOSE of getting BeOS
|
||||
// to boot. It currently does NOTHING more than presenting a generic VGA
|
||||
// device on the PCI bus. ALL gfx in/out-put is still handled by the VGA code.
|
||||
// Furthermore, almost all of the PCI registers are currently acting like RAM.
|
||||
|
||||
|
||||
// Define BX_PLUGGABLE in files that can be compiled into plugins. For
|
||||
// platforms that require a special tag on exported symbols, BX_PLUGGABLE
|
||||
// is used to know when we are exporting symbols and when we are importing.
|
||||
#define BX_PLUGGABLE
|
||||
|
||||
#include "iodev.h"
|
||||
|
||||
#if BX_SUPPORT_PCI
|
||||
|
||||
#include "pci.h"
|
||||
#include "pcivga.h"
|
||||
|
||||
#define LOG_THIS thePciVgaAdapter->
|
||||
|
||||
bx_pcivga_c* thePciVgaAdapter = 0;
|
||||
|
||||
int libpcivga_LTX_plugin_init(plugin_t *plugin, plugintype_t type, int argc, char *argv[])
|
||||
{
|
||||
thePciVgaAdapter = new bx_pcivga_c();
|
||||
BX_REGISTER_DEVICE_DEVMODEL(plugin, type, thePciVgaAdapter, BX_PLUGIN_PCIVGA);
|
||||
return 0; // Success
|
||||
}
|
||||
|
||||
void libpcivga_LTX_plugin_fini(void)
|
||||
{
|
||||
delete thePciVgaAdapter;
|
||||
}
|
||||
|
||||
bx_pcivga_c::bx_pcivga_c()
|
||||
{
|
||||
put("pcivga", "PCIVG");
|
||||
}
|
||||
|
||||
bx_pcivga_c::~bx_pcivga_c()
|
||||
{
|
||||
BX_DEBUG(("Exit"));
|
||||
}
|
||||
|
||||
void bx_pcivga_c::init(void)
|
||||
{
|
||||
// called once when bochs initializes
|
||||
|
||||
Bit8u devfunc = 0x00;
|
||||
unsigned i;
|
||||
|
||||
DEV_register_pci_handlers(this, &devfunc, BX_PLUGIN_PCIVGA,
|
||||
"Experimental PCI VGA");
|
||||
|
||||
for (i=0; i<256; i++) {
|
||||
BX_PCIVGA_THIS pci_conf[i] = 0x0;
|
||||
}
|
||||
|
||||
// readonly registers
|
||||
static const struct init_vals_t {
|
||||
unsigned addr;
|
||||
unsigned char val;
|
||||
} init_vals[] = {
|
||||
// Note that the values for vendor and device id are selected at random!
|
||||
// There might actually be "real" values for "experimental" vendor and
|
||||
// device that should be used!
|
||||
{ 0x00, 0x34 }, { 0x01, 0x12 }, // 0x1234 - experimental vendor
|
||||
{ 0x02, 0x11 }, { 0x03, 0x11 }, // 0x1111 - experimental device
|
||||
{ 0x0a, 0x00 }, // class_sub VGA controller
|
||||
{ 0x0b, 0x03 }, // class_base display
|
||||
{ 0x0e, 0x00 } // header_type_generic
|
||||
};
|
||||
for (i = 0; i < sizeof(init_vals) / sizeof(*init_vals); ++i) {
|
||||
BX_PCIVGA_THIS pci_conf[init_vals[i].addr] = init_vals[i].val;
|
||||
}
|
||||
BX_PCIVGA_THIS vbe_present = !strcmp(SIM->get_param_string(BXPN_VGA_EXTENSION)->getptr(), "vbe");
|
||||
if (BX_PCIVGA_THIS vbe_present) {
|
||||
WriteHostDWordToLittleEndian(&BX_PCIVGA_THIS pci_conf[0x10], 0x08);
|
||||
BX_PCIVGA_THIS pci_base_address[0] = 0;
|
||||
}
|
||||
BX_PCIVGA_THIS pci_rom_address = 0;
|
||||
BX_PCIVGA_THIS load_pci_rom(SIM->get_param_string(BXPN_VGA_ROM_PATH)->getptr());
|
||||
}
|
||||
|
||||
void bx_pcivga_c::reset(unsigned type)
|
||||
{
|
||||
static const struct reset_vals_t {
|
||||
unsigned addr;
|
||||
unsigned char val;
|
||||
} reset_vals[] = {
|
||||
{ 0x04, 0x03 }, { 0x05, 0x00 }, // command_io + command_mem
|
||||
{ 0x06, 0x00 }, { 0x07, 0x02 } // status_devsel_medium
|
||||
};
|
||||
for (unsigned i = 0; i < sizeof(reset_vals) / sizeof(*reset_vals); ++i) {
|
||||
BX_PCIVGA_THIS pci_conf[reset_vals[i].addr] = reset_vals[i].val;
|
||||
}
|
||||
}
|
||||
|
||||
void bx_pcivga_c::register_state(void)
|
||||
{
|
||||
bx_list_c *list = new bx_list_c(SIM->get_bochs_root(), "pcivga", "PCI VGA Adapter State", 1);
|
||||
register_pci_state(list);
|
||||
}
|
||||
|
||||
void bx_pcivga_c::after_restore_state(void)
|
||||
{
|
||||
if (BX_PCIVGA_THIS vbe_present) {
|
||||
if (DEV_vbe_set_base_addr(&BX_PCIVGA_THIS pci_base_address[0],
|
||||
&BX_PCIVGA_THIS pci_conf[0x10])) {
|
||||
BX_INFO(("new base address: 0x%08x", BX_PCIVGA_THIS pci_base_address[0]));
|
||||
}
|
||||
}
|
||||
if (DEV_pci_set_base_mem(this, mem_read_handler, mem_write_handler,
|
||||
&BX_PCIVGA_THIS pci_rom_address,
|
||||
&BX_PCIVGA_THIS pci_conf[0x30],
|
||||
BX_PCIVGA_THIS pci_rom_size)) {
|
||||
BX_INFO(("new ROM address: 0x%08x", BX_PCIVGA_THIS pci_rom_address));
|
||||
}
|
||||
}
|
||||
|
||||
bx_bool bx_pcivga_c::mem_read_handler(bx_phy_address addr, unsigned len, void *data, void *param)
|
||||
{
|
||||
Bit8u *data_ptr;
|
||||
|
||||
Bit32u mask = (BX_PCIVGA_THIS pci_rom_size - 1);
|
||||
#ifdef BX_LITTLE_ENDIAN
|
||||
data_ptr = (Bit8u *) data;
|
||||
#else
|
||||
data_ptr = (Bit8u *) data + (len - 1);
|
||||
#endif
|
||||
|
||||
for (unsigned i = 0; i < len; i++) {
|
||||
if (BX_PCIVGA_THIS pci_conf[0x30] & 0x01) {
|
||||
*data_ptr = BX_PCIVGA_THIS pci_rom[addr & mask];
|
||||
} else {
|
||||
*data_ptr = 0xff;
|
||||
}
|
||||
addr++;
|
||||
#ifdef BX_LITTLE_ENDIAN
|
||||
data_ptr++;
|
||||
#else
|
||||
data_ptr--;
|
||||
#endif
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
bx_bool bx_pcivga_c::mem_write_handler(bx_phy_address addr, unsigned len, void *data, void *param)
|
||||
{
|
||||
BX_INFO(("write to ROM ignored (addr=0x%08x len=%d)", (Bit32u)addr, len));
|
||||
return 1;
|
||||
}
|
||||
|
||||
// pci configuration space read callback handler
|
||||
Bit32u bx_pcivga_c::pci_read_handler(Bit8u address, unsigned io_len)
|
||||
{
|
||||
Bit32u value = 0;
|
||||
|
||||
for (unsigned i=0; i<io_len; i++) {
|
||||
value |= (BX_PCIVGA_THIS pci_conf[address+i] << (i*8));
|
||||
}
|
||||
|
||||
if (io_len == 1)
|
||||
BX_DEBUG(("read PCI register 0x%02x value 0x%02x", address, value));
|
||||
else if (io_len == 2)
|
||||
BX_DEBUG(("read PCI register 0x%02x value 0x%04x", address, value));
|
||||
else if (io_len == 4)
|
||||
BX_DEBUG(("read PCI register 0x%02x value 0x%08x", address, value));
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
// static pci configuration space write callback handler
|
||||
void bx_pcivga_c::pci_write_handler(Bit8u address, Bit32u value, unsigned io_len)
|
||||
{
|
||||
bx_bool baseaddr_change = 0, romaddr_change = 0;
|
||||
|
||||
if (io_len == 1)
|
||||
BX_DEBUG(("write PCI register 0x%02x value 0x%02x", address, value));
|
||||
else if (io_len == 2)
|
||||
BX_DEBUG(("write PCI register 0x%02x value 0x%04x", address, value));
|
||||
else if (io_len == 4)
|
||||
BX_DEBUG(("write PCI register 0x%02x value 0x%08x", address, value));
|
||||
|
||||
if ((address >= 0x14) && (address < 0x30))
|
||||
return;
|
||||
|
||||
if (address == 0x30) {
|
||||
value = value & 0xfffffc01;
|
||||
romaddr_change = 1;
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < io_len; i++) {
|
||||
unsigned write_addr = address + i;
|
||||
Bit8u old_value = BX_PCIVGA_THIS pci_conf[write_addr];
|
||||
Bit8u new_value = (Bit8u)(value & 0xff);
|
||||
switch (write_addr) {
|
||||
case 0x04: // disallowing write to command
|
||||
case 0x06: // disallowing write to status lo-byte (is that expected?)
|
||||
break;
|
||||
case 0x10: // base address #0
|
||||
new_value = (new_value & 0xf0) | (old_value & 0x0f);
|
||||
case 0x11: case 0x12: case 0x13:
|
||||
if (BX_PCIVGA_THIS vbe_present) {
|
||||
baseaddr_change |= (old_value != new_value);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BX_PCIVGA_THIS pci_conf[write_addr] = new_value;
|
||||
}
|
||||
value >>= 8;
|
||||
}
|
||||
|
||||
if (baseaddr_change) {
|
||||
if (DEV_vbe_set_base_addr(&BX_PCIVGA_THIS pci_base_address[0],
|
||||
&BX_PCIVGA_THIS pci_conf[0x10])) {
|
||||
BX_INFO(("new base address: 0x%08x", BX_PCIVGA_THIS pci_base_address[0]));
|
||||
}
|
||||
}
|
||||
if (romaddr_change) {
|
||||
if (DEV_pci_set_base_mem(this, mem_read_handler, mem_write_handler,
|
||||
&BX_PCIVGA_THIS pci_rom_address,
|
||||
&BX_PCIVGA_THIS pci_conf[0x30],
|
||||
BX_PCIVGA_THIS pci_rom_size)) {
|
||||
BX_INFO(("new ROM address: 0x%08x", BX_PCIVGA_THIS pci_rom_address));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // BX_SUPPORT_PCI
|
@ -1,51 +0,0 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id$
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2002,2003 Mike Nordell
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
#ifndef BX_IODEV_PCIVGA_H
|
||||
#define BX_IODEV_PCIVGA_H
|
||||
|
||||
#if BX_USE_PCIVGA_SMF
|
||||
# define BX_PCIVGA_THIS thePciVgaAdapter->
|
||||
# define BX_PCIVGA_SMF static
|
||||
#else
|
||||
# define BX_PCIVGA_THIS this->
|
||||
# define BX_PCIVGA_SMF
|
||||
#endif
|
||||
|
||||
class bx_pcivga_c : public bx_devmodel_c, public bx_pci_device_stub_c {
|
||||
public:
|
||||
bx_pcivga_c();
|
||||
virtual ~bx_pcivga_c();
|
||||
virtual void init(void);
|
||||
virtual void reset(unsigned type);
|
||||
virtual void register_state(void);
|
||||
virtual void after_restore_state(void);
|
||||
|
||||
BX_PCIVGA_SMF bx_bool mem_read_handler(bx_phy_address addr, unsigned len, void *data, void *param);
|
||||
BX_PCIVGA_SMF bx_bool mem_write_handler(bx_phy_address addr, unsigned len, void *data, void *param);
|
||||
|
||||
virtual Bit32u pci_read_handler(Bit8u address, unsigned io_len);
|
||||
virtual void pci_write_handler(Bit8u address, Bit32u value, unsigned io_len);
|
||||
|
||||
private:
|
||||
bx_bool vbe_present;
|
||||
};
|
||||
|
||||
#endif
|
@ -62,9 +62,6 @@ typedef void (*bx_cirrus_bitblt_rop_t)(
|
||||
int bltwidth,int bltheight);
|
||||
|
||||
class bx_svga_cirrus_c : public bx_vgacore_c
|
||||
#if BX_SUPPORT_PCI
|
||||
, public bx_pci_device_stub_c
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
bx_svga_cirrus_c();
|
||||
|
@ -3,6 +3,7 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2002-2012 The Bochs Project
|
||||
// PCI VGA dummy adapter Copyright (C) 2002,2003 Mike Nordell
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
@ -20,6 +21,14 @@
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Standard VGA emulation + Bochs VBE support + PCI VGA interface
|
||||
|
||||
// NOTE from the original pcivga code:
|
||||
// This "driver" was created for the SOLE PURPOSE of getting BeOS
|
||||
// to boot. It currently does NOTHING more than presenting a generic VGA
|
||||
// device on the PCI bus. ALL gfx in/out-put is still handled by the VGA code.
|
||||
// Furthermore, almost all of the PCI registers are currently acting like RAM.
|
||||
|
||||
// Define BX_PLUGGABLE in files that can be compiled into plugins. For
|
||||
// platforms that require a special tag on exported symbols, BX_PLUGGABLE
|
||||
// is used to know when we are exporting symbols and when we are importing.
|
||||
@ -108,12 +117,15 @@ void bx_vga_c::init_vga_extension(void)
|
||||
{
|
||||
unsigned addr;
|
||||
Bit16u max_xres, max_yres, max_bpp;
|
||||
Bit8u devfunc = 0x00;
|
||||
unsigned i;
|
||||
|
||||
BX_VGA_THIS init_iohandlers(read_handler, write_handler);
|
||||
BX_VGA_THIS init_systemtimer(timer_handler, vga_param_handler);
|
||||
BX_VGA_THIS pci_enabled = DEV_is_pci_device(BX_PLUGIN_PCIVGA);
|
||||
BX_VGA_THIS pci_enabled = DEV_is_pci_device("pcivga");
|
||||
|
||||
// The following is for the VBE display extension
|
||||
BX_VGA_THIS vbe_present = 0;
|
||||
BX_VGA_THIS vbe.enabled = 0;
|
||||
BX_VGA_THIS vbe.dac_8bit = 0;
|
||||
BX_VGA_THIS vbe.base_address = 0x0000;
|
||||
@ -165,16 +177,72 @@ void bx_vga_c::init_vga_extension(void)
|
||||
}
|
||||
BX_VGA_THIS s.max_xres = BX_VGA_THIS vbe.max_xres;
|
||||
BX_VGA_THIS s.max_yres = BX_VGA_THIS vbe.max_yres;
|
||||
BX_VGA_THIS vbe_present = 1;
|
||||
BX_VGA_THIS extension_init = 1;
|
||||
|
||||
BX_INFO(("VBE Bochs Display Extension Enabled"));
|
||||
}
|
||||
#if BX_SUPPORT_PCI
|
||||
if (BX_VGA_THIS pci_enabled) {
|
||||
DEV_register_pci_handlers(this, &devfunc, "pcivga", "Experimental PCI VGA");
|
||||
for (i = 0; i < 256; i++) {
|
||||
BX_VGA_THIS pci_conf[i] = 0x0;
|
||||
}
|
||||
|
||||
// readonly registers
|
||||
static const struct init_vals_t {
|
||||
unsigned addr;
|
||||
unsigned char val;
|
||||
} init_vals[] = {
|
||||
// Note that the values for vendor and device id are selected at random!
|
||||
// There might actually be "real" values for "experimental" vendor and
|
||||
// device that should be used!
|
||||
{ 0x00, 0x34 }, { 0x01, 0x12 }, // 0x1234 - experimental vendor
|
||||
{ 0x02, 0x11 }, { 0x03, 0x11 }, // 0x1111 - experimental device
|
||||
{ 0x0a, 0x00 }, // class_sub VGA controller
|
||||
{ 0x0b, 0x03 }, // class_base display
|
||||
{ 0x0e, 0x00 } // header_type_generic
|
||||
};
|
||||
for (i = 0; i < sizeof(init_vals) / sizeof(*init_vals); ++i) {
|
||||
BX_VGA_THIS pci_conf[init_vals[i].addr] = init_vals[i].val;
|
||||
}
|
||||
if (BX_VGA_THIS vbe_present) {
|
||||
BX_VGA_THIS pci_conf[0x10] = 0x08;
|
||||
BX_VGA_THIS pci_base_address[0] = 0;
|
||||
}
|
||||
BX_VGA_THIS pci_rom_address = 0;
|
||||
BX_VGA_THIS load_pci_rom(SIM->get_param_string(BXPN_VGA_ROM_PATH)->getptr());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void bx_vga_c::reset(unsigned type)
|
||||
{
|
||||
#if BX_SUPPORT_PCI
|
||||
if (BX_VGA_THIS pci_enabled) {
|
||||
static const struct reset_vals_t {
|
||||
unsigned addr;
|
||||
unsigned char val;
|
||||
} reset_vals[] = {
|
||||
{ 0x04, 0x03 }, { 0x05, 0x00 }, // command_io + command_mem
|
||||
{ 0x06, 0x00 }, { 0x07, 0x02 } // status_devsel_medium
|
||||
};
|
||||
for (unsigned i = 0; i < sizeof(reset_vals) / sizeof(*reset_vals); ++i) {
|
||||
BX_VGA_THIS pci_conf[reset_vals[i].addr] = reset_vals[i].val;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void bx_vga_c::register_state(void)
|
||||
{
|
||||
bx_list_c *list = new bx_list_c(SIM->get_bochs_root(), "vga", "VGA Adapter State", 2);
|
||||
bx_list_c *list = new bx_list_c(SIM->get_bochs_root(), "vga", "VGA Adapter State", 3);
|
||||
bx_vgacore_c::register_state(list);
|
||||
#if BX_SUPPORT_PCI
|
||||
if (BX_VGA_THIS pci_enabled) {
|
||||
register_pci_state(list);
|
||||
}
|
||||
#endif
|
||||
// register state for Bochs VBE
|
||||
if (!strcmp(SIM->get_param_string(BXPN_VGA_EXTENSION)->getptr(), "vbe")) {
|
||||
bx_list_c *vbe = new bx_list_c(list, "vbe", 18);
|
||||
@ -200,6 +268,22 @@ void bx_vga_c::register_state(void)
|
||||
|
||||
void bx_vga_c::after_restore_state(void)
|
||||
{
|
||||
#if BX_SUPPORT_PCI
|
||||
if (BX_VGA_THIS pci_enabled) {
|
||||
if (BX_VGA_THIS vbe_present) {
|
||||
if (BX_VGA_THIS vbe_set_base_addr(&BX_VGA_THIS pci_base_address[0],
|
||||
&BX_VGA_THIS pci_conf[0x10])) {
|
||||
BX_INFO(("new base address: 0x%08x", BX_VGA_THIS pci_base_address[0]));
|
||||
}
|
||||
}
|
||||
if (DEV_pci_set_base_mem(this, mem_read_handler, mem_write_handler,
|
||||
&BX_VGA_THIS pci_rom_address,
|
||||
&BX_VGA_THIS pci_conf[0x30],
|
||||
BX_VGA_THIS pci_rom_size)) {
|
||||
BX_INFO(("new ROM address: 0x%08x", BX_VGA_THIS pci_rom_address));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (BX_VGA_THIS vbe.enabled) {
|
||||
bx_gui->dimension_update(BX_VGA_THIS vbe.xres, BX_VGA_THIS vbe.yres, 0, 0,
|
||||
BX_VGA_THIS vbe.bpp);
|
||||
@ -666,6 +750,18 @@ bx_bool bx_vga_c::mem_read_handler(bx_phy_address addr, unsigned len, void *data
|
||||
|
||||
Bit8u bx_vga_c::mem_read(bx_phy_address addr)
|
||||
{
|
||||
#if BX_SUPPORT_PCI
|
||||
if ((BX_VGA_THIS pci_enabled) && (BX_VGA_THIS pci_rom_size > 0)) {
|
||||
Bit32u mask = (BX_VGA_THIS pci_rom_size - 1);
|
||||
if ((addr & ~mask) == BX_VGA_THIS pci_rom_address) {
|
||||
if (BX_VGA_THIS pci_conf[0x30] & 0x01) {
|
||||
return BX_VGA_THIS pci_rom[addr & mask];
|
||||
} else {
|
||||
return 0xff;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// if in a vbe enabled mode, read from the vbe_memory
|
||||
if ((BX_VGA_THIS vbe.enabled) && (BX_VGA_THIS vbe.bpp != VBE_DISPI_BPP_4)) {
|
||||
return vbe_mem_read(addr);
|
||||
@ -699,8 +795,7 @@ bx_bool bx_vga_c::mem_write_handler(bx_phy_address addr, unsigned len, void *dat
|
||||
void bx_vga_c::mem_write(bx_phy_address addr, Bit8u value)
|
||||
{
|
||||
// if in a vbe enabled mode, write to the vbe_memory
|
||||
if ((BX_VGA_THIS vbe.enabled) && (BX_VGA_THIS vbe.bpp != VBE_DISPI_BPP_4))
|
||||
{
|
||||
if ((BX_VGA_THIS vbe.enabled) && (BX_VGA_THIS vbe.bpp != VBE_DISPI_BPP_4)) {
|
||||
vbe_mem_write(addr, value);
|
||||
return;
|
||||
} else if ((BX_VGA_THIS vbe.base_address != 0) && (addr >= BX_VGA_THIS vbe.base_address)) {
|
||||
@ -1333,3 +1428,83 @@ Bit32u bx_vga_c::vbe_write(Bit32u address, Bit32u value, unsigned io_len)
|
||||
|
||||
} // end switch address
|
||||
}
|
||||
|
||||
#if BX_SUPPORT_PCI
|
||||
// pci configuration space read callback handler
|
||||
Bit32u bx_vga_c::pci_read_handler(Bit8u address, unsigned io_len)
|
||||
{
|
||||
Bit32u value = 0;
|
||||
|
||||
for (unsigned i=0; i<io_len; i++) {
|
||||
value |= (BX_VGA_THIS pci_conf[address+i] << (i*8));
|
||||
}
|
||||
|
||||
if (io_len == 1)
|
||||
BX_DEBUG(("read PCI register 0x%02x value 0x%02x", address, value));
|
||||
else if (io_len == 2)
|
||||
BX_DEBUG(("read PCI register 0x%02x value 0x%04x", address, value));
|
||||
else if (io_len == 4)
|
||||
BX_DEBUG(("read PCI register 0x%02x value 0x%08x", address, value));
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
// static pci configuration space write callback handler
|
||||
void bx_vga_c::pci_write_handler(Bit8u address, Bit32u value, unsigned io_len)
|
||||
{
|
||||
bx_bool baseaddr_change = 0, romaddr_change = 0;
|
||||
|
||||
if (io_len == 1)
|
||||
BX_DEBUG(("write PCI register 0x%02x value 0x%02x", address, value));
|
||||
else if (io_len == 2)
|
||||
BX_DEBUG(("write PCI register 0x%02x value 0x%04x", address, value));
|
||||
else if (io_len == 4)
|
||||
BX_DEBUG(("write PCI register 0x%02x value 0x%08x", address, value));
|
||||
|
||||
if ((address >= 0x14) && (address < 0x30))
|
||||
return;
|
||||
|
||||
if (address == 0x30) {
|
||||
value = value & 0xfffffc01;
|
||||
romaddr_change = 1;
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < io_len; i++) {
|
||||
unsigned write_addr = address + i;
|
||||
Bit8u old_value = BX_VGA_THIS pci_conf[write_addr];
|
||||
Bit8u new_value = (Bit8u)(value & 0xff);
|
||||
switch (write_addr) {
|
||||
case 0x04: // disallowing write to command
|
||||
case 0x06: // disallowing write to status lo-byte (is that expected?)
|
||||
break;
|
||||
case 0x10: // base address #0
|
||||
new_value = (new_value & 0xf0) | (old_value & 0x0f);
|
||||
case 0x11: case 0x12: case 0x13:
|
||||
if (BX_VGA_THIS vbe_present) {
|
||||
baseaddr_change |= (old_value != new_value);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BX_VGA_THIS pci_conf[write_addr] = new_value;
|
||||
}
|
||||
value >>= 8;
|
||||
}
|
||||
|
||||
if (baseaddr_change) {
|
||||
if (BX_VGA_THIS vbe_set_base_addr(&BX_VGA_THIS pci_base_address[0],
|
||||
&BX_VGA_THIS pci_conf[0x10])) {
|
||||
BX_INFO(("new base address: 0x%08x", BX_VGA_THIS pci_base_address[0]));
|
||||
}
|
||||
}
|
||||
if (romaddr_change) {
|
||||
if (DEV_pci_set_base_mem(this, mem_read_handler, mem_write_handler,
|
||||
&BX_VGA_THIS pci_rom_address,
|
||||
&BX_VGA_THIS pci_conf[0x30],
|
||||
BX_VGA_THIS pci_rom_size)) {
|
||||
BX_INFO(("new ROM address: 0x%08x", BX_VGA_THIS pci_rom_address));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -3,6 +3,7 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2002-2012 The Bochs Project
|
||||
// PCI VGA dummy adapter Copyright (C) 2002,2003 Mike Nordell
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
@ -114,7 +115,7 @@ class bx_vga_c : public bx_vgacore_c {
|
||||
public:
|
||||
bx_vga_c();
|
||||
virtual ~bx_vga_c();
|
||||
virtual void reset(unsigned type) {}
|
||||
virtual void reset(unsigned type);
|
||||
BX_VGA_SMF bx_bool mem_read_handler(bx_phy_address addr, unsigned len, void *data, void *param);
|
||||
BX_VGA_SMF bx_bool mem_write_handler(bx_phy_address addr, unsigned len, void *data, void *param);
|
||||
virtual Bit8u mem_read(bx_phy_address addr);
|
||||
@ -134,6 +135,12 @@ public:
|
||||
#if BX_USE_VGA_SMF == 0
|
||||
BX_VGA_SMF void timer(void);
|
||||
#endif
|
||||
|
||||
#if BX_SUPPORT_PCI
|
||||
virtual Bit32u pci_read_handler(Bit8u address, unsigned io_len);
|
||||
virtual void pci_write_handler(Bit8u address, Bit32u value, unsigned io_len);
|
||||
#endif
|
||||
|
||||
static Bit64s vga_param_handler(bx_param_c *param, int set, Bit64s val);
|
||||
|
||||
protected:
|
||||
@ -160,6 +167,7 @@ protected:
|
||||
#endif
|
||||
|
||||
private:
|
||||
bx_bool vbe_present;
|
||||
struct {
|
||||
Bit16u cur_dispi;
|
||||
Bit32u base_address;
|
||||
|
@ -45,7 +45,11 @@
|
||||
#define X_TILESIZE 16
|
||||
#define Y_TILESIZE 24
|
||||
|
||||
class bx_vgacore_c : public bx_vga_stub_c {
|
||||
class bx_vgacore_c : public bx_vga_stub_c
|
||||
#if BX_SUPPORT_PCI
|
||||
, public bx_pci_device_stub_c
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
bx_vgacore_c();
|
||||
virtual ~bx_vgacore_c();
|
||||
|
@ -63,7 +63,6 @@ extern "C" {
|
||||
#define BX_PLUGIN_NETMOD "netmod"
|
||||
#define BX_PLUGIN_NE2K "ne2k"
|
||||
#define BX_PLUGIN_EXTFPUIRQ "extfpuirq"
|
||||
#define BX_PLUGIN_PCIVGA "pcivga"
|
||||
#define BX_PLUGIN_PCIDEV "pcidev"
|
||||
#define BX_PLUGIN_USB_COMMON "usb_common"
|
||||
#define BX_PLUGIN_USB_UHCI "usb_uhci"
|
||||
@ -224,7 +223,6 @@ extern "C" {
|
||||
#define DEV_vga_refresh() \
|
||||
(bx_devices.pluginVgaDevice->trigger_timer(bx_devices.pluginVgaDevice))
|
||||
#define DEV_vga_debug_dump() (bx_devices.pluginVgaDevice->debug_dump())
|
||||
#define DEV_vbe_set_base_addr(a,b) (bx_devices.pluginVgaDevice->vbe_set_base_addr(a,b))
|
||||
|
||||
///////// PCI macros
|
||||
#define DEV_register_pci_handlers(a,b,c,d) \
|
||||
@ -353,7 +351,6 @@ BOCHSAPI extern void (* pluginVGAGetTextSnapshot)(Bit8u **text_snapshot,
|
||||
unsigned *txHeight, unsigned *txWidth);
|
||||
BOCHSAPI extern void (* pluginVGARefresh)(void *);
|
||||
BOCHSAPI extern void (* pluginVGASetUpdateInterval)(unsigned);
|
||||
BOCHSAPI extern Bit8u (* pluginVGAGetActlPaletteIdx)(Bit8u index);
|
||||
|
||||
/* === Timer stuff === */
|
||||
BOCHSAPI extern int (*pluginRegisterTimer)(void *this_ptr, void (*funct)(void *),
|
||||
@ -424,7 +421,6 @@ DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(parallel)
|
||||
DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(pci)
|
||||
DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(pci2isa)
|
||||
DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(pci_ide)
|
||||
DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(pcivga)
|
||||
DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(pcidev)
|
||||
DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(usb_common)
|
||||
DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(usb_uhci)
|
||||
|
Loading…
Reference in New Issue
Block a user