;******************************************************* ; ; SCSI Driver 'Main Driver'. ; ; Written by Matt Gulick. Started May 25,1988 ; ; Copyright Apple Computer, Inc. 1988-90 ; ;******************************************************* ;******************************************************* ; ; This file contains the 'Main Driver' as defined in ; the ERS. ; ;******************************************************* ;******************************************************* ; ; Revision History: ; ;******************************************************* ; May 25, 1988 File started. ; June 6, 1988 Turned sections into subroutines ; and wrote the Main Driver Proper. ; June 20, 1988 Added Register Input and Output. ; Also included the changes from ; the code review. ; Oct 25, 1988 Made changes in code to reflect the ; redesign of the SCSI Manager interface. ; STRING PASCAL BLANKS OFF PAGESIZE 70 PRINT NOGEN PRINT NOMDIR MACHINE M65816 IMPORT cmd_t_tbl IMPORT call_type IMPORT scratch0 IMPORT cmd_ps_tbl IMPORT c_len_len IMPORT c_blk_len IMPORT divide IMPORT result IMPORT divend IMPORT divsor IMPORT time_cnt IMPORT rout2_s_disp IMPORT gsos_dpage IMPORT f_partition IMPORT internal IMPORT disk_switch IMPORT scsi_mgrnum IMPORT manager_cmd IMPORT cur_cmd IMPORT cur_group IMPORT trans_dest IMPORT p_block_num IMPORT killer_blk IMPORT trans_flag IMPORT temp_x IMPORT temp_y IMPORT timeout_flag IMPORT auto_sense_data IMPORT lst_rslt_stat IMPORT lst_rslt_skey IMPORT lst_rslt_info IMPORT lst_rslt_rqlen IMPORT lst_rslt_scode IMPORT auto_sense_data IMPORT auto_sense_data PRINT OFF INCLUDE 'scsihd.equates' INCLUDE 'M16.MEMORY' INCLUDE 'M16.UTIL' PRINT ON EJECT ;******************************************************* ; ; Main Entry point to the 'Main Driver'. ; ; The function of this code is to take the callers ; command data and build a SCSI Command Packet. This ; is done using the conversion tables in the file ; 'SCSI Command Table'. The command and other data ; is actually built in the space that has been added ; to the DIB and then routed to the SCSI Manager. ; ; The routine is called with the LONG pointer to the ; callers command data in the Direct Page location ; 'scsi_mdrvr'. This, in conjunction with the DIB Ptr ; at direct page location 'dib_ptr' as the address ; for the template overlay, will be used to do the ; following: ; ; Transfer the callers command data to the command ; packet. ; Zero all 12 bytes first. ; Validate Internal Command flag if set. ; .OR. in all values durring translation. ; Adjust Transfer length if needed. ; Convert Block Number from Logical to Actual ; If partition Flag is ­ zero then leave ; block number unmodified. ; Check for command errors. ; ; Stuff SCSI Manager Flags ; ; Stuff data in the TRX buffer data structure ; ; Ship the call out to the SCSI Manager. ; ; Clear Partition Call Flag. ; ; Clear the Internal Command Flag. ; ; Translate any SCSI errors into GS/OS errors. ; ; Inputs: Acc = Unspecified ; Y register = Unspecified ; X register = Unspecified ; P register = 0=M=X=e ; Direct Page = Ours ; Data Bank = Ours ; ; Outputs: Acc = Unspecified ; Y register = Unspecified ; X register = Unspecified ; P register = 0=M=X=e ; Direct Page = Ours ; Data Bank = Ours ; ; Errors: Carry set if Error. ; ;******************************************************* EXPORT main_drvr main_drvr PROC ; ; Clear the Timeout flag ; stz |timeout_flag ; ; Clear the Command Buffer ; ldx #max_cmd_len*2\ -2 ldy #max_cmd_len*2\ +dib.scsicmd\ -2 lda #$0000 @loop sta [dib_ptr],y dey dey dex dex bpl @loop ; ; Get the Current CoMmanD and GRouP ; lda [scsi_mdrvr] and #$00ff sta |cur_cmd ;Preserve Current Command Number pha ; ; Get Offsets to Validate Command ; Support by the device. ; tax and #bit_4\ +bit_5\ +bit_6\ +bit_7 lsr a lsr a lsr a tay lda |bm_cmd_offset,y tay txa and #bit_0\ +bit_1\ +bit_2\ +bit_3 asl a tax lda [dib_ptr],y and |bm_cmd_mask,x bne @cmd_support ; ; Command Not Supported ; by this device. ; pla ;Fix Stack lda #drvr_bad_code sec rts ; ; Get the SCSI Group Number. ; @cmd_support pla and #bit_5\ +bit_6\ +bit_7 lsr a lsr a lsr a lsr a lsr a sta |cur_group ; ; Set TRANSlation PoiNTer ; jsr s_trans_ptr bcs @exit_far ; ; VALidate the CoMmanD TYPe ; jsr val_cmd_typ bcs @exit_far ;Bad Command ; ; Set 'scsi_zp4' to scsi Command ; in DIB ; clc lda smgr_pl_ptr,x lda smgr_pl_ptr+2,x ; ; Call the SCSI Manager via the ; S_DISPATCHER ; lda |scsi_mgrnum ;Get the Managers ID ldx |manager_cmd ;Get Manager Command Number jmp rout2_s_disp EJECT ; ; Bitmaps used to check ; for command errors. ; ; Offset into DIB to where ; the WORD is that holds the ; bit for this group. ; bm_cmd_offset dc.w dib.group0 ;group0 Low WORD dc.w dib.group0+2 ; High WORD dc.w dib.group1 ;group1 Low WORD dc.w dib.group1+2 ; High WORD dc.w dib.group2 ;group2 Low WORD dc.w dib.group2+2 ; High WORD dc.w dib.group3 ;group3 Low WORD dc.w dib.group3+2 ; High WORD dc.w dib.group4 ;group4 Low WORD dc.w dib.group4+2 ; High WORD dc.w dib.group5 ;group5 Low WORD dc.w dib.group5+2 ; High WORD dc.w dib.group6 ;group6 Low WORD dc.w dib.group6+2 ; High WORD dc.w dib.group7 ;group7 Low WORD dc.w dib.group7+2 ; High WORD ; ; Mask for commands $00 - $0F ; in the low word and commands ; $10 - $1F in the high word. ; bm_cmd_mask dc.w bit_7 ;CMD $x0 Bit 7 Low Byte dc.w bit_6 ;CMD $x1 Bit 6 Low Byte dc.w bit_5 ;CMD $x2 Bit 5 Low Byte dc.w bit_4 ;CMD $x3 Bit 4 Low Byte dc.w bit_3 ;CMD $x4 Bit 3 Low Byte dc.w bit_2 ;CMD $x5 Bit 2 Low Byte dc.w bit_1 ;CMD $x6 Bit 1 Low Byte dc.w bit_0 ;CMD $x7 Bit 0 Low Byte dc.w bit_15 ;CMD $x8 Bit 7 High Byte dc.w bit_14 ;CMD $x9 Bit 6 High Byte dc.w bit_13 ;CMD $xA Bit 5 High Byte dc.w bit_12 ;CMD $xB Bit 4 High Byte dc.w bit_11 ;CMD $xC Bit 3 High Byte dc.w bit_10 ;CMD $xD Bit 2 High Byte dc.w bit_9 ;CMD $xE Bit 1 High Byte dc.w bit_8 ;CMD $xF Bit 0 High Byte ENDP EJECT END