[comp.bugs.2bsd] dhu/dhv bug in 2.9CSS

taylor@oswego.UUCP (03/12/87)

Subject: Bug in 2.9CSS dhu driver (with patch)
Index:	sys/dev/dhu.c 2.9CSS/Harvard

Description:
	The dhu/dhv driver will send very strange characters to the 
	dhu/dhv terminal (Eg. 30 K's, 25 spaces, ...) when running
	on a Q_BUS (Non unibus mapped machine) based machine with
	UCB_CLISTS enabled.
Repeat-By:
	Configure a kernel with a dhu/dhv and UCB_CLIST enabled.
Fix:
	See context diffs included.

*** dhu.c	Thu Mar 12 10:46:22 1987
--- dhu.c.orig	Fri Feb 13 16:19:19 1987
***************
*** 32,37
  
  extern	int	hz;
  
  #ifdef	UCB_CLIST
  extern	struct	cblock	*cfree;
  #else	UCB_CLIST

--- 32,41 -----
  
  extern	int	hz;
  
+ #if	defined (UNIBUS_MAP) || defined (UCB_CLIST)
+ 
+ extern	ubadr_t	clstaddr;
+ 
  #ifdef	UCB_CLIST
  extern	struct	cblock	*cfree;
  #else	UCB_CLIST
***************
*** 38,45
  extern	struct	cblock	cfree[];
  #endif	UCB_CLIST
  
- #if	defined (UNIBUS_MAP) || defined (UCB_CLIST)
- extern	ubadr_t	clstaddr;
  #define	cpaddr(x)	(clstaddr + (ubadr_t)((x) - cfree))
  #else	defined (UNIBUS_MAP) || defined (UCB_CLIST)
  #define	cpaddr(x)	((u_short)(x))

--- 42,47 -----
  extern	struct	cblock	cfree[];
  #endif	UCB_CLIST
  
  #define	cpaddr(x)	(clstaddr + (ubadr_t)((x) - cfree))
  
  #else	defined (UNIBUS_MAP) || defined (UCB_CLIST)
***************
*** 41,46
  #if	defined (UNIBUS_MAP) || defined (UCB_CLIST)
  extern	ubadr_t	clstaddr;
  #define	cpaddr(x)	(clstaddr + (ubadr_t)((x) - cfree))
  #else	defined (UNIBUS_MAP) || defined (UCB_CLIST)
  #define	cpaddr(x)	((u_short)(x))
  #endif	defined (UNIBUS_MAP) || defined (UCB_CLIST)

--- 43,49 -----
  #endif	UCB_CLIST
  
  #define	cpaddr(x)	(clstaddr + (ubadr_t)((x) - cfree))
+ 
  #else	defined (UNIBUS_MAP) || defined (UCB_CLIST)
  #define	cpaddr(x)	((u_short)(x))
  #endif	defined (UNIBUS_MAP) || defined (UCB_CLIST)
***************
*** 562,568
  	register struct dhusoftc *sc;
  	register int line, t;
  	u_short cntr;
- 	ubadr_t base;
  
  	sc = &dhu_softc[dhu];
  	tp0 = &dhu11[dhu << NDHUSHIFT];

--- 565,570 -----
  	register struct dhusoftc *sc;
  	register int line, t;
  	u_short cntr;
  
  	sc = &dhu_softc[dhu];
  	tp0 = &dhu11[dhu << NDHUSHIFT];
***************
*** 589,595
  			 *
  			 * In either case, the extension bits are 0.
  			*/
- #if	!defined(UCB_CLIST) || defined(UNIBUS_MAP)
  			cntr = addr->dhubar1 - cpaddr(tp->t_outq.c_cf);
  #else	/* defined (UCB_CLIST) && !defined(UNIBUS_MAP) */
  			base = (ubadr_t) addr->dhubar1 

--- 591,596 -----
  			 *
  			 * In either case, the extension bits are 0.
  			*/
  			cntr = addr->dhubar1 - cpaddr(tp->t_outq.c_cf);
  			ndflush(&tp->t_outq,cntr);
  		}
***************
*** 591,601
  			*/
  #if	!defined(UCB_CLIST) || defined(UNIBUS_MAP)
  			cntr = addr->dhubar1 - cpaddr(tp->t_outq.c_cf);
- #else	/* defined (UCB_CLIST) && !defined(UNIBUS_MAP) */
- 			base = (ubadr_t) addr->dhubar1 
- 				| (ubadr_t) (( addr->dhubar2 & 037) << 16);
- 			cntr = base - cpaddr(tp->t_outq.c_cf);
- #endif	!defined(UCB_CLIST) || defined(UNIBUS_MAP)
  			ndflush(&tp->t_outq,cntr);
  		}
  #ifndef pdp11

--- 592,597 -----
  			 * In either case, the extension bits are 0.
  			*/
  			cntr = addr->dhubar1 - cpaddr(tp->t_outq.c_cf);
  			ndflush(&tp->t_outq,cntr);
  		}
  #ifndef pdp11
***************
*** 683,689
  		addr->dhulcr &= ~DHU_LC_TXABORT;
  		addr->dhubcr = nch;
  		addr->dhubar1 = loint(car);
- #if	!defined(UCB_CLIST) || defined(UNIBUS_MAP)
  		addr->dhubar2 = (hiint(car) & DHU_BA2_XBA) | DHU_BA2_DMAGO;
  #else	/* defined (UCB_CLIST) && !defined(UNIBUS_MAP) */
  		addr->dhubar2 = (hiint(car) & 037) | DHU_BA2_DMAGO;

--- 679,684 -----
  		addr->dhulcr &= ~DHU_LC_TXABORT;
  		addr->dhubcr = nch;
  		addr->dhubar1 = loint(car);
  		addr->dhubar2 = (hiint(car) & DHU_BA2_XBA) | DHU_BA2_DMAGO;
  		tp->t_state |= BUSY;
  	}
***************
*** 685,693
  		addr->dhubar1 = loint(car);
  #if	!defined(UCB_CLIST) || defined(UNIBUS_MAP)
  		addr->dhubar2 = (hiint(car) & DHU_BA2_XBA) | DHU_BA2_DMAGO;
- #else	/* defined (UCB_CLIST) && !defined(UNIBUS_MAP) */
- 		addr->dhubar2 = (hiint(car) & 037) | DHU_BA2_DMAGO;
- #endif	!defined(UCB_CLIST) || defined(UNIBUS_MAP)
  		tp->t_state |= BUSY;
  	}
  out:

--- 680,685 -----
  		addr->dhubcr = nch;
  		addr->dhubar1 = loint(car);
  		addr->dhubar2 = (hiint(car) & DHU_BA2_XBA) | DHU_BA2_DMAGO;
  		tp->t_state |= BUSY;
  	}
  out:
-- 
 UUCP:            sunybcs\         U.S.MAIL: Paul R. Taylor
           allegra!warrior\                  Systems Programmer
  seismo!rochester!rocksvax!oswego!taylor    Instructional Computing Center
{batcomputer|gould}!tundra/                  Oswego, NY 13126