Subject: None
To: None <newsham@uhunix.uhcc.Hawaii.Edu, amiga-dev@sun-lamp.cs.berkeley.edu>
From: Niklas Hallqvist <niklas@appli.se>
List: amiga-dev
Date: 08/15/1994 23:29:22
Here's the fix for RTS as well as as a fix for the case when your serial
port gets a ctrl-S in ixon mode without a corresponding ctrl-Q.  Normally
you can't force the port to anything in those cases, not even close it.
I solved it the FAS/SAS driver way.  An open with O_TRUNC releases the
blocked condition, easiest done in Bourne shell with ">/dev/tty00" or in
C shell with 'echo "\c">/dev/tty00'!

Enjoy, niklas

PS Chris, do you feel like reviewing the device-independent part and
   bring it forward to the core team.  Seemingly noone else uses RTS
   for handshaking, therfore this bug has gone unresolved for a long time.

===================================================================
RCS file: /home2/CVSROOT/NetBSD/sys/kern/tty.c,v
retrieving revision 1.1.1.12
diff -c -r1.1.1.12 tty.c
*** 1.1.1.12	1994/08/15 14:43:22
--- tty.c	1994/08/15 20:18:41
***************
*** 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);
===================================================================
RCS file: /home2/CVSROOT/NetBSD/sys/arch/amiga/dev/ser.c,v
retrieving revision 1.1.1.9
diff -c -r1.1.1.9 ser.c
*** 1.1.1.9	1994/06/18 10:55:24
--- ser.c	1994/08/15 22:49:57
***************
*** 31,40 ****
   * SUCH DAMAGE.
   *
   *	@(#)ser.c	7.12 (Berkeley) 6/27/91
!  *	$Id: ser.c,v 1.1.1.9 1994/06/18 10:55:24 root Exp $
   */
  /*
!  * XXX This file needs major cleanup it will never ervice more than one
   * XXX unit.
   */
  
--- 31,40 ----
   * SUCH DAMAGE.
   *
   *	@(#)ser.c	7.12 (Berkeley) 6/27/91
!  *	$Id: ser.c,v 1.1.1.1.2.13 1994/08/14 23:19:24 root Exp $
   */
  /*
!  * 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,724 ----
  	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)

------------------------------------------------------------------------------