2 * Linux host USB redirector
4 * Copyright (c) 2005 Fabrice Bellard
6 * Copyright (c) 2008 Max Krasnyansky
7 * Support for host device auto connect & disconnect
8 * Magor rewrite to support fully async operation
10 * Permission is hereby granted, free of charge, to any person obtaining a copy
11 * of this software and associated documentation files (the "Software"), to deal
12 * in the Software without restriction, including without limitation the rights
13 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 * copies of the Software, and to permit persons to whom the Software is
15 * furnished to do so, subject to the following conditions:
17 * The above copyright notice and this permission notice shall be included in
18 * all copies or substantial portions of the Software.
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
28 #include "qemu-common.h"
29 #include "qemu-timer.h"
33 #if defined(__linux__)
35 #include <sys/ioctl.h>
36 #include <linux/usbdevice_fs.h>
37 #include <linux/version.h>
40 /* We redefine it to avoid version problems */
41 struct usb_ctrltransfer {
51 typedef int USBScanFunc(void *opaque, int bus_num, int addr, int class_id,
52 int vendor_id, int product_id,
53 const char *product_name, int speed);
54 static int usb_host_find_device(int *pbus_num, int *paddr,
55 char *product_name, int product_name_size,
61 #define dprintf printf
66 #define USBDEVFS_PATH "/proc/bus/usb"
67 #define PRODUCT_NAME_SZ 32
68 #define MAX_ENDPOINTS 16
70 struct sigaction sigact;
72 /* endpoint association data */
78 typedef struct USBHostDevice {
86 struct endp_data endp_table[MAX_ENDPOINTS];
90 /* Host side address */
94 struct USBHostDevice *next;
97 static int is_isoc(USBHostDevice *s, int ep)
99 return s->endp_table[ep - 1].type == USBDEVFS_URB_TYPE_ISO;
102 static int is_halted(USBHostDevice *s, int ep)
104 return s->endp_table[ep - 1].halted;
107 static void clear_halt(USBHostDevice *s, int ep)
109 s->endp_table[ep - 1].halted = 0;
112 static void set_halt(USBHostDevice *s, int ep)
114 s->endp_table[ep - 1].halted = 1;
117 static USBHostDevice *hostdev_list;
119 static void hostdev_link(USBHostDevice *dev)
121 dev->next = hostdev_list;
125 static void hostdev_unlink(USBHostDevice *dev)
127 USBHostDevice *pdev = hostdev_list;
128 USBHostDevice **prev = &hostdev_list;
141 static USBHostDevice *hostdev_find(int bus_num, int addr)
143 USBHostDevice *s = hostdev_list;
145 if (s->bus_num == bus_num && s->addr == addr)
154 * We always allocate one isoc descriptor even for bulk transfers
155 * to simplify allocation and casts.
157 typedef struct AsyncURB
159 struct usbdevfs_urb urb;
160 struct usbdevfs_iso_packet_desc isocpd;
166 static AsyncURB *async_alloc(void)
168 return (AsyncURB *) qemu_mallocz(sizeof(AsyncURB));
171 static void async_free(AsyncURB *aurb)
176 static void async_complete(void *opaque)
178 USBHostDevice *s = opaque;
184 int r = ioctl(s->fd, USBDEVFS_REAPURBNDELAY, &aurb);
189 if (errno == ENODEV) {
190 printf("husb: device %d.%d disconnected\n", s->bus_num, s->addr);
191 usb_device_del_addr(0, s->dev.addr);
195 dprintf("husb: async. reap urb failed errno %d\n", errno);
201 dprintf("husb: async completed. aurb %p status %d alen %d\n",
202 aurb, aurb->urb.status, aurb->urb.actual_length);
205 switch (aurb->urb.status) {
207 p->len = aurb->urb.actual_length;
211 set_halt(s, p->devep);
214 p->len = USB_RET_NAK;
218 usb_packet_complete(p);
225 static void async_cancel(USBPacket *unused, void *opaque)
227 AsyncURB *aurb = opaque;
228 USBHostDevice *s = aurb->hdev;
230 dprintf("husb: async cancel. aurb %p\n", aurb);
232 /* Mark it as dead (see async_complete above) */
235 int r = ioctl(s->fd, USBDEVFS_DISCARDURB, aurb);
237 dprintf("husb: async. discard urb failed errno %d\n", errno);
241 static int usb_host_update_interfaces(USBHostDevice *dev, int configuration)
243 int dev_descr_len, config_descr_len;
244 int interface, nb_interfaces, nb_configurations;
247 if (configuration == 0) /* address state - ignore */
251 dev_descr_len = dev->descr[0];
252 if (dev_descr_len > dev->descr_len)
254 nb_configurations = dev->descr[17];
257 while (i < dev->descr_len) {
258 dprintf("husb: i is %d, descr_len is %d, dl %d, dt %d\n", i, dev->descr_len,
259 dev->descr[i], dev->descr[i+1]);
261 if (dev->descr[i+1] != USB_DT_CONFIG) {
265 config_descr_len = dev->descr[i];
267 printf("husb: config #%d need %d\n", dev->descr[i + 5], configuration);
269 if (configuration < 0 || configuration == dev->descr[i + 5])
272 i += config_descr_len;
275 if (i >= dev->descr_len) {
276 printf("husb: update iface failed. no matching configuration\n");
279 nb_interfaces = dev->descr[i + 4];
281 #ifdef USBDEVFS_DISCONNECT
282 /* earlier Linux 2.4 do not support that */
284 struct usbdevfs_ioctl ctrl;
285 for (interface = 0; interface < nb_interfaces; interface++) {
286 ctrl.ioctl_code = USBDEVFS_DISCONNECT;
287 ctrl.ifno = interface;
288 ret = ioctl(dev->fd, USBDEVFS_IOCTL, &ctrl);
289 if (ret < 0 && errno != ENODATA) {
290 perror("USBDEVFS_DISCONNECT");
297 /* XXX: only grab if all interfaces are free */
298 for (interface = 0; interface < nb_interfaces; interface++) {
299 ret = ioctl(dev->fd, USBDEVFS_CLAIMINTERFACE, &interface);
301 if (errno == EBUSY) {
302 printf("husb: update iface. device already grabbed\n");
304 perror("husb: failed to claim interface");
311 printf("husb: %d interfaces claimed for configuration %d\n",
312 nb_interfaces, configuration);
317 static void usb_host_handle_reset(USBDevice *dev)
319 USBHostDevice *s = (USBHostDevice *)dev;
321 dprintf("husb: reset device %u.%u\n", s->bus_num, s->addr);
323 ioctl(s->fd, USBDEVFS_RESET);
324 usb_host_update_interfaces(s, s->configuration);
327 static void usb_host_handle_destroy(USBDevice *dev)
329 USBHostDevice *s = (USBHostDevice *)dev;
331 qemu_del_timer(s->timer);
332 qemu_set_fd_handler(s->fd, NULL, NULL, NULL);
344 static int usb_linux_update_endp_table(USBHostDevice *s);
346 static int usb_host_handle_control(USBDevice *dev,
353 USBHostDevice *s = (USBHostDevice *)dev;
354 struct usb_ctrltransfer ct;
355 struct usbdevfs_setinterface si;
356 int intf_update_required = 0;
359 if (request == (DeviceOutRequest | USB_REQ_SET_ADDRESS)) {
360 /* specific SET_ADDRESS support */
363 } else if (request == ((USB_RECIP_INTERFACE << 8) |
364 USB_REQ_SET_INTERFACE)) {
365 /* set alternate setting for the interface */
366 si.interface = index;
367 si.altsetting = value;
368 ret = ioctl(s->fd, USBDEVFS_SETINTERFACE, &si);
369 usb_linux_update_endp_table(s);
370 } else if (request == (DeviceOutRequest | USB_REQ_SET_CONFIGURATION)) {
371 dprintf("husb: ctrl set config %d\n", value & 0xff);
372 if (s->configuration != (value & 0xff)) {
373 s->configuration = (value & 0xff);
374 intf_update_required = 1;
379 ct.bRequestType = request >> 8;
380 ct.bRequest = request;
386 ret = ioctl(s->fd, USBDEVFS_CONTROL, &ct);
388 dprintf("husb: ctrl req 0x%x val 0x%x index %u len %u ret %d\n",
389 ct.bRequest, ct.wValue, ct.wIndex, ct.wLength, ret);
397 return USB_RET_STALL;
400 if (intf_update_required) {
401 dprintf("husb: updating interfaces\n");
402 usb_host_update_interfaces(s, value & 0xff);
408 static int usb_host_handle_data(USBDevice *dev, USBPacket *p)
410 USBHostDevice *s = (USBHostDevice *) dev;
412 struct usbdevfs_urb *urb;
415 aurb = async_alloc();
417 dprintf("husb: async malloc failed\n");
425 if (p->pid == USB_TOKEN_IN)
426 urb->endpoint = p->devep | 0x80;
428 urb->endpoint = p->devep;
430 if (is_halted(s, p->devep)) {
431 ret = ioctl(s->fd, USBDEVFS_CLEAR_HALT, &urb->endpoint);
433 dprintf("husb: failed to clear halt. ep 0x%x errno %d\n",
434 urb->endpoint, errno);
437 clear_halt(s, p->devep);
440 urb->buffer = p->data;
441 urb->buffer_length = p->len;
443 if (is_isoc(s, p->devep)) {
444 /* Setup ISOC transfer */
445 urb->type = USBDEVFS_URB_TYPE_ISO;
446 urb->flags = USBDEVFS_URB_ISO_ASAP;
447 urb->number_of_packets = 1;
448 urb->iso_frame_desc[0].length = p->len;
450 /* Setup bulk transfer */
451 urb->type = USBDEVFS_URB_TYPE_BULK;
454 urb->usercontext = s;
456 ret = ioctl(s->fd, USBDEVFS_SUBMITURB, urb);
458 dprintf("husb: data submit. ep 0x%x len %u aurb %p\n", urb->endpoint, p->len, aurb);
461 dprintf("husb: submit failed. errno %d\n", errno);
469 return USB_RET_STALL;
473 usb_defer_packet(p, async_cancel, aurb);
474 return USB_RET_ASYNC;
477 /* returns 1 on problem encountered or 0 for success */
478 static int usb_linux_update_endp_table(USBHostDevice *s)
480 uint8_t *descriptors;
481 uint8_t devep, type, configuration, alt_interface;
482 struct usb_ctrltransfer ct;
483 int interface, ret, length, i;
485 ct.bRequestType = USB_DIR_IN;
486 ct.bRequest = USB_REQ_GET_CONFIGURATION;
490 ct.data = &configuration;
493 ret = ioctl(s->fd, USBDEVFS_CONTROL, &ct);
495 perror("usb_linux_update_endp_table");
499 /* in address state */
500 if (configuration == 0)
503 /* get the desired configuration, interface, and endpoint descriptors
504 * from device description */
505 descriptors = &s->descr[18];
506 length = s->descr_len - 18;
509 if (descriptors[i + 1] != USB_DT_CONFIG ||
510 descriptors[i + 5] != configuration) {
511 dprintf("invalid descriptor data - configuration\n");
517 if (descriptors[i + 1] != USB_DT_INTERFACE ||
518 (descriptors[i + 1] == USB_DT_INTERFACE &&
519 descriptors[i + 4] == 0)) {
524 interface = descriptors[i + 2];
526 ct.bRequestType = USB_DIR_IN | USB_RECIP_INTERFACE;
527 ct.bRequest = USB_REQ_GET_INTERFACE;
529 ct.wIndex = interface;
531 ct.data = &alt_interface;
534 ret = ioctl(s->fd, USBDEVFS_CONTROL, &ct);
536 perror("usb_linux_update_endp_table");
540 /* the current interface descriptor is the active interface
541 * and has endpoints */
542 if (descriptors[i + 3] != alt_interface) {
547 /* advance to the endpoints */
548 while (i < length && descriptors[i +1] != USB_DT_ENDPOINT)
555 if (descriptors[i + 1] != USB_DT_ENDPOINT)
558 devep = descriptors[i + 2];
559 switch (descriptors[i + 3] & 0x3) {
561 type = USBDEVFS_URB_TYPE_CONTROL;
564 type = USBDEVFS_URB_TYPE_ISO;
567 type = USBDEVFS_URB_TYPE_BULK;
570 type = USBDEVFS_URB_TYPE_INTERRUPT;
573 dprintf("usb_host: malformed endpoint type\n");
574 type = USBDEVFS_URB_TYPE_BULK;
576 s->endp_table[(devep & 0xf) - 1].type = type;
577 s->endp_table[(devep & 0xf) - 1].halted = 0;
585 static void usb_host_device_check(void *priv)
587 USBHostDevice *s = priv;
588 struct usbdevfs_connectinfo ci;
591 err = ioctl(s->fd, USBDEVFS_CONNECTINFO, &ci);
593 printf("husb: device %d.%d disconnected\n", s->bus_num, s->addr);
594 usb_device_del_addr(0, s->dev.addr);
598 qemu_mod_timer(s->timer, qemu_get_clock(rt_clock) + 1000);
601 static USBDevice *usb_host_device_open_addr(int bus_num, int addr, const char *prod_name)
604 USBHostDevice *dev = NULL;
605 struct usbdevfs_connectinfo ci;
608 dev = qemu_mallocz(sizeof(USBHostDevice));
612 dev->bus_num = bus_num;
615 dev->timer = qemu_new_timer(rt_clock, usb_host_device_check, (void *) dev);
619 printf("husb: open device %d.%d\n", bus_num, addr);
621 snprintf(buf, sizeof(buf), USBDEVFS_PATH "/%03d/%03d",
623 fd = open(buf, O_RDWR | O_NONBLOCK);
629 /* read the device description */
630 dev->descr_len = read(fd, dev->descr, sizeof(dev->descr));
631 if (dev->descr_len <= 0) {
632 perror("husb: reading device data failed");
639 printf("=== begin dumping device descriptor data ===\n");
640 for (x = 0; x < dev->descr_len; x++)
641 printf("%02x ", dev->descr[x]);
642 printf("\n=== end dumping device descriptor data ===\n");
647 dev->configuration = 1;
649 /* XXX - do something about initial configuration */
650 if (!usb_host_update_interfaces(dev, -1))
653 ret = ioctl(fd, USBDEVFS_CONNECTINFO, &ci);
655 perror("usb_host_device_open: USBDEVFS_CONNECTINFO");
659 printf("husb: grabbed usb device %d.%d\n", bus_num, addr);
661 ret = usb_linux_update_endp_table(dev);
666 dev->dev.speed = USB_SPEED_LOW;
668 dev->dev.speed = USB_SPEED_HIGH;
669 dev->dev.handle_packet = usb_generic_handle_packet;
671 dev->dev.handle_reset = usb_host_handle_reset;
672 dev->dev.handle_control = usb_host_handle_control;
673 dev->dev.handle_data = usb_host_handle_data;
674 dev->dev.handle_destroy = usb_host_handle_destroy;
676 if (!prod_name || prod_name[0] == '\0')
677 snprintf(dev->dev.devname, sizeof(dev->dev.devname),
678 "host:%d.%d", bus_num, addr);
680 pstrcpy(dev->dev.devname, sizeof(dev->dev.devname),
683 /* USB devio uses 'write' flag to check for async completions */
684 qemu_set_fd_handler(dev->fd, NULL, async_complete, dev);
686 /* Start the timer to detect disconnect */
687 qemu_mod_timer(dev->timer, qemu_get_clock(rt_clock) + 1000);
691 return (USBDevice *) dev;
696 qemu_del_timer(dev->timer);
703 USBDevice *usb_host_device_open(const char *devname)
706 char product_name[PRODUCT_NAME_SZ];
708 if (usb_host_find_device(&bus_num, &addr,
709 product_name, sizeof(product_name),
713 if (hostdev_find(bus_num, addr)) {
714 term_printf("husb: host usb device %d.%d is already open\n", bus_num, addr);
718 return usb_host_device_open_addr(bus_num, addr, product_name);
721 static int get_tag_value(char *buf, int buf_size,
722 const char *str, const char *tag,
723 const char *stopchars)
727 p = strstr(str, tag);
734 while (*p != '\0' && !strchr(stopchars, *p)) {
735 if ((q - buf) < (buf_size - 1))
743 static int usb_host_scan(void *opaque, USBScanFunc *func)
748 int bus_num, addr, speed, device_count, class_id, product_id, vendor_id;
750 char product_name[512];
752 f = fopen(USBDEVFS_PATH "/devices", "r");
754 term_printf("husb: could not open %s\n", USBDEVFS_PATH "/devices");
758 bus_num = addr = speed = class_id = product_id = vendor_id = 0;
761 if (fgets(line, sizeof(line), f) == NULL)
763 if (strlen(line) > 0)
764 line[strlen(line) - 1] = '\0';
765 if (line[0] == 'T' && line[1] == ':') {
766 if (device_count && (vendor_id || product_id)) {
767 /* New device. Add the previously discovered device. */
768 ret = func(opaque, bus_num, addr, class_id, vendor_id,
769 product_id, product_name, speed);
773 if (get_tag_value(buf, sizeof(buf), line, "Bus=", " ") < 0)
776 if (get_tag_value(buf, sizeof(buf), line, "Dev#=", " ") < 0)
779 if (get_tag_value(buf, sizeof(buf), line, "Spd=", " ") < 0)
781 if (!strcmp(buf, "480"))
782 speed = USB_SPEED_HIGH;
783 else if (!strcmp(buf, "1.5"))
784 speed = USB_SPEED_LOW;
786 speed = USB_SPEED_FULL;
787 product_name[0] = '\0';
792 } else if (line[0] == 'P' && line[1] == ':') {
793 if (get_tag_value(buf, sizeof(buf), line, "Vendor=", " ") < 0)
795 vendor_id = strtoul(buf, NULL, 16);
796 if (get_tag_value(buf, sizeof(buf), line, "ProdID=", " ") < 0)
798 product_id = strtoul(buf, NULL, 16);
799 } else if (line[0] == 'S' && line[1] == ':') {
800 if (get_tag_value(buf, sizeof(buf), line, "Product=", "") < 0)
802 pstrcpy(product_name, sizeof(product_name), buf);
803 } else if (line[0] == 'D' && line[1] == ':') {
804 if (get_tag_value(buf, sizeof(buf), line, "Cls=", " (") < 0)
806 class_id = strtoul(buf, NULL, 16);
810 if (device_count && (vendor_id || product_id)) {
811 /* Add the last device. */
812 ret = func(opaque, bus_num, addr, class_id, vendor_id,
813 product_id, product_name, speed);
820 struct USBAutoFilter {
821 struct USBAutoFilter *next;
828 static QEMUTimer *usb_auto_timer;
829 static struct USBAutoFilter *usb_auto_filter;
831 static int usb_host_auto_scan(void *opaque, int bus_num, int addr,
832 int class_id, int vendor_id, int product_id,
833 const char *product_name, int speed)
835 struct USBAutoFilter *f;
836 struct USBDevice *dev;
842 for (f = usb_auto_filter; f; f = f->next) {
843 // printf("Auto match: bus_num %d addr %d vid %d pid %d\n",
844 // bus_num, addr, vendor_id, product_id);
846 if (f->bus_num >= 0 && f->bus_num != bus_num)
849 if (f->addr >= 0 && f->addr != addr)
852 if (f->vendor_id >= 0 && f->vendor_id != vendor_id)
855 if (f->product_id >= 0 && f->product_id != product_id)
860 /* Allredy attached ? */
861 if (hostdev_find(bus_num, addr))
864 dprintf("husb: auto open: bus_num %d addr %d\n", bus_num, addr);
866 dev = usb_host_device_open_addr(bus_num, addr, product_name);
868 usb_device_add_dev(dev);
874 static void usb_host_auto_timer(void *unused)
876 usb_host_scan(NULL, usb_host_auto_scan);
877 qemu_mod_timer(usb_auto_timer, qemu_get_clock(rt_clock) + 2000);
881 * Add autoconnect filter
882 * -1 means 'any' (device, vendor, etc)
884 static void usb_host_auto_add(int bus_num, int addr, int vendor_id, int product_id)
886 struct USBAutoFilter *f = qemu_mallocz(sizeof(*f));
888 printf("husb: failed to allocate auto filter\n");
892 f->bus_num = bus_num;
894 f->vendor_id = vendor_id;
895 f->product_id = product_id;
897 if (!usb_auto_filter) {
899 * First entry. Init and start the monitor.
900 * Right now we're using timer to check for new devices.
901 * If this turns out to be too expensive we can move that into a
904 usb_auto_timer = qemu_new_timer(rt_clock, usb_host_auto_timer, NULL);
905 if (!usb_auto_timer) {
906 printf("husb: failed to allocate timer\n");
911 /* Check for new devices every two seconds */
912 qemu_mod_timer(usb_auto_timer, qemu_get_clock(rt_clock) + 2000);
915 dprintf("husb: auto filter: bus_num %d addr %d vid %d pid %d\n",
916 bus_num, addr, vendor_id, product_id);
918 f->next = usb_auto_filter;
922 typedef struct FindDeviceState {
927 char product_name[PRODUCT_NAME_SZ];
930 static int usb_host_find_device_scan(void *opaque, int bus_num, int addr,
932 int vendor_id, int product_id,
933 const char *product_name, int speed)
935 FindDeviceState *s = opaque;
936 if ((vendor_id == s->vendor_id &&
937 product_id == s->product_id) ||
938 (bus_num == s->bus_num &&
940 pstrcpy(s->product_name, PRODUCT_NAME_SZ, product_name);
941 s->bus_num = bus_num;
950 'bus.addr' (decimal numbers) or
951 'vendor_id:product_id' (hexa numbers) */
952 static int usb_host_find_device(int *pbus_num, int *paddr,
953 char *product_name, int product_name_size,
960 p = strchr(devname, '.');
962 *pbus_num = strtoul(devname, NULL, 0);
964 if (*(p + 1) == '*') {
965 usb_host_auto_add(*pbus_num, -1, -1, -1);
969 *paddr = strtoul(p + 1, NULL, 0);
970 fs.bus_num = *pbus_num;
972 ret = usb_host_scan(&fs, usb_host_find_device_scan);
974 pstrcpy(product_name, product_name_size, fs.product_name);
977 p = strchr(devname, ':');
979 fs.vendor_id = strtoul(devname, NULL, 16);
981 if (*(p + 1) == '*') {
982 usb_host_auto_add(-1, -1, fs.vendor_id, -1);
986 fs.product_id = strtoul(p + 1, NULL, 16);
987 ret = usb_host_scan(&fs, usb_host_find_device_scan);
989 *pbus_num = fs.bus_num;
991 pstrcpy(product_name, product_name_size, fs.product_name);
998 /**********************/
999 /* USB host device info */
1001 struct usb_class_info {
1003 const char *class_name;
1006 static const struct usb_class_info usb_class_info[] = {
1007 { USB_CLASS_AUDIO, "Audio"},
1008 { USB_CLASS_COMM, "Communication"},
1009 { USB_CLASS_HID, "HID"},
1010 { USB_CLASS_HUB, "Hub" },
1011 { USB_CLASS_PHYSICAL, "Physical" },
1012 { USB_CLASS_PRINTER, "Printer" },
1013 { USB_CLASS_MASS_STORAGE, "Storage" },
1014 { USB_CLASS_CDC_DATA, "Data" },
1015 { USB_CLASS_APP_SPEC, "Application Specific" },
1016 { USB_CLASS_VENDOR_SPEC, "Vendor Specific" },
1017 { USB_CLASS_STILL_IMAGE, "Still Image" },
1018 { USB_CLASS_CSCID, "Smart Card" },
1019 { USB_CLASS_CONTENT_SEC, "Content Security" },
1023 static const char *usb_class_str(uint8_t class)
1025 const struct usb_class_info *p;
1026 for(p = usb_class_info; p->class != -1; p++) {
1027 if (p->class == class)
1030 return p->class_name;
1033 static void usb_info_device(int bus_num, int addr, int class_id,
1034 int vendor_id, int product_id,
1035 const char *product_name,
1038 const char *class_str, *speed_str;
1044 case USB_SPEED_FULL:
1047 case USB_SPEED_HIGH:
1055 term_printf(" Device %d.%d, speed %s Mb/s\n",
1056 bus_num, addr, speed_str);
1057 class_str = usb_class_str(class_id);
1059 term_printf(" %s:", class_str);
1061 term_printf(" Class %02x:", class_id);
1062 term_printf(" USB device %04x:%04x", vendor_id, product_id);
1063 if (product_name[0] != '\0')
1064 term_printf(", %s", product_name);
1068 static int usb_host_info_device(void *opaque, int bus_num, int addr,
1070 int vendor_id, int product_id,
1071 const char *product_name,
1074 usb_info_device(bus_num, addr, class_id, vendor_id, product_id,
1075 product_name, speed);
1079 void usb_host_info(void)
1081 usb_host_scan(NULL, usb_host_info_device);
1086 void usb_host_info(void)
1088 term_printf("USB host devices not supported\n");
1091 /* XXX: modify configure to compile the right host driver */
1092 USBDevice *usb_host_device_open(const char *devname)