Subject: documentation update, makesimtape update (#383)
Index:	doc/2.10/setup.2.11/2.t,sys/pdpstand/makesimtape.c 2.11BSD

Description:
	The TM bootstrap togglein in the setup documentation is wrong.

	Bob Supnik's PDP-11 simulator has a new tape format.

Repeat-By:
	Attempt to use the TM bootstrap given in the setup documentation.  The
	system will simply hang.

	Create a boot tape using the existing 'makesimtape' program.  Watch
	version 2.2d of the simulator fail to find any data.

Fix:
	The documentation was not updated when the bootblocks were rewritten
	rewritten to accept the CSR of the booting controller in R1 and the
	unit number in R0.  This makes it possible to boot from any unit on
	any controller but the togglein routines need to be changed to match
	the bootblocks.

	The virtual tape format change between version 2.2d and 2.3 of Bob's
	simulator.  Instead of a simple 16 bit count at the beginning of each
	record there is now a 32 bit (little-endian) bytecount at the front and
	back of each record.  The byte order of the record size needs to be
	shuffled because the PDP-11 is neither a big-endian or a little-endian
	machine with respect to 'long'.

	To install this update cut where indicated, saving to a file (/tmp/383).

	Then:

		patch -p0 < /tmp/383
		cd /sys/pdpstand
		make

	That is all there is to it.  Unless you install 'makesimtape' in
	a public area (not done by the Makefile since the usual usage is to
	create boot tapes from the files in pdpstand/) there's nothing to
	install.

	You may want to format and print out the TM togglein routine if you
	are using the simulator.

	As always this and previous updates to 2.11BSD are available via
	anonymous FTP to either FTP.IIPO.GTEGSC.COM or MOE.2BSD.COM in the
	directory /pub/2.11BSD.

---------------------------cut here------------------------
*** /usr/doc/2.10/setup.2.11/2.t.old	Sat Nov 16 17:16:51 1996
--- /usr/doc/2.10/setup.2.11/2.t	Mon Aug 11 20:53:52 1997
***************
*** 2,8 ****
  .\" All rights reserved.  The Berkeley software License Agreement
  .\" specifies the terms and conditions for redistribution.
  .\"
! .\"	@(#)2.t	1.9 (GTE) 1996/11/16
  .\"
  .ds lq ``
  .ds rq ''
--- 2,8 ----
  .\" All rights reserved.  The Berkeley software License Agreement
  .\" specifies the terms and conditions for redistribution.
  .\"
! .\"	@(#)2.t	1.10 (GTE) 1997/8/11
  .\"
  .ds lq ``
  .ds rq ''
***************
*** 93,104 ****
  .DS
  .TS
  l l.
! 012701	(mov $unit, r1)
  000000	(normally unit 0)
! 012700	(mov $172526, r0)
  172526
! 010040	(mov r0, -(r0))
! 012740	(mov $60003, -(r0))
  060003	(if unit 1 use 060403, etc)
  000777	(br .)
  .TE
--- 93,104 ----
  .DS
  .TS
  l l.
! 012700	(mov $unit, r0)
  000000	(normally unit 0)
! 012701	(mov $172526, r1)
  172526
! 010141	(mov r1, -(r1))
! 012741	(mov $60003, -(r1))
  060003	(if unit 1 use 060403, etc)
  000777	(br .)
  .TE
***************
*** 140,146 ****
  .TE
  .DE
  When this is executed, the first block of the tape will be read into memory.
! Halt the CPU and restart at location 0.
  .PP
  The console should type
  .DS
--- 140,149 ----
  .TE
  .DE
  When this is executed, the first block of the tape will be read into memory.
! Halt the CPU and restart at location 0.  The register \fBr1\fP \fBMUST\fP
! be left pointing at the device \fIcsr\fP.  For the default/first TM or TS
! this is 0172522.  The register \fBr0\fP \fBMUST\fP contain the unit number
! (usually 0).
  .PP
  The console should type
  .DS
*** /usr/src/sys/pdpstand/Makefile.old	Fri Jan 24 17:56:43 1997
--- /usr/src/sys/pdpstand/Makefile	Mon Aug 11 20:26:15 1997
***************
*** 1,4 ****
! #	Makefile	(2.11BSD)	2.2	1997/1/24
  #
  #	The limitations on program size have been removed.  The addition
  #	of disklabel support pushed 'restor' over the limit.  Even with
--- 1,4 ----
! #	Makefile	(2.11BSD)	2.3	1997/8/11
  #
  #	The limitations on program size have been removed.  The addition
  #	of disklabel support pushed 'restor' over the limit.  Even with
***************
*** 13,18 ****
--- 13,19 ----
  #	It is still possible to hand craft a version of the utilities by leaving
  #	out all but the necessary drivers. 
  #
+ # 1997/8/11  - add -O to maketape and makesimtape compile commands
  # 1997/1/24  - remove 'skel' from lists of directories.
  # 1997/1/18  - add 'makesimtape' target.
  # 1996/10/28 - added usr/sbin, usr/libexec and corresponding src directories.
***************
*** 139,148 ****
  	ld -X -o $@ srt0.o conf.o $@.o displaylab.o libsa.a -lc
  
  maketape: maketape.c
! 	cc -o $@ maketape.c
  
  makesimtape: makesimtape.c
! 	cc -o $@ makesimtape.c
  
  toyset: toyset.o srt0.o conf.o libsa.a
  	ld -X -o $@ srt0.o conf.o $@.o libsa.a -lc
--- 140,149 ----
  	ld -X -o $@ srt0.o conf.o $@.o displaylab.o libsa.a -lc
  
  maketape: maketape.c
! 	cc -O -o $@ maketape.c
  
  makesimtape: makesimtape.c
! 	cc -O -o $@ makesimtape.c
  
  toyset: toyset.o srt0.o conf.o libsa.a
  	ld -X -o $@ srt0.o conf.o $@.o libsa.a -lc
*** /usr/src/sys/pdpstand/makesimtape.c.old	Tue Jan 21 20:53:32 1997
--- /usr/src/sys/pdpstand/makesimtape.c	Mon Aug 11 20:21:11 1997
***************
*** 1,7 ****
  /*
!  *	@(#)makesimtape.c	1.0 (2.11BSD) 1997/1/17
   *		Hacked 'maketape.c' to write a file in a format suitable for
!  *		use with Bob Supnik's PDP-11 simulator's emulated tape driver.
   */
  
  #include <stdio.h>
--- 1,12 ----
  /*
!  *	@(#)makesimtape.c	2.0 (2.11BSD) 1997/8/7
   *		Hacked 'maketape.c' to write a file in a format suitable for
!  *		use with Bob Supnik's PDP-11 simulator (V2.3) emulated tape 
!  *		driver.
!  *
!  * 	NOTE: a PDP-11 has to flip the shorts within the long when writing out
!  *	      the record size.  Seems a PDP-11 is neither a little-endian
!  *	      machine nor a big-endian one.
   */
  
  #include <stdio.h>
***************
*** 16,24 ****
  
  	char	buf[MAXB * 512];
  	char	name[50];
! 	int	blksz, recsz;
  	int	mt, fd, cnt;
! 	struct	iovec	iovec[2];
  	void	usage();
  
  main(argc, argv)
--- 21,31 ----
  
  	char	buf[MAXB * 512];
  	char	name[50];
! 	long	recsz, flipped, trl();
! 	int	blksz;
  	int	mt, fd, cnt;
! 	struct	iovec	iovec[3];
! 	struct	iovec	tmark[2];
  	void	usage();
  
  main(argc, argv)
***************
*** 25,31 ****
  	int argc;
  	char *argv[];
  	{
! 	int i, j = 0, k = 0;
  	register char	*outfile = NULL, *infile = NULL;
  	FILE *mf;
  	struct	stat	st;
--- 32,38 ----
  	int argc;
  	char *argv[];
  	{
! 	int i, j = 0, k = 0, zero = 0;
  	register char	*outfile = NULL, *infile = NULL;
  	FILE *mf;
  	struct	stat	st;
***************
*** 66,71 ****
--- 73,81 ----
  		err(1, "Can not open %s", infile);
  		/* NOTREACHED*/
  
+ 	tmark[0].iov_len = sizeof (long);
+ 	tmark[0].iov_base = (char *)&zero;
+ 
  	while	(1)
  		{
  		if	((i = fscanf(mf, "%s %d", name, &blksz))== EOF)
***************
*** 80,94 ****
  			exit(1);
  			}
  		recsz = blksz * 512;	/* convert to bytes */
! 		iovec[0].iov_len = sizeof (int);
  		iovec[0].iov_base = (char *)&recsz;
! 		iovec[1].iov_len = recsz;
  		iovec[1].iov_base = buf;
  
  		if	(strcmp(name, "*") == 0)
  			{
! 			recsz = 0;
! 			if	(writev(mt, iovec, 1) < 0)
  				warn(1, "writev of pseudo tapemark failed");
  			k++;
  			continue;
--- 90,109 ----
  			exit(1);
  			}
  		recsz = blksz * 512;	/* convert to bytes */
! 		iovec[0].iov_len = sizeof (recsz);
! #ifdef	pdp11
! 		iovec[0].iov_base = (char *)&flipped;
! #else
  		iovec[0].iov_base = (char *)&recsz;
! #endif
! 		iovec[1].iov_len = (int)recsz;
  		iovec[1].iov_base = buf;
+ 		iovec[2].iov_len =  iovec[0].iov_len;
+ 		iovec[2].iov_base = iovec[0].iov_base;
  
  		if	(strcmp(name, "*") == 0)
  			{
! 			if	(writev(mt, tmark, 1) < 0)
  				warn(1, "writev of pseudo tapemark failed");
  			k++;
  			continue;
***************
*** 108,117 ****
  		 *  with tape files)
  		 */
  
! 		while	((cnt=read(fd, buf, recsz)) == recsz)
  			{
  			j++;
! 			if	(writev(mt, iovec, 2) < 0)
  				err(1, "writev #1");
  				/* NOTREACHED */
  			}
--- 123,135 ----
  		 *  with tape files)
  		 */
  
! 		while	((cnt=read(fd, buf, (int)recsz)) == (int)recsz)
  			{
  			j++;
! #ifdef	pdp11
! 			flipped = trl(recsz);
! #endif
! 			if	(writev(mt, iovec, 3) < 0)
  				err(1, "writev #1");
  				/* NOTREACHED */
  			}
***************
*** 118,125 ****
  		if	(cnt > 0)
  			{
  			j++;
! 			bzero(buf + cnt, recsz - cnt);
! 			if	(writev(mt, iovec, 2) < 0)
  				err(1, "writev #2");
  				/* NOTREACHED */
  			}
--- 136,146 ----
  		if	(cnt > 0)
  			{
  			j++;
! 			bzero(buf + cnt, (int)recsz - cnt);
! #ifdef	pdp11
! 			flipped = trl(recsz);
! #endif
! 			if	(writev(mt, iovec, 3) < 0)
  				err(1, "writev #2");
  				/* NOTREACHED */
  			}
***************
*** 128,136 ****
  /*
   * Write two tape marks to simulate EOT
  */
! 	recsz = 0;
! 	writev(mt, iovec, 1);
! 	writev(mt, iovec, 1);
  	}
  
  void
--- 149,173 ----
  /*
   * Write two tape marks to simulate EOT
  */
! 	writev(mt, tmark, 1);
! 	writev(mt, tmark, 1);
! 	}
! 
! long
! trl(l)
! 	long	l;
! 	{
! 	union	{
! 		long	l;
! 		short	s[2];
! 		} foo;
! 	register short	x;
! 
! 	foo.l = l;
! 	x = foo.s[0];
! 	foo.s[0] = foo.s[1];
! 	foo.s[1] = x;
! 	return(foo.l);
  	}
  
  void
*** /VERSION.old	Tue Aug  5 21:07:30 1997
--- /VERSION	Mon Aug 11 21:20:47 1997
***************
*** 1,5 ****
! Current Patch Level: 382
! Date: August 5, 1997
  
  2.11 BSD
  ============
--- 1,5 ----
! Current Patch Level: 383
! Date: August 11, 1997
  
  2.11 BSD
  ============
