ucomvar.h revision 1.18 1 /* $NetBSD: ucomvar.h,v 1.18 2010/03/13 16:28:13 scw Exp $ */
2
3 /*
4 * Copyright (c) 1999 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Lennart Augustsson (lennart (at) augustsson.net) at
9 * Carlstedt Research & Technology.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33
34 /* just for ucom_attach_args, not in the config namespace */
35 #define UCOM_UNK_PORTNO (-1)
36
37 struct ucom_softc;
38
39 struct ucom_methods {
40 void (*ucom_get_status)(void *sc, int portno, u_char *lsr, u_char *msr);
41 void (*ucom_set)(void *sc, int portno, int reg, int onoff);
42 #define UCOM_SET_DTR 1
43 #define UCOM_SET_RTS 2
44 #define UCOM_SET_BREAK 3
45 int (*ucom_param)(void *sc, int portno, struct termios *);
46 int (*ucom_ioctl)(void *sc, int portno, u_long cmd,
47 void *data, int flag, usb_proc_ptr p);
48 int (*ucom_open)(void *sc, int portno);
49 void (*ucom_close)(void *sc, int portno);
50 /*
51 * Note: The 'ptr' and 'count' pointers can be adjusted as follows:
52 * ptr: If consuming characters from the start of the buffer,
53 * advance '*ptr' to skip the data consumed.
54 * count: If consuming characters at the end of the buffer,
55 * decrement '*count' by the number of characters consumed.
56 * If consuming all characters, set '*count' to zero.
57 */
58 void (*ucom_read)(void *sc, int portno, u_char **ptr, u_int32_t *count);
59 void (*ucom_write)(void *sc, int portno, u_char *to, u_char *from,
60 u_int32_t *count);
61 };
62
63 /* modem control register */
64 #define UMCR_RTS 0x02 /* Request To Send */
65 #define UMCR_DTR 0x01 /* Data Terminal Ready */
66
67 /* line status register */
68 #define ULSR_RCV_FIFO 0x80
69 #define ULSR_TSRE 0x40 /* Transmitter empty: byte sent */
70 #define ULSR_TXRDY 0x20 /* Transmitter buffer empty */
71 #define ULSR_BI 0x10 /* Break detected */
72 #define ULSR_FE 0x08 /* Framing error: bad stop bit */
73 #define ULSR_PE 0x04 /* Parity error */
74 #define ULSR_OE 0x02 /* Overrun, lost incoming byte */
75 #define ULSR_RXRDY 0x01 /* Byte ready in Receive Buffer */
76 #define ULSR_RCV_MASK 0x1f /* Mask for incoming data or error */
77
78 /* modem status register */
79 /* All deltas are from the last read of the MSR. */
80 #define UMSR_DCD 0x80 /* Current Data Carrier Detect */
81 #define UMSR_RI 0x40 /* Current Ring Indicator */
82 #define UMSR_DSR 0x20 /* Current Data Set Ready */
83 #define UMSR_CTS 0x10 /* Current Clear to Send */
84 #define UMSR_DDCD 0x08 /* DCD has changed state */
85 #define UMSR_TERI 0x04 /* RI has toggled low to high */
86 #define UMSR_DDSR 0x02 /* DSR has changed state */
87 #define UMSR_DCTS 0x01 /* CTS has changed state */
88
89 struct ucom_attach_args {
90 int portno;
91 int bulkin;
92 int bulkout;
93 u_int ibufsize;
94 u_int ibufsizepad;
95 u_int obufsize;
96 u_int opkthdrlen;
97 const char *info; /* attach message */
98 usbd_device_handle device;
99 usbd_interface_handle iface;
100 struct ucom_methods *methods;
101 void *arg;
102 };
103
104 int ucomprint(void *, const char *);
105 int ucomsubmatch(device_t t, cfdata_t, const int *, void *);
106 void ucom_status_change(struct ucom_softc *);
107