- major rewrite of the vga / cirrus code

- added new class bx_vgacore_c containing the core of the standard VGA
    emulation. This is now the base class for both vga and cirrus.
  - created 2 separate plugins 'vga' (for standard VGA and VBE) and 'svga_cirrus'
    (Cirrus emulation). The vga extension option is used to select which plugin
    should be loaded.
- TODO: move the pcivga code to the VGA/VBE code, add subdirectory for display
        adapters, severak improvements and cleanups
This commit is contained in:
Volker Ruppert 2012-01-24 21:58:24 +00:00
parent 56ff41bcd5
commit da42a100eb
9 changed files with 2845 additions and 2478 deletions

View File

@ -70,6 +70,7 @@ OBJS_THAT_CAN_BE_PLUGINS = \
floppy.o \
keyboard.o \
vga.o \
svga_cirrus.o \
biosdev.o \
cmos.o \
harddrv.o \
@ -88,7 +89,7 @@ OBJS_THAT_SUPPORT_OTHER_PLUGINS = \
pit82c54.o \
scancodes.o \
serial_raw.o \
svga_cirrus.o \
vgacore.o \
vmware3.o \
vmware4.o \
vvfat.o \
@ -136,8 +137,11 @@ libbx_pit.la: pit82c54.lo pit.lo
libbx_serial.la: serial.lo serial_raw.lo
$(LIBTOOL) --mode=link $(CXX) -module serial.lo serial_raw.lo -o libbx_serial.la -rpath $(PLUGIN_PATH)
libbx_vga.la: vga.lo svga_cirrus.lo
$(LIBTOOL) --mode=link $(CXX) -module vga.lo svga_cirrus.lo -o libbx_vga.la -rpath $(PLUGIN_PATH)
libbx_vga.la: vga.lo vgacore.lo
$(LIBTOOL) --mode=link $(CXX) -module vga.lo vgacore.lo -o libbx_vga.la -rpath $(PLUGIN_PATH)
libbx_svga_cirrus.la: svga_cirrus.lo vgacore.lo
$(LIBTOOL) --mode=link $(CXX) -module svga_cirrus.lo vgacore.lo -o libbx_svga_cirrus.la -rpath $(PLUGIN_PATH)
#### building DLLs for win32 (tested on cygwin only)
bx_%.dll: %.o
@ -159,8 +163,11 @@ bx_gameport.dll: gameport.o
bx_serial.dll: serial.o serial_raw.o
$(CXX) $(CXXFLAGS) -shared -o bx_serial.dll serial.o serial_raw.o $(WIN32_DLL_IMPORT_LIBRARY) -lwsock32
bx_vga.dll: vga.o svga_cirrus.o
$(CXX) $(CXXFLAGS) -shared -o bx_vga.dll vga.o svga_cirrus.o $(WIN32_DLL_IMPORT_LIBRARY)
bx_vga.dll: vga.o vgacore.o
$(CXX) $(CXXFLAGS) -shared -o bx_vga.dll vga.o vgacore.o $(WIN32_DLL_IMPORT_LIBRARY)
bx_svga_cirrus.dll: svga_cirrus.o vgacore.o
$(CXX) $(CXXFLAGS) -shared -o bx_svga_cirrus.dll svga_cirrus.o vgacore.o $(WIN32_DLL_IMPORT_LIBRARY)
##### end DLL section
@ -344,7 +351,7 @@ svga_cirrus.o: svga_cirrus.@CPP_SUFFIX@ iodev.h ../bochs.h ../config.h ../osdep.
../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 vga.h svga_cirrus.h virt_timer.h
../ltdl.h ../param_names.h vgacore.h svga_cirrus.h virt_timer.h
unmapped.o: unmapped.@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 \
@ -354,7 +361,12 @@ vga.o: vga.@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 vga.h virt_timer.h
../ltdl.h ../param_names.h vgacore.h vga.h virt_timer.h
vgacore.o: vgacore.@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 vgacore.h virt_timer.h
virt_timer.o: virt_timer.@CPP_SUFFIX@ ../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 \
@ -539,7 +551,7 @@ svga_cirrus.lo: svga_cirrus.@CPP_SUFFIX@ iodev.h ../bochs.h ../config.h ../osdep
../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 vga.h svga_cirrus.h virt_timer.h
../ltdl.h ../param_names.h vgacore.h svga_cirrus.h virt_timer.h
unmapped.lo: unmapped.@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 \
@ -549,7 +561,12 @@ vga.lo: vga.@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 vga.h virt_timer.h
../ltdl.h ../param_names.h vgacore.h vga.h virt_timer.h
vgacore.lo: vgacore.@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 vgacore.h virt_timer.h
virt_timer.lo: virt_timer.@CPP_SUFFIX@ ../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 \

View File

@ -189,7 +189,16 @@ void bx_devices_c::init(BX_MEM_C *newmem)
PLUG_load_plugin(pic, PLUGTYPE_CORE);
PLUG_load_plugin(pit, PLUGTYPE_CORE);
PLUG_load_plugin(floppy, PLUGTYPE_CORE);
PLUG_load_plugin(vga, PLUGTYPE_CORE);
vga_ext = SIM->get_param_string(BXPN_VGA_EXTENSION)->getptr();
if (!strcmp(vga_ext, "cirrus")) {
#if BX_SUPPORT_CLGD54XX
PLUG_load_plugin(svga_cirrus, PLUGTYPE_CORE);
#else
BX_ERROR(("Bochs is not compiled with Cirrus support"));
#endif
} else {
PLUG_load_plugin(vga, PLUGTYPE_CORE);
}
#if BX_SUPPORT_APIC
PLUG_load_plugin(ioapic, PLUGTYPE_STANDARD);
@ -215,7 +224,6 @@ void bx_devices_c::init(BX_MEM_C *newmem)
#if BX_SUPPORT_PCI
if (SIM->get_param_bool(BXPN_I440FX_SUPPORT)->get()) {
vga_ext = SIM->get_param_string(BXPN_VGA_EXTENSION)->getptr();
if ((DEV_is_pci_device("pcivga")) &&
((!strlen(vga_ext)) || (!strcmp(vga_ext, "none")) || (!strcmp(vga_ext, "vbe")))) {
PLUG_load_plugin(pcivga, PLUGTYPE_STANDARD);
@ -324,7 +332,14 @@ void bx_devices_c::exit()
PLUG_unload_plugin(cmos);
PLUG_unload_plugin(dma);
PLUG_unload_plugin(pic);
PLUG_unload_plugin(vga);
const char *vga_ext = SIM->get_param_string(BXPN_VGA_EXTENSION)->getptr();
if (!strcmp(vga_ext, "cirrus")) {
#if BX_SUPPORT_CLGD54XX
PLUG_unload_plugin(svga_cirrus);
#endif
} else {
PLUG_unload_plugin(vga);
}
PLUG_unload_plugin(floppy);
#if BX_SUPPORT_SOUNDLOW
PLUG_unload_plugin(soundmod);

View File

@ -37,7 +37,7 @@
#define BX_PLUGGABLE
#include "iodev.h"
#include "vga.h"
#include "vgacore.h"
#include "svga_cirrus.h"
#include "virt_timer.h"
@ -61,13 +61,13 @@
#define LOG_THIS BX_CIRRUS_THIS
#if BX_USE_CIRRUS_SMF
#define VGA_READ(addr,len) bx_vga_c::read_handler(theSvga,addr,len)
#define VGA_WRITE(addr,val,len) bx_vga_c::write_handler(theSvga,addr,val,len)
#define VGA_READ(addr,len) bx_vgacore_c::read_handler(theSvga,addr,len)
#define VGA_WRITE(addr,val,len) bx_vgacore_c::write_handler(theSvga,addr,val,len)
#define SVGA_READ(addr,len) svga_read_handler(theSvga,addr,len)
#define SVGA_WRITE(addr,val,len) svga_write_handler(theSvga,addr,val,len)
#else
#define VGA_READ(addr,len) bx_vga_c::read(addr,len)
#define VGA_WRITE(addr,val,len) bx_vga_c::write(addr,val,len)
#define VGA_READ(addr,len) bx_vgacore_c::read(addr,len)
#define VGA_WRITE(addr,val,len) bx_vgacore_c::write(addr,val,len)
#define SVGA_READ(addr,len) svga_read(addr,len)
#define SVGA_WRITE(addr,val,len) svga_write(addr,val,len)
#endif // BX_USE_CIRRUS_SMF
@ -223,25 +223,24 @@
static bx_svga_cirrus_c *theSvga = NULL;
int libvga_LTX_plugin_init(plugin_t *plugin, plugintype_t type, int argc, char *argv[])
int libsvga_cirrus_LTX_plugin_init(plugin_t *plugin, plugintype_t type, int argc, char *argv[])
{
if (type == PLUGTYPE_CORE) {
theSvga = new bx_svga_cirrus_c();
bx_vga_set_smf_pointer(theSvga);
bx_devices.pluginVgaDevice = theSvga;
BX_REGISTER_DEVICE_DEVMODEL(plugin, type, theSvga, BX_PLUGIN_VGA);
BX_REGISTER_DEVICE_DEVMODEL(plugin, type, theSvga, BX_PLUGIN_CIRRUS);
return 0; // Success
} else {
return -1;
}
}
void libvga_LTX_plugin_fini(void)
void libsvga_cirrus_LTX_plugin_fini(void)
{
delete theSvga;
}
bx_svga_cirrus_c::bx_svga_cirrus_c() : bx_vga_c()
bx_svga_cirrus_c::bx_svga_cirrus_c() : bx_vgacore_c()
{
// nothing else to do
}
@ -256,8 +255,8 @@ void bx_svga_cirrus_c::init_vga_extension(void)
if (!strcmp(SIM->get_param_string(BXPN_VGA_EXTENSION)->getptr(), "cirrus")) {
BX_CIRRUS_THIS put("cirrus", "CLVGA");
// initialize SVGA stuffs.
BX_CIRRUS_THIS bx_vga_c::init_iohandlers(svga_read_handler, svga_write_handler);
BX_CIRRUS_THIS bx_vga_c::init_systemtimer(svga_timer_handler, svga_param_handler);
BX_CIRRUS_THIS bx_vgacore_c::init_iohandlers(svga_read_handler, svga_write_handler);
BX_CIRRUS_THIS bx_vgacore_c::init_systemtimer(svga_timer_handler, svga_param_handler);
BX_CIRRUS_THIS pci_enabled = DEV_is_pci_device("cirrus");
BX_CIRRUS_THIS svga_init_members();
#if BX_SUPPORT_PCI
@ -277,7 +276,7 @@ void bx_svga_cirrus_c::init_vga_extension(void)
} else {
BX_CIRRUS_THIS sequencer.reg[0x07] = 0x00; // Cirrus extension disabled
// initialize VGA extension, read/write handlers and timer
BX_CIRRUS_THIS bx_vga_c::init_vga_extension();
BX_CIRRUS_THIS bx_vgacore_c::init_vga_extension();
}
}
@ -359,7 +358,7 @@ void bx_svga_cirrus_c::svga_init_members()
void bx_svga_cirrus_c::reset(unsigned type)
{
// reset VGA stuffs.
BX_CIRRUS_THIS bx_vga_c::reset(type);
BX_CIRRUS_THIS bx_vgacore_c::reset(type);
if (!strcmp(SIM->get_param_string(BXPN_VGA_EXTENSION)->getptr(), "cirrus")) {
// reset SVGA stuffs.
@ -375,6 +374,7 @@ void bx_svga_cirrus_c::register_state(void)
if (!strcmp(SIM->get_param_string(BXPN_VGA_EXTENSION)->getptr(), "cirrus")) {
bx_list_c *list = new bx_list_c(SIM->get_bochs_root(), "svga_cirrus", "Cirrus SVGA State", 18);
bx_vgacore_c::register_state(list);
bx_list_c *crtc = new bx_list_c(list, "crtc", 2);
new bx_shadow_num_c(crtc, "index", &BX_CIRRUS_THIS crtc.index, BASE_HEX);
reg = new bx_list_c(crtc, "reg", CIRRUS_CRTC_MAX+1);
@ -426,13 +426,12 @@ void bx_svga_cirrus_c::register_state(void)
}
#endif
}
bx_vga_c::register_state();
}
void bx_svga_cirrus_c::after_restore_state(void)
{
if ((BX_CIRRUS_THIS sequencer.reg[0x07] & 0x01) == CIRRUS_SR7_BPP_VGA) {
BX_CIRRUS_THIS bx_vga_c::after_restore_state();
BX_CIRRUS_THIS bx_vgacore_c::after_restore_state();
} else {
#if BX_SUPPORT_PCI
if (BX_CIRRUS_THIS pci_enabled) {
@ -479,7 +478,7 @@ void bx_svga_cirrus_c::redraw_area(unsigned x0, unsigned y0,
}
if ((BX_CIRRUS_THIS sequencer.reg[0x07] & 0x01) == CIRRUS_SR7_BPP_VGA) {
BX_CIRRUS_THIS bx_vga_c::redraw_area(x0,y0,width,height);
BX_CIRRUS_THIS bx_vgacore_c::redraw_area(x0,y0,width,height);
return;
}
@ -583,7 +582,7 @@ Bit8u bx_svga_cirrus_c::mem_read(bx_phy_address addr)
#endif
if ((BX_CIRRUS_THIS sequencer.reg[0x07] & 0x01) == CIRRUS_SR7_BPP_VGA) {
return BX_CIRRUS_THIS bx_vga_c::mem_read(addr);
return BX_CIRRUS_THIS bx_vgacore_c::mem_read(addr);
}
#if BX_SUPPORT_PCI
@ -709,7 +708,7 @@ bx_bool bx_svga_cirrus_c::cirrus_mem_write_handler(bx_phy_address addr, unsigned
void bx_svga_cirrus_c::mem_write(bx_phy_address addr, Bit8u value)
{
if ((BX_CIRRUS_THIS sequencer.reg[0x07] & 0x01) == CIRRUS_SR7_BPP_VGA) {
BX_CIRRUS_THIS bx_vga_c::mem_write(addr,value);
BX_CIRRUS_THIS bx_vgacore_c::mem_write(addr,value);
return;
}
@ -824,7 +823,7 @@ void bx_svga_cirrus_c::mem_write(bx_phy_address addr, Bit8u value)
int bx_svga_cirrus_c::get_snapshot_mode()
{
if ((BX_CIRRUS_THIS sequencer.reg[0x07] & 0x01) == CIRRUS_SR7_BPP_VGA) {
return BX_CIRRUS_THIS bx_vga_c::get_snapshot_mode();
return BX_CIRRUS_THIS bx_vgacore_c::get_snapshot_mode();
} else {
return BX_GUI_SNAPSHOT_GFX;
}
@ -833,7 +832,7 @@ int bx_svga_cirrus_c::get_snapshot_mode()
void bx_svga_cirrus_c::get_text_snapshot(Bit8u **text_snapshot,
unsigned *txHeight, unsigned *txWidth)
{
BX_CIRRUS_THIS bx_vga_c::get_text_snapshot(text_snapshot,txHeight,txWidth);
BX_CIRRUS_THIS bx_vgacore_c::get_text_snapshot(text_snapshot,txHeight,txWidth);
}
Bit32u bx_svga_cirrus_c::get_gfx_snapshot(Bit8u **snapshot_ptr, Bit8u **palette_ptr,
@ -864,15 +863,10 @@ Bit32u bx_svga_cirrus_c::get_gfx_snapshot(Bit8u **snapshot_ptr, Bit8u **palette_
}
return len;
} else {
return BX_CIRRUS_THIS bx_vga_c::get_gfx_snapshot(snapshot_ptr, palette_ptr, iHeight, iWidth, iDepth);
return BX_CIRRUS_THIS bx_vgacore_c::get_gfx_snapshot(snapshot_ptr, palette_ptr, iHeight, iWidth, iDepth);
}
}
void bx_svga_cirrus_c::trigger_timer(void *this_ptr)
{
BX_CIRRUS_THIS timer_handler(this_ptr);
}
Bit64s bx_svga_cirrus_c::svga_param_handler(bx_param_c *param, int set, Bit64s val)
{
Bit32u interval;
@ -1279,7 +1273,7 @@ void bx_svga_cirrus_c::svga_update(void)
BX_CIRRUS_THIS s.vga_mem_updated = 1;
BX_CIRRUS_THIS svga_needs_update_mode = 0;
}
BX_CIRRUS_THIS bx_vga_c::update();
BX_CIRRUS_THIS bx_vgacore_c::update();
return;
}
else {

View File

@ -61,7 +61,7 @@ typedef void (*bx_cirrus_bitblt_rop_t)(
int dstpitch,int srcpitch,
int bltwidth,int bltheight);
class bx_svga_cirrus_c : public bx_vga_c
class bx_svga_cirrus_c : public bx_vgacore_c
#if BX_SUPPORT_PCI
, public bx_pci_device_stub_c
#endif
@ -81,7 +81,6 @@ public:
unsigned *txHeight, unsigned *txWidth);
virtual Bit32u get_gfx_snapshot(Bit8u **snapshot_ptr, Bit8u **palette_ptr,
unsigned *iHeight, unsigned *iWidth, unsigned *iDepth);
virtual void trigger_timer(void *this_ptr);
virtual void register_state(void);
virtual void after_restore_state(void);

File diff suppressed because it is too large Load Diff

View File

@ -110,29 +110,22 @@
# define BX_VGA_THIS_PTR this
#endif
class bx_vga_c : public bx_vga_stub_c {
class bx_vga_c : public bx_vgacore_c {
public:
bx_vga_c();
virtual ~bx_vga_c();
virtual void init(void);
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);
virtual void mem_write(bx_phy_address addr, Bit8u value);
virtual void trigger_timer(void *this_ptr);
virtual void register_state(void);
virtual void after_restore_state(void);
#if BX_DEBUGGER
virtual void debug_dump(void);
#endif
virtual void redraw_area(unsigned x0, unsigned y0,
unsigned width, unsigned height);
virtual int get_snapshot_mode(void);
virtual void get_text_snapshot(Bit8u **text_snapshot, unsigned *txHeight,
unsigned *txWidth);
virtual Bit32u get_gfx_snapshot(Bit8u **snapshot_ptr, Bit8u **palette_ptr,
unsigned *iHeight, unsigned *iWidth, unsigned *iDepth);
virtual void init_vga_extension(void);
@ -144,147 +137,13 @@ public:
static Bit64s vga_param_handler(bx_param_c *param, int set, Bit64s val);
protected:
void init_standard_vga(void);
void init_gui(void);
void init_iohandlers(bx_read_handler_t f_read, bx_write_handler_t f_write);
void init_systemtimer(bx_timer_handler_t f_timer, param_event_handler f_param);
static Bit32u read_handler(void *this_ptr, Bit32u address, unsigned io_len);
static void write_handler(void *this_ptr, Bit32u address, Bit32u value, unsigned io_len);
#if BX_USE_VGA_SMF
static void write_handler_no_log(void *this_ptr, Bit32u address, Bit32u value, unsigned io_len);
#endif
#if BX_USE_VGA_SMF == 0
Bit32u read(Bit32u address, unsigned io_len);
#endif
void write(Bit32u address, Bit32u value, unsigned io_len, bx_bool no_log);
BX_VGA_SMF Bit8u get_vga_pixel(Bit16u x, Bit16u y, Bit16u saddr, Bit16u lc, Bit8u **plane);
BX_VGA_SMF bx_bool get_dac_palette(Bit8u **palette_ptr, Bit8u shift);
BX_VGA_SMF void update(void);
BX_VGA_SMF void determine_screen_dimensions(unsigned *piHeight, unsigned *piWidth);
struct {
struct {
bx_bool color_emulation; // 1=color emulation, base address = 3Dx
// 0=mono emulation, base address = 3Bx
bx_bool enable_ram; // enable CPU access to video memory if set
Bit8u clock_select; // 0=25Mhz 1=28Mhz
bx_bool select_high_bank; // when in odd/even modes, select
// high 64k bank if set
bx_bool horiz_sync_pol; // bit6: negative if set
bx_bool vert_sync_pol; // bit7: negative if set
// bit7,bit6 represent number of lines on display:
// 0 = reserved
// 1 = 400 lines
// 2 = 350 lines
// 3 - 480 lines
} misc_output;
struct {
Bit8u address;
Bit8u reg[0x19];
bx_bool write_protect;
} CRTC;
struct {
bx_bool flip_flop; /* 0 = address, 1 = data-write */
unsigned address; /* register number */
bx_bool video_enabled;
Bit8u palette_reg[16];
Bit8u overscan_color;
Bit8u color_plane_enable;
Bit8u horiz_pel_panning;
Bit8u color_select;
struct {
bx_bool graphics_alpha;
bx_bool display_type;
bx_bool enable_line_graphics;
bx_bool blink_intensity;
bx_bool pixel_panning_compat;
bx_bool pixel_clock_select;
bx_bool internal_palette_size;
} mode_ctrl;
} attribute_ctrl;
struct {
Bit8u write_data_register;
Bit8u write_data_cycle; /* 0, 1, 2 */
Bit8u read_data_register;
Bit8u read_data_cycle; /* 0, 1, 2 */
Bit8u dac_state;
struct {
Bit8u red;
Bit8u green;
Bit8u blue;
} data[256];
Bit8u mask;
} pel;
struct {
Bit8u index;
Bit8u set_reset;
Bit8u enable_set_reset;
Bit8u color_compare;
Bit8u data_rotate;
Bit8u raster_op;
Bit8u read_map_select;
Bit8u write_mode;
bx_bool read_mode;
bx_bool odd_even;
bx_bool chain_odd_even;
Bit8u shift_reg;
bx_bool graphics_alpha;
Bit8u memory_mapping; /* 0 = use A0000-BFFFF
* 1 = use A0000-AFFFF EGA/VGA graphics modes
* 2 = use B0000-B7FFF Monochrome modes
* 3 = use B8000-BFFFF CGA modes
*/
Bit8u color_dont_care;
Bit8u bitmask;
Bit8u latch[4];
} graphics_ctrl;
struct {
Bit8u index;
Bit8u map_mask;
bx_bool reset1;
bx_bool reset2;
Bit8u reg1;
Bit8u char_map_select;
bx_bool extended_mem;
bx_bool odd_even;
bx_bool chain_four;
} sequencer;
bx_bool vga_enabled;
bx_bool vga_mem_updated;
unsigned line_offset;
unsigned line_compare;
unsigned vertical_display_end;
unsigned blink_counter;
bx_bool *vga_tile_updated;
Bit8u *memory;
Bit32u memsize;
Bit8u text_snapshot[128 * 1024]; // current text snapshot
Bit8u tile[X_TILESIZE * Y_TILESIZE * 4]; /**< Currently allocates the tile as large as needed. */
Bit16u charmap_address;
bx_bool x_dotclockdiv2;
bx_bool y_doublescan;
Bit16u last_xres;
Bit16u last_yres;
Bit8u last_bpp;
Bit8u last_msl;
Bit16u max_xres;
Bit16u max_yres;
Bit16u num_x_tiles;
Bit16u num_y_tiles;
} s; // state information
int timer_id;
bx_bool extension_init;
bx_bool pci_enabled;
// Bochs VBE section
virtual bx_bool vbe_set_base_addr(Bit32u *addr, Bit8u *pci_conf);
@ -326,8 +185,4 @@ private:
} vbe; // VBE state information
};
#if BX_SUPPORT_CLGD54XX
void bx_vga_set_smf_pointer(bx_vga_c *theVga_ptr);
#endif
#endif

2483
bochs/iodev/vgacore.cc Normal file

File diff suppressed because it is too large Load Diff

220
bochs/iodev/vgacore.h Normal file
View File

@ -0,0 +1,220 @@
/////////////////////////////////////////////////////////////////////////
// $Id$
/////////////////////////////////////////////////////////////////////////
//
// 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
// 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_VGACORE_H
#define BX_IODEV_VGACORE_H
// Make colour
#define MAKE_COLOUR(red, red_shiftfrom, red_shiftto, red_mask, \
green, green_shiftfrom, green_shiftto, green_mask, \
blue, blue_shiftfrom, blue_shiftto, blue_mask) \
( \
((((red_shiftto) > (red_shiftfrom)) ? \
(red) << ((red_shiftto) - (red_shiftfrom)) : \
(red) >> ((red_shiftfrom) - (red_shiftto))) & \
(red_mask)) | \
((((green_shiftto) > (green_shiftfrom)) ? \
(green) << ((green_shiftto) - (green_shiftfrom)) : \
(green) >> ((green_shiftfrom) - (green_shiftto))) & \
(green_mask)) | \
((((blue_shiftto) > (blue_shiftfrom)) ? \
(blue) << ((blue_shiftto) - (blue_shiftfrom)) : \
(blue) >> ((blue_shiftfrom) - (blue_shiftto))) & \
(blue_mask)) \
)
#define X_TILESIZE 16
#define Y_TILESIZE 24
class bx_vgacore_c : public bx_vga_stub_c {
public:
bx_vgacore_c();
virtual ~bx_vgacore_c();
virtual void init(void);
virtual void reset(unsigned type) {}
static bx_bool mem_read_handler(bx_phy_address addr, unsigned len, void *data, void *param);
static bx_bool mem_write_handler(bx_phy_address addr, unsigned len, void *data, void *param);
virtual Bit8u mem_read(bx_phy_address addr);
virtual void mem_write(bx_phy_address addr, Bit8u value);
virtual void trigger_timer(void *this_ptr);
virtual void register_state(bx_list_c *parent);
virtual void after_restore_state(void);
#if BX_DEBUGGER
virtual void debug_dump(void);
#endif
virtual void redraw_area(unsigned x0, unsigned y0,
unsigned width, unsigned height);
virtual int get_snapshot_mode(void);
virtual void get_text_snapshot(Bit8u **text_snapshot, unsigned *txHeight,
unsigned *txWidth);
virtual Bit32u get_gfx_snapshot(Bit8u **snapshot_ptr, Bit8u **palette_ptr,
unsigned *iHeight, unsigned *iWidth, unsigned *iDepth);
virtual void init_vga_extension(void) {}
static void timer_handler(void *);
void timer(void);
protected:
void init_standard_vga(void);
void init_gui(void);
void init_iohandlers(bx_read_handler_t f_read, bx_write_handler_t f_write);
void init_systemtimer(bx_timer_handler_t f_timer, param_event_handler f_param);
static Bit32u read_handler(void *this_ptr, Bit32u address, unsigned io_len);
static void write_handler(void *this_ptr, Bit32u address, Bit32u value, unsigned io_len);
Bit32u read(Bit32u address, unsigned io_len);
void write(Bit32u address, Bit32u value, unsigned io_len, bx_bool no_log);
Bit8u get_vga_pixel(Bit16u x, Bit16u y, Bit16u saddr, Bit16u lc, Bit8u **plane);
bx_bool get_dac_palette(Bit8u **palette_ptr, Bit8u shift);
void update(void);
void determine_screen_dimensions(unsigned *piHeight, unsigned *piWidth);
struct {
struct {
bx_bool color_emulation; // 1=color emulation, base address = 3Dx
// 0=mono emulation, base address = 3Bx
bx_bool enable_ram; // enable CPU access to video memory if set
Bit8u clock_select; // 0=25Mhz 1=28Mhz
bx_bool select_high_bank; // when in odd/even modes, select
// high 64k bank if set
bx_bool horiz_sync_pol; // bit6: negative if set
bx_bool vert_sync_pol; // bit7: negative if set
// bit7,bit6 represent number of lines on display:
// 0 = reserved
// 1 = 400 lines
// 2 = 350 lines
// 3 - 480 lines
} misc_output;
struct {
Bit8u address;
Bit8u reg[0x19];
bx_bool write_protect;
} CRTC;
struct {
bx_bool flip_flop; /* 0 = address, 1 = data-write */
unsigned address; /* register number */
bx_bool video_enabled;
Bit8u palette_reg[16];
Bit8u overscan_color;
Bit8u color_plane_enable;
Bit8u horiz_pel_panning;
Bit8u color_select;
struct {
bx_bool graphics_alpha;
bx_bool display_type;
bx_bool enable_line_graphics;
bx_bool blink_intensity;
bx_bool pixel_panning_compat;
bx_bool pixel_clock_select;
bx_bool internal_palette_size;
} mode_ctrl;
} attribute_ctrl;
struct {
Bit8u write_data_register;
Bit8u write_data_cycle; /* 0, 1, 2 */
Bit8u read_data_register;
Bit8u read_data_cycle; /* 0, 1, 2 */
Bit8u dac_state;
struct {
Bit8u red;
Bit8u green;
Bit8u blue;
} data[256];
Bit8u mask;
} pel;
struct {
Bit8u index;
Bit8u set_reset;
Bit8u enable_set_reset;
Bit8u color_compare;
Bit8u data_rotate;
Bit8u raster_op;
Bit8u read_map_select;
Bit8u write_mode;
bx_bool read_mode;
bx_bool odd_even;
bx_bool chain_odd_even;
Bit8u shift_reg;
bx_bool graphics_alpha;
Bit8u memory_mapping; /* 0 = use A0000-BFFFF
* 1 = use A0000-AFFFF EGA/VGA graphics modes
* 2 = use B0000-B7FFF Monochrome modes
* 3 = use B8000-BFFFF CGA modes
*/
Bit8u color_dont_care;
Bit8u bitmask;
Bit8u latch[4];
} graphics_ctrl;
struct {
Bit8u index;
Bit8u map_mask;
bx_bool reset1;
bx_bool reset2;
Bit8u reg1;
Bit8u char_map_select;
bx_bool extended_mem;
bx_bool odd_even;
bx_bool chain_four;
} sequencer;
bx_bool vga_enabled;
bx_bool vga_mem_updated;
unsigned line_offset;
unsigned line_compare;
unsigned vertical_display_end;
unsigned blink_counter;
bx_bool *vga_tile_updated;
Bit8u *memory;
Bit32u memsize;
Bit8u text_snapshot[128 * 1024]; // current text snapshot
Bit8u tile[X_TILESIZE * Y_TILESIZE * 4]; /**< Currently allocates the tile as large as needed. */
Bit16u charmap_address;
bx_bool x_dotclockdiv2;
bx_bool y_doublescan;
Bit8u plane_shift;
Bit32u plane_offset;
Bit8u dac_shift;
Bit16u last_xres;
Bit16u last_yres;
Bit8u last_bpp;
Bit8u last_msl;
Bit16u max_xres;
Bit16u max_yres;
Bit16u num_x_tiles;
Bit16u num_y_tiles;
} s; // state information
int timer_id;
bx_bool extension_init;
bx_bool pci_enabled;
};
#endif

View File

@ -43,6 +43,7 @@ extern "C" {
#define BX_PLUGIN_BIOSDEV "biosdev"
#define BX_PLUGIN_CMOS "cmos"
#define BX_PLUGIN_VGA "vga"
#define BX_PLUGIN_CIRRUS "svga_cirrus"
#define BX_PLUGIN_FLOPPY "floppy"
#define BX_PLUGIN_PARALLEL "parallel"
#define BX_PLUGIN_SERIAL "serial"
@ -417,6 +418,7 @@ DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(dma)
DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(pic)
DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(pit)
DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(vga)
DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(svga_cirrus)
DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(floppy)
DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(parallel)
DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(pci)