Enabled dynamically sized tty input buffers (with enough buffering

for 1 second's worth of input) and larger tty output buffers.  The
interrupt-level buffers are still too small for speeds above 115200
bps (only a little too small for 230400 bps if RTS flow control is
enabled).

Don't call ttsetwater() explicitly in open().  It is now called for
the TTYDISC l_open() and should be static.

Don't attempt to register the cdevsw more than once.
This commit is contained in:
Bruce Evans 1998-08-19 04:17:38 +00:00
parent 5cf40a698b
commit 3fd2d29816
6 changed files with 60 additions and 54 deletions

View File

@ -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.67 1998/08/13 13:54:10 bde Exp $
* $Id: cy.c,v 1.68 1998/08/13 19:03:22 bde Exp $
*/
#include "opt_compat.h"
@ -153,7 +153,6 @@
#define CD1400_xIVR_CHAN 0x1F
#define LOTS_OF_EVENTS 64 /* helps separate urgent events from input */
#define RB_I_HIGH_WATER (TTYHOG - 2 * RS_IBUFSIZE)
#define RS_IBUFSIZE 256
#define CALLOUT_MASK 0x80
@ -390,7 +389,7 @@ static struct cdevsw sio_cdevsw = {
static int comconsole = -1;
static speed_t comdefaultrate = TTYDEF_SPEED;
static u_int com_events; /* input chars + weighted output completions */
static bool_t siopoll_registered;
static bool_t sio_registered;
static int sio_timeout;
static int sio_timeouts_until_log;
static struct callout_handle sio_timeout_handle
@ -604,8 +603,6 @@ cyattach_common(cy_iobase, cy_align)
com_addr(unit) = com;
splx(s);
dev = makedev(CDEV_MAJOR, 0);
cdevsw_add(&dev, &sio_cdevsw, NULL);
#ifdef DEVFS
com->devfs_token_ttyd = devfs_add_devswf(&sio_cdevsw,
unit, DV_CHR,
@ -634,9 +631,11 @@ cyattach_common(cy_iobase, cy_align)
#endif
}
}
if (!siopoll_registered) {
if (!sio_registered) {
dev = makedev(CDEV_MAJOR, 0);
cdevsw_add(&dev, &sio_cdevsw, NULL);
register_swi(SWI_TTY, siopoll);
siopoll_registered = TRUE;
sio_registered = TRUE;
}
/* ensure an edge for the next interrupt */
@ -721,6 +720,9 @@ sioopen(dev, flag, mode, p)
tp->t_dev = dev;
tp->t_termios = mynor & CALLOUT_MASK
? com->it_out : com->it_in;
tp->t_ififosize = 2 * RS_IBUFSIZE;
tp->t_ispeedwat = (speed_t)-1;
tp->t_ospeedwat = (speed_t)-1;
#if 0
(void)commctl(com, TIOCM_DTR | TIOCM_RTS, DMSET);
com->poll = com->no_irq;
@ -759,7 +761,6 @@ sioopen(dev, flag, mode, p)
/*
* XXX we should goto open_top if comparam() slept.
*/
ttsetwater(tp);
#if 0
if (com->hasfifo) {
/*
@ -1675,7 +1676,7 @@ siopoll()
* call overhead).
*/
if (tp->t_state & TS_CAN_BYPASS_L_RINT) {
if (tp->t_rawq.c_cc + incc >= RB_I_HIGH_WATER
if (tp->t_rawq.c_cc + incc > tp->t_ihiwat
&& (com->state & CS_RTS_IFLOW
|| tp->t_iflag & IXOFF)
&& !(tp->t_state & TS_TBLOCK))

View File

@ -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.67 1998/08/13 13:54:10 bde Exp $
* $Id: cy.c,v 1.68 1998/08/13 19:03:22 bde Exp $
*/
#include "opt_compat.h"
@ -153,7 +153,6 @@
#define CD1400_xIVR_CHAN 0x1F
#define LOTS_OF_EVENTS 64 /* helps separate urgent events from input */
#define RB_I_HIGH_WATER (TTYHOG - 2 * RS_IBUFSIZE)
#define RS_IBUFSIZE 256
#define CALLOUT_MASK 0x80
@ -390,7 +389,7 @@ static struct cdevsw sio_cdevsw = {
static int comconsole = -1;
static speed_t comdefaultrate = TTYDEF_SPEED;
static u_int com_events; /* input chars + weighted output completions */
static bool_t siopoll_registered;
static bool_t sio_registered;
static int sio_timeout;
static int sio_timeouts_until_log;
static struct callout_handle sio_timeout_handle
@ -604,8 +603,6 @@ cyattach_common(cy_iobase, cy_align)
com_addr(unit) = com;
splx(s);
dev = makedev(CDEV_MAJOR, 0);
cdevsw_add(&dev, &sio_cdevsw, NULL);
#ifdef DEVFS
com->devfs_token_ttyd = devfs_add_devswf(&sio_cdevsw,
unit, DV_CHR,
@ -634,9 +631,11 @@ cyattach_common(cy_iobase, cy_align)
#endif
}
}
if (!siopoll_registered) {
if (!sio_registered) {
dev = makedev(CDEV_MAJOR, 0);
cdevsw_add(&dev, &sio_cdevsw, NULL);
register_swi(SWI_TTY, siopoll);
siopoll_registered = TRUE;
sio_registered = TRUE;
}
/* ensure an edge for the next interrupt */
@ -721,6 +720,9 @@ sioopen(dev, flag, mode, p)
tp->t_dev = dev;
tp->t_termios = mynor & CALLOUT_MASK
? com->it_out : com->it_in;
tp->t_ififosize = 2 * RS_IBUFSIZE;
tp->t_ispeedwat = (speed_t)-1;
tp->t_ospeedwat = (speed_t)-1;
#if 0
(void)commctl(com, TIOCM_DTR | TIOCM_RTS, DMSET);
com->poll = com->no_irq;
@ -759,7 +761,6 @@ sioopen(dev, flag, mode, p)
/*
* XXX we should goto open_top if comparam() slept.
*/
ttsetwater(tp);
#if 0
if (com->hasfifo) {
/*
@ -1675,7 +1676,7 @@ siopoll()
* call overhead).
*/
if (tp->t_state & TS_CAN_BYPASS_L_RINT) {
if (tp->t_rawq.c_cc + incc >= RB_I_HIGH_WATER
if (tp->t_rawq.c_cc + incc > tp->t_ihiwat
&& (com->state & CS_RTS_IFLOW
|| tp->t_iflag & IXOFF)
&& !(tp->t_state & TS_TBLOCK))

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* from: @(#)com.c 7.5 (Berkeley) 5/16/91
* $Id: sio.c,v 1.209 1998/07/15 12:18:14 bde Exp $
* $Id: sio.c,v 1.210 1998/08/11 17:01:32 bde Exp $
*/
#include "opt_comconsole.h"
@ -107,7 +107,6 @@
#endif /* SMP */
#define LOTS_OF_EVENTS 64 /* helps separate urgent events from input */
#define RB_I_HIGH_WATER (TTYHOG - 2 * RS_IBUFSIZE)
#define RS_IBUFSIZE 256
#define CALLOUT_MASK 0x80
@ -356,7 +355,7 @@ static int comconsole = -1;
static volatile speed_t comdefaultrate = CONSPEED;
static u_int com_events; /* input chars + weighted output completions */
static Port_t siocniobase;
static bool_t siopoll_registered;
static bool_t sio_registered;
static int sio_timeout;
static int sio_timeouts_until_log;
static struct callout_handle sio_timeout_handle
@ -1071,8 +1070,6 @@ determined_type: ;
com_addr(unit) = com;
splx(s);
dev = makedev(CDEV_MAJOR, 0);
cdevsw_add(&dev, &sio_cdevsw, NULL);
#ifdef DEVFS
com->devfs_token_ttyd = devfs_add_devswf(&sio_cdevsw,
unit, DV_CHR,
@ -1093,9 +1090,11 @@ determined_type: ;
unit | CALLOUT_MASK | CONTROL_LOCK_STATE, DV_CHR,
UID_UUCP, GID_DIALER, 0660, "cuala%r", unit);
#endif
if (!siopoll_registered) {
if (!sio_registered) {
dev = makedev(CDEV_MAJOR, 0);
cdevsw_add(&dev, &sio_cdevsw, NULL);
register_swi(SWI_TTY, siopoll);
siopoll_registered = TRUE;
sio_registered = TRUE;
}
com->id_flags = isdp->id_flags; /* Heritate id_flags for later */
return (1);
@ -1183,6 +1182,9 @@ sioopen(dev, flag, mode, p)
tp->t_dev = dev;
tp->t_termios = mynor & CALLOUT_MASK
? com->it_out : com->it_in;
tp->t_ififosize = 2 * RS_IBUFSIZE;
tp->t_ispeedwat = (speed_t)-1;
tp->t_ospeedwat = (speed_t)-1;
(void)commctl(com, TIOCM_DTR | TIOCM_RTS, DMSET);
com->poll = com->no_irq;
com->poll_output = com->loses_outints;
@ -1194,7 +1196,6 @@ sioopen(dev, flag, mode, p)
/*
* XXX we should goto open_top if comparam() slept.
*/
ttsetwater(tp);
iobase = com->iobase;
if (com->hasfifo) {
/*
@ -1976,7 +1977,7 @@ siopoll()
* call overhead).
*/
if (tp->t_state & TS_CAN_BYPASS_L_RINT) {
if (tp->t_rawq.c_cc + incc >= RB_I_HIGH_WATER
if (tp->t_rawq.c_cc + incc > tp->t_ihiwat
&& (com->state & CS_RTS_IFLOW
|| tp->t_iflag & IXOFF)
&& !(tp->t_state & TS_TBLOCK))

View File

@ -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.67 1998/08/13 13:54:10 bde Exp $
* $Id: cy.c,v 1.68 1998/08/13 19:03:22 bde Exp $
*/
#include "opt_compat.h"
@ -153,7 +153,6 @@
#define CD1400_xIVR_CHAN 0x1F
#define LOTS_OF_EVENTS 64 /* helps separate urgent events from input */
#define RB_I_HIGH_WATER (TTYHOG - 2 * RS_IBUFSIZE)
#define RS_IBUFSIZE 256
#define CALLOUT_MASK 0x80
@ -390,7 +389,7 @@ static struct cdevsw sio_cdevsw = {
static int comconsole = -1;
static speed_t comdefaultrate = TTYDEF_SPEED;
static u_int com_events; /* input chars + weighted output completions */
static bool_t siopoll_registered;
static bool_t sio_registered;
static int sio_timeout;
static int sio_timeouts_until_log;
static struct callout_handle sio_timeout_handle
@ -604,8 +603,6 @@ cyattach_common(cy_iobase, cy_align)
com_addr(unit) = com;
splx(s);
dev = makedev(CDEV_MAJOR, 0);
cdevsw_add(&dev, &sio_cdevsw, NULL);
#ifdef DEVFS
com->devfs_token_ttyd = devfs_add_devswf(&sio_cdevsw,
unit, DV_CHR,
@ -634,9 +631,11 @@ cyattach_common(cy_iobase, cy_align)
#endif
}
}
if (!siopoll_registered) {
if (!sio_registered) {
dev = makedev(CDEV_MAJOR, 0);
cdevsw_add(&dev, &sio_cdevsw, NULL);
register_swi(SWI_TTY, siopoll);
siopoll_registered = TRUE;
sio_registered = TRUE;
}
/* ensure an edge for the next interrupt */
@ -721,6 +720,9 @@ sioopen(dev, flag, mode, p)
tp->t_dev = dev;
tp->t_termios = mynor & CALLOUT_MASK
? com->it_out : com->it_in;
tp->t_ififosize = 2 * RS_IBUFSIZE;
tp->t_ispeedwat = (speed_t)-1;
tp->t_ospeedwat = (speed_t)-1;
#if 0
(void)commctl(com, TIOCM_DTR | TIOCM_RTS, DMSET);
com->poll = com->no_irq;
@ -759,7 +761,6 @@ sioopen(dev, flag, mode, p)
/*
* XXX we should goto open_top if comparam() slept.
*/
ttsetwater(tp);
#if 0
if (com->hasfifo) {
/*
@ -1675,7 +1676,7 @@ siopoll()
* call overhead).
*/
if (tp->t_state & TS_CAN_BYPASS_L_RINT) {
if (tp->t_rawq.c_cc + incc >= RB_I_HIGH_WATER
if (tp->t_rawq.c_cc + incc > tp->t_ihiwat
&& (com->state & CS_RTS_IFLOW
|| tp->t_iflag & IXOFF)
&& !(tp->t_state & TS_TBLOCK))

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* from: @(#)com.c 7.5 (Berkeley) 5/16/91
* $Id: sio.c,v 1.209 1998/07/15 12:18:14 bde Exp $
* $Id: sio.c,v 1.210 1998/08/11 17:01:32 bde Exp $
*/
#include "opt_comconsole.h"
@ -107,7 +107,6 @@
#endif /* SMP */
#define LOTS_OF_EVENTS 64 /* helps separate urgent events from input */
#define RB_I_HIGH_WATER (TTYHOG - 2 * RS_IBUFSIZE)
#define RS_IBUFSIZE 256
#define CALLOUT_MASK 0x80
@ -356,7 +355,7 @@ static int comconsole = -1;
static volatile speed_t comdefaultrate = CONSPEED;
static u_int com_events; /* input chars + weighted output completions */
static Port_t siocniobase;
static bool_t siopoll_registered;
static bool_t sio_registered;
static int sio_timeout;
static int sio_timeouts_until_log;
static struct callout_handle sio_timeout_handle
@ -1071,8 +1070,6 @@ determined_type: ;
com_addr(unit) = com;
splx(s);
dev = makedev(CDEV_MAJOR, 0);
cdevsw_add(&dev, &sio_cdevsw, NULL);
#ifdef DEVFS
com->devfs_token_ttyd = devfs_add_devswf(&sio_cdevsw,
unit, DV_CHR,
@ -1093,9 +1090,11 @@ determined_type: ;
unit | CALLOUT_MASK | CONTROL_LOCK_STATE, DV_CHR,
UID_UUCP, GID_DIALER, 0660, "cuala%r", unit);
#endif
if (!siopoll_registered) {
if (!sio_registered) {
dev = makedev(CDEV_MAJOR, 0);
cdevsw_add(&dev, &sio_cdevsw, NULL);
register_swi(SWI_TTY, siopoll);
siopoll_registered = TRUE;
sio_registered = TRUE;
}
com->id_flags = isdp->id_flags; /* Heritate id_flags for later */
return (1);
@ -1183,6 +1182,9 @@ sioopen(dev, flag, mode, p)
tp->t_dev = dev;
tp->t_termios = mynor & CALLOUT_MASK
? com->it_out : com->it_in;
tp->t_ififosize = 2 * RS_IBUFSIZE;
tp->t_ispeedwat = (speed_t)-1;
tp->t_ospeedwat = (speed_t)-1;
(void)commctl(com, TIOCM_DTR | TIOCM_RTS, DMSET);
com->poll = com->no_irq;
com->poll_output = com->loses_outints;
@ -1194,7 +1196,6 @@ sioopen(dev, flag, mode, p)
/*
* XXX we should goto open_top if comparam() slept.
*/
ttsetwater(tp);
iobase = com->iobase;
if (com->hasfifo) {
/*
@ -1976,7 +1977,7 @@ siopoll()
* call overhead).
*/
if (tp->t_state & TS_CAN_BYPASS_L_RINT) {
if (tp->t_rawq.c_cc + incc >= RB_I_HIGH_WATER
if (tp->t_rawq.c_cc + incc > tp->t_ihiwat
&& (com->state & CS_RTS_IFLOW
|| tp->t_iflag & IXOFF)
&& !(tp->t_state & TS_TBLOCK))

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* from: @(#)com.c 7.5 (Berkeley) 5/16/91
* $Id: sio.c,v 1.209 1998/07/15 12:18:14 bde Exp $
* $Id: sio.c,v 1.210 1998/08/11 17:01:32 bde Exp $
*/
#include "opt_comconsole.h"
@ -107,7 +107,6 @@
#endif /* SMP */
#define LOTS_OF_EVENTS 64 /* helps separate urgent events from input */
#define RB_I_HIGH_WATER (TTYHOG - 2 * RS_IBUFSIZE)
#define RS_IBUFSIZE 256
#define CALLOUT_MASK 0x80
@ -356,7 +355,7 @@ static int comconsole = -1;
static volatile speed_t comdefaultrate = CONSPEED;
static u_int com_events; /* input chars + weighted output completions */
static Port_t siocniobase;
static bool_t siopoll_registered;
static bool_t sio_registered;
static int sio_timeout;
static int sio_timeouts_until_log;
static struct callout_handle sio_timeout_handle
@ -1071,8 +1070,6 @@ determined_type: ;
com_addr(unit) = com;
splx(s);
dev = makedev(CDEV_MAJOR, 0);
cdevsw_add(&dev, &sio_cdevsw, NULL);
#ifdef DEVFS
com->devfs_token_ttyd = devfs_add_devswf(&sio_cdevsw,
unit, DV_CHR,
@ -1093,9 +1090,11 @@ determined_type: ;
unit | CALLOUT_MASK | CONTROL_LOCK_STATE, DV_CHR,
UID_UUCP, GID_DIALER, 0660, "cuala%r", unit);
#endif
if (!siopoll_registered) {
if (!sio_registered) {
dev = makedev(CDEV_MAJOR, 0);
cdevsw_add(&dev, &sio_cdevsw, NULL);
register_swi(SWI_TTY, siopoll);
siopoll_registered = TRUE;
sio_registered = TRUE;
}
com->id_flags = isdp->id_flags; /* Heritate id_flags for later */
return (1);
@ -1183,6 +1182,9 @@ sioopen(dev, flag, mode, p)
tp->t_dev = dev;
tp->t_termios = mynor & CALLOUT_MASK
? com->it_out : com->it_in;
tp->t_ififosize = 2 * RS_IBUFSIZE;
tp->t_ispeedwat = (speed_t)-1;
tp->t_ospeedwat = (speed_t)-1;
(void)commctl(com, TIOCM_DTR | TIOCM_RTS, DMSET);
com->poll = com->no_irq;
com->poll_output = com->loses_outints;
@ -1194,7 +1196,6 @@ sioopen(dev, flag, mode, p)
/*
* XXX we should goto open_top if comparam() slept.
*/
ttsetwater(tp);
iobase = com->iobase;
if (com->hasfifo) {
/*
@ -1976,7 +1977,7 @@ siopoll()
* call overhead).
*/
if (tp->t_state & TS_CAN_BYPASS_L_RINT) {
if (tp->t_rawq.c_cc + incc >= RB_I_HIGH_WATER
if (tp->t_rawq.c_cc + incc > tp->t_ihiwat
&& (com->state & CS_RTS_IFLOW
|| tp->t_iflag & IXOFF)
&& !(tp->t_state & TS_TBLOCK))