Google
 

Trailing-Edge - PDP-10 Archives - SRI_NIC_PERM_SRC_3_19910112 - monitor/mexec.mac
There are 53 other files named mexec.mac in the archive. Click here to see a list.
; Edit= 8964 to MEXEC.MAC on 8-Sep-88 by RASPUZZI
;Add CLUDGR joining sequence to occur after CFSJYN has finished.
;Insert call to CLUJYN after CFS joining has completed.
; Edit= 8924 to MEXEC.MAC on 22-Aug-88 by LOMARTIRE
;Improve BUG. documentation
;[SRI-NIC]SRC:<MONITOR>MEXEC.MAC.2, 25-Nov-88 14:14:05, Edit by MKL
; v7 merge
;[SRI-NIC]XS:<NEWMON>MEXEC.MAC.2,  5-Dec-86 15:27:41, Edit by MKL
; add CRLF after system restarting message
;<6-1-MONITOR>MEXEC.MAC.3, 30-Oct-85 22:39:11, Edit by WHP4
; Support extended-section entry vector CRJOB's
;<6-1-MONITOR.FT6>MEXEC.MAC.2, 12-Aug-85 17:58:00, Edit by WHP4
;Stanford changes:
; Start networks at RUNDD3 instead of at RUNDD7 so TIME program works
; Run TIME program to set system clock.
; No CHKDMS or DDMP swap space low messages if system is remedial or
;  standalone.  Cuts down on CTY chatter when repairing system structure.
; Timestamped console messages
; If system brought up standalone, set Why Reload reason to "SA" automatically
; Support for MRC's HSYS% queuing scheme
; Have 5-minute warning about systemwide expunge
; Fix bug in LGOGOK.  Can't trust user's T1 being anything reasonable
; Output Welcome to ... message on logout and detach
; Less ugly logout message
; Make JOBDIR a GETAB% table  

; Edit= 8818 to MEXEC.MAC on 5-Apr-88 by RASPUZZI (TCO 7.1266)
;Install TCO 7.1266. Ask the startup questions when someone hits ENABLE/DISK
;buttons.
; UPD ID= 8681, RIP:<7.MONITOR>MEXEC.MAC.31,   6-Mar-88 19:54:09 by GSCOTT
;TCO 7.1253 - Don't cause CHKR to be blocked while we copy a DOB.
; UPD ID= 8654, RIP:<7.MONITOR>MEXEC.MAC.29,  18-Feb-88 20:46:47 by GSCOTT
;TCO 7.1230 - Add call to routine BLINKS which breaks links and advice and 
; defaults the CTY to type contained in CTYTY if SAVTRE is nonzero.
; UPD ID= 8643, RIP:<7.MONITOR>MEXEC.MAC.28,  16-Feb-88 14:25:06 by RASPUZZI
;TCO 7.1226 - Make the startup procedure smarter. Don't prompt for "Why
;	      reload?" or "Run CHECKD?" if we are recovering from a BUGHLT.
;	      Do prompt if we are being manually reloaded.
; UPD ID= 8551, RIP:<7.MONITOR>MEXEC.MAC.27,  11-Feb-88 11:02:46 by GSCOTT
;TCO 7.1218 - Update copyright date.
; UPD ID= 8423, RIP:<7.MONITOR>MEXEC.MAC.26,   4-Feb-88 13:23:54 by GSCOTT
;TCO 7.1210 - Set KLIPAF, LGFAIL, NODMPF, NOLODF, NOSERF, SERFOF, TTFSMS
; normally not dumpable.
; UPD ID= 8390, RIP:<7.MONITOR>MEXEC.MAC.25,  27-Jan-88 10:36:38 by GSCOTT
;TCO 7.1200 - Move most JSYS code in MEXEC to JSYSM.
; UPD ID= 272, RIP:<7.MONITOR>MEXEC.MAC.24,   6-Nov-87 15:06:52 by GSCOTT
;TCO 7.1119 - Replace occurances of [ASCIZ/<crlf>/] with CRLF, remove ASZSIX
; UPD ID= 265, RIP:<7.MONITOR>MEXEC.MAC.23,   6-Nov-87 11:53:26 by GSCOTT
;TCO 7.1117 - Remove code that is a slow no-op in CHKR having to do with drums.
; UPD ID= 249, RIP:<7.MONITOR>MEXEC.MAC.22,   4-Nov-87 16:42:11 by MCCOLLUM
;TCO 7.1112 - Fix STCRJB, EXEC2, and .GETJI to use LGSIDX.
;             Make system-wide expunge work for Boot Structure
;             Look for IPALOD and IPADMP on BS:
; UPD ID= 239, RIP:<7.MONITOR>MEXEC.MAC.21,   3-Nov-87 13:18:46 by GSCOTT
;TCO 7.1075 - Update TOC, repaginate.
; UPD ID= 237, RIP:<7.MONITOR>MEXEC.MAC.20,   2-Nov-87 11:43:28 by GSCOTT
;TCO 7.1107 - Don't hang in a DOBE at LOGDES
; UPD ID= 217, RIP:<7.MONITOR>MEXEC.MAC.19,  27-Oct-87 15:52:39 by RASPUZZI
;TCO 7.1086 - Broadcast system going down messages to all systems in the
;             cluster. Also, add system name to the System going down string.
; UPD ID= 204, RIP:<7.MONITOR>MEXEC.MAC.18,  23-Oct-87 15:24:50 by GSCOTT
;TCO 7.1081 - Call DOBINI during system startup, run SETSPD to copy DOB dumps
; UPD ID= 193, RIP:<7.MONITOR>MEXEC.MAC.17,  21-Oct-87 20:24:47 by RASPUZZI
;More of TCO 7.1076 - This time really put the changes in!
; UPD ID= 180, RIP:<7.MONITOR>MEXEC.MAC.16,  21-Oct-87 17:05:23 by RASPUZZI
;TCO 7.1076 - Start up the CLUDGR fork and make GETRTL global.
; UPD ID= 163, RIP:<7.MONITOR>MEXEC.MAC.15,  19-Oct-87 17:15:38 by LOMARTIRE
;TCO 7.1072 - Create the two new ENQ forks for cluster-wide ENQ
; UPD ID= 149, RIP:<7.MONITOR>MEXEC.MAC.14,  29-Sep-87 18:20:17 by MCCOLLUM
;More of TCO 7.1063 - Fix accidental register change in GTDAL%
; UPD ID= 130, RIP:<7.MONITOR>MEXEC.MAC.13,  23-Sep-87 15:45:15 by MCCOLLUM
;TCO 7.1063 - Check for STRX10 in CHKAC% and GTDAL%
; UPD ID= 104, RIP:<7.MONITOR>MEXEC.MAC.12,   8-Sep-87 17:24:06 by GSCOTT
;TCO 7.1051 - Implement two new GETAB words called ACTJOB and WHOJOB.
; UPD ID= 101, RIP:<7.MONITOR>MEXEC.MAC.11,   4-Sep-87 10:55:19 by MCCOLLUM
;TCO 7.1050 - Call RESLCI instead of RESLCK in RUNDD
; UPD ID= 73, RIP:<7.MONITOR>MEXEC.MAC.10,  12-Aug-87 14:47:43 by MCCOLLUM
;TCO 7.1037 - SC.ALM in SCAMPI is now SC.MAL
; UPD ID= 63, RIP:<7.MONITOR>MEXEC.MAC.9,  10-Aug-87 14:12:21 by RASPUZZI
;TCO 7.1034 - Move IPCF to XCDSEC. Change call to LOGOMO to call KJOMO.
; UPD ID= 45, RIP:<7.MONITOR>MEXEC.MAC.7,  17-Jul-87 12:45:58 by RASPUZZI
;TCO 7.1022 - Prevent ILMNRFs during JOBCOF at LDTACH when the controlling
; terminal disappears on us before we expect it to.
; UPD ID= 37, RIP:<7.MONITOR>MEXEC.MAC.6,   9-Jul-87 16:13:32 by RASPUZZI
;TCO 7.1019 - Fix mistake in TCO 7.1003 and then castrate engineer.
; UPD ID= 17, RIP:<7.MONITOR>MEXEC.MAC.5,   5-Jun-87 11:44:31 by MCCOLLUM
;TCO 7.1010 - Fix up ENACT to check for a null file and return an
;  error. Fix RUNDI1 to display a more useful error message.
; UPD ID= 15, RIP:<7.MONITOR>MEXEC.MAC.4,   2-Jun-87 15:30:28 by GSCOTT
;TCO 7.1006 - Repair various accounting problems - put back lost autopatch 
;  edit 7477, install autopatch edits 7484 to 7488.
; UPD ID= 13, RIP:<7.MONITOR>MEXEC.MAC.3,  28-May-87 16:25:08 by RASPUZZI
;TCO 7.1003 - Put a timeout restriction on the questions "Why Reload?"
;  and "Run CHECKD?" so that the system will boot if they are not
;  answered in a reasonable amount of time.
; *** Edit 7479 to MEXEC.MAC by MCCOLLUM on 12-May-87, for SPR #21607
; Turn of LAT lines when shuting down system at CHKHS4: 
; *** Edit 7456 to MEXEC.MAC by GSCOTT on 23-Apr-87, for SPR #19597
; Write session records properly when a job is attached, detached, or its
; session remark is changed. Also make sure session start time is correct. 
; *** Edit 7432 to MEXEC.MAC by MCCOLLUM on 1-Apr-87, for SPR #21552
; Rearrange code and define dummy routine XCKNI so building monitors with
; KNIN=0 will work 
; *** Edit 7414 to MEXEC.MAC by RASPUZZI on 10-Feb-87
; Make the LGOUT% JSYS obey ACJ's wishes
; *** Edit 7316 to MEXEC.MAC by RASPUZZI on 11-Jun-86, for SPR #20381
; Change MEXEC to start SETSPD at entry vector plus 1 when setting terminal
; lines, etc for system startup. 
; *** Edit 7279 to MEXEC.MAC by MRASPUZZI on 31-Mar-86, for SPR #20779
; Make MEXEC setup a PRARG block when CJ%FIL is set for an EXEC besides the
; system EXEC
; *** Edit 7259 to MEXEC.MAC by WONG on 14-Mar-86, for SPR #18580
; Add batch info to Usage Session Record.
; *** Edit 7247 to MEXEC.MAC by LOMARTIRE on 19-Feb-86
; Implement OFN caching 
;Edit 7247 - Add CHKOFN for OFN caching cleanup
; *** Edit 7211 to MEXEC.MAC by GRANT on 18-Dec-85
; Add CI counters for WATCH 
; Edit 7173 to MEXEC.MAC by PALMIERI on 23-Oct-85 (TCO 6.1.1542)
; Move modules NIUSR and LLMOP to an extended section. This required the
; changing of some global routine names in LLMOP; Therefor the changes to
; MEXEC, JSYSA, and FORK. 
; Edit 7160 to MEXEC.MAC by WAGNER on 16-Oct-85
; Modify JOBCOF code to respect ACJs wishes regarding logout of jobs even if
; detached job timeout has expired. 
;Edit 7160 Fix Logout of detached jobs to obey ACJ even if it denies
; request to logout. If ACJ denies, wait COFTIM and ask again.
; UPD ID= 2290, SNARK:<6.1.MONITOR>MEXEC.MAC.284,  29-Jun-85 22:38:22 by GRANT
;TCO 6.1.1477 - IPALOD has new entry point for monitor
; UPD ID= 2238, SNARK:<6.1.MONITOR>MEXEC.MAC.283,  19-Jun-85 10:57:37 by GROSSMAN
;TCO 6.1.1461 - Add call to LLMJB0 to CHKR.
; UPD ID= 2220, SNARK:<6.1.MONITOR>MEXEC.MAC.282,  12-Jun-85 17:45:43 by GRANT
;Change IPAFOO back to IPALOD
; UPD ID= 2120, SNARK:<6.1.MONITOR>MEXEC.MAC.281,   5-Jun-85 09:55:21 by MCCOLLUM
;TCO 6.1.1406  - Update copyright notice.
; UPD ID= 2026, SNARK:<6.1.MONITOR>MEXEC.MAC.280,  28-May-85 16:34:16 by MCCOLLUM
;Add ERJMPs
; UPD ID= 1965, SNARK:<6.1.MONITOR>MEXEC.MAC.279,  13-May-85 10:11:15 by GRANT
;TCO 6.1.1377 - Load CI ucode into resident memory during system startup. CIFORK
;no longer does loading of CI ucode.
; UPD ID= 1890, SNARK:<6.1.MONITOR>MEXEC.MAC.278,   4-May-85 15:14:42 by MCCOLLUM
;TCO 6.1.1238 - Fix more BUG. documentation
; UPD ID= 1862, SNARK:<6.1.MONITOR>MEXEC.MAC.277,   2-May-85 15:02:58 by GROSSMAN
;TCO 6.1.1354 - Fix CRJOB hangs when created job gets logged out too soon.
; UPD ID= 1858, SNARK:<6.1.MONITOR>MEXEC.MAC.276,  30-Apr-85 15:58:06 by LOMARTIRE
;TCO 6.1.1350 - Set local time from cluster first, then local system
; UPD ID= 1838, SNARK:<6.1.MONITOR>MEXEC.MAC.275,  26-Apr-85 15:09:38 by MCCOLLUM
;TCO 6.1.1238 - Fix more BUG. documentation
; UPD ID= 1837, SNARK:<6.1.MONITOR>MEXEC.MAC.274,  26-Apr-85 15:06:45 by MCCOLLUM
;TCO 6.1.1238 - Fix more BUG. documentation
; UPD ID= 1768, SNARK:<6.1.MONITOR>MEXEC.MAC.273,  22-Apr-85 09:02:38 by GRANT
;More 6.1.1284 - CALL CFSKPR should have been removed
; UPD ID= 1711, SNARK:<6.1.MONITOR>MEXEC.MAC.272,   5-Apr-85 13:47:27 by MCCOLLUM
;TCO 6.1.1238 - Fix BUG. documentation
; UPD ID= 1672, SNARK:<6.1.MONITOR>MEXEC.MAC.271,  25-Mar-85 08:20:11 by GRANT
;TCO 6.1.1284 - Change TEFORK to CIFORK and keep it around to do CI stuff
; UPD ID= 1643, SNARK:<6.1.MONITOR>MEXEC.MAC.270,  18-Mar-85 08:10:03 by GRANT
;More TCO 6.1.1245 - Minor enhancement
; UPD ID= 1624, SNARK:<6.1.MONITOR>MEXEC.MAC.269,  12-Mar-85 15:57:06 by LOMARTIRE
;TCO 6.1.1247 - Remove the extra wait after call to CFSJYN
; UPD ID= 1613, SNARK:<6.1.MONITOR>MEXEC.MAC.268,  11-Mar-85 09:54:05 by GRANT
;TCO 6.1.1245 - Broadcast cease, shutdown canceled, and timesharing is over.
;Add a check for cluster ceases in CHKR.
; UPD ID= 1581, SNARK:<6.1.MONITOR>MEXEC.MAC.267,   4-Mar-85 08:00:58 by LOMARTIRE
;TCO 6.1.1227 - Move the starting of TEFORK earlier to help insure CFS joining
; UPD ID= 1283, SNARK:<6.1.MONITOR>MEXEC.MAC.266,   7-Jan-85 11:03:26 by HAUDEL
;TCO 6.1.1115 - Add ERJMPs after a few JSYSes in logout,attach,and detach code
; Fix typo in UPD ID=1249.
; UPD ID= 1270, SNARK:<6.1.MONITOR>MEXEC.MAC.264,   4-Jan-85 15:01:26 by MCCOLLUM
;TCO 6.1.1111 - Get JFN's for job 0 forks with GJ%ACC on
; UPD ID= 1249, SNARK:<6.1.MONITOR>MEXEC.MAC.263,  31-Dec-84 13:12:53 by MCCOLLUM
;TCO 6.1.1112 - In GETAB%, translate local job number to global for DEVUNT table.
; UPD ID= 1230, SNARK:<6.1.MONITOR>MEXEC.MAC.262,  19-Dec-84 18:35:28 by GRANT
;Move SAVTRE to STG.MAC
; UPD ID= 1218, SNARK:<6.1.MONITOR>MEXEC.MAC.261,  18-Dec-84 12:48:47 by TBOYLE
;TCO 6.1.1092 - Fix jobs hung in LOGOUT - Put CFOBF at LOG2 after SOBE loop
; UPD ID= 1018, SNARK:<6.1.MONITOR>MEXEC.MAC.260,   9-Nov-84 13:25:40 by GRANT
;TCO 6.2278 - fix BUGxxx output
; UPD ID= 944, SNARK:<6.1.MONITOR>MEXEC.MAC.259,   4-Nov-84 15:25:06 by GLINDELL
;More TCO 6.1.1021 - Change MDDTP to reflect MDDT's new position in XCDSEC
; UPD ID= 5050, SNARK:<6.MONITOR>MEXEC.MAC.258,  31-Oct-84 18:08:38 by MOSER
;TCO 6.2256 - FIX CRJOB IF CJ%WTA SPECIFIED
; UPD ID= 5038, SNARK:<6.MONITOR>MEXEC.MAC.257,  30-Oct-84 13:55:40 by MCLEAN
;FIX LOGOUT
; UPD ID= 5037, SNARK:<6.MONITOR>MEXEC.MAC.256,  30-Oct-84 09:59:56 by PAETZOLD
;TCO 6.2267 - Save CX in JOBCOF.
; UPD ID= 5003, SNARK:<6.MONITOR>MEXEC.MAC.255,  24-Oct-84 20:15:31 by GLINDELL
;Put in a call to DCNJB0 in CHKR
; UPD ID= 4974, SNARK:<6.MONITOR>MEXEC.MAC.254,  22-Oct-84 16:31:20 by GRANT
;Remove references to FTCI
; UPD ID= 4965, SNARK:<6.MONITOR>MEXEC.MAC.253,  19-Oct-84 14:46:22 by GLINDELL
;More TCO 6.1.1021 - clear T3 before SOUT in LOGBUG
; UPD ID= 4964, SNARK:<6.MONITOR>MEXEC.MAC.252,  19-Oct-84 13:42:26 by GLINDELL
;More TCO 6.1.1021 - get only section-relative address of BUG. for compare
; UPD ID= 4948, SNARK:<6.MONITOR>MEXEC.MAC.251,  17-Oct-84 15:17:44 by HAUDEL
;TCO 6.2250 - Add an ERJMP after an ODTIM% in LOGJ2 code.
; UPD ID= 4947, SNARK:<6.MONITOR>MEXEC.MAC.250,  17-Oct-84 13:58:59 by HAUDEL
;TCO 6.2249 - Add some ERJMPs after a few JSYSes.
; UPD ID= 4945, SNARK:<6.MONITOR>MEXEC.MAC.249,  17-Oct-84 11:57:16 by TGRADY
; TCO 6.2247 (QAR 706189) Print proper job number in ATTACH JSYS.
; TCO 6.2214 (QAR 706279) Fix up STCRJB and ELOGO to understand that JOBONT
; contains GLOBAL job numbers, not local.  Oversight in edit 4785.
; UPD ID= 4944, SNARK:<6.MONITOR>MEXEC.MAC.248,  17-Oct-84 10:55:47 by HAUDEL
;TCO 6.2246 - Add ERJMP .+1 after BOUTs in LOGTIM: code.
; UPD ID= 4935, SNARK:<6.MONITOR>MEXEC.MAC.247,  15-Oct-84 13:06:30 by GRANT
;The assembly switch CFSCOD has been eliminated
; UPD ID= 4915, SNARK:<6.MONITOR>MEXEC.MAC.246,  10-Oct-84 17:13:06 by GLINDELL
;TCO 6.1.1021 - 6.1 address space
;	BGPTR entries are now two words long (full 30-bit addresses)
; UPD ID= 4884, SNARK:<6.MONITOR>MEXEC.MAC.245,  26-Sep-84 16:40:18 by GRANT
;In CHKR, CALL KLPRCT
; UPD ID= 4882, SNARK:<6.MONITOR>MEXEC.MAC.244,  26-Sep-84 15:59:55 by GRANT
;TCO 6.2225 - Add "save a tree" option to LOGBUG
; UPD ID= 4863, SNARK:<6.MONITOR>MEXEC.MAC.243,  23-Sep-84 15:24:41 by TBOYLE
;Clear output buffer during LOGOUT after STPAR in LOG1
; UPD ID= 4813, SNARK:<6.MONITOR>MEXEC.MAC.242,  17-Sep-84 10:13:22 by PURRETTA
;Update copyright notice
; UPD ID= 4785, SNARK:<6.MONITOR>MEXEC.MAC.241,  31-Aug-84 14:29:47 by TGRADY
;TCO 6.2214 (QAR 706071) Fix up use of CRJONJ and JOBONT for CRJOB'ed jobs.
; UPD ID= 4777, SNARK:<6.MONITOR>MEXEC.MAC.240,  30-Aug-84 10:48:24 by PAETZOLD
;TCO 6.2211 - Carrier off needs to preserve KIMUFL and KIMUPC.
; UPD ID= 4771, SNARK:<6.MONITOR>MEXEC.MAC.239,  29-Aug-84 13:57:18 by TGRADY
;TCO 6.2201 (QAR 706198) - Remove edit 4444 (TCO 6.2121) and fix the
;general problem of needing a local job index in the USAGE record.
; UPD ID= 4743, SNARK:<6.MONITOR>MEXEC.MAC.238,  24-Aug-84 09:43:58 by PAETZOLD
;TCO 6.2191 - Change unsafe SETJSB calls to MAPJSB.
; UPD ID= 4702, SNARK:<6.MONITOR>MEXEC.MAC.237,  16-Aug-84 13:28:15 by GROSSMAN
;More TCO 6.2176 - Reverse order of IPALOD and KNIJB0.
; UPD ID= 4698, SNARK:<6.MONITOR>MEXEC.MAC.236,  15-Aug-84 18:51:40 by GROSSMAN
;TCO 6.2176 - Add call to KNIJB0 in CHKR.
; UPD ID= 4677, SNARK:<6.MONITOR>MEXEC.MAC.235,  13-Aug-84 10:26:47 by GLINDELL
;Type out the full 30-bit address on entry to the MX
; UPD ID= 4676, SNARK:<6.MONITOR>MEXEC.MAC.234,  11-Aug-84 00:54:45 by TBOYLE
;TCO 6.2171 Save all registers at JOBCOF.
; UPD ID= 4620, SNARK:<6.MONITOR>MEXEC.MAC.233,  28-Jul-84 15:58:40 by MOSER
;TCO 6.2083 - ENHANCE MONBK - ADD MONBKX
; UPD ID= 4610, SNARK:<6.MONITOR>MEXEC.MAC.232,  27-Jul-84 14:51:19 by TBOYLE
;New SYSERR - At LOGBF6-1 use XMOVEI.
; UPD ID= 4507, SNARK:<6.MONITOR>MEXEC.MAC.231,  12-Jul-84 21:55:51 by TGRADY
;TCO 6.2126 Use Global job number as argument to GTOKM .GOATJ function
; UPD ID= 4455, SNARK:<6.MONITOR>MEXEC.MAC.230,  12-Jul-84 10:43:05 by CDUNN
;More TCO 6.1127 Add call to SCSLGO at FLOGO to delete SCS% data on top 
;fork kill
; UPD ID= 4444, SNARK:<6.MONITOR>MEXEC.MAC.229,   6-Jul-84 16:54:45 by TBOYLE
;TCO 6.2121 - Make UCKSET convert jobno to local before mapping checkpoint pg.
; UPD ID= 4418, SNARK:<6.MONITOR>MEXEC.MAC.228,   2-Jul-84 13:46:13 by TGRADY
;TCO 6.2114 - Fix typo in TTY2GL to return waiting fork number...
; UPD ID= 4364, SNARK:<6.MONITOR>MEXEC.MAC.227,  20-Jun-84 15:59:58 by TBOYLE
;TCO 6.2104 - Fix session start and end times at USGSEN.
; UPD ID= 4363, SNARK:<6.MONITOR>MEXEC.MAC.226,  20-Jun-84 15:10:36 by TGRADY
;TCO 6.2103 (QAR 706052) - Fix ATACH% to prevent 'Wheel or Opr required' error
; UPD ID= 4358, SNARK:<6.MONITOR>MEXEC.MAC.225,  18-Jun-84 15:48:47 by TGRADY
;TCO 6.2077 (QAR 706022) Make GETAB% return a -1 for non-existant jobs.
; UPD ID= 4356, SNARK:<6.MONITOR>MEXEC.MAC.224,  18-Jun-84 14:13:38 by GRANT
;TCO 6.2102 (QAR 706050) - During system shutdown disallow incoming nvt
;(ARPANET and DECnet) logins.
; UPD ID= 4300, SNARK:<6.MONITOR>MEXEC.MAC.223,   4-Jun-84 23:01:34 by MOSER
;TCO 6.2059 - ALLOW EXEC XCT ONLY - FIX CRJOB - CHANGES FOR NON WHEEL STARTUP
; UPD ID= 4219, SNARK:<6.MONITOR>MEXEC.MAC.222,  14-May-84 18:55:34 by WEISBACH
;~6.0 - Add call to LAT host initialization (LATINI)
; UPD ID= 4211, SNARK:<6.MONITOR>MEXEC.MAC.221,  11-May-84 12:15:11 by GRANT
;In RUNDD2, add call to SRVCFS (moved here from CFSJYN in CFSSRV)
; UPD ID= 4207, SNARK:<6.MONITOR>MEXEC.MAC.220,  11-May-84 08:18:39 by GRANT
;In EGET, ERJMP after the GET%
; UPD ID= 4128, SNARK:<6.MONITOR>MEXEC.MAC.219,  25-Apr-84 11:07:42 by LOMARTIRE
;TCO 6.2046 - Record fork number for various job 0 forks created in RUNDD
; UPD ID= 4115, SNARK:<6.MONITOR>MEXEC.MAC.218,  24-Apr-84 12:59:05 by TGRADY
;TCO 6.2042 - Fix CFSILJ BUGCHK's from GETJI% called with .TTDES+n
; UPD ID= 4069, SNARK:<6.MONITOR>MEXEC.MAC.217,  11-Apr-84 19:12:50 by MOSER
;TCO 6.2023 - REMOVE ALL ERCAL INSTRUCTIONS
; UPD ID= 4062, SNARK:<6.MONITOR>MEXEC.MAC.215,  11-Apr-84 14:47:35 by GRANT
;In IPACHK, more graceful handling of no IPALOD or IPADMP
; UPD ID= 4012, SNARK:<6.MONITOR>MEXEC.MAC.214,  31-Mar-84 08:10:17 by GRANT
;Remove SEARCH of SCAPAR
; UPD ID= 4001, SNARK:<6.MONITOR>MEXEC.MAC.213,  28-Mar-84 20:46:37 by GRANT
;In IPACHK, look on PS:<SYSTEM> instead of SYSTEM:
; UPD ID= 3998, SNARK:<6.MONITOR>MEXEC.MAC.212,  28-Mar-84 17:22:15 by GUNN
;Revoke UPD ID 3741 - Put under FTNSPSRV conditional.
; UPD ID= 3946, SNARK:<6.MONITOR>MEXEC.MAC.211,  19-Mar-84 16:57:31 by MOSER
;TCO 6.2003 - ADD .JILJI FUNCTION OF GETJI
; UPD ID= 3924, SNARK:<6.MONITOR>MEXEC.MAC.210,  14-Mar-84 10:51:46 by TGRADY
;TCO 6.1998 - Fix ELOGO to compare user-specified job number to GBLJNO,
;   not JOBNO
;
; UPD ID= 3869, SNARK:<6.MONITOR>MEXEC.MAC.209,   7-Mar-84 11:30:21 by LEACHE
;More TCO 6.1969 - move init of SWPMWF from MEXEC to PAGUTL
; UPD ID= 3850, SNARK:<6.MONITOR>MEXEC.MAC.207,   5-Mar-84 12:12:38 by GRANT
;In IPACHK, do dumping as well as loading.
; UPD ID= 3816, SNARK:<6.MONITOR>MEXEC.MAC.206,  29-Feb-84 17:04:39 by LEACHE
;TCO 6.1969 Change swappable monitor load to reflect single-pass load
; UPD ID= 3802, SNARK:<6.MONITOR>MEXEC.MAC.205,  29-Feb-84 01:44:07 by TGRADY
; Implement Global Job Numbers
; - In SYSINE, assign a Global Job number from CFS, and save it in GBLJNO
; - In STCRJB, return Global job number to CRJOB creator, put index in JOBONT
; - In RUNDD3, Initialize CFS Global Job Number database...
; - In HSYS41:, convert local job index to global job number for LGOUT Jsys
; - In LOG2, call JBAVAL to release Global job number just before HLTJB call.
; - In LOGJOB, Print Global job number during logout.
; - In ELOGO, translate user-specified global job number into local index
; - In .GJINF, use GBLJNO to return user's own job number, instead of JOBNO
; - In .GETAB, overhaul GTTAB table to use new GTJOB routine to translate
;   user-specified Global Job number into local job index.  Make the tables'
;   'size' be the highest legal Global Job number, MXGLBS, for range checking
;   instead of NJOBS, which is only the highest index value.
;   Also, create jacket routine TTY2GL to convert job index returned by
;   GTBTTF to a global job number
; - In .GETJI, translate user-specified global job number into local index
; - In GETJI4, translate job index into Global job number before returning it.
; - In GETJIT table, return other jobs Global Job number (from JSB)
; - In ATACH1, same as .GETJI
;
; UPD ID= 3741, SNARK:<6.MONITOR>MEXEC.MAC.204,  22-Feb-84 17:27:14 by PAETZOLD
;Revoke previous edit until he gets it right.  
; UPD ID= 3725, SNARK:<6.MONITOR>MEXEC.MAC.203,  22-Feb-84 11:39:52 by GUNN
;~6.0 - Add call to initialize Ethernet LLMOP Protocol Servers
; UPD ID= 3721, SNARK:<6.MONITOR>MEXEC.MAC.202,  22-Feb-84 05:36:57 by GRANT
;Call CFSJ0 from CHKR
; UPD ID= 3698, SNARK:<6.MONITOR>MEXEC.MAC.201,  15-Feb-84 21:28:14 by MURPHY
;Make definition of MDDT include section number so MDDT$G always works.
; UPD ID= 3741, SNARK:<6.MONITOR>MEXEC.MAC.204,  22-Feb-84 17:27:14 by PAETZOLD
;Revoke previous edit until he gets it right.  
; UPD ID= 3725, SNARK:<6.MONITOR>MEXEC.MAC.203,  22-Feb-84 11:39:52 by GUNN
;~6.0 - Add call to initialize Ethernet LLMOP Protocol Servers
; UPD ID= 3721, SNARK:<6.MONITOR>MEXEC.MAC.202,  22-Feb-84 05:36:57 by GRANT
;Call CFSJ0 from CHKR
; UPD ID= 3698, SNARK:<6.MONITOR>MEXEC.MAC.201,  15-Feb-84 21:28:14 by MURPHY
;Make definition of MDDT include section number so MDDT$G always works.
; UPD ID= 3656, SNARK:<6.MONITOR>MEXEC.MAC.200,   4-Feb-84 10:32:35 by MILLER
;Call BRDTIM if CFS stuff is around
; UPD ID= 3648, SNARK:<6.MONITOR>MEXEC.MAC.199,   2-Feb-84 14:35:36 by MURPHY
;Ditto - fix bugs.
; UPD ID= 3640, SNARK:<6.MONITOR>MEXEC.MAC.198,   2-Feb-84 11:53:23 by MURPHY
;Different way of getting to BOOT to load swap mon.
; UPD ID= 3633, SNARK:<6.MONITOR>MEXEC.MAC.197,   1-Feb-84 22:08:42 by MURPHY
;Reference bug strings and pointers in symsec.
; UPD ID= 3565, SNARK:<6.MONITOR>MEXEC.MAC.196,  27-Jan-84 13:34:03 by PAETZOLD
;More TCO 6.1954 - Make CHKPER and DDPPER resident.  Fix DDPWAT bug.
; UPD ID= 3557, SNARK:<6.MONITOR>MEXEC.MAC.195,  26-Jan-84 13:56:47 by PAETZOLD
;More TCO 6.1954 - Make CHKPER and DDPPER global.  Make DDPDUE force DDMP.
; UPD ID= 3539, SNARK:<6.MONITOR>MEXEC.MAC.194,  25-Jan-84 15:14:38 by PAETZOLD
;TCO 6.1954 - Add code for DDPDUE and CHKDUE.
; UPD ID= 3510, SNARK:<6.MONITOR>MEXEC.MAC.193,  23-Jan-84 09:44:12 by PRATT
;TCO 6.1924 - Use "display type" block with "msg" block in WROPER
; UPD ID= 3490, SNARK:<6.MONITOR>MEXEC.MAC.192,  20-Jan-84 11:09:27 by CDUNN
;More TCO 6.1127 - Add new "temp" fork at startup to handle SCA buffer deferal
;requests until after DDMP has mounted PS.
; UPD ID= 3456, SNARK:<6.MONITOR>MEXEC.MAC.191,  13-Jan-84 17:16:14 by TBOYLE
;TCO 6.1933 - (RUNDD4) Do processing if SPRCNT not reset, and start 
;SYSERR queue
; UPD ID= 3449, SNARK:<6.MONITOR>MEXEC.MAC.190,  12-Jan-84 14:22:41 by PAETZOLD
;TCO 6.1929 - Change FKJOBN to FKJBN
; UPD ID= 3420, SNARK:<6.MONITOR>MEXEC.MAC.189,   6-Jan-84 18:13:00 by MILLER
;Add CFSCOD conditional around call to CFTADC
; UPD ID= 3418, SNARK:<6.MONITOR>MEXEC.MAC.188,   6-Jan-84 09:07:27 by PRATT
;TCO 6.1912 - In WROPER, QU%NRS should be set in the arg block, not ac 1 
; UPD ID= 3310, SNARK:<6.MONITOR>MEXEC.MAC.187,  13-Dec-83 18:16:03 by PAETZOLD
;TCO 6.1906 - Add code to update DDPTIM
; UPD ID= 3270, SNARK:<6.MONITOR>MEXEC.MAC.186,   7-Dec-83 09:06:17 by MILLER
;TCO 6.1806. Add calls to DTTIME
; UPD ID= 3192, SNARK:<6.MONITOR>MEXEC.MAC.185,  18-Nov-83 11:01:36 by PAETZOLD
;Do not call CHKIMP
; UPD ID= 3183, SNARK:<6.MONITOR>MEXEC.MAC.184,  17-Nov-83 14:15:55 by PRATT
;TCO 6.1796 - Lots of ERJMPs after TTMSGs in case of refusals
; UPD ID= 3151, SNARK:<6.MONITOR>MEXEC.MAC.183,  15-Nov-83 09:47:34 by PAETZOLD
;TCO 6.1862 - Fix problem with incorrect .XPCN2 word being returned in XPEEK
; UPD ID= 3114, SNARK:<6.MONITOR>MEXEC.MAC.182,   8-Nov-83 09:01:15 by MCINTEE
;~6.0 Remove NSP% jsys
; UPD ID= 3095, SNARK:<6.MONITOR>MEXEC.MAC.181,   3-Nov-83 23:37:50 by GROSSMAN
;TCO 6.1849 - Reset CRJTTY to a value of -1 only during CRJOB startup.
; UPD ID= 3084, SNARK:<6.MONITOR>MEXEC.MAC.180,  28-Oct-83 15:54:56 by HAUDEL
;TCO 6.1840 - Add an ERJMP .+1 after TTMSG 
; UPD ID= 3004, SNARK:<6.MONITOR>MEXEC.MAC.179,   7-Oct-83 17:55:34 by GUNN
;~6.0 Add call to LLMRSJ from FLOGO to clean up LLMOP resources at logout.
; UPD ID= 2993, SNARK:<6.MONITOR>MEXEC.MAC.178,   5-Oct-83 14:49:33 by PAETZOLD
;More TCO 6.1733 - Remove call to IMPBEG.  NCPFRK has gone away.
; UPD ID= 2978, SNARK:<6.MONITOR>MEXEC.MAC.177,   4-Oct-83 08:07:04 by MILLER
;TCO 6.1806 Once again.
; UPD ID= 2944, SNARK:<6.MONITOR>MEXEC.MAC.176,  27-Sep-83 20:35:08 by MILLER
;MORE TCO 6.1806. CHECK ON TAD IN CHKR
; UPD ID= 2930, SNARK:<6.MONITOR>MEXEC.MAC.175,  23-Sep-83 14:00:41 by MILLER
;More TCO 6.1806. Output date and time so operator knows
; UPD ID= 2926, SNARK:<6.MONITOR>MEXEC.MAC.174,  23-Sep-83 10:37:51 by MILLER
;TCO 6.1806. Try to get TAD from CFS
; UPD ID= 2914, SNARK:<6.MONITOR>MEXEC.MAC.173,  20-Sep-83 15:33:39 by LOMARTIRE
;TCO 6.1791 - Do not allow ATACH from batch unless WHEEL or OPR enabled
; UPD ID= 2842, SNARK:<6.MONITOR>MEXEC.MAC.172,  17-Aug-83 21:41:01 by MURPHY
;More 6.1525 - Separate section 0/1 maps.  Remove NRCOD from sec 0 map.
; UPD ID= 2807, SNARK:<6.MONITOR>MEXEC.MAC.171,   9-Aug-83 11:46:15 by MURPHY
;Move MOVCST from here to PAGUTL.
; UPD ID= 2797, SNARK:<6.MONITOR>MEXEC.MAC.170,   4-Aug-83 00:30:32 by LEACHE
;TCO 6.1641  Change swappable freespace initialization
; UPD ID= 2768, SNARK:<6.MONITOR>MEXEC.MAC.169,  25-Jul-83 17:48:48 by MCCOLLUM
;TCO 6.1743 - Add XPEEK% JSYS
; UPD ID= 2749, SNARK:<6.MONITOR>MEXEC.MAC.168,  22-Jul-83 16:38:22 by PAETZOLD
;TCO 6.1733 - Reflect that NCP has gone away.
; UPD ID= 2745, SNARK:<6.MONITOR>MEXEC.MAC.167,  22-Jul-83 16:33:16 by MURPHY
;More 6.1568 - Make COFTIM settable by SMON.
;TCO 6.1719 - Customer-selectable hangup action.
; UPD ID= 2673, SNARK:<6.MONITOR>MEXEC.MAC.166,   5-Jul-83 16:04:54 by MILLER
;Various changes for CFS CI error recovery
; UPD ID= 2669, SNARK:<6.MONITOR>MEXEC.MAC.165,   5-Jul-83 15:48:20 by MOSER
;TCO 6.1568 - USE COFMIN AS VALUE FOR CARRIER OFF WAIT BEFORE LOGOUT
; UPD ID= 2667, SNARK:<6.MONITOR>MEXEC.MAC.164,   5-Jul-83 13:32:48 by MURPHY
;More 6.1525 - Remove hidden symbol table, add symtab in separate section.
; UPD ID= 2602, SNARK:<6.MONITOR>MEXEC.MAC.163,  20-Jun-83 15:40:03 by HALL
;TCO 6.1689 - Move fork tables to extended section
;	Reference FKINT bits via DEFSTR
; UPD ID= 2577, SNARK:<6.MONITOR>MEXEC.MAC.162,  10-Jun-83 17:39:29 by PAETZOLD
;TCO 6.1680 - Turn on QU%NRS in WROPR0
; UPD ID= 2546, SNARK:<6.MONITOR>MEXEC.MAC.161,  31-May-83 16:44:49 by MURPHY
;TCO 6.1525 - Move subsys names tables to ext section.
; UPD ID= 2382, SNARK:<6.MONITOR>MEXEC.MAC.160,  29-Apr-83 15:03:02 by MCINTEE
;TCO 6.1630 - MONBK/PSIMB fix
; UPD ID= 2286, SNARK:<6.MONITOR>MEXEC.MAC.158,  16-Apr-83 19:14:33 by PAETZOLD
;TCO 6.1557 - TCP Merge - Delete old edit history - Update copyright.
; UPD ID= 2245, SNARK:<6.MONITOR>MEXEC.MAC.157,  12-Apr-83 13:15:09 by MCINTEE
;Remove IFNDEF FTNSPSRV
; UPD ID= 2219, SNARK:<6.MONITOR>MEXEC.MAC.156,   8-Apr-83 13:06:09 by MILLER
;TCO 6.1602 again. Fix call to RUNDII in IPACHK
; UPD ID= 2218, SNARK:<6.MONITOR>MEXEC.MAC.155,   8-Apr-83 12:29:03 by MILLER
;Fix IPACHK some
; UPD ID= 2216, SNARK:<6.MONITOR>MEXEC.MAC.154,   8-Apr-83 09:37:05 by MILLER
;Once more. Wait for KLIPA reload at system start-up
; UPD ID= 2215, SNARK:<6.MONITOR>MEXEC.MAC.153,   8-Apr-83 08:36:24 by MILLER
;TCO 6.1602. Load KLIPA microcode when needed
; UPD ID= 2205, SNARK:<6.MONITOR>MEXEC.MAC.152,   8-Apr-83 05:58:57 by WACHS
;TCO 6.1604 - Call KLIPA initialization late
; UPD ID= 2130, SNARK:<6.MONITOR>MEXEC.MAC.151,   2-Apr-83 22:46:44 by LEACHE
;TCO 6.1247 Add centralized penalties for bad passwords
; UPD ID= 2111, SNARK:<6.MONITOR>MEXEC.MAC.149,  28-Mar-83 19:43:31 by MILLER
;TCO 6.1094. Get rid of GETALF
; UPD ID= 2102, SNARK:<6.MONITOR>MEXEC.MAC.148,  28-Mar-83 17:43:19 by MURPHY
;TCO 6.1472 - Minor cleanup re. LSTERR.
; UPD ID= 1995, SNARK:<6.MONITOR>MEXEC.MAC.147,  15-Mar-83 10:58:40 by MILLER
;TCO 6.1544. Call MAPPHQ when mapping BOOT
; UPD ID= 1967, SNARK:<6.MONITOR>MEXEC.MAC.146,  10-Mar-83 17:57:28 by CDUNN
;More TCO 6.1127 - Add lost edit to call SC.RAP to clean up SCA data as
;needed.
; UPD ID= 1929, SNARK:<6.MONITOR>MEXEC.MAC.145,   7-Mar-83 21:02:14 by CDUNN
;Change default to include KLIPA code
; UPD ID= 1913, SNARK:<6.MONITOR>MEXEC.MAC.144,   3-Mar-83 13:05:37 by MCINTEE
;TCO 6.1532 - Remove SE1ENT & SE0ENT in routine STCJB2. Put in a TSTMS0.
; UPD ID= 1908, SNARK:<6.MONITOR>MEXEC.MAC.143,   2-Mar-83 17:30:32 by MILLER
;TCO 6.1094 again. CALL CFSJYN
; UPD ID= 1904, SNARK:<6.MONITOR>MEXEC.MAC.142,   2-Mar-83 15:44:36 by MILLER
;TCO 6.1094 again. Move MNTPS yet again, and call FILRST with it
; UPD ID= 1888, SNARK:<6.MONITOR>MEXEC.MAC.141,   1-Mar-83 10:37:34 by MILLER
;TCO 6.1094. Move call to MNTPS
; UPD ID= 1880, SNARK:<6.MONITOR>MEXEC.MAC.140,  27-Feb-83 22:05:25 by MURPHY
;More TCO 6.1514 and 6.1142 - Use ERJMPS after DIRST in LOGBUG.
;TCO 6.1525 - Get rid of unneeded XJRSTs.
; UPD ID= 1860, SNARK:<6.MONITOR>MEXEC.MAC.139,  22-Feb-83 20:24:48 by MILLER
;TCO 6.1520.  Enable disk preallocation after CHECKD runs
; UPD ID= 1858, SNARK:<6.MONITOR>MEXEC.MAC.138,  22-Feb-83 14:12:36 by MILLER
;TCO 6.1094. Add call to MNTPS during start-up
; UPD ID= 1847, SNARK:<6.MONITOR>MEXEC.MAC.137,  21-Feb-83 16:21:26 by MURPHY
;More 6.1507 - JOBCOF should jump to FLOGO1 not FLOGO after UPDL reset.
; UPD ID= 1842, SNARK:<6.MONITOR>MEXEC.MAC.136,  20-Feb-83 22:17:36 by MURPHY
;TCO 6.1514 - Use ITERX instead of JRST ITRAP.
; and revise the fixup to the fix to the fix to 6.1142 now that DIRST works.
; UPD ID= 1821, SNARK:<6.MONITOR>MEXEC.MAC.135,  18-Feb-83 07:32:51 by MCINTEE
;FIXUP THE FIX TO THE FIX TO 6.1142 - USE A TRVAR, NOT THE STACK
; UPD ID= 1814, SNARK:<6.MONITOR>MEXEC.MAC.134,  16-Feb-83 15:03:35 by MCINTEE
;FIX THE FIX TO 6.1142
; UPD ID= 1810, SNARK:<6.MONITOR>MEXEC.MAC.133,  15-Feb-83 14:22:21 by MILLER
;TCO 6.1094. Improve call to GETALF
; UPD ID= 1809, SNARK:<6.MONITOR>MEXEC.MAC.132,  15-Feb-83 10:16:24 by MURPHY
;TCO 6.1472 - Clean up uses of MCENTR.
;TCO 6.1506 - BUGCHK on unexpected job 0 interrupts.
;TCO 6.1507 - Fix MONPDL in JOBCOF.
;Fix to 6.1142 - Pointer clobbered if DIRST fails in LOGBUG.
; UPD ID= 1773, SNARK:<6.MONITOR>MEXEC.MAC.131,   5-Feb-83 18:55:25 by MILLER
;TCO 6.1094. Use DDMPF to flush pages for CFS
; UPD ID= 1768, SNARK:<6.MONITOR>MEXEC.MAC.130,   4-Feb-83 11:18:53 by MILLER
;TCO 6.1094. Distinguish DDMP for CFS from regular cycle
; UPD ID= 1745, SNARK:<6.MONITOR>MEXEC.MAC.129,   2-Feb-83 18:44:23 by MILLER
;TCO 6.1142. Some code clean ups. More to come...
; UPD ID= 1707, SNARK:<6.MONITOR>MEXEC.MAC.128,  27-Jan-83 20:06:53 by MILLER
;TCO 6.1094.CFS "get directory allocation".
; UPD ID= 1700, SNARK:<6.MONITOR>MEXEC.MAC.127,  26-Jan-83 14:25:30 by WEETON
;TCO 6.1401 - Fix ITRLGO BUGCHKs and WAITNI BUGHLTs
; UPD ID= 1680, SNARK:<6.MONITOR>MEXEC.MAC.126,  19-Jan-83 15:40:31 by MCINTEE
;TCO 6.1471 - MOVE SEBINI FROM EXEC0
; UPD ID= 1661, SNARK:<6.MONITOR>MEXEC.MAC.125,  15-Jan-83 16:45:12 by CHALL
;REMOVE RS(SWPMBP,1), WHICH IS DUPLICATED IN STG
; UPD ID= 1650, SNARK:<6.MONITOR>MEXEC.MAC.124,  13-Jan-83 17:10:37 by CHALL.WIZARD
;Add call to .NSPRS at SJLGO4 (to clean up NSP% DECnet lines for top fork)
; UPD ID= 1630, SNARK:<6.MONITOR>MEXEC.MAC.123,   7-Jan-83 12:39:46 by MCINTEE
;TCO 6.1445 - Monitor version number in SYSJOB.EXE
; UPD ID= 1619, SNARK:<6.MONITOR>MEXEC.MAC.122,   5-Jan-83 10:27:35 by HALL
;TCO 6.1000 and 6.1094
;	Fix code at RUNDE1 to set up context correctly for all processors
;	Clean up the comments a bit. Move JB0INT to be near CHKR
; UPD ID= 1615, SNARK:<6.MONITOR>MEXEC.MAC.121,   4-Jan-83 11:30:55 by MILLER
;TCO 6.1094. Set up MONBK for new CHKR fork
; UPD ID= 1550, SNARK:<6.MONITOR>MEXEC.MAC.120,  21-Dec-82 09:16:12 by MILLER
;TCO 6.1094. Enhance DDMP error code by creating routine DDMPER
; UPD ID= 1539, SNARK:<6.MONITOR>MEXEC.MAC.119,  20-Dec-82 17:27:55 by NICHOLS
;Add FTNSPSRV to distinguish between release 6.0 and 6.1
;Make SYSJOB.EXE into 6-1-SYSJOB.EXE for 6.1 monitors
;Add initialization of CTERM host and other DECnet-36 features
;TCO 6.1030 - DAPLGO added to logout code (McIntee)
; UPD ID= 1511, SNARK:<6.MONITOR>MEXEC.MAC.118,   2-Dec-82 15:17:55 by MOSER
;TCO 6.1110 - CHECK CHKAC ARGUMENT BLOCK LENGTH CORRECTLY
; UPD ID= 1491, SNARK:<6.MONITOR>MEXEC.MAC.117,  30-Nov-82 14:59:23 by MOSER
;TCO 6.1109 - LET CHKAC SUCCEED IF CONNECTED DIRECTORY WRONG BUT ACCESS OK
; UPD ID= 1490, SNARK:<6.MONITOR>MEXEC.MAC.116,  30-Nov-82 12:32:58 by HAUDEL
;More TCO 6.1357
; UPD ID= 1486, SNARK:<6.MONITOR>MEXEC.MAC.115,  29-Nov-82 14:19:55 by GRANT
;TCO 6.1010 - Remove EA.ENT at USGINI, startup runs totally in section 1 now
; UPD ID= 1479, SNARK:<6.MONITOR>MEXEC.MAC.114,  29-Nov-82 09:26:47 by GRANT
;TCO 6.1010 - In EXEC0, add call to MOVCST
; UPD ID= 1466, SNARK:<6.MONITOR>MEXEC.MAC.113,  18-Nov-82 13:59:16 by MOSER
;TCO 6.1380 - PREVENT HUNG JOBS AT LOGOUT
; UPD ID= 1461, SNARK:<6.MONITOR>MEXEC.MAC.112,  18-Nov-82 12:59:42 by MOSER
;TCO 6.1353 - PASS CORRECT ARGS TO ACJ FOR ATACH
; UPD ID= 1454, SNARK:<6.MONITOR>MEXEC.MAC.111,  17-Nov-82 14:15:54 by COBB
;TCO 5.1.1107 - Don't PUSH in STKVAR context at LDTACH+10 or so
; UPD ID= 1452, SNARK:<6.MONITOR>MEXEC.MAC.110,  17-Nov-82 08:23:57 by HAUDEL
;More TCO 6.1357
; UPD ID= 1432, SNARK:<6.MONITOR>MEXEC.MAC.109,  10-Nov-82 10:21:04 by HAUDEL
;TCO 6.1357 - CHANGE SHUTDOWN MESSAGE,ADD CTY MESSAGE
; UPD ID= 1430, SNARK:<6.MONITOR>MEXEC.MAC.108,   9-Nov-82 16:34:53 by WEETON
;Fix TCO 6.1344
; UPD ID= 1426, SNARK:<6.MONITOR>MEXEC.MAC.107,   8-Nov-82 13:52:49 by WEETON
;TCO 6.1344 - Allow enabled WHEEL or OPERATORs to load any program in top fork
; UPD ID= 1405, SNARK:<6.MONITOR>MEXEC.MAC.106,   3-Nov-82 07:00:12 by GRANT
;More TCO 6.1010 - Make RUNDD start in section 1, make USGINI run in section 1.
;Also, print out RUNNING DDMP sooner.
; UPD ID= 1400, SNARK:<6.MONITOR>MEXEC.MAC.105,   2-Nov-82 01:42:01 by CDUNN
;More TCO 6.1127 - Make KACCHG reflect the new keep alive scheme for the
;CI emulator
; UPD ID= 1397, SNARK:<6.MONITOR>MEXEC.MAC.104,   1-Nov-82 14:42:46 by LEACHE
;TCO 6.1342 Add MONVER
; UPD ID= 1386, SNARK:<6.MONITOR>MEXEC.MAC.103,  27-Oct-82 23:07:58 by CDUNN
;More TCO 6.1127 - Add further support for CI emulator keep alive
; UPD ID= 1379, SNARK:<6.MONITOR>MEXEC.MAC.102,  25-Oct-82 14:40:02 by MILLER
;TCO 6.1094. Create CFS section at system start up
; UPD ID= 1366, SNARK:<6.MONITOR>MEXEC.MAC.101,  22-Oct-82 03:52:48 by CDUNN
;More TCO 6.1127, add short routine to job init code to update the CI
;emulation keep alive boundries...
; UPD ID= 1348, SNARK:<6.MONITOR>MEXEC.MAC.99,  18-Oct-82 13:27:46 by COBB
;TCO 6.1315 - Clear CRJTTY after assignment to prevent 2 jobs on 1 tty bug
; UPD ID= 1345, SNARK:<6.MONITOR>MEXEC.MAC.98,  18-Oct-82 11:53:09 by MILLER
;TCO 6.1094. Enhance DDMPA some more
; UPD ID= 1335, SNARK:<6.MONITOR>MEXEC.MAC.97,  13-Oct-82 17:22:13 by MILLER
;Rerun DDMP right away if need be
; UPD ID= 1330, SNARK:<6.MONITOR>MEXEC.MAC.96,  12-Oct-82 17:50:23 by MILLER
;Restart DDMP soon if someone needed it while it was running
; UPD ID= 1301, SNARK:<6.MONITOR>MEXEC.MAC.95,   8-Oct-82 14:35:14 by MILLER
;Put DDMP in its own fork for CFS (TCO 6.1094)
; UPD ID= 1259, SNARK:<6.MONITOR>MEXEC.MAC.94,  29-Sep-82 20:20:00 by MILLER
;Make sure time is not negative
; UPD ID= 1251, SNARK:<6.MONITOR>MEXEC.MAC.93,  27-Sep-82 23:38:29 by MILLER
;Make sure job 0 wakes up in time to run DDMP
; UPD ID= 1247, SNARK:<6.MONITOR>MEXEC.MAC.92,  27-Sep-82 22:24:26 by MILLER
;CFS --  Fix DDMP restart
; UPD ID= 1240, SNARK:<6.MONITOR>MEXEC.MAC.91,  24-Sep-82 14:58:10 by MILLER
;Make DDMP retry wait a bit before trying again
; UPD ID= 1237, SNARK:<6.MONITOR>MEXEC.MAC.90,  24-Sep-82 12:27:19 by LEACHE
;TCO 6.1273 Add MS%ASG
; UPD ID= 1230, SNARK:<6.MONITOR>MEXEC.MAC.89,  24-Sep-82 11:48:26 by MOSER
;TCO 5.1614 MAKE CJ%ETF WORK WITH CJ%FIL.
; UPD ID= 1226, SNARK:<6.MONITOR>MEXEC.MAC.88,  23-Sep-82 23:44:50 by MILLER
;Handle failure from DDMP
; UPD ID= 1178, SNARK:<6.MONITOR>MEXEC.MAC.87,  14-Sep-82 11:07:46 by MOSER
;TCO 6.1264 - CORRECT ARGS TO ACJ AT JOBCF1
; UPD ID= 1159, SNARK:<6.MONITOR>MEXEC.MAC.86,  10-Sep-82 13:30:19 by MILLER
;tco 6.1259. Make JOBCOF go to FLOGO whnever it wants to LOGOUT
; UPD ID= 1151, SNARK:<6.MONITOR>MEXEC.MAC.85,   7-Sep-82 11:10:27 by MILLER
;TCO 6.1255. Suppress start-up dialog if DBUGSW = 3
; UPD ID= 1139, SNARK:<6.MONITOR>MEXEC.MAC.84,   3-Sep-82 15:13:55 by MCINTEE
;More TCO 6.1184 - Eliminate unwanted OKSKED from ATACH code
; UPD ID= 1097, SNARK:<6.MONITOR>MEXEC.MAC.83,  19-Aug-82 13:36:37 by MCINTEE
;TCO 6.1030 - Add call to DAPLGO during logout
; UPD ID= 1075, SNARK:<6.MONITOR>MEXEC.MAC.82,  10-Aug-82 14:19:26 by LEACHE
;TCO 6.1223 - Make "WHY RELOAD" accept a lowercase answer.
; UPD ID= 1009, SNARK:<6.MONITOR>MEXEC.MAC.81,  28-Jul-82 08:21:04 by COBB
;MORE TCO 6.1193 - Fix typo in previous edit...
; UPD ID= 1008, SNARK:<6.MONITOR>MEXEC.MAC.80,  27-Jul-82 15:19:05 by COBB
;TCO 6.1193 - ZERO out count of NOSKED p-faults after startup complete AND...
;TCO 6.1194 - Add call to ENQFKR when killing top fork to release ENQ locks
; UPD ID= 984, SNARK:<6.MONITOR>MEXEC.MAC.79,  12-Jul-82 13:52:05 by CDUNN
;TCO 6.1184 Fix ATACH JSYS to allow attach to terminal assigned by calling job
; UPD ID= 980, SNARK:<6.MONITOR>MEXEC.MAC.78,   7-Jul-82 16:16:30 by COBB
;TCO 6.1183 - Change SYSTEM:EXEC.EXE to DEFAULT-EXEC:
; UPD ID= 859, SNARK:<6.MONITOR>MEXEC.MAC.77,   7-Jun-82 09:39:33 by MURPHY
;TCO 6.1147 - Move bugdefs from BUGS.MAC to here and put them in-line.
; UPD ID= 779, SNARK:<6.MONITOR>MEXEC.MAC.76,  24-May-82 09:12:23 by HALL
;TCO 6.1144 - REMOVE "BLT SWAPPABLE MONITOR"
; UPD ID= 777, SNARK:<6.MONITOR>MEXEC.MAC.75,  21-May-82 11:41:57 by CDUNN
;TCO 6.1127 - Add code to call CISRV for a periodic check from job 0.
; UPD ID= 763, SNARK:<6.MONITOR>MEXEC.MAC.74,  19-May-82 10:09:54 by MILLER
;;TCO 6.1142. Send system messages to ORION
; UPD ID= 719, SNARK:<6.MONITOR>MEXEC.MAC.73,  11-May-82 02:15:55 by CDUNN
;More TCO 6.127 - Add free space assurance for SCA in CHKR routine
; UPD ID= 707, SNARK:<6.MONITOR>MEXEC.MAC.72,   9-May-82 13:02:19 by HALL
;TCO 6.1000- Support the 2080
;	Make flags word for user mode include user AC block (EXEC0, EXECI1,
;		EXBUGH, HSYS4, EXPAL0, JOBCOF
;	At EXECI, preserve full word of flags instead of left half only
;	Make CHKR use XJRST to get to section 1
; UPD ID= 540, SNARK:<6.MONITOR>MEXEC.MAC.71,  20-Mar-82 19:42:50 by PAETZOLD
;TCO 5.1766 - Turn on FH%EPN in PMAP call in SJLGO4.  PM%EPN does not work.
; UPD ID= 471, SNARK:<6.MONITOR>MEXEC.MAC.70,  12-Mar-82 14:41:32 by PAETZOLD
;TCO 5.1753 - Turn on PM%EPN in PMAP call in logout code.  Prevents PAGLCKs
; UPD ID= 433, SNARK:<6.MONITOR>MEXEC.MAC.69,   4-Mar-82 13:59:51 by MURPHY
;TCO 5.1744 - Refers to changes made approx June, 1980.  Make default
;  settings of system messages more like release 4.
; UPD ID= 379, SNARK:<6.MONITOR>MEXEC.MAC.68,   4-Feb-82 09:55:41 by HALL
;TCO 6.1000 - Support the 2080
;	Remove call to KDPINI. Don't need it now that KS isn't supported
; UPD ID= 347, SNARK:<6.MONITOR>MEXEC.MAC.67,  24-Jan-82 23:50:20 by MURPHY
;TCO 5.1697 - XSSEV%, etc.  Move GETPAT and GETDMS to FORK.MAC
; UPD ID= 313, SNARK:<6.MONITOR>MEXEC.MAC.66,  18-Jan-82 10:50:17 by MILLER
; UPD ID= 407, SNARK:<5.MONITOR>MEXEC.MAC.64,  18-Jan-82 10:37:36 by MILLER
;TCO 5.1678 again. Enhance check in ATACH for specific TTY designator
; UPD ID= 305, SNARK:<6.MONITOR>MEXEC.MAC.65,  15-Jan-82 16:27:34 by MILLER
;More TCO 5.1678. Check for same job number
; UPD ID= 302, SNARK:<6.MONITOR>MEXEC.MAC.64,  15-Jan-82 14:04:49 by MILLER
;TCO 5.1678. Make detach of object job in ATACH race-free.
; UPD ID= 386, SNARK:<5.MONITOR>MEXEC.MAC.60,   9-Jan-82 18:30:36 by MILLER
;TCO 5.1661. Unlatch MOS cotrollers after TGHA runs
;MORE OF TCO 6.1054
; UPD ID= 278, SNARK:<6.MONITOR>MEXEC.MAC.61,   6-Jan-82 10:11:09 by MILLER
;TCO 6.1054. ADD GTOKM IN ATTACH.
; UPD ID= 191, SNARK:<6.MONITOR>MEXEC.MAC.60,   6-Nov-81 13:39:04 by MURPHY
;Make monitor forks start in section 1
; UPD ID= 162, SNARK:<6.MONITOR>MEXEC.MAC.59,  23-Oct-81 15:23:34 by COBB
; UPD ID= 247, SNARK:<5.MONITOR>MEXEC.MAC.58,   6-Oct-81 15:21:24 by MOSER
;MORE TCO 5.1512 FIX A BUG.
; UPD ID= 222, SNARK:<5.MONITOR>MEXEC.MAC.57,  28-Sep-81 16:20:34 by PAETZOLD
;TCO 5.1544 - CORRECT CALCULATION FOR UPPER LIMIT OF VBOOT GROUP IN GSMDSK
; UPD ID= 209, SNARK:<5.MONITOR>MEXEC.MAC.56,  23-Sep-81 13:41:05 by MURPHY
;DITTO
; UPD ID= 187, SNARK:<5.MONITOR>MEXEC.MAC.55,  16-Sep-81 17:50:34 by MURPHY
;TCO 5.1514 - Start SYSERR fork earlier in RUNDD so messages from FE don't pile up.
; UPD ID= 184, SNARK:<5.MONITOR>MEXEC.MAC.54,  16-Sep-81 12:09:35 by SCHMITT
;More TCO 4.1051 - Remove definition of USGMUP, it is in STG
; UPD ID= 182, SNARK:<5.MONITOR>MEXEC.MAC.53,  15-Sep-81 16:51:13 by SCHMITT
;TCO 4.1.1051 - Make system restart entry include Monitor uptime
; UPD ID= 179, SNARK:<5.MONITOR>MEXEC.MAC.52,  15-Sep-81 16:26:04 by MOSER
;TCO 5.1512 ADD SE1ENT TO JOBCOF.
; UPD ID= 134, SNARK:<5.MONITOR>MEXEC.MAC.51,   1-Sep-81 16:22:40 by GRANT
;Fix the check for DETACHed before CALL TTHNGU in LOG1 - dataset line was not
;being hung up if user was not logged in
; UPD ID= 57, SNARK:<5.MONITOR>MEXEC.MAC.50,  21-Jul-81 15:22:56 by GRANT
;Change "PS:" to "system structure"
;TCO 5.1375 - Fix bugs in ATACH JSYS
; UPD ID= 19, SNARK:<5.MONITOR>MEXEC.MAC.49,  12-Jul-81 15:44:27 by PAETZOLD
;Replace .FHSLF with .TTDES at DETMS3+3
; UPD ID= 18, SNARK:<5.MONITOR>MEXEC.MAC.48,  11-Jul-81 17:45:10 by PAETZOLD
;TCO 5.1407 - Make sure we dont ask to lock more memory than is on
; replacable queue in GSMD2
; UPD ID= 2289, SNARK:<5.MONITOR>MEXEC.MAC.47,   2-Jul-81 13:36:37 by PAETZOLD
;TCO 5.1393 - Change reference of BUGINT from immediate to full word
; UPD ID= 2265, SNARK:<5.MONITOR>MEXEC.MAC.46,  26-Jun-81 18:07:46 by MURPHY
;TCO 5.1376 - JOBCOF, FLOGO, FRKNOP
; UPD ID= 2125, SNARK:<5.MONITOR>MEXEC.MAC.45,   4-Jun-81 10:11:31 by GRANT
;Make sure all 23 bits of address get returned in GETSEG
; UPD ID= 2069, SNARK:<5.MONITOR>MEXEC.MAC.44,  22-May-81 16:48:23 by ZIMA
;TCO 5.1344 - Correct ATACH and DTACH privilege checking for batch jobs.
; UPD ID= 2056, SNARK:<5.MONITOR>MEXEC.MAC.43,  21-May-81 10:46:10 by SCHMITT
;More of TCO 5.1308
; UPD ID= 1967, SNARK:<5.MONITOR>MEXEC.MAC.42,   8-May-81 14:24:43 by SCHMITT
;More of TCO 5.1308 - Check for system shutdown in CHKR loop
; UPD ID= 1941, SNARK:<5.MONITOR>MEXEC.MAC.41,   5-May-81 17:06:32 by SCHMITT
;TCO 5.1308 - Latch HSYST1 to -1 when system shutdown
; UPD ID= 1921, SNARK:<5.MONITOR>MEXEC.MAC.40,   1-May-81 11:33:52 by PAETZOLD
;TCO 5.1301 add SCOUNT to GETAB tables, also bump SCOUNT in SETSN
; UPD ID= 1910, SNARK:<5.MONITOR>MEXEC.MAC.39,  30-Apr-81 16:29:05 by CHALL
;Inform the victim of a LOGOUT about the killer and his terminal
; UPD ID= 1817, SNARK:<5.MONITOR>MEXEC.MAC.38,  17-Apr-81 09:42:10 by WACHS
;TCO 5.1287 Restrict the possible answers to Why Reload question
; UPD ID= 1778, SNARK:<5.MONITOR>MEXEC.MAC.37,  31-Mar-81 17:43:13 by MURPHY
;Default is shutdown messages at 5 and 1 min
; UPD ID= 1719, SNARK:<5.MONITOR>MEXEC.MAC.36,  16-Mar-81 16:37:05 by MURPHY
;Add "PS:" to system expunge message
; UPD ID= 1569, SNARK:<5.MONITOR>MEXEC.MAC.35,  19-Feb-81 14:07:50 by HALL
;TCO 5.1180 - Move DST to non-zero section
; Fix EXEC0 so that it can run in section 1, because call to SETMPG
;  can get to GDSTX
; BSRAD - Use extra stack location and avoid clobbering PC
; GOTSWM - Change BLT to initialize SYSFK table
; UPD ID= 1496, SNARK:<5.MONITOR>MEXEC.MAC.34,  26-Jan-81 13:25:47 by ENGEL
;GET RID OF THE LCS CALLS. NOT PART OF NEXT RELEASE ANYMORE
; UPD ID= 1485, SNARK:<5.MONITOR>MEXEC.MAC.33,  24-Jan-81 23:20:07 by ZIMA
;TCO 5.1240 - Fix connect time calculation in CPGCON checkpoint routine.
; UPD ID= 1479, SNARK:<5.MONITOR>MEXEC.MAC.32,  22-Jan-81 12:37:41 by ZIMA
;TCO 5.1238 - expunge properly on logout.
; UPD ID= 1292, SNARK:<5.MONITOR>MEXEC.MAC.31,  18-Nov-80 18:11:05 by MURPHY
;FIX BUG IN JOBCOF - MAKE DETACH HAPPEN BEFORE LOGOUT
; UPD ID= 1286, SNARK:<5.MONITOR>MEXEC.MAC.30,  18-Nov-80 14:40:13 by OSMAN
; UPD ID= 1248, SNARK:<5.MONITOR>MEXEC.MAC.29,   7-Nov-80 15:01:32 by SCHMITT
;TCO 5.1194 - Fix code at USGIN7 to not cause CHKPNT errors
; UPD ID= 1221, SNARK:<5.MONITOR>MEXEC.MAC.28,   2-Nov-80 11:48:37 by HALL
;TCO 5.1180 - MOVE THE DST TO NON-ZERO SECTION
;	CHKR - RUN IN SECTION 1
;	GSMDX - RUN IN SECTION 1
;tco 5.1189 - Make entry vector two words
; UPD ID= 1221, SNARK:<5.MONITOR>MEXEC.MAC.28,   2-Nov-80 11:48:37 by HALL
;TCO 5.1180 - MOVE THE DST TO NON-ZERO SECTION
;	CHKR - RUN IN SECTION 1
;	GSMDX - RUN IN SECTION 1
; UPD ID= 1143, SNARK:<5.MONITOR>MEXEC.MAC.27,   8-Oct-80 15:14:08 by MURPHY
;BUG IN JOBCOF
; UPD ID= 1103, SNARK:<5.MONITOR>MEXEC.MAC.26,   2-Oct-80 09:28:08 by MURPHY
;DITTO
; UPD ID= 1081, SNARK:<5.MONITOR>MEXEC.MAC.25,   1-Oct-80 11:53:31 by MURPHY
;FIX ACVAR, ETC.
; UPD ID= 975, SNARK:<5.MONITOR>MEXEC.MAC.24,  29-Aug-80 08:41:47 by ENGEL
;ADD LCS INITIALIZATION CALL
; UPD ID= 972, SNARK:<5.MONITOR>MEXEC.MAC.23,  25-Aug-80 16:53:39 by HALL
;TCO 5.1139 - ADD FAILING PC AND LSTERR TO OUTPUT WHEN FORK 0 CRASHES
; UPD ID= 965, SNARK:<5.MONITOR>MEXEC.MAC.22,  25-Aug-80 16:28:07 by ENGEL
;TCO 5.1136 - ADD DEVLKK
; UPD ID= 932, SNARK:<5.MONITOR>MEXEC.MAC.21,  20-Aug-80 14:59:31 by LYONS
;TCO 5.1062 WRITE VERIFICATION ON WRITE FOR DISKS
; UPD ID= 841, SNARK:<5.MONITOR>MEXEC.MAC.20,   5-Aug-80 16:20:06 by OSMAN
;tco 5.1109 - Add PDV support to SSAVE and GET
; UPD ID= 812, SNARK:<5.MONITOR>MEXEC.MAC.19,  30-Jul-80 11:03:46 by MURPHY
;WEFLAG - DON'T WRITE-PROTECT MONITOR IF NON-0
; UPD ID= 789, SNARK:<5.MONITOR>MEXEC.MAC.18,  23-Jul-80 17:20:10 by R.ACE
;TCO 5.1112 - REMOVE VESTIGIAL "MOVE T1,FORKX" AT JOBCF1+2
; UPD ID= 747, SNARK:<5.MONITOR>MEXEC.MAC.17,   8-Jul-80 17:50:12 by HALL
;FIX LYONS' EDIT TO CHKUM1
; UPD ID= 723, SNARK:<5.MONITOR>MEXEC.MAC.15,   2-Jul-80 11:28:18 by LYONS
;Fix ILMNRF in SAVE% JSYS by maping read only page to non-existant page
; with no access, and fooling SAVEB1 into thinking page is really there
;Fix missing checks for tty detached when we get CTRLTT in LOG1
;Fix time race in CHKUM1 that can cause J0NRUN
;Fix reason why system down as told to IMP
;Fix CTY login after ^ECEASE if it was prohibited before
;ARPAnet can cause UPDL overflows if user in JSYS which locks tty data
;A job with PSI for carrier off does not get it until reattach time.
; UPD ID= 703, SNARK:<5.MONITOR>MEXEC.MAC.14,  26-Jun-80 09:52:06 by LYONS
;Add code to call ACJ on an implicit logout (i.e. thru a hangup of a dataset)
; UPD ID= 700, SNARK:<5.MONITOR>MEXEC.MAC.13,  25-Jun-80 17:26:40 by MURPHY
;FIRST SHUTDOWN MESSAGE CONTROLLED BY SF%MS1
; UPD ID= 698, SNARK:<5.MONITOR>MEXEC.MAC.12,  25-Jun-80 17:05:46 by GRADY
;TCO 5.1079 - FIX RACE AT LDTAC2, BUT UNLOKK DEVLKK AND GO OKINT TOO.
; UPD ID= 666, SNARK:<5.MONITOR>MEXEC.MAC.10,  16-Jun-80 19:06:25 by LYONS
;FIX RACE AT LDTAC2, WHERE CTRLTT MAY NOT BE RIGHT
; UPD ID= 662, SNARK:<5.MONITOR>MEXEC.MAC.9,  16-Jun-80 17:23:27 by KONEN
;TCO 5.1063 - REMOVE PS: AS NAME OF PRIMARY STRUCTURE
; UPD ID= 597, SNARK:<5.MONITOR>MEXEC.MAC.8,   3-Jun-80 17:45:02 by MURPHY
;FACTSW BITS TO CONTROL SYSTEM MESSAGES
; UPD ID= 498, SNARK:<5.MONITOR>MEXEC.MAC.7,  30-Apr-80 15:06:35 by GRANT
;TCO 5.1030 - Add description to ?FULL
; UPD ID= 468, SNARK:<5.MONITOR>MEXEC.MAC.6,  23-Apr-80 15:52:58 by LYONS
;pushed literals as PC dont allow for non zero sections
; UPD ID= 445, SNARK:<5.MONITOR>MEXEC.MAC.5,  15-Apr-80 11:01:18 by HALL
;MOVE LOGDES AND JB0TT INTO RSDAT
; UPD ID= 401, SNARK:<5.MONITOR>MEXEC.MAC.4,   2-Apr-80 15:52:50 by HALL
;FIX LOWER CASE IN PREVIOUS EDIT
; UPD ID= 394, SNARK:<5.MONITOR>MEXEC.MAC.3,   1-Apr-80 15:44:01 by HALL
;MAKE JB0TT AND USGMUP BE PART OF RSVAR PSECT
; UPD ID= 374, SNARK:<5.MONITOR>MEXEC.MAC.2,  26-Mar-80 13:36:09 by ENGEL
;STOP EDDT SYMBOL FROM PRINTING
; UPD ID= 288, SNARK:<4.1.MONITOR>MEXEC.MAC.447,  21-Feb-80 10:58:17 by MURPHY
;NEW FKINT DEFS
; UPD ID= 266, SNARK:<4.1.MONITOR>MEXEC.MAC.446,  15-Feb-80 17:39:58 by MURPHY
;PROPER LENGTH FOR QTIMES TABLE IN GETAB
; UPD ID= 240, SNARK:<4.1.MONITOR>MEXEC.MAC.445,   1-Feb-80 14:40:27 by ENGEL
; UPD ID= 110, SNARK:<4.1.MONITOR>MEXEC.MAC.444,   7-Dec-79 16:30:00 by SCHMITT
;TCO 4.1.1051 - CALC. MONITR UPTIME IN SEC AND GIVE TO USAGE JSYS FOR RESTART
; UPD ID= 106, SNARK:<4.1.MONITOR>MEXEC.MAC.443,   7-Dec-79 09:34:57 by R.ACE
;TCO 4.2591 - SECTION-0 PAGE TABLE SHARE COUNT PROBLEM FROM SSAVE
;ADD ERJMP AFTER SOUT IN LITERAL AFTER SSAVB4
; UPD ID= 91, SNARK:<4.1.MONITOR>MEXEC.MAC.442,   5-Dec-79 09:13:00 by OSMAN
;tco 4.1.1044 - Make EXEC command in mini-exec do implicit RESET
;<4.1.MONITOR>MEXEC.MAC.441, 16-Nov-79 13:47:41, EDIT BY MILLER
;PREVIOUS CHANGES UNDER TCO 4.1.1021
;<4.1.MONITOR>MEXEC.MAC.440, 16-Nov-79 13:00:38, EDIT BY MILLER
;ADD TTFSMS BUGINF
;<4.1.MONITOR>MEXEC.MAC.439, 16-Nov-79 11:46:24, EDIT BY MILLER
;CHANGE ALLMSG TO TIME-OUT TTMSG

;	COPYRIGHT (c) DIGITAL EQUIPMENT CORPORATION 1976, 1988.
;	ALL RIGHTS RESERVED.
;
;	THIS SOFTWARE IS FURNISHED UNDER A  LICENSE AND MAY BE USED AND  COPIED
;	ONLY IN  ACCORDANCE  WITH  THE  TERMS OF  SUCH  LICENSE  AND  WITH  THE
;	INCLUSION OF THE ABOVE  COPYRIGHT NOTICE.  THIS  SOFTWARE OR ANY  OTHER
;	COPIES THEREOF MAY NOT BE PROVIDED  OR OTHERWISE MADE AVAILABLE TO  ANY
;	OTHER PERSON.  NO  TITLE TO  AND OWNERSHIP  OF THE  SOFTWARE IS  HEREBY
;	TRANSFERRED.
;
;	THE INFORMATION IN THIS  SOFTWARE IS SUBJECT  TO CHANGE WITHOUT  NOTICE
;	AND SHOULD  NOT  BE CONSTRUED  AS  A COMMITMENT  BY  DIGITAL  EQUIPMENT
;	CORPORATION.
;
;	DIGITAL ASSUMES NO  RESPONSIBILITY FOR  THE USE OR  RELIABILITY OF  ITS
;	SOFTWARE ON EQUIPMENT THAT IS NOT SUPPLIED BY DIGITAL.

	SEARCH MONSYM,PROLOG,SERCOD
	TTITLE MEXEC
	Subttl	Table of Contents

;		     Table of Contents for MEXEC
;
;				  Section		      Page
;
;
;    1. Assembly Parameters  . . . . . . . . . . . . . . . . .   3
;    2. Job and System Initialization  . . . . . . . . . . . .   4
;        2.1    Job Initialization . . . . . . . . . . . . . .   8
;        2.2    Non-zero Jobs  . . . . . . . . . . . . . . . .  10
;        2.3    CRJOB Created Job  . . . . . . . . . . . . . .  12
;        2.4    Read MONNAM.TXT (GETNAM) . . . . . . . . . . .  18
;    3. Job 0 Forks
;        3.1    Initialization (RUNDD) . . . . . . . . . . . .  19
;        3.2    Page Movement to Disk (DDMP) . . . . . . . . .  31
;        3.3    KLIPA Checking (IPACHK)  . . . . . . . . . . .  33
;        3.4    CI Buffer Checks (CIRUN) . . . . . . . . . . .  34
;        3.5    CHKR Initialization  . . . . . . . . . . . . .  35
;        3.6    Fork Startup (RUNDIR/RUNDII) . . . . . . . . .  38
;        3.7    Set Error Address (MONBKX) . . . . . . . . . .  40
;        3.8    Make System Restart Record (LOGSST)  . . . . .  41
;        3.9    Ask "Why Reload?" (WHYRLD) . . . . . . . . . .  43
;        3.10   Ask "Run CHECKD?" (RUNCKD) . . . . . . . . . .  44
;        3.11   Timeout starup questions (TIMOUT)  . . . . . .  45
;        3.12   Check "Why Reload?" Response (MATRLA)  . . . .  46
;        3.13   Get Time and Date for Startup (RDDTAD) . . . .  48
;        3.14   Start Next Special job (DONSJ) . . . . . . . .  49
;        3.15   Scheduler Tests  . . . . . . . . . . . . . . .  50
;        3.16   Fork Error Catcher . . . . . . . . . . . . . .  51
;        3.17   Periodic Checker (CHKR)  . . . . . . . . . . .  53
;            3.17.1   Start DOB SETSPD (DOBSSP)  . . . . . . .  56
;            3.17.2   Kill DOB SETSPD (DOBKSP) . . . . . . . .  57
;            3.17.3   Magtape Online (MTASSP)  . . . . . . . .  58
;            3.17.4   TGHA Check (CHKMOS)  . . . . . . . . . .  59
;            3.17.5   Check Swapping Space (CHKDMS)  . . . . .  60
;            3.17.6   Check OFNs Used (CHKOFN) . . . . . . . .  61
;            3.17.7   Check System Structure Space (CHKDKS)  .  62
;            3.17.8   Utility Routines . . . . . . . . . . . .  65
;    4. Mini-EXEC  . . . . . . . . . . . . . . . . . . . . . .  67
;        4.1    Command Dispatch . . . . . . . . . . . . . . .  69
;        4.2    BLT Swappable Monitor (Historical) . . . . . .  70
;        4.3    Reset Command  . . . . . . . . . . . . . . . .  71
;        4.4    Exec Command . . . . . . . . . . . . . . . . .  72
;        4.5    Jump Command . . . . . . . . . . . . . . . . .  73
;        4.6    Get/Start/Dump Commands  . . . . . . . . . . .  74
;        4.7    Utility Routines . . . . . . . . . . . . . . .  75
;        4.8    Handle Interrupts (EXECI)  . . . . . . . . . .  76
;    5. BUGxxx Processing  . . . . . . . . . . . . . . . . . .  78
;        5.1    BUGHLT In Job Context (EXBUGH) . . . . . . . .  85
;        5.2    Store Time For BUGxxx (CHKBGS) . . . . . . . .  86
;        5.3    Log Parity Error (PFCPJ0)  . . . . . . . . . .  87
;    6. Send Message To All Lines (ALLMSG) . . . . . . . . . .  88
;    7. End of MEXEC . . . . . . . . . . . . . . . . . . . . .  89
	SUBTTL Assembly Parameters

	EXTN <BRDTIM,DDMPF,MOSULE,HNGU0F,HNGU1F,BUGTL>

	IFNDEF FTKLIPA,<FTKLIPA==-1> ;Default is include KLIPA support code
	IFNDEF FTMSCP,<FTMSCP==0>   ;Default is no MSCP

IFN <FTKLIPA!FTMSCP>,<EXTERN SC.RAP>
IFE FTNSPSRV,<EXTERN LLMINI>	;[7.1200][7173] ~6.0 Defined in LLMOP

;AC DEFINITIONS USED HEREIN

DEFAC (FX,Q3)			;FORK INDEX

;NOTE: THE NEXT TWO LOCATIONS MUST BE TOGETHER. GETAB REQUIRES IT

RSI LOGDES,LOGTTY		;DESIGNATOR FOR LOG MSGS - DEF IN PARAMS
RSI JB0TT,0			;DESIG FOR JOB 0 AND ERR MSGS

MICHN==:1B34+1B35		;CHANNELS THAT MONITOR ENABLES
EXWTIM==:^D120			;NUMBER MINUTES BETWEEN AUTO EXPUNGES

	SWAPCD

;REGULAR SUBSYSTEM NAMES FOR INCLUSION IN SNAMES TABLE AT STARTUP

SBSNMS:	SIXBIT /EXEC/
	SIXBIT /(PRIV)/
NSBSNM==.-SBSNMS

;TABLE DEFINES SPECIAL PURPOSE FOR FIRST FEW JOBS

SPECJT:	MSEC1,,RUNDD		;JOB 0 IS ALWAYS DISK CHECKER, ETC.

NSPECJ==.-SPECJT		;NUMBER OF SPECIAL JOBS

	RESCD
	SUBTTL Job and System Initialization

;CODE TO INITIALIZE JOB ON FIRST STARTUP.  ALSO INVOKES SYSTEM
;INITIALIZATION IF FIRST JOB AFTER SYSTEM STARTED FROM SCRATCH
;SYSIFG IS 0 WHEN SYSTEM IS JUST STARTING

EXEC0::	MOVX 1,LOGIOB		;SAY JOB CREATION IN PROGRESS
	IORM 1,JOBBIT
	SETZM FPC
	MOVX 1,USRCTX		;SIMULATE CALL FROM USER
	MOVEM 1,FFL
	MCENTR
	SKIPE SYSIFG		;NEW SYSTEM?
	JRST GOTSWM		;NO
	MOVEI T1,MFRKWD		;GET SPECIAL PRIORITY FOR MONITOR FORKS
	MOVEM T1,JOBSKD		;AND SET THIS JOB AS SUCH
	CALL FSIINI		;GO MOUNT THE PUBLIC STRUCTURE
	CALL SWPINI		;SWAPPER CAN NOW BE INITIALIZED
				;IT MUST BE CALLED AFTER NSSUN AND
				;  THE SDB FOR PS ARE SET UP BY FSIINI
	MOVEI T1,PSNUM		;T1/ STRUCTURE NUMBER (PUBLIC STRUCTURE)
	MOVEI T2,HOMPGA		;T2/ ADDRESS OF PAGE TO USE FOR BAT BLOCKS
	MOVX T3,MI%MSG		;T3/ FLAGS TO TELL OPERATOR, FIX INCONSISTENT
	CALL CHKBAT		;AND NOW THE BAT BLOCKS CAN BE CHECKED
				; AND THE OVERFLOW SWAPPING ADDRESSES
				; IN THE BAT BLOCKS PROCESSED

GETSWM::
;   IFN CFSCOD,<
	CALL CFSCSC		 ;First, create CFS data section
;   >
	SETOM SWPMLF		; INIT COUNT OF LOCKERS OF SWP MON
	SKIPN EDDTF		;KEEP EDDT?
	CALL ULKINI		;NO, UNLOCK IT
	SKIPE SMLKF		;KEEP SWPMON LOCKED?
	CALL SWPMLK		;YES, RE-LOCK IT
	CALL MOVNRC		;MAKE SWPMON (NRCOD) BE IN SEC 1 ONLY

	CALL RESLCK		;LOCK DOWN SOME RESIDENT FREE SPACE
	CALL DOBINI		;[7.1081] () Initialize DOB
	 JFCL			;[7.1081] Ignore error for now
	SKIPE VSMFLG		;SWAP MONITOR NEED TO BE FORCED OUT TO DISK?
	JRST [	SETOM SKEDFC	;YES, FORCE IT ALL TO HAPPEN
		MOVEI T1,1000	;1 SECOND OF SLEEP TIME
		DISMS		;SHOULD BE LONG ENOUGH FOR THE SWAPABLE
				;MONITOR TO GET OUT, WITH OUT ANY PROBLEMS.
		SETZM VSMFLG	;STOP FORCING DATA VERIFICATION
		SETZM SKEDFC	;MAKE SURE WE DONT SPEND EXTRA TIME SWAPPING, TOO
		JRST .+1]	;BACK TO THE MAIL LINE CODE
;AT THIS POINT THE SWAPPABLE MONITOR HAS BEEN LOADED.  IF THE MONITOR WAS
;STARTED AT 144, IT HAS ALSO BEEN SWAPPED OUT TO THE DISK.
; IF IT IS DESIRABLE TO PATCH THE SWAPPABLE MONITOR A BREAKPOINT CAN
; BE PUT HERE.  NO PART OF THE SWAPPABLE MONITOR WILL HAVE BEEN EXECUTED YET.

;INITIALIZE THE FORK STRUCTURE FOR THIS JOB. ASSIGN FIRST WORD OF FKPTRS
;AND SYSFK TO THIS FORK. MAKE EACH REMAINING WORD OF FKPTRS POINT TO NEXT
;AVAILABLE SLOT AND FREJFK POINT TO THE FIRST AVAILABLE SLOT
;INITIALIZE REMAINING WORDS OF SYSFK TO -1

GOTSWM:	MOVEI 1,FKPTRS		;1/NAME OF FORK STRUCTURE LIST
	MOVEI 2,NUFKS		;2/NUMBER OF WORDS IN LIST
	CALL ILIST		;INITIALIZE FREE WORDS IN FKPTRS
	MOVE 1,0(1)		;POINT TO SECOND FREE SLOT
	MOVEM 1,FREJFK		;MAKE FREE LIST START WITH SECOND SLOT
	SETZM FKPTRS		;TAKE FIRST SLOT FO THIS FORK
	MOVE 1,FORKX		;GET SYSTEM-WIDE INDEX FOR THIS FORK
	HRRZM 1,SYSFK		;STORE IN JOB STORAGE AREA
				;Note that this clears all the flag bits
				; (defined in FORK) in LH of SYSFK
	MOVEI T1,NUFKS-2	;T1/ NUMBER OF WORDS TO COPY
	MOVEI T2,SYSFK+1	;T2/ STARTING SOURCE WORD
	SETOM (T2)		;INITIALIZE IT TO -1
	MOVEI T3,1(T2)		;T3/ STARTING DESTINATION WORD
	CALL XBLTA		;INITIALIZE BLOCK TO -1 (EXCEPT FIRST WORD)
	MOVE T1,[JTBIFR]	; Initialize JTB free bit table
	MOVEM T1,JTBFRE		;  ..
	SETOM FKLOCK		;INIT FORK LOCK FOR THIS JOB
	SETZM FLKCNT		;CLEAR NEST COUNT
	SETOM FLKOWN		;CLEAR OWNING FORK

;SET UP FOR INTERRUPTS TO BE PROCESSED BY THE MONITOR
;IF AN INTERRUPT OCCURS ON A CHANNEL WHOSE BIT IS SET IN MONCHN,
;THE MONITOR WILL GO TO EXECI
;CHANNELS 34 AND 35 ARE ACTIVATED HERE, AND CTRL/P IS ASSIGNED
;TO THEM IN THE MINI-EXEC

	SETOM TTJTIW
	MOVE 1,[XWD MSEC1,EXECI] ;GO TO EXECI ON INTERRUPT
	CALL MONBKX
	MOVE T1,FORKN		;GET RELATIVE FORK NUMBER
	CALL SETVGN		;AND RESTORE VIRGINITY

	JRST JBI0		;CONTINUE IN SWAPPABLE CODE
;JOB INITIALIZATION...
;SYSIFG IS 0 IF SYSTEM IS BEING STARTED

RSI SPJCAP,<SC%CTC!SC%GTB!SC%LOG!SC%SCT!SC%SUP!SC%WHL!SC%OPR!SC%CNF!SC%MNT!SC%IPC!SC%ENQ!SC%NWZ!SC%NAS!SC%DNA!SC%ANA> ;SPECIAL JOB CAPS

	SWAPCD

JBI0:	CALL JBFINI		;INIT FILE SYS FOR THIS JOB
	SKIPE SYSIFG		;SYSTEM INITIALIZED?
	JRST SYSINE		;YES

;SYSTEM IS BEING STARTED. DO ONCE-ONLY INITIALIZATION

	MOVE T1,SPJCAP		;GET SPECIAL JOB CAPS
	MOVEM T1,CAPENB		;ENABLE ALL CAPABILITIES FOR INITIALIZATION
	MOVEM T1,CAPMSK		;HERE TOO
	
	EXTERN SWFREE,SWOPTL,SWFREL
	MOVE T1,[SWFREE,,SWFREE+1]
	SETZM SWFREE		;ZERO THE FREE POOL
	BLT T1,SWFREE+SWFREL-1	;...
	MOVEI T1,SWFREE		;GET ADR OF FREE POOL
	HRLOM T1,SWPFRE		;INITIALIZE POINTER TO FREE BLOCK
	MOVEI T1,SWFREL		;GET LENGTH OF FREE AREA
	HRRZM T1,SWFREE		;MAKE IT ONE LARGE BLOCK
	MOVEM T1,SWPFRE+2	;STORE IN SPACE COUNTER
	SETOM SWPFRE+1		;INITIALIZE LOCK ON FREE STORE
	MOVE T1,[XWD SWFREE+SWFREL,SWFREE]
	MOVEM T1,SWPFRE+4	;SET UP TOP AND BOTTOM POINTERS
	MOVEI T1,SWOPTL		;GET OPTIMUM LENGTH OF MESSAGES
	MOVEM T1,SWPFRE+3	;SAVE IN HEADER BLOCK
	CALL FSPINI		;Initialize swappable free space

	SETOM FGLOCK		;INIT FAST GET LOCK
	SETOM SYLNLK		;INIT SYSTEM LOGICAL NAME LOCK
	SETOM CRJLCK		;INIT LOCK OF CRJOB DATA BASE
	CALL FILINI		;INIT FILE SYSTEM
	SETOM GOKLCK		;INIT GETOK LOCK
	SETOM TIMLCK		;INIT LOCK ON TIMER Q'S
	MOVEI T1,0
      DO.
	MOVE T2,SBSNMS(T1)	;MOVE REGULAR SUBSYSTEM NAMES TO TABLE
	MOVEM T2,@[EP. SNAMES(T1)]
	CAIGE T1,NSBSNM-1
	AOJA T1,TOP.
      ENDDO.
	MOVNI 1,NSBSNM		;INIT TABLE POINTER WITH NEG COUNT
	MOVEM 1,SNMPT
	SETOM SNMLCK		;AND INIT LOCK
	MOVE T1,[JOBONT,,JOBONT+1]
	SETOM JOBONT		;NO JOBS ARE YET OWNED BY ANYONE
	BLT T1,JOBONT+NJOBS-1	; ..
	CALL PIDINI		;INITIALIZE THE IPCF DATA BASE AND FORKS
	CALL SLNINI		;INITIALIZE SYSTEM LOGICAL NAMES
	SETOM UTLOCK		;INITIALIZE THE UTEST JSYS DATA BASE
	CALL GETNAM		;INITIALIZE STRING CONTAINING
				; MONITOR VERSION AND NAME
IFN FTNSPSRV,CALL NAMINI        ;INITIALIZE NODE NAME TO "TOPS20", IF DECNET
	MOVEI T1,TMZONE		;INITIALIZE TIMZON
	MOVEM T1,TIMZON
	SETOM ACTLCK		;INITIALIZE LOCK ON ACCT WINDOW PAGES
	SETOM ACTOFN		;NO OFN FOR ACCT VALIDATION DATA FILE YET
	SETOM AVALON		;ALWAYS TURN ON ACCT VALIDATION TILL STATED OTHERWISE
	SUBTTL Job and System Initialization -- Job Initialization

;JOB INITIALIZATION...
;THIS CODE IS REACHED FOR ALL JOBS, INCLUDING FIRST ONE AFTER SYSTEM
;STARTUP

SYSINE:	MOVE T1,JOBNO		;GET OUR LOCAL JOB INDEX
	CALL JBGET1		;ASK CFS FOR A GLOBAL JOB NUMBER
	 IFNSK.			;IF NO SKIP, WE HAVE NO MORE JOBS LEFT
	  TMSG <
?No Global Job slots available.
>				;TELL THE USER WHY HE'S GETTING...
	  JRST FLOGO1		; LOGGED OUT.
	ENDIF.			;[7.1051]
	MOVEM T1,GBLJNO		;[7.1051] Save the global job number here (JSB)
	HLRZ T2,ACTJOB		;[7.1051] Get the lowest job number used
	SKIPE T2		;[7.1051] Skip if there isn't a lowest yet
	CAML T2,T1		;[7.1051] Is the lowest lower?
	HRLM T1,ACTJOB		;[7.1051] No, store new lowest job
	HRRZ T2,ACTJOB		;[7.1051] Get the highest job number
	SKIPE T2		;[7.1051] Skip if there isn't a highest yet
	CAMG T2,T1		;[7.1051] Is highest job still highest?
	HRRM T1,ACTJOB		;[7.1051] Nope, store new highest
	MOVE T1,JOBNO		;INITIALIZE THE PID QUOTA
	CALL PIDJBI		;  AND SEND QUOTA
	CALL ENQJBI		;INITIALIZE ENQ/DEQ QUOTA
	MOVE T1,JOBNO		;GET JOB NUMBER
	SETZM CRJFLG		;ASSUME NOT A CREATE-JOB STARTUP
	HLRZ T2,JOBPT(T1)	;CHECK FOR SPECIAL STARTUP FLAG
	CAIE T2,-2		;FROM CRJOB?
	JRST SYSIN1		;NO. NORMAL STARTUP.
	MOVE T2,CRJTTY		;CRJOB. HERE IS THE REQUESTED TTY.
	HRLM T2,JOBPT(T1)	;PUT IT IN JOBPT OF NEW JOB.
	MOVEM T2,CTRLTT		;AND IN THE JSB
	SETOM CRJFLG		;FLAG IN JSB THIS IS A CRJOB STARTUP
SYSIN1:	JUMPL T2,SYSIN2		;JUMP IF JOB IS DETACHED
	CALL TTYASN		;ASSIGN CONTROLLING TTY
	 JRST SYSIN9
	SKIPGE CRJFLG		;CRJOB STARTUP??
	SETOM CRJTTY		; YES, CRJOB TTY IS NO LONGER SPECIAL
	MOVE T2,CTRLTT		;GET TTY NUMBER
	CALL TTCKSP		;GO SEE IF SPEED SETTING NEEDED
;Continue with job initialization...

SYSIN2:	MOVE T1,TODCLK
	MOVEM T1,CONSTO		;SET CONSOLE TIME ON
	CALL LGTAD		;[7456] (/T1,T2) Get the current date time
	MOVEM T1,JSSCTI		;[7456] Save as the session start time
	SETZM JSSRTM		;Reset session runtime
	SETZM JSSCTM		; and session console time
	MOVE T1,[OURNAM,,LLSR]	;BLT POINTER TO INITIALIZE NODE NAME
	BLT T1,LLSR+WPN-1	;MAKE JOB'S NODE NAME BE OUR LOCAL NAME
	MOVX T1,LOGIOB		;SAY JOB CREATION FINISHED
	ANDCAM T1,JOBBIT

;JOBS 0 THROUGH NSPECJ-1 ARE SPECIAL. SPECJT CONTAINS ADDRESS TO WHICH
;TO TRANSFER. FOR NOW, ONLY JOB 0 IS SPECIAL, AND IT GOES TO RUNDD.
;SEE IF THIS IS A SPECIAL JOB

NOTJB0:	MOVE 1,JOBNO		;FIRST FEW JOBS ARE SPECIAL,
	CAIL 1,NSPECJ		;IS THIS ONE OF THEM?
	IFSKP.
	  MOVEI 2,OPERDN	;YES, GET DIRECTORY NUMBER OF <OPERATOR>
	  HRRM 2,JOBDIR(1) 	;INDICATE LOGGED IN AS <OPERATOR>
	  STOR 2,JSDIR		;SAVE AS CONNECTED DIRECTORY
	  SETZRO JSCDF		;NO STRING IN JSB
	  MOVE 2,STRTAB+PSNUM 	;GET SDB ADDRESS OF PRIMARY STRUCTURE
	  LOAD 2,STRUC,(2) 	;GET ITS UNIQUE STRUCTURE CODE
	  STOR 2,JSUC		;SAVE AS CONNECTED STRUCTURE CODE
	  MOVE 2,[[3
		 ASCIZ "OPERATOR"],,USRNAM]
	  BLT 2,USRNAM+2	;SET UP DEFAULT USER NAME STRING
	  MOVE 2,SPECJT(1)
	  JRST 0(2)		;GO DO THE SPECIAL FUNCTION
	ENDIF.
	SUBTTL Job and System Initialization -- Non-zero Jobs

;NOT A SPECIAL JOB. SET UP TERMINAL INFORMATION

	MOVE A,CTRLTT		; GET CONTROLLING TERMINAL
	JUMPL A,SYSINP		;NO TTY. DON'T INIT TTY PARAMETERS
	CALL CHKPTY		;IS IT A PTY?
	 SKIPA			;NO. INIT TTY PARAMETERS
	JRST SYSINP		;YES. DON'T INIT TTY PARAMETERS
	MOVEI 1,100
	MOVEI 2,3B33		;SET TO HDX HERE, SO SETTING TO FDX
	STPAR			;BELOW WILL FORCE OUT TELNET CONTROL
	MOVE 2,NORMTF		;GET TTY TO STANDARD STATE
	SFMOD
	STPAR			;SET DEVICE PARAMETERS TOO
	MOVE B,CTRLTT		;GET CONTROLLING TERMINAL
	CALL CHKTVT		;SEE IF A TCP VIRTUAL TERMINAL
	 SKIPA T2,NORMTY	;[7.1230] No, load system default
	MOVEI T2,.TTIDL		;[7.1230] Yes, load ideal terminal type
	MOVEI T1,.PRIOU
	STTYP
	MOVE 2,TTICB1
	MOVE 3,TTICB2
	SFCOC
	CALL BLINKS		;[7.1230] () Do a TLINK to clear links/advice
;GO START THE EXEC. IF SYSTEM IS STAND-ALONE, TELL THE USER

SYSINP:	SKIPE CRJFLG		;IF CREATED JOB, GO SET IT UP.
	JRST STCRJB		; ..
	MOVE B,CTRLTT		;GET CONTROLLING TERMINAL
	CALL CHKTVT		;ARE WE A TVT?
	 SKIPA			;NO
          CALL TVTMSG		;YES SO OUTPUT THE MESSAGE
	MOVE T1,DBUGSW
	CAIGE 1,2		;DEBUG MODE OPERATION?
	JRST STEX		;NO, GO START EXEC
	TMSG <
[Caution--System is stand-alone]
>
	JRST STEX		;WARN USERS FIRST

SYSIN9:	SETOM CTRLTT		;INDICATE DETACHED SO LOGOUT WON'T
	MOVE T2,JOBNO		; TRY TO WRITE ON THIS TERMINAL
	HRROS JOBPT(T2)		;..
	SKIPL CRJFLG		;IS THIS JOB BEING CREATED BY CRJOB JSYS?
	JRST FLOGO1		;NO. GO KILL THE JOB
	SETOM CRJTTY		;YES, CRJOB TTY IS NO LONGER SPECIAL
	CALL SETANS		;SETUP CRJANS AND CRJFLG
	JRST LOGO		;GO KILL THE JOB
	SUBTTL Job and System Initialization -- CRJOB Created Job

;HERE AT STARTUP OF JOB BY CRJOB JSYS.

STCRJB:	MOVE T1,GBLJNO		;GET GLOBAL JOB INDEX FOR CREATOR
	HRLM T1,CRJONJ		;TELL CREATOR, IF WE GET THERE.
	MOVE Q1,JOBNO		;CARRY AROUND MY JOB NUMBER
	MOVE Q2,CRJAC1		;AND CONTROL FLAGS OF CRJOB AC1
	HRRZ T1,CRJONJ		;Get creator's global job number
	CALL GL2LCL		;Convert it into a local job index
	 JRST SCJXX4		;No such job...give up
	HRRM T1,CRJAC1		;Save the local index for later
	HRRZ T1,CRJONJ		;Get the global job number of creator
	HRL T1,GBLJNO		;GET JOB NUMBER FOR JOBONT.
	TXNE Q2,CJ%OWN		;CREATOR WANTS TO OWN ME?
	MOVEM T1,JOBONT(Q1)	;YES. REMEMBER WHO HE IS.
	MOVE T1,CRJSLO		;SIGNAL ON LOGOUT?
	TXNN Q2,CJ%SLO		; ..
	MOVEI T1,0		;NO. CLEAR THE PID
	MOVEM T1,JSLOPD		;SAVE THE PID FOR THE SIGNAL
	JN CJ%LOG,Q2,STCJB1	;JUMP IF WANTS TO LOG IN
	HRRZ T1,CRJAC1		;NO LOGIN, GET CREATOR'S JOB INDEX
	HRRZ T1,JOBDIR(T1)	; TO FETCH CREATOR'S LOGIN DIRECTORY
	STOR T1,JSDIR		;AND MAKE IT OUR CONNECTED DIRECTORY
	MOVE T1,LGSIDX		;[7.1112]Get number of Login Structure
	MOVE T1,STRTAB(T1)	;[7.1112]Get SDB address
	LOAD T1,STRUC,(T1)	; AND FETCH THE PRIMARY STRUCTURE UNIQUE CODE
	STOR T1,JSUC		;SET IN JSB, COMPLETING CONNECT TO PRIMARY STR
	SETZM CAPENB		;MAKE SURE I HAVE NO CAPS ENABLED
	HLLZS CAPMSK		;OR POTENTIAL
	MOVE T1,CRJOJC		;GET OWNING JOB'S CAPS
	AND T1,CRJCAM		;MASKED, IF ASKED
	TXNE Q2,CJ%CAP		;DOES HE WANT TO GIVE ME HIS?
	HRRM T1,CAPMSK		;YES, I'LL TAKE THEM, UNTIL LOGIN JSYS
	JRST STCJ1A		;DONE WITH LOGIN-ISH STUFF
;HERE IF CJ%LOG IS ON IN CALL. I AM TO TRY TO LOG THIS JOB IN.

STCJB1:	HRROI B,CRJUSR		;POINT TO THE USER NAME STRING
	MOVX T1,RC%EMO		;EXACT MATCH ONLY
	RCUSR			; AND CONVERT TO USER NUMBER
	 ERJMP SCJXXX		;PASS FAILURE CODE BACK
	TXNE T1,RC%NOM!RC%AMB	;FILES ONLY, NO MATCH OR
	JRST SCJXX1		; AMBIGUOUS? FAIL. CAN'T LOG IN.
	MOVEM T3,CRJUSR		;STORE THE NUMBER
	HRRZ T3,T3		;CLEAN FOR CAMN LATER
	MOVE T4,CRJOJC		;GET CREATOR'S CAPS
	HRRZ T1,CRJAC1		;AND JOB INDEX
	HRRZ T1,JOBDIR(T1)	;CREATOR'S LOGIN DIRECTORY
	TRNN T4,SC%WHL!SC%OPR	;PRIVILEGED CREATOR?
	CAMN T1,T3		;OR LOGGING IN AS SAME USER?
	JRST STCJ1E		;YES. NO NEED FOR PSWD CHECK.
	TXZE Q2,<CJ%NPW!CJ%NUD>	;NO, SO REQUIRE PASSWORD, AND LOGIN DATE
	JRST [	MOVEI T1,CRJBX1	;ILLEGAL REQUEST
		JRST SCJXXX]
STCJ1E:	LOAD T1,CJ%ACT,Q2	;WHAT KIND OF ACCOUNT DO WE USE?
	CAIE T1,.CJUCA		;USE CURRENT ACCOUNT OF CREATOR
	CAIN T1,.CJUAA		;OR ARG BLOCK ACCOUNT?
	JRST STCJ1C		;YES, IT'S IN THE COMMON STORAGE.
	SETZM CRJACT		;USE DEFAULT
   ;FALL THRU
   ;CAN FALL IN
STCJ1C:	MOVEI T1,0		;BUILD FLAGS FOR LOGIN JSYS
	TXNE Q2,CJ%NPW		;NO PASSWORD NEEDED?
	TRO T1,1		;RIGHT.
	TXNE Q2,CJ%NUD		;NO UPDATE LOGIN DATE?
	TRO T1,2		;RIGHT. TELL LOGIN.
	HRRM T1,CRJFLG		;STORE FOR IT TO SEE
	MOVE T1,CRJUSR		;LET'S DO THE LOGIN NOW.
	HRROI T2,CRJPSW		;PASSWORD, IF ANY.
	MOVE T3,CRJACT		;AND ACCOUNT
	LOGIN			;SEE IF THIS IS ALL VALID.
	 JRST SCJXXX		;APPARENTLY NOT.
	TXNN Q2,CJ%CAP		;Test if CAP flag is on
	JRST STCJ1A		;No, skip over the rest
	MOVE T1,CRJOJC		;Get caller's caps back
	AND T1,CAPMSK		;AND them with user's available caps
	HLL T1,CAPMSK		;Copy cap allowed to LH of new jobs caps
	MOVEM T1,CAPENB		;Save caps enabled
STCJ1A:	MOVE T2,CRJCPU		;GET TIME LIMIT FOR THIS JOB
	JUMPE T2,SCJBNL		;JUMP IF NO LIMIT
	MOVE T1,[.FHJOB,,.TIMRT] ;SET TIME LIMIT FOR JOB
	MOVEI T3,.ICMSE		;ON MACHINE-SIZE EXC CHANNEL, SO PANIC
	TIMER			;DO IT
	 JRST SCJXXX		;GIVE BACK FAILURE
SCJBNL:	MOVEI T1,.FHSLF		;SET UP TO DO SPJFN
	MOVE T2,CRJPJF		;FROM THIS ARGUMENT
	TXNE Q2,CJ%FIL		;IS THERE BOTH AN EXEC AND AN INFERIOR?
	TXNN Q2,CJ%ETF		; ..
	SKIPA			;NO. DO THE SPJFN HERE.
	JRST STCJ1D		;YES. ONLY DO THE SPJFN ON THE INFERIOR
	TXNE Q2,CJ%SPJ		;REQUESTED TO DO SPJFN?
	SPJFN			;YES, DO IT.
	 ERJMP SCJXX4		;FAILED. HANDLE IT
STCJ1D:	HLLZS CRJFLG		;NO FLAGS FOR A LATER LOGIN
	TXNN Q2,CJ%FIL		;WANT TO RUN A FILE?
	JRST CJSTEX		;NO. JUST GO GET THE EXEC.
STCJB2:	TXNE Q2,CJ%ETF		;WANT A FILE. AN EXEC TOO?
	JRST STCJB3		;YES.
	SKIPE CRJEXF		;[7279] Are we passing flags to an EXEC?
	CALL SCJPRA		;[7279] (/) Yes, set up a PRARG block
	MOVX T1,GJ%OLD!GJ%SHT	;GET THE REQUESTED FILE IN TOP FORK
	HRROI T2,CRJFIL		;POINT TO THE TEXT
	GTJFN			;GET JFN FOR REQUESTED FILE
	 JRST SCJXXX		;CAN'T
	HRLI T1,.FHSLF		;OK, GET IT INTO THIS FORK.
	GET
	ERJMP SCJXX4		;IF GET FAILS, QUIT.
;NOTE: THIS CODE RUNS IN SECTION 0 FOR SOME UNKNOWN REASON. IN
;ORDER FOR THIS CALL TO BLTMU TO WORK CORRECTLY, THIS CODE TEMPORARILY
;ENTERS SECTION 1. IF STRCJB IS MADE TO RUN ENTIRELY IN SECTION 1, THESE
;MACROS SHOULD BE REMOVED.
	TSTMS0			;We had better be in section 1
	MOVEI T1,20		; Length of AC block
	XMOVEI T2,CRJFAC	; From there
	SETZ T3,
	TXNE Q2,CJ%ACS		;AC SET REQUESTED?
	CALL BLTMU
	MOVEI T1,.FHSLF		;GET THE ENTRY VECTOR
IFE STANSW,<
	GEVEC			;GET THE ENTRY VECTOR
	TLNN T2,777000		;TOPS10 STYLE?
	JRST STCJ2A		;NO. TOPS20 STYLE, IF ANYTHING.
	HRRZ T3,CRJEVO		;OLD STYLE. WHERE DOES START POINT?
	CAILE T3,1		;START OR REENTER, I HOPE.
	JRST SCJXX3		;NO. FAIL.
	UMOVE T2,120		;GET JOBSA
	TRNE T3,-1		;OR IF 1,
	UMOVE T2,124		;GET JOBREN
	SKIPA
STCJ2A:	ADD T2,CRJEVO		;NEW STYLE, ADD OFFSET TO BASE.
	HRRZM T2,-1(P)		;WHERE MRETN WILL GO.
>;IFE STANSW
IFN STANSW,<
	XGVEC%			;GET THE ENTRY VECTOR
	IFXN. T2,777000		;TOPS10 STYLE?
	  HRRZ T3,CRJEVO	;OLD STYLE. WHERE DOES START POINT?
	  CAILE T3,1		;START OR REENTER, I HOPE.
	   JRST SCJXX3		;NO. FAIL.
	  XCTU [HRRZ T2,120]	;GET JOBSA
	  TRNE T3,-1		;OR IF 1,
	   XCTU [HRRZ T2,124]	;GET JOBREN
	ELSE.
	  MOVE T2,CRJEVO	;NEW STYLE, GET OFFSET
	  ADD T2,T3		;AND BASE
	ENDIF.
	MOVEM T2,-1(P)		;WHERE MRETN WILL GO.
>;IFN STANSW
	CALL SUCANS		;SETUP CRJANS WITH SUCCESS
	CALL SCJWTA		;WAIT FOR ATTACH, IF WANTED
	JRST MRETN		;AND GO TO USER MODE.

;Here to setup CRJANS and CRJFLG in an interlocked manner

SUCANS:	SETO T1,		;SAY WE HAVE SUCCEEDED.
SETANS:	NOSKED			;NO INTERRUPTS PLEASE
	SKIPGE CRJFLG		;DO WE HAVE AN ANSWER ALREADY?
	 MOVEM T1,CRJANS	; NO, PUT THE RESPONSE IN CRJANS
	MOVEI T1,1		;INDICATE JOB HAS ALREADY SET CRJANS
	HRLM T1,CRJFLG		; BY MAKING FLAG POSITIVE
	OKSKED			;ENABLE INTERRUPTS
	RET			;ALL DONE!
;HERE IF WANT BOTH A FILE AND AN EXEC.

STCJB3:	MOVX T1,GJ%OLD!GJ%SHT	;GET A JFN FOR THE FILE.
	HRROI T2,CRJFIL		;WITH SUPPLIED NAME
	GTJFN
	 JRST SCJXXX		;CAN'T FIND THE FILE.
	PUSH P,T1		;SAVE JFN A MOMENT
	MOVX T1,CR%CAP		;CREATE THE NEW FORK, MY CAPS.
	TXNE Q2,CJ%ACS		;WANT SOME AC'S LOADED?
	TXO T1,CR%ACS		;YES, HAVE CFORK LOAD THEM.
	MOVEI T2,CRJFAC		;HERE ARE THE AC'S
	CFORK			;MAKE ME A FORK! (YOU'RE A FORK)
	 JRST SCJXX2		;CAN'T DO IT.
	EXCH T1,0(P)		;GET BACK JFN, SAVE FHANDLE
	HRL A,0(P)		;SET UP FOR THE GET
	GET
	ERJMP SCJXX2		;CAN'T GET THE FILE
	MOVE T1,0(P)		;HANDLE OF INFERIOR
	MOVE T2,CRJPJF		;PRIMARY I/O FOR IT
	TXNE Q2,CJ%SPJ		;IF REQUESTED,
	SPJFN			;SET IT.
	POP P,T1		;INFERIOR FORK HANDLE.
	HRLZS T1		;FORK,,0
	HRR T1,CRJEVO		;WHERE TO START IT.
CJSTEX:	CALL SCJPRA		;SET UP PRARG FOR EXEC
	CALL STEX		;GET EXEC 
	CALL SUCANS		;SETUP CRJANS WITH SUCCESS
	CALL SCJWTA		;WAIT FOR ATTACH, IF REQUESTED
	JRST GEX1		;AND START THE EXEC.
;CALL THIS ROUTINE BEFORE GOING TO MRETN FROM CRJOB PATHS. IT WILL
;WAIT FOR JOB TO BECOME ATTACHED, IF THAT'S REQUESTED BY CALLER.

SCJWTA:	TXNN Q2,CJ%WTA		;WANT TO WAIT?
	RET			;NO.
	MOVE T1,JOBNO		;YES. GET MY JOB NUMBER
	MOVEI T1,JOBPT(T1)	;AND JOBPT SLOT FOR THIS JOB
	CALL DISGE		;WAIT FOR LH TO BECOME POSITIVE
	RET			;NOW ATTACHED. RETURN.

SCJXX3:	MOVEI T1,SFRVX1		;BAD ENTRY VECTOR OFFSET
	JRST SCJXXX		;RETURN THAT ERROR

SCJXX2:	POP P,0(P)		;ADJUST STACK POINTER
SCJXX4:	HRRZ T1,LSTERR		;AND RETURN THIS FORK'S LAST ERROR
	JRST SCJXXX		; TO CREATOR

SCJXX1:	MOVEI T1,CRJBX5		;UNKNOWN NAME FOR LOGIN
SCJXXX:	ANDI T1,-1		;REDUCE TO JUST ERROR CODE
	CALL SETANS		;GO SETUP CRJANS
	JRST LOGO		;AND KILL OFF THIS STARTED JOB.

;ROUTINE TO SET UP PRARG FOR EXEC TO READ IN NEW JOB

NCJPRA==3			;NUMBER OF ARGUMENT ITEMS
LCJPRA==6			;LENGTH OF BLOCK TO SET

SCJPRA:	TRVAR <<SCJPRB,10>>	;SPACE TO BUILD PRARG BLOCK
	PUSH P,T1		;PRESERVE FORKX,,SFRKV OFFSET
	MOVEI T1,NCJPRA		;NUMBER OF ARGUMENTS
	MOVEM T1,SCJPRB		;INTO THE BLOCK
	MOVEI T1,SCJPRB		;POINT TO BLOCK WITH PUSH POINTER
	PUSH T1,[1B0+3B6+2B12+CR%PRA]	;I AM A CRJOB PRARG
	PUSH T1,[1B0+4]		;WORD 4 IS ANOTHER DATUM
	PUSH T1,[1B0+5]		;WORD 5 IS ANOTHER DATUM
	MOVE T2,CRJEXF		;FLAGS FOR EXEC IS ONE DATUM
	TXNE Q2,CJ%FIL		;IF THERE IS A PROGRAM
	TXO T2,1B1		;TURN ON "THERE'S A FORK" BIT
	PUSH T1,T2		;FLAGS TO ARG BLOCK
	POP P,T2		;RESTORE FORKX,, ENT-VEC-OFFSET
	TXNE Q2,CJ%FIL		;IF THERE IS A PROGRAM
	PUSH T1,T2		;PUT IT IN BLOCK
	MOVE T1,[.PRAST,,.FHSLF] ; SET MY OWN PRARG BLOCK
	MOVEI T2,SCJPRB		;HERE'S THE BLOCK TO SET
	MOVEI T3,LCJPRA		;HERE'S ITS LENGTH
	PRARG			;SET IT
	ERJMP SCJXX4		;CATCH TRAP IF FAILED
	RET			;SUCCESS.
	SUBTTL Job and System Initialization -- Read MONNAM.TXT (GETNAM)

;GETNAM -- Subroutine to construct version and system name from text in the
; file SYSTEM:MONNAM.TXT, or if the file does not exist, to use the default
; text assembled into the monitor in the block labelled TSVN.  The format of
; the resulting text is:
; 	<text>, TOPS-20 Monitor m.v(e)
; The <text> comes either from the file or from the preassembled string.  The
; last several characters identify the monitor version and always come from the
; preassembled string; the entire string may be up to 132(10) characters long,
; so <text> may be 122(10), or 172(8) characters long.  The <text> in the file
; should be terminated by a CRLF pair.

	SWAPCD
GETNAM:	STKVAR <A1>		;RESERVE SPACE FOR ONE TEMP
	MOVE T1,[POINT 7,SVN]	;BYTE POINTER TO DESTINATION
	MOVEM T1,A1		;SAVE UPDATED PTR. TO DEST. STRING
	MOVX T1,GJ%SHT!GJ%OLD	;FLAG FOR SHORT GTJFN CALL AND OLD FILE ONLY
	HRROI T2,[ASCIZ /SYSTEM:MONNAM.TXT/] ;IMPLICIT STRING PTR TO FILE NAME
	GTJFN			;IS THERE A FILE?
	 JRST GETNA1		;NO FILE - DOESN'T MATTER WHY
	MOVX T2,<OF%RD+FLD(7,OF%BSZ)> ;FILE EXISTS, SET UP OPENF CALL
	OPENF			; ..
	 JRST GETNA1		;UNSUCCESFUL FOR ANY REASON, USE
				; DEFAULT STRING
	MOVEI T3,<NSVNT-VTSVNT>*5-1	;MAX. # OF BYTES WE CAN MOVE
	MOVE T4,A1		;RECALL BYTE PTR TO BUFFER
GETNA2:	BIN			;GET NEXT CHARACTER FROM FILE
	CAIE T2,.CHCRT		;IS IT A CARRIAGE RETURN?
	CAIN T2,.CHLFD		;NO, IS IT A LINE FEED?
	JRST GETNA3		;A CR OR A LF WAS ENCOUNTERED
	JUMPE T2,GETNA3		;JUMP ALSO IF IT'S A NULL
	IDPB T2,T4		;IT'S A GOOD CHARACTER, PUT INTO BUFFER
	SOJG T3,GETNA2		;JUMP IF WE HAVN'T EXHAUSTED ALL BUT
				; ONE BYTE POSITION IN BUFFER.
;MANUAL MERGE OF 1B CHANGES
GETNA3:	CLOSF			;YES, CLOSE FILE, RELEASE JFN
	 JFCL			;IGNORE FAILURE
	MOVE T1,T4		;GET STRING POINTER AGAIN
	HRROI T2,VTSVN		;IMPLICIT STRING POINTER TO VERSION
	SETZ T3,		;STOP ON A NULL
	SOUT			;MOVE PREASSEMBLED VERSION TO BUFFER
	RET			;EXIT

GETNA1:	HRROI T1,SVN		;IMPLICIT BYTE POINTER OF DESTINATION
	HRROI T2,TSVN		;IMPLICIT BYTE POINTER TO PREASSEMBLED
				; MONITOR NAME
GETNA5:	SETZ T3,		;SPECIFY TERMINATION ON A NULL
	SOUT			;MOVE PREASSEMBLED STRING TO BUFFER
				; THE MOVE INCLUDED A TERMINATING NULL
	RET			; SO -- WE'RE DONE
	SUBTTL Job 0 Forks -- Initialization (RUNDD)

;SYSTEM INITIALIZATION.  RUN ONCE ONLY BY JOB 0.

	SWAPCD

RUNDD::	MOVE T1,SPJCAP		;GET SPECIAL JOB CAPS
	MOVEM T1,CAPENB		;ENABLE ALL CAPABILITIES FOR INITIALIZATION
	MOVEM T1,CAPMSK		;HERE TOO
	MOVEI T1,RUNDD3		;GO TO RUNDD3 IF AN INTERRUPT OCCURS
	MOVEM T1,JB0XFR		;SAVE THE ADDRESS FOR JB0INT
	MOVE T1,[MSEC1,,JB0INT]	;XFR TO JB0INT ON ERROR
	CALL MONBKX
	MOVX T1,SF%BGS		;Make all messages type on CTY
	IORM T1,FACTSW
	MOVE T1,CTYLNO		;GET CTY LINE NUMBER
	MOVEI T1,.TTDES(T1)	;CONVERT TO 400000+N
	MOVEM T1,JB0TT		;CONTROLLING TERMINAL FOR JOB 0
	HRRM T1,PRIMRY		;AND PRIMARY OUTPUT FOR US
	CALL ASCINI		;Initialize accounting shift change stuff
	CALL RESLCI		;[7.1050]()Init resident free space
	CALL SERINI		;START SYSERR LOGGING
	SKIPN PROFLG		;WANT PRIMARY PROTOCOL?
	JRST RUNDI7		;NO. SKIP ALL PRIMARY STUFF
	MOVEI A,.PRIOU		;YES. FIRST WAIT FOR CTY TO STOP
	DOBE			;"
	CALL TTSPIN		;INITIALIZE TERMINAL SPEEDS TO NULL
	CALL PROINI		;TURN ON PRIMARY PROTOCOL
	CALL DTRMDS		;TELL -11 NOT TO ANSWER DATA SETS

;TRY TO GET TIME AND DATE FROM THE 11. DTE SERVICE SENDS THE REQUEST TO
;THE 11 AND STORES ITS ANSWER IN TAD11. IF THE 11 DOES NOT KNOW, IT
;RETURNS -1. IN THIS CASE, ASK THE OPERATOR FOR THE TIME. IF THE 11 HAS
;IT, DON'T ASK THE OPERATOR

	SKIPE SMFLAG		;IF SM10 THEN WE ALREADY HAVE TIME AND DATE CORRECT
	JRST RUNDD3
	SETZM TAD11		;ZERO TIME CELL
	CALL RQTAD1		;REQUEST TIME/DATE FROM 11
	 JFCL			;THIS FAILURE CAN'T OCCUR
	SKIPN TAD11		;HAS 11 SENT TIME/DATE YET?
	JRST .-1		;NO. WAIT UNTIL IT DOES
	MOVE B,TAD11		;GET TIME SENT FROM -11
	SETOM TAD11		;YES. RESET TO INDICATE NOT SET BY 11
	CAMN B,[-1]		;DOES THE -11 HAVE IT?
	JRST RUNDI7		;NO
	DMOVE C,TAD11+1		;YES. GET REST OF IDCNV ARGS
	IDCNV			;CONVERT TO INTERNAL
	 JRST RUNDI7		;FAILED. GET FROM OPERATOR THEN
	MOVEM B,CRSTAD		;LET IT FIND IT LATER
	;..
;RUNDD...
;SET SYSTEM TIME AND DATE IF THE 11 PROVIDED IT

	;..
RUNDI7:	MOVEI 1,101
	DOBE
	SKIPE 1,CRSTAD		;DO WE HAVE A SAVED TIME FROM CRASH?
	JRST RUNDD3		;Yes, wait to set time till after cluster join
	MOVX A,SF%MST		;NO. SAY IS A MANUAL START
	IORM A,FACTSW		;""

;Initialize checkpoint interval

RUNDD3:	MOVEI T1,RUNDI4		;GO TO RUNDI4 IF AN INTERRUPT OCCURS
	MOVEM T1,JB0XFR		;SAVE THE ADDRESS FOR JB0INT
	MOVE T1,[^D<10*60000>]	;SET DEFALUT CHECKPOINT INTERVAL
	MOVEM T1,CKPINV		;...
;RUNDD...

;Get SCA going, read the CI20 ucode into resident memory, start up IPALOD to
;do the DIAG JSYS that actually loads and starts the port.

IFN FTKLIPA,<
	CALL PPDINX		;CRANK UP PORT/SCA/SYSAPS
	CALL KLPUCD		;GET PORT UCODE INTO MEMORY
	 IFNSK.
	    CAIE T1,GJFX18	;FAILED, WAS IT NO FILE
	    CAIN T1,KLPX7	; OR NO KLIPA?
	    SKIPA		;YES, THAT'S OK FOR NOW
	    BUG.(CHK,KLIPAF,MEXEC,SOFT,<Failed to read in CI20 microcode>,<<T1,ERRCOD>>,<

Cause:	At system startup we tried to read in the CI20 ucode.  Routine KLPUCD
	in module PHYKLP got a JSYS error while attempting the read.

Action:	This BUG will only appear if the system has a KLIPA and if the GTJFN% 
	attempt on the file succeeded.  So, the I/O on the file failed (OPENF%,
	RIN%, SFPTR%, SIN%, CLOSF%) or the monitor was unable to obtain 
	enough free space to hold the microcode.  First, insure that the file
	is not corrupted.  If, after this is done, this BUG still persists, 
	make it dumpable and submit an SPR with the dump and a copy of 
	MONITR.EXE.  If possible, include any known method for reproducing 
	the problem and/or the state of the system at the time the BUG was 
	observed.

Data:	ERRCOD - Error code returned
>,,<DB%NND>)			;[7.1210] 
	 ENDIF.
	MOVX T1,1B1		;Make a fork to prevent hanging
	CFORK			;""
	IFSKP.			;If it made it...
	 DO.
	  MOVE T2,[MSEC1,,CIRUN] ;Where it is to run
	  MSFRK			;Do it
	  ERJMP ENDLP.		;If failed, go on
	  MOVEM T1,CIFORK	;Save fork handle for later
	 ENDDO.
	ENDIF.			;Now we can't get hung by SCA buffer deferral
   >	;IFN <FTKLPA>

	CALL IPACHK		;Check on the KLIPA
	IFNSK.			;If +1, we did reload the KLIPA
	 MOVEI T1,^D2000	;Wait here for the driver to see it
	 DISMS			;""
	ENDIF.
;   IFN CFSCOD,<
	AOS CFSSKC		;Check on CI utility now
;   >
;RUNDD...

;Startup fork for cluster ENQ/DEQ replies and fork fork ENQ/DEQ rescheds

   IFN CLEQIN,<			;[7.1072] If cluster ENQ code present
	MOVX T1,CR%CAP		;[7.1072] Pass capabilities down
	CFORK			;[7.1072] Create fork to be ENQ reply fork
RUNDEQ:	 BUG.(HLT,NOEQFK,MEXEC,SOFT,<Creation or starting of ENQ fork failed>,,<

Cause:	A CFORK and MSFRK was done to create and start a fork for one of
	the ENQ forks.  For some reason, this has failed.
>)				;[7.1072] 
	MOVE T2,[XCDSEC,,EQARUN];[7.1072] Start inferior ...
	MSFRK			;[7.1072] ... in monitor mode
	 ERJMP RUNDEQ		;[7.1072] An error occurred!
	MOVX T1,CR%CAP		;[7.1072] Pass capabilities down
	CFORK			;[7.1072] Create fork to be ENQ resched fork
	 ERJMP RUNDEQ		;[7.1072] Some kind of error
	MOVE T2,[XCDSEC,,EQRRUN];[7.1072] Start inferior ...
	MSFRK			;[7.1072] ... in monitor mode
	 ERJMP RUNDEQ		;[7.1072] An error occurred!
   >				;[7.1072] 
;RUNDD...

IFN STANSW,<
;We start the Multinet background forks (Internet, PUP, ARP) at this point
; instead of at RUNDD7 because we want to invoke the TIME program to set the
; system TAD. By the time SETSPD has run, the various network background forks
; will be set up, ready for TIME to run.  Note that the PUP fork must be
; started first, so as to correctly initialize our subnet routing tables.
	CALL MNTINI		;INITIALIZE MULTINET TABLES, ETC.
	CALL INTBEG		;START THE INTERNET FORK
>;IFN STANSW	

;RUN SETSPD TO SET LINE SPEEDS, SYSTEM LOGICAL NAMES, OTHER SYSTEM
;PARAMETERS

	MOVX T1,GJ%OLD!GJ%SHT!GJ%PHY ;YES. SET LINE SPEEDS
	HRROI T2,SETSPD		;GET POINTER TO "SYSTEM:X-SETSPD.EXE"
	MOVEI T3,1		;[7316] 3/Offset 1 in entry vector
	SETZM T4		;DO NOT RECORD FORK NUMBER
	CALL RUNDII		;GO RUN IT
	 JRST [	TMSG <
%%No SETSPD.
>
		MOVEI T1,.PRIOU ;WAIT UNTIL THE TERMINAL
		DOBE		; STOPS SO THE NEXT MESSAGE IS OK
		JRST .+1]	;SAY IT FAILED
	CALL GETNAM		;DO AGAIN,SINCE SYSTEM: MAY BE REDEFINED
;   IFN CFSCOD,<		;If CFS...
	CALL FILRST		;reset all file accesses now
	CALL CFSJYN		;Join the network now
	CALL CFGTJB		;Initialize CFS Global Job numbers
	CALL MNTPS		;And mount PS: correctly
;   >	;IFN CFSCOD
	XCALL (XCDSEC,CLUJYN)	;[8964](/) Now check CLUDGR connections

;IF DBUGSW IS 0 OR 1, TELL ALL USERS THAT SYSTEM IS RESTARTING

RUNDD6:	MOVE 1,DBUGSW
	SOJG T1,RUNDI4		;If .GE. 2, don't send notification
	SETO 1,
	HRROI 2,[ASCIZ /
System restarting, wait...
/]
	TTMSG
	 ERJMP .+1
	;..
;RUNDD...

;GET DATE AND TIME FROM OPERATOR UNLESS 11 SENT IT EARLIER

	;..
RUNDI4:	MOVEI T1,RUNDI1		;GO TO RUNDI1 IF AN INTERRUPT OCCURS
	MOVEM T1,JB0XFR		;SAVE THE ADDRESS FOR JB0INT
;   IFN CFSCOD,<		;Only if doing CFS code
	SKIPN CRSTAD		;[7.1266] Someone hit ENABLE DISK?
	SETZM BOOTFL		;[7.1266] Yes, ask the questions
	CALL CFTADC		;See if CFS has a better time
	IFNSK.			;CFS does not have the time yet
	  SKIPN T1,CRSTAD	;Did the -11 ever have it?
	  ANSKP.		;Yes, get most recent time from the -11
            SETZM CRSTAD	;Clear unneeded cell
	    SETZM TAD11		;Zero time cell
	    CALL RQTAD1		;Request time/date from 11
	     JFCL		;This failure can't occur
	    SKIPN TAD11		;Has 11 sent time/date yet?
	     JRST .-1		;No. Wait until it does
	    MOVE T2,TAD11	;Get time sent from -11
	    SETOM TAD11		;Reset to indicate not set by 11
	    SETZ T1,		;Assume -11 does not have the time
	    CAMN B,[-1]		;Does the -11 HAVE IT?
	    IFSKP.		;Yes, process it
	      DMOVE T3,TAD11+1	;Get rest of IDCNV args
	      IDCNV		;Convert to internal
	       SETZ T2,		;Failed
	      MOVE T1,T2	;Repositon for check
	    ENDIF.
	ENDIF.
	SKIPN T1		;Did we get the time from anyone?
	IFSKP.			;If so
	 STAD			;Set it
	 ANSKP.			;And if it got set
	 HRROI T1,[ASCIZ /
Date and time is: /]
	 PSOUT			;Tell the operator
	 MOVEI T1,.PRIOU
	 SETOM T2		;Use time we just set
	 MOVX 3,1B1+1B2+1B4+1B5+1B10+1B11+1B17
	 ODTIM			;TYPE IT IN VERBOSE FORMAT
	 HRROI T1,CRLF		;[7.1119] Point to crlf
	 PSOUT			;Make it pretty
	 CALL DTTIME		;If a KL, tell the FE
	 JRST RUNDI1		;And go on
	ENDIF.
;   >	;IFN CFSCOD
;RUNDD...

	CALL LGTAD		;DOES SYSTEM HAVE TIME AND DATE?
	CAME A,[-1]
	JRST RUNDI1		;YES
	MOVE T1,DBUGSW		;Get mode of system
	CAIE T1,3		;Defaulting time/date?
	JRST RUNDI3		;No. Ask then
	MOVE T1,SYSTAD		;Get monitor creation time
	STAD			;Set system time with it
	 NOP
	JRST RUNDI1		;And go on
RUNDI3:
IFN STANSW,<
	MOVX T1,GJ%OLD!GJ%PHY!GJ%SHT	;GTJFN FLAGS
	HRROI T2,[ASCIZ/SYSTEM:TIME.EXE/] ;THE PROGRAM 
	SETZB T3,T4		;START AT MAIN ENTRY POINT, DON'T RECORD FORKX
	CALL RUNDII		;RUN TO COMPLETION, BLOCK UNTIL DONE
	 NOP			;IGNORE AN ERROR
	CALL LGTAD		;GET TIME WORD
	CAME A,[-1]		;DID WE GET THE TIME FROM THE NETWORK?
	JRST RUNDI1		;YES
>;IFN STANSW
	TMSG <
Enter current date and time: >
RUNDI2:	CALL RDDGTD		;GET TAD INTO 2
	PUSH P,2		;SAVE TAD JUST ENTERED
	TMSG <
You have entered >
	MOVEI 1,.PRIOU
	MOVE 2,0(P)
	MOVX 3,1B1+1B2+1B4+1B5+1B10+1B11+1B17
	ODTIM			;TYPE IT IN VERBOSE FORMAT
	MOVE 2,0(P)
	CAMGE 2,SYSTAD		;IS IT GREATER THAN SYSTEM LOAD TAD?
	JRST [	MOVEI 1,.PRIIN	;CLEAR TYPE AHEAD
		CFIBF
		MOVEI 1,.PRIOU
		DOBE		;WAIT FOR TYPE OUT TO STOP
		TMSG <,
that cannot be correct.
Please try again in form MMM-DD-YY HHMM >
		JRST RUNDI2]
	TMSG <,
 is this correct (Y,N) >
	CALL YESNO		;GET VERIFICATION
	JUMPE A,RUNDI3		;IF 'NO', TRY AGAIN
	POP P,1			;CONFIRMED, RECOVER IT
	STAD			;SET IT
	 JFCL
;   IFN CFSCOD,<
	CALL BRDTIM		;If CFS stuff around, reconcile any differences
;   >
	; ..
;RUNDD...

;DECIDE WHETHER TO RUN CHECKD OR NOT. IF CHKBT FOUND ERRORS, FACTSW HAS
;SF%BTE SET; RUN CHECKDTO DO A BIT TABLE CONSISTENCY CHECK. IF BIT
;TABLE FILE DOESN'T EXIST, MS%ASG IS SET IN SDB. DON'T RUN CHECKD.
;(OPERATOR WILL HAVE TO RUN IT WITH THE REBUILD FUNCTION). IF DOING
;RECONSTRUCTION OF ROOT-DIRECTORY OR REBUILD OF BIT TABLE, STARTF HAS
;MI%BTB SET; RUN CHECKD TO DO A REBUILD OF THE BIT TABLE.  IF DOING
;A REFRESH OF THE FILE SYSTEM, DON'T TRY TO RUN CHECKD. IF NONE OF
;THE ABOVE, ASK THE OPERATOR UNLESS AUTO RELOADING. IN ALL CASES,
;ONLY PS IS MOUNTED AT THIS POINT, SO CHECKD IS ONLY RUN ON PS.

	;..
RUNDI1:	MOVEI T1,RUNDD1		;GO TO RUNDD1 IF AN INTERRUPT OCCURS
	MOVEM T1,JB0XFR		;SAVE THE ADDRESS FOR JB0INT
	CALL LOGSST		;LOG RESTART IN SYSERR FILE
	SKIPN AVALON		;RUNNING ACCOUNT VALIDATION?
	JRST RUNDI5		;NO, PROCEED
	CALL ENACT		;[7.1010](/T1)INITIALIZE THINGS FOR ACCT VALIDATION
	IFNSK.			;[7.1010]IF AN ERROR OCCURRED...
	  HRRZ T2,T1		;[7.1010]SAVE THE ERROR CODE
	  TMSG <Problem with <SYSTEM>ACCOUNTS-TABLE.BIN
>				;[7.1010]TELL THE USER THE FILE NAME
	  MOVEI T1,.PRIOU	;[7.1010]TO THE CTY
	  HRLI T2,.FHSLF	;[7.1010]THIS PROCESS
	  SETZ T3,		;[7.1010]ENTIRE STRING
	  ERSTR%		;[7.1010]PRINT THE ERROR STRING
	   ERJMP .+2		;[7.1010]IGNORE ERRORS
	   ERJMP .+1		;[7.1010]...
	  TMSG < - Account validation is disabled
>				;[7.1010]
	  SETZM AVALON		;[7.1010]TURN OFF VALIDATION
	ENDIF. 			;[7.1010]
;RUNDD...

RUNDI5:	MOVX T4,MI%BTB		;IF REBUILDING THE BIT TABLE (BIT IS
	TDNE T4,STARTF		; SET BY FILINI)
	JRST RUNDC2		;ALWAYS RUN CHECKD IN REBUILD MODE
	MOVE 2,DBUGSW		;IF DEBUGGING,
	CAIL T2,2		;If debugging...
	JRST RUNDD2		;DON'T RUN CHECKD
	MOVX T4,MI%RFS		;IF REFRESHING (BIT IS SET
	TDNE T4,STARTF		; BY FSIINI)
	JRST RUNDD2		;DON'T RUN CHECKD (IT ISN'T THERE)
	MOVE T2,STRTAB+PSNUM	;POINT TO SDB FOR PS
	MOVE T2,SDBSTS(T2)	;GET STATUS BITS FOR PS
	MOVE T1,FACTSW
	TXNE T1,SF%BTE		;BIT TABLE ERRORS?
	TXNE T2,MS%ASG		;YES. ARE DISK ASSIGNMENTS PROHIBITED?
	SKIPA			;YES. DON'T RUN CHECKD
	JRST RUNDC1		;BIT TABLE ERRORS BUT BT FILE EXISTS. RUN CHECKD
	TXNN A,SF%MST		;MANUAL STARTUP?
	JRST RUNDD2		;NO. NO QUESTIONS AND NO CHECKD
	;..
;RUNDD...

;CHECKD NOT REQUIRED.  SEE IF OPERATOR WANTS IT

	;..
	CALL RUNCKD		;[7.1003] (/) Do we run CHECKD?
	 JRST RUNDD2		;[7.1003] No
RUNDC1:	SKIPA T1,[-1,,[ASCIZ/[Checking file consistency]
/]]
RUNDC2:	HRROI T1,[ASCIZ/[Rebuilding bit table]
/]
	PSOUT
	MOVSI 1,(GJ%OLD!GJ%PHY!GJ%SHT)
	HRROI 2,[ASCIZ /SYSTEM:CHECKD.EXE/]
	MOVX T3,SF%CDR		;SAY CHECKD NOW RUNNING
	IORM T3,FACTSW		;DO IT
	SETZ T3,		;NORMAL ENTRY POINT
	MOVX T4,MI%BTB
	TDNE T4,STARTF		;REBUILDING BIT TABLE?
	MOVEI T3,3		;YES. START AT SPECIAL ENTRY POINT
	SETZM T4		;DO NOT RECORD FORK NUMBER
	CALL RUNDII		;GO START IT
	 JRST [	MOVX T1,SF%CDR	;NOT RUNNING
		ANDCAM T1,FACTSW
		JRST RUNDD1]	;FAILED
	SETZM STARTF		;INDICATE STARTUP IS COMPLETE
IFN SKEDSW,<
	SETZM NNSBE		;RESTART COUNTING NOSKED P-FAULTS
	>			;END IFN SKEDSW
	MOVX T1,SF%CDR		;SAY CHECKD NOT RUNNING ANYMORE
	ANDCAM T1,FACTSW	;""
	JRST RUNDD2		;PROCEED

;FAILED TO FIND CHECKD WHEN RUNNING IT WAS REQUIRED BY THE SYSTEM
;OR REQUESTED BY THE OPERATOR. PRETEND THAT IT RAN AND FOUND
;ERRORS. IF IT IS RUN LATER AND FINDS PS TO BE OK, IT WILL CLEAR
;SF%CDE.
;IT ALSO CAUSES THE 'FILE STRUCTURE NEEDS REPAIR' MESSAGE BELOW
;AND PREVENTS SYSJOB FROM DOING ITS USUAL THING

RUNDD1:	MOVEI T1,RUNDD2		;GO TO RUNDD2 IF AN INTERRUPT OCCURS
	MOVEM T1,JB0XFR		;SAVE THE ADDRESS FOR JB0INT
	TMSG <
No CHECKD
>
	SETZM STARTF		;INDICATE STARTUP COMPLETED
IFN SKEDSW,<
	SETZM NNSBE		;RESTART COUNTING NOSKED P-FAULTS
	>			;END IFN SKEDSW
	MOVX T4,SF%CDE		;PRETEND CHECKD FOUND ERRORS
	IORM T4,FACTSW
	;..
;RUNDD...

;IF DEBUGGING, TELL ALL USERS. IF CHECKD FOUND ERRORS, TELL ALL USERS
;THEN PROCEED AS USUAL

	;..
RUNDD2:	CALL SRVCFS		;NOTIFY MSCP SERVER THAT INIT IS COMPLETE
	SETZM LGSIDX		;[7.1112]Initialize LGSIDX
	SKIPE LGSFLG		;[7.1112]Login Structure enabled?
	CALL FNDLGS		;[7.1112]()Yes. Try to mount one
	SETONE SF%DPR,FACTSW	;Now enable disk preallocation
	MOVEI 1,RUNDD7		;GO TO RUNDD7 IF AN INTERRUPT OCCURS
	MOVEM T1,JB0XFR		;SAVE THE ADDRESS FOR JB0INT
	MOVEI 1,101
	DOBE			;WAIT FOR ANY CHECKD OUTPUT
	MOVE 1,DBUGSW
	CAIL 1,2		;DEBUG MODE OPERATION?
	JRST [	SETO 1,		;YES, DIFFERENT MESSAGE
		HRROI 2,[ASCIZ /
[System is stand-alone]
/]
		TTMSG
		 ERNOP.		;IN CASE OF REFUSALS
		JRST RUNDE1]
	MOVX 1,SF%CDE
	TDNE 1,FACTSW		;DID CHECKD FIND DISK ERRORS?
	JRST [	HRROI 2,[ASCIZ /
[System not in operation - file structure needs repair]
/]
		SETO 1,
		TTMSG
		 ERNOP.		;IN CASE OF REFUSALS
		JRST RUNDE1]
;RUNDD...

;Create a fork to be the old "job 0" fork -- the one that runs at CHKR.
;Continue the current fork at DDMP.

RUNDE1:	MOVX T1,1B1		;Create a fork
	CFORK			;Do it
RUNDDX: BUG.(HLT,DDXFRK,MEXEC,SOFT,<Cannot create CHKR fork>,<<T1,ERRCOD>>,<

Cause:	CFORK% failed to create the old "Job 0" fork that runs CHKR or the
	fork could not be be started in monitor mode with the MSFRK% JSYS.

Data:	ERRCOD - Error code returned from JSYS
>)
	XMOVEI T2,RUNDEC	;Where to proceed
	MSFRK			;Continue things below
	 ERJMP RUNDDX

;Continue the current fork at DDMP0.

	MOVE T1,[MSEC1,,DDMPER]	;GO TO DDMPER ON ERRORS
	CALL MONBKX
	TMSG <
Running DDMP

>
	MOVE T1,FORKX		;GET FORK NUMBER
	MOVEM T1,DDMFRK		;RECORD IT
	JRST DDMP0		;DO DDMP HERE
	SUBTTL Job 0 Forks -- Page Movement to Disk (DDMP)

DDMP0:	TSTMS0			;BE SURE NO SECTION 0
	SETZM P1		;Not doing CFS-forced DDMP
DDMP00:	MOVE T1,TODCLK		;GET THE CURRENT TIME
	ADD T1,DDPPER		;CALCULATE NEXT ALARM TIME
	MOVEM T1,DDPTIM		;AND SAVE IT FOR THE SCHED TO CHECK
	SETZM DDPDUE		;RESET THE OVERDUE COUNTER
	MOVE T1,DRMFRE		;DRUM SPACE LOW?
IFE STANSW,<
	CAMGE T1,DRMIN0
	JRST [	TMSG <DDMP: Swapping space low action
>
		JRST DDMPA]
DDMPA:
>;IFE STANSW
IFN STANSW,<
	CAMGE A,DRMIN0		;SWAP SPACE LOW?
	 SKIPE DBUGSW		;YES, NOTE ONLY IF PRODUCTION SYSTEM
	  JRST DDMPAA		;NOT LOW OR WE'RE DEBUGGING
	CALL TIMSMP		;TIMESTAMP OUTPUT
	TMSG < DDMP: Swap space low action
>
DDMPAA:
>;IFN STANSW
	IFE. P1			;Check which flavor we are doing
	 CALL DDMP		;DO THE WORK
	  NOP
	ELSE.
	 CALL DDMPF		;DO force out
	 AOS DDCFSF
	ENDIF.
	IFE. P1			;If this was a regular run
	 MOVX A,^D60000		;SET TIME FOR NEXT CYCLE AS 1 MINUTE
	 ADD A,TODCLK		;When to do it again
	 MOVEM A,DDTIME
	ENDIF.
	SETZM P1
	SKIPE DDCFSF		;Need another force?
	IFNSK.			;If so
	 MOVEI T1,^D50		;Wait a short while
	 DISMS			;""
	ELSE.
	 MOVEI A,DDPWAT		;The test
	 HDISMS			;Wait a bit
	ENDIF.
	EXCH P1,DDCFSF		;Zero the word, get new value for flag
	JRST DDMP00		;And do it again
;Here when DDMP fork gets an error

DDMPER:	BUG.(CHK,DDMINT,MEXEC,SOFT,<Unexpected interrupt in DDMP process>,<<ITFPC,ITFPC>,<LSTERR,LSTERR>>,<

Cause:	An unexpected error has occurred in the process which handles
	migration of pages to disk.  The error handler will attempt
	to reinitialize the context and resume processing.  The
	stack may be examined for an indication of where the error
	occurred.

Action:	If this BUG persists, make it dumpable and submit an SPR with the
	dump and a copy of MONITR.EXE.  If possible, include any known
	method for reproducing the problem and/or the state of the system
	at the time the BUG was observed.

Data:	ITFPC - PC when error occurred.
	LSTERR - Last error code in fork.
>)
	SETZM NSKED		;BE OKSKED
	SETZM CRSKED		;BE NOT 'CRITICAL SECTION'
	MOVX CX,USRCTX
	MOVEM CX,FFL
	MCENTR			;RESET STACK, REINIT CONTEXT
	MOVE T1,FORKX		;T1/ FORK NUMBER
	SETZM T2		;T2/ ALL INTERRUPT LEVELS
	CALL JSBSTF		;CLEAN THE JSB STACK
	JRST DDMP0		;RESUME
	SUBTTL Job 0 Forks -- KLIPA Checking (IPACHK)

;Routine to see if a KLIPA load/dump is needed.
;Returns:
;	+1 did something
;	+2 didn't

IPACHK:	CALL CHKKLP		;(/T2) Ask the port driver
	 RETSKP			;NOTHING NEEDED
	MOVX T1,GJ%SHT!GJ%OLD	;EXISTING FILE
	MOVEI T3,3		;SPECIAL ENTRY FOR MONITOR STARTUP
	SKIPE T2		;LOADING?
	IFSKP.

;We will try to load the port's u-code

	  HRROI T2,[ASCIZ /BS:<SYSTEM>IPALOD.EXE/] ;[7.1112]The file
	  XMOVEI T4,CILFRK	;PLACE TO PUT FORK NUMBER OF IPALOD
	  CALL RUNDII		;Do it
	   SKIPA		;Failed
	  RET			;Did it. Say so.
	  BUG.(CHK,NOLODF,MEXEC,SOFT,<Could not find CI-20 microcode load program>,,<

Cause:	The KLIPA (IPA20) RAM needs to be reloaded.  The program
	BS:<SYSTEM>IPALOD.EXE is supposed to be run to do this.  However,
	the program does not exist.  TOPS-20 is now ignoring the CI20.

Action:	If you wish to use the CI20, you must install the load progam, which 
	also contains the CI20 microcode, as BS:<SYSTEM>IPALOD.EXE and reload 
	the system.
>,,<DB%NND>)			;[7.1210][7.1112]
	  CALL KLPNLF		;DECLARE THE KLIPA DEAD
	  RET
	ENDIF.

;We will try to dump the port's u-code

	HRROI T2,[ASCIZ /BS:<SYSTEM>IPADMP.EXE/] ;[7.1112]The file
	XMOVEI T4,CIDFRK	;PLACE TO PUT FORK NUMBER OF IPADMP
	CALL RUNDII		;Do it
	 SKIPA			;Failed
	RET			;Did it. Say so.
	BUG.(CHK,NODMPF,MEXEC,SOFT,<Could not find CI-20 microcode dump program>,,<

Cause:	The KLIPA (IPA20) RAM needs to be dumped.  The file
	BS:<SYSTEM>IPADMP.EXE is supposed to be run to do this.  However,
	the file does not exist.

Action:	Currently, TOPS-20 does not support dumping of the CI20 via the
	IPADMP.EXE program.  Presently, nothing in TOPS-20 should be 
	attempting to dump the KLIPA and this BUG should never appear.
>,,<DB%NND>)			;[7.1210][7.1112]
	CALL KLPNDF		;RELOAD AND START THE PORT
	RET
	SUBTTL Job 0 Forks -- CI Buffer Checks (CIRUN)

;This is CIFORK.  It is started during system startup, immediately after
;the CI20 is started.  This fork must be started before CHKR becuase it
;performs functions which are needed before CHECKD had completed.

CIRUN:	MOVX T1,USRCTX		;Start with user context set
	MOVEM T1,FFL		;.	.	.
	MCENTR			;Start a new process
CILOOP:	MOVEI T1,CIWAIT		;The wait test
	MDISMS			;Wait up
	TMNE CIBUF		;NEED TO CREATE BUFFERS?
	CALL SC.MAL		;[7.1037]YES, Do buffer checking now
	TMNE CIREP		;NEED TO REAP CONNECT BLOCKS?
	CALL SC.RAP		;YES
	JRST CILOOP		;And do it agaain
	SUBTTL Job 0 Forks -- CHKR Initialization

;System initialization fork resumes here

RUNDEC:	MOVX T1,USRCTX		;Start with user context set
	MOVEM T1,FFL
	MCENTR			;Start a new process
	MOVE T1,FORKX		;GET FORK NUMBER
	MOVEM T1,JB0FRK		;RECORD IT
	MOVE T1,[MSEC1,,JB0INT]	;Where to go on error
	CALL MONBKX
	MOVE 1,JB0TT		;JOB 0 TTY
	CAIE 1,377777		;REAL TTY?
	JRST RUNDD4		;YES

;INITIALIZE SYSERR LOGGING

	MOVEI 1,ERRPT		;GET NAME OF SYSTEM ERROR FILE
	CALL PUTNAM		;ADD STRUCTURE NAME
	MOVSI 1,(GJ%FOU!GJ%PHY!GJ%SHT)	;NONE, SO OPEN FILE FOR MESSAGES
	HRROI 2,ERRPT		;GET NAME OF SYSTEM ERROR FILE
	GTJFN
	 BUG.(CHK,NOSERF,MEXEC,HARD,<Cannot GTJFN error report file>,<<T1,ERRCOD>>,<

Cause:	The CHKR fork failed to get a JFN for the ERROR.REPORT file.

Action:	Based upon the error code returned from GTJFN%, attempt to diagnose
	the problem.  If all appears to be in order and the BUG still 
	persists, make it dumpable and submit an SPR with the dump and a 
	copy of MONITR.EXE.  If possible, include any known method for 
	reproducing the problem and/or the state of the system at the time 
	the BUG was observed.

Data:	ERRCOD - GTJFN error code
>,,<DB%NND>)			;[7.1210] 
	MOVE 2,[44B5+1B20]
	OPENF
	 BUG.(CHK,SERFOF,MEXEC,HARD,<Cannot OPENF error report file>,<<T1,ERRCOD>>,<

Cause:	The CHKR fork could not open the ERROR.REPORT file.

Action:	Based upon the error code returned from OPENF%, attempt to diagnose
	the problem.  If all appears to be in order and the BUG still 
	persists, make it dumpable and submit an SPR with the dump and a 
	copy of MONITR.EXE.  If possible, include any known method for 
	reproducing the problem and/or the state of the system at the time 
	the BUG was observed.

Data:	ERRCOD - OPENF error code
>,,<DB%NND>)			;[7.1210] 
RUNDD4:	HRRM 1,PRIMRY		;USE IT FOR OUTPUT

;START ACCOUNTING

	CALL USGINI		;START ACCOUNTING
	;..
;RUN SETSPD AGAIN. THIS TIME, START IT AT A SPECIAL PLACE TO MAKE
;IT COPY THE DUMP FILE.

	;..
	MOVX T1,SF%CDE		;DON'T CREATE DUMP.CPY IF THE BIT
	TDNE T1,FACTSW		; TABLE IS BAD
	JRST RUNDD7		;CHECKD FOUND ERRORS IN THE BT
	MOVX T1,GJ%OLD!GJ%PHY!GJ%SHT
	HRROI T2,SETSPD		;GET POINTER TO "SYSTEM:X-SETSPD.EXE"
	MOVEI T3,3		;3/ OFFSET 3 IN ENTRY VECTOR
	SETZM T4		;DO NOT RECORD FORK NUMBER
	CALL RUNDII		;GO RUN IT
	 JFCL			;IGNORE FAILURE
	SKIPL SPRCNT		;IF SPRCNT<0 THEN SETSPD DID NOT RE-INIT IT
	IFSKP.			;SO.. TELL WORLD
	 TMSG <
%SPEAR entry counter was not re-initialized, resynching to 0.
>
	 SETZM SPRCNT		;AND RESET TO 0 TO START LOGGING
	ENDIF.
	AOS SECHKF		;FORCE STUFF GOING ON THE SYSERR QUEUE

;DO NETWORK-RELATED FUNCTIONS

RUNDD7:	MOVEI T1,RUNDD8		;GO TO RUNDD8 IF AN INTERRUPT OCCURS
	MOVEM T1,JB0XFR		;SAVE THE ADDRESS FOR JB0INT
;Now start up the CLUDGR fork

	CALLX (XCDSEC,CLSFRK)	;[7.1076] (/) Get the fork meowing

IFE FTNSPSRV,<
	CALL D36INI		;INIT DECNET
	 JFCL			;IGNORE (SPURIOUS) NON-SKIP RETURN
	CALL LLMINI		;INITIALIZE Ethernet LLMOP Protocol Servers
	CALL CTHINI		;INITIALIZE FOR CTERM HOST
	CALL OBJINI		;INITIALIZE OBJECT TYPE TABLE FOR DECNET
>;END IFE NSPSRV
	CALL LATINI		;INITIALIZE LAT HOST
IFE STANSW,<
	CALL MNTINI		;INITIALIZE MULTINET
	CALL INTBEG		;INITIALIZE THE INTERNET FORK
>;IFE STANSW
IFN FTNSPSRV,<
	CALL ATSINI		;INITIALIZE APPLICATIONS TERMINAL SERVICE
	CALL NSPINI		;INIT DECNET FORK AND DATA BASE
>;END IFE NSPSRV
RUNDD8:	MOVEI T1,RUNDD5		;GO TO RUNDD5 IF AN INTERRUPT OCCURS
	MOVEM T1,JB0XFR		;SAVE THE ADDRESS FOR JB0INT
	AOS SYSIFG		;INDICATE NO LONGER IN STARTUP
				; (NEXT JOB WON'T GO THROUGH RUNDD)
	CALL DONSJ		;START NEXT SPECIAL JOB
	;..
;CREATE FORK UNDER JOB 0 AND RUN SYSJOB IN IT. SYSJOB READS A COMMAND
;FILE, WHOSE NAME IS DETERMINED BY THE SETTING OF DBUGSW. IF CHECKD
;HAS NOT BLESSED THE PRIMARY STRUCTURE (SF%CDE IS SET IN FACTSW), SYSJOB
;DOES NOT READ A COMMAND FILE.  AMONG OTHER THINGS, THIS WILL PREVENT
;LOGINS FROM TERMINALS OTHER THAN THE CTY

	;..
	MOVX T1,<GJ%OLD!GJ%PHY!GJ%SHT>
	HRROI T2,SYSJOB
	SETZM T3		;MAIN ENTRY POINT
	XMOVEI T4,SJBFRK	;LOCATION TO PLACE FORK NUMBER OF SYSJOB
	CALL RUNDIR		;RUN SYSJOB AND RETURN
	 JRST [	 TMSG<
No SYSJOB
>
		JRST .+1]
RUNDD5:	MOVEI 1,1		;KEEP JOB 0 IN QUEUE 1 ALWAYS
	MOVEM 1,JOBBIT		;SET PRIORITY FOR CHKR
	XMOVEI T1,CHKR		;GO TO CHKR IF AN INTERRUPT OCCURS
	MOVEM T1,JB0XFR		;SAVE THE ADDRESS FOR JB0INT
	SETZM EXPFRK		;CLEAR FORK HANDLE
	SKIPN SMFLAG		;IF NOT 2020
	CALL RUNMO1		;RUN MOS MEM DIAG
	SE1ENT			;Make sure we are in section one
	JRST CHKR		;GO DO BACKGROUND
	SUBTTL Job 0 Forks -- Fork Startup (RUNDIR/RUNDII)

;ROUTINE TO RUN A PROGRAM IN A FORK UNDER JOB 0
; A/ GTJFN T1 ARGS
; B/ GTJFN T2 ARGS
; C/ OFFSET IN ENTRY VECTOR WHERE WE START FORK
; D/ LOCATION IN WHICH TO PLACE FORK NUMBER (0 IF NOT DESIRED)
;	CALL RUNDII
;	  or
;	CALL RUNDIR
;RETURNS +1: FAILED, PROGRAM NOT RUN
;	 +2: RUNDII - PROGRAM RAN TO COMPLETION, FORK KILLED
;	     RUNDIR - PROGRAM STARTED,  A/ FORK HANDLE

RUNDIR:	SAVEAC <Q1>		;SAVE TRASHED AC
	SETZM Q1		;NO WAIT FLAG
	JRST RUNDIC		;CONTINUE

RUNDII::SAVEAC <Q1>		;SAVE TRASHED AC
	SETOM Q1		;WAIT FLAG
RUNDIC:	STKVAR<EVEC,LOCFN,WFLAG,FKHNDL,FILJFN>
	MOVEM C,EVEC		;SAVE OFFSET IN ENTRY VECTOR
	MOVEM D,LOCFN		;SAVE LOCATION TO PUT FORK NUMBER
	MOVEM Q1,WFLAG		;SAVE WAIT FLAG
	GTJFN
	 RET			;FAILED
	MOVEM T1,FILJFN		;SAVE JFN
	MOVX T1,CR%CAP		;XMIT CAPABILITIES
	CFORK			;CREATE A FORK FOR CHECKD
	 JRST [	EXCH T1,FILJFN	;SAVE ERROR CODE. GET JFN
		RLJFN		;RELEASE IT
		 NOP
		MOVE T1,FILJFN	;GET BACK ERROR CODE
		RET]		;AND DONE
	MOVEM T1,FKHNDL		;SAVE FORK HANDLE
	SKIPN T2,LOCFN		;WANT TO SAVE FORK NUMBER?
	IFSKP.			;YES
	  CALL GSWFRK		;(T1/T1) GET SYSTEM WIDE FORK NUMBER
	   JFCL			;IGNORE ERROR
	  MOVEM T1,(T2)		;SAVE FORK NUMBER OR ERROR CODE WHERE SPECIFIED
	ENDIF.
	;...
	;...
	MOVE T2,JOBBIT		;SET TO SAME AS OURS
	SPRIW			;BY SETTING PRIORITY WORD
	ERJMP .+1		;JUST IN CASE
	HRL T1,FKHNDL		;FORK HANDLE TO LH
	HRR T1,FILJFN		;JFN TO RH
	GET
	 ERJMP [MOVE T1,FKHNDL	;GET FORK HANDLE
		KFORK		;KILL THE FORK
		RET]		;AND DONE
	MOVE T1,FKHNDL		;GET FORK HANDLE
	MOVE 2,EVEC		;2/OFFSET IN ENTRY VECTOR
	SFRKV			;START AT MAIN ENTRY
	 ERJMP [MOVE T1,FKHNDL	;GET HANDLE
		KFORK		;KILL FORK
		RET]
	SKIPN WFLAG		;WANT TO WAIT?
	RETSKP			;NO. RETURN NOW
	WFORK
	KFORK
	RETSKP			;ALL DONE
	SUBTTL Job 0 Forks -- Set Error Address (MONBKX)

;ROUTINE TO SETUP A MONITOR FORK TO HANDLE ERRORS
; ACCEPTS: T1/ 30 BIT ADDRESS OF ROUTINE TO TRANSFER TO ON ERROR
;
MONBKX::MOVEM 1,MONBK
	MOVEI 1,.FHSLF		;1/THIS FORK
	MOVEI 2,MICHN		;2/CHANNELS TO ENABLE
	MOVEM 2,MONCHN		;MAKE THE MONITOR TAKE INTERRUPTS ON THEM
	AIC			;ACTIVATE CHANNELS 34 AND 35
	 ERJMPR [BUG.(CHK,MONBKB,MEXEC,SOFT,<Cannot set monitor error interrupt>,<<T1,LSTERR>>,<

Cause:	The monitor was attempting to enable interrupts on the monitor error 
	channels. This BUG. indicates that the AIC failed.

Action:	If this BUG persists, make it dumpable and submit an SPR with the
	dump and a copy of MONITR.EXE.  If possible, include any known
	method for reproducing the problem and/or the state of the system
	at the time the BUG was observed.

Data:	LSTERR - Last process error
>,R)]
	RET
	SUBTTL Job 0 Forks -- Make System Restart Record (LOGSST)

;ROUTINE TO MAKE RESTART ENTRY IN SYSERR FILE

LOGSST:	TRVAR <<RDDBFR,.RLBSZ>>
	SAVEQ
	SKIPE BOOTFL		;[7.1226] An old boot?
	IFSKP.			;[7.1226] If so, do old method
	  JE SF%MST,FACTSW,LOGSS3 ;[7.1226] Jump if auto restart
	ENDIF.			;[7.1226]
	MOVX T1,SF%MST		;[7.1226] Get auto restart flag
	SKIPL BOOTFL		;[7.1226] Auto restart?
	IFSKP.			;[7.1226] If so,
	  ANDCAM T1,FACTSW	;[7.1226] Flag it such
	  JRST LOGSS3		;[7.1226] And go on (don't ask questions)
	ENDIF.			;[7.1226]
	IORM T1,FACTSW		;[7.1226] Say it isn't auto restart
	MOVE T1,DBUGSW		;Get mode of system
IFE STANSW,<
	CAIE T1,3		;Default startup stuff?
>
IFN STANSW,<
	CAIGE T1,2
>
	JRST LOGSS1		;No
	MOVX T1,<ASCIZ /SA/>	;yes. It is Stand-alone then
	MOVEM T1,RDDBFR		;Stash it
	JRST LOGSS3		;And go on
LOGSS1:	CALL WHYRLD		;[7.1003] (/) Get answer for Why Reload?
	MOVE T1,[-RLALEN,,RLATAB] ;SET TO VERIFY HIS ANSWER
	CALL MATRLA		;SEE IF ANSWER MATCHES TABLE
	 JRST LOGSS2		;NO, TELL HIM HIS CHOICES
	AOBJP T1,LOGSS3		;YES, SEE IF IT'S UNIQUE
	CALL MATRLA		;ANY OTHER MATCHES?
	 JRST LOGSS3		;NO, THIS IS A WINNER
LOGSS2:	TMSG <  Not a valid response (?=HELP)
>
	JRST LOGSS1		;TRY, TRY AGAIN
LOGSS3:	MOVX T1,RL%LEN
	MOVX T2,RL%SIZ
	CALL ALCSEB		;GET SYSERR STORAGE
	 JRST [BUG.(CHK,SYSERF,MEXEC,SOFT,<LOGSST - No SYSERR storage for restart entry>,,<

Cause:	ALCSEB in LOGSST failed to allocate a SYSERR storage block.

Action: As a result, there will be no restart reason entered in ERROR.SYS.
	This is informational and no action is required.
>)
		RET]
	MOVEM T1,Q1
	MOVE T2,[-NWHYIT,,WHYIT]
	CALL SEBCPY		;COPY DATA INTO BLOCK
	 JFCL
	MOVE T2,[-1,,[SEBPTR RL%OPR,SBTSTR,RDDBFR]]
	MOVE T3,FACTSW
	TXNN T3,SF%MST		;USE OPR ANSWER IF MANUAL START
	MOVE T2,[-1,,[SEBPTR RL%HLT,SBTWD,BUGHLT]]
	MOVE T1,Q1		;USE BUGHLT ADDRESS OTHERWISE
	CALL SEBCPY
	 JFCL
	MOVE T1,Q1
	CALL QUESEB		;QUEUE BLOCK FOR SYSERR FILE
	RET
	SUBTTL Job 0 Forks -- Ask "Why Reload?" (WHYRLD)

;[7.1003]
;WHYRLD - ROUTINE TO ANSWER THE "WHY RELOAD?" QUESTION
;This routine will display the question "WHY RELOAD?" on the CTY and
;then get an answer for it. The answer is returned in RDDBFR.
;
; Call with:
;	no arguments
;	CALL WHYRLD
;
; Returns:
;	+1 - answer to "WHY RELOAD?" in RDDBFR

WHYRLD:	TMSG <Why reload? >	;Manual restart, find out why
	CALL TIMOUT		;(/) Only give the user 60 seconds to answer
	 JRST WHYDEF		;60 seconds passed with no answer - use default
	HRROI T1,RDDBFR		;Put answer here
	MOVX T2,RD%BRK+RD%BEL+RD%RAI+RD%CRF+20*5 ;Flags,,number of chars
	HRROI T3,[ASCIZ /Why reload? /] ;Reprompt text
	RDTTY%			;Get answer
	 ERJMP .+1		;Don't care about miscues
	SETZ T3,		;End answer with a NULL
	DPB T3,T1
	MOVE T1,[POINT 7,RDDBFR] ;Setup pointer to source string
WHYRL1:	ILDB T2,T1		;Get a char
	CAIE T2,.CHSPC		;Space?
	CAIN T2,.CHTAB		;Tab?
	JRST WHYRL1		;One of the two
	CAIE T2,"?"		;Did he ask for help?
	RET			;No, must be a real answer
	HRROI T1,LOGMSG		;Get the help message
	PSOUT%			;Display it
	JRST WHYRLD		;Try again

WHYDEF:	TMSG <
Why reload? >			;[7.1019] Retype the question
	HRROI T1,DEFMSG		;Show the default message
	PSOUT%
	HRROI T1,RDDBFR		;Put default answer here
	HRROI T2,DEFMSG		;This is where the default message is
	SETZB T3,T4		;End on NULL
	SOUT%			;Blast default message into RDDBFR
	 ERJMP .+1		;Don't care about failures
	RET			;Done
	SUBTTL Job 0 Forks -- Ask "Run CHECKD?" (RUNCKD)

;[7.1003]
;RUNCKD - ROUTINE TO ANSWER THE "RUN CHECKD?" QUESTION
;This routine displays the question "RUN CHECKD?" and
;obtains a "YES" or "NO" answer for it.
;
; Call with:
;	no arguments
;	CALL RUNCKD
;
; Returns:
;	+1 - "RUN CHECKD?" answered with a "NO"
;	+2 - "RUN CHECKD?" answered with a "YES"

RUNCKD:	TMSG <Run CHECKD? >	;Pose the question
	CALL TIMOUT		;(/) Start timer
	 JRST NOCHKD		;No answer was given in 60 seconds
	CALL YESNO		;(/T1) Something was typed, see what it was
	JUMPE T1,R		;No was the answer
	RETSKP			;Answer was yes

NOCHKD:	TMSG <
Run CHECKD? NO - Question timeout
>
	RET			;Return as no
	SUBTTL Job 0 Forks -- Timeout starup questions (TIMOUT)

;[7.1003]
;TIMOUT - ROUTINE TO PERFORM TIMING FEATURE FOR RUNCKD AND WHYRLD
;This routine performs the timeout service required for
;WHYRLD and RUNCKD.
;
; Call with:
;	no arguments
;	CALL TIMOUT
;
; Uses T4 as the counter. T4 contains the number of times 1/10 of a 
; second has passed.
;
; Returns:
;	+1 - A 60 second timeout occurred and nothing was typed
;	+2 - Something was typed (assume an answer is on the way)

TIMOUT:	SETZ T4,		;No time has elapsed yet
TMOUT1:	MOVE T1,CTYLNO		;Get CTY line number
	MOVEI T1,.TTDES(T1)	;Make it a TTY designator
	SIBE%			;Anything typed?
	 RETSKP			;Yes, we're done here
	CAIL T4,^D600		;Has 1 minute passed?
	RET			;Yes it has, return
	MOVEI T1,^D100		;Sleep for 1/10 of a second
	DISMS%
	AOJA T4,TMOUT1		;Increment our time counter and try again
	SUBTTL Job 0 Forks -- Check "Why Reload?" Response (MATRLA)

;ROUTINE TO SEE IF RDDBFR MATCHES ENTRY IN TABLE
;CALL T1/AOBJN POINTER TO TABLE
;RETURNS +1 NO MATCH
;RETURNS +2 MATCH
MATRLA:	MOVE T2,[POINT 7,RDDBFR,] ;POINTER TO HIS ANSWER
	MOVE T3,[POINT 7,(T1),]   ;POINTER TO LEGAL ANSWERS
MATRL1:	ILDB T4,T2		;GET NEXT CHAR OF HIS ANSWER
	JUMPE T4,MATRL3		;DONE IF A ZERO CHARACTER
	CAIE T4," "		;END OF FIRST WORD?
	CAIN T4,.CHLFD		;END OF LINE?
	JRST MATRL3		;YES
	ILDB CX,T3		;NO, GET NEXT CHAR OF THIS ANSWER
	CAIN CX,(T4)		;MATCH?
	JRST MATRL2		;YES, KEEP ON GOINT
	AOBJN T1,MATRLA		;NO, TRY NEXT TABLE ENTRY
	RET			;NO MATCH -  NON SKIP RETURN
MATRL2:	TLNN T3,760000		;END OF THIS TABLE ENTRY?
	RETSKP			;YES, SKIP RETURN
	JRST MATRL1		;NO, LOOK AT NEXT CHARACTER HE TYPED
MATRL3:	CAME T2,[POINT 7,RDDBFR,6] ;ANYTHING BEFORE THE END-OF-LINE?
	RETSKP			;YES, TAKE MATCH-RETURN
	RET			;NO, NON-MATCH

RLATAB:	ASCIZ	/OPR/
	ASCIZ	/PARIT/
	ASCIZ	/POWER/
	ASCIZ	/STATI/
	ASCIZ	/HARDW/
	ASCIZ	/HALT/
	ASCIZ	/HUNG/
	ASCIZ	/PM/
	ASCIZ	/CM/
	ASCIZ	/SA/
	ASCIZ	/NEW/
	ASCIZ	/SCHED/
	ASCIZ	/OTHER/
RLALEN==.-RLATAB
DEFMSG:	ASCIZ /OTHER - Question timeout
/
LOGMSG:	ASCIZ #
The following is a list of valid responses.  Any comment (up to 72
characters) may be appended to a response.  In case more than one
response is appropriate, choose the earliest one in the list.

Previous system problem:	Different monitor wanted:
	OPR				NEW
	PARITY				SCHED
	POWER
	STATIC			Operator doesn't know or not in list:
	HARDWARE			OTHER
	HALT
	HUNG			If Operator doesn't answer within 60 seconds:
	PM				OTHER - Question timeout
	CM
	SA

#

;POINTER TABLE TO BUILD RELOAD ENTRY

WHYIT:	SEBPTR 0,SBTEVC,SEC%RL	;EVENT CODE (IMMEDIATE)
	SEBPTR RL%SVN,SBTSTR,SVN ;SYSTEM NAME
	SEBPTR RL%STD,SBTWD,SYSTAD ;BUILD TAD
	SEBPTR RL%VER,SBTWD,[EXP SVNM] ;SYSTEM VERSION NUMBER
	SEBPTR RL%SER,SBTWD,APRSER ;APR SERIAL NUMBER
NWHYIT==.-WHYIT
	SUBTTL Job 0 Forks -- Get Time and Date for Startup (RDDTAD)

;LOCAL ROUTINE TO READ TAD FROM CTY
;	CALL RDDTAD
; RETURN +1 ALWAYS, 2/ TAD

RDDGTD:	STKVAR <<RDDBFR,20>>
RDDGT1:	HRROI 1,RDDBFR
	MOVE 2,[RD%BRK+RD%BEL+RD%RAI+20*5]
	MOVEI 3,0
	RDTTY			;READ LINE FROM CTY
	 JRST RDDGT2		;FAILED, REPROMPT
	TXNN 2,RD%BTM		;BREAK CHAR TERMINATED INPUT?
	JRST RDDGT2		;NO, GARBAGE INPUT
	HRROI 1,RDDBFR
	MOVEI 2,0
	IDTIM			;CONVERT STRING TO TAD
	 JRST RDDGT2		;INVALID, REPROMPT
	RET			;OK, RETURN IT

RDDGT2:	TMSG <
? Invalid, please try again in form MMM-DD-YY HHMM: >
	JRST RDDGT1		;TRY AGAIN
	SUBTTL Job 0 Forks -- Start Next Special job (DONSJ) 

;EACH SPECIAL JOB CALLS THIS TO DETACH AND START THE NEXT ONE

DONSJ:	CALL LOGONM		;RECORD START OF CURRENT JOB ON LOGGING TERMINAL
	MOVE 4,CTRLTT		;SAVE THIS JOB'S CONTROLLING TERMINAL
	DTACH			;DETACH THE CURRENT JOB
	MOVE 1,JB0TT
	HRRM 1,PRIMRY		;USE JOB 0 TTY FOR ANY OUTPUT
	MOVE 1,JOBNO		;GET CURRENT JOB NUMBER
	CAIL 1,NSPECJ-1		;MORE SPECIAL JOBS TO DO?
	JRST [	MOVX T1,SF%PTY!SF%CTY ;NO. ALLOW CTY AND PTY LOGINS
		IORM T1,FACTSW
		RET]		; AND DON'T CREATE ANOTHER JOB
	MOVE 2,4		;YES. GET LINE NUMBER FOR CALL
	CALLRET SPCSTJ		;START ANOTHER JOB ON SAME TTY

SPCSTJ:	NOSKED
	PUSH P,T2		;SAVE LINE NUMBER
	CALL STADYN		;GET ADDRESS OF DYNAMIC DATA
	 SKIPA			;NOT FULLY ACTIVE
	JRST [	POP P,2
		OKSKED
		RET]
	JUMPG T2,SPCST1		;IF TEMPORARILY ACTIVE, WAIT
	POP P,2			;GET LINE NUMBER BACK
	SETOM TTACTL(T2)	;INDICATE JOB STARTING
	MOVEI 1,JOBSRT		;REQUEST JOB STARTUP FROM SCHED
	HRL 1,2
	CALL SCDRQ7
	OKSKED
	RET

;LINE IS TEMPORARILY IN USE. WAIT UNTIL IT'S AVAILABLE

SPCST1:	POP P,1			;RESTORE LINE NUMBER
	OKSKED
	HRLZS T1		;T1/ (LINE NUMBER,,ROUTINE)
	HRRI T1,TSACT1		;ROUTINE TO WAIT FOR LINE
	PUSH P,T2
	MOVSI T2,FHV1		;LOW BLOCK PRIORITY
	HDISMS
	POP P,T2
	JRST SPCSTJ
	SUBTTL Job 0 Forks -- Scheduler Tests

;MAXIMUM CHECK PERIOD - USED TO SET SCHEDULER ALARM

	RESCD

CHKPER::^D<1*60000>		;1 MINUTE - CHKR ALARM PERIOD
DDPPER::^D<1*60000>		;1 MINUTE - DDMP ALARM PERIOD

JB0TST:	SKIPE JB0FLG		;EXPLICIT REQUEST?
	JRST 1(4)		;YES, WAKEUP
	JRST BLOCKT		;NO, GO TEST TIME

;Test routine for DDMP

DDPWAT:	MOVE T1,TODCLK		;Get now
	SKIPN DDCFSF		;Force for CFS?
	CAML T1,DDTIME		;Time to do it?
	JRST 1(4)		;yes
	SKIPN DDPDUE		;ddmp force?
	JRST 0(4)		;no
	JRST 1(4)		;yes

;TEST ROUTINE TO CIFORK

CIWAIT:	SKIPE CIFRKF		;ANYTHING TO DO?
	JRST 1(4)		;Yes
	JRST 0(4)		;No
	SWAPCD

NR UMSGTM,1			;TIME OF NEXT USER MESSAGES
NR MTCHNG,1			;FLAG FOR MTA STATUS CHANGE
	SUBTTL Job 0 Forks -- Fork Error Catcher

;JB0INT - HERE WHEN INTERRUPT OCCURS IN FORK 0

;THIS ROUTINE IS POINTED TO BY MONBK. THE SCHEDULER TRANSFERS
;CONTROL TO HERE WHEN AN INTERRUPT OCCURS ON CHANNEL 34 OR 35 IN
;FORK 0. JB0XFR CONTAINS THE ROUTINE TO WHICH THIS CODE TRANSFERS
;AFTER CLEANING THINGS UP

JB0INT:	BUG.(CHK,JB0INX,MEXEC,SOFT,<Unexpected interrupt in job 0 during initialization>,<<ITFPC,PC>,<JB0XFR,NEWPC>,<LSTERR,LSTERR>>,<

Cause:	An unexpected error has occurred in Job 0 which results
	in control being transferred to the default error handler.
	This has happened during job 0 initialization.  The error handler 
	will attempt to reset the context and continue at the specified 
	error address, however some system resources may be hung as a result 
	of locks not being cleared.  

Action:	If this BUG persists, make it dumpable and submit an SPR with the
	dump and a copy of MONITR.EXE.  If possible, include any known
	method for reproducing the problem and/or the state of the system
	at the time the BUG was observed.  In the dump, the stack
	can be examined to determine what was in progress when
	the error occurred.

Data:	PPC - PC at which error occurred
	NEWPC - Address to which control will be transferred after cleanup
	LSTERR - Last error code in this fork
>)
	SETZM NSKED		;BE OKSKED
	SETZM CRSKED		;BE NOT 'CRITICAL SECTION'
	MOVX CX,USRCTX
	MOVEM CX,FFL		;RESET CONTEXT
	MCENTR
	MOVE T1,[XWD MSEC1,J0EMER] ;IN CASE OF EMERGENCY
	CALL MONBKX
	CALL CLRINT		;CLEAR THE INTERRUPT SYSTEM
	MOVE T1,FORKX		;T1/ FORK NUMBER
	SETZM T2		;T2/ ALL INTERRUPT LEVELS
	CALL JSBSTF		;CLEAN THE JSB STACK
	MOVE T1,FORKX		;T1/ FORK NUMBER
	SETZM T2		;T2/ ALL LEVELS
	CALL GOKFRE		;CLEAN UP GETOK QUEUES (SHOULDN'T HAVE ANY)
	MOVE T1,[XWD MSEC1,JB0INT] ;BACK TO HERE IF ANOTHER INTERRUPT
	CALL MONBKX
	MOVE T1,JB0XFR		;SEE WHERE WE ARE TO GO NEXT
	JRST 0(T1)		; AND GO THERE
;HERE WHEN AN ERROR OCCURRED WHILE IN JB0INT. GIVE UP.

J0EMER:	BUG.(HLT,STRTER,MEXEC,SOFT,<Fatal error while processing previous startup error>,,<

Cause:	When a software channel 34 or 35 interrupt happens on fork
	0, the monitor transfers control to the routine specified in
	MONBK.  This address will often be the starting address of
	JB0INT.  JB0INT handles errors in fork 0.  While JB0INT is doing its
	error recovery, it sets MONBK to J0EMER, so that this STRTER BUGHLT
	will occur if another error happens during JB0INT execution.
>)

;CLRINT - CLEAR THE INTERRUPT SYSTEM

CLRINT:	MOVEI 1,400000		;DEACTIVATE SOFTWARE INTERRUPT CHANNELS
	SETO 2,			; FOR THIS PROCESS

	DIC
	CALL DTIALL		;IN CASE PROGRAM TURNED ANY ON
	MOVE 2,PSIBW
	CIS			;CLEAR ALL INTERRUPTS IN PROGRESS
	RET
	SUBTTL Job 0 Forks -- Periodic Checker (CHKR)

;PERIODIC (10 SEC) CHECK OF THINGS

CHKR::	TSTMS0			;BE SURE NO SECTION 0
	SETZM JB0FLG		;CLEAR REQUEST FLAG
	MOVE 1,TODCLK
	ADD T1,CHKPER		;NOW PLUS MAX CHECK PERIOD
	MOVEM 1,CHKTIM		;LEAVE FOR SCHED TO CHECK
	SETZM CHKDUE		;RESET THE OVERDUE COUNTER
	CALL KNIJB0		;Check on the KLNI's
	CALL LLMJB0		;[7432]Check on LLMOP
;   IFN CFSCOD,<
	CALL CFTADC		;See if a TAD is around
	IFSKP.			;If so
	  STAD			;Set it
	   NOP			;
	  CALL DTTIME		;If a KL, tell the FE
	ENDIF.
	CALL CFSJ0		;And see if any background action is needed
;   >	;IFN CFSCOD
	CALL KLPRCT		;DO PERIODIC CI READ-COUNTERS
	CALL RESLCK		;LOCK OR UNLOCK RESIDENT FREE SPACE
	CALL DTEPOL		;GO SEE IF ANY DTE'S NEED ATTENTION
	CALL MNTCHK		;KEEP MULTINET RUNNING
	SKIPE DOBFRK		;[7.1253] Is there a DOB fork to watch?
	CALL DOBKSP		;[7.1253] () Yes, see if it has finished
	SKIPE DOBJB0		;[7.1081] Need to copy a dump file?
	CALL DOBSSP		;[7.1081] () Yes, run SETSPD to do that
	SKIPE MTAJB0		;MTA ON LINE INTERRUPT?
	CALL MTASSP		;YES REQUEST SETSPD
  IFE FTNSPSRV < ;[6.1]
	CALL DCNJB0		;Do DECnet periodic functions
  >
	SKIPE USGBEG		;CHECK USAGE QUEUE
	CALL USGMES		;HAVE SOMETHING - EMPTY QUEUE
	CALL CHKCKP		;CHECK ON CHECKPOINT
	CALL CHKASC		;Check for accounting shift change
	CALL CHKBGS		;CHECK IF TIME TO STORE ASCII TIME
	;...
	;...

	SKIPE A,HSYST1		;SHUTDOWN PROCESS ACTIVE?
	CAMN A,[-1]		;OR IS SYSTEM SHUTDOWN
	SKIPA			;SYSTEM SHUTDOWN OR PROCESS NOT ACTIVE
	CALL CHKHSY		;YES, CHECK IT

	SKIPE CCHEAD		;ANY CLUSTER CEASES?
	CALL CHKCLC		;YES, GO OUTPUT THEM
	CALL IMICHK		;MAKE SURE IMP INPUT Q'S EMPTIED
	CALL CHKOFN		;[7247] Check OFNS
	MOVE A,TODCLK
	CAMGE A,UMSGTM		;TIME FOR USER MESSAGES?
	JRST CHKUM1		;NO
	CALL CHKDKS		;CHECK DISK SPACE
	CALL CHKDMS		;CHECK DRUM SPACE
	CALL CHKSPT		;CHECK SPT SPACE
	MOVE A,TODCLK		;SET TIME FOR NEXT MSG
	ADD A,[^D<5*60000>]	;IN 5 MINUTES
	MOVEM A,UMSGTM
CHKUM1:
	CALL CHKMOS		;CHECK IF MEMORY DIAG NEEDS TO RUN
	MOVEI A,^D30000		;SETUP TO DISMISS FOR 30 SEC
	SKIPE B,HSYST1		;SHUTDOWN ACTIVE?
	CAMN B,[-1]		;OR SYSTEM SHUTDOWN?
	SKIPA			;NO SHUTDOWN OR ALREADY SHUTDOWN
	SKIPGE B,HSYST2		;YES, REASONABLE TIME TO WAIT?
	JRST CHKUM2		;NOT ACTIVE OR BAD TIME
	CAMLE A,B		;LESS THAN 30 SECONDS AWAY
	MOVE A,B		;YES, DISMISS UNTIL THEN
	;..
	;..
CHKUM2:	MOVE B,DDTIME		;Time for DDMP
	SUB B,TODCLK		;Relative time for DDMP
	IFG. B			;If still in the future
	 CAMLE A,B		;Will we run in time?
	 MOVE A,B		;No. So use this time instead
	ENDIF.
	CALL SETBKT		;SETUP TIME FOR DISMISS TEST
	HRRI A,JB0TST		;OR JB0FLG
	MOVSI B,FHV1		;LOW BLOCK PRIORITY
	HDISMS
	JRST CHKR
	SUBTTL Job 0 Forks -- Periodic Checker (CHKR) -- Start DOB SETSPD (DOBSSP)

;[7.1081] This routine calls SETSPD at offset 5 in entry vector to check all 
;[7.1081] dumpable structures for uncopied DUMP.EXE files. 

DOBSSP:	SKIPE DOBFRK		;[7.1253] Is there still a fork running?
	RET			;[7.1253] Yes, only run one at a time
	SETZM DOBJB0		;[7.1081] Clear request flag
	MOVX T1,GJ%OLD!GJ%PHY!GJ%SHT ;[7.1081]GTJFN Flags
	HRROI T2,SETSPD		;[7.1081] Point to program name
	MOVEI T3,5		;[7.1081] Offset 5 in entry vector
	XMOVEI T4,DOBFRK	;[7.1253] Place to save fork number
	CALL RUNDIR		;[7.1253] (T1-T4/T1) Call the program
	 JRST DOBSS0		;[7.1253] It didn't work
	HRLM T1,DOBFRK		;[7.1253] Save fork number
	RET			;[7.1253]  then return

;[7.1081] Here if couldn't get a fork for SETSPD, probably this site is running
;all of GALAXY under SYSJOB or something like that.

DOBSS0:	TMSG <
? DOB Error: Can't copy dump - > ;[7.1081] Output error prefix
	MOVX T1,.PRIOU		;[7.1081] Write it to default device
	MOVX T2,<.FHSLF,,-1>	;[7.1081] Say this fork's latest error
	ERSTR			;[7.1081] Do it
	 JFCL			;[7.1081] Ignore
	 JFCL			;[7.1081]  errors
	TMSG <
>				;[7.1081] Finish it with a CRLF
	RET			;[7.1081] Return
	SUBTTL Job 0 Forks -- Periodic Checker (CHKR) -- Kill DOB SETSPD (DOBKSP)

;[7.1253] Here with dump fork already around, see if it is still running.
;[7.1253] DOBFRK holds fork handle,,fork number (for MDDTing)
;[7.1253] Returns: +1 always

DOBKSP:	HLRZ T1,DOBFRK		;Get the fork handle for DOBFRK
	RFSTS%			;Read fork's status
	ERJMP DOBKS3		;Murder it if error
	LDB T1,[POINTR T1,RF%STS] ;Get fork status
	CAIE T1,.RFHLT		;Is it halted
	CAIN T1,.RFFPT		; or forced termination?
	JRST DOBKS3		;Yes, time for a murder
	RET			;It still must be running, let it

;Here to murder the current DOB fork.

DOBKS3:	HLRZ T1,DOBFRK		;Get the fork handle back
	KFORK%			;Kill it
	ERJMP .+1		;Punt the error
	SETZM DOBFRK		;Now no longer a fork
	RET			;Return
	SUBTTL Job 0 Forks -- Periodic Checker (CHKR) -- Magtape Online (MTASSP)

; ROUTINE TO REQUEST SETSPD FOR MAGTAPE ON LINE

MTASSP:	SETZM MTAJB0		;CLEAR REQUEST FLAG
	MOVX T1,GJ%OLD!GJ%PHY!GJ%SHT
	HRROI T2,SETSPD		;GET POINTER TO "SYSTEM:X-SETSPD.EXE"
	MOVEI T3,4		;START AT ENTRY VECTOR POSITION 4
	SETZM T4		;DO NOT RECORD FORK NUMBER
	CALL RUNDII		;RUN SETSPD AND WAIT UNTIL IT'S DONE
	 JFCL			;IGNORE FAILURE
	RET
	SUBTTL Job 0 Forks -- Periodic Checker (CHKR) -- TGHA Check (CHKMOS)

;ROUTINE CALLED BY CHKR TO SEE IF ANY ACTION NEEDED FOR THE
;MOS MEMORY DIAGNOSTIC

CHKMOS:	SKIPN T1,MOSFRK		;NOW RUNNING?
	JRST CHKMO1		;NO. SEE IF WE SHOULD RUN IT
	RFSTS			;YES. SEE WHAT IT IS DOING
	LOAD T1,RF%STS,T1	;GET ITS STATUS
	CAIE T1,.RFHLT		;HALTED?
	CAIN T1,.RFFPT		;OR ERROR?
	SKIPA T1,MOSFRK		;YES.
	RET			;NO. ALL DONE THEN
	KFORK			;KILL THE PROCESS
	SETZM MOSFRK		;NO MORE FORK HERE
	CALL MOSULE		;UNLATCH CONTROLLER NOW

;HERE IF NO FORK NOW RUNNING. SEE IF ONE NEEDED

CHKMO1:	SKIPE ERRTBL		;HAVE SOME ENTRIES TO PROCESS
	CALL RUNMOS		;YES. START THE DIAG
	RET			;DONE

;ROUTINE TO RUN THE MOS MEM DIAGNOSTIC

RUNMOS:	TDZA T3,T3		;MAIN ENTRY POINT
RUNMO1:	MOVEI T3,1		;SYS START UP ENTRY
	MOVX T1,<GJ%OLD!GJ%SHT!GJ%PHY>
	HRROI T2,[ASCIZ /SYSTEM:TGHA.EXE/] ;THE DIAG
	SETZM T4		;DO NOT RECORD FORK NUMBER
	CALL RUNDIR		;RUN TGHA
	 RET			;DIDN'T DO IT.
	MOVEM T1,MOSFRK		;SAVE FORK HANDLE FOR LATER
	RET			;AND DONE
	SUBTTL Job 0 Forks -- Periodic Checker (CHKR) -- Check Swapping Space (CHKDMS)

;Here to see if swapping space is low

CHKDMS:	MOVE 1,DRMFRE
	CAMLE 1,DRMIN0		;DRUM SPACE LOW?
	RET			;NO
	STKVAR <<MSGBBF,^D70>>
	HRROI 2,[ASCIZ /
[Caution--Swapping space low]
/]
	MOVX T3,SF%MS0
	TDNE T3,FACTSW		;WANT LEVEL 0 MESSAGES?
	CALL ALLMSG		;YES, DO IT
	HRROI T1,MSGBBF		;WHERE IT'S GOING
IFE STANSW,<
	HRROI T2,[ASCIZ /
*****Swapping space low, /]
	SETZM T3
	SOUT			;COPY IT
	MOVE 2,DRMFRE
	CALL CHKH1		;DO MORE
>;IFE STANSW
IFN STANSW,<
	SKIPE DBUGSW		;IF WE ARE STANDALONE OR DEBUGGING
	 RET			;WE DON'T WANT THIS MESSAGE ON THE CTY
	CALL TIMSMF
	FMSG < CHKDMS: Swapping space low, >
	MOVE T2,DRMFRE
	CALL PRTPGS		;PRINT FREE COUNT
>;IFN STANSW
	MOVEI T2,MSGBBF
	MOVEI T3,.QBSYS		;.QBDTY VALUE FOR SYSTEM MESSAGE
	CALLRET WROPR0		;DO IT
	ENDSV.
	SUBTTL Job 0 Forks -- Periodic Checker (CHKR) -- Check OFNs Used (CHKOFN)
	
;[7247] CHKOFN - Check the number of OFNS in system and release some if needed
;[7247] Note - Performance counters - Charge this time to BKGND/FILW?
;[7247] Tricky because low level routines can cause OKSKED/reschedule 
;[7247] Time is now charged to job 0 so this may be enough...

CHKOFN:	NOSKED			;[7247] Lock up system
	SKIPL OFNTIM		;[7247] Should we release only cached OFNS?
	IFSKP.			;[7247] Yes
	  CALL FREOFC		;[7247] Free all cached OFNS now
	   JFCL			;[7247] Don't care about this return
	  OKSKED		;[7247] 
	  RET			;[7247] 
	ENDIF.			;[7247] 
	MOVE T1,TODCLK		;[7247] Get now
	CAMLE T1,OFNTIM		;[7247] Time to do this?
	CALL FREOFG		;[7247] Yes
	 JFCL			;[7247] Ignore +1 return
	MOVEI T1,NOFN		;[7247] Get number OFNS
	SUB T1,NOF		;[7247] ... left in system
	CAIG T1,^D50		;[7247] Below threshold?
	CALL FREOFG		;[7247] Yes so try again
	 JFCL			;[7247] 
	OKSKED			;[7247] Safe to run again!
	RET			;[7247] 

CHKSPT:	MOVE 1,SPTC
	CAMGE 1,SPC1		;SPT LOW?
	RET			;NO
	STKVAR <<MSGBBF,^D70>>
	HRROI 2,[ASCIZ /
[Caution--SPT space low]
/]
	MOVE T3,FACTSW
	TXNE T3,SF%MS0		;WANT LEVEL 0 MESSAGES?
	CALL ALLMSG		;YES, DO IT
	HRROI T1,MSGBBF
	HRROI T2,[ASCIZ /
*****SPT space low, /]
	SETZM T3
	SOUT			;COPY STRING
	MOVN 2,[NOFN-SSPT]
	SUB 2,SPTC		;SPACE LEFT
	CALL CHKH1		;DO REST OF MESSAGE
	MOVEI T2,MSGBBF		;GET START
	MOVEI T3,.QBSYS		;.QBDTY VALUE FOR SYSTEM MESSAGE
	CALLRET WROPR0		;AND WRITE IT
	ENDSV.
	SUBTTL Job 0 Forks -- Periodic Checker (CHKR) -- Check System Structure Space (CHKDKS)

;CHECK DSK SPACE

CHKDKS:	SKIPGE T1,EXPFRK	;EXPUNGE FORK RUNNING?
	RET			;YES - EXIT QUIETLY
	JUMPE T1,CKDKS1		;NO - EXISTS?
	SETZM EXPFRK		;YES - KILL IT
	KFORK			;...
CKDKS1:	MOVEI T1,PSNUM		;[7.1112]Use boot structure
	CALL GSTRPG		;GET COUNT OF USED AND FREE PAGES ON STRUCTURE
	MOVE T1,T2		;GET FREE COUNT
	SUB 1,SYSSPC		;LESS 'BUFFER'
	CAILE 1,SYWRND		;LOW?
	RET			;NO
	STKVAR <<MSGBBF,^D70>,SAVSIZ>
	MOVEM T2,SAVSIZ
	HRROI 2,[ASCIZ /
[Caution--Disk space low on system structure]
/]
	MOVE T3,FACTSW
	TXNE T3,SF%MS0		;WANT LEVEL 0 MESSAGES?
	CALL ALLMSG		;YES, DO IT
	SKIPN T1,EXPTIM		;ENOUGH TIME SINCE LAST EXPUNGE?
	MOVX T1,<EXWTIM*^D60000> ;DONT DO EXPUNGES IN FIRST n MIN
	CAMG T1,TODCLK
	CALL EXPALL		;YES, DO EXPUNGE *
	HRROI T1,MSGBBF		;ADDRESS OF BUFFER
IFE STANSW,<
	HRROI T2,[ASCIZ /
*****Disk space low on system structure, /]
	SETZM T3
	SOUT
	MOVE T2,SAVSIZ		;RECOVER FREE SPACE
	CALL CHKH1
>;IFE STANSW
IFN STANSW,<
	CALL TIMSMF
	FMSG < CHKDKS: Disk space low on system structure, >
	MOVE T2,SAVSIZ		;RESTORE COUNT OF FREE PAGES
PRTPGS:	CALL TTDECP		;OUTPUT IN DECIMAL
	FMSG < pages remaining
>
>;IFN STANSW
	MOVEI T2,MSGBBF		;START OF MESSAGE
	MOVEI T3,.QBSYS		;.QBDTY VALUE FOR SYSTEM MESSAGE
	CALLRET WROPR0		;DO IT
;ROUTINE TO DO EXPUNGE * WHEN DISK SPACE LOW
;START FORK AND MARK IT RUNNING
;	CALL EXPALL
;RETURNS +1 ALWAYS

NR EXPTIM,1		;TIME OF LAST EXPUNGE PLUS MIN INTERVAL
NR EXPFRK,1		;        0 := NO EXPUNGE FORK
			; -1,,FRKH := FORK RUNNING
			;  0,,FRKH := EXPUNGE DONE

EXPALL:	MOVX T1,CR%CAP		;PASS CAPABILITIES DOWN
	CFORK			;CREATE FORK
	 BUG.(HLT,EXPAFK,MEXEC,SOFT,<EXPALL - Job 0 CFORK failed>,,<

Cause:	This will happen if the CFORK JSYS fails to create a fork
	for doing the system-wide expunge of structure BS:. This could most
	likely happen if all the fork slots are used up.
>)				;[7.1112]
	HRROM T1,EXPFRK		;MARK FORK RUNNING
	MOVE T2,[MSEC1,,EXPAL0]	;START INFERIOR
	MSFRK			; IN MONITOR MODE
	RET			;RETURN (WAIT TILL DONE)

;EXPUNGE FORK STARTS HERE

EXPAL0:	MOVX T1,USRCTX	;SET FUNNY JSYS CONTEXT
	MOVEM T1,FFL
	SETZM FPC		;SET PC
	MCENTR
	CALL EXPAL1		;AWAY WE GO
	HRRZS EXPFRK		;SAY WE ARE DONE
	HALTF			;AND STOP
EXPAL1:	MOVX T2,SF%CDE!SF%BTE
	TDNE T2,FACTSW		;ANY BIT TABLE ERRORS?
	RET			;YES. DON'T EXPUNGE
IFN STANSW,<
	HRROI T2,[ASCIZ /
[Deleted files will be expunged from system structure in 5 minutes.]
/]
	MOVE T3,FACTSW
	TXNE T3,SF%MS1		;WANT LEVEL 1 MESSAGES?
	 CALL ALLMSG
	MOVE T1,[<5*^D60000>-^D30000]	;5 MIN. LESS 30 SECONDS
	DISMS%			;WAIT FOR SOMETHING TO HAPPEN
	SETZ T1,		;HAVE WE FREED ANY PAGES?
	CALL GSTRPG		;GET SPACE ON PRIMARY STRUCTURE
	SUB T2,SYSSPC		;LESS BUFFER
	CAMG T2,SYSSPC		;LOW STILL?
	IFSKP.
	  HRROI T2,[ASCIZ/
[Systemwide expunge postponed]
/]				;NO, WE NEEDN'T UNDERGO THE ORDEAL!!
	  MOVE T3,FACTSW
	  TXNE T3,SF%MS1	;WANT LEVEL 1 MESSAGES?
	   CALL ALLMSG
	  RET
	ENDIF.
>;IFN STANSW
	HRROI T2,[ASCIZ /
[Deleted files will be expunged from system structure in 30 seconds]
/]
	MOVE T3,FACTSW
	TXNE T3,SF%MS1		;WANT LEVEL 1 MESSAGES?
	CALL ALLMSG
	MOVEI T1,^D30000
	DISMS			;GIVE USERS TIME TO UNDELETE
	MOVX T1,RC%AWL		;ALLOW WILD CARDS
	HRROI T2,[ASCIZ "BS:<*>"] ;[7.1112]Clean up Boot Structure
	RCDIR			;GET FIRST DIRECTORY NUMBER
	 ERJMP [BUG.(CHK,EXPRCD,MEXEC,HARD,<EXPALL - RCDIR failure>,,<

Cause:	RCDIR% failed to translate the first directory of BS:<*> to a
	directory number in routine EXPALL.

Action:	The system-wide expunge of PS: has not been done.  There may be
	hardware or directory structure problems with the boot structure.
        If this BUG persists, make it dumpable and submit an SPR with the
	dump and a copy of MONITR.EXE.  If possible, include any known
	method for reproducing the problem and/or the state of the system
	at the time the BUG was observed.
>)				;[7.1112]
		JRST EXPAL3]	;WE TRIED
EXPAL2:	SETZ T1,		;NOTHING SPECIAL
	MOVE T2,T3		;PUT DIRECTORY NUMBER IN RIGHT PLACE
	DELDF			;EXPUNGE
	 ERJMP .+1		;IGNORE FAILURES
	MOVX T1,RC%STP!RC%AWL	;STEP TO NEXT
	MOVE T3,T2		;WHERE WE LEFT OFF
	HRROI T2,[ASCIZ "BS:<*>"] ;[7.1112]WHERE WE STARTED
	RCDIR			;...
	 ERJMP EXPAL3		;QUIT ON FAILURE
	TXNN T1,RC%NMD		;DONE?
	JRST EXPAL2		;NO - KEEP GOING

EXPAL3:	MOVX T1,<EXWTIM*^D60000>	;DONE, SET NEXT POSSIBLE TIME
	ADD T1,TODCLK
	MOVEM T1,EXPTIM
	HRROI T2,[ASCIZ /
[System structure expunge completed]
/]
	MOVE T3,FACTSW
	TXNE T3,SF%MS1		;WANT LEVEL 1 MESSAGES?
	CALL ALLMSG		;NOTIFY USERS
	RET			;DONE
	SUBTTL Job 0 Forks -- Periodic Checker (CHKR) -- Utility Routines

;UTILITY NUMBER PRINTERS
;DECIMAL PRINT FOR LESS THAN 18 BIT NUMBERS
;OCTAL PRINT FOR MORE THAN 18 BIT NUMBERS DOES DDT HALFWORD FORMAT.

;A/ BYTE POINTER, IF TTDECP CALLED
;B/ NUMBER TO PRINT
;	CALL TTXXXP	;XXX=(DEC,OCT)
;NUMBER PRINTED TO PRIMARY OUTPUT

TTDECP:	SKIPA C,[^D10]		;DECIMAL
TTOCTP:	MOVEI C,^D8		;IN OCTAL
	TLNN B,-1		;LH NON-0?
	JRST TTOCT1		;NO, SIMPLE PRINT
	PUSH P,B		;SAVE DATA
	HLRZ B,B		;PRINT LH
	NOUT
	 JFCL
	MOVEI B,","		;PRINT ,,
	IDPB B,A
	IDPB B,A
	POP P,B			;RECOVER DATA
	HRRZ B,B
TTOCT1:	NOUT			;PRINT RH
	 JFCL
	RET
;Here to put number in message and provide time stamp.
;	T1/ byte pointer to use

CHKH1:	CALL TTDECP		;OUTPUT DECIMAL
	MOVEI 2," "
	IDPB T2,T1		;PUNCTUATE
	PUSH P,T1		;SAVE POINTER
	CALL LGTAD		;CURRENT TIME AND DATE
	MOVE T2,T1
	POP P,T1
	SETZM T3
	IFG. T2
	 ODTIM			;INCLUDE TAD WITH MESSAGE
	ENDIF.
	HRROI T2,CRLF		;[7.1119] Point to crlf
	SOUT			;MAKE IT PRETTY
	RET
IFN STANSW,<
;TIMSMP - ROUTINE TO OUTPUT A SYSTEM TIMESTAMP FOR CTY LOG MESSAGES
;ENTER AT TIMSFM WITH T1/ DESTINATION

TIMSMP::MOVX T1,.PRIOU		;DEFAULT DESTINATION TO THE CTY
TIMSMF:	PUSH P,T1		;PRESERVE DESTINATION POINTER
	MOVX T1,.PRIOU
	RFPOS%			;SEE WHERE CARRIAGE IS NOW
	POP P,T1		;RESTORE DESTINATION POINTER
	IFXN. T2,.RHALF		;OUTPUT CRLF IF NOT AT LEFT MARGIN
	  FMSG <
>				;SEND A CRLF TO THE BUFFER
	ENDIF.
	SETO T2,		;TIME NOW
	SETZ T3,		;NORMAL FORMATTING OPTIONS
	ODTIM%
	 ERJMP .+1
	RET
>;IFN STANSW
	SUBTTL Mini-EXEC

;'MINI-EXEC' - SIMPLE COMMAND INTERPRETER FOR SPECIAL FUNCTIONS

	SWAPCD

EXEC2:	MOVE T1,JOBBIT
	IFXN. T1,LOGIOB		;LOGIN OR OUT?
	  BUG.(CHK,EXILGO,MEXEC,SOFT,<EXECI - Interrupt during login or logout>,,<

Cause:	Control has passed to the mini-exec because the top fork hit a
	terminating condition or monitor interrupt.  The top fork EXEC may
	have been wiped out.  In addition, the job was trying to log in or
	out.  The fork is put into an infinite wait state since any other 
	action might lead to further itraps, interrupts, looping, etc.

Action:	If this BUG persists, make it dumpable and submit an SPR with the
	dump and a copy of MONITR.EXE.  If possible, include any known
	method for reproducing the problem and/or the state of the system
	at the time the BUG was observed.
>)
	  WAIT%			;YES, SOME KIND OF DISASTER. GO AWAY QUIETLY.
	ENDIF.
	MOVEI 1,100		;ESTABLISH CORRECT TTY MODES
	MOVE 2,NORMTF
	SFMOD
	MOVE 2,TTICB1
	MOVE 3,TTICB2
	SFCOC
	CALL DTIALL		;DISABLE ALL TERMINAL INTERRUPTS
	MOVE 1,[XWD 20,^D34]	;T1/ CTRL/P ON CHANNEL 34
	ATI			;ASSIGN CONTROL-P FOR INTERRUPTS
	MOVE 1,[MSEC1,,EXECI]	;SETUP TO GET INTERRUPTS IN MON
	CALL MONBKX
	MOVE 2,JOBNO
	HRRZ 1,JOBDIR(2)
	IFE. T1
	  SETZM CAPMSK		;IF NOT LOGGED, FLUSH ALL CAPS
	  SETZM CAPENB
	  MOVE 3,CTRLTT
	  CAME 3,CTYLNO		;ALLOW MINI-EXEC ONLY ON CTY
	ANSKP.
	  MOVE T3,SPJCAP	;CTY, NOT LOGGED IN, GIVE ALL CAPABILITIES
	  MOVEM T3,CAPENB
	  MOVEM T3,CAPMSK
	  MOVEI T3,OPERDN	;[7.1112]Get directory number of <OPERATOR>
	  MOVEM T3,JOBDIR(T2) 	;[7.1112]INDICATE LOGGED IN AS <OPERATOR>
	  STOR T3,JSDIR		;[7.1112]Save as connected directory
	  SETZRO JSCDF		;[7.1112]No string in JSB
	  MOVE T3,LGSIDX	;[7.1112]Get number of Login Structure
	  MOVE T3,STRTAB(T3)	;[7.1112]Get SDB address
	  LOAD T3,STRUC,(T3)	;[7.1112]GET ITS UNIQUE STRUCTURE CODE
	  STOR T3,JSUC		;[7.1112]SAVE AS CONNECTED STRUCTURE CODE
	  MOVE T3,[[3
	  	 ASCIZ "OPERATOR"],,USRNAM] ;[7.1112]
	  BLT T3,USRNAM+2	;[7.1112]SET DEFAULT USER NAME TO OPERATOR
	ENDIF.
	JN JBMX,,EXECT0		;IF BEEN IN MX BEFORE, DONT CHECK CAPS
	MOVE T1,CAPENB		;[7.1112]LOOK AT CAPS, ALLOW MINI-EXEC
	TRNE T1,SC%WHL		;[7.1112]ONLY IFWHEEL
	IFSKP.
	  SKIPE FORKN		;OTHERWISE,
	  HALTF			;HALTF IF BELOW EXEC
	  SETONE JSFLO		;REMEMBER THE FORCED LOGOUT
	  JRST LOGO		;LOGOUT IF TOP FORK
	ENDIF.
	SETONE JBMX		;REMEMBER THAT JOB WAS IN MINI-EXEC
	; ..
	SUBTTL Mini-EXEC -- Command Dispatch
;MINI-EXEC...

EXECT0:	TMSG (MX>)
EXECT1:	PBIN			;GET USER INPUT
	CAIN T1,.CHCRT		;FLUSH CR
	JRST EXECT1
	CAIL 1,"A"+40		;LC CHAR?
	CAILE 1,"Z"+40
	SKIPA			;NO
	SUBI 1,40		;YES, CONVERT
	CAIN T1,.CHLFD		;IGNORE BLANK LINE
	JRST EXECT0
	MOVSI 4,-NXCMD		;SCAN COMMAND TABLE
EXECT2:	HLRZ 2,XCMD(4)		;GET KEY LETTER FOR THIS COMMAND
	CAMN 1,2		;SAME AS JUST TYPED?
	JRST [	HRRZ 2,XCMD(4)	;YES, GET DISPATCH ADDRESS
		JRST 0(2)]	;GO TO IT
	AOBJN 4,EXECT2		;TRY ALL COMMANDS
	JRST EXERR		;NOT FOUND, INDICATE ERROR

;MINI-EXEC COMMANDS

DEFINE CM (NAM,LOC)<
	XWD "NAM",LOC>

XCMD:
   REPEAT 0,<
	CM B,EBLT		;BLT SWP MON
   >
	CM D,EDMP		;DUMP ON FILE
	CM E,GEX		;EXEC
	CM G,EGET		;GET FILE
	CM J,EJMP		;JUMP TO ADDRESS
	CM R,EREST		;RESET
	CM S,EST		;START
	CM <^>,MRETN		;DO MRETN
	CM </>,TODDT		;GO TO MDDT
NXCMD==.-XCMD
	SUBTTL Mini-EXEC -- BLT Swappable Monitor (Historical)

;'BLT SWP MON' - BLT SWAPPABLE CODE TO USER SPACE.  SHOULD DO RESET FIRST,
;THEN DUMP ON DTA--

   REPEAT 0,<
EBLT:	TMSG <LT SWP MON>
	CALL OKGO
	MOVE 2,SWCEND		;LST PAGE
	LSH 2,^D9
	MOVE T1,[NRCOD,,NRCOD]
	XBLTMU [BLT 1,777(2)]
	JRST EXEC2
   >				;END OF REPEAT 0
	SUBTTL Mini-EXEC -- Reset Command
;'RESET'

EREST:	TMSG <ESET>
	CALL OKGO
	CALL DRESET		;DO THE RESET
	JRST EXEC2

;DRESET IS COMMON ROUTINE USED BY SEVERAL COMMANDS TO DO A RESET

DRESET:	MOVEI 1,-4
	KFORK			;KILL ALL FORKS
	MOVNI 1,1
	MOVSI 2,400000
	MOVE 3,[1B0+1000]	;CLEAR ALL PAGES FROM USER MAP
	PMAP
	MOVNI 1,1		;CLOSE ALL FILES
	CLOSF
	JFCL
	RET

;OKGO - ROUTINE TO LOOK FOR CONFIRMATION AFTER MINI-EXEC HAS
;TYPED THE COMPLETION OF THE COMMAND.

;	CALL OKGO

;RETURNS +1: CONFIRMATION FOUND
;IF NO CONFIRMATION WAS FOUND, GOES TO ERROR ROUTINE

OKGO:	PBIN
	CAIN T1,.CHCRT		;FLUSH CR
	JRST OKGO
	CAIN T1,.CHLFD		;CRLF MEANS GO
	RET
NODD1:	POP P,1			;ANYTHING ELSE MEANS ABORT
	JRST EXERR
	SUBTTL Mini-EXEC -- Exec Command

;'EXEC'

GEX:	TMSG <XEC>
	CALL OKGO		;CONFIRM
	CALL DRESET		;CLEAR PREVIOUS PROGRAM TO GUARANTEE CINITF IN EXEC IS CLEAR


;HERE TO GET A NEW COPY OF THE EXEC. REACHED FROM MINI-EXEC 'EXEC'
;COMMAND OR WHEN A NEW JOB IS BEING CREATED.  IF FILE EXISTS,
;GOES TO START IT. IF NOT, PRINTS MESSAGE AND GOES TO MINI-EXEC

STEX:	MOVSI 1,(GJ%OLD!GJ%PHY!GJ%SHT)	;OLD FILE+SHORT FORM
	HRROI 2,[ASCIZ /DEFAULT-EXEC:/]
	GTJFN
STEXF:	JRST [	SKIPE CRJFLG	;IS THIS A CRJOB FAILURE?
		JRST CRJMEX	;YES. GO GIVE FAIL CODE
		TMSG <NO EXEC>
		JRST EXCRR]
	HRLI 1,.FHSLF
	GET
	ERJMP STEXF		;CATCH FAILURE OF GET
	SKIPN CRJFLG		;CREATED JOB?
	JRST GEX1
	RET			;RETURN TO FINISH CRJOB STUFF

CRJMEX:	MOVEI T1,CRJBX2		;PREVENT CRJOB GETTING INTO MINIEXEC
	CALL SETANS		;GO SETUP CRJANS
	JRST LOGO		;AND FLUSH OUT THIS JOB.
	SUBTTL Mini-EXEC -- Jump Command

;'JUMP TO ADDRESS' - JUMP TO USER ADDRESS

EJMP:	TMSG <UMP TO >
	MOVEI 1,100
	MOVEI 3,^D8		;GET OCTAL ADDRESS
	NIN
	 JRST EXERR
	HRRZM 2,-1(P)		;SAVE ADDRESS
	BKJFN			;BACKUP TO READ TERMINATOR
	 JFCL
	CALL OKGO
	JRST MRETN		;RETURN TO USER ADDRESS ON STACK
	SUBTTL Mini-EXEC -- Get/Start/Dump Commands

;'GET FILE'

EGET:	TMSG <ET FILE >
	MOVSI 1,(1B2+1B4+1B16+1B17) ;OLD FILE,CONFIRM,IFOF,SHORT
	MOVE 2,[XWD 100,101]
	GTJFN
	 JRST EXERR
	HRLI 1,400000		;THIS FORK
	GET
	 ERJMP EXERR
	JRST EXEC2

;'START' - STARTS PROGRAM GOTTEN VIA 'GET'

EST:	TMSG <TART>
	CALL OKGO
GEX1:	MOVE 1,EVADDR
	JUMPN 1,.+2
	UMOVE 1,120		;USE JOBSA
	MOVEM 1,-1(P)
	JRST MRETN

;'DUMP ON FILE'

EDMP:	TMSG <UMP ON FILE >
	MOVSI 1,(1B0+1B3+1B4+3B17) ;NEW V,PNT O/N,CONFRM,IFOF,SHRT
	MOVE 2,[XWD 100,101]
	GTJFN
	JRST EXERR
	HRLI 1,400000		;THIS FORK
	MOVE 2,[XWD -1000,520000] ;SAVE ALL ADDRESS SPACE
	SETZ 3,
	SSAVE
	JRST EXEC2
	SUBTTL Mini-EXEC -- Utility Routines

;ERROR CONDITION - PRINT A QUESTION MARK AND GO BACK TO START OF
;MINI-EXEC

EXERR:	TMSG <  ?>
	MOVEI 1,100
	CFIBF			;CLEAR INPUT BUFFER

;PRINT CARRIAGE RETURN/LINE FEED

EXCRR:	SKIPE CRJFLG		;IS THIS A CRJOB?
	JRST CRJMEX		;YES. GET OUT OF MINIEXEC.
	TMSG <
>
	JRST EXEC2

EXCRRW:	TMSG <
>
	JRST EXEC2
	SUBTTL Mini-EXEC -- Handle Interrupts (EXECI)

;PSI TRAPPED TO HERE

EXECI::	XCT FRKNOP		;NOP UNLESS MDDT BPT SET
	EXCH 1,ITFFL		;SAVE 1, GET TRAP FL
	TLNN 1,(UMODF)		;USER?
	JRST EXECI1		;NO
	MOVEM 1,FFL		;SET FLAGS
	MOVE 1,ITFPC		;SET PC
	MOVEM 1,FPC		;YES, ENTER MONITOR AT THAT LOC
	MOVE 1,ITFFL		;RESTORE AC1
EXECI2:	MCENTR
	SETOM PRIMRY
	SKIPE CRJFLG		;IS THIS A CRJOB?
	JRST CRJMEX		;YES. GET OUT OF MINIEXEC.
	MOVEI 1,100
	CFIBF			;CLEAR INPUT BUFFER
	 ERJMP	EXECI4		;error while attempting to LOG IN/OUT
	CALL CLRINT		;CLEAR THE SOFTWARE INTERRUPT SYSTEM
	TRNN 2,2		;CHANNEL 34?
	JRST EXECI3
	MOVEI 1,-4
	FFORK			;FREEZE FORKS
	MOVEI 1,101
	CFOBF			;CLEAR OUTPUT BUFFER
	 ERJMP	EXECI4		;error while attempting to LOG IN/OUT
	TMSG <
Abort
>
	JRST EXEC2
	;...
	;...

EXECI1:	MOVE P,UPP		;RESTORE TOP OF PDL
	MOVE 2,1(P)		;GET USER PC
	MOVEM 2,FPC		;STORE PC
	MOVX T1,USRCTX		;SET USER MODE FLAGS WORD
	MOVEM 1,FFL
	JRST EXECI2

EXECI3:	TMSG <
Interrupt at >
	MOVEI 1,101
	HRRZ 2,UPP
	MOVE 2,1(2)		;GET TOP PC
	MOVEI 3,10		;RADIX
	NOUT			;PRINT ADDRESS
	 JFCL
	JRST EXCRRW		;TO MINI-EXEC IF SC%WHL

EXECI4:	MOVE T1,JOBNO		;get current job number
	HLRZ T1,JOBPT(T1)	;get controlling TTY:
	MOVE T2,LSTERR		;get last error this process
	BUG.(INF,LGFAIL,MEXEC,SOFT,<LGOUT or LOGIN JSYS failed>,<<T1,JOBPT>,<T2,LSTERR>>,<

Cause:	An attempt to log in/out a job has failed when it should have succeded.
	The most likely cause of this is terminals that have been TTYSTPed,
	then a LGOUT or LOGIN JSYS was attemped.  An attempt to detach the
	terminal, then logout the job is made.  If either of these fail,
	the job is put in a permanent wait state.

Action:	If this BUG persists, make it dumpable and submit an SPR with the
	dump and a copy of MONITR.EXE.  If possible, include any known
	method for reproducing the problem and/or the state of the system
	at the time the BUG was observed.

Data:	JOBPT - The terminal number
	LSTERR - The reason of the failure
>,,<DB%NND>)			;[7.1210] 
	DTACH			;attempt to detach myself
	 ERJMP	.+1		;ignore errors
	SETOM	T1		;me
	LGOUT			;logout myself
	 ERJMP	.+1		;ignore errors
	WAIT			;can't log myself out, go to sleep
	 ERJMP	.+1		;ignore errors
	JRST	.-2		;try to sleep again.
	SUBTTL BUGxxx Processing

;ROUTINE CALLED BY JOB 0 TO FINISH LOADING UP SYSERR BLOCK
;  FOR BUGHLT'S AND BUGCHK'S
;ACCEPTS IN T1/	ADDRESS OF SYSERR BLOCK
;RETURNS +1:	ALWAYS

LOGBUG::SAVEAC <Q1,Q2,P1>
	TRVAR <BUGSP,BUGPNM,BUGTAD,<LOGBUF,^D70>,<QBLK,4>>
	MOVEM T1,Q1		;SAVE POINTER TO SYSERR BLOCK
	HRROI T1,LOGBUF		;POINTER TO BLOCK
	SKIPN SAVTRE		;SAVING TREES?
	IFSKP.
IFE STANSW,<
	   CALL SLOGTM		;YES, OUTPUT THE TIME
	   FMSG < ***BUG>
	   CALL LOGNAM		;OUTPUT THE BUG NAME
	   FMSG <*** >
>;IFE STANSW
IFN STANSW,<
	   CALL TIMSMF		;PRINT TIME STAMP
	   CALL LOGNAM		;PRINT " BUGINF: FOOBAR"
	   FMSG < - >		;PRETTY PRINTING
>;IFN STANSW
	ELSE.
	   FMSG <
********************
*BUG>
	   CALL LOGNAM		;OUTPUT THE BUG NAME
	   CALL RLOGTM		;OUTPUT THE DATE AND TIME
	   FMSG <
*>
	ENDIF.
	SETZB T2,BUGSP		;CLEAR POINTERS
  IFN FTNSPSRV,< ;[6.0]
	MOVE Q2,BUGTP		;ADDRESS OF BUG POINTERS
	MOVE P1,BUGTL		;LENGTH OF TABLE
      DO.
	SOJL P1,[HRROI T2,[ASCIZ/Message not found for this address/]
		JRST ENDLP.]
	MOVE T4,0(Q2)		;SEARCH FOR ADDRESS IN TABLE
	HLRZ T2,T4		;GET ADDRESS
	HRRZ T3,SEBDAT+BG%ADR(Q1) ;Get BUGHLT address
	CAME T2,T3		;Found it?
	AOJA Q2,TOP.		;NO, STEP POINTER AND LOOP
	HRRZ T2,T4		;GET POINTER TO MESSAGE STRING
	HLL T2,Q2		;INCLUDE SECTION NUMBER
	MOVEM T2,BUGSP		;SAVE IT FOR SYSERR BLOCK
  >
  IFE FTNSPSRV,< ;[6.1]
	MOVE Q2,BUGTP		;ADDRESS OF BUG POINTERS
	MOVE P1,BUGTL		;LENGTH OF TABLE
	MOVE T4,SEBDAT+BG%ADR(Q1) ;Get PC of BUG
	TLNN T4,-1		;Skip if not section 0
	HRLI T4,MSEC1		; otherwise load section 1 for compare
      DO.
	SOJL P1,[HRROI T2,[ASCIZ/Message not found for this address/]
		JRST ENDLP.]
	CAMN T4,0(Q2)		;Compare with BUG in BGPTR
	IFSKP.			; -not the one,
	  ADDI Q2,2		;  Move to next entry
	  LOOP.			;   and go back to try next
	ENDIF.
	MOVE T2,1(Q2)		;Get BGSTR pointer
	MOVEM T2,BUGSP		;SAVE IT FOR SYSERR BLOCK
  >
	TXO T2,<.P07>		;MAKE OWGBP
      ENDDO.
	SETZ T3,		;Set up for SOUT
	SOUT			;TYPE OUT STRING
	SETZM BUGPNM		;START WITH A NULL PROGRAM NAME
	SKIPGE SEBDAT+BG%JOB(Q1)	;IS THERE A JOB?
	JRST LOGBF5		;NO, SKIP JOB/USER LINE
	SKIPN SAVTRE		;SAVING TREES?
	IFSKP.
	   FMSG <  Job: >	;YES
	ELSE.
	   FMSG <
*Job:  >
	ENDIF.
	HRRZ T2,SEBDAT+BG%JOB(Q1)	;GET JOB NUMBER
	MOVEI T3,12		;TYPE IT IN DECIMAL
	NOUT
	 ERJMP .+1
	MOVE T2,JOBPNM(T2)	;GET PROGRAM NAME
	MOVEM T2,BUGPNM		;SAVE NAME OF PROGRAM
	FMSG <, User: >
	HRRZ T2,SEBDAT+BG%USR(Q1)	;GET USER LOGGED IN DIR NUMBER
	HRLI T2,USRLH		;TURN IT INTO PROPER FORMAT USER NUMBER
	DIRST			;TYPE OUT USER NAME
	 ERJMPS .+1		;IGNORE ERROR, PRESERVE PTR IN T1
LOGBF5:	SKIPG Q2,SEBDAT+BG%RCT(Q1) ;GET COUNT OF REGISTERS SAVED
	JRST LOGBF7		;NO REGISTERS TO BE TYPED
	SKIPN SAVTRE		;SAVING TREES?
	IFSKP.
IFE STANSW,<
	   FMSG <  Additional Data: >  ;YES
>;IFE STANSW
IFN STANSW,<
	   FMSG <, Data >	;YES
>;IFN STANSW
	ELSE.
	   FMSG <
*Additional data: >
	ENDIF.
	XMOVEI T4,SEBDAT+BG%REG(Q1)	;GET POINTER TO REGISTER AREA
LOGBF6:	MOVE T3,[NO%MAG+10]	;TYPE THEM IN UNSIGNED OCTAL
	MOVE T2,0(T4)		;GET NEXT REG TO TYPE
	NOUT
	 ERJMP .+1
	SOJLE Q2,LOGBF7		;DONE?
	FMSG <, >	;NO
	AOJA T4,LOGBF6		;GO TYPE OUT REST
LOGBF7:	SKIPN SAVTRE		;SAVING TREES?
	IFSKP.
	   FMSG <
>
	ELSE.
	   FMSG <
********************
>
	ENDIF.
	SETZ T2,
	IDPB T2,T1		;TIE IT OFF
	MOVEI T2,LOGBUF
	MOVE T4,SEBDAT+BG%FLG(Q1) ;GET TYPE OF BUG 
	MOVEI T3,.QBCHK		;BUGCHK BY DEFAULT (BUGHLTS DON'T MAKE IT)
	CAIN T4,BG%CHK		;BUGCHK?
	MOVEI T3,.QBCHK		;YES, .QBDTY VALUE FOR BUGCHK
	CAIN T4,BG%INF		;INFORMATIONAL BUG CHECK?
	MOVEI T3,.QBINF		;YES, .QBDTY VALUE FOR BUGINF
	CALL WROPR0		;SEND IT
	MOVE T1,CRSTD1		;GET DATE OF BUGCHK
	CAMN T1,[-1]		;IS THERE ONE SET?
	CALL LGTAD		;NO, SEE IF IT IS SET NOW
	MOVEM T1,BUGTAD		;SAVE DATE AND TIME OF BUGCHK
	MOVE T1,Q1		;GO COPY REST OF DATA TO BLOCK
	MOVE T2,[-NBUGET,,BUGET]
	CALL SEBCPY
	 JFCL
	SOS BUGCNT		;COUNT DOWN THE QUEUED UP BLOCK COUNT
	SETZM BUGCHK		;CLEAR OUT LAST BUGCHK ADR
	RET			;FINISHED

BUGET:	SEBPTR BG%SVN,SBTSTR,SVN ;SYSTEM NAME
	SEBPTR BG%PNM,SBTWD,BUGPNM ;PROGRAM NAME
	SEBPTR BG%DAT,SBTWD,BUGTAD ;TIME AND DATE OF CRASH
	SEBPTR BG%MSG,SBTSTR,@BUGSP ;BUG MESSAGE
NBUGET==.-BUGET
;LOCAL ROUTINE TO OUTPUT THE TIME
;RETURNS:	+1

RLOGTM:	FMSG <" at >
	SKIPA
SLOGTM:	MOVX T3,OT%NDA		;NO DATE, JUST THE TIME
	MOVE T2,SEBDAT+BG%DAT(Q1) ;GET TIME AND DATE OF BUG CHECK
	ODTIM			;TYPE OUT TIME AND DATE
	 ERJMP .+1
	RET

;LOCAL ROUTINE TO OUTPUT THE BUGXXX TYPE AND NAME
;RETURNS:	+1

LOGNAM:	MOVE T4,SEBDAT+BG%FLG(Q1) ;GET TYPE OF BUG CHECK
IFE STANSW,<
	HRROI T2,[ASCIZ/HLT /]
	CAIN T4,BG%CHK		;BUGCHK?
	HRROI T2,[ASCIZ/CHK /]	;YES
	CAIN T4,BG%INF		;INFORMATIONAL BUG CHECK?
	HRROI T2,[ASCIZ/INF /]	;YES
>;IFE STANSW
IFN STANSW,<
	HRROI T2,[ASCIZ/ BUGHLT: /]
	CAIN T4,BG%CHK		;BUGCHK?
	HRROI T2,[ASCIZ/ BUGCHK: /]	;YES
	CAIN T4,BG%INF		;INFORMATIONAL BUG CHECK?
	HRROI T2,[ASCIZ/ BUGINF: /]	;YES
>;IFN STANSW
	SOUT
	 ERJMP .+1
	SKIPE SAVTRE		;SAVING TREES?
	IFSKP.
	   FMSG <">		;NO
	ENDIF.
	MOVE T4,[POINT 6,SEBDAT+BG%NAM(Q1)]
LOGNA1:	ILDB T2,T4		;NOW TYPE OUT 6 CHAR NAME
	JUMPE T2,R		;IF AT END, STOP TYPING
	ADDI T2," "		;TRANSLATE SIXBIT TO ASCII
	IDPB T2,T1		;STORE IT
	TLNE T4,770000		;AT END OF NAME YET?
	JRST LOGNA1		;NO, LOOP BACK FOR REST OF CHARS
	RET
;Routine to write message to operator. Uses ORION if it can
;	T1/ count of words in string
;	T2/ string address
;	T3/ .QBDTY value (.QBCHK,.QBINF,.QBSYS)
;	CALL WROPER

;	or
;	T1/ ending bp
;	T2/ buffer address
;	T3/ .QBDTY value (.QBCHK,.QBINF,.QBSYS)
;	CALL WROPR0

;	Returns +1 always
;Clobbers all temps

;Format of the QBLK STKVAR storage:
;
;  QBLK/  Function and flags      	;.QUFNC
;    +1/  Response block (not used)	;.QURSP
;    +2/  QA%IMM!<Length=1>!.QBDTY	;.QUARG+.QATYP  (DISPLAY TYPE)
;    +3/  .QBCHK,.QBINF,or .QBSYS	;.QUARG+.QADAT
;    +4/  <Length>,,.QBMSG		;.QUARG+.QATYP+2 (MESSAGE BLOCK)
;    +5/  ADDR OF STRING		;.QUARG+.QADAT+2
   QLNG==6

WROPR0::HRRZS T1		;GET ADDRESS
	SUBI T1,-1(T2)		;COMPUTE WORDS
WROPER::STKVAR<<QBLK,QLNG>>
	MOVEI T4,QBLK		;POINT AT OUR BLOCK
	MOVEM T2,.QUARG+.QADAT+2(T4) ;STORE STRING
	MOVEM T3,.QUARG+.QADAT(T4) ;STORE MESSAGE TYPE
	HRLI T1,.QBMSG		;SUBFUNCTION ARG
	MOVSM T1,.QUARG+.QATYP+2(T4) ;STASH SUBFUNC STUFF
	MOVX T3,<QU%NRS!.QUWTO>	;NO RESPONSE FOR WRITE TO OPERATOR
	MOVEM T3,.QUFNC(T4)	;SAVE THE FUNCTION AND FLAGS
	MOVX T3,<QA%IMM!<FLD(1,QA%LEN)>!<FLD(.QBDTY,QA%TYP)>>
	MOVEM T3,.QUARG+.QATYP(T4) ;SAVE THE DISPLAY TYPE, LENGTH, FLAGS
	SETZM .QURSP(T4)	;NO RESPONSE BLOCK
	MOVEI T1,QLNG		;LENGTH OF ARG BLOCK
	MOVEI T2,QBLK		;POINT AT ARG BLOCK
	QUEUE%			;DO IT
	 ERJMP WROPE0		;IF FAILED, PUT ON THE CTY
	JE SF%BGS,FACTSW,R	;CHECK IF WANT BOTH
WROPE0:	HRRO T1,.QUARG+.QADAT+2(T4) ;GET POINTER TO STRING
	PSOUT			;SO DO IT
	RET			;DONE

	ENDSV.
	SUBTTL BUGxxx Processing -- BUGHLT In Job Context (EXBUGH)

	RESCD

;BUGHLT IN JOB CONTEXT TRAPS TO HERE

EXBUGH::SETZM NSKED		;BE OKSKED
	SETZM CRSKED		;BE NOT 'CRITICAL SECTION'
	SETOM TRAPC
	MOVE 1,UPDL		;RESET STACK, ETC.
	MOVEM 1,FPC		;SET PC
	MOVX T1,USRCTX		;SET USER MODE FLAGS WORD
	MOVEM 1,FFL
	MCENTR
	SETZM INTDF
	SKIPN JOBNO		;JOB 0?
	JRST CHKRI		;YES, INTERRUPT
	HRRZ 1,PRIMRY
	HRROI 2,[ASCIZ /
BUGHLT at /]
	SETZ 3,
	SOUT
	HRRZ 2,BUGHLT
	MOVEI 3,^D8
	NOUT
	JFCL
	TMSG <
>
	ITERX			;GENERATE ITRAP

	SWAPCD

;ANY INTERRUPT WILL EVENTUALLY TRAP TO HERE

CHKRI:	BUG.(CHK,JB0CSH,MEXEC,SOFT,<Job 0 crash>,<<ITFPC,PC>,<LSTERR,LSTERR>>,<

Cause:	An unexpected interrupt has occurred in the job 0 fork which
	checks system status.  The context will be reinitialized, and
	the process restarted.  

Action:	If this BUG persists, make it dumpable and submit an SPR with the
	dump and a copy of MONITR.EXE.  If possible, include any known
	method for reproducing the problem and/or the state of the system
	at the time the BUG was observed.  In the dump, the stack may be 
	examined to determine the situation which caused the error.

Data:	PC - PC at which error occurred.
	LSTERR - Last error code for this fork.
>)
	SETZM NSKED		;BE OKSKED
	SETZM CRSKED		;BE NOT 'CRITICAL SECTION'
	MOVX CX,USRCTX
	MOVEM CX,FFL
	MCENTR			;REINIT CONTEXT
	SETZM PSIBW
	JRST CHKR
	SUBTTL BUGxxx Processing -- Store Time For BUGxxx (CHKBGS) 

;CHKBGS - CHECK IF TIME TO STORE NEW ASCII TIME AND DATE FOR TYPEOUT
;	  AT BUGHLT TIME
;
;RETURNS:  +1,	ALWAYS

CHKBGS:	MOVE T1,TODCLK		;GET CURRENT DATE AND TIME
	CAML T1,BUGTMS		;TIME TO STORE ASCII STRING?
	SKIPGE TADIDT		;HAS TIME BEEN SET
	RET			;NO, NOT YET
	MOVX T2,<BUGINT>	;GET TIME INTERVAL FOR STORING STRING
	ADD T1,T2		;GET NEXT TIME FOR STORING STRING
	MOVEM T1,BUGTMS		;STORE
	MOVE T1,[POINT 7,BUGTIM] ;GET BYTE POINTER FOR STORING TIME
	MOVNI T2,1		;GET CURRENT TIME AND DATE
	SETZ T3,		; IN DEFAULT FORMAT
	ODTIM
	MOVE T2,"/"		;STORE DELIMITER FOR BUGMSG ROUTINE
	IDPB T2,T1
	RET
	SUBTTL BUGxxx Processing -- Log Parity Error (PFCPJ0)

;ROUTINE TO FINISH LOGGING OF PARITY ERROR - RUN IN JOB 0 CONTEXT

; T1/ ADDRESS OF SYSERR BLOCK

PFCPJ0::SAVEQ
	HLRZ FX,SEBDAT+PT%JOB(T1) ;GET FORKX AT TRAP
	CAIE FX,-1
	SKIPGE FKPT(FX)
	RET			;IN SCHED OR FORK KILLED, NO DATA
	LOAD T2,FKJBN		;GET JOB NUMBER
	HRRM T2,SEBDAT+PT%JOB(T1) ;REPORT IT
	HRRZ T3,JOBDIR(T2)	;GET LOGGED-IN DIRECTORY
	HRLI T3,USRLH		;MAKE IT A USER NUMBER
	MOVEM T3,SEBDAT+PT%USR(T1) ;REPORT IT
	MOVE T3,JOBPNM(T2)	;GET PROGRAM NAME
	MOVEM T3,SEBDAT+PT%PGM(T1) ;REPORT IT
	RET
	SUBTTL Send Message To All Lines (ALLMSG)

;SEND TEXT TO ALL LINES, WAIT FOR COMPLETION
; 2/ PTR TO ASCIZ MESSAGE
;	CALL ALLMSG
; RETURN +1 ALWAYS, WAIT LONG ENOUGH FOR MESSAGE TO APPEAR ON 110 BAUD
;LINES.

ALLMSG::SETZ 1,			;SAY NO WAIT
   REPEAT 0,<
	HLRZ 3,2		;CHECK LH OF POINTER
	CAIN 3,-1		;DEFAULT?
	HRLI 2,(<POINT 7,0>)	;YES, DO IT
   >
	SETO T3,		;SAY ALL LINE
	TTMSG			;TYPE THE STUFF
	 ERCAL MESFAL		;[7.1086] Failure, let CTY now
	RET			; AND RETURN

MESFAL::BUG.(INF,TTFSMS,MEXEC,SOFT,<Failed to send system message>,<<LSTERR,LSTERR>>,<

Cause:	The most likely reason for this failure is that RSX20F cannot
	complete the previous TTMSG request. Typically this is caused by a
	hung DH11 line, but could be a software bug as well.

Action:	Look at the error code which explains the reason for the send 
	failure.  Some error conditions (such as a remote CI node going
	down) can cause this BUG to appear and are perfectly legitimate.
	If this BUG persists and the last error appears to be something 
	suspicious, make it dumpable and submit an SPR with the
	dump and a copy of MONITR.EXE.  If possible, include any known
	method for reproducing the problem and/or the state of the system
	at the time the BUG was observed.

Data:	LSTERR - Last TOPS-20 error code for this fork
>,,<DB%NND>)			;[7.1210][7.1200][7.1086] Bug!
	RET			;[7.1086] Now return
	SUBTTL End of MEXEC

	RESCD

	TNXEND 
	END