	.TITLE NRBDMP   DISPLAY STATUS OF NRB'S IN ROUTING DATABASE
	.IDENT	/1.0/
	.NLIST	BEX

;.begin.doc ************************** begin.doc
;  
; .c ;Module name: 
; .c ;^&NRBDMP\&
; .nf
; .x NRBDMP>Defined
; Source:NRBDMP.MAC
; Designer           :DAVE LUECK
; Author             :DAVE LUECK
; Date of last update:17-MAR-87
; Revision level     :1.0
; 	
; .C ;Formal Parameter List
; Receives:
;     
; Returns:
; 	
; Accesses common(s):
; .X RTRDBS>Common
;    RTRDBS                     RESIDENT COMMON ROUTING DATABASE 
;                               (ACCESSED READONLY)
; 	
; Accesses file(s):
; 	
; Other modules referenced:
; 	
; .X FMTHDR>Referenced
;         FMTHDR                FORMATS THE DATABASE HEADER FOR DISPLAY
; .X FMTNRB>Referenced
;         FMTHDR                FORMATS EACH NRB FOR DISPLAY
; 
; .SK
; .fill
; .SK
; Description:
; .sk    
; 	This program will display the current status of the routing
; database.  The database header is displayed first.  Then, each NRB
; is displayed including the status of each message id routed by an NRB.
; Since this program only displays the database, it is mapped readonly
; so that no writes are possible.
; end.doc ****************************** end.doc  
	.PAGE

	.MCALL	QIOW$S			; QIO AND WAIT
	.MCALL	DIR$			; DIRECTIVE CALL
	.MCALL	ATRG$			; ATTACH REGION
	.MCALL	CRAW$			; CREATE ADDRESS WINDOW
	.MCALL	EXIT$S			; EXIT TASK
	.MCALL	NETDF$			; NETWORK OFFSETS
	.MCALL	RTRHED			; DATABASE HEADER OFFSETS
	.MCALL	NRBDEF			; NRB OFFSETS

	NETDF$				; GET OFFSETS
	.LIST 	ME
	RTRHED
	NRBDEF
	.NLIST	ME

	CEFN = 1			; CONSOLE QIO EVENT FLAG
	ICO = 5				; CONSOLE MESSAGES

	.PSECT	$DATA,RW,D,CON,REL,LCL
;
; DPB'S TO ATTACH AND MAP ROUTING DATABASE
;
CRWND:
	CRAW$	WDB	; CREATE ADDRESS WINDOW
;
; WINDOW DESCRIPTOR BLOCK
;
WDB:
	.BYTE	0	; UNUSED
	.BYTE	2	; W.NAPR APR (2)
	.WORD	0	; W.NBAS RETURN V. A. OR WINDOW
	.WORD	0	; W.NSIZ DESIRED SIZE OF WINDOW IN 32W BLOCKS
	.WORD	0	; W.NRID TASK REGION ID (FROM CREATE REGION)
	.WORD	0	; W.NOFF OFFSET TO START MAP
	.WORD	0	; W.NLEN LENGTH TO BE MAPPED IN 32W BLOCKS
	.WORD	WS.RED!WS.MAP!WS.UDS		; W.NSTS STATUS 
		; WS.MAP= IF WINDOW IS TO BE MAPPED
		; WS.RED= READ ACCESS
		; WS.UDS= CREATE WINDOW IN USER "D" SPACE
;
ATREG:
	ATRG$	RDB	; ATTACH REGION
;
; REGIONS DESCRIPTOR BLOCK
;
RDB:
	.WORD	0	; R.GID RETURNDED ID TO THE CREATED REGION
	.WORD	0	; R.GSIZ SIZE OF REGION TO CREATE IN 32W BLOCKS
	.RAD50	/RTRDBS/ ; R.GNAM NAME OF REGION
	.WORD	0,0	; R.GPAR PARTITION NAME (0= OUR PARTITION)
	.WORD	RS.RED			   ; R.GSTS STATUS
	.WORD	010400	; R.GPRO PROTECTION, ALLOW ONLY OWNER AND SYSTEM FULL
			; ACCESS, REST READ ACCESS
ARGHDR:
	.WORD	1	; 1 PARAMETER PASSED TO 'FMTHDR'
	.WORD	0	; 'HEADER' PARAMETER
ARGNRB:
	.WORD	3	; 3 PARAMETERS PASSED TO 'FMTNRB'
	.WORD	0	; 'NRB' PARAMETER
	.WORD	0	; 'NRBID' PARAMETER
	.WORD	0	; 'IDCNT' PARAMETER
CONSTS:
	.WORD	1,0	; CONSOLE QIO STATUS
MSGBUF:
	.BLKB	132.	; MESSAGE BUFFER
ATTERR:	
	.ASCIZ	/%NNRBDMP -- DIRECTIVE ERROR ATTACHING DATABASE; DSW: %D%N/
MAPERR:	
	.ASCIZ	/%NNRBDMP -- DIRECTIVE ERROR MAPPING DATABASE; DSW: %D%N/
FINISH:
	.ASCII	/%3NNo more NRB's; Number of NRB's in database: %D/
	.ASCIZ	/%2NNRBDMP -- EXIT%2N/
	.PAGE

	.PSECT	$CODE,RO,I,CON,REL,LCL
START:
;
; ATTACH TO THE REGION
;
	DIR$	#ATREG		; ATTACH TO THE REGION
	BCC	2$		; ATTACH OK?
	MOV	#ATTERR,R1	; ADDRESS OF FORMAT STRING
	BR	3$		; LOG ERROR
;
; CREATE ADDRESS WINDOW AND MAP
;
2$:
	MOV	RDB+R.GSIZ,WDB+W.NSIZ  ; SET SIZE OF WINDOW
	MOV	RDB+R.GID,WDB+W.NRID   ; COPY REGION ID
	DIR$	#CRWND		; CREATE THE WINDOW
	BCC	5$		; EVERYTHING OK?
	MOV	#MAPERR,R1	; ADDRESS OF FORMAT STRING
3$:
	MOV	#MSGBUF,R0	; ADDRESS OF MESSAGE BUFFER
	BIS	#177400,$DSW	; MAKE SURE DSW IS NEGATIVE
	MOV	#$DSW,R2	; ADDRESS OF DSW
	CALL	$EDMSG		; FORMAT MESSAGE
	QIOW$S	#IO.WVB,#ICO,#CEFN,,#CONSTS,,<#MSGBUF,R1>
	EXIT$S			; FATAL ERROR
5$:
	MOV	WDB+W.NBAS,ARGHDR+2	; GET ADDRESS OF 'HEADER' PARAMETER
	MOV	#ARGHDR,R5		; GET ADDRESS OF HEADER PARAMETER LIST
	CALL	FMTHDR			; DISPLAY DATABASE HEADER
	MOV	WDB+W.NBAS,R3		; GET VIRT ADDRESS OF START OF DBS
	ADD	#HD.NRB,R3		; ADD OFFSET TO POINT TO FIRST NRB
					;   ADDRESS
	MOV	(R3),R3			; GET ADDRESS OF FIRST NRB
	MOV	WDB+W.NBAS,R4		; GET VIRT ADDRESS OF START OF DBS
	ADD	#HD.NCT,R4		; ADD OFFSET TO POINT TO NBR OF NRB'S
	MOV	(R4),R4			; GET NUMBER OF NRB'S DEFINED
	MOV	R4,-(SP)		; SAVE ON STACK FOR LATER USE
10$:
	MOV	R3,ARGNRB+2		; GET ADDRESS OF 'NRB' PARAMETER
	MOV	R3,R2			
	ADD	#N.IDXL,R2		; POINT TO START OF NRBID'S
	MOV	R2,ARGNRB+4		; GET ADDRESS OF 'NRBID' PARAMETER
	MOV	R3,R2
	ADD	#N.IDS,R2		; POINT TO NBR OF ID'S DEFINED FOR NRB
	MOV	R2,ARGNRB+6		; GET ADDRESS OF 'IDCNT' PARAMETER
	MOV	#ARGNRB,R5		; GET ADDRESS OF NRB PARAMETER LIST
	MOV	R3,-(SP)		; SAVE REGISTERS 3 AND 4
	MOV	R4,-(SP)
	CALL	FMTNRB			; DISPLAY NRB
	MOV	(SP)+,R4		; RESTORE REGISTERS 3 AND 4
	MOV	(SP)+,R3
	MOV	N.LNK(R3),R3		; GET ADDRESS OF START OF NEXT NRB
	SOB	R4,10$			; LOOP IF MORE NRB'S

	MOV	#MSGBUF,R0		; PREPARE TO OUTPUT FINAL MESSAGE
	MOV	#FINISH,R1		; GET ADDRESS OF FORMAT STRING
	MOV	SP,R2			; GET STACK ADDRESS CONTAINING NUMBER
					;   OF NRB'S DEFINED IN DATABASE
	CALL	$EDMSG			; FORMAT MESSAGE
	QIOW$S	#IO.WVB,#ICO,#CEFN,,#CONSTS,,<#MSGBUF,R1>

	EXIT$S
	.END	START
