Google
 

Trailing-Edge - PDP-10 Archives - BB-F492Z-DD_1986 - 10,7/703mon/dteprm.mac
There are 12 other files named dteprm.mac in the archive. Click here to see a list.
UNIVERSAL DTEPRM - PARAMETERS FOR DTE20 PROTOCOL - V060
SUBTTL E. SOCCI/EVS/EGF/VJB/SSG	  17 DEC 85

;THIS UNIVERSAL FILE IS ASSEMBLED BEFORE COMDEV OR DTESER IS
; ASSEMBLED. IT CONTAINS SYMBOL AND MACRO DEFINITIONS RELATED
; TO THE OPERATION OF DTESER.  MACROS FROM DTEPRM ARE
; CALLED FROM COMDEV TO GENERATE THE COMMUNICATIONS REGION AND
; THE DTE CONTROL BLOCKS.

;DEFINITIONS ADDED FOR QUEUED PROTOCOL VERSION 2 ON 11 JUL 80

	SEARCH	F,S

;THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY ONLY BE USED
;  OR COPIED IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE.
;
.CPYRT<1976,1986>
;COPYRIGHT (C) 1976,1977,1978,1979,1980,1982,1984,1986
;BY DIGITAL EQUIPMENT CORP., MAYNARD, MASS.
;ALL RIGHTS RESERVED.
;
;
	VDTPRM==060		;VERSION OF DTEPRM GOES IN UNIVERSAL SYMBOL TABLE

;NOTE:
; BE SURE TO INCREMENT THIS VERSION NUMBER EVERY TIME THE FILE IS
; CHANGED TO ENSURE THAT ALL MODULES REQUIRING THE CHANGE WILL
; SEE THE PROPER VERSION NUMBER
SUBTTL 10/11 DTE COMMUNICATIONS REGION
IFDEF TTDBUG,<	XLIST>

;MACRO TO COMPUTE THE WIDTH OF A MASK
;	"WID" RETURNS THE LENGTH OF THE LEFTMOST STRING OF
;	CONSECUTIVE ONES IN THE WORD.
DEFINE	WID(MASK),<<^L<-<<MASK>_<^L<MASK>>>-1>>>

;MACRO TO COMPUTE THE POSITION OF A MASK
DEFINE	POS(MASK),<<^L<MASK>+^L<-<<MASK>_<^L<MASK>>>-1>-1>>

;MACRO TO BUILD A POINTER TO A MASKED QUANTITY
;	POINTR	LOCATION,MASK
DEFINE	POINTR(LOC,MASK),<<POINT	WID(MASK),LOC,POS(MASK)>>

;MACRO TO BUILD A MASK "WID" BITS WIDE, WITH ITS RIGHTMOST BIT
;	IN THE BIT POSITION "POS".   (I.E. A MASK FOR THE BYTE
;	POINTED TO BY THE BYTE POINTER "POINT  WID,LOC,POS")
DEFINE	MASK.(WID,POS),<<<<1_<WID>>-1>B<POS>>>

;MACRO TO DEFINE A SYMBOL WITH ONLY ONE BIT ON, IN THE SAME POSITION AS
;	THE RIGHTMOST BIT IN "MASK" (OR 0, IF "MASK" = 0)
DEFINE RGHBT.(MASK),<<<MASK>&-<MASK>>>

	SUBTTL	SIMPLE STRUCTURE AND LOAD/STORE

;MACROS TO DEFINE AND LOAD/STORE A BYTE LOCATION

;MACRO DEFST. (BYTE NAME, WORD LOCATION, MASK)
; DEFINES THE LOCATION AND SIZE OF THE BYTE

DEFINE	DEFST.(NAM$,LOC$,MASK$),<
	..OLD==10
	..TYP==3
IFE <MASK$>+1,..TYP==0
IFE <MASK$>-^O777777,..TYP==1
IFE <MASK$>-^O777777B17,..TYP==2
..POS==POS(<MASK$>)
..WID==WID(<MASK$>)
	RADIX	10
	DF%%ST (\..TYP,NAM$,<LOC$>,\..POS,\..WID)
	PURGE	..OLD,..TYP,..POS,..WID>

;	THIS IS A HELPER MACRO FOR INTERNAL USE

DEFINE	DF%%ST (TYP$,NAM$,LOC$,POS$,WID$),<
	RADIX	..OLD
DEFINE	NAM$ (OPS,AC,E),<
	..C==0
	IRP	OPS,<
		IFE TYP$-..C,<
			STOPI
			IFN 3-..C, OPS <AC>,LOC$''E
			IFE 3-..C, OPS <AC>,[POINT WID$,LOC$''E,POS$]
		>
	..C==..C+1>
	PURGE	..C>
>

;MACRO LOAD. (AC, BYTE NAME, OPTIONAL LOC)
; WILL LOAD AC WITH THE CONTENTS OF THE BYTE. IF AND ONLY
; NO LOCATION WAS GIVEN IN DEFST., GIVE IT IN LOAD.

;MACRO STOR. IS IDENTICAL EXCEPT THE AC IS STORED INTO THE BYTE.

;MACRO ZERO. IS IDENTICAL (FIRST ARG IGNORED) EXCEPT ZERO IS STORED

DEFINE LOAD. (AC$,STR$,E$),< STR$ (<MOVE,HRRZ,HLRZ,LDB>,<AC$>,<E$>)>
DEFINE STOR. (AC$,STR$,E$),< STR$ (<MOVEM,HRRM,HRLM,DPB>,<AC$>,<E$>)>
DEFINE ZERO. (AC$,STR$,E$),< STR$ (<SETZM,HLLZS,HRRZS,<PRINTX ?CAN'T ZERO BYTE>>,<AC$>,<E$>)>
SUBTTL DTE 10/11 COMMUNICATIONS REGION


;MACRO TO DEFINE A DATA STRUCTURE FOR A GIVEN FIELD.
; CALL IS:	FIELD.(NAME,WIDTH,POSITION,<OPTIONAL VALUE>,<OPTIONAL LOCATION>
; ARGUMENTS:
;	NAME		SIX CHARACTER DATA STRUCTURE NAME
;	WIDTH		SIZE OF FIELD IN BITS.
;	POSITION	POSITION OF RIGHTMOST BIT OF FIELD, DECIMAL
;	VALUE		OPTIONAL, IF SPECIFIED WILL GENERATE A LOCATION
;			  IF USED WITH EWORD., WITH VALUE "VALUE".
;	LOCATION	OPTIONAL, IF SPECIFIED WILL GENERATE A LOCATION
;			  IF USED WITH EWORD., WITH "VALUE"
;			  AS THE CONTENTS
;
; FIELDS OF GREATER THAN LENGTH 1 (BYTE MASKS) CALL DEFST. TO DEFINE
; A MACRO THAT CAN BE USED WITH LOAD./STOR.
;
; FIELDS OF LENGTH 1 DO NOT USE DEFST., BUT DIRECTLY ASSIGN THE 36
; BIT VALUE OF THE BIT POSITION TO THE SYMBOL "NAME".  THIS IS BECAUSE
; THE "TX" MACROS CANNOT BE USED, BECAUSE THEY DO NOT HANDLE EXTERNAL
; SYMBOLS CORRECTLY AND WOULD HAVE TO BE MIXED WITH REGULAR TEST INSTRUCTIONS.
; THEREFORE, DO NOT USE LOAD./STOR. FOR SINGLE BIT VALUES! USE LOAD./STOR.
; TO FETCH THE WORD, AND DO A REGULAR TEST INSTRUCTION USING THE BIT
; VALUE. IF THE VALUE IS IN THE LEFT HALF, USE "()" TO SWAP IT.
; ALTERNATIVELY, ONE CAN DEFINE WORD NAMES (EXAMPLE, ETDSTS) IN ORDER
; TO DO "TDXX" INSTRUCTIONS.
;
; THE SYMBOL ZZ00 (LEVEL 0, TEMP SYMBOL 0) IS USED TO ACCUMULATE
; VALUES FOR A GIVEN WORD. THE MACRO EWORD. WILL CAUSE THESE ACCUMULATED
; VALUES TO BE PLACED IN A LOCATION. IF NO FIELD. MACRO GENERATED A VALUE
; FOR THE CURRENT WORD, THEN EWORD. WILL GENERATE A "BLOCK 1". SEE
; THE EWORD. MACRO FOR FURTHER DETAILS.
;
; "LOCATION" IS USED ONLY FOR BYTE FIELDS AS AN ARGUMENT TO DEFST.

; FIELDS OF LENGTH 1 (BIT ASSIGNMENTS) ARE SIMPLY DEFINED AS VALUES

DEFINE	FIELD.(NAME,WID,POS,VAL,LOC),<MLIST.(S,S) ;LEVEL 0
IFB <LOC> <ZZ01==.>
IFNB <LOC> <ZZ01==LOC>
	ZZ02==MASK.(^D'WID,^D'POS)
IFN ^D'WID-1,<	DEFST.(NAME,\ZZ01,\ZZ02)>;ONLY FOR FIELDS GREATER THAN 1 BIT
IFE ^D'WID-1,<	NAME==ZZ02>;FOR SINGLE BITS, JUST THE BIT NAME
IFNB <VAL> <IF2,<PDEBUG(*NAME='VAL)>>
IFNB <VAL> <
IFNDEF ZZ00,<ZZ00==0>
ZZ00==ZZ00+<VAL>B<POS>>;END IFNB <VAL>
	MLIST.(R)
>;END FIELD. MACRO DEFINITION
;MACRO TO END A WORD WITHIN A DATA STRUCTURE
; ASSUMES ACCUMULATED VALUES HAVE BEEN STORED IN VARIABLE ZZ00
; (LEVEL 0, VARIABLE 0).  IF NO VALUES HAVE BEEN ACCUMULATED FOR A WORD,
; THEN A "BLOCK 1" IS GENERATED.
IFDEF ZZ00,<
	PURGE	ZZ00		;ASSUMPTION IS MADE THAT IF ZZ00
>;END IFDEF ZZ00
; IS DEFINED, THEN A VALUE FOR A FIELD HAS BEEN SPECIFIED (EVEN IF
; THAT VALUE IS ZERO) SO WE MUST PURGE ZZ00 TO MAKE SURE ITS NOT
; DEFINED THE FIRST TIME EWORD. IS USED.  ZZ00 IS PURGED AFTER EVERY
; CALL TO EWORD. LISTING CONTROL MACRO MLIST. IS USED TO SUPPRESS
; EWORD. MACRO EXPANSION IN LISTING, AND OLD LISTING CONTROL IS RESTORED
; AFTER MACRO DOES ITS WORK.
; EWORD. IS USED IN CONJUNCTION WITH FIELD.

DEFINE EWORD.<MLIST.(S,S) ;LEVEL 0
IFNDEF ZZ00,<BLOCK 1>
IFDEF ZZ00,<	ZZ00>
IFDEF ZZ00,<PURGE ZZ00>
	MLIST.(R)
>





;MACRO TO CONVERT FROM A BYTE COUNT OF ONE SIZE TO A BYTE COUNT
; OF ANOTHER SIZE.  DEFAULT ORIGINAL SIZE IS 8 BITS.  NEW SIZE MUST
; BE LARGER THAN ORIGINAL SIZE.
;
;MACRO GENERATES VALUE OF NEW BYTE COUNT

DEFINE SIZE(THING,NEWSIZ,OLDSIZ<8>)
<<THING+<^D'NEWSIZ/^D'OLDSIZ-1>>/<^D'NEWSIZ/^D'OLDSIZ>>
;MACRO TO CONTROL MACRO EXPANSION LEVEL
;  CONTAINS FEATURE TO TEMPORARILY SALL AN UNINTERESTING LOW LEVEL
;  MACRO EXPANSION.  THIS FEATURE WORKS FOR ONE LEVEL ONLY. TO
;  RESTORE THE SAVED LEVEL, CALL IS MLIST.(R).  TO SAVE THE LEVEL,
;  CALL IS MLIST(ARG,S).
;  VALUES FOR FIRST ARGUMENT:
;	X		XALL
;	S		SALL
;	L		LALL
;	R		RESTORE LAST LISTING LEVEL (ONE LEVEL ONLY)
;  VALUES FOR SECOND ARGUMENT
;	(BLANK)		DON'T SAVE CURRENT LEVEL
;	(NON-BLANK)	SAVE CURRENT LEVEL

DEFINE	MLIST.(ARG,SAVE)<SALL
IFNB <SAVE>, <%.MLST==%.MCUR>
IFIDN <ARG> <S>, <%.MCUR==<'SALL'>>
IFIDN <ARG> <L>, <%.MCUR==<'LALL'>>
IFIDN <ARG> <X>, <%.MCUR==<'XALL'>>
IFIDN <ARG> <R>, <%.MCUR==%.MLST>
IFE %.MCUR^!<'SALL'>,<DEFINE MLST1.<SALL>>
IFE %.MCUR^!<'XALL'>,<DEFINE MLST1.<XALL>>
IFE %.MCUR^!<'LALL'>,<DEFINE MLST1.<LALL>>
	MLST1.>;END MLIST. MACRO DEFINITION

;DEFINE INITIAL LEVEL OF MACRO LISTING
DEFINE %.MSET(ARG),<ARG
		%.MLST==''ARG''
		%.MCUR==''ARG''>;END %.MSET MACRO DEFINITION

IFNDEF DEBUG,<%.MSET(SALL)>
IFDEF DEBUG,<%.MSET(LALL)>

;MACRO TO DO A PRINTX IF DEBUG SYMBOL IS DEFINED

DEFINE PDEBUG(TEXT),<IFDEF DEBUG,<MLIST.(L)
	PRINTX	TEXT
	MLIST.(R)
>;END IFDEF DEBUG
IFDEF TTDBUG,<MLIST.(L)
;'TEXT
MLIST.(R)
>;END IFDEF TTDBUG
>;END PDEBUG MACRO DEFINITION
;MACRO TO CALL A MACRO FOR EACH OF A NUMBER OF PROCESSORS
;  ARGUMENTS:
;	X	NUMBER OF PROCESSORS
;	DO	WORKER MACRO.  MAY REFERENCE COUNTING VARIABLE, IF
;		  ARGUMENT Y (SEE BELOW) IS SPECIFIED NON-BLANK
;	Y	IF NON-BLANK, THE NAME OF THE ARGUMENT IS ACCESSIBLE
;		  TO THE WORKER MACRO
;	XBACK	IF SPECIFIED NON-BLANK, WILL CAUSE NUMBERING TO GO BACKWARDS


DEFINE	ETPDOX(X,DO,Y,XBACK)<
IFNB <Y> <
IFB <XBACK> <Y==0>
IFNB <XBACK> <Y==<X-1>>
>;END IFNB Y
	REPEAT	X,<
	DO
IFNB <Y> <
IFB <XBACK> <Y==Y+1>
IFNB <XBACK> <Y==Y-1>
>;END IFNB Y
>;END REPEAT X
>;END ETPDOX MACRO DEFINITION
;MACRO TO DEFINE THE COMMUNICATIONS REGION HEADER
;  ALSO GENERATE SYMBOLS ETNM"X""Y" EQUAL TO PROTOCOL PROCESSOR NUMBER
;  WHERE X IS 10 PROCESSOR AND Y IS EITHER 0 (REPRESENTING 10 PROCESSOR)
;  OR NONZERO (REPRESENTING 11).  THESE SYMBOLS HELP BUILD THE REST
;  OF THE COMM REGION BY SERVING AS A MAP FROM 10 PROCESSOR - DTE
;  TO PROTOCOL PROCESSOR NUMBER
;  CALLED ONLY ONCE WHEN DEFINING COMMUNICATIONS REGION


DEFINE ETHEAD< ;LEVEL 5
PDEBUG(****BEGIN REGION HEADER)
ETCHED::ETPDOX(CPUN,<ETHED1(\ZZ43)>,ZZ43,1)
PDEBUG(****END REGION HEADER)
PDEBUG()
>;END ETHEAD DEFINITION

DEFINE ETHED1(N10)< ;LEVEL 3
IFDEF M'N10'DTEN,<
	ETPDOX(<M'N10'DTEN+1>,<ETHED2(\ZZ43,\ZZ24)>,ZZ24,1)
>;END IFDEF M'N10'DTEN
>;END ETHED1 MACRO DEFINITION

DEFINE ETHED2(N10,N11)< ;LEVEL 1
	DEFINE	X(A)<ZZ10==ETO'A>	;CONVERT PROTOCOL PROCESSOR NUMBER TO 
					;  RELATIVE ADDRESS OF AREA
IF2,<;ETNM'N10'N11 IS NOT DEFINED UNTIL ETREGN IS CALLED
	X(\ETNM'N10'N11)
	FIELD.(EH.PRN,8,11,ETNM'N10'N11,0)	;  PROCESSOR NUMBER
	FIELD.(EH.RLA,22,35,ZZ10,0)		;  RELATIVE ADDRESS OF THIS
						;    PROCESSORS COMM AREA
>;END IF2

	EWORD.
>;END ETHED2 MACRO DEFINITION
;MACRO TO DEFINE A COMPLETE COMMUNICATIONS REGION
;  THIS MACRO AND ETHEAD COMPLETELY GENERATE THE COMPLETE
;  COMMUNICATIONS REGION.  SYMBOLS THAT MUST BE DEFINED BY
;  MONGEN:
;	CPUN		NUMBER OF CPUS
;	DTE"X"N		NUMBER OF DTES ON CPU "X"


DEFINE ETREGN(COMVER,PROVER)< ;LEVEL 8
PDEBUG(****BEGIN REGION)
ETCRGN::ZZ80==0			;ZZ80 WILL ALLOCATE PROTOCOL PROCESSOR NUMBERS

	ETPDOX(CPUN,<ETREG1(COMVER,PROVER,\ZZ70)>,ZZ70)
PDEBUG(****END REGION)
PDEBUG()
ETCEND::ETCSIZ==:.-ETCRGN	;SIZE OF COMM REGION IN WORDS
>;END ETREGN MACRO DEFINITION

DEFINE ETREG1(COMVER,PROVER,N10)< ;LEVEL 6
	ETPDOX(<M'N10'DTEN+1>,<ETAREA(COMVER,PROVER,N10,\ZZ50)>,ZZ50)
>;END ETREG1 MACRO DEFINITION
;MACRO TO DEFINE A COMPLETE COMMUNICATIONS AREA
;  THIS MACRO IS CALLED FOR EACH 10 OR 11 PROCESSOR IN THE
;  SYSTEM TO GENERATE ITS COMM AREA.


DEFINE ETAREA(COMVER,PROVER,N10,N11)< ;LEVEL 4

PDEBUG(***BEGIN 10#'N10 11#'N11 AREA)
	ETNM'N10'N11==ZZ80		;ZZ80 IS ETREGN'S PROCESSOR COUNTER
	ZZ80==ZZ80+1			;NEXT PROCESSOR NUMBER
	ZZ40==M'N10'DTEN+1
IFE N11,<ETOSEC(1,COMVER,PROVER,\ZZ40,,\ETNM'N10'N11,N10)>
IFN N11,<ETOSEC(0,COMVER,PROVER,2,,\ETNM'N10'N11,N10)>

IFE N11,<ETPDOX(<M'N10'DTEN>,<ETARE1(N10,\ZZ33+1,\ZZ33)>,ZZ33)>
IFN N11,<;ASSUMES EACH 11 IS CONNECTED TO ONE AND ONLY ONE DTE20/KL10
	ET2SEC(1,1,N11-1,\ETNM'N10'0)
>;END IFN N11
PDEBUG(***END 10#'N10 11#'N11 AREA)
PDEBUG()
>;END ETAREA MACRO DEFINITION

DEFINE ETARE1(N10,N11,NDTE)< ;LEVEL 2
	ET2SEC(0,1,NDTE,\<ETNM'N10'N11>)
>;END ETARE1 DEFINITION
;MACRO TO DEFINE THE OWNING PROCESSOR'S SECTION OF
;  A COMMUNICATIONS AREA
;ARGUMENTS:
;	TEN		NON-ZERO IF THIS AREA IS OWNED BY A TEN
;	COMVER		COMMUNICATIONS AREA VERSION NUMBER
;	PROVER		PROTOCOL VERSION NUMBER
;	NUMPRO		NUMBER OF PROCESSORS REPRESENTED IN THIS AREA,
;			  INCLUDING OWNING PROCESSOR
;	PRONAM		NAME OF OWNING PROCESSOR (SERIAL NUMBER)
;	PRONUM		PROTOCOL PROCESSOR NUMBER OF OWNING PROCESSOR


DEFINE ETOSEC(TEN,COMVER,PROVER,NUMPRO,PRONAM<0>,PRONUM,N10)< ;LEVEL 1
PDEBUG(**BEGIN OWNING SECTION)
	ETO'PRONUM==.-ETCRGN
	DEFINE	X(A)<ETO'A>

	PHASE	0


ETCREA::!				;START OF EACH AREA
ETCPID::!				;OWNING PROCESSOR'S ID WORD
	FIELD.(EC.OIX,1,0,TEN)		;  OWNING PROCESSOR IS A TEN
	FIELD.(EC.CVR,3,3,COMVER)	;  COMMUNICATIONS AREA VERSION NUMBER
	FIELD.(EC.PVR,6,11,PROVER)	;  PROTOCOL VERSION NUMBER
	FIELD.(EC.NPR,5,16,NUMPRO)	;  NUMBER OF PROCESSORS REPRESENTED IN THIS
					;    AREA, INCLUDING OWNING PROCESSOR
	FIELD.(EC.OSZ,3,19,ETOSIZ+<NUMPRO-1>*ET2SIZ)	
					;  SIZE OF ENTIRE OWNERS AREA, IN 8 WORD BLOCKS
	FIELD.(EC.ONM,16,35,PRONAM)	;  NAME OF OWNING PROCESSOR (SERIAL NUMBER)
	EWORD.
;;------------------------------------------------------------------------


ETCNCA::!
IF2,<;CAN ONLY GENERATE LINKS ON PASS 2
	ZZ10=='PRONUM+1
	DEFINE	X(A),<IFNDEF ETO'A,<ZZ11==ETO0>	;FOR LAST LINK
		     IFDEF ETO'A,<ZZ11==ETO'A>>;END X MACRO DEFINITION
	X(\ZZ10)			; GET VALUE OF ETO SOMETHING
					;   INTO ZZ11
	FIELD.(EC.NCA,18,35,\ZZ11)	; REGION RELATIVE POINTER TO NEXT COMM AREA
					;  (CIRCULAR LIST)
>;END IF2

	EWORD.
;;------------------------------------------------------------------------

ETCCPN::!				;CPU NUMBER ALA SMP, BUT PLUS ONE.
					; NOW, PDP-11 CAN EXAMINE IT'S
					; "OWN" AREA AND FIND OUT WHICH CPU
					; IT IS ON
					;ALSO CONTAINS SYSTEM TYPE (ALA TOPS10,
					; TOPS20, ITS, ETC), SO THAT RSX20F
					; CAN KNOW...

		.CNT10==1	;NICE MNEMONIC

	FIELD.(EC.SST,4,3,.CNT10)	;LET RSX KNOW WE ARE A TOPS-10
	FIELD.(EC.CPN,8,35,N10+1)

	EWORD.
;;------------------------------------------------------------------------
	EWORD.				;UNUSED
;;------------------------------------------------------------------------
	EWORD.				;UNUSED
;;------------------------------------------------------------------------

ETCKAC::!				;KEEP ALIVE COUNT THAT THIS
					; PROCESSOR INCREMENTS
	EWORD.
;;------------------------------------------------------------------------

	EWORD.				;UNUSED
;;------------------------------------------------------------------------
	EWORD.				;UNUSED
;;------------------------------------------------------------------------
	BLOCK	^D8		;ANOTHER 8 WORD BLOCK IS REQUIRED
;;------------------------------------------------------------------------

	ETOSIZ==<<.-ETCREA+^D7>/^D8>	;SIZE OF OWNED SECTION IN 8 WORD BLOCKS

	DEPHASE
PDEBUG(**END OWNING SECTION)
PDEBUG()
>;END ETOSEC MACRO DEFINITION


;MACRO TO DEFINE MULTIPLE NUMBER OF SECTIONS WITHIN AN AREA.
; CALLED FOR EACH TO-PROCESSOR SECTION OF A COMM AREA.
; MUST BE USED AT LEAST ONCE IMMEDIATELY AFTER ETOSEC MACRO TO COMPLETE A
; COMMUNICATIONS AREA.  CHANGES IN THE COMM AREA FOR QPR V2 ARE INDICATED
; BY A (QP2) FOLLOWING THE COMMENT.
; ARGUMENTS:
;	TEN		NON-ZERO IF THIS IS FOR A 10
;	DTECON		NON-ZERO IF THERE IS A DTE CONNECTION BETWEEN
;			  THIS PROCESSOR AND OWNING PROCESSOR
;	DTENUM		DTE NUMBER IF DTECON IS NON-ZERO
;	FORNUM		NUMBER OF THE TO PROCESSOR
;	PROTYP		TYPE OF PROTOCOL (0 = RSX-20F, 1 = MCB)

DEFINE ET2SEC(TEN,DTECON,DTENUM,FORNUM,PROTYP),< ;LEVEL 1
PDEBUG(**BEGIN TO SECTION)
	PHASE	0

ETCSEC::!				;STARTING TO SECTION
	FIELD.(EC.TIX,1,0,TEN)		;  TO-PROCESSOR IS A TEN BIT
	FIELD.(EC.DCE,1,1,DTECON)	;  NON-ZERO IF DTE CONNECTS THESE
					;    TWO PROCESSORS
	FIELD.(EC.DTN,2,3,DTENUM)	;  DTE NUMBER OF DTE, IF ANY
	FIELD.(EC.PRT,5,16,PROTYP)	;  PROTOCOL TO BE USED	(QP2)
	FIELD.(EC.SSZ,3,19,ET2SIZ)	;  SIZE OF THIS SECTION, IN 8
					;    WORD BLOCKS
	FIELD.(EC.TPN,16,35,FORNUM)	;  TO PROCESSOR NUMBER
	EWORD.
;;------------------------------------------------------------------------

ETC2PA::!FIELD.(EC.2PA,18,35,ETO'FORNUM) ;TO-PROCESSORS COMM AREA POINTER
					;  RELATIVE TO COMM REGION ORIGIN
	EWORD.
;;------------------------------------------------------------------------

ETCSTS::!				;STATUS WORD FOR TRANSFERS TO
					; "TO-PROCESSOR"
	FIELD.(EC.PWF,1,0)		;   "OUR POWER FAILED" BIT
	FIELD.(EC.LOD,1,1)		;   "LOAD ME" BIT
	FIELD.(EC.INI,1,2)		;  "INITIALIZE" HANDSHAKING BIT	(QP2)
	FIELD.(EC.VEX,1,3,1)		;  "VALID EXAMINE" BIT, 11 CHECKS
					;    THIS WORD ON EVERY EXAMINE OF STATUS,
					;    IF ITS ZERO GOES TO SECONDARY
					;    PROTOCOL IF POSSIBLE (PRIVILEGED)
	FIELD.(EC.QIU,1,13)		;  QUEUED PROTOCOL IN USE
	FIELD.(EC.16B,1,17)		;  TO-PROCESSOR TRANSFER IS IN
					;    16 BIT MODE
	FIELD.(EC.IND,1,18)		;  CURRENT TO-PROCESSOR TRANSFER IS
					;    INDIRECT.
	FIELD.(EC.2IT,1,19)		;  TO-PROCESSOR TRANSFER IS IN PROGRESS
	FIELD.(EC.RCV,1,19)		;  KNOWN AS RCV IN QPR V2.	(QP2)
	FIELD.(EC.10C,8,27)		;  TO10IC, INCREMENTED AT START
					;    OF EVERY TO-10 TRANSFER IN 11 COMM AREA
	FIELD.(EC.11C,8,35)		;  TO11IC, INCREMENTED AT START OF
					;    EVERY TO-11 TRANSFER IN 10 AREA

; THE FOLLOWING TWO FIELDS ARE ANALOGOUS TO EC.11C & EC.10C, BUT THEY ARE
; FOR QP2 ONLY.

	FIELD.(EC.CPQ,8,27)		;  CPQCNT, OWNING PROCESSOR'S COPY OF
					;   THIS TO-PROCESSOR'S QCOUNT
	FIELD.(EC.QCT,8,35)		;  QCOUNT, INCREMENTED BY OWNING
					;   PROCESSOR AT START OF NEW XFER
	EWORD.
;;------------------------------------------------------------------------

ETCQSZ::!				;TO-PROCESSOR QUEUE SIZE
	FIELD.(EC.TMD,4,3)		;  TRANSFER MODE TYPE	(QP2)
	FIELD.(EC.PSZ,16,19)		;  ENTIRE PACKET SIZE	(QP2)
	FIELD.(EC.QSZ,16,35)		;  QUEUE SIZE FIELD
	FIELD.(EC.CSZ,16,35)		;  CURRENT TRANSFER SIZE (QP2)
	EWORD.
;;------------------------------------------------------------------------

ETCRLD::!				;MEMORY FOR RELOAD PLACE FOR
					; TO-PROCESSOR
	FIELD.(EC.RLD,35,35)		;  BIT 0 DOES NOT BELONG TO THIS FIELD
	EWORD.
;;------------------------------------------------------------------------

ETCCKA::!				;OWNING PROCESSORS COPY OF
					; KEEP ALIVE COUNT IN TO PROCESSORS
					;  AREA.
	FIELD.(EC.CKA,35,35)		;  THE FIELD.
	EWORD.
;;------------------------------------------------------------------------

	BLOCK	2		;REMAINDER UNUSED.

	ET2SIZ==<<.-ETCSEC+^D7>/^D8>	;SIZE OF THIS SECTION IN 8 WORD BLOCKS

	DEPHASE
PDEBUG(**END TO SECTION)
PDEBUG()
>;END ET2SEC MACRO DEFINITION
SUBTTL FRONT END DEVICE CONTROL BLOCK DEFINITION
	.FEALC==^D256		;FE ALLOCATION IS 128 8 BIT BYTES LONG
	.FEISZ==.FEALC*2/2	;SIZE OF FED INPUT BUFFER IN 16 BIT BYTES.
				; NOTE THAT IT IS TWICE AS BIG AS THE
				; ALLOCATION TO SOLVE RACE CONDITION MENTIONED
				; IN FEDSER.
	.FEOSZ==.FEALC/2	;OUTPUT FED BUFFER SIZE IN 16 BIT BYTES
IFGE <.FEOSZ*2>-400,<
	.FEOSZ==374/2		;CAN'T SEND OVER MORE THAN 255 BYTES
>;END IFGE .FEOSZ*2-400
IFN <.FEOSZ/2*2>-.FEOSZ,<.FEOSZ==.FEOSZ-1>
				;BUFFER SIZE MUST BE EVEN TO RELIEVE
				; OUTPUT UUO CODE FROM HAVING TO
				; CARRY AN ODD BYTE WHILE WAITING
				; FOR MORE BUFFER SPACE
	.FEMXU==4-1		;MAXIMUM OF 4 FRONT END DEVICES ON FRONT END
	.FESMS==3		;NUMBER OF 16 BIT BYTES TO TAKE ON STATUS


DEFINE FEDGEN<
	ETPDOX(CPUN,<FEDGN1(\ZZ60)>,ZZ60)
>;END FEDGEN MACRO DEFINITION

DEFINE FEDGN1(N10)<
	ETPDOX(<M'N10'DTEN>,<FEDGN2(N10,\ZZ40)>,ZZ40)
>;END FEDGN1 MACRO DEFINITION

DEFINE FEDGN2(N10,NDTE)<
	DEFINE	X(A)<ZZ30==M.FD'N10''A>
	X(\<NDTE+1>)
	ETPDOX(<ZZ30>,<FEDBLK(N10,NDTE,\ZZ20)>,ZZ20)
>;END FEDGN2 MACRO DEFINITION



DEFINE FEDBLK(N10,NDTE,UNI)<
FED'N10'NDTE'UNI'::!
	PHASE	0

FEDSTS:!				;STATUS WORD
	FIELD.(FE.EOF,1,0)		;  EOF BIT.
	FIELD.(FE.OAE,1,2)		;  BUFFER AVAILABLE FOR OUTPUT TO 11.
					;    SET BY UUO LEVEL, CLEARED BY INTERRUPT LEVEL
	FIELD.(FE.FER,1,3)		;  FATAL ERROR FOR FRONT END DEVICE
		FE.CLR==FE.EOF!FE.OAE!FE.FER	;BITS TO CLEAR



	FIELD.(FE.CPN,3,20,N10)		;  CPU NUMBER
	FIELD.(FE.DTN,3,23,NDTE)	;  DTE NUMBER
	FIELD.(FE.UNI,3,26,UNI)		;FRONT END DEVICE UNIT NUMBER

	EWORD.
;;------------------------------------------------------------------------
	FIELD.(FE.JOB,9,8)		;  JOB NUMBER OWNING FED
	FIELD.(FE.BAO,9,26)		;  BYTES AVAILABLE FOR OUTPUT TO 11

	EWORD.
;;------------------------------------------------------------------------
FEDTPT:!	BLOCK	1			;POINTER USED TO TAKE DATA FROM 
					; FED INPUT BUFFER
;;------------------------------------------------------------------------
FEDPPT:!	BLOCK	1			;POINTER USED TO PUT DATA INTO FRONT END DEVICE INPUT BUFFER
;;------------------------------------------------------------------------
FEDFBI:!	BLOCK	1			;NUMBER OF BYTES FREE IN FED INPUT BUFFER
;;------------------------------------------------------------------------
IF2,<
	DEFINE	X(A,B)<
	IFLE	M.FD'N10''A-<UNI+1>,<ZZ10==0>
	IFG	M.FD'N10''A-<UNI+1>,<ZZ10==FED'N10'NDTE''B>
>;END X MACRO DEFINITION
	X(\<NDTE+1>,\<UNI+1>)
>;END IF2
	FIELD.(FE.LNK,18,17,ZZ10)	;  LINK TO NEXT FED ON THIS FRONT END

	EWORD.
;;------------------------------------------------------------------------
FEDIBF:!BLOCK	1		;  ADDRESS OF FED INPUT BUFFER
;;------------------------------------------------------------------------
FEDOBF:!BLOCK	1		;  ADDRESS OF FED OUTPUT BUFFER
;;------------------------------------------------------------------------
FEDSOB:!BLOCK	.FESMS/<^D36/^D16>
;;------------------------------------------------------------------------


	DEPHASE
>;END FEDBLK MACRO DEFINITION
SUBTTL KL ERROR CORE CHUNK DEFINITIONS
	.KLETM==^D5			;MINUTES AFTER THE LAST KL ERROR
					; STATUS MESSAGE TO WAIT BEFORE
					; RELEASING THE FREE CORE BY
					; DISCARDING THE KL ERROR DATA

	PHASE	0

.KEBEG:!				;BEGINNING OF KL ERROR BLOCK
	FIELD.(KE.DEV,9,8)		;  DEVICE CODE
	FIELD.(KE.LIN,9,17)		;  LINE (UNIT) NUMBER
	FIELD.(KE.CNT,18,35)		;  COUNT OF DATA, IN 8 BIT BYTES

	EWORD.
;;------------------------------------------------------------------------
	FIELD.(KE.CPU,9,8)		;  CPU NUMBER
	FIELD.(KE.DTE,9,17)		;  DTE NUMBER
	FIELD.(KE.LNK,18,35)		;  LINK TO NEXT BLOCK

	EWORD.
;;------------------------------------------------------------------------

	.KEHDL==<.-.KEBEG>*<^D36/^D8>	;SIZE OF HEADER IN 8 BIT BYTES

	FIELD.(KE.1WD,16,15)		;  FIRST 16 BIT BYTE

	EWORD.
;;------------------------------------------------------------------------

	DEPHASE
SUBTTL DTE DEFINITIONS

;DTE DEVICE CODES

	DTE0==200
	DTE1==204
	DTE2==210
	DTE3==214

;EPT LOCATIONS

	PHASE	140

DTEHBG:			;BEGINNING OF DTE20 HARDWARE EPT LOCATIONS
DTEEBP:	BLOCK	1		;TO-11 BYTE POINTER
DTETBP:	BLOCK	1		;TO-10 BYTE POINTER
DTEDII:	BLOCK	1		;INTERRUPT LOCATION
	BLOCK	1		;UNUSED
DTEEPW:	BLOCK	1		;EXAMINE PROTECTION WORD
DTEERW:	BLOCK	1		;EXAMINE RELOCATION WORD
DTEDPW:	BLOCK	1		;DEPOSIT PROTECTION WORD
DTEDRW:				;DEPOSIT RELOCATION WORD
DTEHBE:	BLOCK	1		;END OF DTE20 HARDWARE EPT LOCATIONS
	DEPHASE


;DTE20 CONO BITS (NAMES FROM KL10 EFS CHAP 4.3)


	TO11DB==1B22		;TO -11 DOOR BELL
	CR11B==1B23		;CLEAR RELOAD -11 BUTTO0
	SR11B==1B24		;SET RELOAD -11 BUTTON
	CL11PT==1B26		;CLEAR -11 REQUESTING A 10 INTERRUPT BIT
	TO11ER==1B27		;TO -11 ERROR
	CLTO11==1B29		;CLEAR TO -11 NORMAL TERMINATION FLAG (TO11DN)
	CLTO10==1B30		;CLEAR TO -10 NORMAL TERMINATION FLAG (TO10DN)
	PILDEN==1B31		;ENABLE LOADING PIA
	PI0ENB==1B32		;PI0 ENABLE
	PIA==7B35		;PIA

;DTE20 CONI BITS 
	RM==1B20		;RESTRICTED MODE 11
	DEAD11==1B21		;11 POWER FAILURE
	TO11DB==1B22		;TO -11 DOORBELL PRESSED
	TO10DB==1B26		;TO -10 DOORBELL
	TO11ER==1B27		;ERROR OCCURRED DURING TO-11 XFER (CLEARED BY CLTO11)
	TO11DN==1B29		;TO -11 NORMAL TERMINATION
	TO10DN==1B30		;TO -10 NORMAL TERMINATION
	TO10ER==1B31		;TO -10 ERROR
	PI0ENB==1B32		;PI0 ENABLE
	PIA==7B35		;PIA

;DTE20 DATAO DEFINITIONS

	TO10IB==1B23		;"I" BIT, SAYS INTERRUPT 11 AFTER XFER
	TO10BC==7777B35		;TO-10 BYTE COUNT FIELD

	CLRDTE==CR11B+CL11PT+CLTO11+CLTO10		;CLEAR OUT A DTE WITH CONO THESE BITS


SUBTTL SECONDARY PROTOCOL DEFINITIONS

;SECONDARY PROTOCOL COMMAND FIELDS

	DT.MTO==10B27		;CTY OUTPUT
	DT.ESP==11B27		;ENTER SECONDARY PROTOCOL
	DT.LSP==12B27		;LEAVE SECONDARY PROTOCOL
	  DT.RST==1B35		;  WHEN LEAVING SECONDARY PROTOCOL,
				;    THIS BIT SET TO INDICATE COMM REGIONS WERE RESET
	DT.GDT==13B27		;GET DATE/TIME
	  ;BITS 4-19 ARE EPT OFFSET TO STORE RESULT (3 WORDS)

;TO PROVIDE FOR EXTENDING SECONDARY PROTOCOL WITHOUT CRASHING PRIOR
;VERSIONS OF -20F, DTEMTD (ALWAYS DEFINED AS NON-ZERO WHEN TTY OUTPUT DONE)
;HAS BEEN REDEFINED AS FOLLOWS:

	DF.GDT==1B35		;ZERO IF DT.GDT SUPPORTED
	DF.CSH==1B34		;CACHE WAS ENABLED BY KLI
	;33-19			;RESERVED FOR NEW FEATURES
	DF.ODN==1B20		;TERMINAL OUTPUT DONE

	PHASE	444		;START OF SECONDARY PROTOCOL EPT LOCATIONS
DTEFLG:	BLOCK	1		;COMMAND COMPLETE FLAG
	BLOCK	3		;UNUSED
DTEF11:	BLOCK	1		;FROM 11 DATA
DTECMD:	BLOCK	1		;COMMAND WORD
	BLOCK	3		;UNUSED
DTEMTD:	BLOCK	1		;OUTPUT DONE FLAG
DTEMTI:	BLOCK	1		;INPUT READY FLAG

	DEPHASE
SUBTTL DTE CONTROL BLOCK GENERATION MACRO

DEFINE ETDGEN<
ETPDOX(CPUN,<ETDGN1(\ZZ40)>,ZZ40)
>;END ETDGEN MACRO DEFINITION


DEFINE ETDGN1(N10)<
ETPDOX(<M'N10'DTEN>,<DTEBLK(N10,\<ZZ20+1>)>,ZZ20)
>;END ETDGN1 MACRO DEFINITION

SUBTTL DTE CONTROL BLOCK MACRO DEFINITION

DEFINE DTEBLK(N10,N11),<
IFN N11,<
PDEBUG(**BEGIN DTE BLOCK 'N10'N11)
ETD'N10'N11'B::
	PHASE	0
ETDINT:!0
	0
	EXP	IC.UOU
	EXP	ETD'N10'N11'B+.-ETDINT+1
	DMOVEM	F,D'N10'N11'SAC##+F
	DMOVE	F,ETD'N10'N11'B+ETDINT
	DMOVEM	F,D'N10'N11'CHL##
	DMOVE	F,D'N10'N11'SAC+F

	JSR	D'N10'N11'SAV##	;SAVE AC'S
	MOVEI	F,ETD'N10'N11'B+ETDINT
	PJRST	DTEINT##	;PROCESS INTERRUPT

ETDNAM:!FIELD.(ED.NAM,36,35,<SIXBIT/DTE'N10'N11/>)

	EWORD.
;;------------------------------------------------------------------------

ETDSTS:!				;GENERAL STATUS OF DTE

	FIELD.(ED.2ES,3,2)		;  TO-11 DTE STATE CODE

	ED.EID==0			;    TO-11 IDLE
	ED.EDB==1			;    WAITING FOR TO-11 DONE FOR
					;     A DIRECT TRANSFER
					;    (USED FOR MCB PROTOCOL ALSO)
	ED.EIB==2			;    WAITING FOR TO-11 DONE
					;     FOR AN INDIRECT TRANSFER

	FIELD.(ED.2TS,2,5)		;  TO-10 DTE STATE CODE

	ED.TID==0			;    TO-10 IDLE
	ED.TDB==1			;    WAITING FOR TO-10 DONE FOR
					;     A DIRECT TRANSFER
	ED.TWD==2			;    WAITING FOR TO-10 DOORBELL
					;     INDICATING 11 HAS SETUP
					;     FOR A TO-10 INDIRECT XFER
	ED.TIB==3			;    WAITING FOR TO-10 DONE ON
					;     INDIRECT TRANSFER

; IN QUEUED PROTOCOL VERSION 2, THESE VALUES MEAN:

;	ED.TIB==0			;    TO-10 IDLE
;	ED.TDB==1			;    WAITING FOR TO-10 DONE FOR A
					;     NON-SCATTER READ XFER OR
					;     WAITING FOR TO-10 DONE ON LAST
					;     XFER IN A SCATTER READ
;	ED.TWD=2			;    WAITING FOR DOORBELL SO WE CAN
					;     GET NEXT CHUNK IN A SCATTER
					;     READ XFER.
;	ED.TIB==3			;    WAITING FOR TO-10 DONE FOR A
					;     SCATTER READ XFER THAT IS NOT
					;     THE LAST ONE

;NOTE THAT THE ORDER OF ED.DTX THROUGH ED.RLD IS IMPORTANT TO DTELDR
; AND OTHER USERS OF THE DTE. GET STATUS UUO.

	FIELD.(ED.DTX,1,6)		;  DTE EXISTS. SET BY DTEINI
	FIELD.(ED.DTM,1,7)		;  THIS DTE HAS MASTER 11 ON IT
	FIELD.(ED.PPC,1,8)		;  PRIMARY PROTOCOL IS RUNNING
	FIELD.(ED.SPC,1,9)		;  SECONDARY PROTOCOL IS RUNNING
	FIELD.(ED.RLD,1,10)		;  THIS FRONT END NEEDS RELOADING

	FIELD.(ED.RBF,1,11)		;  WHICH BUFFER IS IN USE FOR RSX-20F
	FIELD.(ED.BFR,1,11)		;  INDICATES INPUT BUFFER HAS VALID
					;  DATA WHEN IN MAINTENANCE MODE.
					;  NO CONFLICT WITH ED.RBF, CAUSE RSX
					;  NEVER RUNS THRU THIS CODE
	FIELD.(ED.MAI,1,12)		;  IN MOP PROTOCOL
	FIELD.(ED.RLP,1,13)		;  11 RELOAD IN PROGRESS
	FIELD.(ED.IPU,1,14)		;  GIVE PROTOCOL UP AT INTERRUPT LEVEL
	FIELD.(ED.DBG,1,15)		;  RSX20F IS IN DEBUG MODE
	FIELD.(ED.LLS,1,16)		;  LAST LINE STATE REPORTED TO DTE USER
					;    0 = LINE DOWN;  1 = LINE UP

	ED.CST==ED.DTX+ED.DTM+ED.PPC+ED.SPC+ED.RLD+ED.MAI+ED.RLP+ED.MAI+ED.IPU
					;BITS TO CLEAR OUT ON INIT
					; ALSO MUST MAKE STATE CODES IDLE

	FIELD.(ED.CPN,3,33,N10)			;  CPU NUMBER THAT THIS DTE IS ON
	FIELD.(ED.DTN,2,35,N11-1)		;  DTE20 NUMBER (0-3)

	EWORD.
;;------------------------------------------------------------------------

ETDAAD:!				;AREA ADDRESSES
	DEFINE	X(A,B)<A==ETCRGN+ETO'B>

	X(ZZ10,\ETNM'N10'0)		;THIS 10'S OWNED AREA
	X(ZZ11,\ETNM'N10'N11)		; ADDRESS OF THIS 10'S 11'S OWNED AREA
	ZZ12==ZZ11+ETOSIZ*^D8		; ADDRESS OF THIS 10'S TO SECTION
					;  IN THE 11'S AREA
	ZZ13==ZZ10+ETOSIZ*^D8+<N11-1>*ET2SIZ*^D8
					; ADDRESS OF THIS 11'S TO SECTION
					;  IN THIS 10'S AREA

	FIELD.(ED.10A,18,17,ZZ10)	; ADDRESS OF THIS 10'S OWNED AREA
	FIELD.(ED.11A,18,35,ZZ11)	; ADDRESS OF THE CONNECTED 11'S AREA

	EWORD.
;;------------------------------------------------------------------------

;STILL IN DTEBLK MACRO DEFINITION

ETDSAD:!				;TO-PROCESSOR SECTION ADDRESSES

	FIELD.(ED.210,18,17,ZZ12)	; TO-10 SECTION OF 11S AREA
	FIELD.(ED.211,18,35,ZZ13)	; TO-11 SECTION OF 10S AREA

	EWORD.
;;------------------------------------------------------------------------

ETDQUE:!				;TO-11 QUEUE WORD
	FIELD.(ED.QUE,36,35)		;  POINTER TO FIRST ITEM OF QUEUE

	EWORD.
;;------------------------------------------------------------------------

ETDLST:!
	FIELD.(ED.LST,36,35)		;  POINTER TO TAIL OF TO-11 QUEUE

	EWORD.
;;------------------------------------------------------------------------

ETDMSP:!				;TO-10 MESSAGE POINTER WORD
	FIELD.(ED.MSP,36,35)		;  THE POINTER, USED FOR EXTRACING BYTES
					;    FROM THE TO-10 MESSAGE
					;    REFERENCED BY LOAD./STOR. AND ILDB

	EWORD.
;;------------------------------------------------------------------------
ETDNMP:!				;NEXT MESSAGE POINTER, COMPUTED
					; EVERY TIME A MESSAGE IS TAKEN
					; FROM A TO-10 PACKET. NEEDED
					; BECAUSE THE ONLY WAY TO FIND
					; NEXT MESSAGE IS TO REMEMBER
					; HOW LONG CURRENT MESSAGE WAS
					; BEFORE ITS GIVEN TO DRIVER

	FIELD.(ED.NMP,36,35)		;  36 BIT FIELD

	EWORD.
;;------------------------------------------------------------------------

ETDCUR:!				;CURRENT TO-11 QUEUE ENTRY
	FIELD.(ED.CUR,36,35)		;  WHEN AN ENTRY IS BEING SENT,
					;   IT IS NO LONGER IN THE QUEUE,
					;   BUT ITS ADDRESS IS IN THIS FIELD.

	EWORD.
;;------------------------------------------------------------------------

ETDICT:!				; INITIAL TO-10 INDIRECT BYTE COUNT
	FIELD.(ED.ICT,18,17)		;  USED TO REMEMBER HOW MUCH
					;  DATA DRIVER WANTS FROM TO-10
					;  INDIRECT MESSAGE FROM TO-10
					;  DONE FOR DIRECT PART OF MESSAGE
					;  TO TIME DOORBELL COMES IN

	DEFINE	X(A),<IFG M.FD'N10'N11,<
			ZZ10==FED'N10''A'0>
			IFLE M.FD'N10'N11,<ZZ10==0>>
	ZZ10==0
	X(\<N11-1>)
	FIELD.(ED.FED,18,35,ZZ10)	;  ADDRESS OF FIRST FRONT END DEVICE BLOCK FOR THIS FRONT END

	EWORD.
;;------------------------------------------------------------------------

ETDPKC:!BLOCK	1			;PACKET COUNT, INITIALLY CONTAINS
					; QSIZE FROM THE TO-10 SECTION OF
					; THE COMM REGION, IS DECREMENTED
					; AS MESSAGES ARE TAKEN FROM THE
					; PACKET.

					;  NO FIELD, ARITHMETIC IS DONE TO THIS LOCATION.

;;------------------------------------------------------------------------

ETDIBL:!				;NUMBER OF INDIRECT BYTES LEFT
					; IN CURRENT TO-10 MESSAGE WITHIN
					; PACKET
	FIELD.(ED.IBL,18,17)		;  THE FIELD

ETDIPS:!				;POST ADDRESS TO TRANSFER TO
					; WHEN THE INDIRECT PART OF AN INDIRECT
					; TO-10 MESSAGE IS RECEIVED,
					; SETUP BY DRIVER AT TIME
					; THE DIRECT PART OF THAT
					; MESSAGE IS RECEIVED.
	FIELD.(ED.IPS,18,35)		;  18 BIT ADDRESS FIELD

	EWORD.
;;------------------------------------------------------------------------

ETDPNP:!				;PROCESSOR PROTOCOL NUMBERS
	FIELD.(ED.KTN,9,8,1)		;DLS LINE NUMBER FOR KLINIK
	FIELD.(ED.CTN,9,17)		;  DLS LINE NUMBER OF CTY ON MASTER DTE
	FIELD.(ED.PNT,9,26,<ETNM'N10'0>);  PROTOCOL NUMBER FOR TEN
	FIELD.(ED.PNE,9,35,<ETNM'N10'N11>);  PROTOCOL NUMBER FOR 11

	EWORD.
;;------------------------------------------------------------------------

ETDATN:!				;WORD CONTAINING # ASYNC TERMINALS ON THIS DTE
					; DRIVEN DIRECTLY THRU RSX20
	FIELD.(ED.ATN,8,35,M.AT'N10'N11);  THE ATN FIELD

	EWORD.
;;------------------------------------------------------------------------

ETDXDI:!				;WORD FOR TO-10 INDIRECT MESSAGES
					; USED TO REMEMBER INFO ABOUT MESSAGE BETWEEN
					; TIME DIRECT PART COMES AND
					; TIME INDIRECT PART COMES TO-10
	FIELD.(ED.XDV,9,8)		;  TO-10 DEVICE CODE
	FIELD.(ED.XLN,9,17)		;  TO-10 LINE NUMBER
	FIELD.(ED.XFN,18,35)		;  TO-10 FUNCTION CODE

	EWORD.
;;------------------------------------------------------------------------

ETDTBP:!DTETBP+.E'N10'MP##+^D8*<N11-1>	;ADDRESS OF TO-10 BYTE POINTER IN EPT
;;------------------------------------------------------------------------

ETDEBP:!DTEEBP+.E'N10'MP##+^D8*<N11-1>	;ADDRESS OF TO-11 BYTE POINTER IN EPT
;;------------------------------------------------------------------------



	DEFINE	X(A)<ZZ10==DTE'A>	;SO WE CAN SUBTRACT ONE FROM N11
	X(\<N11-1>)			;SUBTRACT ONE FROM N11 AND GET DTE DEVICE CODE

ETDCNO:!CONO	ZZ10,(T1)
;;------------------------------------------------------------------------

ETDCNI:!CONI	ZZ10,T1
;;------------------------------------------------------------------------

ETDCSO:!CONSO	ZZ10,(T1)
;;------------------------------------------------------------------------

ETDCSZ:!CONSZ	ZZ10,(T1)
;;------------------------------------------------------------------------

ETDDTO:!DATAO	ZZ10,T1
;;------------------------------------------------------------------------


ETDBUF:!				;TO-10 BUFFER SPACE
	FIELD.(ED.TBA,1,0)		;  TO-10 BUFFER IS ALLOCATED
					;    (KEEP OLD ADDRESS AROUND FOR DEBUGGING)
	FIELD.(ED.BSZ,17,17)		;  SIZE OF ALLOCATED TO-10 BUFFER
	FIELD.(ED.BUF,18,35)		;  EVA OF ALLOCATED TO-10 BUFFER

	EWORD.
;;------------------------------------------------------------------------
ETDKAR:!BLOCK	1			;KEEP ALIVE REMEMBRANCE PLACE
;;------------------------------------------------------------------------
	.EDKAE==^D6			;NUMBER OF SECONDS KEEP ALIVE IS
					; ALLOWED TO REMAIN UNCHANGED
ETDKAN:!BLOCK	1			;NUMBER OF SECONDS KEEP ALIVE HAS NOT
					; CHANGED
;;------------------------------------------------------------------------
ETDLCP:!BLOCK	1			;LAST PC ON AN -11 RELOAD
;;------------------------------------------------------------------------

ETDCNT:!				;SOME COUNTERS
	FIELD.(ED.RMN,18,17)		; BYTE COUNT REMAINING FOR SUBSEQ
	FIELD.(ED.LBC,18,35)		; LAST TRANSFER'S BYTE COUNT

	EWORD.
;;------------------------------------------------------------------------

ETDUSR:!				;CURRENT USER OF LINE
	FIELD.(ED.USR,36,35)		; HANDY FIELD DEFINITION

	EWORD.
;;------------------------------------------------------------------------

ETDDDB::!				;DDB FOR DTE: DEVICE
	FIELD.(ED.DDB,36,35)		;HANDY FIELD DEF

	EWORD.
;;------------------------------------------------------------------------

ETDLBK::!BLOCK	1			;POINTER TO RTR'S LINE BLOCK
;;------------------------------------------------------------------------

ETDOBK:!FIELD.(ED.OBK,36,35)		;POINTER TO BLOCK OF FREE
					; CORE FOR NON-GATHER READ Q.P. V2
					; TRANSFERS
	EWORD.
;;------------------------------------------------------------------------

ETDIBK:!FIELD.(ED.IBK,36,35)		;POINTER TO BLOCK OF FREE
					; CORE FOR NON-GATHER READ Q.P. V2
					; TRANSFERS
	EWORD.
;;------------------------------------------------------------------------


ETDMBP:!BLOCK	1			;POINTER TO CURRENT INPUT MESSAGE BLOCK
;;------------------------------------------------------------------------
	DEPHASE

>;END IFN N11
>;END DTEBLK MACRO DEFINITION
SUBTTL MACRO TO GENERATE DTE CONTROL TABLE

;MACRO TO GENERATE TABLES WHICH MAP 10 CPU# AND DTE# INTO DTE
; CONTROL BLOCK ADDRESS. CALLED FROM COMDEV.
; ROUTINE TO CONVERT 10CPU AND DTE NUMBERS INTO DTE CONTROL BLOCK
; ADDRESS:
;	MOVE	T1,<10 CPU NUMBER>
;	MOVE	F,<DTE NUMBER (0-3)>
;	MOVE	F,@ETDTAB(T1)



DEFINE ETDTBX,<;LEVEL 5

	ETPDOX(CPUN,<ETDTBA(\ZZ40)>,ZZ40)		;TABLE OF TABLE ADDRESSES,
					;ONE ENTRY PER CPU

	ETPDOX(CPUN,<ETDTBB(\ZZ40)>,ZZ40)		;GENERATE PER CPU TABLE OF DTE CONTROL BLOCK ADDRESSES

>;END ETDTBX MACRO

DEFINE ETDTBA(N10)<;LEVEL 3
IFN M'N10'DTEN,<
IFE N10,<
ETDTAB::!ETDTB'N10(F)			;ADDRESS OF 10#'N10'S DTE TABLE
>;END IFE N10

IFN N10,<
	ETDTB'N10(F)			;ADDRESS OF 10#'N10'S DTE TABLE
>;END IFN N10
>;END IFN M'N10'DTEN
>;END ETDTBA MACRO DEFINITION


DEFINE ETDTBB(N10)<;LEVEL 3
	ETPDOX(<M'N10'DTEN+2>,<ETDTBC(N10,\ZZ20)>,ZZ20)
>;END ETDTBB MACRO DEFINITION


DEFINE ETDTBC(N10,N11)<IFN N11,<IFGE M'N10'DTEN-N11,<
IFN N11-1,<
		ETD'N10'N11'B
>;END IFN N11-1

IFE N11-1,<
ETDTB'N10::ETD'N10'N11'B
>;END IFE N11-1
>;END IFGE M'N10'DTEN-N11
>;END IFN N11
>;END ETDTBC MACRO DEFINITION
SUBTTL TO-11 QUEUE AND TO-11 DTE PROTOCOL MESSAGE FORMAT

;THE TO-11 QUEUE ENTRY FORMAT CONSISTS OF A HEADER, FOLLOWED
; BY THE ACTUAL MESSAGE TO BE SENT THROUGH THE DTE20. THIS SETUP
; IMPLIES THAT ONLY ONE MESSAGE PER DTE20 PROTOCOL PACKET CAN BE
; SENT TO THE 11.

;TO-11 QUEUE HEADER DEFINITIONS

	PHASE	0

ETQBEG:!				;FIRST WORD OF TO-11 QUEUE HEADER

ETQLNK:!FIELD.(EQ.LNK,36,35)		; ADDRESS OF NEXT ITEM IN TO-11 QUEUE

	EWORD.
;;------------------------------------------------------------------------
ETQSTS:!				;ENTRY STATUS BITS
	FIELD.(EQ.STS,9,8)		;  QUARTERWORD OF STATUS
	  FIELD.(EQ.16B,1,0)		;    TO-11 INDIRECT TO BE SENT IN 16 BIT MODE
	FIELD.(EQ.ELN,9,17)		;  TO-11 LINE, SAVED FOR TO-11 POST

	EWORD.
;;------------------------------------------------------------------------

ETQCNT:!				;COUNT TO SET DTE BYTE COUNT TO
					; FOR TO-11 INDIRECT DATA
	FIELD.(EQ.CNT,18,17)		;  THE FIELD

ETQPST:!				;POST ADDRESS FOR QUEUE REQUEST
	FIELD.(EQ.PST,18,35)		;  DITTO

	EWORD.
;;------------------------------------------------------------------------

ETQPTR:!				;BYTE POINTER TO TO-11 INDIRECT
					; DATA. IF SIZE IN POINTER IS
					; GREATER THAN 16 BITS, HIGH
					; ORDER UNUSED BITS MUST BE ZERO,,
					; OR ELSE DTE WILL GET PARITY ERRORS
	FIELD.(EQ.PTR,36,35)		;  WHOLE WORD.

	EWORD.
;;------------------------------------------------------------------------

ETQDRD:!				;DRIVER'S DATA
	FIELD.(EQ.DRD,18,17)		;  THE FIELD
ETQSIZ:!FIELD.(EQ.SIZ,18,35)		;  SIZE OF THIS ENTIRE BLOCK OF CORE
					;   IN 36 BIT WORDS

	EWORD.
;;------------------------------------------------------------------------
ETQMBP:!BLOCK	1			;POINTER TO ASSOCIATED MESSAGE BLOCK
;;------------------------------------------------------------------------

	.EQLEN==<.-ETQBEG>*<^D36/^D8>	;SIZE OF QUEUE HEADER
					; IN 8 BIT BYTES

	DEPHASE
;TO-11 MESSAGE FORMAT
; NOTE: BYTES ARE SWAPPED FOR THE CORRESPONDING TO-10 MESSAGES, SO
; REFRAIN FROM USING LOAD./STOR. WITH THESE DATA STRUCTURE DEFINITIONS
; FOR TO-10 MESSAGES.

	PHASE	0

ETMBEG:!				;BEGINNING OF TO-11 MESSAGE
	FIELD.(EM.CNT,16,15)		;  MESSAGE COUNT, IN 8 BIT BYTES
	FIELD.(EM.FNC,16,31)		;  FUNCTION CODE
	  FIELD.(EM.16B,1,19)	;    USED BY DRIVERS, NOT SEEN IN MESSAGES
	  FIELD.(EM.IND,1,20)	;    SUBFIELD OF EM.FNC, SAYS
					;      MESSAGE IS INDIRECT

	;HERE ARE PROTOCOL FUNCTION CODES.
	; THOSE NOT LEGAL FOR TO-11 USE ARE COMMENTED OUT.

	.EM2EI==1			;TO-11 INITIAL MESSAGE FUNCTION
	  FIELD.(EM.50C,1,20)		;  50 HZ BIT IN THIS MESSAGE
;	.EM2TI==2			;TO-10 INITIAL MESSAGE
	.EMSTR==3			;STRING DATA
	.EMLNC==4			;LINE-CHAR, LINE-CHAR
	.EMRDS==5			;REQUEST DEVICE STATUS
					;#6 UNIMPLEMENTED
	.EMHDS==7			;HERE IS DEVICE STATUS

	 ;THE FOLLOWING BIT DEFINITIONS ARE WITH RESPECT TO THE STATUS
	 ; BYTE AS IT APPEARS AFTER A -10 BYTE INSTRUCTION

	FIELD.(EM.CFG,1,24)		;  CONFIGURATION INFORMATION
	FIELD.(EM.LIN,1,25)		;  LOST INTERRUPT ENABLE
	FIELD.(EM.HNG,1,26)		;  HUNG DEVICE
	FIELD.(EM.F11,1,27)		;  FILES-11
	FIELD.(EM.FER,1,28)		;  FATAL ERROR
	FIELD.(EM.ELR,1,29)		;  ERROR LOGGING REQUEST
	FIELD.(EM.EOF,1,30)		;  END OF FILE
	FIELD.(EM.IOP,1,31)		;  I/O IN PROGRESS
	FIELD.(EM.SER,1,32)		;  SOFT ERROR
	FIELD.(EM.HER,1,33)		;  HARD ERROR
	FIELD.(EM.OFL,1,34)		;  OFF LINE
	FIELD.(EM.NXD,1,35)		;  NON-EXISTANT DEVICE

					;#10 UNIMPLEMENTED
	.EMRDT==11			;REQUEST DATE/TIME
	.EMHDT==12			;HERE IS DATE/TIME
	 .EMDTS==^D10			;  SIZE OF DATE/TIME INDIRECT MESSAGE
					;   IN 8 BIT BYTES
	.EMFLO==13			;FLUSH OUTPUT (^O)
	.EMSNA==14			;SEND ALL (TTYS)
	.EMDSC==15			;DATASET CONNECTED
	.EMHUD==16			;HANG UP DATASET
	.EMACK==17			;ACKNOWLEDGE (DEVICE LINE ALLOCATION FREE)
	.EMXOF==20			;XOFF TTY LINE
	.EMXON==21			;XON TTY LINE
	.EMHLS==22			;HERE ARE LINE SPEEDS FOR TTYS
	.EMHLA==23			;HERE ARE LINE ALLOCATIONS
;	.EMRBI==24			;TO-10 REBOOT INFORMATION
	.EMAKA==25			;ACK ALL
	.EMTDO==26			;TURN DEVICE (ON/OFF)
	.EMEDR==27			;ENABLE/DISABLE REMOTES
	.EMLDR==30			;LOAD LP RAM
	.EMLDV==31			;LOAD LP VFU
	.EMD6D==32			;DAS60 DATA
	.EMKPS==33			;KLINIK PARAMETER STATUS
	.EMAXF==34			;ENABLE/DISABLE AUTO-XOFF
	.EMBTC==35			;TO-11 BREAK THROUGH CHARACTER DATA
	.EMDBN==36			;TO-11 TURN ON DEBUGGING-KL MODE
	.EMDBF==37			;TO-11 TURN OFF DEBUG MODE

	.EMMXF==37			;MAXIMUM PROTOCOL FUNCTION

	EWORD.
;;------------------------------------------------------------------------


	FIELD.(EM.DEV,16,15)		;  PROTOCOL DEVICE CODE

	.EMCTY==1			;DEVICE CODE FOR CTY
	.EMDL1==2			;DL11
	.EMDH1==3			;DH11 #1
	.EMDLS==4			;DLS (ALL TTYS COMBINED)
	.EMLPT==5			;FRONT END LPT
	.EMCDR==6			;CDR
	.EMCLK==7			;CLOCK
	.EMFED==10			;FRONT END DEVICE
	.EMNCL==11			;NCL DEVICE (DN87S)
	.EMD60==12			;DN60

	.EMMXD==12			;MAXIMUM DEVICE CODE (EXCEPT FOR WAY OUT ONES BELOW)

	.EMCPU==200			;KL10 CPU
	.EMKLE==201			;KLERR
	.EMD20==202			;DTE-20
	.EMRPX==203			;RH-11  RP04/RP06
	.EMKLI==210			;KLINIK


	FIELD.(EM.SPR,16,31)		;  SPARE, UNUSED

	EWORD.
;;------------------------------------------------------------------------

	.EMHBL==<.-ETMBEG>*<^D36/^D8>	;LENGTH OF FIRST PART OF HEADER,
					; IN 8 BIT BYTES

	FIELD.(EM.1WD,16,15)		;  FIRST WORD (PART OF HEADER)
	FIELD.(EM.DAT,16,35)		;  FIRST DATA WORD (ALSO PART OF HEADER)

	EWORD.
;;------------------------------------------------------------------------
	.EMHDL==<.-ETMBEG>*<^D36/^D8>	;LENGTH OF ENTIRE HEADER IN
					; 8 BIT BYTES
	DEPHASE
IFDEF TTDBUG,<LIST>


;NEGATIVE FUNCTIONS USED ONLY BY DTESER FOR INTERNAL COMMUNICATION
; TO DRIVERS. SYMBOLS ARE 18 BIT NEGATIVE, FOR MOVEI.


	.EMXML==-1&777777	;SAYS THAT THE FRONT END HAS CRASHED
				; WHILE A DRIVER WAS WAITING FOR INDIRECT
				; DATA, THUS POSSIBLY NEEDS TO DEALLOCATE
				; A BUFFER
	SUBTTL	SYMBOL DEFINITIONS

;GENERATE SYMBOLS FOR DTESER AND FRIENDS TO REFER TO

	CPUN==1
	M0DTEN==1		;NUMBER OF DTES ON CPU0
	M.AT01==1		;# ASYNCHRONOUS LINES ON RSX20
	M.FD01==1		;# FRONT END DEVICES ON DTE FE #0

	SUBTTL	DECNET DEFINTIONS

;THE FOLLOWING VALUE OF MAXIMUM MESSAGE BLOCK LENGTH (KNOWN AS THE USER
; DATA SEGMENT TO DECNET-36) MUST BE THE SAME AS THE VALUE IN D36COM.

	UBLSIZ==^D590/4		;MAXIMUM SIZE IS 590 BYTES

	SUBTTL	DEFINITIONS FOR DTE DEVICE

;LOCAL BITS FOR DEVIOS

	IOSMAI==400		;LINE SHOULD BE USED IN MAINT MODE
	IOSSRM==200		;START MODE WAS RCVD IN MAINT MODE
	IOSMRN==100		;NORMAL MESSAGE RCVED IN MAINT MODE

;OTHER DTE DEVICE RELATED PARAMETERS

	DTEMMS==1240		;MAXIMUM MESSAGE SIZE (JUST PICK ONE)
	DTEMXQ==3		;MAXIMUM NUMBER OF BUFFERS TO QUEUE UP

;THIS IS THE INTERLOCK FOR DTESER

	OPDEF	DTEOFF	[CONO PI,NETPIF##]

	OPDEF	DTEON	[CONO PI,NETPIN##]
	SUBTTL	COMM SECTIONS FIELD DEFINITIONS

;OWNING SECTION'S PROTCOL VERSION DEFINITIONS

	.PV20F==0		;VERSION USED ON RSX-20F AND ANF-10
	.PVMCB==1		;VERSION USED FOR MCB

;OWNING SECTION'S COMM AREA VERSION DEFINITIONS

	.CV20F==0		;COMM AREA USED ON RSX-20F AND ANF-10
	.CVMCB==2		;COMM AREA USED FOR MCB

;"TO" SECTION'S "TMODE" (TRANSFER MODE) DEFINITIONS

	.TMBYT==0		;BYTE MODE TRANSFERS
	.TMBWD==1		;BYTES IN WORD MODE TRANSFERS
	.TMWRD==2		;WORD MODE TRANSFERS

;"TO" SECTION'S "PROTYP" (PROTOCOL TYPE) DEFINITIONS

	.M20F==0		;PROTOCOL USED ON RSX-20F
	.MMCB==1		;PROTOCOL USED FOR MCB
	SUBTTL	SYMBOL GENERATION
	.XCREF

;GENERATE FRONT END DEVICE CONTROL BLOCKS FIRST, DTE CONTROL BLOCKS
; POINT TO THEM

	FEDGEN


;GENERATE COMM REGION SYMBOLS BY CALLING THEIR MACROS
; FOR A CONFIGURATION OF ONE TEN AND ONE ELEVEN.

	ETHEAD
	ETREGN(0,0)


;NOW GENERATE SYMBOLS FOR DTE CONTROL BLOCK BY CALLING THE MACRO ONCE


	ETDGEN

	.CREF
	PURGE	ETCRGN,ETCSIZ,ETCHED	;SO NO ERRORS IN DTESER.
	PURGE	CPUN,M.AT01,DTE0NM	; GET RID OF PHONEY CONFIG SYMBOLS

					; DTEDEV DEFINES THESE
					; FOR REAL
	END