| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: ugenhc.c,v 1.22.2.1 2017/04/05 19:54:23 snj Exp $ */ | | 1 | /* $NetBSD: ugenhc.c,v 1.22.2.2 2017/04/19 17:15:18 snj Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2009, 2010 Antti Kantee. All Rights Reserved. | | 4 | * Copyright (c) 2009, 2010 Antti Kantee. All Rights Reserved. |
5 | * | | 5 | * |
6 | * Redistribution and use in source and binary forms, with or without | | 6 | * Redistribution and use in source and binary forms, with or without |
7 | * modification, are permitted provided that the following conditions | | 7 | * modification, are permitted provided that the following conditions |
8 | * are met: | | 8 | * are met: |
9 | * 1. Redistributions of source code must retain the above copyright | | 9 | * 1. Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. | | 10 | * notice, this list of conditions and the following disclaimer. |
11 | * 2. Redistributions in binary form must reproduce the above copyright | | 11 | * 2. Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the | | 12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. | | 13 | * documentation and/or other materials provided with the distribution. |
14 | * | | 14 | * |
| @@ -51,27 +51,27 @@ | | | @@ -51,27 +51,27 @@ |
51 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 51 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
52 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 52 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
53 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 53 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
54 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 54 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
55 | * POSSIBILITY OF SUCH DAMAGE. | | 55 | * POSSIBILITY OF SUCH DAMAGE. |
56 | */ | | 56 | */ |
57 | | | 57 | |
58 | /* | | 58 | /* |
59 | * This rump driver attaches ugen as a kernel usb host controller. | | 59 | * This rump driver attaches ugen as a kernel usb host controller. |
60 | * It's still somewhat under the hammer .... | | 60 | * It's still somewhat under the hammer .... |
61 | */ | | 61 | */ |
62 | | | 62 | |
63 | #include <sys/cdefs.h> | | 63 | #include <sys/cdefs.h> |
64 | __KERNEL_RCSID(0, "$NetBSD: ugenhc.c,v 1.22.2.1 2017/04/05 19:54:23 snj Exp $"); | | 64 | __KERNEL_RCSID(0, "$NetBSD: ugenhc.c,v 1.22.2.2 2017/04/19 17:15:18 snj Exp $"); |
65 | | | 65 | |
66 | #include <sys/param.h> | | 66 | #include <sys/param.h> |
67 | #include <sys/bus.h> | | 67 | #include <sys/bus.h> |
68 | #include <sys/conf.h> | | 68 | #include <sys/conf.h> |
69 | #include <sys/device.h> | | 69 | #include <sys/device.h> |
70 | #include <sys/fcntl.h> | | 70 | #include <sys/fcntl.h> |
71 | #include <sys/kmem.h> | | 71 | #include <sys/kmem.h> |
72 | #include <sys/kernel.h> | | 72 | #include <sys/kernel.h> |
73 | #include <sys/kthread.h> | | 73 | #include <sys/kthread.h> |
74 | #include <sys/mutex.h> | | 74 | #include <sys/mutex.h> |
75 | | | 75 | |
76 | #include <dev/usb/usb.h> | | 76 | #include <dev/usb/usb.h> |
77 | #include <dev/usb/usbdi.h> | | 77 | #include <dev/usb/usbdi.h> |
| @@ -479,27 +479,27 @@ rhscintr(void *arg) | | | @@ -479,27 +479,27 @@ rhscintr(void *arg) |
479 | xfer->ux_status = USBD_NORMAL_COMPLETION; | | 479 | xfer->ux_status = USBD_NORMAL_COMPLETION; |
480 | | | 480 | |
481 | mutex_enter(&sc->sc_lock); | | 481 | mutex_enter(&sc->sc_lock); |
482 | usb_transfer_complete(xfer); | | 482 | usb_transfer_complete(xfer); |
483 | mutex_exit(&sc->sc_lock); | | 483 | mutex_exit(&sc->sc_lock); |
484 | | | 484 | |
485 | kpause("ugwait2", false, hz, NULL); | | 485 | kpause("ugwait2", false, hz, NULL); |
486 | | | 486 | |
487 | /* | | 487 | /* |
488 | * Detect device detach. | | 488 | * Detect device detach. |
489 | */ | | 489 | */ |
490 | | | 490 | |
491 | for (;;) { | | 491 | for (;;) { |
492 | fd = rumpuser_open(buf, RUMPUSER_OPEN_RDWR, &error); | | 492 | error = rumpuser_open(buf, RUMPUSER_OPEN_RDWR, &fd); |
493 | if (fd == -1) | | 493 | if (fd == -1) |
494 | break; | | 494 | break; |
495 | | | 495 | |
496 | error = rumpuser_close(fd); | | 496 | error = rumpuser_close(fd); |
497 | kpause("ugwait2", false, hz/4, NULL); | | 497 | kpause("ugwait2", false, hz/4, NULL); |
498 | } | | 498 | } |
499 | | | 499 | |
500 | sc->sc_port_status = ~(UPS_CURRENT_CONNECT_STATUS | | 500 | sc->sc_port_status = ~(UPS_CURRENT_CONNECT_STATUS |
501 | | UPS_PORT_ENABLED | UPS_PORT_POWER); | | 501 | | UPS_PORT_ENABLED | UPS_PORT_POWER); |
502 | sc->sc_port_change = UPS_C_CONNECT_STATUS | UPS_C_PORT_RESET; | | 502 | sc->sc_port_change = UPS_C_CONNECT_STATUS | UPS_C_PORT_RESET; |
503 | | | 503 | |
504 | error = rumpuser_close(sc->sc_ugenfd[UGEN_EPT_CTRL]); | | 504 | error = rumpuser_close(sc->sc_ugenfd[UGEN_EPT_CTRL]); |
505 | sc->sc_ugenfd[UGEN_EPT_CTRL] = -1; | | 505 | sc->sc_ugenfd[UGEN_EPT_CTRL] = -1; |
| @@ -593,27 +593,27 @@ rumpusb_device_bulk_start(struct usbd_xf | | | @@ -593,27 +593,27 @@ rumpusb_device_bulk_start(struct usbd_xf |
593 | size_t n, done; | | 593 | size_t n, done; |
594 | bool isread; | | 594 | bool isread; |
595 | int len, error, endpt; | | 595 | int len, error, endpt; |
596 | uint8_t *buf; | | 596 | uint8_t *buf; |
597 | int xfererr = USBD_NORMAL_COMPLETION; | | 597 | int xfererr = USBD_NORMAL_COMPLETION; |
598 | int shortval, i; | | 598 | int shortval, i; |
599 | | | 599 | |
600 | ed = xfer->ux_pipe->up_endpoint->ue_edesc; | | 600 | ed = xfer->ux_pipe->up_endpoint->ue_edesc; |
601 | endpt = ed->bEndpointAddress; | | 601 | endpt = ed->bEndpointAddress; |
602 | isread = UE_GET_DIR(endpt) == UE_DIR_IN; | | 602 | isread = UE_GET_DIR(endpt) == UE_DIR_IN; |
603 | endpt = UE_GET_ADDR(endpt); | | 603 | endpt = UE_GET_ADDR(endpt); |
604 | KASSERT(endpt < UGEN_NEPTS); | | 604 | KASSERT(endpt < UGEN_NEPTS); |
605 | | | 605 | |
606 | buf = KERNADDR(&xfer->ux_dmabuf, 0); | | 606 | buf = xfer->ux_buf; |
607 | done = 0; | | 607 | done = 0; |
608 | if ((ed->bmAttributes & UE_XFERTYPE) == UE_ISOCHRONOUS) { | | 608 | if ((ed->bmAttributes & UE_XFERTYPE) == UE_ISOCHRONOUS) { |
609 | for (i = 0, len = 0; i < xfer->ux_nframes; i++) | | 609 | for (i = 0, len = 0; i < xfer->ux_nframes; i++) |
610 | len += xfer->ux_frlengths[i]; | | 610 | len += xfer->ux_frlengths[i]; |
611 | } else { | | 611 | } else { |
612 | KASSERT(xfer->ux_length); | | 612 | KASSERT(xfer->ux_length); |
613 | len = xfer->ux_length; | | 613 | len = xfer->ux_length; |
614 | } | | 614 | } |
615 | shortval = (xfer->ux_flags & USBD_SHORT_XFER_OK) != 0; | | 615 | shortval = (xfer->ux_flags & USBD_SHORT_XFER_OK) != 0; |
616 | | | 616 | |
617 | while (RUSB(xfer)->rusb_status == 0) { | | 617 | while (RUSB(xfer)->rusb_status == 0) { |
618 | if (isread) { | | 618 | if (isread) { |
619 | struct rumpuser_iovec iov; | | 619 | struct rumpuser_iovec iov; |