comvar.h revision 1.20
1/*	$OpenBSD: comvar.h,v 1.20 2001/03/15 17:52:20 deraadt Exp $	*/
2/*	$NetBSD: comvar.h,v 1.5 1996/05/05 19:50:47 christos Exp $	*/
3
4/*
5 * Copyright (c) 1997 - 1998, Jason Downs.  All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 *    notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 *    notice, this list of conditions and the following disclaimer in the
14 *    documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 *    must display the following acknowledgement:
17 *      This product includes software developed by Jason Downs for the
18 *      OpenBSD system.
19 * 4. Neither the name(s) of the author(s) nor the name OpenBSD
20 *    may be used to endorse or promote products derived from this software
21 *    without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS
24 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT,
27 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 */
35/*
36 * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
37 *
38 * Redistribution and use in source and binary forms, with or without
39 * modification, are permitted provided that the following conditions
40 * are met:
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 Christopher G. Demetriou
49 *	for the NetBSD Project.
50 * 4. The name of the author may not be used to endorse or promote products
51 *    derived from this software without specific prior written permission
52 *
53 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
54 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
55 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
56 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
57 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
58 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
59 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
60 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
61 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
62 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
63 */
64
65#include <sys/timeout.h>
66
67struct commulti_attach_args {
68	int		ca_slave;		/* slave number */
69
70	bus_space_tag_t ca_iot;
71	bus_space_handle_t ca_ioh;
72	int		ca_iobase;
73	int		ca_noien;
74};
75
76#define	COM_IBUFSIZE	(2 * 512)
77#define	COM_IHIGHWATER	((3 * COM_IBUFSIZE) / 4)
78
79struct com_softc {
80	struct device sc_dev;
81	void *sc_ih;
82	bus_space_tag_t sc_iot;
83	struct tty *sc_tty;
84	struct timeout sc_dtr_tmo;
85	struct timeout sc_diag_tmo;
86	struct timeout sc_poll_tmo;
87
88	int sc_overflows;
89	int sc_floods;
90	int sc_errors;
91
92	int sc_halt;
93
94	int sc_iobase;
95	int sc_frequency;
96#ifdef COM_HAYESP
97	int sc_hayespbase;
98#endif
99
100	bus_space_handle_t sc_ioh;
101	bus_space_handle_t sc_hayespioh;
102
103	u_char sc_uarttype;
104#define COM_UART_UNKNOWN	0x00		/* unknown */
105#define COM_UART_8250		0x01		/* no fifo */
106#define COM_UART_16450		0x02		/* no fifo */
107#define COM_UART_16550		0x03		/* no working fifo */
108#define COM_UART_16550A		0x04		/* 16 byte fifo */
109#define COM_UART_ST16650	0x05		/* no working fifo */
110#define COM_UART_ST16650V2	0x06		/* 32 byte fifo */
111#define COM_UART_TI16750	0x07		/* 64 byte fifo */
112#define	COM_UART_XR16850	0x10		/* 128 byte fifo */
113
114	u_char sc_hwflags;
115#define	COM_HW_NOIEN	0x01
116#define	COM_HW_FIFO	0x02
117#define	COM_HW_HAYESP	0x04
118#define	COM_HW_CONSOLE	0x40
119#define	COM_HW_KGDB	0x80
120	u_char sc_swflags;
121#define	COM_SW_SOFTCAR	0x01
122#define	COM_SW_CLOCAL	0x02
123#define	COM_SW_CRTSCTS	0x04
124#define	COM_SW_MDMBUF	0x08
125#define	COM_SW_PPS	0x10
126	int	sc_fifolen;
127	u_char sc_msr, sc_mcr, sc_lcr, sc_ier;
128	u_char sc_dtr;
129
130	u_char	sc_cua;
131
132	u_char	sc_initialize;		/* force initialization */
133
134	u_char *sc_ibuf, *sc_ibufp, *sc_ibufhigh, *sc_ibufend;
135	u_char sc_ibufs[2][COM_IBUFSIZE];
136
137	/* power management hooks */
138	int (*enable) __P((struct com_softc *));
139	void (*disable) __P((struct com_softc *));
140	int enabled;
141};
142
143int	comprobe1 __P((bus_space_tag_t, bus_space_handle_t));
144void	cominit __P((bus_space_tag_t, bus_space_handle_t, int));
145int	comstop __P((struct tty *, int));
146int	comintr __P((void *));
147int	com_detach __P((struct device *, int));
148int	com_activate __P((struct device *, enum devact));
149
150#ifdef COM_HAYESP
151int comprobeHAYESP __P((bus_space_handle_t hayespioh, struct com_softc *sc));
152#endif
153void	comdiag		__P((void *));
154int	comspeed	__P((long, long));
155u_char	com_cflag2lcr	__P((tcflag_t));
156int	comparam	__P((struct tty *, struct termios *));
157void	comstart	__P((struct tty *));
158void	compoll		__P((void *));
159
160struct consdev;
161void	comcnprobe	__P((struct consdev *));
162int	comcnattach	__P((bus_space_tag_t, int, int, int, tcflag_t));
163void	comcninit	__P((struct consdev *));
164int	comcngetc	__P((dev_t));
165void	comcnputc	__P((dev_t, int));
166void	comcnpollc	__P((dev_t, int));
167int	com_common_getc	__P((bus_space_tag_t, bus_space_handle_t));
168void	com_common_putc	__P((bus_space_tag_t, bus_space_handle_t, int));
169
170#if defined(DDB) || defined(KGDB)
171void	com_enable_debugport	__P((struct com_softc *));
172#endif
173
174#ifdef KGDB
175int	com_kgdb_attach	__P((bus_space_tag_t, int, int, int, tcflag_t));
176int	kgdbintr __P((void *));
177#endif
178
179int comcnattach __P((bus_space_tag_t, int, int, int, tcflag_t));
180
181extern int comdefaultrate;
182extern int comconsaddr;
183extern int comconsinit;
184extern int comconsattached;
185extern bus_space_tag_t comconsiot;
186extern bus_space_handle_t comconsioh;
187extern tcflag_t comconscflag;
188