Lines Matching refs:tp
88 typedef void d_stop_t(struct tty *tp, int rw);
96 static void ptsstart(struct tty *tp);
97 static void ptcwakeup(struct tty *tp, int flag);
180 struct tty *tp;
185 * the ttymalloc and the tp indirection.
196 if ((tp = pt_tty[minor(dev)] = ttymalloc()) == NULL) {
201 tp = pt_tty[minor(dev)];
203 tty_lock(tp);
205 if ((tp->t_state & TS_ISOPEN) == 0) {
206 termioschars(&tp->t_termios); /* Set up default chars */
207 tp->t_iflag = TTYDEF_IFLAG;
208 tp->t_oflag = TTYDEF_OFLAG;
209 tp->t_lflag = TTYDEF_LFLAG;
210 tp->t_cflag = TTYDEF_CFLAG;
211 tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED;
212 ttsetwater(tp); /* would be done in xxparam() */
213 } else if (tp->t_state&TS_XCLUDE && suser(kauth_cred_get(), NULL)) {
217 if (tp->t_oproc) /* Ctrlr still around. */
218 (void)(*linesw[tp->t_line].l_modem)(tp, 1);
219 while ((tp->t_state & TS_CARR_ON) == 0) {
222 error = ttysleep(tp, TSA_CARR_ON(tp), TTIPRI | PCATCH,
227 error = (*linesw[tp->t_line].l_open)(dev, tp);
229 ptcwakeup(tp, FREAD|FWRITE);
232 tty_unlock(tp);
240 struct tty *tp;
253 tp = pt_tty[minor(dev)];
254 tty_lock(tp);
256 save_timeout = tp->t_timeout;
257 tp->t_timeout = 60;
259 err = (*linesw[tp->t_line].l_close)(tp, flag);
260 ptsstop(tp, FREAD|FWRITE);
261 (void) ttyclose(tp);
263 tp->t_timeout = save_timeout;
265 tty_unlock(tp);
273 struct tty *tp = pt_tty[minor(dev)];
279 tty_lock(tp);
284 while (isbackground(p, tp)) {
302 tty_unlock(tp);
305 tty_lock(tp);
311 tty_lock(tp);
313 error = ttysleep(tp, &lbolt, TTIPRI | PCATCH | PTTYBLOCK, "ptsbg",
318 if (tp->t_canq.c_cc == 0) {
323 error = ttysleep(tp, TSA_PTS_READ(tp), TTIPRI | PCATCH,
329 while (tp->t_canq.c_cc > 1 && uio_resid(uio) > 0) {
335 cc = min(cc, tp->t_canq.c_cc - 1);
336 cc = q_to_b(&tp->t_canq, (u_char *)buf, cc);
341 if (tp->t_canq.c_cc == 1)
342 (void) getc(&tp->t_canq);
343 if (tp->t_canq.c_cc)
346 if (tp->t_oproc)
347 error = (*linesw[tp->t_line].l_read)(tp, uio, flag);
348 ptcwakeup(tp, FWRITE);
350 tty_unlock(tp);
362 struct tty *tp;
365 tp = pt_tty[minor(dev)];
367 tty_lock(tp);
369 if (tp->t_oproc == 0)
372 error = (*linesw[tp->t_line].l_write)(tp, uio, flag);
374 tty_unlock(tp);
385 * Locks: Assumes tp is locked on entry, remains locked on exit
388 ptsstart(struct tty *tp)
390 struct pt_ioctl *pti = &pt_ioctl[minor(tp->t_dev)];
392 if (tp->t_state & TS_TTSTOP)
398 ptcwakeup(tp, FREAD);
407 ptcwakeup(struct tty *tp, int flag)
409 struct pt_ioctl *pti = &pt_ioctl[minor(tp->t_dev)];
413 wakeup(TSA_PTC_READ(tp));
417 wakeup(TSA_PTC_WRITE(tp));
424 struct tty *tp;
433 tp = pt_tty[minor(dev)] = ttymalloc();
435 tp = pt_tty[minor(dev)];
437 tty_lock(tp);
440 if (tp->t_oproc || (tp->t_state & TS_ISOPEN)) {
443 tp->t_oproc = ptsstart;
444 CLR(tp->t_state, TS_ZOMBIE);
446 tp->t_stop = ptsstop;
448 (void)(*linesw[tp->t_line].l_modem)(tp, 1);
449 tp->t_lflag &= ~EXTPROC;
456 tty_unlock(tp);
465 struct tty *tp = pt_tty[minor(dev)];
467 tty_lock(tp);
469 (void)(*linesw[tp->t_line].l_modem)(tp, 0);
479 if (tp->t_state & TS_ISOPEN) {
480 tp->t_state &= ~(TS_CARR_ON | TS_CONNECTED);
481 tp->t_state |= TS_ZOMBIE;
482 ttyflush(tp, FREAD | FWRITE);
485 tp->t_oproc = 0; /* mark closed */
487 tty_unlock(tp);
495 struct tty *tp = pt_tty[minor(dev)];
500 tty_lock(tp);
509 if (tp->t_state&TS_ISOPEN) {
516 sizeof(tp->t_termios));
517 uiomove((caddr_t)&tp->t_termios, cc,
530 if (tp->t_outq.c_cc && (tp->t_state&TS_TTSTOP) == 0)
533 if ((tp->t_state & TS_CONNECTED) == 0)
539 error = ttysleep(tp, TSA_PTC_READ(tp), TTIPRI | PCATCH, "ptcin", 0);
546 cc = q_to_b(&tp->t_outq, (u_char *)buf, min(uio_resid(uio), BUFSIZ));
551 (*linesw[tp->t_line].l_start)(tp);
554 tty_unlock(tp);
565 ptsstop(struct tty *tp, int flush)
570 pti = &pt_ioctl[minor(tp->t_dev)];
585 ptcwakeup(tp, flag);
591 struct tty *tp = pt_tty[minor(dev)];
595 tty_lock(tp);
597 if ((tp->t_state & TS_CONNECTED) == 0) {
607 if ((tp->t_state&TS_ISOPEN) &&
608 tp->t_outq.c_cc && (tp->t_state&TS_TTSTOP) == 0) {
615 if ((tp->t_state&TS_ISOPEN) &&
626 if (tp->t_state&TS_ISOPEN) {
628 if (tp->t_canq.c_cc == 0) {
633 if (tp->t_rawq.c_cc + tp->t_canq.c_cc < TTYHOG-2) {
637 if (tp->t_canq.c_cc == 0 && (tp->t_lflag&ICANON)) {
648 tty_unlock(tp);
656 struct tty *tp = pt_tty[minor(dev)];
664 tty_lock(tp);
667 if ((tp->t_state&TS_ISOPEN) == 0)
670 if (tp->t_canq.c_cc)
673 tp->t_canq.c_cc < TTYHOG - 1) {
676 cc = min(cc, TTYHOG - 1 - tp->t_canq.c_cc);
682 if ((tp->t_state & TS_ISOPEN) == 0) {
690 cc = b_to_q((u_char *)cp, cc, &tp->t_canq);
705 (void) putc(0, &tp->t_canq);
706 ttwakeup(tp);
707 wakeup(TSA_PTS_READ(tp));
718 if ((tp->t_state & TS_ISOPEN) == 0) {
726 if ((tp->t_rawq.c_cc + tp->t_canq.c_cc) >= TTYHOG - 2 &&
727 (tp->t_canq.c_cc > 0 || !(tp->t_lflag&ICANON))) {
728 wakeup(TSA_HUP_OR_INPUT(tp));
731 (*linesw[tp->t_line].l_rint)(*cp++, tp);
738 tty_unlock(tp);
747 if ((tp->t_state & TS_CONNECTED) == 0) {
760 error = ttysleep(tp, TSA_PTC_WRITE(tp), TTOPRI | PCATCH, "ptcout", 0);
772 struct tty *tp = pt_tty[minor(dev)];
774 u_char *cc = tp->t_cc;
777 tty_lock(tp);
781 * ttywflush(tp) will hang if there are characters in the outq.
792 ptcwakeup(tp, FREAD);
794 tp->t_lflag |= EXTPROC;
796 if ((tp->t_lflag & EXTPROC) &&
799 ptcwakeup(tp, FREAD);
801 tp->t_lflag &= ~EXTPROC;
811 * in that case, tp must be the controlling terminal.
813 *(int *)data = tp->t_pgrp ? tp->t_pgrp->pg_id : 0;
843 ttyflush(tp, FREAD|FWRITE);
855 ndflush(&tp->t_outq, tp->t_outq.c_cc);
864 if ((tp->t_lflag&NOFLSH) == 0)
865 ttyflush(tp, FREAD|FWRITE);
867 ((tp->t_lflag&NOKERNINFO) == 0))
868 ttyinfo_locked(tp);
875 tty_unlock(tp);
876 tty_pgsignal(tp, *(unsigned int *)data, 1);
877 tty_lock(tp);
910 error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p);
912 error = ttioctl_locked(tp, cmd, data, flag, p);
918 ptcwakeup(tp, FREAD);
940 if ((tp->t_lflag&EXTPROC) && (pti->pt_flags & PF_PKT)) {
956 ptcwakeup(tp, FREAD);
961 stop = (tp->t_iflag & IXON) && CCEQ(cc[VSTOP], CTRL('s'))
968 ptcwakeup(tp, FREAD);
975 ptcwakeup(tp, FREAD);
979 tty_unlock(tp);