	.TITLE	*** TDV OVERLAY ABORT ***
/
/ 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
/
/
/ EDIT 000	21-APR-76 (SCR) WRITE FROM SCRATCH
/ EDIT 001	24-MAY-76 (SCR) DON'T ABORT EXEC MODE TSK
/								/(002)
/ 002	30-JUL-76 (EAG)		INSERT FLAG BIT INTO ^Y ECHO	/(002)
/				MESSAGE SO THAT BATCH WILL	/(002)
/				IGNORE IT.			/(002)
/								/(002)
/
/ OVERLAY ABORT, ACT OF CONTROL Y FLAGS
/
/
ECLA=641000
IDX=ISZ
MA.CY=227		/ADDR OF CONTROL Y FLAG
NDEL=112		/NODE DELETE ROUTINE IN EXEC
POOL=240		/ADDR OF MT POOL DEQUE HEAD
CURTSK=135		/ATL NODE OF CURRENT TASK (US)
NADD=107		/ADDR OF NODE ADD ROUTINE
TDV.EQ=217		/TDV'S EXIT QUEUE DEQUE HEAD
A.N1=2			/ATL NODE OFF SET FOR NAME
A.N2=3
S.N1=2			/AND FOR STL
S.N2=3
A.RA=10			/ATL RESTART ADDR
R1=101			/MONITOR REGISTER ADDR
R2=102
.INH=705522		/INHIBIT IOT
.ENB=705521		/AND THE ENABLE
ATKL=244		/DEQUE HEAD OF ACTIVE TASK LIST
S.DP=4			/STL FLAGS AND PRIORITY
A.SN=6			/ATL ADDR OF STL
A.TS=7			/ATL FLAGS AND STATUS WORD
X10=10
	.IFUND	MA.NLU		/# OF MAPPED LUNS PER USER
MA.NLU=31
	.ENDC
/
/
/ 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.SSM=74			/SECONDS SINCE MIDNIGHT INTO STATE 11
				/ OR 12 (HUNG ON PARTITION)
U.TW=75				/TOTAL TIME IN SECONDS SPENT IN STATE 11
				/ OR 12.
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
/
	UCAOFF
/
	.GLOBL	ABORT,TDVTYP,TTY.UC,T.LUNS
/
/
UCAXR	0		/SAVE POINTER TO USER CONTEXT AREA
XADJ	0		/XR ADJUSTMENT FOR THIS PAGE
TTYNUM	0		/TTY NUMBER OF USER
NAME1	0		/FIRST HALF OF TASK NAME
NAME2	0		/SECOND HALF OF TASK NAME
ATLADR	0		/ADDR OF ATL NODE
STLADR	0		/ADDR OF STL NODE
/
/  TABLE OF JUMPS BASED ON PRESENT JOB STATUS
/
STDISP	JMP	STAT0	/ON ZERO, INACTIVE, DON'T EVEN ECHO
	JMP	STAT0	/ON 1, LOGGING IN, BUT NO ACTION
	JMP	STAT2	/ON 2, READING, CANCEL READ, ECHO
	JMP	STAT3	/ON 3, LOADING, CHANGE TO STATUS 7
	JMP	STAT4	/ON 4, RUNNING, SET TO EXIT
	JMP	STAT4	/ON 5, JUST AS IN 4
	JMP	STAT6	/ON 6, ABOUT TO READ, JUST ECHO
	JMP	STAT3	/ON 7, WAITING FOR FININS STAY IN 7
	JMP	STAT0	/ON 10 EXEC MODE EXEC. NO-OP		/(001)
	JMP	STAT11	/ON 11 SYST TASK WAITING FOR PARTITION
	JMP	STAT12	/ON 12 USER TASK WAITING FOR PARTITION
/
/  CONTROL Y ECHO
/
ECHO	402002		/ASCII	/ THIS MESSAGE IS IGNORED	/(002)
	0			/ BY BATCH.			/(002)
	572621		/  ^Y
	500000
/
/
/  CAL'S
/
REQUES	1		/REQUEST AUTORM
	EV
	.SIXBT	"AUTORM"
	0
/
ENABLE	22		/ENABLE ABORT AGAIN
	EV
	.SIXBT	"...ABO"
/
DISABL	21		/DISABLE ABORT DURING OUT ACTION
	EV
	.SIXBT	"...ABO"
/
SINGLE	1700		/SINGLE UNIT ABORT
	EV
LUNSLT	XX		/CONSTRUCT TTY LUN HERE
/
EV	0
/
ABORT	0		/CALL WHEN MA.CY NON 0
	LAC	(EV	/SET UP INDEX ADJUSTMENT
	AND	(70000
	CMA!IAC
	DAC	XADJ
	CAL	DISABL	/DISABLE ...ABO SO WE DON'T RACE
ABORTL	.INH		/HOLD OFF INTERRUPTS TO CHECK MA.CY
	LAC*	(MA.CY	/FETCH CONTROL Y WORD
	SNA!CMA!IAC	/SKIP IF STILL BITS TO DO
	JMP	ABDONE	/NOPE, RETURN
	AND*	(MA.CY	/LEAVING ONLY LOWEST BIT FROM MA.CY IN AC!
	LMQ		/SAVE TO LATER OBTAIN TTY NUMBER
	XOR*	(MA.CY	/TURN OFF LOWEST BIT, WE'RE GOING TO DO IT
	.ENB		/SYSTEM BACK IN AFTER ONE INSTRUCT.
	DAC*	(MA.CY	/NEW COPY OF CONTROL Y WORD
	ECLA!NORMS	/MAKE COUNT OUT OF BIT 
	LACS		/STEP COUNTER TO AC
	AAC	-55	/LEFT BIT OF ORIG. MQ TO TTY #0
	DAC	TTYNUM	/SAVE NUMBER TO MAKE UP USR.NN NAME
	PAX		/INDEXED SO WE CAN FETCH UCA ADDRESS
	LAC*	TTY.UC,X /UCA ADDRESS INDEXED BY TTY #
	SPA!SNA		/MUST BE REAL ADDR
	JMP	ABORTL	/NONE FOR THIS TTY, IGNORE
	TAD	XADJ	/ADJUST TO INDEX USER CONTEXT AREA
	DAC	UCAXR	/SAVE
	PAX
	LAC	U.JSW,X	/JOB STATUS WORD TELLS US WHAT TO DO
	PAX		/DISPATCH TO CORRECT ACTION
	JMP	STDISP,X / GO THERE
/
/  DONE CODE
/
ABDONE	.ENB		/ENABLE, SINCE .INH ALREADY IN FORCE
	CAL	ENABLE	/LET ...ABO BE ALIVE AGAIN
	LAC	UCAXR	/SET UP TO SET STATUS IN UCA
	PAX
	CLA!IAC		/OK STATUS
	DAC	U.OEV,X /
	JMP*	ABORT	/ZOT
/
	.EJECT
STAT3	LAC	UCAXR	/RESTORE POINTER TO USER CONTEXT AREA
	PAX
	LAC	(7	/STATES 3 AND 7 BECOME 7
	DAC	U.JSW,X /IN UCA
	JMP	STAT6	/GO ECHO CONTROL Y
/
STAT2	LAC*	T.LUNS	/STARTING LUN FOR TDV LUNS FOR TTYS
	TAD	TTYNUM	/ADDING IN TTY TO GIVE ACTUAL LUN
	DAC	LUNSLT	/PLACE IN SINGLE UNIT ABORT
	CAL	SINGLE	/DO SINGLE UNIT ABORT TO SHUT DOWN READ
SETST6	LAC	UCAXR	/SET UP TO ADDR USER CONTEXT AREA
	PAX
	LAC	(6	/JOB STATE 6, GO ISSUE A READ
	DAC	U.JSW,X	/INTO MASTER STATUS WORD
/
/  FALL THRU TO ECHO CONTROL Y
/
STAT6	JMS*	TDVTYP	/ECHO CONTROL Y
	LAC	TTYNUM	/XCT'D FROM TDVTYP, TTY #
	LAC	(ECHO	/XCT'D FROM TDVTYP, MESSAGE ADDR
	LAC	(2	/XCT'D FROM TDVTYP, ASCII
STAT0	JMP	ABORTL	/GO LOOK FOR OTHER CONTROL Y BITS
/
	.EJECT
/
STAT10	LAC	UCAXR	/SET UP TO LOOK AT UCA
	PAX
	LAC	U.CTSK,X /EXEC MODE, FIRST HALF NAME
	SKP		/JOIN WITH COMPARE NAME IN AC
STAT4	LAC	(252322	/'USR' FOR COMPARE
	DAC	NAME1	/ON ATL NAME IN SCAN
	LAC	TTYNUM	/FORM NAME  'USR.NN'  WHERE NN
	CLQ!LRSS!3	/IS THE OCTAL TTY NUMER
	ALS	3
	LLS	3	/OCTAL CORRECTLY SPACED
	TAD	(566060	/MAKE .NN
	DAC	NAME2	/SAVE AS SECOND HALF OF NAME
	LAC*	(CURTSK	/SCAN ATL FROM PRESENT TASK
	TAD	XADJ
	PAX
/
ATLSCN	LAC	0,X	/NEXT NODE
	SAD	(ATKL	/AROUND TO TOP
	JMP	ABORTL	/?? COULD HAPPEN ON TIMING RACE
/			/BETWEEN REGULAR EXIT AND ^Y
	DAC	ATLADR	/SAVE IN CASE IT IS THE RIGHT ONE
	TAD	XADJ	/ADJUST FOR PAGE
	PAX
	LAC	A.N1,X	/FIRST HALF OF NAME
	SAD	NAME1	/FIRST HALF OF NAME
	SKP
	JMP	ATLSCN	/KEEP GOING
	LAC	A.N2,X	/SECOND HALF OF NAME
	SAD	NAME2	/MUST BE CORRECT '.NN'
	SKP
	JMP	ATLSCN	/NOPE
/
ATLFND	LAC	A.TS,X	/FETCH ATL STATUS
	SPA!CLL!RAR	/SKIP UNLESS MINUS
	JMP	LOADIN	/LOADING RIGHT NOW
	SNA!CLA		/SKIP UNLESS STATE 1
	JMP	STAT41	/JOB STATE 4,5,10; ATL STATE 1
	AAC	4	/SET STATUS TO 4 RUNNABLE
	DAC	A.TS,X	/FOR ATL STATUS , THAT IS
LOADIN	LAC	(300	/ADDRESS 300 TO HAVE IT KILL ITSELF
	DAC	A.RA,X
	JMP	STAT6	/ECHO CONTROL Y AND OUT
/
/
STAT41	LAC	A.SN,X	/STL NODE ADDRESS
	DAC	STLADR	/SAVED FOR LATER
	LAC	ATLADR	/ATL NODE ADDR TO PULL NODE
	DAC*	(R1
	DAC*	(R2	/A COPY FOR NADD
	JMS*	(NDEL	/PULL THE ATL NODE FROM LIST
	LAC	(TDV.EQ	/TDV'S EXIT QUEUE
	DAC*	(R1	/PLACE THE NODE THERE
	JMS*	(NADD
	LAC	STLADR	/SET TASK TO INACTIVE IN STL
	TAD	XADJ
	PAX
	LAC	S.DP,X
	AND	(377777
	DAC	S.DP,X
	JMP	STAT6	/ECHO AND TO LOOP TOP
/
	.EJECT
STAT11	LAC	UCAXR	/SET UP TO FETCH FROM UCA
	PAX
	LAC	U.CPB,X /GETTING STL NODE ADDR
	DAC*	(R1	/SYSTEM REGISTER HAS PULLED ADDR
	DAC*	(R2	/FOR NADD  (LIVES THRU NDEL OK)
	JMS*	(NDEL
	LAC	(POOL	/PLACE NODE BACK INTO EMPTY POOL
	DAC*	(R1	/EXPECTS HEADER IN R1 HERE
	JMS*	(NADD
	JMP	SETST6	/SET TASK STATUS TO 6 AND OUT
/
STAT12	LAC	UCAXR	/SET UP TO FETCH FROM USER CONTEXT AREA
	PAX
	LAC	U.CPB,X /STL NODE ADDRESS
	TAD	XADJ	/SET UP TO USE XR
	PAX
	DZM	S.N1,X	/ZERO NAME TO PREVENT ALIASING 
	DZM	S.N2,X	/PROBLEMS
	LAC	(204000	/FORCE BITS; EXITTED, REMOVE ON EXIT
	DAC	S.DP,X	/IN STL
	CAL	REQUES	/REQUEST AUTORM TO FINISH IT UP
	JMP	SETST6	/FORCE STATUS 6 ON TASK
	.END
