FreeBSD/Linux Kernel Cross Reference
sys/dev/ic/comvar.h
1 /* $NetBSD: comvar.h,v 1.47 2003/11/08 01:59:38 simonb 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 #include "opt_multiprocessor.h"
35 #include "opt_lockdebug.h"
36 #include "opt_com.h"
37 #include "opt_kgdb.h"
38
39 #if NRND > 0 && defined(RND_COM)
40 #include <sys/rnd.h>
41 #endif
42
43 #include <sys/callout.h>
44 #include <sys/timepps.h>
45 #if (defined(MULTIPROCESSOR) || defined(LOCKDEBUG)) && defined(COM_MPLOCK)
46 #include <sys/lock.h>
47 #endif
48
49 int comcnattach __P((bus_space_tag_t, bus_addr_t, int, int, int, tcflag_t));
50
51 #ifdef KGDB
52 int com_kgdb_attach __P((bus_space_tag_t, bus_addr_t, int, int, int, tcflag_t));
53 #endif
54
55 int com_is_console __P((bus_space_tag_t, bus_addr_t, bus_space_handle_t *));
56
57 /* Hardware flag masks */
58 #define COM_HW_NOIEN 0x01
59 #define COM_HW_FIFO 0x02
60 /* 0x04 free for use */
61 #define COM_HW_FLOW 0x08
62 #define COM_HW_DEV_OK 0x20
63 #define COM_HW_CONSOLE 0x40
64 #define COM_HW_KGDB 0x80
65 #define COM_HW_TXFIFO_DISABLE 0x100
66 #define COM_HW_NO_TXPRELOAD 0x200
67
68 /* Buffer size for character buffer */
69 #define COM_RING_SIZE 2048
70
71 struct com_softc {
72 struct device sc_dev;
73 void *sc_si;
74 struct tty *sc_tty;
75
76 struct callout sc_diag_callout;
77
78 bus_addr_t sc_iobase; /* XXX ISA-centric name */
79 int sc_frequency;
80
81 bus_space_tag_t sc_iot;
82 bus_space_handle_t sc_ioh;
83 bus_space_handle_t sc_hayespioh;
84
85 u_int sc_overflows,
86 sc_floods,
87 sc_errors;
88
89 int sc_hwflags,
90 sc_swflags;
91 u_int sc_fifolen;
92
93 u_int sc_r_hiwat,
94 sc_r_lowat;
95 u_char *volatile sc_rbget,
96 *volatile sc_rbput;
97 volatile u_int sc_rbavail;
98 u_char *sc_rbuf,
99 *sc_ebuf;
100
101 u_char *sc_tba;
102 u_int sc_tbc,
103 sc_heldtbc;
104
105 volatile u_char sc_rx_flags,
106 #define RX_TTY_BLOCKED 0x01
107 #define RX_TTY_OVERFLOWED 0x02
108 #define RX_IBUF_BLOCKED 0x04
109 #define RX_IBUF_OVERFLOWED 0x08
110 #define RX_ANY_BLOCK 0x0f
111 sc_tx_busy,
112 sc_tx_done,
113 sc_tx_stopped,
114 sc_st_check,
115 sc_rx_ready;
116
117 volatile u_char sc_heldchange;
118 volatile u_char sc_msr, sc_msr_delta, sc_msr_mask, sc_mcr,
119 sc_mcr_active, sc_lcr, sc_ier, sc_fifo, sc_dlbl, sc_dlbh, sc_efr;
120 u_char sc_mcr_dtr, sc_mcr_rts, sc_msr_cts, sc_msr_dcd;
121
122 #ifdef COM_HAYESP
123 u_char sc_prescaler;
124 #endif
125
126 /*
127 * There are a great many almost-ns16550-compatible UARTs out
128 * there, which have minor differences. The type field here
129 * lets us distinguish between them.
130 */
131 int sc_type;
132 #define COM_TYPE_NORMAL 0 /* normal 16x50 */
133 #define COM_TYPE_HAYESP 1 /* Hayes ESP modem */
134 #define COM_TYPE_PXA2x0 2 /* Intel PXA2x0 processor built-in */
135 #define COM_TYPE_AU1x00 3 /* AMD/Alchemy Au1x000 proc. built-in */
136
137 /* power management hooks */
138 int (*enable) __P((struct com_softc *));
139 void (*disable) __P((struct com_softc *));
140 int enabled;
141
142 /* PPS signal on DCD, with or without inkernel clock disciplining */
143 u_char sc_ppsmask; /* pps signal mask */
144 u_char sc_ppsassert; /* pps leading edge */
145 u_char sc_ppsclear; /* pps trailing edge */
146 pps_info_t ppsinfo;
147 pps_params_t ppsparam;
148
149 #if NRND > 0 && defined(RND_COM)
150 rndsource_element_t rnd_source;
151 #endif
152 #if (defined(MULTIPROCESSOR) || defined(LOCKDEBUG)) && defined(COM_MPLOCK)
153 struct simplelock sc_lock;
154 #endif
155 };
156
157 /* Macros to clear/set/test flags. */
158 #define SET(t, f) (t) |= (f)
159 #define CLR(t, f) (t) &= ~(f)
160 #define ISSET(t, f) ((t) & (f))
161
162 int comprobe1 __P((bus_space_tag_t, bus_space_handle_t));
163 int comintr __P((void *));
164 void com_attach_subr __P((struct com_softc *));
165 int com_detach __P((struct device *, int));
166 int com_activate __P((struct device *, enum devact));
167
168 #ifndef __HAVE_GENERIC_SOFT_INTERRUPTS
169 #ifdef __NO_SOFT_SERIAL_INTERRUPT
170 #define IPL_SERIAL IPL_TTY
171 #define splserial() spltty()
172 #define IPL_SOFTSERIAL IPL_TTY
173 #define splsoftserial() spltty()
174 #endif
175 #endif
Cache object: 34425872587fe435f416d0931161ed66
|