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 /* line status register */
108 #define ULSR_RCV_FIFO 0x80
109 #define ULSR_TSRE 0x40 /* Transmitter empty: byte sent */
110 #define ULSR_TXRDY 0x20 /* Transmitter buffer empty */
111 #define ULSR_BI 0x10 /* Break detected */
112 #define ULSR_FE 0x08 /* Framing error: bad stop bit */
113 #define ULSR_PE 0x04 /* Parity error */
114 #define ULSR_OE 0x02 /* Overrun, lost incoming byte */
115 #define ULSR_RXRDY 0x01 /* Byte ready in Receive Buffer */
116 #define ULSR_RCV_MASK 0x1f /* Mask for incoming data or error */
118 /* ucom state declarations */
119 #define UCS_RXSTOP 0x0001 /* Rx stopped */
120 #define UCS_RTS_IFLOW 0x0008 /* use RTS input flow control */
123 USBBASEDEVICE sc_dev; /* base device */
124 usbd_device_handle sc_udev; /* USB device */
125 usbd_interface_handle sc_iface; /* data interface */
127 int sc_bulkin_no; /* bulk in endpoint address */
128 usbd_pipe_handle sc_bulkin_pipe; /* bulk in pipe */
129 usbd_xfer_handle sc_ixfer; /* read request */
130 u_char *sc_ibuf; /* read buffer */
131 u_int sc_ibufsize; /* read buffer size */
132 u_int sc_ibufsizepad; /* read buffer size padded */
134 int sc_bulkout_no; /* bulk out endpoint address */
135 usbd_pipe_handle sc_bulkout_pipe;/* bulk out pipe */
136 usbd_xfer_handle sc_oxfer; /* write request */
137 u_char *sc_obuf; /* write buffer */
138 u_int sc_obufsize; /* write buffer size */
139 u_int sc_opkthdrlen; /* header length of
142 struct ucom_callback *sc_callback;
146 struct tty *sc_tty; /* our tty */
156 u_char sc_dying; /* disconnecting */
160 extern devclass_t ucom_devclass;
162 int ucom_attach(struct ucom_softc *);
163 int ucom_detach(struct ucom_softc *);
164 void ucom_status_change(struct ucom_softc *);