1 /* $NetBSD: ucomvar.h,v 1.9 2001/01/23 21:56:17 augustss Exp $ */
5 * Copyright (c) 2001-2002, Shunsuke Akiyama <akiyama@jp.FreeBSD.org>.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * Copyright (c) 1999 The NetBSD Foundation, Inc.
32 * All rights reserved.
34 * This code is derived from software contributed to The NetBSD Foundation
35 * by Lennart Augustsson (lennart@augustsson.net) at
36 * Carlstedt Research & Technology.
38 * Redistribution and use in source and binary forms, with or without
39 * modification, are permitted provided that the following conditions
41 * 1. Redistributions of source code must retain the above copyright
42 * notice, this list of conditions and the following disclaimer.
43 * 2. Redistributions in binary form must reproduce the above copyright
44 * notice, this list of conditions and the following disclaimer in the
45 * documentation and/or other materials provided with the distribution.
46 * 3. All advertising materials mentioning features or use of this software
47 * must display the following acknowledgement:
48 * This product includes software developed by the NetBSD
49 * Foundation, Inc. and its contributors.
50 * 4. Neither the name of The NetBSD Foundation nor the names of its
51 * contributors may be used to endorse or promote products derived
52 * from this software without specific prior written permission.
54 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
55 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
56 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
57 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
58 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
59 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
60 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
61 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
62 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
63 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
64 * POSSIBILITY OF SUCH DAMAGE.
67 /* Module interface related macros */
71 #define UCOM_PREFVER UCOM_MODVER
74 /* Macros to clear/set/test flags. */
75 #define SET(t, f) (t) |= (f)
76 #define CLR(t, f) (t) &= ~((unsigned)(f))
77 #define ISSET(t, f) ((t) & (f))
79 #define UCOM_CALLOUT_MASK 0x80
81 #define UCOMUNIT_MASK 0x3ff7f
82 #define UCOMDIALOUT_MASK 0x80000
83 #define UCOMCALLUNIT_MASK 0x40000
85 #define UCOMUNIT(x) (minor(x) & UCOMUNIT_MASK)
86 #define UCOMDIALOUT(x) (minor(x) & UCOMDIALOUT_MASK)
87 #define UCOMCALLUNIT(x) (minor(x) & UCOMCALLUNIT_MASK)
89 #define UCOM_UNK_PORTNO -1 /* XXX */
93 struct ucom_callback {
94 void (*ucom_get_status)(void *, int, u_char *, u_char *);
95 void (*ucom_set)(void *, int, int, int);
96 #define UCOM_SET_DTR 1
97 #define UCOM_SET_RTS 2
98 #define UCOM_SET_BREAK 3
99 int (*ucom_param)(void *, int, struct termios *);
100 int (*ucom_ioctl)(void *, int, u_long, caddr_t, int, usb_proc_ptr);
101 int (*ucom_open)(void *, int);
102 void (*ucom_close)(void *, int);
103 void (*ucom_read)(void *, int, u_char **, u_int32_t *);
104 void (*ucom_write)(void *, int, u_char *, u_char *, u_int32_t *);
107 /* modem control register */
108 #define UMCR_RTS 0x02 /* Request To Send */
109 #define UMCR_DTR 0x01 /* Data Terminal Ready */
111 /* line status register */
112 #define ULSR_RCV_FIFO 0x80
113 #define ULSR_TSRE 0x40 /* Transmitter empty: byte sent */
114 #define ULSR_TXRDY 0x20 /* Transmitter buffer empty */
115 #define ULSR_BI 0x10 /* Break detected */
116 #define ULSR_FE 0x08 /* Framing error: bad stop bit */
117 #define ULSR_PE 0x04 /* Parity error */
118 #define ULSR_OE 0x02 /* Overrun, lost incoming byte */
119 #define ULSR_RXRDY 0x01 /* Byte ready in Receive Buffer */
120 #define ULSR_RCV_MASK 0x1f /* Mask for incoming data or error */
122 /* modem status register */
123 /* All deltas are from the last read of the MSR. */
124 #define UMSR_DCD 0x80 /* Current Data Carrier Detect */
125 #define UMSR_RI 0x40 /* Current Ring Indicator */
126 #define UMSR_DSR 0x20 /* Current Data Set Ready */
127 #define UMSR_CTS 0x10 /* Current Clear to Send */
128 #define UMSR_DDCD 0x08 /* DCD has changed state */
129 #define UMSR_TERI 0x04 /* RI has toggled low to high */
130 #define UMSR_DDSR 0x02 /* DSR has changed state */
131 #define UMSR_DCTS 0x01 /* CTS has changed state */
133 /* ucom state declarations */
134 #define UCS_RXSTOP 0x0001 /* Rx stopped */
135 #define UCS_RTS_IFLOW 0x0008 /* use RTS input flow control */
138 USBBASEDEVICE sc_dev; /* base device */
139 usbd_device_handle sc_udev; /* USB device */
140 usbd_interface_handle sc_iface; /* data interface */
142 int sc_bulkin_no; /* bulk in endpoint address */
143 usbd_pipe_handle sc_bulkin_pipe; /* bulk in pipe */
144 usbd_xfer_handle sc_ixfer; /* read request */
145 u_char *sc_ibuf; /* read buffer */
146 u_int sc_ibufsize; /* read buffer size */
147 u_int sc_ibufsizepad; /* read buffer size padded */
149 int sc_bulkout_no; /* bulk out endpoint address */
150 usbd_pipe_handle sc_bulkout_pipe;/* bulk out pipe */
151 usbd_xfer_handle sc_oxfer; /* write request */
152 u_char *sc_obuf; /* write buffer */
153 u_int sc_obufsize; /* write buffer size */
154 u_int sc_opkthdrlen; /* header length of
157 struct ucom_callback *sc_callback;
161 struct tty *sc_tty; /* our tty */
172 u_char sc_opening; /* lock during open */
174 u_char sc_dying; /* disconnecting */
176 dev_t dev; /* special device node */
179 extern devclass_t ucom_devclass;
181 int ucom_attach(struct ucom_softc *);
182 int ucom_detach(struct ucom_softc *);
183 void ucom_status_change(struct ucom_softc *);