.comment % ######################################################### # # # Safety program for the Kaypro - 10 # # by M. Sherman. # # # # This program moves the heads over the landing # # zone. It should be run before turning off # # the machine. # # # #=======================================================# # # # Current revision: 1.3 19-Oct-83 # # Previous revision: 1.2 18-Jun-83 # # Previous version: 1.1 15-Jun-83 # # Previous version: 1.0 10-Mar-83 # # # # Changes, version 1.3 - Added conditional # # equates for inverted hard disk reset. (M.S.) # # Changes: De-select drive one by selecting # # zero before resetting the controller at the # # begining of the program. M. Sherman, # # version 1.2 # # Changes: Fixed problem with WD 1002 boards # # not being able to accept commands after being # # reset because it's doing internal diagnostics. # # Safety now waits until it's finished. Also # # modified to do two restores, in case the heads # # are out past cylinder 305 and the controller # # doesn't issue enough step pulses. (not very # # likely, but it CAN happen. M.L. # # ( M. Sherman, revision 1.1 ) # # # ######################################################### % .Z80 false equ 0 true equ not false hdcinv equ true ; hard disk reset line inverted? ; cp/m equates bdos equ 05 bcono equ 02 ; hard disk equates bitport equ 20 hdcmsk equ 11111101b ; hard disk controller reset line mask ; conditional select/reset masks if hdcinv hdcres equ 00000010b ; hard disk controller reset mask hdcsel equ 00000000b ; hard disk controller select mask else hdcres equ 00000000b ; hard disk controller reset mask hdcsel equ 00000010b ; hard disk controller select mask endif lzone equ 305 ; safety zone srest equ 1fh ; slow restore command sseek equ 7fh ; slow seek command (WD-Controller) drvsel equ 0A8h ; drive select drvmsk equ 11100111b ; drive select mask hdbase equ 80h hdclo equ 84h ; low byte, cylinder register hdchi equ 85h ; high byte, cylinder register hdsdh equ 86h hdcmd equ 87h hdsts equ 87h hdbusy equ 80h ; busy bit, status register sekcpl equ 10h ; seek complete line start: call hdbsy ; wait until it isn't busy, in a,(hdsdh) and drvmsk out (hdsdh),a ; select drive 0, de-select drive 1 call hdbsy call print ; sign on db 'Safety version 1.3' db 00 ; de-select the HDC in a,(bitport) ; get the system control port contents, and hdcmsk ; clear the reset bit(s), or hdcres ; or in reset mask, out (bitport),a ; de-select the HDC ; delay loop time delay for proper HDC reset ld bc,0 ; timing constant. (BC=0=1856 microseconds) offlp: djnz offlp ; delay loop before re-selecting controller dec c jr nz,offlp ; re-select the HDC in a,(bitport) ; get the system control port contents, and hdcmsk ; clear reset bit(s), or hdcsel ; or in select mask, out (bitport),a ; re-select the HDC. ; WD 1002 does diagnostics on power-up and reset, ; and is not ready to recieve commands, so wait for it to finish call hdbsy ld a,drvsel ; select drive out (hdsdh),a ld a,srest ; do a slow restore, out (hdcmd),a call hdbsy ; wait until done, ld a,srest ; do it twice. out (hdcmd),a call hdbsy ld bc,lzone ; put the landing zone track number in bc, ld a,c ; load the controller with the track address out (hdclo),a ld a,b out (hdchi),a ld a,sseek ; do a seek to the landing zone: out (hdcmd),a ; issue the seek command, call hdbsy call sekok ; wait for seek to finish ld a,drvsel and drvsel ; de-select drive (select drive 0) out (hdsdh),a call hdbsy ; de-select the HDC again before shutting down. in a,(bitport) ; get the system control register contents, and hdcmsk ; mask out HDC reset bit(s), or hdcres ; or in HDC reset mask, out (bitport),a ; de-select the HDC. call print ; tell 'em we're done db 1ah,1bh,'=',' '+11,' ' ; clear screen, position cursor db 'The heads have been placed over the safety zone' db 0dh,0ah,'and the hard disk controller has been de-selected.' db 0dh,0ah,'It is now safe for you to turn off your machine',00 wait: jr wait ; wait here for shut-down or reset. hdbsy: in a,(hdsts) ; wait until it's done. and hdbusy jr nz,hdbsy ret sekok: in a,(hdsts) and sekcpl ; test seek complete line jr nz,sekok ret print: pop hl ; print a message to the console ld a,(hl) inc hl push hl or a ret z ld e,a ld c,bcono call bdos jr print defw 0000h ; two for L80 END