From dafe33fc84fc7869f8db6250f1487d4464c394f6 Mon Sep 17 00:00:00 2001 From: Volker Ruppert Date: Thu, 2 Mar 2006 20:13:14 +0000 Subject: [PATCH] - network options rewritten to a parameter tree - disable usb options if not compiled with usb support - usb and network dependency list created with menu->clone() - load usb plugin only if at least one hub is present - remaining options prepared for rewrite - proposed parameter tree updated --- bochs/PARAM_TREE.txt | 69 ++++---- bochs/bochs.h | 19 +-- bochs/config.cc | 342 ++++++++++++++++++--------------------- bochs/gui/siminterface.h | 29 +--- bochs/gui/textconfig.cc | 10 +- bochs/gui/wxmain.cc | 8 +- bochs/iodev/devices.cc | 22 +-- bochs/iodev/ne2k.cc | 24 +-- bochs/iodev/pcipnic.cc | 19 ++- 9 files changed, 239 insertions(+), 303 deletions(-) diff --git a/bochs/PARAM_TREE.txt b/bochs/PARAM_TREE.txt index 51c59ed1d..806fa0b02 100644 --- a/bochs/PARAM_TREE.txt +++ b/bochs/PARAM_TREE.txt @@ -1,4 +1,4 @@ -$Id: PARAM_TREE.txt,v 1.9 2006-03-01 17:14:35 vruppert Exp $ +$Id: PARAM_TREE.txt,v 1.10 2006-03-02 20:13:13 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 @@ -222,22 +222,20 @@ ports option2 BXP_USB1_OPTION2, network - ne2k - 0 BXP_NE2K, - enabled BXP_NE2K_ENABLED, - ioaddr BXP_NE2K_IOADDR, - irq BXP_NE2K_IRQ, - macaddr BXP_NE2K_MACADDR, - ethmod BXP_NE2K_ETHMOD, - ethdev BXP_NE2K_ETHDEV, - script BXP_NE2K_SCRIPT, - pnic - 0 BXP_PNIC, - enabled BXP_PNIC_ENABLED, - macaddr BXP_PNIC_MACADDR, - ethmod BXP_PNIC_ETHMOD, - ethdev BXP_PNIC_ETHDEV, - script BXP_PNIC_SCRIPT, + ne2k BXP_NE2K, + enabled BXP_NE2K_ENABLED, + ioaddr BXP_NE2K_IOADDR, + irq BXP_NE2K_IRQ, + macaddr BXP_NE2K_MACADDR, + ethmod BXP_NE2K_ETHMOD, + ethdev BXP_NE2K_ETHDEV, + script BXP_NE2K_SCRIPT, + pnic BXP_PNIC, + enabled BXP_PNIC_ENABLED, + macaddr BXP_PNIC_MACADDR, + ethmod BXP_PNIC_ETHMOD, + ethdev BXP_PNIC_ETHDEV, + script BXP_PNIC_SCRIPT, sound sb16 BXP_SB16, @@ -250,28 +248,29 @@ sound loglevel BXP_SB16_LOGLEVEL, dmatimer BXP_SB16_DMATIMER, -config_menus - main BXP_MENU_MAIN, - disk BXP_MENU_DISK, - ser_par BXP_MENU_SERIAL_PARALLEL, - sound BXP_MENU_SOUND, - runtime BXP_MENU_RUNTIME, - -general - start_mode BXP_BOCHS_START, +misc text_snapshot_check BXP_TEXT_SNAPSHOT_CHECK, - -log - filename BXP_LOG_FILENAME, - prefix BXP_LOG_PREFIX, - debugger_filename BXP_DEBUGGER_LOG_FILENAME, - -debugger - running BXP_DEBUG_RUNNING, gdbstub port text_base data_base bss_base -(updated Feb 22, 2006 by vruppert) +log + filename BXP_LOG_FILENAME, + prefix BXP_LOG_PREFIX, + debugger_filename BXP_DEBUGGER_LOG_FILENAME, + +general + start_mode BXP_BOCHS_START, + +debugger + running BXP_DEBUG_RUNNING, + +config_menus + main BXP_MENU_MAIN, + disk BXP_MENU_DISK, + sound BXP_MENU_SOUND, + runtime BXP_MENU_RUNTIME, + +(updated Mar 2, 2006 by vruppert) diff --git a/bochs/bochs.h b/bochs/bochs.h index 1a1ee04e4..83f147bfb 100644 --- a/bochs/bochs.h +++ b/bochs/bochs.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: bochs.h,v 1.183 2006-03-01 17:14:36 vruppert Exp $ +// $Id: bochs.h,v 1.184 2006-03-02 20:13:13 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2002 MandrakeSoft S.A. @@ -464,21 +464,6 @@ extern bx_bool bx_gui_sighandler; #define BX_PATHNAME_LEN 512 -typedef struct { - bx_param_bool_c *Oenabled; - bx_param_string_c *Ooutfile; -} bx_parport_options; - -typedef struct { - bx_param_bool_c *Oenabled; - bx_param_num_c *Oioaddr; - bx_param_num_c *Oirq; - bx_param_string_c *Omacaddr; - bx_param_enum_c *Oethmod; - bx_param_string_c *Oethdev; - bx_param_string_c *Oscript; -} bx_ne2k_options; - typedef struct { bx_param_string_c *Ofilename; bx_param_string_c *Oprefix; @@ -515,8 +500,6 @@ typedef struct { #define BX_N_PCI_SLOTS 5 typedef struct BOCHSAPI { - bx_ne2k_options ne2k; - bx_pnic_options pnic; bx_sb16_options sb16; bx_param_bool_c *Otext_snapshot_check; bx_log_options log; diff --git a/bochs/config.cc b/bochs/config.cc index 0dac679bf..5d011d1e1 100755 --- a/bochs/config.cc +++ b/bochs/config.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: config.cc,v 1.90 2006-03-01 21:24:19 vruppert Exp $ +// $Id: config.cc,v 1.91 2006-03-02 20:13:13 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2002 MandrakeSoft S.A. @@ -326,9 +326,10 @@ void bx_init_options() bx_list_c *deplist; bx_param_num_c *ioaddr, *ioaddr2, *irq; bx_param_bool_c *enabled; - bx_param_enum_c *mode, *status, *type; + bx_param_enum_c *mode, *status, *type, *ethmod; + bx_param_string_c *macaddr, *ethdev; bx_param_filename_c *path; - char name[1024], descr[1024], group[16], label[1024]; + char name[BX_PATHNAME_LEN], descr[512], group[16], label[512]; memset(&bx_options, 0, sizeof(bx_options)); @@ -1289,6 +1290,7 @@ void bx_init_options() sprintf(name, "%d", i+1); sprintf(label, "USB Hub %d", i+1); menu = new bx_list_c(usb, strdup(name), label); + menu->set_enabled(BX_SUPPORT_PCIUSB); sprintf(label, "Enable usb hub #%d", i+1); sprintf(descr, "Controls whether %s is installed or not", group); enabled = new bx_param_bool_c(menu, @@ -1296,7 +1298,7 @@ void bx_init_options() strdup(label), strdup(descr), 0); - deplist = new bx_list_c(BXP_NULL, 4); + enabled->set_enabled(BX_SUPPORT_PCIUSB); port = new bx_param_string_c(menu, "port1", "Port #1 device", @@ -1309,8 +1311,6 @@ void bx_init_options() "Options for device on USB port #1", "", BX_PATHNAME_LEN); option->set_group(strdup(group)); - deplist->add(port); - deplist->add(option); port = new bx_param_string_c(menu, "port2", "Port #2 device", @@ -1323,12 +1323,14 @@ void bx_init_options() "Options for device on USB port #2", "", BX_PATHNAME_LEN); option->set_group(strdup(group)); - deplist->add(port); - deplist->add(option); - enabled->set_dependent_list(deplist); + enabled->set_dependent_list(menu->clone()); } - // NE2K options + // network subtree + bx_list_c *network = new bx_list_c(root_param, "network", "Network Configuration"); + network->get_options()->set(bx_list_c::USE_TAB_WINDOW | bx_list_c::SHOW_PARENT); + + // ne2k & pnic options static char *eth_module_list[] = { "null", #if defined(ETH_LINUX) @@ -1355,112 +1357,96 @@ void bx_init_options() "vnet", NULL }; - bx_options.ne2k.Oenabled = new bx_param_bool_c (BXP_NE2K_ENABLED, - "Enable NE2K NIC emulation", - "Enables the NE2K NIC emulation", - 0); - bx_options.ne2k.Oioaddr = new bx_param_num_c (BXP_NE2K_IOADDR, - "NE2K I/O Address", - "I/O base address of the emulated NE2K device", - 0, 0xffff, - 0x240); - bx_options.ne2k.Oioaddr->set_base (16); - bx_options.ne2k.Oirq = new bx_param_num_c (BXP_NE2K_IRQ, - "NE2K Interrupt", - "IRQ used by the NE2K device", - 0, 15, - 9); - bx_options.ne2k.Oirq->set_options (bx_param_num_c::USE_SPIN_CONTROL); - bx_options.ne2k.Omacaddr = new bx_param_string_c (BXP_NE2K_MACADDR, - "MAC Address", - "MAC address of the NE2K device. Don't use an address of a machine on your net.", - "\xfe\xfd\xde\xad\xbe\xef", 6); - bx_options.ne2k.Omacaddr->get_options ()->set (bx_options.ne2k.Omacaddr->RAW_BYTES); - bx_options.ne2k.Omacaddr->set_separator (':'); - bx_options.ne2k.Oethmod = new bx_param_enum_c (BXP_NE2K_ETHMOD, - "Ethernet module", - "Module used for the connection to the real net.", - eth_module_list, - 0, - 0); - bx_options.ne2k.Oethmod->set_by_name("null"); - bx_options.ne2k.Oethmod->set_ask_format ("Choose ethernet module for the NE2K [%s] "); - bx_options.ne2k.Oethdev = new bx_param_string_c (BXP_NE2K_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); - bx_options.ne2k.Oscript = new bx_param_string_c (BXP_NE2K_SCRIPT, - "Device configuration script", - "Name of the script that is executed after Bochs initializes the network interface (optional).", - "none", BX_PATHNAME_LEN); -#if !BX_WITH_WX - bx_options.ne2k.Oscript->set_ask_format ("Enter new script name, or 'none': [%s] "); -#endif - bx_options.pnic.Oenabled = new bx_param_bool_c (BXP_PNIC_ENABLED, - "Enable Pseudo NIC emulation", - "Enables the Pseudo NIC emulation", - 0); - bx_options.pnic.Omacaddr = new bx_param_string_c (BXP_PNIC_MACADDR, - "MAC Address", - "MAC address of the Pseudo NIC device. Don't use an address of a machine on your net.", - "\xfe\xfd\xde\xad\xbe\xef", 6); - bx_options.pnic.Omacaddr->get_options ()->set (bx_options.pnic.Omacaddr->RAW_BYTES); - bx_options.pnic.Omacaddr->set_separator (':'); - bx_options.pnic.Oethmod = new bx_param_enum_c (BXP_PNIC_ETHMOD, - "Ethernet module", - "Module used for the connection to the real net.", - eth_module_list, - 0, - 0); - bx_options.pnic.Oethmod->set_by_name("null"); - bx_options.pnic.Oethmod->set_ask_format ("Choose ethernet module for the Pseudo NIC [%s]"); - bx_options.pnic.Oethdev = new bx_param_string_c (BXP_PNIC_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); - bx_options.pnic.Oscript = new bx_param_string_c (BXP_PNIC_SCRIPT, - "Device configuration script", - "Name of the script that is executed after Bochs initializes the network interface (optional).", - "none", BX_PATHNAME_LEN); -#if !BX_WITH_WX - bx_options.pnic.Oscript->set_ask_format ("Enter new script name, or 'none': [%s] "); -#endif - bx_param_c *ne2k_init_list[] = { - bx_options.ne2k.Oenabled, - bx_options.ne2k.Oioaddr, - bx_options.ne2k.Oirq, - bx_options.ne2k.Omacaddr, - bx_options.ne2k.Oethmod, - bx_options.ne2k.Oethdev, - bx_options.ne2k.Oscript, - NULL - }; - bx_param_c *pnic_init_list[] = { - bx_options.pnic.Oenabled, - bx_options.pnic.Omacaddr, - bx_options.pnic.Oethmod, - bx_options.pnic.Oethdev, - bx_options.pnic.Oscript, - NULL - }; - menu = new bx_list_c(BXP_NE2K, "ne2k", "NE2000", ne2k_init_list); + // ne2k options + menu = new bx_list_c(network, "ne2k", "NE2000", 7); menu->get_options()->set(bx_list_c::SHOW_PARENT); menu->set_enabled(BX_SUPPORT_NE2K); - bx_options.ne2k.Oenabled->set_dependent_list( - new bx_list_c(BXP_NULL, "", "", ne2k_init_list)); - menu = new bx_list_c(BXP_PNIC, "pnic", "PCI Pseudo NIC", pnic_init_list); + enabled = new bx_param_bool_c(menu, + "enabled", + "Enable NE2K NIC emulation", + "Enables the NE2K NIC emulation", + 0); + enabled->set_enabled(BX_SUPPORT_NE2K); + ioaddr = new bx_param_num_c(menu, + "ioaddr", + "NE2K I/O Address", + "I/O base address of the emulated NE2K device", + 0, 0xffff, + 0x240); + ioaddr->set_base(16); + irq = new bx_param_num_c(menu, + "irq", + "NE2K Interrupt", + "IRQ used by the NE2K device", + 0, 15, + 9); + irq->set_options(bx_param_num_c::USE_SPIN_CONTROL); + macaddr = new bx_param_string_c(menu, + "macaddr", + "MAC Address", + "MAC address of the NE2K device. Don't use an address of a machine on your net.", + "\xfe\xfd\xde\xad\xbe\xef", 6); + macaddr->get_options()->set(bx_param_string_c::RAW_BYTES); + macaddr->set_separator(':'); + ethmod = new bx_param_enum_c(menu, + "ethmod", + "Ethernet module", + "Module used for the connection to the real net.", + eth_module_list, + 0, + 0); + ethmod->set_by_name("null"); + ethmod->set_ask_format("Choose ethernet module for the NE2K [%s] "); + ethdev = 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] "); + enabled->set_dependent_list(menu->clone()); + // pnic options + menu = new bx_list_c(network, "pnic", "PCI Pseudo NIC"); menu->get_options()->set(bx_list_c::SHOW_PARENT); menu->set_enabled(BX_SUPPORT_PCIPNIC); - bx_options.pnic.Oenabled->set_dependent_list ( - new bx_list_c(BXP_NULL, "", "", pnic_init_list)); - - bx_param_c *netdev_init_list2[] = { - SIM->get_param(BXP_NE2K), - SIM->get_param(BXP_PNIC), - NULL - }; - menu = new bx_list_c(BXP_NETWORK, "network", "Network Configuration", netdev_init_list2); - menu->get_options()->set(bx_list_c::SHOW_PARENT | bx_list_c::USE_TAB_WINDOW); + enabled = new bx_param_bool_c(menu, + "enabled", + "Enable Pseudo NIC emulation", + "Enables the Pseudo NIC emulation", + 0); + enabled->set_enabled(BX_SUPPORT_PCIPNIC); + macaddr = new bx_param_string_c(menu, + "macaddr", + "MAC Address", + "MAC address of the Pseudo NIC device. Don't use an address of a machine on your net.", + "\xfe\xfd\xde\xad\xbe\xef", 6); + macaddr->get_options ()->set(bx_param_string_c::RAW_BYTES); + macaddr->set_separator(':'); + ethmod = new bx_param_enum_c(menu, + "ethmod", + "Ethernet module", + "Module used for the connection to the real net.", + eth_module_list, + 0, + 0); + ethmod->set_by_name("null"); + ethmod->set_ask_format("Choose ethernet module for the Pseudo NIC [%s]"); + ethdev = 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] "); + enabled->set_dependent_list(menu->clone()); // SB16 options bx_options.sb16.Oenabled = new bx_param_bool_c (BXP_SB16_ENABLED, @@ -1520,14 +1506,12 @@ void bx_init_options() bx_options.sb16.Odmatimer, NULL }; - menu = new bx_list_c (BXP_SB16, "SB16 Configuration", "", sb16_init_list); - menu->get_options ()->set (menu->SHOW_PARENT); + menu = new bx_list_c(BXP_SB16, "sb16", "SB16 Configuration", sb16_init_list); + menu->get_options()->set (menu->SHOW_PARENT); // sb16_dependent_list is a null-terminated list including all the // sb16 fields except for the "present" field. These will all be enabled/ // disabled according to the value of the present field. - bx_param_c **sb16_dependent_list = &sb16_init_list[1]; - bx_options.sb16.Oenabled->set_dependent_list ( - new bx_list_c (BXP_NULL, "", "", sb16_dependent_list)); + bx_options.sb16.Oenabled->set_dependent_list(menu->clone()); // log options bx_options.log.Ofilename = new bx_param_filename_c (BXP_LOG_FILENAME, @@ -1548,12 +1532,11 @@ void bx_init_options() "-", BX_PATHNAME_LEN); bx_options.log.Odebugger_filename->set_ask_format ("Enter debugger log filename: [%s] "); - // other + // misc options bx_options.Otext_snapshot_check = new bx_param_bool_c (BXP_TEXT_SNAPSHOT_CHECK, - "Enable panic for use in bochs testing", + "Enable text snapshot check panic", "Enable panic when text on screen matches snapchk.txt.\nUseful for regression testing.\nIn win32, turns off CR/LF in snapshots and cuts.", 0); - // GDB stub bx_options.gdbstub.port = 1234; bx_options.gdbstub.text_base = 0; @@ -1564,8 +1547,8 @@ void bx_init_options() SIM->get_param(BXP_TEXT_SNAPSHOT_CHECK), NULL }; - menu = new bx_list_c(BXP_MENU_MISC, "Configure Everything Else", "", other_init_list); - menu->get_options()->set(menu->SHOW_PARENT); + menu = new bx_list_c(BXP_MENU_MISC, "misc", "Configure Everything Else", other_init_list); + menu->get_options()->set(bx_list_c::SHOW_PARENT); bx_param_c *runtime_init_list[] = { SIM->get_param_num(BXPN_VGA_UPDATE_INTERVAL), @@ -1580,15 +1563,15 @@ void bx_init_options() SIM->get_param_string(BXPN_USB1_OPTION2), NULL }; - 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); + menu = new bx_list_c(BXP_MENU_RUNTIME, "runtime", "Misc runtime options", runtime_init_list); + menu->get_options()->set(bx_list_c::SHOW_PARENT | bx_list_c::SHOW_GROUP_NAME); // param-tree test output //printf("parameter tree:\n"); //print_tree(root_param, 0); } -void bx_reset_options () +void bx_reset_options() { // cpu SIM->get_param("cpu")->reset(); @@ -1620,21 +1603,8 @@ void bx_reset_options () // standard ports SIM->get_param("ports")->reset(); - // ne2k - bx_options.ne2k.Oenabled->reset(); - bx_options.ne2k.Oioaddr->reset(); - bx_options.ne2k.Oirq->reset(); - bx_options.ne2k.Omacaddr->reset(); - bx_options.ne2k.Oethmod->reset(); - bx_options.ne2k.Oethdev->reset(); - bx_options.ne2k.Oscript->reset(); - - // pnic - bx_options.pnic.Oenabled->reset(); - bx_options.pnic.Omacaddr->reset(); - bx_options.pnic.Oethmod->reset(); - bx_options.pnic.Oethdev->reset(); - bx_options.pnic.Oscript->reset(); + // ne2k & pnic + SIM->get_param("network")->reset(); // SB16 bx_options.sb16.Oenabled->reset(); @@ -1651,7 +1621,7 @@ void bx_reset_options () bx_options.log.Oprefix->reset(); bx_options.log.Odebugger_filename->reset(); - // other + // misc bx_options.Otext_snapshot_check->reset(); } @@ -2835,19 +2805,20 @@ static Bit32s parse_line_formatted(char *context, int num_params, char *params[] char tmpchar[6]; int valid = 0; int n; - if (!bx_options.ne2k.Oenabled->get ()) { - bx_options.ne2k.Oethmod->set_by_name("null"); + base = (bx_list_c*) SIM->get_param(BXPN_NE2K); + if (!SIM->get_param_bool("enabled", base)->get()) { + SIM->get_param_enum("ethmod", base)->set_by_name("null"); } for (i=1; iset(strtoul(¶ms[i][7], NULL, 16)); valid |= 0x01; } else if (!strncmp(params[i], "irq=", 4)) { - bx_options.ne2k.Oirq->set (atol(¶ms[i][4])); + SIM->get_param_num("irq", base)->set(atol(¶ms[i][4])); valid |= 0x02; } else if (!strncmp(params[i], "mac=", 4)) { @@ -2858,34 +2829,32 @@ static Bit32s parse_line_formatted(char *context, int num_params, char *params[] } for (n=0;n<6;n++) tmpchar[n] = (unsigned char)tmp[n]; - bx_options.ne2k.Omacaddr->set (tmpchar); + SIM->get_param_string("macaddr", base)->set(tmpchar); valid |= 0x04; } else if (!strncmp(params[i], "ethmod=", 7)) { - if (!bx_options.ne2k.Oethmod->set_by_name(¶ms[i][7])) + if (!SIM->get_param_enum("ethmod", base)->set_by_name(¶ms[i][7])) PARSE_ERR(("%s: ethernet module '%s' not available", context, strdup(¶ms[i][7]))); } else if (!strncmp(params[i], "ethdev=", 7)) { - bx_options.ne2k.Oethdev->set(¶ms[i][7]); + SIM->get_param_string("ethdev", base)->set(¶ms[i][7]); } else if (!strncmp(params[i], "script=", 7)) { - bx_options.ne2k.Oscript->set(¶ms[i][7]); + SIM->get_param_string("script", base)->set(¶ms[i][7]); } else { PARSE_WARN(("%s: unknown parameter '%s' for ne2k ignored.", context, params[i])); } } - if (!bx_options.ne2k.Oenabled->get ()) { + if (!SIM->get_param_bool("enabled", base)->get()) { if (valid == 0x07) { - bx_options.ne2k.Oenabled->set (1); - } - else if (valid < 0x80) { + SIM->get_param_bool("enabled", base)->set(1); + } else if (valid < 0x80) { PARSE_ERR(("%s: ne2k directive incomplete (ioaddr, irq and mac are required)", context)); } - } - else { + } else { if (valid & 0x80) { - bx_options.ne2k.Oenabled->set (0); + SIM->get_param_bool("enabled", base)->set(0); } } } else if (!strcmp(params[0], "pnic")) { @@ -2893,8 +2862,9 @@ static Bit32s parse_line_formatted(char *context, int num_params, char *params[] char tmpchar[6]; int valid = 0; int n; - if (!bx_options.pnic.Oenabled->get ()) { - bx_options.pnic.Oethmod->set_by_name("null"); + base = (bx_list_c*) SIM->get_param(BXPN_PNIC); + if (!SIM->get_param_bool("enabled", base)->get()) { + SIM->get_param_enum("ethmod", base)->set_by_name("null"); } for (i=1; iset(tmpchar); valid |= 0x07; } else if (!strncmp(params[i], "ethmod=", 7)) { - if (!bx_options.pnic.Oethmod->set_by_name(¶ms[i][7])) + if (!SIM->get_param_enum("ethmod", base)->set_by_name(¶ms[i][7])) PARSE_ERR(("%s: ethernet module '%s' not available", context, strdup(¶ms[i][7]))); } else if (!strncmp(params[i], "ethdev=", 7)) { - bx_options.pnic.Oethdev->set(¶ms[i][7]); + SIM->get_param_string("ethdev", base)->set(¶ms[i][7]); } else if (!strncmp(params[i], "script=", 7)) { - bx_options.pnic.Oscript->set(¶ms[i][7]); + SIM->get_param_string("script", base)->set(¶ms[i][7]); } else { PARSE_WARN(("%s: unknown parameter '%s' for pnic ignored.", context, params[i])); } } - if (!bx_options.pnic.Oenabled->get ()) { + if (!SIM->get_param_bool("enabled", base)->get()) { if (valid == 0x07) { - bx_options.pnic.Oenabled->set (1); + SIM->get_param_bool("enabled", base)->set(1); } else if (valid < 0x80) { - PARSE_ERR(("%s: pnic directive incomplete (ioaddr, irq and mac are required)", context)); + PARSE_ERR(("%s: pnic directive incomplete (mac is required)", context)); } } else { if (valid & 0x80) { - bx_options.pnic.Oenabled->set (0); + SIM->get_param_bool("enabled", base)->set(0); } } } else if (!strcmp(params[0], "load32bitOSImage")) { @@ -3146,11 +3116,11 @@ int bx_write_usb_options(FILE *fp, bx_list_c *base, int n) return 0; } -int bx_write_pnic_options(FILE *fp, bx_pnic_options *opt) +int bx_write_pnic_options(FILE *fp, bx_list_c *base) { - fprintf (fp, "pnic: enabled=%d", opt->Oenabled->get ()); - if (opt->Oenabled->get ()) { - char *ptr = opt->Omacaddr->getptr (); + fprintf (fp, "pnic: enabled=%d", SIM->get_param_bool("enabled", base)->get()); + if (SIM->get_param_bool("enabled", base)->get()) { + char *ptr = SIM->get_param_string("macaddr", base)->getptr(); fprintf (fp, ", mac=%02x:%02x:%02x:%02x:%02x:%02x, ethmod=%s, ethdev=%s, script=%s", (unsigned int)(0xff & ptr[0]), (unsigned int)(0xff & ptr[1]), @@ -3158,33 +3128,33 @@ int bx_write_pnic_options(FILE *fp, bx_pnic_options *opt) (unsigned int)(0xff & ptr[3]), (unsigned int)(0xff & ptr[4]), (unsigned int)(0xff & ptr[5]), - opt->Oethmod->get_selected(), - opt->Oethdev->getptr(), - opt->Oscript->getptr()); + SIM->get_param_enum("ethmod", base)->get_selected(), + SIM->get_param_string("ethdev", base)->getptr(), + SIM->get_param_string("script", base)->getptr()); } fprintf (fp, "\n"); return 0; } -int bx_write_ne2k_options (FILE *fp, bx_ne2k_options *opt) +int bx_write_ne2k_options (FILE *fp, bx_list_c *base) { - fprintf (fp, "ne2k: enabled=%d", opt->Oenabled->get ()); - if (opt->Oenabled->get ()) { - char *ptr = opt->Omacaddr->getptr (); - fprintf (fp, ", ioaddr=0x%x, irq=%d, mac=%02x:%02x:%02x:%02x:%02x:%02x, ethmod=%s, ethdev=%s, script=%s", - opt->Oioaddr->get (), - opt->Oirq->get (), + fprintf(fp, "ne2k: enabled=%d", SIM->get_param_bool("enabled", base)->get()); + if (SIM->get_param_bool("enabled", base)->get()) { + char *ptr = SIM->get_param_string("macaddr", base)->getptr (); + fprintf(fp, ", ioaddr=0x%x, irq=%d, mac=%02x:%02x:%02x:%02x:%02x:%02x, ethmod=%s, ethdev=%s, script=%s", + SIM->get_param_num("ioaddr", base)->get(), + SIM->get_param_num("irq", base)->get(), (unsigned int)(0xff & ptr[0]), (unsigned int)(0xff & ptr[1]), (unsigned int)(0xff & ptr[2]), (unsigned int)(0xff & ptr[3]), (unsigned int)(0xff & ptr[4]), (unsigned int)(0xff & ptr[5]), - opt->Oethmod->get_selected(), - opt->Oethdev->getptr(), - opt->Oscript->getptr()); + SIM->get_param_enum("ethmod", base)->get_selected(), + SIM->get_param_string("ethdev", base)->getptr(), + SIM->get_param_string("script", base)->getptr()); } - fprintf (fp, "\n"); + fprintf(fp, "\n"); return 0; } @@ -3421,8 +3391,8 @@ int bx_write_configuration(char *rc, int overwrite) fprintf(fp, "screenmode: name=\"%s\"\n", SIM->get_param_string(BXPN_SCREENMODE)->getptr()); #endif bx_write_clock_cmos_options(fp); - bx_write_ne2k_options(fp, &bx_options.ne2k); - bx_write_pnic_options(fp, &bx_options.pnic); + bx_write_ne2k_options(fp, (bx_list_c*) SIM->get_param(BXPN_NE2K)); + bx_write_pnic_options(fp, (bx_list_c*) SIM->get_param(BXPN_PNIC)); bx_write_loader_options(fp); bx_write_log_options(fp, &bx_options.log); bx_write_keyboard_options(fp); diff --git a/bochs/gui/siminterface.h b/bochs/gui/siminterface.h index e4d959fb7..35705ac40 100644 --- a/bochs/gui/siminterface.h +++ b/bochs/gui/siminterface.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: siminterface.h,v 1.169 2006-03-01 17:14:36 vruppert Exp $ +// $Id: siminterface.h,v 1.170 2006-03-02 20:13:13 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Intro to siminterface by Bryce Denney: @@ -205,6 +205,10 @@ typedef enum { #define BXPN_USB1_OPTION1 "ports.usb.1.option1" #define BXPN_USB1_PORT2 "ports.usb.1.port2" #define BXPN_USB1_OPTION2 "ports.usb.1.option2" +#define BXPN_NE2K "network.ne2k" +#define BXPN_NE2K_ENABLED "network.ne2k.enabled" +#define BXPN_PNIC "network.pnic" +#define BXPN_PNIC_ENABLED "network.pnic.enabled" // base value for generated new parameter id #define BXP_NEW_PARAM_ID 1001 @@ -226,21 +230,6 @@ typedef enum { BXP_MENU_SOUND, BXP_MENU_MISC, BXP_MENU_RUNTIME, - BXP_NE2K_ENABLED, - BXP_NE2K_IOADDR, - BXP_NE2K_IRQ, - BXP_NE2K_MACADDR, - BXP_NE2K_ETHMOD, - BXP_NE2K_ETHDEV, - BXP_NE2K_SCRIPT, - BXP_NE2K, - BXP_PNIC_ENABLED, - BXP_PNIC_MACADDR, - BXP_PNIC_ETHMOD, - BXP_PNIC_ETHDEV, - BXP_PNIC_SCRIPT, - BXP_PNIC, - BXP_NETWORK, BXP_SB16_ENABLED, BXP_SB16_MIDIFILE, BXP_SB16_WAVEFILE, @@ -1154,14 +1143,6 @@ BOCHSAPI extern int n_atadevice_translation_names; BOCHSAPI extern char *clock_sync_names[]; BOCHSAPI extern int clock_sync_n_names; -typedef struct { - bx_param_bool_c *Oenabled; - bx_param_string_c *Omacaddr; - bx_param_enum_c *Oethmod; - bx_param_string_c *Oethdev; - bx_param_string_c *Oscript; -} bx_pnic_options; - //////////////////////////////////////////////////////////////////// // base class simulator interface, contains just virtual functions. // I'm not longer sure that having a base class is going to be of any diff --git a/bochs/gui/textconfig.cc b/bochs/gui/textconfig.cc index d9d14305d..77ad4c674 100644 --- a/bochs/gui/textconfig.cc +++ b/bochs/gui/textconfig.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: textconfig.cc,v 1.42 2006-03-01 17:14:36 vruppert Exp $ +// $Id: textconfig.cc,v 1.43 2006-03-02 20:13:13 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // This is code for a text-mode configuration interface. Note that this file @@ -278,8 +278,8 @@ static char *startup_options_prompt = "11. Keyboard & Mouse options\n" "12. Disk options\n" "13. Serial & Parallel port options\n" -"14. Sound Blaster 16 options\n" -"15. Network card options\n" +"14. Network card options\n" +"15. Sound Blaster 16 options\n" "16. Other options\n" "\n" "Please choose one: [0] "; @@ -499,8 +499,8 @@ int bx_config_interface (int menu) case 11: do_menu2("keyboard_mouse", NULL); break; case 12: do_menu(BXP_MENU_DISK); break; case 13: do_menu2("ports", NULL); break; - case 14: do_menu(BXP_SB16); break; - case 15: do_menu(BXP_NETWORK); break; + case 14: do_menu2("network", NULL); break; + case 15: do_menu(BXP_SB16); break; case 16: do_menu(BXP_MENU_MISC); break; default: BAD_OPTION(menu, choice); } diff --git a/bochs/gui/wxmain.cc b/bochs/gui/wxmain.cc index c950ab2c1..2d701ed45 100644 --- a/bochs/gui/wxmain.cc +++ b/bochs/gui/wxmain.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////// -// $Id: wxmain.cc,v 1.123 2006-03-01 21:24:20 vruppert Exp $ +// $Id: wxmain.cc,v 1.124 2006-03-02 20:13:13 vruppert Exp $ ///////////////////////////////////////////////////////////////// // // wxmain.cc implements the wxWidgets frame, toolbar, menus, and dialogs. @@ -666,7 +666,7 @@ void MyFrame::OnEditSerialParallel(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnEditNet(wxCommandEvent& WXUNUSED(event)) { ParamDialog dlg(this, -1); - bx_list_c *list = (bx_list_c*) SIM->get_param(BXP_NETWORK); + bx_list_c *list = (bx_list_c*) SIM->get_param("network"); dlg.SetTitle(list->get_title()->getptr()); dlg.AddParam(list); dlg.ShowModal(); @@ -676,7 +676,7 @@ void MyFrame::OnEditSound(wxCommandEvent& WXUNUSED(event)) { ParamDialog dlg(this, -1); bx_list_c *list = (bx_list_c*) SIM->get_param(BXP_SB16); - dlg.SetTitle(list->get_name()); + dlg.SetTitle(list->get_title()->getptr()); dlg.AddParam(list); dlg.SetRuntimeFlag(sim_thread != NULL); dlg.ShowModal(); @@ -686,7 +686,7 @@ void MyFrame::OnEditOther(wxCommandEvent& WXUNUSED(event)) { ParamDialog dlg(this, -1); bx_list_c *list = (bx_list_c*) SIM->get_param(BXP_MENU_MISC); - dlg.SetTitle(list->get_name ()); + dlg.SetTitle(list->get_title()->getptr()); dlg.AddParam(list); dlg.SetRuntimeFlag(sim_thread != NULL); dlg.ShowModal(); diff --git a/bochs/iodev/devices.cc b/bochs/iodev/devices.cc index bae3c999e..4c17fc373 100644 --- a/bochs/iodev/devices.cc +++ b/bochs/iodev/devices.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: devices.cc,v 1.91 2006-03-01 17:14:36 vruppert Exp $ +// $Id: devices.cc,v 1.92 2006-03-02 20:13:14 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2002 MandrakeSoft S.A. @@ -111,7 +111,7 @@ bx_devices_c::init(BX_MEM_C *newmem) { unsigned i; - BX_DEBUG(("Init $Id: devices.cc,v 1.91 2006-03-01 17:14:36 vruppert Exp $")); + BX_DEBUG(("Init $Id: devices.cc,v 1.92 2006-03-02 20:13:14 vruppert Exp $")); mem = newmem; /* set no-default handlers, will be overwritten by the real default handler */ @@ -169,9 +169,9 @@ bx_devices_c::init(BX_MEM_C *newmem) PLUG_load_plugin(busmouse, PLUGTYPE_OPTIONAL); } #endif - if (is_serial_enabled ()) + if (is_serial_enabled()) PLUG_load_plugin(serial, PLUGTYPE_OPTIONAL); - if (is_parallel_enabled ()) + if (is_parallel_enabled()) PLUG_load_plugin(parallel, PLUGTYPE_OPTIONAL); PLUG_load_plugin(extfpuirq, PLUGTYPE_OPTIONAL); #if BX_SUPPORT_GAME @@ -195,7 +195,9 @@ bx_devices_c::init(BX_MEM_C *newmem) } #endif #if BX_SUPPORT_PCIUSB - PLUG_load_plugin(pciusb, PLUGTYPE_OPTIONAL); + if (is_usb_enabled()) { + PLUG_load_plugin(pciusb, PLUGTYPE_OPTIONAL); + } #endif #if BX_SUPPORT_PCIDEV if (SIM->get_param_num(BXPN_PCIDEV_VENDOR)->get() != 0xffff) { @@ -203,7 +205,7 @@ bx_devices_c::init(BX_MEM_C *newmem) } #endif #if BX_SUPPORT_PCIPNIC - if (bx_options.pnic.Oenabled->get ()) { + if (SIM->get_param_bool(BXPN_PNIC_ENABLED)->get()) { PLUG_load_plugin(pcipnic, PLUGTYPE_OPTIONAL); } #endif @@ -213,7 +215,7 @@ bx_devices_c::init(BX_MEM_C *newmem) } // NE2000 NIC - if (bx_options.ne2k.Oenabled->get ()) { + if (SIM->get_param_bool(BXPN_NE2K_ENABLED)->get()) { #if BX_SUPPORT_NE2K PLUG_load_plugin(ne2k, PLUGTYPE_OPTIONAL); #else @@ -931,7 +933,7 @@ bx_devices_c::outp(Bit16u addr, Bit32u value, unsigned io_len) } } -bx_bool bx_devices_c::is_serial_enabled () +bx_bool bx_devices_c::is_serial_enabled() { char pname[24]; @@ -943,7 +945,7 @@ bx_bool bx_devices_c::is_serial_enabled () return false; } -bx_bool bx_devices_c::is_usb_enabled () +bx_bool bx_devices_c::is_usb_enabled() { char pname[20]; @@ -955,7 +957,7 @@ bx_bool bx_devices_c::is_usb_enabled () return false; } -bx_bool bx_devices_c::is_parallel_enabled () +bx_bool bx_devices_c::is_parallel_enabled() { char pname[26]; diff --git a/bochs/iodev/ne2k.cc b/bochs/iodev/ne2k.cc index ef78598d1..8553e44f6 100644 --- a/bochs/iodev/ne2k.cc +++ b/bochs/iodev/ne2k.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: ne2k.cc,v 1.81 2006-02-21 21:35:09 vruppert Exp $ +// $Id: ne2k.cc,v 1.82 2006-03-02 20:13:14 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2002 MandrakeSoft S.A. @@ -1316,11 +1316,13 @@ void bx_ne2k_c::init(void) { char devname[16]; + bx_list_c *base; - BX_DEBUG(("Init $Id: ne2k.cc,v 1.81 2006-02-21 21:35:09 vruppert Exp $")); + BX_DEBUG(("Init $Id: ne2k.cc,v 1.82 2006-03-02 20:13:14 vruppert Exp $")); - // Read in values from config file - memcpy(BX_NE2K_THIS s.physaddr, bx_options.ne2k.Omacaddr->getptr (), 6); + // Read in values from config interface + base = (bx_list_c*) SIM->get_param(BXPN_NE2K); + memcpy(BX_NE2K_THIS s.physaddr, SIM->get_param_string("macaddr", base)->getptr(), 6); BX_NE2K_THIS s.pci_enabled = 0; strcpy(devname, "NE2000 NIC"); @@ -1357,8 +1359,8 @@ bx_ne2k_c::init(void) } // Register the IRQ and i/o port addresses if (!BX_NE2K_THIS s.pci_enabled) { - BX_NE2K_THIS s.base_address = bx_options.ne2k.Oioaddr->get (); - BX_NE2K_THIS s.base_irq = bx_options.ne2k.Oirq->get (); + BX_NE2K_THIS s.base_address = SIM->get_param_num("ioaddr", base)->get(); + BX_NE2K_THIS s.base_irq = SIM->get_param_num("irq", base)->get(); DEV_register_irq(BX_NE2K_THIS s.base_irq, "NE2000 ethernet NIC"); @@ -1422,13 +1424,13 @@ bx_ne2k_c::init(void) BX_NE2K_THIS s.macaddr[i] = 0x57; // Attach to the simulated ethernet dev - char *ethmod = bx_options.ne2k.Oethmod->get_selected(); + char *ethmod = SIM->get_param_enum("ethmod", base)->get_selected(); BX_NE2K_THIS ethdev = eth_locator_c::create(ethmod, - bx_options.ne2k.Oethdev->getptr (), - (const char *) bx_options.ne2k.Omacaddr->getptr (), + SIM->get_param_string("ethdev", base)->getptr(), + (const char *) SIM->get_param_string("macaddr", base)->getptr(), rx_handler, this, - bx_options.ne2k.Oscript->getptr ()); + SIM->get_param_string("script", base)->getptr()); if (BX_NE2K_THIS ethdev == NULL) { BX_PANIC(("could not find eth module %s", ethmod)); @@ -1436,7 +1438,7 @@ bx_ne2k_c::init(void) BX_INFO(("could not find eth module %s - using null instead", ethmod)); BX_NE2K_THIS ethdev = eth_locator_c::create("null", NULL, - (const char *) bx_options.ne2k.Omacaddr->getptr (), + (const char *) SIM->get_param_string("macaddr", base)->getptr(), rx_handler, this, ""); if (BX_NE2K_THIS ethdev == NULL) diff --git a/bochs/iodev/pcipnic.cc b/bochs/iodev/pcipnic.cc index 0d0778a12..a07a755db 100644 --- a/bochs/iodev/pcipnic.cc +++ b/bochs/iodev/pcipnic.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: pcipnic.cc,v 1.16 2006-02-21 21:35:09 vruppert Exp $ +// $Id: pcipnic.cc,v 1.17 2006-03-02 20:13:14 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2003 Fen Systems Ltd. @@ -68,10 +68,9 @@ bx_pcipnic_c::init(void) { // called once when bochs initializes - if (!bx_options.pnic.Oenabled->get()) return; - - memcpy ( BX_PNIC_THIS s.macaddr, bx_options.pnic.Omacaddr->getptr(), - sizeof( BX_PNIC_THIS s.macaddr ) ); + // Read in values from config interface + base = (bx_list_c*) SIM->get_param(BXPN_PNIC); + memcpy(BX_PNIC_THIS s.physaddr, SIM->get_param_string("macaddr", base)->getptr(), 6); BX_PNIC_THIS s.devfunc = 0x00; DEV_register_pci_handlers(this, @@ -86,13 +85,13 @@ bx_pcipnic_c::init(void) // This code ripped wholesale from ne2k.cc: // Attach to the simulated ethernet dev - char *ethmod = bx_options.pnic.Oethmod->get_selected(); + char *ethmod = SIM->get_param_enum("ethmod", base)->get_selected(); BX_PNIC_THIS ethdev = eth_locator_c::create(ethmod, - bx_options.pnic.Oethdev->getptr (), - (const char *) bx_options.pnic.Omacaddr->getptr (), + SIM->get_param_string("ethdev", base)->getptr(), + (const char *) SIM->get_param_string("macaddr", base)->getptr(), rx_handler, this, - bx_options.pnic.Oscript->getptr ()); + SIM->get_param_string("script", base)->getptr()); if (BX_PNIC_THIS ethdev == NULL) { BX_PANIC(("could not find eth module %s", ethmod)); @@ -100,7 +99,7 @@ bx_pcipnic_c::init(void) BX_INFO(("could not find eth module %s - using null instead", ethmod)); BX_PNIC_THIS ethdev = eth_locator_c::create("null", NULL, - (const char *) bx_options.pnic.Omacaddr->getptr (), + (const char *) SIM->get_param_string("macaddr", base)->getptr(), rx_handler, this, ""); if (BX_PNIC_THIS ethdev == NULL)