.TITLE GRPORT - GET REMOTE PORT NUMBER .IDENT /1.8/ .ENABL LC ;+ ; ; Free software BY ; Project Software & Development, Inc. ; ; This software is furnished for free and may be used and copied as ; desired. This software or any other copies thereof may be provided ; or otherwise made available to any other person. No title to and ; ownership of the software is hereby transferred or allowed. ; ; The information in this software is subject to change without notice ; and should not be construed as a commitment by PROJECT SOFTWARE ; AND DEVELOPMENT, INC. ; ; PROJECT SOFTWARE assumes no responsibility for the use or reliability ; of this software on any equipment whatsoever. ; ; Project Software & Development, Inc. ; 14 Story St. ; Cambridge, Ma. 02138 ; 617-661-1444 ; ; ; Title: GRPORT ; Author: Gary N. Larsen ; Date: April 1, 1982 ; ; Description: ; ; This module prompts the user for the remote port and then tries to ; attach . If the attach is successful it then checks to make sure they ; specified a terminal. ; ; Modification History: ; ; Version 1.8 November 15, 1982 by Gary Larsen ; Donot allow attach to a logged in terminal. ;- .ENABL AMA .MCALL ASTX$S, ALUN$S, DIR$, GLUN$, MRKT$S, QIOW$S .MCALL UCBDF$ UCBDF$ ; Local Equates BELL = 7 ; BELL CR = 13. ; CARRIAGE RETURN LF = 10. ; LINE FEED ; ASCII messages. .NLIST BEX ALLMSG: .ASCII "%RSXNET-W-DEVALLOC, device already allocated to" .ASCIZ " another user" PORTQ: .ASCII %Enter the port being used for the remote (% PORTD: .BLKB 8. PORTH: .ASCIZ %REMOTE_PORT% .EVEN TTBUF:: .BLKB 8. ; TERMINAL NAME BUFFER TTNUM:: .WORD 5 ; TERMINAL UNIT NUMBER GRBUF:: .BLKW 6 ; BUFFER FOR GET REMOTE LUN GRLUN:: GLUN$ REMOTE,GRBUF ; DPB FOR GET LUN INFORMATION ATTFLG:: .WORD 0 ; REMOTE ATTACH FLAG <> 0 = ATTACHED .SBTTL GRPORT - GET THE REMOTE PORT ;+ ; ; GRPORT - Get the remote port. ; ; Description: ; ; This routine prompts the user for the port to communicate with ; the remote. If none is specified the default of TT5 is used. The device ; is then attached and a check is done to be sure it is a terminal. ; ; All registers are preserved. ; ;- GRPORT:: CALL $SAVAL ; SAVE THE REGISTERS 5$: TSTB TTBUF ; DO WE ALREADY HAVE A DEFAULT ? BNE 10$ ; IF NE, YES MOV #"TT,TTBUF ; SETUP THE MOV #5,TTNUM ; DEFAULT PORT ALUN$S #REMOTE,#"RM,#0 ; SEE IF THE LOGICAL RM0: EXISTS BCS 10$ ; IF CS, NO DIR$ #GRLUN ; ELSE GET THE LUN INFORMATION MOV GRBUF+G.LUNA,TTBUF ; COPY THE DEVICE NAME MOVB GRBUF+G.LUNU,TTNUM ; AND THE UNIT NUMBER 10$: MOV #PORTD,R0 ; DEFAULT PORT BUFFER ADDRESS MOVB TTBUF,(R0)+ ; MOVE IN THE DEFAULT MOVB TTBUF+1,(R0)+ ; DEVICE TYPE MOV TTNUM,R1 ; MOVE THE UNIT NUMBER TO BE CONVERTED CLR R2 ; SET UP ZERO SUPPRESSION CALL $CBOMG ; CONVERT IT MOVB #':,(R0)+ ; SET UP THE REST MOVB #'),(R0)+ ; OF THE OUTPUT BUFFER MOVB #' ,(R0)+ ; CLRB (R0) ; AND TERMINATE WITH A NULL CALL GETINI ; GET COMMAND FROM .INI FILE BCC 40$ ; IF CC, GOT A LINE 20$: CALL CLOINI ; CLOSE THE .INI FILE (IF OPEN) MOV #INCMD,R1 ; ADDRESS OF USER INPUT BUFFER MOV #PORTQ,R2 ; REMOTE PORT MOV #PORTH,HLPADR ; ADDRESS OF HELP MESSAGE CALL PROMPT ; AND ASK THEM TST BCKFLG ; NEED TO BACKUP BNE 100$ ; IF NE, YES (RETURN) ; See if remote port is already attached. TSTB ATTFLG ; REMOTE PORT ALREADY ATTACHED ? BEQ 40$ ; IF EQ, NO (TRY TO ASSIGN LUN) DIR$ #KILREM ; KILL ANY I/O ON REMOTE LUN TSTB REMCHA ; REMOTE CHARACTERISTICS CHANGED ? BEQ 30$ ; IF EQ, NO (SKIP RESET) DIR$ #RESREM ; RESET THE CHARACTERISTICS ; CALL CHKRIO ; CHECK FOR ERRORS CLR REMCHA ; SET THE FLAG FALSE 30$: DIR$ #DETREM ; NOW DETACH THE TERMINAL CLR ATTFLG ; REMOTE PORT NO LONGER ATTACHED ; Get the port from the incoming command 40$: MOV #INCMD,R3 ; ADDRESS OF REMOTE PORT TSTB (R3) ; ACCEPT THE DEFAULT ? BEQ 60$ ; IF EQ, YES 50$: MOVB (R3)+,TTBUF ; COPY THE TERMINAL NAME MOVB (R3)+,TTBUF+1 ; AND THE SECOND BYTE CLR R1 ; INITIALIZE UNIT NUMBER CMPB (R3),#': ; IS THERE A UNIT NUMBER ? BEQ 60$ ; IF EQ, NO (DEFAULT TO 0) MOV R3,R0 ; COPY THE BUFFER ADDRESS CALL $COTB ; CONVERT OCTAL TO BINARY MOV R1,TTNUM ; SAVE THE UNIT NUMBER 60$: ALUN$S #REMOTE,TTBUF,TTNUM ; ASSIGN A LUN TO IT BCC 80$ ; IF CC, OK 70$: CALL CHKDIR ; ELSE REPORT THE ERROR BR 20$ ; GET THE PORT AGAIN ; Make sure they specified a terminal 80$: DIR$ #GRLUN ; GET LUN INFORMATION BCS 70$ ; IF CS, ERROR BIT #FD.TTY,GRBUF+G.LUCW ; IS THIS A TERMINAL ? BEQ 20$ ; IF EQ, NO (TRY AGAIN) BIT #U2.LOG,GRBUF+G.LUCW+2 ; IS THIS TERMINAL LOGGED ON ? BNE 90$ ; IF NE, NO MOV #ALLMSG,R4 ; SET THE MESSAGE ADDRESS CALL WRITE ; AND GO WRITE IT BR 20$ ; PROMPT FOR ANOTHER ONE ; Store the terminal name. 90$: MOV #TTBUF+2,R0 ; STORE TERMINAL NAME HERE MOV TTNUM,R1 ; NUMBER TO BE CONVERTED CLR R2 ; SET UP ZERO SUPPRESSION CALL $CBOMG ; CONVERT IT MOVB #':,(R0)+ ; SET UP THE REST CLRB (R0) ; TERMINATE WITH NULL ; Try to attach the remote terminal. CALL REMATT ; DO THE REMOTE ATTACH BCS 20$ ; IF CS, WE FAILED ; Now get the remote characteristics and setup new ones. DIR$ #GETREM ; GET CURRENT CHARACTERISTICS ; CALL CHKRIO ; CHECK FOR ERRORS DIR$ #SETREM ; SETUP NEW CHARACTERISTICS ; CALL CHKRIO ; CHECK FOR ERRORS MOV #-1,REMCHA ; SHOW THEY WERE CHANGED DIR$ #DETREM ; DETACH THE REMOTE TERMINAL DIR$ #ASTREM ; REATTACH WITH UNSOL/AST'S CALL CHKRIO ; CHECK FOR ERRORS 100$: RETURN .SBTTL REMATT - DO THE REMOTE ATTACH ;+ ; ; REMATT - Do the remote attach QIO. ; ; This routine attempts to attach the remote port and if unsuccessful, ; writes an error message to the user and returns. The attach is timed ; out so we don't hang forever if someone else is using the remote port. ; ; Outputs: ; C bit clear/set = success/failure. ; ; All registers are preserved. ; ;- REMATT:: CALL $SAVAL ; SAVE ALL REGISTERS CLR ATTFLG ; PRESUME ATTACH FAILURE MRKT$S ,#1,#2,#TIMOUT ; TIMEOUT THE REMOTE ATTACH DIR$ #ATTREM ; ATTACH THE REMOTE TERMINAL CALL CHKRIO ; CHECK FOR ERRORS CMPB RIOSB,#IE.ABO ; WAS THE ATTACH KILLED ? BEQ 20$ ; IF EQ, YES MOV #-1,ATTFLG ; SHOW REMOTE ATTACHED CLC ; SHOW SUCCESS BR 30$ ; AND RETURN ... 20$: SEC ; SHOW ATTACH FAILED 30$: RETURN ;+ ; ; This routine is entered when the marktime issued before the remote ; terminal attach expires. If we havn't attached the terminal yet, ; then we tell the user and exit to the system. Otherwise we simply ; return and let the program continue. ; ;- TIMOUT: TST ATTFLG ; REMOTE ATTACH DONE ? BNE 10$ ; IF NE, YES DIR$ #KILREM ; KILL THE REMOTE ATTACH MOV #ALLMSG,R4 ; SET THE MESSAGE ADDRESS CALL WRITE ; AND GO WRITE IT 10$: TST (SP)+ ; ELSE, CLEAN THE STACK ASTX$S ; AND EXIT THE AST .END