Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!bellcore!decvax!decwrl!pyramid!pesnta!hplabs!tektronix!uw-beaver!ubc-vision!alberta!calgary!ingoldsby From: ingoldsby@calgary.UUCP Newsgroups: net.micro.6809 Subject: Re: Newdisk bug fixed Message-ID: <141@vaxb.calgary.UUCP> Date: Thu, 22-May-86 12:20:09 EDT Article-I.D.: vaxb.141 Posted: Thu May 22 12:20:09 1986 Date-Received: Sun, 25-May-86 16:11:30 EDT References: <111@vaxb.calgary.UUCP> <1132@loral.UUCP> Organization: U. of Calgary, Calgary, Ab. Lines: 53 Keywords: Device driver Summary: Newdisk fix fix In article <1132@loral.UUCP>, dml@loral.UUCP writes: > In article <111@vaxb.calgary.UUCP> ingoldsby@calgary.UUCP (Terry Ingoldsby) > writes: > >After some late night hacking, I think I have been able to locate and > >correct the bug in Dave Lewis' `Newdisk' device driver for OS9. I > >hope the following will allow other people to correct their versions. > > > > You have not only my permission, but my blessing and any help you need. > Your analysis of the problem looks right and the fix is pretty simple. The > only change needed is to take the command activation out of the subroutine. > > > RWCMDX LDX PD.BUF,Y Point to sector buffer > LDB DPRT.IMG,U Do a side verify using the > BITB #$40 DPORT image byte as a side > BEQ WTKCMDX select indicator > ORA #8 Compare for side 1 > WTKCMDX LDB #$A8 Set up DRQ halt function > ORB DPRT.IMG,U OR in select bits > RTS > > And the calling routines should be modified to: (in four places I believe) > --> ADDED LINES > > WRITE2 LDA #$A2 `Write sector' command > BSR RWCMDX Set up for disk command > --> STA >COMDREG Issue command to controller > --> LDA #2 Identify DRQ status bit > WAITWDRQ BITA >STATREG Wait until controller is > BEQ WAITWDRQ ready to transfer data > * > WRTLOOP LDA ,X+ Get byte from data buffer > STA >DATAREG Put it in data register > STB >DPORT Activate DRQ halt function > BRA WRTLOOP Loop until interrupted > > The whole idea being to get that command store instruction out of the > (insert weird punctuation here) SUBROUTINE! > Alas and alack my fix added a teeny weeny (or was it big and hairy) bug. It is quite subtle and it causes the driver to become flakey. It turns out that Western Digital cannot guarantee that status is valid for `up to' 28usec after the command is given. I went to bed last night before I could exhaust- ively verify that it works, but I believe that a slight delay is needed before the `BITA >STATREG', say PSHS CC,A,B,X,Y PULS CC,A,B,X,Y. Newdisk is like a high spirited horse. Very powerful, and must be given firm but gentle guidance. I will post anymore hints I come up with as I become convinced of them. Terry Ingoldsby