;<FOONEX>PROLOG.MAC;106 18-Mar-81 21:23:53, Edit by MMCM
;<FOONEX>PROLOG.MAC;77 22-Jan-81 16:04:24, Edit by PETERS
; Remove bug storage for modules that don't and won't ever exist
;<NFOONEX>PROLOG.MAC.75, 20-Oct-80 01:31:17, Edit by GEOFF
; Added GTNCP 272 & GTHST 273 to jsys dispach table.
;DSK:<FOONEX>PROLOG.PEF;2 25-Jun-80 13:08:15, Edit by FRENCH
;INCREASE BUG STORAGE FOR PAGEM
;DSK:<FOONEX>PROLOG.MAC;75 23-Jun-80 17:00:34, Edit by FRENCH
;ADDED DEFS FOR BAT STATUS IN FDB AND XB'S
;DSK:<FOONEX>PROLOG.MAC;73  4-Jun-80 14:32:13, Edit by FRENCH
;ADDED HOMBAT TO BUG STORAGE MACRO TABLE
;DSK:<134-TENEX>PROLOG.MAC;72 18-May-80 22:05:36, Edit by PETERS
; Added definitions to support TOPS20 flavored modules
;DSK:<134-TENEX>PROLOG.MAC;71 23-Apr-80 23:51:06, Edit by PETERS
; Installed definitions for millisecond clock on F3
;<134-TENEX>PROLOG.MAC;70     4-Apr-80 17:21:10    EDIT BY PETERS
; Increased JFNPC0 to 500
;DSK:<134-TENEX>PROLOG.MAC;69  3-Apr-80 16:54:14, Edit by RKNIGHT
; Made LOGBUF reflect true size of fact entry, ACCTSR is same as before.
;DSK:<134-TENEX>PROLOG.MAC;68 28-Mar-80 17:56:55, Edit by PETERS
; Fix so symbols for STORAG are kept
;DSK:<134-TENEX>PROLOG.MAC;67  5-Mar-80 17:55:59, Edit by RKNIGHT
; Made ACCTSR larger to accomodate fact entry changes.
;DSK:<134-TENEX>PROLOG.MAC;66 19-Feb-80 16:56:34, Edit by FRENCH
;CHANGED COMMENT AT DEF OF TYMOX.  IS FOR AUXBLD PRIVELEDGE ONLY
;<134-TENEX>PROLOG.MAC;65    19-Feb-80 16:36:38    EDIT BY PETERS
; ADDED TYMOX CAPABILITY BIT.
;<134-TENEX>PROLOG.MAC;64    16-Feb-80 14:10:14    EDIT BY LYNCH
; ADDED CUSTMR BIT IN CAP WORD
;<134-TENEX>PROLOG.MAC;63    15-Feb-80 08:29:01    EDIT BY LYNCH
; ADDED ARPAN CAPABILITY BIT.
;DSK:<134-TENEX>PROLOG.MAC;61  7-Feb-80 17:23:06, Edit by FRENCH
;MADE TYMOP JSYS BOTH 640 AND 654 AND ASSOCIATED TYMNET JSYSES
;<134-TENEX>PROLOG.MAC;59     1-Feb-80 14:14:32    EDIT BY PETERS
; Changed name of REPTY JSYS to RLPTY
;<134-TENEX>PROLOG.MAC;58    29-Jan-80 21:32:03    EDIT BY PETERS
; Fix KAFLG to be KAFLG!F3FLG
;DSK:<134-TENEX>PROLOG.MAC;57 29-Jan-80 15:28:29, Edit by FRENCH
;ONLY DO EXTERN IF SYM UNDEFINED IN ITERR
;<134-TENEX>PROLOG.MAC;56    27-Jan-80 18:13:27    EDIT BY PETERS
; Fix KAFLG to KAFLG!F3FLG
;DSK:<134-TENEX>PROLOG.MAC;55 31-Dec-79 14:44:33, Edit by FRENCH
;GET CVHST JSYS DEF IF GATEWAY FOONLY
;<134-TENEX>PROLOG.MAC;54    15-Dec-79 19:40:01    EDIT BY FRENCH
;INCREASE BUG ALLOCATION IN TYMSRV
;<134-TENEX>PROLOG.MAC;53    12-Dec-79 14:26:01    EDIT BY FRENCH
;ADDED EXTRA TO ITERR AND RETERR MACROS
;<134-TENEX>PROLOG.MAC;52     3-Oct-79 15:44:56    EDIT BY PETERS
;increased nofn from 400 to 1000
;<134-TENEX>PROLOG.MAC;51    22-Sep-78 19:48:35    EDIT BY PETERS
;<134-TENEX>PROLOG.MAC;50    22-Sep-78 15:36:20    EDIT BY PETERS
;<134-TENEX>PROLOG.MAC;49    21-Sep-78 18:13:22    EDIT BY PETERS
;<134-TENEX>PROLOG.MAC;48    20-Sep-78 14:37:20    EDIT BY PETERS
;<134-TENEX>PROLOG.MAC;47    19-Sep-78 14:41:15    EDIT BY PETERS
;<134-TENEX>PROLOG.MAC;46    10-Sep-78 17:35:34    EDIT BY PETERS
;<134-TENEX>PROLOG.MAC;45    10-Sep-78 14:45:11    EDIT BY PETERS
;<134-TENEX>PROLOG.MAC;44     9-Sep-78 16:48:43    EDIT BY PETERS
;<134-TENEX>PROLOG.MAC;43     9-Sep-78 15:59:55    EDIT BY PETERS
;<134-TENEX>PROLOG.MAC;42     9-Sep-78 15:42:16    EDIT BY PETERS
;<134-TENEX>PROLOG.MAC;41     8-Sep-78 19:23:52    EDIT BY PETERS
;<134-TENEX>PROLOG.MAC;40     1-Sep-78 18:33:16    EDIT BY PETERS
;<134-TENEX>PROLOG.MAC;39     8-Jul-78 20:03:27    EDIT BY PETERS
;<134-TENEX>PROLOG.MAC;38     3-DEC-77 16:36:52    EDIT BY PETERS
;<134-TENEX>PROLOG.MAC;36    22-Aug-77 16:10:48    EDIT BY DANG
;1 Added SFPOS jsys number 526
;<134-TENEX>PROLOG.MAC;35    27-May-77 10:45:22    EDIT BY LYNCH
; INCREASED NUMBER OF FORKS.
;<134-TENEX>PROLOG.MAC;34    24-May-77 11:30:51    EDIT BY LYNCH
;<134-TENEX>PROLOG.MAC;33    22-Mar-77 17:34:51    EDIT BY LYNCH
; TOOK OUT PDP-15 AND TV
;<134-TENEX>PROLOG.MAC;32    11-Feb-77 08:24:05    EDIT BY LYNCH
; PUT IN TU10 BUGSTRING ALLOCATOR
;<134-TENEX>PROLOG.MAC;31    10-Feb-77 20:04:41    EDIT BY LYNCH
; ADDED HELPFUL COMMENTS FOR PPRMPG DEFINITIONS.
;<134-TENEX>PROLOG.MAC;30    10-Feb-77 18:43:42    EDIT BY SYSTEM
;<134-TENEX>PROLOG.MAC;29    10-Feb-77 11:04:11    EDIT BY LYNCH
;<134-TENEX>PROLOG.MAC;28    10-Feb-77 10:27:31    EDIT BY LYNCH
;<134-TENEX>PROLOG.MAC;27     8-Nov-76 11:48:50    EDIT BY DANG
;  Increased per processor region to 205 and swappable to 215 for signal code
;<134-TENEX>PROLOG.MAC;26     7-Nov-76 02:45:45    TVEDIT'd by Geoff
; Added SIGNAL.MAC to files we know/care about.
;<134-TENEX>PROLOG.MAC;25    30-Sep-76 00:17:35    TVEDIT'd by Geoff
; Added FORKX jsys(747) for TCP.
;<134-TENEX>PROLOG.MAC;24	27-Sep-76 12:54:19	Edit by DANG
;  Deleted SETNT jsys
;<134-TENEX>PROLOG.MAC;23    16-AUG-76 20:45:43    EDIT BY LYNCH
;<134-TENEX>PROLOG.MAC;22    24-JUL-76 16:54:52    EDIT BY UNTULIS
;ADDED GPGC FOR FINDING DISK HOGS
;<134-TENEX>PROLOG.MAC;17    23-MAR-76 23:10:20    EDIT BY UNTULIS
;<134-TENEX>PROLOG.MAC;16    18-MAR-76 14:42:25    EDIT BY UNTULIS
;ADDED XLIST,LIST TO ITERR AND RETERR DEFINITIONS
;<134-TENEX>PROLOG.MAC;15    26-FEB-76 16:09:36    EDIT BY UNTULIS
;<134-TENEX>PROLOG.MAC;13    23-FEB-76 10:56:38    EDIT BY UNTULIS
;ADDED ORG 0 BEFORE .END TO ELIMINATE PHASE ERROR
;<134-TENEX>PROLOG.MAC;2     4-FEB-76 11:02:32    EDIT BY UNTULIS
;ADDED SRI-AI STUFF
;<135-TENEX>PROLOG.MAC;156     5-DEC-75 13:51:29    EDIT BY ROSENBERG
; ADD THE %TENX% MACRO, AND USE IT FOR THE DFBGP MACRO AND IN POSTLD
;<135-TENEX>PROLOG.MAC;155    13-NOV-75 21:30:53    EDIT BY BELL
; ADD TNDBG JSYS
;<135-TENEX>PROLOG.MAC;154    13-NOV-75 11:30:27    EDIT BY CALVIN
; Increase space for Bugstrings in ACCTJS
;<134-TENEX>PROLOG.MAC;153     9-OCT-75 17:19:35    EDIT BY ALLEN
; INCREASE BUG SPACE FOR NETWRK AND DSK
;<134-TENEX>PROLOG.MAC;152    18-SEP-75 10:17:25    EDIT BY TOMLINSON
; INCREASED BUG SPACE FOR IMPDV TO 50 FROM 40
;<134-TENEX>PROLOG.MAC;151    15-SEP-75 17:29:56    EDIT BY PLUMMER
; REMOVE PLOCK
;<134-TENEX>PROLOG.MAC;150    29-AUG-75 11:44:35    EDIT BY ALLEN
;<134-TENEX>PROLOG.MAC;149    28-AUG-75 16:19:12    EDIT BY ALLEN
; REVISE LOCK AND UNLOCK TO PROVIDE SPECIAL SCHEDULING ONLY
; ON EXPLICIT REQUEST
;<134-TENEX>PROLOG.MAC;148    30-JUL-75 14:16:50    EDIT BY CALVIN
; Increased JFNPC0 by 20(8) to 474
;<134-TENEX>PROLOG.MAC;147    30-JUL-75 11:43:04    EDIT BY CALVIN
; Made GTJFN have 3 bug strings
;<134-TENEX>PROLOG.MAC;146    28-JUL-75 16:26:50    EDIT BY CALVIN
; Added job storage for default file accounts
;<134-TENEX>PROLOG.MAC;145    19-JUN-75 11:08:33    EDIT BY BTHOMAS
; DECLARE SETER JSYS (INVERSE OF GETER)
;<134-TENEX>PROLOG.MAC;144    23-MAY-75 12:14:50    EDIT BY ALLEN
;<134-TENEX>PROLOG.MAC;143    23-MAY-75 11:57:22    EDIT BY ALLEN
; EXTERN IN RETERR DEFINITION NOW CONDITIONAL
;<134-TENEX>PROLOG.MAC;142    11-MAY-75 21:05:13    EDIT BY TOMLINSON
; ADDED BUGSTRINGS FOR TNET
;<134-TENEX>PROLOG.MAC;141    28-APR-75 14:36:54    EDIT BY CLEMENTS
;<134-TENEX>PROLOG.MAC;140    28-APR-75 13:52:34    EDIT BY CLEMENTS
;<134-TENEX>PROLOG.MAC;139    28-APR-75 11:16:04    EDIT BY CLEMENTS
; COMBINING FILEDEF INTO PROLOG
;<134-TENEX>PROLOG.MAC;138    23-APR-75 13:31:28    EDIT BY CLEMENTS
; MOVED BUGSTRINGS AREA DEFINITIONS TO PROLOG FROM PARAMS
; ADDED NAMES OF PIECES OF SWPMON
;<134-TENEX>PROLOG.MAC;137    10-APR-75 23:12:06    EDIT BY ALLEN
; ADD HIQCNT AND SPQCNT TO PSB
;<134-TENEX>PROLOG.MAC;136    10-APR-75 23:03:48    EDIT BY ALLEN
; REVISED LOCK-UNLOCK MACROS
;<134-TENEX>PROLOG.MAC;135    12-MAR-75 20:43:49    EDIT BY PLUMMER
;<134-TENEX>PROLOG.MAC;134    12-MAR-75 13:19:39    EDIT BY PLUMMER
; SIGNAL JSYS DEFINITIONS
;<134-TENEX>PROLOG.MAC;133    24-JAN-75 13:06:39    EDIT BY CLEMENTS
; LISTING CLEANUP. PREPARE FOR MACRO V50
;<134-TENEX>PROLOG.MAC;132    10-JAN-75 12:04:46    EDIT BY ALLEN
;<134-TENEX>PROLOG.MAC;131    10-JAN-75 12:01:16    EDIT BY ALLEN
; LOCK MACRO HI-QUEUES THE FORK IN PIE-SLICE SYSTEM
;<133-TENEX>PROLOG.MAC;130     9-DEC-74 18:46:47    EDIT BY CALVIN
; Added JSYS defn's 327-335

	UNIVERSAL PROLOG
	PASS2

;PC ADJUSTMENT FOR USE MACRO

RESPC==.
DEFINE .OLDPC(VAL)<RESPC==VAL>

;GENERAL PARAMETERS AND MACROS

PGSIZ==:1000		;PAGE SIZE
PGSFT==:^D9		;SHIFT FOR PAGE/ADDRESS CONVERSION

EOL=37			;END OF LINE CHARACTER

UMODF==10000		;USER MODE FLAG IN PC WORD
UIOF==4000		;USER I/O MODE IN PC WORD
NUPDL==120		;PDL FOR MONITOR CALLS

NFKS==<10*NJOBS>/2	;NUMBER OF FORKS 4 PER JOB
NSAC==16		;HIGHEST AC SAVED BY MENTR
NTERMI==^D36		;NUMBER OF TERMINAL INTERRUPTS
NPILEV==3		;NUMBER OF PSEUDO-INTERRUPT LEVELS
NPIPDL==40		;SIZE OF PSI LOCAL PDL
NTSK==50		;SIZE OF PAGE TRAP PDL
NUFKS==30		;MAX NUMBER FORKS/JOB
NLFKS==20		;NUMBER OF LOCAL FORKS
NWSPGS==<1000/44>+1	;SIZE OF WORKING SET PAGES BIT TABLE, 1 BIT/PG

APRCHN==3		;APR PI CHANNEL
SCDCHN==7		;SCHEDULER PI CHANNEL

PI==4			;DEVICE CODE FOR PI

;PAGER BITS

READB==1B20		;READ ALLOW
WRITEB==1B21		;WRITE ALLOW
XCTB==1B22		;EXECUTE ALLOW
USRLKB==1B25		; PAGE LOCKED BY USER
TRAPUB==1B26		;TRAP TO USER BIT
COPYB==1B27		;COPY ON WRITE
ACCESB==1B30		;ACCESS ALLOW
CORMB=1B9		;MODIFIED BIT IN CST0

RWXB==READB+WRITEB+XCTB+ACCESB	;ALL ACCESS
RWX==RWXB-ACCESB
RCW==READB+COPYB	;READ AND COPY ON WRITE

;BITS IN MAP WORD

IFN KIFLG,<	;;Flags pertinent to the KI-10 pager
KIAXB==1B18		;Read access
KIWB==1B20		;Write access
>

SHRBIT==1B19		;SHARE POINTER
INDBIT==1B18		;INDIRECT POINTER

;BAT BIT DEFINITIONS FOR XB'S CURRENTLY NOT MAPPED
;GETS COPIED TO SPTH OFNBAT BIT WHEN OPENED VIA ASOFN
;NOTE: INDBIT CAN NEVER BE LEGITIMATELY ON IN XB ENTRY UNLESS IT MEANS "BAT"

XBBWRD==0		;WORD OF XB USED FOR THIS PURPOSE
XBBAT==INDBIT		;BIT IN LH OF XBBWRD USED FOR THIS PURPOSE


;PAGER HARDWARE PARAMETERS

PGR==24			;DEVICE NUMBER
PGR71=71		;PAGER RELOAD REGISTER (PT.PSB)
PGR72=72		;PAGER RELOAD REGISTER (AGE.PROCESS BIT)

;PARAMETERS FOR CLOCK CONTROL. CAN RUN WITH 1 MS CLOCK AS
; SUPPLIED IN BBN MODS TO KA-10, OR WITH DEC DK10 CLOCK,
; OR WITH NEITHER. IF NEITHER, ASSEMBLE FOR BBN CLOCK - CODE
; WORKS ANYWAY.

IFE F3FLG,<		;UNLESS THIS IS AN F3
IFE DK10F,<		;CODE FOR BBN CLOCK OR NO CLOCK

OAP==20			;CLOCK AND DOORBELL DEVICE.

DEFINE MSCKON
<	CONO OAP,1B29>	;CLOCK ON

DEFINE MSCKOF
<	CONO OAP,1B29>	;SAME. FLOP COMPLEMENTS.

DEFINE SOMSCK
<	CONSO OAP,1B28>	;SKIP IF CLOCK FLAG ON

DEFINE MSCKCL
<	CONO OAP,1B28>	;CLEAR CLOCK FLAG
>;END OF BBN CLOCK
>;END OF NON-F3, NON-DK10 DEFINITIONS
IFN DK10F,<

CLK==070		;DK10 CLOCK DEFINITIONS

DEFINE MSCKON
<	CONO CLK,1B30+APRCHN>

DEFINE MSCKOF
<	CONO CLK,1B29+APRCHN>

DEFINE SOMSCK
<	CONSO CLK,1B31!1B32>	;CHECK OVERFLOW TOO

DEFINE MSCKCL
<	CONO CLK,1B31+1B32+APRCHN>
>;END OF DK10 DEFS
;DEFINITIONS FOR F3 CLOCK MECHANISM (0.1 MS)
IFN F3FLG,<

OPDEF TCONO  [760000,,0]	;CONO CLOCK
OPDEF TCONI  [761000,,0]	;CONI CLOCK
OPDEF TCONSO [762000,,0]	;CONSO CLOCK
OPDEF TCONSZ [763000,,0]	;CONSZ CLOCK
OPDEF TLOAD  [764000,,0]	;LOAD CLOCK COUNTER FROM E
OPDEF TREAD  [765000,,0]	;READ CLOCK COUNTER TO E
OPDEF ADJSP  [105000,,0]	;KL INSTRUCTION

DEFINE MSCKON,<
	TCONO APRCHN
	TLOAD [-^D10]
>

DEFINE MSCKOF,<
	TCONO 0
>

DEFINE SOMSCK,<
	TCONSO 1B32
>

DEFINE MSCKCL,<
	TCONO APRCHN
	TLOAD [-^D10]
>
>;END IF IFN F3FLG

;BITS FOR CONO/CONI APR

IFN KIFLG,<
APNXM==1B29
APCHNS==<APRCHN>B32+APRCHN	;KI APR HAS 2 PI ASMTS
>
IFN KAFLG!F3FLG,<
APNXM==1B23			;NON EX MEM FLAG
APCHNS==APRCHN
>
;PARAMETERS USED IN PAGEM AND SCHED

NOFN==1000		;NUMBER OF SPT SLOTS FOR OFN'S
SPTM==017777		;MASK FOR SPT INDICES (MAX SPT LENGTH)
OFNBAT==1B21		;BAT BIT IN SPTH
THAWB==1B20		;THAWED FILE BIT
FILWB==1B19		;FILE WRITE BIT
SPTLKB==1B22		;IN LH OF SPTH(OFN): XB IN USE BY DDMP
NEWFB==1B33		;NEW FILE OR FILE PAGE BIT
DRPERM==1B23		;PERMANENT ON DRUM PAGE
BWRBIT==1B31		;WRITTEN (CHANGED) FROM HOME COPY
PLKV==1B27		;FOR LOCK VALUE IN CST1
BP1==^D10		;BIT POSITION OF PROCESS 0 IN CST0
DSKSWB==1B20		;SWAP TO DISK REQUESTED
CORWB==<Z (CORMB)>	;RH VALUE FOR USE AS GLOBAL
DWRBIT==<Z (1B0)>	;WRITE BIT IN CST3
SWPERR==<Z (1B1)>	;SWAP ERROR BIT IN CST3
AGTICK==^D20		;MILLISECONDS PER TICK OF AGE REGISTER
AGSEC==^D1000/AGTICK	;AGE-TICKS PER SECOND

;FIXED REAL CORE LOCATIONS

NJDVPG==1		;NORMAL JSYS DISPATCH IS REAL CORE PAGE 1
NJDV==<NJDVPG>B26	;NORMAL JSYS DISPATCH

MMAP=3000		;RESIDENT MAP (RES MON, PPR MON, SWP MON)
CST0=4000		;CORE STATUS TABLE, PART 0 (AGE AND PROCESS BITS)

;MONITOR MAP BOUNDARIES

PJMPG==600		;PER JOB REGION
PPMPG==740		;PER PROCESS REGION
SWPMA==<SWPMPG>B26
PPRMA==<PPRMPG>B26
PJMA==<PJMPG>B26
PPMA==<PPMPG>B26

;SWAPPER PAGES RESERVED IN PROCESSOR-PRIVATE AREA

DEFINE ASNPPG(P,N)
<P==PPGCT
PPGCT==PPGCT+N
P'A=<P>B26
>

PPGCT==PPRMPG		;ASSIGN SOME PAGES IN THIS REGION

ASNPPG CSWPG,1		;SWAPPER TEMP
ASNPPG FITPG,1		;FORK INIT TEMP
ASNPPG PRLPG,1		;FORK PRELOADING MAP TEMP
IFN KIFLG,<
ASNPPG KIPG,1		;TEMP FOR KI SIMULATION ROUTINE
>
ASNPPG PIPG,1		;TO REFERENCE REAL CORE AT PI LEVEL

NRSPG==PPGCT-PPRMPG	;NUMBER OF PAGES RESERVED AT BOTTOM OF SWP MON

;SPECIAL RESERVED AREA FOR MDDT REENTRANT CODE
;PRIVATE SEGMENT LIVES IN PER-PROCESS AREA

LMDDT==10000		;LENGTH OF MDDT AREA
MDDTPG==PJMPG-LMDDT/1000 ;DDT LIVES AT HIGH END OF SWPMON AREA
MDDT=<MDDTPG>B26

;JOB-COMMON AREA

JDVPG==PJMPG		;JSYS DISP IS FIRST PAGE IN PER JOB AREA
JDV==<JDVPG>B26

JSBPG==PJMPG+1		;JSB IS SECOND PAGE IN JOB-COMMON AREA
JSB=<JSBPG>B26

FREJP==JSBPG+4		;4 PAGES RESERVED FOR JSB EXPANSION
FREJPA=<FREJP>B26

;JFN STORAGE PARAMETERS

JFNPC0=JSB+500			;MUST BE ADJUSTED IF JSB STORAGE GROWS
NJFNW==1_SJFN			; = 2^SJFN
MJFN=<<FREJPA-JFNPC0>/NJFNW> ;MAX NUMBER JFNS
RJFN=MJFN*NJFNW			;ACTUAL SPACE USED BY JFNS

;PROCESS-PRIVATE AREA

PSB=777000		;PSB IS TOP PAGE OF MAP
PSBPG==<PSB>B44

UPTA=PSB-1000		;USER PAGE TABLE
UPTPG==<UPTA>B44

UACPG==PSBPG-2		;VIRTUAL PAGE FOR AC SAVE BLOCKS
UACPGA==<UACPG>B26

DEFINE ASNPPG (P,N)
<P==PPGCT
PPGCT=PPGCT+N
P'A=<P>B26 >

PPGCT=PPMPG		;VARIOUS PROCESS RESERVED PAGES

ASNPPG CXBPG,1		;SWAPPER, MAP TEMP
ASNPPG CPTPG,1		; ..
ASNPPG CPYPG,1		; ..
ASNPPG DDPG1,1		;DDMP
ASNPPG DDPG2,1		; ..
ASNPPG PSIPG,1		;PSI IN PROGRESS STORAGE
ASNPPG FTPG1,1		;FORK
ASNPPG FPBPG,1		;FORK, HOLDS OBJECT PSB

FPG2==DDPG1		;USED BY SSAVE
FPG2A=DDPG1A
JSBPA=DDPG1A		; USED BY GACTJ FOR MAPPING JSB'S
FPG3==DDPG2
FPG3A=DDPG2A
DDTPPG==774		;MDDT PRIVATE SEGMENT

ALRMAX==0		;NUMBER OF PAGES RESERVED FOR ALR
ALRVAL==10-<ALRMAX>B40	;3-BIT QUANTITY FOR PAGER ALR

;AC DEFINITIONS

STS=:0
A=:1
B=:2
C=:3
D=:4
UNIT=:5
IOS=:6
E=:7
F=:10
JFN==:11	; JOB FILE NUMBER
NUM==:12	; USED AROUND GTJFN LOOP TO ACCUMULATE NUMBERS
DEV==:13	; LH DEVICE BITS, RH DEVICE DISPATCH TABLE
F1==:14		; MORE FLAGS FOR GTJFN AND LOOKUP ROUTINES
NSAC==F1+1	; NUMBER OF AC'S TO SAVE WHEN CALLING OTHER ROUTINES
P=:17		;UNIVERSAL STACK

; *****
; The following definitions are TOPS20 module support junk
; *****

T1=:A
T2=:B
T3=:C
T4=:D
Q1=:5
Q2=:6
Q3=:7
FX=:7
P1=:10
P2=:11
P3=:12
P4=:13
P5=:14
P6=:15
CX=:16

DEFINE IFKL (STUFF)<>
DEFINE IFKA (STUFF)<STUFF>
DEFINE IFNKA (STUFF)<>
DEFINE IFSM (STUFF)<>
DEFINE MDISMS <JSYS EDISMS##>
DEFINE MCENT <JSYS MENTR##>
DEFINE MCENTR <JSYS MENTR##>
DEFINE SMRETN <JRST SKMRTN##>
DEFINE MRETNG <JRST MRETN##>
DEFINE SAVET <JSP CX,.SAVT##>
DEFINE SAVEQ <JSP CX,.SAVQ##>
DEFINE SAVEP <JSP CX,.SAVP##>

DEFINE HDISMS (HT)<
	JSYS EDISMS##>

DEFINE RETBAD (ERN,EXTRA)<
	IFNB <ERN'EXTRA>,<
	JRST [	EXTRA
	   IFNB <ERN>,<MOVEI 1,ERN>
		RET]>
	IFB <ERN'EXTRA>,<
	RET>>

DEFINE EXTN (SYMS)<
	IRP SYMS,<
	EXTERN SYMS>>


DEFINE DEFAC (NEW,OLD)<
	NEW==OLD>

DEFINE DTBSKP<RSKP>

DEFINE DTBBAD (A)<
    IFNB <A>,<
	[MOVEI T1,A
	RET]>
    IFB <A>,<
	 R>
>

DEFINE DTBDSP (ROU) <ROU>

DEFINE SE0ENT <>
DEFINE SE1ENT <>

DEFINE ..DOTQ (M,T)<		;REDEFINE THESE SINCE THE MACSYM ONES LOSE
	IRP M,<
	IRP T,<
	  DEFINE TQ'M'T (X,Y)<
	    TEST (M'T,X,Y)>>>>

	..DOTQ (<N,O,Z,C>,<,E,N,A>)
	PURGE ..DOTQ

; *****
; End of definitions for TOPS20 module support
; *****

OPDEF JSYS [104B8]
OPDEF CALL [PUSHJ P,0]
OPDEF RET [POPJ P,0]
OPDEF ERJMP [JUMP 16,0]
OPDEF ERCAL [JUMP 17,0]
IFN KAFLG!F3FLG,<
OPDEF XCTUU [XCT 7,0]
OPDEF XCTMU [XCT 1,0]
OPDEF XCTUM [XCT 4,0]
OPDEF XCTBU [XCT 3,0]

OPDEF XBLTUU [XCT 7,0]
OPDEF XBLTMU [XCT 1,0]
OPDEF XBLTUM [XCT 4,0]
>
IFN KIFLG,<
OPDEF XCTUU [XCT 3,0]
OPDEF XCTMU [XCT 2,0]
OPDEF XCTUM [XCT 1,0]
OPDEF XCTBU [XCT 3,0]

DEFINE UMOVE (A,L)
<	XCTUU [MOVE A,L]>
DEFINE UMOVEM (A,L)
<	XCTUU [MOVEM A,L]>
DEFINE UMOVEI (A,L)
<	PRINTX !UMOVEI NOT AVAILABLE ON KI-10!>
DEFINE UMOVES (A,L)
<	XCTUU [MOVES A,L]>
>;END OF KI-10 DEFINITIONS

;LOCAL STORAGE ALLOCATION MACRO

DEFINE LS (T,N)
<	IFB <N>,<ASSIGN T,RESVLC,1>
	IFNB <N>,<ASSIGN T,RESVLC,N>>

;GLOBAL STORAGE

DEFINE GS (T,N)
<	IFB <N>,<ASSIGN T,RESVLC,1>
	IFNB <N>,<ASSIGN T,RESVLC,N>
>

;SWAPPABLE STORAGE

DEFINE NGS (T,N)
<	IFB <N>,<ASSIGN T,NRESLC,1>
	IFNB <N>,<ASSIGN T,NRESLC,N>
>

;SWAPPABLE STORAGE ASSIGNED PAGE-AT-A-TIME

DEFINE NGSP(T,N)
<	IFB <N>,<ASSIGN T,NRPLOC,1000>
	IFNB <N>,<ASSIGN T,NRPLOC,N*1000>
>

;SWAPPABLE, RESIDENT CODE

DEFINE SWAPCD<USE SWAPPC>
DEFINE RESCD<USE RESPC>

;REDEFINE TITLE TO DO ALL NECESSARY INITIAL THINGS

SYN TITLE,%TITLE

DEFINE TITLE(TT)
<	%TITLE TT
   IF2,<IFDEF SCDV1,<
	TSMAC(TTS)
	JSMAC(JJS)>
     IFDEF LDINIT,<
	JSYSLC==0
	EXTERN UJSYS
	JDMAC(LJD)>
   >
>

IFDEF .ORG,<
SYN .ORG,ORG>		;FOR DEC MACRO V50 AND LATER
IFDEF .ASSIGN,<
SYN .ASSIGN,ASSIGN>	; ..

; THE FOLLOWING MACRO DEFINES THE LIST OF TENEX MODULES IN THE ORDER
; IN WHICH THEIR SYMBOLS ARE TO BE DELETED TO REDUCE THE SIZE OF THE
; SYMBOL TABLE. EACH ENTRY HAS THREE ARGUMENTS, AS FOLLOWS:
; FIRST ARGUMENT: MODULE (OR BLOCK) NAME
; SECOND ARGUMENT: -1 MEANS DON'T DEFINE BUGSTRING SYMBOLS
;                   0 MEANS DEFINE BUGSTRING SYMBOLS, BUT DON'T
;                           ALLOCATE BUGSTRING SPACE
;                   .GT. 0 MEANS DEFINE BUGSTRING SYMBOLS, AND
;                                ALLOCATE SPACE FOR THAT MANY BUGSTRINGS
; THIRD ARGUMENT: +1 MEANS DON'T DELETE ANY SYMBOLS FROM THIS MODULE
;                          (OR BLOCK)
;                  0 MEANS DELETE ALL SYMBOLS (BOTH LOCAL AND GLOBAL)
;                          FROM THIS MODULE, WHETHER OR NOT IT IS
;                          NECESSARY TO REDUCE THE SIZE OF THE SYMBOL
;                          TABLE
;                 -1 MEANS DELETE ONLY LOCAL SYMBOLS FROM THIS MODULE,
;                          AND ONLY DO IT IF IT IS NECESSARY TO REDUCE
;                          THE SIZE OF THE SYMBOL TABLE
;	IF A CHANGE IS MADE TO FOLLOWING TABLE, REASSEMBLE POSTLD
DEFINE	%TENX%(X),<
	X(<EDDT>,-1,0)
	X(<JOBDAT>,-1,0)
	X(<TENDMP>,-1,0)
	X(<LDINIT>,0,0)
	X(<STORAG>,0,-1)
	X(<SYSNAM>,0,-1)
	X(<POSTLD>,0,0)
	X(<RITH>,-1,-1)
	X(<FLIN>,-1,-1)
	X(<FLOUT>,-1,-1)
	X(<DATIME>,0,-1)
	X(<NIL>,0,-1)
	X(<DEVICE>,0,-1)
	X(<STRING>,0,-1)
	X(<MFLIN>,0,-1)
	X(<MFLOUT>,0,-1)
	X(<SIGNAL>,0,-1)
	X(<FILTTY>,0,-1)
	X(<VTCDV>,0,-1)
	X(<LINEPR>,10,-1)
	X(<DISC>,10,-1)
	X(<FREE>,40,-1)
	X(<MAGTAP>,10,-1)
	X(<LOOKUP>,10,-1)
	X(<DIRECT>,20,1)
	X(<GTJFN>,3,1)
	X(<ACCTJS>,20,1)
	X(<DEVJS>,14,1)
	X(<FILEJS>,10,1)
	X(<LOGJS>,20,1)
	X(<HOSTS>,0,-1)
	X(<IO>,1,-1)
	X(<PSDOTY>,0,-1)
	X(<MAGTAP>,10,-1)
	X(<FILINI>,30,1)
	X(<FUTILI>,0,1)
	X(<JOBINI>,6,1)
	X(<JOBZRO>,6,1)
	X(<LOG2JS>,4,1)
	X(<MONJS>,4,1)
	X(<FORKS>,14,1)
	X(<SYSINI>,14,1)
	X(<DRM>,30,-1)
	X(<STENEX>,-1,-1)
	X(<PROLOG>,-1,-1)
	X(<TTYSRV>,10,-1)
	X(<TYMSRV>,40,-1)
	X(<NETWRK>,15,-1)
	X(<CHAOS>,100,-1)
	X(<CHATTY>,0,-1)
	X(<DSK>,35,-1)
	X(<IMPDV>,50,-1)
	X(<NVT>,10,-1)
	X(<TOPS>,2,1)
	X(<PISRV>,20,1)
	X(<SCHED>,33,1)
	X(<PAGEM>,110,1)
	X(<HOMBAT>,70,1)
>

;PARAMETERS FOR BUG STRING STORAGE

DEFINE	DFBGP(NAM,NSTRNGS,WHEN)<
IFGE NSTRNGS, <
%P'NAM==..BGP
%S'NAM==..BGS
%N'NAM==NSTRNGS
..BGP==..BGP+NSTRNGS
..BGS==..BGS+10*NSTRNGS>>

NBUGP==:3000		; SIZE OF BUG POINTER AREA
SBUGTF==:6000		; SIZE OF (COMPACTED) BUGTABLE IMAGE FILE
STRBGP==:6000		; START OF POINTER AREA (ITS COMPACTED IN PLACE)
..BGP==:STRBGP		; BEGINNING OF POINTER AREA (COMPACTED IN PLACE)
..BGS==STRBGP+SBUGTF	; BEGINNING OF STRING AREA BEFORE COMPACTION.
; IT IS COMPACTED IMMEDIATELY AFTER THE COMPACTED POINTERS

	%TENX%(DFBGP)

IFG ..BGP-STRBGP-NBUGP,<
PRINTX TOO MANY BUGSTRINGS ALLOCATED IN PROLOG
>

PURGE	..BGP,..BGS

; NON-VARIABLE PARAMETERS -- USED GLOBALLY

; CAPABILITY BITS

WHEEL==:400000
OPER==:200000
OPR==OPER		;SOME USES OF THIS NOT YET EDITTED OUT
CONFI==:100000		; CONFIDENTIAL INFO ACCESS
MAINT==:040000
NETWIZ==:020000		; NETWORK WIZARD
ABSOKT==:010000		;ABSOLUTE SOCKET CAPABILITY
LOG==:040000		;LOG CAP, IN LEFT HALF.
ARPAN==:004000		; ABILITY TO ACCESS ARPANET
CUSTMR==:002000		; CUSTOMER.
TYMOX==:001000		; ABILITY TO USE AUXBLD FUNCTION OF TYMOP JSYS
SC%CHA==:001000		;CAN USE CHAOSNET

; BIT DEFINITIONS IN FACTSW

FACTON==:1B0		;FACT FILE IS ON
CHKDSE==:1B2		;CHECKDSK DISCOVERED ERRORS
CHKDSR==:1B3		;CHECKDSK RUNNING UNDER JOB ZERO

OPDEF PIOFF [CONO PI,1B27]
OPDEF PION [CONO PI,1B28]

DEFINE CHNOFF (CHN)
<	CONO PI,1B26+1B<28+CHN>>

DEFINE CHNON (CHN)
<	CONO PI,1B25+1B<28+CHN>>

DEFINE ISB (CHN)
<	CONO PI,4000+1B<28+CHN>>
DEFINE TESTI(CHN)
<	CONSZ PI,1B<28+CHN>>
IFN KIFLG,<
DEFINE CLSB (CHN)
<	CONO PI,1B22+1B<28+CHN>>
>
DEFINE UNBRK (DEV)
<	EXTERN DEV'CHR
	JRST DEV'CHR>

;INSTRUCTION TRAP ERROR

DEFINE ITERR (ERN,EXTRA)
<	XLIST
IFNB <ERN>,<
	IFNDEF ERN,<EXTERN ERN>
	JRST [	EXTRA
		MOVEI 1,ERN
		JRST ITRAP1]
>
IFB <ERN>,<
	IFB  <EXTRA>,<JRST ITRAP##>
	IFNB <EXTRA>,<JRST [EXTRA
			    JRST ITRAP##]>
	  >
	LIST
>

DEFINE RETERR (ERN,EXTRA)
<	XLIST
IFNB <ERN>,<
	IFNDEF ERN,<EXTERN ERN>
	JRST [	EXTRA
		MOVEI 1,ERN
		JRST MRETNE]
>
IFB <ERN>,<
	IFB <EXTRA>,<JRST MRTNE1>
	IFNB <EXTRA>,<JRST [EXTRA
			    JRST MRTNE1]>
	   >
	LIST>

;SCHEDULING CONTROL MACROS

DEFINE NOSWAP
<	AOS NSWAP>

DEFINE OKSWAP
<	SOSG NSWAP
	AOS ISKED>

DEFINE RESKED
<	AOS ISKED
	EXTERN ISKED
	ISB SCDCHN>

;RESKED MACRO WHICH REQUESTS ONLY BALANCE SET RESCHEDULE
;WITHOUT WAIT LIST SCAN (AS OCCURS WITH RESKED)
DEFINE RESKD1
<	AOS PSKED
	EXTERN PSKED
	ISB SCDCHN>


DEFINE NOSKED
<	AOS NSKED>

DEFINE OKSKED
<	SOSG NSKED
	XCT RSKED>

;NOSKED AND OKSKED FOR CODE POSSIBLY BEING RUN UNDER SCHEDULER

DEFINE NOSKD1
<	SKIPN INSKED
	AOS NSKED>

DEFINE OKSKD1
<	SKIPN INSKED
	SOSLE NSKED
	CAIA
	XCT RSKED>

;SCHEDULER ENTRY CALL - CONDITIONAL BECAUSE CAN'T BE A JSYS ON KI-10
IFN KAFLG!F3FLG,<
DEFINE ENTSKD
<	JSYS ENSKED>>
IFN KIFLG,<
DEFINE ENTSKD
<	JSR ENSKR>>

;MACROS TO SWITCH PROCESS OVER TO CPU WHICH HAS NEEDED I/O DEVICE

DEFINE RUNON0<>
DEFINE RUNON1<>

;PSI CONTROL

DEFINE NOINT
<	AOS INTDF>

DEFINE OKINT
<	XCT INTDFF>

DEFINE TSTINT
<	SKIPE PSIBW>

;HANDY MACROS FOR LOCKS

	DEFINE LOCK (LCK,FAIL,Q,LOQ)
<IFN PIESLC,<
IFNB <Q>,<PUSHJ P,SET'Q##>>

	AOSE LCK

IFB <FAIL>,<PUSHJ P,CNTLCK##>

IFNB <FAIL>,<
	IFB <LOQ>,<FAIL>
	IFNB <LOQ>,<JRST [IFNB <Q>,<PUSHJ P,REL'Q##>
			FAIL]>
>>

	DEFINE UNLOCK (LCK,R,Q)
<IFNB <R>,<SETOM LCK>
IFB <R>,<SOSL LCK
		PUSHJ P,CNFLCT##>

IFN PIESLC,<
	IFNB <Q>,<PUSHJ P,REL'Q##>>
>

;PAGER INSTRUCTIONS - DEPENDENT ON CPU

IFN KAFLG!F3FLG,<

;CLEAR AR'S AND LOAD PARAMETERS

DEFINE PGRCLD
<	CONO PGR,0>

;CLEAR SPECIFIED MONITOR PAGE

DEFINE MONCLR(A)
<	CONO PGR,1>	;CLEARS ALL MONITOR AR'S

;LOAD AGE REGISTER

DEFINE PGRLAG
<	CONO PGR,0>	;LOADS ALL PARAMETERS ON KA-10

;TURN ON PAGING EXCEPT RESIDENT MONITOR

DEFINE PGRON
<	CONO PGR,6
	DATAO APR,[776776,,0]>

;TURN OFF PAGING SO ALL REF'S GO TO REAL CORE

DEFINE PGROFF
<	CONO PGR,4>

;SET AC BLOCKS FOR UMOVEX GROUP

DEFINE SETACB (A)
<	DPB A,[POINT 5,PGR71,22]
	CONO PGR,0>
>;END OF KA-10 DEFINITIONS

IFN KIFLG,<		;CORRESPONDING ROUTINES FOR KI-10

;MONITOR LUUO'S

OPDEF .IMCLR [1B8]	;MONITOR MAP CLEAR

;TRAP MUUO'S

OPDEF .PGTRP [40B8]	;PAGE FAULT, USER OR MONITOR
OPDEF .AROVT [41B8]	;AR OV, USER ONLY
OPDEF .PDOVT [42B8]	;PDL OV , USER OR MONITOR

;NO-TRAP UUO'S ARE JSYS (104) AND TOPS-10 MONITOR CALLS,
; DEFINED ELSEWHERE

;PAGER INSTRUCTIONS FOR KA-10 PAGER SIMULATOR

DEFINE	PGROFF		;;turn off paging
<	JSR KIPOFF## >

DEFINE	PGRON		;;turn on paging
<	JSR KIPCLD## >

DEFINE	SETACB (A)	;;set AC base register
<	DPB A,[POINT 5,PGR71,22]
	JSR KIPSAB## >

DEFINE	PGRLAG		;;load age register
<	CALL KIPLAG## >

DEFINE	PGRCLD		;;clear AR's and load parameters
<	JSR KIPCLD## >

DEFINE	MONCLR (A)	;;clear monitor page A
<IFE <A>,<.IMCLR>
 IFN <A>,<
  IFLE 400-<A>,<
   IFE <A>&1,<	HRRZS KIEPT+<A>/2 >
   IFN <A>&1,<	HLLZS KIEPT+<A>/2 >>
  IFG 400-<A>,<
	PUSH P,1
	MOVE 1,KXUPT
   IFE <A>&1,<	HRRZS 400+<<A>-340>/2(1) >
   IFN <A>&1,<	HLLZS 400+<<A>-340>/2(1) >
	POP P,1 >
	DATAO PAG,KIPGWD >
>

DEFINE	MONSET (A,W,XX)	;;set monitor page A
<IFLE 400-<A>,<
  IFE <A>&1,<	HRLM W,KIEPT+<A>/2 >
  IFN <A>&1,<	HRRM W,KIEPT+<A>/2 >>
 IFG 400-<A>,<
  IFNB <XX>,<X==XX>
  IFB <XX>,<	PUSH P,<X==1> >
	MOVE X,KXUPT
  IFE <A>&1,<	HRLM W,400+<<A>-340>/2(X) >
  IFN <A>&1,<	HRRM W,400+<<A>-340>/2(X) >
  IFB <XX>,<	POP P,X >>
>

DEFINE	SETKIM (A,W,XX,%L)	;;set monitor map
<IFNB <XX>,<X==XX>
 IFB <XX>,<	PUSH P,<X==1+<W&1>> >
	LSH W,-^D9
	ANDI W,SPTM
       PIOFF
	MOVE W,SPT(W)
	MOVSI X,(700B8)
	TLNN W,17
	TDON X,CST0(W)
	 JRST %L
	TLNE X,(CORMB)
	 TRO W,KIWB
	TROA W,KIAXB
%L:	SETZ W,
 IFLE 400-<A>,<
  IFE <A>&1,<	HRLM W,KIEPT+<A>/2 >
  IFN <A>&1,<	HRRM W,KIEPT+<A>/2 >>
 IFG 400-<A>,<
	MOVE X,KXUPT
  IFE <A>&1,<	HRLM W,400+<<A>-340>/2(X) >
  IFN <A>&1,<	HRRM W,400+<<A>-340>/2(X) >>
       PION
 IFB <XX>,<	POP P,X >
>
>; END OF KI-10 PAGER SIMULATOR DEF'S

; The following macro is used to define flag bits
; In conjunction with the test macro, it provides for automatic
; Insertion of the ac holding the flag, and trxx or tlxx to reference
; The proper halfword

DEFINE	FLG(FL,LR,REG,BIT)<FL'%==<T'LR'N REG,BIT>
IFL BIT-20,<FL==BIT>
IFGE BIT-20,<FL=BIT>>

DEFINE	TEST(COND,FL1,FL2)<IFIDN <FL2>,<>,<<TR'COND>!FL1'%>
IFDIF <FL2>,<>,<<TR'COND>!FL1'%!FL2'%
IFN <FL1'%>&777777000000-<FL2'%>&777777000000,<
PRINTX	FL1 & FL2 ARE IN DIFFERENT HALF WORDS>>>

; Macros to allocate storage

DEFINE	DFS(N,PC)<
 DEFINE	N(VAR,SIZE)<
	IFIDN <SIZE><><ASSIGN VAR,PC>
	IFDIF <SIZE><><ASSIGN VAR,PC,SIZE>>>

DFS(JS,JSBLOC)
DFS(LS,RESVLC)
DFS(PS,TSBLOC)
DFS(NR,NRESLC)
DFS(NRP,NRPLOC)


IFDEF SSACHN,<

;PARAMETERS USED IN MAGTAP, SSASRV, AND DSKPAK IF AN SA-10 SSA
;IS USED TO DRIVE DISK OR TAPE.

;PARAMETERS USED IN SA10 AND IBM-STYLE DEVICES

; DEVICE NUMBER ON PDP-10 I/O BUS OF THE SSA ITSELF

SSA==274

;CONO TO SSA

SA.INI==1B18		; INITIALIZE WHOLE SSA
SA.CME==1B19		; CLEAR MEMORY ERROR FLAGS
SA.CLK==1B26		; CLOCK CONTROL IN SSA MICROPROCESSOR
SA.NOP==0B29		; FUNCTION SELECTION, BITS 27-29. NOP=0
SA.HIO==2B29		; HALT I/O
SA.RSC==3B29		; RESET CHANNEL
SA.GOF==4B29		; GO FLAG FOR CHANNEL
SA.SRQ==5B29		; STATUS REQUEST FLAG
SA.STS==6B29		; STATUS DONE FLAG
SA.PIE==7B29		; INTERRUPT ENABLE FOR A CHANNEL
SA.SET==1B30		; SET/DO ONE OF ABOVE FUNCTIONS.
SA.CH0==0B32		; SELECT CHANNEL 0 IN ABOVE COMMANDS
SA.CH1==1B32		; SELECT CHANNEL 1
SA.CH2==2B32		; SELECT CHANNEL 2
SA.CH3==3B32		; SELECT CHANNEL 3
;BITS 33-35 ARE THE PI ASSIGNMENT FOR THE SA-10 AS A WHOLE.

;CONI FROM SSA

SA.PIR==1B18		; A PI REQUEST IS BEING MADE
SA.MPE==1B19		; PARITY ERROR FLAG
SA.NXM==1B20		; NON-EX MEMORY FLAG
SA.IE0==1B21		; INTERRUPTS ARE ENABLED FROM CHANNEL 0
SA.IE1==1B22		; .. CH 1
SA.IE2==1B23		; .. CH 2
SA.IE3==1B24		; .. CH 3
SA.GO0==1B25		; THE GO FLAG IS ON FOR CHANNEL 0
SA.GO1==1B26		; .. CH 1
SA.GO2==1B27		; .. CH 2
SA.GO3==1B28		; .. CH 3
SA.SF0==1B29		; THE STATUS DONE FLAG IS ON FOR CHANNEL 0
SA.SF1==1B30		; .. CH 1
SA.SF2==1B31		; .. CH 2
SA.SF3==1B32		; .. CH 3
;AND THE PIA COMES BACK IN BITS 33-35

;BLOCK MULTIPLEXOR CONTROL COMMANDS -- LEFTMOST 8 BITS OF CHANNEL
; PROGRAM MULTIPLEXOR BLOCK

BMX.S==320		; START THIS DEVICE
BMX.W==340		; THIS DEVICE IS WAITING
BMX.T==360		; THIS DEVICE HAS TERMINATED
			;  A ZERO WORD ENDS THE STRING OF BMX WORDS.

;OTHER CHANNEL PROGRAM COMMANDS

TCH==1B1		; TRANSFER IN CHANNEL PROGRAM

;DEVICE COMMAND WORD

SC.NMX==1B0		; NO MEMORY TRANSFER
SC.XCT==1B2		; EXECUTE THIS WORD
SC.CHN==1B3		; CHAIN TO FURTHER WORDS AFTER THIS ONE
SC.BYT==1B4		; TRANSFER BYTES, NOT WORDS (BYTE = 8 BITS)
SC.INT==1B5		; CAUSE AN INTERRUPT WHEN THIS CMD EXECUTED
SC.ILE==1B6		; IGNORE LENGTH ERROR
SC.BOF==1B7		; BYTE OFFSET. START 2 BYTES OVER IN WORD.

;DEVICE CODES ON THE IBM BUS

I.TDEV==200		; ADDRESS OF TAPE DRIVE 0
I.DDEV==300		; ADDRESS OF DSK DRIVE 0

;CHANNEL STATUS BYTE -- B0 - B7 OF STATUS WORD ONE IN LOW CORE

SS.INI==0B1		; INITIAL SELECTION STATUS
SS.END==1B1		; ENDING STATUS
SS.ASY==2B1		; ASYNCHRONOUS STATUS
SS.DMY==3B1		; DUMMY STATUS (PROGRAM REQUESTED)
SS.SER==1B2		; SELECT ERR. NO SUCH DEVICE.
SS.BIP==1B3		; BUS IN PAR ERR. ERROR ON IBM-CHANNEL BUS
SS.CSE==1B4		; CONTROL SEQUENCE ERROR. JUNK ON CHANNEL BUS.
SS.LNE==1B6		; LENGTH ERROR (DATA TRANSFER WORD/BYTE COUNT)
SS.PIF==1B7		; PROG INTERRUPT FLAG (REQ BY CHAN PRG)

;IBM-DEVICE STATUS BYTE, BIT NAMES. APPEAR IN B8-B15 OF STATUS WD 1
ID.ATN==200		; ATTENTION
ID.SMD==100		; STATUS MODIFIER
ID.CUE==040		; CONTROL UNIT END
ID.BSY==020		; BUSY (DEVICE OR CONTROLLER)
ID.CHE==010		; CHANNEL END (DATA XFR THROUGH)
ID.DVE==004		; DEVICE END
ID.UCK==002		; UNIT CHECK
ID.UEX==001		; UNIT EXCEPTION (UNUSUAL STATE, NOT ERROR)

;IBM COMMAND CODES - OPCODES TO TAPE OR DISK

IC.NOP==003		; NO-OPERATION
IC.WRT==001		; WRITE DATA (TAPE)
IC.RDT==002		; READ DATA (TAPE)
IC.RDD==006		; READ DATA AREA OF DSK RECORD
IC.WRD==005		; WRITE DATA AREA OF DSK RECORD
IC.SNS==004		; REQUEST SENSE BYTES FROM DEVICE
IC.REW==007		; REWIND (MAGTAPE)
IC.SEK==007		; SEEK (DISK)
IC.RUN==017		; REWIND-UNLOAD MAGTAPE
IC.ERG==027		; ERASE GAP (MAGTAPE)
IC.WEF==037		; WRITE TAPE MARK (END OF FILE)
IC.BSB==047		; BACKSPACE BLOCK
IC.BSF==057		; BACKSPACE FILE
IC.SKB==067		; SKIP BLOCK
IC.SKF==077		; SKIP FILE
IC.SSC==043		; SET SECTOR (DSK) WAIT FOR RIGHT ANGULAR POS.
IC.SIE==061		; SEARCH ID EQUAL (DSK)
IC.RCL==027		; RECALIBRATE (RESTORE) (DSK)
>	; END OF CONDITION ON SSACHN

	SUBTTL	CHAOSNET DEFINITIONS
IFDEF CHAOS,<

CHSMGV==123456654321		;MAGIC VALUE FOR VERIFYING CONNECTIONS AND PACKETS

;CHAFLG VALUES TELLING BACKGROUND CHAOS FORK WHAT WORK THERE'S TO DO
CH%TTY==1B18			;SOME TTY WORK TO DO
CH%RFC==1B19			;A RFC TO HANDLE
CH%IIN==1B20			;INPUT INTERRUPTS TO PROCESS
CH%OIN==1B21			;OUTPUT INTERRUPTS
CH%DIN==1B22			;DETACH INTERRUPTS
CH%CLS==1B23			;AN NVT CONNECTION NEEDS CLOSING
CH%STS==1B24			;SOME CONNECTION NEEDS A STATUS DONE


;.MOEOF==3
.MOACN==24
.MOERR==25
.MOPKS==26
.MOPKR==27
.MOSWS==30
;.MONOP==31
.MOOPN==32
.MOAWS==33
.MOFHS==34
.MOSIZ==35
.MORWS==36
.MOUAC==37
.MOSRT==41
.MOFRH==42

SEARCH MONSYM,MACSYM

;PACKET FORMAT
DEFSTR(CPKOP,0,7,8)		;OPCODE
 .CORFC==1			;REQUEST FOR CONNECT
 .COOPN==2			;OPEN
 .COCLS==3			;CLOSE
 .COFWD==4			;FORWARD
 .COANS==5			;ANSWER
 .COSNS==6			;SENSE STATUS
 .COSTS==7			;REPORT STATUS
 .CORUT==10			;ROUTING INFO (NOT USED)
 .COLOS==11			;YOU ARE LOSING
 .COLSN==12			;LISTEN (NEVER USED)
 .COMNT==13			;MAINTENANCE
 .COEOF==14			;EOF CONNECTION STREAM
 .COMAX==15			;MAXIMUM OPCODE+1
 .CODAT==200			;RANDOM DATA OPCODE
DEFSTR(CPKFC,0,19,4)		;FORWARDING COUNT
DEFSTR(CPKNB,0,31,12)		;BYTE COUNT
CHPKD==1			;DESTINATION
DEFSTR(CPKDA,1,15,16)		;DESTINATION ADDRESS
 DEFSTR(CPKDS,1,7,8)		;DESTINATION SUBNET
DEFSTR(CPKDI,1,31,16)		;DESTINATION INDEX
 DEFSTR(CPKD1,1,31,10)		;LOCAL INDEX PART OF "
CHPKS==2			;SOURCE
DEFSTR(CPKSA,2,15,16)		;SOURCE ADDRESS
 DEFSTR(CPKSS,2,7,8)		;SOURCE SUBNET
DEFSTR(CPKSI,2,31,16)		;SOURCE INDEX
DEFSTR(CPKPN,3,15,16)		;PACKET NUMBER
DEFSTR(CPKAN,3,31,16)		;ACKNOWLEDGE NUMBER
CHPKDT==4			;FIRST WORD OF DATA

;CONNECTION STATES
.CSCLS==0			;CLOSED
.CSLSN==1			;LISTENING
.CSRFC==2			;RFC RECEIVED
.CSRFS==3			;RFC SENT
.CSOPN==4			;OPENED
.CSLOS==5			;LOS-ING
.CSINC==6			;INCOMPLETE TRANSMISSION (OTHER SIDE DEAD)
.CSPRF==7			;PERMANENTLY IN RFC-SENT STATE

;CONNECTION BLOCK
CONOFF==0			;UTILITY COUNTER
DEFINE CONENT (E,L) <		;;;DEFINE A CONNECTION ENTRY, LENGTH L
	E==CONOFF
   IFB <L>,<CONOFF==CONOFF+1>
   IFNB<L>,<CONOFF==CONOFF+<L>>
>

CONENT(CHASTA)			;0 FLAGS & NVT INDEX,,CONNECTION STATUS
 CF%STS==1B1			;NEED TO SEND STATUS SOON
 CF%IIN==1B2			;GENERATE INPUT INTERRUPT
 CF%OIN==1B3			;GENERATE OUTPUT INTERRUPT
 CF%DIN==1B4			;GENERATE DETACH INTERRUPT
 CF%CLS==1B5			;NEEDS TO BE CLOSED AT SOME CONVENIENT TIME
 CF%TTO==1B6			;THERE'S SOME TTY OUTPUT FOR THIS LINE
 CF%EOF==1B7			;AN EOF PACKET WAS SEEN ON INPUT
 DEFSTR(CHANVT,CHASTA,17,9)	;TTY NUMBER FOR NVT CONNECTION
CONENT(CHANBF)			;LENGTH(CHAPBF),,LENGTH(CHAIBF)
CONENT(CHANOS)			;NUMBER OF FREE OUTPUT SLOTS
CONENT(CHAIBF)			;RECEIVE BUFFER LIST - FIRST,,LAST
CONENT(CHAPBF)			;OUT OF ORDER BUFFERS LIST - FIRST,,LAST
CONENT(CHAOBF)			;OUTPUT BUFFER LIST - FIRST,,LAST
CONENT(CHAITM)			;TIME OF LAST INPUT FROM NETWORK
CONENT(CHAWIN)			;WINDOW SIZE - RECEIVE,,TRANSMIT
CONENT(CHAPKN)			;LAST PACKET RECEIVED,,LAST PACKET SENT
CONENT(CHAACK)			;LAST RECEIVE PACKET ACK'D,,LAST SENT ACK'D
CONENT(CHALCL)			;LOCAL HOST, LOCAL INDEX
 DEFSTR(CHALCH,CHALCL,15,16)	;LOCAL HOST
 DEFSTR(CHAIDX,CHALCL,31,16)	;LOCAL INDEX
  DEFSTR(CHALDX,CHALCL,31,10)	;LOCAL CHACON TABLE INDEX (" WITHOUT UNIQIZER)
CONENT(CHAFRN)			; FOREIGN HOST, FOREIGN INDEX
 DEFSTR(CHAHST,CHAFRN,15,16)	;FOREIGN HOST
CONENT(CHAFKC)			; VARIOUS
 DEFSTR(CHAFRK,CHAFKC,11,12)	;OWNING FORK INDEX
 DEFSTR(CHAOCN,CHAFKC,17,6)	;OUTPUT INTERRUPT CHANNEL
 DEFSTR(CHABSZ,CHAFKC,29,12)	;BYTE SIZE OF OPENF
 DEFSTR(CHAICN,CHAFKC,35,6)	;INPUT INTERRUPT CHANNEL
CONENT(CHATOV)			;TIMEOUT VALUES:
 DEFSTR(CHATRF,CHATOV,17,18)	; RFC WAIT TIME IN MS
CONENT(CHAOTM)			;TIME OF LAST SNDPKT START
IFN CHSDBG,<
CONENT(CHATTM)			;TIME OF LAST TTY MINISTRATION ATTEMPT
CONENT(CHATSM)			;TIME OF LAST SUCCESSFUL TTY MINISTRATION
CONENT(CONMAG)			;MAGIC WORD FOR VERIFYING THIS IS TRULY A CONN
CONENT(CONHST,^D5)		;HISTORY BYTES WHEN DEBUGGING
CONENT(CONHSP)			;BYTE REF TO NEXT HISTORY ENTRY (WRAPS AROUND)
				; (MUST BE RIGHT AFTER CONHST!)
>
CONSIZ==CONOFF			;TOTAL SIZE
PURGE CONOFF,CONENT		;GET RID OF THESE

>;IFN CHAOS,

;TS BLOCK ASSIGNMENTS

ifn kaflg!f3flg,<
uacb==psb+460		;more room in psb on ka, no overflow logic
>
ifn kiflg,<
uacb==psb+500		;less room in psb on ki, has overflow logic
>
EUACB==PSB+560		;END OF AC BLOCKS IN PSB
EPSB==PSB+1000		;END OF PSB + 1

ACBAS=PSB+570		;LOCATION OF AC'S FOR FORCED USER REFS
TRAPS0=PSB+571		;PAGER TRAP STATUS WORD
TRAPWD=PSB+572		;PAGER TRAP WRITE DATA
TRAPPC=PSB+573		;PAGER TRAP PC
TRAPAP=PSB+574		;PAGER TRAP AC-P
TRAPSW=PSB+575		;TRAP OLD STATUS WORD
UTRSW=PSB+576		;SAVED TRAPSW FOR USER
UTRWD=PSB+577		;SAVED TRAPWD FOR USER

DEFINE TTS (T,N)
<	IFB <N>,<ASSIGN T,TSBLOC,1>
	IFNB <N>,<ASSIGN T,TSBLOC,N>
>

DEFINE ETS (T,N)
<	EXTERN T
>

DEFINE TSMAC (TS)
<
TS JOBNO,1		;JOB NUMBER TO WHICH THIS FORK BELONGS
TS JOBBIT,1		;SCHEDULER CONTROL BITS
TS JOBCK0,1		;VARIABLES FOR SCHEDULER TIME QUARANTEE
TS JOBCK1,1		; ..

TS FKTAB,NLFKS/2	;LOCAL FORK HANDLE TO JOB HANDLE TABLE

TS FORKN,1		;JOB FORK NUMBER OF TOP FORK,,THIS FORK
TS FKRT,1		;FORK RUN TIME
TS ENTVEC,1		;ENTRY VECTOR POINTER
TS PATADR,1		;10/50 COMPATABILITY ENTRY VECTOR
TS PATU40,1		;WHERE TO STORE C(40), SETUP AS UMOVEM 1,XX
TS PATUPC,1		;WHERE TO STORE PC, SETUP AS UMOVEM 1,YY

TS MPP,1		;MONITOR SAVED STACK POINTER AT LAST MENTR
TS UPP,1		;MON ROUTINES STACK POINTER
TS SLOWF,1		;SLOW MON ROUTINE FLAG
TS XMENTR,1		;MENTR-MRETN TEMP
TS XMENT1,1		;MENTR TEMP
TS INTDF,1		;DEFER INTERRUPTS IF .GE. 0
TS INTDFF,1		;SOS INTDF  OR JSYS PSISV1
TS MJRSTF,1		;JRSTF @FPC  OR  JRST PSISV0
TS ACBAS1,1		;ACBAS FOR FIRST MON CALL

TS TW1,1		;DEBREAK TEMPS
TS TW2,1
TS ITFPC,1		;FPC AT LAST ITRAP
IFN KIFLG,<
TS KITMPS,2		;KI-10 MUUO HANDLER TEMPS
>
			;STORAGE FOR JSYS TRAP MECHANISM

JTBSIZ==^D15		;SIZE OF JSYS TRAP BIT TABLE IN WORDS

TS JTBTB,JTBSIZ		;BIT TABLE OF JSYS'S TRAPPED BY IMMED MON
TS JTLCK,1		;LOCK FOR TRAPS TO FORK
TS JTFPC,1		;SAVE FPC ON TRAPSI
TS JTTMP,1		;TEMP STORAGE FOR TRAPSI ROUTINE
TS JTTMP1,1		;TEMP STORAGE FOR SETRP ROUTINE
TS JTMNW,1		;JSYS TRAP MONITOR WORD:
			; B0: MONITOR FLAG. ON = A MONITOR
			; B3-B11: TEMP STORAGE FOR TRAPPED JSYS
			; B12-B17: MONITOR PSI CHANNEL, 77 MEANS
			;	DON'T PSI FORK ON TRAP
			; RH: JOB INDEX OF IMMED MON FORK
TS JTTRW,1		;JSYSTRAP TRAP WORD
			;LH - JOB INDEX OF TRAPPED FORK
			;RH - TRAPPED JSYS
TS JTJDA,1		;ADDR OF PAGE FOR MAPPING OTHER FORK'S DISP VECS

TS PAC,20		;PROCESS AC'S
TS PPC,1		;PROCESS PC
TS PSB40,1		;PROCESS LOCATION 40

IFN KAFLG!F3FLG,<
TS ENSKR,1>		;SCHEDULER TEMP (RETURN)
IFN KIFLG,<
TS ENSKR,2>		;CALL SCHED TEMP VIA JSR
TS SKDPC,1		;SCHEDULER TEMP (RETURN)
TS NSKED,1		;NO-SCHEDULE WORD
TS RSKED,1		;NO-SCHEDULE TRAP
TS NSWAP,1		;NO-SWAP FLAG

TS TRAPSK,NTSK		;STACK USED DURING PAGER TRAPS
TS PGTIM,1		;TIME SINCE AGE REG TICK
TS IFTIM,1		;TIME SINCE LAST PAGE FAULT
TS TRAPC,1		;PAGER TRAP RECURSION COUNT
TS UTRPCT,1		;COUNT OF PAGER TRAPS FOR THIS PROCESS
TS USWPCT,1		;COUNT OF SWPINW CALLS FOR THIS PROCESS
TS PTTIM,1		;TIME SPENT IN PAGER TRAPS
TS IFAV,1		;INTER-FAULT AVERAGE, CONTINUOUSLY MAINTAINED
TS CAPT,1		;WORKING SET WINDOW SIZE IN MS.
TS WSPGS,NWSPGS		;WORKING SET PAGES BIT TABLE
XWSPGS=<Z WSPGS-PSB+FITPGA>

TS MONBK,1		;INTERRUPT TO MONITOR IF NON-0
TS PIPC,1		;SAVED PC DURING INITIAL PI SERVICE
TS PIMSK,1		;PSI REQUEST WORD BEING PASSED TO PSI SERVICE
TS PIPDB,NPIPDL		;PSI ROUTINES STACK
TS PIAC,17		;SAVED USER AC'S DURING BREAK START
TS PIAC17,1		;SAVED USER AC17 .. ..

TS PSICHA,NTERMI/6	;CHANNEL ASSIGNED TO TERM CODE
TS PSIBW,1		;BREAK WAITING WORD
TS FORCTC,1		;CHANNEL WHICH CAUSED FORCED FORK TERMINATION
TS PSICHM,1		;CHANNEL ENABLED WORD
TS SUPCHN,1		;CHANNELS RESERVED BY SUPERIOR
TS PSIBIP,1		;BREAK IN PROGRESS WORD (LEVELS)
TS PSIPT,1		;PSI STORAGE LIST POINTER
TS PIOLDS,1		;FKSTAT PRIOR TO PSI IF WAS WAITING
TS LEVCHN,1		;LEVEL TABLE,,CHANNEL TABLE  ADDRESSES
TS PSISYS,1		;NON-0 IF PSI SYSTEM OFF
TS MONCHN,1		;CHANNELS RESERVED BY MONITOR
TS MONINT,1		;FOR DDT BREAKPOINTS
TS OVFLG,1		;NON-0 =) INITIATE INTERRUPTS ON MONITOR OV'S

TS UPDL,NUPDL		;PDL FOR MONITOR CALLS

TS FPC,1		;MENTR-MRETN JSYS PC
TS PGURET,1		;PLACE TO HOLD RETURN PC DURING PGUNTRP
IFN PIESLC,<
TS HIQCNT,1		;COUNT (-1) OF REQUESTS FOR HI QUEUEING
TS SPQCNT,1		;AS ABOVE FOR SPECIAL QUEUE
>
>
	TSMAC (ETS)		;DEFINE AS EXTERNAL ALWAYS

;JOB STORAGE BLOCK ASSIGNMENTS

DEFINE JJS (T,N)
<	IFB <N>,<ASSIGN T,JSBLOC,1>
	IFNB <N>,<ASSIGN T,JSBLOC,N>
>

DEFINE EJS (T,N)
<	EXTERN T
>

DEFINE JSMAC (JS)
<
JS JOBMAP,PPMPG-PJMPG	;OBJECT MAP FOR JOB-COMMON AREA

JS SYSFK,NUFKS		;FORK CTTY,,JOB FORK INDEX TO SYSTEM FORK INDEX
JS FKPTRS,NUFKS		;FORK POINTERS (STRUCTURE)
JS FKPSIE,NUFKS		;TERM INTERRUPT ENABLED WORD
JS FKDPSI,NUFKS		;DEFERRED TERM INTERRUPTS MASK
JS FREJFK,1		;FREE JOB FORK SLOT LIST

JS CTRLTT,1		;LINE NUMBER OF CONTROLLING TTY
JS TTSPSI,1		;CODE ENABLED ANYWHERE IN THIS JOB
JS TTSDPS,1		;TERM INT CODE DEFERRED
JS TTJTIW,1		;TERMINAL INTERRUPT ENABLE MASK
JS JOBPMF,1		;JFN OF PRIV MEM FILE
IFN KIFLG,<
JS PMFCNT,1>		;COUNT OF PMF PMAPS
JS CONSTO,1		;CONSOLE TIME ON
JS FLDTSL,1		; String length of file account default
JS FLDTPT,1		; Pointer to file account default
JS FLDTSR,11		; String space for file account default
JS ACCTPT,1		;ACCOUNT NUMBER+5B2 OR ACCOUNT STRING PTR
JS LOGBUF,17		;LOGIN-OUT EFACT DATA, MUST PRECEDE ACCTSR
JS ACCTSR,11		;ACCOUNT STRING
>
	JSMAC (ETS)		;DEFINE AS EXTERNAL ALWAYS

; Bit definitions in sts (also filsts)

FLG(OPNF,L,STS,400000)	; File is open
FLG(READF,L,STS,200000)	; File is ok to read
FLG(WRTF,L,STS,100000)	; File is ok to write
FLG(XCTF,L,STS,040000)	; File is ok to execute
FLG(RNDF,L,STS,020000)	; File is ok to reset pointer (i.e. not append)
FLG(ASPF,L,STS,010000)	; File is ok to access as specified in p.t.
FLG(CALLF,L,STS,004000)	; File is ok to call as a procedure
FLG(LONGF,L,STS,002000)	; File is a long file
FLG(EOFF,L,STS,001000)	; End of file if read attempted
FLG(ERRF,L,STS,000400)	; Bytes read may be erroneous
FLG(NAMEF,L,STS,000200)	; Name is associated with this jfn
FLG(ASTF,L,STS,000100)	; A * was typed in
FLG(ASGF,L,STS,000040)	; Jfn is being assigned
FLG(HLTF,L,STS,000020)	; Halt if i-o error
FLG(WNDF,L,STS,000010)	; A window page has been set up
FLG(ENDF,L,STS,000004)	; File is past end of maximum length
FLG(SIZF,L,STS,000002)	; Illegal to change size of byte
FLG(FRKF,L,STS,000001)	; File is restricted to fork in lh(filver)
; In flags

FLG(OUTPF,L,F,400000)	; Bit 0 for output use
FLG(NEWNF,L,F,200000)	; Bit 1 new file name only
FLG(OLDNF,L,F,100000)	; Bit 2 old file only
FLG(PONFF,L,F,040000)	; Bit 3 print "old file"/"new file" etc.
FLG(CFRMF,L,F,020000)	; Bit 4 confirmation required
FLG(TMPFF,L,F,010000)	; Bit 5 temporary file
FLG(RTYPF,L,F,004000)	; Bit 6 retype whole file name when complete
FLG(NACCF,L,F,002000)	; Bit 7 no access to other forks
FLG(IGDLF,L,F,001000)	; Bit 8 ignore deleted bit in files
FLG(JFNF,L,F,000400)	; Bit 9 use jfn given in e+11
FLG(JFNAF,L,F,000200)	; Bit 10 use alternate if jfn in e+11 na
FLG(ASTAF,L,F,000100)	; Asterisk allowed
FLG(OSTRF,L,F,000040)	; Output stars allowed
FLG(RLHFF,L,F,000020)	; RETURN LEFT HALF FLAGS
FLG(SCRF,L,F,000010)	; Make this file a scratch file
FLG(LLTBF,L,F,000004)	; In long GTJFN, have extended table
FLG(FILF,L,F,000002)	; If short form, 2 has xwd infile,outfile
FLG(SHTF,L,F,000001)	; Dummy bit to cause 1 to be taken as flags

; Flags in rh of f used by gtjfn

FLG(DEVF,R,F,400000)	; Device is specified
FLG(DIRF,R,F,200000)	; Directory specified
FLG(NAMF,R,F,100000)	; Name specified
FLG(EXTF,R,F,040000)	; Extension specified
FLG(VERF,R,F,020000)	; Version specified
FLG(PRTF,R,F,010000)	; Protection specified
FLG(ACTF,R,F,004000)	; Account specified
FLG(DEVTF,R,F,002000)	; Device was typed in
FLG(DIRTF,R,F,001000)	; Directory was typed in
FLG(NAMTF,R,F,000400)	; Name was typed in
FLG(EXTTF,R,F,000200)	; Extension was typed in
FLG(VERTF,R,F,000100)	; Version was typed in
FLG(ACTTF,R,F,000040)	; Account was typed in
FLG(PRTTF,R,F,000020)	; Protection was typed in
FLG(TMPTF,R,F,000010)	; Temporary flag was set by type in
FLG(SCRTF,R,F,000004)	; SCRATCH FLAG SET BY TYPE-IN
FLG(CNTVF,R,F,000002)	; Control-v typed
FLG(RSCNF,R,F,000001)	; Rescan input using retype buffer

; Flags in rh of sts used locally

FLG(MTCHF,R,F1,400000)	; Match seen during lookup ooerations
FLG(AMBGF,R,F1,200000)	; More than one match seen during operations
FLG(OCTF,R,F1,100000)	; Octal number is being collected
FLG(NEGF,R,F1,040000)	; Minus sign was typed
FLG(UNLKF,R,F1,020000)	; Used by directory to remember to unlock
FLG(STRF,R,F1,010000)	; String input exists
FLG(NREC,R,F1,004000)	; Don't perform recognition
FLG(NREC1,R,F1,002000)	; Used by lookup routines as for norec
FLG(DIRXF,R,F1,001000)	; Directory was stepped
FLG(NAMXF,R,F1,000400)	; Name was stepped
FLG(DIRFF,R,F1,000200)	; Directory is being specified
FLG(EXTFF,R,F1,000100)	; Extension is being specified
FLG(TSFF,R,F1,000040)	; Temp or Scratch is being specified
FLG(PRTFF,R,F1,000020)	; Protection is being specified
FLG(ACTFF,R,F1,000010)	; Account is being specified
FLG(NUMFF,R,F1,000004)	; Number is being collected
FLG(KEYFF,R,F1,000002)	; Looking for t, p, a

; Flags in lh of f1 (scan control)

FLG(NEWF,L,F1,400000)	; A new file name was created
FLG(NEWVF,L,F1,200000)	; A new version of an existing file was created
FLG(DIRSF,L,F1,100000)	; Scan directories <*>
FLG(NAMSF,L,F1,040000)	; Scan names (^*.)
FLG(EXTSF,L,F1,020000)	; Scan extensions (^.*)
FLG(VERSF,L,F1,010000)	; Scan versions (;*)
FLG(RVERF,L,F1,004000)	; Most recent version specified
FLG(HVERF,L,F1,002000)	; New version specified
FLG(LVERF,L,F1,001000)	; Lowest version specified
FLG(FXPRT,L,F1,000400)	; ;P SPECIFIED
FLG(FXACT,L,F1,000200)	; Account specified with *'s
FLG(FXTMP,L,F1,000100)	; ;t specified with *'s
FLG(EXTXF,L,F1,000040)	; Extension was stepped
FLG(NNAMF,L,F1,000020)	; No name device
FLG(NVERF,L,F1,000010)	; No versions etc.
FLG(DFSTF,L,F1,000004)	; * in default string
FLG(STARF,L,F1,000002)	; Set by *
FLG(STEPF,L,F1,000001)	; Step flag

; TOPS-20 compatible definitions
FLG(FILINP,R,STS,20000)		;DIRECTION OF I/O IS INPUT
FLG(FILOUP,R,STS,10000)		;DIRECTION OF I/O IS OUTPUT

MSKSTR(IOMODE,STS,17B35)	;MODE FILE IS OPENNED IN

; Device dispatch indices

TPC==0
USE TPC

DLUKD::!BLOCK 1		; Directory setup routine
NLUKD::!BLOCK 1		; Name lookup
ELUKD::!BLOCK 1		; Extension lookup
VLUKD::!BLOCK 1		; Version lookup
PLUKD::!BLOCK 1		; Protection insertion
ALUKD::!BLOCK 1		; Account insertion
SLUKD::!BLOCK 1		; Status insertion (temporary permanent etc)
OPEND::!BLOCK 1		; Open file
BIND::!	BLOCK 1		; Byte input
BOUTD::!BLOCK 1		; Byte output
CLOSD::!BLOCK 1		; Close file
REND::!	BLOCK 1		; Rename
DELD::!	BLOCK 1		; Delete file
DMPID::!BLOCK 1		; Dump mode input
DMPOD::!BLOCK 1		; Dump mode output
MNTD::!	BLOCK 1		; Mount device
DSMD::!	BLOCK 1		; Dismount device
INDD::!	BLOCK 1		; Initialize directory of device
MTPD::!	BLOCK 1		; Do mtape operation
GDSTD::!BLOCK 1		; Get device status
SDSTD::!BLOCK 		; Set device status

INTERN	DIRDSK,DIRLCK,DIRUSE,DDBMAX

; Variables in directory

DIRTPC==750000		; Directory origin
	USE	DIRTPC

DIRORG:	BLOCK 0		; Directory origin
DIRLCK:	BLOCK 1		; Directory lock
DIRUSE: BLOCK 1		; Directory use indicator
DIRNUM:	BLOCK 1		; Number of this directory
SYMBOT:	BLOCK 1		; Symbol table bottom
SYMTOP:	BLOCK 1		; Symbol table top
DIRFRE:	BLOCK 7		; Free storage header
FRETOP:	BLOCK 1		; Current top of free storage area
DIRDPW:	BLOCK 1		; Default file protection word
DIRPRT:	BLOCK 1		; Directory protection word
DIRDBK:	BLOCK 1		; Default backup specification
DIRGRP:	BLOCK 1		; Groups having access to this directory
DIRSAV:	BLOCK 1		; A place to put pointers to be gc'ed
DIRDSK:	BLOCK 1		; LH - max allocation this directory,
			; RH - current allocation
DIREXL:	BLOCK 1		; -1 PREVENTS EXPUNGE
SPARE:	BLOCK 1		; Locations for additional variables
DIRLOC:	BLOCK 1		; Temp used for saving location in the directory
DIRINP:	BLOCK 1		; Temp to save pointer to input for lookup
DIRINC:	BLOCK 1		; Temp to hold increment for searching
DIRMSK:	BLOCK 1		; Temp to hold mask for lookups
DIRSCN:	BLOCK 1		; Temp to save pointer to pointer
DIFREE:	BLOCK 0		; Beginning of free area

; Variables in subindex directory block 0

DIRHTO==DIRDPW		; Directory number hash table origin
DIRHTL==DIRPRT		; Directory number hash table length
FDADR==:DIRDBK		; Disc address of fd ib
; DEFINED LSTDNO
LSTDNO==DIRGRP		; LAST ASSIGNED DIRECTORY NUMBER

SBIDTB:	BLOCK <200+4>/5	; Directory subindex dispatch
ESBIDT:

; Parameters and bits pertinent to directories

	USE	TPC,0	; Pc to use to define fdb offsets

	BLOCK 1		; The header, not referenced symbolically
FDBCTL:!BLOCK 1		; Lh ==> control bits (see below)
			; Rh ==> location of file name block
FDBEXT:!BLOCK 1		; Lh ==> location of extension block
			; Rh ==> pointer to other extensions
FDBADR:!BLOCK 1		; The file address & class field
FDBPRT:!BLOCK 1		; File protection word
FDBCRE:!BLOCK 1		; Creation date & time of version 1
FDBUSE:!BLOCK 1		; Lh ==> last writer directory number
			; Rh ==> use count (+1 for each indirect pointer
			;  and saved environment)
FDBVER:!BLOCK 1		; Lh ==> version number
			;  this is job number for temp files
			; Rh ==> pointer to other versions
FDBACT:!BLOCK 1		; Account infor for charging
			;  + for location of string block
			;  - for number
FDBBYV:!BLOCK 1		; 0-5 ==> number of version to retain
			; 6-11 ==> last byte size
			; Rh ==> count of actual pages in file
FDBSIZ:!BLOCK 1		; Length of file in bytes
FDBCRV:!BLOCK 1		; Creation date and time of this version
FDBWRT:!BLOCK 1		; Date & time of last write
FDBREF:!BLOCK 1		; Date & time of last reference
FDBCNT:!BLOCK 1		; Lh ==> count of writes
			; Rh ==> count of references
FDBBCK:!BLOCK 5		; Words for backup system
FDBUSW:!BLOCK 1		; User settable word
FDBLEN:			; Length of fdb

; Bits in lh of fdbctl

FDBTMP==400000		; File is temporary
FDBPRM==200000		; File is permanent
FDBNEX==100000		; No extension for this fdb yet
			;  the file does not really exist
FDBDEL==040000		; File is deleted
FDBNXF==020000		; File does not exist (first write not complete)
FDBLNG==010000		; Long file
FDBSHT==004000		; Compressed page table
FDBBAT==002000		; FILE IS IN ERROR - BAT BIT
FDBSUB==001000		; Subroutine file
FDBUND==000400		; Undeletable file
FDBKEP==000002		; Autokeep file
FDBEPH==000001		; Ephemeral subsys file

; JFN STORAGE IN STORAG.MAC

EXTERNAL FILBYT,FILBYN,FILLEN,FILCNT,FILLCK,FILWND,FILSTS,FILDEV
EXTERNAL FILOFN,FILLFW,FILDDN,FILNEN,FILVER,FILTMP,FILPRT,FILACT
EXTERNAL FILOPT,FILDNW,FILEXW

EXTERNAL JFNLCK,MAXJFN,JOBUNT,JBCLCK,JBCOR,JSBFRE,JSFREE

; Symbols in directory descriptor block

	USE	TPC,0	; Pc to define offsets into ddb

	BLOCK 1		; Header not referenced symbollically
DDBNAM:!BLOCK 1		; Lh ==> pointer to password string block
			; Rh ==> pointer to name string block
DDBMAX:!BLOCK 1		; Maximum disk storage for this directory
DDBLOG:!BLOCK 1		; Time and date of last login
DDBPRV:!BLOCK 1		; Privilege bits
DDBMOD:!BLOCK 1		; Mode bits
DDBRES:!BLOCK 1		; Special resource information
DDBNUM:!BLOCK 1		; Lh ==> directory number
			; Rh ==> pointer to special information block
			; 0 means no special info
DDBDAT:!BLOCK 1		; Date and time of last login
DDBGRP:!BLOCK 1		; Groups to which this user belongs
DDBLEN:!

;JSYS DISPATCH TABLE, INITIALIZED TO ALL ILLEGAL

DEFINE JJD (N,A)
<	OPDEF N [JSYS A]
>

;THE FOLLOWING USED ONLY IN LDINIT

DEFINE LJD (N,A)
<	LOC 1000+JSYSLC
	IFL A-JSYSLC,<PRINTX JSYS'S MUST BE DEFINED IN ORDER>
	REPEAT A-JSYSLC,<XWD FPC,UJSYS>
	EXTERN .'N
	XWD FPC,.'N
JSYSLC==.-1000
	RELOC
>

DEFINE JDMAC (JD)
<
JD LOGIN,1
JD CRJOB,2
JD LGOUT,3
JD CACCT,4
JD EFACT,5
JD SMON,6
JD TMON,7
JD GETAB,10
JD ERSTR,11
JD GETER,12
JD GJINF,13
JD TIME,14
JD RUNTM,15
JD SYSGT,16
JD GNJFN,17
JD GTJFN,20
JD OPENF,21
JD CLOSF,22
JD RLJFN,23
JD GTSTS,24
JD STSTS,25
JD DELF,26
JD SFPTR,27
JD JFNS,30
JD FFFFP,31
JD RDDIR,32
REPEAT 0,<JD CPRTF,33>
JD CLZFF,34
JD RNAMF,35
JD SIZEF,36
JD GACTF,37

JD STDIR,40
JD DIRST,41
JD BKJFN,42
JD RFPTR,43
JD CNDIR,44
JD RFBSZ,45
JD SFBSZ,46
JD SWJFN,47
JD BIN,50
JD BOUT,51
JD SIN,52
JD SOUT,53
JD RIN,54
JD ROUT,55
JD PMAP,56
JD RPACS,57
JD SPACS,60
JD RMAP,61
JD SACTF,62
JD GTFDB,63
JD CHFDB,64
JD DUMPI,65
JD DUMPO,66
JD DELDF,67
JD ASND,70
JD RELD,71
REPEAT 0,<JD CSYNO,72>
JD PBIN,73
JD PBOUT,74
REPEAT 0,<JD PSIN,75>
JD PSOUT,76
JD MTOPR,77

JD CFIBF,100
JD CFOBF,101
JD SIBE,102
JD SOBE,103
JD DOBE,104
JD GTABS,105
JD STABS,106
JD RFMOD,107
JD SFMOD,110
JD RFPOS,111
JD RFCOC,112
JD SFCOC,113
JD STI,114
JD DTACH,115
JD ATACH,116
JD DVCHR,117
JD STDEV,120
JD DEVST,121
JD MOUNT,122
JD DSMNT,123
JD INIDR,124
JD SIR,125
JD EIR,126
JD SKPIR,127
JD DIR,130
JD AIC,131
JD IIC,132
JD DIC,133
JD RCM,134
JD RWM,135
JD DEBRK,136
JD ATI,137
JD DTI,140
JD CIS,141
JD SIRCM,142
JD RIRCM,143
JD RIR,144
JD GDSTS,145
JD SDSTS,146
JD RESET,147

JD RPCAP,150
JD EPCAP,151
JD CFORK,152
JD KFORK,153
JD FFORK,154
JD RFORK,155
JD RFSTS,156
JD SFORK,157
JD SFACS,160
JD RFACS,161
JD HFORK,162
JD WFORK,163
JD GFRKH,164
JD RFRKH,165
REPEAT 0,<JD GFRKS,166>
JD GFRKS,166		;***SRI-AIC***
JD DISMS,167
JD HALTF,170
JD GTRPW,171
JD GTRPI,172
JD RTIW,173
JD STIW,174
JD SOBF,175
JD RWSET,176
JD GETNM,177

JD GET,200
JD SFRKV,201
JD SAVE,202
JD SSAVE,203
JD SEVEC,204
JD GEVEC,205
JD GPJFN,206
JD SPJFN,207
JD SETNM,210
JD FFUFP,211
JD DIBE,212
JD FDFRE,213
JD GDSKC,214
JD LITES,215
JD TLINK,216
JD STPAR,217

JD ODTIM,220
JD IDTIM,221
JD ODCNV,222
JD IDCNV,223
JD NOUT,224
JD NIN,225
JD STAD,226
JD GTAD,227
JD ODTNC,230
JD IDTNC,231
JD FLIN,232
JD FLOUT,233
JD DFIN,234
JD DFOUT,235

JD CRDIR,240
JD GTDIR,241
JD DSKOP,242
JD SPRIW,243
JD DSKAS,244
JD SJPRI,245
JD STO,246

IFDEF DSPCHN,<
JD ASNDP,260		; E&S JSYS'S
JD RELDP,261
JD ASNDC,262
JD RELDC,263
JD STRDP,264
JD STPDP,265
JD STSDP,266
JD RDSDP,267
JD WATDP,270
>

IFDEF IMPCHN,<
; 271 unused
JD GTNCP,272
JD GTHST,273
>

IFG NNVTLN,<
JD ATPTY,274
>

IFDEF IMPCHN,<
JD CVSKT,275
JD CVHST,276
JD FLHST,277
>

;GET CVHST IF ON GATEWAY FOONLY

IFNDEF IMPCHN,<IFN F3FLG,<JD CVHST,276>>


JD GCVEC,300
JD SCVEC,301
JD STTYP,302
JD GTTYP,303
JD BPT,304
JD GTDAL,305
JD WAIT,306
JD HSYS,307
JD USRIO,310
JD PEEK,311
JD MSFRK,312
JD ESOUT,313
JD SPLFK,314
JD ADVIZ,315
JD JOBTM,316
JD DELNF,317
JD SWTCH,320
JD TFORK,321
JD RTFRK,322
JD UTFRK,323
JD SCTTY,324
JD CFGRP,325
JD OPRFN,326
JD CGRP,327
JD VACCT,330
JD GDACC,331
JD ATGRP,332
JD GACTJ,333
JD GPSGN,334

JD GFACC,335
JD SETER,336

;		DEFINITIONNS FOR PSEUDO-TTY BATCH  ***SRI-AIC***
JD ASPTY,360
JD RLPTY,361
JD PSTI,362
JD PSTO,363
JD SIBF,364		;SUMEX SIBF JSYS
JD CPUTL,444
;		END ***SRI-AIC***
;DEFS FOR I4-TENEX
;NOTE THESE NUMBERS ARE NOT IN 400 GROUP WHICH IS RESERVED FOR NON-BBN
; FIELD USE. - THEY MAY GET BUMPED BY BBN DEF'S
;
IFDEF I4SW,<IFN I4SW,<
JD LKPG,340
JD XCM,341
JD BLKPM,343
JD WAKUP,344
JD LD11P,345
JU UJFNO,346
JD BLKMC,347
JD AQMMP,351
JD SMMPT,352
JD RMMPR,353
JD SMMPR,354
JD SMMPI,355
JD RLMMP,356
JD DRMOP,357
JD ASPTY,360
JD RLPTY,361
JD PSTI,362
JD PSTO,363
JD SIBF,364
JD SRUBA,365
JD INTLK,366
JD PARRD,600
JD PARST,601
>>
;DEFS FOR STANFORD RESEARCH INSTITUTE - AUGMENTATION RESEARCH CENTER
IFDEF SRIARC,<
JD SJBST,401
JD RJBST,402
JD GTPSW,415
JD CHKAC,416
JD FLGIN,431
JD TSTFG,432
JD SETFG,433
JD RSTFG,434
> ;END OF SRI-ARC DEFS
;
;NOTE::::: THE GROUP OF JSYS'S FROM 500 - 577 ARE RESERVED FOR DEC BY
;	   AGREEMENT BETWEEN DEC AND BBN
;

JD GETJI,507
JD SNOOP,516
JD SFPOS,526
JD RFTAD,533
JD SFTAD,534
JD TBDEL,535
JD TBADD,536
JD TBLUK,537
JD STCMP,540
JD GFUST,550
JD SFUST,551
JD RCDIR,553
JD RCUSR,554

;TEMPORARY DEF'S

;DEFS FOR STANFORD RESEARCH INSTITUTE ARTIFICAL INTELLEGENCE CENTER.

JD DELCH,625		;DELETE CHARACTER FROM DISPLAY
JD IIT,630
JD GTBLT,634		;BLT TABLE TO USER SPACE (SAME NUMBER AS SUMEX)

;the following jsys's are for tymnet and are located in tymsrv
jd tymop,640		;WHAT WE WERE RUNNING
jd tymli,641
jd tymbr,642
jd tymbw,643

jd tymbw,651
jd tymbr,652
jd tymli,653
JD TYMOP,654		;WHAT SUMEX RUNS AND SHOULD BE USED

IFDEF SIGIPC,<
JD GTSIG,730
JD RLSIG,731
JD WTFOR,732
JD SIGNL,733
>

ifdef	tcp,	<
jd forkx,747
		>

IFDEF IMPCHN,<
JD SNDIM,750
JD RCVIM,751
JD ASNSQ,752
JD RELSQ,753
>

	REPEAT	0,<
JD TNDBG,757		; FOR TELENET CODE
	>		;END REPEAT 0
IFDEF RTISW,<
JD SOLO,760
JD TUTTI,761
JD USEC,763
>

	REPEAT 0,<
IFDEF IMPCHN,<
JD DBGIM,766>
	>		;END REPEAT 0 FOR SRI-AI

IFDEF DIALLN,<
JD TDIAL,767>

JD CADSK,770		;***SRI-AIC***
JD MRPAC,772
JD DSKCV,774
JD TTMSG,775
JD EXEC,777
>
	JDMAC (JJD)		;OPDEF ALL

	ORG	0
	.END

