Subject: kernel 'config', autoconfig,  documentation changes (#91, 3 of 12)
Index:	sys,doc,etc,pdpif,.../many 2.11BSD

Description:
	This is part 3 of 12.  Updates #89 thru #100 are parts 1 thru 12
	respectively.
	
	If you have tired of reading the notes in the "Repeat-By:" section 
	please skip to the "Fix:" section for notes and instructions about 
	this patch file (list of files updated, etc).

Repeat-By:

	This section is repeated in each patch file.  Specific directions
	for the individual patches are included in the "Fix:" section.

	Several problem areas are addressed by this series of updates.

	1) The kernel configuration problems are best noticed
	   by maintaining kernels for a variety of systems and forgetting
	   to copy 'localopts.h' to ../h before compiling.  This at best
	   would cause compile time problems, at worst resulting in a kernel
	   that was unusable.  MANY of the changes described below are
	   aimed at the reduction of 'localopts.h' to almost nothing.

	2) There were several kernel config options which were either known not
	   to work, have not been used within recent memory or were obsolete.
	   UCB_FRCSWAP (to force a swap on program expansion) is a good
	   example of an option which has been removed.
	   
	   The list of things which have been options at one time or another
	   in the system's life has been removed.  Many of them dated back
	   to V7, the modules which they affected are not even present in
	   the system any longer.

	   Two options have been moved to the end of the 'config' script.
	   Neither is known to work (CGL_RTP and FPSIM) and are always left
	   NO.

	3) A couple of kernel config options should not have been options so
	   that the kernel could automatically adapt to whatever machine it
	   found itself running on.  The UNIBUS_MAP and Q22 options are good 
	   examples of this.  Usage of the UNIBUS_MAP option was inconsistent,
	   some of the drivers in the system "#ifdef"d references to the
	   Unibus map allocation routine while other drivers did not.  Since
	   the system knows whether a Unibus Map is present or not the
	   correct behaviour is to either test 'ubmap' or simply call 'mapalloc'
	   (which will do the test for you).  In the case of GENERIC or Unibus
	   based kernels there is _no_ penalty (since UNIBUS_MAP was defined),
	   in the case of Qbus systems there is about 900 bytes of code that
	   simply never gets used (and 40 bytes or so of D space).

	   The Q22 defined was used incorrectly in a couple of drivers to
	   either distinquish between Digital and 3rd party controllers (DH-11
	   vs Emulex CS02) or to indicate whether the system was Qbus or
	   Unibus based.  The references to Q22 in dh.c were changed to
	   CS02 (a new option in the device selection area of the config
	   files), deleted, or replaced with tests of 'ubmap'.

	   UCB_RUSAGE has been made standard because several applications
	   (iostat, vmstat, etc) use the statistics and because the
	   getrusage(2) call uses them.  UCB_METER has been left as an
	   option and will be placed in the Makefile as "-DUCB_METER" in
	   the DEFS line.  References to UCB_RUSAGE have been removed from the
	   kernel.

	   NONFP has been removed.  Hardware floating point is mandatory
	   for two reasons:  the simulator doesn't work, and FP is very
	   inexpensive (or standard on KDJ-11 systems).

	   VIRUS_VFORK has been removed.  Nothing depended on it in the
	   applications and VIRUS_VFORK has never been anything but YES.  

	4) NSWAP has gone away.  It was too easy to either forget to change
	   it or to pick a wrong number (by guessing).  Borrowing yet another
	   concept from 4.3BSD the system now determines the amount of
	   swap space dynamically after booting.  This is done by calling
	   a partition size routine which each disc driver provides.  The
	   bdevsw[] table (in pdp/conf.c) has been expanded to include 
	   a "d_psize" member for each device.

	   NOTE:  this change requires that 'a' and 'b' be the root and
		  swap partitions.  All drivers except the RK06/7 (hk.c) 
		  and RM02/3 (xp.c) observed this rule.  Changes were made 
		  to the RK06/7 and RM02/3 partition tables (and /etc/disktab).
		  The previous practice of using the 'e' or 'f' partitions
		  to overlap the old 'a'+'b' partitions has gone away.  THE
		  new 'a' partition is the same size as the 'e' or 'f'
		  partitions used to be, so there is ROOT FILESYSTEM
		  compatibility (the system will still boot).   Best
		  to back the system up (if using RK07 or RM02 drives)
		  before applying these changes.

	5) SWAPLO has gone away.  It has never been anything but 0 within
	   recent memory (and would have resulted in filesystem corruption
	   if an inappropriate value were chosen).  The only device which 
	   possibly would need to use it (the RL02) is required to be used 
	   in pairs.
	   
	   Deleting SWAPLO removed a number of long word adds scattered around
	   the kernel.  One sector (.5kb) of swap space is "lost"/discarded.
	   The previous practice was to decrement 'swplo' in compensation
	   for entering 1 as the first swap block.  Since 'swplo' has
	   gone away, the number of blocks available ('nswap') is simply 
	   decremented by 1 and the swapmap initialized starting at block 1.

	   This change affects a couple of the applications ('ps', 'pstat',
	   etc.) which were looking for 'swplo'.  These programs have been
	   updated.

	6) 'autoconfig' and programmable vector devices (MSCP, TMSCP, etc)
	    have never gotten along very well.  The drivers had
	    vectors hardcoded (either via #define statments or code
	    which allocated vectors from a base vector) into them.  Changing
	    /etc/dtab would have no effect (at best) or the system would
	    crash (at worst) because 'autoconfig' would allocate/initialize 
	    a vector different than that assumed by the driver. 

	    Networking drivers which support programmable vectors (DEQNA
	    for example) previously had their vectors hardcoded into
	    them AND into pdp/net_scb.s.  Changing one but forgetting to
	    change the other was one way to generate an inoperable system!

	    This has been fixed _at last_!  There are two methods used.
	    One for kernel devices configured by 'autoconfig' and a second 
	    used by the both 'autoconfig' and the networking drivers (which 
	    are not handled by 'autoconfig' because the networking is already 
	    running by the time 'init' starts 'autoconfig').

	    If a driver defines a routine "xxxVec" (where xxx is 'ra',
	    'tms', etc) then 'autoconfig' will call the driver with
	    two parameters:  the controller number and the vector from
	    /etc/dtab.  If the driver lacks a 'xxxVec' routine then
	    'autoconfig' functions as it always has.

	    The second method is used when dynamic allocation of vectors
	    is desired for programmable vector devices.  The networking
	    drivers (DEQNA, DEQTA, etc) use this method.  In the kernel
	    there is a location ('lastiv') which contains the next vector
	    to assign.  Usage is to decrement 'lastiv' by 4 and use the
	    new value.  If multiple vectors are needed then a multiple of
	    4 is subtracted ('autoconfig' counts how many "handlers" it
	    needs for a device).  To make use of this feature (second or third
	    MSCP controllers for example) put a 0 (zero) in the vector
	    field in /etc/dtab.

		NOTE:  It is an error to specify a 0 vector (dynamic
		       allocation) and not have a 'xxxVec' routine for
		       'autoconfig' to call.  'autoconfig' will print
		       an error and leave the device unattached.

		       If 'xxxVec' is used by 'autoconfig' the driver
		       should return success (0) or failure (non-0).
		       'autoconfig' will print "vectorset" if a programmable
		       vector is successfully installed.

	    Networking drivers access 'lastiv' via the "mfkd" and "mtkd"
	    (move from kernel data, move to kernel data) routines.  The
	    hardwired vector (400 for the DEQNA) has been removed from
	    scb.s.,

		NOTE:  the handlers for networking devices are still
		       present in net_scb.s, the drivers initialize
		       the allocated vector by means of a small (1 instruction)
		       assembly language routine (see the changes to 
		       pdpif/if_qe.c).  This 'asm' routine is needed
		       for the driver to access the handle name which does
		       not have a leading (underscore) prepended to it.

	7)  The logic in the DHV-11 driver to attempt forcing a fuller silo
	    (by turning off and on the receive interrupt enable) was removed
	    since it did not work (for very long).  After 2 silo overruns
	    or 90% full silos the logic would disable itself by decrementing
	    the number of delay ticks to 0.  The only real fix for the DHV-11's
	    silo handling problem is to replace the DHV-11 with a DHQ-11.

	8)  The kernel option UCB_NET has been renamed to INET (as 4.3BSD
	    does).  The TCP_COMPAT_42 option has been made "standard" by
	    removing the ifdef in netinet/tcp_var.h.

	9)  The MAXMEM option has been moved to param.h.  It is (almost)
	    never changed and was yet one more thing to accidentally get
	    wrong when configuring a kernel.  Thought was given to removing
	    MAXMEM entirely but it was put in with the other "never changed
	    without a great deal of thought" parameters in param.h

	10) The setup and installation documents have been revised to reflect
	    the new kernel configuration process and to remove references
	    to 'xpunix', 'raunix', etc (not needed now that the generic
	    kernel adapts automatically).

	11) The drivers in the OTHERS directory have been lightly edited
	    to change UCB_NET to INET, remove UNIBUS_MAP usage, etc.  No
	    attempt has been made to port or fix the drivers.

	12) Last, but by no means least, the 'config' script (/sys/conf/config)
	    and the conf/Make.{nsunix,unix,sunix} files have been totally 
	    redone.  Borrowing still another idea from 4.3BSD (not a whole
	    lot left to 'steal' ;-)) the 'config' script now places a line:

		DEFS="-DKERNEL -Doption1 -Doption2 ..."

	    at the front of the main Makefile.  The CFLAGS statement has
	    been modified to include ${DEFS}, thus the configuration options
	    are passed thru to the secondary makefiles Make.pdp, Make.pdpuba,
	    etc. 

	    The GENERIC config file has been redone.  You should make note
	    of your present device complement and then re-config your kernels
	    by making a copy of GENERIC and editing it.

		    NOTE:  The PDP11 line is now only used to select the
			   appropriate inlining method for the 'spl'
			   instruction.  You may safely set PDP11 to GENERIC,
			   no references to PDP11 are now made anywhere in the
			   kernel.

			   You should only set the IDENT line to GENERIC
			   if you either know what you are doing, or if
			   you really are making a distribution kernel.

			   Setting IDENT to GENERIC causes the kernel at
			   boot time to:

			   a) override "swapdev".
			      A GENERIC kernel automatically assigns the 'b'
			      partition of the booted device to be "swapdev"

			   b) override "rootdev".
			      A GENERIC kernel automatically assigns the 'a'
			      partition of the booted device to be "rootdev"
			      and "pipedev".

		The /GENALLSYS script is obsolete and has been removed
		from the system.  For a GENERIC system /unix will now
		adapt to the bootstrapped drive and automatically determine
		the amount of swap space.

	    The only change made to the secondary makefiles was to add
	    a new ethernet driver (not yet working) to Make.net.  The DEQTA
	    driver (if_qt.c) is still being debugged, a future update will
	    be forthcoming.  Since if_qt.c does not exist, the "patch" is
	    the whole file (the same applies to if_qtreg.h).  You will need
	    to create two 0 length files in pdpif ("touch /sys/pdpif/if_qt.c
	    /sys/pdpif/if_qtreg.h") before applying the 'pdpif' update kit.
	    A reminder will be placed in the part containing that patch.

		NOTE:  localopts.h has exactly _TWO_ (2) definitions in it
		       now:  EXTERNALITIMES (mapped out time values from the
		       inodes) and LINEHZ.

		       The default for EXTERNALITIMES is now YES.  It is
		       recommended that this not be changed, if it is changed
		       then applications which look at the kernel incore
		       inode table (pstat for example) will need to be
		       recompiled.

		       Unless either of these two defines change you never
		       need to worry about copying localopts.h again!

Fix:
	The following files are modified:

/usr/src/lib/libc/pdp/crt/aldiv.s
/usr/src/lib/libc/pdp/crt/alrem.s
/usr/src/lib/libc/pdp/crt/csv.s
/usr/src/lib/libc/pdp/crt/ldiv.s
/usr/src/lib/libc/pdp/crt/lrem.s

	'csv.s' was changed to use "INET" rather than UCB_NET for the
	conditional inclusion of networking specific code.

	All the other files had "NONFP" removed from them since hardware
	floating point is mandatory (the emulator does not work at the
	present time).

*** /usr/src/lib/libc/pdp/crt/aldiv.s.old	Mon Feb 23 03:34:20 1987
--- /usr/src/lib/libc/pdp/crt/aldiv.s	Sat Dec 26 17:18:22 1992
***************
*** 5,11 ****
   */
  
  #ifdef LIBC_SCCS
! 	<@(#)aldiv.s	2.3 (Berkeley) 1/28/87\0>
  	.even
  #endif LIBC_SCCS
  
--- 5,11 ----
   */
  
  #ifdef LIBC_SCCS
! 	<@(#)aldiv.s	2.4 (2.11BSD GTE) 12/26/92\0>
  	.even
  #endif LIBC_SCCS
  
***************
*** 18,24 ****
   */
  #include "DEFS.h"
  
- #ifndef NONFP
  /*
   * Aldiv for floating point hardware.  Check for divide by zero.  Don't want
   * floating divide trap in integer math.
--- 18,23 ----
***************
*** 43,49 ****
  	mov	(r1),r1
  	seti
  	rts	pc
! #else NONFP
  /*
   * Aldiv for fixed point hardware.
   */
--- 42,48 ----
  	mov	(r1),r1
  	seti
  	rts	pc
! #ifdef	never
  /*
   * Aldiv for fixed point hardware.
   */
***************
*** 62,65 ****
  	mov	r1,(r2)		/   and low
  	mov	(sp)+,r2	/ restore r2
  	rts	pc		/   and return
! #endif NONFP
--- 61,64 ----
  	mov	r1,(r2)		/   and low
  	mov	(sp)+,r2	/ restore r2
  	rts	pc		/   and return
! #endif
*** /usr/src/lib/libc/pdp/crt/alrem.s.old	Mon Feb 23 03:34:20 1987
--- /usr/src/lib/libc/pdp/crt/alrem.s	Sat Dec 26 17:17:48 1992
***************
*** 5,11 ****
   */
  
  #ifdef LIBC_SCCS
! 	<@(#)alrem.s	2.3 (Berkeley) 1/28/87\0>
  	.even
  #endif LIBC_SCCS
  
--- 5,11 ----
   */
  
  #ifdef LIBC_SCCS
! 	<@(#)alrem.s	2.4 (2.11BSD GTE) 12/26/92\0>
  	.even
  #endif LIBC_SCCS
  
***************
*** 18,24 ****
   */
  #include "DEFS.h"
  
- #ifndef NONFP
  /*
   * Alrem for floating point hardware.  Check for divide by zero.  Don't want
   * floating divide trap in integer math.
--- 18,23 ----
***************
*** 49,55 ****
  	mov	(r1),r1
  	seti
  	rts	pc
! #else NONFP
  /*
   * Alrem for fixed point hardware.
   */
--- 48,54 ----
  	mov	(r1),r1
  	seti
  	rts	pc
! #ifdef	never
  /*
   * Alrem for fixed point hardware.
   */
***************
*** 68,71 ****
  	mov	r1,(r2)		/   and low
  	mov	(sp)+,r2	/ restore r2
  	rts	pc		/   and return
! #endif NONFP
--- 67,70 ----
  	mov	r1,(r2)		/   and low
  	mov	(sp)+,r2	/ restore r2
  	rts	pc		/   and return
! #endif
*** /usr/src/lib/libc/pdp/crt/csv.s.old	Sun Jul  3 21:52:34 1988
--- /usr/src/lib/libc/pdp/crt/csv.s	Thu Dec 24 17:13:31 1992
***************
*** 5,11 ****
   */
  
  #if defined(LIBC_SCCS) && !defined(KERNEL) && !defined(SUPERVISOR)
! 	<@(#)csv.s	2.3 (Berkeley) 4/3/88\0>
  	.even
  #endif
  
--- 5,11 ----
   */
  
  #if defined(LIBC_SCCS) && !defined(KERNEL) && !defined(SUPERVISOR)
! 	<@(#)csv.s	2.4 (2.11BSD GTE) 12/24/92\0>
  	.even
  #endif
  
***************
*** 275,281 ****
  	 */
  	cmp	r4,__ovno	/ current overlay same as old overlay?
  	beq	1b		/   lucked out!
! #if	defined(KERNEL) && defined(UCB_NET)
  	cmp	2(r5),$Kretu	/ must always restore overlays if returning
  	beq	3f		/   from SKcall
  #endif
--- 275,281 ----
  	 */
  	cmp	r4,__ovno	/ current overlay same as old overlay?
  	beq	1b		/   lucked out!
! #if	defined(KERNEL) && defined(INET)
  	cmp	2(r5),$Kretu	/ must always restore overlays if returning
  	beq	3f		/   from SKcall
  #endif
*** /usr/src/lib/libc/pdp/crt/ldiv.s.old	Mon Dec 26 14:41:00 1988
--- /usr/src/lib/libc/pdp/crt/ldiv.s	Sat Dec 26 17:16:15 1992
***************
*** 5,11 ****
   */
  
  #ifdef LIBC_SCCS
! 	<@(#)ldiv.s	2.3 (Berkeley) 8/23/88\0>
  	.even
  #endif LIBC_SCCS
  
--- 5,11 ----
   */
  
  #ifdef LIBC_SCCS
! 	<@(#)ldiv.s	2.4 (GTE) 12/26/92\0>
  	.even
  #endif LIBC_SCCS
  
***************
*** 18,24 ****
   */
  #include "DEFS.h"
  
! #if !defined(KERNEL) && !defined(NONFP)
  /*
   * Ldiv for floating point hardware.  Check for divide by zero.  Don't want
   * floating divide trap in integer math.
--- 18,24 ----
   */
  #include "DEFS.h"
  
! #if !defined(KERNEL)
  /*
   * Ldiv for floating point hardware.  Check for divide by zero.  Don't want
   * floating divide trap in integer math.
*** /usr/src/lib/libc/pdp/crt/lrem.s.old	Mon Dec 26 14:40:59 1988
--- /usr/src/lib/libc/pdp/crt/lrem.s	Sat Dec 26 17:13:42 1992
***************
*** 5,11 ****
   */
  
  #ifdef LIBC_SCCS
! 	<@(#)lrem.s	2.3 (Berkeley) 8/23/88\0>
  	.even
  #endif LIBC_SCCS
  
--- 5,11 ----
   */
  
  #ifdef LIBC_SCCS
! 	<@(#)lrem.s	2.4 (GTE) 12/26/92\0>
  	.even
  #endif LIBC_SCCS
  
***************
*** 18,24 ****
   */
  #include "DEFS.h"
  
! #if !defined(KERNEL) && !defined(NONFP)
  /*
   * Lrem for floating point hardware.  Check for divide by zero.  Don't want
   * floating point divide trap in integer math.
--- 18,24 ----
   */
  #include "DEFS.h"
  
! #if !defined(KERNEL)
  /*
   * Lrem for floating point hardware.  Check for divide by zero.  Don't want
   * floating point divide trap in integer math.
