typedef struct UHCIPort {
USBPort port;
uint16_t ctrl;
- USBDevice *dev; /* connected device */
} UHCIPort;
typedef struct UHCIState {
} else {
level = 0;
}
- pci_set_irq(&s->dev, 0, level);
+ pci_set_irq(&s->dev, 3, level);
}
static void uhci_reset(UHCIState *s)
for(i = 0; i < NB_PORTS; i++) {
port = &s->ports[i];
port->ctrl = 0x0080;
- if (port->dev)
- uhci_attach(&port->port, port->dev);
+ if (port->port.dev)
+ uhci_attach(&port->port, port->port.dev);
}
}
switch(addr) {
case 0x0c:
val = s->sof_timing;
+ break;
default:
val = 0xff;
break;
/* send reset on the USB bus */
for(i = 0; i < NB_PORTS; i++) {
port = &s->ports[i];
- dev = port->dev;
+ dev = port->port.dev;
if (dev) {
dev->handle_packet(dev,
USB_MSG_RESET, 0, 0, NULL, 0);
uhci_reset(s);
return;
}
- if (val & UHCI_CMD_GRESET) {
+ if (val & UHCI_CMD_HCRESET) {
uhci_reset(s);
return;
}
if (n >= NB_PORTS)
return;
port = &s->ports[n];
- dev = port->dev;
+ dev = port->port.dev;
if (dev) {
/* port reset */
if ( (val & UHCI_PORT_RESET) &&
UHCIPort *port = &s->ports[port1->index];
if (dev) {
- if (port->dev) {
+ if (port->port.dev) {
usb_attach(port1, NULL);
}
/* set connect status */
port->ctrl |= UHCI_PORT_LSDA;
else
port->ctrl &= ~UHCI_PORT_LSDA;
- port->dev = dev;
+ port->port.dev = dev;
/* send the attach message */
dev->handle_packet(dev,
USB_MSG_ATTACH, 0, 0, NULL, 0);
port->ctrl &= ~UHCI_PORT_EN;
port->ctrl |= UHCI_PORT_ENC;
}
- dev = port->dev;
+ dev = port->port.dev;
if (dev) {
/* send the detach message */
dev->handle_packet(dev,
USB_MSG_DETACH, 0, 0, NULL, 0);
}
- port->dev = NULL;
+ port->port.dev = NULL;
}
}
#endif
for(i = 0; i < NB_PORTS; i++) {
port = &s->ports[i];
- dev = port->dev;
+ dev = port->port.dev;
if (dev && (port->ctrl & UHCI_PORT_EN)) {
ret = dev->handle_packet(dev, pid,
devaddr, devep,
s = (UHCIState *)pci_register_device(bus,
"USB-UHCI", sizeof(UHCIState),
- -1,
+ ((PCIDevice *)piix3_state)->devfn + 2,
NULL, NULL);
pci_conf = s->dev.config;
pci_conf[0x00] = 0x86;
pci_conf[0x0a] = 0x03;
pci_conf[0x0b] = 0x0c;
pci_conf[0x0e] = 0x00; // header_type
- pci_conf[0x3d] = 1; // interrupt pin 0
+ pci_conf[0x3d] = 4; // interrupt pin 3
+ pci_conf[0x60] = 0x10; // release number
for(i = 0; i < NB_PORTS; i++) {
port = &s->ports[i];
uhci_reset(s);
- pci_register_io_region(&s->dev, 0, 0x20,
+ /* Use region 4 for consistency with real hardware. BSD guests seem
+ to rely on this. */
+ pci_register_io_region(&s->dev, 4, 0x20,
PCI_ADDRESS_SPACE_IO, uhci_map);
}