CVS commit: src/sys/rump/dev/lib/libugenhc
Module Name:src Committed By: riastradh Date: Mon Apr 17 07:13:30 UTC 2017 Modified Files: src/sys/rump/dev/lib/libugenhc: ugenhc.c Log Message: Fix bulk xfer buffer with usedma = false. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/sys/rump/dev/lib/libugenhc/ugenhc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/rump/dev/lib/libugenhc/ugenhc.c diff -u src/sys/rump/dev/lib/libugenhc/ugenhc.c:1.25 src/sys/rump/dev/lib/libugenhc/ugenhc.c:1.26 --- src/sys/rump/dev/lib/libugenhc/ugenhc.c:1.25 Mon Apr 17 05:11:05 2017 +++ src/sys/rump/dev/lib/libugenhc/ugenhc.c Mon Apr 17 07:13:30 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ugenhc.c,v 1.25 2017/04/17 05:11:05 riastradh Exp $ */ +/* $NetBSD: ugenhc.c,v 1.26 2017/04/17 07:13:30 riastradh Exp $ */ /* * Copyright (c) 2009, 2010 Antti Kantee. All Rights Reserved. @@ -61,7 +61,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ugenhc.c,v 1.25 2017/04/17 05:11:05 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ugenhc.c,v 1.26 2017/04/17 07:13:30 riastradh Exp $"); #include #include @@ -603,7 +603,7 @@ rumpusb_device_bulk_start(struct usbd_xf endpt = UE_GET_ADDR(endpt); KASSERT(endpt < UGEN_NEPTS); - buf = KERNADDR(>ux_dmabuf, 0); + buf = xfer->ux_buf; done = 0; if ((ed->bmAttributes & UE_XFERTYPE) == UE_ISOCHRONOUS) { for (i = 0, len = 0; i < xfer->ux_nframes; i++)
CVS commit: src/sys/rump/dev/lib/libugenhc
Module Name:src Committed By: riastradh Date: Mon Apr 17 05:11:05 UTC 2017 Modified Files: src/sys/rump/dev/lib/libugenhc: ugenhc.c Log Message: Fix order of outputs in rumpuser_open call. Now ugenhc works again after a four-year hiatus... To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/sys/rump/dev/lib/libugenhc/ugenhc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/rump/dev/lib/libugenhc/ugenhc.c diff -u src/sys/rump/dev/lib/libugenhc/ugenhc.c:1.24 src/sys/rump/dev/lib/libugenhc/ugenhc.c:1.25 --- src/sys/rump/dev/lib/libugenhc/ugenhc.c:1.24 Sat Apr 23 10:15:30 2016 +++ src/sys/rump/dev/lib/libugenhc/ugenhc.c Mon Apr 17 05:11:05 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ugenhc.c,v 1.24 2016/04/23 10:15:30 skrll Exp $ */ +/* $NetBSD: ugenhc.c,v 1.25 2017/04/17 05:11:05 riastradh Exp $ */ /* * Copyright (c) 2009, 2010 Antti Kantee. All Rights Reserved. @@ -61,7 +61,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ugenhc.c,v 1.24 2016/04/23 10:15:30 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ugenhc.c,v 1.25 2017/04/17 05:11:05 riastradh Exp $"); #include #include @@ -489,7 +489,7 @@ rhscintr(void *arg) */ for (;;) { - fd = rumpuser_open(buf, RUMPUSER_OPEN_RDWR, ); + error = rumpuser_open(buf, RUMPUSER_OPEN_RDWR, ); if (fd == -1) break;
CVS commit: src/sys/rump/dev/lib/libugenhc
Module Name:src Committed By: pooka Date: Mon Sep 14 15:08:50 UTC 2015 Modified Files: src/sys/rump/dev/lib/libugenhc: ugenhc_dma.c Log Message: Note in comment why this "d"ma implementation is not in libusb. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/rump/dev/lib/libugenhc/ugenhc_dma.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/rump/dev/lib/libugenhc/ugenhc_dma.c diff -u src/sys/rump/dev/lib/libugenhc/ugenhc_dma.c:1.1 src/sys/rump/dev/lib/libugenhc/ugenhc_dma.c:1.2 --- src/sys/rump/dev/lib/libugenhc/ugenhc_dma.c:1.1 Thu Sep 19 17:55:22 2013 +++ src/sys/rump/dev/lib/libugenhc/ugenhc_dma.c Mon Sep 14 15:08:50 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: ugenhc_dma.c,v 1.1 2013/09/19 17:55:22 pooka Exp $ */ +/* $NetBSD: ugenhc_dma.c,v 1.2 2015/09/14 15:08:50 pooka Exp $ */ /* * Copyright (c) 2009 Antti Kantee. All Rights Reserved. @@ -34,7 +34,16 @@ #include /* - * bus_dma(9) that works for USB drivers + * bus_dma(9) that works for USB drivers. + * + * So why is it here instead of in libusb? Well, first of all, it's + * actually a bus_dma implementation which works with ugenhc. Of course, + * ugenhc doesn't make any bus_dma calls itself, all of those calls come + * from the usb code. However, the USB component can be paired with other + * USB host controllers, such as {e,o,u}hci. Therefore, we keep the "D"MA + * code here. + * + * Note: this implementation requires a __HAVE_NEW_STYLE_BUS_H arch */ int
CVS commit: src/sys/rump/dev/lib/libugenhc
Module Name:src Committed By: pooka Date: Mon Sep 14 15:09:35 UTC 2015 Modified Files: src/sys/rump/dev/lib/libugenhc: Makefile Log Message: Fully build ugenhc only on archs where libusb is built. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/rump/dev/lib/libugenhc/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/rump/dev/lib/libugenhc/Makefile diff -u src/sys/rump/dev/lib/libugenhc/Makefile:1.8 src/sys/rump/dev/lib/libugenhc/Makefile:1.9 --- src/sys/rump/dev/lib/libugenhc/Makefile:1.8 Thu Mar 13 01:38:11 2014 +++ src/sys/rump/dev/lib/libugenhc/Makefile Mon Sep 14 15:09:35 2015 @@ -1,7 +1,9 @@ -# $NetBSD: Makefile,v 1.8 2014/03/13 01:38:11 pooka Exp $ +# $NetBSD: Makefile,v 1.9 2015/09/14 15:09:35 pooka Exp $ # LIB= rumpdev_ugenhc + +.if ${MACHINE} == "i386" || ${MACHINE} == "amd64" IOCONF= UGENHC.ioconf SRCS= ugenhc.c ugenhc_at_mainbus.c ugenhc_dma.c @@ -9,6 +11,10 @@ SRCS= ugenhc.c ugenhc_at_mainbus.c ugenh CPPFLAGS+= -I${RUMPTOP}/librump/rumpkern RUMPCOMP_USER_SRCS= ugenhc_user.c +.else +.PATH: ${.CURDIR}/../libusb +SRCS= dummy.c +.endif .include .include
CVS commit: src/sys/rump/dev/lib/libugenhc
Module Name:src Committed By: skrll Date: Sat Aug 2 07:18:47 UTC 2014 Modified Files: src/sys/rump/dev/lib/libugenhc: ugenhc.c Log Message: Return a valid error in rumpusb_root_intr_start on failure. To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/sys/rump/dev/lib/libugenhc/ugenhc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/rump/dev/lib/libugenhc/ugenhc.c diff -u src/sys/rump/dev/lib/libugenhc/ugenhc.c:1.18 src/sys/rump/dev/lib/libugenhc/ugenhc.c:1.19 --- src/sys/rump/dev/lib/libugenhc/ugenhc.c:1.18 Thu Mar 20 20:42:08 2014 +++ src/sys/rump/dev/lib/libugenhc/ugenhc.c Sat Aug 2 07:18:47 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: ugenhc.c,v 1.18 2014/03/20 20:42:08 christos Exp $ */ +/* $NetBSD: ugenhc.c,v 1.19 2014/08/02 07:18:47 skrll Exp $ */ /* * Copyright (c) 2009, 2010 Antti Kantee. All Rights Reserved. @@ -61,7 +61,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: ugenhc.c,v 1.18 2014/03/20 20:42:08 christos Exp $); +__KERNEL_RCSID(0, $NetBSD: ugenhc.c,v 1.19 2014/08/02 07:18:47 skrll Exp $); #include sys/param.h #include sys/bus.h @@ -667,7 +667,7 @@ rumpusb_root_intr_start(usbd_xfer_handle error = kthread_create(PRI_NONE, 0, NULL, rhscintr, sc, sc-sc_rhintr, ugenrhi); if (error) - xfer-status = error; + xfer-status = USBD_IOERROR; } return (USBD_IN_PROGRESS);
CVS commit: src/sys/rump/dev/lib/libugenhc
Module Name:src Committed By: skrll Date: Sat Aug 2 07:20:08 UTC 2014 Modified Files: src/sys/rump/dev/lib/libugenhc: ugenhc.c Log Message: Let's believe the spec when it says must. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sys/rump/dev/lib/libugenhc/ugenhc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/rump/dev/lib/libugenhc/ugenhc.c diff -u src/sys/rump/dev/lib/libugenhc/ugenhc.c:1.19 src/sys/rump/dev/lib/libugenhc/ugenhc.c:1.20 --- src/sys/rump/dev/lib/libugenhc/ugenhc.c:1.19 Sat Aug 2 07:18:47 2014 +++ src/sys/rump/dev/lib/libugenhc/ugenhc.c Sat Aug 2 07:20:08 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: ugenhc.c,v 1.19 2014/08/02 07:18:47 skrll Exp $ */ +/* $NetBSD: ugenhc.c,v 1.20 2014/08/02 07:20:08 skrll Exp $ */ /* * Copyright (c) 2009, 2010 Antti Kantee. All Rights Reserved. @@ -61,7 +61,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: ugenhc.c,v 1.19 2014/08/02 07:18:47 skrll Exp $); +__KERNEL_RCSID(0, $NetBSD: ugenhc.c,v 1.20 2014/08/02 07:20:08 skrll Exp $); #include sys/param.h #include sys/bus.h @@ -152,7 +152,6 @@ static const usb_config_descriptor_t rum .bNumInterface = 1, .bmAttributes = UC_SELF_POWERED | UC_ATTR_MBO, }; -/* XXX: spec says UC_ATTR_MBO is reserved and set to one. required? */ static const usb_interface_descriptor_t rumphub_uid = { .bLength = USB_INTERFACE_DESCRIPTOR_SIZE,
CVS commit: src/sys/rump/dev/lib/libugenhc
Module Name:src Committed By: skrll Date: Sat Aug 2 11:43:21 UTC 2014 Modified Files: src/sys/rump/dev/lib/libugenhc: ugenhc.c Log Message: First pass at adapting to usbmp. To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/sys/rump/dev/lib/libugenhc/ugenhc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/rump/dev/lib/libugenhc/ugenhc.c diff -u src/sys/rump/dev/lib/libugenhc/ugenhc.c:1.20 src/sys/rump/dev/lib/libugenhc/ugenhc.c:1.21 --- src/sys/rump/dev/lib/libugenhc/ugenhc.c:1.20 Sat Aug 2 07:20:08 2014 +++ src/sys/rump/dev/lib/libugenhc/ugenhc.c Sat Aug 2 11:43:21 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: ugenhc.c,v 1.20 2014/08/02 07:20:08 skrll Exp $ */ +/* $NetBSD: ugenhc.c,v 1.21 2014/08/02 11:43:21 skrll Exp $ */ /* * Copyright (c) 2009, 2010 Antti Kantee. All Rights Reserved. @@ -61,7 +61,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: ugenhc.c,v 1.20 2014/08/02 07:20:08 skrll Exp $); +__KERNEL_RCSID(0, $NetBSD: ugenhc.c,v 1.21 2014/08/02 11:43:21 skrll Exp $); #include sys/param.h #include sys/bus.h @@ -71,6 +71,7 @@ __KERNEL_RCSID(0, $NetBSD: ugenhc.c,v 1 #include sys/kmem.h #include sys/kernel.h #include sys/kthread.h +#include sys/mutex.h #include dev/usb/usb.h #include dev/usb/usbdi.h @@ -103,6 +104,8 @@ struct ugenhc_softc { struct lwp *sc_rhintr; usbd_xfer_handle sc_intrxfer; + + kmutex_t sc_lock; }; static int ugenhc_probe(device_t, cfdata_t, void *); @@ -313,17 +316,22 @@ rumpusb_root_ctrl_start(usbd_xfer_handle ret: xfer-status = err; - /* XXX locking */ + mutex_enter(sc-sc_lock); usb_transfer_complete(xfer); + mutex_exit(sc-sc_lock); + return (USBD_IN_PROGRESS); } static usbd_status rumpusb_root_ctrl_transfer(usbd_xfer_handle xfer) { + struct ugenhc_softc *sc = xfer-pipe-device-bus-hci_private; usbd_status err; + mutex_enter(sc-sc_lock); err = usb_insert_transfer(xfer); + mutex_exit(sc-sc_lock); if (err) return (err); @@ -538,16 +546,22 @@ rumpusb_device_ctrl_start(usbd_xfer_hand ret: xfer-status = err; + mutex_enter(sc-sc_lock); usb_transfer_complete(xfer); + mutex_exit(sc-sc_lock); + return (USBD_IN_PROGRESS); } static usbd_status rumpusb_device_ctrl_transfer(usbd_xfer_handle xfer) { + struct ugenhc_softc *sc = xfer-pipe-device-bus-hci_private; usbd_status err; + mutex_enter(sc-sc_lock); err = usb_insert_transfer(xfer); + mutex_exit(sc-sc_lock); if (err) return (err); @@ -619,7 +633,9 @@ rhscintr(void *arg) xfer-actlen = xfer-length; xfer-status = USBD_NORMAL_COMPLETION; + mutex_enter(sc-sc_lock); usb_transfer_complete(xfer); + mutex_exit(sc-sc_lock); kpause(ugwait2, false, hz, NULL); @@ -647,7 +663,9 @@ rhscintr(void *arg) memset(xfer-buffer, 0xff, xfer-length); xfer-actlen = xfer-length; xfer-status = USBD_NORMAL_COMPLETION; + mutex_enter(sc-sc_lock); usb_transfer_complete(xfer); + mutex_exit(sc-sc_lock); kpause(ugwait3, false, hz, NULL); } @@ -661,6 +679,7 @@ rumpusb_root_intr_start(usbd_xfer_handle struct ugenhc_softc *sc = xfer-pipe-device-bus-hci_private; int error; + mutex_enter(sc-sc_lock); sc-sc_intrxfer = xfer; if (!sc-sc_rhintr) { error = kthread_create(PRI_NONE, 0, NULL, @@ -668,6 +687,7 @@ rumpusb_root_intr_start(usbd_xfer_handle if (error) xfer-status = USBD_IOERROR; } + mutex_exit(sc-sc_lock); return (USBD_IN_PROGRESS); } @@ -675,9 +695,12 @@ rumpusb_root_intr_start(usbd_xfer_handle static usbd_status rumpusb_root_intr_transfer(usbd_xfer_handle xfer) { + struct ugenhc_softc *sc = xfer-pipe-device-bus-hci_private; usbd_status err; + mutex_enter(sc-sc_lock); err = usb_insert_transfer(xfer); + mutex_exit(sc-sc_lock); if (err) return (err); @@ -815,24 +838,33 @@ rumpusb_device_bulk_start(usbd_xfer_hand if (done != len) panic(lazy bum); xfer-status = xfererr; + mutex_enter(sc-sc_lock); usb_transfer_complete(xfer); + mutex_exit(sc-sc_lock); return (USBD_IN_PROGRESS); } static void doxfer_kth(void *arg) { - usbd_xfer_handle xfer = arg; + usbd_pipe_handle pipe = arg; + struct ugenhc_softc *sc = pipe-device-bus-hci_private; + mutex_enter(sc-sc_lock); do { - rumpusb_device_bulk_start(SIMPLEQ_FIRST(xfer-pipe-queue)); - } while (!SIMPLEQ_EMPTY(xfer-pipe-queue)); + usbd_xfer_handle xfer = SIMPLEQ_FIRST(pipe-queue); + mutex_exit(sc-sc_lock); + rumpusb_device_bulk_start(xfer); + mutex_enter(sc-sc_lock); + } while (!SIMPLEQ_EMPTY(pipe-queue)); + mutex_exit(sc-sc_lock); kthread_exit(0); } static usbd_status rumpusb_device_bulk_transfer(usbd_xfer_handle xfer) { + struct ugenhc_softc *sc = xfer-pipe-device-bus-hci_private; usbd_status err; if (!rump_threads) { @@ -843,19 +875,21 @@ rumpusb_device_bulk_transfer(usbd_xfer_h return USBD_IN_PROGRESS; } + mutex_enter(sc-sc_lock); err = usb_insert_transfer(xfer); +
CVS commit: src/sys/rump/dev/lib/libugenhc
Module Name:src Committed By: skrll Date: Sat Aug 2 12:38:01 UTC 2014 Modified Files: src/sys/rump/dev/lib/libugenhc: ugenhc.c Log Message: Fix error checking mistake introduced in r1.15. Hi Antti! To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/sys/rump/dev/lib/libugenhc/ugenhc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/rump/dev/lib/libugenhc/ugenhc.c diff -u src/sys/rump/dev/lib/libugenhc/ugenhc.c:1.21 src/sys/rump/dev/lib/libugenhc/ugenhc.c:1.22 --- src/sys/rump/dev/lib/libugenhc/ugenhc.c:1.21 Sat Aug 2 11:43:21 2014 +++ src/sys/rump/dev/lib/libugenhc/ugenhc.c Sat Aug 2 12:38:01 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: ugenhc.c,v 1.21 2014/08/02 11:43:21 skrll Exp $ */ +/* $NetBSD: ugenhc.c,v 1.22 2014/08/02 12:38:01 skrll Exp $ */ /* * Copyright (c) 2009, 2010 Antti Kantee. All Rights Reserved. @@ -61,7 +61,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: ugenhc.c,v 1.21 2014/08/02 11:43:21 skrll Exp $); +__KERNEL_RCSID(0, $NetBSD: ugenhc.c,v 1.22 2014/08/02 12:38:01 skrll Exp $); #include sys/param.h #include sys/bus.h @@ -618,7 +618,7 @@ rhscintr(void *arg) for (;;) { error = rumpuser_open(buf, RUMPUSER_OPEN_RDWR, fd); - if (error != 0) + if (error == 0) break; kpause(ugwait, false, hz/4, NULL); }
CVS commit: src/sys/rump/dev/lib/libugenhc
Module Name:src Committed By: pooka Date: Thu Mar 13 01:38:11 UTC 2014 Modified Files: src/sys/rump/dev/lib/libugenhc: Makefile ugenhc.c Added Files: src/sys/rump/dev/lib/libugenhc: ugenhc_user.c ugenhc_user.h Removed Files: src/sys/rump/dev/lib/libugenhc: rumpcomp_user.c rumpcomp_user.h Log Message: rename rumpcomp_user.* - ugenhc_user.* To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/rump/dev/lib/libugenhc/Makefile cvs rdiff -u -r1.6 -r0 src/sys/rump/dev/lib/libugenhc/rumpcomp_user.c cvs rdiff -u -r1.1 -r0 src/sys/rump/dev/lib/libugenhc/rumpcomp_user.h cvs rdiff -u -r1.16 -r1.17 src/sys/rump/dev/lib/libugenhc/ugenhc.c cvs rdiff -u -r0 -r1.1 src/sys/rump/dev/lib/libugenhc/ugenhc_user.c \ src/sys/rump/dev/lib/libugenhc/ugenhc_user.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/rump/dev/lib/libugenhc/Makefile diff -u src/sys/rump/dev/lib/libugenhc/Makefile:1.7 src/sys/rump/dev/lib/libugenhc/Makefile:1.8 --- src/sys/rump/dev/lib/libugenhc/Makefile:1.7 Thu Sep 19 17:55:22 2013 +++ src/sys/rump/dev/lib/libugenhc/Makefile Thu Mar 13 01:38:11 2014 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.7 2013/09/19 17:55:22 pooka Exp $ +# $NetBSD: Makefile,v 1.8 2014/03/13 01:38:11 pooka Exp $ # LIB= rumpdev_ugenhc @@ -8,7 +8,7 @@ SRCS= ugenhc.c ugenhc_at_mainbus.c ugenh CPPFLAGS+= -I${RUMPTOP}/librump/rumpkern -RUMPCOMP_USER= #ioctl +RUMPCOMP_USER_SRCS= ugenhc_user.c .include bsd.lib.mk .include bsd.klinks.mk Index: src/sys/rump/dev/lib/libugenhc/ugenhc.c diff -u src/sys/rump/dev/lib/libugenhc/ugenhc.c:1.16 src/sys/rump/dev/lib/libugenhc/ugenhc.c:1.17 --- src/sys/rump/dev/lib/libugenhc/ugenhc.c:1.16 Fri Sep 13 20:38:39 2013 +++ src/sys/rump/dev/lib/libugenhc/ugenhc.c Thu Mar 13 01:38:11 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: ugenhc.c,v 1.16 2013/09/13 20:38:39 joerg Exp $ */ +/* $NetBSD: ugenhc.c,v 1.17 2014/03/13 01:38:11 pooka Exp $ */ /* * Copyright (c) 2009, 2010 Antti Kantee. All Rights Reserved. @@ -61,7 +61,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: ugenhc.c,v 1.16 2013/09/13 20:38:39 joerg Exp $); +__KERNEL_RCSID(0, $NetBSD: ugenhc.c,v 1.17 2014/03/13 01:38:11 pooka Exp $); #include sys/param.h #include sys/bus.h @@ -81,7 +81,7 @@ __KERNEL_RCSID(0, $NetBSD: ugenhc.c,v 1 #include rump/rumpuser.h -#include rumpcomp_user.h +#include ugenhc_user.h #include rump_private.h #include rump_dev_private.h Added files: Index: src/sys/rump/dev/lib/libugenhc/ugenhc_user.c diff -u /dev/null src/sys/rump/dev/lib/libugenhc/ugenhc_user.c:1.1 --- /dev/null Thu Mar 13 01:38:11 2014 +++ src/sys/rump/dev/lib/libugenhc/ugenhc_user.c Thu Mar 13 01:38:11 2014 @@ -0,0 +1,54 @@ +/* $NetBSD: ugenhc_user.c,v 1.1 2014/03/13 01:38:11 pooka Exp $ */ + +/* + * Copyright (c) 2007-2010 Antti Kantee. All Rights Reserved. + * + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. + */ +#ifndef _KERNEL +#include sys/types.h +#include sys/ioctl.h + +#include errno.h +#include unistd.h + +#include rump/rumpuser_component.h + +#include ugenhc_user.h + +int +rumpcomp_ugenhc_ioctl(int fd, u_long cmd, void *data, int *ioctlrv) +{ + void *cookie; + int rv; + + cookie = rumpuser_component_unschedule(); + *ioctlrv = ioctl(fd, cmd, data); + if (*ioctlrv == -1) + rv = errno; + else + rv = 0; + rumpuser_component_schedule(cookie); + + return rumpuser_component_errtrans(rv); +} +#endif Index: src/sys/rump/dev/lib/libugenhc/ugenhc_user.h diff -u /dev/null src/sys/rump/dev/lib/libugenhc/ugenhc_user.h:1.1 --- /dev/null Thu Mar 13 01:38:11 2014 +++ src/sys/rump/dev/lib/libugenhc/ugenhc_user.h Thu Mar 13 01:38:11 2014 @@ -0,0 +1,28 @@ +/* $NetBSD:
CVS commit: src/sys/rump/dev/lib/libugenhc
Module Name:src Committed By: joerg Date: Fri Sep 13 20:38:39 UTC 2013 Modified Files: src/sys/rump/dev/lib/libugenhc: ugenhc.c Log Message: GC rumpusb_device_intr_methods. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/rump/dev/lib/libugenhc/ugenhc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/rump/dev/lib/libugenhc/ugenhc.c diff -u src/sys/rump/dev/lib/libugenhc/ugenhc.c:1.15 src/sys/rump/dev/lib/libugenhc/ugenhc.c:1.16 --- src/sys/rump/dev/lib/libugenhc/ugenhc.c:1.15 Tue Apr 30 00:03:52 2013 +++ src/sys/rump/dev/lib/libugenhc/ugenhc.c Fri Sep 13 20:38:39 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: ugenhc.c,v 1.15 2013/04/30 00:03:52 pooka Exp $ */ +/* $NetBSD: ugenhc.c,v 1.16 2013/09/13 20:38:39 joerg Exp $ */ /* * Copyright (c) 2009, 2010 Antti Kantee. All Rights Reserved. @@ -61,7 +61,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: ugenhc.c,v 1.15 2013/04/30 00:03:52 pooka Exp $); +__KERNEL_RCSID(0, $NetBSD: ugenhc.c,v 1.16 2013/09/13 20:38:39 joerg Exp $); #include sys/param.h #include sys/bus.h @@ -913,15 +913,6 @@ static const struct usbd_pipe_methods ru .done = rumpusb_device_bulk_done, }; -static const struct usbd_pipe_methods rumpusb_device_intr_methods = { - .transfer = rumpusb_root_intr_transfer, - .start = rumpusb_root_intr_start, - .abort = rumpusb_root_intr_abort, - .close = rumpusb_root_intr_close, - .cleartoggle = rumpusb_root_intr_cleartoggle, - .done = rumpusb_root_intr_done, -}; - static usbd_status ugenhc_open(struct usbd_pipe *pipe) {
CVS commit: src/sys/rump/dev/lib/libugenhc
Module Name:src Committed By: pooka Date: Thu Jul 4 10:09:55 UTC 2013 Modified Files: src/sys/rump/dev/lib/libugenhc: rumpcomp_user.c Log Message: Some systems provide ioctl() via unistd.h (not that this is going to work there, but at least we don't get unnecessary compiler warnings) To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/rump/dev/lib/libugenhc/rumpcomp_user.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/rump/dev/lib/libugenhc/rumpcomp_user.c diff -u src/sys/rump/dev/lib/libugenhc/rumpcomp_user.c:1.5 src/sys/rump/dev/lib/libugenhc/rumpcomp_user.c:1.6 --- src/sys/rump/dev/lib/libugenhc/rumpcomp_user.c:1.5 Tue Apr 30 12:39:21 2013 +++ src/sys/rump/dev/lib/libugenhc/rumpcomp_user.c Thu Jul 4 10:09:55 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: rumpcomp_user.c,v 1.5 2013/04/30 12:39:21 pooka Exp $ */ +/* $NetBSD: rumpcomp_user.c,v 1.6 2013/07/04 10:09:55 pooka Exp $ */ /* * Copyright (c) 2007-2010 Antti Kantee. All Rights Reserved. @@ -29,6 +29,7 @@ #include sys/ioctl.h #include errno.h +#include unistd.h #include rump/rumpuser_component.h
CVS commit: src/sys/rump/dev/lib/libugenhc
Module Name:src Committed By: christos Date: Mon Apr 29 18:06:59 UTC 2013 Modified Files: src/sys/rump/dev/lib/libugenhc: rumpcomp_user.c Log Message: don't compile the for kernel To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/rump/dev/lib/libugenhc/rumpcomp_user.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/rump/dev/lib/libugenhc/rumpcomp_user.c diff -u src/sys/rump/dev/lib/libugenhc/rumpcomp_user.c:1.2 src/sys/rump/dev/lib/libugenhc/rumpcomp_user.c:1.3 --- src/sys/rump/dev/lib/libugenhc/rumpcomp_user.c:1.2 Sun Apr 28 06:23:36 2013 +++ src/sys/rump/dev/lib/libugenhc/rumpcomp_user.c Mon Apr 29 14:06:59 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: rumpcomp_user.c,v 1.2 2013/04/28 10:23:36 pooka Exp $ */ +/* $NetBSD: rumpcomp_user.c,v 1.3 2013/04/29 18:06:59 christos Exp $ */ /* * Copyright (c) 2007-2010 Antti Kantee. All Rights Reserved. @@ -24,7 +24,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - +#ifndef _KERNEL #include sys/types.h #include sys/ioctl.h @@ -50,3 +50,4 @@ rumpcomp_ugenhc_ioctl(int fd, u_long cmd return rv; } +#endif
CVS commit: src/sys/rump/dev/lib/libugenhc
Module Name:src Committed By: pooka Date: Sun Apr 28 10:06:16 UTC 2013 Modified Files: src/sys/rump/dev/lib/libugenhc: Makefile Log Message: typo To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/rump/dev/lib/libugenhc/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/rump/dev/lib/libugenhc/Makefile diff -u src/sys/rump/dev/lib/libugenhc/Makefile:1.3 src/sys/rump/dev/lib/libugenhc/Makefile:1.4 --- src/sys/rump/dev/lib/libugenhc/Makefile:1.3 Sun Apr 28 09:58:11 2013 +++ src/sys/rump/dev/lib/libugenhc/Makefile Sun Apr 28 10:06:16 2013 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.3 2013/04/28 09:58:11 pooka Exp $ +# $NetBSD: Makefile,v 1.4 2013/04/28 10:06:16 pooka Exp $ # LIB= rumpdev_ugenhc @@ -8,7 +8,7 @@ SRCS= ugenhc.c ugenhc_at_mainbus.c CPPFLAGS+= -I${RUMPTOP}/librump/rumpkern -RUMPUSER_COMP= ioctl +RUMPCOMP_USER= ioctl .include bsd.lib.mk .include bsd.klinks.mk
CVS commit: src/sys/rump/dev/lib/libugenhc
Module Name:src Committed By: pooka Date: Sun Apr 28 10:16:52 UTC 2013 Modified Files: src/sys/rump/dev/lib/libugenhc: Makefile Log Message: duh, the untypoed version doesn't work with bsd.ioconf.mk. comment it out while i figure it out To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/rump/dev/lib/libugenhc/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/rump/dev/lib/libugenhc/Makefile diff -u src/sys/rump/dev/lib/libugenhc/Makefile:1.4 src/sys/rump/dev/lib/libugenhc/Makefile:1.5 --- src/sys/rump/dev/lib/libugenhc/Makefile:1.4 Sun Apr 28 10:06:16 2013 +++ src/sys/rump/dev/lib/libugenhc/Makefile Sun Apr 28 10:16:52 2013 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.4 2013/04/28 10:06:16 pooka Exp $ +# $NetBSD: Makefile,v 1.5 2013/04/28 10:16:52 pooka Exp $ # LIB= rumpdev_ugenhc @@ -8,7 +8,7 @@ SRCS= ugenhc.c ugenhc_at_mainbus.c CPPFLAGS+= -I${RUMPTOP}/librump/rumpkern -RUMPCOMP_USER= ioctl +#RUMPCOMP_USER= #ioctl .include bsd.lib.mk .include bsd.klinks.mk
CVS commit: src/sys/rump/dev/lib/libugenhc
Module Name:src Committed By: pooka Date: Sun Apr 28 10:23:36 UTC 2013 Modified Files: src/sys/rump/dev/lib/libugenhc: rumpcomp_user.c Log Message: need errno To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/rump/dev/lib/libugenhc/rumpcomp_user.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/rump/dev/lib/libugenhc/rumpcomp_user.c diff -u src/sys/rump/dev/lib/libugenhc/rumpcomp_user.c:1.1 src/sys/rump/dev/lib/libugenhc/rumpcomp_user.c:1.2 --- src/sys/rump/dev/lib/libugenhc/rumpcomp_user.c:1.1 Sun Apr 28 09:58:11 2013 +++ src/sys/rump/dev/lib/libugenhc/rumpcomp_user.c Sun Apr 28 10:23:36 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: rumpcomp_user.c,v 1.1 2013/04/28 09:58:11 pooka Exp $ */ +/* $NetBSD: rumpcomp_user.c,v 1.2 2013/04/28 10:23:36 pooka Exp $ */ /* * Copyright (c) 2007-2010 Antti Kantee. All Rights Reserved. @@ -28,6 +28,8 @@ #include sys/types.h #include sys/ioctl.h +#include errno.h + #include rump/rumpuser_component.h #include rumpcomp_user.h
CVS commit: src/sys/rump/dev/lib/libugenhc
Module Name:src Committed By: pooka Date: Sun Apr 28 10:25:41 UTC 2013 Modified Files: src/sys/rump/dev/lib/libugenhc: Makefile Log Message: problem with ioconf.c solved, reenable To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/rump/dev/lib/libugenhc/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/rump/dev/lib/libugenhc/Makefile diff -u src/sys/rump/dev/lib/libugenhc/Makefile:1.5 src/sys/rump/dev/lib/libugenhc/Makefile:1.6 --- src/sys/rump/dev/lib/libugenhc/Makefile:1.5 Sun Apr 28 10:16:52 2013 +++ src/sys/rump/dev/lib/libugenhc/Makefile Sun Apr 28 10:25:41 2013 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.5 2013/04/28 10:16:52 pooka Exp $ +# $NetBSD: Makefile,v 1.6 2013/04/28 10:25:41 pooka Exp $ # LIB= rumpdev_ugenhc @@ -8,7 +8,7 @@ SRCS= ugenhc.c ugenhc_at_mainbus.c CPPFLAGS+= -I${RUMPTOP}/librump/rumpkern -#RUMPCOMP_USER= #ioctl +RUMPCOMP_USER= #ioctl .include bsd.lib.mk .include bsd.klinks.mk
CVS commit: src/sys/rump/dev/lib/libugenhc
Module Name:src Committed By: pooka Date: Mon Mar 22 12:05:45 UTC 2010 Modified Files: src/sys/rump/dev/lib/libugenhc: ugenhc.c Log Message: * support isochronous transfers (for as much as they can be supported considering our ugen driver doesn't support isochronous write. kern/25960 seems to contain a patch and could be investigated for that) * add a dirty rotten hack which makes interrupt transfers of 16 work for me To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/rump/dev/lib/libugenhc/ugenhc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/rump/dev/lib/libugenhc/ugenhc.c diff -u src/sys/rump/dev/lib/libugenhc/ugenhc.c:1.8 src/sys/rump/dev/lib/libugenhc/ugenhc.c:1.9 --- src/sys/rump/dev/lib/libugenhc/ugenhc.c:1.8 Tue Feb 23 14:05:04 2010 +++ src/sys/rump/dev/lib/libugenhc/ugenhc.c Mon Mar 22 12:05:45 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: ugenhc.c,v 1.8 2010/02/23 14:05:04 pooka Exp $ */ +/* $NetBSD: ugenhc.c,v 1.9 2010/03/22 12:05:45 pooka Exp $ */ /* * Copyright (c) 2009, 2010 Antti Kantee. All Rights Reserved. @@ -61,7 +61,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: ugenhc.c,v 1.8 2010/02/23 14:05:04 pooka Exp $); +__KERNEL_RCSID(0, $NetBSD: ugenhc.c,v 1.9 2010/03/22 12:05:45 pooka Exp $); #include sys/param.h #include sys/bus.h @@ -506,6 +506,7 @@ case C(0x22, UT_WRITE_CLASS_INTERFACE): case C(0x0a, UT_WRITE_CLASS_INTERFACE): case C(UR_SET_FEATURE, UT_WRITE_CLASS_OTHER): + case C(0x00, UT_WRITE_CLASS_DEVICE): case C(UR_SET_FEATURE, UT_WRITE_DEVICE): case C(UR_CLEAR_FEATURE, UT_WRITE_CLASS_OTHER): case C(UR_SET_REPORT, UT_WRITE_CLASS_INTERFACE): @@ -718,40 +719,46 @@ rumpusb_device_bulk_start(usbd_xfer_handle xfer) { struct ugenhc_softc *sc = xfer-pipe-device-bus-hci_private; + usb_endpoint_descriptor_t *ed = xfer-pipe-endpoint-edesc; ssize_t n; ssize_t done; bool isread; int len, error, endpt; uint8_t *buf; int xfererr = USBD_NORMAL_COMPLETION; - int val; + int shortval, i; - endpt = xfer-pipe-endpoint-edesc-bEndpointAddress; + ed = xfer-pipe-endpoint-edesc; + endpt = ed-bEndpointAddress; isread = UE_GET_DIR(endpt) == UE_DIR_IN; endpt = UE_GET_ADDR(endpt); KASSERT(endpt UGEN_NEPTS); - KASSERT(xfer-length); - len = xfer-length; buf = KERNADDR(xfer-dmabuf, 0); done = 0; + if ((ed-bmAttributes UE_XFERTYPE) == UE_ISOCHRONOUS) { + for (i = 0, len = 0; i xfer-nframes; i++) + len += xfer-frlengths[i]; + } else { + KASSERT(xfer-length); + len = xfer-length; + } + shortval = (xfer-flags USBD_SHORT_XFER_OK) != 0; while (RUSB(xfer)-rusb_status == 0) { if (isread) { - if (xfer-flags USBD_SHORT_XFER_OK) -val = 1; - else -val = 0; rumpuser_ioctl(sc-sc_ugenfd[endpt], - USB_SET_SHORT_XFER, val, error); + USB_SET_SHORT_XFER, shortval, error); n = rumpuser_read(sc-sc_ugenfd[endpt], buf+done, len-done, error); if (n == -1) { -if (error == ETIMEDOUT) - continue; n = 0; -xfererr = USBD_IOERROR; -goto out; +if (done == 0) { + if (error == ETIMEDOUT) + continue; + xfererr = USBD_IOERROR; + goto out; +} } done += n; if (done == len) @@ -769,8 +776,23 @@ goto out; } - if (xfer-flags USBD_SHORT_XFER_OK) - break; + if (shortval) { + /* + * Holy XXX, bitman. I get 16byte interrupt + * transfers from ugen in 16 byte chunks. + * Don't know how to better fix this for now. + * Of course this hack will fail e.g. if someone + * sports other magic values or if the transfer + * happens to be an integral multiple of 16 + * in size + */ + if ((ed-bmAttributes UE_XFERTYPE) == UE_INTERRUPT + n == 16) { +continue; + } else { +break; + } + } } if (RUSB(xfer)-rusb_status == 0) { @@ -780,6 +802,9 @@ RUSB(xfer)-rusb_status = 2; } out: + if ((ed-bmAttributes UE_XFERTYPE) == UE_ISOCHRONOUS) + if (done != len) + panic(lazy bum); xfer-status = xfererr; usb_transfer_complete(xfer); return (USBD_IN_PROGRESS); @@ -918,6 +943,7 @@ break; case UE_INTERRUPT: case UE_BULK: + case UE_ISOCHRONOUS: pipe-methods = rumpusb_device_bulk_methods; endpt = pipe-endpoint-edesc-bEndpointAddress; if (UE_GET_DIR(endpt) == UE_DIR_IN) { @@ -927,6 +953,11 @@ } endpt = UE_GET_ADDR(endpt); + if (oflags != O_RDONLY xfertype == UE_ISOCHRONOUS) { +printf(WARNING: faking isoc write open\n); +oflags = O_RDONLY; + } + if (sc-sc_fdmodes[endpt] == oflags || sc-sc_fdmodes[endpt] == O_RDWR) break; @@ -939,14 +970,16 @@ makeugendevstr(sc-sc_devnum, endpt, buf); fd = rumpuser_open(buf, oflags, error); - if (fd == -1) + if (fd == -1) { return USBD_INVAL; /* XXX: no mapping */ + } val = 100; if (rumpuser_ioctl(fd, USB_SET_TIMEOUT, val, error) == -1) panic(timeout
CVS commit: src/sys/rump/dev/lib/libugenhc
Module Name:src Committed By: pooka Date: Tue Feb 23 14:05:04 UTC 2010 Modified Files: src/sys/rump/dev/lib/libugenhc: ugenhc.c Log Message: * abort correct endpoint in bulk xfers * actually free memory in the freem method (well, usually stick it to the usb freelist, but same thing) To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/rump/dev/lib/libugenhc/ugenhc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/rump/dev/lib/libugenhc/ugenhc.c diff -u src/sys/rump/dev/lib/libugenhc/ugenhc.c:1.7 src/sys/rump/dev/lib/libugenhc/ugenhc.c:1.8 --- src/sys/rump/dev/lib/libugenhc/ugenhc.c:1.7 Mon Feb 22 14:47:40 2010 +++ src/sys/rump/dev/lib/libugenhc/ugenhc.c Tue Feb 23 14:05:04 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: ugenhc.c,v 1.7 2010/02/22 14:47:40 pooka Exp $ */ +/* $NetBSD: ugenhc.c,v 1.8 2010/02/23 14:05:04 pooka Exp $ */ /* * Copyright (c) 2009, 2010 Antti Kantee. All Rights Reserved. @@ -61,7 +61,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: ugenhc.c,v 1.7 2010/02/22 14:47:40 pooka Exp $); +__KERNEL_RCSID(0, $NetBSD: ugenhc.c,v 1.8 2010/02/23 14:05:04 pooka Exp $); #include sys/param.h #include sys/bus.h @@ -136,6 +136,8 @@ .bDeviceSubClass = UDSUBCLASS_HUB, .bDeviceProtocol = UDPROTO_FSHUB, .bMaxPacketSize = 64, + .idVendor = { 0x75, 0x72 }, + .idProduct = { 0x70, 0x6d }, .bNumConfigurations = 1, }; @@ -845,6 +847,8 @@ usbd_xfer_handle xfer; int error; + endpt = UE_GET_ADDR(endpt); + while ((xfer = SIMPLEQ_FIRST(pipe-queue)) != NULL) rumpusb_device_bulk_abort(xfer); @@ -974,9 +978,11 @@ } static void -ugenhc_freem(struct usbd_bus *ubus, usb_dma_t *udma) +ugenhc_freem(struct usbd_bus *bus, usb_dma_t *dma) { + struct ugenhc_softc *sc = bus-hci_private; + usb_freemem(sc-sc_bus, dma); } static struct usbd_xfer *
CVS commit: src/sys/rump/dev/lib/libugenhc
Module Name:src Committed By: pooka Date: Sat Feb 20 13:56:29 UTC 2010 Modified Files: src/sys/rump/dev/lib/libugenhc: ugenhc.c Log Message: Fix snafu with error reporting in bulk transfers. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/rump/dev/lib/libugenhc/ugenhc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/rump/dev/lib/libugenhc/ugenhc.c diff -u src/sys/rump/dev/lib/libugenhc/ugenhc.c:1.5 src/sys/rump/dev/lib/libugenhc/ugenhc.c:1.6 --- src/sys/rump/dev/lib/libugenhc/ugenhc.c:1.5 Thu Feb 18 16:24:19 2010 +++ src/sys/rump/dev/lib/libugenhc/ugenhc.c Sat Feb 20 13:56:29 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: ugenhc.c,v 1.5 2010/02/18 16:24:19 pooka Exp $ */ +/* $NetBSD: ugenhc.c,v 1.6 2010/02/20 13:56:29 pooka Exp $ */ /* * Copyright (c) 2009 Antti Kantee. All Rights Reserved. @@ -61,7 +61,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: ugenhc.c,v 1.5 2010/02/18 16:24:19 pooka Exp $); +__KERNEL_RCSID(0, $NetBSD: ugenhc.c,v 1.6 2010/02/20 13:56:29 pooka Exp $); #include sys/param.h #include sys/bus.h @@ -707,7 +707,7 @@ bool isread; int len, error, endpt; uint8_t *buf; - int xfererr = 0; + int xfererr = USBD_NORMAL_COMPLETION; int val; endpt = xfer-pipe-endpoint-edesc-bEndpointAddress; @@ -734,7 +734,7 @@ if (error == ETIMEDOUT) continue; n = 0; -xfer-status = USBD_IOERROR; +xfererr = USBD_IOERROR; goto out; } done += n; @@ -746,8 +746,11 @@ done = n; if (done == len) break; - else + else if (n != -1) panic(short write); + + xfererr = USBD_IOERROR; + goto out; } if (xfer-flags USBD_SHORT_XFER_OK) @@ -756,21 +759,12 @@ if (RUSB(xfer)-rusb_status == 0) { xfer-actlen = done; - xfer-status = USBD_NORMAL_COMPLETION; - /* override */ - if (xfererr) { - printf(err!\n); - xfer-status = xfererr; - } } else { - xfer-status = USBD_CANCELLED; + xfererr = USBD_CANCELLED; RUSB(xfer)-rusb_status = 2; } out: - val = 0; - error = 0; - rumpuser_ioctl(sc-sc_ugenfd[endpt], USB_SET_SHORT_XFER, val, error); - xfer-status = error; + xfer-status = xfererr; usb_transfer_complete(xfer); return (USBD_IN_PROGRESS); }
CVS commit: src/sys/rump/dev/lib/libugenhc
Module Name:src Committed By: pooka Date: Thu Feb 18 15:25:13 UTC 2010 Modified Files: src/sys/rump/dev/lib/libugenhc: ugenhc.c Log Message: Change match to be based on the existence of the ugen device node and signal the root hub interrupt only once we are succesfully able to open the device node. This makes it possible to insert a device after the rump kernel was booted and have it succesfully attach (does not make detach possible yet, though, as there are some ugen and host kernel uhci/ohci/ehci evil crashies with that). XXX: optimally, match would fail if there is a permanent error in opening. However, it is difficult to figure out the difference between the device backing ugen not being present, a transient error in opening and a permanent error in opening. For example, which of the latter two would EPERM be? And, ugen returns ENXIO if the device is not present, but how would be know that's really the case and not some other ENXIO from elsewhere in the stack? To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/rump/dev/lib/libugenhc/ugenhc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/rump/dev/lib/libugenhc/ugenhc.c diff -u src/sys/rump/dev/lib/libugenhc/ugenhc.c:1.2 src/sys/rump/dev/lib/libugenhc/ugenhc.c:1.3 --- src/sys/rump/dev/lib/libugenhc/ugenhc.c:1.2 Wed Feb 17 20:39:53 2010 +++ src/sys/rump/dev/lib/libugenhc/ugenhc.c Thu Feb 18 15:25:13 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: ugenhc.c,v 1.2 2010/02/17 20:39:53 pooka Exp $ */ +/* $NetBSD: ugenhc.c,v 1.3 2010/02/18 15:25:13 pooka Exp $ */ /* * Copyright (c) 2009 Antti Kantee. All Rights Reserved. @@ -61,7 +61,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: ugenhc.c,v 1.2 2010/02/17 20:39:53 pooka Exp $); +__KERNEL_RCSID(0, $NetBSD: ugenhc.c,v 1.3 2010/02/18 15:25:13 pooka Exp $); #include sys/param.h #include sys/bus.h @@ -98,6 +98,9 @@ int sc_port_change; int sc_addr; int sc_conf; + + struct lwp *sc_rhintr; + usbd_xfer_handle sc_intrxfer; }; static int ugenhc_probe(struct device *, struct cfdata *, void *); @@ -382,8 +385,10 @@ totlen = min(len, USB_DEVICE_DESCRIPTOR_SIZE); memset(buf, 0, totlen); if (rumpuser_ioctl(sc-sc_ugenfd[UGEN_EPT_CTRL], - USB_GET_DEVICE_DESC, uddesc, ru_error) == -1) -panic(%d, ru_error); + USB_GET_DEVICE_DESC, uddesc, ru_error) == -1) { +err = EIO; +goto ret; + } memcpy(buf, uddesc, totlen); } @@ -570,39 +575,49 @@ .done = rumpusb_device_ctrl_done, }; -struct intrent { - usbd_xfer_handle xfer; - LIST_ENTRY(intrent) entries; -}; - -static LIST_HEAD(, intrent) intrlist = LIST_HEAD_INITIALIZER(intrlist); - static void -rhscintr(void) +rhscintr(void *arg) { - struct intrent *ie, *ie_next; + char buf[UGENDEV_BUFSIZE]; + struct ugenhc_softc *sc = arg; usbd_xfer_handle xfer; + int fd, error; - for (ie = LIST_FIRST(intrlist); ie; ie = ie_next) { - xfer = ie-xfer; - xfer-actlen = xfer-length; - xfer-status = USBD_NORMAL_COMPLETION; - usb_transfer_complete(xfer); - - ie_next = LIST_NEXT(ie, entries); - LIST_REMOVE(ie, entries); - kmem_free(ie, sizeof(*ie)); + makeugendevstr(sc-sc_devnum, 0, buf); + for (;;) { + fd = rumpuser_open(buf, O_RDWR, error); + if (fd != -1) + break; + kpause(ugwait, false, hz/4, NULL); } + + sc-sc_ugenfd[UGEN_EPT_CTRL] = fd; + + sc-sc_port_status = UPS_CURRENT_CONNECT_STATUS + | UPS_PORT_ENABLED | UPS_PORT_POWER; + sc-sc_port_change = UPS_C_CONNECT_STATUS; + + xfer = sc-sc_intrxfer;; + xfer-actlen = 0; + xfer-status = USBD_NORMAL_COMPLETION; + usb_transfer_complete(xfer); + + kthread_exit(0); } static usbd_status rumpusb_root_intr_start(usbd_xfer_handle xfer) { - struct intrent *ie; + struct ugenhc_softc *sc = xfer-pipe-device-bus-hci_private; + int error; - ie = kmem_alloc(sizeof(*ie), KM_SLEEP); - ie-xfer = xfer; - LIST_INSERT_HEAD(intrlist, ie, entries); + sc-sc_intrxfer = xfer; + if (!sc-sc_rhintr) { + error = kthread_create(PRI_NONE, 0, NULL, + rhscintr, sc, sc-sc_rhintr, ugenrhi); + if (error) + xfer-status = error; + } return (USBD_IN_PROGRESS); } @@ -831,10 +846,6 @@ int endpt, oflags, error; int fd, val; - sc-sc_port_status = UPS_CURRENT_CONNECT_STATUS - | UPS_PORT_ENABLED | UPS_PORT_POWER; - sc-sc_port_change = UPS_C_CONNECT_STATUS; - if (addr == sc-sc_addr) { switch (xfertype) { case UE_CONTROL: @@ -955,14 +966,14 @@ ugenhc_probe(struct device *parent, struct cfdata *match, void *aux) { char buf[UGENDEV_BUFSIZE]; - int fd, error; + int error; makeugendevstr(match-cf_unit, 0, buf); - fd = rumpuser_open(buf, O_RDWR, error); - if (fd == -1) + if (rumpuser_getfileinfo(buf, NULL, NULL, error) == -1) { + printf(match error %d\n, error); return 0; + } - rumpuser_close(fd, error); return 1; } @@ -971,8 +982,6 @@ { struct mainbus_attach_args *maa = aux; struct ugenhc_softc *sc =
CVS commit: src/sys/rump/dev/lib/libugenhc
Module Name:src Committed By: pooka Date: Thu Feb 18 16:13:30 UTC 2010 Modified Files: src/sys/rump/dev/lib/libugenhc: ugenhc.c Log Message: Actually, detach is possible enough if the device isn't in use. So just support it. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/rump/dev/lib/libugenhc/ugenhc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/rump/dev/lib/libugenhc/ugenhc.c diff -u src/sys/rump/dev/lib/libugenhc/ugenhc.c:1.3 src/sys/rump/dev/lib/libugenhc/ugenhc.c:1.4 --- src/sys/rump/dev/lib/libugenhc/ugenhc.c:1.3 Thu Feb 18 15:25:13 2010 +++ src/sys/rump/dev/lib/libugenhc/ugenhc.c Thu Feb 18 16:13:30 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: ugenhc.c,v 1.3 2010/02/18 15:25:13 pooka Exp $ */ +/* $NetBSD: ugenhc.c,v 1.4 2010/02/18 16:13:30 pooka Exp $ */ /* * Copyright (c) 2009 Antti Kantee. All Rights Reserved. @@ -61,7 +61,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: ugenhc.c,v 1.3 2010/02/18 15:25:13 pooka Exp $); +__KERNEL_RCSID(0, $NetBSD: ugenhc.c,v 1.4 2010/02/18 16:13:30 pooka Exp $); #include sys/param.h #include sys/bus.h @@ -584,23 +584,52 @@ int fd, error; makeugendevstr(sc-sc_devnum, 0, buf); + for (;;) { - fd = rumpuser_open(buf, O_RDWR, error); - if (fd != -1) - break; - kpause(ugwait, false, hz/4, NULL); - } + /* + * Detect device attach. + */ + + for (;;) { + fd = rumpuser_open(buf, O_RDWR, error); + if (fd != -1) +break; + kpause(ugwait, false, hz/4, NULL); + } - sc-sc_ugenfd[UGEN_EPT_CTRL] = fd; + sc-sc_ugenfd[UGEN_EPT_CTRL] = fd; + sc-sc_port_status = UPS_CURRENT_CONNECT_STATUS + | UPS_PORT_ENABLED | UPS_PORT_POWER; + sc-sc_port_change = UPS_C_CONNECT_STATUS; - sc-sc_port_status = UPS_CURRENT_CONNECT_STATUS - | UPS_PORT_ENABLED | UPS_PORT_POWER; - sc-sc_port_change = UPS_C_CONNECT_STATUS; - - xfer = sc-sc_intrxfer;; - xfer-actlen = 0; - xfer-status = USBD_NORMAL_COMPLETION; - usb_transfer_complete(xfer); + xfer = sc-sc_intrxfer; + xfer-actlen = 0; + xfer-status = USBD_NORMAL_COMPLETION; + usb_transfer_complete(xfer); + + /* + * Detect device detach. + */ + + for (;;) { + fd = rumpuser_open(buf, O_RDWR, error); + if (fd == -1) +break; + + rumpuser_close(fd, error); + kpause(ugwait2, false, hz/4, NULL); + } + + sc-sc_port_status = ~(UPS_CURRENT_CONNECT_STATUS + | UPS_PORT_ENABLED | UPS_PORT_POWER); + sc-sc_port_change = UPS_C_CONNECT_STATUS; + sc-sc_ugenfd[UGEN_EPT_CTRL] = -1; + + xfer = sc-sc_intrxfer; + xfer-actlen = 0; + xfer-status = USBD_NORMAL_COMPLETION; + usb_transfer_complete(xfer); + } kthread_exit(0); }
CVS commit: src/sys/rump/dev/lib/libugenhc
Module Name:src Committed By: pooka Date: Thu Feb 18 16:24:19 UTC 2010 Modified Files: src/sys/rump/dev/lib/libugenhc: ugenhc.c Log Message: Don't leak control endpoint descriptors. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/rump/dev/lib/libugenhc/ugenhc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/rump/dev/lib/libugenhc/ugenhc.c diff -u src/sys/rump/dev/lib/libugenhc/ugenhc.c:1.4 src/sys/rump/dev/lib/libugenhc/ugenhc.c:1.5 --- src/sys/rump/dev/lib/libugenhc/ugenhc.c:1.4 Thu Feb 18 16:13:30 2010 +++ src/sys/rump/dev/lib/libugenhc/ugenhc.c Thu Feb 18 16:24:19 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: ugenhc.c,v 1.4 2010/02/18 16:13:30 pooka Exp $ */ +/* $NetBSD: ugenhc.c,v 1.5 2010/02/18 16:24:19 pooka Exp $ */ /* * Copyright (c) 2009 Antti Kantee. All Rights Reserved. @@ -61,7 +61,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: ugenhc.c,v 1.4 2010/02/18 16:13:30 pooka Exp $); +__KERNEL_RCSID(0, $NetBSD: ugenhc.c,v 1.5 2010/02/18 16:24:19 pooka Exp $); #include sys/param.h #include sys/bus.h @@ -623,6 +623,8 @@ sc-sc_port_status = ~(UPS_CURRENT_CONNECT_STATUS | UPS_PORT_ENABLED | UPS_PORT_POWER); sc-sc_port_change = UPS_C_CONNECT_STATUS; + + rumpuser_close(sc-sc_ugenfd[UGEN_EPT_CTRL], error); sc-sc_ugenfd[UGEN_EPT_CTRL] = -1; xfer = sc-sc_intrxfer;
CVS commit: src/sys/rump/dev/lib/libugenhc
Module Name:src Committed By: pooka Date: Wed Feb 17 20:39:53 UTC 2010 Modified Files: src/sys/rump/dev/lib/libugenhc: ugenhc.c Log Message: * allow one more request * print warning if a request which might fail, fails * report error from bulk transfers To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/rump/dev/lib/libugenhc/ugenhc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/rump/dev/lib/libugenhc/ugenhc.c diff -u src/sys/rump/dev/lib/libugenhc/ugenhc.c:1.1 src/sys/rump/dev/lib/libugenhc/ugenhc.c:1.2 --- src/sys/rump/dev/lib/libugenhc/ugenhc.c:1.1 Thu Feb 11 02:22:09 2010 +++ src/sys/rump/dev/lib/libugenhc/ugenhc.c Wed Feb 17 20:39:53 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: ugenhc.c,v 1.1 2010/02/11 02:22:09 pooka Exp $ */ +/* $NetBSD: ugenhc.c,v 1.2 2010/02/17 20:39:53 pooka Exp $ */ /* * Copyright (c) 2009 Antti Kantee. All Rights Reserved. @@ -61,7 +61,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: ugenhc.c,v 1.1 2010/02/11 02:22:09 pooka Exp $); +__KERNEL_RCSID(0, $NetBSD: ugenhc.c,v 1.2 2010/02/17 20:39:53 pooka Exp $); #include sys/param.h #include sys/bus.h @@ -491,6 +491,7 @@ case C(0x22, UT_WRITE_CLASS_INTERFACE): case C(0x0a, UT_WRITE_CLASS_INTERFACE): case C(UR_SET_FEATURE, UT_WRITE_CLASS_OTHER): + case C(UR_SET_FEATURE, UT_WRITE_DEVICE): case C(UR_CLEAR_FEATURE, UT_WRITE_CLASS_OTHER): case C(UR_SET_REPORT, UT_WRITE_CLASS_INTERFACE): case C(UR_CLEAR_FEATURE, UT_WRITE_ENDPOINT): @@ -501,10 +502,12 @@ ucr.ucr_data = buf; if (rumpuser_ioctl(sc-sc_ugenfd[UGEN_EPT_CTRL], USB_DO_REQUEST, ucr, ru_error) == -1) { - if (!mightfail) + if (!mightfail) { panic(request failed: %d, ru_error); - else + } else { err = ru_error; +printf(warning: request failed: %d\n, err); + } } } break; @@ -719,7 +722,9 @@ } out: val = 0; + error = 0; rumpuser_ioctl(sc-sc_ugenfd[endpt], USB_SET_SHORT_XFER, val, error); + xfer-status = error; usb_transfer_complete(xfer); return (USBD_IN_PROGRESS); }