summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>1996-11-13 18:31:57 +0000
committerbde <bde@FreeBSD.org>1996-11-13 18:31:57 +0000
commit9f1b68b59760da580a30207937de555fe35c107b (patch)
treea78d3dc6b9a66741e6c7c5479ddebb9fb0fecb74 /sys
parent6bc86ef427c4f4e9594a1362d2edd1f9c431f1bb (diff)
downloadFreeBSD-src-9f1b68b59760da580a30207937de555fe35c107b.zip
FreeBSD-src-9f1b68b59760da580a30207937de555fe35c107b.tar.gz
Don't fiddle with RTS if RTS flow control is off. This gives applications
almost complete control over RTS (control of its initial value is still missing). This fixes PR 1644 for sio. The author of PR 1644 wants it in 2.1.6 and 2.2. This may be safe since the complications are only in rarely used cases that I hope I've covered.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/cy/cy.c45
-rw-r--r--sys/dev/cy/cy_isa.c45
-rw-r--r--sys/dev/sio/sio.c40
-rw-r--r--sys/i386/isa/cy.c45
-rw-r--r--sys/i386/isa/sio.c40
-rw-r--r--sys/isa/sio.c40
6 files changed, 153 insertions, 102 deletions
diff --git a/sys/dev/cy/cy.c b/sys/dev/cy/cy.c
index 0c84e33..5a4805b 100644
--- a/sys/dev/cy/cy.c
+++ b/sys/dev/cy/cy.c
@@ -27,7 +27,7 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $Id: cy.c,v 1.40 1996/10/14 16:10:00 davidg Exp $
+ * $Id: cy.c,v 1.41 1996/10/14 16:43:11 davidg Exp $
*/
#include "cy.h"
@@ -1460,6 +1460,10 @@ sioioctl(dev, cmd, data, flag, p)
case TIOCCDTR:
(void)commctl(com, TIOCM_DTR, DMBIC);
break;
+ /*
+ * XXX should disallow changing MCR_RTS if CS_RTS_IFLOW is set. The
+ * changes get undone on the next call to comparam().
+ */
case TIOCMSET:
(void)commctl(com, *(int *)data, DMSET);
break;
@@ -1567,13 +1571,6 @@ repeat:
* of input, so enable RTS if it is now disabled and
* there is room in the high-level buffer.
*/
- /*
- * XXX this used not to look at CS_RTS_IFLOW. The
- * change is to allow full control of MCR_RTS via
- * ioctls after turning CS_RTS_IFLOW off. Check
- * for races. We shouldn't allow the ioctls while
- * CS_RTS_IFLOW is on.
- */
if ((com->state & CS_RTS_IFLOW)
&& !(com->mcr_image & MCR_RTS)
&& !(tp->t_state & TS_TBLOCK))
@@ -1952,10 +1949,27 @@ comparam(tp, t)
com->state &= ~CS_TTGO;
if (!(tp->t_state & TS_TTSTOP))
com->state |= CS_TTGO;
- if (cflag & CRTS_IFLOW)
- com->state |= CS_RTS_IFLOW; /* XXX - secondary changes? */
- else
+ if (cflag & CRTS_IFLOW) {
+ com->state |= CS_RTS_IFLOW;
+ /*
+ * If CS_RTS_IFLOW just changed from off to on, the change
+ * needs to be propagated to MCR_RTS. This isn't urgent,
+ * so do it later by calling comstart() instead of repeating
+ * a lot of code from comstart() here.
+ */
+ } else if (com->state & CS_RTS_IFLOW) {
com->state &= ~CS_RTS_IFLOW;
+ /*
+ * CS_RTS_IFLOW just changed from on to off. Force MCR_RTS
+ * on here, since comstart() won't do it later.
+ */
+#if 0
+ outb(com->modem_ctl_port, com->mcr_image |= MCR_RTS);
+#else
+ cd_outb(iobase, CD1400_MSVR1, com->cy_align,
+ com->mcr_image |= MCR_RTS);
+#endif
+ }
/*
* Set up state to handle output flow control.
@@ -1994,6 +2008,7 @@ comparam(tp, t)
enable_intr();
splx(s);
+ comstart(tp);
return (0);
}
@@ -2042,12 +2057,8 @@ comstart(tp)
com->mcr_image &= ~MCR_RTS);
#endif
} else {
- /*
- * XXX don't raise MCR_RTS if CTS_RTS_IFLOW is off. Set it
- * appropriately in comparam() if RTS-flow is being changed.
- * Check for races.
- */
- if (!(com->mcr_image & MCR_RTS) && com->iptr < com->ihighwater)
+ if (!(com->mcr_image & MCR_RTS) && com->iptr < com->ihighwater
+ && com->state & CS_RTS_IFLOW)
#if 0
outb(com->modem_ctl_port, com->mcr_image |= MCR_RTS);
#else
diff --git a/sys/dev/cy/cy_isa.c b/sys/dev/cy/cy_isa.c
index 0c84e33..5a4805b 100644
--- a/sys/dev/cy/cy_isa.c
+++ b/sys/dev/cy/cy_isa.c
@@ -27,7 +27,7 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $Id: cy.c,v 1.40 1996/10/14 16:10:00 davidg Exp $
+ * $Id: cy.c,v 1.41 1996/10/14 16:43:11 davidg Exp $
*/
#include "cy.h"
@@ -1460,6 +1460,10 @@ sioioctl(dev, cmd, data, flag, p)
case TIOCCDTR:
(void)commctl(com, TIOCM_DTR, DMBIC);
break;
+ /*
+ * XXX should disallow changing MCR_RTS if CS_RTS_IFLOW is set. The
+ * changes get undone on the next call to comparam().
+ */
case TIOCMSET:
(void)commctl(com, *(int *)data, DMSET);
break;
@@ -1567,13 +1571,6 @@ repeat:
* of input, so enable RTS if it is now disabled and
* there is room in the high-level buffer.
*/
- /*
- * XXX this used not to look at CS_RTS_IFLOW. The
- * change is to allow full control of MCR_RTS via
- * ioctls after turning CS_RTS_IFLOW off. Check
- * for races. We shouldn't allow the ioctls while
- * CS_RTS_IFLOW is on.
- */
if ((com->state & CS_RTS_IFLOW)
&& !(com->mcr_image & MCR_RTS)
&& !(tp->t_state & TS_TBLOCK))
@@ -1952,10 +1949,27 @@ comparam(tp, t)
com->state &= ~CS_TTGO;
if (!(tp->t_state & TS_TTSTOP))
com->state |= CS_TTGO;
- if (cflag & CRTS_IFLOW)
- com->state |= CS_RTS_IFLOW; /* XXX - secondary changes? */
- else
+ if (cflag & CRTS_IFLOW) {
+ com->state |= CS_RTS_IFLOW;
+ /*
+ * If CS_RTS_IFLOW just changed from off to on, the change
+ * needs to be propagated to MCR_RTS. This isn't urgent,
+ * so do it later by calling comstart() instead of repeating
+ * a lot of code from comstart() here.
+ */
+ } else if (com->state & CS_RTS_IFLOW) {
com->state &= ~CS_RTS_IFLOW;
+ /*
+ * CS_RTS_IFLOW just changed from on to off. Force MCR_RTS
+ * on here, since comstart() won't do it later.
+ */
+#if 0
+ outb(com->modem_ctl_port, com->mcr_image |= MCR_RTS);
+#else
+ cd_outb(iobase, CD1400_MSVR1, com->cy_align,
+ com->mcr_image |= MCR_RTS);
+#endif
+ }
/*
* Set up state to handle output flow control.
@@ -1994,6 +2008,7 @@ comparam(tp, t)
enable_intr();
splx(s);
+ comstart(tp);
return (0);
}
@@ -2042,12 +2057,8 @@ comstart(tp)
com->mcr_image &= ~MCR_RTS);
#endif
} else {
- /*
- * XXX don't raise MCR_RTS if CTS_RTS_IFLOW is off. Set it
- * appropriately in comparam() if RTS-flow is being changed.
- * Check for races.
- */
- if (!(com->mcr_image & MCR_RTS) && com->iptr < com->ihighwater)
+ if (!(com->mcr_image & MCR_RTS) && com->iptr < com->ihighwater
+ && com->state & CS_RTS_IFLOW)
#if 0
outb(com->modem_ctl_port, com->mcr_image |= MCR_RTS);
#else
diff --git a/sys/dev/sio/sio.c b/sys/dev/sio/sio.c
index 2a73b2f..697deb8 100644
--- a/sys/dev/sio/sio.c
+++ b/sys/dev/sio/sio.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* from: @(#)com.c 7.5 (Berkeley) 5/16/91
- * $Id: sio.c,v 1.147 1996/09/30 12:22:27 bde Exp $
+ * $Id: sio.c,v 1.148 1996/11/02 02:26:01 pst Exp $
*/
#include "opt_comconsole.h"
@@ -1619,6 +1619,10 @@ sioioctl(dev, cmd, data, flag, p)
case TIOCCDTR:
(void)commctl(com, TIOCM_DTR, DMBIC);
break;
+ /*
+ * XXX should disallow changing MCR_RTS if CS_RTS_IFLOW is set. The
+ * changes get undone on the next call to comparam().
+ */
case TIOCMSET:
(void)commctl(com, *(int *)data, DMSET);
break;
@@ -1724,13 +1728,6 @@ repeat:
* of input, so enable RTS if it is now disabled and
* there is room in the high-level buffer.
*/
- /*
- * XXX this used not to look at CS_RTS_IFLOW. The
- * change is to allow full control of MCR_RTS via
- * ioctls after turning CS_RTS_IFLOW off. Check
- * for races. We shouldn't allow the ioctls while
- * CS_RTS_IFLOW is on.
- */
if ((com->state & CS_RTS_IFLOW)
&& !(com->mcr_image & MCR_RTS)
&& !(tp->t_state & TS_TBLOCK))
@@ -1957,10 +1954,22 @@ retry:
outb(iobase + com_cfcr, com->cfcr_image = cfcr);
if (!(tp->t_state & TS_TTSTOP))
com->state |= CS_TTGO;
- if (cflag & CRTS_IFLOW)
- com->state |= CS_RTS_IFLOW; /* XXX - secondary changes? */
- else
+ if (cflag & CRTS_IFLOW) {
+ com->state |= CS_RTS_IFLOW;
+ /*
+ * If CS_RTS_IFLOW just changed from off to on, the change
+ * needs to be propagated to MCR_RTS. This isn't urgent,
+ * so do it later by calling comstart() instead of repeating
+ * a lot of code from comstart() here.
+ */
+ } else if (com->state & CS_RTS_IFLOW) {
com->state &= ~CS_RTS_IFLOW;
+ /*
+ * CS_RTS_IFLOW just changed from on to off. Force MCR_RTS
+ * on here, since comstart() won't do it later.
+ */
+ outb(com->modem_ctl_port, com->mcr_image |= MCR_RTS);
+ }
/*
* Set up state to handle output flow control.
@@ -1986,6 +1995,7 @@ retry:
enable_intr();
splx(s);
+ comstart(tp);
return (0);
}
@@ -2009,12 +2019,8 @@ comstart(tp)
if (com->mcr_image & MCR_RTS && com->state & CS_RTS_IFLOW)
outb(com->modem_ctl_port, com->mcr_image &= ~MCR_RTS);
} else {
- /*
- * XXX don't raise MCR_RTS if CTS_RTS_IFLOW is off. Set it
- * appropriately in comparam() if RTS-flow is being changed.
- * Check for races.
- */
- if (!(com->mcr_image & MCR_RTS) && com->iptr < com->ihighwater)
+ if (!(com->mcr_image & MCR_RTS) && com->iptr < com->ihighwater
+ && com->state & CS_RTS_IFLOW)
outb(com->modem_ctl_port, com->mcr_image |= MCR_RTS);
}
enable_intr();
diff --git a/sys/i386/isa/cy.c b/sys/i386/isa/cy.c
index 0c84e33..5a4805b 100644
--- a/sys/i386/isa/cy.c
+++ b/sys/i386/isa/cy.c
@@ -27,7 +27,7 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $Id: cy.c,v 1.40 1996/10/14 16:10:00 davidg Exp $
+ * $Id: cy.c,v 1.41 1996/10/14 16:43:11 davidg Exp $
*/
#include "cy.h"
@@ -1460,6 +1460,10 @@ sioioctl(dev, cmd, data, flag, p)
case TIOCCDTR:
(void)commctl(com, TIOCM_DTR, DMBIC);
break;
+ /*
+ * XXX should disallow changing MCR_RTS if CS_RTS_IFLOW is set. The
+ * changes get undone on the next call to comparam().
+ */
case TIOCMSET:
(void)commctl(com, *(int *)data, DMSET);
break;
@@ -1567,13 +1571,6 @@ repeat:
* of input, so enable RTS if it is now disabled and
* there is room in the high-level buffer.
*/
- /*
- * XXX this used not to look at CS_RTS_IFLOW. The
- * change is to allow full control of MCR_RTS via
- * ioctls after turning CS_RTS_IFLOW off. Check
- * for races. We shouldn't allow the ioctls while
- * CS_RTS_IFLOW is on.
- */
if ((com->state & CS_RTS_IFLOW)
&& !(com->mcr_image & MCR_RTS)
&& !(tp->t_state & TS_TBLOCK))
@@ -1952,10 +1949,27 @@ comparam(tp, t)
com->state &= ~CS_TTGO;
if (!(tp->t_state & TS_TTSTOP))
com->state |= CS_TTGO;
- if (cflag & CRTS_IFLOW)
- com->state |= CS_RTS_IFLOW; /* XXX - secondary changes? */
- else
+ if (cflag & CRTS_IFLOW) {
+ com->state |= CS_RTS_IFLOW;
+ /*
+ * If CS_RTS_IFLOW just changed from off to on, the change
+ * needs to be propagated to MCR_RTS. This isn't urgent,
+ * so do it later by calling comstart() instead of repeating
+ * a lot of code from comstart() here.
+ */
+ } else if (com->state & CS_RTS_IFLOW) {
com->state &= ~CS_RTS_IFLOW;
+ /*
+ * CS_RTS_IFLOW just changed from on to off. Force MCR_RTS
+ * on here, since comstart() won't do it later.
+ */
+#if 0
+ outb(com->modem_ctl_port, com->mcr_image |= MCR_RTS);
+#else
+ cd_outb(iobase, CD1400_MSVR1, com->cy_align,
+ com->mcr_image |= MCR_RTS);
+#endif
+ }
/*
* Set up state to handle output flow control.
@@ -1994,6 +2008,7 @@ comparam(tp, t)
enable_intr();
splx(s);
+ comstart(tp);
return (0);
}
@@ -2042,12 +2057,8 @@ comstart(tp)
com->mcr_image &= ~MCR_RTS);
#endif
} else {
- /*
- * XXX don't raise MCR_RTS if CTS_RTS_IFLOW is off. Set it
- * appropriately in comparam() if RTS-flow is being changed.
- * Check for races.
- */
- if (!(com->mcr_image & MCR_RTS) && com->iptr < com->ihighwater)
+ if (!(com->mcr_image & MCR_RTS) && com->iptr < com->ihighwater
+ && com->state & CS_RTS_IFLOW)
#if 0
outb(com->modem_ctl_port, com->mcr_image |= MCR_RTS);
#else
diff --git a/sys/i386/isa/sio.c b/sys/i386/isa/sio.c
index 2a73b2f..697deb8 100644
--- a/sys/i386/isa/sio.c
+++ b/sys/i386/isa/sio.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* from: @(#)com.c 7.5 (Berkeley) 5/16/91
- * $Id: sio.c,v 1.147 1996/09/30 12:22:27 bde Exp $
+ * $Id: sio.c,v 1.148 1996/11/02 02:26:01 pst Exp $
*/
#include "opt_comconsole.h"
@@ -1619,6 +1619,10 @@ sioioctl(dev, cmd, data, flag, p)
case TIOCCDTR:
(void)commctl(com, TIOCM_DTR, DMBIC);
break;
+ /*
+ * XXX should disallow changing MCR_RTS if CS_RTS_IFLOW is set. The
+ * changes get undone on the next call to comparam().
+ */
case TIOCMSET:
(void)commctl(com, *(int *)data, DMSET);
break;
@@ -1724,13 +1728,6 @@ repeat:
* of input, so enable RTS if it is now disabled and
* there is room in the high-level buffer.
*/
- /*
- * XXX this used not to look at CS_RTS_IFLOW. The
- * change is to allow full control of MCR_RTS via
- * ioctls after turning CS_RTS_IFLOW off. Check
- * for races. We shouldn't allow the ioctls while
- * CS_RTS_IFLOW is on.
- */
if ((com->state & CS_RTS_IFLOW)
&& !(com->mcr_image & MCR_RTS)
&& !(tp->t_state & TS_TBLOCK))
@@ -1957,10 +1954,22 @@ retry:
outb(iobase + com_cfcr, com->cfcr_image = cfcr);
if (!(tp->t_state & TS_TTSTOP))
com->state |= CS_TTGO;
- if (cflag & CRTS_IFLOW)
- com->state |= CS_RTS_IFLOW; /* XXX - secondary changes? */
- else
+ if (cflag & CRTS_IFLOW) {
+ com->state |= CS_RTS_IFLOW;
+ /*
+ * If CS_RTS_IFLOW just changed from off to on, the change
+ * needs to be propagated to MCR_RTS. This isn't urgent,
+ * so do it later by calling comstart() instead of repeating
+ * a lot of code from comstart() here.
+ */
+ } else if (com->state & CS_RTS_IFLOW) {
com->state &= ~CS_RTS_IFLOW;
+ /*
+ * CS_RTS_IFLOW just changed from on to off. Force MCR_RTS
+ * on here, since comstart() won't do it later.
+ */
+ outb(com->modem_ctl_port, com->mcr_image |= MCR_RTS);
+ }
/*
* Set up state to handle output flow control.
@@ -1986,6 +1995,7 @@ retry:
enable_intr();
splx(s);
+ comstart(tp);
return (0);
}
@@ -2009,12 +2019,8 @@ comstart(tp)
if (com->mcr_image & MCR_RTS && com->state & CS_RTS_IFLOW)
outb(com->modem_ctl_port, com->mcr_image &= ~MCR_RTS);
} else {
- /*
- * XXX don't raise MCR_RTS if CTS_RTS_IFLOW is off. Set it
- * appropriately in comparam() if RTS-flow is being changed.
- * Check for races.
- */
- if (!(com->mcr_image & MCR_RTS) && com->iptr < com->ihighwater)
+ if (!(com->mcr_image & MCR_RTS) && com->iptr < com->ihighwater
+ && com->state & CS_RTS_IFLOW)
outb(com->modem_ctl_port, com->mcr_image |= MCR_RTS);
}
enable_intr();
diff --git a/sys/isa/sio.c b/sys/isa/sio.c
index 2a73b2f..697deb8 100644
--- a/sys/isa/sio.c
+++ b/sys/isa/sio.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* from: @(#)com.c 7.5 (Berkeley) 5/16/91
- * $Id: sio.c,v 1.147 1996/09/30 12:22:27 bde Exp $
+ * $Id: sio.c,v 1.148 1996/11/02 02:26:01 pst Exp $
*/
#include "opt_comconsole.h"
@@ -1619,6 +1619,10 @@ sioioctl(dev, cmd, data, flag, p)
case TIOCCDTR:
(void)commctl(com, TIOCM_DTR, DMBIC);
break;
+ /*
+ * XXX should disallow changing MCR_RTS if CS_RTS_IFLOW is set. The
+ * changes get undone on the next call to comparam().
+ */
case TIOCMSET:
(void)commctl(com, *(int *)data, DMSET);
break;
@@ -1724,13 +1728,6 @@ repeat:
* of input, so enable RTS if it is now disabled and
* there is room in the high-level buffer.
*/
- /*
- * XXX this used not to look at CS_RTS_IFLOW. The
- * change is to allow full control of MCR_RTS via
- * ioctls after turning CS_RTS_IFLOW off. Check
- * for races. We shouldn't allow the ioctls while
- * CS_RTS_IFLOW is on.
- */
if ((com->state & CS_RTS_IFLOW)
&& !(com->mcr_image & MCR_RTS)
&& !(tp->t_state & TS_TBLOCK))
@@ -1957,10 +1954,22 @@ retry:
outb(iobase + com_cfcr, com->cfcr_image = cfcr);
if (!(tp->t_state & TS_TTSTOP))
com->state |= CS_TTGO;
- if (cflag & CRTS_IFLOW)
- com->state |= CS_RTS_IFLOW; /* XXX - secondary changes? */
- else
+ if (cflag & CRTS_IFLOW) {
+ com->state |= CS_RTS_IFLOW;
+ /*
+ * If CS_RTS_IFLOW just changed from off to on, the change
+ * needs to be propagated to MCR_RTS. This isn't urgent,
+ * so do it later by calling comstart() instead of repeating
+ * a lot of code from comstart() here.
+ */
+ } else if (com->state & CS_RTS_IFLOW) {
com->state &= ~CS_RTS_IFLOW;
+ /*
+ * CS_RTS_IFLOW just changed from on to off. Force MCR_RTS
+ * on here, since comstart() won't do it later.
+ */
+ outb(com->modem_ctl_port, com->mcr_image |= MCR_RTS);
+ }
/*
* Set up state to handle output flow control.
@@ -1986,6 +1995,7 @@ retry:
enable_intr();
splx(s);
+ comstart(tp);
return (0);
}
@@ -2009,12 +2019,8 @@ comstart(tp)
if (com->mcr_image & MCR_RTS && com->state & CS_RTS_IFLOW)
outb(com->modem_ctl_port, com->mcr_image &= ~MCR_RTS);
} else {
- /*
- * XXX don't raise MCR_RTS if CTS_RTS_IFLOW is off. Set it
- * appropriately in comparam() if RTS-flow is being changed.
- * Check for races.
- */
- if (!(com->mcr_image & MCR_RTS) && com->iptr < com->ihighwater)
+ if (!(com->mcr_image & MCR_RTS) && com->iptr < com->ihighwater
+ && com->state & CS_RTS_IFLOW)
outb(com->modem_ctl_port, com->mcr_image |= MCR_RTS);
}
enable_intr();
OpenPOWER on IntegriCloud