version 1.182, 2019/02/17 04:17:31 |
version 1.182.4.2, 2020/02/20 14:53:09 |
Line 76 static void usbd_request_async_cb(struct |
|
Line 76 static void usbd_request_async_cb(struct |
|
void |
void |
usbd_dump_iface(struct usbd_interface *iface) |
usbd_dump_iface(struct usbd_interface *iface) |
{ |
{ |
USBHIST_FUNC(); USBHIST_CALLED(usbdebug); |
USBHIST_FUNC(); |
|
USBHIST_CALLARGS(usbdebug, "iface %#jx", (uintptr_t)iface, 0, 0, 0); |
|
|
USBHIST_LOG(usbdebug, "iface %#jx", (uintptr_t)iface, 0, 0, 0); |
|
if (iface == NULL) |
if (iface == NULL) |
return; |
return; |
USBHIST_LOG(usbdebug, " device = %#jx idesc = %#jx index = %d", |
USBHIST_LOG(usbdebug, " device = %#jx idesc = %#jx index = %d", |
Line 91 usbd_dump_iface(struct usbd_interface *i |
|
Line 91 usbd_dump_iface(struct usbd_interface *i |
|
void |
void |
usbd_dump_device(struct usbd_device *dev) |
usbd_dump_device(struct usbd_device *dev) |
{ |
{ |
USBHIST_FUNC(); USBHIST_CALLED(usbdebug); |
USBHIST_FUNC(); |
|
USBHIST_CALLARGS(usbdebug, "dev = %#jx", (uintptr_t)dev, 0, 0, 0); |
|
|
USBHIST_LOG(usbdebug, "dev = %#jx", (uintptr_t)dev, 0, 0, 0); |
|
if (dev == NULL) |
if (dev == NULL) |
return; |
return; |
USBHIST_LOG(usbdebug, " bus = %#jx default_pipe = %#jx", |
USBHIST_LOG(usbdebug, " bus = %#jx default_pipe = %#jx", |
Line 108 usbd_dump_device(struct usbd_device *dev |
|
Line 108 usbd_dump_device(struct usbd_device *dev |
|
void |
void |
usbd_dump_endpoint(struct usbd_endpoint *endp) |
usbd_dump_endpoint(struct usbd_endpoint *endp) |
{ |
{ |
USBHIST_FUNC(); USBHIST_CALLED(usbdebug); |
USBHIST_FUNC(); |
|
USBHIST_CALLARGS(usbdebug, "endp = %#jx", (uintptr_t)endp, 0, 0, 0); |
|
|
USBHIST_LOG(usbdebug, "endp = %#jx", (uintptr_t)endp, 0, 0, 0); |
|
if (endp == NULL) |
if (endp == NULL) |
return; |
return; |
USBHIST_LOG(usbdebug, " edesc = %#jx refcnt = %jd", |
USBHIST_LOG(usbdebug, " edesc = %#jx refcnt = %jd", |
Line 125 usbd_dump_queue(struct usbd_pipe *pipe) |
|
Line 125 usbd_dump_queue(struct usbd_pipe *pipe) |
|
{ |
{ |
struct usbd_xfer *xfer; |
struct usbd_xfer *xfer; |
|
|
USBHIST_FUNC(); USBHIST_CALLED(usbdebug); |
USBHIST_FUNC(); |
|
USBHIST_CALLARGS(usbdebug, "pipe = %#jx", (uintptr_t)pipe, 0, 0, 0); |
|
|
USBHIST_LOG(usbdebug, "pipe = %#jx", (uintptr_t)pipe, 0, 0, 0); |
|
SIMPLEQ_FOREACH(xfer, &pipe->up_queue, ux_next) { |
SIMPLEQ_FOREACH(xfer, &pipe->up_queue, ux_next) { |
USBHIST_LOG(usbdebug, " xfer = %#jx", (uintptr_t)xfer, |
USBHIST_LOG(usbdebug, " xfer = %#jx", (uintptr_t)xfer, |
0, 0, 0); |
0, 0, 0); |
Line 137 usbd_dump_queue(struct usbd_pipe *pipe) |
|
Line 137 usbd_dump_queue(struct usbd_pipe *pipe) |
|
void |
void |
usbd_dump_pipe(struct usbd_pipe *pipe) |
usbd_dump_pipe(struct usbd_pipe *pipe) |
{ |
{ |
USBHIST_FUNC(); USBHIST_CALLED(usbdebug); |
USBHIST_FUNC(); |
|
USBHIST_CALLARGS(usbdebug, "pipe = %#jx", (uintptr_t)pipe, 0, 0, 0); |
|
|
USBHIST_LOG(usbdebug, "pipe = %#jx", (uintptr_t)pipe, 0, 0, 0); |
|
if (pipe == NULL) |
if (pipe == NULL) |
return; |
return; |
usbd_dump_iface(pipe->up_iface); |
usbd_dump_iface(pipe->up_iface); |
Line 171 usbd_open_pipe_ival(struct usbd_interfac |
|
Line 171 usbd_open_pipe_ival(struct usbd_interfac |
|
usbd_status err; |
usbd_status err; |
int i; |
int i; |
|
|
USBHIST_FUNC(); USBHIST_CALLED(usbdebug); |
USBHIST_FUNC(); |
|
USBHIST_CALLARGS(usbdebug, "iface = %#jx address = 0x%jx flags = 0x%jx", |
USBHIST_LOG(usbdebug, "iface = %#jx address = 0x%jx flags = 0x%jx", |
|
(uintptr_t)iface, address, flags, 0); |
(uintptr_t)iface, address, flags, 0); |
|
|
for (i = 0; i < iface->ui_idesc->bNumEndpoints; i++) { |
for (i = 0; i < iface->ui_idesc->bNumEndpoints; i++) { |
Line 205 usbd_open_pipe_intr(struct usbd_interfac |
|
Line 204 usbd_open_pipe_intr(struct usbd_interfac |
|
struct usbd_xfer *xfer; |
struct usbd_xfer *xfer; |
struct usbd_pipe *ipipe; |
struct usbd_pipe *ipipe; |
|
|
USBHIST_FUNC(); USBHIST_CALLED(usbdebug); |
USBHIST_FUNC(); |
|
USBHIST_CALLARGS(usbdebug, "address = 0x%jx flags = 0x%jx len = %jd", |
USBHIST_LOG(usbdebug, "address = 0x%jx flags = 0x%jx len = %jd", |
|
address, flags, len, 0); |
address, flags, len, 0); |
|
|
err = usbd_open_pipe_ival(iface, address, |
err = usbd_open_pipe_ival(iface, address, |
Line 279 usbd_transfer(struct usbd_xfer *xfer) |
|
Line 277 usbd_transfer(struct usbd_xfer *xfer) |
|
usbd_status err; |
usbd_status err; |
unsigned int size, flags; |
unsigned int size, flags; |
|
|
USBHIST_FUNC(); USBHIST_CALLED(usbdebug); |
USBHIST_FUNC(); USBHIST_CALLARGS(usbdebug, |
|
|
USBHIST_LOG(usbdebug, |
|
"xfer = %#jx, flags = %#jx, pipe = %#jx, running = %jd", |
"xfer = %#jx, flags = %#jx, pipe = %#jx, running = %jd", |
(uintptr_t)xfer, xfer->ux_flags, (uintptr_t)pipe, pipe->up_running); |
(uintptr_t)xfer, xfer->ux_flags, (uintptr_t)pipe, pipe->up_running); |
KASSERT(xfer->ux_status == USBD_NOT_STARTED); |
KASSERT(xfer->ux_status == USBD_NOT_STARTED); |
Line 327 usbd_transfer(struct usbd_xfer *xfer) |
|
Line 323 usbd_transfer(struct usbd_xfer *xfer) |
|
|
|
/* xfer is not valid after the transfer method unless synchronous */ |
/* xfer is not valid after the transfer method unless synchronous */ |
err = pipe->up_methods->upm_transfer(xfer); |
err = pipe->up_methods->upm_transfer(xfer); |
USBHIST_LOG(usbdebug, "<- done transfer %#jx, err = %jd", |
|
(uintptr_t)xfer, err, 0, 0); |
|
|
|
if (err != USBD_IN_PROGRESS && err) { |
if (err != USBD_IN_PROGRESS && err) { |
/* |
/* |
Line 336 usbd_transfer(struct usbd_xfer *xfer) |
|
Line 330 usbd_transfer(struct usbd_xfer *xfer) |
|
* accepted by the HCD for some reason. It needs removing |
* accepted by the HCD for some reason. It needs removing |
* from the pipe queue. |
* from the pipe queue. |
*/ |
*/ |
|
USBHIST_LOG(usbdebug, "xfer failed: %s, reinserting", |
|
err, 0, 0, 0); |
usbd_lock_pipe(pipe); |
usbd_lock_pipe(pipe); |
SIMPLEQ_REMOVE_HEAD(&pipe->up_queue, ux_next); |
SIMPLEQ_REMOVE_HEAD(&pipe->up_queue, ux_next); |
if (pipe->up_serialise) |
if (pipe->up_serialise) |
Line 350 usbd_transfer(struct usbd_xfer *xfer) |
|
Line 346 usbd_transfer(struct usbd_xfer *xfer) |
|
} |
} |
|
|
if (err != USBD_IN_PROGRESS) { |
if (err != USBD_IN_PROGRESS) { |
USBHIST_LOG(usbdebug, "<- done xfer %#jx, sync (err %jd)" |
USBHIST_LOG(usbdebug, "<- done xfer %#jx, sync (err %jd)", |
"(complete/error)", (uintptr_t)xfer, err, 0, 0); |
(uintptr_t)xfer, err, 0, 0); |
return err; |
return err; |
} |
} |
|
|
Line 469 usbd_alloc_xfer(struct usbd_device *dev, |
|
Line 465 usbd_alloc_xfer(struct usbd_device *dev, |
|
{ |
{ |
struct usbd_xfer *xfer; |
struct usbd_xfer *xfer; |
|
|
USBHIST_FUNC(); USBHIST_CALLED(usbdebug); |
USBHIST_FUNC(); |
|
|
ASSERT_SLEEPABLE(); |
ASSERT_SLEEPABLE(); |
|
|
xfer = dev->ud_bus->ub_methods->ubm_allocx(dev->ud_bus, nframes); |
xfer = dev->ud_bus->ub_methods->ubm_allocx(dev->ud_bus, nframes); |
if (xfer == NULL) |
if (xfer == NULL) |
return NULL; |
goto out; |
xfer->ux_bus = dev->ud_bus; |
xfer->ux_bus = dev->ud_bus; |
callout_init(&xfer->ux_callout, CALLOUT_MPSAFE); |
callout_init(&xfer->ux_callout, CALLOUT_MPSAFE); |
cv_init(&xfer->ux_cv, "usbxfer"); |
cv_init(&xfer->ux_cv, "usbxfer"); |
|
|
USBHIST_LOG(usbdebug, "returns %#jx", (uintptr_t)xfer, 0, 0, 0); |
out: |
|
USBHIST_CALLARGS(usbdebug, "returns %#jx", (uintptr_t)xfer, 0, 0, 0); |
|
|
return xfer; |
return xfer; |
} |
} |
Line 488 usbd_alloc_xfer(struct usbd_device *dev, |
|
Line 485 usbd_alloc_xfer(struct usbd_device *dev, |
|
static usbd_status |
static usbd_status |
usbd_free_xfer(struct usbd_xfer *xfer) |
usbd_free_xfer(struct usbd_xfer *xfer) |
{ |
{ |
USBHIST_FUNC(); USBHIST_CALLED(usbdebug); |
USBHIST_FUNC(); |
|
USBHIST_CALLARGS(usbdebug, "%#jx", (uintptr_t)xfer, 0, 0, 0); |
|
|
USBHIST_LOG(usbdebug, "%#jx", (uintptr_t)xfer, 0, 0, 0); |
|
if (xfer->ux_buf) { |
if (xfer->ux_buf) { |
usbd_free_buffer(xfer); |
usbd_free_buffer(xfer); |
} |
} |
Line 794 usbd_set_interface(struct usbd_interface |
|
Line 791 usbd_set_interface(struct usbd_interface |
|
usbd_status err; |
usbd_status err; |
void *endpoints; |
void *endpoints; |
|
|
USBHIST_FUNC(); USBHIST_CALLED(usbdebug); |
USBHIST_FUNC(); |
|
|
if (LIST_FIRST(&iface->ui_pipes) != NULL) |
if (LIST_FIRST(&iface->ui_pipes) != NULL) |
return USBD_IN_USE; |
return USBD_IN_USE; |
|
|
endpoints = iface->ui_endpoints; |
endpoints = iface->ui_endpoints; |
int nendpt = iface->ui_idesc->bNumEndpoints; |
int nendpt = iface->ui_idesc->bNumEndpoints; |
USBHIST_LOG(usbdebug, "iface %#jx endpoints = %#jx nendpt %jd", |
USBHIST_CALLARGS(usbdebug, "iface %#jx endpoints = %#jx nendpt %jd", |
(uintptr_t)iface, (uintptr_t)endpoints, |
(uintptr_t)iface, (uintptr_t)endpoints, |
iface->ui_idesc->bNumEndpoints, 0); |
iface->ui_idesc->bNumEndpoints, 0); |
err = usbd_fill_iface_data(iface->ui_dev, iface->ui_index, altidx); |
err = usbd_fill_iface_data(iface->ui_dev, iface->ui_index, altidx); |
Line 869 usbd_ar_pipe(struct usbd_pipe *pipe) |
|
Line 866 usbd_ar_pipe(struct usbd_pipe *pipe) |
|
{ |
{ |
struct usbd_xfer *xfer; |
struct usbd_xfer *xfer; |
|
|
USBHIST_FUNC(); USBHIST_CALLED(usbdebug); |
USBHIST_FUNC(); |
|
USBHIST_CALLARGS(usbdebug, "pipe = %#jx", (uintptr_t)pipe, 0, 0, 0); |
|
|
KASSERT(mutex_owned(pipe->up_dev->ud_bus->ub_lock)); |
KASSERT(mutex_owned(pipe->up_dev->ud_bus->ub_lock)); |
|
|
USBHIST_LOG(usbdebug, "pipe = %#jx", (uintptr_t)pipe, 0, 0, 0); |
|
#ifdef USB_DEBUG |
#ifdef USB_DEBUG |
if (usbdebug > 5) |
if (usbdebug > 5) |
usbd_dump_queue(pipe); |
usbd_dump_queue(pipe); |
#endif |
#endif |
pipe->up_repeat = 0; |
pipe->up_repeat = 0; |
|
pipe->up_running = 0; |
pipe->up_aborting = 1; |
pipe->up_aborting = 1; |
while ((xfer = SIMPLEQ_FIRST(&pipe->up_queue)) != NULL) { |
while ((xfer = SIMPLEQ_FIRST(&pipe->up_queue)) != NULL) { |
USBHIST_LOG(usbdebug, "pipe = %#jx xfer = %#jx " |
USBHIST_LOG(usbdebug, "pipe = %#jx xfer = %#jx " |
Line 907 usb_transfer_complete(struct usbd_xfer * |
|
Line 905 usb_transfer_complete(struct usbd_xfer * |
|
int polling = bus->ub_usepolling; |
int polling = bus->ub_usepolling; |
int repeat = pipe->up_repeat; |
int repeat = pipe->up_repeat; |
|
|
USBHIST_FUNC(); USBHIST_CALLED(usbdebug); |
USBHIST_FUNC(); |
|
USBHIST_CALLARGS(usbdebug, "pipe = %#jx xfer = %#jx status = %jd " |
USBHIST_LOG(usbdebug, "pipe = %#jx xfer = %#jx status = %jd " |
|
"actlen = %jd", (uintptr_t)pipe, (uintptr_t)xfer, xfer->ux_status, |
"actlen = %jd", (uintptr_t)pipe, (uintptr_t)xfer, xfer->ux_status, |
xfer->ux_actlen); |
xfer->ux_actlen); |
|
|
Line 1028 usb_insert_transfer(struct usbd_xfer *xf |
|
Line 1025 usb_insert_transfer(struct usbd_xfer *xf |
|
struct usbd_pipe *pipe = xfer->ux_pipe; |
struct usbd_pipe *pipe = xfer->ux_pipe; |
usbd_status err; |
usbd_status err; |
|
|
USBHIST_FUNC(); USBHIST_CALLED(usbdebug); |
USBHIST_FUNC(); USBHIST_CALLARGS(usbdebug, |
|
"xfer = %#jx pipe = %#jx running = %jd timeout = %jd", |
USBHIST_LOG(usbdebug, "xfer = %#jx pipe = %#jx running = %jd " |
(uintptr_t)xfer, (uintptr_t)pipe, |
"timeout = %jd", (uintptr_t)xfer, (uintptr_t)pipe, |
|
pipe->up_running, xfer->ux_timeout); |
pipe->up_running, xfer->ux_timeout); |
|
|
KASSERT(mutex_owned(pipe->up_dev->ud_bus->ub_lock)); |
KASSERT(mutex_owned(pipe->up_dev->ud_bus->ub_lock)); |
Line 1060 usbd_start_next(struct usbd_pipe *pipe) |
|
Line 1056 usbd_start_next(struct usbd_pipe *pipe) |
|
struct usbd_xfer *xfer; |
struct usbd_xfer *xfer; |
usbd_status err; |
usbd_status err; |
|
|
USBHIST_FUNC(); USBHIST_CALLED(usbdebug); |
USBHIST_FUNC(); |
|
|
KASSERT(pipe != NULL); |
KASSERT(pipe != NULL); |
KASSERT(pipe->up_methods != NULL); |
KASSERT(pipe->up_methods != NULL); |
Line 1072 usbd_start_next(struct usbd_pipe *pipe) |
|
Line 1068 usbd_start_next(struct usbd_pipe *pipe) |
|
|
|
/* Get next request in queue. */ |
/* Get next request in queue. */ |
xfer = SIMPLEQ_FIRST(&pipe->up_queue); |
xfer = SIMPLEQ_FIRST(&pipe->up_queue); |
USBHIST_LOG(usbdebug, "pipe = %#jx, xfer = %#jx", (uintptr_t)pipe, |
USBHIST_CALLARGS(usbdebug, "pipe = %#jx, xfer = %#jx", (uintptr_t)pipe, |
(uintptr_t)xfer, 0, 0); |
(uintptr_t)xfer, 0, 0); |
if (xfer == NULL) { |
if (xfer == NULL) { |
pipe->up_running = 0; |
pipe->up_running = 0; |
|
|
usbd_do_request_flags(struct usbd_device *dev, usb_device_request_t *req, |
usbd_do_request_flags(struct usbd_device *dev, usb_device_request_t *req, |
void *data, uint16_t flags, int *actlen, uint32_t timeout) |
void *data, uint16_t flags, int *actlen, uint32_t timeout) |
{ |
{ |
USBHIST_FUNC(); USBHIST_CALLED(usbdebug); |
size_t len = UGETW(req->wLength); |
|
|
|
return usbd_do_request_len(dev, req, len, data, flags, actlen, timeout); |
|
} |
|
|
|
usbd_status |
|
usbd_do_request_len(struct usbd_device *dev, usb_device_request_t *req, |
|
size_t len, void *data, uint16_t flags, int *actlen, uint32_t timeout) |
|
{ |
struct usbd_xfer *xfer; |
struct usbd_xfer *xfer; |
usbd_status err; |
usbd_status err; |
|
|
|
KASSERT(len >= UGETW(req->wLength)); |
|
|
|
USBHIST_FUNC(); |
|
USBHIST_CALLARGS(usbdebug, "dev=%#jx req=%jx flags=%jx len=%jx", |
|
(uintptr_t)dev, (uintptr_t)req, flags, len); |
|
|
ASSERT_SLEEPABLE(); |
ASSERT_SLEEPABLE(); |
|
|
size_t len = UGETW(req->wLength); |
|
int error = usbd_create_xfer(dev->ud_pipe0, len, 0, 0, &xfer); |
int error = usbd_create_xfer(dev->ud_pipe0, len, 0, 0, &xfer); |
if (error) |
if (error) |
return error; |
return error; |