[net.micro.6809] Improved disk driver for OS-9 Version 2

dml@loral.UUCP (Dave Lewis) (02/14/86)

-------------------------------

  Here it is at long last...what you need to do to NewDisk to make it get
along with OS-9 Version 2. It's not thoroughly tested yet but it seems OK --
let me know if there are any problems out there. Version 2 uses a thing
called the Virtual Interrupt to shut off the drive motors where in Version 1
I think it's done in the kernel. (Many thanks to Chuck Buche for the info
on Virtual Interrupts).

  My source of Version 2 for testing was one of those Deskmate disks, which
has no pipes or /T1 in its bootfile. Also, if you have to deal with one of
these critters, watch out for SysGo. For some reason when it initializes it
points the working and execution directories at /H0 and /H0/CMDS respectively.
I have no idea how it ever managed to get started before but when I replaced
CCDisk with NewDisk.V2 I had to patch those two strings to /D0 and /D0/CMDS -
then it worked fine. It may have something to do with the disk descriptors
because I replaced them too.

  The entire Version 2 disk driver is now included on my source disk which
is still available for $10. Space is getting short on the standard 35-track
single sided format and I may have to exclude some of the large assortment
of disk descriptor binaries to make room. The sources will NOT get squeezed
out even if enough stuff accumulates to crowd out the binaries. If it gets
big enough I'll format 40 tracks double-sided if you can read that, or add a
second disk and ask $15 for the set.
*****************************************************************
*
*  Changes necessary to make NewDisk run under
*    OS-9 Version 2.0
*
*  Copyright 1986 by Dave Lewis
*                 4417 Idaho apt. 4
*                 San Diego, CA 92116
*  Released to public domain February, 1986
*
*****************************************************************
*
*  Change the revision level
*
REV      EQU 2
*
*  Add this line to the big block of EQUates near the beginning
*    (unless you're using Version 2 and have the new DEFS files)
*
F$VIRQ   EQU $27 Virtual Interrupt code
*
*  Add this line just after the MOD declaration block
*    (after the Version number FCB)
*
D.IRQPAK FCB 0,1,10 IRQ service entry data
*
*  Add this line to the storage declarations just after
*    the line that allocates Q.SEEK
*
VI.VAR   RMB 5 Virtual Interrupt data
*
*  Replace the first line of INIT with this
*
INIT     CLR VI.VAR+1,U Zero disk rundown timer
*
*  Add this code immediately after the NMI jump vector
*    storage (the line STA >NMIVECT)
*
         PSHS Y Save Y register
         LEAY VI.VAR+4,U Point to status byte
         TFR Y,D Put address in correct reg
         LEAY IRQ.SVC,PCR Point to IRQ service routine
         LEAX <D.IRQPAK,PCR Point to IRQ service data
         OS9 F$IRQ Create an IRQ table entry
         PULS Y Restore Y register
         BCS RETURN1 Exit if error
*
*  Numerous changes to DSKSTART; make it look like this:
*
DSKSTART TST VI.VAR+1,U Are drives already running?
         BNE SPINRDY Ready, no need to wait
         CLR DRVS.RDY,U No drives are ready
         LDD #$80B Motor on, wait 550 mSec
         STA >DPORT Start spindle motors
         BSR WAIT50MS Wait for motors to start
         PSHS Y Save path descriptor address
         LEAY VI.VAR,U Point to VIRQ data
         CLR 4,Y Clear status byte -- one shot
         LDX #1 Install entry
         LDD #DISKRUN Initial count value
         OS9 F$VIRQ Set virtual interrupt
         PULS Y Restore path descriptor
         BCS RETURN3 Exit if error
SPINRDY  LDA PD.DRV,Y Get drive number
         CMPA V.NDRV,U Test for valid drive #
         BHS ERR.UNIT Return error if not
         LEAX TABL.ORG,U Compute address of active
         LDB #DRVMEM   drive's parameter table
         MUL   TABL.ORG + (D# * tablesize)
         LEAX D,X Add computed offset to origin
         LDA PD.DRV,Y Get drive number again
         LSLA Set corresponding drv select
         BNE NOTDRV0   bit -- 1 for D1, 2 for D2
         INCA Set bit 0 for drive 0
NOTDRV0  TFR A,B Copy select bit
         ORB #$28 Enable double density
         ORCC #INTMASKS Disable IRQ and FIRQ
         STB >DPORT Enable drive
         STB DPRT.IMG,U Set image byte
         CLR Q.SEEK,U Clear same drive/track flag
         CMPX DRV.ACT,U Is this the same drive?
         BNE NEWDRIVE If not, leave flag zeroed
         LDB #$FF Indicate successive accesses
         STB Q.SEEK,U   to the same drive.
NEWDRIVE STX DRV.ACT,U Store table address
         BITA DRVS.RDY,U Has this drive been ready
         BNE DRVRDY   since the motors started?
         PSHS A Save drive select bit
         LDD #$D405 Force int, allow 250 mSec
         LBSR COMDEX Look for index pulse
         PSHS CC Save carry flag condition
         BSR KILLCOMD Clear index-pulse NMI state
         PULS CC,A Restore carry flag and A
         BCS RETURN3 Error if no index pulse
DRVRDY   ORA DRVS.RDY,U Set corresponding drive
         STA DRVS.RDY,U   ready flag
         LDA >STATREG Clear interrupt condition
         LDD #DISKRUN Restart the disk rundown
         STD VI.VAR,U   VIRQ counter
         CLRB Return no error
RETURN3  RTS
*
ERR.UNIT COMB Set carry flag
         LDB E$UNIT Set error code
         RTS
*
*  And add this code to finish it up:
*
IRQ.SVC  LEAY VI.VAR,U Point to VIRQ data
         CLR 1,Y Clear counter LSB
         CLR 4,Y Clear status byte
         CLR >DPORT Stop disk motors
         RTS
*
         EMOD CRC bytes
SIZE     EQU *
         END

-------------------------------
		Dave Lewis    Loral Instrumentation   San Diego

    sdcsvax--\     gould9 --\
    ihnp4 ---->-->!sdcc3 ---->--->!loral!dml  (uucp)
    sdcrdcf -/     crash ---/

"It would seem that I could ride away without being shot down."
"To ambush me later? I'm afraid I can't permit it. It has become a matter of
      future self-defense."  -- Dilvish (Roger Zelazny)
-------------------------------