From d748f22ed0ea33b06e5a4032512ae7a9bb676550 Mon Sep 17 00:00:00 2001 From: Volker Ruppert Date: Sun, 22 Feb 2004 13:03:02 +0000 Subject: [PATCH] - new gui function get_capabilities() returns the maximum values for xres, yres and bpp (done for the x display library) - new switch VBE_DISPI_GETCAPS. The xres, yres and bpp registers return the gui capabilities if enabled. - VBE_DISPI_ID3 defined --- bochs/gui/gui.cc | 12 ++++++++++-- bochs/gui/gui.h | 3 ++- bochs/gui/x.cc | 11 ++++++++++- bochs/iodev/vga.cc | 49 +++++++++++++++++++++++++++++++++++++++------- bochs/iodev/vga.h | 9 ++++++++- 5 files changed, 72 insertions(+), 12 deletions(-) diff --git a/bochs/gui/gui.cc b/bochs/gui/gui.cc index f3307b4dd..39466627f 100644 --- a/bochs/gui/gui.cc +++ b/bochs/gui/gui.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: gui.cc,v 1.76 2004-02-07 14:34:34 vruppert Exp $ +// $Id: gui.cc,v 1.77 2004-02-22 13:02:54 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2002 MandrakeSoft S.A. @@ -600,7 +600,7 @@ bx_gui_c::beep_off() BX_INFO(( "GUI Beep OFF")); } -int + int bx_gui_c::register_statusitem(const char *text) { if (statusitem_count < BX_MAX_STATUSITEMS) { @@ -611,3 +611,11 @@ bx_gui_c::register_statusitem(const char *text) return -1; } } + + void +bx_gui_c::get_capabilities(Bit16u *xres, Bit16u *yres, Bit16u *bpp) +{ + *xres = 1024; + *yres = 768; + *bpp = 32; +} diff --git a/bochs/gui/gui.h b/bochs/gui/gui.h index d3f342b6c..e7c8f8397 100644 --- a/bochs/gui/gui.h +++ b/bochs/gui/gui.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: gui.h,v 1.42 2004-02-07 14:34:34 vruppert Exp $ +// $Id: gui.h,v 1.43 2004-02-22 13:02:56 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2002 MandrakeSoft S.A. @@ -88,6 +88,7 @@ public: #endif virtual void beep_on(float frequency); virtual void beep_off(); + virtual void get_capabilities(Bit16u *xres, Bit16u *yres, Bit16u *bpp); // The following function(s) are defined already, and your // GUI code calls them diff --git a/bochs/gui/x.cc b/bochs/gui/x.cc index 9975ed0c3..8dc7524d6 100644 --- a/bochs/gui/x.cc +++ b/bochs/gui/x.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: x.cc,v 1.79 2004-02-15 19:46:13 vruppert Exp $ +// $Id: x.cc,v 1.80 2004-02-22 13:02:56 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2002 MandrakeSoft S.A. @@ -64,6 +64,7 @@ public: virtual void beep_on(float frequency); virtual void beep_off(); virtual void statusbar_setitem(int element, bx_bool active); + virtual void get_capabilities(Bit16u *xres, Bit16u *yres, Bit16u *bpp); }; // declare one instance of the gui object and call macro to insert the @@ -1931,4 +1932,12 @@ bx_x_gui_c::beep_off() BX_INFO(( "X11 Beep OFF")); } + void +bx_x_gui_c::get_capabilities(Bit16u *xres, Bit16u *yres, Bit16u *bpp) +{ + *xres = 1024; + *yres = 768; + *bpp = imBPP; +} + #endif /* if BX_WITH_X11 */ diff --git a/bochs/iodev/vga.cc b/bochs/iodev/vga.cc index 65f775b13..8b9ecb191 100644 --- a/bochs/iodev/vga.cc +++ b/bochs/iodev/vga.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: vga.cc,v 1.95 2004-01-24 20:50:45 vruppert Exp $ +// $Id: vga.cc,v 1.96 2004-02-22 13:02:59 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2002 MandrakeSoft S.A. @@ -123,6 +123,9 @@ bx_vga_c::init(void) { unsigned i; unsigned x,y; +#if BX_SUPPORT_VBE + Bit16u max_xres, max_yres, max_bpp; +#endif unsigned addr; for (addr=0x03B4; addr<=0x03B5; addr++) { @@ -283,7 +286,24 @@ bx_vga_c::init(void) BX_VGA_THIS s.vbe_virtual_start=0; BX_VGA_THIS s.vbe_line_byte_width=640; BX_VGA_THIS s.vbe_lfb_enabled=0; - + BX_VGA_THIS s.vbe_get_capabilities=0; + bx_gui->get_capabilities(&max_xres, &max_yres, + &max_bpp); + if (max_xres > VBE_DISPI_MAX_XRES) { + BX_VGA_THIS s.vbe_max_xres=VBE_DISPI_MAX_XRES; + } else { + BX_VGA_THIS s.vbe_max_xres=max_xres; + } + if (max_yres > VBE_DISPI_MAX_YRES) { + BX_VGA_THIS s.vbe_max_yres=VBE_DISPI_MAX_YRES; + } else { + BX_VGA_THIS s.vbe_max_yres=max_yres; + } + if (max_bpp > VBE_DISPI_MAX_BPP) { + BX_VGA_THIS s.vbe_max_bpp=VBE_DISPI_MAX_BPP; + } else { + BX_VGA_THIS s.vbe_max_bpp=max_bpp; + } BX_INFO(("VBE Bochs Display Extension Enabled")); #endif @@ -2592,22 +2612,35 @@ bx_vga_c::vbe_read(Bit32u address, unsigned io_len) case VBE_DISPI_INDEX_XRES: // x resolution { - return BX_VGA_THIS s.vbe_xres; + if (BX_VGA_THIS s.vbe_get_capabilities) { + return BX_VGA_THIS s.vbe_max_xres; + } else { + return BX_VGA_THIS s.vbe_xres; + } } break; case VBE_DISPI_INDEX_YRES: // y resolution { - return BX_VGA_THIS s.vbe_yres; + if (BX_VGA_THIS s.vbe_get_capabilities) { + return BX_VGA_THIS s.vbe_max_yres; + } else { + return BX_VGA_THIS s.vbe_yres; + } } break; case VBE_DISPI_INDEX_BPP: // bpp { - return BX_VGA_THIS s.vbe_bpp; + if (BX_VGA_THIS s.vbe_get_capabilities) { + return BX_VGA_THIS s.vbe_max_bpp; + } else { + return BX_VGA_THIS s.vbe_bpp; + } } break; case VBE_DISPI_INDEX_ENABLE: // vbe enabled { - return BX_VGA_THIS s.vbe_enabled; + return BX_VGA_THIS s.vbe_enabled | + (BX_VGA_THIS s.vbe_get_capabilities << 1); } break; case VBE_DISPI_INDEX_BANK: // current bank @@ -2686,7 +2719,8 @@ bx_vga_c::vbe_write(Bit32u address, Bit32u value, unsigned io_len) { if ( (value == VBE_DISPI_ID0) || (value == VBE_DISPI_ID1) || - (value == VBE_DISPI_ID2) ) + (value == VBE_DISPI_ID2) || + (value == VBE_DISPI_ID3) ) { // allow backwards compatible with previous dispi bioses BX_VGA_THIS s.vbe_cur_dispi=value; @@ -2892,6 +2926,7 @@ bx_vga_c::vbe_write(Bit32u address, Bit32u value, unsigned io_len) BX_VGA_THIS s.vbe_lfb_enabled=0; } BX_VGA_THIS s.vbe_enabled=(bx_bool)(value & VBE_DISPI_ENABLED); + BX_VGA_THIS s.vbe_get_capabilities=(bx_bool)(value & VBE_DISPI_GETCAPS); } break; case VBE_DISPI_INDEX_X_OFFSET: diff --git a/bochs/iodev/vga.h b/bochs/iodev/vga.h index 77d20db30..570afb6b6 100644 --- a/bochs/iodev/vga.h +++ b/bochs/iodev/vga.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: vga.h,v 1.36 2003-12-31 10:33:27 vruppert Exp $ +// $Id: vga.h,v 1.37 2004-02-22 13:03:02 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2002 MandrakeSoft S.A. @@ -32,6 +32,7 @@ #define VBE_DISPI_MAX_XRES 1024 #define VBE_DISPI_MAX_YRES 768 + #define VBE_DISPI_MAX_BPP 32 #define VBE_DISPI_IOPORT_INDEX 0x01CE #define VBE_DISPI_IOPORT_DATA 0x01CF @@ -53,6 +54,7 @@ #define VBE_DISPI_ID0 0xB0C0 #define VBE_DISPI_ID1 0xB0C1 #define VBE_DISPI_ID2 0xB0C2 + #define VBE_DISPI_ID3 0xB0C3 #define VBE_DISPI_BPP_4 0x04 #define VBE_DISPI_BPP_8 0x08 @@ -63,6 +65,7 @@ #define VBE_DISPI_DISABLED 0x00 #define VBE_DISPI_ENABLED 0x01 + #define VBE_DISPI_GETCAPS 0x02 #define VBE_DISPI_NOCLEARMEM 0x80 #define VBE_DISPI_LFB_ENABLED 0x40 @@ -252,6 +255,9 @@ private: Bit16u vbe_xres; Bit16u vbe_yres; Bit16u vbe_bpp; + Bit16u vbe_max_xres; + Bit16u vbe_max_yres; + Bit16u vbe_max_bpp; Bit16u vbe_bank; bx_bool vbe_enabled; Bit16u vbe_curindex; @@ -264,6 +270,7 @@ private: Bit32u vbe_virtual_start; /**< For dealing with bpp>8, this is where the virtual screen starts. */ Bit8u vbe_bpp_multiplier; /**< We have to save this b/c sometimes we need to recalculate stuff with it. */ bx_bool vbe_lfb_enabled; + bx_bool vbe_get_capabilities; #endif } s; // state information