.TITLE MTYSET.MAC - MULTI-TERMINAL INITIALIZATION .ENABL LC ;+ ; MULTI-TERMINAL INITIALIZATION PROGRAM ; ; AUTHOR: L.C.P. - 10/79 ; ; This program will attach all "known" terminals and ; if they are VT100s or VT52s it will determine at what ; baud rate they are set and put that information in ; their TCBs. ("Foreign" terminals will be assumed to ; be set at the correct baud rate). As each terminal is ; "initialized", its screen will be cleared, a "sign-on" ; message will be displayed, and the terminal type and ; baud rate will be logged on the background console. ;- .SBTTL Macros and definitions .MCALL .MTATCH,.MTDTCH,.MTGET,.MTOUT,.MTIN .MCALL .MTPRNT,.MTSET,.MTSTAT,.EXIT .MCALL .MTRCTO,.PRINT,.TTYOUT,.MRKT,.CMKT M.TSTW = 7 ;Offset to state word in TCB S.FTCB = 0 ;Stat offset to 1st TCB offset S.CTCB = 2 ;Stat offset to console TCB S.NTCB = 4 ;Stat offset to # TCB (LUN) S.STCB = 6 ;Stat offset to TCB size MSPEED = 7400 ;Baud rate mask = bits 8-11 TCBIT$ = 100 ;Inhibit TT wait TTSPC$ = 10000 ;TT special bit HNGUP$ = 4000 ;Terminal had hung up (offline) DZ11$ = 10000 ;DZ11 REMOT$ = 20000 ;DZ11 line is remote BKSP = 100000 ;Backspace for rubout(delete) ;*LCP* TAB = 1 ;Hardware tab ;*LCP* NOCRLF = 2 ;*CLEAR* CRLF bit ;*LCP* LF = 12 ;Line feed CR = 15 ;Carriage return ESC = 33 ;Escape .SBTTL Start of program .ENABL LSB,LC ;MUST enable Lower case! MTYSET: MOV #STAT,R3 ;R3 => 8 word status .MTSTAT #AREA,R3 ;Get MTTY status MOV S.NTCB(R3),R2 ;R2 = # of LUNs BEQ MTEXIT ;Just exit if none! MOV S.CTCB(R3),R4 ;R4 = Offset to console ;TCB SUB @R3,R4 ;R4 = Diff from 1st TCB BEQ 1$ ;No difference, so ;LUN:0 = console... MOV S.STCB(R3),R5 ;R5 = Size of TCB CLR R1 ;R1 = Quotient DIV$: INC R1 ;Divide diff by size ;of a TCB SUB R5,R4 ;to get LUN of console BHI DIV$ ;Repeat until done... MOV R1,(PC)+ ;Save console LUN... CLUN: .WORD 0 ;for later reference 1$: CMP R2,CLUN ;Is this the Console? BEQ 4$ ;Yes...already set up .MTATCH #AREA,#0,R2 ;Try to attach terminal BCS MTERR1 ;If carry set, can't ! .MTGET #AREA,R3,R2 ;Get terminal's status BCS MTERR2 ;Can't! (Very Bad!!!) BITB #DZ11$/400,M.TSTW(R3) ;Is line a DZ11? BEQ 6$ ;No...assume a DL11 BITB #REMOT$/400,M.TSTW(R3) ;Remote line? BEQ 2$ ;Nope... BITB #HNGUP$/400,M.TSTW(R3) ;Is it online? BNE 5$ ;Branch if not 2$: CALL TSETUP ;Figure out baud rate ;and terminal type 3$: .MTRCTO #AREA,R2 ;Reset CTRL/O .MTPRNT #AREA,#HELLO,R2 ;Clear screen (if CRT) ;and say hello... CALL LOGLUN ;Log term ID on console 4$: DEC R2 ;Are we finished? BPL 1$ ;No...go do another LUN MTEXIT: .EXIT ;We're done...exit .SBTTL Terminal ID Log routines, error routines 5$: .PRINT #OFFLIN ;Log terminal offline CALL PRNLUN ;Include LUN... .PRINT #CRLF ;...and CRLF BR 4$ ;Merge... 6$: BIS #,@R3 ;DL11 - Set the ;special bits in TCB MOV #ENDTBL,R4 ;Don't know speed... CALL TERMID ;Try to figure out ;the terminal ID CALL RSET ;Set new status... BR 3$ ;Merge... LOGLUN: .PRINT #ATMSG ;Print 1st part of log CALL PRNLUN ;Print LUN... .PRINT R1 ;...then terminal ID... .PRINT #TINIT ;...and finally... .PRINT R4 ;....the baud rate RETURN PRNLUN: MOV R2,R0 ;Copy LUN into R0 SWAB R0 ;Put it in high byte 7$: ADD #<-10.*400>+1,R0 ;Divide by 10 with ;repeated subtracts BPL 7$ ;Q=Q-10, R=R+1 till ;overflow (V set) ADD #'0*400+'0+<10.*400-1>,R0 ;Correct ;Q & R then ASCIIfy... .TTYOUT ;Print Q... SWAB R0 ;R to low byte... .TTYOUT ;Print it... RETURN MTERR1: .PRINT #MSG1 ;Log attatch error BR 8$ ;Merge MTERR2: .PRINT #MSG2 ;Log get status error 8$: CALL PRNLUN ;Include LUN BR 4$ ;Try next LUN .SBTTL Main terminal setup subroutine TSETUP: MOV #SPTABL-2,R4 ;R4 => Baud rate table MOV @R3,MSTAT ;Save old status... BIS #,@R3 ;Set special bits 10$: TST (R4)+ ;R4 => Next table entry BIC #MSPEED,@R3 ;Clear baud rate mask MOV (R4)+,R5 ;R5 = Baud from table BIS R5,@R3 ;Set it in CONFG1 CMP #ENDTBL,R4 ;Are we thru table? BEQ 14$ ;Yes...use as is MOV #32,LOTIM ;Magic # in .MRKT arg SWAB R5 ;Put mask in low byte SUB R5,LOTIM ;Subtract from magic # ;to get # ticks to wait CALL TERMID ;Try to get terminal ID BCS 10$ ;No dice... RSET: BIC #,@R3 ;Clear special bits TST R2 ;Hardcopy console? ;*LCP* BEQ 12$ ;Yes...don't do this ;*LCP* BIC #NOCRLF,@R3 ;NOCRLF ;*LCP* BIS #,@R3 ;TAB SCOPE ;*LCP* 12$: MOV @R4,R4 ;R4 => ASCII baud rate 13$: .MTSET #AREA,R3,R2 ;Store status RETURN ;Return to caller 14$: CALL GETSP ;Get ASCII of baud rate BR 13$ ;Merge... TERMID: .MTSET #AREA,R3,R2 ;Set new status MOV #TTLIST,R5 ;R5 => List of Terminals 15$: MOV (R5)+,R1 ;R1 => Terminal specific ;character sequence BEQ 18$ ;End of table - leave ;with carry set! CALL TOUT ;Try to communicate... BCS 15$ ;Carry set = no dice ADD OUTCT,R1 ;R1 => ASCII terminal ID 16$: RETURN ;Return 18$: MOV #UNKTT,R1 ;R1 => "Unkown terminal" RETURN ;(with carry status) .SBTTL Terminal I/O & Get baud rate routines TOUT: MOVB (R1)+,OUTCT ;Get # char in "What- ;are-you?" sequence .MTOUT #AREA,R1,R2,OUTCT ;Send What-are-you? BCS 20$ ;Output error CLRB TFLG ;Clear flag .MRKT #AREA,#WAITM,#CRTNE,#1 ;Set time-out 19$: TSTB TFLG BEQ 19$ .MTIN #AREA,#MSGIN,R2,#1 ;Get response, 20$: RETURN ;(with carry status) GETSP: MOV #SPTABL,R4 ;R4 => baud rate table MOV @R3,R5 ;R5 = TCB config word 1 BIC #^C,R5 ;Clear all but baud rate 21$: CMP (R4)+,R5 ;compare it with table BEQ 22$ ;Branch if equal CMP #UNKSP,(R4)+ ;End of table? BNE 21$ ;Try another if not 22$: MOV @R4,R4 ;R4 => ASCII baud rate RETURN ;Return to caller .SBTTL Timeout Completion Routine CRTNE: INCB TFLG ;Set time-out flag RTS PC ;Return to mainline ; Argument blocks & working storage OUTCT: .WORD 0 ;Output byte count AREA: .BLKW 5 ;EMT Argument block WAITM: .WORD 0 ;Time-out argument LOTIM: .WORD 0 ; Lo order ticks STAT: .BLKW 8. ;Status block (8 words) .SBTTL Baud rate mask & ASCII baud rate tables ; Baud rate table - in "best guess" order SPTABL: .WORD 7000,B9600 ;9600 baud ;Scopes .WORD 3400,B1200 ;1200 baud ;LA120 .WORD 2400,B300 ;300 baud ;LA36 .WORD 6000,B4800 ;4800 baud ;Scopes .WORD 5000,B2400 ;2400 baud ;Scopes .WORD 2000,B150 ;150 baud ;LA36 .WORD 1400,B134 ;134.5 baud ;IBM MSTAT: .WORD 0 ;Orig status ENDTBL: .WORD UNKSP ;End-of-table ;=> "Unknown baud" TFLG: .BYTE 0 ;Time-out flag MSGIN: .BYTE 0 ;Response buffer .NLIST BEX B134: .ASCIZ /134.5 Baud/ B150: .ASCIZ /150 Baud/ B300: .ASCIZ /300 Baud/ B1200: .ASCIZ /1200 Baud/ B2400: .ASCIZ /2400 Baud/ B4800: .ASCIZ /4800 Baud/ B9600: .ASCIZ /9600 Baud/ .EVEN .SBTTL Terminal ID tables TTLIST: ;Terminal List... .WORD VT100 ;Address of terminal .WORD VT52 ;specific "What-are .WORD LA120 ;you?" sequence .WORD 0 ;Table Stopper ; DEC terminal command sequences VT100: .BYTE 3,ESC,'[,'c ;OUTCNT,"W-A-Y" seq .ASCII / VT100/<200> ;ASCII terminal ID .EVEN LA120: .BYTE 3,ESC,'[,'C .ASCII / LA120/<200> .EVEN VT52: .BYTE 2,ESC,'Z .ASCII / VT52 /<200> .SBTTL Message text & Initialization string ; Message text... MSG1: .ASCII /?Cannot attach terminal LUN:/ .ASCII <200> MSG2: .ASCII /?Status error - LUN:/<200> ATMSG: .ASCII /Attaching LUN:/<200> TINIT: .ASCII / initialized at /<200> UNKSP: .ASCIZ /unknown baud rate/ UNKTT: .ASCII / unidentifiable terminal/<200> OFFLIN: .ASCII /Terminal offline - LUN:/<200> CRLF: .ASCIZ // ; Clear screen & say hello character string... HELLO: .ASCII "[2J" ;VT100 Erase screen .ASCII "\" ;VT52 "Exit hold ; screen mode" .ASCII "H""J" ;VT52 Home + "Erase- ; to-End-of-Screen" .ASCII ;CRLF (for hardcopy) .ASCIZ /TERMINAL INITIALIZED/ .END MTYSET ;End of program