;******************************************************* ; ; SCSI Driver 'Shutdown' filter. ; ; Written by Matt Gulick. Started August 9,1988 ; ; Copyright Apple Computer, Inc. 1988-90 ; ;******************************************************* ;******************************************************* ; ; This file contains the 'Shutdown' filter as defined ; in the ERS. ; ;******************************************************* ;******************************************************* ; ; Revision History: ; ;******************************************************* ; ; Aug 9, 1988 File started. ; Mar 8, 1989 Modified to support Warm/Cold ; Shutdown. STRING PASCAL BLANKS OFF PAGESIZE 70 PRINT NOGEN PRINT NOMDIR MACHINE M65816 IMPORT direct_page IMPORT default_dib IMPORT tot_dib_cnt IMPORT active_starts IMPORT stop_unit PRINT OFF INCLUDE 'scsihd.equates' INCLUDE 'M16.MEMORY' INCLUDE 'M16.UTIL' PRINT ON EJECT ;******************************************************* ; ; Main Entry point to the 'Shutdown' filter. This ; "Filter" is called when a Device is no longer ; desired in the tables. The following code segment ; first checks to see if the DIB being shut down is ; the default dib (it will only be shutdown durring ; startup). If it is the default dib we will do ; nothing and exit with no error. If on the other ; hand it is a valid DIB, we will clear some key ; fields within the dib and then we will alter the ; links to skip this DIB, then we update a field in the ; first DIB of this memory segment. This count tells ; how many active dibs there are in that segment. If ; this reaches zero we will then dispose this handle ; because it is unused. If we later need space to ; bring new devices online and we don't have the space, ; we'll get it at that time. If on exit there are ; still any active dibs that use this code segment then ; a DRVR_BUSY error will be returned. If no DIBs are ; active then no error will be returned. ; ; Inputs: [dib_ptr] = Last DIB built (LONG) ; Acc = Unspecified ; Carry = Unspecified ; Y register = Unspecified ; X register = Unspecified ; P register = 0=M=X=e ; Direct Page = Ours ; Data Bank = Ours ; ; Outputs: Acc = DRVR_BUSY ; Carry = 1 ; unless we have no more dibs then ; Acc = 0 ; Carry = 0 ; ; Y register = Unspecified ; X register = Unspecified ; P register = 0=M=X=e ; Direct Page = GS/OS Direct Page ; Data Bank = Ours ; ; Errors: See Spec. ; ;******************************************************* EXPORT shutdown shutdown PROC ; ; Check to see if this is for the ; 'default_dib'. If it is, then we ; need to exit with a DRVR_BUSY Error. ; lda warm_cold_flag and #$0001 beq @do_cold ;It's Cold ; ; Yeah, so it's a warm shutdown. But ; does this device know what that ; means? We'll see! ; ldy #dib.dvcchar lda [dib_ptr],y and #restartable beq @do_cold ;Not restartable. ; ; Mark as OFFLINE and Relaxing ; ldy #dib.dvcflag lda [dib_ptr],y and #dvc_online--\ $ffff ora #relaxing sta [dib_ptr],y ; ; Reinitialise DIB Device Number to ; zero. ; lda #null ldy #dib.devnum sta [dib_ptr],y ; ; Do the Head and Forward links also. ; ldy #dib.headlnk sta [dib_ptr],y ldy #dib.fdvclnk sta [dib_ptr],y ; ; Get out of here updating only ; the active DIB count not the ; total DIB Count. ; @continue jmp @update_acnt ENDIF ;------------------------------------------------------------------------------- ; ; It's a real DIB. Issue a $1B ; START/STOP Command. Ignor all ; errors, not all devices support ; this optional command. ; @do_cold jsr stop_unit ; ; Set Device to Default. ; ldy #dib.dvcflag lda #wait_mode++\ cold_dib sta [dib_ptr],y ; ; Shut it down. To do this we clear ; the DIB Device Number. ; ldy #dib.devnum lda [dib_ptr],y sta @this_device ;Save for a while lda #null sta [dib_ptr],y ; ; Dec Device count for this memory ; segment. ; ldy #dib.handle ;Set up to deref the handle to find lda [dib_ptr],y ;where this memory segment starts. sta