- started implementation of the parameter tree based on patch.param-tree

* memory parameter handling rewritten (not yet complete)
  * new reset() method for bx_list_c for recursive reset of all list members
  * memory options in wx now handled in a ParamDialog (ConfigMemoryDialog removed)
  * removed obsolete BXP_* constants in siminterface.h
  * updated proposed parameter tree
- constant BX_N_OPTRAM_IMAGES for optional RAM images limit added
This commit is contained in:
Volker Ruppert 2006-02-16 21:44:17 +00:00
parent b966703504
commit 4cece81589
9 changed files with 399 additions and 191 deletions

View File

@ -1,4 +1,4 @@
$Id: PARAM_TREE.txt,v 1.2 2006-02-12 20:43:10 vruppert Exp $
$Id: PARAM_TREE.txt,v 1.3 2006-02-16 21:44:15 vruppert Exp $
I'm trying to organize the parameters into a tree structure instead of
a huge flat list. Once the parameter code is improved, I hope to use
@ -66,13 +66,15 @@ cpu
reset_on_triple_fault BXP_RESET_ON_TRIPLE_FAULT,
memory
ram
size BXP_MEM_SIZE,
rom
address BXP_ROM_ADDRESS,
path BXP_ROM_PATH,
vga_rom_path BXP_VGA_ROM_PATH,
optional_rom
standard
ram
size BXP_MEM_SIZE,
rom
path BXP_ROM_PATH,
address BXP_ROM_ADDRESS,
vgarom
path BXP_VGA_ROM_PATH,
optrom
0
path BXP_OPTROM1_PATH,
addr BXP_OPTROM1_ADDRESS,
@ -85,7 +87,7 @@ memory
3
path BXP_OPTROM4_PATH,
addr BXP_OPTROM4_ADDRESS,
optional_ram
optram
0
path BXP_OPTRAM1_PATH,
addr BXP_OPTRAM1_ADDRESS,

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: bochs.h,v 1.171 2006-02-11 15:28:42 sshwarts Exp $
// $Id: bochs.h,v 1.172 2006-02-16 21:44:16 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -112,6 +112,8 @@ int bx_read_configuration (char *rcfile);
int bx_write_configuration (char *rcfile, int overwrite);
void bx_reset_options (void);
Bit32u crc32(const Bit8u *buf, int len);
// for param-tree testing only
void print_tree(bx_param_c *node, int level = 0);
//
// some macros to interface the CPU and memory to external environment
@ -567,6 +569,7 @@ typedef struct {
#define BX_KBD_MF_TYPE 2
#define BX_N_OPTROM_IMAGES 4
#define BX_N_OPTRAM_IMAGES 4
#define BX_N_SERIAL_PORTS 4
#define BX_N_PARALLEL_PORTS 2
#define BX_N_USB_HUBS 1
@ -584,7 +587,7 @@ typedef struct BOCHSAPI {
bx_rom_options rom;
bx_vgarom_options vgarom;
bx_rom_options optrom[BX_N_OPTROM_IMAGES]; // Optional rom images
bx_rom_options optram[BX_N_OPTROM_IMAGES]; // Optional ram images
bx_rom_options optram[BX_N_OPTRAM_IMAGES]; // Optional ram images
bx_cpu_options cpu;
bx_mem_options memory;
bx_parport_options par[BX_N_PARALLEL_PORTS]; // parallel ports

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: config.cc,v 1.73 2006-02-12 20:05:03 sshwarts Exp $
// $Id: config.cc,v 1.74 2006-02-16 21:44:16 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -363,6 +363,8 @@ void bx_init_options ()
memset (&bx_options, 0, sizeof(bx_options));
bx_param_c *root_param = SIM->get_param(".");
// quick start option, set by command line arg
new bx_param_enum_c (BXP_BOCHS_START,
"Bochs start types",
@ -801,9 +803,18 @@ void bx_init_options ()
menu = new bx_list_c (BXP_BOOT, "Boot options", "", boot_init_list);
#endif
// memory subtree
bx_list_c *memory = new bx_list_c (root_param, "memory", "");
bx_list_c *stdmem = new bx_list_c (memory, "standard", "");
bx_list_c *ram = new bx_list_c (stdmem, "ram", "");
bx_list_c *rom = new bx_list_c (stdmem, "rom", "");
bx_list_c *vgarom = new bx_list_c (stdmem, "vgarom", "");
bx_list_c *optrom = new bx_list_c (memory, "optrom", "");
bx_list_c *optram = new bx_list_c (memory, "optram", "");
// memory options (ram & rom)
bx_options.memory.Osize = new bx_param_num_c (BXP_MEM_SIZE,
"memory.ram.megs",
bx_options.memory.Osize = new bx_param_num_c (ram,
"size",
"Amount of RAM in megabytes",
1, 2048,
BX_DEFAULT_MEM_MEGS);
@ -814,15 +825,15 @@ void bx_init_options ()
bx_options.memory.Osize->set_options (bx_param_num_c::USE_SPIN_CONTROL);
#endif
bx_options.rom.Opath = new bx_param_filename_c (BXP_ROM_PATH,
"memory.rom.path",
bx_options.rom.Opath = new bx_param_filename_c (rom,
"path",
"Pathname of ROM image to load",
"", BX_PATHNAME_LEN);
bx_options.rom.Opath->set_format ("Name of ROM BIOS image: %s");
sprintf(name, "%s/BIOS-bochs-latest", get_builtin_variable("BXSHARE"));
bx_options.rom.Opath->set_initial_val (name);
bx_options.rom.Oaddress = new bx_param_num_c (BXP_ROM_ADDRESS,
"memory.rom.addr",
bx_options.rom.Oaddress = new bx_param_num_c (rom,
"addr",
"The address at which the ROM image should be loaded",
0, BX_MAX_BIT32U,
0);
@ -835,8 +846,8 @@ void bx_init_options ()
bx_options.rom.Oaddress->set_format ("ROM BIOS address: 0x%05x");
#endif
bx_options.vgarom.Opath = new bx_param_filename_c (BXP_VGA_ROM_PATH,
"memory.vgarom.path",
bx_options.vgarom.Opath = new bx_param_filename_c (vgarom,
"path",
"Pathname of VGA ROM image to load",
"", BX_PATHNAME_LEN);
bx_options.vgarom.Opath->set_format ("Name of VGA BIOS image: %s");
@ -847,19 +858,19 @@ void bx_init_options ()
bx_options.vgarom.Opath->set_initial_val (name);
for (i=0; i<BX_N_OPTROM_IMAGES; i++) {
sprintf (name, "memory.optrom.%d.path", i+1);
sprintf (name, "%d", i+1);
bx_list_c *optnum1 = new bx_list_c (optrom, strdup(name), "");
sprintf (descr, "Pathname of optional ROM image #%d to load", i+1);
bx_options.optrom[i].Opath = new bx_param_filename_c ((bx_id)(BXP_OPTROM1_PATH+i),
strdup(name),
bx_options.optrom[i].Opath = new bx_param_filename_c (optnum1,
"path",
strdup(descr),
"", BX_PATHNAME_LEN);
sprintf (label, "Name of optional ROM image #%d", i+1);
strcat(label, " : %s");
bx_options.optrom[i].Opath->set_format (strdup(label));
sprintf (name, "memory.optrom.%d.address", i+1);
sprintf (descr, "The address at which the optional ROM image #%d should be loaded", i+1);
bx_options.optrom[i].Oaddress = new bx_param_num_c ((bx_id)(BXP_OPTROM1_ADDRESS+i),
strdup(name),
bx_options.optrom[i].Oaddress = new bx_param_num_c (optnum1,
"addr",
strdup(descr),
0, BX_MAX_BIT32U,
0);
@ -876,11 +887,12 @@ void bx_init_options ()
#endif
}
for (i=0; i<BX_N_OPTROM_IMAGES; i++) {
sprintf (name, "memory.optram.%d.path", i+1);
for (i=0; i<BX_N_OPTRAM_IMAGES; i++) {
sprintf (name, "%d", i+1);
bx_list_c *optnum2 = new bx_list_c (optram, strdup(name), "");
sprintf (descr, "Pathname of optional RAM image #%d to load", i+1);
bx_options.optram[i].Opath = new bx_param_filename_c ((bx_id)(BXP_OPTRAM1_PATH+i),
strdup(name),
bx_options.optram[i].Opath = new bx_param_filename_c (optnum2,
"path",
strdup(descr),
"", BX_PATHNAME_LEN);
sprintf (label, "Name of optional RAM image #%d", i+1);
@ -888,8 +900,8 @@ void bx_init_options ()
bx_options.optram[i].Opath->set_format (strdup(label));
sprintf (name, "memory.optram.%d.address", i+1);
sprintf (descr, "The address at which the optional RAM image #%d should be loaded", i+1);
bx_options.optram[i].Oaddress = new bx_param_num_c ((bx_id)(BXP_OPTRAM1_ADDRESS+i),
strdup(name),
bx_options.optram[i].Oaddress = new bx_param_num_c (optnum2,
"addr",
strdup(descr),
0, BX_MAX_BIT32U,
0);
@ -905,6 +917,11 @@ void bx_init_options ()
bx_options.optram[i].Oaddress->set_format (strdup(label));
#endif
}
memory->get_options()->set(bx_list_c::USE_TAB_WINDOW);
memory->set_label("Memory Options");
stdmem->set_label("Standard Options");
optrom->set_label("Optional ROM Images");
optram->set_label("Optional RAM Images");
bx_param_c *memory_init_list[] = {
bx_options.memory.Osize,
@ -931,10 +948,6 @@ void bx_init_options ()
};
menu = new bx_list_c (BXP_MENU_MEMORY, "Bochs Memory Options", "memmenu", memory_init_list);
menu->get_options ()->set (menu->SHOW_PARENT);
#if BX_WITH_WX
menu = new bx_list_c (BXP_OPTROM_LIST, "Optional ROM Images", "optromlist", &memory_init_list[4]);
menu->get_options ()->set (menu->USE_BOX_TITLE);
#endif
// serial and parallel port options
@ -1760,6 +1773,10 @@ void bx_init_options ()
};
menu = new bx_list_c (BXP_MENU_RUNTIME, "Misc runtime options", "", runtime_init_list);
menu->get_options ()->set (menu->SHOW_PARENT | menu->SHOW_GROUP_NAME);
// param-tree test output
//printf ("parameter tree:\n");
//print_tree (root_param, 0);
}
void bx_reset_options ()
@ -1804,18 +1821,7 @@ void bx_reset_options ()
bx_options.OfloppySigCheck->reset();
// memory (ram & rom)
bx_options.memory.Osize->reset();
bx_options.rom.Opath->reset();
bx_options.rom.Oaddress->reset();
bx_options.vgarom.Opath->reset();
for (i=0; i<BX_N_OPTROM_IMAGES; i++) {
bx_options.optrom[i].Opath->reset();
bx_options.optrom[i].Oaddress->reset();
}
for (i=0; i<BX_N_OPTROM_IMAGES; i++) {
bx_options.optram[i].Opath->reset();
bx_options.optram[i].Oaddress->reset();
}
SIM->get_param("memory")->reset();
// standard ports
for (i=0; i<BX_N_SERIAL_PORTS; i++) {
@ -2688,37 +2694,37 @@ static Bit32s parse_line_formatted(char *context, int num_params, char *params[]
if (num_params != 2) {
PARSE_ERR(("%s: megs directive: wrong # args.", context));
}
bx_options.memory.Osize->set (atol(params[1]));
SIM->get_param_num("memory.standard.ram.size")->set(atol(params[1]));
} else if (!strcmp(params[0], "romimage")) {
if ((num_params < 2) || (num_params > 3)) {
PARSE_ERR(("%s: romimage directive: wrong # args.", context));
}
if (!strncmp(params[1], "file=", 5)) {
bx_options.rom.Opath->set (&params[1][5]);
SIM->get_param_string("memory.standard.rom.path")->set(&params[1][5]);
} else {
PARSE_ERR(("%s: romimage directive malformed.", context));
}
if (num_params == 3) {
if (!strncmp(params[2], "address=", 8)) {
if ((params[2][8] == '0') && (params[2][9] == 'x'))
bx_options.rom.Oaddress->set (strtoul (&params[2][8], NULL, 16));
SIM->get_param_num("memory.standard.rom.addr")->set(strtoul (&params[2][8], NULL, 16));
else
bx_options.rom.Oaddress->set (strtoul (&params[2][8], NULL, 10));
SIM->get_param_num("memory.standard.rom.addr")->set(strtoul (&params[2][8], NULL, 10));
} else {
PARSE_ERR(("%s: romimage directive malformed.", context));
}
} else {
bx_options.rom.Oaddress->set (0);
SIM->get_param_num("memory.standard.rom.addr")->set (0);
}
} else if (!strcmp(params[0], "vgaromimage")) {
if (num_params != 2) {
PARSE_ERR(("%s: vgaromimage directive: wrong # args.", context));
}
if (!strncmp(params[1], "file=", 5)) {
bx_options.vgarom.Opath->set (&params[1][5]);
SIM->get_param_string("memory.standard.vgarom.path")->set(&params[1][5]);
} else {
BX_INFO(("WARNING: syntax has changed, please use 'vgaromimage: file=...' now"));
bx_options.vgarom.Opath->set (params[1]);
SIM->get_param_string("memory.standard.vgarom.path")->set (params[1]);
}
} else if (!strncmp(params[0], "optromimage", 11)) {
int num = atoi(&params[0][11]);
@ -2742,7 +2748,7 @@ static Bit32s parse_line_formatted(char *context, int num_params, char *params[]
}
} else if (!strncmp(params[0], "optramimage", 11)) {
int num = atoi(&params[0][11]);
if ((num < 1) || (num > BX_N_OPTROM_IMAGES)) {
if ((num < 1) || (num > BX_N_OPTRAM_IMAGES)) {
PARSE_ERR(("%s: ramimage%d: not supported", context, num));
}
if (num_params != 3) {
@ -3661,7 +3667,7 @@ int bx_write_configuration (char *rc, int overwrite)
fprintf (fp, "optromimage%d: file=\"%s\", address=0x%05x\n", i+1, bx_options.optrom[i].Opath->getptr(),
(unsigned int)bx_options.optrom[i].Oaddress->get ());
}
for (i=0; i<BX_N_OPTROM_IMAGES; i++) {
for (i=0; i<BX_N_OPTRAM_IMAGES; i++) {
if (strlen (bx_options.optram[i].Opath->getptr ()) > 0)
fprintf (fp, "optramimage%d: file=\"%s\", address=0x%05x\n", i+1, bx_options.optram[i].Opath->getptr(),
(unsigned int)bx_options.optram[i].Oaddress->get ());

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: siminterface.cc,v 1.113 2006-01-31 19:37:56 vruppert Exp $
// $Id: siminterface.cc,v 1.114 2006-02-16 21:44:16 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// See siminterface.h for description of the siminterface concept.
@ -11,6 +11,7 @@
bx_simulator_interface_c *SIM = NULL;
logfunctions *siminterface_log = NULL;
bx_list_c *root_param = NULL;
#define LOG_THIS siminterface_log->
// bx_simulator_interface just defines the interface that the Bochs simulator
@ -52,10 +53,19 @@ public:
virtual int register_param (bx_id id, bx_param_c *it);
virtual void reset_all_param ();
virtual bx_param_c *get_param (bx_id id);
virtual bx_param_c *get_param (const char *pname, bx_param_c *base=NULL);
// deprecated
virtual bx_param_num_c *get_param_num (bx_id id);
// deprecated
virtual bx_param_string_c *get_param_string (bx_id id);
// deprecated
virtual bx_param_bool_c *get_param_bool (bx_id id);
// deprecated
virtual bx_param_enum_c *get_param_enum (bx_id id);
virtual bx_param_num_c *get_param_num (const char *pname);
virtual bx_param_string_c *get_param_string (const char *pname);
virtual bx_param_bool_c *get_param_bool (const char *pname);
virtual bx_param_enum_c *get_param_enum (const char *pname);
virtual int get_n_log_modules ();
virtual char *get_prefix (int mod);
virtual int get_log_action (int mod, int level);
@ -146,6 +156,56 @@ bx_real_sim_c::get_param (bx_id id)
return retval;
}
// recursive function to find parameters from the path
static
bx_param_c *find_param (const char *full_pname, const char *rest_of_pname, bx_param_c *base)
{
const char *from = rest_of_pname;
char component[BX_PATHNAME_LEN];
char *to = component;
// copy the first piece of pname into component, stopping at first separator
// or at the end of the string
while (*from != 0 && *from != '.') {
*to = *from;
to++;
from++;
}
*to = 0;
if (!component[0]) {
BX_PANIC (("find_param: found empty component in parameter name %s", full_pname));
// or does that mean that we're done?
}
if (base->get_type() != BXT_LIST) {
BX_PANIC (("find_param: base was not a list!"));
}
BX_DEBUG(("searching for component '%s' in list '%s'", component, base->get_name()));
// find the component in the list.
bx_list_c *list = (bx_list_c *)base;
bx_param_c *child = list->get_by_name (component);
// if child not found, there is nothing else that can be done. return NULL.
if (child == NULL) return NULL;
if (from[0] == 0) {
// that was the end of the path, we're done
return child;
}
// continue parsing the path
BX_ASSERT(from[0] == '.');
from++; // skip over the separator
return find_param (full_pname, from, child);
}
bx_param_c *
bx_real_sim_c::get_param (const char *pname, bx_param_c *base)
{
if (base == NULL)
base = root_param;
// to access top level object, look for parameter "."
if (pname[0] == '.' && pname[1] == 0)
return base;
return find_param (pname, pname, base);
}
bx_param_num_c *
bx_real_sim_c::get_param_num (bx_id id) {
bx_param_c *generic = get_param(id);
@ -160,6 +220,20 @@ bx_real_sim_c::get_param_num (bx_id id) {
return NULL;
}
bx_param_num_c *
bx_real_sim_c::get_param_num (const char *pname) {
bx_param_c *generic = get_param(pname);
if (generic==NULL) {
BX_PANIC (("get_param_num(%s) could not find a parameter", pname));
return NULL;
}
int type = generic->get_type ();
if (type == BXT_PARAM_NUM || type == BXT_PARAM_BOOL || type == BXT_PARAM_ENUM)
return (bx_param_num_c *)generic;
BX_PANIC (("get_param_num(%s) could not find an integer parameter with that name", pname));
return NULL;
}
bx_param_string_c *
bx_real_sim_c::get_param_string (bx_id id) {
bx_param_c *generic = get_param(id);
@ -173,6 +247,19 @@ bx_real_sim_c::get_param_string (bx_id id) {
return NULL;
}
bx_param_string_c *
bx_real_sim_c::get_param_string (const char *pname) {
bx_param_c *generic = get_param(pname);
if (generic==NULL) {
BX_PANIC (("get_param_string(%s) could not find a parameter", pname));
return NULL;
}
if (generic->get_type () == BXT_PARAM_STRING)
return (bx_param_string_c *)generic;
BX_PANIC (("get_param_string(%s) could not find an integer parameter with that name", pname));
return NULL;
}
bx_param_bool_c *
bx_real_sim_c::get_param_bool (bx_id id) {
bx_param_c *generic = get_param(id);
@ -186,6 +273,19 @@ bx_real_sim_c::get_param_bool (bx_id id) {
return NULL;
}
bx_param_bool_c *
bx_real_sim_c::get_param_bool (const char *pname) {
bx_param_c *generic = get_param(pname);
if (generic==NULL) {
BX_PANIC (("get_param_bool(%s) could not find a parameter", pname));
return NULL;
}
if (generic->get_type () == BXT_PARAM_BOOL)
return (bx_param_bool_c *)generic;
BX_PANIC (("get_param_bool(%s) could not find a bool parameter with that name", pname));
return NULL;
}
bx_param_enum_c *
bx_real_sim_c::get_param_enum (bx_id id) {
bx_param_c *generic = get_param(id);
@ -199,6 +299,19 @@ bx_real_sim_c::get_param_enum (bx_id id) {
return NULL;
}
bx_param_enum_c *
bx_real_sim_c::get_param_enum (const char *pname) {
bx_param_c *generic = get_param(pname);
if (generic==NULL) {
BX_PANIC (("get_param_enum(%s) could not find a parameter", pname));
return NULL;
}
if (generic->get_type () == BXT_PARAM_ENUM)
return (bx_param_enum_c *)generic;
BX_PANIC (("get_param_enum(%s) could not find a enum parameter with that name", pname));
return NULL;
}
void bx_init_siminterface ()
{
siminterface_log = new logfunctions ();
@ -206,6 +319,12 @@ void bx_init_siminterface ()
siminterface_log->settype(CTRLLOG);
if (SIM == NULL)
SIM = new bx_real_sim_c();
if (root_param == NULL) {
root_param = new bx_list_c (NULL,
"bochs",
"list of top level bochs parameters",
30);
}
}
bx_simulator_interface_c::bx_simulator_interface_c ()
@ -806,6 +925,7 @@ bx_param_c::bx_param_c (bx_id id, char *name, char *description)
this->group_name = NULL;
this->runtime_param = 0;
this->enabled = 1;
this->parent = NULL;
SIM->register_param (id, this);
}
@ -815,6 +935,22 @@ const char* bx_param_c::set_default_format (const char *f) {
return old;
}
void bx_list_c::set_parent (bx_param_c *newparent) {
if (parent) {
// if this object already had a parent, the correct thing
// to do would be to remove this object from the parent's
// list of children. Deleting children is currently
// not supported.
BX_PANIC (("bx_list_c::set_parent: changing from one parent to another is not supported"));
}
if (newparent) {
BX_ASSERT(newparent->get_type() == BXT_LIST);
this->parent = (bx_list_c *)newparent;
this->parent->add (this);
}
}
bx_param_num_c::bx_param_num_c (bx_id id,
char *name,
char *description,
@ -835,6 +971,28 @@ bx_param_num_c::bx_param_num_c (bx_id id,
set (initial_val);
}
bx_param_num_c::bx_param_num_c (bx_param_c *parent,
char *name,
char *description,
Bit64s min, Bit64s max, Bit64s initial_val)
: bx_param_c (BXP_NULL, name, description)
{
set_type (BXT_PARAM_NUM);
this->min = min;
this->max = max;
this->initial_val = initial_val;
this->val.number = initial_val;
this->handler = NULL;
this->base = default_base;
// dependent_list must be initialized before the set(),
// because set calls update_dependents().
dependent_list = NULL;
set (initial_val);
BX_ASSERT(parent->get_type() == BXT_LIST);
this->parent = (bx_list_c *) parent;
if (this->parent) this->parent->add (this);
}
Bit32u bx_param_num_c::default_base = 10;
Bit32u bx_param_num_c::set_default_base (Bit32u val) {
@ -892,7 +1050,7 @@ bx_param_num_c::set (Bit64s newval)
val.number = newval;
}
if ((val.number < min || val.number > max) && (Bit64u)max != BX_MAX_BIT64U)
BX_PANIC (("numerical parameter %s was set to " FMT_LL "d, which is out of range " FMT_LL "d to " FMT_LL "d", get_name (), val.number, min, max));
BX_PANIC (("numerical parameter '%s' was set to " FMT_LL "d, which is out of range " FMT_LL "d to " FMT_LL "d", get_name (), val.number, min, max));
if (dependent_list != NULL) update_dependents ();
}
@ -1105,6 +1263,12 @@ bx_shadow_num_c::set (Bit64s newval)
}
}
void
bx_shadow_num_c::reset ()
{
BX_PANIC (("reset not supported on bx_shadow_num_c yet"));
}
bx_param_bool_c::bx_param_bool_c (bx_id id,
char *name,
char *description,
@ -1214,6 +1378,31 @@ bx_param_string_c::bx_param_string_c (bx_id id,
set (initial_val);
}
bx_param_string_c::bx_param_string_c (bx_param_c *parent,
char *name,
char *description,
char *initial_val,
int maxsize)
: bx_param_c (BXP_NULL, name, description)
{
set_type (BXT_PARAM_STRING);
if (maxsize < 0)
maxsize = strlen(initial_val) + 1;
this->val = new char[maxsize];
this->initial_val = new char[maxsize];
this->handler = NULL;
this->enable_handler = NULL;
this->maxsize = maxsize;
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_BIT64S, 0);
set (initial_val);
BX_ASSERT(parent->get_type() == BXT_LIST);
this->parent = (bx_list_c *) parent;
if (this->parent) this->parent->add (this);
}
bx_param_filename_c::bx_param_filename_c (bx_id id,
char *name,
char *description,
@ -1224,6 +1413,16 @@ bx_param_filename_c::bx_param_filename_c (bx_id id,
get_options()->set (IS_FILENAME);
}
bx_param_filename_c::bx_param_filename_c (bx_param_c *parent,
char *name,
char *description,
char *initial_val,
int maxsize)
: bx_param_string_c (parent, name, description, initial_val, maxsize)
{
get_options()->set (IS_FILENAME);
}
bx_param_string_c::~bx_param_string_c ()
{
if ( this->val != NULL )
@ -1325,6 +1524,7 @@ bx_list_c::bx_list_c (bx_id id, int maxsize)
this->size = 0;
this->maxsize = maxsize;
this->list = new bx_param_c* [maxsize];
this->parent = NULL;
init ();
}
@ -1335,6 +1535,24 @@ bx_list_c::bx_list_c (bx_id id, char *name, char *description, int maxsize)
this->size = 0;
this->maxsize = maxsize;
this->list = new bx_param_c* [maxsize];
this->parent = NULL;
init ();
}
bx_list_c::bx_list_c (bx_param_c *parent, char *name, char *description,
int maxsize)
: bx_param_c (BXP_NULL, name, description)
{
set_type (BXT_LIST);
this->size = 0;
this->maxsize = maxsize;
this->list = new bx_param_c* [maxsize];
this->parent = NULL;
if (parent) {
BX_ASSERT(parent->get_type() == BXT_LIST);
this->parent = (bx_list_c *)parent;
this->parent->add (this);
}
init ();
}
@ -1350,6 +1568,7 @@ bx_list_c::bx_list_c (bx_id id, char *name, char *description, bx_param_c **init
for (int i=0; i<this->size; i++)
this->list[i] = init_list[i];
init ();
this->parent = NULL;
}
bx_list_c::~bx_list_c()
@ -1390,17 +1609,15 @@ bx_list_c::init ()
this->choice = new bx_param_num_c (BXP_NULL,
"list_choice", "", 0, BX_MAX_BIT64S,
1);
this->parent = NULL;
}
bx_list_c *
bx_list_c::clone ()
{
bx_list_c *newlist = new bx_list_c (BXP_NULL, name, description, maxsize);
bx_list_c *newlist = new bx_list_c (get_parent(), name, description, maxsize);
for (int i=0; i<get_size (); i++)
newlist->add (get(i));
newlist->set_options (get_options ());
newlist->set_parent (get_parent ());
return newlist;
}
@ -1420,3 +1637,24 @@ bx_list_c::get (int index)
return list[index];
}
bx_param_c *
bx_list_c::get_by_name (const char *name)
{
int i, imax = get_size ();
for (i=0; i<imax; i++) {
bx_param_c *p = get(i);
if (0 == strcmp (name, p->get_name ())) {
return p;
}
}
return NULL;
}
void
bx_list_c::reset()
{
int i, imax = get_size ();
for (i=0; i<imax; i++) {
get(i)->reset();
}
}

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: siminterface.h,v 1.154 2006-02-12 20:43:12 vruppert Exp $
// $Id: siminterface.h,v 1.155 2006-02-16 21:44:17 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Intro to siminterface by Bryce Denney:
@ -131,27 +131,6 @@ typedef enum {
BXP_VGA_UPDATE_INTERVAL,
BXP_MOUSE_ENABLED,
BXP_MOUSE_TYPE,
BXP_MEM_SIZE,
BXP_ROM_PATH,
BXP_ROM_ADDRESS,
BXP_VGA_ROM_PATH,
BXP_OPTROM1_PATH,
BXP_OPTROM2_PATH,
BXP_OPTROM3_PATH,
BXP_OPTROM4_PATH,
BXP_OPTROM1_ADDRESS,
BXP_OPTROM2_ADDRESS,
BXP_OPTROM3_ADDRESS,
BXP_OPTROM4_ADDRESS,
BXP_OPTROM_LIST,
BXP_OPTRAM1_PATH,
BXP_OPTRAM2_PATH,
BXP_OPTRAM3_PATH,
BXP_OPTRAM4_PATH,
BXP_OPTRAM1_ADDRESS,
BXP_OPTRAM2_ADDRESS,
BXP_OPTRAM3_ADDRESS,
BXP_OPTRAM4_ADDRESS,
BXP_KBD_SERIAL_DELAY,
BXP_KBD_PASTE_DELAY,
BXP_KBD_TYPE,
@ -896,6 +875,7 @@ public:
class BOCHSAPI bx_param_c : public bx_object_c {
BOCHSAPI_CYGONLY static const char *default_text_format;
protected:
bx_list_c *parent;
char *name;
char *description;
char *label; // label string for text menus and gui dialogs
@ -906,6 +886,7 @@ protected:
int enabled;
public:
bx_param_c (bx_id id, char *name, char *description);
bx_param_c *get_parent () { return (bx_param_c *) parent; }
void set_format (const char *format) {text_format = format;}
const char *get_format () {return text_format;}
void set_ask_format (char *format) {ask_format = format; }
@ -920,7 +901,7 @@ public:
char *get_description () { return description; }
int get_enabled () { return enabled; }
virtual void set_enabled (int enabled) { this->enabled = enabled; }
void reset () {}
virtual void reset () {}
int getint () {return -1;}
static const char* set_default_format (const char *f);
static const char *get_default_format () { return default_text_format; }
@ -966,7 +947,11 @@ public:
char *name,
char *description,
Bit64s min, Bit64s max, Bit64s initial_val);
void reset ();
bx_param_num_c (bx_param_c *parent,
char *name,
char *description,
Bit64s min, Bit64s max, Bit64s initial_val);
virtual void reset ();
void set_handler (param_event_handler handler);
void set_enable_handler (param_enable_handler handler);
virtual bx_list_c *get_dependent_list () { return dependent_list; }
@ -1051,6 +1036,7 @@ public:
Bit8u lowbit = 0);
virtual Bit64s get64 ();
virtual void set (Bit64s val);
virtual void reset ();
};
class BOCHSAPI bx_param_bool_c : public bx_param_num_c {
@ -1124,8 +1110,13 @@ public:
char *description,
char *initial_val,
int maxsize=-1);
bx_param_string_c (bx_param_c *parent,
char *name,
char *description,
char *initial_val,
int maxsize=-1);
virtual ~bx_param_string_c ();
void reset ();
virtual void reset ();
void set_handler (param_string_event_handler handler);
void set_enable_handler (param_enable_handler handler);
virtual void set_enabled (int enabled);
@ -1154,10 +1145,17 @@ public:
char *description,
char *initial_val,
int maxsize=-1);
bx_param_filename_c (bx_param_c *parent,
char *name,
char *description,
char *initial_val,
int maxsize=-1);
};
#define BX_DEFAULT_LIST_SIZE 6
class BOCHSAPI bx_list_c : public bx_param_c {
private:
protected:
// just a list of bx_param_c objects. size tells current number of
// objects in the list, and maxsize tells how many list items are
// allocated in the constructor.
@ -1174,8 +1172,7 @@ private:
// title of the menu or series
bx_param_string_c *title;
// if the menu shows a "return to previous menu" type of choice,
// this controls where that choice will go.
bx_param_c *parent;
// "parent" controls where that choice will go.
void init ();
public:
enum {
@ -1200,20 +1197,23 @@ public:
// item (used in the runtime menu).
SHOW_GROUP_NAME = (1<<4)
} bx_listopt_bits;
bx_list_c (bx_id id, int maxsize);
bx_list_c (bx_id id, int maxsize = BX_DEFAULT_LIST_SIZE);
bx_list_c (bx_id id, char *name, char *description, bx_param_c **init_list);
bx_list_c (bx_id id, char *name, char *description, int maxsize);
bx_list_c (bx_id id, char *name, char *description, int maxsize = BX_DEFAULT_LIST_SIZE);
bx_list_c (bx_param_c *parent, char *name, char *description, int maxsize = BX_DEFAULT_LIST_SIZE);
virtual ~bx_list_c();
bx_list_c *clone ();
void add (bx_param_c *param);
bx_param_c *get (int index);
bx_param_c *get_by_name (const char *name);
int get_size () { return size; }
bx_param_num_c *get_options () { return options; }
void set_options (bx_param_num_c *newopt) { options = newopt; }
bx_param_num_c *get_choice () { return choice; }
bx_param_string_c *get_title () { return title; }
void set_parent (bx_param_c *newparent) { parent = newparent; }
void set_parent (bx_param_c *newparent);
bx_param_c *get_parent () { return parent; }
virtual void reset ();
#if BX_USE_TEXTCONFIG
virtual void text_print (FILE *);
virtual int text_ask (FILE *fpin, FILE *fpout);
@ -1416,10 +1416,19 @@ public:
virtual int register_param (bx_id id, bx_param_c *it) {return -1;}
virtual void reset_all_param () {}
virtual bx_param_c *get_param (bx_id id) {return NULL;}
virtual bx_param_c *get_param (const char *pname, bx_param_c *base=NULL) {return NULL;}
// deprecated
virtual bx_param_num_c *get_param_num (bx_id id) {return NULL;}
// deprecated
virtual bx_param_string_c *get_param_string (bx_id id) {return NULL;}
// deprecated
virtual bx_param_bool_c *get_param_bool (bx_id id) {return NULL;}
// deprecated
virtual bx_param_enum_c *get_param_enum (bx_id id) {return NULL;}
virtual bx_param_num_c *get_param_num (const char *pname) {return NULL;}
virtual bx_param_string_c *get_param_string (const char *pname) {return NULL;}
virtual bx_param_bool_c *get_param_bool (const char *pname) {return NULL;}
virtual bx_param_enum_c *get_param_enum (const char *pname) {return NULL;}
virtual int get_n_log_modules () {return -1;}
virtual char *get_prefix (int mod) {return 0;}
virtual int get_log_action (int mod, int level) {return -1;}

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////
// $Id: wxdialog.cc,v 1.80 2005-11-26 09:22:58 vruppert Exp $
// $Id: wxdialog.cc,v 1.81 2006-02-16 21:44:17 vruppert Exp $
/////////////////////////////////////////////////////////////////
// Define BX_PLUGGABLE in files that can be compiled into plugins. For
@ -1635,85 +1635,6 @@ void ParamDialog::ShowHelp ()
wxMessageBox(MSG_NO_HELP, MSG_NO_HELP_CAPTION, wxOK | wxICON_ERROR, this );
}
//////////////////////////////////////////////////////////////////////
// ConfigMemoryDialog implementation
//////////////////////////////////////////////////////////////////////
// Structure:
// mainSizer:
// box1 = static box "Standard Options"
// box1sizer:
// box1gridSizer, 3 columns:
// "memsize"
// megs = textfield
// spacer
// "biosimg"
// biosImage = textfield
// browse button
// "biosaddr"
// biosAddr = textfield
// spacer
// "vgabiosimg"
// vgabios = textfield
// browse button
// "vgabiosaddr"
// "0xc0000"
// box2 = static box "Optional ROM images"
// box2sizer:
// box2gridSizer, 3 columns:
// "opt rom 1"
// romImage[0] = textfield
// browse button
// "opt rom 2"
// romImage[1] = textfield
// browse button
// "opt rom 3"
// romImage[2] = textfield
// browse button
// "opt rom 4"
// romImage[3] = textfield
// browse button
// buttonSizer:
// help
// cancel
// ok
//
// all events go to OnEvent method
BEGIN_EVENT_TABLE(ConfigMemoryDialog, wxDialog)
EVT_BUTTON(-1, ConfigMemoryDialog::OnEvent)
EVT_CHECKBOX(-1, ConfigMemoryDialog::OnEvent)
EVT_TEXT(-1, ConfigMemoryDialog::OnEvent)
END_EVENT_TABLE()
ConfigMemoryDialog::ConfigMemoryDialog(
wxWindow* parent,
wxWindowID id)
: ParamDialog (parent, id)
{
bx_id standardList[] = {BXP_MEM_SIZE, BXP_ROM_PATH, BXP_ROM_ADDRESS,
BXP_VGA_ROM_PATH, BXP_NULL};
int insideStaticBoxMargin = 15;
SetTitle (CONFIG_MEMORY_TITLE);
// top level objects
wxStaticBox *box1 = new wxStaticBox (this, -1, CONFIG_MEMORY_BOX1_TITLE);
wxStaticBoxSizer *box1sizer = new wxStaticBoxSizer (box1, wxVERTICAL);
mainSizer->Add (box1sizer, 0, wxALL|wxGROW, 10);
// box1 contents
box1gridSizer = new wxFlexGridSizer (3);
box1sizer->Add (box1gridSizer, 0, wxALL, insideStaticBoxMargin);
AddParamList (standardList, box1gridSizer);
wxStaticText *vgabiosaddr1 = new wxStaticText (this, -1, "VGA BIOS address");
box1gridSizer->Add (vgabiosaddr1, 0, wxALIGN_RIGHT|wxALL, 2);
wxStaticText *vgabiosaddr2 = new wxStaticText (this, -1, "0xC0000");
box1gridSizer->Add (vgabiosaddr2, 0, wxALL, 2);
// box2 contains a list
bx_list_c *list = (bx_list_c *) SIM->get_param (BXP_OPTROM_LIST);
AddParam (list);
}
/////////////////////////////////////////////////////////////////
// CpuRegistersDialog
/////////////////////////////////////////////////////////////////

View File

@ -1,5 +1,5 @@
////////////////////////////////////////////////////////////////////
// $Id: wxdialog.h,v 1.56 2005-11-25 16:24:47 vruppert Exp $
// $Id: wxdialog.h,v 1.57 2006-02-16 21:44:17 vruppert Exp $
////////////////////////////////////////////////////////////////////
//
// wxWidgets dialogs for Bochs
@ -505,18 +505,6 @@ public:
DECLARE_EVENT_TABLE()
};
class ConfigMemoryDialog : public ParamDialog
{
#define CONFIG_MEMORY_TITLE "Configure Memory"
#define CONFIG_MEMORY_BOX1_TITLE "Standard Options"
#define CONFIG_MEMORY_BOX2_TITLE "Optional ROM Images"
private:
wxFlexGridSizer *box1gridSizer, *box2gridSizer;
public:
ConfigMemoryDialog(wxWindow* parent, wxWindowID id);
DECLARE_EVENT_TABLE()
};
////////////////////////////////////////////////////////////////////////////
// CpuRegistersDialog
////////////////////////////////////////////////////////////////////////////

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////
// $Id: wxmain.cc,v 1.111 2005-11-26 09:22:58 vruppert Exp $
// $Id: wxmain.cc,v 1.112 2006-02-16 21:44:17 vruppert Exp $
/////////////////////////////////////////////////////////////////
//
// wxmain.cc implements the wxWidgets frame, toolbar, menus, and dialogs.
@ -594,8 +594,11 @@ void MyFrame::OnEditBoot(wxCommandEvent& WXUNUSED(event))
void MyFrame::OnEditMemory(wxCommandEvent& WXUNUSED(event))
{
ConfigMemoryDialog dlg (this, -1);
dlg.ShowModal ();
ParamDialog dlg(this, -1);
bx_list_c *list = (bx_list_c*) SIM->get_param("memory");
dlg.SetTitle(list->get_label());
dlg.AddParam(list);
dlg.ShowModal();
}
void MyFrame::OnEditPCI(wxCommandEvent& WXUNUSED(event))

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: main.cc,v 1.309 2006-02-11 15:28:43 sshwarts Exp $
// $Id: main.cc,v 1.310 2006-02-16 21:44:16 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -185,6 +185,43 @@ static void carbonFatalDialog(const char *error, const char *exposition)
}
#endif
void print_tree(bx_param_c *node, int level)
{
int i;
for (i=0; i<level; i++)
printf (" ");
if (node == NULL) {
printf ("NULL pointer\n");
return;
}
switch (node->get_type()) {
case BXT_PARAM_NUM:
if (((bx_param_num_c*)node)->get_base() == 10) {
printf ("%s = %d (number)\n", node->get_name(), ((bx_param_num_c*)node)->get());
} else {
printf ("%s = 0x%x (hex number)\n", node->get_name(), ((bx_param_num_c*)node)->get());
}
break;
case BXT_PARAM_BOOL:
printf ("%s = %s (boolean)\n", node->get_name(), ((bx_param_bool_c*)node)->get()?"true":"false");
break;
case BXT_PARAM:
case BXT_PARAM_ENUM:
case BXT_PARAM_STRING:
printf ("%s = '%s' (string)\n", node->get_name(), ((bx_param_string_c*)node)->getptr());
break;
case BXT_LIST:
{
printf ("%s = \n", node->get_name ());
bx_list_c *list = (bx_list_c*)node;
for (i=0; i < list->get_size (); i++) {
print_tree(list->get(i), level+1);
}
break;
}
}
}
int bxmain () {
#ifdef HAVE_LOCALE_H
// Initialize locale (for isprint() and other functions)
@ -859,7 +896,8 @@ int bx_init_hardware()
}
// set up memory and CPU objects
Bit32u memSize = bx_options.memory.Osize->get()*1024*1024;
bx_param_num_c *bxp_memsize = SIM->get_param_num("memory.standard.ram.size");
Bit32u memSize = bxp_memsize->get() * 1024*1024;
#if BX_SUPPORT_ICACHE
pageWriteStampTable.alloc(memSize);