Tue Mar 29 08:42:41 2016 UTC ()
Whitespace


(skrll)
diff -r1.126.2.23 -r1.126.2.24 src/sys/dev/usb/uhub.c
diff -r1.109.2.25 -r1.109.2.26 src/sys/dev/usb/usbdivar.h

cvs diff -r1.126.2.23 -r1.126.2.24 src/sys/dev/usb/uhub.c (expand / switch to unified diff)

--- src/sys/dev/usb/uhub.c 2016/02/16 08:02:49 1.126.2.23
+++ src/sys/dev/usb/uhub.c 2016/03/29 08:42:41 1.126.2.24
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: uhub.c,v 1.126.2.23 2016/02/16 08:02:49 skrll Exp $ */ 1/* $NetBSD: uhub.c,v 1.126.2.24 2016/03/29 08:42:41 skrll Exp $ */
2/* $FreeBSD: src/sys/dev/usb/uhub.c,v 1.18 1999/11/17 22:33:43 n_hibma Exp $ */ 2/* $FreeBSD: src/sys/dev/usb/uhub.c,v 1.18 1999/11/17 22:33:43 n_hibma Exp $ */
3/* $OpenBSD: uhub.c,v 1.86 2015/06/29 18:27:40 mpi Exp $ */ 3/* $OpenBSD: uhub.c,v 1.86 2015/06/29 18:27:40 mpi Exp $ */
4 4
5/* 5/*
6 * Copyright (c) 1998, 2004 The NetBSD Foundation, Inc. 6 * Copyright (c) 1998, 2004 The NetBSD Foundation, Inc.
7 * All rights reserved. 7 * All rights reserved.
8 * 8 *
9 * This code is derived from software contributed to The NetBSD Foundation 9 * This code is derived from software contributed to The NetBSD Foundation
10 * by Lennart Augustsson (lennart@augustsson.net) at 10 * by Lennart Augustsson (lennart@augustsson.net) at
11 * Carlstedt Research & Technology. 11 * Carlstedt Research & Technology.
12 * 12 *
13 * Redistribution and use in source and binary forms, with or without 13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions 14 * modification, are permitted provided that the following conditions
@@ -27,27 +27,27 @@ @@ -27,27 +27,27 @@
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE. 32 * POSSIBILITY OF SUCH DAMAGE.
33 */ 33 */
34 34
35/* 35/*
36 * USB spec: http://www.usb.org/developers/docs/usbspec.zip 36 * USB spec: http://www.usb.org/developers/docs/usbspec.zip
37 */ 37 */
38 38
39#include <sys/cdefs.h> 39#include <sys/cdefs.h>
40__KERNEL_RCSID(0, "$NetBSD: uhub.c,v 1.126.2.23 2016/02/16 08:02:49 skrll Exp $"); 40__KERNEL_RCSID(0, "$NetBSD: uhub.c,v 1.126.2.24 2016/03/29 08:42:41 skrll Exp $");
41 41
42#include <sys/param.h> 42#include <sys/param.h>
43 43
44#include <sys/bus.h> 44#include <sys/bus.h>
45#include <sys/device.h> 45#include <sys/device.h>
46#include <sys/kernel.h> 46#include <sys/kernel.h>
47#include <sys/kmem.h> 47#include <sys/kmem.h>
48#include <sys/proc.h> 48#include <sys/proc.h>
49#include <sys/sysctl.h> 49#include <sys/sysctl.h>
50#include <sys/systm.h> 50#include <sys/systm.h>
51 51
52 52
53#include <dev/usb/usb.h> 53#include <dev/usb/usb.h>
@@ -88,40 +88,40 @@ SYSCTL_SETUP(sysctl_hw_uhub_setup, "sysc @@ -88,40 +88,40 @@ SYSCTL_SETUP(sysctl_hw_uhub_setup, "sysc
88fail: 88fail:
89 aprint_error("%s: sysctl_createv failed (err = %d)\n", __func__, err); 89 aprint_error("%s: sysctl_createv failed (err = %d)\n", __func__, err);
90} 90}
91 91
92#endif /* UHUB_DEBUG */ 92#endif /* UHUB_DEBUG */
93#endif /* USB_DEBUG */ 93#endif /* USB_DEBUG */
94 94
95#define DPRINTF(FMT,A,B,C,D) USBHIST_LOGN(uhubdebug,1,FMT,A,B,C,D) 95#define DPRINTF(FMT,A,B,C,D) USBHIST_LOGN(uhubdebug,1,FMT,A,B,C,D)
96#define DPRINTFN(N,FMT,A,B,C,D) USBHIST_LOGN(uhubdebug,N,FMT,A,B,C,D) 96#define DPRINTFN(N,FMT,A,B,C,D) USBHIST_LOGN(uhubdebug,N,FMT,A,B,C,D)
97#define UHUBHIST_FUNC() USBHIST_FUNC() 97#define UHUBHIST_FUNC() USBHIST_FUNC()
98#define UHUBHIST_CALLED(name) USBHIST_CALLED(uhubdebug) 98#define UHUBHIST_CALLED(name) USBHIST_CALLED(uhubdebug)
99 99
100struct uhub_softc { 100struct uhub_softc {
101 device_t sc_dev; /* base device */ 101 device_t sc_dev; /* base device */
102 struct usbd_device * sc_hub; /* USB device */ 102 struct usbd_device *sc_hub; /* USB device */
103 int sc_proto; /* device protocol */ 103 int sc_proto; /* device protocol */
104 struct usbd_pipe * sc_ipipe; /* interrupt pipe */ 104 struct usbd_pipe *sc_ipipe; /* interrupt pipe */
105 105
106 kmutex_t sc_lock; 106 kmutex_t sc_lock;
107 107
108 uint8_t *sc_statusbuf; 108 uint8_t *sc_statusbuf;
109 uint8_t *sc_statuspend; 109 uint8_t *sc_statuspend;
110 uint8_t *sc_status; 110 uint8_t *sc_status;
111 size_t sc_statuslen; 111 size_t sc_statuslen;
112 int sc_explorepending; 112 int sc_explorepending;
113 113
114 u_char sc_running; 114 u_char sc_running;
115}; 115};
116 116
117#define UHUB_IS_HIGH_SPEED(sc) \ 117#define UHUB_IS_HIGH_SPEED(sc) \
118 ((sc)->sc_proto == UDPROTO_HSHUBSTT || (sc)->sc_proto == UDPROTO_HSHUBMTT) 118 ((sc)->sc_proto == UDPROTO_HSHUBSTT || (sc)->sc_proto == UDPROTO_HSHUBMTT)
119#define UHUB_IS_SINGLE_TT(sc) ((sc)->sc_proto == UDPROTO_HSHUBSTT) 119#define UHUB_IS_SINGLE_TT(sc) ((sc)->sc_proto == UDPROTO_HSHUBSTT)
120 120
121#define PORTSTAT_ISSET(sc, port) \ 121#define PORTSTAT_ISSET(sc, port) \
122 ((sc)->sc_status[(port) / 8] & (1 << ((port) % 8))) 122 ((sc)->sc_status[(port) / 8] & (1 << ((port) % 8)))
123 123
124Static usbd_status uhub_explore(struct usbd_device *); 124Static usbd_status uhub_explore(struct usbd_device *);
125Static void uhub_intr(struct usbd_xfer *, void *, usbd_status); 125Static void uhub_intr(struct usbd_xfer *, void *, usbd_status);
126 126
127 127

cvs diff -r1.109.2.25 -r1.109.2.26 src/sys/dev/usb/usbdivar.h (expand / switch to unified diff)

--- src/sys/dev/usb/usbdivar.h 2016/03/17 09:04:53 1.109.2.25
+++ src/sys/dev/usb/usbdivar.h 2016/03/29 08:42:41 1.109.2.26
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: usbdivar.h,v 1.109.2.25 2016/03/17 09:04:53 skrll Exp $ */ 1/* $NetBSD: usbdivar.h,v 1.109.2.26 2016/03/29 08:42:41 skrll Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1998, 2012 The NetBSD Foundation, Inc. 4 * Copyright (c) 1998, 2012 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Lennart Augustsson (lennart@augustsson.net) at 8 * by Lennart Augustsson (lennart@augustsson.net) at
9 * Carlstedt Research & Technology and Matthew R. Green (mrg@eterna.com.au). 9 * Carlstedt Research & Technology and Matthew R. Green (mrg@eterna.com.au).
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
13 * are met: 13 * are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
@@ -142,146 +142,153 @@ struct usbd_hub { @@ -142,146 +142,153 @@ struct usbd_hub {
142 142
143struct usbd_bus { 143struct usbd_bus {
144 /* Filled by HC driver */ 144 /* Filled by HC driver */
145 void *ub_hcpriv; 145 void *ub_hcpriv;
146 int ub_revision; /* USB revision */ 146 int ub_revision; /* USB revision */
147#define USBREV_UNKNOWN 0 147#define USBREV_UNKNOWN 0
148#define USBREV_PRE_1_0 1 148#define USBREV_PRE_1_0 1
149#define USBREV_1_0 2 149#define USBREV_1_0 2
150#define USBREV_1_1 3 150#define USBREV_1_1 3
151#define USBREV_2_0 4 151#define USBREV_2_0 4
152#define USBREV_3_0 5 152#define USBREV_3_0 5
153#define USBREV_STR { "unknown", "pre 1.0", "1.0", "1.1", "2.0", "3.0" } 153#define USBREV_STR { "unknown", "pre 1.0", "1.0", "1.1", "2.0", "3.0" }
154 154
155 const struct usbd_bus_methods *ub_methods; 155 const struct usbd_bus_methods
 156 *ub_methods;
156 uint32_t ub_pipesize; /* size of a pipe struct */ 157 uint32_t ub_pipesize; /* size of a pipe struct */
157 bool ub_usedma; /* Does this HC support DMA */ 158 bool ub_usedma; /* Does this HC support DMA */
158 int ub_dmaflags; 159 int ub_dmaflags;
159 bus_dma_tag_t ub_dmatag; /* DMA tag */ 160 bus_dma_tag_t ub_dmatag; /* DMA tag */
160 161
161 /* Filled by usb driver */ 162 /* Filled by usb driver */
162 kmutex_t *ub_lock; 163 kmutex_t *ub_lock;
163 struct usbd_device *ub_roothub; 164 struct usbd_device *ub_roothub;
164 uint8_t ub_rhaddr; /* roothub address */ 165 uint8_t ub_rhaddr; /* roothub address */
165 uint8_t ub_rhconf; /* roothub configuration */ 166 uint8_t ub_rhconf; /* roothub configuration */
166 struct usbd_device * ub_devices[USB_MAX_DEVICES]; 167 struct usbd_device *ub_devices[USB_MAX_DEVICES];
167 kcondvar_t ub_needsexplore_cv; 168 kcondvar_t ub_needsexplore_cv;
168 char ub_needsexplore;/* a hub a signalled a change */ 169 char ub_needsexplore;/* a hub a signalled a change */
169 char ub_usepolling; 170 char ub_usepolling;
170 device_t ub_usbctl; 171 device_t ub_usbctl;
171 struct usb_device_stats ub_stats; 172 struct usb_device_stats ub_stats;
172 173
173 void *ub_soft; /* soft interrupt cookie */ 174 void *ub_soft; /* soft interrupt cookie */
174}; 175};
175 176
176struct usbd_device { 177struct usbd_device {
177 struct usbd_bus *ud_bus; /* our controller */ 178 struct usbd_bus *ud_bus; /* our controller */
178 struct usbd_pipe *ud_pipe0; /* pipe 0 */ 179 struct usbd_pipe *ud_pipe0; /* pipe 0 */
179 uint8_t ud_addr; /* device addess */ 180 uint8_t ud_addr; /* device addess */
180 uint8_t ud_config; /* current configuration # */ 181 uint8_t ud_config; /* current configuration # */
181 uint8_t ud_depth; /* distance from root hub */ 182 uint8_t ud_depth; /* distance from root hub */
182 uint8_t ud_speed; /* low/full/high speed */ 183 uint8_t ud_speed; /* low/full/high speed */
183 uint8_t ud_selfpowered; /* flag for self powered */ 184 uint8_t ud_selfpowered; /* flag for self powered */
184 uint16_t ud_power; /* mA the device uses */ 185 uint16_t ud_power; /* mA the device uses */
185 int16_t ud_langid; /* language for strings */ 186 int16_t ud_langid; /* language for strings */
186#define USBD_NOLANG (-1) 187#define USBD_NOLANG (-1)
187 usb_event_cookie_t ud_cookie; /* unique connection id */ 188 usb_event_cookie_t ud_cookie; /* unique connection id */
188 struct usbd_port *ud_powersrc; /* upstream hub port, or 0 */ 189 struct usbd_port *ud_powersrc; /* upstream hub port, or 0 */
189 struct usbd_device *ud_myhub; /* upstream hub */ 190 struct usbd_device *ud_myhub; /* upstream hub */
190 struct usbd_port *ud_myhsport; /* closest high speed port */ 191 struct usbd_port *ud_myhsport; /* closest high speed port */
191 struct usbd_endpoint ud_ep0; /* for pipe 0 */ 192 struct usbd_endpoint ud_ep0; /* for pipe 0 */
192 usb_endpoint_descriptor_t ud_ep0desc; /* for pipe 0 */ 193 usb_endpoint_descriptor_t
 194 ud_ep0desc; /* for pipe 0 */
193 struct usbd_interface *ud_ifaces; /* array of all interfaces */ 195 struct usbd_interface *ud_ifaces; /* array of all interfaces */
194 usb_device_descriptor_t ud_ddesc; /* device descriptor */ 196 usb_device_descriptor_t ud_ddesc; /* device descriptor */
195 usb_config_descriptor_t *ud_cdesc; /* full config descr */ 197 usb_config_descriptor_t *ud_cdesc; /* full config descr */
196 usb_bos_descriptor_t *ud_bdesc; /* full BOS descr */ 198 usb_bos_descriptor_t *ud_bdesc; /* full BOS descr */
197 const struct usbd_quirks *ud_quirks;/* device quirks, always set */ 199 const struct usbd_quirks
 200 *ud_quirks; /* device quirks, always set */
198 struct usbd_hub *ud_hub; /* only if this is a hub */ 201 struct usbd_hub *ud_hub; /* only if this is a hub */
199 int ud_subdevlen; /* array length of following */ 202 int ud_subdevlen; /* array length of following */
200 device_t *ud_subdevs; /* sub-devices */ 203 device_t *ud_subdevs; /* sub-devices */
201 int ud_nifaces_claimed; /* number of ifaces in use */ 204 int ud_nifaces_claimed; /* number of ifaces in use */
202 void *ud_hcpriv; 205 void *ud_hcpriv;
203 206
204 char *ud_serial; /* serial number, can be NULL */ 207 char *ud_serial; /* serial number, can be NULL */
205 char *ud_vendor; /* vendor string, can be NULL */ 208 char *ud_vendor; /* vendor string, can be NULL */
206 char *ud_product; /* product string can be NULL */ 209 char *ud_product; /* product string can be NULL */
207}; 210};
208 211
209struct usbd_interface { 212struct usbd_interface {
210 struct usbd_device *ui_dev; 213 struct usbd_device *ui_dev;
211 usb_interface_descriptor_t *ui_idesc; 214 usb_interface_descriptor_t
 215 *ui_idesc;
212 int ui_index; 216 int ui_index;
213 int ui_altindex; 217 int ui_altindex;
214 struct usbd_endpoint *ui_endpoints; 218 struct usbd_endpoint *ui_endpoints;
215 void *ui_priv; 219 void *ui_priv;
216 LIST_HEAD(, usbd_pipe) ui_pipes; 220 LIST_HEAD(, usbd_pipe) ui_pipes;
217}; 221};
218 222
219struct usbd_pipe { 223struct usbd_pipe {
220 struct usbd_interface *up_iface; 224 struct usbd_interface *up_iface;
221 struct usbd_device *up_dev; 225 struct usbd_device *up_dev;
222 struct usbd_endpoint *up_endpoint; 226 struct usbd_endpoint *up_endpoint;
223 char up_running; 227 char up_running;
224 char up_aborting; 228 char up_aborting;
225 bool up_serialise; 229 bool up_serialise;
226 SIMPLEQ_HEAD(, usbd_xfer) up_queue; 230 SIMPLEQ_HEAD(, usbd_xfer)
 231 up_queue;
227 LIST_ENTRY(usbd_pipe) up_next; 232 LIST_ENTRY(usbd_pipe) up_next;
228 struct usb_task up_async_task; 233 struct usb_task up_async_task;
229 234
230 struct usbd_xfer *up_intrxfer; /* used for repeating requests */ 235 struct usbd_xfer *up_intrxfer; /* used for repeating requests */
231 char up_repeat; 236 char up_repeat;
232 int up_interval; 237 int up_interval;
233 uint8_t up_flags; 238 uint8_t up_flags;
234 239
235 /* Filled by HC driver. */ 240 /* Filled by HC driver. */
236 const struct usbd_pipe_methods *up_methods; 241 const struct usbd_pipe_methods
 242 *up_methods;
237}; 243};
238 244
239struct usbd_xfer { 245struct usbd_xfer {
240 struct usbd_pipe *ux_pipe; 246 struct usbd_pipe *ux_pipe;
241 void *ux_priv; 247 void *ux_priv;
242 void *ux_buffer; 248 void *ux_buffer;
243 kcondvar_t ux_cv; 249 kcondvar_t ux_cv;
244 uint32_t ux_length; 250 uint32_t ux_length;
245 uint32_t ux_actlen; 251 uint32_t ux_actlen;
246 uint16_t ux_flags; 252 uint16_t ux_flags;
247 uint32_t ux_timeout; 253 uint32_t ux_timeout;
248 usbd_status ux_status; 254 usbd_status ux_status;
249 usbd_callback ux_callback; 255 usbd_callback ux_callback;
250 volatile uint8_t ux_done; 256 volatile uint8_t ux_done;
251 uint8_t ux_state; /* used for DIAGNOSTIC */ 257 uint8_t ux_state; /* used for DIAGNOSTIC */
252#define XFER_FREE 0x46 258#define XFER_FREE 0x46
253#define XFER_BUSY 0x55 259#define XFER_BUSY 0x55
254#define XFER_ONQU 0x9e 260#define XFER_ONQU 0x9e
255 261
256 /* For control pipe */ 262 /* For control pipe */
257 usb_device_request_t ux_request; 263 usb_device_request_t ux_request;
258 264
259 /* For isoc */ 265 /* For isoc */
260 uint16_t *ux_frlengths; 266 uint16_t *ux_frlengths;
261 int ux_nframes; 267 int ux_nframes;
262 268
263 const struct usbd_pipe_methods *ux_methods; 269 const struct usbd_pipe_methods *ux_methods;
264 270
265 /* For memory allocation and softc */ 271 /* For memory allocation and softc */
266 struct usbd_bus *ux_bus; 272 struct usbd_bus *ux_bus;
267 usb_dma_t ux_dmabuf; 273 usb_dma_t ux_dmabuf;
268 void *ux_buf; 274 void *ux_buf;
269 uint32_t ux_bufsize; 275 uint32_t ux_bufsize;
270 276
271 uint8_t ux_rqflags; 277 uint8_t ux_rqflags;
272#define URQ_REQUEST 0x01 278#define URQ_REQUEST 0x01
273 279
274 SIMPLEQ_ENTRY(usbd_xfer) ux_next; 280 SIMPLEQ_ENTRY(usbd_xfer)
 281 ux_next;
275 282
276 void *ux_hcpriv; /* private use by the HC driver */ 283 void *ux_hcpriv; /* private use by the HC driver */
277 uint8_t ux_hcflags; /* private use by the HC driver */ 284 uint8_t ux_hcflags; /* private use by the HC driver */
278#define UXFER_ABORTING 0x01 /* xfer is aborting. */ 285#define UXFER_ABORTING 0x01 /* xfer is aborting. */
279#define UXFER_ABORTWAIT 0x02 /* abort completion is being awaited. */ 286#define UXFER_ABORTWAIT 0x02 /* abort completion is being awaited. */
280 kcondvar_t ux_hccv; /* private use by the HC driver */ 287 kcondvar_t ux_hccv; /* private use by the HC driver */
281 288
282 struct callout ux_callout; 289 struct callout ux_callout;
283}; 290};
284 291
285void usbd_init(void); 292void usbd_init(void);
286void usbd_finish(void); 293void usbd_finish(void);
287 294