summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1995-04-11 17:54:25 +0000
committerache <ache@FreeBSD.org>1995-04-11 17:54:25 +0000
commita569d0b92cb34fd85f0acd7224bedbf6c02521dd (patch)
tree227218dbaad6f8807ea9cc383990073d4e27245f
parent8dd2e3731fe9b5cee62ec0f6e2d37b604ec0e8c8 (diff)
downloadFreeBSD-src-a569d0b92cb34fd85f0acd7224bedbf6c02521dd.zip
FreeBSD-src-a569d0b92cb34fd85f0acd7224bedbf6c02521dd.tar.gz
Extract "set" family functions to separate module, needed for
locking in sio f.e.
-rw-r--r--sys/kern/tty_compat.c160
1 files changed, 90 insertions, 70 deletions
diff --git a/sys/kern/tty_compat.c b/sys/kern/tty_compat.c
index 4ca1193..b420d46 100644
--- a/sys/kern/tty_compat.c
+++ b/sys/kern/tty_compat.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)tty_compat.c 8.1 (Berkeley) 6/10/93
- * $Id: tty_compat.c,v 1.10 1995/04/02 04:15:08 ache Exp $
+ * $Id: tty_compat.c,v 1.11 1995/04/02 19:26:50 ache Exp $
*/
/*
@@ -83,76 +83,38 @@ static int compatspcodes[] = {
1800, 2400, 4800, 9600, 19200, 38400, 57600, 115200,
};
-/*ARGSUSED*/
-int
-ttcompat(tp, com, data, flag)
+int ttsetcompat(tp, com, data, term)
register struct tty *tp;
- int com;
+ int *com;
caddr_t data;
- int flag;
+ struct termios *term;
{
- struct termios term;
-
- switch (com) {
- case TIOCGETP: {
- register struct sgttyb *sg = (struct sgttyb *)data;
- register cc_t *cc = tp->t_cc;
- register speed;
-
- speed = ttspeedtab(tp->t_ospeed, compatspeeds);
- sg->sg_ospeed = (speed == -1) ? MAX_SPEED : speed;
- if (tp->t_ispeed == 0)
- sg->sg_ispeed = sg->sg_ospeed;
- else {
- speed = ttspeedtab(tp->t_ispeed, compatspeeds);
- sg->sg_ispeed = (speed == -1) ? MAX_SPEED : speed;
- }
- sg->sg_erase = cc[VERASE];
- sg->sg_kill = cc[VKILL];
- sg->sg_flags = tp->t_flags = ttcompatgetflags(tp);
- break;
- }
-
+ switch (*com) {
case TIOCSETP:
case TIOCSETN: {
register struct sgttyb *sg = (struct sgttyb *)data;
int speed;
- term = tp->t_termios;
if ((speed = sg->sg_ispeed) > MAX_SPEED || speed < 0)
return(EINVAL);
else
- term.c_ispeed = compatspcodes[speed];
+ term->c_ispeed = compatspcodes[speed];
if ((speed = sg->sg_ospeed) > MAX_SPEED || speed < 0)
return(EINVAL);
else
- term.c_ospeed = compatspcodes[speed];
- term.c_cc[VERASE] = sg->sg_erase;
- term.c_cc[VKILL] = sg->sg_kill;
+ term->c_ospeed = compatspcodes[speed];
+ term->c_cc[VERASE] = sg->sg_erase;
+ term->c_cc[VKILL] = sg->sg_kill;
tp->t_flags = (tp->t_flags&0xffff0000) | (sg->sg_flags&0xffff);
- ttcompatsetflags(tp, &term);
- return (ttioctl(tp, com == TIOCSETP ? TIOCSETAF : TIOCSETA,
- &term, flag));
- }
-
- case TIOCGETC: {
- struct tchars *tc = (struct tchars *)data;
- register cc_t *cc = tp->t_cc;
-
- 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];
+ ttcompatsetflags(tp, term);
+ *com = (*com == TIOCSETP) ? TIOCSETAF : TIOCSETA;
break;
}
case TIOCSETC: {
struct tchars *tc = (struct tchars *)data;
register cc_t *cc;
- term = tp->t_termios;
- cc = term.c_cc;
+ cc = term->c_cc;
cc[VINTR] = tc->t_intrc;
cc[VQUIT] = tc->t_quitc;
cc[VSTART] = tc->t_startc;
@@ -161,51 +123,109 @@ ttcompat(tp, com, data, flag)
cc[VEOL] = tc->t_brkc;
if (tc->t_brkc == -1)
cc[VEOL2] = _POSIX_VDISABLE;
- return (ttioctl(tp, TIOCSETA, &term, flag));
+ *com = TIOCSETA;
+ break;
}
case TIOCSLTC: {
struct ltchars *ltc = (struct ltchars *)data;
register cc_t *cc;
- term = tp->t_termios;
- cc = term.c_cc;
+ cc = term->c_cc;
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;
- return (ttioctl(tp, TIOCSETA, &term, flag));
- }
- case TIOCGLTC: {
- struct ltchars *ltc = (struct ltchars *)data;
- register cc_t *cc = tp->t_cc;
-
- 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];
+ *com = TIOCSETA;
break;
}
case TIOCLBIS:
case TIOCLBIC:
case TIOCLSET:
- term = tp->t_termios;
- if (com == TIOCLSET)
+ if (*com == TIOCLSET)
tp->t_flags = (tp->t_flags&0xffff) | *(int *)data<<16;
else {
tp->t_flags =
(ttcompatgetflags(tp)&0xffff0000)|(tp->t_flags&0xffff);
- if (com == TIOCLBIS)
+ if (*com == TIOCLBIS)
tp->t_flags |= *(int *)data<<16;
else
tp->t_flags &= ~(*(int *)data<<16);
}
- ttcompatsetlflags(tp, &term);
- return (ttioctl(tp, TIOCSETA, &term, flag));
+ ttcompatsetlflags(tp, term);
+ *com = TIOCSETA;
+ break;
+ }
+ return 0;
+}
+
+/*ARGSUSED*/
+int
+ttcompat(tp, com, data, flag)
+ register struct tty *tp;
+ int com;
+ caddr_t data;
+ int flag;
+{
+ 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;
+ return ttioctl(tp, com, &term, flag);
+ }
+ case TIOCGETP: {
+ register struct sgttyb *sg = (struct sgttyb *)data;
+ register cc_t *cc = tp->t_cc;
+ register speed;
+
+ speed = ttspeedtab(tp->t_ospeed, compatspeeds);
+ sg->sg_ospeed = (speed == -1) ? MAX_SPEED : speed;
+ if (tp->t_ispeed == 0)
+ sg->sg_ispeed = sg->sg_ospeed;
+ else {
+ speed = ttspeedtab(tp->t_ispeed, compatspeeds);
+ sg->sg_ispeed = (speed == -1) ? MAX_SPEED : speed;
+ }
+ sg->sg_erase = cc[VERASE];
+ sg->sg_kill = cc[VKILL];
+ sg->sg_flags = tp->t_flags = ttcompatgetflags(tp);
+ break;
+ }
+ case TIOCGETC: {
+ struct tchars *tc = (struct tchars *)data;
+ register cc_t *cc = tp->t_cc;
+
+ 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;
+ register cc_t *cc = tp->t_cc;
+ 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;
+ }
case TIOCLGET:
tp->t_flags =
(ttcompatgetflags(tp) & 0xffff0000UL)
OpenPOWER on IntegriCloud