ser.c revision 1.10 1 1.1 mw /*
2 1.1 mw * Copyright (c) 1982, 1986, 1990 The Regents of the University of California.
3 1.1 mw * All rights reserved.
4 1.1 mw *
5 1.1 mw * Redistribution and use in source and binary forms, with or without
6 1.1 mw * modification, are permitted provided that the following conditions
7 1.1 mw * are met:
8 1.1 mw * 1. Redistributions of source code must retain the above copyright
9 1.1 mw * notice, this list of conditions and the following disclaimer.
10 1.1 mw * 2. Redistributions in binary form must reproduce the above copyright
11 1.1 mw * notice, this list of conditions and the following disclaimer in the
12 1.1 mw * documentation and/or other materials provided with the distribution.
13 1.1 mw * 3. All advertising materials mentioning features or use of this software
14 1.1 mw * must display the following acknowledgement:
15 1.1 mw * This product includes software developed by the University of
16 1.1 mw * California, Berkeley and its contributors.
17 1.1 mw * 4. Neither the name of the University nor the names of its contributors
18 1.1 mw * may be used to endorse or promote products derived from this software
19 1.1 mw * without specific prior written permission.
20 1.1 mw *
21 1.1 mw * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 1.1 mw * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 1.1 mw * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 1.1 mw * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 1.1 mw * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 1.1 mw * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 1.1 mw * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 1.1 mw * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 1.1 mw * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 1.1 mw * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 1.1 mw * SUCH DAMAGE.
32 1.1 mw *
33 1.4 mw * @(#)ser.c 7.12 (Berkeley) 6/27/91
34 1.10 chopps * $Id: ser.c,v 1.10 1994/02/13 21:11:01 chopps Exp $
35 1.1 mw */
36 1.1 mw
37 1.1 mw #include "ser.h"
38 1.1 mw
39 1.1 mw #if NSER > 0
40 1.10 chopps #include <sys/param.h>
41 1.10 chopps #include <sys/systm.h>
42 1.10 chopps #include <sys/ioctl.h>
43 1.10 chopps #include <sys/tty.h>
44 1.10 chopps #include <sys/proc.h>
45 1.10 chopps #include <sys/conf.h>
46 1.10 chopps #include <sys/file.h>
47 1.10 chopps #include <sys/malloc.h>
48 1.10 chopps #include <sys/uio.h>
49 1.10 chopps #include <sys/kernel.h>
50 1.10 chopps #include <sys/syslog.h>
51 1.10 chopps
52 1.10 chopps #include <amiga/dev/device.h>
53 1.10 chopps #include <amiga/dev/serreg.h>
54 1.10 chopps #include <machine/cpu.h>
55 1.10 chopps
56 1.10 chopps #include <amiga/amiga/custom.h>
57 1.10 chopps #include <amiga/amiga/cia.h>
58 1.10 chopps #include <amiga/amiga/dlists.h>
59 1.10 chopps #include <amiga/amiga/cc.h>
60 1.1 mw
61 1.1 mw int serprobe();
62 1.1 mw struct driver serdriver = {
63 1.1 mw serprobe, "ser",
64 1.1 mw };
65 1.1 mw
66 1.1 mw int serstart(), serparam(), serintr();
67 1.1 mw int ser_active;
68 1.1 mw int ser_hasfifo;
69 1.1 mw int nser = NSER;
70 1.1 mw #ifdef SERCONSOLE
71 1.1 mw int serconsole = SERCONSOLE;
72 1.1 mw #else
73 1.1 mw int serconsole = -1;
74 1.1 mw #endif
75 1.1 mw int serconsinit;
76 1.1 mw int serdefaultrate = TTYDEF_SPEED;
77 1.1 mw int sermajor;
78 1.1 mw struct serdevice *ser_addr[NSER];
79 1.5 mw struct vbl_node ser_vbl_node[NSER];
80 1.1 mw struct tty ser_cons;
81 1.3 mw struct tty *ser_tty[NSER];
82 1.1 mw
83 1.1 mw struct speedtab serspeedtab[] = {
84 1.1 mw 0, 0,
85 1.1 mw 50, SERBRD(50),
86 1.1 mw 75, SERBRD(75),
87 1.1 mw 110, SERBRD(110),
88 1.1 mw 134, SERBRD(134),
89 1.1 mw 150, SERBRD(150),
90 1.1 mw 200, SERBRD(200),
91 1.1 mw 300, SERBRD(300),
92 1.1 mw 600, SERBRD(600),
93 1.1 mw 1200, SERBRD(1200),
94 1.1 mw 1800, SERBRD(1800),
95 1.1 mw 2400, SERBRD(2400),
96 1.1 mw 4800, SERBRD(4800),
97 1.1 mw 9600, SERBRD(9600),
98 1.1 mw 19200, SERBRD(19200),
99 1.1 mw 38400, SERBRD(38400),
100 1.1 mw -1, -1
101 1.1 mw };
102 1.1 mw
103 1.1 mw
104 1.1 mw /* since this UART is not particularly bright (nice put), we'll have to do
105 1.1 mw parity stuff on our own. this table contains the 8th bit in 7bit character
106 1.1 mw mode, for even parity. If you want odd parity, flip the bit. (for
107 1.1 mw generation of the table, see genpar.c) */
108 1.1 mw
109 1.1 mw u_char even_parity[] = {
110 1.1 mw 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
111 1.1 mw 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
112 1.1 mw 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
113 1.1 mw 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
114 1.1 mw 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
115 1.1 mw 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
116 1.1 mw 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
117 1.1 mw 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
118 1.1 mw };
119 1.1 mw
120 1.1 mw
121 1.1 mw /* since we don't get interrupts for changes on the modem control line,
122 1.1 mw well have to fake them by comparing current settings to the settings
123 1.1 mw we remembered on last invocation. */
124 1.1 mw u_char last_ciab_pra;
125 1.1 mw
126 1.1 mw extern struct tty *constty;
127 1.1 mw #ifdef KGDB
128 1.10 chopps #include <machine/remote-sl.h>
129 1.1 mw
130 1.1 mw extern dev_t kgdb_dev;
131 1.1 mw extern int kgdb_rate;
132 1.1 mw extern int kgdb_debug_init;
133 1.1 mw #endif
134 1.1 mw
135 1.1 mw #ifdef DEBUG
136 1.1 mw long fifoin[17];
137 1.1 mw long fifoout[17];
138 1.1 mw long serintrcount[16];
139 1.1 mw long sermintcount[16];
140 1.1 mw #endif
141 1.1 mw
142 1.5 mw void sermint (register int unit);
143 1.5 mw
144 1.5 mw int
145 1.1 mw serprobe(ad)
146 1.5 mw register struct amiga_device *ad;
147 1.1 mw {
148 1.5 mw register struct serdevice *ser;
149 1.5 mw register int unit;
150 1.5 mw unsigned short ir = custom.intenar;
151 1.5 mw
152 1.5 mw ser = (struct serdevice *) ad->amiga_addr;
153 1.5 mw unit = ad->amiga_unit;
154 1.5 mw if (unit == serconsole)
155 1.5 mw DELAY(100000);
156 1.5 mw
157 1.5 mw ad->amiga_ipl = 2;
158 1.5 mw ser_addr[unit] = ser;
159 1.5 mw ser_active |= 1 << unit;
160 1.6 chopps ser_vbl_node[unit].function = (void (*)(void *))sermint;
161 1.5 mw add_vbl_function (&ser_vbl_node[unit], SER_VBL_PRIORITY, (void *)unit);
162 1.1 mw #ifdef KGDB
163 1.5 mw if (kgdb_dev == makedev(sermajor, unit)) {
164 1.5 mw if (serconsole == unit)
165 1.5 mw kgdb_dev = NODEV; /* can't debug over console port */
166 1.5 mw else {
167 1.5 mw (void) serinit(unit, kgdb_rate);
168 1.5 mw serconsinit = 1; /* don't re-init in serputc */
169 1.5 mw if (kgdb_debug_init) {
170 1.1 mw /*
171 1.5 mw * Print prefix of device name,
172 1.5 mw * let kgdb_connect print the rest.
173 1.1 mw */
174 1.5 mw printf("ser%d: ", unit);
175 1.5 mw kgdb_connect(1);
176 1.5 mw } else
177 1.5 mw printf("ser%d: kgdb enabled\n", unit);
178 1.5 mw }
179 1.5 mw }
180 1.5 mw #endif
181 1.5 mw /*
182 1.5 mw * Need to reset baud rate, etc. of next print so reset serconsinit.
183 1.5 mw */
184 1.5 mw if (unit == serconsole)
185 1.5 mw serconsinit = 0;
186 1.5 mw
187 1.5 mw return (1);
188 1.1 mw }
189 1.1 mw
190 1.1 mw /* ARGSUSED */
191 1.5 mw int
192 1.1 mw #ifdef __STDC__
193 1.1 mw seropen(dev_t dev, int flag, int mode, struct proc *p)
194 1.1 mw #else
195 1.1 mw seropen(dev, flag, mode, p)
196 1.5 mw dev_t dev;
197 1.5 mw int flag, mode;
198 1.5 mw struct proc *p;
199 1.1 mw #endif
200 1.1 mw {
201 1.5 mw register struct tty *tp;
202 1.5 mw register int unit;
203 1.5 mw int error = 0;
204 1.5 mw int s;
205 1.5 mw
206 1.5 mw unit = SERUNIT(dev);
207 1.1 mw
208 1.5 mw if (unit >= NSER || (ser_active & (1 << unit)) == 0)
209 1.5 mw return (ENXIO);
210 1.5 mw if(!ser_tty[unit])
211 1.5 mw {
212 1.5 mw tp = ser_tty[unit] = ttymalloc();
213 1.5 mw /* default values are not optimal for this device, increase
214 1.5 mw buffers */
215 1.5 mw clfree(&tp->t_rawq);
216 1.5 mw clfree(&tp->t_canq);
217 1.5 mw clfree(&tp->t_outq);
218 1.5 mw clalloc(&tp->t_rawq, 8192, 1);
219 1.5 mw clalloc(&tp->t_canq, 8192, 1);
220 1.5 mw clalloc(&tp->t_outq, 8192, 0);
221 1.5 mw }
222 1.5 mw else
223 1.5 mw tp = ser_tty[unit];
224 1.1 mw
225 1.6 chopps tp->t_oproc = (void (*)(struct tty *)) serstart;
226 1.5 mw tp->t_param = serparam;
227 1.5 mw tp->t_dev = dev;
228 1.5 mw
229 1.5 mw if ((tp->t_state & TS_ISOPEN) == 0)
230 1.5 mw {
231 1.5 mw tp->t_state |= TS_WOPEN;
232 1.5 mw ttychars(tp);
233 1.5 mw if (tp->t_ispeed == 0)
234 1.5 mw {
235 1.5 mw tp->t_iflag = TTYDEF_IFLAG | IXOFF; /* XXXXX */
236 1.5 mw tp->t_oflag = TTYDEF_OFLAG;
237 1.1 mw #if 0
238 1.5 mw tp->t_cflag = TTYDEF_CFLAG;
239 1.1 mw #else
240 1.5 mw tp->t_cflag = (CREAD | CS8 | CLOCAL); /* XXXXX */
241 1.1 mw #endif
242 1.5 mw tp->t_lflag = TTYDEF_LFLAG;
243 1.5 mw tp->t_ispeed = tp->t_ospeed = serdefaultrate;
244 1.1 mw }
245 1.5 mw serparam(tp, &tp->t_termios);
246 1.5 mw ttsetwater(tp);
247 1.5 mw }
248 1.5 mw else if (tp->t_state&TS_XCLUDE && p->p_ucred->cr_uid != 0)
249 1.5 mw return (EBUSY);
250 1.5 mw
251 1.5 mw (void) sermctl (dev, TIOCM_DTR | TIOCM_RTS, DMSET);
252 1.5 mw
253 1.5 mw if (DIALOUT(dev) || (sermctl (dev, 0, DMGET) & TIOCM_CD))
254 1.5 mw tp->t_state |= TS_CARR_ON;
255 1.5 mw
256 1.5 mw s = spltty();
257 1.5 mw while ((flag & O_NONBLOCK) == 0
258 1.5 mw && (tp->t_cflag & CLOCAL) == 0
259 1.5 mw && (tp->t_state & TS_CARR_ON) == 0)
260 1.5 mw {
261 1.5 mw tp->t_state |= TS_WOPEN;
262 1.5 mw if (error = ttysleep(tp, (caddr_t)&tp->t_rawq, TTIPRI | PCATCH,
263 1.5 mw ttopen, 0))
264 1.5 mw break;
265 1.5 mw }
266 1.5 mw splx (s);
267 1.5 mw if (error == 0)
268 1.5 mw {
269 1.5 mw /* reset the tty pointer, as there could have been a dialout
270 1.5 mw use of the tty with a dialin open waiting. */
271 1.5 mw tp->t_dev = dev;
272 1.5 mw error = (*linesw[tp->t_line].l_open)(dev, tp);
273 1.5 mw }
274 1.5 mw return (error);
275 1.1 mw }
276 1.1 mw
277 1.1 mw /*ARGSUSED*/
278 1.5 mw int
279 1.1 mw serclose(dev, flag, mode, p)
280 1.5 mw dev_t dev;
281 1.5 mw int flag, mode;
282 1.5 mw struct proc *p;
283 1.5 mw {
284 1.5 mw register struct tty *tp;
285 1.5 mw register struct serdevice *ser;
286 1.5 mw register int unit;
287 1.5 mw
288 1.5 mw unit = SERUNIT(dev);
289 1.5 mw
290 1.5 mw ser = ser_addr[unit];
291 1.5 mw tp = ser_tty[unit];
292 1.5 mw (*linesw[tp->t_line].l_close)(tp, flag);
293 1.5 mw custom.adkcon = ADKCONF_UARTBRK; /* clear break */
294 1.1 mw #ifdef KGDB
295 1.5 mw /* do not disable interrupts if debugging */
296 1.5 mw if (dev != kgdb_dev)
297 1.1 mw #endif
298 1.5 mw custom.intena = INTF_RBF|INTF_TBE; /* clear interrupt enable */
299 1.5 mw custom.intreq = INTF_RBF|INTF_TBE; /* and interrupt request */
300 1.1 mw #if 0
301 1.5 mw /* if the device is closed, it's close, no matter whether we deal with modem
302 1.5 mw control signals nor not. */
303 1.5 mw if (tp->t_cflag&HUPCL || tp->t_state&TS_WOPEN ||
304 1.5 mw (tp->t_state&TS_ISOPEN) == 0)
305 1.1 mw #endif
306 1.5 mw (void) sermctl(dev, 0, DMSET);
307 1.5 mw ttyclose(tp);
308 1.1 mw #if 0
309 1.5 mw if (tp != &ser_cons)
310 1.5 mw {
311 1.5 mw remove_vbl_function (&ser_vbl_node[unit]);
312 1.5 mw ttyfree (tp);
313 1.5 mw ser_tty[unit] = (struct tty *)NULL;
314 1.5 mw }
315 1.3 mw #endif
316 1.5 mw return (0);
317 1.1 mw }
318 1.1 mw
319 1.5 mw int
320 1.1 mw serread(dev, uio, flag)
321 1.5 mw dev_t dev;
322 1.5 mw struct uio *uio;
323 1.1 mw {
324 1.5 mw register struct tty *tp = ser_tty[SERUNIT(dev)];
325 1.5 mw int error;
326 1.3 mw
327 1.5 mw if (! tp)
328 1.5 mw return ENXIO;
329 1.1 mw
330 1.5 mw error = (*linesw[tp->t_line].l_read)(tp, uio, flag);
331 1.5 mw
332 1.5 mw return error;
333 1.1 mw }
334 1.1 mw
335 1.5 mw int
336 1.1 mw serwrite(dev, uio, flag)
337 1.5 mw dev_t dev;
338 1.5 mw struct uio *uio;
339 1.1 mw {
340 1.5 mw int unit = SERUNIT(dev);
341 1.5 mw register struct tty *tp = ser_tty[unit];
342 1.1 mw
343 1.5 mw if (! tp)
344 1.5 mw return ENXIO;
345 1.3 mw
346 1.5 mw /*
347 1.5 mw * (XXX) We disallow virtual consoles if the physical console is
348 1.5 mw * a serial port. This is in case there is a display attached that
349 1.5 mw * is not the console. In that situation we don't need/want the X
350 1.5 mw * server taking over the console.
351 1.5 mw */
352 1.5 mw if (constty && unit == serconsole)
353 1.5 mw constty = NULL;
354 1.5 mw return ((*linesw[tp->t_line].l_write)(tp, uio, flag));
355 1.1 mw }
356 1.3 mw
357 1.3 mw
358 1.3 mw /* don't do any processing of data here, so we store the raw code
359 1.5 mw obtained from the uart register. In theory, 110kBaud gives you
360 1.3 mw 11kcps, so 16k buffer should be more than enough, interrupt
361 1.3 mw latency of 1s should never happen, or something is seriously
362 1.3 mw wrong.. */
363 1.5 mw #define SERIBUF_SIZE 16384
364 1.3 mw static u_short serbuf[SERIBUF_SIZE];
365 1.3 mw static u_short *sbrpt = serbuf;
366 1.3 mw static u_short *sbwpt = serbuf;
367 1.3 mw
368 1.3 mw
369 1.3 mw /* this is a replacement for the lack of a hardware fifo. 32k should be
370 1.3 mw enough (there's only one unit anyway, so this is not going to
371 1.3 mw accumulate). */
372 1.3 mw void
373 1.3 mw ser_fastint ()
374 1.3 mw {
375 1.3 mw /* we're at RBE-level, which is higher than VBL-level which is used
376 1.3 mw to periodically transmit contents of this buffer up one layer,
377 1.3 mw so no spl-raising is necessary. */
378 1.3 mw
379 1.3 mw register u_short ints, code;
380 1.3 mw
381 1.3 mw ints = custom.intreqr & INTF_RBF;
382 1.3 mw if (! ints)
383 1.3 mw return;
384 1.3 mw
385 1.3 mw /* clear interrupt */
386 1.3 mw custom.intreq = ints;
387 1.3 mw /* this register contains both data and status bits! */
388 1.3 mw code = custom.serdatr;
389 1.3 mw
390 1.3 mw /* should really not happen, but you never know.. buffer
391 1.3 mw overflow. */
392 1.3 mw if (sbwpt + 1 == sbrpt
393 1.3 mw || (sbwpt == serbuf + SERIBUF_SIZE - 1 && sbrpt == serbuf))
394 1.3 mw {
395 1.3 mw log (LOG_WARNING, "ser_fastint: buffer overflow!");
396 1.3 mw return;
397 1.3 mw }
398 1.3 mw
399 1.3 mw *sbwpt++ = code;
400 1.3 mw if (sbwpt == serbuf + SERIBUF_SIZE)
401 1.3 mw sbwpt = serbuf;
402 1.3 mw }
403 1.3 mw
404 1.3 mw
405 1.3 mw int
406 1.5 mw serintr (unit)
407 1.5 mw register int unit;
408 1.1 mw {
409 1.5 mw register struct serdevice *ser;
410 1.5 mw int s1, s2;
411 1.1 mw
412 1.5 mw ser = ser_addr[unit];
413 1.1 mw
414 1.5 mw /* make sure we're not interrupted by another
415 1.5 mw vbl, but allow level5 ints */
416 1.5 mw s1 = spltty();
417 1.1 mw
418 1.5 mw /* ok, pass along any acumulated information .. */
419 1.5 mw while (sbrpt != sbwpt)
420 1.5 mw {
421 1.5 mw /* no collision with ser_fastint() */
422 1.5 mw sereint (unit, *sbrpt, ser);
423 1.5 mw /* lock against ser_fastint() */
424 1.5 mw s2 = spl5();
425 1.5 mw {
426 1.5 mw sbrpt++;
427 1.5 mw if (sbrpt == serbuf + SERIBUF_SIZE)
428 1.5 mw sbrpt = serbuf;
429 1.5 mw }
430 1.5 mw splx (s2);
431 1.5 mw }
432 1.5 mw
433 1.5 mw splx (s1);
434 1.1 mw
435 1.3 mw #if 0
436 1.3 mw /* add the code below if you really need it */
437 1.1 mw {
438 1.1 mw /*
439 1.1 mw * Process a received byte. Inline for speed...
440 1.1 mw */
441 1.1 mw #ifdef KGDB
442 1.1 mw #define RCVBYTE() \
443 1.1 mw ch = code & 0xff; \
444 1.1 mw if ((tp->t_state & TS_ISOPEN) == 0) { \
445 1.1 mw if (ch == FRAME_END && \
446 1.1 mw kgdb_dev == makedev(sermajor, unit)) \
447 1.1 mw kgdb_connect(0); /* trap into kgdb */ \
448 1.1 mw }
449 1.1 mw #else
450 1.1 mw #define RCVBYTE()
451 1.1 mw #endif
452 1.1 mw RCVBYTE();
453 1.1 mw /* sereint does the receive-processing */
454 1.1 mw sereint (unit, code, ser);
455 1.1 mw }
456 1.3 mw #endif
457 1.1 mw }
458 1.1 mw
459 1.5 mw int
460 1.1 mw sereint(unit, stat, ser)
461 1.5 mw register int unit, stat;
462 1.5 mw register struct serdevice *ser;
463 1.1 mw {
464 1.5 mw register struct tty *tp;
465 1.5 mw register int c;
466 1.5 mw register u_char ch;
467 1.1 mw
468 1.5 mw tp = ser_tty[unit];
469 1.5 mw if ((tp->t_state & TS_ISOPEN) == 0)
470 1.5 mw {
471 1.1 mw #ifdef KGDB
472 1.5 mw /* we don't care about parity errors */
473 1.5 mw if (kgdb_dev == makedev(sermajor, unit) && c == FRAME_END)
474 1.5 mw kgdb_connect(0); /* trap into kgdb */
475 1.1 mw #endif
476 1.5 mw return;
477 1.5 mw }
478 1.1 mw
479 1.5 mw ch = stat & 0xff;
480 1.5 mw c = ch;
481 1.5 mw /* all databits 0 including stop indicate break condition */
482 1.5 mw if (!(stat & 0x1ff))
483 1.5 mw c |= TTY_FE;
484 1.5 mw
485 1.5 mw /* if parity checking enabled, check parity */
486 1.5 mw else if ((tp->t_cflag & PARENB) &&
487 1.5 mw (((ch >> 7) + even_parity[ch & 0x7f] + !!(tp->t_cflag & PARODD)) & 1))
488 1.5 mw c |= TTY_PE;
489 1.5 mw
490 1.5 mw if (stat & SERDATRF_OVRUN)
491 1.5 mw log(LOG_WARNING, "ser%d: silo overflow\n", unit);
492 1.5 mw
493 1.5 mw (*linesw[tp->t_line].l_rint)(c, tp);
494 1.1 mw }
495 1.1 mw
496 1.3 mw /* this interrupt is periodically invoked in the vertical blank
497 1.3 mw interrupt. It's used to keep track of the modem control lines
498 1.3 mw and (new with the fast_int code) to move accumulated data
499 1.3 mw up into the tty layer. */
500 1.3 mw void
501 1.5 mw sermint (register int unit)
502 1.1 mw {
503 1.5 mw register struct tty *tp;
504 1.5 mw register u_char stat, last, istat;
505 1.5 mw register struct serdevice *ser;
506 1.5 mw
507 1.5 mw tp = ser_tty[unit];
508 1.5 mw if (!tp)
509 1.5 mw return;
510 1.3 mw
511 1.5 mw if ((tp->t_state & (TS_ISOPEN|TS_WOPEN)) == 0)
512 1.5 mw {
513 1.5 mw sbrpt = sbwpt = serbuf;
514 1.5 mw return;
515 1.5 mw }
516 1.5 mw
517 1.5 mw /* first empty buffer */
518 1.5 mw serintr (unit);
519 1.5 mw
520 1.5 mw stat = ciab.pra;
521 1.5 mw last = last_ciab_pra;
522 1.5 mw last_ciab_pra = stat;
523 1.1 mw
524 1.5 mw /* check whether any interesting signal changed state */
525 1.5 mw istat = stat ^ last;
526 1.1 mw
527 1.5 mw if ((istat & CIAB_PRA_CD) && DIALIN(tp->t_dev))
528 1.5 mw {
529 1.5 mw if (ISDCD (stat))
530 1.5 mw (*linesw[tp->t_line].l_modem)(tp, 1);
531 1.5 mw else if ((*linesw[tp->t_line].l_modem)(tp, 0) == 0)
532 1.5 mw {
533 1.5 mw CLRDTR (stat);
534 1.5 mw CLRRTS (stat);
535 1.5 mw ciab.pra = stat;
536 1.5 mw last_ciab_pra = stat;
537 1.5 mw }
538 1.5 mw }
539 1.5 mw if ((istat & CIAB_PRA_CTS) && (tp->t_state & TS_ISOPEN) &&
540 1.5 mw (tp->t_cflag & CRTSCTS))
541 1.5 mw {
542 1.5 mw #if 0
543 1.5 mw /* the line is up and we want to do rts/cts flow control */
544 1.5 mw if (ISCTS (stat))
545 1.5 mw {
546 1.5 mw tp->t_state &=~ TS_TTSTOP;
547 1.5 mw ttstart(tp);
548 1.5 mw /* cause tbe-int if we were stuck there */
549 1.5 mw custom.intreq = INTF_SETCLR | INTF_TBE;
550 1.5 mw }
551 1.5 mw else
552 1.5 mw tp->t_state |= TS_TTSTOP;
553 1.5 mw #else
554 1.5 mw /* do this on hardware level, not with tty driver */
555 1.5 mw if (ISCTS (stat))
556 1.5 mw {
557 1.5 mw tp->t_state &= ~TS_TTSTOP;
558 1.5 mw /* cause TBE interrupt */
559 1.5 mw custom.intreq = INTF_SETCLR | INTF_TBE;
560 1.5 mw }
561 1.5 mw #endif
562 1.5 mw }
563 1.1 mw }
564 1.1 mw
565 1.5 mw int
566 1.8 chopps serioctl(dev, cmd, data, flag, p)
567 1.8 chopps dev_t dev;
568 1.8 chopps caddr_t data;
569 1.8 chopps struct proc *p;
570 1.1 mw {
571 1.5 mw register struct tty *tp;
572 1.5 mw register int unit = SERUNIT(dev);
573 1.5 mw register struct serdevice *ser;
574 1.5 mw register int error;
575 1.5 mw
576 1.5 mw tp = ser_tty[unit];
577 1.5 mw if (! tp)
578 1.5 mw return ENXIO;
579 1.5 mw
580 1.8 chopps error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p);
581 1.5 mw if (error >= 0)
582 1.5 mw return (error);
583 1.5 mw
584 1.8 chopps error = ttioctl(tp, cmd, data, flag, p);
585 1.5 mw if (error >= 0)
586 1.5 mw return (error);
587 1.5 mw
588 1.5 mw ser = ser_addr[unit];
589 1.5 mw switch (cmd)
590 1.5 mw {
591 1.5 mw case TIOCSBRK:
592 1.5 mw custom.adkcon = ADKCONF_SETCLR | ADKCONF_UARTBRK;
593 1.5 mw break;
594 1.5 mw
595 1.5 mw case TIOCCBRK:
596 1.5 mw custom.adkcon = ADKCONF_UARTBRK;
597 1.5 mw break;
598 1.5 mw
599 1.5 mw case TIOCSDTR:
600 1.5 mw (void) sermctl(dev, TIOCM_DTR | TIOCM_RTS, DMBIS);
601 1.5 mw break;
602 1.5 mw
603 1.5 mw case TIOCCDTR:
604 1.5 mw (void) sermctl(dev, TIOCM_DTR | TIOCM_RTS, DMBIC);
605 1.5 mw break;
606 1.5 mw
607 1.5 mw case TIOCMSET:
608 1.5 mw (void) sermctl(dev, *(int *)data, DMSET);
609 1.5 mw break;
610 1.5 mw
611 1.5 mw case TIOCMBIS:
612 1.5 mw (void) sermctl(dev, *(int *)data, DMBIS);
613 1.5 mw break;
614 1.5 mw
615 1.5 mw case TIOCMBIC:
616 1.5 mw (void) sermctl(dev, *(int *)data, DMBIC);
617 1.5 mw break;
618 1.5 mw
619 1.5 mw case TIOCMGET:
620 1.5 mw *(int *)data = sermctl(dev, 0, DMGET);
621 1.5 mw break;
622 1.5 mw
623 1.5 mw default:
624 1.5 mw return (ENOTTY);
625 1.5 mw }
626 1.1 mw
627 1.5 mw return (0);
628 1.1 mw }
629 1.1 mw
630 1.5 mw int
631 1.1 mw serparam(tp, t)
632 1.5 mw register struct tty *tp;
633 1.5 mw register struct termios *t;
634 1.1 mw {
635 1.5 mw register struct serdevice *ser;
636 1.5 mw register int cfcr, cflag = t->c_cflag;
637 1.5 mw int unit = SERUNIT(tp->t_dev);
638 1.5 mw int ospeed = ttspeedtab(t->c_ospeed, serspeedtab);
639 1.5 mw
640 1.5 mw /* check requested parameters */
641 1.5 mw if (ospeed < 0 || (t->c_ispeed && t->c_ispeed != t->c_ospeed))
642 1.5 mw return (EINVAL);
643 1.5 mw
644 1.5 mw /* and copy to tty */
645 1.5 mw tp->t_ispeed = t->c_ispeed;
646 1.5 mw tp->t_ospeed = t->c_ospeed;
647 1.5 mw tp->t_cflag = cflag;
648 1.5 mw
649 1.5 mw custom.intena = INTF_SETCLR | INTF_RBF | INTF_TBE;
650 1.5 mw last_ciab_pra = ciab.pra;
651 1.5 mw
652 1.5 mw if (ospeed == 0)
653 1.5 mw {
654 1.5 mw (void) sermctl(tp->t_dev, 0, DMSET); /* hang up line */
655 1.5 mw return (0);
656 1.5 mw }
657 1.5 mw else
658 1.5 mw {
659 1.5 mw /* make sure any previous hangup is undone, ie.
660 1.5 mw reenable DTR. */
661 1.5 mw (void) sermctl (tp->t_dev, TIOCM_DTR | TIOCM_RTS, DMSET);
662 1.5 mw }
663 1.5 mw /* set the baud rate */
664 1.5 mw custom.serper = (0<<15) | ospeed; /* select 8 bit mode (instead of 9 bit) */
665 1.5 mw
666 1.5 mw return (0);
667 1.1 mw }
668 1.3 mw
669 1.3 mw
670 1.3 mw static void
671 1.3 mw ser_putchar (tp, c)
672 1.3 mw struct tty *tp;
673 1.3 mw unsigned short c;
674 1.3 mw {
675 1.3 mw /* handle truncation of character if necessary */
676 1.3 mw if ((tp->t_cflag & CSIZE) == CS7)
677 1.3 mw c &= 0x7f;
678 1.3 mw
679 1.3 mw /* handle parity if necessary (forces CS7) */
680 1.3 mw if (tp->t_cflag & PARENB)
681 1.3 mw {
682 1.5 mw c &= 0x7f;
683 1.5 mw if (even_parity[c])
684 1.3 mw c |= 0x80;
685 1.3 mw if (tp->t_cflag & PARODD)
686 1.3 mw c ^= 0x80;
687 1.3 mw }
688 1.3 mw
689 1.3 mw /* add stop bit(s) */
690 1.3 mw if (tp->t_cflag & CSTOPB)
691 1.3 mw c |= 0x300;
692 1.3 mw else
693 1.3 mw c |= 0x100;
694 1.3 mw
695 1.3 mw custom.serdat = c;
696 1.3 mw }
697 1.3 mw
698 1.3 mw
699 1.5 mw #define SEROBUF_SIZE 32
700 1.3 mw static u_char ser_outbuf[SEROBUF_SIZE];
701 1.3 mw static u_char *sob_ptr=ser_outbuf, *sob_end=ser_outbuf;
702 1.3 mw void
703 1.3 mw ser_outintr ()
704 1.3 mw {
705 1.3 mw struct tty *tp = ser_tty[0]; /* hmmmmm */
706 1.3 mw unsigned short c;
707 1.5 mw int s = spltty ();
708 1.3 mw
709 1.3 mw if (! tp)
710 1.5 mw goto out;
711 1.3 mw
712 1.3 mw if (! (custom.intreqr & INTF_TBE))
713 1.5 mw goto out;
714 1.3 mw
715 1.3 mw /* clear interrupt */
716 1.3 mw custom.intreq = INTF_TBE;
717 1.3 mw
718 1.3 mw if (sob_ptr == sob_end)
719 1.3 mw {
720 1.5 mw tp->t_state &= ~(TS_BUSY|TS_FLUSH);
721 1.5 mw if (tp->t_line)
722 1.5 mw (*linesw[tp->t_line].l_start)(tp);
723 1.5 mw else
724 1.5 mw serstart (tp);
725 1.5 mw
726 1.5 mw goto out;
727 1.3 mw }
728 1.3 mw
729 1.5 mw /* do hardware flow control here. if the CTS line goes down, don't
730 1.5 mw transmit anything. That way, we'll be restarted by the periodic
731 1.5 mw interrupt when CTS comes back up. */
732 1.5 mw if (ISCTS (ciab.pra))
733 1.5 mw ser_putchar (tp, *sob_ptr++);
734 1.5 mw out:
735 1.5 mw splx (s);
736 1.3 mw }
737 1.1 mw
738 1.5 mw int
739 1.1 mw serstart(tp)
740 1.5 mw register struct tty *tp;
741 1.1 mw {
742 1.5 mw register int cc, s;
743 1.5 mw int unit;
744 1.5 mw register struct serdevice *ser;
745 1.5 mw int hiwat = 0;
746 1.5 mw
747 1.5 mw if (! (tp->t_state & TS_ISOPEN))
748 1.5 mw return;
749 1.5 mw
750 1.5 mw unit = SERUNIT(tp->t_dev);
751 1.5 mw ser = ser_addr[unit];
752 1.5 mw
753 1.5 mw s = spltty();
754 1.5 mw if (tp->t_state & (TS_TIMEOUT|TS_TTSTOP))
755 1.5 mw goto out;
756 1.5 mw
757 1.5 mw cc = tp->t_outq.c_cc;
758 1.5 mw if (cc <= tp->t_lowat)
759 1.5 mw {
760 1.5 mw if (tp->t_state & TS_ASLEEP)
761 1.5 mw {
762 1.5 mw tp->t_state &= ~TS_ASLEEP;
763 1.6 chopps wakeup((caddr_t)&tp->t_outq);
764 1.3 mw }
765 1.5 mw selwakeup(&tp->t_wsel);
766 1.5 mw }
767 1.5 mw
768 1.5 mw if (! cc || (tp->t_state & TS_BUSY))
769 1.5 mw goto out;
770 1.5 mw
771 1.5 mw /* we only do bulk transfers if using CTSRTS flow control,
772 1.5 mw not for (probably sloooow) ixon/ixoff devices. */
773 1.5 mw if (! (tp->t_cflag & CRTSCTS))
774 1.5 mw cc = 1;
775 1.5 mw
776 1.5 mw /*
777 1.5 mw * Limit the amount of output we do in one burst
778 1.5 mw * to prevent hogging the CPU.
779 1.5 mw */
780 1.5 mw if (cc > SEROBUF_SIZE)
781 1.5 mw {
782 1.5 mw hiwat++;
783 1.5 mw cc = SEROBUF_SIZE;
784 1.5 mw }
785 1.5 mw cc = q_to_b (&tp->t_outq, ser_outbuf, cc);
786 1.5 mw if (cc > 0)
787 1.5 mw {
788 1.5 mw tp->t_state |= TS_BUSY;
789 1.5 mw
790 1.5 mw sob_ptr = ser_outbuf;
791 1.5 mw sob_end = ser_outbuf + cc;
792 1.5 mw /* get first character out, then have tbe-interrupts blow out
793 1.5 mw further characters, until buffer is empty, and TS_BUSY
794 1.5 mw gets cleared. */
795 1.5 mw ser_putchar (tp, *sob_ptr++);
796 1.5 mw }
797 1.1 mw
798 1.5 mw out:
799 1.5 mw splx(s);
800 1.1 mw }
801 1.1 mw
802 1.1 mw /*
803 1.1 mw * Stop output on a line.
804 1.1 mw */
805 1.1 mw /*ARGSUSED*/
806 1.5 mw int
807 1.1 mw serstop(tp, flag)
808 1.5 mw register struct tty *tp;
809 1.1 mw {
810 1.5 mw register int s;
811 1.1 mw
812 1.5 mw s = spltty();
813 1.5 mw if (tp->t_state & TS_BUSY)
814 1.5 mw {
815 1.5 mw if ((tp->t_state & TS_TTSTOP) == 0)
816 1.5 mw tp->t_state |= TS_FLUSH;
817 1.5 mw }
818 1.5 mw splx(s);
819 1.1 mw }
820 1.1 mw
821 1.5 mw int
822 1.1 mw sermctl(dev, bits, how)
823 1.5 mw dev_t dev;
824 1.5 mw int bits, how;
825 1.1 mw {
826 1.5 mw register struct serdevice *ser;
827 1.5 mw register int unit;
828 1.5 mw u_char ub;
829 1.5 mw int s;
830 1.1 mw
831 1.5 mw unit = SERUNIT(dev);
832 1.5 mw ser = ser_addr[unit];
833 1.1 mw
834 1.5 mw /* convert TIOCM* mask into CIA mask (which is really low-active!!) */
835 1.5 mw if (how != DMGET)
836 1.5 mw {
837 1.5 mw ub = 0;
838 1.5 mw if (bits & TIOCM_DTR) ub |= CIAB_PRA_DTR;
839 1.5 mw if (bits & TIOCM_RTS) ub |= CIAB_PRA_RTS;
840 1.5 mw if (bits & TIOCM_CTS) ub |= CIAB_PRA_CTS;
841 1.5 mw if (bits & TIOCM_CD) ub |= CIAB_PRA_CD;
842 1.5 mw if (bits & TIOCM_RI) ub |= CIAB_PRA_SEL; /* collision with /dev/par ! */
843 1.5 mw if (bits & TIOCM_DSR) ub |= CIAB_PRA_DSR;
844 1.5 mw }
845 1.1 mw
846 1.1 mw
847 1.5 mw s = spltty();
848 1.5 mw switch (how)
849 1.5 mw {
850 1.5 mw case DMSET:
851 1.5 mw /* invert and set */
852 1.5 mw ciab.pra = ~ub;
853 1.5 mw break;
854 1.5 mw
855 1.5 mw case DMBIC:
856 1.5 mw ciab.pra |= ub;
857 1.5 mw ub = ~ciab.pra;
858 1.5 mw break;
859 1.5 mw
860 1.5 mw case DMBIS:
861 1.5 mw ciab.pra &= ~ub;
862 1.5 mw ub = ~ciab.pra;
863 1.5 mw break;
864 1.5 mw
865 1.5 mw case DMGET:
866 1.5 mw ub = ~ciab.pra;
867 1.5 mw break;
868 1.5 mw }
869 1.5 mw (void) splx(s);
870 1.5 mw
871 1.5 mw bits = 0;
872 1.5 mw if (ub & CIAB_PRA_DTR) bits |= TIOCM_DTR;
873 1.5 mw if (ub & CIAB_PRA_RTS) bits |= TIOCM_RTS;
874 1.5 mw if (ub & CIAB_PRA_CTS) bits |= TIOCM_CTS;
875 1.5 mw if (ub & CIAB_PRA_CD) bits |= TIOCM_CD;
876 1.5 mw if (ub & CIAB_PRA_SEL) bits |= TIOCM_RI;
877 1.5 mw if (ub & CIAB_PRA_DSR) bits |= TIOCM_DSR;
878 1.5 mw
879 1.5 mw return bits;
880 1.1 mw }
881 1.1 mw
882 1.1 mw /*
883 1.1 mw * Following are all routines needed for SER to act as console
884 1.1 mw */
885 1.10 chopps #include <amiga/amiga/cons.h>
886 1.1 mw
887 1.1 mw sercnprobe(cp)
888 1.1 mw struct consdev *cp;
889 1.1 mw {
890 1.5 mw int unit = CONUNIT;
891 1.5 mw /* locate the major number */
892 1.5 mw for (sermajor = 0; sermajor < nchrdev; sermajor++)
893 1.5 mw if (cdevsw[sermajor].d_open == seropen)
894 1.5 mw break;
895 1.1 mw
896 1.5 mw /* XXX: ick */
897 1.5 mw unit = CONUNIT;
898 1.1 mw
899 1.5 mw /* initialize required fields */
900 1.5 mw cp->cn_dev = makedev(sermajor, unit);
901 1.3 mw #if 0
902 1.5 mw /* on ser it really doesn't matter whether we're later
903 1.5 mw using the tty interface or single-character io thru
904 1.5 mw cnputc, so don't reach out to later on remember that
905 1.5 mw our console is here (see ite.c) */
906 1.5 mw cp->cn_tp = ser_tty[unit];
907 1.5 mw #endif
908 1.5 mw cp->cn_pri = CN_NORMAL;
909 1.5 mw
910 1.5 mw /*
911 1.5 mw * If serconsole is initialized, raise our priority.
912 1.5 mw */
913 1.5 mw if (serconsole == unit)
914 1.5 mw cp->cn_pri = CN_REMOTE;
915 1.1 mw #ifdef KGDB
916 1.5 mw if (major(kgdb_dev) == 1) /* XXX */
917 1.5 mw kgdb_dev = makedev(sermajor, minor(kgdb_dev));
918 1.1 mw #endif
919 1.1 mw }
920 1.1 mw
921 1.1 mw sercninit(cp)
922 1.1 mw struct consdev *cp;
923 1.1 mw {
924 1.5 mw int unit = SERUNIT(cp->cn_dev);
925 1.1 mw
926 1.5 mw serinit(unit, serdefaultrate);
927 1.5 mw serconsole = unit;
928 1.5 mw serconsinit = 1;
929 1.1 mw }
930 1.1 mw
931 1.1 mw serinit(unit, rate)
932 1.1 mw int unit, rate;
933 1.1 mw {
934 1.5 mw int s;
935 1.1 mw
936 1.1 mw #ifdef lint
937 1.5 mw stat = unit; if (stat) return;
938 1.1 mw #endif
939 1.5 mw s = splhigh();
940 1.5 mw /* might want to fiddle with the CIA later ??? */
941 1.5 mw custom.serper = ttspeedtab(rate, serspeedtab);
942 1.5 mw splx(s);
943 1.1 mw }
944 1.1 mw
945 1.1 mw sercngetc(dev)
946 1.1 mw {
947 1.5 mw u_short stat;
948 1.5 mw int c, s;
949 1.1 mw
950 1.1 mw #ifdef lint
951 1.5 mw stat = dev; if (stat) return (0);
952 1.1 mw #endif
953 1.5 mw s = splhigh();
954 1.5 mw while (!((stat = custom.serdatr & 0xffff) & SERDATRF_RBF))
955 1.5 mw ;
956 1.5 mw c = stat & 0xff;
957 1.5 mw /* clear interrupt */
958 1.5 mw custom.intreq = INTF_RBF;
959 1.5 mw splx(s);
960 1.5 mw return (c);
961 1.1 mw }
962 1.1 mw
963 1.1 mw /*
964 1.1 mw * Console kernel output character routine.
965 1.1 mw */
966 1.1 mw sercnputc(dev, c)
967 1.5 mw dev_t dev;
968 1.5 mw register int c;
969 1.1 mw {
970 1.5 mw register int timo;
971 1.5 mw short stat;
972 1.5 mw int s = splhigh();
973 1.1 mw
974 1.1 mw #ifdef lint
975 1.5 mw stat = dev; if (stat) return;
976 1.1 mw #endif
977 1.5 mw if (serconsinit == 0)
978 1.5 mw {
979 1.5 mw (void) serinit(SERUNIT(dev), serdefaultrate);
980 1.5 mw serconsinit = 1;
981 1.5 mw }
982 1.5 mw
983 1.5 mw /* wait for any pending transmission to finish */
984 1.5 mw timo = 50000;
985 1.5 mw while (! (custom.serdatr & SERDATRF_TBE) && --timo)
986 1.5 mw ;
987 1.5 mw
988 1.5 mw custom.serdat = (c&0xff) | 0x100;
989 1.5 mw /* wait for this transmission to complete */
990 1.5 mw timo = 1500000;
991 1.5 mw while (! (custom.serdatr & SERDATRF_TBE) && --timo)
992 1.5 mw ;
993 1.5 mw
994 1.5 mw /* wait for the device (my vt100..) to process the data, since
995 1.5 mw we don't do flow-control with cnputc */
996 1.5 mw for (timo = 0; timo < 30000; timo++) ;
997 1.5 mw
998 1.5 mw /* clear any interrupts generated by this transmission */
999 1.5 mw custom.intreq = INTF_TBE;
1000 1.5 mw splx(s);
1001 1.1 mw }
1002 1.1 mw
1003 1.1 mw
1004 1.1 mw serspit(c)
1005 1.5 mw int c;
1006 1.1 mw {
1007 1.6 chopps register struct Custom *cu asm("a2") = (struct Custom *)CUSTOMbase;
1008 1.5 mw register int timo asm("d2");
1009 1.5 mw extern int cold;
1010 1.5 mw int s;
1011 1.5 mw
1012 1.5 mw if (c == 10)
1013 1.5 mw serspit (13);
1014 1.5 mw
1015 1.5 mw s = splhigh();
1016 1.5 mw
1017 1.5 mw /* wait for any pending transmission to finish */
1018 1.5 mw timo = 500000;
1019 1.5 mw while (! (cu->serdatr & (SERDATRF_TBE|SERDATRF_TSRE)) && --timo)
1020 1.5 mw ;
1021 1.5 mw cu->serdat = (c&0xff) | 0x100;
1022 1.5 mw /* wait for this transmission to complete */
1023 1.5 mw timo = 15000000;
1024 1.5 mw while (! (cu->serdatr & SERDATRF_TBE) && --timo)
1025 1.5 mw ;
1026 1.5 mw /* clear any interrupts generated by this transmission */
1027 1.5 mw cu->intreq = INTF_TBE;
1028 1.5 mw
1029 1.5 mw for (timo = 0; timo < 30000; timo++) ;
1030 1.5 mw
1031 1.5 mw splx (s);
1032 1.1 mw }
1033 1.1 mw
1034 1.3 mw serspits(cp)
1035 1.3 mw char *cp;
1036 1.3 mw {
1037 1.3 mw while (*cp)
1038 1.3 mw serspit(*cp++);
1039 1.3 mw }
1040 1.3 mw
1041 1.1 mw int
1042 1.1 mw serselect(dev, rw, p)
1043 1.5 mw dev_t dev;
1044 1.5 mw int rw;
1045 1.5 mw struct proc *p;
1046 1.5 mw {
1047 1.5 mw register struct tty *tp = ser_tty[SERUNIT(dev)];
1048 1.5 mw int nread;
1049 1.5 mw int s = spltty();
1050 1.5 mw struct proc *selp;
1051 1.5 mw
1052 1.5 mw switch (rw)
1053 1.5 mw {
1054 1.5 mw case FREAD:
1055 1.5 mw nread = ttnread(tp);
1056 1.5 mw if (nread > 0 || ((tp->t_cflag&CLOCAL) == 0
1057 1.5 mw && (tp->t_state&TS_CARR_ON) == 0))
1058 1.5 mw goto win;
1059 1.5 mw selrecord(p, &tp->t_rsel);
1060 1.5 mw break;
1061 1.5 mw
1062 1.5 mw case FWRITE:
1063 1.5 mw if (tp->t_outq.c_cc <= tp->t_lowat)
1064 1.5 mw goto win;
1065 1.5 mw selrecord(p, &tp->t_wsel);
1066 1.5 mw break;
1067 1.5 mw }
1068 1.5 mw splx(s);
1069 1.5 mw return (0);
1070 1.5 mw
1071 1.5 mw win:
1072 1.5 mw splx(s);
1073 1.5 mw return (1);
1074 1.1 mw }
1075 1.1 mw
1076 1.1 mw #endif
1077