Google
 

Trailing-Edge - PDP-10 Archives - BB-P363B-SM_1985 - mcb/drivers/nrd.m11
There are no other files named nrd.m11 in the archive.
.TITLE	NRD
.IDENT	/006070/
;
;                    COPYRIGHT (c) 1980, 1981, 1982
;                    DIGITAL EQUIPMENT CORPORATION
;                        Maynard, Massachusetts
;
;     This software is furnished under a license and may  be  used
;     and copied only in accordance with the terms of such license
;     and with the inclusion of the above copyright notice.   This
;     software  or any other copies thereof may not be provided or
;     otherwise made available to any other person.  No  title  to
;     and ownership of the software is hereby transferred.
;
;     The information  in  this  software  is  subject  to  change
;     without  notice  and should not be construed as a commitment
;     by DIGITAL EQUIPMENT CORPORATION.
;
;     DIGITAL assumes no responsibility for the use or reliability
;     of  its  software  on  equipment  which  is  not supplied by
;     DIGITAL.
;
;
;	NRD GENERIC DIALOG MANAGER
;
;
; MODIFIED:
;
; 1.06	26-JAN-79 ALAN D. PECKHAM
;	MAKE INITIAL FLOW COUNT GLOBAL
;
; 6060 	19-MAR-79 SCOTT G. ROBINSON
;	MAKE RESOURCE RECOVERY WORK AND
;	 MODIFY CONTROL-START PROCESSING TO NOT REQUIRE AN
;	 EXTRA CCB.
;
; 6070	19-MAR-79 SCOTT G. ROBINSON
;	MODIFY RESOURCE RECOVERY TO CLEAR RECOVERY BIT UPON
;	 COMPLETION OF ROUTINE NRDTIM
;
; 2.00  6-aug-80 andrew kerne
;	extensive rewrite (short of redesign) for compatibility with mcb
;	 version 3.0 and cleanliness.


;  EXTERNAL MACROS
;
	.mcall	phd$b,dsp$,dsp$b,dsp$e
	.MCALL	CCBDF$,MAP$,return,callr,NRMDF$
	.mcall	scdf$,nrtn$,nint$,nrti$,ndat$,ndak$
	.mcall	ncra$,nacc$,nrdm$,nirq$,$gtula

	CCBDF$				;DEFINE CCB SYMBOLS
	scdf$				;define session control c.mod's
	NRMDF$				;define NRM's data base

;	.LIST	MEB		;LET'S not SEE SOME OF THAT HIDDEN CODE
	.SBTTL	DISPATCH TABLES


	phd$b  nrd
	phd$d  LLCDSP
	phd$e

	.PSECT	$PLIT$,D
;
;  PRIMARY DISPATCH TABLE
;
 
llcdsp:	dsp$b
	dsp$	fc.ast,nrdast		;  AST
	dsp$ 	FC.XME,nrdxme		;  TRANSMIT ENABLE
	dsp$	FC.RCE,nrdrce		;  RECEIVE ENABLE
	dsp$	FC.KIL			;  KILL ENABLE
	dsp$ 	FC.CTL,nrdctl		;  CONTROL ENABLE
	dsp$	FC.TIM,NRDTIM		;  TIMEOUT
	dsp$	FC.XCP,NRDXCP		;  TRANSMIT COMPLETE
	dsp$	FC.RCP,NRDRCP		;  RECEIVE COMPLETE
	dsp$	FC.KCP			;  KILL COMPLETE
	dsp$	FC.CCP,NRDCCP		;  CONTROL COMPLETE
	dsp$e


;  dispatch table for control enable
;
nrdctl:	jmp	@1$(r3)
1$:	dsp$b
	dsp$
	dsp$	fm.str,ctlstr
	dsp$	fm.stp,ctlstp
	dsp$e


;  dispatch table for timer entry
;
nrdtim:	jmp	@1$(r3)
1$:	dsp$b
	dsp$	fm.stm			;short timer
	dsp$	fm.ltm,tick		;long timer
	dsp$	fm.pwf			;power failure
	dsp$	fm.pin,pinset		;initialization
	dsp$e




;dispatch for transmit completes

NRDXCP:	JMP	@1$(r3)
1$:	dsp$b
	dsp$	s$con			;SC CONNECT COMPLETE
	dsp$	s$acc,request		;sc accept connection (our ccb)
	dsp$	s$rej			;sc reject connection
	dsp$	s$snd,scrtn		;SC DATA TRANSMITTED.		
	dsp$	s$mrq			;sc data message request
	dsp$	s$drq,scrtn		;sc data segment request
	dsp$	s$sni,scrtn		;sc interrupt segment xmitted
	dsp$	s$irq,scrtn		;sc interrupt request
	dsp$	s$dis			;sc return from our disconnect request
	dsp$	s$ABO,scrtn		;sc return from our abortion request
	dsp$	s$gln			;sc get local node info
	dsp$e



;
;dispatch for receive completes

NRDRCP:	JMP	@1$(R3)
1$:	dsp$b
	dsp$	s$cnr,sccon		; connect to nrd device 
	dsp$	s$dat,scdata		; receive data segment
	dsp$	s$int,scint		; receive interupt data 
	dsp$	s$dsr,sctrm		; disconnect
	dsp$e



 QS.CVR	==	100000		;  RECOVERY IN PROGRESS.
 QS.CCB	==	000400		;  CCB PENDING.

		.mcall	DAT$

	DAT$ DSR

timer:	.blkw	1		;long timer byte
nrmpix:	.blkw	1		;NRM's pix
nrdpix:	.blkw	1		;NRD's pix
fldif:	.blkw	1		;flow adjustment factor
flow:	.blkw	1		;flow control segment request count
quesw:	.blkw	1		;queue switches
wtque:	lst$d			;resource wait queue

	END$
	.PSECT $CODE$,I

; process initilization routine
;

pinset:
	call	$ltmen			;enable long timer
	mov	#^RNRM,r0		;pick up NRM's pix
	call	pidid			;...
	mov	r0,nrmpix(r5)		;...
	mov	.crpix,nrdpix(r5)	;pick up own pix
	return
;+
; QUEUE UP A CCB FOR A RESOURCE WAIT
;
; INPUTS:
;	R4 - CCB TO QUEUE UP
;-
NRDQUE:	mov	.crdat+2,r5		;point to NRD data base
	inc	(r5)			;set timer on
	mov	r5,r3			;point to resource queue
	add	#wtque,r3		;...
	BIS	#QS.CCB,quesw(r5)	;set CCB recovery flag
	BMI	10$			;recovery in progress ?
	CALLR	$CMQIN			; QUEUE TO THE REAR
10$:	CALLR	$CMQIF			; OTHERWISE TO THE FRONT.
 
tick:
	BIS	#QS.CVR,quesw(R5)		; OTHERWISE SET RECOVERY SWITCH
	BIC	#QS.CCB,quesw(R5)	; RESET CCB PENDING SWITCH
20$:	mov	r5,r3
	add	#wtque,r3		;point to the wait queue
	CALL	$CMQRM			; AND SEE IF ANYTHING IS IN THE QUEUE.
	BCS	80$			; IF SO,
	MOVB	C.MOD(R4),R3		; PICK UP MODIFIER
	MOVB	C.FNC(R4),R0		; AND FUNCTION CODE
	CALL	@llcdsp(R0)		; AND RE-DISPATCH FUNCTION.
	BIT	#QS.CCB,quesw(R5)		; IF NO RESOURCE ERROR,
	BEQ	20$			; THEN GO FOR MORE.
80$:	BIC	#QS.CVR,QUESW(r5)	; RESET RECOVERY SWTCH
90$:	
	RETURN			



;routine to flush out my resource wait queue for a given pipe

nrdfls:
	mov	.crdat+2,r5		;point to data base
	mov	r5,r3			;now look at the resource queue
	add	#wtque,r3		;...
1$:	call	$cmqrm			;try and remove a ccb
	bcs	2$			;no such luck,queue is empty
	mov	(r4),-(sp)		;save link word
	cmpb	c.prm1(r4),p.num(r0)	;for this pipe ?
	beq	3$
	call	$cmqin			;no so put it back
	tst	(sp)+			;alittle cleanup
	br	1$			;once more jack
2$:	return				;all done !
3$:	movb	p.pix(r0),c.pix(r4)	;set up to whomever
	NDAK$				;and give it up
	br	1$			;play it again sam
	.SBTTL	SCCON	- CONNECT PROCESSOR


SCCON:
	mov	R4,-(sp)		; stuff away connect ccb
	call	$ccbgt			; allocate an accept CCB
	bcc	4$			; allocation failure
	clr	r3			; failure indicator
	br	5$			; now reject cuz no resources
4$:
	mov	r4,r3			; stash away accept ccb
	mov	(sp),r0			;connect ccb
	mov	nrmpix(r5),r1		; NRM's pix
	CALL$P	#$pcbop,r1,<r0>
	tst	r0			; did we get a PCB
	bne	7$
5$:	mov	(sp)+,r4		; give back connect ccb
	ncra$	,#s.eres		; failure, reject connection
	mov	r3,r4			; point to accept ccb and
	beq	6$
	call	$ccbrt			; return it
6$:	return

7$:					; we now have a PCB in r0
	mov	(sp)+,r4		; connect ccb
	movb	c.lix(r4),c.lix(r3)	; copy info to accept ccb
	movb	c.lix(r4),p.lla(r0)	; put LLA in PCB
	movb	c.pix(r4),c.pix(r3)	; put in dest pix
	movb	c.pix(r4),p.pix(r0)	; and save it for later
	bis	#ps.ci!ps.dat,p.sts(r0)	; set connect initiated
	ncra$	p.num(r0)		; acknowledge intent to connect
	mov	r3,r4
	mov	#1, c.cnt(r4)		; send ULA that's in c.prm1 as
	add	#c.prm1, r3		; optional data
	clr	c.buf(r4)		; ......
	mov	r3,c.buf+2(r4)		; ......
	NACC$	,p.num(r0),#s$pseg	; now accept the connection
	return
; receive enables from higher ups
 
NRDRCE:	clr	r0			;ask NRM for the PCB address
	bisb	c.prm1(r4),r0		;for this pipe number..
	mov	nrmpix(r5),r1		;...
	CALL$P	#$pcbdb,r1,<r0>		;...
	mov	r4,-(sp)		;save away ccb
	tst	p.sts(r0)		;is pipe active
	beq	15$			;no so just return CCB
	cmpb	#s$int,r3		;was this an interrupt message
	beq	12$
	decb	p.segs(r0)		;need more segment requests ?
	cmpb	fldif(r5),p.segs(r0)	;no, not really
	bne	15$
12$:	call	$ccbgt			;get a request ccb
	bcc	13$			;got one
	incb	p.segs(r0)		;adjust count
	mov	(sp)+,r4		;queue up resource failure
	jmp	nrdque
13$:	movb	p.pix(r0),c.pix(r4)	;set up to whom
	cmpb	#s$int,r3		;interrupt
	beq	14$
	mov	flow(r5),r2
	movb	r2,p.segs(r0)
	sub	fldif(r5),r2
	ndrq$	p.lla(r0),p.num(r0),r2	;request more segments
	br	15$

14$:	nirq$	p.lla(r0),p.num(r0)		;request interrupt data

15$:	mov	(sp)+,r4
	movb	p.pix(r0),c.pix(r4)
	call	$SCHED
	return

; transmit completes come here

SCRTN:	clr	r0			;ask NRM for the PCB address
	bisb	c.prm1(r4),r0		;for this pipe number..
	mov	nrmpix(r5),r1		;...
	CALL$P	#$pcbdb,r1,<r0>		;...
	cmpb	c.own(r4),nrdpix(r5)	;is this my ccb
	bne	1$
	call	$ccbrt			;release ccb
	br	4$

1$:	mov	p.opn(r0),r1		;point to the TCB
	movb	t.pri(r1),c.pix(r4)	;set destination process
	call	$SCHED			;complete his CCB
4$:	return



;connect complete processor

request:clr	r0			;ask NRM for the PCB address
	bisb	c.prm1(r4),r0		;for this pipe number..
	mov	nrmpix(r5),r1		;...
	CALL$P	#$pcbdb,r1,<r0>		;...
	bic	#ps.ci,p.sts(r0)	; clear connect initiated
	cmp	c.sts(r4), #s.ssuc	;connect successful?
	bne	10$			;close up shop
	bis	#ps.cc,p.sts(r0)	; set connect completed
	ndrq$	,,flow(r5)	 	; request some segments
	movb	flow(r5),p.segs(r0)
	br	11$
10$:
	nabo$	p.num(r0)		; connect accept not successful so
					; abort the session.
11$:	return				; exit
	.SBTTL	TRANSMIT ENABLE PROCESSORS
;
;
;  INPUTS:	R4 -> CCB
;		R3 = SUBFUNCTION = C.MOD(R4)
;
;
NRDXME:	clr	r0			; pick up his pix
	bisb	c.pix(r4),r0		;...
	mov	nrmpix(r5),r1		;..and get to the TCB
	CALL$P	#$tcbdb,r1,<r0>
	mov	t.pcbd(r0),r0		;point to pcb for this pipe
	movb	p.num(r0),c.prm1(r4)	;set up ULA
	movb	p.pix(r0),c.pix(r4)	;...
	movb	p.lla(r0),c.lix(r4)	;set up LLA
	call	$SCHED			;ship it off
	return
;
;  DATA AND INTERRUPTS RECEIVED FROM SESSION CONTROL
;

scint:
scdata:	clr	r0			;ask NRM for the PCB address
	bisb	c.prm1(r4),r0		;for this pipe number..
	mov	nrmpix(r5),r1		;...
	CALL$P	#$pcbdb,r1,<r0>		;...
	mov	p.opn(r0),r1		;get to the tcb

	movb	t.pri(r1),c.pix(r4)	;and set it up
	call	$SCHED			;pass it on
	return
	.SBTTL control function processors

; NRM START AND STOP FUNCTIONS

CTLSTP:
CTLSTR:	
	movb	c.pix(r4),r3		; save who it came from
	movb	c.lix(r4),c.pix(r4)	; set destination pix
	movb	r3,c.lix(r4)
	call	$SCHED			; send off control CCB
	return



;  CONTROL COMPLETE

NRDCCP:
	movb	c.pix(r4),r3		;who it came from
	movb	c.lix(r4),c.pix(r4)	; set return pix	
	movb	r3,c.lix(r4)		; not really important,,,ha ha ha
	call	$SCHED			; return ccb 
	return
	.sbTTL code to handle disconnect proceedings
;
; sctrm:   session control initiation of disconnection
;
.enabl lsb
 
sctrm:	clr	r0			;ask NRM for the PCB address
	bisb	c.prm1(r4),r0		;for this pipe number..
	mov	nrmpix(r5),r1		;...
	CALL$P	#$pcbdb,r1,<r0>		;...
	mov	r4,-(sp)		;save disconnect ccb
	call	$ccbgt			;try for a ABORT ccb
	bcc	1$			;got one
	mov	(sp)+,r4
	jmp	nrdque			;resource error
1$:
	mov	r4,-(sp)		;save r4
	call	nrdfls			;clean out resource queue
	mov	(sp)+,r4
	movb	p.pix(r0),c.pix(r4)	;set dest pix
	nabo$	p.num(r0)		;clean up the link on my side
	mov	(sp)+,r4
	ndak$				;send abort ccb back to SC
	return

nrdast:
	clr	r0			;pipe number to close
	bisb	c.prm1(r4),r0		;..for this pipe
	call	$ccbrt			;return the ccb
	mov	nrmpix(r5),r1		;ask NRM to close the pipe
	CALL$P	#$pcbcl,r1,<r0>		;...
	return
	.end