.MCALL .MODULE .MODULE INDUTL,VERSION=24,COMMENT= ; Copyright (c) 1998 by Mentec, Inc., Nashua, NH. ; All rights reserved ; ; This software is furnished under a license for use only on a ; single computer system and may be copied only with the ; inclusion of the above copyright notice. This software, or ; any other copies thereof, may not be provided or otherwise ; made available to any other person except for use on such ; system and to one who agrees to these license terms. Title ; to and ownership of the software shall at all times remain ; in Mentec, Inc. ; ; The information in this document is subject to change without ; notice and should not be construed as a commitment by Digital ; Equipment Corporation, or Mentec, Inc. ; ; Digital and Mentec assume no responsibility for the use or ; reliability of its software on equipment which is not supplied ; by Digital or Mentec, and listed in the Software Product ; Description. .ENABL GBL,LC .SBTTL System macros ;+ ;External macros. ;- .MCALL .READC, .READW, .CSTAT, .RELEAS, .SPFUN .MCALL .CLOSE, .HERR, .SERR, .DSTAT, .CKXX .MCALL GCLDF$, DEFIN$, FDBDF$, FERDF$, RT5DF$ .GLOBL VOLFLG, DVSTAT, RDEMT, SYSGEN, RTEM$ DEFIN$ ;Definitions for IND files GCLDF$ ;Define GCML block offsets and symbols FDBDF$ ;Define FDB offsets FERDF$ ;Define file service error codes RT5DF$ ;RT11 definitions ;+ ; Equates used in this module ;- SF.MRE =: 373 ; Rewind code for magtapes SF.SIZ =: 373 ; Get Device Size OPSECT INDUTL ;+ ;This module contains general use utility directives such as: ; .INC, .DEC, and .TESTDEVICE ;- ;+ ;ASCII text for device status. To be stored in EXSTRI. ;- NSD: .ASCIZ /NSD,/ ;No such device DOTTXT: .ASCIZ /.,0,0,0,/ ;Dot for decimal plus 3 fill values LOD: .ASCIZ /LOD,/ ;Loaded device UNL: .ASCIZ /UNL,/ ;Unloaded device ONL: .ASCIZ /ONL,/ ;Device on line OFL: .ASCIZ /OFL,/ ;Device off line MTD: .ASCIZ /MTD,/ ;LD unit is mounted NMT: .ASCIZ /NMT,/ ;Not a mountable device or LD unit not mounted UNK: .ASCIZ /UNK,/ ;Unknown ATT: .ASCIZ /ATT,/ ;Device attached to another job NAT: .ASCIZ /NAT,/ ;Device is not attached to another job .EVEN .SBTTL Routine to process INC and DEC directives ;+ ;INC0 ;DEC0 ;Increment or decreament a numeric symbol ;- .ENABL LSB INC0:: MOV #1,-(SP) ;Set value to add to symbol BR 1$ ;Goto common routine DEC0:: MOV #-1,-(SP) ;Set value to add to symbol 1$: CALL GTSYM ;Parse symbol name BCC 2$ ;Branch if no error CMPB R2,# ;End of line? BNE 5$ ;No, syntax error 2$: CALL SRSYM ;Search symbol table for symbol BCS 3$ ;Undefined symbol error BITB #,SETYP(R5) ;Is symbol numeric (Octal or decimal)? BEQ 4$ ;No, symbol type error ADD (SP)+,SEVAL(R5) ;Yes, add or subtract 1 with contents of sym JMP INDRD ;Return for next command 3$: TRAP ERUDS ;Undefined symbol error 4$: TRAP ERTYP ;Symbol type error 5$: TRAP ERSYN ;Syntax error .DSABL LSB .SBTTL TESTDV - .TESTDEVICE directive ;+ ;TESTDV ; TESTDEVICE directive processing. Determine if what was specified is ; a valid device and return the physical name, device size and attributes ; in the special symbol . ; ; Input: ; R0 -> command string (after TESTDEVICE directive itself) ;- .CKXX ; Track the stack through S.ORG =: 1000 ; the spaghetti code CK.SPA = S.ORG CK.SPB = CK.SPA .ENABL LSB TESTDV::CLR VOLFLG ; Just in case we just did a .VOL MOV #NSD,R4 ; Point to no such device message MOV #SPSDEV+SEVAL,R5 ; Point to special symbol CALL GDSTAT ; Get device status BCC 10$ ; Branch if there's a device TDEND: MOVB (R4)+,(R5)+ ; Store the message BNE TDEND ; Branch if more TSTB -(R5) ; Back up one for exact sizing SUB #SPSDEV+SEVAL,R5 ; Point to EXSTRI data area MOVB R5,SPSDEV+SELEN ; and store it JMP INDRD ; Return for next command ...... 10$: MOV #DVSTAT,R3 ; Let R3 point to DVSTAT BIT #,@R3 ; Device MSCP? BNE 14$ ; branch if so BIS #,@R3 ; otherwise, want LOOKUP in GETHDL 14$: CALL GETHDL ; Get handler (and do LOOKUP) BIT #,@R3 ; Is it resident? BEQ 24$ ; Fetch failed MOV DVINFO+4,-(SP) ; Save load address for later CK.SPA ,-2 CK.SPB ,-2 CMP F$ERR(R1),# ; Did LOOKUP fail? BEQ 17$ ; then say NSD. ; Use IGTDUS to get status of (T)MSCP devices. IGTDUS does a .LOOKUP ; and .CLOSE of its own. BIT #,@R3 ; MSCP device? BEQ 20$ ; branch around if not. .SERR ; Trap all errors CALL GDSTA1 ; Yes, special check for NSD vs OFL .HERR ; Let monitor handle fatal errors now .ASSUME NSDFLG EQ 100000 TST @R3 ; Did GDSTA1 say NO SUCH DEVICE? BPL 18$ ; Branch if not 17$: JMP 230$ ; No such device (NSD) ...... 18$: BIS #,@R3 ; Now request NFS LOOKUP on MSCP dev CALL GETHDL ; re-lookup channel ; All devices join in here 20$: SAVE CK.SPA ,-2 CK.SPB ,-2 BIT #,@R3 ; Is it resident? BEQ 22$ ; Use the name we have. BIT #,@R3 ; Is device attached? BEQ 30$ ; No, go on 22$: MOV R5,R0 ; Get pointer to string buffer MOV F$DNAM(R1),R1 ; Get device name BR 40$ ; go on to device size 24$: CLR -(SP) ; indicate NOT LOADED, BR 20$ ; go get the name .ASSUME F$CHAN EQ 0 30$: .CSTAT #EMTBLK,@R1,#CSIBLK ; Get channel status MOV CSIBLK+12,R0 ; Get RAD50 device handler name MOV CSIBLK+10,R1 ; Now get unit number BIC #^C<77>,R1 ; (necessary for MQ) CALL $DEVTR ; SYSLIB routine handles 64-units MOV R0,R1 ; Do the register shuffle... MOV R5,R0 ; Get pointer to string buffer 40$: CALL $C5TA ; Convert name to ASCII and store it CK.SPA = CK.SPB MOV R0,R5 ; Return pointer to R5 MOVB #,(R5)+ ; Store a separator MOV @SP,R1 ; Restore R1 but don't lose it MOV #$INPBF,R2 ; R2 = Start address to read into CLR @R2 ; Default to size=0 BIT #,DVSTAT ; is device attached? BNE 50$ ; Can't do SPFUN, use size from DSTAT BIT #,DVINFO ; Variable sized device? BEQ 50$ ; Use DSTAT info if not. MOV #SF.SIZ,R3 ; Set up SPFUN code to get device size CLR R4 ; 5th argument is 0 CK.SPA = S.ORG-4 CALL SPFUN ; Do SPFUN to get device size BCC 60$ ; Branch if SPFUN got a size 50$: MOV DVINFO+6,@R2 ; Use size returned by .DSTAT 60$: MOV R5,R0 ; Point to string buffer MOV @R2,R1 ; Get device size CLR R2 ; Suppress leading zeros CALL $CBDMG ; Convert to decimal ASCII MOV R0,R5 ; Return pointer to R5 MOV #DOTTXT,R4 ; Point to decimal and fill zeros 70$: MOVB (R4)+,(R5)+ ; Move chars into string buffer BNE 70$ ; Branch until done TSTB -(R5) ; Backup position pointer RESTOR CK.SPA ,+2 CK.SPB ,+2 75$: MOV #UNL,R4 ; assume unloaded BIT #,DVSTAT ; Handler resident? BEQ 80$ ; No store UNL MOV #LOD,R4 ; Point to loaded message 80$: MOVB (R4)+,(R5)+ ; Store the message BNE 80$ ; Branch if more TSTB -(R5) ; Back up one for exact sizing ;+ ;Check and record ONLINE/OFFLINE status. If device is "write only" or ;sequential access device (other than non RT-11 directory-structured devices) ;then this field is reported ans unknown (UNK). ;- MOV DVINFO,R3 ; Store device status CMPB R3,# ; Logical disk? BEQ 110$ ; Branch if yes 85$: MOV #UNK,R4 ; Assume WRITE ONLY or certain seq dev CLR -(SP) ; Setup flag to set NMT later CK.SPA ,-2 ;+ ;The order of checks in this next section is to be considered critical. It ;was done due to the nature of the "PRINTER" class devices. ;- BIT #,R3 ; Write-only device? BNE 150$ ; Branch if yes -- it's UNKnown MOV R3,-(SP) ; is this device BIC #^c,@SP ; "non-quiescable"? CMP (SP)+,#HNDLR$ ; (like MQ?) BEQ 150$ ; if so, it's an UNKnown MOV R3,-(SP) ; is this device BIC #^c,@SP ; foreign and random access? CMP (SP)+,# ; (like KP?) BEQ 150$ ; if so, it's an UNKnown BIT #,R3 ; Printer or magtape? BNE 90$ ; Yes, skip next check BIT #,DVSTAT ; Attached? BNE 100$ ; Yes, don't care what kind .ASSUME FILST$ EQ 100000 TST R3 ; Sequential access device? like TT? BPL 150$ ; Branch if yes ; End of section to be considered critical. 90$: MOV #OFL,R4 ; Assume device is offline BIT #,DVSTAT ; Is device attached? BEQ 140$ ; No go on 100$: MOV #ONL,R4 ; Say it is online BR 150$ ; Store it ...... ;+ ; This section is for LD units only. Crawl through the LD table to ; ensure that the underlying physical device is on-line. ;- 110$: BIT #,DVSTAT ; Is device attached? BEQ 130$ ; No, skip next MOV #ONL,R4 ; Say we are online 120$: MOVB (R4)+,(R5)+ ; Put it in the buffer BNE 120$ TSTB -(R5) BR 160$ ; Go get MNT in buffer ...... 130$: MOV #OFL,R4 ; Assume off-line... CALL LDSTAR ; Get LD unit status MOV R0,-(SP) ; *C* (store LD.FLG on stack) CK.SPB ,-2 BCS 150$ ; branch if OFF_LINE ;+ ; Now return to general processing. ; Read a block to make certain that the device is ON_LINE ;- 140$: MOV R1,$IOWNR ; Make us the owners of input buffer MOV #$INPBF,R2 ; R2 = Start address of read buffer BIT #,DVSTAT ; Is it a MAGTAPE? BEQ 142$ ; If not, use READ to determine ; ON/OFF line ; Rewind the tape to determine whether or not it is on-line MOV #SF.MRE,R3 CALL SPFUN1 ; rewind BCS 150$ ; error means OFFLINE BR 146$ ; otherwise, say ONLINE ...... 142$: .READC #RDEMT,@R1,CODE=NOSET ;Use this to avoid additional ;instructions that READW generates. ;This is actually a READW as set in RDEMT .ASSUME F$CHAN EQ 0 ;F$CHAN(R1) BCS 150$ ;Error implys that device is offline 146$: MOV #ONL,R4 ;No error. Device is ON_LINE ; Store the OFL, ONL or UNK message 150$: MOVB (R4)+,(R5)+ ;Store the message BNE 150$ ;Branch if more TSTB -(R5) ;Back up one for exact sizing MOV #NMT,R4 ;Assume LD unit is not mounted TST (SP)+ ;Get unit status CK.SPA ,+2 CK.SPB ,+2 BPL 170$ ;Plus - not mounted 160$: MOV #MTD,R4 ;Else mounted ; Close the channel, release the handler if we fetched it. 170$: .CLOSE @R1 ;Get rid of channel .ASSUME F$CHAN EQ 0 ;F$CHAN(R1) TST (SP)+ ;Was handler FETCHed? CK.SPA ,+2 CK.SPB ,+2 CK.SPA = S.ORG CK.SPB = S.ORG BNE 180$ ;Branch if no BIT #,DVSTAT ;If device attached we don't want to RELEASE BNE 180$ .RELEAS #WRKFDB+F$DNAM ;Yes, then release it 180$: TST DVSTAT ;NSD? BMI 200$ ;Yes - skip the NAT or ATT stuff 190$: MOVB (R4)+,(R5)+ BNE 190$ TSTB -(R5) MOV #NAT,R4 ;Assume device is not attached to another job BIT #,DVSTAT ;Is device attached? BEQ 200$ ;Branch if not attached MOV #ATT,R4 ;Say device is attached 200$: JMP TDEND ;Return to common exit ...... .SBTTL SPFUN - SPFUN routine for TESTDEVICE ;+ ;This SPFUN routine is used to make this module fit in this overlay. ;Since SPFUN generates a lot of instructions one general one is used. ;However ther is some special casing. Twice this routine may be entered. ;To get a size of a variable device (code 373) or to get the logical disk ;(LD) table (code 372). In the case of 373, if a error occurs on LD ;the error should be ignored. If not the device characters should be set ;to NSD. An error should not occur on a 372 since it has already been ;determined that LD is present. Watch me eat these words. ; ;Error is returned on SPFUN 373 when device is offline or not present. ;In this case size is return as 0, and we continue. ;- SPFUN: CALL SPFUN1 ; Do the SPFUN .ASSUME F$CHAN EQ 0 ;F$CHAN(R1) BCC 210$ ;Return if no error CMPB DVINFO,# ;Logical disk? BEQ 210$ ;Ignore error CMP R3,#373 ;SPFUN for size? BEQ 220$ ;Yes, special case 210$: TST (PC)+ ;CLC and RETURN 215$: SEC ;SEC to indicate .SPFUN didn't get size RETURN 220$: BIC #,DVSTAT ;No errors from size SPFUN CMPB DVINFO,# ;DY? BEQ 210$ ;Yes, ignore CMPB DVINFO,# ;DU? BEQ 215$ ;Yes, return with error (didn't get size) MOV #NSD,R4 ;Point to no such device message MOV #SPSDEV+SEVAL,R5 ;Point to special symbol CMP (SP)+,(SP)+ ;Clean up stack (saved R1 and RETURN) 230$: BIS #,DVSTAT ;NSD from SPFUN BR 170$ SPFUN1: .SPFUN #EMTBLK,@R1,R3,R2,R4,#0,#0 REGET:: RETURN ;Used to pull overlay back in after ;INDDEV code in another overlay from INDSU2 .DSABL LSB ROUNDUP ;Check for overflow and roundup .END