Subject: TIOC[SG]FLAGS ioctl's for the sparc zs driver.
To: None <deraadt@fsa.ca>
From: matthew green <mrg@mame.mu.oz.au>
List: port-sparc
Date: 12/04/1994 00:19:50
i said i'd work on this, and i believe i've got it working.  i
don't claim that what i've done is 100% correct.  i had to make
my own interpretations of all the things it's doing here, and
work out what the best way to `do' it is.  i could be wrong in
a couple of places, but it works just fine for me.

i'm running with this kernel now, with `softcar' added to the
ttya and ttyb lines in /etc/ttys, and `rtscts' also on the line
for ttyb.  the lossage i was seeing when i first went to 1.0A
was caused by the code i've re-commented, the tty[ab]-ignore-cd
bit.  this is fixed with the /etc/ttys entries.

.mrg.


Index: zs.c
*** 1.1.1.1	1994/12/03 07:30:05
--- zs.c	1994/12/03 12:58:31
***************
*** 272,277 ****
--- 272,278 ----
  		zs_tty[unit+1] = ttymalloc();
  
  	softcar = dev->dv_cfdata->cf_flags;
+ #if 0
  #if defined(SUN4C) || defined(SUN4M)
  	if (cputyp == CPU_SUN4C || cputyp == CPU_SUN4M) {
  		if (unit == 0) {
***************
*** 286,291 ****
--- 287,293 ----
  		}
  	}
  #endif
+ #endif
  
  	/* link into interrupt list with order (A,B) (B=A+1) */
  	cs[0].cs_next = &cs[1];
***************
*** 1111,1116 ****
--- 1113,1188 ----
  		ZS_WRITE(cs->cs_zc, 5, cs->cs_creg[5]);
  		splx(s);
  		break;
+ 	case TIOCGFLAGS: {
+ 		int bits = 0;
+ 
+ 		if (cs->cs_softcar)
+ 			bits |= TIOCFLAG_SOFTCAR;
+ 		if (cs->cs_creg[15] & ZSWR15_DCD_IE)
+ 			bits |= TIOCFLAG_CLOCAL;
+ 		if (cs->cs_creg[3] & ZSWR3_HFC)
+ 			bits |= TIOCFLAG_CRTSCTS;
+ 
+ 		*(int *)data = bits;
+ 		break;
+ 	}
+ 	case TIOCSFLAGS: {
+ 		int userbits, driverbits = 0;
+ 
+ 		error = suser(p->p_ucred, &p->p_acflag);
+ 		if (error != 0)
+ 			return(EPERM);
+ 
+ 		userbits = *(int *)data;
+ 
+ 		/*
+ 		 * can have `local' or `softcar', and `rtscts' or `mdmbuf'
+ 		 # defaulting to software flow control.
+ 		 */
+ 		if (userbits & TIOCFLAG_SOFTCAR && userbits & TIOCFLAG_CLOCAL)
+ 			return(EINVAL);
+ 		if (userbits & TIOCFLAG_MDMBUF)	/* don't support this (yet?) */
+ 			return(ENXIO);
+ 
+ 		s = splzs();
+ 		if ((userbits & TIOCFLAG_SOFTCAR) || (tp == zs_ctty))
+ 		{
+ 			cs->cs_softcar = 1;	/* turn on softcar */
+ 			cs->cs_preg[15] &= ~ZSWR15_DCD_IE; /* turn off dcd */
+ 			cs->cs_creg[15] &= ~ZSWR15_DCD_IE;
+ 			ZS_WRITE(cs->cs_zc, 15, cs->cs_creg[15]);
+ 		}
+ 		else if (userbits & TIOCFLAG_CLOCAL)
+ 		{
+ 			cs->cs_softcar = 0; 	/* turn off softcar */
+ 			cs->cs_preg[15] |= ZSWR15_DCD_IE; /* turn on dcd */
+ 			cs->cs_creg[15] |= ZSWR15_DCD_IE;
+ 			ZS_WRITE(cs->cs_zc, 15, cs->cs_creg[15]);
+ 			tp->t_termios.c_cflag |= CLOCAL;
+ 		}
+ 		if (userbits & TIOCFLAG_CRTSCTS)
+ 		{
+ 			cs->cs_preg[15] |= ZSWR15_CTS_IE;
+ 			cs->cs_creg[15] |= ZSWR15_CTS_IE;
+ 			ZS_WRITE(cs->cs_zc, 15, cs->cs_creg[15]);
+ 			cs->cs_preg[3] |= ZSWR3_HFC;
+ 			cs->cs_creg[3] |= ZSWR3_HFC;
+ 			ZS_WRITE(cs->cs_zc, 3, cs->cs_creg[3]);
+ 			tp->t_termios.c_cflag |= CRTSCTS;
+ 		}
+ 		else	/* no mdmbuf, so we must want software flow control */
+ 		{
+ 			cs->cs_preg[15] &= ~ZSWR15_CTS_IE;
+ 			cs->cs_creg[15] &= ~ZSWR15_CTS_IE;
+ 			ZS_WRITE(cs->cs_zc, 15, cs->cs_creg[15]);
+ 			cs->cs_preg[3] &= ~ZSWR3_HFC;
+ 			cs->cs_creg[3] &= ~ZSWR3_HFC;
+ 			ZS_WRITE(cs->cs_zc, 3, cs->cs_creg[3]);
+ 			tp->t_termios.c_cflag &= ~CRTSCTS;
+ 		}
+ 		splx(s);
+ 		break;
+ 	}
  	case TIOCSDTR:
  	case TIOCCDTR:
  	case TIOCMSET: