Subject: Re: Hardware handshaking
To: None <amiga@netbsd.org, jag@world.std.com>
From: Niklas Hallqvist <niklas@appli.se>
List: amiga
Date: 10/20/1994 01:39:27
To: jag@world.std.com
CC: amiga@netbsd.org
In-reply-to: <199410191743.AA27567@world.std.com> (jag@world.std.com)
Subject: Re: Hardware handshaking

Try this:

diff -c NetBSD/sys/arch/amiga/dev/ser.c:1.1.1.9 NetBSD/sys/arch/amiga/dev/ser.c:1.1.1.1.2.15
*** NetBSD/sys/arch/amiga/dev/ser.c:1.1.1.9	Sat Sep 10 21:33:51 1994
--- NetBSD/sys/arch/amiga/dev/ser.c	Sat Sep 10 21:33:56 1994
***************
*** 34,40 ****
   *	$Id$
   */
  /*
!  * XXX This file needs major cleanup it will never ervice more than one
   * XXX unit.
   */
  
--- 34,40 ----
   *	$Id$
   */
  /*
!  * XXX This file needs major cleanup it will never service more than one
   * XXX unit.
   */
  
***************
*** 73,79 ****
  #define SEROBUF_SIZE 32
  #define SERIBUF_SIZE 512
  
! int	serstart(), serparam(), serintr();
  int	ser_active;
  int	ser_hasfifo;
  int	nser = NSER;
--- 73,79 ----
  #define SEROBUF_SIZE 32
  #define SERIBUF_SIZE 512
  
! int	serstart(), serparam(), serintr(), serhwiflow();
  int	ser_active;
  int	ser_hasfifo;
  int	nser = NSER;
***************
*** 245,250 ****
--- 245,251 ----
  	tp->t_oproc = (void (*) (struct tty *)) serstart;
  	tp->t_param = serparam;
  	tp->t_dev = dev;
+ 	tp->t_hwiflow = serhwiflow;
  
  	if ((tp->t_state & TS_ISOPEN) == 0) {
  		tp->t_state |= TS_WOPEN;
***************
*** 301,306 ****
--- 302,313 ----
  		}
  	}
  done:
+ 	/* This is a way to handle lost XON characters */
+ 	if ((flag & O_TRUNC) && (tp->t_state & TS_TTSTOP)) {
+ 		tp->t_state &= ~TS_TTSTOP;
+ 	        ttstart (tp);
+ 	}
+ 
  	splx(s);
  	/*
  	 * Reset the tty pointer, as there could have been a dialout
***************
*** 699,704 ****
--- 706,725 ----
  	return(0);
  }
  
+ int
+ serhwiflow(tp, flag)
+         struct tty *tp;
+         int flag;
+ {
+ #if 0
+ 	printf ("serhwiflow %d\n", flag);
+ #endif
+         if (flag)
+ 		CLRRTS(ciab.pra);
+ 	else
+ 	        SETRTS(ciab.pra);
+         return 1;
+ }
  
  static void
  ser_putchar(tp, c)
diff -c NetBSD/sys/kern/tty.c:1.1.1.12 NetBSD/sys/kern/tty.c:1.1.1.1.2.12
*** NetBSD/sys/kern/tty.c:1.1.1.12	Sun Sep 11 00:09:02 1994
--- NetBSD/sys/kern/tty.c	Sun Sep 11 00:09:10 1994
***************
*** 1044,1053 ****
  	 */
  	if (total >= TTYHOG / 2 &&
  	    !ISSET(tp->t_state, TS_TBLOCK) &&
! 	    !ISSET(tp->t_lflag, ICANON) || tp->t_canq.c_cc > 0 &&
! 	    tp->t_cc[VSTOP] != _POSIX_VDISABLE) {
! 		if (putc(tp->t_cc[VSTOP], &tp->t_outq) == 0) {
! 			SET(tp->t_state, TS_TBLOCK);
  			ttstart(tp);
  		}
  		/* try to block remote output via hardware flow control */
--- 1044,1053 ----
  	 */
  	if (total >= TTYHOG / 2 &&
  	    !ISSET(tp->t_state, TS_TBLOCK) &&
! 	    (!ISSET(tp->t_lflag, ICANON) || tp->t_canq.c_cc > 0)) {
! 		if (ISSET(tp->t_iflag, IXOFF) && tp->t_cc[VSTOP] != _POSIX_VDISABLE &&
! 		    putc(tp->t_cc[VSTOP], &tp->t_outq) == 0) {
! 	        	SET(tp->t_state, TS_TBLOCK);
  			ttstart(tp);
  		}
  		/* try to block remote output via hardware flow control */
***************
*** 1378,1384 ****
  	 */
  	s = spltty();
  	if (ISSET(tp->t_state, TS_TBLOCK) && tp->t_rawq.c_cc < TTYHOG/5) {
! 		if (cc[VSTART] != _POSIX_VDISABLE &&
  		    putc(cc[VSTART], &tp->t_outq) == 0) {
  			CLR(tp->t_state, TS_TBLOCK);
  			ttstart(tp);
--- 1378,1384 ----
  	 */
  	s = spltty();
  	if (ISSET(tp->t_state, TS_TBLOCK) && tp->t_rawq.c_cc < TTYHOG/5) {
! 		if (ISSET(tp->t_iflag, IXOFF) && cc[VSTART] != _POSIX_VDISABLE &&
  		    putc(cc[VSTART], &tp->t_outq) == 0) {
  			CLR(tp->t_state, TS_TBLOCK);
  			ttstart(tp);