Google
 

Trailing-Edge - PDP-10 Archives - BB-R598A-RM_1983 - swskit-v3/nvt/nvttmp.mac
There is 1 other file named nvttmp.mac in the archive. Click here to see a list.
;<V-SOURCES>NVTTMP.MAC.3, 22-Aug-78 18:08:48, EDIT BY OPERATOR
	SEARCH MONSYM,MACSYM
	TITLE NVTTMP
	SALL
	.REQUIRE SYS:MACREL
	MAXFRK==4

	T1==1
	T2==2
	T3==3
	T4==4
	CX==16
	P==17
SAVAC:	BLOCK 4
DEVNAM:	BLOCK 2			;FOR BUILDING PTY NAMES
PTYJFN:	BLOCK 1			;THE JFN OF THE PTY
TTYJFN:	BLOCK 1			;TTY DESIGNATOR
SRVJFN:	BLOCK 1			;THE JFN OF THE NETWORK CONNECTION
SRVSIZ==10			;SIZE OF SERVER BUFFER
SRVINP:	BLOCK SRVSIZ		;HOLDS INPUT CHARACTERS
SRVOSZ==24			;OUTPUT BUFFER SIZE
MAXOUT==SRVOSZ*5
OUTPUT:	BLOCK 1			;OUTPUT BUFFER POINTER
OUCNT:	BLOCK 1
PC:	BLOCK 1			;THE PC
SRVOUP:	BLOCK SRVOSZ		;HOLDS OUPTUT DATA
FORKS:	BLOCK MAXFRK		;SAVE FORK I.D.S HERE
NPDL==40			;SIZE OF PDL
PDL:	BLOCK NPDL		;ALLOCATE THE STACK

	RELOC 1000-140		;START ON PAGE

LEVTAB:	PC			;WHERE TO STASH THE PC
CHNTAB:	1,,GOTCI		;WHEN GET CONNECT
	1,,GOTDAT		;GOT DATA

BEGIN:	RESET			;CLEAN UP THE WORLD
	MOVE T1,[SIXBIT /NVTTMP/]
	SETNM			;SET OUR NAME
	HRROI T1,[ASCIZ /SRV/]	;SEE IF NET EXISTS
	STDEV			;BY CHECKING FOR SRV DEVICE
	 JRST [	SETOM T1	;DOESN'T EXIST
		LGOUT		;SO GO AWAY
		 JFCL
		HALTF]		;EITHER WAY, GO AWAY
	MOVSI T4,-MAXFRK	;MAX FORKS TO CREATE
FRKDO:	SETZB T1,T2		;GET A CLEAN FORK
	CFORK			;CREATE A FORK
	 ERJMP WTFRK		;IF NO MORE, DONE
	MOVEM T1,FORKS(T4)	;SAVE FORK HANDLE
	HRLZ T2,T1		;FORK HANDLE
	HRRI T2,1		;START AT PAGE 1
	MOVE T1,[.FHSLF,,1]	;MAP THIS FORK TO IT
	MOVEI T3,ENDPRG-1	;LAST ADDRESS IN USE
	LSH T3,-11		;MAKE A PAGE ADDRESS
	TLO T3,540000		;MAKE PMAP ARG
	PMAP			;DO MAP
	HLRZ T1,T2		;GET FORK HANDLE
	MOVEI T2,START		;START ADDRESS
	SFORK			;START IT UP
FRKLOP:	AOBJN T4,FRKDO		;DO ALL OF THEM
WTFRK:	MOVEI T1,.FHINF		;WAIT FOR ANY
	WFORK			;""
	; ..


;ONE OR MORE FORKS DIED. FIND THEM AND RESTART THEM

	MOVSI T4,-MAXFRK	;SCAN FORK TABLE
DEDLOP:	SKIPN T1,FORKS(T4)	;THIS ONE EXIST?
	JRST DEDLO1		;NO. GO ON
	RFSTS			;YES. GET ITS STATUS
	LOAD T1,RF%STS,T1	;GET ITS STATUS
	CAIE T1,.RFHLT		;HALTED?
	CAIN T1,.RFFPT		;OR ERROR?
	JRST [	MOVE T1,FORKS(T4) ;YES. GET HANDLE AGAIN
		SETZM FORKS(T4)	;CLEAR ENTRY
		KFORK		;ZAP THE FORK
		HRRZS T4	;CREATE ONE MORE FORK
		JRST FRKDO]	;DO IT
DEDLO1:	AOBJN T4,DEDLOP		;LOOK AT THEM ALL
	JRST WTFRK		;WAIT SOME MORE
	; ..


;START FOR PROCESSING FORKS

START:	CIS			;CLEAR INTS
	SKIPN T1,SRVJFN		;HAVE A SERVER?
	JRST START1		;NO. GO AWAY
	TXO T1,CZ%ABT		;ABORT IT
	CLOSF			;DO IT
	 JFCL
	SETZM SRVJFN		;CLEAN IT UP
START1:	SKIPN T1,PTYJFN		;HAVE A PTY?
	JRST START2		;NO
	TXO T1,CZ%ABT		;YES. ZAP IT
	CLOSF
	 JFCL
START2:	MOVE P,[IOWD NPDL,PDL]	;INIT STACK
	MOVEI T1,.FHSLF		;THIS FORK
	MOVE T2,[LEVTAB,,CHNTAB]
	SIR			;DEFINE INT SYSTEM
	MOVX T2,3B1
	AIC			;TURN ON CHANNELS
	EIR			;TURN ON SYSTEM
	MOVE T1,[POINT 7,SRVOUP] ;INITIAL OUTPUT POINTER
	MOVEM T1,OUTPUT		;INIT THE POINTER
	MOVEI T1,MAXOUT
	MOVEM T1,OUCNT
	MOVX T1,GJ%SHT		;SHORT FORM GTJFN
	HRROI T2,[ASCIZ /SRV:.HOST/] ;THE SERVER NAME
	GTJFN			;GET IT
	 JRST TRYAGN		;FAILED. GO RECOVER
	MOVEM T1,SRVJFN		;SAVE THE SERVER JFN
	MOVE T2,[070000,,300000]
	OPENF			;OPEN IT
	 JRST [	MOVE T1,SRVJFN	;FAILED
		RLJFN		;GET RID OF JFN
		 JFCL
		SETZM SRVJFN
		JRST TRYAGN]	;AND RECOVER
	MOVEI T2,.MOACN
	MOVE T3,[000777,,001000]
	MTOPR

	WAIT			;WAIT HERE FOR SOMETHING TO HAPPEN

;GTJFN OR OPENF OF SRV: FAILED.

TRYAGN:	MOVX T1,^D<1000*60*2>	;WAIT 2 MINS
	DISMS			;""
	JRST START		;AND TRY AGAIN


;GOT A CONNECTION

GOTCI:	CALL GETPTY		;GET A PTY
	JRST START		;COULDN'T
	MOVEM T1,PTYJFN		;STORE PTY
	MOVEM T2,TTYJFN		;SAVE TTY DESIGNATOR
	MOVEI T2,"C"-100	;START UP JOB
	BOUT			;""
	MOVE T1,SRVJFN		;GET SERVER
	MOVEI T2,.MOCC		;CONFIRM CONNECTION
	SETZB T3,T4		;NO OPTDATA
	MTOPR			;DO IT
	ERJMP START		;IF LINK BROKEN, START AGAIN
	MOVEI T1,PTYIN		;GO DO PTY INPUT
	MOVEM T1,PC
	GJINF			;SEE IF JOB ATTACHED
	JUMPL T4,DONCI		;IF NOT, GO ON
	HRROI T1,[ASCIZ /
NVTTMP- CONNECTION FROM /]
	PSOUT
	MOVE T1,SRVJFN		;GET SERVER JFN
	MOVEI T2,.MORHN		;GET HOST NAME
	HRROI T3,100000		;WHERE TO PUT IT
	MTOPR			;READ HOST NAME
	ERJMP .+1
	HRROI T1,100000
	PSOUT			;DUMP OUT NAME
	HRROI T1,[ASCIZ / ON /]
	PSOUT
	MOVEI T1,.PRIOU
	MOVE T2,PTYJFN
	SETZM T3
	JFNS			;SAY WHERE
	HRROI T1,[ASCIZ /
/]
	PSOUT
DONCI:	DEBRK			;GO DO PTY INPUT

;RECEIVED A DATA INTERRUPT

GOTDAT:	DMOVEM T1,SAVAC
	DMOVEM T3,SAVAC+2
GOTDA1:	MOVE T1,SRVJFN		;GET THE JFN
	MOVEI T2,.MORLS		;READ THE LINK'S STATUS
	MTOPR			;DO IT
	TXNN T3,MO%CON		;STILL CONNECTED?
	JRST START		;COULDN'T
	SIBE			;FIND OUT HOW MUCH INPUT WE HAVE
	 SKIPA			;HAVE SOME
	JRST [	DMOVE T1,SAVAC
		DMOVE T3,SAVAC+2
		DEBRK]		;GO BACK
	CAILE T2,SRVSIZ*5	;CAN HOLD IT ALL?
	MOVEI T2,SRVSIZ*5	;NO. GET MAX
	MOVN T3,T2		;GET COUNT
	MOVE T4,T3		;SAVE IT
	HRROI T2,SRVINP		;WHERE IT IS GOING
	SIN			;READ IT
	ERJMP START		;IF LINK BROKEN, START AGAIN
	SUB T4,T3		;GET BYTES READ
	MOVE T3,T4
	MOVE T1,PTYJFN
	HRROI T2,SRVINP
	SOUT			;WRITE DATA TO PTY
	JRST GOTDA1		;AND DO MORE


;MAIN INPUT LOOP FOR PTY

PTYIN:	MOVE T1,PTYJFN		;GET PTY JFN
	BIN			;WAIT FOR A BYTE
	IDPB T2,OUTPUT		;SAVE POINTER
	SOSG OUCNT		;MORE ROOM?
	JRST PTYIN1		;NO. WRITE IT THEN
	MOVE T1,TTYJFN		;LOOK AT TTY BUFFER
	SOBE			;ANY MORE CHARACTERS?
	 JRST PTYIN		;YEP. GO GET 'EM
PTYIN1:	MOVNI T3,MAXOUT		;MAX OUTPUT COUNT
	ADD T3,OUCNT		;COMPUTE BYTES IN BUFFER
	MOVE T1,SRVJFN
	HRROI T2,SRVOUP		;THE OUTPUT BUFFER
	SOUTR			;SEND DATA
	ERJMP START		;IF LINK DIED, START OVER
	MOVE T1,[POINT 7,SRVOUP]
	MOVEM T1,OUTPUT		;REINIT POINTER
	MOVEI T2,MAXOUT		;MAX OUTPUT COUNT
	MOVEM T2,OUCNT
	JRST PTYIN


;GET A PTY. RETURNS A JFN THAT INDICATES AN OPENED PTY

GETPTY:	STKVAR <SAVCHR>
	MOVE T1,[SIXBIT /PTYPAR/]
	SYSGT			;GET PTY INFO
	HRRZM T1,SAVCHR		;SAVE FIRST PTY NUMBER
	HLRZ T4,T1		;GET NUMBER OF PTY'S
	MOVNS T4		;GET NEG OF COUNT
	HRLZS T4		;MAKE AN AOBJN POINTER
GETPT1:	MOVSI T1,600000+.DVPTY	;GET DESIGNATOR FOR PTY
	HRR T1,T4		;GET PTY NUMBER
	DVCHR			;GET CHARACTERISTICS
	TXNN T2,1B5		;AVAILABLE?
	JRST GETPT2		;NO. DO ALL OF THEM THEN
	MOVE T2,T1		;GET DESIGNATOR
	HRROI T1,DEVNAM		;WHERE TO BUILD STRING
	DEVST			;GET NAME
	 JRST GETPT2		;?
	MOVEI T2,":"		;GET TERMINATOR
	IDPB T2,T1
	SETZM T2
	IDPB T2,T1		;TIE OFF STRING
	MOVX T1,GJ%SHT		;SHORT FROM GTJFN
	HRROI T2,DEVNAM		;THE NAME
	GTJFN			;GET IT
	 JRST GETPT2		;FAILED
	MOVE T3,T1		;SAVE JFN
	MOVE T2,[070000,,300000]
	OPENF			;OPEN IT
	 JRST [	MOVE T1,T3	;FAILED
		RLJFN		;GET RID OF PTY JFN
		 JFCL
		JRST GETPT2]	;AND PROCEED
	MOVEI T2,400000(T4)	;GET PTY INDEX
	ADD T2,SAVCHR		;GET PTY DESIGNATOR
	RETSKP			;AND DONE

;COULDN'T GET THIS ONE

GETPT2:	AOBJN T4,GETPT1		;SEE IF MORE TO DO
	RET			;NO. GIVE UP THEN
	LIT			;ASSEMBLE LITERALS
ENDPRG:				;END OF CODE
	END BEGIN