2007-03-07 03:41:16 +03:00
|
|
|
.\" $NetBSD: ucom.9,v 1.14 2007/03/07 00:41:17 dogcow Exp $
|
2000-04-15 21:20:26 +04:00
|
|
|
.\"
|
|
|
|
.\" Copyright (c) 2000 The NetBSD Foundation, Inc.
|
|
|
|
.\" All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
.\" by Lennart Augustsson.
|
|
|
|
.\"
|
|
|
|
.\" 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.
|
|
|
|
.\" 3. All advertising materials mentioning features or use of this software
|
|
|
|
.\" must display the following acknowledgement:
|
|
|
|
.\" This product includes software developed by the NetBSD
|
|
|
|
.\" Foundation, Inc. and its contributors.
|
|
|
|
.\" 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
|
|
.\" contributors may be used to endorse or promote products derived
|
|
|
|
.\" from this software without specific prior written permission.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
.\" ``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 FOUNDATION 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.
|
|
|
|
.\"
|
2005-12-20 22:53:14 +03:00
|
|
|
.Dd December 20, 2005
|
2000-04-15 21:20:26 +04:00
|
|
|
.Dt UCOM 9
|
|
|
|
.Os
|
|
|
|
.Sh NAME
|
|
|
|
.Nm ucom
|
|
|
|
.Nd interface for USB tty like devices
|
|
|
|
.Sh DESCRIPTION
|
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
driver is a (relatively) easy way to make a USB device look like
|
|
|
|
a
|
|
|
|
.Xr tty 4 .
|
|
|
|
It basically takes two bulk pipes, input and output, and makes
|
|
|
|
a tty out of them.
|
|
|
|
This is useful for a number of device types, e.g., serial ports
|
2001-04-09 23:12:44 +04:00
|
|
|
(see
|
2001-06-21 15:59:00 +04:00
|
|
|
.Xr uftdi 4 ) ,
|
2001-04-09 23:12:44 +04:00
|
|
|
modems (see
|
2001-06-21 15:59:00 +04:00
|
|
|
.Xr umodem 4 ) ,
|
2001-04-09 23:12:44 +04:00
|
|
|
and devices that traditionally look like a tty (see
|
2001-06-21 15:59:00 +04:00
|
|
|
.Xr uvisor 4 ) .
|
2000-04-15 21:20:26 +04:00
|
|
|
.Pp
|
|
|
|
Communication between the real driver and the
|
|
|
|
.Nm
|
|
|
|
driver is via the attachment arguments (when attached) and
|
|
|
|
via the
|
|
|
|
.Va ucom_methods
|
|
|
|
struct
|
|
|
|
.Sh ATTACHMENT
|
|
|
|
.Bd -literal
|
|
|
|
struct ucom_attach_args {
|
|
|
|
int portno;
|
|
|
|
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;
|
|
|
|
void *arg;
|
|
|
|
};
|
|
|
|
.Ed
|
2001-12-26 04:08:41 +03:00
|
|
|
.Pp
|
2000-04-15 21:20:26 +04:00
|
|
|
.Bl -tag -width indent
|
|
|
|
.It Dv int portno
|
2001-06-21 15:59:00 +04:00
|
|
|
identifies the port if the devices should have more than one
|
2000-04-15 21:20:26 +04:00
|
|
|
.Nm
|
2002-10-14 17:43:14 +04:00
|
|
|
attached.
|
|
|
|
Use the value
|
2000-04-15 21:20:26 +04:00
|
|
|
.Dv UCOM_UNK_PORTNO
|
|
|
|
if there is only one port.
|
|
|
|
.It Dv int bulkin
|
|
|
|
the number of the bulk input pipe.
|
|
|
|
.It Dv int bulkout
|
|
|
|
the number of the bulk output pipe.
|
|
|
|
.It Dv u_int ibufsize
|
|
|
|
the size of the read requests on the bulk in pipe.
|
|
|
|
.It Dv u_int ibufsizepad
|
2002-10-14 17:43:14 +04:00
|
|
|
the size of the input buffer.
|
|
|
|
This is usually the same as
|
2002-06-01 13:16:08 +04:00
|
|
|
.Dv ibufsize .
|
2000-04-15 21:20:26 +04:00
|
|
|
.It Dv u_int obufsize
|
|
|
|
the size of the write requests on the bulk out pipe.
|
|
|
|
.It Dv u_int ibufsizepad
|
2002-10-14 17:43:14 +04:00
|
|
|
the size of the output buffer.
|
|
|
|
This is usually the same as
|
2002-06-01 13:16:08 +04:00
|
|
|
.Dv obufsize .
|
2000-04-15 21:20:26 +04:00
|
|
|
.It Dv usbd_device_handle device
|
|
|
|
a handle to the device.
|
|
|
|
.It usbd_interface_handle iface
|
|
|
|
a handle to the interface that should be used.
|
|
|
|
.It struct ucom_methods *methods
|
|
|
|
a pointer to the methods that the
|
|
|
|
.Nm
|
|
|
|
driver should use for further communication with the driver.
|
|
|
|
.It void *arg
|
|
|
|
the value that should be passed as first argument to each method.
|
|
|
|
.El
|
|
|
|
.Sh METHODS
|
|
|
|
The
|
|
|
|
.Dv ucom_methods
|
|
|
|
struct contains a number of function pointers used by the
|
|
|
|
.Nm
|
2002-10-14 17:43:14 +04:00
|
|
|
driver at various stages.
|
|
|
|
If the device is not interested in being called at a particular point
|
|
|
|
it should just use a
|
2000-04-15 21:20:26 +04:00
|
|
|
.Dv NULL
|
|
|
|
pointer and the
|
|
|
|
.Nm
|
|
|
|
driver will use a sensible default.
|
|
|
|
.Bd -literal
|
|
|
|
struct ucom_methods {
|
2001-11-28 19:49:02 +03:00
|
|
|
void (*ucom_get_status)(void *sc, int portno,
|
|
|
|
u_char *lsr, u_char *msr);
|
|
|
|
void (*ucom_set)(void *sc, int portno, int reg, int onoff);
|
2000-04-15 21:20:26 +04:00
|
|
|
#define UCOM_SET_DTR 1
|
|
|
|
#define UCOM_SET_RTS 2
|
|
|
|
#define UCOM_SET_BREAK 3
|
2001-11-28 19:49:02 +03:00
|
|
|
int (*ucom_param)(void *sc, int portno, struct termios *);
|
|
|
|
int (*ucom_ioctl)(void *sc, int portno, u_long cmd,
|
2007-03-07 03:41:16 +03:00
|
|
|
void *data, int flag, struct lwp *l);
|
2001-11-28 19:49:02 +03:00
|
|
|
int (*ucom_open)(void *sc, int portno);
|
|
|
|
void (*ucom_close)(void *sc, int portno);
|
|
|
|
void (*ucom_read)(void *sc, int portno, u_char **ptr,
|
2005-12-26 22:40:14 +03:00
|
|
|
uint32_t *count);
|
2001-11-28 19:49:02 +03:00
|
|
|
void (*ucom_write)(void *sc, int portno, u_char *to,
|
2005-12-26 22:40:14 +03:00
|
|
|
u_char *from, uint32_t *count);
|
2000-04-15 21:20:26 +04:00
|
|
|
};
|
|
|
|
.Ed
|
2001-12-26 04:08:41 +03:00
|
|
|
.Pp
|
2000-04-15 21:20:26 +04:00
|
|
|
.Bl -tag -width indent
|
2000-04-28 13:37:43 +04:00
|
|
|
.It Fn "void (*ucom_get_status)" "void *sc, int portno, u_char *lsr, u_char *msr"
|
2000-04-15 21:20:26 +04:00
|
|
|
get the status of port
|
2000-04-28 13:37:43 +04:00
|
|
|
.Fa portno .
|
2000-04-15 21:20:26 +04:00
|
|
|
The status consists of the line status,
|
2000-04-28 13:37:43 +04:00
|
|
|
.Fa lsr ,
|
2000-04-15 21:20:26 +04:00
|
|
|
and the modem status
|
2000-04-28 13:37:43 +04:00
|
|
|
.Fa msr .
|
2000-04-15 21:20:26 +04:00
|
|
|
The contents of these two bytes is exactly as for a 16550 UART.
|
2000-04-28 13:37:43 +04:00
|
|
|
.It Fn "void (*ucom_set)" "void *sc, int portno, int reg, int onoff"
|
2000-04-15 21:20:26 +04:00
|
|
|
Set (or unset) a particular feature of a port.
|
2000-04-28 13:37:43 +04:00
|
|
|
.It Fn "int (*ucom_param)" "void *sc, int portno, struct termios *t"
|
2000-04-15 21:20:26 +04:00
|
|
|
Set the speed, number of data bit, stop bits, and parity of a port
|
2001-04-09 23:12:44 +04:00
|
|
|
according to the
|
2000-04-15 21:20:26 +04:00
|
|
|
.Xr termios 4
|
|
|
|
struct.
|
2007-03-07 03:41:16 +03:00
|
|
|
.It Fn "int (*ucom_ioctl)" "void *sc, int portno, u_long cmd, void *data, int flag, struct lwp *l"
|
2000-04-15 21:20:26 +04:00
|
|
|
implements any non-standard
|
2001-04-09 23:12:44 +04:00
|
|
|
.Xr ioctl 2
|
2000-04-15 21:20:26 +04:00
|
|
|
that a device needs.
|
2000-04-28 13:37:43 +04:00
|
|
|
.It Fn "int (*ucom_open)" "void *sc, int portno"
|
2000-04-15 21:20:26 +04:00
|
|
|
called just before the
|
|
|
|
.Nm
|
|
|
|
driver opens the bulk pipes for the port.
|
2000-04-28 13:37:43 +04:00
|
|
|
.It Fn "void (*ucom_close)" "void *sc, int portno"
|
2000-04-15 21:20:26 +04:00
|
|
|
called just after the
|
|
|
|
.Nm
|
|
|
|
driver closes the bulk pipes for the port.
|
2005-12-26 22:40:14 +03:00
|
|
|
.It Fn "void (*ucom_read)" "void *sc, int portno, u_char **ptr, uint32_t *count"
|
2000-04-15 21:20:26 +04:00
|
|
|
if the data delivered on the bulk pipe is not just the raw input characters
|
|
|
|
this routine needs to adjust
|
2000-04-28 13:37:43 +04:00
|
|
|
.Fa ptr
|
2000-04-15 21:20:26 +04:00
|
|
|
and
|
2000-04-28 13:37:43 +04:00
|
|
|
.Fa count
|
2000-04-15 21:20:26 +04:00
|
|
|
so that they tell where to find the given number of raw characters.
|
2005-12-26 22:40:14 +03:00
|
|
|
.It Fn "void (*ucom_write)" "void *sc, int portno, u_char *dst, u_char *src, uint32_t *count"
|
2000-04-15 21:20:26 +04:00
|
|
|
if the data written to the bulk pipe is not just the raw characters then
|
|
|
|
this routine needs to copy
|
2000-04-28 13:37:43 +04:00
|
|
|
.Fa count
|
|
|
|
raw characters from
|
|
|
|
.Fa src
|
2000-04-15 21:20:26 +04:00
|
|
|
into the buffer at
|
2000-04-28 13:37:43 +04:00
|
|
|
.Fa dst
|
2002-10-14 17:43:14 +04:00
|
|
|
and do the appropriate padding.
|
|
|
|
The
|
2000-04-28 13:37:43 +04:00
|
|
|
.Fa count
|
2000-04-15 21:20:26 +04:00
|
|
|
should be updated to the new size.
|
|
|
|
The buffer at
|
2000-04-28 13:37:43 +04:00
|
|
|
.Fa src
|
2000-04-15 21:20:26 +04:00
|
|
|
is at most
|
2000-04-28 13:37:43 +04:00
|
|
|
.Va ibufsize
|
2000-04-15 21:20:26 +04:00
|
|
|
bytes and the buffer
|
|
|
|
at
|
2000-04-28 13:37:43 +04:00
|
|
|
.Fa dst
|
2000-04-15 21:20:26 +04:00
|
|
|
is
|
2000-04-28 13:37:43 +04:00
|
|
|
.Va ibufsizepad
|
2000-04-15 21:20:26 +04:00
|
|
|
bytes.
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
Apart from these methods there is a function
|
2002-02-07 06:15:06 +03:00
|
|
|
.Bl -tag -width 5n -offset 5n
|
2000-04-28 13:37:43 +04:00
|
|
|
.It Fn "void ucom_status_change" "struct ucom_softc *"
|
2000-04-15 21:20:26 +04:00
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
which should be called by the driver whenever it notices a status change.
|
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr tty 4 ,
|
|
|
|
.Xr uftdi 4 ,
|
|
|
|
.Xr umodem 4 ,
|
|
|
|
.Xr usb 4 ,
|
|
|
|
.Xr uvisor 4
|
|
|
|
.Sh HISTORY
|
|
|
|
This
|
|
|
|
.Nm
|
|
|
|
interface first appeared in
|
|
|
|
.Nx 1.5 .
|