- prepared usb port configuration parameter and removed usb irq parameter

(assigned by BIOS)
- fixed some issues in bx_write_configuration()
- fixed bug in ne2k/pnic option parser (failed when disabling disabled device)
This commit is contained in:
Volker Ruppert 2004-12-30 14:50:37 +00:00
parent fb19ad1b75
commit aa5fa1daf3
3 changed files with 51 additions and 31 deletions

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: config.cc,v 1.26 2004-12-16 19:03:28 vruppert Exp $
// $Id: config.cc,v 1.27 2004-12-30 14:50:36 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -923,27 +923,32 @@ void bx_init_options ()
"I/O base adress of USB hub",
0, 0xffe0,
(i==0)?0xff80 : 0);
bx_options.usb[i].Oirq = new bx_param_num_c (
BXP_USBx_IRQ(i+1),
"IRQ",
"IRQ used by USB hub",
0, 15,
(i==0)?10 : 0);
deplist = new bx_list_c (BXP_NULL, 2);
bx_options.usb[i].Oport1 = new bx_param_string_c (
BXP_USBx_PORT1(i+1),
"port #1 device",
"Device connected to USB port #1",
"", BX_PATHNAME_LEN);
bx_options.usb[i].Oport2 = new bx_param_string_c (
BXP_USBx_PORT2(i+1),
"port #2 device",
"Device connected to USB port #2",
"", BX_PATHNAME_LEN);
deplist = new bx_list_c (BXP_NULL, 3);
deplist->add (bx_options.usb[i].Oioaddr);
deplist->add (bx_options.usb[i].Oirq);
deplist->add (bx_options.usb[i].Oport1);
deplist->add (bx_options.usb[i].Oport2);
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].Oioaddr;
*par_ser_ptr++ = bx_options.usb[i].Oirq;
*par_ser_ptr++ = bx_options.usb[i].Oport1;
*par_ser_ptr++ = bx_options.usb[i].Oport2;
bx_options.usb[i].Oioaddr->set_ask_format ("Enter new ioaddr: [0x%x] ");
bx_options.usb[i].Oioaddr->set_base (16);
bx_options.usb[i].Oioaddr->set_group (strdup(group));
bx_options.usb[i].Oioaddr->set_ask_format ("Enter new IRQ: [%d] ");
bx_options.usb[i].Oirq->set_options (bx_param_num_c::USE_SPIN_CONTROL);
bx_options.usb[i].Oirq->set_group (strdup(group));
bx_options.usb[i].Oport1->set_group (strdup(group));
bx_options.usb[i].Oport2->set_group (strdup(group));
}
// add final NULL at the end, and build the menu
*par_ser_ptr = NULL;
@ -1776,6 +1781,12 @@ void bx_reset_options ()
bx_options.par[i].Oenabled->reset();
bx_options.par[i].Ooutfile->reset();
}
for (i=0; i<BX_N_USB_HUBS; i++) {
bx_options.usb[i].Oenabled->reset();
bx_options.usb[i].Oioaddr->reset();
bx_options.usb[i].Oport1->reset();
bx_options.usb[i].Oport2->reset();
}
// rom images
bx_options.rom.Opath->reset();
@ -2691,11 +2702,17 @@ parse_line_formatted(char *context, int num_params, char *params[])
bx_options.usb[0].Oioaddr->set (strtoul (&params[i][7], NULL, 10));
bx_options.usb[0].Oenabled->set (1);
}
else if (!strncmp(params[i], "port1=", 6)) {
bx_options.usb[0].Oport1->set (strdup(&params[i][6]));
}
else if (!strncmp(params[i], "port2=", 6)) {
bx_options.usb[0].Oport2->set (strdup(&params[i][6]));
}
else if (!strncmp(params[i], "irq=", 4)) {
bx_options.usb[0].Oirq->set (atol(&params[i][4]));
PARSE_WARN(("%s: usb irq is now deprecated (assigned by BIOS).", context));
}
else {
PARSE_ERR(("%s: unknown parameter for usb1 ignored.", context));
PARSE_WARN(("%s: unknown parameter '%s' for usb1 ignored.", context, params[i]));
}
}
}
@ -3310,7 +3327,7 @@ parse_line_formatted(char *context, int num_params, char *params[])
if (valid == 0x07) {
bx_options.ne2k.Oenabled->set (1);
}
else {
else if (valid < 0x80) {
PARSE_ERR(("%s: ne2k directive incomplete (ioaddr, irq and mac are required)", context));
}
}
@ -3370,7 +3387,7 @@ parse_line_formatted(char *context, int num_params, char *params[])
if (valid == 0x07) {
bx_options.pnic.Oenabled->set (1);
}
else {
else if (valid < 0x80) {
PARSE_ERR(("%s: pnic directive incomplete (ioaddr, irq and mac are required)", context));
}
}
@ -3639,8 +3656,8 @@ bx_write_usb_options (FILE *fp, bx_usb_options *opt, int n)
{
fprintf (fp, "usb%d: enabled=%d", n, opt->Oenabled->get ());
if (opt->Oenabled->get ()) {
fprintf (fp, ", ioaddr=0x%04x, irq=%d", opt->Oioaddr->get (),
opt->Oirq->get ());
fprintf (fp, ", ioaddr=0x%04x, port1=%s, port2=%s", opt->Oioaddr->get (),
opt->Oport1->getptr (), opt->Oport2->getptr ());
}
fprintf (fp, "\n");
return 0;
@ -3675,7 +3692,7 @@ bx_write_ne2k_options (FILE *fp, bx_ne2k_options *opt)
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\n",
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 (),
(unsigned int)(0xff & ptr[0]),
@ -3697,7 +3714,7 @@ bx_write_sb16_options (FILE *fp, bx_sb16_options *opt)
{
fprintf (fp, "sb16: enabled=%d", opt->Oenabled->get ());
if (opt->Oenabled->get ()) {
fprintf (fp, "sb16: midimode=%d, midi=%s, wavemode=%d, wave=%s, loglevel=%d, log=%s, dmatimer=%d\n",
fprintf (fp, ", midimode=%d, midi=%s, wavemode=%d, wave=%s, loglevel=%d, log=%s, dmatimer=%d",
opt->Omidimode->get (),
opt->Omidifile->getptr (),
opt->Owavemode->get (),
@ -3825,7 +3842,7 @@ bx_write_configuration (char *rc, int overwrite)
fprintf (fp, "vgaromimage: file=\"%s\"\n", bx_options.vgarom.Opath->getptr ());
else
fprintf (fp, "# no vgaromimage\n");
fprintf (fp, "boot: %s", bx_options.Obootdrive[0]->get_choice(bx_options.Obootdrive[0]->get()));
fprintf (fp, "boot: %s", bx_options.Obootdrive[0]->get_choice(bx_options.Obootdrive[0]->get() - 1));
for (i=1; i<3; i++) {
if (bx_options.Obootdrive[i]->get() != BX_BOOT_NONE) {
fprintf (fp, ", %s", bx_options.Obootdrive[i]->get_choice(bx_options.Obootdrive[i]->get()));

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: siminterface.h,v 1.132 2004-12-16 19:03:28 vruppert Exp $
// $Id: siminterface.h,v 1.133 2004-12-30 14:50:37 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Before I can describe what this file is for, I have to make the
@ -329,10 +329,11 @@ typedef enum {
BXP_COM4_ENABLED,
BXP_COM4_MODE,
BXP_COM4_PATH,
#define BXP_PARAMS_PER_USB_HUB 3
#define BXP_PARAMS_PER_USB_HUB 4
BXP_USB1_ENABLED,
BXP_USB1_IOADDR,
BXP_USB1_IRQ,
BXP_USB1_PORT1,
BXP_USB1_PORT2,
BXP_PRIVATE_COLORMAP,
BXP_FULLSCREEN,
BXP_SCREENMODE,
@ -513,8 +514,10 @@ typedef enum {
(bx_id)(BXP_USB1_ENABLED + (((x)-1)*BXP_PARAMS_PER_USB_HUB))
#define BXP_USBx_IOADDR(x) \
(bx_id)(BXP_USB1_IOADDR + (((x)-1)*BXP_PARAMS_PER_USB_HUB))
#define BXP_USBx_IRQ(x) \
(bx_id)(BXP_USB1_IRQ + (((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_PORT2(x) \
(bx_id)(BXP_USB1_PORT2 + (((x)-1)*BXP_PARAMS_PER_USB_HUB))
// use x=1,2
#define BXP_PARPORTx_ENABLED(x) \
@ -1345,7 +1348,8 @@ typedef struct {
typedef struct {
bx_param_bool_c *Oenabled;
bx_param_num_c *Oioaddr;
bx_param_num_c *Oirq;
bx_param_string_c *Oport1;
bx_param_string_c *Oport2;
} bx_usb_options;
typedef struct {

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: pciusb.cc,v 1.17 2004-12-26 09:28:35 vruppert Exp $
// $Id: pciusb.cc,v 1.18 2004-12-30 14:50:37 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2004 MandrakeSoft S.A.
@ -118,9 +118,8 @@ bx_pciusb_c::init(void)
BX_USB_THIS hub[0].base_ioaddr = 0x0;
Bit16u base_ioaddr = bx_options.usb[0].Oioaddr->get();
Bit8u irq = bx_options.usb[0].Oirq->get();
BX_INFO(("usb1 at 0x%04x-0x%04x irq %d", base_ioaddr, base_ioaddr+0x13, irq));
BX_INFO(("usb1 at 0x%04x-0x%04x irq assigned by BIOS", base_ioaddr, base_ioaddr+0x13));
//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");