comvar.h revision 1.24 1 /* $NetBSD: comvar.h,v 1.24 1998/06/11 02:01:58 thorpej 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 #include "rnd.h"
34 #if NRND > 0 && defined(RND_COM)
35 #include <sys/rnd.h>
36 #endif
37
38 #include <sys/timepps.h>
39
40 int comcnattach __P((bus_space_tag_t, int, int, int, tcflag_t));
41
42 #ifdef KGDB
43 int com_kgdb_attach __P((bus_space_tag_t, int, int, int, tcflag_t));
44 #endif
45
46 int com_is_console __P((bus_space_tag_t, int, bus_space_handle_t *));
47
48 /* Hardware flag masks */
49 #define COM_HW_NOIEN 0x01
50 #define COM_HW_FIFO 0x02
51 #define COM_HW_HAYESP 0x04
52 #define COM_HW_FLOW 0x08
53 #define COM_HW_DEV_OK 0x20
54 #define COM_HW_CONSOLE 0x40
55 #define COM_HW_KGDB 0x80
56
57 /* Buffer size for character buffer */
58 #define COM_RING_SIZE 2048
59
60 struct com_softc {
61 struct device sc_dev;
62 void *sc_si;
63 struct tty *sc_tty;
64
65 int sc_iobase; /* XXX ISA-centric name */
66 int sc_frequency;
67
68 bus_space_tag_t sc_iot;
69 bus_space_handle_t sc_ioh;
70 bus_space_handle_t sc_hayespioh;
71
72 u_int sc_overflows,
73 sc_floods,
74 sc_errors;
75
76 int sc_hwflags,
77 sc_swflags;
78 u_int sc_fifolen;
79
80 u_int sc_r_hiwat,
81 sc_r_lowat;
82 u_char *volatile sc_rbget,
83 *volatile sc_rbput;
84 volatile u_int sc_rbavail;
85 u_char *sc_rbuf,
86 *sc_ebuf;
87
88 u_char *sc_tba;
89 u_int sc_tbc,
90 sc_heldtbc;
91
92 volatile u_char sc_rx_flags,
93 #define RX_TTY_BLOCKED 0x01
94 #define RX_TTY_OVERFLOWED 0x02
95 #define RX_IBUF_BLOCKED 0x04
96 #define RX_IBUF_OVERFLOWED 0x08
97 #define RX_ANY_BLOCK 0x0f
98 sc_tx_busy,
99 sc_tx_done,
100 sc_tx_stopped,
101 sc_st_check,
102 sc_rx_ready;
103
104 volatile u_char sc_heldchange;
105 volatile u_char sc_msr, sc_msr_delta, sc_msr_mask, sc_mcr,
106 sc_mcr_active, sc_lcr, sc_ier, sc_fifo, sc_dlbl, sc_dlbh, sc_efr;
107 u_char sc_mcr_dtr, sc_mcr_rts, sc_msr_cts, sc_msr_dcd;
108
109 /* power management hooks */
110 int (*enable) __P((struct com_softc *));
111 void (*disable) __P((struct com_softc *));
112 int enabled;
113
114 /* PPS signal on DCD, with or without inkernel clock disciplining */
115 int sc_ppsassertmask; /* pps signal mask */
116 int sc_ppsassert; /* pps edge mask */
117 int sc_ppsclearmask; /* pps signal mask */
118 int sc_ppsclear; /* pps edge mask */
119 pps_info_t ppsinfo;
120 pps_params_t ppsparam;
121
122 #if NRND > 0 && defined(RND_COM)
123 rndsource_element_t rnd_source;
124 #endif
125 };
126
127 /* Macros to clear/set/test flags. */
128 #define SET(t, f) (t) |= (f)
129 #define CLR(t, f) (t) &= ~(f)
130 #define ISSET(t, f) ((t) & (f))
131
132 int comprobe1 __P((bus_space_tag_t, bus_space_handle_t, int));
133 int comintr __P((void *));
134 void com_attach_subr __P((struct com_softc *));
135 int cominit __P((bus_space_tag_t, int, int, int, tcflag_t,
136 bus_space_handle_t *));
137
138 #ifndef __GENERIC_SOFT_INTERRUPTS
139 #if defined(alpha) || defined(arm32)
140 #define __NO_SOFT_SERIAL_INTERRUPT
141 #endif
142 #ifdef __NO_SOFT_SERIAL_INTERRUPT
143 #define IPL_SERIAL IPL_TTY
144 #define splserial() spltty()
145 #define IPL_SOFTSERIAL IPL_TTY
146 #define splsoftserial() spltty()
147 #endif
148 #endif
149