Google
 

Trailing-Edge - PDP-10 Archives - BB-4170H-SM - sources/ttdzdv.mac
There are 21 other files named ttdzdv.mac in the archive. Click here to see a list.
;<4.MONITOR>TTDZDV.MAC.180,  3-Jan-80 08:10:38, EDIT BY R.ACE
;UPDATE COPYRIGHT DATE
;<4.MONITOR>TTDZDV.MAC.179, 25-Oct-79 15:13:10, EDIT BY ZIMA
;TCO 4.2550 - INSTALL A TERMINAL SPEED ZERO FOR DZ11 LINES BY TURNING
; OFF THE RECEIVER CLOCK.  PRESERVES OUTPUT CHARACTERISTICS SINCE
; THE OUTPUT CANNOT BE TURNED OFF FOR A LINE.
;<4.MONITOR>TTDZDV.MAC.178, 12-Oct-79 09:35:34, Edit by KONEN
;CORRECT CODE SENDING XON WHILE THERE IS ROOM IN THE INPUT BUFFER
;<4.MONITOR>TTDZDV.MAC.177,  5-Oct-79 17:07:29, EDIT BY MURPHY
;MINXOS CHANGED TO MINXON
;<4.MONITOR>TTDZDV.MAC.176,  5-Oct-79 00:36:16, Edit by KONEN
;CALL GETEXA BEFORE DZXOCA
;<4.MONITOR>TTDZDV.MAC.175,  2-Oct-79 09:13:06, Edit by KONEN
;APPLY PARITY IF NEEDED TO XON/XOFF
;<4.MONITOR>TTDZDV.MAC.174, 28-Sep-79 14:03:03, Edit by KONEN
;ALLOW OUTPUT OF XON/XOF OF DZ'S WHEN OUTPUT BUFFER IS EMPTY
;<4.MONITOR>TTDZDV.MAC.173, 19-Sep-79 14:49:53, EDIT BY MURPHY
;CHANGE VECTOR OFFSET NAMES
;<OSMAN.MON>TTDZDV.MAC.1, 10-Sep-79 16:11:45, EDIT BY OSMAN
;TCO 4.2412 - Move definition of BUGHLTs, BUGCHKs, and BUGINFs to BUGS.MAC
;<4.MONITOR>TTDZDV.MAC.171, 24-Aug-79 13:38:11, EDIT BY WEISBACH
;TCO 4.2355 SEND XON OVER DZ LINES ONLY IF LINE  PREVIOUSLY X'D OFF.
;<4.MONITOR>TTDZDV.MAC.170, 11-Mar-79 13:12:43, EDIT BY KONEN
;UPDATE COPYRIGHT FOR RELEASE 4
;<4.MONITOR>TTDZDV.MAC.169, 15-Feb-79 19:06:01, Edit by MCLEAN
;SOTP EXTRANEOUS DZ OUTPUT INTERRUPT FROM HANGING
;<4.MONITOR>TTDZDV.MAC.168,  2-Feb-79 23:40:35, Edit by MCLEAN
;ADD VSFEXO FOR FRONT-END XOFF RECOGNITION	;ENABLE/DISABLE FRONT-END XOFF RECOGNITION

;<4.MONITOR>TTDZDV.MAC.167, 24-Jan-79 00:20:48, Edit by MCLEAN
;FIX XON/XOFF AND OUTPUT TO NON-EX LINE CRASHES
;<4.MONITOR>TTDZDV.MAC.166, 28-Dec-78 22:45:26, Edit by MCLEAN
;ADD VSTPLN	;STOP LINE

;<4.MONITOR>TTDZDV.MAC.165, 13-Dec-78 16:20:51, Edit by MCLEAN
;CORRECT NUMBER OF STOP BITS IN TABLE IT WAS BACKWARDS.
;<2MCLEAN>TTDZDV.MAC.164, 18-Oct-78 22:50:03, Edit by MCLEAN
;<2MCLEAN>TTDZDV.MAC.163, 18-Oct-78 11:46:55, Edit by MCLEAN
;<2MCLEAN>TTDZDV.MAC.162, 14-Oct-78 22:18:05, Edit by MCLEAN
;<2MCLEAN>TTDZDV.MAC.161, 14-Oct-78 22:14:57, Edit by MCLEAN
;<2MCLEAN>TTDZDV.MAC.160, 14-Oct-78 18:07:23, Edit by MCLEAN
;<2MCLEAN>TTDZDV.MAC.159, 13-Oct-78 16:10:51, Edit by MCLEAN
;<2MCLEAN>TTDZDV.MAC.158, 11-Oct-78 00:09:41, Edit by MCLEAN
;<2MCLEAN>TTDZDV.MAC.157, 10-Oct-78 23:52:42, Edit by MCLEAN
;<2MCLEAN>TTDZDV.MAC.156,  7-Oct-78 22:31:18, Edit by MCLEAN
;REMOVE OBFFR FOR SPEED
;<4.MONITOR>TTDZDV.MAC.155,  5-Oct-78 15:50:02, Edit by MCLEAN
;FIX CARNON SO PERM BIT IS CORRECTLY CHECKED

;THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY ONLY BE USED
;  OR COPIED IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE.
;
;COPYRIGHT (C) 1976,1977,1978,1979,1980 BY DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.

	SUBTTL DZ11 DEVICE DEPENDENT CODE FOR SM10


; DZ11 TTY SERVICE MODULE FOR SM10 CONFIGURATIONS

	EXTN <DZCHCT>		;SPECIAL "CLOCK" FOR PI CHECKS

;DEFINITIONS FOR TTDEV FOR DZ TYPE LINES


;DEFINITIONS FOR TT.DZ LINE TYPE
TT%DZI==1B0			;DZ INTERRUPT SERVICE FLAG
MSKSTR TTDZI,TTDEV,TT%DZI

	RESCD

SCDTMZ==^D50			;TIME FOR RING CHECKS
DZTMCK==^D5000/SCDTMZ		;WHEN TO DO PI CHECK
DZCRDL==^D8000			;TIME DELAY FOR CARRIER HANGUP

;VECTOR TABLE FOR DEVICE DEPENDENT ROUTINES

TTDZVT=.
	TTDDLN			;LENGTH OF DYNAMIC DATA FOR THIS TYPE
	-1			;FIRST LINE OF THIS TYPE/-1 NO LINES
	IFIW!DZINIT		;VITBLS -INITALIZATION	;INITIALIZE TABLES AT SYSTEM STARTUP

	IFIW!DZRSTR		;RESTART
	IFIW!TTCOB5		;CLEAR OUTPUT BUFFER
	IFIW!DZSSP2		;SET LINE SPEED
	IFIW!TTRSP1		;READ TTY SPEED
	IFIW!DZSNT1		;SET NON-TERM STATUS
	IFIW!DZRNT1		;READ NON-TERM STATUS
	IFIW!TTSTO3		;REMOVE CHAR FROM OUTPUT BUFFER
	IFIW!R			;STPAR JSYS
	IFIW!RSKP		;CHECK PHYSICAL LINE
	IFIW!TTXON2		;VXON -XON	;PROCESS XON FROM TERMINAL

	IFIW!TTYDE0		;DEASIGN DYNAMIC DATA
	TRO 1,200		;SET PARITY
	IFIW!STRTO1		;START OUTPUT LINE
	IFIW!DZSXOF		;XOFF
	IFIW!DZSXON		;XON
	IFIW!DZRING		;EMPTY BUFFER
	IFIW!DZ7CX2		;CARRIER ON
	IFIW!DZCX2		;CARRIER OFF
	IFIW!DZHU0		;HANGUP
	IFIW!R			;VXOFF -^S	;PROCESS XOFF FROM TERMINAL

	IFIW!TTC7S1		;NO LOGINS
	IFIW!DZBST		;STORE CHARACTER
	IFIW!DZSND1		;SEND CHARACTER
	IFIW!TTDAL7		;DEALLOCATE LINE
	IFIW!DLSSX2		;BUFFER OVERFLOW
	IFIW!R			;EMPTY BUFFER
	IFIW!DZSNSA		;VTTMSG - ALLOW TTMSG FOR SINGLE LINE	;DO TTMSG FOR ONE LINE?

	IFIW!R			;ENABLE/DISABLE DATASETS
	IFIW!DZCH7D		;PIA ETC CHECKS
	IFIW!R			;30  CLEAR INPUT BUFFER
	IFIW!R			;31  DOBE
	IFIW!R			;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!DZSNSN		;VSNDA1 - ALLOW TTMSG FOR SINGLE LINE	;SENDALL FOR ONE LINE

	IFIW!DZSNDL		;VSNDAL - ALLOW TTMSG FOR ALL LINES	;SENDALL FOR ALL LINES

	JFCL			;VAJWCL - ADJUST WAKEUP CLASS	;ADJUST WAKEUP CLASS

	IFIW!R			;VSTPLN - STOP LINE	;STOP LINE

	IFIW!R			;VSFEXO - ENABLE XOFF RECOGNITION	;ENABLE/DISABLE FRONT-END XOFF RECOGNITION


   IFN <.-TTVTMX>-TTDZVT,<PRINTX %% INVALID DEVICE DEPENDTNT TABLE SIZE>
;
; SEND CHARACTER TO LINE
; CURRENTLY ONLY CTY IN SECONDARY PROTOCOL IS IMPLEMENTED
;WARNING!!! SNEAKY BUT Q2 IS SET UP TO EXTERNAL PAGE ADDRESS OF
;DZ11 IFF TTDZI IS NON-ZERO!!!



DZSND1:	PUSH P,T2
	JN TTDZI,(T2),[	MOVEI T4,0(T3) ;IF DZ INTERRUPT THEN JUST OUTPUT CHARACTER
			SETZRO TTDZI,(T2)
			WRIOB T4,DZTBUF(Q2)
			POP P,T2
			RET]
	DYNST	
	CAME T2,KLILNO		;KLINIK?
	JRST NOTDZK		;NOT KLINIK
	JN KLIOVL,,[	POP P,T2	;BACKUP STILL BUSY
			JRST DZBKUP]
	JN TTXOC,(T2),DZXOC	;XON/OFF REQUESTED?
	STOR T3,KLIOCH		;STORE OUTPUT CHARACTER
	SETONE KLIOVL		;SET VALID
	JRST CTYCOM		;AND DO COMMON STUFF

NOTDZK:CAME T2,CTYLNO
	JRST [	SKIPE DZLNCT	;IF NO DZ LINES MUST RETURN
		SKIPN FEFLG	;SECONDARY PROTOCOL?
		JRST PB2	;NO -- RETURN IT IS NOT LEGAL NOW
		JRST DZPRNC]	;NOT CTY BUT PRIMARY PROTOCOL
	JN CTYOVL,,[	POP P,T2	;RESTORE T2
			JRST DZBKUP] ;AND BACKUP
	JN TTXOC,(T2),DZXOC	;XON/OFF REQUIRED?
	STOR T3,CTYOCH		;SET OUTPUT CHARACTER
	SETONE CTYOVL		;SET VALID CHARACTER AVAILABLE
CTYCOM:	CALL INTETY		;INTERRUPT 8080
	POP P,T2		;RESTORE
	SETONE TTOTP,(T2)	;SET LINE ACTIVE
	RET			;RETURN

DZPRNC:	SUB T2,DZLNOF		;SUBTRACT RESTRICTED LINES
	CAMLE T2,DZLNNO		;LEGAL?
	JRST PB2		;NO IGNORE
	POP P,T2		;RESTORE REGISTER
	MOVEI T4,0(T3)		;SAVE CHARACTER
	
	CALL GETEXL		;GET EXTERNAL PAGE INFO
	SETONE TTOTP,(T2)	;SET LINE ACTIVE
	BSIOB T1,DZTCR(T3)	;LINE NOT ENABLED DO IT AND WAIT FOR INTERRUPT
DZBKUP:	JN TTSAL,(T2),[	MOVNI T3,1	;BACK UP SENDALL
			LOAD T1,TSALP,(T2)
			ADJBP T3,T1	;BACKUP POINTER
			STOR T3,TSALP,(T2) ;RESTORE COUNTER
			INCR TSALC,(T2)	;UPDATE CHARACTER COUNT
			RET]		;RETURN
	MOVNI T3,1		;BACKUP BYTE POINTER
	ADJBP T3,TTOOUT(T2)
	MOVEM T3,TTOOUT(T2)	;RESTORE IT
	AOS TTOCT(T2)		;RESET COUNT
	RET



DZXOC:	JN TTFXF,(T2),DZPRXO	;DO XON
DZPRXF:	MOVEI T4,XOFFC		;GET XOFF CHARACTER
	SKIPA			;COMMON
DZPRXO:	MOVEI T4,XONC		;GET CHARACTER
	SKIPGE CHITAB(T4)	;PARITY NEEDED?
	TXO T4,200		;YES, APPLY IT
	SETZRO <TTXOC>,(T2)	;CLEAR FLAGS
	CAMN T2,KLILNO		;KLINIK?
	JRST [	STOR T4,KLIOCH	;YES STORE IN KLINIK BUFFER
		SETONE KLIOVL	;SET VALID CHARACTER
		JRST DZPRXA]
	STOR T4,CTYOCH		;STORE CHARACTER IN 8080 BUFFER
	SETONE CTYOVL		;SET VALID CHARACTER
DZPRXA:	CALL INTETY		;INTERRUPT 8080
	POP P,T2		;RESTORE T2
	SETONE TTOTP,(T2)	;SET LINE ACTIVE
	JRST DZBKUP		;AND BACKUP
;
DZXOCA:	JN TTFXO,(T2),DZDZXF	;XOFF?
DZDZXO:	MOVEI T4,XONC		;GET CHARACTER
	SKIPA			;COMMON ENTRY
DZDZXF:	MOVEI T4,XOFFC		;GET XOFF CHARACTER
	SKIPGE CHITAB(T4)	;PARITY NEEDED?
	TXO T4,200		;YES, APPLY IT
	SETZRO <TTXOC>,(T2)	;CLEAR FLAGS
	WRIOB T4,DZTBUF(T3)	;WRITE CHARACTER
	RET
; SET/CLEAR NON-TERMINAL STATUS
	SWAPCD

DZSNT1:	STOR T3,TTNTS,(T2)	;SET/CLEAR FLAG
	RET

; READ NON-TERMINAL STATUS

DZRNT1:	LOAD T3,TTNTS,(T2)	;RETURN STATUS
	RET
	RESCD

DZBST:	LOAD T3,TTFBB,(T2)	;GET COUNT
	AOS T3			;INCREASE COUNT OF CHARACTERS IN TTBBUF
	CAIL T3,MAXABC		;OVER RUN (IGNORE IT TOO MANY)
	RET			;YOU HAVE BEEN WARNED
	STOR T3,TTFBB,(T2)	;STORE COUNT
	CAIL T3,MAXBBC		;CHECK FOR MAX BEFORE SHUT OFF
	CALL SNDXOF		;SEND XOFF
	JRST BIGST1		;STORE CHARACTER


DZSXOF:	MOVEI T4,XOFFC		;GET XOFF CHARACTER
	SETONE <TTXOC,TTFXO>,(T2) ;SET XOFF
	SETZRO TTFXF,(T2)
	JRST DZXCM		;GO TO COMMON STUFF

DZSXON:	JE TTFXO,(T2),R		;XON ONLY IF REQUIRED
	PUSH P,T2		;SAVE LINE NUMBER
	CALL STADYN		;CONVERT TO DYNAMIC
	 JRST DZNXN		;FORGET IT
	LOAD T4,TIMAX,(2)	;CAPACITY OF INPUT BUFFERS
	SUBI T4,MINCT1		;LESS AMOUNT BEFORE FORCED WAKEUP
	CAMG T4,TTICT(2)	;BUFFER NOW THAT FULL?
	JRST PB2		;YES, WAIT
	DYNST			;BACK TO STATIC ADDRESS
	SETONE <TTXOC,TTFXF>,(T2)	;SET XON REQUIRED
	SETZRO TTFXO,(T2)	;CLEAR OLD SWITCH
DZNXN:	MOVEI T4,XONC		;GET XON CHARACTER
	POP P,T2		;RESTORE LINE NUMBER
DZXCM:	SKIPGE CHITAB(T4)	;PARITY NEEDED?
	TXO T4,200		;YES, APPLY IT
	CHNOFF DLSCHN		;SET CHANNEL OFF
	CAMN T2,KLILNO		;KLINIK?
	JRST [	JN KLIOVL,,DZCXR	;CHECK TO SEE IF READY
		STOR T4,KLIOCH	;STORE CHARACTER
		SETONE KLIOVL	;SET VALID
		JRST DZXCM1]
	CAME T2,CTYLNO		;CTY?
	JRST DZXDZ		;REAL DZ
	JN CTYOVL,,DZCXR	;CHECK TO SEE IF READY FOR A CHARACTER
	STOR T4,CTYOCH		;SET OUTPUT CHARACTER
	SETONE CTYOVL		;SET VALID
DZXCM1:	SETZRO TTXOC,(T2)	;CLEAR BOTH SINCE ALL IS DONE
	CALL INTETY		;INTERRUPT 8080
DZCXR:	CHNON DLSCHN		;TURN CHANNEL BACK ON
	RET			;AND RETURN

DZXDZ:	PUSH P,T2		;SAVE STATIC ADDRESS
	CALL STADYN		;FIND DYNAMIC STORAGE ADDRESS
	JRST DZDZX		;NOT SETUP YET FORGET IT
	JN TTDZI,(T2),DZDZX	;QUIT IF BUSY (IT WILL GET CLEARED)
	CALL GETEXL		;FIND EXTERNAL PAGE ADDRESS
	SETONE TTOTP,(T2)	;SET LINE ACTIVE
	BSIOB T1,DZTCR(T3)	;REQUEST INTERRUPT
DZDZX:	CHNON DLSCHN
	JRST PB2		;AND QUIT
;DZINIT -- ROUTINE TO INITALIZE DZ11
;DZRSTR -- SAME ROUTINE TO RESTART DZ11

DZINIT:	SAVEAC <Q1,Q2,P1>	;SAVE AN AC
	SETZM CTYINT		;SET ALIAS (FOR NOW IT IS 0) FOR CTY
	MOVE T4,SMTEPT+DZUBN	;FIND THE TRAP VECTORS
	ADDI T4,DZ110V/4	;OFFSET TO INTERRUPT VECTORS
	MOVEI Q2,DZMAX		;FIND THE MAX DZ11
	MOVE T2,[XPCW DZRDIB]	;SET INTERRUPT BLOCK
	MOVE T3,[XPCW DZXINB]	;OUTPUT INTERRUPT BLOCK
	SETZB Q1,P1		;SET POINTER TO CORRECT BLOCK
DZIVLP:	MOVEM T2,0(T4)		;MAKE AN ENTRY IN THE INTERRUPT VECTOR BLOCK
	MOVEM T3,1(T4)		;GET OUTPUT INTERRUPT VECTOR
	ADDI T3,4		;FOUR WORDS PER INTERRUPT BLOCK
	ADDI T4,2		;POINT TO NEXT INTERRUPT BLOCK
	MOVE T1,[MSEC1,,DZRDIN]	;SET UP THE INTERRUPT BLOCK
	MOVEM T1,DZRDIB+3	;SET UP VECTOR ADDRESS
	SETZM DZRDIB+2		;SET FLAGS TO 0
	MOVE T1,[MSEC1,,DZTXIN]	;SET UP OUTPUT INTERRUPT BLOCK
	ADD T1,Q1		;POINT TO CORRECT INTERRUPT INST
	MOVEM T1,DZXINB+3(P1)
	SETZM DZXINB+2+(P1)	;SET FLAGS TO 0
	ADDI Q1,3		;3 INSTRUCTIONS PER LINE
	ADDI P1,4		;4 WORDS PER BLOCK
	SOJN Q2,DZIVLP		;LOOP UNTIL DONE
	MOVE T1,CTYINT		;GET CTY LINE NUMBER
	AOS T1			;MAKE KLINIK CTY+1
	MOVEM T1,KLILNO		;SAVE KLINIK LINE NUMBER
	RET

; RESTART CODE ALSO RUN FOR INITILIZATION IT SETS UP THE INTERRUPT ENABLES

DZRSTR:	SAVEP			;SAVE THE P'S
	MOVSI P1,-DZMAX		;MAXIMUNM NUMBER OF DZ11'S TO HANDLE
	MOVE P2,[DZ11BA]	;GET BASE ADDRESS OF DZ11
DZINLP:	MOVE T1,P2		;ADDRESS OF DZ11
	CALL UBGOOD		;DOES IT EXIST ?
	 JRST DZNOUB		;NO
	MOVEI T1,DZCLR		;INIT THE DZ11
	WRIO T1,DZCSR(P2)	;RESET THE DZ
	MOVSI T2,1		;SET UP LOOP COUNT
DZCLRK:	SOJE T2,[BUG(DZCLRB)]
	TIOE T1,DZCSR(P2)	;WAIT FOR FINISH
	JRST DZCLRK
	MOVEI T1,DZRIEN+DZTIEN+DZMSCN ;SET INTERRUPT ENABLES AND SCANNER
	WRIO T1,DZCSR(P2)	;START DZ11
	ADDI P2,DZMNV		;ADD THE VECTOR SIZE
	AOBJN P1,DZINLP		;AND TRY THE NEXT ONE
DZNOUB:	HRRZM P1,DZLNCT		;SAVE NUMBER OF DZ11'S FOUND
	IMULI P1,10		;COUNT OF LINES
	HRRZM P1,DZLNNO
	MOVE T1,TTLINV+TT.DZ	;FIND THE OFFSET AND KEEP IT HANDY
	MOVE T1,TT1LIN(T1)
	ADDI T1,FELNS		;ADD IN PSEUDO LINES
	MOVEM T1,DZLNOF
	RET			;RETURN

; DZHU0 -- ROUTINE TO SCHEDULE A HANGUP

DZHU0:	SETZ T1,		;T1/ INDICATE DO IT IMMEDIATELY
	MOVE T3,[DZHU2]		;T3/ ROUTINE TO HANGUP THE LINE
	CALL TTQAD		;SCHEDULE HANGUP AS SOON AS POSSIBLE
	RET


; DZHU2 -- ROUTINE TO DO A HANGUP

DZHU2:	JE TTFEM,(T2),R		;RETURN IF NO DATASET
	SAVET			;SAVE TEMP'S
	CALL GETEXA		;GET EXTERNAL ADDRESS
	BCIOB T1,DZLPR(T3)	;CLEAR LINE ENABLE
	BCIOB T1,DZDTR(T3)	;CLEAR CARRIER
	RET			;RETURN

;DZ7CX2 -- CARRIER ON


;DZCX2 -- CARRIER OFF

DZ7CX2:	SKIPA T3,[TTCON1]	;CARRIER ON
DZCX2:	MOVE T3,[TTCOF]		;CARRIER OFF
	MOVEI T1,DZCRDL		;8 SEC
	CALL TTQAD
	JRST TTCH7


;DZCH7D -- PIA CHECK TO SEE IF INTERRUPTS ENABLES HAVE BEEN LOST

DZCH7D:	MOVEI T1,SCDTMZ		;TIME FOR NEXT CHECK
	MOVEM T1,TTYTIM		;TELL SCHEDULER
	SOSLE DZCHCT		;TIME FOR PI CHECK?
	JRST DZRING		;NO. DO RING POLL ONLY THEN
	MOVEI T1,DZTMCK		;YES. SET UP NEXT TIME CHECK
	MOVEM T1,DZCHCT		;AND SET UP "CLOCK"
	CHNOFF DLSCHN		;TURN OFF DLS CHANNEL
	MOVE T1,DZLNCT		;GET LINE COUNTS
	JUMPE T1,DZCH7E		;IF NO DZ'S THEN NO CHECK
	MOVE T2,[DZ11BA]	;GET BASE ADDRESS
	MOVEI T3,DZRIEN!DZTIEN!DZMSCN
DZCH7L:	TION T3,DZCSR(T2)	;CHECK FOR ENABLES
	JRST [	BUG(DZLINT,<<T2,D>>)
		MOVEI T4,377	;SET ALL LINES TO INTERRUPT ASSUMING LOST ONE
		WRIOB T4,DZTCR(T2)
		BSIO T3,DZCSR(T2) ;SET INTERRUPT ENABLES AGAIN
		JRST .+1]
	ADDI T2,DZMNV		;LOOK AT NEXT DEVICE
	SOJN T1,DZCH7L		;TRY NEXT ONE
DZCH7E:	CHNON DLSCHN		;TURN ON CHANNEL

;NOW CHECK FOR RING ON ANY OF THE LINES

DZRING:	MOVE T2,TTLINV+TT.DZ	;GET VECTOR FOR THIS LINE TYPE
	SKIPE DZLNCT		;IF NO DZ LINES FORGET IT
	SKIPGE T2,TT1LIN(T2)	;GET FIRST LINE NUMBER
	RET			;NONE THERE
	MOVN T4,DZLNNO		;FIND COUNT OF LINES
	HRL T2,T4		;GET - NUMBER OF LINES
	ADDI T2,FELNS		;UPDATE FOR CTY AND KLINIK
DZRNG0:	JE TTFEM,(T2),DZRNG7	;NOT A REMOTE LINE - NO PROCESSING NECESSARY
	PUSH P,T2		;SAVE ARGS
	CALL GETEXA		;GET EXTERNAL PAGE ADDRESS
	TIONB T1,DZRNG(T3)	;CHECK FOR RING
	JRST NORNG		;NOT RING
	JN TTCON,(T2),[	SETZRO TTCON,(T2) ;HANG UP IMMEDIATELY
			MOVE T3,[NTYCOF] ;HANGUP ROUTINE
			SETZ T1,0	;DO ASAP
			CALL TTQAD
			JRST DZRRTN] ;IMPLIES NEW CALL
	JN TROUT,(T2),DZRRTN	;IGNORE RING IF LINE HAS ROUTINE QUEUE'D (JOB DETACH)
	BSIOB T1,DZDTR(T3)	;SET CARRIER ON
	JRST DZRSCO		;INDICATE CARRIER SET ON

DZRRTN:	POP P,T2
DZRNG7:	AOBJN T2,DZRNG0		;DO THEM ALL
	RET			;AND DONE

NORNG:	TIONB T1,DZCAR(T3)	;CHECK FOR CARRIER ON
	JRST CARNON		;CARRIER NOT ON
	JN TTCON,(T2),DZRRTN	;CARRIER  EXPECTED TO BE ON
DZRSCO:	SETONE TTCON,(T2)
	MOVE T3,[TTCON1]	;SET CARRIER ON
	MOVEI T1,DZCRDL		;8 SEC
	CALL TTQAD		;SCHEDULE IT
	JRST DZRRTN		;AND QUIT

CARNON:	JE TTCON,(T2),DZRRTN	;CARRIER NOT EXPECTED TO BE ON
	CALL STADYN		;ACTIVE?
	JRST DZCAR1		;NOT ACTIVE AND QUIT BETTER KILL IT
	JN TTPRM,(T2),DZRRTN	;NOT PERM --WAIT
DZCAR1:	HRRZ 2,0(P)		;GET UNIT NUMBER BACK
	SETZRO TTCON,(T2)
	MOVE T3,[TTCOF]		;SET CARRIER OFF FLAG
	MOVEI T1,DZCRDL		;8 SEC
	CALL TTQAD		;SCHEDULE IT
	JRST DZRRTN		;AND QUIT
;READ INTERRUPT ROUTINE

DZRDIN: MOVEM P,DZSAVP		;SAVE A REGISTER
	MOVEI P,DZSVAC		;POINT TO AC SAVE AREA
	BLT P,DZSVAC+16		;SAVE AC'S
	MOVE P,DZPDL		;SET UP STACK
	MOVE Q1,DZLNCT		;FIND THE NUMBER OF LINES
	MOVE Q2,[DZ11BA]	;FIND FIRST EXTERNAL PAGE ADDRESS
	SKIPE FEFLG		;CHECK FOR PRIMARY PROTOCOL
	JRST DZINPP		;YES -- GO DUMP ALL DZ'S
DZCTRD:	RDIO T1,DZRBUF(Q2)	;READ A CHARACTER
	TRNE T1,DZRDVL		;VALID?
	JRST DZCTRD		;LOOP AND TRY FOR ANOTHER
DZNXCL:	SOJE Q1,DZRXIT		;CHECK TO SEE IF ALL DZS DONE
	ADDI Q2,DZMNV		;LOOK AT NEXT DZ TO DUMP ALL CHARACTERS
	MOVEI T1,DZRDVL		;IN THE BUFFERS TO STOP THEIR INTERRUPTING
	TIOE T1,DZRBUF(Q2)	;THIS WILL READ A CHARACTER AND DUMP IT
	JRST .-1		;THIS WILL CAUSE ALL CHARACTERS TO BE DUMPED
	JRST DZNXCL		;GO DO NEXT DZ

DZINPP:	MOVE P1,DZLNOF		;SET UP LINE NUMBER (MUST START AT 1
DZINPL:	RDIO T1,DZRBUF(Q2)	;GET A CHARACTER
	TRNN T1,DZRDVL		;VALID?
	JRST DZNXLN		;NO -- GO TO NEXT LINE
	TRNE T1,DZROVR		;OVER RUN
	BUG(DZOVER,<<T1,D>>)
	LOAD T2,DZTXLN,T1	;GET THE LINE NUMBER
	ADD T2,P1		;FIND ITS INTERNAL LINE NUMBER
	ANDI T1,377		;MASK TO CHARACTER ONLY
	CALL TTIDON		;GO PUT IN BUFFER
	JRST DZINPL		;GET ANOTHER CHARACTER

DZNXLN:	ADDI P1,10		;8 LINES PER DZ
	ADDI Q2,DZMNV		;LOOK AT NEXT DZ
	SOJN Q1,DZINPL		;CHECK TO SEE IF COUNT DONE
	JRST DZRXIT		;GO TO READ EXIT (DONE)


DZRXIT:	MOVSI P,DZSVAC		;RESTORE ACS
	BLT P,CX		;RESTORE
	MOVE P,DZSAVP		;RESTORE P
	XJEN DZRDIB		;RETURN
;INTERRUPT ROUTINE FOR THE CTY FOR THE KS10

DZCTIN::CLSB DLSCHN		;CLEAR CHANNEL INTERRUPT REQUEST
	MOVEM P,DZSAVP		;SAVE STACK REGISTER
	MOVEI P,DZSVAC		;POINT TO SC SAVE AREA
	BLT P,DZSVAC+16		;SAVE ACS
	MOVE P,DZPDL		;SET UP STACK
	JE KLIIVL,,DZNOKL	;CHECK FOR KLINIK INPUT
	LOAD T1,KLIICH		;GET THE CHARACTER
	MOVE T2,KLILNO		;GET LINE NUMBER
	SETZRO KLIIVL		;CLEAR VALID BIT
	CALL TTIDON		;OUTPUT CHARACTER
	CALL INTETY		;INTERRUPT EIGHTY EIGHTY
DZNOKL:	JN KLIOVL,,DZNXT	;OUTPUT VALID?
	MOVE T2,KLILNO		;YES GET LINE NUMBER
	CALL STADYN		;GET DYN ADDR
	JUMPLE T2,DZNXT		;TRY NEXT
	CALL TTSND		;DONE DO NEXT CHARCTER
DZNXT:	JE CTYIVL,,DZNOCT	;CHECK FOR CTY INPUT
	LOAD T1,CTYICH		;PICK UP THE CHACTER
	MOVE T2,CTYLNO		;GET THE CTY LINE NUMBER
	SETZRO CTYIVL		;CLEAR  CHARACTER IN BUFFER FLAG
	CALL TTIDON		;OUTPUT CHARACTER
	CALL INTETY		;INTERRUPT EIGHTY EIGHTY
DZNOCT:	JN CTYOVL,,DZNXIT	;NO CTY
	MOVE T2,CTYLNO		;GET LINE NUMBER
	CALL STADYN		;CONVERT TO DYNAMIC STORAGE
	JUMPLE T2,DZNXIT	;QUIT IF NO DYNAMIC STORAGE
	CALL TTSND		;DO DONE STUFF
DZNXIT:	MOVSI P,DZSVAC		;RESTORE
	BLT P,CX
	MOVE P,DZSAVP
	RET			;RETURN
DZPDL:	IOWD 40,DZISTK		;I/O STACK SIZE
RS (DZISTK,40)			;STACK FOR INTERRUPT SERVICE
RS (DZRDIB,4)			;INPUT INTERRUPT BLOCK
RS (DZXINB,4*^D8)		;INTERRUPT BLOCK FOR OUTPUT
RS (DZSVAC,17)			;SAVE AC FOR READ INTERRUPT
RS (DZSAVP,1)			;SAVE AC 17
RS (DZLNCT,1)			;COUNT OF DZ'S FOUND
RS (DZLNNO,1)			;COUNT OF LINES FOUND
RS (DZLNOF,1)			;OFFSET TO FIRST LINE NUMBER

; NOTE MUST HAVE ONE SET OF 3 INSTRUCTIONS PER DZ11!!!!!!
DZTXIN::DMOVEM P6,DZSVAC+P6	;SAVE REGISTERS
	SETZ P6,0		;POINTER TO WHICH LINE SET
	JRST DZCOMI		;GO TO COMMON INTERRUPT SERVICE
DZTXI1:	DMOVEM P6,DZSVAC+P6
	MOVEI P6,10		;SECOND BLOCK OF 10
	JRST DZCOMI
DZTXI2:	DMOVEM P6,DZSVAC+P6
	MOVEI P6,20
	JRST DZCOMI
DZTXI3:	DMOVEM P6,DZSVAC+P6
	MOVEI P6,30
	JRST DZCOMI
DZTXI4:	DMOVEM P6,DZSVAC+P6
	MOVEI P6,40
	JRST DZCOMI
DZTXI5:	DMOVEM P6,DZSVAC+P6
	MOVEI P6,50
	JRST DZCOMI
DZTXI6:	DMOVEM P6,DZSVAC+P6
	MOVEI P6,60
	JRST DZCOMI
DZTXI7:	DMOVEM P6,DZSVAC+P6
	MOVEI P6,70
;	JRST DZCOMI
;
DZCOMI:	MOVEM P,DZSAVP		;SAVE A REGISTER
	DMOVEM T1,DZSVAC+T1
	DMOVEM T3,DZSVAC+T3
	DMOVEM Q1,DZSVAC+Q1
	MOVE P,DZPDL		;SET UP STACK SIZE
	MOVE Q2,[DZ11BA]	;GET BASE ADDRESS
	ADD Q2,P6		;POINT TO CORRECT ADDRESS
	LSH P6,-1		;FIND RETURN ADDRESS
	DMOVE T1,DZXINB(P6)	;GET RETURN PS/PC
	DMOVEM T1,DZXINB	;STORE IN COMMON RETURN
	LSH P6,1		;GET ADDRESS BACK
	ADD P6,DZLNOF		;SET UP LINE COUNT
DZTNXO:	RDIO T2,DZCSR(Q2)	;READ THE STATUS
	TRNN T2,DZTRDY		;CHECK FOR TRANSMIT DONN
	JRST DZTXIT		;NOT THIS DZ TRY NEXT ONE
	LDB T2,[POINT 3,T2,27]	;PICK UP LINE NUMBER
	MOVNS T2		;GET CORRECT BIT POSITION
	MOVE Q1,BITS+^D35(T2)	;SAVE LINE NUMBER
	MOVNS T2		;BACK THE WAY IT WAS
	ADD T2,P6		;MAKE ABSOLUTE NUMBER
	JN <TTXOC>,(T2),[CALL GETEXA
			 CALL DZXOCA ;DO XON/XOF
			  JRST DZTNXO]
	SKIPN T2,TTACTL(T2)	;NET DYNAMIC STORANE
	JRST DXTNEX		;IF NO BLOCK THIS IS AN EXTRNAEOUS INTERRUPT
	SETONE TTDZI,(T2)	;SET INTERRUPT FLAG
	CALL TTSND		;DO TTY DONE
	SETZRO TTDZI,(T2)
	JN TTOTP,(T2),DZTNXO 	;DONE?
DXTNEX:	BCIOB Q1,DZTCR(Q2)  	;CLEAR THE ACTIVE BITS
	JRST DZTNXO		;TRY FOR ANOTHER
				;THIS WILL STOP INTERRUPTING DZ AND END OUTPUT

DZTXIT:	DMOVE T1,DZSVAC+T1
	DMOVE T3,DZSVAC+T3
	DMOVE Q1,DZSVAC+Q1
	DMOVE P6,DZSVAC+P6
	MOVE P,DZSAVP		;RESTORE AC
	XJEN DZXINB		;AND RETURN
; SENDALL
	SWAPCD

DZSNDL:	CAME T2,KLILNO
	CAMN T2,CTYINT		;CHECK FOR REAL CTY
	RET			;CAN'T DO THIS LINE
	PUSH P,T2
	SUB T2,DZLNOF		;FIND IF LINE A LEGAL DZ LINE
	CAML T2,DZLNNO		;LGAL? (DZ'S +CTY)
	JRST [	ADD T2,DZLNOF	;PUT LINE NUMBER BACK
		CAME T2,KLILNO	;CHECK FOR KLINIK
		CAMN T2,CTYLNO	;CHECK FOR CTY
		JRST .+1	;YUP ALL OK TO DO SENDALL
		JRST PB2]	;NOPE QUIT
DZCTOK:	POP P,T2		;RESTORE LINE NUMBER
	SKIPE FEFLG		;SECONDARY PROTOCOL?
	RETSKP			;YES RETURN OK
	SETO T2,0		;NO SKIP GROUP
	RETSKP


; SENDALL TO SPECIFIC LINE


;
DZSNSA:
DZSNSN:	CAME T2,KLILNO		;NOT KLINIK YET
	CAMN T2,CTYINT		;CHECK FOR CTY
	RET			;YES NOT THIS ONE
	SKIPL TTSPWD(T2)	;IF NO SPEED SET CAN'T DO SEND ALL
	SKIPN FEFLG		;CHECK FOR PRIMARY PROTOCOL
	RET			;NO SEND ALL LEGAL HERE
	PUSH P,T2		;SAVE REGISTER
	SUB T2,DZLNOF		;FIND BEGINNING OF LINES
	CAML T2,DZLNNO		;LGAL? (DZ'S + CTY)
	JRST [	ADD T2,DZLNOF	;PUT LINE NUMBER BACK
		CAME T2,KLILNO	;CHECK FOR KLINIK
		CAMN T2,CTYLNO	;CHECK FOR CTY
		JRST .+1	;YUP DO SENDALL
		JRST PB2]	;NO ON SENDALL
	POP P,T2		;YES
	RETSKP			;RETURN SEND ALL LEGAL

	RESCD
;
	SWAPCD
; SET SPEED FOR A DZ11 LINE
;

DZSSP2:	UMOVE T4,2		;GET FLAGS
	TXNE T4,MO%AUT		;REQUESTING AUTO?
	RETBAD			;YES. CAN'T HAVE IT ON THIS DEVICE
	SKIPN DZLNCT		;IF NO DZ LINES CAN'T SET SPEED
	RET
	UMOVE T4,T3		;GET THE SPEED
	HLRZ T1,T4		;CHECK TO SEE BOTH HALF THE SAME
	CAME T2,KLILNO		;NOT KLINIK LINE NUMBER EITHER
	CAMN T2,CTYINT		;CHECK FOR CTY
	RET			;NOT LEGAL ON THIS MACHINE
	CAME T2,CTYLNO		;CHECK TO SEE IF CTY <CAN'T SET THAT ONE)
	CAIE T1,0(T4)		;IF NOT SAME THEN FORGET IT HARDWARE
	RET			;SUPPORTS INPUT/OUTPUT SAME
	NOINT			;SET NOINT
	CHNOFF DLSCHN		;TURN OFF CHANNEL WHILE PLAYING WITH LINE SPEEDS
	JN TTFEM,(T2),DZSSP1	;IF REMOTE DON'T SET PERM SPEED
	XCTU [SKIPGE 2]		;REMOTE REQUESTED?
	JRST [	MOVX T3,SC%OPR!SC%WHL	;CHECK CAPBILITIES
		TDNN T3,CAPENB
		JRST DZSSP1		;NO CAPABILITIES FORGET IT
		SETONE TTFEM,(T2)	;SET ONCE ONLY FLAG
		JRST .+1]
	JUMPE T4,[EXCH T4,TTSPWD(T2) ;TREAT SPEED ZERO SPECIALLY, PRESERVE
		  JRST DZSSP1]	; OUTPUT CHARACTERISTICS, TURN OFF INPUT
	MOVEM T4,TTSPWD(T2)	;SAVE TTY SPEED
DZSSP1:	HRRZS T4		;SET SPEED IN RIGHT HALF ONLY
	MOVEI T1,DZSPTB		;FIND POINTER TO TABLE POINTER
DZSPLP:	MOVE T3,0(T1)		;GET A TABLE ENTRY
	JUMPE T3,NOLNSP		;NO LINE SPEED FOUND
	CAIE T4,0(T3)		;CORRECT ENTRY?
	AOJA T1,DZSPLP		;NO -- TRY NEXT ONE
	HLRZ T4,T3		;GET LINE SPEED
	MOVE T3,T2		;GET LINE NUMBER
	SUB T3,DZLNOF		;SUBTRACT FRONT-END LINES
	CAML T3,DZLNNO		;CHECK TO SEE IF LEGAL LINE NUMBER
	JRST NOLNSP		;NOPE -- QUIT WHILE AHEAD
	ANDI T3,7		;MASK TO 3 BITS
	IOR T4,T3		;SET UNIT NUMBER
	CALL GETEXA		;GET THE EXTERNAL PAGE ADDRESS OF THIS DZ
	SKIPN TTSPWD(T2)	;SETTING SPEED TO ZERO?
	TRZ T4,DZ1RXO		;YES, FOR DZ HARDWARE TURN OFF RX CLOCK
	WRIO T4,DZLPR(T3)	;SET THE LINE PARAMETER REGISTER
NOLNSP:	CHNON DLSCHN		;ENABLE CHANNEL
	OKINT			;ENABLE INTERRUPTS
	RET			;RETURN

DZSPTB:	DZ1RXO+DZ1OPA+DZ8BIT+DZ2STP+0,,^D50
	DZ1RXO+DZ1OPA+DZ8BIT+DZ2STP+400,,^D75
	DZ1RXO+DZ1OPA+DZ8BIT+DZ2STP+1000,,^D110
	DZ1RXO+DZ1OPA+DZ8BIT+DZ1STP+1400,,^D134
	DZ1RXO+DZ1OPA+DZ8BIT+DZ1STP+2000,,^D150
	DZ1RXO+DZ1OPA+DZ8BIT+DZ1STP+2400,,^D300
	DZ1RXO+DZ1OPA+DZ8BIT+DZ1STP+3000,,^D600
	DZ1RXO+DZ1OPA+DZ8BIT+DZ1STP+3400,,^D1200
	DZ1RXO+DZ1OPA+DZ8BIT+DZ1STP+4000,,^D1800
	DZ1RXO+DZ1OPA+DZ8BIT+DZ1STP+4400,,^D2000
	DZ1RXO+DZ1OPA+DZ8BIT+DZ1STP+5000,,^D2400
	DZ1RXO+DZ1OPA+DZ8BIT+DZ1STP+5400,,^D3600
	DZ1RXO+DZ1OPA+DZ8BIT+DZ1STP+6000,,^D4800
	DZ1RXO+DZ1OPA+DZ8BIT+DZ1STP+6400,,^D7200
	DZ1RXO+DZ1OPA+DZ8BIT+DZ1STP+7000,,^D9600
	0,,0			;END OF TABLE
	RESCD
;GETEXA -- SUBROUTINE TO FIND THE EXTERNAL PAGE ADDRESS OF 
; THE SPECIFIED DZ11

; CALLING SEQUENCE:
; T2 -- LINE NUMBER
;
;	CALL GETLIN
; T1 -- LINE BIT POSITION (LINE 0=1B35 ETC)
; T3 -- EXTERNAL PAGE ADDRESS OF FIRST REGISTER FOR THIS DZ11
; RETURNS +1 ALWAYS

GETEXA:	PUSH P,T2		;SAVE LINE NUMBER
GETEX1:	SUB T2,DZLNOF		;BACKUP TO POINT TO REAL  NUMBER
	MOVE 3,2		;GET LINE NUMBER
	ANDI T3,777770		;MASK OF LOW ORDER 3 BITS (8 PER DZ)
	ADD T3,[DZ11BA]		;ADD DZ11 BASE ADDRESS
	MOVE T1,T2
	ANDI T1,7		;MASK OFF UNIT
	MOVNS T1
	MOVE T1,BITS+^D35(T1)
	POP P,T2		;RESTORE
	RET

;
;  GETEXL -- SUBROUTINE TO FIND EXTERNAL PAGE AND LINE NUMBER
;
;	CALLING SEQUENCE:
;	B -- DYNAMIC STORAGE ADDRESS
;	CALL GETEXL
;	RETURNS:
;	A -- LINE BIT POSITION (LINE 0=1B35 1,1B34 ETC)
;	C -- EXTERNAL PAGE ADDRESS OF THIS DZ11
;

GETEXL:	PUSH P,T2		;SAVE DYNAMIC ADDRESS
	DYNST			;GET LINE NUMBER
	CALLRET GETEX1		;GET EXTERNAL PAGE ADDRESS