Subject: 2BSD patches...
From: Johnny Billquist <[email-masked]>
Date: Sun, 17 Jun 2012 18:25:24 +0200
Newsgroups: vmsnet.pdp-11,alt.sys.pdp11

Hi. Here is a set of patches to 2BSD, which fixes a number of problems.
Terribly sorry that I don't present it in the same nice format that 
Steven M. Schultz does, but I'll try an explain what this is briefly.

I've named this patch set path #448, as the last known patches to me are 
#447. Apply this patch set after you brought it up to version 447...

Fixes in here:

====

1. Use of non-DEC MSCP controllers improved. Some parts of 2BSD have 
been updated to work with (for example) CMD controllers, but not all 
parts were. This set of patches makes it possible to boot and run with 
the CDU-720, for example, which did not work before.

2. Boot program now automatically boots unless manual intervention on 
console. This looks pretty similar to NetBSD on VAX for example, where a 
countdown is presented at boot time, and the system continues with an 
automatic boot unless aborted. Previously, 2BSD would not autoboot from 
cold start because the reboot-flag was not present at power up.

3. Console terminal made 8-bit clean. On a real PDP-11, the boot 
monitors are 8-bit clean. However, 2BSD previously ran with 7E on the 
console, and there was no way to avoid this for system output. This 
patch makes it all 8-bit clean.

4. The libc resolver code used /etc/hosts if no resolved was available, 
but if one was, it never used the /etc/hosts. This created a peculiar 
effect, especially at bootup, since the resolver couldn't be contacted 
before the network was up, but /etc/hosts were not used, since a correct 
/etc/resolv.conf existed. The order is not possible to select. It will 
first try using the resolver, but if that fails, it now falls back to 
trying /etc/hosts

5. At system build time, the newvers.sh tries to figure out various bits 
and pieces to put into the built file to tell when the kernel was built, 
where and by who. This parsing could fail in various ways because of how 
the date command works with time zones. Fixed by changing how it figures 
out the information and pass it around.

6. The mandoc macros had a Y2K bug, or rather a 2010 bug, in that the 
Y2K bug fix actually only fixed years 2000-2009, and it broke again in 
2010. This patch does a proper fix to the Y2K problem. Also fixed a 
spelling error.

====

As usual, the code might not be pretty, but I've atleast been running it 
myself on several machines for close to two years now, and believe these 
are all workable, and important patches.
Download to your machine.
At the root of the file system run:
$ patch -p0 < patchfile

after this, rebuild the kernel and the boot image. Install the new 
kernel, the new boot, and then rebuild all of userland.

If you have any questions, feel free to send me an email.

This patch set will bring your system up to patch version 448.

     Johnny

-- 
Johnny Billquist                  || "I'm on a bus
                                   ||  on a psychedelic trip
email: [email-masked]             ||  Reading murder books
pdp is alive!                     ||  tryin' to stay hip" - B. Idol

*** VERSION.orig	Sun Jun 17 17:02:22 2012
--- VERSION	Thu Apr  1 14:17:48 2010
***************
*** 1,5 ****
! Current Patch Level: 447
! Date: December 31, 2008
  
  2.11 BSD
  ============
--- 1,5 ----
! Current Patch Level: 448
! Date: January 5, 2010
  
  2.11 BSD
  ============
***************
*** 62,88 ****
  	112 South Lakeview Canyon Road
  	Thousand Oaks CA 91359
  	[email-masked]
- 
- 	Below is the original VERSION file distributed with 2.10.1BSD
- -----------------------------------------------------------------------
- NOTE --
- 	This is the second release of 2.10BSD; most of the changes
- 	are part of the addition of supervisor space networking in
- 	the kernel, although there are other changes.
- 
- 	To give some idea of the dates involved, distribution of
- 	2.10BSD by the USENIX Assoc. started in fall of 1987.
- 	Distribution of this source started in January of 1989.
- 
- Keith Bostic
- Casey Leedom
- Cyrus Rahman
- Steven Schultz
- 	Steven M. Schultz
- 	Contel Federal Systems
- 	31717 La Tienda Drive
- 	Westlake Village CA 91359
- 	[email-masked]
  
  	Below is the original VERSION file distributed with 2.10.1BSD
  -----------------------------------------------------------------------
--- 62,67 ----
*** usr/src/sys/pdpstand/boot.c.old	Wed Aug 19 00:22:03 2009
--- usr/src/sys/pdpstand/boot.c	Wed Aug 19 02:46:18 2009
***************
*** 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) {
--- 172,189 ----
  	 * this is an automatic reboot, otherwise do it the hard way.
  	 */
  	if (checkword != ~bootopts)
! 		bootopts = 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;
! 			break;
! 		}
! 	}
! 	printf("\n");
  	j = -1;
  	do {
  		if (bootopts & RB_ASKNAME) {
*** usr/src/sys/pdp/cons.c.old	Wed Aug 19 00:25:03 2009
--- usr/src/sys/pdp/cons.c	Tue Aug 18 18:09:57 2009
***************
*** 164,170 ****
  	if (tp->t_flags & (RAW|LITOUT))
  		addr->dlxbuf = c&0xff;
  	else
! 		addr->dlxbuf = c | (partab[c] & 0200);
  	tp->t_state |= TS_BUSY;
  out:
  	splx(s);
--- 164,170 ----
  	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);
*** usr/src/lib/libc/net/named/gethnamadr.c.orig	Sun Feb 28 03:59:41 2010
--- usr/src/lib/libc/net/named/gethnamadr.c	Thu Apr  1 04:25:45 2010
***************
*** 8,13 ****
--- 8,20 ----
   * may not be used to endorse or promote products derived from this
   * software without specific prior written permission. This software
   * is provided ``as is'' without express or implied warranty.
+  *
+  * 2010-04-01	Johnny Billquist
+  *
+  * Changed code so that /etc/hosts are consulted even if named is
+  * used. This means that if name resolution fails, it will fall back
+  * to using /etc/hosts. Previously it just failed in this case. (But it
+  * did consult /etc/hosts if no named.conf existed.)
   */
  
  #if defined(LIBC_SCCS) && !defined(lint)
***************
*** 227,236 ****
--- 234,247 ----
  		if (_res.options & RES_DEBUG)
  			printf("res_search failed\n");
  #endif
+ #ifdef BQT
  		if (errno == ECONNREFUSED)
+ #endif
  			return (_gethtbyname(name));
+ #ifdef BQT
  		else
  			return ((struct hostent *) NULL);
+ #endif
  	}
  	return (getanswer(&buf, n, 0));
  }
***************
*** 259,269 ****
  		if (_res.options & RES_DEBUG)
  			printf("res_query failed\n");
  #endif
  		if (errno == ECONNREFUSED)
  			hp = _gethtbyaddr(addr, len, type);
! 		return ((struct hostent *) NULL);
! 	}
! 	hp = getanswer(&buf, n, 1);
  	if (hp == NULL)
  		return ((struct hostent *) NULL);
  	hp->h_addrtype = type;
--- 270,285 ----
  		if (_res.options & RES_DEBUG)
  			printf("res_query failed\n");
  #endif
+ #ifdef BQT
  		if (errno == ECONNREFUSED)
+ #endif
  			hp = _gethtbyaddr(addr, len, type);
! #ifdef BQT
! 		else
! 			return ((struct hostent *) NULL);
! #endif
! 	} else
! 		hp = getanswer(&buf, n, 1);
  	if (hp == NULL)
  		return ((struct hostent *) NULL);
  	hp->h_addrtype = type;
*** usr/src/sys/conf/newvers.sh.old	Tue Aug 18 17:50:09 2009
--- usr/src/sys/conf/newvers.sh	Tue Aug 18 17:32:57 2009
***************
*** 8,17 ****
  #
  if [ ! -r version ]; then echo 0 > version; fi
  touch version
! echo `cat version` ${USER-root} `pwd` `date` `hostname` | \
  awk ' {
! 	version = $1 + 1; user = $2; host = $10; dir = $3; \
! 	date = $4 " " $5 " " $6 " " $7 " " $8 " " $9;
  }\
  END {
  	printf "char version[] = \"2.11 BSD UNIX #%d: %s\\n", \
--- 8,17 ----
  #
  if [ ! -r version ]; then echo 0 > version; fi
  touch version
! echo `cat version` ${USER-root} `pwd` `hostname` `date` | \
  awk ' {
! 	version = $1 + 1; user = $2; host = $4; dir = $3; \
! 	date = $5 " " $6 " " $7 " " $8 " " $9 " " $10 " " $11;
  }\
  END {
  	printf "char version[] = \"2.11 BSD UNIX #%d: %s\\n", \
*** usr/src/sys/pdpstand/prf.c.old	Tue Aug 18 15:45:40 2009
--- usr/src/sys/pdpstand/prf.c	Wed Aug 19 02:45:36 2009
***************
*** 9,14 ****
--- 9,15 ----
  #include "../machine/cons.h"
  
  #define	KLADDR	((struct dldevice *)0177560)
+ #define LKS ((int *)0177546)
  
  #define	CTRL(x)	('x' & 037)
  
***************
*** 116,121 ****
--- 117,146 ----
  	KLADDR->dlrcsr = DL_RE;
  	while ((KLADDR->dlrcsr & DL_RDONE) == 0)
  		continue;
+ 	c = KLADDR->dlrbuf & 0177;
+ 	if (c=='\r')
+ 		c = '\n';
+ 	return(c);
+ }
+ 
+ getchar2(t)
+ 	int t;
+ {
+ 	register c;
+ 	int clks, olks;
+ 
+ 	KLADDR->dlrcsr = DL_RE;
+ 	*LKS = 0;
+ 	clks = 0x80;
+ 	while ((KLADDR->dlrcsr & DL_RDONE) == 0) {
+ 		olks = clks;
+ 		clks = *LKS;
+ 		if (~olks & clks & 0x80) {
+ 			*LKS = 0;
+ 			if ((--t) == 0) return (-1);
+ 		}
+ 		continue;
+ 	}
  	c = KLADDR->dlrbuf & 0177;
  	if (c=='\r')
  		c = '\n';
*** usr/src/sys/conf/boot/raboot.s.old	Mon Aug 17 21:41:34 2009
--- usr/src/sys/conf/boot/raboot.s	Mon Aug 17 22:44:12 2009
***************
*** 1,5 ****
--- 1,9 ----
  /*
   *	SCCS id	@(#)raboot.s	2.0 (2.11BSD)	4/13/91
+  *
+  * Code corrected as per the other primitive mscp drivers
+  * to handles other mscp controllers than DECs.
+  * /bqt - 20090817
   */
  #include "localopts.h"
  
***************
*** 59,65 ****
  
  MSCPSIZE =	64.	/ One MSCP command packet is 64bytes long (need 2)
  
! RASEMAP	=	140000	/ RA controller owner semaphore
  
  RAERR =		100000	/ error bit 
  RASTEP1 =	04000	/ step1 has started
--- 63,69 ----
  
  MSCPSIZE =	64.	/ One MSCP command packet is 64bytes long (need 2)
  
! RASEMAP	=	100000	/ RA controller owner semaphore
  
  RAERR =		100000	/ error bit 
  RASTEP1 =	04000	/ step1 has started
***************
*** 153,170 ****
  	mov	$RASEMAP,*$ra+RARSPH	/ set mscp semaphores
  	mov	$RASEMAP,*$ra+RACMDH
  	mov	*_bootcsr,r0		/ tap controllers shoulder
! 	mov	$ra+RACMDI,r0
  1:
  	tst	(r0)
! 	beq	1b			/ Wait till command read
! 	clr	(r0)+			/ Tell controller we saw it, ok.
  2:
  	tst	(r0)
! 	beq	2b			/ Wait till response written
  	clr	(r0)			/ Tell controller we got it
  	rts	pc
  
! icons:	RAERR
  	ra+RARING
  	0
  	RAGO
--- 157,176 ----
  	mov	$RASEMAP,*$ra+RARSPH	/ set mscp semaphores
  	mov	$RASEMAP,*$ra+RACMDH
  	mov	*_bootcsr,r0		/ tap controllers shoulder
! 	mov	$ra+RACMDH,r0
  1:
  	tst	(r0)
! 	bmi	1b			/ Wait till command read
! 	mov	$ra+RARSPH,r0
  2:
  	tst	(r0)
! 	bmi	2b			/ Wait till response written
! 	mov	$ra+RACMDI,r0
! 	clr	(r0)+			/ Tell controller we saw it, ok.
  	clr	(r0)			/ Tell controller we got it
  	rts	pc
  
! icons:	RAERR + 033
  	ra+RARING
  	0
  	RAGO
*** usr/src/share/tmac/tmac.an.new.old	Wed Aug 12 09:43:23 2009
--- usr/src/share/tmac/tmac.an.new	Sun Aug 22 03:30:46 2010
***************
*** 20,28 ****
  .if "\nm"10" .ds ]m November
  .if "\nm"11" .ds ]m December
  '	# set the date
! .nr )y \n(yr-100
! .ie \n(yr<100 .ds ]Y \n(yr
! .el .ds ]Y 0\n()y
  '
  .nr )Y \n(yr+1900
  .if n \{.nr m \nm+1
--- 20,28 ----
  .if "\nm"10" .ds ]m November
  .if "\nm"11" .ds ]m December
  '	# set the date
! .nr )y \n(yr%100
! .ie \n()y<10 .ds ]Y 0\n()y
! .el .ds ]Y \n()y
  '
  .nr )Y \n(yr+1900
  .if n \{.nr m \nm+1
***************
*** 53,59 ****
  .de UC
  .if t \{\
  .	ds ]W 3rd Berkeley Distribution
! .	if "\\$1"2" .ds ]W 2rd Berkeley Distribution
  .	if "\\$1"3" .ds ]W 3rd Berkeley Distribution
  .	if "\\$1"4" .ds ]W 4th Berkeley Distribution
  .	if "\\$1"5" .ds ]W 4.2 Berkeley Distribution
--- 53,59 ----
  .de UC
  .if t \{\
  .	ds ]W 3rd Berkeley Distribution
! .	if "\\$1"2" .ds ]W 2nd Berkeley Distribution
  .	if "\\$1"3" .ds ]W 3rd Berkeley Distribution
  .	if "\\$1"4" .ds ]W 4th Berkeley Distribution
  .	if "\\$1"5" .ds ]W 4.2 Berkeley Distribution