;******************************************************* ; ; SCSI Driver 'Status' filter. ; ; Written by Matt Gulick. Started August 12,1988 ; ; Copyright Apple Computer, Inc. 1988-90 ; ;******************************************************* ;******************************************************* ; ; This file contains the 'Status' filter as defined ; in the ERS. ; ;******************************************************* ;******************************************************* ; ; Revision History: ; ;******************************************************* ; Aug 12, 1988 File started. STRING PASCAL BLANKS OFF PAGESIZE 70 PRINT NOGEN PRINT NOMDIR MACHINE M65816 IMPORT call_type IMPORT main_drvr 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 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 PRINT OFF INCLUDE 'scsihd.equates' INCLUDE 'M16.MEMORY' INCLUDE 'M16.UTIL' PRINT ON 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 ; ; Zero out the Data Chaining Flag ; stz |uses_dc ; ; Clear transfer count. ; lda #null ldy #dib.trx_len sta [dib_ptr],y ldy #dib.trx_len+2 sta [dib_ptr],y ; ; Entry to the Status Call Filter. ; This filter acts as a mini driver. ; It examines the Status Code sent ; and calls the appropriate routines. ; If the Command is $8000 or greater, ; then it will be routed to the device ; specific section. ; 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 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 > 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 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