Definition of maximum nuber of USB ports moved from bochs.h to device.
This commit is contained in:
parent
234f10f159
commit
be304bf4af
@ -477,10 +477,6 @@ extern bx_bool bx_gui_sighandler;
|
||||
#define BX_N_OPTRAM_IMAGES 4
|
||||
#define BX_N_SERIAL_PORTS 4
|
||||
#define BX_N_PARALLEL_PORTS 2
|
||||
#define BX_N_USB_UHCI_PORTS 2
|
||||
#define BX_N_USB_OHCI_PORTS 2
|
||||
#define BX_N_USB_XHCI_PORTS 4
|
||||
#define BX_N_USB_HUB_PORTS 8
|
||||
#define BX_N_PCI_SLOTS 5
|
||||
#define BX_N_USER_PLUGINS 8
|
||||
|
||||
|
@ -113,7 +113,7 @@ int bx_usb_devctl_c::init_device(bx_list_c *portconf, logfunctions *hub, void **
|
||||
if (dnlen > 3) {
|
||||
if (devname[3] == ':') {
|
||||
ports = atoi(&devname[4]);
|
||||
if ((ports < 2) || (ports > BX_N_USB_HUB_PORTS)) {
|
||||
if ((ports < 2) || (ports > USB_HUB_PORTS)) {
|
||||
hub->panic("USB device 'hub': invalid number of ports");
|
||||
}
|
||||
} else {
|
||||
|
@ -30,7 +30,7 @@
|
||||
#define BX_IODEV_USB_HUB_H
|
||||
|
||||
|
||||
// max. number of ports defined in bochs.h
|
||||
#define USB_HUB_PORTS 8
|
||||
|
||||
class usb_hub_device_c : public usb_device_c {
|
||||
public:
|
||||
@ -58,7 +58,7 @@ private:
|
||||
|
||||
Bit16u PortStatus;
|
||||
Bit16u PortChange;
|
||||
} usb_port[BX_N_USB_HUB_PORTS];
|
||||
} usb_port[USB_HUB_PORTS];
|
||||
Bit16u device_change;
|
||||
} hub;
|
||||
|
||||
|
@ -81,11 +81,11 @@ Bit32s usb_ohci_options_parser(const char *context, int num_params, char *params
|
||||
if (!strncmp(params[i], "enabled=", 8)) {
|
||||
SIM->get_param_bool(BXPN_OHCI_ENABLED)->set(atol(¶ms[i][8]));
|
||||
} else if (!strncmp(params[i], "port", 4)) {
|
||||
if (SIM->parse_usb_port_params(context, 0, params[i], BX_N_USB_OHCI_PORTS, base) < 0) {
|
||||
if (SIM->parse_usb_port_params(context, 0, params[i], USB_OHCI_PORTS, base) < 0) {
|
||||
return -1;
|
||||
}
|
||||
} else if (!strncmp(params[i], "options", 7)) {
|
||||
if (SIM->parse_usb_port_params(context, 1, params[i], BX_N_USB_OHCI_PORTS, base) < 0) {
|
||||
if (SIM->parse_usb_port_params(context, 1, params[i], USB_OHCI_PORTS, base) < 0) {
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
@ -101,7 +101,7 @@ Bit32s usb_ohci_options_parser(const char *context, int num_params, char *params
|
||||
Bit32s usb_ohci_options_save(FILE *fp)
|
||||
{
|
||||
bx_list_c *base = (bx_list_c*) SIM->get_param(BXPN_USB_OHCI);
|
||||
SIM->write_usb_options(fp, BX_N_USB_OHCI_PORTS, base);
|
||||
SIM->write_usb_options(fp, USB_OHCI_PORTS, base);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -112,7 +112,7 @@ int CDECL libusb_ohci_LTX_plugin_init(plugin_t *plugin, plugintype_t type, int a
|
||||
theUSB_OHCI = new bx_usb_ohci_c();
|
||||
BX_REGISTER_DEVICE_DEVMODEL(plugin, type, theUSB_OHCI, BX_PLUGIN_USB_OHCI);
|
||||
// add new configuration parameter for the config interface
|
||||
SIM->init_usb_options("OHCI", "ohci", BX_N_USB_OHCI_PORTS);
|
||||
SIM->init_usb_options("OHCI", "ohci", USB_OHCI_PORTS);
|
||||
// register add-on option for bochsrc and command line
|
||||
SIM->register_addon_option("usb_ohci", usb_ohci_options_parser, usb_ohci_options_save);
|
||||
return 0; // Success
|
||||
@ -145,7 +145,7 @@ bx_usb_ohci_c::~bx_usb_ohci_c()
|
||||
if (BX_OHCI_THIS device_buffer != NULL)
|
||||
delete [] BX_OHCI_THIS device_buffer;
|
||||
|
||||
for (int i=0; i<BX_N_USB_OHCI_PORTS; i++) {
|
||||
for (int i=0; i<USB_OHCI_PORTS; i++) {
|
||||
sprintf(pname, "port%d.device", i+1);
|
||||
SIM->get_param_string(pname, SIM->get_param(BXPN_USB_OHCI))->set_handler(NULL);
|
||||
remove_device(i);
|
||||
@ -197,7 +197,7 @@ void bx_usb_ohci_c::init(void)
|
||||
bx_list_c *usb_rt = (bx_list_c*)SIM->get_param(BXPN_MENU_RUNTIME_USB);
|
||||
bx_list_c *ohci_rt = new bx_list_c(usb_rt, "ohci", "OHCI Runtime Options");
|
||||
ohci_rt->set_options(ohci_rt->SHOW_PARENT);
|
||||
for (i=0; i<BX_N_USB_OHCI_PORTS; i++) {
|
||||
for (i=0; i<USB_OHCI_PORTS; i++) {
|
||||
sprintf(pname, "port%d", i+1);
|
||||
port = (bx_list_c*)SIM->get_param(pname, ohci);
|
||||
ohci_rt->add(port);
|
||||
@ -345,10 +345,10 @@ void bx_usb_ohci_c::reset_hc()
|
||||
BX_OHCI_THIS hub.op_regs.HcRhDescriptorA.dt = 0;
|
||||
BX_OHCI_THIS hub.op_regs.HcRhDescriptorA.nps = 0;
|
||||
BX_OHCI_THIS hub.op_regs.HcRhDescriptorA.psm = 1;
|
||||
BX_OHCI_THIS hub.op_regs.HcRhDescriptorA.ndp = BX_N_USB_OHCI_PORTS;
|
||||
BX_OHCI_THIS hub.op_regs.HcRhDescriptorA.ndp = USB_OHCI_PORTS;
|
||||
|
||||
// HcRhDescriptorB
|
||||
BX_OHCI_THIS hub.op_regs.HcRhDescriptorB.ppcm = ((1 << BX_N_USB_OHCI_PORTS) - 1) << 1;
|
||||
BX_OHCI_THIS hub.op_regs.HcRhDescriptorB.ppcm = ((1 << USB_OHCI_PORTS) - 1) << 1;
|
||||
BX_OHCI_THIS hub.op_regs.HcRhDescriptorB.dr = 0x0000;
|
||||
|
||||
// HcRhStatus
|
||||
@ -362,7 +362,7 @@ void bx_usb_ohci_c::reset_hc()
|
||||
BX_OHCI_THIS hub.op_regs.HcRhStatus.lps = 0;
|
||||
|
||||
// HcRhPortStatus[x]
|
||||
for (i=0; i<BX_N_USB_OHCI_PORTS; i++) {
|
||||
for (i=0; i<USB_OHCI_PORTS; i++) {
|
||||
reset_port(i);
|
||||
if (BX_OHCI_THIS hub.usb_port[i].device == NULL) {
|
||||
sprintf(pname, "port%d", i+1);
|
||||
@ -453,7 +453,7 @@ void bx_usb_ohci_c::register_state(void)
|
||||
BXRS_PARAM_BOOL(reg, drwe, BX_OHCI_THIS hub.op_regs.HcRhStatus.drwe);
|
||||
BXRS_PARAM_BOOL(reg, oci, BX_OHCI_THIS hub.op_regs.HcRhStatus.oci);
|
||||
BXRS_PARAM_BOOL(reg, lps, BX_OHCI_THIS hub.op_regs.HcRhStatus.lps);
|
||||
for (i=0; i<BX_N_USB_OHCI_PORTS; i++) {
|
||||
for (i=0; i<USB_OHCI_PORTS; i++) {
|
||||
sprintf(portnum, "port%d", i+1);
|
||||
port = new bx_list_c(hub, portnum);
|
||||
reg = new bx_list_c(port, "HcRhPortStatus");
|
||||
@ -489,7 +489,7 @@ void bx_usb_ohci_c::after_restore_state(void)
|
||||
4096)) {
|
||||
BX_INFO(("new base address: 0x%04x", BX_OHCI_THIS pci_base_address[0]));
|
||||
}
|
||||
for (int j=0; j<BX_N_USB_OHCI_PORTS; j++) {
|
||||
for (int j=0; j<USB_OHCI_PORTS; j++) {
|
||||
if (BX_OHCI_THIS hub.usb_port[j].device != NULL) {
|
||||
BX_OHCI_THIS hub.usb_port[j].device->after_restore_state();
|
||||
}
|
||||
@ -680,17 +680,17 @@ bx_bool bx_usb_ohci_c::read_handler(bx_phy_address addr, unsigned len, void *dat
|
||||
break;
|
||||
|
||||
case 0x60: // HcRhPortStatus[3]
|
||||
#if (BX_N_USB_OHCI_PORTS < 4)
|
||||
#if (USB_OHCI_PORTS < 4)
|
||||
val = 0;
|
||||
break;
|
||||
#endif
|
||||
case 0x5C: // HcRhPortStatus[2]
|
||||
#if (BX_N_USB_OHCI_PORTS < 3)
|
||||
#if (USB_OHCI_PORTS < 3)
|
||||
val = 0;
|
||||
break;
|
||||
#endif
|
||||
case 0x58: // HcRhPortStatus[1]
|
||||
#if (BX_N_USB_OHCI_PORTS < 2)
|
||||
#if (USB_OHCI_PORTS < 2)
|
||||
val = 0;
|
||||
break;
|
||||
#endif
|
||||
@ -787,7 +787,7 @@ bx_bool bx_usb_ohci_c::write_handler(bx_phy_address addr, unsigned len, void *da
|
||||
BX_OHCI_THIS hub.op_regs.HcCommandStatus.hcr = 1;
|
||||
BX_OHCI_THIS reset_hc();
|
||||
BX_OHCI_THIS hub.op_regs.HcControl.hcfs = 3; // suspend state
|
||||
for (unsigned i=0; i<BX_N_USB_OHCI_PORTS; i++)
|
||||
for (unsigned i=0; i<USB_OHCI_PORTS; i++)
|
||||
if (BX_OHCI_THIS hub.usb_port[i].HcRhPortStatus.ccs && (BX_OHCI_THIS hub.usb_port[i].device != NULL))
|
||||
DEV_usb_send_msg(BX_OHCI_THIS hub.usb_port[i].device, USB_MSG_RESET);
|
||||
}
|
||||
@ -925,20 +925,20 @@ bx_bool bx_usb_ohci_c::write_handler(bx_phy_address addr, unsigned len, void *da
|
||||
if (value & (1<<17)) BX_OHCI_THIS hub.op_regs.HcRhStatus.ocic = 1;
|
||||
if (value & (1<<16)) {
|
||||
if (BX_OHCI_THIS hub.op_regs.HcRhDescriptorA.psm == 0) {
|
||||
for (p=0; p<BX_N_USB_OHCI_PORTS; p++)
|
||||
for (p=0; p<USB_OHCI_PORTS; p++)
|
||||
BX_OHCI_THIS hub.usb_port[p].HcRhPortStatus.pps = 1;
|
||||
} else {
|
||||
for (p=0; p<BX_N_USB_OHCI_PORTS; p++)
|
||||
for (p=0; p<USB_OHCI_PORTS; p++)
|
||||
if ((BX_OHCI_THIS hub.op_regs.HcRhDescriptorB.ppcm & (1<<p)) == 0)
|
||||
BX_OHCI_THIS hub.usb_port[p].HcRhPortStatus.pps = 1;
|
||||
}
|
||||
}
|
||||
if (value & (1<<0)) {
|
||||
if (BX_OHCI_THIS hub.op_regs.HcRhDescriptorA.psm == 0) {
|
||||
for (p=0; p<BX_N_USB_OHCI_PORTS; p++)
|
||||
for (p=0; p<USB_OHCI_PORTS; p++)
|
||||
BX_OHCI_THIS hub.usb_port[p].HcRhPortStatus.pps = 0;
|
||||
} else {
|
||||
for (p=0; p<BX_N_USB_OHCI_PORTS; p++)
|
||||
for (p=0; p<USB_OHCI_PORTS; p++)
|
||||
if (!(BX_OHCI_THIS hub.op_regs.HcRhDescriptorB.ppcm & (1<<p)))
|
||||
BX_OHCI_THIS hub.usb_port[p].HcRhPortStatus.pps = 0;
|
||||
}
|
||||
@ -947,15 +947,15 @@ bx_bool bx_usb_ohci_c::write_handler(bx_phy_address addr, unsigned len, void *da
|
||||
}
|
||||
|
||||
case 0x60: // HcRhPortStatus[3]
|
||||
#if (BX_N_USB_OHCI_PORTS < 4)
|
||||
#if (USB_OHCI_PORTS < 4)
|
||||
break;
|
||||
#endif
|
||||
case 0x5C: // HcRhPortStatus[2]
|
||||
#if (BX_N_USB_OHCI_PORTS < 3)
|
||||
#if (USB_OHCI_PORTS < 3)
|
||||
break;
|
||||
#endif
|
||||
case 0x58: // HcRhPortStatus[1]
|
||||
#if (BX_N_USB_OHCI_PORTS < 2)
|
||||
#if (USB_OHCI_PORTS < 2)
|
||||
break;
|
||||
#endif
|
||||
case 0x54: { // HcRhPortStatus[0]
|
||||
@ -1387,7 +1387,7 @@ int bx_usb_ohci_c::broadcast_packet(USBPacket *p)
|
||||
int i, ret;
|
||||
|
||||
ret = USB_RET_NODEV;
|
||||
for (i = 0; i < BX_N_USB_OHCI_PORTS && ret == USB_RET_NODEV; i++) {
|
||||
for (i = 0; i < USB_OHCI_PORTS && ret == USB_RET_NODEV; i++) {
|
||||
if ((BX_OHCI_THIS hub.usb_port[i].device != NULL) &&
|
||||
(BX_OHCI_THIS hub.usb_port[i].HcRhPortStatus.ccs)) {
|
||||
ret = BX_OHCI_THIS hub.usb_port[i].device->handle_packet(p);
|
||||
@ -1408,7 +1408,7 @@ void bx_usb_ohci_c::runtime_config(void)
|
||||
char pname[6];
|
||||
usbdev_type type = USB_DEV_TYPE_NONE;
|
||||
|
||||
for (i = 0; i < BX_N_USB_OHCI_PORTS; i++) {
|
||||
for (i = 0; i < USB_OHCI_PORTS; i++) {
|
||||
// device change support
|
||||
if ((BX_OHCI_THIS hub.device_change & (1 << i)) != 0) {
|
||||
if (!BX_OHCI_THIS hub.usb_port[i].HcRhPortStatus.ccs) {
|
||||
@ -1566,7 +1566,7 @@ const char *bx_usb_ohci_c::usb_param_handler(bx_param_string_c *param, int set,
|
||||
if (set) {
|
||||
portnum = atoi((param->get_parent())->get_name()+4) - 1;
|
||||
bx_bool empty = ((strlen(val) == 0) || (!strcmp(val, "none")));
|
||||
if ((portnum >= 0) && (portnum < BX_N_USB_OHCI_PORTS)) {
|
||||
if ((portnum >= 0) && (portnum < USB_OHCI_PORTS)) {
|
||||
if (empty && BX_OHCI_THIS hub.usb_port[portnum].HcRhPortStatus.ccs) {
|
||||
BX_OHCI_THIS hub.device_change |= (1 << portnum);
|
||||
} else if (!empty && !BX_OHCI_THIS hub.usb_port[portnum].HcRhPortStatus.ccs) {
|
||||
|
@ -31,7 +31,7 @@
|
||||
# define BX_OHCI_THIS_PTR this
|
||||
#endif
|
||||
|
||||
// number of ports defined in bochs.h
|
||||
#define USB_OHCI_PORTS 2
|
||||
|
||||
#define OHCI_INTR_SO (1<<0) // Scheduling overrun
|
||||
#define OHCI_INTR_WD (1<<1) // HcDoneHead writeback
|
||||
@ -228,7 +228,7 @@ typedef struct {
|
||||
bx_bool pes; // 1 bit PortEnableStatus = 0b RW RW
|
||||
bx_bool ccs; // 1 bit CurrentConnectStatus = 0b RW RW
|
||||
} HcRhPortStatus;
|
||||
} usb_port[BX_N_USB_OHCI_PORTS];
|
||||
} usb_port[USB_OHCI_PORTS];
|
||||
|
||||
Bit8u devfunc;
|
||||
unsigned ohci_done_count;
|
||||
|
@ -68,11 +68,11 @@ Bit32s usb_uhci_options_parser(const char *context, int num_params, char *params
|
||||
if (!strncmp(params[i], "enabled=", 8)) {
|
||||
SIM->get_param_bool(BXPN_UHCI_ENABLED)->set(atol(¶ms[i][8]));
|
||||
} else if (!strncmp(params[i], "port", 4)) {
|
||||
if (SIM->parse_usb_port_params(context, 0, params[i], BX_N_USB_UHCI_PORTS, base) < 0) {
|
||||
if (SIM->parse_usb_port_params(context, 0, params[i], USB_UHCI_PORTS, base) < 0) {
|
||||
return -1;
|
||||
}
|
||||
} else if (!strncmp(params[i], "options", 7)) {
|
||||
if (SIM->parse_usb_port_params(context, 1, params[i], BX_N_USB_UHCI_PORTS, base) < 0) {
|
||||
if (SIM->parse_usb_port_params(context, 1, params[i], USB_UHCI_PORTS, base) < 0) {
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
@ -88,7 +88,7 @@ Bit32s usb_uhci_options_parser(const char *context, int num_params, char *params
|
||||
Bit32s usb_uhci_options_save(FILE *fp)
|
||||
{
|
||||
bx_list_c *base = (bx_list_c*) SIM->get_param(BXPN_USB_UHCI);
|
||||
SIM->write_usb_options(fp, BX_N_USB_UHCI_PORTS, base);
|
||||
SIM->write_usb_options(fp, USB_UHCI_PORTS, base);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -99,7 +99,7 @@ int CDECL libusb_uhci_LTX_plugin_init(plugin_t *plugin, plugintype_t type, int a
|
||||
theUSB_UHCI = new bx_usb_uhci_c();
|
||||
BX_REGISTER_DEVICE_DEVMODEL(plugin, type, theUSB_UHCI, BX_PLUGIN_USB_UHCI);
|
||||
// add new configuration parameter for the config interface
|
||||
SIM->init_usb_options("UHCI", "uhci", BX_N_USB_UHCI_PORTS);
|
||||
SIM->init_usb_options("UHCI", "uhci", USB_UHCI_PORTS);
|
||||
// register add-on option for bochsrc and command line
|
||||
SIM->register_addon_option("usb_uhci", usb_uhci_options_parser, usb_uhci_options_save);
|
||||
return 0; // Success
|
||||
@ -132,7 +132,7 @@ bx_usb_uhci_c::~bx_usb_uhci_c()
|
||||
if (BX_UHCI_THIS device_buffer != NULL)
|
||||
delete [] BX_UHCI_THIS device_buffer;
|
||||
|
||||
for (int i=0; i<BX_N_USB_UHCI_PORTS; i++) {
|
||||
for (int i=0; i<USB_UHCI_PORTS; i++) {
|
||||
sprintf(pname, "port%d.device", i+1);
|
||||
SIM->get_param_string(pname, SIM->get_param(BXPN_USB_UHCI))->set_handler(NULL);
|
||||
remove_device(i);
|
||||
@ -185,7 +185,7 @@ void bx_usb_uhci_c::init(void)
|
||||
bx_list_c *usb_rt = (bx_list_c*)SIM->get_param(BXPN_MENU_RUNTIME_USB);
|
||||
bx_list_c *uhci_rt = new bx_list_c(usb_rt, "uhci", "UHCI Runtime Options");
|
||||
uhci_rt->set_options(uhci_rt->SHOW_PARENT);
|
||||
for (i=0; i<BX_N_USB_UHCI_PORTS; i++) {
|
||||
for (i=0; i<USB_UHCI_PORTS; i++) {
|
||||
sprintf(pname, "port%d", i+1);
|
||||
port = (bx_list_c*)SIM->get_param(pname, uhci);
|
||||
uhci_rt->add(port);
|
||||
@ -255,7 +255,7 @@ void bx_usb_uhci_c::reset(unsigned type)
|
||||
BX_UHCI_THIS hub.usb_frame_num.frame_num = 0x0000;
|
||||
BX_UHCI_THIS hub.usb_frame_base.frame_base = 0x00000000;
|
||||
BX_UHCI_THIS hub.usb_sof.sof_timing = 0x40;
|
||||
for (j=0; j<BX_N_USB_UHCI_PORTS; j++) {
|
||||
for (j=0; j<USB_UHCI_PORTS; j++) {
|
||||
BX_UHCI_THIS hub.usb_port[j].connect_changed = 0;
|
||||
BX_UHCI_THIS hub.usb_port[j].line_dminus = 0;
|
||||
BX_UHCI_THIS hub.usb_port[j].line_dplus = 0;
|
||||
@ -309,7 +309,7 @@ void bx_usb_uhci_c::register_state(void)
|
||||
BXRS_HEX_PARAM_FIELD(hub, frame_num, BX_UHCI_THIS hub.usb_frame_num.frame_num);
|
||||
BXRS_HEX_PARAM_FIELD(hub, frame_base, BX_UHCI_THIS hub.usb_frame_base.frame_base);
|
||||
BXRS_HEX_PARAM_FIELD(hub, sof_timing, BX_UHCI_THIS hub.usb_sof.sof_timing);
|
||||
for (j=0; j<BX_N_USB_UHCI_PORTS; j++) {
|
||||
for (j=0; j<USB_UHCI_PORTS; j++) {
|
||||
sprintf(portnum, "port%d", j+1);
|
||||
port = new bx_list_c(hub, portnum);
|
||||
BXRS_PARAM_BOOL(port, suspend, BX_UHCI_THIS hub.usb_port[j].suspend);
|
||||
@ -340,7 +340,7 @@ void bx_usb_uhci_c::after_restore_state(void)
|
||||
{
|
||||
BX_INFO(("new base address: 0x%04x", BX_UHCI_THIS pci_base_address[4]));
|
||||
}
|
||||
for (int j=0; j<BX_N_USB_UHCI_PORTS; j++) {
|
||||
for (int j=0; j<USB_UHCI_PORTS; j++) {
|
||||
if (BX_UHCI_THIS hub.usb_port[j].device != NULL) {
|
||||
BX_UHCI_THIS hub.usb_port[j].device->after_restore_state();
|
||||
}
|
||||
@ -469,7 +469,7 @@ Bit32u bx_usb_uhci_c::read(Bit32u address, unsigned io_len)
|
||||
case 0x12: // port #2
|
||||
case 0x13:
|
||||
port = (offset & 0x0F) >> 1;
|
||||
if (port < BX_N_USB_UHCI_PORTS) {
|
||||
if (port < USB_UHCI_PORTS) {
|
||||
val = BX_UHCI_THIS hub.usb_port[port].suspend << 12
|
||||
| 1 << 10 // some Root Hubs have bit 10 set ?????
|
||||
| BX_UHCI_THIS hub.usb_port[port].reset << 9
|
||||
@ -536,7 +536,7 @@ void bx_usb_uhci_c::write(Bit32u address, Bit32u value, unsigned io_len)
|
||||
// HCRESET
|
||||
if (BX_UHCI_THIS hub.usb_command.host_reset) {
|
||||
BX_UHCI_THIS reset(0);
|
||||
for (unsigned i=0; i<BX_N_USB_UHCI_PORTS; i++) {
|
||||
for (unsigned i=0; i<USB_UHCI_PORTS; i++) {
|
||||
if (BX_UHCI_THIS hub.usb_port[i].status) {
|
||||
if (BX_UHCI_THIS hub.usb_port[i].device != NULL) {
|
||||
DEV_usb_send_msg(BX_UHCI_THIS hub.usb_port[i].device, USB_MSG_RESET);
|
||||
@ -651,7 +651,7 @@ void bx_usb_uhci_c::write(Bit32u address, Bit32u value, unsigned io_len)
|
||||
case 0x10: // port #1
|
||||
case 0x12: // port #2
|
||||
port = (offset & 0x0F) >> 1;
|
||||
if ((port < BX_N_USB_UHCI_PORTS) && (io_len == 2)) {
|
||||
if ((port < USB_UHCI_PORTS) && (io_len == 2)) {
|
||||
// If the ports reset bit is set, don't allow any writes unless the new write will clear the reset bit
|
||||
if (BX_UHCI_THIS hub.usb_port[port].reset & (value & (1<<9)))
|
||||
break;
|
||||
@ -716,7 +716,7 @@ void bx_usb_uhci_c::usb_timer(void)
|
||||
|
||||
// If the "global reset" bit was set by software
|
||||
if (BX_UHCI_THIS global_reset) {
|
||||
for (i=0; i<BX_N_USB_UHCI_PORTS; i++) {
|
||||
for (i=0; i<USB_UHCI_PORTS; i++) {
|
||||
BX_UHCI_THIS hub.usb_port[i].able_changed = 0;
|
||||
BX_UHCI_THIS hub.usb_port[i].connect_changed = 0;
|
||||
BX_UHCI_THIS hub.usb_port[i].enabled = 0;
|
||||
@ -968,7 +968,7 @@ int bx_usb_uhci_c::broadcast_packet(USBPacket *p)
|
||||
int i, ret;
|
||||
|
||||
ret = USB_RET_NODEV;
|
||||
for (i = 0; i < BX_N_USB_UHCI_PORTS && ret == USB_RET_NODEV; i++) {
|
||||
for (i = 0; i < USB_UHCI_PORTS && ret == USB_RET_NODEV; i++) {
|
||||
if ((BX_UHCI_THIS hub.usb_port[i].device != NULL) &&
|
||||
(BX_UHCI_THIS hub.usb_port[i].enabled)) {
|
||||
ret = BX_UHCI_THIS hub.usb_port[i].device->handle_packet(p);
|
||||
@ -1008,7 +1008,7 @@ void bx_usb_uhci_c::runtime_config(void)
|
||||
char pname[6];
|
||||
usbdev_type type = USB_DEV_TYPE_NONE;
|
||||
|
||||
for (i = 0; i < BX_N_USB_UHCI_PORTS; i++) {
|
||||
for (i = 0; i < USB_UHCI_PORTS; i++) {
|
||||
// device change support
|
||||
if ((BX_UHCI_THIS hub.device_change & (1 << i)) != 0) {
|
||||
if (!BX_UHCI_THIS hub.usb_port[i].status) {
|
||||
@ -1190,7 +1190,7 @@ const char *bx_usb_uhci_c::usb_param_handler(bx_param_string_c *param, int set,
|
||||
if (set) {
|
||||
portnum = atoi((param->get_parent())->get_name()+4) - 1;
|
||||
bx_bool empty = ((strlen(val) == 0) || (!strcmp(val, "none")));
|
||||
if ((portnum >= 0) && (portnum < BX_N_USB_UHCI_PORTS)) {
|
||||
if ((portnum >= 0) && (portnum < USB_UHCI_PORTS)) {
|
||||
if (empty && BX_UHCI_THIS hub.usb_port[portnum].status) {
|
||||
BX_UHCI_THIS hub.device_change |= (1 << portnum);
|
||||
} else if (!empty && !BX_UHCI_THIS hub.usb_port[portnum].status) {
|
||||
|
@ -30,7 +30,7 @@
|
||||
# define BX_UHCI_THIS_PTR this
|
||||
#endif
|
||||
|
||||
// defined in bochs.h: UHCI supports 2 ports per root hub
|
||||
#define USB_UHCI_PORTS 2
|
||||
|
||||
typedef struct {
|
||||
int timer_index;
|
||||
@ -154,7 +154,7 @@ typedef struct {
|
||||
bx_bool enabled;
|
||||
bx_bool connect_changed;
|
||||
bx_bool status;
|
||||
} usb_port[BX_N_USB_UHCI_PORTS];
|
||||
} usb_port[USB_UHCI_PORTS];
|
||||
|
||||
Bit8u devfunc;
|
||||
|
||||
|
@ -147,13 +147,7 @@
|
||||
// ie.: Each physical port (socket) has two defined port register sets. One for USB3, one for USB2
|
||||
// Only one port type may be used at a time. Port0 or Port1, not both. If Port0 is used, then
|
||||
// Port1 must be vacant.
|
||||
#ifndef BX_N_USB_XHCI_PORTS
|
||||
#error "BX_N_USB_XHCI_PORTS was not defined in bochs.h"
|
||||
#else
|
||||
#if (BX_N_USB_XHCI_PORTS < USB_XHCI_PORTS)
|
||||
#error "BX_N_USB_XHCI_PORTS is less than USB_XHCI_PORTS."
|
||||
#endif
|
||||
#endif
|
||||
#define BX_N_USB_XHCI_PORTS 4
|
||||
|
||||
// xHCI speed values
|
||||
#define SPEED_FULL 1
|
||||
|
Loading…
Reference in New Issue
Block a user