diff options
| author | augustss <augustss@NetBSD.org> | 1999-01-08 11:58:25 +0000 |
|---|---|---|
| committer | augustss <augustss@NetBSD.org> | 1999-01-08 11:58:25 +0000 |
| commit | 875aa92d2ca98da2250dc18b284c634b2654ac75 (patch) | |
| tree | 3741fa2779be6762e8124394eef036321506a3f7 /sys/dev | |
| parent | d7154c29c9b5c93743e2b1b4229225ba4d10b0f9 (diff) | |
Various little fixes from the FreeBSD version.
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/usb/hid.c | 7 | ||||
| -rw-r--r-- | sys/dev/usb/ucom.c | 4 | ||||
| -rw-r--r-- | sys/dev/usb/ugen.c | 49 | ||||
| -rw-r--r-- | sys/dev/usb/uhci.c | 3 | ||||
| -rw-r--r-- | sys/dev/usb/uhid.c | 8 | ||||
| -rw-r--r-- | sys/dev/usb/uhub.c | 15 | ||||
| -rw-r--r-- | sys/dev/usb/ukbd.c | 10 | ||||
| -rw-r--r-- | sys/dev/usb/ulpt.c | 4 | ||||
| -rw-r--r-- | sys/dev/usb/umodem.c | 15 | ||||
| -rw-r--r-- | sys/dev/usb/ums.c | 10 | ||||
| -rw-r--r-- | sys/dev/usb/usb.c | 115 | ||||
| -rw-r--r-- | sys/dev/usb/usb_port.h | 28 | ||||
| -rw-r--r-- | sys/dev/usb/usb_quirks.c | 8 | ||||
| -rw-r--r-- | sys/dev/usb/usb_subr.c | 39 | ||||
| -rw-r--r-- | sys/dev/usb/usbdi.c | 164 | ||||
| -rw-r--r-- | sys/dev/usb/usbdi.h | 11 | ||||
| -rw-r--r-- | sys/dev/usb/usbdi_util.c | 6 | ||||
| -rw-r--r-- | sys/dev/usb/usbdivar.h | 18 |
18 files changed, 254 insertions, 260 deletions
diff --git a/sys/dev/usb/hid.c b/sys/dev/usb/hid.c index 2f7bacb166e..6f838cc9f8f 100644 --- a/sys/dev/usb/hid.c +++ b/sys/dev/usb/hid.c @@ -1,4 +1,4 @@ -/* $NetBSD: hid.c,v 1.6 1999/01/07 02:22:50 augustss Exp $ */ +/* $NetBSD: hid.c,v 1.7 1999/01/08 11:58:25 augustss Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -41,7 +41,10 @@ #include <sys/systm.h> #include <sys/kernel.h> #include <sys/malloc.h> - +#if defined(__FreeBSD__) +#include <sys/bus.h> +#endif + #include <dev/usb/usb.h> #include <dev/usb/usbhid.h> diff --git a/sys/dev/usb/ucom.c b/sys/dev/usb/ucom.c index 0bfc7fea621..8a4c910b694 100644 --- a/sys/dev/usb/ucom.c +++ b/sys/dev/usb/ucom.c @@ -1,4 +1,4 @@ -/* $NetBSD: ucom.c,v 1.5 1999/01/07 02:22:50 augustss Exp $ */ +/* $NetBSD: ucom.c,v 1.6 1999/01/08 11:58:25 augustss Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -135,6 +135,6 @@ ucom_detach(device_t self) #endif #if defined(__FreeBSD__) -DRIVER_MODULE(ucom, usb, ucom_driver, ucom_devclass, usb_driver_load, 0); +DRIVER_MODULE(ucom, usb, ucom_driver, ucom_devclass, usbd_driver_load, 0); #endif diff --git a/sys/dev/usb/ugen.c b/sys/dev/usb/ugen.c index 9d3f6a10c59..d34f35b2a11 100644 --- a/sys/dev/usb/ugen.c +++ b/sys/dev/usb/ugen.c @@ -1,4 +1,4 @@ -/* $NetBSD: ugen.c,v 1.10 1999/01/07 02:22:20 augustss Exp $ */ +/* $NetBSD: ugen.c,v 1.11 1999/01/08 11:58:25 augustss Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -42,8 +42,17 @@ #include <sys/systm.h> #include <sys/kernel.h> #include <sys/malloc.h> +#if defined(__NetBSD__) #include <sys/device.h> #include <sys/ioctl.h> +#elif defined(__FreeBSD__) +#include <sys/module.h> +#include <sys/bus.h> +#include <sys/ioccom.h> +#include <sys/conf.h> +#include <sys/fcntl.h> +#include <sys/filio.h> +#endif #include <sys/tty.h> #include <sys/file.h> #include <sys/select.h> @@ -83,7 +92,7 @@ struct ugen_endpoint { #define UGEN_BBSIZE 1024 struct ugen_softc { - struct device sc_dev; /* base device */ + bdevice sc_dev; /* base device */ struct usbd_device *sc_udev; struct ugen_endpoint sc_endpoints[USB_MAX_ENDPOINTS][2]; @@ -93,9 +102,6 @@ struct ugen_softc { int sc_disconnected; /* device is gone */ }; -int ugen_match __P((struct device *, struct cfdata *, void *)); -void ugen_attach __P((struct device *, struct device *, void *)); - int ugenopen __P((dev_t, int, int, struct proc *)); int ugenclose __P((dev_t, int, int, struct proc *p)); int ugenread __P((dev_t, struct uio *uio, int)); @@ -219,18 +225,13 @@ ugenopen(dev, flag, mode, p) int unit = UGENUNIT(dev); int endpt = UGENENDPOINT(dev); usb_endpoint_descriptor_t *edesc; - struct ugen_softc *sc; struct ugen_endpoint *sce; int dir, isize; usbd_status r; - DPRINTFN(5, ("ugenopen: flag=%d, mode=%d, unit=%d endpt=%d\n", + USB_GET_SC_OPEN(ugen, unit, sc); + DPRINTFN(5, ("ugenopen: flag=%d, mode=%d, unit=%d endpt=%d\n", flag, mode, unit, endpt)); - if (unit >= ugen_cd.cd_ndevs) - return (ENXIO); - sc = ugen_cd.cd_devs[unit]; - if (!sc) - return (ENXIO); if (sc->sc_disconnected) return (EIO); @@ -268,15 +269,23 @@ ugenopen(dev, flag, mode, p) sce->ibuf = malloc(isize, M_USB, M_WAITOK); DPRINTFN(5, ("ugenopen: intr endpt=%d,isize=%d\n", endpt, isize)); - if (clalloc(&sce->q, UGEN_IBSIZE, 0) == -1) - return (ENOMEM); +#if defined(__NetBSD__) + if (clalloc(&sce->q, UGEN_IBSIZE, 0) == -1) + return (ENOMEM); +#elif defined(__FreeBSD__) + clist_alloc_cblocks(&sce->q, UGEN_IBSIZE, 0); +#endif r = usbd_open_pipe_intr(sce->iface, edesc->bEndpointAddress, USBD_SHORT_XFER_OK, &sce->pipeh, sce, sce->ibuf, isize, ugenintr); if (r != USBD_NORMAL_COMPLETION) { free(sce->ibuf, M_USB); +#if defined(__NetBSD__) clfree(&sce->q); +#elif defined(__FreeBSD__) + clist_free_cblocks(&sce->q); +#endif return (EIO); } usbd_set_disco(sce->pipeh, ugen_disco, sc); @@ -305,7 +314,7 @@ ugenclose(dev, flag, mode, p) int mode; struct proc *p; { - struct ugen_softc *sc = ugen_cd.cd_devs[UGENUNIT(dev)]; + USB_GET_SC(ugen, UGENUNIT(dev), sc); int endpt = UGENENDPOINT(dev); struct ugen_endpoint *sce; int dir; @@ -352,7 +361,7 @@ ugenread(dev, uio, flag) struct uio *uio; int flag; { - struct ugen_softc *sc = ugen_cd.cd_devs[UGENUNIT(dev)]; + USB_GET_SC(ugen, UGENUNIT(dev), sc); int endpt = UGENENDPOINT(dev); struct ugen_endpoint *sce = &sc->sc_endpoints[endpt][IN]; u_int32_t n, tn; @@ -452,7 +461,7 @@ ugenwrite(dev, uio, flag) struct uio *uio; int flag; { - struct ugen_softc *sc = ugen_cd.cd_devs[UGENUNIT(dev)]; + USB_GET_SC(ugen, UGENUNIT(dev), sc); int endpt = UGENENDPOINT(dev); struct ugen_endpoint *sce = &sc->sc_endpoints[endpt][OUT]; size_t n; @@ -658,7 +667,7 @@ ugenioctl(dev, cmd, addr, flag, p) int flag; struct proc *p; { - struct ugen_softc *sc = ugen_cd.cd_devs[UGENUNIT(dev)]; + USB_GET_SC(ugen, UGENUNIT(dev), sc); int endpt = UGENENDPOINT(dev); struct ugen_endpoint *sce; usbd_status r; @@ -910,7 +919,7 @@ ugenpoll(dev, events, p) int events; struct proc *p; { - struct ugen_softc *sc = ugen_cd.cd_devs[UGENUNIT(dev)]; + USB_GET_SC(ugen, UGENUNIT(dev), sc); /* XXX */ struct ugen_endpoint *sce; int revents = 0; @@ -969,4 +978,6 @@ ugen_detach(device_t self) } return 0; } + +DRIVER_MODULE(ugen, usb, ugen_driver, ugen_devclass, usbd_driver_load, 0); #endif diff --git a/sys/dev/usb/uhci.c b/sys/dev/usb/uhci.c index 121d7a50985..b316b1667d7 100644 --- a/sys/dev/usb/uhci.c +++ b/sys/dev/usb/uhci.c @@ -1,4 +1,4 @@ -/* $NetBSD: uhci.c,v 1.21 1999/01/07 02:22:51 augustss Exp $ */ +/* $NetBSD: uhci.c,v 1.22 1999/01/08 11:58:25 augustss Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -74,7 +74,6 @@ #if defined(__FreeBSD__) #include <machine/clock.h> -#include "dev/usb/queue.addendum.h" #define delay(d) DELAY(d) #endif diff --git a/sys/dev/usb/uhid.c b/sys/dev/usb/uhid.c index bed772087ef..f9ea5fb4f49 100644 --- a/sys/dev/usb/uhid.c +++ b/sys/dev/usb/uhid.c @@ -1,4 +1,4 @@ -/* $NetBSD: uhid.c,v 1.13 1999/01/07 02:22:51 augustss Exp $ */ +/* $NetBSD: uhid.c,v 1.14 1999/01/08 11:58:25 augustss Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -43,15 +43,15 @@ #include <sys/kernel.h> #include <sys/malloc.h> #if defined(__NetBSD__) +#include <sys/device.h> #include <sys/ioctl.h> #elif defined(__FreeBSD__) #include <sys/ioccom.h> #include <sys/filio.h> #include <sys/module.h> #include <sys/bus.h> +#include <sys/ioccom.h> #endif -#include <sys/device.h> -#include <sys/ioctl.h> #include <sys/tty.h> #include <sys/file.h> #include <sys/select.h> @@ -542,5 +542,5 @@ uhidpoll(dev, events, p) } #if defined(__FreeBSD__) -DRIVER_MODULE(uhid, usb, uhid_driver, uhid_devclass, usb_driver_load, 0); +DRIVER_MODULE(uhid, usb, uhid_driver, uhid_devclass, usbd_driver_load, 0); #endif diff --git a/sys/dev/usb/uhub.c b/sys/dev/usb/uhub.c index 5043eef6e13..2f639f39252 100644 --- a/sys/dev/usb/uhub.c +++ b/sys/dev/usb/uhub.c @@ -1,4 +1,4 @@ -/* $NetBSD: uhub.c,v 1.13 1998/12/30 18:06:25 augustss Exp $ */ +/* $NetBSD: uhub.c,v 1.14 1999/01/08 11:58:25 augustss Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -80,7 +80,7 @@ void uhub_intr __P((usbd_request_handle, usbd_private_handle, usbd_status)); /*void uhub_disco __P((void *));*/ -USB_DECLARE_DRIVER_NAME("usb", uhub); +USB_DECLARE_DRIVER_NAME(usb, uhub); /* FIXME what does FreeBSD need? */ #if defined(__NetBSD__) @@ -458,7 +458,6 @@ uhub_disconnect(up) } } -#if defined(__NetBSD__) /* XXX Free all data structures and disable further I/O. */ if (dev->hub) { struct usbd_port *rup; @@ -476,10 +475,10 @@ uhub_disconnect(up) dev->bus->devices[dev->address] = 0; up->device = 0; /* XXX free */ -#elif defined(__FreeBSD__) - /* XXX this doesn't work. */ - /* clean up the kindergarten, get rid of the kids */ - usbd_remove_device(dev, up); +#if defined(__FreeBSD__) + device_delete_child( + device_get_parent(((struct softc *)dev->softc)->sc_dev), + ((struct softc *)dev->softc)->sc_dev); #endif } @@ -499,5 +498,5 @@ uhub_intr(reqh, addr, status) } #if defined(__FreeBSD__) -DRIVER_MODULE(uhub, usb, uhub_driver, uhub_devclass, usb_driver_load, 0); +DRIVER_MODULE(uhub, usb, uhub_driver, uhub_devclass, usbd_driver_load, 0); #endif diff --git a/sys/dev/usb/ukbd.c b/sys/dev/usb/ukbd.c index 49653af58e1..fc904c872c5 100644 --- a/sys/dev/usb/ukbd.c +++ b/sys/dev/usb/ukbd.c @@ -1,4 +1,4 @@ -/* $NetBSD: ukbd.c,v 1.20 1998/12/30 19:25:27 augustss Exp $ */ +/* $NetBSD: ukbd.c,v 1.21 1999/01/08 11:58:25 augustss Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -77,6 +77,10 @@ #include "opt_pckbd_layout.h" #include "opt_wsdisplay_compat.h" + +#elif defined(__FreeBSD__) +#include <machine/clock.h> +#define delay(d) DELAY(d) #endif #ifdef USB_DEBUG @@ -225,7 +229,7 @@ const struct wskbd_accessops ukbd_accessops = { ukbd_enable, ukbd_set_leds, ukbd_ioctl, -#if 0 +#if 1 ukbd_cnattach, #endif }; @@ -673,5 +677,5 @@ ukbd_cnattach(v) #endif /* NetBSD */ #if defined(__FreeBSD__) -DRIVER_MODULE(ukbd, usb, ukbd_driver, ukbd_devclass, usb_driver_load, 0); +DRIVER_MODULE(ukbd, usb, ukbd_driver, ukbd_devclass, usbd_driver_load, 0); #endif diff --git a/sys/dev/usb/ulpt.c b/sys/dev/usb/ulpt.c index fea4339077a..1776e754420 100644 --- a/sys/dev/usb/ulpt.c +++ b/sys/dev/usb/ulpt.c @@ -1,4 +1,4 @@ -/* $NetBSD: ulpt.c,v 1.9 1998/12/30 17:46:20 augustss Exp $ */ +/* $NetBSD: ulpt.c,v 1.10 1999/01/08 11:58:25 augustss Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -409,5 +409,5 @@ ulpt_detach(device_t self) return 0; } -DRIVER_MODULE(ulpt, usb, ulpt_driver, ulpt_devclass, usb_driver_load, 0); +DRIVER_MODULE(ulpt, usb, ulpt_driver, ulpt_devclass, usbd_driver_load, 0); #endif diff --git a/sys/dev/usb/umodem.c b/sys/dev/usb/umodem.c index 7e507a783ef..d1eb10d1dcf 100644 --- a/sys/dev/usb/umodem.c +++ b/sys/dev/usb/umodem.c @@ -1,4 +1,4 @@ -/* $NetBSD: umodem.c,v 1.4 1998/12/30 17:46:20 augustss Exp $ */ +/* $NetBSD: umodem.c,v 1.5 1999/01/08 11:58:25 augustss Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -42,7 +42,6 @@ #include <sys/kernel.h> #include <sys/malloc.h> #if defined(__NetBSD__) -#include <sys/device.h> #include <sys/ioctl.h> #elif defined(__FreeBSD__) #include <sys/module.h> @@ -59,13 +58,12 @@ #include <sys/poll.h> #include <dev/usb/usb.h> -#include <dev/usb/usbhid.h> +#include <dev/usb/usbcdc.h> #include <dev/usb/usbdi.h> #include <dev/usb/usbdi_util.h> #include <dev/usb/usbdevs.h> #include <dev/usb/usb_quirks.h> -#include <dev/usb/hid.h> #ifdef USB_DEBUG #define DPRINTF(x) if (umodemdebug) printf x @@ -78,7 +76,10 @@ int umodemdebug = 0; struct umodem_softc { bdevice sc_dev; /* base device */ - usbd_interface_handle sc_iface; /* interface */ + usbd_interface_handle sc_ctl; /* control interface */ + usbd_interface_handle sc_data; /* data interface */ + uByte cmCaps; + uByte acmCaps; }; void umodem_intr __P((usbd_request_handle, usbd_private_handle, usbd_status)); @@ -110,7 +111,7 @@ USB_ATTACH(umodem) usb_interface_descriptor_t *id; char devinfo[1024]; - sc->sc_iface = iface; + sc->sc_ctl = iface; id = usbd_get_interface_descriptor(iface); usbd_devinfo(uaa->device, 0, devinfo); USB_ATTACH_SETUP; @@ -137,6 +138,6 @@ umodem_detach(device_t self) #endif #if defined(__FreeBSD__) -DRIVER_MODULE(umodem, usb, umodem_driver, umodem_devclass, usb_driver_load, 0); +DRIVER_MODULE(umodem, usb, umodem_driver, umodem_devclass, usbd_driver_load,0); #endif diff --git a/sys/dev/usb/ums.c b/sys/dev/usb/ums.c index b13b79a58c0..8a76869e5c8 100644 --- a/sys/dev/usb/ums.c +++ b/sys/dev/usb/ums.c @@ -1,4 +1,4 @@ -/* $NetBSD: ums.c,v 1.18 1998/12/30 17:46:20 augustss Exp $ */ +/* $NetBSD: ums.c,v 1.19 1999/01/08 11:58:25 augustss Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -153,13 +153,13 @@ static d_read_t ums_read; static d_ioctl_t ums_ioctl; static d_poll_t ums_poll; -#define UMS_CDEV_MAJOR 138 /* XXX NWH should be requested */ +#define UMS_CDEV_MAJOR 111 static struct cdevsw ums_cdevsw = { ums_open, ums_close, ums_read, nowrite, ums_ioctl, nostop, nullreset, nodevtotty, ums_poll, nommap, - NULL, "ums_", NULL, -1 + NULL, "ums", NULL, -1 }; #endif @@ -199,7 +199,9 @@ USB_ATTACH(ums) usbd_interface_handle iface = uaa->iface; usb_interface_descriptor_t *id; usb_endpoint_descriptor_t *ed; +#if defined(__NetBSD__) struct wsmousedev_attach_args a; +#endif int size; void *desc; usbd_status r; @@ -730,6 +732,6 @@ ums_ioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) #if defined(__FreeBSD__) CDEV_DRIVER_MODULE(ums, usb, ums_driver, ums_devclass, - UMS_CDEV_MAJOR, ums_cdevsw, usb_driver_load, 0); + UMS_CDEV_MAJOR, ums_cdevsw, usbd_driver_load, 0); #endif diff --git a/sys/dev/usb/usb.c b/sys/dev/usb/usb.c index f455606ef12..bd0c0dfd6f3 100644 --- a/sys/dev/usb/usb.c +++ b/sys/dev/usb/usb.c @@ -1,4 +1,4 @@ -/* $NetBSD: usb.c,v 1.10 1999/01/03 01:00:56 augustss Exp $ */ +/* $NetBSD: usb.c,v 1.11 1999/01/08 11:58:25 augustss Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -102,10 +102,6 @@ int usbioctl __P((dev_t, u_long, caddr_t, int, struct proc *)); int usbpoll __P((dev_t, int, struct proc *)); #elif defined(__FreeBSD__) -static device_probe_t usb_match; -static device_attach_t usb_attach; -static bus_print_child_t usb_print_child; - d_open_t usbopen; d_close_t usbclose; d_ioctl_t usbioctl; @@ -121,7 +117,7 @@ struct cdevsw usb_cdevsw = { usbd_status usb_discover __P((struct usb_softc *)); -USB_DECLARE_DRIVER_INIT(usb, DEVMETHOD(bus_print_child, usb_print_child)); +USB_DECLARE_DRIVER_INIT(usb, DEVMETHOD(bus_print_child, usbd_print_child)); USB_MATCH(usb) { @@ -134,8 +130,8 @@ USB_ATTACH(usb) #if defined(__NetBSD__) struct usb_softc *sc = (struct usb_softc *)self; #elif defined(__FreeBSD__) - struct usb_softc *sc = device_get_softc(device); - void *aux = device_get_ivars(device); + struct usb_softc *sc = device_get_softc(self); + void *aux = device_get_ivars(self); #endif usbd_device_handle dev; usbd_status r; @@ -143,7 +139,7 @@ USB_ATTACH(usb) #if defined(__NetBSD__) printf("\n"); #elif defined(__FreeBSD__) - sc->sc_dev = device; + sc->sc_dev = self; #endif DPRINTF(("usbd_attach\n")); @@ -187,105 +183,6 @@ usbctlprint(aux, pnp) return (UNCONF); } - -#elif defined(__FreeBSD__) -static void -usb_print_child(device_t parent, device_t child) -{ - struct usb_softc *sc = device_get_softc(child); - - printf(" at %s%d", device_get_name(parent), device_get_unit(parent)); - - /* How do we get to the usbd_device_handle??? - usbd_device_handle dev = invalidadosch; - - printf(" addr %d", dev->addr); - - if (bootverbose) { - if (dev->lowspeed) - printf(", lowspeed"); - if (dev->self_powered) - printf(", self powered"); - else - printf(", %dmA", dev->power); - printf(", config %d", dev->config); - } - */ -} - -/* Reconfigure all the USB busses in the system. */ -int -usb_driver_load(module_t mod, int what, void *arg) -{ - /* subroutine is there but inactive at the moment - * the reconfiguration process has not been thought through yet. - */ - devclass_t ugen_devclass = devclass_find("ugen"); - device_t *devlist; - int devcount; - int error; - - switch (what) { - case MOD_LOAD: - case MOD_UNLOAD: - if (!usb_devclass) - return 0; /* just ignore call */ - - if (ugen_devclass) { - /* detach devices from generic driver if possible - */ - error = devclass_get_devices(ugen_devclass, &devlist, - &devcount); - if (!error) - for (devcount--; devcount >= 0; devcount--) - (void)DEVICE_DETACH(devlist[devcount]); - } - - error = devclass_get_devices(usb_devclass, &devlist, &devcount); - if (error) - return 0; /* XXX maybe transient, or error? */ - - for (devcount--; devcount >= 0; devcount--) - USB_RECONFIGURE(devlist[devcount]); - - free(devlist, M_TEMP); - return 0; - } - - return 0; /* nothing to do by us */ -} - -/* Set the description of the device including a malloc and copy. */ -void -usb_device_set_desc(device_t device, char *devinfo) -{ - size_t l; - char *desc; - - if ( devinfo ) { - l = strlen(devinfo); - desc = malloc(l+1, M_USB, M_NOWAIT); - if (desc) - memcpy(desc, devinfo, l+1); - } else - desc = NULL; - - device_set_desc(device, desc); -} - -/* - * A static buffer is a loss if this routine is used from an interrupt, - * but it's not fatal. - */ -char * -usb_devname(struct device *bdev) -{ - static char buf[20]; - - sprintf(buf, "%s%d", device_get_name(*bdev), device_get_unit(*bdev)); - return (buf); -} - #endif int @@ -439,6 +336,7 @@ usbpoll(dev, events, p) return (revents); } +#if 0 int usb_bus_count() { @@ -449,6 +347,7 @@ usb_bus_count() n++; return (n); } +#endif usbd_status usb_get_bus_handle(n, h) diff --git a/sys/dev/usb/usb_port.h b/sys/dev/usb/usb_port.h index e1001a67921..f3379ccda99 100644 --- a/sys/dev/usb/usb_port.h +++ b/sys/dev/usb/usb_port.h @@ -1,4 +1,4 @@ -/* $NetBSD: usb_port.h,v 1.4 1999/01/07 22:09:00 augustss Exp $ */ +/* $NetBSD: usb_port.h,v 1.5 1999/01/08 11:58:25 augustss Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -116,8 +116,12 @@ __CONCAT(dname,_attach)(parent, self, aux) \ */ #include "opt_usb.h" -char *usb_devname(struct device *); -#define USBDEVNAME(bdev) usb_devname(&bdev) +/* + * The following is not a type def to avoid error messages + * because of includes in the wrong order. + */ +#define bdevice device_t +#define USBDEVNAME(bdev) usbd_devname(&bdev) /* XXX Change this when FreeBSD has memset */ @@ -129,15 +133,7 @@ char *usb_devname(struct device *); panic("Non zero filler for memset, cannot handle!"); \ } while (0) -typedef device_t bdevice; - -/* - * To avoid race conditions we first initialise the struct - * before we use it. The timeout might happen between the - * setting of the timeout and the setting of timo_handle - */ -#define usb_timeout(f, d, t, h) \ - (callout_handle_init(&(h)), (h) = timeout((f), (d), (t))) +#define usb_timeout(f, d, t, h) ((h) = timeout((f), (d), (t))) #define usb_untimeout(f, d, h) untimeout((f), (d), (h)) #define USB_DECLARE_DRIVER_NAME_INIT(name, dname, init) \ @@ -199,7 +195,7 @@ __CONCAT(dname,_attach)(device_t self) (device_probe_and_attach((bdev)) == 0 ? ((dev)->softc = (bdev)) : 0) /* conversion from one type of queue to the other */ -#define SIMPLEQ_REMOVE_HEAD STAILQ_REMOVE_HEAD_QUEUE +#define SIMPLEQ_REMOVE_HEAD STAILQ_REMOVE_HEAD_UNTIL #define SIMPLEQ_INSERT_HEAD STAILQ_INSERT_HEAD #define SIMPLEQ_INSERT_TAIL STAILQ_INSERT_TAIL #define SIMPLEQ_NEXT STAILQ_NEXT @@ -213,10 +209,10 @@ __CONCAT(dname,_attach)(device_t self) #define NONE {0,0} #define USB_DECLARE_DRIVER_NAME(name, dname) \ - USB_DECLARE_DRIVER_NAME_INIT(name, dname, NONE ) + USB_DECLARE_DRIVER_NAME_INIT(#name, dname, NONE ) #define USB_DECLARE_DRIVER_INIT(dname, init) \ - USB_DECLARE_DRIVER_NAME_INIT(##dname, dname, init) + USB_DECLARE_DRIVER_NAME_INIT(#dname, dname, init) #define USB_DECLARE_DRIVER(dname) \ - USB_DECLARE_DRIVER_NAME_INIT(##dname, dname, NONE ) + USB_DECLARE_DRIVER_NAME_INIT(#dname, dname, NONE ) #undef NONE diff --git a/sys/dev/usb/usb_quirks.c b/sys/dev/usb/usb_quirks.c index ed7bd0d761d..145dfc028eb 100644 --- a/sys/dev/usb/usb_quirks.c +++ b/sys/dev/usb/usb_quirks.c @@ -1,4 +1,4 @@ -/* $NetBSD: usb_quirks.c,v 1.7 1999/01/07 02:22:51 augustss Exp $ */ +/* $NetBSD: usb_quirks.c,v 1.8 1999/01/08 11:58:25 augustss Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -39,8 +39,10 @@ #include <sys/param.h> #include <sys/systm.h> -#include <sys/select.h> - +#if defined(__FreeBSD__) +#include <sys/bus.h> +#endif + #include <dev/usb/usb.h> #include <dev/usb/usbdevs.h> diff --git a/sys/dev/usb/usb_subr.c b/sys/dev/usb/usb_subr.c index 2c88315e105..06caf9432c3 100644 --- a/sys/dev/usb/usb_subr.c +++ b/sys/dev/usb/usb_subr.c @@ -1,4 +1,4 @@ -/* $NetBSD: usb_subr.c,v 1.26 1999/01/07 22:12:08 augustss Exp $ */ +/* $NetBSD: usb_subr.c,v 1.27 1999/01/08 11:58:25 augustss Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -58,6 +58,11 @@ #include <dev/usb/usbdevs.h> #include <dev/usb/usb_quirks.h> +#if defined(__FreeBSD__) +#include <machine/clock.h> +#define delay(d) DELAY(d) +#endif + #ifdef USB_DEBUG #define DPRINTF(x) if (usbdebug) printf x #define DPRINTFN(n,x) if (usbdebug>(n)) printf x @@ -70,15 +75,16 @@ extern int usbdebug; static usbd_status usbd_set_config __P((usbd_device_handle, int)); char *usbd_get_string __P((usbd_device_handle, int, char *)); int usbd_getnewaddr __P((usbd_bus_handle bus)); -int usbd_print __P((void *aux, const char *pnp)); #if defined(__NetBSD__) -int usbd_submatch __P((struct device *, struct cfdata *cf, void *)); +int usbd_print __P((void *aux, const char *pnp)); +int usbd_submatch __P((bdevice *, struct cfdata *cf, void *)); #endif void usbd_free_iface_data __P((usbd_device_handle dev, int ifcno)); void usbd_kill_pipe __P((usbd_pipe_handle)); usbd_status usbd_probe_and_attach __P((bdevice *parent, usbd_device_handle dev, int port, int addr)); + #ifdef USBVERBOSE typedef u_int16_t usb_vendor_id_t; typedef u_int16_t usb_product_id_t; @@ -759,7 +765,10 @@ usbd_probe_and_attach(parent, dev, port, addr) printf("%s: port %d, set config at addr %d failed\n", USBDEVNAME(*parent), port, addr); #endif - return (r); +#if defined(__FreeBSD__) + device_delete_child(*parent, bdev); +#endif + return (r); } nifaces = dev->cdesc->bNumInterface; uaa.configno = dev->cdesc->bConfigurationValue; @@ -801,7 +810,14 @@ usbd_probe_and_attach(parent, dev, port, addr) * fully operational and not harming anyone. */ DPRINTF(("usbd_probe_and_attach: generic attach failed\n")); - return (USBD_NORMAL_COMPLETION); +#if defined(__FreeBSD__) +/* + * XXX should we delete the child again? Left for now to avoid dangling + * references. + device_delete_child(*parent, bdev); +*/ +#endif + return (USBD_NORMAL_COMPLETION); } @@ -954,19 +970,6 @@ usbd_remove_device(dev, up) { DPRINTF(("usbd_remove_device: %p\n", dev)); -#if defined(__NetBSD__) - /* XXX bit of a hack, only for hubs the detach is called - * - * easiest solution, register a detach method in the softc, call that - * one and pass the device struct to it, or the softc. Whatever. - */ - /*if (dev->bdev && dev->hub) - uhub_detach(dev->hub->hubdata);*/ -#elif defined(__FreeBSD__) - if (dev->bdev) - device_delete_child(device_get_parent(dev->bdev), dev->bdev); -#endif - if (dev->default_pipe) usbd_kill_pipe(dev->default_pipe); up->device = 0; diff --git a/sys/dev/usb/usbdi.c b/sys/dev/usb/usbdi.c index ab15ebf6193..322ecd1b6a5 100644 --- a/sys/dev/usb/usbdi.c +++ b/sys/dev/usb/usbdi.c @@ -1,4 +1,4 @@ -/* $NetBSD: usbdi.c,v 1.19 1999/01/03 01:00:56 augustss Exp $ */ +/* $NetBSD: usbdi.c,v 1.20 1999/01/08 11:58:26 augustss Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -56,6 +56,10 @@ #include <dev/usb/usbdi_util.h> #include <dev/usb/usbdivar.h> +#if defined(__FreeBSD__) +#include "usb_if.h" +#endif + #ifdef USB_DEBUG #define DPRINTF(x) if (usbdebug) printf x #define DPRINTFN(n,x) if (usbdebug>(n)) printf x @@ -76,7 +80,7 @@ void usbd_do_request_async_cb static SIMPLEQ_HEAD(, usbd_request) usbd_free_requests; #if defined(__FreeBSD__) -#define USB_CDEV_MAJOR 79 +#define USB_CDEV_MAJOR 108 extern struct cdevsw usb_cdevsw; #endif @@ -222,55 +226,6 @@ usbd_do_transfer(reqh) return (pipe->methods->transfer(reqh)); } -#if 0 -static usbd_status -usbd_do_transfer(reqh) - usbd_request_handle reqh; -{ - usbd_pipe_handle pipe = reqh->pipe; - - DPRINTFN(10,("usbd_do_transfer: reqh=%p\n", reqh)); - reqh->done = 0; - s = splusb(); - if (pipe->state == USBD_PIPE_IDLE || - (iface && iface->state == USBD_INTERFACE_IDLE)) { - splx(s); - return (USBD_IS_IDLE); - } - SIMPLEQ_INSERT_TAIL(&pipe->queue, reqh, next); - if (pipe->state == USBD_PIPE_ACTIVE && - (!iface || iface->state == USBD_INTERFACE_ACTIVE)) { - r = usbd_start(pipe); - } else - r = USBD_NOT_STARTED; - splx(s); - return (r); -} - -static usbd_status -usbd_start(pipe) - usbd_pipe_handle pipe; -{ - usbd_request_handle reqh; - - DPRINTFN(5, ("usbd_start: pipe=%p, running=%d\n", - pipe, pipe->running)); - if (pipe->running) - return (USBD_IN_PROGRESS); - reqh = SIMPLEQ_FIRST(&pipe->queue); - if (!reqh) { - /* XXX */ - printf("usbd_start: pipe empty!\n"); - pipe->running = 0; - return (USBD_XXX); - } - SIMPLEQ_REMOVE_HEAD(&pipe->queue, reqh, next); - pipe->running = 1; - pipe->curreqh = reqh; - return (pipe->methods->transfer(reqh)); -} -#endif - usbd_request_handle usbd_alloc_request() { @@ -702,11 +657,13 @@ usbd_interface_count(dev, count) return (USBD_NORMAL_COMPLETION); } +#if 0 u_int8_t usbd_bus_count() { return (usb_bus_count()); } +#endif usbd_status usbd_get_bus_handle(index, bus) @@ -927,6 +884,7 @@ usbd_ar_pipe(pipe) { usbd_request_handle reqh; +#if 0 for (;;) { reqh = SIMPLEQ_FIRST(&pipe->queue); if (reqh == 0) @@ -936,6 +894,12 @@ usbd_ar_pipe(pipe) if (reqh->callback) reqh->callback(reqh, reqh->priv, reqh->status); } +#else + while ((reqh = SIMPLEQ_FIRST(&pipe->queue))) { + pipe->methods->abort(reqh); + SIMPLEQ_REMOVE_HEAD(&pipe->queue, reqh, next); + } +#endif return (USBD_NORMAL_COMPLETION); } @@ -1228,3 +1192,101 @@ usbd_get_endpoint_descriptor(iface, address) return (0); } +#if defined(__FreeBSD__) +void +usbd_print_child(device_t parent, device_t child) +{ + /* + struct usb_softc *sc = device_get_softc(child); + */ + + printf(" at %s%d", device_get_name(parent), device_get_unit(parent)); + + /* XXX How do we get to the usbd_device_handle??? + usbd_device_handle dev = invalidadosch; + + printf(" addr %d", dev->addr); + + if (bootverbose) { + if (dev->lowspeed) + printf(", lowspeed"); + if (dev->self_powered) + printf(", self powered"); + else + printf(", %dmA", dev->power); + printf(", config %d", dev->config); + } + */ +} + +/* Reconfigure all the USB busses in the system. */ +int +usbd_driver_load(module_t mod, int what, void *arg) +{ + devclass_t usb_devclass = devclass_find("usb"); + devclass_t ugen_devclass = devclass_find("ugen"); + device_t *devlist; + int devcount; + int error; + + switch (what) { + case MOD_LOAD: + case MOD_UNLOAD: + if (!usb_devclass) + return 0; /* just ignore call */ + + if (ugen_devclass) { + /* detach devices from generic driver if possible */ + error = devclass_get_devices(ugen_devclass, &devlist, + &devcount); + if (!error) + for (devcount--; devcount >= 0; devcount--) + (void)DEVICE_DETACH(devlist[devcount]); + } + + error = devclass_get_devices(usb_devclass, &devlist, &devcount); + if (error) + return 0; /* XXX maybe transient, or error? */ + + for (devcount--; devcount >= 0; devcount--) + USB_RECONFIGURE(devlist[devcount]); + + free(devlist, M_TEMP); + return 0; + } + + return 0; /* nothing to do by us */ +} + +/* Set the description of the device including a malloc and copy. */ +void +usbd_device_set_desc(device_t device, char *devinfo) +{ + size_t l; + char *desc; + + if ( devinfo ) { + l = strlen(devinfo); + desc = malloc(l+1, M_USB, M_NOWAIT); + if (desc) + memcpy(desc, devinfo, l+1); + } else + desc = NULL; + + device_set_desc(device, desc); +} + +/* + * A static buffer is a loss if this routine is used from an interrupt, + * but it's not fatal. + */ +char * +usbd_devname(bdevice *bdev) +{ + static char buf[20]; + + sprintf(buf, "%s%d", device_get_name(*bdev), device_get_unit(*bdev)); + return (buf); +} + +#endif diff --git a/sys/dev/usb/usbdi.h b/sys/dev/usb/usbdi.h index b82df6e9034..e8491d7e673 100644 --- a/sys/dev/usb/usbdi.h +++ b/sys/dev/usb/usbdi.h @@ -1,4 +1,4 @@ -/* $NetBSD: usbdi.h,v 1.15 1999/01/03 01:00:56 augustss Exp $ */ +/* $NetBSD: usbdi.h,v 1.16 1999/01/08 11:58:26 augustss Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -174,7 +174,9 @@ usbd_status usbd_endpoint_count __P((usbd_interface_handle dev, u_int8_t *count)); usbd_status usbd_interface_count __P((usbd_device_handle dev, u_int8_t *count)); +#if 0 u_int8_t usbd_bus_count __P((void)); +#endif usbd_status usbd_get_bus_handle __P((u_int8_t index, usbd_bus_handle *bus)); usbd_status usbd_get_root_hub __P((usbd_bus_handle bus, usbd_device_handle *dev)); @@ -326,6 +328,13 @@ void usbd_set_disco __P((usbd_pipe_handle, void (*)(void *), void *)); usb_endpoint_descriptor_t *usbd_get_endpoint_descriptor __P((usbd_interface_handle iface, u_int8_t address)); +#if defined(__FreeBSD__) +int usbd_driver_load __P((module_t mod, int what, void *arg)); +void usbd_device_set_desc __P((device_t device, char *devinfo)); +char *usbd_devname(bdevice *bdev); +bus_print_child_t usbd_print_child; +#endif + /* XXX */ #define splusb splbio #define IPL_USB IPL_BIO diff --git a/sys/dev/usb/usbdi_util.c b/sys/dev/usb/usbdi_util.c index 34026eb1216..e3ade617dbe 100644 --- a/sys/dev/usb/usbdi_util.c +++ b/sys/dev/usb/usbdi_util.c @@ -1,4 +1,4 @@ -/* $NetBSD: usbdi_util.c,v 1.12 1999/01/07 02:22:51 augustss Exp $ */ +/* $NetBSD: usbdi_util.c,v 1.13 1999/01/08 11:58:26 augustss Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -42,7 +42,9 @@ #include <sys/kernel.h> #include <sys/malloc.h> #include <sys/proc.h> -#include <sys/select.h> +#if defined(__FreeBSD__) +#include <sys/bus.h> +#endif #include <dev/usb/usb.h> #include <dev/usb/usbhid.h> diff --git a/sys/dev/usb/usbdivar.h b/sys/dev/usb/usbdivar.h index a0335103baa..ab4a50461f2 100644 --- a/sys/dev/usb/usbdivar.h +++ b/sys/dev/usb/usbdivar.h @@ -1,4 +1,4 @@ -/* $NetBSD: usbdivar.h,v 1.15 1999/01/07 02:22:51 augustss Exp $ */ +/* $NetBSD: usbdivar.h,v 1.16 1999/01/08 11:58:26 augustss Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -202,17 +202,19 @@ int usb_bus_count __P((void)); usbd_status usb_get_bus_handle __P((int, usbd_bus_handle *)); void usb_needs_explore __P((usbd_bus_handle)); -#if defined(__FreeBSD__) -int usb_driver_load __P((module_t mod, int what, void *arg)); -void usb_device_set_desc __P((device_t device, char *devinfo)); -#endif - -extern int usbd_use_polling; - /* Locator stuff. */ #if defined(__NetBSD__) #include "locators.h" +#elif defined(__FreeBSD__) +/* XXX these values are used to statically bind some elements in the USB tree + * to specific driver instances. This should be somehow emulated in FreeBSD + * but can be done later on. + * The values are copied from the files.usb file in the NetBSD sources. + */ +#define UHUBCF_PORT_DEFAULT -1 +#define UHUBCF_CONFIGURATION_DEFAULT -1 +#define UHUBCF_INTERFACE_DEFAULT -1 #endif #define uhubcf_port cf_loc[UHUBCF_PORT] |
