Google
 

Trailing-Edge - PDP-10 Archives - red405a2 - uetp/lib/statuf.mac
There is 1 other file named statuf.mac in the archive. Click here to see a list.
;<UETP.LIB>statuf.MAC.1, 11-Jul-79 11:01:45, Edit by F-S
TITLE statuf - TOPS20 DEVICE STATISTICS
SUBTTL		B.EIBEN			JUL-11-79

;	ACCUMULATOR DEFINITIONS
;	=========== ===========

	A1=	1	;JSYS ARGUMENT AC 1
	A2=	2	;JSYS ARGUMENT AC 2
	A3=	3	;JSYS ARGUMENT AC 3
	A4=	4	;JSYS ARGUMENT AC 4
	T1=	5	;TEMPORARY AC 1
	T2=	6	;TEMPORARY AC 2
	T3=	7	;TEMPORARY AC 3
	T4=	10	;TEMPORARY AC 4
	CI=	11	;AOBJN POINTER TO CDB'S
	KI=	12	;AOBJN POINTER TO KDB'S (IF ANY)
	UI=	13	;AOBJN POINTER TO UDB'S
	P1=	14	;PRESERVED AC 1
	P2=	15	;PRESERVED AC 2
	MA=	16	;MAPPING ADDRESS
	P=	17	;PUSH-DOWN POINTER

	SALL
	.DIRECTIVE .XTABM

	.REQUIRE SYS:MACREL, SYS:MONSYM
	SEARCH MACSYM, MONSYM

; VERSION NUMBERS

	VMAJOR==2		;MAJOR VERSION
	VMINOR==0		;MINOR VERSION
	VWHO==0			;WHO LAST EDITED (0=DEC DEVELOPMENT)
	VEDIT==1		;EDIT NUMBER

	VSTATS== <VWHO>B2+<VMAJOR>B11+<VMINOR>B17+VEDIT
NPDL==140		;SIZE OF PDL

; MISCELLANEOUS SYMBOL DEFINITIONS

SLEEP==^D1000 * ^D600	;SLEEP TIME 10 MINUTES
JOBTTY==0		;JOBTTY TABLE OFFSET
JOBRT==1		;JOBRT TABLE OFFSET
TICKPS==2		;TICKPS TABLE OFFSET
JOBDIR==3		;JOBDIR TABLE OFFSET
TTYJOB==4		;TTYJOB TABLE OFFSET
NCPGS==5		;NCPGS  TABLE OFFSET
DEVNAM==6		;DEVNAM TABLE OFFSET
DEVCHR==7		;DEVCHR TABLE OFFSET
DEVUNT==10		;DEVUNT TABLE OFFSET
DSKERR==11		;DSKERR TABLE OFFSET
DRMERR==12		;DRMERR TABLE OFFSET
SYSVER==13		;SYSVER TABLE OFFSET
SYSTAT==14		;SYSTAT TABLE OFFSET
QTIMES==15		;QTIMES TABLE OFFSET
JOBNAM==16		;JOBNAM TABLE OFFSET
SNAMES==17		;SNAMES TABLE OFFSET
STIMES==20		;STIMES TABLE OFFSET
SPFLTS==21		;SPFLTS TABLE OFFSET
SSIZE==22		;SSIZE  TABLE OFFSET
SNBLKS==23		;SNBLKS TABLE OFFSET
DBUGSW==24		;DBUGSW TABLE OFFSET
LOGDES==25		;LOGDES TABLE OFFSET
PTYPAR==26		;PTYPAR TABLE OFFSET
SYMTAB==27		;SYMTAB TABLE OFFSET
DWNTIM==30		;DWNTIM TABLE OFFSET
JOBPNM==31		;JOBPNM TABLE OFFSET
SYSTAD==32		;SYSTAD TABLE OFFSET
LSTDRN==33		;LSTDRN TABLE OFFSET
APRID==34		;APRID  TABLE OFFSET
TBLENR==35		;KNOWN TABLES
MAXJOB==^D101		;MAX NR OF JOBS SUPPORTED
MAXFRK== 3*MAXJOB	;3 FORKS PER JOB
.TM02==4		;TM02 AS A DEVICE (KDB-TYP)
.TU45==3		;A DEVICE NOT DOING SEEKS
.cblk==1		;cdb-block type
.kblk==2		;kdb-block type
ks.act==1		;kdb is active
.ublk==3		;udb-block type
GENDEL=="."		;GENERATION DELIMITER
NCHPW==5		;NUMBER OF ASCII CHARACTERS PER WORD
BUFSIZ==200		;SIZE OF INPUT TEXT BUFFER
ATMSIZ==BUFSIZ		;SIZE OF ATOM BUFFER FOR COMND JSYS
GJFSIZ==.GJRTY+2	;SIZE OF GTJFN BLOCK USED BY COMND JSYS
PRIMRY== .PRIIN,,.PRIOU	;PRIMARY JFN'S
PAGSIZ== 1000		;SIZE OF A PAGE
MAXREP== ^D72		;MAXIMUM OF 72 CHARS IN REPLIES
REPSIZ== MAXREP/5+1	;SIZE OF USER'S REPLY BUFFER
GJFSIZ== 12		;SIZE OF BLOCK FOR GTJFN
MAXPRT== ^D20		;MAX # OF WORDS TO PRINT IN WEIRD BLKS
SUBTTL	SYMBOL AND DATA STRUCTURE DEFINITIONS

DEFSTR (CDBSTS,CDB+00,17,18)		;STATUS INFO CDB
DEFSTR (CDBPIA,CDB+00,28,3)		;CHANNEL PI ASSIGNMENT
DEFSTR (CDBTYP,CDB+00,35,5)		;CHANNEL TYPE
DEFSTR (CDBPAR,CDB+10,35,36)		;CHANNEL MEM PAR ERRORS
DEFSTR (CDBNXM,CDB+11,35,36)		;CHANNEL NXM'S
DEFSTR (CDBUDB,CDB+16,35,18)		;UDB/KDB ADRESSES

;STRUCTURE DEFINITION FOR KDB'S

DEFSTR (KDBSTS,KDB+00,29,30)		;FLAGS
DEFSTR (KDBTYP,KDB+00,35,5)		;KONTROLER TYPE
defstr (blktyp,kdb+00,30,5)		;block-type
DEFSTR (KDBUDB,KDB+04,35,18)		;UDB ADRESSES (MAX 8) or 16 on DX20/TX02
defstr (kdbact,kdb+00,1,1)		;KDB is active

;STRUCTURE DEFINITION FOR UDB'S

DEFSTR (UDBSTS,UDB+00,17,18)		;STATUS INFO UNIT
DEFSTR (UDBTYP,UDB+00,35,5)		;UNIT TYPE
DEFSTR (UDBDSN,UDB+14,35,36)		;UNIT SERIAL NUMBER
DEFSTR (UDBSEK,UDB+15,35,36)		;TOTAL NR. OF SEEKS
DEFSTR (UDBRED,UDB+16,35,36)		;TOTAL NR. OF READS
DEFSTR (UDBWRT,UDB+17,35,36)		;TOTAL NR. OF WRITES
DEFSTR (UDBSRE,UDB+22,35,36)		;TOTAL NR. OF SOFT READ ERRORS
DEFSTR (UDBSWE,UDB+23,35,36)		;TOTAL NR. OF SOFT WRITE ERRORS
DEFSTR (UDBHRE,UDB+24,35,36)		;TOTAL NR. OF HARD READ ERRORS
DEFSTR (UDBHWE,UDB+25,35,36)		;TOTAL NR. OF HARD WRITE ERRORS

;GETTAB CONVENTIONS

DEFSTR (TABLEN,GETTAB+00,17,18)	;TABLE-LENGTH
DEFSTR (TABADR,GETTAB+00,35,18)	;MONITOR-TABLE ADRESS


;JOB - STATUS DEFINITIONS

DEFSTR (CONDIR,.JBDIR+00,17,18)		;CONNECTED DIR-NR
DEFSTR (LOGDIR,.JBDIR+00,35,36)		;LOGGED IN DIR-NR
DEFSTR (CONTTY,.JBTTY+00,17,18)		;CONTROLING TTY-NR
DEFSTR (TOPFRK,.JBTTY+00,35,18)		;TOP FORK THIS JOB
DEFSTR (WRKSET,.FKNR+00 ,35,18)		;WORKING SET THIS FORK
DEFSTR (JOBNAM,.JBPNM+00,35,36)		;SIXBIT JOB-NAME

;CDB - STATUS BITS

CDBSTAT:ASCII /OFFLN/			;1B0	OFFLINE
	ASCII /PR CM/			;1B1	PRIMARY COMMAND ACTIVE
	ASCII /SC CM/			;1B2	SECONDARY COMMAND ACTIVE
	ASCII /MAINT/			;1B3	MAINTENANCE MODE
	ASCII /MA RQ/			;1B4	MAINTENANCE MODE REQUESTED
	ASCII /RECOV/			;1B5	ERROR RECOVERY IN PROGRESS
	ASCII /CH ST/			;1B6	CHANNEN SUPPORTS STACK
	ASCII /ALT C/			;1B7	ALTERNATE CCW IS CURRENT
CSTSLN==.-CDBSTAT			;NUMBER OF BITS

; UDB - STATUS BITS

UDBSTAT:ASCII /OFFLN/			;1B0	OFFLINE
	ASCII /CHHOM/			;1B1	CHECK HOME-BLOCKS FIRST
	ASCII /POSIT/			;1B2	POSITIONING IN PROGRESS
	ASCII /ACTIV/			;1B3	ACTIVE
	ASCII /HSBAD/			;1B4	BAD BLOCKS ON THIS UNIT
	ASCII /LKBAD/			;1B5	LOCK BIT FOR THIS UNITS BAD BLOCKS
	ASCII /DUALP/			;1B6	DUAL PORT SWITCH ON
	ASCII /MAINT/			;1B7	UNIT IN MAINTENANCE MODE
	ASCII /MNTRQ/			;1B8	MAINT MODE REQUESTED
	ASCII /BOT  /			;1B9	UNIT IS AT BOT
	ASCII /REWND/			;1B10	UNIT IS REWINDING
	ASCII /WLOCK/			;1B11	UNIT IS WRITE LOCKED
	ASCII /MALLW/			;1B12	UNIT HAS MAINT ALLOWED
	ASCII /OPINT/			;1B13	UNIT NEEDS OPR INTERVENTION
	ASCII /1MIN /			;1B14	ONCE A MINUTE MESSAGE
	ASCII /POSRQ/			;1B15	POSITIONING REQUIRED
	ASCII /TAPE /			;1B16   TAPE TYPE DEVICE
	ASCII /TRANS/			;1B17	PSI online/offline/rewind done transition occurred
USTSLN==.-UDBSTAT			;NUMBER OF BITS

;CHANNEL - TYPES

CHNTYP:ASCII /UNDEF/			;0 = NOT DEFINED
	ASCII /RH10 /			;1 = RH10
	ASCII /RH20 /			;2 = RH20
	ASCII /RH11 /			;3 = RH11
CHNLN==.-CHNTYP			;NUMBER OF BITS

;UNIT - TYPES

UNITYP:	ASCII /?????/			;NOT LEGAL
	ASCII /RP04 /			;1 = RP04
	ASCII /RS04 /			;2 = RS04
	ASCII /TU45 /			;3 = TU45
	ASCII /TM02 /			;4 = TM02 *AS A UNIT*
	ASCII /RP05 /			;5 = RP05
	ASCII /RP06 /			;6 = RP06
	ASCII /RP07 /			;7 = RP07
	ASCII /RP08 /			;10= RP08
	ASCII /RM03 /			;11= RM03
	ASCII /TM03 /			;12= TM03
	ASCII /TU77 /			;13= TU77
	ASCII /TM78 /			;14= TM78
	ASCII /TU78 /			;15= TU78
	ASCII /DX20 /			;16= DX20
	ASCII /TU70 /			;17= TU70 (800/1600 200IPS 9TRACK)
	ASCII /TU71 /			;20= TU71 (200/556/800 200 IPS 7TRACK)
	ASCII /TU72 /			;21= TU72 (1600/6250 125 IPS 9TRACK)
	ASCII /TU73 /			;22= TU73 (1600/6250 200 IPS 9TRACK)
UNILN==.-UNITYP				;NUMBER OF BITS

;KONTROLLER - TYPES

KONTYP:ASCII /UNDEF/			;0 = UNDEFINED
	ASCII /TM02 /			;1 = TM02
SUBTTL	MACRO DEFINITIONS
DEFINE BUG(X,Y)<
	JRST [PUSH P,A1
		CRLF
		SAYCR <? STATUS - UNEXPECTED ERROR: Y>
		POP P,A1
	IFIDN <X> <HLT>,<HALTF>
		JRST .+1]>

; FUNCTION DESCRIPTOR BLOCK FOR COMND JSYS
DEFINE CMFDB (TYPE,FLAGS,DATA,HELP,DEFLT,LST)
<	..XX== < FLD(TYPE,CM%FNC) + FLAGS + LST >
  IFNB <HELP>,< ..XX== ..XX+CM%HPP >
  IFNB <DEFLT>,< ..XX== ..XX+CM%DPP >
	..XX
  IFNB <DATA>,<DATA>
  IFB <DATA>,<0>
  IFNB <HELP>, <POINT 7,[ASCIZ\HELP\] >
  IFB <HELP>,  <0>
  IFNB <DEFLT>, <POINT 7,DEFLT >
  IFB <DEFLT>, <0>
>

DEFINE TXT(TEXT) <POINT 7,[ASCIZ\TEXT\]>

	DEFINE O.FLOAT (AC)
<	MOVE A1,OUTJFN
	XLIST
	MOVE A2,AC
	MOVEI A3,10200
	FLOUT
	 ERCAL ERROR
	LIST
>

	DEFINE O.TIME (AC)
<	MOVE A2,AC
	XLIST
	MOVE A1,OUTJFN
	MOVSI A3,200000
	ODTIM
	 ERCAL ERROR
	LIST
>

	DEFINE O.TYP (AC)
<	HRROI A2,AC
	XLIST
	MOVEI A3,5
	MOVE A1,OUTJFN
	SETZ A4
	SOUT
	  ERCAL ERROR
	LIST
>

	DEFINE O.STR (STRING)
<	MOVE A1,OUTJFN
	XLIST
	HRROI A2,[ASCIZ\STRING\]
	SETZM A4
	SETZM A3
	SOUT
	LIST
>


	DEFINE O.OCT(NUM)
<	MOVE A1,OUTJFN
	XLIST
	MOVE A2,NUM
	MOVE A3,[1B2!7B17!10B35]
	NOUT
	  ERCAL ERROR
	LIST
>
;... CONTINUED
;... CONTINUED

	DEFINE O.OCTM (NUM)
<	MOVE A1,OUTJFN
	XLIST
	MOVE A2,NUM
	MOVE A3,[1B0+10]
	NOUT
	  ERCAL ERROR
	LIST
>


	DEFINE O.DEC (NUM)
<	MOVE A1,OUTJFN
	XLIST
	MOVE A2,NUM
	MOVE A3,[1B2!12b17!12B35]
	NOUT
	  ERCAL ERROR
	LIST
>
	DEFINE O.HEX (NUM)
<	MOVE A1,OUTJFN
	XLIST
	MOVE A2,NUM
	MOVE A3,[1B2!7B17!20B35]
	NOUT
	 ERCAL ERROR
	LIST
>

	DEFINE O.CRLF
<	MOVE A1,OUTJFN
	XLIST
	MOVEI A2,.CHCRT
	BOUT
	MOVEI A2,.CHLFD
	BOUT
	LIST
>
	DEFINE MAPTST (ADR)
<	MOVE MA,ADR
	XLIST
	CAML MA,MAPBOT
	CAMLE MA,MAPTOP
	CALL MAPDIR
	LIST
>


	DEFINE GETMPW (AC,LOC)
<	MAPTST LOC
	XLIST
	HRRZ AC,MA
	ADD AC,FDBOFS
	MOVE AC,(AC)
	LIST
>
;... CONTINUED
;... CONTINUED


	DEFINE GETSYM (AC,LOC)
<	HRRZ AC,LOC
	XLIST
	ADD AC,STBOFS
	MOVE AC,(AC)
	LIST
>


	DEFINE PUTSYM (AC,LOC)
<	HRRZ AC,LOC
	XLIST
	ADD AC,STBOFS
	MOVEM AC,(AC)
	LIST
>
	DEFINE TLOAD (AC,LOC,ADR)
<	MOVE MA,LOC
	XLIST
	CAML MA,MAPBOT
	CAMLE MA,MAPTOP
	CALL MAPDIR
	LOAD AC,LOC,ADR
	LIST
>
	DEFINE CRLF
<	MOVEI A1,.CHCRT
	XLIST
	PBOUT
	MOVEI A1,.CHLFD
	PBOUT
	LIST
>

	DEFINE SAY (STRING)
<	HRROI A1,[ASCIZ\STRING\]
	XLIST
	PSOUT
	LIST
>

;... CONTINUED
;... CONTINUED
	DEFINE SAYCR (STRING)
<	HRROI A1,[ASCIZ\STRING
\]
	XLIST
	PSOUT
	LIST
>


	DEFINE PUTOCT
<	MOVEI	A1, 101
	XLIST
	MOVE	A3, [1B0+^D8]
	NOUT
	  ERCAL ERROR
	LIST
>


	DEFINE CHEK (AC,ADR,LOC)
<	SKIPGE ADR
IFB <LOC>,<RET>
IFNB <LOC>,<JRST LOC>
	LOAD AC,DIRTOP
	CAMGE AC,ADR
IFB <LOC>,<RET>
IFNB <LOC>,<JRST LOC>
>



DEFINE	GDIF(AC,MEM),<
	PUSH	P,AC		;SAVE NEW VALUE
	SUB	AC,MEM		;GET DELTA
	POP	P,MEM		;SAVE THIS VALUE AS LAST 
				; VALUE
>

DEFINE	BITTXT(AC,BIT,TEXT),<
IFE AC-A1,<PRINTX ?ERROR IN BITTXT: CAN NOT USE A1>
	XLIST
	MOVE A1,OUTJFN
	MOVEI A3,5
	HRROI	A2,TEXT
	TRNE	AC,(BIT)
	JRST [	SOUT
		MOVEI A2," "
		BOUT
		JRST .+1]
	LIST
>
;... CONTINUED
;... CONTINUED

	DEFINE M.PEEK(WORDS,ADRESS,TO)
<	XLIST
	HRLI A1,WORDS	;NUMBER OF WORDS
	HRR A1,ADRESS	;MONITOR ADRESS
	HRRZI A2,TO	;USER ADRESS
	PEEK
	 ERJMP ERROR	;FAILED
	LIST
>
SUBTTL	MAIN ENTRY POINT AND INITIALIZATION

START:
	RESET
	MOVE P,[IOWD NPDL,PDL]		;SET PDL UP
	MOVEI A1,.FHSLF			;OUR ID
	RPCAP				;READ OUR CAPABILITIES
	 ERCAL ERROR
	DMOVEM A2,SAVCAP		;SAVE THEM FOR EXIT
	TLNN A2,(1B0)			;CAN WE ENABLE CONTROL-C ?
;	  BUG(HLT,<CANNOT ENABLE FOR CONTROL-C INTERCEPT>)
	MOVEI A1,.FHSLF			;US
	MOVE A3,A2			;ENABLE ALL OF THEM
	EPCAP				;DO IT
	 ERCAL ERROR
	SETZM ZERBEG
	MOVE A1,[ZERBEG,,ZERBEG+1]
	BLT A1,ZEREND			;CLEAR IMPURE STORAGE
	MOVEI A1,.FHSLF			;US
	 DIR				;TURN PI-SYSTEM OFF
	MOVE A2,[LEVTAB,,CHNTB]		;SET IT UP
	 SIR
	EIR				;ENABLE INTERRUPTS
	MOVE A2,[1B0]
	AIC				;ENABLE CHAN 0
	MOVE A1,["C"-100,,0]
;	ATI				;ASSIGN CONTROL-C FOR INTERRUPTING
	MOVSI T1,-SYMTBL
SYMFND:	MOVEI A1,.SNPSY			;TRANSFORM SYMBOL TO ADRESS
	MOVE A2,SYMOCT(T1)
	MOVE A3,SYMOCT+1(T1)
	SNOOP
	 ERCAL ERROR
	MOVE A3,SYMOCT+2(T1)		;GET LABEL WHERE TO STICK ADRESS
	HRRM A2,(A3)
	ADD T1,[2,,2]
	AOBJN T1,SYMFND
	MOVE A1,NJOBS			;MAX JOB-NR THE SYSTEM SUPPORTS
	CAIL A1,MAXJOB			;DO WE HAVE ENOUGH ROOM
	 BUG(HLT,<RECOMPILE WITH MAXJOB SET HIGHER>)
	

TYPANO:MOVE A1,[SIXBIT/JOBRT/]
	SYSGT
	 ERCAL ERROR
	HLRE A1,A2
	GJINF
	 ERCAL ERROR
	MOVEM A3,OURJOB				;OUR JOB-NR
	HRROI A2,[ASCIZ /MONITR.STS/]		;OUR OUTPUT-FILE
	MOVEM A2,OURFIL				;SAVE FOR POSIBBLE RETRY
	hrrz a1,ourjob
	caie a1,0				;under SYSJOB ?
	jrst [move a1,[1b0!1b6!1b17]		;Try next generation
		GTJFN
		 ercal error
		;MOVEI A1,101
		;MOVEM A1,OUTJFN			;TO TTY ONLY
		MOVEM A1,OUTJFN				;REMEMBER JFN
		MOVE A2,[7B5!1B20]			;WRITE 7BIT
		OPENF
		 ERCAL ERROR
		MOVE A1,OUTJFN
		jrst typanp]
	MOVE A1,[1B2!1B6!1B17]
	GTJFN
	 JRST [MOVE A2,OURFIL
		MOVE A1,[1B1!1B6!1B17]
		GTJFN				;TRY NEW FILE
		 ERCAL ERROR
		JRST .+1]
	MOVEM A1,OUTJFN				;REMEMBER JFN
	MOVE A2,[7B5!1B20!1B22]			;WRITE 7BIT,UPDATE
	OPENF
	 ERCAL ERROR
	MOVE A1,OUTJFN
	RFPTR				;READ FILE-POINTER NOW
	 ERCAL ERROR
	MOVEM A2,FILPOS			;AND SAVE IT
TYPANP:	CALL MONSTS			;DO MONITOR STATUS
;	CALL JOBSTS			;.. AND SYSTAT
	CALL CHNFND			;STEP THRU DDB'S
	HRRZ A1,OUTJFN			;CLOSE OUTPUT-FILE
	TXO A1,1B0			;BUT KEEP JFN
	CLOSF
	 ERCAL ERROR
;	MOVE A1,OUTJFN			;OPEN IT FOR WRITE ONLY
;	MOVE A2,[7B5!1B19!1B20]		;WRITE 7 BIT,UPDATE
;	OPENF
;	 ERCAL ERROR
;	MOVE A1,[1B2!1B6!1B17]
;	MOVE A2,OURFIL
;	GTJFN
;	 ERCAL ERROR
	jrst loop1			;sleep or not to ( thats the question )
	SUBTTL MAIN LOOP AND END-HANDLING ( CONTROL-C INTERCEPT)
LOOP:	CALL MONSTS			;DO MONITOR THINGIES
;	CALL JOBSTS			;... AND SYSTAT
	CALL CHNFND			;STEP THRU CDB'S
	HRRZ A1,OUTJFN			;CLOSE OUTPUT-FILE
	TXO A1,1B0			;BUT KEEP JFN
	CLOSF
	 ERCAL ERROR
loop1:	hrrz a1,ourjob
	caie a1,0		;if under SYSJOB go to sleep , otherwise finish
	jrst	[HALTF
		JRST START ]		;in case he types continue
	MOVE A1,[SLEEP]			;SLEEP 
WAITPC:	DISMS			;	A WHILE
	MOVE A1,OUTJFN			;OPEN IT FOR WRITE ONLY
	MOVE A2,[7B5!1B19!1B20]		;READ AND WRITE 7 BIT
	OPENF
	 ERCAL ERROR
	MOVE A1,OUTJFN			;RESET FILE POINTER
	MOVE A2,FILPOS
	SFPTR
	 ERCAL ERROR
	JRST LOOP			;AND KEEP GOING
ABORT:	MOVEM A1,SAVEIT			;SAVE AC1
	HRRZ A1,IPC1
	CAIE A1,WAITPC+1		;CAME FROM REQUESTED WAIT?
	JRST .+2			;NO RESUME
	MOVEI A1,ABRT1			;RESUME TO END
INTR1:	HRRM A1,IPC1
	MOVE A1,SAVEIT			;RESTORE A1
	DEBRK

ABRT1:	MOVE A1,OUTJFN
	RLJFN
	 ERCAL ERROR
	HRROI A1,[ASCIZ /
ABORTED.
/]
	PSOUT
	MOVEI A1,.FHSLF
	DMOVE A2,SAVCAP			;GET ORIGINAL CAPS
	EPCAP
	 ERCAL ERROR
	HALTF
	SUBTTL GET MONITOR-STATUS
MONSTS:O.CRLF
	O.STR <MONITOR-STATUS AT:	>
	SETO T1,			;TYPE TIME OF DAY
	O.TIME T1			;
	O.CRLF
	O.CRLF
	M.PEEK TBLENR,GTTAB,GETTAB	;GET LENGTH,ADRESS
	M.PEEK 1,GETTAB+APRID,T1	;..FIRST APR-ID
	O.STR <APR-NR. : >
	O.DEC T1			;TYPE APR-NR.
	O.STR <	>
	M.PEEK 50,GETTAB+SYSVER,TMPDAT
	HRROI A2,TMPDAT
	MOVE A1,OUTJFN
	SOUT				;TYPE SYSTEM VERSION
	 ERCAL ERROR
	O.CRLF
	O.STR <			BUILT AT : >
	M.PEEK 1,GETTAB+SYSTAD,T1
	O.TIME T1
	O.CRLF
	O.STR <   UPTIME : >
	M.PEEK 1,TODCLK,T1
	M.PEEK 1,GETTAB+TICKPS,T2
	DMOVE A1,T1			;MOVE TIME OVER FOR TYPTIM
	IDIV A1,A2
	PUSHJ P,TYPTIM			;AND PRINT UPTIME
	O.STR <	LOAD AV: >
	M.PEEK TBLENR,GETTAB+SYSTAT,TMPDAT;GET SYSTAT TABLE
	MOVE T1,TMPDAT+14
	O.FLOAT T1
	O.STR <	>
	MOVE T1,TMPDAT+15
	O.FLOAT T1
	O.STR <	>
	MOVE T1,TMPDAT+16
	O.FLOAT T1
	O.CRLF
	MOVE A1,NTMS			;NR OF TICKS PER  MS
	IMULI A1,^D600			;MAKE IT DIVISOR
	MOVEM A1,NTMS			;AND STORE
	O.STR <IDLE-TIME : >
	MOVE A1,TMPDAT		;IDLE TIME
	MOVE A2,T2			;DIVISOR
	IDIV A1,A2			;FOR TYPTIM
	CALL TYPTIM			;PRINT IT
	O.STR <	LOST-TIME : >
	MOVE A1,TMPDAT+1		;LOST TIME
	MOVE A2,T2			;DIVISOR
	IDIV A1,A2			;FOR TYPTIM
	CALL TYPTIM			;PRINT IT
	O.STR <	SCHED-USE : >
	MOVE A1,TMPDAT+2		;SCHED OVERHEAD
	MOVE A2,T2			;DIVISOR
	IDIV A1,A2			;FOR TYPTIM
	CALL TYPTIM			;PRINT IT
	M.PEEK 1,GETTAB+NCPGS,T1	;GET USER PAGES
	O.CRLF
	O.DEC T1			;PRINT THEM
	O.STR < PAGES PHYSICAL USER CORE (PAGEABLE) >
	M.PEEK 2,GETTAB+DWNTIM,TMPDAT	;GET CEASE VALUES
	MOVE T1,TMPDAT
	JUMPE T1,NOCEAS			;NO VALUE SET
	O.CRLF
	O.STR <SHUTDOWN AT: >
	O.TIME T1
	MOVE T1,TMPDAT+1
	JUMPE T1,NOCEAS			;NO VALUE SET
	O.STR <	UP AGAIN AT: >
	O.TIME T1
NOCEAS:O.CRLF
	RET				;FINISHED
	SUBTTL GETTING THRU CDB'S => KDB'S => UDB'S
CHNFND:O.CRLF
	O.CRLF
	O.STR < DEVICE STATUS: >
	O.CRLF
	O.CRLF
	M.PEEK 8,CHNADR,CDBADR		;GET CDB-ADRESSES
	M.PEEK 1,MAXCHN,CI		;GET MAX CHANNELS IN CI
	MOVNS CI,CI
	HRLZ CI,CI			;MAKE IT AOBJN-POINTER
CHNLOP:SKIPN ,CDBADR(CI)		;THIS CHANNEL USED?
	JRST CHNMOR			;TRY NEXT ONE
	O.STR <CHANNEL: >
	HRRZ T1,CI			;GET CHANNEL NR.
	O.OCT T1			;AND TYPE IT
	O.STR <	TYPE: >			;
CDBFND:M.PEEK 50,CDBADR(CI),CDB	;GET CDB
	LOAD T1,CDBTYP			;CDB-TYPE
	O.TYP CHNTYP(T1)		;AND TYPE IT
;	O.STR <	PI: >			;PI-ASSIGNMENT
;	LOAD T1,CDBPIA			;GET PI-ASSIGNMENT
;	O.OCT T1			;AND TYPE IT
	O.CRLF				;NEXT LINE
	O.STR <STATUS: >
	CLEAR T2,			;INDEX INTO CDBSTA
	LOAD T1,CDBSTS			;GET CDB STATUS
	MOVEI T3,400000			;BIT - MASK
	MOVEI T4,CSTSLN			;COUNTER
CDBOUT:BITTXT T1,T3,CDBSTA(T2)	;TYPE IT
	SOS T4
	JUMPE T4,CDBDON			;DONE WITH STATUS
	LSH T3,-1			;NEXT BIT
	AOS T2
	JRST CDBOUT			;NEXT BIT
CDBDON:O.CRLF
	HRLZI KI,-10			;MAKE IT AOBJN-POINTER
	HRRZ T4,CDB+16(KI)		;GET KDB/UDB ADRESS
	JUMPN T4,KDBFND			;A REAL ADRESS?
CDBMOR:AOBJN KI,.-2			;KEEP LOOKING
	JRST CHNMOR			;ALL DONE
KDBFND:M.PEEK 50,T4,KDB		;GET UDB/KDB
	LOAD T1,blkTYP			;KDB ?
	cain t1,.ublk			;is it UDB?
	JRST UDBFND
	JRST FNDUDB			;FIND UDB'S FOR THIS KDB
UDBFND:MOVE UI,KI			;GET INDEX AOBJN-POINTER
	M.PEEK 50,T4,UDB		;GET UDB
	CALL UDBPNT			;PRINT UDB-VALUES
	JRST CDBMOR			;FIND NEXT ONE

FNDUDB:HRLZI UI,-10			;MAKE AOBJN-POINTER
	HRRZ T1,KDB+4(UI)		;CHECK IF UDB USED
	JUMPE T1,NXTUDB			;NOPE,TRY NEXT ONE
	M.PEEK 50,T1,UDB		;GET UDB
	CALL UDBPNT			;PRINT UDB-VALUES
NXTUDB:AOBJN UI,FNDUDB+1		;NEXT ONE
	JRST CDBMOR			;AND NEXT CDB-ENTRY
CHNMOR:O.CRLF
	O.CRLF
	AOBJN CI,CHNLOP			;GO THRU CHANNELS
	RET				;AND RETURN
 SUBTTL COMMON SUBROUTINES

UDBPNT:O.CRLF
	O.STR <		DEVICE: >
	LOAD T1,UDBTYP			;DEVICE-TYP
	O.TYP UNITYP(T1)
UDVDON:O.STR <	SER. NR. : >
	LOAD T1,UDBDSN			;DRIVE SERIAL-NR
	MOVEM T1,DEVTYP			;CHECK IF MAGTAPE
	LOAD T2,udbsts			;IS IT MAGTAPE?
	trne t2,2			;is it tape?
	jrst udvdn1			;it is
	O.HEX T1			;RM03'S ANMD RP06'S
	JRST UDVDN2			;GO AROUND
UDVDN1:	cain t1,40431			;serial # NOT cut ?
	jrst [ o.typ unityp		;type ????? to him
		jrst udvdn2]
	O.DEC T1			;MAGTAPES (TU45)
UDVDN2:	O.STR <	UNIT : >
	HRRZ T1,UI			;GET SLAVE-NR
	O.OCT T1
	O.CRLF
	O.STR <		STATUS: >
	LOAD T1,UDBSTS			;STATUS OF UDB
	CLEAR T2,			;INDEX INTO TRANSLATION TABLE
	MOVEI T3,400000			;FIRST BIT TO TEST
	MOVEI T4,USTSLN			;TABLE LENGTH
UDBOUT:	BITTXT T1,T3,UDBSTA(T2)		;TYPE IT
	SOS T4
	JUMPE T4,UDBDON			;DONE WITH STATUS
	LSH T3,-1			;NEXT BIT
	AOS T2
	JRST UDBOUT			;TYPE NEXT BIT
UDBDON:	O.CRLF
	troe t1,400000			;unit off-line?
	popj p,				;then done
	O.STR <		FUNCTION       UNITS      SOFT-ERR   HARD-ERR >
	O.CRLF
	O.STR <		-------------------------------------------------------- >
	LOAD T2,UDBSEK			;SEEK COUNT
	JUMPE T2,UDBNSK			;NO SEEK'S--NO TYPEOUT
	O.CRLF
	O.STR <		SEEKS :   >
	O.DEC T2
UDBNSK:O.CRLF
	O.STR <		READ  :   >
	LOAD T1,UDBRED			;READ COUNT
	O.DEC T1
	O.STR < >
	LOAD T1,UDBSRE			;SOFT READ ERROR COUNT
	O.DEC T1
	O.STR < >
	LOAD T1,UDBHRE			;HARD READ ERROR COUNT
	O.DEC T1
	LOAD T4,UDBsts			;UNIT A TAPE?
	trne t4,2			;is it tape?
	JRST	[ O.STR <	(FRAMES)>
		  JRST .+2 ]
	JRST	[ O.STR <	(BLOCKS or 4608. Bits)>
		  JRST .+1 ]
	O.CRLF
	O.STR <		WRITE :   >
	LOAD T1,UDBWRT			;WRITE COUNT
	O.DEC T1
	O.STR < >
	LOAD T1,UDBSWE			;SOFT WRITE ERROR COUNT
	O.DEC T1
	O.STR < >
	LOAD T1,UDBHWE			;HARD WRITE ERROR COUNT
	O.DEC T1
	LOAD T4,UDBsts			;UNIT A TAPE?
	trne t4,2			;is it tape?
	JRST	[ O.STR <	(FRAMES)>
		  JRST .+2  ]
	JRST	[ O.STR <	(BLOCKS or 4608. Bits)>
		  JRST .+1 ]
	O.CRLF
	POPJ P,				;AND GO BACK

;SUBROUTINE TO DO SYSTAT-LIKE OUTPUT

JOBSTS:O.CRLF
	O.STR <      JOB   TTY PROGRM  RUNTIME        LOGGED CONNECTED >
	O.CRLF
;	M.PEEK MAXJOB,GETTAB+JOBDIR,.JBDIR ;FIRST GET THE DATA-TABLES
;	M.PEEK MAXJOB,GETTAB+JOBTTY,.JBTTY
;	M.PEEK MAXJOB,GETTAB+JOBRT ,.JBRT
;	M.PEEK MAXJOB,GETTAB+TTYJOB,.TTYJB
;	M.PEEK MAXJOB,GETTAB+JOBPNM,.JBPNM
;	M.PEEK MAXFRK,GETTAB+DEVUNT,.DVUNT
;	M.PEEK MAXFRK,GETTAB+DEVNAM,.DVNAM
	MOVN T3,NJOBS			;AOBJN-POINTER
	HRLZ T3,T3			;
JOBLOP:	hrrz a1,t3			;this job now
	move a2,[xwd -20,jobinf]		;this job now
	setzm a3				;all of it
	getji
	JRST JOBNXT			;FIND NEXT JOB
	move t2,jobinf+1		;is he logged in?
	camn t2,[-1,,-1]		;skip is he is
	jrst jobnxt			;next one
	o.crlf
	move a1,outjfn			;our output
	move t2,jobinf			;job-nr
	o.dec t2
	o.str <	>	
	move t2,jobinf+1		;terminal number
	cain t2,-1			;job detached?
	jrst dtchd			;say so
	o.oct t2
ndtchd:	o.str <	>
	move t4,jobinf+5		;jobs program name
	call sixpnt			;print it
	o.str <	>
	m.peek 1,gettab+tickps,a2	;get divisor
	move a1,jobinf+6		;runtime
	idiv a1,a2			;convert
	call typtim
	o.str <	>
	move a2,jobinf+17		;logged in directory number
	movem a2,dirnum			;for compare
	dirst
	 CALL error			;
	o.str <	>
	move a2,jobinf+3		;connected directory
	camn a2,dirnum			;same as logged in?
	jrst jobnxt			;don't print then
	dirst
	 call error
JOBNXT:AOBJN T3,JOBLOP			;KEEP LOOPING
	POPJ P,				;AND RETURN

DTCHD:	O.STR <DET>
	JRST NDTCHD			;AND KEEP GOING


;SIXPNT TRANSLATES 6-BIT WORD IN T4 TO OUTJFN

SIXPNT:MOVEI A4,6		;6 CHARACTERS
	MOVE A1,OUTJFN		;OUR OUTPUT
	MOVE A3,[POINT 6,T4]	;POINTER TO IT

SIXPUT:ILDB A2,A3		;GET A BYTE
	ADDI A2,40		;MAKE IT ASCII
	BOUT
	 ERCAL ERROR
	SOJG A4,.-4		;COUNT 6 OF THEM
	POPJ P,			;RETURN TO CALLER

;SUBROUTINE TO PRINT THE TIME
;CALL WITH:
;	A1 = TIME IN SECONDS
;	A2 = MILLISECONDS
;	PUSHJ	P,TYPTIM
;
;

TYPTIM:	push p,a1
	push p,a2
	push p,a3
	move a2,a1
	move a1,outjfn
TYPTM2: idivi a2,^D3600
	push p,a3
	move a3,[ 1b0+1b2+1b5+3B17+^D10]
	nout			;hours
	jfcl
	movei a2,":"
	bout
	pop p,a2
	idivi a2,^D60
	push p,a3
	move a3,[ 1b2+1b3+1b5+2b17+^D10]
	nout			;minutes
	jfcl
	movei a2,":"
	bout
	pop p,a2
	nout			;seconds
	jfcl
	jrst [pop p,a3
	      pop p,a2
	      pop p,a1
	      ret ]


; SAVACS - ROUTINE TO SAVE ALL 16 ACCUMULATORS.
;
; CALL:		CALL SAVACS
;		RETURN


SAVACS:	MOVEM 0,SAVE0		;SAVE ACCUMULATOR 0
	MOVE 0,[A1,,SAVEA1]	;SET UP FOR BLT
	BLT 0,SAVEA1+16		;SAVE NEXT 15 ACCUMULATORS
	RET			;RETURN TO WHENCE WE CAME ...



; RESACS - ROUTINE TO RESTORE ALL 16 ACCUMULATORS
;
; CALL:		CALL RESACS
;		RETURN


RESACS:	MOVE 0,[SAVEA1,,A1]	;SET UP FOR BLT
	BLT 0,17		;RESTORE AC'S 1-17
	MOVE 0,SAVE0		;RESTORE AC 0
	RET			;RETURN TO WHENCE WE CAME ...
; MAPDIR - ROUTINE TO MAP PAGES FROM THE DIRECTORY FILE INTO THE
;	   ADDRESS SPACE OF THIS PROCESS.
;
; CALL:		[JFN FOR DIRECTORY FILE IS IN DIRJFN]
;		MOVE MA,REQUIRED ADDRESS
;		CALL MAPDIR
;		RETURN

MAPDIR:	CALL SAVACS		;GO SAVE ALL AC'S
	HRLZ A1,DIRJFN		;GET DIRECTORY JFN
	MOVE T1,MA		;COPY ADDRESS REQUIRED
	LSH T1,-^D9		;CONVERT ADDRESS TO PAGE #
	HRR A1,T1		;GET PAGE # IN FILE
	MOVSI A2,.FHSLF		;GET OUR FORK HANDLE
	MOVEI T1,MAPPGS		;GET CORE ADDRESS OF DIR PAGE
	LSH T1,-^D9		;CONVERT ADDRESS TO PAGE #
	HRR A2,T1		;COPY ADDRESS TO ARG AC FOR PMAP
	MOVX A3,PM%RD!PM%CNT	;READ ACCESS ONLY, ITERATION CNT
	HRRI A3,FDBPGS		;GET # OF PAGES TO MAP
;	LOAD T1,DIRFRE		;GET HIGHEST ADDRESS+1 FOR FDB'S
	SUBI T1,1		;COMPUTE HIGHEST ADR FOR FDB'S
	LSH T1,-^D9		;CONVERT ADDRESS TO PAGE #
	MOVE T2,MA		;GET DESIRED ADDRESS
	LSH T2,-^D9		;CONVERT ADDRESS TO A PAGE #
	SUB T1,T2		;COMPUTE # OF PAGES TO MAP-1
	ADDI T1,1		;COMPUTE # OF PAGES TO MAP
	CAIG T1,FDBPGS		;LESS THAN # OF MAPPING PAGES ?
	HRR A3,T1		;YES, USE LESSER # OF PAGES
	HRREI A4,-1(A3)		;SAVE # OF PAGES TO MAP-1
	PMAP			;MAP THE PAGES
	MOVE T1,MA		;GET REQUIRED ADDRESS
	TRZ T1,777		;COMPUTE LOWEST ADDRESS MAPPED
	MOVEM T1,MAPBOT		;SAVE LOWEST ADDRESS MAPPED
	LSH T1,-^D9		;CONVERT LOWEST ADR TO PAGE #
	ADD T1,A4		;COMPUTE HIGHEST PAGE MAPPED
	LSH T1,^D9		;CONVERT PAGE # TO ADDRESS
	TRO T1,777		;COMPUTE HIGHEST ADR MAPPED
	MOVEM T1,MAPTOP		;SAVE HIGHEST ADR MAPPED
	MOVEI T1,MAPPGS		;GET ADDRESS OF MAPPED AREA
	HRRZ T2,A1		;GET PAGE # IN FILE
	LSH T2,^D9		;COMPUTE ADDRESS IN FILE
	SUB T1,T2		;COMPUTE MAPPED ADDRESS OFFSET
	MOVEM T1,FDBOFS		;SAVE OFFSET TO MAPPED ADDRESSES
	CALL RESACS		;GO RESTORE ALL THE AC'S
	RET			;RETURN TO WHENCE WE CAME ...
; ECHOFF - ROUTINE TO TURN OFF ECHOING FOR ESCAPES
;
; CALL:		CALL ECHOFF
;		RETURN


ECHOFF:	MOVEI A1,.PRIOU		;GET PRIMARY OUTPUT JFN
	RFCOC			;READ ECHOING BITS
	TRZ A3,3B19		;TURN OFF ESCAPE ECHOING
	SFCOC			;TELL MONITOR
	RET			;RETURN TO WHENCE WE CAME ...


ERROR:	MOVEI A1,.PRIIN
	HRLOI A2,.FHSLF
	SETZ A3,
	ERSTR
	JFCL
	JFCL
	HALTF
	JRST START
	SUBTTL PURE STORAGE
;ENTRY VECTOR DEFINITION
ENTVEC:	JRST START		;MAIN ENTRY POINT
	JRST START		;REENRTY ADRESS
	EXP VSTATS		;VERSION OF STATUS

LEVTAB:	XWD 0,IPC1
	XWD 0,IPC2
	XWD 0,IPC3

IPC1:	BLOCK 1
IPC2:	BLOCK 1
IPC3:	BLOCK 1

CHNTB:	XWD 1,ABORT
	REPEAT ^D19-^D1,<0
		XLIST>
SAVJFN:777777
	LIST
	REPEAT ^D35-^D19,<0
		XLIST>
	LIST

SYMOCT:	RADIX50 0,NTMS		;NUMBER OF TICKS PER MS
	RADIX50 0,APRSRV
	NTMS
	RADIX50 0,MAXCHN	;SYMBOL NAME
	RADIX50 0,STG		;MODULE NAME
	MAXCHN			;WHERE WE KEEP MONITOR-ADRESS
	RADIX50 0,CHNTAB
	RADIX50 0,STG
	CHNADR
	RADIX50 0,GTTAB
	RADIX50 0,MEXEC
	GTTAB			;WHERE WE KEEP IT
	RADIX50 0,TODCLK
	RADIX50 0,STG
	TODCLK
	RADIX50 0,NJOBS
	RADIX50 0,STG
	NJOBS

SYMTBL==.-SYMOCT
SUBTTL IMPURE STORAGE

ZERBEG::
FDBOFS:	BLOCK 1		;JUST FOR NOW
NTMS:	BLOCK 1			;NUMBER OF TICKS PER MS
PDL:		BLOCK NPDL	;PUSH DOWN LIST
SAVEIT:	BLOCK 1		;A1 DURING CONTROL-C HANDLING
SAVE0:		BLOCK 1		;SAVED AC0
SAVEA1:	BLOCK 17	;OTHER 17 SAVED AC'S
FILPOS:	BLOCK 1		;OUR FILE-POSITION
NJOBS:		BLOCK 1		;NUMBER OF JOBS ,THIS MONITOR
OURFIL:	BLOCK 2		;OUR FILE-NAME STRING
OURJOB:	BLOCK 1		;OUR JOB-NR (TEST FOR SYSJOB)
SAVCAP:	BLOCK 2			;OUR CAPABILTIES
DIRNUM:	BLOCK 1		;LOGGED IN DIRECTORY
GTTAB:		BLOCK 1		;ADRESS OF LNGTH,,GETTAB TABLES
TODCLK:	BLOCK 1		;ADRESS OF TODCLK
DIRJFN:	BLOCK 1		;JFN FOR PMAP
FDBPGS:	BLOCK 1		;NUMBER OF PAGES TO MAP
MAPTOP:	BLOCK 1		;HIGHEST ADRESS MAPPED
MAPBOT:	BLOCK 1		;LOWEST ADRESS MAPPED
MAPPGS:	BLOCK 1		;MAPPING AREA (PAGE-NR)
OUTJFN:	BLOCK 1		;OUTPUT-JFN
MAXCHN:	BLOCK 1		;ADRESS OF SAME
CHNADR:	BLOCK 1		;ADRESS OF CHNTAB
CHNTAB:	BLOCK 10	;	""
CDBADR:	BLOCK 10	;ADRESSES OF CDB'S
UDBADR:	BLOCK 10	;ADRESSES OF UDB'S
KDBADR:	BLOCK 10	;ADRESSES OF KDB'S
UDB:		BLOCK 50	;CONTENTS OF A UDB
CDB:		BLOCK 50	;CONTENTS OF A CDB
KDB:		BLOCK 50	;CONTENTS OF A KDB
TMPDAT:	BLOCK MAXFRK	;TEMPORARY STORAGE
GETTAB:	BLOCK TBLENR	;CONTENTS OF GTTAB-TABLE (LENGTH,,ADRESS)
.JBDIR:	BLOCK MAXJOB	;LH:CONN-DIR, RH:LOGD-DIR
.JBTTY:	BLOCK MAXJOB	;LH: CON-TTY, RH:TOP FRK-NR
.JBRT:		BLOCK MAXJOB	;JOB RUNTIME
.TTYJB:	BLOCK MAXJOB	;LH: JOB-NR , RH: JOB WAITING (IF NOT -1)
.JBPNM:	BLOCK MAXJOB	;SIXBIT NAME OF PROGRAM RUNNING
.FKJOB:	BLOCK MAXFRK	;LH: JOB-NR , RH: JSB-ADRESS
.FKNR:		BLOCK MAXFRK	;LH: 2 AGES , RH: WORKING SET SIZE
.DVUNT:	BLOCK MAXFRK	;LH: JOB ASS, RH: UNIT-NR
.DVNAM:	BLOCK MAXFRK	;SIXBIT DEVICE NAME
DEVTYP:	BLOCK 1		;DEV-TYP OF UDB
jobinf:	block 20	;job info for getji
ZEREND::.-1			;END OF IMPURE STORAGE
	END <3,,ENTVEC>