else
port->wPortStatus &= ~PORT_STAT_LOW_SPEED;
port->port.dev = dev;
+ /* send the attach message */
+ dev->handle_packet(dev,
+ USB_MSG_ATTACH, 0, 0, NULL, 0);
} else {
dev = port->port.dev;
if (dev) {
port->wPortStatus &= ~PORT_STAT_ENABLE;
port->wPortChange |= PORT_STAT_C_ENABLE;
}
+ /* send the detach message */
+ dev->handle_packet(dev,
+ USB_MSG_DETACH, 0, 0, NULL, 0);
port->port.dev = NULL;
}
}
}
-static void usb_hub_handle_reset(USBDevice *dev)
+static void usb_hub_handle_reset(USBDevice *dev, int destroy)
{
/* XXX: do it */
+ if (destroy)
+ qemu_free(dev);
}
static int usb_hub_handle_control(USBDevice *dev, int request, int value,
return usb_generic_handle_packet(dev, pid, devaddr, devep, data, len);
}
-USBDevice *usb_hub_init(USBPort **usb_ports, int nb_ports)
+USBDevice *usb_hub_init(int nb_ports)
{
USBHubState *s;
USBHubPort *port;
s->nb_ports = nb_ports;
for(i = 0; i < s->nb_ports; i++) {
port = &s->ports[i];
+ qemu_register_usb_port(&port->port, s, i, usb_hub_attach);
port->wPortStatus = PORT_STAT_POWER;
port->wPortChange = 0;
- port->port.attach = usb_hub_attach;
- port->port.opaque = s;
- port->port.index = i;
- usb_ports[i] = &port->port;
}
return (USBDevice *)s;
}