Revision 4b096fc9 vl.c
b/vl.c | ||
---|---|---|
5747 | 5747 |
free_usb_ports = port; |
5748 | 5748 |
} |
5749 | 5749 |
|
5750 |
int usb_device_add_dev(USBDevice *dev) |
|
5751 |
{ |
|
5752 |
USBPort *port; |
|
5753 |
|
|
5754 |
/* Find a USB port to add the device to. */ |
|
5755 |
port = free_usb_ports; |
|
5756 |
if (!port->next) { |
|
5757 |
USBDevice *hub; |
|
5758 |
|
|
5759 |
/* Create a new hub and chain it on. */ |
|
5760 |
free_usb_ports = NULL; |
|
5761 |
port->next = used_usb_ports; |
|
5762 |
used_usb_ports = port; |
|
5763 |
|
|
5764 |
hub = usb_hub_init(VM_USB_HUB_SIZE); |
|
5765 |
usb_attach(port, hub); |
|
5766 |
port = free_usb_ports; |
|
5767 |
} |
|
5768 |
|
|
5769 |
free_usb_ports = port->next; |
|
5770 |
port->next = used_usb_ports; |
|
5771 |
used_usb_ports = port; |
|
5772 |
usb_attach(port, dev); |
|
5773 |
return 0; |
|
5774 |
} |
|
5775 |
|
|
5750 | 5776 |
static int usb_device_add(const char *devname) |
5751 | 5777 |
{ |
5752 | 5778 |
const char *p; |
... | ... | |
5787 | 5813 |
if (!dev) |
5788 | 5814 |
return -1; |
5789 | 5815 |
|
5790 |
/* Find a USB port to add the device to. */ |
|
5791 |
port = free_usb_ports; |
|
5792 |
if (!port->next) { |
|
5793 |
USBDevice *hub; |
|
5794 |
|
|
5795 |
/* Create a new hub and chain it on. */ |
|
5796 |
free_usb_ports = NULL; |
|
5797 |
port->next = used_usb_ports; |
|
5798 |
used_usb_ports = port; |
|
5799 |
|
|
5800 |
hub = usb_hub_init(VM_USB_HUB_SIZE); |
|
5801 |
usb_attach(port, hub); |
|
5802 |
port = free_usb_ports; |
|
5803 |
} |
|
5804 |
|
|
5805 |
free_usb_ports = port->next; |
|
5806 |
port->next = used_usb_ports; |
|
5807 |
used_usb_ports = port; |
|
5808 |
usb_attach(port, dev); |
|
5809 |
return 0; |
|
5816 |
return usb_device_add_dev(dev); |
|
5810 | 5817 |
} |
5811 | 5818 |
|
5812 | 5819 |
int usb_device_del_addr(int bus_num, int addr) |
... | ... | |
5859 | 5866 |
|
5860 | 5867 |
void do_usb_add(const char *devname) |
5861 | 5868 |
{ |
5862 |
int ret; |
|
5863 |
ret = usb_device_add(devname); |
|
5864 |
if (ret < 0) |
|
5865 |
term_printf("Could not add USB device '%s'\n", devname); |
|
5869 |
usb_device_add(devname); |
|
5866 | 5870 |
} |
5867 | 5871 |
|
5868 | 5872 |
void do_usb_del(const char *devname) |
5869 | 5873 |
{ |
5870 |
int ret; |
|
5871 |
ret = usb_device_del(devname); |
|
5872 |
if (ret < 0) |
|
5873 |
term_printf("Could not remove USB device '%s'\n", devname); |
|
5874 |
usb_device_del(devname); |
|
5874 | 5875 |
} |
5875 | 5876 |
|
5876 | 5877 |
void usb_info(void) |
Also available in: Unified diff