Subject: standalone programs should not use FP (#434)
Index:	pdp/mch_xxx.s,pdpstand/Makefile,lib/libkern/Makefile 2.11BSD

Description:
	1. boot (and the other standalone programs: disklabel, mkfs, restor,
	and so on) crash if run on a system without floating point hardware.

	2. the kernel panics on a system without hardware floating point
	even when no FP instructions are used by user mode programs!

Repeat-By:
	Either use an emulator which can be told not to provide FP emulation
	or pull the FP boards from a real 11.   

Fix:
	Thanks to Robin Birch for spotting these problems and testing the
	changes.   He is actively working on getting the FP simulator
	working but had a rough time initially due to the bugs mentioned
	above.

	1.  The standalone programs used to load and run on a system without
	FP hardware.  When the "unsigned long" datatype was introduced the
	supporting routines added to libc used FP to perform the 32 bit
	remainder, divide and multiply functions.   The standalone programs
	were being linked against "-lc" and thus picking up versions of 
	routines they should not have.

	The unsigned long support routines have special #ifdef'd code in them
	for use in the kernel.   The standalone routines should use "libkern"
	and NOT libc!   In order to make this possible additional routines
	were added to libkern.  A side effect of this is that now the kernel
	can use 'strcpy', 'strlen' and so on.

	2. The kernel uses the FP instruction 'clrd' (well, ok - clrf but with
	double mode set ;)) to clear buffers.   If no FP is present the normal
	'clr' instruction should be used.   The error was that at the end of
	the first loop the branch was made back to the FP code rather than
	the non-FP code.

	To install this fix, cut where indicated and save to a file (/tmp/434).
	Then:

		patch -p0 < /tmp/434
		cd /usr/src/lib/libkern
		make clean
		make
		make install
		make clean

		cd /sys/pdpstand
		make clean
		make
		cp boot disklabel toyset /

	You may wish to recompile the kernel (both the current and the GENERIC)
	but that can be deferred if desired.

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

-----------------------cut here------------------------
*** /usr/src/sys/pdp/mch_xxx.s.old	Thu Dec 15 20:20:38 1994
--- /usr/src/sys/pdp/mch_xxx.s	Mon Nov 20 23:05:47 2000
***************
*** 3,9 ****
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)mch_xxx.s	1.5 (2.11BSD GTE) 12/15/94
   */
  #include "DEFS.h"
  #include "../machine/mch_iopage.h"
--- 3,9 ----
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)mch_xxx.s	1.6 (2.11BSD) 2000/11/20
   */
  #include "DEFS.h"
  #include "../machine/mch_iopage.h"
***************
*** 319,325 ****
  	clr	(r0)+
  	clr	(r0)+
  	clr	(r0)+
! 	sob	r1,1b
  4:
  #ifdef DIAGNOSTIC
  	jmp	_mapout			/ map out buffer
--- 319,325 ----
  	clr	(r0)+
  	clr	(r0)+
  	clr	(r0)+
! 	sob	r1,3b
  4:
  #ifdef DIAGNOSTIC
  	jmp	_mapout			/ map out buffer
*** /usr/src/sys/pdpstand/Makefile.old	Mon Aug 11 20:26:15 1997
--- /usr/src/sys/pdpstand/Makefile	Mon Nov 13 13:21:51 2000
***************
*** 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
--- 1,4 ----
! #	Makefile	(2.11BSD)	2.4	2000/11/13
  #
  #	The limitations on program size have been removed.  The addition
  #	of disklabel support pushed 'restor' over the limit.  Even with
***************
*** 13,18 ****
--- 13,20 ----
  #	It is still possible to hand craft a version of the utilities by leaving
  #	out all but the necessary drivers. 
  #
+ # 2000/11/13 - use libkern instead of libc because the libc routines use 
+ #	       floating point which may not exist.
  # 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.
***************
*** 54,59 ****
--- 56,64 ----
  .s.o:
  	/lib/cpp -P ${DEFS} $< | as -u -V -o $@
  
+ csv.o:	FRC
+ 	ar xv /lib/libc.a csv.o
+ 
  srt0-i.o: srt0.s
  	/lib/cpp -P -DSPLIT_ID ${DEFS} srt0.s | as -u -V -o $@
  
***************
*** 124,143 ****
  	dd if=$@.o of=mtboot bs=16 skip=1
  	rm -f $@.o
  
! boot: M.o conf.o boot.o ubmapset.o libsa.a
! 	ld -X -o $@ M.o conf.o boot.o ubmapset.o libsa.a -lc
  
! mkfs: srt0.o conf.o libsa.a mkfs.o
! 	ld -X -o $@ srt0.o conf.o $@.o libsa.a -lc
  
! restor: srt0-i.o conf.o libsa.a restor.o
! 	ld -X -i -o $@ srt0-i.o conf.o $@.o libsa.a -lc
  
! icheck: srt0-i.o conf.o libsa.a icheck.o
! 	ld -X -i -o $@ srt0-i.o conf.o $@.o libsa.a -lc
  
! disklabel: srt0.o conf.o libsa.a disklabel.o displaylab.o
! 	ld -X -o $@ srt0.o conf.o $@.o displaylab.o libsa.a -lc
  
  maketape: maketape.c
  	cc -O -o $@ maketape.c
--- 129,148 ----
  	dd if=$@.o of=mtboot bs=16 skip=1
  	rm -f $@.o
  
! boot: M.o conf.o boot.o ubmapset.o libsa.a csv.o
! 	ld -X -o $@ M.o conf.o boot.o ubmapset.o libsa.a -lkern csv.o
  
! mkfs: srt0.o conf.o libsa.a mkfs.o csv.o
! 	ld -X -o $@ srt0.o conf.o $@.o libsa.a -lkern csv.o
  
! restor: srt0-i.o conf.o libsa.a restor.o csv.o
! 	ld -X -i -o $@ srt0-i.o conf.o $@.o libsa.a -lkern csv.o
  
! icheck: srt0-i.o conf.o libsa.a icheck.o csv.o
! 	ld -X -i -o $@ srt0-i.o conf.o $@.o libsa.a -lkern csv.o
  
! disklabel: srt0.o conf.o libsa.a disklabel.o displaylab.o csv.o
! 	ld -X -o $@ srt0.o conf.o $@.o displaylab.o libsa.a -lkern csv.o
  
  maketape: maketape.c
  	cc -O -o $@ maketape.c
***************
*** 145,152 ****
  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
  
  tags: FRC
  	rm -f tags
--- 150,157 ----
  makesimtape: makesimtape.c
  	cc -O -o $@ makesimtape.c
  
! toyset: toyset.o srt0.o conf.o libsa.a csv.o
! 	ld -X -o $@ srt0.o conf.o $@.o libsa.a -lkern csv.o
  
  tags: FRC
  	rm -f tags
*** /usr/src/lib/libkern/Makefile.old	Tue Mar 26 21:14:47 1996
--- /usr/src/lib/libkern/Makefile	Mon Nov 13 13:20:43 2000
***************
*** 1,5 ****
  #
! #	@(#)Makefile	1.2 (2.11BSD GTE) 1996/3/26
  #
  # This is the Makefile for 'libkern.a'.  These are the specially compiled
  # versions of libc.a routines which the kernel and network use.
--- 1,5 ----
  #
! #	@(#)Makefile	1.3 (2.11BSD) 2000/11/13
  #
  # This is the Makefile for 'libkern.a'.  These are the specially compiled
  # versions of libc.a routines which the kernel and network use.
***************
*** 17,29 ****
  PREFIX=	/usr/src/lib/libc/pdp
  
  SRCS=	bcmp.s bcopy.s bzero.s ffs.s htonl.s htons.s insque.s \
! 	ldiv.s lmul.s lrem.s remque.s strlen.s udiv.s uldiv.s ulsh.s
  
  OBJS=	bcmp.o bcopy.o bzero.o ffs.o htonl.o htons.o insque.o \
! 	ldiv.o lmul.o lrem.o remque.o strlen.o udiv.o uldiv.o ulsh.o
  
  .c.o:
! 	${CC} ${CFLAGS} $*.c
  	ld -X -r $*.o
  	mv a.out $*.o
  
--- 17,33 ----
  PREFIX=	/usr/src/lib/libc/pdp
  
  SRCS=	bcmp.s bcopy.s bzero.s ffs.s htonl.s htons.s insque.s \
! 	ldiv.s lmul.s lrem.s remque.s strlen.s udiv.s uldiv.s ulsh.s ulrem.s \
! 	almul.s strcpy.s strncpy.s strcat.s index.s strncmp.s strcmp.s \
! 	atoi.c atol.c
  
  OBJS=	bcmp.o bcopy.o bzero.o ffs.o htonl.o htons.o insque.o \
! 	ldiv.o lmul.o lrem.o remque.o strlen.o udiv.o uldiv.o ulsh.o ulrem.o \
! 	almul.o strcpy.o strncpy.o strcat.o index.o strncmp.o strcmp.o \
! 	atoi.o atol.o
  
  .c.o:
! 	${CC} ${CFLAGS} -c $*.c
  	ld -X -r $*.o
  	mv a.out $*.o
  
***************
*** 59,70 ****
--- 63,84 ----
  	ln ${PREFIX}/gen/strlen.s strlen.s
  	ln ${PREFIX}/crt/ldiv.s ldiv.s
  	ln ${PREFIX}/crt/lmul.s lmul.s
+ 	ln ${PREFIX}/crt/almul.s almul.s
  	ln ${PREFIX}/crt/lrem.s lrem.s
  	ln ${PREFIX}/crt/udiv.s udiv.s
  	ln ${PREFIX}/crt/uldiv.s uldiv.s
+ 	ln ${PREFIX}/crt/ulrem.s ulrem.s
  	ln ${PREFIX}/crt/ulsh.s ulsh.s
  	ln ${PREFIX}/net/htonl.s htonl.s
  	ln ${PREFIX}/net/htons.s htons.s
+ 	ln ${PREFIX}/gen/strcpy.s strcpy.s
+ 	ln ${PREFIX}/gen/strncpy.s strncpy.s
+ 	ln ${PREFIX}/gen/strcat.s strcat.s
+ 	ln ${PREFIX}/gen/index.s index.s
+ 	ln ${PREFIX}/gen/strncmp.s strncmp.s
+ 	ln ${PREFIX}/gen/strcmp.s strcmp.s
+ 	ln ${PREFIX}/../gen/atoi.c atoi.c
+ 	ln ${PREFIX}/../gen/atol.c atol.c
  
  # DO NOT DELETE THIS LINE -- mkdep uses it.
  # DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
*** /VERSION.old	Tue Oct 17 19:30:52 2000
--- /VERSION	Fri Nov 24 09:42:22 2000
***************
*** 1,5 ****
! Current Patch Level: 433
! Date: October 17, 2000
  
  2.11 BSD
  ============
--- 1,5 ----
! Current Patch Level: 434
! Date: November 24, 2000
  
  2.11 BSD
  ============
