From: sms@WLV.IIPO.GTEGSC.COM (Steven M. Schultz)
Subject: Serious standalone 'restor' bug (+fix) (#88)
Organization: GTE Government Systems
Date: Sun, 3 Jan 93 05:23:55 GMT

Subject: Serious standalone 'restor' bug (+fix) (#88)
Index:	sys/pdpstand/sys,ra.c+others 2.11BSD

Description:
	There are two major problems in the standalone runtime.

	The first problem shows up when using a raw disc as the input 
	file with standalone 'restor'.  It does not work at all.  Also
	not working is the case where a multivolume dump (several floppies 
	for example) is used with standalone restor.

	The second problem is specific to the MSCP standalone driver.  When
	both input and output files are drives on the same controller (the
	input file is a RX33 and the disc being restor'd to is an RD54)
	'restor' locks up without an error.

Repeat-By:
	The first problem is fairly easy to reproduce.  Use as input to
	standalone restor anything except a tape as the input device.  The
	multivolume part of the problem is also fairly easy, simply attempt
	to use 4 RX33 floppies (to create them tell 'dump' that he is using
	a tape 70 feet long) as input to standalone restor.  After a volume
	change note that restor keeps prompting for the next volume - this is
	because the block number to read was not reset when the diskette was
	changed and the device driver is rejecting the i/o request because
	the block number is out of range.

	The second problem is a bit more difficult to duplicate.  The
	scenario in which the problem involved a RX33 [unit 1] and a RD54 
	[unit 0] both attached to the same RQDX3.  The "Tape? " prompt was
	answered "ra(1,0)" (after making sure that the first volume of the
	dump set was in the RX33).  The "Disk? " prompt was answered "ra(0,0)".
	After about a minute both disc drives would cease activity.  Halting
	and single stepping the processor showed an endless loop in the
	'ra.c' driver waiting for an operation to complete.

Fix:
	The patches below fix both problems.

	Problem 1 was caused by the 'sys.c' module assuming that all
	i/o operations to non-files (raw devices) were 1kb (CLSIZE) in
	length.  The block number to read (or write) next would thus only
	be incremented by 2 even though 'restor' was reading 20 blocks
	(10kb) at a time.  The multivolume part of this problem was caused
	by the block number never being cleared.  Thus reading of the
	second RX33 (~2400 blocks) would start at block number 2400 (the
	end of volume 1).

	Problem 2 was fixed by 1) providing the RQDX3 with an interrupt 
	vector in the process of going to step 2 in the initialization 
	sequence and 2) removing the "request interrupt" bit in the 
	request descriptors.  Also added were minor delays before accessing
	the device registers and checks for failure to enter the various
	steps during initialization.

	With the fixes above installed the standalone restor program
	exceeded 48kb (max size of a standalone program).  To reduce
	restor's size several small changes were made to other drivers
	(br, rl, si, tmscp).  These changes consist of changing the
	"segflag & 3" statements to simply "segflag".  The "& 3" was
	redundant since 'segflag' is never anything but 1, 2 or 3 anyhow
	(from M.s)!  In sys.c a couple of 'goto' statments were added
	to remove redundant statements and strings.

	The last two changes are somewhat cosmetic, removing references
	to UCB_NKB (which is _always_ defined and has been for many years)
	in two of the (unused) NEW/ modules.

=============================cut here===================================
*** /sys/pdpstand/sys.c.old	Sun Apr 21 00:18:28 1991
--- /sys/pdpstand/sys.c	Sat Jan  2 15:01:48 1993
***************
*** 3,9 ****
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)sys.c	2.0 (2.11BSD) 4/20/91
   */
  
  #include "../h/param.h"
--- 3,9 ----
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)sys.c	2.1 (2.11BSD) 1/2/93
   */
  
  #include "../h/param.h"
***************
*** 140,149 ****
  	 * fetch the address from the inode
  	 */
  	nb = ip->i_addr[NADDR-j];
! 	if (nb == 0) {
! 		printf("bn void %D\n", bn);
! 		return((daddr_t)0);
! 	}
  
  	/*
  	 * fetch through the indirect blocks
--- 140,147 ----
  	 * fetch the address from the inode
  	 */
  	nb = ip->i_addr[NADDR-j];
! 	if (nb == 0)
! 		goto bnvoid;
  
  	/*
  	 * fetch through the indirect blocks
***************
*** 161,166 ****
--- 159,165 ----
  		i = (bn>>sh) & NMASK;
  		nb = bap[i];
  		if (nb == 0) {
+ bnvoid:
  			printf("bn void %D\n", bn);
  			return((daddr_t)0);
  		}
***************
*** 243,249 ****
  	register struct iob *io;
  
  	if (ptr != 0) {
! 		printf("illegal lseek\n");
  		return(-1);
  	}
  	fdesc -= 3;
--- 242,248 ----
  	register struct iob *io;
  
  	if (ptr != 0) {
! 		printf("lseek\n");
  		return(-1);
  	}
  	fdesc -= 3;
***************
*** 348,354 ****
  		file->i_cc = count;
  		file->i_ma = buf;
  		i = devread(file);
! 		file->i_bn += CLSIZE;
  		return(i);
  	}
  	else {
--- 347,353 ----
  		file->i_cc = count;
  		file->i_ma = buf;
  		i = devread(file);
! 		file->i_bn += (count / NBPG);
  		return(i);
  	}
  	else {
***************
*** 385,391 ****
  	file->i_cc = count;
  	file->i_ma = buf;
  	i = devwrite(file);
! 	file->i_bn += CLSIZE;
  	return(i);
  }
  
--- 384,390 ----
  	file->i_cc = count;
  	file->i_ma = buf;
  	i = devwrite(file);
! 	file->i_bn += (count / NBPG);
  	return(i);
  }
  
***************
*** 454,462 ****
  		return(-1);
  	if (*++cp == '\0') {
  		file->i_flgs |= how+1;
! 		file->i_cc = 0;
! 		file->i_offset = 0;
! 		return(fdesc+3);
  	}
  	if ((i = find(cp, file)) == 0) {
  		file->i_flgs = 0;
--- 453,459 ----
  		return(-1);
  	if (*++cp == '\0') {
  		file->i_flgs |= how+1;
! 		goto comret;
  	}
  	if ((i = find(cp, file)) == 0) {
  		file->i_flgs = 0;
***************
*** 468,476 ****
  		return(-1);
  	}
  	openi(i, file);
  	file->i_offset = 0;
  	file->i_cc = 0;
! 	file->i_flgs |= F_FILE | (how+1);
  	return(fdesc+3);
  }
  
--- 465,475 ----
  		return(-1);
  	}
  	openi(i, file);
+ 	file->i_flgs |= F_FILE | (how+1);
+ comret:
  	file->i_offset = 0;
  	file->i_cc = 0;
! 	file->i_bn = 0;
  	return(fdesc+3);
  }
  
*** /sys/pdpstand/ra.c.old	Thu Dec 26 12:11:36 1991
--- /sys/pdpstand/ra.c	Sat Jan  2 00:29:55 1993
***************
*** 3,14 ****
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)ra.c	2.0 (2.11BSD) 4/20/91
   */
  
  /*
!  * RAxx disk device driver
!  * RQDX?/UDA50 (rx33, rx50, rd5?, ra??)
   */
  #include "../h/param.h"
  #include "../h/inode.h"
--- 3,13 ----
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)ra.c	2.3 (2.11BSD GTE) 1/1/93
   */
  
  /*
!  * MSCP disk device driver (rx23, rx33, rx50, rd??, ra??, rz??)
   */
  #include "../h/param.h"
  #include "../h/inode.h"
***************
*** 17,22 ****
--- 16,22 ----
  #include "saio.h"
  
  #define	NRA	2
+ #define	RA_SMASK	(RA_STEP4|RA_STEP3|RA_STEP2|RA_STEP1)
  
  	struct	radevice *RAcsr[NRA + 1] =
  		{
***************
*** 69,94 ****
  	racom = &rd[ctlr];
  
  	if (rainit[ctlr] == 0) {
! 		raaddr->raip = 0;
! 		while ((raaddr->rasa & RA_STEP1) == 0)
! 			continue;
! 		raaddr->rasa = RA_ERR;
! 		while ((raaddr->rasa & RA_STEP2) == 0)
! 			continue;
  		raaddr->rasa = (short)&racom->ra_ca.ca_ringbase;
! 		while ((raaddr->rasa & RA_STEP3) == 0)
! 			continue;
! 		raaddr->rasa = (short)(segflag & 3);
! 		while ((raaddr->rasa & RA_STEP4) == 0)
! 			continue;
  		raaddr->rasa = RA_GO;
  		racom->ra_ca.ca_rspl = (short)&racom->ra_rsp.m_cmdref;
! 		racom->ra_ca.ca_rsph = (short)(segflag & 3);
  		racom->ra_ca.ca_cmdl = (short)&racom->ra_cmd.m_cmdref;
! 		racom->ra_ca.ca_cmdh = (short)(segflag & 3);
  		racom->ra_cmd.m_cntflgs = 0;
  		if (racmd(M_O_STCON, io->i_unit) < 0) {
! 			printf("RA%d ctlr STCON err\n", ctlr);
  			return(-1);
  		}
  		rainit[ctlr] = 1;
--- 69,94 ----
  	racom = &rd[ctlr];
  
  	if (rainit[ctlr] == 0) {
! again:		raaddr->raip = 0;
! 		if 	(ra_step(raaddr, RA_STEP1, 1))
! 			goto again;
! 		raaddr->rasa = RA_ERR | (0154/4);
! 		if	(ra_step(raaddr, RA_STEP2, 2))
! 			goto again;
  		raaddr->rasa = (short)&racom->ra_ca.ca_ringbase;
! 		if	(ra_step(raaddr, RA_STEP3, 3))
! 			goto again;
! 		raaddr->rasa = segflag;
! 		if	(ra_step(raaddr, RA_STEP4, 4))
! 			goto again;
  		raaddr->rasa = RA_GO;
  		racom->ra_ca.ca_rspl = (short)&racom->ra_rsp.m_cmdref;
! 		racom->ra_ca.ca_rsph = segflag;
  		racom->ra_ca.ca_cmdl = (short)&racom->ra_cmd.m_cmdref;
! 		racom->ra_ca.ca_cmdh = segflag;
  		racom->ra_cmd.m_cntflgs = 0;
  		if (racmd(M_O_STCON, io->i_unit) < 0) {
! 			printf("RA%d STCON err\n", ctlr);
  			return(-1);
  		}
  		rainit[ctlr] = 1;
***************
*** 114,120 ****
  	register int unit = UNITn(io->i_unit);
  
  	if (racmd(M_O_ONLIN, io->i_unit) < 0) {
! 		printf("RA%d,%d: online err\n", ctlr, unit);
  		return(-1);
  	}
  	raonline[ctlr][unit] = rd[ctlr].ra_rsp.m_uslow +  
--- 114,120 ----
  	register int unit = UNITn(io->i_unit);
  
  	if (racmd(M_O_ONLIN, io->i_unit) < 0) {
! 		printf("RA%d: online err\n", io->i_unit);
  		return(-1);
  	}
  	raonline[ctlr][unit] = rd[ctlr].ra_rsp.m_uslow +  
***************
*** 128,133 ****
--- 128,134 ----
  	register struct mscp *mp;
  	register int ctlr = CTLRn(unit);
  	register struct ra *racom = &rd[ctlr];
+ 	struct	radevice *csr = RAcsr[ctlr];
  	int i;
  
  	racom->ra_cmd.m_opcode = op;
***************
*** 134,157 ****
  	racom->ra_cmd.m_unit = UNITn(unit);
  	racom->ra_rsp.m_header.ra_msglen = sizeof(struct mscp);
  	racom->ra_cmd.m_header.ra_msglen = sizeof(struct mscp);
! 	racom->ra_ca.ca_rsph = RA_OWN | RA_INT | (segflag & 3);
! 	racom->ra_ca.ca_cmdh = RA_OWN | RA_INT | (segflag & 3);
! 	i = RAcsr[ctlr]->raip;
  	while (1) {
! 		if (racom->ra_ca.ca_cmdint)
! 			racom->ra_ca.ca_cmdint = 0;
! 		if (racom->ra_ca.ca_rspint)
  			break;
  	}
! 	racom->ra_ca.ca_rspint = 0;
! 	mp = &racom->ra_rsp;
! 	if ((mp->m_opcode != (op | M_O_END)) ||
! 	    ((mp->m_status & M_S_MASK) != M_S_SUCC)) {
! 		printf("RA%d,%d: cmd err op=%x, sts=%x\n",
! 			ctlr, unit, mp->m_opcode, mp->m_status);
  		return(-1);
  	}
  	return(0);
  }
  
  rastrategy(io, func)
--- 135,171 ----
  	racom->ra_cmd.m_unit = UNITn(unit);
  	racom->ra_rsp.m_header.ra_msglen = sizeof(struct mscp);
  	racom->ra_cmd.m_header.ra_msglen = sizeof(struct mscp);
! 	racom->ra_ca.ca_rsph = RA_OWN | segflag;
! 	racom->ra_ca.ca_cmdh = RA_OWN | segflag;
! 	i = csr->raip;
! 	mp = &racom->ra_rsp;
  	while (1) {
! 		while	(racom->ra_ca.ca_cmdh & RA_OWN) {
! 			delay(200);		/* SA access delay */
! 			if	(csr->rasa & (RA_ERR|RA_SMASK))
! 				goto fail;
! 		}
! 		while	(racom->ra_ca.ca_rsph & RA_OWN) {
! 			delay(200);		/* SA access delay */
! 			if	(csr->rasa & (RA_ERR|RA_SMASK))
! 				goto fail;
! 		}
! 		racom->ra_ca.ca_cmdint = 0;
! 		racom->ra_ca.ca_rspint = 0;
! 		if (mp->m_opcode == (op | M_O_END))
  			break;
+ 		printf("RA%d: rsp %x op %x ignored\n",
+ 			unit,mp->m_header.ra_credits & 0xf0, mp->m_opcode);
+ 		racom->ra_ca.ca_rsph |= RA_OWN;
  	}
! 	if ((mp->m_status & M_S_MASK) != M_S_SUCC) {
! 		printf("RA%d: err op=%x sts=%x\n",unit,
! 			mp->m_opcode, mp->m_status);
  		return(-1);
  	}
  	return(0);
+ fail:
+ 	printf("RA%d: rasa=%o\n", ctlr, csr->rasa);
  }
  
  rastrategy(io, func)
***************
*** 170,177 ****
  	mp->m_lbn_h = hiint(io->i_bn);
  	mp->m_bytecnt = io->i_cc;
  	mp->m_buf_l = (ushort)io->i_ma;
! 	mp->m_buf_h = segflag & 3;
  	if (racmd(func == READ ? M_O_READ : M_O_WRITE, io->i_unit) < 0)
  		return(-1);
  	return(io->i_cc);
  }
--- 184,217 ----
  	mp->m_lbn_h = hiint(io->i_bn);
  	mp->m_bytecnt = io->i_cc;
  	mp->m_buf_l = (ushort)io->i_ma;
! 	mp->m_buf_h = segflag;
  	if (racmd(func == READ ? M_O_READ : M_O_WRITE, io->i_unit) < 0)
  		return(-1);
  	return(io->i_cc);
  }
+ 
+ ra_step(csr, mask, step)
+ 	register struct radevice *csr;
+ 	int mask, step;
+ 	{
+ 	register int	cnt;
+ 
+ 	for	(cnt = 0; (csr->rasa & mask) == 0; )
+ 		{
+ 		delay(2000);
+ 		cnt++;
+ 		if	(cnt < 10000)
+ 			continue;
+ 		printf("RA(%o) failed step %d. retrying\n",csr,step);
+ 		return(1);
+ 		}
+ 	return(0);
+ 	}
+ 
+ delay(l)
+ 	int	l;
+ 	{
+ 
+ 	while	(l > 0)
+ 		l--;
+ 	}
*** /sys/pdpstand/br.c.old	Sun Apr 21 00:05:45 1991
--- /sys/pdpstand/br.c	Sat Jan  2 00:20:10 1993
***************
*** 3,9 ****
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)br.c	2.0 (2.11BSD) 4/20/91
   */
  
  /*
--- 3,9 ----
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)br.c	2.1 (2.11BSD) 1/2/93
   */
  
  /*
***************
*** 50,56 ****
  		while ((braddr->brcs.w & BR_RDY) == 0 && --ctr)
  			continue;
  		if (braddr->brcs.w & BR_HE) {
! 			printf("br%d,%d not ready\n", ctlr,unit);
  			return(-1);
  		}
  		com = braddr->brae;
--- 50,56 ----
  		while ((braddr->brcs.w & BR_RDY) == 0 && --ctr)
  			continue;
  		if (braddr->brcs.w & BR_HE) {
! 			printf("br%d,%d !ready\n", ctlr,unit);
  			return(-1);
  		}
  		com = braddr->brae;
***************
*** 84,91 ****
  	while ((braddr->brcs.w& BR_RDY)==0)
  		continue;
  	if (braddr->brcs.w < 0) {	/* error bit */
! 		printf("br%d,%d err: cy=%d tr=%d sc=%d er=%o ds=%o\n",
! 		    ctlr, unit, cn, tn, sn, braddr->brer, braddr->brds);
  		return(-1);
  	}
  	return(io->i_cc);
--- 84,91 ----
  	while ((braddr->brcs.w& BR_RDY)==0)
  		continue;
  	if (braddr->brcs.w < 0) {	/* error bit */
! 		printf("br%d err: cy=%d tr=%d sc=%d er=%o ds=%o\n",
! 		    unit, cn, tn, sn, braddr->brer, braddr->brds);
  		return(-1);
  	}
  	return(io->i_cc);
*** /sys/pdpstand/rl.c.old	Sun Apr 21 00:15:03 1991
--- /sys/pdpstand/rl.c	Sat Jan  2 00:31:59 1993
***************
*** 3,9 ****
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)rl.c	2.0 (2.11BSD) 4/20/91
   */
  
  /*
--- 3,9 ----
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)rl.c	2.1 (2.11BSD) 1/2/93
   */
  
  /*
***************
*** 117,123 ****
  	rlp->chn = io->i_bn/20;
  	rlp->sn = (io->i_bn%20) << 1;
  	rlp->bleft = io->i_cc;
! 	rlp->addr.w[0] = segflag & 3;
  	rlp->addr.w[1] = (int)io->i_ma;
  	rlp->com = (drive << 8);
  	if (func == READ)
--- 117,123 ----
  	rlp->chn = io->i_bn/20;
  	rlp->sn = (io->i_bn%20) << 1;
  	rlp->bleft = io->i_cc;
! 	rlp->addr.w[0] = segflag;
  	rlp->addr.w[1] = (int)io->i_ma;
  	rlp->com = (drive << 8);
  	if (func == READ)
*** /sys/pdpstand/si.c.old	Sun Apr 21 00:15:46 1991
--- /sys/pdpstand/si.c	Sat Jan  2 00:32:46 1993
***************
*** 65,71 ****
  	siaddr->sihsr = (tn << 5) + sn;
  	siaddr->simar = io->i_ma;
  	siaddr->siwcr = io->i_cc >> 1;
! 	ii = ((segflag & 03) << 4) | SI_GO;
  	if (func == READ)
  		ii |= SI_READ;
  	else if (func == WRITE)
--- 65,71 ----
  	siaddr->sihsr = (tn << 5) + sn;
  	siaddr->simar = io->i_ma;
  	siaddr->siwcr = io->i_cc >> 1;
! 	ii = (segflag << 4) | SI_GO;
  	if (func == READ)
  		ii |= SI_READ;
  	else if (func == WRITE)
*** /sys/pdpstand/tmscp.c.old	Sun Apr 21 00:21:54 1991
--- /sys/pdpstand/tmscp.c	Sat Jan  2 00:33:59 1993
***************
*** 125,131 ****
  #		define STEP2GOOD (TMSCP_STEP3)
  		if ((tmscpaddr->tmscpsa&STEP2MASK) != STEP2GOOD)
  			printf(opnmsg, ctlr, 2, tmscpaddr->tmscpsa);
! 		tmscpaddr->tmscpsa = (short) (segflag & 3);
   
  		while ((tmscpaddr->tmscpsa & TMSCP_STEP4) == 0)
  			;
--- 125,131 ----
  #		define STEP2GOOD (TMSCP_STEP3)
  		if ((tmscpaddr->tmscpsa&STEP2MASK) != STEP2GOOD)
  			printf(opnmsg, ctlr, 2, tmscpaddr->tmscpsa);
! 		tmscpaddr->tmscpsa = segflag;
   
  		while ((tmscpaddr->tmscpsa & TMSCP_STEP4) == 0)
  			;
***************
*** 205,215 ****
  	 * Init cmd & rsp area
  	 */
  	tms->tmscp_ca.ca_cmddsc[0].lsh = (short)&tms->tmscp_cmd.mscp_cmdref;
! 	tms->tmscp_ca.ca_cmddsc[0].hsh = segflag & 3;
  	tms->tmscp_cmd.mscp_dscptr = (long *)tms->tmscp_ca.ca_cmddsc;
  	tms->tmscp_cmd.mscp_header.tmscp_vcid = 1;	/* for tape */
  	tms->tmscp_ca.ca_rspdsc[0].lsh = (short)&tms->tmscp_rsp.mscp_cmdref;
! 	tms->tmscp_ca.ca_rspdsc[0].hsh = segflag & 3;
  	tms->tmscp_rsp.mscp_dscptr = (long *)tms->tmscp_ca.ca_rspdsc;
  	tms->tmscp_cmd.mscp_cntflgs = 0;
  
--- 205,215 ----
  	 * Init cmd & rsp area
  	 */
  	tms->tmscp_ca.ca_cmddsc[0].lsh = (short)&tms->tmscp_cmd.mscp_cmdref;
! 	tms->tmscp_ca.ca_cmddsc[0].hsh = segflag;
  	tms->tmscp_cmd.mscp_dscptr = (long *)tms->tmscp_ca.ca_cmddsc;
  	tms->tmscp_cmd.mscp_header.tmscp_vcid = 1;	/* for tape */
  	tms->tmscp_ca.ca_rspdsc[0].lsh = (short)&tms->tmscp_rsp.mscp_cmdref;
! 	tms->tmscp_ca.ca_rspdsc[0].hsh = segflag;
  	tms->tmscp_rsp.mscp_dscptr = (long *)tms->tmscp_ca.ca_rspdsc;
  	tms->tmscp_cmd.mscp_cntflgs = 0;
  
***************
*** 280,286 ****
  	mp->mscp_unit = UNITn(io->i_unit);
  	mp->mscp_bytecnt = io->i_cc;
  	mp->mscp_buffer_l = (u_short)io->i_ma;
! 	mp->mscp_buffer_h = segflag & 3;
  	if (tmscpcmd(ctlr, func == READ ? M_OP_READ : M_OP_WRITE, 0)==0) {
  		printf("tms%d,%d: I/O err\n", ctlr, UNITn(io->i_unit));
  		return(-1);
--- 280,286 ----
  	mp->mscp_unit = UNITn(io->i_unit);
  	mp->mscp_bytecnt = io->i_cc;
  	mp->mscp_buffer_l = (u_short)io->i_ma;
! 	mp->mscp_buffer_h = segflag;
  	if (tmscpcmd(ctlr, func == READ ? M_OP_READ : M_OP_WRITE, 0)==0) {
  		printf("tms%d,%d: I/O err\n", ctlr, UNITn(io->i_unit));
  		return(-1);
*** /sys/pdpstand/boot.c.old	Mon May 27 20:33:44 1991
--- /sys/pdpstand/boot.c	Sat Jan  2 00:18:13 1993
***************
*** 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"
--- 3,9 ----
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)boot.c	2.2 (2.11BSD) 1/1/93
   */
  #include "../h/param.h"
  #include "../machine/seg.h"
***************
*** 128,137 ****
  	char	line[64], defnam[64], *itoa();
  
  	maj = major(bootdev);
! 	if (maj >= ndevsw) {
! 		printf("bootdev: 0%o", bootdev);
! 		_stop("bad major");
! 	}
  	adjcsr = (caddr_t *)((short)bootcsr - ADJcsr[maj]);
  	for (i = 0; devsw[maj].dv_csr != (caddr_t) -1; i++) {
  		if (adjcsr == devsw[maj].dv_csr[i])
--- 128,135 ----
  	char	line[64], defnam[64], *itoa();
  
  	maj = major(bootdev);
! 	if (maj >= ndevsw)
! 		_stop("bad major");		/* can't happen */
  	adjcsr = (caddr_t *)((short)bootcsr - ADJcsr[maj]);
  	for (i = 0; devsw[maj].dv_csr != (caddr_t) -1; i++) {
  		if (adjcsr == devsw[maj].dv_csr[i])
***************
*** 141,150 ****
  			break;
  		}
  	}
! 	if (devsw[maj].dv_csr[i] == (caddr_t *) -1) {
! 		printf("bootdev: 0%o", bootdev);
  		_stop("no free csr slots");
- 	}
  	bootdev &= ~(3 << 6);
  	bootdev |= (i << 6);	/* controller # to bits 6&7 */
  	printf("\n%d%s from %s(%d,0,0%o)\n", cputype, module, 
--- 139,146 ----
  			break;
  		}
  	}
! 	if (devsw[maj].dv_csr[i] == (caddr_t *) -1)
  		_stop("no free csr slots");
  	bootdev &= ~(3 << 6);
  	bootdev |= (i << 6);	/* controller # to bits 6&7 */
  	printf("\n%d%s from %s(%d,0,0%o)\n", cputype, module, 
***************
*** 219,225 ****
  	for (i = 0; i < sizeof(loadtable) / sizeof(struct loadtable); i++)
  		if (loadtable[i].lt_magic == exec.a_magic)
  			return(&loadtable[i]);
! 	printf("Bad magic number 0%o\n", exec.a_magic);
  	return((struct loadtable *) NULL);
  }
  
--- 215,221 ----
  	for (i = 0; i < sizeof(loadtable) / sizeof(struct loadtable); i++)
  		if (loadtable[i].lt_magic == exec.a_magic)
  			return(&loadtable[i]);
! 	printf("Bad magic # 0%o\n", exec.a_magic);
  	return((struct loadtable *) NULL);
  }
  
***************
*** 239,245 ****
  	 */
  	if (exec.a_magic == A_MAGIC3 || exec.a_magic == A_MAGIC6)
  		if (!sep_id) {
! 			printf("Cannot load separate I & D object files\n");
  			return(-1);
  		} else
  			setsep();
--- 235,241 ----
  	 */
  	if (exec.a_magic == A_MAGIC3 || exec.a_magic == A_MAGIC6)
  		if (!sep_id) {
! 			printf("Can't load split I&D files\n");
  			return(-1);
  		} else
  			setsep();
***************
*** 291,297 ****
  				/*
  				 * This ``cannot happen.''
  				 */
! 				printf("Unknown segment type in load table:  %d\n", segtype);
  				return(-1);
  				/*NOTREACHED*/
  		}
--- 287,293 ----
  				/*
  				 * This ``cannot happen.''
  				 */
! 				printf("seg type botch: %d\n", segtype);
  				return(-1);
  				/*NOTREACHED*/
  		}
***************
*** 299,307 ****
  		seglen = ctob(btoc(seglen));
  		if (((long) seglen) > lm->seg_len) {
  			if (segtype == SEG_OVLY)
! 				printf("%s %d too large by %D bytes", segname, ovseg, lm->seg_len -((long) seglen));
  			else
! 				printf("%s too large by %D bytes", segname, lm->seg_len -((long) seglen));
  			return(-1);
  		}
  		if (segtype == SEG_TEXT)
--- 295,303 ----
  		seglen = ctob(btoc(seglen));
  		if (((long) seglen) > lm->seg_len) {
  			if (segtype == SEG_OVLY)
! 				printf("%s %d over by %D bytes", segname, ovseg, lm->seg_len -((long) seglen));
  			else
! 				printf("%s over by %D bytes", segname, lm->seg_len -((long) seglen));
  			return(-1);
  		}
  		if (segtype == SEG_TEXT)
***************
*** 308,320 ****
  		    switch (exec.a_magic) {
  			case A_MAGIC5:
  			    if (seglen <= 8 KB) {
! 				printf("Base segment too small, 8K minimum\n");
  				return(-1);
  			    }
  			    break;
  			case A_MAGIC6:
  			    if (seglen <= 48 KB) {
! 				printf("Base segment too small, 48K minimum\n");
  				return(-1);
  			    }
  			    break;
--- 304,316 ----
  		    switch (exec.a_magic) {
  			case A_MAGIC5:
  			    if (seglen <= 8 KB) {
! 				printf("Base too small, 8K min\n");
  				return(-1);
  			    }
  			    break;
  			case A_MAGIC6:
  			    if (seglen <= 48 KB) {
! 				printf("Base too small, 48K min\n");
  				return(-1);
  			    }
  			    break;
*** /sys/pdpstand/NEW/dskinit.c.old	Thu Jan  5 21:52:31 1989
--- /sys/pdpstand/NEW/dskinit.c	Wed Dec 23 23:30:48 1992
***************
*** 57,66 ****
   * Must use 512 instead of BSIZE (1024 for new file system).
   * Fred Canter 6/12/85
   */
- #ifdef	UCB_NKB
  #undef	BSIZE
  #define	BSIZE	512
- #endif	UCB_NKB
  
  #define READ 1
  #define WRITE 0
--- 57,64 ----
*** /sys/pdpstand/NEW/bads.c.old	Thu Jan  5 21:50:49 1989
--- /sys/pdpstand/NEW/bads.c	Wed Dec 23 23:30:58 1992
***************
*** 49,58 ****
   * Must use 512 instead of BSIZE (1024 for new file system).
   * Fred Canter 6/12/85
   */
- #ifdef	UCB_NKB
  #undef	BSIZE
  #define	BSIZE	512
- #endif	UCB_NKB
  
  /*
   *	BAD144 info for disk bad blocking. A zero entry in
--- 49,56 ----