2004-06-05 02:06:55 +04:00
/////////////////////////////////////////////////////////////////////////
2011-02-25 01:05:47 +03:00
// $Id$
2004-06-05 02:06:55 +04:00
/////////////////////////////////////////////////////////////////////////
//
2023-03-13 02:36:22 +03:00
// Copyright (C) 2002-2023 The Bochs Project
2004-06-05 02:06:55 +04:00
//
// 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
2009-08-22 23:30:23 +04:00
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2004-06-05 02:06:55 +04:00
# include "bochs.h"
2011-08-16 23:58:56 +04:00
# include "bxversion.h"
2004-06-19 19:20:15 +04:00
# include "iodev/iodev.h"
2021-01-06 00:57:13 +03:00
# include "iodev/hdimage/hdimage.h"
2021-02-05 23:40:43 +03:00
# if BX_NETWORKING
# include "iodev/network/netmod.h"
# endif
2021-02-06 19:51:55 +03:00
# if BX_SUPPORT_SOUNDLOW
# include "iodev/sound/soundmod.h"
# endif
2021-02-14 11:30:49 +03:00
# if BX_SUPPORT_PCIUSB
# include "iodev/usb/usb_common.h"
# endif
2010-02-26 17:18:19 +03:00
# include "param_names.h"
2004-06-05 02:06:55 +04:00
# include <assert.h>
# ifdef HAVE_LOCALE_H
# include <locale.h>
# endif
# if defined(macintosh)
// Work around a bug in SDL 1.2.4 on MacOS X, which redefines getenv to
// SDL_getenv, but then neglects to provide SDL_getenv. It happens
// because we are defining -Dmacintosh.
# undef getenv
# endif
2023-04-16 12:22:45 +03:00
# ifdef WIN32
# define DIRECTORY_SEPARATOR "\\"
# else
# define DIRECTORY_SEPARATOR " / "
# endif
2004-06-05 02:06:55 +04:00
2021-03-27 20:23:31 +03:00
const char * * config_interface_list ;
2021-02-10 00:53:15 +03:00
const char * * display_library_list ;
2021-02-23 11:12:24 +03:00
const char * * vga_extension_names ;
const char * * vga_extension_plugins ;
2021-02-27 13:23:05 +03:00
const char * * pcislot_dev_list ;
2012-09-16 12:55:59 +04:00
int bochsrc_include_level = 0 ;
2004-06-05 02:06:55 +04:00
# define LOG_THIS genlog->
extern bx_debug_t bx_dbg ;
2008-03-30 18:32:14 +04:00
static int parse_line_unformatted ( const char * context , char * line ) ;
static int parse_line_formatted ( const char * context , int num_params , char * params [ ] ) ;
2006-03-13 21:55:53 +03:00
static int parse_bochsrc ( const char * rcfile ) ;
2021-03-29 14:17:03 +03:00
static int get_floppy_type_from_image ( const char * filename ) ;
int get_floppy_devtype_from_type ( int type )
{
switch ( type ) {
case BX_FLOPPY_2_88 :
return BX_FDD_350ED ;
case BX_FLOPPY_1_44 :
return BX_FDD_350HD ;
2023-11-21 10:35:07 +03:00
case BX_FLOPPY_720K :
return BX_FDD_350DD ;
case BX_FLOPPY_1_2 :
2021-03-29 14:17:03 +03:00
return BX_FDD_525HD ;
2023-11-21 10:35:07 +03:00
// the remaining types return a 5 1/4" 360k drive
case BX_FLOPPY_360K :
default :
return BX_FDD_525DD ;
2021-03-29 14:17:03 +03:00
}
}
2004-06-05 02:06:55 +04:00
2021-02-19 16:13:42 +03:00
static Bit64s bx_param_handler ( bx_param_c * param , bool set , Bit64s val )
2004-06-05 02:06:55 +04:00
{
2006-02-24 15:05:24 +03:00
char pname [ BX_PATHNAME_LEN ] ;
2023-12-03 14:34:03 +03:00
Bit8u device ;
2021-02-19 19:05:56 +03:00
Bit64s oldval ;
2006-02-26 22:11:20 +03:00
bx_list_c * base = ( bx_list_c * ) param - > get_parent ( ) ;
base - > get_param_path ( pname , BX_PATHNAME_LEN ) ;
if ( ! strncmp ( pname , " ata. " , 4 ) ) {
if ( ! strcmp ( base - > get_name ( ) , " master " ) ) {
device = 0 ;
} else {
device = 1 ;
}
2011-06-13 13:32:39 +04:00
if ( ! strcmp ( param - > get_name ( ) , " type " ) ) {
2004-06-05 02:06:55 +04:00
if ( set ) {
switch ( val ) {
case BX_ATA_DEVICE_DISK :
2009-03-16 00:16:17 +03:00
( ( bx_param_filename_c * ) SIM - > get_param ( " path " , base ) ) - > set_extension ( " img " ) ;
2004-06-05 02:06:55 +04:00
break ;
case BX_ATA_DEVICE_CDROM :
2009-03-16 00:16:17 +03:00
( ( bx_param_filename_c * ) SIM - > get_param ( " path " , base ) ) - > set_extension ( " iso " ) ;
2004-06-05 02:06:55 +04:00
break ;
2006-02-25 01:35:46 +03:00
}
2006-02-26 22:11:20 +03:00
}
2009-03-21 03:50:53 +03:00
} else {
BX_PANIC ( ( " bx_param_handler called with unknown parameter '%s.%s' " , pname , param - > get_name ( ) ) ) ;
return - 1 ;
2006-02-26 22:11:20 +03:00
}
} else {
param - > get_param_path ( pname , BX_PATHNAME_LEN ) ;
2021-02-19 19:05:56 +03:00
if ( ! strcmp ( pname , BXPN_VGA_EXTENSION ) ) {
if ( set ) {
oldval = ( ( bx_param_enum_c * ) param ) - > get ( ) ;
if ( val ! = oldval ) {
2023-12-03 14:34:03 +03:00
PLUG_unload_opt_plugin ( vga_extension_plugins [ ( Bit8u ) oldval ] ) ;
2021-04-01 22:36:59 +03:00
PLUG_load_plugin_var ( vga_extension_plugins [ ( Bit8u ) val ] , PLUGTYPE_VGA ) ;
2021-02-19 19:05:56 +03:00
}
}
2021-03-29 14:17:03 +03:00
} else if ( ( ! strcmp ( pname , BXPN_FLOPPYA_DEVTYPE ) ) | |
( ! strcmp ( pname , BXPN_FLOPPYB_DEVTYPE ) ) ) {
if ( ( set ) & & ( val = = BX_FDD_NONE ) ) {
SIM - > get_param_enum ( " type " , base ) - > set ( BX_FLOPPY_NONE ) ;
SIM - > get_param_enum ( " status " , base ) - > set ( BX_EJECTED ) ;
}
2021-02-19 19:05:56 +03:00
} else if ( ( ! strcmp ( pname , BXPN_FLOPPYA_TYPE ) ) | |
2009-03-23 22:05:16 +03:00
( ! strcmp ( pname , BXPN_FLOPPYB_TYPE ) ) ) {
2006-02-26 22:11:20 +03:00
if ( set ) {
if ( val = = BX_FLOPPY_AUTO ) {
2021-03-29 14:17:03 +03:00
val = get_floppy_type_from_image ( SIM - > get_param_string ( " path " , base ) - > getptr ( ) ) ;
2009-03-23 22:05:16 +03:00
SIM - > get_param_enum ( " type " , base ) - > set ( val ) ;
} else if ( ! SIM - > get_init_done ( ) & & ( val ! = BX_FLOPPY_NONE ) ) {
2021-07-12 22:05:25 +03:00
device = get_floppy_devtype_from_type ( ( int ) val ) ;
2009-03-23 22:05:16 +03:00
SIM - > get_param_enum ( " devtype " , base ) - > set ( device ) ;
2006-02-25 01:35:46 +03:00
}
2006-02-24 01:48:57 +03:00
}
2006-02-26 22:11:20 +03:00
} else {
BX_PANIC ( ( " bx_param_handler called with unknown parameter '%s' " , pname ) ) ;
return - 1 ;
}
2004-06-05 02:06:55 +04:00
}
return val ;
}
2021-02-19 16:13:42 +03:00
const char * bx_param_string_handler ( bx_param_string_c * param , bool set ,
2009-01-05 00:46:20 +03:00
const char * oldval , const char * val , int maxlen )
2004-06-05 02:06:55 +04:00
{
2006-02-24 15:05:24 +03:00
char pname [ BX_PATHNAME_LEN ] ;
2004-06-05 02:06:55 +04:00
2011-06-13 13:32:39 +04:00
param - > get_param_path ( pname , BX_PATHNAME_LEN ) ;
if ( ! strcmp ( pname , BXPN_SCREENMODE ) ) {
2021-02-19 16:13:42 +03:00
if ( set ) {
2011-06-13 13:32:39 +04:00
BX_INFO ( ( " Screen mode changed to %s " , val ) ) ;
2006-02-26 22:11:20 +03:00
}
2014-07-08 18:30:27 +04:00
} else if ( ! strcmp ( pname , BXPN_USER_SHORTCUT ) ) {
2021-02-19 16:13:42 +03:00
if ( set & & ( SIM - > get_init_done ( ) ) ) {
2020-10-19 18:01:40 +03:00
if ( ! bx_gui - > parse_user_shortcut ( val ) ) {
val = oldval ;
}
2014-07-08 18:30:27 +04:00
}
2011-06-13 13:32:39 +04:00
} else {
BX_PANIC ( ( " bx_param_string_handler called with unknown parameter '%s' " , pname ) ) ;
2004-06-05 02:06:55 +04:00
}
return val ;
}
2021-03-03 20:47:15 +03:00
# if BX_NETWORKING
2011-12-23 18:40:43 +04:00
void bx_init_std_nic_options ( const char * name , bx_list_c * menu )
{
bx_param_enum_c * ethmod ;
2018-01-19 23:27:04 +03:00
bx_param_bytestring_c * macaddr ;
2011-12-23 18:40:43 +04:00
bx_param_filename_c * path , * bootrom ;
char descr [ 120 ] ;
sprintf ( descr , " MAC address of the %s device. Don't use an address of a machine on your net. " , name ) ;
2018-01-19 23:27:04 +03:00
macaddr = new bx_param_bytestring_c ( menu ,
2013-01-19 16:25:53 +04:00
" mac " ,
2011-12-23 18:40:43 +04:00
" MAC Address " ,
descr ,
" " , 6 ) ;
macaddr - > set_initial_val ( " \xfe \xfd \xde \xad \xbe \xef " ) ;
macaddr - > set_separator ( ' : ' ) ;
ethmod = new bx_param_enum_c ( menu ,
" ethmod " ,
" Ethernet module " ,
" Module used for the connection to the real net. " ,
2021-02-05 23:40:43 +03:00
bx_netmod_ctl . get_module_names ( ) ,
2011-12-23 18:40:43 +04:00
0 ,
0 ) ;
ethmod - > set_by_name ( " null " ) ;
ethmod - > set_ask_format ( " Choose ethernet module for the device [%s] " ) ;
new bx_param_string_c ( menu ,
" ethdev " ,
" Ethernet device " ,
" Device used for the connection to the real net. This is only valid if an ethernet module other than 'null' is used. " ,
" xl0 " , BX_PATHNAME_LEN ) ;
path = new bx_param_filename_c ( menu ,
" script " ,
" Device configuration script " ,
" Name of the script that is executed after Bochs initializes the network interface (optional). " ,
" none " , BX_PATHNAME_LEN ) ;
path - > set_ask_format ( " Enter new script name, or 'none': [%s] " ) ;
bootrom = new bx_param_filename_c ( menu ,
" bootrom " ,
" Boot ROM image " ,
" Pathname of network boot ROM image to load " ,
" " , BX_PATHNAME_LEN ) ;
bootrom - > set_format ( " Name of boot ROM image: %s " ) ;
}
2021-03-03 20:47:15 +03:00
# endif
2011-12-23 18:40:43 +04:00
2021-03-03 20:47:15 +03:00
# if BX_SUPPORT_PCIUSB
2023-10-15 21:47:24 +03:00
void bx_init_usb_options ( const char * usb_name , const char * pname , int maxports , int param0 )
2012-01-08 16:43:46 +04:00
{
char group [ 16 ] , name [ 8 ] , descr [ 512 ] , label [ 512 ] ;
2021-03-07 14:54:50 +03:00
bx_list_c * usb , * usbrt , * deplist , * deplist2 ;
bx_list_c * ports = ( bx_list_c * ) SIM - > get_param ( " ports " ) ;
usb = ( bx_list_c * ) ports - > get_by_name ( " usb " ) ;
if ( usb = = NULL ) {
usb = new bx_list_c ( ports , " usb " , " USB Configuration " ) ;
usb - > set_options ( usb - > USE_TAB_WINDOW | usb - > SHOW_PARENT ) ;
// prepare runtime options
bx_list_c * rtmenu = ( bx_list_c * ) SIM - > get_param ( " menu.runtime " ) ;
usbrt = new bx_list_c ( rtmenu , " usb " , " USB options " ) ;
usbrt - > set_runtime_param ( 1 ) ;
usbrt - > set_options ( usbrt - > SHOW_PARENT | usbrt - > USE_TAB_WINDOW ) ;
}
2012-01-08 16:43:46 +04:00
sprintf ( group , " USB %s " , usb_name ) ;
sprintf ( label , " %s Configuration " , usb_name ) ;
bx_list_c * menu = new bx_list_c ( usb , pname , label ) ;
menu - > set_options ( menu - > SHOW_PARENT ) ;
sprintf ( label , " Enable %s emulation " , usb_name ) ;
sprintf ( descr , " Enables the %s emulation " , usb_name ) ;
2013-12-30 18:37:04 +04:00
bx_param_bool_c * enabled = new bx_param_bool_c ( menu , " enabled " , label , descr , 1 ) ;
2023-03-10 21:29:06 +03:00
2023-10-20 21:00:59 +03:00
// ehci companion type
static const char * ehci_comp_type [ ] = { " uhci " , " ohci " , NULL } ;
2023-10-23 09:55:42 +03:00
new bx_param_enum_c ( menu ,
2023-10-20 21:00:59 +03:00
" companion " , " Companion Type " ,
" Select Companion type to emulate " ,
ehci_comp_type ,
0 , 0
) ;
2023-03-10 21:29:06 +03:00
// xhci host controller type and number of ports
static const char * xhci_model_names [ ] = { " uPD720202 " , " uPD720201 " , NULL } ;
2023-10-18 08:19:33 +03:00
new bx_param_enum_c ( menu ,
2023-03-10 21:29:06 +03:00
" model " , " HC model " ,
" Select Host Controller to emulate " ,
xhci_model_names ,
0 , 0
) ;
2023-10-18 08:19:33 +03:00
new bx_param_num_c ( menu ,
2023-03-10 21:29:06 +03:00
" n_ports " , " Number of ports " ,
" Set the number of ports for this controller " ,
- 1 , 10 ,
- 1 , 0 // -1 as a default so that we can tell if this parameter was given
) ;
2021-02-15 22:55:53 +03:00
deplist = new bx_list_c ( NULL ) ;
2020-08-06 23:21:14 +03:00
for ( Bit8u i = 0 ; i < maxports ; i + + ) {
sprintf ( name , " port%u " , i + 1 ) ;
sprintf ( label , " Port #%u Configuration " , i + 1 ) ;
sprintf ( descr , " Device connected to %s port #%u and it's options " , usb_name , i + 1 ) ;
2012-01-08 16:43:46 +04:00
bx_list_c * port = new bx_list_c ( menu , name , label ) ;
port - > set_options ( port - > SERIES_ASK | port - > USE_BOX_TITLE ) ;
sprintf ( descr , " Device connected to %s port #%d " , usb_name , i + 1 ) ;
2021-02-15 19:09:02 +03:00
bx_param_enum_c * device = new bx_param_enum_c ( port ,
" device " ,
" Device " ,
descr ,
bx_usbdev_ctl . get_device_names ( ) ,
0 , 0 ) ;
2020-08-06 23:21:14 +03:00
sprintf ( descr , " Options for device connected to %s port #%u " , usb_name , i + 1 ) ;
2023-10-15 21:47:24 +03:00
# if BX_SUPPORT_USB_XHCI
if ( ! strcmp ( usb_name , " xHCI " ) ) {
if ( i < ( param0 / 2 ) )
strcpy ( label , " Options: (Must be super-speed) " ) ;
else
strcpy ( label , " Options: (Must NOT be super-speed) " ) ;
} else
# endif
2023-10-20 21:00:59 +03:00
strcpy ( label , " Options " ) ;
2021-02-15 19:09:02 +03:00
bx_param_string_c * options = new bx_param_string_c ( port ,
" options " ,
2023-10-15 21:47:24 +03:00
label ,
2021-02-15 19:09:02 +03:00
descr ,
" " , BX_PATHNAME_LEN ) ;
2023-03-23 02:12:08 +03:00
bx_param_bool_c * overcurrent = new bx_param_bool_c ( port ,
" over_current " ,
" signal over-current " ,
" signal over-current " , 0 ) ;
2012-01-08 16:43:46 +04:00
port - > set_group ( group ) ;
deplist - > add ( port ) ;
deplist - > add ( device ) ;
2023-03-23 02:12:08 +03:00
deplist - > add ( overcurrent ) ;
2021-02-15 22:55:53 +03:00
deplist2 = new bx_list_c ( NULL ) ;
deplist2 - > add ( options ) ;
device - > set_dependent_list ( deplist2 , 1 ) ;
device - > set_dependent_bitmap ( 0 , 0 ) ;
2012-01-08 16:43:46 +04:00
}
enabled - > set_dependent_list ( deplist ) ;
}
2021-03-03 20:47:15 +03:00
# endif
2012-01-08 16:43:46 +04:00
2021-01-21 21:10:40 +03:00
void bx_plugin_ctrl_init ( )
{
bx_list_c * base = ( bx_list_c * ) SIM - > get_param ( BXPN_PLUGIN_CTRL ) ;
const char * name ;
2021-02-10 00:53:15 +03:00
int count = PLUG_get_plugins_count ( PLUGTYPE_OPTIONAL ) ;
2023-11-12 02:09:42 +03:00
if ( count = = 0 ) {
BX_PANIC ( ( " bx_plugin_ctrl_init() failure: no plugins found " ) ) ;
}
2021-01-21 21:10:40 +03:00
for ( int i = 0 ; i < count ; i + + ) {
2021-02-10 00:53:15 +03:00
name = PLUG_get_plugin_name ( PLUGTYPE_OPTIONAL , i ) ;
2021-01-21 21:10:40 +03:00
new bx_param_bool_c ( base , name , " " , " " , 0 ) ;
}
}
2021-01-30 18:16:00 +03:00
void bx_plugin_ctrl_reset ( bool init_done )
2012-08-19 15:45:50 +04:00
{
bx_list_c * base = ( bx_list_c * ) SIM - > get_param ( BXPN_PLUGIN_CTRL ) ;
if ( init_done ) {
for ( int i = 0 ; i < base - > get_size ( ) ; i + + ) {
( ( bx_param_bool_c * ) base - > get ( i ) ) - > set ( 0 ) ;
}
SIM - > opt_plugin_ctrl ( " * " , 0 ) ;
}
2021-01-21 21:10:40 +03:00
// enable the default set of plugins to be loaded
SIM - > get_param_bool ( " unmapped " , base ) - > set ( 1 ) ;
SIM - > get_param_bool ( " biosdev " , base ) - > set ( 1 ) ;
SIM - > get_param_bool ( " speaker " , base ) - > set ( 1 ) ;
SIM - > get_param_bool ( " extfpuirq " , base ) - > set ( 1 ) ;
SIM - > get_param_bool ( " parallel " , base ) - > set ( 1 ) ;
SIM - > get_param_bool ( " serial " , base ) - > set ( 1 ) ;
2012-08-19 15:45:50 +04:00
# if BX_SUPPORT_GAMEPORT
2021-01-21 21:10:40 +03:00
SIM - > get_param_bool ( " gameport " , base ) - > set ( 1 ) ;
2012-08-19 15:45:50 +04:00
# endif
# if BX_SUPPORT_IODEBUG && BX_DEBUGGER
2021-01-21 21:10:40 +03:00
SIM - > get_param_bool ( " iodebug " , base ) - > set ( 1 ) ;
2012-08-19 15:45:50 +04:00
# endif
2020-01-24 19:01:00 +03:00
SIM - > opt_plugin_ctrl ( " * " , 1 ) ;
2012-08-19 15:45:50 +04:00
}
2021-01-27 23:06:02 +03:00
bool bx_opt_plugin_available ( const char * plugname )
2021-01-24 13:16:22 +03:00
{
return ( ( ( bx_list_c * ) SIM - > get_param ( BXPN_PLUGIN_CTRL ) ) - > get_by_name ( plugname ) ! = NULL ) ;
}
2021-03-27 20:23:31 +03:00
void bx_init_config_interface_list ( )
{
Bit8u i , count = 0 ;
count = PLUG_get_plugins_count ( PLUGTYPE_CI ) ;
config_interface_list = ( const char * * ) malloc ( ( count + 1 ) * sizeof ( char * ) ) ;
for ( i = 0 ; i < count ; i + + ) {
config_interface_list [ i ] = PLUG_get_plugin_name ( PLUGTYPE_CI , i ) ;
}
config_interface_list [ count ] = NULL ;
// move default config_intergface to the top of the list
if ( strcmp ( config_interface_list [ 0 ] , BX_DEFAULT_CONFIG_INTERFACE ) ) {
for ( i = 1 ; i < count ; i + + ) {
if ( ! strcmp ( config_interface_list [ i ] , BX_DEFAULT_CONFIG_INTERFACE ) ) {
config_interface_list [ i ] = config_interface_list [ 0 ] ;
config_interface_list [ 0 ] = BX_DEFAULT_CONFIG_INTERFACE ;
break ;
}
}
}
}
2021-02-10 00:53:15 +03:00
void bx_init_displaylib_list ( )
{
Bit8u i , count = 0 ;
count = PLUG_get_plugins_count ( PLUGTYPE_GUI ) ;
display_library_list = ( const char * * ) malloc ( ( count + 1 ) * sizeof ( char * ) ) ;
for ( i = 0 ; i < count ; i + + ) {
display_library_list [ i ] = PLUG_get_plugin_name ( PLUGTYPE_GUI , i ) ;
}
display_library_list [ count ] = NULL ;
// move default display library to the top of the list
if ( strcmp ( display_library_list [ 0 ] , BX_DEFAULT_DISPLAY_LIBRARY ) ) {
for ( i = 1 ; i < count ; i + + ) {
if ( ! strcmp ( display_library_list [ i ] , BX_DEFAULT_DISPLAY_LIBRARY ) ) {
display_library_list [ i ] = display_library_list [ 0 ] ;
display_library_list [ 0 ] = BX_DEFAULT_DISPLAY_LIBRARY ;
break ;
}
}
}
}
2021-02-19 19:05:56 +03:00
void bx_init_vgaext_list ( )
{
Bit8u i , count = 0 ;
2021-02-23 11:12:24 +03:00
const char * plugname ;
2021-02-19 19:05:56 +03:00
count = PLUG_get_plugins_count ( PLUGTYPE_VGA ) ;
2021-02-23 11:12:24 +03:00
vga_extension_names = ( const char * * ) malloc ( ( count + 2 ) * sizeof ( char * ) ) ;
vga_extension_plugins = ( const char * * ) malloc ( ( count + 1 ) * sizeof ( char * ) ) ;
vga_extension_names [ 0 ] = " none " ;
vga_extension_plugins [ 0 ] = " vga " ;
2021-02-19 19:05:56 +03:00
for ( i = 0 ; i < count ; i + + ) {
2021-02-23 11:12:24 +03:00
plugname = PLUG_get_plugin_name ( PLUGTYPE_VGA , i ) ;
vga_extension_plugins [ i + 1 ] = plugname ;
if ( ! strcmp ( plugname , " vga " ) ) {
vga_extension_names [ i + 1 ] = " vbe " ;
} else if ( ! strcmp ( plugname , " svga_cirrus " ) ) {
vga_extension_names [ i + 1 ] = plugname + 5 ;
} else {
vga_extension_names [ i + 1 ] = plugname ;
}
2021-02-19 19:05:56 +03:00
}
2021-04-18 20:20:41 +03:00
vga_extension_names [ count + 1 ] = NULL ;
2021-02-19 19:05:56 +03:00
}
2021-02-27 13:23:05 +03:00
void bx_init_pcidev_list ( )
{
Bit8u i , j , count , flags ;
const Bit16u mask = PLUGTYPE_VGA | PLUGTYPE_OPTIONAL ;
const char * plugname ;
count = PLUG_get_plugins_count ( mask ) ;
pcislot_dev_list = ( const char * * ) malloc ( ( count + 2 ) * sizeof ( char * ) ) ;
pcislot_dev_list [ 0 ] = " none " ;
j = 1 ;
for ( i = 0 ; i < count ; i + + ) {
plugname = PLUG_get_plugin_name ( mask , i ) ;
flags = PLUG_get_plugin_flags ( mask , i ) ;
if ( ( flags & PLUGFLAG_PCI ) ! = 0 ) {
if ( ! strcmp ( plugname , " vga " ) ) {
plugname = " pcivga " ;
} else if ( ! strcmp ( plugname , " svga_cirrus " ) ) {
plugname = " cirrus " ;
}
pcislot_dev_list [ j + + ] = plugname ;
}
}
pcislot_dev_list [ j ] = NULL ;
}
2006-02-19 18:43:03 +03:00
void bx_init_options ( )
2004-06-05 02:06:55 +04:00
{
int i ;
bx_list_c * menu ;
bx_list_c * deplist ;
2006-02-26 22:11:20 +03:00
bx_param_num_c * ioaddr , * ioaddr2 , * irq ;
2013-01-23 21:56:57 +04:00
bx_param_bool_c * enabled , * readonly ;
bx_param_enum_c * mode , * type , * toggle , * status ;
2011-12-23 18:40:43 +04:00
bx_param_filename_c * path ;
2012-01-08 16:43:46 +04:00
char name [ BX_PATHNAME_LEN ] , descr [ 512 ] , label [ 512 ] ;
2004-06-05 02:06:55 +04:00
2006-02-17 00:44:17 +03:00
bx_param_c * root_param = SIM - > get_param ( " . " ) ;
2006-03-05 13:24:29 +03:00
// general options subtree
2012-02-12 22:43:20 +04:00
menu = new bx_list_c ( root_param , " general " , " " ) ;
2006-03-05 13:24:29 +03:00
2006-10-08 14:18:51 +04:00
// config interface option, set in bochsrc or command line
2021-03-27 20:23:31 +03:00
bx_init_config_interface_list ( ) ;
2006-10-08 14:18:51 +04:00
bx_param_enum_c * sel_config = new bx_param_enum_c ( menu ,
" config_interface " , " Configuration interface " ,
" Select configuration interface " ,
config_interface_list ,
0 ,
0 ) ;
sel_config - > set_by_name ( BX_DEFAULT_CONFIG_INTERFACE ) ;
2010-02-26 01:04:31 +03:00
static const char * bochs_start_names [ ] = { " quick " , " load " , " edit " , " run " } ;
2004-06-05 02:06:55 +04:00
// quick start option, set by command line arg
2006-03-05 13:24:29 +03:00
new bx_param_enum_c ( menu ,
" start_mode " ,
2004-06-05 02:06:55 +04:00
" Bochs start types " ,
" Bochs start types " ,
bochs_start_names ,
BX_RUN_START ,
BX_QUICK_START ) ;
2006-04-07 00:42:51 +04:00
new bx_param_bool_c ( menu ,
" restore " ,
" Restore Bochs session " ,
" Restore Bochs session " ,
0 ) ;
new bx_param_string_c ( menu ,
" restore_path " ,
" Path to data for restore " ,
" Path to data for restore " ,
" " ,
BX_PATHNAME_LEN ) ;
2007-09-22 19:59:41 +04:00
// benchmarking mode, set by command line arg
new bx_param_num_c ( menu ,
" benchmark " ,
" benchmark mode " ,
" set benchmark mode " ,
0 , BX_MAX_BIT32U , 0 ) ;
2014-10-14 21:55:41 +04:00
// dump statistics, set by command line arg
2014-10-14 19:59:10 +04:00
new bx_param_num_c ( menu ,
" dumpstats " ,
" dumpstats mode " ,
" dump statistics period " ,
0 , BX_MAX_BIT32U , 0 ) ;
2018-05-11 10:44:49 +03:00
// unlock disk images
new bx_param_bool_c ( menu ,
" unlock_images " ,
" Unlock disk images " ,
" Unlock disk images leftover previous from Bochs session " ,
0 ) ;
2014-10-14 19:59:10 +04:00
2011-12-29 16:44:38 +04:00
// subtree for setting up log actions by device in bochsrc
2012-02-12 22:43:20 +04:00
bx_list_c * logfn = new bx_list_c ( menu , " logfn " , " Logfunctions " ) ;
new bx_list_c ( logfn , " debug " , " " ) ;
new bx_list_c ( logfn , " info " , " " ) ;
new bx_list_c ( logfn , " error " , " " ) ;
new bx_list_c ( logfn , " panic " , " " ) ;
2011-12-29 16:44:38 +04:00
2012-07-06 21:19:32 +04:00
// optional plugin control
2012-08-19 15:45:50 +04:00
new bx_list_c ( menu , " plugin_ctrl " , " Optional Plugin Control " ) ;
2021-01-21 21:10:40 +03:00
bx_plugin_ctrl_init ( ) ;
2011-12-25 12:52:34 +04:00
2006-03-05 13:24:29 +03:00
// subtree for special menus
bx_list_c * special_menus = new bx_list_c ( root_param , " menu " , " " ) ;
2006-02-18 19:53:18 +03:00
# if BX_SUPPORT_SMP
2009-02-20 18:38:36 +03:00
# define BX_CPU_PROCESSORS_LIMIT 255
# define BX_CPU_CORES_LIMIT 8
2006-02-18 19:53:18 +03:00
# define BX_CPU_HT_THREADS_LIMIT 4
# else
# define BX_CPU_PROCESSORS_LIMIT 1
# define BX_CPU_CORES_LIMIT 1
# define BX_CPU_HT_THREADS_LIMIT 1
# endif
// cpu subtree
2012-02-12 22:43:20 +04:00
bx_list_c * cpu_param = new bx_list_c ( root_param , " cpu " , " CPU Options " ) ;
2011-07-29 19:03:54 +04:00
2011-07-31 22:43:46 +04:00
static const char * cpu_names [ ] = {
# define bx_define_cpudb(model) #model,
# include "cpudb.h"
2011-07-29 19:03:54 +04:00
NULL
} ;
2011-07-31 22:43:46 +04:00
# undef bx_define_cpudb
2011-07-29 19:03:54 +04:00
new bx_param_enum_c ( cpu_param ,
" model " , " CPU configuration " ,
" Choose pre-defined CPU configuration " ,
2011-07-31 22:43:46 +04:00
cpu_names , 0 , 0 ) ;
2006-02-18 19:53:18 +03:00
// cpu options
bx_param_num_c * nprocessors = new bx_param_num_c ( cpu_param ,
2011-07-29 19:03:54 +04:00
" n_processors " , " Number of processors in SMP mode " ,
" Sets the number of processors for multiprocessor emulation " ,
2006-02-18 19:53:18 +03:00
1 , BX_CPU_PROCESSORS_LIMIT ,
1 ) ;
nprocessors - > set_enabled ( BX_CPU_PROCESSORS_LIMIT > 1 ) ;
2013-01-30 20:43:58 +04:00
nprocessors - > set_options ( bx_param_c : : CI_ONLY ) ;
2006-02-18 19:53:18 +03:00
bx_param_num_c * ncores = new bx_param_num_c ( cpu_param ,
2011-07-29 19:03:54 +04:00
" n_cores " , " Number of cores in each processor in SMP mode " ,
" Sets the number of cores per processor for multiprocessor emulation " ,
2006-02-18 19:53:18 +03:00
1 , BX_CPU_CORES_LIMIT ,
1 ) ;
ncores - > set_enabled ( BX_CPU_CORES_LIMIT > 1 ) ;
2013-01-30 20:43:58 +04:00
ncores - > set_options ( bx_param_c : : CI_ONLY ) ;
2006-02-18 19:53:18 +03:00
bx_param_num_c * nthreads = new bx_param_num_c ( cpu_param ,
2011-07-29 19:03:54 +04:00
" n_threads " , " Number of HT threads per each core in SMP mode " ,
2006-02-18 19:53:18 +03:00
" Sets the number of HT (Intel(R) HyperThreading Technology) threads per core for multiprocessor emulation " ,
1 , BX_CPU_HT_THREADS_LIMIT ,
1 ) ;
nthreads - > set_enabled ( BX_CPU_HT_THREADS_LIMIT > 1 ) ;
2013-01-30 20:43:58 +04:00
nthreads - > set_options ( bx_param_c : : CI_ONLY ) ;
2006-02-18 19:53:18 +03:00
new bx_param_num_c ( cpu_param ,
" ips " , " Emulated instructions per second (IPS) " ,
" Emulated instructions per second, used to calibrate bochs emulated time with wall clock time. " ,
2009-01-20 15:37:41 +03:00
BX_MIN_IPS , BX_MAX_BIT32U ,
4000000 ) ;
2006-06-22 00:42:26 +04:00
# if BX_SUPPORT_SMP
new bx_param_num_c ( cpu_param ,
" quantum " , " Quantum ticks in SMP simulation " ,
" Maximum amount of instructions allowed to execute before returning control to another CPU. " ,
BX_SMP_QUANTUM_MIN , BX_SMP_QUANTUM_MAX ,
2012-08-03 00:48:27 +04:00
16 ) ;
2006-06-22 00:42:26 +04:00
# endif
2006-02-18 19:53:18 +03:00
new bx_param_bool_c ( cpu_param ,
" reset_on_triple_fault " , " Enable CPU reset on triple fault " ,
2019-12-09 19:29:23 +03:00
" Enable CPU reset if triple fault occurred (highly recommended) " ,
2006-02-18 19:53:18 +03:00
1 ) ;
2009-11-13 18:55:46 +03:00
# if BX_CPU_LEVEL >= 5
new bx_param_bool_c ( cpu_param ,
2011-07-29 19:03:54 +04:00
" ignore_bad_msrs " , " Ignore RDMSR / WRMSR to unknown MSR register " ,
2009-11-13 18:55:46 +03:00
" Ignore RDMSR/WRMSR to unknown MSR register " ,
1 ) ;
# endif
2011-07-29 19:03:54 +04:00
new bx_param_bool_c ( cpu_param ,
" cpuid_limit_winnt " , " Limit max CPUID function to 3 " ,
" Limit max CPUID function reported to 3 to workaround WinNT issue " ,
0 ) ;
2012-03-15 23:46:57 +04:00
# if BX_SUPPORT_MONITOR_MWAIT
new bx_param_bool_c ( cpu_param ,
" mwait_is_nop " , " Don't put CPU to sleep state by MWAIT " ,
" Don't put CPU to sleep state by MWAIT " ,
0 ) ;
# endif
2008-12-28 23:30:48 +03:00
# if BX_CONFIGURE_MSRS
2011-01-22 19:49:00 +03:00
new bx_param_filename_c ( cpu_param ,
2008-12-28 23:30:48 +03:00
" msrs " ,
" Configurable MSR definition file " ,
" Set path to the configurable MSR definition file " ,
2008-12-28 23:49:03 +03:00
" " , BX_PATHNAME_LEN ) ;
2008-12-28 23:30:48 +03:00
# endif
2010-02-26 01:04:31 +03:00
cpu_param - > set_options ( menu - > SHOW_PARENT ) ;
// cpuid subtree
2011-02-25 18:05:48 +03:00
# if BX_CPU_LEVEL >= 4
2012-02-12 22:43:20 +04:00
bx_list_c * cpuid_param = new bx_list_c ( root_param , " cpuid " , " CPUID Options " ) ;
2010-02-26 01:04:31 +03:00
2013-04-17 23:46:11 +04:00
new bx_param_num_c ( cpuid_param ,
" level " , " CPU Level " ,
" CPU level " ,
2013-09-04 18:23:58 +04:00
( BX_CPU_LEVEL < 5 ) ? BX_CPU_LEVEL : 5 , BX_CPU_LEVEL ,
2013-04-17 23:46:11 +04:00
BX_CPU_LEVEL ) ;
new bx_param_num_c ( cpuid_param ,
" stepping " , " Stepping ID " ,
" Processor 4-bits stepping ID " ,
0 , 15 ,
3 ) ;
new bx_param_num_c ( cpuid_param ,
" model " , " Model ID " ,
" Processor model ID, extended model ID " ,
0 , 255 ,
3 ) ;
new bx_param_num_c ( cpuid_param ,
" family " , " Family ID " ,
" Processor family ID, extended family ID " ,
BX_CPU_LEVEL , ( BX_CPU_LEVEL > = 6 ) ? 4095 : BX_CPU_LEVEL ,
BX_CPU_LEVEL ) ;
2010-02-26 01:04:31 +03:00
new bx_param_string_c ( cpuid_param ,
2008-08-19 20:43:07 +04:00
" vendor_string " ,
" CPUID vendor string " ,
" Set the CPUID vendor string " ,
# if BX_CPU_VENDOR_INTEL
2022-08-23 21:38:00 +03:00
" GenuineIntel " ,
2008-08-19 20:43:07 +04:00
# else
2022-08-23 21:38:00 +03:00
" AuthenticAMD " ,
2008-08-19 20:43:07 +04:00
# endif
BX_CPUID_VENDOR_LEN + 1 ) ;
2010-02-26 01:04:31 +03:00
new bx_param_string_c ( cpuid_param ,
2008-08-19 20:43:07 +04:00
" brand_string " ,
" CPUID brand string " ,
" Set the CPUID brand string " ,
# if BX_CPU_VENDOR_INTEL
2022-08-23 21:38:00 +03:00
" Intel(R) Pentium(R) 4 CPU " ,
2008-08-19 20:43:07 +04:00
# else
" AMD Athlon(tm) processor " ,
# endif
BX_CPUID_BRAND_LEN + 1 ) ;
2010-03-01 21:53:53 +03:00
# if BX_CPU_LEVEL >= 5
new bx_param_bool_c ( cpuid_param ,
" mmx " , " Support for MMX instruction set " ,
" Support for MMX instruction set " ,
1 ) ;
2011-04-21 17:27:42 +04:00
// configure defaults to XAPIC enabled
2012-01-04 20:06:37 +04:00
static const char * apic_names [ ] = {
" legacy " ,
" xapic " ,
# if BX_CPU_LEVEL >= 6
" xapic_ext " ,
" x2apic " ,
# endif
NULL
} ;
2011-04-21 17:27:42 +04:00
new bx_param_enum_c ( cpuid_param ,
" apic " , " APIC configuration " ,
2012-01-04 20:06:37 +04:00
" Select APIC configuration (Legacy APIC/XAPIC/XAPIC_EXT/X2APIC) " ,
2011-04-21 17:27:42 +04:00
apic_names ,
BX_CPUID_SUPPORT_XAPIC ,
BX_CPUID_SUPPORT_LEGACY_APIC ) ;
2010-03-01 21:53:53 +03:00
# endif
2010-02-26 01:04:31 +03:00
# if BX_CPU_LEVEL >= 6
2010-02-28 17:52:17 +03:00
// configure defaults to CPU_LEVEL = 6 with SSE2 enabled
2013-09-16 23:50:36 +04:00
static const char * simd_names [ ] = {
" none " ,
" sse " ,
" sse2 " ,
" sse3 " ,
" ssse3 " ,
" sse4_1 " ,
" sse4_2 " ,
# if BX_SUPPORT_AVX
" avx " ,
" avx2 " ,
# if BX_SUPPORT_EVEX
" avx512 " ,
# endif
# endif
NULL } ;
2010-02-26 01:04:31 +03:00
new bx_param_enum_c ( cpuid_param ,
2013-09-16 23:50:36 +04:00
" simd " , " Support for SIMD instruction set " ,
" Support for SIMD (SSE/SSE2/SSE3/SSSE3/SSE4_1/SSE4_2/AVX/AVX2/AVX512) instruction set " ,
simd_names ,
2010-02-28 17:52:17 +03:00
BX_CPUID_SUPPORT_SSE2 ,
2010-02-26 01:04:31 +03:00
BX_CPUID_SUPPORT_NOSSE ) ;
2011-04-21 17:27:42 +04:00
2011-09-18 20:18:22 +04:00
new bx_param_bool_c ( cpuid_param ,
" sse4a " , " Support for AMD SSE4A instructions " ,
2012-01-04 20:06:37 +04:00
" Support for AMD SSE4A instructions " ,
2011-09-18 20:18:22 +04:00
0 ) ;
2012-12-20 23:43:11 +04:00
new bx_param_bool_c ( cpuid_param ,
" misaligned_sse " , " Support for AMD Misaligned SSE mode " ,
" Support for AMD Misaligned SSE mode " ,
0 ) ;
2011-09-18 20:18:22 +04:00
2010-02-28 17:52:17 +03:00
new bx_param_bool_c ( cpuid_param ,
" sep " , " Support for SYSENTER/SYSEXIT instructions " ,
" Support for SYSENTER/SYSEXIT instructions " ,
1 ) ;
2010-02-26 01:04:31 +03:00
new bx_param_bool_c ( cpuid_param ,
" movbe " , " Support for MOVBE instruction " ,
" Support for MOVBE instruction " ,
0 ) ;
2012-07-12 18:51:54 +04:00
new bx_param_bool_c ( cpuid_param ,
" adx " , " Support for ADX instructions " ,
" Support for ADCX/ADOX instructions " ,
0 ) ;
2010-02-26 01:04:31 +03:00
new bx_param_bool_c ( cpuid_param ,
" aes " , " Support for AES instruction set " ,
" Support for AES instruction set " ,
0 ) ;
2013-07-24 22:44:22 +04:00
new bx_param_bool_c ( cpuid_param ,
" sha " , " Support for SHA instruction set " ,
" Support for SHA instruction set " ,
0 ) ;
2010-02-27 01:53:43 +03:00
new bx_param_bool_c ( cpuid_param ,
" xsave " , " Support for XSAVE extensions " ,
" Support for XSAVE extensions " ,
0 ) ;
2011-03-25 23:32:07 +03:00
new bx_param_bool_c ( cpuid_param ,
" xsaveopt " , " Support for XSAVEOPT instruction " ,
" Support for XSAVEOPT instruction " ,
0 ) ;
2011-05-25 00:33:36 +04:00
# if BX_SUPPORT_AVX
2011-06-11 17:12:32 +04:00
new bx_param_bool_c ( cpuid_param ,
" avx_f16c " , " Support for AVX F16 convert instructions " ,
" Support for AVX F16 convert instructions " ,
0 ) ;
2011-09-30 02:20:56 +04:00
new bx_param_bool_c ( cpuid_param ,
" avx_fma " , " Support for AVX FMA instructions " ,
" Support for AVX FMA instructions " ,
0 ) ;
2011-08-27 17:47:16 +04:00
new bx_param_num_c ( cpuid_param ,
" bmi " , " Support for BMI instructions " ,
" Support for Bit Manipulation Instructions (BMI) " ,
0 , 2 ,
0 ) ;
2011-10-20 00:54:04 +04:00
new bx_param_bool_c ( cpuid_param ,
" xop " , " Support for AMD XOP instructions " ,
" Support for AMD XOP instructions " ,
0 ) ;
2011-10-07 18:09:35 +04:00
new bx_param_bool_c ( cpuid_param ,
" fma4 " , " Support for AMD four operand FMA instructions " ,
" Support for AMD FMA4 instructions " ,
0 ) ;
2011-10-20 00:54:04 +04:00
new bx_param_bool_c ( cpuid_param ,
" tbm " , " Support for AMD TBM instructions " ,
" Support for AMD Trailing Bit Manipulation (TBM) instructions " ,
0 ) ;
2011-05-25 00:33:36 +04:00
# endif
2010-04-24 13:36:04 +04:00
# if BX_SUPPORT_X86_64
2011-09-25 21:36:20 +04:00
new bx_param_bool_c ( cpuid_param ,
" x86_64 " , " x86-64 and long mode " ,
" Support for x86-64 and long mode " ,
1 ) ;
2010-04-24 13:36:04 +04:00
new bx_param_bool_c ( cpuid_param ,
" 1g_pages " , " 1G pages support in long mode " ,
" Support for 1G pages in long mode " ,
0 ) ;
2010-04-29 23:34:32 +04:00
new bx_param_bool_c ( cpuid_param ,
" pcid " , " PCID support in long mode " ,
" Support for process context ID (PCID) in long mode " ,
0 ) ;
2010-07-22 20:41:59 +04:00
new bx_param_bool_c ( cpuid_param ,
" fsgsbase " , " FS/GS BASE access instructions support " ,
" FS/GS BASE access instructions support in long mode " ,
0 ) ;
2010-04-24 13:36:04 +04:00
# endif
2011-05-29 20:28:26 +04:00
new bx_param_bool_c ( cpuid_param ,
" smep " , " Supervisor Mode Execution Protection support " ,
" Supervisor Mode Execution Protection support " ,
0 ) ;
2012-09-10 19:22:26 +04:00
new bx_param_bool_c ( cpuid_param ,
2013-04-17 23:46:11 +04:00
" smap " , " Supervisor Mode Access Prevention support " ,
" Supervisor Mode Access Prevention support " ,
2012-09-10 19:22:26 +04:00
0 ) ;
2010-03-12 14:28:59 +03:00
# if BX_SUPPORT_MONITOR_MWAIT
2010-11-21 15:02:12 +03:00
new bx_param_bool_c ( cpuid_param ,
" mwait " , " MONITOR/MWAIT instructions support " ,
2011-09-18 21:30:36 +04:00
" MONITOR/MWAIT instructions support " ,
2010-11-21 15:02:12 +03:00
BX_SUPPORT_MONITOR_MWAIT ) ;
2010-03-12 14:28:59 +03:00
# endif
2011-12-21 13:11:51 +04:00
# if BX_SUPPORT_VMX
new bx_param_num_c ( cpuid_param ,
" vmx " , " Support for Intel VMX extensions emulation " ,
" Support for Intel VMX extensions emulation " ,
0 , BX_SUPPORT_VMX ,
1 ) ;
# endif
2011-12-25 23:35:29 +04:00
# if BX_SUPPORT_SVM
new bx_param_bool_c ( cpuid_param ,
" svm " , " Secure Virtual Machine (SVM) emulation support " ,
" Secure Virtual Machine (SVM) emulation support " ,
0 ) ;
2010-02-26 01:04:31 +03:00
# endif
2011-12-25 23:35:29 +04:00
# endif // CPU_LEVEL >= 6
2010-02-26 01:04:31 +03:00
2013-03-17 21:16:45 +04:00
cpuid_param - > set_options ( menu - > SHOW_PARENT | menu - > USE_SCROLL_WINDOW ) ;
2006-02-18 19:53:18 +03:00
2012-02-18 14:50:14 +04:00
// CPUID subtree depends on CPU model
SIM - > get_param_enum ( BXPN_CPU_MODEL ) - > set_dependent_list ( cpuid_param - > clone ( ) , 0 ) ;
// enable CPUID subtree only for CPU model choice #0
SIM - > get_param_enum ( BXPN_CPU_MODEL ) - > set_dependent_bitmap ( 0 , BX_MAX_BIT64U ) ;
2011-02-25 19:27:01 +03:00
# endif // CPU_LEVEL >= 4
2006-02-17 00:44:17 +03:00
// memory subtree
2006-02-18 19:53:18 +03:00
bx_list_c * memory = new bx_list_c ( root_param , " memory " , " Memory Options " ) ;
bx_list_c * stdmem = new bx_list_c ( memory , " standard " , " Standard Options " ) ;
bx_list_c * optrom = new bx_list_c ( memory , " optrom " , " Optional ROM Images " ) ;
bx_list_c * optram = new bx_list_c ( memory , " optram " , " Optional RAM Images " ) ;
2011-02-12 20:50:48 +03:00
bx_list_c * ram = new bx_list_c ( stdmem , " ram " , " RAM size options " ) ;
bx_list_c * rom = new bx_list_c ( stdmem , " rom " , " BIOS ROM options " ) ;
bx_list_c * vgarom = new bx_list_c ( stdmem , " vgarom " , " VGABIOS ROM options " ) ;
2006-02-17 00:44:17 +03:00
2005-08-07 19:50:07 +04:00
// memory options (ram & rom)
2006-02-18 01:27:38 +03:00
bx_param_num_c * ramsize = new bx_param_num_c ( ram ,
2023-11-07 16:40:20 +03:00
" guest " ,
2006-02-18 19:53:18 +03:00
" Memory size (megabytes) " ,
2004-06-05 02:06:55 +04:00
" Amount of RAM in megabytes " ,
2009-10-17 21:52:26 +04:00
1 , ( ( Bit64u ) ( 1 ) < < BX_PHY_ADDRESS_WIDTH ) / ( 1024 * 1024 ) ,
2004-06-05 02:06:55 +04:00
BX_DEFAULT_MEM_MEGS ) ;
2006-02-18 01:27:38 +03:00
ramsize - > set_ask_format ( " Enter memory size (MB): [%d] " ) ;
2004-06-05 02:06:55 +04:00
2009-10-17 21:38:58 +04:00
bx_param_num_c * host_ramsize = new bx_param_num_c ( ram ,
2023-11-07 16:40:20 +03:00
" host " ,
2009-10-17 21:38:58 +04:00
" Host allocated memory size (megabytes) " ,
" Amount of host allocated memory in megabytes " ,
2009-10-17 21:52:26 +04:00
1 , 2048 ,
2009-10-17 21:38:58 +04:00
BX_DEFAULT_MEM_MEGS ) ;
2011-02-12 20:50:48 +03:00
host_ramsize - > set_ask_format ( " Enter host memory size (MB): [%d] " ) ;
ram - > set_options ( ram - > SERIES_ASK ) ;
2009-10-17 21:38:58 +04:00
2022-07-30 13:56:09 +03:00
bx_param_num_c * mem_block_size = new bx_param_num_c ( ram ,
" block_size " ,
" Memory block granularity (kilobytes) " ,
" Granularity of host memory allocation " ,
4 , 8192 ,
128 ) ;
mem_block_size - > set_ask_format ( " Enter memory block size (KB): [%d] " ) ;
ram - > set_options ( ram - > SERIES_ASK ) ;
2006-02-25 01:35:46 +03:00
path = new bx_param_filename_c ( rom ,
2017-02-14 00:14:34 +03:00
" file " ,
2006-02-18 19:53:18 +03:00
" ROM BIOS image " ,
2005-08-07 19:50:07 +04:00
" Pathname of ROM image to load " ,
" " , BX_PATHNAME_LEN ) ;
2006-02-25 01:35:46 +03:00
path - > set_format ( " Name of ROM BIOS image: %s " ) ;
2023-04-16 12:22:45 +03:00
sprintf ( name , " %s " DIRECTORY_SEPARATOR " BIOS-bochs-latest " , ( char * ) get_builtin_variable ( " BXSHARE " ) ) ;
2006-02-25 01:35:46 +03:00
path - > set_initial_val ( name ) ;
2006-02-18 01:27:38 +03:00
bx_param_num_c * romaddr = new bx_param_num_c ( rom ,
2017-02-14 00:14:34 +03:00
" address " ,
2006-02-18 19:53:18 +03:00
" ROM BIOS address " ,
2005-08-07 19:50:07 +04:00
" The address at which the ROM image should be loaded " ,
2008-02-06 01:57:43 +03:00
0 , BX_MAX_BIT32U ,
2005-12-27 19:59:27 +03:00
0 ) ;
2006-02-18 01:27:38 +03:00
romaddr - > set_base ( 16 ) ;
2017-02-14 00:14:34 +03:00
romaddr - > set_format ( " 0x%08x " ) ;
romaddr - > set_long_format ( " ROM BIOS address: 0x%08x " ) ;
2017-02-14 23:11:58 +03:00
new bx_param_string_c ( rom ,
" options " ,
" BIOS options " ,
" Options for the Bochs BIOS " ,
" " , BX_PATHNAME_LEN ) ;
2023-12-09 19:52:33 +03:00
new bx_param_filename_c ( rom ,
" flash_data " ,
" Flash BIOS config space image " ,
" Name of the image file for the config data of the flash BIOS " ,
" " , BX_PATHNAME_LEN ) ;
2011-02-12 20:50:48 +03:00
rom - > set_options ( rom - > SERIES_ASK ) ;
2005-08-07 19:50:07 +04:00
2006-02-25 01:35:46 +03:00
path = new bx_param_filename_c ( vgarom ,
2017-02-14 00:14:34 +03:00
" file " ,
2006-02-18 19:53:18 +03:00
" VGA BIOS image " ,
2005-08-07 19:50:07 +04:00
" Pathname of VGA ROM image to load " ,
" " , BX_PATHNAME_LEN ) ;
2006-02-25 01:35:46 +03:00
path - > set_format ( " Name of VGA BIOS image: %s " ) ;
2023-04-16 12:22:45 +03:00
sprintf ( name , " %s " DIRECTORY_SEPARATOR " VGABIOS-lgpl-latest " , get_builtin_variable ( " BXSHARE " ) ) ;
2006-02-25 01:35:46 +03:00
path - > set_initial_val ( name ) ;
2011-02-12 20:50:48 +03:00
vgarom - > set_options ( vgarom - > SERIES_ASK ) ;
2006-02-18 01:27:38 +03:00
2017-02-14 23:11:58 +03:00
bx_list_c * optnum ;
2006-02-18 01:27:38 +03:00
bx_param_num_c * optaddr ;
2005-08-07 19:50:07 +04:00
2005-10-28 10:33:53 +04:00
for ( i = 0 ; i < BX_N_OPTROM_IMAGES ; i + + ) {
2006-02-18 01:27:38 +03:00
sprintf ( name , " %d " , i + 1 ) ;
sprintf ( descr , " Pathname of optional ROM image #%d to load " , i + 1 ) ;
2006-02-18 19:53:18 +03:00
sprintf ( label , " Optional ROM image #%d " , i + 1 ) ;
2017-02-14 23:11:58 +03:00
optnum = new bx_list_c ( optrom , name , label ) ;
path = new bx_param_filename_c ( optnum ,
" file " ,
2006-02-19 18:43:03 +03:00
" Path " ,
2006-05-30 21:01:27 +04:00
descr ,
2005-08-07 19:50:07 +04:00
" " , BX_PATHNAME_LEN ) ;
2006-02-18 19:53:18 +03:00
sprintf ( label , " Name of optional ROM image #%d " , i + 1 ) ;
2005-08-07 19:50:07 +04:00
strcat ( label , " : %s " ) ;
2023-11-25 15:28:51 +03:00
path - > set_format ( label ) ;
2006-02-18 19:53:18 +03:00
sprintf ( descr , " The address at which the optional ROM image #%d should be loaded " , i + 1 ) ;
2017-02-14 23:11:58 +03:00
optaddr = new bx_param_num_c ( optnum ,
" address " ,
2006-02-18 19:53:18 +03:00
" Address " ,
2006-05-30 21:01:27 +04:00
descr ,
2008-02-06 01:57:43 +03:00
0 , BX_MAX_BIT32U ,
2005-08-07 19:50:07 +04:00
0 ) ;
2006-02-18 01:27:38 +03:00
optaddr - > set_base ( 16 ) ;
optaddr - > set_format ( " 0x%05x " ) ;
2006-02-18 19:53:18 +03:00
sprintf ( label , " Optional ROM #%d address: " , i + 1 ) ;
2005-08-07 19:50:07 +04:00
strcat ( label , " 0x%05x " ) ;
2023-11-25 15:28:51 +03:00
optaddr - > set_long_format ( label ) ;
2017-02-14 23:11:58 +03:00
deplist = new bx_list_c ( NULL ) ;
deplist - > add ( optaddr ) ;
path - > set_dependent_list ( deplist ) ;
optnum - > set_options ( optnum - > SERIES_ASK | optnum - > USE_BOX_TITLE ) ;
2005-08-07 19:50:07 +04:00
}
2009-03-16 00:16:17 +03:00
optrom - > set_options ( optrom - > SHOW_PARENT ) ;
2005-08-07 19:50:07 +04:00
2006-02-17 00:44:17 +03:00
for ( i = 0 ; i < BX_N_OPTRAM_IMAGES ; i + + ) {
2006-02-18 01:27:38 +03:00
sprintf ( name , " %d " , i + 1 ) ;
sprintf ( descr , " Pathname of optional RAM image #%d to load " , i + 1 ) ;
2006-02-18 19:53:18 +03:00
sprintf ( label , " Optional RAM image #%d " , i + 1 ) ;
2017-02-14 23:11:58 +03:00
optnum = new bx_list_c ( optram , name , label ) ;
path = new bx_param_filename_c ( optnum ,
" file " ,
2006-02-19 18:43:03 +03:00
" Path " ,
2006-05-30 21:01:27 +04:00
descr ,
2005-10-28 04:12:27 +04:00
" " , BX_PATHNAME_LEN ) ;
2006-02-18 01:27:38 +03:00
sprintf ( label , " Name of optional RAM image #%d " , i + 1 ) ;
2005-10-28 04:12:27 +04:00
strcat ( label , " : %s " ) ;
2023-11-25 15:28:51 +03:00
path - > set_format ( label ) ;
2006-02-18 19:53:18 +03:00
sprintf ( descr , " The address at which the optional RAM image #%d should be loaded " , i + 1 ) ;
2017-02-14 23:11:58 +03:00
optaddr = new bx_param_num_c ( optnum ,
2017-02-14 00:14:34 +03:00
" address " ,
2006-02-18 19:53:18 +03:00
" Address " ,
2006-05-30 21:01:27 +04:00
descr ,
2008-02-06 01:57:43 +03:00
0 , BX_MAX_BIT32U ,
2005-10-28 04:12:27 +04:00
0 ) ;
2006-02-18 01:27:38 +03:00
optaddr - > set_base ( 16 ) ;
optaddr - > set_format ( " 0x%05x " ) ;
sprintf ( label , " Optional RAM #%d address: " , i + 1 ) ;
2005-10-28 04:12:27 +04:00
strcat ( label , " 0x%05x " ) ;
2023-11-25 15:28:51 +03:00
optaddr - > set_long_format ( label ) ;
2017-02-14 23:11:58 +03:00
deplist = new bx_list_c ( NULL ) ;
deplist - > add ( optaddr ) ;
path - > set_dependent_list ( deplist ) ;
optnum - > set_options ( optnum - > SERIES_ASK | optnum - > USE_BOX_TITLE ) ;
2005-10-28 04:12:27 +04:00
}
2011-02-12 20:50:48 +03:00
optram - > set_options ( optram - > SHOW_PARENT ) ;
memory - > set_options ( memory - > SHOW_PARENT | memory - > USE_TAB_WINDOW ) ;
2006-02-19 18:43:03 +03:00
// clock & cmos subtree
bx_list_c * clock_cmos = new bx_list_c ( root_param , " clock_cmos " , " Clock & CMOS Options " ) ;
// clock & cmos options
2010-02-26 01:04:31 +03:00
static const char * clock_sync_names [ ] = { " none " , " realtime " , " slowdown " , " both " , NULL } ;
Porting #SF patch #565 Real Time Clock /CMOS fix (#4)
by Michele Giacomone
Detailed description:
-Observed issues
Due to some limitations only dates between 1980 and 2038 can be
used in a reliable way.
Also, bochs incorrectly assumes a linear correspondence between
the data returned by the <time.h> functions localtime() and
mktime(), and isn't setting the latter properly.
Bochs keeps its internal time value dependent to these functions
after setup, assuming that their internal settings won't change
on the go - which is not the case.
In my OS, and in my timezone, this leads to incorrect startup values
for 5 months each year and unreliable values if the simulation is
kept going for a long time. (a feedback between localtime() and
mktime() is created which keeps shifting back the time)
Also, the RTC simulation is not realistic since the clock fixes
itself across DST changes, without updating any DST related flag,
a behavior that no guest OS expects.
-Proposed fix
This is implemented in such way that no bochs' previous behavior
is changed, a part from the broken ones, with legacy in mind
== the user can keep using bochs exactly as before knowing nothing
of this patch
+Make the internal s.timeval variable a Bit64s, so it can fit all
values that the cmos can correctly represent, reported below:
MIN setting -62167219200 => 0000/01/01 SAT 0:00:00
MAX BCD setting 253402300799 => 9999/12/31 FRI 23:59:59
MAX BIN setting 745690751999 => 25599/12/31 FRI 23:59:59
And then fix each reference to these so it can handle such values
And make bochs correctly wrap around for under/overflows, so that
only the most significant bits of the century are lost.
+Do the same thing to the bochs time0 parameter, so all the above
values can be chosen at startup (despite being now legal values,
1 and 2 will still be treated as "local" and "utc"). Note that
normally only BCD settings are valid since bochs' CMOS defaults
to such operating mode - the only way to use the binary range
is by loading a cmos memory map.
+Make the internal s.timeval variable independent from external
factors. This means providing a small set of time handling
functions, contained in "iodev/utctime.h", which must work in
any environment in which bochs compiles, accessing no external
resource. This also means that after startup, s.timeval will only
be changed internally, and no call to the OS time functions will
be made.
+Make the internal s.timeval variable timezone independent, to
have a linear correlation between its values and valid CMOS
settings. To make it easier, s.timeval is gonna be treated as
if the current timezone was UTC: so,
- if the user selects UTC as time0, s.timeval will become current
time(NULL)
- if the user selects localtime, s.timeval will be computed as
the value which will display the same broken down time as
localtime(&now)
- if the user inputs a time formatted string the proper s.timeval
to displayed will be easily calculated,
- if the user inputs a starting time value, s.timeval will be
computed as the value which will display the same broken down
time as localtime(&user_input) to ensure the same operation as
before.
A "tz=utc" is displayed when bochs prints out the current time
value, to warn users about the difference in meaning between the
internally kept time value and the value they can set through
the "time0=" parameter. This might be changed to communicate
instead the time value they can input to get the same setting,
but performing such calculation (except for the startup time)
suffers from all the mktime()/localtime() problems listed above
so I did not do it.
The range of "time0" is automatically adjusted so all users in
all time zones can set any legal value despite "time0=" having a
local meaning.
A thorough explanation of what I did and why can be found in the
"iodev/utctime.h" library header.
---------
Co-authored-by: Stanislav Shwartsman <sshwarts@users.sourceforge.net>
Co-authored-by: Volker Ruppert <Volker.Ruppert@t-online.de>
2023-12-02 00:55:35 +03:00
Bit64s mintime , maxtime ;
struct tm mtim , xtim ;
mtim . tm_year = 0000 - 1900 ;
mtim . tm_mon = 1 - 1 ;
mtim . tm_mday = 1 ;
mtim . tm_hour = 00 ;
mtim . tm_min = 00 ;
mtim . tm_sec = 00 ;
mtim . tm_isdst = - 1 ;
xtim . tm_year = 9999 - 1900 ;
xtim . tm_mon = 12 - 1 ;
xtim . tm_mday = 31 ;
xtim . tm_hour = 23 ;
xtim . tm_min = 59 ;
xtim . tm_sec = 59 ;
xtim . tm_isdst = - 1 ;
mintime = mktime ( & mtim ) ; //Find which epoch corresponds to the upper limit expressed in local time
maxtime = mktime ( & xtim ) ; //Find which epoch corresponds to the lower limit expressed in local time
2010-02-26 01:04:31 +03:00
2006-02-19 18:43:03 +03:00
bx_param_enum_c * clock_sync = new bx_param_enum_c ( clock_cmos ,
" clock_sync " , " Synchronisation method " ,
" Host to guest time synchronization method " ,
clock_sync_names ,
BX_CLOCK_SYNC_NONE ,
BX_CLOCK_SYNC_NONE ) ;
bx_param_num_c * time0 = new bx_param_num_c ( clock_cmos ,
" time0 " ,
" Initial CMOS time for Bochs \n (1:localtime, 2:utc, other:time in seconds) " ,
" Initial time for Bochs CMOS clock, used if you really want two runs to be identical " ,
Porting #SF patch #565 Real Time Clock /CMOS fix (#4)
by Michele Giacomone
Detailed description:
-Observed issues
Due to some limitations only dates between 1980 and 2038 can be
used in a reliable way.
Also, bochs incorrectly assumes a linear correspondence between
the data returned by the <time.h> functions localtime() and
mktime(), and isn't setting the latter properly.
Bochs keeps its internal time value dependent to these functions
after setup, assuming that their internal settings won't change
on the go - which is not the case.
In my OS, and in my timezone, this leads to incorrect startup values
for 5 months each year and unreliable values if the simulation is
kept going for a long time. (a feedback between localtime() and
mktime() is created which keeps shifting back the time)
Also, the RTC simulation is not realistic since the clock fixes
itself across DST changes, without updating any DST related flag,
a behavior that no guest OS expects.
-Proposed fix
This is implemented in such way that no bochs' previous behavior
is changed, a part from the broken ones, with legacy in mind
== the user can keep using bochs exactly as before knowing nothing
of this patch
+Make the internal s.timeval variable a Bit64s, so it can fit all
values that the cmos can correctly represent, reported below:
MIN setting -62167219200 => 0000/01/01 SAT 0:00:00
MAX BCD setting 253402300799 => 9999/12/31 FRI 23:59:59
MAX BIN setting 745690751999 => 25599/12/31 FRI 23:59:59
And then fix each reference to these so it can handle such values
And make bochs correctly wrap around for under/overflows, so that
only the most significant bits of the century are lost.
+Do the same thing to the bochs time0 parameter, so all the above
values can be chosen at startup (despite being now legal values,
1 and 2 will still be treated as "local" and "utc"). Note that
normally only BCD settings are valid since bochs' CMOS defaults
to such operating mode - the only way to use the binary range
is by loading a cmos memory map.
+Make the internal s.timeval variable independent from external
factors. This means providing a small set of time handling
functions, contained in "iodev/utctime.h", which must work in
any environment in which bochs compiles, accessing no external
resource. This also means that after startup, s.timeval will only
be changed internally, and no call to the OS time functions will
be made.
+Make the internal s.timeval variable timezone independent, to
have a linear correlation between its values and valid CMOS
settings. To make it easier, s.timeval is gonna be treated as
if the current timezone was UTC: so,
- if the user selects UTC as time0, s.timeval will become current
time(NULL)
- if the user selects localtime, s.timeval will be computed as
the value which will display the same broken down time as
localtime(&now)
- if the user inputs a time formatted string the proper s.timeval
to displayed will be easily calculated,
- if the user inputs a starting time value, s.timeval will be
computed as the value which will display the same broken down
time as localtime(&user_input) to ensure the same operation as
before.
A "tz=utc" is displayed when bochs prints out the current time
value, to warn users about the difference in meaning between the
internally kept time value and the value they can set through
the "time0=" parameter. This might be changed to communicate
instead the time value they can input to get the same setting,
but performing such calculation (except for the startup time)
suffers from all the mktime()/localtime() problems listed above
so I did not do it.
The range of "time0" is automatically adjusted so all users in
all time zones can set any legal value despite "time0=" having a
local meaning.
A thorough explanation of what I did and why can be found in the
"iodev/utctime.h" library header.
---------
Co-authored-by: Stanislav Shwartsman <sshwarts@users.sourceforge.net>
Co-authored-by: Volker Ruppert <Volker.Ruppert@t-online.de>
2023-12-02 00:55:35 +03:00
mintime , maxtime ,
2006-02-19 18:43:03 +03:00
BX_CLOCK_TIME0_LOCAL ) ;
2012-05-15 21:03:45 +04:00
bx_param_bool_c * rtc_sync = new bx_param_bool_c ( clock_cmos ,
" rtc_sync " , " Sync RTC speed with realtime " ,
" If enabled, the RTC runs at realtime speed " ,
0 ) ;
deplist = new bx_list_c ( NULL ) ;
deplist - > add ( rtc_sync ) ;
clock_sync - > set_dependent_list ( deplist , 0 ) ;
clock_sync - > set_dependent_bitmap ( BX_CLOCK_SYNC_REALTIME , 1 ) ;
clock_sync - > set_dependent_bitmap ( BX_CLOCK_SYNC_BOTH , 1 ) ;
2006-02-19 18:43:03 +03:00
bx_list_c * cmosimage = new bx_list_c ( clock_cmos , " cmosimage " , " CMOS Image Options " ) ;
bx_param_bool_c * use_cmosimage = new bx_param_bool_c ( cmosimage ,
" enabled " , " Use a CMOS image " ,
" Controls the usage of a CMOS image " ,
0 ) ;
2006-02-25 01:35:46 +03:00
path = new bx_param_filename_c ( cmosimage ,
2006-02-19 18:43:03 +03:00
" path " , " Pathname of CMOS image " ,
" Pathname of CMOS image " ,
" " , BX_PATHNAME_LEN ) ;
bx_param_bool_c * rtc_init = new bx_param_bool_c ( cmosimage ,
" rtc_init " , " Initialize RTC from image " ,
" Controls whether to initialize the RTC with values stored in the image " ,
0 ) ;
2012-02-12 22:43:20 +04:00
deplist = new bx_list_c ( NULL ) ;
2006-02-25 01:35:46 +03:00
deplist - > add ( path ) ;
2006-02-19 18:43:03 +03:00
deplist - > add ( rtc_init ) ;
use_cmosimage - > set_dependent_list ( deplist ) ;
Porting #SF patch #565 Real Time Clock /CMOS fix (#4)
by Michele Giacomone
Detailed description:
-Observed issues
Due to some limitations only dates between 1980 and 2038 can be
used in a reliable way.
Also, bochs incorrectly assumes a linear correspondence between
the data returned by the <time.h> functions localtime() and
mktime(), and isn't setting the latter properly.
Bochs keeps its internal time value dependent to these functions
after setup, assuming that their internal settings won't change
on the go - which is not the case.
In my OS, and in my timezone, this leads to incorrect startup values
for 5 months each year and unreliable values if the simulation is
kept going for a long time. (a feedback between localtime() and
mktime() is created which keeps shifting back the time)
Also, the RTC simulation is not realistic since the clock fixes
itself across DST changes, without updating any DST related flag,
a behavior that no guest OS expects.
-Proposed fix
This is implemented in such way that no bochs' previous behavior
is changed, a part from the broken ones, with legacy in mind
== the user can keep using bochs exactly as before knowing nothing
of this patch
+Make the internal s.timeval variable a Bit64s, so it can fit all
values that the cmos can correctly represent, reported below:
MIN setting -62167219200 => 0000/01/01 SAT 0:00:00
MAX BCD setting 253402300799 => 9999/12/31 FRI 23:59:59
MAX BIN setting 745690751999 => 25599/12/31 FRI 23:59:59
And then fix each reference to these so it can handle such values
And make bochs correctly wrap around for under/overflows, so that
only the most significant bits of the century are lost.
+Do the same thing to the bochs time0 parameter, so all the above
values can be chosen at startup (despite being now legal values,
1 and 2 will still be treated as "local" and "utc"). Note that
normally only BCD settings are valid since bochs' CMOS defaults
to such operating mode - the only way to use the binary range
is by loading a cmos memory map.
+Make the internal s.timeval variable independent from external
factors. This means providing a small set of time handling
functions, contained in "iodev/utctime.h", which must work in
any environment in which bochs compiles, accessing no external
resource. This also means that after startup, s.timeval will only
be changed internally, and no call to the OS time functions will
be made.
+Make the internal s.timeval variable timezone independent, to
have a linear correlation between its values and valid CMOS
settings. To make it easier, s.timeval is gonna be treated as
if the current timezone was UTC: so,
- if the user selects UTC as time0, s.timeval will become current
time(NULL)
- if the user selects localtime, s.timeval will be computed as
the value which will display the same broken down time as
localtime(&now)
- if the user inputs a time formatted string the proper s.timeval
to displayed will be easily calculated,
- if the user inputs a starting time value, s.timeval will be
computed as the value which will display the same broken down
time as localtime(&user_input) to ensure the same operation as
before.
A "tz=utc" is displayed when bochs prints out the current time
value, to warn users about the difference in meaning between the
internally kept time value and the value they can set through
the "time0=" parameter. This might be changed to communicate
instead the time value they can input to get the same setting,
but performing such calculation (except for the startup time)
suffers from all the mktime()/localtime() problems listed above
so I did not do it.
The range of "time0" is automatically adjusted so all users in
all time zones can set any legal value despite "time0=" having a
local meaning.
A thorough explanation of what I did and why can be found in the
"iodev/utctime.h" library header.
---------
Co-authored-by: Stanislav Shwartsman <sshwarts@users.sourceforge.net>
Co-authored-by: Volker Ruppert <Volker.Ruppert@t-online.de>
2023-12-02 00:55:35 +03:00
time0 - > set_ask_format ( " Enter Initial CMOS time (1:localtime, 2:utc, other:time in seconds): [ " FMT_LL " d] " ) ;
2006-02-19 18:43:03 +03:00
clock_sync - > set_ask_format ( " Enter Synchronisation method: [%s] " ) ;
2009-03-16 00:16:17 +03:00
clock_cmos - > set_options ( clock_cmos - > SHOW_PARENT ) ;
2023-12-04 22:39:24 +03:00
cmosimage - > set_options ( cmosimage - > SERIES_ASK ) ;
2005-08-07 19:50:07 +04:00
2006-02-20 00:35:50 +03:00
// pci subtree
bx_list_c * pci = new bx_list_c ( root_param , " pci " , " PCI Options " ) ;
// pci options
2018-02-24 21:04:36 +03:00
static const char * pci_chipset_names [ ] = { " i430fx " , " i440fx " , " i440bx " , NULL } ;
2012-02-12 22:43:20 +04:00
deplist = new bx_list_c ( NULL ) ;
2006-02-20 00:35:50 +03:00
2012-11-11 12:11:17 +04:00
enabled = new bx_param_bool_c ( pci ,
" enabled " ,
" Enable PCI Support " ,
" Controls whether to emulate a PCI chipset " ,
2006-02-20 00:35:50 +03:00
BX_SUPPORT_PCI ) ;
2012-11-11 12:11:17 +04:00
bx_param_enum_c * pci_chipset = new bx_param_enum_c ( pci ,
" chipset " , " PCI chipset " ,
" Select PCI chipset to emulate " ,
pci_chipset_names ,
BX_PCI_CHIPSET_I440FX ,
BX_PCI_CHIPSET_I430FX ) ;
deplist - > add ( pci_chipset ) ;
2006-02-20 00:35:50 +03:00
// pci slots
2021-02-27 13:23:05 +03:00
bx_init_pcidev_list ( ) ;
2006-02-20 00:35:50 +03:00
bx_list_c * slot = new bx_list_c ( pci , " slot " , " PCI Slots " ) ;
2012-01-09 21:15:03 +04:00
deplist - > add ( slot ) ;
2006-02-20 00:35:50 +03:00
for ( i = 0 ; i < BX_N_PCI_SLOTS ; i + + ) {
sprintf ( name , " %d " , i + 1 ) ;
sprintf ( descr , " Name of the device connected to PCI slot #%d " , i + 1 ) ;
sprintf ( label , " PCI slot #%d device " , i + 1 ) ;
2021-02-27 13:23:05 +03:00
bx_param_enum_c * devname = new bx_param_enum_c ( slot ,
2008-02-06 01:57:43 +03:00
name ,
label ,
2006-05-30 21:01:27 +04:00
descr ,
2021-02-27 13:23:05 +03:00
pcislot_dev_list ,
0 , 0 ) ;
2012-01-09 21:15:03 +04:00
deplist - > add ( devname ) ;
}
2020-12-04 20:04:40 +03:00
bx_param_string_c * advopts = new bx_param_string_c ( pci , " advopts " , " Advanced PCI Options " ,
" Set advanced PCI options " ,
" " , BX_PATHNAME_LEN ) ;
deplist - > add ( advopts ) ;
2012-11-11 12:11:17 +04:00
enabled - > set_dependent_list ( deplist ) ;
2021-03-06 00:25:13 +03:00
enabled - > set_enabled ( BX_SUPPORT_PCI ) ;
2009-03-16 00:16:17 +03:00
pci - > set_options ( pci - > SHOW_PARENT ) ;
slot - > set_options ( slot - > SHOW_PARENT ) ;
2006-02-20 00:35:50 +03:00
2006-02-22 00:35:09 +03:00
// display subtree
2012-02-12 22:43:20 +04:00
bx_list_c * display = new bx_list_c ( root_param , " display " , " Bochs Display & Interface Options " ) ;
2006-02-22 00:35:09 +03:00
2021-02-10 00:53:15 +03:00
bx_init_displaylib_list ( ) ;
2006-02-22 00:35:09 +03:00
bx_param_enum_c * sel_displaylib = new bx_param_enum_c ( display ,
" display_library " , " VGA Display Library " ,
" Select VGA Display Library " ,
display_library_list ,
0 ,
0 ) ;
sel_displaylib - > set_by_name ( BX_DEFAULT_DISPLAY_LIBRARY ) ;
sel_displaylib - > set_ask_format ( " Choose which library to use for the Bochs display: [%s] " ) ;
new bx_param_string_c ( display ,
" displaylib_options " , " Display Library options " ,
" Options passed to Display Library " ,
" " ,
BX_PATHNAME_LEN ) ;
new bx_param_bool_c ( display ,
" private_colormap " , " Use a private colormap " ,
" Request that the GUI create and use it's own non-shared colormap. This colormap will be used when in the bochs window. If not enabled, a shared colormap scheme may be used. Not implemented on all GUI's. " ,
0 ) ;
2013-02-03 16:14:29 +04:00
# if BX_WITH_AMIGAOS
2006-02-22 00:35:09 +03:00
bx_param_bool_c * fullscreen = new bx_param_bool_c ( display ,
" fullscreen " , " Use full screen mode " ,
" When enabled, bochs occupies the whole screen instead of just a window. " ,
0 ) ;
bx_param_string_c * screenmode = new bx_param_string_c ( display ,
" screenmode " ,
" Screen mode name " ,
" Screen mode name " ,
" " , BX_PATHNAME_LEN ) ;
screenmode - > set_handler ( bx_param_string_handler ) ;
# endif
2014-11-15 13:22:27 +03:00
new bx_param_bool_c ( display ,
" vga_realtime " ,
" VGA timer realtime " ,
" If enabled, the VGA timer is based on realtime " ,
1 ) ;
2011-07-27 02:16:24 +04:00
bx_param_num_c * vga_update_freq = new bx_param_num_c ( display ,
" vga_update_frequency " ,
" VGA Update Frequency " ,
" Number of VGA updates per emulated second " ,
1 , 60 ,
5 ) ;
vga_update_freq - > set_ask_format ( " Type a new value for VGA update frequency: [%d] " ) ;
2006-02-22 00:35:09 +03:00
2021-02-19 19:05:56 +03:00
bx_init_vgaext_list ( ) ;
bx_param_enum_c * vga_extension = new bx_param_enum_c ( display ,
" vga_extension " ,
" VGA Extension " ,
" Name of the VGA extension " ,
2021-02-23 11:12:24 +03:00
vga_extension_names ,
0 , 0 ) ;
vga_extension - > set_by_name ( " vbe " ) ;
2021-02-19 19:05:56 +03:00
vga_extension - > set_handler ( bx_param_handler ) ;
2009-03-16 00:16:17 +03:00
display - > set_options ( display - > SHOW_PARENT ) ;
2006-02-22 00:35:09 +03:00
2020-03-21 21:00:02 +03:00
static const char * ddc_mode_list [ ] = {
2020-03-22 15:31:34 +03:00
" disabled " ,
2020-03-21 21:00:02 +03:00
" builtin " ,
" file " ,
NULL
} ;
bx_param_enum_c * ddc_mode = new bx_param_enum_c ( display ,
2020-03-22 15:31:34 +03:00
" ddc_mode " , " DDC emulation mode " ,
2020-03-21 21:00:02 +03:00
" Select DDC emulation mode " ,
ddc_mode_list ,
BX_DDC_MODE_BUILTIN ,
2020-03-22 15:31:34 +03:00
BX_DDC_MODE_DISABLED ) ;
2020-03-21 21:00:02 +03:00
path = new bx_param_filename_c ( display ,
" ddc_file " ,
" DDC definition file " ,
" Set path to a DDC definition file " ,
" " , BX_PATHNAME_LEN ) ;
deplist = new bx_list_c ( NULL ) ;
deplist - > add ( path ) ;
ddc_mode - > set_dependent_list ( deplist , 0 ) ;
ddc_mode - > set_dependent_bitmap ( BX_DDC_MODE_FILE , 1 ) ;
2006-02-22 22:18:29 +03:00
// keyboard & mouse subtree
bx_list_c * kbd_mouse = new bx_list_c ( root_param , " keyboard_mouse " , " Keyboard & Mouse Options " ) ;
bx_list_c * keyboard = new bx_list_c ( kbd_mouse , " keyboard " , " Keyboard Options " ) ;
bx_list_c * mouse = new bx_list_c ( kbd_mouse , " mouse " , " Mouse Options " ) ;
2010-09-13 00:47:23 +04:00
static const char * keyboard_type_names [ ] = { " xt " , " at " , " mf " , NULL } ;
2006-02-22 22:18:29 +03:00
// keyboard & mouse options
2006-03-01 20:14:36 +03:00
type = new bx_param_enum_c ( keyboard ,
2006-02-22 22:18:29 +03:00
" type " , " Keyboard type " ,
" Keyboard type reported by the 'identify keyboard' command " ,
keyboard_type_names ,
BX_KBD_MF_TYPE ,
BX_KBD_XT_TYPE ) ;
2006-03-01 20:14:36 +03:00
type - > set_ask_format ( " Enter keyboard type: [%s] " ) ;
2006-02-22 22:18:29 +03:00
new bx_param_num_c ( keyboard ,
" serial_delay " , " Keyboard serial delay " ,
2012-07-15 12:14:43 +04:00
" Approximate time in microseconds that it takes one character to be transferred from the keyboard to controller over the serial path. " ,
2013-01-27 23:09:24 +04:00
5 , BX_MAX_BIT32U ,
2006-02-22 22:18:29 +03:00
250 ) ;
new bx_param_num_c ( keyboard ,
" paste_delay " , " Keyboard paste delay " ,
2019-12-09 19:29:23 +03:00
" Approximate time in microseconds between attempts to paste characters to the keyboard controller. " ,
2006-02-22 22:18:29 +03:00
1000 , BX_MAX_BIT32U ,
100000 ) ;
bx_param_bool_c * use_kbd_mapping = new bx_param_bool_c ( keyboard ,
" use_mapping " , " Use keyboard mapping " ,
" Controls whether to use the keyboard mapping feature " ,
0 ) ;
2013-01-30 20:43:58 +04:00
use_kbd_mapping - > set_options ( bx_param_c : : CI_ONLY ) ;
2006-02-22 22:18:29 +03:00
bx_param_filename_c * keymap = new bx_param_filename_c ( keyboard ,
" keymap " , " Keymap filename " ,
" Pathname of the keymap file used " ,
" " , BX_PATHNAME_LEN ) ;
2009-03-16 00:16:17 +03:00
keymap - > set_extension ( " map " ) ;
2012-02-12 22:43:20 +04:00
deplist = new bx_list_c ( NULL ) ;
2006-02-22 22:18:29 +03:00
deplist - > add ( keymap ) ;
use_kbd_mapping - > set_dependent_list ( deplist ) ;
2014-07-08 18:30:27 +04:00
bx_param_string_c * user_shortcut = new bx_param_string_c ( keyboard ,
2006-02-22 22:18:29 +03:00
" user_shortcut " ,
" Userbutton shortcut " ,
" Defines the keyboard shortcut to be sent when you press the 'user' button in the headerbar. " ,
" none " , 20 ) ;
2014-07-08 18:30:27 +04:00
user_shortcut - > set_handler ( bx_param_string_handler ) ;
2006-02-22 22:18:29 +03:00
2007-10-25 03:29:40 +04:00
static const char * mouse_type_list [ ] = {
2006-02-22 22:18:29 +03:00
" none " ,
" ps2 " ,
" imps2 " ,
# if BX_SUPPORT_BUSMOUSE
2016-03-31 20:24:34 +03:00
" inport " ,
2006-02-22 22:18:29 +03:00
" bus " ,
# endif
" serial " ,
" serial_wheel " ,
2006-12-31 14:56:14 +03:00
" serial_msys " ,
2006-02-22 22:18:29 +03:00
NULL
} ;
2006-03-01 20:14:36 +03:00
type = new bx_param_enum_c ( mouse ,
2006-02-22 22:18:29 +03:00
" type " , " Mouse type " ,
" The mouse type can be one of these: 'none', 'ps2', 'imps2', 'serial', 'serial_wheel' "
# if BX_SUPPORT_BUSMOUSE
" , 'bus' "
# endif
,
mouse_type_list ,
BX_MOUSE_TYPE_PS2 ,
BX_MOUSE_TYPE_NONE ) ;
2006-03-01 20:14:36 +03:00
type - > set_ask_format ( " Choose the type of mouse [%s] " ) ;
2006-02-22 22:18:29 +03:00
2011-01-20 19:54:42 +03:00
new bx_param_bool_c ( mouse ,
2009-03-10 22:33:03 +03:00
" enabled " , " Enable mouse capture " ,
2006-02-22 22:18:29 +03:00
" Controls whether the mouse sends events to the guest. The hardware emulation is always enabled. " ,
0 ) ;
2009-01-13 22:01:19 +03:00
2010-05-16 13:01:36 +04:00
static const char * mouse_toggle_list [ ] = {
" ctrl+mbutton " ,
" ctrl+f10 " ,
" ctrl+alt " ,
2010-05-18 19:33:41 +04:00
" f12 " ,
2010-05-16 13:01:36 +04:00
NULL
} ;
toggle = new bx_param_enum_c ( mouse ,
" toggle " , " Mouse toggle method " ,
" The mouse toggle method can be one of these: 'ctrl+mbutton', 'ctrl+f10', 'ctrl+alt' " ,
mouse_toggle_list ,
BX_MOUSE_TOGGLE_CTRL_MB ,
BX_MOUSE_TOGGLE_CTRL_MB ) ;
toggle - > set_ask_format ( " Choose the mouse toggle method [%s] " ) ;
2009-03-16 00:16:17 +03:00
kbd_mouse - > set_options ( kbd_mouse - > SHOW_PARENT ) ;
keyboard - > set_options ( keyboard - > SHOW_PARENT ) ;
mouse - > set_options ( mouse - > SHOW_PARENT ) ;
2006-02-22 22:18:29 +03:00
2006-02-24 01:48:57 +03:00
// boot parameter subtree
bx_list_c * boot_params = new bx_list_c ( root_param , " boot_params " , " Boot Options " ) ;
// boot sequence
for ( i = 0 ; i < 3 ; i + + ) {
sprintf ( name , " boot_drive%d " , i + 1 ) ;
sprintf ( label , " Boot drive #%d " , i + 1 ) ;
sprintf ( descr , " Name of drive #%d in boot sequence (A, C or CD) " , i + 1 ) ;
bx_param_enum_c * bootdrive = new bx_param_enum_c ( boot_params ,
2006-05-30 02:33:38 +04:00
name ,
2006-05-30 21:01:27 +04:00
label ,
descr ,
2006-02-24 01:48:57 +03:00
& bochs_bootdisk_names [ ( i = = 0 ) ? BX_BOOT_FLOPPYA : BX_BOOT_NONE ] ,
( i = = 0 ) ? BX_BOOT_FLOPPYA : BX_BOOT_NONE ,
( i = = 0 ) ? BX_BOOT_FLOPPYA : BX_BOOT_NONE ) ;
bootdrive - > set_ask_format ( " Boot from floppy drive, hard drive or cdrom ? [%s] " ) ;
}
new bx_param_bool_c ( boot_params ,
" floppy_sig_check " ,
" Skip Floppy Boot Signature Check " ,
" Skips check for the 0xaa55 signature on floppy boot device. " ,
0 ) ;
2009-03-16 00:16:17 +03:00
boot_params - > set_options ( menu - > SHOW_PARENT ) ;
2006-02-25 01:35:46 +03:00
// floppy subtree
bx_list_c * floppy = new bx_list_c ( root_param , " floppy " , " Floppy Options " ) ;
2011-01-18 00:36:00 +03:00
new bx_list_c ( floppy , " 0 " , " First Floppy Drive " ) ;
new bx_list_c ( floppy , " 1 " , " Second Floppy Drive " ) ;
2006-02-25 01:35:46 +03:00
2006-03-01 20:14:36 +03:00
bx_param_enum_c * devtype ;
2006-02-25 01:35:46 +03:00
// floppy options
2011-01-18 00:36:00 +03:00
for ( i = 0 ; i < 2 ; i + + ) {
2006-02-25 01:35:46 +03:00
2011-01-18 00:36:00 +03:00
bx_list_c * floppyX = ( bx_list_c * ) floppy - > get ( i ) ;
2006-02-25 01:35:46 +03:00
2011-01-18 00:36:00 +03:00
devtype = new bx_param_enum_c ( floppyX ,
2009-03-23 22:05:16 +03:00
" devtype " ,
" Type of floppy drive " ,
" Type of floppy drive " ,
floppy_devtype_names ,
2021-03-28 11:40:28 +03:00
( i = = 0 ) ? BX_FDD_350HD : BX_FDD_NONE ,
2009-03-23 22:05:16 +03:00
BX_FDD_NONE ) ;
2011-01-18 00:36:00 +03:00
devtype - > set_ask_format ( " What type of floppy drive? [%s] " ) ;
2021-03-29 14:17:03 +03:00
devtype - > set_handler ( bx_param_handler ) ;
2006-02-25 01:35:46 +03:00
2011-01-18 00:36:00 +03:00
if ( i = = 0 ) {
strcpy ( label , " First floppy image/device " ) ;
strcpy ( descr , " Pathname of first floppy image file or device. If you're booting from floppy, this should be a bootable floppy. " ) ;
} else {
strcpy ( label , " Second floppy image/device " ) ;
strcpy ( descr , " Pathname of second floppy image file or device. " ) ;
}
path = new bx_param_filename_c ( floppyX , " path " , label , descr , " " , BX_PATHNAME_LEN ) ;
path - > set_ask_format ( " Enter new filename, or 'none' for no disk: [%s] " ) ;
path - > set_extension ( " img " ) ;
path - > set_initial_val ( " none " ) ;
type = new bx_param_enum_c ( floppyX ,
2006-02-25 01:35:46 +03:00
" type " ,
2009-03-23 22:05:16 +03:00
" Type of floppy media " ,
" Type of floppy media " ,
2006-02-25 01:35:46 +03:00
floppy_type_names ,
BX_FLOPPY_NONE ,
BX_FLOPPY_NONE ) ;
2011-01-18 00:36:00 +03:00
type - > set_ask_format ( " What type of floppy media? (auto=detect) [%s] " ) ;
type - > set_handler ( bx_param_handler ) ;
type - > set_runtime_param ( 1 ) ;
2006-02-25 01:35:46 +03:00
2011-01-18 00:36:00 +03:00
readonly = new bx_param_bool_c ( floppyX ,
2010-07-03 09:34:27 +04:00
" readonly " ,
" Write Protection " ,
" Floppy media write protection " ,
0 ) ;
2011-01-18 00:36:00 +03:00
readonly - > set_ask_format ( " Is media write protected? [%s] " ) ;
2010-07-03 09:34:27 +04:00
2013-01-23 21:56:57 +04:00
status = new bx_param_enum_c ( floppyX ,
2006-02-25 01:35:46 +03:00
" status " ,
2013-01-23 21:56:57 +04:00
" Status " ,
2009-03-25 21:33:43 +03:00
" Floppy media status (inserted / ejected) " ,
2013-01-23 21:56:57 +04:00
media_status_names ,
2013-06-09 14:27:43 +04:00
BX_EJECTED ,
2013-01-23 21:56:57 +04:00
BX_EJECTED ) ;
status - > set_ask_format ( " Is the device inserted or ejected? [%s] " ) ;
2006-02-25 01:35:46 +03:00
2012-02-12 22:43:20 +04:00
deplist = new bx_list_c ( NULL ) ;
2011-01-18 00:36:00 +03:00
deplist - > add ( path ) ;
devtype - > set_dependent_list ( deplist , 1 ) ;
devtype - > set_dependent_bitmap ( BX_FDD_NONE , 0 ) ;
2012-02-12 22:43:20 +04:00
deplist = new bx_list_c ( NULL ) ;
2011-01-18 00:36:00 +03:00
deplist - > add ( type ) ;
deplist - > add ( readonly ) ;
deplist - > add ( status ) ;
path - > set_dependent_list ( deplist ) ;
2009-03-29 15:13:49 +04:00
2011-01-18 00:36:00 +03:00
floppyX - > set_options ( floppyX - > SERIES_ASK | floppyX - > USE_BOX_TITLE ) ;
}
2009-03-29 15:13:49 +04:00
2009-03-16 00:16:17 +03:00
floppy - > set_options ( floppy - > SHOW_PARENT ) ;
2006-02-25 01:35:46 +03:00
2006-02-26 22:11:20 +03:00
// ATA/ATAPI subtree
2021-01-06 00:57:13 +03:00
bx_hdimage_ctl . init ( ) ; // initialize available disk image modes
2006-02-26 22:11:20 +03:00
bx_list_c * ata = new bx_list_c ( root_param , " ata " , " ATA/ATAPI Options " ) ;
2009-03-16 00:16:17 +03:00
ata - > set_options ( ata - > USE_TAB_WINDOW ) ;
2006-02-26 22:11:20 +03:00
// disk options
2007-10-25 03:29:40 +04:00
const char * s_atachannel [ ] = {
2006-02-26 22:11:20 +03:00
" ATA channel 0 " ,
" ATA channel 1 " ,
" ATA channel 2 " ,
" ATA channel 3 " ,
} ;
2007-10-25 03:29:40 +04:00
const char * s_atadevname [ 2 ] = {
2006-02-26 22:11:20 +03:00
" master " ,
" slave " ,
} ;
2007-10-25 03:29:40 +04:00
const char * s_atadevice [ 4 ] [ 2 ] = {
2006-02-26 22:11:20 +03:00
{ " First HD/CD on channel 0 " ,
" Second HD/CD on channel 0 " } ,
{ " First HD/CD on channel 1 " ,
" Second HD/CD on channel 1 " } ,
{ " First HD/CD on channel 2 " ,
" Second HD/CD on channel 2 " } ,
{ " First HD/CD on channel 3 " ,
" Second HD/CD on channel 3 " }
} ;
2006-02-27 12:37:58 +03:00
Bit16u ata_default_ioaddr1 [ 4 ] = {
2008-02-06 01:57:43 +03:00
0x1f0 , 0x170 , 0x1e8 , 0x168
2006-02-26 22:11:20 +03:00
} ;
2006-02-27 12:37:58 +03:00
Bit16u ata_default_ioaddr2 [ 4 ] = {
2008-02-06 01:57:43 +03:00
0x3f0 , 0x370 , 0x3e0 , 0x360
2006-02-26 22:11:20 +03:00
} ;
2008-02-06 01:57:43 +03:00
Bit8u ata_default_irq [ 4 ] = {
14 , 15 , 11 , 9
2006-02-26 22:11:20 +03:00
} ;
2006-03-08 21:10:41 +03:00
# define BXP_PARAMS_PER_ATA_DEVICE 12
2006-02-26 22:11:20 +03:00
bx_list_c * ata_menu [ BX_MAX_ATA_CHANNEL ] ;
bx_list_c * ata_res [ BX_MAX_ATA_CHANNEL ] ;
2011-10-01 00:38:18 +04:00
for ( Bit8u channel = 0 ; channel < BX_MAX_ATA_CHANNEL ; channel + + ) {
2006-02-26 22:11:20 +03:00
sprintf ( name , " %d " , channel ) ;
2006-05-30 02:33:38 +04:00
ata_menu [ channel ] = new bx_list_c ( ata , name , s_atachannel [ channel ] ) ;
2009-03-16 00:16:17 +03:00
ata_menu [ channel ] - > set_options ( bx_list_c : : USE_TAB_WINDOW ) ;
2012-02-12 22:43:20 +04:00
ata_res [ channel ] = new bx_list_c ( ata_menu [ channel ] , " resources " , s_atachannel [ channel ] ) ;
2009-03-16 00:16:17 +03:00
ata_res [ channel ] - > set_options ( bx_list_c : : SERIES_ASK ) ;
2006-02-26 22:11:20 +03:00
enabled = new bx_param_bool_c ( ata_res [ channel ] ,
2008-02-06 01:57:43 +03:00
" enabled " ,
2006-02-26 22:11:20 +03:00
" Enable ATA channel " ,
" Controls whether ata channel is installed or not " ,
0 ) ;
enabled - > set_ask_format ( " Channel is enabled: [%s] " ) ;
ioaddr = new bx_param_num_c ( ata_res [ channel ] ,
" ioaddr1 " ,
" I/O Address 1 " ,
2019-12-09 19:29:23 +03:00
" IO address of ata command block " ,
2006-02-26 22:11:20 +03:00
0 , 0xffff ,
ata_default_ioaddr1 [ channel ] ) ;
ioaddr - > set_base ( 16 ) ;
ioaddr - > set_ask_format ( " Enter new ioaddr1: [0x%x] " ) ;
ioaddr2 = new bx_param_num_c ( ata_res [ channel ] ,
" ioaddr2 " ,
" I/O Address 2 " ,
2019-12-09 19:29:23 +03:00
" IO address of ata control block " ,
2006-02-26 22:11:20 +03:00
0 , 0xffff ,
ata_default_ioaddr2 [ channel ] ) ;
ioaddr2 - > set_base ( 16 ) ;
ioaddr2 - > set_ask_format ( " Enter new ioaddr2: [0x%x] " ) ;
irq = new bx_param_num_c ( ata_res [ channel ] ,
" irq " ,
" IRQ " ,
" IRQ used by this ata channel " ,
0 , 15 ,
ata_default_irq [ channel ] ) ;
irq - > set_ask_format ( " Enter new IRQ: [%d] " ) ;
2009-03-16 00:16:17 +03:00
irq - > set_options ( irq - > USE_SPIN_CONTROL ) ;
2006-02-26 22:11:20 +03:00
// all items in the ata[channel] menu depend on the enabled flag.
// The menu list is complete, but a few dependent_list items will
// be added later. Use clone() to make a copy of the dependent_list
// so that it can be changed without affecting the menu.
enabled - > set_dependent_list ( ata_res [ channel ] - > clone ( ) ) ;
for ( Bit8u slave = 0 ; slave < 2 ; slave + + ) {
menu = new bx_list_c ( ata_menu [ channel ] ,
2006-05-30 02:33:38 +04:00
s_atadevname [ slave ] ,
2012-02-12 22:43:20 +04:00
s_atadevice [ channel ] [ slave ] ) ;
2009-03-16 00:16:17 +03:00
menu - > set_options ( menu - > SERIES_ASK ) ;
2006-02-26 22:11:20 +03:00
2013-01-22 22:26:49 +04:00
static const char * atadevice_type_names [ ] = { " none " , " disk " , " cdrom " , NULL } ;
2010-02-26 01:04:31 +03:00
2006-03-01 20:14:36 +03:00
type = new bx_param_enum_c ( menu ,
2006-02-26 22:11:20 +03:00
" type " ,
" Type of ATA device " ,
" Type of ATA device (disk or cdrom) " ,
atadevice_type_names ,
2013-01-22 22:26:49 +04:00
BX_ATA_DEVICE_NONE ,
BX_ATA_DEVICE_NONE ) ;
2006-02-26 22:11:20 +03:00
type - > set_ask_format ( " Enter type of ATA device, disk or cdrom: [%s] " ) ;
path = new bx_param_filename_c ( menu ,
" path " ,
" Path or physical device name " ,
" Pathname of the image or physical device (cdrom only) " ,
" " , BX_PATHNAME_LEN ) ;
path - > set_ask_format ( " Enter new filename: [%s] " ) ;
2009-03-16 00:16:17 +03:00
path - > set_extension ( " img " ) ;
2006-02-26 22:11:20 +03:00
2006-03-01 20:14:36 +03:00
mode = new bx_param_enum_c ( menu ,
2006-02-26 22:11:20 +03:00
" mode " ,
" Type of disk image " ,
" Mode of the ATA harddisk " ,
2021-01-06 00:57:13 +03:00
bx_hdimage_ctl . get_mode_names ( ) ,
0 , 0 ) ;
2006-02-26 22:11:20 +03:00
mode - > set_ask_format ( " Enter mode of ATA device, (flat, concat, etc.): [%s] " ) ;
2013-01-23 21:56:57 +04:00
status = new bx_param_enum_c ( menu ,
2006-02-26 22:11:20 +03:00
" status " ,
2013-01-22 22:26:49 +04:00
" Status " ,
2006-02-26 22:11:20 +03:00
" CD-ROM media status (inserted / ejected) " ,
2013-01-22 22:26:49 +04:00
media_status_names ,
2013-06-09 14:27:43 +04:00
BX_EJECTED ,
2013-01-22 22:26:49 +04:00
BX_EJECTED ) ;
2013-01-23 21:56:57 +04:00
status - > set_ask_format ( " Is the device inserted or ejected? [%s] " ) ;
2006-02-26 22:11:20 +03:00
bx_param_filename_c * journal = new bx_param_filename_c ( menu ,
" journal " ,
" Path of journal file " ,
" Pathname of the journal file " ,
" " , BX_PATHNAME_LEN ) ;
journal - > set_ask_format ( " Enter path of journal file: [%s] " ) ;
2012-02-12 22:43:20 +04:00
deplist = new bx_list_c ( NULL ) ;
2009-03-17 22:37:20 +03:00
deplist - > add ( journal ) ;
mode - > set_dependent_list ( deplist , 0 ) ;
2021-01-06 00:57:13 +03:00
mode - > set_dependent_bitmap ( bx_hdimage_ctl . get_mode_id ( " undoable " ) , 1 ) ;
mode - > set_dependent_bitmap ( bx_hdimage_ctl . get_mode_id ( " volatile " ) , 1 ) ;
mode - > set_dependent_bitmap ( bx_hdimage_ctl . get_mode_id ( " vvfat " ) , 1 ) ;
2006-02-26 22:11:20 +03:00
bx_param_num_c * cylinders = new bx_param_num_c ( menu ,
" cylinders " ,
" Cylinders " ,
" Number of cylinders " ,
0 , 262143 ,
0 ) ;
cylinders - > set_ask_format ( " Enter number of cylinders: [%d] " ) ;
bx_param_num_c * heads = new bx_param_num_c ( menu ,
" heads " ,
" Heads " ,
" Number of heads " ,
2012-02-04 20:39:59 +04:00
0 , 16 ,
2006-02-26 22:11:20 +03:00
0 ) ;
heads - > set_ask_format ( " Enter number of heads: [%d] " ) ;
bx_param_num_c * spt = new bx_param_num_c ( menu ,
" spt " ,
" Sectors per track " ,
" Number of sectors per track " ,
2012-02-04 20:39:59 +04:00
0 , 63 ,
2006-02-26 22:11:20 +03:00
0 ) ;
spt - > set_ask_format ( " Enter number of sectors per track: [%d] " ) ;
2018-03-13 23:35:56 +03:00
static const char * sector_size_names [ ] = { " 512 " , " 1024 " , " 4096 " , NULL } ;
bx_param_enum_c * sect_size = new bx_param_enum_c ( menu ,
" sect_size " ,
" Sector size " ,
" Size of a disk sector in bytes " ,
sector_size_names ,
BX_SECT_SIZE_512 ,
BX_SECT_SIZE_512 ) ;
sect_size - > set_ask_format ( " Enter sector size: [%s] " ) ;
2006-02-26 22:11:20 +03:00
bx_param_string_c * model = new bx_param_string_c ( menu ,
" model " ,
" Model name " ,
" String returned by the 'identify device' command " ,
2008-07-27 12:06:52 +04:00
" Generic 1234 " , 41 ) ;
2006-02-26 22:11:20 +03:00
model - > set_ask_format ( " Enter new model name: [%s] " ) ;
2017-02-17 00:43:52 +03:00
static const char * atadevice_biosdetect_names [ ] = { " auto " , " cmos " , " none " , NULL } ;
2010-02-26 01:04:31 +03:00
2006-02-26 22:11:20 +03:00
bx_param_enum_c * biosdetect = new bx_param_enum_c ( menu ,
" biosdetect " ,
" BIOS Detection " ,
" Type of bios detection " ,
atadevice_biosdetect_names ,
BX_ATA_BIOSDETECT_AUTO ,
2017-02-17 00:43:52 +03:00
BX_ATA_BIOSDETECT_AUTO ) ;
2006-02-26 22:11:20 +03:00
biosdetect - > set_ask_format ( " Enter bios detection type: [%s] " ) ;
2010-02-26 01:04:31 +03:00
static const char * atadevice_translation_names [ ] = { " none " , " lba " , " large " , " rechs " , " auto " , NULL } ;
2006-02-26 22:11:20 +03:00
bx_param_enum_c * translation = new bx_param_enum_c ( menu ,
" translation " ,
" Translation type " ,
" How the ata-disk translation is done by the bios " ,
atadevice_translation_names ,
BX_ATA_TRANSLATION_AUTO ,
BX_ATA_TRANSLATION_NONE ) ;
translation - > set_ask_format ( " Enter translation type: [%s] " ) ;
// the master/slave menu depends on the ATA channel's enabled flag
enabled - > get_dependent_list ( ) - > add ( menu ) ;
2013-01-22 22:26:49 +04:00
// the type selector depends on the ATA channel's enabled flag
enabled - > get_dependent_list ( ) - > add ( type ) ;
// all items depend on the drive type
type - > set_dependent_list ( menu - > clone ( ) , 0 ) ;
2018-03-13 23:35:56 +03:00
type - > set_dependent_bitmap ( BX_ATA_DEVICE_DISK , 0xfe6 ) ;
type - > set_dependent_bitmap ( BX_ATA_DEVICE_CDROM , 0x60a ) ;
2009-03-17 00:07:44 +03:00
2006-02-26 22:11:20 +03:00
type - > set_handler ( bx_param_handler ) ;
}
// Enable two ATA interfaces by default, disable the others.
// Now that the dependence relationships are established, call set() on
// the ata device present params to set all enables correctly.
2006-02-27 01:36:01 +03:00
enabled - > set_initial_val ( channel < 2 ) ;
enabled - > set ( channel < 2 ) ;
2006-02-26 22:11:20 +03:00
}
2006-02-25 01:35:46 +03:00
// disk menu
bx_param_c * disk_menu_init_list [ ] = {
SIM - > get_param ( BXPN_FLOPPYA ) ,
SIM - > get_param ( BXPN_FLOPPYB ) ,
2006-02-26 22:11:20 +03:00
SIM - > get_param ( BXPN_ATA0_RES ) ,
SIM - > get_param ( BXPN_ATA0_MASTER ) ,
SIM - > get_param ( BXPN_ATA0_SLAVE ) ,
2006-02-25 01:35:46 +03:00
# if BX_MAX_ATA_CHANNEL>1
2006-02-26 22:11:20 +03:00
SIM - > get_param ( BXPN_ATA1_RES ) ,
SIM - > get_param ( BXPN_ATA1_MASTER ) ,
SIM - > get_param ( BXPN_ATA1_SLAVE ) ,
2006-02-25 01:35:46 +03:00
# endif
# if BX_MAX_ATA_CHANNEL>2
2006-02-26 22:11:20 +03:00
SIM - > get_param ( BXPN_ATA2_RES ) ,
SIM - > get_param ( BXPN_ATA2_MASTER ) ,
SIM - > get_param ( BXPN_ATA2_SLAVE ) ,
2006-02-25 01:35:46 +03:00
# endif
# if BX_MAX_ATA_CHANNEL>3
2006-02-26 22:11:20 +03:00
SIM - > get_param ( BXPN_ATA3_RES ) ,
SIM - > get_param ( BXPN_ATA3_MASTER ) ,
SIM - > get_param ( BXPN_ATA3_SLAVE ) ,
2006-02-25 01:35:46 +03:00
# endif
SIM - > get_param ( " boot_params " ) ,
NULL
} ;
2006-03-05 13:24:29 +03:00
menu = new bx_list_c ( special_menus , " disk " , " Bochs Disk Options " , disk_menu_init_list ) ;
2009-03-16 00:16:17 +03:00
menu - > set_options ( menu - > SHOW_PARENT ) ;
2013-02-03 16:14:29 +04:00
# ifdef WIN32
2009-03-16 00:16:17 +03:00
// disk menu for win32paramdlg
bx_param_c * disk_menu2_init_list [ ] = {
SIM - > get_param ( " floppy " ) ,
SIM - > get_param ( " ata.0 " ) ,
# if BX_MAX_ATA_CHANNEL>1
SIM - > get_param ( " ata.1 " ) ,
# endif
# if BX_MAX_ATA_CHANNEL>2
SIM - > get_param ( " ata.2 " ) ,
# endif
# if BX_MAX_ATA_CHANNEL>3
SIM - > get_param ( " ata.3 " ) ,
# endif
SIM - > get_param ( " boot_params " ) ,
NULL
} ;
menu = new bx_list_c ( special_menus , " disk_win32 " , " Bochs Disk Options " , disk_menu2_init_list ) ;
menu - > set_options ( menu - > USE_TAB_WINDOW ) ;
2013-02-03 16:14:29 +04:00
# endif
2006-02-24 01:48:57 +03:00
2006-03-01 20:14:36 +03:00
// ports subtree
2021-03-07 14:54:50 +03:00
bx_list_c * ports = new bx_list_c ( root_param , " ports " , " Serial / Parallel / USB Options " ) ;
2009-03-16 00:16:17 +03:00
ports - > set_options ( ports - > USE_TAB_WINDOW | ports - > SHOW_PARENT ) ;
2021-02-14 11:30:49 +03:00
# if BX_SUPPORT_PCIUSB
bx_usbdev_ctl . init ( ) ;
# endif
2021-03-07 14:54:50 +03:00
// parallel / serial / USB options initialized in the device plugin code
2004-06-05 02:06:55 +04:00
2021-02-05 23:40:43 +03:00
# if BX_NETWORKING
2006-03-02 23:13:14 +03:00
// network subtree
bx_list_c * network = new bx_list_c ( root_param , " network " , " Network Configuration " ) ;
2009-03-16 00:16:17 +03:00
network - > set_options ( network - > USE_TAB_WINDOW | network - > SHOW_PARENT ) ;
2021-02-05 23:40:43 +03:00
bx_netmod_ctl . init ( ) ;
2021-03-07 14:54:50 +03:00
// network device options initialized in the device plugin code
2021-02-05 23:40:43 +03:00
# endif
2004-06-05 02:06:55 +04:00
2006-03-03 23:29:50 +03:00
// sound subtree
bx_list_c * sound = new bx_list_c ( root_param , " sound " , " Sound Configuration " ) ;
2011-03-12 20:37:26 +03:00
sound - > set_options ( sound - > USE_TAB_WINDOW | sound - > SHOW_PARENT ) ;
2021-03-05 19:52:26 +03:00
# if BX_SUPPORT_SOUNDLOW
2013-06-24 23:19:12 +04:00
bx_list_c * soundlow = new bx_list_c ( sound , " lowlevel " , " Lowlevel Sound Configuration " ) ;
soundlow - > set_options ( soundlow - > SHOW_PARENT | soundlow - > SERIES_ASK ) ;
soundlow - > set_enabled ( BX_SUPPORT_SOUNDLOW ) ;
2021-02-06 19:51:55 +03:00
bx_soundmod_ctl . init ( ) ;
2015-02-22 23:29:58 +03:00
bx_param_enum_c * driver = new bx_param_enum_c ( soundlow ,
2015-03-07 01:54:30 +03:00
" waveoutdrv " ,
" Waveout driver " ,
" This is the waveout driver to use for emulated sound devices " ,
2021-02-06 19:51:55 +03:00
bx_soundmod_ctl . get_driver_names ( ) ,
0 , 0 ) ;
2015-02-22 23:29:58 +03:00
driver - > set_by_name ( BX_SOUND_LOWLEVEL_NAME ) ;
2013-06-24 23:19:12 +04:00
new bx_param_filename_c ( soundlow ,
2013-06-30 12:21:26 +04:00
" waveout " ,
2013-06-24 23:19:12 +04:00
" Wave output device " ,
" This is the device where the wave output is sent to " ,
" " , BX_PATHNAME_LEN ) ;
2015-03-07 01:54:30 +03:00
driver = new bx_param_enum_c ( soundlow ,
" waveindrv " ,
" Wavein driver " ,
" This is the wavein driver to use for emulated sound devices " ,
2021-02-06 19:51:55 +03:00
bx_soundmod_ctl . get_driver_names ( ) ,
0 , 0 ) ;
2015-03-07 01:54:30 +03:00
driver - > set_by_name ( BX_SOUND_LOWLEVEL_NAME ) ;
2013-07-06 19:12:04 +04:00
new bx_param_filename_c ( soundlow ,
" wavein " ,
" Wave input device " ,
" This is the device to be used as the wave input source " ,
" " , BX_PATHNAME_LEN ) ;
2015-03-07 01:54:30 +03:00
driver = new bx_param_enum_c ( soundlow ,
" midioutdrv " ,
" Midiout driver " ,
" This is the midiout driver to use for emulated sound devices " ,
2021-02-06 19:51:55 +03:00
bx_soundmod_ctl . get_driver_names ( ) ,
0 , 0 ) ;
2015-03-07 01:54:30 +03:00
driver - > set_by_name ( BX_SOUND_LOWLEVEL_NAME ) ;
2015-02-17 11:33:07 +03:00
new bx_param_filename_c ( soundlow ,
" midiout " ,
" MIDI output device " ,
" This is the device where the MIDI output is sent to " ,
" " , BX_PATHNAME_LEN ) ;
2013-06-24 23:19:12 +04:00
# endif
2021-03-07 14:54:50 +03:00
// sound device options initialized in the device plugin code
2004-06-05 02:06:55 +04:00
2006-03-04 15:43:47 +03:00
// misc options subtree
bx_list_c * misc = new bx_list_c ( root_param , " misc " , " Configure Everything Else " ) ;
2009-03-16 00:16:17 +03:00
misc - > set_options ( misc - > SHOW_PARENT ) ;
2006-03-04 15:43:47 +03:00
2009-04-26 10:56:28 +04:00
// port e9 hack
2023-10-18 08:19:33 +03:00
bx_list_c * port_e9_hack = new bx_list_c ( misc , " port_e9_hack " , " port 0xE9 hack " ) ;
new bx_param_bool_c ( port_e9_hack ,
" enabled " ,
2009-04-26 10:56:28 +04:00
" Enable port 0xE9 hack " ,
" Debug messages written to i/o port 0xE9 will be displayed on console " ,
0 ) ;
2023-08-26 18:37:55 +03:00
// port e9 hack all rings
2023-10-18 08:19:33 +03:00
new bx_param_bool_c ( port_e9_hack ,
" all_rings " ,
2023-08-26 18:37:55 +03:00
" Enable port 0xE9 hack for all rings " ,
" Debug messages written to i/o port 0xE9 from ring3 will be displayed on console " ,
0 ) ;
2023-08-27 19:34:01 +03:00
# if BX_SUPPORT_IODEBUG
// iodebug all rings
new bx_param_bool_c ( misc ,
" iodebug_all_rings " ,
" Enable iodebug ports for all rings " ,
" I/O Interface to Bochs Debugger plugin for all rings " ,
0 ) ;
# endif
2004-06-05 02:06:55 +04:00
// GDB stub
2006-03-04 15:43:47 +03:00
menu = new bx_list_c ( misc , " gdbstub " , " GDB Stub Options " ) ;
2009-03-16 00:16:17 +03:00
menu - > set_options ( menu - > SHOW_PARENT | menu - > USE_BOX_TITLE ) ;
2006-03-04 15:43:47 +03:00
menu - > set_enabled ( BX_GDBSTUB ) ;
enabled = new bx_param_bool_c ( menu ,
" enabled " ,
" Enable GDB stub " ,
" " ,
0 ) ;
enabled - > set_enabled ( BX_GDBSTUB ) ;
2011-04-21 17:27:42 +04:00
new bx_param_num_c ( menu ,
2006-03-04 15:43:47 +03:00
" port " ,
" Port " ,
" TCP/IP port for GDB stub " ,
0 , 65535 ,
1234 ) ;
2011-04-21 17:27:42 +04:00
new bx_param_num_c ( menu ,
2006-03-04 15:43:47 +03:00
" text_base " ,
" Text base " ,
" " ,
0 , BX_MAX_BIT32U ,
0 ) ;
2011-04-21 17:27:42 +04:00
new bx_param_num_c ( menu ,
2006-03-04 15:43:47 +03:00
" data_base " ,
" Data base " ,
" " ,
0 , BX_MAX_BIT32U ,
0 ) ;
2011-04-21 17:27:42 +04:00
new bx_param_num_c ( menu ,
2006-03-04 15:43:47 +03:00
" bss_base " ,
" BSS base " ,
" " ,
0 , BX_MAX_BIT32U ,
0 ) ;
enabled - > set_dependent_list ( menu - > clone ( ) ) ;
2004-06-05 02:06:55 +04:00
2009-01-02 14:51:03 +03:00
# if BX_PLUGINS
2009-01-05 00:46:20 +03:00
// user-defined options subtree
2012-02-12 22:43:20 +04:00
bx_list_c * user = new bx_list_c ( root_param , " user " , " User-defined options " ) ;
2009-03-16 00:16:17 +03:00
user - > set_options ( user - > SHOW_PARENT ) ;
2009-01-02 14:51:03 +03:00
# endif
2006-03-05 13:24:29 +03:00
// log options subtree
menu = new bx_list_c ( root_param , " log " , " Logfile Options " ) ;
2010-11-23 00:55:56 +03:00
menu - > set_options ( menu - > SHOW_PARENT ) ;
2006-03-05 13:24:29 +03:00
2006-03-03 23:29:50 +03:00
// log options
2006-03-05 13:24:29 +03:00
path = new bx_param_filename_c ( menu ,
" filename " ,
2006-03-03 23:29:50 +03:00
" Log filename " ,
" Pathname of bochs log file " ,
" - " , BX_PATHNAME_LEN ) ;
2006-03-05 13:24:29 +03:00
path - > set_ask_format ( " Enter log filename: [%s] " ) ;
2009-03-16 00:16:17 +03:00
path - > set_extension ( " txt " ) ;
2006-03-03 23:29:50 +03:00
2006-03-05 13:24:29 +03:00
bx_param_string_c * prefix = new bx_param_string_c ( menu ,
" prefix " ,
2006-03-03 23:29:50 +03:00
" Log output prefix " ,
" Prefix prepended to log output " ,
2013-12-29 14:41:11 +04:00
" %t%e%d " , BX_LOGPREFIX_LEN ) ;
2006-03-05 13:24:29 +03:00
prefix - > set_ask_format ( " Enter log prefix: [%s] " ) ;
2006-03-03 23:29:50 +03:00
2006-03-05 13:24:29 +03:00
path = new bx_param_filename_c ( menu ,
" debugger_filename " ,
2006-03-03 23:29:50 +03:00
" Debugger Log filename " ,
" Pathname of debugger log file " ,
" - " , BX_PATHNAME_LEN ) ;
2006-03-05 13:24:29 +03:00
path - > set_ask_format ( " Enter debugger log filename: [%s] " ) ;
2009-03-16 00:16:17 +03:00
path - > set_extension ( " log " ) ;
2006-03-05 13:24:29 +03:00
path - > set_enabled ( BX_DEBUGGER ) ;
2006-03-03 23:29:50 +03:00
2009-03-30 00:48:17 +04:00
// runtime options
menu = new bx_list_c ( special_menus , " runtime " , " Runtime options " ) ;
2012-02-12 22:43:20 +04:00
bx_list_c * cdrom = new bx_list_c ( menu , " cdrom " , " CD-ROM options " ) ;
2013-11-26 01:07:39 +04:00
cdrom - > set_runtime_param ( 1 ) ;
2009-03-30 00:48:17 +04:00
cdrom - > set_options ( cdrom - > SHOW_PARENT ) ;
2009-03-04 21:20:50 +03:00
// misc runtime options
2012-01-12 22:03:20 +04:00
misc = new bx_list_c ( menu , " misc " , " Misc options " ) ;
2013-11-26 01:07:39 +04:00
misc - > set_runtime_param ( 1 ) ;
2012-01-12 22:03:20 +04:00
misc - > add ( SIM - > get_param ( BXPN_VGA_UPDATE_FREQUENCY ) ) ;
misc - > add ( SIM - > get_param ( BXPN_MOUSE_ENABLED ) ) ;
misc - > add ( SIM - > get_param ( BXPN_KBD_PASTE_DELAY ) ) ;
misc - > add ( SIM - > get_param ( BXPN_USER_SHORTCUT ) ) ;
2021-05-11 17:42:31 +03:00
misc - > add ( SIM - > get_param ( BXPN_PORT_E9_HACK ) ) ;
2023-08-26 18:37:55 +03:00
misc - > add ( SIM - > get_param ( BXPN_PORT_E9_HACK_ALL_RINGS ) ) ;
2023-08-27 19:34:01 +03:00
# if BX_SUPPORT_IODEBUG
misc - > add ( SIM - > get_param ( BXPN_IODEBUG_ALL_RINGS ) ) ;
# endif
2009-03-30 00:48:17 +04:00
misc - > set_options ( misc - > SHOW_PARENT | misc - > SHOW_GROUP_NAME ) ;
2004-06-05 02:06:55 +04:00
}
2006-03-02 23:13:14 +03:00
void bx_reset_options ( )
2004-06-05 02:06:55 +04:00
{
2012-08-19 15:45:50 +04:00
// optional plugin control
bx_plugin_ctrl_reset ( 1 ) ;
2006-02-18 19:53:18 +03:00
// cpu
SIM - > get_param ( " cpu " ) - > reset ( ) ;
2011-02-25 19:27:01 +03:00
# if BX_CPU_LEVEL >= 4
2010-02-26 01:04:31 +03:00
// cpuid
SIM - > get_param ( " cpuid " ) - > reset ( ) ;
2011-02-25 19:27:01 +03:00
# endif
2010-02-26 01:04:31 +03:00
2005-08-07 19:50:07 +04:00
// memory (ram & rom)
2006-02-17 00:44:17 +03:00
SIM - > get_param ( " memory " ) - > reset ( ) ;
2004-06-05 02:06:55 +04:00
2006-02-19 18:43:03 +03:00
// clock & cmos
SIM - > get_param ( " clock_cmos " ) - > reset ( ) ;
2006-02-20 00:35:50 +03:00
// pci
SIM - > get_param ( " pci " ) - > reset ( ) ;
2006-02-22 00:35:09 +03:00
// display & interface
SIM - > get_param ( " display " ) - > reset ( ) ;
2006-02-22 22:18:29 +03:00
// keyboard & mouse
SIM - > get_param ( " keyboard_mouse " ) - > reset ( ) ;
2006-02-24 01:48:57 +03:00
// boot
SIM - > get_param ( " boot_params " ) - > reset ( ) ;
2006-02-25 01:35:46 +03:00
// floppy drives
SIM - > get_param ( " floppy " ) - > reset ( ) ;
2006-02-26 22:11:20 +03:00
// ata/atapi drives
SIM - > get_param ( " ata " ) - > reset ( ) ;
2009-01-20 12:26:26 +03:00
// serial/parallel/usb
2006-03-01 20:14:36 +03:00
SIM - > get_param ( " ports " ) - > reset ( ) ;
2004-06-05 02:06:55 +04:00
2011-12-23 18:40:43 +04:00
// network devices
2006-03-02 23:13:14 +03:00
SIM - > get_param ( " network " ) - > reset ( ) ;
2005-09-23 01:12:26 +04:00
2011-12-26 21:32:57 +04:00
// sound devices
2006-03-03 23:29:50 +03:00
SIM - > get_param ( " sound " ) - > reset ( ) ;
// misc
2006-03-04 15:43:47 +03:00
SIM - > get_param ( " misc " ) - > reset ( ) ;
2004-06-05 02:06:55 +04:00
// logfile
2006-03-05 13:24:29 +03:00
SIM - > get_param ( " log " ) - > reset ( ) ;
2009-01-02 14:51:03 +03:00
# if BX_PLUGINS
2009-01-05 00:46:20 +03:00
// user-defined options
SIM - > get_param ( " user " ) - > reset ( ) ;
2009-01-02 14:51:03 +03:00
# endif
2004-06-05 02:06:55 +04:00
}
2023-11-26 17:44:38 +03:00
void bx_cleanup_options ( )
{
free ( config_interface_list ) ;
free ( display_library_list ) ;
free ( vga_extension_names ) ;
free ( vga_extension_plugins ) ;
free ( pcislot_dev_list ) ;
}
2006-03-13 21:55:53 +03:00
int bx_read_configuration ( const char * rcfile )
2004-06-05 02:06:55 +04:00
{
// parse rcfile first, then parse arguments in order.
BX_INFO ( ( " reading configuration from %s " , rcfile ) ) ;
if ( parse_bochsrc ( rcfile ) < 0 ) {
BX_PANIC ( ( " reading from %s failed " , rcfile ) ) ;
return - 1 ;
}
// update log actions
for ( int level = 0 ; level < N_LOGLEV ; level + + ) {
2008-09-13 01:05:49 +04:00
int action = SIM - > get_default_log_action ( level ) ;
io - > set_log_action ( level , action ) ;
2004-06-05 02:06:55 +04:00
}
2013-02-04 22:51:07 +04:00
bx_set_log_actions_by_device ( 0 ) ;
2004-06-05 02:06:55 +04:00
return 0 ;
}
2008-03-30 18:32:14 +04:00
int bx_parse_cmdline ( int arg , int argc , char * argv [ ] )
2004-06-05 02:06:55 +04:00
{
2013-02-06 00:57:40 +04:00
int level , def_action [ N_LOGLEV ] ;
2004-06-05 02:06:55 +04:00
2013-02-06 00:57:40 +04:00
for ( level = 0 ; level < N_LOGLEV ; level + + ) {
def_action [ level ] = SIM - > get_default_log_action ( level ) ;
}
2004-06-05 02:06:55 +04:00
while ( arg < argc ) {
2023-12-08 16:17:40 +03:00
char ch = argv [ arg ] [ strlen ( argv [ arg ] ) - 1 ] ;
if ( ( ( arg + 1 ) < argc ) & & ( ( ch = = ' : ' ) | | ( ch = = ' = ' ) | | ( ch = = ' , ' ) ) ) {
char tmparg [ BX_PATHNAME_LEN ] ;
strcpy ( tmparg , argv [ arg ] ) ;
do {
arg + + ;
strcat ( tmparg , argv [ arg ] ) ;
ch = argv [ arg ] [ strlen ( argv [ arg ] ) - 1 ] ;
} while ( ( ( arg + 1 ) < argc ) & & ( ( ch = = ' : ' ) | | ( ch = = ' = ' ) | | ( ch = = ' , ' ) ) ) ;
BX_INFO ( ( " parsing concatenated arg %s " , tmparg ) ) ;
parse_line_unformatted ( " cmdline args " , tmparg ) ;
} else {
BX_INFO ( ( " parsing arg %d, %s " , arg , argv [ arg ] ) ) ;
parse_line_unformatted ( " cmdline args " , argv [ arg ] ) ;
}
2004-06-05 02:06:55 +04:00
arg + + ;
}
2013-02-06 00:57:40 +04:00
// update log actions if default has been changed
for ( level = 0 ; level < N_LOGLEV ; level + + ) {
2008-09-13 01:05:49 +04:00
int action = SIM - > get_default_log_action ( level ) ;
2013-02-06 00:57:40 +04:00
if ( action ! = def_action [ level ] ) {
io - > set_log_action ( level , action ) ;
}
2004-06-05 02:06:55 +04:00
}
2013-02-04 22:51:07 +04:00
bx_set_log_actions_by_device ( 0 ) ;
2004-06-05 02:06:55 +04:00
return 0 ;
}
2006-06-05 23:06:36 +04:00
char * bx_find_bochsrc ( )
2004-06-05 02:06:55 +04:00
{
FILE * fd = NULL ;
char rcfile [ 512 ] ;
Bit32u retry = 0 , found = 0 ;
// try several possibilities for the bochsrc before giving up
while ( ! found ) {
rcfile [ 0 ] = 0 ;
switch ( retry + + ) {
case 0 : strcpy ( rcfile , " .bochsrc " ) ; break ;
case 1 : strcpy ( rcfile , " bochsrc " ) ; break ;
case 2 : strcpy ( rcfile , " bochsrc.txt " ) ; break ;
# ifdef WIN32
case 3 : strcpy ( rcfile , " bochsrc.bxrc " ) ; break ;
# elif !BX_WITH_MACOS
// only try this on unix
case 3 :
{
2006-01-23 21:39:10 +03:00
char * ptr = getenv ( " HOME " ) ;
if ( ptr ) snprintf ( rcfile , sizeof ( rcfile ) , " %s/.bochsrc " , ptr ) ;
2004-06-05 02:06:55 +04:00
}
break ;
2006-01-23 21:39:10 +03:00
case 4 : strcpy ( rcfile , " /etc/bochsrc " ) ; break ;
2004-06-05 02:06:55 +04:00
# endif
default :
return NULL ;
}
if ( rcfile [ 0 ] ) {
BX_DEBUG ( ( " looking for configuration in %s " , rcfile ) ) ;
fd = fopen ( rcfile , " r " ) ;
if ( fd ) found = 1 ;
}
}
assert ( fd ! = NULL & & rcfile [ 0 ] ! = 0 ) ;
fclose ( fd ) ;
2006-05-30 21:01:27 +04:00
return strdup ( rcfile ) ;
2004-06-05 02:06:55 +04:00
}
2006-03-13 21:55:53 +03:00
static int parse_bochsrc ( const char * rcfile )
2004-06-05 02:06:55 +04:00
{
FILE * fd = NULL ;
char * ret ;
char line [ 512 ] ;
2007-04-03 19:47:23 +04:00
char context [ BX_PATHNAME_LEN ] ;
Bit32u linenum = 1 ;
2004-06-05 02:06:55 +04:00
// try several possibilities for the bochsrc before giving up
2012-09-16 12:55:59 +04:00
bochsrc_include_level + + ;
2004-06-05 02:06:55 +04:00
fd = fopen ( rcfile , " r " ) ;
if ( fd = = NULL ) return - 1 ;
int retval = 0 ;
do {
ret = fgets ( line , sizeof ( line ) - 1 , fd ) ;
line [ sizeof ( line ) - 1 ] = ' \0 ' ;
2007-12-23 20:21:28 +03:00
size_t len = strlen ( line ) ;
2004-08-01 23:17:18 +04:00
if ( ( len > 0 ) & & ( line [ len - 1 ] < ' ' ) )
2004-06-05 02:06:55 +04:00
line [ len - 1 ] = ' \0 ' ;
if ( ( ret ! = NULL ) & & strlen ( line ) ) {
2007-04-03 19:47:23 +04:00
sprintf ( context , " %s:%u " , rcfile , linenum ) ;
if ( parse_line_unformatted ( context , line ) < 0 ) {
2004-06-05 02:06:55 +04:00
retval = - 1 ;
break ; // quit parsing after first error
}
2007-04-03 19:47:23 +04:00
}
linenum + + ;
} while ( ! feof ( fd ) ) ;
2004-06-05 02:06:55 +04:00
fclose ( fd ) ;
2012-09-16 12:55:59 +04:00
bochsrc_include_level - - ;
2004-06-05 02:06:55 +04:00
return retval ;
}
2017-04-22 13:17:54 +03:00
const char * get_builtin_variable ( const char * varname )
2004-06-05 02:06:55 +04:00
{
# ifdef WIN32
int code ;
DWORD size ;
DWORD type = 0 ;
HKEY hkey ;
char keyname [ 80 ] ;
static char data [ MAX_PATH ] ;
# endif
if ( strlen ( varname ) < 1 ) return NULL ;
else {
if ( ! strcmp ( varname , " BXSHARE " ) ) {
# ifdef WIN32
2019-11-30 20:51:19 +03:00
wsprintf ( keyname , " Software \\ Bochs " ) ;
2004-06-05 02:06:55 +04:00
code = RegOpenKeyEx ( HKEY_LOCAL_MACHINE , keyname , 0 , KEY_READ , & hkey ) ;
if ( code = = ERROR_SUCCESS ) {
data [ 0 ] = 0 ;
size = MAX_PATH ;
if ( RegQueryValueEx ( hkey , " " , NULL , ( LPDWORD ) & type , ( LPBYTE ) data ,
2008-02-16 01:05:43 +03:00
( LPDWORD ) & size ) = = ERROR_SUCCESS ) {
2004-06-05 02:06:55 +04:00
RegCloseKey ( hkey ) ;
return data ;
} else {
RegCloseKey ( hkey ) ;
return NULL ;
}
} else {
return NULL ;
}
# else
return BX_SHARE_PATH ;
# endif
}
return NULL ;
}
}
2008-03-30 18:32:14 +04:00
static int parse_line_unformatted ( const char * context , char * line )
2004-06-05 02:06:55 +04:00
{
# define MAX_PARAMS_LEN 40
char * ptr ;
unsigned i , string_i = 0 ;
char string [ 512 ] ;
char * params [ MAX_PARAMS_LEN ] ;
int num_params ;
2021-01-30 18:16:00 +03:00
bool inquotes = 0 ;
bool comment = 0 ;
2004-06-05 02:06:55 +04:00
memset ( params , 0 , sizeof ( params ) ) ;
if ( line = = NULL ) return 0 ;
// if passed nothing but whitespace, just return
for ( i = 0 ; i < strlen ( line ) ; i + + ) {
if ( ! isspace ( line [ i ] ) ) break ;
2009-11-20 00:28:25 +03:00
}
2004-06-05 02:06:55 +04:00
if ( i > = strlen ( line ) )
return 0 ;
num_params = 0 ;
if ( ! strncmp ( line , " #include " , 8 ) )
ptr = strtok ( line , " " ) ;
else
ptr = strtok ( line , " : " ) ;
while ( ( ptr ) & & ( ! comment ) ) {
if ( ! inquotes ) {
string_i = 0 ;
} else {
string [ string_i + + ] = ' , ' ;
}
for ( i = 0 ; i < strlen ( ptr ) ; i + + ) {
if ( ptr [ i ] = = ' " ' )
inquotes = ! inquotes ;
else if ( ( ptr [ i ] = = ' # ' ) & & ( strncmp ( line + i , " #include " , 8 ) ) & & ! inquotes ) {
comment = 1 ;
break ;
} else {
# if BX_HAVE_GETENV
// substitute environment variables.
if ( ptr [ i ] = = ' $ ' ) {
char varname [ 512 ] ;
char * pv = varname ;
2007-10-25 03:29:40 +04:00
const char * value ;
2004-06-05 02:06:55 +04:00
* pv = 0 ;
i + + ;
while ( isalpha ( ptr [ i ] ) | | ptr [ i ] = = ' _ ' ) {
* pv = ptr [ i ] ; pv + + ; i + + ;
}
* pv = 0 ;
if ( strlen ( varname ) < 1 | | ! ( value = getenv ( varname ) ) ) {
if ( ( value = get_builtin_variable ( varname ) ) ) {
2014-04-30 20:26:22 +04:00
if ( ( string_i + strlen ( value ) ) < 512 ) {
// append value to the string
for ( pv = ( char * ) value ; * pv ; pv + + )
string [ string_i + + ] = * pv ;
} else {
BX_PANIC ( ( " parse_line_unformatted(): out of memory " ) ) ;
}
} else {
BX_PANIC ( ( " could not look up environment variable '%s' " , varname ) ) ;
}
} else {
if ( ( string_i + strlen ( value ) ) < 512 ) {
2004-06-05 02:06:55 +04:00
// append value to the string
2007-10-25 03:29:40 +04:00
for ( pv = ( char * ) value ; * pv ; pv + + )
2004-06-05 02:06:55 +04:00
string [ string_i + + ] = * pv ;
} else {
2014-04-30 20:26:22 +04:00
BX_PANIC ( ( " parse_line_unformatted(): out of memory " ) ) ;
2004-06-05 02:06:55 +04:00
}
}
}
# endif
if ( ! isspace ( ptr [ i ] ) | | inquotes ) {
2014-04-30 20:26:22 +04:00
if ( string_i < 511 ) {
string [ string_i + + ] = ptr [ i ] ;
} else {
BX_PANIC ( ( " parse_line_unformatted(): out of memory " ) ) ;
}
2004-06-05 02:06:55 +04:00
}
}
}
string [ string_i ] = ' \0 ' ;
if ( string_i = = 0 ) break ;
if ( ! inquotes ) {
if ( params [ num_params ] ! = NULL ) {
free ( params [ num_params ] ) ;
params [ num_params ] = NULL ;
}
if ( num_params < MAX_PARAMS_LEN ) {
2006-05-30 02:33:38 +04:00
params [ num_params + + ] = strdup ( string ) ;
2004-06-05 02:06:55 +04:00
} else {
BX_PANIC ( ( " too many parameters, max is %d \n " , MAX_PARAMS_LEN ) ) ;
}
}
ptr = strtok ( NULL , " , " ) ;
}
Bit32s retval = parse_line_formatted ( context , num_params , & params [ 0 ] ) ;
for ( i = 0 ; i < MAX_PARAMS_LEN ; i + + )
{
2008-02-15 22:03:54 +03:00
if ( params [ i ] ! = NULL )
2004-06-05 02:06:55 +04:00
{
free ( params [ i ] ) ;
params [ i ] = NULL ;
}
}
return retval ;
}
// These macros are called for all parse errors, so that we can easily
// change the behavior of all occurrences.
# define PARSE_ERR(x) \
do { BX_PANIC ( x ) ; return - 1 ; } while ( 0 )
# define PARSE_WARN(x) \
BX_ERROR ( x )
2004-09-07 22:02:29 +04:00
/*
* this supports the " floppyx: image= " option .
* the functions returns the type of the floppy
* image ( 1.44 , 360 , etc . ) , based on the image file size .
*/
2021-03-29 14:17:03 +03:00
int get_floppy_type_from_image ( const char * filename )
2004-09-07 22:02:29 +04:00
{
struct stat stat_buf ;
2011-01-19 00:04:44 +03:00
if ( ! strncmp ( filename , " vvfat: " , 6 ) ) {
2021-03-29 14:17:03 +03:00
return BX_FLOPPY_1_44 ;
2021-03-28 11:40:28 +03:00
} else if ( stat ( filename , & stat_buf ) ) {
2004-09-07 22:02:29 +04:00
return BX_FLOPPY_NONE ;
2021-03-28 11:40:28 +03:00
} else {
switch ( stat_buf . st_size ) {
case 163840 :
2021-03-29 14:17:03 +03:00
return BX_FLOPPY_160K ;
2021-03-28 11:40:28 +03:00
case 184320 :
2021-03-29 14:17:03 +03:00
return BX_FLOPPY_180K ;
2021-03-28 11:40:28 +03:00
case 327680 :
2021-03-29 14:17:03 +03:00
return BX_FLOPPY_320K ;
2021-03-28 11:40:28 +03:00
case 368640 :
2021-03-29 14:17:03 +03:00
return BX_FLOPPY_360K ;
2021-03-28 11:40:28 +03:00
case 737280 :
2021-03-29 14:17:03 +03:00
return BX_FLOPPY_720K ;
2021-03-28 11:40:28 +03:00
case 1228800 :
2021-03-29 14:17:03 +03:00
return BX_FLOPPY_1_2 ;
2021-03-28 11:40:28 +03:00
case 1474560 :
case 1720320 :
case 1763328 :
case 1884160 :
2021-03-29 14:17:03 +03:00
return BX_FLOPPY_1_44 ;
2021-03-28 11:40:28 +03:00
case 2949120 :
2021-03-29 14:17:03 +03:00
return BX_FLOPPY_2_88 ;
2021-03-28 11:40:28 +03:00
default :
2021-03-29 14:17:03 +03:00
return BX_FLOPPY_UNKNOWN ;
2021-03-28 11:40:28 +03:00
}
2004-09-07 22:02:29 +04:00
}
}
2011-12-29 16:44:38 +04:00
static Bit32s parse_log_options ( const char * context , int num_params , char * params [ ] )
2005-11-17 23:35:38 +03:00
{
2011-12-29 16:44:38 +04:00
int level , action , i ;
2021-01-30 18:16:00 +03:00
bool def_action = 0 ;
2011-12-29 16:44:38 +04:00
char * param , * module , * actstr ;
char pname [ 20 ] ;
bx_list_c * base ;
bx_param_num_c * mparam ;
2005-11-17 23:35:38 +03:00
2011-12-29 16:44:38 +04:00
if ( ! strcmp ( params [ 0 ] , " panic " ) ) {
2005-11-17 23:35:38 +03:00
level = LOGLEV_PANIC ;
2011-12-29 16:44:38 +04:00
} else if ( ! strcmp ( params [ 0 ] , " error " ) ) {
2005-11-17 23:35:38 +03:00
level = LOGLEV_ERROR ;
2011-12-29 16:44:38 +04:00
} else if ( ! strcmp ( params [ 0 ] , " info " ) ) {
2005-11-17 23:35:38 +03:00
level = LOGLEV_INFO ;
} else { /* debug */
level = LOGLEV_DEBUG ;
}
2011-12-29 16:44:38 +04:00
for ( i = 1 ; i < num_params ; i + + ) {
param = strdup ( params [ i ] ) ;
module = strtok ( param , " = " ) ;
actstr = strtok ( NULL , " " ) ;
if ( actstr ! = NULL ) {
def_action = ! strcmp ( module , " action " ) ;
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/bochs.h ./bochs.h
--- /home/volker/bochs/bochs/bochs.h 2016-08-12 19:06:18.803209189 +0200
+++ ./bochs.h 2016-12-28 00:41:20.000627252 +0100
@@ -2,7 +2,7 @@
// $Id: bochs.h 12935 2016-08-12 17:06:14Z vruppert $
/////////////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2001-2015 The Bochs Project
+// Copyright (C) 2001-2016 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
@@ -276,8 +276,9 @@
void error(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3);
void panic(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3);
void ldebug(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3);
- void fatal (const char *prefix, const char *fmt, va_list ap, int exit_status);
- void ask (int level, const char *prefix, const char *fmt, va_list ap);
+ void fatal(const char *prefix, const char *fmt, va_list ap, int exit_status);
+ void warn(int level, const char *prefix, const char *fmt, va_list ap);
+ void ask(int level, const char *prefix, const char *fmt, va_list ap);
void put(const char *p);
void put(const char *n, const char *p);
void setio(class iofunctions *);
@@ -334,7 +335,8 @@
void set_log_action(int loglevel, int action);
const char *getlevel(int i) const;
const char *getaction(int i) const;
-
+ int isaction(const char *val) const;
+
protected:
int n_logfn;
#define MAX_LOGFNS 512
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/CHANGES ./CHANGES
--- /home/volker/bochs/bochs/CHANGES 2016-12-26 10:45:44.000000000 +0100
+++ ./CHANGES 2016-12-28 15:54:25.127088081 +0100
@@ -1,5 +1,8 @@
Changes after 2.6.8 release:
+- General
+ - Added new log action "warn", designed to show a message box on error events.
+
- Configure and compile
- Added Android host platform support.
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/config.cc ./config.cc
--- /home/volker/bochs/bochs/config.cc 2016-05-03 21:15:09.158016000 +0200
+++ ./config.cc 2016-12-27 19:53:10.461420368 +0100
@@ -2062,15 +2062,8 @@
actstr = strtok(NULL, "");
if (actstr != NULL) {
def_action = !strcmp(module, "action");
- if (!strcmp(actstr, "fatal"))
- action = ACT_FATAL;
- else if (!strcmp (actstr, "report"))
- action = ACT_REPORT;
- else if (!strcmp (actstr, "ignore"))
- action = ACT_IGNORE;
- else if (!strcmp (actstr, "ask"))
- action = ACT_ASK;
- else {
+ action = SIM->is_action_name(actstr);
+ if (action < ACT_IGNORE) {
PARSE_ERR(("%s: %s directive malformed.", context, params[0]));
free(param);
return -1;
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/sdl2.cc ./gui/sdl2.cc
--- /home/volker/bochs/bochs/gui/sdl2.cc 2016-08-12 19:06:18.811209142 +0200
+++ ./gui/sdl2.cc 2016-12-28 12:33:39.534288819 +0100
@@ -2,7 +2,7 @@
// $Id: sdl2.cc 12935 2016-08-12 17:06:14Z vruppert $
/////////////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2014-2015 The Bochs Project
+// Copyright (C) 2014-2016 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
@@ -1478,20 +1478,16 @@
SDL_MessageBoxData msgboxdata;
SDL_MessageBoxButtonData buttondata[4];
int level, retcode;
-#if BX_DEBUGGER || BX_GDBSTUB
- int defbtn = 3;
-#else
- int defbtn = 2;
-#endif
char message[512];
level = event->u.logmsg.level;
- sprintf(message, "%s %s", event->u.logmsg.prefix, event->u.logmsg.msg);
+ sprintf(message, "Device: %s\nMessage: %s", event->u.logmsg.prefix,
+ event->u.logmsg.msg);
msgboxdata.flags = SDL_MESSAGEBOX_ERROR;
msgboxdata.window = window;
msgboxdata.title = SIM->get_log_level_name(level);
msgboxdata.message = message;
- msgboxdata.numbuttons = defbtn + 1;
+ msgboxdata.numbuttons = 2;
msgboxdata.buttons = buttondata;
msgboxdata.colorScheme = NULL;
buttondata[0].flags = 0;
@@ -1500,14 +1496,18 @@
buttondata[1].flags = 0;
buttondata[1].buttonid = BX_LOG_ASK_CHOICE_CONTINUE_ALWAYS;
buttondata[1].text = "Alwayscont";
+ if (event->u.logmsg.flag == BX_LOG_ASK_ASKDLG) {
+ msgboxdata.numbuttons = 3;
+ buttondata[2].flags = SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT;
+ buttondata[2].buttonid = BX_LOG_ASK_CHOICE_DIE;
+ buttondata[2].text = "Quit";
#if BX_DEBUGGER || BX_GDBSTUB
- buttondata[2].flags = 0;
- buttondata[2].buttonid = BX_LOG_ASK_CHOICE_ENTER_DEBUG;
- buttondata[2].text = "Debugger";
-#endif
- buttondata[defbtn].flags = SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT;
- buttondata[defbtn].buttonid = BX_LOG_ASK_CHOICE_DIE;
- buttondata[defbtn].text = "Quit";
+ msgboxdata.numbuttons = 4;
+ buttondata[3].flags = 0;
+ buttondata[3].buttonid = BX_LOG_ASK_CHOICE_ENTER_DEBUG;
+ buttondata[3].text = "Debugger";
+#endif
+ }
if (SDL_ShowMessageBox(&msgboxdata, &retcode) < 0) {
return -1;
} else {
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/siminterface.cc ./gui/siminterface.cc
--- /home/volker/bochs/bochs/gui/siminterface.cc 2016-12-05 19:56:56.729685000 +0100
+++ ./gui/siminterface.cc 2016-12-28 11:14:02.004075717 +0100
@@ -2,7 +2,7 @@
// $Id: siminterface.cc 12981 2016-12-05 18:56:56Z sshwarts $
/////////////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2002-2015 The Bochs Project
+// Copyright (C) 2002-2016 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
@@ -100,6 +100,7 @@
virtual int get_log_action(int mod, int level);
virtual void set_log_action(int mod, int level, int action);
virtual const char *get_action_name(int action);
+ virtual int is_action_name(const char *val);
virtual int get_default_log_action(int level) {
return logfunctions::get_default_action(level);
}
@@ -123,6 +124,7 @@
virtual void set_notify_callback(bxevent_handler func, void *arg);
virtual void get_notify_callback(bxevent_handler *func, void **arg);
virtual BxEvent* sim_to_ci_event(BxEvent *event);
+ virtual int log_warn(const char *prefix, int level, const char *msg);
virtual int log_ask(const char *prefix, int level, const char *msg);
virtual void log_msg(const char *prefix, int level, const char *msg);
virtual void set_log_viewer(bx_bool val) { bx_log_viewer = val; }
@@ -420,6 +422,11 @@
return io->getaction(action);
}
+int bx_real_sim_c::is_action_name(const char *val)
+{
+ return io->isaction(val);
+}
+
const char *bx_real_sim_c::get_log_level_name(int level)
{
return io->getlevel(level);
@@ -575,6 +582,21 @@
}
}
+int bx_real_sim_c::log_warn(const char *prefix, int level, const char *msg)
+{
+ BxEvent be;
+ be.type = BX_SYNC_EVT_LOG_ASK;
+ be.u.logmsg.prefix = prefix;
+ be.u.logmsg.level = level;
+ be.u.logmsg.msg = msg;
+ be.u.logmsg.flag = BX_LOG_ASK_MSGBOX_WARN;
+ // default return value in case something goes wrong.
+ be.retcode = BX_LOG_NOTIFY_FAILED;
+ // calling notify
+ sim_to_ci_event(&be);
+ return be.retcode;
+}
+
// returns 0 for continue, 1 for alwayscontinue, 2 for die.
int bx_real_sim_c::log_ask(const char *prefix, int level, const char *msg)
{
@@ -583,6 +605,7 @@
be.u.logmsg.prefix = prefix;
be.u.logmsg.level = level;
be.u.logmsg.msg = msg;
+ be.u.logmsg.flag = BX_LOG_ASK_ASKDLG;
// default return value in case something goes wrong.
be.retcode = BX_LOG_NOTIFY_FAILED;
// calling notify
@@ -1157,16 +1180,10 @@
} else if (!strncmp(string, "PANIC=", 6)) {
type = LOGLEV_PANIC;
}
- if (!strcmp(string+j, "ignore")) {
- action = ACT_IGNORE;
- } else if (!strcmp(string+j, "report")) {
- action = ACT_REPORT;
- } else if (!strcmp(string+j, "ask")) {
- action = ACT_ASK;
- } else if (!strcmp(string+j, "fatal")) {
- action = ACT_FATAL;
+ action = is_action_name(string+j);
+ if (action >= ACT_IGNORE) {
+ set_log_action(dev, type, action);
}
- set_log_action(dev, type, action);
} else {
if (i == 1) {
BX_ERROR(("restore_logopts(): log module '%s' not found", devname));
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/siminterface.h ./gui/siminterface.h
--- /home/volker/bochs/bochs/gui/siminterface.h 2016-03-31 19:24:37.451025427 +0200
+++ ./gui/siminterface.h 2016-12-28 11:11:21.036683362 +0100
@@ -168,6 +168,7 @@
typedef enum {
ACT_IGNORE = 0,
ACT_REPORT,
+ ACT_WARN,
ACT_ASK,
ACT_FATAL,
N_ACT
@@ -178,11 +179,11 @@
// normally all action choices are available for all event types. The exclude
// expression allows some choices to be eliminated if they don't make any
// sense. For example, it would be stupid to ignore a panic.
-#define BX_LOG_OPTS_EXCLUDE(type, choice) ( \
- /* can't die or ask, on debug or info events */ \
- (type <= LOGLEV_INFO && (choice == ACT_ASK || choice == ACT_FATAL)) \
- /* can't ignore panics */ \
- || (type == LOGLEV_PANIC && choice == ACT_IGNORE) \
+#define BX_LOG_OPTS_EXCLUDE(type, choice) ( \
+ /* can't die, ask or warn, on debug or info events */ \
+ (type <= LOGLEV_INFO && (choice >= ACT_WARN)) \
+ /* can't ignore panics */ \
+ || (type == LOGLEV_PANIC && choice == ACT_IGNORE) \
)
// floppy / cdrom media status
@@ -392,6 +393,7 @@
// synchronizing threads, etc. for each.
typedef struct {
Bit8u level;
+ Bit8u flag;
const char *prefix;
const char *msg;
} BxLogMsgEvent;
@@ -419,6 +421,12 @@
BX_LOG_NOTIFY_FAILED
};
+enum {
+ BX_LOG_ASK_ASKDLG,
+ BX_LOG_ASK_MSGBOX_WARN,
+ BX_LOG_ASK_MSGBOX_QUIT
+};
+
// Event type: BX_SYNC_EVT_GET_DBG_COMMAND
//
// This is a synchronous event sent from the simulator to the debugger
@@ -675,6 +683,7 @@
virtual int get_default_log_action(int level) {return -1;}
virtual void set_default_log_action(int level, int action) {}
virtual const char *get_action_name(int action) {return NULL;}
+ virtual int is_action_name(const char *val) {return -1;}
virtual const char *get_log_level_name(int level) {return NULL;}
virtual int get_max_log_level() {return -1;}
@@ -715,6 +724,9 @@
// send an event from the simulator to the CI.
virtual BxEvent* sim_to_ci_event(BxEvent *event) {return NULL;}
+ // called from simulator when it hits errors, to warn the user
+ // before continuing simulation
+ virtual int log_warn(const char *prefix, int level, const char *msg) {return -1;}
// called from simulator when it hits serious errors, to ask if the user
// wants to continue or not
virtual int log_ask(const char *prefix, int level, const char *msg) {return -1;}
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/textconfig.cc ./gui/textconfig.cc
--- /home/volker/bochs/bochs/gui/textconfig.cc 2016-12-05 20:15:59.112637000 +0100
+++ ./gui/textconfig.cc 2016-12-28 12:44:43.079411258 +0100
@@ -2,7 +2,7 @@
// $Id: textconfig.cc 12983 2016-12-05 19:15:59Z sshwarts $
/////////////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2002-2013 The Bochs Project
+// Copyright (C) 2002-2016 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
@@ -552,8 +552,8 @@
}
static const char *log_options_prompt1 = "Enter the ID of the device to edit, or -1 to return: [-1] ";
-static const char *log_level_choices[] = { "ignore", "report", "ask", "fatal", "no change" };
-static int log_level_n_choices_normal = 4;
+static const char *log_level_choices[N_ACT+1] = { "ignore", "report", "warn", "ask", "fatal", "no change" };
+static int log_level_n_choices_normal = N_ACT;
void bx_log_options(int individual)
{
@@ -589,7 +589,7 @@
bx_print_log_action_table();
for (int level=0; level<SIM->get_max_log_level(); level++) {
char prompt[1024];
- int action, default_action = 4; // default to no change
+ int action, default_action = N_ACT; // default to no change
sprintf(prompt, "Enter action for %s event on all devices: [no change] ", SIM->get_log_level_name(level));
// do show the no change choice (choices=4)
if (ask_menu(prompt, "", log_level_n_choices_normal+1, log_level_choices, default_action, &action)<0)
@@ -718,47 +718,50 @@
event->retcode = event->u.param.param->text_ask(stdin, stderr);
return event;
case BX_SYNC_EVT_LOG_ASK:
- {
- int level = event->u.logmsg.level;
- fprintf(stderr, "========================================================================\n");
- fprintf(stderr, "Event type: %s\n", SIM->get_log_level_name (level));
- fprintf(stderr, "Device: %s\n", event->u.logmsg.prefix);
- fprintf(stderr, "Message: %s\n\n", event->u.logmsg.msg);
- fprintf(stderr, "A %s has occurred. Do you want to:\n", SIM->get_log_level_name (level));
- fprintf(stderr, " cont - continue execution\n");
- fprintf(stderr, " alwayscont - continue execution, and don't ask again.\n");
- fprintf(stderr, " This affects only %s events from device %s\n", SIM->get_log_level_name (level), event->u.logmsg.prefix);
- fprintf(stderr, " die - stop execution now\n");
- fprintf(stderr, " abort - dump core %s\n",
- BX_HAVE_ABORT ? "" : "(Disabled)");
+ if (event->u.logmsg.flag == BX_LOG_ASK_ASKDLG) {
+ int level = event->u.logmsg.level;
+ fprintf(stderr, "========================================================================\n");
+ fprintf(stderr, "Event type: %s\n", SIM->get_log_level_name (level));
+ fprintf(stderr, "Device: %s\n", event->u.logmsg.prefix);
+ fprintf(stderr, "Message: %s\n\n", event->u.logmsg.msg);
+ fprintf(stderr, "A %s has occurred. Do you want to:\n", SIM->get_log_level_name (level));
+ fprintf(stderr, " cont - continue execution\n");
+ fprintf(stderr, " alwayscont - continue execution, and don't ask again.\n");
+ fprintf(stderr, " This affects only %s events from device %s\n", SIM->get_log_level_name (level), event->u.logmsg.prefix);
+ fprintf(stderr, " die - stop execution now\n");
+ fprintf(stderr, " abort - dump core %s\n",
+ BX_HAVE_ABORT ? "" : "(Disabled)");
#if BX_DEBUGGER
- fprintf(stderr, " debug - continue and return to bochs debugger\n");
+ fprintf(stderr, " debug - continue and return to bochs debugger\n");
#endif
#if BX_GDBSTUB
- fprintf(stderr, " debug - hand control to gdb\n");
+ fprintf(stderr, " debug - hand control to gdb\n");
#endif
- int choice;
+ int choice;
ask:
- if (ask_menu("Choose one of the actions above: [%s] ", "",
- log_action_n_choices, log_action_ask_choices, 2, &choice) < 0)
- event->retcode = -1;
- // return 0 for continue, 1 for alwayscontinue, 2 for die, 3 for debug.
- if (!BX_HAVE_ABORT && choice==BX_LOG_ASK_CHOICE_DUMP_CORE) goto ask;
- fflush(stdout);
- fflush(stderr);
- event->retcode = choice;
- }
- return event;
- case BX_ASYNC_EVT_REFRESH:
- case BX_ASYNC_EVT_DBG_MSG:
- case BX_ASYNC_EVT_LOG_MSG:
- // The text mode interface does not use these events, so just ignore
- // them.
- return event;
- default:
- fprintf(stderr, "textconfig: notify callback called with event type %04x\n", event->type);
- return event;
+ if (ask_menu("Choose one of the actions above: [%s] ", "",
+ log_action_n_choices, log_action_ask_choices, 2, &choice) < 0)
+ event->retcode = -1;
+ // return 0 for continue, 1 for alwayscontinue, 2 for die, 3 for debug.
+ if (!BX_HAVE_ABORT && choice==BX_LOG_ASK_CHOICE_DUMP_CORE) goto ask;
+ fflush(stdout);
+ fflush(stderr);
+ event->retcode = choice;
+ } else {
+ // warning prompt not implemented
+ event->retcode = 0;
+ }
+ return event;
+ case BX_ASYNC_EVT_REFRESH:
+ case BX_ASYNC_EVT_DBG_MSG:
+ case BX_ASYNC_EVT_LOG_MSG:
+ // The text mode interface does not use these events, so just ignore
+ // them.
+ return event;
+ default:
+ fprintf(stderr, "textconfig: notify callback called with event type %04x\n", event->type);
+ return event;
}
assert(0); // switch statement should return
}
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/win32dialog.cc ./gui/win32dialog.cc
--- /home/volker/bochs/bochs/gui/win32dialog.cc 2014-06-20 11:32:02.034026376 +0200
+++ ./gui/win32dialog.cc 2016-12-28 12:50:14.148888740 +0100
@@ -2,7 +2,7 @@
// $Id: win32dialog.cc 12381 2014-06-20 09:31:56Z vruppert $
/////////////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2003-2014 The Bochs Project
+// Copyright (C) 2003-2016 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
@@ -27,7 +27,7 @@
#include "win32res.h"
#include "win32paramdlg.h"
-const char log_choices[5][16] = {"ignore", "log", "ask user", "end simulation", "no change"};
+const char log_choices[N_ACT+1][16] = {"ignore", "log", "warn user", "ask user", "end simulation", "no change"};
HWND GetBochsWindow()
{
@@ -97,12 +97,16 @@
SetWindowText(GetDlgItem(hDlg, IDASKMSG), event->u.logmsg.msg);
SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue");
SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue and don't ask again");
- SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Kill simulation");
- SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Abort (dump core)");
+ if (event->u.logmsg.flag == BX_LOG_ASK_ASKDLG) {
+ SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Kill simulation");
+ SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Abort (dump core)");
#if BX_DEBUGGER
- SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue and return to debugger");
+ SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue and return to debugger");
#endif
- SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_SETCURSEL, 2, 0);
+ SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_SETCURSEL, 2, 0);
+ } else {
+ SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_SETCURSEL, 0, 0);
+ }
SetFocus(GetDlgItem(hDlg, IDASKLIST));
return FALSE;
case WM_CLOSE:
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/wxdialog.cc ./gui/wxdialog.cc
--- /home/volker/bochs/bochs/gui/wxdialog.cc 2015-01-07 17:17:40.447882000 +0100
+++ ./gui/wxdialog.cc 2016-12-27 20:30:44.997609007 +0100
@@ -2,7 +2,7 @@
// $Id: wxdialog.cc 12594 2015-01-07 16:17:40Z sshwarts $
/////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2002-2014 The Bochs Project
+// Copyright (C) 2002-2016 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
@@ -208,7 +208,6 @@
: wxDialog(parent, id, wxT(""), wxDefaultPosition, wxDefaultSize,
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
{
- //static int integers[LOG_OPTS_N_CHOICES_NORMAL] = {0, 1, 2, 3};
static wxString names[] = ADVLOG_OPTS_TYPE_NAMES;
SetTitle(ADVLOG_OPTS_TITLE);
vertSizer = new wxBoxSizer(wxVERTICAL);
@@ -1563,7 +1562,7 @@
bool includeNoChange)
{
static wxString choices[] = LOG_OPTS_CHOICES;
- static int integers[LOG_OPTS_N_CHOICES] = {0, 1, 2, 3, 4};
+ static int integers[LOG_OPTS_N_CHOICES] = {0, 1, 2, 3, 4, 5};
wxChoice *control = new wxChoice(parent, id, wxDefaultPosition, wxDefaultSize);
int lastChoice = 0; // remember index of last choice
int nchoice = includeNoChange? LOG_OPTS_N_CHOICES : LOG_OPTS_N_CHOICES_NORMAL;
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/wxdialog.h ./gui/wxdialog.h
--- /home/volker/bochs/bochs/gui/wxdialog.h 2014-12-23 20:30:12.896090221 +0100
+++ ./gui/wxdialog.h 2016-12-27 20:34:28.518389938 +0100
@@ -2,7 +2,7 @@
// $Id: wxdialog.h 12576 2014-12-23 19:30:03Z vruppert $
////////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2002-2014 The Bochs Project
+// Copyright (C) 2002-2016 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
@@ -354,10 +354,10 @@
#define LOG_OPTS_PROMPT wxT("How should Bochs respond to each type of event?")
#define LOG_OPTS_TYPE_NAMES { wxT("Debug events"), wxT("Info events"), wxT("Error events"), wxT("Panic events") }
#define LOG_OPTS_N_TYPES 4
-#define LOG_OPTS_CHOICES { wxT("ignore"), wxT("log"), wxT("ask user"), wxT("end simulation"), wxT("no change") }
-#define LOG_OPTS_N_CHOICES_NORMAL 4
-#define LOG_OPTS_N_CHOICES 5 // number of choices, including "no change"
-#define LOG_OPTS_NO_CHANGE 4 // index of "no change"
+#define LOG_OPTS_CHOICES { wxT("ignore"), wxT("log"), wxT("warn user"), wxT("ask user"), wxT("end simulation"), wxT("no change") }
+#define LOG_OPTS_N_CHOICES_NORMAL 5
+#define LOG_OPTS_N_CHOICES 6 // number of choices, including "no change"
+#define LOG_OPTS_NO_CHANGE 5 // index of "no change"
#define LOG_OPTS_ADV wxT("For additional control over how each device responds to events, use the menu option \"Log ... By Device\".")
wxFlexGridSizer *gridSizer;
wxChoice *action[LOG_OPTS_N_TYPES];
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/wxmain.cc ./gui/wxmain.cc
--- /home/volker/bochs/bochs/gui/wxmain.cc 2016-12-26 17:12:57.470174541 +0100
+++ ./gui/wxmain.cc 2016-12-28 12:15:26.035961463 +0100
@@ -2,7 +2,7 @@
// $Id: wxmain.cc 13006 2016-12-26 16:12:54Z vruppert $
/////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2002-2014 The Bochs Project
+// Copyright (C) 2002-2016 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
@@ -1158,6 +1158,10 @@
#if !BX_DEBUGGER && !BX_GDBSTUB
dlg.EnableButton(dlg.DEBUG, FALSE);
#endif
+ if (be->u.logmsg.flag != BX_LOG_ASK_ASKDLG) {
+ dlg.EnableButton(dlg.DIE, FALSE);
+ dlg.EnableButton(dlg.DUMP, FALSE);
+ }
dlg.SetContext(wxString(be->u.logmsg.prefix, wxConvUTF8));
dlg.SetMessage(wxString(be->u.logmsg.msg, wxConvUTF8));
int n = dlg.ShowModal();
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/x.cc ./gui/x.cc
--- /home/volker/bochs/bochs/gui/x.cc 2016-12-27 17:26:59.622665119 +0100
+++ ./gui/x.cc 2016-12-28 12:03:10.963351647 +0100
@@ -2687,11 +2687,7 @@
} else {
size_x = 30 + maxlen * 6;
}
- if (lines < 3) {
- size_y = 90;
- } else {
- size_y = 60 + lines * 15;
- }
+ size_y = 70 + lines * 15;
x11_dialog_c *xdlg = new x11_dialog_c(name, size_x, size_y,
(mode == XDLG_SIMPLE) ? 1 : 2);
ypos = 34;
@@ -2729,11 +2725,21 @@
bx_param_string_c *sparam;
bx_param_enum_c *eparam;
bx_list_c *list;
+ char message[256];
switch (event->type)
{
case BX_SYNC_EVT_LOG_ASK:
- event->retcode = x11_ask_dialog(event);
+ if (event->u.logmsg.flag == BX_LOG_ASK_ASKDLG) {
+ event->retcode = x11_ask_dialog(event);
+ } else if (event->u.logmsg.flag == BX_LOG_ASK_MSGBOX_WARN) {
+ const char *title = SIM->get_log_level_name(event->u.logmsg.level);
+ sprintf(message, "Device: %s\n\nMessage: %s", event->u.logmsg.prefix,
+ event->u.logmsg.msg);
+ bx_param_bool_c bparam(NULL, "warn", title, message, 1);
+ x11_message_box(&bparam, XDLG_SIMPLE);
+ event->retcode = 0;
+ }
return event;
case BX_SYNC_EVT_ASK_PARAM:
param = event->u.param.param;
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/logio.cc ./logio.cc
--- /home/volker/bochs/bochs/logio.cc 2015-05-10 08:55:18.678940963 +0200
+++ ./logio.cc 2016-12-28 00:40:40.395736643 +0100
@@ -2,7 +2,7 @@
// $Id: logio.cc 12759 2015-05-10 06:55:16Z vruppert $
/////////////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2001-2014 The Bochs Project
+// Copyright (C) 2001-2016 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
@@ -50,11 +50,25 @@
else return "?";
}
+static const char *act_name[N_ACT] = { "ignore", "report", "warn", "ask", "fatal" };
+
const char* iofunctions::getaction(int i) const
{
- static const char *name[] = { "ignore", "report", "ask", "fatal" };
assert (i>=ACT_IGNORE && i<N_ACT);
- return name[i];
+ return act_name[i];
+}
+
+int iofunctions::isaction(const char *val) const
+{
+ int action = -1;
+
+ for (int i = 0; i < N_ACT; i++) {
+ if (!strcmp(val, act_name[i])) {
+ action = ACT_IGNORE + i;
+ break;
+ }
+ }
+ return action;
}
void iofunctions::flush(void)
@@ -414,6 +428,11 @@
logio->out(LOGLEV_ERROR, prefix, fmt, ap);
va_end(ap);
+ if (onoff[LOGLEV_ERROR] == ACT_WARN) {
+ va_start(ap, fmt);
+ warn(LOGLEV_ERROR, prefix, fmt, ap);
+ va_end(ap);
+ }
if (onoff[LOGLEV_ERROR] == ACT_ASK) {
va_start(ap, fmt);
ask(LOGLEV_ERROR, prefix, fmt, ap);
@@ -438,6 +457,11 @@
logio->out(LOGLEV_PANIC, prefix, fmt, ap);
va_end(ap);
+ if (onoff[LOGLEV_PANIC] == ACT_WARN) {
+ va_start(ap, fmt);
+ warn(LOGLEV_PANIC, prefix, fmt, ap);
+ va_end(ap);
+ }
if (onoff[LOGLEV_PANIC] == ACT_ASK) {
va_start(ap, fmt);
ask(LOGLEV_PANIC, prefix, fmt, ap);
@@ -465,6 +489,36 @@
// the actions ask() and fatal() are not supported here
}
+void logfunctions::warn(int level, const char *prefix, const char *fmt, va_list ap)
+{
+ // Guard against reentry on warn() function. The danger is that some
+ // function that's called within warn() could trigger another
+ // BX_ERROR that could call warn() again, leading to infinite
+ // recursion and infinite asks.
+ static char in_warn_already = 0;
+ char buf1[1024];
+ if (in_warn_already) {
+ fprintf(stderr, "logfunctions::warn() should not reenter!!\n");
+ return;
+ }
+ in_warn_already = 1;
+ vsnprintf(buf1, sizeof(buf1), fmt, ap);
+ // FIXME: facility set to 0 because it's unknown.
+
+ // update vga screen. This is useful because sometimes useful messages
+ // are printed on the screen just before a panic. It's also potentially
+ // dangerous if this function calls ask again... That's why I added
+ // the reentry check above.
+ SIM->refresh_vga();
+
+ // ensure the text screen is showing
+ SIM->set_display_mode(DISP_MODE_CONFIG);
+ SIM->log_warn(prefix, level, buf1);
+ // return to simulation mode
+ SIM->set_display_mode(DISP_MODE_SIM);
+ in_warn_already = 0;
+}
+
void logfunctions::ask(int level, const char *prefix, const char *fmt, va_list ap)
{
// Guard against reentry on ask() function. The danger is that some
2016-12-28 18:06:34 +03:00
action = SIM - > is_action_name ( actstr ) ;
if ( action < ACT_IGNORE ) {
2011-12-29 16:44:38 +04:00
PARSE_ERR ( ( " %s: %s directive malformed. " , context , params [ 0 ] ) ) ;
free ( param ) ;
return - 1 ;
}
2012-10-06 01:36:49 +04:00
// exclude some action / level combinations (see siminterface.h)
if ( BX_LOG_OPTS_EXCLUDE ( level , action ) ) {
PARSE_ERR ( ( " %s: event type '%s' does not support log action '%s'. " , context , params [ 0 ] , actstr ) ) ;
free ( param ) ;
return - 1 ;
}
2011-12-29 16:44:38 +04:00
if ( def_action ) {
SIM - > set_default_log_action ( level , action ) ;
} else {
sprintf ( pname , " general.logfn.%s " , params [ 0 ] ) ;
base = ( bx_list_c * ) SIM - > get_param ( pname ) ;
mparam = ( bx_param_num_c * ) base - > get_by_name ( module ) ;
if ( mparam ! = NULL ) {
mparam - > set ( action ) ;
} else {
2012-04-06 17:15:27 +04:00
mparam = new bx_param_num_c ( base , module , " " , " " , - 1 , BX_MAX_BIT32U , action ) ;
2012-02-21 19:56:18 +04:00
if ( mparam = = NULL ) {
PARSE_ERR ( ( " %s: %s: failed to add log module. " , context , params [ 0 ] ) ) ;
2011-12-29 16:44:38 +04:00
}
}
}
} else {
PARSE_ERR ( ( " %s: %s directive malformed. " , context , params [ 0 ] ) ) ;
free ( param ) ;
return - 1 ;
}
free ( param ) ;
2005-11-17 23:35:38 +03:00
}
return 0 ;
}
2009-05-03 23:21:38 +04:00
static int parse_debug_symbols ( const char * context , const char * * params , int num_params )
2008-03-30 18:32:14 +04:00
{
# if BX_DEBUGGER
Bit32u offset = 0 ;
2009-05-03 23:21:38 +04:00
const char * filename = 0 ;
2008-03-30 18:32:14 +04:00
while ( num_params > 0 )
{
if ( ! strncmp ( * params , " file= " , 5 ) ) {
filename = * params + 5 ;
}
else if ( ! strncmp ( * params , " offset= " , 7 ) ) {
char * end ;
offset = strtoul ( * params + 7 , & end , 0 ) ;
if ( * end )
PARSE_ERR ( ( " %s: debug_symbols: invalid parameter %s " , context , * params ) ) ;
}
else {
PARSE_ERR ( ( " %s: debug_symbols: invalid parameter %s " , context , * params ) ) ;
}
params + + ; num_params - - ;
}
if ( ! filename )
PARSE_ERR ( ( " %s: debug_symbols: missing file name " , context ) ) ;
if ( bx_dbg_symbol_command ( filename , 1 , offset ) < 0 )
PARSE_ERR ( ( " %s: debug_symbols: failed to load symbols from '%s' " , context , filename ) ) ;
# endif
return 0 ;
}
2010-03-01 21:53:53 +03:00
static int parse_param_bool ( const char * input , int len , const char * param )
{
2018-02-02 22:04:59 +03:00
if ( SIM - > get_param_bool ( param ) - > parse_param ( & input [ len ] ) = = 1 ) {
2010-03-01 21:53:53 +03:00
return 0 ;
}
return - 1 ;
}
2013-01-26 22:17:23 +04:00
int bx_parse_param_from_list ( const char * context , const char * input , bx_list_c * list )
2013-01-26 11:52:14 +04:00
{
char * propval , * property , * value ;
bx_param_c * param ;
int ret = 0 ;
if ( list = = NULL ) {
2013-01-26 22:17:23 +04:00
PARSE_WARN ( ( " %s: parameter list == NULL! " , context ) ) ;
return - 1 ;
2013-01-26 11:52:14 +04:00
}
propval = strdup ( input ) ;
property = strtok ( propval , " = " ) ;
value = strtok ( NULL , " " ) ;
2013-01-26 17:32:28 +04:00
if ( ! strcmp ( property , input ) ) {
2013-01-26 22:17:23 +04:00
PARSE_WARN ( ( " %s: incorrect parameter format " , context ) ) ;
2013-01-27 16:11:19 +04:00
free ( propval ) ;
2013-01-26 22:17:23 +04:00
return - 1 ;
2013-01-26 17:32:28 +04:00
}
2013-01-26 11:52:14 +04:00
param = list - > get_by_name ( property ) ;
if ( param ! = NULL ) {
2013-01-30 20:43:58 +04:00
if ( ( param - > get_options ( ) & param - > CI_ONLY ) > 0 ) {
2013-01-27 23:09:24 +04:00
PARSE_WARN ( ( " %s: ignoring hidden parameter '%s' " , context , property ) ) ;
free ( propval ) ;
2013-01-30 20:43:58 +04:00
return 0 ;
2013-01-27 23:09:24 +04:00
}
2016-05-03 22:15:09 +03:00
int res = param - > parse_param ( value ) ;
if ( res ! = - 1 ) {
if ( res = = 0 ) {
PARSE_WARN ( ( " %s: wrong value for parameter '%s' " , context , property ) ) ;
2013-01-26 22:17:23 +04:00
ret = - 1 ;
2016-05-03 22:15:09 +03:00
}
}
else {
PARSE_WARN ( ( " %s: parameter '%s': unknown type " , context , property ) ) ;
ret = - 1 ;
2013-01-26 11:52:14 +04:00
}
} else {
2013-01-26 22:17:23 +04:00
PARSE_WARN ( ( " %s: unknown parameter '%s' " , context , property ) ) ;
ret = - 1 ;
2013-01-26 11:52:14 +04:00
}
free ( propval ) ;
return ret ;
}
2021-02-15 19:09:02 +03:00
int bx_parse_usb_port_params ( const char * context , const char * param ,
int maxports , bx_list_c * base )
2011-06-10 01:02:51 +04:00
{
2021-02-15 19:09:02 +03:00
bool devopt = 0 ;
2011-06-10 01:02:51 +04:00
int idx , plen ;
2021-06-24 22:45:20 +03:00
char tmpname [ 20 ] , newopts [ BX_PATHNAME_LEN ] ;
2023-03-13 02:36:22 +03:00
char * devstr , * arg , * pEnd ;
2021-06-24 22:45:20 +03:00
const char * opt = NULL , * origopts ;
2021-06-30 18:50:49 +03:00
static bool compat_mode = false ;
2011-06-10 01:02:51 +04:00
2021-02-15 19:09:02 +03:00
if ( ! strncmp ( param , " port " , 4 ) ) {
devopt = 1 ;
2011-06-10 01:02:51 +04:00
plen = 4 ;
} else {
2021-02-15 19:09:02 +03:00
devopt = 0 ;
2011-06-10 01:02:51 +04:00
plen = 7 ;
}
2023-03-13 02:36:22 +03:00
// this gets the long int number value after the string: 'port'.
// Ex: 'port15=' will produce 15 for idx. We allow up to 30 for now.
idx = ( int ) strtol ( & param [ plen ] , & pEnd , 10 ) ;
if ( ( idx < 1 ) | | ( idx > 30 ) | | ( pEnd [ 0 ] ! = ' = ' ) ) {
2011-06-10 01:02:51 +04:00
PARSE_ERR ( ( " %s: usb_%s: portX / optionsX parameter malformed. " , context , base - > get_name ( ) ) ) ;
return - 1 ;
}
if ( idx > maxports ) {
PARSE_ERR ( ( " %s: usb_%s: port number out of range. " , context , base - > get_name ( ) ) ) ;
return - 1 ;
}
2021-02-15 19:09:02 +03:00
sprintf ( tmpname , " port%d.%s " , idx , devopt ? " device " : " options " ) ;
if ( devopt ) {
2021-06-30 18:50:49 +03:00
compat_mode = false ;
2023-09-09 07:46:43 +03:00
// if we already have found this port's declaration in the bochsrc.txt file, give error
// for example:
// usb_ohci: port1=mouse, options1="speed:low, model:m228"
// usb_ohci: port1=keyboard, options1="speed:low"
// this catches the second line, giving an error...
if ( SIM - > get_param_enum ( tmpname , base ) - > get ( ) > 0 ) {
BX_PANIC ( ( " %s: Already declared port%d type. Please choose another available port number. " , context , idx ) ) ;
}
2021-02-15 19:09:02 +03:00
if ( ! SIM - > get_param_enum ( tmpname , base ) - > set_by_name ( & param [ plen + 2 ] ) ) {
// backward compatibility code
devstr = strdup ( & param [ plen + 2 ] ) ;
arg = strtok ( devstr , " : " ) ;
arg = strtok ( NULL , " \n " ) ;
SIM - > get_param_enum ( tmpname , base ) - > set_by_name ( devstr ) ;
if ( arg ! = NULL ) {
if ( ! strcmp ( devstr , " disk " ) | | ! strcmp ( devstr , " cdrom " ) | |
! strcmp ( devstr , " floppy " ) ) {
opt = " path " ;
} else if ( ! strcmp ( devstr , " hub " ) ) {
opt = " ports " ;
} else if ( ! strcmp ( devstr , " printer " ) ) {
opt = " file " ;
}
if ( opt ! = NULL ) {
2021-06-30 18:50:49 +03:00
sprintf ( tmpname , " port%d.options " , idx ) ;
origopts = SIM - > get_param_string ( tmpname , base ) - > getptr ( ) ;
2021-06-24 22:45:20 +03:00
if ( strlen ( origopts ) > 0 ) {
sprintf ( newopts , " %s:%s, %s " , opt , arg , origopts ) ;
} else {
sprintf ( newopts , " %s:%s " , opt , arg ) ;
}
2021-06-30 18:50:49 +03:00
SIM - > get_param_string ( tmpname , base ) - > set ( newopts ) ;
compat_mode = true ;
2021-02-15 19:09:02 +03:00
}
}
free ( devstr ) ;
}
} else {
2023-09-09 07:46:43 +03:00
// if we already have found this options#= declaration in the bochsrc.txt file, give warning.
// (it is legal to do this, as in:
// usb_ohci: port2=disk
// usb_ohci: options2="speed:full"
// usb_ohci: options2="path:hdd.img"
// however, this catches something like:
// usb_ohci: port1=tablet, options1="speed:low"
// usb_ohci: port2=disk, options1="speed:full, path:hdd.img"
// where the user copy/pasted something and forgot to adjust the options# in the second line)
if ( ! SIM - > get_param_string ( tmpname , base ) - > isempty ( ) ) {
BX_INFO ( ( " %s: Already declared options%d parameter. Was this intended? " , context , idx ) ) ;
}
2021-06-30 18:50:49 +03:00
if ( compat_mode ) {
origopts = SIM - > get_param_string ( tmpname , base ) - > getptr ( ) ;
sprintf ( newopts , " %s, %s " , origopts , & param [ plen + 2 ] ) ;
compat_mode = false ;
} else {
strcpy ( newopts , & param [ plen + 2 ] ) ;
}
SIM - > get_param_string ( tmpname , base ) - > set ( newopts ) ;
2021-02-15 19:09:02 +03:00
}
2011-06-10 01:02:51 +04:00
return 0 ;
}
2011-12-25 12:52:34 +04:00
int bx_parse_nic_params ( const char * context , const char * param , bx_list_c * base )
2011-12-23 18:40:43 +04:00
{
int valid = 0 ;
int n ;
2018-02-05 01:20:46 +03:00
bx_param_bytestring_c * bsp ;
2011-12-23 18:40:43 +04:00
if ( ! strncmp ( param , " enabled= " , 8 ) ) {
2018-02-02 22:04:59 +03:00
SIM - > get_param_bool ( " enabled " , base ) - > parse_param ( & param [ 8 ] ) ;
n = SIM - > get_param_bool ( " enabled " , base ) - > get ( ) ;
2020-03-03 01:04:10 +03:00
valid & = 0x3f ;
2013-01-26 17:32:28 +04:00
if ( n = = 0 ) valid | = 0x80 ;
2020-03-03 01:04:10 +03:00
else valid | = 0x40 ;
2011-12-23 18:40:43 +04:00
} else if ( ! strncmp ( param , " mac= " , 4 ) ) {
2018-02-05 01:20:46 +03:00
bsp = ( bx_param_bytestring_c * ) SIM - > get_param_string ( " mac " , base ) ;
if ( bsp - > parse_param ( & param [ 4 ] ) = = 0 ) {
2011-12-23 18:40:43 +04:00
PARSE_ERR ( ( " %s: '%s' mac address malformed. " , context , base - > get_name ( ) ) ) ;
2018-02-05 01:20:46 +03:00
} else {
valid | = 0x04 ;
2011-12-23 18:40:43 +04:00
}
} else if ( ! strncmp ( param , " ethmod= " , 7 ) ) {
if ( ! SIM - > get_param_enum ( " ethmod " , base ) - > set_by_name ( & param [ 7 ] ) )
PARSE_ERR ( ( " %s: ethernet module '%s' not available " , context , & param [ 7 ] ) ) ;
2013-01-26 22:17:23 +04:00
} else if ( bx_parse_param_from_list ( context , param , base ) < 0 ) {
2013-01-26 17:32:28 +04:00
PARSE_WARN ( ( " %s: expected parameter '%s' for '%s' ignored. " , context , param , base - > get_name ( ) ) ) ;
2011-12-23 18:40:43 +04:00
return - 1 ;
}
return valid ;
}
2020-12-03 23:30:10 +03:00
int bx_split_option_list ( const char * msg , const char * rawopt , char * * argv , int max_argv )
{
char * ptr , * ptr2 , * tmpstr ;
int argc = 0 , i ;
char * options = new char [ strlen ( rawopt ) + 1 ] ;
strcpy ( options , rawopt ) ;
ptr = strtok ( options , " , " ) ;
while ( ptr & & strcmp ( ptr , " none " ) ) {
if ( argc < max_argv ) {
tmpstr = new char [ strlen ( ptr ) + 1 ] ;
strcpy ( tmpstr , ptr ) ;
ptr2 = tmpstr ;
while ( isspace ( * ptr2 ) ) ptr2 + + ;
2021-07-12 22:05:25 +03:00
i = ( int ) strlen ( ptr2 ) - 1 ;
2020-12-03 23:30:10 +03:00
while ( ( i > = 0 ) & & isspace ( ptr2 [ i ] ) ) {
ptr2 [ i ] = 0 ;
i - - ;
}
if ( strlen ( ptr2 ) > 0 ) {
argv [ argc + + ] = strdup ( ptr2 ) ;
}
delete [ ] tmpstr ;
} else {
BX_ERROR ( ( " %s: too many parameters, max is %d " , msg , max_argv ) ) ;
}
ptr = strtok ( NULL , " , " ) ;
}
delete [ ] options ;
return argc ;
}
2021-01-30 18:16:00 +03:00
bool is_deprecated_option ( const char * oldparam , const char * * newparam )
2013-08-10 11:40:38 +04:00
{
2017-03-21 23:12:07 +03:00
if ( ( ! strcmp ( oldparam , " keyboard_serial_delay " ) ) | |
2014-07-08 13:24:35 +04:00
( ! strcmp ( oldparam , " keyboard_paste_delay " ) ) | |
( ! strcmp ( oldparam , " keyboard_type " ) ) | |
( ! strcmp ( oldparam , " keyboard_mapping " ) ) | |
( ! strcmp ( oldparam , " keyboardmapping " ) ) ) {
2017-03-21 23:12:07 +03:00
// replaced v2.6 / removed v2.6.7
* newparam = " keyboard " ;
return 1 ;
} else if ( ! strcmp ( oldparam , " user_shortcut " ) ) {
// replaced v2.6.1 / removed v2.6.9
2014-07-08 13:24:35 +04:00
* newparam = " keyboard " ;
return 1 ;
2013-08-10 11:40:38 +04:00
# if BX_SUPPORT_PCIPNIC
} else if ( ! strcmp ( oldparam , " pnic " ) ) {
2014-05-31 21:24:20 +04:00
// replaced v2.6 / removed v2.6.5
2013-08-10 11:40:38 +04:00
* newparam = " pcipnic " ;
return 1 ;
2021-01-24 13:16:22 +03:00
# endif
# if BX_PLUGINS
} else if ( ! strcmp ( oldparam , " user_plugin " ) ) {
// replaced / removed after v2.6.11
* newparam = " plugin_ctrl " ;
return 1 ;
2013-08-10 11:40:38 +04:00
# endif
}
return 0 ;
}
2008-03-30 18:32:14 +04:00
static int parse_line_formatted ( const char * context , int num_params , char * params [ ] )
2004-06-05 02:06:55 +04:00
{
2021-03-28 11:40:28 +03:00
int i , slot , t , dt ;
2006-02-26 22:11:20 +03:00
bx_list_c * base ;
2013-08-10 11:40:38 +04:00
const char * newparam ;
2021-03-29 14:17:03 +03:00
char * value ;
2004-06-05 02:06:55 +04:00
if ( num_params < 1 ) return 0 ;
if ( num_params < 2 ) {
PARSE_ERR ( ( " %s: a bochsrc option needs at least one parameter " , context ) ) ;
}
if ( ! strcmp ( params [ 0 ] , " #include " ) ) {
if ( num_params ! = 2 ) {
PARSE_ERR ( ( " %s: ignoring malformed #include directive. " , context ) ) ;
2006-01-23 21:39:10 +03:00
}
2004-06-05 02:06:55 +04:00
if ( ! strcmp ( params [ 1 ] , context ) ) {
PARSE_ERR ( ( " %s: cannot include this file again. " , context ) ) ;
2006-01-23 21:39:10 +03:00
}
2012-09-16 12:55:59 +04:00
if ( bochsrc_include_level > 2 ) {
PARSE_ERR ( ( " %s: maximum include level exceeded (limit = 2). " , context ) ) ;
2004-06-05 02:06:55 +04:00
}
2006-01-23 21:39:10 +03:00
bx_read_configuration ( params [ 1 ] ) ;
2013-07-20 20:13:07 +04:00
} else if ( ! strcmp ( params [ 0 ] , " plugin_ctrl " ) ) {
char * param , * pname , * val ;
for ( i = 1 ; i < num_params ; i + + ) {
param = strdup ( params [ i ] ) ;
pname = strtok ( param , " = " ) ;
val = strtok ( NULL , " " ) ;
if ( val ! = NULL ) {
2018-01-26 23:02:28 +03:00
if ( ! strcmp ( val , " 0 " ) | | ! stricmp ( val , " false " ) ) {
SIM - > opt_plugin_ctrl ( pname , 0 ) ;
} else if ( ! strcmp ( val , " 1 " ) | | ! stricmp ( val , " true " ) ) {
SIM - > opt_plugin_ctrl ( pname , 1 ) ;
2013-07-20 20:13:07 +04:00
} else {
PARSE_ERR ( ( " %s: plugin_ctrl directive malformed " , context ) ) ;
}
} else {
PARSE_ERR ( ( " %s: plugin_ctrl directive malformed " , context ) ) ;
}
free ( param ) ;
}
} else if ( ! strcmp ( params [ 0 ] , " config_interface " ) ) {
if ( num_params ! = 2 ) {
PARSE_ERR ( ( " %s: config_interface directive: wrong # args. " , context ) ) ;
}
if ( ! SIM - > get_param_enum ( BXPN_SEL_CONFIG_INTERFACE ) - > set_by_name ( params [ 1 ] ) )
PARSE_ERR ( ( " %s: config_interface '%s' not available " , context , params [ 1 ] ) ) ;
} else if ( ! strcmp ( params [ 0 ] , " display_library " ) ) {
if ( ( num_params < 2 ) | | ( num_params > 3 ) ) {
PARSE_ERR ( ( " %s: display_library directive: wrong # args. " , context ) ) ;
}
2020-11-29 16:37:07 +03:00
if ( SIM - > get_param_enum ( BXPN_SEL_DISPLAY_LIBRARY ) - > set_by_name ( params [ 1 ] ) ) {
i = 2 ;
} else {
i = 1 ;
}
if ( ( num_params = = 3 ) | | ( i = = 1 ) ) {
if ( ! strncmp ( params [ i ] , " options= " , 8 ) ) {
SIM - > get_param_string ( BXPN_DISPLAYLIB_OPTIONS ) - > set ( & params [ i ] [ 8 ] ) ;
} else if ( i = = 1 ) {
PARSE_ERR ( ( " %s: display library '%s' not available " , context , params [ 1 ] ) ) ;
2014-05-25 21:47:02 +04:00
} else {
PARSE_ERR ( ( " %s: display_library directive malformed " , context ) ) ;
2013-07-20 20:13:07 +04:00
}
}
} else if ( ( ! strcmp ( params [ 0 ] , " floppya " ) ) | |
2009-03-24 14:20:17 +03:00
( ! strcmp ( params [ 0 ] , " floppyb " ) ) ) {
if ( ! strcmp ( params [ 0 ] , " floppya " ) ) {
base = ( bx_list_c * ) SIM - > get_param ( BXPN_FLOPPYA ) ;
} else {
base = ( bx_list_c * ) SIM - > get_param ( BXPN_FLOPPYB ) ;
2004-06-05 02:06:55 +04:00
}
for ( i = 1 ; i < num_params ; i + + ) {
2009-03-24 14:20:17 +03:00
if ( ! strncmp ( params [ i ] , " type= " , 5 ) ) {
2021-03-29 14:17:03 +03:00
value = params [ i ] + 5 ;
2021-03-28 11:40:28 +03:00
dt = - 1 ;
2021-03-29 14:17:03 +03:00
if ( ! strcmp ( value , " 2_88 " ) ) {
2021-03-28 11:40:28 +03:00
dt = BX_FDD_350ED ;
2009-03-24 14:20:17 +03:00
}
2021-03-29 14:17:03 +03:00
else if ( ! strcmp ( value , " 1_44 " ) ) {
2021-03-28 11:40:28 +03:00
dt = BX_FDD_350HD ;
2009-03-24 14:20:17 +03:00
}
2021-03-29 14:17:03 +03:00
else if ( ! strcmp ( value , " 1_2 " ) ) {
2021-03-28 11:40:28 +03:00
dt = BX_FDD_525HD ;
2009-03-24 14:20:17 +03:00
}
2021-03-29 14:17:03 +03:00
else if ( ! strcmp ( value , " 720k " ) ) {
2021-03-28 11:40:28 +03:00
dt = BX_FDD_350DD ;
2009-03-24 14:20:17 +03:00
}
2021-03-29 14:17:03 +03:00
else if ( ! strcmp ( value , " 360k " ) ) {
2021-03-28 11:40:28 +03:00
dt = BX_FDD_525DD ;
2009-03-24 14:20:17 +03:00
}
2021-03-29 14:17:03 +03:00
else if ( ! strcmp ( value , " none " ) ) {
dt = BX_FDD_NONE ;
}
2009-03-24 14:20:17 +03:00
else {
2021-03-29 14:17:03 +03:00
PARSE_ERR ( ( " %s: %s: unknown type '%s'. " , context , params [ 0 ] , value ) ) ;
2009-03-24 14:20:17 +03:00
}
2021-03-29 14:17:03 +03:00
if ( dt > = 0 ) {
2021-03-28 11:40:28 +03:00
SIM - > get_param_enum ( " devtype " , base ) - > set ( dt ) ;
}
2009-03-24 14:20:17 +03:00
}
2021-03-29 14:17:03 +03:00
else if ( ! strcmp ( params [ i ] , " status=inserted " ) ) {
SIM - > get_param_enum ( " status " , base ) - > set ( BX_INSERTED ) ;
2006-01-23 21:39:10 +03:00
}
2021-03-29 14:17:03 +03:00
else if ( ! strcmp ( params [ i ] , " status=ejected " ) ) {
SIM - > get_param_enum ( " status " , base ) - > set ( BX_EJECTED ) ;
2006-01-23 21:39:10 +03:00
}
2021-03-29 14:17:03 +03:00
else if ( ! strncmp ( params [ i ] , " write_protected= " , 16 ) ) {
SIM - > get_param_bool ( " readonly " , base ) - > set ( atol ( & params [ i ] [ 16 ] ) ) ;
2006-01-23 21:39:10 +03:00
}
2004-09-07 22:02:29 +04:00
else if ( ! strncmp ( params [ i ] , " image= " , 6 ) ) {
/* "image=" means we should get floppy type from image */
2021-03-29 14:17:03 +03:00
value = params [ i ] + 6 ;
t = get_floppy_type_from_image ( value ) ;
dt = get_floppy_devtype_from_type ( t ) ;
2021-03-28 11:40:28 +03:00
if ( t ! = BX_FLOPPY_UNKNOWN ) {
SIM - > get_param_enum ( " devtype " , base ) - > set ( dt ) ;
2021-03-29 14:17:03 +03:00
SIM - > get_param_string ( " path " , base ) - > set ( value ) ;
2009-03-24 14:20:17 +03:00
SIM - > get_param_enum ( " type " , base ) - > set ( t ) ;
2021-03-28 11:40:28 +03:00
} else
2009-03-24 14:20:17 +03:00
PARSE_ERR ( ( " %s: %s image size doesn't match one of the supported types. " ,
context , params [ 0 ] ) ) ;
2006-01-23 21:39:10 +03:00
}
2004-06-05 02:06:55 +04:00
else {
2021-03-29 14:17:03 +03:00
if ( ! strncmp ( params [ i ] , " 2_88= " , 5 ) ) {
t = BX_FLOPPY_2_88 ;
value = params [ i ] + 5 ;
}
else if ( ! strncmp ( params [ i ] , " 1_44= " , 5 ) ) {
t = BX_FLOPPY_1_44 ;
value = params [ i ] + 5 ;
}
else if ( ! strncmp ( params [ i ] , " 1_2= " , 4 ) ) {
t = BX_FLOPPY_1_2 ;
value = params [ i ] + 4 ;
}
else if ( ! strncmp ( params [ i ] , " 720k= " , 5 ) ) {
t = BX_FLOPPY_720K ;
value = params [ i ] + 5 ;
}
else if ( ! strncmp ( params [ i ] , " 360k= " , 5 ) ) {
t = BX_FLOPPY_360K ;
value = params [ i ] + 5 ;
}
// use CMOS reserved types?
else if ( ! strncmp ( params [ i ] , " 160k= " , 5 ) ) {
t = BX_FLOPPY_160K ;
value = params [ i ] + 5 ;
}
else if ( ! strncmp ( params [ i ] , " 180k= " , 5 ) ) {
t = BX_FLOPPY_180K ;
value = params [ i ] + 5 ;
}
else if ( ! strncmp ( params [ i ] , " 320k= " , 5 ) ) {
t = BX_FLOPPY_320K ;
value = params [ i ] + 5 ;
}
else {
t = - 1 ;
PARSE_ERR ( ( " %s: %s attribute '%s' not understood. " , context , params [ 0 ] ,
params [ i ] ) ) ;
}
if ( t > 0 ) {
dt = get_floppy_devtype_from_type ( t ) ;
SIM - > get_param_enum ( " devtype " , base ) - > set ( dt ) ;
SIM - > get_param_string ( " path " , base ) - > set ( value ) ;
SIM - > get_param_enum ( " type " , base ) - > set ( t ) ;
}
2004-06-05 02:06:55 +04:00
}
}
2013-07-20 20:13:07 +04:00
} else if ( ( ! strncmp ( params [ 0 ] , " ata " , 3 ) ) & & ( strlen ( params [ 0 ] ) = = 4 ) ) {
2006-02-26 22:11:20 +03:00
char tmpname [ 80 ] ;
2004-06-05 02:06:55 +04:00
Bit8u channel = params [ 0 ] [ 3 ] ;
if ( ( channel < ' 0 ' ) | | ( channel > ' 9 ' ) ) {
PARSE_ERR ( ( " %s: ataX directive malformed. " , context ) ) ;
2006-01-23 21:39:10 +03:00
}
2004-06-05 02:06:55 +04:00
channel - = ' 0 ' ;
if ( channel > = BX_MAX_ATA_CHANNEL ) {
PARSE_ERR ( ( " %s: ataX directive malformed. " , context ) ) ;
2006-01-23 21:39:10 +03:00
}
2004-06-05 02:06:55 +04:00
if ( ( num_params < 2 ) | | ( num_params > 5 ) ) {
PARSE_ERR ( ( " %s: ataX directive malformed. " , context ) ) ;
2006-01-23 21:39:10 +03:00
}
2006-02-26 22:11:20 +03:00
sprintf ( tmpname , " ata.%d.resources " , channel ) ;
2013-01-26 17:32:28 +04:00
for ( i = 1 ; i < num_params ; i + + ) {
2013-01-26 22:17:23 +04:00
if ( bx_parse_param_from_list ( context , params [ i ] , ( bx_list_c * ) SIM - > get_param ( tmpname ) ) < 0 ) {
2004-06-05 02:06:55 +04:00
PARSE_ERR ( ( " %s: ataX directive malformed. " , context ) ) ;
2006-01-23 21:39:10 +03:00
}
2004-06-05 02:06:55 +04:00
}
2013-07-20 20:13:07 +04:00
} else if ( ( ! strncmp ( params [ 0 ] , " ata " , 3 ) ) & & ( strlen ( params [ 0 ] ) > 4 ) ) {
// ataX-master, ataX-slave
2006-03-02 00:24:20 +03:00
Bit8u channel = params [ 0 ] [ 3 ] ;
2013-01-26 17:32:28 +04:00
int type = - 1 ;
2005-08-06 22:29:36 +04:00
Bit32u cylinders = 0 , heads = 0 , sectors = 0 ;
2006-02-26 22:11:20 +03:00
char tmpname [ 80 ] ;
2004-06-05 02:06:55 +04:00
if ( ( channel < ' 0 ' ) | | ( channel > ' 9 ' ) ) {
PARSE_ERR ( ( " %s: ataX-master/slave directive malformed. " , context ) ) ;
2006-01-23 21:39:10 +03:00
}
2004-06-05 02:06:55 +04:00
channel - = ' 0 ' ;
if ( channel > = BX_MAX_ATA_CHANNEL ) {
PARSE_ERR ( ( " %s: ataX-master/slave directive malformed. " , context ) ) ;
2006-01-23 21:39:10 +03:00
}
2004-06-05 02:06:55 +04:00
if ( ( strcmp ( & params [ 0 ] [ 4 ] , " -slave " ) ) & &
( strcmp ( & params [ 0 ] [ 4 ] , " -master " ) ) ) {
PARSE_ERR ( ( " %s: ataX-master/slave directive malformed. " , context ) ) ;
2006-01-23 21:39:10 +03:00
}
2004-06-05 02:06:55 +04:00
2006-02-26 22:11:20 +03:00
sprintf ( tmpname , " ata.%d.%s " , channel , & params [ 0 ] [ 5 ] ) ;
base = ( bx_list_c * ) SIM - > get_param ( tmpname ) ;
2004-06-05 02:06:55 +04:00
for ( i = 1 ; i < num_params ; i + + ) {
2006-03-02 00:24:20 +03:00
if ( ! strncmp ( params [ i ] , " type= " , 5 ) ) {
type = SIM - > get_param_enum ( " type " , base ) - > find_by_name ( & params [ i ] [ 5 ] ) ;
if ( type < 0 ) {
PARSE_ERR ( ( " %s: ataX-master/slave: unknown type '%s' " , context , & params [ i ] [ 5 ] ) ) ;
2013-01-26 17:32:28 +04:00
} else {
SIM - > get_param_enum ( " type " , base ) - > set ( type ) ;
2006-03-02 00:24:20 +03:00
}
2005-08-06 22:29:36 +04:00
} else if ( ! strncmp ( params [ i ] , " cylinders= " , 10 ) ) {
cylinders = atol ( & params [ i ] [ 10 ] ) ;
} else if ( ! strncmp ( params [ i ] , " heads= " , 6 ) ) {
heads = atol ( & params [ i ] [ 6 ] ) ;
} else if ( ! strncmp ( params [ i ] , " spt= " , 4 ) ) {
sectors = atol ( & params [ i ] [ 4 ] ) ;
} else if ( ! strcmp ( params [ i ] , " translation=echs " ) ) { // synonym of large
2006-02-26 22:11:20 +03:00
SIM - > get_param_enum ( " translation " , base ) - > set ( BX_ATA_TRANSLATION_LARGE ) ;
2013-01-26 22:17:23 +04:00
} else if ( bx_parse_param_from_list ( context , params [ i ] , base ) < 0 ) {
2004-06-05 02:06:55 +04:00
PARSE_ERR ( ( " %s: ataX-master/slave directive malformed. " , context ) ) ;
}
2005-08-06 22:29:36 +04:00
}
2004-06-05 02:06:55 +04:00
2013-01-27 16:11:19 +04:00
// Check for geometry autodetection mode
2013-01-26 17:32:28 +04:00
if ( type = = BX_ATA_DEVICE_DISK ) {
if ( strlen ( SIM - > get_param_string ( " path " , base ) - > getptr ( ) ) > 0 ) {
SIM - > get_param_num ( " cylinders " , base ) - > set ( cylinders ) ;
if ( ( cylinders = = 0 ) & & ( heads = = 0 ) & & ( sectors = = 0 ) ) {
PARSE_WARN ( ( " %s: ataX-master/slave CHS set to 0/0/0 - autodetection enabled " , context ) ) ;
// using heads = 16 and spt = 63 for autodetection (bximage defaults)
SIM - > get_param_num ( " heads " , base ) - > set ( 16 ) ;
SIM - > get_param_num ( " spt " , base ) - > set ( 63 ) ;
2009-03-24 14:20:17 +03:00
} else {
2013-01-26 17:32:28 +04:00
SIM - > get_param_num ( " heads " , base ) - > set ( heads ) ;
SIM - > get_param_num ( " spt " , base ) - > set ( sectors ) ;
2009-03-24 14:20:17 +03:00
}
2013-01-26 17:32:28 +04:00
} else {
SIM - > get_param_enum ( " type " , base ) - > set ( BX_ATA_DEVICE_NONE ) ;
2009-03-24 14:20:17 +03:00
}
2005-08-06 22:29:36 +04:00
}
} else if ( ! strcmp ( params [ 0 ] , " boot " ) ) {
2006-02-24 01:48:57 +03:00
char tmppath [ 80 ] ;
2004-10-16 19:44:00 +04:00
if ( num_params < 2 ) {
PARSE_ERR ( ( " %s: boot directive malformed. " , context ) ) ;
2005-08-06 22:29:36 +04:00
}
2004-10-16 19:44:00 +04:00
for ( i = 1 ; i < num_params ; i + + ) {
2006-02-24 01:48:57 +03:00
sprintf ( tmppath , " boot_params.boot_drive%d " , i ) ;
2004-10-16 19:44:00 +04:00
if ( ! strcmp ( params [ i ] , " none " ) ) {
2006-02-24 01:48:57 +03:00
SIM - > get_param_enum ( tmppath ) - > set ( BX_BOOT_NONE ) ;
2004-10-16 19:44:00 +04:00
} else if ( ! strcmp ( params [ i ] , " a " ) ) {
2006-02-24 01:48:57 +03:00
SIM - > get_param_enum ( tmppath ) - > set ( BX_BOOT_FLOPPYA ) ;
2004-10-16 19:44:00 +04:00
} else if ( ! strcmp ( params [ i ] , " floppy " ) ) {
2006-02-24 01:48:57 +03:00
SIM - > get_param_enum ( tmppath ) - > set ( BX_BOOT_FLOPPYA ) ;
2004-10-16 19:44:00 +04:00
} else if ( ! strcmp ( params [ i ] , " c " ) ) {
2006-02-24 01:48:57 +03:00
SIM - > get_param_enum ( tmppath ) - > set ( BX_BOOT_DISKC ) ;
2004-10-16 19:44:00 +04:00
} else if ( ! strcmp ( params [ i ] , " disk " ) ) {
2006-02-24 01:48:57 +03:00
SIM - > get_param_enum ( tmppath ) - > set ( BX_BOOT_DISKC ) ;
2004-10-16 19:44:00 +04:00
} else if ( ! strcmp ( params [ i ] , " cdrom " ) ) {
2006-02-24 01:48:57 +03:00
SIM - > get_param_enum ( tmppath ) - > set ( BX_BOOT_CDROM ) ;
2008-02-01 23:38:50 +03:00
} else if ( ! strcmp ( params [ i ] , " network " ) ) {
SIM - > get_param_enum ( tmppath ) - > set ( BX_BOOT_NETWORK ) ;
2004-10-16 19:44:00 +04:00
} else {
2008-02-01 23:38:50 +03:00
PARSE_ERR ( ( " %s: boot directive with unknown boot drive '%s'. use 'floppy', 'disk', 'cdrom' or 'network'. " , context , params [ i ] ) ) ;
2004-10-16 19:44:00 +04:00
}
2005-08-06 22:29:36 +04:00
}
2006-02-24 01:48:57 +03:00
if ( SIM - > get_param_enum ( BXPN_BOOTDRIVE1 ) - > get ( ) = = BX_BOOT_NONE ) {
2004-10-16 19:44:00 +04:00
PARSE_ERR ( ( " %s: first boot drive must be one of 'floppy', 'disk' or 'cdrom'. " , context ) ) ;
2005-08-06 22:29:36 +04:00
}
2006-02-24 01:48:57 +03:00
if ( ( SIM - > get_param_enum ( BXPN_BOOTDRIVE1 ) - > get ( ) = = SIM - > get_param_enum ( BXPN_BOOTDRIVE2 ) - > get ( ) ) | |
( SIM - > get_param_enum ( BXPN_BOOTDRIVE1 ) - > get ( ) = = SIM - > get_param_enum ( BXPN_BOOTDRIVE3 ) - > get ( ) ) | |
( ( SIM - > get_param_enum ( BXPN_BOOTDRIVE3 ) - > get ( ) ! = BX_BOOT_NONE ) & &
( SIM - > get_param_enum ( BXPN_BOOTDRIVE2 ) - > get ( ) = = SIM - > get_param_enum ( BXPN_BOOTDRIVE3 ) - > get ( ) ) ) ) {
2004-10-16 19:44:00 +04:00
PARSE_ERR ( ( " %s: a boot drive appears twice in boot sequence. " , context ) ) ;
2004-06-05 02:06:55 +04:00
}
2005-08-06 22:29:36 +04:00
} else if ( ! strcmp ( params [ 0 ] , " floppy_bootsig_check " ) ) {
2004-06-05 02:06:55 +04:00
if ( num_params ! = 2 ) {
PARSE_ERR ( ( " %s: floppy_bootsig_check directive malformed. " , context ) ) ;
2005-08-07 19:50:07 +04:00
}
2004-06-05 02:06:55 +04:00
if ( strncmp ( params [ 1 ] , " disabled= " , 9 ) ) {
PARSE_ERR ( ( " %s: floppy_bootsig_check directive malformed. " , context ) ) ;
2005-08-07 19:50:07 +04:00
}
2010-03-01 21:53:53 +03:00
if ( parse_param_bool ( params [ 1 ] , 9 , BXPN_FLOPPYSIGCHECK ) < 0 ) {
2004-06-05 02:06:55 +04:00
PARSE_ERR ( ( " %s: floppy_bootsig_check directive malformed. " , context ) ) ;
}
2005-08-07 19:50:07 +04:00
} else if ( ! strcmp ( params [ 0 ] , " log " ) ) {
2004-06-05 02:06:55 +04:00
if ( num_params ! = 2 ) {
PARSE_ERR ( ( " %s: log directive has wrong # args. " , context ) ) ;
}
2006-03-05 13:24:29 +03:00
SIM - > get_param_string ( BXPN_LOG_FILENAME ) - > set ( params [ 1 ] ) ;
2005-08-07 19:50:07 +04:00
} else if ( ! strcmp ( params [ 0 ] , " logprefix " ) ) {
2004-06-05 02:06:55 +04:00
if ( num_params ! = 2 ) {
PARSE_ERR ( ( " %s: logprefix directive has wrong # args. " , context ) ) ;
}
2006-03-05 13:24:29 +03:00
SIM - > get_param_string ( BXPN_LOG_PREFIX ) - > set ( params [ 1 ] ) ;
2005-08-07 19:50:07 +04:00
} else if ( ! strcmp ( params [ 0 ] , " debugger_log " ) ) {
2004-06-05 02:06:55 +04:00
if ( num_params ! = 2 ) {
PARSE_ERR ( ( " %s: debugger_log directive has wrong # args. " , context ) ) ;
}
2006-03-05 13:24:29 +03:00
SIM - > get_param_string ( BXPN_DEBUGGER_LOG_FILENAME ) - > set ( params [ 1 ] ) ;
2005-08-07 19:50:07 +04:00
} else if ( ! strcmp ( params [ 0 ] , " panic " ) ) {
2011-12-29 16:44:38 +04:00
if ( num_params < 2 ) {
2004-06-05 02:06:55 +04:00
PARSE_ERR ( ( " %s: panic directive malformed. " , context ) ) ;
2005-08-07 19:50:07 +04:00
}
2011-12-29 16:44:38 +04:00
if ( parse_log_options ( context , num_params , params ) < 0 ) {
2005-11-17 23:35:38 +03:00
return - 1 ;
2004-06-05 02:06:55 +04:00
}
2005-08-07 19:50:07 +04:00
} else if ( ! strcmp ( params [ 0 ] , " error " ) ) {
2011-12-29 16:44:38 +04:00
if ( num_params < 2 ) {
2004-06-05 02:06:55 +04:00
PARSE_ERR ( ( " %s: error directive malformed. " , context ) ) ;
2005-08-07 19:50:07 +04:00
}
2011-12-29 16:44:38 +04:00
if ( parse_log_options ( context , num_params , params ) < 0 ) {
2005-11-17 23:35:38 +03:00
return - 1 ;
2004-06-05 02:06:55 +04:00
}
2005-08-07 19:50:07 +04:00
} else if ( ! strcmp ( params [ 0 ] , " info " ) ) {
2011-12-29 16:44:38 +04:00
if ( num_params < 2 ) {
2004-06-05 02:06:55 +04:00
PARSE_ERR ( ( " %s: info directive malformed. " , context ) ) ;
2005-08-07 19:50:07 +04:00
}
2011-12-29 16:44:38 +04:00
if ( parse_log_options ( context , num_params , params ) < 0 ) {
2005-11-17 23:35:38 +03:00
return - 1 ;
2004-06-05 02:06:55 +04:00
}
2005-08-07 19:50:07 +04:00
} else if ( ! strcmp ( params [ 0 ] , " debug " ) ) {
2011-12-29 16:44:38 +04:00
if ( num_params < 2 ) {
2004-06-05 02:06:55 +04:00
PARSE_ERR ( ( " %s: debug directive malformed. " , context ) ) ;
2005-08-07 19:50:07 +04:00
}
2011-12-29 16:44:38 +04:00
if ( parse_log_options ( context , num_params , params ) < 0 ) {
2005-11-17 23:35:38 +03:00
return - 1 ;
2004-06-05 02:06:55 +04:00
}
2006-01-18 21:35:38 +03:00
} else if ( ! strcmp ( params [ 0 ] , " cpu " ) ) {
if ( num_params < 2 ) {
PARSE_ERR ( ( " %s: cpu directive malformed. " , context ) ) ;
}
for ( i = 1 ; i < num_params ; i + + ) {
if ( ! strncmp ( params [ i ] , " count= " , 6 ) ) {
2006-02-11 18:28:43 +03:00
unsigned processors = 1 , cores = 1 , threads = 1 ;
sscanf ( & params [ i ] [ 6 ] , " %u:%u:%u " , & processors , & cores , & threads ) ;
unsigned smp_threads = cores * threads * processors ;
if ( smp_threads < 1 ) {
PARSE_ERR ( ( " %s: at least one CPU thread should be defined, cpu directive malformed " , context ) ) ;
}
2006-02-18 19:53:18 +03:00
SIM - > get_param_num ( BXPN_CPU_NPROCESSORS ) - > set ( processors ) ;
SIM - > get_param_num ( BXPN_CPU_NCORES ) - > set ( cores ) ;
SIM - > get_param_num ( BXPN_CPU_NTHREADS ) - > set ( threads ) ;
2013-01-27 16:11:19 +04:00
} else if ( bx_parse_param_from_list ( context , params [ i ] , ( bx_list_c * ) SIM - > get_param ( " cpu " ) ) < 0 ) {
2010-02-26 01:04:31 +03:00
PARSE_ERR ( ( " %s: cpu directive malformed. " , context ) ) ;
}
}
2011-02-25 18:05:48 +03:00
# if BX_CPU_LEVEL >= 4
2010-02-26 01:04:31 +03:00
} else if ( ! strcmp ( params [ 0 ] , " cpuid " ) ) {
if ( num_params < 2 ) {
PARSE_ERR ( ( " %s: cpuid directive malformed. " , context ) ) ;
}
for ( i = 1 ; i < num_params ; i + + ) {
2013-01-26 22:17:23 +04:00
if ( bx_parse_param_from_list ( context , params [ i ] , ( bx_list_c * ) SIM - > get_param ( " cpuid " ) ) < 0 ) {
2010-02-26 01:04:31 +03:00
PARSE_ERR ( ( " %s: cpuid directive malformed. " , context ) ) ;
2006-01-18 21:35:38 +03:00
}
}
2011-02-25 18:05:48 +03:00
# endif
2005-08-07 19:50:07 +04:00
} else if ( ! strcmp ( params [ 0 ] , " megs " ) ) {
if ( num_params ! = 2 ) {
PARSE_ERR ( ( " %s: megs directive: wrong # args. " , context ) ) ;
}
2006-02-18 01:27:38 +03:00
SIM - > get_param_num ( BXPN_MEM_SIZE ) - > set ( atol ( params [ 1 ] ) ) ;
2009-10-17 21:38:58 +04:00
SIM - > get_param_num ( BXPN_HOST_MEM_SIZE ) - > set ( atol ( params [ 1 ] ) ) ;
} else if ( ! strcmp ( params [ 0 ] , " memory " ) ) {
2023-11-07 16:40:20 +03:00
if ( num_params < 2 ) {
2009-10-17 21:38:58 +04:00
PARSE_ERR ( ( " %s: memory directive malformed. " , context ) ) ;
}
for ( i = 1 ; i < num_params ; i + + ) {
2023-11-07 16:40:20 +03:00
if ( bx_parse_param_from_list ( context , params [ i ] , ( bx_list_c * ) SIM - > get_param ( BXPN_MEMORY ) ) < 0 ) {
2009-10-17 21:38:58 +04:00
PARSE_ERR ( ( " %s: memory directive malformed. " , context ) ) ;
}
}
2005-08-07 19:50:07 +04:00
} else if ( ! strcmp ( params [ 0 ] , " romimage " ) ) {
2023-12-09 19:52:33 +03:00
if ( ( num_params < 2 ) | | ( num_params > 5 ) ) {
2004-06-05 02:06:55 +04:00
PARSE_ERR ( ( " %s: romimage directive: wrong # args. " , context ) ) ;
}
2017-02-14 23:11:58 +03:00
// set to default value 0 (auto-detect if no specified)
SIM - > get_param_num ( BXPN_ROM_ADDRESS ) - > set ( 0 ) ;
for ( i = 1 ; i < num_params ; i + + ) {
if ( ! strncmp ( params [ i ] , " file= " , 5 ) ) {
SIM - > get_param_string ( BXPN_ROM_PATH ) - > set ( & params [ i ] [ 5 ] ) ;
} else if ( ! strncmp ( params [ i ] , " address= " , 8 ) ) {
if ( ( params [ i ] [ 8 ] = = ' 0 ' ) & & ( params [ i ] [ 9 ] = = ' x ' ) )
SIM - > get_param_num ( BXPN_ROM_ADDRESS ) - > set ( strtoul ( & params [ i ] [ 8 ] , NULL , 16 ) ) ;
2004-09-28 21:37:52 +04:00
else
2017-02-14 23:11:58 +03:00
SIM - > get_param_num ( BXPN_ROM_ADDRESS ) - > set ( strtoul ( & params [ i ] [ 8 ] , NULL , 10 ) ) ;
2023-12-09 19:52:33 +03:00
} else if ( ! strncmp ( params [ i ] , " flash_data= " , 11 ) ) {
SIM - > get_param_string ( BXPN_ROM_FLASH_DATA ) - > set ( & params [ i ] [ 11 ] ) ;
2017-02-14 23:11:58 +03:00
} else if ( ! strncmp ( params [ i ] , " options= " , 8 ) ) {
SIM - > get_param_string ( BXPN_ROM_OPTIONS ) - > set ( & params [ i ] [ 8 ] ) ;
2005-08-07 19:50:07 +04:00
} else {
2004-09-28 21:37:52 +04:00
PARSE_ERR ( ( " %s: romimage directive malformed. " , context ) ) ;
2004-06-05 02:06:55 +04:00
}
}
2005-08-07 19:50:07 +04:00
} else if ( ! strcmp ( params [ 0 ] , " vgaromimage " ) ) {
if ( num_params ! = 2 ) {
PARSE_ERR ( ( " %s: vgaromimage directive: wrong # args. " , context ) ) ;
}
if ( ! strncmp ( params [ 1 ] , " file= " , 5 ) ) {
2006-02-18 01:27:38 +03:00
SIM - > get_param_string ( BXPN_VGA_ROM_PATH ) - > set ( & params [ 1 ] [ 5 ] ) ;
2005-08-07 19:50:07 +04:00
} else {
2009-05-07 22:46:12 +04:00
PARSE_ERR ( ( " %s: vgaromimage directive malformed. " , context ) ) ;
2005-08-07 19:50:07 +04:00
}
} else if ( ! strncmp ( params [ 0 ] , " optromimage " , 11 ) ) {
2004-09-28 21:37:52 +04:00
int num = atoi ( & params [ 0 ] [ 11 ] ) ;
2017-02-14 23:11:58 +03:00
char pname [ 16 ] ;
2005-10-28 10:33:53 +04:00
if ( ( num < 1 ) | | ( num > BX_N_OPTROM_IMAGES ) ) {
2004-09-28 21:37:52 +04:00
PARSE_ERR ( ( " %s: optromimage%d: not supported " , context , num ) ) ;
2005-08-07 19:50:07 +04:00
}
2017-02-14 23:11:58 +03:00
if ( num_params > 3 ) {
2004-09-28 21:37:52 +04:00
PARSE_ERR ( ( " %s: optromimage%d directive: wrong # args. " , context , num ) ) ;
2005-08-07 19:50:07 +04:00
}
2017-02-14 23:11:58 +03:00
sprintf ( pname , " %s.%d " , BXPN_OPTROM_BASE , num ) ;
base = ( bx_list_c * ) SIM - > get_param ( pname ) ;
2004-09-28 21:37:52 +04:00
for ( i = 1 ; i < num_params ; i + + ) {
if ( ! strncmp ( params [ i ] , " file= " , 5 ) ) {
2017-02-14 23:11:58 +03:00
SIM - > get_param_string ( " file " , base ) - > set ( & params [ i ] [ 5 ] ) ;
2005-08-07 19:50:07 +04:00
} else if ( ! strncmp ( params [ i ] , " address= " , 8 ) ) {
2004-09-28 21:37:52 +04:00
if ( ( params [ i ] [ 8 ] = = ' 0 ' ) & & ( params [ 2 ] [ 9 ] = = ' x ' ) )
2017-02-14 23:11:58 +03:00
SIM - > get_param_num ( " address " , base ) - > set ( strtoul ( & params [ i ] [ 8 ] , NULL , 16 ) ) ;
2004-09-28 21:37:52 +04:00
else
2017-02-14 23:11:58 +03:00
SIM - > get_param_num ( " address " , base ) - > set ( strtoul ( & params [ i ] [ 8 ] , NULL , 10 ) ) ;
2005-08-07 19:50:07 +04:00
} else {
2004-09-28 21:37:52 +04:00
PARSE_ERR ( ( " %s: optromimage%d directive malformed. " , context , num ) ) ;
2004-06-05 02:06:55 +04:00
}
}
2005-10-28 04:12:27 +04:00
} else if ( ! strncmp ( params [ 0 ] , " optramimage " , 11 ) ) {
int num = atoi ( & params [ 0 ] [ 11 ] ) ;
2017-02-14 23:11:58 +03:00
char pname [ 16 ] ;
2006-02-17 00:44:17 +03:00
if ( ( num < 1 ) | | ( num > BX_N_OPTRAM_IMAGES ) ) {
2006-03-07 01:03:16 +03:00
PARSE_ERR ( ( " %s: optramimage%d: not supported " , context , num ) ) ;
2005-10-28 04:12:27 +04:00
}
2017-02-14 23:11:58 +03:00
if ( num_params > 3 ) {
2006-03-07 01:03:16 +03:00
PARSE_ERR ( ( " %s: optramimage%d directive: wrong # args. " , context , num ) ) ;
2005-10-28 04:12:27 +04:00
}
2017-02-14 23:11:58 +03:00
sprintf ( pname , " %s.%d " , BXPN_OPTRAM_BASE , num ) ;
base = ( bx_list_c * ) SIM - > get_param ( pname ) ;
2005-10-28 04:12:27 +04:00
for ( i = 1 ; i < num_params ; i + + ) {
if ( ! strncmp ( params [ i ] , " file= " , 5 ) ) {
2017-02-14 23:11:58 +03:00
SIM - > get_param_string ( " file " , base ) - > set ( & params [ i ] [ 5 ] ) ;
2005-10-28 04:12:27 +04:00
} else if ( ! strncmp ( params [ i ] , " address= " , 8 ) ) {
if ( ( params [ i ] [ 8 ] = = ' 0 ' ) & & ( params [ 2 ] [ 9 ] = = ' x ' ) )
2017-02-14 23:11:58 +03:00
SIM - > get_param_num ( " address " , base ) - > set ( strtoul ( & params [ i ] [ 8 ] , NULL , 16 ) ) ;
2005-10-28 04:12:27 +04:00
else
2017-02-14 23:11:58 +03:00
SIM - > get_param_num ( " address " , base ) - > set ( strtoul ( & params [ i ] [ 8 ] , NULL , 10 ) ) ;
2005-10-28 04:12:27 +04:00
} else {
2006-03-07 01:03:16 +03:00
PARSE_ERR ( ( " %s: optramimage%d directive malformed. " , context , num ) ) ;
2005-10-28 04:12:27 +04:00
}
}
2005-08-07 19:50:07 +04:00
} else if ( ! strcmp ( params [ 0 ] , " vga " ) ) {
2011-07-27 02:16:24 +04:00
if ( num_params < 2 ) {
PARSE_ERR ( ( " %s: vga directive malformed. " , context ) ) ;
2005-08-07 19:50:07 +04:00
}
2011-07-27 02:16:24 +04:00
for ( i = 1 ; i < num_params ; i + + ) {
if ( ! strncmp ( params [ i ] , " extension= " , 10 ) ) {
2021-02-19 19:05:56 +03:00
SIM - > get_param_enum ( BXPN_VGA_EXTENSION ) - > set_by_name ( & params [ i ] [ 10 ] ) ;
2011-07-27 02:16:24 +04:00
} else if ( ! strncmp ( params [ i ] , " update_freq= " , 12 ) ) {
SIM - > get_param_num ( BXPN_VGA_UPDATE_FREQUENCY ) - > set ( atol ( & params [ i ] [ 12 ] ) ) ;
2014-11-15 13:22:27 +03:00
} else if ( ! strncmp ( params [ i ] , " realtime= " , 9 ) ) {
SIM - > get_param_bool ( BXPN_VGA_REALTIME ) - > set ( atol ( & params [ i ] [ 9 ] ) ) ;
2020-03-21 21:00:02 +03:00
} else if ( ! strncmp ( params [ i ] , " ddc= " , 4 ) ) {
const char * strval = & params [ i ] [ 4 ] ;
if ( strncmp ( strval , " file: " , 5 ) ) {
SIM - > get_param_enum ( BXPN_DDC_MODE ) - > set_by_name ( strval ) ;
} else {
SIM - > get_param_enum ( BXPN_DDC_MODE ) - > set ( BX_DDC_MODE_FILE ) ;
SIM - > get_param_string ( BXPN_DDC_FILE ) - > set ( strval + 5 ) ;
}
2012-07-14 20:13:01 +04:00
} else {
PARSE_ERR ( ( " %s: vga directive malformed. " , context ) ) ;
}
}
} else if ( ! strcmp ( params [ 0 ] , " keyboard " ) ) {
if ( num_params < 2 ) {
PARSE_ERR ( ( " %s: keyboard directive malformed. " , context ) ) ;
}
for ( i = 1 ; i < num_params ; i + + ) {
2013-01-27 23:09:24 +04:00
if ( ! strncmp ( params [ i ] , " keymap= " , 7 ) ) {
2013-02-01 23:13:58 +04:00
char * kmap = & params [ i ] [ 7 ] ;
SIM - > get_param_bool ( BXPN_KBD_USEMAPPING ) - > set ( ( strlen ( kmap ) > 0 ) & & ( strcmp ( kmap , " none " ) ) ) ;
SIM - > get_param_string ( BXPN_KBD_KEYMAP ) - > set ( kmap ) ;
2013-01-27 23:09:24 +04:00
} else if ( bx_parse_param_from_list ( context , params [ i ] , ( bx_list_c * ) SIM - > get_param ( BXPN_KEYBOARD ) ) < 0 ) {
2012-07-14 20:13:01 +04:00
PARSE_ERR ( ( " %s: keyboard directive malformed. " , context ) ) ;
2011-07-27 02:16:24 +04:00
}
2005-02-01 22:16:39 +03:00
}
2005-08-07 19:50:07 +04:00
} else if ( ! strcmp ( params [ 0 ] , " mouse " ) ) {
2004-12-01 00:03:16 +03:00
if ( num_params < 2 ) {
2004-06-05 02:06:55 +04:00
PARSE_ERR ( ( " %s: mouse directive malformed. " , context ) ) ;
2005-08-07 19:50:07 +04:00
}
2004-12-01 00:03:16 +03:00
for ( i = 1 ; i < num_params ; i + + ) {
2013-01-26 22:17:23 +04:00
if ( bx_parse_param_from_list ( context , params [ i ] , ( bx_list_c * ) SIM - > get_param ( BXPN_MOUSE ) ) < 0 ) {
2004-12-01 00:03:16 +03:00
PARSE_ERR ( ( " %s: mouse directive malformed. " , context ) ) ;
2004-06-05 02:06:55 +04:00
}
}
2005-08-07 19:50:07 +04:00
} else if ( ! strcmp ( params [ 0 ] , " private_colormap " ) ) {
2004-06-05 02:06:55 +04:00
if ( num_params ! = 2 ) {
PARSE_ERR ( ( " %s: private_colormap directive malformed. " , context ) ) ;
2005-08-07 19:50:07 +04:00
}
2004-06-05 02:06:55 +04:00
if ( strncmp ( params [ 1 ] , " enabled= " , 8 ) ) {
PARSE_ERR ( ( " %s: private_colormap directive malformed. " , context ) ) ;
2005-08-07 19:50:07 +04:00
}
2010-03-01 21:53:53 +03:00
if ( parse_param_bool ( params [ 1 ] , 8 , BXPN_PRIVATE_COLORMAP ) < 0 ) {
2004-06-05 02:06:55 +04:00
PARSE_ERR ( ( " %s: private_colormap directive malformed. " , context ) ) ;
}
2005-08-07 19:50:07 +04:00
} else if ( ! strcmp ( params [ 0 ] , " fullscreen " ) ) {
2004-06-05 02:06:55 +04:00
# if BX_WITH_AMIGAOS
if ( num_params ! = 2 ) {
PARSE_ERR ( ( " %s: fullscreen directive malformed. " , context ) ) ;
2005-08-07 19:50:07 +04:00
}
2004-06-05 02:06:55 +04:00
if ( strncmp ( params [ 1 ] , " enabled= " , 8 ) ) {
PARSE_ERR ( ( " %s: fullscreen directive malformed. " , context ) ) ;
2005-08-07 19:50:07 +04:00
}
2010-03-01 21:53:53 +03:00
if ( parse_param_bool ( params [ 1 ] , 8 , BXPN_FULLSCREEN ) < 0 ) {
2004-06-05 02:06:55 +04:00
PARSE_ERR ( ( " %s: fullscreen directive malformed. " , context ) ) ;
}
2005-08-07 19:50:07 +04:00
# endif
} else if ( ! strcmp ( params [ 0 ] , " screenmode " ) ) {
2004-06-05 02:06:55 +04:00
# if BX_WITH_AMIGAOS
if ( num_params ! = 2 ) {
PARSE_ERR ( ( " %s: screenmode directive malformed. " , context ) ) ;
2005-08-07 19:50:07 +04:00
}
2004-06-05 02:06:55 +04:00
if ( strncmp ( params [ 1 ] , " name= " , 5 ) ) {
PARSE_ERR ( ( " %s: screenmode directive malformed. " , context ) ) ;
2005-08-07 19:50:07 +04:00
}
2006-02-28 17:02:06 +03:00
SIM - > get_param_string ( BXPN_SCREENMODE ) - > set ( & params [ 1 ] [ 5 ] ) ;
2004-06-05 02:06:55 +04:00
# endif
2012-11-11 12:11:17 +04:00
} else if ( ! strcmp ( params [ 0 ] , " pci " ) ) {
2006-02-20 00:35:50 +03:00
char tmpdev [ 80 ] ;
2011-07-10 19:40:19 +04:00
int enabled = - 1 ;
2021-01-30 18:16:00 +03:00
bool chipset = 0 ;
2005-11-13 17:26:02 +03:00
for ( i = 1 ; i < num_params ; i + + ) {
if ( ! strncmp ( params [ i ] , " enabled= " , 8 ) ) {
2011-07-10 19:40:19 +04:00
enabled = atol ( & params [ i ] [ 8 ] ) ;
} else if ( ! strncmp ( params [ i ] , " chipset= " , 8 ) ) {
2012-11-11 12:11:17 +04:00
if ( ! SIM - > get_param_enum ( BXPN_PCI_CHIPSET ) - > set_by_name ( & params [ i ] [ 8 ] ) ) {
2011-07-10 19:40:19 +04:00
PARSE_ERR ( ( " %s: pci: unknown chipset '%s' " , context , & params [ i ] [ 8 ] ) ) ;
2012-11-11 12:11:17 +04:00
} else {
chipset = 1 ;
2011-07-10 19:40:19 +04:00
}
2005-11-13 17:26:02 +03:00
} else if ( ( ! strncmp ( params [ i ] , " slot " , 4 ) ) & & ( params [ i ] [ 5 ] = = ' = ' ) ) {
2006-02-20 00:35:50 +03:00
slot = atol ( & params [ i ] [ 4 ] ) ;
if ( ( slot > 0 ) & & ( slot < 6 ) ) {
sprintf ( tmpdev , " pci.slot.%d " , slot ) ;
2021-02-27 13:23:05 +03:00
if ( strlen ( & params [ i ] [ 6 ] ) > 0 ) {
2021-10-14 20:59:08 +03:00
if ( ! SIM - > get_param_enum ( tmpdev ) - > set_by_name ( & params [ i ] [ 6 ] ) ) {
PARSE_ERR ( ( " %s: unknown plugin '%s' at PCI slot #%d. " ,
context , & params [ i ] [ 6 ] , slot ) ) ;
}
2021-02-27 13:23:05 +03:00
} else {
SIM - > get_param_enum ( tmpdev ) - > set_by_name ( " none " ) ;
}
2005-11-13 17:26:02 +03:00
} else {
2021-10-14 20:59:08 +03:00
PARSE_ERR ( ( " %s: unknown PCI slot number #%d. " , context , slot ) ) ;
2004-06-29 23:24:34 +04:00
}
2020-12-04 20:04:40 +03:00
} else if ( ! strncmp ( params [ i ] , " advopts= " , 8 ) ) {
SIM - > get_param_string ( BXPN_PCI_ADV_OPTS ) - > set ( & params [ i ] [ 8 ] ) ;
2005-11-13 17:26:02 +03:00
} else {
2011-07-10 19:40:19 +04:00
PARSE_ERR ( ( " %s: pci: unknown parameter '%s'. " , context , params [ i ] ) ) ;
}
}
if ( enabled = = 0 ) {
2012-11-11 12:11:17 +04:00
SIM - > get_param_bool ( BXPN_PCI_ENABLED ) - > set ( 0 ) ;
2011-07-10 19:40:19 +04:00
} else if ( enabled = = 1 ) {
if ( chipset = = 1 ) {
2012-11-11 12:11:17 +04:00
SIM - > get_param_bool ( BXPN_PCI_ENABLED ) - > set ( 1 ) ;
2011-07-10 19:40:19 +04:00
} else {
PARSE_ERR ( ( " %s: pci: chipset not specified " , context ) ) ;
2004-06-29 23:24:34 +04:00
}
2004-06-05 02:06:55 +04:00
}
2005-09-12 00:03:56 +04:00
} else if ( ! strcmp ( params [ 0 ] , " cmosimage " ) ) {
for ( i = 1 ; i < num_params ; i + + ) {
if ( ! strncmp ( params [ i ] , " file= " , 5 ) ) {
2006-02-28 17:02:06 +03:00
SIM - > get_param_string ( BXPN_CMOSIMAGE_PATH ) - > set ( & params [ i ] [ 5 ] ) ;
2023-12-04 22:39:24 +03:00
if ( strlen ( & params [ i ] [ 5 ] ) > 0 ) {
SIM - > get_param_bool ( BXPN_CMOSIMAGE_ENABLED ) - > set ( 1 ) ;
}
Porting #SF patch #565 Real Time Clock /CMOS fix (#4)
by Michele Giacomone
Detailed description:
-Observed issues
Due to some limitations only dates between 1980 and 2038 can be
used in a reliable way.
Also, bochs incorrectly assumes a linear correspondence between
the data returned by the <time.h> functions localtime() and
mktime(), and isn't setting the latter properly.
Bochs keeps its internal time value dependent to these functions
after setup, assuming that their internal settings won't change
on the go - which is not the case.
In my OS, and in my timezone, this leads to incorrect startup values
for 5 months each year and unreliable values if the simulation is
kept going for a long time. (a feedback between localtime() and
mktime() is created which keeps shifting back the time)
Also, the RTC simulation is not realistic since the clock fixes
itself across DST changes, without updating any DST related flag,
a behavior that no guest OS expects.
-Proposed fix
This is implemented in such way that no bochs' previous behavior
is changed, a part from the broken ones, with legacy in mind
== the user can keep using bochs exactly as before knowing nothing
of this patch
+Make the internal s.timeval variable a Bit64s, so it can fit all
values that the cmos can correctly represent, reported below:
MIN setting -62167219200 => 0000/01/01 SAT 0:00:00
MAX BCD setting 253402300799 => 9999/12/31 FRI 23:59:59
MAX BIN setting 745690751999 => 25599/12/31 FRI 23:59:59
And then fix each reference to these so it can handle such values
And make bochs correctly wrap around for under/overflows, so that
only the most significant bits of the century are lost.
+Do the same thing to the bochs time0 parameter, so all the above
values can be chosen at startup (despite being now legal values,
1 and 2 will still be treated as "local" and "utc"). Note that
normally only BCD settings are valid since bochs' CMOS defaults
to such operating mode - the only way to use the binary range
is by loading a cmos memory map.
+Make the internal s.timeval variable independent from external
factors. This means providing a small set of time handling
functions, contained in "iodev/utctime.h", which must work in
any environment in which bochs compiles, accessing no external
resource. This also means that after startup, s.timeval will only
be changed internally, and no call to the OS time functions will
be made.
+Make the internal s.timeval variable timezone independent, to
have a linear correlation between its values and valid CMOS
settings. To make it easier, s.timeval is gonna be treated as
if the current timezone was UTC: so,
- if the user selects UTC as time0, s.timeval will become current
time(NULL)
- if the user selects localtime, s.timeval will be computed as
the value which will display the same broken down time as
localtime(&now)
- if the user inputs a time formatted string the proper s.timeval
to displayed will be easily calculated,
- if the user inputs a starting time value, s.timeval will be
computed as the value which will display the same broken down
time as localtime(&user_input) to ensure the same operation as
before.
A "tz=utc" is displayed when bochs prints out the current time
value, to warn users about the difference in meaning between the
internally kept time value and the value they can set through
the "time0=" parameter. This might be changed to communicate
instead the time value they can input to get the same setting,
but performing such calculation (except for the startup time)
suffers from all the mktime()/localtime() problems listed above
so I did not do it.
The range of "time0" is automatically adjusted so all users in
all time zones can set any legal value despite "time0=" having a
local meaning.
A thorough explanation of what I did and why can be found in the
"iodev/utctime.h" library header.
---------
Co-authored-by: Stanislav Shwartsman <sshwarts@users.sourceforge.net>
Co-authored-by: Volker Ruppert <Volker.Ruppert@t-online.de>
2023-12-02 00:55:35 +03:00
} else if ( ! strncmp ( params [ i ] , " rtc_init=time0 " , 14 ) ) {
2006-02-19 18:43:03 +03:00
SIM - > get_param_bool ( BXPN_CMOSIMAGE_RTC_INIT ) - > set ( 0 ) ;
Porting #SF patch #565 Real Time Clock /CMOS fix (#4)
by Michele Giacomone
Detailed description:
-Observed issues
Due to some limitations only dates between 1980 and 2038 can be
used in a reliable way.
Also, bochs incorrectly assumes a linear correspondence between
the data returned by the <time.h> functions localtime() and
mktime(), and isn't setting the latter properly.
Bochs keeps its internal time value dependent to these functions
after setup, assuming that their internal settings won't change
on the go - which is not the case.
In my OS, and in my timezone, this leads to incorrect startup values
for 5 months each year and unreliable values if the simulation is
kept going for a long time. (a feedback between localtime() and
mktime() is created which keeps shifting back the time)
Also, the RTC simulation is not realistic since the clock fixes
itself across DST changes, without updating any DST related flag,
a behavior that no guest OS expects.
-Proposed fix
This is implemented in such way that no bochs' previous behavior
is changed, a part from the broken ones, with legacy in mind
== the user can keep using bochs exactly as before knowing nothing
of this patch
+Make the internal s.timeval variable a Bit64s, so it can fit all
values that the cmos can correctly represent, reported below:
MIN setting -62167219200 => 0000/01/01 SAT 0:00:00
MAX BCD setting 253402300799 => 9999/12/31 FRI 23:59:59
MAX BIN setting 745690751999 => 25599/12/31 FRI 23:59:59
And then fix each reference to these so it can handle such values
And make bochs correctly wrap around for under/overflows, so that
only the most significant bits of the century are lost.
+Do the same thing to the bochs time0 parameter, so all the above
values can be chosen at startup (despite being now legal values,
1 and 2 will still be treated as "local" and "utc"). Note that
normally only BCD settings are valid since bochs' CMOS defaults
to such operating mode - the only way to use the binary range
is by loading a cmos memory map.
+Make the internal s.timeval variable independent from external
factors. This means providing a small set of time handling
functions, contained in "iodev/utctime.h", which must work in
any environment in which bochs compiles, accessing no external
resource. This also means that after startup, s.timeval will only
be changed internally, and no call to the OS time functions will
be made.
+Make the internal s.timeval variable timezone independent, to
have a linear correlation between its values and valid CMOS
settings. To make it easier, s.timeval is gonna be treated as
if the current timezone was UTC: so,
- if the user selects UTC as time0, s.timeval will become current
time(NULL)
- if the user selects localtime, s.timeval will be computed as
the value which will display the same broken down time as
localtime(&now)
- if the user inputs a time formatted string the proper s.timeval
to displayed will be easily calculated,
- if the user inputs a starting time value, s.timeval will be
computed as the value which will display the same broken down
time as localtime(&user_input) to ensure the same operation as
before.
A "tz=utc" is displayed when bochs prints out the current time
value, to warn users about the difference in meaning between the
internally kept time value and the value they can set through
the "time0=" parameter. This might be changed to communicate
instead the time value they can input to get the same setting,
but performing such calculation (except for the startup time)
suffers from all the mktime()/localtime() problems listed above
so I did not do it.
The range of "time0" is automatically adjusted so all users in
all time zones can set any legal value despite "time0=" having a
local meaning.
A thorough explanation of what I did and why can be found in the
"iodev/utctime.h" library header.
---------
Co-authored-by: Stanislav Shwartsman <sshwarts@users.sourceforge.net>
Co-authored-by: Volker Ruppert <Volker.Ruppert@t-online.de>
2023-12-02 00:55:35 +03:00
} else if ( ! strncmp ( params [ i ] , " rtc_init=image " , 14 ) ) {
2006-02-19 18:43:03 +03:00
SIM - > get_param_bool ( BXPN_CMOSIMAGE_RTC_INIT ) - > set ( 1 ) ;
2005-09-12 00:03:56 +04:00
} else {
2017-03-23 22:09:37 +03:00
BX_ERROR ( ( " %s: unknown parameter for cmosimage ignored. " , context ) ) ;
2004-06-05 02:06:55 +04:00
}
}
2005-09-12 00:03:56 +04:00
} else if ( ! strcmp ( params [ 0 ] , " clock " ) ) {
2013-08-18 21:16:16 +04:00
const char months [ ] = " Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec " ;
char wday [ 4 ] , mon [ 4 ] ;
2013-08-19 10:39:07 +04:00
int n , year ;
2013-08-18 21:16:16 +04:00
struct tm tm_time ;
2004-06-05 02:06:55 +04:00
for ( i = 1 ; i < num_params ; i + + ) {
if ( ! strncmp ( params [ i ] , " sync= " , 5 ) ) {
2006-02-19 18:43:03 +03:00
SIM - > get_param_enum ( BXPN_CLOCK_SYNC ) - > set_by_name ( & params [ i ] [ 5 ] ) ;
2006-01-23 21:39:10 +03:00
}
2012-05-15 21:03:45 +04:00
else if ( ! strncmp ( params [ i ] , " rtc_sync= " , 9 ) ) {
SIM - > get_param_bool ( BXPN_CLOCK_RTC_SYNC ) - > set ( atol ( & params [ i ] [ 9 ] ) ) ;
}
2004-06-05 02:06:55 +04:00
else if ( ! strcmp ( params [ i ] , " time0=local " ) ) {
2006-02-19 18:43:03 +03:00
SIM - > get_param_num ( BXPN_CLOCK_TIME0 ) - > set ( BX_CLOCK_TIME0_LOCAL ) ;
2006-01-23 21:39:10 +03:00
}
2004-06-05 02:06:55 +04:00
else if ( ! strcmp ( params [ i ] , " time0=utc " ) ) {
2006-02-19 18:43:03 +03:00
SIM - > get_param_num ( BXPN_CLOCK_TIME0 ) - > set ( BX_CLOCK_TIME0_UTC ) ;
2006-01-23 21:39:10 +03:00
}
2004-06-05 02:06:55 +04:00
else if ( ! strncmp ( params [ i ] , " time0= " , 6 ) ) {
2013-08-18 21:16:16 +04:00
if ( isalpha ( params [ i ] [ 6 ] ) ) {
memset ( & tm_time , 0 , sizeof ( tm_time ) ) ;
Porting #SF patch #565 Real Time Clock /CMOS fix (#4)
by Michele Giacomone
Detailed description:
-Observed issues
Due to some limitations only dates between 1980 and 2038 can be
used in a reliable way.
Also, bochs incorrectly assumes a linear correspondence between
the data returned by the <time.h> functions localtime() and
mktime(), and isn't setting the latter properly.
Bochs keeps its internal time value dependent to these functions
after setup, assuming that their internal settings won't change
on the go - which is not the case.
In my OS, and in my timezone, this leads to incorrect startup values
for 5 months each year and unreliable values if the simulation is
kept going for a long time. (a feedback between localtime() and
mktime() is created which keeps shifting back the time)
Also, the RTC simulation is not realistic since the clock fixes
itself across DST changes, without updating any DST related flag,
a behavior that no guest OS expects.
-Proposed fix
This is implemented in such way that no bochs' previous behavior
is changed, a part from the broken ones, with legacy in mind
== the user can keep using bochs exactly as before knowing nothing
of this patch
+Make the internal s.timeval variable a Bit64s, so it can fit all
values that the cmos can correctly represent, reported below:
MIN setting -62167219200 => 0000/01/01 SAT 0:00:00
MAX BCD setting 253402300799 => 9999/12/31 FRI 23:59:59
MAX BIN setting 745690751999 => 25599/12/31 FRI 23:59:59
And then fix each reference to these so it can handle such values
And make bochs correctly wrap around for under/overflows, so that
only the most significant bits of the century are lost.
+Do the same thing to the bochs time0 parameter, so all the above
values can be chosen at startup (despite being now legal values,
1 and 2 will still be treated as "local" and "utc"). Note that
normally only BCD settings are valid since bochs' CMOS defaults
to such operating mode - the only way to use the binary range
is by loading a cmos memory map.
+Make the internal s.timeval variable independent from external
factors. This means providing a small set of time handling
functions, contained in "iodev/utctime.h", which must work in
any environment in which bochs compiles, accessing no external
resource. This also means that after startup, s.timeval will only
be changed internally, and no call to the OS time functions will
be made.
+Make the internal s.timeval variable timezone independent, to
have a linear correlation between its values and valid CMOS
settings. To make it easier, s.timeval is gonna be treated as
if the current timezone was UTC: so,
- if the user selects UTC as time0, s.timeval will become current
time(NULL)
- if the user selects localtime, s.timeval will be computed as
the value which will display the same broken down time as
localtime(&now)
- if the user inputs a time formatted string the proper s.timeval
to displayed will be easily calculated,
- if the user inputs a starting time value, s.timeval will be
computed as the value which will display the same broken down
time as localtime(&user_input) to ensure the same operation as
before.
A "tz=utc" is displayed when bochs prints out the current time
value, to warn users about the difference in meaning between the
internally kept time value and the value they can set through
the "time0=" parameter. This might be changed to communicate
instead the time value they can input to get the same setting,
but performing such calculation (except for the startup time)
suffers from all the mktime()/localtime() problems listed above
so I did not do it.
The range of "time0" is automatically adjusted so all users in
all time zones can set any legal value despite "time0=" having a
local meaning.
A thorough explanation of what I did and why can be found in the
"iodev/utctime.h" library header.
---------
Co-authored-by: Stanislav Shwartsman <sshwarts@users.sourceforge.net>
Co-authored-by: Volker Ruppert <Volker.Ruppert@t-online.de>
2023-12-02 00:55:35 +03:00
n = sscanf ( & params [ i ] [ 6 ] , " %3s %3s %2d %2d:%2d:%2d %d " , wday , mon , & tm_time . tm_mday ,
2013-08-19 10:39:07 +04:00
& tm_time . tm_hour , & tm_time . tm_min , & tm_time . tm_sec , & year ) ;
Porting #SF patch #565 Real Time Clock /CMOS fix (#4)
by Michele Giacomone
Detailed description:
-Observed issues
Due to some limitations only dates between 1980 and 2038 can be
used in a reliable way.
Also, bochs incorrectly assumes a linear correspondence between
the data returned by the <time.h> functions localtime() and
mktime(), and isn't setting the latter properly.
Bochs keeps its internal time value dependent to these functions
after setup, assuming that their internal settings won't change
on the go - which is not the case.
In my OS, and in my timezone, this leads to incorrect startup values
for 5 months each year and unreliable values if the simulation is
kept going for a long time. (a feedback between localtime() and
mktime() is created which keeps shifting back the time)
Also, the RTC simulation is not realistic since the clock fixes
itself across DST changes, without updating any DST related flag,
a behavior that no guest OS expects.
-Proposed fix
This is implemented in such way that no bochs' previous behavior
is changed, a part from the broken ones, with legacy in mind
== the user can keep using bochs exactly as before knowing nothing
of this patch
+Make the internal s.timeval variable a Bit64s, so it can fit all
values that the cmos can correctly represent, reported below:
MIN setting -62167219200 => 0000/01/01 SAT 0:00:00
MAX BCD setting 253402300799 => 9999/12/31 FRI 23:59:59
MAX BIN setting 745690751999 => 25599/12/31 FRI 23:59:59
And then fix each reference to these so it can handle such values
And make bochs correctly wrap around for under/overflows, so that
only the most significant bits of the century are lost.
+Do the same thing to the bochs time0 parameter, so all the above
values can be chosen at startup (despite being now legal values,
1 and 2 will still be treated as "local" and "utc"). Note that
normally only BCD settings are valid since bochs' CMOS defaults
to such operating mode - the only way to use the binary range
is by loading a cmos memory map.
+Make the internal s.timeval variable independent from external
factors. This means providing a small set of time handling
functions, contained in "iodev/utctime.h", which must work in
any environment in which bochs compiles, accessing no external
resource. This also means that after startup, s.timeval will only
be changed internally, and no call to the OS time functions will
be made.
+Make the internal s.timeval variable timezone independent, to
have a linear correlation between its values and valid CMOS
settings. To make it easier, s.timeval is gonna be treated as
if the current timezone was UTC: so,
- if the user selects UTC as time0, s.timeval will become current
time(NULL)
- if the user selects localtime, s.timeval will be computed as
the value which will display the same broken down time as
localtime(&now)
- if the user inputs a time formatted string the proper s.timeval
to displayed will be easily calculated,
- if the user inputs a starting time value, s.timeval will be
computed as the value which will display the same broken down
time as localtime(&user_input) to ensure the same operation as
before.
A "tz=utc" is displayed when bochs prints out the current time
value, to warn users about the difference in meaning between the
internally kept time value and the value they can set through
the "time0=" parameter. This might be changed to communicate
instead the time value they can input to get the same setting,
but performing such calculation (except for the startup time)
suffers from all the mktime()/localtime() problems listed above
so I did not do it.
The range of "time0" is automatically adjusted so all users in
all time zones can set any legal value despite "time0=" having a
local meaning.
A thorough explanation of what I did and why can be found in the
"iodev/utctime.h" library header.
---------
Co-authored-by: Stanislav Shwartsman <sshwarts@users.sourceforge.net>
Co-authored-by: Volker Ruppert <Volker.Ruppert@t-online.de>
2023-12-02 00:55:35 +03:00
if ( ( n = = 7 ) & & ( strstr ( months , mon ) ! = NULL ) ) {
2013-08-19 10:39:07 +04:00
tm_time . tm_year = year - 1900 ;
2021-07-12 22:05:25 +03:00
tm_time . tm_mon = 12 - ( ( int ) strlen ( strstr ( months , mon ) ) / 4 ) ;
Porting #SF patch #565 Real Time Clock /CMOS fix (#4)
by Michele Giacomone
Detailed description:
-Observed issues
Due to some limitations only dates between 1980 and 2038 can be
used in a reliable way.
Also, bochs incorrectly assumes a linear correspondence between
the data returned by the <time.h> functions localtime() and
mktime(), and isn't setting the latter properly.
Bochs keeps its internal time value dependent to these functions
after setup, assuming that their internal settings won't change
on the go - which is not the case.
In my OS, and in my timezone, this leads to incorrect startup values
for 5 months each year and unreliable values if the simulation is
kept going for a long time. (a feedback between localtime() and
mktime() is created which keeps shifting back the time)
Also, the RTC simulation is not realistic since the clock fixes
itself across DST changes, without updating any DST related flag,
a behavior that no guest OS expects.
-Proposed fix
This is implemented in such way that no bochs' previous behavior
is changed, a part from the broken ones, with legacy in mind
== the user can keep using bochs exactly as before knowing nothing
of this patch
+Make the internal s.timeval variable a Bit64s, so it can fit all
values that the cmos can correctly represent, reported below:
MIN setting -62167219200 => 0000/01/01 SAT 0:00:00
MAX BCD setting 253402300799 => 9999/12/31 FRI 23:59:59
MAX BIN setting 745690751999 => 25599/12/31 FRI 23:59:59
And then fix each reference to these so it can handle such values
And make bochs correctly wrap around for under/overflows, so that
only the most significant bits of the century are lost.
+Do the same thing to the bochs time0 parameter, so all the above
values can be chosen at startup (despite being now legal values,
1 and 2 will still be treated as "local" and "utc"). Note that
normally only BCD settings are valid since bochs' CMOS defaults
to such operating mode - the only way to use the binary range
is by loading a cmos memory map.
+Make the internal s.timeval variable independent from external
factors. This means providing a small set of time handling
functions, contained in "iodev/utctime.h", which must work in
any environment in which bochs compiles, accessing no external
resource. This also means that after startup, s.timeval will only
be changed internally, and no call to the OS time functions will
be made.
+Make the internal s.timeval variable timezone independent, to
have a linear correlation between its values and valid CMOS
settings. To make it easier, s.timeval is gonna be treated as
if the current timezone was UTC: so,
- if the user selects UTC as time0, s.timeval will become current
time(NULL)
- if the user selects localtime, s.timeval will be computed as
the value which will display the same broken down time as
localtime(&now)
- if the user inputs a time formatted string the proper s.timeval
to displayed will be easily calculated,
- if the user inputs a starting time value, s.timeval will be
computed as the value which will display the same broken down
time as localtime(&user_input) to ensure the same operation as
before.
A "tz=utc" is displayed when bochs prints out the current time
value, to warn users about the difference in meaning between the
internally kept time value and the value they can set through
the "time0=" parameter. This might be changed to communicate
instead the time value they can input to get the same setting,
but performing such calculation (except for the startup time)
suffers from all the mktime()/localtime() problems listed above
so I did not do it.
The range of "time0" is automatically adjusted so all users in
all time zones can set any legal value despite "time0=" having a
local meaning.
A thorough explanation of what I did and why can be found in the
"iodev/utctime.h" library header.
---------
Co-authored-by: Stanislav Shwartsman <sshwarts@users.sourceforge.net>
Co-authored-by: Volker Ruppert <Volker.Ruppert@t-online.de>
2023-12-02 00:55:35 +03:00
tm_time . tm_isdst = - 1 ;
2013-08-19 10:39:07 +04:00
SIM - > get_param_num ( BXPN_CLOCK_TIME0 ) - > set ( mktime ( & tm_time ) ) ;
} else {
PARSE_ERR ( ( " %s: time0 string format malformed. " , context ) ) ;
}
2013-08-18 21:16:16 +04:00
} else {
Porting #SF patch #565 Real Time Clock /CMOS fix (#4)
by Michele Giacomone
Detailed description:
-Observed issues
Due to some limitations only dates between 1980 and 2038 can be
used in a reliable way.
Also, bochs incorrectly assumes a linear correspondence between
the data returned by the <time.h> functions localtime() and
mktime(), and isn't setting the latter properly.
Bochs keeps its internal time value dependent to these functions
after setup, assuming that their internal settings won't change
on the go - which is not the case.
In my OS, and in my timezone, this leads to incorrect startup values
for 5 months each year and unreliable values if the simulation is
kept going for a long time. (a feedback between localtime() and
mktime() is created which keeps shifting back the time)
Also, the RTC simulation is not realistic since the clock fixes
itself across DST changes, without updating any DST related flag,
a behavior that no guest OS expects.
-Proposed fix
This is implemented in such way that no bochs' previous behavior
is changed, a part from the broken ones, with legacy in mind
== the user can keep using bochs exactly as before knowing nothing
of this patch
+Make the internal s.timeval variable a Bit64s, so it can fit all
values that the cmos can correctly represent, reported below:
MIN setting -62167219200 => 0000/01/01 SAT 0:00:00
MAX BCD setting 253402300799 => 9999/12/31 FRI 23:59:59
MAX BIN setting 745690751999 => 25599/12/31 FRI 23:59:59
And then fix each reference to these so it can handle such values
And make bochs correctly wrap around for under/overflows, so that
only the most significant bits of the century are lost.
+Do the same thing to the bochs time0 parameter, so all the above
values can be chosen at startup (despite being now legal values,
1 and 2 will still be treated as "local" and "utc"). Note that
normally only BCD settings are valid since bochs' CMOS defaults
to such operating mode - the only way to use the binary range
is by loading a cmos memory map.
+Make the internal s.timeval variable independent from external
factors. This means providing a small set of time handling
functions, contained in "iodev/utctime.h", which must work in
any environment in which bochs compiles, accessing no external
resource. This also means that after startup, s.timeval will only
be changed internally, and no call to the OS time functions will
be made.
+Make the internal s.timeval variable timezone independent, to
have a linear correlation between its values and valid CMOS
settings. To make it easier, s.timeval is gonna be treated as
if the current timezone was UTC: so,
- if the user selects UTC as time0, s.timeval will become current
time(NULL)
- if the user selects localtime, s.timeval will be computed as
the value which will display the same broken down time as
localtime(&now)
- if the user inputs a time formatted string the proper s.timeval
to displayed will be easily calculated,
- if the user inputs a starting time value, s.timeval will be
computed as the value which will display the same broken down
time as localtime(&user_input) to ensure the same operation as
before.
A "tz=utc" is displayed when bochs prints out the current time
value, to warn users about the difference in meaning between the
internally kept time value and the value they can set through
the "time0=" parameter. This might be changed to communicate
instead the time value they can input to get the same setting,
but performing such calculation (except for the startup time)
suffers from all the mktime()/localtime() problems listed above
so I did not do it.
The range of "time0" is automatically adjusted so all users in
all time zones can set any legal value despite "time0=" having a
local meaning.
A thorough explanation of what I did and why can be found in the
"iodev/utctime.h" library header.
---------
Co-authored-by: Stanislav Shwartsman <sshwarts@users.sourceforge.net>
Co-authored-by: Volker Ruppert <Volker.Ruppert@t-online.de>
2023-12-02 00:55:35 +03:00
Bit64s tmptm = atol ( & params [ i ] [ 6 ] ) ;
SIM - > get_param_num ( BXPN_CLOCK_TIME0 ) - > set ( tmptm ) ;
2013-08-18 21:16:16 +04:00
}
2006-01-23 21:39:10 +03:00
}
2004-06-05 02:06:55 +04:00
else {
BX_ERROR ( ( " %s: unknown parameter for clock ignored. " , context ) ) ;
}
}
2013-07-20 20:13:07 +04:00
} else if ( ! strcmp ( params [ 0 ] , " sound " ) ) {
2013-06-24 23:19:12 +04:00
# if BX_SUPPORT_SOUNDLOW
2015-03-07 01:54:30 +03:00
static const char default_drv [ ] = BX_SOUND_LOWLEVEL_NAME ;
const char * driver ;
2013-06-24 23:19:12 +04:00
for ( i = 1 ; i < num_params ; i + + ) {
2015-03-07 01:54:30 +03:00
if ( ! strncmp ( params [ i ] , " driver= " , 7 ) ) {
if ( ! strcmp ( & params [ i ] [ 7 ] , " default " ) ) {
driver = default_drv ;
} else {
driver = & params [ i ] [ 7 ] ;
}
SIM - > get_param_enum ( BXPN_SOUND_WAVEOUT_DRV ) - > set_by_name ( driver ) ;
SIM - > get_param_enum ( BXPN_SOUND_WAVEIN_DRV ) - > set_by_name ( driver ) ;
SIM - > get_param_enum ( BXPN_SOUND_MIDIOUT_DRV ) - > set_by_name ( driver ) ;
2015-02-22 23:29:58 +03:00
} else if ( bx_parse_param_from_list ( context , params [ i ] , ( bx_list_c * ) SIM - > get_param ( BXPN_SOUNDLOW ) ) < 0 ) {
2013-06-24 23:19:12 +04:00
BX_ERROR ( ( " %s: unknown parameter for sound ignored. " , context ) ) ;
}
}
# else
PARSE_ERR ( ( " %s: Bochs is not compiled with lowlevel sound support " , context ) ) ;
# endif
2013-07-20 20:13:07 +04:00
} else if ( ! strcmp ( params [ 0 ] , " gdbstub " ) ) {
2005-03-16 19:36:31 +03:00
# if BX_GDBSTUB
2004-11-06 13:50:03 +03:00
if ( num_params < 2 ) {
PARSE_ERR ( ( " %s: gdbstub directive: wrong # args. " , context ) ) ;
2006-01-23 21:39:10 +03:00
}
2006-03-04 15:43:47 +03:00
base = ( bx_list_c * ) SIM - > get_param ( BXPN_GDBSTUB ) ;
2004-11-06 13:50:03 +03:00
for ( i = 1 ; i < num_params ; i + + ) {
if ( ! strncmp ( params [ i ] , " enabled= " , 8 ) ) {
if ( params [ i ] [ 8 ] = = ' 0 ' ) {
2006-03-04 15:43:47 +03:00
SIM - > get_param_bool ( " enabled " , base ) - > set ( 0 ) ;
2004-11-06 13:50:03 +03:00
BX_INFO ( ( " Disabled gdbstub " ) ) ;
bx_dbg . gdbstub_enabled = 0 ;
2006-01-23 21:39:10 +03:00
}
2004-11-06 13:50:03 +03:00
else if ( params [ i ] [ 8 ] = = ' 1 ' ) {
2006-03-04 15:43:47 +03:00
SIM - > get_param_bool ( " enabled " , base ) - > set ( 1 ) ;
2004-11-06 13:50:03 +03:00
BX_INFO ( ( " Enabled gdbstub " ) ) ;
bx_dbg . gdbstub_enabled = 1 ;
2006-01-23 21:39:10 +03:00
}
2004-11-06 13:50:03 +03:00
else {
PARSE_ERR ( ( " %s: gdbstub directive malformed. " , context ) ) ;
}
2006-01-23 21:39:10 +03:00
}
2004-11-06 13:50:03 +03:00
else if ( ! strncmp ( params [ i ] , " port= " , 5 ) ) {
2006-04-25 19:59:20 +04:00
SIM - > get_param_num ( " port " , base ) - > set ( atoi ( & params [ i ] [ 5 ] ) ) ;
2006-01-23 21:39:10 +03:00
}
2004-11-06 13:50:03 +03:00
else if ( ! strncmp ( params [ i ] , " text_base= " , 10 ) ) {
2006-04-25 19:59:20 +04:00
SIM - > get_param_num ( " text_base " , base ) - > set ( atoi ( & params [ i ] [ 10 ] ) ) ;
2006-01-23 21:39:10 +03:00
}
2004-11-06 13:50:03 +03:00
else if ( ! strncmp ( params [ i ] , " data_base= " , 10 ) ) {
2006-04-25 19:59:20 +04:00
SIM - > get_param_num ( " data_base " , base ) - > set ( atoi ( & params [ i ] [ 10 ] ) ) ;
2006-01-23 21:39:10 +03:00
}
2004-11-06 13:50:03 +03:00
else if ( ! strncmp ( params [ i ] , " bss_base= " , 9 ) ) {
2006-04-25 19:59:20 +04:00
SIM - > get_param_num ( " bss_base " , base ) - > set ( atoi ( & params [ i ] [ 9 ] ) ) ;
2006-01-23 21:39:10 +03:00
}
2004-11-06 13:50:03 +03:00
else {
PARSE_ERR ( ( " %s: gdbstub directive malformed. " , context ) ) ;
}
2006-01-23 21:39:10 +03:00
}
2004-11-06 13:50:03 +03:00
# else
PARSE_ERR ( ( " %s: Bochs is not compiled with gdbstub support " , context ) ) ;
# endif
2013-07-20 20:13:07 +04:00
} else if ( ! strcmp ( params [ 0 ] , " magic_break " ) ) {
2008-01-22 00:36:58 +03:00
# if BX_DEBUGGER
2023-08-20 18:21:16 +03:00
bx_dbg . magic_break = 0 ;
2004-06-05 02:06:55 +04:00
if ( num_params ! = 2 ) {
PARSE_ERR ( ( " %s: magic_break directive: wrong # args. " , context ) ) ;
2006-01-23 21:39:10 +03:00
}
2004-06-05 02:06:55 +04:00
if ( strncmp ( params [ 1 ] , " enabled= " , 8 ) ) {
PARSE_ERR ( ( " %s: magic_break directive malformed. " , context ) ) ;
2006-01-23 21:39:10 +03:00
}
2004-06-05 02:06:55 +04:00
if ( params [ 1 ] [ 8 ] = = ' 0 ' ) {
BX_INFO ( ( " Ignoring magic break points " ) ) ;
2023-08-20 18:21:16 +03:00
} else if ( params [ 1 ] [ 8 ] = = ' 1 ' ) {
bx_dbg_set_magic_bp_mask ( bx_dbg_get_magic_bp_mask_from_str ( params [ 1 ] ) ) ;
if ( 0 = = bx_dbg . magic_break ) {
// bx if not specified for backward compatibility
bx_dbg_set_magic_bp_mask ( bx_dbg_get_magic_bp_mask_from_str ( " bx " ) ) ;
}
} else {
PARSE_ERR ( ( " %s: magic_break directive malformed " , context ) ) ;
2004-06-05 02:06:55 +04:00
}
2008-01-22 00:36:58 +03:00
# else
2010-02-10 01:14:54 +03:00
PARSE_WARN ( ( " %s: Bochs is not compiled with internal debugger support " , context ) ) ;
2004-06-05 02:06:55 +04:00
# endif
2013-07-20 20:13:07 +04:00
} else if ( ! strcmp ( params [ 0 ] , " debug_symbols " ) ) {
2009-05-03 23:21:38 +04:00
if ( parse_debug_symbols ( context , ( const char * * ) ( params + 1 ) , num_params - 1 ) < 0 ) {
2008-03-30 18:32:14 +04:00
return - 1 ;
}
2013-07-20 20:13:07 +04:00
} else if ( ! strcmp ( params [ 0 ] , " print_timestamps " ) ) {
2007-11-20 21:36:26 +03:00
if ( num_params ! = 2 ) {
PARSE_ERR ( ( " %s: print_timestamps directive: wrong # args. " , context ) ) ;
}
if ( strncmp ( params [ 1 ] , " enabled= " , 8 ) ) {
PARSE_ERR ( ( " %s: print_timestamps directive malformed. " , context ) ) ;
}
if ( params [ 1 ] [ 8 ] = = ' 0 ' | | params [ 1 ] [ 8 ] = = ' 1 ' ) {
bx_dbg . print_timestamps = params [ 1 ] [ 8 ] - ' 0 ' ;
}
else {
PARSE_ERR ( ( " %s: print_timestamps directive malformed. " , context ) ) ;
}
2013-07-20 20:13:07 +04:00
} else if ( ! strcmp ( params [ 0 ] , " port_e9_hack " ) ) {
2023-10-18 08:19:33 +03:00
for ( i = 1 ; i < num_params ; i + + ) {
if ( bx_parse_param_from_list ( context , params [ i ] , ( bx_list_c * ) SIM - > get_param ( BXPN_PORT_E9_HACK_ROOT ) ) < 0 ) {
PARSE_ERR ( ( " %s: port_e9_hack directive malformed. " , context ) ) ;
}
2009-04-23 22:28:17 +04:00
}
2023-08-27 19:34:01 +03:00
} else if ( ! strcmp ( params [ 0 ] , " iodebug " ) ) {
# if BX_SUPPORT_IODEBUG
if ( num_params ! = 2 ) {
PARSE_ERR ( ( " %s: iodebug directive: wrong # args. " , context ) ) ;
}
if ( ! strncmp ( params [ 1 ] , " all_rings= " , 10 ) ) {
if ( parse_param_bool ( params [ 1 ] , 10 , BXPN_IODEBUG_ALL_RINGS ) < 0 ) {
PARSE_ERR ( ( " %s: all_rings option malformed. " , context ) ) ;
}
} else {
PARSE_ERR ( ( " %s: iodebug: invalid parameter %s " , context , params [ 1 ] ) ) ;
}
# else
PARSE_WARN ( ( " %s: Bochs is not compiled with iodebug support " , context ) ) ;
# endif
2013-07-20 20:13:07 +04:00
} else if ( ! strcmp ( params [ 0 ] , " load32bitOSImage " ) ) {
2020-06-07 20:28:54 +03:00
PARSE_ERR ( ( " %s: load32bitOSImage: This legacy feature is no longer supported. " , context ) ) ;
2013-07-20 20:13:07 +04:00
} else if ( SIM - > is_addon_option ( params [ 0 ] ) ) {
// add-on options handled by registered functions
2011-12-23 14:03:10 +04:00
return SIM - > parse_addon_option ( context , num_params , & params [ 0 ] ) ;
2013-08-10 11:40:38 +04:00
} else if ( is_deprecated_option ( params [ 0 ] , & newparam ) ) {
PARSE_ERR ( ( " %s: '%s' is deprecated - use '%s' option instead. " , context , params [ 0 ] , newparam ) ) ;
2021-01-27 23:06:02 +03:00
} else if ( bx_opt_plugin_available ( params [ 0 ] ) ) {
2013-07-20 20:13:07 +04:00
// treat unknown option as plugin name and try to load it
2021-01-24 13:16:22 +03:00
if ( SIM - > opt_plugin_ctrl ( params [ 0 ] , 1 ) ) {
if ( SIM - > is_addon_option ( params [ 0 ] ) ) {
// after loading the plugin a bochsrc option with it's name must exist
return SIM - > parse_addon_option ( context , num_params , & params [ 0 ] ) ;
} else {
PARSE_ERR ( ( " %s: directive '%s' not understood " , context , params [ 0 ] ) ) ;
}
2012-07-08 23:35:58 +04:00
}
2013-07-20 20:13:07 +04:00
} else {
2008-02-16 01:05:43 +03:00
PARSE_ERR ( ( " %s: directive '%s' not understood " , context , params [ 0 ] ) ) ;
2005-10-10 23:32:53 +04:00
}
2004-06-05 02:06:55 +04:00
return 0 ;
}
2006-02-25 01:35:46 +03:00
2021-01-30 18:16:00 +03:00
int bx_write_param_list ( FILE * fp , bx_list_c * base , const char * optname , bool multiline )
2013-01-18 21:11:23 +04:00
{
2013-02-01 23:13:58 +04:00
char bxrcline [ BX_PATHNAME_LEN ] , tmpstr [ BX_PATHNAME_LEN ] ;
2021-01-30 18:16:00 +03:00
bool newline = 1 ;
2013-02-03 22:28:25 +04:00
int p = 0 ;
2013-01-18 21:11:23 +04:00
if ( base = = NULL ) return - 1 ;
2013-01-22 22:26:49 +04:00
if ( ! base - > get_enabled ( ) ) return - 1 ;
2013-02-03 22:28:25 +04:00
bxrcline [ 0 ] = 0 ;
2013-01-18 21:11:23 +04:00
for ( int i = 0 ; i < base - > get_size ( ) ; i + + ) {
2013-02-03 22:28:25 +04:00
if ( newline ) {
if ( strlen ( bxrcline ) > 0 ) {
fprintf ( fp , " %s \n " , bxrcline ) ;
}
if ( optname = = NULL ) {
sprintf ( bxrcline , " %s: " , base - > get_name ( ) ) ;
2020-03-04 20:37:34 +03:00
} else if ( isspace ( optname [ strlen ( optname ) - 1 ] ) ) {
sprintf ( bxrcline , " %s " , optname ) ;
2013-02-03 22:28:25 +04:00
} else {
sprintf ( bxrcline , " %s: " , optname ) ;
}
newline = 0 ;
p = 0 ;
}
2013-01-18 21:11:23 +04:00
bx_param_c * param = base - > get ( i ) ;
2013-01-30 20:43:58 +04:00
if ( param - > get_enabled ( ) & & ( ( param - > get_options ( ) & param - > CI_ONLY ) = = 0 ) ) {
2013-01-19 16:25:53 +04:00
if ( p > 0 ) {
strcat ( bxrcline , " , " ) ;
}
sprintf ( tmpstr , " %s= " , param - > get_name ( ) ) ;
strcat ( bxrcline , tmpstr ) ;
switch ( param - > get_type ( ) ) {
case BXT_PARAM_NUM :
case BXT_PARAM_BOOL :
case BXT_PARAM_ENUM :
case BXT_PARAM_STRING :
2018-02-02 22:04:59 +03:00
case BXT_PARAM_BYTESTRING :
2018-01-10 23:05:59 +03:00
param - > dump_param ( tmpstr , BX_PATHNAME_LEN , 1 ) ;
2013-01-19 16:25:53 +04:00
break ;
default :
BX_ERROR ( ( " bx_write_param_list(): unsupported parameter type " ) ) ;
2018-02-02 22:04:59 +03:00
tmpstr [ 0 ] = 0 ;
2013-01-19 16:25:53 +04:00
}
strcat ( bxrcline , tmpstr ) ;
p + + ;
2013-01-18 21:11:23 +04:00
}
2013-02-03 22:28:25 +04:00
if ( multiline & & ( strlen ( bxrcline ) > 80 ) ) {
newline = 1 ;
2013-01-18 21:11:23 +04:00
}
}
2013-02-03 22:28:25 +04:00
fprintf ( fp , " %s \n " , bxrcline ) ;
2013-01-18 21:11:23 +04:00
return 0 ;
}
2007-10-25 03:29:40 +04:00
static const char * fdtypes [ ] = {
2004-06-05 02:06:55 +04:00
" none " , " 1_2 " , " 1_44 " , " 2_88 " , " 720k " , " 360k " , " 160k " , " 180k " , " 320k "
} ;
2006-03-01 20:14:36 +03:00
int bx_write_floppy_options ( FILE * fp , int drive )
2004-06-05 02:06:55 +04:00
{
2010-07-03 15:13:40 +04:00
char devtype [ 80 ] , path [ 80 ] , type [ 80 ] , status [ 80 ] , readonly [ 80 ] ;
2009-03-24 14:20:17 +03:00
int ftype ;
2006-02-25 01:35:46 +03:00
BX_ASSERT ( drive = = 0 | | drive = = 1 ) ;
2009-03-24 14:20:17 +03:00
sprintf ( devtype , " floppy.%d.devtype " , drive ) ;
2006-02-25 01:35:46 +03:00
sprintf ( path , " floppy.%d.path " , drive ) ;
sprintf ( type , " floppy.%d.type " , drive ) ;
sprintf ( status , " floppy.%d.status " , drive ) ;
2010-07-03 15:13:40 +04:00
sprintf ( readonly , " floppy.%d.readonly " , drive ) ;
2009-03-24 14:20:17 +03:00
ftype = SIM - > get_param_enum ( devtype ) - > get ( ) ;
if ( ftype = = BX_FDD_NONE ) {
2006-02-25 01:35:46 +03:00
fprintf ( fp , " # no floppy%c \n " , ( char ) ' a ' + drive ) ;
2004-06-05 02:06:55 +04:00
return 0 ;
2009-03-24 14:20:17 +03:00
} else {
fprintf ( fp , " floppy%c: type= " , ( char ) ' a ' + drive ) ;
if ( ftype = = BX_FDD_350ED ) {
fprintf ( fp , " 2_88 " ) ;
} else if ( ftype = = BX_FDD_350HD ) {
fprintf ( fp , " 1_44 " ) ;
} else if ( ftype = = BX_FDD_525HD ) {
fprintf ( fp , " 1_2 " ) ;
} else if ( ftype = = BX_FDD_350DD ) {
fprintf ( fp , " 720k " ) ;
} else if ( ftype = = BX_FDD_525DD ) {
fprintf ( fp , " 360k " ) ;
}
}
if ( ( SIM - > get_param_enum ( type ) - > get ( ) > BX_FLOPPY_NONE ) & &
( SIM - > get_param_enum ( type ) - > get ( ) < = BX_FLOPPY_LAST ) ) {
2010-07-03 15:13:40 +04:00
fprintf ( fp , " , %s= \" %s \" , status=%s, write_protected=%d " ,
2009-03-24 14:20:17 +03:00
fdtypes [ SIM - > get_param_enum ( type ) - > get ( ) - BX_FLOPPY_NONE ] ,
SIM - > get_param_string ( path ) - > getptr ( ) ,
2013-01-23 21:56:57 +04:00
SIM - > get_param_enum ( status ) - > get_selected ( ) ,
2010-07-03 15:13:40 +04:00
SIM - > get_param_bool ( readonly ) - > get ( ) ) ;
2004-06-05 02:06:55 +04:00
}
2009-03-24 14:20:17 +03:00
fprintf ( fp , " \n " ) ;
2004-06-05 02:06:55 +04:00
return 0 ;
}
2021-03-03 20:47:15 +03:00
# if BX_SUPPORT_PCIUSB
2011-06-10 01:02:51 +04:00
int bx_write_usb_options ( FILE * fp , int maxports , bx_list_c * base )
2004-06-05 02:06:55 +04:00
{
2019-11-08 16:49:48 +03:00
char tmpname [ 24 ] , tmpstr [ BX_PATHNAME_LEN ] ;
2011-06-10 01:02:51 +04:00
2009-01-19 16:13:32 +03:00
fprintf ( fp , " usb_%s: enabled=%d " , base - > get_name ( ) , SIM - > get_param_bool ( " enabled " , base ) - > get ( ) ) ;
2023-10-23 17:01:45 +03:00
2023-10-23 07:53:22 +03:00
// if we are the ehci, we need to add the companion= parameter
2023-10-23 17:01:45 +03:00
if ( base = = SIM - > get_param ( BXPN_USB_EHCI ) )
fprintf ( fp , " , companion=%s " , SIM - > get_param_enum ( BXPN_EHCI_COMPANION ) - > get_selected ( ) ) ;
// if we are the xhci, we need to add the model= and n_ports= parameters
if ( base = = SIM - > get_param ( BXPN_USB_XHCI ) ) {
fprintf ( fp , " , model=%s " , SIM - > get_param_enum ( BXPN_XHCI_MODEL ) - > get_selected ( ) ) ;
fprintf ( fp , " , n_ports=%i " , SIM - > get_param_num ( BXPN_XHCI_N_PORTS ) - > get ( ) ) ;
}
2006-03-01 20:14:36 +03:00
if ( SIM - > get_param_bool ( " enabled " , base ) - > get ( ) ) {
2023-10-23 07:53:22 +03:00
for ( int i = 1 ; i < = maxports ; i + + ) {
2011-06-10 01:02:51 +04:00
sprintf ( tmpname , " port%d.device " , i ) ;
2021-02-15 19:09:02 +03:00
SIM - > get_param_enum ( tmpname , base ) - > dump_param ( tmpstr , BX_PATHNAME_LEN , 1 ) ;
2013-02-01 23:13:58 +04:00
fprintf ( fp , " , port%d=%s " , i , tmpstr ) ;
2011-06-10 01:02:51 +04:00
sprintf ( tmpname , " port%d.options " , i ) ;
2018-01-10 23:05:59 +03:00
SIM - > get_param_string ( tmpname , base ) - > dump_param ( tmpstr , BX_PATHNAME_LEN , 1 ) ;
2013-02-01 23:13:58 +04:00
fprintf ( fp , " , options%d=%s " , i , tmpstr ) ;
2011-06-10 01:02:51 +04:00
}
2004-06-05 02:06:55 +04:00
}
2006-03-01 20:14:36 +03:00
fprintf ( fp , " \n " ) ;
2004-06-05 02:06:55 +04:00
return 0 ;
}
2021-03-03 20:47:15 +03:00
# endif
2004-06-05 02:06:55 +04:00
2006-02-19 18:43:03 +03:00
int bx_write_clock_cmos_options ( FILE * fp )
2004-06-05 02:06:55 +04:00
{
2013-01-29 00:49:24 +04:00
fprintf ( fp , " clock: sync=%s " , SIM - > get_param_enum ( BXPN_CLOCK_SYNC ) - > get_selected ( ) ) ;
2004-06-05 02:06:55 +04:00
Porting #SF patch #565 Real Time Clock /CMOS fix (#4)
by Michele Giacomone
Detailed description:
-Observed issues
Due to some limitations only dates between 1980 and 2038 can be
used in a reliable way.
Also, bochs incorrectly assumes a linear correspondence between
the data returned by the <time.h> functions localtime() and
mktime(), and isn't setting the latter properly.
Bochs keeps its internal time value dependent to these functions
after setup, assuming that their internal settings won't change
on the go - which is not the case.
In my OS, and in my timezone, this leads to incorrect startup values
for 5 months each year and unreliable values if the simulation is
kept going for a long time. (a feedback between localtime() and
mktime() is created which keeps shifting back the time)
Also, the RTC simulation is not realistic since the clock fixes
itself across DST changes, without updating any DST related flag,
a behavior that no guest OS expects.
-Proposed fix
This is implemented in such way that no bochs' previous behavior
is changed, a part from the broken ones, with legacy in mind
== the user can keep using bochs exactly as before knowing nothing
of this patch
+Make the internal s.timeval variable a Bit64s, so it can fit all
values that the cmos can correctly represent, reported below:
MIN setting -62167219200 => 0000/01/01 SAT 0:00:00
MAX BCD setting 253402300799 => 9999/12/31 FRI 23:59:59
MAX BIN setting 745690751999 => 25599/12/31 FRI 23:59:59
And then fix each reference to these so it can handle such values
And make bochs correctly wrap around for under/overflows, so that
only the most significant bits of the century are lost.
+Do the same thing to the bochs time0 parameter, so all the above
values can be chosen at startup (despite being now legal values,
1 and 2 will still be treated as "local" and "utc"). Note that
normally only BCD settings are valid since bochs' CMOS defaults
to such operating mode - the only way to use the binary range
is by loading a cmos memory map.
+Make the internal s.timeval variable independent from external
factors. This means providing a small set of time handling
functions, contained in "iodev/utctime.h", which must work in
any environment in which bochs compiles, accessing no external
resource. This also means that after startup, s.timeval will only
be changed internally, and no call to the OS time functions will
be made.
+Make the internal s.timeval variable timezone independent, to
have a linear correlation between its values and valid CMOS
settings. To make it easier, s.timeval is gonna be treated as
if the current timezone was UTC: so,
- if the user selects UTC as time0, s.timeval will become current
time(NULL)
- if the user selects localtime, s.timeval will be computed as
the value which will display the same broken down time as
localtime(&now)
- if the user inputs a time formatted string the proper s.timeval
to displayed will be easily calculated,
- if the user inputs a starting time value, s.timeval will be
computed as the value which will display the same broken down
time as localtime(&user_input) to ensure the same operation as
before.
A "tz=utc" is displayed when bochs prints out the current time
value, to warn users about the difference in meaning between the
internally kept time value and the value they can set through
the "time0=" parameter. This might be changed to communicate
instead the time value they can input to get the same setting,
but performing such calculation (except for the startup time)
suffers from all the mktime()/localtime() problems listed above
so I did not do it.
The range of "time0" is automatically adjusted so all users in
all time zones can set any legal value despite "time0=" having a
local meaning.
A thorough explanation of what I did and why can be found in the
"iodev/utctime.h" library header.
---------
Co-authored-by: Stanislav Shwartsman <sshwarts@users.sourceforge.net>
Co-authored-by: Volker Ruppert <Volker.Ruppert@t-online.de>
2023-12-02 00:55:35 +03:00
switch ( SIM - > get_param_num ( BXPN_CLOCK_TIME0 ) - > get64 ( ) ) {
2008-02-06 01:57:43 +03:00
case BX_CLOCK_TIME0_LOCAL :
2006-02-19 18:43:03 +03:00
fprintf ( fp , " , time0=local " ) ;
2004-06-05 02:06:55 +04:00
break ;
2008-02-06 01:57:43 +03:00
case BX_CLOCK_TIME0_UTC :
2006-02-19 18:43:03 +03:00
fprintf ( fp , " , time0=utc " ) ;
2004-06-05 02:06:55 +04:00
break ;
2008-02-06 01:57:43 +03:00
default :
Porting #SF patch #565 Real Time Clock /CMOS fix (#4)
by Michele Giacomone
Detailed description:
-Observed issues
Due to some limitations only dates between 1980 and 2038 can be
used in a reliable way.
Also, bochs incorrectly assumes a linear correspondence between
the data returned by the <time.h> functions localtime() and
mktime(), and isn't setting the latter properly.
Bochs keeps its internal time value dependent to these functions
after setup, assuming that their internal settings won't change
on the go - which is not the case.
In my OS, and in my timezone, this leads to incorrect startup values
for 5 months each year and unreliable values if the simulation is
kept going for a long time. (a feedback between localtime() and
mktime() is created which keeps shifting back the time)
Also, the RTC simulation is not realistic since the clock fixes
itself across DST changes, without updating any DST related flag,
a behavior that no guest OS expects.
-Proposed fix
This is implemented in such way that no bochs' previous behavior
is changed, a part from the broken ones, with legacy in mind
== the user can keep using bochs exactly as before knowing nothing
of this patch
+Make the internal s.timeval variable a Bit64s, so it can fit all
values that the cmos can correctly represent, reported below:
MIN setting -62167219200 => 0000/01/01 SAT 0:00:00
MAX BCD setting 253402300799 => 9999/12/31 FRI 23:59:59
MAX BIN setting 745690751999 => 25599/12/31 FRI 23:59:59
And then fix each reference to these so it can handle such values
And make bochs correctly wrap around for under/overflows, so that
only the most significant bits of the century are lost.
+Do the same thing to the bochs time0 parameter, so all the above
values can be chosen at startup (despite being now legal values,
1 and 2 will still be treated as "local" and "utc"). Note that
normally only BCD settings are valid since bochs' CMOS defaults
to such operating mode - the only way to use the binary range
is by loading a cmos memory map.
+Make the internal s.timeval variable independent from external
factors. This means providing a small set of time handling
functions, contained in "iodev/utctime.h", which must work in
any environment in which bochs compiles, accessing no external
resource. This also means that after startup, s.timeval will only
be changed internally, and no call to the OS time functions will
be made.
+Make the internal s.timeval variable timezone independent, to
have a linear correlation between its values and valid CMOS
settings. To make it easier, s.timeval is gonna be treated as
if the current timezone was UTC: so,
- if the user selects UTC as time0, s.timeval will become current
time(NULL)
- if the user selects localtime, s.timeval will be computed as
the value which will display the same broken down time as
localtime(&now)
- if the user inputs a time formatted string the proper s.timeval
to displayed will be easily calculated,
- if the user inputs a starting time value, s.timeval will be
computed as the value which will display the same broken down
time as localtime(&user_input) to ensure the same operation as
before.
A "tz=utc" is displayed when bochs prints out the current time
value, to warn users about the difference in meaning between the
internally kept time value and the value they can set through
the "time0=" parameter. This might be changed to communicate
instead the time value they can input to get the same setting,
but performing such calculation (except for the startup time)
suffers from all the mktime()/localtime() problems listed above
so I did not do it.
The range of "time0" is automatically adjusted so all users in
all time zones can set any legal value despite "time0=" having a
local meaning.
A thorough explanation of what I did and why can be found in the
"iodev/utctime.h" library header.
---------
Co-authored-by: Stanislav Shwartsman <sshwarts@users.sourceforge.net>
Co-authored-by: Volker Ruppert <Volker.Ruppert@t-online.de>
2023-12-02 00:55:35 +03:00
fprintf ( fp , " , time0= " FMT_LL " d " , SIM - > get_param_num ( BXPN_CLOCK_TIME0 ) - > get64 ( ) ) ;
2004-06-05 02:06:55 +04:00
}
2012-05-15 21:03:45 +04:00
fprintf ( fp , " , rtc_sync=%d \n " , SIM - > get_param_bool ( BXPN_CLOCK_RTC_SYNC ) - > get ( ) ) ;
2006-02-19 18:43:03 +03:00
if ( strlen ( SIM - > get_param_string ( BXPN_CMOSIMAGE_PATH ) - > getptr ( ) ) > 0 ) {
fprintf ( fp , " cmosimage: file=%s, " , SIM - > get_param_string ( BXPN_CMOSIMAGE_PATH ) - > getptr ( ) ) ;
2007-12-07 01:21:40 +03:00
fprintf ( fp , " rtc_init=%s \n " , SIM - > get_param_bool ( BXPN_CMOSIMAGE_RTC_INIT ) - > get ( ) ? " image " : " time0 " ) ;
2006-02-19 18:43:03 +03:00
} else {
fprintf ( fp , " # no cmosimage \n " ) ;
}
2004-06-05 02:06:55 +04:00
return 0 ;
}
2006-03-05 13:24:29 +03:00
int bx_write_log_options ( FILE * fp , bx_list_c * base )
2004-06-05 02:06:55 +04:00
{
2013-02-03 22:28:25 +04:00
char pname [ 20 ] ;
2013-02-04 22:51:07 +04:00
bx_list_c * logfn , * loglev ;
2013-02-03 22:28:25 +04:00
bx_param_num_c * mparam ;
2013-02-04 22:51:07 +04:00
int action , def_action , level , mod ;
2013-02-03 22:28:25 +04:00
2006-03-05 13:24:29 +03:00
fprintf ( fp , " log: %s \n " , SIM - > get_param_string ( " filename " , base ) - > getptr ( ) ) ;
fprintf ( fp , " logprefix: %s \n " , SIM - > get_param_string ( " prefix " , base ) - > getptr ( ) ) ;
2013-02-03 22:28:25 +04:00
strcpy ( pname , " general.logfn " ) ;
logfn = ( bx_list_c * ) SIM - > get_param ( pname ) ;
2013-02-04 22:51:07 +04:00
for ( level = 0 ; level < N_LOGLEV ; level + + ) {
loglev = ( bx_list_c * ) logfn - > get ( level ) ;
def_action = SIM - > get_default_log_action ( level ) ;
fprintf ( fp , " %s: action=%s " , loglev - > get_name ( ) , SIM - > get_action_name ( def_action ) ) ;
// stage #1: save log actions of existing modules
for ( mod = 0 ; mod < SIM - > get_n_log_modules ( ) ; mod + + ) {
action = SIM - > get_log_action ( mod , level ) ;
if ( action ! = def_action ) {
fprintf ( fp , " , %s=%s " , SIM - > get_logfn_name ( mod ) , SIM - > get_action_name ( action ) ) ;
}
}
// stage #2: save log actions of not yet existing modules (from bochsrc)
for ( mod = 0 ; mod < loglev - > get_size ( ) ; mod + + ) {
mparam = ( bx_param_num_c * ) loglev - > get ( mod ) ;
action = mparam - > get ( ) ;
if ( ( action > = 0 ) & & ( action ! = def_action ) ) {
fprintf ( fp , " , %s=%s " , mparam - > get_name ( ) , SIM - > get_action_name ( action ) ) ;
2013-02-03 22:28:25 +04:00
}
}
2013-02-04 22:51:07 +04:00
fprintf ( fp , " \n " ) ;
2013-02-03 22:28:25 +04:00
}
2004-06-05 02:06:55 +04:00
return 0 ;
}
2009-05-08 18:53:45 +04:00
int bx_write_debugger_options ( FILE * fp )
{
# if BX_DEBUGGER
fprintf ( fp , " debugger_log: %s \n " , SIM - > get_param_string ( BXPN_DEBUGGER_LOG_FILENAME ) - > getptr ( ) ) ;
2023-08-20 18:21:16 +03:00
fprintf ( fp , " magic_break: enabled=1 0x%x \n " , bx_dbg . magic_break ) ;
2009-05-08 18:53:45 +04:00
// TODO: debug symbols
# endif
# if BX_GDBSTUB
bx_list_c * base = ( bx_list_c * ) SIM - > get_param ( BXPN_GDBSTUB ) ;
2021-01-30 18:16:00 +03:00
bool enabled = SIM - > get_param_bool ( " enabled " , base ) - > get ( ) ;
2009-05-08 18:53:45 +04:00
if ( enabled ) {
fprintf ( fp , " gdbstub: enabled=%d, port=%d, text_base=%d, data_base=%d, bss_base=%d \n " ,
enabled , SIM - > get_param_num ( " port " , base ) - > get ( ) , SIM - > get_param_num ( " text_base " , base ) - > get ( ) ,
SIM - > get_param_num ( " data_base " , base ) - > get ( ) , SIM - > get_param_num ( " bss_base " , base ) - > get ( ) ) ;
} else {
fprintf ( fp , " # no gdb stub \n " ) ;
}
# endif
return 0 ;
}
2004-06-05 02:06:55 +04:00
// return values:
// 0: written ok
// -1: failed
// -2: already exists, and overwrite was off
2006-03-13 21:55:53 +03:00
int bx_write_configuration ( const char * rc , int overwrite )
2004-06-05 02:06:55 +04:00
{
2004-07-03 03:18:21 +04:00
int i ;
2017-02-14 23:11:58 +03:00
char pname [ 16 ] , tmppath [ 80 ] , tmpdev [ 80 ] ;
2013-02-03 16:14:29 +04:00
bx_param_string_c * sparam ;
2006-02-26 22:11:20 +03:00
bx_list_c * base ;
2006-06-05 21:33:25 +04:00
BX_INFO ( ( " write current configuration to %s " , rc ) ) ;
2004-06-05 02:06:55 +04:00
// check if it exists. If so, only proceed if overwrite is set.
2006-02-22 00:35:09 +03:00
FILE * fp = fopen ( rc , " r " ) ;
2004-06-05 02:06:55 +04:00
if ( fp ! = NULL ) {
2006-02-22 00:35:09 +03:00
fclose ( fp ) ;
2004-06-05 02:06:55 +04:00
if ( ! overwrite ) return - 2 ;
}
2006-02-22 00:35:09 +03:00
fp = fopen ( rc , " w " ) ;
2004-06-05 02:06:55 +04:00
if ( fp = = NULL ) return - 1 ;
// finally it's open and we can start writing.
2006-02-22 00:35:09 +03:00
fprintf ( fp , " # configuration file generated by Bochs \n " ) ;
2013-01-25 22:37:03 +04:00
bx_write_param_list ( fp , ( bx_list_c * ) SIM - > get_param ( BXPN_PLUGIN_CTRL ) , NULL , 0 ) ;
2006-02-22 00:35:09 +03:00
fprintf ( fp , " config_interface: %s \n " , SIM - > get_param_enum ( BXPN_SEL_CONFIG_INTERFACE ) - > get_selected ( ) ) ;
fprintf ( fp , " display_library: %s " , SIM - > get_param_enum ( BXPN_SEL_DISPLAY_LIBRARY ) - > get_selected ( ) ) ;
2013-02-03 16:14:29 +04:00
sparam = SIM - > get_param_string ( BXPN_DISPLAYLIB_OPTIONS ) ;
if ( ! sparam - > isempty ( ) )
fprintf ( fp , " , options= \" %s \" \n " , sparam - > getptr ( ) ) ;
2004-06-05 02:06:55 +04:00
else
2006-02-26 22:11:20 +03:00
fprintf ( fp , " \n " ) ;
2017-02-14 00:14:34 +03:00
2023-11-07 16:40:20 +03:00
bx_write_param_list ( fp , ( bx_list_c * ) SIM - > get_param ( BXPN_MEMORY ) , " memory " , 0 ) ;
2017-02-14 00:14:34 +03:00
bx_write_param_list ( fp , ( bx_list_c * ) SIM - > get_param ( BXPN_ROMIMAGE ) , " romimage " , 0 ) ;
bx_write_param_list ( fp , ( bx_list_c * ) SIM - > get_param ( BXPN_VGA_ROMIMAGE ) , " vgaromimage " , 0 ) ;
2006-02-24 01:48:57 +03:00
fprintf ( fp , " boot: %s " , SIM - > get_param_enum ( BXPN_BOOTDRIVE1 ) - > get_selected ( ) ) ;
2004-10-16 19:44:00 +04:00
for ( i = 1 ; i < 3 ; i + + ) {
2006-02-24 01:48:57 +03:00
sprintf ( tmppath , " boot_params.boot_drive%d " , i + 1 ) ;
if ( SIM - > get_param_enum ( tmppath ) - > get ( ) ! = BX_BOOT_NONE ) {
fprintf ( fp , " , %s " , SIM - > get_param_enum ( tmppath ) - > get_selected ( ) ) ;
2004-10-16 19:44:00 +04:00
}
}
2006-02-24 01:48:57 +03:00
fprintf ( fp , " \n " ) ;
fprintf ( fp , " floppy_bootsig_check: disabled=%d \n " , SIM - > get_param_bool ( BXPN_FLOPPYSIGCHECK ) - > get ( ) ) ;
2004-06-05 02:06:55 +04:00
// it would be nice to put this type of function as methods on
// the structs like bx_floppy_options::print or something.
2006-02-25 01:35:46 +03:00
bx_write_floppy_options ( fp , 0 ) ;
bx_write_floppy_options ( fp , 1 ) ;
2004-06-05 02:06:55 +04:00
for ( Bit8u channel = 0 ; channel < BX_MAX_ATA_CHANNEL ; channel + + ) {
2006-02-26 22:11:20 +03:00
sprintf ( tmppath , " ata.%d " , channel ) ;
base = ( bx_list_c * ) SIM - > get_param ( tmppath ) ;
2013-01-20 02:37:15 +04:00
sprintf ( tmppath , " ata%d " , channel ) ;
bx_write_param_list ( fp , ( bx_list_c * ) SIM - > get_param ( " resources " , base ) , tmppath , 0 ) ;
2013-01-22 22:26:49 +04:00
sprintf ( tmppath , " ata%d-master " , channel ) ;
bx_write_param_list ( fp , ( bx_list_c * ) SIM - > get_param ( " master " , base ) , tmppath , 0 ) ;
sprintf ( tmppath , " ata%d-slave " , channel ) ;
bx_write_param_list ( fp , ( bx_list_c * ) SIM - > get_param ( " slave " , base ) , tmppath , 0 ) ;
2006-01-23 21:39:10 +03:00
}
2005-10-28 10:33:53 +04:00
for ( i = 0 ; i < BX_N_OPTROM_IMAGES ; i + + ) {
2017-02-14 23:11:58 +03:00
sprintf ( pname , " %s.%d " , BXPN_OPTROM_BASE , i + 1 ) ;
sprintf ( tmppath , " optromimage%d " , i + 1 ) ;
bx_write_param_list ( fp , ( bx_list_c * ) SIM - > get_param ( pname ) , tmppath , 0 ) ;
2004-09-28 21:37:52 +04:00
}
2006-02-17 00:44:17 +03:00
for ( i = 0 ; i < BX_N_OPTRAM_IMAGES ; i + + ) {
2017-02-14 23:11:58 +03:00
sprintf ( pname , " %s.%d " , BXPN_OPTRAM_BASE , i + 1 ) ;
sprintf ( tmppath , " optramimage%d " , i + 1 ) ;
bx_write_param_list ( fp , ( bx_list_c * ) SIM - > get_param ( pname ) , tmppath , 0 ) ;
2005-10-28 04:12:27 +04:00
}
2004-07-03 03:18:21 +04:00
// pci
2011-07-12 19:29:04 +04:00
fprintf ( fp , " pci: enabled=%d " ,
2012-11-11 12:11:17 +04:00
SIM - > get_param_bool ( BXPN_PCI_ENABLED ) - > get ( ) ) ;
if ( SIM - > get_param_bool ( BXPN_PCI_ENABLED ) - > get ( ) ) {
fprintf ( fp , " , chipset=%s " , SIM - > get_param_enum ( BXPN_PCI_CHIPSET ) - > get_selected ( ) ) ;
2004-07-03 03:18:21 +04:00
for ( i = 0 ; i < BX_N_PCI_SLOTS ; i + + ) {
2006-02-20 00:35:50 +03:00
sprintf ( tmpdev , " pci.slot.%d " , i + 1 ) ;
2021-02-27 13:23:05 +03:00
fprintf ( fp , " , slot%d=%s " , i + 1 , SIM - > get_param_enum ( tmpdev ) - > get_selected ( ) ) ;
2004-07-03 03:18:21 +04:00
}
2021-02-10 00:32:35 +03:00
sparam = SIM - > get_param_string ( BXPN_PCI_ADV_OPTS ) ;
if ( strlen ( sparam - > getptr ( ) ) > 0 ) {
2021-02-27 13:23:05 +03:00
fprintf ( fp , " , advopts= \" %s \" " , sparam - > getptr ( ) ) ;
2021-02-10 00:32:35 +03:00
}
2004-07-03 03:18:21 +04:00
}
2006-02-26 22:11:20 +03:00
fprintf ( fp , " \n " ) ;
2020-03-21 21:00:02 +03:00
fprintf ( fp , " vga: extension=%s, update_freq=%u, realtime=%u, ddc=%s " ,
2021-02-19 19:05:56 +03:00
SIM - > get_param_enum ( BXPN_VGA_EXTENSION ) - > get_selected ( ) ,
2014-11-15 13:22:27 +03:00
SIM - > get_param_num ( BXPN_VGA_UPDATE_FREQUENCY ) - > get ( ) ,
2020-03-21 21:00:02 +03:00
SIM - > get_param_bool ( BXPN_VGA_REALTIME ) - > get ( ) ,
SIM - > get_param_enum ( BXPN_DDC_MODE ) - > get_selected ( ) ) ;
if ( SIM - > get_param_enum ( BXPN_DDC_MODE ) - > get ( ) = = BX_DDC_MODE_FILE ) {
fprintf ( fp , " :%s " , SIM - > get_param_string ( BXPN_DDC_FILE ) - > getptr ( ) ) ;
}
fprintf ( fp , " \n " ) ;
2006-02-11 18:28:43 +03:00
# if BX_SUPPORT_SMP
2008-12-28 23:49:03 +03:00
fprintf ( fp , " cpu: count=%u:%u:%u, ips=%u, quantum=%d, " ,
2006-02-18 19:53:18 +03:00
SIM - > get_param_num ( BXPN_CPU_NPROCESSORS ) - > get ( ) , SIM - > get_param_num ( BXPN_CPU_NCORES ) - > get ( ) ,
SIM - > get_param_num ( BXPN_CPU_NTHREADS ) - > get ( ) , SIM - > get_param_num ( BXPN_IPS ) - > get ( ) ,
2008-12-28 23:49:03 +03:00
SIM - > get_param_num ( BXPN_SMP_QUANTUM ) - > get ( ) ) ;
2006-02-11 18:28:43 +03:00
# else
2008-12-28 23:49:03 +03:00
fprintf ( fp , " cpu: count=1, ips=%u, " , SIM - > get_param_num ( BXPN_IPS ) - > get ( ) ) ;
# endif
2011-07-29 19:18:39 +04:00
fprintf ( fp , " model=%s, reset_on_triple_fault=%d, cpuid_limit_winnt=%d " ,
SIM - > get_param_enum ( BXPN_CPU_MODEL ) - > get_selected ( ) ,
2011-07-29 19:03:54 +04:00
SIM - > get_param_bool ( BXPN_RESET_ON_TRIPLE_FAULT ) - > get ( ) ,
SIM - > get_param_bool ( BXPN_CPUID_LIMIT_WINNT ) - > get ( ) ) ;
2009-11-13 18:55:46 +03:00
# if BX_CPU_LEVEL >= 5
fprintf ( fp , " , ignore_bad_msrs=%d " , SIM - > get_param_bool ( BXPN_IGNORE_BAD_MSRS ) - > get ( ) ) ;
# endif
2012-03-15 23:46:57 +04:00
# if BX_SUPPORT_MONITOR_MWAIT
fprintf ( fp , " , mwait_is_nop=%d " , SIM - > get_param_bool ( BXPN_MWAIT_IS_NOP ) - > get ( ) ) ;
# endif
2008-12-28 23:49:03 +03:00
# if BX_CONFIGURE_MSRS
2013-02-03 16:14:29 +04:00
sparam = SIM - > get_param_string ( BXPN_CONFIGURABLE_MSRS_PATH ) ;
if ( ! sparam - > isempty ( ) )
fprintf ( fp , " , msrs= \" %s \" " , sparam - > getptr ( ) ) ;
2010-02-26 01:04:31 +03:00
# endif
fprintf ( fp , " \n " ) ;
2011-02-25 18:05:48 +03:00
# if BX_CPU_LEVEL >= 4
2012-03-15 23:55:14 +04:00
if ( ! SIM - > get_param_enum ( BXPN_CPU_MODEL ) - > get ( ) ) {
// dump only when using BX_GENERIC CPUDB profile
2013-01-20 02:37:15 +04:00
bx_write_param_list ( fp , ( bx_list_c * ) SIM - > get_param ( " cpuid " ) , NULL , 1 ) ;
2012-03-15 23:55:14 +04:00
}
2011-02-25 18:05:48 +03:00
# endif
2010-07-17 01:03:52 +04:00
2009-04-23 22:28:17 +04:00
fprintf ( fp , " print_timestamps: enabled=%d \n " , bx_dbg . print_timestamps ) ;
2009-05-08 18:53:45 +04:00
bx_write_debugger_options ( fp ) ;
2023-10-18 08:19:33 +03:00
bx_write_param_list ( fp , ( bx_list_c * ) SIM - > get_param ( BXPN_PORT_E9_HACK_ROOT ) , NULL , 0 ) ;
# if BX_SUPPORT_IODEBUG
2023-08-27 19:34:01 +03:00
fprintf ( fp , " iodebug_all_rings: enabled=%d \n " , SIM - > get_param_bool ( BXPN_IODEBUG_ALL_RINGS ) - > get ( ) ) ;
2023-10-18 08:19:33 +03:00
# endif
2006-02-26 22:11:20 +03:00
fprintf ( fp , " private_colormap: enabled=%d \n " , SIM - > get_param_bool ( BXPN_PRIVATE_COLORMAP ) - > get ( ) ) ;
2004-06-05 02:06:55 +04:00
# if BX_WITH_AMIGAOS
2006-02-26 22:11:20 +03:00
fprintf ( fp , " fullscreen: enabled=%d \n " , SIM - > get_param_bool ( BXPN_FULLSCREEN ) - > get ( ) ) ;
fprintf ( fp , " screenmode: name= \" %s \" \n " , SIM - > get_param_string ( BXPN_SCREENMODE ) - > getptr ( ) ) ;
2004-06-05 02:06:55 +04:00
# endif
2006-02-19 18:43:03 +03:00
bx_write_clock_cmos_options ( fp ) ;
2006-03-05 13:24:29 +03:00
bx_write_log_options ( fp , ( bx_list_c * ) SIM - > get_param ( " log " ) ) ;
2013-01-27 23:09:24 +04:00
bx_write_param_list ( fp , ( bx_list_c * ) SIM - > get_param ( BXPN_KEYBOARD ) , NULL , 0 ) ;
2013-01-20 02:37:15 +04:00
bx_write_param_list ( fp , ( bx_list_c * ) SIM - > get_param ( BXPN_MOUSE ) , NULL , 0 ) ;
2014-02-19 20:39:32 +04:00
bx_write_param_list ( fp , ( bx_list_c * ) SIM - > get_param ( BXPN_SOUNDLOW ) , " sound " , 0 ) ;
2011-12-23 14:03:10 +04:00
SIM - > save_addon_options ( fp ) ;
2006-02-26 22:11:20 +03:00
fclose ( fp ) ;
2004-06-05 02:06:55 +04:00
return 0 ;
}