Subject: question about ttysleep
To: None <current-users@NetBSD.ORG>
From: Robert Dobbs <banshee@gabriella.resort.com>
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)) {
                        splx(s);
                        return (0);     /* EOF */
                }
                if (flag & IO_NDELAY) {
                        splx(s);
                        return (EWOULDBLOCK);
                }
                error = ttysleep(tp, &tp->t_rawq, TTIPRI | PCATCH,
                    carrier ? ttyin : ttopen, slp);
if (error == -1)
        printf("Xerror(ttysleep2) ERESTART\n");
                splx(s);
                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.

	RxFIFO		TxFIFO
	  ^		  ^
	  |		  |
	Intr		  |
          |		tp->t_oproc
	  |		  ^
	  |		  |
	  ---------------tty

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?

-j