Subject: question about ttysleep
To: None <current-users@NetBSD.ORG>
From: Robert Dobbs <>
List: current-users
Date: 02/07/1995 13:41:21
I'm working on a serial port driver and have hit a snag.  My device
opens up with tip, and accept keystrokes, passing them on through the
board to the modem.  However nothing echos back, and the call to
 ret = (*linesw[tp->t_line].l_read)(tp, uio, flag);
blocks in ttysleep in this segment from tty.c:

                 * If there is no input, sleep on rawq
                 * awaiting hardware receipt and notification.
                 * If we have data, we don't need to check for carrier.
                carrier = ISSET(tp->t_state, TS_CARR_ON) ||
                    ISSET(tp->t_cflag, CLOCAL);
                if (!carrier && ISSET(tp->t_state, TS_ISOPEN)) {
                        return (0);     /* EOF */
                if (flag & IO_NDELAY) {
                        return (EWOULDBLOCK);
                error = ttysleep(tp, &tp->t_rawq, TTIPRI | PCATCH,
                    carrier ? ttyin : ttopen, slp);
if (error == -1)
        printf("Xerror(ttysleep2) ERESTART\n");
                if (error && error != EWOULDBLOCK)
                        return (error);

This call returns only when tip is exitted, returning ERESTART.

The way I see this is that the tty is not able to read any characters
because the device is not passing them to the tty via the intr routine.

	  ^		  ^
	  |		  |
	Intr		  |
          |		tp->t_oproc
	  |		  ^
	  |		  |

Therefore once my intr routine is being called, the Intr routine will 
pass data from the RxFIFO into the tty device via:
(*linesw[tp->t_line].l_rint)(*(cp + n), tp);

Is this a reasonable synopsis?