diff options
author | Federico G. Schwindt <fgsch@cvs.openbsd.org> | 1999-08-19 08:18:40 +0000 |
---|---|---|
committer | Federico G. Schwindt <fgsch@cvs.openbsd.org> | 1999-08-19 08:18:40 +0000 |
commit | d2fb3e6b4d34b003fb7e2146e053140c3217b39a (patch) | |
tree | 1e7bc152528eb7d8d7785f44f69a71913ca62d79 | |
parent | 8faaaa88c31e033130b9fb704cae7379c0fe21ca (diff) |
Sync with NetBSD.
-rw-r--r-- | sys/dev/usb/ohci.c | 50 | ||||
-rw-r--r-- | sys/dev/usb/ohcivar.h | 4 | ||||
-rw-r--r-- | sys/dev/usb/uhci.c | 113 | ||||
-rw-r--r-- | sys/dev/usb/usb.c | 10 | ||||
-rw-r--r-- | sys/dev/usb/usb.h | 8 | ||||
-rw-r--r-- | sys/dev/usb/usb_mem.c | 19 | ||||
-rw-r--r-- | sys/dev/usb/usb_port.h | 6 | ||||
-rw-r--r-- | sys/dev/usb/usb_subr.c | 18 | ||||
-rw-r--r-- | sys/dev/usb/usbcdc.h | 149 | ||||
-rw-r--r-- | sys/dev/usb/usbdi.c | 52 | ||||
-rw-r--r-- | sys/dev/usb/usbdivar.h | 8 |
11 files changed, 323 insertions, 114 deletions
diff --git a/sys/dev/usb/ohci.c b/sys/dev/usb/ohci.c index eead92f1ebc..503d1a50e33 100644 --- a/sys/dev/usb/ohci.c +++ b/sys/dev/usb/ohci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ohci.c,v 1.3 1999/08/15 18:58:58 fgsch Exp $ */ +/* $OpenBSD: ohci.c,v 1.4 1999/08/19 08:18:38 fgsch Exp $ */ /* $NetBSD: ohci.c,v 1.33 1999/06/30 06:44:23 augustss Exp $ */ /* @@ -89,11 +89,7 @@ struct cfdriver ohci_cd = { * the data strored in memory needs to be swapped. */ #if BYTE_ORDER == BIG_ENDIAN -#if defined(__OpenBSD__) -#define LE(x) (swap32(x)) -#else #define LE(x) (bswap32(x)) -#endif #else #define LE(x) (x) #endif @@ -161,6 +157,9 @@ void ohci_close_pipe __P((usbd_pipe_handle pipe, ohci_soft_ed_t *head)); void ohci_abort_request __P((usbd_request_handle reqh)); +void ohci_device_clear_toggle __P((usbd_pipe_handle pipe)); +void ohci_noop __P((usbd_pipe_handle pipe)); + #ifdef USB_DEBUG ohci_softc_t *thesc; void ohci_dumpregs __P((ohci_softc_t *)); @@ -169,15 +168,9 @@ void ohci_dump_td __P((ohci_soft_td_t *)); void ohci_dump_ed __P((ohci_soft_ed_t *)); #endif -#if defined(__NetBSD__) || defined(__OpenBSD__) #define OWRITE4(sc, r, x) bus_space_write_4((sc)->iot, (sc)->ioh, (r), (x)) #define OREAD4(sc, r) bus_space_read_4((sc)->iot, (sc)->ioh, (r)) #define OREAD2(sc, r) bus_space_read_2((sc)->iot, (sc)->ioh, (r)) -#elif defined(__FreeBSD__) -#define OWRITE4(sc, r, x) (*(u_int32_t *) ((sc)->sc_iobase + (r)) = (x)) -#define OREAD4(sc, r) (*(u_int32_t *) ((sc)->sc_iobase + (r))) -#define OREAD2(sc, r) (*(u_int16_t *) ((sc)->sc_iobase + (r))) -#endif /* Reverse the bits in a value 0 .. 31 */ static u_int8_t revbits[OHCI_NO_INTRS] = @@ -221,6 +214,7 @@ struct usbd_methods ohci_root_ctrl_methods = { ohci_root_ctrl_start, ohci_root_ctrl_abort, ohci_root_ctrl_close, + ohci_noop, 0, }; @@ -229,6 +223,7 @@ struct usbd_methods ohci_root_intr_methods = { ohci_root_intr_start, ohci_root_intr_abort, ohci_root_intr_close, + ohci_noop, 0, }; @@ -237,6 +232,7 @@ struct usbd_methods ohci_device_ctrl_methods = { ohci_device_ctrl_start, ohci_device_ctrl_abort, ohci_device_ctrl_close, + ohci_noop, 0, }; @@ -245,6 +241,8 @@ struct usbd_methods ohci_device_intr_methods = { ohci_device_intr_start, ohci_device_intr_abort, ohci_device_intr_close, + ohci_device_clear_toggle, + 0, }; struct usbd_methods ohci_device_bulk_methods = { @@ -252,6 +250,7 @@ struct usbd_methods ohci_device_bulk_methods = { ohci_device_bulk_start, ohci_device_bulk_abort, ohci_device_bulk_close, + ohci_device_clear_toggle, 0, }; @@ -534,9 +533,7 @@ ohci_init(sc) sc->sc_bus.pipe_size = sizeof(struct ohci_pipe); sc->sc_bus.do_poll = ohci_poll; -#if !defined(__OpenBSD__) - (void)powerhook_establish(ohci_power, sc); -#endif + powerhook_establish(ohci_power, sc); return (USBD_NORMAL_COMPLETION); @@ -549,6 +546,7 @@ ohci_init(sc) return (r); } +#if !defined(__OpenBSD__) void ohci_power(why, v) int why; @@ -562,6 +560,7 @@ ohci_power(why, v) ohci_dumpregs(sc); #endif } +#endif /* !defined(__OpenBSD__) */ #ifdef USB_DEBUG void ohcidump(void); @@ -810,13 +809,15 @@ ohci_done(sc, reqh) ohci_softc_t *sc; usbd_request_handle reqh; { + usbd_pipe_handle pipe = reqh->pipe; + #ifdef DIAGNOSTIC if (!reqh->hcpriv) printf("ohci_done: reqh=%p, no hcpriv\n", reqh); #endif reqh->hcpriv = 0; - switch (reqh->pipe->endpoint->edesc->bmAttributes & UE_XFERTYPE) { + switch (pipe->endpoint->edesc->bmAttributes & UE_XFERTYPE) { case UE_CONTROL: ohci_ctrl_done(sc, reqh); break; @@ -831,6 +832,9 @@ ohci_done(sc, reqh) break; } + /* Remove request from queue. */ + SIMPLEQ_REMOVE_HEAD(&pipe->queue, reqh, next); + /* And finally execute callback. */ reqh->xfercb(reqh); } @@ -1881,6 +1885,7 @@ ohci_root_ctrl_start(reqh) reqh->actlen = totlen; r = USBD_NORMAL_COMPLETION; ret: + SIMPLEQ_REMOVE_HEAD(&reqh->pipe->queue, reqh, next); reqh->status = r; reqh->xfercb(reqh); usb_start_next(reqh->pipe); @@ -2026,6 +2031,21 @@ ohci_device_ctrl_close(pipe) /************************/ +void +ohci_device_clear_toggle(pipe) + usbd_pipe_handle pipe; +{ + struct ohci_pipe *opipe = (struct ohci_pipe *)pipe; + + opipe->sed->ed->ed_tailp &= LE(~OHCI_TOGGLECARRY); +} + +void +ohci_noop(pipe) + usbd_pipe_handle pipe; +{ +} + usbd_status ohci_device_bulk_transfer(reqh) usbd_request_handle reqh; diff --git a/sys/dev/usb/ohcivar.h b/sys/dev/usb/ohcivar.h index 76a2dfea5d4..601619a4199 100644 --- a/sys/dev/usb/ohcivar.h +++ b/sys/dev/usb/ohcivar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ohcivar.h,v 1.2 1999/08/16 22:08:48 fgsch Exp $ */ +/* $OpenBSD: ohcivar.h,v 1.3 1999/08/19 08:18:38 fgsch Exp $ */ /* $NetBSD: ohcivar.h,v 1.6 1999/08/14 14:49:31 augustss Exp $ */ /* @@ -73,7 +73,7 @@ typedef struct ohci_softc { bus_dma_tag_t sc_dmatag; /* DMA tag */ /* XXX should keep track of all DMA memory */ -#endif /* __NetBSD__ */ +#endif /* __NetBSD__ || defined(__OpenBSD__) */ usb_dma_t sc_hccadma; struct ohci_hcca *sc_hcca; diff --git a/sys/dev/usb/uhci.c b/sys/dev/usb/uhci.c index a0b2a0059ed..9296c686491 100644 --- a/sys/dev/usb/uhci.c +++ b/sys/dev/usb/uhci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uhci.c,v 1.2 1999/08/16 22:08:48 fgsch Exp $ */ +/* $OpenBSD: uhci.c,v 1.3 1999/08/19 08:18:38 fgsch Exp $ */ /* $NetBSD: uhci.c,v 1.34 1999/08/02 23:35:55 augustss Exp $ */ /* @@ -157,8 +157,8 @@ usbd_status uhci_alloc_std_chain __P((struct uhci_pipe *, uhci_softc_t *, void uhci_timo __P((void *)); void uhci_waitintr __P((uhci_softc_t *, usbd_request_handle)); void uhci_check_intr __P((uhci_softc_t *, uhci_intr_info_t *)); -void uhci_ii_done __P((uhci_intr_info_t *)); -void uhci_ii_finish __P((uhci_intr_info_t *)); +void uhci_idone __P((uhci_intr_info_t *)); +void uhci_done __P((uhci_intr_info_t *)); void uhci_abort_req __P((usbd_request_handle, usbd_status status)); void uhci_timeout __P((void *)); void uhci_wakeup_ctrl __P((void *, int, int, void *, int)); @@ -213,6 +213,9 @@ usbd_status uhci_device_setintr __P((uhci_softc_t *sc, void uhci_intr_done __P((uhci_intr_info_t *ii)); void uhci_isoc_done __P((uhci_intr_info_t *ii)); +void uhci_device_clear_toggle __P((usbd_pipe_handle pipe)); +void uhci_noop __P((usbd_pipe_handle pipe)); + #ifdef USB_DEBUG static void uhci_dumpregs __P((uhci_softc_t *)); void uhci_dump_tds __P((uhci_soft_td_t *)); @@ -241,6 +244,7 @@ struct usbd_methods uhci_root_ctrl_methods = { uhci_root_ctrl_start, uhci_root_ctrl_abort, uhci_root_ctrl_close, + uhci_noop, 0, }; @@ -249,6 +253,7 @@ struct usbd_methods uhci_root_intr_methods = { uhci_root_intr_start, uhci_root_intr_abort, uhci_root_intr_close, + uhci_noop, 0, }; @@ -257,6 +262,7 @@ struct usbd_methods uhci_device_ctrl_methods = { uhci_device_ctrl_start, uhci_device_ctrl_abort, uhci_device_ctrl_close, + uhci_noop, 0, }; @@ -265,6 +271,7 @@ struct usbd_methods uhci_device_intr_methods = { uhci_device_intr_start, uhci_device_intr_abort, uhci_device_intr_close, + uhci_device_clear_toggle, 0, }; @@ -273,6 +280,7 @@ struct usbd_methods uhci_device_bulk_methods = { uhci_device_bulk_start, uhci_device_bulk_abort, uhci_device_bulk_close, + uhci_device_clear_toggle, 0, }; @@ -281,6 +289,7 @@ struct usbd_methods uhci_device_isoc_methods = { uhci_device_isoc_start, uhci_device_isoc_abort, uhci_device_isoc_close, + uhci_noop, uhci_device_isoc_setbuf, }; @@ -379,8 +388,8 @@ uhci_init(sc) #if !defined(__OpenBSD__) sc->sc_suspend = PWR_RESUME; - (void)powerhook_establish(uhci_power, sc); #endif + powerhook_establish(uhci_power, sc); DPRINTFN(1,("uhci_init: enabling\n")); UWRITE2(sc, UHCI_INTR, UHCI_INTR_TOCRCIE | UHCI_INTR_RIE | @@ -451,7 +460,7 @@ uhci_power(why, v) } splx(s); } -#endif +#endif /* !defined(__OpenBSD__) */ #ifdef USB_DEBUG static void @@ -558,6 +567,8 @@ uhci_timo(addr) if (UREAD2(sc, UHCI_PORTSC2) & (UHCI_PORTSC_CSC|UHCI_PORTSC_OCIC)) p[0] |= 1<<2; s = splusb(); + if (!reqh->pipe->repeat) + SIMPLEQ_REMOVE_HEAD(&pipe->queue, reqh, next); if (p[0] != 0) { reqh->actlen = 1; reqh->status = USBD_NORMAL_COMPLETION; @@ -724,12 +735,10 @@ uhci_intr(p) } #endif status = UREAD2(sc, UHCI_STS); -#if !defined(__OpenBSD__) -#ifdef DIAGNOSTIC +#if defined(DIAGNOSTIC) && !defined(__OpenBSD__) if (sc->sc_suspend != PWR_RESUME) printf("uhci_intr: suspended sts=0x%x\n", status); #endif -#endif ret = 0; if (status & UHCI_STS_USBINT) { UWRITE2(sc, UHCI_STS, UHCI_STS_USBINT); /* acknowledge */ @@ -824,28 +833,28 @@ uhci_check_intr(sc, ii) done: usb_untimeout(uhci_timeout, ii, ii->timeout_handle); upipe = (struct uhci_pipe *)ii->reqh->pipe; - uhci_ii_done(ii); - upipe->pipe.endpoint->toggle = upipe->nexttoggle; + uhci_idone(ii); } void -uhci_ii_done(ii) +uhci_idone(ii) uhci_intr_info_t *ii; { usbd_request_handle reqh = ii->reqh; + struct uhci_pipe *upipe = (struct uhci_pipe *)reqh->pipe; uhci_soft_td_t *std; u_int32_t status; int actlen; #ifdef USB_DEBUG - DPRINTFN(10, ("uhci_ii_done: ii=%p ready\n", ii)); + DPRINTFN(10, ("uhci_idone: ii=%p ready\n", ii)); if (uhcidebug > 10) uhci_dump_tds(ii->stdstart); #endif if (reqh->status == USBD_CANCELLED || reqh->status == USBD_TIMEOUT) { - DPRINTF(("uhci_ii_done: aborted reqh=%p\n", reqh)); + DPRINTF(("uhci_idone: aborted reqh=%p\n", reqh)); return; } @@ -854,7 +863,7 @@ uhci_ii_done(ii) int s = splhigh(); if (ii->isdone) { splx(s); - printf("uhci_ii_done: ii=%p is done!\n", ii); + printf("uhci_idone: ii=%p is done!\n", ii); return; } ii->isdone = 1; @@ -872,13 +881,17 @@ uhci_ii_done(ii) if (UHCI_TD_GET_PID(std->td->td_token) != UHCI_TD_PID_SETUP) actlen += UHCI_TD_GET_ACTLEN(status); } + /* If there are left over TDs we need to update the toggle. */ + if (std) + upipe->nexttoggle = UHCI_TD_GET_DT(std->td->td_token); + status &= UHCI_TD_ERROR; DPRINTFN(10, ("uhci_check_intr: actlen=%d, status=0x%x\n", actlen, status)); reqh->actlen = actlen; if (status != 0) { DPRINTFN(-1+((status&UHCI_TD_STALLED)!=0), - ("uhci_ii_done: error, addr=%d, endpt=0x%02x, " + ("uhci_idone: error, addr=%d, endpt=0x%02x, " "status 0x%b\n", reqh->pipe->device->address, reqh->pipe->endpoint->edesc->bEndpointAddress, @@ -892,35 +905,39 @@ uhci_ii_done(ii) } else { reqh->status = USBD_NORMAL_COMPLETION; } - uhci_ii_finish(ii); + + uhci_done(ii); + if (ii->reqh->pipe->intrreqh != ii->reqh) + usb_start_next(ii->reqh->pipe); } void -uhci_ii_finish(ii) +uhci_done(ii) uhci_intr_info_t *ii; { usbd_request_handle reqh = ii->reqh; + usbd_pipe_handle pipe = reqh->pipe; DPRINTFN(5, ("uhci_ii_finish: calling handler ii=%p\n", ii)); - switch (reqh->pipe->endpoint->edesc->bmAttributes & UE_XFERTYPE) { + switch (pipe->endpoint->edesc->bmAttributes & UE_XFERTYPE) { case UE_CONTROL: uhci_ctrl_done(ii); - usb_start_next(reqh->pipe); break; case UE_ISOCHRONOUS: uhci_isoc_done(ii); - usb_start_next(reqh->pipe); break; case UE_BULK: uhci_bulk_done(ii); - usb_start_next(reqh->pipe); break; case UE_INTERRUPT: uhci_intr_done(ii); break; } + /* Remove request from queue. */ + SIMPLEQ_REMOVE_HEAD(&pipe->queue, reqh, next); + /* And finally execute callback. */ reqh->xfercb(reqh); } @@ -972,7 +989,7 @@ uhci_waitintr(sc, reqh) ii = LIST_NEXT(ii, list)) ; if (ii) - uhci_ii_done(ii); + uhci_idone(ii); else panic("uhci_waitintr: lost intr_info\n"); } @@ -1200,7 +1217,7 @@ uhci_alloc_std_chain(upipe, sc, len, rd, shortok, dma, sp, ep) return (USBD_INVAL); } ntd = (len + maxp - 1) / maxp; - tog = upipe->pipe.endpoint->toggle; + tog = upipe->nexttoggle; if (ntd % 2 == 0) tog ^= 1; upipe->nexttoggle = tog ^ 1; @@ -1237,12 +1254,25 @@ uhci_alloc_std_chain(upipe, sc, len, rd, shortok, dma, sp, ep) tog ^= 1; } *sp = lastp; - /*upipe->pipe.endpoint->toggle = tog;*/ - DPRINTFN(10, ("uhci_alloc_std_chain: oldtog=%d nexttog=%d\n", - upipe->pipe.endpoint->toggle, upipe->nexttoggle)); + DPRINTFN(10, ("uhci_alloc_std_chain: nexttog=%d\n", + upipe->nexttoggle)); return (USBD_NORMAL_COMPLETION); } +void +uhci_device_clear_toggle(pipe) + usbd_pipe_handle pipe; +{ + struct uhci_pipe *upipe = (struct uhci_pipe *)pipe; + upipe->nexttoggle = 0; +} + +void +uhci_noop(pipe) + usbd_pipe_handle pipe; +{ +} + usbd_status uhci_device_bulk_transfer(reqh) usbd_request_handle reqh; @@ -1380,7 +1410,7 @@ uhci_abort_req(reqh, status) /* and call final part of interrupt handler. */ s = splusb(); - uhci_ii_finish(ii); + uhci_done(ii); splx(s); } @@ -1554,17 +1584,12 @@ void uhci_device_intr_abort(reqh) usbd_request_handle reqh; { - struct uhci_pipe *upipe; - - DPRINTFN(1, ("uhci_device_intr_abort: reqh=%p\n", reqh)); - /* XXX inactivate */ - usb_delay_ms(reqh->pipe->device->bus, 2); /* make sure it is done */ - if (reqh->pipe->repeat) { - DPRINTF(("uhci_device_intr_abort: remove\n")); - reqh->pipe->repeat = 0; - upipe = (struct uhci_pipe *)reqh->pipe; - uhci_intr_done(upipe->u.intr.qhs[0]->intr_info); + DPRINTFN(1,("uhci_device_intr_abort: reqh=%p\n", reqh)); + if (reqh->pipe->intrreqh == reqh) { + DPRINTFN(1,("uhci_device_intr_abort: remove\n")); + reqh->pipe->intrreqh = 0; } + uhci_abort_req(reqh, USBD_CANCELLED); } /* Close a device interrupt pipe. */ @@ -1644,7 +1669,7 @@ uhci_device_request(reqh) r = usb_allocmem(sc->sc_dmatag, len, 0, dmap); if (r != USBD_NORMAL_COMPLETION) goto ret1; - upipe->pipe.endpoint->toggle = 1; + upipe->nexttoggle = 1; r = uhci_alloc_std_chain(upipe, sc, len, isread, reqh->flags & USBD_SHORT_XFER_OK, dmap, &xfer, &xferend); @@ -1969,7 +1994,6 @@ uhci_intr_done(ii) } else { usb_freemem(sc->sc_dmatag, dma); ii->stdstart = 0; /* mark as inactive */ - usb_start_next(reqh->pipe); } } @@ -2012,7 +2036,6 @@ uhci_bulk_done(ii) uhci_softc_t *sc = ii->sc; usbd_request_handle reqh = ii->reqh; struct uhci_pipe *upipe = (struct uhci_pipe *)reqh->pipe; - uhci_soft_td_t *std; u_int datalen = upipe->u.bulk.length; usb_dma_t *dma; @@ -2020,14 +2043,6 @@ uhci_bulk_done(ii) uhci_remove_bulk(sc, upipe->u.bulk.sqh); - /* find the toggle for the last transfer and invert it */ - for (std = ii->stdstart; std; std = std->td->link.std) { - if (std->td->td_status & UHCI_TD_ACTIVE) - break; - upipe->nexttoggle = UHCI_TD_GET_DT(std->td->td_token); - } - upipe->nexttoggle ^= 1; - /* copy the data from dma memory to userland storage */ dma = &upipe->u.bulk.datadma; if (upipe->u.bulk.isread) @@ -2643,6 +2658,7 @@ uhci_root_ctrl_start(reqh) reqh->actlen = totlen; r = USBD_NORMAL_COMPLETION; ret: + SIMPLEQ_REMOVE_HEAD(&reqh->pipe->queue, reqh, next); reqh->status = r; reqh->xfercb(reqh); usb_start_next(reqh->pipe); @@ -2664,7 +2680,6 @@ uhci_root_ctrl_close(pipe) { uhci_softc_t *sc = (uhci_softc_t *)pipe->device->bus; - usb_untimeout(uhci_timo, pipe->intrreqh, pipe->intrreqh->timo_handle); sc->sc_has_timo = 0; DPRINTF(("uhci_root_ctrl_close\n")); } diff --git a/sys/dev/usb/usb.c b/sys/dev/usb/usb.c index 947f0f9e1ba..b343778ed8d 100644 --- a/sys/dev/usb/usb.c +++ b/sys/dev/usb/usb.c @@ -1,5 +1,5 @@ -/* $OpenBSD: usb.c,v 1.2 1999/08/16 22:08:49 fgsch Exp $ */ -/* $NetBSD: usb.c,v 1.15 1999/08/02 19:36:48 augustss Exp $ */ +/* $OpenBSD: usb.c,v 1.3 1999/08/19 08:18:39 fgsch Exp $ */ +/* $NetBSD: usb.c,v 1.17 1999/08/17 16:06:21 augustss Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -191,10 +191,10 @@ usb_create_event_thread(arg) { struct usb_softc *sc = arg; -#if defined(__OpenBSD__) - if (kthread_create(usb_event_thread, sc, &sc->event_thread, -#else +#if !defined(__OpenBSD__) if (kthread_create1(usb_event_thread, sc, &sc->event_thread, +#else + if (kthread_create(usb_event_thread, sc, &sc->event_thread, #endif "%s", sc->sc_dev.dv_xname)) { printf("%s: unable to create event thread for\n", diff --git a/sys/dev/usb/usb.h b/sys/dev/usb/usb.h index edc0cdcf7a4..a466a7bae82 100644 --- a/sys/dev/usb/usb.h +++ b/sys/dev/usb/usb.h @@ -1,5 +1,5 @@ -/* $OpenBSD: usb.h,v 1.1 1999/08/13 05:28:04 fgsch Exp $ */ -/* $NetBSD: usb.h,v 1.23 1999/06/30 06:44:23 augustss Exp $ */ +/* $OpenBSD: usb.h,v 1.2 1999/08/19 08:18:39 fgsch Exp $ */ +/* $NetBSD: usb.h,v 1.27 1999/08/18 07:55:19 augustss Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -510,4 +510,8 @@ struct usb_device_stats { #define USB_GET_DEVICEINFO _IOR ('U', 112, struct usb_device_info) #define USB_SET_SHORT_XFER _IOW ('U', 113, int) +/* Modem device */ +#define USB_GET_CM_OVER_DATA _IOR ('U', 130, int) +#define USB_SET_CM_OVER_DATA _IOW ('U', 131, int) + #endif /* _USB_H_ */ diff --git a/sys/dev/usb/usb_mem.c b/sys/dev/usb/usb_mem.c index 9dec07993c0..805877dcbae 100644 --- a/sys/dev/usb/usb_mem.c +++ b/sys/dev/usb/usb_mem.c @@ -1,5 +1,5 @@ -/* $OpenBSD: usb_mem.c,v 1.2 1999/08/16 22:08:49 fgsch Exp $ */ -/* $NetBSD: usb_mem.c,v 1.7 1999/08/02 19:49:50 augustss Exp $ */ +/* $OpenBSD: usb_mem.c,v 1.3 1999/08/19 08:18:39 fgsch Exp $ */ +/* $NetBSD: usb_mem.c,v 1.9 1999/08/16 20:19:55 augustss Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -107,8 +107,8 @@ usb_block_allocmem(tag, size, align, dmap) #ifdef DIAGNOSTIC if (!curproc) { - printf("usb_block_allocmem: in interrupt context\n"); - return (USBD_NOMEM); + printf("usb_block_allocmem: in interrupt context, size=%u\n", + size); } #endif @@ -119,13 +119,20 @@ usb_block_allocmem(tag, size, align, dmap) LIST_REMOVE(p, next); splx(s); *dmap = p; - DPRINTFN(6, ("usb_block_allocmem: free list size=%d\n", - p->size)); + DPRINTFN(6,("usb_block_allocmem: free list size=%d\n", + p->size)); return (USBD_NORMAL_COMPLETION); } } splx(s); +#ifdef DIAGNOSTIC + if (!curproc) { + printf("usb_block_allocmem: in interrupt context, failed\n"); + return (USBD_NOMEM); + } +#endif + DPRINTFN(6, ("usb_block_allocmem: no free\n")); p = malloc(sizeof *p, M_USB, M_NOWAIT); if (p == 0) diff --git a/sys/dev/usb/usb_port.h b/sys/dev/usb/usb_port.h index 8b77e56d11d..98d7f0fb02d 100644 --- a/sys/dev/usb/usb_port.h +++ b/sys/dev/usb/usb_port.h @@ -1,5 +1,5 @@ -/* $OpenBSD: usb_port.h,v 1.3 1999/08/16 22:08:49 fgsch Exp $ */ -/* $NetBSD: usb_port.h,v 1.7 1999/06/30 06:44:23 augustss Exp $ */ +/* $OpenBSD: usb_port.h,v 1.4 1999/08/19 08:18:39 fgsch Exp $ */ +/* $NetBSD: usb_port.h,v 1.9 1999/08/17 16:06:21 augustss Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -123,6 +123,8 @@ __CONCAT(dname,_attach)(parent, self, aux) \ */ #define memcpy(d, s, l) bcopy((s),(d),(l)) #define memset(d, v, l) bzero((d),(l)) +#define bswap32(x) swap32(x) +#define powerhook_establish(h, sc) /* nothing */ #define usbpoll usbselect #define uhidpoll uhidselect diff --git a/sys/dev/usb/usb_subr.c b/sys/dev/usb/usb_subr.c index 83cc9bc3c6a..a26022ee9ad 100644 --- a/sys/dev/usb/usb_subr.c +++ b/sys/dev/usb/usb_subr.c @@ -1,5 +1,5 @@ -/* $OpenBSD: usb_subr.c,v 1.2 1999/08/16 22:08:49 fgsch Exp $ */ -/* $NetBSD: usb_subr.c,v 1.34 1999/06/30 06:44:23 augustss Exp $ */ +/* $OpenBSD: usb_subr.c,v 1.3 1999/08/19 08:18:39 fgsch Exp $ */ +/* $NetBSD: usb_subr.c,v 1.38 1999/08/17 20:59:04 augustss Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -76,11 +76,10 @@ extern int usbdebug; static usbd_status usbd_set_config __P((usbd_device_handle, int)); char *usbd_get_string __P((usbd_device_handle, int, char *)); int usbd_getnewaddr __P((usbd_bus_handle bus)); -#if defined(__NetBSD__) int usbd_print __P((void *aux, const char *pnp)); +#if defined(__NetBSD__) int usbd_submatch __P((bdevice *, struct cfdata *cf, void *)); #elif defined(__OpenBSD__) -int usbd_print __P((void *aux, const char *pnp)); int usbd_submatch __P((bdevice *, void *, void *)); #endif void usbd_free_iface_data __P((usbd_device_handle dev, int ifcno)); @@ -463,7 +462,6 @@ usbd_fill_iface_data(dev, ifaceidx, altidx) found: ifc->endpoints[endpt].edesc = ed; ifc->endpoints[endpt].refcnt = 0; - ifc->endpoints[endpt].toggle = 0; p += ed->bLength; } #undef ed @@ -677,6 +675,9 @@ usbd_setup_pipe(dev, iface, ep, pipe) free(p, M_USB); return (r); } + /* Clear any stall and make sure DATA0 toggle will be used next. */ + if (UE_GET_ADDR(ep->edesc->bEndpointAddress) != USB_CONTROL_ENDPOINT) + usbd_clear_endpoint_stall(p); *pipe = p; return (USBD_NORMAL_COMPLETION); } @@ -1116,14 +1117,9 @@ usb_start_next(pipe) printf("usb_start_next: no start method\n"); return; } - if (SIMPLEQ_FIRST(&pipe->queue) == 0) { - printf("usb_start_next: empty\n"); - return; - } #endif - /* First remove remove old */ - SIMPLEQ_REMOVE_HEAD(&pipe->queue, SIMPLEQ_FIRST(&pipe->queue), next); + /* Get next request in queue. */ reqh = SIMPLEQ_FIRST(&pipe->queue); DPRINTFN(5, ("usb_start_next: start reqh=%p\n", reqh)); if (!reqh) diff --git a/sys/dev/usb/usbcdc.h b/sys/dev/usb/usbcdc.h new file mode 100644 index 00000000000..993d6f726a5 --- /dev/null +++ b/sys/dev/usb/usbcdc.h @@ -0,0 +1,149 @@ +/* $OpenBSD: usbcdc.h,v 1.1 1999/08/19 08:18:39 fgsch Exp $ */ +/* $NetBSD: usbcdc.h,v 1.4 1999/08/16 20:20:19 augustss Exp $ */ + +/* + * Copyright (c) 1998 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Lennart Augustsson (augustss@carlstedt.se) at + * Carlstedt Research & Technology. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _USBCDC_H_ +#define _USBCDC_H_ + +#define UDESCSUB_CDC_HEADER 0 +#define UDESCSUB_CDC_CM 1 /* Call Management */ +#define UDESCSUB_CDC_ACM 2 /* Abstract Control Model */ +#define UDESCSUB_CDC_DLM 3 /* Direct Line Management */ +#define UDESCSUB_CDC_TRF 4 /* Telephone Ringer */ +#define UDESCSUB_CDC_TCLSR 5 /* Telephone Call ... */ +#define UDESCSUB_CDC_UNION 6 +#define UDESCSUB_CDC_CS 7 /* Country Selection */ +#define UDESCSUB_CDC_TOM 8 /* Telephone Operational Modes */ +#define UDESCSUB_CDC_USBT 9 /* USB Terminal */ + +typedef struct { + uByte bLength; + uByte bDescriptorType; + uByte bDescriptorSubtype; + uWord bcdCDC; +} usb_cdc_header_descriptor_t; + +typedef struct { + uByte bLength; + uByte bDescriptorType; + uByte bDescriptorSubtype; + uByte bmCapabilities; +#define USB_CDC_CM_DOES_CM 0x01 +#define USB_CDC_CM_OVER_DATA 0x02 + uByte bDataInterface; +} usb_cdc_cm_descriptor_t; + +typedef struct { + uByte bLength; + uByte bDescriptorType; + uByte bDescriptorSubtype; + uByte bmCapabilities; +#define USB_CDC_ACM_HAS_FEATURE 0x01 +#define USB_CDC_ACM_HAS_LINE 0x02 +#define USB_CDC_ACM_HAS_BREAK 0x04 +#define USB_CDC_ACM_HAS_NETWORK_CONN 0x08 +} usb_cdc_acm_descriptor_t; + +typedef struct { + uByte bLength; + uByte bDescriptorType; + uByte bDescriptorSubtype; + uByte bMasterInterface; + uByte bSlaveInterface[1]; +} usb_cdc_union_descriptor_t; + +#define UCDC_SEND_ENCAPSULATED_COMMAND 0x00 +#define UCDC_GET_ENCAPSULATED_RESPONSE 0x01 +#define UCDC_SET_COMM_FEATURE 0x02 +#define UCDC_GET_COMM_FEATURE 0x03 +#define UCDC_ABSTRACT_STATE 0x01 +#define UCDC_COUNTRY_SETTING 0x02 +#define UCDC_CLEAR_COMM_FEATURE 0x04 +#define UCDC_SET_LINE_CODING 0x20 +#define UCDC_GET_LINE_CODING 0x21 +#define UCDC_SET_CONTROL_LINE_STATE 0x22 +#define UCDC_LINE_DTR 0x0001 +#define UCDC_LINE_RTS 0x0002 +#define UCDC_SEND_BREAK 0x23 +#define UCDC_BREAK_ON 0xffff +#define UCDC_BREAK_OFF 0x0000 + +typedef struct { + uWord wState; +#define UCDC_IDLE_SETTING 0x0001 +#define UCDC_DATA_MULTIPLEXED 0x0002 +} usb_cdc_abstract_state_t; +#define UCDC_ABSTRACT_STATE_LENGTH 2 + +typedef struct { + uDWord dwDTERate; + uByte bCharFormat; +#define UCDC_STOP_BIT_1 0 +#define UCDC_STOP_BIT_1_5 1 +#define UCDC_STOP_BIT_2 2 + uByte bParityType; +#define UCDC_PARITY_NONE 0 +#define UCDC_PARITY_ODD 1 +#define UCDC_PARITY_EVEN 2 +#define UCDC_PARITY_MARK 3 +#define UCDC_PARITY_SPACE 4 + uByte bDataBits; +} usb_cdc_line_state_t; +#define UCDC_LINE_STATE_LENGTH 7 + +typedef struct { + uByte bmRequestType; +#define UCDC_NOTIFICATION 0xa1 + uByte bNotification; +#define UCDC_N_NETWORK_CONNECTION 0x00 +#define UCDC_N_RESPONSE_AVAILABLE 0x01 +#define UCDC_N_AUX_JACK_HOOK_STATE 0x08 +#define UCDC_N_RING_DETECT 0x09 +#define UCDC_N_SERIAL_STATE 0x20 +#define UCDC_N_CALL_STATE_CHANGED 0x28 +#define UCDC_N_LINE_STATE_CHANGED 0x29 +#define UCDC_N_CONNECTION_SPEED_CHANGE 0x2a + uWord wValue; + uWord wIndex; + uWord wLength; + uByte data[16]; +} usb_cdc_notification_t; +#define UCDC_NOTIFICATION_LENGTH 8 + +#endif /* _USBCDC_H_ */ diff --git a/sys/dev/usb/usbdi.c b/sys/dev/usb/usbdi.c index bdaeaca129a..48708c75cd6 100644 --- a/sys/dev/usb/usbdi.c +++ b/sys/dev/usb/usbdi.c @@ -1,5 +1,5 @@ -/* $OpenBSD: usbdi.c,v 1.2 1999/08/16 22:08:49 fgsch Exp $ */ -/* $NetBSD: usbdi.c,v 1.26 1999/07/06 07:12:03 augustss Exp $ */ +/* $OpenBSD: usbdi.c,v 1.3 1999/08/19 08:18:39 fgsch Exp $ */ +/* $NetBSD: usbdi.c,v 1.30 1999/08/17 20:59:04 augustss Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -85,6 +85,24 @@ static SIMPLEQ_HEAD(, usbd_request) usbd_free_requests; extern struct cdevsw usb_cdevsw; #endif +#ifdef USB_DEBUG +void usbd_dump_queue __P((usbd_pipe_handle)); + +void +usbd_dump_queue(pipe) + usbd_pipe_handle pipe; +{ + usbd_request_handle reqh; + + printf("usbd_dump_queue: pipe=%p\n", pipe); + for (reqh = SIMPLEQ_FIRST(&pipe->queue); + reqh; + reqh = SIMPLEQ_NEXT(reqh, next)) { + printf(" reqh=%p\n", reqh); + } +} +#endif + usbd_status usbd_open_pipe(iface, address, flags, pipe) usbd_interface_handle iface; @@ -225,7 +243,11 @@ usbd_do_transfer(reqh) { usbd_pipe_handle pipe = reqh->pipe; - DPRINTFN(10,("usbd_do_transfer: reqh=%p\n", reqh)); + DPRINTFN(5,("usbd_do_transfer: reqh=%p\n", reqh)); +#ifdef USB_DEBUG + if (usbdebug > 5) + usbd_dump_queue(pipe); +#endif reqh->done = 0; return (pipe->methods->transfer(reqh)); } @@ -387,6 +409,7 @@ usbd_clear_endpoint_stall(pipe) usbd_status r; DPRINTFN(8, ("usbd_clear_endpoint_stall\n")); + pipe->methods->cleartoggle(pipe); req.bmRequestType = UT_WRITE_ENDPOINT; req.bRequest = UR_CLEAR_FEATURE; USETW(req.wValue, UF_ENDPOINT_HALT); @@ -411,6 +434,7 @@ usbd_clear_endpoint_stall_async(pipe) usb_device_request_t req; usbd_status r; + pipe->methods->cleartoggle(pipe); req.bmRequestType = UT_WRITE_ENDPOINT; req.bRequest = UR_CLEAR_FEATURE; USETW(req.wValue, UF_ENDPOINT_HALT); @@ -543,25 +567,17 @@ usbd_ar_pipe(pipe) { usbd_request_handle reqh; -#if 0 - for (;;) { - reqh = SIMPLEQ_FIRST(&pipe->queue); - if (reqh == 0) - break; - SIMPLEQ_REMOVE_HEAD(&pipe->queue, reqh, next); - reqh->status = USBD_CANCELLED; - if (reqh->callback) - reqh->callback(reqh, reqh->priv, reqh->status); - } -#else DPRINTFN(2,("usbd_ar_pipe: pipe=%p\n", pipe)); +#ifdef USB_DEBUG + if (usbdebug > 5) + usbd_dump_queue(pipe); +#endif while ((reqh = SIMPLEQ_FIRST(&pipe->queue))) { - DPRINTFN(2,("usbd_ar_pipe: reqh=%p (methods=%p)\n", - pipe, pipe->methods)); + DPRINTFN(2,("usbd_ar_pipe: pipe=%p reqh=%p (methods=%p)\n", + pipe, reqh, pipe->methods)); + /* Make the HC abort it (and invoke the callback). */ pipe->methods->abort(reqh); - SIMPLEQ_REMOVE_HEAD(&pipe->queue, reqh, next); } -#endif return (USBD_NORMAL_COMPLETION); } diff --git a/sys/dev/usb/usbdivar.h b/sys/dev/usb/usbdivar.h index c8b70855038..2ccaa846f54 100644 --- a/sys/dev/usb/usbdivar.h +++ b/sys/dev/usb/usbdivar.h @@ -1,5 +1,5 @@ -/* $OpenBSD: usbdivar.h,v 1.1 1999/08/13 05:28:05 fgsch Exp $ */ -/* $NetBSD: usbdivar.h,v 1.22 1999/06/30 06:44:23 augustss Exp $ */ +/* $OpenBSD: usbdivar.h,v 1.2 1999/08/19 08:18:39 fgsch Exp $ */ +/* $NetBSD: usbdivar.h,v 1.24 1999/08/17 20:59:04 augustss Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -44,7 +44,6 @@ struct usbd_pipe; struct usbd_endpoint { usb_endpoint_descriptor_t *edesc; int refcnt; - int toggle; /* XXX */ }; typedef void (*usbd_xfercb)__P((usbd_request_handle req)); @@ -53,7 +52,8 @@ struct usbd_methods { usbd_status (*transfer)__P((usbd_request_handle reqh)); usbd_status (*start)__P((usbd_request_handle reqh)); void (*abort)__P((usbd_request_handle reqh)); - void (*close)__P((usbd_pipe_handle pipe)); + void (*close)__P((usbd_pipe_handle pipe)); + void (*cleartoggle)__P((usbd_pipe_handle pipe)); usbd_status (*isobuf)__P((usbd_pipe_handle pipe, u_int32_t bufsize,u_int32_t nbuf)); }; |