diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2011-08-29 13:45:25 +0200 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2012-01-17 09:44:50 +0100 |
commit | 5b6780d045720848c57a7cf461b49befcd24c691 (patch) | |
tree | 9a98421d3ba3a512bd8c5650f8a07ac7fcbc26ed /hw | |
parent | 83a53bbcdae2270656d70c7311d4f7f791532d23 (diff) |
usb/debug: add usb_ep_dump
Add function to dump endpoint data, for debugging purposes.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/usb.c | 40 | ||||
-rw-r--r-- | hw/usb.h | 1 |
2 files changed, 41 insertions, 0 deletions
@@ -427,6 +427,46 @@ void usb_ep_init(USBDevice *dev) } } +void usb_ep_dump(USBDevice *dev) +{ + static const char *tname[] = { + [USB_ENDPOINT_XFER_CONTROL] = "control", + [USB_ENDPOINT_XFER_ISOC] = "isoc", + [USB_ENDPOINT_XFER_BULK] = "bulk", + [USB_ENDPOINT_XFER_INT] = "int", + }; + int ifnum, ep, first; + + fprintf(stderr, "Device \"%s\", config %d\n", + dev->product_desc, dev->configuration); + for (ifnum = 0; ifnum < 16; ifnum++) { + first = 1; + for (ep = 0; ep < USB_MAX_ENDPOINTS; ep++) { + if (dev->ep_in[ep].type != USB_ENDPOINT_XFER_INVALID && + dev->ep_in[ep].ifnum == ifnum) { + if (first) { + first = 0; + fprintf(stderr, " Interface %d, alternative %d\n", + ifnum, dev->altsetting[ifnum]); + } + fprintf(stderr, " Endpoint %d, IN, %s\n", ep, + tname[dev->ep_in[ep].type]); + } + if (dev->ep_out[ep].type != USB_ENDPOINT_XFER_INVALID && + dev->ep_out[ep].ifnum == ifnum) { + if (first) { + first = 0; + fprintf(stderr, " Interface %d, alternative %d\n", + ifnum, dev->altsetting[ifnum]); + } + fprintf(stderr, " Endpoint %d, OUT, %s\n", ep, + tname[dev->ep_out[ep].type]); + } + } + } + fprintf(stderr, "--\n"); +} + struct USBEndpoint *usb_ep_get(USBDevice *dev, int pid, int ep) { struct USBEndpoint *eps = pid == USB_TOKEN_IN ? dev->ep_in : dev->ep_out; @@ -333,6 +333,7 @@ void usb_packet_complete(USBDevice *dev, USBPacket *p); void usb_cancel_packet(USBPacket * p); void usb_ep_init(USBDevice *dev); +void usb_ep_dump(USBDevice *dev); struct USBEndpoint *usb_ep_get(USBDevice *dev, int pid, int ep); uint8_t usb_ep_get_type(USBDevice *dev, int pid, int ep); uint8_t usb_ep_get_ifnum(USBDevice *dev, int pid, int ep); |