Google
 

Trailing-Edge - PDP-10 Archives - BB-V552A-SB_1983 - d6sint.mac
There are 4 other files named d6sint.mac in the archive. Click here to see a list.
TITLE D6SINT -- UUO AND INTERRUPT SERVICE FOR THE DTE-20 DN60 SERIES - V020
SUBTTL	ED FORTMILLER/EGF	02 OCT 79

	SEARCH	F,S,DTEPRM
	$RELOC
	$HIGH




;THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY ONLY BE USED
;  OR COPIED IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE.
;
;COPYRIGHT (C) DIGITAL EQUIPMENT CORPORATION
; 1976,1977,1978,1979,1980,1982
XP	V6SINT,020			;VERSION NUMBER

ENTRY	D6SINT

D6SINT:

;THESE BITS ARE USED IN THE (LH) OF FEKUNI
;
	D6.OUT==1B0			;EXPECTING A TO-11 DONE INTERRUPT
	D6.INP==1B1			;EXPECTING A TO-10 DOORBELL INTERRUPT
	D6.TTD==1B2			;EXPECTING A TO-10 DONE INTERRUPT
	D6.IND==1B3			;RECEIVED THE TO-10 DONE INTERRUPT

SUBTTL	FORMAT OF DATA MESSAGES BETWEEN 10 AND 11

REPEAT 0,<

25 May 77
Edit 7

                             DAS60 Write Functions


To perform the DAS60 functions 2, 4, 6, and 8 using the DTE the 10 will  send  a
direct message followed by the data in the indirect message.

!-------------------------------------------------------------------------!
!      MSG COUNT IN BYTES       ! PROTOCOL FUNCT CODE (.EMD6D)  !         !
!-------------------------------------------------------------------------!
!  PROTOCOL DEV CODE (.EMD60)   !          SPARE WORD           !         !
!-------------------------------------------------------------------------!
!       0       !DAS60 FUN CODE !  DAS60 LINE #  !  DAS60 DEV #  !        !
!-------------------------------------------------------------------------!
! LENGTH (MSB)  ! LENGTH (LSB)  !                !               !        !
!-------------------------------------------------------------------------!

MSG COUNT IN BYTES                      The number  of  bytes  in  this  message
                                        header = 14.

PROTOCOL FUNCT CODE                     .EMD6D DAS60 data

PROTOCOL DEV CODE                       .EMD60

SPARE WORD                              Not used

0                                       Not used

DAS60 FUNCTION CODE                     2, 4, 6, or 8

DAS60 LINE NUMBER                       Line number from the CAL11.  blk

DAS60 DEVICE NUMBER                     Device number from the CAL11.  blk

LENGTH                                  Length of  the  data  in  bytes  in  the
                                        indirect  message.   The  maximum length
                                        will be 4095 bytes.



The 11 should respond with the following direct message.

!-------------------------------------------------------------------------!
!      MSG COUNT IN BYTES       ! PROTOCOL FUNCT CODE (.EMD6D)  !         !
!-------------------------------------------------------------------------!
!  PROTOCOL DEV CODE (.EMD60)   !          SPARE WORD           !         !
!-------------------------------------------------------------------------!
!  RESULT CODE  !DAS60 FUN CODE !  DAS60 LINE #  !  DAS60 DEV #  !        !
!-------------------------------------------------------------------------!
! LENGTH (MSB)  ! LENGTH (LSB)  !                !               !        !
!-------------------------------------------------------------------------!

MSG COUNT IN BYTES                      The number  of  bytes  in  this  message
                                        header = 14.

PROTOCOL FUNCT CODE                     .EMD6D DAS60 data

PROTOCOL DEV CODE                       .EMD60

SPARE WORD                              Not used

DAS60 RESULT CODE                       1, 2, or 3

DAS60 FUNCTION CODE                     2, 4, 6, or 8

DAS60 LINE NUMBER                       Line number giving result code for

DAS60 DEVICE NUMBER                     Device number giving result code for

LENGTH                                  Number of data  bytes  the  11  absorbed
                                        from the indirect portion

                              DAS60 Read Functions


To perform the DAS60 functions 1,3,5, or 7 using the DTE  the  10  will  request
data by using a direct message.

!-------------------------------------------------------------------------!
!      MSG COUNT IN BYTES       ! PROTOCOL FUNCT CODE (.EMD6D)  !         !
!-------------------------------------------------------------------------!
!  PROTOCOL DEV CODE (.EMD60)   !          SPARE WORD           !         !
!-------------------------------------------------------------------------!
!       0       !DAS60 FUN CODE !  DAS60 LINE #  !  DAS60 DEV #  !        !
!-------------------------------------------------------------------------!
! LENGTH (MSB)  ! LENGTH (LSB)  !                !               !        !
!-------------------------------------------------------------------------!

MSG COUNT IN BYTES                      The number  of  bytes  in  this  message
                                        header = 14.

PROTOCOL FUNCT CODE                     .EMD6D DAS60 data

PROTOCOL DEV CODE                       .EMD60

SPARE WORD                              Not used

0                                       Not used

DAS60 FUNCTION CODE                     2, 4, 6, or 8

DAS60 LINE NUMBER                       Line number from the CAL11.  blk

DAS60 DEVICE NUMBER                     Device number from the CAL11.  blk

LENGTH                                  Length of  the  data  in  bytes  in  the
                                        indirect  message.   The  maximum length
                                        will be 4095 bytes.



The 11 should respond with a direct message and the data should  follow  in  the
indirect message.

!-------------------------------------------------------------------------!
!      MSG COUNT IN BYTES       ! PROTOCOL FUNCT CODE (.EMD6D)  !         !
!-------------------------------------------------------------------------!
!  PROTOCOL DEV CODE (.EMD60)   !          SPARE WORD           !         !
!-------------------------------------------------------------------------!
!  RESULT CODE  !DAS60 FUN CODE !  DAS60 LINE #  !  DAS60 DEV #  !        !
!-------------------------------------------------------------------------!
! LENGTH (MSB)  ! LENGTH (LSB)  !                !               !        !
!-------------------------------------------------------------------------!

MSG COUNT IN BYTES                      The number  of  bytes  in  this  message
                                        header = 14.

PROTOCOL FUNCT CODE                     .EMD6D DAS60 data

PROTOCOL DEV CODE                       .EMD60

SPARE WORD                              Not used

DAS60 RESULT CODE                       1, 2, or 3

DAS60 FUNCTION CODE                     1, 3, 5, or 7

DAS60 LINE NUMBER                       Line number giving result and data for

DAS60 DEVICE NUMBER                     Device number giving result and data for

LENGTH                                  Length of  the  data  in  bytes  in  the
                                        indirect message

                                Deposit Function


To perform the deposit function (DAS60 function code 10) the 10  will  send  the
following direct message:

!-------------------------------------------------------------------------!
!      MSG COUNT IN BYTES       ! PROTOCOL FUNCT CODE (.EMD6D)  !         !
!-------------------------------------------------------------------------!
!  PROTOCOL DEV CODE (.EMD60)   !          SPARE WORD           !         !
!-------------------------------------------------------------------------!
!       0       !DAS60 FUN CODE !   ADR (MSB)    !   ADR (LSB)   !        !
!-------------------------------------------------------------------------!
!  DATA (MSB)   !  DATA (LSB)   !                !               !        !
!-------------------------------------------------------------------------!

MSG COUNT IN BYTES                      The number  of  bytes  in  this  message
                                        header = 14.

PROTOCOL FUNCT CODE                     .EMD6D DAS60 data

PROTOCOL DEV CODE                       .EMD60

SPARE WORD                              Not used

0                                       Not used

DAS60 FUNCTION CODE                     10

ADR                                     Address to deposit the data into

DATA                                    Data to be deposited into ADR



The 11 should respond with the result code:

!-------------------------------------------------------------------------!
!      MSG COUNT IN BYTES       ! PROTOCOL FUNCT CODE (.EMD6D)  !         !
!-------------------------------------------------------------------------!
!  PROTOCOL DEV CODE (.EMD60)   !          SPARE WORD           !         !
!-------------------------------------------------------------------------!
!  RESULT CODE  !DAS60 FUN CODE !                !               !        !
!-------------------------------------------------------------------------!

MSG COUNT IN BYTES                      The number  of  bytes  in  this  message
                                        header = 10.

PROTOCOL FUNCT CODE                     .EMD6D DAS60 data

PROTOCOL DEV CODE                       .EMD60

SPARE WORD                              Not used

DAS60 RESULT CODE                       1, 2, or 3

DAS60 FUNCTION CODE                     10

                                Examine Function


To perform the examine function (DAS60 function code  9)  the  10  will  send  a
direct message containing the address to be examined:

!-------------------------------------------------------------------------!
!      MSG COUNT IN BYTES       ! PROTOCOL FUNCT CODE (.EMD6D)  !         !
!-------------------------------------------------------------------------!
!  PROTOCOL DEV CODE (.EMD60)   !          SPARE WORD           !         !
!-------------------------------------------------------------------------!
!       0       !DAS60 FUN CODE !   ADR (MSB)    !   ADR (LSB)   !        !
!-------------------------------------------------------------------------!

MSG COUNT IN BYTES                      The number  of  bytes  in  this  message
                                        header = 12.

PROTOCOL FUNCT CODE                     .EMD6D DAS60 data

PROTOCOL DEV CODE                       .EMD60

SPARE WORD                              Not used

0                                       Not used

DAS60 FUNCTION CODE                     9

ADR                                     Address to examine


The 11 then should respond with the data:

!-------------------------------------------------------------------------!
!      MSG COUNT IN BYTES       ! PROTOCOL FUNCT CODE (.EMD6D)  !         !
!-------------------------------------------------------------------------!
!  PROTOCOL DEV CODE (.EMD60)   !          SPARE WORD           !         !
!-------------------------------------------------------------------------!
!  RESULT CODE  !DAS60 FUN CODE !   ADR (MSB)    !   ADR (LSB)   !        !
!-------------------------------------------------------------------------!
!  DATA (MSB)   !  DATA (LSB)   !                !               !        !
!-------------------------------------------------------------------------!

MSG COUNT IN BYTES                      The number  of  bytes  in  this  message
                                        header = 14.

PROTOCOL FUNCT CODE                     .EMD6D DAS60 data

PROTOCOL DEV CODE                       .EMD60

SPARE WORD                              Not used

DAS60 RESULT CODE                       1, 2, or 3

DAS60 FUNCTION CODE                     9

ADR                                     Address examined

DATA                                    The data in ADR

>;END REPEAT 0
;COME HERE WHEN THE 11 ON THE DTE ENTERS
; PRIMARY PROTOCOL
;
D60UP:: PUSHJ	P,SETWJ			;POINT W TO BASE TABLE
					; AND J TO THE FEK
	PJRST	D60SUP##		;GO FINISH THE SETUP

;COME HERE WHEN THE 11 ON THE DTE IS PUT INTO
; SECONDARY PROTOCOL.
;
;	P1 CONTAINS THE DTE NUMBER
;
D60DWN::PUSHJ	P,SETWJ			;POINT W TO BASE TABLE AND
					; J TO THE FEK.
	SKIPE	T1,DLXCEU##(W)		;IS THERE A CAL11. USER?
	  PUSHJ	P,D60WAK##		;YES, GO GET HIM OUT OF EVENT WAIT
	SETZM	FEKUNI##(J)		;NO MORE ONCE A SECOND CODE
	PJRST	RTNEVM			;IF ANY EVM GIVE IT BACK
					; AND RETURN TO DTESER

;COME HERE WHEN THE ONCE A SECOND ROUTINE TIMES OUT
;
; CALL:	PJUMPLE	P1,D6STMO		;P1 CONTAINS -1,,DTE NUMBER
;					;W POINTS TO THE BASE TABLE
;					;J POINTS TO THE FEK
;
D6STMO::PUSHJ	P,RTNEVM		;GIVE BACK EVM IF WE HAVE ANY
	HRRZ	F,P1			;0,,DTE NUMBER
	PUSHJ	P,GTETDS##		;POINT F AT DTE CONTROL BLOCK
	PJRST	DTECLR##		;CLEANUP QUEUES IF ANY
					; AND RETURN
;HERE TO EXAMINE OR DEPOSIT PDP11 MEMORY VIA THE DTE
;
; CALL:	JRST	D6SED			;J CONTAINS JOB NUMBER
;					;T1 FUNCTION CODE
;					;T3 ADDRESS
;					;T4 DATA TO DEPOSIT
;					;(RH) P1 CONTAINS THE DTE NUMBER
;					;W POINTS TO THE BASE TABLE
;
D6SED::	HRRZM	J,DLXCEU##(W)		;STORE OUR JOB NUMBER AND INDICATE
					; EXM/DEP BY 0 IN THE (LH)
	SETZM	DLXEVM##(W)		;WE DON'T USE EVM
	MOVE	T1,[	EXP	F6.DEP## ;MAKE A DN60 FUNCTION CODE
			EXP	F6.EXM## ]-1(T1) ; OUT OF THE CAL11. CODE
	SETZ	P2,			;DIRECT MESSAGE TO PDP11
	PUSHJ	P,DTEQ			;SEND THE DEP/EXM REQ TO THE 11
	  JRST	NFCPPD			;ERROR
	PJUMPE	T2,ECOD5##		;**ERROR-5** BECAUSE OF TIMEOUT
					; (TIMEOUT IS 0 RESULT CODE)
	CAIE	P2,1			;SEE IF GOOD RESULT CODE
	  PJRST	ECOD10##		;**ERROR-10** BECAUSE OF ILLEGAL ADDRESS
	CAIN	P2,F6.DEP		;WAS IT DEPOSIT?
	  PJRST	CPOPJ1##		;YES, GIVE SKIP RETURN
	MOVE	T1,P4			;COPY EXAMINE DATA
	PJRST	STOTC1##		;GIVE USER THE DATA HE REQUESTED

;HERE IF ON ERROR RETURN FROM THE CALL TO DTEQ
;
NFCPPD:	PJUMPE	T1,ECOD12##		;**ERROR-12** BECAUSE DTESER COULDN'T
					; GET ANY FREE CORE.
	PJRST	ECOD13##		;**ERROR-13** BECAUSE RELOAD BIT SET
					; OR PRIMARY PROTOCOL NOT RUNNING.
;HERE TO PERFORM THE DTE PORTION OF THE .C11QU FUNCTION
;
;AC CONTENTS AT THIS TIME
;
;	T1	FIRST ADDRESS IN THE BUFFER TO BE USED
;	T2	POSITIVE COMPUTED WORD COUNT
;	T3	N/A, WILL NOW BECOME A SCRATCH REGISTER
;	T4	LENGTH, WILL NOW BECOME A SCRATCH REGISTER
;	P1	POINTER TO BEGINNING OF THE WINDOW
;	P2	LINE NUMBER,,DEVICE NUMBER
;	P3	0,,START OF BUFFER, WILL NOW BE A SCRATCH
;		REGISTER.
;	P4	FUNCTION CODE,,NUMBER OF BYTES
;	F	POSITION OF FIRST BYTE
;	J	JOB NUMBER, WILL NOW CONTAIN INDEX POINTER TO WINDOW
;	S	BYTE SIZE (THE NUMBER OF BYTES PER WORD)
;	U	REMAINDER FROM (BYTE POSITION)/(BYTE SIZE)
;	W	POINTER TO BASE TABLE
;
D6SQ11::HRRZ	T3,P4			;GET NUMBER OF BYTES
	CAILE	T3,^D4095		;IS IT REASONABLE?
	  PJRST	ECOD11##		;**ERROR-11** BECAUSE OF TOO MANY
					; BYTES IN REQUEST.
	MOVE	T3,T2			;NUMBER OF WORDS OF DATA
	EXCH	T1,T3			;T1 = NUMBER OF WORDS
					; T3 = USER VIRTUAL ADDRESS OF DATA
	SUBM	T3,P3			;DIFFERENCE BETWEEN BUFFER AND
					; START OF DATA NOW IN P3
	TLO	J,D6.Q11##		;FLAG DOING .C11QU FUNCTION
	MOVEM	J,DLXCEU##(W)		;MAKE THE CAL11. UUO BUSY
	PUSHJ	P,GTEVBF##		;MAP USER BUFFER INTO EVM FOR DTE
					; (ONLY START WHERE HIS REAL
					; DATA STARTS - NOT THE BEGINNING
					; OF THE BUFFER)
	  JRST	[	SETZM	DLXCEU##(W)	;FREE UP THE CAL11 UUO
			PJRST	ECOD14## ]	;**ERROR-14** BECAUSE
						; THERE NEVER WILL BE EVOUGH EVM.
	HRLZM	T1,DLXEVM##(W)		;SAVE EV PAGE # AND # OF EXEC PAGES
	HRRM	T3,DLXEVM##(W)		;SAVE THE EXEC VIRTUAL ADDRESS
	SUB	T3,P3			;POINT TO BEGINNING OF BUFFER SO
					; ADJBP WILL POINT TO CORRECT
					; DATA.  THE ADDRESS IN T3 MAY
					; NOT BE MAPPED INTO EVM BUT AFTER
					; ADJUSTING THE BYTE POINTER WE
					; HAD BETTER BE POINTING INTO EVM.
	TLO	J,D6.ALK##		;GUESS ALREADY LOCKED
	MOVSI	T1,NSHF!NSWP		;LOCK BITS
	TDNE	T1,JBTSTS##(J)		;ALREADY LOCKED?
	  IORM	J,DLXCEU##(W)		;YES, SET D6.ALK SO LATER
					; WE DON'T UNLOCK HIM
	IORM	T1,JBTSTS##(J)		;LOCK THE JOB (EVEN IF ALREADY LOCKED)
	MOVE	T1,S			;CAN'T INDEX OFF OF S
	HLL	T3,[	POINT	8,	;4 .EQ. 8 BIT BYTES
			POINT	7,	;5 .EQ. 7 BIT BYTES
			POINT	6, ]-4(T1)	;6 .EQ. 6 BIT BYTES
	HLRZ	T1,P4			;GET DN60 FUNCTION CODE FOR CALL TO DTEQ
	HRRZ	P3,P4			;GET COUNT OF BYTES FOR CALL TO DTEQ
	MOVE	T4,P3			;DITTO
	ADJBP	F,T3			;BYTE POINTER TO FIRST BYTE OF
					; USER DATA
	MOVE	P4,F			;COPY POINTER HERE
	TRNE	T1,1			;SEE IF WRITING
	DMOVEM	P3,DLXICI##(W)		;READING, SAVE COUNT AND POINTER
	HRRZ	T3,P2			;GET DEVICE NUMBER
	ANDI	T3,377			;KEEP ONLY DEVICE NUMBER BITS
	LSH	P2,-^D10		;POSITION THE LINE NUMBER
	ANDI	P2,377*400		;KEEP ONLY THE 8 BITS OF LINE NUMBER
	IORI	T3,(P2)			;INCLUDE THE LINE NUMBER
	SETZ	P2,			;ASSUME READING
	TRNN	T1,1			;SEE IF WE GUESSED RIGHT
	  MOVEI	P2,EM.IND		;NO, WRITING SO ITS INDIRECT
	PUSHJ	P,DTEQ			;SEND A MESSAGE TO THE PDP11
	  PJRST	NFCPPD			;NO FREE CORE OR PRIMARY
					; PROTOCOL IS DOWN.
	PJUMPE	P2,ECOD5##		;**ERROR-5** BECAUSE OF TIMEOUT
	HRRZ	T1,P2			;GET THE RESULT CODE
	HRL	T1,P4			; AND THE NUMBER OF BYTES
	PUSHJ	P,PUTWD1##		;NOW GIVE USER THE LENGTH,,RESULT CODE
	PJRST	CPOPJ1##		;GIVE SKIP RETURN
;HERE TO TELL THE STATUS OF THE PDP11 ON THE DTE
;
; CALL:	JRST	DWND6S			;W POINTS TO THE BASE TABLE
;
DWND6S::MOVSI	T1,FK.ONL		;SEE IF ON-LINE BIT SET
	TDNN	T1,@DLXFEK##(W)		;TEST IT
	  PJRST	D60RT0##		;OFF-LINE SO RETURN 0 TO USER
	PJRST	D60RT1##		;ON-LINE SO RETURN 1 TO USER
;ROUTINE TO POINT W AT THE DL10 BASE TABLE
; AND J AT THE FEK.
;
; CALL:	PUSHJ	P,SETWJ			;P1 CONTAIN THE DTE NUMBER (0-3)
;	RETURN				;ALWAYS
;
SETWJ:	MOVE	W,DTEBAS##(P1)		;POINT TO THE BASE TABLE
	MOVE	J,DLXFEK##(W)		;POINT TO THE FEK
	POPJ	P,			;RETURN TO THE CALLER

;ROUTINE TO RETURN EVM IF WE HAVE ANY
;
; CALL:	PUSHJ	P,RTNEVM		;W POINTS TO THE BASE TABLE
;	RETURN				;ALWAYS
;
RTNEVM:	HLRZ	T1,DLXEVM##(W)		;GET (9) EXEC VIRTUAL PAGE # (9)
					; NUMBER OF EXEC PAGES
	PJUMPE	T1,CPOPJ##		;IF ZERO, THEN NO EVM.
	HRRZ	T2,DLXEVM##(W)		;GET EXEC VIRTUAL ADDRESS
	ANDI	T1,777			;KEEP THE NUMBER OF PAGES
	SETZM	DLXEVM##(W)		;CLEAR OUR EVM LOCATION
	PUSH	P,F			;SAVE F
	SETZ	F,			;MAKE SURE THIS IS 0 OR WE
					; WILL GET INTO TROUBLE IN
					; "RTEVM" IN KLSER.
	PUSHJ	P,GIVEVM##		;NOW GIVE UP THE EVM
	PJRST	FPOPJ##			;RESTORE F AND RETURN TO CALLER
;THIS ROUTINE IS USED TO QUEUE A MESSAGE TO THE DTE
;
; CALL:	PUSHJ	P,DTEQ			;T1 = DN60 FUNCTION CODE
;					;T3 = SHOULD CONTAIN THE 2nd 16 BITS
;					;T4 = SHOULD CONTAIN THE 3rd 16 BITS
;					;W  = POINTS TO THE BASE TABLE
;					;P1 = N/A,DTE NUMBER
;					;P2 = 0 OR THE INDIRECT BIT (.EMIND)
;					;P3 = CONTAINS INDIRECT COUNT OR 0
;					;P4 = CONTAINS INDIRECT POINTER OR 0
;	  ERROR RETURN			;IF DTESER COULDN'T GET FREE CORE
;					; T1 = -1 IF PRIMARY PROTOCOL DOWN
;					;  OR THE RELOAD BIT IS SET.
;					; T1 = 0 IF DTESER COULDN'T GET
;					;  FREE CORE.
;	OK RETURN			;IF PDP11 TOOK OUR MESSAGE AND
;					; GAVE US A RESULT CODE.
;					;P1 = DN60 FUNCTION CODE
;					;P2 = RESULT CODE
;					;P3 = 2nd 16 BITS
;					;P4 = 3rd 16 BITS
;					;W  = POINTS TO THE BASE TABLE
;					;J  = POINTS TO THE FEK
;	EITHER RETURN			;DLXCEU IS 0 AND JOB IS UNLOCKED
;					; IF WE LOCKED HIM
;
DTEQ:	MOVE	J,DLXFEK##(W)		;MAKE J POINT TO THE FEK
	MOVE	F,[POINT 16,DLXODA##(W)] ;POINT TO DIRECT DATA BLOCK
	IDPB	T1,F			;PUT IN THE DN60 FUNCTION CODE
	IDPB	T3,F			;PUT IN THE 2nd 16 BITS
	IDPB	T4,F			;PUT IN THE 3rd 16 BITS
	MOVE	T1,NUMBYT(T1)		;GET NUMBER OF BYTES EXPECTING BACK,,
					; NUMBER OF BYTES SENDING.
	HRRZM	T1,DLXOCN##(W)		;STORE BYTES SENDING
	HLLZM	T1,DLXICN##(W)		;STORE BYTES EXPECTED
	SETZM	DLXIDA##(W)		;CLEAR INPUT DATA BLOCK
	SETZM	DLXIDA##+1(W)		; DITTO
	MOVSI	T1,(D6.OUT)		;FLAG DOING OUPUT
	HLLM	T1,FEKUNI##(J)		;PUT THE FLAG WHERE TO-11 DONE WILL FIND IT
	HRLZI	S,T11DON		;THE POST ADDRESS FOR DTESER
	HRRI	S,DLXOCN##(W)		;POINT TO THE DIRECT COUNT
	SKIPN	P2			;SEE IF INDIRECT
	  SETZB	P3,P4			;NO, ITS DIRECT
	IOR	P2,[XWD	.EMD60,.EMD6D]	;PROTOCOL DEVICE CODE,PROTOCOL FUNCTION CODE
	HRRZS	P1			;0,,DTE NUMBER
	MOVEI	T1,2			;NUMBER OF SECONDS TILL WE TIME OUT
	PUSHJ	P,D60TIM##		;PUT TIME IN THE BASE TABLE WHEN
					; TIME OUT AT.
	PUSHJ	P,DTEQUE##		;CALL DTESER TO QUEUE OUR MESSAGE
	  JRST	[	PUSH	P,T1		;SAVE T1 ERROR CODE FROM DTEQUE
			PUSHJ	P,SETWJ		;POINT TO BASE TABLE AND FEK
			HRRZS	FEKUNI##(J)	;CLEAR OUT FLAGS
			PUSHJ	P,D60LKC##	;CHECK IF TO UNLOCK
			  PUSHJ	P,D60UNL##	;YES, UNLOCK HIM
						; (J NOW CONTAINS JOB #)
			SETZM	DLXCEU##(W)	;FREE UP THE CAL11 UUO
			SETZM	DLXTIM##(W)	;NO MORE ONCE A SECOND CALL
			PUSHJ	P,RTNEVM	;FREE UP THE EVM (IF ANY)
			PJRST	TPOPJ##	]	;RESTORE T1 AND
						; RETURN ERROR CODE.
	PUSHJ	P,D60EVW##		;GO WAIT TILL PDP11 TAKES OUR
					; MESSAGE AND REPLIES WITH THE
					; RESULT CODE.
	PUSHJ	P,SETWJ			;POINT TO BASE TABLE AND FEK
	LDB	P2,[POINT 8,DLXIDA##(W),7] ;GET RESULT CODE
	LDB	P1,[POINT 8,DLXIDA##(W),15] ;GET FUNCTION CODE
	LDB	P3,[POINT 16,DLXIDA##(W),31] ;GET THE 2nd 16 BITS
	LDB	P4,[POINT 16,DLXIDA##+1(W),15] ;GET THE 3rd 16 BITS
	SETZM	DLXCEU##(W)		;FREE UP THE CAL11. UUO
	PUSHJ	P,RTNEVM		;GIVE BACK EVM IF WE HAVE ANY
	PJRST	CPOPJ1##		;GIVE OK RETURN

;THIS TABLE CONTAINS IN THE (LH) THE NUMBER OF BYTES EXPECTED IN
; THE MESSAGE HEADER FROM THE PDP11, AND IN THE (RH) THE NUMBER
; OF DIRECT BYTES TO BE SENT TO THE PDP11.
;
NUMBYT:	0				;0 - ILLEGAL FUNCTION
	XWD	6,6			;1 - READ FUNCTION
	XWD	6,6			;2 - WRITE FUNCTION
	XWD	6,6			;3 - READ FUNCTION
	XWD	6,6			;4 - WRITE FUNCTION
	XWD	6,6			;5 - READ FUNCTION
	XWD	6,6			;6 - WRITE FUNCTION
	XWD	6,6			;7 - READ FUNCTION
	XWD	6,6			;8 - WRITE FUNCTION
	XWD	6,4			;9 - EXAMINE FUNCTION
	XWD	2,6			;10 - DEPOSIT FUNCTION
	.NMBYT==.-NUMBYT		;LENGTH OF THIS TABLE NUMBYT
;THIS ROUTINE IS CALLED FROM DTESER AFTER
; A T0-10 DONE INTERRUPT
;
; CALL:	PUSHJ	P,D6SDAT		;U CONTAINS BYTES IN DIRECT
;					; MESSAGE-.EMHBL
;					;IF INDIRECT P3 CONTAINS NUMBER
;					; OF BYTES COMING IN INDIRECT MESSAGE
;					;P2 CONTAINS DEVICE CODE,,FUNCTIN CODE
;					;P4 CONTAINS POINTER TO DATA IN
;					; THE DIRECT MESSAGE
;					;P1 CONTAINS THE DTE NUMBER
;
D6SDAT:	PUSHJ	P,SETWJ			;POINT W TO THE BASE TABLE
					; AND J TO THE FEK.
	SKIPN	DLXCEU##(W)		;SEE IF THERES A USER
	  PJRST	EATMSG##		;EATUP THE MESSAGE
	HLRZ	T1,DLXICN##(W)		;GET AMOUNT 11 SHOULD HAVE GIVEN
	CAME	T1,U			;SEE IF THATS REALLY TRUE
	STOPCD	CPOPJ##,DEBUG,6DD,	;++PDP11 TRIED TO GIVE US TO MUCH
					; DIRECT DATA.
					;??PROBABLY SHOULD KILL THE PDP11
	MOVEM	U,DLXICN##(W)		;PUT COUNT OF THE NUMBER OF DIRECT
					; 8 BIT BYTES FOLLOWING THE HEADER
	MOVE	T4,P4			;POINT TO THE DIRECT BYTES FOLLOWING
					; THE MESSAGE HEADER
	LSH	U,-1			;CONVERT NUMBER OF 8 BIT BYTES
					; INTO 16 BIT BYTES.
	MOVE	T3,[POINT 16,DLXIDA##(W)] ;PLACE WHERE TO PUT THE DIRECT BYTES
D6SDA2:	PUSHJ	P,GX2BYT##		;GET A 16 BIT BYTE INTO T1
	IDPB	T1,T3			;PUT IT IN THE BASE TABLE
	SOJG	U,D6SDA2		;GOT ALL OF THEM YET?
	TRNN	P2,EM.IND		;DOING INDIRECT DATA?
	  JRST	D6SEVW			;ITS DIRECT
	CAMLE	P3,DLXICI##(W)		;SEE IF PDP11 IS TRYING TO OVER
					; STUFF US WITH DATA.
	STOPCD	CPOPJ##,DEBUG,6ID,	;++PDP11 IS TRYING TO GIVE
					; US TOO MUCH INDIRECT DATA.
	MOVSI	S,T10DON		;WHERE TO GO ON TO10 DONE INTERRUPT
	MOVE	P4,DLXIBP##(W)		;GET THE BYTE POINTER
	MOVSI	T1,(D6.TTD)		;EXPECTING A TO10 DONE INTERRUPT
	IORM	T1,FEKUNI##(J)		;WHERE WE'LL FIND THAT BIT
	POPJ	P,			;RETURN TO DTESER

;HERE TO GET OUT OF EVENT WAIT SO AT UUO LEVEL
; WE CAN GIVE THE JOB HIS RESULT CODE.
;
D6SEVW:	MOVSI	T1,(D6.IND)		;BIT FOR INPUT DONE
	IORM	T1,FEKUNI##(J)		;WHERE UUO LEVEL WILL FIND THE BIT
	PJRST	D60WAK##		;GET JOB OUT OF EVENT WAIT

;HERE ON THE T0-10 DONE INTERRUPT FROM DTESER
; AFTER RECEIPT OF THE INDIRECT MESSAGE.
;
T10DON:	PUSHJ	P,SETWJ			;POINT W TO THE BASE TABLE
					; AND J TO THE FEK.
	MOVSI	T1,(D6.TTD)		;SEE IF EXPECTING A TO-10
	TDNN	T1,FEKUNI##(J)		; INTERRUPT
	STOPCD	CPOPJ##,DEBUG,6DI,	;++NOT EXPECTING A TO-10 DONE INT
					;??PROBABLY SHOULD KILL THE PDP11
	ANDCAM	T1,FEKUNI##(J)		;CLEAR EXPECTING TO-10 DONE INT
	JRST	D6SEVW			;GET OUT OF EVENT WAIT

;HERE ON A TO-11 DONE INTERRUPT FROM DTESER
;
T11DON:	POPJ	P,			;NOW RETURN TO DTESER
;TO-10 DISPATCH TABLE
;
	CPOPJ##				;(-1) LOST TO-10 INDIRECT MESSAGE
D6SDSP::EATMSG##			;(0)
	EATMSG##			;(1)
	EATMSG##			;(2)
	EATMSG##			;(3)
	EATMSG##			;(4)
	EATMSG##			;(5)
	EATMSG##			;(6)
	EATMSG##			;(7)
	EATMSG##			;(10)
	EATMSG##			;(11)
	EATMSG##			;(12)
	EATMSG##			;(13)
	EATMSG##			;(14)
	EATMSG##			;(15)
	EATMSG##			;(16)
	EATMSG##			;(17)
	EATMSG##			;(20)
	EATMSG##			;(21)
	EATMSG##			;(22)
	EATMSG##			;(23)
	EATMSG##			;(24)
	EATMSG##			;(25)
	EATMSG##			;(26)
	EATMSG##			;(27)
	EATMSG##			;(30)
	EATMSG##			;(31)
	D6SDAT				;(32) DN60 DATA
	$HIGH

	$LIT

D6SEND::END