Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/usb Add a capability for pre/post processing on writ...
details: https://anonhg.NetBSD.org/src/rev/1c28fff20d15
branches: trunk
changeset: 484901:1c28fff20d15
user: augustss <augustss%NetBSD.org@localhost>
date: Fri Apr 14 14:21:55 2000 +0000
description:
Add a capability for pre/post processing on write/read.
diffstat:
sys/dev/usb/ucom.c | 46 ++++++++++++++++++++++++++++++++++------------
sys/dev/usb/ucomvar.h | 11 +++++++++--
sys/dev/usb/umodem.c | 7 ++++++-
sys/dev/usb/uvisor.c | 6 +++++-
4 files changed, 54 insertions(+), 16 deletions(-)
diffs (246 lines):
diff -r fde7eff67f37 -r 1c28fff20d15 sys/dev/usb/ucom.c
--- a/sys/dev/usb/ucom.c Fri Apr 14 14:20:02 2000 +0000
+++ b/sys/dev/usb/ucom.c Fri Apr 14 14:21:55 2000 +0000
@@ -1,7 +1,7 @@
-/* $NetBSD: ucom.c,v 1.21 2000/04/08 01:22:26 itojun Exp $ */
+/* $NetBSD: ucom.c,v 1.22 2000/04/14 14:21:55 augustss Exp $ */
/*
- * Copyright (c) 1998 The NetBSD Foundation, Inc.
+ * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@@ -36,6 +36,9 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
+/*
+ * This code is very heavily based on the 16550 driver, com.c.
+ */
#include <sys/param.h>
#include <sys/systm.h>
@@ -91,12 +94,14 @@
usbd_xfer_handle sc_ixfer; /* read request */
u_char *sc_ibuf; /* read buffer */
u_int sc_ibufsize; /* read buffer size */
+ u_int sc_ibufsizepad; /* read buffer size padded */
int sc_bulkout_no; /* bulk out endpoint address */
usbd_pipe_handle sc_bulkout_pipe;/* bulk out pipe */
usbd_xfer_handle sc_oxfer; /* write request */
u_char *sc_obuf; /* write buffer */
u_int sc_obufsize; /* write buffer size */
+ u_int sc_obufsizepad; /* write buffer size padded */
struct ucom_methods *sc_methods;
void *sc_parent;
@@ -125,7 +130,6 @@
int, struct proc *));
Static void ucom_dtr __P((struct ucom_softc *, int));
Static void ucom_rts __P((struct ucom_softc *, int));
-Static void ucom_status_change __P((struct ucom_softc *));
Static void ucom_break __P((struct ucom_softc *, int));
Static usbd_status ucomstartread __P((struct ucom_softc *));
Static void ucomreadcb __P((usbd_xfer_handle, usbd_private_handle,
@@ -157,7 +161,9 @@
sc->sc_bulkout_no = uca->bulkout;
sc->sc_bulkin_no = uca->bulkin;
sc->sc_ibufsize = uca->ibufsize;
+ sc->sc_ibufsizepad = uca->ibufsizepad;
sc->sc_obufsize = uca->obufsize;
+ sc->sc_obufsizepad = uca->obufsizepad;
sc->sc_methods = uca->methods;
sc->sc_parent = uca->arg;
sc->sc_portno = uca->portno;
@@ -208,8 +214,8 @@
mn = self->dv_unit;
DPRINTF(("ucom_detach: maj=%d mn=%d\n", maj, mn));
vdevgone(maj, mn, mn, VCHR);
- vdevgone(maj, mn, mn | UCOMDIALOUT_MASK, VCHR);
- vdevgone(maj, mn, mn | UCOMCALLUNIT_MASK, VCHR);
+ vdevgone(maj, mn | UCOMDIALOUT_MASK, mn | UCOMDIALOUT_MASK, VCHR);
+ vdevgone(maj, mn | UCOMCALLUNIT_MASK, mn | UCOMCALLUNIT_MASK, VCHR);
/* Detach and free the tty. */
tty_detach(sc->sc_tty);
@@ -310,6 +316,15 @@
tp->t_dev = dev;
+ if (sc->sc_methods->ucom_open != NULL) {
+ error = sc->sc_methods->ucom_open(sc->sc_parent,
+ sc->sc_portno);
+ if (error) {
+ ucom_cleanup(sc);
+ return (error);
+ }
+ }
+
ucom_status_change(sc);
/*
@@ -375,7 +390,8 @@
usbd_close_pipe(sc->sc_bulkout_pipe);
return (ENOMEM);
}
- sc->sc_ibuf = usbd_alloc_buffer(sc->sc_ixfer, sc->sc_ibufsize);
+ sc->sc_ibuf = usbd_alloc_buffer(sc->sc_ixfer,
+ sc->sc_ibufsizepad);
if (sc->sc_ibuf == NULL) {
usbd_free_xfer(sc->sc_ixfer);
usbd_close_pipe(sc->sc_bulkin_pipe);
@@ -390,7 +406,8 @@
usbd_close_pipe(sc->sc_bulkout_pipe);
return (ENOMEM);
}
- sc->sc_obuf = usbd_alloc_buffer(sc->sc_oxfer, sc->sc_obufsize);
+ sc->sc_obuf = usbd_alloc_buffer(sc->sc_oxfer,
+ sc->sc_obufsizepad);
if (sc->sc_obuf == NULL) {
usbd_free_xfer(sc->sc_oxfer);
usbd_free_xfer(sc->sc_ixfer);
@@ -399,9 +416,6 @@
return (ENOMEM);
}
- if (sc->sc_methods->ucom_open != NULL)
- sc->sc_methods->ucom_open(sc->sc_parent, sc->sc_portno);
-
ucomstartread(sc);
}
sc->sc_opening = 0;
@@ -719,7 +733,7 @@
UCOM_SET_RTS, onoff);
}
-Static void
+void
ucom_status_change(sc)
struct ucom_softc *sc;
{
@@ -875,7 +889,11 @@
DPRINTF(("ucomstart: big buffer %d chars\n", cnt));
cnt = sc->sc_obufsize;
}
- memcpy(sc->sc_obuf, data, cnt);
+ if (sc->sc_methods->ucom_write != NULL)
+ sc->sc_methods->ucom_write(sc->sc_parent, sc->sc_portno,
+ sc->sc_obuf, data, &cnt);
+ else
+ memcpy(sc->sc_obuf, data, cnt);
DPRINTFN(4,("ucomstart: %d chars\n", cnt));
usbd_setup_xfer(sc->sc_oxfer, sc->sc_bulkout_pipe,
@@ -995,6 +1013,10 @@
usbd_get_xfer_status(xfer, NULL, (void **)&cp, &cc, NULL);
DPRINTFN(5,("ucomreadcb: got %d chars, tp=%p\n", cc, tp));
+ if (sc->sc_methods->ucom_read != NULL)
+ sc->sc_methods->ucom_read(sc->sc_parent, sc->sc_portno,
+ &cp, &cc);
+
s = spltty();
/* Give characters to tty layer. */
while (cc-- > 0) {
diff -r fde7eff67f37 -r 1c28fff20d15 sys/dev/usb/ucomvar.h
--- a/sys/dev/usb/ucomvar.h Fri Apr 14 14:20:02 2000 +0000
+++ b/sys/dev/usb/ucomvar.h Fri Apr 14 14:21:55 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ucomvar.h,v 1.4 2000/04/08 01:22:26 itojun Exp $ */
+/* $NetBSD: ucomvar.h,v 1.5 2000/04/14 14:21:55 augustss Exp $ */
/*
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -59,8 +59,12 @@
int (*ucom_param)__P((void *sc, int portno, struct termios *));
int (*ucom_ioctl)__P((void *sc, int portno, u_long cmd,
caddr_t data, int flag, struct proc *p));
- void (*ucom_open)__P((void *sc, int portno));
+ int (*ucom_open)__P((void *sc, int portno));
void (*ucom_close)__P((void *sc, int portno));
+ void (*ucom_read)__P((void *sc, int portno, u_char **ptr,
+ u_int32_t *count));
+ void (*ucom_write)__P((void *sc, int portno, u_char *to, u_char *from,
+ u_int32_t *count));
};
/* modem control register */
@@ -94,7 +98,9 @@
int bulkin;
int bulkout;
u_int ibufsize;
+ u_int ibufsizepad;
u_int obufsize;
+ u_int obufsizepad;
usbd_device_handle device;
usbd_interface_handle iface;
struct ucom_methods *methods;
@@ -103,3 +109,4 @@
int ucomprint __P((void *aux, const char *pnp));
int ucomsubmatch __P((struct device *parent, struct cfdata *cf, void *aux));
+void ucom_status_change __P((struct ucom_softc *));
diff -r fde7eff67f37 -r 1c28fff20d15 sys/dev/usb/umodem.c
--- a/sys/dev/usb/umodem.c Fri Apr 14 14:20:02 2000 +0000
+++ b/sys/dev/usb/umodem.c Fri Apr 14 14:21:55 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: umodem.c,v 1.26 2000/04/06 13:32:28 augustss Exp $ */
+/* $NetBSD: umodem.c,v 1.27 2000/04/14 14:21:55 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -141,6 +141,8 @@
umodem_ioctl,
NULL,
NULL,
+ NULL,
+ NULL,
};
USB_DECLARE_DRIVER(umodem);
@@ -276,6 +278,8 @@
/* bulkin, bulkout set above */
uca.ibufsize = UMODEMIBUFSIZE;
uca.obufsize = UMODEMOBUFSIZE;
+ uca.ibufsizepad = UMODEMIBUFSIZE;
+ uca.obufsizepad = UMODEMOBUFSIZE;
uca.device = sc->sc_udev;
uca.iface = sc->sc_data_iface;
uca.methods = &umodem_methods;
@@ -489,6 +493,7 @@
umodem_set(addr, portno, reg, onoff)
void *addr;
int portno;
+ int reg;
int onoff;
{
struct umodem_softc *sc = addr;
diff -r fde7eff67f37 -r 1c28fff20d15 sys/dev/usb/uvisor.c
--- a/sys/dev/usb/uvisor.c Fri Apr 14 14:20:02 2000 +0000
+++ b/sys/dev/usb/uvisor.c Fri Apr 14 14:21:55 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvisor.c,v 1.4 2000/04/06 13:32:28 augustss Exp $ */
+/* $NetBSD: uvisor.c,v 1.5 2000/04/14 14:21:55 augustss Exp $ */
/*
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -140,6 +140,8 @@
NULL,
NULL,
uvisor_close,
+ NULL,
+ NULL,
};
USB_DECLARE_DRIVER(uvisor);
@@ -237,6 +239,8 @@
/* bulkin, bulkout set above */
uca.ibufsize = UVISORIBUFSIZE;
uca.obufsize = UVISOROBUFSIZE;
+ uca.ibufsizepad = UVISORIBUFSIZE;
+ uca.obufsizepad = UVISOROBUFSIZE;
uca.device = dev;
uca.iface = iface;
uca.methods = &uvisor_methods;
Home |
Main Index |
Thread Index |
Old Index