Subject: kernel 'config', autoconfig,  documentation changes (#99, 11 of 12)
Index:	sys,doc,etc,pdpif,.../many 2.11BSD

Description:
	This is part 11 of 12.  Updates #89 thru #100 are parts 1 thru 12
	respectively.
	
	If you have tired of reading the notes in the "Repeat-By:" section 
	please skip to the "Fix:" section for notes and instructions about 
	this patch file (list of files updated, etc).

Repeat-By:

	This section is repeated in each patch file.  Specific directions
	for the individual patches are included in the "Fix:" section.

	Several problem areas are addressed by this series of updates.

	1) The kernel configuration problems are best noticed
	   by maintaining kernels for a variety of systems and forgetting
	   to copy 'localopts.h' to ../h before compiling.  This at best
	   would cause compile time problems, at worst resulting in a kernel
	   that was unusable.  MANY of the changes described below are
	   aimed at the reduction of 'localopts.h' to almost nothing.

	2) There were several kernel config options which were either known not
	   to work, have not been used within recent memory or were obsolete.
	   UCB_FRCSWAP (to force a swap on program expansion) is a good
	   example of an option which has been removed.
	   
	   The list of things which have been options at one time or another
	   in the system's life has been removed.  Many of them dated back
	   to V7, the modules which they affected are not even present in
	   the system any longer.

	   Two options have been moved to the end of the 'config' script.
	   Neither is known to work (CGL_RTP and FPSIM) and are always left
	   NO.

	3) A couple of kernel config options should not have been options so
	   that the kernel could automatically adapt to whatever machine it
	   found itself running on.  The UNIBUS_MAP and Q22 options are good 
	   examples of this.  Usage of the UNIBUS_MAP option was inconsistent,
	   some of the drivers in the system "#ifdef"d references to the
	   Unibus map allocation routine while other drivers did not.  Since
	   the system knows whether a Unibus Map is present or not the
	   correct behaviour is to either test 'ubmap' or simply call 'mapalloc'
	   (which will do the test for you).  In the case of GENERIC or Unibus
	   based kernels there is _no_ penalty (since UNIBUS_MAP was defined),
	   in the case of Qbus systems there is about 900 bytes of code that
	   simply never gets used (and 40 bytes or so of D space).

	   The Q22 defined was used incorrectly in a couple of drivers to
	   either distinquish between Digital and 3rd party controllers (DH-11
	   vs Emulex CS02) or to indicate whether the system was Qbus or
	   Unibus based.  The references to Q22 in dh.c were changed to
	   CS02 (a new option in the device selection area of the config
	   files), deleted, or replaced with tests of 'ubmap'.

	   UCB_RUSAGE has been made standard because several applications
	   (iostat, vmstat, etc) use the statistics and because the
	   getrusage(2) call uses them.  UCB_METER has been left as an
	   option and will be placed in the Makefile as "-DUCB_METER" in
	   the DEFS line.  References to UCB_RUSAGE have been removed from the
	   kernel.

	   NONFP has been removed.  Hardware floating point is mandatory
	   for two reasons:  the simulator doesn't work, and FP is very
	   inexpensive (or standard on KDJ-11 systems).

	   VIRUS_VFORK has been removed.  Nothing depended on it in the
	   applications and VIRUS_VFORK has never been anything but YES.  

	4) NSWAP has gone away.  It was too easy to either forget to change
	   it or to pick a wrong number (by guessing).  Borrowing yet another
	   concept from 4.3BSD the system now determines the amount of
	   swap space dynamically after booting.  This is done by calling
	   a partition size routine which each disc driver provides.  The
	   bdevsw[] table (in pdp/conf.c) has been expanded to include 
	   a "d_psize" member for each device.

	   NOTE:  this change requires that 'a' and 'b' be the root and
		  swap partitions.  All drivers except the RK06/7 (hk.c) 
		  and RM02/3 (xp.c) observed this rule.  Changes were made 
		  to the RK06/7 and RM02/3 partition tables (and /etc/disktab).
		  The previous practice of using the 'e' or 'f' partitions
		  to overlap the old 'a'+'b' partitions has gone away.  THE
		  new 'a' partition is the same size as the 'e' or 'f'
		  partitions used to be, so there is ROOT FILESYSTEM
		  compatibility (the system will still boot).   Best
		  to back the system up (if using RK07 or RM02 drives)
		  before applying these changes.

	5) SWAPLO has gone away.  It has never been anything but 0 within
	   recent memory (and would have resulted in filesystem corruption
	   if an inappropriate value were chosen).  The only device which 
	   possibly would need to use it (the RL02) is required to be used 
	   in pairs.
	   
	   Deleting SWAPLO removed a number of long word adds scattered around
	   the kernel.  One sector (.5kb) of swap space is "lost"/discarded.
	   The previous practice was to decrement 'swplo' in compensation
	   for entering 1 as the first swap block.  Since 'swplo' has
	   gone away, the number of blocks available ('nswap') is simply 
	   decremented by 1 and the swapmap initialized starting at block 1.

	   This change affects a couple of the applications ('ps', 'pstat',
	   etc.) which were looking for 'swplo'.  These programs have been
	   updated.

	6) 'autoconfig' and programmable vector devices (MSCP, TMSCP, etc)
	    have never gotten along very well.  The drivers had
	    vectors hardcoded (either via #define statments or code
	    which allocated vectors from a base vector) into them.  Changing
	    /etc/dtab would have no effect (at best) or the system would
	    crash (at worst) because 'autoconfig' would allocate/initialize 
	    a vector different than that assumed by the driver. 

	    Networking drivers which support programmable vectors (DEQNA
	    for example) previously had their vectors hardcoded into
	    them AND into pdp/net_scb.s.  Changing one but forgetting to
	    change the other was one way to generate an inoperable system!

	    This has been fixed _at last_!  There are two methods used.
	    One for kernel devices configured by 'autoconfig' and a second 
	    used by the both 'autoconfig' and the networking drivers (which 
	    are not handled by 'autoconfig' because the networking is already 
	    running by the time 'init' starts 'autoconfig').

	    If a driver defines a routine "xxxVec" (where xxx is 'ra',
	    'tms', etc) then 'autoconfig' will call the driver with
	    two parameters:  the controller number and the vector from
	    /etc/dtab.  If the driver lacks a 'xxxVec' routine then
	    'autoconfig' functions as it always has.

	    The second method is used when dynamic allocation of vectors
	    is desired for programmable vector devices.  The networking
	    drivers (DEQNA, DEQTA, etc) use this method.  In the kernel
	    there is a location ('lastiv') which contains the next vector
	    to assign.  Usage is to decrement 'lastiv' by 4 and use the
	    new value.  If multiple vectors are needed then a multiple of
	    4 is subtracted ('autoconfig' counts how many "handlers" it
	    needs for a device).  To make use of this feature (second or third
	    MSCP controllers for example) put a 0 (zero) in the vector
	    field in /etc/dtab.

		NOTE:  It is an error to specify a 0 vector (dynamic
		       allocation) and not have a 'xxxVec' routine for
		       'autoconfig' to call.  'autoconfig' will print
		       an error and leave the device unattached.

		       If 'xxxVec' is used by 'autoconfig' the driver
		       should return success (0) or failure (non-0).
		       'autoconfig' will print "vectorset" if a programmable
		       vector is successfully installed.

	    Networking drivers access 'lastiv' via the "mfkd" and "mtkd"
	    (move from kernel data, move to kernel data) routines.  The
	    hardwired vector (400 for the DEQNA) has been removed from
	    scb.s.,

		NOTE:  the handlers for networking devices are still
		       present in net_scb.s, the drivers initialize
		       the allocated vector by means of a small (1 instruction)
		       assembly language routine (see the changes to 
		       pdpif/if_qe.c).  This 'asm' routine is needed
		       for the driver to access the handle name which does
		       not have a leading (underscore) prepended to it.

	7)  The logic in the DHV-11 driver to attempt forcing a fuller silo
	    (by turning off and on the receive interrupt enable) was removed
	    since it did not work (for very long).  After 2 silo overruns
	    or 90% full silos the logic would disable itself by decrementing
	    the number of delay ticks to 0.  The only real fix for the DHV-11's
	    silo handling problem is to replace the DHV-11 with a DHQ-11.

	8)  The kernel option UCB_NET has been renamed to INET (as 4.3BSD
	    does).  The TCP_COMPAT_42 option has been made "standard" by
	    removing the ifdef in netinet/tcp_var.h.

	9)  The MAXMEM option has been moved to param.h.  It is (almost)
	    never changed and was yet one more thing to accidentally get
	    wrong when configuring a kernel.  Thought was given to removing
	    MAXMEM entirely but it was put in with the other "never changed
	    without a great deal of thought" parameters in param.h

	10) The setup and installation documents have been revised to reflect
	    the new kernel configuration process and to remove references
	    to 'xpunix', 'raunix', etc (not needed now that the generic
	    kernel adapts automatically).

	11) The drivers in the OTHERS directory have been lightly edited
	    to change UCB_NET to INET, remove UNIBUS_MAP usage, etc.  No
	    attempt has been made to port or fix the drivers.

	12) Last, but by no means least, the 'config' script (/sys/conf/config)
	    and the conf/Make.{nsunix,unix,sunix} files have been totally 
	    redone.  Borrowing still another idea from 4.3BSD (not a whole
	    lot left to 'steal' ;-)) the 'config' script now places a line:

		DEFS="-DKERNEL -Doption1 -Doption2 ..."

	    at the front of the main Makefile.  The CFLAGS statement has
	    been modified to include ${DEFS}, thus the configuration options
	    are passed thru to the secondary makefiles Make.pdp, Make.pdpuba,
	    etc. 

	    The GENERIC config file has been redone.  You should make note
	    of your present device complement and then re-config your kernels
	    by making a copy of GENERIC and editing it.

		    NOTE:  The PDP11 line is now only used to select the
			   appropriate inlining method for the 'spl'
			   instruction.  You may safely set PDP11 to GENERIC,
			   no references to PDP11 are now made anywhere in the
			   kernel.

			   You should only set the IDENT line to GENERIC
			   if you either know what you are doing, or if
			   you really are making a distribution kernel.

			   Setting IDENT to GENERIC causes the kernel at
			   boot time to:

			   a) override "swapdev".
			      A GENERIC kernel automatically assigns the 'b'
			      partition of the booted device to be "swapdev"

			   b) override "rootdev".
			      A GENERIC kernel automatically assigns the 'a'
			      partition of the booted device to be "rootdev"
			      and "pipedev".

		The /GENALLSYS script is obsolete and has been removed
		from the system.  For a GENERIC system /unix will now
		adapt to the bootstrapped drive and automatically determine
		the amount of swap space.

	    The only change made to the secondary makefiles was to add
	    a new ethernet driver (not yet working) to Make.net.  The DEQTA
	    driver (if_qt.c) is still being debugged, a future update will
	    be forthcoming.  Since if_qt.c does not exist, the "patch" is
	    the whole file (the same applies to if_qtreg.h).  You will need
	    to create two 0 length files in pdpif ("touch /sys/pdpif/if_qt.c
	    /sys/pdpif/if_qtreg.h") before applying the 'pdpif' update kit.
	    A reminder will be placed in the part containing that patch.

		NOTE:  localopts.h has exactly _TWO_ (2) definitions in it
		       now:  EXTERNALITIMES (mapped out time values from the
		       inodes) and LINEHZ.

		       The default for EXTERNALITIMES is now YES.  It is
		       recommended that this not be changed, if it is changed
		       then applications which look at the kernel incore
		       inode table (pstat for example) will need to be
		       recompiled.

		       Unless either of these two defines change you never
		       need to worry about copying localopts.h again!

Fix:

/usr/src/sys/pdpuba/br.c
/usr/src/sys/pdpuba/dh.c
/usr/src/sys/pdpuba/dhu.c
/usr/src/sys/pdpuba/dhv.c
/usr/src/sys/pdpuba/dr.c
/usr/src/sys/pdpuba/hk.c
/usr/src/sys/pdpuba/ht.c
/usr/src/sys/pdpuba/ra.c
/usr/src/sys/pdpuba/rk.c
/usr/src/sys/pdpuba/rl.c
/usr/src/sys/pdpuba/rx.c
/usr/src/sys/pdpuba/si.c
/usr/src/sys/pdpuba/tm.c
/usr/src/sys/pdpuba/tmscp.c
/usr/src/sys/pdpuba/ts.c
/usr/src/sys/pdpuba/xp.c
/usr/src/man/man4/hk.4
/usr/src/man/man4/xp.4

	All of the drivers had references to UNIBUS_MAP either removed
	or replaced with a run time test for the Unibus Map being present.

	In dh.c the Q22 option (which has been removed) was incorrectly
	being used to distinguish between an Emulex CS02 and a DEC DH-11.
	A new kernel config option CS02 has been created for this purpose.

	In dhv.c the logic used to attempt obtaining a fuller silo has
	been removed because it was ineffective.  After two silo overrun
	or two 90% full silo interrupts the number of ticks to delay was
	decremented to zero resulting in interrupt per character at higher
	baud rates.  Only known solution is to replace the DHV-11 with a
	DHQ-11 (running in DHU mode).  Added was an unused (you can try
	enabling the ifdef if you're curious) section to lower the processor 
	priority, delay 1ms (approximately) and then raise the priority.

	The hk.c (RK06/7) and xp.c (RM02/3 case) driver partition tables were 
	modified.  The 'a', 'b', and 'c' partitions are now 'root', 'swap'
	and 'whole disc (including badsector track)' respectively.  The old
	practice of using the 'e' or 'f' partition to overlap the 'a'+'b'
	partitions is not used.

	All disc drivers had a function added to return the size of a
	partition.  This is used by the kernel at boot time to determine
	how much swap space is present in the 'b' partition.  In some cases
	the XXopen() routine had to be modified to bring the drive online
	and/or determine the drive type.  The XXsize() routines assume that
	the drive has been brought online.

	The rl.c driver had the 'get unit status' logic made into a common
	routine rather than replicating the code in several places.

*** /usr/src/sys/pdpuba/br.c.old	Sun Sep 22 08:36:20 1991
--- /usr/src/sys/pdpuba/br.c	Sun Jan  3 18:29:18 1993
***************
*** 27,32 ****
--- 27,35 ----
   *	      converting the systems.  BE CAREFUL!  For T300 only.
   * 8/4/89   - Use the log() function to record soft errors.
   * 9/22/91  - remove read and write entry - use common raw read/write routine.
+  * 12/23/92 - add the partition size routine.
+  * 1/2/93   - remove unibus map ifdefs, the run time check using 'ubmap' is
+  *	      sufficient and does the right thing.
   */
  
  #include "br.h"
***************
*** 42,55 ****
  #include "brreg.h"
  #include "dk.h"
  #include "syslog.h"
- 
- #ifdef UNIBUS_MAP
  #include "map.h"
  #include "uba.h"
- #endif
  
  #define	BRADDR ((struct brdevice *) 0176710)
! #define	brunit(dev)	((minor(dev) >> 3) & 7)
  #define	SECTRK  brc->sectrk
  #define	TRKCYL  brc->trkcyl
  
--- 45,55 ----
  #include "brreg.h"
  #include "dk.h"
  #include "syslog.h"
  #include "map.h"
  #include "uba.h"
  
  #define	BRADDR ((struct brdevice *) 0176710)
! #define	brunit(dev)	((dev >> 3) & 7)
  #define	SECTRK  brc->sectrk
  #define	TRKCYL  brc->trkcyl
  
***************
*** 143,153 ****
  	return(0);
  }
  
! bropen(dev)
! 	dev_t dev;
  {
! 	if (brunit(dev) >= NBR || !Br_addr)
  		return(ENXIO);
  	return(0);
  }
  
--- 143,160 ----
  	return(0);
  }
  
! bropen(dev, flag)
! 	dev_t	dev;
! 	int	flag;
  {
! 	register int dn = brunit(dev);
! 
! 	if	(dn >= NBR || !Br_addr)
  		return(ENXIO);
+ 	if	(!br_disk[dn])
+ 		brinit(dn);
+ 	if	(!br_disk[dn])
+ 		return(EIO);
  	return(0);
  }
  
***************
*** 163,169 ****
  
  	unit = bp->b_dev & 07;
  	drive = brunit(bp->b_dev);
! 	if (!(brc = br_disk[drive])) {
  		brinit(drive);
  		if (!(brc = br_disk[drive])) {
  			bp->b_error = ENODEV;
--- 170,176 ----
  
  	unit = bp->b_dev & 07;
  	drive = brunit(bp->b_dev);
! 	if	(!(brc = br_disk[drive])) {
  		brinit(drive);
  		if (!(brc = br_disk[drive])) {
  			bp->b_error = ENODEV;
***************
*** 185,194 ****
  		iodone(bp);
  		return;
  	}
- #ifdef UNIBUS_MAP
  	if (Br_addr->brae >= 0)
  		mapalloc(bp);
- #endif
  	bp->b_cylin = bp->b_blkno/(SECTRK*TRKCYL) + brz->cyloff;
  	s = splbio();
  	dp = &brtab;
--- 192,199 ----
***************
*** 360,378 ****
   * Dump routine.  Dumps from dumplo to end of memory/end of disk section for
   * minor(dev).
   */
- #ifdef UNIBUS_MAP
- #define	DBSIZE	(UBPAGE/NBPG)		/* unit of transfer, one UBPAGE */
- #else
  #define	DBSIZE	16			/* unit of transfer, same number */
- #endif
  
  brdump(dev)
  	dev_t dev;
  {
  	struct br_char *brc;
- #ifdef UNIBUS_MAP
  	struct ubmap *ubp;
- #endif
  	daddr_t bn, dumpsize;
  	long paddr;
  	int count, cyl, dn, cn, tn, sn, unit, com;
--- 365,377 ----
***************
*** 389,397 ****
  		return(EINVAL);
  	dumpsize -= dumplo;
  	while (!(Br_addr->brcs.w & BR_RDY));
- #ifdef UNIBUS_MAP
  	ubp = &UBMAP[0];
- #endif
  	for (paddr = 0L; dumpsize > 0; dumpsize -= count) {
  		count = dumpsize > DBSIZE ? DBSIZE : dumpsize;
  		bn = dumplo + (paddr >> PGSHIFT);
--- 388,394 ----
***************
*** 403,409 ****
  		Br_addr->brda = (tn << 8) | sn;
  		Br_addr->brwc = -(count << (PGSHIFT-1));
  		com = (dn << 8) | BR_GO | BR_WCOM;
- #ifdef UNIBUS_MAP
  		if (ubmap && Br_addr->brae >= 0) {
  			ubp->ub_lo = loint(paddr);
  			ubp->ub_hi = hiint(paddr);
--- 400,405 ----
***************
*** 410,422 ****
  			Br_addr->brba = 0;
  		}
  		else {
- #endif
  			Br_addr->brba = (caddr_t)loint(paddr);
  			Br_addr->brae = hiint(paddr);
  			com |= ((hiint(paddr) & 3) << 4);
- #ifdef UNIBUS_MAP
  		}
- #endif
  		Br_addr->brcs.w = com;
  		while (!(Br_addr->brcs.w & BR_RDY));
  		if (Br_addr->brcs.w < 0) {
--- 406,415 ----
***************
*** 429,432 ****
--- 422,439 ----
  	return(0);				/* filled disk */
  }
  #endif /* BR_DUMP */
+ 
+ /*
+  * Assumes the 'open' entry point has been called to validate the unit
+  * number and fill in the drive type structure.
+ */
+ daddr_t
+ brsize(dev)
+ 	register dev_t dev;
+ 	{
+ 	register struct	br_char *brc;
+ 
+ 	brc = br_disk[brunit(dev)];
+ 	return(brc->br_sizes[dev & 7].nblocks);
+ 	}
  #endif /* NBR */
*** /usr/src/sys/pdpuba/dh.c.old	Tue Apr  3 19:45:16 1990
--- /usr/src/sys/pdpuba/dh.c	Sun Jan  3 12:57:36 1993
***************
*** 64,70 ****
  static short timerstarted;
  int	dhstart(), ttrstrt();
  
! #if defined(UNIBUS_MAP) || defined(UCB_CLIST)
  extern	ubadr_t	clstaddr;
  #define	cpaddr(x)	(clstaddr + (ubadr_t)((x) - (char *)cfree))
  #else
--- 64,70 ----
  static short timerstarted;
  int	dhstart(), ttrstrt();
  
! #if defined(UCB_CLIST)
  extern	ubadr_t	clstaddr;
  #define	cpaddr(x)	(clstaddr + (ubadr_t)((x) - (char *)cfree))
  #else
***************
*** 376,381 ****
--- 376,383 ----
  	struct uba_device *ui;
  	register int unit;
  	u_short cntr;
+ 	ubadr_t car;
+ 	struct dmdevice *dmaddr;
  
  	ui = &dhinfo[dh];
  	addr = (struct dhdevice *)ui->ui_addr;
***************
*** 397,403 ****
  				tp->t_state &= ~TS_FLUSH;
  			else {
  				addr->un.dhcsrl = (unit&017)|DH_IE;
- #if !defined(UCB_CLIST) || defined(UNIBUS_MAP)
  				/*
  				 * Clists are either:
  				 *	1)  in kernel virtual space,
--- 399,404 ----
***************
*** 407,430 ****
  				 *
  				 * In either case, the extension bits are 0.
  				 */
! 				cntr = (caddr_t)addr->dhcar - cpaddr(tp->t_outq.c_cf);
! 				ndflush(&tp->t_outq, (int)cntr);
! #else
! 				{
! 				ubadr_t car;
! #if defined(Q22)
! 				struct dmdevice *dmaddr = (struct dmdevice *)dminfo[dh].ui_addr;
  
! 				car = (ubadr_t)addr->dhcar;
! 				car |= ((ubadr_t)(dmaddr->dmlst_h&077) << 16);
  #else
! 				car = (ubadr_t) addr->dhcar
! 				    | (ubadr_t)(addr->dhsilo & 0300) << 10;
! #endif defined(Q22)
! 				cntr = car - cpaddr(tp->t_outq.c_cf);
! 				ndflush(&tp->t_outq, cntr);
! 				}
  #endif
  			}
  			if (tp->t_line)
  				(*linesw[tp->t_line].l_start)(tp);
--- 408,425 ----
  				 *
  				 * In either case, the extension bits are 0.
  				 */
! 				car = (caddr_t)addr->dhcar;
! 				if (!ubmap) {
! #if defined(CS02)
! 					dmaddr = (struct dmdevice *)dminfo[dh].ui_addr;
  
! 					car |= ((ubadr_t)(dmaddr->dmlst_h&077) << 16);
  #else
! 					car |= (ubadr_t)((addr->dhsilo & 0300) << 10);
  #endif
+ 				}
+ 			cntr = car - cpaddr(tp->t_outq.c_cf);
+ 			ndflush(&tp->t_outq, cntr);
  			}
  			if (tp->t_line)
  				(*linesw[tp->t_line].l_start)(tp);
***************
*** 442,448 ****
  {
  	register struct dhdevice *addr;
  	register int dh, unit, nch;
! 	int s;
  
  	unit = UNIT(tp->t_dev);
  	dh = unit >> 4;
--- 437,445 ----
  {
  	register struct dhdevice *addr;
  	register int dh, unit, nch;
! 	int s, csrl;
! 	ubadr_t uba;
! 	struct dmdevice *dmaddr;
  
  	unit = UNIT(tp->t_dev);
  	dh = unit >> 4;
***************
*** 498,521 ****
  	 * If characters to transmit, restart transmission.
  	 */
  	if (nch) {
- #if !defined(UCB_CLIST) || defined (UNIBUS_MAP)
- 		addr->un.dhcsrl = (char)((unit&017)|DH_IE);
- 		addr->dhcar = (u_short)cpaddr(tp->t_outq.c_cf);
- #else
- 		ubadr_t uba;
- #if defined(Q22)
- 		struct dmdevice *dmaddr = (struct dmdevice *)dminfo[dh].ui_addr;
- #endif
- 
  		uba = cpaddr(tp->t_outq.c_cf);
! #if defined(Q22)
!                 addr->un.dhcsrl = (unit&017) | DH_IE;
!                 dmaddr->dmlst_h = hiint(uba) & 077;
  #else
! 		addr->un.dhcsrl = (unit&017) | DH_IE | ((hiint(uba)<<4)&060);
! #endif defined(Q22)
! 		addr->dhcar = loint(uba);
  #endif
  		{ short word = 1 << unit;
  		dhsar[dh] |= word;
  		addr->dhbcr = -nch;
--- 495,515 ----
  	 * If characters to transmit, restart transmission.
  	 */
  	if (nch) {
  		uba = cpaddr(tp->t_outq.c_cf);
! 		csrl = (unit&017) | DH_IE;
! 		if (ubmap)
! 			addr->un.dhcsrl = (char)csrl;
! 		else {
! #if defined(CS02)
! 			dmaddr = (struct dmdevice *)dminfo[dh].ui_addr;
! 			addr->un.dhcsrl = csrl;
! 			dmaddr->dmlst_h = hiint(uba) & 077;
  #else
! 			addr->un.dhcsrl = csrl | DH_IE | ((hiint(uba)<<4)&060);
  #endif
+ 		}
+ 		addr->dhcar = loint(uba);
+ 
  		{ short word = 1 << unit;
  		dhsar[dh] |= word;
  		addr->dhbcr = -nch;
*** /usr/src/sys/pdpuba/dhu.c.old	Tue Apr  3 16:50:14 1990
--- /usr/src/sys/pdpuba/dhu.c	Sun Jan  3 13:29:37 1993
***************
*** 3,9 ****
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)dhu.c	1.1 (2.10BSD Berkeley) 12/1/86
   */
  
  /*
--- 3,9 ----
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)dhu.c	2.0 (2.11BSD GTE) 1/3/93
   */
  
  /*
***************
*** 84,90 ****
  int	dhustart(), ttrstrt();
  long	dhumctl(),dmtodhu();
  
! #if defined(UNIBUS_MAP) || defined(UCB_CLIST)
  extern	ubadr_t clstaddr;
  #define	cpaddr(x)	(clstaddr + (ubadr_t)((x) - (char *)cfree))
  #else
--- 84,90 ----
  int	dhustart(), ttrstrt();
  long	dhumctl(),dmtodhu();
  
! #if defined(UCB_CLIST)
  extern	ubadr_t clstaddr;
  #define	cpaddr(x)	(clstaddr + (ubadr_t)((x) - (char *)cfree))
  #else
***************
*** 461,466 ****
--- 461,467 ----
  	register struct uba_device *ui;
  	register int line, t;
  	u_short cntr;
+ 	ubadr_t	base;
  
  	ui = &dhuinfo[dhu];
  	tp0 = &dhu_tty[dhu<<4];
***************
*** 477,482 ****
--- 478,484 ----
  			tp->t_state &= ~TS_FLUSH;
  		else {
  			addr->dhucsrl = DHU_SELECT(line) | DHU_IE;
+ 			base = (ubadr_t) addr->dhubar1;
  			/*
  			 * Clists are either:
  			 *	1)  in kernel virtual space,
***************
*** 486,502 ****
  			 *
  			 * 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
! 			/* UCB_CLIST && !UNIBUS_MAP (QBUS) taylor@oswego */
! 			{
! 			ubadr_t base;
! 
! 			base = (ubadr_t) addr->dhubar1 | (ubadr_t)((addr->dhubar2 & 037) << 16);
  			cntr = base - cpaddr(tp->t_outq.c_cf);
- 			}
- #endif
  			ndflush(&tp->t_outq,cntr);
  		}
  		if (tp->t_line)
--- 488,496 ----
  			 *
  			 * In either case, the extension bits are 0.
  			*/
! 			if (!ubmap)
! 				base |= (ubadr_t)((addr->dhubar2 & 037) << 16);
  			cntr = base - cpaddr(tp->t_outq.c_cf);
  			ndflush(&tp->t_outq,cntr);
  		}
  		if (tp->t_line)
***************
*** 575,586 ****
  		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
! 		/* UCB_CLIST && !UNIBUS_MAP (QBUS) taylor@oswego */
! 		addr->dhubar2 = (hiint(car) & 037) | DHU_BA2_DMAGO;
! #endif
  		tp->t_state |= TS_BUSY;
  	}
  out:
--- 569,578 ----
  		addr->dhulcr &= ~DHU_LC_TXABORT;
  		addr->dhubcr = nch;
  		addr->dhubar1 = loint(car);
! 		if (ubmap)
! 			addr->dhubar2 = (hiint(car) & DHU_BA2_XBA) | DHU_BA2_DMAGO;
! 		else
! 			addr->dhubar2 = (hiint(car) & 037) | DHU_BA2_DMAGO;
  		tp->t_state |= TS_BUSY;
  	}
  out:
*** /usr/src/sys/pdpuba/dhv.c.old	Sun Oct 25 17:07:26 1992
--- /usr/src/sys/pdpuba/dhv.c	Sun Jan  3 13:27:09 1993
***************
*** 53,68 ****
  /*
   * DHV's don't have a very good interrupt facility - you get an
   * interrupt when the first character is put into the silo
!  * and nothing after that.  The timout value below is the number
!  * of ticks to wait after that interrupt so we get a reasonably
!  * full silo for our effort.
   */
  
- #define DHV_SILO	256	/* chars */
- #define DHV_RRATE	4000	/* ch/sec, max receive thruput from manual */
- #define DHV_TIMEOUT	((LINEHZ*DHV_SILO)/DHV_RRATE - 1)
- 
- int	dhv_timeout[NDHV];
  char	dhv_hwxon[NDHVLINE];	/* hardware xon/xoff enabled, per line */
  
  /*
--- 53,67 ----
  /*
   * DHV's don't have a very good interrupt facility - you get an
   * interrupt when the first character is put into the silo
!  * and nothing after that.  Previously an attempt was made to
!  * delay a couple of clock ticks with receive interrupts disabled.
!  *
!  * Unfortunately the code was ineffective because the number of ticks
!  * to delay was decremented if a full (90%) or overrun silo was encountered.
!  * After two such events the driver was back in interrupt per character
!  * mode thus wasting/negating the whole effort.
   */
  
  char	dhv_hwxon[NDHVLINE];	/* hardware xon/xoff enabled, per line */
  
  /*
***************
*** 75,88 ****
  
  struct	tty dhv_tty[NDHVLINE];
  int	ndhv = NDHVLINE;
- int	dhv_ie[NDHV];
  int	dhvact;				/* mask of active dhv's */
  int	dhv_rcnt[16];
  int	dhvstart(), ttrstrt();
  long	dhvmctl(),dmtodhv();
- int	dhv_diag = 0;
  
! #if defined(UNIBUS_MAP) || defined(UCB_CLIST)
  extern	ubadr_t clstaddr;
  #define	cpaddr(x)	(clstaddr + (ubadr_t)((x) - (char *)cfree))
  #else
--- 74,85 ----
  
  struct	tty dhv_tty[NDHVLINE];
  int	ndhv = NDHVLINE;
  int	dhvact;				/* mask of active dhv's */
  int	dhv_rcnt[16];
  int	dhvstart(), ttrstrt();
  long	dhvmctl(),dmtodhv();
  
! #if defined(UCB_CLIST)
  extern	ubadr_t clstaddr;
  #define	cpaddr(x)	(clstaddr + (ubadr_t)((x) - (char *)cfree))
  #else
***************
*** 101,108 ****
  	dhvinfo[unit].ui_unit = unit;
  	dhvinfo[unit].ui_addr = addr;
  	dhvinfo[unit].ui_alive = 1;
- 	dhv_ie[unit] = DHV_IE;
- 	dhv_timeout[unit] = DHV_TIMEOUT;
  	return (1);
      }
      return (0);
--- 98,103 ----
***************
*** 135,141 ****
  	tp->t_oproc = dhvstart;
  
  	if ((dhvact&(1<<dhv)) == 0) {
! 		addr->dhvcsr = DHV_SELECT(0) | dhv_ie[dhv];
  		dhvact |= (1<<dhv);
  		/* anything else to configure whole board */
  	}
--- 130,136 ----
  	tp->t_oproc = dhvstart;
  
  	if ((dhvact&(1<<dhv)) == 0) {
! 		addr->dhvcsr = DHV_SELECT(0) | DHV_IE;
  		dhvact |= (1<<dhv);
  		/* anything else to configure whole board */
  	}
***************
*** 159,165 ****
  		continue;
  	    }
  	    tp->t_dev = dev;
! 	    addr->dhvcsr = DHV_SELECT(dev) | dhv_ie[dhv];
  	    if ( addr->dhvstat & DHV_ST_DCD ) tp->t_state |= TS_CARR_ON;
  	    else			      tp->t_state &= ~TS_CARR_ON;
  	    if ( CDWAIT(dev) && (tp->t_state & TS_CARR_ON) == 0 ||
--- 154,160 ----
  		continue;
  	    }
  	    tp->t_dev = dev;
! 	    addr->dhvcsr = DHV_SELECT(dev) | DHV_IE;
  	    if ( addr->dhvstat & DHV_ST_DCD ) tp->t_state |= TS_CARR_ON;
  	    else			      tp->t_state &= ~TS_CARR_ON;
  	    if ( CDWAIT(dev) && (tp->t_state & TS_CARR_ON) == 0 ||
***************
*** 250,265 ****
  /*
   * DHV11 receiver interrupt.
   */
- dhvtimer(dhv)
- 	int dhv;
- {
- register struct dhvdevice *addr = (struct dhvdevice *) dhvinfo[dhv].ui_addr;
- register s;
  
!     s = spltty();
!     addr->dhvcsr = dhv_ie[dhv] = DHV_IE;
!     splx(s);
! }
  
  dhvrint(dhv)
  	int	dhv;
--- 245,252 ----
  /*
   * DHV11 receiver interrupt.
   */
  
! int	dhvwait;
  
  dhvrint(dhv)
  	int	dhv;
***************
*** 269,279 ****
  	register struct dhvdevice *addr;
  	register struct tty *tp0;
  	register struct uba_device *ui;
! 	register line, rcnt = 0;
! 	int overrun = 0, disable = 0;
  
  	ui = &dhvinfo[dhv];
! 	if (ui == 0 || ui->ui_alive == 0)
  		return;
  	addr = (struct dhvdevice *)ui->ui_addr;
  	tp0 = &dhv_tty[dhv<<3];
--- 256,266 ----
  	register struct dhvdevice *addr;
  	register struct tty *tp0;
  	register struct uba_device *ui;
! 	int line, rcnt;
! 	int overrun;
  
  	ui = &dhvinfo[dhv];
! 	if (ui->ui_alive == 0)
  		return;
  	addr = (struct dhvdevice *)ui->ui_addr;
  	tp0 = &dhv_tty[dhv<<3];
***************
*** 281,286 ****
--- 268,275 ----
  	 * Loop fetching characters from the silo for this
  	 * dhv until there are no more in the silo.
  	 */
+ 	rcnt = 0;
+ 	overrun = 0;
  	while ((c = addr->dhvrbuf) & DHV_RB_VALID )
  	{
  		rcnt++;
***************
*** 293,299 ****
  			if (c & DHV_RB_DIAG)
  			{
  			    if ( (c & 0xff) > 0201 )
! 				printf ( "dv%d: diagnostic %o\n",
  							dhv, c & 0xff );
  			    continue;
  			}
--- 282,288 ----
  			if (c & DHV_RB_DIAG)
  			{
  			    if ( (c & 0xff) > 0201 )
! 				printf ( "dhv%d: diagnostic %o\n",
  							dhv, c & 0xff );
  			    continue;
  			}
***************
*** 329,363 ****
  		    if ( (c & DHV_RB_DO) && !overrun )
  		    {
  			overrun = 1;
- 			if ( dhv_timeout[dhv] )
- 			{
  			    /* bit-bucket the que to free the cpu */
! 			    while ( addr->dhvrbuf & DHV_RB_VALID );
! 			    break;
! 			}
! 			else
! 			{
! 				int	j, i, cnt[8];
! 
! 			    /* runaway line - disable */
! 			    for ( i = 0; i < 8; i++ ) cnt[i] = 0;
! 			    while ( (i = addr->dhvrbuf) & DHV_RB_VALID )
! 				cnt[DHV_RX_LINE(i)]++;
! 			    for ( j = i = 0; i < 8; i++ )
! 				if ( cnt[i] > cnt[j] ) j = i;
! 			    tp = tp0 + j;
! 			    ttyflush ( tp, FREAD|FWRITE );
! 			    tp->t_flags |= FLUSHO;
! 			    tp->t_state |= TS_FLUSH;
! 			    addr->dhvcsr = DHV_SELECT(j) | dhv_ie[dhv];
! 			    addr->dhvlcr &= ~(DHV_LC_RXEN|DHV_LC_MODEM);
! 			    dhv_timeout[dhv] = DHV_TIMEOUT;
! 			    if ( dhv_diag )
! 				printf ( "dv%d: line %d disabled\n", dhv, j );
! 			    while ( addr->dhvrbuf & DHV_RB_VALID );
! 			    disable = 1;
! 			    continue;
! 			}
  		    }
  		    if (c & DHV_RB_FE)
  			/*
--- 318,326 ----
  		    if ( (c & DHV_RB_DO) && !overrun )
  		    {
  			overrun = 1;
  			    /* bit-bucket the que to free the cpu */
! 			while ( addr->dhvrbuf & DHV_RB_VALID );
! 			break;
  		    }
  		    if (c & DHV_RB_FE)
  			/*
***************
*** 369,382 ****
  			if ( !(tp->t_flags&RAW) )
  			    c = tp->t_intrc;
  		}
- 		{
  #if NBK > 0
  		if (tp->t_line == NETLDISC) {
  			c &= 0x7f;
  			BKINPUT(c, tp);
  		} else
- 		{
  #endif
  		    if ( !(c & DHV_RB_PE) && dhv_hwxon[(dhv<<3)+line] &&
  			((c & 0x7f) == CSTOP || (c & 0x7f) == CSTART) )
  				continue;
--- 332,344 ----
  			if ( !(tp->t_flags&RAW) )
  			    c = tp->t_intrc;
  		}
  #if NBK > 0
  		if (tp->t_line == NETLDISC) {
  			c &= 0x7f;
  			BKINPUT(c, tp);
  		} else
  #endif
+ 		{
  		    if ( !(c & DHV_RB_PE) && dhv_hwxon[(dhv<<3)+line] &&
  			((c & 0x7f) == CSTOP || (c & 0x7f) == CSTART) )
  				continue;
***************
*** 383,402 ****
  		    (*linesw[tp->t_line].l_rint)(c, tp);
  		}
  	}
! 	if ( !disable && dhv_timeout[dhv] &&
! 		(rcnt > (DHV_SILO*9)/10 || overrun) ) dhv_timeout[dhv]--;
! 	if ( !overrun && dhv_timeout[dhv] > 0 && dhv_ie[dhv] == DHV_IE )
! 	{
! 	    addr->dhvcsr = dhv_ie[dhv] = DHV_CS_TIE;
! 	    timeout ( dhvtimer, (caddr_t) dhv, dhv_timeout[dhv] );
! 	}
! 	if ( overrun && !disable )
! 	    printf("dv%d: silo overflow\n", dhv);
! 	else
! 	{
! 	    for ( line = 0; rcnt; line++ ) rcnt >>= 1;
! 	    dhv_rcnt[line]++;
! 	}
  }
  
  /*
--- 345,374 ----
  		    (*linesw[tp->t_line].l_rint)(c, tp);
  		}
  	}
! 	if	(overrun)
! 		printf("dhv%d: silo overflow\n", dhv);
! 	else if	(rcnt)
! 		{
! 		for	(line = 0; rcnt; line++) rcnt >>= 1;
! 		dhv_rcnt[line]++;
! #ifdef	notnow
! /*
!  * If 16 or less characters were processed from the silo we drop
!  * priority to 4 which will block further DHV interrupts but allow
!  * clock and most disc interrupts to occur.  Then a small (~ 1ms)
!  * delay is done and the interrupt dismissed.  Best that can be done
!  * since delaying for any number of whole clock ticks seems to cause
!  * problems.
! */
! 		if	(line <= 4)
! 			{
! 			c = spl4();	/* DHV is a spl4 device */
! 			delay(1000L);	/* try a 1 ms delay */
! 			dhvwait++;
! 			splx(c);
! 			}
! #endif
! 		}
  }
  
  /*
***************
*** 535,541 ****
  	}
  	if ((tp->t_ospeed) == B110)
  		lpar |= DHV_LP_TWOSB;
! 	addr->dhvcsr = DHV_SELECT(unit) | dhv_ie[unit>>3];
  	addr->dhvlpr = lpar;
  	dhv_hwxon[unit] = !(tp->t_flags & RAW) &&
  		(tp->t_line == OTTYDISC || tp->t_line == NTTYDISC) &&
--- 507,513 ----
  	}
  	if ((tp->t_ospeed) == B110)
  		lpar |= DHV_LP_TWOSB;
! 	addr->dhvcsr = DHV_SELECT(unit) | DHV_IE;
  	addr->dhvlpr = lpar;
  	dhv_hwxon[unit] = !(tp->t_flags & RAW) &&
  		(tp->t_line == OTTYDISC || tp->t_line == NTTYDISC) &&
***************
*** 565,570 ****
--- 537,543 ----
  	register struct uba_device *ui;
  	register int line, t;
  	u_short cntr;
+ 	ubadr_t base;
  
  	ui = &dhvinfo[dhv];
  	tp0 = &dhv_tty[dhv<<4];
***************
*** 580,586 ****
  		if (tp->t_state&TS_FLUSH)
  			tp->t_state &= ~TS_FLUSH;
  		else {
! 			addr->dhvcsrl = DHV_SELECT(line) | dhv_ie[dhv];
  			/*
  			 * Clists are either:
  			 *	1)  in kernel virtual space,
--- 553,560 ----
  		if (tp->t_state&TS_FLUSH)
  			tp->t_state &= ~TS_FLUSH;
  		else {
! 			addr->dhvcsrl = DHV_SELECT(line) | DHV_IE;
! 			base = (ubadr_t) addr->dhvbar1;
  			/*
  			 * Clists are either:
  			 *	1)  in kernel virtual space,
***************
*** 590,606 ****
  			 *
  			 * In either case, the extension bits are 0.
  			 */
! #if !defined(UCB_CLIST) || defined(UNIBUS_MAP)
! 			cntr = addr->dhvbar1 - cpaddr(tp->t_outq.c_cf);
! #else
! 			/* UCB_CLIST && !UNIBUS_MAP (QBUS) taylor@oswego */
! 			{
! 			ubadr_t base;
! 
! 			base = (ubadr_t) addr->dhvbar1 | (ubadr_t)((addr->dhvbar2 & 037) << 16);
! 			cntr = base - cpaddr(tp->t_outq.c_cf);
! 			}
! #endif
  			ndflush(&tp->t_outq,cntr);
  		}
  		if (tp->t_line)
--- 564,572 ----
  			 *
  			 * In either case, the extension bits are 0.
  			 */
! 			if (!ubmap)
! 			      base |= (ubadr_t)((addr->dhvbar2 & 037) << 16);
! 		        cntr = base - cpaddr(tp->t_outq.c_cf);
  			ndflush(&tp->t_outq,cntr);
  		}
  		if (tp->t_line)
***************
*** 674,689 ****
  	 */
  	if (nch) {
  		car = cpaddr(tp->t_outq.c_cf);
! 		addr->dhvcsrl = DHV_SELECT(unit) | dhv_ie[unit>>3];
  		addr->dhvlcr &= ~DHV_LC_TXABORT;
  		addr->dhvbcr = nch;
  		addr->dhvbar1 = loint(car);
! #if !defined(UCB_CLIST) || defined(UNIBUS_MAP)
! 		addr->dhvbar2 = (hiint(car) & DHV_BA2_XBA) | DHV_BA2_DMAGO;
! #else
! 		/* UCB_CLIST && !UNIBUS_MAP (QBUS) taylor@oswego */
! 		addr->dhvbar2 = (hiint(car) & 037) | DHV_BA2_DMAGO;
! #endif
  		tp->t_state |= TS_BUSY;
  	}
  out:
--- 640,653 ----
  	 */
  	if (nch) {
  		car = cpaddr(tp->t_outq.c_cf);
! 		addr->dhvcsrl = DHV_SELECT(unit) | DHV_IE;
  		addr->dhvlcr &= ~DHV_LC_TXABORT;
  		addr->dhvbcr = nch;
  		addr->dhvbar1 = loint(car);
! 		if (ubmap)
! 			addr->dhvbar2 = (hiint(car) & DHV_BA2_XBA) | DHV_BA2_DMAGO;
! 		else
! 			addr->dhvbar2 = (hiint(car) & 037) | DHV_BA2_DMAGO;
  		tp->t_state |= TS_BUSY;
  	}
  out:
***************
*** 716,722 ****
  		 * In either case, dhvstart will clear the TXABORT bit.
  		 */
  		unit = UNIT(tp->t_dev);
! 		addr->dhvcsrl = DHV_SELECT(unit) | dhv_ie[unit>>3];
  		addr->dhvlcr |= DHV_LC_TXABORT;
  		delay(25L); /* see the dhv manual, sec 3.3.6 */
  		addr->dhvlcr2 |= DHV_LC2_TXEN;
--- 680,686 ----
  		 * In either case, dhvstart will clear the TXABORT bit.
  		 */
  		unit = UNIT(tp->t_dev);
! 		addr->dhvcsrl = DHV_SELECT(unit) | DHV_IE;
  		addr->dhvlcr |= DHV_LC_TXABORT;
  		delay(25L); /* see the dhv manual, sec 3.3.6 */
  		addr->dhvlcr2 |= DHV_LC2_TXEN;
***************
*** 745,751 ****
  	tp = dhv_tty + unit;
  	dhvaddr = (struct dhvdevice *) tp->t_addr;
  	s = spltty();
! 	dhvaddr->dhvcsr = DHV_SELECT(unit) | dhv_ie[unit>>3];
  	/*
  	 * combine byte from stat register (read only, bits 16..23)
  	 * with lcr register (read write, bits 0..15).
--- 709,715 ----
  	tp = dhv_tty + unit;
  	dhvaddr = (struct dhvdevice *) tp->t_addr;
  	s = spltty();
! 	dhvaddr->dhvcsr = DHV_SELECT(unit) | DHV_IE;
  	/*
  	 * combine byte from stat register (read only, bits 16..23)
  	 * with lcr register (read write, bits 0..15).
*** /usr/src/sys/pdpuba/dr.c.old	Sun Sep 22 08:36:38 1991
--- /usr/src/sys/pdpuba/dr.c	Sat Jan  2 23:28:15 1993
***************
*** 3,9 ****
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)dr.c	1.2 (2.11BSD Berkeley) 9/22/91
   */
  
  /*
--- 3,9 ----
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)dr.c	1.3 (2.11BSD GTE) 1/2/93
   */
  
  /*
***************
*** 105,113 ****
  	bp->av_forw = NULL;
  	s = splbio();			/* lock out interrupts */
  
- #ifdef	UNIBUS_MAP
  	mapalloc(bp);
- #endif	UNIBUS_MAP
  
  	if(dp->b_actf == NULL)		/* if nothing in current buffer */
  		dp->b_actf = bp;	/* this request is first */
--- 105,111 ----
*** /usr/src/sys/pdpuba/hk.c.old	Sun Sep 22 08:37:08 1991
--- /usr/src/sys/pdpuba/hk.c	Tue Dec 29 22:29:57 1992
***************
*** 3,9 ****
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)hk.c	1.l (2.11BSD Berkeley) 9/22/91
   */
  
  /*
--- 3,9 ----
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)hk.c	2.0 (2.11BSD GTE) 12/29/92
   */
  
  /*
***************
*** 11,26 ****
   *
   * This driver mimics the 4.1bsd rk driver.
   * It does overlapped seeks, ECC, and bad block handling.
   *
-  * salkind@nyu
-  */
- 
- /*
   * Modified to correctly handle 22 bit addressing available on DILOG
!  * DQ615 controller.
   *
!  * 05/31/90 -- tymann@oswego.edu
!  *
   */
  
  #include "hk.h"
--- 11,27 ----
   *
   * This driver mimics the 4.1bsd rk driver.
   * It does overlapped seeks, ECC, and bad block handling.
+  * 	salkind@nyu
   *
   * Modified to correctly handle 22 bit addressing available on DILOG
!  * DQ615 controller. 05/31/90 -- tymann@oswego.edu
   *
!  * Removed ifdefs on both Q22 and UNIBUS_MAP, substituting a runtime
!  * test for presence of a Unibus Map.  Reworked the partition logic,
!  * the 'e' partiton no longer overlaps the 'a'+'b' partitions - a separate
!  * 'b' partition is now present.  Old root filesystems can still be used
!  * because the size is the same, but user data will have to be saved and
!  * then reloaded.  12/28/92 -- sms@wlv.iipo.gtegsc.com
   */
  
  #include "hk.h"
***************
*** 35,40 ****
--- 36,42 ----
  #include "hkreg.h"
  #include "dkbad.h"
  #include "dk.h"
+ #include "syslog.h"
  
  #define	NHK7CYL	815
  #define	NHK6CYL	411
***************
*** 46,69 ****
  struct size {
  	daddr_t	nblocks;
  	int	cyloff;
! } hk_sizes[8] = {
! 	5940,	0,	/* a: cyl   0 -  89 */
! 	2376,	90,	/* b: cyl  90 - 125 */
! 	45474,	126,	/* c: cyl 126 - 814 */
! 	18810,	126,	/* d: cyl 126 - 410 */
! 	8316,	0,	/* e: cyl   0 - 125, overlaps a & b */
  	0,	0,	/* f: Not Defined */
! 	27126,	0,	/* g: cyl   0 - 410, whole RK06 */
! 	53790,	0	/* h: cyl   0 - 814, whole RK07 */
  };
  
! int	hkpip;		/* DEBUG */
! int	hknosval;	/* DEBUG */
! #ifdef HKDEBUG
! int	hkdebug = 1;
! #endif
! 
! int	hk_offset[] =
  {
  	HKAS_P400,	HKAS_M400,	HKAS_P400,	HKAS_M400,
  	HKAS_P800,	HKAS_M800,	HKAS_P800,	HKAS_M800,
--- 48,78 ----
  struct size {
  	daddr_t	nblocks;
  	int	cyloff;
! } hk6_sizes[8] =
! 	{
! 	8316,	0,	/* a: cyl    0 - 125 */
! 	8316,	90,	/* b: cyl  126 - 251 */
! 	27126,	0,	/* c: cyl    0 - 410, whole RK06 */
! 	0,	0,	/* d: Not Defined */
! 	0,	0,	/* e: Not Defined */
  	0,	0,	/* f: Not Defined */
! 	10428,	252,	/* g: cyl  252 - 409 */
! 	27126,	0,	/* h: cyl   0 - 409, whole RK06 less 1 track */
! 	},
! hk7_sizes[8] =
! 	{
! 	8316,	0,	/* a: cyl   0 -  125 */
! 	8316,	126,	/* b: cyl  126 - 251 */
! 	53790,	0,	/* c: cyl   0 - 814, whole RK07 */
! 	0,	0,	/* d: Not Defined */
! 	0,	0,	/* e: Not Defined */
! 	0,	0,	/* f: Not Defined */
! 	37092,	0,	/* g: cyl   252 - 813 */
! 	53724,	0	/* h: cyl   0 - 813, whole RK07 less 1 track */
  };
  
! /* Can be u_char because all are less than 0377 */
! u_char	hk_offset[] =
  {
  	HKAS_P400,	HKAS_M400,	HKAS_P400,	HKAS_M400,
  	HKAS_P800,	HKAS_M800,	HKAS_P800,	HKAS_M800,
***************
*** 73,79 ****
  
  int	hk_type[NHK];
  int	hk_cyl[NHK];
! char	hk_mntflg[NHK];
  char	hk_pack[NHK];
  
  struct hk_softc {
--- 82,88 ----
  
  int	hk_type[NHK];
  int	hk_cyl[NHK];
! struct	size *hk_sizes[NHK];
  char	hk_pack[NHK];
  
  struct hk_softc {
***************
*** 94,100 ****
  
  #define	hkwait(hkaddr)		while ((hkaddr->hkcs1 & HK_CRDY) == 0)
  #define	hkncyl(unit)		(hk_type[unit] ? NHK7CYL : NHK6CYL)
! #define	hkunit(dev)		((minor(dev) >> 3) & 07)
  
  void
  hkroot()
--- 103,109 ----
  
  #define	hkwait(hkaddr)		while ((hkaddr->hkcs1 & HK_CRDY) == 0)
  #define	hkncyl(unit)		(hk_type[unit] ? NHK7CYL : NHK6CYL)
! #define	hkunit(dev)		(((dev) >> 3) & 07)
  
  void
  hkroot()
***************
*** 118,138 ****
  	return(1);
  }
  
! hkopen(dev)
  	dev_t dev;
  {
  	register int unit = hkunit(dev);
  
  	if (unit >= NHK || !HKADDR)
  		return (ENXIO);
- 	return (0);
- }
  
- hkdsel(unit)
- register unit;
- {
- 	register struct hkdevice *hkaddr = HKADDR;
- 
  	hk_type[unit] = 0;
  	hkaddr->hkcs1 = HK_CCLR;
  	hkaddr->hkcs2 = unit;
--- 127,142 ----
  	return(1);
  }
  
! hkopen(dev, flag)
  	dev_t dev;
+ 	int flag;
  {
  	register int unit = hkunit(dev);
+ 	register struct hkdevice *hkaddr = HKADDR;
  
  	if (unit >= NHK || !HKADDR)
  		return (ENXIO);
  
  	hk_type[unit] = 0;
  	hkaddr->hkcs1 = HK_CCLR;
  	hkaddr->hkcs2 = unit;
***************
*** 141,155 ****
  	if((hkaddr->hkcs2&HKCS2_NED) || (hkaddr->hkds&HKDS_SVAL) == 0) {
  		hkaddr->hkcs1 = HK_CCLR;
  		hkwait(hkaddr);
! 		return(-1);
  	}
  	if((hkaddr->hkcs1&HK_CERR) && (hkaddr->hker&HKER_DTYE)) {
  		hk_type[unit] = HK_CDT;
  		hkaddr->hkcs1 = HK_CCLR;
  		hkwait(hkaddr);
  	}
! 
! 	hk_mntflg[unit] = 1;
  	hk_cyl[unit] = -1;
  	return(0);
  }
--- 145,160 ----
  	if((hkaddr->hkcs2&HKCS2_NED) || (hkaddr->hkds&HKDS_SVAL) == 0) {
  		hkaddr->hkcs1 = HK_CCLR;
  		hkwait(hkaddr);
! 		return(ENXIO);
  	}
  	if((hkaddr->hkcs1&HK_CERR) && (hkaddr->hker&HKER_DTYE)) {
  		hk_type[unit] = HK_CDT;
  		hkaddr->hkcs1 = HK_CCLR;
  		hkwait(hkaddr);
+ 		hk_sizes[unit] = hk7_sizes;
  	}
! 	else
! 		hk_sizes[unit] = hk6_sizes;
  	hk_cyl[unit] = -1;
  	return(0);
  }
***************
*** 159,188 ****
  {
  	register struct buf *dp;
  	register unit;
! 	int s;
  	long bn;
  	long sz;
  
! 	unit = minor(bp->b_dev) & 077;
! 	if ((unit >= (NHK << 3)) || (HKADDR == (struct hkdevice *) NULL)) {
  		bp->b_error = ENXIO;
  		goto bad;
  	}
  	sz = (bp->b_bcount + (NBPG-1)) >> PGSHIFT;
! 	if (bp->b_blkno < 0 || (bn = dkblock(bp))+sz > hk_sizes[unit & 07].nblocks) {
  		bp->b_error = EINVAL;
  		goto bad;
  	}
! 	bp->b_cylin = bn / HK_NSPC + hk_sizes[unit & 07].cyloff;
! 	unit = dkunit(bp);
! 	if (hk_mntflg[unit] == 0) {
! 		/* SHOULD BE DONE AT BOOT TIME */
! 		if (hkdsel(unit) < 0)
! 			goto bad;
! 	}
! #ifdef UNIBUS_MAP
  	mapalloc(bp);
- #endif
  	dp = &hkutab[unit];
  	s = splbio();
  	disksort(dp, bp);
--- 164,187 ----
  {
  	register struct buf *dp;
  	register unit;
! 	int s, part;
  	long bn;
  	long sz;
+ 	struct size *szp;
  
! 	unit = dkunit(bp);
! 	part = bp->b_dev & 7;
! 	if (unit >= NHK || !HKADDR  || !(szp = hk_sizes[unit])) {
  		bp->b_error = ENXIO;
  		goto bad;
  	}
  	sz = (bp->b_bcount + (NBPG-1)) >> PGSHIFT;
! 	if (bp->b_blkno < 0 || (bn = dkblock(bp))+sz > szp[part].nblocks) {
  		bp->b_error = EINVAL;
  		goto bad;
  	}
! 	bp->b_cylin = bn / HK_NSPC + szp[part].cyloff;
  	mapalloc(bp);
  	dp = &hkutab[unit];
  	s = splbio();
  	disksort(dp, bp);
***************
*** 205,212 ****
  	register struct buf *bp, *dp;
  	int didie = 0;
  
- 	if (unit >= NHK || hk_mntflg[unit] == 0)
- 		return(0);
  #ifdef UCB_METER
  	if (hk_dkn >= 0)
  		dk_busy &= ~(1 << (hk_dkn + unit));
--- 204,209 ----
***************
*** 242,250 ****
  		bbp->b_un.b_addr = (caddr_t)&hkbad[unit];
  		bbp->b_blkno = (long)hkncyl(unit)*HK_NSPC - HK_NSECT;
  		bbp->b_cylin = hkncyl(unit) - 1;
- #ifdef UNIBUS_MAP
  		mapalloc(bbp);
- #endif
  		dp->b_actf = bbp;
  		bbp->av_forw = bp;
  		bp = bbp;
--- 239,245 ----
***************
*** 311,326 ****
  	hkaddr->hkcs1 = hk_type[unit] | HK_DCLR | HK_GO;
  	hkwait(hkaddr);
  
! 	if ((hkaddr->hkds & HKDS_SVAL) == 0) {
! 		hknosval++;
  		goto nosval;
! 	}
! 	if (hkaddr->hkds & HKDS_PIP) {
! 		hkpip++;
  		goto retry;
- 	}
  	if ((hkaddr->hkds&HKDS_DREADY) != HKDS_DREADY) {
! 		printf("hk%d: not ready", unit);
  		if ((hkaddr->hkds&HKDS_DREADY) != HKDS_DREADY) {
  			printf("\n");
  			hkaddr->hkcs1 = hk_type[unit] | HK_DCLR | HK_GO;
--- 306,317 ----
  	hkaddr->hkcs1 = hk_type[unit] | HK_DCLR | HK_GO;
  	hkwait(hkaddr);
  
! 	if ((hkaddr->hkds & HKDS_SVAL) == 0)
  		goto nosval;
! 	if (hkaddr->hkds & HKDS_PIP)
  		goto retry;
  	if ((hkaddr->hkds&HKDS_DREADY) != HKDS_DREADY) {
! 		log(LOG_WARNING, "hk%d: not ready\n", unit);
  		if ((hkaddr->hkds&HKDS_DREADY) != HKDS_DREADY) {
  			printf("\n");
  			hkaddr->hkcs1 = hk_type[unit] | HK_DCLR | HK_GO;
***************
*** 335,342 ****
  			iodone(bp);
  			goto loop;
  		}
- 		else
- 			printf(" (came back!)\n");
  	}
  nosval:
  	hkaddr->hkcyl = bp->b_cylin;
--- 326,331 ----
***************
*** 344,355 ****
  	hkaddr->hkda = (tn << 8) + sn;
  	hkaddr->hkwc = -(bp->b_bcount >> 1);
  	hkaddr->hkba = bp->b_un.b_addr;
  
- #ifdef Q22
-         /* modification for 22 bit addressing -- tymann@oswego.edu */
- 	hkaddr->hkxmem=bp->b_xmem;
- #endif
- 
  	cmd = hk_type[unit] | ((bp->b_xmem & 3) << 8) | HK_IE | HK_GO;
  	if (bp->b_flags & B_READ)
  		cmd |= HK_READ;
--- 333,341 ----
  	hkaddr->hkda = (tn << 8) + sn;
  	hkaddr->hkwc = -(bp->b_bcount >> 1);
  	hkaddr->hkba = bp->b_un.b_addr;
+ 	if	(!ubmap)
+ 		hkaddr->hkxmem=bp->b_xmem;
  
  	cmd = hk_type[unit] | ((bp->b_xmem & 3) << 8) | HK_IE | HK_GO;
  	if (bp->b_flags & B_READ)
  		cmd |= HK_READ;
***************
*** 395,415 ****
  			u_short ds = hkaddr->hkds;
  			u_short cs2 = hkaddr->hkcs2;
  			u_short er = hkaddr->hker;
! #ifdef HKDEBUG
! 			if (hkdebug) {
! 				printf("cs2=%b ds=%b er=%b\n",
! 				    cs2, HKCS2_BITS, ds, 
! 				    HKDS_BITS, er, HKER_BITS);
! 			}
! #endif
  			if (er & HKER_WLE) {
! 				printf("hk%d: write locked\n", unit);
  				bp->b_flags |= B_ERROR;
  			} else if (++hktab.b_errcnt > 28 ||
  			    ds&HKDS_HARD || er&HKER_HARD || cs2&HKCS2_HARD) {
  hard:
  				harderr(bp, "hk");
! 				printf("cs2=%b ds=%b er=%b\n",
  				    cs2, HKCS2_BITS, ds, 
  				    HKDS_BITS, er, HKER_BITS);
  				bp->b_flags |= B_ERROR;
--- 381,395 ----
  			u_short ds = hkaddr->hkds;
  			u_short cs2 = hkaddr->hkcs2;
  			u_short er = hkaddr->hker;
! 
  			if (er & HKER_WLE) {
! 				log(LOG_WARNING, "hk%d: write locked\n", unit);
  				bp->b_flags |= B_ERROR;
  			} else if (++hktab.b_errcnt > 28 ||
  			    ds&HKDS_HARD || er&HKER_HARD || cs2&HKCS2_HARD) {
  hard:
  				harderr(bp, "hk");
! 				log(LOG_WARNING, "cs2=%b ds=%b er=%b\n",
  				    cs2, HKCS2_BITS, ds, 
  				    HKDS_BITS, er, HKER_BITS);
  				bp->b_flags |= B_ERROR;
***************
*** 488,494 ****
  	}
  	for (unit = 0; as; as >>= 1, unit++)
  		if (as & 1) {
! 			if (unit < NHK && hk_mntflg[unit]) {
  				if (hkustart(unit))
  					needie = 0;
  			} else {
--- 468,474 ----
  	}
  	for (unit = 0; as; as >>= 1, unit++)
  		if (as & 1) {
! 			if (unit < NHK && hk_sizes[unit]) {
  				if (hkustart(unit))
  					needie = 0;
  			} else {
***************
*** 512,522 ****
   *  Dumps from dumplo to end of memory/end of disk section for minor(dev).
   *  It uses the UNIBUS map to dump all of memory if there is a UNIBUS map.
   */
- #ifdef UNIBUS_MAP
  #define	DBSIZE	(UBPAGE/NBPG)		/* unit of transfer, one UBPAGE */
- #else
- #define DBSIZE	16			/* unit of transfer, same number */
- #endif
  
  hkdump(dev)
  	dev_t dev;
--- 492,498 ----
***************
*** 525,540 ****
  	daddr_t	bn, dumpsize;
  	long paddr;
  	register count;
- #ifdef UNIBUS_MAP
  	register struct ubmap *ubp;
- #endif
  	int com, cn, tn, sn, unit;
  
! 	unit = minor(dev) >> 3;
! 	if ((bdevsw[major(dev)].d_strategy != hkstrategy)	/* paranoia */
! 	    || unit >= NHK)
  		return(EINVAL);
! 	dumpsize = hk_sizes[minor(dev)&07].nblocks;
  	if ((dumplo < 0) || (dumplo >= dumpsize))
  		return(EINVAL);
  	dumpsize -= dumplo;
--- 501,515 ----
  	daddr_t	bn, dumpsize;
  	long paddr;
  	register count;
  	register struct ubmap *ubp;
  	int com, cn, tn, sn, unit;
+ 	struct size *szp;
  
! 	unit = hkunit(dev);
! 	szp = hk_sizes[unit];
! 	if (unit >= NHK || !szp)
  		return(EINVAL);
! 	dumpsize = szp[dev & 7]->nblocks;
  	if ((dumplo < 0) || (dumplo >= dumpsize))
  		return(EINVAL);
  	dumpsize -= dumplo;
***************
*** 548,560 ****
  		hkaddr->hkcs1 = hk_type[unit]|HK_IE|HK_PACK|HK_GO;
  		hkwait(hkaddr);
  	}
- #ifdef UNIBUS_MAP
  	ubp = &UBMAP[0];
- #endif
  	for (paddr = 0L; dumpsize > 0; dumpsize -= count) {
  		count = dumpsize>DBSIZE? DBSIZE: dumpsize;
  		bn = dumplo + (paddr >> PGSHIFT);
! 		cn = (bn/HK_NSPC) + hk_sizes[minor(dev)&07].cyloff;
  		sn = bn%HK_NSPC;
  		tn = sn/HK_NSECT;
  		sn = sn%HK_NSECT;
--- 523,533 ----
  		hkaddr->hkcs1 = hk_type[unit]|HK_IE|HK_PACK|HK_GO;
  		hkwait(hkaddr);
  	}
  	ubp = &UBMAP[0];
  	for (paddr = 0L; dumpsize > 0; dumpsize -= count) {
  		count = dumpsize>DBSIZE? DBSIZE: dumpsize;
  		bn = dumplo + (paddr >> PGSHIFT);
! 		cn = (bn/HK_NSPC) + szp[dev & 7]->cyloff;
  		sn = bn%HK_NSPC;
  		tn = sn/HK_NSECT;
  		sn = sn%HK_NSECT;
***************
*** 562,589 ****
  		hkaddr->hkda = (tn << 8) | sn;
  		hkaddr->hkwc = -(count << (PGSHIFT-1));
  		com = hk_type[unit]|HK_GO|HK_WRITE;
- #ifdef UNIBUS_MAP
- 		/*
- 		 *  If UNIBUS_MAP exists, use the map.
- 		 */
  		if (ubmap) {
  			ubp->ub_lo = loint(paddr);
  			ubp->ub_hi = hiint(paddr);
  			hkaddr->hkba = 0;
  		} else {
- #endif
  			/* non UNIBUS map */
  			hkaddr->hkba = loint(paddr);
- 
- #ifdef Q22
- 			/* mod for 22 bit addressing -- tymann@oswego.edu */
  			hkaddr->hkxmem = hiint(paddr);
- #endif
- 
  			com |= ((paddr >> 8) & (03 << 8));
- #ifdef UNIBUS_MAP
  		}
- #endif
  		hkaddr->hkcs2 = unit;
  		hkaddr->hkcs1 = com;
  		hkwait(hkaddr);
--- 535,550 ----
***************
*** 648,660 ****
  		long mask;
  		ubadr_t bb;
  		unsigned o;
- #ifdef	UNIBUS_MAP
  		struct ubmap *ubp;
- #endif
- 		printf("hk%d%c:  soft ecc sn %D\n",
- 			unit, 'a' + (minor(bp->b_dev) & 07),
- 			bp->b_blkno + npx - 1);
  
  		mask = hkaddr->hkecpt;
  		byte = hkaddr->hkecps - 1;
  		bit = byte & 07;
--- 609,618 ----
  		long mask;
  		ubadr_t bb;
  		unsigned o;
  		struct ubmap *ubp;
  
+ 		log(LOG_WARNING, "hk%d%c:  soft ecc sn %D\n",
+ 			unit, 'a' + (bp->b_dev & 07), bp->b_blkno + npx - 1);
  		mask = hkaddr->hkecpt;
  		byte = hkaddr->hkecps - 1;
  		bit = byte & 07;
***************
*** 663,674 ****
  		o = (ndone - NBPG) + byte;
  		bb = exadr(bp->b_xmem, bp->b_un.b_addr);
  		bb += o;
! #ifdef	UNIBUS_MAP
! 		if (bp->b_flags & (B_MAP|B_UBAREMAP))	{
  			ubp = UBMAP + ((bb >> 13) & 037);
  			bb = exadr(ubp->ub_hi, ubp->ub_lo) + (bb & 017777);
  		}
- #endif
  		/*
  		 * Correct until mask is zero or until end of
  		 * sector or transfer, whichever comes first.
--- 621,630 ----
  		o = (ndone - NBPG) + byte;
  		bb = exadr(bp->b_xmem, bp->b_un.b_addr);
  		bb += o;
! 		if (ubmap && (bp->b_flags & (B_MAP|B_UBAREMAP))) {
  			ubp = UBMAP + ((bb >> 13) & 037);
  			bb = exadr(ubp->ub_hi, ubp->ub_lo) + (bb & 017777);
  		}
  		/*
  		 * Correct until mask is zero or until end of
  		 * sector or transfer, whichever comes first.
***************
*** 687,697 ****
  
  #ifdef BADSECT
  	case BSE:
- #ifdef HKDEBUG
- 		if (hkdebug)
- 			printf("hkecc, BSE: bn %D cn %d tn %d sn %d\n",
- 				bn, cn, tn, sn);
- #endif
  		if ((bn = isbad(&hkbad[unit], cn, tn, sn)) < 0)
  			return(0);
  		bp->b_flags |= B_BAD;
--- 643,648 ----
***************
*** 701,710 ****
  		sn = bn%HK_NSPC;
  		tn = sn/HK_NSECT;
  		sn %= HK_NSECT;
- #ifdef HKDEBUG
- 		if (hkdebug)
- 			printf("revector to cn %d tn %d sn %d\n", cn, tn, sn);
- #endif
  		wc = -(NBPG / NBPW);
  		break;
  
--- 652,657 ----
***************
*** 712,722 ****
  		bp->b_flags &= ~B_BAD;
  		if (wc == 0)
  			return(0);
- #ifdef HKDEBUG
- 		if (hkdebug)
- 			printf("hkecc, CONT: bn %D cn %d tn %d sn %d\n",
- 				bn, cn, tn, sn);
- #endif
  		break;
  #endif BADSECT
  	}
--- 659,664 ----
***************
*** 738,748 ****
  	hkaddr->hkwc = wc;
  	hkaddr->hkba = (caddr_t)addr;
  
! #ifdef Q22
! 	/* modification to handle 18-22 bit addressing -- tymann@oswego.edu */
! 	hkaddr->hkxmem=hiint(addr);
! #endif
! 
  	cmd = hk_type[unit] | ((hiint(addr) & 3) << 8) | HK_IE | HK_GO;
  	if (bp->b_flags & B_READ)
  		cmd |= HK_READ;
--- 680,687 ----
  	hkaddr->hkwc = wc;
  	hkaddr->hkba = (caddr_t)addr;
  
! 	if	(!ubmap)
! 		hkaddr->hkxmem=hiint(addr);
  	cmd = hk_type[unit] | ((hiint(addr) & 3) << 8) | HK_IE | HK_GO;
  	if (bp->b_flags & B_READ)
  		cmd |= HK_READ;
***************
*** 752,755 ****
--- 691,709 ----
  	hktab.b_errcnt = 0;	/* error has been corrected */
  	return (1);
  }
+ 
+ /*
+  * Assumes the 'open' entry point has already been called to validate
+  * the unit number.
+ */
+ daddr_t
+ hksize(dev)
+ 	register dev_t dev;
+ 	{
+ 	register struct size *szp = hk_sizes[hkunit(dev)];
+ 
+ 	if	(!szp)
+ 		return(-1);
+ 	return(szp[dev & 7].nblocks);
+ 	}
  #endif NHK > 0
*** /usr/src/sys/pdpuba/ht.c.old	Sun Sep 22 08:37:43 1991
--- /usr/src/sys/pdpuba/ht.c	Sat Jan  2 23:29:35 1993
***************
*** 3,9 ****
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)ht.c	2.1 (2.11BSD) 9/22/91
   */
  
  /*
--- 3,9 ----
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)ht.c	2.2 (2.11BSD GTE) 1/2/93
   */
  
  /*
***************
*** 172,181 ****
  	register int s;
  	register struct softc *sc = &tu_softc[TUUNIT(bp->b_dev)];
  
- #ifdef	UNIBUS_MAP
  	if (rh70 == 0)
  		mapalloc(bp);
- #endif
  	if (bp->b_flags & B_PHYS) {
  		sc->sc_blkno = sc->sc_nxrec = dbtofsb(bp->b_blkno);
  		sc->sc_nxrec++;
--- 172,179 ----
*** /usr/src/sys/pdpuba/ra.c.old	Fri Nov 20 23:20:09 1992
--- /usr/src/sys/pdpuba/ra.c	Sat Jan  2 23:09:46 1993
***************
*** 3,9 ****
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)ra.c	2.2 (2.11BSD GTE) 7/11/92
   */
  
   /***********************************************************************
--- 3,9 ----
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)ra.c	2.4 (2.11BSD GTE) 1/2/93
   */
  
   /***********************************************************************
***************
*** 14,19 ****
--- 14,23 ----
  
  /* 
   * ra.c - MSCP Driver
+  * Date:	Dec 1992, Jan 1993
+  * Add the partition size routine.  Remove unibus map ifdefs, the run time
+  * check for 'ubmap' is sufficient and does the right thing.
+  *
   * Date:	Nov 1992
   * Add raVec() routine.  This is called by autoconfig to set the vector
   * (from /etc/dtab) for controllers other than the root (1st).  The boot/root
***************
*** 542,551 ****
  	    || disk->ra_size[part].blkoff >= disk->ra_dsize)
  		goto bad;
  
! #ifdef UNIBUS_MAP
! 	/* Get unibus map if we need it */
  	mapalloc(bp);
- #endif
  
  	/*
  	 * Link the buffer onto the drive queue
--- 546,553 ----
  	    || disk->ra_size[part].blkoff >= disk->ra_dsize)
  		goto bad;
  
! 	/* Unibus Map buffer if required */
  	mapalloc(bp);
  
  	/*
  	 * Link the buffer onto the drive queue
***************
*** 1204,1212 ****
   * RA dump routines (act like stand alone driver)
   */
  #ifdef RA_DUMP
  
- #define DBSIZE	16			/* unit of transfer, same number */
- 
  radump(dev)
  	dev_t dev;
  {
--- 1206,1213 ----
   * RA dump routines (act like stand alone driver)
   */
  #ifdef RA_DUMP
+ #define DBSIZE	16			/* number of blocks to write */
  
  radump(dev)
  	dev_t dev;
  {
***************
*** 1217,1225 ****
  	daddr_t	bn, dumpsize;
  	long paddr, maddr;
  	int count;
- #ifdef	UNIBUS_MAP
  	struct ubmap *ubp;
- #endif
  	int 	unit, partition;
  	segm	seg5;
  
--- 1218,1224 ----
***************
*** 1233,1245 ****
  
  	/* Init RA controller */
  	paddr = _iomap(ra_com[sc->sc_unit]);
- #ifdef	UNIBUS_MAP
  	if (ubmap) {
  		ubp = UBMAP;
  		ubp->ub_lo = loint(paddr);
  		ubp->ub_hi = hiint(paddr);
  	}
- #endif
  
  	/* Get communications area and clear out packets */
  	paddr += RINGBASE;
--- 1232,1242 ----
***************
*** 1287,1295 ****
  	dumpsize -= dumplo;
  
  	/* Save core to dump partition */
- #ifdef	UNIBUS_MAP
  	ubp = &UBMAP[1];
- #endif
  	for (paddr = 0L; dumpsize > 0; dumpsize -= count) {
  		count = MIN(dumpsize, DBSIZE);
  		bn = dumplo + (paddr >> PGSHIFT)
--- 1284,1290 ----
***************
*** 1296,1311 ****
  			+ disk->ra_size[partition].blkoff;
  		maddr = paddr;
  
- #ifdef	UNIBUS_MAP
- 		/*
- 		 *  If UNIBUS_MAP exists, use the map.
- 		 */
  		if (ubmap) {
  			ubp->ub_lo = loint(paddr);
  			ubp->ub_hi = hiint(paddr);
  			maddr = (u_int)(1 << 13);
  		}
- #endif
  
  		/* Write it to the disk */
  		mp = &sc->sc_com->ra_rsp[1];
--- 1291,1301 ----
***************
*** 1359,1362 ****
--- 1349,1367 ----
  	return(rmp);
  }
  #endif RA_DUMP
+ 
+ /*
+  * Assumes the 'open' routine has already been called to bring the
+  * drive online and initialize the drive size structures.
+ */
+ daddr_t
+ rasize(dev)
+ 	register dev_t dev;
+ 	{
+ 	ra_softcT *sc = &ra_sc[RACON(dev)];
+ 	register ra_infoT *disk;
+ 
+ 	disk = sc->sc_drives[RAUNIT(dev)];
+ 	return(disk->ra_size[dev & 7].nblocks);
+ 	}
  #endif NRAC > 0 && NRAD > 0
*** /usr/src/sys/pdpuba/rk.c.old	Sun Sep 22 08:40:33 1991
--- /usr/src/sys/pdpuba/rk.c	Sat Jan  2 23:13:30 1993
***************
*** 3,9 ****
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)rk.c	1.2 (2.11BSD Berkeley) 9/22/91
   */
  
  /*
--- 3,9 ----
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)rk.c	1.4 (2.11BSD GTE) 1/2/93
   */
  
  /*
***************
*** 47,54 ****
  	return(1);
  }
  
! rkopen(dev)
  	dev_t dev;
  {
  	register int unit = rkunit(dev);
  
--- 47,55 ----
  	return(1);
  }
  
! rkopen(dev, flag)
  	dev_t dev;
+ 	int flag;
  {
  	register int unit = rkunit(dev);
  
***************
*** 74,82 ****
  		iodone(bp);
  		return;
  	}
- #ifdef UNIBUS_MAP
  	mapalloc(bp);
- #endif
  	bp->av_forw = (struct buf *)NULL;
  	s = splbio();
  	if(rktab.b_actf == NULL)
--- 75,81 ----
***************
*** 166,169 ****
--- 165,178 ----
  	iodone(bp);
  	rkstart();
  }
+ 
+ /*
+  * Hack - no one is using these anyhow, especially for swapping.
+ */
+ daddr_t
+ rksize(dev)
+ 	dev_t	dev;
+ 	{
+ 	return(NRKBLK);
+ 	}
  #endif NRK
*** /usr/src/sys/pdpuba/rl.c.old	Sun Sep 22 08:41:02 1991
--- /usr/src/sys/pdpuba/rl.c	Sat Jan  2 23:24:01 1993
***************
*** 3,9 ****
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)rl.c	1.2 (2.11BSD Berkeley) 9/22/91
   */
  
  /*
--- 3,9 ----
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)rl.c	1.4 (2.11BSD GTE) 1/2/93
   */
  
  /*
***************
*** 83,93 ****
  	return (0);
  }
  
! rlopen(dev)
  	dev_t dev;
  {
! 	if (minor(dev) >= NRL || !RLADDR)
  		return (ENXIO);
  	return (0);
  }
  
--- 83,98 ----
  	return (0);
  }
  
! rlopen(dev, flag)
  	dev_t dev;
+ 	int flag;
  {
! 	register int drive = minor(dev);
! 
! 	if (drive >= NRL || !RLADDR)
  		return (ENXIO);
+ 	if	(rl.type[drive] == -1)
+ 		rlgsts(drive);
  	return (0);
  }
  
***************
*** 94,105 ****
  rlstrategy(bp)
  	register struct	buf *bp;
  {
- 	register struct rldevice *rp;
  	register int drive;
  	int nblocks, s, ctr;
  
  	drive = minor(bp->b_dev);
! 	if (drive >= NRL || !(rp = RLADDR)) {
  		bp->b_error = ENXIO;
  		goto bad;
  	}
--- 99,109 ----
  rlstrategy(bp)
  	register struct	buf *bp;
  {
  	register int drive;
  	int nblocks, s, ctr;
  
  	drive = minor(bp->b_dev);
! 	if (drive >= NRL || !RLADDR) {
  		bp->b_error = ENXIO;
  		goto bad;
  	}
***************
*** 109,143 ****
  	 * to determine how many blocks are on the device.  The rl.type[]
  	 * array has been initialized with -1's so that we may test first
  	 * contact with a particular drive and do this determination only once.
- 	 *
- 	 * For some unknown reason the RL02 (seems to be
- 	 * only drive 1) does not return a valid drive status
- 	 * the first time that a GET STATUS request is issued
- 	 * for the drive, in fact it can take up to three or more
- 	 * GET STATUS requests to obtain the correct status.
- 	 * In order to overcome this "HACK" the driver has been
- 	 * modified to issue a GET STATUS request, validate the
- 	 * drive status returned, and then use it to determine the
- 	 * drive type. If a valid status is not returned after eight
- 	 * attempts, then an error message is printed.
  	 */
! 	if (rl.type[drive] < 0) {
! 		ctr = 0;
! 		do { /* get status and reset when first touching this drive */
! 			rp->rlda = RLDA_RESET | RLDA_GS;
! 			rp->rlcs = (drive << 8) | RL_GETSTATUS;	/* set up csr */
! 			rlwait(rp);
! 		} while (((rp->rlmp & 0177477) != 035) && (++ctr < 16));
! 		if (ctr >= 16) {
! 			printf("rl%d: no status\n", drive);
! 			printf("cs=%b da=%b\n", rp->rlcs, RL_BITS,
! 			    rp->rlda, RLDA_BITS);
! 			rl.type[drive] = RL02_NBLKS;	/* assume RL02 */
! 		} else if (rp->rlmp & RLMP_DTYP) {
! 			rl.type[drive] = RL02_NBLKS;	/* drive is RL02 */
! 		} else
! 			rl.type[drive] = RL01_NBLKS;	/* drive RL01 */
! 	}
  	/* determine nblocks based upon which drive this is */
  	nblocks = rl.type[drive];
  	if(bp->b_blkno >= nblocks) {
--- 113,121 ----
  	 * to determine how many blocks are on the device.  The rl.type[]
  	 * array has been initialized with -1's so that we may test first
  	 * contact with a particular drive and do this determination only once.
  	 */
! 	if (rl.type[drive] < 0)
! 		rlgsts(drive);
  	/* determine nblocks based upon which drive this is */
  	nblocks = rl.type[drive];
  	if(bp->b_blkno >= nblocks) {
***************
*** 151,159 ****
  		iodone(bp);
  		return;
  	}
- #ifdef UNIBUS_MAP
  	mapalloc(bp);
- #endif
  
  	bp->av_forw = NULL;
  	bp->b_cylin = (int)(bp->b_blkno/20l);
--- 129,135 ----
***************
*** 371,377 ****
  /*
   * Dump routine for RL01/02
   * Dumps from dumplo to end of memory/end of disk section for minor(dev).
-  * It uses the UNIBUS map to dump all of memory if there is a UNIBUS map.
   * This routine is stupid (because the rl is stupid) and assumes that
   * dumplo begins on a track boundary!
   */
--- 347,352 ----
***************
*** 387,411 ****
  	register int count;
  	u_int com;
  	int ccn, cn, tn, sn, unit, dif, ctr;
- #ifdef UNIBUS_MAP
  	register struct ubmap *ubp;
- #endif
  
  	unit = minor(dev);
  	ctr = 0;
! 	do {			/* Determine drive type */
! 		rladdr->rlda = RLDA_RESET | RLDA_GS;
! 		rladdr->rlcs = (dev << 8) | RL_GETSTATUS;
! 		rlwait(rladdr);
! 	} while(((rladdr->rlmp & 0177477) != 035) && (++ctr < 16));
! 	if(ctr >= 16) {
! 		printf("rl%d: no status\n",dev);
  		return(EIO);
! 	}
! 	if(rladdr->rlmp & RLMP_DTYP)
! 		dumpsize = RL02_NBLKS;
! 	else
! 		dumpsize = RL01_NBLKS;
  	if((dumplo < 0) || (dumplo >= dumpsize))
  		return(EINVAL);
  	dumpsize -= dumplo;
--- 362,374 ----
  	register int count;
  	u_int com;
  	int ccn, cn, tn, sn, unit, dif, ctr;
  	register struct ubmap *ubp;
  
  	unit = minor(dev);
  	ctr = 0;
! 	if	(rlgsts(unit) < 0)
  		return(EIO);
! 	dumpsize = rl.type[unit];
  	if((dumplo < 0) || (dumplo >= dumpsize))
  		return(EINVAL);
  	dumpsize -= dumplo;
***************
*** 414,422 ****
  	rlwait(rladdr);
  	ccn = ((unsigned)rladdr->rlmp&0177700) >> 6;
  
- #ifdef UNIBUS_MAP
  	ubp = &UBMAP[0];
- #endif
  	for(paddr = 0L;dumpsize > 0;dumpsize -= count) {
  		count = dumpsize > DBSIZE ? DBSIZE : dumpsize;
  		bn = dumplo + (paddr >> PGSHIFT);
--- 377,383 ----
***************
*** 437,443 ****
  		rladdr->rlda = (cn << 6) | sn;
  		rladdr->rlmp = -(count << (PGSHIFT-1));
  		com = (dev << 8) | RL_WCOM;
- #ifdef UNIBUS_MAP
  		/* If there is a map - use it */
  		if(ubmap) {
  			ubp->ub_lo = loint(paddr);
--- 398,403 ----
***************
*** 444,450 ****
  			ubp->ub_hi = hiint(paddr);
  			rladdr->rlba = 0;
  		} else {
- #endif
  			rladdr->rlba = loint(paddr);
  			if	(q22bae == 1)
  				q22bae = (fioword(&rladdr->rlbae) == -1 ? -1:0);
--- 404,409 ----
***************
*** 451,459 ****
  			if	(q22bae == 0)
  				rladdr->rlbae = hiint(paddr);
  			com |= (hiint(paddr) & 03) << 4;
- #ifdef UNIBUS_MAP
  		}
- #endif
  		rladdr->rlcs = com;
  		rlwait(rladdr);
  		if(rladdr->rlcs & RL_CERR) {
--- 410,416 ----
***************
*** 469,472 ****
--- 426,477 ----
  	return(0);	/* Filled the disk */
  }
  #endif RL_DUMP
+ 
+ /*
+  * Assumes the 'open' routine has already been called to get the drive
+  * status and determine what type of drive this is.
+ */
+ daddr_t
+ rlsize(dev)
+ 	dev_t	dev;
+ 	{
+ 
+ 	return(rl.type[minor(dev)]);
+ 	}
+ 
+ /* For some unknown reason the RL02 (seems to be
+  * only drive 1) does not return a valid drive status
+  * the first time that a GET STATUS request is issued
+  * for the drive, in fact it can take up to three or more
+  * GET STATUS requests to obtain the correct status.
+  * In order to overcome this "HACK" the driver has been
+  * modified to issue a GET STATUS request, validate the
+  * drive status returned, and then use it to determine the
+  * drive type. If a valid status is not returned after eight
+  * attempts, then an error message is printed.
+  */
+ rlgsts(drive)
+ 	int	drive;
+ 	{
+ 	register int	ctr = 0;
+ 	register struct	rldevice *rp = RLADDR;
+ 
+ 	do	{ /* get status and reset when first touching this drive */
+ 		rp->rlda = RLDA_RESET | RLDA_GS;
+ 		rp->rlcs = (drive << 8) | RL_GETSTATUS;	/* set up csr */
+ 		rlwait(rp);
+ 		} while (((rp->rlmp & 0177477) != 035) && (++ctr < 16));
+ 	if	(ctr >= 16)
+ 		{
+ 		printf("rl%d: !status cs=%b da=%b\n", drive,
+ 			rp->rlcs, RL_BITS, rp->rlda, RLDA_BITS);
+ 		rl.type[drive] = RL02_NBLKS;	/* assume RL02 */
+ 		return(-1);
+ 		}
+ 	else if (rp->rlmp & RLMP_DTYP)
+ 		rl.type[drive] = RL02_NBLKS;	/* drive is RL02 */
+ 	else
+ 		rl.type[drive] = RL01_NBLKS;	/* drive RL01 */
+ 	return(0);
+ 	}
  #endif
*** /usr/src/sys/pdpuba/rx.c.old	Sun Sep 22 08:41:32 1991
--- /usr/src/sys/pdpuba/rx.c	Sat Jan  2 23:29:46 1993
***************
*** 3,9 ****
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)rx.c	1.2 (2.11BSD Berkeley) 9/22/91
   */
  
  /*
--- 3,9 ----
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)rx.c	1.3 (2.11BSD GTE) 1/2/93
   */
  
  /*
***************
*** 91,99 ****
  
  	if (minor(bp->b_dev) >= 4 || !RXADDR)
  		goto bad;
- #ifdef UNIBUS_MAP
  	mapalloc(bp);
- #endif
  	if (bp->b_blkno >= NRXBLKS) {
  		if (bp->b_flags&B_READ)
  			bp->b_resid = bp->b_bcount;
--- 91,97 ----
*** /usr/src/sys/pdpuba/si.c.old	Sun Sep 22 08:41:56 1991
--- /usr/src/sys/pdpuba/si.c	Sat Jan  2 23:24:21 1993
***************
*** 3,9 ****
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)si.c	1.2 (2.11BSD Berkeley) 9/22/91
   */
  
  /*
--- 3,9 ----
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)si.c	1.4 (2.11BSD GTE) 1/2/93
   */
  
  /*
***************
*** 100,107 ****
  	return(0);
  }
  
! siopen(dev)
  	dev_t dev;
  {
  	register int unit;
  
--- 100,108 ----
  	return(0);
  }
  
! siopen(dev, flag)
  	dev_t dev;
+ 	int flag;
  {
  	register int unit;
  
***************
*** 133,141 ****
  		iodone(bp);
  		return;
  	}
- #ifdef	UNIBUS_MAP
  	mapalloc(bp);
- #endif
  	bp->b_cylin = bn / (SI_NSECT * SI_NTRAC) + rm5_sizes[unit & 07].cyloff;
  	unit = dkunit(bp);
  	dp = &siutab[unit];
--- 134,140 ----
***************
*** 211,217 ****
  search:
  	siaddr->sisar = (unit << 10) | cn;
  	if(dualsi)
! 		donesi();
  	sicc[unit] = cn;
  #ifdef UCB_METER
  	/*
--- 210,216 ----
  search:
  	siaddr->sisar = (unit << 10) | cn;
  	if(dualsi)
! 		SIADDR->siscr = 0;
  	sicc[unit] = cn;
  #ifdef UCB_METER
  	/*
***************
*** 367,373 ****
  		}
  
  		if(dualsi)
! 			donesi();
  		if (sitab.b_active) {
  			sitab.b_active = 0;
  			sitab.b_errcnt = 0;
--- 366,372 ----
  		}
  
  		if(dualsi)
! 			SIADDR->siscr = 0;
  		if (sitab.b_active) {
  			sitab.b_active = 0;
  			sitab.b_errcnt = 0;
***************
*** 403,417 ****
  /*
   *  Dump routine for SI 9500
   *  Dumps from dumplo to end of memory/end of disk section for minor(dev).
-  *  It uses the UNIBUS map to dump all of memory if there is a UNIBUS map
-  *  and this isn't an RH70.  This depends on UNIBUS_MAP being defined.
   */
  
! #ifdef	UNIBUS_MAP
! #define	DBSIZE	(UBPAGE/NBPG)		/* unit of transfer, one UBPAGE */
! #else
! #define DBSIZE	16			/* unit of transfer, same number */
! #endif
  
  sidump(dev)
  dev_t	dev;
--- 402,410 ----
  /*
   *  Dump routine for SI 9500
   *  Dumps from dumplo to end of memory/end of disk section for minor(dev).
   */
  
! #define DBSIZE	16			/* number of blocks to write */
  
  sidump(dev)
  dev_t	dev;
***************
*** 420,428 ****
  	daddr_t	bn, dumpsize;
  	long	paddr;
  	register count;
- #ifdef	UNIBUS_MAP
  	register struct ubmap *ubp;
- #endif
  	int cn, tn, sn, unit;
  
  	unit = minor(dev) >> 3;
--- 413,419 ----
***************
*** 438,446 ****
  	 * reset the 9500
  	 */
  	siaddr->sicnr = SI_RESET;
- #ifdef	UNIBUS_MAP
  	ubp = &UBMAP[0];
- #endif
  	for (paddr = 0L; dumpsize > 0; dumpsize -= count) {
  		count = dumpsize>DBSIZE? DBSIZE: dumpsize;
  		bn = dumplo + (paddr >> PGSHIFT);
--- 429,435 ----
***************
*** 453,463 ****
  		siaddr->sipcr = (unit << 10) | cn;
  		siaddr->sihsr = (tn << 5) + sn;
  		siaddr->siwcr = count << (PGSHIFT-1);
! #ifdef	UNIBUS_MAP
! 		/*
! 		 *  If UNIBUS_MAP exists, use
! 		 *  the map.
! 		 */
  		if (ubmap) {
  			ubp->ub_lo = loint(paddr);
  			ubp->ub_hi = hiint(paddr);
--- 442,448 ----
  		siaddr->sipcr = (unit << 10) | cn;
  		siaddr->sihsr = (tn << 5) + sn;
  		siaddr->siwcr = count << (PGSHIFT-1);
! 
  		if (ubmap) {
  			ubp->ub_lo = loint(paddr);
  			ubp->ub_hi = hiint(paddr);
***************
*** 465,475 ****
  			siaddr->sicnr = SI_WRITE | SI_GO;
  		}
  		else
- #endif
  			{
- 			/*
- 			 *  Non-UNIBUS map.
- 			 */
  			siaddr->simar = loint(paddr);
  			siaddr->sicnr = SI_WRITE|SI_GO|((paddr >> 8)&(03 << 4));
  		}
--- 450,456 ----
***************
*** 497,506 ****
  	}
  }
  
! donesi()
! {
! 	register struct sidevice *siaddr = SIADDR;
  
! 	siaddr->siscr = 0;
! }
  #endif NSI
--- 478,491 ----
  	}
  }
  
! /*
!  * Simple minded but effective. Likely none of these are still around or in use.
! */
! daddr_t
! sisize(dev)
! 	dev_t	dev;
! 	{
  
! 	return(rm5_sizes[dev & 07].nblocks);
! 	}
  #endif NSI
*** /usr/src/sys/pdpuba/tm.c.old	Sun Sep 22 08:42:33 1991
--- /usr/src/sys/pdpuba/tm.c	Sat Jan  2 23:29:04 1993
***************
*** 3,9 ****
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)tm.c	2.1 (2.11BSD) 9/22/91
   */
  
  /*
--- 3,9 ----
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)tm.c	2.2 (2.11BSD GTE) 1/2/93
   */
  
  /*
***************
*** 241,249 ****
  	register struct te_softc *sc = &te_softc[TEUNIT(bp->b_dev)];
  
  	if (bp->b_flags & B_PHYS) {
- #ifdef UNIBUS_MAP
  		mapalloc(bp);
- #endif
  		sc->sc_blkno = sc->sc_nxrec = dbtofsb(bp->b_blkno);
  		sc->sc_nxrec++;
  	}
--- 241,247 ----
*** /usr/src/sys/pdpuba/tmscp.c.old	Thu Nov 19 21:02:38 1992
--- /usr/src/sys/pdpuba/tmscp.c	Sat Jan  2 23:32:49 1993
***************
*** 1,4 ****
! /*	@(#)tmscp.c	1.2 (2.11BSD) 9/22/91 */
  
  #if	!defined(lint) && defined(DOSCCS)
  static	char	*sccsid = "@(#)tmscp.c	1.24	(ULTRIX)	1/21/86";
--- 1,4 ----
! /*	@(#)tmscp.c	1.3 (2.11BSD) 1/2/93 */
  
  #if	!defined(lint) && defined(DOSCCS)
  static	char	*sccsid = "@(#)tmscp.c	1.24	(ULTRIX)	1/21/86";
***************
*** 31,36 ****
--- 31,40 ----
   * tmscp.c - TMSCP (TK50/TU81) tape device driver
   * 
   * Modification History:
+  * 02-Jan-93 - sms@wlv. [2.11BSD]
+  *	Remove unibus map ifdefs and rely on run time testing of 'ubmap' which
+  * 	does the right thing and makes kernels easier to move between machines.
+  *
   * 20-Nov-92 - sms@wlv.iipo.gtegsc.com [2.11BSD]
   *	Add tmsVec() for autoconfig to use in passing the vector from /etc/dtab
   *	to this driver.  The previous scheme of having a fixed vector with
***************
*** 1472,1480 ****
  		iodone(bp);
  		return;
  		}
- #ifdef	UNIBUS_MAP
  	mapalloc(bp);
- #endif
  	s = spl5();
  	/*
  	 * Link the buffer onto the drive queue
--- 1476,1482 ----
***************
*** 1536,1548 ****
  		return(ENXIO);
  
  	paddr = _iomap(tmscp[sc->sc_unit]);
- #ifdef	UNIBUS_MAP
  	if (ubmap) {
  		ubp = UBMAP;
  		ubp->ub_lo = loint(paddr);
  		ubp->ub_hi = hiint(paddr);
  	}
- #endif
  	paddr += RINGBASE;
  	saveseg5(seg5);
  	mapseg5(tmscp[sc->sc_unit], MAPBUFDESC);
--- 1538,1548 ----
***************
*** 1575,1594 ****
  	}
  
  	dumpsize = 8 * 1024L;	 /* XXX */
- #ifdef	UNIBUS_MAP
  	ubp = &UBMAP[1];
- #endif
  	for (paddr = 0; dumpsize > 0; dumpsize -= count) {
  		count = MIN(dumpsize, DBSIZE);
  		bn = paddr >> PGSHIFT;
  		maddr = paddr;
- #ifdef	UNIBUS_MAP
  		if (ubmap) {
  			ubp->ub_lo = loint(paddr);
  			ubp->ub_hi = hiint(paddr);
  			maddr = (u_int)(1 << 13);
  		}
- #endif
  	/* write it to the tape */
  	mp = &sc->sc_com->tmscp_rsp[1];
  	mp->mscp_lbn_l = loint(bn);
--- 1575,1590 ----
*** /usr/src/sys/pdpuba/ts.c.old	Sun Sep 22 08:43:39 1991
--- /usr/src/sys/pdpuba/ts.c	Sat Jan  2 23:28:52 1993
***************
*** 3,9 ****
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)ts.c	2.2 (2.11BSD) 9/22/91
   */
  
  /*
--- 3,9 ----
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)ts.c	2.2 (2.11BSD GTE) 1/2/93
   */
  
  /*
***************
*** 118,126 ****
  		tbuf.b_un.b_addr = (caddr_t) softspace;
  		tbuf.b_flags = B_PHYS;
  		tbuf.b_bcount = sizeof (softspace);
- #ifdef	UNIBUS_MAP
  		mapalloc(&tbuf);
- #endif
  		TS_ubadr = ((long)((unsigned)tbuf.b_xmem)) << 16
  				| ((long)((unsigned)tbuf.b_un.b_addr));
  	}
--- 118,124 ----
***************
*** 257,265 ****
  	register struct buf *dp = &tstab[ts11];
  
  	if (bp->b_flags & B_PHYS) {	/* if RAW I/O call */
- #ifdef UNIBUS_MAP
  		mapalloc(bp);
- #endif
  		sc->sc_blkno = sc->sc_nxrec = dbtofsb(bp->b_blkno);
  		sc->sc_nxrec++;
  	}
--- 255,261 ----
*** /usr/src/sys/pdpuba/xp.c.old	Sun Sep 22 08:44:09 1991
--- /usr/src/sys/pdpuba/xp.c	Sat Jan  2 23:29:25 1993
***************
*** 3,9 ****
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)xp.c	1.3 (2.11BSD) 9/22/91
   */
  
  /*
--- 3,9 ----
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)xp.c	1.5 (2.11BSD GTE) 1/2/93
   */
  
  /*
***************
*** 30,40 ****
  #include "hpreg.h"
  #include "dkbad.h"
  #include "dk.h"
- 
- #ifdef UNIBUS_MAP
  #include "map.h"
  #include "uba.h"
- #endif UNIBUS_MAP
  
  #define	XP_SDIST	2
  #define	XP_RDIST	6
--- 30,37 ----
***************
*** 182,195 ****
  	 171798,	  0,	/* g: cyl   0 - 410, whole RP04/05 */
  	 340670,	  0,	/* h: cyl   0 - 814, whole RP06 */
  }, rm_sizes[8] = { /* RM02/03 */
! 	   4800,	  0,	/* a: cyl   0 -  29 */
! 	   4800,	 30,	/* b: cyl  30 -  59 */
! 	 122080,	 60,	/* c: cyl  60 - 822 */
! 	  62720,	 60,	/* d: cyl  60 - 451 */
! 	  59360,	452,	/* e: cyl 452 - 822 */
! 	   9600,	  0,	/* f: cyl   0 -  59, overlaps a & b */
! 	      0,	  0,	/* g: Not Defined */
! 	 131680,	  0,	/* h: cyl   0 - 822 */
  }, rm5_sizes[8] = { /* RM05, or SI 9500, CDC 9766 */
  	   9120,	  0,	/* a: cyl   0 -  14 */
  	   9120,	 15,	/* b: cyl  15 -  29 */
--- 179,192 ----
  	 171798,	  0,	/* g: cyl   0 - 410, whole RP04/05 */
  	 340670,	  0,	/* h: cyl   0 - 814, whole RP06 */
  }, rm_sizes[8] = { /* RM02/03 */
! 	   9600,	  0,	/* a: cyl   0 -  59 */
! 	   9600,	 60,	/* b: cyl  60 - 119 */
! 	 131680,	  0,	/* c: cyl   0 - 822, whole RM02/03 */
! 	      0,	  0,	/* d: Not Defined */
! 	      0,	  0,	/* e: Not Defined */
! 	 121920,	 60,	/* f: cyl  60 - 821 */
! 	 112320,	120,	/* g: cyl 120 - 821 */
! 	 131680,	  0,	/* h: cyl   0 - 822, whole RM02/03 */
  }, rm5_sizes[8] = { /* RM05, or SI 9500, CDC 9766 */
  	   9120,	  0,	/* a: cyl   0 -  14 */
  	   9120,	 15,	/* b: cyl  15 -  29 */
***************
*** 294,300 ****
  	register int i;
  	register struct hpdevice *xpaddr;
  
! #if	(PDP11 == GENERIC)
  	printf("\nxp_drive=0%o xp_controller=0%o\n",xp_drive,xp_controller);
  	delay(10000000L);	/* 10 secs to halt and patch xp_drive */
  #endif
--- 291,297 ----
  	register int i;
  	register struct hpdevice *xpaddr;
  
! #ifdef	GENERIC
  	printf("\nxp_drive=0%o xp_controller=0%o\n",xp_drive,xp_controller);
  	delay(10000000L);	/* 10 secs to halt and patch xp_drive */
  #endif
***************
*** 347,356 ****
  		return(0);
  	if ((xpaddr != 0) && (fioword(xpaddr) != -1)) {
  		xc->xp_addr = xpaddr;
- #if (PDP11 == 70 || PDP11 == GENERIC || defined(Q22))
  		if (fioword(&xpaddr->hpbae) != -1)
  			xc->xp_flags |= XP_RH70;
- #endif
  #ifdef XP_PROBE
  	/*
  	 *  If already attached, ignore (don't want to renumber drives)
--- 344,351 ----
***************
*** 510,519 ****
  		iodone(bp);
  		return;
  	}
- #ifdef UNIBUS_MAP
  	if ((xd->xp_ctlr->xp_flags & XP_RH70) == 0)
  		mapalloc(bp);
- #endif
  	bp->b_cylin = bn / xd->xp_nspc + xd->xp_sizes[pseudo_unit].cyloff;
  	dp = &xputab[unit];
  	s = splbio();
--- 505,512 ----
***************
*** 590,599 ****
  		bbp->b_un.b_addr = (caddr_t)&xpbad[unit];
  		bbp->b_blkno = (daddr_t)xd->xp_ncyl * xd->xp_nspc - xd->xp_nsect;
  		bbp->b_cylin = xd->xp_ncyl - 1;
- #ifdef UNIBUS_MAP
  		if ((xd->xp_ctlr->xp_flags & XP_RH70) == 0)
  			mapalloc(bbp);
- #endif
  		dp->b_actf = bbp;
  		bbp->av_forw = bp;
  		bp = bbp;
--- 583,590 ----
***************
*** 718,727 ****
  	xpaddr->hpdc = cn;
  	xpaddr->hpda = (tn << 8) + sn;
  	xpaddr->hpba = bp->b_un.b_addr;
- #if (PDP11 == 70 || PDP11 == GENERIC || defined(Q22))
  	if (xc->xp_flags & XP_RH70)
  		xpaddr->hpbae = bp->b_xmem;
- #endif
  	xpaddr->hpwc = -(bp->b_bcount >> 1);
  	/*
  	 * Warning:  unit is being used as a temporary.
--- 709,716 ----
***************
*** 901,909 ****
  	int	ocmd;
  	int	cn, tn, sn;
  	daddr_t bn;
- #ifdef UNIBUS_MAP
  	struct ubmap *ubp;
- #endif
  	int	unit;
  
  	/*
--- 890,896 ----
***************
*** 963,969 ****
  			 */
  			while (byte < bp->b_bcount && wrong != 0) {
  				addr = bb + byte;
- #ifdef UNIBUS_MAP
  				if (bp->b_flags & (B_MAP|B_UBAREMAP)) {
  					/*
  					 * Simulate UNIBUS map if UNIBUS
--- 950,955 ----
***************
*** 972,978 ****
  					ubp = UBMAP + ((addr >> 13) & 037);
  					addr = exadr(ubp->ub_hi, ubp->ub_lo) + (addr & 017777);
  				}
- #endif
  				putmemc(addr, getmemc(addr) ^ (int) wrong);
  				byte++;
  				wrong >>= 8;
--- 958,963 ----
***************
*** 1019,1028 ****
  	xpaddr->hpda = (tn << 8) + sn;
  	xpaddr->hpwc = wc;
  	xpaddr->hpba = (caddr_t)addr;
- #if (PDP11 == 70 || PDP11 == GENERIC || defined(Q22))
  	if (xd->xp_ctlr->xp_flags & XP_RH70)
  		xpaddr->hpbae = (int)(addr >> 16);
- #endif
  	xpaddr->hpcs1.w = ocmd;
  	return (1);
  }
--- 1004,1011 ----
***************
*** 1030,1044 ****
  #ifdef XP_DUMP
  /*
   * Dump routine.  Dumps from dumplo to end of memory/end of disk section for
!  * minor(dev).  It uses the UNIBUS map to dump all of memory if there is a
!  * UNIBUS map and this isn't an RH70.  This depends on UNIBUS_MAP being
!  * defined.
   */
! #ifdef UNIBUS_MAP
! #define	DBSIZE	(UBPAGE/NBPG)		/* unit of transfer, one UBPAGE */
! #else
! #define DBSIZE	16			/* unit of transfer, same number */
! #endif
  
  xpdump(dev)
  	dev_t dev;
--- 1013,1021 ----
  #ifdef XP_DUMP
  /*
   * Dump routine.  Dumps from dumplo to end of memory/end of disk section for
!  * minor(dev).
   */
! #define DBSIZE	16			/* number of blocks to write */
  
  xpdump(dev)
  	dev_t dev;
***************
*** 1051,1059 ****
  	daddr_t bn, dumpsize;
  	long paddr;
  	int	sn, count;
- #ifdef UNIBUS_MAP
  	struct ubmap *ubp;
- #endif
  
  	if ((bdevsw[major(dev)].d_strategy != xpstrategy)	/* paranoia */
  		|| ((dev=minor(dev)) > (NXPD << 3)))
--- 1028,1034 ----
***************
*** 1075,1083 ****
  	}
  	if ((xpaddr->hpds & (HPDS_DPR | HPDS_MOL)) != (HPDS_DPR | HPDS_MOL))
  		return(EFAULT);
- #ifdef UNIBUS_MAP
  	ubp = &UBMAP[0];
- #endif
  	for (paddr = 0L; dumpsize > 0; dumpsize -= count) {
  		count = dumpsize>DBSIZE? DBSIZE: dumpsize;
  		bn = dumplo + (paddr >> PGSHIFT);
--- 1050,1056 ----
***************
*** 1087,1097 ****
  		xpaddr->hpwc = -(count << (PGSHIFT - 1));
  		xpaddr->hper1 = 0;
  		xpaddr->hper3 = 0;
- #ifdef UNIBUS_MAP
- 		/*
- 		 * If UNIBUS_MAP exists, use the map, unless on an 11/70
- 		 * with RH70.
- 		 */
  		if (ubmap && ((xd->xp_ctlr->xp_flags & XP_RH70) == 0)) {
  			ubp->ub_lo = loint(paddr);
  			ubp->ub_hi = hiint(paddr);
--- 1060,1065 ----
***************
*** 1099,1117 ****
  			xpaddr->hpcs1.w = HP_WCOM | HP_GO;
  		}
  		else {
- #endif UNIBUS_MAP
  			/*
  			 * Non-UNIBUS map, or 11/70 RH70 (MASSBUS)
  			 */
  			xpaddr->hpba = loint(paddr);
- #if (PDP11 == 70 || PDP11 == GENERIC || defined(Q22))
  			if (xd->xp_ctlr->xp_flags & XP_RH70)
  				xpaddr->hpbae = hiint(paddr);
- #endif
  			xpaddr->hpcs1.w = HP_WCOM | HP_GO | ((paddr >> 8) & (03 << 8));
- #ifdef UNIBUS_MAP
  		}
- #endif
  		/* Emulex controller emulating two RM03's needs a delay */
  		delay(50000L);
  		while (xpaddr->hpcs1.w & HP_GO)
--- 1067,1080 ----
***************
*** 1126,1129 ****
--- 1089,1107 ----
  	return(0);		/* filled disk minor dev */
  }
  #endif XP_DUMP
+ 
+ /*
+  * By this time either the slaves have been "probed" for or the drive
+  * information was statically initialized - either way the lookup of
+  * partition size is straightforward.
+ */
+ daddr_t
+ xpsize(dev)
+ 	register dev_t	dev;
+ 	{
+ 	register struct xp_drive *xd;
+ 
+ 	xd = &xp_drive[xpunit(dev)];
+ 	return(xd->xp_sizes[dev].nblocks);
+ 	}
  #endif NXPD
*** /usr/src/man/man4/hk.4.old	Sat Aug 29 13:11:16 1987
--- /usr/src/man/man4/hk.4	Sun Jan  3 14:21:57 1993
***************
*** 2,10 ****
  .\" All rights reserved.  The Berkeley software License Agreement
  .\" specifies the terms and conditions for redistribution.
  .\"
! .\"	@(#)hk.4	6.2 (Berkeley) 8/29/87
  .\"
! .TH HK 4 "August 29, 1987"
  .UC 2
  .SH NAME
  hk \- RK6-11/RK06 and RK07 moving head disk
--- 2,10 ----
  .\" All rights reserved.  The Berkeley software License Agreement
  .\" specifies the terms and conditions for redistribution.
  .\"
! .\"	@(#)hk.4	6.3 (2.11BSD GTE) 1/3/93
  .\"
! .TH HK 4 "January 3, 1993"
  .UC 2
  .SH NAME
  hk \- RK6-11/RK06 and RK07 moving head disk
***************
*** 60,85 ****
  .ne 10
  RK06 partitions:
  	disk	 start	length	     cyls	comments
! 	hk?a	     0	  5940	  0 -  89	too small to hold 2.10BSD root
! 	hk?b	  5940	  2376	 90 - 125
! 	hk?c	unusable
! 	hk?d	  8316	 18810	126 - 410*
! 	hk?e	     0	  8316	  0 - 125	overlaps a & b (2.10BSD root)
  	hk?f	unused
! 	hk?g	     0	 27126	  0 - 410*	whole pack
! 	hk?h	unusable
  .PP
  .ne 10
  RK07 partitions:
  	disk	 start	length	     cyls	comments
! 	hk?a	     0	  5940	  0 -  89	too small to hold 2.10BSD root
! 	hk?b	  5940	  2376	 90 - 125
! 	hk?c	  8316	 45474	126 - 814*
! 	hk?d	  8316	 18810	126 - 410
! 	hk?e	     0	  8316	  0 - 125	overlaps a & b (2.10BSD root)
  	hk?f	unused
! 	hk?g	     0	 27126	  0 - 410
! 	hk?h	     0	 53790	  0 - 814*	whole pack
  .DT
  .fi
  .PP
--- 60,85 ----
  .ne 10
  RK06 partitions:
  	disk	 start	length	     cyls	comments
! 	hk?a	     0	  8316	  0 - 125	root
! 	hk?b	  8316	  8316	126 - 251	swap
! 	hk?c	     0   27126	  0 - 410*	whole pack plus badsect track
! 	hk?d	unused
! 	hk?e	unused
  	hk?f	unused
! 	hk?g	 16632	 10428	251 - 409	tmp
! 	hk?h	     0	 27060	  0 - 409	whole pack minus badsect track
  .PP
  .ne 10
  RK07 partitions:
  	disk	 start	length	     cyls	comments
! 	hk?a	     0	  8316	  0 - 125	root
! 	hk?b	  8316	  8316	126 - 251	swap
! 	hk?c	     0	 53790	  0 - 814*	whole pack plus badsect track
! 	hk?d	unused
! 	hk?e	unused
  	hk?f	unused
! 	hk?g	 16632	 37092	252 - 813
! 	hk?h	     0	 53724	  0 - 814	whole pack minus badsect track
  .DT
  .fi
  .PP
***************
*** 91,107 ****
  to create file systems since it uses the ``safe'' partition sizes recored in
  .IR /etc/disktab .
  .PP
- On a dual RK-07 system
- partition hk?e is used
- for the root for one drive
- and partition hk?c for the /usr file system,
- while partition hk?a on the other drive would be
- used for swap.
- If large jobs are to be run using
- hk?e on the second drive as swap area provides a 4Mbyte swap area.
- Otherwise
- partitions hk?b and hk?c on the other drive
- can be used as /tmp and a large (sic) file system.
  .SH FILES
  .ta \w'/dev/MAKEDEV.local  'u
  /dev/hk[0-7][a-h]	block files
--- 91,96 ----
***************
*** 134,143 ****
  \fBhk%d: write locked\fP.  The write protect switch was set on the drive
  when a write was attempted.  The write operation is not recoverable.
  .PP
! \fBrk%d: not ready\fR.  The drive was spun down or off line when it was
  accessed.  The i/o operation is not recoverable.
  .PP
! \fBrk%d: not ready (came back!)\fR.  The drive was not ready, but after
  printing the message about being not ready (which takes a fraction
  of a second) was ready.  The operation is recovered if no further
  errors occur.
--- 123,132 ----
  \fBhk%d: write locked\fP.  The write protect switch was set on the drive
  when a write was attempted.  The write operation is not recoverable.
  .PP
! \fBhk%d: not ready\fR.  The drive was spun down or off line when it was
  accessed.  The i/o operation is not recoverable.
  .PP
! \fBhk%d: not ready (came back!)\fR.  The drive was not ready, but after
  printing the message about being not ready (which takes a fraction
  of a second) was ready.  The operation is recovered if no further
  errors occur.
*** /usr/src/man/man4/xp.4.old	Wed Sep  7 01:13:39 1988
--- /usr/src/man/man4/xp.4	Wed Dec 30 14:58:00 1992
***************
*** 2,8 ****
  .\" All rights reserved.  The Berkeley software License Agreement
  .\" specifies the terms and conditions for redistribution.
  .\"
! .\"	@(#)xp.4	6.2 (Berkeley) 9/7/88
  .\"
  .TH XP 4 "September 7, 1988"
  .UC 2
--- 2,8 ----
  .\" All rights reserved.  The Berkeley software License Agreement
  .\" specifies the terms and conditions for redistribution.
  .\"
! .\"	@(#)xp.4	6.3 (2.11BSD GTE) 12/30/92
  .\"
  .TH XP 4 "September 7, 1988"
  .UC 2
***************
*** 116,129 ****
  .ne 10
  RM02/RM03 partitions:
  	disk	 start	 length	      cyls	comments
! 	xp?a	     0	   4800	  0 -   29	too small to hold 2.10BSD root
! 	xp?b	  4800	   4800	 30 -   59	swap
! 	xp?c	  9600	 122080	 60 -  822*	/usr
! 	xp?d	  9600	  62720	 60 -  451
! 	xp?e	 72320	  59360	452 -  822*
! 	xp?f	     0	   9600	  0 -   59	overlaps a & b (2.10BSD root)
! 	xp?g	unused
! 	xp?h	     0	 131680	  0 -  822*	whole pack
  .PP
  .ne 10
  RM05 (or SI 9500, CDC 9766) partitions:
--- 116,129 ----
  .ne 10
  RM02/RM03 partitions:
  	disk	 start	 length	      cyls	comments
! 	xp?a	     0	   9600	  0 -   59	/
! 	xp?b	  9600	   9600	 60 -  119	swap
! 	xp?c	     0	 131680	  0 -  822*	whole pack + bad144 track
! 	xp?d	unused
! 	xp?e	unused
! 	xp?f	unused
! 	xp?g	 19200	 112320	120 -  821
! 	xp?h         0	 131520   0 -  821	whole pack - bad144 track
  .PP
  .ne 10
  RM05 (or SI 9500, CDC 9766) partitions:
