- reorganisation of the vga init code:

- using the same init() method for all display adapters
  - new method protected init_standard_vga() for the shared vga core
  - new method init_vga_extension() implements the extended features
- moved loading of vgabios image for the ISA case from main.cc to the vga init code
This commit is contained in:
Volker Ruppert 2011-07-03 15:31:16 +00:00
parent 5a1cd21ca9
commit 4699840aaf
5 changed files with 41 additions and 47 deletions

View File

@ -245,18 +245,14 @@ bx_svga_cirrus_c::~bx_svga_cirrus_c()
BX_DEBUG(("Exit"));
}
void bx_svga_cirrus_c::init(void)
void bx_svga_cirrus_c::init_vga_extension(void)
{
// initialize VGA stuffs.
BX_CIRRUS_THIS bx_vga_c::init();
if (!strcmp(SIM->get_param_string(BXPN_VGA_EXTENSION)->getptr(), "cirrus")) {
BX_CIRRUS_THIS put("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);
#if BX_SUPPORT_PCI
BX_CIRRUS_THIS pci_enabled = DEV_is_pci_device("cirrus");
#endif
BX_CIRRUS_THIS svga_init_members();
#if BX_SUPPORT_PCI
if (BX_CIRRUS_THIS pci_enabled)
@ -272,11 +268,8 @@ void bx_svga_cirrus_c::init(void)
BX_CIRRUS_THIS extension_init = 1;
} else {
BX_CIRRUS_THIS sequencer.reg[0x07] = 0x00; // Cirrus extension disabled
// initialize VGA read/write handlers and timer
BX_CIRRUS_THIS bx_vga_c::init_iohandlers(
bx_vga_c::read_handler, bx_vga_c::write_handler);
BX_CIRRUS_THIS bx_vga_c::init_systemtimer(
bx_vga_c::timer_handler, bx_vga_c::vga_param_handler);
// initialize VGA extension, read/write handlers and timer
BX_CIRRUS_THIS bx_vga_c::init_vga_extension();
}
}

View File

@ -70,7 +70,7 @@ public:
bx_svga_cirrus_c();
virtual ~bx_svga_cirrus_c();
virtual void init(void);
virtual void init_vga_extension(void);
virtual void reset(unsigned type);
virtual void redraw_area(unsigned x0, unsigned y0,
unsigned width, unsigned height);
@ -212,9 +212,6 @@ private:
Bit32u bank_base[2];
Bit32u bank_limit[2];
Bit8u *disp_ptr;
#if BX_SUPPORT_PCI
bx_bool pci_enabled;
#endif
struct {
bx_cirrus_bitblt_rop_t rop_handler;

View File

@ -118,11 +118,27 @@ bx_vga_c::~bx_vga_c()
}
void bx_vga_c::init(void)
{
BX_VGA_THIS extension_init = 0;
BX_VGA_THIS pci_enabled = 0;
BX_VGA_THIS init_standard_vga();
BX_VGA_THIS init_vga_extension();
char *strptr = SIM->get_param_string(BXPN_VGA_EXTENSION)->getptr();
if (!BX_VGA_THIS extension_init &&
(strlen(strptr) > 0) && strcmp(strptr, "none")) {
BX_PANIC(("unknown display extension: %s", strptr));
}
if (!BX_VGA_THIS pci_enabled) {
BX_MEM(0)->load_ROM(SIM->get_param_string(BXPN_VGA_ROM_PATH)->getptr(), 0xc0000, 1);
}
}
void bx_vga_c::init_standard_vga(void)
{
unsigned i,string_i;
unsigned x,y;
unsigned addr;
Bit16u max_xres, max_yres, max_bpp;
int argc;
char *argv[16];
char *ptr;
@ -218,9 +234,6 @@ void bx_vga_c::init(void)
for (x=0; x<640/X_TILESIZE; x++)
SET_TILE_UPDATED (x, y, 0);
BX_VGA_THIS extension_init = 0;
BX_VGA_THIS extension_checked = 0;
// initialize memory, handlers and timer (depending on extension)
extname = SIM->get_param_string(BXPN_VGA_EXTENSION)->getptr();
if ((strlen(extname) == 0) || (!strcmp(extname, "none"))) {
@ -229,10 +242,6 @@ void bx_vga_c::init(void)
BX_VGA_THIS s.memory = new Bit8u[BX_VGA_THIS s.memsize];
memset(BX_VGA_THIS s.memory, 0, BX_VGA_THIS s.memsize);
}
#if !BX_SUPPORT_CLGD54XX
BX_VGA_THIS init_iohandlers(read_handler,write_handler);
BX_VGA_THIS init_systemtimer(timer_handler, vga_param_handler);
#endif
DEV_register_memory_handlers(theVga, mem_read_handler, mem_write_handler,
0xa0000, 0xbffff);
@ -277,26 +286,32 @@ void bx_vga_c::init(void)
}
}
}
void bx_vga_c::init_vga_extension(void)
{
unsigned addr;
Bit16u max_xres, max_yres, max_bpp;
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);
// The following is for the VBE display extension
BX_VGA_THIS vbe.enabled=0;
BX_VGA_THIS vbe.dac_8bit=0;
BX_VGA_THIS vbe.base_address = 0x0000;
if (!strcmp(extname, "vbe")) {
if (!strcmp(SIM->get_param_string(BXPN_VGA_EXTENSION)->getptr(), "vbe")) {
BX_VGA_THIS put("BXVGA");
for (addr=VBE_DISPI_IOPORT_INDEX; addr<=VBE_DISPI_IOPORT_DATA; addr++) {
DEV_register_ioread_handler(this, vbe_read_handler, addr, "vga video", 7);
DEV_register_iowrite_handler(this, vbe_write_handler, addr, "vga video", 7);
}
#if BX_SUPPORT_PCI
if ((!SIM->get_param_bool(BXPN_I440FX_SUPPORT)->get()) ||
(!DEV_is_pci_device(BX_PLUGIN_PCIVGA)))
#endif
{
if (!BX_VGA_THIS pci_enabled) {
BX_VGA_THIS vbe.base_address = VBE_DISPI_LFB_PHYSICAL_ADDRESS;
DEV_register_memory_handlers(theVga, mem_read_handler, mem_write_handler,
BX_VGA_THIS vbe.base_address,
BX_VGA_THIS vbe.base_address + VBE_DISPI_TOTAL_VIDEO_MEMORY_BYTES - 1);
}
if (BX_VGA_THIS s.memory == NULL)
BX_VGA_THIS s.memory = new Bit8u[VBE_DISPI_TOTAL_VIDEO_MEMORY_BYTES];
@ -387,19 +402,6 @@ void bx_vga_c::init_systemtimer(bx_timer_handler_t f_timer, param_event_handler
}
}
void bx_vga_c::reset(unsigned type)
{
if (!BX_VGA_THIS extension_checked) {
char *strptr = SIM->get_param_string(BXPN_VGA_EXTENSION)->getptr();
if (!BX_VGA_THIS extension_init &&
(strlen(strptr) > 0) &&
strcmp(strptr, "none")) {
BX_PANIC(("unknown display extension: %s", strptr));
}
BX_VGA_THIS extension_checked = 1;
}
}
void bx_vga_c::register_state(void)
{
unsigned i;

View File

@ -120,7 +120,7 @@ public:
bx_vga_c();
virtual ~bx_vga_c();
virtual void init(void);
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);
@ -138,6 +138,7 @@ public:
virtual void get_text_snapshot(Bit8u **text_snapshot, unsigned *txHeight,
unsigned *txWidth);
virtual Bit8u get_actl_palette_idx(Bit8u index);
virtual void init_vga_extension(void);
static void timer_handler(void *);
#if BX_USE_VGA_SMF == 0
@ -146,6 +147,7 @@ public:
static Bit64s vga_param_handler(bx_param_c *param, int set, Bit64s val);
protected:
void init_standard_vga(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);
@ -277,7 +279,7 @@ protected:
int timer_id;
bx_bool extension_init;
bx_bool extension_checked;
bx_bool pci_enabled;
// Bochs VBE section
virtual bx_bool vbe_set_base_addr(Bit32u *addr, Bit8u *pci_conf);
@ -293,6 +295,7 @@ protected:
void vbe_write(Bit32u address, Bit32u value, unsigned io_len, bx_bool no_log);
#endif
private:
struct {
Bit16u cur_dispi;
Bit32u base_address;

View File

@ -1119,10 +1119,9 @@ void bx_init_hardware()
BX_MEM(0)->init_memory(memSize, hostMemSize);
// First load the BIOS and VGABIOS
// First load the system BIOS (VGABIOS loading moved to the vga code)
BX_MEM(0)->load_ROM(SIM->get_param_string(BXPN_ROM_PATH)->getptr(),
SIM->get_param_num(BXPN_ROM_ADDRESS)->get(), 0);
BX_MEM(0)->load_ROM(SIM->get_param_string(BXPN_VGA_ROM_PATH)->getptr(), 0xc0000, 1);
// Then load the optional ROM images
if (strcmp(SIM->get_param_string(BXPN_OPTROM1_PATH)->getptr(), "") !=0)