- min and max in shadow params were broken recently when I changed the

constructors around.  The min,max that were being passed to the parent
  class constructor had junk in them.  In config.h.in, I defined the minimum
  and maximum values for each integer datatype so now we pass correct
  min and max values to the parent class.  These replace the BX_MAX_[U]INT
  and BX_MIN_[U]INT values.
- modified: main.cc config.h.in gui/siminterface.cc
This commit is contained in:
Bryce Denney 2002-10-21 11:13:54 +00:00
parent 8047b68ba2
commit cd4d17a363
3 changed files with 50 additions and 39 deletions

View File

@ -450,14 +450,25 @@ typedef Bit32u bx_address;
#endif
#define BX_MAX_UINT 4294967295
#define BX_MAX_INT 2147483647
#define BX_MIN_UINT 0
#define BX_MIN_INT -2147483647
// I would think BX_MIN_INT should be -2147483648 because that's the smallest
// representable number in 32bit unsigned. But gcc gives warnings, probably
// because it has to parse the 2147483648 first and then negate it.
// technically, in an 8 bit signed the real minimum is -128, not -127.
// But if you decide to negate -128 you tend to get -128 again, so it's
// better not to use the absolute maximum in the signed range.
#define BX_MAX_BIT64U ( (Bit64u) -1 )
#define BX_MIN_BIT64U ( 0 )
#define BX_MAX_BIT64S ( ((Bit64u) -1) >> 1 )
#define BX_MIN_BIT64S ( -(((Bit64u) -1) >> 1) )
#define BX_MAX_BIT32U ( (Bit32u) -1 )
#define BX_MIN_BIT32U ( 0 )
#define BX_MAX_BIT32S ( ((Bit32u) -1) >> 1 )
#define BX_MIN_BIT32S ( -(((Bit32u) -1) >> 1) )
#define BX_MAX_BIT16U ( (Bit16u) -1 )
#define BX_MIN_BIT16U ( 0 )
#define BX_MAX_BIT16S ( ((Bit16u) -1) >> 1 )
#define BX_MIN_BIT16S ( -(((Bit16u) -1) >> 1) )
#define BX_MAX_BIT8U ( (Bit8u) -1 )
#define BX_MIN_BIT8U ( 0 )
#define BX_MAX_BIT8S ( ((Bit8u) -1) >> 1 )
#define BX_MIN_BIT8S ( -(((Bit8u) -1) >> 1) )
// create an unsigned integer type that is the same size as a pointer.

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: siminterface.cc,v 1.75 2002-10-21 01:05:53 bdenney Exp $
// $Id: siminterface.cc,v 1.76 2002-10-21 11:13:54 bdenney Exp $
/////////////////////////////////////////////////////////////////////////
//
// See siminterface.h for description of the siminterface concept.
@ -796,7 +796,7 @@ bx_shadow_num_c::bx_shadow_num_c (bx_id id,
Bit64s *ptr_to_real_val,
Bit8u highbit,
Bit8u lowbit)
: bx_param_num_c (id, name, description, min, max, *ptr_to_real_val)
: bx_param_num_c (id, name, description, BX_MIN_BIT64S, BX_MAX_BIT64S, *ptr_to_real_val)
{
this->varsize = 16;
this->lowbit = lowbit;
@ -811,7 +811,7 @@ bx_shadow_num_c::bx_shadow_num_c (bx_id id,
Bit64u *ptr_to_real_val,
Bit8u highbit,
Bit8u lowbit)
: bx_param_num_c (id, name, description, min, max, *ptr_to_real_val)
: bx_param_num_c (id, name, description, BX_MIN_BIT64U, BX_MAX_BIT64U, *ptr_to_real_val)
{
this->varsize = 16;
this->lowbit = lowbit;
@ -826,7 +826,7 @@ bx_shadow_num_c::bx_shadow_num_c (bx_id id,
Bit32s *ptr_to_real_val,
Bit8u highbit,
Bit8u lowbit)
: bx_param_num_c (id, name, description, min, max, *ptr_to_real_val)
: bx_param_num_c (id, name, description, BX_MIN_BIT32S, BX_MAX_BIT32S, *ptr_to_real_val)
{
this->varsize = 16;
this->lowbit = lowbit;
@ -841,7 +841,7 @@ bx_shadow_num_c::bx_shadow_num_c (bx_id id,
Bit32u *ptr_to_real_val,
Bit8u highbit,
Bit8u lowbit)
: bx_param_num_c (id, name, description, min, max, *ptr_to_real_val)
: bx_param_num_c (id, name, description, BX_MIN_BIT32U, BX_MAX_BIT32U, *ptr_to_real_val)
{
this->varsize = 32;
this->lowbit = lowbit;
@ -856,7 +856,7 @@ bx_shadow_num_c::bx_shadow_num_c (bx_id id,
Bit16s *ptr_to_real_val,
Bit8u highbit,
Bit8u lowbit)
: bx_param_num_c (id, name, description, min, max, *ptr_to_real_val)
: bx_param_num_c (id, name, description, BX_MIN_BIT16S, BX_MAX_BIT16S, *ptr_to_real_val)
{
this->varsize = 16;
this->lowbit = lowbit;
@ -871,7 +871,7 @@ bx_shadow_num_c::bx_shadow_num_c (bx_id id,
Bit16u *ptr_to_real_val,
Bit8u highbit,
Bit8u lowbit)
: bx_param_num_c (id, name, description, min, max, *ptr_to_real_val)
: bx_param_num_c (id, name, description, BX_MIN_BIT16U, BX_MAX_BIT16U, *ptr_to_real_val)
{
this->varsize = 16;
this->lowbit = lowbit;
@ -886,7 +886,7 @@ bx_shadow_num_c::bx_shadow_num_c (bx_id id,
Bit8s *ptr_to_real_val,
Bit8u highbit,
Bit8u lowbit)
: bx_param_num_c (id, name, description, min, max, *ptr_to_real_val)
: bx_param_num_c (id, name, description, BX_MIN_BIT8S, BX_MAX_BIT8S, *ptr_to_real_val)
{
this->varsize = 16;
this->lowbit = lowbit;
@ -901,7 +901,7 @@ bx_shadow_num_c::bx_shadow_num_c (bx_id id,
Bit8u *ptr_to_real_val,
Bit8u highbit,
Bit8u lowbit)
: bx_param_num_c (id, name, description, min, max, *ptr_to_real_val)
: bx_param_num_c (id, name, description, BX_MIN_BIT8U, BX_MAX_BIT8U, *ptr_to_real_val)
{
this->varsize = 8;
this->lowbit = lowbit;
@ -1017,7 +1017,7 @@ bx_param_enum_c::bx_param_enum_c (bx_id id,
char **choices,
Bit64s initial_val,
Bit64s value_base)
: bx_param_num_c (id, name, description, value_base, BX_MAX_INT, initial_val)
: bx_param_num_c (id, name, description, value_base, BX_MAX_BIT64S, initial_val)
{
set_type (BXT_PARAM_ENUM);
this->choices = choices;
@ -1025,7 +1025,7 @@ bx_param_enum_c::bx_param_enum_c (bx_id id,
char **p = choices;
while (*p != NULL) p++;
this->min = value_base;
// now that the max is known, replace the BX_MAX_INT sent to the parent
// now that the max is known, replace the BX_MAX_BIT64S sent to the parent
// class constructor with the real max.
this->max = value_base + (p - choices - 1);
set (initial_val);
@ -1048,7 +1048,7 @@ bx_param_string_c::bx_param_string_c (bx_id id,
strncpy (this->val, initial_val, maxsize);
strncpy (this->initial_val, initial_val, maxsize);
this->options = new bx_param_num_c (BXP_NULL,
"stringoptions", NULL, 0, BX_MAX_INT, 0);
"stringoptions", NULL, 0, BX_MAX_BIT64S, 0);
set (initial_val);
}
@ -1190,10 +1190,10 @@ bx_list_c::init ()
"",
get_name (), 80);
this->options = new bx_param_num_c (BXP_NULL,
"list_option", "", 0, BX_MAX_INT,
"list_option", "", 0, BX_MAX_BIT64S,
0);
this->choice = new bx_param_num_c (BXP_NULL,
"list_choice", "", 0, BX_MAX_INT,
"list_choice", "", 0, BX_MAX_BIT64S,
1);
this->parent = NULL;
}

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: main.cc,v 1.160 2002-10-16 19:39:27 bdenney Exp $
// $Id: main.cc,v 1.161 2002-10-21 11:13:53 bdenney Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -721,7 +721,7 @@ void bx_init_options ()
bx_options.memory.Osize = new bx_param_num_c (BXP_MEM_SIZE,
"megs",
"Amount of RAM in megabytes",
1, BX_MAX_INT,
1, BX_MAX_BIT32U,
BX_DEFAULT_MEM_MEGS);
bx_options.memory.Osize->set_format ("Memory size in megabytes: %d");
bx_options.memory.Osize->set_ask_format ("Enter memory size (MB): [%d] ");
@ -795,7 +795,7 @@ void bx_init_options ()
bx_options.rom.Oaddress = new bx_param_num_c (BXP_ROM_ADDRESS,
"romaddr",
"The address at which the ROM image should be loaded",
0, BX_MAX_INT,
0, BX_MAX_BIT32U,
0xf0000);
bx_options.rom.Oaddress->set_format ("ROM BIOS address: 0x%05x");
bx_options.rom.Oaddress->set_base (16);
@ -808,7 +808,7 @@ void bx_init_options ()
bx_options.optrom[0].Oaddress = new bx_param_num_c (BXP_OPTROM1_ADDRESS,
"optional romaddr #1",
"The address at which the optional ROM image #1 should be loaded",
0, BX_MAX_INT,
0, BX_MAX_BIT32U,
0);
bx_options.optrom[0].Oaddress->set_format ("optional ROM #1 address: 0x%05x");
bx_options.optrom[0].Oaddress->set_base (16);
@ -821,7 +821,7 @@ void bx_init_options ()
bx_options.optrom[1].Oaddress = new bx_param_num_c (BXP_OPTROM2_ADDRESS,
"optional romaddr #2",
"The address at which the optional ROM image #2 should be loaded",
0, BX_MAX_INT,
0, BX_MAX_BIT32U,
0);
bx_options.optrom[1].Oaddress->set_format ("optional ROM #2 address: 0x%05x");
bx_options.optrom[1].Oaddress->set_base (16);
@ -834,7 +834,7 @@ void bx_init_options ()
bx_options.optrom[2].Oaddress = new bx_param_num_c (BXP_OPTROM3_ADDRESS,
"optional romaddr #3",
"The address at which the optional ROM image #3 should be loaded",
0, BX_MAX_INT,
0, BX_MAX_BIT32U,
0);
bx_options.optrom[2].Oaddress->set_format ("optional ROM #3 address: 0x%05x");
bx_options.optrom[2].Oaddress->set_base (16);
@ -847,7 +847,7 @@ void bx_init_options ()
bx_options.optrom[3].Oaddress = new bx_param_num_c (BXP_OPTROM4_ADDRESS,
"optional romaddr #4",
"The address at which the optional ROM image #4 should be loaded",
0, BX_MAX_INT,
0, BX_MAX_BIT32U,
0);
bx_options.optrom[3].Oaddress->set_format ("optional ROM #4 address: 0x%05x");
bx_options.optrom[3].Oaddress->set_base (16);
@ -879,7 +879,7 @@ void bx_init_options ()
bx_options.Ovga_update_interval = new bx_param_num_c (BXP_VGA_UPDATE_INTERVAL,
"VGA Update Interval",
"Number of microseconds between VGA updates",
1, BX_MAX_INT,
1, BX_MAX_BIT32U,
30000);
bx_options.Ovga_update_interval->set_handler (bx_param_handler);
bx_options.Ovga_update_interval->set_ask_format ("Type a new value for VGA update interval: [%d] ");
@ -891,7 +891,7 @@ void bx_init_options ()
bx_options.Oips = new bx_param_num_c (BXP_IPS,
"Emulated instructions per second (IPS)",
"Emulated instructions per second, used to calibrate bochs emulated\ntime with wall clock time.",
1, BX_MAX_INT,
1, BX_MAX_BIT32U,
500000);
bx_options.Oprivate_colormap = new bx_param_bool_c (BXP_PRIVATE_COLORMAP,
"Use a private colormap",
@ -992,22 +992,22 @@ void bx_init_options ()
bx_options.sb16.Omidimode = new bx_param_num_c (BXP_SB16_MIDIMODE,
"Midi mode",
"to be written",
0, BX_MAX_INT,
0, BX_MAX_BIT32U,
0);
bx_options.sb16.Owavemode = new bx_param_num_c (BXP_SB16_WAVEMODE,
"Wave mode",
"to be written",
0, BX_MAX_INT,
0, BX_MAX_BIT32U,
0);
bx_options.sb16.Ologlevel = new bx_param_num_c (BXP_SB16_LOGLEVEL,
"Log mode",
"to be written",
0, BX_MAX_INT,
0, BX_MAX_BIT32U,
0);
bx_options.sb16.Odmatimer = new bx_param_num_c (BXP_SB16_DMATIMER,
"DMA timer",
"to be written",
0, BX_MAX_INT,
0, BX_MAX_BIT32U,
0);
bx_param_c *sb16_init_list[] = {
bx_options.sb16.Opresent,
@ -1084,18 +1084,18 @@ void bx_init_options ()
bx_options.Okeyboard_serial_delay = new bx_param_num_c (BXP_KBD_SERIAL_DELAY,
"Keyboard serial delay",
"Approximate time in microseconds that it takes one character to be transfered from the keyboard to controller over the serial path.",
1, BX_MAX_INT,
1, BX_MAX_BIT32U,
20000);
bx_options.Okeyboard_paste_delay = new bx_param_num_c (BXP_KBD_PASTE_DELAY,
"Keyboard paste delay",
"Approximate time in microseconds between attemps to paste characters to the keyboard controller.",
1000, BX_MAX_INT,
1000, BX_MAX_BIT32U,
100000);
bx_options.Okeyboard_paste_delay->set_handler (bx_param_handler);
bx_options.Ofloppy_command_delay = new bx_param_num_c (BXP_FLOPPY_CMD_DELAY,
"Floppy command delay",
"Time in microseconds to wait before completing some floppy commands such as read/write/seek/etc, which normally have a delay associated. This used to be hardwired to 50,000 before.",
1, BX_MAX_INT,
1, BX_MAX_BIT32U,
50000);
bx_options.Oi440FXSupport = new bx_param_bool_c (BXP_I440FX_SUPPORT,
"PCI i440FX Support",
@ -1116,7 +1116,7 @@ void bx_init_options ()
bx_options.cmos.Otime0 = new bx_param_num_c (BXP_CMOS_TIME0,
"Initial CMOS time for Bochs",
"Start time for Bochs CMOS clock, used if you really want two runs to be identical (cosimulation)",
0, BX_MAX_INT,
0, BX_MAX_BIT32U,
0);
// Keyboard mapping