Google
 

Trailing-Edge - PDP-10 Archives - BB-M081Q-SM - monitor-sources/syserr.mac
There are 64 other files named syserr.mac in the archive. Click here to see a list.
; UPD ID= 8626, RIP:<7.MONITOR>SYSERR.MAC.5,  11-Feb-88 18:37:58 by GSCOTT
;TCO 7.1218 - Update copyright date.
; UPD ID= 8448, RIP:<7.MONITOR>SYSERR.MAC.4,   4-Feb-88 16:42:52 by GSCOTT
;TCO 7.1210 - Set SERGOF and SPRZR1 normally not dumpable.
; UPD ID= 254, RIP:<7.MONITOR>SYSERR.MAC.3,   4-Nov-87 16:44:21 by MCCOLLUM
;TCO 7.1112 - Look for ERROR.SYS on SERR: instead of <SYSTEM-ERROR>
; *** Edit 7357 to SYSERR.MAC by RASPUZZI on 22-Aug-86
; Remove routine GAPRID since the processor serial number is already in APRSER
; and make all CALLs to GAPRID refer to that resident location. 
; UPD ID= 2190, SNARK:<6.1.MONITOR>SYSERR.MAC.48,   5-Jun-85 11:08:37 by MCCOLLUM
;TCO 6.1.1406  - Update copyright notice.
; UPD ID= 1935, SNARK:<6.1.MONITOR>SYSERR.MAC.47,   7-May-85 22:49:09 by MCCOLLUM
;TCO 6.1.1238 - Fix more BUG. documentation
; UPD ID= 1830, SNARK:<6.1.MONITOR>SYSERR.MAC.46,  26-Apr-85 09:31:09 by MCCOLLUM
;TCO 6.1.1238 - Fix more BUG. documentation
; UPD ID= 1799, SNARK:<6.1.MONITOR>SYSERR.MAC.45,  23-Apr-85 13:39:37 by MCCOLLUM
;TCO 6.1.1238 - Fix more BUG. documentation
; UPD ID= 1776, SNARK:<6.1.MONITOR>SYSERR.MAC.44,  22-Apr-85 14:35:39 by MCCOLLUM
;TCO 6.1.1238 - Fix BUG. documentation
; UPD ID= 1750, SNARK:<6.1.MONITOR>SYSERR.MAC.43,  12-Apr-85 13:50:37 by MCCOLLUM
;Change SYENCD to an INF and add some data words
; UPD ID= 1480, SNARK:<6.1.MONITOR>SYSERR.MAC.42,   5-Feb-85 17:13:11 by GLINDELL
;  TCO 6.1.1177 - fix copying of bug descriptions
; UPD ID= 972, SNARK:<6.1.MONITOR>SYSERR.MAC.41,   6-Nov-84 19:49:03 by TBOYLE
;TCO 6.1.1034 - Put ALCSBX back into operation for extended free space now
; that SETSPD can read the stuff out.
; UPD ID= 4871, SNARK:<6.MONITOR>SYSERR.MAC.40,  24-Sep-84 16:16:42 by GRANT
;In SEBCPY, MOVEI needs to be XMOVEI
; UPD ID= 4837, SNARK:<6.MONITOR>SYSERR.MAC.39,  17-Sep-84 11:24:06 by PURRETTA
;Update copyright notice
; UPD ID= 4695, SNARK:<6.MONITOR>SYSERR.MAC.38,  15-Aug-84 17:24:45 by TBOYLE
;NOP ALCSBX until SETSPD fixed.
; UPD ID= 4689, SNARK:<6.MONITOR>SYSERR.MAC.37,  14-Aug-84 16:11:47 by TBOYLE
;New SYSERR - Off by one bug around SEBCH1 with RESYNC word.
; UPD ID= 4621, SNARK:<6.MONITOR>SYSERR.MAC.36,  28-Jul-84 16:05:33 by MOSER
;TCO 6.2141 - HANDLE FORK TERMINATION USING MONBK/SEBINH
; UPD ID= 4616, SNARK:<6.MONITOR>SYSERR.MAC.35,  27-Jul-84 16:45:13 by TBOYLE
;New SYSERR - EXTADR counter, ALXLST counter.
; UPD ID= 4613, SNARK:<6.MONITOR>SYSERR.MAC.34,  27-Jul-84 14:55:50 by TBOYLE
;New SYSERR - EA.ENT in QUESEB, ALCSBX in .SYERR
; UPD ID= 4572, SNARK:<6.MONITOR>SYSERR.MAC.33,  20-Jul-84 14:21:43 by TBOYLE
;Fix lost SYSERR entries. At SEBINI, UNQSEB to use MOVEI's for SEBQOU.
; UPD ID= 4570, SNARK:<6.MONITOR>SYSERR.MAC.32,  19-Jul-84 18:39:55 by TBOYLE
;Fix the register garbaging in ALCSEB of T3.
; UPD ID= 4565, SNARK:<6.MONITOR>SYSERR.MAC.31,  18-Jul-84 23:21:37 by TBOYLE
;New SYSERR - Hooks for extended storage of blocks - Phase I.
; UPD ID= 4194, SNARK:<6.MONITOR>SYSERR.MAC.30,   9-May-84 13:04:57 by TBOYLE
;More TCO 6.2055 - Pick up the SPEAR sequence number in SEBOFI when 1st opened.
; UPD ID= 4176, SNARK:<6.MONITOR>SYSERR.MAC.29,   7-May-84 13:13:47 by TBOYLE
;TCO 6.2055 - Maintain SPEAR sequence number inside EOF at end of ERROR.SYS.
; UPD ID= 4126, SNARK:<6.MONITOR>SYSERR.MAC.28,  25-Apr-84 11:06:34 by LOMARTIRE
;TCO 6.2046 - Record job 0 fork number of SYSERR fork in SEBFRK
; UPD ID= 4074, SNARK:<6.MONITOR>SYSERR.MAC.27,  11-Apr-84 22:06:39 by TBOYLE
;TCO 6.2027 AOS ALCLST at ALCSEB fail, and SYELST at ALCSEB in .SYERR
; UPD ID= 3457, SNARK:<6.MONITOR>SYSERR.MAC.26,  13-Jan-84 17:18:10 by TBOYLE
;TCO 6.1933 At SEBLUP if SPRCNT<0 then defer processing of SPEAR entries.
; UPD ID= 2986, SNARK:<6.MONITOR>SYSERR.MAC.25,   5-Oct-83 11:15:58 by MCLEAN
;MORE OF 6.1808 GONNA GET IT RIGHT THIS TIME..
; UPD ID= 2979, SNARK:<6.MONITOR>SYSERR.MAC.24,   4-Oct-83 11:47:56 by MCLEAN
;MORE OF 6.1808
; UPD ID= 2949, SNARK:<6.MONITOR>SYSERR.MAC.23,  27-Sep-83 21:46:46 by MCLEAN
;TCO 6.1808 BUGCHK AND DON'T MAKE ENTRIES IF NO CODE SUPPLIED FOR JSYS
; UPD ID= 2820, SNARK:<6.MONITOR>SYSERR.MAC.22,   9-Aug-83 14:20:27 by PURRETTA
;Missing module name in SPRZR1 Buginf.
; UPD ID= 2700, SNARK:<6.MONITOR>SYSERR.MAC.21,  18-Jul-83 13:07:12 by MCLEAN
;TCO 6.1734 ADD ROOM TO JSYS FOR CRASH SPANNING WORD.
; UPD ID= 2574, SNARK:<6.MONITOR>SYSERR.MAC.20,   8-Jun-83 17:05:05 by MCLEAN
;THE PREVIOUS EDIT WAS TCO 6.1672 BUT TCO WAS BROKEN SO HEADER IS MISSING.
; UPD ID= 2558, SNARK:<6.MONITOR>SYSERR.MAC.19,   3-Jun-83 22:44:44 by MCLEAN
;ADD A UFPGS TO SEBCH2 TO INSURE DISK IS WRITTEN.
; UPD ID= 2402, SNARK:<6.MONITOR>SYSERR.MAC.18,   3-May-83 15:07:48 by COBB
;TCO 6.1637 - Increment SPRCNT in SEBCHK and store into header
; UPD ID= 1998, SNARK:<6.MONITOR>SYSERR.MAC.17,  15-Mar-83 17:00:32 by MILLER
;TCO 6.1546. Increment SERCNT at QUESEB
; UPD ID= 1900, SNARK:<6.MONITOR>SYSERR.MAC.16,   1-Mar-83 16:03:54 by HALL
;TCO 6.1502 - Allow free space outside of section 0
;	At least temporarily, make all callers request section 0
; UPD ID= 910, SNARK:<6.MONITOR>SYSERR.MAC.15,   9-Jun-82 23:38:58 by MURPHY
;TCO 6.1147 - Move bugdefs from BUGS.MAC to here and put them in-line.
; UPD ID= 704, SNARK:<6.MONITOR>SYSERR.MAC.14,   9-May-82 11:45:47 by HALL
;TCO 6.1000 - Support the 2080
;	AT SEBRUN, initialize full word of flags
; UPD ID= 192, SNARK:<6.MONITOR>SYSERR.MAC.13,   6-Nov-81 13:40:13 by MURPHY
;Make monitor fork start in section 1.
; UPD ID= 202, SNARK:<5.MONITOR>SYSERR.MAC.12,  21-Sep-81 14:55:01 by MURPHY
;TCO 5.1514 - Don't move SYSERR blocks to file until TAD set.
; UPD ID= 145, SNARK:<5.MONITOR>SYSERR.MAC.11,   3-Sep-81 12:44:09 by MILLER
;TCO 5.1487. ADD CODE TO SCAN SEBQOU ON BUGHLT
; UPD ID= 32, SNARK:<5.MONITOR>SYSERR.MAC.10,  14-Jul-81 13:00:03 by PAETZOLD
;TCO 5.1412 - change relative JRST in UNQSEB to JRST UNQSB2
; UPD ID= 31, SNARK:<5.MONITOR>SYSERR.MAC.9,  14-Jul-81 12:31:13 by PAETZOLD
;More TCO 5.1380 - Dont zero syserr block in ALCSEB as ASGRES did it
; UPD ID= 2304, SNARK:<5.MONITOR>SYSERR.MAC.8,   7-Jul-81 11:05:07 by WACHS
;TCO 5.1397 - Add a header version number to the header
; UPD ID= 2285, SNARK:<5.MONITOR>SYSERR.MAC.7,   1-Jul-81 21:11:02 by PAETZOLD
;TCO 5.1380 - Use resident free space for syserr block storage
; UPD ID= 2155, SNARK:<5.MONITOR>SYSERR.MAC.6,   9-Jun-81 12:30:12 by PAETZOLD
;TCO 5.1365 MAKE SYSERR FORK RUN IN QUEUE ZERO
; UPD ID= 2129, SNARK:<5.MONITOR>SYSERR.MAC.5,   6-Jun-81 11:00:12 by PAETZOLD
;Add semicolon to TCO 5.1338 comment
; UPD ID= 2116, SNARK:<5.MONITOR>SYSERR.MAC.4,   2-Jun-81 15:19:25 by LEACHE
;TCO 5.1338 - Open error file in <SYSTEM-ERROR>
; UPD ID= 1425, SNARK:<5.MONITOR>SYSERR.MAC.3,   8-Jan-81 16:33:59 by HALL
;TCO 5.1064 - Move DBELL's ERJMP to after the MOVEM that writes the
; resynch word. Remove the MOVMM. The MOVEM is the only instruction that
; can create a page.
;TCO 5.1180 - Make SYSERR fork run in section 1 because it can lead to
; references to the DST
; UPD ID= 624, SNARK:<5.MONITOR>SYSERR.MAC.2,  11-Jun-80 12:19:14 by DBELL
;TCO 5.1064 - PREVENT ILMNRF WHEN WRITING SYSERR FILE AND DISK IS FULL
;<4.MONITOR>SYSERR.MAC.6, 27-Sep-79 06:58:46, EDIT BY R.ACE
;FIX COMMENT (CHANGE . TO ;)
;<4.MONITOR>SYSERR.MAC.5, 26-Sep-79 15:57:38, EDIT BY HALL
;SYERR - CALL BLTUM1 INSTEAD OF BLTUM FOR EXTENDED ADDRESSING
;<OSMAN.MON>SYSERR.MAC.1, 10-Sep-79 16:06:07, EDIT BY OSMAN
;TCO 4.2412 - Move definition of BUGHLTs, BUGCHKs, and BUGINFs to BUGS.MAC
;<4.MONITOR>SYSERR.MAC.3, 14-Mar-79 10:02:26, EDIT BY KIRSCHEN
;FIX DATA CLOBBERAGE ON LARGE ENTRIES (LARGER THAN SEBBLK)
;<4.MONITOR>SYSERR.MAC.2, 11-Mar-79 13:03:02, EDIT BY KONEN
;UPDATE COPYRIGHT FOR RELEASE 4
;<4.MONITOR>SYSERR.MAC.1, 19-Dec-78 15:41:41, EDIT BY MURPHY
;ADD BLOCK PRIORITY TO SCHED CALL

;	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 PROLOG
	TTITLE SYSERR

;STRUCTURE OF BLOCK
; WORD 0 - HEADER

DEFSTR SEBCDR,,35,36		;PTR TO NEXT IN LIST

;BLOCK STATE CODES

SBCFRE==0			;ON FREE LIST
SBCREL==1			;RELEASED
SBCACT==2			;ACTIVE

; WORD 1-2 - LOCAL USAGE

DEFSTR SEBFN,1,35,36		;FUNCTION TO CALL IN JOB 0
DEFSTR SEBCOD,2,5,3		;STATE CODE
DEFSTR SEBSOF,2,17,12		;OFFSET TO FREE STRING SPACE
DEFSTR SEBSIZ,2,35,12		;SIZE OF THIS BLOCK (INCLUDING HEADER)

SEBHED==:3			;FIRST REGULAR HEADER WORD

; WORD 3-6 - SYSERR HEADER

DEFSTR SEHCOD,SEBHED,8,9		;EVENT CODE
DEFSTR SEHLEN,SEBHED,35,9		;LENGTH OF BLOCK
DEFSTR SEHTAD,SEBHED+1,35,36		;DATE AND TIME
DEFSTR SEHUTM,SEBHED+2,35,36		;UPTIME
DEFSTR SEHSER,SEBHED+3,35,36		;APRID WORD
DEFSTR SEHCNT,SEBHED+4,35,36		;CRASH SPANNING COUNTER

SEBDAT==:SEBHED+5			;FIRST DATA WORD
SBSMAX==400			;MAX SIZE, JSYS CALL
SEHWD0==1B17+1B20+2B23+5B26		;STANDARD BITS, HEADER WORD
				; (TOPS20, BODY VER 1, HDR VER 2, HDR LEN 5)
SEBBLK==200			;SIZE OF LOGICAL BLOCK IN SYSERR FILE

;LOCAL DATA - OTHER STORAGE IN STG.MAC

RS ALXLST,1			;COUNT OF LOST ALLOCATIONS IN EXTENEDED STORAGE
RS EXTADR,1			;LAST EXTENDED CALLER OF ALCSEB

;INITIALIZATION

	RESCD

SEBINI::
	MOVEI T1,SEBQOU		;INIT QUEUE
	MOVEM T1,SEBQIN
	SETZM SEBQOU		;INIT OUTPUT POINTER ALSO
	RET
;ALLOCATE SYSERR BLOCK
; T1/ SIZE (NOT INCLUDING HEADER AND LOCAL DATA)
; T2/ OFFSET TO STRING STORAGE (I.E. SIZE OF HEADER AND DATA)
;	CALL ALCSEB
; RETURN +1: FAILURE, NO BUFFER SPACE AVAILABLE
; RETURN +2: SUCCESS, T1/ PTR TO BLOCK

;THIS ROUTINE MAY BE CALLED AT ANY PI LEVEL.  IT TURNS THE PI SYSTEM
;OFF WHILE MANIPULATING LISTS, BUT WAS DESIGNED TO MINIMIZE THE
;DURATION OF PI DISABLING.  THE FIRST TWO WORDS OF THE RETURNED BLOCK
;ARE USED FOR LOCAL PURPOSES AS DEFINED ABOVE.  THE ACTUAL SYSERR
;DATA BEGINS IN THE THIRD WORD AND CONSTITUTES THE REMAINDER OF THE BLOCK.

	RESCD

ALCSBX::
	ADDI T1,SEBDAT+1	;INCLUDE SPACE FOR HEADER and eof w/sequence
	ASUBR <ARG1,ARG2>
	HRLI T1,.RESP1		;HIGHEST PRIORITY REQUEST
	MOVX T2,.RESGP		;FROM THE GENERAL POOL, EXTENDED
	CALL ASGRES		;ASSIGN RESIDENT FREE SPACE
	 JRST	[AOS ALXLST	;COUNT LOST ALLOCATIONS EXTENDED
		 RET]		;IT FAILED SO USE ERROR RETURN
	JRST ALCCOM
ALCSEB::			;ROUTINE TO ALLOCATE SYSERR BLOCKS
	ADDI T1,SEBDAT+1	;INCLUDE SPACE FOR HEADER and eof w/sequence
	ASUBR <ARG1,ARG2>
	MOVE T2,-6(P)		;***TEMP*** GET CALLER'S PC
	TXNE T2,VSECNO		;***TEMP*** SEE IF EXTENDED
	MOVEM T2,EXTADR		;***TEMP*** WRITE HIS NAME DOWN
	HRLI T1,.RESP1		;HIGHEST PRIORITY REQUEST
	MOVX T2,RS%SE0!.RESGP	;FROM THE GENERAL POOL, SECTION 0
	CALL ASGRES		;ASSIGN RESIDENT FREE SPACE
	 JRST	[AOS ALCLST	;COUNT LOST ALLOCATIONS SECTION ZERO
		 RET]		;IT FAILED SO USE ERROR RETURN
ALCCOM:
				;STORE INFORMATION IN THE HEADER
	MOVE T2,ARG1		;GET LENGTH USER ASKED FOR
	STOR T2,SEBSIZ,(T1)	;STORE IN SYSERR BLOCK
	MOVX T2,SBCACT		;SET CODE TO ACTIVVE
	STOR T2,SEBCOD,(T1)	;STORE IN SYSERR BLOCK
	MOVE T2,ARG2		;GET OFFSET FOR STRING STORAGE
	ADDI T2,SEBDAT		;MAKE RELATIVE TO BLOCK ORIGIN
	STOR T2,SEBSOF,(T1)	;STORE IN SYSERR BLOCK
	RETSKP			;AND RETURN, ADR OF BLOCK IN T1
;QUEUE SYSERR BLOCK FOR JOB 0.
; T1/ PTR TO BLOCK
;	CALL QUESEB
; RETURN +1 ALWAYS, BLOCK QUEUED
;MAY BE CALLED AT ANY PI LEVEL.

	RESCD

QUESEB::CALL EXTCHK
	EA.ENT
	CONI PI,T2		;SAVE PI STATE
	SETZRO SEBCDR,(T1)	;MARK NEW END OF LIST
	PIOFF
	STOR T1,SEBCDR,@SEBQIN	;APPEND TO END OF QUEUE
	MOVEM T1,SEBQIN		;UPDATE END PTR
	TXNE T2,PIPION		;PI WAS ON?
	PION			;YES, RESTORE IT
	AOS SECHKF		;FIRE UP JOB 0
	AOS SERCNT		;ONE MORE DONE FOR THIS LOAD
	RET

;UNQUEUE NEXT ITEM FROM SYSERR JOB 0 QUEUE
;	CALL UNQSEB
; RETURN +1: NOTHING LEFT ON QUEUE
; RETURN +2: SUCCESS, T1/ PTR TO BLOCK

	SWAPCD

UNQSEB::SKIPN T1,SEBQOU		;ANYTHING IN QUEUE?
	RET			;NO
	PIOFF			;INTO THE TUNNEL
	LOAD T1,SEBCDR,(T1)	;YES, GET CDR
	JUMPN T1,UNQSB2		;QUEUE BECOMING EMPTY?
	MOVEI T2,SEBQOU		;YES, FIX IN PTR
	MOVEM T2,SEBQIN		;SAVE NEW IN POINTER
UNQSB2:
	EXCH T1,SEBQOU		;SAVE NEW OUT POINTER
	PION			;TURN MACHINE BACK ON
	RETSKP			;RETURN SUCCESS
;COPY DATA AND STRINGS INTO SYSERR BLOCK
; T1/ POINTER TO BLOCK
; T2/ -N,,ADR	- PTR TO LIST OF ITEMS
;	CALL SEBCPY
; RETURN +1: FAILURE (NO CASES AT PRESENT)
; RETURN +2: SUCCESS
;THIS ROUTINE MOVES DATA INTO THE SYSERR BLOCK AND ALLOCATES STRING
;STORAGE AS NEEDED.

	RESCD

SEBCPY::CALL EXTCHK
	SAVEQ
	DMOVEM T1,Q1		;KEEP BLK PTR, LIST PTR IN Q1, Q2
SEBCP1:	XMOVEI T4,SEBDAT(Q1)	;GET ADDRESS OF DATA AREA
	LOAD T3,SEBOFS,(Q2)	;GET OFFSET FOR NEXT ITEM
	ADD T4,T3		;FORM POINTER TO ACTUAL WORD
	XMOVEI T3,@0(Q2)	;GET POINTER TO DATA
	LOAD T1,SEBTYP,(Q2)	;GET DATA TYPE
	CAIGE T1,NSBTTB		;LEGAL?
	JRST @SBTTB(T1)		;DISPATCH
	LOAD T4,SEHCOD,(Q1)	;GET EVENT CODE INTO T4
	BUG.(CHK,SEBUDT,SYSERR,HARD,<SEBCPY - Unknown data type>,<<T1,DATTYP>,<T4,EVENT>>,<

Cause:	An unknown data type was supplied to SEBCPY to be copied into a
	SYSERR block. Legal types are defined in the SBTTB table.

Action:	This data type entry will be ignored.

Data:	DATTYP - Data type
	EVENT - Event code
>)
SEBCP9:	AOBJN Q2,SEBCP1		;LOOP FOR ALL ITEMS
	RETSKP			;DONE

;POINTER TYPE DISPATCH TABLE.  POINTER CODES CHECKED HERE ALTHOUGH
;DEFINED IN PROLOG.  CONFLICTING DEFINITION WILL PRODUCE
;MULDEF GLOBAL DURING LINK

SBTTB:	PHASE 0
SBTWD::	IFIW!SEBCP2		;FULL WORD
SBTSTR::IFIW!SEBCP3		;STRING (ASCIZ)
SBTEVC::IFIW!SEBCP4		;EVENT CODE
SBTFNA::IFIW!SEBCP5		;FUNCTION ADDRESS
	DEPHASE
NSBTTB==.-SBTTB

;DISPATCH ON POINTER TYPE IS EXECUTED WITH:
; T3/ POINTER TO DATA ITEM
; T4/ POINTER TO WORD IN SYSERR BLOCK

;FULL WORD

SEBCP2:	MOVE T1,0(T3)		;GET DATA
	MOVEM T1,0(T4)		;PUT INTO BLOCK
	JRST SEBCP9		;DONE
;STRING - ALLOCATE STORAGE AT END OF BLOCK, COPY STRING, SET POINTER

SEBCP3:	TXO T3,<.P07>		;Make global byte ptr to source string
	LOAD T2,SEBSOF,(Q1)	;GET OFFSET TO FREE STRING STG
	MOVEI T1,-SEBDAT(T2)	;MAKE PTR RELATIVE TO DATA AREA
	MOVEM T1,0(T4)		;PUT PTR IN BLOCK
	LOAD T4,SEBSIZ,(Q1)	;GET SIZE OF BLOCK
	SUB T4,T2		;COMPUTE FREE SPACE LEFT
	JUMPLE T4,SEBCP7	;JUMP IF NONE
	IMULI T4,5		;COMPUTE NUMBER BYTES LEFT
	ADD T2,Q1		;MAKE POINTER TO DESTINATION STRING
	TLO T2,(OWGP. 7,0)	;MAKE GLOBAL BYTE POINTER 
SEBCP8:	SOJL T4,[SETZ T1,	;SPACE EXHAUSTED, TERMINATE
		DPB T1,T2	;STRING AS IS
		JRST SEBCP7]
	ILDB T1,T3		;COPY A BYTE
	IDPB T1,T2
	JUMPN T1,SEBCP8		;COPY UNTIL NULL TERMINATOR
	TLZ T2,770000		;GET ADDRESS OF LAST WORD
	ADDI T2,1		;GET ADDRESS OF NEXT FREE WORD
	SUB T2,Q1		;COMPUTE PTR TO FREE SPACE
	STOR T2,SEBSOF,(Q1)	;UPDATE BLOCK
	JRST SEBCP9		;DONE

;HERE IF INSUFFICIENT STORAGE FOR STRING

SEBCP7:	BUG.(CHK,SEBISS,SYSERR,HARD,<SEBCPY - Insufficient string storage in block>,,<

Cause:	There is insufficent room in the SYSERR block for a string type
	data item.

Action:	The string will be truncated to fit into the space available.

>)
	LOAD T1,SEBSIZ,(Q1)	;UPDATE FREE STRING PTR
	STOR T1,SEBSOF,(Q1)
	JRST SEBCP9

;EVENT CODE

SEBCP4:	STOR T3,SEHCOD,(Q1)	;CODE IS IMMEDIATE
	JRST SEBCP9

;FUNCTION ADDRESS

SEBCP5:	STOR T3,SEBFN,(Q1)	;STORE IMMEDIATE VALUE
	JRST SEBCP9
;JSYS TO LOG INFORMATION IN SYSERR FILE
; T1/ ADDRESS OF BLOCK
; T2/ SIZE OF BLOCK
;	SYERR
; RETURN +1: SUCCESS.  ITRAP IF FAILURE

	SWAPCD

.SYERR::MCENT
	MOVE T1,CAPENB
	TXNN T1,SC%WHL+SC%OPR+SC%MNT ;CAPS?
	ITERR CAPX1
	UMOVE T1,T1		;GET THE ADDRESS OF THE BUFFER
	UMOVE T1,(T1)		;GET THE FIRST WORD
	TLNN T1,777000		;CHECK FOR ZERO CODE
	JRST [ MOVE A,JOBNO	;GET JOB NUMBER
	       MOVE B,JOBPNM(A)	;AND THE PROGRAM NAME
               BUG. (INF,SYENCD,SYSERR,SOFT,<SYSERR - Missing code for error type>,<<A,JOBNO>,<B,JOBPNM>>,<

Cause: The user forgot to supply a code type for the error entry.

Action: Don't make an entry since it will cause problems in the error file.

Data:	JOBNO - Job number, internal index
	JOBPNM - Job program name
>)
		ITERR ARGX02]
	UMOVE T1,T2		;GET SIZE
	CAIL T1,1		;REASONABLE?
	CAIL T1,SBSMAX
	ITERR SYEX1		;NO
	MOVE T2,T1		;ALLOW NO EXTRA STRING STG
	NOSKED
	CALL ALCSBX		;ALLOCATE A BLOCK
	 JRST	[AOS SYELST	;count lost syserr entries
		 ITERR (SYEX2,<OKSKED>)] ;NO ROOM
	OKSKED
	PUSH P,T1		;SAVE BLOCK POINTER
	XMOVEI T3,SEBHED(T1)	;SETUP BLT PTR - DEST
	XMOVEI P4,SEBDAT(T1) 	;SAVE POINTER FOR SECOND BLT
	MOVEI T1,SEBDAT-SEBHED-1 ;MOVE THE HEADER
	UMOVE T2,T1		;USER BUFFER ADDRESS
	CALL BLTUM1		;DO BLT FROM USER TO MONITOR
	MOVE T3,P4		;RESTORE THE SECOND BLT POINTER
	UMOVE T1,T2		;GET THE OUNT
	SUBI T1,SEBDAT-SEBHED-1	;SUBTRACT OFF THE SUPPOSED COUNT
	UMOVE T2,T1		;GET THE NEXT ADDRESS
	ADDI T2,SEBDAT-SEBHED-1	;WHERE WE LEFT OFF IN THE USERS SPACE
	CALL BLTUM1		;FINISH THE BLT
	POP P,T1		;RESTORE BLOCK POINTER
	CALL QUESEB		;QUEUE BLOCK
	MRETNG			;RETURN GOOD
;START SYSERR LOGGING FORK - CALLED FROM JOB 0 ONLY

SERINI::MOVX T1,1B1		;XMIT CAPABILITIES
	CFORK
	 BUG.(HLT,SERFRK,SYSERR,HARD,<SERINI - Cannot create SYSERR fork>,,<

Cause:	The cause of this BUGHLT is that Job 0 was unable to create a
	SYSERR fork.  The specific JSYS that fails is the CFORK JSYS,
	and the dump should have the reason for the failure.  Look at
	LSTERR to determine the reason the CFORK failed.

Action:	The action needed to remedy this problem depends on the error returned
	by CFORK.  Look at that code and try to determine how to
	undo what it is complaining about.


>)
	MOVE T2,[MSEC1,,SEBRUN]	;START PC
	MSFRK			;START IN EXEC MODE
	RET

;MAIN SYSERR LOGGING LOOP.
;JOB 0 FORK STARTED HERE AT SYSTEM STARTUP

SEBRUN::MOVX T1,USRCTX		;INIT CONTEXT
	MOVEM T1,FFL
	SETZM FPC
	MCENTR
	MOVE 1,[XWD MSEC1,SEBINH] ;GO TO SEBINH ON INTERRUPT
	CALL MONBKX
SEBIN0:	MOVE T1,FORKX		;GET SYSTEM WIDE FORK NUMBER
	MOVEM T1,SEBFRK		;RECORD IT
	MOVEI T1,.FHSLF		;THIS FORK
	MOVEI T2,1		;ONLY RUNS IN QUEUE 0
	SPRIW%			;SET FORK PRIORITY WORD
	MOVEI T1,TADIDT
	CALL DISGE		;DISMISS UNTIL TAD SET (I.E. TADIDT NOT -1)
	CALL SEBOFI		;OPEN SYSERR FILE
	 JRST SEBLUP		;CAN'T - KEEP GOING ANYHOW
	MOVE T1,SEBJFN		;CLOSE IT
	CLOSF
	 JFCL
SEBLUP:	MOVEI T1,SEBTST
	MOVSI T2,FHV1		;LOW PRIORITY
	HDISMS
	SETZM SECHKF		;CLEAR FLAG
	SKIPL SPRCNT		;IF SPRCNT<0 THEN LEAVE STUFF QUEUED.
	CALL SEBCHK		;PROCESS QUEUE
	JRST SEBLUP

	RESCD

SEBTST:	SKIPN SECHKF
	JRST 0(4)
	JRST 1(4)

	SWAPCD
;INTERRUPT HANDLER BUGCHK AND TRY AGAIN

SEBINH:	BUG.(CHK,SEBINT,MEXEC,SOFT,<Unexpected interrupt in SYSERR process>,<<ITFPC,ITFPC>,<LSTERR,LSTERR>>,<

Cause:	An unexpected error has occurred in the process that handles
	error logging.  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.

Data:	ITFPC - PC when error occurred.
	LSTERR - Last error code in fork.
>)
	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 SEBIN0
;INITIALIZATION - OPEN SYSERR LOG FILE

SEBOFI:	TRVAR <NEWFLG>
	SETZM NEWFLG		;NO NEW SYSERR FILE YET
	MOVE T1,TODCLK
	CAMGE T1,SEIETM		;AT LEAST 1 MINUTE AFTER PREVIOUS FAILURE?
	RET			;NO, RETURN FAILURE
	MOVX T1,GJ%OLD+GJ%PHY+GJ%SHT
	HRROI T2,SEFLNM
	GTJFN			;TRY FOR EXISTING SYSERR FILE
	 JRST SEBOF1		;THAT VERSION FAILED, TRY NEXT ONE
SEBOF3:	MOVEM T1,SEBJFN		;SAVE JFN
	MOVX T2,OF%RD+OF%WR
	OPENF
SEBOER:	 JRST [	MOVE T1,SEBJFN	;BAD VERSION, TRY NEXT ONE
		RLJFN
		 JFCL
		SKIPE NEWFLG	;WERE TRYING FOR NEW FILE?
		JRST SEBOF2	;YES, DISASTER
		JRST SEBOF1]	;NO, TRY FOR NEW VERSION
	MOVE T1,SEBJFN
	HRLI T1,.FBBYV
	MOVX T2,<MASKB 6,11>	;SPECIFY BYTE SIZE FIELD
	MOVX T3,^D36B11		;SET IT TO 36-BIT BYTES
	CHFDB
	 ERJMP SEBOER		;ERROR, TRY A NEW FILE
	SKIPE SPRFLG		;HAVE WE SET THE SPEAR SEQUENCE NUMBER YET?
	RETSKP			;YES, RETURN
	SETOM SPRFLG		;NO, THEN DO SO. RESET SETNESS FLAG
	MOVE T1,SEBJFN
	MOVE T2,[1,,.FBSIZ]	;GET LOCATION OF LAST WORD IN ERROR.SYS
	MOVEI T3,T2		;PUT IT IN T2
	GTFDB			
	 ERJMP SEBOER		;ERROR, TRY A NEW FILE
	SKIPN T2		;IS THIS A BRAND NEW FILE?
	RETSKP			;YES, THEN THERE IS NO NEW SEQ. NO AVAILABLE
	SUBI T2,1		;NOT A NEW FILE, BACK UP ONE WORD
	SFPTR			;TO THE INTERNAL EOF WITH THE SEQ. NO ON IT.
	 JRST SEBOER		;ERROR, TRY ANOTHER FILE
	BIN			;READ THE VALUE IN
	 ERJMP SEBOER		;ERROR, TRY ANOTHER FILE
	MOVE T3,T2		;SAVE A COPY
	TLZ T3,777000		;REMOVE THE EOF BITS (777)
	ADDI T3,1		;ADD ONE TO BE IN SYNC.
	MOVEM T3,SPRCNT		;SAVE THE RESULT IN SPRCNT
	LSH T2,^D-27		;GET THE COPY AND SEE IF IT IS VALID
	CAIE T2,777		;BY CHECKING IF THE EOF VALUE WAS 777
	SETZM SPRCNT		;NOT VALID, SET SPRCNT TO START AT 1.
	RETSKP			;AND RETURN

SEBOF1:	MOVX T1,GJ%FOU+GJ%PHY+GJ%SHT
	HRROI T2,SEFLNM
	GTJFN			;TRY FOR NEW VERSION
	 JRST SEBOF2		;TOTAL LOSS
	SETOM NEWFLG		;NOTE NEW FILE STARTED
	JRST SEBOF3

SEBOF2:	BUG.(CHK,SERGOF,SYSERR,HARD,<SETOFI - Cannot GTJFN/OPEN SYSERR file>,,<

Cause:	The SYSERR fork failed to open the ERROR.SYS file for output.
	SYSERR first attempts to get a JFN on a currently existing version
	of the file. If that fails, it attempts to get a JFN for a new
	version of the file. This BUG indicates that both attempts failed.
>,,<DB%NND>)			;[7.1210] 
	MOVX T1,^D60000		;COMPUTE 1 MINUTE FROM NOW
	ADD T1,TODCLK
	MOVEM T1,SEIETM		;WON'T TRY AGAIN UNTIL THEN
	RET			;RETURN FAILURE

SEFLNM:	ASCIZ /SERR:ERROR.SYS/	;[7.1112]
;ROUTINE TO COPY SYSERR BLOCKS FROM BUFFER INTO FILE
;	CALL SEBCHK
;CALLED UNDER JOB 0 ONLY.

SEBCHK::TRVAR <SEBOAD,SEBFBN,SEBWDN,SEBFOF,SEBOLN,SEBOID>
	SETZM SEBFOF		;NOTE SYSERR FILE NOT OPEN
SEBCH0:	CALL UNQSEB		;UNQUEUE NEXT BLOCK
	 JRST [	SKIPN SEBFOF	;NONE, SYSERR FILE OPEN?
		RET		;NO, DONE.
		MOVE T1,SEBJFN	;YES, CLOSE IT
		CLOSF
		 JFCL
		RET]
	MOVEM T1,Q1		;Q1 HOLDS PTR TO BLOCK
	SKIPN SEBFOF		;SYSERR FILE OPEN?
	CALL SEBOFI		;NO, OPEN IT
	 SKIPA			;FAILED, FILE NOT OPEN
	SETOM SEBFOF		;NOTE FILE NOW OPEN
	LOAD T4,SEBFN,(Q1)	;GET FUNCTION
	MOVE T1,Q1		;SETUP BLOCK ADR FOR CALL
	SKIPE T4		;ONE GIVEN?
	CALL 0(T4)		;YES, CALL IT
	SKIPN SEBFOF		;FILE OPEN?
	JRST SEBCHX		;NO, FORGET REST OF PROCEDURE
	LOAD T1,SEBSOF,(Q1)	;get offset to string space
	ADD T1,Q1		;locating address of end of block
	MOVE T2,SPRCNT		;We will tack the SPEAR sequence number
	TLO T2,777000		;in an internal EOF word
	MOVEM T2,0(T1)		;at the end of file after last SPEAR block.
	LOAD Q2,SEBSOF,(Q1)	;GET FINAL LENGTH OF BLOCK
	MOVEI T1,-SEBDAT(Q2)	;LENGTH OF BODY ONLY
	STOR T1,SEHLEN,(Q1)	;SET LENGTH
	SUBI Q2,SEBHED-1	;LESS LOCAL HEADER but with room for eof & seq.
	MOVEM Q2,SEBOLN		;SAVE ORIGINAL LENGTH
	MOVX T1,SEHWD0		;GET HEADER BOILERPLATE
	IORM T1,SEBHED(Q1)	;PUT IN HEADER
	CALL LGTAD		;GET DATE AND TIME (FRACTION)
	STOR T1,SEHTAD,(Q1)
	SUB T1,TADIDT		;COMPUTE UPTIME IN UNIVERSAL UNITS
	STOR T1,SEHUTM,(Q1)
	MOVE T1,APRSER		;[7357] Get APR serial numbern
	STOR T1,SEHSER,(Q1)
	AOSN T1,SPRCNT		;INCREMENT RUNNING COUNT
	 BUG.(INF,SPRZR1,SYSERR,SOFT,<SEBCHK - SPRCNT went to zero>,,<

Cause:	The SYSERR fork keeps a running count of the number of entries made
	on the error file in SPRCNT. This count is continous over system
	reloads and crashes. This BUG indicates that the count has
	overflowed its one word value.

Action:	None. The count has wrapped around, probably legitimately, and will
	be reset to zero.
>,,<DB%NND>)			;[7.1210] Tell someone if wraparound
	STOR T1,SEHCNT,(Q1)
	XMOVEI T1,SEBHED(Q1)	;SETUP PTR TO FIRST WORD TO BE MOVED
	MOVEM T1,SEBOAD
	MOVE T1,SEBJFN		;THE SYSERR FILE JFN
	MOVE T2,[1,,.FBSIZ]	;READ CURRENT EOF POINTER
	MOVEI T3,SEBFBN		;INTO SEBFBN
	GTFDB
	SKIPE SEBFBN		;Is this a new file?
	SOS SEBFBN		;no, then back up and overwrite sequence number
SEBCH1:	MOVE T1,SEBFBN		;COMPUTE PAGE NUMBER AND WORD FOR APPEND
	IDIVI T1,PGSIZ
	MOVEM T1,SEBFBN		;SAVE PAGE NUMBER
	MOVEM T2,SEBWDN		;SAVE WORD NUMBER
	HRL T1,SEBJFN		;CONSTRUCT PAGE IDENT
	MOVEM T1,SEBOID		;SAVE IT
	CALL JFNOFN
	 JRST SEBCHX		;LOSE - DISCARD DATA
	MOVE T2,[PTRW+FPG2A]
	CALL SETMPG		;MAP FILE PAGE
	MOVE T1,SEBWDN		;GET WORD NUMBER
	IDIVI T1,SEBBLK		;GET WORD WITHIN SYSERR BLOCK
	JUMPG T2,SEBCH2		;FIRST WORD?
	MOVE T3,SEBWDN		;YES, STORE POINTER
	MOVEI T4,1		;POINT TO THIS ENTRY UNLESS
	CAME Q2,SEBOLN		;NOT AT BEGINNING
	MOVE T4,Q2		;POINT TO END OF THIS ENTRY (DON'T COUNT EOF)
	CAIL T4,SEBBLK		;WILL THIS ENTRY USE THE ENTIRE BLOCK ?
	MOVEI T4,-1		;YES, MARK NO NEW ENTRY STARTS IN THIS BLOCK
	TLO T4,775000		;SET HIG ORDER BITS TO INDICATE START OF BLOCK
	MOVEM T4,FPG2A(T3)
	 ERJMP [SETZ T1,	;FAILED, UNMAP THE FILE PAGE
		MOVEI T2,FPG2A
		CALL SETMPG	;DO IT
		JRST SEBCHX]	;AND DISCARD THE DATA
	AOS SEBWDN		;NOTE ONE ADDITIONAL WORD USED IN FILE
	MOVEI T2,1		;ACCOUNT FOR POINTER WORD
	; ..
;SEBCHK...

SEBCH2:	MOVN T2,T2		;COMPUTE SPACE LEFT IN CURRENT SYSERR BLK
	ADDI T2,SEBBLK
	MOVE T1,Q2		;GET SPACE NEEDED FOR OUTPUT BLOCK
	CAMLE T1,T2		;LESS THAN SPACE AVAILABLE?
	MOVE T1,T2		;NO, USE ALL SPACE AVAILABLE
	SUB Q2,T1		;UPDATE REMAINING OUTPUT COUNT
	MOVE T2,SEBOAD		;GET POINTER TO OUTPUT DATA
	ADDM T1,SEBOAD		;UPDATE FILE POINTER FOR WORDS BEING DONE
	MOVE T3,SEBWDN		;GET WINDOW OFFSET
	ADDM T1,SEBWDN
	XMOVEI T3,FPG2A(T3)	;MAKE BLT POINTER TO FILE WINDOW PAGE
	EXTEND T1,[XBLT]	;COPY DATA
	SETZ T1,		;UNMAP FILE WINDOW
	MOVEI T2,FPG2A
	CALL SETMPG
	HRLZ T1,SEBJFN		;GET JFN OF FILE
	HRR T1,SEBFBN		;AND PAGE NUMBER
	MOVEI T2,1		;UPDATE 1 PAGE
	UFPGS			;UPDATE FILE PAGES ASAP
	JRST SEBCHX		;OOPS CAN'T DO IT FORGET IT
	MOVE T3,SEBFBN		;COMPUTE NEW EOF PTR
	IMULI T3,PGSIZ
	ADD T3,SEBWDN
	MOVEM T3,SEBFBN
	JUMPG Q2,SEBCH1		;LOOP IF MORE IN OUTPUT BLOCK
	MOVE T3,SEBFBN		;GET FINAL EOF PTR
	SETO T2,		;PUT IT IN FDB
	MOVE T1,SEBJFN
	HRLI T1,.FBSIZ
	CHFDB
SEBCHX:	MOVE T1,Q1		;BLOCK DONE, RELEASE IT
	CALL RELRES
	JRST SEBCH0		;TRY FOR ANOTHER BLOCK
;Routine to scan remaining SYSERR blocks and map calling function
;over them.
;	call site+1/ function to map
;should be called PIOFF
; and map function should keep it that way!!!
;returns
;	+1 always

	RESCD

SYRMAP::MOVE T1,@0(P)		;GET FUNCTION
	SAVEQ			;SAVE REGS
	MOVE Q2,T1		;SAVE FUNCTION
	MOVE Q1,SEBQOU		;GET OUTPUT QUEUE
SYRMP0:	JUMPE Q1,RSKP		;IF AT THEN END, DONE
	LOAD T1,SEHCOD,(Q1)	;GET THE CODE
	MOVE T2,Q1		;BLOCK ADDRESS
	XCT Q2			;DO IT
	LOAD Q1,SEBCDR,(Q1)	;GET CDR
	JRST SYRMP0		;AND CONTINUE

EXTCHK:	SAVET			;CHECK TO SEE IF CALLER CAN REFERENCE HIS DATA
	TXNN T1,VSECNO		;IS ADDRESS OF BLOCK EXTENDED?
	RET			;NO, NO PROBLEM
	MOVE T1,(P)		;YES, GET CALLER PC
	TXNN T1,VSECNO		;IF NOT EXTENDED BUGCHK.
	BUG.(HLT,SBXSE0,SYSERR,SOFT,<SYSERR called from SEC 0 with ext blk>,<<T4,PC>>,<

Cause:	SEBCPY/QUESEB/OR SEBCPY with unextended function call address was
	performed when the SYSERR block was in extended free space.

Action:	The inconsistency must be fixed because it indicates that referencing
	the data block may fail if performed by unextended instructions.

Data:	PC - the PC of the caller to the SYSERR routine.

>)
	RET
	TNXEND
	END