Lines Matching +full:wake +full:- +full:up
14 * PTY - Stream "pseudo-tty" device.
54 extern int npty; /* number of pseudo-ttys configured in */
125 static dev_info_t *ptsl_dip; /* for dev-to-dip conversions */
189 return (-1); in ptsl_attach()
245 mutex_enter(&pty->ptc_lock); in ptslopen()
247 * Block waiting for controller to open, unless this is a no-delay in ptslopen()
251 if (pty->pt_ttycommon.t_writeq == NULL) { in ptslopen()
252 pty->pt_ttycommon.t_iflag = 0; in ptslopen()
253 pty->pt_ttycommon.t_cflag = (B38400 << IBSHIFT)|B38400|IFLAGS; in ptslopen()
254 pty->pt_ttycommon.t_iocpending = NULL; in ptslopen()
255 pty->pt_wbufcid = 0; in ptslopen()
256 pty->pt_ttycommon.t_size.ws_row = 0; in ptslopen()
257 pty->pt_ttycommon.t_size.ws_col = 0; in ptslopen()
258 pty->pt_ttycommon.t_size.ws_xpixel = 0; in ptslopen()
259 pty->pt_ttycommon.t_size.ws_ypixel = 0; in ptslopen()
260 } else if ((pty->pt_ttycommon.t_flags & TS_XCLUDE) && in ptslopen()
262 mutex_exit(&pty->ptc_lock); in ptslopen()
266 !(pty->pt_ttycommon.t_cflag & CLOCAL)) { in ptslopen()
267 if (!(pty->pt_flags & PF_CARR_ON)) { in ptslopen()
268 pty->pt_flags |= PF_WOPEN; in ptslopen()
269 if (!cv_wait_sig(&pty->pt_cv_flags, &pty->ptc_lock)) { in ptslopen()
270 pty->pt_flags &= ~PF_WOPEN; in ptslopen()
271 mutex_exit(&pty->ptc_lock); in ptslopen()
278 pty->pt_sdev = dev; in ptslopen()
279 q->q_ptr = WR(q)->q_ptr = pty; in ptslopen()
280 pty->pt_flags &= ~PF_SUBSIDGONE; in ptslopen()
281 pty->pt_ttycommon.t_readq = pty->pt_ttycommon.t_writeq = NULL; in ptslopen()
289 mutex_exit(&pty->ptc_lock); in ptslopen()
297 mutex_enter(&pty->ptc_lock); in ptslopen()
302 pty->pt_vnode = strq2vp(q); in ptslopen()
303 VN_RELE(pty->pt_vnode); in ptslopen()
304 pty->pt_ttycommon.t_readq = q; in ptslopen()
305 pty->pt_ttycommon.t_writeq = WR(q); in ptslopen()
307 if (pty->pt_flags & PF_CARR_ON) in ptslopen()
308 cv_broadcast(&pty->pt_cv_readq); in ptslopen()
309 mutex_exit(&pty->ptc_lock); in ptslopen()
325 if ((pty = (struct pty *)q->q_ptr) == NULL) in ptslclose()
334 mutex_enter(&pty->ptc_lock); in ptslclose()
335 pty->pt_ttycommon.t_readq = NULL; in ptslclose()
336 pty->pt_ttycommon.t_writeq = NULL; in ptslclose()
337 while (pty->pt_flags & PF_IOCTL) { in ptslclose()
338 pty->pt_flags |= PF_WAIT; in ptslclose()
339 cv_wait(&pty->pt_cv_flags, &pty->ptc_lock); in ptslclose()
341 pty->pt_vnode = NULL; in ptslclose()
342 mutex_exit(&pty->ptc_lock); in ptslclose()
346 mutex_enter(&pty->ptc_lock); in ptslclose()
351 ttycommon_close(&pty->pt_ttycommon); in ptslclose()
356 if (pty->pt_wbufcid) { in ptslclose()
357 pt_wbufcid = pty->pt_wbufcid; in ptslclose()
358 pty->pt_wbufcid = 0; in ptslclose()
362 * Clear out all the subsidiary-side state. in ptslclose()
364 pty->pt_flags &= ~(PF_WOPEN|PF_STOPPED|PF_NOSTOP); in ptslclose()
365 if (pty->pt_flags & PF_CARR_ON) { in ptslclose()
366 pty->pt_flags |= PF_SUBSIDGONE; /* let the controller know */ in ptslclose()
367 ptcpollwakeup(pty, 0); /* wake up readers/selectors */ in ptslclose()
368 ptcpollwakeup(pty, FWRITE); /* wake up writers/selectors */ in ptslclose()
369 cv_broadcast(&pty->pt_cv_flags); in ptslclose()
371 pty->pt_sdev = 0; in ptslclose()
372 q->q_ptr = WR(q)->q_ptr = NULL; in ptslclose()
373 mutex_exit(&pty->ptc_lock); in ptslclose()
384 * queue up M_DATA messages for processing by the controller "read"
393 pty = (struct pty *)q->q_ptr; in ptslwput()
395 mutex_enter(&pty->ptc_lock); in ptslwput()
397 switch (mp->b_datap->db_type) { in ptslwput()
400 if (!(pty->pt_flags & PF_STOPPED)) { in ptslwput()
401 pty->pt_flags |= PF_STOPPED; in ptslwput()
402 pty->pt_send |= TIOCPKT_STOP; in ptslwput()
409 if (pty->pt_flags & PF_STOPPED) { in ptslwput()
410 pty->pt_flags &= ~PF_STOPPED; in ptslwput()
411 pty->pt_send = TIOCPKT_START; in ptslwput()
423 if (*mp->b_rptr & FLUSHW) { in ptslwput()
429 if (!(pty->pt_send & TIOCPKT_FLUSHWRITE)) { in ptslwput()
430 pty->pt_send |= TIOCPKT_FLUSHWRITE; in ptslwput()
437 *mp->b_rptr &= ~FLUSHW; /* it has been flushed */ in ptslwput()
439 if (*mp->b_rptr & FLUSHR) { in ptslwput()
445 if (!(pty->pt_send & TIOCPKT_FLUSHREAD)) { in ptslwput()
446 pty->pt_send |= TIOCPKT_FLUSHREAD; in ptslwput()
450 mutex_exit(&pty->ptc_lock); in ptslwput()
459 * Throw away any leading zero-length blocks, and queue it up in ptslwput()
462 if (pty->pt_flags & PF_CARR_ON) { in ptslwput()
464 while ((bp->b_wptr - bp->b_rptr) == 0) { in ptslwput()
465 mp = bp->b_cont; in ptslwput()
468 mutex_exit(&pty->ptc_lock); in ptslwput()
481 if ((*(int *)mp->b_rptr) == MC_CANONQUERY) { in ptslwput()
484 * or not. Send a reply back up indicating whether in ptslwput()
488 (pty->pt_flags & PF_REMOTE) ? in ptslwput()
502 mutex_exit(&pty->ptc_lock); in ptslwput()
517 mutex_enter(&pty->ptc_lock); in ptslreioctl()
521 if (pty->pt_wbufcid == 0) { in ptslreioctl()
522 mutex_exit(&pty->ptc_lock); in ptslreioctl()
526 pty->pt_wbufcid = 0; in ptslreioctl()
527 if ((q = pty->pt_ttycommon.t_writeq) == NULL) { in ptslreioctl()
528 mutex_exit(&pty->ptc_lock); in ptslreioctl()
531 if ((mp = pty->pt_ttycommon.t_iocpending) != NULL) { in ptslreioctl()
533 pty->pt_ttycommon.t_iocpending = NULL; in ptslreioctl()
536 mutex_exit(&pty->ptc_lock); in ptslreioctl()
551 ASSERT(MUTEX_HELD(&pty->ptc_lock)); in ptslioctl()
553 iocp = (struct iocblk *)mp->b_rptr; in ptslioctl()
554 cmd = iocp->ioc_cmd; in ptslioctl()
574 *bp->b_wptr++ = *mp->b_cont->b_rptr; in ptslioctl()
575 if (!(pty->pt_flags & PF_REMOTE)) { in ptslioctl()
576 if (!canput(pty->pt_ttycommon.t_readq)) { in ptslioctl()
577 mutex_exit(&pty->ptc_lock); in ptslioctl()
578 ttycommon_qfull(&pty->pt_ttycommon, q); in ptslioctl()
579 mutex_enter(&pty->ptc_lock); in ptslioctl()
585 pty->pt_ttycommon.t_readq, bp); in ptslioctl()
587 if (pty->pt_flags & PF_UCNTL) { in ptslioctl()
589 * XXX - flow control; don't overflow in ptslioctl()
592 if (pty->pt_stuffqfirst != NULL) { in ptslioctl()
593 pty->pt_stuffqlast->b_next = bp; in ptslioctl()
594 bp->b_prev = pty->pt_stuffqlast; in ptslioctl()
596 pty->pt_stuffqfirst = bp; in ptslioctl()
597 bp->b_prev = NULL; in ptslioctl()
599 bp->b_next = NULL; in ptslioctl()
600 pty->pt_stuffqlast = bp; in ptslioctl()
601 pty->pt_stuffqlen++; in ptslioctl()
613 iocp->ioc_count = 0; /* no data returned */ in ptslioctl()
614 mp->b_datap->db_type = M_IOCACK; in ptslioctl()
619 tty_common_t *tc = &pty->pt_ttycommon; in ptslioctl()
629 tp = (struct ttysize *)mp->b_cont->b_rptr; in ptslioctl()
630 tc->t_size.ws_row = tp->ts_lines; in ptslioctl()
631 tc->t_size.ws_col = tp->ts_cols; in ptslioctl()
632 tc->t_size.ws_xpixel = 0; in ptslioctl()
633 tc->t_size.ws_ypixel = 0; in ptslioctl()
638 iocp->ioc_count = 0; /* no data returned */ in ptslioctl()
639 mp->b_datap->db_type = M_IOCACK; in ptslioctl()
644 tty_common_t *tc = &pty->pt_ttycommon; in ptslioctl()
650 if (pty->pt_wbufcid) { in ptslioctl()
651 if (pty->pt_ttycommon.t_iocpending) in ptslioctl()
652 freemsg(pty->pt_ttycommon.t_iocpending); in ptslioctl()
653 pty->pt_ttycommon.t_iocpending = mp; in ptslioctl()
656 pty->pt_wbufcid = bufcall(sizeof (struct ttysize), in ptslioctl()
658 if (pty->pt_wbufcid == 0) { in ptslioctl()
662 pty->pt_ttycommon.t_iocpending = mp; in ptslioctl()
668 tp = (struct ttysize *)datap->b_wptr; in ptslioctl()
669 tp->ts_lines = tc->t_size.ws_row; in ptslioctl()
670 tp->ts_cols = tc->t_size.ws_col; in ptslioctl()
671 datap->b_wptr += sizeof (struct ttysize); in ptslioctl()
672 iocp->ioc_count = sizeof (struct ttysize); in ptslioctl()
674 if (mp->b_cont != NULL) in ptslioctl()
675 freemsg(mp->b_cont); in ptslioctl()
676 mp->b_cont = datap; in ptslioctl()
677 mp->b_datap->db_type = M_IOCACK; in ptslioctl()
686 tty_common_t *tc = &pty->pt_ttycommon; in ptslioctl()
693 cb = (struct termios *)mp->b_cont->b_rptr; in ptslioctl()
696 mutex_exit(&pty->ptc_lock); in ptslioctl()
698 mutex_enter(&pty->ptc_lock); in ptslioctl()
699 mutex_enter(&tc->t_excl); in ptslioctl()
700 tc->t_iflag = cb->c_iflag; in ptslioctl()
701 tc->t_cflag = cb->c_cflag; in ptslioctl()
702 tc->t_stopc = cb->c_cc[VSTOP]; in ptslioctl()
703 tc->t_startc = cb->c_cc[VSTART]; in ptslioctl()
704 mutex_exit(&tc->t_excl); in ptslioctl()
709 iocp->ioc_count = 0; /* no data returned */ in ptslioctl()
710 mp->b_datap->db_type = M_IOCACK; in ptslioctl()
715 tty_common_t *tc = &pty->pt_ttycommon; in ptslioctl()
722 cb = (struct termios *)mp->b_cont->b_rptr; in ptslioctl()
725 mutex_exit(&pty->ptc_lock); in ptslioctl()
727 mutex_enter(&pty->ptc_lock); in ptslioctl()
728 mutex_enter(&tc->t_excl); in ptslioctl()
729 tc->t_iflag = (tc->t_iflag & 0xffff0000 | cb->c_iflag); in ptslioctl()
730 tc->t_cflag = (tc->t_cflag & 0xffff0000 | cb->c_cflag); in ptslioctl()
731 mutex_exit(&tc->t_excl); in ptslioctl()
736 iocp->ioc_count = 0; /* no data returned */ in ptslioctl()
737 mp->b_datap->db_type = M_IOCACK; in ptslioctl()
742 tty_common_t *tc = &pty->pt_ttycommon; in ptslioctl()
749 ws = (struct winsize *)mp->b_cont->b_rptr; in ptslioctl()
753 mutex_enter(&tc->t_excl); in ptslioctl()
754 if (bcmp(&tc->t_size, ws, sizeof (struct winsize))) { in ptslioctl()
755 tc->t_size = *ws; in ptslioctl()
756 mutex_exit(&tc->t_excl); in ptslioctl()
757 mutex_exit(&pty->ptc_lock); in ptslioctl()
759 mutex_enter(&pty->ptc_lock); in ptslioctl()
761 mutex_exit(&tc->t_excl); in ptslioctl()
766 iocp->ioc_count = 0; /* no data returned */ in ptslioctl()
767 mp->b_datap->db_type = M_IOCACK; in ptslioctl()
780 if (*(int *)mp->b_cont->b_rptr != 0) { in ptslioctl()
784 iocp->ioc_count = 0; /* no data returned */ in ptslioctl()
785 mp->b_datap->db_type = M_IOCACK; in ptslioctl()
797 * do any state-changes the "ioctl" calls for. If we couldn't allocate in ptslioctl()
803 ttycommon_ioctl(&pty->pt_ttycommon, q, mp, &error)) != 0) { in ptslioctl()
804 if (pty->pt_wbufcid) { in ptslioctl()
805 if (pty->pt_ttycommon.t_iocpending) in ptslioctl()
806 freemsg(pty->pt_ttycommon.t_iocpending); in ptslioctl()
807 pty->pt_ttycommon.t_iocpending = mp; in ptslioctl()
810 pty->pt_wbufcid = bufcall(datasize, BPRI_HI, ptslreioctl, pty); in ptslioctl()
811 if (pty->pt_wbufcid == 0) { in ptslioctl()
815 pty->pt_ttycommon.t_iocpending = mp; in ptslioctl()
823 * data it set up. in ptslioctl()
834 if (!(pty->pt_send & TIOCPKT_FLUSHREAD)) { in ptslioctl()
835 pty->pt_send |= TIOCPKT_FLUSHREAD; in ptslioctl()
854 if (pty->pt_flags & PF_43UCNTL) { in ptslioctl()
858 pty->pt_ucntl = (uchar_t)cmd & 0xff; in ptslioctl()
867 if ((pty->pt_flags & PF_UCNTL) && in ptslioctl()
870 pty->pt_ucntl = (uchar_t)cmd & 0xff; in ptslioctl()
880 ((struct iocblk *)mp->b_rptr)->ioc_error = error; in ptslioctl()
881 mp->b_datap->db_type = M_IOCNAK; in ptslioctl()
884 mutex_exit(&pty->ptc_lock); in ptslioctl()
886 mutex_enter(&pty->ptc_lock); in ptslioctl()
891 * Just wakes the controller side up so it can write some more data
897 struct pty *pty = (struct pty *)q->q_ptr; in ptslrserv()
901 * Build up the link list of messages, then drop in ptslrserv()
904 mutex_enter(&pty->ptc_lock); in ptslrserv()
907 if ((mp->b_datap->db_type < QPCTL) && !canputnext(q)) { in ptslrserv()
915 tail->b_next = mp; in ptslrserv()
920 if (q->q_count <= q->q_lowat) in ptslrserv()
921 ptcpollwakeup((struct pty *)q->q_ptr, FWRITE); in ptslrserv()
923 mutex_exit(&pty->ptc_lock); in ptslrserv()
927 head = mp->b_next; in ptslrserv()
928 mp->b_next = NULL; in ptslrserv()
940 ASSERT(MUTEX_HELD(&pty->ptc_lock)); in pt_sendstop()
942 if ((pty->pt_ttycommon.t_cflag&CBAUD) == 0) { in pt_sendstop()
943 if (pty->pt_flags & PF_CARR_ON) { in pt_sendstop()
945 * Let the manager know, then wake up in pt_sendstop()
948 pty->pt_flags |= PF_SUBSIDGONE; in pt_sendstop()
954 stop = (pty->pt_ttycommon.t_iflag & IXON) && in pt_sendstop()
955 pty->pt_ttycommon.t_stopc == CTRL('s') && in pt_sendstop()
956 pty->pt_ttycommon.t_startc == CTRL('q'); in pt_sendstop()
958 if (pty->pt_flags & PF_NOSTOP) { in pt_sendstop()
960 pty->pt_send &= ~TIOCPKT_NOSTOP; in pt_sendstop()
961 pty->pt_send |= TIOCPKT_DOSTOP; in pt_sendstop()
962 pty->pt_flags &= ~PF_NOSTOP; in pt_sendstop()
967 pty->pt_send &= ~TIOCPKT_DOSTOP; in pt_sendstop()
968 pty->pt_send |= TIOCPKT_NOSTOP; in pt_sendstop()
969 pty->pt_flags |= PF_NOSTOP; in pt_sendstop()
976 * Wake up controller side. "flag" is 0 if a special packet or
977 * user control mode message has been queued up (this data is readable,
979 * though?), FREAD if regular data has been queued up, or FWRITE if
985 ASSERT(MUTEX_HELD(&pty->ptc_lock)); in ptcpollwakeup()
994 if (pty->pt_flags & PF_ASYNC) in ptcpollwakeup()
995 gsignal(pty->pt_pgrp, SIGURG); in ptcpollwakeup()
999 * Wake up the parent process as there is regular in ptcpollwakeup()
1003 cv_broadcast(&pty->pt_cv_writeq); in ptcpollwakeup()
1004 if (pty->pt_flags & PF_ASYNC) in ptcpollwakeup()
1005 gsignal(pty->pt_pgrp, SIGIO); in ptcpollwakeup()
1009 * Wake up the parent process to write in ptcpollwakeup()
1014 cv_broadcast(&pty->pt_cv_readq); in ptcpollwakeup()
1015 if (pty->pt_flags & PF_ASYNC) in ptcpollwakeup()
1016 gsignal(pty->pt_pgrp, SIGIO); in ptcpollwakeup()