update from netbsd
authorderaadt <deraadt@openbsd.org>
Fri, 15 Dec 1995 02:33:01 +0000 (02:33 +0000)
committerderaadt <deraadt@openbsd.org>
Fri, 15 Dec 1995 02:33:01 +0000 (02:33 +0000)
16 files changed:
etc/etc.alpha/disktab
etc/etc.amiga/MAKEDEV
etc/etc.amiga/Makefile.inc
etc/etc.amiga/disktab
etc/etc.atari/ttys
etc/etc.hp300/MAKEDEV
etc/etc.i386/MAKEDEV
etc/etc.pc532/disktab
etc/etc.sparc/disktab
etc/etc.sun3/MAKEDEV
etc/etc.sun3/disktab
sys/dev/ic/com.c
sys/dev/ic/comreg.h
sys/dev/ic/nec765reg.h
sys/dev/isa/com.c
sys/dev/isa/comreg.h

index 191f161..21bcc56 100644 (file)
@@ -1,10 +1,10 @@
-#      $NetBSD: disktab,v 1.1 1995/02/23 05:59:32 cgd Exp $
+#      $NetBSD: disktab,v 1.2 1995/10/13 03:09:39 cgd Exp $
 
 # A DEC RZ25, configured so that all of the free partition IDs are at
 # the end, etc.  A good setup to make a disk image from...
 rz25|RZ25|DEC RZ25 SCSI:\
        :ty=winchester:dt=SCSI:ns#62:nt#9:nc#1476:\
-       :pa#139500:oa#0:ba#8192:fa#1024:ta=4.2BSD:\
-       :pb#139500:ob#139500:tb=swap:\
+       :pa#111600:oa#0:ba#8192:fa#1024:ta=4.2BSD:\
+       :pb#111600:ob#111600:tb=swap:\
        :pc#823608:oc#0:\
-       :pd#544608:od#279000:bd#8192:fd#1024:td=4.2BSD:
+       :pd#600408:od#223200:bd#8192:fd#1024:td=4.2BSD:
index 9aafc78..8e3e66e 100644 (file)
@@ -1,6 +1,6 @@
 #!/bin/sh -
 #
-#      $NetBSD: MAKEDEV,v 1.17.2.1 1995/10/20 10:30:08 chopps Exp $
+#      $NetBSD: MAKEDEV,v 1.18 1995/11/28 05:40:18 jtc Exp $
 #
 # Copyright (c) 1990 The Regents of the University of California.
 # All rights reserved.
index b9fe9eb..0a05677 100644 (file)
@@ -1,7 +1,7 @@
 #
 #      etc.amiga/Makefile.inc -- amiga-specific etc Makefile targets
 #
-#      $NetBSD: Makefile.inc,v 1.6.2.2 1995/11/24 19:44:36 chopps Exp $
+#      $NetBSD: Makefile.inc,v 1.7 1995/11/28 05:40:21 jtc Exp $
 
 .ifdef DESTDIR
 snap_md: netbsd-install
index 7168ae9..3363eb6 100644 (file)
@@ -1,5 +1,5 @@
 #
-#      $NetBSD: disktab,v 1.3.2.1 1995/11/24 08:00:48 chopps Exp $
+#      $NetBSD: disktab,v 1.4 1995/11/28 05:40:23 jtc Exp $
 #
 # Disk geometry and partition layout tables. 
 # Key:
index 1de4c7d..c51c459 100644 (file)
@@ -1,5 +1,5 @@
 #
-#      $NetBSD: ttys,v 1.1.1.1.2.1 1995/11/21 07:21:35 leo Exp $
+#      $NetBSD: ttys,v 1.2 1995/11/28 05:40:26 jtc Exp $
 #
 #      from: @(#)ttys  5.1 (Berkeley) 4/17/89
 #
index 1bc88c9..0f22c23 100644 (file)
@@ -1,6 +1,6 @@
 #!/bin/sh -
 #
-#      $NetBSD: MAKEDEV,v 1.11.2.1 1995/11/07 08:24:41 thorpej Exp $
+#      $NetBSD: MAKEDEV,v 1.12 1995/11/05 23:50:22 thorpej Exp $
 #
 # Copyright (c) 1990 The Regents of the University of California.
 # All rights reserved.
index 60f88b0..a5a4b3e 100644 (file)
@@ -135,10 +135,17 @@ fd)
        ;;
 
 wt*)
-       umask 2
-       rm -f wt0 rwt0
-       mknod wt0       b 3 0;  chown root.operator wt0
-       mknod rwt0      c 10 0; chown root.operator rwt0
+       umask 2 ; unit=`expr $i : '..\(.*\)'`
+       case $i in
+       wt*) name=wt;  chr=10; blk=3;;
+       esac
+       rm -f $name$unit n$name$unit r$name$unit nr$name$unit
+       mknod $name$unit        b $blk `expr $unit '*' 8 + 0`
+       mknod n$name$unit       b $blk `expr $unit '*' 8 + 4`
+       mknod r$name$unit       c $chr `expr $unit '*' 8 + 0`
+       mknod nr$name$unit      c $chr `expr $unit '*' 8 + 4`
+       chgrp operator $name$unit n$name$unit r$name$unit nr$name$unit
+       chmod 640 $name$unit n$name$unit r$name$unit nr$name$unit
        umask 77
        ;;
 
@@ -211,22 +218,18 @@ st*)
        esac
        rm -f $name$unit n$name$unit e$name$unit en$name$unit \
                r$name$unit nr$name$unit er$name$unit enr$name$unit 
-       mknod ${name}${unit}    b $blk `expr $unit '*' 16 + 0`
-       mknod n${name}${unit}   b $blk `expr $unit '*' 16 + 1`
-       mknod e${name}${unit}   b $blk `expr $unit '*' 16 + 2`
-       mknod en${name}${unit}  b $blk `expr $unit '*' 16 + 3`
-       mknod r${name}${unit}   c $chr `expr $unit '*' 16 + 0`
-       mknod nr${name}${unit}  c $chr `expr $unit '*' 16 + 1`
-       mknod er${name}${unit}  c $chr `expr $unit '*' 16 + 2`
-       mknod enr${name}${unit} c $chr `expr $unit '*' 16 + 3`
-       chgrp operator ${name}${unit} n${name}${unit} \
-               e$name$unit en$name$unit \
-               r${name}${unit} nr${name}${unit} \
-               er${name}${unit} enr${name}${unit} 
-       chmod 640 ${name}${unit} n${name}${unit} \
-               e$name$unit en$name$unit \
-               r${name}${unit} nr${name}${unit} \
-               er${name}${unit} enr${name}${unit} 
+       mknod $name$unit        b $blk `expr $unit '*' 16 + 0`
+       mknod n$name$unit       b $blk `expr $unit '*' 16 + 1`
+       mknod e$name$unit       b $blk `expr $unit '*' 16 + 2`
+       mknod en$name$unit      b $blk `expr $unit '*' 16 + 3`
+       mknod r$name$unit       c $chr `expr $unit '*' 16 + 0`
+       mknod nr$name$unit      c $chr `expr $unit '*' 16 + 1`
+       mknod er$name$unit      c $chr `expr $unit '*' 16 + 2`
+       mknod enr$name$unit     c $chr `expr $unit '*' 16 + 3`
+       chgrp operator $name$unit n$name$unit e$name$unit en$name$unit \
+               r$name$unit nr$name$unit er$name$unit enr$name$unit 
+       chmod 640 $name$unit n$name$unit e$name$unit en$name$unit \
+               r$name$unit nr$name$unit er$name$unit enr$name$unit 
        umask 77
        ;;
 
@@ -236,9 +239,9 @@ ch*)
        ch*) name=ch;  chr=17;;
        esac
        rm -f $name$unit
-       mknod ${name}${unit}    c $chr `expr $unit '*' 16 + 0`
-       chgrp operator ${name}${unit}
-       chmod 640 ${name}${unit}
+       mknod $name$unit        c $chr `expr $unit '*' 16 + 0`
+       chgrp operator $name$unit
+       chmod 640 $name$unit
        umask 77
        ;;
 
@@ -258,33 +261,26 @@ cd*|mcd*)
        umask 77
        ;;
 
-lpa*)
-       unit=`expr $i : 'lpa\(.*\)'`
-       rm -f lpa$unit
-       mknod lpa$unit c 16 `expr $unit + 128`
-       chown root.wheel lpa$unit
-       ;;
-
-lpt*)
-       unit=`expr $i : 'lpt\(.*\)'`
-       rm -f lpt$unit
-       mknod lpt$unit c 16 $unit
-       chown root.wheel lpt$unit
-       ;;
-
-bpf*)
-       unit=`expr $i : 'bpf\(.*\)'`
-       rm -f bpf$unit
-       mknod bpf$unit c 23 $unit
-       chown root.wheel bpf$unit
+lpt*|lpa*)
+       unit=`expr $i : '...\(.*\)'`
+       case $i in
+       lpt*) name=lpt; flags=0;;
+       lpa*) name=lpa; flags=128;;
+       esac
+       rm -f $name$unit
+       mknod $name$unit c 16 `expr $unit + $flags`
+       chown root.wheel $name$unit
        ;;
 
-tun*)
-       unit=`expr $i : 'tun\(.*\)'`
-       rm -f tun$unit
-       mknod tun$unit c 40 $unit
-       chmod 600 tun$unit
-       chown root.wheel tun$unit
+bpf*|tun*)
+       unit=`expr $i : '...\(.*\)'`
+       case $i in
+       bpf*) name=bpf; chr=23;;
+       tun*) name=tun; chr=40;;
+       esac
+       rm -f $name$unit
+       mknod $name$unit c $chr $unit
+       chown root.wheel $name$unit
        ;;
 
 speaker)                                       # (XXX - installed)
@@ -300,25 +296,16 @@ lkm)
        chmod 640 lkm
        ;;
 
-mms*)
-       unit=`expr $i : 'mms\(.*\)'`
-       rm -f mms$unit
-       mknod mms$unit c 35 $unit
-       chown root.wheel mms$unit
-       ;;
-
-lms*)
-       unit=`expr $i : 'lms\(.*\)'`
-       rm -f lms$unit
-       mknod lms$unit c 36 $unit
-       chown root.wheel lms$unit
-       ;;
-
-pms*)
-       unit=`expr $i : 'pms\(.*\)'`
-       rm -f pms$unit
-       mknod pms$unit c 37 $unit
-       chown root.wheel pms$unit
+mms*|lms*|pms*)
+       unit=`expr $i : '.ms\(.*\)'`
+       case $i in
+       mms*) name=mms; chr=35;;
+       lms*) name=lms; chr=36;;
+       pms*) name=pms; chr=37;;
+       esac
+       rm -f $name$unit
+       mknod $name$unit c $chr $unit
+       chown root.wheel $name$unit
        ;;
 
 mouse*)                                                # (XXX)
index 32ff56b..d6976e9 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: disktab,v 1.2 1995/10/27 23:58:28 deraadt Exp $
+# $Id: disktab,v 1.3 1995/12/15 02:33:10 deraadt Exp $
 #
 # PC532 version.
 #
index 65d1d7f..c73868b 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: disktab,v 1.4 1995/11/01 17:40:06 deraadt Exp $
+# $Id: disktab,v 1.5 1995/12/15 02:33:11 deraadt Exp $
 #
 #      @(#)disktab     5.5 (Berkeley) 2/27/91
 #
index 77c217d..0f7d87e 100644 (file)
@@ -32,7 +32,7 @@
 # SUCH DAMAGE.
 #
 #      @(#)MAKEDEV     5.5 (Berkeley) 5/28/91
-#      $Id: MAKEDEV,v 1.2 1995/11/23 15:59:42 deraadt Exp $
+#      $Id: MAKEDEV,v 1.3 1995/12/15 02:33:13 deraadt Exp $
 #
 # Device "make" file.  Valid arguments:
 #      std     standard devices
index 4968d46..8967e51 100644 (file)
@@ -1,5 +1,5 @@
 #
-#      $NetBSD: disktab,v 1.2.2.1 1995/11/21 21:03:50 gwr Exp $
+#      $NetBSD: disktab,v 1.3 1995/11/21 20:58:33 gwr Exp $
 #
 # Disk geometry and partition layout tables. 
 # Key:
index 8c5c548..52b8dfc 100644 (file)
@@ -1,4 +1,4 @@
-/*     $NetBSD: com.c,v 1.61 1995/07/04 06:47:18 mycroft Exp $ */
+/*     $NetBSD: com.c,v 1.62 1995/10/15 19:43:04 mycroft Exp $ */
 
 /*-
  * Copyright (c) 1993, 1994, 1995 Charles M. Hannum.  All rights reserved.
@@ -61,6 +61,7 @@
 #include <dev/isa/isavar.h>
 #include <dev/isa/comreg.h>
 #include <dev/ic/ns16550reg.h>
+#define        com_lcr com_cfcr
 
 #define        COM_IBUFSIZE    (2 * 256)
 #define        COM_IHIGHWATER  ((3 * COM_IBUFSIZE) / 4)
@@ -84,7 +85,7 @@ struct com_softc {
 #define        COM_SW_CLOCAL   0x02
 #define        COM_SW_CRTSCTS  0x04
 #define        COM_SW_MDMBUF   0x08
-       u_char sc_msr, sc_mcr;
+       u_char sc_msr, sc_mcr, sc_lcr;
        u_char sc_dtr;
 
        u_char *sc_ibuf, *sc_ibufp, *sc_ibufhigh, *sc_ibufend;
@@ -125,10 +126,10 @@ extern int kgdb_debug_init;
 
 #define        COMUNIT(x)      (minor(x))
 
-#define        bis(c, b)       do { const register int com_ad = (c); \
-                            outb(com_ad, inb(com_ad) | (b)); } while(0)
-#define        bic(c, b)       do { const register int com_ad = (c); \
-                            outb(com_ad, inb(com_ad) & ~(b)); } while(0)
+/* Macros to clear/set/test flags. */
+#define        SET(t, f)       (t) |= (f)
+#define        CLR(t, f)       (t) &= ~(f)
+#define        ISSET(t, f)     ((t) & (f))
 
 int
 comspeed(speed)
@@ -161,7 +162,7 @@ comprobe1(iobase)
 {
 
        /* force access to id reg */
-       outb(iobase + com_cfcr, 0);
+       outb(iobase + com_lcr, 0);
        outb(iobase + com_iir, 0);
        if (inb(iobase + com_iir) & 0x38)
                return 0;
@@ -197,7 +198,7 @@ comattach(parent, self, aux)
        struct tty *tp;
 
        sc->sc_iobase = iobase;
-       sc->sc_hwflags = cf->cf_flags & COM_HW_NOIEN;
+       sc->sc_hwflags = ISSET(cf->cf_flags, COM_HW_NOIEN);
        sc->sc_swflags = 0;
 
        if (sc->sc_dev.dv_unit == comconsole)
@@ -207,9 +208,9 @@ comattach(parent, self, aux)
        outb(iobase + com_fifo,
            FIFO_ENABLE | FIFO_RCV_RST | FIFO_XMT_RST | FIFO_TRIGGER_14);
        delay(100);
-       if ((inb(iobase + com_iir) & IIR_FIFO_MASK) == IIR_FIFO_MASK)
-               if ((inb(iobase + com_fifo) & FIFO_TRIGGER_14) == FIFO_TRIGGER_14) {
-                       sc->sc_hwflags |= COM_HW_FIFO;
+       if (ISSET(inb(iobase + com_iir), IIR_FIFO_MASK) == IIR_FIFO_MASK)
+               if (ISSET(inb(iobase + com_fifo), FIFO_TRIGGER_14) == FIFO_TRIGGER_14) {
+                       SET(sc->sc_hwflags, COM_HW_FIFO);
                        printf(": ns16550a, working fifo\n");
                } else
                        printf(": ns16550, broken fifo\n");
@@ -251,8 +252,8 @@ comattach(parent, self, aux)
                 * comconsinit.  Also make sure console is always "hardwired".
                 */
                comconsinit = 0;
-               sc->sc_hwflags |= COM_HW_CONSOLE;
-               sc->sc_swflags |= COM_SW_SOFTCAR;
+               SET(sc->sc_hwflags, COM_HW_CONSOLE);
+               SET(sc->sc_swflags, COM_SW_SOFTCAR);
        }
 }
 
@@ -283,18 +284,18 @@ comopen(dev, flag, mode, p)
        tp->t_oproc = comstart;
        tp->t_param = comparam;
        tp->t_dev = dev;
-       if ((tp->t_state & TS_ISOPEN) == 0) {
-               tp->t_state |= TS_WOPEN;
+       if (!ISSET(tp->t_state, TS_ISOPEN)) {
+               SET(tp->t_state, TS_WOPEN);
                ttychars(tp);
                tp->t_iflag = TTYDEF_IFLAG;
                tp->t_oflag = TTYDEF_OFLAG;
                tp->t_cflag = TTYDEF_CFLAG;
-               if (sc->sc_swflags & COM_SW_CLOCAL)
-                       tp->t_cflag |= CLOCAL;
-               if (sc->sc_swflags & COM_SW_CRTSCTS)
-                       tp->t_cflag |= CRTSCTS;
-               if (sc->sc_swflags & COM_SW_MDMBUF)
-                       tp->t_cflag |= MDMBUF;
+               if (ISSET(sc->sc_swflags, COM_SW_CLOCAL))
+                       SET(tp->t_cflag, CLOCAL);
+               if (ISSET(sc->sc_swflags, COM_SW_CRTSCTS))
+                       SET(tp->t_cflag, CRTSCTS);
+               if (ISSET(sc->sc_swflags, COM_SW_MDMBUF))
+                       SET(tp->t_cflag, MDMBUF);
                tp->t_lflag = TTYDEF_LFLAG;
                tp->t_ispeed = tp->t_ospeed = comdefaultrate;
 
@@ -312,39 +313,39 @@ comopen(dev, flag, mode, p)
 
                iobase = sc->sc_iobase;
                /* Set the FIFO threshold based on the receive speed. */
-               if (sc->sc_hwflags & COM_HW_FIFO)
+               if (ISSET(sc->sc_hwflags, COM_HW_FIFO))
                        outb(iobase + com_fifo,
                            FIFO_ENABLE | FIFO_RCV_RST | FIFO_XMT_RST |
                            (tp->t_ispeed <= 1200 ? FIFO_TRIGGER_1 : FIFO_TRIGGER_8));
                /* flush any pending I/O */
-               while (inb(iobase + com_lsr) & LSR_RXRDY)
+               while (ISSET(inb(iobase + com_lsr), LSR_RXRDY))
                        (void) inb(iobase + com_data);
                /* you turn me on, baby */
                sc->sc_mcr = MCR_DTR | MCR_RTS;
-               if ((sc->sc_hwflags & COM_HW_NOIEN) == 0)
-                       sc->sc_mcr |= MCR_IENABLE;
+               if (!ISSET(sc->sc_hwflags, COM_HW_NOIEN))
+                       SET(sc->sc_mcr, MCR_IENABLE);
                outb(iobase + com_mcr, sc->sc_mcr);
                outb(iobase + com_ier,
                    IER_ERXRDY | IER_ETXRDY | IER_ERLS | IER_EMSC);
 
                sc->sc_msr = inb(iobase + com_msr);
-               if (sc->sc_swflags & COM_SW_SOFTCAR || sc->sc_msr & MSR_DCD ||
-                   tp->t_cflag & MDMBUF)
-                       tp->t_state |= TS_CARR_ON;
+               if (ISSET(sc->sc_swflags, COM_SW_SOFTCAR) ||
+                   ISSET(sc->sc_msr, MSR_DCD) || ISSET(tp->t_cflag, MDMBUF))
+                       SET(tp->t_state, TS_CARR_ON);
                else
-                       tp->t_state &= ~TS_CARR_ON;
-       } else if (tp->t_state&TS_XCLUDE && p->p_ucred->cr_uid != 0) {
+                       CLR(tp->t_state, TS_CARR_ON);
+       } else if (ISSET(tp->t_state, TS_XCLUDE) && p->p_ucred->cr_uid != 0)
                return EBUSY;
-       else
+       else
                s = spltty();
 
        /* wait for carrier if necessary */
-       if ((flag & O_NONBLOCK) == 0)
-               while ((tp->t_cflag & CLOCAL) == 0 &&
-                   (tp->t_state & TS_CARR_ON) == 0) {
-                       tp->t_state |= TS_WOPEN;
-                       error = ttysleep(tp, (caddr_t)&tp->t_rawq, 
-                           TTIPRI | PCATCH, ttopen, 0);
+       if (!ISSET(flag, O_NONBLOCK))
+               while (!ISSET(tp->t_cflag, CLOCAL) &&
+                   !ISSET(tp->t_state, TS_CARR_ON)) {
+                       SET(tp->t_state, TS_WOPEN);
+                       error = ttysleep(tp, &tp->t_rawq, TTIPRI | PCATCH,
+                           ttopen, 0);
                        if (error) {
                                /* XXX should turn off chip if we're the
                                   only waiter */
@@ -370,19 +371,20 @@ comclose(dev, flag, mode, p)
        int s;
 
        /* XXX This is for cons.c. */
-       if ((tp->t_state & TS_ISOPEN) == 0)
+       if (!ISSET(tp->t_state, TS_ISOPEN))
                return 0;
 
        (*linesw[tp->t_line].l_close)(tp, flag);
        s = spltty();
-       bic(iobase + com_cfcr, CFCR_SBREAK);
+       CLR(sc->sc_lcr, LCR_SBREAK);
+       outb(iobase + com_lcr, sc->sc_lcr);
        outb(iobase + com_ier, 0);
-       if (tp->t_cflag & HUPCL &&
-           (sc->sc_swflags & COM_SW_SOFTCAR) == 0) {
+       if (ISSET(tp->t_cflag, HUPCL) &&
+           !ISSET(sc->sc_swflags, COM_SW_SOFTCAR)) {
                /* XXX perhaps only clear DTR */
                outb(iobase + com_mcr, 0);
        }
-       tp->t_state &= ~(TS_BUSY | TS_FLUSH);
+       CLR(tp->t_state, TS_BUSY | TS_FLUSH);
        if (--comsopen == 0)
                untimeout(compoll, NULL);
        splx(s);
@@ -436,10 +438,10 @@ tiocm_xxx2mcr(data)
 {
        u_char m = 0;
 
-       if (data & TIOCM_DTR)
-               m |= MCR_DTR;
-       if (data & TIOCM_RTS)
-               m |= MCR_RTS;
+       if (ISSET(data, TIOCM_DTR))
+               SET(m, MCR_DTR);
+       if (ISSET(data, TIOCM_RTS))
+               SET(m, MCR_RTS);
        return m;
 }
 
@@ -466,63 +468,68 @@ comioctl(dev, cmd, data, flag, p)
 
        switch (cmd) {
        case TIOCSBRK:
-               bis(iobase + com_cfcr, CFCR_SBREAK);
+               SET(sc->sc_lcr, LCR_SBREAK);
+               outb(iobase + com_lcr, sc->sc_lcr);
                break;
        case TIOCCBRK:
-               bic(iobase + com_cfcr, CFCR_SBREAK);
+               CLR(sc->sc_lcr, LCR_SBREAK);
+               outb(iobase + com_lcr, sc->sc_lcr);
                break;
        case TIOCSDTR:
-               outb(iobase + com_mcr, sc->sc_mcr |= sc->sc_dtr);
+               SET(sc->sc_mcr, sc->sc_dtr);
+               outb(iobase + com_mcr, sc->sc_mcr);
                break;
        case TIOCCDTR:
-               outb(iobase + com_mcr, sc->sc_mcr &= ~sc->sc_dtr);
+               CLR(sc->sc_mcr, sc->sc_dtr);
+               outb(iobase + com_mcr, sc->sc_mcr);
                break;
        case TIOCMSET:
-               sc->sc_mcr &= ~(MCR_DTR | MCR_RTS);
+               CLR(sc->sc_mcr, MCR_DTR | MCR_RTS);
        case TIOCMBIS:
-               outb(iobase + com_mcr,
-                   sc->sc_mcr |= tiocm_xxx2mcr(*(int *)data));
+               SET(sc->sc_mcr, tiocm_xxx2mcr(*(int *)data));
+               outb(iobase + com_mcr, sc->sc_mcr);
                break;
        case TIOCMBIC:
-               outb(iobase + com_mcr,
-                   sc->sc_mcr &= ~tiocm_xxx2mcr(*(int *)data));
+               CLR(sc->sc_mcr, tiocm_xxx2mcr(*(int *)data));
+               outb(iobase + com_mcr, sc->sc_mcr);
                break;
        case TIOCMGET: {
                u_char m;
                int bits = 0;
 
                m = sc->sc_mcr;
-               if (m & MCR_DTR)
-                       bits |= TIOCM_DTR;
-               if (m & MCR_RTS)
-                       bits |= TIOCM_RTS;
+               if (ISSET(m, MCR_DTR))
+                       SET(bits, TIOCM_DTR);
+               if (ISSET(m, MCR_RTS))
+                       SET(bits, TIOCM_RTS);
                m = sc->sc_msr;
-               if (m & MSR_DCD)
-                       bits |= TIOCM_CD;
-               if (m & MSR_CTS)
-                       bits |= TIOCM_CTS;
-               if (m & MSR_DSR)
-                       bits |= TIOCM_DSR;
-               if (m & (MSR_RI | MSR_TERI))
-                       bits |= TIOCM_RI;
+               if (ISSET(m, MSR_DCD))
+                       SET(bits, TIOCM_CD);
+               if (ISSET(m, MSR_CTS))
+                       SET(bits, TIOCM_CTS);
+               if (ISSET(m, MSR_DSR))
+                       SET(bits, TIOCM_DSR);
+               if (ISSET(m, MSR_RI | MSR_TERI))
+                       SET(bits, TIOCM_RI);
                if (inb(iobase + com_ier))
-                       bits |= TIOCM_LE;
+                       SET(bits, TIOCM_LE);
                *(int *)data = bits;
                break;
        }
        case TIOCGFLAGS: {
-               int bits = 0;
-
-               if (sc->sc_swflags & COM_SW_SOFTCAR)
-                       bits |= TIOCFLAG_SOFTCAR;
-               if (sc->sc_swflags & COM_SW_CLOCAL)
-                       bits |= TIOCFLAG_CLOCAL;
-               if (sc->sc_swflags & COM_SW_CRTSCTS)
-                       bits |= TIOCFLAG_CRTSCTS;
-               if (sc->sc_swflags & COM_SW_MDMBUF)
-                       bits |= TIOCFLAG_MDMBUF;
-
-               *(int *)data = bits;
+               int driverbits, userbits = 0;
+
+               driverbits = sc->sc_swflags;
+               if (ISSET(driverbits, COM_SW_SOFTCAR))
+                       SET(userbits, TIOCFLAG_SOFTCAR);
+               if (ISSET(driverbits, COM_SW_CLOCAL))
+                       SET(userbits, TIOCFLAG_CLOCAL);
+               if (ISSET(driverbits, COM_SW_CRTSCTS))
+                       SET(userbits, TIOCFLAG_CRTSCTS);
+               if (ISSET(driverbits, COM_SW_MDMBUF))
+                       SET(userbits, TIOCFLAG_MDMBUF);
+
+               *(int *)data = userbits;
                break;
        }
        case TIOCSFLAGS: {
@@ -533,15 +540,15 @@ comioctl(dev, cmd, data, flag, p)
                        return(EPERM); 
 
                userbits = *(int *)data;
-               if ((userbits & TIOCFLAG_SOFTCAR) ||
-                   (sc->sc_hwflags & COM_HW_CONSOLE))
-                       driverbits |= COM_SW_SOFTCAR;
-               if (userbits & TIOCFLAG_CLOCAL)
-                       driverbits |= COM_SW_CLOCAL;
-               if (userbits & TIOCFLAG_CRTSCTS)
-                       driverbits |= COM_SW_CRTSCTS;
-               if (userbits & TIOCFLAG_MDMBUF)
-                       driverbits |= COM_SW_MDMBUF;
+               if (ISSET(userbits, TIOCFLAG_SOFTCAR) ||
+                   ISSET(sc->sc_hwflags, COM_HW_CONSOLE))
+                       SET(driverbits, COM_SW_SOFTCAR);
+               if (ISSET(userbits, TIOCFLAG_CLOCAL))
+                       SET(driverbits, COM_SW_CLOCAL);
+               if (ISSET(userbits, TIOCFLAG_CRTSCTS))
+                       SET(driverbits, COM_SW_CRTSCTS);
+               if (ISSET(userbits, TIOCFLAG_MDMBUF))
+                       SET(driverbits, COM_SW_MDMBUF);
 
                sc->sc_swflags = driverbits;
                break;
@@ -561,7 +568,7 @@ comparam(tp, t)
        struct com_softc *sc = comcd.cd_devs[COMUNIT(tp->t_dev)];
        int iobase = sc->sc_iobase;
        int ospeed = comspeed(t->c_ospeed);
-       u_char cfcr;
+       u_char lcr;
        tcflag_t oldcflag;
        int s;
 
@@ -569,61 +576,72 @@ comparam(tp, t)
        if (ospeed < 0 || (t->c_ispeed && t->c_ispeed != t->c_ospeed))
                return EINVAL;
 
-       switch (t->c_cflag & CSIZE) {
+       lcr = sc->sc_lcr & LCR_SBREAK;
+
+       switch (ISSET(t->c_cflag, CSIZE)) {
        case CS5:
-               cfcr = CFCR_5BITS;
+               SET(lcr, LCR_5BITS);
                break;
        case CS6:
-               cfcr = CFCR_6BITS;
+               SET(lcr, LCR_6BITS);
                break;
        case CS7:
-               cfcr = CFCR_7BITS;
+               SET(lcr, LCR_7BITS);
                break;
        case CS8:
-               cfcr = CFCR_8BITS;
+               SET(lcr, LCR_8BITS);
                break;
        }
-       if (t->c_cflag & PARENB) {
-               cfcr |= CFCR_PENAB;
-               if ((t->c_cflag & PARODD) == 0)
-                       cfcr |= CFCR_PEVEN;
+       if (ISSET(t->c_cflag, PARENB)) {
+               SET(lcr, LCR_PENAB);
+               if (!ISSET(t->c_cflag, PARODD))
+                       SET(lcr, LCR_PEVEN);
        }
-       if (t->c_cflag & CSTOPB)
-               cfcr |= CFCR_STOPB;
+       if (ISSET(t->c_cflag, CSTOPB))
+               SET(lcr, LCR_STOPB);
+
+       sc->sc_lcr = lcr;
 
        s = spltty();
 
-       if (ospeed == 0)
-               outb(iobase + com_mcr, sc->sc_mcr &= ~MCR_DTR);
+       if (ospeed == 0) {
+               CLR(sc->sc_mcr, MCR_DTR);
+               outb(iobase + com_mcr, sc->sc_mcr);
+       }
 
        /*
         * Set the FIFO threshold based on the receive speed, if we are
         * changing it.
         */
        if (tp->t_ispeed != t->c_ispeed) {
-               if (sc->sc_hwflags & COM_HW_FIFO)
+               if (ISSET(sc->sc_hwflags, COM_HW_FIFO))
                        outb(iobase + com_fifo,
                            FIFO_ENABLE |
                            (t->c_ispeed <= 1200 ? FIFO_TRIGGER_1 : FIFO_TRIGGER_8));
        }
 
        if (ospeed != 0) {
-               outb(iobase + com_cfcr, cfcr | CFCR_DLAB);
+               outb(iobase + com_lcr, lcr | LCR_DLAB);
                outb(iobase + com_dlbl, ospeed);
                outb(iobase + com_dlbh, ospeed >> 8);
-               outb(iobase + com_cfcr, cfcr);
-               outb(iobase + com_mcr, sc->sc_mcr |= MCR_DTR);
+               outb(iobase + com_lcr, lcr);
+               SET(sc->sc_mcr, MCR_DTR);
+               outb(iobase + com_mcr, sc->sc_mcr);
        } else
-               outb(iobase + com_cfcr, cfcr);
+               outb(iobase + com_lcr, lcr);
 
        /* When not using CRTSCTS, RTS follows DTR. */
-       if ((t->c_cflag & CRTSCTS) == 0) {
-               if (sc->sc_mcr & MCR_DTR) {
-                       if ((sc->sc_mcr & MCR_RTS) == 0)
-                               outb(iobase + com_mcr, sc->sc_mcr |= MCR_RTS);
+       if (!ISSET(t->c_cflag, CRTSCTS)) {
+               if (ISSET(sc->sc_mcr, MCR_DTR)) {
+                       if (!ISSET(sc->sc_mcr, MCR_RTS)) {
+                               SET(sc->sc_mcr, MCR_RTS);
+                               outb(iobase + com_mcr, sc->sc_mcr);
+                       }
                } else {
-                       if (sc->sc_mcr & MCR_RTS)
-                               outb(iobase + com_mcr, sc->sc_mcr &= ~MCR_RTS);
+                       if (ISSET(sc->sc_mcr, MCR_RTS)) {
+                               CLR(sc->sc_mcr, MCR_RTS);
+                               outb(iobase + com_mcr, sc->sc_mcr);
+                       }
                }
                sc->sc_dtr = MCR_DTR | MCR_RTS;
        } else
@@ -639,11 +657,12 @@ comparam(tp, t)
         * If DCD is off and MDMBUF is changed, ask the tty layer if we should
         * stop the device.
         */
-       if ((sc->sc_msr & MSR_DCD) == 0 &&
-           (sc->sc_swflags & COM_SW_SOFTCAR) == 0 &&
-           (oldcflag & MDMBUF) != (tp->t_cflag & MDMBUF) &&
+       if (!ISSET(sc->sc_msr, MSR_DCD) &&
+           !ISSET(sc->sc_swflags, COM_SW_SOFTCAR) &&
+           ISSET(oldcflag, MDMBUF) != ISSET(tp->t_cflag, MDMBUF) &&
            (*linesw[tp->t_line].l_modem)(tp, 0) == 0) {
-               outb(iobase + com_mcr, sc->sc_mcr &= ~sc->sc_dtr);
+               CLR(sc->sc_mcr, sc->sc_dtr);
+               outb(iobase + com_mcr, sc->sc_mcr);
        }
 
        splx(s);
@@ -659,22 +678,21 @@ comstart(tp)
        int s;
 
        s = spltty();
-       if (tp->t_state & (TS_TTSTOP | TS_BUSY))
+       if (ISSET(tp->t_state, TS_TTSTOP | TS_BUSY))
                goto out;
-       if ((tp->t_cflag & CRTSCTS) != 0 &&
-           (sc->sc_msr & MSR_CTS) == 0)
+       if (ISSET(tp->t_cflag, CRTSCTS) && !ISSET(sc->sc_msr, MSR_CTS))
                goto out;
        if (tp->t_outq.c_cc <= tp->t_lowat) {
-               if (tp->t_state & TS_ASLEEP) {
-                       tp->t_state &= ~TS_ASLEEP;
-                       wakeup((caddr_t)&tp->t_outq);
+               if (ISSET(tp->t_state, TS_ASLEEP)) {
+                       CLR(tp->t_state, TS_ASLEEP);
+                       wakeup(&tp->t_outq);
                }
                if (tp->t_outq.c_cc == 0)
                        goto out;
                selwakeup(&tp->t_wsel);
        }
-       tp->t_state |= TS_BUSY;
-       if (sc->sc_hwflags & COM_HW_FIFO) {
+       SET(tp->t_state, TS_BUSY);
+       if (ISSET(sc->sc_hwflags, COM_HW_FIFO)) {
                u_char buffer[16], *cp = buffer;
                int n = q_to_b(&tp->t_outq, cp, sizeof buffer);
                do {
@@ -696,9 +714,9 @@ comstop(tp, flag)
        int s;
 
        s = spltty();
-       if (tp->t_state & TS_BUSY)
-               if ((tp->t_state & TS_TTSTOP) == 0)
-                       tp->t_state |= TS_FLUSH;
+       if (ISSET(tp->t_state, TS_BUSY))
+               if (!ISSET(tp->t_state, TS_TTSTOP))
+                       SET(tp->t_state, TS_FLUSH);
        splx(s);
 }
 
@@ -772,14 +790,17 @@ compoll(arg)
                sc->sc_ibufhigh = sc->sc_ibuf + COM_IHIGHWATER;
                sc->sc_ibufend = sc->sc_ibuf + COM_IBUFSIZE;
 
-               if (tp == 0 || (tp->t_state & TS_ISOPEN) == 0) {
+               if (tp == 0 || !ISSET(tp->t_state, TS_ISOPEN)) {
                        splx(s);
                        continue;
                }
 
-               if ((tp->t_cflag & CRTSCTS) != 0 &&
-                   (sc->sc_mcr & MCR_RTS) == 0)
-                       outb(sc->sc_iobase + com_mcr, sc->sc_mcr |= MCR_RTS);
+               if (ISSET(tp->t_cflag, CRTSCTS) &&
+                   !ISSET(sc->sc_mcr, MCR_RTS)) {
+                       /* XXX */
+                       SET(sc->sc_mcr, MCR_RTS);
+                       outb(sc->sc_iobase + com_mcr, sc->sc_mcr);
+               }
 
                splx(s);
 
@@ -809,7 +830,7 @@ comintr(arg)
        struct tty *tp;
        u_char lsr, data, msr, delta;
 
-       if (inb(iobase + com_iir) & IIR_NOPEND)
+       if (ISSET(inb(iobase + com_iir), IIR_NOPEND))
                return (0);
 
        tp = sc->sc_tty;
@@ -817,12 +838,14 @@ comintr(arg)
        for (;;) {
                lsr = inb(iobase + com_lsr);
 
-               if (lsr & LSR_RCV_MASK) {
+               if (ISSET(lsr, LSR_RCV_MASK)) {
                        register u_char *p = sc->sc_ibufp;
 
                        comevents = 1;
                        do {
-                               if ((lsr & LSR_BI) != 0) {
+                               data = ISSET(lsr, LSR_RXRDY) ?
+                                   inb(iobase + com_data) : 0;
+                               if (ISSET(lsr, LSR_BI)) {
 #ifdef DDB
                                        if (sc->sc_dev.dv_unit == comconsole) {
                                                Debugger();
@@ -830,8 +853,7 @@ comintr(arg)
                                        }
 #endif
                                        data = '\0';
-                               } else
-                                       data = inb(iobase + com_data);
+                               }
                                if (p >= sc->sc_ibufend) {
                                        sc->sc_floods++;
                                        if (sc->sc_errors++ == 0)
@@ -840,43 +862,51 @@ comintr(arg)
                                        *p++ = data;
                                        *p++ = lsr;
                                        if (p == sc->sc_ibufhigh &&
-                                           (tp->t_cflag & CRTSCTS) != 0)
+                                           ISSET(tp->t_cflag, CRTSCTS)) {
+                                               /* XXX */
+                                               CLR(sc->sc_mcr, MCR_RTS);
                                                outb(iobase + com_mcr,
-                                                    sc->sc_mcr &= ~MCR_RTS);
+                                                    sc->sc_mcr);
+                                       }
                                }
                        next:
                                lsr = inb(iobase + com_lsr);
-                       } while (lsr & LSR_RCV_MASK);
+                       } while (ISSET(lsr, LSR_RCV_MASK));
 
                        sc->sc_ibufp = p;
                }
-
-               if (lsr & LSR_TXRDY && (tp->t_state & TS_BUSY) != 0) {
-                       tp->t_state &= ~TS_BUSY;
-                       if (tp->t_state & TS_FLUSH)
-                               tp->t_state &= ~TS_FLUSH;
-                       else
-                               (*linesw[tp->t_line].l_start)(tp);
-               }
+#if 0
+               else if (ISSET(lsr, LSR_BI|LSR_FE|LSR_PE|LSR_OE))
+                       printf("weird lsr %02x\n", lsr);
+#endif
 
                msr = inb(iobase + com_msr);
 
                if (msr != sc->sc_msr) {
                        delta = msr ^ sc->sc_msr;
                        sc->sc_msr = msr;
-                       if ((delta & MSR_DCD) != 0 &&
-                           (sc->sc_swflags & COM_SW_SOFTCAR) == 0 &&
-                           (*linesw[tp->t_line].l_modem)(tp, (msr & MSR_DCD) != 0) == 0) {
-                               outb(iobase + com_mcr, sc->sc_mcr &= ~sc->sc_dtr);
+                       if (ISSET(delta, MSR_DCD) &&
+                           !ISSET(sc->sc_swflags, COM_SW_SOFTCAR) &&
+                           (*linesw[tp->t_line].l_modem)(tp, ISSET(msr, MSR_DCD)) == 0) {
+                               CLR(sc->sc_mcr, sc->sc_dtr);
+                               outb(iobase + com_mcr, sc->sc_mcr);
                        }
-                       if ((delta & msr & MSR_CTS) != 0 &&
-                           (tp->t_cflag & CRTSCTS) != 0) {
+                       if (ISSET(delta & msr, MSR_CTS) &&
+                           ISSET(tp->t_cflag, CRTSCTS)) {
                                /* the line is up and we want to do rts/cts flow control */
                                (*linesw[tp->t_line].l_start)(tp);
                        }
                }
 
-               if (inb(iobase + com_iir) & IIR_NOPEND)
+               if (ISSET(lsr, LSR_TXRDY) && ISSET(tp->t_state, TS_BUSY)) {
+                       CLR(tp->t_state, TS_BUSY);
+                       if (ISSET(tp->t_state, TS_FLUSH))
+                               CLR(tp->t_state, TS_FLUSH);
+                       else
+                               (*linesw[tp->t_line].l_start)(tp);
+               }
+
+               if (ISSET(inb(iobase + com_iir), IIR_NOPEND))
                        return (1);
        }
 }
@@ -927,11 +957,11 @@ cominit(unit, rate)
        int iobase = CONADDR;
        u_char stat;
 
-       outb(iobase + com_cfcr, CFCR_DLAB);
+       outb(iobase + com_lcr, LCR_DLAB);
        rate = comspeed(comdefaultrate);
        outb(iobase + com_dlbl, rate);
        outb(iobase + com_dlbh, rate >> 8);
-       outb(iobase + com_cfcr, CFCR_8BITS);
+       outb(iobase + com_lcr, LCR_8BITS);
        outb(iobase + com_ier, IER_ERXRDY | IER_ETXRDY);
        outb(iobase + com_fifo, FIFO_ENABLE | FIFO_RCV_RST | FIFO_XMT_RST | FIFO_TRIGGER_4);
        stat = inb(iobase + com_iir);
@@ -945,7 +975,7 @@ comcngetc(dev)
        int iobase = CONADDR;
        u_char stat, c;
 
-       while (((stat = inb(iobase + com_lsr)) & LSR_RXRDY) == 0)
+       while (!ISSET(stat = inb(iobase + com_lsr), LSR_RXRDY))
                ;
        c = inb(iobase + com_data);
        stat = inb(iobase + com_iir);
@@ -975,12 +1005,12 @@ comcnputc(dev, c)
        }
        /* wait for any pending transmission to finish */
        timo = 50000;
-       while (((stat = inb(iobase + com_lsr)) & LSR_TXRDY) == 0 && --timo)
+       while (!ISSET(stat = inb(iobase + com_lsr), LSR_TXRDY) && --timo)
                ;
        outb(iobase + com_data, c);
        /* wait for this transmission to complete */
        timo = 1500000;
-       while (((stat = inb(iobase + com_lsr)) & LSR_TXRDY) == 0 && --timo)
+       while (!ISSET(stat = inb(iobase + com_lsr), LSR_TXRDY) && --timo)
                ;
        /* clear any interrupts generated by this transmission */
        stat = inb(iobase + com_iir);
index 4a4f0e9..da3fe9b 100644 (file)
@@ -1,4 +1,4 @@
-/*     $NetBSD: comreg.h,v 1.6 1995/06/28 04:31:30 cgd Exp $   */
+/*     $NetBSD: comreg.h,v 1.7 1995/10/15 19:43:07 mycroft Exp $       */
 
 /*-
  * Copyright (c) 1991 The Regents of the University of California.
 #define        FIFO_TRIGGER_8  0x80
 #define        FIFO_TRIGGER_14 0xc0
 
-/* character format control register */
-#define        CFCR_DLAB       0x80
-#define        CFCR_SBREAK     0x40
-#define        CFCR_PZERO      0x30
-#define        CFCR_PONE       0x20
-#define        CFCR_PEVEN      0x10
-#define        CFCR_PODD       0x00
-#define        CFCR_PENAB      0x08
-#define        CFCR_STOPB      0x04
-#define        CFCR_8BITS      0x03
-#define        CFCR_7BITS      0x02
-#define        CFCR_6BITS      0x01
-#define        CFCR_5BITS      0x00
+/* line control register */
+#define        LCR_DLAB        0x80
+#define        LCR_SBREAK      0x40
+#define        LCR_PZERO       0x30
+#define        LCR_PONE        0x20
+#define        LCR_PEVEN       0x10
+#define        LCR_PODD        0x00
+#define        LCR_PENAB       0x08
+#define        LCR_STOPB       0x04
+#define        LCR_8BITS       0x03
+#define        LCR_7BITS       0x02
+#define        LCR_6BITS       0x01
+#define        LCR_5BITS       0x00
 
 /* modem control register */
 #define        MCR_LOOPBACK    0x10
index 670117f..21d799a 100644 (file)
@@ -1,4 +1,4 @@
-/*     $NetBSD: nec765reg.h,v 1.3 1994/10/27 04:18:41 cgd Exp $        */
+/*     $NetBSD: nec765reg.h,v 1.4 1995/10/20 00:02:20 pk Exp $ */
 
 /*-
  * Copyright (c) 1991 The Regents of the University of California.
@@ -65,7 +65,7 @@
 #define NE7CMD_SENSED  4       /*  sense drive - requires unit select byte */
 #define NE7CMD_WRITE   0xc5    /*  write - requires eight additional bytes */
 #define NE7CMD_READ    0xe6    /*  read - requires eight additional bytes */
-#define NE7CMD_FORMAT  0x4c    /*  format - requires five additional bytes */
+#define NE7CMD_FORMAT  0x4d    /*  format - requires five additional bytes */
 #define NE7CMD_RECAL   7       /*  recalibrate drive - requires
                                        unit select byte */
 #define NE7CMD_SENSEI  8       /*  sense controller interrupt status */
index 8c5c548..52b8dfc 100644 (file)
@@ -1,4 +1,4 @@
-/*     $NetBSD: com.c,v 1.61 1995/07/04 06:47:18 mycroft Exp $ */
+/*     $NetBSD: com.c,v 1.62 1995/10/15 19:43:04 mycroft Exp $ */
 
 /*-
  * Copyright (c) 1993, 1994, 1995 Charles M. Hannum.  All rights reserved.
@@ -61,6 +61,7 @@
 #include <dev/isa/isavar.h>
 #include <dev/isa/comreg.h>
 #include <dev/ic/ns16550reg.h>
+#define        com_lcr com_cfcr
 
 #define        COM_IBUFSIZE    (2 * 256)
 #define        COM_IHIGHWATER  ((3 * COM_IBUFSIZE) / 4)
@@ -84,7 +85,7 @@ struct com_softc {
 #define        COM_SW_CLOCAL   0x02
 #define        COM_SW_CRTSCTS  0x04
 #define        COM_SW_MDMBUF   0x08
-       u_char sc_msr, sc_mcr;
+       u_char sc_msr, sc_mcr, sc_lcr;
        u_char sc_dtr;
 
        u_char *sc_ibuf, *sc_ibufp, *sc_ibufhigh, *sc_ibufend;
@@ -125,10 +126,10 @@ extern int kgdb_debug_init;
 
 #define        COMUNIT(x)      (minor(x))
 
-#define        bis(c, b)       do { const register int com_ad = (c); \
-                            outb(com_ad, inb(com_ad) | (b)); } while(0)
-#define        bic(c, b)       do { const register int com_ad = (c); \
-                            outb(com_ad, inb(com_ad) & ~(b)); } while(0)
+/* Macros to clear/set/test flags. */
+#define        SET(t, f)       (t) |= (f)
+#define        CLR(t, f)       (t) &= ~(f)
+#define        ISSET(t, f)     ((t) & (f))
 
 int
 comspeed(speed)
@@ -161,7 +162,7 @@ comprobe1(iobase)
 {
 
        /* force access to id reg */
-       outb(iobase + com_cfcr, 0);
+       outb(iobase + com_lcr, 0);
        outb(iobase + com_iir, 0);
        if (inb(iobase + com_iir) & 0x38)
                return 0;
@@ -197,7 +198,7 @@ comattach(parent, self, aux)
        struct tty *tp;
 
        sc->sc_iobase = iobase;
-       sc->sc_hwflags = cf->cf_flags & COM_HW_NOIEN;
+       sc->sc_hwflags = ISSET(cf->cf_flags, COM_HW_NOIEN);
        sc->sc_swflags = 0;
 
        if (sc->sc_dev.dv_unit == comconsole)
@@ -207,9 +208,9 @@ comattach(parent, self, aux)
        outb(iobase + com_fifo,
            FIFO_ENABLE | FIFO_RCV_RST | FIFO_XMT_RST | FIFO_TRIGGER_14);
        delay(100);
-       if ((inb(iobase + com_iir) & IIR_FIFO_MASK) == IIR_FIFO_MASK)
-               if ((inb(iobase + com_fifo) & FIFO_TRIGGER_14) == FIFO_TRIGGER_14) {
-                       sc->sc_hwflags |= COM_HW_FIFO;
+       if (ISSET(inb(iobase + com_iir), IIR_FIFO_MASK) == IIR_FIFO_MASK)
+               if (ISSET(inb(iobase + com_fifo), FIFO_TRIGGER_14) == FIFO_TRIGGER_14) {
+                       SET(sc->sc_hwflags, COM_HW_FIFO);
                        printf(": ns16550a, working fifo\n");
                } else
                        printf(": ns16550, broken fifo\n");
@@ -251,8 +252,8 @@ comattach(parent, self, aux)
                 * comconsinit.  Also make sure console is always "hardwired".
                 */
                comconsinit = 0;
-               sc->sc_hwflags |= COM_HW_CONSOLE;
-               sc->sc_swflags |= COM_SW_SOFTCAR;
+               SET(sc->sc_hwflags, COM_HW_CONSOLE);
+               SET(sc->sc_swflags, COM_SW_SOFTCAR);
        }
 }
 
@@ -283,18 +284,18 @@ comopen(dev, flag, mode, p)
        tp->t_oproc = comstart;
        tp->t_param = comparam;
        tp->t_dev = dev;
-       if ((tp->t_state & TS_ISOPEN) == 0) {
-               tp->t_state |= TS_WOPEN;
+       if (!ISSET(tp->t_state, TS_ISOPEN)) {
+               SET(tp->t_state, TS_WOPEN);
                ttychars(tp);
                tp->t_iflag = TTYDEF_IFLAG;
                tp->t_oflag = TTYDEF_OFLAG;
                tp->t_cflag = TTYDEF_CFLAG;
-               if (sc->sc_swflags & COM_SW_CLOCAL)
-                       tp->t_cflag |= CLOCAL;
-               if (sc->sc_swflags & COM_SW_CRTSCTS)
-                       tp->t_cflag |= CRTSCTS;
-               if (sc->sc_swflags & COM_SW_MDMBUF)
-                       tp->t_cflag |= MDMBUF;
+               if (ISSET(sc->sc_swflags, COM_SW_CLOCAL))
+                       SET(tp->t_cflag, CLOCAL);
+               if (ISSET(sc->sc_swflags, COM_SW_CRTSCTS))
+                       SET(tp->t_cflag, CRTSCTS);
+               if (ISSET(sc->sc_swflags, COM_SW_MDMBUF))
+                       SET(tp->t_cflag, MDMBUF);
                tp->t_lflag = TTYDEF_LFLAG;
                tp->t_ispeed = tp->t_ospeed = comdefaultrate;
 
@@ -312,39 +313,39 @@ comopen(dev, flag, mode, p)
 
                iobase = sc->sc_iobase;
                /* Set the FIFO threshold based on the receive speed. */
-               if (sc->sc_hwflags & COM_HW_FIFO)
+               if (ISSET(sc->sc_hwflags, COM_HW_FIFO))
                        outb(iobase + com_fifo,
                            FIFO_ENABLE | FIFO_RCV_RST | FIFO_XMT_RST |
                            (tp->t_ispeed <= 1200 ? FIFO_TRIGGER_1 : FIFO_TRIGGER_8));
                /* flush any pending I/O */
-               while (inb(iobase + com_lsr) & LSR_RXRDY)
+               while (ISSET(inb(iobase + com_lsr), LSR_RXRDY))
                        (void) inb(iobase + com_data);
                /* you turn me on, baby */
                sc->sc_mcr = MCR_DTR | MCR_RTS;
-               if ((sc->sc_hwflags & COM_HW_NOIEN) == 0)
-                       sc->sc_mcr |= MCR_IENABLE;
+               if (!ISSET(sc->sc_hwflags, COM_HW_NOIEN))
+                       SET(sc->sc_mcr, MCR_IENABLE);
                outb(iobase + com_mcr, sc->sc_mcr);
                outb(iobase + com_ier,
                    IER_ERXRDY | IER_ETXRDY | IER_ERLS | IER_EMSC);
 
                sc->sc_msr = inb(iobase + com_msr);
-               if (sc->sc_swflags & COM_SW_SOFTCAR || sc->sc_msr & MSR_DCD ||
-                   tp->t_cflag & MDMBUF)
-                       tp->t_state |= TS_CARR_ON;
+               if (ISSET(sc->sc_swflags, COM_SW_SOFTCAR) ||
+                   ISSET(sc->sc_msr, MSR_DCD) || ISSET(tp->t_cflag, MDMBUF))
+                       SET(tp->t_state, TS_CARR_ON);
                else
-                       tp->t_state &= ~TS_CARR_ON;
-       } else if (tp->t_state&TS_XCLUDE && p->p_ucred->cr_uid != 0) {
+                       CLR(tp->t_state, TS_CARR_ON);
+       } else if (ISSET(tp->t_state, TS_XCLUDE) && p->p_ucred->cr_uid != 0)
                return EBUSY;
-       else
+       else
                s = spltty();
 
        /* wait for carrier if necessary */
-       if ((flag & O_NONBLOCK) == 0)
-               while ((tp->t_cflag & CLOCAL) == 0 &&
-                   (tp->t_state & TS_CARR_ON) == 0) {
-                       tp->t_state |= TS_WOPEN;
-                       error = ttysleep(tp, (caddr_t)&tp->t_rawq, 
-                           TTIPRI | PCATCH, ttopen, 0);
+       if (!ISSET(flag, O_NONBLOCK))
+               while (!ISSET(tp->t_cflag, CLOCAL) &&
+                   !ISSET(tp->t_state, TS_CARR_ON)) {
+                       SET(tp->t_state, TS_WOPEN);
+                       error = ttysleep(tp, &tp->t_rawq, TTIPRI | PCATCH,
+                           ttopen, 0);
                        if (error) {
                                /* XXX should turn off chip if we're the
                                   only waiter */
@@ -370,19 +371,20 @@ comclose(dev, flag, mode, p)
        int s;
 
        /* XXX This is for cons.c. */
-       if ((tp->t_state & TS_ISOPEN) == 0)
+       if (!ISSET(tp->t_state, TS_ISOPEN))
                return 0;
 
        (*linesw[tp->t_line].l_close)(tp, flag);
        s = spltty();
-       bic(iobase + com_cfcr, CFCR_SBREAK);
+       CLR(sc->sc_lcr, LCR_SBREAK);
+       outb(iobase + com_lcr, sc->sc_lcr);
        outb(iobase + com_ier, 0);
-       if (tp->t_cflag & HUPCL &&
-           (sc->sc_swflags & COM_SW_SOFTCAR) == 0) {
+       if (ISSET(tp->t_cflag, HUPCL) &&
+           !ISSET(sc->sc_swflags, COM_SW_SOFTCAR)) {
                /* XXX perhaps only clear DTR */
                outb(iobase + com_mcr, 0);
        }
-       tp->t_state &= ~(TS_BUSY | TS_FLUSH);
+       CLR(tp->t_state, TS_BUSY | TS_FLUSH);
        if (--comsopen == 0)
                untimeout(compoll, NULL);
        splx(s);
@@ -436,10 +438,10 @@ tiocm_xxx2mcr(data)
 {
        u_char m = 0;
 
-       if (data & TIOCM_DTR)
-               m |= MCR_DTR;
-       if (data & TIOCM_RTS)
-               m |= MCR_RTS;
+       if (ISSET(data, TIOCM_DTR))
+               SET(m, MCR_DTR);
+       if (ISSET(data, TIOCM_RTS))
+               SET(m, MCR_RTS);
        return m;
 }
 
@@ -466,63 +468,68 @@ comioctl(dev, cmd, data, flag, p)
 
        switch (cmd) {
        case TIOCSBRK:
-               bis(iobase + com_cfcr, CFCR_SBREAK);
+               SET(sc->sc_lcr, LCR_SBREAK);
+               outb(iobase + com_lcr, sc->sc_lcr);
                break;
        case TIOCCBRK:
-               bic(iobase + com_cfcr, CFCR_SBREAK);
+               CLR(sc->sc_lcr, LCR_SBREAK);
+               outb(iobase + com_lcr, sc->sc_lcr);
                break;
        case TIOCSDTR:
-               outb(iobase + com_mcr, sc->sc_mcr |= sc->sc_dtr);
+               SET(sc->sc_mcr, sc->sc_dtr);
+               outb(iobase + com_mcr, sc->sc_mcr);
                break;
        case TIOCCDTR:
-               outb(iobase + com_mcr, sc->sc_mcr &= ~sc->sc_dtr);
+               CLR(sc->sc_mcr, sc->sc_dtr);
+               outb(iobase + com_mcr, sc->sc_mcr);
                break;
        case TIOCMSET:
-               sc->sc_mcr &= ~(MCR_DTR | MCR_RTS);
+               CLR(sc->sc_mcr, MCR_DTR | MCR_RTS);
        case TIOCMBIS:
-               outb(iobase + com_mcr,
-                   sc->sc_mcr |= tiocm_xxx2mcr(*(int *)data));
+               SET(sc->sc_mcr, tiocm_xxx2mcr(*(int *)data));
+               outb(iobase + com_mcr, sc->sc_mcr);
                break;
        case TIOCMBIC:
-               outb(iobase + com_mcr,
-                   sc->sc_mcr &= ~tiocm_xxx2mcr(*(int *)data));
+               CLR(sc->sc_mcr, tiocm_xxx2mcr(*(int *)data));
+               outb(iobase + com_mcr, sc->sc_mcr);
                break;
        case TIOCMGET: {
                u_char m;
                int bits = 0;
 
                m = sc->sc_mcr;
-               if (m & MCR_DTR)
-                       bits |= TIOCM_DTR;
-               if (m & MCR_RTS)
-                       bits |= TIOCM_RTS;
+               if (ISSET(m, MCR_DTR))
+                       SET(bits, TIOCM_DTR);
+               if (ISSET(m, MCR_RTS))
+                       SET(bits, TIOCM_RTS);
                m = sc->sc_msr;
-               if (m & MSR_DCD)
-                       bits |= TIOCM_CD;
-               if (m & MSR_CTS)
-                       bits |= TIOCM_CTS;
-               if (m & MSR_DSR)
-                       bits |= TIOCM_DSR;
-               if (m & (MSR_RI | MSR_TERI))
-                       bits |= TIOCM_RI;
+               if (ISSET(m, MSR_DCD))
+                       SET(bits, TIOCM_CD);
+               if (ISSET(m, MSR_CTS))
+                       SET(bits, TIOCM_CTS);
+               if (ISSET(m, MSR_DSR))
+                       SET(bits, TIOCM_DSR);
+               if (ISSET(m, MSR_RI | MSR_TERI))
+                       SET(bits, TIOCM_RI);
                if (inb(iobase + com_ier))
-                       bits |= TIOCM_LE;
+                       SET(bits, TIOCM_LE);
                *(int *)data = bits;
                break;
        }
        case TIOCGFLAGS: {
-               int bits = 0;
-
-               if (sc->sc_swflags & COM_SW_SOFTCAR)
-                       bits |= TIOCFLAG_SOFTCAR;
-               if (sc->sc_swflags & COM_SW_CLOCAL)
-                       bits |= TIOCFLAG_CLOCAL;
-               if (sc->sc_swflags & COM_SW_CRTSCTS)
-                       bits |= TIOCFLAG_CRTSCTS;
-               if (sc->sc_swflags & COM_SW_MDMBUF)
-                       bits |= TIOCFLAG_MDMBUF;
-
-               *(int *)data = bits;
+               int driverbits, userbits = 0;
+
+               driverbits = sc->sc_swflags;
+               if (ISSET(driverbits, COM_SW_SOFTCAR))
+                       SET(userbits, TIOCFLAG_SOFTCAR);
+               if (ISSET(driverbits, COM_SW_CLOCAL))
+                       SET(userbits, TIOCFLAG_CLOCAL);
+               if (ISSET(driverbits, COM_SW_CRTSCTS))
+                       SET(userbits, TIOCFLAG_CRTSCTS);
+               if (ISSET(driverbits, COM_SW_MDMBUF))
+                       SET(userbits, TIOCFLAG_MDMBUF);
+
+               *(int *)data = userbits;
                break;
        }
        case TIOCSFLAGS: {
@@ -533,15 +540,15 @@ comioctl(dev, cmd, data, flag, p)
                        return(EPERM); 
 
                userbits = *(int *)data;
-               if ((userbits & TIOCFLAG_SOFTCAR) ||
-                   (sc->sc_hwflags & COM_HW_CONSOLE))
-                       driverbits |= COM_SW_SOFTCAR;
-               if (userbits & TIOCFLAG_CLOCAL)
-                       driverbits |= COM_SW_CLOCAL;
-               if (userbits & TIOCFLAG_CRTSCTS)
-                       driverbits |= COM_SW_CRTSCTS;
-               if (userbits & TIOCFLAG_MDMBUF)
-                       driverbits |= COM_SW_MDMBUF;
+               if (ISSET(userbits, TIOCFLAG_SOFTCAR) ||
+                   ISSET(sc->sc_hwflags, COM_HW_CONSOLE))
+                       SET(driverbits, COM_SW_SOFTCAR);
+               if (ISSET(userbits, TIOCFLAG_CLOCAL))
+                       SET(driverbits, COM_SW_CLOCAL);
+               if (ISSET(userbits, TIOCFLAG_CRTSCTS))
+                       SET(driverbits, COM_SW_CRTSCTS);
+               if (ISSET(userbits, TIOCFLAG_MDMBUF))
+                       SET(driverbits, COM_SW_MDMBUF);
 
                sc->sc_swflags = driverbits;
                break;
@@ -561,7 +568,7 @@ comparam(tp, t)
        struct com_softc *sc = comcd.cd_devs[COMUNIT(tp->t_dev)];
        int iobase = sc->sc_iobase;
        int ospeed = comspeed(t->c_ospeed);
-       u_char cfcr;
+       u_char lcr;
        tcflag_t oldcflag;
        int s;
 
@@ -569,61 +576,72 @@ comparam(tp, t)
        if (ospeed < 0 || (t->c_ispeed && t->c_ispeed != t->c_ospeed))
                return EINVAL;
 
-       switch (t->c_cflag & CSIZE) {
+       lcr = sc->sc_lcr & LCR_SBREAK;
+
+       switch (ISSET(t->c_cflag, CSIZE)) {
        case CS5:
-               cfcr = CFCR_5BITS;
+               SET(lcr, LCR_5BITS);
                break;
        case CS6:
-               cfcr = CFCR_6BITS;
+               SET(lcr, LCR_6BITS);
                break;
        case CS7:
-               cfcr = CFCR_7BITS;
+               SET(lcr, LCR_7BITS);
                break;
        case CS8:
-               cfcr = CFCR_8BITS;
+               SET(lcr, LCR_8BITS);
                break;
        }
-       if (t->c_cflag & PARENB) {
-               cfcr |= CFCR_PENAB;
-               if ((t->c_cflag & PARODD) == 0)
-                       cfcr |= CFCR_PEVEN;
+       if (ISSET(t->c_cflag, PARENB)) {
+               SET(lcr, LCR_PENAB);
+               if (!ISSET(t->c_cflag, PARODD))
+                       SET(lcr, LCR_PEVEN);
        }
-       if (t->c_cflag & CSTOPB)
-               cfcr |= CFCR_STOPB;
+       if (ISSET(t->c_cflag, CSTOPB))
+               SET(lcr, LCR_STOPB);
+
+       sc->sc_lcr = lcr;
 
        s = spltty();
 
-       if (ospeed == 0)
-               outb(iobase + com_mcr, sc->sc_mcr &= ~MCR_DTR);
+       if (ospeed == 0) {
+               CLR(sc->sc_mcr, MCR_DTR);
+               outb(iobase + com_mcr, sc->sc_mcr);
+       }
 
        /*
         * Set the FIFO threshold based on the receive speed, if we are
         * changing it.
         */
        if (tp->t_ispeed != t->c_ispeed) {
-               if (sc->sc_hwflags & COM_HW_FIFO)
+               if (ISSET(sc->sc_hwflags, COM_HW_FIFO))
                        outb(iobase + com_fifo,
                            FIFO_ENABLE |
                            (t->c_ispeed <= 1200 ? FIFO_TRIGGER_1 : FIFO_TRIGGER_8));
        }
 
        if (ospeed != 0) {
-               outb(iobase + com_cfcr, cfcr | CFCR_DLAB);
+               outb(iobase + com_lcr, lcr | LCR_DLAB);
                outb(iobase + com_dlbl, ospeed);
                outb(iobase + com_dlbh, ospeed >> 8);
-               outb(iobase + com_cfcr, cfcr);
-               outb(iobase + com_mcr, sc->sc_mcr |= MCR_DTR);
+               outb(iobase + com_lcr, lcr);
+               SET(sc->sc_mcr, MCR_DTR);
+               outb(iobase + com_mcr, sc->sc_mcr);
        } else
-               outb(iobase + com_cfcr, cfcr);
+               outb(iobase + com_lcr, lcr);
 
        /* When not using CRTSCTS, RTS follows DTR. */
-       if ((t->c_cflag & CRTSCTS) == 0) {
-               if (sc->sc_mcr & MCR_DTR) {
-                       if ((sc->sc_mcr & MCR_RTS) == 0)
-                               outb(iobase + com_mcr, sc->sc_mcr |= MCR_RTS);
+       if (!ISSET(t->c_cflag, CRTSCTS)) {
+               if (ISSET(sc->sc_mcr, MCR_DTR)) {
+                       if (!ISSET(sc->sc_mcr, MCR_RTS)) {
+                               SET(sc->sc_mcr, MCR_RTS);
+                               outb(iobase + com_mcr, sc->sc_mcr);
+                       }
                } else {
-                       if (sc->sc_mcr & MCR_RTS)
-                               outb(iobase + com_mcr, sc->sc_mcr &= ~MCR_RTS);
+                       if (ISSET(sc->sc_mcr, MCR_RTS)) {
+                               CLR(sc->sc_mcr, MCR_RTS);
+                               outb(iobase + com_mcr, sc->sc_mcr);
+                       }
                }
                sc->sc_dtr = MCR_DTR | MCR_RTS;
        } else
@@ -639,11 +657,12 @@ comparam(tp, t)
         * If DCD is off and MDMBUF is changed, ask the tty layer if we should
         * stop the device.
         */
-       if ((sc->sc_msr & MSR_DCD) == 0 &&
-           (sc->sc_swflags & COM_SW_SOFTCAR) == 0 &&
-           (oldcflag & MDMBUF) != (tp->t_cflag & MDMBUF) &&
+       if (!ISSET(sc->sc_msr, MSR_DCD) &&
+           !ISSET(sc->sc_swflags, COM_SW_SOFTCAR) &&
+           ISSET(oldcflag, MDMBUF) != ISSET(tp->t_cflag, MDMBUF) &&
            (*linesw[tp->t_line].l_modem)(tp, 0) == 0) {
-               outb(iobase + com_mcr, sc->sc_mcr &= ~sc->sc_dtr);
+               CLR(sc->sc_mcr, sc->sc_dtr);
+               outb(iobase + com_mcr, sc->sc_mcr);
        }
 
        splx(s);
@@ -659,22 +678,21 @@ comstart(tp)
        int s;
 
        s = spltty();
-       if (tp->t_state & (TS_TTSTOP | TS_BUSY))
+       if (ISSET(tp->t_state, TS_TTSTOP | TS_BUSY))
                goto out;
-       if ((tp->t_cflag & CRTSCTS) != 0 &&
-           (sc->sc_msr & MSR_CTS) == 0)
+       if (ISSET(tp->t_cflag, CRTSCTS) && !ISSET(sc->sc_msr, MSR_CTS))
                goto out;
        if (tp->t_outq.c_cc <= tp->t_lowat) {
-               if (tp->t_state & TS_ASLEEP) {
-                       tp->t_state &= ~TS_ASLEEP;
-                       wakeup((caddr_t)&tp->t_outq);
+               if (ISSET(tp->t_state, TS_ASLEEP)) {
+                       CLR(tp->t_state, TS_ASLEEP);
+                       wakeup(&tp->t_outq);
                }
                if (tp->t_outq.c_cc == 0)
                        goto out;
                selwakeup(&tp->t_wsel);
        }
-       tp->t_state |= TS_BUSY;
-       if (sc->sc_hwflags & COM_HW_FIFO) {
+       SET(tp->t_state, TS_BUSY);
+       if (ISSET(sc->sc_hwflags, COM_HW_FIFO)) {
                u_char buffer[16], *cp = buffer;
                int n = q_to_b(&tp->t_outq, cp, sizeof buffer);
                do {
@@ -696,9 +714,9 @@ comstop(tp, flag)
        int s;
 
        s = spltty();
-       if (tp->t_state & TS_BUSY)
-               if ((tp->t_state & TS_TTSTOP) == 0)
-                       tp->t_state |= TS_FLUSH;
+       if (ISSET(tp->t_state, TS_BUSY))
+               if (!ISSET(tp->t_state, TS_TTSTOP))
+                       SET(tp->t_state, TS_FLUSH);
        splx(s);
 }
 
@@ -772,14 +790,17 @@ compoll(arg)
                sc->sc_ibufhigh = sc->sc_ibuf + COM_IHIGHWATER;
                sc->sc_ibufend = sc->sc_ibuf + COM_IBUFSIZE;
 
-               if (tp == 0 || (tp->t_state & TS_ISOPEN) == 0) {
+               if (tp == 0 || !ISSET(tp->t_state, TS_ISOPEN)) {
                        splx(s);
                        continue;
                }
 
-               if ((tp->t_cflag & CRTSCTS) != 0 &&
-                   (sc->sc_mcr & MCR_RTS) == 0)
-                       outb(sc->sc_iobase + com_mcr, sc->sc_mcr |= MCR_RTS);
+               if (ISSET(tp->t_cflag, CRTSCTS) &&
+                   !ISSET(sc->sc_mcr, MCR_RTS)) {
+                       /* XXX */
+                       SET(sc->sc_mcr, MCR_RTS);
+                       outb(sc->sc_iobase + com_mcr, sc->sc_mcr);
+               }
 
                splx(s);
 
@@ -809,7 +830,7 @@ comintr(arg)
        struct tty *tp;
        u_char lsr, data, msr, delta;
 
-       if (inb(iobase + com_iir) & IIR_NOPEND)
+       if (ISSET(inb(iobase + com_iir), IIR_NOPEND))
                return (0);
 
        tp = sc->sc_tty;
@@ -817,12 +838,14 @@ comintr(arg)
        for (;;) {
                lsr = inb(iobase + com_lsr);
 
-               if (lsr & LSR_RCV_MASK) {
+               if (ISSET(lsr, LSR_RCV_MASK)) {
                        register u_char *p = sc->sc_ibufp;
 
                        comevents = 1;
                        do {
-                               if ((lsr & LSR_BI) != 0) {
+                               data = ISSET(lsr, LSR_RXRDY) ?
+                                   inb(iobase + com_data) : 0;
+                               if (ISSET(lsr, LSR_BI)) {
 #ifdef DDB
                                        if (sc->sc_dev.dv_unit == comconsole) {
                                                Debugger();
@@ -830,8 +853,7 @@ comintr(arg)
                                        }
 #endif
                                        data = '\0';
-                               } else
-                                       data = inb(iobase + com_data);
+                               }
                                if (p >= sc->sc_ibufend) {
                                        sc->sc_floods++;
                                        if (sc->sc_errors++ == 0)
@@ -840,43 +862,51 @@ comintr(arg)
                                        *p++ = data;
                                        *p++ = lsr;
                                        if (p == sc->sc_ibufhigh &&
-                                           (tp->t_cflag & CRTSCTS) != 0)
+                                           ISSET(tp->t_cflag, CRTSCTS)) {
+                                               /* XXX */
+                                               CLR(sc->sc_mcr, MCR_RTS);
                                                outb(iobase + com_mcr,
-                                                    sc->sc_mcr &= ~MCR_RTS);
+                                                    sc->sc_mcr);
+                                       }
                                }
                        next:
                                lsr = inb(iobase + com_lsr);
-                       } while (lsr & LSR_RCV_MASK);
+                       } while (ISSET(lsr, LSR_RCV_MASK));
 
                        sc->sc_ibufp = p;
                }
-
-               if (lsr & LSR_TXRDY && (tp->t_state & TS_BUSY) != 0) {
-                       tp->t_state &= ~TS_BUSY;
-                       if (tp->t_state & TS_FLUSH)
-                               tp->t_state &= ~TS_FLUSH;
-                       else
-                               (*linesw[tp->t_line].l_start)(tp);
-               }
+#if 0
+               else if (ISSET(lsr, LSR_BI|LSR_FE|LSR_PE|LSR_OE))
+                       printf("weird lsr %02x\n", lsr);
+#endif
 
                msr = inb(iobase + com_msr);
 
                if (msr != sc->sc_msr) {
                        delta = msr ^ sc->sc_msr;
                        sc->sc_msr = msr;
-                       if ((delta & MSR_DCD) != 0 &&
-                           (sc->sc_swflags & COM_SW_SOFTCAR) == 0 &&
-                           (*linesw[tp->t_line].l_modem)(tp, (msr & MSR_DCD) != 0) == 0) {
-                               outb(iobase + com_mcr, sc->sc_mcr &= ~sc->sc_dtr);
+                       if (ISSET(delta, MSR_DCD) &&
+                           !ISSET(sc->sc_swflags, COM_SW_SOFTCAR) &&
+                           (*linesw[tp->t_line].l_modem)(tp, ISSET(msr, MSR_DCD)) == 0) {
+                               CLR(sc->sc_mcr, sc->sc_dtr);
+                               outb(iobase + com_mcr, sc->sc_mcr);
                        }
-                       if ((delta & msr & MSR_CTS) != 0 &&
-                           (tp->t_cflag & CRTSCTS) != 0) {
+                       if (ISSET(delta & msr, MSR_CTS) &&
+                           ISSET(tp->t_cflag, CRTSCTS)) {
                                /* the line is up and we want to do rts/cts flow control */
                                (*linesw[tp->t_line].l_start)(tp);
                        }
                }
 
-               if (inb(iobase + com_iir) & IIR_NOPEND)
+               if (ISSET(lsr, LSR_TXRDY) && ISSET(tp->t_state, TS_BUSY)) {
+                       CLR(tp->t_state, TS_BUSY);
+                       if (ISSET(tp->t_state, TS_FLUSH))
+                               CLR(tp->t_state, TS_FLUSH);
+                       else
+                               (*linesw[tp->t_line].l_start)(tp);
+               }
+
+               if (ISSET(inb(iobase + com_iir), IIR_NOPEND))
                        return (1);
        }
 }
@@ -927,11 +957,11 @@ cominit(unit, rate)
        int iobase = CONADDR;
        u_char stat;
 
-       outb(iobase + com_cfcr, CFCR_DLAB);
+       outb(iobase + com_lcr, LCR_DLAB);
        rate = comspeed(comdefaultrate);
        outb(iobase + com_dlbl, rate);
        outb(iobase + com_dlbh, rate >> 8);
-       outb(iobase + com_cfcr, CFCR_8BITS);
+       outb(iobase + com_lcr, LCR_8BITS);
        outb(iobase + com_ier, IER_ERXRDY | IER_ETXRDY);
        outb(iobase + com_fifo, FIFO_ENABLE | FIFO_RCV_RST | FIFO_XMT_RST | FIFO_TRIGGER_4);
        stat = inb(iobase + com_iir);
@@ -945,7 +975,7 @@ comcngetc(dev)
        int iobase = CONADDR;
        u_char stat, c;
 
-       while (((stat = inb(iobase + com_lsr)) & LSR_RXRDY) == 0)
+       while (!ISSET(stat = inb(iobase + com_lsr), LSR_RXRDY))
                ;
        c = inb(iobase + com_data);
        stat = inb(iobase + com_iir);
@@ -975,12 +1005,12 @@ comcnputc(dev, c)
        }
        /* wait for any pending transmission to finish */
        timo = 50000;
-       while (((stat = inb(iobase + com_lsr)) & LSR_TXRDY) == 0 && --timo)
+       while (!ISSET(stat = inb(iobase + com_lsr), LSR_TXRDY) && --timo)
                ;
        outb(iobase + com_data, c);
        /* wait for this transmission to complete */
        timo = 1500000;
-       while (((stat = inb(iobase + com_lsr)) & LSR_TXRDY) == 0 && --timo)
+       while (!ISSET(stat = inb(iobase + com_lsr), LSR_TXRDY) && --timo)
                ;
        /* clear any interrupts generated by this transmission */
        stat = inb(iobase + com_iir);
index 4a4f0e9..da3fe9b 100644 (file)
@@ -1,4 +1,4 @@
-/*     $NetBSD: comreg.h,v 1.6 1995/06/28 04:31:30 cgd Exp $   */
+/*     $NetBSD: comreg.h,v 1.7 1995/10/15 19:43:07 mycroft Exp $       */
 
 /*-
  * Copyright (c) 1991 The Regents of the University of California.
 #define        FIFO_TRIGGER_8  0x80
 #define        FIFO_TRIGGER_14 0xc0
 
-/* character format control register */
-#define        CFCR_DLAB       0x80
-#define        CFCR_SBREAK     0x40
-#define        CFCR_PZERO      0x30
-#define        CFCR_PONE       0x20
-#define        CFCR_PEVEN      0x10
-#define        CFCR_PODD       0x00
-#define        CFCR_PENAB      0x08
-#define        CFCR_STOPB      0x04
-#define        CFCR_8BITS      0x03
-#define        CFCR_7BITS      0x02
-#define        CFCR_6BITS      0x01
-#define        CFCR_5BITS      0x00
+/* line control register */
+#define        LCR_DLAB        0x80
+#define        LCR_SBREAK      0x40
+#define        LCR_PZERO       0x30
+#define        LCR_PONE        0x20
+#define        LCR_PEVEN       0x10
+#define        LCR_PODD        0x00
+#define        LCR_PENAB       0x08
+#define        LCR_STOPB       0x04
+#define        LCR_8BITS       0x03
+#define        LCR_7BITS       0x02
+#define        LCR_6BITS       0x01
+#define        LCR_5BITS       0x00
 
 /* modem control register */
 #define        MCR_LOOPBACK    0x10