*M*      ERR:FIL  <<TRANSFER ERROR LOG BUFFER TO PUBLIC FILE>>
*P*
*P*      THIS MODULE EXISTS SOLELY TO MOVE THE ERROR LOG RECORDS
*P*      INTO THE PUBLIC FILE 'ERRFILE' IN THE :SYS ACCOUNT.
*P*
*P*      IT CONTAINS A SINGLE ENTRY POINT (THE LMN START ADDRS) AND
*P*      A SINGLE EXIT POINT (RETURN TO SLEEP WAITING FOR THE ERRLOG-
*P*      -ROUTINE TO WAKE IT UP AGAIN).
*P*
*P*      INTER-ACTION BETWEEN 'ERHNDLR' IN THE ROOT AND THIS MODULE
*P*      IS COORDINATED BY HAVING THIS MODULE 'SLEEP' AND
*P*      'ERHNDLR' WAKE IT UP WHENEVER A BUFFER IS WRITTEN OR AN
*P*      BUFFER BLOCKED EVENT OCCUR.
*P*
 TITLE '*** ERROR LOGGING PUBLIC FILE WRITER: <ERR:FIL> ***'
         PAGE
         CSECT    1                 GENERATE PROCEDURE
*
*
         SYSTEM   SIG7FDP
         SYSTEM   BPM
         PAGE
*
*        EXTERNAL DEFINITIONS
*
         DEF      ERR:FIL         MODULE ENTRY POINT
         DEF      PATCH           MODULE PATCH AREA
         DEF      DATA            MODULE DATA AREA
         PAGE
*
*
*        EXTERNAL REFERENCES
*
*
         REF      BOOTFLG         * INDICATES IF SYSTEM REALLY UP
         REF      BUFMSIZ         * MAX BUF USEFUL SIZE
         REF      BUFTSIZ         * MAX BUF SIZE TOTAL
         REF      CORED           *  ACTUAL SIZE OF PHYSICAL MEMORY(+1)
         REF      DCTSIZ          * LENGTH OF DCT TABLES
         REF      DCT1            * DEVICE ADDRESS TABLE
         REF      DCT1A           * ALT DEVICE ADDRESS TABLE
         REF      DCT1P           * PRI DEVICE ADDRESS TABLE
         REF      DCT22           * DISC/NON-DISC FLAG TABLE
         REF      DCT25           * SIO COUNTER TABLE
         REF      DEVMOD#         * MODEL # TABLE
         REF      ERRLOG9         * GET RELATIVE TIME ROTINE IN ERHNDLR
         REF      F:ERF           * FILE WRITER DCB
         REF      J:JIT           * ADDRESS OF JOB INFO TABLE
         REF      JULIAN          * DATA TO JULIAN ROUTINE (JULIAN)
         REF      M:OC              * DCB FOR TYPING TO OC DEVICE
         REF      M16             * DATA OF X'0000FFFF'
         REF      SITEID          * 8 BYTE EBCDIC SITE ID CELL
         REF      Y002            * DATA X'00200000'
*
*        REGISTER ASSIGNMENTS
*
R0       EQU      0
R1       EQU      1
R2       EQU      2
R3       EQU      3
R4       EQU      4
R5       EQU      5
R6       EQU      6
R7       EQU      7
R8       EQU      8
SR1      EQU      8
*
R9       EQU      9
SR2      EQU      9
*
R10      EQU      10
SR3      EQU      10
*
R11      EQU      11
SR4      EQU      11
*
R12      EQU      12
D1       EQU      12
*
R13      EQU      13
D2       EQU      13
*
R14      EQU      14
D3       EQU      14
*
R15      EQU      15
D4       EQU      15
MAXTYPE  EQU      X'53'             CURRENT MAX CODE NUMBER
         PAGE
*F*
*F*      NAME:    ERR:FIL
*F*
*F*      PURPOSE:
*F*               LOAD MODULE START ADDRESS AND THEREFORE THE
*F*               ONLY ENTRY POINT.
*F*
*F*      DESCRIPTION:
*F*               THE VERY FIRST TIME ERR:FIL IS ENTERED IT WILL
*F*               CHECK TO SEE IF THE 'ERRFILE' EXISTS -;
*F*
*F*               IF IT DOES - IT GOES ON AND READS THE NEXT BLOCK
*F*               OF ERROR RECORDS FROM EITHER THE INCORE BUFFERS
*F*               OR THE INTERMEDIATE FILE ERHNDLR IS BUILDING.
*F*
*F*               IF IT DOES NOT - IT WILL BUILD IT CONFORMING TO THE
*F*               C00 DATA BASE TECHNICAL MANUAL.
*F*
ERR:FIL  EQU      %
         CAL1,6   MASTER            GET INTO MASTER MODE
         BCS,8    EXIT1             FOULED OUT....GET OUT
         MTW,0    BOOTFLG           ARE WE REALLY UP/RUNNING
         BNEZ     EXIT1             NO - EXIT OUT OF THHE SYSTEMM
         LI,R5    COPYLOG           FAKE THE BAL INTO HERE
ERR:FIL1 EQU      %
         PSW,R5   TSTACK            REMEMBER RETURN
         M:OPEN   F:ERF,(FILE,'ERRFILE'),(KEYED),(DIRECT),(SAVE),;
                        (TRIES,10),(INOUT),(ERR,ERFERR),(ABN,ERFERR),;
                        (KEYM,8)
         BAL,R1   NEWHOUR           SET UP THE FILE ACCESS KEY
         PLW,R5   TSTACK            RETRIEVE THE LINK
         B        0,R5              AND EXIT W/FILE OPEN
         PAGE
*
*        GET HERE IF FILE NEEDS TO BE BUILT
*
ERR:FIL2 EQU      %
         M:OPEN   F:ERF,(FILE,'ERRFILE'),(OUT),(SAVE),(KEYED),(DIRECT),;
                        (ERR,ERFERR),(ABN,ERFERR),(KEYM,8)
         BAL,R1   NEWHOUR           SET UP KEY
         BAL,R1   TIMESTMP          PUT OUT TIME STAMP RECORD
         BAL,R1   SITID             PUT OUT SITE ID RECORD
         BAL,R1   CODE21            PUT OUT CONFIGURATION RECORD
         BAL,R1   ERR28             PUT OUT I/O ACTIVITY RECORD
         B        COPYLOG           GO ASK FOR A BUFFER
         PAGE
*F*
*F*      NAME:    NEWHOUR
*F*
*F*      PURPOSE:
*F*               TO CONSTRUCT AN HOUR STAMP RECORD FOR THE
*F*               ERROR LOG PUBLIC FILE.
*F*
*F*      DESCRIPTION:
*F*               ERR:FIL COMES HERE AT BOOT TIME AND AT
*F*               EACH NEW HOUR EVERY DAY CP-V IS RUNNING TO
*F*               BUILD AND INJECT A TIME STAMP INTO THE ERROR
*F*               PUBLIC FILE.
*F*
*F*               THE RECORD IS BUILT CONFORMING TO THE COO DATA BASE
*F*               TECHNICAL MANUAL.
*F*
NEWHOUR  EQU      %
         LCFI     0
         PSM,R0   TSTACK
         CAL1,8   TIMECAL           GET CURRENT M:TIME TIME
         LI,SR3   TEMPBLK           POINT TO IT
         BAL,SR4  JULIAN            FOR JULIAN TO FIND
         LI,SR3   8
         STB,SR3  SR1               CREATE KEY LENGTH
         STW,SR1  KEY               CREATE WORD ZERO OF KEY
         BAL,R5   ERRLOG9           GET CURRENT TIME IN MCS/2
         LI,R3    0                 PHONY UP INDEX FOR
         STW,R3   KEY+2             CLEAR COUNTER EVERY MINUTE
         STW,R4   ERRLOG+1          GETIME TO USE
         BAL,R1   GETIME            GO CONVERT TIME TO HHMM
         STW,R8   KEY+1             KEY WORD ONE SET UP
         LCFI     0
         PLM,R0   TSTACK
         B        0,R1              AND EXIT
         PAGE
*F*
*F*      NAME:    CODE21
*F*
*F*      PURPOSE:
*F*               TO CONSTRUCT A SYSTEM CONFIGURATION RECORD TO
*F*               PLACE INTO THE ERROR LOG PUBLIC FILE.
*F*
*F*      DESCRIPTION:
*F*               THE RECORD IS BUILT ONLY AT START-UP TIME
*F*               AND IS BUILT ACCCORDING TO THE STANDARDS
*F*               RECORDED IN THE C00 DATA BASE TECHNICAL MANUAL.
*F*
*
CODE21   EQU      %
         LCI      3
         PSM,R1   TSTACK            SAVE MINIMUM SET
         LI,R5    DCTSIZ            LENGTH OF DCT TABLES
         LI,R4    0                 INITIAL INDEX
CODE21A  LI,R3    X'21'             CODE FOR CONFIG RECORD
         STB,R3   BUF3              SET
         BAL,R1   NEWHOUR           UPDATE KEY W/TIME + DATE
         LI,R6    1
CODE21B  AI,R6    1
         AI,R4    1                 NEXT DCT INDEX
         LW,R10   R4                DCT INDEX
         LH,R3    DEVMOD#,R4        MODE NUMBER FOR THIS DCT INDEX
         STH,R3   R10               PUT TOGETHER
         STW,R10  BUF3,R6           STORE IT IN RECORD
         AI,R6    1
         LH,R2    DCT1A,R4          ALTERNATE DEVICE ADDRESS
         LH,R3    DCT1P,R4          PRIMARY DEVICE ADDRESS
         STH,R2   R3                PUT TOGETHER
         STW,R3   BUF3,R6
         AI,R5    -1                DECREMENT DCT INDEX
         BLEZ     CODE21C           DONE W/RECORDS
         CI,R6    11                HOW MANY ENTRIES IN RECORD
         BL       CODE21B           GET NEXT ONE
CODE21C  EQU      %
         AI,R6    1
         LI,R14   BUF3              LOAD BUFFER ADDRESS
         LW,R13   R6                LOAD BUFFER WORD COUNT
         BAL,R2   WRITBUF           AND WRITE THE BUFFER OUT
         CI,R5    0                 DONE
         BGZ      CODE21A           NOT YET
         LCI      3
         PLM,R1   TSTACK
         B        0,R1
         PAGE
*F*
*F*      NAME:    ERR28
*F*
*F*      PURPOSE:
*F*               TO CONSTRUCT AN I/O ACTIVITY RECORD FOR THE
*F*               ERROR LOG PUBLIC FILE.
*F*
*F*      DESCRIPTION:
*F*               THIS RECORD IS ONLY BUILT AT START-UP TIME
*F*               AND IS CONSTRUCTED BY PICKING UP THE
*F*               CONTENTS OF DCT1 / DCT25 AND WRITING RECORDS
*F*               DIRECTLY INTO THE 'ERRFILE'.
*F*               RECORD FORMAT CONFORMS TO THE C00 DATA BASE
*F*               TECHNICAL MANUAL.
*F*
ERR28    EQU      %
         LCI      3
         PSM,R1   TSTACK
         LI,R4    0
         LI,R5    DCTSIZ
ERR28A   LI,R2    X'28'
         STB,R2   BUF3              CODE SAYING ITS I/O COUNT RECOD
         BAL,R1   NEWHOUR           UPDATE KEY W/TIME + DATE
         LI,R6    1
ERR28B   AI,R6    1
         AI,R4    1                 NEXT DCT INDEX
         LW,R10   R4                DCT INDEX
         LH,R2    DCT1,R4           DEVICE ADDRESS
         STH,R2   R10               TOGETHER W/DCT INDEX
         STW,R10  BUF3,R6           STORED AWAY
         LW,R2    DCT25,R4          GET SIO COUNTER
         AI,R6    1
         STW,R2   BUF3,R6           SAVED
         AI,R5    -1                NEXT DCT INDEX
         BLEZ     ERR28C            DONE
         CI,R6    11                RECORD MAX YET
         BL       ERR28B            KEEP GOING
ERR28C   EQU      %
         AI,R6    1
         LI,R14   BUF3              LOAD BUFFER ADDRESS
         LW,R13   R6                LOAD BUFFER WORD COUNT
         BAL,R2   WRITBUF           AND WRITE THE BUFFER OUT
         CI,R5    0                 DONE YET
         BGZ      ERR28A            NOT YET
         LCI      3
         PLM,R1   TSTACK
         B        0,R1              EXIT OUT
         PAGE
*F*
*F*      NAME:    EXIT
*F*
*F*      PURPOSE:
*F*               TO TEST IF RUNNING AS A GHOST AND IF SO RETURN TO
*F*               SLEEP.
*F*
*F*      DESCRIPTION:
*F*               ANY ROUTINE INTERNALLY WISHING TO BAIL OUT OF
*F*               THE MODULE COMES HERE TO EFFECT THE SLEEP EVENT.
*F*
*F*               IF NOT A GHOST JOB (J:JIT BYTE ZERO BIT ZERO)
*F*               EXIT WILL PERFORM AN EXIT CAL.
*F*
*
EXIT     EQU      %
         LI,R3    0                 CLEAR ACCUMULATOR
         LI,R2    #LOADS            LOAD LOOP COUNTER
EXIT0    EQU      %
         LI,R1    0                 CLEAR EXCHANGE WORD CELL
         EXU      LOADCNT,R2        LOAD VALUE
         AW,R3    R1                ADD TO ACCUMULATOR
         EXU      STORCNT,R2        STORE VALUE AWAY
         BDR,R2   EXIT0             FINISH UP
         CI,R3    0                 ANY HARDWARE ERRORS OBSERVED
         BEZ      EXIT01            NO-GO BACK TO SLEEP
         LI,R15   HEMSG             YES - LETS TELL THE OPERATOR
         CAL1,2   TYPE              ON THE OPERATOR'S CONSOLE
EXIT01   EQU      %
         CAL1,1   CLS:ERF
         LC       J:JIT
         BCS,4    %+2               DEFINITELY A GHOST JOB
EXIT1    CAL1,9   1                 NOT A GHOST
         CAL1,8   SLEEP
*
*
*
*        FALL THRU AND PROCESS ERRORS
*
*
         PAGE
*F*
*F*      NAME:    COPYLOG
*F*
*F*      PURPOSE:
*F*               TO PERFORM THE NEXT ERROR LOG READ CAL
*F*
*F*      DESCRIPTION:
*F*               OPEN THE ERROR LOG FILE DCB IF NESSARY - DO
*F*               THE ERROR LOG READ CAL AND THEN FIGURE OUT IF
*F*               THE INCOMING BUFFER LOOKS REASONABLE.
*F*
*F*               IF THE BUFFER LOOKS VALID - MOVE THE RECORDS INTO
*F*               THE PUBLIC FILE.
*F*
*F*               IF IT DOESN'T - SNAP THE ENTIRE THING INTO THE
*F*               PUBLIC FILE AND THEN READ ANOTHER RECORD.
*F*
COPYLOG  EQU      %
         CAL1,6   RDELFPT           READ A RECORD
         BCS,1    EXIT              NO ERRORS TO GET
         BCS,8    EXIT              NOT :SYS OR JB:PRIV LOW..
         STCF     FLAG              REMEMBER CC'S
         BCR,6    COPYLOG1          NO READ ERRORS ENCOUNTERED
         LI,R1    1                 GOT A READ ERRROR
         B        COPYLOG2
COPYLOG1 EQU      %
         LW,R10   Y002
         CW,R10   F:ERF             IS DCB OPEN NOW
         BANZ     %+2               YEP
         BAL,R5   ERR:FIL1          NO - GO OPEN IT
         LI,R1    3                 ASSUME BUFFER HAS BAD COUNT
         LW,R7    ERRLOG+2          GET COUNT
         BLEZ     COPYLOG2          BAD BUFFER COUNT
         CI,R7    BUFTSIZ           IS COUNT OK
         BLE      COPYLOG3          YES
COPYLOG2 EQU      %
         LI,R3    0                 FLAG BUFFER PRE-PROCESS ERRORS
         BAL,R2   ERRWRITE          PUT OUT COPY EROR RECORD
         B        COPYLOG           ASK FOR ANOTHER BUFFER
         PAGE
*F*
*F*      NAME:    COPYLOG3
*F*
*F*      PURPOSE:
*F*               LOOP POINT EXTRACTING RECORDS FROM THE BUFFER
*F*               JUST OBTAINED.
*F*
*F*      DESCRIPTION:
*F*               PULL OUT THE RECORD INFORMATION AND VERIFY IT.
*F*
*F*               IF THE INFORMATION IS VALID - MOVE THE RECORD
*F*               INTO THE PUBLIC FILE.
*F*
*F*               IF IT ISN'T VALID - WRITE AN ERROR RECORD ABOUT IT
*F*               INTO THE PUBLIC FILE AND THEN SNAP THE
*F*               ENTIRE BUFFER INTO THE PUBLIC FILE.
*F*
COPYLOG3 EQU      %
         CI,R7    BUFMSIZ           IS COUNT POSSIBLE
         BG       COPYLOG2          NO - CNT MUST BE NOT GREATER THAN;
*                                   1 THRU BUFMSIZ
         LI,R3    3                 INITIAL INDEX INTO BUFFER
COPYLOG4 EQU      %                 LOOP RETURN POINT
         LW,R1    ERRLOG,R3         GET ENTRY WORD ZERO
         LH,R13   R1                GET CODE AND COUNT
         STH,R13  ERRTYPE           REMEMBER BOTH OF THEM
         AND,R13  M8                MASK OFF WORD COUNT
         BEZ      COPYLOG6          THATS AN ERROR
         STW,R13  MSGSIZ            SAVE THE SIZE OF THE RECORD
         CI,R13   24                RECORD SIZE OK
         BG       COPYLOG6          NO..
         LB,R4    ERRTYPE           GET RECORD CODE
         BLEZ     COPYLOG6          THATS A BAD CODE TO HAVE...
         BAL,R1   STAMP             CHECK FOR START-UP OR TIME STAMP
         BAL,R1   CHECKMOD          CHECK FOR DEVICE ERROR RECORD
         BAL,R1   GETIME            GET THE TIME CONVERTED
         STW,R8   KEY+1             STORE IT AWAY
         LB,R4    ERRTYPE           GET THE CODE AGAIN
         BEZ      COPYLOG6          *****ERROR*****
         CI,R4    X'15'             IS A DEVICE ERROR
         BNE      COPYLOG5          NOPE
         LW,R1    ERRLOG+11,R3      GET TAPE SN FIELD OF RECORD
         MTH,0    R1                WAS IT AN ANSS TAPE
         BEZ      COPYLOG5          NOPE
         BAL,R1   ANSTAPE           YES - CONVERT SN TO EBCDIC
COPYLOG5 EQU      %
         CI,R4    MAXTYPE           DOES CODE FALL IN RANGE
         BLE      COPYLOG7          YES
COPYLOG6 EQU      %                 NO
         LI,R1    6
         BAL,R2   ERRWRITE          PUT OUT COPY ERROR RECORD
         B        COPYLOG           AND REQUEST ANOTHER BUFFER
         PAGE
*F*
*F*      NAME:
*F*               WRITBUF / WRITBUF1
*F*
*F*      PURPOSE:
*F*               TO WRITE OUT THE CURRENT RECORD INTO THE FILE.
*F*
*F*      DESCRIPTION:
*F*               BAL HERE VIA R2 TO WRITBUF AND HE WILL INSERT THE
*F*               WORD COUNT INTO BYTE 1 OF THE HEADER.
*F*
*F*               BAL HERE VIA R2 TO WRITBUF1 AND HE WILL WRITE THE
*F*               BUFFER AS IS.
*F*
WRITBUF  EQU      %
         LI,R1    1                 INDEX TO INSERT
         STB,R13  *R14,R1           WORD COUNT INTO MESSAGE
WRITBUF1 EQU      %
         LCI      2
         PSM,R1   TSTACK
         LB,R1    KEY+2
         AI,R1    1
         STB,R1   KEY+2
         LI,R2    255
         SW,R2    R1                R2 = # OF ENTRIES LEFT
         STW,R2   REMCOUNT          REMEMBER ORIGINAL #
         SLS,R13  2                 CREATE BYTE COUNT
         M:WRITE  F:ERF,(BUF,*R14),(SIZE,*R13),(KEY,KEY),;
                        (NEWKEY),(WAIT),(ERR,ERFERR),(ABN,ERFERR)
         LCI      2
         PLM,R1   TSTACK
         B        0,R2              RETURN TO CALLER
         PAGE
*F*
*F*      NAME:    COPYLOG7
*F*
*F*      PURPOSE:
*F*               TO WRITE THE CURRENT VALID RECORRD INTO THE
*F*               PUBLIC FILE.
*F*
*F*      DESCRIPTION:
*F*               ONCE THE RECORD HAS PASSED ALL THE TESTS WE COME
*F*               HERE TO ACCOMPLISH THE RECORD WRITE.
*F*
*
COPYLOG7 EQU      %
         MTW,1    #MESSAGES,R4      COUNT TIMES  WE SEE EACH  TYPE
         LW,R13   MSGSIZ            LOAD MSG WORD COUNT
         LI,R14   ERRLOG            BASE OF BUFFER WA
         AW,R14   R3                POINT TO SLOT IN BUFFER
         BAL,R2   WRITBUF1          AND GO WRITE THE BUFFER OUT
         LB,R6    ERRTYPE           GET CODE AGAN
         CI,R6    X'18'             JUST DO A START-UP RECORD
         BNE      COPYLOG8          NO
         BAL,R1   NEWHOUR           REBUILD KEY
         BAL,R1   TIMESTMP          BUILD TIME STAMP
         B        COPYLOG9
COPYLOG8 EQU      %
         CI,R6    X'23'             WAS IT A TIME STAMP
         BNE      COPYLOG9
         BAL,R1   NEWHOUR           REBUILD KEY
         BAL,R1   ERR28             PUT I/O ACTIVITY RECORD
COPYLOG9 EQU      %
         AW,R3    MSGSIZ            ADD LENGTH OF MSG
         CW,R3    ERRLOG+2          STILL FITS...
         BL       COPYLOG4          YES - GET ANOTHER RECORD
         B        COPYLOG           READ ANOTHER BUFFER
         PAGE
*F*
*F*      NAME:    GETIME
*F*
*F*      PURPOSE:
*F*               TO CONVERT RELATIVE MILLISECONDS INTO AN
*F*               HOUR - HOUR - MINUTE - MINUTE FORMAT.
*F*
*F*      DESCRIPTION:
*F*               THE CURRENT RELATIVE MCS FILED IN THE CURRENT
*F*               ERROR LOG RECORD IS EXTRACTED AND DIVIDED
*F*               INTO THE APPROPRIATE HHMM FORM.
*F*
GETIME   EQU      %
         LCI      3
         PSM,R1   TSTACK
         LW,R4    ERRLOG+1,R3       GET MCS/S
         SLS,R4   1                 INTO MCS
         STW,R4   ERRLOG+1,R3       REPLACE IT IN RECORD
         STW,R4   BUF3+1            PUT IT AWAY FOR INTERNAL RECORDS
         LW,R3    R4
         LI,R4    0
         LI,R5    0
         LI,R2    0
         DW,R2    1THOU
         CW,R2    1THOU             REQUIRE ROUNDING
         BL       %+2               NO
         AI,R3    1                 YES..DO SO
GETIME1  LW,R1    TMTABLE,R5
         LI,R2    0
         DW,R2    R1
         CW,R2    R1                REQUIRE ROUNDING
         BL       %+2               NO
         AI,R3    1                 YES..DO SO
         STW,R2   TMCELL            REMEMBER REMAINDER
         LI,R2    0
         DW,R2    TEN
         AI,R2    X'F0'
         AI,R3    X'F0'             BOTHH INTO EBCDIC NUMBERS
         STB,R3   RELTIME,R4        STORE FIRST BYTE
         AI,R4    1
         STB,R2   RELTIME,R4
         AI,R5    1
         AI,R4    1
         LW,R3    TMCELL
         CI,R5    2
         BL       GETIME1
         LW,R8    RELTIME
         CW,R8    MAXTIME
         BL       %+2               IS OKAY
         LW,R8    MAXTIME           NOT OKAY
         LCI      3
         PLM,R1   TSTACK
         B        0,R1
         PAGE
*F*
*F*      NAME:    ANSTAPE
*F*
*F*      PURPOSE:
*F*               TO CHECK IF THE CURRENT ERROR LOG RECORD CONTAINS
*F*               AN ANSS TAPE SERIAL NUMBER.
*F*
*F*      DESCRIPTION:
*F*               THE MODULE 'IOSERCK' IN THE MODULE 'HANDLERS' WHO
*F*               BUILDS I/O ERROR RECORDS HAS PASSED A FLAG
*F*               INDICATING WHETHER OR NOT THE ERROR RECORD
*F*               CONTAINS AN ANSS TAPE SERIAL NUMBER.
*F*
*F*               IF IT DOES - IT IS CONVERTED FROM ITS 'HASHED'
*F*               FORMAT INTO REGULAR EBCDIC AND REPLACED.
*F*
*F*               IF IT DOESNT NO ACTION IS TAKEN.
*F*
ANSTAPE  EQU      %
         LCI      3
         PSM,R1   TSTACK
         LW,R2    ERRLOG+10,R3      GET SN
         SLD,R2   -20
         SLS,R3   -12
         LW,R5    R3
         LI,R6    6                 6 BYTES OF SERIAL NUMBER
ANSTAPE1 SLD,R2   -2
         SLS,R3   -26               SHIFT INTO PERSPECTIVE
         LI,R4    0
         DW,R4    TEN
         OR,R3    R4                INSERT BITS
         BEZ      %+2               OKA
         AI,R3    X'80'
         AI,R3    X'40'
         SLD,R8   -8
         STB,R3   R8
         BDR,R6   ANSTAPE1          FINISH SIX BYTE SN
         LCI      3
         PLM,R1   TSTACK
         STW,R8   ERRLOG+10,R3      STORE EBCDIC SN IN RECORD
         LW,R8    R9
         SLS,R8   -16
         LW,R9    ERRLOG+11,R3
         STH,R8   R9
         STW,R9   ERRLOG+11,R3      REPLACE LAST TWO BYTES OF SN
         B        0,R1              AND EXIT
         PAGE
*F*
*F*      NAME:    STAMP
*F*
*F*      PURPOSE:
*F*               TO PLACE YEAR AND DAY FILEDS INTO THE
*F*               'TIME STAMP' AND STARTUP RECORDS.
*F*
*F*      DESCRIPTION:
*F*               A CAL IS EXECUTED TO GET THE CURRENT
*F*               JULIAN DAY/YEAR (IE; 0 THRU 365 ) SO THAT
*F*               IT CAN BE MERGED INTO THE ERROR RECORD.
*F*
STAMP    EQU      %
         PSW,R3   TSTACK
         CI,R3    0                 INTERNAL TIME STAMP
         BLZ      STAMP1            YEP - GO DO IT
         LB,R4    ERRTYPE           CODE OF RECORD
         LB,R2    STMPTBL           GET LENGTH OF ENTRIES
         CB,R4    STMPTBL,R2        SEE IF CODE APPEARS IN LIST
         BE       STAMP1            GOTCHA
         BDR,R2   %-2
         B        STAMP2            NOPE
STAMP1   CAL1,8   TIMECAL1          GET M:TIME IN TIMS
         STW,R8   ERRLOG+2,R3       STORE YEAR AND DAY
         STW,R8   BUF3+2            SAVE IT FOR INTERNAL CODES
STAMP2   EQU      %
         PLW,R3   TSTACK
         B        0,R1              AND RETURN
         PAGE
*F*
*F*      NAME:    ERRWRITE
*F*
*F*      PURPOSE:
*F*               TO INJECT A SNAP OF THE CURRENT BUFFER INTO
*F*               THE ERROR LOG PUBLIC FILE.
*F*
*F*      DESCRIPTION:
*F*               THIS ROUTINE WILL WRITE THE ENTIRE BUFFER
*F*               INTO THE PUBLIC FILE ALONG WITH AN ERROR CODE
*F*               THAT THE CALLER HAS PASSED.
*F*
ERRWRITE EQU      %
         PSW,R2   TSTACK
         LI,R6    3
         STB,R1   CEREC,R6          INSERT TYPE OF ERROR
         STW,R3   CEREC+2           PUT INDEX INTO COPY ERR RECORD
         LI,R6    0                 ASSUME ERROR
         CI,R3    BUFTSIZ           IS INDEX PROPER
         BG       %+2               YES - INDEX IS NO GOOD
         LW,R6    ERRLOG+1,R3       IS OK - GET TIME FROM RECORD
         SLS,R6   1                 CONVERT TO ACTUAL TIME
         STW,R6   CEREC+1
         LI,R14   CEREC             LOAD BUF WA
         LI,R13   3                 LOAD BUF WORD CNT
         BAL,R2   WRITBUF1          WRITE THE BUFFER
*
         LI,R14   ERRLOG            LOAD THE BUF WA
         LI,R13   BUFTSIZ           LOAD BUFFER WORD CNT
         BAL,R2   WRITBUF1          AND WRITE THE BUF OUT
         PLW,R2   TSTACK
         B        0,R2
         PAGE
*F*
*F*      NAME:    CHECKMOD
*F*
*F*      PURPOSE:
*F*               TO ADD THE DEVICE MODEL # INTO THE ERROR LOG
*F*               RECORD CURRENTLY POINTED TO.
*F*
*F*      DESCRIPTION:
*F*               CALL HERE VIA R1 AND CHECKMOD WILL SCAN
*F*               THE TABLE TO SEE IF YOUR ERROR LOG RECORD NEEDS
*F*               A DEVICE MODEL # PUT INTO IT.
*F*
CHECKMOD EQU      %
         LB,R2    MODTBL            LENGTH OF TABLE
         CB,R4    MODTBL,R2         SCAN LIST
         BE       CHECKMOD1         GOTCHA
         BDR,R2   %-2
         B        0,R1              NOPE
CHECKMOD1 EQU     %
         PSW,R3   TSTACK
         LW,R4    ERRLOG,R3         GET WORD ZERO
         BAL,R9   GETDCTX           SEE IF DCT REQUIRED
         LH,R2    DEVMOD#,R4        GET MODDEL NUMBER
         SLS,R3   1                 WORD INDEX INTO HALF WORD INDEX
         AI,R3    1                 PLUS ONE
         STH,R2   ERRLOG,R3         SET IN MODEL NUMBER
CHKBAD   EQU      %                 HERE IF BAD DEVICE ADDRESS
         PLW,R3   TSTACK            RESTORE R3
         MTB,0    DCT22,R4          IS THIS DEVICE RAD/PACK
         BNEZ     0,R1              YEP - EXIT
         LB,R2    ERRTYPE           GET ERROR MSG CODE
         LB,R4    SUPTABL           GET LENGTH OF TABLE
         CB,R2    SUPTABL,R4        SEE IF RECORD REQUIRES
         BE       CHECKMOD2         YEP
         BDR,R4   %-2               KEEP GOING
         B        0,R1              NOTHING TO DO - EXIT
CHECKMOD2 EQU     %
         LW,R4    MSGSIZ            GET MSG WORD COUNT
         AW,R4    R3                ADD CURRENT INDEX INTO BUFFER
         LI,R2    0
         STW,R2   ERRLOG-1,R4       SUPPRESS SEEK ADDRESS FILED
         B        0,R1              RETURN
         PAGE
*
*
*
GETDCTX  EQU      %
         AND,R4   M16               SCREEN
         CLM,R4   DCTLIMS           IS VALID DCT INDEX
         BCR,9    *R9               YES-> RETURN IT
         LI,R2    DCTSIZ
         CH,R4    DCT1P,R2
         BE       GETDCTX1
         CH,R4    DCT1A,R2
         BE       GETDCTX1
         BDR,R2   %-4
         B        CHKBAD            AND RETURN
*
GETDCTX1 EQU      %
         LW,R4    R2                RETURN THE CORRECT DCT INDEX
         B        *R9
*
         BOUND    8
DCTLIMS  DATA     1,DCTSIZ
*
         PAGE
*F*
*F*      NAME:    ERFERR
*F*
*F*      PURPOSE:
*F*               TO RECEIVE ALL FILE I/O ERRORS / ABNORMAL RETURNS.
*F*
*F*      DESCRIPTION:
*F*               THE ONLY WAY YOU CAN GET HERE IS FROM AN
*F*               ERROR / ABNORMAL RETURN FROM A CAL.
*F*
*F*               ERFERR WILL GO TO A REASONABLE ADDRESS TO ACCOMPLISH
*F*               ERROR RECOVERY FROM THE ERROR/ABNORMAL.
*F*
ERFERR   EQU      %
         LB,R9    R10               GET I/O ERROR CODE
         CI,R9    3                 FILE DOESNT EXITST CODE
         BE       ERR:FIL2          YEP - GO CREATE FILE
         CI,R9    X'75'             IS THE FILE BROKEN
         BE       ERFBRK            YEP - TELL OPERATOR ABOUT IT
         CI,R9    X'2E'             OPENING AN OPEN FILE
         BE       *R8               YEP
         CI,R9    X'57'             DISC SATURATED
         BE       EXIT              YES - EXIT
         CI,R9    10                CLOSING A CLOSED FILE
         BE       *R8               YES - IGNORE
         CI,R9    X'16'             DUPLICATE KEY
         BNE      ERFERR2           NO
         MTB,1    KEY+2             STEP SEQUENCE NUMBER IN KEY
         MTW,-1   REMCOUNT          CHECK FOR DUPE INSERTION COUNTER
         BLZ      *R8               NO MORE ROOM-> SKIP THIS RECORD
ERFERR1  AI,R8    -1                POINT BACK TO CAL
         B        *R8               AND RE-EXECUTE IT
ERFERR2  CI,R9    X'14'             FILE BUSY
         BNE      *R8               NOPE-FLUSH THE CAL
         AI,R8    -1                YES-ADJUST CAL ADDRS
         CAL1,8   SLEEP10           SLEEP FOR TEN SECONDS
         B        *R8               AND GO TRY THE CAL AGAIN
*
SLEEP10  XPSD,0   10
*
         PAGE
*F*
*F*      NAME:    SITID
*F*
*F*      PURPOSE:
*F*               TO CREATE THE SITE ID RECORD INTO THE ERROR FILE.
*F*
*F*      DESCRIPTION:
*F*               YOU CALL HERE VIA R1 AND SITID WILL BUILD A
*F*               SITE ID ERROR LOG RECORD AND PUT IT INTO THE
*F*               ERROR LOG PUBLIC FILE.
*F*
SITID    EQU      %
         LCI      3
         PSM,R1   TSTACK
         LI,R2    X'2205'           CODE AND COUNT
         STH,R2   BUF3
         LW,R2    CORED           GET ACTUAL SIZE OF PHYSICAL MEMORY
         SLS,R2   -13               TO NUMBER OF 8K BLOCKS
         LI,R1    2
         STB,R2   BUF3,R1           STORE IT
         LI,R1    3
         LI,R2    1                 TIME RESOLUTION = MCS
         STB,R2   BUF3,R1
         LW,R2    X'2B'             SYSTEM ID FLAG
         STW,R2   BUF3+2            INTO RECORD
         LCI      2
         LM,R2    SITEID            GET EBCDIC ID CELL
         STM,R2   BUF3+3            SAVED
         LI,R14   BUF3              LOAD BUF WA
         LI,R13   5                 LOAD BUF WORD CNT
         BAL,R2   WRITBUF1          AND WRITE BUFFER OUT
         LCI      3
         PLM,R1   TSTACK
         B        0,R1
         PAGE
*F*
*F*      NAME:    TIMESTMP
*F*
*F*      PURPOSE:
*F*               TO CREATE THE TIME STAMP RECORD INTO THE ERROR FILE.
*F*
*F*      DESCRIPTION:
*F*               YOU CALL HERE VIA R1 AND TIMESTMP WILL CREATE
*F*               THE RECORD AND WRITE IT INTO THE ERROR LOG FILE.
*F*
TIMESTMP EQU      %
         LCI      3
         PSM,R1   TSTACK
         LI,R2    X'2303'           CODE AND COUNT
         STH,R2   BUF3              STORED
         BAL,R1   NEWHOUR           UPDATE KEY
         LI,R3    -1
         BAL,R1   STAMP             INSERT YEAR AND DAY
         LI,R14   BUF3              LOAD BUF WA
         LI,R13   3                 LOAD BUF WORD CNT
         BAL,R2   WRITBUF1          AND WRITE BUFFER OUT
         LCI      3
         PLM,R1   TSTACK
         B        0,R1
         PAGE
*F*
*F*      NAME:    ERFBRK
*F*
*F*      PURPOSE:
*F*               TO TELL THE LOCAL COMPUTER OPERATOR THAT THE
*F*               ERROR LOG FILE APPEARS TO BE BROKEN.
*F*
*F*      DESCRIPTION:
*F*               WE NOTICED IN 'ERFERR' THAT WE HAD GOTTEN AN
*F*               I/O ERROR 75XX - SO WE TELL THE COMPUTER OPERATOR
*F*               THAT THE FILE IS BROKEN AND EXIT THE SYSTEM.
*F*
ERFBRK   EQU      %
         LI,R15   BRKMSG          LOAD MSG ADDRS
         CAL1,2   TYPE            TYPE IT
         B        EXIT1           AND EXIT
TYPE     GEN,8,24 2,M:OC
         PZE      *0
         PZE      *15             MSG ADDRS IN R15
*
HEMSG    TEXTC    '**ERR:FIL->  CENTRAL SYSTEM ERROR RECORDED -',;
                  'CHECK THE ERROR LOG'
*
BRKMSG   TEXTC    '**ERR:FIL->  THE ERROR LOG FILE IS INACESSIBLE'
*
SUPTABL  DATA,1   2,21,18,0         MSG TYPES THAT REQUIRED A LOOK
         PAGE
*
*
*
LOADCNT  EQU      %
         NOP      %
         XW,R1    #MESSAGES+X'17'   GET CPU PARITY ERROR COUNT
         XW,R1    #MESSAGES+X'19'   GET WATCHDOG TIMER COUNT
         XW,R1    #MESSAGES+X'30'   GET PFI PRIMARY COUNT
         XW,R1    #MESSAGES+X'31'   GET MFI PRIMARY COUNT
#LOADS   EQU      %-LOADCNT-1
*
*
STORCNT  EQU      %
         NOP
         AWM,R1   MSG17
         AWM,R1   MSG19
         AWM,R1   MSG30
         AWM,R1   MSG31
*
*
         PAGE
*
*        CONSTANTS USED BY ERR:FIL
*
*        (NOTE:    <<<PROCEDURE>>>
*
TIMECAL  GEN,8,24 16,TEMPBLK      GET REGULAR TIME FPT
TIMECAL1 GEN,8,1,23 16,1,TEMPBLK  GET TIME IN UNITS FPT
*
STMPTBL  DATA,1   2,X'18',X'23',0 **SPECIAL ERROR LOG CODES
*
CLS:ERF  GEN,8,24 21,F:ERF        CLOSE/SAVE ERRFILE FPT
         PZE      *0              GENERATE WORD INDICATING OPTION
         DATA     2               GENERATE WORD SAYING SAVE
*
TMTABLE  DATA     3600,60         USED TO CREATE HHMM FILED FROM
*                                 RELATIVE MCS OUT OF RECORDS
*
*
MODTBL   DATA,1   4,17,18,19,21   ERROR LOG CODES THAT NEED MODEL #
*                                 INJECTED INTO RECORD
*
*
         BOUND    4
*
*
MASTER   GEN,8,24 8,0             MASTER MODE CAL FPT
*
*
MAXTIME  TEXT     '2359'          MAXIMUM TIME IN A SINGLE DAY
*
TEN      DATA     10
*
1THOU    DATA     1000
*
M8       DATA     X'FF'
*
         PAGE
*
*        CREATE DATA (CSECT ZERO) AREA
*
DATA     CSECT    0
*
*
MSGSIZ   DATA     0                 SIZE OF CURRENT MESSAGE IN WORDS
*
BUF3     EQU      %               SPECIAL ERROR LOG RECORD BUFFER
         DO1      12
         DATA     00              GENERATE ROOM FOR MAX RECORD
*
*
RELTIME  DATA     0               USED FOR CREATING HHMM FORMAT
*
*
TMCELL   DATA     0               DITTO
*
*
ERRTYPE  DATA     0               CONTAINS FIRST TWO BYTES OF RECORD
*
*
ERFKEY   GEN,8,24 8,0
         DATA     0,0
KEY      DATA     0,0,0
CEREC    EQU      %
         DATA     X'10030000'       CODE=10  /  COUNT =3
         DATA     0,0               ROOM FOR TIME..ETC..
FLAG     DATA     0
RDELFPT  GEN,8,24 0,ERRLOG
*
SLEEP    XPSD,0   X'FFFF'
*
         BOUND    8
TSTACK   DATA     %+1
         GEN,16,16    32,0
         DO1      32
         DATA     0
         PAGE
*
*        BUFFER TO READ INTO
*
ERRLOG   EQU      %
         DATA     0                 BACK LINK DISC ADDRESS
         DATA     0                 FWD LINK DISC ADDRESS
         DATA     29                # OF WORDS IN THIS BUFFER
************************
         DATA     X'150D0000'
         DATA     14*60*60*500+1000
         DO1      11
         DATA     0
****************************
         DATA     X'23030000'
         DATA     14*60*60*500+1500
         DATA     0
******************************
         DATA     X'11060000'
         DATA     14*60*60*500+2500
         DO1      4
         DATA     0
**********************************
         DATA     X'18040000'
         DATA     14*60*60*500+3500
         DATA     0,0
         DO1      90                RESERVE ROOM FOR BIGGEST BUFFER
         DATA     0
         PAGE
*
*        TEMPBLK IS USED FOR M:TIME BUFFER
*
TEMPBLK  DO1      4
         DATA     0
REMCOUNT DATA     0
         PAGE
*
*        FOLLOWING TABLE CONTAINS COUNTS BY RECORD CODE
*
MSG17    DATA     0               COUNT FOR TYPE 17 KEPT HERE
MSG19    DATA     0                 COUNT FOR TYPE 19
MSG30    DATA     0                 COUNT FOR TYPE 30
MSG31    DATA     0                 COUNT FOR TYPE 31
#MESSAGES EQU     %
         DO1      X'60'           LEAVE ROOM FOR EXPANSION
         DATA     0
*
*        PATCH IS USED FOR ON THE FLY PATCHES OR GENMD'S
*
PATCH    DO1      16
         DATA     0
         END      ERR:FIL

