	.TITLE *** OFF TDV OVERLAY ***

/

/ 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 001	12-APR-76 (SCR) CREATE OFF FROM ASSIGN
/ EDIT 002	13-APR-76 (SCR) MINOR CLEANUP
/ EDIT 003	13-APR-76 (SCR) NONE TO NONE;TAKE OUT MA.NUS;TIME FIX
/ EDIT 004	13-APR-76 (SCR) FIX UP 003
/ EDIT 005 	13-APR-76 (SCR) REARRANGE ORDER OF WORK
/ EDIT 006	14-APR-76 (SCR) REMOVE I/O BUSY MESSAGE
/ EDIT 007	24-MAY-76 (SCR) HANDLER NOT IN CORE MESSAGE NOT FATAL
/ EDIT 008	2-JUNE-76 (SCR) MISSING .INH, BT.USR
/ 009	14-JUL-76 (RCHM)	LAS, FINAL , ONCE AND FOR ALL	/(009)
/				FIX FOR THE LOUSY BATCH DEVICE	/(009)
/				DEASSIGNMENT.			/(009)
/

/ OVERLAY NAME "OFF..." TO LOG OFF A MULTI-ACCESS USER

/

/  NOT TO BE CONFUSED WITH A COMERCIALLY AVAILABLE BUG
/  REPELLANT - N,N DIMETHYL METATOLUAMIDE - OF THE SAME NAME.
/
/  NOTE, IN CASE OF A 'FATAL' ERROR, NO MODIFICATION IS MADE TO
/  THE UCA, SO THAT THE POLLER WILL CALL US AGAIN THE NEXT TIME
/  HE COMES AROUND. IN CASE OF A REASSIGN INHIBITED OR OUT OF POOL
/  I BELIEVE THIS IS THE CORRECT THING TO HAPPEN.
/
/
/
MCRRI=171

HH=165

MM=164

CURTSK=135

TTMCTT=200

TTDVTT=201

ECLA=641000

.INH=705522

.ENB=705521

LUN1=142

LUN2=143

LUFD1=304

DUFD1=306

AFTP1=144

FAC=174

IDX=ISZ

PENP=115

R1=101

R2=102

SPRI=126

X10=10

PDVL=252

	.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	LOGOFF,TDVTYP,MA.LBM,MA.USR,TTY.UC,BT.USR

/

LOGOFF	0		/CALL WITH UCA ADDRESS IN AC

	DAC	TEMP	/HOLD

	LAC	(LUNTAB	/SET UP LAST POINTER

	DAC	LASTUN	/CALL WITH ONE LUN AT A TIME

	AND	(70000	/CONSTRUCT PAGE OFFSET

	DAC	MXADJ	/PAGE ADJUST XR BACK TO AC

	CMA!IAC

	DAC	XADJ	/PAGE ADJUST AC TO XR

	TAD	TEMP	/ADJUSTED UCA ADDRESS

	PAX		/STAYS IN XR

	DAC	UCAXR	/WELL, AT LEAST MOST OF TIME, SAVE IT

	LAC	U.ULOF,X /USER # IN RIGHT HALF

	AND	(777	/GETTING USER #

	DAC	USERNO

	XOR	U.ULOF,X /LUN OFFSET IN LEFT HALF

	SWHA

	AAC	-1	/OFF BY ONE MAGIC FOR LUT TABLE

	TAD*	(LUN1	/LUT TABLE ADDR
	DAC	LUNTAB	/LOWEST # TO BE ASSIGNED NONE

	LAC	U.TTYN,X /TELETYPE NUMBER
	DAC	TTYNUM	/(002)
/
/  ASSIGN USER'S MAPPED LUN'S (XCPT 1) TO NONE
/
/  EDIT 005, DO THIS BEFORE TDV... BOOKKEEPING
/
	DZM	UNIT	/NEW UNIT # IS ZERO FOR NONE
	DZM	UFDNAM	/NEW UFD NAME IS ZERO FOR NONE
	LAC	(56	/NEW DEV IS NUL + . IN SIXBIT
	DAC	REQNAM
	LAW	-MA.NLU+1 /LOOP CONTROL (#1 NOT DONE)
	DAC	COUNTR	/ASSIGN EVERYONE BACK TO NONE
OFFLOO	LAC	LASTUN	/ENDING LUN
	DAC	LUNADR	/MAKE IT ALSO THE FIRST ONE
	JMS	ASGWRK	/ACTUAL ASSIGNMENT WORK
	ISZ	LUNTAB	/TO NEXT LUT ENTRY ADDREESS
	ISZ	COUNTR	/MORE?
	JMP	OFFLOO
/
/  IF GOT HERE OK, SEND THE ENDING MESSAGE
/
	LAC*	(HH	/(003)SET TIME IN MESSAGE
	JMS	DIV10	/(003)DECIMAL #'S IN AC
	RTL		/(003)7,7,4 POSITION IN WORD
	TAD	(301407	/(003)MAKE HH:
	DAC	HOURS	/(003) INTO MES1
	LAC*	(MM	/(003)AND THE MINUTES READING
	JMS	DIV10	/(003)
	RAR		/(003)3,7,7,1 POSITION IN WORD
	TAD	(230140	/(003)MAKE :MM
	DAC	MINUTE	/(003)PLACE INTO MESSAGE
/
/  SEND OUT EXIT MESSAGE
/
	LAC	(MES1	/(002)
	JMS	OUTMES	/(002)
/
	LAC	TTYNUM	/(002)TTY NUMBER INDEX
	PAX
/
/  BOOKKEEPING IN TDV...
/
	JMS	MASK	/TELETYPE MASK IN AC
	PAL		/(008) SAVE MASK
	AND*	MA.USR	/TURN OFF TELETYPE ACTIVE BIT
	DAC*	MA.USR
	PLA		/(008) AND IN OTHER WORD
	AND*	BT.USR	/(008)
	DAC*	BT.USR	/(008)
	LAW	-1	/-1 TO SET IN TTY.UC TABLE
	DAC*	TTY.UC,X /INDEXED BY TTY NUMBER
	LAC	USERNO	/TURN ON MA.LBM BIT MAP
	CLL!RTR		/WATCH IT, BITS ARE IN 9-13
	RTR		/RIGHT JUSTIFY

	JMS	MASK	/MASK IN AC

	RAL		/CORRECT IT, #1 IS LEFTMOST BIT!

	CMA		/BUT TURN ON, NOT OFF

	XOR*	MA.LBM

	DAC*	MA.LBM

	LAC	UCAXR	/SET TO CLEAR ENTIRE UCA

	PAX		/WITH XR LOOPS

	AAC	U.LEN	/SIZE OF CONTEXT AREA

	PAL

CLEARL	DZM	0,X

	AXS	1

	JMP	CLEARL

/
/
DONE	LAC	MESSET	/MESSAGE TO RETURN
	SZA		/SKIP IF ALREADY DONE
TYPMSG	JMS	OUTMES	/RETURN MESSAGE
	LAC	UCAXR	/RESTORE XR TO POINT TO AREA
	PAX
	LAC	STATUS	/STATUS FROM MESSAGE HEADER
	DAC	U.OEV,X	/OVERLAY STATUS
	JMP*	LOGOFF	/OUT

/

/

/  SUBROUTINE SETXR  --  ADJUST THE XR

/

SETXR	0

	TAD	XADJ

	PAX

	JMP*	SETXR

/

/

/  SUBROUTINE  OUTMES

/

/  CALL TDV MESSAGE SENDER

/

/  ENTER WITH THE ADDRESS OF THE MESSAGE IN THE AC

/

/  ALSO UPDATE STATUS WITH # IN MESSAGE+1

/

OUTMES	0

	DAC	MESSET	/ADDR IN AC

	JMS*	TDVTYP	/

	LAC	TTYNUM	/ EXECUTED FROM TDVTYP

	LAC	MESSET	/ "

	LAC	(2	/ "

	ISZ	MESSET	/PICK UP STATUS

	LAC*	MESSET	/

	DAC	STATUS	/ TO PLACE UPON EXIT

	DZM	MESSET	/DON'T SEND TWICE

	JMP*	OUTMES

/

/  SUBROUTINE MASK

/

/  CALL WITH # IN AC

/

/  RETURN WITH MASK TO CLEAR THAT BIT, IN AC

/

/  I.E. 0 RETURNS 377777; 1 RETURNS 577777; ETC.

/

/  LINK IS RETURNED SET. MQ IS DESTROYED

/

MASK	0

	TAD	(LRS 0	/MAKE SHIFT INSTRUCTION

	DAC	MASKXX	/EXECUTE SHORTLY

	CLL!CML		/SET LINK TO SHIFT IN 1'S

	LAC	(377777	/DEFAULT FOR NUMBER 0

MASKXX	HLT

	JMP*	MASK

/

/  SUBROUTINE DIV10

/

/  TO MAKE UP TWO ASCII CHAR'S FROM # IN AC

/  # OBTAINED FROM HOURS OR MINUTES IN EXEC TIME

/

/  DIVIDE BY 10(10) AND RETURN REMAINDER*4

/  ADDED TO QUOTIENT*512

/

/  LINK RETURNED CLEAR, MQ DESTROYED

/

DIV10	0

	RTL!CLL		/*4 FOR REMAINDER*4

	IDIV		/IDIV DIVIDES AC BY FOLLOWING WORD

	50		/DECIMAL 10, *4

	SWHA		/GET REMAINDER OUT OF WAY

	OMQ		/OR IN THE QUOTIENT

	SWHA		/WANT QUOTIENT ON TOP

	JMP*	DIV10

/

	.TITLE *** ASSIGN WORKING ROUTINE ***

/

/  THIS ROUTINE TAKEN FROM ASSIGN, HAS BEEN MODIFIED

/  FOR OFF. ONLY ONE LUN AT A TIME IS SENT, SO THAT

/  LUNTAB IS A SINGLE LOCATION, RATHER THAN A BLOCK.

/  THE NEW DEVICE IS ALWAYS 'NONE'. THE OLD DEVICE

/  IS THAT FOUND IN THE TABLES. CHANGES MADE FOR OFF

/  WILL BE FLAGGED WITH /(OFF).

/

/  INPUT ARGUMENTS FOR ASGWRK

/

LASTUN	0		/POINTER TO LAST OF LIST OF LUT POINTERS

LUNADR	0		/POINTER FOR FIRST OF LIST

OLDNAM	0		/OLD DEVICE NAME

OLDUNT	0		/OLD UNIT NUMBER

UNIT	0		/NEW UNIT NUMBER
UFDNAM	0		/NEW UFD NAME

/

/  NEW DEVICE NAME IS IN A CAL UNDER NAME 'REQNAM'

/  THE DEVICE NAME HAS A '.' APPENDED TO IT

/

LUNTAB	0		/(OFF)LUT ENTRY ADDR

/

/

/  WORK REGISTERS FOR ASGWRK

/

TMPA	0

TMPB	0

TMPC	0

CNT	0

NEWPVD	0

TRGGR	0

/

TTA	.SIXBT	"TT"

DSK	.SIXBT	"DK@"

/
ASGWRK	0
	LAC*	LUNADR	/PICK UP THE POINTER TO THE PDVL
	DAC	CNT
	LAC*	CNT
	SNA		/SKIP IF NOT NONE
	JMP*	ASGWRK	/(OFF)NONE ALREADY, JUST GO BACK
/			/(OFF) REMOVE CHECKS
NOTNON	JMS	SETXR	/ USE XR TO CHECK OLD DEV,#
	LAC	2,X	/NAME CHECK
	DAC	OLDNAM	/(OFF)FETCH OLD NAME
	LAC	5,X	/ NUMBER
	DAC	OLDUNT	/(OFF)FETCH OLD UNIT
/			/(OFF) REMOVE I/O QUEUE BUSY CHECK
	LAC	10,X	/HANDLER INIT'ED
	SZA		/ SKIP IF NOT
	JMP	LUNCK	/ INIT'ED, OK
	DZM* CNT	/ CLEAR THE PDVL POINTER IN THE LUT	/(009)
			/ TO AVOID LOOPING ON ANY ERROR.	/(009)
	LAC	11,X	/ CHOICE OF ERRORS
	SPA		/ REA. INHIBIT ON?
	JMP	ERR7	/YES -- REA. INHIBITED
	LAC	(MES10	/(007) SEND NOT IN CORE MESSAGE
	JMS	OUTMES	/(007)
LUNCK=.			/(OFF)SECTION NOT NEEDED
UPDLUN=.		/SPECIAL CASE TTY STULFF NO LONGER NEEDED
STORNO	CLLR		/(OFF)NEW DEVICE

	LAC	(LUNTAB) /SET UP TO INSERT NODE POINTER

	DAC	LUNADR
SETUP	LAC*	LUNADR	/PICK UP THE LUNT TABLE POINTER
	DAC	TMPA
	LAC*	(LUN1)
	TCA
	DAC	TEMP
	TAD*	LUNADR	/DETERMINE THIS LUN NUMBER
	TAD*	(AFTP1)	/FIND THE  AFT TABLE POINTER
	DAC	TMPB
	LAC	TEMP	/FIND LUN-UFD POINTER
	TAD*	LUNADR
	TAD*	(LUFD1
	DAC	TMPC
	LAC*	LUNADR
	DAC	CNT
	LAC*	CNT	/POINT TO ASSING INHIBIT FALG
	AAC	11
	DAC	CNT
/			/(002)ELIMINATE FILES OPEN MESSAGE
/			/(002)HAPPENS OFTEN; OTHER USER'S FILES.
	.INH		/(008) INHIBIT WHILE CLEAR
	DZM*	TMPA	/(008) KNOWN TO GO TO NONE
	DZM*	TMPC	/(008) KNOWN TO GO TO NONE
	.ENB		/(008)
	LAC*	TMPB	/PICK UP THE DEVICE ATTACHED FLAG
	SNA
	JMP	NOTATT	/NOT ATTACHED TO THE DEVICE OK
	LAC	(MES9	/SET UP TO RETURN A MESSAGE
	JMS	OUTMES	/(007) OUT MESS NOW
NOTATT	LAC	LUNADR
	SAD	LASTUN
	JMP	REQOK	/YES SEARCH FOR CARRTN
	ISZ	LUNADR	/NO CHECK NEXT LUN IN TABLE

	JMP	SETUP	/NO LOOK UNTIL ARE SET

REQOK	LAC	OLDNAM	/IS THE DEV NAME NONE?

	SNA!CLL

	JMP*	ASGWRK	/NO FURTHER WORK FOR NONE

	LAC*	(LUN1)	/PICK UP LUN POINTER

	SKP

NXTNOD	IAC		/CHECK NEXT LUN

	TAD	XADJ	/SET UP XR TO LOOK AT LUN SLOTS

	PAX

	LAC	0,X	/LOOK AT A LUN POINTER

	AAC	2	/POINT TO PDVL NAME

	DAC	CNT

	LAC	OLDNAM	/LOOK FOR A NAME MATCH

	SAD*	CNT

	JMP*	ASGWRK	/ASSIGNMENT FOUND DON'T REQUEST HANDLER TO EXIT

	PXA		/CHECK FOR THE END OF THE TABLE

	TAD	MXADJ	/SUBTRACT PAGE BITS

	SAD*	(LUN2)	/ARE WE AT THE END OF THE TABLE ?

	SKP

	JMP	NXTNOD	/NO TRY ANOTHER ENTRY

	LAC	(400004)	/RAISE TO LEVEL 5 TO PREVENT HANDLER

	ISA		/FROM EXITING BEFORE ALL NODES HAVE BEEN FOUND

	LAC*	(PDVL)

	TAD	XADJ	/ADD PAGE BITS

	PAX		/SAVE IT IN XR

NXTND	LAC	2,X	/PICK UP THE DEVICE NAME

	SAD	OLDNAM	/IS IT THE OLD NAME?

	SKP		/YES SET ASSIGN INHIBIT FLAG

	JMP	NOASGN	/NO DON'T FLAG IT

	PXL		/SAVE LAST NODE ADDRESS

	LAC	11,X	/SET REASSIGN INHIBIT FLAG

	AND	(377777)

	XOR	(400000)

	DAC	11,X	/RESTORE WORD

	LAC	10,X	/SAVE TRIGGER EVENT VARIABLE ADDRESS

	DAC	TRGGR

	DZM	10,X	/CLEAR THE TRIGGER EVENT VARIABLE ADDRESS

NOASGN	LAC	0,X	/IS THIS THE END OF THE TABLE?

	SAD	(PDVL)

	JMP	EXNOD	/YES EXIT

	TAD	XADJ	/ADD PAGE BITS

	PAX

	JMP	NXTND	/SEARCH NEXT NODE

EXNOD	JMS*	(PENP)	/PICK UP A NODE FOR 777 REQUEST

	JMP	ERR5	/EMPTY POOL ERROR

	DAC*	(R2)	/SAVE NODE ADDRESS FOR SPRI

	TAD	XADJ

	PAX

	LAC*	(CURTSK)

	AAC	6	/FIND A GOOD STL NODE ADDRESS

	DAC	CNT

	LAC*	CNT

	DAC	2,X

	DZM	3,X	/CLEAR UNUSED WORDS

	DZM	7,X

	DZM	10,X

	DZM	11,X

	LAC	(1002)	/SET PRIORITY TO 514

	DAC	4,X

	AAC	-3

	DAC	5,X	/SET REQUEST TYPE TO 777

	DZM	6,X	/CLEAR EVENT VARIABLE ADDRESS

	PLA		/PICK UP LAST NODE FOUND FOR 777 REQUEST

	TAD	MXADJ	/SUBTRACT PAGE BITS

	AAC	6	/POINT TO THE QUEUE

	DAC*	(R1)

	JMS*	(SPRI)	/PUT NODE IN REQUEST QUEUE

	DBK		/DEBREAK FORM LEVEL 5

	LAC	(401000)	/SET SIGNIFICANT EVENT

	ISA

	.INH		/INHIBIT INTERRUPTS

	LAC*	TRGGR	/LOOK AT TRIGGER

	AND	(377776)	/MASK OFF BITS

	XOR	(400001)	/SET Q I/O

	.ENB		/ENABLE INTERRUPTS

	DAC*	TRGGR

	JMP*	ASGWRK	/DONE!

	.TITLE	*** STORAGE, CAL'S, MESSAGES, ETC. ***

/

REQCPB	1

	EV

REQNAM	0

	.SIXBT	"..."

	0

/

WAIT	20

	EV

/

EV	0

/

ERR5	LAC	(MES5)

	JMP	TYPMSG

ERR7	LAC	(MES7)

	JMP	TYPMSG
ERR10	LAC	(MES10

	JMP	TYPMSG

/

XADJ	0

MXADJ	0

TEMP	0

UCAXR	0

TTYNUM	0

MESSET	0

USERNO	0

COUNTR	0

STATUS	0

/
MES1	MES5-MES1/2*1000+2
	1
	.ASCII " LOGGING OFF MULTI-ACCESS AT       "<15>
HOURS=MES1+16
MINUTE=MES1+17
MES5	MES7-MES5/2*1000+2

	-5

	.ASCII	"OFF-EMPTY POOL"<15>
MES7	MES9-MES7/2*1000+2
	-7
	.ASCII	"OFF-REASSIGN INHIBITED"<15>
MES9	MES10-MES9/2*1000+2
	11
	.ASCII	"OFF-ASSIGNED, BUT DEVICE IS ATTACHED"<15>
MES10	ENDMSG-MES10/2*1000+2

	-12

	.ASCII	"OFF-OLD DEV NOT YET IN CORE"<15>

ENDMSG=.

/

/

	.END
