/
/COPYRIGHT (C) 1976
/DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.
/
/THIS SOFTWARE IS FURNISHED UNDER A LICENSE FOR USE ONLY
/ON A SINGLE COMPUTER SYSTEM AND MAY BE COPIED ONLY WITH
/THE INCLUSION OF THE ABOVE COPYRIGHT NOTICE.  THIS
/SOFTWARE, OR ANY OTHER COPIES THEREOF, MAY NOT BE PRO-
/VIDED OR OTHERWISE MADE AVAILABLE TO ANY OTHER PERSON
/EXCEPT FOR USE ON SUCH SYSTEM AND TO ONE WHO AGREES TO
/THESE LICENSE TERMS.  TITLE TO AND OWNERSHIP OF THE
/SOFTWARE SHALL AT ALL TIMES REMAIN IN DEC.
/
/THE INFORMATION IN THIS DOCUMENT IS SUBJECT TO CHANGE
/WITHOUT NOTICE AND SHOULD NOT BE CONSTRUED AS A COM-
/MITMENT BY DIGITAL EQUIPMENT CORPORATION.
/
/DEC ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY
/OF ITS SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY DEC.
	.EJECT
/
/ MACRO TO DEFINE OFFSETS INTO THE USER CONTEXT AREA.
/
	.DEFIN UCAOFF
U.JSW=0				/OFFSET TO JOB STATUS WORD.
U.MAEV=1			/OFFSET TO EVENT VARIABLE
U.MAMTE=2			/OFFSET TO MARK TIME EVENT VARIABLE.
U.OEV=3				/OFFSET TO OVERLAY EVENT VARIABLE.
U.DSK=4				/OFFSET TO DISK NAME
U.DUN=5				/OFFSET TO DISK UNIT NUMBER
U.UFD=6				/OFFSET TO UFD NAME.
U.CTSK=7			/OFFSET TO CURRENT TASK NAME
U.PSC=11			/OFFSET TO PARTITION SELECTION CRITERIA.
U.ULOF=14			/OFFSET TO USER NUMBER AND LUN OFFSET.
U.TTYN=15			/OFFSET TO USER TERMINAL NUMBER.
U.TB=16				/OFFSET TO USER TERMINAL BUFFER.
U.CPB=62			/OFFSET TO MULTI-ACCESS CPB.
U.OVID=76			/OVERLAY IDENTIFIER (LAST OVERLAY CALLED)
U.CKS=77			/CHECKSUM OF INPUT BUFFER FOR TIMED READ.
U.LEN=100			/LENGTH OF UCA.
	.DEFIN UCAOFF
	.ENDM
	.ENDM
	.EJECT
/
/ EDIT #2	M. HEBENSTREIT		MAR. 17, 1976
/
/ THIS FILE IS AN OVERLAY TO THE XVM/RSX TDV DISPATCHER TASK.
/ IT IS RESPONCIBLE FOR INITIALIZING VARIOUS PIECES OF DATA
/ WHICH MUST BE SET UP FOR THE OPERATION OF MULTIACCESS.
/ THIS OVERLAY IS ONLY CALLED WHEN TDV HAS BEEN REQUESTED
/ AND IS NOT YET INITIALIZED (I.E. ONLY IF TDV HAS JUST STARTED).
/
/ 003	18-MAR-76 (RCHM)	CLEAN UP SEVERAL MINOR NITS.	/(003)
/				1. NO .GLOBL FOR SUBROUTINE	/(003)
/				   ENTRY POINT.			/(003)
/				2. UCA WORDS SHOULD BE BASED ON	/(003)
/				   THE MIN(UCA#,TTYS).		/(003)
/				3. ONE TOO MANY BITS ARE BEING	/(003)
/				    GENERATED IN THE AND/XOR	/(003)
/				   MASK WHICH CONVERTS RT.LBM	/(003)
/				   INTO MA.LBM.			/(003)
/				4. GENERATE RT.LBM PROPERLY.	/(003)
/ 004	22-MAR-76 (RCHM)	TWO NEW ASSEMBLY PARAMETERS ARE	/(004)
/				ADDED. ONE ("PPS") AFFECTS THE	/(004)
/				NUMBER OF TIMES/SEC THE POLLRE	/(004)
/				WAKES UP. THE OTHER ("TMO") IS	/(004)
/				THE NUMBER OF SECONDS BETWEEN	/(004)
/				CHARACTERS BEFORE TIMEOUT.	/(004)
/ 005	22-MAR-76 (RCHM)	SET UP TO INITIALIZE CONTROL	/(005)
/				TABLE AND STATUS WORDS IN MULTI-/(005)
/				ACCESS CONTROL AND STATUS TABLE./(005)
/ 006	26-MAR-76 (RCHM)	SET UP INITIALIZATION OF THE	/(006)
/				DYNAMIC STORAGE REGION.		/(006)
/ 007	95-APR-76 (RCHM)	FIX MISCELLANEOUS BUGS IN THE	/(007)
/				TDV INITIALIZATION PROCESSOR.	/(007)
/ 008	22-APR-76 (RCHM)	FIX REASSIGN DISABLE PROBLEM	/(008)
/ 009	28-APR-76 (RCHM)	FIX UCA MINIMUM CALCULATION	/(009)
/ 010	14-JUL-76 (RCHM)	MAKE SURE THAT LINKAGE TO BD	/(010)
/				PDVL NODE IS SET UP.		/(010)
/ ASSEMBLY PARAMETERS:
/
/	MALLOF: LOWEST LUN WHICH CAN BE USED FOR MULTIACCESS (DEFAULT IS XX(10))
/	MA.NLU: NUMBER OF VIRTUAL LUNS PER USER (DEFAULT IS 25(10))
/	PPS:	NUMBER OF POLLS PER SECOND. THE FRACTION OF A	/(004)
/		SECOND THE POLLER WILL BE ASLEEP 1 <= PPS <= 60	/(004)
/		(10)						/(004)
/	TMO:	NUMBER OF SECONDS BETWEEN CHARACTERS WHICH WILL	/(004)
/		CAUSE A LOGIN TIME OUT TO OCCUR.		/(004)
/	WPUCA:	NUMBER OF DYNAMIC STORAGE WORDS TO BE ALLOCATED	/(006)
/		PER UCA ALLOCATED.				/(006)
/	MWDS:	MINIMUM NUMBER OF WORDS TO BE ALLOCATED.	/(006)
/
	UCAOFF
	.IFUND PPS						/(004)
PPS=4			/ DEFAULT SLEEP TIME IS 1/4 SECOND.	/(004)
	.ENDC							/(004)
	.IFNEG PPS-1						/(004)
	.END ERROR -- POLLS/SECOND MUST BE AT LEAST 1.		/(004)
	.ENDC							/(004)
	.IFPOZ PPS-75						/(004)
	.END ERROR -- POLLS/SECOND MUST BE <= 60.		/(004)
	.ENDC							/(004)
	.IFUND TMO						/(004)
TMO=36			/ DEFAULT TIMEOUT IS 30 (10) SECONDS.	/(004)
	.ENDC							/(004)
	.IFNEG TMO-36						/(004)
	.END ERROR -- TIME OUT INTERVAL MUST BE >= 30 SECONDS.	/(004)
	.ENDC							/(004)
	.IFUND	MALLOF
MALLOF=34
	.ENDC
	.IFUND	MA.NLU
MA.NLU=31
	.ENDC
	.IFUND WPUCA						/(006)
WPUCA=10		/ 10 (8) WORDS ALLOCATED / UCA.		/(006)
	.ENDC							/(006)
	.IFUND MWDS						/(006)
MWDS=144		/ 100 (10) WORDS MINIMUM.		/(006)
	.ENDC							/(006)
WPUCA=WPUCA+1&777776	/ MAKE SURE IT'S EVEN.			/(006)
MWDS=MWDS+1&777776	/ MAKE SURE THIS IS EVEN TOO.		/(006)
	.TITLE	GLOBALS AND EQUATES
/
/ GLOBALS
/
	.GLOBL INIT		/ SUBROUTINE ENTRY POINT.	/(003)
	.GLOBL	T.LUNS		/1ST LUN AVAILABLE FOR TDV I/O
	.GLOBL	TTY.UC		/BASE ADDR OF  TABLE RELATING TERMINAL NO. TO UCA
	.GLOBL	MA.STL		/TDV'S STL NODE ADDRESS
	.GLOBL	T.PEND		/POINTER TO LAST WORD IN LAST UCA
	.GLOBL	MA.LBM		/MULTIACCESS LUN BIT MAP
	.GLOBL	RT.LBM		/REAL TIME LUN BIT MAP
	.GLOBL TDVTYP	/ OVERLAY I/O SYSTEM.			/(006)
	.GLOBL	TS.CTB		/BASE OF TASK SIZE HISTOGRAM DATA
	.GLOBL MA.TMO	/ TIME OUT TIME.			/(004)
	.GLOBL MA.PPS	/ POLLER SLEEP TIME.			/(004)
	.GLOBL MA.CTL	/ POINTER TO BEGINNING OF TABLE.	/(005)
	.GLOBL MA.STP	/ POINTER TO MULTIACCESS STOP WORD.	/(005)
	.GLOBL BEGBUF	/ BEGINNING OF DYNAMIC BUFFER REGION.	/(006)
	.GLOBL ENDBUF	/ POINTER TO DUMMY BUSY AREA.		/(006)
	.GLOBL BEGFREE	/ FIRST WORD OF THE INITIAL FREE AREA.	/(006)
	.GLOBL ENDFREE	/ FIRST WORD OF THE NEXT NON-FREE AREA	/(006)
/
/ EQUATES
/
TDV.EQ=217			/TDV EXIT QUEUE LISTHEAD
MA.UCA=221			/BASE ADDRESS OF 1ST UCA
MA.ELU=225			/LAST USER LUN
MA.BLU=224			/FIRST USER LUN
MA.CY=227			/CONTROL Y WORD
TTYS=205			/NUMBER OF TERMINALS ON SYSTEM
LUTP1=142			/ADDRESS OF BASE OF LUT
LUTP2=143			/ADDRESS OF END OF LUT
CURTSK=135			/CURRENT TASK'S ATL NODE ADDRESS
PDVL=252			/LISTHEAD OF PDVL
A.SN=6 				/ATL NODE OFFSET FOR STL NODE ADDRESS
A.PB=5				/ATL NODE OFFSET FOR PBDL NODE ADDRESS
P.BA=4				/PBDL NODE OFFSET FOR PARTITION BASE
P.SZ=5				/PBDL NODE OFFSET FOR PARTITION SIZE
P.TS=6				/PBDL NODE OFFSET FOR TASK SIZE
D.FP=0				/PDVL OFFSET FOR FORWARD POINTER
D.NM=2				/PDVL OFFSET FOR DEVICE NAME
D.UN=5				/PDVL OFFSET FOR DEVICE UNIT NUMBER
X10=10				/AUTOINCREMENT REGISTER 10
X11=11				/AUTOINCREMENT REGISTER 11	/(006)
TT=242400			/SIXBT OF 'TT'
BD=020400			/SIXBIT OF 'BD'			/(010)
TS.CSZ=42			/SIZE OF TS.CTB (34 DECIMAL)
TPS=140			/ TICKS/SECOND IN SCOM.			/(004)
MA.CST=230		/ SCOM POINTER TO CONTROL AND STATUS	/(005)
			/ TABLE.				/(005)
SHAL=660000							/(005)
ECLA=641000							/(005)
	.TITLE	INITIALIZE TDV
/
/ INITIALIZE THIS OVERLY
/
INIT	0			/ENTRY POINT
	LAC	(INIT		/FIND THE XR ADJUSTMENT FACTOR
	AND	(70000
	TCA
	DAC	XRADJ
/
	CAL	DISABL		/DISABLE REASSIGN
/
/ CHECK THAT TDV'S I/O LUNS ARE ASSIGNED TO NONE
/
	LAC*	(LUTP1		/GET THE BASE OF THE LUT
	TCA			/NEGATE FOR LATER USE
	DAC	TEMP		/SAVE TEMPORARILY
/
	LAC*	(TTYS		/GET THE NUMBER OF TERMINALS
	IAC			/ADD ONE FOR BATCH
	DAC	MXUSRS		/SAVE THE MAX. NUMBER OF USERS
	TCA			/NEGATE
	DAC	CNTR1		/SAVE FOR USE AS AN ISZ COUNTER
	TAD*	(LUTP2		/ADD TOP ADDR OF LUT TO -(MAX USERS)
	DAC*	(X10		/SAVE IN AUTOINCREMENT REGISTER
	AAC	+2		/CALCULATE 1ST TDV I/O LUN 
	TAD	TEMP
	DAC*	T.LUNS		/SAVE 1ST TDV I/O LUN (IT'S FOR TT0)
	AAC	-1		/AND THE LAST USER LUN
	DAC	LUNEND
/
CHKLUN	LAC*	X10		/GET 1ST LUT ENTRY FOR TDV I/O LUNS
	SZA			/IS IT ASSIGNED TO NONE?
	JMP	ERR.TL		/NO -- ERROR
	ISZ	CNTR1		/YES -- HAVE ALL TDV I/O LUNS BEEN CHECKED?
	JMP	CHKLUN		/NO -- GO CHECK NEXT LUN
				/YES -- ALL TDV I/O LUNS ARE ASSIGNED TO NONE!
/
/ DETERMINE THE NUMBER AND POSITION OF UCAS WITHIN FREE CORE
/
	LAC*	(CURTSK		/GET THE ADDRESS OF TDV'S ATL NODE
	JMS	SETXR		/PREPARE TO ACCESS THAT NODE
/
	LAC	A.SN,X		/GET TDV'S STL NODE ADDRESS
	DAC*	MA.STL		/SAVE IT
	LAC	A.PB,X		/GET THE ADDRESS OF TDV'S PBDL NODE
	JMS	SETXR		/PREPARE TO ACCESS TDV'S PARTITION BLOCK
/
	LAC	P.BA,X		/GET THE BASE ADDRESS
	TAD	P.TS,X		/ADD THE SIZE NEEDED TO RUN THIS TASK
	DAC	BSEUCA		/THIS GIVES US THE BASE OF 1ST UCA (SAVE)
	TCA			/NOW NEGATE AND SAVE SO THE SPACE AVAILABLE
	TAD	P.BA,X		/GET THE PARTITON BASE AGAIN	/(005)
	TAD	P.SZ,X		/ADD THE SIZE OF THE PARTITION
	DAC FREECO	/ SAVE MAXIMUM FREE CORE.		/(006)
UCALP	DAC TEMP2	/ SAVE WORDS AVAILABLE FOR UCA.		/(006)
/
	GSM		/ SET UP THE AC AND LINK FOR IDIV	/(005)
			/ AC = SPACE AVAILABLE.			/(005)
	DIV!ECLA!LMQ		/ MOVE AC TO MQ AND DIVIDE.	/(005)
	U.LEN			/NUMBER OF WORDS PER UCA
	LACQ			/GET RESULT INTO AC
	DAC	NUMUCA		/SAVE THE NUMBER OF UCAS WHICH CAN FIT
	SPA!SNA!CMA!IAC		/DO ANY FIT?			/(009)
	JMP	ERR.UC		/NO -- ERROR
/
/ DETERMINE THE 1ST USER LUN
/
	TAD MXUSRS		/ THIS NEW NUMBER BECOMES THE	/(003)
	SMA			/ NEW MAX # OF USERS (MXUSRS)	/(003)
	CLA			/ AND IS USED IN THE REST OF THE/(003)
	TAD NUMUCA		/ CALCULATIONS.			/(003)
	DAC NUMUCA		/ UPDATE TO NEW MAX USERS.	/(009)
	DAC TEMP		/ SET UP LUN SCAN LOOP.		/(003)
/
	MUL!SHAL	/YES -- NOW MULTIPLY BY WORDS/UCA TO GET/(006)
				/SPACE NEEDED FOR UCAS.
	U.LEN
	LACQ			/GET SPACE NEEDED FOR UCAS INTO AC
	DAC	UCAWDS		/SAVE
	TAD	BSEUCA		/ADD THE ADDRESS OF 1ST UCA WORD
	DAC* BEGFREE	/ SET UP BEGINNING OF FREE AREA		/(006)
	DAC* BEGBUF	/ SET UP BEGINNING OF DSR.		/(006)
	AAC -1		/ SET UP T.PEND.			/(006)
	DAC* T.PEND	/ END OF UCA AREA SET UP.		/(006)
	DAC* (X10)	/ PREPARE TO FORMAT FREE AREA.		/(006)
 
/ NOW CALCULATE NUMBER OF WORDS AVAILABLE FOR DSR. USE MINIMUM	/(006)
/ OR ALL POSSIBLE. IF ANY ARE LEFT OVER, USE THEM.		/(006)
 
	LAC MXUSRS	/ FIGURE NUMBER OF FUDGE WORDS/UCA.	/(006)
	MUL!SHAL	/ 					/(006)
	WPUCA		/ WORDS / UCA.				/(006)
	LACQ		/ FETCH RESULT.				/(006)
	TAD (MWDS)	/ ADD IN MINIMUM BUFFER SIZE		/(006)
	TAD* BEGFREE	/ CALCULATE END OF BUFFER.		/(006)
	TCA		/ SEE IF BUFFER FITS.			/(006)
	TAD BSEUCA						/(006)
	TAD FREECO	/ MAX FREE CORE IN PARTITION		/(006)
	SMA		/ IS THIS TOO BIG?			/(006)
	JMP DSRDON	/ NO, DSR IS DONE.			/(006)
	LAC TEMP2	/ FETCH FREE CORE FUDGE FACTOR.		/(006)
	AAC -U.LEN	/ SUBTRACT ONE UCA LENGTH.		/(006)
	JMP UCALP	/ GO TRY UCA LOOP AGAIN.		/(006)
DSRDON	LAC* BEGFREE	/ FETCH BEGINNING OF FREE AREA.		/(006)
	TCA		/ CALCULATE NUMBER OF WORDS IN DSR.	/(006)
	TAD FREECO	/ NUMBER OF WORDS IN FREE CORE.		/(006)
	TAD BSEUCA	/ BASE OF UCA.				/(006)
	AND (777776)	/ MAKE THE DIFFERENCE EVE.		/(006)
	TAD* BEGFREE	/ RE CALCULATE BUFFER END.		/(006)
	AAC -2		/ SET UP PHONY BUFFER END.		/(006)
	DAC* ENDBUF	/ INITIALIZE BUFFER POINTER.		/(006)
	DAC* ENDFREE	/ INITIALIZE END OF FREE AREA.		/(006)
	AAC -1		/ PREPARE TO FORMAT AREAS.		/(006)
	DAC* (X11)						/(006)
	CLA		/ FLAGE A DUMMY ACTIVE AREA		/(006)
	DAC* X11						/(006)
	IAC		/ FLAG FREE AREA AS IDLE.		/(006)
	DAC* X10						/(006)
	IAC		/ COUNT CORRECT NUMBER OF WORDS FOR	/(006)
	DAC* X11	/ DUMMY					/(006)
	LAC* BEGBUF	/ FETCH START OF BUFFER.		/(006)
	TCA							/(006)
	TAD* ENDBUF	/ CALCULATE NUMBER OF WORDS IN FREE AREA/(006)
	DAC* X10	/ STORE THE MAGIC NUMBER.		/(006)
	LAC TEMP		/ GET THE MIN. # OF USERS.	/(003)
	MUL!SHAL	/ MULTIPLY BY LUNX PER USER -1 TO GET	/(005)
			/ MAXIMUM NUMBER OF USEFUL USER LUNS.	/(005)
	MA.NLU-1		/# LUNS/USER-1
	LACQ			/GET RESULT INTO AC
	TCA			/NEGATE
	TAD*	T.LUNS		/ADD BASE OF TDV I/O LUNS TO GET 
				/BASE OF USER LUNS ASSUMING ALL ARE AVAILABLE
/
LUN3	PAL			/SAVE BASE USER LUN IN LR
	SPA			/ABOVE ZERO?
	JMP	LUN1		/NO -- DECREMENT MAX # POSSIBLE USERS AND 
				/CHANGE BASE USER LUN
	AAC	-MALLOF		/YES -- EQUAL OR ABOVE LOWER LUN LIMIT?
	SMA
	JMP	LUN2		/YES -- LR HAS BASE USER LUN AND
				/TEMP HAS MAX # POSSIBLE USERS
LUN1	LAC	TEMP		/NO -- DECREMENT MAX # POSSIBLE USERS
	AAC	-1
	DAC	TEMP
	SNA			/CAN ANY USERS LOG IN?
	JMP	ERR.IL		/NO -- ERROR
	PLA			/YES -- RAISE BASE USER LUN
	AAC	+MA.NLU-1
	JMP	LUN3		/GO CHECK THIS BASE
/
/ CONSTRUCT THE LUN BIT MAPS
/
LUN2	DZM*	RT.LBM		/ZERO REAL TIME LUN BIT MAP
/
	PLA			/GET USER BASE LUN
	DAC	LUNBSE		/SAVE IT
	TAD*	(LUTP1		/ADD BASE OF LUT
	AAC	-2		/SET UP X10 FOR CHECKING
	DAC	PTR		/AND PTR FOR REMEMBERING
	DAC*	(X10		/WHERE WE ARE IN LUT
/
	LAC	TEMP		/GET MAX # POSSIBLE USERS
	TCA			/NEGATE AND SAVE
	DAC	CNTR1		/FOR USE AS AN ISZ COUNTER
	JMP	NON4		/NOW SCAN 1ST BLOCK OF USER LUNS
/
NON1	LAC	PTR		/BUMP PTR TO NEXT USER LUN SPACE
	AAC	MA.NLU-1
	DAC	PTR
	DAC*	(X10
NON4	LAC	(-MA.NLU+1	/SET UP THE VIRTUAL LUN ISZ COUNTER
	DAC	CNTR2
/
NON2	LAC*	X10		/IS THIS LUN ASSIGNED TO NONE?
	SZA
	JMP NON2A		/ NO -- THIS BLOCK IS BEING	/(003)
				/ USED FOR REAL TIME, FLAG IT.	/(003)
	ISZ	CNTR2		/YES -- ARE WE DONE WITH THIS BLOCK?
	JMP	NON2		/NO -- CHECK NEXT LUN IN BLOCK
	JMP NON3		/ YES -- GO TO NEXT LUN BLOCK.	/(003)
/
NON2A	LAC TEMP		/ CALC LUN BLOCK FROM 0.	/(003)
	TAD	CNTR1
	TAD (LRS!CLQ+1)		/ CONSTRUCT BIT MASK INSTRUCTION/(007)
	DAC	NONXX		/PREPARE TO EXECUTE THAT INSTRUCTION
	CLA!IAC			/ GENERATE BIT MASK IN MQ.	/(003)
NONXX	XX			/LRS (IMPURE)
	LAC* RT.LBM		/ FETCH REAL TIME BIT MAP.	/(003)
	OMQ			/ SET BIT IN BIT MAP.		/(003)
	DAC*	RT.LBM		/SALT AWAY THE BIT MAP
NON3	ISZ	CNTR1		/DONE WITH ALL LUN BLOCKS?
	JMP	NON1		/NO -- GO CHECK NEXT ONE
/
	LAC	MXUSRS		/YES -- SETUP THE USER LUN BIT MAP
	TAD	(LRS		/AS THE 1S COMPLEMENT OF THE 	/(003)
	DAC	SHIFT		/REAL TIME BIT MAP FOR ONLY THOSE LUN
	STL!CLA			/SPACES WHICH CAN BE USED
SHIFT	XX			/LRS (IMPURE)
	DAC	TEMP
	AND* RT.LBM	/ STRIP OUT SPURIOUS BITS IN RT.LBM.	/(007)
	XOR TEMP	/ COMPLEMENT RT.LBM TO CONSTRUCT	/(007)
			/ MA.LBM.				/(007)
	DAC*	MA.LBM		/SAVE THE USER LUN BIT MAP
	SNA			/IS ANY VIRTUAL LUN SPACE AVAILABLE?
	JMP	ERR.RT		/NO -- ERROR
				/YES -- PROCEED
/
/ ASSIGN THE TDV I/O LUNS TO TERMINALS 0 TO TTYS-1
/
	LAC	(PDVL		/PREPARE TO SCAN PDVL FOR TTY NODES
	JMS	SETXR
ASG1	LAC	D.FP,X		/GET THE ADDR OF NEXT NODE
	DAC	TEMP		/SAVE IT
	SAD	(PDVL		/END OF PDVL?
	JMP	FINISH		/YES -- THEN WE'RE JUST ABOUT DONE
	JMS	SETXR		/NO -- PREPARE TO ACCESS NODE
	LAC	D.NM,X		/GET THE DEVICE NAME
	SAD	(TT		/IS IT A TERMINAL?
	JMP ASG2		/ INITIALIZE A TTY NODE.	/(010)
	SAD (BD)		/ CHECK FOR BATCH DEVICE.	/(010)
	SKP			/ YES, THIS IS IT.		/(010)
	JMP	ASG1		/NO -- GO CHECK NEXT NODE
	LAC* (TTYS)		/ FETCH MAXIMUM TTY NUMBER.	/(010)
	SKP			/ SPECIAL CASE BATCH DEVICE.	/(010)
ASG2	LAC	D.UN,X		/YES -- GET UNIT NUMBER		/(010)
	TAD*	T.LUNS		/ADD BASE OF TDV I/O LUNS
	TAD*	(LUTP1		/ADD BASE OF LUT
	AAC	-1		/POSITION POINT TO ACCESS LUT
	DAC	PTR
	LAC	TEMP 		/GET PDVL NODE ADDRESS FOR THIS UNIT
	DAC*	PTR		/ENTER INTO LUT (ASSIGN)
	JMP	ASG1		/GO CHECK NEXT NODE
/
/ SET UP THE TDV SCOM REGISTERS
/
FINISH	LAC* (LUTP1)	/ FIGURE OUT WHAT THE DEVICE NUMBER IS	/(007)
	AAC 2		/ ON LUN 3.				/(007)
	DAC PTR		/ PTR NOW POINTS TO THE LUN ENTRY FOR	/(007)
	LAC* PTR	/ LUN 3. FETCH THE PDVL NODE ADDRESS.	/(007)
	JMS SETXR	/ SET UP THE XR TO ACCESS PDVL.		/(007)
	LAC D.UN,X 	/ FETCH THE UNIT NUMBER FROM THE PDVL.	/(007)
	DAC TTYN	/ SAVE LUN 3 TTY NUMBER.		/(006)
	LAC LUNBSE	/ SET UP BASE OF USER LUNS.		/(006)
	DAC*	(MA.BLU
	LAC	LUNEND		/SET UP END OF USER LUNS
	DAC*	(MA.ELU
	LAC	BSEUCA		/ENTER BASE ADDRESS OF 1ST UCA
	DAC*	(MA.UCA
	DZM*	(MA.CY		/CLEAR CONTROL Y WORD
	LAC*	(TDV.EQ		/CHECK IF TDV EXIT QUEUE IS EMPTY
	SAD	(TDV.EQ
	JMP	ENAREA		/IT IS -- COMPLETE THE INITIALIZATION
	JMS* TDVTYP	/ TYPE MESSAGE TO OPERATOR.		/(006)
	LAC TTYN	/ PASS TTY NUMBER.			/(006)
	LAC (MESEQ)	/ PASS MESSAGE ADDRESS.			/(006)
	LAC (2)		/ PASS MODE INFORMATION.		/(006)
/
/ ENABLE REASSIGN AND SET UP TDV DATA TABLES
/
ENAREA	CAL	ENABLE		/ENABLE REASSIGN
/
	LAC	TTY.UC		/SET TABLE RELATING UCA TO TERMINAL # TO -1
	AAC	-1		/THIS SHOWS THAT NO USERS ARE LOGGED ON
	DAC*	(X10
	LAW	-22
	DAC	CNTR1
	LAW	-1
	DAC*	X10
	ISZ	CNTR1
	JMP	.-2
/
	LAC	BSEUCA		/ZERO ALL THE UCAS
	AAC	-1
	DAC*	(X10
	LAC	UCAWDS
	TCA
	DAC	CNTR1
	DZM*	X10
	ISZ	CNTR1
	JMP	.-2
/
	LAC	TS.CTB		/ZERO TS.CTB
	AAC	-1
	DAC*	(X10
	LAW	-TS.CSZ
	DAC	CNTR1
	DZM*	X10
	ISZ	CNTR1
	JMP	.-2
 
/ INITIALIZE THE TIMEOUT INTERVAL.				/(004)
 
	LAC (TMO)	/ FETCH THE NUMBER OF SECONDS.		/(004)
	DAC* MA.TMO	/ SET UP MARK TIME.			/(004)
 
/ CALCULATE POLLER SLEEP TIME.					/(004)
 
	LAC* (TPS)	/ FETCH TICKS/SECOND			/(004)
	LMQ		/ LOAD IN MQ.				/(004)
	CLA!CLL		/ PREPARE FOR.				/(004)
	DIV							/(004)
	PPS		/ NUMBER OF POLLS/SECOND.		/(004)
	LACQ		/ FETCH QUOTIENT.			/(004)
	DAC* MA.PPS	/ SET UP POLLER SLEEP TIMER.		/(004)
/
	LAC MA.CTL	/ FETCH CONTROL TABLE ADDRESS.		/(005)
	DAC* (MA.CST)	/ SET UP SCOM.				/(005)
	DZM* MA.STP	/ CLEAR STOP WORD, JUST IN CASE.	/(005)
 
/ PRINT MESSAGE TO OPERATOR TELLING HIM HOW MANY OF WHAT KIND	/(007)
/ HAS BEEN ALLOCATED FOR THIS RUN OF MULTIACCESS.		/(007)
 
	LAC MXUSRS	/ FETCH THE MAXIMUM NUMBER OF USERS.	/(007)
	CLQ!LRS!SHAL 3	/ AND					/(007)
	ALS 4		/ CONVERT				/(007)
	LLS 7		/ TO					/(007)
	XOR MESLB+2	/ 7 BIT					/(007)
	DAC MESLB+2	/ ASCII.				/(007)
/								/(007)
	LAC NUMUCA	/ DO THE SAME THING FOR # OF UCA AREAS.	/(007)
	CLQ!LRS!SHAL 3						/(007)
	ALS 4							/(007)
	LLS 7							/(007)
	XOR MESUCA+2	/ BUT PUT IT INTO A DIFFERENT MESSAGE.	/(007)
	DAC MESUCA+2						/(007)
/								/(007)
	JMS* TDVTYP	/ PRINT THE MESSAGES TO TTY ON LUN 4.	/(007)
	LAC TTYN						/(007)
	LAC (MESLB)						/(007)
	LAC (2)							/(007)
	JMS* TDVTYP						/(007)
	LAC TTYN						/(007)
	LAC (MESUCA)						/(007)
	LAC (2)							/(007)
	JMP*	INIT		/RETURN TO POLLER
	.TITLE	OVERLAY VARIABLES,CPBS, MESSAGES,ETC.
/
/ PROGRAM VARIABLES
/
LUNBSE	0			/1ST USER LUN
LUNEND	0			/LAST USER LUN
NUMUCA	0			/NUMBER OF UCAS
XRADJ	0			/XR ADJUSTMENT FACTOR
TEMP	0			/TEMPORARY STORAGE
TEMP2	0		/ AMOUNT OF SPACE AVAILABLE FOR UCA.	/(006)
FREECO	0		/ TOTAL AMOUNT OF FREE CORE.		/(006)
TTYN	0		/ TTY NUMBER OF DEVICE ON LUN 3.	/(006)
PTR	0			/TEMPORARY POINTER
MXUSRS	0			/MAXIMUM NUMBER OF USERS (TTYS+1)
CNTR1	0			/TEMPORARY ISZ COUNTER
CNTR2	0			/TEMPORARY ISZ COUNTER
BSEUCA	0			/POINTER TO BASE OF 1ST UCA
UCAWDS	0			/NUMBER OF WORDS OCCUPIED BY UCAS
EV	0			/GENERAL PURPOSE EVENT VARIABLE
/
/ CAL PARAMETER BLOCKS (CPBS)
/
WRITE	2700
	EV
	3
	2
WRITMS	XX
/
WAIT	20							/(006)
	EV							/(006)
/
ENABLE	22							/(008)
	0
	.SIXBT	"..."
	.SIXBT	"REA"
/
DISABL	21							/(008)
	0
	.SIXBT	"..."
	.SIXBT	"REA"
/
/ ERROR ROUTINES
/
ERR.RT	LAC	(MESRT
	SKP
ERR.UC	LAC	(MESUC
	SKP
ERR.TL	LAC	(MESTL
	SKP
ERR.IL	LAC	(MESIL
	JMS	TYPE
	CAL WAIT	/ WAIT FOR I/O TO COMPLETE.		/(006)
	CAL	ENABLE
	CAL	(10
/
/SUBROUTINES
/
SETXR	0
	TAD	XRADJ
	PAX
	JMP*	SETXR
/
TYPE	0
	DAC	WRITMS
	CAL	WRITE
	JMP*	TYPE
/
/ MESSAGES
/
MESEQ	MESIL-MESEQ/2*1000+2
	0
	.ASCII "TDV EXIT QUEUE NOT EMPTY -- CONTINUING"<15>	/(007)
MESIL	MESRT-MESIL/2*1000+2
	0
	.ASCII "INSUFFICIENT LUNS"<15>
MESRT	MESUC-MESRT/2*1000+2
	0
	.ASCII "ALL LUN SPACES USED FOR REAL TIME"<15>
MESUC	MESTL-MESUC/2*1000+2
	0
	.ASCII "NO SPACE AVAILABLE FOR UCAS"<15>
MESTL	MESLB-MESTL/2*1000+2					/(007)
	0
	.ASCII "TDV I/O LUNS ASSIGNED"<15>
MESLB	MESUCA-MESLB*400&777000+2				/(007)
	0							/(007)
	.ASCII "00 LUN BLOCKS RESERVED - "<175>			/(007)
MESUCA	MESEND-MESUCA*400&777000+2				/(007)
	0							/(007)
	.ASCII "00 USER CONTEXT AREAS RESERVED"<15>		/(007)
MESEND=.
	.END
