.enabl mcl .module MOUNT,version=01,comment= ;+ ;***************************************************************************** ; ; This routine mounts/dismounts logical disks. There are both FORTRAN and ; MACRO entry points. ; ; WARNING: This routine assumes RT-11 V5.4 or later ; ; Handlers for both LD: and the device for the logical disk file ; must be in memory - having been either LOADed or FETCHed. ; ;***************************************************************************** ; ; FORTRAN calling method: ; ; J = MOUNT ( IUNIT , FILE [,IFLAG] ) ; where: ; IUNIT = LD unit number to be mounted/dismounted ; (See description of IFLAG) ; FILE = 4-word RAD50 descriptor of file ; IFLAG = (optional) +1 => mount read-only ; 0 => ignored ; -1 => dismount ; ; J = value returned ; +1 LD table size mismatch (wrong version) ; 0 Normal return - no errors ; -1 Error reading/writing LD tables ; -2 LD handler not in memory ; -3 File not found ; -4 Device handler not in memory ; -5 No I/O channel available ; ; (R1 & R5 not preserved when called at FORTRAN entry point.) ; ;***************************************************************************** ; ; MACRO calling method ; ; JSR PC,$MOUNT ; ; Entry conditions: R0 = low-byte : unit number ; high-byte >0 => mount readonly ; <0 => dismount ; R1 = address of .RAD50 file descriptor ; ; Exit conditions: C-bit clear, R0 = 0 => normal return ; C-bit set, R0 <>0 error return. (See error ; valued in FORTRAN description ; R1-R5 preserved ; ;***************************************************************************** ;- ldunit = 8. ; Number of entries in LD tables ; LD.FLG bits ld.act = 100000 ld.rdo = 40000 ; If set, LD unit is read-only ld.unt = 37400 ; Unit number of physical disk ; assigned to this logical disk .psect USER$I mount:: clr r0 mov (r5)+,-(sp) cmpb (sp)+,#3 ; 3 parameters ? blt 1$ cmp 4(r5),#-1 ; yes, is third actually there ? beq 1$ mov @4(r5),r0 ; yes, put it in high byte swab r0 clrb r0 1$: bisb @(r5)+,r0 mov (r5),r1 .br $mount $mount::jsr r5,$savrg mov r1,-(sp) mov r0,r5 mov #-5,r3 ; error code .serr ; Disable EMT error abort movb #14.,r4 ; Find an available channel 5$: .cstat #area,r4,#status ; (Don't use 15. in case of overlays) bcs 10$ decb r4 bge 5$ br 25$ ; Oops, all channels in use 10$: inc r3 tst r5 ; Is this a dismount? bpl 15$ inc r3 ; Yes, skip the file lookup br 20$ 15$: .dstat #status,r1 ; Does device exist? bcs 25$ ; no error = -4 tst status+4 ; yes, is it loaded? beq 25$ ; no, error = -4 inc r3 ; yes, is file there? .lookup #area,r4,r1 bcs 69$ ; no, error = -3 .cstat #area,r4,#status ; yes, get particulars on file .purge r4 20$: inc r3 ; yes, how about LD .dstat #ldtbl,#lddev bcs 69$ ; not available, error = -2 tst ldtbl+4 ; OK is it in memory? beq 69$ ; no, error = -2 .lookup #area,r4,#lddev ; lookup LD bcs 69$ inc r3 .spfun #area,r4,#372,#ldtbl,#1 ; Read LD tables bcs 69$ cmpb ld.num,#ldunit ; did tables match? beq 30$ ; If not, we probably destroyed mov #1,r3 ; something. Sorry 'bout that! 25$: br 69$ 30$: asl r5 bcc 35$ ; mount or dismount ? bic #^c377,r5 ; isolate unit number bic #ld.act,ld.flg(r5) ; dismount this unit br 45$ 35$: mov nunit,r0 swab r0 bisb csw,r0 bicb #^c76,r0 bis #ld.act,r0 bit #^c377,r5 ; read-only ? beq 40$ bis #ld.rdo,r0 ; yes, set the bit 40$: bic #^c377,r5 ; isolate LD unit number mov r0,ld.flg(r5) mov stblk,ld.ofs(r5) mov length,ld.siz(r5) asl r5 asl r5 add #ld.nam,r5 mov device,(r5)+ tst (r1)+ ; skip device name (we already got it) mov (r1)+,(r5)+ ; copy file name mov (r1)+,(r5)+ mov (r1),(r5) 45$: .spfun #area,r4,#372,#ldtbl,#-1 ; write LD tables bcs 69$ inc r3 69$: .purge r4 .herr ; Restore EMT error abort mov r3,r0 bne 70$ tst (pc)+ 70$: sec mov (sp)+,r1 return .psect USER$D area: .blkw 6 lddev: .word ^RLD ,0,0,0 status: csw: .word 0 stblk: .word 0 length: .word 0 hiblok: .word 0 nunit: .word 0 device: .word 0 ldtbl: ld.id: .blkw 1 ; Filles with ^RLD ld.num: .blkb 1 ; Number of LD units (8. in V5.4) .blkb 1 ; (reserved) ld.flg: .blkw ldunit ld.ofs: .blkw ldunit ld.siz: .blkw ldunit ld.nam: .blkw 4*ldunit .end