Subject: port-i386/4196: patches to dev/isa/com.c for hardware TIOCMGET
To: None <gnats-bugs@gnats.netbsd.org>
From: Michael C. Richardson <mcr@sandelman.ottawa.on.ca>
List: netbsd-bugs
Date: 09/30/1997 17:00:54
>Number:         4196
>Category:       port-i386
>Synopsis:       Adds TIOCMGET support.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    gnats-admin (GNATS administrator)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Tue Sep 30 23:20:03 1997
>Last-Modified:
>Originator:     Michael C. Richardson
>Organization:
Sandelman Software Works
>Release:        1.2G
>Environment:
	
System: NetBSD istari.sandelman.ottawa.on.ca 1.2D NetBSD 1.2D (SSW) #10: Wed Jun 11 00:01:01 EDT 1997 mcr@istari.sandelman.ottawa.on.ca:/j/netbsd/src/sys/arch/i386/compile/SSW i386
Architecture: i386

>Description:
	TIOCMGET support went AWOL. This adds it back in.
>How-To-Repeat:
	
>Fix:
*** /w/netbsd/src/sys/dev/isa/com.c	Tue Sep 30 16:47:33 1997
--- com.c	Tue Sep 30 16:55:04 1997
***************
*** 130,135 ****
--- 131,137 ----
  void	com_break	__P((struct com_softc *, int));
  void	com_modem	__P((struct com_softc *, int));
  void	com_iflush	__P((struct com_softc *));
+ int     commctl         __P((struct com_softc *sc, int bits, int how));
  
  int	com_common_getc	__P((bus_space_tag_t, bus_space_handle_t));
  void	com_common_putc	__P((bus_space_tag_t, bus_space_handle_t, int));
***************
*** 676,681 ****
--- 696,769 ----
  }
   
  int
+ commctl(sc, bits, how)
+ 	struct com_softc *sc;
+ 	int bits, how;
+ {
+ 	int s;
+ 	int posix_mcr;
+ 
+ 	s = spltty();
+ 
+ 	/* make up the posix flags */
+ 	posix_mcr = 0;
+ 	if(sc->sc_mcr & MCR_DTR)
+ 	  posix_mcr |= TIOCM_DTR;
+ 	if(sc->sc_mcr & MCR_RTS)
+ 	  posix_mcr |= TIOCM_RTS;
+ 	if(sc->sc_msr & MSR_DCD)
+ 	  posix_mcr |= TIOCM_CAR;
+ 	if(sc->sc_msr & MSR_RI)
+ 	  posix_mcr |= TIOCM_RI;
+ 	if(sc->sc_msr & MSR_DSR)
+ 	  posix_mcr |= TIOCM_DSR;
+ 	if(sc->sc_msr & MSR_CTS)
+ 	  posix_mcr |= TIOCM_CTS;
+ 
+ 	switch (how) {
+ 	case TIOCMSET:
+ 		posix_mcr = bits;
+ 		break;
+ 
+ 	case TIOCMBIS:
+ 		posix_mcr |= bits;
+ 		break;
+ 
+ 	case TIOCMBIC:
+ 		posix_mcr &= ~bits;
+ 		break;
+ 
+ 	case TIOCMGET:
+ 		bits = posix_mcr;
+ 		break;
+ 	}
+ 
+ 	if(how != TIOCMGET) {
+ 	  if(posix_mcr & TIOCM_DTR)
+ 	    sc->sc_mcr |= MCR_DTR;
+ 	  else
+ 	    sc->sc_mcr &= ~MCR_DTR;
+ 	  
+ 	  if(posix_mcr & TIOCM_RTS)
+ 	    sc->sc_mcr |= MCR_RTS;
+ 	  else
+ 	    sc->sc_mcr &= ~MCR_RTS;
+ 	  
+ 	  if (!sc->sc_heldchange) {
+ 	    if (sc->sc_tx_busy) {
+ 	      sc->sc_heldtbc = sc->sc_tbc;
+ 	      sc->sc_tbc = 0;
+ 	      sc->sc_heldchange = 1;
+ 	    } else
+ 	      com_loadchannelregs(sc);
+ 	  }
+ 	}
+ 	
+ 	(void) splx(s);
+ 	return (bits);
+ }
+ 
+ int
  comioctl(dev, cmd, data, flag, p)
  	dev_t dev;
  	u_long cmd;
***************
*** 725,733 ****
--- 813,833 ----
  		break;
  
  	case TIOCMSET:
+ 		(void) commctl(sc, *(int *)data, TIOCMSET);
+ 		break;
+ 
  	case TIOCMBIS:
+ 		(void) commctl(sc, *(int *)data, TIOCMBIS);
+ 		break;
+ 
  	case TIOCMBIC:
+ 		(void) commctl(sc, *(int *)data, TIOCMBIC);
+ 		break;
+ 
  	case TIOCMGET:
+ 		*(int *)data = commctl(sc, 0, TIOCMGET);
+ 		break;
+ 
  	default:
  		return (ENOTTY);
  	}
***************
*** 1701,1707 ****
  com_kgdb_attach(iot, iobase, rate, frequency, cflag)
  	bus_space_tag_t iot;
  	int iobase;
! 	int rate;
  	tcflag_t cflag;
  {
  	int res;
--- 1809,1815 ----
  com_kgdb_attach(iot, iobase, rate, frequency, cflag)
  	bus_space_tag_t iot;
  	int iobase;
! 	int rate, frequency;
  	tcflag_t cflag;
  {
  	int res;

>Audit-Trail:
>Unformatted: