Subject: /boot
Index:	 src/sys/pdpstand/boot.c,mtboot.s,src/sys/pdp/cons.c,src/ucb/ex/ex_tune.h  2.11BSD

Description:
	1. The changes made to boot.c in patch 448 broke the ability to enter
	   single user mode when running under the Begemot (p11) simulator.
	   Patch 449 was released to restore pre-448 behaviour.

	   However some folks want /boot to bring the system to a multi-user
	   state automatically.

	2. Multi-user booting from magtape doesn't work but if /boot is built
	   with automatic multi-user booting enabled it will attempt (and fail)
	   to go "multi-user" on a magtape.

	3. The console device forced even parity setting.

	4. vi/ex display limited to 70 lines.

Repeat-By:
        1. Observation ;)  On a system with /boot built before patch 448 observe
	   the kernel will load, run autoconf, and a # prompt given as the
	   system comes to single user mode.  Hitting ^D initiates multi-user
	   mode.

	2. Inspection / observation.  With boot.c modified to go automatically
	   to multi-user then booting from tape (during an installation) only
	   gives the operator 5 seconds to prevent a (failed) attempt to bring
	   up a multi-user system from magtape.
	    
	3. Switch a terminal between a PDP-11 with even parity and a system
	   not using parity.

	4. Run 'vi' more than 70 rows in the window ("stty rows 70").

Fix:

	1. For almost 30 years a cold start (power on) boot required manual
	   intervention by entering a ^D to move the system from single user
	   (# prompt) to multi-user.  Some folks wanted the system to enter 
	   multi-user autmatically.

	   Since the system can not boot to two modes (single | multi) at the 
	   same time it was, after much converstation with bqt@update.uu.se, to
	   offer the choice of "automatic multi-user boot" as a compile time
	   option in /boot

	   If you do not care or prefer the previous solution (the way the
	   system's been since around 1988) you need do nothing except apply
	   the patch below (to keep the source tree current).  

	   If you want the system to boot automatially to multi-user upon
	   power up (the bootrom module must of course be configured properly
	   for this to work) then in boot.c change 

	   	AUTOMULTIBOOT=0  

		to

	   	AUTOMULTIBOOT=1

	   This will enable a 5 second countdown.  During that interval
	   hitting <cr> will end the timeout and the system will immediately
	   beging the transition to multi-user state.  If no key is pressed
	   the transition to multi-user will happen at the end of the countdown.	   If a key other than <cr> is pressed the user will be prompted for
	   a kernel image.

	   Also in boot.c the '-a option was removed as redundant - if you are
	   typing at the ':' (boot's "ask" prompt) then /boot is already in
	   "-a" (ask) mode.

	   For symmetry/completness a "-m" flag was added to turn off the
	   "-s" singleuser (RB_SINGLE) flag.  The need for this was not urgent,
	   same thing could have been achieved by simply hitting ^D at the
	   shell prompt after the kernel was loaded.

	2. Change mtboot.s to force the prompting (RB_ASKNAME) for the file
	   to load. Because /boot can now be built to turn off prompting so 
	   the tape bootblock needs to force the previous 'boot' behaviour  of
	   always prompting with ":"

	3. Patch 448 hardwired "noparity" into the console driver.  That did
	   not follow the same logic as other serial line drivers.  A better
	   approach was submitted by tih@hamartun.priv.no which implements
	   the parity setting via 'stty' (stty evenp | oddp).  Thanks!

	4. 'vi' has enough dataspace available to increase the number of lines
	   that can be displayed to 80 (from 70).  This was a change made
	   in May of 2000 but overlooked for inclusion in a patch until now.

	Cut where indicated and save to a file (/tmp/450 for example):

	    cd /
	    patch -p0 < /tmp/450

	NOTE:  IF the parity setting of the console has not been a problem
	       OR if the power on boot process  has not bothered you  then
	       a new kernel or /boot does NOT need to be recompiled or installed

	If you want to install the new boot program:

	       cd /sys/pdpstand
	       make boot
	       cp boot /boot

	for the change to the console driver to take effect you will need to
	compile the kernel

		cd /sys/YOUR_KERNEL
		make
		mv /unix /ounix
		mv unix /unix
		(and optionally for a networking kernel)
		mv /netnix /onetnix
		mv netnix /netnix

	Recompiling/installing vi/ex:

		cd /usr/src/ucb/ex
		make
		make install
		make clean

	This and previous updates to 2.11BSD are available at the following
	locations:
	
	ftp://ftp.update.uu.se/pub/pdp11/2.11BSD
	https://www.tuhs.org/Archive/Distributions/UCB/2.11BSD/Patches/
	ftp://ftp.2bsd.com/pub/2.11BSD

---------------------------cut here--------------------
*** ./usr/src/sys/pdp/cons.c.orig	Thu Mar  3 17:39:15 2016
--- ./usr/src/sys/pdp/cons.c	Wed Mar 16 06:47:34 2016
***************
*** 3,9 ****
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)cons.c	1.3 (2.11BSD GTE) 1997/4/25
   */
  
  /*
--- 3,9 ----
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)cons.c	1.4 (2.11BSD) 2016/3/16
   */
  
  /*
***************
*** 62,68 ****
  	if ((tp->t_state&TS_ISOPEN) == 0) {
  		ttychars(tp);
  		tp->t_state = TS_ISOPEN|TS_CARR_ON;
! 		tp->t_flags = EVENP|ECHO|XTABS|CRMOD;
  	}
  	if (tp->t_state&TS_XCLUDE && u.u_uid != 0)
  		return (EBUSY);
--- 62,68 ----
  	if ((tp->t_state&TS_ISOPEN) == 0) {
  		ttychars(tp);
  		tp->t_state = TS_ISOPEN|TS_CARR_ON;
! 		tp->t_flags = ANYP|ECHO|XTABS|CRMOD;
  	}
  	if (tp->t_state&TS_XCLUDE && u.u_uid != 0)
  		return (EBUSY);
***************
*** 163,170 ****
  	c = getc(&tp->t_outq);
  	if (tp->t_flags & (RAW|LITOUT))
  		addr->dlxbuf = c&0xff;
  	else
! 		addr->dlxbuf = c&0xff; /* | (partab[c] & 0200); /bqt */
  	tp->t_state |= TS_BUSY;
  out:
  	splx(s);
--- 163,174 ----
  	c = getc(&tp->t_outq);
  	if (tp->t_flags & (RAW|LITOUT))
  		addr->dlxbuf = c&0xff;
+ 	else if ((tp->t_flags & (EVENP | ODDP)) == EVENP)
+ 		addr->dlxbuf = c | (partab[c] & 0200);
+ 	else if ((tp->t_flags & (EVENP | ODDP)) == ODDP)
+ 		addr->dlxbuf = c | ((partab[c] & 0200) ^ 0200);
  	else
! 		addr->dlxbuf = c;
  	tp->t_state |= TS_BUSY;
  out:
  	splx(s);
*** ./usr/src/sys/pdpstand/mtboot.s.orig	Wed May 31 19:54:10 1995
--- ./usr/src/sys/pdpstand/mtboot.s	Wed Mar 16 16:39:49 2016
***************
*** 3,8 ****
--- 3,11 ----
   *
   * 1995/05/31 - unit number changed to be in bits 3-5 of 'bootdev'
   *
+  * 2016/03/10 - force bootflags to RB_ASKNAME|RB_SINGLE
+  *              (auto/multi-user boot from tape makes no sense)
+  *
   * This is a universal tape boot which can handle HT, TM, TS and TMSCP
   * tapes.  This boot is FULL.  Some of the more extended error
   * checking had to be left out to get all the drivers to fit.
***************
*** 20,25 ****
--- 23,29 ----
   * all the registers are used, this boot does not support the 
   * "jsr pc,0; br restart" convention.
   */
+ 
  NEWLOC	= [48.*1024.]			/ we relocate ourselves to this address
  OURSIZE = 512.				/ assume we are up to this size
  
***************
*** 101,106 ****
--- 105,113 ----
  	cmp	blkcnt,sp
  	blo	1b
  	mov	csr,r1			/ put things where 'boot'
+ 	mov	$3,r4			/ bootopts (RB_SINGLE|RB_ASKNAME)
+ 	mov	r4,r2
+ 	com	r2			/ checkword
  	mov	unit,r3			/  expects them
  	ash	$3,r3			/ unit # in bits 3-5
  	bis	major,r3		/ the major device to high byte
*** ./usr/src/sys/pdpstand/boot.c.orig	Thu Mar  3 18:14:09 2016
--- ./usr/src/sys/pdpstand/boot.c	Fri Mar 18 07:59:49 2016
***************
*** 3,9 ****
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)boot.c	3.0 (2.11BSD) 1996/5/9
   */
  #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	4.0 (2.11BSD) 2016/3/18
   */
  #include "../h/param.h"
  #include "../machine/seg.h"
***************
*** 12,17 ****
--- 12,24 ----
  #include "saio.h"
  #include <a.out.h>
  
+ /*
+  * Some people want the system to go multi-user on power-up while others 
+  * prefer to enter ^D at the single user prompt.  This define offers the 
+  * choice of old (traditional) or new (automatic multi-user) behaviour.
+ */
+ #define AUTOMULTIUSER 0		/* 0 = old behaviour, !0 = new (automatic) behaviour */
+ 
  #undef	btoc			/* to save space */
  #define	KB	* 1024L
  
***************
*** 153,160 ****
  	unit = (minor(bootdev) >> 3) & 7;
  	part = minor(bootdev) & 7;
  
! 	printf("\n%d%s from %s(%d,%d,%d) at 0%o\n", cputype, module, 
! 		devsw[major(bootdev)].dv_name, bootctlr, unit, part, bootcsr);
  
  	strcpy(defdev, devsw[major(bootdev)].dv_name);
  	strcat(defdev, "(");
--- 160,168 ----
  	unit = (minor(bootdev) >> 3) & 7;
  	part = minor(bootdev) & 7;
  
! 	printf("\n%d%s from %s(%d,%d,%d) at 0%o\n",
! 		cputype, module, devsw[major(bootdev)].dv_name,
! 		bootctlr, unit, part, bootcsr);
  
  	strcpy(defdev, devsw[major(bootdev)].dv_name);
  	strcat(defdev, "(");
***************
*** 172,178 ****
  	 * this is an automatic reboot, otherwise do it the hard way.
  	 */
  	if (checkword != ~bootopts)
! 		bootopts = RB_SINGLE | RB_ASKNAME;
  	j = -1;
  	do {
  		if (bootopts & RB_ASKNAME) {
--- 180,203 ----
  	 * this is an automatic reboot, otherwise do it the hard way.
  	 */
  	if (checkword != ~bootopts)
! #if AUTOMULTIUSER == 1
! 		bootopts = 0;		/* If from a power on /cold boot */
! #else
! 		bootopts = RB_ASKNAME | RB_SINGLE;	/* traditional (previous) method */
! #endif
! 
! 	if ((bootopts & RB_ASKNAME) == 0) {
! 		printf("Press <CR> to boot, or any other key to abort:  ");
! 		for (i=5; i>=0; i--) {
! 			printf("\b%d", i);
! 			j = getchar2(50);
! 			if (j != -1) {
! 				if (j != '\n') bootopts = RB_ASKNAME|RB_SINGLE;
! 				break;
! 			}
! 		}
! 		printf("\n");
! 	}
  	j = -1;
  	do {
  		if (bootopts & RB_ASKNAME) {
***************
*** 208,214 ****
  		j = -1;
  		if	(cp = index(line, ' '))
  			{
! 			if	((bootflags(cp, &bootopts, "bootfile")) == -1)
  				{
  				bootopts |= RB_ASKNAME;
  				continue;
--- 233,239 ----
  		j = -1;
  		if	(cp = index(line, ' '))
  			{
! 			if	(bootflags(cp, &bootopts) == -1)
  				{
  				bootopts |= RB_ASKNAME;
  				continue;
***************
*** 684,702 ****
  	if	(strncmp(cp, bflags, sizeof (BOOTFLAGS) - 1) == 0)
  		{
  		if	(cp = arg(cp))
! 			(void) bootflags(cp, &bootopts, bflags);
  		else
! 			printf("%s = %u\n", bflags, bootopts);
  		return(0);
  		}
! 	printf("bad cmd: %s\n", cp);
  	return(0);
  	}
  
! bootflags(cp, pflags, tag)
  	register char *cp;
  	int *pflags;
- 	char *tag;
  	{
  	int first = 1;
  	int flags = 0;
--- 709,726 ----
  	if	(strncmp(cp, bflags, sizeof (BOOTFLAGS) - 1) == 0)
  		{
  		if	(cp = arg(cp))
! 			(void) bootflags(cp, opt);
  		else
! 			printf("%s = %u\n", bflags, *opt);
  		return(0);
  		}
! 	usage();
  	return(0);
  	}
  
! bootflags(cp, pflags)
  	register char *cp;
  	int *pflags;
  	{
  	int first = 1;
  	int flags = 0;
***************
*** 715,723 ****
  					{
  					case	' ':
  						goto nextarg;
- 					case	'a':
- 						flags |= RB_ASKNAME;
- 						break;
  					case	'D':
  						flags |= RB_AUTODEBUG;
  						break;
--- 739,744 ----
***************
*** 730,737 ****
  					case	's':
  						flags |= RB_SINGLE;
  						break;
  					default:
! 						goto usage;
  					}
  				continue;
  			}
--- 751,761 ----
  					case	's':
  						flags |= RB_SINGLE;
  						break;
+ 					case	'm':
+ 						flags &= ~RB_SINGLE;
+ 						break;
  					default:
! 						goto err;
  					}
  				continue;
  			}
***************
*** 740,746 ****
  			*pflags = atoi(cp);
  			return(0);
  			}
! 		goto usage;
  
  nextarg: 	;
  		}
--- 764,770 ----
  			*pflags = atoi(cp);
  			return(0);
  			}
! 		goto err;
  
  nextarg: 	;
  		}
***************
*** 747,753 ****
  	if	(first == 0)
  		*pflags = flags;
  	return(0);
! usage:
! 	printf("usage: %s [ -aDrRs ]\n", tag);
  	return(-1);
  	}
--- 771,782 ----
  	if	(first == 0)
  		*pflags = flags;
  	return(0);
! err:
! 	usage();
  	return(-1);
  	}
+ 
+ usage()
+ {
+ 	printf("usage: boot [ -DrRsm ]\n");
+ }
*** ./usr/src/ucb/ex/ex_tune.h.orig	Wed Oct 23 15:56:54 1996
--- ./usr/src/ucb/ex/ex_tune.h	Sat May  6 01:54:44 2000
***************
*** 3,9 ****
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)ex_tune.h	7.8.1 (2.11BSD) 1996/10/23
   */
  
  /*
--- 3,9 ----
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)ex_tune.h	7.8.2 (2.11BSD) 2000/5/6
   */
  
  /*
***************
*** 100,108 ****
   * hardcopy mode when a line gets longer than 80 characters.
   */
  #ifndef VMUNIX
! #define	TUBELINES	70	/* Number of screen lines for visual */
  #define	TUBECOLS	160	/* Number of screen columns for visual */
! #define	TUBESIZE	6000	/* Maximum screen size for visual */
  #else
  #define	TUBELINES	70
  #define	TUBECOLS	160
--- 100,108 ----
   * hardcopy mode when a line gets longer than 80 characters.
   */
  #ifndef VMUNIX
! #define	TUBELINES	80	/* Number of screen lines for visual */
  #define	TUBECOLS	160	/* Number of screen columns for visual */
! #define	TUBESIZE	6400	/* Maximum screen size for visual (80x80)*/
  #else
  #define	TUBELINES	70
  #define	TUBECOLS	160
*** ./VERSION.orig	Thu Mar  3 18:18:15 2016
--- ./VERSION	Wed Mar 16 06:05:36 2016
***************
*** 1,5 ****
! Current Patch Level: 449
! Date: March 3, 2016
  
  2.11 BSD
  ============
--- 1,5 ----
! Current Patch Level: 450
! Date: March 16, 2016
  
  2.11 BSD
  ============