UCOM(9) | Kernel Developer's Manual | UCOM(9) |
ucom
—
ucom
driver is a (relatively) easy way to make a USB
device look like a 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 (see
uftdi(4)), modems (see
umodem(4)), and devices that
traditionally look like a tty (see
uvisor(4)).
Communication between the real driver and the
ucom
driver is via the attachment arguments (when
attached) and via the ucom_methods struct
struct ucom_attach_args { int ucaa_portno; int ucaa_bulkin; int ucaa_bulkout; u_int ucaa_ibufsize; u_int ucaa_ibufsizepad; u_int ucaa_obufsize; u_int ucaa_opkthdrlen; const char *ucaa_info; struct usbd_device *ucaa_device; struct usbd_interface *ucaa_iface; const struct ucom_methods *ucaa_methods; void *ucaa_arg; };
int
ucaa_portno
ucom
attached. Use the value
UCOM_UNK_PORTNO
if there is only one port.int
ucaa_bulkin
int
ucaa_bulkout
u_int
ucaa_ibufsize
u_int
ucaa_ibufsizepad
ibufsize
.u_int
ucaa_obufsize
u_int
ucaa_ibufsizepad
ucaa_obufsize
.struct
usbd_device *ucaa_device
ucom
driver
should use for further communication with the driver.ucom_methods
struct contains a number of function
pointers used by the ucom
driver at various stages. If
the device is not interested in being called at a particular point it should
just use a NULL
pointer and the
ucom
driver will use a sensible default.
struct ucom_methods { 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); #define UCOM_SET_DTR 1 #define UCOM_SET_RTS 2 #define UCOM_SET_BREAK 3 int (*ucom_param)(void *sc, int portno, struct termios *); int (*ucom_ioctl)(void *sc, int portno, u_long cmd, void *data, int flag, proc_t *p); int (*ucom_open)(void *sc, int portno); void (*ucom_close)(void *sc, int portno); void (*ucom_read)(void *sc, int portno, u_char **ptr, uint32_t *count); void (*ucom_write)(void *sc, int portno, u_char *to, u_char *from, uint32_t *count); };
(*ucom_get_status)
(void *sc,
int portno, u_char *lsr,
u_char *msr)(*ucom_set)
(void *sc,
int portno, int reg,
int onoff)(*ucom_param)
(void *sc,
int portno, struct termios
*t)(*ucom_ioctl)
(void *sc,
int portno, u_long cmd,
void *data, int flag,
proc_t *p)(*ucom_open)
(void *sc,
int portno)ucom
driver opens the bulk
pipes for the port.(*ucom_close)
(void *sc,
int portno)ucom
driver closes the bulk
pipes for the port.(*ucom_read)
(void *sc,
int portno, u_char **ptr,
uint32_t *count)(*ucom_write)
(void *sc,
int portno, u_char *dst,
u_char *src, uint32_t
*count)Apart from these methods there is a function
ucom_status_change
(struct ucom_softc
*)which should be called by the driver whenever it notices a status change.
ucom
interface first appeared in
NetBSD 1.5.
September 12, 2016 | NetBSD 9.2 |