Google
 

Trailing-Edge - PDP-10 Archives - SRI_NIC_PERM_SRC_3_19910112 - mit/monitor/ttchdv.mac
There are no other files named ttchdv.mac in the archive.
;<BERLIN.M5>TTCHDV.MAC.4, 20-Sep-82 13:20:07, Edit by BERLIN
;1027 Fix for send all to CVT (KDO)
;<BERLIN.M5>TTCHDV.MAC.3, 23-Aug-82 17:48:15, Edit by BERLIN
;1015 Learn how to count
;REL5:<BBN-4-MONITOR>TTCHDV.MAC.9 27-Jan-82 09:45:51, Edit by RBASCH
;FIX UP CHATC2 TO HANDLE CHANGED TTSND IN REL-5
;<RBASCH>TTCHDV.MAC.3,  5-Jan-82 15:29:34, Edit by TAPPAN
; Some rel-5 changes, changed .CHFLG to CHAOS
;<RBASCH>TTCHDV.MAC.2  5-Jan-82 10:30:12, Edit by RBASCH
;REMOVED VECTOR TABLE, ADDED IFN .CHFLG, CHANGED IFNDEF TTNTVT
;TO IFE .NTFLG FOR REL-5
;[BBNF]<BBN-4-MONITOR>TTCHDV.MAC.2, 30-Dec-81 17:49:20, Ed: RBASCH
;ADD ENDAV. AFTER ACVAR'S FOR REL-5 COMPATIBILITY
;<TAPPAN.4>TTCHDV.MAC.2, 25-Aug-81 11:24:24, Edit by TAPPAN
; Comment out some VTS stuff

  IFN CHAOS,<		;** THIS MODULE ONLY IF WANTED **
IF1 <PRINTX IN TTCHDV PASS 1>
IF2 <PRINTX IN TTCHDV PASS 2>
	SUBTTL	Chaos NVT (CVT) code

EXTN <CHAFLG,CTMSTM,CVTCLZ,CHNGTM,ASGPK1,RELPKM,SNDPK1> 
EXTN <CHPKIA,CHAQGF,CHATTW,CHPMXT,CHAVSO>

DEFINE RCALL (RTN,R) <		;;;USED FOR DEBUGGING: CALL ROUTINE WITH 'REASON'
	MOVX CX,R
	CALL RTN
>

;CVT VECTOR TABLE ENTRYS

	RESCD

REPEAT 0,<			;NOT USED IN RELEASE 5
TTCHVT=.
	CVTLEN			;LENGTH OF DYNAMIC DATA FOR THIS TYPE
	-1			;FIRST LINE OF THIS TYPE/-1 NO LINES
	IFIW!CHTINI		;TTVT00 - INITALIZATION
	IFIW!R			;RESTART
	IFIW!NVTCOB		;CLEAR OUTPUT BUFFER
	IFIW!R			;SET LINE SPEED
	IFIW!TTRSP2		;READ TTY SPEED
	IFIW!TTSNT2		;SET NON-TERM STATUS
	IFIW!TTRNT1		;READ NON-TERM STATUS
	IFIW!TTSTO5		;REMOVE CHAR FROM OUTPUT BUFFER
	IFIW!NVTPAR		;STPAR JSYS
	IFIW!R			;CHECK PHYSICAL LINE
	IFIW!TTXON2		;TTVT10 - XON
	IFIW!CVTDET		;DEASIGN DYNAMIC DATA
	ANDI T1,177		;TTY OUTPUT PARITY OFF
	IFIW!CHTCSO		;START OUTPUT LINE
	IFIW!R			;XOFF
	IFIW!R			;XON
	IFIW!TTCQ1		;EMPTY BUFFER
	IFIW!R			;CARRIER ON
	IFIW!NTYCOF		;CARRIER OFF
	IFIW!NVTDTS		;HANGUP
	IFIW!R			;TTVT20 - ^S
	IFIW!TTC7SN		;NO LOGINS
	IFIW!R			;STORE CHARACTER
	IFIW!R			;SEND CHARACTER
	IFIW!TTDAL6		;DEALLOCATE LINE
	IFIW!DLSSX2		;BUFFER OVERFLOW
	IFIW!R			;EMPTY BUFFER
	IFIW!RSKP		;TTVT27 - SENDALL TO SINGLE LINE
	IFIW!R			;ENABLE/DISABLE DATASETS
	IFIW!R			;INIT
	IFIW!R			;30  CLEAR INPUT BUFFER
	IFIW!NVTDOB		;31  DOBE
	IFIW!CVTCAP		;32  INPUT GA
	IFIW!TTSET1		;33  SET INIT. VALUES FOR A LINE
	IFIW!TTSBE1		;34  SOBE
	IFIW!TTOBE1		;35  WAKEUP IF OUTPUT BUFFER EMPTY
	IFIW!TTMSCH		;TTVT36 - SENDALL TO SINGLE LINE
	IFIW!TTMSCH		;TTVT37 - SENDALL TO ALL LINES
	JFCL			;TTVT38 - ADJUST WAKEUP CLASS
	IFIW!R			;TTVT39 - STOP LINE
	IFIW!R			;TTVT40 - XOFF RECOGNITION
;	IFIW!TTNOAC		;TTVT41 - NO ACCTING
;	IFIW!R			;TTVT42 - OR LINE USAGE LOGGING


   IFN <.-TTVTMX>-TTCHVT,<PRINTX %%INVALID DEVICE DEPENDENT TABLE SIZE>
>				;END REPEAT 0
   IFE .NTFLG,<PRINTX ?Chaos NVTs require TTNTDV to be included>

; Dynamic data def

DEFSTR PTCON,TTNETW,35,18	;CHAOSNET CONNECTION FOR NVT
CVTLEN==NVTLEN			; Block is same length as ARPA NVT

; Paramaters
NEGTM0==^D30000			; Negotiation time-out for NVTs
; SYSTEM INITIALIZATION
CHTINI:	SETOM CHATTW
	RET

;CVTCHK - SEE IF THIS LINE NUMBER IS A CVT AND GET ADDRESS OF DYNAMIC
; DATA IF IT IS

;ACCEPTS:
;	T2/ INTERNAL LINE NUMBER

;	CALL CVTCHK

;RETURNS +1: NOT A CHAOS NVT OR NO DYNAMIC DATA
;		TTY DATA BASE NOT LOCKED
;	 +2: A CHAOS NVT
;		T2/ ADDRESS OF DYNAMIC DATA
;		AND TTY DATA BASE LOCKED

	RESCD

CVTCHK::CAIL T2,NLINES		;LEGAL TERMINAL NUMBER
	RETBAD			;NO. FAILURE
	ACVAR <W1>		;GET AN AC TO WORK WITH
	LOAD W1,TTSTY,(T2)	;GET LINE TYPE FOR THIS LINE
	CAIE W1,TT.CVT		;IS IT A CHAOS NVT?
	RETBAD			;NO. FAILURE
	CALL LCKTTY		;GET ADDRESS OF DYNAMIC DATA AND LOCK
	 JRST [CALL ULKTTY	;LINE NOT INITIALIZED UNLOCK
		RETBAD]		;AND RETURN
	RETSKP			;RETURN SUCCESS

	ENDAV.			;END ACVAR

;CHKCVT - SEE IF THIS LINE NUMBER IS A CHAOS NVT

;ACCEPTS:
;	T2/ INTERNAL LINE NUMBER

;	CALL CHKCVT

;RETURNS +1: IF NOT NVT
;	 +2: IF NVT

	RESCD

CHKCVT::ACVAR <W1>		;GET AN AC TO WORK WITH
	LOAD W1,TTSTY,(T2)	;GET LINE TYPE FOR THIS LINE
	CAIE W1,TT.CVT		;IS IT A NVT?
	RETBAD			;NO. FAILURE
	RETSKP			;RETURN SUCCESS

	ENDAV.			;END ACVAR
TTMSCH:	PUSH P,T2		;SAVE LINE NUMBER
	CALL LCKTTY		;GET DYNAMIC DATA ADDRESS IF IT EXIST
	JRST TTMSC1		;NO DYNAMIC DATA DO NOT SEND
	SKIPG TTNETW(T2)	;ANY CONNECTIONS?
	JRST TTMSC1		;NO DO NOT SEND MESSAGE
	CALL ULKTTY		;YES UNLOCK TTY DATABASE
	MOVX T1,CH%TTY		;INDICATE OUTPUT FOR NVTS
	IORM T1,CHAFLG
	MOVE T2,MSCT		;GET COUNT OF CHARACTERS IN MESSAGE
	IMULI T2,TMSNTT		;MULTIPLY BY ALLOWABLE TIME PER CHAR.
	MOVEI T2,^D5000		; A REASONABLE TIMEOUT
	ADD T2,TODCLK		;GET TIME MESSAGE TO BE DISCARDED
	MOVEM T2,CTMSTM		;SAVE TIME FOR NCPFORK
	POP P,T2		;RESTORE T2
	RETSKP			;SEND MESSAGE

TTMSC1:	CALL ULKTTY		;UNLOCK TTY
	POP P,T2		;RESTORE T2
	RETBAD			;NO DO NOT SEND MESSAGE

; TMSCHR - Clear all Chaos NVT SNDALL requests
TMSCHR::MOVE T3,CVTPTR		; Get AOBJN ctr for CVTs
	JRST TMSNR1		; Join regular NVT code

; CVTDWN - Clear up all Chaos NVTs
CVTDWN::MOVE T1,CVTPTR		; Get AOBJN ctr
	JRST NVTDW1		; Join regular NVT code
	
; ASNCVT - Assign a Chaos NVT

;ACCEPTS:
;	Q1/ Flags,,connection number

;	CALL ASNCVT

;RETURNS +1: FAILURE
;	 +2: SUCESS
;		T1/ LINE NUMBER
;		T2/ ADDRESS OF DYNAMIC DATA AND DATA BASE LOCKED

ASNCVT::STKVAR<CVLIN>
	HRRZ T1,CVTPTR		;GET FIRST CVT LINE NUMBER
	SETZ T3,		;START WITH FIRST CVT
	NOSKED
ASNCV1:	MOVE T2,T1		;GET FIRST CVT OFFSET
	ADD T2,T3		;ADD CURRENT CVT
	MOVEM T2,CVLIN		;SAVE LINE NUMBER
	CALL STADYN		;IS IT INITIALIZED
	 JUMPE T2,ASNCV4	;NO. NO DYNAMIC DATA
	SKIPG TTNETW(T2)	;FREE?
	JRST ASNCV3		;YES.
ASNCV2:	CAIGE T3,NTTCVT-1	;1015 LOOKED AT ALL CVT'S?  (starts with 0!!!)
	AOJA T3,ASNCV1		;NO
	OKSKED			;YES,
	RETBAD			;RETURN BAD

ASNCV3:	LOAD T2,TCJOB,(T2)	;GET JOB FOR WHICH THIS IS A CNTRL TTY.
	CAIE T2,-1		;IS THERE ONE
	JRST ASNCV2		;YES. TTY ALREADY ATTACHED?
ASNCV4:	MOVE T2,CVLIN		;GET LINE NUMBER BACK
	CALL TTYASC		;ASSIGN CVT
	 JRST ASNCV6		;COULD NOT ASSIGN IT
	MOVE T2,CVLIN		;GET LINE NUMBER
	CALL LCKTTY		;AND LOCK DATA BASE
	 JRST ASNCV5		;CANNOT LOCK DATA BASE. SHOULD'NT HAPPEN
	SETONE TCJOB,(T2)	;INDICATE NO CONTROLLING JOB FOR TERM.
	SETONE TTPRM,(T2)	;MAKE DATA PERMANENT UNTIL CVT CLOSED
	SETZM TTNETW(T2)	;CLEAR TTNETW EXCEPT FOR TYPE

;99 Begin modification
	TXNN Q1,AN%SUP		; SUPDUP specified?
	 SKIPA T3,[.TYNNV]	; No, NEW TELNET NVT BIT
	 MOVX T3,.TYSUP		; Yes
	STOR T3,NVTYP,(T2)
;99 End modification

	SETZM NVTOPF(T2)	;CLEAR OPTION STATUS
	OKSKED
	STOR Q1,PTCON,(T2)	;REMEMBER CONNECTION
	SETONE TT%DUM,TTFLGS(T2) ;SET DUPLEX MODE
	MOVEI T1,.TTNVT		;21 Set to be NVT type terminal
	STOR T1,TTTYP,(T2)
	MOVE T1,CVLIN		;RETURN LINE NUMBER
	RETSKP

ASNCV5:	CALL ULKTTY		;UNLOCK DATA BASE
ASNCV6:	HRRZ T1,CVTPTR		;GET FIRST CVT
	MOVE T3,CVLIN		;SET UP TO TRY NEXT LINE
	SUB T3,T1		;GET CVT NUMBER IN 3
	JRST ASNCV2		;AND TRY NEXT CVT
;CVTDET - CLOSE A FULL DUPLEX NET TTY CONNECTION
;
;ACCEPTS:
;	T2/ LINE NUMBER
;	CALL CVTDET
;
;RETURNS +1: FAILURE
;		T1/  1B0 + ADDRESS OF ROUTINE IF NEED TO DISMISS
;		T1/  ERROR CODE IF FAILED
;	 +2: SUCCESS

	RESCD

CVTDET:: POP P,0(P)		; RETURN TO CALLER'S CALLER
DETCVT::
	SE1CAL			;ENTER SECTION 1
	SAVEQ			;SAVE Q1,Q2,Q3
	MOVE T1,T2		;SAVE LINE NUMBER
	CALL CVTCHK		;IS IT AN NVT
	 RETSKP			;NOT ASSIGNED RETURN
	SKIPG TTNETW(T2)	;REASONABLE UNITS?
	JRST CVTDT1		;NO GO CLEAN IT UP
	LOAD Q1,PTCON,(T2)	;GET CONNECTION
	PUSH P,T2		;SAVE DYNAMIC DATA
	CALL CVTCLZ		;CLOSE IT NETWORKILY
	POP P,T2	
CVTDT1:	SETZM TTNETW(T2)	;ZERO OUT UNITS
	CALLRET VTDET		;JOIN GENERAL NVT CODE
;CVTCAP - CALLED FROM TCI ON INPUT WAIT

;ACCEPTS:
;	T2/ DYNAMIC DATA ADDRESS

;	FNCALL OFF TTVT32

;RETURNS: +1: ALWAYS
;	T2/ DYNAMIC DATA ADDRESS


CVTCAP:	SKIPG TTNETW(T2)	;STILL CONNECTED?
	RET			;NO
	PUSH P,Q1		;SAVE Q1
	PUSH P,T2		;AND T2.  MUST BE RETURNED
	NOINT			;PROTECT ANY POSSIBLE ILOCKS
	CALL CKNNVT		;NEW NVT PROTOCOL?
	 JRST CVTCA1		;99 SUPDUP, don't send GA
	 JRST CVTCA1		;NO.  SKIP SENDING GA
	CALL NVTXGA		;SEND GA IF NEEDED
CVTCA1:	OKINT
	POP P,T2		;RESTORE T2
	POP P,Q1		;AND Q1
	RET
;CHTCSO - START OUTPUT TO A LINE CALLED FROM STRTOU

;	FNJRST OF TTVT13

;RETURNS +2: ALWAYS

CHTCSO:	MOVX T1,CH%TTY		;INDICATE WORK FOR BACKGROUND FORK TO DO
	IORM T1,CHAFLG
REPEAT 0,<			;+++ WELL, THIS WORKS, BUT IT'S TOO SLOW
	PUSH P,Q1		;SAVE CONN
	LOAD Q1,PTCON,(T2)	;PICK UP CONN FROM DYNAMIC DATA
	PUSH P,T2		;SAVE DYNAMIC DATA (JUST IN CASE)
	CALL CHAVSO		;CALL CHAOS CODE TO START THIS GUY UP
	POP P,T2		;GET BACK DYNAMIC DATA REF
	POP P,Q1
>;REPEAT 0,
	RETSKP
; CHECK OVERDUE NEGOTIATIONS IF IT'S TIME (CALLED FROM CHAOS BACKGROUND FORK)

CHANEG::MOVE T1,TODCLK		;GET NOW
	CAMG T1,CHNGTM		;IS OUR TIME RIPE?
	 RET			;NOPE, GET OUT
	ADD T1,[NEGTM0]		;ADD TIME OUT QUANITY
	MOVEM T1,CHNGTM		;SAVE TIME FOR NEXT CHECK
	MOVE T2,CVTPTR
	CALL NEGCH1		;JOIN NVT CODE
	RET
;CHATCS - MOVE TTY OUTPUT TO NET BUFFERS

;ACCEPTS:
;	T2/ ADDRESS OF DYNAMIC DATA

;RETURN +1: ALWAYS


CHATCS::MOVEI T3,(1B<RCTOPT+WILOPT>)
	TDNE T3,NVTOPF(T2)
	CALL CKNNVT
	 JRST CHATC8		;99 NO RCTE (SUPDUP)
	 JRST CHATC8		;NO RCTE
	LOAD T3,PBRCT,(T2)	;LOAD BREAK COUNT
	SKIPE T3		;NEED TO SEND RESET?
	 CALL NVTRRR		;YES, TRY TO SEND
CHATC8:	SKIPG TTNETW(T2)	;STILL CONNECTED?
	 JRST TTCOBN		;NO, JUST CLEAR BUFFER
	LOAD Q1,PTCON,(T2)	;GET CONNECTION INDEX
	HRRZ FX,CHASTA(Q1)	;GET CONNECTION STATUS
	CAIE FX,.CSOPN		;STILL OPENED?
	 JRST TTCOBN		;NO, FORGET OUTPUT
;1027	MOVE T1,TTOCT(T2)	;GET NUMBER OF BYTES TO BE SENT OUT
;1027	CAMLE T1,CHPMXT
	 MOVE T1,CHPMXT		;NO MORE THAN THIS AT A TIME THOUGH
	ADDI T1,3		;CONVERT TO WORDS, ROUNDING UP
	LSH T1,-2
	PUSH P,T1
	MOVEI Q2,.CODAT		;DATA PACKET
	PUSH P,T2		;SAVE POINTER TO DYNAMIC AREA
	SKIPG CHANOS(Q1)	;ROOM WITHIN CURRENT WINDOW SIZE FOR ANOTHER PACKET?
	 JRST CHATC9		;NO
	RCALL ASGPK1,63		;CAN ALLOCATE A PACKET NOW?
CHATC9:	 JRST [POP P,T2		;+++NO, FORGET IT (SHOULDN'T WE REMEMBER WE DIDN'T)?
	       POP P,T1
	       RET]
	MOVEI Q2,CHPKDT(FX)
	HRLI Q2,441000		;MAKE BYTE POINTER TO DATA PORTION OF PACKET
	POP P,T2		;GET BACK DYNAMIC AREA
	POP P,P1		;NO MORE THAN THIS AT A TIME THOUGH
	LSH P1,2
	SETZ T4,		;INIT CHAR COUNT
	SETONE TTOTP,(T2)	;INDICATE OUTPUT ACTIVE
CHATC2:	SOJL P1,CHATC4		;COUNT DOWN LIMIT
	PUSH P,T4		;SAVE T4
	NOSKD1
	CALL TTSND		;GET A CHARACTER FROM OUTPUT BUFFER
	 IFNSK.
		OKSKD1		;DIDN'T GET ANY
		POP P,T4
		JRST CHATC5
	 ENDIF.
	OKSKD1
	POP P,T4		;RESTORE T4
	IDPB T1,Q2		;YES. PUT CHAR IN OUR PACKET
	AOJA T4,CHATC2

CHATC4:	SETZRO TTOTP,(T2)	;CLEAR OUTPUT ACTIVE BIT
CHATC5:	JUMPE T4,[RCALL RELPKM,1 ;DONE IF NO OUTPUT GENERATED
		RET]
	STOR T4,CPKNB,(FX)	;PACKET BYTE COUNT
	PUSH P,T2		;SAVE DYNAMIC AREA
	SETO T1,
	CALL SNDPK1		;QUEUE IT TO BE SENT OFF, BUT DON'T BLOCK
	POP P,T2		;GET BACK POINTER TO DYNAMIC AREA
;1027	SKIPE TTOCT(T2)		;SEE IF ANY MORE OUTPUT TO BE GENERATED
	CALL TTSOBE		;1027 Use canonical check
	 JRST CHATC8	
	RET
;CVTUPI - UNPACK MESSAGE INTO TTY BUFFERS

;ACCEPTS
;	T2/ NVT index
;	Q1/ CONNECTION POINTER
; 
; Note!!  We assume we're called from TTCH7 scheduler level, so we
; don't need to worry about locking the tty data bases.

CVTUPI::STKVAR<CVUPDD,CVUPKT,CVUFLS>
	SETZM CVUFLS		;NOT FLUSHING ANYTHING
	CALL STADYN		;TURN T2 INTO DYNAMIC DATA ADDRESS
	 IFNSK.
		BUG(CHVTNA)	;NOT FULLY ACTIVE, COMPLAIN
		SETOM CVUFLS	; AND JUST FLUSH ANY INPUT DATA
	 ENDIF.
	MOVEM T2,CVUPDD		;SAVE DYNAMIC DATA ADDRESS (POSS INVALID)
CVTUPP:	HLRZ FX,CHAIBF(Q1)	;GET NEXT INPUT PACKET
	JUMPE FX,R		;NO MORE
	CALL CHPKIA		;HANDLE ACKNOWLEDGEMENT IF DATA PACKET
	MOVEI Q2,CHAIBF(Q1)
	CALL CHAQGF		;REMOVE PACKET FROM QUEUE
	SOS CHANBF(Q1)		;ONE LESS ON QUEUE
	MOVEM FX,CVUPKT		;SAVE PACKET
	SKIPN CVUFLS		;FLUSHING INPUT?
	 SKIPL (FX)		; OR NON-DATA PACKET?
	 JRST CVTUPR		;YES, JUST FLUSH IT
	LOAD Q2,CPKNB,(FX)	;GET BYTE COUNT OF PACKET
	MOVEI FX,CHPKDT(FX)
	HRLI FX,441000		;BYTE POINTER TO DATA
CVTUPL:	SOJL Q2,CVTUPR		;COUNT CHARS LEFT IN PKT
	ILDB T1,FX		;GET CHARACTER
	MOVE T2,CVUPDD		;GET ADDRESS OF DYNAMIC DATA
	LOAD T3,NVSTP,(T2)	;GET THE CURRENT COMMAND STATE OF THIS
	SETZRO NVSTP,(T2)	;ZERO CURRENT STATE
	PUSH P,FX		;SAVE BYTE POINTER
	PUSH P,Q2		;AND BYTE COUNT
	CALL @NVTSTD(T3)	;DISPATCH ON IT
	POP P,Q2		;GET BACK BYTE COUNT
	POP P,FX		;AND BYTE POINTER
	JRST CVTUPL		;DO NEXT CHARACTER

CVTUPR:	MOVE FX,CVUPKT		;GET BACK PACKET
	RCALL RELPKM,2		;DONE WITH THIS PACKET
	MOVE T2,CVUPDD		;POINT TO DYNAMIC AREA AGAIN
	JRST CVTUPP		;GO SEE IF MORE TO COME
>				;END IFN .CHFLG AT TOP