	.TITLE CC....-COMMON COMMUNICATOR
/ 
/ 
/                   FIRST PRINTING, FEBRUARY 1974
/ 
/ THE INFORMATION IN THIS DOCUMENT IS SUBJECT TO 
/ CHANGE WITHOUT NOTICE AND SHOULD NOT BE CONSTRUED
/ AS A COMMITMENT BY DIGITAL EQUIPMENT CORPORATION.
/ DIGITAL EQUIPMENT CORPORATION ASSUMES NO RESPON-
/ SIBILITY FOR ANY ERRORS THAT MAY APPEAR IN THIS
/ DOCUMENT.
/ 
/ THE SOFTWARE DESCRIBED IN THIS DOCUMENT IS FUR-
/ NISHED TO THE PURCHASER UNDER A LICENSE FOR USE ON
/ A SINGLE COMPUTER SYSTEM AND CAN BE COPIED (WITH
/ INCLUSION OF DIGITAL'S COPYRIGHT NOTICE) ONLY FOR 
/ USE IN SUCH SYSTEM, EXCEPT AS MAY OTHERWISE BE PRO-
/ VIDED IN WRITING BY DIGITAL.
/ 
/ DIGITAL EQUIPMENT CORPORATION ASSUMES NO RESPONSIBILITY
/ FOR THE USE OR RELIABILITY OF ITS SOFTWARE ON EQUIP-
/ MENT THAT IS NOT SUPPLIED BY DIGITAL.
/ 
/ COPYRIGHT (C) 1974, BY DIGITAL EQUIPMENT CORPORATION
/ 
/ 
        .EJECT
/EDIT 007 1-12-72
/
/W.A. DESIMONE
/
/COPYRIGHT 1971,DIGITAL EQUIPMENT CORP., MAYNARD MASS.
/
/RSX COMMON COMMUNICATOR  HANDLER TASK.
/
/THIS HANDLER TASK COMMUNICATES SYSTEM COMMON
/WITH PROTECTED AND PRIVILEGED TASKS.  COMMUNICATION
/IS ACCOMPLISHED VIA CORE TO CORE BLOCK TRANSFER DIRECTED
/BY QUEUE I/O REQUESTS TO THE COMMON COMMUNICATOR
/HANDLER.  PER QUEUE I/O REQUEST,UP TO 32K OF SYSTEM COMMON
/CAN BE COMMUNICATED WITH.
/
/
/THE FOLLOWING CAL PARAMETER BLOCKS ARE USED TO QUEUE
/REQUESTS FOR COMMON COMMUNICATION SERVICE:
/
/	CPB	3600	/HANDLER INFORMATION (HINF)
/		EV
/		LUN
/
/	CPB	2400	/ATTACH HANDLER
/		EV
/		LUN
/
/	CPB	2500	/DETACH HANDLER
/		EV
/		LUN
/
/	CPB	3000	/COMMON GET-BLOCK TRANSFER
/		EV	/FROM SYS. COMM. TO TASK.
/		LUN
/		CTB	/ADDRESS OF CONTROL TABLE
/
/
/	CPB	3100	/COMMON PUT-BLOCK TRANSFER FROM
/		EV	/TASK TO SYSTEM COMMON.
/		LUN	/
/		CTB	/ADDRESS OF CONTROL TABLE
/
/CONTROL TABLE (CTB) FOR COMMON GET AND PUT QUEUE I/O DIRECT.
/
/	WORD0	.SIXBT SYS	/SIXBIT ASCII NAME OF SYSTEM COMMON
/	WORD1	.SIXBT COM	/BLOCK.
/	WORD2	OFFSET		/SYSTEM COMMON OFF SET
/	WORD3	CA		/CURRENT ADDRESS IN TASK AREA.
/	WORD4	WC		/WORD COUNT (NO. OF WORDS TO TRANSFER).
	.EJECT
/
/THE REQUESTOR'S EVENT VARIABLE IS CLEARED (ZEROED)WHEN
/THE REQUEST IS QUEUED BY THE "QUEUE I/O" DIRECTIVE.  IF THE
/REQUEST CAN BE PREFORMED, THE EVENT VARIABLE IS SET TO ONE
/(C+1) UPON COMPLETION.  IF THE REQUEST CANNOT BE PERFORMED,
/THE EVENT VARIABLE IS SET TO ONE OF THE FOLLOWING NEGATIVE
/VALUES:
/
/
/
/	-6--ILLEGAL REQUEST FUNCTION
/	-24--LUN HAS BEEN REASSINGNED WHILE REQUEST IN QUEUE.
/	-30--I/O PARAMETER OUT OF PARTITION
/	-31--I/O PARAMETER OUT OF SYSTEM COMMON BLOCK
/	-32--NON-EXISTANT SYSTEM COMMON BLOCK
/
/HARDWARE GENERAL REGISTERS
X12=12		/AUTO-INCREMENT REG 12
X13=13		/AUTO-INCREMENT REG 13
/
/IOT DEFINITIONS:
/
.INH=705522	/INHIBIT INTERRUPTS.
.ENB=705521	/ENABLE INTERRUPTS.
/
/
/
/
/RSX REENTRANT PSUEDO-REGISTERS
R1=101
R2=102
R3=103
R4=104
/
/
/RSX REENTRANT ROUTINE ENTRY POINTS:
/
/
NADD=107		/NODE ADDITION
SNAM=123		/NAME SCAN
ALAD=325		/ATTACH LUN AND DEVICE
DLAD=332		/DETACH LUN AND DEVICE 
DQRQ=337		/DE-QUEUE REQUEST
VAJX=342		/VERIFY AND ADJUST I/O TRANSFER PARAMETERS
IOCD=345		/DECREMENT TRANSFERS PENDING COUNT
DMTQ=361		/DEQUE I/O REQ. (FOR ABORT.)
/
/
/SYSTEM INFORMATION
POOL=240		/LISTHEAD FOR POOL OF EMPTY NODES
PDVL=252		/LISTHEAD FOR PHYSICAL DEVICE LIST
SCDL=254		/LISTHEAD FOR SYSTEM COMMON LIST
/
	.EJECT
/CONSTANTS
D.TG=10			/POSITION OF TRIGGER EVENT VARIABLE IN PDVL NODE.
/
/
/DIRECTIVE CAL PAR. BLK.
WFTCPB	20		/WAIT FOR TRIGGER CPB.
	TG
/
/
	.EJECT
/
/	HANDLER INITIALIZATION CODE-ONCE ONLY CODE
/
/
/START		/TEMP
/RN		/REQUEST MODE ADDRESS
/RE		/REQUESTOR'S EVENT VARIABLE ADDRESS.
/SCBASE		/SYSTEM COMMON BASE ADDRESS
/SCSIZE		/SYSTEM COMMON BLK. SIZE
/WC		/TWOS COMPLEMENT WORD COUNT
/TCNT		/LOOP COUNT FOR GET,PUT
/BEGINNING OF ONCE ONLY CODE.
START	LAC	(PDVL)	/SCAN PHYS. DEVICE LIST FOR DEVICE NODE.
RN	DAC*	(R1)	/LISTHEAD TO R1
RE	LAC	(HNAM)	/GET HANDLER NAME TO R2.
SCBASE	DAC*	(R2)	/(R1,R2,R6,XR,AC ALTERED)
SCSIZE	JMS*	(SNAM)	/NODE FOUND?
WC	CAL	(10)	/NO.EXIT
PDVNA	DAC	.	/YES.PDVL NODE ADDRESS IN AC. SAVE
TCNT	AAC	+D.TG	/ADD TRIGGER EVENT VAR. ADDRESS OFFSET
PDVTA	DAC	.	/TRIGGER EVENT VAR. ADDRESS ADDRESS.
	LAC	(TG)	/SET TRIGGER EVENT VARIABLE ADDRESS
	DAC*	PDVTA	/IN PHYSICAL DEVICE NODE
	AND (70000)	/DETERMIN "XR-ADJ."(TWOS COMPL. OF
	TCA		/PAGE BITS).
XADJ	DAC	.	/SAVE
	JMP	WFTGR	/WAIT FOR TRIGGER
HNAM	.SIXBT	"CC@"	/HANDLER NAME
TG	0		/THREE SIXBIT @'S.  TG MUST INIT TO 0
/END OF ONCE ONLY CODE
	.EJECT
/	WAITFOR TASK TO BE TRIGGERED (BY 'I/O CAL" CAL SERV. ROVT.
/	THIS SIGNALS REQUEST HAS BEEN QUEUED.
/
WFTGR	CAL	WFTCPB	/WAIT FOR TRIGGER EVENT VARIABLE TO BE SET.
/
/TASK TRIGGERED--PICK REQUEST FROM QUEUE
	DZM	TG	/CLEAR TRIGGER
/CAL PARAM. BLOCK GETS MAPPED TO FOLLOWING REQUEST NODE.
/
/WORD0		FORWARD PTR.
/WORD1		BACKWARD PTR.
/WORD2		STL PTR.
/WORD3		NOT APPLIC.
/WORD4		PRIORITY
/WORD5		LUN AND FUNCTION CODE
/WORD6		EV ADDRESS
/WORD7		CTB PTR.
/WORD10		EXTRA
/WORD11		EXTRA
/
/
/
PQ	LAC	PDVNA	/DE-QUE REQUEST
	DAC*	(R1)	/PDVL NODE ADDRESS TO R1
	JMS*	(DQRQ)	/(R1,R2,R4,R5,R6,XR,&AC ALTERED).
	JMP	WFTGR	/NO REQUEST--WAIT FOR TRIGGER.
	DAC	RN	/YES. SAVE ADDRESS OF REQUEST NODE.
	TAD	XADJ	/SETUP XR TO PROCESS NODE.
	PAX		/AC-->XR
	LAC	6,X	/SAVE ADDRESS OF REQUESTOR'S EV IF
	SNA		/SPECIFIED (NON-ZERO).
	LAC	(RE)
	DAC	RE
/
	LAC	5,X	/FETCH CAL FUNCTION CODE + DISPATCH.
	AND	(777)
	SAD	(030)	/COMGET?
	JMP	COMGET	/YES
	SAD	(31)	/COMPUT?
	JMP	COMPUT	/YES
	SAD	(24)	/ATTACH?
	JMP	ATTACH	/YES
	SAD	(25)	/DETACH?
	JMP	DETACH	/YES
	SAD	(36)	/HINF?
	JMP	HINF	/YES
	SAD	(777)	/EXIT (DEASSIGNED) REQUEST?
	JMP	DETEXT	/YES.  DETACH AND EXIT.
	SAD	(017)	/ABORT REQ.?
	JMP	CCABRT	/YES.
EVM6	LAW	-6	/NO--UNIMPLEMENTED FUNCTION
	JMP	SEV	/SET EV TO -6
	.EJECT
/
/	ATTACH TO TASK
ATTACH	JMS	COM1	/COMMON SURR. FOR ATTACH/DETACH
	JMS*	(ALAD)	/XCT'ED BY COM1
COM1	0		/NEVER RETURNS THROUGH COM1
	LAC	PDVNA	/PDVNA + RN TO R1,R2
	DAC*	(R1)
	LAC	RN
	DAC*	(R2)	/R3,R4,R5,R6,X10,X11,XR,&AC ALTERED
	XCT*	COM1	/JMS* (ALAD) OR (DLAD)
	JMP	SEV	/HERE WITH AC=-24 IF ALREADY ATTACH OR DETACH.
	JMP	REQCMP	/ATTACHED OR DETACH COMPLETED
/	DETACH FROM TASK
/
DETACH	JMS	COM1
	JMS*	(DLAD)	/XCT'ED BY COM1
			/DOES NOT RETURN HERE.
/RETURN HANDLER INFORMATION IN EVENT VARIABLE
/
HINF	LAC	(300014)	/BIT1=INPUT,BIT2=OUTPUT,BITS12-17 = DEVICE #.
	JMP	SEV
/
/DETACH AND EXIT.  SERVICES REASSIGN REQUEST.
/
DETEXT	JMS	COM3	/COMMON ROUTINE TO RETRN. REQ. NODE
/TO POOL AND DECR. TRANFS. PENDING CNT.
	ISZ	PDVTA	/UNCOND. RETRN.
	.INH		///INHIBIT INTERRUPTS.
	DZM*	PDVTA	///CLEAR ASSIGN INHIB. FLAG.
	.ENB		///ENABLE INTERRUPTS.
	CAL	(10)	///EXIT
/
/FOR I/O RUNDOWN,REMOVE PENDING REQS. FROM TASK-TO-BE-ABORTED'S
/I/O REQ. QUEUE.
/
CCABRT	LAC	5,X	/CHK. ABORT. REQ. FOR 0 LUN.
	AND	(777000)
	SZA		/LUN=0?
	JMP	EVM6	/NO.  ERROR.  RETRN -6 EV.
	LAC	PDVNA	/PDVL NODE ADDRESS.
	DAC*	(R1)
	LAC	RN	/ABORT REQ. NODE ADDR.
	DAC*	(R2)
	JMS*	(DMTQ)	/CLEAN UP QUEUE.
	JMP	REQCMP
	.EJECT
/
/COMGET - TRANSFER FROM SYSCOM TO TASK AREA.
/RETURN FROM COM2 IF NO ERRORS AND WC>0
COMGET	JMS	COM2	/RETURNS WITH 17BIT ADJ. CA-1 IN X12
GETLOP	LAC*	X13	/-WC IN TCNT, SYSCOM CA-1 IN X13
	DAC*	X12
	ISZ	TCNT
	JMP	GETLOP	/CYCLE
	JMP	REQCMP	/DONE!!
/
/COMPUT - TRANSFER FROM TASK AREA TO SYSCOM.
/RETURNS FROM COM2 IF NO ERRORS AND WC>0/
COMPUT	JMS	COM2	/17BIT ADJ CA-1 IN X12,-WC IN TCNT,
PUTLOP	LAC*	X12	/SYSCOM CA-1 IN X13.
	DAC*	X13
	ISZ	TCNT
	JMP	PUTLOP
REQCMP	CLA!IAC		/1 TO AC
SEV	PAL		/LOAD LR.
	LAC	RE	/SET USERS EV.
	TAD	XADJ	/SETUP XR. (17-BIT ADDRESS).
	PAX
	PLA		/EV SETTING BACK TO AC.
	DAC	0,X
	LAC	(401000)	/DECLARE SIGNIF EVENT
	ISA
	JMS	COM3	/COMMON ROUT. TO RETRN REQ. NODE TO POOL
/AND DECR. TRANFS. PENDING CNT.
	JMP	PQ	/UNCOND. RETURN. --DE-QUEUE AGAIN.
/
/COMMON SUBR. USED BY DETEXT AND SEV TO DO INDICATED.
COM3	0
	LAC	(POOL)	/RETRN. REQ NODE TO POOL AND DECR. TRANSF. PEND. CNT.
	DAC*	(R1)
	LAC	RN
	DAC*	(R2)
	JMS*	(IOCD)	/R5,XR,AC ALTERED.
	JMS*	(NADD)
	JMP*	COM3	/UNCOND. RETURN.
	.EJECT
/ROUTINE USED BY COMGET + PUT. TO GET SYSCOM NAME, FIND SCDL
/NODE,SCANCTB. ALTERS X12,X13,AC,R1,R2,R3,R4,X4
/CALLING SEQUENCE:
/	JMS	COM2
/	NEXT	INSTR	/HERE IF NO ERRORS WITH FOLLOWING:
/17-BIT ADJUSTED CA-1 IN X12
/17-BIT SYS COM CA-1 IN X13
/-(WC) IN TCNT (IN LOCAL TO SAVE TIME ON LOOP)
COM2	0
	LAC	7,X	/CTB ADDR-ALSO PTR. TO DBL. WD. SYSCOM NAME
	DAC*	(R3)	/MUST ADJUST TO 17-BITS VIA VAJX.
	LAC	(5)		/5 WC FOR CTB.
	DAC*	(R4)
	LAC	RN		/REQUEST NODE ADDRESS.
	DAC*	(R2)
	JMS*	(VAJX)		/ADJUST.  VAJX ALTERS AC,R3,R5,XR.
	JMP	EVM30		/HERE IF INVALID ADDRESS.
	LAC*	(R3)		/HERE IF OK.
	DAC*	(R2)		/FOR SNAME.
	DAC*	(X12)	/SET UP AUTOXR FOR CTB SCAN.
	LAC	(SCDL)	/SYSCOM LIST HEAD
	DAC*	(R1)
	JMS*	(SNAM)	/R1,R2,R6,XR,AC ALTERED
	JMP	EVM32	/HERE IF SYSCOM NOT FOUND.-32 TO EV.
	AAC	4	/HERE IF FOUND WITH NODE ADDRESS IN AC
	DAC*	(X13)	/-->AUTO INCR13.
	LAC*	X13	/GET SYS.COM. BASE ADDRESS
	DAC	SCBASE	/SAVE
	LAC*	X13	/GET SYS COM. SIZE
	DAC	SCSIZE	/SAVE
	LAC*	X12	/BUMP AUTO-INCRM REGISTER
	LAC*	X12	/SYS COM OFFSET 
	SPA		/POS.?
	JMP	EVM31	/NO-SET EV TO -31
	DAC	START	/SAVE LEGAL OFFSET.
	LAC*	X12	/GET CA TO R3
	DAC*	(R3)
	LAC*	X12	/GET WC TO R4
	DAC*	(R4)	/VAJX ALTERS R3,R5,XR,AC
	LAC	RN	/REQUEST NODE ADDRESS.  TO R2.
	DAC*	(R2)
	JMS*	(VAJX)	/VERIFY AND ADJUST I/O PARAMETERS.
	JMP	EVM30	/HERE IF INVALID TRANSFER - SET EV TO -30
	LAC*	(R3)	/HERE IF OK. WITH 17-BIT ADDRESS IN R3.
	AAC	-1
	DAC*	(X12)	/SET ADJ 17-BIT CA-1 IN AUTO-I 12
	LAC	START	/SAVED OFFSET
	TAD*	(R4)	/+WC
	TCA		/-(OFFSET+WC)
	TAD	SCSIZE	/ADD SYS. COM. SIZE
	SPA
	JMP	EVM31	/OUT OF SYS COM BLOCK
	LAC	SCBASE	/SET SYS. COM(CA-1)INTO AUTO-I 13
	TAD	START
	AAC	-1
	DAC*	(X13)
	LAC*	(R4)	/WC
	SPA!SNA		/ ZERO CASE CHECK.
	JMP	REQCMP	/0, SO TREAT AS NOP.
	TCA		/(-WC)
	DAC	TCNT	/STORE
	JMP*	COM2
EVM30	LAW	-30	/I/O PARAMETER OUT OF PARTION
	JMP	SEV
EVM31	LAW	-31	/OUT OF COMMON CLK
	JMP	SEV
EVM32	LAW	-32	/NON-EXISTANT SYSTEM COMMON BLK.
	JMP	SEV
	.END	START
INSERT A
	AAC	-1
	DAC*	(X12)	/SET ADJ 17-BIT CA-1 IN AUTO-I 12
	LAC*	START	/SAVED OFFSET
	TAD*	(R4)	/+WC
	TCA		/-(OFFSET+WC)
	TAD	SCSIZE	/ADD DYD. COM. SIZE
	SPA
	JMP	EVM32	/OUT OF SYS COM BLOCK
	LAC	SCBASE	/SET SYS. COM(CA-1)INTO AUTO-I 13
	TAD	START
	AAC	-1
	DAC*	(X13)
	LAC*	(R4)	/WC
	SPA!SNA		/-7 ZERO
	JMP	REQCMP	/0, SO TREAT AS NOP.
	TCA		/(-WC)
	DAC	TCNT	/STORE
	JMP*	COM2
