From 5ec78eaae2d671bccf5209cb28f11154bd5b2f94 Mon Sep 17 00:00:00 2001 From: Volker Ruppert Date: Thu, 12 Oct 2017 19:18:23 +0000 Subject: [PATCH] Modified VGA extension init method. Now it returns 1 if the extension code has initialized the VGA compatible video memory. If it has returned 0 the VGA core code sets up the default VGA memory (256k). --- bochs/iodev/display/svga_cirrus.cc | 4 ++-- bochs/iodev/display/svga_cirrus.h | 2 +- bochs/iodev/display/vga.cc | 6 ++++-- bochs/iodev/display/vga.h | 2 +- bochs/iodev/display/vgacore.cc | 24 ++++++++++-------------- bochs/iodev/display/vgacore.h | 3 +-- 6 files changed, 19 insertions(+), 22 deletions(-) diff --git a/bochs/iodev/display/svga_cirrus.cc b/bochs/iodev/display/svga_cirrus.cc index 1e7d0021e..5b7389224 100644 --- a/bochs/iodev/display/svga_cirrus.cc +++ b/bochs/iodev/display/svga_cirrus.cc @@ -252,7 +252,7 @@ bx_svga_cirrus_c::~bx_svga_cirrus_c() BX_DEBUG(("Exit")); } -void bx_svga_cirrus_c::init_vga_extension(void) +bx_bool bx_svga_cirrus_c::init_vga_extension(void) { BX_CIRRUS_THIS put("CIRRUS"); // initialize SVGA stuffs. @@ -272,11 +272,11 @@ void bx_svga_cirrus_c::init_vga_extension(void) } BX_CIRRUS_THIS s.max_xres = 1600; BX_CIRRUS_THIS s.max_yres = 1200; - BX_CIRRUS_THIS extension_init = 1; #if BX_DEBUGGER // register device for the 'info device' command (calls debug_dump()) bx_dbg_register_debug_info("cirrus", this); #endif + return 1; } void bx_svga_cirrus_c::svga_init_members() diff --git a/bochs/iodev/display/svga_cirrus.h b/bochs/iodev/display/svga_cirrus.h index 0e817dac9..0df54ff21 100644 --- a/bochs/iodev/display/svga_cirrus.h +++ b/bochs/iodev/display/svga_cirrus.h @@ -68,7 +68,7 @@ public: bx_svga_cirrus_c(); virtual ~bx_svga_cirrus_c(); - virtual void init_vga_extension(void); + virtual bx_bool init_vga_extension(void); virtual void reset(unsigned type); virtual void redraw_area(unsigned x0, unsigned y0, unsigned width, unsigned height); diff --git a/bochs/iodev/display/vga.cc b/bochs/iodev/display/vga.cc index 0f0ef6f3e..d6be28114 100644 --- a/bochs/iodev/display/vga.cc +++ b/bochs/iodev/display/vga.cc @@ -86,10 +86,11 @@ bx_vga_c::~bx_vga_c() BX_DEBUG(("Exit")); } -void bx_vga_c::init_vga_extension(void) +bx_bool bx_vga_c::init_vga_extension(void) { unsigned addr; Bit16u max_xres, max_yres, max_bpp; + bx_bool ret = 0; BX_VGA_THIS init_iohandlers(read_handler, write_handler); BX_VGA_THIS pci_enabled = SIM->is_pci_device("pcivga"); @@ -148,7 +149,7 @@ 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; + ret = 1; BX_INFO(("VBE Bochs Display Extension Enabled")); } @@ -176,6 +177,7 @@ void bx_vga_c::init_vga_extension(void) // register device for the 'info device' command (calls debug_dump()) bx_dbg_register_debug_info("vga", this); #endif + return ret; } void bx_vga_c::reset(unsigned type) diff --git a/bochs/iodev/display/vga.h b/bochs/iodev/display/vga.h index 8d8573641..c61eaa20b 100644 --- a/bochs/iodev/display/vga.h +++ b/bochs/iodev/display/vga.h @@ -104,7 +104,7 @@ public: virtual void redraw_area(unsigned x0, unsigned y0, unsigned width, unsigned height); - virtual void init_vga_extension(void); + virtual bx_bool init_vga_extension(void); #if BX_SUPPORT_PCI virtual void pci_write_handler(Bit8u address, Bit32u value, unsigned io_len); diff --git a/bochs/iodev/display/vgacore.cc b/bochs/iodev/display/vgacore.cc index acdde0ae8..5aa1f1104 100644 --- a/bochs/iodev/display/vgacore.cc +++ b/bochs/iodev/display/vgacore.cc @@ -101,11 +101,16 @@ void bx_vgacore_c::init(void) unsigned x,y; BX_VGA_THIS vgaext = SIM->get_param_string(BXPN_VGA_EXTENSION); - BX_VGA_THIS extension_init = 0; BX_VGA_THIS pci_enabled = 0; BX_VGA_THIS init_standard_vga(); - BX_VGA_THIS init_vga_extension(); + if (!BX_VGA_THIS init_vga_extension()) { + // VGA memory not yet initialized + BX_VGA_THIS s.memsize = 0x40000; + if (BX_VGA_THIS s.memory == NULL) + BX_VGA_THIS s.memory = new Bit8u[BX_VGA_THIS s.memsize]; + memset(BX_VGA_THIS s.memory, 0, BX_VGA_THIS s.memsize); + } BX_VGA_THIS init_gui(); BX_VGA_THIS s.num_x_tiles = BX_VGA_THIS s.max_xres / X_TILESIZE + @@ -117,9 +122,6 @@ void bx_vgacore_c::init(void) for (x = 0; x < BX_VGA_THIS s.num_x_tiles; x++) SET_TILE_UPDATED(x, y, 0); - if (!BX_VGA_THIS extension_init && !BX_VGA_THIS vgaext->isempty()) { - BX_PANIC(("unknown display extension: %s", BX_VGA_THIS vgaext->getptr())); - } if (!BX_VGA_THIS pci_enabled) { BX_MEM(0)->load_ROM(SIM->get_param_string(BXPN_VGA_ROM_PATH)->getptr(), 0xc0000, 1); } @@ -161,20 +163,14 @@ void bx_vgacore_c::init_standard_vga(void) BX_VGA_THIS s.vga_override = 0; - // initialize memory, handlers and timer (depending on extension) - if (BX_VGA_THIS vgaext->isempty()) { - BX_VGA_THIS s.memsize = 0x40000; - if (BX_VGA_THIS s.memory == NULL) - BX_VGA_THIS s.memory = new Bit8u[BX_VGA_THIS s.memsize]; - memset(BX_VGA_THIS s.memory, 0, BX_VGA_THIS s.memsize); - } + // initialize memory handlers, timer and CMOS DEV_register_memory_handlers(BX_VGA_THIS_PTR, mem_read_handler, mem_write_handler, 0xa0000, 0xbffff); + BX_VGA_THIS init_systemtimer(); + // video card with BIOS ROM DEV_cmos_set_reg(0x14, (DEV_cmos_get_reg(0x14) & 0xcf) | 0x00); - - BX_VGA_THIS init_systemtimer(); } void bx_vgacore_c::init_gui(void) diff --git a/bochs/iodev/display/vgacore.h b/bochs/iodev/display/vgacore.h index 71e79364c..f25fac603 100644 --- a/bochs/iodev/display/vgacore.h +++ b/bochs/iodev/display/vgacore.h @@ -79,7 +79,7 @@ public: virtual void refresh_display(void *this_ptr, bx_bool redraw); virtual void get_text_snapshot(Bit8u **text_snapshot, unsigned *txHeight, unsigned *txWidth); - virtual void init_vga_extension(void) {} + virtual bx_bool init_vga_extension(void) {return 0;} static void vga_timer_handler(void *); static Bit64s vga_param_handler(bx_param_c *param, int set, Bit64s val); @@ -243,7 +243,6 @@ protected: int timer_id; bx_bool realtime; bx_param_string_c *vgaext; - bx_bool extension_init; bx_bool pci_enabled; };