[unix-pc.sources] "Installable" Device Driver for WD2010 speedup

psfales@cbnewsc.ATT.COM (Peter Fales) (09/11/89)

A while back, I mentioned in an article that I had gotten my WD2010
to accept the faster step rate available with that controller by
patching an installable driver to execute a RESTORE command at
boot time.  Several people have commented on that posting, one
saying that the information was sketchy, and another (hi Lenny) 
expressing concern about using up 4K of kernel memory for a driver
that does essentially nothing.

The following code is an attempt to get around these problems, at
least until the new fixdisk comes out.  It is a standalone "installable"
driver which executes the RESTORE at boot time.  However, it then
sets the error flag, so that the driver is not actually loaded into
memory.

Who needs this?

First of all, it is only useful to someone who has opened up their 
system and installed a WD2010 hard disk controller.  If you haven't
done this, DO NOT USE THIS DRIVER.  It should not hurt your system,
but it will have a major negative impact on performance.

Second, some people are apparently getting the faster step rate 
without doing anything like this.  If you are, this program will not
help.  However, if you installed a WD2010, changed the VHB, and 
did not see any improvement (such as in Lenny's disk exerciser 
benchmarks), you may want to try this.

Peter Fales			AT&T, Room 5B-420
				2000 N. Naperville Rd.
UUCP:	...att!peter.fales	Naperville, IL 60566
Domain: peter.fales@att.com	work:	(312) 979-8031

#!/bin/sh
# shar:	Shell Archiver
#	Run the following text with /bin/sh to create:
#	README
#	Files
#	INSTALL
#	Install
#	Makefile
#	Name
#	Remove
#	Size
#	fast.c
sed 's/^X//' << 'SHAR_EOF' > README
XThis archive includes a (sort of) installable driver for speeding up
Xdisk accesses when using the WD2010 controller.  I understand that
Xwhen the next fixdisk comes out this will no longer be necessary, but
Xfor you impatient people (like me), here it is.
X
XA number of people have speculated that changing the step parameter
Xin the VHB from its default value of zero to the value 14 could 
Ximprove disk accesses times if a WD2010 is installed in the UNIX-PC.
XWith the stock WD1010 chip, a value of zero corresponds to a step rate
Xof 35 microseconds and is the fastest available.  However, the WD2010
Xhas a faster step rate of 3.2 microseconds corresponding to a step
Xrate parameter of 14.  In fact, several people have found some 
Xdefinite improvement, while others have not.  For the ones that have
Xnot, the reason may be the one outlined below:
X
XSome people have found that simply changing the value in the VHB and
Xrebooting causes the new step rate to take effect, but I have found
Xthat the new step rate does not seem to be loaded into the controller
Xuntil a RESTORE or SEEK occurs, something that normally only happens
Xafter a disk read error.  If you never have a disk error, the value
Xin the VHB will be effectively ignored.
X
XThis driver contains only an "init" routine.  At driver installation
Xtime, this routine changes the step rate (in memory, not on the VHB)
Xto 14, and executes a restore.  Then it sets the error return, so
Xthe driver is not installed.   There is no need for the driver or
Xanything else to be saved in memory once the RESTORE has been executed.
X
XWARNINGS (DON'T SAY I DIDN'T WARN YOU)
X
X1) I take no responsibility for anything that may happen as a result
X	of using this information.  It has caused a measurable 
X	improvement in disk access times on my system.
X
X2) Do not use this unless you have a WD2010 installed.  (It's not
X	fatal if you only have a WD1010, but when your hard disk 
X	becomes slower than a floppy, you will be sorry.)
X
X2) This is a real kludge, since I am writing to the disk controller in
X	a way that UNIX neither understands nor expects.  This usually
X	(always?) results in an error message in /usr/adm/unix.log, but 
X	seems to have no other harmful effects.  Let me know if you have
X	any problems.
X
X3) If you have problems, one way to recover would be to boot the
X	floppy file system,  mount /dev/fp002 /mnt, and delete the
X	file /mnt/etc/lddrv/fast.o
X
XPeter Fales			AT&T, Room 5B-420
X				2000 N. Naperville Rd.
XUUCP:	...att!ihlpb!psfales	Naperville, IL 60566
XDomain: psfales@ihlpb.att.com	work:	(312) 979-8031
SHAR_EOF
sed 's/^X//' << 'SHAR_EOF' > Files
XSize
XInstall
XName
XRemove
XFiles
XINSTALL
Xfast.o
SHAR_EOF
sed 's/^X//' << 'SHAR_EOF' > INSTALL
XDRIVER=fast
X
Xif [ ! -f ${DRIVER}.o ]; then
X	echo "you must make ${DRIVER}.o before running INSTALL" 1>&2
X	exit 1
Xfi
X
Xecho Installing driver to execute RESTORE.  
Xecho A Hard Disk error message in /usr/adm/unix.log is OK.
X
X/etc/masterupd -d ${DRIVER}  2> /dev/null
X/etc/masterupd -a init ${DRIVER}
X
Xcp ${DRIVER}.o /etc/lddrv/
X
Xcd /etc/lddrv
X
X# remove the driver if it's already running
X
X./lddrv -q ${DRIVER} && ./lddrv -d ${DRIVER}
X
X# allocate and load the module
X
X
X./lddrv -a ${DRIVER}
X
X
Xgrep "^${DRIVER}\$" drivers > /dev/null || echo ${DRIVER} >> drivers
SHAR_EOF
sed 's/^X//' << 'SHAR_EOF' > Install
X# Install script for disk speedup
X
XDRIVER=fast
X
X./INSTALL || exit 1
X
Xcd /etc/lddrv
X
X# put an entry in InstDrv for ${DRIVER}
Xcat >> InstDrv << EOF
XName=Disk speedup driver
XFile=${DRIVER}
XEOF
X
X
Xecho "The disk speedup driver is now installed"
Xexit 0
SHAR_EOF
sed 's/^X//' << 'SHAR_EOF' > Makefile
XD=-O
XCFLAGS= $D
XDRIVER=fast
X
Xinstall : $(DRIVER).o
X	./INSTALL
X
Xall : $(DRIVER)+IN
X
Xinstallable : $(DRIVER)+IN
X
X$(DRIVER)+IN : $(DRIVER).o
X	cpio -oBc < Files > $(DRIVER)+IN
X
Xfloppy : $(DRIVER)+IN
X	echo "Insert a formatted floppy disk and press return"; read foo
X	dd if=$(DRIVER)+IN of=/dev/rfp021 bs=16384
X
Xclean: 
X	rm $(DRIVER).o $(DRIVER)+IN
X
Xclobber: clean
X
Xshar:
X	shar README Files INSTALL Install Makefile Name Remove Size fast.c >fast.shar
SHAR_EOF
sed 's/^X//' << 'SHAR_EOF' > Name
XDisk speedup driver by Peter Fales
SHAR_EOF
sed 's/^X//' << 'SHAR_EOF' > Remove
Xcd /etc/lddrv
Xecho '/^fast$/d
Xw' | ed - drivers
Xrm -f ifile.fast fast fast.o
X
X/etc/masterupd -d fast
X
X
Xecho "Disk speedup driver REMOVED"
SHAR_EOF
sed 's/^X//' << 'SHAR_EOF' > Size
X42
SHAR_EOF
sed 's/^X//' << 'SHAR_EOF' > fast.c
X#define KERNEL
X
X#include <sys/types.h>
X#include <sys/param.h>
X#include <sys/inode.h>
X#include <sys/proc.h>
X#include <sys/user.h>
X#include <sys/conf.h>
X#include <sys/errno.h>
X#include <sys/systm.h>
X#include <sys/iohw.h>
X
X
X#include <sys/gdisk.h>
Xfastinit()
X{
X	eprintf("#An error message immediately following this one is OK");
X	ldelay(1000);
X	gdsw[0].dsk.step = 14;
X	HD_BASE[H_COMMANDREG] = W_RESTORE+gdsw[0].dsk.step;
X	ldelay(1000);
X	u.u_error = ENOENT;
X}
SHAR_EOF
exit
-- 
Peter Fales			AT&T, Room 5B-420
				2000 N. Naperville Rd.
UUCP:	...att!peter.fales	Naperville, IL 60566
Domain: peter.fales@att.com	work:	(312) 979-8031