From jkh@time.cdrom.com  Wed Oct 14 15:26:05 1998
Received: from time.cdrom.com (time.cdrom.com [204.216.27.226])
          by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id PAA07443
          for <FreeBSD-gnats-submit@freebsd.org>; Wed, 14 Oct 1998 15:26:04 -0700 (PDT)
          (envelope-from jkh@time.cdrom.com)
Received: (from jkh@localhost)
	by time.cdrom.com (8.8.8/8.8.8) id PAA29825;
	Wed, 14 Oct 1998 15:26:06 -0700 (PDT)
	(envelope-from jkh)
Message-Id: <199810142226.PAA29825@time.cdrom.com>
Date: Wed, 14 Oct 1998 15:26:06 -0700 (PDT)
From: "Andrew J. Korty" <ajk@physics.purdue.edu>
To: FreeBSD-gnats-submit@freebsd.org
Subject: Update to cy driver.
X-Send-Pr-Version: 3.2

>Number:         8318
>Category:       kern
>Synopsis:       [PATCH] Add break support to cy driver.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Oct 14 15:30:00 PDT 1998
>Closed-Date:    Fri Jan 1 05:19:15 PST 1999
>Last-Modified:  Mon Jun 14 00:30:01 PDT 1999
>Originator:     "Andrew J. Korty" <ajk@physics.purdue.edu>
>Release:        FreeBSD 3.0-current i386
>Organization:
Purdue University
>Environment:

>Description:

Patch to add support for the TIOCSBRK and TIOCCBRK ioctls to
the FreeBSD driver for the Cyclades Cyclom-Y (cy).  We use our
Cyclades on our console server, so it's more than just a convenience
to be able to ioctl() a break and drop into the PROM or DDB.  We'd
been living with it for a while until last week when I got fed up
and fixed the driver.

>How-To-Repeat:

>Fix:

*** sys/i386/isa/cy.c.orig	Sun Aug 23 03:26:40 1998
--- sys/i386/isa/cy.c	Wed Oct 14 16:42:02 1998
***************
*** 37,43 ****
  
  /*
   * TODO:
-  * Implement BREAK.
   * Fix overflows when closing line.
   * Atomic COR change.
   * Consoles.
--- 37,42 ----
***************
*** 308,313 ****
--- 307,315 ----
  	u_char	channel_control;/* CD1400 CCR control command shadow */
  	u_char	cor[3];		/* CD1400 COR1-3 shadows */
  	u_char	intr_enable;	/* CD1400 SRER shadow */
+ 	u_char	brk;
+ #define COM_SBRK 0x01		/* start break */
+ #define COM_CBRK 0x02		/* end break */
  
  	/*
  	 * Ping-pong input buffers.  The extra factor of 2 in the sizes is
***************
*** 1333,1350 ****
  					  & CD1400_xIVR_CHAN));
  #endif
  
  		if (com->state >= (CS_BUSY | CS_TTGO | CS_ODEVREADY)) {
  			u_char	*ioptr;
  			u_int	ocount;
  
  			ioptr = com->obufq.l_head;
  				ocount = com->obufq.l_tail - ioptr;
  				if (ocount > CD1400_TX_FIFO_SIZE)
  					ocount = CD1400_TX_FIFO_SIZE;
  				com->bytes_out += ocount;
  				do
! 					cd_outb(iobase, CD1400_TDR, cy_align,
! 						*ioptr++);
  				while (--ocount != 0);
  			com->obufq.l_head = ioptr;
  			if (ioptr >= com->obufq.l_tail) {
--- 1335,1379 ----
  					  & CD1400_xIVR_CHAN));
  #endif
  
+ 		if (com->brk & COM_SBRK) {
+ 			cd_outb(iobase, CD1400_TDR, cy_align, 0);
+ 			cd_outb(iobase, CD1400_TDR, cy_align, 0x81);
+ 		}
+ 		if (com->brk & COM_CBRK) {
+ 			cd_outb(iobase, CD1400_TDR, cy_align, 0);
+ 			cd_outb(iobase, CD1400_TDR, cy_align, 0x83);
+ 		}
+ 
  		if (com->state >= (CS_BUSY | CS_TTGO | CS_ODEVREADY)) {
  			u_char	*ioptr;
  			u_int	ocount;
  
  			ioptr = com->obufq.l_head;
  				ocount = com->obufq.l_tail - ioptr;
+ 			if (com->brk)
+ 				ocount -= 2;
  				if (ocount > CD1400_TX_FIFO_SIZE)
  					ocount = CD1400_TX_FIFO_SIZE;
  				com->bytes_out += ocount;
  				do
! 				/*
! 				 * Check for NULs and double them up.
! 				 * We've turned on Embedded Trasmit
! 				 * Commands, for which NUL is the escape
! 				 * character.  Therefore, bona-fide NULs
! 				 * must be escaped.
! 				 */
! 				if (*ioptr)
! 					cd_outb(iobase, CD1400_TDR,
! 						cy_align, *ioptr++);
! 				else
! 					if (1 < ocount) {
! 						cd_outb(iobase, CD1400_TDR,
! 							cy_align, *ioptr++);
! 						cd_outb(iobase, CD1400_TDR,
! 							cy_align, 0);
! 						--ocount;
! 					}
  				while (--ocount != 0);
  			com->obufq.l_head = ioptr;
  			if (ioptr >= com->obufq.l_tail) {
***************
*** 1373,1378 ****
--- 1402,1408 ----
  				}
  			}
  		}
+ 		com->brk = 0;
  
  			/* terminate service context */
  #ifdef PollMode
***************
*** 1502,1515 ****
  	cd_outb(iobase, CD1400_CAR, com->cy_align,
  		MINOR_TO_UNIT(mynor) & CD1400_CAR_CHAN);
  	switch (cmd) {
- #if 0
  	case TIOCSBRK:
! 		outb(iobase + com_cfcr, com->cfcr_image |= CFCR_SBREAK);
  		break;
  	case TIOCCBRK:
! 		outb(iobase + com_cfcr, com->cfcr_image &= ~CFCR_SBREAK);
  		break;
- #endif /* 0 */
  	case TIOCSDTR:
  		(void)commctl(com, TIOCM_DTR, DMBIS);
  		break;
--- 1532,1547 ----
  	cd_outb(iobase, CD1400_CAR, com->cy_align,
  		MINOR_TO_UNIT(mynor) & CD1400_CAR_CHAN);
  	switch (cmd) {
  	case TIOCSBRK:
! 		com->brk |= COM_SBRK;
! 		if (!(tp->t_state & TS_BUSY))
! 			comstart(tp);
  		break;
  	case TIOCCBRK:
! 		com->brk |= COM_CBRK;
! 		if (!(tp->t_state & TS_BUSY))
! 			comstart(tp);
  		break;
  	case TIOCSDTR:
  		(void)commctl(com, TIOCM_DTR, DMBIS);
  		break;
***************
*** 1888,1893 ****
--- 1920,1927 ----
  	if (cflag & CCTS_OFLOW)
  		opt |= CD1400_COR2_CCTS_OFLOW;
  #endif
+ 	/* enable Embedded Transmit Commands */
+ 	opt |= CD1400_COR2_ETC;
  	if (opt != com->cor[1]) {
  		cor_change |= CD1400_CCR_COR2;
  		cd_outb(iobase, CD1400_COR2, com->cy_align, com->cor[1] = opt);
***************
*** 2113,2118 ****
--- 2147,2155 ----
  			cd_outb(iobase, CD1400_SRER, com->cy_align,
  				com->intr_enable |= CD1400_SRER_TXRDY);
  	}
+ 	if (com->brk)
+ 		cd_outb(iobase, CD1400_SRER, com->cy_align,
+ 			com->intr_enable |= CD1400_SRER_TXRDY);
  	if (tp->t_state & TS_TBLOCK) {
  		if (com->mcr_image & com->mcr_rts && com->state & CS_RTS_IFLOW)
  #if 0
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: bde 
State-Changed-When: Fri Jan 1 05:19:15 PST 1999 
State-Changed-Why:  
Fixed in rev.1.77 of cy.c (using a different fix than the one in the PR. 
The fix in the PR was not wasted since it helped me finish the second 90% 
of the fix that I had 90% finished). 

From: "Patrick M. Hausen" <hausen@punkt.de>
To: freebsd-gnats-submit@freebsd.org, ajk@physics.purdue.edu
Cc:  
Subject: Re: kern/8318: [PATCH] Add break support to cy driver.
Date: Mon, 14 Jun 1999 09:20:12 +0200

 Hi!
 
 I'm planning to buy a Cyclades board to connect to the consoles
 of our Ciscos. Break is essential so I checked the CVS repository.
 
 I'm glad to see this fixed in the driver.
 Please update the manpage. ;-) Still claims
 "BREAK unsupported" in the BUGS section.
 
 Patrick
 
>Unformatted:
