diff options
author | Aaron Campbell <aaron@cvs.openbsd.org> | 2000-03-30 16:19:34 +0000 |
---|---|---|
committer | Aaron Campbell <aaron@cvs.openbsd.org> | 2000-03-30 16:19:34 +0000 |
commit | a1987e2c602829ad767a70ace887e30293688fab (patch) | |
tree | aff05488573e83694e0a53fb218b11b8dc0cb029 /sys/dev/usb | |
parent | 2995dd2fe3905a085c7ea17930a26d47044d9c2f (diff) |
Sync with NetBSD. USB Ethernet drivers should work now.
Diffstat (limited to 'sys/dev/usb')
-rw-r--r-- | sys/dev/usb/hid.c | 8 | ||||
-rw-r--r-- | sys/dev/usb/if_aue.c | 172 | ||||
-rw-r--r-- | sys/dev/usb/if_cue.c | 145 | ||||
-rw-r--r-- | sys/dev/usb/if_kue.c | 122 | ||||
-rw-r--r-- | sys/dev/usb/kue_fw.h | 10 | ||||
-rw-r--r-- | sys/dev/usb/ohci.c | 727 | ||||
-rw-r--r-- | sys/dev/usb/ohcireg.h | 8 | ||||
-rw-r--r-- | sys/dev/usb/ohcivar.h | 22 | ||||
-rw-r--r-- | sys/dev/usb/uaudio.c | 114 | ||||
-rw-r--r-- | sys/dev/usb/ugen.c | 38 | ||||
-rw-r--r-- | sys/dev/usb/uhci.c | 521 | ||||
-rw-r--r-- | sys/dev/usb/uhid.c | 14 | ||||
-rw-r--r-- | sys/dev/usb/uhub.c | 18 | ||||
-rw-r--r-- | sys/dev/usb/ulpt.c | 14 | ||||
-rw-r--r-- | sys/dev/usb/usb.c | 40 | ||||
-rw-r--r-- | sys/dev/usb/usb_mem.c | 18 | ||||
-rw-r--r-- | sys/dev/usb/usb_port.h | 62 | ||||
-rw-r--r-- | sys/dev/usb/usb_quirks.c | 6 | ||||
-rw-r--r-- | sys/dev/usb/usb_subr.c | 31 | ||||
-rw-r--r-- | sys/dev/usb/usbdi.c | 26 | ||||
-rw-r--r-- | sys/dev/usb/usbdi_util.c | 8 | ||||
-rw-r--r-- | sys/dev/usb/usbdivar.h | 10 |
22 files changed, 1123 insertions, 1011 deletions
diff --git a/sys/dev/usb/hid.c b/sys/dev/usb/hid.c index 207ead12211..123cccc44e4 100644 --- a/sys/dev/usb/hid.c +++ b/sys/dev/usb/hid.c @@ -1,5 +1,5 @@ -/* $OpenBSD: hid.c,v 1.5 2000/03/28 19:37:46 aaron Exp $ */ -/* $NetBSD: hid.c,v 1.12 2000/03/17 18:16:18 augustss Exp $ */ +/* $OpenBSD: hid.c,v 1.6 2000/03/30 16:19:32 aaron Exp $ */ +/* $NetBSD: hid.c,v 1.13 2000/03/27 12:33:53 augustss Exp $ */ /* $FreeBSD: src/sys/dev/usb/hid.c,v 1.11 1999/11/17 22:33:39 n_hibma Exp $ */ /* @@ -60,7 +60,7 @@ extern int usbdebug; #define DPRINTFN(n,x) #endif -static void hid_clear_local __P((struct hid_item *)); +Static void hid_clear_local __P((struct hid_item *)); #define MAXUSAGE 100 struct hid_data { @@ -76,7 +76,7 @@ struct hid_data { int kindset; }; -static void +Static void hid_clear_local(c) struct hid_item *c; { diff --git a/sys/dev/usb/if_aue.c b/sys/dev/usb/if_aue.c index 4ff18e9ec3c..3bec16926b8 100644 --- a/sys/dev/usb/if_aue.c +++ b/sys/dev/usb/if_aue.c @@ -1,5 +1,5 @@ -/* $OpenBSD: if_aue.c,v 1.1 2000/03/28 19:37:47 aaron Exp $ */ -/* $NetBSD: if_aue.c,v 1.33 2000/03/24 22:03:28 augustss Exp $ */ +/* $OpenBSD: if_aue.c,v 1.2 2000/03/30 16:19:32 aaron Exp $ */ +/* $NetBSD: if_aue.c,v 1.36 2000/03/30 00:18:17 augustss Exp $ */ /* * Copyright (c) 1997, 1998, 1999, 2000 * Bill Paul <wpaul@ee.columbia.edu>. All rights reserved. @@ -84,7 +84,7 @@ #include "rnd.h" #elif defined(__OpenBSD__) #include "bpfilter.h" -#endif +#endif /* defined(__OpenBSD__) */ #include <sys/param.h> #include <sys/systm.h> @@ -179,7 +179,7 @@ int auedebug = 0; /* * Various supported device vendors/products. */ -static struct aue_type aue_devs[] = { +Static struct aue_type aue_devs[] = { { USB_VENDOR_BILLIONTON, USB_PRODUCT_BILLIONTON_USB100 }, { USB_VENDOR_MELCO, USB_PRODUCT_MELCO_LUATX }, { USB_VENDOR_LINKSYS, USB_PRODUCT_LINKSYS_USB100TX }, @@ -194,48 +194,48 @@ static struct aue_type aue_devs[] = { USB_DECLARE_DRIVER(aue); -static int aue_tx_list_init __P((struct aue_softc *)); -static int aue_rx_list_init __P((struct aue_softc *)); -static int aue_newbuf __P((struct aue_softc *, struct aue_chain *, +Static int aue_tx_list_init __P((struct aue_softc *)); +Static int aue_rx_list_init __P((struct aue_softc *)); +Static int aue_newbuf __P((struct aue_softc *, struct aue_chain *, struct mbuf *)); -static int aue_send __P((struct aue_softc *, struct mbuf *, int)); -static void aue_intr __P((usbd_xfer_handle, +Static int aue_send __P((struct aue_softc *, struct mbuf *, int)); +Static void aue_intr __P((usbd_xfer_handle, usbd_private_handle, usbd_status)); -static void aue_rxeof __P((usbd_xfer_handle, +Static void aue_rxeof __P((usbd_xfer_handle, usbd_private_handle, usbd_status)); -static void aue_txeof __P((usbd_xfer_handle, +Static void aue_txeof __P((usbd_xfer_handle, usbd_private_handle, usbd_status)); -static void aue_tick __P((void *)); -static void aue_start __P((struct ifnet *)); -static int aue_ioctl __P((struct ifnet *, u_long, caddr_t)); -static void aue_init __P((void *)); -static void aue_stop __P((struct aue_softc *)); -static void aue_watchdog __P((struct ifnet *)); +Static void aue_tick __P((void *)); +Static void aue_start __P((struct ifnet *)); +Static int aue_ioctl __P((struct ifnet *, u_long, caddr_t)); +Static void aue_init __P((void *)); +Static void aue_stop __P((struct aue_softc *)); +Static void aue_watchdog __P((struct ifnet *)); #ifdef __FreeBSD__ -static void aue_shutdown __P((device_ptr_t)); +Static void aue_shutdown __P((device_ptr_t)); #endif -static int aue_openpipes __P((struct aue_softc *)); -static int aue_ifmedia_upd __P((struct ifnet *)); -static void aue_ifmedia_sts __P((struct ifnet *, struct ifmediareq *)); +Static int aue_openpipes __P((struct aue_softc *)); +Static int aue_ifmedia_upd __P((struct ifnet *)); +Static void aue_ifmedia_sts __P((struct ifnet *, struct ifmediareq *)); -static int aue_eeprom_getword __P((struct aue_softc *, int)); -static void aue_read_mac __P((struct aue_softc *, u_char *)); -static int aue_miibus_readreg __P((device_ptr_t, int, int)); +Static int aue_eeprom_getword __P((struct aue_softc *, int)); +Static void aue_read_mac __P((struct aue_softc *, u_char *)); +Static int aue_miibus_readreg __P((device_ptr_t, int, int)); #if defined(__FreeBSD__) -static int aue_miibus_writereg __P((device_ptr_t, int, int, int)); +Static int aue_miibus_writereg __P((device_ptr_t, int, int, int)); #elif defined(__NetBSD__) || defined(__OpenBSD__) -static void aue_miibus_writereg __P((device_ptr_t, int, int, int)); +Static void aue_miibus_writereg __P((device_ptr_t, int, int, int)); #endif /* defined(__NetBSD__) || defined(__OpenBSD__) */ -static void aue_miibus_statchg __P((device_ptr_t)); +Static void aue_miibus_statchg __P((device_ptr_t)); -static void aue_setmulti __P((struct aue_softc *)); -static u_int32_t aue_crc __P((caddr_t)); -static void aue_reset __P((struct aue_softc *)); +Static void aue_setmulti __P((struct aue_softc *)); +Static u_int32_t aue_crc __P((caddr_t)); +Static void aue_reset __P((struct aue_softc *)); -static int aue_csr_read_1 __P((struct aue_softc *, int)); -static int aue_csr_write_1 __P((struct aue_softc *, int, int)); -static int aue_csr_read_2 __P((struct aue_softc *, int)); -static int aue_csr_write_2 __P((struct aue_softc *, int, int)); +Static int aue_csr_read_1 __P((struct aue_softc *, int)); +Static int aue_csr_write_1 __P((struct aue_softc *, int, int)); +Static int aue_csr_read_2 __P((struct aue_softc *, int)); +Static int aue_csr_write_2 __P((struct aue_softc *, int, int)); #if defined(__FreeBSD__) #if !defined(lint) @@ -243,11 +243,11 @@ static const char rcsid[] = "$FreeBSD: src/sys/dev/usb/if_aue.c,v 1.11 2000/01/14 01:36:14 wpaul Exp $"; #endif -static void aue_rxstart __P((struct ifnet *)); +Static void aue_rxstart __P((struct ifnet *)); -static struct usb_qdat aue_qdat; +Static struct usb_qdat aue_qdat; -static device_method_t aue_methods[] = { +Static device_method_t aue_methods[] = { /* Device interface */ DEVMETHOD(device_probe, aue_match), DEVMETHOD(device_attach, aue_attach), @@ -266,13 +266,13 @@ static device_method_t aue_methods[] = { { 0, 0 } }; -static driver_t aue_driver = { +Static driver_t aue_driver = { "aue", aue_methods, sizeof(struct aue_softc) }; -static devclass_t aue_devclass; +Static devclass_t aue_devclass; DRIVER_MODULE(if_aue, uhub, aue_driver, aue_devclass, usbd_driver_load, 0); DRIVER_MODULE(miibus, aue, miibus_driver, miibus_devclass, 0, 0); @@ -288,7 +288,7 @@ DRIVER_MODULE(miibus, aue, miibus_driver, miibus_devclass, 0, 0); #define AUE_CLRBIT(sc, reg, x) \ aue_csr_write_1(sc, reg, aue_csr_read_1(sc, reg) & ~(x)) -static int +Static int aue_csr_read_1(sc, reg) struct aue_softc *sc; int reg; @@ -320,7 +320,7 @@ aue_csr_read_1(sc, reg) return (val); } -static int +Static int aue_csr_read_2(sc, reg) struct aue_softc *sc; int reg; @@ -352,7 +352,7 @@ aue_csr_read_2(sc, reg) return (UGETW(val)); } -static int +Static int aue_csr_write_1(sc, reg, aval) struct aue_softc *sc; int reg, aval; @@ -385,7 +385,7 @@ aue_csr_write_1(sc, reg, aval) return (0); } -static int +Static int aue_csr_write_2(sc, reg, aval) struct aue_softc *sc; int reg, aval; @@ -421,7 +421,7 @@ aue_csr_write_2(sc, reg, aval) /* * Read a word of data stored in the EEPROM at address 'addr.' */ -static int +Static int aue_eeprom_getword(sc, addr) struct aue_softc *sc; int addr; @@ -447,7 +447,7 @@ aue_eeprom_getword(sc, addr) /* * Read the MAC from the EEPROM. It's at offset 0. */ -static void +Static void aue_read_mac(sc, dest) struct aue_softc *sc; u_char *dest; @@ -465,7 +465,7 @@ aue_read_mac(sc, dest) } } -static int +Static int aue_miibus_readreg(dev, phy, reg) device_ptr_t dev; int phy, reg; @@ -512,9 +512,9 @@ aue_miibus_readreg(dev, phy, reg) } #if defined(__FreeBSD__) -static int +Static int #elif defined(__NetBSD__) || defined(__OpenBSD__) -static void +Static void #endif /* defined(__NetBSD__) || defined(__OpenBSD__) */ aue_miibus_writereg(dev, phy, reg, data) device_ptr_t dev; @@ -555,7 +555,7 @@ aue_miibus_writereg(dev, phy, reg, data) #endif } -static void +Static void aue_miibus_statchg(dev) device_ptr_t dev; { @@ -597,7 +597,7 @@ aue_miibus_statchg(dev) #define AUE_POLY 0xEDB88320 #define AUE_BITS 6 -static u_int32_t +Static u_int32_t aue_crc(addr) caddr_t addr; { @@ -614,7 +614,7 @@ aue_crc(addr) return (crc & ((1 << AUE_BITS) - 1)); } -static void +Static void aue_setmulti(sc) struct aue_softc *sc; { @@ -673,7 +673,7 @@ aue_setmulti(sc) #endif /* defined(__NetBSD__) || defined(__OpenBSD__) */ } -static void +Static void aue_reset(sc) struct aue_softc *sc; { @@ -828,13 +828,13 @@ USB_ATTACH(aue) /* * A Pegasus chip was detected. Inform the world. */ + ifp = GET_IFP(sc); #if defined(__FreeBSD__) printf("%s: Ethernet address: %6D\n", USBDEVNAME(sc->aue_dev), eaddr, ":"); bcopy(eaddr, (char *)&sc->arpcom.ac_enaddr, ETHER_ADDR_LEN); - ifp = &sc->arpcom.ac_if; ifp->if_softc = sc; ifp->if_unit = sc->aue_unit; ifp->if_name = "aue"; @@ -885,13 +885,15 @@ USB_ATTACH(aue) ether_sprintf(eaddr)); /* Initialize interface info.*/ - ifp = GET_IFP(sc); ifp->if_softc = sc; ifp->if_mtu = ETHERMTU; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = aue_ioctl; ifp->if_start = aue_start; ifp->if_watchdog = aue_watchdog; +#if defined(__OpenBSD__) + ifp->if_snd.ifq_maxlen = IFQ_MAXLEN; +#endif strncpy(ifp->if_xname, USBDEVNAME(sc->aue_dev), IFNAMSIZ); /* Initialize MII/media info. */ @@ -901,11 +903,7 @@ USB_ATTACH(aue) mii->mii_writereg = aue_miibus_writereg; mii->mii_statchg = aue_miibus_statchg; ifmedia_init(&mii->mii_media, 0, aue_ifmedia_upd, aue_ifmedia_sts); -#if defined(__NetBSD__) mii_attach(self, mii, 0xffffffff, MII_PHY_ANY, MII_OFFSET_ANY, 0); -#else - mii_phy_probe(self, mii, 0xffffffff); -#endif if (LIST_FIRST(&mii->mii_phys) == NULL) { ifmedia_add(&mii->mii_media, IFM_ETHER | IFM_NONE, 0, NULL); ifmedia_set(&mii->mii_media, IFM_ETHER | IFM_NONE); @@ -914,11 +912,7 @@ USB_ATTACH(aue) /* Attach the interface. */ if_attach(ifp); -#if defined (__NetBSD__) - ether_ifattach(ifp, eaddr); -#else - ether_ifattach(ifp); -#endif + Ether_ifattach(ifp, eaddr); #if NBPFILTER > 0 bpfattach(&ifp->if_bpf, ifp, DLT_EN10MB, @@ -1010,9 +1004,7 @@ aue_activate(self, act) break; case DVACT_DEACTIVATE: -#if defined(__NetBSD__) if_deactivate(&sc->aue_ec.ec_if); -#endif sc->aue_dying = 1; break; } @@ -1023,7 +1015,7 @@ aue_activate(self, act) /* * Initialize an RX descriptor and attach an MBUF cluster. */ -static int +Static int aue_newbuf(sc, c, m) struct aue_softc *sc; struct aue_chain *c; @@ -1061,7 +1053,7 @@ aue_newbuf(sc, c, m) return (0); } -static int +Static int aue_rx_list_init(sc) struct aue_softc *sc; { @@ -1091,7 +1083,7 @@ aue_rx_list_init(sc) return (0); } -static int +Static int aue_tx_list_init(sc) struct aue_softc *sc; { @@ -1120,7 +1112,7 @@ aue_tx_list_init(sc) return (0); } -static void +Static void aue_intr(xfer, priv, status) usbd_xfer_handle xfer; usbd_private_handle priv; @@ -1157,7 +1149,7 @@ aue_intr(xfer, priv, status) } #if defined(__FreeBSD__) -static void +Static void aue_rxstart(ifp) struct ifnet *ifp; { @@ -1193,7 +1185,7 @@ aue_rxstart(ifp) * for three days, I'm willing to settle. I'd rather have reliable * receive performance that fast but spotty performance. */ -static void +Static void aue_rxeof(xfer, priv, status) usbd_xfer_handle xfer; usbd_private_handle priv; @@ -1207,7 +1199,6 @@ aue_rxeof(xfer, priv, status) struct aue_rxpkt r; #if defined(__NetBSD__) || defined(__OpenBSD__) int s; - struct ether_header *eh; #endif /* defined(__NetBSD__) || defined(__OpenBSD__) */ DPRINTFN(10,("%s: %s: enter\n", USBDEVNAME(sc->aue_dev),__FUNCTION__)); @@ -1275,8 +1266,6 @@ aue_rxeof(xfer, priv, status) goto done1; } - eh = mtod(m, struct ether_header *); - #if NBPFILTER > 0 /* * Handle BPF listeners. Let the BPF user see the packet, but @@ -1285,8 +1274,9 @@ aue_rxeof(xfer, priv, status) * address or the interface is in promiscuous mode. */ if (ifp->if_bpf) { - BPF_MTAP(ifp, m); #if defined(__NetBSD__) + struct ether_header *eh = mtod(m, struct ether_header *); + BPF_MTAP(ifp, m); if ((ifp->if_flags & IFF_PROMISC) && memcmp(eh->ether_dhost, LLADDR(ifp->if_sadl), ETHER_ADDR_LEN) && @@ -1294,17 +1284,15 @@ aue_rxeof(xfer, priv, status) m_freem(m); goto done1; } +#else + BPF_MTAP(ifp, m); #endif } #endif DPRINTFN(10,("%s: %s: deliver %d\n", USBDEVNAME(sc->aue_dev), __FUNCTION__, m->m_len)); -#if defined(__NetBSD__) - (*ifp->if_input)(ifp, m); -#else - ether_input(ifp, eh, m); -#endif + IF_INPUT(ifp, m); done1: splx(s); #endif /* defined(__NetBSD__) || defined(__OpenBSD__) */ @@ -1327,7 +1315,7 @@ aue_rxeof(xfer, priv, status) * the list buffers. */ -static void +Static void aue_txeof(xfer, priv, status) usbd_xfer_handle xfer; usbd_private_handle priv; @@ -1380,7 +1368,7 @@ aue_txeof(xfer, priv, status) splx(s); } -static void +Static void aue_tick(xsc) void *xsc; { @@ -1422,7 +1410,7 @@ aue_tick(xsc) splx(s); } -static int +Static int aue_send(sc, m, idx) struct aue_softc *sc; struct mbuf *m; @@ -1471,7 +1459,7 @@ aue_send(sc, m, idx) return (0); } -static void +Static void aue_start(ifp) struct ifnet *ifp; { @@ -1517,7 +1505,7 @@ aue_start(ifp) ifp->if_timer = 5; } -static void +Static void aue_init(xsc) void *xsc; { @@ -1595,7 +1583,7 @@ aue_init(xsc) usb_callout(sc->aue_stat_ch, hz, aue_tick, sc); } -static int +Static int aue_openpipes(sc) struct aue_softc *sc; { @@ -1646,7 +1634,7 @@ aue_openpipes(sc) /* * Set media options. */ -static int +Static int aue_ifmedia_upd(ifp) struct ifnet *ifp; { @@ -1673,7 +1661,7 @@ aue_ifmedia_upd(ifp) /* * Report current media status. */ -static void +Static void aue_ifmedia_sts(ifp, ifmr) struct ifnet *ifp; struct ifmediareq *ifmr; @@ -1688,7 +1676,7 @@ aue_ifmedia_sts(ifp, ifmr) ifmr->ifm_status = mii->mii_media_status; } -static int +Static int aue_ioctl(ifp, command, data) struct ifnet *ifp; u_long command; @@ -1794,7 +1782,7 @@ aue_ioctl(ifp, command, data) return (error); } -static void +Static void aue_watchdog(ifp) struct ifnet *ifp; { @@ -1824,7 +1812,7 @@ aue_watchdog(ifp) * Stop the adapter and free any mbufs allocated to the * RX and TX lists. */ -static void +Static void aue_stop(sc) struct aue_softc *sc; { @@ -1919,7 +1907,7 @@ aue_stop(sc) * Stop all chip I/O so that the kernel's probe routines don't * get confused by errant DMAs when rebooting. */ -static void +Static void aue_shutdown(dev) device_ptr_t dev; { diff --git a/sys/dev/usb/if_cue.c b/sys/dev/usb/if_cue.c index 2483a266f70..8a425317383 100644 --- a/sys/dev/usb/if_cue.c +++ b/sys/dev/usb/if_cue.c @@ -1,5 +1,5 @@ -/* $OpenBSD: if_cue.c,v 1.1 2000/03/28 19:37:47 aaron Exp $ */ -/* $NetBSD: if_cue.c,v 1.16 2000/03/24 22:03:29 augustss Exp $ */ +/* $OpenBSD: if_cue.c,v 1.2 2000/03/30 16:19:32 aaron Exp $ */ +/* $NetBSD: if_cue.c,v 1.20 2000/03/30 08:53:30 augustss Exp $ */ /* * Copyright (c) 1997, 1998, 1999, 2000 * Bill Paul <wpaul@ee.columbia.edu>. All rights reserved. @@ -67,7 +67,7 @@ #include "rnd.h" #elif defined(__OpenBSD__) #include "bpfilter.h" -#endif +#endif /* defined(__OpenBSD__) */ #include <sys/param.h> #include <sys/systm.h> @@ -159,7 +159,7 @@ int cuedebug = 0; /* * Various supported device vendors/products. */ -static struct cue_type cue_devs[] = { +Static struct cue_type cue_devs[] = { { USB_VENDOR_CATC, USB_PRODUCT_CATC_NETMATE }, { USB_VENDOR_CATC, USB_PRODUCT_CATC_NETMATE2 }, /* Belkin F5U111 adapter covered by NETMATE entry */ @@ -168,38 +168,36 @@ static struct cue_type cue_devs[] = { USB_DECLARE_DRIVER(cue); -#define static - -static int cue_open_pipes __P((struct cue_softc *)); -static int cue_tx_list_init __P((struct cue_softc *)); -static int cue_rx_list_init __P((struct cue_softc *)); -static int cue_newbuf __P((struct cue_softc *, struct cue_chain *, +Static int cue_open_pipes __P((struct cue_softc *)); +Static int cue_tx_list_init __P((struct cue_softc *)); +Static int cue_rx_list_init __P((struct cue_softc *)); +Static int cue_newbuf __P((struct cue_softc *, struct cue_chain *, struct mbuf *)); -static int cue_send __P((struct cue_softc *, struct mbuf *, int)); -static void cue_rxeof __P((usbd_xfer_handle, +Static int cue_send __P((struct cue_softc *, struct mbuf *, int)); +Static void cue_rxeof __P((usbd_xfer_handle, usbd_private_handle, usbd_status)); -static void cue_txeof __P((usbd_xfer_handle, +Static void cue_txeof __P((usbd_xfer_handle, usbd_private_handle, usbd_status)); -static void cue_tick __P((void *)); -static void cue_start __P((struct ifnet *)); -static int cue_ioctl __P((struct ifnet *, u_long, caddr_t)); -static void cue_init __P((void *)); -static void cue_stop __P((struct cue_softc *)); -static void cue_watchdog __P((struct ifnet *)); - -static void cue_setmulti __P((struct cue_softc *)); -static u_int32_t cue_crc __P((caddr_t)); -static void cue_reset __P((struct cue_softc *)); - -static int cue_csr_read_1 __P((struct cue_softc *, int)); -static int cue_csr_write_1 __P((struct cue_softc *, int, int)); -static int cue_csr_read_2 __P((struct cue_softc *, int)); +Static void cue_tick __P((void *)); +Static void cue_start __P((struct ifnet *)); +Static int cue_ioctl __P((struct ifnet *, u_long, caddr_t)); +Static void cue_init __P((void *)); +Static void cue_stop __P((struct cue_softc *)); +Static void cue_watchdog __P((struct ifnet *)); + +Static void cue_setmulti __P((struct cue_softc *)); +Static u_int32_t cue_crc __P((caddr_t)); +Static void cue_reset __P((struct cue_softc *)); + +Static int cue_csr_read_1 __P((struct cue_softc *, int)); +Static int cue_csr_write_1 __P((struct cue_softc *, int, int)); +Static int cue_csr_read_2 __P((struct cue_softc *, int)); #ifdef notdef -static int cue_csr_write_2 __P((struct cue_softc *, int, int)); +Static int cue_csr_write_2 __P((struct cue_softc *, int, int)); #endif -static int cue_mem __P((struct cue_softc *, int, +Static int cue_mem __P((struct cue_softc *, int, int, void *, int)); -static int cue_getmac __P((struct cue_softc *, void *)); +Static int cue_getmac __P((struct cue_softc *, void *)); #ifdef __FreeBSD__ #ifndef lint @@ -207,12 +205,12 @@ static const char rcsid[] = "$FreeBSD: src/sys/dev/usb/if_cue.c,v 1.4 2000/01/16 22:45:06 wpaul Exp $"; #endif -static void cue_rxstart __P((struct ifnet *)); -static void cue_shutdown __P((device_t)); +Static void cue_rxstart __P((struct ifnet *)); +Static void cue_shutdown __P((device_t)); -static struct usb_qdat cue_qdat; +Static struct usb_qdat cue_qdat; -static device_method_t cue_methods[] = { +Static device_method_t cue_methods[] = { /* Device interface */ DEVMETHOD(device_probe, cue_match), DEVMETHOD(device_attach, cue_attach), @@ -222,13 +220,13 @@ static device_method_t cue_methods[] = { { 0, 0 } }; -static driver_t cue_driver = { +Static driver_t cue_driver = { "cue", cue_methods, sizeof(struct cue_softc) }; -static devclass_t cue_devclass; +Static devclass_t cue_devclass; DRIVER_MODULE(if_cue, uhub, cue_driver, cue_devclass, usbd_driver_load, 0); @@ -243,7 +241,7 @@ DRIVER_MODULE(if_cue, uhub, cue_driver, cue_devclass, usbd_driver_load, 0); #define CUE_CLRBIT(sc, reg, x) \ cue_csr_write_1(sc, reg, cue_csr_read_1(sc, reg) & ~(x)) -static int +Static int cue_csr_read_1(sc, reg) struct cue_softc *sc; int reg; @@ -278,7 +276,7 @@ cue_csr_read_1(sc, reg) return (val); } -static int +Static int cue_csr_read_2(sc, reg) struct cue_softc *sc; int reg; @@ -313,7 +311,7 @@ cue_csr_read_2(sc, reg) return (UGETW(val)); } -static int +Static int cue_csr_write_1(sc, reg, val) struct cue_softc *sc; int reg, val; @@ -351,7 +349,7 @@ cue_csr_write_1(sc, reg, val) } #ifdef notdef -static int +Static int cue_csr_write_2(sc, reg, val) struct cue_softc *sc; int reg, aval; @@ -388,7 +386,7 @@ cue_csr_write_2(sc, reg, val) } #endif -static int +Static int cue_mem(sc, cmd, addr, buf, len) struct cue_softc *sc; int cmd; @@ -425,7 +423,7 @@ cue_mem(sc, cmd, addr, buf, len) return (0); } -static int +Static int cue_getmac(sc, buf) struct cue_softc *sc; void *buf; @@ -457,7 +455,7 @@ cue_getmac(sc, buf) #define CUE_POLY 0xEDB88320 #define CUE_BITS 9 -static u_int32_t +Static u_int32_t cue_crc(addr) caddr_t addr; { @@ -474,7 +472,7 @@ cue_crc(addr) return (crc & ((1 << CUE_BITS) - 1)); } -static void +Static void cue_setmulti(sc) struct cue_softc *sc; { @@ -547,7 +545,7 @@ cue_setmulti(sc) &sc->cue_mctab, CUE_MCAST_TABLE_LEN); } -static void +Static void cue_reset(sc) struct cue_softc *sc; { @@ -720,15 +718,14 @@ USB_ATTACH(cue) ifp->if_ioctl = cue_ioctl; ifp->if_start = cue_start; ifp->if_watchdog = cue_watchdog; +#if defined(__OpenBSD__) + ifp->if_snd.ifq_maxlen = IFQ_MAXLEN; +#endif strncpy(ifp->if_xname, USBDEVNAME(sc->cue_dev), IFNAMSIZ); /* Attach the interface. */ if_attach(ifp); -#if defined(__NetBSD__) - ether_ifattach(ifp, eaddr); -#else - ether_ifattach(ifp); -#endif + Ether_ifattach(ifp, eaddr); #if NBPFILTER > 0 bpfattach(&ifp->if_bpf, ifp, DLT_EN10MB, @@ -818,10 +815,8 @@ cue_activate(self, act) break; case DVACT_DEACTIVATE: -#if defined(__NetBSD__) /* Deactivate the interface. */ if_deactivate(&sc->cue_ec.ec_if); -#endif sc->cue_dying = 1; break; } @@ -832,7 +827,7 @@ cue_activate(self, act) /* * Initialize an RX descriptor and attach an MBUF cluster. */ -static int +Static int cue_newbuf(sc, c, m) struct cue_softc *sc; struct cue_chain *c; @@ -868,7 +863,7 @@ cue_newbuf(sc, c, m) return (0); } -static int +Static int cue_rx_list_init(sc) struct cue_softc *sc; { @@ -898,7 +893,7 @@ cue_rx_list_init(sc) return (0); } -static int +Static int cue_tx_list_init(sc) struct cue_softc *sc; { @@ -928,7 +923,7 @@ cue_tx_list_init(sc) } #ifdef __FreeBSD__ -static void +Static void cue_rxstart(ifp) struct ifnet *ifp; { @@ -955,7 +950,7 @@ cue_rxstart(ifp) * A frame has been uploaded: pass the resulting mbuf chain up to * the higher level protocols. */ -static void +Static void cue_rxeof(xfer, priv, status) usbd_xfer_handle xfer; usbd_private_handle priv; @@ -969,7 +964,6 @@ cue_rxeof(xfer, priv, status) u_int16_t len; #if defined(__NetBSD__) || defined(__OpenBSD__) int s; - struct ether_header *eh; #endif /* defined(__NetBSD__) || defined(__OpenBSD__) */ DPRINTFN(10,("%s: %s: enter status=%d\n", USBDEVNAME(sc->cue_dev), @@ -1032,8 +1026,6 @@ cue_rxeof(xfer, priv, status) goto done1; } - eh = mtod(m, struct ether_header *); - #if NBPFILTER > 0 /* * Handle BPF listeners. Let the BPF user see the packet, but @@ -1042,8 +1034,9 @@ cue_rxeof(xfer, priv, status) * address or the interface is in promiscuous mode. */ if (ifp->if_bpf) { - BPF_MTAP(ifp, m); #if defined(__NetBSD__) + struct ether_header *eh = mtod(m, struct ether_header *); + BPF_MTAP(ifp, m); if ((ifp->if_flags & IFF_PROMISC) && memcmp(eh->ether_dhost, LLADDR(ifp->if_sadl), ETHER_ADDR_LEN) && @@ -1051,17 +1044,15 @@ cue_rxeof(xfer, priv, status) m_freem(m); goto done1; } +#else + BPF_MTAP(ifp, m); #endif } #endif DPRINTFN(10,("%s: %s: deliver %d\n", USBDEVNAME(sc->cue_dev), __FUNCTION__, m->m_len)); -#if defined(__NetBSD__) - (*ifp->if_input)(ifp, m); -#else - ether_input(ifp, eh, m); -#endif + IF_INPUT(ifp, m); done1: splx(s); #endif /* defined(__NetBSD__) || defined(__OpenBSD__) */ @@ -1081,7 +1072,7 @@ done: * A frame was downloaded to the chip. It's safe for us to clean up * the list buffers. */ -static void +Static void cue_txeof(xfer, priv, status) usbd_xfer_handle xfer; usbd_private_handle priv; @@ -1134,7 +1125,7 @@ cue_txeof(xfer, priv, status) splx(s); } -static void +Static void cue_tick(xsc) void *xsc; { @@ -1166,7 +1157,7 @@ cue_tick(xsc) splx(s); } -static int +Static int cue_send(sc, m, idx) struct cue_softc *sc; struct mbuf *m; @@ -1210,7 +1201,7 @@ cue_send(sc, m, idx) return (0); } -static void +Static void cue_start(ifp) struct ifnet *ifp; { @@ -1252,7 +1243,7 @@ cue_start(ifp) ifp->if_timer = 5; } -static void +Static void cue_init(xsc) void *xsc; { @@ -1286,7 +1277,7 @@ cue_init(xsc) eaddr = sc->arpcom.ac_enaddr; #elif defined(__NetBSD__) eaddr = LLADDR(ifp->if_sadl); -#endif /* defined(__NetBSD__) */ +#endif /* defined(__NetBSD__) || defined(__OpenBSD__) */ /* Set MAC address */ for (i = 0; i < ETHER_ADDR_LEN; i++) cue_csr_write_1(sc, CUE_PAR0 - i, eaddr[i]); @@ -1343,7 +1334,7 @@ cue_init(xsc) usb_callout(sc->cue_stat_ch, hz, cue_tick, sc); } -static int +Static int cue_open_pipes(sc) struct cue_softc *sc; { @@ -1380,7 +1371,7 @@ cue_open_pipes(sc) return (0); } -static int +Static int cue_ioctl(ifp, command, data) struct ifnet *ifp; u_long command; @@ -1483,7 +1474,7 @@ cue_ioctl(ifp, command, data) return (error); } -static void +Static void cue_watchdog(ifp) struct ifnet *ifp; { @@ -1516,7 +1507,7 @@ cue_watchdog(ifp) * Stop the adapter and free any mbufs allocated to the * RX and TX lists. */ -static void +Static void cue_stop(sc) struct cue_softc *sc; { @@ -1608,7 +1599,7 @@ cue_stop(sc) * Stop all chip I/O so that the kernel's probe routines don't * get confused by errant DMAs when rebooting. */ -static void +Static void cue_shutdown(dev) device_t dev; { diff --git a/sys/dev/usb/if_kue.c b/sys/dev/usb/if_kue.c index 0f0e7c567cb..cbc43e37102 100644 --- a/sys/dev/usb/if_kue.c +++ b/sys/dev/usb/if_kue.c @@ -1,5 +1,5 @@ -/* $OpenBSD: if_kue.c,v 1.2 2000/03/28 19:37:47 aaron Exp $ */ -/* $NetBSD: if_kue.c,v 1.23 2000/03/26 15:08:44 augustss Exp $ */ +/* $OpenBSD: if_kue.c,v 1.3 2000/03/30 16:19:32 aaron Exp $ */ +/* $NetBSD: if_kue.c,v 1.27 2000/03/30 00:18:17 augustss Exp $ */ /* * Copyright (c) 1997, 1998, 1999, 2000 * Bill Paul <wpaul@ee.columbia.edu>. All rights reserved. @@ -173,7 +173,7 @@ int kuedebug = 0; /* * Various supported device vendors/products. */ -static struct kue_type kue_devs[] = { +Static struct kue_type kue_devs[] = { { USB_VENDOR_AOX, USB_PRODUCT_AOX_USB101 }, { USB_VENDOR_ADS, USB_PRODUCT_ADS_UBS10BT }, { USB_VENDOR_ATEN, USB_PRODUCT_ATEN_UC10T }, @@ -193,30 +193,30 @@ static struct kue_type kue_devs[] = { USB_DECLARE_DRIVER(kue); -static int kue_tx_list_init __P((struct kue_softc *)); -static int kue_rx_list_init __P((struct kue_softc *)); -static int kue_newbuf __P((struct kue_softc *, struct kue_chain *, +Static int kue_tx_list_init __P((struct kue_softc *)); +Static int kue_rx_list_init __P((struct kue_softc *)); +Static int kue_newbuf __P((struct kue_softc *, struct kue_chain *, struct mbuf *)); -static int kue_send __P((struct kue_softc *, struct mbuf *, int)); -static int kue_open_pipes __P((struct kue_softc *)); -static void kue_rxeof __P((usbd_xfer_handle, +Static int kue_send __P((struct kue_softc *, struct mbuf *, int)); +Static int kue_open_pipes __P((struct kue_softc *)); +Static void kue_rxeof __P((usbd_xfer_handle, usbd_private_handle, usbd_status)); -static void kue_txeof __P((usbd_xfer_handle, +Static void kue_txeof __P((usbd_xfer_handle, usbd_private_handle, usbd_status)); -static void kue_start __P((struct ifnet *)); -static int kue_ioctl __P((struct ifnet *, u_long, caddr_t)); -static void kue_init __P((void *)); -static void kue_stop __P((struct kue_softc *)); -static void kue_watchdog __P((struct ifnet *)); +Static void kue_start __P((struct ifnet *)); +Static int kue_ioctl __P((struct ifnet *, u_long, caddr_t)); +Static void kue_init __P((void *)); +Static void kue_stop __P((struct kue_softc *)); +Static void kue_watchdog __P((struct ifnet *)); -static void kue_setmulti __P((struct kue_softc *)); -static void kue_reset __P((struct kue_softc *)); +Static void kue_setmulti __P((struct kue_softc *)); +Static void kue_reset __P((struct kue_softc *)); -static usbd_status kue_ctl __P((struct kue_softc *, int, u_int8_t, +Static usbd_status kue_ctl __P((struct kue_softc *, int, u_int8_t, u_int16_t, void *, u_int32_t)); -static usbd_status kue_setword __P((struct kue_softc *, u_int8_t, u_int16_t)); -static int kue_is_warm __P((struct kue_softc *)); -static int kue_load_fw __P((struct kue_softc *)); +Static usbd_status kue_setword __P((struct kue_softc *, u_int8_t, u_int16_t)); +Static int kue_is_warm __P((struct kue_softc *)); +Static int kue_load_fw __P((struct kue_softc *)); #if defined(__FreeBSD__) #ifndef lint @@ -224,12 +224,12 @@ static const char rcsid[] = "$FreeBSD: src/sys/dev/usb/if_kue.c,v 1.14 2000/01/14 01:36:15 wpaul Exp $"; #endif -static void kue_rxstart __P((struct ifnet *)); -static void kue_shutdown __P((device_t)); +Static void kue_rxstart __P((struct ifnet *)); +Static void kue_shutdown __P((device_t)); -static struct usb_qdat kue_qdat; +Static struct usb_qdat kue_qdat; -static device_method_t kue_methods[] = { +Static device_method_t kue_methods[] = { /* Device interface */ DEVMETHOD(device_probe, kue_match), DEVMETHOD(device_attach, kue_attach), @@ -239,13 +239,13 @@ static device_method_t kue_methods[] = { { 0, 0 } }; -static driver_t kue_driver = { +Static driver_t kue_driver = { "kue", kue_methods, sizeof(struct kue_softc) }; -static devclass_t kue_devclass; +Static devclass_t kue_devclass; DRIVER_MODULE(if_kue, uhub, kue_driver, kue_devclass, usbd_driver_load, 0); @@ -254,7 +254,7 @@ DRIVER_MODULE(if_kue, uhub, kue_driver, kue_devclass, usbd_driver_load, 0); #define KUE_DO_REQUEST(dev, req, data) \ usbd_do_request_flags(dev, req, data, USBD_NO_TSLEEP, NULL) -static usbd_status +Static usbd_status kue_setword(sc, breq, word) struct kue_softc *sc; u_int8_t breq; @@ -279,7 +279,7 @@ kue_setword(sc, breq, word) return (err); } -static usbd_status +Static usbd_status kue_ctl(sc, rw, breq, val, data, len) struct kue_softc *sc; int rw; @@ -312,7 +312,7 @@ kue_ctl(sc, rw, breq, val, data, len) return (err); } -static int +Static int kue_is_warm(sc) struct kue_softc *sc; { @@ -331,7 +331,7 @@ kue_is_warm(sc) return (!err); } -static int +Static int kue_load_fw(sc) struct kue_softc *sc; { @@ -413,7 +413,7 @@ kue_load_fw(sc) return (0); } -static void +Static void kue_setmulti(sc) struct kue_softc *sc; { @@ -492,7 +492,7 @@ kue_setmulti(sc) * done after the firmware is loaded into the adapter in order to * bring it into proper operation. */ -static void +Static void kue_reset(sc) struct kue_softc *sc; { @@ -674,15 +674,14 @@ USB_ATTACH(kue) ifp->if_ioctl = kue_ioctl; ifp->if_start = kue_start; ifp->if_watchdog = kue_watchdog; +#if defined(__OpenBSD__) + ifp->if_snd.ifq_maxlen = IFQ_MAXLEN; +#endif strncpy(ifp->if_xname, USBDEVNAME(sc->kue_dev), IFNAMSIZ); /* Attach the interface. */ if_attach(ifp); -#if defined(__NetBSD__) - ether_ifattach(ifp, sc->kue_desc.kue_macaddr); -#else - ether_ifattach(ifp); -#endif + Ether_ifattach(ifp, sc->kue_desc.kue_macaddr); #if NBPFILTER > 0 bpfattach(&ifp->if_bpf, ifp, DLT_EN10MB, @@ -781,7 +780,7 @@ kue_activate(self, act) /* * Initialize an RX descriptor and attach an MBUF cluster. */ -static int +Static int kue_newbuf(sc, c, m) struct kue_softc *sc; struct kue_chain *c; @@ -818,7 +817,7 @@ kue_newbuf(sc, c, m) return (0); } -static int +Static int kue_rx_list_init(sc) struct kue_softc *sc; { @@ -848,7 +847,7 @@ kue_rx_list_init(sc) return (0); } -static int +Static int kue_tx_list_init(sc) struct kue_softc *sc; { @@ -878,7 +877,7 @@ kue_tx_list_init(sc) } #ifdef __FreeBSD__ -static void +Static void kue_rxstart(ifp) struct ifnet *ifp; { @@ -905,7 +904,7 @@ kue_rxstart(ifp) * A frame has been uploaded: pass the resulting mbuf chain up to * the higher level protocols. */ -static void +Static void kue_rxeof(xfer, priv, status) usbd_xfer_handle xfer; usbd_private_handle priv; @@ -918,7 +917,6 @@ kue_rxeof(xfer, priv, status) int total_len = 0; #if defined(__NetBSD__) || defined(__OpenBSD__) int s; - struct ether_header *eh; #endif /* defined(__NetBSD__) || defined(__OpenBSD__) */ DPRINTFN(10,("%s: %s: enter status=%d\n", USBDEVNAME(sc->kue_dev), @@ -988,8 +986,6 @@ kue_rxeof(xfer, priv, status) goto done1; } - eh = mtod(m, struct ether_header *); - #if NBPFILTER > 0 /* * Handle BPF listeners. Let the BPF user see the packet, but @@ -998,8 +994,9 @@ kue_rxeof(xfer, priv, status) * address or the interface is in promiscuous mode. */ if (ifp->if_bpf) { - BPF_MTAP(ifp, m); #if defined(__NetBSD__) + struct ether_header *eh = mtod(m, struct ether_header *); + BPF_MTAP(ifp, m); if ((ifp->if_flags & IFF_PROMISC) && memcmp(eh->ether_dhost, LLADDR(ifp->if_sadl), ETHER_ADDR_LEN) && @@ -1007,17 +1004,15 @@ kue_rxeof(xfer, priv, status) m_freem(m); goto done1; } +#else + BPF_MTAP(ifp, m); #endif } #endif DPRINTFN(10,("%s: %s: deliver %d\n", USBDEVNAME(sc->kue_dev), __FUNCTION__, m->m_len)); -#if defined(__NetBSD__) - (*ifp->if_input)(ifp, m); -#else - ether_input(ifp, eh, m); -#endif + IF_INPUT(ifp, m); done1: splx(s); #endif /* defined(__NetBSD__) || defined(__OpenBSD__) */ @@ -1039,7 +1034,7 @@ kue_rxeof(xfer, priv, status) * the list buffers. */ -static void +Static void kue_txeof(xfer, priv, status) usbd_xfer_handle xfer; usbd_private_handle priv; @@ -1092,7 +1087,7 @@ kue_txeof(xfer, priv, status) splx(s); } -static int +Static int kue_send(sc, m, idx) struct kue_softc *sc; struct mbuf *m; @@ -1121,13 +1116,14 @@ kue_send(sc, m, idx) c->kue_buf[0] = (u_int8_t)m->m_pkthdr.len; c->kue_buf[1] = (u_int8_t)(m->m_pkthdr.len >> 8); - /* XXX 10000 */ usbd_setup_xfer(c->kue_xfer, sc->kue_ep[KUE_ENDPT_TX], - c, c->kue_buf, total_len, USBD_NO_COPY, 10000, kue_txeof); + c, c->kue_buf, total_len, USBD_NO_COPY, USBD_DEFAULT_TIMEOUT, kue_txeof); /* Transmit */ err = usbd_transfer(c->kue_xfer); if (err != USBD_IN_PROGRESS) { + DPRINTF(("%s: kue_send err=%s\n", USBDEVNAME(sc->kue_dev), + usbd_errstr(err))); kue_stop(sc); return (EIO); } @@ -1137,7 +1133,7 @@ kue_send(sc, m, idx) return (0); } -static void +Static void kue_start(ifp) struct ifnet *ifp; { @@ -1179,7 +1175,7 @@ kue_start(ifp) ifp->if_timer = 5; } -static void +Static void kue_init(xsc) void *xsc; { @@ -1251,7 +1247,7 @@ kue_init(xsc) splx(s); } -static int +Static int kue_open_pipes(sc) struct kue_softc *sc; { @@ -1293,7 +1289,7 @@ kue_open_pipes(sc) return (0); } -static int +Static int kue_ioctl(ifp, command, data) struct ifnet *ifp; u_long command; @@ -1400,7 +1396,7 @@ kue_ioctl(ifp, command, data) return (error); } -static void +Static void kue_watchdog(ifp) struct ifnet *ifp; { @@ -1433,7 +1429,7 @@ kue_watchdog(ifp) * Stop the adapter and free any mbufs allocated to the * RX and TX lists. */ -static void +Static void kue_stop(sc) struct kue_softc *sc; { @@ -1521,7 +1517,7 @@ kue_stop(sc) * Stop all chip I/O so that the kernel's probe routines don't * get confused by errant DMAs when rebooting. */ -static void +Static void kue_shutdown(dev) device_t dev; { diff --git a/sys/dev/usb/kue_fw.h b/sys/dev/usb/kue_fw.h index 6de46b531e8..08b914b0931 100644 --- a/sys/dev/usb/kue_fw.h +++ b/sys/dev/usb/kue_fw.h @@ -1,5 +1,5 @@ -/* $OpenBSD: kue_fw.h,v 1.2 2000/03/28 19:37:48 aaron Exp $ */ -/* $NetBSD: kue_fw.h,v 1.1 2000/01/17 01:38:43 augustss Exp $ */ +/* $OpenBSD: kue_fw.h,v 1.3 2000/03/30 16:19:32 aaron Exp $ */ +/* $NetBSD: kue_fw.h,v 1.2 2000/03/27 12:33:54 augustss Exp $ */ /* * Copyright (c) 1997, 1998, 1999, 2000 * Bill Paul <wpaul@ee.columbia.edu>. All rights reserved. @@ -87,7 +87,7 @@ #define KUE_QTINTR_LOAD_CODE_HIGH 0x9C /* Firmware code segment */ -static unsigned char kue_code_seg[] = +Static unsigned char kue_code_seg[] = { /******************************************/ /* NOTE: B6/C3 is data header signature */ @@ -579,7 +579,7 @@ static unsigned char kue_code_seg[] = }; /* Firmware fixup (data?) segment */ -static unsigned char kue_fix_seg[] = +Static unsigned char kue_fix_seg[] = { /******************************************/ /* NOTE: B6/C3 is data header signature */ @@ -682,6 +682,6 @@ static unsigned char kue_fix_seg[] = /* Fixup command. */ #define KUE_TRIGCMD_OFFSET 5 -static unsigned char kue_trig_seg[] = { +Static unsigned char kue_trig_seg[] = { 0xb6, 0xc3, 0x01, 0x00, 0x06, 0x64, 0x00, 0x00 }; diff --git a/sys/dev/usb/ohci.c b/sys/dev/usb/ohci.c index 83b2105b4cb..b7bdf7de794 100644 --- a/sys/dev/usb/ohci.c +++ b/sys/dev/usb/ohci.c @@ -1,5 +1,5 @@ -/* $OpenBSD: ohci.c,v 1.9 2000/03/28 19:37:48 aaron Exp $ */ -/* $NetBSD: ohci.c,v 1.81 2000/03/25 18:02:32 augustss Exp $ */ +/* $OpenBSD: ohci.c,v 1.10 2000/03/30 16:19:32 aaron Exp $ */ +/* $NetBSD: ohci.c,v 1.84 2000/03/29 18:24:53 augustss Exp $ */ /* $FreeBSD: src/sys/dev/usb/ohci.c,v 1.22 1999/11/17 22:33:40 n_hibma Exp $ */ /* @@ -114,110 +114,118 @@ int ohcidebug = 0; struct ohci_pipe; -static ohci_soft_ed_t *ohci_alloc_sed __P((ohci_softc_t *)); -static void ohci_free_sed __P((ohci_softc_t *, ohci_soft_ed_t *)); +Static ohci_soft_ed_t *ohci_alloc_sed __P((ohci_softc_t *)); +Static void ohci_free_sed __P((ohci_softc_t *, ohci_soft_ed_t *)); -static ohci_soft_td_t *ohci_alloc_std __P((ohci_softc_t *)); -static void ohci_free_std __P((ohci_softc_t *, ohci_soft_td_t *)); +Static ohci_soft_td_t *ohci_alloc_std __P((ohci_softc_t *)); +Static void ohci_free_std __P((ohci_softc_t *, ohci_soft_td_t *)); -static ohci_soft_itd_t *ohci_alloc_sitd __P((ohci_softc_t *)); -static void ohci_free_sitd __P((ohci_softc_t *,ohci_soft_itd_t *)); +Static ohci_soft_itd_t *ohci_alloc_sitd __P((ohci_softc_t *)); +Static void ohci_free_sitd __P((ohci_softc_t *,ohci_soft_itd_t *)); #if 0 -static void ohci_free_std_chain __P((ohci_softc_t *, +Static void ohci_free_std_chain __P((ohci_softc_t *, ohci_soft_td_t *, ohci_soft_td_t *)); #endif -static usbd_status ohci_alloc_std_chain __P((struct ohci_pipe *, +Static usbd_status ohci_alloc_std_chain __P((struct ohci_pipe *, ohci_softc_t *, int, int, usbd_xfer_handle, ohci_soft_td_t *, ohci_soft_td_t **)); -static void ohci_shutdown __P((void *v)); -static void ohci_power __P((int, void *)); -static usbd_status ohci_open __P((usbd_pipe_handle)); -static void ohci_poll __P((struct usbd_bus *)); -static void ohci_softintr __P((struct usbd_bus *)); -static void ohci_waitintr __P((ohci_softc_t *, - usbd_xfer_handle)); -static void ohci_rhsc __P((ohci_softc_t *, usbd_xfer_handle)); - -static usbd_status ohci_device_request __P((usbd_xfer_handle xfer)); -static void ohci_add_ed __P((ohci_soft_ed_t *, ohci_soft_ed_t *)); -static void ohci_rem_ed __P((ohci_soft_ed_t *, ohci_soft_ed_t *)); -static void ohci_hash_add_td __P((ohci_softc_t *, +Static void ohci_shutdown __P((void *v)); +Static void ohci_power __P((int, void *)); +Static usbd_status ohci_open __P((usbd_pipe_handle)); +Static void ohci_poll __P((struct usbd_bus *)); +Static void ohci_softintr __P((struct usbd_bus *)); +Static void ohci_waitintr __P((ohci_softc_t *, usbd_xfer_handle)); +Static void ohci_add_done __P((ohci_softc_t *, ohci_physaddr_t)); +Static void ohci_rhsc __P((ohci_softc_t *, usbd_xfer_handle)); + +Static usbd_status ohci_device_request __P((usbd_xfer_handle xfer)); +Static void ohci_add_ed __P((ohci_soft_ed_t *, ohci_soft_ed_t *)); +Static void ohci_rem_ed __P((ohci_soft_ed_t *, ohci_soft_ed_t *)); +Static void ohci_hash_add_td __P((ohci_softc_t *, ohci_soft_td_t *)); -static void ohci_hash_rem_td __P((ohci_softc_t *, +Static void ohci_hash_rem_td __P((ohci_softc_t *, ohci_soft_td_t *)); -static ohci_soft_td_t *ohci_hash_find_td __P((ohci_softc_t *, +Static ohci_soft_td_t *ohci_hash_find_td __P((ohci_softc_t *, + ohci_physaddr_t)); +Static void ohci_hash_add_itd __P((ohci_softc_t *, + ohci_soft_itd_t *)); +Static void ohci_hash_rem_itd __P((ohci_softc_t *, + ohci_soft_itd_t *)); +Static ohci_soft_itd_t *ohci_hash_find_itd __P((ohci_softc_t *, ohci_physaddr_t)); -static usbd_status ohci_setup_isoc __P((usbd_pipe_handle pipe)); -static void ohci_device_isoc_enter __P((usbd_xfer_handle)); +Static usbd_status ohci_setup_isoc __P((usbd_pipe_handle pipe)); +Static void ohci_device_isoc_enter __P((usbd_xfer_handle)); -static usbd_status ohci_allocm __P((struct usbd_bus *, usb_dma_t *, +Static usbd_status ohci_allocm __P((struct usbd_bus *, usb_dma_t *, u_int32_t)); -static void ohci_freem __P((struct usbd_bus *, usb_dma_t *)); - -static usbd_xfer_handle ohci_allocx __P((struct usbd_bus *)); -static void ohci_freex __P((struct usbd_bus *, usbd_xfer_handle)); - -static usbd_status ohci_root_ctrl_transfer __P((usbd_xfer_handle)); -static usbd_status ohci_root_ctrl_start __P((usbd_xfer_handle)); -static void ohci_root_ctrl_abort __P((usbd_xfer_handle)); -static void ohci_root_ctrl_close __P((usbd_pipe_handle)); -static void ohci_root_ctrl_done __P((usbd_xfer_handle)); - -static usbd_status ohci_root_intr_transfer __P((usbd_xfer_handle)); -static usbd_status ohci_root_intr_start __P((usbd_xfer_handle)); -static void ohci_root_intr_abort __P((usbd_xfer_handle)); -static void ohci_root_intr_close __P((usbd_pipe_handle)); -static void ohci_root_intr_done __P((usbd_xfer_handle)); - -static usbd_status ohci_device_ctrl_transfer __P((usbd_xfer_handle)); -static usbd_status ohci_device_ctrl_start __P((usbd_xfer_handle)); -static void ohci_device_ctrl_abort __P((usbd_xfer_handle)); -static void ohci_device_ctrl_close __P((usbd_pipe_handle)); -static void ohci_device_ctrl_done __P((usbd_xfer_handle)); - -static usbd_status ohci_device_bulk_transfer __P((usbd_xfer_handle)); -static usbd_status ohci_device_bulk_start __P((usbd_xfer_handle)); -static void ohci_device_bulk_abort __P((usbd_xfer_handle)); -static void ohci_device_bulk_close __P((usbd_pipe_handle)); -static void ohci_device_bulk_done __P((usbd_xfer_handle)); - -static usbd_status ohci_device_intr_transfer __P((usbd_xfer_handle)); -static usbd_status ohci_device_intr_start __P((usbd_xfer_handle)); -static void ohci_device_intr_abort __P((usbd_xfer_handle)); -static void ohci_device_intr_close __P((usbd_pipe_handle)); -static void ohci_device_intr_done __P((usbd_xfer_handle)); - -static usbd_status ohci_device_isoc_transfer __P((usbd_xfer_handle)); -static usbd_status ohci_device_isoc_start __P((usbd_xfer_handle)); -static void ohci_device_isoc_abort __P((usbd_xfer_handle)); -static void ohci_device_isoc_close __P((usbd_pipe_handle)); -static void ohci_device_isoc_done __P((usbd_xfer_handle)); - -static usbd_status ohci_device_setintr __P((ohci_softc_t *sc, +Static void ohci_freem __P((struct usbd_bus *, usb_dma_t *)); + +Static usbd_xfer_handle ohci_allocx __P((struct usbd_bus *)); +Static void ohci_freex __P((struct usbd_bus *, usbd_xfer_handle)); + +Static usbd_status ohci_root_ctrl_transfer __P((usbd_xfer_handle)); +Static usbd_status ohci_root_ctrl_start __P((usbd_xfer_handle)); +Static void ohci_root_ctrl_abort __P((usbd_xfer_handle)); +Static void ohci_root_ctrl_close __P((usbd_pipe_handle)); +Static void ohci_root_ctrl_done __P((usbd_xfer_handle)); + +Static usbd_status ohci_root_intr_transfer __P((usbd_xfer_handle)); +Static usbd_status ohci_root_intr_start __P((usbd_xfer_handle)); +Static void ohci_root_intr_abort __P((usbd_xfer_handle)); +Static void ohci_root_intr_close __P((usbd_pipe_handle)); +Static void ohci_root_intr_done __P((usbd_xfer_handle)); + +Static usbd_status ohci_device_ctrl_transfer __P((usbd_xfer_handle)); +Static usbd_status ohci_device_ctrl_start __P((usbd_xfer_handle)); +Static void ohci_device_ctrl_abort __P((usbd_xfer_handle)); +Static void ohci_device_ctrl_close __P((usbd_pipe_handle)); +Static void ohci_device_ctrl_done __P((usbd_xfer_handle)); + +Static usbd_status ohci_device_bulk_transfer __P((usbd_xfer_handle)); +Static usbd_status ohci_device_bulk_start __P((usbd_xfer_handle)); +Static void ohci_device_bulk_abort __P((usbd_xfer_handle)); +Static void ohci_device_bulk_close __P((usbd_pipe_handle)); +Static void ohci_device_bulk_done __P((usbd_xfer_handle)); + +Static usbd_status ohci_device_intr_transfer __P((usbd_xfer_handle)); +Static usbd_status ohci_device_intr_start __P((usbd_xfer_handle)); +Static void ohci_device_intr_abort __P((usbd_xfer_handle)); +Static void ohci_device_intr_close __P((usbd_pipe_handle)); +Static void ohci_device_intr_done __P((usbd_xfer_handle)); + +Static usbd_status ohci_device_isoc_transfer __P((usbd_xfer_handle)); +Static usbd_status ohci_device_isoc_start __P((usbd_xfer_handle)); +Static void ohci_device_isoc_abort __P((usbd_xfer_handle)); +Static void ohci_device_isoc_close __P((usbd_pipe_handle)); +Static void ohci_device_isoc_done __P((usbd_xfer_handle)); + +Static usbd_status ohci_device_setintr __P((ohci_softc_t *sc, struct ohci_pipe *pipe, int ival)); -static int ohci_str __P((usb_string_descriptor_t *, int, char *)); +Static int ohci_str __P((usb_string_descriptor_t *, int, char *)); -static void ohci_timeout __P((void *)); -static void ohci_rhsc_able __P((ohci_softc_t *, int)); +Static void ohci_timeout __P((void *)); +Static void ohci_rhsc_able __P((ohci_softc_t *, int)); -static void ohci_close_pipe __P((usbd_pipe_handle pipe, +Static void ohci_close_pipe __P((usbd_pipe_handle pipe, ohci_soft_ed_t *head)); -static void ohci_abort_xfer __P((usbd_xfer_handle xfer, +Static void ohci_abort_xfer __P((usbd_xfer_handle xfer, usbd_status status)); -static void ohci_abort_xfer_end __P((void *)); +Static void ohci_abort_xfer_end __P((void *)); -static void ohci_device_clear_toggle __P((usbd_pipe_handle pipe)); -static void ohci_noop __P((usbd_pipe_handle pipe)); +Static void ohci_device_clear_toggle __P((usbd_pipe_handle pipe)); +Static void ohci_noop __P((usbd_pipe_handle pipe)); #ifdef OHCI_DEBUG -static void ohci_dumpregs __P((ohci_softc_t *)); -static void ohci_dump_tds __P((ohci_soft_td_t *)); -static void ohci_dump_td __P((ohci_soft_td_t *)); -static void ohci_dump_ed __P((ohci_soft_ed_t *)); +Static void ohci_dumpregs __P((ohci_softc_t *)); +Static void ohci_dump_tds __P((ohci_soft_td_t *)); +Static void ohci_dump_td __P((ohci_soft_td_t *)); +Static void ohci_dump_ed __P((ohci_soft_ed_t *)); +Static void ohci_dump_itd __P((ohci_soft_itd_t *)); +Static void ohci_dump_itds __P((ohci_soft_itd_t *)); #endif #define OWRITE4(sc, r, x) bus_space_write_4((sc)->iot, (sc)->ioh, (r), (x)) @@ -225,7 +233,7 @@ static void ohci_dump_ed __P((ohci_soft_ed_t *)); #define OREAD2(sc, r) bus_space_read_2((sc)->iot, (sc)->ioh, (r)) /* Reverse the bits in a value 0 .. 31 */ -static u_int8_t revbits[OHCI_NO_INTRS] = +Static u_int8_t revbits[OHCI_NO_INTRS] = { 0x00, 0x10, 0x08, 0x18, 0x04, 0x14, 0x0c, 0x1c, 0x02, 0x12, 0x0a, 0x1a, 0x06, 0x16, 0x0e, 0x1e, 0x01, 0x11, 0x09, 0x19, 0x05, 0x15, 0x0d, 0x1d, @@ -265,7 +273,7 @@ struct ohci_pipe { #define OHCI_INTR_ENDPT 1 -static struct usbd_bus_methods ohci_bus_methods = { +Static struct usbd_bus_methods ohci_bus_methods = { ohci_open, ohci_softintr, ohci_poll, @@ -275,7 +283,7 @@ static struct usbd_bus_methods ohci_bus_methods = { ohci_freex, }; -static struct usbd_pipe_methods ohci_root_ctrl_methods = { +Static struct usbd_pipe_methods ohci_root_ctrl_methods = { ohci_root_ctrl_transfer, ohci_root_ctrl_start, ohci_root_ctrl_abort, @@ -284,7 +292,7 @@ static struct usbd_pipe_methods ohci_root_ctrl_methods = { ohci_root_ctrl_done, }; -static struct usbd_pipe_methods ohci_root_intr_methods = { +Static struct usbd_pipe_methods ohci_root_intr_methods = { ohci_root_intr_transfer, ohci_root_intr_start, ohci_root_intr_abort, @@ -293,7 +301,7 @@ static struct usbd_pipe_methods ohci_root_intr_methods = { ohci_root_intr_done, }; -static struct usbd_pipe_methods ohci_device_ctrl_methods = { +Static struct usbd_pipe_methods ohci_device_ctrl_methods = { ohci_device_ctrl_transfer, ohci_device_ctrl_start, ohci_device_ctrl_abort, @@ -302,7 +310,7 @@ static struct usbd_pipe_methods ohci_device_ctrl_methods = { ohci_device_ctrl_done, }; -static struct usbd_pipe_methods ohci_device_intr_methods = { +Static struct usbd_pipe_methods ohci_device_intr_methods = { ohci_device_intr_transfer, ohci_device_intr_start, ohci_device_intr_abort, @@ -311,7 +319,7 @@ static struct usbd_pipe_methods ohci_device_intr_methods = { ohci_device_intr_done, }; -static struct usbd_pipe_methods ohci_device_bulk_methods = { +Static struct usbd_pipe_methods ohci_device_bulk_methods = { ohci_device_bulk_transfer, ohci_device_bulk_start, ohci_device_bulk_abort, @@ -320,7 +328,7 @@ static struct usbd_pipe_methods ohci_device_bulk_methods = { ohci_device_bulk_done, }; -static struct usbd_pipe_methods ohci_device_isoc_methods = { +Static struct usbd_pipe_methods ohci_device_isoc_methods = { ohci_device_isoc_transfer, ohci_device_isoc_start, ohci_device_isoc_abort, @@ -346,6 +354,7 @@ ohci_activate(self, act) case DVACT_DEACTIVATE: if (sc->sc_child != NULL) rv = config_deactivate(sc->sc_child); + sc->sc_dying = 1; break; } return (rv); @@ -429,7 +438,7 @@ ohci_alloc_std(sc) err = usb_allocmem(&sc->sc_bus, OHCI_STD_SIZE * OHCI_STD_CHUNK, OHCI_TD_ALIGN, &dma); if (err) - return (0); + return (NULL); s = splusb(); for(i = 0; i < OHCI_STD_CHUNK; i++) { offs = i * OHCI_STD_SIZE; @@ -445,8 +454,8 @@ ohci_alloc_std(sc) std = sc->sc_freetds; sc->sc_freetds = std->nexttd; memset(&std->td, 0, sizeof(ohci_td_t)); - std->nexttd = 0; - + std->nexttd = NULL; + std->xfer = NULL; ohci_hash_add_td(sc, std); splx(s); @@ -462,7 +471,6 @@ ohci_free_std(sc, std) s = splusb(); ohci_hash_rem_td(sc, std); - std->nexttd = sc->sc_freetds; sc->sc_freetds = std; splx(s); @@ -566,7 +574,7 @@ ohci_alloc_std_chain(opipe, sc, alen, rd, xfer, sp, ep) } #if 0 -static void +Static void ohci_free_std_chain(sc, std, stdend) ohci_softc_t *sc; ohci_soft_td_t *std; @@ -587,27 +595,37 @@ ohci_alloc_sitd(sc) { ohci_soft_itd_t *sitd; usbd_status err; - int i, offs; + int i, s, offs; usb_dma_t dma; if (sc->sc_freeitds == NULL) { DPRINTFN(2, ("ohci_alloc_sitd: allocating chunk\n")); - err = usb_allocmem(&sc->sc_bus, OHCI_STD_SIZE * OHCI_STD_CHUNK, - OHCI_TD_ALIGN, &dma); + err = usb_allocmem(&sc->sc_bus, OHCI_SITD_SIZE * OHCI_SITD_CHUNK, + OHCI_ITD_ALIGN, &dma); if (err) - return (0); - for(i = 0; i < OHCI_STD_CHUNK; i++) { - offs = i * OHCI_STD_SIZE; + return (NULL); + for(i = 0; i < OHCI_SITD_CHUNK; i++) { + offs = i * OHCI_SITD_SIZE; sitd = (ohci_soft_itd_t *)((char*)KERNADDR(&dma)+offs); sitd->physaddr = DMAADDR(&dma) + offs; sitd->nextitd = sc->sc_freeitds; sc->sc_freeitds = sitd; } } + + s = splusb(); sitd = sc->sc_freeitds; sc->sc_freeitds = sitd->nextitd; memset(&sitd->itd, 0, sizeof(ohci_itd_t)); - sitd->nextitd = 0; + sitd->nextitd = NULL; + sitd->xfer = NULL; + ohci_hash_add_itd(sc, sitd); + splx(s); + +#ifdef DIAGNOSTIC + sitd->isdone = 0; +#endif + return (sitd); } @@ -616,8 +634,22 @@ ohci_free_sitd(sc, sitd) ohci_softc_t *sc; ohci_soft_itd_t *sitd; { + int s; + + DPRINTFN(10,("ohci_free_sitd: sitd=%p\n", sitd)); + +#ifdef DIAGNOSTIC + if (!sitd->isdone) { + panic("ohci_free_sitd: sitd=%p not done\n", sitd); + return; + } +#endif + + s = splusb(); + ohci_hash_rem_itd(sc, sitd); sitd->nextitd = sc->sc_freeitds; sc->sc_freeitds = sitd; + splx(s); } usbd_status @@ -649,6 +681,8 @@ ohci_init(sc) for (i = 0; i < OHCI_HASH_SIZE; i++) LIST_INIT(&sc->sc_hash_tds[i]); + for (i = 0; i < OHCI_HASH_SIZE; i++) + LIST_INIT(&sc->sc_hash_itds[i]); SIMPLEQ_INIT(&sc->sc_free_xfers); @@ -980,7 +1014,7 @@ ohci_dumpregs(sc) } #endif -static int ohci_intr1 __P((ohci_softc_t *)); +Static int ohci_intr1 __P((ohci_softc_t *)); int ohci_intr(p) @@ -999,7 +1033,7 @@ ohci_intr(p) return (ohci_intr1(sc)); } -static int +Static int ohci_intr1(sc) ohci_softc_t *sc; { @@ -1045,19 +1079,7 @@ ohci_intr1(sc) intrs &= ~OHCI_SO; } if (eintrs & OHCI_WDH) { - done &= ~OHCI_DONE_INTRS; - if (sc->sc_done == 0) - sc->sc_done = done; - else { - /* Tack on at the end of sc_done. */ - ohci_physaddr_t ldone; - ohci_soft_td_t *std; - - for (ldone = sc->sc_done; ldone != 0; - ldone = le32toh(std->td.td_nexttd)) - std = ohci_hash_find_td(sc, ldone); - std->td.td_nexttd = htole32(done); - } + ohci_add_done(sc, done &~ OHCI_DONE_INTRS); sc->sc_hcca->hcca_done_head = 0; usb_schedsoftintr(&sc->sc_bus); intrs &= ~OHCI_WDH; @@ -1129,30 +1151,67 @@ char *ohci_cc_strs[] = { #endif void +ohci_add_done(sc, done) + ohci_softc_t *sc; + ohci_physaddr_t done; +{ + ohci_soft_itd_t *sitd, *sidone, **ip; + ohci_soft_td_t *std, *sdone, **p; + + /* Reverse the done list. */ + for (sdone = NULL, sidone = NULL; done != 0; ) { + std = ohci_hash_find_td(sc, done); + if (std != NULL) { + std->dnext = sdone; + done = le32toh(std->td.td_nexttd); + sdone = std; + DPRINTFN(10,("add TD %p\n", std)); + continue; + } + sitd = ohci_hash_find_itd(sc, done); + if (sitd != NULL) { + sitd->dnext = sidone; + done = le32toh(sitd->itd.itd_nextitd); + sidone = sitd; + DPRINTFN(5,("add ITD %p\n", sitd)); + continue; + } + panic("ohci_add_done: addr 0x%08lx not found\n", (u_long)done); + } + + /* sdone & sidone now hold the done lists. */ + /* Put them on the already processed lists. */ + for (p = &sc->sc_sdone; *p != NULL; p = &(*p)->dnext) + ; + *p = sdone; + for (ip = &sc->sc_sidone; *ip != NULL; ip = &(*ip)->dnext) + ; + *ip = sidone; +} + +void baaz(void); +void baaz(void) {} + +void ohci_softintr(bus) struct usbd_bus *bus; { ohci_softc_t *sc = (ohci_softc_t *)bus; - ohci_physaddr_t done; - ohci_soft_td_t *std, *sdone, *stdnext; + ohci_soft_itd_t *sitd, *sidone, *sitdnext; + ohci_soft_td_t *std, *sdone, *stdnext; usbd_xfer_handle xfer; int len, cc, s; sc->sc_bus.intr_context++; s = splhardusb(); - done = sc->sc_done; - sc->sc_done = 0; + sdone = sc->sc_sdone; + sc->sc_sdone = NULL; + sidone = sc->sc_sidone; + sc->sc_sidone = NULL; splx(s); - DPRINTFN(10,("ohci_process_done: done=0x%08lx\n", (u_long)done)); - - /* Reverse the done list. */ - for (sdone = NULL; done != 0; done = le32toh(std->td.td_nexttd)) { - std = ohci_hash_find_td(sc, done); - std->dnext = sdone; - sdone = std; - } + DPRINTFN(10,("ohci_process_done: sdone=%p sidone=%p\n", sdone, sidone)); #ifdef OHCI_DEBUG if (ohcidebug > 10) { @@ -1173,14 +1232,16 @@ ohci_softintr(bus) */ continue; } - cc = OHCI_TD_GET_CC(le32toh(std->td.td_flags)); - usb_uncallout(xfer->timeout_handle, ohci_timeout, xfer); if (xfer->status == USBD_CANCELLED || xfer->status == USBD_TIMEOUT) { DPRINTF(("ohci_process_done: cancel/timeout %p\n", xfer)); /* Handled by abort routine. */ - } else if (cc == OHCI_CC_NO_ERROR) { + continue; + } + usb_uncallout(xfer->timeout_handle, ohci_timeout, xfer); + cc = OHCI_TD_GET_CC(le32toh(std->td.td_flags)); + if (cc == OHCI_CC_NO_ERROR) { len = std->len; if (std->td.td_cbp != 0) len -= le32toh(std->td.td_be) - @@ -1226,6 +1287,50 @@ ohci_softintr(bus) } } +#ifdef OHCI_DEBUG + if (ohcidebug > 10) { + DPRINTF(("ohci_process_done: ITD done:\n")); + ohci_dump_itds(sidone); + } +#endif + + for (sitd = sidone; sitd != NULL; sitd = sitdnext) { + xfer = sitd->xfer; + sitdnext = sitd->dnext; + DPRINTFN(1, ("ohci_process_done: sitd=%p xfer=%p hcpriv=%p\n", + sitd, xfer, xfer ? xfer->hcpriv : 0)); + if (xfer == NULL) + continue; + if (xfer->status == USBD_CANCELLED || + xfer->status == USBD_TIMEOUT) { + DPRINTF(("ohci_process_done: cancel/timeout %p\n", + xfer)); + /* Handled by abort routine. */ + continue; + } +#ifdef DIAGNOSTIC + if (sitd->isdone) + printf("ohci_softintr: sitd=%p is done\n", sitd); + sitd->isdone = 1; +#endif + cc = OHCI_ITD_GET_CC(le32toh(sitd->itd.itd_flags)); + if (cc == OHCI_CC_NO_ERROR) { + /* XXX compute length for input */ + struct ohci_pipe *opipe = + (struct ohci_pipe *)xfer->pipe; + if (sitd->flags & OHCI_CALL_DONE) { + opipe->u.iso.inuse -= xfer->nframes; + /* XXX xfer->actlen = actlen; */ + xfer->status = USBD_NORMAL_COMPLETION; + usb_transfer_complete(xfer); + } + } else { + /* XXX Do more */ + xfer->status = USBD_IOERROR; + usb_transfer_complete(xfer); + } + } + sc->sc_bus.intr_context--; } @@ -1608,7 +1713,53 @@ ohci_hash_find_td(sc, a) std = LIST_NEXT(std, hnext)) if (std->physaddr == a) return (std); - panic("ohci_hash_find_td: addr 0x%08lx not found\n", (u_long)a); + return (NULL); +} + +/* Called at splusb() */ +void +ohci_hash_add_itd(sc, sitd) + ohci_softc_t *sc; + ohci_soft_itd_t *sitd; +{ + int h = HASH(sitd->physaddr); + + SPLUSBCHECK; + + DPRINTFN(10,("ohci_hash_add_itd: sitd=%p physaddr=0x%08lx\n", + sitd, (u_long)sitd->physaddr)); + + LIST_INSERT_HEAD(&sc->sc_hash_itds[h], sitd, hnext); +} + +/* Called at splusb() */ +void +ohci_hash_rem_itd(sc, sitd) + ohci_softc_t *sc; + ohci_soft_itd_t *sitd; +{ + SPLUSBCHECK; + + DPRINTFN(10,("ohci_hash_rem_itd: sitd=%p physaddr=0x%08lx\n", + sitd, (u_long)sitd->physaddr)); + + LIST_REMOVE(sitd, hnext); +} + +ohci_soft_itd_t * +ohci_hash_find_itd(sc, a) + ohci_softc_t *sc; + ohci_physaddr_t a; +{ + int h = HASH(a); + ohci_soft_itd_t *sitd; + + for (sitd = LIST_FIRST(&sc->sc_hash_itds[h]); + sitd != NULL; + sitd = LIST_NEXT(sitd, hnext)) + if (sitd->physaddr == a) + return (sitd); + return (NULL); } void @@ -1654,6 +1805,36 @@ ohci_dump_td(std) } void +ohci_dump_itd(sitd) + ohci_soft_itd_t *sitd; +{ + int i; + + DPRINTF(("ITD(%p) at %08lx: sf=%d di=%d fc=%d cc=%d\n" + "bp0=0x%08lx next=0x%08lx be=0x%08lx\n", + sitd, (u_long)sitd->physaddr, + OHCI_ITD_GET_SF(le32toh(sitd->itd.itd_flags)), + OHCI_ITD_GET_DI(le32toh(sitd->itd.itd_flags)), + OHCI_ITD_GET_FC(le32toh(sitd->itd.itd_flags)), + OHCI_ITD_GET_CC(le32toh(sitd->itd.itd_flags)), + (u_long)le32toh(sitd->itd.itd_bp0), + (u_long)le32toh(sitd->itd.itd_nextitd), + (u_long)le32toh(sitd->itd.itd_be))); + for (i = 0; i < OHCI_ITD_NOFFSET; i++) + DPRINTF(("offs[%d]=0x%04x ", i, + (u_int)le16toh(sitd->itd.itd_offset[i]))); + DPRINTF(("\n")); +} + +void +ohci_dump_itds(sitd) + ohci_soft_itd_t *sitd; +{ + for (; sitd; sitd = sitd->nextitd) + ohci_dump_itd(sitd); +} + +void ohci_dump_ed(sed) ohci_soft_ed_t *sed; { @@ -1720,6 +1901,10 @@ ohci_open(pipe) opipe->tail.itd = sitd; tdphys = sitd->physaddr; fmt = OHCI_ED_FORMAT_ISO; + if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN) + fmt |= OHCI_ED_DIR_IN; + else + fmt |= OHCI_ED_DIR_OUT; } else { std = ohci_alloc_std(sc); if (std == NULL) { @@ -1728,12 +1913,11 @@ ohci_open(pipe) } opipe->tail.td = std; tdphys = std->physaddr; - fmt = OHCI_ED_FORMAT_GEN; + fmt = OHCI_ED_FORMAT_GEN | OHCI_ED_DIR_TD; } sed->ed.ed_flags = htole32( OHCI_ED_SET_FA(addr) | OHCI_ED_SET_EN(ed->bEndpointAddress) | - OHCI_ED_DIR_TD | (dev->lowspeed ? OHCI_ED_SPEED : 0) | fmt | OHCI_ED_SET_MAXP(UGETW(ed->wMaxPacketSize))); sed->ed.ed_headp = sed->ed.ed_tailp = htole32(tdphys); @@ -1906,7 +2090,7 @@ ohci_abort_xfer_end(v) /* * Data structures and routines to emulate the root hub. */ -static usb_device_descriptor_t ohci_devd = { +Static usb_device_descriptor_t ohci_devd = { USB_DEVICE_DESCRIPTOR_SIZE, UDESC_DEVICE, /* type */ {0x00, 0x01}, /* USB version */ @@ -1919,7 +2103,7 @@ static usb_device_descriptor_t ohci_devd = { 1 /* # of configurations */ }; -static usb_config_descriptor_t ohci_confd = { +Static usb_config_descriptor_t ohci_confd = { USB_CONFIG_DESCRIPTOR_SIZE, UDESC_CONFIG, {USB_CONFIG_DESCRIPTOR_SIZE + @@ -1932,7 +2116,7 @@ static usb_config_descriptor_t ohci_confd = { 0 /* max power */ }; -static usb_interface_descriptor_t ohci_ifcd = { +Static usb_interface_descriptor_t ohci_ifcd = { USB_INTERFACE_DESCRIPTOR_SIZE, UDESC_INTERFACE, 0, @@ -1944,7 +2128,7 @@ static usb_interface_descriptor_t ohci_ifcd = { 0 }; -static usb_endpoint_descriptor_t ohci_endpd = { +Static usb_endpoint_descriptor_t ohci_endpd = { USB_ENDPOINT_DESCRIPTOR_SIZE, UDESC_ENDPOINT, UE_DIR_IN | OHCI_INTR_ENDPT, @@ -1953,7 +2137,7 @@ static usb_endpoint_descriptor_t ohci_endpd = { 255 }; -static usb_hub_descriptor_t ohci_hubd = { +Static usb_hub_descriptor_t ohci_hubd = { USB_HUB_DESCRIPTOR_SIZE, UDESC_HUB, 0, @@ -1963,7 +2147,7 @@ static usb_hub_descriptor_t ohci_hubd = { {0}, }; -static int +Static int ohci_str(p, l, s) usb_string_descriptor_t *p; int l; @@ -1986,7 +2170,7 @@ ohci_str(p, l, s) /* * Simulate a hardware hub by handling all the necessary requests. */ -static usbd_status +Static usbd_status ohci_root_ctrl_transfer(xfer) usbd_xfer_handle xfer; { @@ -2001,7 +2185,7 @@ ohci_root_ctrl_transfer(xfer) return (ohci_root_ctrl_start(SIMPLEQ_FIRST(&xfer->pipe->queue))); } -static usbd_status +Static usbd_status ohci_root_ctrl_start(xfer) usbd_xfer_handle xfer; { @@ -2015,6 +2199,9 @@ ohci_root_ctrl_start(xfer) usbd_status err; u_int32_t v; + if (sc->sc_dying) + return (USBD_IOERROR); + #ifdef DIAGNOSTIC if (!(xfer->rqflags & URQ_REQUEST)) /* XXX panic */ @@ -2301,7 +2488,7 @@ ohci_root_ctrl_start(xfer) } /* Abort a root control request. */ -static void +Static void ohci_root_ctrl_abort(xfer) usbd_xfer_handle xfer; { @@ -2309,7 +2496,7 @@ ohci_root_ctrl_abort(xfer) } /* Close the root pipe. */ -static void +Static void ohci_root_ctrl_close(pipe) usbd_pipe_handle pipe; { @@ -2317,7 +2504,7 @@ ohci_root_ctrl_close(pipe) /* Nothing to do. */ } -static usbd_status +Static usbd_status ohci_root_intr_transfer(xfer) usbd_xfer_handle xfer; { @@ -2332,20 +2519,23 @@ ohci_root_intr_transfer(xfer) return (ohci_root_intr_start(SIMPLEQ_FIRST(&xfer->pipe->queue))); } -static usbd_status +Static usbd_status ohci_root_intr_start(xfer) usbd_xfer_handle xfer; { usbd_pipe_handle pipe = xfer->pipe; ohci_softc_t *sc = (ohci_softc_t *)pipe->device->bus; + if (sc->sc_dying) + return (USBD_IOERROR); + sc->sc_intrxfer = xfer; return (USBD_IN_PROGRESS); } /* Abort a root interrupt request. */ -static void +Static void ohci_root_intr_abort(xfer) usbd_xfer_handle xfer; { @@ -2362,7 +2552,7 @@ ohci_root_intr_abort(xfer) } /* Close the root pipe. */ -static void +Static void ohci_root_intr_close(pipe) usbd_pipe_handle pipe; { @@ -2375,7 +2565,7 @@ ohci_root_intr_close(pipe) /************************/ -static usbd_status +Static usbd_status ohci_device_ctrl_transfer(xfer) usbd_xfer_handle xfer; { @@ -2390,13 +2580,16 @@ ohci_device_ctrl_transfer(xfer) return (ohci_device_ctrl_start(SIMPLEQ_FIRST(&xfer->pipe->queue))); } -static usbd_status +Static usbd_status ohci_device_ctrl_start(xfer) usbd_xfer_handle xfer; { ohci_softc_t *sc = (ohci_softc_t *)xfer->pipe->device->bus; usbd_status err; + if (sc->sc_dying) + return (USBD_IOERROR); + #ifdef DIAGNOSTIC if (!(xfer->rqflags & URQ_REQUEST)) { /* XXX panic */ @@ -2415,7 +2608,7 @@ ohci_device_ctrl_start(xfer) } /* Abort a device control request. */ -static void +Static void ohci_device_ctrl_abort(xfer) usbd_xfer_handle xfer; { @@ -2424,7 +2617,7 @@ ohci_device_ctrl_abort(xfer) } /* Close a device control pipe. */ -static void +Static void ohci_device_ctrl_close(pipe) usbd_pipe_handle pipe; { @@ -2438,7 +2631,7 @@ ohci_device_ctrl_close(pipe) /************************/ -static void +Static void ohci_device_clear_toggle(pipe) usbd_pipe_handle pipe; { @@ -2447,13 +2640,13 @@ ohci_device_clear_toggle(pipe) opipe->sed->ed.ed_headp &= htole32(~OHCI_TOGGLECARRY); } -static void +Static void ohci_noop(pipe) usbd_pipe_handle pipe; { } -static usbd_status +Static usbd_status ohci_device_bulk_transfer(xfer) usbd_xfer_handle xfer; { @@ -2468,7 +2661,7 @@ ohci_device_bulk_transfer(xfer) return (ohci_device_bulk_start(SIMPLEQ_FIRST(&xfer->pipe->queue))); } -static usbd_status +Static usbd_status ohci_device_bulk_start(xfer) usbd_xfer_handle xfer; { @@ -2481,6 +2674,9 @@ ohci_device_bulk_start(xfer) int s, len, isread, endpt; usbd_status err; + if (sc->sc_dying) + return (USBD_IOERROR); + #ifdef DIAGNOSTIC if (xfer->rqflags & URQ_REQUEST) { /* XXX panic */ @@ -2565,7 +2761,7 @@ ohci_device_bulk_start(xfer) return (USBD_IN_PROGRESS); } -static void +Static void ohci_device_bulk_abort(xfer) usbd_xfer_handle xfer; { @@ -2576,7 +2772,7 @@ ohci_device_bulk_abort(xfer) /* * Close a device bulk pipe. */ -static void +Static void ohci_device_bulk_close(pipe) usbd_pipe_handle pipe; { @@ -2590,7 +2786,7 @@ ohci_device_bulk_close(pipe) /************************/ -static usbd_status +Static usbd_status ohci_device_intr_transfer(xfer) usbd_xfer_handle xfer; { @@ -2605,7 +2801,7 @@ ohci_device_intr_transfer(xfer) return (ohci_device_intr_start(SIMPLEQ_FIRST(&xfer->pipe->queue))); } -static usbd_status +Static usbd_status ohci_device_intr_start(xfer) usbd_xfer_handle xfer; { @@ -2617,6 +2813,9 @@ ohci_device_intr_start(xfer) int len; int s; + if (sc->sc_dying) + return (USBD_IOERROR); + DPRINTFN(3, ("ohci_device_intr_transfer: xfer=%p len=%d " "flags=%d priv=%p\n", xfer, xfer->length, xfer->flags, xfer->priv)); @@ -2682,7 +2881,7 @@ ohci_device_intr_start(xfer) } /* Abort a device control request. */ -static void +Static void ohci_device_intr_abort(xfer) usbd_xfer_handle xfer; { @@ -2694,7 +2893,7 @@ ohci_device_intr_abort(xfer) } /* Close a device interrupt pipe. */ -static void +Static void ohci_device_intr_close(pipe) usbd_pipe_handle pipe; { @@ -2731,7 +2930,7 @@ ohci_device_intr_close(pipe) ohci_free_sed(sc, opipe->sed); } -static usbd_status +Static usbd_status ohci_device_setintr(sc, opipe, ival) ohci_softc_t *sc; struct ohci_pipe *opipe; @@ -2818,7 +3017,7 @@ ohci_device_isoc_transfer(xfer) /* insert into schedule, */ ohci_device_isoc_enter(xfer); - /* and put on interrupt list if the pipe wasn't running */ + /* and start if the pipe wasn't running */ if (!err) ohci_device_isoc_start(SIMPLEQ_FIRST(&xfer->pipe->queue)); @@ -2835,89 +3034,215 @@ ohci_device_isoc_enter(xfer) ohci_soft_ed_t *sed = opipe->sed; struct iso *iso = &opipe->u.iso; ohci_soft_itd_t *sitd, *nsitd; - ohci_physaddr_t buf, offs; + ohci_physaddr_t buf, offs, noffs, bp0; int i, ncur, nframes; - int ncross; int s; - s = splusb(); + DPRINTFN(1,("ohci_device_isoc_enter: used=%d next=%d xfer=%p " + "nframes=%d\n", + iso->inuse, iso->next, xfer, xfer->nframes)); + + if (sc->sc_dying) + return; + + if (iso->next == -1) { + /* Not in use yet, schedule it a few frames ahead. */ + iso->next = le32toh(sc->sc_hcca->hcca_frame_number) + 5; + DPRINTFN(2,("ohci_device_isoc_enter: start next=%d\n", + iso->next)); + } + sitd = opipe->tail.itd; buf = DMAADDR(&xfer->dmabuf); - sitd->itd.itd_bp0 = htole32(buf & OHCI_ITD_PAGE_MASK); + bp0 = OHCI_PAGE(buf); + offs = OHCI_PAGE_OFFSET(buf); nframes = xfer->nframes; - offs = buf & OHCI_ITD_OFFSET_MASK; - ncross = 0; + xfer->hcpriv = sitd; for (i = ncur = 0; i < nframes; i++, ncur++) { + noffs = offs + xfer->frlengths[i]; if (ncur == OHCI_ITD_NOFFSET || /* all offsets used */ - ncross > 1) { /* too many page crossings */ + OHCI_PAGE(buf + noffs) > bp0 + OHCI_PAGE_SIZE) { /* too many page crossings */ + /* Allocate next ITD */ nsitd = ohci_alloc_sitd(sc); if (nsitd == NULL) { /* XXX what now? */ + printf("%s: isoc TD alloc failed\n", + USBDEVNAME(sc->sc_bus.bdev)); return; } - sitd->nextitd = nsitd; - sitd->itd.itd_nextitd = htole32(nsitd->physaddr); + + /* Fill current ITD */ sitd->itd.itd_flags = htole32( OHCI_ITD_NOCC | OHCI_ITD_SET_SF(iso->next) | - OHCI_ITD_NOINTR | - OHCI_ITD_SET_FC(OHCI_ITD_NOFFSET)); - sitd->itd.itd_be = htole32( - le32toh(sitd->itd.itd_bp0) + offs - 1); - nsitd->itd.itd_bp0 = htole32( - (buf + offs) & OHCI_ITD_PAGE_MASK); + OHCI_ITD_SET_DI(6) | /* delay intr a little */ + OHCI_ITD_SET_FC(ncur)); + sitd->itd.itd_bp0 = htole32(bp0); + sitd->nextitd = nsitd; + sitd->itd.itd_nextitd = htole32(nsitd->physaddr); + sitd->itd.itd_be = htole32(bp0 + offs - 1); + sitd->xfer = xfer; + sitd->flags = 0; + sitd = nsitd; iso->next = iso->next + ncur; + bp0 = OHCI_PAGE(buf + offs); ncur = 0; - ncross = 0; } - /* XXX byte order */ - sitd->itd.itd_offset[i] = - offs | (ncross == 1 ? OHCI_ITD_PAGE_SELECT : 0); - offs += xfer->frlengths[i]; - /* XXX update ncross */ + sitd->itd.itd_offset[ncur] = htole16(OHCI_ITD_MK_OFFS(offs)); + offs = noffs; } nsitd = ohci_alloc_sitd(sc); if (nsitd == NULL) { /* XXX what now? */ + printf("%s: isoc TD alloc failed\n", + USBDEVNAME(sc->sc_bus.bdev)); return; } - sitd->nextitd = nsitd; - sitd->itd.itd_nextitd = htole32(nsitd->physaddr); - sitd->itd.itd_flags = le32toh( + /* Fixup last used ITD */ + sitd->itd.itd_flags = htole32( OHCI_ITD_NOCC | OHCI_ITD_SET_SF(iso->next) | OHCI_ITD_SET_DI(0) | OHCI_ITD_SET_FC(ncur)); - sitd->itd.itd_be = htole32(le32toh(sitd->itd.itd_bp0) + offs - 1); + sitd->itd.itd_bp0 = htole32(bp0); + sitd->nextitd = nsitd; + sitd->itd.itd_nextitd = htole32(nsitd->physaddr); + sitd->itd.itd_be = htole32(bp0 + offs - 1); + sitd->xfer = xfer; + sitd->flags = OHCI_CALL_DONE; + iso->next = iso->next + ncur; + iso->inuse += nframes; + + xfer->actlen = offs; /* XXX pretend we did it all */ + + xfer->status = USBD_IN_PROGRESS; + +#ifdef OHCI_DEBUG + if (ohcidebug > 5) { + DPRINTF(("ohci_device_isoc_enter: frame=%d\n", + le32toh(sc->sc_hcca->hcca_frame_number))); + ohci_dump_itds(xfer->hcpriv); + ohci_dump_ed(sed); + } +#endif + s = splusb(); opipe->tail.itd = nsitd; sed->ed.ed_tailp = htole32(nsitd->physaddr); - /* XXX update ED */ splx(s); + +#ifdef OHCI_DEBUG + if (ohcidebug > 5) { + delay(150000); + DPRINTF(("ohci_device_isoc_enter: after frame=%d\n", + le32toh(sc->sc_hcca->hcca_frame_number))); + ohci_dump_itds(xfer->hcpriv); + ohci_dump_ed(sed); + } +#endif } usbd_status ohci_device_isoc_start(xfer) usbd_xfer_handle xfer; { - printf("ohci_device_isoc_start: not implemented\n"); - return (USBD_INVAL); + struct ohci_pipe *opipe = (struct ohci_pipe *)xfer->pipe; + ohci_softc_t *sc = (ohci_softc_t *)opipe->pipe.device->bus; + + DPRINTFN(5,("ohci_device_isoc_start: xfer=%p\n", xfer)); + + if (sc->sc_dying) + return (USBD_IOERROR); + +#ifdef DIAGNOSTIC + if (xfer->status != USBD_IN_PROGRESS) + printf("uhci_device_isoc_start: not in progress %p\n", xfer); +#endif + + /* XXX anything to do? */ + + return (USBD_IN_PROGRESS); } void ohci_device_isoc_abort(xfer) usbd_xfer_handle xfer; { + struct ohci_pipe *opipe = (struct ohci_pipe *)xfer->pipe; + ohci_softc_t *sc = (ohci_softc_t *)opipe->pipe.device->bus; + ohci_soft_ed_t *sed; + ohci_soft_itd_t *sitd; + int s; + + s = splusb(); + + DPRINTFN(1,("ohci_device_isoc_abort: xfer=%p\n", xfer)); + + /* Transfer is already done. */ + if (xfer->status != USBD_NOT_STARTED && + xfer->status != USBD_IN_PROGRESS) { + splx(s); + printf("ohci_device_isoc_abort: early return\n"); + return; + } + + /* Give xfer the requested abort code. */ + xfer->status = USBD_CANCELLED; + + sed = opipe->sed; + sed->ed.ed_flags |= htole32(OHCI_ED_SKIP); /* force hardware skip */ + + sitd = xfer->hcpriv; +#ifdef DIAGNOSTIC + if (sitd == NULL) { + printf("ohci_device_isoc_abort: hcpriv==0\n"); + return; + } +#endif + for (; sitd->xfer == xfer; sitd = sitd->nextitd) { +#ifdef DIAGNOSTIC + DPRINTFN(1,("abort sets done sitd=%p\n", sitd)); + sitd->isdone = 1; +#endif + } + + splx(s); + + usb_delay_ms(&sc->sc_bus, OHCI_ITD_NOFFSET); + + s = splusb(); + + /* Run callback. */ + usb_transfer_complete(xfer); + + sed->ed.ed_headp = htole32(sitd->physaddr); /* unlink TDs */ + sed->ed.ed_flags &= htole32(~OHCI_ED_SKIP); /* remove hardware skip */ + + splx(s); } void ohci_device_isoc_done(xfer) usbd_xfer_handle xfer; { - printf("ohci_device_isoc_done: not implemented\n"); + struct ohci_pipe *opipe = (struct ohci_pipe *)xfer->pipe; + ohci_softc_t *sc = (ohci_softc_t *)opipe->pipe.device->bus; + ohci_soft_itd_t *sitd, *nsitd; + + DPRINTFN(1,("ohci_device_isoc_done: xfer=%p\n", xfer)); + + for (sitd = xfer->hcpriv; + !(sitd->flags & OHCI_CALL_DONE); + sitd = nsitd) { + nsitd = sitd->nextitd; + DPRINTFN(1,("ohci_device_isoc_done: free sitd=%p\n", sitd)); + ohci_free_sitd(sc, sitd); + } + ohci_free_sitd(sc, sitd); + xfer->hcpriv = NULL; } usbd_status @@ -2925,11 +3250,17 @@ ohci_setup_isoc(pipe) usbd_pipe_handle pipe; { struct ohci_pipe *opipe = (struct ohci_pipe *)pipe; + ohci_softc_t *sc = (ohci_softc_t *)pipe->device->bus; struct iso *iso = &opipe->u.iso; + int s; iso->next = -1; iso->inuse = 0; + s = splusb(); + ohci_add_ed(opipe->sed, sc->sc_isoc_head); + splx(s); + return (USBD_NORMAL_COMPLETION); } @@ -2939,8 +3270,16 @@ ohci_device_isoc_close(pipe) { struct ohci_pipe *opipe = (struct ohci_pipe *)pipe; ohci_softc_t *sc = (ohci_softc_t *)pipe->device->bus; + int s; DPRINTF(("ohci_device_isoc_close: pipe=%p\n", pipe)); + + s = splusb(); + ohci_rem_ed(opipe->sed, sc->sc_isoc_head); + splx(s); ohci_close_pipe(pipe, sc->sc_isoc_head); +#ifdef DIAGNOSTIC + opipe->tail.itd->isdone = 1; +#endif ohci_free_sitd(sc, opipe->tail.itd); } diff --git a/sys/dev/usb/ohcireg.h b/sys/dev/usb/ohcireg.h index c40926579a2..d1297204b68 100644 --- a/sys/dev/usb/ohcireg.h +++ b/sys/dev/usb/ohcireg.h @@ -1,5 +1,5 @@ -/* $OpenBSD: ohcireg.h,v 1.5 2000/03/28 19:37:48 aaron Exp $ */ -/* $NetBSD: ohcireg.h,v 1.15 2000/03/19 22:24:58 augustss Exp $ */ +/* $OpenBSD: ohcireg.h,v 1.6 2000/03/30 16:19:32 aaron Exp $ */ +/* $NetBSD: ohcireg.h,v 1.16 2000/03/29 01:46:27 augustss Exp $ */ /* $FreeBSD: src/sys/dev/usb/ohcireg.h,v 1.8 1999/11/17 22:33:40 n_hibma Exp $ */ @@ -147,6 +147,7 @@ struct ohci_hcca { #define OHCI_PAGE_SIZE 0x1000 #define OHCI_PAGE(x) ((x) &~ 0xfff) +#define OHCI_PAGE_OFFSET(x) ((x) & 0xfff) typedef struct { u_int32_t ed_flags; @@ -214,13 +215,12 @@ typedef struct { #define OHCI_ITD_GET_CC(x) ((x) >> 28) /* Condition Code */ #define OHCI_ITD_NOCC 0xf0000000 ohci_physaddr_t itd_bp0; /* Buffer Page 0 */ -#define OHCI_ITD_OFFSET_MASK 0x00000fff -#define OHCI_ITD_PAGE_MASK (~OHCI_ITD_OFFSET_MASK) ohci_physaddr_t itd_nextitd; /* Next ITD */ ohci_physaddr_t itd_be; /* Buffer End */ u_int16_t itd_offset[OHCI_ITD_NOFFSET]; /* Buffer offsets */ #define itd_pswn itd_offset /* Packet Status Word*/ #define OHCI_ITD_PAGE_SELECT 0x00001000 +#define OHCI_ITD_MK_OFFS(len) (0xe000 | ((len) & 0x1fff)) #define OHCI_ITD_PSW_LENGTH(x) ((x) & 0xfff) /* Transfer length */ #define OHCI_ITD_PSW_GET_CC(x) ((x) >> 12) /* Condition Code */ } ohci_itd_t; diff --git a/sys/dev/usb/ohcivar.h b/sys/dev/usb/ohcivar.h index e1f310171cf..0a0f09d4b0e 100644 --- a/sys/dev/usb/ohcivar.h +++ b/sys/dev/usb/ohcivar.h @@ -1,5 +1,5 @@ -/* $OpenBSD: ohcivar.h,v 1.8 2000/03/28 19:37:48 aaron Exp $ */ -/* $NetBSD: ohcivar.h,v 1.20 2000/02/22 11:30:55 augustss Exp $ */ +/* $OpenBSD: ohcivar.h,v 1.9 2000/03/30 16:19:33 aaron Exp $ */ +/* $NetBSD: ohcivar.h,v 1.21 2000/03/29 01:46:27 augustss Exp $ */ /* $FreeBSD: src/sys/dev/usb/ohcivar.h,v 1.13 1999/11/17 22:33:41 n_hibma Exp $ */ /* @@ -47,6 +47,7 @@ typedef struct ohci_soft_ed { #define OHCI_SED_SIZE ((sizeof (struct ohci_soft_ed) + OHCI_ED_ALIGN - 1) / OHCI_ED_ALIGN * OHCI_ED_ALIGN) #define OHCI_SED_CHUNK 128 + typedef struct ohci_soft_td { ohci_td_t td; struct ohci_soft_td *nexttd; /* mirrors nexttd in TD */ @@ -62,14 +63,23 @@ typedef struct ohci_soft_td { #define OHCI_STD_SIZE ((sizeof (struct ohci_soft_td) + OHCI_TD_ALIGN - 1) / OHCI_TD_ALIGN * OHCI_TD_ALIGN) #define OHCI_STD_CHUNK 128 + typedef struct ohci_soft_itd { ohci_itd_t itd; struct ohci_soft_itd *nextitd; /* mirrors nexttd in ITD */ + struct ohci_soft_itd *dnext; /* next in done list */ ohci_physaddr_t physaddr; + LIST_ENTRY(ohci_soft_itd) hnext; + usbd_xfer_handle xfer; + u_int16_t flags; +#ifdef DIAGNOSTIC + char isdone; +#endif } ohci_soft_itd_t; #define OHCI_SITD_SIZE ((sizeof (struct ohci_soft_itd) + OHCI_ITD_ALIGN - 1) / OHCI_ITD_ALIGN * OHCI_ITD_ALIGN) #define OHCI_SITD_CHUNK 64 + #define OHCI_NO_EDS (2*OHCI_NO_INTRS-1) #define OHCI_HASH_SIZE 128 @@ -89,7 +99,8 @@ typedef struct ohci_softc { ohci_soft_ed_t *sc_ctrl_head; ohci_soft_ed_t *sc_bulk_head; - LIST_HEAD(, ohci_soft_td) sc_hash_tds[OHCI_HASH_SIZE]; + LIST_HEAD(, ohci_soft_td) sc_hash_tds[OHCI_HASH_SIZE]; + LIST_HEAD(, ohci_soft_itd) sc_hash_itds[OHCI_HASH_SIZE]; int sc_noport; u_int8_t sc_addr; /* device address */ @@ -103,7 +114,8 @@ typedef struct ohci_softc { usbd_xfer_handle sc_intrxfer; - ohci_physaddr_t sc_done; + ohci_soft_itd_t *sc_sidone; + ohci_soft_td_t *sc_sdone; char sc_vendor[16]; int sc_id_vendor; @@ -114,6 +126,8 @@ typedef struct ohci_softc { #endif device_ptr_t sc_child; + + char sc_dying; } ohci_softc_t; usbd_status ohci_init __P((ohci_softc_t *)); diff --git a/sys/dev/usb/uaudio.c b/sys/dev/usb/uaudio.c index 27dee78b7b8..d579aebc15d 100644 --- a/sys/dev/usb/uaudio.c +++ b/sys/dev/usb/uaudio.c @@ -1,5 +1,5 @@ -/* $OpenBSD: uaudio.c,v 1.3 2000/03/28 19:37:49 aaron Exp $ */ -/* $NetBSD: uaudio.c,v 1.20 2000/03/24 13:02:00 augustss Exp $ */ +/* $OpenBSD: uaudio.c,v 1.4 2000/03/30 16:19:33 aaron Exp $ */ +/* $NetBSD: uaudio.c,v 1.23 2000/03/29 18:24:53 augustss Exp $ */ /* * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -79,7 +79,7 @@ int uaudiodebug = 0; #define DPRINTFN(n,x) #endif -#define UAUDIO_NCHANBUFS 5 /* number of outstanding request */ +#define UAUDIO_NCHANBUFS 6 /* number of outstanding request */ #define UAUDIO_NFRAMES 20 /* ms of sound in each request */ @@ -180,105 +180,105 @@ struct uaudio_softc { #define UAC_INPUT 1 #define UAC_EQUAL 2 -static usbd_status uaudio_identify_ac __P((struct uaudio_softc *sc, +Static usbd_status uaudio_identify_ac __P((struct uaudio_softc *sc, usb_config_descriptor_t *cdesc)); -static usbd_status uaudio_identify_as __P((struct uaudio_softc *sc, +Static usbd_status uaudio_identify_as __P((struct uaudio_softc *sc, usb_config_descriptor_t *cdesc)); -static usbd_status uaudio_process_as __P((struct uaudio_softc *sc, +Static usbd_status uaudio_process_as __P((struct uaudio_softc *sc, char *buf, int *offsp, int size, usb_interface_descriptor_t *id)); -static void uaudio_add_alt __P((struct uaudio_softc *sc, +Static void uaudio_add_alt __P((struct uaudio_softc *sc, struct as_info *ai)); -static usb_interface_descriptor_t *uaudio_find_iface +Static usb_interface_descriptor_t *uaudio_find_iface __P((char *buf, int size, int *offsp, int subtype)); -static void uaudio_mixer_add_ctl __P((struct uaudio_softc *sc, +Static void uaudio_mixer_add_ctl __P((struct uaudio_softc *sc, struct mixerctl *mp)); -static char *uaudio_id_name __P((struct uaudio_softc *sc, +Static char *uaudio_id_name __P((struct uaudio_softc *sc, usb_descriptor_t **dps, int id)); -static struct usb_audio_cluster uaudio_get_cluster __P((int id, +Static struct usb_audio_cluster uaudio_get_cluster __P((int id, usb_descriptor_t **dps)); -static void uaudio_add_input __P((struct uaudio_softc *sc, +Static void uaudio_add_input __P((struct uaudio_softc *sc, usb_descriptor_t *v, usb_descriptor_t **dps)); -static void uaudio_add_output __P((struct uaudio_softc *sc, +Static void uaudio_add_output __P((struct uaudio_softc *sc, usb_descriptor_t *v, usb_descriptor_t **dps)); -static void uaudio_add_mixer __P((struct uaudio_softc *sc, +Static void uaudio_add_mixer __P((struct uaudio_softc *sc, usb_descriptor_t *v, usb_descriptor_t **dps)); -static void uaudio_add_selector __P((struct uaudio_softc *sc, +Static void uaudio_add_selector __P((struct uaudio_softc *sc, usb_descriptor_t *v, usb_descriptor_t **dps)); -static void uaudio_add_feature __P((struct uaudio_softc *sc, +Static void uaudio_add_feature __P((struct uaudio_softc *sc, usb_descriptor_t *v, usb_descriptor_t **dps)); -static void uaudio_add_processing_updown +Static void uaudio_add_processing_updown __P((struct uaudio_softc *sc, usb_descriptor_t *v, usb_descriptor_t **dps)); -static void uaudio_add_processing __P((struct uaudio_softc *sc, +Static void uaudio_add_processing __P((struct uaudio_softc *sc, usb_descriptor_t *v, usb_descriptor_t **dps)); -static void uaudio_add_extension __P((struct uaudio_softc *sc, +Static void uaudio_add_extension __P((struct uaudio_softc *sc, usb_descriptor_t *v, usb_descriptor_t **dps)); -static usbd_status uaudio_identify __P((struct uaudio_softc *sc, +Static usbd_status uaudio_identify __P((struct uaudio_softc *sc, usb_config_descriptor_t *cdesc)); -static int uaudio_signext __P((int type, int val)); -static int uaudio_value2bsd __P((struct mixerctl *mc, int val)); -static int uaudio_bsd2value __P((struct mixerctl *mc, int val)); -static int uaudio_get __P((struct uaudio_softc *sc, int type, +Static int uaudio_signext __P((int type, int val)); +Static int uaudio_value2bsd __P((struct mixerctl *mc, int val)); +Static int uaudio_bsd2value __P((struct mixerctl *mc, int val)); +Static int uaudio_get __P((struct uaudio_softc *sc, int type, int which, int wValue, int wIndex, int len)); -static int uaudio_ctl_get __P((struct uaudio_softc *sc, int which, +Static int uaudio_ctl_get __P((struct uaudio_softc *sc, int which, struct mixerctl *mc, int chan)); -static void uaudio_set __P((struct uaudio_softc *sc, int type, +Static void uaudio_set __P((struct uaudio_softc *sc, int type, int which, int wValue, int wIndex, int l, int v)); -static void uaudio_ctl_set __P((struct uaudio_softc *sc, int which, +Static void uaudio_ctl_set __P((struct uaudio_softc *sc, int which, struct mixerctl *mc, int chan, int val)); -static usbd_status uaudio_set_speed __P((struct uaudio_softc *, int, +Static usbd_status uaudio_set_speed __P((struct uaudio_softc *, int, u_int)); -static usbd_status uaudio_chan_open __P((struct uaudio_softc *sc, +Static usbd_status uaudio_chan_open __P((struct uaudio_softc *sc, struct chan *ch)); -static void uaudio_chan_close __P((struct uaudio_softc *sc, +Static void uaudio_chan_close __P((struct uaudio_softc *sc, struct chan *ch)); -static usbd_status uaudio_chan_alloc_buffers __P((struct uaudio_softc *, +Static usbd_status uaudio_chan_alloc_buffers __P((struct uaudio_softc *, struct chan *)); -static void uaudio_chan_free_buffers __P((struct uaudio_softc *, +Static void uaudio_chan_free_buffers __P((struct uaudio_softc *, struct chan *)); -static void uaudio_chan_set_param __P((struct chan *ch, +Static void uaudio_chan_set_param __P((struct chan *ch, struct audio_params *param, u_char *start, u_char *end, int blksize)); -static void uaudio_chan_ptransfer __P((struct chan *ch)); -static void uaudio_chan_pintr __P((usbd_xfer_handle xfer, +Static void uaudio_chan_ptransfer __P((struct chan *ch)); +Static void uaudio_chan_pintr __P((usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)); -static void uaudio_chan_rtransfer __P((struct chan *ch)); -static void uaudio_chan_rintr __P((usbd_xfer_handle xfer, +Static void uaudio_chan_rtransfer __P((struct chan *ch)); +Static void uaudio_chan_rintr __P((usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)); -static int uaudio_open __P((void *, int)); -static void uaudio_close __P((void *)); -static int uaudio_drain __P((void *)); -static int uaudio_query_encoding __P((void *, +Static int uaudio_open __P((void *, int)); +Static void uaudio_close __P((void *)); +Static int uaudio_drain __P((void *)); +Static int uaudio_query_encoding __P((void *, struct audio_encoding *)); -static int uaudio_set_params __P((void *, int, int, +Static int uaudio_set_params __P((void *, int, int, struct audio_params *, struct audio_params *)); -static int uaudio_round_blocksize __P((void *, int)); -static int uaudio_trigger_output __P((void *, void *, void *, +Static int uaudio_round_blocksize __P((void *, int)); +Static int uaudio_trigger_output __P((void *, void *, void *, int, void (*)(void *), void *, struct audio_params *)); -static int uaudio_trigger_input __P((void *, void *, void *, +Static int uaudio_trigger_input __P((void *, void *, void *, int, void (*)(void *), void *, struct audio_params *)); -static int uaudio_halt_in_dma __P((void *)); -static int uaudio_halt_out_dma __P((void *)); -static int uaudio_getdev __P((void *, struct audio_device *)); -static int uaudio_mixer_set_port __P((void *, mixer_ctrl_t *)); -static int uaudio_mixer_get_port __P((void *, mixer_ctrl_t *)); -static int uaudio_query_devinfo __P((void *, mixer_devinfo_t *)); -static int uaudio_get_props __P((void *)); - -static struct audio_hw_if uaudio_hw_if = { +Static int uaudio_halt_in_dma __P((void *)); +Static int uaudio_halt_out_dma __P((void *)); +Static int uaudio_getdev __P((void *, struct audio_device *)); +Static int uaudio_mixer_set_port __P((void *, mixer_ctrl_t *)); +Static int uaudio_mixer_get_port __P((void *, mixer_ctrl_t *)); +Static int uaudio_query_devinfo __P((void *, mixer_devinfo_t *)); +Static int uaudio_get_props __P((void *)); + +Static struct audio_hw_if uaudio_hw_if = { uaudio_open, uaudio_close, uaudio_drain, @@ -307,7 +307,7 @@ static struct audio_hw_if uaudio_hw_if = { uaudio_trigger_input, }; -static struct audio_device uaudio_device = { +Static struct audio_device uaudio_device = { "USB audio", "", "uaudio" @@ -1798,7 +1798,7 @@ uaudio_trigger_input(addr, start, end, blksize, intr, arg, param) sc->sc_chan.arg = arg; s = splusb(); - for (i = 0; i < UAUDIO_NCHANBUFS; i++) + for (i = 0; i < UAUDIO_NCHANBUFS-1; i++) /* XXX -1 shouldn't be needed */ uaudio_chan_rtransfer(ch); splx(s); @@ -1844,7 +1844,7 @@ uaudio_trigger_output(addr, start, end, blksize, intr, arg, param) sc->sc_chan.arg = arg; s = splusb(); - for (i = 0; i < UAUDIO_NCHANBUFS; i++) + for (i = 0; i < UAUDIO_NCHANBUFS-1; i++) /* XXX */ uaudio_chan_ptransfer(ch); splx(s); diff --git a/sys/dev/usb/ugen.c b/sys/dev/usb/ugen.c index 7301f95b7e5..4b391760f82 100644 --- a/sys/dev/usb/ugen.c +++ b/sys/dev/usb/ugen.c @@ -1,5 +1,5 @@ -/* $OpenBSD: ugen.c,v 1.9 2000/03/28 19:37:49 aaron Exp $ */ -/* $NetBSD: ugen.c,v 1.36 2000/03/06 20:59:17 augustss Exp $ */ +/* $OpenBSD: ugen.c,v 1.10 2000/03/30 16:19:33 aaron Exp $ */ +/* $NetBSD: ugen.c,v 1.37 2000/03/27 12:33:55 augustss Exp $ */ /* $FreeBSD: src/sys/dev/usb/ugen.c,v 1.26 1999/11/17 22:33:41 n_hibma Exp $ */ /* @@ -119,7 +119,7 @@ d_poll_t ugenpoll; #define UGEN_CDEV_MAJOR 114 -static struct cdevsw ugen_cdevsw = { +Static struct cdevsw ugen_cdevsw = { /* open */ ugenopen, /* close */ ugenclose, /* read */ ugenread, @@ -137,18 +137,18 @@ static struct cdevsw ugen_cdevsw = { }; #endif -static void ugenintr __P((usbd_xfer_handle xfer, usbd_private_handle addr, +Static void ugenintr __P((usbd_xfer_handle xfer, usbd_private_handle addr, usbd_status status)); -static int ugen_do_read __P((struct ugen_softc *, int, struct uio *, int)); -static int ugen_do_write __P((struct ugen_softc *, int, struct uio *, int)); -static int ugen_do_ioctl __P((struct ugen_softc *, int, u_long, +Static int ugen_do_read __P((struct ugen_softc *, int, struct uio *, int)); +Static int ugen_do_write __P((struct ugen_softc *, int, struct uio *, int)); +Static int ugen_do_ioctl __P((struct ugen_softc *, int, u_long, caddr_t, int, struct proc *)); -static int ugen_set_config __P((struct ugen_softc *sc, int configno)); -static usb_config_descriptor_t *ugen_get_cdesc __P((struct ugen_softc *sc, +Static int ugen_set_config __P((struct ugen_softc *sc, int configno)); +Static usb_config_descriptor_t *ugen_get_cdesc __P((struct ugen_softc *sc, int index, int *lenp)); -static usbd_status ugen_set_interface __P((struct ugen_softc *, int, int)); -static int ugen_get_alt_index __P((struct ugen_softc *sc, int ifaceidx)); +Static usbd_status ugen_set_interface __P((struct ugen_softc *, int, int)); +Static int ugen_get_alt_index __P((struct ugen_softc *sc, int ifaceidx)); #define UGENUNIT(n) ((minor(n) >> 4) & 0xf) #define UGENENDPOINT(n) (minor(n) & 0xf) @@ -215,7 +215,7 @@ USB_ATTACH(ugen) USB_ATTACH_SUCCESS_RETURN; } -static int +Static int ugen_set_config(sc, configno) struct ugen_softc *sc; int configno; @@ -410,7 +410,7 @@ ugenclose(dev, flag, mode, p) return (0); } -static int +Static int ugen_do_read(sc, endpt, uio, flag) struct ugen_softc *sc; int endpt; @@ -538,7 +538,7 @@ ugenread(dev, uio, flag) return (error); } -static int +Static int ugen_do_write(sc, endpt, uio, flag) struct ugen_softc *sc; int endpt; @@ -694,7 +694,7 @@ USB_DETACH(ugen) return (0); } -static void +Static void ugenintr(xfer, addr, status) usbd_xfer_handle xfer; usbd_private_handle addr; @@ -732,7 +732,7 @@ ugenintr(xfer, addr, status) selwakeup(&sce->rsel); } -static usbd_status +Static usbd_status ugen_set_interface(sc, ifaceidx, altno) struct ugen_softc *sc; int ifaceidx, altno; @@ -789,7 +789,7 @@ ugen_set_interface(sc, ifaceidx, altno) } /* Retrieve a complete descriptor for a certain device and index. */ -static usb_config_descriptor_t * +Static usb_config_descriptor_t * ugen_get_cdesc(sc, index, lenp) struct ugen_softc *sc; int index; @@ -825,7 +825,7 @@ ugen_get_cdesc(sc, index, lenp) return (cdesc); } -static int +Static int ugen_get_alt_index(sc, ifaceidx) struct ugen_softc *sc; int ifaceidx; @@ -839,7 +839,7 @@ ugen_get_alt_index(sc, ifaceidx) return (usbd_get_interface_altindex(iface)); } -static int +Static int ugen_do_ioctl(sc, endpt, cmd, addr, flag, p) struct ugen_softc *sc; int endpt; diff --git a/sys/dev/usb/uhci.c b/sys/dev/usb/uhci.c index ca3fe32acea..23c8921ac92 100644 --- a/sys/dev/usb/uhci.c +++ b/sys/dev/usb/uhci.c @@ -1,5 +1,5 @@ -/* $OpenBSD: uhci.c,v 1.10 2000/03/28 19:37:49 aaron Exp $ */ -/* $NetBSD: uhci.c,v 1.100 2000/03/27 09:41:36 augustss Exp $ */ +/* $OpenBSD: uhci.c,v 1.11 2000/03/30 16:19:33 aaron Exp $ */ +/* $NetBSD: uhci.c,v 1.108 2000/03/29 18:55:36 augustss Exp $ */ /* $FreeBSD: src/sys/dev/usb/uhci.c,v 1.33 1999/11/17 22:33:41 n_hibma Exp $ */ /* @@ -152,116 +152,112 @@ struct uhci_pipe { } u; }; -static void uhci_busreset __P((uhci_softc_t *)); -static void uhci_shutdown __P((void *v)); -static void uhci_power __P((int, void *)); -static usbd_status uhci_run __P((uhci_softc_t *, int run)); -static uhci_soft_td_t *uhci_alloc_std __P((uhci_softc_t *)); -static void uhci_free_std __P((uhci_softc_t *, uhci_soft_td_t *)); -static uhci_soft_qh_t *uhci_alloc_sqh __P((uhci_softc_t *)); -static void uhci_free_sqh __P((uhci_softc_t *, uhci_soft_qh_t *)); +Static void uhci_busreset __P((uhci_softc_t *)); +Static void uhci_shutdown __P((void *v)); +Static void uhci_power __P((int, void *)); +Static usbd_status uhci_run __P((uhci_softc_t *, int run)); +Static uhci_soft_td_t *uhci_alloc_std __P((uhci_softc_t *)); +Static void uhci_free_std __P((uhci_softc_t *, uhci_soft_td_t *)); +Static uhci_soft_qh_t *uhci_alloc_sqh __P((uhci_softc_t *)); +Static void uhci_free_sqh __P((uhci_softc_t *, uhci_soft_qh_t *)); #if 0 -static void uhci_enter_ctl_q __P((uhci_softc_t *, uhci_soft_qh_t *, +Static void uhci_enter_ctl_q __P((uhci_softc_t *, uhci_soft_qh_t *, uhci_intr_info_t *)); -static void uhci_exit_ctl_q __P((uhci_softc_t *, uhci_soft_qh_t *)); +Static void uhci_exit_ctl_q __P((uhci_softc_t *, uhci_soft_qh_t *)); #endif -static void uhci_free_std_chain __P((uhci_softc_t *, +Static void uhci_free_std_chain __P((uhci_softc_t *, uhci_soft_td_t *, uhci_soft_td_t *)); -static usbd_status uhci_alloc_std_chain __P((struct uhci_pipe *, +Static usbd_status uhci_alloc_std_chain __P((struct uhci_pipe *, uhci_softc_t *, int, int, u_int16_t, usb_dma_t *, uhci_soft_td_t **, uhci_soft_td_t **)); -static void uhci_poll_hub __P((void *)); -static void uhci_waitintr __P((uhci_softc_t *, +Static void uhci_poll_hub __P((void *)); +Static void uhci_waitintr __P((uhci_softc_t *, usbd_xfer_handle)); -static void uhci_check_intr __P((uhci_softc_t *, +Static void uhci_check_intr __P((uhci_softc_t *, uhci_intr_info_t *)); -static void uhci_idone __P((uhci_intr_info_t *)); +Static void uhci_idone __P((uhci_intr_info_t *)); -static void uhci_abort_xfer __P((usbd_xfer_handle, +Static void uhci_abort_xfer __P((usbd_xfer_handle, usbd_status status)); -static void uhci_abort_xfer_end __P((void *v)); -static void uhci_abort_unlink_qh __P((struct uhci_pipe *)); -static void uhci_abort_relink_qh __P((struct uhci_pipe *)); -static void uhci_cancel_abort __P((usbd_pipe_handle)); - -static void uhci_timeout __P((void *)); -static void uhci_add_ctrl __P((uhci_softc_t *, uhci_soft_qh_t *)); -static void uhci_add_bulk __P((uhci_softc_t *, uhci_soft_qh_t *)); -static void uhci_remove_ctrl __P((uhci_softc_t *,uhci_soft_qh_t *)); -static void uhci_remove_bulk __P((uhci_softc_t *,uhci_soft_qh_t *)); -static int uhci_str __P((usb_string_descriptor_t *, int, char *)); - -static usbd_status uhci_setup_isoc __P((usbd_pipe_handle pipe)); -static void uhci_device_isoc_enter __P((usbd_xfer_handle)); - -static usbd_status uhci_allocm __P((struct usbd_bus *, usb_dma_t *, + +Static void uhci_timeout __P((void *)); +Static void uhci_add_ctrl __P((uhci_softc_t *, uhci_soft_qh_t *)); +Static void uhci_add_bulk __P((uhci_softc_t *, uhci_soft_qh_t *)); +Static void uhci_remove_ctrl __P((uhci_softc_t *,uhci_soft_qh_t *)); +Static void uhci_remove_bulk __P((uhci_softc_t *,uhci_soft_qh_t *)); +Static int uhci_str __P((usb_string_descriptor_t *, int, char *)); + +Static usbd_status uhci_setup_isoc __P((usbd_pipe_handle pipe)); +Static void uhci_device_isoc_enter __P((usbd_xfer_handle)); + +Static usbd_status uhci_allocm __P((struct usbd_bus *, usb_dma_t *, u_int32_t)); -static void uhci_freem __P((struct usbd_bus *, usb_dma_t *)); - -static usbd_xfer_handle uhci_allocx __P((struct usbd_bus *)); -static void uhci_freex __P((struct usbd_bus *, usbd_xfer_handle)); - -static usbd_status uhci_device_ctrl_transfer __P((usbd_xfer_handle)); -static usbd_status uhci_device_ctrl_start __P((usbd_xfer_handle)); -static void uhci_device_ctrl_abort __P((usbd_xfer_handle)); -static void uhci_device_ctrl_close __P((usbd_pipe_handle)); -static void uhci_device_ctrl_done __P((usbd_xfer_handle)); - -static usbd_status uhci_device_intr_transfer __P((usbd_xfer_handle)); -static usbd_status uhci_device_intr_start __P((usbd_xfer_handle)); -static void uhci_device_intr_abort __P((usbd_xfer_handle)); -static void uhci_device_intr_close __P((usbd_pipe_handle)); -static void uhci_device_intr_done __P((usbd_xfer_handle)); - -static usbd_status uhci_device_bulk_transfer __P((usbd_xfer_handle)); -static usbd_status uhci_device_bulk_start __P((usbd_xfer_handle)); -static void uhci_device_bulk_abort __P((usbd_xfer_handle)); -static void uhci_device_bulk_close __P((usbd_pipe_handle)); -static void uhci_device_bulk_done __P((usbd_xfer_handle)); - -static usbd_status uhci_device_isoc_transfer __P((usbd_xfer_handle)); -static usbd_status uhci_device_isoc_start __P((usbd_xfer_handle)); -static void uhci_device_isoc_abort __P((usbd_xfer_handle)); -static void uhci_device_isoc_close __P((usbd_pipe_handle)); -static void uhci_device_isoc_done __P((usbd_xfer_handle)); - -static usbd_status uhci_root_ctrl_transfer __P((usbd_xfer_handle)); -static usbd_status uhci_root_ctrl_start __P((usbd_xfer_handle)); -static void uhci_root_ctrl_abort __P((usbd_xfer_handle)); -static void uhci_root_ctrl_close __P((usbd_pipe_handle)); -static void uhci_root_ctrl_done __P((usbd_xfer_handle)); - -static usbd_status uhci_root_intr_transfer __P((usbd_xfer_handle)); -static usbd_status uhci_root_intr_start __P((usbd_xfer_handle)); -static void uhci_root_intr_abort __P((usbd_xfer_handle)); -static void uhci_root_intr_close __P((usbd_pipe_handle)); -static void uhci_root_intr_done __P((usbd_xfer_handle)); - -static usbd_status uhci_open __P((usbd_pipe_handle)); -static void uhci_poll __P((struct usbd_bus *)); -static void uhci_softintr __P((struct usbd_bus *)); - -static usbd_status uhci_device_request __P((usbd_xfer_handle xfer)); - -static void uhci_add_intr __P((uhci_softc_t *, uhci_soft_qh_t *)); -static void uhci_remove_intr __P((uhci_softc_t*, uhci_soft_qh_t*)); -static usbd_status uhci_device_setintr __P((uhci_softc_t *sc, +Static void uhci_freem __P((struct usbd_bus *, usb_dma_t *)); + +Static usbd_xfer_handle uhci_allocx __P((struct usbd_bus *)); +Static void uhci_freex __P((struct usbd_bus *, usbd_xfer_handle)); + +Static usbd_status uhci_device_ctrl_transfer __P((usbd_xfer_handle)); +Static usbd_status uhci_device_ctrl_start __P((usbd_xfer_handle)); +Static void uhci_device_ctrl_abort __P((usbd_xfer_handle)); +Static void uhci_device_ctrl_close __P((usbd_pipe_handle)); +Static void uhci_device_ctrl_done __P((usbd_xfer_handle)); + +Static usbd_status uhci_device_intr_transfer __P((usbd_xfer_handle)); +Static usbd_status uhci_device_intr_start __P((usbd_xfer_handle)); +Static void uhci_device_intr_abort __P((usbd_xfer_handle)); +Static void uhci_device_intr_close __P((usbd_pipe_handle)); +Static void uhci_device_intr_done __P((usbd_xfer_handle)); + +Static usbd_status uhci_device_bulk_transfer __P((usbd_xfer_handle)); +Static usbd_status uhci_device_bulk_start __P((usbd_xfer_handle)); +Static void uhci_device_bulk_abort __P((usbd_xfer_handle)); +Static void uhci_device_bulk_close __P((usbd_pipe_handle)); +Static void uhci_device_bulk_done __P((usbd_xfer_handle)); + +Static usbd_status uhci_device_isoc_transfer __P((usbd_xfer_handle)); +Static usbd_status uhci_device_isoc_start __P((usbd_xfer_handle)); +Static void uhci_device_isoc_abort __P((usbd_xfer_handle)); +Static void uhci_device_isoc_close __P((usbd_pipe_handle)); +Static void uhci_device_isoc_done __P((usbd_xfer_handle)); + +Static usbd_status uhci_root_ctrl_transfer __P((usbd_xfer_handle)); +Static usbd_status uhci_root_ctrl_start __P((usbd_xfer_handle)); +Static void uhci_root_ctrl_abort __P((usbd_xfer_handle)); +Static void uhci_root_ctrl_close __P((usbd_pipe_handle)); +Static void uhci_root_ctrl_done __P((usbd_xfer_handle)); + +Static usbd_status uhci_root_intr_transfer __P((usbd_xfer_handle)); +Static usbd_status uhci_root_intr_start __P((usbd_xfer_handle)); +Static void uhci_root_intr_abort __P((usbd_xfer_handle)); +Static void uhci_root_intr_close __P((usbd_pipe_handle)); +Static void uhci_root_intr_done __P((usbd_xfer_handle)); + +Static usbd_status uhci_open __P((usbd_pipe_handle)); +Static void uhci_poll __P((struct usbd_bus *)); +Static void uhci_softintr __P((struct usbd_bus *)); + +Static usbd_status uhci_device_request __P((usbd_xfer_handle xfer)); + +Static void uhci_add_intr __P((uhci_softc_t *, uhci_soft_qh_t *)); +Static void uhci_remove_intr __P((uhci_softc_t*, uhci_soft_qh_t*)); +Static usbd_status uhci_device_setintr __P((uhci_softc_t *sc, struct uhci_pipe *pipe, int ival)); -static void uhci_device_clear_toggle __P((usbd_pipe_handle pipe)); -static void uhci_noop __P((usbd_pipe_handle pipe)); +Static void uhci_device_clear_toggle __P((usbd_pipe_handle pipe)); +Static void uhci_noop __P((usbd_pipe_handle pipe)); -static __inline__ uhci_soft_qh_t *uhci_find_prev_qh +Static __inline__ uhci_soft_qh_t *uhci_find_prev_qh __P((uhci_soft_qh_t *, uhci_soft_qh_t *)); #ifdef UHCI_DEBUG -static void uhci_dumpregs __P((uhci_softc_t *)); -static void uhci_dump_qhs __P((uhci_soft_qh_t *)); -static void uhci_dump_qh __P((uhci_soft_qh_t *)); -static void uhci_dump_tds __P((uhci_soft_td_t *)); -static void uhci_dump_td __P((uhci_soft_td_t *)); -static void uhci_dump_ii __P((uhci_intr_info_t *ii)); +Static void uhci_dumpregs __P((uhci_softc_t *)); +Static void uhci_dump_qhs __P((uhci_soft_qh_t *)); +Static void uhci_dump_qh __P((uhci_soft_qh_t *)); +Static void uhci_dump_tds __P((uhci_soft_td_t *)); +Static void uhci_dump_td __P((uhci_soft_td_t *)); +Static void uhci_dump_ii __P((uhci_intr_info_t *ii)); #endif #define UWRITE1(sc, r, x) bus_space_write_1((sc)->iot, (sc)->ioh, (r), (x)) @@ -349,7 +345,7 @@ struct usbd_pipe_methods uhci_device_isoc_methods = { #define uhci_del_intr_info(ii) \ LIST_REMOVE((ii), list) -static __inline__ uhci_soft_qh_t * +Static __inline__ uhci_soft_qh_t * uhci_find_prev_qh(pqh, sqh) uhci_soft_qh_t *pqh, *sqh; { @@ -541,8 +537,32 @@ uhci_allocm(bus, dma, size) usb_dma_t *dma; u_int32_t size; { - return (usb_allocmem(&((struct uhci_softc *)bus)->sc_bus, size, 0, - dma)); + struct uhci_softc *sc = (struct uhci_softc *)bus; + u_int32_t n; + + /* + * XXX + * Since we are allocating a buffer we can assume that we will + * need TDs for it. Since we don't want to alolocate those from + * an interrupt context, we allocate them here and free them again. + * This is no guarantee that we'll get the TDs next time... + */ + n = size / 8; + if (n > 16) { + u_int32_t i; + uhci_soft_td_t **stds; + DPRINTF(("uhci_allocm: get %d TDs\n", n)); + stds = malloc(sizeof(uhci_soft_td_t *) * n, M_TEMP, M_NOWAIT); + memset(stds, 0, sizeof(uhci_soft_td_t *) * n); + for(i=0; i < n; i++) + stds[i] = uhci_alloc_std(sc); + for(i=0; i < n; i++) + if (stds[i] != NULL) + uhci_free_std(sc, stds[i]); + free(stds, M_TEMP); + } + + return (usb_allocmem(&sc->sc_bus, size, 0, dma)); } void @@ -599,8 +619,10 @@ uhci_freex(bus, xfer) return; } xfer->busy_free = XFER_FREE; - if (!UXFER(xfer)->iinfo.isdone) + if (!UXFER(xfer)->iinfo.isdone) { printf("uhci_freex: !isdone\n"); + return; + } #endif SIMPLEQ_INSERT_HEAD(&sc->sc_free_xfers, xfer, next); } @@ -695,7 +717,7 @@ uhci_power(why, v) } #ifdef UHCI_DEBUG -static void +Static void uhci_dumpregs(sc) uhci_softc_t *sc; { @@ -815,7 +837,7 @@ uhci_dump_tds(std) } } -static void +Static void uhci_dump_ii(ii) uhci_intr_info_t *ii; { @@ -1619,7 +1641,7 @@ uhci_device_bulk_start(xfer) #endif len = xfer->length; - endpt = xfer->pipe->endpoint->edesc->bEndpointAddress; + endpt = upipe->pipe.endpoint->edesc->bEndpointAddress; isread = UE_GET_DIR(endpt) == UE_DIR_IN; sqh = upipe->u.bulk.sqh; @@ -1687,73 +1709,20 @@ uhci_device_bulk_abort(xfer) } /* - * Aborting a xfer on the UHCI host controller is tricky. - * The problem is that the HC can asynchronously manipulate - * the very fields in the QH and TD that we need to abort a - * xfer. - * The problematic field are qh_elink (which points to the first - * TD) and td_status which contains the active flag. - * - * Here's my current (convoluted) strategy: - * - Block HC interrupt. We need this to check if the xfer - * might already be over. If called outside splusb() this can - * happen. - * - Check if an abort is already in progress (see below), if so - * just link out the xfer, run the callback, and return. - * - Otherwise, flag that abort is in progress. - * - Remove the QH for the xfer from the list of QHs (this - * can be done safely). - * - Remove the transaction from the list of transactions examined - * when the HC interrupts. - * At this point we know that the transaction will never be considered - * by the interrupt routine. The trouble we have is that the HC might - * be following the chain of TDs rooted at the unlinked QH because it - * started before the unlink. - * We would like to run the xfer callback function at this point - * to inform it that the xfer has been aborted, but running the - * callback might result in freeing the xfer. This would be bad - * since the HC might still use it. So we need to avoid this by: - * - Disable the active flag in all TD belonging to the xfer. - * If we do this we can guarantee that the HC will execute at most one - * TD after we turn off the flag in the last TD. - * - Busy-wait until the HC has finished with the TD. We do this by - * keeping track of the longest TD and using delay() for the time it - * takes to complete it (one byte takes a little less than 1 (LS 6) us). - * - Run the callback routine, since at this point the HC can not be - * using any TDs in the xfer. - * We still cannot manipulate the qh_elink field in the QH since the - * HC might be following TDs further down the chain for another 1 ms. - * So... - * - Set up a timeout 1 ms into the future. - * - Turn on interrupts. - * - Return. - * - * When the timeout happens we do the following: - * - Check if the qh_elink field points anywhere in the TD chain we had - * when the timeout was set up. If it is, leave qh_elink alone, - * otherwise set qh_elink pointing to the next (if any) xfer in - * the TD chain. - * - Link the QH back where we got it. - * - Turn off flag about abort in progress. - * Done! - * - * The timeout is associated with the pipe and it must be cancelled if - * the pipe is closed. + * XXX This way of aborting is neither safe, nor good. + * But it will have to do until I figure out what to do. + * I apologize for the delay(). */ - void uhci_abort_xfer(xfer, status) usbd_xfer_handle xfer; usbd_status status; { - struct uhci_pipe *upipe = (struct uhci_pipe *)xfer->pipe; uhci_intr_info_t *ii = &UXFER(xfer)->iinfo; uhci_soft_td_t *std; int s; - int len, maxlen; - DPRINTFN(1,("uhci_abort_xfer: xfer=%p, xfer->status=%d, status=%d\n", - xfer, xfer->status, status)); + DPRINTFN(1,("uhci_abort_xfer: xfer=%p, status=%d\n", xfer, status)); s = splusb(); @@ -1764,239 +1733,30 @@ uhci_abort_xfer(xfer, status) return; } - /* Give xfer the requested abort code. */ + /* Make interrupt routine ignore it, */ xfer->status = status; - /* If already aborting, bail out early. */ - if (upipe->aborting) { - /* Unlink the xfer from HC */ - /*XXX only one xfer for now*/ - printf("uhci_abort_xfer: abort while aborting\n"); - /* Finalize xfer. */ - usb_transfer_complete(xfer); - splx(s); - return; - } - - upipe->aborting = 1; - upipe->abortstart = SIMPLEQ_NEXT(xfer, next); - upipe->abortend = NULL; /* XXX only one xfer for now */ - - /* Remove QH(s) from HC schedule. */ - uhci_abort_unlink_qh(upipe); - - /* Remove intr_info from list is done by usb_transfer_complete() .*/ - - /* Disable active bit. */ - maxlen = 0; - for (std = ii->stdstart; std != NULL; std = std->link.std) { - std->td.td_status &= htole32(~(UHCI_TD_ACTIVE | UHCI_TD_IOC)); - len = UHCI_TD_GET_MAXLEN(std->td.td_token); - if (len > maxlen) - maxlen = len; - } - /* compute delay in us */ - if (upipe->pipe.device->lowspeed) - maxlen *= 6; - /* wait for HC to complete TDs */ - delay(maxlen); - - /* Don't timeout, */ + /* don't timeout, */ usb_uncallout(xfer->timeout_handle, uhci_timeout, ii); -#ifdef DIAGNOSTIC - UXFER(xfer)->iinfo.isdone = 1; -#endif - /* Run callback and remove from interrupt list. */ - usb_transfer_complete(xfer); + /* make hardware ignore it, */ + for (std = ii->stdstart; std != NULL; std = std->link.std) + std->td.td_status &= htole32(~(UHCI_TD_ACTIVE | UHCI_TD_IOC)); - /* Set up final processing. */ - usb_callout(xfer->pipe->abort_handle, hz / USB_FRAMES_PER_SECOND, - uhci_abort_xfer_end, upipe); + xfer->hcpriv = ii; - /* And return. */ splx(s); -} - -void -uhci_abort_xfer_end(v) - void *v; -{ - struct uhci_pipe *upipe = v; - usbd_xfer_handle xf; - uhci_soft_td_t *std; - uhci_soft_qh_t *sqh, **qhs; - int s; - int i, nqhs; - DPRINTFN(5,("uhci_abort_xfer_end: upipe=%p\n", upipe)); - - switch (UE_GET_XFERTYPE(upipe->pipe.endpoint->edesc->bmAttributes)) { - case UE_CONTROL: -#if 0 - qhs = &upipe->u.ctl.sqh; - nqhs = 1; -#else -/* only one ctl transfer; qh unlinked by usb_transfer_complete() */ - nqhs = 0; -#endif - break; - case UE_ISOCHRONOUS: - printf("uhci_abort_xfer_end: iso\n"); - nqhs = 0; - break; - case UE_BULK: - qhs = &upipe->u.bulk.sqh; - nqhs = 1; - break; - case UE_INTERRUPT: - qhs = upipe->u.intr.qhs; - nqhs = upipe->u.intr.npoll; - break; - } + delay(1000); s = splusb(); - - for (i = 0; i < nqhs; i++) { - sqh = qhs[i]; - /* Check if inside remaining TD chain. */ - for (xf = upipe->abortstart; xf != NULL; - xf = SIMPLEQ_NEXT(xf, next)) { - for (std = UXFER(xf)->iinfo.stdstart; std != NULL; - std = std->link.std) { - if (std->physaddr == le32toh(sqh->qh.qh_elink)) - goto outside; - } - if (xf == upipe->abortend) - break; - } - if (upipe->abortstart != NULL) { - std = UXFER(upipe->abortstart)->iinfo.stdstart; - DPRINTFN(5,("uhci_abort_xfer_end: new std=%p\n", std)); - sqh->elink = std; - sqh->qh.qh_elink = htole32(std->physaddr); - } else { - DPRINTFN(5,("uhci_abort_xfer_end: new std=NULL\n")); - sqh->elink = NULL; - sqh->qh.qh_elink = htole32(UHCI_PTR_T); - } - } - -outside: - - /* Insert QH again. */ - uhci_abort_relink_qh(upipe); - - /* No longer aborting */ - upipe->aborting = 0; - - splx(s); -} - -void -uhci_abort_unlink_qh(upipe) - struct uhci_pipe *upipe; -{ - uhci_softc_t *sc = (uhci_softc_t *)upipe->pipe.device->bus; - uhci_soft_qh_t *sqh, *pqh, **qhs; - int i, npoll; - - DPRINTFN(5,("uhci_abort_unlink_qh: sc=%p pipe=%p\n", sc, upipe)); - - switch (UE_GET_XFERTYPE(upipe->pipe.endpoint->edesc->bmAttributes)) { - case UE_CONTROL: -#if 0 -/* At the moment the done routine removes the QH */ - sqh = upipe->u.ctl.sqh; - pqh = uhci_find_prev_qh(sc->sc_ctl_start, sqh); - pqh->qh.qh_hlink = sqh->qh.qh_hlink; -#endif - break; -#ifdef DIAGNOSTIC - case UE_ISOCHRONOUS: - printf("uhci_abort_unlink_qh: iso\n"); - break; -#endif - case UE_BULK: -#if 0 -/* At the moment the done routine removes the QH */ - sqh = upipe->u.bulk.sqh; - pqh = uhci_find_prev_qh(sc->sc_bulk_start, sqh); - pqh->qh.qh_hlink = sqh->qh.qh_hlink; -#endif - break; - case UE_INTERRUPT: - npoll = upipe->u.intr.npoll; - qhs = upipe->u.intr.qhs; - for (i = 0; i < npoll; i++) { - sqh = qhs[i]; - pqh = uhci_find_prev_qh(sc->sc_vframes[sqh->pos].hqh, - sqh); - pqh->qh.qh_hlink = sqh->qh.qh_hlink; - } - break; - } -} - -void -uhci_abort_relink_qh(upipe) - struct uhci_pipe *upipe; -{ - uhci_softc_t *sc = (uhci_softc_t *)upipe->pipe.device->bus; - uhci_soft_qh_t *sqh, *pqh, **qhs; - int i, npoll; - - switch (UE_GET_XFERTYPE(upipe->pipe.endpoint->edesc->bmAttributes)) { - case UE_CONTROL: -#if 0 -/* At the moment the done routine removes the QH */ - sqh = upipe->u.ctl.sqh; - pqh = uhci_find_prev_qh(sc->sc_ctl_start, sqh); - pqh->qh.qh_hlink = htole32(sqh->physaddr | UHCI_PTR_Q); -#endif - break; #ifdef DIAGNOSTIC - case UE_ISOCHRONOUS: - printf("uhci_abort_relink_qh: iso\n"); - break; -#endif - case UE_BULK: -#if 0 -/* At the moment the done routine removes the QH */ - sqh = upipe->u.bulk.sqh; - pqh = uhci_find_prev_qh(sc->sc_bulk_start, sqh); - pqh->qh.qh_hlink = htole32(sqh->physaddr | UHCI_PTR_Q); + ii->isdone = 1; #endif - break; - case UE_INTERRUPT: - npoll = upipe->u.intr.npoll; - qhs = upipe->u.intr.qhs; - for (i = 0; i < npoll; i++) { - sqh = qhs[i]; - pqh = uhci_find_prev_qh(sc->sc_vframes[sqh->pos].hqh, - sqh); - pqh->qh.qh_hlink = htole32(sqh->physaddr | UHCI_PTR_Q); - } - break; - } -} - -void -uhci_cancel_abort(pipe) - usbd_pipe_handle pipe; -{ - struct uhci_pipe *upipe = (struct uhci_pipe *)pipe; - int s; - - s = splusb(); - if (upipe->aborting) { - usb_uncallout(pipe->abort_handle, uhci_abort_xfer_end, upipe); - upipe->aborting = 0; - } + usb_transfer_complete(xfer); splx(s); } - /* Close a device bulk pipe. */ void uhci_device_bulk_close(pipe) @@ -2006,7 +1766,6 @@ uhci_device_bulk_close(pipe) usbd_device_handle dev = upipe->pipe.device; uhci_softc_t *sc = (uhci_softc_t *)dev->bus; - uhci_cancel_abort(pipe); uhci_free_sqh(sc, upipe->u.bulk.sqh); } @@ -2156,7 +1915,6 @@ void uhci_device_ctrl_close(pipe) usbd_pipe_handle pipe; { - uhci_cancel_abort(pipe); } /* Abort a device interrupt request. */ @@ -2182,8 +1940,6 @@ uhci_device_intr_close(pipe) int i, npoll; int s; - uhci_cancel_abort(pipe); - /* Unlink descriptors from controller data structures. */ npoll = upipe->u.intr.npoll; s = splusb(); @@ -2351,7 +2107,7 @@ uhci_device_isoc_transfer(xfer) /* insert into schedule, */ uhci_device_isoc_enter(xfer); - /* and put on interrupt list if the pipe wasn't running */ + /* and start if the pipe wasn't running */ if (!err) uhci_device_isoc_start(SIMPLEQ_FIRST(&xfer->pipe->queue)); @@ -2469,9 +2225,8 @@ uhci_device_isoc_start(xfer) ii->stdstart = end; ii->stdend = end; #ifdef DIAGNOSTIC - if (!ii->isdone) { + if (!ii->isdone) printf("uhci_device_isoc_start: not done, ii=%p\n", ii); - } ii->isdone = 0; #endif uhci_add_intr_info(sc, ii); diff --git a/sys/dev/usb/uhid.c b/sys/dev/usb/uhid.c index fb8c3a27e3c..f36e6ce6d21 100644 --- a/sys/dev/usb/uhid.c +++ b/sys/dev/usb/uhid.c @@ -1,5 +1,5 @@ -/* $OpenBSD: uhid.c,v 1.8 2000/03/28 19:37:50 aaron Exp $ */ -/* $NetBSD: uhid.c,v 1.35 2000/03/19 22:23:28 augustss Exp $ */ +/* $OpenBSD: uhid.c,v 1.9 2000/03/30 16:19:33 aaron Exp $ */ +/* $NetBSD: uhid.c,v 1.36 2000/03/27 12:33:56 augustss Exp $ */ /* $FreeBSD: src/sys/dev/usb/uhid.c,v 1.22 1999/11/17 22:33:43 n_hibma Exp $ */ /* @@ -130,7 +130,7 @@ d_poll_t uhidpoll; #define UHID_CDEV_MAJOR 122 -static struct cdevsw uhid_cdevsw = { +Static struct cdevsw uhid_cdevsw = { /* open */ uhidopen, /* close */ uhidclose, /* read */ uhidread, @@ -148,12 +148,12 @@ static struct cdevsw uhid_cdevsw = { }; #endif -static void uhid_intr __P((usbd_xfer_handle, usbd_private_handle, +Static void uhid_intr __P((usbd_xfer_handle, usbd_private_handle, usbd_status)); -static int uhid_do_read __P((struct uhid_softc *, struct uio *uio, int)); -static int uhid_do_write __P((struct uhid_softc *, struct uio *uio, int)); -static int uhid_do_ioctl __P((struct uhid_softc *, u_long, caddr_t, int, +Static int uhid_do_read __P((struct uhid_softc *, struct uio *uio, int)); +Static int uhid_do_write __P((struct uhid_softc *, struct uio *uio, int)); +Static int uhid_do_ioctl __P((struct uhid_softc *, u_long, caddr_t, int, struct proc *)); USB_DECLARE_DRIVER(uhid); diff --git a/sys/dev/usb/uhub.c b/sys/dev/usb/uhub.c index 92183cdcd46..7dddc87bdce 100644 --- a/sys/dev/usb/uhub.c +++ b/sys/dev/usb/uhub.c @@ -1,5 +1,5 @@ -/* $OpenBSD: uhub.c,v 1.8 2000/03/28 19:37:50 aaron Exp $ */ -/* $NetBSD: uhub.c,v 1.40 2000/02/29 21:37:01 augustss Exp $ */ +/* $OpenBSD: uhub.c,v 1.9 2000/03/30 16:19:33 aaron Exp $ */ +/* $NetBSD: uhub.c,v 1.41 2000/03/27 12:33:56 augustss Exp $ */ /* $FreeBSD: src/sys/dev/usb/uhub.c,v 1.18 1999/11/17 22:33:43 n_hibma Exp $ */ /* @@ -80,12 +80,12 @@ struct uhub_softc { u_char sc_running; }; -static usbd_status uhub_init_port __P((struct usbd_port *)); -static usbd_status uhub_explore __P((usbd_device_handle hub)); -static void uhub_intr __P((usbd_xfer_handle, usbd_private_handle,usbd_status)); +Static usbd_status uhub_init_port __P((struct usbd_port *)); +Static usbd_status uhub_explore __P((usbd_device_handle hub)); +Static void uhub_intr __P((usbd_xfer_handle, usbd_private_handle,usbd_status)); #if defined(__FreeBSD__) -static bus_child_detached_t uhub_child_detached; +Static bus_child_detached_t uhub_child_detached; #endif @@ -110,7 +110,7 @@ USB_DECLARE_DRIVER_INIT(uhub, /* Create the driver instance for the hub connected to usb case. */ devclass_t uhubroot_devclass; -static device_method_t uhubroot_methods[] = { +Static device_method_t uhubroot_methods[] = { DEVMETHOD(device_probe, uhub_match), DEVMETHOD(device_attach, uhub_attach), @@ -118,7 +118,7 @@ static device_method_t uhubroot_methods[] = { {0,0} }; -static driver_t uhubroot_driver = { +Static driver_t uhubroot_driver = { "uhub", uhubroot_methods, sizeof(struct uhub_softc) @@ -534,7 +534,7 @@ USB_DETACH(uhub) #if defined(__FreeBSD__) /* Called when a device has been detached from it */ -static void +Static void uhub_child_detached(self, child) device_t self; device_t child; diff --git a/sys/dev/usb/ulpt.c b/sys/dev/usb/ulpt.c index 93ade608e84..5ed4f0e9eb0 100644 --- a/sys/dev/usb/ulpt.c +++ b/sys/dev/usb/ulpt.c @@ -1,5 +1,5 @@ -/* $OpenBSD: ulpt.c,v 1.1 2000/03/28 19:37:50 aaron Exp $ */ -/* $NetBSD: ulpt.c,v 1.33 2000/03/06 20:58:39 augustss Exp $ */ +/* $OpenBSD: ulpt.c,v 1.2 2000/03/30 16:19:33 aaron Exp $ */ +/* $NetBSD: ulpt.c,v 1.35 2000/03/29 18:24:53 augustss Exp $ */ /* $FreeBSD: src/sys/dev/usb/ulpt.c,v 1.24 1999/11/17 22:33:44 n_hibma Exp $ */ /* @@ -119,14 +119,14 @@ struct ulpt_softc { #if defined(__NetBSD__) || defined(__OpenBSD__) cdev_decl(ulpt); #elif defined(__FreeBSD__) -static d_open_t ulptopen; -static d_close_t ulptclose; -static d_write_t ulptwrite; -static d_ioctl_t ulptioctl; +Static d_open_t ulptopen; +Static d_close_t ulptclose; +Static d_write_t ulptwrite; +Static d_ioctl_t ulptioctl; #define ULPT_CDEV_MAJOR 113 -static struct cdevsw ulpt_cdevsw = { +Static struct cdevsw ulpt_cdevsw = { /* open */ ulptopen, /* close */ ulptclose, /* read */ noread, diff --git a/sys/dev/usb/usb.c b/sys/dev/usb/usb.c index 0c901df0f59..78ca7a5acdb 100644 --- a/sys/dev/usb/usb.c +++ b/sys/dev/usb/usb.c @@ -1,5 +1,5 @@ -/* $OpenBSD: usb.c,v 1.10 2000/03/28 19:37:50 aaron Exp $ */ -/* $NetBSD: usb.c,v 1.41 2000/03/16 00:46:38 augustss Exp $ */ +/* $OpenBSD: usb.c,v 1.11 2000/03/30 16:19:33 aaron Exp $ */ +/* $NetBSD: usb.c,v 1.43 2000/03/29 18:24:53 augustss Exp $ */ /* $FreeBSD: src/sys/dev/usb/usb.c,v 1.20 1999/11/17 22:33:46 n_hibma Exp $ */ /* @@ -147,31 +147,31 @@ struct cdevsw usb_cdevsw = { }; #endif -static usbd_status usb_discover __P((struct usb_softc *)); -static void usb_create_event_thread __P((void *)); -static void usb_event_thread __P((void *)); +Static usbd_status usb_discover __P((struct usb_softc *)); +Static void usb_create_event_thread __P((void *)); +Static void usb_event_thread __P((void *)); #define USB_MAX_EVENTS 100 struct usb_event_q { struct usb_event ue; SIMPLEQ_ENTRY(usb_event_q) next; }; -static SIMPLEQ_HEAD(, usb_event_q) usb_events = +Static SIMPLEQ_HEAD(, usb_event_q) usb_events = SIMPLEQ_HEAD_INITIALIZER(usb_events); -static int usb_nevents = 0; -static struct selinfo usb_selevent; -static struct proc *usb_async_proc; /* process who wants USB SIGIO */ -static int usb_dev_open = 0; -static void usb_add_event __P((int, struct usb_event *)); +Static int usb_nevents = 0; +Static struct selinfo usb_selevent; +Static struct proc *usb_async_proc; /* process who wants USB SIGIO */ +Static int usb_dev_open = 0; +Static void usb_add_event __P((int, struct usb_event *)); -static int usb_get_next_event __P((struct usb_event *)); +Static int usb_get_next_event __P((struct usb_event *)); #if defined(__NetBSD__) || defined(__OpenBSD__) /* Flag to see if we are in the cold boot process. */ extern int cold; #endif -static const char *usbrev_str[] = USBREV_STR; +Static const char *usbrev_str[] = USBREV_STR; USB_DECLARE_DRIVER(usb); @@ -249,12 +249,8 @@ USB_ATTACH(usb) if (cold) sc->sc_bus->use_polling--; -#if defined(__NetBSD__) || defined(__FreeBSD__) config_pending_incr(); - kthread_create(usb_create_event_thread, sc); -#else - kthread_create_deferred(usb_create_event_thread, sc); -#endif + usb_kthread_create(usb_create_event_thread, sc); #if defined(__FreeBSD__) make_dev(&usb_cdevsw, device_get_unit(self), UID_ROOT, GID_OPERATOR, @@ -271,7 +267,7 @@ usb_create_event_thread(arg) { struct usb_softc *sc = arg; - if (kthread_create1(usb_event_thread, sc, &sc->sc_event_thread, + if (usb_kthread_create1(usb_event_thread, sc, &sc->sc_event_thread, "%s", sc->sc_dev.dv_xname)) { printf("%s: unable to create event thread for\n", sc->sc_dev.dv_xname); @@ -284,9 +280,7 @@ usb_event_thread(arg) void *arg; { struct usb_softc *sc = arg; -#if defined(__NetBSD__) int first = 1; -#endif DPRINTF(("usb_event_thread: start\n")); @@ -298,12 +292,10 @@ usb_event_thread(arg) if (usb_noexplore < 2) #endif usb_discover(sc); -#if defined(__NetBSD__) if (first) { config_pending_decr(); first = 0; } -#endif (void)tsleep(&sc->sc_bus->needs_explore, PWAIT, "usbevt", #ifdef USB_DEBUG usb_noexplore ? 0 : @@ -677,7 +669,7 @@ usbd_add_drv_event(type, udev, dev) usb_add_event(type, &ue); } -static void +Static void usb_add_event(type, uep) int type; struct usb_event *uep; diff --git a/sys/dev/usb/usb_mem.c b/sys/dev/usb/usb_mem.c index 101bef93df5..2856ce3545d 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.8 2000/03/28 19:37:50 aaron Exp $ */ -/* $NetBSD: usb_mem.c,v 1.18 2000/03/27 08:27:03 augustss Exp $ */ +/* $OpenBSD: usb_mem.c,v 1.9 2000/03/30 16:19:33 aaron Exp $ */ +/* $NetBSD: usb_mem.c,v 1.19 2000/03/27 12:33:58 augustss Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -82,18 +82,18 @@ struct usb_frag_dma { LIST_ENTRY(usb_frag_dma) next; }; -static usbd_status usb_block_allocmem __P((bus_dma_tag_t, size_t, size_t, +Static usbd_status usb_block_allocmem __P((bus_dma_tag_t, size_t, size_t, usb_dma_block_t **)); -static void usb_block_freemem __P((usb_dma_block_t *)); +Static void usb_block_freemem __P((usb_dma_block_t *)); -static LIST_HEAD(, usb_dma_block) usb_blk_freelist = +Static LIST_HEAD(, usb_dma_block) usb_blk_freelist = LIST_HEAD_INITIALIZER(usb_blk_freelist); -int usb_blk_nfree = 0; +Static int usb_blk_nfree = 0; /* XXX should have different free list for different tags (for speed) */ -static LIST_HEAD(, usb_frag_dma) usb_frag_freelist = +Static LIST_HEAD(, usb_frag_dma) usb_frag_freelist = LIST_HEAD_INITIALIZER(usb_frag_freelist); -static usbd_status +Static usbd_status usb_block_allocmem(tag, size, align, dmap) bus_dma_tag_t tag; size_t size; @@ -200,7 +200,7 @@ usb_block_real_freemem(p) * from an interrupt context and that is BAD. * XXX when should we really free? */ -static void +Static void usb_block_freemem(p) usb_dma_block_t *p; { diff --git a/sys/dev/usb/usb_port.h b/sys/dev/usb/usb_port.h index 7f81ba9e4fc..645d9e22eb9 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.8 2000/03/28 19:37:50 aaron Exp $ */ -/* $NetBSD: usb_port.h,v 1.23 2000/03/24 22:03:32 augustss Exp $ */ +/* $OpenBSD: usb_port.h,v 1.9 2000/03/30 16:19:33 aaron Exp $ */ +/* $NetBSD: usb_port.h,v 1.28 2000/03/30 08:53:31 augustss Exp $ */ /* $FreeBSD: src/sys/dev/usb/usb_port.h,v 1.21 1999/11/17 22:33:47 n_hibma Exp $ */ /* @@ -64,6 +64,10 @@ #define AUE_DEBUG 1 #define CUE_DEBUG 1 #define KUE_DEBUG 1 +#define UMASS_DEBUG 1 +#define Static +#else +#define Static static #endif typedef struct device *device_ptr_t; @@ -86,6 +90,12 @@ typedef struct callout usb_callout_t; #define usb_callout(h, t, f, d) callout_reset(&(h), (t), (f), (d)) #define usb_uncallout(h, f, d) callout_stop(&(h)) +#define usb_kthread_create1 kthread_create1 +#define usb_kthread_create kthread_create + +#define Ether_ifattach ether_ifattach +#define IF_INPUT(ifp, m) (*(ifp)->if_input)((ifp), (m)) + #define logprintf printf #define USB_DECLARE_DRIVER(dname) \ @@ -172,12 +182,30 @@ __CONCAT(dname,_detach)(self, flags) \ #define AUE_DEBUG 1 #define CUE_DEBUG 1 #define KUE_DEBUG 1 +#define UMASS_DEBUG 1 #endif +#define Static + #define memcpy(d, s, l) bcopy((s),(d),(l)) #define memset(d, v, l) bzero((d),(l)) #define bswap32(x) swap32(x) -#define kthread_create1 kthread_create +#define usb_kthread_create1 kthread_create +#define usb_kthread_create kthread_create_deferred + +#define config_pending_incr() +#define config_pending_decr() + +#define mii_attach(x1,x2,x3,x4,x5,x6) mii_phy_probe(x1,x2,x3) +#define Ether_ifattach(ifp, eaddr) ether_ifattach(ifp) +#define if_deactivate(x) +#define IF_INPUT(ifp, m) do { \ + struct ether_header *eh; \ + \ + eh = mtod(m, struct ether_header *); \ + m_adj(m, sizeof(struct ether_header)); \ + ether_input((ifp), (eh), (m)); \ +} while (0) #define usbpoll usbselect #define uhidpoll uhidselect @@ -196,6 +224,8 @@ __CONCAT(dname,_detach)(self, flags) \ #define realloc usb_realloc void *usb_realloc __P((void *, u_int, int, int)); +extern int cold; + typedef struct device *device_ptr_t; #define USBBASEDEVICE struct device #define USBDEV(bdev) (&(bdev)) @@ -292,6 +322,8 @@ __CONCAT(dname,_detach)(self, flags) \ #include "opt_usb.h" +#define Static + #define USBVERBOSE #define device_ptr_t device_t @@ -309,9 +341,9 @@ __CONCAT(dname,_detach)(self, flags) \ #define memcpy(d, s, l) bcopy((s),(d),(l)) #define memset(d, v, l) bzero((d),(l)) #define bswap32(x) swap32(x) -#define kthread_create1(function, sc, priv, string, name) -#define kthread_create(create_function, sc) -#define kthread_exit(err) +#define usb_kthread_create1(function, sc, priv, string, name) +#define usb_kthread_create(create_function, sc) +#define usb_kthread_exit(err) typedef struct callout_handle usb_callout_t; #define usb_callout_init(h) callout_handle_init(&(h)) @@ -326,13 +358,13 @@ typedef struct callout_handle usb_callout_t; #define PWR_RESUME 0 #define USB_DECLARE_DRIVER_INIT(dname, init) \ -static device_probe_t __CONCAT(dname,_match); \ -static device_attach_t __CONCAT(dname,_attach); \ -static device_detach_t __CONCAT(dname,_detach); \ +Static device_probe_t __CONCAT(dname,_match); \ +Static device_attach_t __CONCAT(dname,_attach); \ +Static device_detach_t __CONCAT(dname,_detach); \ \ -static devclass_t __CONCAT(dname,_devclass); \ +Static devclass_t __CONCAT(dname,_devclass); \ \ -static device_method_t __CONCAT(dname,_methods)[] = { \ +Static device_method_t __CONCAT(dname,_methods)[] = { \ DEVMETHOD(device_probe, __CONCAT(dname,_match)), \ DEVMETHOD(device_attach, __CONCAT(dname,_attach)), \ DEVMETHOD(device_detach, __CONCAT(dname,_detach)), \ @@ -340,7 +372,7 @@ static device_method_t __CONCAT(dname,_methods)[] = { \ {0,0} \ }; \ \ -static driver_t __CONCAT(dname,_driver) = { \ +Static driver_t __CONCAT(dname,_driver) = { \ #dname, \ __CONCAT(dname,_methods), \ sizeof(struct __CONCAT(dname,_softc)) \ @@ -350,14 +382,14 @@ static driver_t __CONCAT(dname,_driver) = { \ #define USB_MATCH(dname) \ -static int \ +Static int \ __CONCAT(dname,_match)(device_t self) #define USB_MATCH_START(dname, uaa) \ struct usb_attach_arg *uaa = device_get_ivars(self) #define USB_ATTACH(dname) \ -static int \ +Static int \ __CONCAT(dname,_attach)(device_t self) #define USB_ATTACH_START(dname, sc, uaa) \ @@ -373,7 +405,7 @@ __CONCAT(dname,_attach)(device_t self) device_set_desc_copy(self, devinfo) #define USB_DETACH(dname) \ -static int \ +Static int \ __CONCAT(dname,_detach)(device_t self) #define USB_DETACH_START(dname, sc) \ diff --git a/sys/dev/usb/usb_quirks.c b/sys/dev/usb/usb_quirks.c index 7df8df233bd..bcc821a2ab3 100644 --- a/sys/dev/usb/usb_quirks.c +++ b/sys/dev/usb/usb_quirks.c @@ -1,5 +1,5 @@ -/* $OpenBSD: usb_quirks.c,v 1.4 2000/03/28 19:37:50 aaron Exp $ */ -/* $NetBSD: usb_quirks.c,v 1.23 2000/03/25 17:30:00 augustss Exp $ */ +/* $OpenBSD: usb_quirks.c,v 1.5 2000/03/30 16:19:33 aaron Exp $ */ +/* $NetBSD: usb_quirks.c,v 1.24 2000/03/27 12:33:58 augustss Exp $ */ /* $FreeBSD: src/sys/dev/usb/usb_quirks.c,v 1.13 1999/11/17 22:33:47 n_hibma Exp $ */ /* @@ -51,7 +51,7 @@ extern int usbdebug; #endif -static struct usbd_quirk_entry { +Static struct usbd_quirk_entry { u_int16_t idVendor; u_int16_t idProduct; u_int16_t bcdDevice; diff --git a/sys/dev/usb/usb_subr.c b/sys/dev/usb/usb_subr.c index a3e10986a3e..77d7eab65c1 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.8 2000/03/28 19:37:51 aaron Exp $ */ -/* $NetBSD: usb_subr.c,v 1.68 2000/03/25 18:02:33 augustss Exp $ */ +/* $OpenBSD: usb_subr.c,v 1.9 2000/03/30 16:19:33 aaron Exp $ */ +/* $NetBSD: usb_subr.c,v 1.71 2000/03/29 18:24:53 augustss Exp $ */ /* $FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $ */ /* @@ -76,22 +76,22 @@ extern int usbdebug; #define DPRINTFN(n,x) #endif -static usbd_status usbd_set_config __P((usbd_device_handle, int)); -static char *usbd_get_string __P((usbd_device_handle, int, char *)); -static int usbd_getnewaddr __P((usbd_bus_handle bus)); +Static usbd_status usbd_set_config __P((usbd_device_handle, int)); +Static char *usbd_get_string __P((usbd_device_handle, int, char *)); +Static int usbd_getnewaddr __P((usbd_bus_handle bus)); #if defined(__NetBSD__) -static int usbd_print __P((void *aux, const char *pnp)); -static int usbd_submatch __P((device_ptr_t, struct cfdata *cf, void *)); +Static int usbd_print __P((void *aux, const char *pnp)); +Static int usbd_submatch __P((device_ptr_t, struct cfdata *cf, void *)); #elif defined(__OpenBSD__) -static int usbd_print __P((void *aux, const char *pnp)); -static int usbd_submatch __P((device_ptr_t, void *, void *)); +Static int usbd_print __P((void *aux, const char *pnp)); +Static int usbd_submatch __P((device_ptr_t, void *, void *)); #endif -static void usbd_free_iface_data __P((usbd_device_handle dev, int ifcno)); -static void usbd_kill_pipe __P((usbd_pipe_handle)); -static usbd_status usbd_probe_and_attach +Static void usbd_free_iface_data __P((usbd_device_handle dev, int ifcno)); +Static void usbd_kill_pipe __P((usbd_pipe_handle)); +Static usbd_status usbd_probe_and_attach __P((device_ptr_t parent, usbd_device_handle dev, int port, int addr)); -static u_int32_t usb_cookie_no = 0; +Static u_int32_t usb_cookie_no = 0; #ifdef USBVERBOSE typedef u_int16_t usb_vendor_id_t; @@ -111,7 +111,7 @@ struct usb_knowndev { #include <dev/usb/usbdevs_data.h> #endif /* USBVERBOSE */ -static const char *usbd_error_strs[] = { +Static const char *usbd_error_strs[] = { "NORMAL_COMPLETION", "IN_PROGRESS", "PENDING_REQUESTS", @@ -514,7 +514,7 @@ usbd_free_iface_data(dev, ifcno) free(ifc->endpoints, M_USB); } -static usbd_status +Static usbd_status usbd_set_config(dev, conf) usbd_device_handle dev; int conf; @@ -697,6 +697,7 @@ usbd_setup_pipe(dev, iface, ep, ival, pipe) p->refcnt = 1; p->intrxfer = 0; p->running = 0; + p->aborting = 0; p->repeat = 0; p->interval = ival; SIMPLEQ_INIT(&p->queue); diff --git a/sys/dev/usb/usbdi.c b/sys/dev/usb/usbdi.c index eddcf375d01..c88d33d87ae 100644 --- a/sys/dev/usb/usbdi.c +++ b/sys/dev/usb/usbdi.c @@ -1,5 +1,5 @@ -/* $OpenBSD: usbdi.c,v 1.9 2000/03/28 19:37:52 aaron Exp $ */ -/* $NetBSD: usbdi.c,v 1.68 2000/03/25 18:02:33 augustss Exp $ */ +/* $OpenBSD: usbdi.c,v 1.10 2000/03/30 16:19:33 aaron Exp $ */ +/* $NetBSD: usbdi.c,v 1.71 2000/03/29 01:45:21 augustss Exp $ */ /* $FreeBSD: src/sys/dev/usb/usbdi.c,v 1.28 1999/11/17 22:33:49 n_hibma Exp $ */ /* @@ -77,14 +77,14 @@ extern int usbdebug; #define DPRINTFN(n,x) #endif -static usbd_status usbd_ar_pipe __P((usbd_pipe_handle pipe)); -static void usbd_do_request_async_cb +Static usbd_status usbd_ar_pipe __P((usbd_pipe_handle pipe)); +Static void usbd_do_request_async_cb __P((usbd_xfer_handle, usbd_private_handle, usbd_status)); -static void usbd_start_next __P((usbd_pipe_handle pipe)); -static usbd_status usbd_open_pipe_ival +Static void usbd_start_next __P((usbd_pipe_handle pipe)); +Static usbd_status usbd_open_pipe_ival __P((usbd_interface_handle, u_int8_t, u_int8_t, usbd_pipe_handle *, int)); -static int usbd_nbuses = 0; +Static int usbd_nbuses = 0; void usbd_init() @@ -98,8 +98,8 @@ usbd_finish() --usbd_nbuses; } -static __inline int usbd_xfer_isread __P((usbd_xfer_handle xfer)); -static __inline int +Static __inline int usbd_xfer_isread __P((usbd_xfer_handle xfer)); +Static __inline int usbd_xfer_isread(xfer) usbd_xfer_handle xfer; { @@ -269,6 +269,9 @@ usbd_transfer(xfer) #endif xfer->done = 0; + if (pipe->aborting) + return (USBD_CANCELLED); + size = xfer->length; /* If there is no buffer, allocate one. */ if (!(xfer->rqflags & URQ_DEV_DMABUF) && size != 0) { @@ -322,6 +325,7 @@ usbd_transfer(xfer) if (xfer->done) break; } + /* XXX Is this right, what about the HC timeout? */ if (!xfer->done) { pipe->methods->abort(xfer); xfer->status = USBD_TIMEOUT; @@ -755,7 +759,7 @@ usbd_get_interface(iface, aiface) /*** Internal routines ***/ /* Dequeue all pipe operations, called at splusb(). */ -static usbd_status +Static usbd_status usbd_ar_pipe(pipe) usbd_pipe_handle pipe; { @@ -769,6 +773,7 @@ usbd_ar_pipe(pipe) usbd_dump_queue(pipe); #endif pipe->repeat = 0; + pipe->aborting = 1; while ((xfer = SIMPLEQ_FIRST(&pipe->queue)) != NULL) { DPRINTFN(2,("usbd_ar_pipe: pipe=%p xfer=%p (methods=%p)\n", pipe, xfer, pipe->methods)); @@ -776,6 +781,7 @@ usbd_ar_pipe(pipe) pipe->methods->abort(xfer); /* XXX only for non-0 usbd_clear_endpoint_stall(pipe); */ } + pipe->aborting = 0; return (USBD_NORMAL_COMPLETION); } diff --git a/sys/dev/usb/usbdi_util.c b/sys/dev/usb/usbdi_util.c index 10354e0f269..cf91d15bdf8 100644 --- a/sys/dev/usb/usbdi_util.c +++ b/sys/dev/usb/usbdi_util.c @@ -1,5 +1,5 @@ -/* $OpenBSD: usbdi_util.c,v 1.7 2000/03/28 19:37:52 aaron Exp $ */ -/* $NetBSD: usbdi_util.c,v 1.28 2000/02/22 11:25:06 augustss Exp $ */ +/* $OpenBSD: usbdi_util.c,v 1.8 2000/03/30 16:19:33 aaron Exp $ */ +/* $NetBSD: usbdi_util.c,v 1.29 2000/03/27 12:33:59 augustss Exp $ */ /* $FreeBSD: src/sys/dev/usb/usbdi_util.c,v 1.14 1999/11/17 22:33:50 n_hibma Exp $ */ /* @@ -485,9 +485,9 @@ usbd_get_config(dev, conf) return (usbd_do_request(dev, &req, conf)); } -static void usbd_bulk_transfer_cb __P((usbd_xfer_handle xfer, +Static void usbd_bulk_transfer_cb __P((usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)); -static void +Static void usbd_bulk_transfer_cb(xfer, priv, status) usbd_xfer_handle xfer; usbd_private_handle priv; diff --git a/sys/dev/usb/usbdivar.h b/sys/dev/usb/usbdivar.h index 2d23ef4af1f..61c3f316fde 100644 --- a/sys/dev/usb/usbdivar.h +++ b/sys/dev/usb/usbdivar.h @@ -1,5 +1,5 @@ -/* $OpenBSD: usbdivar.h,v 1.8 2000/03/28 19:37:53 aaron Exp $ */ -/* $NetBSD: usbdivar.h,v 1.52 2000/03/25 18:02:33 augustss Exp $ */ +/* $OpenBSD: usbdivar.h,v 1.9 2000/03/30 16:19:33 aaron Exp $ */ +/* $NetBSD: usbdivar.h,v 1.55 2000/03/30 00:18:18 augustss Exp $ */ /* $FreeBSD: src/sys/dev/usb/usbdivar.h,v 1.11 1999/11/17 22:33:51 n_hibma Exp $ */ /* @@ -39,10 +39,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#if defined(__NetBSD__) || defined(__FreeBSD__) +#if defined(__NetBSD__) #include <sys/callout.h> -#else -#include <sys/timeout.h> #endif /* From usb_mem.h */ @@ -163,6 +161,7 @@ struct usbd_pipe { struct usbd_endpoint *endpoint; int refcnt; char running; + char aborting; SIMPLEQ_HEAD(, usbd_xfer) queue; LIST_ENTRY(usbd_pipe) next; @@ -251,7 +250,6 @@ void usb_schedsoftintr __P((struct usbd_bus *)); #ifdef DIAGNOSTIC #define SPLUSBCHECK \ do { int _s = splusb(), _su = splusb(); \ - extern int cold; \ if (!cold && _s != _su) printf("SPLUSBCHECK failed 0x%x!=0x%x, %s:%d\n", \ _s, _su, __FILE__, __LINE__); \ splx(_s); \ |