1994-05-24 10:09:53 +00:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 1982, 1986, 1991, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
2016-09-15 13:16:20 +00:00
|
|
|
* 3. Neither the name of the University nor the names of its contributors
|
1994-05-24 10:09:53 +00:00
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* @(#)tty_compat.c 8.1 (Berkeley) 6/10/93
|
|
|
|
*/
|
|
|
|
|
2003-06-11 00:56:59 +00:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
1997-12-16 17:40:42 +00:00
|
|
|
#include "opt_compat.h"
|
|
|
|
|
1995-05-30 08:16:23 +00:00
|
|
|
/*
|
1994-05-24 10:09:53 +00:00
|
|
|
* mapping routines for old line discipline (yuck)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
1997-03-24 12:03:06 +00:00
|
|
|
#include <sys/ioctl_compat.h>
|
1994-05-24 10:09:53 +00:00
|
|
|
#include <sys/tty.h>
|
|
|
|
#include <sys/kernel.h>
|
1995-12-14 08:32:45 +00:00
|
|
|
#include <sys/sysctl.h>
|
1994-05-24 10:09:53 +00:00
|
|
|
|
Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:
- Improved driver model:
The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.
If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.
- Improved hotplugging:
With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).
The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.
- Improved performance:
One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.
Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.
Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan
2008-08-20 08:31:58 +00:00
|
|
|
struct speedtab {
|
|
|
|
int sp_speed; /* Speed. */
|
|
|
|
int sp_code; /* Code. */
|
|
|
|
};
|
|
|
|
|
2002-03-24 05:09:11 +00:00
|
|
|
static int ttcompatgetflags(struct tty *tp);
|
|
|
|
static void ttcompatsetflags(struct tty *tp, struct termios *t);
|
|
|
|
static void ttcompatsetlflags(struct tty *tp, struct termios *t);
|
|
|
|
static int ttcompatspeedtab(int speed, struct speedtab *table);
|
1994-05-25 09:21:21 +00:00
|
|
|
|
1995-12-14 08:32:45 +00:00
|
|
|
static int ttydebug = 0;
|
|
|
|
SYSCTL_INT(_debug, OID_AUTO, ttydebug, CTLFLAG_RW, &ttydebug, 0, "");
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
static struct speedtab compatspeeds[] = {
|
1994-08-25 10:01:00 +00:00
|
|
|
#define MAX_SPEED 17
|
|
|
|
{ 115200, 17 },
|
|
|
|
{ 57600, 16 },
|
1994-05-24 10:09:53 +00:00
|
|
|
{ 38400, 15 },
|
|
|
|
{ 19200, 14 },
|
|
|
|
{ 9600, 13 },
|
|
|
|
{ 4800, 12 },
|
|
|
|
{ 2400, 11 },
|
|
|
|
{ 1800, 10 },
|
|
|
|
{ 1200, 9 },
|
|
|
|
{ 600, 8 },
|
|
|
|
{ 300, 7 },
|
|
|
|
{ 200, 6 },
|
|
|
|
{ 150, 5 },
|
|
|
|
{ 134, 4 },
|
|
|
|
{ 110, 3 },
|
|
|
|
{ 75, 2 },
|
|
|
|
{ 50, 1 },
|
|
|
|
{ 0, 0 },
|
|
|
|
{ -1, -1 },
|
|
|
|
};
|
1995-08-02 06:55:36 +00:00
|
|
|
static int compatspcodes[] = {
|
|
|
|
0, 50, 75, 110, 134, 150, 200, 300, 600, 1200,
|
1995-11-18 11:07:00 +00:00
|
|
|
1800, 2400, 4800, 9600, 19200, 38400, 57600, 115200,
|
1995-08-02 06:55:36 +00:00
|
|
|
};
|
1994-05-24 10:09:53 +00:00
|
|
|
|
1995-11-18 11:07:00 +00:00
|
|
|
static int
|
2004-06-21 12:28:56 +00:00
|
|
|
ttcompatspeedtab(int speed, struct speedtab *table)
|
1995-08-02 12:03:12 +00:00
|
|
|
{
|
|
|
|
if (speed == 0)
|
|
|
|
return (0); /* hangup */
|
|
|
|
for ( ; table->sp_speed > 0; table++)
|
|
|
|
if (table->sp_speed <= speed) /* nearest one, rounded down */
|
|
|
|
return (table->sp_code);
|
|
|
|
return (1); /* 50, min and not hangup */
|
|
|
|
}
|
|
|
|
|
2005-10-16 20:40:40 +00:00
|
|
|
static int
|
2004-06-21 12:28:56 +00:00
|
|
|
ttsetcompat(struct tty *tp, u_long *com, caddr_t data, struct termios *term)
|
1994-05-24 10:09:53 +00:00
|
|
|
{
|
1995-04-11 17:54:25 +00:00
|
|
|
switch (*com) {
|
1994-05-24 10:09:53 +00:00
|
|
|
case TIOCSETP:
|
|
|
|
case TIOCSETN: {
|
2004-06-21 12:28:56 +00:00
|
|
|
struct sgttyb *sg = (struct sgttyb *)data;
|
1994-05-24 10:09:53 +00:00
|
|
|
int speed;
|
|
|
|
|
1994-08-25 10:01:00 +00:00
|
|
|
if ((speed = sg->sg_ispeed) > MAX_SPEED || speed < 0)
|
1995-04-02 03:51:53 +00:00
|
|
|
return(EINVAL);
|
Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:
- Improved driver model:
The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.
If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.
- Improved hotplugging:
With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).
The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.
- Improved performance:
One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.
Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.
Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan
2008-08-20 08:31:58 +00:00
|
|
|
else if (speed != ttcompatspeedtab(tp->t_termios.c_ispeed,
|
|
|
|
compatspeeds))
|
1995-08-02 06:55:36 +00:00
|
|
|
term->c_ispeed = compatspcodes[speed];
|
1995-08-02 12:53:14 +00:00
|
|
|
else
|
Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:
- Improved driver model:
The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.
If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.
- Improved hotplugging:
With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).
The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.
- Improved performance:
One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.
Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.
Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan
2008-08-20 08:31:58 +00:00
|
|
|
term->c_ispeed = tp->t_termios.c_ispeed;
|
1994-08-25 10:01:00 +00:00
|
|
|
if ((speed = sg->sg_ospeed) > MAX_SPEED || speed < 0)
|
1995-04-02 03:51:53 +00:00
|
|
|
return(EINVAL);
|
Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:
- Improved driver model:
The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.
If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.
- Improved hotplugging:
With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).
The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.
- Improved performance:
One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.
Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.
Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan
2008-08-20 08:31:58 +00:00
|
|
|
else if (speed != ttcompatspeedtab(tp->t_termios.c_ospeed,
|
|
|
|
compatspeeds))
|
1995-08-02 06:55:36 +00:00
|
|
|
term->c_ospeed = compatspcodes[speed];
|
1995-08-02 12:53:14 +00:00
|
|
|
else
|
Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:
- Improved driver model:
The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.
If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.
- Improved hotplugging:
With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).
The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.
- Improved performance:
One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.
Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.
Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan
2008-08-20 08:31:58 +00:00
|
|
|
term->c_ospeed = tp->t_termios.c_ospeed;
|
1995-04-11 17:54:25 +00:00
|
|
|
term->c_cc[VERASE] = sg->sg_erase;
|
|
|
|
term->c_cc[VKILL] = sg->sg_kill;
|
2008-09-04 16:30:53 +00:00
|
|
|
tp->t_compatflags = (tp->t_compatflags&0xffff0000) |
|
|
|
|
(sg->sg_flags&0xffff);
|
1995-04-11 17:54:25 +00:00
|
|
|
ttcompatsetflags(tp, term);
|
|
|
|
*com = (*com == TIOCSETP) ? TIOCSETAF : TIOCSETA;
|
1994-05-24 10:09:53 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TIOCSETC: {
|
|
|
|
struct tchars *tc = (struct tchars *)data;
|
2004-06-21 12:28:56 +00:00
|
|
|
cc_t *cc;
|
1994-05-24 10:09:53 +00:00
|
|
|
|
1995-04-11 17:54:25 +00:00
|
|
|
cc = term->c_cc;
|
1994-05-24 10:09:53 +00:00
|
|
|
cc[VINTR] = tc->t_intrc;
|
|
|
|
cc[VQUIT] = tc->t_quitc;
|
|
|
|
cc[VSTART] = tc->t_startc;
|
|
|
|
cc[VSTOP] = tc->t_stopc;
|
|
|
|
cc[VEOF] = tc->t_eofc;
|
|
|
|
cc[VEOL] = tc->t_brkc;
|
2004-05-07 15:35:38 +00:00
|
|
|
if (tc->t_brkc == (char)_POSIX_VDISABLE)
|
1994-05-24 10:09:53 +00:00
|
|
|
cc[VEOL2] = _POSIX_VDISABLE;
|
1995-04-11 17:54:25 +00:00
|
|
|
*com = TIOCSETA;
|
|
|
|
break;
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
case TIOCSLTC: {
|
|
|
|
struct ltchars *ltc = (struct ltchars *)data;
|
2004-06-21 12:28:56 +00:00
|
|
|
cc_t *cc;
|
1994-05-24 10:09:53 +00:00
|
|
|
|
1995-04-11 17:54:25 +00:00
|
|
|
cc = term->c_cc;
|
1994-05-24 10:09:53 +00:00
|
|
|
cc[VSUSP] = ltc->t_suspc;
|
|
|
|
cc[VDSUSP] = ltc->t_dsuspc;
|
|
|
|
cc[VREPRINT] = ltc->t_rprntc;
|
|
|
|
cc[VDISCARD] = ltc->t_flushc;
|
|
|
|
cc[VWERASE] = ltc->t_werasc;
|
|
|
|
cc[VLNEXT] = ltc->t_lnextc;
|
1995-04-11 17:54:25 +00:00
|
|
|
*com = TIOCSETA;
|
1994-05-24 10:09:53 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TIOCLBIS:
|
|
|
|
case TIOCLBIC:
|
1995-04-02 04:15:08 +00:00
|
|
|
case TIOCLSET:
|
1995-04-11 17:54:25 +00:00
|
|
|
if (*com == TIOCLSET)
|
2008-09-04 16:30:53 +00:00
|
|
|
tp->t_compatflags = (tp->t_compatflags&0xffff) |
|
|
|
|
*(int *)data<<16;
|
1994-05-24 10:09:53 +00:00
|
|
|
else {
|
2008-09-04 16:30:53 +00:00
|
|
|
tp->t_compatflags = (ttcompatgetflags(tp)&0xffff0000) |
|
|
|
|
(tp->t_compatflags&0xffff);
|
1995-04-11 17:54:25 +00:00
|
|
|
if (*com == TIOCLBIS)
|
2008-09-04 16:30:53 +00:00
|
|
|
tp->t_compatflags |= *(int *)data<<16;
|
1994-05-24 10:09:53 +00:00
|
|
|
else
|
2008-09-04 16:30:53 +00:00
|
|
|
tp->t_compatflags &= ~(*(int *)data<<16);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
1995-04-11 17:54:25 +00:00
|
|
|
ttcompatsetlflags(tp, term);
|
|
|
|
*com = TIOCSETA;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
1995-04-02 04:15:08 +00:00
|
|
|
|
1995-04-11 17:54:25 +00:00
|
|
|
/*ARGSUSED*/
|
|
|
|
int
|
2010-01-04 20:59:52 +00:00
|
|
|
tty_ioctl_compat(struct tty *tp, u_long com, caddr_t data, int fflag,
|
|
|
|
struct thread *td)
|
1995-04-11 17:54:25 +00:00
|
|
|
{
|
|
|
|
switch (com) {
|
|
|
|
case TIOCSETP:
|
|
|
|
case TIOCSETN:
|
|
|
|
case TIOCSETC:
|
|
|
|
case TIOCSLTC:
|
|
|
|
case TIOCLBIS:
|
|
|
|
case TIOCLBIC:
|
|
|
|
case TIOCLSET: {
|
|
|
|
struct termios term;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
term = tp->t_termios;
|
|
|
|
if ((error = ttsetcompat(tp, &com, data, &term)) != 0)
|
|
|
|
return error;
|
2010-01-04 20:59:52 +00:00
|
|
|
return tty_ioctl(tp, com, &term, fflag, td);
|
1995-04-11 17:54:25 +00:00
|
|
|
}
|
|
|
|
case TIOCGETP: {
|
2004-06-21 12:28:56 +00:00
|
|
|
struct sgttyb *sg = (struct sgttyb *)data;
|
Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:
- Improved driver model:
The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.
If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.
- Improved hotplugging:
With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).
The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.
- Improved performance:
One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.
Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.
Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan
2008-08-20 08:31:58 +00:00
|
|
|
cc_t *cc = tp->t_termios.c_cc;
|
1995-04-11 17:54:25 +00:00
|
|
|
|
Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:
- Improved driver model:
The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.
If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.
- Improved hotplugging:
With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).
The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.
- Improved performance:
One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.
Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.
Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan
2008-08-20 08:31:58 +00:00
|
|
|
sg->sg_ospeed = ttcompatspeedtab(tp->t_termios.c_ospeed,
|
|
|
|
compatspeeds);
|
|
|
|
if (tp->t_termios.c_ispeed == 0)
|
1995-04-11 17:54:25 +00:00
|
|
|
sg->sg_ispeed = sg->sg_ospeed;
|
1995-08-02 12:03:12 +00:00
|
|
|
else
|
Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:
- Improved driver model:
The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.
If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.
- Improved hotplugging:
With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).
The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.
- Improved performance:
One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.
Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.
Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan
2008-08-20 08:31:58 +00:00
|
|
|
sg->sg_ispeed = ttcompatspeedtab(tp->t_termios.c_ispeed,
|
|
|
|
compatspeeds);
|
1995-04-11 17:54:25 +00:00
|
|
|
sg->sg_erase = cc[VERASE];
|
|
|
|
sg->sg_kill = cc[VKILL];
|
2008-09-04 16:30:53 +00:00
|
|
|
sg->sg_flags = tp->t_compatflags = ttcompatgetflags(tp);
|
1995-04-11 17:54:25 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TIOCGETC: {
|
|
|
|
struct tchars *tc = (struct tchars *)data;
|
Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:
- Improved driver model:
The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.
If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.
- Improved hotplugging:
With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).
The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.
- Improved performance:
One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.
Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.
Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan
2008-08-20 08:31:58 +00:00
|
|
|
cc_t *cc = tp->t_termios.c_cc;
|
1995-04-11 17:54:25 +00:00
|
|
|
|
|
|
|
tc->t_intrc = cc[VINTR];
|
|
|
|
tc->t_quitc = cc[VQUIT];
|
|
|
|
tc->t_startc = cc[VSTART];
|
|
|
|
tc->t_stopc = cc[VSTOP];
|
|
|
|
tc->t_eofc = cc[VEOF];
|
|
|
|
tc->t_brkc = cc[VEOL];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TIOCGLTC: {
|
|
|
|
struct ltchars *ltc = (struct ltchars *)data;
|
Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:
- Improved driver model:
The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.
If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.
- Improved hotplugging:
With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).
The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.
- Improved performance:
One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.
Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.
Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan
2008-08-20 08:31:58 +00:00
|
|
|
cc_t *cc = tp->t_termios.c_cc;
|
1995-04-11 17:54:25 +00:00
|
|
|
|
|
|
|
ltc->t_suspc = cc[VSUSP];
|
|
|
|
ltc->t_dsuspc = cc[VDSUSP];
|
|
|
|
ltc->t_rprntc = cc[VREPRINT];
|
|
|
|
ltc->t_flushc = cc[VDISCARD];
|
|
|
|
ltc->t_werasc = cc[VWERASE];
|
|
|
|
ltc->t_lnextc = cc[VLNEXT];
|
|
|
|
break;
|
|
|
|
}
|
1994-05-24 10:09:53 +00:00
|
|
|
case TIOCLGET:
|
2008-09-04 16:30:53 +00:00
|
|
|
tp->t_compatflags =
|
1995-05-30 08:16:23 +00:00
|
|
|
(ttcompatgetflags(tp) & 0xffff0000UL)
|
2008-09-04 16:30:53 +00:00
|
|
|
| (tp->t_compatflags & 0xffff);
|
|
|
|
*(int *)data = tp->t_compatflags>>16;
|
1994-05-24 10:09:53 +00:00
|
|
|
if (ttydebug)
|
|
|
|
printf("CLGET: returning %x\n", *(int *)data);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OTIOCGETD:
|
Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:
- Improved driver model:
The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.
If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.
- Improved hotplugging:
With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).
The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.
- Improved performance:
One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.
Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.
Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan
2008-08-20 08:31:58 +00:00
|
|
|
*(int *)data = 2;
|
1994-05-24 10:09:53 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case OTIOCSETD: {
|
|
|
|
int ldisczero = 0;
|
|
|
|
|
Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:
- Improved driver model:
The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.
If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.
- Improved hotplugging:
With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).
The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.
- Improved performance:
One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.
Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.
Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan
2008-08-20 08:31:58 +00:00
|
|
|
return (tty_ioctl(tp, TIOCSETD,
|
2010-01-04 20:59:52 +00:00
|
|
|
*(int *)data == 2 ? (caddr_t)&ldisczero : data,
|
|
|
|
fflag, td));
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case OTIOCCONS:
|
|
|
|
*(int *)data = 1;
|
2010-01-04 20:59:52 +00:00
|
|
|
return (tty_ioctl(tp, TIOCCONS, data, fflag, td));
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
default:
|
1997-12-06 13:25:01 +00:00
|
|
|
return (ENOIOCTL);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1995-04-02 19:26:50 +00:00
|
|
|
static int
|
2004-06-21 12:28:56 +00:00
|
|
|
ttcompatgetflags(struct tty *tp)
|
1994-05-24 10:09:53 +00:00
|
|
|
{
|
Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:
- Improved driver model:
The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.
If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.
- Improved hotplugging:
With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).
The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.
- Improved performance:
One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.
Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.
Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan
2008-08-20 08:31:58 +00:00
|
|
|
tcflag_t iflag = tp->t_termios.c_iflag;
|
|
|
|
tcflag_t lflag = tp->t_termios.c_lflag;
|
|
|
|
tcflag_t oflag = tp->t_termios.c_oflag;
|
|
|
|
tcflag_t cflag = tp->t_termios.c_cflag;
|
2004-06-21 12:28:56 +00:00
|
|
|
int flags = 0;
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
if (iflag&IXOFF)
|
|
|
|
flags |= TANDEM;
|
|
|
|
if (iflag&ICRNL || oflag&ONLCR)
|
|
|
|
flags |= CRMOD;
|
1994-10-11 20:04:49 +00:00
|
|
|
if ((cflag&CSIZE) == CS8) {
|
|
|
|
flags |= PASS8;
|
|
|
|
if (iflag&ISTRIP)
|
|
|
|
flags |= ANYP;
|
|
|
|
}
|
|
|
|
else if (cflag&PARENB) {
|
1994-05-24 10:09:53 +00:00
|
|
|
if (iflag&INPCK) {
|
|
|
|
if (cflag&PARODD)
|
|
|
|
flags |= ODDP;
|
|
|
|
else
|
|
|
|
flags |= EVENP;
|
|
|
|
} else
|
|
|
|
flags |= EVENP | ODDP;
|
|
|
|
}
|
1995-05-30 08:16:23 +00:00
|
|
|
|
|
|
|
if ((lflag&ICANON) == 0) {
|
1994-05-24 10:09:53 +00:00
|
|
|
/* fudge */
|
1994-10-11 20:04:49 +00:00
|
|
|
if (iflag&(INPCK|ISTRIP|IXON) || lflag&(IEXTEN|ISIG)
|
1998-01-25 17:25:41 +00:00
|
|
|
|| (cflag&(CSIZE|PARENB)) != CS8)
|
1994-05-24 10:09:53 +00:00
|
|
|
flags |= CBREAK;
|
|
|
|
else
|
|
|
|
flags |= RAW;
|
|
|
|
}
|
1998-01-25 17:25:41 +00:00
|
|
|
if (!(flags&RAW) && !(oflag&OPOST) && (cflag&(CSIZE|PARENB)) == CS8)
|
1994-10-11 20:04:49 +00:00
|
|
|
flags |= LITOUT;
|
1994-05-24 10:09:53 +00:00
|
|
|
if (cflag&MDMBUF)
|
|
|
|
flags |= MDMBUF;
|
|
|
|
if ((cflag&HUPCL) == 0)
|
|
|
|
flags |= NOHANG;
|
Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:
- Improved driver model:
The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.
If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.
- Improved hotplugging:
With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).
The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.
- Improved performance:
One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.
Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.
Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan
2008-08-20 08:31:58 +00:00
|
|
|
if (oflag&TAB3)
|
1994-05-24 10:09:53 +00:00
|
|
|
flags |= XTABS;
|
|
|
|
if (lflag&ECHOE)
|
|
|
|
flags |= CRTERA|CRTBS;
|
|
|
|
if (lflag&ECHOKE)
|
|
|
|
flags |= CRTKIL|CRTBS;
|
|
|
|
if (lflag&ECHOPRT)
|
|
|
|
flags |= PRTERA;
|
|
|
|
if (lflag&ECHOCTL)
|
|
|
|
flags |= CTLECH;
|
|
|
|
if ((iflag&IXANY) == 0)
|
|
|
|
flags |= DECCTQ;
|
|
|
|
flags |= lflag&(ECHO|TOSTOP|FLUSHO|PENDIN|NOFLSH);
|
1994-10-11 20:29:42 +00:00
|
|
|
if (ttydebug)
|
|
|
|
printf("getflags: %x\n", flags);
|
1994-05-24 10:09:53 +00:00
|
|
|
return (flags);
|
|
|
|
}
|
|
|
|
|
1995-04-02 19:26:50 +00:00
|
|
|
static void
|
2004-06-21 12:28:56 +00:00
|
|
|
ttcompatsetflags(struct tty *tp, struct termios *t)
|
1994-05-24 10:09:53 +00:00
|
|
|
{
|
2008-09-04 16:30:53 +00:00
|
|
|
int flags = tp->t_compatflags;
|
2004-06-21 12:28:56 +00:00
|
|
|
tcflag_t iflag = t->c_iflag;
|
|
|
|
tcflag_t oflag = t->c_oflag;
|
|
|
|
tcflag_t lflag = t->c_lflag;
|
|
|
|
tcflag_t cflag = t->c_cflag;
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
if (flags & RAW) {
|
1995-03-29 19:50:58 +00:00
|
|
|
iflag = IGNBRK;
|
1994-05-24 10:09:53 +00:00
|
|
|
lflag &= ~(ECHOCTL|ISIG|ICANON|IEXTEN);
|
|
|
|
} else {
|
1995-03-29 19:50:58 +00:00
|
|
|
iflag &= ~(PARMRK|IGNPAR|IGNCR|INLCR);
|
1994-05-24 10:09:53 +00:00
|
|
|
iflag |= BRKINT|IXON|IMAXBEL;
|
|
|
|
lflag |= ISIG|IEXTEN|ECHOCTL; /* XXX was echoctl on ? */
|
|
|
|
if (flags & XTABS)
|
Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:
- Improved driver model:
The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.
If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.
- Improved hotplugging:
With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).
The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.
- Improved performance:
One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.
Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.
Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan
2008-08-20 08:31:58 +00:00
|
|
|
oflag |= TAB3;
|
1994-05-24 10:09:53 +00:00
|
|
|
else
|
Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:
- Improved driver model:
The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.
If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.
- Improved hotplugging:
With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).
The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.
- Improved performance:
One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.
Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.
Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan
2008-08-20 08:31:58 +00:00
|
|
|
oflag &= ~TAB3;
|
1994-05-24 10:09:53 +00:00
|
|
|
if (flags & CBREAK)
|
|
|
|
lflag &= ~ICANON;
|
|
|
|
else
|
|
|
|
lflag |= ICANON;
|
|
|
|
if (flags&CRMOD) {
|
|
|
|
iflag |= ICRNL;
|
|
|
|
oflag |= ONLCR;
|
|
|
|
} else {
|
|
|
|
iflag &= ~ICRNL;
|
|
|
|
oflag &= ~ONLCR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (flags&ECHO)
|
|
|
|
lflag |= ECHO;
|
|
|
|
else
|
|
|
|
lflag &= ~ECHO;
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-10-11 20:29:42 +00:00
|
|
|
cflag &= ~(CSIZE|PARENB);
|
1994-10-11 20:04:49 +00:00
|
|
|
if (flags&(RAW|LITOUT|PASS8)) {
|
1994-05-24 10:09:53 +00:00
|
|
|
cflag |= CS8;
|
1994-10-11 20:04:49 +00:00
|
|
|
if (!(flags&(RAW|PASS8))
|
|
|
|
|| (flags&(RAW|PASS8|ANYP)) == (PASS8|ANYP))
|
1994-05-24 10:09:53 +00:00
|
|
|
iflag |= ISTRIP;
|
|
|
|
else
|
|
|
|
iflag &= ~ISTRIP;
|
1994-10-11 20:04:49 +00:00
|
|
|
if (flags&(RAW|LITOUT))
|
|
|
|
oflag &= ~OPOST;
|
|
|
|
else
|
|
|
|
oflag |= OPOST;
|
1994-05-24 10:09:53 +00:00
|
|
|
} else {
|
|
|
|
cflag |= CS7|PARENB;
|
|
|
|
iflag |= ISTRIP;
|
1994-10-11 20:04:49 +00:00
|
|
|
oflag |= OPOST;
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
1995-11-18 11:07:00 +00:00
|
|
|
/* XXX don't set INPCK if RAW or PASS8? */
|
1994-05-24 10:09:53 +00:00
|
|
|
if ((flags&(EVENP|ODDP)) == EVENP) {
|
|
|
|
iflag |= INPCK;
|
|
|
|
cflag &= ~PARODD;
|
|
|
|
} else if ((flags&(EVENP|ODDP)) == ODDP) {
|
|
|
|
iflag |= INPCK;
|
|
|
|
cflag |= PARODD;
|
1995-05-30 08:16:23 +00:00
|
|
|
} else
|
1994-05-24 10:09:53 +00:00
|
|
|
iflag &= ~INPCK;
|
|
|
|
if (flags&TANDEM)
|
|
|
|
iflag |= IXOFF;
|
|
|
|
else
|
|
|
|
iflag &= ~IXOFF;
|
1994-10-11 20:29:42 +00:00
|
|
|
if ((flags&DECCTQ) == 0)
|
|
|
|
iflag |= IXANY;
|
|
|
|
else
|
|
|
|
iflag &= ~IXANY;
|
1994-05-24 10:09:53 +00:00
|
|
|
t->c_iflag = iflag;
|
|
|
|
t->c_oflag = oflag;
|
|
|
|
t->c_lflag = lflag;
|
|
|
|
t->c_cflag = cflag;
|
|
|
|
}
|
|
|
|
|
1995-04-02 19:26:50 +00:00
|
|
|
static void
|
2004-06-21 12:28:56 +00:00
|
|
|
ttcompatsetlflags(struct tty *tp, struct termios *t)
|
1994-05-24 10:09:53 +00:00
|
|
|
{
|
2008-09-04 16:30:53 +00:00
|
|
|
int flags = tp->t_compatflags;
|
2004-06-21 12:28:56 +00:00
|
|
|
tcflag_t iflag = t->c_iflag;
|
|
|
|
tcflag_t oflag = t->c_oflag;
|
|
|
|
tcflag_t lflag = t->c_lflag;
|
|
|
|
tcflag_t cflag = t->c_cflag;
|
1994-05-24 10:09:53 +00:00
|
|
|
|
1995-03-29 19:50:58 +00:00
|
|
|
iflag &= ~(PARMRK|IGNPAR|IGNCR|INLCR);
|
1994-05-24 10:09:53 +00:00
|
|
|
if (flags&CRTERA)
|
|
|
|
lflag |= ECHOE;
|
|
|
|
else
|
|
|
|
lflag &= ~ECHOE;
|
|
|
|
if (flags&CRTKIL)
|
|
|
|
lflag |= ECHOKE;
|
|
|
|
else
|
|
|
|
lflag &= ~ECHOKE;
|
|
|
|
if (flags&PRTERA)
|
|
|
|
lflag |= ECHOPRT;
|
|
|
|
else
|
|
|
|
lflag &= ~ECHOPRT;
|
|
|
|
if (flags&CTLECH)
|
|
|
|
lflag |= ECHOCTL;
|
|
|
|
else
|
|
|
|
lflag &= ~ECHOCTL;
|
1994-10-11 20:29:42 +00:00
|
|
|
if (flags&TANDEM)
|
|
|
|
iflag |= IXOFF;
|
|
|
|
else
|
|
|
|
iflag &= ~IXOFF;
|
1994-05-24 10:09:53 +00:00
|
|
|
if ((flags&DECCTQ) == 0)
|
|
|
|
iflag |= IXANY;
|
|
|
|
else
|
|
|
|
iflag &= ~IXANY;
|
|
|
|
if (flags & MDMBUF)
|
|
|
|
cflag |= MDMBUF;
|
|
|
|
else
|
|
|
|
cflag &= ~MDMBUF;
|
|
|
|
if (flags&NOHANG)
|
|
|
|
cflag &= ~HUPCL;
|
|
|
|
else
|
|
|
|
cflag |= HUPCL;
|
|
|
|
lflag &= ~(TOSTOP|FLUSHO|PENDIN|NOFLSH);
|
|
|
|
lflag |= flags&(TOSTOP|FLUSHO|PENDIN|NOFLSH);
|
1994-10-11 20:04:49 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The next if-else statement is copied from above so don't bother
|
|
|
|
* checking it separately. We could avoid fiddlling with the
|
|
|
|
* character size if the mode is already RAW or if neither the
|
|
|
|
* LITOUT bit or the PASS8 bit is being changed, but the delta of
|
|
|
|
* the change is not available here and skipping the RAW case would
|
|
|
|
* make the code different from above.
|
|
|
|
*/
|
1994-10-11 20:29:42 +00:00
|
|
|
cflag &= ~(CSIZE|PARENB);
|
1994-10-11 20:04:49 +00:00
|
|
|
if (flags&(RAW|LITOUT|PASS8)) {
|
1994-05-24 10:09:53 +00:00
|
|
|
cflag |= CS8;
|
1994-10-11 20:04:49 +00:00
|
|
|
if (!(flags&(RAW|PASS8))
|
|
|
|
|| (flags&(RAW|PASS8|ANYP)) == (PASS8|ANYP))
|
1994-05-24 10:09:53 +00:00
|
|
|
iflag |= ISTRIP;
|
1994-10-11 20:04:49 +00:00
|
|
|
else
|
|
|
|
iflag &= ~ISTRIP;
|
|
|
|
if (flags&(RAW|LITOUT))
|
|
|
|
oflag &= ~OPOST;
|
|
|
|
else
|
|
|
|
oflag |= OPOST;
|
|
|
|
} else {
|
1994-05-24 10:09:53 +00:00
|
|
|
cflag |= CS7|PARENB;
|
1994-10-11 20:04:49 +00:00
|
|
|
iflag |= ISTRIP;
|
1994-05-24 10:09:53 +00:00
|
|
|
oflag |= OPOST;
|
|
|
|
}
|
|
|
|
t->c_iflag = iflag;
|
|
|
|
t->c_oflag = oflag;
|
|
|
|
t->c_lflag = lflag;
|
|
|
|
t->c_cflag = cflag;
|
|
|
|
}
|