Lines Matching defs:pty

55 extern struct pty *pty_softc;
118 static void ptslioctl(struct pty *, queue_t *, mblk_t *);
119 static void pt_sendstop(struct pty *);
120 static void ptcpollwakeup(struct pty *, int);
229 * Open the slave side of a pty.
237 struct pty *pty;
243 pty = &pty_softc[unit];
245 mutex_enter(&pty->ptc_lock);
251 if (pty->pt_ttycommon.t_writeq == NULL) {
252 pty->pt_ttycommon.t_iflag = 0;
253 pty->pt_ttycommon.t_cflag = (B38400 << IBSHIFT)|B38400|IFLAGS;
254 pty->pt_ttycommon.t_iocpending = NULL;
255 pty->pt_wbufcid = 0;
256 pty->pt_ttycommon.t_size.ws_row = 0;
257 pty->pt_ttycommon.t_size.ws_col = 0;
258 pty->pt_ttycommon.t_size.ws_xpixel = 0;
259 pty->pt_ttycommon.t_size.ws_ypixel = 0;
260 } else if ((pty->pt_ttycommon.t_flags & TS_XCLUDE) &&
262 mutex_exit(&pty->ptc_lock);
266 !(pty->pt_ttycommon.t_cflag & CLOCAL)) {
267 if (!(pty->pt_flags & PF_CARR_ON)) {
268 pty->pt_flags |= PF_WOPEN;
269 if (!cv_wait_sig(&pty->pt_cv_flags, &pty->ptc_lock)) {
270 pty->pt_flags &= ~PF_WOPEN;
271 mutex_exit(&pty->ptc_lock);
278 pty->pt_sdev = dev;
279 q->q_ptr = WR(q)->q_ptr = pty;
280 pty->pt_flags &= ~PF_SLAVEGONE;
281 pty->pt_ttycommon.t_readq = pty->pt_ttycommon.t_writeq = NULL;
289 mutex_exit(&pty->ptc_lock);
297 mutex_enter(&pty->ptc_lock);
302 pty->pt_vnode = strq2vp(q);
303 VN_RELE(pty->pt_vnode);
304 pty->pt_ttycommon.t_readq = q;
305 pty->pt_ttycommon.t_writeq = WR(q);
307 if (pty->pt_flags & PF_CARR_ON)
308 cv_broadcast(&pty->pt_cv_readq);
309 mutex_exit(&pty->ptc_lock);
317 struct pty *pty;
325 if ((pty = (struct pty *)q->q_ptr) == NULL)
334 mutex_enter(&pty->ptc_lock);
335 pty->pt_ttycommon.t_readq = NULL;
336 pty->pt_ttycommon.t_writeq = NULL;
337 while (pty->pt_flags & PF_IOCTL) {
338 pty->pt_flags |= PF_WAIT;
339 cv_wait(&pty->pt_cv_flags, &pty->ptc_lock);
341 pty->pt_vnode = NULL;
342 mutex_exit(&pty->ptc_lock);
346 mutex_enter(&pty->ptc_lock);
351 ttycommon_close(&pty->pt_ttycommon);
356 if (pty->pt_wbufcid) {
357 pt_wbufcid = pty->pt_wbufcid;
358 pty->pt_wbufcid = 0;
364 pty->pt_flags &= ~(PF_WOPEN|PF_STOPPED|PF_NOSTOP);
365 if (pty->pt_flags & PF_CARR_ON) {
366 pty->pt_flags |= PF_SLAVEGONE; /* let the controller know */
367 ptcpollwakeup(pty, 0); /* wake up readers/selectors */
368 ptcpollwakeup(pty, FWRITE); /* wake up writers/selectors */
369 cv_broadcast(&pty->pt_cv_flags);
371 pty->pt_sdev = 0;
373 mutex_exit(&pty->ptc_lock);
390 struct pty *pty;
393 pty = (struct pty *)q->q_ptr;
395 mutex_enter(&pty->ptc_lock);
400 if (!(pty->pt_flags & PF_STOPPED)) {
401 pty->pt_flags |= PF_STOPPED;
402 pty->pt_send |= TIOCPKT_STOP;
403 ptcpollwakeup(pty, 0);
409 if (pty->pt_flags & PF_STOPPED) {
410 pty->pt_flags &= ~PF_STOPPED;
411 pty->pt_send = TIOCPKT_START;
412 ptcpollwakeup(pty, 0);
414 ptcpollwakeup(pty, FREAD); /* permit controller to read */
419 ptslioctl(pty, q, mp);
429 if (!(pty->pt_send & TIOCPKT_FLUSHWRITE)) {
430 pty->pt_send |= TIOCPKT_FLUSHWRITE;
431 ptcpollwakeup(pty, 0);
445 if (!(pty->pt_send & TIOCPKT_FLUSHREAD)) {
446 pty->pt_send |= TIOCPKT_FLUSHREAD;
447 ptcpollwakeup(pty, 0);
450 mutex_exit(&pty->ptc_lock);
462 if (pty->pt_flags & PF_CARR_ON) {
468 mutex_exit(&pty->ptc_lock);
474 ptcpollwakeup(pty, FREAD); /* soup's on! */
487 (pty->pt_flags & PF_REMOTE) ?
501 mutex_exit(&pty->ptc_lock);
511 struct pty *pty = arg;
515 mutex_enter(&pty->ptc_lock);
519 if (pty->pt_wbufcid == 0) {
520 mutex_exit(&pty->ptc_lock);
524 pty->pt_wbufcid = 0;
525 if ((q = pty->pt_ttycommon.t_writeq) == NULL) {
526 mutex_exit(&pty->ptc_lock);
529 if ((mp = pty->pt_ttycommon.t_iocpending) != NULL) {
531 pty->pt_ttycommon.t_iocpending = NULL;
532 ptslioctl(pty, q, mp);
534 mutex_exit(&pty->ptc_lock);
539 * Drops pty's ptc_lock mutex and then reacquire
542 ptslioctl(struct pty *pty, queue_t *q, mblk_t *mp)
549 ASSERT(MUTEX_HELD(&pty->ptc_lock));
573 if (!(pty->pt_flags & PF_REMOTE)) {
574 if (!canput(pty->pt_ttycommon.t_readq)) {
575 mutex_exit(&pty->ptc_lock);
576 ttycommon_qfull(&pty->pt_ttycommon, q);
577 mutex_enter(&pty->ptc_lock);
583 pty->pt_ttycommon.t_readq, bp);
585 if (pty->pt_flags & PF_UCNTL) {
590 if (pty->pt_stuffqfirst != NULL) {
591 pty->pt_stuffqlast->b_next = bp;
592 bp->b_prev = pty->pt_stuffqlast;
594 pty->pt_stuffqfirst = bp;
598 pty->pt_stuffqlast = bp;
599 pty->pt_stuffqlen++;
600 ptcpollwakeup(pty, 0);
617 tty_common_t *tc = &pty->pt_ttycommon;
642 tty_common_t *tc = &pty->pt_ttycommon;
648 if (pty->pt_wbufcid) {
649 if (pty->pt_ttycommon.t_iocpending)
650 freemsg(pty->pt_ttycommon.t_iocpending);
651 pty->pt_ttycommon.t_iocpending = mp;
654 pty->pt_wbufcid = bufcall(sizeof (struct ttysize),
655 BPRI_HI, ptslreioctl, pty);
656 if (pty->pt_wbufcid == 0) {
660 pty->pt_ttycommon.t_iocpending = mp;
684 tty_common_t *tc = &pty->pt_ttycommon;
694 mutex_exit(&pty->ptc_lock);
696 mutex_enter(&pty->ptc_lock);
713 tty_common_t *tc = &pty->pt_ttycommon;
723 mutex_exit(&pty->ptc_lock);
725 mutex_enter(&pty->ptc_lock);
740 tty_common_t *tc = &pty->pt_ttycommon;
755 mutex_exit(&pty->ptc_lock);
757 mutex_enter(&pty->ptc_lock);
801 ttycommon_ioctl(&pty->pt_ttycommon, q, mp, &error)) != 0) {
802 if (pty->pt_wbufcid) {
803 if (pty->pt_ttycommon.t_iocpending)
804 freemsg(pty->pt_ttycommon.t_iocpending);
805 pty->pt_ttycommon.t_iocpending = mp;
808 pty->pt_wbufcid = bufcall(datasize, BPRI_HI, ptslreioctl, pty);
809 if (pty->pt_wbufcid == 0) {
813 pty->pt_ttycommon.t_iocpending = mp;
832 if (!(pty->pt_send & TIOCPKT_FLUSHREAD)) {
833 pty->pt_send |= TIOCPKT_FLUSHREAD;
834 ptcpollwakeup(pty, 0);
841 pt_sendstop(pty);
847 pt_sendstop(pty);
852 if (pty->pt_flags & PF_43UCNTL) {
856 pty->pt_ucntl = (uchar_t)cmd & 0xff;
857 ptcpollwakeup(pty, FREAD);
865 if ((pty->pt_flags & PF_UCNTL) &&
868 pty->pt_ucntl = (uchar_t)cmd & 0xff;
869 ptcpollwakeup(pty, FREAD);
882 mutex_exit(&pty->ptc_lock);
884 mutex_enter(&pty->ptc_lock);
895 struct pty *pty = (struct pty *)q->q_ptr;
902 mutex_enter(&pty->ptc_lock);
919 ptcpollwakeup((struct pty *)q->q_ptr, FWRITE);
921 mutex_exit(&pty->ptc_lock);
934 pt_sendstop(struct pty *pty)
938 ASSERT(MUTEX_HELD(&pty->ptc_lock));
940 if ((pty->pt_ttycommon.t_cflag&CBAUD) == 0) {
941 if (pty->pt_flags & PF_CARR_ON) {
946 pty->pt_flags |= PF_SLAVEGONE;
947 ptcpollwakeup(pty, 0);
948 ptcpollwakeup(pty, FWRITE);
952 stop = (pty->pt_ttycommon.t_iflag & IXON) &&
953 pty->pt_ttycommon.t_stopc == CTRL('s') &&
954 pty->pt_ttycommon.t_startc == CTRL('q');
956 if (pty->pt_flags & PF_NOSTOP) {
958 pty->pt_send &= ~TIOCPKT_NOSTOP;
959 pty->pt_send |= TIOCPKT_DOSTOP;
960 pty->pt_flags &= ~PF_NOSTOP;
961 ptcpollwakeup(pty, 0);
965 pty->pt_send &= ~TIOCPKT_DOSTOP;
966 pty->pt_send |= TIOCPKT_NOSTOP;
967 pty->pt_flags |= PF_NOSTOP;
968 ptcpollwakeup(pty, 0);
981 ptcpollwakeup(struct pty *pty, int flag)
983 ASSERT(MUTEX_HELD(&pty->ptc_lock));
992 if (pty->pt_flags & PF_ASYNC)
993 gsignal(pty->pt_pgrp, SIGURG);
1001 cv_broadcast(&pty->pt_cv_writeq);
1002 if (pty->pt_flags & PF_ASYNC)
1003 gsignal(pty->pt_pgrp, SIGIO);
1012 cv_broadcast(&pty->pt_cv_readq);
1013 if (pty->pt_flags & PF_ASYNC)
1014 gsignal(pty->pt_pgrp, SIGIO);