epcom.c revision 1.2.4.2 1 1.2.4.2 skrll /* $NetBSD: epcom.c,v 1.2.4.2 2005/01/17 19:29:12 skrll Exp $ */
2 1.2.4.2 skrll /*
3 1.2.4.2 skrll * Copyright (c) 1998, 1999, 2001, 2002, 2004 The NetBSD Foundation, Inc.
4 1.2.4.2 skrll * All rights reserved.
5 1.2.4.2 skrll *
6 1.2.4.2 skrll * This code is derived from software contributed to The NetBSD Foundation
7 1.2.4.2 skrll * by Jesse Off
8 1.2.4.2 skrll *
9 1.2.4.2 skrll * This code is derived from software contributed to The NetBSD Foundation
10 1.2.4.2 skrll * by Ichiro FUKUHARA and Naoto Shimazaki.
11 1.2.4.2 skrll *
12 1.2.4.2 skrll * This code is derived from software contributed to The NetBSD Foundation
13 1.2.4.2 skrll * by IWAMOTO Toshihiro.
14 1.2.4.2 skrll *
15 1.2.4.2 skrll * This code is derived from software contributed to The NetBSD Foundation
16 1.2.4.2 skrll * by Charles M. Hannum.
17 1.2.4.2 skrll *
18 1.2.4.2 skrll * Redistribution and use in source and binary forms, with or without
19 1.2.4.2 skrll * modification, are permitted provided that the following conditions
20 1.2.4.2 skrll * are met:
21 1.2.4.2 skrll * 1. Redistributions of source code must retain the above copyright
22 1.2.4.2 skrll * notice, this list of conditions and the following disclaimer.
23 1.2.4.2 skrll * 2. Redistributions in binary form must reproduce the above copyright
24 1.2.4.2 skrll * notice, this list of conditions and the following disclaimer in the
25 1.2.4.2 skrll * documentation and/or other materials provided with the distribution.
26 1.2.4.2 skrll * 3. All advertising materials mentioning features or use of this software
27 1.2.4.2 skrll * must display the following acknowledgement:
28 1.2.4.2 skrll * This product includes software developed by the NetBSD
29 1.2.4.2 skrll * Foundation, Inc. and its contributors.
30 1.2.4.2 skrll * 4. Neither the name of The NetBSD Foundation nor the names of its
31 1.2.4.2 skrll * contributors may be used to endorse or promote products derived
32 1.2.4.2 skrll * from this software without specific prior written permission.
33 1.2.4.2 skrll *
34 1.2.4.2 skrll * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
35 1.2.4.2 skrll * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
36 1.2.4.2 skrll * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
37 1.2.4.2 skrll * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
38 1.2.4.2 skrll * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
39 1.2.4.2 skrll * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
40 1.2.4.2 skrll * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
41 1.2.4.2 skrll * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
42 1.2.4.2 skrll * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
43 1.2.4.2 skrll * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
44 1.2.4.2 skrll * POSSIBILITY OF SUCH DAMAGE.
45 1.2.4.2 skrll */
46 1.2.4.2 skrll
47 1.2.4.2 skrll /*
48 1.2.4.2 skrll * Copyright (c) 1991 The Regents of the University of California.
49 1.2.4.2 skrll * All rights reserved.
50 1.2.4.2 skrll *
51 1.2.4.2 skrll * Redistribution and use in source and binary forms, with or without
52 1.2.4.2 skrll * modification, are permitted provided that the following conditions
53 1.2.4.2 skrll * are met:
54 1.2.4.2 skrll * 1. Redistributions of source code must retain the above copyright
55 1.2.4.2 skrll * notice, this list of conditions and the following disclaimer.
56 1.2.4.2 skrll * 2. Redistributions in binary form must reproduce the above copyright
57 1.2.4.2 skrll * notice, this list of conditions and the following disclaimer in the
58 1.2.4.2 skrll * documentation and/or other materials provided with the distribution.
59 1.2.4.2 skrll * 3. Neither the name of the University nor the names of its contributors
60 1.2.4.2 skrll * may be used to endorse or promote products derived from this software
61 1.2.4.2 skrll * without specific prior written permission.
62 1.2.4.2 skrll *
63 1.2.4.2 skrll * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
64 1.2.4.2 skrll * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
65 1.2.4.2 skrll * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
66 1.2.4.2 skrll * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
67 1.2.4.2 skrll * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
68 1.2.4.2 skrll * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
69 1.2.4.2 skrll * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
70 1.2.4.2 skrll * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
71 1.2.4.2 skrll * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
72 1.2.4.2 skrll * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
73 1.2.4.2 skrll * SUCH DAMAGE.
74 1.2.4.2 skrll *
75 1.2.4.2 skrll * @(#)com.c 7.5 (Berkeley) 5/16/91
76 1.2.4.2 skrll */
77 1.2.4.2 skrll
78 1.2.4.2 skrll /*
79 1.2.4.2 skrll * TODO: hardware flow control
80 1.2.4.2 skrll */
81 1.2.4.2 skrll
82 1.2.4.2 skrll #include <sys/cdefs.h>
83 1.2.4.2 skrll __KERNEL_RCSID(0, "$NetBSD: epcom.c,v 1.2.4.2 2005/01/17 19:29:12 skrll Exp $");
84 1.2.4.2 skrll
85 1.2.4.2 skrll #include "opt_ddb.h"
86 1.2.4.2 skrll #include "opt_kgdb.h"
87 1.2.4.2 skrll #include "epcom.h"
88 1.2.4.2 skrll
89 1.2.4.2 skrll #include "rnd.h"
90 1.2.4.2 skrll #if NRND > 0 && defined(RND_COM)
91 1.2.4.2 skrll #include <sys/rnd.h>
92 1.2.4.2 skrll #endif
93 1.2.4.2 skrll
94 1.2.4.2 skrll /*
95 1.2.4.2 skrll * Override cnmagic(9) macro before including <sys/systm.h>.
96 1.2.4.2 skrll * We need to know if cn_check_magic triggered debugger, so set a flag.
97 1.2.4.2 skrll * Callers of cn_check_magic must declare int cn_trapped = 0;
98 1.2.4.2 skrll * XXX: this is *ugly*!
99 1.2.4.2 skrll */
100 1.2.4.2 skrll #define cn_trap() \
101 1.2.4.2 skrll do { \
102 1.2.4.2 skrll console_debugger(); \
103 1.2.4.2 skrll cn_trapped = 1; \
104 1.2.4.2 skrll } while (/* CONSTCOND */ 0)
105 1.2.4.2 skrll
106 1.2.4.2 skrll
107 1.2.4.2 skrll #include <sys/param.h>
108 1.2.4.2 skrll #include <sys/systm.h>
109 1.2.4.2 skrll #include <sys/types.h>
110 1.2.4.2 skrll #include <sys/conf.h>
111 1.2.4.2 skrll #include <sys/file.h>
112 1.2.4.2 skrll #include <sys/device.h>
113 1.2.4.2 skrll #include <sys/kernel.h>
114 1.2.4.2 skrll #include <sys/malloc.h>
115 1.2.4.2 skrll #include <sys/tty.h>
116 1.2.4.2 skrll #include <sys/uio.h>
117 1.2.4.2 skrll #include <sys/vnode.h>
118 1.2.4.2 skrll
119 1.2.4.2 skrll #include <machine/intr.h>
120 1.2.4.2 skrll #include <machine/bus.h>
121 1.2.4.2 skrll
122 1.2.4.2 skrll #include <arm/ep93xx/epcomreg.h>
123 1.2.4.2 skrll #include <arm/ep93xx/epcomvar.h>
124 1.2.4.2 skrll #include <arm/ep93xx/ep93xxreg.h>
125 1.2.4.2 skrll #include <arm/ep93xx/ep93xxvar.h>
126 1.2.4.2 skrll
127 1.2.4.2 skrll #include <dev/cons.h>
128 1.2.4.2 skrll
129 1.2.4.2 skrll static int epcomparam(struct tty *, struct termios *);
130 1.2.4.2 skrll static void epcomstart(struct tty *);
131 1.2.4.2 skrll static int epcomhwiflow(struct tty *, int);
132 1.2.4.2 skrll
133 1.2.4.2 skrll static u_int cflag2lcrhi(tcflag_t);
134 1.2.4.2 skrll static void epcom_iflush(struct epcom_softc *);
135 1.2.4.2 skrll static void epcom_set(struct epcom_softc *);
136 1.2.4.2 skrll
137 1.2.4.2 skrll int epcomcngetc(dev_t);
138 1.2.4.2 skrll void epcomcnputc(dev_t, int);
139 1.2.4.2 skrll void epcomcnpollc(dev_t, int);
140 1.2.4.2 skrll
141 1.2.4.2 skrll static void epcomsoft(void* arg);
142 1.2.4.2 skrll inline static void epcom_txsoft(struct epcom_softc *, struct tty *);
143 1.2.4.2 skrll inline static void epcom_rxsoft(struct epcom_softc *, struct tty *);
144 1.2.4.2 skrll
145 1.2.4.2 skrll void epcomcnprobe(struct consdev *);
146 1.2.4.2 skrll void epcomcninit(struct consdev *);
147 1.2.4.2 skrll
148 1.2.4.2 skrll static struct epcom_cons_softc {
149 1.2.4.2 skrll bus_space_tag_t sc_iot;
150 1.2.4.2 skrll bus_space_handle_t sc_ioh;
151 1.2.4.2 skrll bus_addr_t sc_hwbase;
152 1.2.4.2 skrll int sc_ospeed;
153 1.2.4.2 skrll tcflag_t sc_cflag;
154 1.2.4.2 skrll int sc_attached;
155 1.2.4.2 skrll } epcomcn_sc;
156 1.2.4.2 skrll
157 1.2.4.2 skrll static struct cnm_state epcom_cnm_state;
158 1.2.4.2 skrll
159 1.2.4.2 skrll extern struct cfdriver epcom_cd;
160 1.2.4.2 skrll
161 1.2.4.2 skrll dev_type_open(epcomopen);
162 1.2.4.2 skrll dev_type_close(epcomclose);
163 1.2.4.2 skrll dev_type_read(epcomread);
164 1.2.4.2 skrll dev_type_write(epcomwrite);
165 1.2.4.2 skrll dev_type_ioctl(epcomioctl);
166 1.2.4.2 skrll dev_type_stop(epcomstop);
167 1.2.4.2 skrll dev_type_tty(epcomtty);
168 1.2.4.2 skrll dev_type_poll(epcompoll);
169 1.2.4.2 skrll
170 1.2.4.2 skrll const struct cdevsw epcom_cdevsw = {
171 1.2.4.2 skrll epcomopen, epcomclose, epcomread, epcomwrite, epcomioctl,
172 1.2.4.2 skrll epcomstop, epcomtty, epcompoll, nommap, ttykqfilter, D_TTY
173 1.2.4.2 skrll };
174 1.2.4.2 skrll
175 1.2.4.2 skrll struct consdev epcomcons = {
176 1.2.4.2 skrll NULL, NULL, epcomcngetc, epcomcnputc, epcomcnpollc, NULL,
177 1.2.4.2 skrll NULL, NULL, NODEV, CN_NORMAL
178 1.2.4.2 skrll };
179 1.2.4.2 skrll
180 1.2.4.2 skrll #ifndef DEFAULT_COMSPEED
181 1.2.4.2 skrll #define DEFAULT_COMSPEED 115200
182 1.2.4.2 skrll #endif
183 1.2.4.2 skrll
184 1.2.4.2 skrll #define COMUNIT_MASK 0x7ffff
185 1.2.4.2 skrll #define COMDIALOUT_MASK 0x80000
186 1.2.4.2 skrll
187 1.2.4.2 skrll #define COMUNIT(x) (minor(x) & COMUNIT_MASK)
188 1.2.4.2 skrll #define COMDIALOUT(x) (minor(x) & COMDIALOUT_MASK)
189 1.2.4.2 skrll
190 1.2.4.2 skrll #define COM_ISALIVE(sc) ((sc)->enabled != 0 && \
191 1.2.4.2 skrll ISSET((sc)->sc_dev.dv_flags, DVF_ACTIVE))
192 1.2.4.2 skrll
193 1.2.4.2 skrll #define SET(t, f) (t) |= (f)
194 1.2.4.2 skrll #define CLR(t, f) (t) &= ~(f)
195 1.2.4.2 skrll #define ISSET(t, f) ((t) & (f))
196 1.2.4.2 skrll
197 1.2.4.2 skrll void
198 1.2.4.2 skrll epcom_attach_subr(sc)
199 1.2.4.2 skrll struct epcom_softc *sc;
200 1.2.4.2 skrll {
201 1.2.4.2 skrll struct tty *tp;
202 1.2.4.2 skrll
203 1.2.4.2 skrll if (sc->sc_iot == epcomcn_sc.sc_iot
204 1.2.4.2 skrll && sc->sc_hwbase == epcomcn_sc.sc_hwbase) {
205 1.2.4.2 skrll epcomcn_sc.sc_attached = 1;
206 1.2.4.2 skrll sc->sc_lcrlo = EPCOMSPEED2BRD(epcomcn_sc.sc_ospeed) & 0xff;
207 1.2.4.2 skrll sc->sc_lcrmid = EPCOMSPEED2BRD(epcomcn_sc.sc_ospeed) >> 8;
208 1.2.4.2 skrll
209 1.2.4.2 skrll /* Make sure the console is always "hardwired". */
210 1.2.4.2 skrll delay(10000); /* wait for output to finish */
211 1.2.4.2 skrll SET(sc->sc_hwflags, COM_HW_CONSOLE);
212 1.2.4.2 skrll SET(sc->sc_swflags, TIOCFLAG_SOFTCAR);
213 1.2.4.2 skrll }
214 1.2.4.2 skrll
215 1.2.4.2 skrll tp = ttymalloc();
216 1.2.4.2 skrll tp->t_oproc = epcomstart;
217 1.2.4.2 skrll tp->t_param = epcomparam;
218 1.2.4.2 skrll tp->t_hwiflow = epcomhwiflow;
219 1.2.4.2 skrll
220 1.2.4.2 skrll sc->sc_tty = tp;
221 1.2.4.2 skrll sc->sc_rbuf = malloc(EPCOM_RING_SIZE << 1, M_DEVBUF, M_NOWAIT);
222 1.2.4.2 skrll sc->sc_rbput = sc->sc_rbget = sc->sc_rbuf;
223 1.2.4.2 skrll sc->sc_rbavail = EPCOM_RING_SIZE;
224 1.2.4.2 skrll if (sc->sc_rbuf == NULL) {
225 1.2.4.2 skrll printf("%s: unable to allocate ring buffer\n",
226 1.2.4.2 skrll sc->sc_dev.dv_xname);
227 1.2.4.2 skrll return;
228 1.2.4.2 skrll }
229 1.2.4.2 skrll sc->sc_ebuf = sc->sc_rbuf + (EPCOM_RING_SIZE << 1);
230 1.2.4.2 skrll sc->sc_tbc = 0;
231 1.2.4.2 skrll
232 1.2.4.2 skrll sc->sc_lcrlo = EPCOMSPEED2BRD(DEFAULT_COMSPEED) & 0xff;
233 1.2.4.2 skrll sc->sc_lcrmid = EPCOMSPEED2BRD(DEFAULT_COMSPEED) >> 8;
234 1.2.4.2 skrll sc->sc_lcrhi = cflag2lcrhi(CS8); /* 8N1 */
235 1.2.4.2 skrll
236 1.2.4.2 skrll tty_attach(tp);
237 1.2.4.2 skrll
238 1.2.4.2 skrll if (ISSET(sc->sc_hwflags, COM_HW_CONSOLE)) {
239 1.2.4.2 skrll int maj;
240 1.2.4.2 skrll
241 1.2.4.2 skrll /* locate the major number */
242 1.2.4.2 skrll maj = cdevsw_lookup_major(&epcom_cdevsw);
243 1.2.4.2 skrll
244 1.2.4.2 skrll cn_tab->cn_dev = makedev(maj, sc->sc_dev.dv_unit);
245 1.2.4.2 skrll
246 1.2.4.2 skrll aprint_normal("%s: console\n", sc->sc_dev.dv_xname);
247 1.2.4.2 skrll }
248 1.2.4.2 skrll
249 1.2.4.2 skrll sc->sc_si = softintr_establish(IPL_SOFTSERIAL, epcomsoft, sc);
250 1.2.4.2 skrll
251 1.2.4.2 skrll #if NRND > 0 && defined(RND_COM)
252 1.2.4.2 skrll rnd_attach_source(&sc->rnd_source, sc->sc_dev.dv_xname,
253 1.2.4.2 skrll RND_TYPE_TTY, 0);
254 1.2.4.2 skrll #endif
255 1.2.4.2 skrll
256 1.2.4.2 skrll /* if there are no enable/disable functions, assume the device
257 1.2.4.2 skrll is always enabled */
258 1.2.4.2 skrll if (!sc->enable)
259 1.2.4.2 skrll sc->enabled = 1;
260 1.2.4.2 skrll
261 1.2.4.2 skrll /* XXX configure register */
262 1.2.4.2 skrll /* xxx_config(sc) */
263 1.2.4.2 skrll
264 1.2.4.2 skrll SET(sc->sc_hwflags, COM_HW_DEV_OK);
265 1.2.4.2 skrll }
266 1.2.4.2 skrll
267 1.2.4.2 skrll static int
268 1.2.4.2 skrll epcomparam(tp, t)
269 1.2.4.2 skrll struct tty *tp;
270 1.2.4.2 skrll struct termios *t;
271 1.2.4.2 skrll {
272 1.2.4.2 skrll struct epcom_softc *sc
273 1.2.4.2 skrll = device_lookup(&epcom_cd, COMUNIT(tp->t_dev));
274 1.2.4.2 skrll int s;
275 1.2.4.2 skrll
276 1.2.4.2 skrll if (COM_ISALIVE(sc) == 0)
277 1.2.4.2 skrll return (EIO);
278 1.2.4.2 skrll
279 1.2.4.2 skrll if (t->c_ispeed && t->c_ispeed != t->c_ospeed)
280 1.2.4.2 skrll return (EINVAL);
281 1.2.4.2 skrll
282 1.2.4.2 skrll /*
283 1.2.4.2 skrll * For the console, always force CLOCAL and !HUPCL, so that the port
284 1.2.4.2 skrll * is always active.
285 1.2.4.2 skrll */
286 1.2.4.2 skrll if (ISSET(sc->sc_swflags, TIOCFLAG_SOFTCAR) ||
287 1.2.4.2 skrll ISSET(sc->sc_hwflags, COM_HW_CONSOLE)) {
288 1.2.4.2 skrll SET(t->c_cflag, CLOCAL);
289 1.2.4.2 skrll CLR(t->c_cflag, HUPCL);
290 1.2.4.2 skrll }
291 1.2.4.2 skrll
292 1.2.4.2 skrll /*
293 1.2.4.2 skrll * If there were no changes, don't do anything. This avoids dropping
294 1.2.4.2 skrll * input and improves performance when all we did was frob things like
295 1.2.4.2 skrll * VMIN and VTIME.
296 1.2.4.2 skrll */
297 1.2.4.2 skrll if (tp->t_ospeed == t->c_ospeed &&
298 1.2.4.2 skrll tp->t_cflag == t->c_cflag)
299 1.2.4.2 skrll return (0);
300 1.2.4.2 skrll
301 1.2.4.2 skrll s = splserial();
302 1.2.4.2 skrll
303 1.2.4.2 skrll sc->sc_lcrhi = cflag2lcrhi(t->c_cflag);
304 1.2.4.2 skrll sc->sc_lcrlo = EPCOMSPEED2BRD(t->c_ospeed) & 0xff;
305 1.2.4.2 skrll sc->sc_lcrmid = EPCOMSPEED2BRD(t->c_ospeed) >> 8;
306 1.2.4.2 skrll
307 1.2.4.2 skrll /* And copy to tty. */
308 1.2.4.2 skrll tp->t_ispeed = 0;
309 1.2.4.2 skrll tp->t_ospeed = t->c_ospeed;
310 1.2.4.2 skrll tp->t_cflag = t->c_cflag;
311 1.2.4.2 skrll epcom_set(sc);
312 1.2.4.2 skrll
313 1.2.4.2 skrll splx(s);
314 1.2.4.2 skrll
315 1.2.4.2 skrll /*
316 1.2.4.2 skrll * Update the tty layer's idea of the carrier bit.
317 1.2.4.2 skrll * We tell tty the carrier is always on.
318 1.2.4.2 skrll */
319 1.2.4.2 skrll (void) (*tp->t_linesw->l_modem)(tp, 1);
320 1.2.4.2 skrll
321 1.2.4.2 skrll #ifdef COM_DEBUG
322 1.2.4.2 skrll if (com_debug)
323 1.2.4.2 skrll comstatus(sc, "comparam ");
324 1.2.4.2 skrll #endif
325 1.2.4.2 skrll
326 1.2.4.2 skrll if (!ISSET(t->c_cflag, CHWFLOW)) {
327 1.2.4.2 skrll if (sc->sc_tx_stopped) {
328 1.2.4.2 skrll sc->sc_tx_stopped = 0;
329 1.2.4.2 skrll epcomstart(tp);
330 1.2.4.2 skrll }
331 1.2.4.2 skrll }
332 1.2.4.2 skrll
333 1.2.4.2 skrll return (0);
334 1.2.4.2 skrll }
335 1.2.4.2 skrll
336 1.2.4.2 skrll static int
337 1.2.4.2 skrll epcomhwiflow(tp, block)
338 1.2.4.2 skrll struct tty *tp;
339 1.2.4.2 skrll int block;
340 1.2.4.2 skrll {
341 1.2.4.2 skrll return (0);
342 1.2.4.2 skrll }
343 1.2.4.2 skrll
344 1.2.4.2 skrll static void
345 1.2.4.2 skrll epcom_filltx(struct epcom_softc *sc)
346 1.2.4.2 skrll {
347 1.2.4.2 skrll bus_space_tag_t iot = sc->sc_iot;
348 1.2.4.2 skrll bus_space_handle_t ioh = sc->sc_ioh;
349 1.2.4.2 skrll int n;
350 1.2.4.2 skrll
351 1.2.4.2 skrll n = 0;
352 1.2.4.2 skrll while ((bus_space_read_4(iot, ioh, EPCOM_Flag) & Flag_TXFF) == 0) {
353 1.2.4.2 skrll if (n >= sc->sc_tbc)
354 1.2.4.2 skrll break;
355 1.2.4.2 skrll bus_space_write_4(iot, ioh, EPCOM_Data,
356 1.2.4.2 skrll 0xff & *(sc->sc_tba + n));
357 1.2.4.2 skrll n++;
358 1.2.4.2 skrll }
359 1.2.4.2 skrll sc->sc_tbc -= n;
360 1.2.4.2 skrll sc->sc_tba += n;
361 1.2.4.2 skrll }
362 1.2.4.2 skrll
363 1.2.4.2 skrll static void
364 1.2.4.2 skrll epcomstart(tp)
365 1.2.4.2 skrll struct tty *tp;
366 1.2.4.2 skrll {
367 1.2.4.2 skrll struct epcom_softc *sc
368 1.2.4.2 skrll = device_lookup(&epcom_cd, COMUNIT(tp->t_dev));
369 1.2.4.2 skrll int s;
370 1.2.4.2 skrll
371 1.2.4.2 skrll if (COM_ISALIVE(sc) == 0)
372 1.2.4.2 skrll return;
373 1.2.4.2 skrll
374 1.2.4.2 skrll s = spltty();
375 1.2.4.2 skrll if (ISSET(tp->t_state, TS_BUSY | TS_TIMEOUT | TS_TTSTOP))
376 1.2.4.2 skrll goto out;
377 1.2.4.2 skrll if (sc->sc_tx_stopped)
378 1.2.4.2 skrll goto out;
379 1.2.4.2 skrll
380 1.2.4.2 skrll if (tp->t_outq.c_cc <= tp->t_lowat) {
381 1.2.4.2 skrll if (ISSET(tp->t_state, TS_ASLEEP)) {
382 1.2.4.2 skrll CLR(tp->t_state, TS_ASLEEP);
383 1.2.4.2 skrll wakeup(&tp->t_outq);
384 1.2.4.2 skrll }
385 1.2.4.2 skrll selwakeup(&tp->t_wsel);
386 1.2.4.2 skrll if (tp->t_outq.c_cc == 0)
387 1.2.4.2 skrll goto out;
388 1.2.4.2 skrll }
389 1.2.4.2 skrll
390 1.2.4.2 skrll /* Grab the first contiguous region of buffer space. */
391 1.2.4.2 skrll {
392 1.2.4.2 skrll u_char *tba;
393 1.2.4.2 skrll int tbc;
394 1.2.4.2 skrll
395 1.2.4.2 skrll tba = tp->t_outq.c_cf;
396 1.2.4.2 skrll tbc = ndqb(&tp->t_outq, 0);
397 1.2.4.2 skrll
398 1.2.4.2 skrll (void)splserial();
399 1.2.4.2 skrll
400 1.2.4.2 skrll sc->sc_tba = tba;
401 1.2.4.2 skrll sc->sc_tbc = tbc;
402 1.2.4.2 skrll }
403 1.2.4.2 skrll
404 1.2.4.2 skrll SET(tp->t_state, TS_BUSY);
405 1.2.4.2 skrll sc->sc_tx_busy = 1;
406 1.2.4.2 skrll
407 1.2.4.2 skrll /* Output the first chunk of the contiguous buffer. */
408 1.2.4.2 skrll epcom_filltx(sc);
409 1.2.4.2 skrll
410 1.2.4.2 skrll if (!ISSET(sc->sc_ctrl, Ctrl_TIE)) {
411 1.2.4.2 skrll SET(sc->sc_ctrl, Ctrl_TIE);
412 1.2.4.2 skrll epcom_set(sc);
413 1.2.4.2 skrll }
414 1.2.4.2 skrll
415 1.2.4.2 skrll out:
416 1.2.4.2 skrll splx(s);
417 1.2.4.2 skrll return;
418 1.2.4.2 skrll }
419 1.2.4.2 skrll
420 1.2.4.2 skrll static void
421 1.2.4.2 skrll epcom_break(struct epcom_softc *sc, int onoff)
422 1.2.4.2 skrll {
423 1.2.4.2 skrll if (onoff)
424 1.2.4.2 skrll SET(sc->sc_lcrhi, LinCtrlHigh_BRK);
425 1.2.4.2 skrll else
426 1.2.4.2 skrll CLR(sc->sc_lcrhi, LinCtrlHigh_BRK);
427 1.2.4.2 skrll epcom_set(sc);
428 1.2.4.2 skrll }
429 1.2.4.2 skrll
430 1.2.4.2 skrll static void
431 1.2.4.2 skrll epcom_shutdown(struct epcom_softc *sc)
432 1.2.4.2 skrll {
433 1.2.4.2 skrll int s;
434 1.2.4.2 skrll
435 1.2.4.2 skrll s = splserial();
436 1.2.4.2 skrll
437 1.2.4.2 skrll /* Turn off interrupts. */
438 1.2.4.2 skrll CLR(sc->sc_ctrl, (Ctrl_TIE|Ctrl_RTIE|Ctrl_RIE));
439 1.2.4.2 skrll
440 1.2.4.2 skrll /* Clear any break condition set with TIOCSBRK. */
441 1.2.4.2 skrll epcom_break(sc, 0);
442 1.2.4.2 skrll epcom_set(sc);
443 1.2.4.2 skrll
444 1.2.4.2 skrll if (sc->disable) {
445 1.2.4.2 skrll #ifdef DIAGNOSTIC
446 1.2.4.2 skrll if (!sc->enabled)
447 1.2.4.2 skrll panic("epcom_shutdown: not enabled?");
448 1.2.4.2 skrll #endif
449 1.2.4.2 skrll (*sc->disable)(sc);
450 1.2.4.2 skrll sc->enabled = 0;
451 1.2.4.2 skrll }
452 1.2.4.2 skrll splx(s);
453 1.2.4.2 skrll }
454 1.2.4.2 skrll
455 1.2.4.2 skrll int
456 1.2.4.2 skrll epcomopen(dev, flag, mode, p)
457 1.2.4.2 skrll dev_t dev;
458 1.2.4.2 skrll int flag, mode;
459 1.2.4.2 skrll struct proc *p;
460 1.2.4.2 skrll {
461 1.2.4.2 skrll struct epcom_softc *sc;
462 1.2.4.2 skrll struct tty *tp;
463 1.2.4.2 skrll int s, s2;
464 1.2.4.2 skrll int error;
465 1.2.4.2 skrll
466 1.2.4.2 skrll sc = device_lookup(&epcom_cd, COMUNIT(dev));
467 1.2.4.2 skrll if (sc == NULL || !ISSET(sc->sc_hwflags, COM_HW_DEV_OK) ||
468 1.2.4.2 skrll sc->sc_rbuf == NULL)
469 1.2.4.2 skrll return (ENXIO);
470 1.2.4.2 skrll
471 1.2.4.2 skrll if (ISSET(sc->sc_dev.dv_flags, DVF_ACTIVE) == 0)
472 1.2.4.2 skrll return (ENXIO);
473 1.2.4.2 skrll
474 1.2.4.2 skrll #ifdef KGDB
475 1.2.4.2 skrll /*
476 1.2.4.2 skrll * If this is the kgdb port, no other use is permitted.
477 1.2.4.2 skrll */
478 1.2.4.2 skrll if (ISSET(sc->sc_hwflags, COM_HW_KGDB))
479 1.2.4.2 skrll return (EBUSY);
480 1.2.4.2 skrll #endif
481 1.2.4.2 skrll
482 1.2.4.2 skrll tp = sc->sc_tty;
483 1.2.4.2 skrll
484 1.2.4.2 skrll if (ISSET(tp->t_state, TS_ISOPEN) &&
485 1.2.4.2 skrll ISSET(tp->t_state, TS_XCLUDE) &&
486 1.2.4.2 skrll p->p_ucred->cr_uid != 0)
487 1.2.4.2 skrll return (EBUSY);
488 1.2.4.2 skrll
489 1.2.4.2 skrll s = spltty();
490 1.2.4.2 skrll
491 1.2.4.2 skrll /*
492 1.2.4.2 skrll * Do the following iff this is a first open.
493 1.2.4.2 skrll */
494 1.2.4.2 skrll if (!ISSET(tp->t_state, TS_ISOPEN) && tp->t_wopen == 0) {
495 1.2.4.2 skrll struct termios t;
496 1.2.4.2 skrll
497 1.2.4.2 skrll tp->t_dev = dev;
498 1.2.4.2 skrll
499 1.2.4.2 skrll s2 = splserial();
500 1.2.4.2 skrll
501 1.2.4.2 skrll if (sc->enable) {
502 1.2.4.2 skrll if ((*sc->enable)(sc)) {
503 1.2.4.2 skrll splx(s2);
504 1.2.4.2 skrll splx(s);
505 1.2.4.2 skrll printf("%s: device enable failed\n",
506 1.2.4.2 skrll sc->sc_dev.dv_xname);
507 1.2.4.2 skrll return (EIO);
508 1.2.4.2 skrll }
509 1.2.4.2 skrll sc->enabled = 1;
510 1.2.4.2 skrll #if 0
511 1.2.4.2 skrll /* XXXXXXXXXXXXXXX */
512 1.2.4.2 skrll com_config(sc);
513 1.2.4.2 skrll #endif
514 1.2.4.2 skrll }
515 1.2.4.2 skrll
516 1.2.4.2 skrll /* Turn on interrupts. */
517 1.2.4.2 skrll SET(sc->sc_ctrl, (Ctrl_UARTE|Ctrl_RIE|Ctrl_RTIE));
518 1.2.4.2 skrll epcom_set(sc);
519 1.2.4.2 skrll
520 1.2.4.2 skrll #if 0
521 1.2.4.2 skrll /* Fetch the current modem control status, needed later. */
522 1.2.4.2 skrll sc->sc_msr = bus_space_read_1(sc->sc_iot, sc->sc_ioh, com_msr);
523 1.2.4.2 skrll
524 1.2.4.2 skrll /* Clear PPS capture state on first open. */
525 1.2.4.2 skrll sc->sc_ppsmask = 0;
526 1.2.4.2 skrll sc->ppsparam.mode = 0;
527 1.2.4.2 skrll #endif
528 1.2.4.2 skrll
529 1.2.4.2 skrll splx(s2);
530 1.2.4.2 skrll
531 1.2.4.2 skrll /*
532 1.2.4.2 skrll * Initialize the termios status to the defaults. Add in the
533 1.2.4.2 skrll * sticky bits from TIOCSFLAGS.
534 1.2.4.2 skrll */
535 1.2.4.2 skrll t.c_ispeed = 0;
536 1.2.4.2 skrll if (ISSET(sc->sc_hwflags, COM_HW_CONSOLE)) {
537 1.2.4.2 skrll t.c_ospeed = epcomcn_sc.sc_ospeed;
538 1.2.4.2 skrll t.c_cflag = epcomcn_sc.sc_cflag;
539 1.2.4.2 skrll } else {
540 1.2.4.2 skrll t.c_ospeed = TTYDEF_SPEED;
541 1.2.4.2 skrll t.c_cflag = TTYDEF_CFLAG;
542 1.2.4.2 skrll }
543 1.2.4.2 skrll if (ISSET(sc->sc_swflags, TIOCFLAG_CLOCAL))
544 1.2.4.2 skrll SET(t.c_cflag, CLOCAL);
545 1.2.4.2 skrll if (ISSET(sc->sc_swflags, TIOCFLAG_CRTSCTS))
546 1.2.4.2 skrll SET(t.c_cflag, CRTSCTS);
547 1.2.4.2 skrll if (ISSET(sc->sc_swflags, TIOCFLAG_MDMBUF))
548 1.2.4.2 skrll SET(t.c_cflag, MDMBUF);
549 1.2.4.2 skrll /* Make sure epcomparam() will do something. */
550 1.2.4.2 skrll tp->t_ospeed = 0;
551 1.2.4.2 skrll (void) epcomparam(tp, &t);
552 1.2.4.2 skrll tp->t_iflag = TTYDEF_IFLAG;
553 1.2.4.2 skrll tp->t_oflag = TTYDEF_OFLAG;
554 1.2.4.2 skrll tp->t_lflag = TTYDEF_LFLAG;
555 1.2.4.2 skrll ttychars(tp);
556 1.2.4.2 skrll ttsetwater(tp);
557 1.2.4.2 skrll
558 1.2.4.2 skrll s2 = splserial();
559 1.2.4.2 skrll
560 1.2.4.2 skrll /* Clear the input ring, and unblock. */
561 1.2.4.2 skrll sc->sc_rbput = sc->sc_rbget = sc->sc_rbuf;
562 1.2.4.2 skrll sc->sc_rbavail = EPCOM_RING_SIZE;
563 1.2.4.2 skrll epcom_iflush(sc);
564 1.2.4.2 skrll CLR(sc->sc_rx_flags, RX_ANY_BLOCK);
565 1.2.4.2 skrll
566 1.2.4.2 skrll #ifdef COM_DEBUG
567 1.2.4.2 skrll if (epcom_debug)
568 1.2.4.2 skrll comstatus(sc, "epcomopen ");
569 1.2.4.2 skrll #endif
570 1.2.4.2 skrll
571 1.2.4.2 skrll splx(s2);
572 1.2.4.2 skrll }
573 1.2.4.2 skrll
574 1.2.4.2 skrll splx(s);
575 1.2.4.2 skrll
576 1.2.4.2 skrll error = ttyopen(tp, COMDIALOUT(dev), ISSET(flag, O_NONBLOCK));
577 1.2.4.2 skrll if (error)
578 1.2.4.2 skrll goto bad;
579 1.2.4.2 skrll
580 1.2.4.2 skrll error = (*tp->t_linesw->l_open)(dev, tp);
581 1.2.4.2 skrll if (error)
582 1.2.4.2 skrll goto bad;
583 1.2.4.2 skrll
584 1.2.4.2 skrll return (0);
585 1.2.4.2 skrll
586 1.2.4.2 skrll bad:
587 1.2.4.2 skrll if (!ISSET(tp->t_state, TS_ISOPEN) && tp->t_wopen == 0) {
588 1.2.4.2 skrll /*
589 1.2.4.2 skrll * We failed to open the device, and nobody else had it opened.
590 1.2.4.2 skrll * Clean up the state as appropriate.
591 1.2.4.2 skrll */
592 1.2.4.2 skrll epcom_shutdown(sc);
593 1.2.4.2 skrll }
594 1.2.4.2 skrll
595 1.2.4.2 skrll return (error);
596 1.2.4.2 skrll }
597 1.2.4.2 skrll
598 1.2.4.2 skrll int
599 1.2.4.2 skrll epcomclose(dev, flag, mode, p)
600 1.2.4.2 skrll dev_t dev;
601 1.2.4.2 skrll int flag, mode;
602 1.2.4.2 skrll struct proc *p;
603 1.2.4.2 skrll {
604 1.2.4.2 skrll struct epcom_softc *sc = device_lookup(&epcom_cd, COMUNIT(dev));
605 1.2.4.2 skrll struct tty *tp = sc->sc_tty;
606 1.2.4.2 skrll
607 1.2.4.2 skrll /* XXX This is for cons.c. */
608 1.2.4.2 skrll if (!ISSET(tp->t_state, TS_ISOPEN))
609 1.2.4.2 skrll return (0);
610 1.2.4.2 skrll
611 1.2.4.2 skrll (*tp->t_linesw->l_close)(tp, flag);
612 1.2.4.2 skrll ttyclose(tp);
613 1.2.4.2 skrll
614 1.2.4.2 skrll if (COM_ISALIVE(sc) == 0)
615 1.2.4.2 skrll return (0);
616 1.2.4.2 skrll
617 1.2.4.2 skrll if (!ISSET(tp->t_state, TS_ISOPEN) && tp->t_wopen == 0) {
618 1.2.4.2 skrll /*
619 1.2.4.2 skrll * Although we got a last close, the device may still be in
620 1.2.4.2 skrll * use; e.g. if this was the dialout node, and there are still
621 1.2.4.2 skrll * processes waiting for carrier on the non-dialout node.
622 1.2.4.2 skrll */
623 1.2.4.2 skrll epcom_shutdown(sc);
624 1.2.4.2 skrll }
625 1.2.4.2 skrll
626 1.2.4.2 skrll return (0);
627 1.2.4.2 skrll }
628 1.2.4.2 skrll
629 1.2.4.2 skrll int
630 1.2.4.2 skrll epcomread(dev, uio, flag)
631 1.2.4.2 skrll dev_t dev;
632 1.2.4.2 skrll struct uio *uio;
633 1.2.4.2 skrll int flag;
634 1.2.4.2 skrll {
635 1.2.4.2 skrll struct epcom_softc *sc = device_lookup(&epcom_cd, COMUNIT(dev));
636 1.2.4.2 skrll struct tty *tp = sc->sc_tty;
637 1.2.4.2 skrll
638 1.2.4.2 skrll if (COM_ISALIVE(sc) == 0)
639 1.2.4.2 skrll return (EIO);
640 1.2.4.2 skrll
641 1.2.4.2 skrll return ((*tp->t_linesw->l_read)(tp, uio, flag));
642 1.2.4.2 skrll }
643 1.2.4.2 skrll
644 1.2.4.2 skrll int
645 1.2.4.2 skrll epcomwrite(dev, uio, flag)
646 1.2.4.2 skrll dev_t dev;
647 1.2.4.2 skrll struct uio *uio;
648 1.2.4.2 skrll int flag;
649 1.2.4.2 skrll {
650 1.2.4.2 skrll struct epcom_softc *sc = device_lookup(&epcom_cd, COMUNIT(dev));
651 1.2.4.2 skrll struct tty *tp = sc->sc_tty;
652 1.2.4.2 skrll
653 1.2.4.2 skrll if (COM_ISALIVE(sc) == 0)
654 1.2.4.2 skrll return (EIO);
655 1.2.4.2 skrll
656 1.2.4.2 skrll return ((*tp->t_linesw->l_write)(tp, uio, flag));
657 1.2.4.2 skrll }
658 1.2.4.2 skrll
659 1.2.4.2 skrll int
660 1.2.4.2 skrll epcompoll(dev, events, p)
661 1.2.4.2 skrll dev_t dev;
662 1.2.4.2 skrll int events;
663 1.2.4.2 skrll struct proc *p;
664 1.2.4.2 skrll {
665 1.2.4.2 skrll struct epcom_softc *sc = device_lookup(&epcom_cd, COMUNIT(dev));
666 1.2.4.2 skrll struct tty *tp = sc->sc_tty;
667 1.2.4.2 skrll
668 1.2.4.2 skrll if (COM_ISALIVE(sc) == 0)
669 1.2.4.2 skrll return (EIO);
670 1.2.4.2 skrll
671 1.2.4.2 skrll return ((*tp->t_linesw->l_poll)(tp, events, p));
672 1.2.4.2 skrll }
673 1.2.4.2 skrll
674 1.2.4.2 skrll struct tty *
675 1.2.4.2 skrll epcomtty(dev)
676 1.2.4.2 skrll dev_t dev;
677 1.2.4.2 skrll {
678 1.2.4.2 skrll struct epcom_softc *sc = device_lookup(&epcom_cd, COMUNIT(dev));
679 1.2.4.2 skrll struct tty *tp = sc->sc_tty;
680 1.2.4.2 skrll
681 1.2.4.2 skrll return (tp);
682 1.2.4.2 skrll }
683 1.2.4.2 skrll
684 1.2.4.2 skrll int
685 1.2.4.2 skrll epcomioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
686 1.2.4.2 skrll {
687 1.2.4.2 skrll struct epcom_softc *sc = device_lookup(&epcom_cd, COMUNIT(dev));
688 1.2.4.2 skrll struct tty *tp = sc->sc_tty;
689 1.2.4.2 skrll int error;
690 1.2.4.2 skrll int s;
691 1.2.4.2 skrll
692 1.2.4.2 skrll if (COM_ISALIVE(sc) == 0)
693 1.2.4.2 skrll return (EIO);
694 1.2.4.2 skrll
695 1.2.4.2 skrll error = (*tp->t_linesw->l_ioctl)(tp, cmd, data, flag, p);
696 1.2.4.2 skrll if (error != EPASSTHROUGH)
697 1.2.4.2 skrll return (error);
698 1.2.4.2 skrll
699 1.2.4.2 skrll error = ttioctl(tp, cmd, data, flag, p);
700 1.2.4.2 skrll if (error != EPASSTHROUGH)
701 1.2.4.2 skrll return (error);
702 1.2.4.2 skrll
703 1.2.4.2 skrll error = 0;
704 1.2.4.2 skrll
705 1.2.4.2 skrll s = splserial();
706 1.2.4.2 skrll
707 1.2.4.2 skrll switch (cmd) {
708 1.2.4.2 skrll case TIOCSBRK:
709 1.2.4.2 skrll epcom_break(sc, 1);
710 1.2.4.2 skrll break;
711 1.2.4.2 skrll
712 1.2.4.2 skrll case TIOCCBRK:
713 1.2.4.2 skrll epcom_break(sc, 0);
714 1.2.4.2 skrll break;
715 1.2.4.2 skrll
716 1.2.4.2 skrll case TIOCGFLAGS:
717 1.2.4.2 skrll *(int *)data = sc->sc_swflags;
718 1.2.4.2 skrll break;
719 1.2.4.2 skrll
720 1.2.4.2 skrll case TIOCSFLAGS:
721 1.2.4.2 skrll error = suser(p->p_ucred, &p->p_acflag);
722 1.2.4.2 skrll if (error)
723 1.2.4.2 skrll break;
724 1.2.4.2 skrll sc->sc_swflags = *(int *)data;
725 1.2.4.2 skrll break;
726 1.2.4.2 skrll
727 1.2.4.2 skrll default:
728 1.2.4.2 skrll error = EPASSTHROUGH;
729 1.2.4.2 skrll break;
730 1.2.4.2 skrll }
731 1.2.4.2 skrll
732 1.2.4.2 skrll splx(s);
733 1.2.4.2 skrll
734 1.2.4.2 skrll return (error);
735 1.2.4.2 skrll }
736 1.2.4.2 skrll
737 1.2.4.2 skrll /*
738 1.2.4.2 skrll * Stop output on a line.
739 1.2.4.2 skrll */
740 1.2.4.2 skrll void
741 1.2.4.2 skrll epcomstop(tp, flag)
742 1.2.4.2 skrll struct tty *tp;
743 1.2.4.2 skrll int flag;
744 1.2.4.2 skrll {
745 1.2.4.2 skrll struct epcom_softc *sc
746 1.2.4.2 skrll = device_lookup(&epcom_cd, COMUNIT(tp->t_dev));
747 1.2.4.2 skrll int s;
748 1.2.4.2 skrll
749 1.2.4.2 skrll s = splserial();
750 1.2.4.2 skrll if (ISSET(tp->t_state, TS_BUSY)) {
751 1.2.4.2 skrll /* Stop transmitting at the next chunk. */
752 1.2.4.2 skrll sc->sc_tbc = 0;
753 1.2.4.2 skrll if (!ISSET(tp->t_state, TS_TTSTOP))
754 1.2.4.2 skrll SET(tp->t_state, TS_FLUSH);
755 1.2.4.2 skrll }
756 1.2.4.2 skrll splx(s);
757 1.2.4.2 skrll }
758 1.2.4.2 skrll
759 1.2.4.2 skrll static u_int
760 1.2.4.2 skrll cflag2lcrhi(cflag)
761 1.2.4.2 skrll tcflag_t cflag;
762 1.2.4.2 skrll {
763 1.2.4.2 skrll u_int lcrhi;
764 1.2.4.2 skrll
765 1.2.4.2 skrll switch (cflag & CSIZE) {
766 1.2.4.2 skrll case CS7:
767 1.2.4.2 skrll lcrhi = 0x40;
768 1.2.4.2 skrll break;
769 1.2.4.2 skrll case CS6:
770 1.2.4.2 skrll lcrhi = 0x20;
771 1.2.4.2 skrll break;
772 1.2.4.2 skrll case CS8:
773 1.2.4.2 skrll default:
774 1.2.4.2 skrll lcrhi = 0x60;
775 1.2.4.2 skrll break;
776 1.2.4.2 skrll }
777 1.2.4.2 skrll lcrhi |= (cflag & PARENB) ? LinCtrlHigh_PEN : 0;
778 1.2.4.2 skrll lcrhi |= (cflag & PARODD) ? 0 : LinCtrlHigh_EPS;
779 1.2.4.2 skrll lcrhi |= (cflag & CSTOPB) ? LinCtrlHigh_STP2 : 0;
780 1.2.4.2 skrll lcrhi |= LinCtrlHigh_FEN; /* FIFO always enabled */
781 1.2.4.2 skrll
782 1.2.4.2 skrll return (lcrhi);
783 1.2.4.2 skrll }
784 1.2.4.2 skrll
785 1.2.4.2 skrll static void
786 1.2.4.2 skrll epcom_iflush(sc)
787 1.2.4.2 skrll struct epcom_softc *sc;
788 1.2.4.2 skrll {
789 1.2.4.2 skrll bus_space_tag_t iot = sc->sc_iot;
790 1.2.4.2 skrll bus_space_handle_t ioh = sc->sc_ioh;
791 1.2.4.2 skrll #ifdef DIAGNOSTIC
792 1.2.4.2 skrll int reg;
793 1.2.4.2 skrll #endif
794 1.2.4.2 skrll int timo;
795 1.2.4.2 skrll
796 1.2.4.2 skrll #ifdef DIAGNOSTIC
797 1.2.4.2 skrll reg = 0xffff;
798 1.2.4.2 skrll #endif
799 1.2.4.2 skrll timo = 50000;
800 1.2.4.2 skrll /* flush any pending I/O */
801 1.2.4.2 skrll while ((bus_space_read_4(iot, ioh, EPCOM_Flag) & Flag_RXFE) == 0
802 1.2.4.2 skrll && --timo)
803 1.2.4.2 skrll #ifdef DIAGNOSTIC
804 1.2.4.2 skrll reg =
805 1.2.4.2 skrll #else
806 1.2.4.2 skrll (void)
807 1.2.4.2 skrll #endif
808 1.2.4.2 skrll bus_space_read_4(iot, ioh, EPCOM_Data);
809 1.2.4.2 skrll #ifdef DIAGNOSTIC
810 1.2.4.2 skrll if (!timo)
811 1.2.4.2 skrll printf("%s: com_iflush timeout %02x\n", sc->sc_dev.dv_xname,
812 1.2.4.2 skrll reg);
813 1.2.4.2 skrll #endif
814 1.2.4.2 skrll }
815 1.2.4.2 skrll
816 1.2.4.2 skrll static void
817 1.2.4.2 skrll epcom_set(struct epcom_softc *sc)
818 1.2.4.2 skrll {
819 1.2.4.2 skrll bus_space_write_4(sc->sc_iot, sc->sc_ioh, EPCOM_LinCtrlLow,
820 1.2.4.2 skrll sc->sc_lcrlo);
821 1.2.4.2 skrll bus_space_write_4(sc->sc_iot, sc->sc_ioh, EPCOM_LinCtrlMid,
822 1.2.4.2 skrll sc->sc_lcrmid);
823 1.2.4.2 skrll bus_space_write_4(sc->sc_iot, sc->sc_ioh, EPCOM_LinCtrlHigh,
824 1.2.4.2 skrll sc->sc_lcrhi);
825 1.2.4.2 skrll bus_space_write_4(sc->sc_iot, sc->sc_ioh, EPCOM_Ctrl,
826 1.2.4.2 skrll sc->sc_ctrl);
827 1.2.4.2 skrll }
828 1.2.4.2 skrll
829 1.2.4.2 skrll int
830 1.2.4.2 skrll epcomcnattach(iot, iobase, ioh, ospeed, cflag)
831 1.2.4.2 skrll bus_space_tag_t iot;
832 1.2.4.2 skrll bus_addr_t iobase;
833 1.2.4.2 skrll bus_space_handle_t ioh;
834 1.2.4.2 skrll int ospeed;
835 1.2.4.2 skrll tcflag_t cflag;
836 1.2.4.2 skrll {
837 1.2.4.2 skrll u_int lcrlo, lcrmid, lcrhi, ctrl, pwrcnt;
838 1.2.4.2 skrll bus_space_handle_t syscon_ioh;
839 1.2.4.2 skrll
840 1.2.4.2 skrll cn_tab = &epcomcons;
841 1.2.4.2 skrll cn_init_magic(&epcom_cnm_state);
842 1.2.4.2 skrll cn_set_magic("\047\001");
843 1.2.4.2 skrll
844 1.2.4.2 skrll epcomcn_sc.sc_iot = iot;
845 1.2.4.2 skrll epcomcn_sc.sc_ioh = ioh;
846 1.2.4.2 skrll epcomcn_sc.sc_hwbase = iobase;
847 1.2.4.2 skrll epcomcn_sc.sc_ospeed = ospeed;
848 1.2.4.2 skrll epcomcn_sc.sc_cflag = cflag;
849 1.2.4.2 skrll
850 1.2.4.2 skrll lcrhi = cflag2lcrhi(cflag);
851 1.2.4.2 skrll lcrlo = EPCOMSPEED2BRD(ospeed) & 0xff;
852 1.2.4.2 skrll lcrmid = EPCOMSPEED2BRD(ospeed) >> 8;
853 1.2.4.2 skrll ctrl = Ctrl_UARTE;
854 1.2.4.2 skrll
855 1.2.4.2 skrll bus_space_map(iot, EP93XX_APB_HWBASE + EP93XX_APB_SYSCON,
856 1.2.4.2 skrll EP93XX_APB_SYSCON_SIZE, 0, &syscon_ioh);
857 1.2.4.2 skrll pwrcnt = bus_space_read_4(iot, syscon_ioh, EP93XX_SYSCON_PwrCnt);
858 1.2.4.2 skrll pwrcnt &= ~(PwrCnt_UARTBAUD);
859 1.2.4.2 skrll bus_space_write_4(iot, syscon_ioh, EP93XX_SYSCON_PwrCnt, pwrcnt);
860 1.2.4.2 skrll bus_space_unmap(iot, syscon_ioh, EP93XX_APB_SYSCON_SIZE);
861 1.2.4.2 skrll
862 1.2.4.2 skrll bus_space_write_4(iot, ioh, EPCOM_LinCtrlLow, lcrlo);
863 1.2.4.2 skrll bus_space_write_4(iot, ioh, EPCOM_LinCtrlMid, lcrmid);
864 1.2.4.2 skrll bus_space_write_4(iot, ioh, EPCOM_LinCtrlHigh, lcrhi);
865 1.2.4.2 skrll bus_space_write_4(iot, ioh, EPCOM_Ctrl, ctrl);
866 1.2.4.2 skrll
867 1.2.4.2 skrll return (0);
868 1.2.4.2 skrll }
869 1.2.4.2 skrll
870 1.2.4.2 skrll void
871 1.2.4.2 skrll epcomcnprobe(cp)
872 1.2.4.2 skrll struct consdev *cp;
873 1.2.4.2 skrll {
874 1.2.4.2 skrll cp->cn_pri = CN_REMOTE;
875 1.2.4.2 skrll }
876 1.2.4.2 skrll
877 1.2.4.2 skrll void
878 1.2.4.2 skrll epcomcnpollc(dev, on)
879 1.2.4.2 skrll dev_t dev;
880 1.2.4.2 skrll int on;
881 1.2.4.2 skrll {
882 1.2.4.2 skrll }
883 1.2.4.2 skrll
884 1.2.4.2 skrll void
885 1.2.4.2 skrll epcomcnputc(dev, c)
886 1.2.4.2 skrll dev_t dev;
887 1.2.4.2 skrll int c;
888 1.2.4.2 skrll {
889 1.2.4.2 skrll int s;
890 1.2.4.2 skrll bus_space_tag_t iot = epcomcn_sc.sc_iot;
891 1.2.4.2 skrll bus_space_handle_t ioh = epcomcn_sc.sc_ioh;
892 1.2.4.2 skrll
893 1.2.4.2 skrll s = splserial();
894 1.2.4.2 skrll
895 1.2.4.2 skrll while((bus_space_read_4(iot, ioh, EPCOM_Flag) & Flag_TXFF) != 0)
896 1.2.4.2 skrll ;
897 1.2.4.2 skrll
898 1.2.4.2 skrll bus_space_write_4(iot, ioh, EPCOM_Data, c);
899 1.2.4.2 skrll
900 1.2.4.2 skrll #ifdef DEBUG
901 1.2.4.2 skrll if (c == '\r') {
902 1.2.4.2 skrll while((bus_space_read_4(iot, ioh, EPCOM_Flag) & Flag_TXFE) == 0)
903 1.2.4.2 skrll ;
904 1.2.4.2 skrll }
905 1.2.4.2 skrll #endif
906 1.2.4.2 skrll
907 1.2.4.2 skrll splx(s);
908 1.2.4.2 skrll }
909 1.2.4.2 skrll
910 1.2.4.2 skrll int
911 1.2.4.2 skrll epcomcngetc(dev)
912 1.2.4.2 skrll dev_t dev;
913 1.2.4.2 skrll {
914 1.2.4.2 skrll int c, sts;
915 1.2.4.2 skrll int s;
916 1.2.4.2 skrll bus_space_tag_t iot = epcomcn_sc.sc_iot;
917 1.2.4.2 skrll bus_space_handle_t ioh = epcomcn_sc.sc_ioh;
918 1.2.4.2 skrll
919 1.2.4.2 skrll s = splserial();
920 1.2.4.2 skrll
921 1.2.4.2 skrll while((bus_space_read_4(iot, ioh, EPCOM_Flag) & Flag_RXFE) != 0)
922 1.2.4.2 skrll ;
923 1.2.4.2 skrll
924 1.2.4.2 skrll c = bus_space_read_4(iot, ioh, EPCOM_Data);
925 1.2.4.2 skrll sts = bus_space_read_4(iot, ioh, EPCOM_RXSts);
926 1.2.4.2 skrll if (ISSET(sts, RXSts_BE)) c = CNC_BREAK;
927 1.2.4.2 skrll #ifdef DDB
928 1.2.4.2 skrll extern int db_active;
929 1.2.4.2 skrll if (!db_active)
930 1.2.4.2 skrll #endif
931 1.2.4.2 skrll {
932 1.2.4.2 skrll int cn_trapped = 0; /* unused */
933 1.2.4.2 skrll
934 1.2.4.2 skrll cn_check_magic(dev, c, epcom_cnm_state);
935 1.2.4.2 skrll }
936 1.2.4.2 skrll c &= 0xff;
937 1.2.4.2 skrll splx(s);
938 1.2.4.2 skrll
939 1.2.4.2 skrll return (c);
940 1.2.4.2 skrll }
941 1.2.4.2 skrll
942 1.2.4.2 skrll inline static void
943 1.2.4.2 skrll epcom_txsoft(sc, tp)
944 1.2.4.2 skrll struct epcom_softc *sc;
945 1.2.4.2 skrll struct tty *tp;
946 1.2.4.2 skrll {
947 1.2.4.2 skrll CLR(tp->t_state, TS_BUSY);
948 1.2.4.2 skrll if (ISSET(tp->t_state, TS_FLUSH))
949 1.2.4.2 skrll CLR(tp->t_state, TS_FLUSH);
950 1.2.4.2 skrll else
951 1.2.4.2 skrll ndflush(&tp->t_outq, (int)(sc->sc_tba - tp->t_outq.c_cf));
952 1.2.4.2 skrll (*tp->t_linesw->l_start)(tp);
953 1.2.4.2 skrll }
954 1.2.4.2 skrll
955 1.2.4.2 skrll inline static void
956 1.2.4.2 skrll epcom_rxsoft(sc, tp)
957 1.2.4.2 skrll struct epcom_softc *sc;
958 1.2.4.2 skrll struct tty *tp;
959 1.2.4.2 skrll {
960 1.2.4.2 skrll int (*rint) __P((int c, struct tty *tp)) = tp->t_linesw->l_rint;
961 1.2.4.2 skrll u_char *get, *end;
962 1.2.4.2 skrll u_int cc, scc;
963 1.2.4.2 skrll u_char sts;
964 1.2.4.2 skrll int code;
965 1.2.4.2 skrll int s;
966 1.2.4.2 skrll
967 1.2.4.2 skrll end = sc->sc_ebuf;
968 1.2.4.2 skrll get = sc->sc_rbget;
969 1.2.4.2 skrll scc = cc = EPCOM_RING_SIZE - sc->sc_rbavail;
970 1.2.4.2 skrll #if 0
971 1.2.4.2 skrll if (cc == EPCOM_RING_SIZE) {
972 1.2.4.2 skrll sc->sc_floods++;
973 1.2.4.2 skrll if (sc->sc_errors++ == 0)
974 1.2.4.2 skrll callout_reset(&sc->sc_diag_callout, 60 * hz,
975 1.2.4.2 skrll comdiag, sc);
976 1.2.4.2 skrll }
977 1.2.4.2 skrll #endif
978 1.2.4.2 skrll while (cc) {
979 1.2.4.2 skrll code = get[0];
980 1.2.4.2 skrll sts = get[1];
981 1.2.4.2 skrll if (ISSET(sts, RXSts_OE | RXSts_FE | RXSts_PE | RXSts_BE)) {
982 1.2.4.2 skrll #if 0
983 1.2.4.2 skrll if (ISSET(lsr, DR_ROR)) {
984 1.2.4.2 skrll sc->sc_overflows++;
985 1.2.4.2 skrll if (sc->sc_errors++ == 0)
986 1.2.4.2 skrll callout_reset(&sc->sc_diag_callout,
987 1.2.4.2 skrll 60 * hz, comdiag, sc);
988 1.2.4.2 skrll }
989 1.2.4.2 skrll #endif
990 1.2.4.2 skrll if (ISSET(sts, (RXSts_FE|RXSts_BE)))
991 1.2.4.2 skrll SET(code, TTY_FE);
992 1.2.4.2 skrll if (ISSET(sts, RXSts_PE))
993 1.2.4.2 skrll SET(code, TTY_PE);
994 1.2.4.2 skrll }
995 1.2.4.2 skrll if ((*rint)(code, tp) == -1) {
996 1.2.4.2 skrll /*
997 1.2.4.2 skrll * The line discipline's buffer is out of space.
998 1.2.4.2 skrll */
999 1.2.4.2 skrll if (!ISSET(sc->sc_rx_flags, RX_TTY_BLOCKED)) {
1000 1.2.4.2 skrll /*
1001 1.2.4.2 skrll * We're either not using flow control, or the
1002 1.2.4.2 skrll * line discipline didn't tell us to block for
1003 1.2.4.2 skrll * some reason. Either way, we have no way to
1004 1.2.4.2 skrll * know when there's more space available, so
1005 1.2.4.2 skrll * just drop the rest of the data.
1006 1.2.4.2 skrll */
1007 1.2.4.2 skrll get += cc << 1;
1008 1.2.4.2 skrll if (get >= end)
1009 1.2.4.2 skrll get -= EPCOM_RING_SIZE << 1;
1010 1.2.4.2 skrll cc = 0;
1011 1.2.4.2 skrll } else {
1012 1.2.4.2 skrll /*
1013 1.2.4.2 skrll * Don't schedule any more receive processing
1014 1.2.4.2 skrll * until the line discipline tells us there's
1015 1.2.4.2 skrll * space available (through comhwiflow()).
1016 1.2.4.2 skrll * Leave the rest of the data in the input
1017 1.2.4.2 skrll * buffer.
1018 1.2.4.2 skrll */
1019 1.2.4.2 skrll SET(sc->sc_rx_flags, RX_TTY_OVERFLOWED);
1020 1.2.4.2 skrll }
1021 1.2.4.2 skrll break;
1022 1.2.4.2 skrll }
1023 1.2.4.2 skrll get += 2;
1024 1.2.4.2 skrll if (get >= end)
1025 1.2.4.2 skrll get = sc->sc_rbuf;
1026 1.2.4.2 skrll cc--;
1027 1.2.4.2 skrll }
1028 1.2.4.2 skrll
1029 1.2.4.2 skrll if (cc != scc) {
1030 1.2.4.2 skrll sc->sc_rbget = get;
1031 1.2.4.2 skrll s = splserial();
1032 1.2.4.2 skrll
1033 1.2.4.2 skrll cc = sc->sc_rbavail += scc - cc;
1034 1.2.4.2 skrll /* Buffers should be ok again, release possible block. */
1035 1.2.4.2 skrll if (cc >= 1) {
1036 1.2.4.2 skrll if (ISSET(sc->sc_rx_flags, RX_IBUF_OVERFLOWED)) {
1037 1.2.4.2 skrll CLR(sc->sc_rx_flags, RX_IBUF_OVERFLOWED);
1038 1.2.4.2 skrll SET(sc->sc_ctrl, (Ctrl_RIE|Ctrl_RTIE));
1039 1.2.4.2 skrll epcom_set(sc);
1040 1.2.4.2 skrll }
1041 1.2.4.2 skrll if (ISSET(sc->sc_rx_flags, RX_IBUF_BLOCKED)) {
1042 1.2.4.2 skrll CLR(sc->sc_rx_flags, RX_IBUF_BLOCKED);
1043 1.2.4.2 skrll #if 0
1044 1.2.4.2 skrll com_hwiflow(sc);
1045 1.2.4.2 skrll #endif
1046 1.2.4.2 skrll }
1047 1.2.4.2 skrll }
1048 1.2.4.2 skrll splx(s);
1049 1.2.4.2 skrll }
1050 1.2.4.2 skrll }
1051 1.2.4.2 skrll
1052 1.2.4.2 skrll static void
1053 1.2.4.2 skrll epcomsoft(void* arg)
1054 1.2.4.2 skrll {
1055 1.2.4.2 skrll struct epcom_softc *sc = arg;
1056 1.2.4.2 skrll
1057 1.2.4.2 skrll if (COM_ISALIVE(sc) == 0)
1058 1.2.4.2 skrll return;
1059 1.2.4.2 skrll
1060 1.2.4.2 skrll if (sc->sc_rx_ready) {
1061 1.2.4.2 skrll sc->sc_rx_ready = 0;
1062 1.2.4.2 skrll epcom_rxsoft(sc, sc->sc_tty);
1063 1.2.4.2 skrll }
1064 1.2.4.2 skrll if (sc->sc_tx_done) {
1065 1.2.4.2 skrll sc->sc_tx_done = 0;
1066 1.2.4.2 skrll epcom_txsoft(sc, sc->sc_tty);
1067 1.2.4.2 skrll }
1068 1.2.4.2 skrll }
1069 1.2.4.2 skrll
1070 1.2.4.2 skrll int
1071 1.2.4.2 skrll epcomintr(void* arg)
1072 1.2.4.2 skrll {
1073 1.2.4.2 skrll struct epcom_softc *sc = arg;
1074 1.2.4.2 skrll bus_space_tag_t iot = sc->sc_iot;
1075 1.2.4.2 skrll bus_space_handle_t ioh = sc->sc_ioh;
1076 1.2.4.2 skrll u_char *put, *end;
1077 1.2.4.2 skrll u_int cc;
1078 1.2.4.2 skrll u_int flagr;
1079 1.2.4.2 skrll u_int intr;
1080 1.2.4.2 skrll u_int32_t c, csts;
1081 1.2.4.2 skrll
1082 1.2.4.2 skrll intr = bus_space_read_4(iot, ioh, EPCOM_IntIDIntClr);
1083 1.2.4.2 skrll
1084 1.2.4.2 skrll if (COM_ISALIVE(sc) == 0)
1085 1.2.4.2 skrll panic("intr on disabled epcom");
1086 1.2.4.2 skrll
1087 1.2.4.2 skrll flagr = bus_space_read_4(iot, ioh, EPCOM_Flag);
1088 1.2.4.2 skrll
1089 1.2.4.2 skrll end = sc->sc_ebuf;
1090 1.2.4.2 skrll put = sc->sc_rbput;
1091 1.2.4.2 skrll cc = sc->sc_rbavail;
1092 1.2.4.2 skrll
1093 1.2.4.2 skrll if (!(ISSET(flagr, Flag_RXFE))) {
1094 1.2.4.2 skrll if (!ISSET(sc->sc_rx_flags, RX_IBUF_OVERFLOWED)) {
1095 1.2.4.2 skrll while (cc > 0) {
1096 1.2.4.2 skrll if (ISSET(flagr, Flag_RXFE))
1097 1.2.4.2 skrll break;
1098 1.2.4.2 skrll c = bus_space_read_4(iot, ioh, EPCOM_Data);
1099 1.2.4.2 skrll csts = bus_space_read_4(iot, ioh, EPCOM_RXSts);
1100 1.2.4.2 skrll if (ISSET(csts, RXSts_BE)) {
1101 1.2.4.2 skrll int cn_trapped = 0;
1102 1.2.4.2 skrll
1103 1.2.4.2 skrll cn_check_magic(sc->sc_tty->t_dev,
1104 1.2.4.2 skrll CNC_BREAK, epcom_cnm_state);
1105 1.2.4.2 skrll if (cn_trapped)
1106 1.2.4.2 skrll goto next;
1107 1.2.4.2 skrll #if defined(KGDB) && !defined(DDB)
1108 1.2.4.2 skrll if (ISSET(sc->sc_hwflags, COM_HW_KGDB)){
1109 1.2.4.2 skrll kgdb_connect(1);
1110 1.2.4.2 skrll goto next;
1111 1.2.4.2 skrll }
1112 1.2.4.2 skrll #endif
1113 1.2.4.2 skrll } else {
1114 1.2.4.2 skrll int cn_trapped = 0;
1115 1.2.4.2 skrll
1116 1.2.4.2 skrll cn_check_magic(sc->sc_tty->t_dev,
1117 1.2.4.2 skrll (c & 0xff), epcom_cnm_state);
1118 1.2.4.2 skrll if (cn_trapped)
1119 1.2.4.2 skrll goto next;
1120 1.2.4.2 skrll }
1121 1.2.4.2 skrll
1122 1.2.4.2 skrll
1123 1.2.4.2 skrll put[0] = c & 0xff;
1124 1.2.4.2 skrll put[1] = csts & 0xf;
1125 1.2.4.2 skrll put += 2;
1126 1.2.4.2 skrll if (put >= end)
1127 1.2.4.2 skrll put = sc->sc_rbuf;
1128 1.2.4.2 skrll cc--;
1129 1.2.4.2 skrll next:
1130 1.2.4.2 skrll flagr = bus_space_read_4(iot, ioh, EPCOM_Flag);
1131 1.2.4.2 skrll }
1132 1.2.4.2 skrll
1133 1.2.4.2 skrll /*
1134 1.2.4.2 skrll * Current string of incoming characters ended because
1135 1.2.4.2 skrll * no more data was available or we ran out of space.
1136 1.2.4.2 skrll * Schedule a receive event if any data was received.
1137 1.2.4.2 skrll * If we're out of space, turn off receive interrupts.
1138 1.2.4.2 skrll */
1139 1.2.4.2 skrll sc->sc_rbput = put;
1140 1.2.4.2 skrll sc->sc_rbavail = cc;
1141 1.2.4.2 skrll if (!ISSET(sc->sc_rx_flags, RX_TTY_OVERFLOWED))
1142 1.2.4.2 skrll sc->sc_rx_ready = 1;
1143 1.2.4.2 skrll
1144 1.2.4.2 skrll /*
1145 1.2.4.2 skrll * See if we are in danger of overflowing a buffer. If
1146 1.2.4.2 skrll * so, use hardware flow control to ease the pressure.
1147 1.2.4.2 skrll */
1148 1.2.4.2 skrll
1149 1.2.4.2 skrll /* but epcom cannot. X-( */
1150 1.2.4.2 skrll
1151 1.2.4.2 skrll /*
1152 1.2.4.2 skrll * If we're out of space, disable receive interrupts
1153 1.2.4.2 skrll * until the queue has drained a bit.
1154 1.2.4.2 skrll */
1155 1.2.4.2 skrll if (!cc) {
1156 1.2.4.2 skrll SET(sc->sc_rx_flags, RX_IBUF_OVERFLOWED);
1157 1.2.4.2 skrll CLR(sc->sc_ctrl, (Ctrl_RIE|Ctrl_RTIE));
1158 1.2.4.2 skrll epcom_set(sc);
1159 1.2.4.2 skrll }
1160 1.2.4.2 skrll } else {
1161 1.2.4.2 skrll #ifdef DIAGNOSTIC
1162 1.2.4.2 skrll panic("epcomintr: we shouldn't reach here");
1163 1.2.4.2 skrll #endif
1164 1.2.4.2 skrll CLR(sc->sc_ctrl, (Ctrl_RIE|Ctrl_RTIE));
1165 1.2.4.2 skrll epcom_set(sc);
1166 1.2.4.2 skrll }
1167 1.2.4.2 skrll }
1168 1.2.4.2 skrll
1169 1.2.4.2 skrll /*
1170 1.2.4.2 skrll * Done handling any receive interrupts. See if data can be
1171 1.2.4.2 skrll * transmitted as well. Schedule tx done event if no data left
1172 1.2.4.2 skrll * and tty was marked busy.
1173 1.2.4.2 skrll */
1174 1.2.4.2 skrll
1175 1.2.4.2 skrll if (!ISSET(flagr, Flag_TXFF) && sc->sc_tbc > 0) {
1176 1.2.4.2 skrll /* Output the next chunk of the contiguous buffer, if any. */
1177 1.2.4.2 skrll epcom_filltx(sc);
1178 1.2.4.2 skrll } else {
1179 1.2.4.2 skrll /* Disable transmit completion interrupts if necessary. */
1180 1.2.4.2 skrll if (ISSET(sc->sc_ctrl, Ctrl_TIE)) {
1181 1.2.4.2 skrll CLR(sc->sc_ctrl, Ctrl_TIE);
1182 1.2.4.2 skrll epcom_set(sc);
1183 1.2.4.2 skrll }
1184 1.2.4.2 skrll if (sc->sc_tx_busy) {
1185 1.2.4.2 skrll sc->sc_tx_busy = 0;
1186 1.2.4.2 skrll sc->sc_tx_done = 1;
1187 1.2.4.2 skrll }
1188 1.2.4.2 skrll }
1189 1.2.4.2 skrll
1190 1.2.4.2 skrll /* Wake up the poller. */
1191 1.2.4.2 skrll softintr_schedule(sc->sc_si);
1192 1.2.4.2 skrll
1193 1.2.4.2 skrll #if 0 /* XXX: broken */
1194 1.2.4.2 skrll #if NRND > 0 && defined(RND_COM)
1195 1.2.4.2 skrll rnd_add_uint32(&sc->rnd_source, intr ^ flagr);
1196 1.2.4.2 skrll #endif
1197 1.2.4.2 skrll #endif
1198 1.2.4.2 skrll return (1);
1199 1.2.4.2 skrll }
1200