tty.c (50477) | tty.c (51654) |
---|---|
1/*- 2 * Copyright (c) 1982, 1986, 1990, 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 22 unchanged lines hidden (view full) --- 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)tty.c 8.8 (Berkeley) 1/21/94 | 1/*- 2 * Copyright (c) 1982, 1986, 1990, 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 22 unchanged lines hidden (view full) --- 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)tty.c 8.8 (Berkeley) 1/21/94 |
39 * $FreeBSD: head/sys/kern/tty.c 50477 1999-08-28 01:08:13Z peter $ | 39 * $FreeBSD: head/sys/kern/tty.c 51654 1999-09-25 16:21:39Z phk $ |
40 */ 41 42/*- 43 * TODO: 44 * o Fix races for sending the start char in ttyflush(). 45 * o Handle inter-byte timeout for "MIN > 0, TIME > 0" in ttyselect(). 46 * With luck, there will be MIN chars before select() returns(). 47 * o Handle CLOCAL consistently for ptys. Perhaps disallow setting it. --- 369 unchanged lines hidden (view full) --- 417 } 418 /* 419 * Handle start/stop characters. 420 */ 421 if (ISSET(iflag, IXON)) { 422 if (CCEQ(cc[VSTOP], c)) { 423 if (!ISSET(tp->t_state, TS_TTSTOP)) { 424 SET(tp->t_state, TS_TTSTOP); | 40 */ 41 42/*- 43 * TODO: 44 * o Fix races for sending the start char in ttyflush(). 45 * o Handle inter-byte timeout for "MIN > 0, TIME > 0" in ttyselect(). 46 * With luck, there will be MIN chars before select() returns(). 47 * o Handle CLOCAL consistently for ptys. Perhaps disallow setting it. --- 369 unchanged lines hidden (view full) --- 417 } 418 /* 419 * Handle start/stop characters. 420 */ 421 if (ISSET(iflag, IXON)) { 422 if (CCEQ(cc[VSTOP], c)) { 423 if (!ISSET(tp->t_state, TS_TTSTOP)) { 424 SET(tp->t_state, TS_TTSTOP); |
425#ifdef sun4c /* XXX */ | |
426 (*tp->t_stop)(tp, 0); | 425 (*tp->t_stop)(tp, 0); |
427#else 428 (*devsw(tp->t_dev)->d_stop)(tp, 429 0); 430#endif | |
431 return (0); 432 } 433 if (!CCEQ(cc[VSTART], c)) 434 return (0); 435 /* 436 * if VSTART == VSTOP then toggle 437 */ 438 goto endcase; --- 555 unchanged lines hidden (view full) --- 994 s = spltty(); 995 (*linesw[tp->t_line].l_rint)(*(u_char *)data, tp); 996 splx(s); 997 break; 998 case TIOCSTOP: /* stop output, like ^S */ 999 s = spltty(); 1000 if (!ISSET(tp->t_state, TS_TTSTOP)) { 1001 SET(tp->t_state, TS_TTSTOP); | 426 return (0); 427 } 428 if (!CCEQ(cc[VSTART], c)) 429 return (0); 430 /* 431 * if VSTART == VSTOP then toggle 432 */ 433 goto endcase; --- 555 unchanged lines hidden (view full) --- 989 s = spltty(); 990 (*linesw[tp->t_line].l_rint)(*(u_char *)data, tp); 991 splx(s); 992 break; 993 case TIOCSTOP: /* stop output, like ^S */ 994 s = spltty(); 995 if (!ISSET(tp->t_state, TS_TTSTOP)) { 996 SET(tp->t_state, TS_TTSTOP); |
1002#ifdef sun4c /* XXX */ | |
1003 (*tp->t_stop)(tp, 0); | 997 (*tp->t_stop)(tp, 0); |
1004#else 1005 (*devsw(tp->t_dev)->d_stop)(tp, 0); 1006#endif | |
1007 } 1008 splx(s); 1009 break; 1010 case TIOCSCTTY: /* become controlling tty */ 1011 /* Session ctty vnode pointer set in vnode layer. */ 1012 if (!SESS_LEADER(p) || 1013 ((p->p_session->s_ttyvp || tp->t_session) && 1014 (tp->t_session != p->p_session))) --- 42 unchanged lines hidden (view full) --- 1057#else 1058 return (ENOIOCTL); 1059#endif 1060 } 1061 return (0); 1062} 1063 1064int | 998 } 999 splx(s); 1000 break; 1001 case TIOCSCTTY: /* become controlling tty */ 1002 /* Session ctty vnode pointer set in vnode layer. */ 1003 if (!SESS_LEADER(p) || 1004 ((p->p_session->s_ttyvp || tp->t_session) && 1005 (tp->t_session != p->p_session))) --- 42 unchanged lines hidden (view full) --- 1048#else 1049 return (ENOIOCTL); 1050#endif 1051 } 1052 return (0); 1053} 1054 1055int |
1065ttypoll(tp, events, p) 1066 struct tty *tp; | 1056ttypoll(dev, events, p) 1057 dev_t dev; |
1067 int events; 1068 struct proc *p; 1069{ 1070 int s; 1071 int revents = 0; | 1058 int events; 1059 struct proc *p; 1060{ 1061 int s; 1062 int revents = 0; |
1063 struct tty *tp; |
|
1072 | 1064 |
1065 tp = dev->si_tty; |
|
1073 if (tp == NULL) /* XXX used to return ENXIO, but that means true! */ 1074 return ((events & (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM)) 1075 | POLLHUP); 1076 1077 s = spltty(); 1078 if (events & (POLLIN | POLLRDNORM)) { 1079 if (ttnread(tp) > 0 || ISSET(tp->t_state, TS_ZOMBIE)) 1080 revents |= events & (POLLIN | POLLRDNORM); --- 8 unchanged lines hidden (view full) --- 1089 else 1090 selrecord(p, &tp->t_wsel); 1091 } 1092 splx(s); 1093 return (revents); 1094} 1095 1096/* | 1066 if (tp == NULL) /* XXX used to return ENXIO, but that means true! */ 1067 return ((events & (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM)) 1068 | POLLHUP); 1069 1070 s = spltty(); 1071 if (events & (POLLIN | POLLRDNORM)) { 1072 if (ttnread(tp) > 0 || ISSET(tp->t_state, TS_ZOMBIE)) 1073 revents |= events & (POLLIN | POLLRDNORM); --- 8 unchanged lines hidden (view full) --- 1082 else 1083 selrecord(p, &tp->t_wsel); 1084 } 1085 splx(s); 1086 return (revents); 1087} 1088 1089/* |
1097 * This is a wrapper for compatibility with the select vector used by 1098 * cdevsw. It relies on a proper xxxdevtotty routine. 1099 */ 1100int 1101ttpoll(dev, events, p) 1102 dev_t dev; 1103 int events; 1104 struct proc *p; 1105{ 1106 return ttypoll((*devsw(dev)->d_devtotty)(dev), events, p); 1107} 1108 1109/* | |
1110 * Must be called at spltty(). 1111 */ 1112static int 1113ttnread(tp) 1114 struct tty *tp; 1115{ 1116 int nread; 1117 --- 69 unchanged lines hidden (view full) --- 1187 s = spltty(); 1188#if 0 1189again: 1190#endif 1191 if (rw & FWRITE) { 1192 FLUSHQ(&tp->t_outq); 1193 CLR(tp->t_state, TS_TTSTOP); 1194 } | 1090 * Must be called at spltty(). 1091 */ 1092static int 1093ttnread(tp) 1094 struct tty *tp; 1095{ 1096 int nread; 1097 --- 69 unchanged lines hidden (view full) --- 1167 s = spltty(); 1168#if 0 1169again: 1170#endif 1171 if (rw & FWRITE) { 1172 FLUSHQ(&tp->t_outq); 1173 CLR(tp->t_state, TS_TTSTOP); 1174 } |
1195#ifdef sun4c /* XXX */ | |
1196 (*tp->t_stop)(tp, rw); | 1175 (*tp->t_stop)(tp, rw); |
1197#else 1198 (*devsw(tp->t_dev)->d_stop)(tp, rw); 1199#endif | |
1200 if (rw & FREAD) { 1201 FLUSHQ(&tp->t_canq); 1202 FLUSHQ(&tp->t_rawq); 1203 CLR(tp->t_lflag, PENDIN); 1204 tp->t_rocount = 0; 1205 tp->t_rocol = 0; 1206 CLR(tp->t_state, TS_LOCAL); 1207 ttwakeup(tp); --- 164 unchanged lines hidden (view full) --- 1372 */ 1373 if (flag) { 1374 CLR(tp->t_state, TS_CAR_OFLOW); 1375 CLR(tp->t_state, TS_TTSTOP); 1376 ttstart(tp); 1377 } else if (!ISSET(tp->t_state, TS_CAR_OFLOW)) { 1378 SET(tp->t_state, TS_CAR_OFLOW); 1379 SET(tp->t_state, TS_TTSTOP); | 1176 if (rw & FREAD) { 1177 FLUSHQ(&tp->t_canq); 1178 FLUSHQ(&tp->t_rawq); 1179 CLR(tp->t_lflag, PENDIN); 1180 tp->t_rocount = 0; 1181 tp->t_rocol = 0; 1182 CLR(tp->t_state, TS_LOCAL); 1183 ttwakeup(tp); --- 164 unchanged lines hidden (view full) --- 1348 */ 1349 if (flag) { 1350 CLR(tp->t_state, TS_CAR_OFLOW); 1351 CLR(tp->t_state, TS_TTSTOP); 1352 ttstart(tp); 1353 } else if (!ISSET(tp->t_state, TS_CAR_OFLOW)) { 1354 SET(tp->t_state, TS_CAR_OFLOW); 1355 SET(tp->t_state, TS_TTSTOP); |
1380#ifdef sun4c /* XXX */ | |
1381 (*tp->t_stop)(tp, 0); | 1356 (*tp->t_stop)(tp, 0); |
1382#else 1383 (*devsw(tp->t_dev)->d_stop)(tp, 0); 1384#endif | |
1385 } 1386 } else if (flag == 0) { 1387 /* 1388 * Lost carrier. 1389 */ 1390 CLR(tp->t_state, TS_CARR_ON); 1391 if (ISSET(tp->t_state, TS_ISOPEN) && 1392 !ISSET(tp->t_cflag, CLOCAL)) { --- 1072 unchanged lines hidden --- | 1357 } 1358 } else if (flag == 0) { 1359 /* 1360 * Lost carrier. 1361 */ 1362 CLR(tp->t_state, TS_CARR_ON); 1363 if (ISSET(tp->t_state, TS_ISOPEN) && 1364 !ISSET(tp->t_cflag, CLOCAL)) { --- 1072 unchanged lines hidden --- |