CLEAN UP SLIP INTERFACE TO KEEP FROM HANGING
[unix-history] / usr / src / sys.386bsd / i386 / isa / com.c
CommitLineData
5ae84897
WJ
1/*-
2 * Copyright (c) 1991 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)com.c 7.5 (Berkeley) 5/16/91
be5839e2
CR
34 *
35 * PATCHES MAGIC LEVEL PATCH THAT GOT US HERE
36 * -------------------- ----- ----------------------
05e2df41 37 * CURRENT PATCH LEVEL: 2 00019
be5839e2
CR
38 * -------------------- ----- ----------------------
39 *
05e2df41 40 * 30 Aug 92 Poul-Henning Kamp Stabilize SLIP on lossy lines/UARTS
be5839e2 41 * 09 Aug 92 Christoph Robitschko Correct minor number on com ports
5ae84897
WJ
42 */
43static char rcsid[] = "$Header: /usr/bill/working/sys/i386/isa/RCS/com.c,v 1.2 92/01/21 14:34:11 william Exp $";
44
45#include "com.h"
46#if NCOM > 0
47/*
48 * COM driver, based on HP dca driver
49 * uses National Semiconductor NS16450/NS16550AF UART
50 */
51#include "param.h"
52#include "systm.h"
53#include "ioctl.h"
54#include "tty.h"
55#include "proc.h"
56#include "user.h"
57#include "conf.h"
58#include "file.h"
59#include "uio.h"
60#include "kernel.h"
61#include "syslog.h"
62
63#include "i386/isa/isa_device.h"
64#include "i386/isa/comreg.h"
65#include "i386/isa/ic/ns16550.h"
66#define cominor(d)
67
68int comprobe(), comattach(), comintr(), comstart(), comparam();
69
70struct isa_driver comdriver = {
71 comprobe, comattach, "com"
72};
73
74int comsoftCAR;
75int com_active;
76int com_hasfifo;
77int ncom = NCOM;
78#ifdef COMCONSOLE
79int comconsole = COMCONSOLE;
80#else
81int comconsole = -1;
82#endif
83int comconsinit;
84int comdefaultrate = TTYDEF_SPEED;
85int commajor;
86short com_addr[NCOM];
87struct tty com_tty[NCOM];
88
89struct speedtab comspeedtab[] = {
90 0, 0,
91 50, COMBRD(50),
92 75, COMBRD(75),
93 110, COMBRD(110),
94 134, COMBRD(134),
95 150, COMBRD(150),
96 200, COMBRD(200),
97 300, COMBRD(300),
98 600, COMBRD(600),
99 1200, COMBRD(1200),
100 1800, COMBRD(1800),
101 2400, COMBRD(2400),
102 4800, COMBRD(4800),
103 9600, COMBRD(9600),
104 19200, COMBRD(19200),
105 38400, COMBRD(38400),
106 57600, COMBRD(57600),
107 -1, -1
108};
109
110extern struct tty *constty;
111#ifdef KGDB
112#include "machine/remote-sl.h"
113
114extern int kgdb_dev;
115extern int kgdb_rate;
116extern int kgdb_debug_init;
117#endif
118
be5839e2 119#define UNIT(x) (minor(x))
5ae84897
WJ
120
121comprobe(dev)
122struct isa_device *dev;
123{
124 /* force access to id reg */
125 outb(dev->id_iobase+com_cfcr, 0);
126 outb(dev->id_iobase+com_iir, 0);
127 DELAY(100);
128 if ((inb(dev->id_iobase+com_iir) & 0x38) == 0)
129 return(1);
130 return(0);
131}
132
133
134int
135comattach(isdp)
136struct isa_device *isdp;
137{
138 struct tty *tp;
139 u_char unit;
140 int port = isdp->id_iobase;
141
be5839e2 142 unit = isdp->id_unit;
5ae84897
WJ
143 if (unit == comconsole)
144 DELAY(1000);
145 com_addr[unit] = port;
146 com_active |= 1 << unit;
147 comsoftCAR |= 1 << unit; /* XXX */
148
149 /* look for a NS 16550AF UART with FIFOs */
150 outb(port+com_fifo, FIFO_ENABLE|FIFO_RCV_RST|FIFO_XMT_RST|FIFO_TRIGGER_14);
151 DELAY(100);
152 if ((inb(port+com_iir) & IIR_FIFO_MASK) == IIR_FIFO_MASK) {
153 com_hasfifo |= 1 << unit;
154 printf(" fifo");
155 }
156
157 outb(port+com_ier, 0);
158 outb(port+com_mcr, 0 | MCR_IENABLE);
159#ifdef KGDB
be5839e2 160 if (kgdb_dev == makedev(commajor, unit)) {
5ae84897
WJ
161 if (comconsole == unit)
162 kgdb_dev = -1; /* can't debug over console port */
163 else {
164 (void) cominit(unit, kgdb_rate);
165 if (kgdb_debug_init) {
166 /*
167 * Print prefix of device name,
168 * let kgdb_connect print the rest.
169 */
170 printf("com%d: ", unit);
171 kgdb_connect(1);
172 } else
173 printf("com%d: kgdb enabled\n", unit);
174 }
175 }
176#endif
177 /*
178 * Need to reset baud rate, etc. of next print so reset comconsinit.
179 * Also make sure console is always "hardwired"
180 */
181 if (unit == comconsole) {
182 comconsinit = 0;
183 comsoftCAR |= (1 << unit);
184 }
185 return (1);
186}
187
188/* ARGSUSED */
189comopen(dev_t dev, int flag, int mode, struct proc *p)
190{
191 register struct tty *tp;
192 register int unit;
193 int error = 0;
194
195 unit = UNIT(dev);
196 if (unit >= NCOM || (com_active & (1 << unit)) == 0)
197 return (ENXIO);
198 tp = &com_tty[unit];
199 tp->t_oproc = comstart;
200 tp->t_param = comparam;
201 tp->t_dev = dev;
202 if ((tp->t_state & TS_ISOPEN) == 0) {
203 tp->t_state |= TS_WOPEN;
204 ttychars(tp);
205 if (tp->t_ispeed == 0) {
206 tp->t_iflag = TTYDEF_IFLAG;
207 tp->t_oflag = TTYDEF_OFLAG;
208 tp->t_cflag = TTYDEF_CFLAG;
209 tp->t_lflag = TTYDEF_LFLAG;
210 tp->t_ispeed = tp->t_ospeed = comdefaultrate;
211 }
212 comparam(tp, &tp->t_termios);
213 ttsetwater(tp);
214 } else if (tp->t_state&TS_XCLUDE && p->p_ucred->cr_uid != 0)
215 return (EBUSY);
216 (void) spltty();
217 (void) commctl(dev, MCR_DTR | MCR_RTS, DMSET);
218 if ((comsoftCAR & (1 << unit)) || (commctl(dev, 0, DMGET) & MSR_DCD))
219 tp->t_state |= TS_CARR_ON;
220 while ((flag&O_NONBLOCK) == 0 && (tp->t_cflag&CLOCAL) == 0 &&
221 (tp->t_state & TS_CARR_ON) == 0) {
222 tp->t_state |= TS_WOPEN;
223 if (error = ttysleep(tp, (caddr_t)&tp->t_raw, TTIPRI | PCATCH,
224 ttopen, 0))
225 break;
226 }
227 (void) spl0();
228 if (error == 0)
229 error = (*linesw[tp->t_line].l_open)(dev, tp);
230 return (error);
231}
232
233/*ARGSUSED*/
234comclose(dev, flag, mode, p)
235 dev_t dev;
236 int flag, mode;
237 struct proc *p;
238{
239 register struct tty *tp;
240 register com;
241 register int unit;
242
243 unit = UNIT(dev);
244 com = com_addr[unit];
245 tp = &com_tty[unit];
246 (*linesw[tp->t_line].l_close)(tp, flag);
247 outb(com+com_cfcr, inb(com+com_cfcr) & ~CFCR_SBREAK);
248#ifdef KGDB
249 /* do not disable interrupts if debugging */
be5839e2 250 if (kgdb_dev != makedev(commajor, unit))
5ae84897
WJ
251#endif
252 outb(com+com_ier, 0);
253 if (tp->t_cflag&HUPCL || tp->t_state&TS_WOPEN ||
254 (tp->t_state&TS_ISOPEN) == 0)
255 (void) commctl(dev, 0, DMSET);
256 ttyclose(tp);
257 return(0);
258}
259
260comread(dev, uio, flag)
261 dev_t dev;
262 struct uio *uio;
263{
264 register struct tty *tp = &com_tty[UNIT(dev)];
265
266 return ((*linesw[tp->t_line].l_read)(tp, uio, flag));
267}
268
269comwrite(dev, uio, flag)
270 dev_t dev;
271 struct uio *uio;
272{
273 int unit = UNIT(dev);
274 register struct tty *tp = &com_tty[unit];
275
276 /*
277 * (XXX) We disallow virtual consoles if the physical console is
278 * a serial port. This is in case there is a display attached that
279 * is not the console. In that situation we don't need/want the X
280 * server taking over the console.
281 */
282 if (constty && unit == comconsole)
283 constty = NULL;
284 return ((*linesw[tp->t_line].l_write)(tp, uio, flag));
285}
286
287comintr(unit)
288 register int unit;
289{
290 register com;
291 register u_char code;
292 register struct tty *tp;
293
be5839e2 294 unit;
5ae84897
WJ
295 com = com_addr[unit];
296 while (1) {
297 code = inb(com+com_iir);
298 switch (code & IIR_IMASK) {
299 case IIR_NOPEND:
300 return (1);
301 case IIR_RXTOUT:
302 case IIR_RXRDY:
303 tp = &com_tty[unit];
304/*
305 * Process received bytes. Inline for speed...
306 */
307#ifdef KGDB
308#define RCVBYTE() \
309 code = inb(com+com_data); \
310 if ((tp->t_state & TS_ISOPEN) == 0) { \
be5839e2 311 if (kgdb_dev == makedev(commajor, unit) && \
5ae84897
WJ
312 code == FRAME_END) \
313 kgdb_connect(0); /* trap into kgdb */ \
314 } else \
315 (*linesw[tp->t_line].l_rint)(code, tp)
316#else
317#define RCVBYTE() \
318 code = inb(com+com_data); \
319 if (tp->t_state & TS_ISOPEN) \
320 (*linesw[tp->t_line].l_rint)(code, tp)
321#endif
322
323 RCVBYTE();
324
325 if (com_hasfifo & (1 << unit))
326 while ((code = inb(com+com_lsr)) & LSR_RCV_MASK) {
327 if (code == LSR_RXRDY) {
328 RCVBYTE();
329 } else
330 comeint(unit, code, com);
331 }
332 break;
333 case IIR_TXRDY:
334 tp = &com_tty[unit];
335 tp->t_state &=~ (TS_BUSY|TS_FLUSH);
336 if (tp->t_line)
337 (*linesw[tp->t_line].l_start)(tp);
338 else
339 comstart(tp);
340 break;
341 case IIR_RLS:
342 comeint(unit, inb(com+com_lsr), com);
343 break;
344 default:
345 if (code & IIR_NOPEND)
346 return (1);
347 log(LOG_WARNING, "com%d: weird interrupt: 0x%x\n",
348 unit, code);
349 /* fall through */
350 case IIR_MLSC:
351 commint(unit, com);
352 break;
353 }
354 }
355}
356
357comeint(unit, stat, com)
358 register int unit, stat;
359 register com;
360{
361 register struct tty *tp;
362 register int c;
363
364 tp = &com_tty[unit];
365 c = inb(com+com_data);
366 if ((tp->t_state & TS_ISOPEN) == 0) {
367#ifdef KGDB
368 /* we don't care about parity errors */
369 if (((stat & (LSR_BI|LSR_FE|LSR_PE)) == LSR_PE) &&
be5839e2 370 kgdb_dev == makedev(commajor, unit) && c == FRAME_END)
5ae84897
WJ
371 kgdb_connect(0); /* trap into kgdb */
372#endif
373 return;
374 }
375 if (stat & (LSR_BI | LSR_FE))
376 c |= TTY_FE;
377 else if (stat & LSR_PE)
378 c |= TTY_PE;
05e2df41
PHK
379 else if (stat & LSR_OE) { /* 30 Aug 92*/
380 c |= TTY_PE; /* Ought to have it's own define... */
5ae84897 381 log(LOG_WARNING, "com%d: silo overflow\n", unit);
05e2df41 382 }
5ae84897
WJ
383 (*linesw[tp->t_line].l_rint)(c, tp);
384}
385
386commint(unit, com)
387 register int unit;
388 register com;
389{
390 register struct tty *tp;
391 register int stat;
392
393 tp = &com_tty[unit];
394 stat = inb(com+com_msr);
395 if ((stat & MSR_DDCD) && (comsoftCAR & (1 << unit)) == 0) {
396 if (stat & MSR_DCD)
397 (void)(*linesw[tp->t_line].l_modem)(tp, 1);
398 else if ((*linesw[tp->t_line].l_modem)(tp, 0) == 0)
399 outb(com+com_mcr,
400 inb(com+com_mcr) & ~(MCR_DTR | MCR_RTS) | MCR_IENABLE);
401 } else if ((stat & MSR_DCTS) && (tp->t_state & TS_ISOPEN) &&
402 (tp->t_flags & CRTSCTS)) {
403 /* the line is up and we want to do rts/cts flow control */
404 if (stat & MSR_CTS) {
405 tp->t_state &=~ TS_TTSTOP;
406 ttstart(tp);
407 } else
408 tp->t_state |= TS_TTSTOP;
409 }
410}
411
412comioctl(dev, cmd, data, flag)
413 dev_t dev;
414 caddr_t data;
415{
416 register struct tty *tp;
417 register int unit = UNIT(dev);
418 register com;
419 register int error;
420
421 tp = &com_tty[unit];
422 error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag);
423 if (error >= 0)
424 return (error);
425 error = ttioctl(tp, cmd, data, flag);
426 if (error >= 0)
427 return (error);
428
429 com = com_addr[unit];
430 switch (cmd) {
431
432 case TIOCSBRK:
433 outb(com+com_cfcr, inb(com+com_cfcr) | CFCR_SBREAK);
434 break;
435
436 case TIOCCBRK:
437 outb(com+com_cfcr, inb(com+com_cfcr) & ~CFCR_SBREAK);
438 break;
439
440 case TIOCSDTR:
441 (void) commctl(dev, MCR_DTR | MCR_RTS, DMBIS);
442 break;
443
444 case TIOCCDTR:
445 (void) commctl(dev, MCR_DTR | MCR_RTS, DMBIC);
446 break;
447
448 case TIOCMSET:
449 (void) commctl(dev, *(int *)data, DMSET);
450 break;
451
452 case TIOCMBIS:
453 (void) commctl(dev, *(int *)data, DMBIS);
454 break;
455
456 case TIOCMBIC:
457 (void) commctl(dev, *(int *)data, DMBIC);
458 break;
459
460 case TIOCMGET:
461 *(int *)data = commctl(dev, 0, DMGET);
462 break;
463
464 default:
465 return (ENOTTY);
466 }
467 return (0);
468}
469
470comparam(tp, t)
471 register struct tty *tp;
472 register struct termios *t;
473{
474 register com;
475 register int cfcr, cflag = t->c_cflag;
476 int unit = UNIT(tp->t_dev);
477 int ospeed = ttspeedtab(t->c_ospeed, comspeedtab);
478
479 /* check requested parameters */
480 if (ospeed < 0 || (t->c_ispeed && t->c_ispeed != t->c_ospeed))
481 return(EINVAL);
482 /* and copy to tty */
483 tp->t_ispeed = t->c_ispeed;
484 tp->t_ospeed = t->c_ospeed;
485 tp->t_cflag = cflag;
486
487 com = com_addr[unit];
488 outb(com+com_ier, IER_ERXRDY | IER_ETXRDY | IER_ERLS /*| IER_EMSC*/);
489 if (ospeed == 0) {
490 (void) commctl(unit, 0, DMSET); /* hang up line */
491 return(0);
492 }
493 outb(com+com_cfcr, inb(com+com_cfcr) | CFCR_DLAB);
494 outb(com+com_data, ospeed & 0xFF);
495 outb(com+com_ier, ospeed >> 8);
496 switch (cflag&CSIZE) {
497 case CS5:
498 cfcr = CFCR_5BITS; break;
499 case CS6:
500 cfcr = CFCR_6BITS; break;
501 case CS7:
502 cfcr = CFCR_7BITS; break;
503 case CS8:
504 cfcr = CFCR_8BITS; break;
505 }
506 if (cflag&PARENB) {
507 cfcr |= CFCR_PENAB;
508 if ((cflag&PARODD) == 0)
509 cfcr |= CFCR_PEVEN;
510 }
511 if (cflag&CSTOPB)
512 cfcr |= CFCR_STOPB;
513 outb(com+com_cfcr, cfcr);
514
515 if (com_hasfifo & (1 << unit))
516 outb(com+com_fifo, FIFO_ENABLE | FIFO_TRIGGER_14);
517
518 return(0);
519}
520
521comstart(tp)
522 register struct tty *tp;
523{
524 register com;
525 int s, unit, c;
526
527 unit = UNIT(tp->t_dev);
528 com = com_addr[unit];
529 s = spltty();
530 if (tp->t_state & (TS_TIMEOUT|TS_TTSTOP))
531 goto out;
532 if (RB_LEN(&tp->t_out) <= tp->t_lowat) {
533 if (tp->t_state&TS_ASLEEP) {
534 tp->t_state &= ~TS_ASLEEP;
535 wakeup((caddr_t)&tp->t_out);
536 }
537 if (tp->t_wsel) {
538 selwakeup(tp->t_wsel, tp->t_state & TS_WCOLL);
539 tp->t_wsel = 0;
540 tp->t_state &= ~TS_WCOLL;
541 }
542 }
543 if (RB_LEN(&tp->t_out) == 0)
544 goto out;
545 if (inb(com+com_lsr) & LSR_TXRDY) {
546 c = getc(&tp->t_out);
547 tp->t_state |= TS_BUSY;
548 outb(com+com_data, c);
549 if (com_hasfifo & (1 << unit))
550 for (c = 1; c < 16 && RB_LEN(&tp->t_out); ++c)
551 outb(com+com_data, getc(&tp->t_out));
552 }
553out:
554 splx(s);
555}
556
557/*
558 * Stop output on a line.
559 */
560/*ARGSUSED*/
561comstop(tp, flag)
562 register struct tty *tp;
563{
564 register int s;
565
566 s = spltty();
567 if (tp->t_state & TS_BUSY) {
568 if ((tp->t_state&TS_TTSTOP)==0)
569 tp->t_state |= TS_FLUSH;
570 }
571 splx(s);
572}
573
574commctl(dev, bits, how)
575 dev_t dev;
576 int bits, how;
577{
578 register com;
579 register int unit;
580 int s;
581
582 unit = UNIT(dev);
583 com = com_addr[unit];
584 s = spltty();
585 switch (how) {
586
587 case DMSET:
588 outb(com+com_mcr, bits | MCR_IENABLE);
589 break;
590
591 case DMBIS:
592 outb(com+com_mcr, inb(com+com_mcr) | bits | MCR_IENABLE);
593 break;
594
595 case DMBIC:
596 outb(com+com_mcr, inb(com+com_mcr) & ~bits | MCR_IENABLE);
597 break;
598
599 case DMGET:
600 bits = inb(com+com_msr);
601 break;
602 }
603 (void) splx(s);
604 return(bits);
605}
606
607/*
608 * Following are all routines needed for COM to act as console
609 */
610#include "i386/i386/cons.h"
611
612comcnprobe(cp)
613 struct consdev *cp;
614{
615 int unit;
616
617 /* locate the major number */
618 for (commajor = 0; commajor < nchrdev; commajor++)
619 if (cdevsw[commajor].d_open == comopen)
620 break;
621
622 /* XXX: ick */
623 unit = CONUNIT;
624 com_addr[CONUNIT] = CONADDR;
625
626 /* make sure hardware exists? XXX */
627
628 /* initialize required fields */
be5839e2 629 cp->cn_dev = makedev(commajor, unit);
5ae84897
WJ
630 cp->cn_tp = &com_tty[unit];
631#ifdef COMCONSOLE
632 cp->cn_pri = CN_REMOTE; /* Force a serial port console */
633#else
634 cp->cn_pri = CN_NORMAL;
635#endif
636}
637
638comcninit(cp)
639 struct consdev *cp;
640{
641 int unit = UNIT(cp->cn_dev);
642
643 cominit(unit, comdefaultrate);
644 comconsole = unit;
645 comconsinit = 1;
646}
647
648cominit(unit, rate)
649 int unit, rate;
650{
651 register int com;
652 int s;
653 short stat;
654
655#ifdef lint
656 stat = unit; if (stat) return;
657#endif
658 com = com_addr[unit];
659 s = splhigh();
660 outb(com+com_cfcr, CFCR_DLAB);
661 rate = ttspeedtab(comdefaultrate, comspeedtab);
662 outb(com+com_data, rate & 0xFF);
663 outb(com+com_ier, rate >> 8);
664 outb(com+com_cfcr, CFCR_8BITS);
665 outb(com+com_ier, IER_ERXRDY | IER_ETXRDY);
666 outb(com+com_fifo, FIFO_ENABLE|FIFO_RCV_RST|FIFO_XMT_RST|FIFO_TRIGGER_14);
667 stat = inb(com+com_iir);
668 splx(s);
669}
670
671comcngetc(dev)
672{
673 register com = com_addr[UNIT(dev)];
674 short stat;
675 int c, s;
676
677#ifdef lint
678 stat = dev; if (stat) return(0);
679#endif
680 s = splhigh();
681 while (((stat = inb(com+com_lsr)) & LSR_RXRDY) == 0)
682 ;
683 c = inb(com+com_data);
684 stat = inb(com+com_iir);
685 splx(s);
686 return(c);
687}
688
689/*
690 * Console kernel output character routine.
691 */
692comcnputc(dev, c)
693 dev_t dev;
694 register int c;
695{
696 register com = com_addr[UNIT(dev)];
697 register int timo;
698 short stat;
699 int s = splhigh();
700
701#ifdef lint
702 stat = dev; if (stat) return;
703#endif
704#ifdef KGDB
705 if (dev != kgdb_dev)
706#endif
707 if (comconsinit == 0) {
708 (void) cominit(UNIT(dev), comdefaultrate);
709 comconsinit = 1;
710 }
711 /* wait for any pending transmission to finish */
712 timo = 50000;
713 while (((stat = inb(com+com_lsr)) & LSR_TXRDY) == 0 && --timo)
714 ;
715 outb(com+com_data, c);
716 /* wait for this transmission to complete */
717 timo = 1500000;
718 while (((stat = inb(com+com_lsr)) & LSR_TXRDY) == 0 && --timo)
719 ;
720 /* clear any interrupts generated by this transmission */
721 stat = inb(com+com_iir);
722 splx(s);
723}
724#endif