disc&tape D space (part 2 of 2)

Steven M. Schultz sms at wlv.imsd.contel.com
Wed May 29 05:54:05 AEST 1991


Subject: save D space in disc&tape drivers, TS11&TMSCP fixes
Index:	sys/pdpuba/* 2.11BSD

Description:
	This two part patch addresses several enhancments and fixes.

	This is part 2 of 2.

	1) Each disc and tape drive statically allocates at least one
	   (possibly more)  "struct buf" to be used for 'raw' I/O.  The
	   new method has the drivers passing a NULL pointer to physio()
	   and dynamically allocating a buffer header from the system pool.

	   The step of replacing the XXread and XXwrite routines with
	   common "rawread" and "rawwrite" routines was not done because
	   that involved adding a 'd_strategy' entry point in the cdevsw[]
	   table and that would cost 48 bytes of D space.  In many of the
	   drivers the validation code and block number calculation was
	   either removed as redundant (the strategy routine already was
	   performing the checks) or relocated to the strategy routine.

	   Drivers are still allowed to statically allocate a raw i/o buffer
	   if needed (driver has not yet been converted for example).

	   vm_swp.c no longer has 2 statically allocated buffer headers,
	   swapping now dynamically allocates buffer headers also.

	2) The TS11 driver now supports multiple controllers.  The controller
	   number is coded in bits 6 and 7 of the minor device number now.

	3) /boot now constructs the "default" boot image name from the
	   information passed by boot ROMs.  After all, the system did
	   boot from the device, so the device name and CSR information has
	   to be correct.  Previously /boot would have to be recompiled
	   with a different RB_DEFNAME (which is not defined/used now)
	   depending on the current system disc name.

	4) The B_RH70 bit in the buffer flags word has been replaced by
	   the B_LOCKED bit and the necessary changes to ufs_bio.c made
	   to add the 'locked' queue.  At present nothing uses this, future
	   use may be to relocate the superblock information (for mounted
	   filesystems) external to the kernel.

	   The ht.c driver was the ONLY module to refer to the B_RH70 bit,
	   the driver has been modified to use a static flag word internal
	   to itself (like the other drivers which can be in a RH70 slot).

	5) Enough space was saved that the GENERIC kernel could have the
	   number of buffers raised from 20 to 32.

	6) The density selection logic in the TMSCP driver (tmscp.c) was
	   redone to support tri-density drives.  Although 4 densities
	   are defined, the middle two are identical at present.  If a
	   different choice of "middle" density was desired, it is a simple
	   matter to alter the table.  Also fixed was a minor typo in the
	   multi-controller support.

	7) /dev/MAKEDEV was modified to create the tape device nodes 
	   placing the controller number in bits 6 and 7.  Also for TMSCP
	   (tu) devices the additional nodes for tri-density drives are
	   created.  For devices such as the TK50 and TU81 the extra
	   nodes can be removed later to keep /dev smaller.

	8) in /etc/rc a blank line is output before the "skipping disk
 	   checks" message.

Repeat-By:
	Examine the code.
Fix:
	Gather both parts of this patch kit.  Apply the patches, then
	recompile and install /boot, /unix, and /netnix

	This is part 2 of 2


*** /dev/MAKEDEV.old	Thu Aug 23 18:21:21 1990
--- /dev/MAKEDEV	Sat May 25 18:17:57 1991
***************
*** 56,92 ****
  	;;
  
  ht*|tm*|ts*|tu*)
! 	umask 0 ; unit=`expr $i : '..\(.*\)'`
  	case $i in
! 	ht*) blk=0; chr=6 ;;
  	tm*) blk=1; chr=7;;
  	ts*) blk=2; chr=8;;
  	tu*) blk=12; chr=23;;
  	esac
! 	case $unit in
! 	0|1|2|3)
! 		four=`expr $unit + 4` ; eight=`expr $unit + 8`
! 		twelve=`expr $unit + 12`; twenty=`expr $unit + 20`
! 		/etc/mknod mt$unit	b $blk $unit
  		/etc/mknod mt$four	b $blk $four
  		/etc/mknod mt$eight	b $blk $eight
  		/etc/mknod mt$twelve	b $blk $twelve
! 		/etc/mknod nmt$unit	b $blk $four ;: sanity w/pdp11 v7
  		/etc/mknod nmt$eight	b $blk $twelve ;: ditto
! 		/etc/mknod nrmt$unit	c $chr $four ;: sanity w/pdp11 v7
  		/etc/mknod nrmt$eight	c $chr $twelve ;: ditto
! 		/etc/mknod rmt$unit	c $chr $unit
  		/etc/mknod rmt$four	c $chr $four
  		/etc/mknod rmt$eight	c $chr $eight
  		/etc/mknod rmt$twelve	c $chr $twelve
! 		if [ $i = ut ] 
  		then
  			/etc/mknod mt$twenty	b $blk $twenty
  			/etc/mknod rmt$twenty	c $chr $twenty
  		fi
  		;;
  	*)
! 		echo bad unit for tape in: $1
  		;;
  	esac
  	umask 77
--- 56,119 ----
  	;;
  
  ht*|tm*|ts*|tu*)
! 	umask 0 ; ctlr=`expr $i : '..\(.*\)'`
! 	ctlr=`expr $ctlr '*' 64`
  	case $i in
! 	ht*) blk=0; chr=6;;
  	tm*) blk=1; chr=7;;
  	ts*) blk=2; chr=8;;
  	tu*) blk=12; chr=23;;
  	esac
! # Maximum of 4 controllers in a system
! 	case $ctlr in
! 	0|64|128|192)
! # Maximum of 4 units per controller
! #		for unit in 0 1 2 3
! 		for unit in 0
! 		do
! 		zero=`expr $ctlr + $unit + 0`
! 		four=`expr $zero + 4` ; eight=`expr $zero + 8`
! 		twelve=`expr $zero + 12`
! 		sixteen=`expr $zero + 16`
! 		twenty=`expr $zero + 20`
! 		twentyfour=`expr $zero + 24`
! 		twentyeight=`expr $zero + 28`
! 		/etc/mknod mt$zero	b $blk $zero
  		/etc/mknod mt$four	b $blk $four
  		/etc/mknod mt$eight	b $blk $eight
  		/etc/mknod mt$twelve	b $blk $twelve
! 		/etc/mknod nmt$zero	b $blk $four ;: v7 compatibility
  		/etc/mknod nmt$eight	b $blk $twelve ;: ditto
! 		/etc/mknod nrmt$zero	c $chr $four ;: ditto
  		/etc/mknod nrmt$eight	c $chr $twelve ;: ditto
! 		/etc/mknod rmt$zero	c $chr $zero
  		/etc/mknod rmt$four	c $chr $four
  		/etc/mknod rmt$eight	c $chr $eight
  		/etc/mknod rmt$twelve	c $chr $twelve
! 		if [ `expr $i : '\(..\)'` = tu ]
  		then
+ 		/etc/mknod mt$sixteen	b $blk $sixteen
+ 		/etc/mknod mt$twenty	b $blk $twenty
+ 		/etc/mknod mt$twentyfour b $blk $twentyfour
+ 		/etc/mknod mt$twentyeight b $blk $twentyeight
+ 		/etc/mknod nmt$sixteen	b $blk $twenty ;: v7 compatibility
+ 		/etc/mknod nmt$twentyfour b $blk $twentyeight ;: ditto
+ 		/etc/mknod nrmt$sixteen c $chr $twenty ;: ditto
+ 		/etc/mknod nrmt$twentyfour c $chr $twentyeight ;: ditto
+ 		/etc/mknod rmt$sixteen	c $chr $sixteen
+ 		/etc/mknod rmt$twenty	c $chr $twenty
+ 		/etc/mknod rmt$twentyfour c $chr $twentyfour
+ 		/etc/mknod rmt$twentyeight c $chr $twentyeight
+ 		fi
+ 		if [ `expr $i : '\(..\)'` = ut ]
+ 		then
  			/etc/mknod mt$twenty	b $blk $twenty
  			/etc/mknod rmt$twenty	c $chr $twenty
  		fi
+ 		done
  		;;
  	*)
! 		echo bad controller for tape in: $1
  		;;
  	esac
  	umask 77
*** /etc/rc.old	Mon Aug 27 14:28:43 1990
--- /etc/rc	Sun May 26 01:46:19 1991
***************
*** 23,28 ****
--- 23,29 ----
  fi
  if [ "$1" = fastboot ]
  then
+ 	echo ''
  	echo Fast boot ... skipping disk checks		>/dev/console 2>&1
  elif [ "$1" = autoboot ]
  then
*** /usr/src/sys/conf/GENERIC.old	Wed Dec 19 10:13:42 1990
--- /usr/src/sys/conf/GENERIC	Sun May 19 01:09:53 1991
***************
*** 208,215 ****
  # buffers for a 1K file system, NBUF would be 128.  A possible exception would
  # be to reduce the buffers to save on data space, as they were 24 bytes per
  # header, last time I looked.
! # should be 20 for GENERIC, so room for kernel + large program to run.
! NBUF		20			# buffer cache, *must* be <= 240
  
  # MAXMEM is the maximum core per process is allowed.  First number
  # is Kb.
--- 208,215 ----
  # buffers for a 1K file system, NBUF would be 128.  A possible exception would
  # be to reduce the buffers to save on data space, as they were 24 bytes per
  # header, last time I looked.
! # should be 'small' for GENERIC, so room for kernel + large program to run.
! NBUF		32			# buffer cache, *must* be <= 240
  
  # MAXMEM is the maximum core per process is allowed.  First number
  # is Kb.
*** /usr/src/sys/sys/vm_swp.c.old	Wed Apr 11 09:49:09 1990
--- /usr/src/sys/sys/vm_swp.c	Sat May 18 22:03:16 1991
***************
*** 3,9 ****
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)vm_swp.c	1.1 (2.10BSD Berkeley) 12/1/86
   */
  
  #include "param.h"
--- 3,9 ----
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)vm_swp.c	2.0 (2.11BSD) 5/18/91
   */
  
  #include "param.h"
***************
*** 19,30 ****
  #include "uio.h"
  
  /*
-  * swap IO headers.  They are filled in to point
-  * at the desired IO operation.
-  */
- struct	buf swbuf1, swbuf2;
- 
- /*
   * swap I/O
   */
  swap(blkno, coreaddr, count, rdflg)
--- 19,24 ----
***************
*** 46,63 ****
  		cnt.v_pgout++;
  	}
  #endif
! 	bp = &swbuf1;
! 	if (bp->b_flags & B_BUSY)
! 		if ((swbuf2.b_flags&B_WANTED) == 0)
! 			bp = &swbuf2;
! 	s = splbio();
! 	while (bp->b_flags&B_BUSY) {
! 		bp->b_flags |= B_WANTED;
! 		sleep((caddr_t)bp, PSWP+1);
! 	}
! 	splx(s);
  	while (count) {
! 		bp->b_flags = B_BUSY | B_PHYS | rdflg;
  		bp->b_dev = swapdev;
  		tcount = count;
  		if (tcount >= 01700)	/* prevent byte-count wrap */
--- 40,49 ----
  		cnt.v_pgout++;
  	}
  #endif
! 	bp = geteblk();			/* allocate a buffer header */
! 
  	while (count) {
! 		bp->b_flags = B_BUSY | B_PHYS | B_INVAL | rdflg;
  		bp->b_dev = swapdev;
  		tcount = count;
  		if (tcount >= 01700)	/* prevent byte-count wrap */
***************
*** 74,82 ****
  		coreaddr += tcount;
  		blkno += ctod(tcount);
  	}
! 	if (bp->b_flags&B_WANTED)
! 		wakeup((caddr_t)bp);
! 	bp->b_flags &= ~(B_BUSY|B_WANTED);
  }
  
  /*
--- 60,66 ----
  		coreaddr += tcount;
  		blkno += ctod(tcount);
  	}
! 	brelse(bp);
  }
  
  /*
***************
*** 104,136 ****
  /*
   * Raw I/O. The arguments are
   *	The strategy routine for the device
!  *	A buffer, which will always be a special buffer
!  *	  header owned exclusively by the device for this purpose
   *	The device number
   *	Read/write flag
   * Essentially all the work is computing physical addresses and
   * validating them.
   *
-  * physio broken into smaller routines, 3/81 mjk
-  *	chkphys(WORD or BYTE) checks validity of word- or byte-
-  *	oriented transfer (for physio or device drivers);
-  *	physbuf(strat,bp,rw) fills in the buffer header.
-  *
-  * physio divided into two functions, 1/83 - Mike Edmonds - Tektronix
-  *	Physio divided into separate functions:
-  *		physio (for WORD i/o)
-  *		bphysio (for BYTE i/o)
-  *	This allows byte-oriented devices (such as tape drives)
-  *	to write/read odd length blocks.
-  *
-  * since physio/bphysio just called physio1 with BYTE or WORD added
-  *	to the argument list, adjusted all calls to physio/bphysio
-  *	to pass the correct argument themselves.
-  *		5/86 kb
-  *
   * rewritten to use the iov/uio mechanism from 4.3bsd.  the physbuf routine
   * was inlined.  essentially the chkphys routine performs the same task
   * as the useracc routine on a 4.3 system. 3/90 sms
   */
  physio(strat, bp, dev, rw, kind, uio)
  	int (*strat)();
--- 88,114 ----
  /*
   * Raw I/O. The arguments are
   *	The strategy routine for the device
!  *	A buffer, which may be a special buffer header
!  *	  owned exclusively by the device for this purpose or
!  *	  NULL if one is to be allocated.
   *	The device number
   *	Read/write flag
   * Essentially all the work is computing physical addresses and
   * validating them.
   *
   * rewritten to use the iov/uio mechanism from 4.3bsd.  the physbuf routine
   * was inlined.  essentially the chkphys routine performs the same task
   * as the useracc routine on a 4.3 system. 3/90 sms
+  *
+  * If the buffer pointer is NULL then one is allocated "dynamically" from
+  * the system cache.  the 'invalid' flag is turned on so that the brelse()
+  * done later doesn't place the buffer back in the cache.  the 'phys' flag
+  * is left on so that the address of the buffer is recalcuated in getnewbuf().
+  * The BYTE/WORD stuff began to be removed after testing proved that either
+  * 1) the underlying hardware gives an error or 2) nothing bad happens.
+  * besides, 4.3BSD doesn't do the byte/word check and noone could remember
+  * why the byte/word check was added in the first place - likely historical
+  * paranoia.  chkphys() inlined.  5/91 sms
   */
  physio(strat, bp, dev, rw, kind, uio)
  	int (*strat)();
***************
*** 139,167 ****
  	int rw, kind;
  	register struct uio *uio;
  {
! 	int error, s, nb, ts, c;
  	register struct iovec *iov;
  
! nextiov:
  	u.u_procp->p_flag |= SLOCK;
! 	if (uio->uio_iovcnt == 0) {
! 		u.u_procp->p_flag &= ~SLOCK;
! 		return (0);
! 	}
  	iov = uio->uio_iov;
! 	error = chkphys(kind, iov);
! 	if (error) {
! 		u.u_procp->p_flag &= ~SLOCK;
! 		return(error);
  	}
- 	s = splbio();
- 	while (bp->b_flags & B_BUSY) {
- 		bp->b_flags |= B_WANTED;
- 		sleep((caddr_t)bp, PRIBIO+1);
- 	}
- 	splx(s);
  	while (iov->iov_len) {
! 		bp->b_flags = B_BUSY|B_PHYS|rw;
  		bp->b_dev = dev;
  		nb = ((int)iov->iov_base >> 6) & 01777;
  		ts = (u.u_sep ? UDSA : UISA)[nb >> 7] + (nb & 0177);
--- 117,178 ----
  	int rw, kind;
  	register struct uio *uio;
  {
! 	int error, s, nb, ts, c, alloc = 0;
  	register struct iovec *iov;
  
! 	if (!bp)
! 		alloc++;
  	u.u_procp->p_flag |= SLOCK;
! nextiov:
! 	error = 0;
! 	if (uio->uio_iovcnt == 0)
! 		goto out;
  	iov = uio->uio_iov;
! 
! #ifdef	whybother
! 	/*
! 	 * Check odd base, odd count, and address wraparound
! 	 * Odd base and count not allowed if flag = WORD,
! 	 * allowed if flag = BYTE.
! 	 */
! 	if (kind == WORD && (((int)iov->iov_base|iov->iov_len) & 01))
! 		goto efault;
! #endif
! 	if (iov->iov_base >= iov->iov_base + iov->iov_len)
! 		goto efault;
! 	if (u.u_sep)
! 		ts = 0;
! 	else
! 		ts = (u.u_tsize + 127) & ~0177;
! 	nb = ((int)iov->iov_base >> 6) & 01777;
! 	/*
! 	 * Check overlap with text. (ts and nb now
! 	 * in 64-byte clicks)
! 	 */
! 	if (nb < ts)
! 		goto efault;
! 	/*
! 	 * Check that transfer is either entirely in the
! 	 * data or in the stack: that is, either
! 	 * the end is in the data or the start is in the stack
! 	 * (remember wraparound was already checked).
! 	 */
! 	if (((((int)iov->iov_base + iov->iov_len) >> 6) & 01777) >= ts + u.u_dsize &&
! 	    nb < 1024 - u.u_ssize)
! 		goto efault;
! 
! 	if (alloc)
! 		bp = geteblk();
! 	else {
! 		s = splbio();
! 		while (bp->b_flags & B_BUSY) {
! 			bp->b_flags |= B_WANTED;
! 			sleep((caddr_t)bp, PRIBIO+1);
! 		}
! 		splx(s);
  	}
  	while (iov->iov_len) {
! 		bp->b_flags = B_BUSY|B_PHYS|B_INVAL|rw;
  		bp->b_dev = dev;
  		nb = ((int)iov->iov_base >> 6) & 01777;
  		ts = (u.u_sep ? UDSA : UISA)[nb >> 7] + (nb & 0177);
***************
*** 181,238 ****
  		if (bp->b_resid || (bp->b_flags & B_ERROR))
  			break;
  	}
- 	if (bp->b_flags & B_WANTED)
- 		wakeup((caddr_t)bp);
- 	bp->b_flags &= ~(B_BUSY|B_WANTED|B_PHYS);
  	error = geterror(bp);
! 	/* temp kludge for tape drives */
! 	if (bp->b_resid || error) {
! 		u.u_procp->p_flag &= ~SLOCK;
! 		return (error);
  	}
  	uio->uio_iov++;
  	uio->uio_iovcnt--;
  	goto nextiov;
! }
! 
! /*
!  * check for validity of physical I/O area
!  * (modified from physio to use flag for BYTE-oriented transfers)
!  */
! chkphys(flag, iov)
! 	int flag;
! 	register struct iovec *iov;
! {
! 	register int nb, ts;
! 
! 	/*
! 	 * Check odd base, odd count, and address wraparound
! 	 * Odd base and count not allowed if flag = WORD,
! 	 * allowed if flag = BYTE.
! 	 */
! 	if (flag == WORD && (((int)iov->iov_base|iov->iov_len) & 01))
! 		return(EFAULT);
! 	if (iov->iov_base >= iov->iov_base + iov->iov_len)
! 		return(EFAULT);
! 	if (u.u_sep)
! 		ts = 0;
! 	else
! 		ts = (u.u_tsize + 127) & ~0177;
! 	nb = ((int)iov->iov_base >> 6) & 01777;
! 	/*
! 	 * Check overlap with text. (ts and nb now
! 	 * in 64-byte clicks)
! 	 */
! 	if (nb < ts)
! 		return(EFAULT);
! 	/*
! 	 * Check that transfer is either entirely in the
! 	 * data or in the stack: that is, either
! 	 * the end is in the data or the start is in the stack
! 	 * (remember wraparound was already checked).
! 	 */
! 	if (((((int)iov->iov_base + iov->iov_len) >> 6) & 01777) >= ts + u.u_dsize &&
! 	    nb < 1024 - u.u_ssize)
! 		return(EFAULT);
! 	return(0);
  }
--- 192,215 ----
  		if (bp->b_resid || (bp->b_flags & B_ERROR))
  			break;
  	}
  	error = geterror(bp);
! 	c = bp->b_resid;
! 	if (!alloc) {
! 		if (bp->b_flags & B_WANTED)
! 			wakeup((caddr_t)bp);
! 		bp->b_flags &= ~(B_BUSY|B_WANTED);
  	}
+ 	else
+ 		brelse(bp);
+ 	/* temp kludge for tape drives */
+ 	if (c || error)
+ 		goto out;
  	uio->uio_iov++;
  	uio->uio_iovcnt--;
  	goto nextiov;
! efault:
! 	error = EFAULT;
! out:
! 	u.u_procp->p_flag &= ~SLOCK;
! 	return(error);
  }
*** /usr/src/sys/sys/ufs_bio.c.old	Fri Jun 22 15:28:17 1990
--- /usr/src/sys/sys/ufs_bio.c	Sun May 26 23:08:00 1991
***************
*** 3,9 ****
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)ufs_bio.c	1.1 (2.10BSD Berkeley) 12/1/86
   */
  
  #include "param.h"
--- 3,9 ----
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)ufs_bio.c	2.0 (2.11BSD) 5/18/91
   */
  
  #include "param.h"
***************
*** 29,35 ****
  	register struct buf *bp;
  
  	bp = getblk(dev, blkno);
! 	if (bp->b_flags&B_DONE) {
  		trace(TR_BREADHIT);
  		return (bp);
  	}
--- 29,35 ----
  	register struct buf *bp;
  
  	bp = getblk(dev, blkno);
! 	if (bp->b_flags&(B_DONE|B_DELWRI)) {
  		trace(TR_BREADHIT);
  		return (bp);
  	}
***************
*** 64,70 ****
  	 */
  	if (!incore(dev, blkno)) {
  		bp = getblk(dev, blkno);
! 		if ((bp->b_flags&B_DONE) == 0) {
  			bp->b_flags |= B_READ;
  			bp->b_bcount = DEV_BSIZE;	/* XXX? KB */
  			(*bdevsw[major(dev)].d_strategy)(bp);
--- 64,70 ----
  	 */
  	if (!incore(dev, blkno)) {
  		bp = getblk(dev, blkno);
! 		if ((bp->b_flags&(B_DONE|B_DELWRI)) == 0) {
  			bp->b_flags |= B_READ;
  			bp->b_bcount = DEV_BSIZE;	/* XXX? KB */
  			(*bdevsw[major(dev)].d_strategy)(bp);
***************
*** 83,89 ****
  	 */
  	if (rablkno && !incore(dev, rablkno)) {
  		rabp = getblk(dev, rablkno);
! 		if (rabp->b_flags & B_DONE) {
  			brelse(rabp);
  			trace(TR_BREADHITRA);
  		} else {
--- 83,89 ----
  	 */
  	if (rablkno && !incore(dev, rablkno)) {
  		rabp = getblk(dev, rablkno);
! 		if (rabp->b_flags & (B_DONE|B_DELWRI)) {
  			brelse(rabp);
  			trace(TR_BREADHITRA);
  		} else {
***************
*** 185,191 ****
  		wakeup((caddr_t)bfreelist);
  	}
  	if (bp->b_flags&B_ERROR)
! 		bp->b_dev = NODEV;	/* no assoc */
  
  	/*
  	 * Stick the buffer back on a free list.
--- 185,194 ----
  		wakeup((caddr_t)bfreelist);
  	}
  	if (bp->b_flags&B_ERROR)
! 		if (bp->b_flags & B_LOCKED)
! 			bp->b_flags &= ~B_ERROR;	/* try again later */
! 		else
! 			bp->b_dev = NODEV;  		/* no assoc */
  
  	/*
  	 * Stick the buffer back on a free list.
***************
*** 196,202 ****
  		flist = &bfreelist[BQ_AGE];
  		binsheadfree(bp, flist);
  	} else {
! 		if (bp->b_flags & B_AGE)
  			flist = &bfreelist[BQ_AGE];
  		else
  			flist = &bfreelist[BQ_LRU];
--- 199,207 ----
  		flist = &bfreelist[BQ_AGE];
  		binsheadfree(bp, flist);
  	} else {
! 		if (bp->b_flags & B_LOCKED)
! 			flist = &bfreelist[BQ_LOCKED];
! 		else if (bp->b_flags & B_AGE)
  			flist = &bfreelist[BQ_AGE];
  		else
  			flist = &bfreelist[BQ_LRU];
***************
*** 331,338 ****
  		bwrite(bp);
  		goto loop;
  	}
! #ifdef NRAM > 0
! 	if(bp->b_flags & B_RAMREMAP) {
  		register memaddr paddr;	/* click address of real buffer */
  		extern memaddr bpaddr;
  
--- 336,342 ----
  		bwrite(bp);
  		goto loop;
  	}
! 	if(bp->b_flags & (B_RAMREMAP|B_PHYS)) {
  		register memaddr paddr;	/* click address of real buffer */
  		extern memaddr bpaddr;
  
***************
*** 344,350 ****
  		bp->b_un.b_addr = (caddr_t)(paddr << 6);
  		bp->b_xmem = (paddr >> 10) & 077;
  	}
- #endif
  	trace(TR_BRELSE);
  	bp->b_flags = B_BUSY;
  	return (bp);
--- 348,353 ----
***************
*** 454,459 ****
--- 457,477 ----
  		}
  	}
  	splx(s);
+ }
+ 
+ /*
+  * Pick up the device's error number and pass it to the user;
+  * if there is an error but the number is 0 set a generalized code.
+  */
+ geterror(bp)
+ 	register struct buf *bp;
+ {
+ 	register int error = 0;
+ 
+ 	if (bp->b_flags&B_ERROR)
+ 		if ((error = bp->b_error)==0)
+ 			return(EIO);
+ 	return (error);
  }
  
  /*
*** /usr/src/sys/h/buf.h.old	Fri Jun 22 15:24:49 1990
--- /usr/src/sys/h/buf.h	Sun May 26 23:02:08 1991
***************
*** 73,79 ****
  #define	bftopaddr(bp)	((u_int)(bp)->b_un.b_addr >> 6 | (bp)->b_xmem << 10)
  #define	dkblock(bp)	((bp)->b_blkno)
  #define	dkunit(bp)	(minor((bp)->b_dev) >> 3)
- #define	geterror(bp)	((bp)->b_flags&B_ERROR ? (bp)->b_error ? (bp)->b_error : EIO : 0)
  
  #if defined(KERNEL) && !defined(SUPERVISOR)
  #define	BUFHSZ	16	/* must be power of 2 */
--- 73,78 ----
***************
*** 108,114 ****
  #define	B_TAPE 		0x00400		/* this is a magtape (no bdwrite) */
  #define	B_INVAL		0x00800		/* does not contain valid info */
  #define	B_BAD		0x01000		/* bad block revectoring in progress */
! #define	B_RH70		0x02000		/* device is talking to an RH70 */
  #define	B_UBAREMAP	0x04000		/* addr UNIBUS virtual, not physical */
  #define	B_RAMREMAP	0x08000		/* remapped into ramdisk */
  
--- 107,113 ----
  #define	B_TAPE 		0x00400		/* this is a magtape (no bdwrite) */
  #define	B_INVAL		0x00800		/* does not contain valid info */
  #define	B_BAD		0x01000		/* bad block revectoring in progress */
! #define	B_LOCKED	0x02000		/* locked in core (not reusable) */
  #define	B_UBAREMAP	0x04000		/* addr UNIBUS virtual, not physical */
  #define	B_RAMREMAP	0x08000		/* remapped into ramdisk */
  
*** /usr/src/sys/pdpstand/boot.c.old	Tue Apr 23 13:08:44 1991
--- /usr/src/sys/pdpstand/boot.c	Mon May 27 20:33:44 1991
***************
*** 3,9 ****
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)boot.c	2.0 (2.11BSD) 4/20/91
   */
  #include "../h/param.h"
  #include "../machine/seg.h"
--- 3,9 ----
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)boot.c	2.1 (2.11BSD) 5/25/91
   */
  #include "../h/param.h"
  #include "../machine/seg.h"
***************
*** 12,24 ****
  #include "../h/inode.h"
  #include "../h/reboot.h"
  #include "saio.h"
- 
  #include <a.out.h>
  
- #ifndef RB_DEFNAME
- #	define	RB_DEFNAME	"xp(0,0)unix"
- #endif
- 
  #undef	btoc			/* to save space */
  #define	KB	* 1024L
  
--- 12,19 ----
***************
*** 45,51 ****
  extern	char	ADJcsr[];	/* adjustments for ROM csr addresses */
  
  char		module[] = "Boot"; /* this program's name (used by trap) */
- char		line[64] = RB_DEFNAME;
  bool_t		overlaid = 0;
  u_short		pdrproto[16 + NOVL] = {0};
  struct exec	exec;
--- 40,45 ----
***************
*** 131,137 ****
  	caddr_t	*adjcsr;
  	struct loadtable *setup();
  	struct iob *file;
! 	char *rb = RB_DEFNAME;
  
  	maj = major(bootdev);
  	if (maj >= ndevsw) {
--- 125,131 ----
  	caddr_t	*adjcsr;
  	struct loadtable *setup();
  	struct iob *file;
! 	char	line[64], defnam[64], *itoa();
  
  	maj = major(bootdev);
  	if (maj >= ndevsw) {
***************
*** 155,160 ****
--- 149,159 ----
  	bootdev |= (i << 6);	/* controller # to bits 6&7 */
  	printf("\n%d%s from %s(%d,0,0%o)\n", cputype, module, 
  		devsw[major(bootdev)].dv_name, minor(bootdev), bootcsr);
+ 	strcpy(defnam, devsw[major(bootdev)].dv_name);
+ 	strcat(defnam, "(");
+ 	strcat(defnam, itoa(minor(bootdev)));
+ 	strcat(defnam, ",0)unix");
+ 	strcpy(line, defnam);
  	/*
  	 * The machine language will have gotten the bootopts
  	 * if we're an autoboot and will pass them along.
***************
*** 170,177 ****
  		} else
  			printf(": %s\n", line);
  		if (line[0] == '\0') {
! 			printf(": %s\n", rb);
! 			strcpy(line, rb);
  		}
  		i = open(line, 0);
  		j = -1;
--- 169,176 ----
  		} else
  			printf(": %s\n", line);
  		if (line[0] == '\0') {
! 			strcpy(line, defnam);
! 			printf(": %s\n", line);
  		}
  		i = open(line, 0);
  		j = -1;
***************
*** 562,565 ****
--- 561,578 ----
  	register unsigned nclicks;
  {
  	return((unsigned)(((((long) nclicks) + ((long) 63)) >> 6)));
+ }
+ 
+ char *
+ itoa(i)
+ 	register int i;
+ {
+ 	static char x[8];
+ 	register char *cp = x+8;
+ 
+ 	do {
+ 		*--cp = (i % 10) + '0';
+ 		i /= 10;
+ 	} while (i);
+ 	return(cp);
  }
*** /usr/src/sys/pdpstand/Makefile.old	Sun Apr 28 00:12:26 1991
--- /usr/src/sys/pdpstand/Makefile	Sat May 25 23:29:47 1991
***************
*** 5,23 ****
  #	be loaded along with all device drivers.  This is especially
  #	a problem with restor.  Programs should be <= 48K to be safe.
  
- # BPI will compile a primary tape bootstrap capable of supporting 800 (HT and
- # TM), 1600 (HT, some third party TMs, and TS), or 6250 (some third party
- # TMs only).  2.10BSD is only distributed at 1600BPI, but others may have
- # need to make boot tapes at different densities ...
- #
- BPI=	1600
- 
- # RB_DEFNAME is the name the secondary boot will go for if you just type
- # carriage return to the boot prompt, or if boot detects boot options passed
- # in and RB_ASKNAME isn't set.
- #
- RB_DEFNAME=ra(0,0)unix
- 
  # DISK	which disk to take a root dump of for the distribution tape
  # TAPE	which tape to write the distribution on
  # DUMP	where to store a root system dump if you do a ``make dump''
--- 5,10 ----
***************
*** 32,39 ****
  RESTOR=	${ETCSRC}/restor/restor.c
  ICHECK=	${ETCSRC}/icheck.c
  
! DEFS=	-DBPI=${BPI} -DRB_DEFNAME='"${RB_DEFNAME}"' -DSTANDALONE \
! 	-I${ROOT}/usr/include
  CFLAGS=	-O ${DEFS}
  
  BOOT=	M.o boot.o ubmapset.o
--- 19,25 ----
  RESTOR=	${ETCSRC}/restor/restor.c
  ICHECK=	${ETCSRC}/icheck.c
  
! DEFS=	-DSTANDALONE -I${ROOT}/usr/include
  CFLAGS=	-O ${DEFS}
  
  BOOT=	M.o boot.o ubmapset.o
*** /usr/src/sys/GENERIC/localopts.h.old	Sat Apr  6 01:05:54 1991
--- /usr/src/sys/GENERIC/localopts.h	Sun May 19 01:10:43 1991
***************
*** 16,22 ****
  #define MAXMEM	(300*16)
  #define LINEHZ	60
  #ifdef KERNEL
! #define NBUF	20
  #define	Q22	1
  #define UNIBUS_MAP 1
  #define VIRUS_VFORK 1
--- 16,22 ----
  #define MAXMEM	(300*16)
  #define LINEHZ	60
  #ifdef KERNEL
! #define NBUF	32
  #define	Q22	1
  #define UNIBUS_MAP 1
  #define VIRUS_VFORK 1



More information about the Comp.bugs.2bsd mailing list