From c7003d37d3a4a933df784fd2c50158559986ffe8 Mon Sep 17 00:00:00 2001 From: mycroft Date: Fri, 16 Sep 1994 02:50:39 +0000 Subject: [PATCH] Only reset FIFO if changing baud rate. From John Kohl (slightly edited). --- sys/arch/i386/isa/com.c | 33 ++++++++++++++++++++++++--------- sys/dev/ic/com.c | 33 ++++++++++++++++++++++++--------- sys/dev/isa/com.c | 33 ++++++++++++++++++++++++--------- 3 files changed, 72 insertions(+), 27 deletions(-) diff --git a/sys/arch/i386/isa/com.c b/sys/arch/i386/isa/com.c index 2af047ebd15c..63756e363e80 100644 --- a/sys/arch/i386/isa/com.c +++ b/sys/arch/i386/isa/com.c @@ -32,7 +32,7 @@ * SUCH DAMAGE. * * from: @(#)com.c 7.5 (Berkeley) 5/16/91 - * $Id: com.c,v 1.35 1994/08/24 07:25:18 mycroft Exp $ + * $Id: com.c,v 1.36 1994/09/16 02:50:39 mycroft Exp $ */ /* @@ -296,6 +296,11 @@ comopen(dev, flag, mode, p) ttsetwater(tp); iobase = sc->sc_iobase; + /* Set the FIFO threshold based on the receive speed. */ + if (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 */ (void) inb(iobase + com_lsr); (void) inb(iobase + com_data); @@ -555,22 +560,32 @@ comparam(tp, t) s = spltty(); - /* Set the FIFO threshold based on the receive speed. */ - if (sc->sc_hwflags & COM_HW_FIFO) - outb(iobase + com_fifo, - FIFO_ENABLE | FIFO_RCV_RST | FIFO_XMT_RST | - (t->c_ispeed <= 1200 ? FIFO_TRIGGER_1 : FIFO_TRIGGER_8)); - if (ospeed == 0) outb(iobase + com_mcr, sc->sc_mcr &= ~MCR_DTR); - else - outb(iobase + com_mcr, sc->sc_mcr |= MCR_DTR); + + /* + * Set the FIFO threshold based on the receive speed, if we are + * changing it. + * + * XXX + * It would be better if we waited for the FIFO to empty, so we don't + * lose any in-transit characters. + */ + if (tp->t_ispeed != t->c_ispeed) { + if (sc->sc_hwflags & COM_HW_FIFO) + outb(iobase + com_fifo, + FIFO_ENABLE | FIFO_RCV_RST | FIFO_XMT_RST | + (t->c_ispeed <= 1200 ? FIFO_TRIGGER_1 : FIFO_TRIGGER_8)); + } outb(iobase + com_cfcr, cfcr | CFCR_DLAB); outb(iobase + com_dlbl, ospeed); outb(iobase + com_dlbh, ospeed>>8); outb(iobase + com_cfcr, cfcr); + if (ospeed != 0) + outb(iobase + com_mcr, sc->sc_mcr |= MCR_DTR); + /* When not using CRTSCTS, RTS follows DTR. */ if ((t->c_cflag & CRTSCTS) == 0) { if (sc->sc_mcr & MCR_DTR) { diff --git a/sys/dev/ic/com.c b/sys/dev/ic/com.c index 2af047ebd15c..63756e363e80 100644 --- a/sys/dev/ic/com.c +++ b/sys/dev/ic/com.c @@ -32,7 +32,7 @@ * SUCH DAMAGE. * * from: @(#)com.c 7.5 (Berkeley) 5/16/91 - * $Id: com.c,v 1.35 1994/08/24 07:25:18 mycroft Exp $ + * $Id: com.c,v 1.36 1994/09/16 02:50:39 mycroft Exp $ */ /* @@ -296,6 +296,11 @@ comopen(dev, flag, mode, p) ttsetwater(tp); iobase = sc->sc_iobase; + /* Set the FIFO threshold based on the receive speed. */ + if (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 */ (void) inb(iobase + com_lsr); (void) inb(iobase + com_data); @@ -555,22 +560,32 @@ comparam(tp, t) s = spltty(); - /* Set the FIFO threshold based on the receive speed. */ - if (sc->sc_hwflags & COM_HW_FIFO) - outb(iobase + com_fifo, - FIFO_ENABLE | FIFO_RCV_RST | FIFO_XMT_RST | - (t->c_ispeed <= 1200 ? FIFO_TRIGGER_1 : FIFO_TRIGGER_8)); - if (ospeed == 0) outb(iobase + com_mcr, sc->sc_mcr &= ~MCR_DTR); - else - outb(iobase + com_mcr, sc->sc_mcr |= MCR_DTR); + + /* + * Set the FIFO threshold based on the receive speed, if we are + * changing it. + * + * XXX + * It would be better if we waited for the FIFO to empty, so we don't + * lose any in-transit characters. + */ + if (tp->t_ispeed != t->c_ispeed) { + if (sc->sc_hwflags & COM_HW_FIFO) + outb(iobase + com_fifo, + FIFO_ENABLE | FIFO_RCV_RST | FIFO_XMT_RST | + (t->c_ispeed <= 1200 ? FIFO_TRIGGER_1 : FIFO_TRIGGER_8)); + } outb(iobase + com_cfcr, cfcr | CFCR_DLAB); outb(iobase + com_dlbl, ospeed); outb(iobase + com_dlbh, ospeed>>8); outb(iobase + com_cfcr, cfcr); + if (ospeed != 0) + outb(iobase + com_mcr, sc->sc_mcr |= MCR_DTR); + /* When not using CRTSCTS, RTS follows DTR. */ if ((t->c_cflag & CRTSCTS) == 0) { if (sc->sc_mcr & MCR_DTR) { diff --git a/sys/dev/isa/com.c b/sys/dev/isa/com.c index 2af047ebd15c..63756e363e80 100644 --- a/sys/dev/isa/com.c +++ b/sys/dev/isa/com.c @@ -32,7 +32,7 @@ * SUCH DAMAGE. * * from: @(#)com.c 7.5 (Berkeley) 5/16/91 - * $Id: com.c,v 1.35 1994/08/24 07:25:18 mycroft Exp $ + * $Id: com.c,v 1.36 1994/09/16 02:50:39 mycroft Exp $ */ /* @@ -296,6 +296,11 @@ comopen(dev, flag, mode, p) ttsetwater(tp); iobase = sc->sc_iobase; + /* Set the FIFO threshold based on the receive speed. */ + if (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 */ (void) inb(iobase + com_lsr); (void) inb(iobase + com_data); @@ -555,22 +560,32 @@ comparam(tp, t) s = spltty(); - /* Set the FIFO threshold based on the receive speed. */ - if (sc->sc_hwflags & COM_HW_FIFO) - outb(iobase + com_fifo, - FIFO_ENABLE | FIFO_RCV_RST | FIFO_XMT_RST | - (t->c_ispeed <= 1200 ? FIFO_TRIGGER_1 : FIFO_TRIGGER_8)); - if (ospeed == 0) outb(iobase + com_mcr, sc->sc_mcr &= ~MCR_DTR); - else - outb(iobase + com_mcr, sc->sc_mcr |= MCR_DTR); + + /* + * Set the FIFO threshold based on the receive speed, if we are + * changing it. + * + * XXX + * It would be better if we waited for the FIFO to empty, so we don't + * lose any in-transit characters. + */ + if (tp->t_ispeed != t->c_ispeed) { + if (sc->sc_hwflags & COM_HW_FIFO) + outb(iobase + com_fifo, + FIFO_ENABLE | FIFO_RCV_RST | FIFO_XMT_RST | + (t->c_ispeed <= 1200 ? FIFO_TRIGGER_1 : FIFO_TRIGGER_8)); + } outb(iobase + com_cfcr, cfcr | CFCR_DLAB); outb(iobase + com_dlbl, ospeed); outb(iobase + com_dlbh, ospeed>>8); outb(iobase + com_cfcr, cfcr); + if (ospeed != 0) + outb(iobase + com_mcr, sc->sc_mcr |= MCR_DTR); + /* When not using CRTSCTS, RTS follows DTR. */ if ((t->c_cflag & CRTSCTS) == 0) { if (sc->sc_mcr & MCR_DTR) {