.TITLE FTINIT SUBROUTINE FOR GETDVI, AND OPENING AN FTCOPY I/O FILE. .IDENT /30-APR-1984 V01.D/ ; ; V01.D TWD 30-APR-1984 Get the device buffer size with ; $GETDVI and store in calling program. ; V01.C TWD 29-DEC-1983 Change calling sequence to add fourth ; argument as the address of the storage for the ; current (in/out) device class. Use the new ; argument for the device class. Remove the trap ; for a device not being a tape or disk - this ; will allow use of devices NL:, TT:, and others. ; Use only RMS for any device/file which is not ; a tape mounted foreign. ; ; Get device information and either open an RMS file or SETUPFT the ; foreign tape. All errors are handled by calling the appropriate ; error handling routine. ; ; Calling sequence: ; ; PUSHAL device-size-word ; PUSHAL device-class-byte ; PUSHL #foreign-tape-flag ; PUSHAL foreign-tape-lun ; PUSHAL file-name-descriptor ; CALLS #5,G^FT_INI_FILE ; ; where - device-size-word is the address in the FTCB where the device's ; buffer size is to be stored. ; device-class-byte is the address in the FTCB where the device ; class for the current device is to be stored. ; foreign-tape-flag is the bit in the FTCB which indicates ; whether the file is foreign or RMS. ; foreign-tape-lun is the logical unit number for a foreign tape ; accessed through TAPESUBS. ; file-name-descriptor is the string descriptor of the file ; which is to be used for the input or output. ; ; On entry, the following registers are retained and used by the ; subroutine. ; R8 - the address of the NAM block for the current file. ; R9 - the address of the FAB for the current file. ; R10 - the address of the FTCB ; R11 - the address of the FTIO block. ; All other registers are saved with the exception of R0 and R1. ; Internal usage of the registers is: ; R0 - Status value from System subroutines. ; R1 - Not used. ; R2 - Used for scratch register. ; R3-R7 - Not used. ; ; ; This routine does not set any status on exit. All errors are handled ; internally or by the appropriate error routines. ; ; $NAMDEF ; NAME BLOCK DEFINITIONS. $FABDEF ; FILE ACCESS BLOCK DEFINITIONS. $DEVDEF ; DEVICE TYPE DEF. $DCDEF ; DEVICE CLASS DEF. $SSDEF ; SYS. STATUS DEF. $DVIDEF ; GET DEVICE INFO DEFINITIONS. ; FTCBDEF ; FOREIGN TAPE CONTROL BLOCK ; .PAGE ; .ENTRY FT_INI_FILE,^M ; ; PARSE THE FILE NAME THROUGH RMS BEFORE GETTING DEVICE INFO. ; MOVL 4(AP),R2 ; GET THE ADDR OF THE FILE DESCRIPTOR. ; MOVB (R2),FAB$B_FNS(R9) ; PUT THE FILE SIZE INTO FAB., ALSO, MOVL 4(R2),FAB$L_FNA(R9) ; PUT THE FILE NAME ADDR. ; $PARSE FAB=R9 ; PARSE THE FILE NAME. BLBS R0,5$ ; IF SUCCESS, BRANCH. ; ; BAD PARSE, EXIT PROGRAM. MOVZBL NAM$B_ESL(R8),R5 ; GET EXPANDED STRING LENGTH. CALL_MSG EXIT_SYS,#FTC_RMSERROR,#4,MSG_18,MSG_18+4,- R5,NAM$L_ESA(R8),R0,FAB$L_STV(R9) ; ; SET UP THE CALL TO THE GETDVI SERVICE WITH THE DEVICE PORTION ; OF THE FILE NAME SPECIFIED IN THE CALL. ; 5$: MOVL NAM$L_DEV(R8),DEV_DESC+4 ; BUILD THE DEVICE NAME MOVZBL NAM$B_DEV(R8),DEV_DESC ; DESCRIPTOR. ; $GETDVI_S EFN=#15,DEVNAM=DEV_DESC,- ; GET DEVICE INFO. ITMLST=DEVI_LST,IOSB=INI_STAT BLBS R0,10$ ; IF SUCCESS, THEN BRANCH. ; ; BAD GET DEV INFO - EXIT CALL_MSG EXIT_SYS,#FTC_GETDVIERR,#0,#FTC_SYSERROR,#0 ; 10$: $WAITFR_S EFN=#15 ; WAIT TO BE SURE THE GETDVI IS COMPLETE. BLBS R0,15$ ; IF OK, BRANCH ; ; BAD WAIT, EXIT WITH SYS INFO. CALL_MSG EXIT_SYS,#FTC_WAITFRERR,#0,#FTC_SYSERROR,#0 ; ; SAVE THE DEVICE CLASS IN THE FTCB AND ; CHECK THE DEVICE TYPE. ; 15$: MOVB DEV_CLASS,@16(AP) ; SAVE DEVICE CLASS. MOVW DEV_BUF,@20(AP) ; SAVE THE DEVICE'S BUFFER SIZE. CMPB #DC$_TAPE,DEV_CLASS ; CHECK TO SEE IF THIS IS A TAPE BNEQ CK_DISK ; NOT TAPE -- CHECK DISK ET.AL. ; BRW CK_TAPE ; GO CHECK ON TAPE DEVICES. ; ; ; DISK OR OTHER RMS INPUT ; DISK INPUT -- CHECK SOME MORE AND THEN OPEN THE FILE. ; CK_DISK: ; START TO OPEN THE FILE FOR RMS INPUT. ; RMS_OPEN: INCL FTCB_L_RMS_CNT(R10) ; INCREMENT THE RMS COUNT. BBCC 12(AP),FTCB_W_FLAG(R10),11$ ; CLEAR THE FOR. TAPE ; FLAG - I.E. RMS ; 11$: CMPL 12(AP),#FLAG_V_FTIN ; CHECK TO SEE IF THIS IS INPUT OR OUT. BEQL 15$ ; IF INPUT, THEN CONTINUE TO OPEN. ; RET ; IF OUTPUT, RETURN TO MAIN. ; 15$: $OPEN FAB=R9 ; OPEN THE FILE. BLBS R0,20$ ; IF OK, BRANCH. ; ; BAD OPEN - EXIT - RMS MOVZBL NAM$B_ESL(R8),R5 ; GET EXPANDED STRING LENGTH. CALL_MSG EXIT_SYS,#FTC_RMSERROR,#4,MSG_10,MSG_10+4,- R5,NAM$L_ESA(R8),R0,FAB$L_STV(R9) ; 20$: RET ; RETURN AND CONTINUE THE OPEN. ; ; ; CHECK ON THE TAPE AND SET UP THE CHANNEL IF OK. ; CK_TAPE: BBS #DEV$V_MNT,DEV_CHAR,10$ ; BRANCH IF MOUNT BIT IS SET. ; ; DEVICE NOT MOUNTED - ABORT. CALL_MSG EXIT_SYS,#FTC_FTDEVERR,#2,DEV_DESC,DEV_DESC+4,- #SS$_DEVNOTMOUNT ; ; CHECK TO SEE IF MOUNTED FOREIGN - RMS OR TAPESUBS FOR ACCESS. ; 10$: BBS #DEV$V_FOR,DEV_CHAR,20$ ; BRANCH IF FOREIGN BIT IS SET. ; ; ; TAPE IS NOT MOUNTED FOREIGN, BRANCH TO USE RMS TO OPEN. ; BRW RMS_OPEN ; USE RMS. ; ; ; FOREIGN TAPE - ; SET UP THE CHANNEL AND "OPEN" IT. ; 20$: PUSHAL INI_STAT PUSHL 4(AP) ; THE FILE DESCRIPTOR. PUSHL 8(AP) ; THE TAPE LUN. CALLS #3,G^SETUPFT ; BLBS INI_STAT,30$ ; CHECK TO BE SURE SETUP WAS DONE. ; ; BAD FOREIGN TAPE SETUP - ABORT. CALL_MSG EXIT_SYS,#FTC_FTERROR,#2,MSG_14,MSG_14+4,- #FTC_ERRCODE,#1,INI_STAT,INI_STAT ; 30$: RET ; RETURN TO CONTINUE THE OPEN. ;; .PAGE .SUBTITLE DATA FOR FTINIT. ;; DEVI_LST: .WORD 4 ; GETDVI ITEM LIST .WORD DVI$_DEVCLASS ; DEVICE CLASS .ADDRESS DEV_CLASS .LONG 0 ; .WORD 4 .WORD DVI$_DEVCHAR ; DEVICE CHARACTERISTICS. .ADDRESS DEV_CHAR .LONG 0 ; .WORD 4 .WORD DVI$_DEVBUFSIZ ; DEVICE BUFFER SIZE. .ADDRESS DEV_BUF .LONG 0 .LONG 0 ; DEV_CLASS: .LONG 0 DEV_CHAR: .LONG 0 DEV_BUF: .LONG 0 ; DEV_DESC: .QUAD 0 ; INI_STAT: .QUAD 0 ; .END