;*****************************************************************************
;		L E V E L S . M A C
 
	.TITLE LEVELS
	.IDENT	/V 3.0/
	.ENABL	LC
	.NLIST	BEX,CND,ME
	.SBTTL	AUTHOR'S CREDITS
 
;	Authors:	RANDY ADAMS, HENRY TUMBLIN
;			THE JACKSON LABORATORY COMPUTER SERVICE
 
;	DATE: 		APRIL 10,1978
 
;	VERSION:	3.0
 
;	RESIDENCE:	DB1:[1,20]LEVELS.*
 
;	MODULE NAME:	LEVELS -- SYSTEM STATUS INDICATOR
 
;	FOR:		SYSTEMS/UTILITIES
 
;	CORE REQUIREMENTS:  APPROX. 2-K WORDS
 
;	MACHINE/SYSTEM:	PDP11/70-IAS V2.0
 
;	TYPE/LANGUAGE:	MAIN/ASSEMBLER
 
;	INDIRECT COMMAND FILE: LEVELS.CMD
 
;	ABSTRACT:	THIS ROUTINE DISPLAYS ALL JOBS CURRENTLY
;			EXECUTING UNDER IAS, THE JOB NAME, THE
;			USER NAME, THE UIC, AND THE AMT OF TICS EACH
;			JOB HAS ACCUMULATED SO FAR.
 
;	EDITS:
;
;	Date	By	Reason
;    ---------	------	------------------------------------------------------
;    10-APR-78	HRT	Got rid of some unnecessary buffer space. Reduced
;			overall task size to 2-K.
;    12-MAY-78	HRT	Added Utilization stuff.
;    12-MAY-78	HRT	Added Node pool and Max Hole stuff.
;    12-MAY-78	HRT	Added message to SY:[1,1]NOTICE.TXT.
;    13-MAY-78	HRT	Added "Total Terminals Logged in" message.
;    23-Jul-78	HRT	Re-evaluated utilization figure and added VT-52
;			conditional assembly stuff 
;    11-Sep-78	HRT	Changed utilization calculation to use the FPP
;			because of overflow errors.
;    12-Sep-78	HRT	Re-enabled utilization message to Notice.TXT.
;    11-Nov-78	HRT	Fixed up device load pending message and
;			modified output to use $EDMG to format messages.
;    13-Nov-78	HRT	Added node warning message. Added device name
;			to display.
;

	.SBTTL	TELL THE ASSEMBLER WHICH LIBMACS TO USE
;*****************************************************************************
 
	.MCALL	DIR$,FSRSZ$,QIOW$,EXIT$,CALL,RETURN,EXIT$S
	.MCALL	WAIT$,MRKT$S,WTSE$S,GTIM$S,ALTP$S,RUN$,RQST$
	.MCALL	GTIM$,CVTA$,C$C,SAVE,UNSAVE
	.MCALL	FDBDF$,FDOP$A,FDRC$A,FDBK$A,OPNS$M,CLOSE$
	.MCALL	FINIT$,MVCL
 
	.SBTTL	DEFINE ALL LOCAL MACROS
 
 
	.MACRO	PRINT,A,B,C=0
	MOV	A,WRITE+Q.IOPL		; GET BUFFER POINTER
	MOV	B,WRITE+Q.IOPL+2  	; GET BUFFER LENGTH
	MOV	C,WRITE+Q.IOPL+4  	; SET PRINT TYPE
	DIR$	#WRITE			; OUTPUT TO SCREEN
	.ENDM	PRINT
 
	.MACRO	INH0			; INHIBIT TASK SWITCHING MACRO
	MOV	PS.EXP,-(SP)
	BIS	#140,PS.EXP
	.ENDM	INH0
 
 
	adds=1				; define for an ADDS CONSUL-980
; 	vt52=1				; define if for a VT-52
; 	vt100=1				; define for a VT-100
; 	la36=1				; define for a LA36 or ASR-33

;*****************************************************************************

	.sbttl	Set up the FCS stuff.
;***************************************************************************
 
	INLUN=2				; FILE LUN
	FSRSZ$	0			; 0 FOR BLOCK I/O
 
MESFDB:	FDBDF$				; Allocate a File Descriptor Block
 
	FDRC$A	FD.RWM			; File Access :
					; ...Block I/O to be performed

	FDBK$A	INBUF,512.		; Block Data Attributes :
					; ...Input buffer is INBUF
					; ...Input buffer size is 512. bytes

	FDOP$A	INLUN,NOTIC		; File Open :
					; ...FCS Lun is INLUN
					; ...File name descriptor block
 
NOTIC:	.WORD	DEVS,DEV		; Length of device string, string @
	.WORD	UICS,UIC		; Length of UIC string, string @
	.WORD	FNAMS,FNAM		; Length of filename string, string @
 
DEV:	.ASCII	/LB00:/			; Device name
	DEVS=.-DEV			; string length
 
UIC:	.ASCII	/[1,1]/			; UIC
	UICS=.-UIC			; string length
 
FNAM:	.ASCII	/NOTICE.TXT/		; File name
	FNAMS=.-FNAM			; string length
 
;*****************************************************************************

	.sbttl	Impure Area + Buffers
;****************************************************************************

	.psect	impur,d,rw,rel 

LEVCT:	.BLKB	16.			; Level count
UICP:	.BLKW	64.			; UIC programmer number
UICG:	.BLKW	64.			; UIC group code
CPU:	.BLKW	64.			; CPU time in tics
STD:	.BLKW	64.			; STD entry for task
TS:	.BLKW	64.			; Total task size
NAME:	.BLKW	64.			; User name
TERM:	.BLKW	64.			; Terminal number






;*****************************************************************************

	.sbttl	QIO's, Status blocks, and other DPB's
;*****************************************************************************

RUNN:	RUN$	LEVELS,SYS,200,,,20.,2	; RERUN EVERY 20. SECONDS

RDREC:	QIOW$	IO.RVB,INLUN,1,200,IOSTAT,,<INBUF,512.,,,1>
WTREC:	QIOW$	IO.WVB,INLUN,2,200,IOSTAT,,<INBUF,512.,,,1>
 
WRITE:	QIOW$	IO.WVB,1,1,200,,,<0,0,0>	; TERMINAL WRITE QIO
 
COUNT:	.BLKB	2
CLIR:	.RAD50	/CLI/			; CLI match word
IOSTAT:	.WORD	0,0
LEVEL:	.BLKW	1			; Current level number
NLEV:	.WORD	0			; Total number of levels
NODE1:	.WORD	0			; TOTAL NUMBER OF FREE NODES
HOLE:	.WORD	0			; TOTAL MAX HOLE
USERS:	.WORD	0			; # OF ACTIVE TERMINALS (CLI'S)
TEMP:	.blkw	10.			; Work area
LDDEV:	.WORD	0			; LOADABLE DEVICE WORD
INBUF:	.BLKW	256.			; INPUT BUFFER FOR MESSAGE FILE.
JBLNAL:	.BLKW	10.			; Argument list for job line
DLTSAV:
	.REPT	4			; Device load table save area
	.BLKW	1			; Device name
	.BLKW	1			; Unit Number
	.BLKW	6			; Requested Volume name
	.ENDR
 
;*****************************************************************************

	.SBTTL	DATE AND TIME BUFFERS
;*****************************************************************************
 
	C$C				; DEFINE ALL CONTROL CHARACTERS
 
	.EVEN
GETTIM:	GTIM$	TIMBUF			; GET THE TIME AND TODAY'S DATE
TIMBUF:	.BLKW	8.			; BUFFER TO RECEIVE TIME INFORMATION.
 
BUZBUF:	.BYTE	BEL,BEL,BEL,BEL
	BUZS=.-BUZBUF

	.SBTTL	DEFINE STORAGE AREA.

HDRLIN:	.ASCIZ	"%N** Current Task Status  %Y %3Z %4SPDP-11/70 IAS V2.0"

JOBLIN:	.ASCIZ	"%N%S%2R%2S%12E  %2E%O	[%O,%O]    	%M	%2R	%D"

LVLLIN:	.ASCIZ	"%NLevel # %D"

STABUF:	.ASCIZ	"%2N%10SUser= %D Swap= %D Null= %D Elap= %D"

UTMES:	.ASCIZ	"%N%10SNOTE: Current Utilization is now at %D%"

NDMES:	.ASCII	"%N%5STotal Nodes available = %D"
	.ASCII	"%5SMax Hole = %D"
	.ASCIZ	"%N%10STotal terminals logged in = %D"

LODMES:	.ASCIZ	"%N%16SLoad Volume %12A on %2A%O"

NOTMES:	.ASCIZ	"		NOTE: Current utilization is now at %D%   "
  
WRNMES:	.ASCIZ	"%L%10SWarning     ---     Node pool dangerously low"

	.EVEN
 
	.if	df	vt52
	.mcall	.vt52.
	.vt52.				;define screen commands
clrscn:	.byte	esc,crshom,esc,ereos,esc,crshom
	clrsz=.-clrscn
	.endc
	
	.if	df	adds
clrscn:	.byte	ff
	clrsz=.-clrscn
	.endc
 
	.even
;*****************************************************************************


	.sbttl	Description
;*****************************************************************************

;	THIS PROGRAM GOES INTO THE "BOWELS" OF THE IAS COMMON AREA 
;	TO FIND OUT SOME INFORMATION CONCERNING TIMESHARING TASKS
;	IN MEMORY AND THE LIKE. TO DO THIS, IT FIRST DISABLES
;	TASK SWITCHING, GRABS ALL THE INFO IT NEEDS FROM IASCOM
;	AND THEN ENABLES TASK SWITCHING SO THINGS CAN PROCEED
;	NORMALLY. THE PARAMETERS THAT "LEVELS" CURRENTLY DISPLAY
;	ARE:
;	1) EACH TIMESHARING(NO REALTIME) TASK IN MEMORY.
;	2) THE USER ID CURRENTLY RUNNING THE TASK.
;	3) THE TERMINAL THAT THE USER IS LOGGED IN UNDER.
;	4) THE USERS  LOGIN U.I.C.
;	5) THE AMOUNT OF CPU TIME THAT EACH JOB HAS USED IN TICKS.
;	6) THE INSTALLED TASK NAME(IF OTHER THAN JOB NAME).
;	7) THE CURRENT SYSTEM UTILIZATION AS A FUNCTION OF SWAPPING.
;	8) THE TOTAL FREE NODES AND MAX HOLE AVAILABLE.
;	9) IF THERE IS A DEVICE LOAD PENDING, A MESSAGE WILL BE SENT
;	   TO THE OPERATOR EACH TIME LEVELS IS RUN, UNTIL THE
;	   LOAD REQUEST IS SATISFIED.
;	10) IF THE TOTAL AVAILABLE NODES OR MAX HOLE DROPS BELOW
;	    75, A WARNING MESSAGE WILL BE SENT TO THE OPERATOR'S
;	    CONSOLE TO WARN THAT A CRASH IS IMMINENT.
;	11) The actual task size in words.
;
;	THIS PROGRAM IS CURRENTLY RUNNING ON A ADDS CONSUL-580 VIDEO TERMINAL
;	BUT THERE IS A PROVISION IN THE ASSEMBLY PARAMETERS IN CASE
;	A VT-52 OR LA-36 IS TO BE USED INSTEAD.
;
;	THIS ROUTINE USES PART OF ONE OF THE TIMING PARAMETER WORDS
;	IN IASCOM TO PUT THE PREVIOUS SYSTEM UTILIZATION FIGURE
;	SO AS TO GIVE A MORE ACCURATE(MAYBE?) UTILIZATION FIGURE.
;	THE CURRENT LIMITS OF THIS PROGRAM ARE 32 TIMESHARING
;	JOBS TO BE DISPLAYED.
;	
;	Note: This utilization parameter was a modification to the
;	      IASCOM database. Reference symbol .SUTIL within
;	      IASCOM for a description of this parameter.
;
;
;*****************************************************************************

	.SBTTL	INITIALIZATION SECTION
;*****************************************************************************
 
START:
	CLR	R1			; CLEAR R4
	CLR	R4			; AND R1 FOR LATER STUFF
	MOV	.UTLNO,NLEV		; GET NUMBER OF TIMESHARING LEVELS
	INC	NLEV			; ADD 1 AND STORE IN NLEV(For BATCH)
	INH0				; INHIBIT TASK SWITCHING
 
; 	NOW SEE IF THERE IS A DEVICE LOAD PENDING. IF THERE
; 	IS, THEN LET'S SET A DEVICE LOAD PENDING FLAG
; 	AND CONTINUE. AT THE TAIL END OF THE DISPLAY, IF THE
; 	DEVICE LOAD PENDING FLAG IS SET, WE'LL TELL THE
; 	OPERATOR TO MOUNT THE DRIVE.
; 
 
	TST	.DLTNO			; ANY DEVICES IN USE ?
	BEQ	1$			; NO -- GO ON
	MOV	.DLTBA,R0		; GET DEVICE LOAD TABLE ADDRESS
	CMPB	#1,DV.ST(R0)		; IS LOAD REQUEST PENDING ?
	BNE	1$			; NO LOAD PENDING,  CONTINUE
	INC	LDDEV			; SET DEVICE LOAD PENDING FLAG
	CALL	GETLDD			; Transfer the device load info
1$:	MOV	.UTLHD,R0		; GET UTL LISTHEAD
LEV:	INC	R1			; MOVE LEVEL # TO R1
	CMP	R1,NLEV			; SEE IF AT LAST LEVEL 
	BMI	LEV1			; NO, THEN CHECK THIS LEVEL
	JMP	UTIL			; ALL DONE, CALCULATE UTILIZATION
 
;*****************************************************************************

;*****************************************************************************

LEV1:	MOV	R1,LEVEL		; SAVE CURRENT LEVEL
	MOV	Z.NL(R0),R5		; SAVE NEXT LEVEL IN R5
	MOV	Z.FJ(R0),R2		; SAVE FIRST UJN ADDRESS
	MOV	Z.LJ(R0),R3		; SAVE LAST UJN ADDRESS
	TSTB	Z.NE(R0)		; IS ANYTHING AT THIS LEVEL?
	BEQ	NEXT3			; EQ -- THEN THIS LEVEL'S EMPTY
	MOV	R2,R0			; ELSE PUT FIRST UJN @ IN R0
 
 
; 	NOW CHECK TO SEE IF IT'S A CLI. IF IT IS, THEN
; 	WE DON'T WANT TO DISPLAY IT.(...PDS,...SCI, ETC)
 
 
DEQ:	CMP	J.JB(R0),CLIR		; IS THIS A CLI
	BNE	DEQ1			; NO... GO ON
	INC	USERS			; KEEP TRACK OF # OF ACTIVE CLI'S
	CMP	R0,R3			; IS THIS THE LAST UJN
	BEQ	NEXT3			; YES  GO TO NEXT LEVEL
	MOV	@R0,R0			; NO GO TO NEXT NODE
	BR	DEQ			; AND GO CHECK NEXT UJN

;*****************************************************************************

	.SBTTL	GET JOBS AT THIS LEVEL
;*****************************************************************************
 
;	NOW PULL OUT ANY JOBS RUNNING AT THIS LEVEL OF TIMSHARING
;	AND STORE THEM IN A BUFFER SO WE CAN TRANSLATE AND FORMAT
;	THEM LATER ON. 
 
DEQ1:	MOV	J.JB(R0),NAME(R4)	; GET JOB NAME
	MOV	J.JB+2(R0),NAME+2(R4)	; 2 RAD-50 WORDS
	MOV	J.TA(R0),TERM(R4)	; SAVE TERMINAL NODE ADDRESS
	MOVB	J.PC(R0),UICP(R4)	; SAVE PROGRAMMER CODE
	MOVB	J.GC(R0),UICG(R4)	; SAVE GROUP CODE
	MOV	J.AC+2(R0),CPU(R4)	; SAVE CPU TIME
	MOV	J.AT(R0),R2		;  GET ATL NODE @
	MOV	J.TS(R0),TS(R4)		; + Save total task size
	MOV	A.TD(R2),STD(R4)	; SAVE STD ENTRY
	INC	COUNT			; BUMP UP COUNT
	ADD	#4,R4			; POINT TO NEXT OPEN BUFFER ENTRY
	CMP	R0,R3			; IS THIS LAST UJN
	BEQ	NEXT3			; YES, GO TO NEXT3
	CMP	#100,R4			; MORE THAN 8 ENTRIES ??
	BMI	NEXT3			; YES BRANCH OUT
	MOV	@R0,R0			; NO, GET NEXT LINK
	JMP	DEQ			; AND GET NEXT NAME
NEXT3:	MOVB	COUNT,LEVCT(R1)		; SAVE # OF UJNS
	CLR	COUNT			; CLEAR COUNT
	MOV	R5,R0			; GET NEXT LEVEL
	JMP	LEV			; GO TO NEXT LEVEL

;*****************************************************************************

;*****************************************************************************

UTIL:	CALL	UTIL0			; FIND CURRENT SYSTEM UTILIZATION
	CALL	NODE			; AND FIND THE # OF NODES AVAILABLE
					; AND MAX HOLE.
EDEQ:	CALL	..ENB0			; ENABLE TASK SWITCHING

	DIR$	#GETTIM			; Get current time and date

	MOV	#INBUF,R0		; Set up to output
	MOV	#HDRLIN,R1		; Point to format line
	MOV	#TIMBUF,R2		; Set p-list pointer
	CALL	$EDMSG			; Convert to ASCII
	PRINT	#CLRSCN,#CLRSZ		; CLEAR THE SCREEN
	PRINT	#INBUF,R1		; AND OUTPUT HEADER LINE

	CLR	R1			; CLEAR R1
	CLR	R4			; CLEAR POINTER
EDEQ1:	INC	R1			; ADVANCE LEVEL POINTER
	CMP	R1,NLEV			; LAST LEVEL ????
	BMI	DEQ2			; YES GO WAIT
	JMP	WAIT			; 

DEQ2:	MOV	R1,LEVEL		; SET UP LEVEL
	MOVB	LEVCT(R1),R5		; PUT UJN COUNT IN R5
	BEQ	EDEQ1			; RIGHT GO TO NEXT LEVEL
	MOV	R1,R3			; SAVE OFF R1 IN R3
	MOV	#INBUF,R0		; Set buffer pointer
	MOV	#LVLLIN,R1		; Point to format line
	MOV	#LEVEL,R2		; Point to the actual data
	CALL	$EDMSG			; Convert and format
	PRINT	#INBUF,R1		; And output the the terminal
 
;*****************************************************************************

;*****************************************************************************

PRI:	MOV	#JBLNAL,R0		; Use R0 to set up job arg. list
	MOV	NAME(R4),(R0)+		; GET FIRST HALF OF RAD50 NAME
	MOV	NAME+2(R4),(R0)+	; GET SECOND HALF
	MOV	TERM(R4),R2		; GET TERMINAL NODE ADDRESS
	MOV	R2,(R0)			; Set pointer to user terminal node
	ADD	#I.UN,(R0)+		; Set pointer to username string
	MOV	R2,(R0)			; Set pointer to user terminal node
	ADD	#I.DN,(R0)+		; Set to display device name
	MOVB	I.TT(R2),R1		; GET TERMINAL #
	MOV	R1,(R0)+		; AND PLACE IN ARGLST
	MOV	UICG(R4),(R0)+		; PUT BINARY GROUP CODE IN R1
	MOV	UICP(R4),(R0)+		; PUT BINARY PROG CODE IN R1
	MOV	CPU(R4),(R0)+		; Get CPU time in TICS
	MOV	STD(R4),R2		; GET SYSTEM TASK DIR ADDRESS
	MOV	S.TN(R2),(R0)+		; GET FIRST TASK NAME
	MOV	S.TN+2(R2),(R0)+	; AND SECOND HALF
	MOV	TS(R4),R1		; TASK SIZE IS IN 32 WORD BLKS
	MUL	#32.,R1			; SO ADJUST ACCORDINGLY
	MOV	R1,(R0)+		; AND PLACE IN ARGLST
	MOV	#INBUF,R0		; Get output buffer pointer
	MOV	#JOBLIN,R1		; Point to format string
	MOV	#JBLNAL,R2		; Point to argument list
	CALL	$EDMSG			; And format the mess
	PRINT	#INBUF,R1		; Output the line to the screen
PRI1:	ADD	#4,R4			; GO  TO NEXT NAME
	DEC	R5			; DECREMENT COUNT
	BNE	PRI			; IF NO MORE UJN THEN GO TO NEXT LEV
NEXT:	MOV	R3,R1			; RESTORE R1
	JMP	EDEQ1			; NEXT LEVEL
WAIT:


; 	NOW TRANSLATE THE SYSTEM UTILIZATION
; 
	CLR	R3			; Clear count
	MOV	#INBUF,R0		; Set output buffer pointer
	MOV	#STABUF,R1		; Set up for Statistics line
	MOV	#TEMP,R2		; Point to the statistics
	CALL	$EDMSG			; Process the line
	ADD	R1,R3			; Accumulate total line length
	MOV	#UTMES,R1		; Set up for utilization line
	MOV	#.SUTIL,R2		; Point to utilization word
	CALL	$EDMSG			; Process the line
	ADD	R1,R3			; Accumulate total line length
	MOV	#NDMES,R1		; Set up for node,max hole, total term
	MOV	#NODE1,R2		; Point to the appropriate spot
	CALL	$EDMSG			; process this line
	ADD	R1,R3			; Accumulate total line length
	PRINT	#INBUF,R3		; And output the total message

	CMP	#75.,NODE1		; Is the node pool depleted??
	BHI	LDPEND			; No - check for load pending
	MOV	#INBUF,R0		; Else send message
	MOV	#WRNMES,R1		; Indicating this fact
	MOV	#NODE1,R2		; to the system operator
	CALL	$EDMSG			; Format message
	PRINT	#BUZBUF,#BUZS		; Sound the bell
	PRINT	#INBUF,R1		; And print warning message

LDPEND:	TST	LDDEV			; Is there a load request pending?
	BEQ	FILSTF			; EQ - No
	MOV	#JBLNAL,R0		; Set up the parameter list
	MOV	#DLTSAV+4,(R0)+		; Point to volume name
	MOV	#DLTSAV,(R0)+		; Point to device name
	MOV	DLTSAV+2,(R0)+		; Set unit number
	MOV	#INBUF,R0		; Set outbuf pointer
	MOV	#LODMES,R1		; Set format string @
	MOV	#JBLNAL,R2		; Set arglist pointer
	CALL	$EDMSG			; Format the line
	PRINT	#INBUF,R1		; Output the line
	PRINT	#BUZBUF,#BUZS		; And inform the operator

;*****************************************************************************

	.sbttl	File I/O stuff
;*****************************************************************************
FILSTF:
 	OPNS$M	#MESFDB			; OPEN NOTICE.TXT

 	DIR$	#RDREC			; READ THE FIRST BLOCK

	MOV	#INBUF+2,R0		; Point to output area
	MOV	#NOTMES,R1		; Point to input format string
	MOV	#.SUTIL,R2		; Point to utilization figure

	CALL	$EDMSG			; And format the message

 	DIR$	#WTREC			; NOW REWRITE THE BLOCK

 	CLOSE$	#MESFDB			; Close the file

	DIR$	#RUNN			; RUN OURSELVES AGAIN

STOP:	EXIT$S				; AND EXIT GRACEFULLY(ALWAYS)
;*****************************************************************************

	.sbttl	Utilization routine
;*****************************************************************************
 
;	This routine calculates the system utilization
;	as a function of work done versus elapsed time.
 
;	The calculation performed is:
 
;	  UTILIZATION = (USER_TIME + SWAP_TIME)/ELAPSED_TIME * 100%

UTIL0:	MOV	.SUTIM+2,TEMP		; Save all statistics
	MOV	.SPTIM+2,TEMP+2		; ...
	MOV	.SNTIM+2,TEMP+4		; ...
	MOV	.SSTIM+2,TEMP+6		; ...
	CLR	.SUTIM+2		; Clear all statistics
	CLR	.SPTIM+2		; For next time
	CLR	.SNTIM+2		; ...
	CLR	.SSTIM+2		; ...

	AC0=%0				; Define the FP registers 
	AC1=%1

	LDCIF	TEMP,AC0		; LOAD TOTAL TIME USER JOBS
	LDCIF	TEMP+2,AC1		; LOAD TOTAL SWAP TIME
	ADDF	AC1,AC0			; GET TOTAL UTILIZATION
	LDCIF	TEMP+6,AC1		; GET TOTAL ELAPSED TIME
	DIVF	AC1,AC0			; GET UTILIZATION
	LDCIF	#100.,AC1		; SET UP TO CONVERT TO %
	MULF	AC1,AC0			; GET PERCENTAGE
	STCFI	AC0,.SUTIL		; STORE COMPLETED %
	RETURN				; AND LEAVE

;*****************************************************************************

	.sbttl	Node and Max-Hole module
;*****************************************************************************
 
NODE:	CALL	$SAVAL			;SAVE ALL GP REGISTERS
	MOV	.POLLH,R4		;GET POOL LIST HEAD
	CLR	R3			;CLEAR LARGEST HOLE COUNT
	CLR	R2			;CLEAR TOTAL NODES COUNT
10$:	ADD	2(R4),R2		;ADD IN NEW HOLE SIZE
	CMP	2(R4),R3		;IS THIS THE LARGEST HOLE SO FAR?
	BLOS	20$			;BR IF NO.
	MOV	2(R4),R3		;GET NEW SIZE
20$:	TST	(R4)			;DONE??
	BEQ	30$			;BRANCH IF YES
	MOV	@R4,R4			;ELSE MOVE TO NEXT HOLE
	BR	10$			;LOOP TILL THRU
30$:	ASH	#-4,R3			;GET PROPER HOLE
	ASH	#-4,R2			;AND NODE COUNT
	MOV	R3,HOLE			;SAVE MAX HOLE
	MOV	R2,NODE1		;AND NO. OF AVAILABLE NODES
	RETURN

;*****************************************************************************


	.SBTTL	Device load table save module
;*****************************************************************************

GETLDD:	CALL	$SAVAL			; Save all registers
	MOV	.DLTBA,R0		; Get device table base @
	MOV	.DLTNO,R1		; Number of devices to load
	MOV	#DLTSAV,R2		; Device load save area
100$:	MOV	4(R0),(R2)+		; Save the Device name
	MOVB	6(R0),R3		; Save the
	MOV	R3,(R2)+		; Unit Number
	MOV	R0,R3			; Save R0
	ADD	#10,R3			; Point to Volume label
	MOV	#6,R4			; And its length in words
110$:	MOV	(R3)+,(R2)+		; Move into position
	SOB	R4,110$			; Loop until thru
	ADD	#20,R0			; Point to next entry
	SOB	R1,100$			; Loop until all requests saved
	RETURN				; Return to calling proc.

;*****************************************************************************
 
	.END	START
