1/* $FreeBSD: head/sys/dev/usb/usb_debug.c 190749 2009-04-05 21:24:15Z piso $ */
| 1/* $FreeBSD: head/sys/dev/usb/usb_debug.c 192502 2009-05-21 01:48:42Z thompsa $ */
|
2/*- 3 * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <dev/usb/usb.h> 28 29#include <dev/usb/usb_core.h> 30#include <dev/usb/usb_debug.h> 31#include <dev/usb/usb_process.h> 32#include <dev/usb/usb_device.h> 33#include <dev/usb/usb_busdma.h> 34#include <dev/usb/usb_transfer.h> 35 36/* 37 * Define this unconditionally in case a kernel module is loaded that 38 * has been compiled with debugging options. 39 */ 40int usb2_debug = 0; 41
| 2/*- 3 * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <dev/usb/usb.h> 28 29#include <dev/usb/usb_core.h> 30#include <dev/usb/usb_debug.h> 31#include <dev/usb/usb_process.h> 32#include <dev/usb/usb_device.h> 33#include <dev/usb/usb_busdma.h> 34#include <dev/usb/usb_transfer.h> 35 36/* 37 * Define this unconditionally in case a kernel module is loaded that 38 * has been compiled with debugging options. 39 */ 40int usb2_debug = 0; 41
|
42SYSCTL_NODE(_hw, OID_AUTO, usb2, CTLFLAG_RW, 0, "USB debugging"); 43SYSCTL_INT(_hw_usb2, OID_AUTO, debug, CTLFLAG_RW,
| 42SYSCTL_NODE(_hw, OID_AUTO, usb, CTLFLAG_RW, 0, "USB debugging"); 43SYSCTL_INT(_hw_usb, OID_AUTO, debug, CTLFLAG_RW,
|
44 &usb2_debug, 0, "Debug level"); 45 46/*------------------------------------------------------------------------* 47 * usb2_dump_iface 48 * 49 * This function dumps information about an USB interface. 50 *------------------------------------------------------------------------*/ 51void 52usb2_dump_iface(struct usb2_interface *iface) 53{ 54 printf("usb2_dump_iface: iface=%p\n", iface); 55 if (iface == NULL) { 56 return; 57 } 58 printf(" iface=%p idesc=%p altindex=%d\n", 59 iface, iface->idesc, iface->alt_index); 60} 61 62/*------------------------------------------------------------------------* 63 * usb2_dump_device 64 * 65 * This function dumps information about an USB device. 66 *------------------------------------------------------------------------*/ 67void 68usb2_dump_device(struct usb2_device *udev) 69{ 70 printf("usb2_dump_device: dev=%p\n", udev); 71 if (udev == NULL) { 72 return; 73 } 74 printf(" bus=%p \n" 75 " address=%d config=%d depth=%d speed=%d self_powered=%d\n" 76 " power=%d langid=%d\n", 77 udev->bus, 78 udev->address, udev->curr_config_no, udev->depth, udev->speed, 79 udev->flags.self_powered, udev->power, udev->langid); 80} 81 82/*------------------------------------------------------------------------* 83 * usb2_dump_queue 84 * 85 * This function dumps the USB transfer that are queued up on an USB pipe. 86 *------------------------------------------------------------------------*/ 87void 88usb2_dump_queue(struct usb2_pipe *pipe) 89{ 90 struct usb2_xfer *xfer; 91 92 printf("usb2_dump_queue: pipe=%p xfer: ", pipe); 93 TAILQ_FOREACH(xfer, &pipe->pipe_q.head, wait_entry) { 94 printf(" %p", xfer); 95 } 96 printf("\n"); 97} 98 99/*------------------------------------------------------------------------* 100 * usb2_dump_pipe 101 * 102 * This function dumps information about an USB pipe. 103 *------------------------------------------------------------------------*/ 104void 105usb2_dump_pipe(struct usb2_pipe *pipe) 106{ 107 if (pipe) { 108 printf("usb2_dump_pipe: pipe=%p", pipe); 109 110 printf(" edesc=%p isoc_next=%d toggle_next=%d", 111 pipe->edesc, pipe->isoc_next, pipe->toggle_next); 112 113 if (pipe->edesc) { 114 printf(" bEndpointAddress=0x%02x", 115 pipe->edesc->bEndpointAddress); 116 } 117 printf("\n"); 118 usb2_dump_queue(pipe); 119 } else { 120 printf("usb2_dump_pipe: pipe=NULL\n"); 121 } 122} 123 124/*------------------------------------------------------------------------* 125 * usb2_dump_xfer 126 * 127 * This function dumps information about an USB transfer. 128 *------------------------------------------------------------------------*/ 129void 130usb2_dump_xfer(struct usb2_xfer *xfer) 131{ 132 struct usb2_device *udev; 133 printf("usb2_dump_xfer: xfer=%p\n", xfer); 134 if (xfer == NULL) { 135 return; 136 } 137 if (xfer->pipe == NULL) { 138 printf("xfer %p: pipe=NULL\n", 139 xfer); 140 return; 141 } 142 udev = xfer->xroot->udev; 143 printf("xfer %p: udev=%p vid=0x%04x pid=0x%04x addr=%d " 144 "pipe=%p ep=0x%02x attr=0x%02x\n", 145 xfer, udev, 146 UGETW(udev->ddesc.idVendor), 147 UGETW(udev->ddesc.idProduct), 148 udev->address, xfer->pipe, 149 xfer->pipe->edesc->bEndpointAddress, 150 xfer->pipe->edesc->bmAttributes); 151}
| 44 &usb2_debug, 0, "Debug level"); 45 46/*------------------------------------------------------------------------* 47 * usb2_dump_iface 48 * 49 * This function dumps information about an USB interface. 50 *------------------------------------------------------------------------*/ 51void 52usb2_dump_iface(struct usb2_interface *iface) 53{ 54 printf("usb2_dump_iface: iface=%p\n", iface); 55 if (iface == NULL) { 56 return; 57 } 58 printf(" iface=%p idesc=%p altindex=%d\n", 59 iface, iface->idesc, iface->alt_index); 60} 61 62/*------------------------------------------------------------------------* 63 * usb2_dump_device 64 * 65 * This function dumps information about an USB device. 66 *------------------------------------------------------------------------*/ 67void 68usb2_dump_device(struct usb2_device *udev) 69{ 70 printf("usb2_dump_device: dev=%p\n", udev); 71 if (udev == NULL) { 72 return; 73 } 74 printf(" bus=%p \n" 75 " address=%d config=%d depth=%d speed=%d self_powered=%d\n" 76 " power=%d langid=%d\n", 77 udev->bus, 78 udev->address, udev->curr_config_no, udev->depth, udev->speed, 79 udev->flags.self_powered, udev->power, udev->langid); 80} 81 82/*------------------------------------------------------------------------* 83 * usb2_dump_queue 84 * 85 * This function dumps the USB transfer that are queued up on an USB pipe. 86 *------------------------------------------------------------------------*/ 87void 88usb2_dump_queue(struct usb2_pipe *pipe) 89{ 90 struct usb2_xfer *xfer; 91 92 printf("usb2_dump_queue: pipe=%p xfer: ", pipe); 93 TAILQ_FOREACH(xfer, &pipe->pipe_q.head, wait_entry) { 94 printf(" %p", xfer); 95 } 96 printf("\n"); 97} 98 99/*------------------------------------------------------------------------* 100 * usb2_dump_pipe 101 * 102 * This function dumps information about an USB pipe. 103 *------------------------------------------------------------------------*/ 104void 105usb2_dump_pipe(struct usb2_pipe *pipe) 106{ 107 if (pipe) { 108 printf("usb2_dump_pipe: pipe=%p", pipe); 109 110 printf(" edesc=%p isoc_next=%d toggle_next=%d", 111 pipe->edesc, pipe->isoc_next, pipe->toggle_next); 112 113 if (pipe->edesc) { 114 printf(" bEndpointAddress=0x%02x", 115 pipe->edesc->bEndpointAddress); 116 } 117 printf("\n"); 118 usb2_dump_queue(pipe); 119 } else { 120 printf("usb2_dump_pipe: pipe=NULL\n"); 121 } 122} 123 124/*------------------------------------------------------------------------* 125 * usb2_dump_xfer 126 * 127 * This function dumps information about an USB transfer. 128 *------------------------------------------------------------------------*/ 129void 130usb2_dump_xfer(struct usb2_xfer *xfer) 131{ 132 struct usb2_device *udev; 133 printf("usb2_dump_xfer: xfer=%p\n", xfer); 134 if (xfer == NULL) { 135 return; 136 } 137 if (xfer->pipe == NULL) { 138 printf("xfer %p: pipe=NULL\n", 139 xfer); 140 return; 141 } 142 udev = xfer->xroot->udev; 143 printf("xfer %p: udev=%p vid=0x%04x pid=0x%04x addr=%d " 144 "pipe=%p ep=0x%02x attr=0x%02x\n", 145 xfer, udev, 146 UGETW(udev->ddesc.idVendor), 147 UGETW(udev->ddesc.idProduct), 148 udev->address, xfer->pipe, 149 xfer->pipe->edesc->bEndpointAddress, 150 xfer->pipe->edesc->bmAttributes); 151}
|