;******************************************************* ; ; SCSI Driver 'Status' filter. ; ; Written by Matt Gulick. Started August 12,1988 ; ; Copyright Apple Computer, Inc. 1988-93 ; All Rights Reserved ; ;******************************************************* ;******************************************************* ; ; This file contains the 'Status' filter as defined ; in the ERS. ; ;******************************************************* ;******************************************************* ; ; Revision History: ; ;******************************************************* ; ; Aug 12, 1988 File started. ; April 17, 1989 Made changes to accomadate the ; Scanner Driver. ; ; *** System 6.0.1 *** ; ; 16-Feb-93 Jim Murphy added DStatus $4000 ; to return SCSI ID (search for ; JCM). ; ;******************************************************* STRING PASCAL BLANKS OFF PAGESIZE 70 PRINT NOGEN PRINT NOMDIR MACHINE M65816 IMPORT bitmap IMPORT rpm_blk_num IMPORT stat_cont IMPORT rebuild IMPORT read_pm_blk IMPORT call_type IMPORT main_drvr IMPORT internal IMPORT f_partition IMPORT test_unit_rdy IMPORT rqst_sense IMPORT mode_sense IMPORT read_capacity IMPORT t_dvc_blocks IMPORT set_512_mode IMPORT open_flag IMPORT set_our_dp IMPORT disk_switch IMPORT set_disk_sw IMPORT rebld_dibs IMPORT unit_state IMPORT trash_it IMPORT uses_dc IMPORT dib_data_struct IMPORT lst_rslt_ec ;Status IMPORT lst_rslt_id ;Status IMPORT lst_rslt_stat ;Status IMPORT lst_rslt_skey ;Status IMPORT lst_rslt_info ;Status IMPORT lst_rslt_rqlen ;Status IMPORT lst_rslt_scode ;Status IMPORT sense_data IMPORT auto_sense_data IMPORT internal_buff IMPORT display_cnt IMPORT current_fmt IMPORT opt1_blk_cnt IMPORT opt1_blk_siz IMPORT opt1_med_siz IMPORT opt2_blk_cnt IMPORT opt2_blk_siz IMPORT opt2_med_siz IMPORT opt3_blk_cnt IMPORT opt3_blk_siz IMPORT opt3_med_siz IMPORT format_options IMPORT check_532_rw ENTRY dvc_status ENTRY g_config_parms ENTRY wait_status ENTRY fmt_options ENTRY read_p_map ENTRY g_last_rslt ENTRY get_target_priority PRINT OFF INCLUDE 'scsihd.equates' INCLUDE 'M16.MEMORY' INCLUDE 'M16.UTIL' PRINT ON ;------------------------------------------------------------------------------- IF scsi_dtype = direct_acc THEN ENTRY gdp ENTRY gvp ENDIF ;------------------------------------------------------------------------------- EJECT ;******************************************************* ; ; Main Entry point to the 'Status' filter. This ; "Filter" is called when a Status Command comes in. ; See the headers of the seperate sections for the ; details of the commands. ; ; 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 status status PROC ; ; Check to see if this is a Get Last Result ; call. If so, then don't worry yet about ; getting the Unit State. ; lda Bit 15, Bit 0 --> Carry bcs @bad_rqst_cnt ;No odd byte transfers asl a ;Carry <-- Bit 15, Bit 0 <-- 0 sta >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> IF scsi_dtype<>apple_cd\ AND scsi_dtype<>changer THEN @chk_for_6 cmp #$0006 beq @inserted ELSE ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> @chk_for_6 cmp #$0006 bne @not_a_6 lda sense_data+\ ;Was it a RESET? rqst_sens.addnl_sens_code and #$00ff cmp #$00b0 ;Checking for $B0 (NO MEDIA) beq @fixit and #$00fe ;Checking for $28 (INSERTION) cmp #$0028 ;or $29 (RESET) beq @inserted ;Yes it was. @fixit jmp @chk_switch ; ; If the device is a CD_ROM device ; then check to see if the SENSE KEY ; = 5. If so, then treat it as no ; error. ; @not_a_6 cmp #$0005 bne @its_bs jmp @its_back @its_bs ENDIF ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> stz mcd_40 THEN jsr set_512_mode ENDIF ;scsi_dtype <> mcd_40 ;------------------------------------------------------------------------------- ; ; Issue the READ CAPACITY Command. ; jsr read_capacity bcs @no_capacity ;Was there an error? ; ; Get the Block Count (Stored ; High >> Low. Must be switched ; to Low >> High). This is the last ; readable block number. Add 1 to ; it for comparison reasons. ; lda |block.count\ +internal_buff\ +2 xba adc #$0001 ;Carry is Clear as a result sta |t_dvc_blocks ;of the 'READ CAPACITY' Call lda |block.count\ +internal_buff xba adc #null sta |t_dvc_blocks+2 @no_capacity jsr rebld_dibs ;Rebuild DIBs and Issue a DISK_SW php ;for each ; ; Restore the origonal Direct Page ; values. ; jsr set_our_dp plp bcc @set_switch jsr test_unit_rdy bcc @set_switch ; ; For some reason, we cannot talk to the ; device. It must be offline. ; @chk_switch ldy #dib.dvcflag lda [dib_ptr],y tax and #dvc_hardofl bne @opened txa and #dvc_online--\ $ffff ora #dvc_hardofl sta [dib_ptr],y lda #bit_4 ;Clear the Online bit trb @dvc_stat lda #bit_0 ;Set the Switch bit tsb @dvc_stat bra @opened ; ; Set Online Bit. If dvc_hard_sw is ; set, then clear it and return the ; disk switch bit. ; @its_back lda [dib_ptr],y pha and #dvc_hard_sw tax pla and #dvc_hard_sw--\ $ffff sta [dib_ptr],y txa bne @set_switch bra @opened ;Back in business @switch ; ; Is this device linked? If it is, ; then we need to mark them all as ; being offline. ; ; Start at the headptr if non-zero. ; ldy #dib.headptr lda [dib_ptr],y tax ldy #dib.headptr+2 lda [dib_ptr],y bne @set_pointer2 ;Should not be bank 0 ; ; Current pointer is the first. ; lda > LSB formatted. ; lda |mode.blocks\ ;High Byte +internal_buff\ -1 and #$ff00 ora |mode.blocks\ ;.OR.ed with the Low Word +internal_buff\ +1 beq @do_from_dib ; ; MODE SENSE is legal. Use it. ; ; Set Block Count in format ; option list. ; lda |mode.blocks\ +internal_buff\ +1 xba sta |opt1_blk_cnt sta |opt2_blk_cnt lda |mode.blocks\ +internal_buff\ -1 xba sta |opt1_blk_cnt+2 sta |opt2_blk_cnt+2 ; ; Set Block Size in format ; option list. ; lda |mode.blk_size\ +internal_buff\ +1 xba cmp #$0214 ;is it = 532? bne @not_532 ;No. lda #$0200 ;Yes. @not_532 sta |opt1_blk_siz sta |opt2_blk_siz bra @set_med_size ; ; Set Block Count in format ; option list from DIB. ; @do_from_dib ldy #dib.blkcnt lda [dib_ptr],y sta |opt1_blk_cnt sta |opt2_blk_cnt ldy #dib.blkcnt+2 lda [dib_ptr],y sta |opt1_blk_cnt+2 sta |opt2_blk_cnt+2 ; ; Set Block Size in format ; option list. ; ldy #dib.blksize lda [dib_ptr],y sta |opt1_blk_siz sta |opt2_blk_siz ; ; Set Media Size in format ; option list. ; @set_med_size lda |opt1_blk_cnt+3 and #$00ff sta @t_blocks lda |opt1_blk_cnt+1 lsr @t_blocks lsr a lsr @t_blocks lsr a lsr @t_blocks lsr a adc #$0000 sta |opt1_med_siz sta |opt2_med_siz ; ; Get Read Capacity ; jsr read_capacity ; ; Set Block Size in format ; option list. ; lda |block.size\ +internal_buff\ +2 xba sta |opt3_blk_siz cmp #$0200 bne @over ; ; Set display count to 2 ; lda #$0002 sta |display_cnt-2 sta |display_cnt ; ; Set Block Count in format ; option list. ; @over lda |block.count\ +internal_buff\ +2 xba sta |opt3_blk_cnt lda |block.count\ +internal_buff xba sta |opt3_blk_cnt+2 ; ; Set Media Size in format ; option list. ; lda |block.count\ +internal_buff\ -1 xba sta @t_blocks lda |block.count\ +internal_buff\ +1 xba lsr @t_blocks lsr a lsr @t_blocks lsr a lsr @t_blocks lsr a adc #$0000 sta |opt3_med_siz ; ; Restore Direct Page ; jsr set_our_dp ; ; Check Count range ; lda > High. xba ; I Send it out High >> Low. sta |c_block_num ; ; Set Main Driver Pointer to ; our data for the command. ; lda #cmd_$8008 sta