Google
 

Trailing-Edge - PDP-10 Archives - saio_sources - 5sources/prolog.mac
There are 56 other files named prolog.mac in the archive. Click here to see a list.
;<SMITH.TMP>PROLOG.MAC.4260	16-Dec-82 22:43:38	Edit by SMITH
;#426	See edit 100,
;
;#112	Obsolesced
;
;#151	Fix DSKNB to avoid disc address overflow
;
;#150	Fix MAXSC0 to limit number of indirect pointers
;
;[105]<DEC-SCHED-MONITOR>PROLOG.MAC.3, 17-Mar-82 13:15:03, Ed: EONEIL
;Deleted DEC sheduler defs
;<BBN-4-MONITOR>PROLOG.MAC.208, 25-Aug-81 11:15:29, Edit by TAPPAN
; 100: Added CHAOSNet stuff
;<MULTINET-MONITOR>PROLOG.MAC.3, 12-Nov-80 13:12:53, Edit by TAPPAN
; REMOVE TELENET LINE TYPE
;[BBN-TENEXD]<MERGED-UTILITIES>PROLOG.MAC.2, 28-Jul-80 11:12:25, Ed: RBASCH
; MERGED DEC ORIGINAL W/ BBN AND DEC CHANGES, REMOVED CONDITIONAL
; ASSEMBLY REFERENCES TO %%MODS AND %%BASE, REMOVED MULTIPLE DEFINITION
; OF FKWTL THAT PRODUCED ASSEMBLY ERROR; THE REMOVED LINE WAS:
; DEFSTR FKWTL,FKQ2(FX),35,18		;WAITLIST ADR FOR BLOCKED FORK
; IT OCCURRED 10 LINES ABOVE THE CURRENT DEFINITION OF FKWTL.
;[BBNF]<TCP-BBN-4-MONITOR>PROLOG.MAC.205,  6-May-80 16:10:42, Ed: PLUMMER
; TVT Line type
;[BBN-TENEXG]<4-ALLEN>PROLOG.MAC.11, 20-Jan-80 11:08:34, Ed: ALLEN
; DEFINE MULTOP FLAG IN SPTH -- INDICATES MULTIPLY OPEN FILE
; ADDX

;<4-ALLEN>PROLOG.MAC.10, 14-Jan-80 12:46:04, Edit by TAPPAN
; ADDED MACRO DEFINITION OF ERCAL
;[BBN-TENEXD]<BBN-4-MONITOR>PROLOG.MAC.202, 12-Oct-79 16:47:52, Ed: EONEIL
;REMOVED LAST EDIT--EPHEMERAL HANDLED NOW BY FILE CLASS FIELD
;[BBN-TENEXD]<BBN-4-MONITOR>PROLOG.MAC.201, 12-Sep-79 22:09:04, Ed: EONEIL
;ADDED FBEPH DEF FOR EPHEMERAL BIT IN FDB
; UPD ID= 520, SNARK:<5.MONITOR>PROLOG.MAC.63,   8-Mar-82 16:12:43 by PAETZOLD
;Turn off DEBUG
; UPD ID= 428, SNARK:<5.MONITOR>PROLOG.MAC.62,  21-Jan-82 17:14:35 by GRANT
;Turn on RESHSW
; UPD ID= 401, SNARK:<5.MONITOR>PROLOG.MAC.61,  15-Jan-82 15:20:24 by GRANT
;TCO 5.1679 - change LOKK macro to store FORKX on fast lock
; UPD ID= 396, SNARK:<5.MONITOR>PROLOG.MAC.60,  13-Jan-82 16:58:35 by GRANT
;Turn on DTESW
; UPD ID= 375, SNARK:<5.MONITOR>PROLOG.MAC.59,   5-Jan-82 09:04:26 by GRANT
;TCO 5.1649 - Add NSPNUL
; UPD ID= 351, SNARK:<5.MONITOR>PROLOG.MAC.58,  10-Dec-81 09:23:20 by GRANT
;Turn off all debug switches
; UPD ID= 305, SNARK:<5.MONITOR>PROLOG.MAC.57,   2-Nov-81 15:40:33 by GRANT
;Turn on master debug switch
; UPD ID= 298, SNARK:<5.MONITOR>PROLOG.MAC.56,  28-Oct-81 10:23:00 by PAETZOLD
;More TCO 5.1596
; UPD ID= 295, SNARK:<5.MONITOR>PROLOG.MAC.55,  25-Oct-81 13:00:23 by PAETZOLD
;TCO 5.1596 - Put DEBUG switch stuff under NDG's
; UPD ID= 241, SNARK:<5.MONITOR>PROLOG.MAC.54,   4-Oct-81 23:44:22 by PAETZOLD
;TCO 5.1554 - ADD SPTDSW DEBUGINGG SWITCH
; UPD ID= 63, SNARK:<5.MONITOR>PROLOG.MAC.53,  22-Jul-81 17:27:26 by MURPHY
; UPD ID= 59, SNARK:<5.MONITOR>PROLOG.MAC.52,  22-Jul-81 11:23:23 by MURPHY
;TCO 5.1428 - BSOVRD IN FKSWP
; UPD ID= 7, SNARK:<5.MONITOR>PROLOG.MAC.51,   9-Jul-81 17:12:35 by MURPHY
;TCO 5.1396 - BSSPQ IN FKSWP
; UPD ID= 2294, SNARK:<5.MONITOR>PROLOG.MAC.50,   6-Jul-81 13:50:45 by MURPHY
;DEBUG SWITCH CZQDBG
; UPD ID= 2262, SNARK:<5.MONITOR>PROLOG.MAC.49,  26-Jun-81 18:06:39 by MURPHY
;Make NOSKED/OKSKED equivalent to NOSKD1/OKSKD1, same for CSKED, etc.
; UPD ID= 2162, SNARK:<5.MONITOR>PROLOG.MAC.48,  10-Jun-81 08:21:57 by GRANT
;More of previous edit
; UPD ID= 2157, SNARK:<5.MONITOR>PROLOG.MAC.47,   9-Jun-81 14:49:15 by GRANT
;Change all SLOW locks to FAST
; UPD ID= 1787, SNARK:<5.MONITOR>PROLOG.MAC.46,   5-Apr-81 14:46:42 by GRANT
;Add DN20SW - debugging switch for a 2nd DN20
; UPD ID= 1755, SNARK:<5.MONITOR>PROLOG.MAC.45,  23-Mar-81 16:28:56 by MURPHY
;Change BUGCHK and BUGINF calls to PUSHJ
; UPD ID= 1724, SNARK:<5.MONITOR>PROLOG.MAC.44,  17-Mar-81 08:54:02 by GRANT
;Turn on RESBSW
; UPD ID= 1669, SNARK:<5.MONITOR>PROLOG.MAC.43,  11-Mar-81 17:13:48 by MURPHY
;MOVE ENTSKD TO SCHED
; UPD ID= 1612, SNARK:<5.MONITOR>PROLOG.MAC.41,  27-Feb-81 18:27:09 by MURPHY
;EA.ENT, S0.ENT
; UPD ID= 1604, SNARK:<5.MONITOR>PROLOG.MAC.40,  27-Feb-81 09:53:56 by FLEMMING
;TCO 5.1265 - define a mask for page/section pointer access bits
; UPD ID= 1590, SNARK:<5.MONITOR>PROLOG.MAC.39,  26-Feb-81 17:41:58 by MURPHY
;BUG(NULL)
; UPD ID= 1558, SNARK:<5.MONITOR>PROLOG.MAC.38,  13-Feb-81 15:54:41 by MURPHY
;MORE OF%RDU
; UPD ID= 1540, SNARK:<5.MONITOR>PROLOG.MAC.37,   9-Feb-81 13:03:54 by HALL
;TYPO IN PREVIOUS EDIT
; UPD ID= 1538, SNARK:<5.MONITOR>PROLOG.MAC.36,   9-Feb-81 12:53:44 by HALL
;TCO 5.1180 - ADD SEC0SW DEBUGGING SWITCH
; UPD ID= 1537, SNARK:<5.MONITOR>PROLOG.MAC.35,   9-Feb-81 12:24:15 by MURPHY
;SUPPORT FOR OF%RDU
; UPD ID= 1491, SNARK:<5.MONITOR>PROLOG.MAC.34,  26-Jan-81 11:56:18 by MURPHY
;PUT SALL BACK IN TTITLE
; UPD ID= 1484, SNARK:<5.MONITOR>PROLOG.MAC.33,  24-Jan-81 22:39:18 by GRANT
; UPD ID= 1483, SNARK:<5.MONITOR>PROLOG.MAC.32,  24-Jan-81 22:22:07 by GRANT
;REMOVE RESFSW AND ADD RESBSW AND RESHSW
; UPD ID= 1476, SNARK:<5.MONITOR>PROLOG.MAC.31,  22-Jan-81 12:19:39 by MURPHY
;MOVE BLCALL AND FRIENDS TO MACSYM
; UPD ID= 1462, SNARK:<5.MONITOR>PROLOG.MAC.29,  21-Jan-81 11:06:52 by GRANT
;TCO 5.1230 - ADD DEBUGGING SWITCHES
; UPD ID= 1460, SNARK:<5.MONITOR>PROLOG.MAC.28,  20-Jan-81 17:36:54 by MURPHY
;FIX BLCALL, BLSUBR
; UPD ID= 1227, SNARK:<5.MONITOR>PROLOG.MAC.27,   4-Nov-80 11:27:18 by GRANT
;TCO 5.1188 - EXPAND RESIDENT FREE SPACE HEADER, CREATE TRAILER
; UPD ID= 1180, SNARK:<5.MONITOR>PROLOG.MAC.26,  20-Oct-80 17:58:26 by MURPHY
;BLCALL, BLSUBR MACROS
; UPD ID= 1094, SNARK:<5.MONITOR>PROLOG.MAC.25,   1-Oct-80 15:46:06 by MURPHY
;DITTO
; UPD ID= 1076, SNARK:<5.MONITOR>PROLOG.MAC.24,   1-Oct-80 10:37:29 by MURPHY
;FANCIER SAVEAC MACRO
;REMOVE REPEAT 0 AROUND STKFLG AND STKPC
;<5.MONITOR>PROLOG.MAC.23, 18-Sep-80 16:28:33, EDIT BY ENGEL
;GET RID OF LOKGNM
; UPD ID= 969, SNARK:<5.MONITOR>PROLOG.MAC.22,  25-Aug-80 16:30:19 by ENGEL
;TCO 5.1136 - ADD DEVLKK
; UPD ID= 950, SNARK:<5.MONITOR>PROLOG.MAC.21,  22-Aug-80 15:52:54 by ENGEL
; UPD ID= 949, SNARK:<5.MONITOR>PROLOG.MAC.19,  22-Aug-80 15:50:59 by ENGEL
;FIX LOCK BUG
; UPD ID= 937, SNARK:<5.MONITOR>PROLOG.MAC.17,  20-Aug-80 15:16:15 by ENGEL
;TCO #5.1136 - CHANGE ALL LOCKS TO CONFORM TO THE NEW LOCK SCHEME
; UPD ID= 887, SNARK:<5.MONITOR>PROLOG.MAC.16,  13-Aug-80 13:38:56 by ENGEL
; UPD ID= 885, SNARK:<5.MONITOR>PROLOG.MAC.15,  13-Aug-80 13:34:23 by ENGEL
;ADD THE BASIC LOCKING MACRO'S
; UPD ID= 881, SNARK:<5.MONITOR>PROLOG.MAC.14,  12-Aug-80 18:56:00 by MURPHY
;TTITLE
; UPD ID= 798, SNARK:<5.MONITOR>PROLOG.MAC.13,  24-Jul-80 15:03:03 by LYONS
;TCO 5.1062  move MI%ASG and other bits in HOMFLG over to prevent overlap
;with MS%??? bits of the MSTR% JSYS
; UPD ID= 784, SNARK:<5.MONITOR>PROLOG.MAC.12,  23-Jul-80 11:49:16 by HALL
;ADD COMMENTS TO RSI MACRO DEFINITION
; UPD ID= 763, SNARK:<5.MONITOR>PROLOG.MAC.11,  18-Jul-80 15:20:40 by MURPHY
;Add DEFSTR for JBTTY and JBTFK in JOBPT
; UPD ID= 716, SNARK:<5.MONITOR>PROLOG.MAC.10,   1-Jul-80 09:44:51 by HALL
;IN RESIDENT FREE SPACE, REMOVE RSREL, MAKE POOL NUMBER BE 18 BITS
; UPD ID= 680, SNARK:<5.MONITOR>PROLOG.MAC.9,  19-Jun-80 22:11:36 by MURPHY
;BUG macro again
; UPD ID= 676, SNARK:<5.MONITOR>PROLOG.MAC.8,  18-Jun-80 22:36:24 by MURPHY
;Clean up listing output from BUG macro a bit.
; UPD ID= 651, SNARK:<5.MONITOR>PROLOG.MAC.7,  16-Jun-80 15:55:18 by MURPHY
;IMPROVE COMMENTS ON SE1CAL, ETC.
; UPD ID= 561, SNARK:<5.MONITOR>PROLOG.MAC.6,  27-May-80 15:05:50 by ENGEL
;ADD LCSDTE
; UPD ID= 559, SNARK:<5.MONITOR>PROLOG.MAC.5,  27-May-80 13:05:07 by ENGEL
; UPD ID= 507, SNARK:<5.MONITOR>PROLOG.MAC.4,   5-May-80 14:32:12 by ENGEL
;ADD ICCS DEFNITIONS
; UPD ID= 438, SNARK:<5.MONITOR>PROLOG.MAC.3,  13-Apr-80 15:13:34 by OSMAN
;Add FRKTTY
; UPD ID= 422, SNARK:<5.MONITOR>PROLOG.MAC.2,  11-Apr-80 13:51:28 by HALL
;ADD DEFINITION OF RSI MACRO FOR RESIDENT DATA THAT ISN'T ZEROED
; UPD ID= 334, SNARK:<4.1.MONITOR>PROLOG.MAC.127,  14-Mar-80 11:16:30 by OSMAN
;tco 4.1.1110 - Prevent false alphabetical order warning in DEFBUG
; UPD ID= 284, SNARK:<4.1.MONITOR>PROLOG.MAC.126,  20-Feb-80 17:55:44 by MURPHY
;CHANGE NAME OF FIELD TO FKMNQ
; UPD ID= 80, SNARK:<4.1.MONITOR>PROLOG.MAC.125,   3-Dec-79 10:52:11 by OSMAN
;Add alphabetical order checking for bugs
;<4.1.MONITOR>PROLOG.MAC.124, 12-Nov-79 16:30:03, EDIT BY OSMAN
;tco 4.1.1017 - Search MACSYM before MONSYM
;<4.1.MONITOR>PROLOG.MAC.123,  8-Nov-79 17:35:04, EDIT BY MURPHY
;CHANGE DEF OF CHKINT
;<4.MONITOR>PROLOG.MAC.122, 24-Oct-79 11:47:52, EDIT BY MURPHY
;TRPIRF
;<4.MONITOR>PROLOG.MAC.121,  4-Oct-79 14:20:43, EDIT BY OSMAN
;ADD FROSTF
;<4.MONITOR>PROLOG.MAC.120,  2-Oct-79 16:04:28, EDIT BY MILLER
;ONE MORE FIX TO GTOKM. HANDLE DENY DEFAULT ASAP
;<4.MONITOR>PROLOG.MAC.119,  2-Oct-79 15:30:38, EDIT BY MILLER
;CHANGE GTOKM DEFINITION TO CHECK FOR DEFAULT ACTION BEFORE CALLING
; KERNEL ROUTINE.
;<4.MONITOR>PROLOG.MAC.118, 28-Sep-79 17:58:03, EDIT BY HELLIWELL
;ADD PSUTPS BIT IN PSBITS
;<4.MONITOR>PROLOG.MAC.117, 26-Sep-79 11:55:09, EDIT BY MURPHY
;MAKE BUGS.MAC ASSEMBLE AS PART OF PROLOG
;<4.MONITOR>PROLOG.MAC.116, 26-Sep-79 11:25:27, EDIT BY MURPHY
;ONCE MORE ON CALL, CALLRET, ETC.
;<4.MONITOR>PROLOG.MAC.115, 26-Sep-79 08:36:23, EDIT BY R.ACE
;FIX DEF OF CALLRET TO HAVE AN ARGUMENT
;<4.MONITOR>PROLOG.MAC.114, 25-Sep-79 18:11:41, EDIT BY MILLER
;FIX DEF OF CALL MACRO TO HAVE AN ARGUMENT
;<4.MONITOR>PROLOG.MAC.113, 25-Sep-79 13:31:28, EDIT BY MURPHY
;PUT NOINT, ETC. BACK AS MACROS
;<4.MONITOR>PROLOG.MAC.112, 14-Sep-79 10:50:05, EDIT BY R.ACE
;ADD HACK IN DEFBUG MACRO TO CIRCUMVENT PROBLEM IN MACRO 53A
;SHOULD BE REMOVED WHEN WE GET TO MACRO 53B
;<4.MONITOR>PROLOG.MAC.111, 12-Sep-79 15:51:21, EDIT BY HALL
;DEFINE MASK FOR PREVIOUS CONTEXT SECTION RETURNED BY XSFM
;<4.MONITOR>PROLOG.MAC.109,  6-Sep-79 08:57:35, EDIT BY OSMAN
;Add "Macros for defining BUGs"
;<4.MONITOR>PROLOG.MAC.108, 19-Aug-79 18:20:53, EDIT BY GILBERT
;Change FKIBSH to FKIBH to avoid conflict with FKIBS.
;Change NOINT, RETSKP, etc. from MACROs to OPDEFS for DDT typeout.
;Assemble both passes so PROLOG can use EXTERNs defined in GGLOBS.
;<4.MONITOR>PROLOG.MAC.107, 12-Jul-79 13:43:15, EDIT BY MURPHY
;ADD XGAGE
;<4.MONITOR>PROLOG.MAC.106, 12-Jul-79 06:56:12, EDIT BY HALL
;ADD FIELDS FOR NEW FORM OF SIR JSYS
;<4.MONITOR>PROLOG.MAC.105, 26-Jun-79 15:08:00, EDIT BY HALL
;TYPO IN PSXSIR DEFINITION
;<4.MONITOR>PROLOG.MAC.104, 26-Jun-79 11:33:21, EDIT BY DBELL
;TCO 4.2311 - DEFINE NOLOGF FOR GTJFN
;<4.MONITOR>PROLOG.MAC.103, 26-Jun-79 10:32:43, EDIT BY HALL
;MOVE PSXSIR TO PSBITS
;<4.MONITOR>PROLOG.MAC.102, 26-Jun-79 10:15:37, EDIT BY HALL
;ADD PSXSIR TO JOBBIT
;<4.MONITOR>PROLOG.MAC.101, 14-Jun-79 16:24:23, EDIT BY HALL
;FOR ATS, ADD APNIR TO DATA PIPE
;<4.MONITOR>PROLOG.MAC.100, 14-Jun-79 16:02:06, EDIT BY KIRSCHEN
;ADD NSPX6
;<4.MONITOR>PROLOG.NEW.1,  6-Jun-79 09:18:06, EDIT BY OSMAN
;ADD ACRLFF, CRNXT, LFNXT - remove eol in DTBDSP definition
; so it can be used in expressions.
;<4.MONITOR>PROLOG.MAC.98, 30-May-79 11:17:15, EDIT BY DBELL
;TCO 4.2262 - DEFINE THE FLAG GNJFF
;<4.MONITOR>PROLOG.MAC.97, 24-Apr-79 14:21:34, Edit by MCLEAN
;<4.MONITOR>PROLOG.MAC.96,  9-Apr-79 14:00:34, EDIT BY BOSACK
;FLUSH EXTRA PHYCHN DEFN
;<4.MONITOR>PROLOG.MAC.95,  9-Apr-79 12:16:52, Edit by MCLEAN
;FIX ..GOKN COUNT
;<4.MONITOR>PROLOG.MAC.94,  5-Apr-79 12:00:16, Edit by MCLEAN
;<4.MONITOR>PROLOG.MAC.93,  5-Apr-79 11:04:53, Edit by MCLEAN
;MAKE FIRST ARG TO IN CALL TO GETOKM BE 0
;<4.MONITOR>PROLOG.MAC.92,  1-Apr-79 13:31:21, EDIT BY MILLER
;DEFINE PIBMP
;<4.MONITOR>PROLOG.MAC.91,  6-Mar-79 10:04:55, EDIT BY KONEN
;UPDATE COPYRIGHT FOR RELEASE 4
;<4.MONITOR>PROLOG.MAC.90, 13-Feb-79 08:26:50, EDIT BY ENGEL
;ADD .NSMQI AND .NSMQO - VALUES FOR MAXIMUM MESSAGES TO QUEUE ON LINK
;<4.MONITOR>PROLOG.MAC.89, 26-Jan-79 12:18:18, EDIT BY HALL
;TCO 4.2174 - MAKE THE BUG MACRO IGNORE MORE THAN 4 OPTIONAL DATA AC'S
;<4.MONITOR>PROLOG.MAC.88, 20-Jan-79 14:17:01, EDIT BY MILLER
;ADD RECF DEFINITION TO STS
;<4.MONITOR>PROLOG.MAC.87, 17-Jan-79 12:42:16, EDIT BY HALL
;TCO 4.2166 - DEFINE DEFSTRS FOR A BLOCK OF RESIDENT FREE SPACE
;<4.MONITOR>PROLOG.MAC.86, 17-Jan-79 11:41:06, EDIT BY HALL
;TCO 4.2166 - ADD RS%REL FOR RESIDENT FREE SPACE
;<4.MONITOR>PROLOG.MAC.85, 17-Jan-79 11:31:35, EDIT BY MURPHY
;MAKE AC DEFS GLOBAL
;<4.MONITOR>PROLOG.MAC.84, 15-Jan-79 21:39:00, EDIT BY GILBERT
;FIX EDIT SKEW PROBLEM BETWEEN GILBERT, HALL, AND KONEN.
;<4.MONITOR>PROLOG.MAC.83, 15-Jan-79 14:01:40, Edit by KONEN
;ADD PSB FIELDS RELATED TO STRUCTURES
;<4.MONITOR>PROLOG.MAC.82, 15-Jan-79 07:48:32, EDIT BY GILBERT
;More TCO 4.2155:
;	Change SYTBL to SYVAR.
;	Suppress created symbols in BUG macro.
;<4.MONITOR>PROLOG.MAC.81, 14-Jan-79 13:07:28, EDIT BY HALL
;TYPO IN PREVIOUS EDIT
;<4.MONITOR>PROLOG.MAC.80, 11-Jan-79 15:49:00, EDIT BY HALL
;TCO 4.1900 - ADD APOBS TO DATA PIPE DEFINITION
;<4.MONITOR>PROLOG.MAC.79,  9-Jan-79 17:21:54, EDIT BY MILLER
;DEFINE TIMBSZ TO BE 4 WORDS. DON'T USE HEADER
;<4.MONITOR>PROLOG.MAC.78,  8-Jan-79 06:57:16, EDIT BY GILBERT
;TCO 4.2155 - Implement hidden symbol tables:
;	Define the ST macro to allocate storage in the SYTBL PSECT.
;<MURPHY.MON>PROLOG.MAC.2,  3-Jan-79 17:08:25, EDIT BY MURPHY
;FKBSP
;<4.MONITOR>PROLOG.MAC.76,  5-Jan-79 11:08:28, EDIT BY HALL
;TCO 4.1900 - ADD TO DATA PIPE DATA A WORD FOR REASON FOR CONNECT-REJECT
;<4.MONITOR>PROLOG.MAC.75,  4-Jan-79 17:14:52, EDIT BY HALL
;TCO 4.1900 - ADD ATNDP AND MOVE STATUS REPORT CODES TO NRMSRV
;<4.MONITOR>PROLOG.MAC.74, 29-Dec-78 12:19:09, EDIT BY MURPHY
;REMOVE PUFLD
;<4.MONITOR>PROLOG.MAC.70,  8-Dec-78 17:30:59, EDIT BY MILLER
;<4.MONITOR>PROLOG.MAC.69,  8-Dec-78 17:29:35, EDIT BY MILLER
;<4.MONITOR>PROLOG.MAC.68,  8-Dec-78 17:20:36, EDIT BY MILLER
;ADD HLDF FLAG TO STS
;<4.MONITOR>PROLOG.MAC.67,  7-Dec-78 14:30:02, EDIT BY MURPHY
;NEW SWAP LOGIC
;<4.MONITOR>PROLOG.MAC.66, 28-Nov-78 16:20:25, EDIT BY HALL
;tco 1900 - rearrange ats defstrs
;<4.MONITOR>PROLOG.MAC.65,  3-Nov-78 17:08:02, EDIT BY MURPHY
;FIX ENTSKD ANCIENT BUG
;<4.MONITOR>PROLOG.MAC.64, 26-Oct-78 10:56:57, EDIT BY OSMAN
;WPN, CPN
;<ARC-DEC>PROLOG.MAC.3, 21-Aug-78 10:12:26, EDIT BY CALVIN
; Add slots for default online and offline expiration date/intervals
; for the directory
;<CALVIN>PROLOG.MAC.2, 15-Aug-78 08:18:26, EDIT BY CALVIN
; Added archive system-related definitions
;<4.MONITOR>PROLOG.MAC.61, 17-Oct-78 13:46:08, EDIT BY MILLER
;ADD ANOTHER ARG TO GTOKM MACRO
;<4.MONITOR>PROLOG.MAC.60, 17-Oct-78 10:52:53, EDIT BY ENGEL
;ADD COMMENTS TO PREVIOUS CONTEXT OPDEFS
;<4.MONITOR>PROLOG.MAC.59, 13-Oct-78 15:24:21, EDIT BY HALL
;TCO 1900 - REORDER BITS IN ATUST TO CONFORM TO MONSYM
;TCO 1900 - ADD ADDRESS OF PIPE DATA TO CONTROL PIPE I/O BLOCKS
;<4;ADD STKCD4
;<4.MONITOR>PROLOG.MAC.57, 29-Sep-78 10:23:58, EDIT BY HALL
;TCO 1900 - ADD ATCRJ TO ATS TERMINAL STATUS BITS
;<4.MONITOR>PROLOG.MAC.56, 27-Sep-78 11:28:58, EDIT BY ENGEL
;ELIMINATE (FX) FROM DEFINTION OF FKNTC
;<4.MONITOR>PROLOG.MAC.55, 21-Sep-78 15:59:53, Edit by MCLEAN
;FIX XHLLI TO REALLY BE XHLLI (HLLI)
;<4.MONITOR>PROLOG.MAC.54, 14-Sep-78 17:21:58, EDIT BY MURPHY
;<4.MONITOR>PROLOG.MAC.53, 24-Aug-78 08:20:15, EDIT BY MILLER
;ADD ACCLS TO ACCOUNT BLOCK
;<4.MONITOR>PROLOG.MAC.52, 21-Aug-78 10:32:04, EDIT BY HALL
;TCO 1900 - TYPO IN PREVIOUS EDIT
;<4.MONITOR>PROLOG.MAC.51, 17-Aug-78 16:05:09, EDIT BY HALL
;TCO 1900 - ADD TERMINAL BIT MASK TO JFN DATA
;<4.MONITOR>PROLOG.MAC.50, 11-Aug-78 12:10:40, Edit by KONEN
;ADD STNRS CODE FOR STRUCTURE NOT REGULATED
;<4.MONITOR>PROLOG.MAC.49, 11-Aug-78 09:18:33, Edit by ENGEL
;GET RID OF AT%TRL
;<KONEN>PROLOG.MAC.2,  2-Aug-78 18:28:58, Edit by KONEN
;ADD DEFSTR FOR JSFKMT, FOURTH WORD OF STRUCTURE BLOCK
;<4.MONITOR>PROLOG.MAC.47, 28-Jul-78 15:38:45, Edit by HALL
;TCO 1900 - MAKE ATS SYMBOLS GLOBAL, MOVE SOME DEFINITIONS FROM
;	ATSSRV
;<4.MONITOR>PROLOG.MAC.46, 28-Jul-78 13:34:26, Edit by KIRSCHEN
;ADD FKNTC
;<4.MONITOR>PROLOG.MAC.45, 15-Jul-78 22:18:22, Edit by MCLEAN
;<4.MONITOR>PROLOG.MAC.44, 15-Jul-78 22:09:50, Edit by MCLEAN
;<4.MONITOR>PROLOG.MAC.43, 15-Jul-78 22:01:43, Edit by MCLEAN
;<4.MONITOR>PROLOG.MAC.42, 15-Jul-78 18:50:56, Edit by MCLEAN
;<4.MONITOR>PROLOG.MAC.41, 15-Jul-78 17:47:22, Edit by MCLEAN
;<4.MONITOR>PROLOG.MAC.40, 15-Jul-78 17:43:13, Edit by MCLEAN
;<4.MONITOR>PROLOG.MAC.39, 15-Jul-78 17:35:34, Edit by MCLEAN
;<4.MONITOR>PROLOG.MAC.38, 15-Jul-78 17:26:50, Edit by MCLEAN
;<4.MONITOR>PROLOG.MAC.37, 15-Jul-78 17:20:27, Edit by MCLEAN
;<4.MONITOR>PROLOG.MAC.36, 15-Jul-78 17:17:18, Edit by MCLEAN
;<4.MONITOR>PROLOG.MAC.35, 15-Jul-78 15:27:44, Edit by MCLEAN
;GTOKM MACRO
;<4.MONITOR>PROLOG.MAC.34, 14-Jul-78 00:24:29, Edit by MCLEAN
;DIRECTORY CACHE DEFINITIONS
;<4.MONITOR>PROLOG.MAC.33, 11-Jul-78 13:43:32, EDIT BY MILLER
;REMOVE BUTPG
;<4.MONITOR>PROLOG.MAC.32,  5-Jul-78 10:45:00, Edit by HALL
;TCO 1900 - ADD DEFSTR APINO FOR ATS DATA PIPES
;<4.MONITOR>PROLOG.MAC.31, 30-Jun-78 17:39:11, EDIT BY MURPHY
;<4.MONITOR>PROLOG.MAC.30, 30-Jun-78 16:06:29, Edit by HALL
;TCO 1900 - FIX SOME DATA DEFINITIONS FOR ATS
;<4.MONITOR>PROLOG.MAC.29, 30-Jun-78 15:43:50, EDIT BY MURPHY
;TCO #1930 - CRITICAL SECTION (CRSKED) FACILITY
;<4.MONITOR>PROLOG.MAC.28, 30-Jun-78 08:31:02, EDIT BY MILLER
;ADD NEW FIELD, FKMNQ TO FKQ2. CHANGE Q NUMBER FIELDS TO BE 6 BITS EACH
;<4.MONITOR>PROLOG.MAC.27, 28-Jun-78 14:05:16, Edit by HALL
;TCO 1900 - ADD SOME ENTRIES TO ATS'S PIPE DATA
;<4.MONITOR>PROLOG.MAC.26, 28-Jun-78 13:36:38, Edit by KIRSCHEN
;ADD NSPX05
;<4.MONITOR>PROLOG.MAC.25, 28-Jun-78 10:56:06, EDIT BY OSMAN
;ADD JBT20 - TCO 1927
;<4.MONITOR>PROLOG.MAC.24, 26-Jun-78 10:28:42, Edit by KIRSCHEN
;ADD NSPX4
;<4.MONITOR>PROLOG.MAC.23, 24-Jun-78 10:56:28, Edit by HALL
;TCO 1900 - CHANGES TO ATS DATA BASE
; PIPE DATA: ADD APSIX, APSIB,APIAD,APICT,APIHT,APIAL
; TERMINAL DATA: ADD ATSIX
;<1BOSACK>PROLOG.MAC.1004,  5-Jun-78 18:32:21, EDIT BY BOSACK
;<1BOSACK>PROLOG.MAC.1003, 24-May-78 15:05:44, EDIT BY BOSACK
;<1BOSACK>PROLOG.MAC.1002, 24-May-78 14:43:09, EDIT BY BOSACK
;<1BOSACK>PROLOG.MAC.1001, 22-May-78 01:20:01, EDIT BY BOSACK
;<4.MONITOR>PROLOG.MAC.21, 16-Jun-78 14:21:56, Edit by HALL
;TCO 1900 - TYPO IN PREVIOUS EDIT
;<4.MONITOR>PROLOG.MAC.20, 15-Jun-78 12:01:46, Edit by HALL
;TCO 1900 - FOR DATA PIPES ADD FIELDS FOR JOB NUMBER AND JFN
;<4.MONITOR>PROLOG.MAC.19, 14-Jun-78 14:00:55, Edit by ENGEL
;TCO 1900 - MOVE THE AT%XXX USER BIT DEFINITIONS FOR ATSSRV TO MONSYM
;<4.MONITOR>PROLOG.MAC.18,  8-Jun-78 14:33:10, Edit by KIRSCHEN
;ADD SOME ERROR CODES FOR INTERNAL NSP LINKS
;<4.MONITOR>PROLOG.MAC.17,  6-Jun-78 01:25:52, Edit by JBORCHEK
;REMOVE IMP DEFINITIONS TO IMPPAR
;<4.MONITOR>PROLOG.MAC.16,  5-Jun-78 02:29:26, Edit by JBORCHEK
;CORRECT IMPBS FIELD TO BE 8 BITS
;<4.MONITOR>PROLOG.MAC.15,  3-Jun-78 16:49:45, Edit by GILBERT
;Add GSOPDEF, suppress CALLRET etc. to DDT typeout
;<4.MONITOR>PROLOG.MAC.13,  1-Jun-78 14:42:17, Edit by HALL
;TCO 1900 - ADD AP%NOD TO PIPE STATUS BITS AND MOVE OTHERS OVER
;<4.MONITOR>PROLOG.MAC.12, 31-May-78 13:14:28, Edit by HALL
;TCO 1900 - TEMPORARILY ADDED A WORD TO THE PIPE DATA TO
; CONTAIN NSP'S ADDRESS OF ITS LINK BLOCK
;<4.MONITOR>PROLOG.MAC.11, 23-May-78 13:46:32, Edit by ENGEL
;<4.MONITOR>PROLOG.MAC.10, 23-May-78 13:43:23, Edit by ENGEL
;<4.MONITOR>PROLOG.MAC.9, 23-May-78 13:36:26, Edit by ENGEL
;CHANGE AT%STR TO AT%STF
;<4.MONITOR>PROLOG.MAC.8, 23-May-78 12:55:54, Edit by HALL
;TCO 1900 - FIX PREVIOUS EDITS OF ATS BITS BY ENGEL
;<4.MONITOR>PROLOG.MAC.7, 23-May-78 10:31:37, Edit by ENGEL
;TCO 1900 - fix at%sch
;<4.MONITOR>PROLOG.MAC.6, 22-May-78 09:28:21, Edit by ENGEL
;TCO 1900 - REPAIR BIT DEFINITIONS FOR ATMST
;<4.MONITOR>PROLOG.MAC.5, 19-May-78 14:57:23, EDIT BY HALL
;TCO 1900 - REMOVE EXTRA DEFINITION OF ATNRH
;<4.MONITOR>PROLOG.MAC.4, 17-May-78 15:59:08, Edit by ENGEL
;<4.MONITOR>PROLOG.MAC.3, 17-May-78 13:59:57, Edit by ENGEL
;TCO 1900 - ADD ATS LINK DEFINITIONS
;<4.MONITOR>PROLOG.MAC.2, 17-May-78 13:24:45, Edit by KIRSCHEN
;MORE NSP SYMBOLS
;<4.MONITOR>PROLOG.MAC.1, 17-May-78 07:49:54, EDIT BY MILLER
;ADD NEW FIELD, FKFLG TO FKQ2 WORD. REDUCE FKQN TO 9 BITS
;THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY ONLY BE USED
;  OR COPIED IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE.
;
;COPYRIGHT (C) 1976,1977,1978,1979 BY DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.

	UNIVERSAL PROLOG
	SALL
	SEARCH MACSYM,MONSYM

;FORM OF OPDEF TO DO INTERNAL

DEFINE GOPDEF (NAM,VAL)<
	OPDEF NAM [<VAL>]
	INTERN NAM>

;FORM OF OPDEF TO DO .NODDT'D INTERNAL

DEFINE GSOPDEF (NAM,VAL)<
	OPDEF NAM [VAL]
	INTERN NAM
	.NODDT NAM>

;DEFINE GLOBAL SYMBOL IF NOT ALREADY DEFINED AND LIST VALUE

DEFINE NDG (SYM,VAL)<
   IFNDEF SYM,<
	SYM==:VAL>>

;DEFINE SYMBOL IF NOT ALREADY DEFINED AND LIST VALUE

DEFINE ND (SYM,VAL)<
   IFNDEF SYM,<
	SYM==VAL>>


;ABBREVIATION FOR IFN ??FLG,<>

DEFINE IFKL (ARG)<
   IFN KLFLG,<
	ARG>>
DEFINE IFSM (ARG)<
   IFN SMFLG,<
	ARG>>

IJSFRE==:100			; INITIAL SIZE OF JSB FREE AREA

ND RVCF,0			;T=RVC/MLKBK SUPPORTED
;DEBUG SWITCHES

NDG DEBUG,0			;THE MASTER SWITCH

;IF THE MASTER SWITCH IS OFF, ALL SWITCHES ARE OFF

IFE DEBUG,<

RESBSW==:0			;RESIDENT FREE SPACE RING BUFFER
RESHSW==:0			;RESIDENT FREE SPACE EXTRA HEADER AND TRAILER
DTESW==:0			;DTE DRIVER
SKEDSW==:0			;SCHEDULER
SEC0SW==:0			;CHECK FOR CODE IN SECTION 0
DN20SW==:0			;CHECK FOR A 2ND DN20
SPTDSW==:0			;SPTLKB LOCKER TRACE FACILITY
CZQDBG==:0			;TRACE LOGICAL LINK CLOSES FROM NVT CODE

>				;END OF IFE DEBUG

;IF THE MASTER SWITCH IS ON, THE FOLLOWING SWITCH VALUES ARE IN USE

IFN DEBUG,<

NDG RESBSW,0
NDG RESHSW,0
NDG DTESW,0
NDG SKEDSW,0
NDG SEC0SW,0
NDG DN20SW,0
NDG CZQDBG,0
NDG SPTDSW,0

>
;GENERAL PARAMETERS AND MACROS

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

; GTJFN FIELD LENGTHS

MAXLC==:^D39
MAXLW==:8
MAXSHT==:6			; MAX CHARACTERS IF G1%NLN IS ON
MAXEXT==:3			; MAX CHARACTERS IN EXTENSION
;PC FLAGS

FPD==:1B4			;FIRST PART DONE (PC WORD)
UMODF==:1B5			;USER MODE FLAG
UIOF==:1B6			;USER IO MODE
PCU==:1B6			;PREVIOUS CONTEXT USER (PC WORD)

;SOFTWARE BIT IN PC WORD

QUOTAB==:1B15			;PC "BACKED UP" BECAUSE OF OVER QUOTA
PCX==:77B5			;MBZ BITS IN PC WORD

NUACB==:120			;NUMBER WORDS FOR AC STACK
NTERMI==:^D36			;NUMBER OF TERMINAL INTERRUPTS
NPILEV==:3			;NUMBER OF PSEUDO-INTERRUPT LEVELS
;PI CHANNEL ASSIGNMENTS FOR ALL DIVICES

DSKCHN==:5			;DISK
DRMCHN==:4			;DRUM
DLSCHN==:6			;KL CHANNEL FOR TTY PI
IMPCHN==:6			; CHANNEL FOR IMP DEVICES
MTACHN==:5			;MAG TAPE FLAGS CHANNEL
 MTDCHN==:1			;MAG TAPE DATA CHANNEL
DTACHN==:5			;DECTAPE CONTROL
 DTDCHN==:2			;DECTAPE DATA
PTPCHN==:6			;PAPER TAPE PUNCH
PTRCHN==:5			;PAPER TAPE READER
PLTCHN==:6			;PLOTTER
LPTCHN==:6			; LINE PRINTER PI CHANNEL
VBCCHN==:6			;VB10C DISPLAY
DLXCHN==:6			;DL10 SERVICE ROUTINE

APRCHN==:3			;APR PI CHANNEL
SCDCHN==:7			;SCHEDULER PI CHANNEL
UNBCHN==:56			;UNIBUS ADAPTER 2 PIA'S (11 DEVICES ARE BACKWARDS)
UNBPI5==6B35			;PI LEVEL OF BR5,BR4
UNBPI7==5B32			;PI LEVEL OF BR6,BR7
				;PI7 ON 11 IS HIGH THEREFORE IT IS 5 HERE
				;PI5 ON 11 IS LOW THEREFORE IT IS 7 HERE

;PI CONTROL DEFINITIONS


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

DEFINE CHNON (CHN)<
	CONO PI,PICHON+1B<28+CHN>>
;CONI/CONO PI

APR==:0				;DEVICE CODE FOR APR
;WARNING PI,PICHON AND PICHOF ARE ALSO DEFINED IN
;PROKL AND PROKS

PI==:4				;DEVICE CODE FOR PI

PICPIR==:1B22			;CLEAR PROGRAM PI REQUEST
PICLPI==:1B23			;CLEAR PI SYSTEM
PISPIR==:1B24			;SET PROGRAM PI REQUEST
PICHON==:1B25			;TURN CHANNELS ON
PICHOF==:1B26			;TURN CHANNELS OFF
PIPIOF==:1B27			;TURN PI SYSTEM OFF
PIPION==:1B28			;TURN PI SYSTEM ON

PIPIRM==:177B17			;PROGRAM REQUEST ACTIVE CHANNELS
PIPIIP==:177B27			;PI IN PROGRESS CHANNELS
PICHNM==:177B35			;CHANNEL MASK

;BITS FOR DATAO APR (ADDRESS BREAK)

ABIF==:1B9			;INSTRUCTION FETCH
ABDR==:1B10			;DATA READ
ABDW==:1B11			;DATA WRITE
ABUM==:1B12			;USER MODE (PC, NOT VMA)

;CONI/CONO PAG

PGCLKE==:1B18			;CACHE LOOK ENABLE
PGCLDE==:1B19			;CACHE LOAD ENABLE

PGKLMD==:1B21			;KL20 PAGING MODE
PGTPEN==:1B22			;TRAP ENABLE
PGEBRM==:<MASKB 23,35>		;EXEC BASE REGISTER

;DATAI/DATAO PAG

PGLACB==:1B0			;LOAD AC BLOCKS
PGLPCS==:1B1			;LOAD PCS
PGLUBR==:1B2			;LOAD UBR
PGCACB==:<MASKB 6,8>		;CURRENT AC BLOCK
PGPACB==:<MASKB 9,11>		;PREVIOUS AC BLOCK
PGNSAC==:1B18			;NO STORE ACCOUNTING REGISTERS
PGUBRM==:<MASKB 23,35>		;USER BASE REGISTER
MSKSTR PAGUBA,KIPGWD,PGUBRM

GSOPDEF ADJBP,<IBP>	;ADJBP = IBP WITH AC FIELD
;AC DEFINITIONS
;THESE ARE USED EXCLUSIVELY UNLESS SPECIFICALLY REDEFINED AT
;THE BEGINNING OF A MODULE

P=:17				;UNIVERSAL STACK
CX=:16				;CALL/RETURN TEMPORARY
 .SAC==:16			;SCRATCH - USED BY MACSYM MACROS
F=:0				;GENERAL FLAG REGISTER - PRESERVED

T1=:1				;GENERAL TEMPORARY
T2=:2
T3=:3
T4=:4
Q1=:5				;SECOND SET OF PRESERVED
Q2=:6
Q3=:7
P1=:10				;PRESERVED AC'S (NOT UNIVERSALLY OBSERVED NOW)
P2=:11
P3=:12
P4=:13
P5=:14
P6=:15
A==:1				;ALTERNATE DEFINITION FOR TEMPORARIES
B==:2				; FOR COMPATIBILITY WITH OLD CONVENTION UNTIL CHANGED
C==:3
D==:4

NSAC==:15			;HIGHEST PRESERVED AC

;IF AN ALTERNATE DEFINITION FOR AN AC IS USED IN A MODULE, THE
;FOLLOWING MACRO MUST BE USED TO DEFINE IT.  THE NEW DEFINITION
;MUST BE MADE IN TERMS OF ONE OF THE GLOBAL DEFINITIONS ABOVE.  THE
;DEFINITION PROCESS PURGES THE OLD NAME THUS PREVENTING MULTIPLE
;NAMES FOR ONE AC.

DEFINE DEFAC (NEW,OLD)<
   IF1,<
	IFG OLD-15,<PRINTX **INVALID REDEFINITION OF AC OLD**>
	IFL OLD-1,<PRINTX **INVALID REDEFINITION OF AC OLD**>
	NEW=OLD
	PURGE OLD,OLD
	DEFINE OLD<%'OLD'%>>>
;OPDEFS

GOPDEF JSYS,<104B8>

;CALLING CONVENTIONS FOR LOCAL SUBROUTINES.
; SUBROUTINES ARE CALLED WITH 'CALL' WHICH IS A PSEUDONUM FOR PUSHJ P,.
; RETURN +1 IS EFFECTED BY 'RET' WHICH IS A PSEUDONUM FOR POPJ P,.
; RETURN +2 IS EFFECTED BY 'RETSKP' WHICH IS A JRST TO AN AOS, RET.

GOPDEF CALL,<PUSHJ P,0>
GOPDEF RET,<POPJ P,0>

DEFINE RETSKP <JRST RSKP>

;'CALLRET' IS AN ABBREVIATION FOR THE COMMON SEQUENCE
;	CALL ...
;	RET
;	RETSKP		;(OPTIONALLY)
;CODE WHICH USES 'CALLRET' MAY NOT ASSUME THAT IT ASSEMBLES INTO
;A SINGLE INSTRUCTION, I.E. THAT IT MAY BE SKIPPED OVER.

GSOPDEF CALLRET,<JRST>
; 'ERCAL' FROM MONITOR CONTEXT CANNOT WORK DUE TO 
; COMMON STACK USAGE, THE FOLLOWING MACRO PRODUCES
; SOMETHING THAT DOES WORK

DEFINE ERCAL(FOO,%NEXT)<
	ERJMP [	CALL FOO
		JRST %NEXT]
%NEXT:!
>


;DECLARE LIST OF SYMBOLS EXTERNAL. (EQUIVALENT TO EXTERN BUT
;USES ANGLEBRACKET FORMAT LIKE OTHER IRP MACROS)

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

;FACILITY TO SAVE ALL ACS, OR P1-P4, OR Q1-Q3, OR Q1-Q3 AND P1-P6
;PUTS DUMMY RETURN ON STACK FOR AUTOMATIC RESTORE ON RETURN

DEFINE ACSAV <JSP CX,ACSAV0>
DEFINE SAVEP <JSP CX,SAVP>
DEFINE SAVEQ <JSP CX,SAVQ>
DEFINE SAVEPQ <JSP CX,SAVPQ>
DEFINE SAVET <JSP CX,SAVT>
;AC SAVE FACILITY - COMPILES OPEN PUSH'S OR CALL
;TO SPECIFIC LOCAL ROUTINE IF AVAILABLE
;	SAVEAC <LIST-OF-ACS>
;DUMMY ROUTINE PUT ON STACK TO CAUSE AUTOMATIC RESTORE. SUPPORTS
; +1 OR +2 RETURNS.

DEFINE SAVEAC (ACS)<
	.AM==0			;;COMPUTE MASK OF ACS USED
	IRP ACS,<
	  .AM=.AM!1B<ACS>>
	.AF==0			;;FLAG, HAVE ASSEMBLED NOTHING YET
	IFE .AM-17B4,< JSP CX,SAVT
		.AF=1>		;;T1-T4
	IFE .AM-07B4,< JSP CX,.SAV24
		.AF=1>		;;T2-T4
	IFE .AM-03B4,< JSP CX,.SAV34
		.AF=1>		;;T3-T4
	IFE .AM-01B4,< JSP CX,.SAV44
		.AF=1>		;;T4
	IFE .AM-02B4,< JSP CX,.SAV33
		.AF=1>		;;T3
	IFE .AM-04B4,< JSP CX,.SAV22
		.AF=1>		;;T2
	IFE .AM-10B4,< JSP CX,.SAV11
		.AF=1>		;;T1
	IFE .AM-14B4,< JSP CX,.SAV12
		.AF=1>		;;T1-T2
	IFE .AM-16B4,< JSP CX,.SAV13
		.AF=1>		;;T1-T3
	IFE .AM-4B7,< JSP CX,.SAV1
		.AF=1>		;;Q1
	IFE .AM-6B7,< JSP CX,.SAV2
		.AF=1>		;;Q1-Q2
	IFE .AM-7B7,< JSP CX,.SAV3
		.AF=1>		;;Q1-Q3
	IFE .AM-17B8,< JSP CX,.SAV4
		.AF=1>		;;Q1-Q3, P1
	IFE .AF,<		;;IF NONE OF THE ABOVE CASES, DO OPEN PUSH'S
	.NAC==0
	IRP ACS,<
	  PUSH P,ACS		;;SAVE AN AC
	  .NAC=.NAC+1>		;;COUNT THEM
	.N1==.NAC
	SETMI .A16,[CAIA	;;STACK DUMMY RETURN
		AOS -.N1(P)	;;HANDLE SKIP RETURN
	  IRP ACS,<
		.N1=.N1-1
		MOVE ACS,-.N1(P)>  ;;RESTORE AN AC
		SUB P,[.NAC,,.NAC]  ;;CLEAR STACK
		POPJ P,]	;;FINAL RETURN
	PUSH P,.A16>>

;SYMBOLS FOR REFERRING TO FLAGS AND/OR PC ON THE STACK

DEFINE STKFLG <0(P)>
DEFINE STKPC <-1(P)>
;THE FOLLOWING OPCODES ARE USED TO REFERENCE DATA IN THE 'PREVIOUS
;CONTEXT'.  THE PREVIOUS CONTEXT IS THE USER ADDRESS SPACE IF
;THE JSYS CALL WAS EXECUTED BY A USER PROGRAM, OR THE
;MONITOR ADDRESS SPACE IF IT WAS EXECUTED BY THE MONITOR.
;WHEN WRITING JSYS CODE HOWEVER, IT IS CONVENIENT TO THINK OF THE
;CURRENT CONTEXT AS 'MONITOR' AND THE PREVIOUS CONTEXT AS
;'USER'.  THESE TERMS SHOULD BE UNDERSTOOD IN THIS WAY IN THE
;FOLLOWING DISCUSSION AND IN THE OPDEF'S.

;XCTU IS THE GENERAL CASE AND IS USED FOR ALL ORDINARY (ONE-ADDRESS)
;INSTRUCTIONS.  IF USED FOR BLT, IT WILL CAUSE BOTH SOURCE AND
;DESTINATION TO BE USER.

;XCTUU ARE USED TO BOTH COMPUTE EFFECTIVE ADDRS IN USER AND FETCH
;FROM USER, I.E. - XCTUU [MOVE T1,@T1]

;XBLTMU AND XBLTUM ARE USED WITH BLT TO DO MONITOR-TO-USER
;AND USER-TO-MONITOR BLT'S RESPECTIVELY.  XBLTUU IS ALSO DEFINED
;FOR CONSISTENCY FOR USER-TO-USER BLT.

;XCTBU IS USED WITH BYTE INSTRUCTIONS WHERE POINTER IS IN MONITOR,
;DATA IN USER.  XCTBUU IS BYTE INSTRUCTION WITH POINTER AND DATA
;IN USER (KI10 DOES NOT SUPPORT).

;XPSHUM AND XPOPMU ARE THE ONLY CASES OF PUSH AND POP CURRENTLY USED.
;XPSHUM MEANS PUSH USER-TO-MONITOR, XPOPMU MEANS POP MONITOR-TO-USER, ETC.
;ADDITIONAL SUCH MNEMONICS WILL BE DEFINED IF NEEDED.

GOPDEF XCTU,<XCT 4,0>	;DATA ONLY IS IN PREVIOUS CONTEXT
GOPDEF XCTUU,<XCT 14,0>	;"E" AND DATA FROM PREV. CONTEXT (INCLUDES AC LOOK-UP)


GSOPDEF XBLTMU,<XCT 4,0>	;DATA FROM PREVIOUS CONTEXT
GOPDEF XBLTUM,<XCT 1,0>		;DATA TO PREVIOUS CONTEXT
GOPDEF XBLTUU,<XCT 5,0>		;DATA FROM AND TO PREVIOUS CONTEXT
GOPDEF XCTBU,<XCT 3,0>		;EXTENDED BLT - DATA FROM PREVIOUS CONTEXT
GOPDEF XCTBMU,<XCT 1,0>		;BLT - DATA TO PREVIOUS CONTEXT
GOPDEF XCTBUU,<XCT 7,0>		;POINTER,POINTER E AND DATA FROM PREVIOUS CONTEXT

GSOPDEF XPSHUM,<XCT 4,0>	;STACK IN PREVIOUS CONTEXT
GSOPDEF XPOPMU,<XCT 4,0>	;STACK IN PREVIOUS CONTEXT
;'UMOVEX' IS A GROUP OF INSTRUCTIONS LIKE 'MOVEX' WHERE THE DATA
;REFERENCE IS FORCED TO 'USER' SPACE.  THEY ARE DEFINED IN TERMS
;OF 'XCTXX'.

 DEFINE UMOVE (A,L)<
	XCTU [MOVE A,L]>

 DEFINE UMOVEM (A,L)<
	XCTU [MOVEM A,L]>

;UMOVEI AND UMOVES ARE NOT DEFINED.

;THE FOLLOWING IS USED IN PLACE OF THE LOAD AND STOR MACROS WHEN
;PREVIOUS CONTEXT IS TO BE REFERENCED.  LOAD AND STORE CANNOT
;BE USED DIRECTLY UNDER XCTU BECAUSE THEY MAY ASSEMBLE BYTE
;INSTRUCTIONS WHICH REQUIRE DIFFERENT XCT BITS.

DEFINE ULOAD (AC,STR,Y)<
	..STR0 (..ULDB,AC,STR,Y)>

   DEFINE ..ULDB (AC,LOC,MSK)<
	..TSIZ (..PST,MSK)
	.CASE ..PST,<<
	  XCTU [MOVE AC,LOC]>,<
	  XCTU [HRRZ AC,LOC]>,<
	  XCTU [HLRZ AC,LOC]>,<
	  XCTBMU [LDB AC,[POINTR (LOC,MSK)]]>>>

DEFINE USTOR (AC,STR,Y)<
	..STR0 (..UDPB,AC,STR,Y)>

   DEFINE ..UDPB (AC,LOC,MSK)<
	..TSIZ (..PST,MSK)
	.CASE ..PST,<<
	  XCTU [MOVEM AC,LOC]>,<
	  XCTU [HRRM AC,LOC]>,<
	  XCTU [HRLM AC,LOC]>,<
	  XCTBMU [DPB AC,[POINTER (LOC,MSK)]]>>>

;THE FOLLOWING MACRO IS USED TO DEFINE FLAG BITS USING
;THE STRUCTURE FACILITY.  MSKSTR OR DEFSTR COULD BE USED DIRECTLY, THIS
;MACRO IS HERE FOR HISTORICAL REASONS.  THE FLAGS SO DEFINED
;ARE SET/TESTED WITH TQ??.

DEFINE FLG(FL,LR,REG,BIT)<
	IFIDN <LR><L>,<FL==<BIT>B17>
	IFIDN <LR><R>,<FL==BIT>
	MSKSTR (FL,REG,FL)>

;SAME AS ABOVE BUT MAKE FLAG GLOBAL

DEFINE GFLG(FL,LR,REG,BIT)<
	IFIDN <LR><L>,<FL==:<BIT>B17>
	IFIDN <LR><R>,<FL==:BIT>
	MSKSTR (FL,REG,FL)>
;RESIDENT STORAGE ALLOCATION MACRO

DEFINE RS (T,N)<
	.PSECT RSVAR
	IFB <N>,<
T::	BLOCK 1>
	IFNB <N>,<
T::	BLOCK N>
	.ENDPS RSVAR
>

;RSI MACRO - THIS MACRO ALLOCATES STORAGE IN THE RSDAT PSECT, A RESIDENT,
;WRITE-ENABLED PSECT THAT IS NOT ZEROED AT SYSTEM STARTUP.
;ARGUMENTS ARE:
;	NAME - LABEL ASSOCIATED WITH THE FIRST LOCATION
;	LIST - A LIST OF THE INITIAL CONTENTS, ONE ENTRY PER WORD
;	TOTAL - TOTAL NUMBER OF WORDS ALLOCATED
;IF TOTAL IS NOT BLANK, IT MUST BE LARGE ENOUGH TO INCLUDE ALL WORDS
;IN THE LIST. IF TOTAL EXCEEDS THE NUMBER OF INITIAL VALUES, THE
;REMAINING SPACE IS ALLOCATED BUT NOT INITIALIZED.

DEFINE RSI (NAME,LIST,TOTAL),<
	.PSECT RSDAT
NAME::	IRP LIST,<
	LIST
	>
	IFNB <TOTAL>,<
	IFG <<TOTAL>-<.-NAME>>,<BLOCK <TOTAL>-<.-NAME>>
	IFG <.-NAME-<TOTAL>>,<IF2,<PRINTX %DEFINITION OF NAME EXCEEDS WORD COUNT
>>
	>			;END OF IFNB

	.ENDPS
>				;END OF RSI DEFINITION
;SWAPPABLE STORAGE

DEFINE NR (T,N)<
	.PSECT NRVAR
	IFB <N>,<
T::	BLOCK 1>
	IFNB <N>,<
T::	BLOCK N>
	.ENDPS NRVAR
>

;SWAPPABLE STORAGE ASSIGNED PAGE-AT-A-TIME

DEFINE NRP(T,N)<
	.PSECT NPVAR
	IFB <N>,<
T::	BLOCK PGSIZ>
	IFNB <N>,<
T::	BLOCK N>
	.ENDPS NPVAR
>

;STORAGE IN SYMBOL TABLE PSECT (HIDDEN WHEN SYMBOLS ARE)

DEFINE ST(T,N)<
	.PSECT SYVAR
T::	BLOCK N
	.ENDPS SYVAR
>
;SWAPPABLE, RESIDENT CODE

DEFINE SWAPCD<
	.ENDPS
	.PSECT NRCOD
>
DEFINE RESCD($TYPE)<
	.ENDPS
   IFB <$TYPE><
	.PSECT RSCOD
   >
   IFIDN <$TYPE><INIT><
	.PSECT INCOD
   >
>

;PSEUDO-TITLE FOR ALL REGULAR MODULES


DEFINE TTITLE (TT,NN,XTT)<
	SALL
	.DIRECT FLBLST
OURTTL==SIXBIT /TT/		;;Remember module name for BUG macro
	TITLE TT'XTT
IFB <NN>,<ENTRY $'TT
	$'TT==:0>
IFNB <NN>,<ENTRY $'NN
	$'NN==:0>
	SEARCH MONSYM,MACSYM
	.XCMSY			;;XCREF JUNK SYMBOLS
	.PSECT RSCOD
	GGLOBS
	DEFINE TNXEND <
	XLIST
L'TT'....:	LIT
	LIST
>>

;MAKE SYMBOLS EXTERN IF NOT ALREADY DEFINED

DEFINE EXT (SYM)<
   IF2,<
	IRP SYM,<
	IFNDEF SYM,<EXTERN SYM
	SUPPRE SYM>>>>
;PI CONTROL DEFINITIONS

GOPDEF PIOFF,<CONO PI,PIPIOF>
GOPDEF PION,<CONO PI,PIPION>
DEFINE ISB (CHN)<
	CONO PI,PISPIR+1B<28+CHN>>

DEFINE CLSB (CHN)<
	CONO PI,PICPIR+1B<28+CHN>>

DEFINE UNBRK (DEV)<
	JRST DEV'CHR##>
;PAGEM BITS

;IN SPTH

FILUB==:1B0			;'UNRESTRICTED' BIT (ASOFN CALL ONLY)
FILWB==:1B1			;'FILE WRITE' BIT IN SPTH AND ASOFN ARG
THAWB==:1B2			;'THAWED' BIT """
FILNB==:1B3			;'FILE NEW' BIT """
SPTLKB==:1B4			;LH OF SPTH(OFN), XB IN USE BY DDMP
OFNWRB==:1B5			;OFN HAS BEEN MODIFIED
OFNBAT==:1B6			;XB CONTAINS A BAD BLOCK
OFNERR==:1B7			;ERROR IN FILE (E.G. MPE)
OFNDMO==:1B8			;THIS OFN IS ON A DISMOUNTED STRUCTURE
OFNDUD==:1B9			;THIS OFN NOT TO BE SWAPPED TO DISK
OFN2XB==:1B10			;**TEMP** SECOND LEVEL XB
MULTOP==:1B11			;FILE IS MULTIPLY OPEN

;THERE ARE NO SPARE BITS IN SPTH FLAG FIELD

;IN SPT

DEFSTR (ALOCX,SPT,11,12)		;INDEX INTO ALLOCATION TABLES (OFN)
USHR==:1B11			;ONE UNIT OF SHARE COUNT IN SPT
DEFSTR SPTSHC,SPT,11,12		;SHARE COUNT IN SPT ENTRY
MAXSHC==:.RTJST(SPTSHC,SPTSHC)	;MAX SHARE COUNT VALUE
;;;#150 MAXSC0==:MAXSHC-1000	;MAX SHARE COUNT FOR NEW INDIRECT PTR
MAXSC0==:MAXSHC-10		;#150 make a reasonable limit on
				;      indirect pointers

;IN SPTO

OFSHR==:1B17			;ONE UNIT OF OFN SHARE ENTRY
DEFSTR OFNSHC,SPTO,17,18	;SHARE COUNT FOR AN OFN
STX==:777777			;STRUCTURE INDEX IS RH OF SPTO
MSKSTR (STRX,SPTO,STX)		;DEFINE LOADABLE FIELD

;IN SPTO2

DEFSTR OFOPC,SPTO2,35,18	;COUNT OF NORMAL OPENS (NOT READ-UNRESTRICTED)

;IN DST

BWRBIT==:1B11			;WRITTEN (CHANGED) FROM HOME COPY IN DST

;IN CST0

CORMB==:1B35			;MODIFIED BIT IN CST0
PSTFLD==:<MASKB 33,34>		;MASK FOR SPECIAL PAGE STATE FIELD
DEFSTR CFXRD,CST0,32,18		;FORK WHICH INITIATED READ
  CFXRM==:CFXRD			;MASK FOR FIELD IN HARDWARE
  CFXNUL==:.RTJST(CFXRD,CFXRD)	;NULL VALUE
PUFLD==:<MASKB 9,32>		;PROCESS USE BITS
DEFSTR XGAGE,CST0,14,6	;AGE AT LAST XGC (LOW BITS ONLY)
AGEMSK==:<MASKB 0,8>		;AGE AND CODE FIELD
MSKSTR CSTAGE,CST0,AGEMSK
MSKSTR CSTPST,CST0,PSTFLD	;SPECIAL PAGE STATE

;SPECIAL PAGE STATE CODES (CSTPST)

PSTAVL==.MCPSA			;AVAILABLE FOR RPLQ WHEN FREED
PSTSPM==.MCPSS			;PLACE ON SPMQ WHEN FREED
PSTOFL==.MCPSO			;OFFLINE - ACTION AS PSTSPM
PSTERR==.MCPSE			;OFFLINE DUE TO ERROR - ACTION AS PSTSPM

;PAGE STATE CODES (CSTAGE)

PSRPQ==:0			;ON REPLACABLE QUEUE
PSDEL==:1			;DELETED (ON DELETED QUEUE)
PSRDN==:2			;READ COMPLETED
PSWIP==:4			;WRITE IN PROGRESS
PSRIP==:6			;READ IN PROGRESS
PSSPQ==:7			;PAGE ON SPECIAL MEMORY QUEUE
PSASN==:10			;PAGE ASSIGNED TO PROCESS IF .GE. PSASN
PSASM==:<FLD(770,AGEMSK)>	;MASK TO TEST FOR ASSIGNED PAGE
;IN CST1

PLKV==:1B11			;PAGE LOCK VALUE IN CST1
PLKMSK==:<MASKB 0,11>		;LOCK COUNT FIELD
MSKSTR PLKCNT,CST1,PLKMSK

;IN CST3

DWRBIT==:1B0			;WRITE BIT IN CST3
SWPERR==:1B1			;SWAP ERROR BIT IN CST3
DSKSWB==:1B2			;SWAP TO DISK REQUESTED
DEFSTR CSTOFK,CST3,14,12	;OWNING FORK INDEX IN CST
DEFSTR CSTLDA,CST3,35,21	;LOCAL DISK ADDRESS FOR PHYSIO
OFNUL==:7777			;NULL VALUE FOR CSTOFK (NO OWNING FORK)

;TRAP STATUS (PAGE FAIL) WORD

TWUSR==:1B0			;USER MODE REFERENCE
TWHPFF==:1B1			;'HARD' FAILURE
TWCOD==:<MASKB 1,5>		;FAIL CODE
TWWRT==:1B5			;WRITE REFERENCE
TWVADR==:<MASKB 13,35>		;VIRTUAL ADDRESS

;FLAGS IN TRPDSP

TRPIRF==:1B0			;DO INTERRUPT REQUEST

;EXTENDED ADDRESS MASKS


; SECTION DEFINITIONS

BTMXSZ==077777			;SIZE OF EXTENDED BITMAPS

;IN ALLOCATION OFN TABLES

DEFSTR (ALCWD,ALOC1,35,36)	;ALLOCATION WORD
DEFSTR (ADIRN,ALOC1,17,18)	;DIRECTORY NUMBER (LH)
DEFSTR (ODIRC,ALOC1,35,18)	;OFN DIRECTORY COUNT
DEFSTR (PGLFT,ALOC2,35,36)	;COUNT OF PAGES LEFT (MAYBE NEG)

;IN OFNLEN TABLE

DEFSTR (OFNBSZ,OFNLEN,5,6)	;OFN FILE BYTE SIZE
DEFSTR (OFNBC,OFNLEN,35,30)	;OFN FILE BYTE COUNT
;BITS IN MAP WORD

STGADM==:<MASKB 12,35>		;MASK FOR STORAGE ADDRESSES
SPTM==:<MASKB 18,35>		;MASK FOR SPT INDICES
MSKSTR SPTX,,SPTM		;SPT INDEX IN SHARE OR INDIRECT PTR
DEFSTR IPPGN,,17,9		;WHERE TO FIND PAGE NUMBER IN INDIRECT POINTER
MSKSTR STGADR,,STGADM		;STORAGE ADDRESS FIELD IN PTR OR SPT

PTRCOD==:<MASKB 0,2>		;CODE FIELD IN PAGE POINTER
IMMCOD==:1			;IMMEDIATE POINTER
SHRCOD==:2			;SHARE POINTER
INDCOD==:3			;INDIRECT POINTER
PTACB==:<MASKB 3,8>		;ACCESS BITS (BOTH HARDWARE AND SOFTWARE)
PTPUB==:1B3			;PUBLIC BIT
PTWR==:1B4			;WRITE ACCESS
PTSOFT==:1B5			;SOFTWARE BIT
PTCACH==:1B6			;CACHE BIT
PTCPY==:1B7			;COPY-ON-WRITE (SOFTWARE ONLY)
PTSECM==:1B8			;SECTION IS MAPPED
PTLOK==:1B9			;PAGE IS LOCKED (IMMEDIATE PTR ONLY)

NCORTM==:<MASKB 12,17>		;NOT-CORE TEST MASK IN STORAGE ADR
UAAB==:1B17			;UNASSIGNED BIT IN STORAGE ADR
UAACB==:1B17+1B35		;UNASSIGNED AND COPY
DRMAB==:2B17			;DRUM BIT IN STORAGE ADR
DRMOB==:1B17			;DRUM OVERFLOW (WITH DRMAB) IN STG ADR
DSKAB==:1B14			;DSK BIT IN STORAGE ADR
;;;#151 DSKNB==:1B15		;WITH DSKAB, NEWLY ASSIGNED ADDRESS
DSKNB==:1b13			;#151 Fix for disc address overflow

;HARDWARE/FIRMWARE REGISTERS

HWRACB==:6			;AC BLOCK FOR PAGING VARIABLES

SPTBR==:3			;SPT BASE REG
CSTBR==:2			;CST BASE REG
CSTMSK==:0			;CST UPDATE MASK
CSTDAT==:1			;CST UPDATE DATA

PTRW==:PM%RD+PM%WT		;NORMAL ACCESS, MONITOR CALL

;PHYSICAL CORE ADDRESS

PGWD==:777			;WORD WITHIN PAGE
PHCPNO==:<MASKB 14,26>		;PHYSICAL CORE PAGE NUMBER

;VIRTUAL ADDRESSES

VPGNO==:37777000			;PAGE NUMBER
LPGNO==:777000			;LOCAL PAGE NUMBER (WITHIN SECTION)
VSECNO==:37B17			;SECTION NUMBER
EXPCBT==:<MASKB 13,35>		;23 BIT PC ADDRESS
EXFLBT==:<MASKB 0,12>		;FLAGS BITS FOR ALL
EXSCBT==:<MASKB 13,17>		;SECTION BITS OF PC
EXPCS==:<MASKB 31,35>		;XSFM PUTS PREVIOUS CONTEXT SECTION HERE
				;SHOULD BE 24-35 SOMEDAY
;PAGER-RELATED STORAGE FORMAT DEFINITIONS


;BAT BLOCK DEFINITIONS
;THE BAT BLOCK IS ONE SECTOR IN LENGTH.  IT CONSISTS OF 4 WORDS OF
;HEADER, FOLLOWED BY DATA, TWO WORDS PER ENTRY, INDICATING WHERE THE
;BAD SPOTS ON THE DISK ARE.  WORD ^D126 CONTAINS A SPECIAL CODE, AND
;WORD ^D127 CONTAINS THE SECTOR NUMBER OF THE BAT BLOCK

BATBL1==2			;SECTOR NO. OF FIRST BAT BLOCK

;HEADER

BATNAM==0			;OFFSET OF SIXBIT /BAT/
BATFRE==1			;WORD WITH FREE BLOCKS LEFT
DEFSTR BATFR,BATFRE,17,18	;FIELD WITH FREE COUNT
DEFSTR BTFR2,BATFRE+HBLEN,17,18	;IN THE SECONDARY BLOCK
DEFSTR BTHCT,2,17,9		;NUMBER OF PAIRS ADDED BY MAPPER
DEFSTR BTMCT,3,35,36		;COUNT OF PAIRS ADDED BY MONITOR
DEFSTR BTMC2,HBLEN+3,35,36	;IN SECONDARY BLOCK

;DATA PAIRS

DEFSTR BATNB,0,8,9		;COUNT OF BAD BLOCKS IN PAIR
PUBCNT==22			;RIGHT-MOST BIT OF UNARY UNIT FIELD
DEFSTR BTKNM,0,20,3		;MASSBUS CONTROLLER #
DEFSTR BADT,0,21,1		;TYPE FIELD IN BAT PAIR
DEFSTR APRNM,0,35,14		;APR SERIAL NUMBER FIELD
DEFSTR ADD18,1,35,18		;OLD STYLE DISK ADDRESS OF STARTING SECTOR
DEFSTR ADD27,1,35,27		;NEW STYLE ADDRESS OF STARTING SECTOR

;SPECIAL WORDS AT END OF BAT BLOCK

BATCOD==^D126			;OFFSET FOR UNLIKELY CODE 606060
BATBLK==^D127			;OFFSET FOR SECTOR NUMBER
;VARIABLES USED IN MOUNTING STRUCTURES

HB%PUB==:1B0			;PUBLIC STR
HB%1OK==:1B1			;FIRST HOME BLOCK OK
HB%2OK==:1B2			;SECOND HOME BLOCK OK
HB%HBM==:1B3			;HOME BLOCKS MATCH
HB%MUN==:1B4			;MULTIPLE LOGICAL UNITS IN STR
HB%WLK==:1B5			;THIS UNIT IS WRITE-LOCKED

;INTERNAL BITS RELATING TO STRUCTURES. NOT NECESSARILY FOUND IN THE
;SAME WORD

MI%MSG==:1B11			;"TYPE CTY MESSAGES" FLAG FOR STR MOUNTING
				; ROUTINES CALLED BOTH FROM MSTR AND AT STARTUP
;MI%LIM==:1B5			;STRUCTURE IS LIMITED IN GROWTH
				; DEFINED AS MS%LIM IN MONSYM
MI%ASG==:1B9			;DISK ASSIGNMENTS ARE PROHIBITED (BIT TABLE IS BAD)
MI%MXB==:1B10			;BIT TABLE TOO BIG FOR MONITOR ADDRESS SPACE
;STORAGE DEFINITIONS FOR SYSTEM FORK DATA BASE

DEFSTR HIBFL,JOBNAM,0,1		;FLAG USED BY .HIBER JSYS
DEFSTR DIAFL,JOBNAM,1,1		;FLAG SAYING JOB HAS .DIAG
				; RESOURCES
DEFSTR FKPSB,FKPGS(FX),35,18
DEFSTR FKUPT,FKPGS(FX),17,18
DEFSTR FKQTM,FKQ1(FX),35,36
DEFSTR FKNTC,FKQ2,0,1	;NETWORK TOPOLOGY CHANGE INTERRUPT ENABLED
DEFSTR PIBMP,FKQ2(FX),1,1	;PI BOOST FLAG
DEFSTR FKFLG,FKQ2(FX),5,4	;FORK FLAGS
DEFSTR FKMNQ,FKQ2(FX),11,6	;MIN Q FOR FORK
DEFSTR FKQN,FKQ2(FX),17,6	;QUEUE LEVEL NUMBER
DEFSTR FKWTL,FKQ2(FX),35,18	;WAITLIST ADR FOR BLOCKED FORK
DEFSTR FKBET,FKPT(FX),17,17	;BALSET ENTRY TIME
 FKBETH==:1B<^L<.RTJST(FKBET,FKBET)>> ;HIGH BIT OF RIGHT JUSTIFIED FKBET
DEFSTR FKWSL,FKSWP(FX),0,1	;WORKING SET IS LOADED
DEFSTR FKBLK,FKSWP(FX),1,1	;FORK BLOCKED
DEFSTR FKIBS,FKSWP(FX),2,1	;FORK IN BALSET
DEFSTR BSWTB,FKSWP(FX),3,1	;IN BALSET WAIT
DEFSTR BSNSK,FKSWP(FX),4,1	;NOSKED
DEFSTR BSCRSK,FKSWP(FX),5,1	;IN CRITICAL SECTION
DEFSTR FKIBH,FKSWP(FX),6,1	;IBS HOLD, SET ON BALSET ENTRY
DEFSTR FKBSHF,FKSWP(FX),7,1	;IN BALSET HOLD (IN AJBALS ONLY)
DEFSTR BSSPQ,FKSWP(FX),8,1	;SPECIAL QUEUE (SYSTEM FORK)
DEFSTR BSOVRD,FKSWP(FX),9,1	;OVERRIDE HIGH PRIORITY
DEFSTR BSNST,FKSWP(FX),10,1	;LAST BLOCK WAS LONG
; B11-17 AVAILABLE
DEFSTR FKHST,FKSWP(FX),35,18	;HISTORY
DEFSTR FKGOLN,FKBSPW(FX),17,18	;GOLST POSITION
   FHV1==:1			;BLOCK PRIORITY VALUES IN FKGOLN
   FHV2==:2
   FHV3==:3
   FHV4==:4
   FHV5==:5
   FHV6==:6
   FHV7==:7
DEFSTR FKBLP,FKBSPW(FX),35,18	;LIST OF FORKS IN BALSET HOLD
DEFSTR FKJSB,FKJOB(FX),35,18
DEFSTR FKJOBN,FKJOB(FX),17,18
DEFSTR FKXAGE,FKNR(FX),8,9	;AGE AT LAST XGC
DEFSTR FKAGE,FKNR(FX),17,9	;CURRENT AGE
DEFSTR FKWSS,FKNR(FX),35,18	;WORKING SET SIZE
DEFSTR FKCSIZ,FKWSP(FX),35,18	;CURRENT SIZE (NUMBER ASSIGNED PAGES)
DEFSTR FKNWCE,FKWSP(FX),17,18	;NUMBER ENTRIES IN WS CACHE
DEFSTR HWPTN,FKCNO(FX),17,18
DEFSTR FSSPTN,FKCNO(FX),17,18		;PSB STACK PAGE FOR KL ONLY

;FIELDS IN FKINT

FKPSI0==:1B0			;INTERRUPT ATTENTION
FKPSI1==:1B1			;IN PSI HANDLER OR INT DEFERRED
NEWFK%==:1B2			;INITIATE NEW FORK - PI FLAG
NEWJB%==:1B3			;INITIATE NEW JOB - PI FLAG
PSIIF%==:1B4			;CHANNEL INTERRUPT REQUESTED IN FKINTB
PSIT1%==:1B5			;TERMINAL CODE INTERRUPT, PHASE 1
PSIT2%==:1B6			;TERMINAL CODE INTERRUPT, PHASE 2
SUSFK%==:1B7			;SUSPEND FORK REQUEST
PSIWT%==:1B8			;JOB WAS IN WAIT STATUS
PSILO%==:1B9			;LOGOUT JOB REQUEST
FRZB1%==:1B10			;DIRECT FREEZE HAS BEEN DONE
FRZB2%==:1B11			;INDIRECT FREEZE HAS BEEN DONE
FRZBB%==:FRZB1%+FRZB2%		;BOTH BITS FOR EXTERNAL REFS
PSICO%==:1B12			;CARRIER OFF ACTION REQUEST
PSITL%==:1B13			;TIME LIMIT EXCEEDED INTERRUPT
PSIJT%==:1B14			; JSYS trap request
JTFRZ%==:1B15			; JSYS trap freeze
ADRBK%==:1B16			;ADDRESS BREAK REQUEST
ABFRZ%==:1B17			;ADDRESS BREAK FREEZE
FRZBA%==:ABFRZ%+JTFRZ%+FRZBB%	; All types of freezes
DEFSTR (TRMCOD,,35,9)		; FIELD IN FKINT OR PIMSK FOR TERM
;DEFS IN RH OF WORD

PSIPRI==:1B18			;PRIORITY WORD SET.
UNUSED==MASKB(19,26)		;UNUSED FKINT BITS

;STRUCTURES IN JOB DATA BASE

DEFSTR JBTFK,JOBPT,35,18	;TOP FORK
DEFSTR JBTTY,JOBPT,17,18	;CONTROLLING TTY

; TIMER block defns

DEFSTR JOBRTP,JOBRTL,35,23	; Ptr to runtime limit block
DEFSTR TIMCNT,JOBRTL,12,13	; # of TIMER clocks in use by job
;STORAGE DEFINITIONS FOR THE PSB

DEFSTR ABFLG,ADRBRK,12,6	;FLAG BITS IN ADDRESS BREAK WORD

;STORAGE DEFINITIONS FOR THE JSB

DEFSTR JSMTR,JSMTA1,35,18	;DEFAULT RECORD SIZE (HARDWARE BYTES)
DEFSTR JSMTM,JSMTA1,17,3	;DEFAULT MODE FOR TRANSFER'S (IRMXXX)
DEFSTR JSMTD,JSMTA1,14,4	;DEFAULT DENSITY
DEFSTR JSMTP,JSMTA1,10,1	;DEFAULT PARITY

MSKSTR (JSDFS,JBFLAG,SP%DFS)	;SPOOLING IS DEFERRED
MSKSTR (JSBAT,JBFLAG,SP%BAT)	;JOB IS BEING CONTROLLED BY BATCH
MSKSTR (JSELO,JBFLAG,SP%ELO)	;JOB EXECUTED LGOUT JSYS
MSKSTR (JSFLO,JBFLAG,SP%FLO)	;JOB FORCED TO LOGOUT BY TOP FK ERROR
MSKSTR (JSOLO,JBFLAG,SP%OLO)	;JOB LOGGED OUT BY OTHER JOB

DEFSTR JBMX,JBFLAG,18,1		;JOB HAS BEEN IN THE MINI-EXEC
DEFSTR JBT20,JBFLAG,19,1	;JOB IS AT TOPS20 COMMAND LEVEL

;FIELDS IN JOBBIT

LOGIOB==:1B0			;JOB BEING CREATED OR DESTROYED

;BITS IN PSBIT

DEFSTR (PSXSIR,PSBITS,0,1)	;EXTENDED ADDRESSING SIR WAS DONE
DEFSTR (PSUTPS,PSBITS,1,1)	;THIS FORK HAS USED .MOTPS MTOPR FUNCTION

;DEFINITIONS FOR JFN AREA IN JSB

DEFSTR LNMCNT,0,17,18		;DEPTH COUNT FOR LOGICAL NAMES
DEFSTR LNMIDX,0,18,1		;INDEX INTO LN TABLES
DEFSTR LNMSTP,0,35,17		;STEP COUNTER AT TIME OF CHAINING
DEFSTR LNMLNK,1,17,18		;LINK TO NEXT CHAIN BLOCK
DEFSTR LNMPNT,1,35,18		;POINTER TO LOGICAL NAME STRING
DEFSTR FILDMS,FILMS1,17,18	;WILD MASK FOR DIRECTORY
DEFSTR FILNMS,FILMS1,35,18	;WILD MASK FOR NAME
DEFSTR FILEMS,FILMS2,17,18	;WILD MASK FOR EXTENSION
DEFSTR STR,FILDEV,17,18		;STRUCTURE NUMBER IN JFN BLOCK
DEFSTR FILUC,FILCOD,17,18	;STRUCTURE UNIQUE CODE IN JFN BLOCK
DEFSTR FILP0,FILCOD,35,18	;PT0 OFN IF A LONG FILE
DEFSTR FILDIR,FILDNM,17,18	;POINTER TO DIRECTORY STRING IN JFN BLOCK
DEFSTR FILATL,FILDNM,35,18	;POINTER TO THE ATTRIBUTE LIST
DEFSTR ORG,FILVER,17,18		;FORK ORIGINATOR OF FILE

DEFSTR PRFXS,0,35,9		;SIZE OF ATTRIBUTE STRING BLOCK
DEFSTR PRFXV,0,26,9		;VALUE OF ATTRIBUTE PREFIX
DEFSTR PRFXL,0,17,18		;LINK TO NEXT ATTRIBUTE ON CHAIN

; Actual TIMER block

DEFSTR TIMLNK,0,35,36		; Link to next block (Q)
DEFSTR TIMTIM,1,35,36		; Time word (when clock should go off)
DEFSTR TIMFRK,2,35,18		; System fork handle to be PSI'd
DEFSTR TIMJOB,2,17,12		; Job # that set the clock
DEFSTR TIMCHN,2,5,6		; Channel for PSI
DEFSTR TIMKNL,3,35,36		; Back link to previous clock
TIMBSZ==:4			; Get a 4 word block for timer

;STRUCTURE OF ADDRESSES ON PHYSICAL DRUM

MSKSTR DRSEC,,000077		;DRUM SECTOR FIELD
MSKSTR DRTRK,,777700		;DRUM TRACK FIELD
;STANDARD ENTRY SEQUENCE FOR NORMAL (NON-HIGH SPEED) MONITOR CALLS

DEFINE MCENT<>

;PROCEDURE TO ESTABLISH NORMAL JSYS CONTEXT WHEN ENTERING MONITOR
;THROUGH SOME WAY OTHER THAN NORMAL JSYS

DEFINE MCENTR <JSP CX,MENT0>

;RETURN FROM NORMAL JSYS CONTEXT.  SKIP (SUCCESS) CASE.
; SEE ERROR RETURNS FOR NOSKIP CASES.

DEFINE SMRETN <JRST SKMRTN>

;RETURN GOOD FROM NEW CONVENTION JSYS (ITRAP IS BAD RETURN)

DEFINE MRETNG <JRST MRETN>

;INTERNAL MONITOR CALL - DOES NOT CHANGE PREVIOUS CONTEXT.  ADDRESS
;SHOULD BE JSYS ENTRY POINT, E.G. .GTJFN.
;	IMCALL ADDRESS,SECTION

DEFINE IMCALL (ADR,SEC)<
	JSP CX,IMCLL0
	IFB <SEC>,<ADR>
	IFNB <SEC>,<SEC,,ADR>
   >

DEFINE GTOKM	(FUN,ARGS,EXTRA,BLKADR) <
	SKIPGE CX,GTOKPR+FUN	;SEE IF NEED TO VERIFY IT
	SKIPA			;YES. DO VERIFICATION CODE THEN
	TXNN CX,SF%DOK		;IF DEFAULT, NEED TO VERIFY
	CALL [	JUMPGE CX,[MOVEI T1,GOKER2 ;IF DENY
			   RETSKP] ;INDICATE SUCH
		ADJSP P,4	;ALLOCATE STACK
		DMOVEM T1,-3(P)		;SAVE TEMPS
		DMOVEM T3,-1(P)
		PUSH P,[0]
		..GOKN==1
		IRP ARGS,<
		..GOKN=..GOKN+1
		PUSH P,ARGS>
		MOVEI T3,..GOKN
		MOVEI T1,FUN
		MOVEI T2,1-..GOKN(P)
		IFB <BLKADR>,<SETZ T4,>
		IFNB <BLKADR>,<MOVEI T4,BLKADR>
		CALL GETOKM		;CALL MONITOR ROUTINE
		 JRST [	MOVE T2,-2-..GOKN(P) ;RESTORE T2
			DMOVE T3,-1-..GOKN(P)
			ADJSP P,-..GOKN-4	;RESET STACK
			RETSKP] ;;INDICATE ERROR
		DMOVE T1,-3-..GOKN(P)	;RESTORE AC'S
		DMOVE T3,-1-..GOKN(P)
		ADJSP P,-..GOKN-4	;RESET STACK
		RET]		;;GOOD RETURN
	 SKIPA		;;GOOD RETURN
	IFNB <EXTRA>,<JRST EXTRA> ;;IF USER ERROR RETURN, DO IT
	IFB <EXTRA>,<ITERR ()>
>  ;END GTOKM MACRO
;MONITOR ERROR CONDITIONS.  ALL TAKE ERROR CODE AS ARGUMENT.
;IF NO ARGUMENT GIVEN, ERROR CODE ASSUMED TO ALREADY BE IN A.
;IF 'EXTRA' APPEARS AS AN ARGUMENT, THEN EXTRA CODE CAN BE
;SPECIFIED WHICH WILL BE EXECUTED BEFORE THE ERROR CODE IS LOADED

;INSTRUCTION TRAP ERROR

DEFINE ITERR (ERN,EXTRA)<
	IFNB <ERN'EXTRA>,<
	JRST [	EXTRA
	   IFNB <ERN>,<MOVEI 1,ERN>
		JSP 2,ITRAP1]>
	IFB <ERN'EXTRA>,<
	JSP 2,ITRAP1>>

;JSYS ERROR RETURN. STORE ERROR CODE IN LSTERR AND RETURN IT IN
;AC1

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


;JSYS ERROR RETURN.  STORE ERROR CODE IN LSTERR BUT DO NOT
;RETURN IT IN AN AC

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

;ERRJMP - LOAD ERROR CODE THEN JUMP

DEFINE ERRJMP (ERN,JMP)<
	JRST [	MOVEI 1,ERN
		JRST JMP]>
;LOCAL CALL ERROR RETURN

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

;
; DTB RETURN AND DISPATCH MACROS

DEFINE DTBSKP<	IFIW!RSKP>

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

DEFINE DTBDSP (ROU) <IFIW!ROU>

;JSYS ERROR RETURN - UNLOCK JFN, RETURN ERROR CODE IN AC1 AND LSTERR

DEFINE ERUNLK(ERRORN,EXTRA)<
	JRST [	EXTRA
		IFDIF <ERRORN>,<>,<MOVEI A,ERRORN>
		JRST ERUNLD]>
; STANDARD ENTRY MACROS FOR SECTION MANIPULATION

;MACRO TO CAUSE SUBROUTINE TO RUN IN EXTENDED SECTION
;Causes automatic return to section of caller on return.

DEFINE EA.ENT <
	JSP CX,$EAENT>

;MACRO TO CAUSE ROUTINE TO RUN IN SECTION 0
;Causes automatic return to section of caller on return.

DEFINE S0.ENT <
	JSP CX,$S0ENT>

;The following macros are OBSOLETE.  Any new uses should be avoided.

; ENTER SECTION 1 AND PRESERVE FLAGS

DEFINE SE1ENT <CALL SECALL>

;SE1CAL IS THE SAME AS SE1ENT EXCEPT THAT
;IT ASSUMES THAT THERE IS A RETURN PC ON THE STACK THAT NEEDS
;TO BE CLEARED OF THE FLAGS BITS SO IT WILL RETURN WITHOUT
;A SECTION GREATER THAN 27 BUGCHECK.

DEFINE SE1CAL <CALL SECALE>

; ENTER SECTION 0

; ENTER SECTION 0 IS USED TO GET FROM A NON-ZERO SECTION INTO
; SECTION 0 IT ASSUMES THAT THERE IS A STACK.

DEFINE SE0ENT <CALL SE0CAL>
;SCHEDULING CONTROL MACROS

DEFINE NOSKED <JSP CX,NOSK11>

DEFINE OKSKED <JSP CX,OKSK11>

;NOSKED AND OKSKED FOR CODE POSSIBLY BEING RUN UNDER SCHEDULER
;OBSOLETE - NOSKED AND OKSKED ARE NOW EQUIVALENT

DEFINE NOSKD1 <JSP CX,NOSK11>

DEFINE OKSKD1 <JSP CX,OKSK11>

;CRITICAL SECTION - LIKE NOSKED BUT DOES NOT PREVENT RUNNING OTHER
;FORKS IF PAGE FAULT

DEFINE CSKED  <JSP CX,CRSKD0>

DEFINE ECSKED  <JSP CX,ECSKD0>

;FLAG WAITING FORK NOW UNBLOCKED

DEFINE FSKED <AOS QSKED>

;VARIOUS CALLS TO SCHEDULER

;NORMAL DISMISS

DEFINE MDISMS <JSP CX,EDMS0>

;DISMISS AND HOLD IN BALSET FOR SPECIFIED TIME-- USED FOR BLOCKS
;WHICH ARE EXPECTED TO BE SHORT
; HT = TIME IN MILLISECONDS

DEFINE HDISMS (HT)<
   IFNB <HT>,<
	MOVEI 2,HT>
	JSP CX,EDMSH>

;PAGE FAULT DISMISS

DEFINE PDISMS <JSP CX,SCHEDP>

;PAGE FAULT DISMISS PLUS OKSKED

DEFINE RDISMS <JSP CX,SCHEDR>

;WAIT 100 MS IN BALSET, RETURN .-1

DEFINE CBLK0 <JSP CX,BLOCK0>

;WAIT 100 MS NOT IN BALSET, RETURN .-1

DEFINE CBLK1 <JSP CX,BLOCK1>
;PSI CONTROL

DEFINE NOINT <AOS INTDF>

DEFINE OKINT <XCT INTDFF>

;LET PSI SEE INTERRUPT REQUESTS

DEFINE CHKINT<
	CALL CKINT0>

DEFINE TSTINT <SKIPE PSIBW>

;STANDARD LOCK

DEFINE LOCK(LCK,FAIL)<
	AOSE LCK
	IFB <FAIL>,<
	  CBLK1	>
	IFNB <FAIL>,<
	  FAIL>>

DEFINE UNLOCK(LCK)<
	SETOM LCK>
;SYSTEM LOCKS

;New system locks should be added to this list.  The format is as follows:

;	LK Name,Check,Access,Address

;	where Name = name of lock
;	      Check = kind of checking before granting lock (FAST or SLOW)
;	      Access = whether or not lock used across LCS (LOCAL or GLOBAL)
;	      Address = address of first word of 4-word lock block


DEFINE LK(NAML,SLOWF,GLOBF,ADDR),<	;This definition of LK assigns
IFN<GLOBF>,<IFE<SLOWF>,<PRINTX ?ERROR IN LOCK DEFINITION. LOCK CAN'T BE FAST AND GLOBAL>>
LOKIDX==LOKIDX+1
NAML==:LOKIDX!SLOWF!GLOBF		; global values to the lock
>

DEFINE ALLOKS <

LK DEVLKK,FAST,LOCAL,DEVL0K
;LK BTLKK,FAST,LOCAL,BTL0K
;LK DMPLKK,FAST,LOCAL,DMPL0K
;LK FELKK,FAST,LOCAL,FEL0K
;LK IDVLKK,FAST,LOCAL,IDVL0K
;LK NCPLKK,FAST,LOCAL,NCPL0K
;LK OUTLKK,FAST,LOCAL,OUTL0K
;LK NODLKK,FAST,LOCAL,NODL0K
;LK LLLLKK,FAST,LOCAL,LLLL0K
;LK STRLKK,FAST,LOCAL,STRL0K
;LK LPTLKK,FAST,LOCAL,0
;LK MTALKK,FAST,LOCAL,0
;LK CDPLKK,FAST,LOCAL,CDPL0K
;LK CDRLKK,FAST,LOCAL,CDRL0K
;LK MTALKK,FAST,LOCAL,0
;LK PLTLKK,FAST,LOCAL,0
;LK PTPLKK,FAST,LOCAL,PTPL0K
;LK PTRLKK,FAST,LOCAL,PTRL0K
;LK FGLKK,FAST,LOCAL,FGL0K
;LK SNPLKK,FAST,LOCAL,SNPL0K
;LK USGLKK,FAST,LOCAL,USGL0K
;LK ACTLKK,FAST,LOCAL,ACTL0K
;LK ASCLKK,FAST,LOCAL,ASCL0K
;LK GOKLKK,FAST,LOCAL,GOKL0K
;LK TIMLKK,FAST,LOCAL,TIML0K
;LK CRJLKK,FAST,LOCAL,CRJL0K
;LK LDTLKK,FAST,LOCAL,LDTL0K
;LK JSTLKK,FAST,LOCAL,JSTL0K
;LK DRCLKK,FAST,LOCAL,DRCL0K
;LK JFNLKK,FAST,LOCAL,JFNL0K
;LK FILLKK,FAST,LOCAL,FILL0K
LK ENQLKK,FAST,LOCAL,ENQL0K
LK PIDLKK,FAST,LOCAL,PIDL0K
;LK JSFLKK,FAST,LOCAL,JSFL0K
;LK JBCLKK,FAST,LOCAL,JBCL0K
;LK SFRLKK,FAST,LOCAL,SFRL0K
;LK JFRLKK,FAST,LOCAL,JFRL0K
>
;STANDARD LOCK


FAST==0
SLOW==1B0
LOCAL==0
GLOBAL==1B1
LOKIDX==0				;Count of locks


	ALLOKS				;Assign locks

DEFINE LK(NAML,SLOWF,GLOBF,ADDR),<
	ADDR>				;This redefinition sets up a
					; pointer to the lock block

;LOCK BLOCK DEFINITIONS

LOKWRD==0				;-1 if unlocked
LOKFRK==1				;Fork with lock
LOKCNT==2				;Count of times locked
LOKPHI==3				;Index of previous highest lock held
LOKFLG==4				;Flags defining lock
LOKHLD==5				;State of global lock
					;LOKHLD HAS TWO USES, LOCK CACHING WHEN
					;THE LOCK IS NOT HELD AND STATE WORD
					;WHEN LOCK IS BEING REQUESTED GLOBALLY.
LOKWAT==6				;LOCK TIMEOUT FOR GLOBAL REQUEST
LOKFRE==7				;SCHEDULER TEST WORD. GOES FROM 0 TO -1
					;WHEN REMOTE LOCKER FREES THE LOCK
LOKLEN==10				;Length of lock blocks


DEFINE LCKINI(NAML,IDX),<			;Initialize lock blocks
	PUSH P,T1
	PUSH P,T2
	IFNB <IDX>,<MOVE T2,IDX>
	HRRZ T1,[NAML]
	MOVE T1,LCKTAB(T1)		;Get address of lock block
	IFNB <IDX>,<ADD T1,T2>
	SETOM LOKWRD(T1)		;Initialize lock
	SETOM LOKFRK(T1)		; And fork
	SETZM LOKCNT(T1)		; And count of times locked
	SETZM LOKHLD(T1)		;TURN OFF QUICK LOCKING
	MOVE T2,[NAML]			;Get flags and index
	MOVEM T2,LOKFLG(T1)		; and store
	POP P,T2
	POP P,T1>
DEFINE LOKK(NAML,FAIL,IDX,%LA,%LB,%LC,%LX,%LY,%LZ),<
IFNB <NAML>,<
    IFGE NAML,<
%LA:	PUSH P,T1
	PUSH P,T2
	IFNB <IDX>,<MOVE T1,IDX
		    ADD T1,LCKTAB+<777777&NAML>
	>			;END OF IFNB
	IFB <IDX>,<MOVE T1,LCKTAB+<777777&NAML>>
	AOSE (T1)
	IFB <FAIL>,<CBLK1>
	IFNB <FAIL>,<
	IFNSK.
	   POP P,T2
	   POP P,T1
	   SKIPA
	   JRST %LA		;THIS LINE IS FOR FAIL CODE THAT
				; BELIEVES THIS IS THE LOCK PC
	   FAIL
	   JRST %LX
	ENDIF.
	>			;END OF IFNB
	MOVEI T1,777777&NAML	;GET NAME OF LOCK
	MOVE T1,LCKTAB(T1)	;GET IT'S DATA BASE
	MOVE T2,FORKX		;GET CURRENT FORK
	MOVEM T2,LOKFRK(T1)	;SAVE IT IN DATA BASE
	POP P,T2
	POP P,T1
%LX:
    >				;END OF IFGE
    IFL NAML,<
%LB:	PUSH P,T1
	PUSH P,T2
	IFB <IDX>,<SETZ T2,>
	IFNB <IDX>,<MOVE T2,IDX>
	MOVE T1,[NAML]
	CALL GETLOK
	 IFB <FAIL>,<CBLK1>
	 IFNB <FAIL>,<
	 IFNSK.
	    POP P,T2
	    POP P,T1
	    SKIPA
	    JRST %LB		;THIS LINE IS FOR FAIL CODE THAT
				; BELIEVES THIS IS THE LOCK PC
	    FAIL
	    JRST %LY
	 ENDIF.
	 >			;END OF IFNB
	POP P,T2
	POP P,T1
%LY:
    >				;END OF IFL
>				;END OF IFNB
IFB <NAML>,<
%LC:	PUSH P,T1
	PUSH P,T2
	SETZ T2,
	MOVE T1,IDX
	CALL LOKTYP
	 IFB <FAIL>,<CBLK1>
	 IFNB <FAIL>,<
	 IFNSK.
	    POP P,T2
	    POP P,T1
	    SKIPA
	    JRST %LC		;THIS LINE IS FOR FAIL CODE THAT
				; BELIEVES THIS IS THE LOCK PC
	    FAIL
	    JRST %LZ
	 ENDIF.
	>			;END OF IFNB
	POP P,T2
	POP P,T1
%LZ:
>>				;END OF IFB, END OF LOKK
DEFINE UNLOKK(NAML,IDX),<
IFNB <NAML>,<
    IFGE NAML,<
	PUSH P,T1
	IFNB <IDX>,<	MOVE T1,IDX
			ADD T1,LCKTAB+<777777&NAML>
>
	IFB <IDX>,<MOVE T1,LCKTAB+<777777&NAML>>
	SETOM (T1)
	POP P,T1>
    IFL NAML,<
	PUSH P,T1
	PUSH P,T2
	IFB <IDX>,<SETZ T2,>
	IFNB <IDX>,<MOVE T2,IDX>
	MOVE T1,[NAML]
	CALL RELLOK
	POP P,T2
	POP P,T1>>
IFB <NAML>,<
	PUSH P,T1
	PUSH P,T2
	SETO T2,
	MOVE T1,IDX
	CALL LOKTYP
	POP P,T2
	POP P,T1>>
;Macros for defining BUGs


;******* THIS MACRO IS ONLY USED BY TCP AND INET MONITOR MODULES NOW****


;MACROS FOR DEFINING BUGHLT AND BUGCHK STRINGS

;THIS IS THE MACRO THAT APPEARS IN THE CODE.  ITS FIRST ARG IS INF, CHK 
;OR HLT, AND CAUSES ASSEMBLY OF JSR BUGINF, JSR BUGCHK OR JSR BUGHLT
;RESPECTIVELY.  ITS SECOND ARGUMENT IS A GLOBAL SYMBOL WHICH IS TYPED
;OUT AT THE TIME OF THE CHECK.   ITS THIRD ARGUMENT IS A STRING DEFINING
;THE PROBLEM REPRESENTED BY THE CHECK. THE FORTH ARGUMENT IS AN OPTIONAL
;LIST OF REGISTERS TO BE TYPED OUT AND TO BE PUT IN THE SYSERR REPORT.
;A LIMIT OF 4 IS IMPOSED.

BUGMXR==:4
DEFINE OLDBUG (TYP,TAG,STR,REGS,%NAM,%STR)<
	XCT [TAG::	JSR BUG'TYP
		..NRGS==0
		IRP REGS,<
		..NRGS==..NRGS+1
		IFG ..NRGS-BUGMXR,<IF2,<PRINTX %TOO MANY REGISTERS IN DEFINITION OF BUG'TYP TAG>
				STOPI>
		Z REGS>
		SIXBIT /TAG/]
	.PSECT BGSTR
%STR:!	ASCIZ \STR\
	.ENDPS BGSTR
	.PSECT BGPTR
	XWD TAG,%STR
	.ENDPS BGPTR
>

;**** END OF OLD-STYLE BUG DEFINITION ********

;DEFBUG - USED ONLY IN BUGS.MAC.  Arguments:
;
;TYP -	Flavor, HLT, CHK, or INF
;
;TAG -	Name of BUG
;
;MODULE -
;	Name of module in which BUG occurs.  This argument gets verified
;	by the module in which the bug occurs, and a warning is printed if
;	it is wrong.
;
;WORD -	Flavor of BUG.  For instance, HARD for hardware-caused, SOFT for
;	software-caused.
;
;STR -	Short descriptive string describing cause of BUG, which gets printed
;	on CTY when BUG occurs.
;
;LOC -	List of locations whose contents should be displayed when the BUG
;	occurs.  Each location must be followed by a comma and then a one-word
;	descriptor of what the datum represents, for instance UNIT or CHN.
;	Each pair of locations and descriptors must be in angle brackets,
;	and the angle-bracketed pairs must be separated by commas with the
;	entire LOC argument in angle brackets.
;
;HELP -	General documentation for the BUG

BUGMXR==:4
DEFINE DEFBUG (TYP,TAG,MOD,WORD,STR,LOCS,HELP)<
  REPEAT 0,<			;CHECK FOR ALPHABETICAL NOT PRESENTLY USED
IF1,<IFL <<SIXBIT /TAG/>-..BV>,<PRINTX % At BUG'TYP TAG, something is out of alphabetical order in BUGS.MAC>>
..BV==SIXBIT /TAG/
  >
IFB <HELP>,<
DEFINE TAG(ODATA)<
CONCHK(TYP,TAG,MOD,WORD,<ODATA>,<STR>,<LOCS>,<>)
>>
IFNB <HELP>,<
DEFINE TAG(ODATA) <	;;DEFINE MACRO WITH NAME OF BUG

CONCHK(TYP,TAG,MOD,WORD,<ODATA>,<STR>,<LOCS>,<O.K.>)
>>>

CURBUG==1B0		;FOR ALPHABETICAL ORDER CHECKING

DEFINE CONCHK (TYP,TAG,MOD,WORD,ODATA,STR,LOCS,HELP,%STR)
<

IF2,<IFDIF <ODATA>,<LOCS>,<PRINTX % "ODATA" within BUG'TYP TAG in MOD'.MAC disagrees with "LOCS" in BUGS.MAC>>

IF1,IFN <<SIXBIT /MOD/>-OURTTL>,<PRINTX % BUGS.MAC claims BUG'TYP TAG is in module MOD, but it's in this one.>
;;The reason it's IF1 instead of IF2 is so we'll catch things like
;;there being a RELBAD: in PAGEM.MAC and a RELBAD BUGCHK in FREE.MAC,
;;which causes many "P" errors when compiling PAGEM.  The solution is to
;;change RELBAD: in PAGEM to something else.

IF2,<IFB <HELP>,<PRINTX % BUG'TYP TAG is undocumented in BUGS.MAC.>>

;;Make listing include info about BUG:
	LALL
	  ;BUG type:    BUG'TYP, WORD
	  ;BUG message: STR
	       SALL
IF1,<SYN TAG,TAGSAV			;;SAVE THE MACRO DEFINITION
PURGE TAG			;;KILL OFF MACRO IN BLANK PSECT
SYN TAGSAV,TAG			;;REDEFINE MACRO IN CORRECT PSECT
PURGE TAGSAV>			;;GET RID OF DUMMY SYMBOL
	XCT [
	TAG::
	  IFIDN <TYP><HLT>,<
		JSR BUGHLT>	;;USE JSR FOR BUGHLT
	  IFDIF <TYP><HLT>,<
		PUSHJ P,BGC'TYP> ;;USE PUSHJ FOR OTHERS
	DOLOCS <LOCS>,TYP,TAG
		SIXBIT /TAG/]
	XLIST
	.PSECT BGSTR
%STR:!	ASCIZ \STR\
	.ENDPS BGSTR
	.PSECT BGPTR
   IF2,<PURGE TAG>		;;HACK FOR MACRO 53A
	XWD TAG,%STR
	.ENDPS BGPTR
	LIST
>

;MACRO USED TO HANDLE EACH PAIR OF LOCATION NAMES AND DESCRIPTIONS

DEFINE DOLOCS (FOO,TYP,TAG)
<		..NRGS==0
	IRP FOO,<DOLOC2 FOO,TYP,TAG>
>

DEFINE DOLOC2 (FOO,TYP,TAG)
<	DOLOC1 (FOO,TYP,TAG)
>

DEFINE DOLOC1 (LOCADR,LOCNAM,TYP,TAG)
<	Z LOCADR
IF2,IFB <LOCNAM>,<PRINTX % Data item LOCADR in BUG'TYP TAG has no descriptor in BUGS.MAC.>
		..NRGS==..NRGS+1
		IFG ..NRGS-BUGMXR,<IF2,<PRINTX %TOO MANY LOCATIONS IN DEFINITION OF BUG'TYP TAG>>
   >;END DEFINE DOLOC1

;BUG - THIS IS THE MACRO THAT GETS REFERENCED IN THE SOURCE CODE WHERE
;THE BUG IS DETECTED.  THE CALLING SEQUENCE IS:
;
;	BUG (FOO,ODATA)
;
;WHERE "FOO" IS THE NAME OF THE BUG.  ALL THE INFORMATION ABOUT THE BUG,
;INCLUDING EVEN WHETHER THE BUG IS A BUGCHK OR A BUGHLT IS DEFINED IN
;BUGS.MAC, FORCING BUGS.MAC TO BE CURRENT!
;
;ODATA IS THE LIST OF OPTIONAL DATA.  IT IS DUPLICATED IN THE SOURCE MODULE
;IN WHICH THE BUG OCCURS AND THE BUGS.MAC FILE.  IT IS IN THE BUGS.MAC
;FILE FOR DOCUMENTATION PURPOSES.  IT IS IN THE SOURCE MODULE SO PROGRAMMERS KNOW
;WHICH LOCATIONS TO BE CAREFUL OF CLOBBERING IN THE VICINITY OF THE
;BUG

;THERE IS ONE SPECIAL CASE - BUG(NULL) WHICH IS USED AS SPACE FILLER
;INSTEAD OF NOP OR JFCL FOR ROUTINE THAT ALWAYS SKIP, ETC.

DEFINE BUG(TAG,ODATA)<
	IFIDN <TAG><NULL>,<
	 XCT [	PUSHJ P,BGCCHK
		SIXBIT /NULL/]>
	IFDIF <TAG><NULL>,<
	TAG<ODATA>>
>
;End of macros for defining BUGs
;JSBVAR - JSB VARIABLE FACILITY

;USES REGISTER P6 AS BASE POINTER TO VARIABLES ASSIGNED IN THE JSB
;ALLOWS VARIABLES TO BE USED WITHIN LOWER LEVEL ROUTINES
;AND AFTER OTHER THINGS HAVE BEEN PUSHED ON STACK.
;N.B. USES P6 AS FRAME POINTER - MUST NOT BE CHANGED WHILE
;VARIABLES IN USE.


DEFINE JSBVAR (VARS,ERET)<
	..TRR==10		;;REMEMBER CURRENT RADIX
	RADIX 8
	..NV==0			;;INIT COUNT OF JSB WORDS
	IRP VARS,<
	  .TRV1 (VARS)>		;;PROCESS LIST
	JSP CX,.JSSET##		;;ALLOCATE JSB SPACE, SETUP P6
    IFB <ERET>,< ..NV+1,,0 >
    IFNB <ERET>,< ..NV+1,,ERET >
	RADIX ..TRR		;;RESTORE RADIX
	PURGE ..TRR,..NV>	;;CLEAN UP
;USAGE FILE / QUEUE DEFINTIONS

;USAGE QUEUE FOR JOB 0

DEFSTR (UQFCN,0,17,18)		;FUNCTION
DEFSTR (UQLEN,0,35,18)		;LENGTH
DEFSTR (UQLNK,1,35,36)		;LINK TO NEXT OR 0

UQDAT==:2			;OFFSET TO DATA

CKPSIZ==:PGSIZ/10		;ALLOW 8 JOBS/PAGE
				;IE 64 WORDS
;FIELDS FOR THE SIR JSYS AND CHNTAB

MSKSTR (SIVER,,SI%VER)		;VERSION OF SIR (IN T1)
MSKSTR (SILEV,,SI%LEV)		;LEVEL NUMBER (IN CHNTAB)
MSKSTR (SIADR,,SI%ADR)		;ADDRESS OF INTERRUPT ROUTINE (IN CHNTAB)
; Bit definitions in sts (also filsts)

GFLG(OPNF,L,STS,400000)		; File is open
GFLG(READF,L,STS,200000)	; File is ok to read
GFLG(WRTF,L,STS,100000)		; File is ok to write
GFLG(XCTF,L,STS,040000)		; File is ok to execute
GFLG(RNDF,L,STS,020000)		; File is ok to reset pointer (i.e. not append)
GFLG(NONXF,L,STS,010000)	; NON-EXISTENT FILE, DELETE FDB ON RLJFN
GFLG(NWTF,L,STS,004000)		; NO-WAIT ON DUMPI/O
GFLG(LONGF,L,STS,002000)	; File is a long file
GFLG(EOFF,L,STS,001000)		; End of file if read attempted
GFLG(ERRF,L,STS,000400)		; Bytes read may be erroneous
GFLG(NAMEF,L,STS,000200)	; Name is associated with this jfn
GFLG(ASTF,L,STS,000100)		; A * was typed in
GFLG(ASGF,L,STS,000040)		; Jfn is being assigned
GFLG(BLKF,L,STS,000040)		; SERVICE ROUTINE WANTS TO BLOCK
				; SHARES A BIT POSITON WITH ASGF
GFLG(HLTF,L,STS,000020)		; Halt if i-o error
GFLG(WNDF,L,STS,000010)		; A window page has been set up
GFLG(ENDF,L,STS,000004)		; File is past end of maximum length
GFLG(TRNSF,L,STS,000004)	; BIT TIME-SHARED WITH ENDF TO SAY
				; THE JFN IS IN A TRANSITIONAL STATE
				; AND MAY NOT BE ACCESSED
GFLG(SIZF,L,STS,000002)		; Illegal to change size of byte
GFLG(FRKF,L,STS,000001)		; File is restricted to fork in lh(filver)

;NOTE: THIS WORD CONTAINS ALL THE BITS THAT ARE KNOWN TO BE DOCUMENTED FOR
;THE GTSTS JSYS.  ALL OTHER BITS ARE DISCARDED BEFORE RETURNING THE FILE'S
;STATUS.  THEREFORE, WHEN A NEW BIT IS ADDED TO THE STATUS WORD AND IS
;TO BE DOCUMENTED, IT MUST BE ADDED TO THIS WORD

DOCSTS==:OPNF!READF!WRTF!XCTF!RNDF!LONGF!EOFF!ERRF!NAMEF!ASTF!ASGF!HLTF!FRKF!1B18!17B35

MSKSTR(PASLSN,STS,1B18)		;SET TO SKIP LINE NUMBER CHECKING ON ASCII FILES
MSKSTR(SKIPBY,STS,1B19)		;SET BY BYTINA TO REMEMBER IT HAS TO DISCARD
				;  A BYTE ON THE NEXT CALL
GFLG(XQTAF,R,STS,1B20)		;QUOTA EXCEEDED FLAG
GFLG(FILDUD,R,STS,40000)	;SUPPRESS DDMP ACTION IF SET
GFLG(FILINP,R,STS,20000)	;DIRECTION OF I/O IS INPUT
GFLG(FILOUP,R,STS,10000)	;DIRECTION OF I/O IS OUTPUT
GFLG(HLDF,R,STS,4000)		;HOLD IN BALANCE SET IF SET
GFLG(RECF,R,STS,2000)		;END-OF-RECORD SEEN
GFLG(ACRLFF,R,STS,1000)		;ADD CRLF'S AFTER RECORDS ON INPUT

	;Note:  keep CR stuff contiguous - see CRSTUF, DCRSTF (see IO.MAC too)
GFLG(CRNXT,R,STS,400)		;RETURN CR NEXT
GFLG(LFNXT,R,STS,200)		;RETURN LF NEXT
GFLG(FROSTF,R,STS,100)		;Record has been frosted
	GFLG(CRSTUF,R,STS,CRNXT!LFNXT!FROSTF)	;composite CR status field
GFLG(JFNUB,R,STS,40)		;OPEN UNRESTRICTED
GFLG(NSPNUL,R,STS,20)		;NSP NULL RECORD INDICATOR

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

; In flags

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

GFLG(DEVF,R,F,400000)		; Device is specified
GFLG(DIRF,R,F,200000)		; Directory specified
GFLG(NAMF,R,F,100000)		; Name specified
GFLG(EXTF,R,F,040000)		; Extension specified
GFLG(VERF,R,F,020000)		; Version specified
GFLG(PRTF,R,F,010000)		; Protection specified
GFLG(ACTF,R,F,004000)		; Account specified
GFLG(DEVTF,R,F,002000)		; Device was typed in
GFLG(DIRTF,R,F,001000)		; Directory was typed in
GFLG(NAMTF,R,F,000400)		; Name was typed in
GFLG(EXTTF,R,F,000200)		; Extension was typed in
GFLG(VERTF,R,F,000100)		; Version was typed in
GFLG(ACTTF,R,F,000040)		; Account was typed in
GFLG(PRTTF,R,F,000020)		; Protection was typed in
GFLG(TMPTF,R,F,000010)		; Temporary flag was set by type in
GFLG(CNTVF,R,F,000004)		; Control-v typed
GFLG(NNAMF,R,F,000002)		; No name device
GFLG(NVERF,R,F,000001)		; No versions etc.

; Flags in rh of F1 used locally

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

;FLAGS USED IN LOGNAM ONLY

GFLG(PFXFF,R,F1,000001)		; ENTERING A PREFIX FIELD
GFLG(ATRFF,R,F1,000002)		; ENTERING AN ATTRIBUTE VALUE
; Flags in lh of f1 (scan control)

GFLG(GNJFF,L,F1,400000)		; A GNJFN IS BEING DONE
GFLG(STRSF,L,F1,200000)		; SCAN ALL STRUCTURES
GFLG(DIRSF,L,F1,100000)		; Scan directories <*>
GFLG(NAMSF,L,F1,040000)		; Scan names (^*.)
GFLG(EXTSF,L,F1,020000)		; Scan extensions (^.*)
GFLG(VERSF,L,F1,010000)		; Scan versions (;*)
GFLG(RVERF,L,F1,004000)		; Most recent version specified
GFLG(HVERF,L,F1,002000)		; New version specified
GFLG(LVERF,L,F1,001000)		; Lowest version specified
GFLG(FXPRT,L,F1,000400)		; ;P SPECIFIED
GFLG(FXACT,L,F1,000200)		; Account specified with *'s
GFLG(FXTMP,L,F1,000100)		; ;t specified with *'s
GFLG(EXTXF,L,F1,000040)		; Extension was stepped
GFLG(IGIVF,L,F1,000020)		; Ignore fact file is invisible
GFLG(TCONF,L,F1,000010)		; SAW CONFIRMING TERMINATOR
GFLG(DFSTF,L,F1,000004)		; * in default string
GFLG(STARF,L,F1,000002)		; Set by *
GFLG(STEPF,L,F1,000001)		; Step flag

;BITS IN LOCAL FLAG WORD USED BY GTJFN
WLDF==:1B0			; STRING IS A WILD MASK
DWLDF==:1B1			; DEFAULT STRING IS WILD
VERFF==:1B2			;COLLECTING A VERSION
SAWALT==:1B3			;SAW AN ALTMODE WHILE SCANNING
SWBRKT==:1B4			;SAW A SQUARE BRACKET FOR DIRECTORY
SAWCR==:1B5			;SAW A CR
SAWSLN==:1B6			;SAW A SYSTEM LOGICAL NAME
TMPFL==:1B7			;LAST ATTRIBUTE WAS ;T
PREFXF==:1B8			;GATHERING A PREFIX OF AN ATTRIBUTE
ARBATF==:1B9			;GATHERING THE DATA PART OF AN ATTRIBUTE
ATRF==:1B10			;HAVE SEEN AN ATTRIBUTE
RIEFLG==:1B11			;RETURN ON EMPTY FLAG
SAWF==:1B12			;SAW A CONTROL-F
NOLOGF==:1B13			;DON'T USE LOGICAL NAMES



;FLAGS IN DEVCHR

DV%OPN==:1B5			; FILE OPEN ON DEVICE

;FLAGS IN JOBNAM

JWAKEF==:1B0			;WAKEUP SIGNAL TO THIBR

;FLAGS IN REMFGS

GCF1==:1B0		;FULL GC DONE SINCE LAST REMBSJ/REMBSF

;BITS IN STARTF (SYSTEM STARTUP FLAG WORD)

MI%RFS==:1B0		;REFRESH BEING DONE
MI%RCN==:1B1		;RECONSTRUCTION OF ROOT-DIRECTORY
MI%HMB==:1B2		;HOME BLOCKS WERE REWRITTEN
MI%BTB==:1B3		;BIT TABLE BEING REBUILT
MI%XTB==:1B4		;INDEX TABLE MUST BE REBUILT
;PROCEDURE FOR DEFINING BLOCKS OF NAMED ITEMS

DEFINE DOPC (MAC,IVAL)<
   DEFINE MAC (NAM,SIZ)<
	NAM=:..PC
	..PC=..PC+SIZ>
   DEFINE S'MAC (NAM,SIZ)<
	NAM==:..PC
	..PC=..PC+SIZ>
   ..PC==IVAL
>

; Jsys Trap Block definitions

	DOPC (JTB,0)		;

JTBTL==:<1000+^D35>/^D36	; Length of JSYS trap bit tables
SJTB  JTBMN,1			; RH: forkn of immediate monitor
SJTB  JTBAL,JTBTL		; Bit table of all JSYSes being trapped
SJTB  JTBIM,JTBTL		; Bit table of JSYSes trapped by im. mon.
SJTB  JTBSIZ,0			; Length of Jsys Trap Block

; The length of the JTBs is 31 words, hence there are 33 blocks in 2 pages
; with one word left over, the first word of the JTB page is used as a
; free storage bit table. The actual number of blocks needed is, worst case,
; one per fork (NUFKS) so the number of page needed and the bit table should
; be based on the following calculations.
; NJTBS=<NUFKS*JTBSIZ+1000>/1000	;number of JTB pages needed

DEFSTR JTIMP,JTBMN,35,18	; immed mon pointer (forkn of im. mon.)
DEFSTR JTMCN,JTMNW,17,6		; monitor's channel to send PSI
DEFSTR JTMNI,JTMNW,35,18	; forkn of the monitor we interrupted
DEFSTR JTJNO,KIMUU1+1,35,18	; Jsys number for last USER jsys
DEFSTR JTFRK,JTTFK,35,18	; Trapped forkn; set by trapped fork

; Device dispatch indices

	DOPC (DTB,0)

SDTB DLUKD,1			; Directory setup routine
SDTB NLUKD,1			; Name lookup
SDTB ELUKD,1			; Extension lookup
SDTB VLUKD,1			; Version lookup
SDTB PLUKD,1			; Protection insertion
SDTB ALUKD,1			; Account insertion
SDTB SLUKD,1			; Status insertion (temporary permanent etc)
SDTB OPEND,1			; Open file
SDTB BIND,1			; Byte input
SDTB BOUTD,1			; Byte output
SDTB CLOSD,1			; Close file
SDTB REND,1			; Rename
SDTB DELD,1			; Delete file
SDTB DMPID,1			; Dump mode input
SDTB DMPOD,1			; Dump mode output
SDTB MNTD,1			; Mount device
SDTB DSMD,1			; Dismount device
SDTB INDD,1			; Initialize directory of device
SDTB MTPD,1			; Do mtape operation
SDTB GDSTD,1			; Get device status
SDTB SDSTD,1			; Set device status
SDTB RECOUT,1			; FORCE RECORD OUT, (SOUTR JSYS)
SDTB RFTADD,1			; READ FILE TIME AND DATE
SDTB SFTADD,1			; SET FILE TIME AND DATE
SDTB JFNID,1			; SET JFN FOR INPUT
SDTB JFNOD,1			; SET JFN FOR OUTPUT
SDTB ATRD,1			; CHECK ATTRIBUTE
;STANDARD CALL TO UNLOCK MAPPED DIRECTORY

DEFINE ULKDIR <CALL ULKMD0>

;DIRECTORY RELATED DEFINITIONS
DRMXSZ==500			;NUMBER OF PAGES FOR EXTENDED
MXDRNM==100			;NUMBER OF PAGES FOR IDXTAB
.IDXLN==2			;NUMBER OF ELEMENTS PER ENTRY IN INDEX

;NOTE: CHECKD CONTAINS A COPY OF THESE DEFINITIONS; WHEN CHANGING
;THEM HERE, CHANGE THEM IN CHECKD ALSO

;DIRECTORY HEADER (FOR PAGE 0; FIRST 3 WORDS ARE REPEATED ON
;SUBSEQUENT PAGES)

DEFSTR DRTYP,0,17,18		;BLOCK TYPE OF DIRECTORY (.TYDIR)
DEFSTR DRVER,0,23,6		;VERSION # OF DIRECTORY
DEFSTR DRHLN,0,35,12		;LENGTH OF HEADER AREA
DEFSTR DRRPN,1,17,18		;RELATIVE PAGE # WITHIN DIRECTORY
DEFSTR DRNUM,1,35,18		;DIRECTORY NUMBER
DEFSTR DRFFB,.DRFFB,35,36	;FIRST FREE BLOCK ON THIS PAGE
DEFSTR DRSBT,3,35,36		;ADDRESS OF BOTTOM OF SYMBOL TABLE
DEFSTR DRSTP,4,35,36		;ADDRESS OF TOP OF SYMBOL TABLE
DEFSTR DRFTP,5,35,36		;ADDRESS OF LAST USED WORD + 1
DEFSTR DRFBT,6,35,36		;POINTER TO FREE POOL BIT TABLE
DEFSTR DRDPW,7,35,36		;DEFAULT FILE PROTECTION
DEFSTR DRPRT,10,35,36		;DEFAULT DIRECTORY PROTECTION
	DEFSTR DRPOW,10,23,6	;OWNER FIELD
	DEFSTR DRPGP,10,29,6	;GROUP FIELD
	DEFSTR DRPWL,10,35,6	;WORLD FIELD
DEFSTR DRDBK,11,35,36		;BACKUP SPECIFICATION
DEFSTR DRLIQ,12,35,36		;LOGIN DISK QUOTA
DEFSTR DRLOQ,13,35,36		;LOGGED OUT QUOTA
DEFSTR DRDCA,14,35,36		;CURRENT DIR ALLOCATION
DEFSTR DRNAM,15,35,36		;POINTER TO NAME STRING
DEFSTR DRPSW,16,35,36		;POINTER TO PASSWORD STRING
DEFSTR DRPRV,17,35,36		;PRIVILEGE BITS
DEFSTR DRMOD,20,35,36		;MODE BITS
DEFSTR DRDAT,21,35,36		;TIME AND DATE OF LAST LOGIN
DEFSTR DRUGP,22,35,36		;USER GROUPS
DEFSTR DRDGP,23,35,36		;DIRECTORY GROUPS
DEFSTR DRUDT,24,35,36		;LAST UPDATE TIME OF DIR
DEFSTR DRSDC,25,35,18		;COUNT OF SUBDIRECTORIES
DEFSTR DRSDM,25,17,18		;MAXIMUM NUMBER OF SUBDIRECTORIES
DEFSTR DRCUG,26,35,36		;CRDIR ALLOWED SPECIFYING THESE USER GRPS
DEFSTR DRACT,27,35,36		;POINTER TO DIRECTORY DEFAULT ACCOUNT
DEFSTR DRDNE,30,35,36		; Default online expiration date/interval
DEFSTR DRDFE,31,35,36		; Default offline expiration date/interval

	.DIHL0==:100		;LENGTH OF DIR PAGE 0 HEADER (+ SPARES)
	.DIHL1==:3		;LENGTH OF HEADER FOR DIR PAGES 1 & UP
	.DRFFB==:2		;OFFSET OF FIRST FREE BLOCK POINTER

;GENERAL FORMAT FOR ALL BLOCKS

DEFSTR BLKTYP,0,17,18		;TYPE CODE FOR STANDARD FORMAT BLOCKS
				;NMTYP, EXTYP, ACTYP, SYMTY, DRTYP,
				;UNTYP, FBTYP, AND FRTYP
DEFSTR BLKVER,0,23,6		;VERSION NUMBER OF BLOCK
DEFSTR BLKLEN,0,35,12		;LENGTH OF STANDARD FORMAT BLOCK

;SYMBOL TABLE

;	SYMBOL TABLE HEADER

DEFSTR SYMTY,0,17,18		;SYMBOL TABLE TYPE CODE (.TYSYM)
DEFSTR SYMDN,0,35,18		;DIR NUMBER OF SYMBOL TABLE

;	SYMBOL TABLE ENTRIES

	SY%ET==:7B2		;SYMBOL TABLE ENTRY TYPE MASK
	.SYMAD==:0		;POSITION OF ADDRESSES IN SYMBOL TABLE
	.SYMVL==:1		;POSITION OF SYMBOL HASH VALUE WORD
	.SYMLN==:2		;# OF WORDS IN A SYMBOL TABLE ENTRY
DEFSTR SYMET,.SYMAD,2,3		;SYMBOL TABLE ENTRY TYPE
DEFSTR SYMAD,.SYMAD,35,33	;ADDRESS OF BLOCK IN DIR FOR THIS SYM
DEFSTR SYMVL,.SYMVL,35,36	;FIRST 5 CHARACTERS OF NAME OR ACCOUNT
	.ETNAM==:0		;ENTRY TYPE OF NAME
	.ETUNS==:2		;ENTRY TYPE OF USER NAME
	.ETACT==:4		;ENTRY TYPE OF ACCOUNT

;NAME BLOCK

DEFSTR NMTYP,0,17,18		;NAME BLOCK TYPE CODE (.TYNAM)
DEFSTR NMLEN,0,35,12		;LENGTH OF NAME BLOCK
DEFSTR NMVAL,1,35,36		;FIRST 5 CHARACTERS OF NAME STRING

;EXTENSION BLOCK

DEFSTR EXTYP,0,17,18		;EXTENSION BLOCK TYPE CODE (.TYEXT)
DEFSTR EXLEN,0,35,12		;LENGTH OF EXTENSION BLOCK

;ACCOUNT STRING BLOCK

DEFSTR ACTYP,0,17,18		;ACCOUNT STRING BLOCK TYPE CODE (.TYACT)
DEFSTR ACLEN,0,35,12		;LENGTH OF ACCOUNT BLOCK
DEFSTR ACSHR,1,35,36		;SHARE COUNT OF ACCOUNT STRING
	.ACVAL==2		;START OF ACCOUNT STRING
DEFSTR ACVAL,.ACVAL,35,36	;FIRST 5 CHARACTERS OF ACCOUNT STRING

;USER NAME STRING BLOCK

DEFSTR UNTYP,0,17,18		;USER STRING BLOCK TYPE CODE (.TYUNS)
DEFSTR UNLEN,0,35,12		;LENGTH OF USER NAME BLOCK
DEFSTR UNSHR,1,35,36		;SHARE COUNT OF USER NAME STRING
DEFSTR UNVAL,2,35,36		;FIRST 5 CHARS OF USER NAME STRING

;FREE POOL BLOCK

	.FRNFB==:1		;OFFSET OF NEXT FREE BLOCK POINTER
	.FRHLN==:2		;LENGTH OF FREE BLOCK HEADER
DEFSTR FRTYP,0,17,18		;FREE BLOCK TYPE CODE (.TYFRE)
DEFSTR FRVER,0,23,6		;VERSION # OF FREE BLOCK
DEFSTR FRLEN,0,35,12		;LENGTH OF THIS FREE BLOCK
DEFSTR FRNFB,.FRNFB,35,36	;POINTER TO NEXT FREE BLOCK

;FDB DEFINITIONS (OTHERS IN MONSYM)

DEFSTR FBTYP,.FBHDR,17,18	;FDB TYPE CODE (.TYFDB)
DEFSTR FBVER,.FBHDR,23,6	;VERSION # OF FDB (0 := PRE-V2)
DEFSTR FBLEN,.FBHDR,35,12	;LENGTH OF FDB
DEFSTR FBFLG,.FBCTL,35,36	;FLAGS
	MSKSTR (FBTMP,.FBCTL,FB%TMP)
	MSKSTR (FBPRM,.FBCTL,FB%PRM)
	MSKSTR (FBNEX,.FBCTL,FB%NEX)
	MSKSTR (FBDEL,.FBCTL,FB%DEL)
	MSKSTR (FBNXF,.FBCTL,FB%NXF)
	MSKSTR (FBLNG,.FBCTL,FB%LNG)
	MSKSTR (FBSHT,.FBCTL,FB%SHT)
	MSKSTR (FBDIR,.FBCTL,FB%DIR)
	MSKSTR (FBNOD,.FBCTL,FB%NOD)
	MSKSTR (FBARC,.FBCTL,FB%ARC)
	MSKSTR (FBINV,.FBCTL,FB%INV)
	MSKSTR (FBOFF,.FBCTL,FB%OFF)
DEFSTR FBEXL,.FBEXL,35,33	;LINK TO NEXT EXTENSION FDB
DEFSTR FBADR,.FBADR,35,36	;DISK ADDRESS OF INDEX BLOCK
DEFSTR FBPRT,.FBPRT,35,36	;PROTECTION OF THE FILE
DEFSTR FBCRE,.FBCRE,35,36	;TIME AND DATE OF LAST WRITE
DEFSTR FBLW0,.FBUSE,17,18	;VER #0 LAST WRITER DIR #
DEFSTR FBAT0,.FBUSE,35,18	;VER #0 AUTHOR DIR #
DEFSTR FBAUT,.FBAUT,35,36	;POINTER TO AUTHOR STRING
DEFSTR FBLWR,.FBLWR,35,36	;POINTER TO LAST WRITER STRING
DEFSTR FBGEN,.FBGEN,17,18	;GENERATION # OF FILE
DEFSTR FBDRN,.FBDRN,35,18	;DIR NUMBER (IF THIS IS A DIR FILE)
DEFSTR FBACT,.FBACT,35,36	;ACCOUNT # OR POINTER TO ACCOUNT BLOCK
DEFSTR FBGNR,.FBBYV,5,6		;GENERATION RETENTION COUNT
DEFSTR FBBSZ,.FBBYV,11,6	;BYTE SIZE OF DATA IN FILE
DEFSTR FBMOD,.FBBYV,17,4	;MODE OF LAST WRITE TO FILE
DEFSTR FBNPG,.FBBYV,35,18	;# OF PAGES IN FILE
DEFSTR FBSIZ,.FBSIZ,35,36	;# OF BYTES IN THE FILE
DEFSTR FBCRV,.FBCRV,35,36	;CREATION TIME AND DATE OF FILE
DEFSTR FBWRT,.FBWRT,35,36	;DATE AND TIME OF LAST USER WRITE
DEFSTR FBREF,.FBREF,35,36	;TIME AND DATE OF LAST NON-WRITE ACCESS
DEFSTR FBNWR,.FBCNT,17,18	;# OF WRITES TO FILE
DEFSTR FBNRF,.FBCNT,35,18	;# OF REFERENCES TO FILE
DEFSTR FBBK0,.FBBK0,35,36	;BACKUP WORD 0
DEFSTR FBBK1,.FBBK1,35,36	;BACKUP WORD 1
DEFSTR FBBK2,.FBBK2,35,36	;BACKUP WORD 2
DEFSTR FBBBT,.FBBBT,35,36	; Tape system flag bits
	MSKSTR (K0RAR,.FBBBT,AR%RAR)
	MSKSTR (K0RIV,.FBBBT,AR%RIV)
	MSKSTR (K0NDL,.FBBBT,AR%NDL)
	MSKSTR (K0NAR,.FBBBT,AR%NAR)
	MSKSTR (K0EXM,.FBBBT,AR%EXM)
	MSKSTR (K01ST,.FBBBT,AR%1ST)
	MSKSTR (K0RFL,.FBBBT,AR%RFL)
	MSKSTR (K0RSN,.FBBBT,AR%RSN)
	MSKSTR (ARPSZ,.FBBBT,AR%PSZ) ; # pages in RH
DEFSTR FBNET,.FBNET,35,36	; Online expiration
DEFSTR FBUSW,.FBUSW,35,36	;USER SETTABLE WORD
DEFSTR FBGNL,.FBGNL,35,33	;LINK TO NEXT GENERATION
DEFSTR FBNAM,.FBNAM,35,36	;POINTER TO NAME STRING
DEFSTR FBEXT,.FBEXT,35,36	;POINTER TO EXTENSION STRING
DEFSTR FBTDT,.FBTDT,35,36	; Tape write date & time
DEFSTR FBFET,.FBFET,35,36	; Offline expiration tad/interval
DEFSTR ARTP1,.FBTP1,35,36	; Tape 1 for archive/virtual disk
DEFSTR TFN1,.FBSS1,35,18	; Tape 1 tape file #
DEFSTR TSN1,.FBSS1,17,18	; Tape 1 saveset #
DEFSTR ARTP2,.FBTP2,35,36	; Tape 2 for archive/virtual disk
DEFSTR TFN2,.FBSS2,35,18	; Tape 2 tape file #
DEFSTR TSN2,.FBSS2,17,18	; Tape 2 saveset #

	.FBLN0==:30		;MINIMUM LENGTH OF AN FDB

;BLOCK TYPE CODES - FOUND IN LEFT HALF OF WORD 0 OF THE BLOCK

	.TYNAM==:400001		;BLOCK TYPE OF NAME STRING
	.TYEXT==:400002		;BLOCK TYPE OF EXTENSION STRING
	.TYACT==:400003		;BLOCK TYPE OF ACCOUNT STRING
	.TYUNS==:400004		;BLOCK TYPE OF USER NAME STRING
	.TYFDB==:400100		;BLOCK TYPE OF FDB
	.TYLAC==:400200		;BLOCK TYPE OF LEGAL ACCOUNT LIST
	.TYDIR==:400300		;BLOCK TYPE OF DIRECTORY BLOCK
	.TYSYM==:400400		;BLOCK TYPE OF SYMBOL TABLE
	.TYFRE==:400500		;BLOCK TYPE OF BLOCK ON THE FREE LIST
	.TYFBT==:400600		;BLOCK TYPE OF FREE STORAGE BIT TABLE
	.TYGDB==:400700		;BLOCK TYPE OF GROUP DESCRIPTOR BLOCK

; DIRECTORY CACHE ENTRIES
DCDIRN==:0			;DIRECTORY NUMBER
DCSTRN==:1			;STRUCTURE NUMBER
DCSHRC==:2			;SHARE COUNT
DCSOFN==:3			;SHARED OFN
DCSTIM==:4			;TIME OF ENTRY
DCSIZE==:5			;SIZE OF CACHE
;ENTRIES IN THE INDEX TABLE

DEFSTR IDXFB,0,35,18		;POINTER TO FDB FOR THIS DIRECTORY
DEFSTR IDXSD,0,17,18		;SUPERIOR DIRECTORY
DEFSTR IDXIB,1,35,30		;DISK ADDRESS OF INDEX BLOCK OF DIR
	IDXFLP==5		;BIT POSITION OF IDXFL IN DEFSTR
DEFSTR IDXFG,1,IDXFLP,6		;FLAGS
	IDX%IV==:1		;THIS IDX ENTRY IS INVALID
MSKSTR (IDXIV,1,<<IDX%IV>B<IDXFLP>>)

; INDEX TABLE FIELDS IN THE PSB

DEFSTR (CURUC,STRINF,17,18)	;UNIQUE CODE OF CURRENTLY MAPPED INDEX FILE
DEFSTR (IDXFLG,STRINF,18,1)	;0 IF NO INDEX FILE MAPPED, ELSE 1
DEFSTR (CURSTR,STRINF,35,17)	;STR # OF CURRENTLY MAPPED INDEX FILE

DEFSTR DIRLA,0,35,33		;ADDRESS POINTED TO BY DIRLOC

;THESE DEFINITIONS APPLY TO DROFN, WHICH IS SET UP WHENEVER A DIRECTORY
;IS MAPPED

DEFSTR (DRLFDB,DROFN,17,18)	;ADR OF LAST FDB CHECKED BY FDBCHK
DEFSTR (DRROF,DROFN,18,1)	;SET IF UNMAPD SHOULD RELEASE OFN
DEFSTR (DIROFN,DROFN,35,17)	;OFN OF CURRENTLY MAPPED DIR
; JSB FIELDS RELATED TO STRUCTURES

;THESE DEFSTRS RELATE TO THE 3-WORD BLOCKS CONTAINED IN JSSTR IN THE JSB.
;EACH BLOCK CONTAINS THE STRUCTURE UNIQUE CODE TO WHICH IT APPLIES.

DEFSTR (JSSDM,JSSTRF,0,1)	;STRUCTURE IS DISMOUNTED
DEFSTR (JSMCI,JSSTRF,1,1)	;MOUNT COUNT HAS BEEN INCREMENTED FOR THIS STR
DEFSTR (JSXCL,JSSTRF,2,1)	;STRUCTURE IS MOUNTED EXCLUSIVE BY THIS JOB
JSFRST==:777777			;VALUE IN STRUCTURE NUMBER FIELD WHEN SLOT
				; IS FREE
MSKSTR (JSSTN,JSSTRF,JSFRST)	;STRUCTURE UNIQUE CODE
DEFSTR (JSGRP,JSGRPS,35,36)	;AOBJN POINTER TO USER GROUPS
DEFSTR (JSFMT,JSFKMT,35,36)	;WORD OF BITS REFERRING TO FORKS WHICH
				; HAVE MOUNTED THIS STRUCTURE
DEFSTR (JSADN,JSADIR,35,18)	;"ACCESS'ED" DIRECTORY # FOR THIS STRUCTURE

;THESE DEFSTRS RELATE TO THE CONNECTED STRUCTURE AND DIRECTORY FOR THE JOB

DEFSTR (JSUC,JSBSDN,17,18)	;CONNECTED STRUCTURE UNIQUE CODE
DEFSTR (JSDIR,JSBSDN,35,18)	;CONNECTED DIRECTORY NUMBER
DEFSTR (JSCDS,JSBCDS,35,18)	;POINTER TO CONNECTED DIR NAME STRING
DEFSTR (JSCDF,JSBCDS,0,1)	;0=NO VALID STRING POINTER IN JSCDS
				;1=STRING POINTER IN JSCDS IS VALID

; PSB FIELDS RELATED TO STRUCTURES

DEFSTR (STRFLG,STRWRD,17,18)	;FLAG FOR STRUCTURE INFORMATION
	ST%IMC==:400000		;IGNORE MOUNT COUNT FOR STRUCTURE USE
DEFSTR (NOSTR,STRWRD,35,18)	;NUMBER OF STRUCTURES FOR WHICH PROCESS
				; HAS INCREMENTED MOUNT COUNT.  THIS
				; NUMBER MAY NOT BE ACCURATE AS IT IS
				; NOT DECREMENTED WHEN A DRIVE IS
				; REMOVED FROM THE SYSTEM, AND THE FORK
				; HAS NOT DECREMENTED IT. THE COUNT IS
				; USED AT KSELF TIME TO SEE IF IT IS
				; NECESSARY TO GO THRU EXTRA STRUCTURE
				; CODE.

;NODE NAME STUFF

CPN==6			;NUMBER OF CHARACTERS ALLOWED IN NODE NAME
WPN==CPN/5+1		;WORDS NEEDED FOR LONGEST NODE NAME IN ASCIZ

;DEFINITIONS OF DECNET QUOTA WORD

DEFSTR (DCMAX,DCNCNT,17,18)	;MAX LINKS THIS JOB CAN HAVE
DEFSTR (DCCUR,DCNCNT,35,18)	;CURRENT COUNT OF OPEN LINKS

;DEFINITIONS FOR ATS QUOTA WORD

DEFSTR (JSAMX,JSATCT,17,18)	;MAXIMUM HTN'S THIS JOB CAN HAVE
DEFSTR (JSANO,JSATCT,35,18)	;NUMBER OF HTN'S THIS JOB HAS NOW

;BITS PASSED BETWEEN ATS ROUTINES TO INDICATE STATUS - CODE IN ATSSRV
;SETS THEM, CODE IN FILATS READS THEM

MI%SCH==1B0			;STATUS CHANGED
MI%DHT==1B1			;DEASSIGNING THIS HTN
; STRUCTURE DATA BLOCK DEFINITIONS

DEFSTR (STRNAM,SDBNAM,35,36)	;NAME OF STRUCTURE IN SIXBIT
DEFSTR (STRNUM,SDBNUM,35,36)	;NUMBER OF UNITS IN STRUCTURE
DEFSTR (STRSIZ,SDBSIZ,35,36)	;SIZE IN SECTORS OF EACH UNIT IN STRUCTURE
DEFSTR (STRSTS,SDBSTS,17,18)	;STRUCTURE STATUS
	MSKSTR (STPS,SDBSTS,MS%PS)	;STRUCTURE IS PUBLIC
	MSKSTR (STDIS,SDBSTS,MS%DIS)	;STRUCTURE IS BEING DISMOUNTED
	MSKSTR (STDOM,SDBSTS,MS%DOM)	;STRUCTURE IS DOMESTIC
	MSKSTR (STNRS,SDBSTS,MS%NRS)	;STRUCTURE IS NOT REGULATED
	DEFSTR (STCRD,SDBSTS,17,1)	;CREATING ROOT-DIRECTORY ON THIS STR
	DEFSTR (STIDX,SDBSTS,16,1)	;INDEX TABLE FILE OFN HAS BEEN SET UP
DEFSTR (STRJB,SDBSTS,35,18)	;NUMBER OF INITING JOB
DEFSTR (STRRDO,SDBIDX,17,18)	;OFN OF ROOT-DIRECTORY FOR THIS STRUCTURE
DEFSTR (STRIDX,SDBIDX,35,18)	;FIELD WHICH HOLDS HANDLE OF INDEX TABLE
DEFSTR (STRLDN,SDBLDN,35,36)	;LAST DIRECTORY NUMBER ON THIS STRUCTURE
DEFSTR (STRRXB,SDBRXB,35,36)	;INDEX BLOCK ADDRESS OF ROOT-DIRECTORY
DEFSTR (STRBXB,SDBBXB,35,36)	;INDEX BLOCK ADDRESS OF BACKUP ROOT-DIRECTORY
DEFSTR (STRNSS,SDBNSS,35,36)	;NUMBER OF SWAPPING SECTORS PER UNIT
DEFSTR (STRFSS,SDBFSS,35,36)	;FIRST SWAPPING SECTOR PER UNIT
DEFSTR (STRBTB,SDBBTB,35,36)	;OFN OF BIT TABLE FILE
DEFSTR (STRFC,SDBFRC,35,36)	;COUNT OF FREE PAGES ON STRUCTURE
DEFSTR (STRLCA,SDBLCA,35,36)	;LAST CYLINDER ASSIGNED BY DSKASN
DEFSTR (STRCYL,SDBCYL,35,36)	;TOTAL CYLINDERS IN STRUCTURE
DEFSTR (STRB0,SDBBT0,35,36)	;LENGTH OF TOP HALF OF BIT TABLE
DEFSTR (STRB1,SDBBT1,35,36)	;LENGTH OF BOTTON HALF OF BIT TABLE
DEFSTR (STRTYP,SDBTYP,35,36)	;ADDRESS OF DSKSIZ TABLE FOR THIS TYPE DISK
DEFSTR (STRUDB,SDBUDB,35,36)	;FLAGS,,ADDRESS OF UDB FOR FIRST UNIT IN STR
DEFSTR (STRUC,SDBFLK,17,18)	;UNIQUE CODE IN SDB
	STRNS==:6		;LENGTH OF THE STR NUMBER FIELD
DEFSTR (STRUS,SDBFLK,17,STRNS)	;FIELD WITHIN STRUC TO HOLD STR NUMBER
DEFSTR (STRLK,SDBFLK,35,18)	;FILE LOCK COUNT
DEFSTR (STRMC,SDBCNT,17,18)	;MOUNT COUNT
DEFSTR (STROF,SDBCNT,35,18)	;OPEN FILE COUNT
DEFSTR (STRMI,SDBPUC,35,36)	;MEDIA IDENTIFICATION FIELD
;BITS FOR CALLING DIRCHK TO CHECK IF THE SPECIFIED ACCESS TO A DIRECTORY IS LEGAL

DC%RD==:DP%RD_<^D30-1>		;ACCESS FILES ACCORDING TO THEIR PROTECTION
DC%CN==:DP%CN_<^D30-1>		;CONNECT TO THE DIRECTORY
DC%CF==:DP%CF_<^D30-1>		;CREATE FILES

;BITS FOR CALLING ACCCHK TO CHECK IF THE SPECIFIED ACCESS TO A FILE IS LEGAL

FC%DIR==:FP%DIR_<^D30-1>	;LIST THE FILE SPEC VIA 'DIR' COMMAND
FC%APP==:FP%APP_<^D30-1>	;APPEND
FC%EX==:FP%EX_<^D30-1>		;EXECUTE
FC%WR==:FP%WR_<^D30-1>		;WRITE
FC%RD==:FP%RD_<^D30-1>		;READ

FC%MSK==:FC%DIR!FC%APP!FC%EX!FC%WR!FC%RD	;MASK OF ALL ACCESS BITS

;BIT DEFINITIONS FOR FE STATUS WORD

.DVFNX==:1B35			;NON-EX DEVICE
.DVFOL==:1B34			;OFF LINE
.DVFHE==:1B33			;HARDWARE ERROR
.DVFSE==:1B32			;SOFTEARE CONDITION
.DVFIP==:1B31			;I/O IN PROGRESS
.DVFEF==:1B30			;END OF FILE
.DVFLG==:1B29			;ERROR LOGGING INFO FOLLOWS
.DVFFE==:1B28			;DEVICE HAS A FATAL UNRECOVERABLE
				; ERROR

;SECOND STATUS WORD DEFINITONS
.DDRCK==:1B35			;READ CHECK
.DDPCK==:1B34			;PICK CHECK
.DDSCK==:1B33			;STACK CHECK
.DDHEM==:1B32			;HOPPER EMPTY
.DDSFL==:1B31			;STACKER FULL

;CODE DEFINITIONS FOR THE JSB FREE SPACE STACK. THESE
;CODES IDENTIFY THE TYPE OF ENTRY ON THE STACK

STKCD1==:1			;TYPE 1 FOR ASGJFR STRINGS
STKCD2==:2			;TYPE 2 FOR ASGPAG STRINGS
STKCD3==:3			;TYPE 3 FOR TTY LOCKS
STKCD4==:4			;TYPE 4 FOR SWAP FREE STRINGS
STKCD5==:5			; 100: TYPE 5 FOR CHAOS NET CONNS DURING ICP
;SYSERR DEFINITIONS

;FORMAT OF SEBCPY WORD

SEBOFS==:<MASKB 2,8>		;OFFSET
SEBTYP==:<MASKB 9,11>		;TYPE
SEBDPT==:<MASKB 13,35>		;DATA POINTER

;MACRO TO BUILD POINTER WORD AT ASSEMBLY TIME
; SEBPTR OFFSET,DATATYPE,ADDRESS

DEFINE SEBPTR (AA,BB,CC)<
	1B0+FLD(AA,SEBOFS)+FLD(BB,SEBTYP)+<Z CC>>

;DATA TYPES - SEBCPY WORD

SBTWD==:0			;FULL WORD
SBTSTR==:1			;STRING
SBTEVC==:2			;EVENT CODE IMMEDIATE
SBTFNA==:3			;FUNCTION ADDRESS FOR JOB 0 PROCESSING

;POSSIBLE LINE TYPES FOR TELETYPE SERVICE

TT.FE==0			;ON THE RSX20F FRONT END
TT.MCB==1			;ON THE MCB NETWORK
TT.PTY==2			;PSEUDO-TERMINAL
TT.D10==3			;ON THE DC10
TT.NVT==4			;ON THE ARPANET
TT.DZ==5			;ON THE SM10
TT.MLC==6			;PTIP LINES
TT.CVT==7			; 100: Chaosnet NVTs
TT.TVT==10			; TCP Virtual Terminals
NLTYPS==11			;NUMBER OF TYPES


;FIELD FOR CONTROLLING TERMINAL

DEFSTR (FRKTTY,CTTAB,35,18)

;DEFINITIONS FOR RESIDENT FREE POOL ALLOCATION

;DEFINE SPECIAL RESIDENT FREE SPACE VALUES

	RS%SE0==:1B0		;SPACE MUST BE IN SECTION 0 (USED BY ASGRES)
	RS%GRO==:1B0		;THE RELEASING IS REALLY A "GROWING" (USED BY RELRES)
	RESFLG==:101010		;FLAG PUT IN TRAILER WORD OF BLOCK
;FORMAT OF A RESIDENT FREE SPACE HEADER

RSHLEN==1			;LENGTH OF HEADER FOR EACH BLOCK
	DEFSTR (RSPOO,0,17,18)	;POOL NUMBER FOR THIS BLOCK
	DEFSTR (RSSIZ,0,35,18)	;SIZE OF BLOCK IN 4-WORD CHUNKS

IFN RESHSW,<			;SECOND HEADER WORD FOR DEBUGGING
RSHLEN==2
	DEFSTR (RSINU,1,0,1)	;"BLOCK IN USE" FLAG
	DEFSTR (RSCAL,1,35,35)	;PC OF CALLER TO ASGRES
>

;FORMAT OF A RESIDENT FREE SPACE TRAILER

RSTLEN==0			;LENGTH OF TRAILER FOR EACH BLOCK

IFN RESHSW,<			;MAKE IT BIGGER FOR DEBUGGING
RSTLEN==1
	DEFSTR (RSFLG,0,17,18)	;THE TRAILER FLAG
	DEFSTR (RSHED,0,35,18)	;THE ADDRESS OF THE HEADER
>
;ICCS DEFINITIONS
FLINK==:0			;FORWARD POINTER
BLINK==:1			;BACKWARD POINTER
QINTL==:2			;INTERLOCK WORD
QLNGTH==:3			;LENGTH OF THE QUEUE ENTRY
; DEFINITIONS FOR ACCOUNT VALIDATION
; THESE THREE DEFINITIONS ARE COMMON TO ALL ACCOUNT DATA BLOCKS

DEFSTR (BKTYP,0,17,18)		;DATA BLOCK TYPE
DEFSTR (BKLEN,0,35,18)		;BLOCK LENGTH
DEFSTR (XPDAT,1,35,35)		;EXPIRATION DATE

; ACCOUNT HEADER

DEFSTR (ACCLS,2,8,9)		;CLASS FOR THIS ACCOUNT
DEFSTR (DATASZ,2,35,27)		;TOTAL LENGTH OF ACCOUNT DATA BLOCK
DEFSTR (ACPTR,3,35,36)		;POINTER TO CHAINED ACCOUNT BLOCK
DEFSTR (ACNAM,4,35,36)		;ACCOUNT STRING NAME

; USER NAME

DEFSTR (USRNM,2,35,36)		;USER NAME STRING

; USER GROUP

DEFSTR (USRGP,2,35,36)		;USER GROUP NUMBER


; SXSTR IS COMMON TO ALL DIRECTORY-TYPE BLOCKS

DEFSTR (SXSTR,2,35,36)		;SIXBIT STRUCTURE NAME

; DIRECTORY NAME

DEFSTR (DIRNM,3,35,36)		;DIRECTORY NAME STRING

; DIRECTORY GROUP

DEFSTR (DIRGP,3,35,36)		;DIRECTORY GROUP NUMBER

; ALL DIRECTORIES


; DATA BLOCK TYPES

	.TYHSH==:577001		;HASH TABLE
	.TYACC==:577002		;ACCOUNT HEADER
	.TYUNM==:577003		;USER NAME
	.TYUGP==:577004		;USER GROUP
	.TYALU==:577005		;ALL USERS
	.TYDNM==:577006		;DIRECTORY NAME
	.TYDGP==:577007		;DIRECTORY GROUP
	.TYALD==:577010		;ALL DIRECTORIES
	.TYNUL==:577011		;NULL BLOCK
	.TYWUS==:577012		;WILD USER NAME STRING
; NSP INTERNAL INTERFACE FUNCTION VECTOR OFFSETS

.NSCRT==:0			;CREATE AN INTERNAL LOGICAL LINK
	.NSSZW==:0		;ARGUMENT BLOCK SIZE
	.NSSTR==:1		;ADDRESS OF NAME STRING TO PARSE
	.NSHST==:1		;ADDRESS OF HOST NAME STRING
	.NSOBJ==:2		;ADDRESS OF OBJECT NAME STRING
	.NSDSC==:3		;ADDRESS OF DESCRIPTOR STRING
	.NSODC==:4		;COUNT OF BYTES IN OPTIONAL DATA STRING
	.NSOPD==:5		;ADDRESS OF OPTIONAL DATA STRING (8 BIT BYTES)
	.NSTSN==:6		;ADDRESS OF TASK NAME STRING
	.NSUSR==:7		;ADDRESS OF USER STRING
	.NSPWC==:10		;COUNT OF BYTES IN PASSWORD STRING
	.NSPSW==:11		;ADDRESS OF PASSWORD STRING (8 BIT BYTES)
	.NSCHG==:12		;ADDRESS OF ACCOUNT STRING
	.NSMQI==:13		;MAXIMUM INPUT TO QUEUE ON LINK
	.NSMQO==:14		;MAXIMUM OUTPUT TO QUEUE ON LINK

	NS%SHT==:1B0		;SHORT FORM CALL
	NS%RD==:1B1		;READ ACCESS WANTED
	NS%WRT==:1B2		;WRITE ACCESS WANTED
	NS%LOK==:1B3		;LOCK THE LOGICAL LINK ON RETURNING TO DRIVER
.NSCLZ==:1			;CLOSE AN INTERNAL LINK
.NSOUT==:2			;OUTPUT TO AN INTERNAL LINK
	NS%BLK==:1B0		;BLOCK UNTIL ALL DATA SENT
	NS%EOM==:1B1		;THIS BUFFERFUL IS AN ENTIRE NSP MESSAGE
.NSINB==:3			;PROVIDE INPUT BUFFER
.NSRIN==:4			;READ INTERRUPT MESSAGE
.NSSIN==:5			;SEND INTERRUPT MESSAGE
.NSTRN==:6			;TRUNCATE CURRENT MESSAGE
.NSRLS==:7			;READ LINK STATUS
.NSRHN==:10			;READ HOST NAME
.NSRTN==:11			;READ TASK NAME
.NSRDA==:12			;READ OPTIONAL DATA
.NSRSS==:13			;READ LINK SEGMENT SIZE
.NSRON==:14			;READ OBJECT NAME

; DRIVER FUNCTION VECTOR OFFSETS

.NSHDR==:0			;COUNT OF WORDS IN VECTOR
.NSCND==:1			;CONNECT DISPOSITION RECEIVED
.NSBFR==:2			;NSP NEEDS A BUFFER
	NS%TRN==:1B0		;TRUNCATE MESSAGES IF TOO BIG FOR BUFFER
.NSDAT==:3			;INPUT DATA NOW AVAILABLE
	NS%MSG==:1B1		;COMPLETE MESSAGE RECEIVED (END-OF-MESSAGE SEEN)
	NS%ABT==:1B2		;LINK ABORTED. NO DATA IS PRESENT IN BUFFER.
.NSOOK==:4			;OK TO SEND OUTPUT NOW
	.NSOMO==:1		;OUTPUT MAY NOW BE SENT
	.NSIMI==:2		;INTERRUPT MESSAGE MAY NOW BE SENT
.NSINT==:5			;INTERRUPT MESSAGE RECEIVED
.NSOBE==:6			;OUTPUT BUFFER IS NOW EMPTY
.NSDIS==:7			;DISCONNECT RECEIVED



;MCBDTE (FOR NSP) DEFINITIONS

INIRCV==1B0			;NODE INIT RECEIVED
FRKRUN==1B1			;FLAG IN MCBDTE TO SAY NETWORK IS INITED
NTSHUT==1B2			;IF SET, NSP IS IN "SHUTDOWN" STATE
NOTMCB==1B3			;NEIGHBOR IS NOT AN MCB
REQVER==1B4			;LINE REQUIRES VERIFICATION
INISNT==1B5			;NODE INIT SENT
LCSDTE==1B6			;THIS DTE IS ACTUALLY AN LCS SLOT
DEFSTR (NAMCN,,17,3)		;COUNT OF BYTES IN NODE NAME

; NSP INTERNAL LINK ERROR CODES

NSPX1==:1			;DUPLICATE DRIVER VECTOR/CORRELATION CODE PAIR
NSPX2==:2			;NO SUCH LINK (INVALID NSP IDENTIFIER)
NSPX3==:3			;LINK NOT IN RUN STATE
NSPX4==:4			;PREVIOUS BUFFER STILL BEING PROCESSED
NSPX5==:5			;SUPERFLUOUS BUFFER - NO REQUEST OUTSTANDING
NSPX6==:6			;INT MSG UNAVAILABLE DUE TO FLOW CTL FAILURE
;MEMORY ERROR SAVE AREA DEFINTIONS

;DEFINITIONS FOR ERROR BLOCK

SBSLNK==:0			;OFFSET FOR LINK WORD
SBSERA==:1			;ERROR REG
SBSTYP==:2			;TYPE WORD AS FOLLOWS
 DEFSTR (SBSCN,SBSTYP,17,18)	;CONTROLLER NUMBER
 DEFSTR (SBSTP,SBSTYP,35,18)	;TYPE OF THIS ENTRY

;FOLLOWING ENTRIES ARE "TYPE" DEPENDENT.

;.PMMER DEFINTIONS

ERRSIZ==:11			;LENGTH OF A CER ENTRY
SBSEAD==:4			;OFFSET FOR ERROR ADDRESS
SBSSER==:5			;OFFSET FOR FIRST SERIAL NUMBER
DEFSTR (SBSSY,3,5,6)		;SYNDROME OF ERROR
DEFSTR (SBSBN,3,9,4)		;4-BIT BLOCK NUMBER
DEFSTR (SBSSB,3,15,6)		;SPARE BIT NUMBER
DEFSTR (SBHEB,3,16,1)		;HARD ERROR, NEEDS RECORDING
	SUBTTL		STORAGE DEFINITIONS FOR ATSSRV

;THIS CLUMSY SET OF DEFINITIONS IS NECESSARY TO MAKE MACRO COOPERATE.
;THE END RESULT IS A MASK THAT REPRESENTS 30 OR MORE BITS OF ADDRESS
;AND A VALUE THAT REPRESENTS -1 IN THE MASK.  THE SIZE OF THE ADDRESS
;CAN BE CHANGED BY ALTERING THE ARGUMENTS FOR THE MASKB MACRO, AND NO
;CODE NEED BE CHANGED

ADRMSK==MASKB(6,35)
ADRSHF==^D35-POS(ADRMSK)
ADRNEG==-ADRSHF
ADRVAL==ADRMSK_ADRNEG


;DATA FOR AN APPLICATION TERMINAL

;EACH ACTIVE APPLICATIONS TERMINAL HAS THIS DATA BASE. FOR A GIVEN
;HTN, THE ROUTINE GTATDB PROVIDES THE ADDRESS OF THIS BLOCK OF DATA

	DEFSTR (ATLEN,0,35,18)	;LENGTH OF THIS BLOCK IN WORDS
	MSKSTR (ATJFN,1,ADRMSK)	;ADDRESS OF JFN DATA

;POINTERS TO PIPES

	MSKSTR (ATDAP,2,ADRMSK)	;ADDRESS OF DATA PIPE DATA
	MSKSTR (ATCOP,3,ADRMSK)	;ADDRESS OF CONTROL PIPE DATA

;STATUS WORDS

		.ATMST==:4
	DEFSTR (ATMST,.ATMST,35,36)	;MONITOR STATUS BITS
		AT%SCH==:1B0	;STATUS CHANGED SINCE LAST REPORT
		MSKSTR (ATSCH,.ATMST,AT%SCH)
		AT%NIO==:177B7	;TERMINAL NOT AVAILABLE FOR I/O IF ANY BIT SET
		MSKSTR (ATNIO,.ATMST,AT%NIO)
		AT%BZY==:1B1	;HTN IS BUSY - NRM NEGOTIATIONS UNDERWAY
		MSKSTR (ATBZY,.ATMST,AT%BZY)
		AT%ABR==:1B2	;HTN IS IN ABORT MODE
		MSKSTR (ATABR,.ATMST,AT%ABR)
		AT%NRH==:1B3	;REMOTE NRM RELEASED HTN
		MSKSTR (ATNRH,.ATMST,AT%NRH)
		AT%GTD==:1B4	;GET THE TERMINAL (ATS TO NRM)
		MSKSTR (ATGTD,.ATMST,AT%GTD)
		AT%RLD==:1B5	;RELEASE THE TERMINAL (ATS TO NRM)
		MSKSTR (ATRLD,.ATMST,AT%RLD)
		AT%URH==:1B6	;USER RELEASED HTN (WITH OR WITHOUT ABORT)
		MSKSTR (ATURH,.ATMST,AT%URH)
		AT%UAH==:1B7	;USER RELEASED HTN WITH ABORT
		MSKSTR (ATUAH,.ATMST,AT%UAH)
		AT%RIP==:1B8	;RELEASE OF HTN IS IN PROGRESS
		MSKSTR (ATRIP,.ATMST,AT%RIP)
		AT%EOM==:1B13	;INPUT INCLUDES END-OF-MESSAGE
		MSKSTR (ATEOM,.ATMST,AT%EOM)
		AT%XOF==:7B17	;TERMINAL IS XOFF'D IF ANY BIT SET
		MSKSTR (ATXOF,.ATMST,AT%XOF)
		AT%XMC==:1B15	;XOFF'D BECAUSE MCB SENT XOFF
		MSKSTR (ATXMC,.ATMST,AT%XMC)
		AT%XQU==:1B16	;XOFF'D BECAUSE ATS COULDN'T QUEUE MESSAGE
		MSKSTR (ATXQU,.ATMST,AT%XQU)
		AT%XFR==:1B17	;XOFF'D BECAUSE NO FREE SPACE FOR MESSAGE
		MSKSTR (ATXFR,.ATMST,AT%XFR)
		DEFSTR (ATSTR,.ATMST,35,18) ;STATE FOR NRM PROCESSING
		.ATUST==:5
	DEFSTR (ATUST,.ATUST,35,36) ;USER STATUS BITS
		MSKSTR (ATOPN,.ATUST,AT%OPN) ;HTN IS OPEN AND USABLE
		MSKSTR (ATTCL,.ATUST,AT%TCL) ;NRM CLOSED TERMINAL VIA STATUS-REPORT
		MSKSTR (ATDHT,.ATUST,AT%DHT) ;DEASSIGNING HTN
		MSKSTR (ATTXF,.ATUST,AT%TXF) ;TERMINAL IS XOFF'D
		MSKSTR (ATUND,.ATUST,AT%UND) ;DEVICE REQUESTED IS UNDEFINED
		MSKSTR (ATNAV,.ATUST,AT%NAV) ;DEVICE REQUESTED IS NOT AVAILBLE
		MSKSTR (ATOFL,.ATUST,AT%OFL) ;DEVICE REQUESTED IS OFFLINE
		MSKSTR (ATFUL,.ATUST,AT%FUL) ;SERVER IS FULL
		MSKSTR (ATUNS,.ATUST,AT%UNS) ;DEVICE TYPE IS UNSUPPORTED
		MSKSTR (ATREJ,.ATUST,AT%REJ) ;NODE NRM REJECTED THE REQUEST
		MSKSTR (ATMIE,.ATUST,AT%MIE) ;MONITOR INTERNAL ERROR
		MSKSTR (ATSTF,.ATUST,AT%STF) ;VT62 STARTUP FAILED
		MSKSTR (ATCRJ,.ATUST,AT%CRJ) ;CONNECTION WAS REJECTED
		MSKSTR (ATNDP,.ATUST,AT%NDP) ;DATA PIPE IS NOT OPEN
		MSKSTR (ATSER,.ATUST,AT%SER) ;STATUS REORT ERROR CODE (SEE BELOW)

;IDENTIFIERS FOR TERMINALS (BOUNDARY NODE'S, HOST NODE'S, USER'S)

	DEFSTR (ATBTN,6,17,18)	;BOUNDARY TERMINAL NUMBER
	DEFSTR (ATHTN,6,35,18)	;HOST TERMINAL NUMBER
	DEFSTR (ATUTN,7,35,36)	;USER TERMINAL NUMBER

;FIELDS FOR I/O

	DEFSTR (ATICT,10,17,18)	;COUNT OF INPUT DATA
	DEFSTR (ATOCT,10,35,18)	;BYTES NEEDED FOR OUTPUT
	MSKSTR (ATIAD,11,ADRMSK) ;ADDRESS OF FIRST INPUT BUFFER
	DEFSTR (ATIBP,12,35,36)	;BYTE POINTER TO INPUT

;LINKS TO OTHER TERMINALS

	MSKSTR (ATLJF,13,ADRMSK) ;ADDRESS OF NEXT TERMINAL BLOCK FOR JFN
	MSKSTR (ATLDP,14,ADRMSK) ;ADDRESS OF NEXT TERMINAL BLOCK FOR DATA PIPE
	MSKSTR (ATLBP,15,ADRMSK) ;ADDRESS OF NEXT TERMINAL BLOCK FOR BACKGROUND PROCESS

;NAME OF THE DEVICE

	DEFSTR (ATDEV,16,35,36)	;ADDRESS OF FREE SPACE CONTAINING DEVICE NAME
		.ATLCK==:17	;LOCK WORD
	DEFSTR (ATSIX,20,35,36) ;DEVICE NAME IN SIXBIT
	ATSIZ==:21		;SIZE OF BLOCK
;DATA FOR A PIPE

;EACH OPEN (OR BEING OPENED) LOGICAL LINK TO EITHER A DIALOGUE MANAGER
;(A DATA PIPE) OR A RESOURCE MANAGER (A CONTROL PIPE) HAS THIS DATA
;BASE. THE DATA PIPES ARE CHAINED TOGETHER STARTING AT THE CELL
;ATDPHD; THE CONTROL PIPES ARE CHAINED TOGETHER STARTING AT ATCPHD.
;IN BOTH CASES, OFFSET APLPS POINTS TO THE NEXT ENTRY IN THE CHAIN.

;NOTE: THESE BLOCKS TEMPORARILY CONTAIN OFFSET .APADR, WHICH IS THE
;ADDRESS OF NSP'S DATA FOR THE PIPE. IT CAN BE REMOVED BEFORE SHIPMENT
;TO SAVE SPACE

	DEFSTR (APLEN,0,35,18)	;LENGTH OF THIS BLOCK IN WORDS
	DEFSTR (APTYP,1,2,3)	;TYPE OF LINK
		.APDAP==:0	;DATA PIPE
		.APCOP==:1	;CONTROL PIPE
	DEFSTR (APSTS,1,17,15)	;STATUS
		AP%NBP==:177B9	;NEED ACTION BY THE BACKGROUND PROCESS
		MSKSTR (APNBP,1,AP%NBP)
		AP%NIB==:1B3	;NEED INPUT BUFFER
		MSKSTR (APNIB,1,AP%NIB)
		AP%NRI==:1B4	;NEED TO READ INTERRUPT MESSAGE
		MSKSTR (APNRI,1,AP%NRI)
		AP%NOD==:1B5	;NEED TO READ OPTIONAL DATA
		MSKSTR (APNOD,1,AP%NOD)
		AP%NIO==:37B10	;PIPE IS NOT FULLY OPEN IF ANY BIT SET
		MSKSTR (APNIO,1,AP%NIO)
		AP%NCL==:1B6	;NEED TO CLOSE THIS PIPE
		MSKSTR (APNCL,1,AP%NCL)
		AP%NAB==:7B9	;NEED TO ABORT PIPE IF ANY BIT SET
		MSKSTR (APNAB,1,AP%NAB)
		AP%CLR==:1B7	;CLOSED BY REMOTE PROCESS
		MSKSTR (APCLR,1,AP%CLR)
		AP%CRJ==:1B8	;CONNECT-REJECT RECEIVED
		MSKSTR (APCRJ,1,AP%CRJ)
		AP%PER==:1B9	;PROTOCOL ERROR OCCURRED
		MSKSTR (APPER,1,AP%PER)
		AP%WCC==:1B10	;WAITING FOR CONNECT-CONFIRM
		MSKSTR (APWCC,1,AP%WCC)
		AP%EOM==:1B14	;EXTRA MESSAGE HAS END-OF-MESSAGE
		MSKSTR (APEOM,1,AP%EOM)
		AP%OTO==:1B15	;LIMITED TO ONE TERMINAL
		MSKSTR (APOTO,1,AP%OTO)
		AP%NRO==:1B16	;NSP REFUSED OUTPUT ON THIS LINK
		MSKSTR (APNRO,1,AP%NRO)
		AP%TXF==:1B17	;A TERMINAL WAS XOFF'D BECAUSE QUEUE WAS FULL
		MSKSTR (APTXF,1,AP%TXF)
	DEFSTR (APNIR,1,23,6)	;NO. TIMES TRIED TO READ INTERRUPT MESSAGE
	DEFSTR (APNOT,1,35,12)	;NUMBER TERMINALS ASSIGNED TO THE LINK
	DEFSTR (APNSP,2,35,36)	;NSP'S IDENTIFIER FOR THE LINK
	MSKSTR (APOAD,3,ADRMSK) ;ADDRESS OF FIRST OUTPUT MESSAGE
	MSKSTR (APLPS,4,ADRMSK) ;ADDRESS OF NEXT LINK BLOCK FOR SYSTEM
	MSKSTR (APLBP,5,ADRMSK) ;ADDRESS OF NEXT LINK BLOCK FOR BACKGROUND PROCESS
	DEFSTR (APSIX,6,35,36)	;NODE NAME IN SIXBIT
		.APADR==:7	;* * *NSP'S ADDRESS OF DATA
	DEFSTR (APREA,10,35,18)	;REASON CODE FOR CONNECT-REJECT
		CPSIZ==:11	;SIZE OF A CONTROL PIPE'S DATA

;THE FOLLOWING OFFSETS ARE USED FOR DATA PIPES ONLY

	MSKSTR (APLAT,11,ADRMSK) ;ADDRESS OF FIRST TERMINAL BLOCK
	DEFSTR (APOBJ,12,17,18)	;OBJECT NUMBER OF REMOTE TASK
	DEFSTR (APBUL,12,35,18)	;BULA (REMOTE END'S ID FOR THE LINK)
	DEFSTR (APJOB,13,17,18)	;JOB THAT CREATED THIS PIPE
	DEFSTR (APJFN,13,35,18)	;JFN THAT CREATED THIS PIPE

;LOCATIONS FOR OUTPUT

	MSKSTR (APXAD,14,ADRMSK) ;ADDRESS OF FIRST XOFF'D OUTPUT MESSAGE
	DEFSTR (APOCT,15,17,18)	;NUMBER OF OUTPUT MESSAGES QUEUED
	DEFSTR (APOBS,15,35,18)	;SIZE OF OUTPUT BUFFER (WITHOUT HEADER)

;LOCATIONS FOR THE 'SECOND INPUT MESSAGE'

	MSKSTR (APSIA,16,ADRMSK) ;ADDRESS OF SECOND INPUT MESSAGE
	DEFSTR (APSIB,17,35,36)	;BYTE POINTER FOR SECOND MESSAGE
	DEFSTR (APSIT,20,17,18)	;TERMINAL FOR SECOND MESSAGE
	DEFSTR (APSIC,20,35,18)	;COUNT FOR SECOND MESSAGE

;LOCATIONS FOR ACCUMULATING AN INPUT MESSAGE BEFORE COPYING IT TO A
;TERMINAL

	MSKSTR (APIAD,21,ADRMSK) ;ADDRESS OF FIRST INPUT BUFFER
	MSKSTR (APIAL,22,ADRMSK) ;ADDRESS OF LAST INPUT BUFFER
	DEFSTR (APINO,23,5,6)	;CURRENT NO. OF BUFFERS IN INPUT MESSAGE
	DEFSTR (APICT,23,17,12)	;NO. OF BYTES IN CURRENT INPUT MESSAGE
	DEFSTR (APIHT,23,35,18)	;HTN OF INPUT MESSAGE BEING COLLECTED
	DEFSTR (APIBP,24,35,36) ;BYTE POINTER FOR INPUT MESSAGE
		DPSIZ==:25	;;SIZE OF A DATA PIPE'S DATA

;NOTES ON PIPE STATUS:
;	AP%NBP=ALL BITS THAT REQUIRE ACTION BY THE BACKGROUND PROCESS
;	AP%NIO=ALL BITS THAT MAKE THE PIPE UNAVAILABLE FOR I/O
;	AP%NAB=ALL BITS THAT CAUSE A PIPE TO BE ABORTED BY THE BACKGROUND
;		PROCESS
;DATA FOR A JFN

	DEFSTR (AJLEN,0,35,18)	;LENGTH OF THIS BLOCK
	DEFSTR (AJMOD,1,5,6)	;MODE
	DEFSTR (AJFLG,1,17,12)	;FLAGS
	DEFSTR (AJCDA,2,17,18)	;CHANNEL FOR DATA ARRIVAL INTERRUPT
	DEFSTR (AJCST,2,35,18)	;CHANNEL FOR STATUS ARRIVAL INTERRUPT
	MSKSTR (AJLAT,3,ADRMSK) ;ADDRESS OF FIRST TERMINAL ON JFN
	MSKSTR (AJLIN,4,ADRMSK)	;ADDRESS OF NEXT TERMINAL WITH INPUT
	DEFSTR (AJPRO,5,17,18)	;PROCESS
	DEFSTR (AJJFN,5,35,18)	;JFN
		.AJSLK==:6	;LOCK ON STRUCTURE FOR THIS JFN
		.AJCHG==:7	;NUMBER OF TERMINALS WITH CHANGED STATUS
		.AJICT==:10	;NUMBER OF TERMINALS WITH INPUT
	MSKSTR (AJMSK,11,ADRMSK) ;FIRST WORD OF TERMINAL MASK
		AJSIZ==:12	;SIZE OF JFN BLOCK

;NOTE: MASK WORDS ARE CONTIGUOUS AND CONTAIN ONE BIT POSITION PER
;HTN
;DATA FROM THE DATA PIPE THAT HAS BEEN RECEIVED AT OUR END.
;INTERRUPT MESSAGES ARE QUEUED FOR THE BACKGROUND PROCESS IN THIS FORM.
;DATA MESSAGES ARE QUEUED FIRST ON THE PIPE, THEN ON THE TERMINAL.

	DEFSTR (DILEN,0,35,18)	;LENGTH OF THIS BLOCK IN WORDS
	DEFSTR (DIBYT,1,35,18)	;NUMBER OF BYTES IN MESSAGE
	MSKSTR (DILNK,2,ADRMSK)	;ADDRESS OF NEXT BLOCK IN QUEUE
		DIDAT==:3	;FIRST WORD CONTAINING DATA

REPEAT 0,<
!-------------------------------------------------------!
!                           !      Length in words      !
!-------------------------------------------------------!
!                           !      Number of bytes      !
!-------------------------------------------------------!
!            Address of next block on chain             !
!-------------------------------------------------------!
!   data    !   data    !    ...     !   data    !      !
+-------------------------------------------------------+
>

;OUTPUT MESSAGE FOR DATA PIPE QUEUED TO BE SENT

	DEFSTR (DOLEN,0,35,18)	;LENGTH OF THIS BLOCK IN WORDS
	DEFSTR (DOEOM,1,0,1)	;SET IF END-OF-MESSAGE
	DEFSTR (DOREL,1,1,1)	;NSP HAS RELEASED THIS BUFFER
	DEFSTR (DOQUE,1,2,1)	;ATS HAS QUEUED THIS BUFFER
	DEFSTR (DOSEG,1,17,9)	;SEGMENT NUMBER
		DOMAX==:FLD(777,DOSEG) ;MAXIMUM SEGMENT NUMBER
	DEFSTR (DOBYT,1,35,18)	;NUMBER OF BYTES IN THIS SEGMENT
	MSKSTR (DONMS,2,ADRMSK)	;ADDRESS OF NEXT MESSAGE FOR THIS LINK
	MSKSTR (DONSG,3,ADRMSK)	;ADDRESS OF NEXT SEGMENT FOR THIS MESSAGE
		DODAT==:4	;FIRST WORD CONTAINING DATA

REPEAT 0,<
+-------------------------------------------------------+
!                           !      Length in words      !
!-------------------------------------------------------!
!!!!          ! Segment No. !      Number of bytes      !
!-------------------------------------------------------!
!                Address of next message                !
!-------------------------------------------------------!
!                Address of next segment                !
!-------------------------------------------------------!
!                         Data                          !
!-------------------------------------------------------!
\                                                       \
\                                                       \
!-------------------------------------------------------!
!                         Data                          !
+-------------------------------------------------------+
>
;OUTPUT FOR CONTROL PIPE QUEUED TO BE SENT
;INPUT FROM CONTROL PIPE QUEUED FOR THE BACKGROUND PROCESS

	DEFSTR (COLEN,0,35,18)	;LENGTH OF THIS BLOCK IN WORDS
	DEFSTR (COREL,1,1,1)	;NSP HAS RELEASED THIS BUFFER
	DEFSTR (COQUE,1,2,1)	;ATS HAS QUEUED THIS BUFFER
	DEFSTR (COBYT,1,35,18)	;NUMBER OF BYTES IN MESSAGE
	MSKSTR (COLNK,2,ADRMSK)	;ADDRESS OF NEXT MESSAGE ON THE CHAIN
	MSKSTR (COPIP,3,ADRMSK)	;ADDRESS OF CONTROL PIPE DATA
		CODAT==:4	;FIRST WORD CONTAINING DATA


repeat 0,<
+-------------------------------------------------------+
!                           !      Length in words      !
!-------------------------------------------------------!
!!!!                        !      Number of bytes      !
!-------------------------------------------------------!
!            Address of next block on chain             !
!-------------------------------------------------------!
!             Address of control pipe data              !
!-------------------------------------------------------!
!   data    !   data    !    data    !   data    !      !
!-------------------------------------------------------!
\                                                       \
\                                                       \
!-------------------------------------------------------!
!    data   !   data    !    data    !   data    !      !
+-------------------------------------------------------+
>

REPEAT 0,<
;DATA FROM CONTROL PIPE QUEUED FOR BACKGROUND PROCESS
;NOT USED

	DEFSTR (CIBYT,0,17,18)	;NUMBER OF BYTES IN MESSAGE
	DEFSTR (CILEN,0,35,18)	;LENGTH OF THIS BLOCK IN WORDS
	MSKSTR (CILNK,1,ADRMSK)	;ADDRESS OF NEXT BLOCK IN QUEUE
		CIDAT==:2	;FIRST WORD CONTAINING DATA
>

;DATA BY LINK TYPE

ILSIZE==:0
	DEFSTR (ILBSZ,ILSIZE,17,18) ;SIZE OF INPUT BUFFER IN WORDS
	DEFSTR (ILDSZ,ILSIZE,35,18) ;SIZE OF DATA BLOCK FOR THIS TYPE
ILNSPV==:1
	MSKSTR (ILVEC,ILNSPV,ADRMSK) ;ADDRESS OF VECTOR FOR NSP
ILMISC==:2
	DEFSTR (ILOUT,ILMISC,17,9) ;MAXIMUM NUMBER OF BUFFERED OUTPUT MESSAGES
	DEFSTR (ILSEG,ILMISC,35,18) ;SEGMENT SIZE FOR OUTPUT (WORDS)
ILOBJT==:3

;STORAGE FOR READING OPTIONAL DATA WHEN DATA PIPE IS CONNECTED

ATODWD==:6			;NUMBER OF WORDS NEEDED FOR OPTIONAL DATA
				; (16 BYTES PLUS A HEADER WORD)
	DEFSTR (ADLEN,0,35,18)	;NUMBER OF WORDS IN BLOCK
	DEFSTR (ADBYT,1,35,18)	;NUMBER OF BYTES IN OPTIONAL DATA
		ADDAT==:2	;OFFSET FOR START OF OPTIONAL DATA

;STORAGE FOR READING INTERRUPT MESSAGE

ATIMWD==:4			;WORDS NEEDED FOR INTERRUPT MESSAGE -
				; HEADER PLUS 16 8-BIT BYTES

;STORAGE FOR SAVING DEVICE NAME WITH TERMINAL DATA

ATDVWD==:4			;LENGTH OF FREE SPACE FOR TERMINAL NAME-
				; HEADER PLUS 6 8-BIT BYTES
	DEFSTR (AVLEN,0,35,18)	;NUMBER OF WORDS IN BLOCK
	DEFSTR (AVBYT,1,35,18)	;NUMBER OF BYTES IN DEVICE NAME
		AVDAT==:2	;OFFSET FOR FIRST BYTE

;STORAGE FOR READING HOST NAME

ATHNWD==:3			;LENGTH OF FREE SPACE FOR HOST NAME -
				; HEADER PLUS 6 ASCII CHARACTERS AND NULL
	DEFSTR (AHLEN,0,35,18)	;NUMBER OF WORDS IN BLOCK
		AHDAT==:1	;OFFSET OF FIRST WORD OF NAME

..BV==1B0			;FORCE FIRST DEFBUG TO BE IN ALPHABETICAL ORDER


;Command opcodes as sent to the MLC

MC.ORS==1	;Forget everything, I have been restarted. (Old code)
MC.RCN==4	;Reconnect this line to host x
MC.CON==5	;Connect this phys line to my TTY n
MC.FCN==6	;Forced connect
MC.HUP==7	;Hang up this line
MC.ALI==^D9	;Allocate increment
MC.ARQ==^D10	;Allocate request. What do you think it is for line?
MC.COB==^D11	;Clear output buffer
MC.CIB==^D12	;Clear input buffer
MC.DOB==^D13	;Tell me when (delay until) output buffer is empty
MC.ERR==^D16	;Error. I don't think that line is open.
MC.OSR==^D17	;Output status request. Tell me what level of out bfr is
MC.PVR==^D18	;Param Value Request. What is value of param N for line?
MC.PVS==^D19	;Param Value Set. Set this param for line.
MC.HPS==^D20	;Host Parameter Set under mask. Declares hosts down.
MC.RST==^D21	;Forget everything, I have been restarted. (New code)
MC.RRP=^D22	;Reset reply. Required answer to MC.RST
; Various definitions

MF.OBK==1B0		;Output blocked by MLC. (Must be sign bit)
MF.ONE==1B1		;Output buffer is not empty.
MF.BCN==1B2		;This connection is the result of a brdcst req.
MF.PCN==7B5		;Pending connection. Field is counted down.
MF.NSJ==1B6		;No Start Job. Forced connect, doesn't want EXEC
MF.OSP==1B7		;Output Status pending. (Due to SOBE/SOBF)
; The right-half flags are all requests for a command to be done.
MF.ALI==1B18		;Allocate for this line should be updated
MF.CON==1B19		;Connect request to be answered
MF.FCN==1B20		;Forced connect to be sent
MF.HUP==1B21		;Hang up this line. All done.
MF.ARQ==1B22		;Request confirmation of allocation
MF.COB==1B23		;Clear output buffer
MF.CIB==1B24		;Clear input buffer
MF.DOB==1B25		;Tell me when output buffer is empty
MF.NEW==1B26		;Pseudo command. Causes ^C after connection
MF.ERR==1B27		;Send an ERR about this line.
MF.OSR==1B28		;Get the output status for this line
MF.CRQ==777600		;The IOR of all above commands

;;; 100 - begin addition
	SUBTTL	CHAOSNET DEFINITIONS

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


;191 CHASBS==12
.FECHA==11
;.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

;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(CHAWBF)			;WAITING-FOR-WINDOW 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
;;;DEBUGGING ENTRIES
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

;;; 100: end of addition