-/* $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 $ */
/*
#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 {
int kindset;
};
-static void
+Static void
hid_clear_local(c)
struct hid_item *c;
{
-/* $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.
#include "rnd.h"
#elif defined(__OpenBSD__)
#include "bpfilter.h"
-#endif
+#endif /* defined(__OpenBSD__) */
#include <sys/param.h>
#include <sys/systm.h>
/*
* 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 },
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)
"$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),
{ 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);
#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;
return (val);
}
-static int
+Static int
aue_csr_read_2(sc, reg)
struct aue_softc *sc;
int reg;
return (UGETW(val));
}
-static int
+Static int
aue_csr_write_1(sc, reg, aval)
struct aue_softc *sc;
int reg, aval;
return (0);
}
-static int
+Static int
aue_csr_write_2(sc, reg, aval)
struct aue_softc *sc;
int 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;
/*
* 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;
}
}
-static int
+Static int
aue_miibus_readreg(dev, phy, reg)
device_ptr_t dev;
int 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;
#endif
}
-static void
+Static void
aue_miibus_statchg(dev)
device_ptr_t dev;
{
#define AUE_POLY 0xEDB88320
#define AUE_BITS 6
-static u_int32_t
+Static u_int32_t
aue_crc(addr)
caddr_t addr;
{
return (crc & ((1 << AUE_BITS) - 1));
}
-static void
+Static void
aue_setmulti(sc)
struct aue_softc *sc;
{
#endif /* defined(__NetBSD__) || defined(__OpenBSD__) */
}
-static void
+Static void
aue_reset(sc)
struct aue_softc *sc;
{
/*
* 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";
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. */
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);
/* 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,
break;
case DVACT_DEACTIVATE:
-#if defined(__NetBSD__)
if_deactivate(&sc->aue_ec.ec_if);
-#endif
sc->aue_dying = 1;
break;
}
/*
* 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;
return (0);
}
-static int
+Static int
aue_rx_list_init(sc)
struct aue_softc *sc;
{
return (0);
}
-static int
+Static int
aue_tx_list_init(sc)
struct aue_softc *sc;
{
return (0);
}
-static void
+Static void
aue_intr(xfer, priv, status)
usbd_xfer_handle xfer;
usbd_private_handle priv;
}
#if defined(__FreeBSD__)
-static void
+Static void
aue_rxstart(ifp)
struct ifnet *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;
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__));
goto done1;
}
- eh = mtod(m, struct ether_header *);
-
#if NBPFILTER > 0
/*
* Handle BPF listeners. Let the BPF user see the packet, but
* 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) &&
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__) */
* the list buffers.
*/
-static void
+Static void
aue_txeof(xfer, priv, status)
usbd_xfer_handle xfer;
usbd_private_handle priv;
splx(s);
}
-static void
+Static void
aue_tick(xsc)
void *xsc;
{
splx(s);
}
-static int
+Static int
aue_send(sc, m, idx)
struct aue_softc *sc;
struct mbuf *m;
return (0);
}
-static void
+Static void
aue_start(ifp)
struct ifnet *ifp;
{
ifp->if_timer = 5;
}
-static void
+Static void
aue_init(xsc)
void *xsc;
{
usb_callout(sc->aue_stat_ch, hz, aue_tick, sc);
}
-static int
+Static int
aue_openpipes(sc)
struct aue_softc *sc;
{
/*
* Set media options.
*/
-static int
+Static int
aue_ifmedia_upd(ifp)
struct ifnet *ifp;
{
/*
* Report current media status.
*/
-static void
+Static void
aue_ifmedia_sts(ifp, ifmr)
struct ifnet *ifp;
struct ifmediareq *ifmr;
ifmr->ifm_status = mii->mii_media_status;
}
-static int
+Static int
aue_ioctl(ifp, command, data)
struct ifnet *ifp;
u_long command;
return (error);
}
-static void
+Static void
aue_watchdog(ifp)
struct ifnet *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;
{
* 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;
{
-/* $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.
#include "rnd.h"
#elif defined(__OpenBSD__)
#include "bpfilter.h"
-#endif
+#endif /* defined(__OpenBSD__) */
#include <sys/param.h>
#include <sys/systm.h>
/*
* 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 */
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
"$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),
{ 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);
#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;
return (val);
}
-static int
+Static int
cue_csr_read_2(sc, reg)
struct cue_softc *sc;
int reg;
return (UGETW(val));
}
-static int
+Static int
cue_csr_write_1(sc, reg, val)
struct cue_softc *sc;
int reg, val;
}
#ifdef notdef
-static int
+Static int
cue_csr_write_2(sc, reg, val)
struct cue_softc *sc;
int reg, aval;
}
#endif
-static int
+Static int
cue_mem(sc, cmd, addr, buf, len)
struct cue_softc *sc;
int cmd;
return (0);
}
-static int
+Static int
cue_getmac(sc, buf)
struct cue_softc *sc;
void *buf;
#define CUE_POLY 0xEDB88320
#define CUE_BITS 9
-static u_int32_t
+Static u_int32_t
cue_crc(addr)
caddr_t addr;
{
return (crc & ((1 << CUE_BITS) - 1));
}
-static void
+Static void
cue_setmulti(sc)
struct cue_softc *sc;
{
&sc->cue_mctab, CUE_MCAST_TABLE_LEN);
}
-static void
+Static void
cue_reset(sc)
struct cue_softc *sc;
{
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,
break;
case DVACT_DEACTIVATE:
-#if defined(__NetBSD__)
/* Deactivate the interface. */
if_deactivate(&sc->cue_ec.ec_if);
-#endif
sc->cue_dying = 1;
break;
}
/*
* 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;
return (0);
}
-static int
+Static int
cue_rx_list_init(sc)
struct cue_softc *sc;
{
return (0);
}
-static int
+Static int
cue_tx_list_init(sc)
struct cue_softc *sc;
{
}
#ifdef __FreeBSD__
-static void
+Static void
cue_rxstart(ifp)
struct ifnet *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;
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),
goto done1;
}
- eh = mtod(m, struct ether_header *);
-
#if NBPFILTER > 0
/*
* Handle BPF listeners. Let the BPF user see the packet, but
* 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) &&
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__) */
* 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;
splx(s);
}
-static void
+Static void
cue_tick(xsc)
void *xsc;
{
splx(s);
}
-static int
+Static int
cue_send(sc, m, idx)
struct cue_softc *sc;
struct mbuf *m;
return (0);
}
-static void
+Static void
cue_start(ifp)
struct ifnet *ifp;
{
ifp->if_timer = 5;
}
-static void
+Static void
cue_init(xsc)
void *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]);
usb_callout(sc->cue_stat_ch, hz, cue_tick, sc);
}
-static int
+Static int
cue_open_pipes(sc)
struct cue_softc *sc;
{
return (0);
}
-static int
+Static int
cue_ioctl(ifp, command, data)
struct ifnet *ifp;
u_long command;
return (error);
}
-static void
+Static void
cue_watchdog(ifp)
struct ifnet *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;
{
* 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;
{
-/* $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.
/*
* 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 },
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
"$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),
{ 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);
#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;
return (err);
}
-static usbd_status
+Static usbd_status
kue_ctl(sc, rw, breq, val, data, len)
struct kue_softc *sc;
int rw;
return (err);
}
-static int
+Static int
kue_is_warm(sc)
struct kue_softc *sc;
{
return (!err);
}
-static int
+Static int
kue_load_fw(sc)
struct kue_softc *sc;
{
return (0);
}
-static void
+Static void
kue_setmulti(sc)
struct kue_softc *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;
{
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,
/*
* 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;
return (0);
}
-static int
+Static int
kue_rx_list_init(sc)
struct kue_softc *sc;
{
return (0);
}
-static int
+Static int
kue_tx_list_init(sc)
struct kue_softc *sc;
{
}
#ifdef __FreeBSD__
-static void
+Static void
kue_rxstart(ifp)
struct ifnet *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;
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),
goto done1;
}
- eh = mtod(m, struct ether_header *);
-
#if NBPFILTER > 0
/*
* Handle BPF listeners. Let the BPF user see the packet, but
* 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) &&
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__) */
* the list buffers.
*/
-static void
+Static void
kue_txeof(xfer, priv, status)
usbd_xfer_handle xfer;
usbd_private_handle priv;
splx(s);
}
-static int
+Static int
kue_send(sc, m, idx)
struct kue_softc *sc;
struct mbuf *m;
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);
}
return (0);
}
-static void
+Static void
kue_start(ifp)
struct ifnet *ifp;
{
ifp->if_timer = 5;
}
-static void
+Static void
kue_init(xsc)
void *xsc;
{
splx(s);
}
-static int
+Static int
kue_open_pipes(sc)
struct kue_softc *sc;
{
return (0);
}
-static int
+Static int
kue_ioctl(ifp, command, data)
struct ifnet *ifp;
u_long command;
return (error);
}
-static void
+Static void
kue_watchdog(ifp)
struct ifnet *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;
{
* 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;
{
-/* $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.
#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 */
};
/* Firmware fixup (data?) segment */
-static unsigned char kue_fix_seg[] =
+Static unsigned char kue_fix_seg[] =
{
/******************************************/
/* NOTE: B6/C3 is data header signature */
/* 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
};
-/* $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 $ */
/*
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))
#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,
#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,
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,
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,
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,
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,
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,
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,
case DVACT_DEACTIVATE:
if (sc->sc_child != NULL)
rv = config_deactivate(sc->sc_child);
+ sc->sc_dying = 1;
break;
}
return (rv);
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;
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);
s = splusb();
ohci_hash_rem_td(sc, std);
-
std->nexttd = sc->sc_freetds;
sc->sc_freetds = std;
splx(s);
}
#if 0
-static void
+Static void
ohci_free_std_chain(sc, std, stdend)
ohci_softc_t *sc;
ohci_soft_td_t *std;
{
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);
}
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
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);
}
#endif
-static int ohci_intr1 __P((ohci_softc_t *));
+Static int ohci_intr1 __P((ohci_softc_t *));
int
ohci_intr(p)
return (ohci_intr1(sc));
}
-static int
+Static int
ohci_intr1(sc)
ohci_softc_t *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;
};
#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) {
*/
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) -
}
}
+#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--;
}
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
(u_long)le32toh(std->td.td_be)));
}
+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;
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) {
}
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);
/*
* 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 */
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 +
0 /* max power */
};
-static usb_interface_descriptor_t ohci_ifcd = {
+Static usb_interface_descriptor_t ohci_ifcd = {
USB_INTERFACE_DESCRIPTOR_SIZE,
UDESC_INTERFACE,
0,
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,
255
};
-static usb_hub_descriptor_t ohci_hubd = {
+Static usb_hub_descriptor_t ohci_hubd = {
USB_HUB_DESCRIPTOR_SIZE,
UDESC_HUB,
0,
{0},
};
-static int
+Static int
ohci_str(p, l, s)
usb_string_descriptor_t *p;
int l;
/*
* 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;
{
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;
{
usbd_status err;
u_int32_t v;
+ if (sc->sc_dying)
+ return (USBD_IOERROR);
+
#ifdef DIAGNOSTIC
if (!(xfer->rqflags & URQ_REQUEST))
/* XXX panic */
}
/* Abort a root control request. */
-static void
+Static void
ohci_root_ctrl_abort(xfer)
usbd_xfer_handle xfer;
{
}
/* Close the root pipe. */
-static void
+Static void
ohci_root_ctrl_close(pipe)
usbd_pipe_handle pipe;
{
/* Nothing to do. */
}
-static usbd_status
+Static usbd_status
ohci_root_intr_transfer(xfer)
usbd_xfer_handle 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;
{
}
/* Close the root pipe. */
-static void
+Static void
ohci_root_intr_close(pipe)
usbd_pipe_handle pipe;
{
/************************/
-static usbd_status
+Static usbd_status
ohci_device_ctrl_transfer(xfer)
usbd_xfer_handle 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 */
}
/* Abort a device control request. */
-static void
+Static void
ohci_device_ctrl_abort(xfer)
usbd_xfer_handle xfer;
{
}
/* Close a device control pipe. */
-static void
+Static void
ohci_device_ctrl_close(pipe)
usbd_pipe_handle pipe;
{
/************************/
-static void
+Static void
ohci_device_clear_toggle(pipe)
usbd_pipe_handle 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;
{
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;
{
int s, len, isread, endpt;
usbd_status err;
+ if (sc->sc_dying)
+ return (USBD_IOERROR);
+
#ifdef DIAGNOSTIC
if (xfer->rqflags & URQ_REQUEST) {
/* XXX panic */
return (USBD_IN_PROGRESS);
}
-static void
+Static void
ohci_device_bulk_abort(xfer)
usbd_xfer_handle xfer;
{
/*
* Close a device bulk pipe.
*/
-static void
+Static void
ohci_device_bulk_close(pipe)
usbd_pipe_handle pipe;
{
/************************/
-static usbd_status
+Static usbd_status
ohci_device_intr_transfer(xfer)
usbd_xfer_handle 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;
{
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));
}
/* Abort a device control request. */
-static void
+Static void
ohci_device_intr_abort(xfer)
usbd_xfer_handle xfer;
{
}
/* Close a device interrupt pipe. */
-static void
+Static void
ohci_device_intr_close(pipe)
usbd_pipe_handle 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;
/* 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));
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
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);
}
{
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);
}
-/* $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 $ */
#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;
#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;
-/* $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 $ */
/*
#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 */
#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
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 */
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;
#endif
device_ptr_t sc_child;
+
+ char sc_dying;
} ohci_softc_t;
usbd_status ohci_init __P((ohci_softc_t *));
-/* $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.
#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 */
#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,
uaudio_trigger_input,
};
-static struct audio_device uaudio_device = {
+Static struct audio_device uaudio_device = {
"USB audio",
"",
"uaudio"
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);
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);
-/* $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 $ */
/*
#define UGEN_CDEV_MAJOR 114
-static struct cdevsw ugen_cdevsw = {
+Static struct cdevsw ugen_cdevsw = {
/* open */ ugenopen,
/* close */ ugenclose,
/* read */ ugenread,
};
#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)
USB_ATTACH_SUCCESS_RETURN;
}
-static int
+Static int
ugen_set_config(sc, configno)
struct ugen_softc *sc;
int configno;
return (0);
}
-static int
+Static int
ugen_do_read(sc, endpt, uio, flag)
struct ugen_softc *sc;
int endpt;
return (error);
}
-static int
+Static int
ugen_do_write(sc, endpt, uio, flag)
struct ugen_softc *sc;
int endpt;
return (0);
}
-static void
+Static void
ugenintr(xfer, addr, status)
usbd_xfer_handle xfer;
usbd_private_handle addr;
selwakeup(&sce->rsel);
}
-static usbd_status
+Static usbd_status
ugen_set_interface(sc, ifaceidx, altno)
struct ugen_softc *sc;
int 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;
return (cdesc);
}
-static int
+Static int
ugen_get_alt_index(sc, ifaceidx)
struct ugen_softc *sc;
int 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;
-/* $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 $ */
/*
} 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))
#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;
{
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
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);
}
}
#ifdef UHCI_DEBUG
-static void
+Static void
uhci_dumpregs(sc)
uhci_softc_t *sc;
{
}
}
-static void
+Static void
uhci_dump_ii(ii)
uhci_intr_info_t *ii;
{
#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;
}
/*
- * 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();
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)
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);
}
uhci_device_ctrl_close(pipe)
usbd_pipe_handle pipe;
{
- uhci_cancel_abort(pipe);
}
/* Abort a device interrupt request. */
int i, npoll;
int s;
- uhci_cancel_abort(pipe);
-
/* Unlink descriptors from controller data structures. */
npoll = upipe->u.intr.npoll;
s = splusb();
/* 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));
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);
-/* $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 $ */
/*
#define UHID_CDEV_MAJOR 122
-static struct cdevsw uhid_cdevsw = {
+Static struct cdevsw uhid_cdevsw = {
/* open */ uhidopen,
/* close */ uhidclose,
/* read */ uhidread,
};
#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);
-/* $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 $ */
/*
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
/* 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),
{0,0}
};
-static driver_t uhubroot_driver = {
+Static driver_t uhubroot_driver = {
"uhub",
uhubroot_methods,
sizeof(struct uhub_softc)
#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;
-/* $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 $ */
/*
#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,
-/* $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 $ */
/*
};
#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);
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,
{
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);
void *arg;
{
struct usb_softc *sc = arg;
-#if defined(__NetBSD__)
int first = 1;
-#endif
DPRINTF(("usb_event_thread: start\n"));
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 :
usb_add_event(type, &ue);
}
-static void
+Static void
usb_add_event(type, uep)
int type;
struct usb_event *uep;
-/* $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.
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;
* 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;
{
-/* $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 $ */
/*
#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;
#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) \
#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
#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))
#include "opt_usb.h"
+#define Static
+
#define USBVERBOSE
#define device_ptr_t device_t
#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))
#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)), \
{0,0} \
}; \
\
-static driver_t __CONCAT(dname,_driver) = { \
+Static driver_t __CONCAT(dname,_driver) = { \
#dname, \
__CONCAT(dname,_methods), \
sizeof(struct __CONCAT(dname,_softc)) \
#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) \
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) \
-/* $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 $ */
/*
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;
-/* $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 $ */
/*
#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;
#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",
free(ifc->endpoints, M_USB);
}
-static usbd_status
+Static usbd_status
usbd_set_config(dev, conf)
usbd_device_handle dev;
int conf;
p->refcnt = 1;
p->intrxfer = 0;
p->running = 0;
+ p->aborting = 0;
p->repeat = 0;
p->interval = ival;
SIMPLEQ_INIT(&p->queue);
-/* $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 $ */
/*
#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()
--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;
{
#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) {
if (xfer->done)
break;
}
+ /* XXX Is this right, what about the HC timeout? */
if (!xfer->done) {
pipe->methods->abort(xfer);
xfer->status = USBD_TIMEOUT;
/*** Internal routines ***/
/* Dequeue all pipe operations, called at splusb(). */
-static usbd_status
+Static usbd_status
usbd_ar_pipe(pipe)
usbd_pipe_handle 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));
pipe->methods->abort(xfer);
/* XXX only for non-0 usbd_clear_endpoint_stall(pipe); */
}
+ pipe->aborting = 0;
return (USBD_NORMAL_COMPLETION);
}
-/* $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 $ */
/*
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;
-/* $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 $ */
/*
* 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 */
struct usbd_endpoint *endpoint;
int refcnt;
char running;
+ char aborting;
SIMPLEQ_HEAD(, usbd_xfer) queue;
LIST_ENTRY(usbd_pipe) next;
#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); \