From 154702eaca887db12a03ae2b47857a10029ad740 Mon Sep 17 00:00:00 2001 From: Volker Ruppert Date: Wed, 1 Mar 2006 17:14:36 +0000 Subject: [PATCH] - serial, parallel and usb options rewritten to a parameter tree - bx_init_options(): local variables cleanup - hide floppy devtype parameter (floppy media type change support not yet complete) - wx: menu order changed - keyboard.cc: removed obsolete FIXME - proposed parameter tree updated --- bochs/PARAM_TREE.txt | 18 +- bochs/bochs.h | 5 +- bochs/config.cc | 384 +++++++++++++++++++-------------------- bochs/gui/siminterface.h | 74 +------- bochs/gui/textconfig.cc | 6 +- bochs/gui/wxmain.cc | 46 ++--- bochs/gui/wxmain.h | 10 +- bochs/iodev/devices.cc | 19 +- bochs/iodev/keyboard.cc | 6 +- bochs/iodev/parallel.cc | 20 +- bochs/iodev/pciusb.cc | 54 +++--- bochs/iodev/serial.cc | 36 ++-- bochs/iodev/vga.cc | 4 +- 13 files changed, 313 insertions(+), 369 deletions(-) diff --git a/bochs/PARAM_TREE.txt b/bochs/PARAM_TREE.txt index 23f69eaf5..51c59ed1d 100644 --- a/bochs/PARAM_TREE.txt +++ b/bochs/PARAM_TREE.txt @@ -1,4 +1,4 @@ -$Id: PARAM_TREE.txt,v 1.8 2006-02-26 19:11:20 vruppert Exp $ +$Id: PARAM_TREE.txt,v 1.9 2006-03-01 17:14:35 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 @@ -197,22 +197,22 @@ ata ports serial - 0 + 1 enabled BXP_COM1_ENABLED mode BXP_COM1_MODE path BXP_COM1_PATH - 1 - (same options as ports.serial.0) 2 - (same options as ports.serial.0) + (same options as ports.serial.1) 3 - (same options as ports.serial.0) + (same options as ports.serial.1) + 4 + (same options as ports.serial.1) parallel - 0 + 1 enabled BXP_PARPORT1_ENABLED, outfile BXP_PARPORT1_OUTFILE, - 1 - (same options as ports.parallel.0) + 2 + (same options as ports.parallel.1) usb 1 enabled BXP_USB1_ENABLED, diff --git a/bochs/bochs.h b/bochs/bochs.h index 9725edeea..1a1ee04e4 100644 --- a/bochs/bochs.h +++ b/bochs/bochs.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: bochs.h,v 1.182 2006-02-26 19:11:20 vruppert Exp $ +// $Id: bochs.h,v 1.183 2006-03-01 17:14:36 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2002 MandrakeSoft S.A. @@ -515,9 +515,6 @@ typedef struct { #define BX_N_PCI_SLOTS 5 typedef struct BOCHSAPI { - bx_serial_options com[BX_N_SERIAL_PORTS]; - bx_parport_options par[BX_N_PARALLEL_PORTS]; - bx_usb_options usb[BX_N_USB_HUBS]; bx_ne2k_options ne2k; bx_pnic_options pnic; bx_sb16_options sb16; diff --git a/bochs/config.cc b/bochs/config.cc index 8dcdae537..288d41a43 100755 --- a/bochs/config.cc +++ b/bochs/config.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: config.cc,v 1.88 2006-02-28 14:02:06 vruppert Exp $ +// $Id: config.cc,v 1.89 2006-03-01 17:14:36 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2002 MandrakeSoft S.A. @@ -239,7 +239,6 @@ char *bx_param_string_handler(bx_param_string_c *param, int set, char *val, int DEV_floppy_set_media_status(0, 1); } } else { - SIM->get_param_enum(BXPN_FLOPPYA_DEVTYPE)->set_enabled(!empty); SIM->get_param_enum(BXPN_FLOPPYA_TYPE)->set_enabled(!empty); SIM->get_param_enum(BXPN_FLOPPYA_STATUS)->set_enabled(!empty); } @@ -263,7 +262,6 @@ char *bx_param_string_handler(bx_param_string_c *param, int set, char *val, int DEV_floppy_set_media_status(1, 1); } } else { - SIM->get_param_enum(BXPN_FLOPPYB_DEVTYPE)->set_enabled(!empty); SIM->get_param_enum(BXPN_FLOPPYB_TYPE)->set_enabled(!empty); SIM->get_param_enum(BXPN_FLOPPYB_STATUS)->set_enabled(!empty); } @@ -328,6 +326,7 @@ 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_filename_c *path; char name[1024], descr[1024], group[16], label[1024]; @@ -738,13 +737,13 @@ void bx_init_options() bx_list_c *mouse = new bx_list_c(kbd_mouse, "mouse", "Mouse Options"); // keyboard & mouse options - bx_param_enum_c *keyboard_type = new bx_param_enum_c(keyboard, + type = new bx_param_enum_c(keyboard, "type", "Keyboard type", "Keyboard type reported by the 'identify keyboard' command", keyboard_type_names, BX_KBD_MF_TYPE, BX_KBD_XT_TYPE); - keyboard_type->set_ask_format ("Enter keyboard type: [%s] "); + type->set_ask_format ("Enter keyboard type: [%s] "); new bx_param_num_c(keyboard, "serial_delay", "Keyboard serial delay", @@ -789,7 +788,7 @@ void bx_init_options() "serial_wheel", NULL }; - bx_param_enum_c *mouse_type = new bx_param_enum_c(mouse, + type = new bx_param_enum_c(mouse, "type", "Mouse type", "The mouse type can be one of these: 'none', 'ps2', 'imps2', 'serial', 'serial_wheel'" #if BX_SUPPORT_BUSMOUSE @@ -802,7 +801,7 @@ void bx_init_options() mouse_type_list, BX_MOUSE_TYPE_PS2, BX_MOUSE_TYPE_NONE); - mouse_type->set_ask_format("Choose the type of mouse [%s] "); + type->set_ask_format("Choose the type of mouse [%s] "); new bx_param_bool_c(mouse, "enabled", "Enable the mouse capture", @@ -873,7 +872,7 @@ void bx_init_options() bx_list_c *floppya = new bx_list_c(floppy, "0", "Floppy Disk 0"); bx_list_c *floppyb = new bx_list_c(floppy, "1", "Floppy Disk 1"); - bx_param_enum_c *devtype, *type, *status; + bx_param_enum_c *devtype; // floppy options path = new bx_param_filename_c(floppya, "path", @@ -890,6 +889,7 @@ void bx_init_options() floppy_type_names, BX_FLOPPY_NONE, BX_FLOPPY_NONE); + devtype->set_enabled(0); // hide devtype parameter type = new bx_param_enum_c(floppya, "type", "Type of floppy disk", @@ -931,6 +931,7 @@ void bx_init_options() floppy_type_names, BX_FLOPPY_NONE, BX_FLOPPY_NONE); + devtype->set_enabled(0); // hide devtype parameter type = new bx_param_enum_c(floppyb, "type", "Type of floppy disk", @@ -1059,7 +1060,7 @@ void bx_init_options() 0); present->set_ask_format("Device is enabled: [%s] "); - bx_param_enum_c *type = new bx_param_enum_c(menu, + type = new bx_param_enum_c(menu, "type", "Type of ATA device", "Type of ATA device (disk or cdrom)", @@ -1075,7 +1076,7 @@ void bx_init_options() "", BX_PATHNAME_LEN); path->set_ask_format("Enter new filename: [%s] "); - bx_param_enum_c *mode = new bx_param_enum_c(menu, + mode = new bx_param_enum_c(menu, "mode", "Type of disk image", "Mode of the ATA harddisk", @@ -1084,7 +1085,7 @@ void bx_init_options() BX_ATA_MODE_FLAT); mode->set_ask_format("Enter mode of ATA device, (flat, concat, etc.): [%s] "); - bx_param_enum_c *status = new bx_param_enum_c(menu, + status = new bx_param_enum_c(menu, "status", "Inserted", "CD-ROM media status (inserted / ejected)", @@ -1199,37 +1200,35 @@ void bx_init_options() menu = new bx_list_c(BXP_MENU_DISK, "Bochs Disk Options", "", disk_menu_init_list); menu->get_options()->set(bx_list_c::SHOW_PARENT); - // serial and parallel port options - -#define PAR_SER_INIT_LIST_MAX \ - ((BXP_PARAMS_PER_PARALLEL_PORT * BX_N_PARALLEL_PORTS) \ - + (BXP_PARAMS_PER_SERIAL_PORT * BX_N_SERIAL_PORTS) \ - + (BXP_PARAMS_PER_USB_HUB * BX_N_USB_HUBS)) - bx_param_c *par_ser_init_list[1+PAR_SER_INIT_LIST_MAX]; - bx_param_c **par_ser_ptr = &par_ser_init_list[0]; + // ports subtree + bx_list_c *ports = new bx_list_c(root_param, "ports", "Serial and Parallel Port Options"); + ports->get_options()->set(bx_list_c::USE_TAB_WINDOW | bx_list_c::SHOW_PARENT); // parallel ports + bx_list_c *parallel = new bx_list_c(ports, "parallel", "Parallel Port Options"); + parallel->get_options()->set(bx_list_c::SHOW_PARENT); for (i=0; iadd (bx_options.par[i].Ooutfile); - bx_options.par[i].Oenabled->set_dependent_list (deplist); - // add to menu - *par_ser_ptr++ = bx_options.par[i].Oenabled; - *par_ser_ptr++ = bx_options.par[i].Ooutfile; + sprintf(name, "%d", i+1); + sprintf(label, "Parallel Port %d", i+1); + menu = new bx_list_c(parallel, strdup(name), label); + menu->get_options()->set(bx_list_c::SERIES_ASK); + sprintf(label, "Enable parallel port #%d", i+1); + sprintf(descr, "Controls whether parallel port #%d is installed or not", i+1); + enabled = new bx_param_bool_c(menu, + "enabled", + strdup(label), + strdup(descr), + (i==0)? 1 : 0); // only enable #1 by default + sprintf(label, "Parallel port #%d output file", i+1); + sprintf(descr, "Data written to parport#%d by the guest OS is written to this file", i+1); + path = new bx_param_filename_c(menu, + "outfile", + strdup(label), + strdup(descr), + "", BX_PATHNAME_LEN); + deplist = new bx_list_c(BXP_NULL, 1); + deplist->add(path); + enabled->set_dependent_list(deplist); } static char *serial_mode_list[] = { @@ -1243,99 +1242,91 @@ void bx_init_options() }; // serial ports + bx_list_c *serial = new bx_list_c(ports, "serial", "Serial Port Options"); + serial->get_options()->set(bx_list_c::SHOW_PARENT); for (i=0; iset_ask_format ("Choose I/O mode of the serial device [%s] "); - sprintf (name, "Pathname of the serial device for COM%d", i+1); - sprintf (descr, "The path can be a real serial device or a pty (X/Unix only)"); - bx_options.com[i].Odev = new bx_param_filename_c ( - BXP_COMx_PATH(i+1), - strdup(name), - strdup(descr), - "", BX_PATHNAME_LEN); - deplist = new bx_list_c (BXP_NULL, 2); - deplist->add (bx_options.com[i].Omode); - deplist->add (bx_options.com[i].Odev); - bx_options.com[i].Oenabled->set_dependent_list (deplist); - // add to menu - *par_ser_ptr++ = bx_options.com[i].Oenabled; - *par_ser_ptr++ = bx_options.com[i].Omode; - *par_ser_ptr++ = bx_options.com[i].Odev; + sprintf(name, "%d", i+1); + sprintf(label, "Serial Port %d", i+1); + menu = new bx_list_c(serial, strdup(name), label); + menu->get_options()->set(bx_list_c::SERIES_ASK); + sprintf(label, "Enable serial port #%d (COM%d)", i+1, i+1); + sprintf(descr, "Controls whether COM%d is installed or not", i+1); + enabled = new bx_param_bool_c(menu, + "enabled", + strdup(label), + strdup(descr), + (i==0)?1 : 0); // only enable the first by default + sprintf(label, "I/O mode of the serial device for COM%d", i+1); + sprintf(descr, "The mode can be one these: 'null', 'file', 'term', 'raw', 'mouse', 'socket'"); + mode = new bx_param_enum_c(menu, + "mode", + strdup(label), + strdup(descr), + serial_mode_list, + 0, + 0); + mode->set_ask_format("Choose I/O mode of the serial device [%s] "); + sprintf(label, "Pathname of the serial device for COM%d", i+1); + sprintf(descr, "The path can be a real serial device or a pty (X/Unix only)"); + path = new bx_param_filename_c(menu, + "dev", + strdup(label), + strdup(descr), + "", BX_PATHNAME_LEN); + deplist = new bx_list_c(BXP_NULL, 2); + deplist->add(mode); + deplist->add(path); + enabled->set_dependent_list(deplist); } + bx_param_string_c *port, *option; + // usb hubs + bx_list_c *usb = new bx_list_c(ports, "usb", "USB Hub Options"); + usb->get_options()->set(bx_list_c::SHOW_PARENT); for (i=0; iadd (bx_options.usb[i].Oport1); - deplist->add (bx_options.usb[i].Ooption1); - deplist->add (bx_options.usb[i].Oport2); - deplist->add (bx_options.usb[i].Ooption2); - bx_options.usb[i].Oenabled->set_dependent_list (deplist); - // add to menu - *par_ser_ptr++ = bx_options.usb[i].Oenabled; - *par_ser_ptr++ = bx_options.usb[i].Oport1; - *par_ser_ptr++ = bx_options.usb[i].Ooption1; - *par_ser_ptr++ = bx_options.usb[i].Oport2; - *par_ser_ptr++ = bx_options.usb[i].Ooption2; - - bx_options.usb[i].Oport1->set_group (strdup(group)); - bx_options.usb[i].Ooption1->set_group (strdup(group)); - bx_options.usb[i].Oport2->set_group (strdup(group)); - bx_options.usb[i].Ooption2->set_group (strdup(group)); + sprintf(group, "USB%d", i+1); + sprintf(name, "%d", i+1); + sprintf(label, "USB Hub %d", i+1); + menu = new bx_list_c(usb, strdup(name), label); + 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, + "enabled", + strdup(label), + strdup(descr), + 0); + deplist = new bx_list_c(BXP_NULL, 4); + port = new bx_param_string_c(menu, + "port1", + "Port #1 device", + "Device connected to USB port #1", + "", BX_PATHNAME_LEN); + port->set_group(strdup(group)); + option = new bx_param_string_c(menu, + "option1", + "Port #1 device 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", + "Device connected to USB port #2", + "", BX_PATHNAME_LEN); + port->set_group(strdup(group)); + option = new bx_param_string_c(menu, + "option2", + "Port #2 device 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); } - // add final NULL at the end, and build the menu - *par_ser_ptr = NULL; - menu = new bx_list_c (BXP_MENU_SERIAL_PARALLEL, - "Serial and Parallel Port Options", - "", - par_ser_init_list); - menu->get_options ()->set (menu->SHOW_PARENT); - menu->get_options ()->set (menu->SHOW_GROUP_NAME); bx_options.Otext_snapshot_check = new bx_param_bool_c (BXP_TEXT_SNAPSHOT_CHECK, "Enable panic for use in bochs testing", @@ -1579,10 +1570,10 @@ void bx_init_options() SIM->get_param_string(BXPN_USER_SHORTCUT), bx_options.sb16.Odmatimer, bx_options.sb16.Ologlevel, - bx_options.usb[0].Oport1, - bx_options.usb[0].Ooption1, - bx_options.usb[0].Oport2, - bx_options.usb[0].Ooption2, + SIM->get_param_string(BXPN_USB1_PORT1), + SIM->get_param_string(BXPN_USB1_OPTION1), + SIM->get_param_string(BXPN_USB1_PORT2), + SIM->get_param_string(BXPN_USB1_OPTION2), NULL }; menu = new bx_list_c (BXP_MENU_RUNTIME, "Misc runtime options", "", runtime_init_list); @@ -1595,8 +1586,6 @@ void bx_init_options() void bx_reset_options () { - Bit8u i; - // cpu SIM->get_param("cpu")->reset(); @@ -1625,22 +1614,7 @@ void bx_reset_options () SIM->get_param("ata")->reset(); // standard ports - for (i=0; ireset(); - bx_options.com[i].Omode->reset(); - bx_options.com[i].Odev->reset(); - } - for (i=0; ireset(); - bx_options.par[i].Ooutfile->reset(); - } - for (i=0; ireset(); - bx_options.usb[i].Oport1->reset(); - bx_options.usb[i].Ooption1->reset(); - bx_options.usb[i].Oport2->reset(); - bx_options.usb[i].Ooption2->reset(); - } + SIM->get_param("ports")->reset(); // ne2k bx_options.ne2k.Oenabled->reset(); @@ -2651,73 +2625,82 @@ static Bit32s parse_line_formatted(char *context, int num_params, char *params[] else bx_options.sb16.Oenabled->set (0); } else if ((!strncmp(params[0], "com", 3)) && (strlen(params[0]) == 4)) { + char tmpname[80]; idx = params[0][3]; if ((idx < '1') || (idx > '9')) { PARSE_ERR(("%s: comX directive malformed.", context)); } - idx -= '1'; - if (idx >= BX_N_SERIAL_PORTS) { + idx -= '0'; + if (idx > BX_N_SERIAL_PORTS) { PARSE_ERR(("%s: comX port number out of range.", context)); } + sprintf(tmpname, "ports.serial.%d", idx); + base = (bx_list_c*) SIM->get_param(tmpname); for (i=1; iset(atol(¶ms[i][8])); } else if (!strncmp(params[i], "mode=", 5)) { - if (!bx_options.com[idx].Omode->set_by_name(¶ms[i][5])) - PARSE_ERR(("%s: com%d serial port mode '%s' not available", context, idx+1, strdup(¶ms[i][5]))); - bx_options.com[idx].Oenabled->set (1); + if (!SIM->get_param_enum("mode", base)->set_by_name(¶ms[i][5])) + PARSE_ERR(("%s: com%d serial port mode '%s' not available", context, idx, strdup(¶ms[i][5]))); + SIM->get_param_bool("enabled", base)->set(1); } else if (!strncmp(params[i], "dev=", 4)) { - bx_options.com[idx].Odev->set (¶ms[i][4]); - bx_options.com[idx].Oenabled->set (1); + SIM->get_param_string("dev", base)->set(¶ms[i][4]); + SIM->get_param_bool("enabled", base)->set(1); } else { - PARSE_ERR(("%s: unknown parameter for com%d ignored.", context, idx+1)); + PARSE_ERR(("%s: unknown parameter for com%d ignored.", context, idx)); } } } else if ((!strncmp(params[0], "parport", 7)) && (strlen(params[0]) == 8)) { + char tmpname[80]; idx = params[0][7]; if ((idx < '1') || (idx > '9')) { PARSE_ERR(("%s: parportX directive malformed.", context)); } - idx -= '1'; - if (idx >= BX_N_PARALLEL_PORTS) { + idx -= '0'; + if (idx > BX_N_PARALLEL_PORTS) { PARSE_ERR(("%s: parportX port number out of range.", context)); } + sprintf(tmpname, "ports.parallel.%d", idx); + base = (bx_list_c*) SIM->get_param(tmpname); for (i=1; iset(atol(¶ms[i][8])); } else if (!strncmp(params[i], "file=", 5)) { - bx_options.par[idx].Ooutfile->set(¶ms[i][5]); - bx_options.par[idx].Oenabled->set (1); + SIM->get_param_string("outfile", base)->set(¶ms[i][5]); + SIM->get_param_bool("enabled", base)->set(1); } else { - BX_ERROR(("%s: unknown parameter for parport%d ignored.", context, idx+1)); + BX_ERROR(("%s: unknown parameter for parport%d ignored.", context, idx)); } } } else if ((!strncmp(params[0], "usb", 3)) && (strlen(params[0]) == 4)) { + char tmpname[80]; idx = params[0][3]; if ((idx < '1') || (idx > '9')) { PARSE_ERR(("%s: usbX directive malformed.", context)); } - idx -= '1'; - if (idx >= BX_N_USB_HUBS) { + idx -= '0'; + if (idx > BX_N_USB_HUBS) { PARSE_ERR(("%s: usbX hub number out of range.", context)); } + sprintf(tmpname, "ports.usb.%d", idx); + base = (bx_list_c*) SIM->get_param(tmpname); for (i=1; iset(atol(¶ms[i][8])); } else if (!strncmp(params[i], "port1=", 6)) { - bx_options.usb[idx].Oport1->set(¶ms[i][6]); - } else if (!strncmp(params[i], "option1=", 6)) { - bx_options.usb[idx].Ooption1->set(¶ms[i][6]); + SIM->get_param_string("port1", base)->set(¶ms[i][6]); + } else if (!strncmp(params[i], "option1=", 8)) { + SIM->get_param_string("option1", base)->set(¶ms[i][8]); } else if (!strncmp(params[i], "port2=", 6)) { - bx_options.usb[idx].Oport2->set(¶ms[i][6]); - } else if (!strncmp(params[i], "option2=", 6)) { - bx_options.usb[idx].Ooption2->set(¶ms[i][6]); + SIM->get_param_string("port2", base)->set(¶ms[i][6]); + } else if (!strncmp(params[i], "option2=", 8)) { + SIM->get_param_string("option2", base)->set(¶ms[i][8]); } else if (!strncmp(params[i], "ioaddr=", 7)) { PARSE_WARN(("%s: usb ioaddr is now DEPRECATED (assigned by BIOS).", context)); } else if (!strncmp(params[i], "irq=", 4)) { PARSE_WARN(("%s: usb irq is now DEPRECATED (assigned by BIOS).", context)); } else { - PARSE_WARN(("%s: unknown parameter '%s' for usb%d ignored.", context, params[i], idx+1)); + PARSE_WARN(("%s: unknown parameter '%s' for usb%d ignored.", context, params[i], idx)); } } } else if (!strcmp(params[0], "i440fxsupport")) { @@ -3064,7 +3047,7 @@ static char *fdtypes[] = { "none", "1_2", "1_44", "2_88", "720k", "360k", "160k", "180k", "320k" }; -int bx_write_floppy_options (FILE *fp, int drive) +int bx_write_floppy_options(FILE *fp, int drive) { char path[80], type[80], status[80]; @@ -3086,7 +3069,7 @@ int bx_write_floppy_options (FILE *fp, int drive) return 0; } -int bx_write_ata_options (FILE *fp, Bit8u channel, bx_list_c *base) +int bx_write_ata_options(FILE *fp, Bit8u channel, bx_list_c *base) { fprintf(fp, "ata%d: enabled=%d", channel, SIM->get_param_bool("enabled", base)->get()); @@ -3099,7 +3082,7 @@ int bx_write_ata_options (FILE *fp, Bit8u channel, bx_list_c *base) return 0; } -int bx_write_atadevice_options (FILE *fp, Bit8u channel, Bit8u drive, bx_list_c *base) +int bx_write_atadevice_options(FILE *fp, Bit8u channel, Bit8u drive, bx_list_c *base) { if (SIM->get_param_bool("present", base)->get()) { fprintf(fp, "ata%d-%s: ", channel, drive==0?"master":"slave"); @@ -3197,39 +3180,41 @@ int bx_write_atadevice_options (FILE *fp, Bit8u channel, Bit8u drive, bx_list_c return 0; } -int bx_write_parport_options (FILE *fp, bx_parport_options *opt, int n) +int bx_write_parport_options(FILE *fp, bx_list_c *base, int n) { - fprintf (fp, "parport%d: enabled=%d", n, opt->Oenabled->get ()); - if (opt->Oenabled->get ()) { - fprintf (fp, ", file=\"%s\"", opt->Ooutfile->getptr ()); + fprintf(fp, "parport%d: enabled=%d", n, SIM->get_param_bool("enabled", base)->get()); + if (SIM->get_param_bool("enabled", base)->get()) { + fprintf(fp, ", file=\"%s\"", SIM->get_param_string("outfile", base)->getptr()); } - fprintf (fp, "\n"); + fprintf(fp, "\n"); return 0; } -int bx_write_serial_options (FILE *fp, bx_serial_options *opt, int n) +int bx_write_serial_options(FILE *fp, bx_list_c *base, int n) { - fprintf (fp, "com%d: enabled=%d", n, opt->Oenabled->get ()); - if (opt->Oenabled->get ()) { - fprintf(fp, ", mode=%s", opt->Omode->get_selected()); - fprintf(fp, ", dev=\"%s\"", opt->Odev->getptr()); + fprintf(fp, "com%d: enabled=%d", n, SIM->get_param_bool("enabled", base)->get()); + if (SIM->get_param_bool("enabled", base)->get()) { + fprintf(fp, ", mode=%s", SIM->get_param_enum("mode", base)->get_selected()); + fprintf(fp, ", dev=\"%s\"", SIM->get_param_string("dev", base)->getptr()); } - fprintf (fp, "\n"); + fprintf(fp, "\n"); return 0; } -int bx_write_usb_options (FILE *fp, bx_usb_options *opt, int n) +int bx_write_usb_options(FILE *fp, bx_list_c *base, int n) { - fprintf (fp, "usb%d: enabled=%d", n, opt->Oenabled->get ()); - if (opt->Oenabled->get ()) { - fprintf (fp, ", port1=%s, option1=%s", opt->Oport1->getptr (), opt->Ooption1->getptr ()); - fprintf (fp, ", port2=%s, option2=%s", opt->Oport2->getptr (), opt->Ooption2->getptr ()); + fprintf(fp, "usb%d: enabled=%d", n, SIM->get_param_bool("enabled", base)->get()); + if (SIM->get_param_bool("enabled", base)->get()) { + fprintf(fp, ", port1=%s, option1=%s", SIM->get_param_string("port1", base)->getptr(), + SIM->get_param_string("option1", base)->getptr()); + fprintf(fp, ", port2=%s, option2=%s", SIM->get_param_string("port2", base)->getptr(), + SIM->get_param_string("option2", base)->getptr()); } - fprintf (fp, "\n"); + fprintf(fp, "\n"); return 0; } -int bx_write_pnic_options (FILE *fp, bx_pnic_options *opt) +int bx_write_pnic_options(FILE *fp, bx_pnic_options *opt) { fprintf (fp, "pnic: enabled=%d", opt->Oenabled->get ()); if (opt->Oenabled->get ()) { @@ -3455,12 +3440,18 @@ int bx_write_configuration(char *rc, int overwrite) } // parallel ports for (i=0; iget_param(tmpdev); + bx_write_parport_options(fp, base, i+1); } // serial ports for (i=0; iget_param(tmpdev); + bx_write_serial_options(fp, base, i+1); } + base = (bx_list_c*) SIM->get_param("ports.usb.1"); + bx_write_usb_options(fp, base, 1); // pci fprintf(fp, "i440fxsupport: enabled=%d", SIM->get_param_bool(BXPN_I440FX_SUPPORT)->get()); @@ -3479,7 +3470,6 @@ int bx_write_configuration(char *rc, int overwrite) SIM->get_param_num(BXPN_PCIDEV_VENDOR)->get(), SIM->get_param_num(BXPN_PCIDEV_DEVICE)->get()); } - bx_write_usb_options(fp, &bx_options.usb[0], 1); bx_write_sb16_options(fp, &bx_options.sb16); fprintf(fp, "vga_update_interval: %u\n", SIM->get_param_num(BXPN_VGA_UPDATE_INTERVAL)->get()); fprintf(fp, "vga: extension=%s\n", SIM->get_param_string(BXPN_VGA_EXTENSION)->getptr()); diff --git a/bochs/gui/siminterface.h b/bochs/gui/siminterface.h index 3dd431ade..e4d959fb7 100644 --- a/bochs/gui/siminterface.h +++ b/bochs/gui/siminterface.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: siminterface.h,v 1.168 2006-02-28 16:19:29 vruppert Exp $ +// $Id: siminterface.h,v 1.169 2006-03-01 17:14:36 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Intro to siminterface by Bryce Denney: @@ -75,7 +75,7 @@ // // An important part of the siminterface implementation is the use of parameter // classes, or bx_param_*. The parameter classes are described below, where -// they are declared. Search for "parameter classes" below for detals. +// they are declared. Search for "parameter classes" below for details. // // Also this header file declares data structures for certain events that pass // between the siminterface and the CI. Search for "event structures" below. @@ -200,6 +200,11 @@ typedef enum { #define BXPN_ATA1_SLAVE "ata.1.slave" #define BXPN_ATA2_SLAVE "ata.2.slave" #define BXPN_ATA3_SLAVE "ata.3.slave" +#define BXPN_USB1_ENABLED "ports.usb.1.enabled" +#define BXPN_USB1_PORT1 "ports.usb.1.port1" +#define BXPN_USB1_OPTION1 "ports.usb.1.option1" +#define BXPN_USB1_PORT2 "ports.usb.1.port2" +#define BXPN_USB1_OPTION2 "ports.usb.1.option2" // base value for generated new parameter id #define BXP_NEW_PARAM_ID 1001 @@ -212,32 +217,12 @@ typedef enum { BXP_NULL = 301, BXP_TEXT_SNAPSHOT_CHECK, -#define BXP_PARAMS_PER_SERIAL_PORT 3 - BXP_COM1_ENABLED, - BXP_COM1_MODE, - BXP_COM1_PATH, - BXP_COM2_ENABLED, - BXP_COM2_MODE, - BXP_COM2_PATH, - BXP_COM3_ENABLED, - BXP_COM3_MODE, - BXP_COM3_PATH, - BXP_COM4_ENABLED, - BXP_COM4_MODE, - BXP_COM4_PATH, -#define BXP_PARAMS_PER_USB_HUB 5 - BXP_USB1_ENABLED, - BXP_USB1_PORT1, - BXP_USB1_OPTION1, - BXP_USB1_PORT2, - BXP_USB1_OPTION2, BXP_LOG_FILENAME, BXP_LOG_PREFIX, BXP_DEBUGGER_LOG_FILENAME, BXP_MENU_MAIN, BXP_MENU_MEMORY, BXP_MENU_DISK, - BXP_MENU_SERIAL_PARALLEL, BXP_MENU_SOUND, BXP_MENU_MISC, BXP_MENU_RUNTIME, @@ -265,11 +250,6 @@ typedef enum { BXP_SB16_LOGLEVEL, BXP_SB16_DMATIMER, BXP_SB16, -#define BXP_PARAMS_PER_PARALLEL_PORT 2 - BXP_PARPORT1_ENABLED, - BXP_PARPORT1_OUTFILE, - BXP_PARPORT2_ENABLED, - BXP_PARPORT2_OUTFILE, BXP_BOCHS_START, // How Bochs starts // experiment: add params for CPU registers BXP_CPU_PARAMETERS, @@ -349,32 +329,6 @@ typedef enum { BXP_THIS_IS_THE_LAST // used to determine length of list } bx_id; -// use x=1,2,3,4 -#define BXP_COMx_ENABLED(x) \ - (bx_id)(BXP_COM1_ENABLED + (((x)-1)*BXP_PARAMS_PER_SERIAL_PORT)) -#define BXP_COMx_MODE(x) \ - (bx_id)(BXP_COM1_MODE + (((x)-1)*BXP_PARAMS_PER_SERIAL_PORT)) -#define BXP_COMx_PATH(x) \ - (bx_id)(BXP_COM1_PATH + (((x)-1)*BXP_PARAMS_PER_SERIAL_PORT)) - -// use x=1 -#define BXP_USBx_ENABLED(x) \ - (bx_id)(BXP_USB1_ENABLED + (((x)-1)*BXP_PARAMS_PER_USB_HUB)) -#define BXP_USBx_PORT1(x) \ - (bx_id)(BXP_USB1_PORT1 + (((x)-1)*BXP_PARAMS_PER_USB_HUB)) -#define BXP_USBx_OPTION1(x) \ - (bx_id)(BXP_USB1_OPTION1 + (((x)-1)*BXP_PARAMS_PER_USB_HUB)) -#define BXP_USBx_PORT2(x) \ - (bx_id)(BXP_USB1_PORT2 + (((x)-1)*BXP_PARAMS_PER_USB_HUB)) -#define BXP_USBx_OPTION2(x) \ - (bx_id)(BXP_USB1_OPTION2 + (((x)-1)*BXP_PARAMS_PER_USB_HUB)) - -// use x=1,2 -#define BXP_PARPORTx_ENABLED(x) \ - (bx_id)(BXP_PARPORT1_ENABLED + (((x)-1)*BXP_PARAMS_PER_PARALLEL_PORT)) -#define BXP_PARPORTx_OUTFILE(x) \ - (bx_id)(BXP_PARPORT1_OUTFILE + (((x)-1)*BXP_PARAMS_PER_PARALLEL_PORT)) - typedef enum { BX_TOOLBAR_UNDEFINED, BX_TOOLBAR_FLOPPYA, @@ -1200,20 +1154,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_enum_c *Omode; - bx_param_string_c *Odev; -} bx_serial_options; - -typedef struct { - bx_param_bool_c *Oenabled; - bx_param_string_c *Oport1; - bx_param_string_c *Ooption1; - bx_param_string_c *Oport2; - bx_param_string_c *Ooption2; -} bx_usb_options; - typedef struct { bx_param_bool_c *Oenabled; bx_param_string_c *Omacaddr; diff --git a/bochs/gui/textconfig.cc b/bochs/gui/textconfig.cc index 8ce59878b..d9d14305d 100644 --- a/bochs/gui/textconfig.cc +++ b/bochs/gui/textconfig.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: textconfig.cc,v 1.41 2006-02-26 19:11:20 vruppert Exp $ +// $Id: textconfig.cc,v 1.42 2006-03-01 17:14:36 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // This is code for a text-mode configuration interface. Note that this file @@ -277,7 +277,7 @@ static char *startup_options_prompt = "10. Bochs Display & Interface options\n" "11. Keyboard & Mouse options\n" "12. Disk options\n" -"13. Serial or Parallel port options\n" +"13. Serial & Parallel port options\n" "14. Sound Blaster 16 options\n" "15. Network card options\n" "16. Other options\n" @@ -498,7 +498,7 @@ int bx_config_interface (int menu) case 10: do_menu2("display", NULL); break; case 11: do_menu2("keyboard_mouse", NULL); break; case 12: do_menu(BXP_MENU_DISK); break; - case 13: do_menu(BXP_MENU_SERIAL_PARALLEL); break; + case 13: do_menu2("ports", NULL); break; case 14: do_menu(BXP_SB16); break; case 15: do_menu(BXP_NETWORK); break; case 16: do_menu(BXP_MENU_MISC); break; diff --git a/bochs/gui/wxmain.cc b/bochs/gui/wxmain.cc index 35da781c8..5bfc0f5b0 100644 --- a/bochs/gui/wxmain.cc +++ b/bochs/gui/wxmain.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////// -// $Id: wxmain.cc,v 1.121 2006-02-27 12:03:56 vruppert Exp $ +// $Id: wxmain.cc,v 1.122 2006-03-01 17:14:36 vruppert Exp $ ///////////////////////////////////////////////////////////////// // // wxmain.cc implements the wxWidgets frame, toolbar, menus, and dialogs. @@ -324,9 +324,9 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame) EVT_MENU(ID_Edit_Display, MyFrame::OnEditDisplay) EVT_MENU(ID_Edit_Keyboard, MyFrame::OnEditKeyboard) EVT_MENU(ID_Edit_Boot, MyFrame::OnEditBoot) - EVT_MENU(ID_Edit_Sound, MyFrame::OnEditSound) - EVT_MENU(ID_Edit_Network, MyFrame::OnEditNet) EVT_MENU(ID_Edit_Serial_Parallel, MyFrame::OnEditSerialParallel) + EVT_MENU(ID_Edit_Network, MyFrame::OnEditNet) + EVT_MENU(ID_Edit_Sound, MyFrame::OnEditSound) EVT_MENU(ID_Edit_Other, MyFrame::OnEditOther) EVT_MENU(ID_Log_Prefs, MyFrame::OnLogPrefs) EVT_MENU(ID_Log_PrefsDevice, MyFrame::OnLogPrefsDevice) @@ -437,9 +437,9 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size, menuEdit->Append(ID_Edit_Display, "&Display + Interface..." ); menuEdit->Append(ID_Edit_Keyboard, "&Keyboard + Mouse..." ); menuEdit->Append(ID_Edit_Boot, "&Boot..." ); - menuEdit->Append(ID_Edit_Sound, "S&ound..." ); - menuEdit->Append(ID_Edit_Network, "&Network..." ); menuEdit->Append(ID_Edit_Serial_Parallel, "&Serial/Parallel..." ); + menuEdit->Append(ID_Edit_Network, "&Network..." ); + menuEdit->Append(ID_Edit_Sound, "S&ound..." ); menuEdit->Append(ID_Edit_Other, "&Other..." ); menuSimulate = new wxMenu; @@ -653,33 +653,33 @@ void MyFrame::OnEditBoot(wxCommandEvent& WXUNUSED(event)) dlg.ShowModal(); } -void MyFrame::OnEditSound(wxCommandEvent& WXUNUSED(event)) +void MyFrame::OnEditSerialParallel(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.AddParam (list); - dlg.SetRuntimeFlag (sim_thread != NULL); - dlg.ShowModal (); + ParamDialog dlg(this, -1); + bx_list_c *list = (bx_list_c*) SIM->get_param("ports"); + dlg.SetTitle(list->get_title()->getptr()); + dlg.AddParam(list); + dlg.SetRuntimeFlag(sim_thread != NULL); + dlg.ShowModal(); } void MyFrame::OnEditNet(wxCommandEvent& WXUNUSED(event)) { - ParamDialog dlg (this, -1); - bx_list_c *list = (bx_list_c*) SIM->get_param (BXP_NETWORK); - dlg.SetTitle (list->get_name ()); - dlg.AddParam (list); - dlg.ShowModal (); + ParamDialog dlg(this, -1); + bx_list_c *list = (bx_list_c*) SIM->get_param(BXP_NETWORK); + dlg.SetTitle(list->get_name()); + dlg.AddParam(list); + dlg.ShowModal(); } -void MyFrame::OnEditSerialParallel(wxCommandEvent& WXUNUSED(event)) +void MyFrame::OnEditSound(wxCommandEvent& WXUNUSED(event)) { ParamDialog dlg(this, -1); - bx_list_c *list = (bx_list_c*) SIM->get_param (BXP_MENU_SERIAL_PARALLEL); - dlg.SetTitle (list->get_name ()); - dlg.AddParam (list); - dlg.SetRuntimeFlag (sim_thread != NULL); - dlg.ShowModal (); + bx_list_c *list = (bx_list_c*) SIM->get_param(BXP_SB16); + dlg.SetTitle(list->get_name()); + dlg.AddParam(list); + dlg.SetRuntimeFlag(sim_thread != NULL); + dlg.ShowModal(); } void MyFrame::OnEditOther(wxCommandEvent& WXUNUSED(event)) diff --git a/bochs/gui/wxmain.h b/bochs/gui/wxmain.h index 9d8a25b16..8a98751aa 100644 --- a/bochs/gui/wxmain.h +++ b/bochs/gui/wxmain.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////// -// $Id: wxmain.h,v 1.51 2006-02-23 22:48:57 vruppert Exp $ +// $Id: wxmain.h,v 1.52 2006-03-01 17:14:36 vruppert Exp $ ///////////////////////////////////////////////////////////////// // This file defines variables and classes that the wxWidgets .cc files // share. It should be included only by wx.cc and wxmain.cc. @@ -46,9 +46,9 @@ enum ID_Edit_Display, ID_Edit_Keyboard, ID_Edit_Boot, - ID_Edit_Sound, - ID_Edit_Network, ID_Edit_Serial_Parallel, + ID_Edit_Network, + ID_Edit_Sound, ID_Edit_Other, ID_Simulate_Start, ID_Simulate_PauseResume, @@ -180,9 +180,9 @@ public: void OnEditDisplay(wxCommandEvent& event); void OnEditKeyboard(wxCommandEvent& event); void OnEditBoot(wxCommandEvent& event); - void OnEditSound(wxCommandEvent& event); - void OnEditNet(wxCommandEvent& event); void OnEditSerialParallel(wxCommandEvent& event); + void OnEditNet(wxCommandEvent& event); + void OnEditSound(wxCommandEvent& event); void OnEditOther(wxCommandEvent& event); void OnLogPrefs(wxCommandEvent& event); void OnLogPrefsDevice(wxCommandEvent& event); diff --git a/bochs/iodev/devices.cc b/bochs/iodev/devices.cc index 6aab27ea5..bae3c999e 100644 --- a/bochs/iodev/devices.cc +++ b/bochs/iodev/devices.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: devices.cc,v 1.90 2006-02-22 19:18:28 vruppert Exp $ +// $Id: devices.cc,v 1.91 2006-03-01 17:14:36 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.90 2006-02-22 19:18:28 vruppert Exp $")); + BX_DEBUG(("Init $Id: devices.cc,v 1.91 2006-03-01 17:14:36 vruppert Exp $")); mem = newmem; /* set no-default handlers, will be overwritten by the real default handler */ @@ -933,8 +933,11 @@ bx_devices_c::outp(Bit16u addr, Bit32u value, unsigned io_len) bx_bool bx_devices_c::is_serial_enabled () { + char pname[24]; + for (int i=0; iget_param_bool (BXP_COMx_ENABLED(i+1))->get()) + sprintf(pname, "ports.serial.%d.enabled", i+1); + if (SIM->get_param_bool(pname)->get()) return true; } return false; @@ -942,8 +945,11 @@ bx_bool bx_devices_c::is_serial_enabled () bx_bool bx_devices_c::is_usb_enabled () { + char pname[20]; + for (int i=0; iget_param_bool (BXP_USBx_ENABLED(i+1))->get()) + sprintf(pname, "ports.usb.%d.enabled", i+1); + if (SIM->get_param_bool(pname)->get()) return true; } return false; @@ -951,8 +957,11 @@ bx_bool bx_devices_c::is_usb_enabled () bx_bool bx_devices_c::is_parallel_enabled () { + char pname[26]; + for (int i=0; iget_param_bool (BXP_PARPORTx_ENABLED(i+1))->get()) + sprintf(pname, "ports.parallel.%d.enabled", i+1); + if (SIM->get_param_bool(pname)->get()) return true; } return false; diff --git a/bochs/iodev/keyboard.cc b/bochs/iodev/keyboard.cc index e3cf78ca7..b221150b8 100644 --- a/bochs/iodev/keyboard.cc +++ b/bochs/iodev/keyboard.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: keyboard.cc,v 1.110 2006-02-24 12:05:24 vruppert Exp $ +// $Id: keyboard.cc,v 1.111 2006-03-01 17:14:36 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2002 MandrakeSoft S.A. @@ -125,7 +125,7 @@ bx_keyb_c::resetinternals(bx_bool powerup) void bx_keyb_c::init(void) { - BX_DEBUG(("Init $Id: keyboard.cc,v 1.110 2006-02-24 12:05:24 vruppert Exp $")); + BX_DEBUG(("Init $Id: keyboard.cc,v 1.111 2006-03-01 17:14:36 vruppert Exp $")); Bit32u i; DEV_register_irq(1, "8042 Keyboard controller"); @@ -272,7 +272,7 @@ Bit64s bx_keyb_c::kbd_param_handler(bx_param_c *param, int set, Bit64s val) if (set) { char pname[BX_PATHNAME_LEN]; param->get_param_path(pname, BX_PATHNAME_LEN); - if (!strcmp(pname, BXPN_MOUSE_ENABLED)) { // FIXME: check full param path + if (!strcmp(pname, BXPN_MOUSE_ENABLED)) { bx_gui->mouse_enabled_changed(val!=0); BX_KEY_THIS mouse_enabled_changed(val!=0); } else if (!strcmp(pname, BXPN_KBD_PASTE_DELAY)) { diff --git a/bochs/iodev/parallel.cc b/bochs/iodev/parallel.cc index 93c11e64f..0efce70f6 100644 --- a/bochs/iodev/parallel.cc +++ b/bochs/iodev/parallel.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: parallel.cc,v 1.26 2004-06-19 15:20:13 sshwarts Exp $ +// $Id: parallel.cc,v 1.27 2006-03-01 17:14:36 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2002 MandrakeSoft S.A. @@ -75,12 +75,15 @@ bx_parallel_c::init(void) { Bit16u ports[BX_PARPORT_MAXDEV] = {0x0378, 0x0278}; Bit8u irqs[BX_PARPORT_MAXDEV] = {7, 5}; - char name[16]; + char name[16], pname[20]; + bx_list_c *base; - BX_DEBUG(("Init $Id: parallel.cc,v 1.26 2004-06-19 15:20:13 sshwarts Exp $")); + BX_DEBUG(("Init $Id: parallel.cc,v 1.27 2006-03-01 17:14:36 vruppert Exp $")); for (unsigned i=0; iget ()) { + sprintf(pname, "ports.parallel.%d", i+1); + base = (bx_list_c*) SIM->get_param(pname); + if (SIM->get_param_bool("enabled", base)->get()) { sprintf(name, "Parallel Port %d", i + 1); /* parallel interrupt and i/o ports */ BX_PAR_THIS s[i].IRQ = irqs[i]; @@ -106,11 +109,12 @@ bx_parallel_c::init(void) BX_PAR_THIS s[i].initmode = 0; /* output file */ - if (strlen(bx_options.par[i].Ooutfile->getptr ()) > 0) { - s[i].output = fopen(bx_options.par[i].Ooutfile->getptr (), "wb"); + char *outfile = SIM->get_param_string("outfile", base)->getptr(); + if (strlen(outfile) > 0) { + s[i].output = fopen(outfile, "wb"); if (!s[i].output) - BX_PANIC (("Could not open '%s' to write parport%d output", - bx_options.par[i].Ooutfile->getptr (), i+1)); + BX_PANIC(("Could not open '%s' to write parport%d output", + outfile, i+1)); } } } diff --git a/bochs/iodev/pciusb.cc b/bochs/iodev/pciusb.cc index 2aa89a4fd..fa2c78881 100644 --- a/bochs/iodev/pciusb.cc +++ b/bochs/iodev/pciusb.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: pciusb.cc,v 1.32 2006-02-22 19:18:29 vruppert Exp $ +// $Id: pciusb.cc,v 1.33 2006-03-01 17:14:36 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2004 MandrakeSoft S.A. @@ -98,7 +98,7 @@ bx_pciusb_c::init(void) { // called once when bochs initializes - if (!bx_options.usb[0].Oenabled->get()) return; + if (!SIM->get_param_bool(BXPN_USB1_ENABLED)->get()) return; BX_USB_THIS device_buffer = new Bit8u[65536]; @@ -125,14 +125,14 @@ bx_pciusb_c::init(void) //FIXME: for now, we want a status bar // hub zero, port zero BX_USB_THIS hub[0].statusbar_id[0] = bx_gui->register_statusitem("USB"); - bx_options.usb[0].Oport1->set_handler(usb_param_handler); - bx_options.usb[0].Oport1->set_runtime_param(1); - bx_options.usb[0].Ooption1->set_handler(usb_param_handler); - bx_options.usb[0].Ooption1->set_runtime_param(1); - bx_options.usb[0].Oport2->set_handler(usb_param_handler); - bx_options.usb[0].Oport2->set_runtime_param(1); - bx_options.usb[0].Ooption2->set_handler(usb_param_handler); - bx_options.usb[0].Ooption2->set_runtime_param(1); + SIM->get_param_string(BXPN_USB1_PORT1)->set_handler(usb_param_handler); + SIM->get_param_string(BXPN_USB1_PORT1)->set_runtime_param(1); + SIM->get_param_string(BXPN_USB1_OPTION1)->set_handler(usb_param_handler); + SIM->get_param_string(BXPN_USB1_OPTION1)->set_runtime_param(1); + SIM->get_param_string(BXPN_USB1_PORT2)->set_handler(usb_param_handler); + SIM->get_param_string(BXPN_USB1_PORT2)->set_runtime_param(1); + SIM->get_param_string(BXPN_USB1_OPTION2)->set_handler(usb_param_handler); + SIM->get_param_string(BXPN_USB1_OPTION2)->set_runtime_param(1); //HACK: Turn on debug messages from the start //BX_USB_THIS setonoff(LOGLEV_DEBUG, ACT_REPORT); @@ -143,7 +143,7 @@ bx_pciusb_c::reset(unsigned type) { unsigned i, j; - if (!bx_options.usb[0].Oenabled->get()) return; + if (!SIM->get_param_bool(BXPN_USB1_ENABLED)->get()) return; if (type == BX_RESET_HARDWARE) { static const struct reset_vals_t { @@ -241,8 +241,8 @@ bx_pciusb_c::reset(unsigned type) // include the device(s) initialize code #include "pciusb_devs.h" - init_device(0, bx_options.usb[0].Oport1->getptr()); - init_device(1, bx_options.usb[0].Oport2->getptr()); + init_device(0, SIM->get_param_string(BXPN_USB1_PORT1)->getptr()); + init_device(1, SIM->get_param_string(BXPN_USB1_PORT2)->getptr()); } void @@ -1857,22 +1857,18 @@ char *bx_pciusb_c::usb_param_handler(bx_param_string_c *param, int set, char *va { // handler for USB runtime parameters if (set) { - bx_id id = param->get_id (); - switch (id) { - case BXP_USB1_PORT1: - BX_ERROR(("USB port #1 device change not implemented yet")); - break; - case BXP_USB1_OPTION1: - BX_ERROR(("USB port #1 option change not implemented yet")); - break; - case BXP_USB1_PORT2: - BX_ERROR(("USB port #2 device change not implemented yet")); - break; - case BXP_USB1_OPTION2: - BX_ERROR(("USB port #2 option change not implemented yet")); - break; - default: - BX_PANIC(("usb_param_handler called with unexpected parameter %d", id)); + char pname[BX_PATHNAME_LEN]; + param->get_param_path(pname, BX_PATHNAME_LEN); + if (!strcmp(pname, BXPN_USB1_PORT1)) { + BX_ERROR(("USB port #1 device change not implemented yet")); + } else if (!strcmp(pname, BXPN_USB1_OPTION1)) { + BX_ERROR(("USB port #1 option change not implemented yet")); + } else if (!strcmp(pname, BXPN_USB1_PORT2)) { + BX_ERROR(("USB port #2 device change not implemented yet")); + } else if (!strcmp(pname, BXPN_USB1_OPTION2)) { + BX_ERROR(("USB port #2 option change not implemented yet")); + } else { + BX_PANIC(("usb_param_handler called with unexpected parameter '%s'", pname)); } } return val; diff --git a/bochs/iodev/serial.cc b/bochs/iodev/serial.cc index 0e124a270..a86c4173a 100644 --- a/bochs/iodev/serial.cc +++ b/bochs/iodev/serial.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: serial.cc,v 1.68 2006-02-22 19:18:29 vruppert Exp $ +// $Id: serial.cc,v 1.69 2006-03-01 17:14:36 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2004 MandrakeSoft S.A. @@ -80,8 +80,13 @@ bx_serial_c::bx_serial_c(void) bx_serial_c::~bx_serial_c(void) { + char pname[20]; + bx_list_c *base; + for (int i=0; iget ()) { + sprintf(pname, "ports.serial.%d", i+1); + base = (bx_list_c*) SIM->get_param(pname); + if (SIM->get_param_bool("enabled", base)->get()) { switch (BX_SER_THIS s[i].io_mode) { case BX_SER_MODE_FILE: if (BX_SER_THIS s[i].output != NULL) @@ -112,7 +117,8 @@ bx_serial_c::~bx_serial_c(void) bx_serial_c::init(void) { Bit16u ports[BX_SERIAL_MAXDEV] = {0x03f8, 0x02f8, 0x03e8, 0x02e8}; - char name[16]; + char name[16], pname[20]; + bx_list_c *base; unsigned i; BX_SER_THIS detect_mouse = 0; @@ -127,7 +133,9 @@ bx_serial_c::init(void) * Put the UART registers into their RESET state */ for (i=0; iget ()) { + sprintf(pname, "ports.serial.%d", i+1); + base = (bx_list_c*) SIM->get_param(pname); + if (SIM->get_param_bool("enabled", base)->get()) { sprintf(name, "Serial Port %d", i + 1); /* serial interrupt */ BX_SER_THIS s[i].IRQ = 4 - (i & 1); @@ -228,19 +236,20 @@ bx_serial_c::init(void) } BX_SER_THIS s[i].io_mode = BX_SER_MODE_NULL; - char *mode = bx_options.com[i].Omode->get_selected(); + char *mode = SIM->get_param_enum("mode", base)->get_selected(); + char *dev = SIM->get_param_string("dev", base)->getptr(); if (!strcmp(mode, "file")) { - if (strlen(bx_options.com[i].Odev->getptr ()) > 0) { - BX_SER_THIS s[i].output = fopen(bx_options.com[i].Odev->getptr (), "wb"); + if (strlen(dev) > 0) { + BX_SER_THIS s[i].output = fopen(dev, "wb"); if (BX_SER_THIS s[i].output) BX_SER_THIS s[i].io_mode = BX_SER_MODE_FILE; } } else if (!strcmp(mode, "term")) { #if defined(SERIAL_ENABLE) && !defined(WIN32) - if (strlen(bx_options.com[i].Odev->getptr ()) > 0) { - BX_SER_THIS s[i].tty_id = open(bx_options.com[i].Odev->getptr (), O_RDWR|O_NONBLOCK,600); + if (strlen(dev) > 0) { + BX_SER_THIS s[i].tty_id = open(dev, O_RDWR|O_NONBLOCK,600); if (BX_SER_THIS s[i].tty_id < 0) { - BX_PANIC(("open of com%d (%s) failed", i+1, bx_options.com[i].Odev->getptr ())); + BX_PANIC(("open of com%d (%s) failed", i+1, dev)); } else { BX_SER_THIS s[i].io_mode = BX_SER_MODE_TERM; BX_DEBUG(("com%d tty_id: %d", i+1, BX_SER_THIS s[i].tty_id)); @@ -273,7 +282,7 @@ bx_serial_c::init(void) #endif /* def SERIAL_ENABLE */ } else if (!strcmp(mode, "raw")) { #if USE_RAW_SERIAL - BX_SER_THIS s[i].raw = new serial_raw(bx_options.com[i].Odev->getptr ()); + BX_SER_THIS s[i].raw = new serial_raw(dev); BX_SER_THIS s[i].io_mode = BX_SER_MODE_RAW; #else BX_PANIC(("raw serial support not present")); @@ -303,12 +312,11 @@ bx_serial_c::init(void) } #endif - char *substr = strtok(bx_options.com[i].Odev->getptr(), ":"); + char *substr = strtok(dev, ":"); strcpy(host, substr); substr = strtok(NULL, ":"); if (!substr) { - BX_PANIC(("com%d: inet address is wrong (%s)", i+1, - bx_options.com[i].Odev->getptr ())); + BX_PANIC(("com%d: inet address is wrong (%s)", i+1, dev)); } port = atoi (substr); diff --git a/bochs/iodev/vga.cc b/bochs/iodev/vga.cc index bc7a8ad8d..86f312a23 100644 --- a/bochs/iodev/vga.cc +++ b/bochs/iodev/vga.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: vga.cc,v 1.126 2006-02-27 19:04:01 sshwarts Exp $ +// $Id: vga.cc,v 1.127 2006-03-01 17:14:36 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2002 MandrakeSoft S.A. @@ -292,7 +292,7 @@ bx_vga_c::init(void) DEV_register_ioread_handler(this, vbe_read_handler, addr, "vga video", 7); DEV_register_iowrite_handler(this, vbe_write_handler, addr, "vga video", 7); } - if (!BX_SUPPORT_PCIUSB || !bx_options.usb[0].Oenabled->get()) { + if (!BX_SUPPORT_PCIUSB || !SIM->get_param_bool(BXPN_USB1_ENABLED)->get()) { for (addr=VBE_DISPI_IOPORT_INDEX_OLD; addr<=VBE_DISPI_IOPORT_DATA_OLD; addr++) { DEV_register_ioread_handler(this, vbe_read_handler, addr, "vga video", 7); DEV_register_iowrite_handler(this, vbe_write_handler, addr, "vga video", 7);