comvar.h revision 1.15 1 /* $NetBSD: comvar.h,v 1.15 1997/09/16 20:34:29 is Exp $ */
2
3 /*
4 * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement:
16 * This product includes software developed by Christopher G. Demetriou
17 * for the NetBSD Project.
18 * 4. The name of the author may not be used to endorse or promote products
19 * derived from this software without specific prior written permission
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 int comcnattach __P((bus_space_tag_t, int, int, int, tcflag_t));
34
35 #ifdef KGDB
36 int com_kgdb_attach __P((bus_space_tag_t, int, int, int, tcflag_t));
37 #endif
38
39 int com_is_console __P((bus_space_tag_t, int, bus_space_handle_t *));
40
41 /* Hardware flag masks */
42 #define COM_HW_NOIEN 0x01
43 #define COM_HW_FIFO 0x02
44 #define COM_HW_HAYESP 0x04
45 #define COM_HW_CONSOLE 0x40
46 #define COM_HW_KGDB 0x80
47
48 /* Buffer size for character buffer */
49 #define RXBUFSIZE 2048 /* More than enough.. */
50 #define RXBUFMASK (RXBUFSIZE - 1) /* Only iff previous is a power of 2 */
51 #define RXHIWAT ((RXBUFSIZE * 1) / 4)
52 #define RXLOWAT ((RXBUFSIZE * 3) / 4)
53
54 struct com_softc {
55 struct device sc_dev;
56 void *sc_ih;
57 void *sc_si;
58 struct tty *sc_tty;
59
60 int sc_overflows;
61 int sc_floods;
62 int sc_errors;
63
64 int sc_iobase;
65 int sc_frequency;
66
67 bus_space_tag_t sc_iot;
68 bus_space_handle_t sc_ioh;
69 bus_space_handle_t sc_hayespioh;
70
71 u_char sc_hwflags;
72 u_char sc_swflags;
73 int sc_fifolen;
74
75 u_char sc_msr, sc_msr_delta, sc_msr_mask, sc_mcr, sc_mcr_active, sc_lcr,
76 sc_ier, sc_fifo, sc_dlbl, sc_dlbh;
77 u_char sc_mcr_dtr, sc_mcr_rts, sc_msr_cts, sc_msr_dcd;
78
79 int sc_r_hiwat;
80 int sc_r_lowat;
81 volatile u_int sc_rbget;
82 volatile u_int sc_rbput;
83 volatile u_int sc_rbavail;
84 u_char sc_rbuf[RXBUFSIZE];
85 u_char sc_lbuf[RXBUFSIZE];
86
87 u_char *sc_tba;
88 int sc_tbc,
89 sc_heldtbc;
90
91 volatile u_char sc_rx_flags,
92 #define RX_TTY_BLOCKED 0x01
93 #define RX_TTY_OVERFLOWED 0x02
94 #define RX_IBUF_BLOCKED 0x04
95 #define RX_IBUF_OVERFLOWED 0x08
96 #define RX_ANY_BLOCK 0x0f
97 sc_tx_busy,
98 sc_tx_done,
99 sc_tx_stopped,
100 sc_st_check,
101 sc_rx_ready;
102
103 volatile u_char sc_heldchange;
104 };
105
106 /* Macros to clear/set/test flags. */
107 #define SET(t, f) (t) |= (f)
108 #define CLR(t, f) (t) &= ~(f)
109 #define ISSET(t, f) ((t) & (f))
110
111 int comprobe1 __P((bus_space_tag_t, bus_space_handle_t, int));
112 int comintr __P((void *));
113 void com_attach_subr __P((struct com_softc *));
114 int cominit __P((bus_space_tag_t, int, int, int, tcflag_t,
115 bus_space_handle_t *));
116
117 #ifndef __GENERIC_SOFT_INTERRUPTS
118 #ifdef alpha
119 #define IPL_SERIAL IPL_TTY
120 #define splserial() spltty()
121 #define IPL_SOFTSERIAL IPL_TTY
122 #define splsoftserial() spltty()
123 #endif
124 #endif
125