2002-04-07 12:32:55 +00:00
|
|
|
/* $NetBSD: usbdi.c,v 1.89 2001/12/02 23:25:25 augustss Exp $ */
|
1999-01-22 00:51:12 +00:00
|
|
|
/* $FreeBSD$ */
|
1998-11-26 23:13:13 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
1999-01-07 23:07:57 +00:00
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
2000-05-14 16:43:10 +00:00
|
|
|
* by Lennart Augustsson (lennart@augustsson.net) at
|
1999-01-07 23:07:57 +00:00
|
|
|
* Carlstedt Research & Technology.
|
1998-11-26 23:13:13 +00:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the NetBSD
|
|
|
|
* Foundation, Inc. and its contributors.
|
|
|
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
1999-10-07 19:26:38 +00:00
|
|
|
#if defined(__NetBSD__) || defined(__OpenBSD__)
|
1998-11-26 23:13:13 +00:00
|
|
|
#include <sys/device.h>
|
1999-10-07 19:26:38 +00:00
|
|
|
#elif defined(__FreeBSD__)
|
1998-11-26 23:13:13 +00:00
|
|
|
#include <sys/module.h>
|
|
|
|
#include <sys/bus.h>
|
1999-11-17 22:33:51 +00:00
|
|
|
#include "usb_if.h"
|
|
|
|
#if defined(DIAGNOSTIC) && defined(__i386__)
|
|
|
|
#include <machine/cpu.h>
|
|
|
|
#endif
|
1998-11-26 23:13:13 +00:00
|
|
|
#endif
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
|
1999-11-17 22:33:51 +00:00
|
|
|
#include <machine/bus.h>
|
1998-11-26 23:13:13 +00:00
|
|
|
|
1999-10-07 19:26:38 +00:00
|
|
|
#include <dev/usb/usb.h>
|
1998-11-26 23:13:13 +00:00
|
|
|
#include <dev/usb/usbdi.h>
|
|
|
|
#include <dev/usb/usbdi_util.h>
|
|
|
|
#include <dev/usb/usbdivar.h>
|
1999-10-07 19:26:38 +00:00
|
|
|
#include <dev/usb/usb_mem.h>
|
1998-11-26 23:13:13 +00:00
|
|
|
|
1999-01-07 23:07:57 +00:00
|
|
|
#if defined(__FreeBSD__)
|
|
|
|
#include "usb_if.h"
|
2000-10-16 18:50:00 +00:00
|
|
|
#include <machine/clock.h>
|
More USB ethernet tweaks:
- Sync ohci, uhci and usbdi modules with NetBSD in order to obtain the
following improvements:
o New USBD_NO_TSLEEP flag can be used in place of UQ_NO_TSLEEP
quirk. This allows drivers to specify busy waiting only for
certain transfers (namely control transfers for reading/writing
registers and stuff).
o New USBD_FORCE_SHORT_XFER flag can be used to deal with
devices like the ADMtek Pegasus that sense the end of bulk OUT
transfers in a special way (if a transfer is exactly a multiple
of 64 bytes in size, you need to send an extra empty packet
to terminate the transfer).
o usbd_open_pipe_intr() now accepts an interval argument which
can be used to change the rate at which the interrupt callback
routine is invoked. Specifying USBD_DEFAULT_INTERVAL uses the
value specified in the device's config data, but drivers can
override it if needed.
- Change if_aue to use USBD_FORCE_SHORT_XFER for packet transmissions.
- Change if_aue, if_kue and if_cue to use USBD_NO_TSLEEP for all
control transfers. We no longer force the non-tsleep hack for
bulk transfers since these are done asynchronously anyway.
- Removed quirk entry fiddling from if_aue and if_kue since we don't
need it anymore now that we have the USBD_NO_TSLEEP flag.
- Tweak ulpt, uhid, ums and ukbd drivers to use the new arg to
usbd_open_pipe_intr().
- Add a flag to the softc struct in the ethernet drivers to indicate
when a device has been detached, and use this flag to perform
tests to prevent the drivers from trying to do control transfers
if this is the case. This is necessary because calling if_detach()
with INET6 enabled will eventually result in a call to the driver's
ioctl() routine to delete the multicast groups on the interface,
which will result in attempts to perform control transfers. (It's
possible this also happens even without INET6 support enabled.) This
is pointless since we know that if the detach method has been called,
the hardware has been unplugged.
- Changed watchdog timeout routines to just call the driver init routines
to initialize the device states without trying to close and re-open the
pipes. This is partly because we don't want to frob things at interrupt
context, but also because this doesn't seem to work right and I don't
want to panic the system just because a USB device may have stopped
responding.
- Fix aue_rxeof() to be a little smarter about detecting when a double
transfer is needed. Unfortunately, the design of the chip makes it hard
to get this exactly right. Hopefully, this will go away once either
Nick or Lennart finds the bug in the uhci driver that makes this ugly
hack necessary.
- Also sync usbdevs with NetBSD.
2000-01-20 07:38:33 +00:00
|
|
|
#define delay(d) DELAY(d)
|
1999-01-07 23:07:57 +00:00
|
|
|
#endif
|
1999-11-17 22:33:51 +00:00
|
|
|
|
1998-11-26 23:13:13 +00:00
|
|
|
#ifdef USB_DEBUG
|
1999-04-11 20:50:33 +00:00
|
|
|
#define DPRINTF(x) if (usbdebug) logprintf x
|
|
|
|
#define DPRINTFN(n,x) if (usbdebug>(n)) logprintf x
|
1998-11-26 23:13:13 +00:00
|
|
|
extern int usbdebug;
|
|
|
|
#else
|
|
|
|
#define DPRINTF(x)
|
|
|
|
#define DPRINTFN(n,x)
|
|
|
|
#endif
|
|
|
|
|
2000-07-17 18:41:20 +00:00
|
|
|
Static usbd_status usbd_ar_pipe(usbd_pipe_handle pipe);
|
2000-04-03 20:58:30 +00:00
|
|
|
Static void usbd_do_request_async_cb
|
2002-04-01 17:24:49 +00:00
|
|
|
(usbd_xfer_handle, usbd_private_handle, usbd_status);
|
2000-07-17 18:41:20 +00:00
|
|
|
Static void usbd_start_next(usbd_pipe_handle pipe);
|
2000-04-03 20:58:30 +00:00
|
|
|
Static usbd_status usbd_open_pipe_ival
|
2002-04-01 17:24:49 +00:00
|
|
|
(usbd_interface_handle, u_int8_t, u_int8_t, usbd_pipe_handle *, int);
|
1999-11-17 22:33:51 +00:00
|
|
|
|
2000-04-03 20:58:30 +00:00
|
|
|
Static int usbd_nbuses = 0;
|
1998-11-26 23:13:13 +00:00
|
|
|
|
1999-11-17 22:33:51 +00:00
|
|
|
void
|
|
|
|
usbd_init()
|
|
|
|
{
|
|
|
|
usbd_nbuses++;
|
|
|
|
}
|
1999-10-07 19:26:38 +00:00
|
|
|
|
1999-11-17 22:33:51 +00:00
|
|
|
void
|
|
|
|
usbd_finish()
|
|
|
|
{
|
More USB ethernet tweaks:
- Sync ohci, uhci and usbdi modules with NetBSD in order to obtain the
following improvements:
o New USBD_NO_TSLEEP flag can be used in place of UQ_NO_TSLEEP
quirk. This allows drivers to specify busy waiting only for
certain transfers (namely control transfers for reading/writing
registers and stuff).
o New USBD_FORCE_SHORT_XFER flag can be used to deal with
devices like the ADMtek Pegasus that sense the end of bulk OUT
transfers in a special way (if a transfer is exactly a multiple
of 64 bytes in size, you need to send an extra empty packet
to terminate the transfer).
o usbd_open_pipe_intr() now accepts an interval argument which
can be used to change the rate at which the interrupt callback
routine is invoked. Specifying USBD_DEFAULT_INTERVAL uses the
value specified in the device's config data, but drivers can
override it if needed.
- Change if_aue to use USBD_FORCE_SHORT_XFER for packet transmissions.
- Change if_aue, if_kue and if_cue to use USBD_NO_TSLEEP for all
control transfers. We no longer force the non-tsleep hack for
bulk transfers since these are done asynchronously anyway.
- Removed quirk entry fiddling from if_aue and if_kue since we don't
need it anymore now that we have the USBD_NO_TSLEEP flag.
- Tweak ulpt, uhid, ums and ukbd drivers to use the new arg to
usbd_open_pipe_intr().
- Add a flag to the softc struct in the ethernet drivers to indicate
when a device has been detached, and use this flag to perform
tests to prevent the drivers from trying to do control transfers
if this is the case. This is necessary because calling if_detach()
with INET6 enabled will eventually result in a call to the driver's
ioctl() routine to delete the multicast groups on the interface,
which will result in attempts to perform control transfers. (It's
possible this also happens even without INET6 support enabled.) This
is pointless since we know that if the detach method has been called,
the hardware has been unplugged.
- Changed watchdog timeout routines to just call the driver init routines
to initialize the device states without trying to close and re-open the
pipes. This is partly because we don't want to frob things at interrupt
context, but also because this doesn't seem to work right and I don't
want to panic the system just because a USB device may have stopped
responding.
- Fix aue_rxeof() to be a little smarter about detecting when a double
transfer is needed. Unfortunately, the design of the chip makes it hard
to get this exactly right. Hopefully, this will go away once either
Nick or Lennart finds the bug in the uhci driver that makes this ugly
hack necessary.
- Also sync usbdevs with NetBSD.
2000-01-20 07:38:33 +00:00
|
|
|
--usbd_nbuses;
|
1999-11-17 22:33:51 +00:00
|
|
|
}
|
|
|
|
|
2002-04-01 17:05:55 +00:00
|
|
|
static __inline int usbd_xfer_isread(usbd_xfer_handle xfer);
|
|
|
|
static __inline int
|
|
|
|
usbd_xfer_isread(usbd_xfer_handle xfer)
|
1999-10-07 19:26:38 +00:00
|
|
|
{
|
1999-11-17 22:33:51 +00:00
|
|
|
if (xfer->rqflags & URQ_REQUEST)
|
|
|
|
return (xfer->request.bmRequestType & UT_READ);
|
1999-10-07 19:26:38 +00:00
|
|
|
else
|
1999-11-17 22:33:51 +00:00
|
|
|
return (xfer->pipe->endpoint->edesc->bEndpointAddress &
|
1999-10-07 19:26:38 +00:00
|
|
|
UE_DIR_IN);
|
|
|
|
}
|
1998-11-26 23:13:13 +00:00
|
|
|
|
1999-04-11 20:50:33 +00:00
|
|
|
#ifdef USB_DEBUG
|
2002-04-07 10:41:51 +00:00
|
|
|
void
|
|
|
|
usbd_dump_iface(struct usbd_interface *iface)
|
|
|
|
{
|
|
|
|
printf("usbd_dump_iface: iface=%p\n", iface);
|
|
|
|
if (iface == NULL)
|
|
|
|
return;
|
|
|
|
printf(" device=%p idesc=%p index=%d altindex=%d priv=%p\n",
|
|
|
|
iface->device, iface->idesc, iface->index, iface->altindex,
|
|
|
|
iface->priv);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
usbd_dump_device(struct usbd_device *dev)
|
|
|
|
{
|
|
|
|
printf("usbd_dump_device: dev=%p\n", dev);
|
|
|
|
if (dev == NULL)
|
|
|
|
return;
|
|
|
|
printf(" bus=%p default_pipe=%p\n", dev->bus, dev->default_pipe);
|
2002-04-07 11:19:05 +00:00
|
|
|
printf(" address=%d config=%d depth=%d speed=%d self_powered=%d "
|
|
|
|
"power=%d langid=%d\n",
|
|
|
|
dev->address, dev->config, dev->depth, dev->speed,
|
2002-04-07 10:41:51 +00:00
|
|
|
dev->self_powered, dev->power, dev->langid);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
usbd_dump_endpoint(struct usbd_endpoint *endp)
|
|
|
|
{
|
|
|
|
printf("usbd_dump_endpoint: endp=%p\n", endp);
|
|
|
|
if (endp == NULL)
|
|
|
|
return;
|
|
|
|
printf(" edesc=%p refcnt=%d\n", endp->edesc, endp->refcnt);
|
|
|
|
if (endp->edesc)
|
|
|
|
printf(" bEndpointAddress=0x%02x\n",
|
|
|
|
endp->edesc->bEndpointAddress);
|
|
|
|
}
|
|
|
|
|
1999-10-07 19:26:38 +00:00
|
|
|
void
|
2002-04-01 17:05:55 +00:00
|
|
|
usbd_dump_queue(usbd_pipe_handle pipe)
|
1999-10-07 19:26:38 +00:00
|
|
|
{
|
1999-11-17 22:33:51 +00:00
|
|
|
usbd_xfer_handle xfer;
|
1999-10-07 19:26:38 +00:00
|
|
|
|
|
|
|
printf("usbd_dump_queue: pipe=%p\n", pipe);
|
1999-11-17 22:33:51 +00:00
|
|
|
for (xfer = SIMPLEQ_FIRST(&pipe->queue);
|
|
|
|
xfer;
|
|
|
|
xfer = SIMPLEQ_NEXT(xfer, next)) {
|
|
|
|
printf(" xfer=%p\n", xfer);
|
1999-10-07 19:26:38 +00:00
|
|
|
}
|
|
|
|
}
|
2002-04-07 10:41:51 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
usbd_dump_pipe(usbd_pipe_handle pipe)
|
|
|
|
{
|
|
|
|
printf("usbd_dump_pipe: pipe=%p\n", pipe);
|
|
|
|
if (pipe == NULL)
|
|
|
|
return;
|
|
|
|
usbd_dump_iface(pipe->iface);
|
|
|
|
usbd_dump_device(pipe->device);
|
|
|
|
usbd_dump_endpoint(pipe->endpoint);
|
|
|
|
printf(" (usbd_dump_pipe:)\n refcnt=%d running=%d aborting=%d\n",
|
|
|
|
pipe->refcnt, pipe->running, pipe->aborting);
|
2002-04-07 12:25:55 +00:00
|
|
|
printf(" intrxfer=%p, repeat=%d, interval=%d\n",
|
2002-04-07 10:41:51 +00:00
|
|
|
pipe->intrxfer, pipe->repeat, pipe->interval);
|
|
|
|
}
|
1999-10-07 19:26:38 +00:00
|
|
|
#endif
|
1999-04-11 20:50:33 +00:00
|
|
|
|
1998-11-26 23:13:13 +00:00
|
|
|
usbd_status
|
2002-04-01 17:24:49 +00:00
|
|
|
usbd_open_pipe(usbd_interface_handle iface, u_int8_t address,
|
|
|
|
u_int8_t flags, usbd_pipe_handle *pipe)
|
More USB ethernet tweaks:
- Sync ohci, uhci and usbdi modules with NetBSD in order to obtain the
following improvements:
o New USBD_NO_TSLEEP flag can be used in place of UQ_NO_TSLEEP
quirk. This allows drivers to specify busy waiting only for
certain transfers (namely control transfers for reading/writing
registers and stuff).
o New USBD_FORCE_SHORT_XFER flag can be used to deal with
devices like the ADMtek Pegasus that sense the end of bulk OUT
transfers in a special way (if a transfer is exactly a multiple
of 64 bytes in size, you need to send an extra empty packet
to terminate the transfer).
o usbd_open_pipe_intr() now accepts an interval argument which
can be used to change the rate at which the interrupt callback
routine is invoked. Specifying USBD_DEFAULT_INTERVAL uses the
value specified in the device's config data, but drivers can
override it if needed.
- Change if_aue to use USBD_FORCE_SHORT_XFER for packet transmissions.
- Change if_aue, if_kue and if_cue to use USBD_NO_TSLEEP for all
control transfers. We no longer force the non-tsleep hack for
bulk transfers since these are done asynchronously anyway.
- Removed quirk entry fiddling from if_aue and if_kue since we don't
need it anymore now that we have the USBD_NO_TSLEEP flag.
- Tweak ulpt, uhid, ums and ukbd drivers to use the new arg to
usbd_open_pipe_intr().
- Add a flag to the softc struct in the ethernet drivers to indicate
when a device has been detached, and use this flag to perform
tests to prevent the drivers from trying to do control transfers
if this is the case. This is necessary because calling if_detach()
with INET6 enabled will eventually result in a call to the driver's
ioctl() routine to delete the multicast groups on the interface,
which will result in attempts to perform control transfers. (It's
possible this also happens even without INET6 support enabled.) This
is pointless since we know that if the detach method has been called,
the hardware has been unplugged.
- Changed watchdog timeout routines to just call the driver init routines
to initialize the device states without trying to close and re-open the
pipes. This is partly because we don't want to frob things at interrupt
context, but also because this doesn't seem to work right and I don't
want to panic the system just because a USB device may have stopped
responding.
- Fix aue_rxeof() to be a little smarter about detecting when a double
transfer is needed. Unfortunately, the design of the chip makes it hard
to get this exactly right. Hopefully, this will go away once either
Nick or Lennart finds the bug in the uhci driver that makes this ugly
hack necessary.
- Also sync usbdevs with NetBSD.
2000-01-20 07:38:33 +00:00
|
|
|
{
|
|
|
|
return (usbd_open_pipe_ival(iface, address, flags, pipe,
|
|
|
|
USBD_DEFAULT_INTERVAL));
|
|
|
|
}
|
|
|
|
|
|
|
|
usbd_status
|
2002-04-01 17:24:49 +00:00
|
|
|
usbd_open_pipe_ival(usbd_interface_handle iface, u_int8_t address,
|
|
|
|
u_int8_t flags, usbd_pipe_handle *pipe, int ival)
|
1998-11-26 23:13:13 +00:00
|
|
|
{
|
|
|
|
usbd_pipe_handle p;
|
|
|
|
struct usbd_endpoint *ep;
|
1999-11-17 22:33:51 +00:00
|
|
|
usbd_status err;
|
1999-01-07 23:07:57 +00:00
|
|
|
int i;
|
1998-11-26 23:13:13 +00:00
|
|
|
|
More USB ethernet tweaks:
- Sync ohci, uhci and usbdi modules with NetBSD in order to obtain the
following improvements:
o New USBD_NO_TSLEEP flag can be used in place of UQ_NO_TSLEEP
quirk. This allows drivers to specify busy waiting only for
certain transfers (namely control transfers for reading/writing
registers and stuff).
o New USBD_FORCE_SHORT_XFER flag can be used to deal with
devices like the ADMtek Pegasus that sense the end of bulk OUT
transfers in a special way (if a transfer is exactly a multiple
of 64 bytes in size, you need to send an extra empty packet
to terminate the transfer).
o usbd_open_pipe_intr() now accepts an interval argument which
can be used to change the rate at which the interrupt callback
routine is invoked. Specifying USBD_DEFAULT_INTERVAL uses the
value specified in the device's config data, but drivers can
override it if needed.
- Change if_aue to use USBD_FORCE_SHORT_XFER for packet transmissions.
- Change if_aue, if_kue and if_cue to use USBD_NO_TSLEEP for all
control transfers. We no longer force the non-tsleep hack for
bulk transfers since these are done asynchronously anyway.
- Removed quirk entry fiddling from if_aue and if_kue since we don't
need it anymore now that we have the USBD_NO_TSLEEP flag.
- Tweak ulpt, uhid, ums and ukbd drivers to use the new arg to
usbd_open_pipe_intr().
- Add a flag to the softc struct in the ethernet drivers to indicate
when a device has been detached, and use this flag to perform
tests to prevent the drivers from trying to do control transfers
if this is the case. This is necessary because calling if_detach()
with INET6 enabled will eventually result in a call to the driver's
ioctl() routine to delete the multicast groups on the interface,
which will result in attempts to perform control transfers. (It's
possible this also happens even without INET6 support enabled.) This
is pointless since we know that if the detach method has been called,
the hardware has been unplugged.
- Changed watchdog timeout routines to just call the driver init routines
to initialize the device states without trying to close and re-open the
pipes. This is partly because we don't want to frob things at interrupt
context, but also because this doesn't seem to work right and I don't
want to panic the system just because a USB device may have stopped
responding.
- Fix aue_rxeof() to be a little smarter about detecting when a double
transfer is needed. Unfortunately, the design of the chip makes it hard
to get this exactly right. Hopefully, this will go away once either
Nick or Lennart finds the bug in the uhci driver that makes this ugly
hack necessary.
- Also sync usbdevs with NetBSD.
2000-01-20 07:38:33 +00:00
|
|
|
DPRINTFN(3,("usbd_open_pipe: iface=%p address=0x%x flags=0x%x\n",
|
|
|
|
iface, address, flags));
|
|
|
|
|
1998-11-26 23:13:13 +00:00
|
|
|
for (i = 0; i < iface->idesc->bNumEndpoints; i++) {
|
|
|
|
ep = &iface->endpoints[i];
|
1999-11-28 21:01:06 +00:00
|
|
|
if (ep->edesc == NULL)
|
|
|
|
return (USBD_IOERROR);
|
1998-11-26 23:13:13 +00:00
|
|
|
if (ep->edesc->bEndpointAddress == address)
|
|
|
|
goto found;
|
|
|
|
}
|
|
|
|
return (USBD_BAD_ADDRESS);
|
|
|
|
found:
|
More USB ethernet tweaks:
- Sync ohci, uhci and usbdi modules with NetBSD in order to obtain the
following improvements:
o New USBD_NO_TSLEEP flag can be used in place of UQ_NO_TSLEEP
quirk. This allows drivers to specify busy waiting only for
certain transfers (namely control transfers for reading/writing
registers and stuff).
o New USBD_FORCE_SHORT_XFER flag can be used to deal with
devices like the ADMtek Pegasus that sense the end of bulk OUT
transfers in a special way (if a transfer is exactly a multiple
of 64 bytes in size, you need to send an extra empty packet
to terminate the transfer).
o usbd_open_pipe_intr() now accepts an interval argument which
can be used to change the rate at which the interrupt callback
routine is invoked. Specifying USBD_DEFAULT_INTERVAL uses the
value specified in the device's config data, but drivers can
override it if needed.
- Change if_aue to use USBD_FORCE_SHORT_XFER for packet transmissions.
- Change if_aue, if_kue and if_cue to use USBD_NO_TSLEEP for all
control transfers. We no longer force the non-tsleep hack for
bulk transfers since these are done asynchronously anyway.
- Removed quirk entry fiddling from if_aue and if_kue since we don't
need it anymore now that we have the USBD_NO_TSLEEP flag.
- Tweak ulpt, uhid, ums and ukbd drivers to use the new arg to
usbd_open_pipe_intr().
- Add a flag to the softc struct in the ethernet drivers to indicate
when a device has been detached, and use this flag to perform
tests to prevent the drivers from trying to do control transfers
if this is the case. This is necessary because calling if_detach()
with INET6 enabled will eventually result in a call to the driver's
ioctl() routine to delete the multicast groups on the interface,
which will result in attempts to perform control transfers. (It's
possible this also happens even without INET6 support enabled.) This
is pointless since we know that if the detach method has been called,
the hardware has been unplugged.
- Changed watchdog timeout routines to just call the driver init routines
to initialize the device states without trying to close and re-open the
pipes. This is partly because we don't want to frob things at interrupt
context, but also because this doesn't seem to work right and I don't
want to panic the system just because a USB device may have stopped
responding.
- Fix aue_rxeof() to be a little smarter about detecting when a double
transfer is needed. Unfortunately, the design of the chip makes it hard
to get this exactly right. Hopefully, this will go away once either
Nick or Lennart finds the bug in the uhci driver that makes this ugly
hack necessary.
- Also sync usbdevs with NetBSD.
2000-01-20 07:38:33 +00:00
|
|
|
if ((flags & USBD_EXCLUSIVE_USE) && ep->refcnt != 0)
|
1998-11-26 23:13:13 +00:00
|
|
|
return (USBD_IN_USE);
|
More USB ethernet tweaks:
- Sync ohci, uhci and usbdi modules with NetBSD in order to obtain the
following improvements:
o New USBD_NO_TSLEEP flag can be used in place of UQ_NO_TSLEEP
quirk. This allows drivers to specify busy waiting only for
certain transfers (namely control transfers for reading/writing
registers and stuff).
o New USBD_FORCE_SHORT_XFER flag can be used to deal with
devices like the ADMtek Pegasus that sense the end of bulk OUT
transfers in a special way (if a transfer is exactly a multiple
of 64 bytes in size, you need to send an extra empty packet
to terminate the transfer).
o usbd_open_pipe_intr() now accepts an interval argument which
can be used to change the rate at which the interrupt callback
routine is invoked. Specifying USBD_DEFAULT_INTERVAL uses the
value specified in the device's config data, but drivers can
override it if needed.
- Change if_aue to use USBD_FORCE_SHORT_XFER for packet transmissions.
- Change if_aue, if_kue and if_cue to use USBD_NO_TSLEEP for all
control transfers. We no longer force the non-tsleep hack for
bulk transfers since these are done asynchronously anyway.
- Removed quirk entry fiddling from if_aue and if_kue since we don't
need it anymore now that we have the USBD_NO_TSLEEP flag.
- Tweak ulpt, uhid, ums and ukbd drivers to use the new arg to
usbd_open_pipe_intr().
- Add a flag to the softc struct in the ethernet drivers to indicate
when a device has been detached, and use this flag to perform
tests to prevent the drivers from trying to do control transfers
if this is the case. This is necessary because calling if_detach()
with INET6 enabled will eventually result in a call to the driver's
ioctl() routine to delete the multicast groups on the interface,
which will result in attempts to perform control transfers. (It's
possible this also happens even without INET6 support enabled.) This
is pointless since we know that if the detach method has been called,
the hardware has been unplugged.
- Changed watchdog timeout routines to just call the driver init routines
to initialize the device states without trying to close and re-open the
pipes. This is partly because we don't want to frob things at interrupt
context, but also because this doesn't seem to work right and I don't
want to panic the system just because a USB device may have stopped
responding.
- Fix aue_rxeof() to be a little smarter about detecting when a double
transfer is needed. Unfortunately, the design of the chip makes it hard
to get this exactly right. Hopefully, this will go away once either
Nick or Lennart finds the bug in the uhci driver that makes this ugly
hack necessary.
- Also sync usbdevs with NetBSD.
2000-01-20 07:38:33 +00:00
|
|
|
err = usbd_setup_pipe(iface->device, iface, ep, ival, &p);
|
1999-11-17 22:33:51 +00:00
|
|
|
if (err)
|
|
|
|
return (err);
|
1998-11-26 23:13:13 +00:00
|
|
|
LIST_INSERT_HEAD(&iface->pipes, p, next);
|
|
|
|
*pipe = p;
|
|
|
|
return (USBD_NORMAL_COMPLETION);
|
|
|
|
}
|
|
|
|
|
|
|
|
usbd_status
|
2002-04-01 17:24:49 +00:00
|
|
|
usbd_open_pipe_intr(usbd_interface_handle iface, u_int8_t address,
|
|
|
|
u_int8_t flags, usbd_pipe_handle *pipe,
|
|
|
|
usbd_private_handle priv, void *buffer, u_int32_t len,
|
|
|
|
usbd_callback cb, int ival)
|
1998-11-26 23:13:13 +00:00
|
|
|
{
|
1999-11-17 22:33:51 +00:00
|
|
|
usbd_status err;
|
|
|
|
usbd_xfer_handle xfer;
|
1998-11-26 23:13:13 +00:00
|
|
|
usbd_pipe_handle ipipe;
|
|
|
|
|
More USB ethernet tweaks:
- Sync ohci, uhci and usbdi modules with NetBSD in order to obtain the
following improvements:
o New USBD_NO_TSLEEP flag can be used in place of UQ_NO_TSLEEP
quirk. This allows drivers to specify busy waiting only for
certain transfers (namely control transfers for reading/writing
registers and stuff).
o New USBD_FORCE_SHORT_XFER flag can be used to deal with
devices like the ADMtek Pegasus that sense the end of bulk OUT
transfers in a special way (if a transfer is exactly a multiple
of 64 bytes in size, you need to send an extra empty packet
to terminate the transfer).
o usbd_open_pipe_intr() now accepts an interval argument which
can be used to change the rate at which the interrupt callback
routine is invoked. Specifying USBD_DEFAULT_INTERVAL uses the
value specified in the device's config data, but drivers can
override it if needed.
- Change if_aue to use USBD_FORCE_SHORT_XFER for packet transmissions.
- Change if_aue, if_kue and if_cue to use USBD_NO_TSLEEP for all
control transfers. We no longer force the non-tsleep hack for
bulk transfers since these are done asynchronously anyway.
- Removed quirk entry fiddling from if_aue and if_kue since we don't
need it anymore now that we have the USBD_NO_TSLEEP flag.
- Tweak ulpt, uhid, ums and ukbd drivers to use the new arg to
usbd_open_pipe_intr().
- Add a flag to the softc struct in the ethernet drivers to indicate
when a device has been detached, and use this flag to perform
tests to prevent the drivers from trying to do control transfers
if this is the case. This is necessary because calling if_detach()
with INET6 enabled will eventually result in a call to the driver's
ioctl() routine to delete the multicast groups on the interface,
which will result in attempts to perform control transfers. (It's
possible this also happens even without INET6 support enabled.) This
is pointless since we know that if the detach method has been called,
the hardware has been unplugged.
- Changed watchdog timeout routines to just call the driver init routines
to initialize the device states without trying to close and re-open the
pipes. This is partly because we don't want to frob things at interrupt
context, but also because this doesn't seem to work right and I don't
want to panic the system just because a USB device may have stopped
responding.
- Fix aue_rxeof() to be a little smarter about detecting when a double
transfer is needed. Unfortunately, the design of the chip makes it hard
to get this exactly right. Hopefully, this will go away once either
Nick or Lennart finds the bug in the uhci driver that makes this ugly
hack necessary.
- Also sync usbdevs with NetBSD.
2000-01-20 07:38:33 +00:00
|
|
|
DPRINTFN(3,("usbd_open_pipe_intr: address=0x%x flags=0x%x len=%d\n",
|
|
|
|
address, flags, len));
|
|
|
|
|
|
|
|
err = usbd_open_pipe_ival(iface, address, USBD_EXCLUSIVE_USE,
|
|
|
|
&ipipe, ival);
|
1999-11-17 22:33:51 +00:00
|
|
|
if (err)
|
|
|
|
return (err);
|
1999-11-28 21:01:06 +00:00
|
|
|
xfer = usbd_alloc_xfer(iface->device);
|
1999-11-17 22:33:51 +00:00
|
|
|
if (xfer == NULL) {
|
|
|
|
err = USBD_NOMEM;
|
1998-11-26 23:13:13 +00:00
|
|
|
goto bad1;
|
1999-10-07 19:26:38 +00:00
|
|
|
}
|
More USB ethernet tweaks:
- Sync ohci, uhci and usbdi modules with NetBSD in order to obtain the
following improvements:
o New USBD_NO_TSLEEP flag can be used in place of UQ_NO_TSLEEP
quirk. This allows drivers to specify busy waiting only for
certain transfers (namely control transfers for reading/writing
registers and stuff).
o New USBD_FORCE_SHORT_XFER flag can be used to deal with
devices like the ADMtek Pegasus that sense the end of bulk OUT
transfers in a special way (if a transfer is exactly a multiple
of 64 bytes in size, you need to send an extra empty packet
to terminate the transfer).
o usbd_open_pipe_intr() now accepts an interval argument which
can be used to change the rate at which the interrupt callback
routine is invoked. Specifying USBD_DEFAULT_INTERVAL uses the
value specified in the device's config data, but drivers can
override it if needed.
- Change if_aue to use USBD_FORCE_SHORT_XFER for packet transmissions.
- Change if_aue, if_kue and if_cue to use USBD_NO_TSLEEP for all
control transfers. We no longer force the non-tsleep hack for
bulk transfers since these are done asynchronously anyway.
- Removed quirk entry fiddling from if_aue and if_kue since we don't
need it anymore now that we have the USBD_NO_TSLEEP flag.
- Tweak ulpt, uhid, ums and ukbd drivers to use the new arg to
usbd_open_pipe_intr().
- Add a flag to the softc struct in the ethernet drivers to indicate
when a device has been detached, and use this flag to perform
tests to prevent the drivers from trying to do control transfers
if this is the case. This is necessary because calling if_detach()
with INET6 enabled will eventually result in a call to the driver's
ioctl() routine to delete the multicast groups on the interface,
which will result in attempts to perform control transfers. (It's
possible this also happens even without INET6 support enabled.) This
is pointless since we know that if the detach method has been called,
the hardware has been unplugged.
- Changed watchdog timeout routines to just call the driver init routines
to initialize the device states without trying to close and re-open the
pipes. This is partly because we don't want to frob things at interrupt
context, but also because this doesn't seem to work right and I don't
want to panic the system just because a USB device may have stopped
responding.
- Fix aue_rxeof() to be a little smarter about detecting when a double
transfer is needed. Unfortunately, the design of the chip makes it hard
to get this exactly right. Hopefully, this will go away once either
Nick or Lennart finds the bug in the uhci driver that makes this ugly
hack necessary.
- Also sync usbdevs with NetBSD.
2000-01-20 07:38:33 +00:00
|
|
|
usbd_setup_xfer(xfer, ipipe, priv, buffer, len, flags,
|
|
|
|
USBD_NO_TIMEOUT, cb);
|
1999-11-17 22:33:51 +00:00
|
|
|
ipipe->intrxfer = xfer;
|
1999-10-07 19:26:38 +00:00
|
|
|
ipipe->repeat = 1;
|
1999-11-17 22:33:51 +00:00
|
|
|
err = usbd_transfer(xfer);
|
1998-11-26 23:13:13 +00:00
|
|
|
*pipe = ipipe;
|
1999-11-17 22:33:51 +00:00
|
|
|
if (err != USBD_IN_PROGRESS)
|
1999-10-07 19:26:38 +00:00
|
|
|
goto bad2;
|
1998-11-26 23:13:13 +00:00
|
|
|
return (USBD_NORMAL_COMPLETION);
|
|
|
|
|
|
|
|
bad2:
|
1999-11-17 22:33:51 +00:00
|
|
|
ipipe->intrxfer = NULL;
|
1999-10-07 19:26:38 +00:00
|
|
|
ipipe->repeat = 0;
|
1999-11-28 21:01:06 +00:00
|
|
|
usbd_free_xfer(xfer);
|
1999-10-07 19:26:38 +00:00
|
|
|
bad1:
|
|
|
|
usbd_close_pipe(ipipe);
|
1999-11-17 22:33:51 +00:00
|
|
|
return (err);
|
1998-11-26 23:13:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
usbd_status
|
2002-04-01 17:24:49 +00:00
|
|
|
usbd_close_pipe(usbd_pipe_handle pipe)
|
1998-11-26 23:13:13 +00:00
|
|
|
{
|
1999-10-07 19:26:38 +00:00
|
|
|
#ifdef DIAGNOSTIC
|
1999-11-17 22:33:51 +00:00
|
|
|
if (pipe == NULL) {
|
1999-10-07 19:26:38 +00:00
|
|
|
printf("usbd_close_pipe: pipe==NULL\n");
|
|
|
|
return (USBD_NORMAL_COMPLETION);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1998-11-26 23:13:13 +00:00
|
|
|
if (--pipe->refcnt != 0)
|
|
|
|
return (USBD_NORMAL_COMPLETION);
|
|
|
|
if (SIMPLEQ_FIRST(&pipe->queue) != 0)
|
|
|
|
return (USBD_PENDING_REQUESTS);
|
|
|
|
LIST_REMOVE(pipe, next);
|
|
|
|
pipe->endpoint->refcnt--;
|
|
|
|
pipe->methods->close(pipe);
|
1999-11-17 22:33:51 +00:00
|
|
|
if (pipe->intrxfer != NULL)
|
1999-11-28 21:01:06 +00:00
|
|
|
usbd_free_xfer(pipe->intrxfer);
|
1998-11-26 23:13:13 +00:00
|
|
|
free(pipe, M_USB);
|
|
|
|
return (USBD_NORMAL_COMPLETION);
|
|
|
|
}
|
|
|
|
|
1999-10-07 19:26:38 +00:00
|
|
|
usbd_status
|
2002-04-01 17:24:49 +00:00
|
|
|
usbd_transfer(usbd_xfer_handle xfer)
|
1998-11-26 23:13:13 +00:00
|
|
|
{
|
1999-11-17 22:33:51 +00:00
|
|
|
usbd_pipe_handle pipe = xfer->pipe;
|
|
|
|
usb_dma_t *dmap = &xfer->dmabuf;
|
|
|
|
usbd_status err;
|
1999-10-07 19:26:38 +00:00
|
|
|
u_int size;
|
|
|
|
int s;
|
|
|
|
|
1999-11-17 22:33:51 +00:00
|
|
|
DPRINTFN(5,("usbd_transfer: xfer=%p, flags=%d, pipe=%p, running=%d\n",
|
|
|
|
xfer, xfer->flags, pipe, pipe->running));
|
1999-10-07 19:26:38 +00:00
|
|
|
#ifdef USB_DEBUG
|
|
|
|
if (usbdebug > 5)
|
|
|
|
usbd_dump_queue(pipe);
|
|
|
|
#endif
|
1999-11-17 22:33:51 +00:00
|
|
|
xfer->done = 0;
|
1999-10-07 19:26:38 +00:00
|
|
|
|
Huge merge from NetBSD:
usbdi.c (1.61):
===================================================================
revision 1.61
date: 2000/01/31 20:13:07; author: augustss; lines: +20 -4
Change the way the HC done method is invoked a little.
===================================================================
usbdi.c (1.65):
===================================================================
revision 1.65
date: 2000/03/08 15:34:10; author: augustss; lines: +4 -2
Get the status right when a polled transfer times out.
===================================================================
ohci.c (1.79), uhci.c (1.89), uhcivar.h (1.24), usb_port.h (1.22),
usbdivar.h (1.48):
===================================================================
date: 2000/03/23 07:01:46; author: thorpej;
New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.
The old timeout()/untimeout() API has been removed from the kernel.
===================================================================
uhci.c (1.80), usbdi.c (1.66):
===================================================================
date: 2000/03/23 18:59:10; author: thorpej;
Shake out some bugs from the callout changes.
===================================================================
ohci.c (1.80), uhci.c (1.91), uhcivar.h (1.25), usb_port.h (1.23),
usbdi.c (1.67), usbdivar.h (1.49):
===================================================================
date: 2000/03/24 22:03:30; author: augustss;
Some cleanup and renaming of the callouts used in USB drivers.
===================================================================
uhci.c (1.92), uhcivar.h (1.26):
===================================================================
date: 2000/03/24 22:57:58; author: augustss;
Two major changes:
Make each xfer have its own intr_info. This is necessary if we want
to queue multiple xfers on an endpoint. This should get rid of the
(mostly harmless) DIAGNOSTICs about intr_infos (not) being done.
Change (again!) how xfers are aborted. Aborting a TD is a nightmare
on the braindead UHCI controller. (Unless you stop the HC, thereby
losing isoc traffic.) Hopefully I got it right this time.
===================================================================
usbdivar.h (1.50):
===================================================================
revision 1.50
date: 2000/03/25 00:10:19; author: augustss; lines: +4 -2
GC an unsued field and add some DIAGNOSTIC in xfer.
===================================================================
ums.c: Use the callout functions instead of the timeout ones.
uhci.c (1.93):
===================================================================
revision 1.93
date: 2000/03/25 00:11:21; author: augustss;
lines: +26 -1
Add more DIAGNOSTIC when aborting isoc.
===================================================================
uhci.c (1.94), usbdivar.h (1.51):
===================================================================
date: 2000/03/25 07:13:05; author: augustss;
More DIAGNOSTIC.
Initialize a callout handle I forgot.
===================================================================
uhci.c (1.95):
===================================================================
revision 1.95
date: 2000/03/25 07:23:12; author: augustss;
Exp; lines: +24 -7
Improve uhci_dump_ii().
===================================================================
ohci.c (1.81), uhci.c (1.96), uhcivar.h (1.27), usb_subr.c (1.68),
usbdi.c (1.68), usbdivar.h (1.52):
===================================================================
date: 2000/03/25 18:02:33; author: augustss;
Rename and move around callout handles to make it more sane.
Add some DIAGNOSTIC.
Fix buglet in isoc abort on UHCI.
===================================================================
uhci.c (1.98):
===================================================================
revision 1.98
date: 2000/03/27 07:39:48; author: augustss; lines: +12 -4
Make it compile without DIAGNOSTIC.
===================================================================
uhci.c (1.99):
===================================================================
revision 1.99
date: 2000/03/27 08:01:09; author: augustss; lines: +1 -5
Remove some debug nonsense.
===================================================================
uhci.c (1.100):
===================================================================
revision 1.100
date: 2000/03/27 09:41:36; author: augustss; lines: +13 -3
Don't mess with QH in bulk abort for the moment.
===================================================================
uhci.c (1.102):
===================================================================
revision 1.102
date: 2000/03/27 22:42:57; author: augustss; lines: +66 -26
Be a little more careful when aborting.
Preallocate some TDs for large buffers.
===================================================================
uhci.c (1.103):
===================================================================
date: 2000/03/28 09:47:10; author: augustss; lines: +11 -1
Another patch for xfer abort...
XXX The current xfer queueing and aborting semantics should really
XXX be changed. It cannot be implemented in a sane way on UHCI.
XXX One day when I have lots of time I'll redesign it...
===================================================================
uhci.c (1.104): Correct a debug message.
uhci.c (1.105): Be more defensive in a DIAGNOSTIC test.
uhci.c (1.106):
===================================================================
revision 1.106
date: 2000/03/29 01:49:13; author: augustss; lines: +14 -309
*SIGH* Revert back to the old method of aborting xfers.
I had tested the new stuff for two months now, but as soon as I commited
it the problems started to appear. Murphy, no doubt...
===================================================================
usb_subr.c (1.70), usbdi.c (1.71), usbdivar.h (1.53):
===================================================================
revision 1.70
date: 2000/03/29 01:45:20; author: augustss; lines: +2 -1
Do not accept new xfers for queuing while a pipe is aborting.
===================================================================
2002-03-16 12:06:01 +00:00
|
|
|
if (pipe->aborting)
|
|
|
|
return (USBD_CANCELLED);
|
|
|
|
|
1999-11-17 22:33:51 +00:00
|
|
|
size = xfer->length;
|
|
|
|
/* If there is no buffer, allocate one. */
|
|
|
|
if (!(xfer->rqflags & URQ_DEV_DMABUF) && size != 0) {
|
1999-10-07 19:26:38 +00:00
|
|
|
struct usbd_bus *bus = pipe->device->bus;
|
|
|
|
|
|
|
|
#ifdef DIAGNOSTIC
|
1999-11-17 22:33:51 +00:00
|
|
|
if (xfer->rqflags & URQ_AUTO_DMABUF)
|
1999-10-07 19:26:38 +00:00
|
|
|
printf("usbd_transfer: has old buffer!\n");
|
|
|
|
#endif
|
1999-11-17 22:33:51 +00:00
|
|
|
err = bus->methods->allocm(bus, dmap, size);
|
|
|
|
if (err)
|
|
|
|
return (err);
|
|
|
|
xfer->rqflags |= URQ_AUTO_DMABUF;
|
1999-10-07 19:26:38 +00:00
|
|
|
}
|
|
|
|
|
1999-11-17 22:33:51 +00:00
|
|
|
/* Copy data if going out. */
|
|
|
|
if (!(xfer->flags & USBD_NO_COPY) && size != 0 &&
|
|
|
|
!usbd_xfer_isread(xfer))
|
2000-02-10 18:50:19 +00:00
|
|
|
memcpy(KERNADDR(dmap, 0), xfer->buffer, size);
|
1999-11-17 22:33:51 +00:00
|
|
|
|
|
|
|
err = pipe->methods->transfer(xfer);
|
1999-10-07 19:26:38 +00:00
|
|
|
|
1999-11-17 22:33:51 +00:00
|
|
|
if (err != USBD_IN_PROGRESS && err) {
|
1999-10-07 19:26:38 +00:00
|
|
|
/* The transfer has not been queued, so free buffer. */
|
1999-11-17 22:33:51 +00:00
|
|
|
if (xfer->rqflags & URQ_AUTO_DMABUF) {
|
1999-10-07 19:26:38 +00:00
|
|
|
struct usbd_bus *bus = pipe->device->bus;
|
|
|
|
|
1999-11-17 22:33:51 +00:00
|
|
|
bus->methods->freem(bus, &xfer->dmabuf);
|
|
|
|
xfer->rqflags &= ~URQ_AUTO_DMABUF;
|
1999-10-07 19:26:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-11-17 22:33:51 +00:00
|
|
|
if (!(xfer->flags & USBD_SYNCHRONOUS))
|
|
|
|
return (err);
|
1999-10-07 19:26:38 +00:00
|
|
|
|
|
|
|
/* Sync transfer, wait for completion. */
|
1999-11-17 22:33:51 +00:00
|
|
|
if (err != USBD_IN_PROGRESS)
|
|
|
|
return (err);
|
1999-10-07 19:26:38 +00:00
|
|
|
s = splusb();
|
1999-11-17 22:33:51 +00:00
|
|
|
if (!xfer->done) {
|
1999-10-07 19:26:38 +00:00
|
|
|
if (pipe->device->bus->use_polling)
|
|
|
|
panic("usbd_transfer: not done\n");
|
2002-04-07 12:18:52 +00:00
|
|
|
tsleep(xfer, PRIBIO, "usbsyn", 0);
|
1999-10-07 19:26:38 +00:00
|
|
|
}
|
|
|
|
splx(s);
|
1999-11-17 22:33:51 +00:00
|
|
|
return (xfer->status);
|
1999-10-07 19:26:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Like usbd_transfer(), but waits for completion. */
|
|
|
|
usbd_status
|
2002-04-01 17:24:49 +00:00
|
|
|
usbd_sync_transfer(usbd_xfer_handle xfer)
|
1999-10-07 19:26:38 +00:00
|
|
|
{
|
1999-11-17 22:33:51 +00:00
|
|
|
xfer->flags |= USBD_SYNCHRONOUS;
|
|
|
|
return (usbd_transfer(xfer));
|
1998-11-26 23:13:13 +00:00
|
|
|
}
|
|
|
|
|
1999-10-07 19:26:38 +00:00
|
|
|
void *
|
2002-04-01 17:24:49 +00:00
|
|
|
usbd_alloc_buffer(usbd_xfer_handle xfer, u_int32_t size)
|
1998-11-26 23:13:13 +00:00
|
|
|
{
|
1999-11-17 22:33:51 +00:00
|
|
|
struct usbd_bus *bus = xfer->device->bus;
|
|
|
|
usbd_status err;
|
1999-01-07 23:07:57 +00:00
|
|
|
|
1999-11-17 22:33:51 +00:00
|
|
|
err = bus->methods->allocm(bus, &xfer->dmabuf, size);
|
|
|
|
if (err)
|
1999-10-07 19:26:38 +00:00
|
|
|
return (0);
|
1999-11-17 22:33:51 +00:00
|
|
|
xfer->rqflags |= URQ_DEV_DMABUF;
|
2000-02-10 18:50:19 +00:00
|
|
|
return (KERNADDR(&xfer->dmabuf, 0));
|
1999-10-07 19:26:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-04-01 17:24:49 +00:00
|
|
|
usbd_free_buffer(usbd_xfer_handle xfer)
|
1999-10-07 19:26:38 +00:00
|
|
|
{
|
|
|
|
#ifdef DIAGNOSTIC
|
1999-11-17 22:33:51 +00:00
|
|
|
if (!(xfer->rqflags & (URQ_DEV_DMABUF | URQ_AUTO_DMABUF))) {
|
1999-10-07 19:26:38 +00:00
|
|
|
printf("usbd_free_buffer: no buffer\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
1999-11-17 22:33:51 +00:00
|
|
|
xfer->rqflags &= ~(URQ_DEV_DMABUF | URQ_AUTO_DMABUF);
|
|
|
|
xfer->device->bus->methods->freem(xfer->device->bus, &xfer->dmabuf);
|
1999-01-07 23:07:57 +00:00
|
|
|
}
|
|
|
|
|
1999-11-17 22:33:51 +00:00
|
|
|
void *
|
2002-04-01 17:24:49 +00:00
|
|
|
usbd_get_buffer(usbd_xfer_handle xfer)
|
1999-11-17 22:33:51 +00:00
|
|
|
{
|
|
|
|
if (!(xfer->rqflags & URQ_DEV_DMABUF))
|
|
|
|
return (0);
|
2000-02-10 18:50:19 +00:00
|
|
|
return (KERNADDR(&xfer->dmabuf, 0));
|
1999-11-17 22:33:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
usbd_xfer_handle
|
2002-04-01 17:24:49 +00:00
|
|
|
usbd_alloc_xfer(usbd_device_handle dev)
|
1998-11-26 23:13:13 +00:00
|
|
|
{
|
1999-11-17 22:33:51 +00:00
|
|
|
usbd_xfer_handle xfer;
|
1998-11-26 23:13:13 +00:00
|
|
|
|
More USB ethernet tweaks:
- Sync ohci, uhci and usbdi modules with NetBSD in order to obtain the
following improvements:
o New USBD_NO_TSLEEP flag can be used in place of UQ_NO_TSLEEP
quirk. This allows drivers to specify busy waiting only for
certain transfers (namely control transfers for reading/writing
registers and stuff).
o New USBD_FORCE_SHORT_XFER flag can be used to deal with
devices like the ADMtek Pegasus that sense the end of bulk OUT
transfers in a special way (if a transfer is exactly a multiple
of 64 bytes in size, you need to send an extra empty packet
to terminate the transfer).
o usbd_open_pipe_intr() now accepts an interval argument which
can be used to change the rate at which the interrupt callback
routine is invoked. Specifying USBD_DEFAULT_INTERVAL uses the
value specified in the device's config data, but drivers can
override it if needed.
- Change if_aue to use USBD_FORCE_SHORT_XFER for packet transmissions.
- Change if_aue, if_kue and if_cue to use USBD_NO_TSLEEP for all
control transfers. We no longer force the non-tsleep hack for
bulk transfers since these are done asynchronously anyway.
- Removed quirk entry fiddling from if_aue and if_kue since we don't
need it anymore now that we have the USBD_NO_TSLEEP flag.
- Tweak ulpt, uhid, ums and ukbd drivers to use the new arg to
usbd_open_pipe_intr().
- Add a flag to the softc struct in the ethernet drivers to indicate
when a device has been detached, and use this flag to perform
tests to prevent the drivers from trying to do control transfers
if this is the case. This is necessary because calling if_detach()
with INET6 enabled will eventually result in a call to the driver's
ioctl() routine to delete the multicast groups on the interface,
which will result in attempts to perform control transfers. (It's
possible this also happens even without INET6 support enabled.) This
is pointless since we know that if the detach method has been called,
the hardware has been unplugged.
- Changed watchdog timeout routines to just call the driver init routines
to initialize the device states without trying to close and re-open the
pipes. This is partly because we don't want to frob things at interrupt
context, but also because this doesn't seem to work right and I don't
want to panic the system just because a USB device may have stopped
responding.
- Fix aue_rxeof() to be a little smarter about detecting when a double
transfer is needed. Unfortunately, the design of the chip makes it hard
to get this exactly right. Hopefully, this will go away once either
Nick or Lennart finds the bug in the uhci driver that makes this ugly
hack necessary.
- Also sync usbdevs with NetBSD.
2000-01-20 07:38:33 +00:00
|
|
|
xfer = dev->bus->methods->allocx(dev->bus);
|
1999-11-17 22:33:51 +00:00
|
|
|
if (xfer == NULL)
|
More USB ethernet tweaks:
- Sync ohci, uhci and usbdi modules with NetBSD in order to obtain the
following improvements:
o New USBD_NO_TSLEEP flag can be used in place of UQ_NO_TSLEEP
quirk. This allows drivers to specify busy waiting only for
certain transfers (namely control transfers for reading/writing
registers and stuff).
o New USBD_FORCE_SHORT_XFER flag can be used to deal with
devices like the ADMtek Pegasus that sense the end of bulk OUT
transfers in a special way (if a transfer is exactly a multiple
of 64 bytes in size, you need to send an extra empty packet
to terminate the transfer).
o usbd_open_pipe_intr() now accepts an interval argument which
can be used to change the rate at which the interrupt callback
routine is invoked. Specifying USBD_DEFAULT_INTERVAL uses the
value specified in the device's config data, but drivers can
override it if needed.
- Change if_aue to use USBD_FORCE_SHORT_XFER for packet transmissions.
- Change if_aue, if_kue and if_cue to use USBD_NO_TSLEEP for all
control transfers. We no longer force the non-tsleep hack for
bulk transfers since these are done asynchronously anyway.
- Removed quirk entry fiddling from if_aue and if_kue since we don't
need it anymore now that we have the USBD_NO_TSLEEP flag.
- Tweak ulpt, uhid, ums and ukbd drivers to use the new arg to
usbd_open_pipe_intr().
- Add a flag to the softc struct in the ethernet drivers to indicate
when a device has been detached, and use this flag to perform
tests to prevent the drivers from trying to do control transfers
if this is the case. This is necessary because calling if_detach()
with INET6 enabled will eventually result in a call to the driver's
ioctl() routine to delete the multicast groups on the interface,
which will result in attempts to perform control transfers. (It's
possible this also happens even without INET6 support enabled.) This
is pointless since we know that if the detach method has been called,
the hardware has been unplugged.
- Changed watchdog timeout routines to just call the driver init routines
to initialize the device states without trying to close and re-open the
pipes. This is partly because we don't want to frob things at interrupt
context, but also because this doesn't seem to work right and I don't
want to panic the system just because a USB device may have stopped
responding.
- Fix aue_rxeof() to be a little smarter about detecting when a double
transfer is needed. Unfortunately, the design of the chip makes it hard
to get this exactly right. Hopefully, this will go away once either
Nick or Lennart finds the bug in the uhci driver that makes this ugly
hack necessary.
- Also sync usbdevs with NetBSD.
2000-01-20 07:38:33 +00:00
|
|
|
return (NULL);
|
1999-11-17 22:33:51 +00:00
|
|
|
xfer->device = dev;
|
Huge merge from NetBSD:
usbdi.c (1.61):
===================================================================
revision 1.61
date: 2000/01/31 20:13:07; author: augustss; lines: +20 -4
Change the way the HC done method is invoked a little.
===================================================================
usbdi.c (1.65):
===================================================================
revision 1.65
date: 2000/03/08 15:34:10; author: augustss; lines: +4 -2
Get the status right when a polled transfer times out.
===================================================================
ohci.c (1.79), uhci.c (1.89), uhcivar.h (1.24), usb_port.h (1.22),
usbdivar.h (1.48):
===================================================================
date: 2000/03/23 07:01:46; author: thorpej;
New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.
The old timeout()/untimeout() API has been removed from the kernel.
===================================================================
uhci.c (1.80), usbdi.c (1.66):
===================================================================
date: 2000/03/23 18:59:10; author: thorpej;
Shake out some bugs from the callout changes.
===================================================================
ohci.c (1.80), uhci.c (1.91), uhcivar.h (1.25), usb_port.h (1.23),
usbdi.c (1.67), usbdivar.h (1.49):
===================================================================
date: 2000/03/24 22:03:30; author: augustss;
Some cleanup and renaming of the callouts used in USB drivers.
===================================================================
uhci.c (1.92), uhcivar.h (1.26):
===================================================================
date: 2000/03/24 22:57:58; author: augustss;
Two major changes:
Make each xfer have its own intr_info. This is necessary if we want
to queue multiple xfers on an endpoint. This should get rid of the
(mostly harmless) DIAGNOSTICs about intr_infos (not) being done.
Change (again!) how xfers are aborted. Aborting a TD is a nightmare
on the braindead UHCI controller. (Unless you stop the HC, thereby
losing isoc traffic.) Hopefully I got it right this time.
===================================================================
usbdivar.h (1.50):
===================================================================
revision 1.50
date: 2000/03/25 00:10:19; author: augustss; lines: +4 -2
GC an unsued field and add some DIAGNOSTIC in xfer.
===================================================================
ums.c: Use the callout functions instead of the timeout ones.
uhci.c (1.93):
===================================================================
revision 1.93
date: 2000/03/25 00:11:21; author: augustss;
lines: +26 -1
Add more DIAGNOSTIC when aborting isoc.
===================================================================
uhci.c (1.94), usbdivar.h (1.51):
===================================================================
date: 2000/03/25 07:13:05; author: augustss;
More DIAGNOSTIC.
Initialize a callout handle I forgot.
===================================================================
uhci.c (1.95):
===================================================================
revision 1.95
date: 2000/03/25 07:23:12; author: augustss;
Exp; lines: +24 -7
Improve uhci_dump_ii().
===================================================================
ohci.c (1.81), uhci.c (1.96), uhcivar.h (1.27), usb_subr.c (1.68),
usbdi.c (1.68), usbdivar.h (1.52):
===================================================================
date: 2000/03/25 18:02:33; author: augustss;
Rename and move around callout handles to make it more sane.
Add some DIAGNOSTIC.
Fix buglet in isoc abort on UHCI.
===================================================================
uhci.c (1.98):
===================================================================
revision 1.98
date: 2000/03/27 07:39:48; author: augustss; lines: +12 -4
Make it compile without DIAGNOSTIC.
===================================================================
uhci.c (1.99):
===================================================================
revision 1.99
date: 2000/03/27 08:01:09; author: augustss; lines: +1 -5
Remove some debug nonsense.
===================================================================
uhci.c (1.100):
===================================================================
revision 1.100
date: 2000/03/27 09:41:36; author: augustss; lines: +13 -3
Don't mess with QH in bulk abort for the moment.
===================================================================
uhci.c (1.102):
===================================================================
revision 1.102
date: 2000/03/27 22:42:57; author: augustss; lines: +66 -26
Be a little more careful when aborting.
Preallocate some TDs for large buffers.
===================================================================
uhci.c (1.103):
===================================================================
date: 2000/03/28 09:47:10; author: augustss; lines: +11 -1
Another patch for xfer abort...
XXX The current xfer queueing and aborting semantics should really
XXX be changed. It cannot be implemented in a sane way on UHCI.
XXX One day when I have lots of time I'll redesign it...
===================================================================
uhci.c (1.104): Correct a debug message.
uhci.c (1.105): Be more defensive in a DIAGNOSTIC test.
uhci.c (1.106):
===================================================================
revision 1.106
date: 2000/03/29 01:49:13; author: augustss; lines: +14 -309
*SIGH* Revert back to the old method of aborting xfers.
I had tested the new stuff for two months now, but as soon as I commited
it the problems started to appear. Murphy, no doubt...
===================================================================
usb_subr.c (1.70), usbdi.c (1.71), usbdivar.h (1.53):
===================================================================
revision 1.70
date: 2000/03/29 01:45:20; author: augustss; lines: +2 -1
Do not accept new xfers for queuing while a pipe is aborting.
===================================================================
2002-03-16 12:06:01 +00:00
|
|
|
usb_callout_init(xfer->timeout_handle);
|
1999-11-28 21:01:06 +00:00
|
|
|
DPRINTFN(5,("usbd_alloc_xfer() = %p\n", xfer));
|
1999-11-17 22:33:51 +00:00
|
|
|
return (xfer);
|
1998-11-26 23:13:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
usbd_status
|
2002-04-01 17:24:49 +00:00
|
|
|
usbd_free_xfer(usbd_xfer_handle xfer)
|
1998-11-26 23:13:13 +00:00
|
|
|
{
|
1999-11-28 21:01:06 +00:00
|
|
|
DPRINTFN(5,("usbd_free_xfer: %p\n", xfer));
|
1999-11-17 22:33:51 +00:00
|
|
|
if (xfer->rqflags & (URQ_DEV_DMABUF | URQ_AUTO_DMABUF))
|
|
|
|
usbd_free_buffer(xfer);
|
Huge merge from NetBSD:
usbdi.c (1.61):
===================================================================
revision 1.61
date: 2000/01/31 20:13:07; author: augustss; lines: +20 -4
Change the way the HC done method is invoked a little.
===================================================================
usbdi.c (1.65):
===================================================================
revision 1.65
date: 2000/03/08 15:34:10; author: augustss; lines: +4 -2
Get the status right when a polled transfer times out.
===================================================================
ohci.c (1.79), uhci.c (1.89), uhcivar.h (1.24), usb_port.h (1.22),
usbdivar.h (1.48):
===================================================================
date: 2000/03/23 07:01:46; author: thorpej;
New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.
The old timeout()/untimeout() API has been removed from the kernel.
===================================================================
uhci.c (1.80), usbdi.c (1.66):
===================================================================
date: 2000/03/23 18:59:10; author: thorpej;
Shake out some bugs from the callout changes.
===================================================================
ohci.c (1.80), uhci.c (1.91), uhcivar.h (1.25), usb_port.h (1.23),
usbdi.c (1.67), usbdivar.h (1.49):
===================================================================
date: 2000/03/24 22:03:30; author: augustss;
Some cleanup and renaming of the callouts used in USB drivers.
===================================================================
uhci.c (1.92), uhcivar.h (1.26):
===================================================================
date: 2000/03/24 22:57:58; author: augustss;
Two major changes:
Make each xfer have its own intr_info. This is necessary if we want
to queue multiple xfers on an endpoint. This should get rid of the
(mostly harmless) DIAGNOSTICs about intr_infos (not) being done.
Change (again!) how xfers are aborted. Aborting a TD is a nightmare
on the braindead UHCI controller. (Unless you stop the HC, thereby
losing isoc traffic.) Hopefully I got it right this time.
===================================================================
usbdivar.h (1.50):
===================================================================
revision 1.50
date: 2000/03/25 00:10:19; author: augustss; lines: +4 -2
GC an unsued field and add some DIAGNOSTIC in xfer.
===================================================================
ums.c: Use the callout functions instead of the timeout ones.
uhci.c (1.93):
===================================================================
revision 1.93
date: 2000/03/25 00:11:21; author: augustss;
lines: +26 -1
Add more DIAGNOSTIC when aborting isoc.
===================================================================
uhci.c (1.94), usbdivar.h (1.51):
===================================================================
date: 2000/03/25 07:13:05; author: augustss;
More DIAGNOSTIC.
Initialize a callout handle I forgot.
===================================================================
uhci.c (1.95):
===================================================================
revision 1.95
date: 2000/03/25 07:23:12; author: augustss;
Exp; lines: +24 -7
Improve uhci_dump_ii().
===================================================================
ohci.c (1.81), uhci.c (1.96), uhcivar.h (1.27), usb_subr.c (1.68),
usbdi.c (1.68), usbdivar.h (1.52):
===================================================================
date: 2000/03/25 18:02:33; author: augustss;
Rename and move around callout handles to make it more sane.
Add some DIAGNOSTIC.
Fix buglet in isoc abort on UHCI.
===================================================================
uhci.c (1.98):
===================================================================
revision 1.98
date: 2000/03/27 07:39:48; author: augustss; lines: +12 -4
Make it compile without DIAGNOSTIC.
===================================================================
uhci.c (1.99):
===================================================================
revision 1.99
date: 2000/03/27 08:01:09; author: augustss; lines: +1 -5
Remove some debug nonsense.
===================================================================
uhci.c (1.100):
===================================================================
revision 1.100
date: 2000/03/27 09:41:36; author: augustss; lines: +13 -3
Don't mess with QH in bulk abort for the moment.
===================================================================
uhci.c (1.102):
===================================================================
revision 1.102
date: 2000/03/27 22:42:57; author: augustss; lines: +66 -26
Be a little more careful when aborting.
Preallocate some TDs for large buffers.
===================================================================
uhci.c (1.103):
===================================================================
date: 2000/03/28 09:47:10; author: augustss; lines: +11 -1
Another patch for xfer abort...
XXX The current xfer queueing and aborting semantics should really
XXX be changed. It cannot be implemented in a sane way on UHCI.
XXX One day when I have lots of time I'll redesign it...
===================================================================
uhci.c (1.104): Correct a debug message.
uhci.c (1.105): Be more defensive in a DIAGNOSTIC test.
uhci.c (1.106):
===================================================================
revision 1.106
date: 2000/03/29 01:49:13; author: augustss; lines: +14 -309
*SIGH* Revert back to the old method of aborting xfers.
I had tested the new stuff for two months now, but as soon as I commited
it the problems started to appear. Murphy, no doubt...
===================================================================
usb_subr.c (1.70), usbdi.c (1.71), usbdivar.h (1.53):
===================================================================
revision 1.70
date: 2000/03/29 01:45:20; author: augustss; lines: +2 -1
Do not accept new xfers for queuing while a pipe is aborting.
===================================================================
2002-03-16 12:06:01 +00:00
|
|
|
#if defined(__NetBSD__) && defined(DIAGNOSTIC)
|
|
|
|
if (callout_pending(&xfer->timeout_handle)) {
|
|
|
|
callout_stop(&xfer->timeout_handle);
|
|
|
|
printf("usbd_free_xfer: timout_handle pending");
|
|
|
|
}
|
|
|
|
#endif
|
More USB ethernet tweaks:
- Sync ohci, uhci and usbdi modules with NetBSD in order to obtain the
following improvements:
o New USBD_NO_TSLEEP flag can be used in place of UQ_NO_TSLEEP
quirk. This allows drivers to specify busy waiting only for
certain transfers (namely control transfers for reading/writing
registers and stuff).
o New USBD_FORCE_SHORT_XFER flag can be used to deal with
devices like the ADMtek Pegasus that sense the end of bulk OUT
transfers in a special way (if a transfer is exactly a multiple
of 64 bytes in size, you need to send an extra empty packet
to terminate the transfer).
o usbd_open_pipe_intr() now accepts an interval argument which
can be used to change the rate at which the interrupt callback
routine is invoked. Specifying USBD_DEFAULT_INTERVAL uses the
value specified in the device's config data, but drivers can
override it if needed.
- Change if_aue to use USBD_FORCE_SHORT_XFER for packet transmissions.
- Change if_aue, if_kue and if_cue to use USBD_NO_TSLEEP for all
control transfers. We no longer force the non-tsleep hack for
bulk transfers since these are done asynchronously anyway.
- Removed quirk entry fiddling from if_aue and if_kue since we don't
need it anymore now that we have the USBD_NO_TSLEEP flag.
- Tweak ulpt, uhid, ums and ukbd drivers to use the new arg to
usbd_open_pipe_intr().
- Add a flag to the softc struct in the ethernet drivers to indicate
when a device has been detached, and use this flag to perform
tests to prevent the drivers from trying to do control transfers
if this is the case. This is necessary because calling if_detach()
with INET6 enabled will eventually result in a call to the driver's
ioctl() routine to delete the multicast groups on the interface,
which will result in attempts to perform control transfers. (It's
possible this also happens even without INET6 support enabled.) This
is pointless since we know that if the detach method has been called,
the hardware has been unplugged.
- Changed watchdog timeout routines to just call the driver init routines
to initialize the device states without trying to close and re-open the
pipes. This is partly because we don't want to frob things at interrupt
context, but also because this doesn't seem to work right and I don't
want to panic the system just because a USB device may have stopped
responding.
- Fix aue_rxeof() to be a little smarter about detecting when a double
transfer is needed. Unfortunately, the design of the chip makes it hard
to get this exactly right. Hopefully, this will go away once either
Nick or Lennart finds the bug in the uhci driver that makes this ugly
hack necessary.
- Also sync usbdevs with NetBSD.
2000-01-20 07:38:33 +00:00
|
|
|
xfer->device->bus->methods->freex(xfer->device->bus, xfer);
|
1998-11-26 23:13:13 +00:00
|
|
|
return (USBD_NORMAL_COMPLETION);
|
|
|
|
}
|
|
|
|
|
1999-10-07 19:26:38 +00:00
|
|
|
void
|
2002-04-01 17:24:49 +00:00
|
|
|
usbd_setup_xfer(usbd_xfer_handle xfer, usbd_pipe_handle pipe,
|
|
|
|
usbd_private_handle priv, void *buffer, u_int32_t length,
|
|
|
|
u_int16_t flags, u_int32_t timeout,
|
|
|
|
usbd_callback callback)
|
1998-11-26 23:13:13 +00:00
|
|
|
{
|
1999-11-17 22:33:51 +00:00
|
|
|
xfer->pipe = pipe;
|
|
|
|
xfer->priv = priv;
|
|
|
|
xfer->buffer = buffer;
|
|
|
|
xfer->length = length;
|
|
|
|
xfer->actlen = 0;
|
|
|
|
xfer->flags = flags;
|
|
|
|
xfer->timeout = timeout;
|
|
|
|
xfer->status = USBD_NOT_STARTED;
|
|
|
|
xfer->callback = callback;
|
|
|
|
xfer->rqflags &= ~URQ_REQUEST;
|
|
|
|
xfer->nframes = 0;
|
1998-11-26 23:13:13 +00:00
|
|
|
}
|
|
|
|
|
1999-10-07 19:26:38 +00:00
|
|
|
void
|
2002-04-01 17:24:49 +00:00
|
|
|
usbd_setup_default_xfer(usbd_xfer_handle xfer, usbd_device_handle dev,
|
|
|
|
usbd_private_handle priv, u_int32_t timeout,
|
|
|
|
usb_device_request_t *req, void *buffer,
|
|
|
|
u_int32_t length, u_int16_t flags,
|
|
|
|
usbd_callback callback)
|
1998-11-26 23:13:13 +00:00
|
|
|
{
|
1999-11-17 22:33:51 +00:00
|
|
|
xfer->pipe = dev->default_pipe;
|
|
|
|
xfer->priv = priv;
|
|
|
|
xfer->buffer = buffer;
|
|
|
|
xfer->length = length;
|
|
|
|
xfer->actlen = 0;
|
|
|
|
xfer->flags = flags;
|
|
|
|
xfer->timeout = timeout;
|
|
|
|
xfer->status = USBD_NOT_STARTED;
|
|
|
|
xfer->callback = callback;
|
|
|
|
xfer->request = *req;
|
|
|
|
xfer->rqflags |= URQ_REQUEST;
|
|
|
|
xfer->nframes = 0;
|
1998-11-26 23:13:13 +00:00
|
|
|
}
|
|
|
|
|
1999-10-07 19:26:38 +00:00
|
|
|
void
|
2002-04-01 17:24:49 +00:00
|
|
|
usbd_setup_isoc_xfer(usbd_xfer_handle xfer, usbd_pipe_handle pipe,
|
|
|
|
usbd_private_handle priv, u_int16_t *frlengths,
|
|
|
|
u_int32_t nframes, u_int16_t flags, usbd_callback callback)
|
1998-11-26 23:13:13 +00:00
|
|
|
{
|
1999-11-17 22:33:51 +00:00
|
|
|
xfer->pipe = pipe;
|
|
|
|
xfer->priv = priv;
|
|
|
|
xfer->buffer = 0;
|
|
|
|
xfer->length = 0;
|
|
|
|
xfer->actlen = 0;
|
|
|
|
xfer->flags = flags;
|
|
|
|
xfer->timeout = USBD_NO_TIMEOUT;
|
|
|
|
xfer->status = USBD_NOT_STARTED;
|
|
|
|
xfer->callback = callback;
|
|
|
|
xfer->rqflags &= ~URQ_REQUEST;
|
|
|
|
xfer->frlengths = frlengths;
|
|
|
|
xfer->nframes = nframes;
|
1998-11-26 23:13:13 +00:00
|
|
|
}
|
|
|
|
|
1999-10-07 19:26:38 +00:00
|
|
|
void
|
2002-04-01 17:24:49 +00:00
|
|
|
usbd_get_xfer_status(usbd_xfer_handle xfer, usbd_private_handle *priv,
|
|
|
|
void **buffer, u_int32_t *count, usbd_status *status)
|
1998-11-26 23:13:13 +00:00
|
|
|
{
|
1999-11-17 22:33:51 +00:00
|
|
|
if (priv != NULL)
|
|
|
|
*priv = xfer->priv;
|
|
|
|
if (buffer != NULL)
|
|
|
|
*buffer = xfer->buffer;
|
|
|
|
if (count != NULL)
|
|
|
|
*count = xfer->actlen;
|
|
|
|
if (status != NULL)
|
|
|
|
*status = xfer->status;
|
1998-11-26 23:13:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
usb_config_descriptor_t *
|
2002-04-01 17:24:49 +00:00
|
|
|
usbd_get_config_descriptor(usbd_device_handle dev)
|
1998-11-26 23:13:13 +00:00
|
|
|
{
|
More USB ethernet tweaks:
- Sync ohci, uhci and usbdi modules with NetBSD in order to obtain the
following improvements:
o New USBD_NO_TSLEEP flag can be used in place of UQ_NO_TSLEEP
quirk. This allows drivers to specify busy waiting only for
certain transfers (namely control transfers for reading/writing
registers and stuff).
o New USBD_FORCE_SHORT_XFER flag can be used to deal with
devices like the ADMtek Pegasus that sense the end of bulk OUT
transfers in a special way (if a transfer is exactly a multiple
of 64 bytes in size, you need to send an extra empty packet
to terminate the transfer).
o usbd_open_pipe_intr() now accepts an interval argument which
can be used to change the rate at which the interrupt callback
routine is invoked. Specifying USBD_DEFAULT_INTERVAL uses the
value specified in the device's config data, but drivers can
override it if needed.
- Change if_aue to use USBD_FORCE_SHORT_XFER for packet transmissions.
- Change if_aue, if_kue and if_cue to use USBD_NO_TSLEEP for all
control transfers. We no longer force the non-tsleep hack for
bulk transfers since these are done asynchronously anyway.
- Removed quirk entry fiddling from if_aue and if_kue since we don't
need it anymore now that we have the USBD_NO_TSLEEP flag.
- Tweak ulpt, uhid, ums and ukbd drivers to use the new arg to
usbd_open_pipe_intr().
- Add a flag to the softc struct in the ethernet drivers to indicate
when a device has been detached, and use this flag to perform
tests to prevent the drivers from trying to do control transfers
if this is the case. This is necessary because calling if_detach()
with INET6 enabled will eventually result in a call to the driver's
ioctl() routine to delete the multicast groups on the interface,
which will result in attempts to perform control transfers. (It's
possible this also happens even without INET6 support enabled.) This
is pointless since we know that if the detach method has been called,
the hardware has been unplugged.
- Changed watchdog timeout routines to just call the driver init routines
to initialize the device states without trying to close and re-open the
pipes. This is partly because we don't want to frob things at interrupt
context, but also because this doesn't seem to work right and I don't
want to panic the system just because a USB device may have stopped
responding.
- Fix aue_rxeof() to be a little smarter about detecting when a double
transfer is needed. Unfortunately, the design of the chip makes it hard
to get this exactly right. Hopefully, this will go away once either
Nick or Lennart finds the bug in the uhci driver that makes this ugly
hack necessary.
- Also sync usbdevs with NetBSD.
2000-01-20 07:38:33 +00:00
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
if (dev == NULL) {
|
|
|
|
printf("usbd_get_config_descriptor: dev == NULL\n");
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
#endif
|
1998-11-26 23:13:13 +00:00
|
|
|
return (dev->cdesc);
|
|
|
|
}
|
|
|
|
|
|
|
|
usb_interface_descriptor_t *
|
2002-04-01 17:24:49 +00:00
|
|
|
usbd_get_interface_descriptor(usbd_interface_handle iface)
|
1998-11-26 23:13:13 +00:00
|
|
|
{
|
More USB ethernet tweaks:
- Sync ohci, uhci and usbdi modules with NetBSD in order to obtain the
following improvements:
o New USBD_NO_TSLEEP flag can be used in place of UQ_NO_TSLEEP
quirk. This allows drivers to specify busy waiting only for
certain transfers (namely control transfers for reading/writing
registers and stuff).
o New USBD_FORCE_SHORT_XFER flag can be used to deal with
devices like the ADMtek Pegasus that sense the end of bulk OUT
transfers in a special way (if a transfer is exactly a multiple
of 64 bytes in size, you need to send an extra empty packet
to terminate the transfer).
o usbd_open_pipe_intr() now accepts an interval argument which
can be used to change the rate at which the interrupt callback
routine is invoked. Specifying USBD_DEFAULT_INTERVAL uses the
value specified in the device's config data, but drivers can
override it if needed.
- Change if_aue to use USBD_FORCE_SHORT_XFER for packet transmissions.
- Change if_aue, if_kue and if_cue to use USBD_NO_TSLEEP for all
control transfers. We no longer force the non-tsleep hack for
bulk transfers since these are done asynchronously anyway.
- Removed quirk entry fiddling from if_aue and if_kue since we don't
need it anymore now that we have the USBD_NO_TSLEEP flag.
- Tweak ulpt, uhid, ums and ukbd drivers to use the new arg to
usbd_open_pipe_intr().
- Add a flag to the softc struct in the ethernet drivers to indicate
when a device has been detached, and use this flag to perform
tests to prevent the drivers from trying to do control transfers
if this is the case. This is necessary because calling if_detach()
with INET6 enabled will eventually result in a call to the driver's
ioctl() routine to delete the multicast groups on the interface,
which will result in attempts to perform control transfers. (It's
possible this also happens even without INET6 support enabled.) This
is pointless since we know that if the detach method has been called,
the hardware has been unplugged.
- Changed watchdog timeout routines to just call the driver init routines
to initialize the device states without trying to close and re-open the
pipes. This is partly because we don't want to frob things at interrupt
context, but also because this doesn't seem to work right and I don't
want to panic the system just because a USB device may have stopped
responding.
- Fix aue_rxeof() to be a little smarter about detecting when a double
transfer is needed. Unfortunately, the design of the chip makes it hard
to get this exactly right. Hopefully, this will go away once either
Nick or Lennart finds the bug in the uhci driver that makes this ugly
hack necessary.
- Also sync usbdevs with NetBSD.
2000-01-20 07:38:33 +00:00
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
if (iface == NULL) {
|
|
|
|
printf("usbd_get_interface_descriptor: dev == NULL\n");
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
#endif
|
1998-11-26 23:13:13 +00:00
|
|
|
return (iface->idesc);
|
|
|
|
}
|
|
|
|
|
|
|
|
usb_device_descriptor_t *
|
2002-04-01 17:24:49 +00:00
|
|
|
usbd_get_device_descriptor(usbd_device_handle dev)
|
1998-11-26 23:13:13 +00:00
|
|
|
{
|
|
|
|
return (&dev->ddesc);
|
|
|
|
}
|
|
|
|
|
|
|
|
usb_endpoint_descriptor_t *
|
2002-04-01 17:24:49 +00:00
|
|
|
usbd_interface2endpoint_descriptor(usbd_interface_handle iface, u_int8_t index)
|
1998-11-26 23:13:13 +00:00
|
|
|
{
|
|
|
|
if (index >= iface->idesc->bNumEndpoints)
|
1999-01-07 23:07:57 +00:00
|
|
|
return (0);
|
1998-11-26 23:13:13 +00:00
|
|
|
return (iface->endpoints[index].edesc);
|
|
|
|
}
|
|
|
|
|
|
|
|
usbd_status
|
2002-04-01 17:24:49 +00:00
|
|
|
usbd_abort_pipe(usbd_pipe_handle pipe)
|
1998-11-26 23:13:13 +00:00
|
|
|
{
|
1999-11-17 22:33:51 +00:00
|
|
|
usbd_status err;
|
1998-11-26 23:13:13 +00:00
|
|
|
int s;
|
|
|
|
|
1999-10-07 19:26:38 +00:00
|
|
|
#ifdef DIAGNOSTIC
|
1999-11-17 22:33:51 +00:00
|
|
|
if (pipe == NULL) {
|
1999-10-07 19:26:38 +00:00
|
|
|
printf("usbd_close_pipe: pipe==NULL\n");
|
|
|
|
return (USBD_NORMAL_COMPLETION);
|
|
|
|
}
|
|
|
|
#endif
|
1998-11-26 23:13:13 +00:00
|
|
|
s = splusb();
|
1999-11-17 22:33:51 +00:00
|
|
|
err = usbd_ar_pipe(pipe);
|
1998-11-26 23:13:13 +00:00
|
|
|
splx(s);
|
1999-11-17 22:33:51 +00:00
|
|
|
return (err);
|
1998-11-26 23:13:13 +00:00
|
|
|
}
|
1999-10-07 19:26:38 +00:00
|
|
|
|
1998-11-26 23:13:13 +00:00
|
|
|
usbd_status
|
2002-04-01 17:24:49 +00:00
|
|
|
usbd_clear_endpoint_stall(usbd_pipe_handle pipe)
|
1998-11-26 23:13:13 +00:00
|
|
|
{
|
|
|
|
usbd_device_handle dev = pipe->device;
|
|
|
|
usb_device_request_t req;
|
1999-11-17 22:33:51 +00:00
|
|
|
usbd_status err;
|
1998-11-26 23:13:13 +00:00
|
|
|
|
1999-10-07 19:26:38 +00:00
|
|
|
DPRINTFN(8, ("usbd_clear_endpoint_stall\n"));
|
|
|
|
|
|
|
|
/*
|
2002-04-07 12:24:55 +00:00
|
|
|
* Clearing en endpoint stall resets the endpoint toggle, so
|
1999-10-07 19:26:38 +00:00
|
|
|
* do the same to the HC toggle.
|
|
|
|
*/
|
|
|
|
pipe->methods->cleartoggle(pipe);
|
|
|
|
|
1998-11-26 23:13:13 +00:00
|
|
|
req.bmRequestType = UT_WRITE_ENDPOINT;
|
|
|
|
req.bRequest = UR_CLEAR_FEATURE;
|
1999-01-07 23:07:57 +00:00
|
|
|
USETW(req.wValue, UF_ENDPOINT_HALT);
|
1998-11-26 23:13:13 +00:00
|
|
|
USETW(req.wIndex, pipe->endpoint->edesc->bEndpointAddress);
|
|
|
|
USETW(req.wLength, 0);
|
1999-11-17 22:33:51 +00:00
|
|
|
err = usbd_do_request(dev, &req, 0);
|
1998-11-26 23:13:13 +00:00
|
|
|
#if 0
|
|
|
|
XXX should we do this?
|
1999-11-17 22:33:51 +00:00
|
|
|
if (!err) {
|
1998-11-26 23:13:13 +00:00
|
|
|
pipe->state = USBD_PIPE_ACTIVE;
|
|
|
|
/* XXX activate pipe */
|
|
|
|
}
|
|
|
|
#endif
|
1999-11-17 22:33:51 +00:00
|
|
|
return (err);
|
1998-11-26 23:13:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
usbd_status
|
2002-04-01 17:24:49 +00:00
|
|
|
usbd_clear_endpoint_stall_async(usbd_pipe_handle pipe)
|
1998-11-26 23:13:13 +00:00
|
|
|
{
|
|
|
|
usbd_device_handle dev = pipe->device;
|
|
|
|
usb_device_request_t req;
|
1999-11-17 22:33:51 +00:00
|
|
|
usbd_status err;
|
1998-11-26 23:13:13 +00:00
|
|
|
|
1999-10-07 19:26:38 +00:00
|
|
|
pipe->methods->cleartoggle(pipe);
|
|
|
|
|
1998-11-26 23:13:13 +00:00
|
|
|
req.bmRequestType = UT_WRITE_ENDPOINT;
|
|
|
|
req.bRequest = UR_CLEAR_FEATURE;
|
1999-01-07 23:07:57 +00:00
|
|
|
USETW(req.wValue, UF_ENDPOINT_HALT);
|
1998-11-26 23:13:13 +00:00
|
|
|
USETW(req.wIndex, pipe->endpoint->edesc->bEndpointAddress);
|
|
|
|
USETW(req.wLength, 0);
|
1999-11-17 22:33:51 +00:00
|
|
|
err = usbd_do_request_async(dev, &req, 0);
|
|
|
|
return (err);
|
1998-11-26 23:13:13 +00:00
|
|
|
}
|
|
|
|
|
2000-01-25 18:40:39 +00:00
|
|
|
void
|
Huge merge from NetBSD:
usbdi.c (1.61):
===================================================================
revision 1.61
date: 2000/01/31 20:13:07; author: augustss; lines: +20 -4
Change the way the HC done method is invoked a little.
===================================================================
usbdi.c (1.65):
===================================================================
revision 1.65
date: 2000/03/08 15:34:10; author: augustss; lines: +4 -2
Get the status right when a polled transfer times out.
===================================================================
ohci.c (1.79), uhci.c (1.89), uhcivar.h (1.24), usb_port.h (1.22),
usbdivar.h (1.48):
===================================================================
date: 2000/03/23 07:01:46; author: thorpej;
New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.
The old timeout()/untimeout() API has been removed from the kernel.
===================================================================
uhci.c (1.80), usbdi.c (1.66):
===================================================================
date: 2000/03/23 18:59:10; author: thorpej;
Shake out some bugs from the callout changes.
===================================================================
ohci.c (1.80), uhci.c (1.91), uhcivar.h (1.25), usb_port.h (1.23),
usbdi.c (1.67), usbdivar.h (1.49):
===================================================================
date: 2000/03/24 22:03:30; author: augustss;
Some cleanup and renaming of the callouts used in USB drivers.
===================================================================
uhci.c (1.92), uhcivar.h (1.26):
===================================================================
date: 2000/03/24 22:57:58; author: augustss;
Two major changes:
Make each xfer have its own intr_info. This is necessary if we want
to queue multiple xfers on an endpoint. This should get rid of the
(mostly harmless) DIAGNOSTICs about intr_infos (not) being done.
Change (again!) how xfers are aborted. Aborting a TD is a nightmare
on the braindead UHCI controller. (Unless you stop the HC, thereby
losing isoc traffic.) Hopefully I got it right this time.
===================================================================
usbdivar.h (1.50):
===================================================================
revision 1.50
date: 2000/03/25 00:10:19; author: augustss; lines: +4 -2
GC an unsued field and add some DIAGNOSTIC in xfer.
===================================================================
ums.c: Use the callout functions instead of the timeout ones.
uhci.c (1.93):
===================================================================
revision 1.93
date: 2000/03/25 00:11:21; author: augustss;
lines: +26 -1
Add more DIAGNOSTIC when aborting isoc.
===================================================================
uhci.c (1.94), usbdivar.h (1.51):
===================================================================
date: 2000/03/25 07:13:05; author: augustss;
More DIAGNOSTIC.
Initialize a callout handle I forgot.
===================================================================
uhci.c (1.95):
===================================================================
revision 1.95
date: 2000/03/25 07:23:12; author: augustss;
Exp; lines: +24 -7
Improve uhci_dump_ii().
===================================================================
ohci.c (1.81), uhci.c (1.96), uhcivar.h (1.27), usb_subr.c (1.68),
usbdi.c (1.68), usbdivar.h (1.52):
===================================================================
date: 2000/03/25 18:02:33; author: augustss;
Rename and move around callout handles to make it more sane.
Add some DIAGNOSTIC.
Fix buglet in isoc abort on UHCI.
===================================================================
uhci.c (1.98):
===================================================================
revision 1.98
date: 2000/03/27 07:39:48; author: augustss; lines: +12 -4
Make it compile without DIAGNOSTIC.
===================================================================
uhci.c (1.99):
===================================================================
revision 1.99
date: 2000/03/27 08:01:09; author: augustss; lines: +1 -5
Remove some debug nonsense.
===================================================================
uhci.c (1.100):
===================================================================
revision 1.100
date: 2000/03/27 09:41:36; author: augustss; lines: +13 -3
Don't mess with QH in bulk abort for the moment.
===================================================================
uhci.c (1.102):
===================================================================
revision 1.102
date: 2000/03/27 22:42:57; author: augustss; lines: +66 -26
Be a little more careful when aborting.
Preallocate some TDs for large buffers.
===================================================================
uhci.c (1.103):
===================================================================
date: 2000/03/28 09:47:10; author: augustss; lines: +11 -1
Another patch for xfer abort...
XXX The current xfer queueing and aborting semantics should really
XXX be changed. It cannot be implemented in a sane way on UHCI.
XXX One day when I have lots of time I'll redesign it...
===================================================================
uhci.c (1.104): Correct a debug message.
uhci.c (1.105): Be more defensive in a DIAGNOSTIC test.
uhci.c (1.106):
===================================================================
revision 1.106
date: 2000/03/29 01:49:13; author: augustss; lines: +14 -309
*SIGH* Revert back to the old method of aborting xfers.
I had tested the new stuff for two months now, but as soon as I commited
it the problems started to appear. Murphy, no doubt...
===================================================================
usb_subr.c (1.70), usbdi.c (1.71), usbdivar.h (1.53):
===================================================================
revision 1.70
date: 2000/03/29 01:45:20; author: augustss; lines: +2 -1
Do not accept new xfers for queuing while a pipe is aborting.
===================================================================
2002-03-16 12:06:01 +00:00
|
|
|
usbd_clear_endpoint_toggle(usbd_pipe_handle pipe)
|
2000-01-25 18:40:39 +00:00
|
|
|
{
|
|
|
|
pipe->methods->cleartoggle(pipe);
|
|
|
|
}
|
|
|
|
|
1998-11-26 23:13:13 +00:00
|
|
|
usbd_status
|
2002-04-01 17:24:49 +00:00
|
|
|
usbd_endpoint_count(usbd_interface_handle iface, u_int8_t *count)
|
1998-11-26 23:13:13 +00:00
|
|
|
{
|
2002-04-01 13:43:02 +00:00
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
if (iface == NULL || iface->idesc == NULL) {
|
|
|
|
printf("usbd_endpoint_count: NULL pointer\n");
|
|
|
|
return (USBD_INVAL);
|
|
|
|
}
|
|
|
|
#endif
|
1998-11-26 23:13:13 +00:00
|
|
|
*count = iface->idesc->bNumEndpoints;
|
|
|
|
return (USBD_NORMAL_COMPLETION);
|
|
|
|
}
|
|
|
|
|
|
|
|
usbd_status
|
2002-04-01 17:24:49 +00:00
|
|
|
usbd_interface_count(usbd_device_handle dev, u_int8_t *count)
|
1998-11-26 23:13:13 +00:00
|
|
|
{
|
1999-11-17 22:33:51 +00:00
|
|
|
if (dev->cdesc == NULL)
|
1998-11-26 23:13:13 +00:00
|
|
|
return (USBD_NOT_CONFIGURED);
|
|
|
|
*count = dev->cdesc->bNumInterface;
|
|
|
|
return (USBD_NORMAL_COMPLETION);
|
|
|
|
}
|
|
|
|
|
2002-04-07 10:50:41 +00:00
|
|
|
void
|
2002-04-01 17:24:49 +00:00
|
|
|
usbd_interface2device_handle(usbd_interface_handle iface,
|
|
|
|
usbd_device_handle *dev)
|
1998-11-26 23:13:13 +00:00
|
|
|
{
|
|
|
|
*dev = iface->device;
|
|
|
|
}
|
|
|
|
|
|
|
|
usbd_status
|
2002-04-01 17:24:49 +00:00
|
|
|
usbd_device2interface_handle(usbd_device_handle dev,
|
|
|
|
u_int8_t ifaceno, usbd_interface_handle *iface)
|
1998-11-26 23:13:13 +00:00
|
|
|
{
|
1999-11-17 22:33:51 +00:00
|
|
|
if (dev->cdesc == NULL)
|
1998-11-26 23:13:13 +00:00
|
|
|
return (USBD_NOT_CONFIGURED);
|
|
|
|
if (ifaceno >= dev->cdesc->bNumInterface)
|
|
|
|
return (USBD_INVAL);
|
|
|
|
*iface = &dev->ifaces[ifaceno];
|
|
|
|
return (USBD_NORMAL_COMPLETION);
|
|
|
|
}
|
|
|
|
|
1999-10-07 19:26:38 +00:00
|
|
|
usbd_device_handle
|
2002-04-01 17:24:49 +00:00
|
|
|
usbd_pipe2device_handle(usbd_pipe_handle pipe)
|
1998-11-26 23:13:13 +00:00
|
|
|
{
|
1999-10-07 19:26:38 +00:00
|
|
|
return (pipe->device);
|
1998-11-26 23:13:13 +00:00
|
|
|
}
|
|
|
|
|
1999-01-07 23:07:57 +00:00
|
|
|
/* XXXX use altno */
|
1998-11-26 23:13:13 +00:00
|
|
|
usbd_status
|
2002-04-01 17:24:49 +00:00
|
|
|
usbd_set_interface(usbd_interface_handle iface, int altidx)
|
1998-11-26 23:13:13 +00:00
|
|
|
{
|
|
|
|
usb_device_request_t req;
|
1999-11-17 22:33:51 +00:00
|
|
|
usbd_status err;
|
2002-04-01 13:43:02 +00:00
|
|
|
void *endpoints;
|
1999-01-07 23:07:57 +00:00
|
|
|
|
|
|
|
if (LIST_FIRST(&iface->pipes) != 0)
|
|
|
|
return (USBD_IN_USE);
|
|
|
|
|
2002-04-01 13:43:02 +00:00
|
|
|
endpoints = iface->endpoints;
|
1999-11-17 22:33:51 +00:00
|
|
|
err = usbd_fill_iface_data(iface->device, iface->index, altidx);
|
|
|
|
if (err)
|
|
|
|
return (err);
|
1998-11-26 23:13:13 +00:00
|
|
|
|
2002-04-01 17:05:55 +00:00
|
|
|
/* new setting works, we can free old endpoints */
|
2002-04-01 13:43:02 +00:00
|
|
|
if (endpoints != NULL)
|
|
|
|
free(endpoints, M_USB);
|
|
|
|
|
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
if (iface->idesc == NULL) {
|
|
|
|
printf("usbd_set_interface: NULL pointer\n");
|
|
|
|
return (USBD_INVAL);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1998-11-26 23:13:13 +00:00
|
|
|
req.bmRequestType = UT_WRITE_INTERFACE;
|
|
|
|
req.bRequest = UR_SET_INTERFACE;
|
1999-01-07 23:07:57 +00:00
|
|
|
USETW(req.wValue, iface->idesc->bAlternateSetting);
|
|
|
|
USETW(req.wIndex, iface->idesc->bInterfaceNumber);
|
1998-11-26 23:13:13 +00:00
|
|
|
USETW(req.wLength, 0);
|
1999-11-17 22:33:51 +00:00
|
|
|
return (usbd_do_request(iface->device, &req, 0));
|
1998-11-26 23:13:13 +00:00
|
|
|
}
|
|
|
|
|
1999-01-07 23:07:57 +00:00
|
|
|
int
|
2002-04-01 17:24:49 +00:00
|
|
|
usbd_get_no_alts(usb_config_descriptor_t *cdesc, int ifaceno)
|
1999-01-07 23:07:57 +00:00
|
|
|
{
|
|
|
|
char *p = (char *)cdesc;
|
|
|
|
char *end = p + UGETW(cdesc->wTotalLength);
|
|
|
|
usb_interface_descriptor_t *d;
|
|
|
|
int n;
|
|
|
|
|
|
|
|
for (n = 0; p < end; p += d->bLength) {
|
|
|
|
d = (usb_interface_descriptor_t *)p;
|
|
|
|
if (p + d->bLength <= end &&
|
|
|
|
d->bDescriptorType == UDESC_INTERFACE &&
|
|
|
|
d->bInterfaceNumber == ifaceno)
|
|
|
|
n++;
|
|
|
|
}
|
|
|
|
return (n);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2002-04-01 17:24:49 +00:00
|
|
|
usbd_get_interface_altindex(usbd_interface_handle iface)
|
1999-01-07 23:07:57 +00:00
|
|
|
{
|
|
|
|
return (iface->altindex);
|
|
|
|
}
|
|
|
|
|
|
|
|
usbd_status
|
2002-04-01 17:24:49 +00:00
|
|
|
usbd_get_interface(usbd_interface_handle iface, u_int8_t *aiface)
|
1999-01-07 23:07:57 +00:00
|
|
|
{
|
|
|
|
usb_device_request_t req;
|
|
|
|
|
|
|
|
req.bmRequestType = UT_READ_INTERFACE;
|
|
|
|
req.bRequest = UR_GET_INTERFACE;
|
|
|
|
USETW(req.wValue, 0);
|
|
|
|
USETW(req.wIndex, iface->idesc->bInterfaceNumber);
|
|
|
|
USETW(req.wLength, 1);
|
1999-11-17 22:33:51 +00:00
|
|
|
return (usbd_do_request(iface->device, &req, aiface));
|
1999-01-07 23:07:57 +00:00
|
|
|
}
|
|
|
|
|
1998-11-26 23:13:13 +00:00
|
|
|
/*** Internal routines ***/
|
|
|
|
|
|
|
|
/* Dequeue all pipe operations, called at splusb(). */
|
2000-04-03 20:58:30 +00:00
|
|
|
Static usbd_status
|
2002-04-01 17:24:49 +00:00
|
|
|
usbd_ar_pipe(usbd_pipe_handle pipe)
|
1998-11-26 23:13:13 +00:00
|
|
|
{
|
1999-11-17 22:33:51 +00:00
|
|
|
usbd_xfer_handle xfer;
|
|
|
|
|
|
|
|
SPLUSBCHECK;
|
1998-11-26 23:13:13 +00:00
|
|
|
|
1999-10-07 19:26:38 +00:00
|
|
|
DPRINTFN(2,("usbd_ar_pipe: pipe=%p\n", pipe));
|
|
|
|
#ifdef USB_DEBUG
|
|
|
|
if (usbdebug > 5)
|
|
|
|
usbd_dump_queue(pipe);
|
|
|
|
#endif
|
1999-11-17 22:33:51 +00:00
|
|
|
pipe->repeat = 0;
|
Huge merge from NetBSD:
usbdi.c (1.61):
===================================================================
revision 1.61
date: 2000/01/31 20:13:07; author: augustss; lines: +20 -4
Change the way the HC done method is invoked a little.
===================================================================
usbdi.c (1.65):
===================================================================
revision 1.65
date: 2000/03/08 15:34:10; author: augustss; lines: +4 -2
Get the status right when a polled transfer times out.
===================================================================
ohci.c (1.79), uhci.c (1.89), uhcivar.h (1.24), usb_port.h (1.22),
usbdivar.h (1.48):
===================================================================
date: 2000/03/23 07:01:46; author: thorpej;
New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.
The old timeout()/untimeout() API has been removed from the kernel.
===================================================================
uhci.c (1.80), usbdi.c (1.66):
===================================================================
date: 2000/03/23 18:59:10; author: thorpej;
Shake out some bugs from the callout changes.
===================================================================
ohci.c (1.80), uhci.c (1.91), uhcivar.h (1.25), usb_port.h (1.23),
usbdi.c (1.67), usbdivar.h (1.49):
===================================================================
date: 2000/03/24 22:03:30; author: augustss;
Some cleanup and renaming of the callouts used in USB drivers.
===================================================================
uhci.c (1.92), uhcivar.h (1.26):
===================================================================
date: 2000/03/24 22:57:58; author: augustss;
Two major changes:
Make each xfer have its own intr_info. This is necessary if we want
to queue multiple xfers on an endpoint. This should get rid of the
(mostly harmless) DIAGNOSTICs about intr_infos (not) being done.
Change (again!) how xfers are aborted. Aborting a TD is a nightmare
on the braindead UHCI controller. (Unless you stop the HC, thereby
losing isoc traffic.) Hopefully I got it right this time.
===================================================================
usbdivar.h (1.50):
===================================================================
revision 1.50
date: 2000/03/25 00:10:19; author: augustss; lines: +4 -2
GC an unsued field and add some DIAGNOSTIC in xfer.
===================================================================
ums.c: Use the callout functions instead of the timeout ones.
uhci.c (1.93):
===================================================================
revision 1.93
date: 2000/03/25 00:11:21; author: augustss;
lines: +26 -1
Add more DIAGNOSTIC when aborting isoc.
===================================================================
uhci.c (1.94), usbdivar.h (1.51):
===================================================================
date: 2000/03/25 07:13:05; author: augustss;
More DIAGNOSTIC.
Initialize a callout handle I forgot.
===================================================================
uhci.c (1.95):
===================================================================
revision 1.95
date: 2000/03/25 07:23:12; author: augustss;
Exp; lines: +24 -7
Improve uhci_dump_ii().
===================================================================
ohci.c (1.81), uhci.c (1.96), uhcivar.h (1.27), usb_subr.c (1.68),
usbdi.c (1.68), usbdivar.h (1.52):
===================================================================
date: 2000/03/25 18:02:33; author: augustss;
Rename and move around callout handles to make it more sane.
Add some DIAGNOSTIC.
Fix buglet in isoc abort on UHCI.
===================================================================
uhci.c (1.98):
===================================================================
revision 1.98
date: 2000/03/27 07:39:48; author: augustss; lines: +12 -4
Make it compile without DIAGNOSTIC.
===================================================================
uhci.c (1.99):
===================================================================
revision 1.99
date: 2000/03/27 08:01:09; author: augustss; lines: +1 -5
Remove some debug nonsense.
===================================================================
uhci.c (1.100):
===================================================================
revision 1.100
date: 2000/03/27 09:41:36; author: augustss; lines: +13 -3
Don't mess with QH in bulk abort for the moment.
===================================================================
uhci.c (1.102):
===================================================================
revision 1.102
date: 2000/03/27 22:42:57; author: augustss; lines: +66 -26
Be a little more careful when aborting.
Preallocate some TDs for large buffers.
===================================================================
uhci.c (1.103):
===================================================================
date: 2000/03/28 09:47:10; author: augustss; lines: +11 -1
Another patch for xfer abort...
XXX The current xfer queueing and aborting semantics should really
XXX be changed. It cannot be implemented in a sane way on UHCI.
XXX One day when I have lots of time I'll redesign it...
===================================================================
uhci.c (1.104): Correct a debug message.
uhci.c (1.105): Be more defensive in a DIAGNOSTIC test.
uhci.c (1.106):
===================================================================
revision 1.106
date: 2000/03/29 01:49:13; author: augustss; lines: +14 -309
*SIGH* Revert back to the old method of aborting xfers.
I had tested the new stuff for two months now, but as soon as I commited
it the problems started to appear. Murphy, no doubt...
===================================================================
usb_subr.c (1.70), usbdi.c (1.71), usbdivar.h (1.53):
===================================================================
revision 1.70
date: 2000/03/29 01:45:20; author: augustss; lines: +2 -1
Do not accept new xfers for queuing while a pipe is aborting.
===================================================================
2002-03-16 12:06:01 +00:00
|
|
|
pipe->aborting = 1;
|
1999-11-17 22:33:51 +00:00
|
|
|
while ((xfer = SIMPLEQ_FIRST(&pipe->queue)) != NULL) {
|
|
|
|
DPRINTFN(2,("usbd_ar_pipe: pipe=%p xfer=%p (methods=%p)\n",
|
|
|
|
pipe, xfer, pipe->methods));
|
1999-10-07 19:26:38 +00:00
|
|
|
/* Make the HC abort it (and invoke the callback). */
|
1999-11-17 22:33:51 +00:00
|
|
|
pipe->methods->abort(xfer);
|
1999-10-07 19:26:38 +00:00
|
|
|
/* XXX only for non-0 usbd_clear_endpoint_stall(pipe); */
|
1998-11-26 23:13:13 +00:00
|
|
|
}
|
Huge merge from NetBSD:
usbdi.c (1.61):
===================================================================
revision 1.61
date: 2000/01/31 20:13:07; author: augustss; lines: +20 -4
Change the way the HC done method is invoked a little.
===================================================================
usbdi.c (1.65):
===================================================================
revision 1.65
date: 2000/03/08 15:34:10; author: augustss; lines: +4 -2
Get the status right when a polled transfer times out.
===================================================================
ohci.c (1.79), uhci.c (1.89), uhcivar.h (1.24), usb_port.h (1.22),
usbdivar.h (1.48):
===================================================================
date: 2000/03/23 07:01:46; author: thorpej;
New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.
The old timeout()/untimeout() API has been removed from the kernel.
===================================================================
uhci.c (1.80), usbdi.c (1.66):
===================================================================
date: 2000/03/23 18:59:10; author: thorpej;
Shake out some bugs from the callout changes.
===================================================================
ohci.c (1.80), uhci.c (1.91), uhcivar.h (1.25), usb_port.h (1.23),
usbdi.c (1.67), usbdivar.h (1.49):
===================================================================
date: 2000/03/24 22:03:30; author: augustss;
Some cleanup and renaming of the callouts used in USB drivers.
===================================================================
uhci.c (1.92), uhcivar.h (1.26):
===================================================================
date: 2000/03/24 22:57:58; author: augustss;
Two major changes:
Make each xfer have its own intr_info. This is necessary if we want
to queue multiple xfers on an endpoint. This should get rid of the
(mostly harmless) DIAGNOSTICs about intr_infos (not) being done.
Change (again!) how xfers are aborted. Aborting a TD is a nightmare
on the braindead UHCI controller. (Unless you stop the HC, thereby
losing isoc traffic.) Hopefully I got it right this time.
===================================================================
usbdivar.h (1.50):
===================================================================
revision 1.50
date: 2000/03/25 00:10:19; author: augustss; lines: +4 -2
GC an unsued field and add some DIAGNOSTIC in xfer.
===================================================================
ums.c: Use the callout functions instead of the timeout ones.
uhci.c (1.93):
===================================================================
revision 1.93
date: 2000/03/25 00:11:21; author: augustss;
lines: +26 -1
Add more DIAGNOSTIC when aborting isoc.
===================================================================
uhci.c (1.94), usbdivar.h (1.51):
===================================================================
date: 2000/03/25 07:13:05; author: augustss;
More DIAGNOSTIC.
Initialize a callout handle I forgot.
===================================================================
uhci.c (1.95):
===================================================================
revision 1.95
date: 2000/03/25 07:23:12; author: augustss;
Exp; lines: +24 -7
Improve uhci_dump_ii().
===================================================================
ohci.c (1.81), uhci.c (1.96), uhcivar.h (1.27), usb_subr.c (1.68),
usbdi.c (1.68), usbdivar.h (1.52):
===================================================================
date: 2000/03/25 18:02:33; author: augustss;
Rename and move around callout handles to make it more sane.
Add some DIAGNOSTIC.
Fix buglet in isoc abort on UHCI.
===================================================================
uhci.c (1.98):
===================================================================
revision 1.98
date: 2000/03/27 07:39:48; author: augustss; lines: +12 -4
Make it compile without DIAGNOSTIC.
===================================================================
uhci.c (1.99):
===================================================================
revision 1.99
date: 2000/03/27 08:01:09; author: augustss; lines: +1 -5
Remove some debug nonsense.
===================================================================
uhci.c (1.100):
===================================================================
revision 1.100
date: 2000/03/27 09:41:36; author: augustss; lines: +13 -3
Don't mess with QH in bulk abort for the moment.
===================================================================
uhci.c (1.102):
===================================================================
revision 1.102
date: 2000/03/27 22:42:57; author: augustss; lines: +66 -26
Be a little more careful when aborting.
Preallocate some TDs for large buffers.
===================================================================
uhci.c (1.103):
===================================================================
date: 2000/03/28 09:47:10; author: augustss; lines: +11 -1
Another patch for xfer abort...
XXX The current xfer queueing and aborting semantics should really
XXX be changed. It cannot be implemented in a sane way on UHCI.
XXX One day when I have lots of time I'll redesign it...
===================================================================
uhci.c (1.104): Correct a debug message.
uhci.c (1.105): Be more defensive in a DIAGNOSTIC test.
uhci.c (1.106):
===================================================================
revision 1.106
date: 2000/03/29 01:49:13; author: augustss; lines: +14 -309
*SIGH* Revert back to the old method of aborting xfers.
I had tested the new stuff for two months now, but as soon as I commited
it the problems started to appear. Murphy, no doubt...
===================================================================
usb_subr.c (1.70), usbdi.c (1.71), usbdivar.h (1.53):
===================================================================
revision 1.70
date: 2000/03/29 01:45:20; author: augustss; lines: +2 -1
Do not accept new xfers for queuing while a pipe is aborting.
===================================================================
2002-03-16 12:06:01 +00:00
|
|
|
pipe->aborting = 0;
|
1998-11-26 23:13:13 +00:00
|
|
|
return (USBD_NORMAL_COMPLETION);
|
|
|
|
}
|
|
|
|
|
1999-11-17 22:33:51 +00:00
|
|
|
/* Called at splusb() */
|
1999-10-07 19:26:38 +00:00
|
|
|
void
|
2002-04-01 17:24:49 +00:00
|
|
|
usb_transfer_complete(usbd_xfer_handle xfer)
|
1998-11-26 23:13:13 +00:00
|
|
|
{
|
1999-11-17 22:33:51 +00:00
|
|
|
usbd_pipe_handle pipe = xfer->pipe;
|
|
|
|
usb_dma_t *dmap = &xfer->dmabuf;
|
|
|
|
int repeat = pipe->repeat;
|
1999-10-07 19:26:38 +00:00
|
|
|
int polling;
|
1998-11-26 23:13:13 +00:00
|
|
|
|
1999-11-17 22:33:51 +00:00
|
|
|
SPLUSBCHECK;
|
|
|
|
|
|
|
|
DPRINTFN(5, ("usb_transfer_complete: pipe=%p xfer=%p status=%d "
|
|
|
|
"actlen=%d\n", pipe, xfer, xfer->status, xfer->actlen));
|
1999-10-07 19:26:38 +00:00
|
|
|
|
|
|
|
#ifdef DIAGNOSTIC
|
1999-11-17 22:33:51 +00:00
|
|
|
if (pipe == NULL) {
|
|
|
|
printf("usbd_transfer_cb: pipe==0, xfer=%p\n", xfer);
|
1999-10-07 19:26:38 +00:00
|
|
|
return;
|
1998-11-26 23:13:13 +00:00
|
|
|
}
|
1999-10-07 19:26:38 +00:00
|
|
|
#endif
|
|
|
|
polling = pipe->device->bus->use_polling;
|
|
|
|
/* XXXX */
|
|
|
|
if (polling)
|
|
|
|
pipe->running = 0;
|
|
|
|
|
1999-11-17 22:33:51 +00:00
|
|
|
if (!(xfer->flags & USBD_NO_COPY) && xfer->actlen != 0 &&
|
|
|
|
usbd_xfer_isread(xfer)) {
|
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
if (xfer->actlen > xfer->length) {
|
|
|
|
printf("usb_transfer_complete: actlen > len %d > %d\n",
|
|
|
|
xfer->actlen, xfer->length);
|
|
|
|
xfer->actlen = xfer->length;
|
|
|
|
}
|
|
|
|
#endif
|
2000-02-10 18:50:19 +00:00
|
|
|
memcpy(xfer->buffer, KERNADDR(dmap, 0), xfer->actlen);
|
1999-11-17 22:33:51 +00:00
|
|
|
}
|
1999-10-07 19:26:38 +00:00
|
|
|
|
1999-11-17 22:33:51 +00:00
|
|
|
/* if we allocated the buffer in usbd_transfer() we free it here. */
|
|
|
|
if (xfer->rqflags & URQ_AUTO_DMABUF) {
|
|
|
|
if (!repeat) {
|
1999-10-07 19:26:38 +00:00
|
|
|
struct usbd_bus *bus = pipe->device->bus;
|
|
|
|
bus->methods->freem(bus, dmap);
|
1999-11-17 22:33:51 +00:00
|
|
|
xfer->rqflags &= ~URQ_AUTO_DMABUF;
|
1999-10-07 19:26:38 +00:00
|
|
|
}
|
|
|
|
}
|
1998-11-26 23:13:13 +00:00
|
|
|
|
1999-11-17 22:33:51 +00:00
|
|
|
if (!repeat) {
|
|
|
|
/* Remove request from queue. */
|
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
if (xfer != SIMPLEQ_FIRST(&pipe->queue))
|
|
|
|
printf("usb_transfer_complete: bad dequeue %p != %p\n",
|
|
|
|
xfer, SIMPLEQ_FIRST(&pipe->queue));
|
|
|
|
#endif
|
|
|
|
SIMPLEQ_REMOVE_HEAD(&pipe->queue, xfer, next);
|
|
|
|
}
|
Huge merge from NetBSD:
usbdi.c (1.61):
===================================================================
revision 1.61
date: 2000/01/31 20:13:07; author: augustss; lines: +20 -4
Change the way the HC done method is invoked a little.
===================================================================
usbdi.c (1.65):
===================================================================
revision 1.65
date: 2000/03/08 15:34:10; author: augustss; lines: +4 -2
Get the status right when a polled transfer times out.
===================================================================
ohci.c (1.79), uhci.c (1.89), uhcivar.h (1.24), usb_port.h (1.22),
usbdivar.h (1.48):
===================================================================
date: 2000/03/23 07:01:46; author: thorpej;
New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.
The old timeout()/untimeout() API has been removed from the kernel.
===================================================================
uhci.c (1.80), usbdi.c (1.66):
===================================================================
date: 2000/03/23 18:59:10; author: thorpej;
Shake out some bugs from the callout changes.
===================================================================
ohci.c (1.80), uhci.c (1.91), uhcivar.h (1.25), usb_port.h (1.23),
usbdi.c (1.67), usbdivar.h (1.49):
===================================================================
date: 2000/03/24 22:03:30; author: augustss;
Some cleanup and renaming of the callouts used in USB drivers.
===================================================================
uhci.c (1.92), uhcivar.h (1.26):
===================================================================
date: 2000/03/24 22:57:58; author: augustss;
Two major changes:
Make each xfer have its own intr_info. This is necessary if we want
to queue multiple xfers on an endpoint. This should get rid of the
(mostly harmless) DIAGNOSTICs about intr_infos (not) being done.
Change (again!) how xfers are aborted. Aborting a TD is a nightmare
on the braindead UHCI controller. (Unless you stop the HC, thereby
losing isoc traffic.) Hopefully I got it right this time.
===================================================================
usbdivar.h (1.50):
===================================================================
revision 1.50
date: 2000/03/25 00:10:19; author: augustss; lines: +4 -2
GC an unsued field and add some DIAGNOSTIC in xfer.
===================================================================
ums.c: Use the callout functions instead of the timeout ones.
uhci.c (1.93):
===================================================================
revision 1.93
date: 2000/03/25 00:11:21; author: augustss;
lines: +26 -1
Add more DIAGNOSTIC when aborting isoc.
===================================================================
uhci.c (1.94), usbdivar.h (1.51):
===================================================================
date: 2000/03/25 07:13:05; author: augustss;
More DIAGNOSTIC.
Initialize a callout handle I forgot.
===================================================================
uhci.c (1.95):
===================================================================
revision 1.95
date: 2000/03/25 07:23:12; author: augustss;
Exp; lines: +24 -7
Improve uhci_dump_ii().
===================================================================
ohci.c (1.81), uhci.c (1.96), uhcivar.h (1.27), usb_subr.c (1.68),
usbdi.c (1.68), usbdivar.h (1.52):
===================================================================
date: 2000/03/25 18:02:33; author: augustss;
Rename and move around callout handles to make it more sane.
Add some DIAGNOSTIC.
Fix buglet in isoc abort on UHCI.
===================================================================
uhci.c (1.98):
===================================================================
revision 1.98
date: 2000/03/27 07:39:48; author: augustss; lines: +12 -4
Make it compile without DIAGNOSTIC.
===================================================================
uhci.c (1.99):
===================================================================
revision 1.99
date: 2000/03/27 08:01:09; author: augustss; lines: +1 -5
Remove some debug nonsense.
===================================================================
uhci.c (1.100):
===================================================================
revision 1.100
date: 2000/03/27 09:41:36; author: augustss; lines: +13 -3
Don't mess with QH in bulk abort for the moment.
===================================================================
uhci.c (1.102):
===================================================================
revision 1.102
date: 2000/03/27 22:42:57; author: augustss; lines: +66 -26
Be a little more careful when aborting.
Preallocate some TDs for large buffers.
===================================================================
uhci.c (1.103):
===================================================================
date: 2000/03/28 09:47:10; author: augustss; lines: +11 -1
Another patch for xfer abort...
XXX The current xfer queueing and aborting semantics should really
XXX be changed. It cannot be implemented in a sane way on UHCI.
XXX One day when I have lots of time I'll redesign it...
===================================================================
uhci.c (1.104): Correct a debug message.
uhci.c (1.105): Be more defensive in a DIAGNOSTIC test.
uhci.c (1.106):
===================================================================
revision 1.106
date: 2000/03/29 01:49:13; author: augustss; lines: +14 -309
*SIGH* Revert back to the old method of aborting xfers.
I had tested the new stuff for two months now, but as soon as I commited
it the problems started to appear. Murphy, no doubt...
===================================================================
usb_subr.c (1.70), usbdi.c (1.71), usbdivar.h (1.53):
===================================================================
revision 1.70
date: 2000/03/29 01:45:20; author: augustss; lines: +2 -1
Do not accept new xfers for queuing while a pipe is aborting.
===================================================================
2002-03-16 12:06:01 +00:00
|
|
|
DPRINTFN(5,("usb_transfer_complete: repeat=%d new head=%p\n",
|
|
|
|
repeat, SIMPLEQ_FIRST(&pipe->queue)));
|
1998-11-26 23:13:13 +00:00
|
|
|
|
|
|
|
/* Count completed transfers. */
|
2002-02-20 20:47:21 +00:00
|
|
|
++pipe->device->bus->stats.uds_requests
|
1999-10-07 19:26:38 +00:00
|
|
|
[pipe->endpoint->edesc->bmAttributes & UE_XFERTYPE];
|
1998-11-26 23:13:13 +00:00
|
|
|
|
1999-11-17 22:33:51 +00:00
|
|
|
xfer->done = 1;
|
1999-11-28 21:01:06 +00:00
|
|
|
if (!xfer->status && xfer->actlen < xfer->length &&
|
1999-11-17 22:33:51 +00:00
|
|
|
!(xfer->flags & USBD_SHORT_XFER_OK)) {
|
1999-11-28 21:01:06 +00:00
|
|
|
DPRINTFN(-1,("usbd_transfer_cb: short transfer %d<%d\n",
|
|
|
|
xfer->actlen, xfer->length));
|
1999-11-17 22:33:51 +00:00
|
|
|
xfer->status = USBD_SHORT_XFER;
|
1998-11-26 23:13:13 +00:00
|
|
|
}
|
1999-10-07 19:26:38 +00:00
|
|
|
|
1999-11-17 22:33:51 +00:00
|
|
|
if (xfer->callback)
|
|
|
|
xfer->callback(xfer, xfer->priv, xfer->status);
|
1998-11-26 23:13:13 +00:00
|
|
|
|
Huge merge from NetBSD:
usbdi.c (1.61):
===================================================================
revision 1.61
date: 2000/01/31 20:13:07; author: augustss; lines: +20 -4
Change the way the HC done method is invoked a little.
===================================================================
usbdi.c (1.65):
===================================================================
revision 1.65
date: 2000/03/08 15:34:10; author: augustss; lines: +4 -2
Get the status right when a polled transfer times out.
===================================================================
ohci.c (1.79), uhci.c (1.89), uhcivar.h (1.24), usb_port.h (1.22),
usbdivar.h (1.48):
===================================================================
date: 2000/03/23 07:01:46; author: thorpej;
New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.
The old timeout()/untimeout() API has been removed from the kernel.
===================================================================
uhci.c (1.80), usbdi.c (1.66):
===================================================================
date: 2000/03/23 18:59:10; author: thorpej;
Shake out some bugs from the callout changes.
===================================================================
ohci.c (1.80), uhci.c (1.91), uhcivar.h (1.25), usb_port.h (1.23),
usbdi.c (1.67), usbdivar.h (1.49):
===================================================================
date: 2000/03/24 22:03:30; author: augustss;
Some cleanup and renaming of the callouts used in USB drivers.
===================================================================
uhci.c (1.92), uhcivar.h (1.26):
===================================================================
date: 2000/03/24 22:57:58; author: augustss;
Two major changes:
Make each xfer have its own intr_info. This is necessary if we want
to queue multiple xfers on an endpoint. This should get rid of the
(mostly harmless) DIAGNOSTICs about intr_infos (not) being done.
Change (again!) how xfers are aborted. Aborting a TD is a nightmare
on the braindead UHCI controller. (Unless you stop the HC, thereby
losing isoc traffic.) Hopefully I got it right this time.
===================================================================
usbdivar.h (1.50):
===================================================================
revision 1.50
date: 2000/03/25 00:10:19; author: augustss; lines: +4 -2
GC an unsued field and add some DIAGNOSTIC in xfer.
===================================================================
ums.c: Use the callout functions instead of the timeout ones.
uhci.c (1.93):
===================================================================
revision 1.93
date: 2000/03/25 00:11:21; author: augustss;
lines: +26 -1
Add more DIAGNOSTIC when aborting isoc.
===================================================================
uhci.c (1.94), usbdivar.h (1.51):
===================================================================
date: 2000/03/25 07:13:05; author: augustss;
More DIAGNOSTIC.
Initialize a callout handle I forgot.
===================================================================
uhci.c (1.95):
===================================================================
revision 1.95
date: 2000/03/25 07:23:12; author: augustss;
Exp; lines: +24 -7
Improve uhci_dump_ii().
===================================================================
ohci.c (1.81), uhci.c (1.96), uhcivar.h (1.27), usb_subr.c (1.68),
usbdi.c (1.68), usbdivar.h (1.52):
===================================================================
date: 2000/03/25 18:02:33; author: augustss;
Rename and move around callout handles to make it more sane.
Add some DIAGNOSTIC.
Fix buglet in isoc abort on UHCI.
===================================================================
uhci.c (1.98):
===================================================================
revision 1.98
date: 2000/03/27 07:39:48; author: augustss; lines: +12 -4
Make it compile without DIAGNOSTIC.
===================================================================
uhci.c (1.99):
===================================================================
revision 1.99
date: 2000/03/27 08:01:09; author: augustss; lines: +1 -5
Remove some debug nonsense.
===================================================================
uhci.c (1.100):
===================================================================
revision 1.100
date: 2000/03/27 09:41:36; author: augustss; lines: +13 -3
Don't mess with QH in bulk abort for the moment.
===================================================================
uhci.c (1.102):
===================================================================
revision 1.102
date: 2000/03/27 22:42:57; author: augustss; lines: +66 -26
Be a little more careful when aborting.
Preallocate some TDs for large buffers.
===================================================================
uhci.c (1.103):
===================================================================
date: 2000/03/28 09:47:10; author: augustss; lines: +11 -1
Another patch for xfer abort...
XXX The current xfer queueing and aborting semantics should really
XXX be changed. It cannot be implemented in a sane way on UHCI.
XXX One day when I have lots of time I'll redesign it...
===================================================================
uhci.c (1.104): Correct a debug message.
uhci.c (1.105): Be more defensive in a DIAGNOSTIC test.
uhci.c (1.106):
===================================================================
revision 1.106
date: 2000/03/29 01:49:13; author: augustss; lines: +14 -309
*SIGH* Revert back to the old method of aborting xfers.
I had tested the new stuff for two months now, but as soon as I commited
it the problems started to appear. Murphy, no doubt...
===================================================================
usb_subr.c (1.70), usbdi.c (1.71), usbdivar.h (1.53):
===================================================================
revision 1.70
date: 2000/03/29 01:45:20; author: augustss; lines: +2 -1
Do not accept new xfers for queuing while a pipe is aborting.
===================================================================
2002-03-16 12:06:01 +00:00
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
if (pipe->methods->done != NULL)
|
|
|
|
pipe->methods->done(xfer);
|
|
|
|
else
|
|
|
|
printf("usb_transfer_complete: pipe->methods->done == NULL\n");
|
|
|
|
#else
|
|
|
|
pipe->methods->done(xfer);
|
|
|
|
#endif
|
|
|
|
|
1999-11-17 22:33:51 +00:00
|
|
|
if ((xfer->flags & USBD_SYNCHRONOUS) && !polling)
|
|
|
|
wakeup(xfer);
|
1999-10-07 19:26:38 +00:00
|
|
|
|
1999-11-17 22:33:51 +00:00
|
|
|
if (!repeat) {
|
|
|
|
/* XXX should we stop the queue on all errors? */
|
2000-03-15 22:09:53 +00:00
|
|
|
if ((xfer->status == USBD_CANCELLED
|
|
|
|
|| xfer->status == USBD_TIMEOUT)
|
|
|
|
&& pipe->iface != NULL) /* not control pipe */
|
1999-11-17 22:33:51 +00:00
|
|
|
pipe->running = 0;
|
|
|
|
else
|
|
|
|
usbd_start_next(pipe);
|
|
|
|
}
|
1998-11-26 23:13:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
usbd_status
|
2002-04-01 17:24:49 +00:00
|
|
|
usb_insert_transfer(usbd_xfer_handle xfer)
|
1998-11-26 23:13:13 +00:00
|
|
|
{
|
1999-11-17 22:33:51 +00:00
|
|
|
usbd_pipe_handle pipe = xfer->pipe;
|
|
|
|
usbd_status err;
|
1998-11-26 23:13:13 +00:00
|
|
|
int s;
|
|
|
|
|
1999-11-17 22:33:51 +00:00
|
|
|
DPRINTFN(5,("usb_insert_transfer: pipe=%p running=%d timeout=%d\n",
|
|
|
|
pipe, pipe->running, xfer->timeout));
|
1998-11-26 23:13:13 +00:00
|
|
|
s = splusb();
|
1999-11-17 22:33:51 +00:00
|
|
|
SIMPLEQ_INSERT_TAIL(&pipe->queue, xfer, next);
|
1999-10-07 19:26:38 +00:00
|
|
|
if (pipe->running)
|
1999-11-17 22:33:51 +00:00
|
|
|
err = USBD_IN_PROGRESS;
|
1999-10-07 19:26:38 +00:00
|
|
|
else {
|
|
|
|
pipe->running = 1;
|
1999-11-17 22:33:51 +00:00
|
|
|
err = USBD_NORMAL_COMPLETION;
|
1998-11-26 23:13:13 +00:00
|
|
|
}
|
|
|
|
splx(s);
|
1999-11-17 22:33:51 +00:00
|
|
|
return (err);
|
1999-10-07 19:26:38 +00:00
|
|
|
}
|
|
|
|
|
1999-11-17 22:33:51 +00:00
|
|
|
/* Called at splusb() */
|
1999-10-07 19:26:38 +00:00
|
|
|
void
|
2002-04-01 17:24:49 +00:00
|
|
|
usbd_start_next(usbd_pipe_handle pipe)
|
1999-10-07 19:26:38 +00:00
|
|
|
{
|
1999-11-17 22:33:51 +00:00
|
|
|
usbd_xfer_handle xfer;
|
|
|
|
usbd_status err;
|
|
|
|
|
|
|
|
SPLUSBCHECK;
|
1999-10-07 19:26:38 +00:00
|
|
|
|
|
|
|
#ifdef DIAGNOSTIC
|
1999-11-17 22:33:51 +00:00
|
|
|
if (pipe == NULL) {
|
|
|
|
printf("usbd_start_next: pipe == NULL\n");
|
1999-10-07 19:26:38 +00:00
|
|
|
return;
|
|
|
|
}
|
1999-11-17 22:33:51 +00:00
|
|
|
if (pipe->methods == NULL || pipe->methods->start == NULL) {
|
|
|
|
printf("usbd_start_next: pipe=%p no start method\n", pipe);
|
1999-10-07 19:26:38 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Get next request in queue. */
|
1999-11-17 22:33:51 +00:00
|
|
|
xfer = SIMPLEQ_FIRST(&pipe->queue);
|
|
|
|
DPRINTFN(5, ("usbd_start_next: pipe=%p, xfer=%p\n", pipe, xfer));
|
|
|
|
if (xfer == NULL) {
|
1999-10-07 19:26:38 +00:00
|
|
|
pipe->running = 0;
|
1999-11-17 22:33:51 +00:00
|
|
|
} else {
|
|
|
|
err = pipe->methods->start(xfer);
|
|
|
|
if (err != USBD_IN_PROGRESS) {
|
|
|
|
printf("usbd_start_next: error=%d\n", err);
|
1999-10-07 19:26:38 +00:00
|
|
|
pipe->running = 0;
|
|
|
|
/* XXX do what? */
|
|
|
|
}
|
|
|
|
}
|
1998-11-26 23:13:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
usbd_status
|
2002-04-01 17:24:49 +00:00
|
|
|
usbd_do_request(usbd_device_handle dev, usb_device_request_t *req, void *data)
|
1999-01-07 23:07:57 +00:00
|
|
|
{
|
|
|
|
return (usbd_do_request_flags(dev, req, data, 0, 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
usbd_status
|
2002-04-01 17:24:49 +00:00
|
|
|
usbd_do_request_flags(usbd_device_handle dev, usb_device_request_t *req,
|
|
|
|
void *data, u_int16_t flags, int *actlen)
|
2002-04-01 17:30:24 +00:00
|
|
|
{
|
|
|
|
return (usbd_do_request_flags_pipe(dev, dev->default_pipe, req,
|
|
|
|
data, flags, actlen));
|
|
|
|
}
|
|
|
|
|
|
|
|
usbd_status
|
|
|
|
usbd_do_request_flags_pipe(usbd_device_handle dev, usbd_pipe_handle pipe,
|
|
|
|
usb_device_request_t *req, void *data, u_int16_t flags, int *actlen)
|
1998-11-26 23:13:13 +00:00
|
|
|
{
|
1999-11-17 22:33:51 +00:00
|
|
|
usbd_xfer_handle xfer;
|
|
|
|
usbd_status err;
|
1998-11-26 23:13:13 +00:00
|
|
|
|
|
|
|
#ifdef DIAGNOSTIC
|
1999-11-28 21:01:06 +00:00
|
|
|
#if defined(__i386__) && defined(__FreeBSD__)
|
2001-09-12 08:38:13 +00:00
|
|
|
KASSERT(curthread->td_intr_nesting_level == 0,
|
2000-03-15 22:09:53 +00:00
|
|
|
("usbd_do_request: in interrupt context"));
|
1999-11-17 22:33:51 +00:00
|
|
|
#endif
|
|
|
|
if (dev->bus->intr_context) {
|
1998-11-26 23:13:13 +00:00
|
|
|
printf("usbd_do_request: not in process context\n");
|
1999-10-07 19:26:38 +00:00
|
|
|
return (USBD_INVAL);
|
1998-11-26 23:13:13 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1999-11-28 21:01:06 +00:00
|
|
|
xfer = usbd_alloc_xfer(dev);
|
1999-11-17 22:33:51 +00:00
|
|
|
if (xfer == NULL)
|
1998-11-26 23:13:13 +00:00
|
|
|
return (USBD_NOMEM);
|
1999-11-28 21:01:06 +00:00
|
|
|
usbd_setup_default_xfer(xfer, dev, 0, USBD_DEFAULT_TIMEOUT, req,
|
2002-04-01 17:30:24 +00:00
|
|
|
data, UGETW(req->wLength), flags, 0);
|
|
|
|
xfer->pipe = pipe;
|
1999-11-17 22:33:51 +00:00
|
|
|
err = usbd_sync_transfer(xfer);
|
1998-11-26 23:13:13 +00:00
|
|
|
#if defined(USB_DEBUG) || defined(DIAGNOSTIC)
|
1999-11-17 22:33:51 +00:00
|
|
|
if (xfer->actlen > xfer->length)
|
1999-10-07 19:26:38 +00:00
|
|
|
DPRINTF(("usbd_do_request: overrun addr=%d type=0x%02x req=0x"
|
|
|
|
"%02x val=%d index=%d rlen=%d length=%d actlen=%d\n",
|
1999-11-17 22:33:51 +00:00
|
|
|
dev->address, xfer->request.bmRequestType,
|
|
|
|
xfer->request.bRequest, UGETW(xfer->request.wValue),
|
|
|
|
UGETW(xfer->request.wIndex),
|
|
|
|
UGETW(xfer->request.wLength),
|
|
|
|
xfer->length, xfer->actlen));
|
1998-11-26 23:13:13 +00:00
|
|
|
#endif
|
1999-11-17 22:33:51 +00:00
|
|
|
if (actlen != NULL)
|
|
|
|
*actlen = xfer->actlen;
|
|
|
|
if (err == USBD_STALLED) {
|
1999-01-07 23:07:57 +00:00
|
|
|
/*
|
|
|
|
* The control endpoint has stalled. Control endpoints
|
|
|
|
* should not halt, but some may do so anyway so clear
|
|
|
|
* any halt condition.
|
|
|
|
*/
|
|
|
|
usb_device_request_t treq;
|
|
|
|
usb_status_t status;
|
|
|
|
u_int16_t s;
|
1999-11-17 22:33:51 +00:00
|
|
|
usbd_status nerr;
|
1999-01-07 23:07:57 +00:00
|
|
|
|
|
|
|
treq.bmRequestType = UT_READ_ENDPOINT;
|
|
|
|
treq.bRequest = UR_GET_STATUS;
|
|
|
|
USETW(treq.wValue, 0);
|
|
|
|
USETW(treq.wIndex, 0);
|
|
|
|
USETW(treq.wLength, sizeof(usb_status_t));
|
1999-11-28 21:01:06 +00:00
|
|
|
usbd_setup_default_xfer(xfer, dev, 0, USBD_DEFAULT_TIMEOUT,
|
1999-10-07 19:26:38 +00:00
|
|
|
&treq, &status,sizeof(usb_status_t),
|
|
|
|
0, 0);
|
1999-11-17 22:33:51 +00:00
|
|
|
nerr = usbd_sync_transfer(xfer);
|
|
|
|
if (nerr)
|
1999-01-07 23:07:57 +00:00
|
|
|
goto bad;
|
|
|
|
s = UGETW(status.wStatus);
|
|
|
|
DPRINTF(("usbd_do_request: status = 0x%04x\n", s));
|
|
|
|
if (!(s & UES_HALT))
|
|
|
|
goto bad;
|
|
|
|
treq.bmRequestType = UT_WRITE_ENDPOINT;
|
|
|
|
treq.bRequest = UR_CLEAR_FEATURE;
|
|
|
|
USETW(treq.wValue, UF_ENDPOINT_HALT);
|
|
|
|
USETW(treq.wIndex, 0);
|
|
|
|
USETW(treq.wLength, 0);
|
1999-11-28 21:01:06 +00:00
|
|
|
usbd_setup_default_xfer(xfer, dev, 0, USBD_DEFAULT_TIMEOUT,
|
1999-10-07 19:26:38 +00:00
|
|
|
&treq, &status, 0, 0, 0);
|
1999-11-17 22:33:51 +00:00
|
|
|
nerr = usbd_sync_transfer(xfer);
|
|
|
|
if (nerr)
|
1999-01-07 23:07:57 +00:00
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
|
|
|
|
bad:
|
1999-11-28 21:01:06 +00:00
|
|
|
usbd_free_xfer(xfer);
|
1999-11-17 22:33:51 +00:00
|
|
|
return (err);
|
1998-11-26 23:13:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-04-01 17:24:49 +00:00
|
|
|
usbd_do_request_async_cb(usbd_xfer_handle xfer, usbd_private_handle priv,
|
|
|
|
usbd_status status)
|
1998-11-26 23:13:13 +00:00
|
|
|
{
|
|
|
|
#if defined(USB_DEBUG) || defined(DIAGNOSTIC)
|
1999-11-17 22:33:51 +00:00
|
|
|
if (xfer->actlen > xfer->length)
|
1999-10-07 19:26:38 +00:00
|
|
|
DPRINTF(("usbd_do_request: overrun addr=%d type=0x%02x req=0x"
|
|
|
|
"%02x val=%d index=%d rlen=%d length=%d actlen=%d\n",
|
1999-11-17 22:33:51 +00:00
|
|
|
xfer->pipe->device->address,
|
|
|
|
xfer->request.bmRequestType,
|
|
|
|
xfer->request.bRequest, UGETW(xfer->request.wValue),
|
|
|
|
UGETW(xfer->request.wIndex),
|
|
|
|
UGETW(xfer->request.wLength),
|
|
|
|
xfer->length, xfer->actlen));
|
1998-11-26 23:13:13 +00:00
|
|
|
#endif
|
1999-11-28 21:01:06 +00:00
|
|
|
usbd_free_xfer(xfer);
|
1998-11-26 23:13:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Execute a request without waiting for completion.
|
|
|
|
* Can be used from interrupt context.
|
|
|
|
*/
|
|
|
|
usbd_status
|
2002-04-01 17:24:49 +00:00
|
|
|
usbd_do_request_async(usbd_device_handle dev, usb_device_request_t *req,
|
|
|
|
void *data)
|
1998-11-26 23:13:13 +00:00
|
|
|
{
|
1999-11-17 22:33:51 +00:00
|
|
|
usbd_xfer_handle xfer;
|
|
|
|
usbd_status err;
|
1998-11-26 23:13:13 +00:00
|
|
|
|
1999-11-28 21:01:06 +00:00
|
|
|
xfer = usbd_alloc_xfer(dev);
|
1999-11-17 22:33:51 +00:00
|
|
|
if (xfer == NULL)
|
1998-11-26 23:13:13 +00:00
|
|
|
return (USBD_NOMEM);
|
1999-11-28 21:01:06 +00:00
|
|
|
usbd_setup_default_xfer(xfer, dev, 0, USBD_DEFAULT_TIMEOUT, req,
|
1999-11-17 22:33:51 +00:00
|
|
|
data, UGETW(req->wLength), 0, usbd_do_request_async_cb);
|
|
|
|
err = usbd_transfer(xfer);
|
|
|
|
if (err != USBD_IN_PROGRESS) {
|
1999-11-28 21:01:06 +00:00
|
|
|
usbd_free_xfer(xfer);
|
1999-11-17 22:33:51 +00:00
|
|
|
return (err);
|
1998-11-26 23:13:13 +00:00
|
|
|
}
|
|
|
|
return (USBD_NORMAL_COMPLETION);
|
|
|
|
}
|
|
|
|
|
2001-07-05 10:12:59 +00:00
|
|
|
const struct usbd_quirks *
|
2002-04-01 17:24:49 +00:00
|
|
|
usbd_get_quirks(usbd_device_handle dev)
|
1998-11-26 23:13:13 +00:00
|
|
|
{
|
2002-04-07 10:38:07 +00:00
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
if (dev == NULL) {
|
|
|
|
printf("usbd_get_quirks: dev == NULL\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
1998-11-26 23:13:13 +00:00
|
|
|
return (dev->quirks);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* XXX do periodic free() of free list */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Called from keyboard driver when in polling mode.
|
|
|
|
*/
|
|
|
|
void
|
2002-04-01 17:24:49 +00:00
|
|
|
usbd_dopoll(usbd_interface_handle iface)
|
1998-11-26 23:13:13 +00:00
|
|
|
{
|
1999-10-07 19:26:38 +00:00
|
|
|
iface->device->bus->methods->do_poll(iface->device->bus);
|
1998-11-26 23:13:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-04-01 17:24:49 +00:00
|
|
|
usbd_set_polling(usbd_interface_handle iface, int on)
|
1998-11-26 23:13:13 +00:00
|
|
|
{
|
1999-11-17 22:33:51 +00:00
|
|
|
if (on)
|
|
|
|
iface->device->bus->use_polling++;
|
|
|
|
else
|
|
|
|
iface->device->bus->use_polling--;
|
1998-11-26 23:13:13 +00:00
|
|
|
}
|
1999-01-07 23:07:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
usb_endpoint_descriptor_t *
|
2002-04-01 17:24:49 +00:00
|
|
|
usbd_get_endpoint_descriptor(usbd_interface_handle iface, u_int8_t address)
|
1999-01-07 23:07:57 +00:00
|
|
|
{
|
|
|
|
struct usbd_endpoint *ep;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < iface->idesc->bNumEndpoints; i++) {
|
|
|
|
ep = &iface->endpoints[i];
|
|
|
|
if (ep->edesc->bEndpointAddress == address)
|
|
|
|
return (iface->endpoints[i].edesc);
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2002-04-07 11:56:19 +00:00
|
|
|
/*
|
|
|
|
* usbd_ratecheck() can limit the number of error messages that occurs.
|
|
|
|
* When a device is unplugged it may take up to 0.25s for the hub driver
|
|
|
|
* to notice it. If the driver continuosly tries to do I/O operations
|
|
|
|
* this can generate a large number of messages.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
usbd_ratecheck(struct timeval *last)
|
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
static struct timeval errinterval = { 0, 2500000 }; /* 0.25 s*/
|
|
|
|
|
|
|
|
return (ratecheck(last, &errinterval));
|
|
|
|
#endif
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
2002-04-07 12:32:55 +00:00
|
|
|
/*
|
|
|
|
* Search for a vendor/product pair in an array. The item size is
|
|
|
|
* given as an argument.
|
|
|
|
*/
|
|
|
|
const struct usb_devno *
|
|
|
|
usb_match_device(const struct usb_devno *tbl, u_int nentries, u_int sz,
|
|
|
|
u_int16_t vendor, u_int16_t product)
|
|
|
|
{
|
|
|
|
while (nentries-- > 0) {
|
|
|
|
if (tbl->ud_vendor == vendor && tbl->ud_product == product)
|
|
|
|
return (tbl);
|
|
|
|
tbl = (const struct usb_devno *)((const char *)tbl + sz);
|
|
|
|
}
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
|
1999-01-07 23:07:57 +00:00
|
|
|
#if defined(__FreeBSD__)
|
1999-07-29 01:03:04 +00:00
|
|
|
int
|
1999-01-07 23:07:57 +00:00
|
|
|
usbd_driver_load(module_t mod, int what, void *arg)
|
|
|
|
{
|
1999-10-07 19:26:38 +00:00
|
|
|
/* XXX should implement something like a function that removes all generic devices */
|
1999-11-17 22:33:51 +00:00
|
|
|
|
|
|
|
return (0);
|
1999-01-07 23:07:57 +00:00
|
|
|
}
|
1999-11-17 22:33:51 +00:00
|
|
|
|
1999-01-07 23:07:57 +00:00
|
|
|
#endif
|