*M*      CSECOM   CENTRAL SYS CODE COMMON TO SIGMA 9 AND XEROX 560
*P*  NAME:  CSECOM
*P*
*P*  PURPOSE:  PROVIDE MACHINE SPECIFIC CODE FOR HANDLING
*P*            FAULTS ON SIGMA 9 AND XEROX 560; USED IN
*P*            CONJUNCTION WITH THE MODULE CSEHAND AND CSES9
*P*            AND/OR CSEX560.
*P*
*P*  DESCRIPTION:  SEE CSEHAND MODULE FOR OVERVIEW OF FAULT HANDLING
         PCC      0
         TITLE    'CSECOM  -  SIGMA 9 AND XEROX 560 COMMON CODE'
         DEF      CSECOM:           MODULE NAME
CSECOM:  EQU      %
RAWORKS  SET      1                 MAYBE THEY'LL FIX IT SOMEDAY
RAWORKS  SET      0                 BUT RIGHT NOW IT DOESN'T WORK
BITS     SET      1                 GET BT31TO0 BITS
         SYSTEM   UTS
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
R9       EQU      9
R10      EQU      10
R11      EQU      11
R12      EQU      12
R13      EQU      13
R14      EQU      14
R15      EQU      15
         TITLE    'CSECOM  -  REFS AND DEFS'
         REF      CSE%BEST%END%ABORT%STEP SETS ABORT JOB STEP FLAG
         REF      CSE%BEST%END%SCREECH    SETS SCREECH FLAG
         REF      CSE%BEST%END%STOP       SETS HALT FLAG
         REF      CSE%END           EXIT ROUTINE TO SCREECH OR HALT
         REF      CSE%MFIX          MEMORY POLLING ROUITNE FOR I57
         SPACE
         DEF      CSE%LOG%PRIMARY%PFI  LOGS TYPE#30 ENTRY
         DEF      CSE%T4D%FIX       HANDLER FOR TRAP 4D
         DEF      CSE%I57           HANDLER FOR INTERRUPT 57 (MFI)
         DEF      CSE%T4C%FIX%MAP   ROUTINE TO RELOAD MAP, AND ACC
         DO1      RAWORKS
         DEF      CSE%RA%TST        ROUTINE TO TEST RA FLAG IN TRAP PSD
         SPACE
*   DEFS AND REFS FOR CSE BRANCH TABLE ENTRIES AND TARGETS
         SPACE
         DEF      CSE%2:9           CSE BRANCH TABLE TARGET #2 FOR SIG9
         DEF      CSE%2:560         CSE BRANCH TABLE TARGET #2 FOR X560
         DEF      CSE%4:9           CSE BRANCH TABLE TARGET #4 FOR SIG9
         DEF      CSE%4:560         CSE BRANCH TABLE TARGET #4 FOR X560
         DEF      CSE%6:9           CSE BRANCH TABLE TARGET #6 FOR SIG9
         DEF      CSE%6:560         CSE BRANCH TABLE TARGET #6 FOR X560
         DEF      CSE%8:9           CSE BRANCH TABLE TARGET #8 FOR SIG9
         DEF      CSE%8:560         CSE BRANCH TABLE TARGET #8 FOR X560
         DEF      CSE%9:9           CSE BRANCH TABLE TARGET #9 FOR SIG9
         DEF      CSE%9:560         CSE BRANCH TABLE TARGET #9 FOR X560
         DEF      CSE%B:9           CSE BRANCH TABLE TARGET #11 FOR SIG9
         DEF      CSE%B:560         CSE BRANCH TABLE TARGET #11 FOR X560
         SPACE
CSE%2:9   EQ      CSE%MPOLR         MEMORY BANK POLLING ROUTINE
CSE%2:560 EQ      CSE%MPOLR         MEMORY BANK POLLING ROUTINE
CSE%4:9   EQ      CSE%MLOG          MEMORY STATUS LOGGING ROUTINE
CSE%4:560 EQ      CSE%MLOG          MEMORY STATUS LOGGING ROUTINE
CSE%6:9   EQ      CSE%MDEL          C%MSTAT CLEARING ROUTINE
CSE%6:560 EQ      CSE%MDEL          C%MSTAT CLEARING ROUTINE
CSE%8:9   EQ      CSE%GET%CONTENTS  READ AND INHIBIT PE
CSE%8:560 EQ      CSE%GET%CONTENTS  READ AND INHIBIT PE
CSE%9:9   EQ      CSE%T46%FIX       WATCHDOG TIMER HANDLER
CSE%9:560 EQ      CSE%T46%FIX       WATCHDOG TIMER HANDLER
CSE%B:9   EQ      CSE%MDEL%IF%LOGGED C%MSTAT CLEARING
CSE%B:560 EQ      CSE%MDEL%IF%LOGGED C%MSTAT CLEARING
         SPACE
         REF      CSE%1             CSE BRANCH TABLE ENTRY #1
         REF      CSE%3             CSE BRANCH TABLE ENTRY #3
         REF      CSE%5             CSE BRANCH TABLE ENTRY #5
         REF      CSE%7             CSE BRANCH TABLE ENTRY #7
         SPACE
CSE%PPOLR EQU     CSE%1             PROCESSOR POLLING
CSE%PLOG  EQU     CSE%3             PROCESSOR POLL LOGGING
CSE%PDEL  EQU     CSE%5             PSTAT CLEARING
CSE%MFIX%ENTRY  EQU  CSE%7          MEMORY STATUS BIT CHECKING
         SPACE
         REF      CSED%BEST%END     FLAG TO INDICATE EXIT CONDITION
         REF      CSED%LOG%MFI      FLAG TO ALLOW LOGGING MEMORY
*,*                                 STATUS ASSOCIATED WITH MFI
         REF      CSED%MAPPED       FLAG INDICATES MAPPED/UNMAPPED TRAP
         REF      CSED%RTRY%CNT     RETRY COUNTER
         REF      C%MSTAT           MEMORY BANK FAULT STATUS TABLE
         REF      C%MSZE            SIZE OF MEMORY STATUS TABLE
         REF      CSED%PSD          TRAP PSD
         REF      F:INST            TRAPPED INSTRUCTION
         REF      F:EVIRT           VIRTUAL EFFECTIVE ADDRESS
         REF      F:TEMP1           USED AS MFIX FLAG
         REF      F:TEMP2           * TEMP CELL (MOSFIX FLAG)
         REF      CSED%CF           TRAP CC AND FLOATING CONTROLS
         REF      CSED%LINK         TEMP STORE FOR LINK REG
         REF      CSED%SPDF         SOFTWARE BOUBLE FAULT FLAG
         REF      CSED%PATH         TRACK BITS FOR RE-ENTRY
         REF      PSD%I57           INTERRUPT 57 PSD
         REF      CORED             USED IN POLLING MEMORY
         REF      S:CUN             USED IN RELOADING USERS MAP AND ACC
         REF      LMA               USED IN RELOADING USERS MAP
         REF      T:XMMC            USED IN RELOADING USERS MAP
         REF      ERRLOG            LOG HARDWARE FAULTS FOUND
         REF      X0                TABLE CONSTANT
         REF      XFFFF
         REF      CSED%3STAT        MEMORY PE LOCATION TABLE
         REF      3COUNT            COUNT OF BAD MEM LOCATIONS
         REF      3BUFCLR           USED TO CLEAR CSED%3STAT TABLE
         REF      S:ADR             CPU HARDWARE ADDRESS TABLE
         REF      NSCPU             NUMBER OF SLAVE CPUS
         SREF     FB:EFLG           SLAVE FAULT FLAG TABLE
         SREF     F:EADDR           ADDR OF SLAVE ERRLOG ENTRY TABLE
         SREF     COC               RESTART COC AFTER RIO
         SREF     COCGFLG           RESTART COC AFTER RIO
         SREF     MOSTAB            * MOS MEMORY INDICATOR
         SPACE
CSEI%PATH%MPOL  EQU  X'08'          MEMORY POLLING ROUTINE
CSEI%PATH%I57   EQU  X'40'          I57 HANDLER
         SPACE
CSEP%WHY%WD   EQU  1                WATCHDOG TIMER
CSEP%WHY%MAP  EQU  4                MAP PARITY ERROR
CSEP%WHY%T4D  EQU  2                X'4D' TRAP
CSEP%WHY%MPE  EQU  6                MEMORY PARITY ERROR
         SPACE
CSEP%PFI%BIT  EQU  X'800'   B20, WD BIT FOR PFI
CSEP%MPE%BIT EQU  X'800'            * B20, WD FOR SIGMA 7 MEM P.E.
CSEP%S7%MFLIGHTS  EQU X'0010'       * RD,X TO GET SIGMA 7 MFI LIGHTS
CSEP%ARM%ENABLE   EQU X'1200'       * STANDARD ARM & ENABLE EQU
CSEP%DISARM       EQU X'1100'       * STANDARD DISABLE EQU
CSEP%BEST%END%STOP  EQU   4
         SPACE
         BOUND    8
4C4F     DATA     X'4C',X'4F'       I/O INSTR
6C6D     DATA     X'6C',X'6D'       RD,WD INSTR
         TITLE    'CSECOM  -  CSE%MPOLR'
*F*  NAME:  CSE%MPOLR    (CSE BRANCH TABLE ENTRY #2)
*F*
*F*  PURPOSE:  TO POLL THE MEMORY BANK FAULT STATUS REGISTERS
*F*            ON SIGMA 9 AND XEROX 560 MACHINES, PLACING ERROR
*F*            STATUS FOUND IN MEMORY (C%MSTAT)
*F*
*F*  DESCRIPTION:  THIS ROUTINE POLLS EACH MEMORY BANK WITH LMS
*F*                TO FIND ANY FAULT STATUS.  IF ERROR STATUS IS
*F*                FOUND, THE TWO WORDS (X560) OR THREE WORDS (SIG9)
*F*                OF STATUS ARE PLACED IN THE FIRST AVAILABLE ENTRY
*F*                IN THE TABLE C%MSTAT.  THE MACHINE DEPENDANT ROUTINE
*F*                CSE%MFIX%ENTRY IS CALLED TO EXAMINE THE ERROR
*F*                BITS FOR POSSIBLE ACTION, AND THE SCREECH FLAG
*F*                IS SET.  PRESENCE OF MEMORY FAULT STATUS WILL
*F*                ALWAYS CAUSE A SCREECH UNLESS THE ROUTINE IS CALLED
*F*                FROM THE I/O HANDLERS.  IF UNRECOVERABLE ERRORS
*F*                ARE FOUND, THE HALT FLAG IS SET IRREGARDLESS OF
*F*                THE CALLING ROUTINE.
*F*
*F*  REFERENCE:  CP-V OPERATORS REFERENCE MANUAL APPENDIX F.
*F*                    (CONTAINS FORMAT FOR C%MSTAT TABLE)
         SPACE
CSE%MPOLR  EQU    %                 MEMORY POLLING
         SPACE
*   ENTER WITH BAL,R15, ALL REGISTERS VOLATILE
         SPACE
         LI,R3    CSEI%PATH%MPOL    CRITICAL PATH BIT
         STS,R3   CSED%PATH         SET FOR REENTRY DETECTION
         LI,R1    C%MSTAT           WORD INDEX TO MPOLR TABLE
         LI,R0    -1               ENTRY INDEX IN MPOLR TABLE
         LI,R2    16                INDEX TO MEMORY
         LI,R6    4                 SIGMA 9 CAN HAVE 4-WAY INTERLEAVE
         LW,R5    CORED             GET MAX MEMORY
         AI,R5    -1                GET MAX ADDRESS
         BIF,S7S9 CSEM1             * ONLY FOR X560'S
         LI,6     2                 X560 CAN ONLY HAVE 2-WAY
CSEM1    EQU      %
         LI,R4    0                 INTERLEAVING MODIFIER
CSEM2    EQU      %
         LCI      X'8'              LOAD MEMORY STATUS
         LMS,R11  0,R2              WORD ZERO
         CI,11    0                 * IF NEGATIVE, CORRECTABLE (MOS)
         BGEZ     CSEM2A            * NOPE => USE CORE PATH
         LCI      5                 * RESET RCE ON THIS BANK (TEMPORARILY)
         LMS,11   0,2               *
         LCI      8                 * AND GET BACK MSW 0
         LMS,11   0,2               *
         MTW,1    F:TEMP2           * *** TELL US WE HAVE TO SKIP MFI REC
CSEM2A   EQU      %
         BIF,X560 CSEM21            B/ X560 DONT NEED TO SHIFT BITS
         SCS,R11  9                 PUT BITS IN LINE WITH X560 STATUS
CSEM21   SCS,R11  2                 GET B1 FROM X560
         CI,R11   X'7FF'            ARE ANY ERROR BITS SET ?
         BANZ     CSEM4             B/ YES, WE HAVE AN ERROR
CSEM3    EQU      %
         AI,R2    1                 BUMP UP BY ONE
         AI,R4    1                 SO WE CAN COUNT NUMBER OF TIMES BUMPED
         CW,R4    R6                COMPARE WITH MAX INTERLEAVE
         BL       CSEM2             B/ OK TO USE
         SW,R2    R4                SET BUMP=0
         AI,R2    8*1024            8K INCREMENT IS SAFEST
         CW,R2    R5                COMPARE WITH HIGHEST ADDR
         BL       CSEM1             B/ NOT DONE YET
         LI,R2    0                 DONE, RETURN
         STS,R2   CSED%PATH         RESET CRITICAL PATH BIT (USES R3)
         B        *R15              RETURN
CSEM4    EQU      %
         AI,R0    1                 BUMP UP ENTRY INDEX
         CI,R0    C%MSZE            COMPARE W/ MAX INDEX
         BLE      CSEM4B            B/ YES, ROOM TO LOG IT
         LCI      X'C'              READ AND RESET
         LMS,R11  0,R2              IN ORDER TO CLEAR FLT REG
         B        CSEM3             CONTINUE POLLING
CSEM4B   EQU      %
         MTW,0    0,R1              R1=WORD INDEX OF ENTRY WORD 0
         BGEZ     CSEM6             B/ B0 NOT SET, OK TO USE
         AI,R1    3                 GO TO NEXT ENTRY
         BIF,X560 CSEM4             X560 ENTRY SIZE IS 3 WORDS
         AI,R1    1                 SIGMA 9 HAS 4 WORD ENTRY
         B        CSEM4             GO TRY NEXT
CSEM6    EQU      %
         BIF,S7S9 CSEM7             B/ SIGMA 7 OR SIGMA 9
         LCI      X'A'              X560 WORD 1 B'1010'
         B        CSEM8
CSEM7    LCI      X'9'              SIG9 WORD 1 B'1001'
CSEM8    LMS,R11  0,R2              PICK UP MSW1
         STW,R11  2,R1              MSW1=WORD 2 OF MSTAT ENTRY
         BIF,X560 CSEM9             B/ IF X560
         LCI      X'A'              SIG9 WORD 2 B'1010'
         LMS,R11  0,R2              PICK UP MSW2 (SIG9 ONLY)
         STW,R11  3,R1              MSW2=WORD 3 OF MSTAT ENTRY
CSEM9    LCI      X'C'              WORD 0 AND RESET (SIG9 AND X560)
         LMS,R10  0,R2              PICK UP MSW0 AND RESET
         STW,R10  1,R1              MSW0=WORD 1 OF MSTAT ENTRY
         AND,10   Y8                * SBCE SET?
         BGEZ     CSEM9A            * NOPE => CORE PATH
         SPACE    5
*************************************************************
*
*        MOS MEMORY SPECIAL HANDLER SECTION
*                                             JLJ 07/02/78
*
*        SET THE IN-USE FLAG ON THE MSTAT ENTRY
*        EXAMINE THE MSW2 & MSW3 TO GET THE INDEX
*             INTO THE MOSTAB TABLE
*        FETCH THE STATUS WORD; UPDATE THE COUNT
*        IF COUNT = THRESHOLD, DON'T RE-ENABLE SBCE ON
*             THE REQUESTED BANK
*             CHANGE STATUS WORD
*             RESET IN-USE FLAG ON EFFECTIVE WORD
*        IF COUNT < THRESHOLD, RE-ENABLE SBCE ON REQUESTED BANK
*             UPDATE THE COUNT
*             REPLACE THE COUNT
*
*
*************************************************************
*
*        SBCE ERROR THRESHOLD/COUNT TABLE ENTRY:
*
*        0 1                  15 16                      31
*       +-+---------------------+--------------------------+
*       |*|         THRESHOLD  |      CURRENT COUNT        |
*       +-+---------------------+--------------------------+
*
*        *        INDICATES, IF SET, THAT NO MFI'S FROM SBCE ARE TO
*                                   LOGGED FOR THIS BANK
*        THRESHOLD  IS THE VALUE FOR WHICH N-1 ERROR LOG ENTRIES ARE
*                 TO BE MADE
*        CURRENT    IS THE COUNT OF HOW MANY HAVE BEEN LOGGED SO FAR
*
*************************************************************
         SPACE    1
         STW,R10  0,R1              * STORE THE 'INUSE' FLAG
         LI,R4    4                 * 4 BANK BITS
         LI,R7    0                 * ACCUMULATOR
         LW,R11   3,R1              * GET MSW 2 (BANK IN B20-23)
         SLS,R11  -8                * SHIFT OFF THE LOW ORDER
         SLS,R11  28                * UP IN HIGH ORDER NIBBLE
         SPACE    1
MFIMOS1  EQU      %
         SLS,R11  1                 * SHIFT OFF A BIT
         BCS,X'8' MFIMOS2           * DID A '1' SHIFT OFF?...OUT
         AI,R7    1                 * UP THE 'INDEX COUNT'
         BDR,R5   MFIMOS1           * AND TRY AGIN
         SPACE    1
MFIMOS2  EQU      %
         LW,R10   2,R1              * GET MSW 1 (UNIT # IN BIT 7)
         SLS,R10  6                 * DROP HIGH ORDER BITS
         SLS,R10  -28               * AND LOW ORDER BITS
         AW,R7    R10               * ADD IN THE UNIT # INDEX
         LW,R10   MOSTAB,R7         * GET THE STATUS WD FOR THIS BANK
         BLZ      MFIMOS4           * IF NEGATIVE (ALREADY OVER THRESH)
*                                   * DONT DO ANYTHING FOR THIS BANK
*                                   * BUT LEAVE THE SBCE RESET
         SPACE    1
         LH,R11   R10               * GET THE THRESHOLD INTO R11
         AND,R10  XFFFF             * DELETE HIGH-ORDER HALFWD
         AI,R10   1                 * UP THE COUNT........
         CW,R10   R11               * COMPARE COUNT TO THRESHOLD
         BL       MFIMOS3           * IF LESS...EVERYTHINGS FINE
         SPACE    1
         LI,R5    1                 * TELL ERR:FIL TO REPORT OVERFLO
         STS,R5   2,R1              * BY SETTING A RESERVED BIT IN MSW2
         OR,R11   X8000             * PUT IN THE NEGATIVE BIT TO OVERFLO
         SPACE    1
MFIMOS3  EQU      %
         STH,R11  R10               * RESTORE THE STATUS WORD
         STW,R10  MOSTAB,R7         * TO THE TABLE
         LCI      X'4'              * RESTORE SBCE IN ? BANK
         LMS,R10  0,R2              *
         MTW,1    CSED%LOG%MFI      * FLAG ME TO LOG NOW
         B        CSEM9B            * MERGE WITH STANDARD PATH
         SPACE    1
MFIMOS4  EQU      %
         LI,R10   0                 * WELL, CLEAR THE USED ENTRY WORD
         STW,R10  0,R1              * IN MSTAT (SKIP NTH+1 SBCE)
         B        CSEM9B            * MERGE WITH STD PATH
         SPACE    5
CSEM9A   EQU      %
         LW,R10   2,R1              PICK UP MSW1 (FOR X560 = ADDRESS)
         BAL,R14  CSE%MFIX%ENTRY    CHECK MACHINE SPECIFIC BITS
         OR,R10   Y8                SET ENTRY IN USE FLAG
         STW,R10  0,R1              REALL ADDRESS AND FLAGS IN WORD 0
         LI,R11   CSEP%WHY%MPE
         BAL,R12  CSE%BEST%END%SCREECH  SET SCREECH FOR ALL MEM ERRORS
         MTW,1    F:TEMP1           SET FLAG FOR MFIX
CSEM9B   EQU      %
         AI,R1    3                 BUMP UP ENTRY INDEX
         BIF,X560 CSEM3             B/ IF X560 , ENTRY SIZE OF 3 WORDS
         AI,R1    1                 SIGMA 9 HAS 4 WORD ENTRY SIZE
         B        CSEM3             GO LOOK FOR MORE
         TITLE    'CSECOM   -  CSE%MLOG'
*F*  NAME:  CSE%MLOG    (CSE BRANCH TABLE ENTRY #4)
*F*
*F*  PURPOSE:  TO GENERATE TYPE #43 (SIG9) AND TYPE #42 (X560)
*F*            ERROR LOG ENTRIES FORM THE ENTRIES IN C%MSTAT
*F*            ALSO GENERATES TYPE #49 ENTRY (ALL MACHINES) FROM
*F*            THE TABLE CSED%3STAT.
*F*
         SPACE
CSE%MLOG EQU %
         LI,R4    0                 LOG ALL ENTRIES
         B        CSML1
CSE%MLOG%IF%MFI  EQU  %             FOR SIG9 , MFI LOG ONLY OT AND PF
         LI,R4    -1                SET FLAG
CSML1    EQU      %
         LI,R0    4                 MSTAT SIZE FOR SIGMA9
         LW,R7    =X'43060000'      CODE,COUNT FOR SIGMA 9
         BIF,S7S9 CSML2             * ONLY FOR X560'S
         LI,R0    3                 MSTAT ENTRY SIZE FOR X560
         LW,R7    =X'42050000'      CODE,COUNT FOR X560
CSML2    EQU      %
         OR,R7    S:ADR             MERGE IN CPU HARDWARE ADDRESS
         LI,R3    C%MSZE            HIGHEST INDEX TO MSTAT TABLE
         MW,R3    R0                TIMES ENTRY SIZE
         STW,R0   R1                R1 IS ENTRY SIZE
         SCS,R0   -4                POSITION R0 FOR LC/LM
         LI,R6    R7                ADDRESS OF BUFFER
         OR,R6    Y1                DONT ENABLE FLAG
CSML3    EQU      %                 BEGINNING OF LOOP
         LC       R0                ENTRY SIZE
         LM,R9    C%MSTAT,R3        PICK UP THIS ENTRY
         CI,R9    0                 IS THIS ENTRY USED
         BGEZ     CSML5             B/ NO, TRY NEXT ONE
         CI,R4    0                 IS THIS SIGMA9 MFI
         BEZ      CSML4             B/ NO OK TO LOG ALL
         LC       9                 * GET B0 FROM R9
         BCS,8    CSML4             * LOG ME IF SBCE
         CW,R10   Y01               YES, IS THIS POWERFAIL, OVERTEMP
         BAZ      CSML5             B/ NO, DONT LOG IT
CSML4    EQU      %
         OR,R9    Y1                SET LOGGED FLAG
         STW,R9   C%MSTAT,R3        PUT IT IN TABLE WITH FLAG SET
         AND,R9   M24               GET RID OF FLAGS
         BAL,R5   ERRLOG            GO LOG IT
CSML5    SW,R3    R1                SUBTRACT ENTRY SIZE FROM INDEX
         BGEZ     CSML3             B/ GO GET NEXT ENTRY
         MTW,0    3COUNT            ANY 49 DATA ?
         BEZ      *R15              B/ NO RETURN
         LI,R7    X'FFFF'
         LW,R6    S:ADR             GET CPU HARDWARE ADDRESS
         STS,R6   CSED%3STAT        STORE IN BUFFER
         LI,R6    CSED%3STAT        ADDRESS OF ERRLOG IMAGE
         OR,R6    Y1                ERRLOG DONT ENABLE FLAG
         BAL,R5   ERRLOG            GO LOG 49 RECORD
         LW,R5    Y8                SET LOGGED FLAG
         STS,R5   3COUNT
         B        *R15              AND RETURN
         TITLE    'CSEHAND  -  CSE%MDEL'
*F*  NAME: CSE%MDEL   (CSE BRANCH TABLE ENTRY #6)
*F*
*F*  PURPOSE:  ZEROES OUT ENTRIES IN C%MSTAT TABLE AFTER THEY
*F*            HAVE BEEN LOGGED.  ALSO ZEROES OUT CSED%3STAT TABLE
*F*            AFTER IT IS LOGGED.
         SPACE
CSE%MDEL EQU      %
         LI,R9    0                 FLAG FOR ALL
         B        CSMD1
CSE%MDEL%IF%LOGGED  EQU  %
         LI,R9    -1                DELETE ONLY IF LOGGED FLAG
CSMD1    LD,R0    X0                ZERO OUT R0-R1
         LD,R2    X0                ZERO OUT R1-R3
         LI,R4    4                 ENTRY SIZE FOR SIGMA 9
         BIF,S7S9 CSMD2             B/ YES, SIGMA 7/9
         LI,R4    3                 ENTRY SIZE FOR X560
CSMD2    LI,R5    C%MSZE            MAX INDEX OF ENTRIES
         MW,R5    R4                TIMES ENTRY SIZE
         STW,R4   R6                SAVE ENTRY SIZE
         SCS,R4   -4                POSITION SIZE FOR LC/STM
CSMD3    CI,R9    0                 OK TO DELETE ALL
         BE       CSMD4             B/ YES, SKIP CHECK
         LW,R7    C%MSTAT,R5        PICK UP WORD ZERO
         AND,R7   Y1                IS LOGGED BIT SET ?
         BEZ      CSMD5             B/ NO, DONT DELETE
CSMD4    LC       R4                OK TO DELETE
         STM,R0   C%MSTAT,R5        ZERO OUT THIS ENTRY
CSMD5    SW,R5    R6                SUBTRACT ENTRY SIZE
         BGEZ     CSMD3             GO GET ANOTHER
         CI,R9    0                 OK TO DELETE 3DATA ?
         BE       CSMD5B            B/ NO, DONT DELETE
         MTW,0    3COUNT            HAS IT BEEN LOGGED ?
         BGEZ     *R15              B/ NO, RETURN
CSMD5B   EQU      %
         LW,R1    3BUFCLR           MBS SETUP TO CLEAR CSED%3STAT
         MBS,R0   0                 DO IT
         B        *R15              RETURN, ALL DONE
         TITLE    'CSECOM  -  CSE%T4C%FIX%MAP'
*F*  NAME:  CSE%T4C%FIX%MAP
*F*
*F*  PURPOSE:  TO RELOAD THE CURRENT USERS MAP AND ACCESS CODES TO
*F*            CLEAR A PARITY ERROR IN ONE OF THE MAP REGISTERS.
*F*
*F*  DESCRIPTION:  THE ROUTINE LMA IS USED TO RELOAD THE COMPLETE
*F*                MAP, ACCESS CODES AND WRITE LOCK SYSTEM, THEN
*F*                T:XMMC IS CALLED TO RESTORE THE CURRENT USERS
*F*                MAP IMAGE AND ACC.  A RETRY COUNTER IS DECREMENTED
*F*                AND IF ZERO, THE HALT FLAG IS SET, INDICATING
*F*                THAT CONTINUED OPERATION OF THE MACHINE IS NOT POSSIBLE
         SPACE
CSE%T4C%FIX%MAP  EQU  %
         STW,R15  CSED%LINK         SAVE RETURN ADDRESS
         BAL,R11  LMA               LOAD COMPLETE MAP AND ACC
         LW,R4    S:CUN             GET CURRENT USER NUMBER
         BAL,R11  T:XMMC            LOAD USERS MAP IMAGE
         LI,R11   CSEP%WHY%MAP      IN CASE WE ABORT
         MTW,-1   CSED%RTRY%CNT     DECRMT RETRY COUNTER
         DO       RAWORKS
         BGZ      CSE%RA%TST        OK TO RETRY, CHECK RA BIT
         ELSE
         BGZ      CSEASTEP          GO ABORT USERS STEP
         FIN
         BAL,R12  CSE%BEST%END%STOP QUIT, RETRY FAILED
         B        *R15
         SPACE    2
         DO       RAWORKS
CSE%RA%TST  EQU   %
         LW,R1    CSED%PSD+1        GET PSD WORD 2
         CI,R1    X'8'              CHECK RA BIT
         BAZ      *CSED%LINK
         FIN
CSEASTEP  BAL,R12 CSE%BEST%END%ABORT%STEP  CANT RETRY , ABORT STEP
         B        *CSED%LINK
         TITLE    'CSECOM  -  CSE%T46%FIX'
*F*  NAME:  CSE%T46%FIX    (CSE BRANCH TABLE ENTRY #9)
*F*
*F*  PURPOSE:  TO HANDLE WATCHDOG TIMER TRAPS FOR SIGMA 9 AND
*F*            XEROX 560 MACHINES.
*F*
*F*  DESCRIPTION:  FOR SIGMA 9 PHASE ONE (INSTR COMPLETED) TIMEOUT,
*F*                NOTHING IS DONE, FOR SIGMA 9 PHASE TWO AND ALL
*F*                XEROX 560 TIMEOUTS, THE TRAPPED INSTRUCTION
*F*                IS EXAMINED.  IF THE INSTRUCTION IS A READ DIRECT
*F*                OR A WRITE DIRECT WITH MODE OF 2 OR HIGHER THE
*F*                TRAPPED INSTRUCTION IS SKIPPED, CONTINUING
*F*                EXECUTION WITH THE NEXT INSTRUCTION.
*F*
*F*                IF THE TRAPPED INSTRUCTION IS AN I/O INSTRUCTION,
*F*                AN RIO IS ISSUED TO THE IOP WHICH CAUSED THE TRAP,
*F*                A RETRY COUNTER IS DECREMENTED, AND EXECUTION
*F*                CONTINUES WITH THE NEXT INSTRUCTION.  (THE I/O
*F*                INSTRUCTION IS NOT RETRIED.)  IF A COC IS ON THE IOP
*F*                WHICH WAS RESET, COCINIT IS CALLED TO RESTART IT.
         SPACE
CSE%T46%FIX  EQU  %
         STW,R15  CSED%LINK         SAVE RETURN IN CASE COCINIT
         BIF,S7X560 NOTSIG9         * SKIP THIS EXCEPT FOR SIGMA 9'S
         LC       CSED%CF           GET TCC
         BCR,7    *R15              SIGMA 9 PHASE 1 TIMEOUT, RETURN
NOTSIG9  EQU      %
         LB,R1    F:INST            GET INSTRUCTION
         AND,R1   M7                STRIP OFF INDIRECT
         CLM,R1   6C6D              RD OR WD
         BCS,9    NOTRDWD           B/ NO
         INT,R1   F:EVIRT           GET EFF ADDRESS (16 BITS)
         CI,R1    X'2000'           MODE >= 2 ?
         BL       OKOP              B/ NOT EXTERNAL MODE
         MTW,R1   CSED%PSD          INCR. PSD TO SKIP INSTRUCTION
         B        *R15              AND RETURN
NOTRDWD  EQU      %
         CLM,R1   4C4F              IS IT I/O INSTRUCTION ?
         BCS,9    OKOP              B/ NO
         LI,R2    COC               YES, CHECK FOR COC @ THIS IOP
         BEZ      OKOP              B/ NON COC SYSTEM
         LW,R2    F:EVIRT           GET I/O ADDRESS
         LI,R3    X'1F00'           MASK FOR IOP ADDRESS
         RIO,0    0,R2              RIO TO IOP TO CLEAR IT
         LW,R0    Y0004             SET TO DELAY
         BDR,R0   %
         LI,R1    X'800'            L/CSECOM-CALLING-COCINIT FLAG
         STS,R1   COCGFLG           S/COC GHOST FLAG; CLOCK3/T:COCHC WILL
*                                   .. CALL COCINIT IN PIGEON/COCG
         MTW,-1   CSED%RTRY%CNT     DECR RETRY COUNT
         BGZ      *CSED%LINK        RETURN IF NOT EXHAUSTED
OKOP     EQU      %
         LI,R11   CSEP%WHY%WD       WHY CODE
         BAL,R12  CSE%BEST%END%ABORT%STEP SET UP TO ABORT STEP (SCREECH)
         B        *CSED%LINK        RETURN
         TITLE    'CSECOM  -  CSE%T4D%FIX'
*F*  NAME:  CSE%T4D%FIX
*F*
*F*  PURPOSE:  TO HANDLE INSTRUCTION EXCEPTION TRAPS
*F*
*F*  DESCRIPTION:  SETS SCREECH FLAG TO CAUSE SC24
         SPACE
CSE%T4D%FIX  EQU  %
         LI,R11   CSEP%WHY%T4D
         BAL,R12  CSE%BEST%END%SCREECH  MUST BE MASTER MODE
         B        *R15                    OR WE WOULDN'T BE HERE
         TITLE    'CSECOM  -  CSE%GET%CONTENTS'
*F*  NAME:  CSE%GET%CONTENTS       (CSE BRANCH TABLE ENTRY #8)
*F*
*F*  PURPOSE:  TO FETCH LOCATION FROM MEMORY WITHOUT CAUSING
*F*            ANY PARITY RELATED TRAPS OR INTERRUPTS
*F*
*F*  DESCRIPTION:  USES LMS - READ AND INHIBIT PARITY ERROR TO PICK
*F*                UP THE CONTENTS OF THE REQUESTED LOCATION, LMS
*F*                CC INDICATE WHETHER OR NOT AN ERROR EXISTS.
         SPACE
CSE%GET%CONTENTS  EQU  %
         SPACE
*   ENTER WITH REAL WORD ADDRESS IN R0, LINK IN R13
*   RETURN WITH CONTENTS IN R0, CC4=1 IF PARITY ERROR, 0 IF NOT
         SPACE
         BIF,S7   CSEGCS7           * GET SIGMA 7 CONTENTS
         LCI      X'1'              READ AND INHIBIT PARITY
         LMS,R0   *R0               GET CONTENTS
         STCF     R2                SAVE CC FOR CALLING ROUTINE
         BCS,X'C' CSGET1            B/ PAR ERROR
         LCI      0                 NO ERROR
         B        *R13
CSGET1   LCI      1                 PARITY ERROR OR DATA BUS CHECK
         B        *R13
         SPACE    3
*
*
*        SPECIAL CASE HANDLER FOR 'MOS MEMORY SIGMA 7'S'
*
*        FUNCTIONS THE SAME AS READ-AND-INHIBIT PARITY FOR
*        SIGMA 9'S (BUT 7'S DON'T HAVE THE INSTRUCTION)
*
CSEGCS7  EQU      %
         LI,R10   CSEP%MPE%BIT      * DISARM SIGMA 7 MEM P.E. INT
         WD,R10   CSEP%DISARM       * ***************************
         SPACE    1
         RD,R11   CSEP%S7%MFLIGHTS  * READ AND CLEAR MFI LIGHTS
         SPACE    1
         LW,0     *0                * GET THE CONTENTS
         SPACE    1
         RD,R11   CSEP%S7%MFLIGHTS  * READ AND CLEAR MFI LIGHTS
         WD,R10   CSEP%ARM%ENABLE   * RE-ESTABLISH I56 AS MEM P.E. INT
         SPACE    1
         CI,R11   0                 * CHECK THE MEM PARITY ERROR LIGHTS
         BEZ      *13               * NOPE....GOBACK (CC'S O.K.)
         SPACE    1
         LCI      X'1'              * RESET THE CC'S CORRECTLY
         B        *13               * BACK TO CALLER
         TITLE    'CSECOM  -  CSE%I57  -  MFI'
*F*  NAME:  CSE%I57
*F*
*F*  PURPOSE:  HANDLER FOR INTERRUPT 57 - MEMORY FAULT INTERRUPT
*F*
*F*  DESCRIPTION:  SAVES ENVIRONMENT IN UNMAPPED TSTACK (ASSUMES ROOM)
*F*                DISARMS PFI,
*F*                POLLS PROCESSORS FOR FAULT STATUS,
*F*                POLLS MEMORY BANKS FOR FAULT STATUS,
*F*                POLLS MEMORY FOR INDIVIDUAL PARITY ERRORS,
*F*                LOGS TYPE #31 (MFI) ERROR LOG ENTRY,
*F*                LOGS PROCESSOR FAULT STATUS (IF ANY),
*F*                LOGS MEMORY BANK FAULT STATUS (IF ANY),
*F*                LOGS MEMORY LOCATION POLLING STATUS (IF ANY),
*F*
*F*      IF A MULTIPROCESSING SYSTEM THEN CHECKS TO SEE IF
*F*      ANY SLAVE ERRLOG ENTRIES SINCE A T4C IN THE SLAVE MAY CAUSE AN
*F*      MFI WHICH IS PROCESSED BY THE MASTER.
*F*      IF THERE ARE ANY SLAVE ERRLOG ENTRIES THEN A CALL IS
*F*      MADE TO ERRLOG TO CREATE THE ENTRY AND UPON RETURN THE FLAG IS
*F*      RESET
*F*                IF THE POLLING ROUTINES DID NOT DETECT ANY
*F*                SERIOUS ERRORS, RETURN IS TO THE INTERRUPTED
*F*                PROCESS, OTHERWISE SYSTEM RECOVERY OR SYSTEM
*F*                HALT IS EFFECTED BY TRANSFERRING CONTROL TO THE
*F*                TRAP HANDLER EXIT ROUTINE CSE%END.
CSE%I57  EQU      %
         STW,R1   CSED%LINK         SAVE R1
         LI,R1    CSEI%PATH%I57     PATH BIT FOR I57
         STS,R1   CSED%PATH         SET FOR REENTRY CHECK
         LW,R1    CSED%LINK         RESTORE IT
         PUSH     16,R0             SAVE ALL REGS IN TSTACK
         LI,R2    CSEP%PFI%BIT      WD BIT FOR PFI
         WD,R2    X'1100'           DISARM PFI
         LI,R0    0
         STW,R0   CSED%BEST%END     CLEAR BEST END FLAG
         STW,R0   CSED%LOG%MFI      CLEAR ERROR LOGGER FLAG
         BAL,R15  CSE%MPOLR         MEMORY POLLING
         BIF,S7   CSMFIC            * SKIP IF SIGMA 7
         BAL,R15  CSE%MFIX          LOOK AT MEMORY ERRORS
         B        %+2               * IF CORRECTABLE....LOG IT
CSMFIC   EQU      %
         BAL,15   CSE%MLOG          * GO LOG SIGMA 7 CORRECTABLES
         MTW,0    CSED%LOG%MFI      CHECK LOGGER FLAG
         BEZ      CSMFI1            B/ NO, SOMEONE ELSE WILL
         MTW,0    F:TEMP2           * WAS THIS A MOS SBCE MFI?
         BNEZ     %+3               * SKIP PPOLR AND MFI PRIM RECS
         BAL,R15  CSE%LOG%PRIMARY%MFI
         BAL,R15  CSE%PLOG          LOG PPOLR SECONDARIES
         BAL,R15  CSE%MLOG%IF%MFI  LOG ONLY THOSE NOT DUALLY REPORTED
         LI,R1    NSCPU             MP SYSTEM
         BEZ      CSMFIA            NO
         MTW,0    FB:EFLG           ANY SLAVE FAULTS AT ALL
         BEZ      CSMFIA            NOPE
         LI,R3    0                 ZERO VALUE
         MTB,0    FB:EFLG,R1        IS IT THIS ONE
         BNEZ     CSMFIN            YEP GO PROCESS
CSMFIB   BDR,R1   %-2               GET NEXT ENTRY
CSMFIA   EQU      %                 ALL DONE
         LI,R0    CSEP%BEST%END%STOP
         CW,R0    CSED%BEST%END
         BG       CSMFI1
         LI,R0    0                 NO, SET UP FOR CSE%END EXIT
         STW,R0   CSED%SPDF         RESET REENTRY FLAG
         STW,R0   F:TEMP2           * CLEAR MOS LOGGER FLAG
         STW,R0   CSED%MAPPED       RESET MAPPED FLAG
         LD,R0    PSD%I57           MOVE PSD
         STD,R0   CSED%PSD
         CW,R0    Y004              CHECK MAPPED BIT
         BAZ      CSE%END           GO EXIT (SCREECH OR STOP)
*                                   NOTE TSTACK NOT PULLED
*                                   SAVE IT FOR RECOVERY
         MTW,1    CSED%MAPPED       SET MAPPED FLAG
         B        CSE%END           GO EXIT
         SPACE
CSMFI1   EQU      %
         BAL,R15  CSE%PDEL          CLEAR PSTAT (PPOLR TABLE)
         BAL,R15  CSE%MDEL%IF%LOGGED  CLEAR MSTAT (MPOLR TABLE) IF LOGGED
         BIF,S7S9 CSMFI2            B/ SIG7 SIG9 (DONT ARM PFI)
*                                        IF SIG7 I56 SHOULD BE ARMED
         LI,R1    CSEP%PFI%BIT      WD BIT FOR PFI
         WD,R1    X'1200'           ARM PFI
CSMFI2   LI,R0    0
         LI,R1    CSEI%PATH%I57     PATH BIT FOR I57
         STS,R0   CSED%PATH         RESET REENTRY FLAG
         PULL     16,R0             RESTORE REGS
         LPSD,X'B'  PSD%I57         GO BACK WITH NEW RP, MFI CLEARED
CSMFIN   EQU      %                 PROCESS SLAVE FAULT ERRLOG ENTRY
         LW,R6    F:EADDR,R1        GET ADDRESS OF BUFFER
         OR,R6    Y1
         BAL,R5   ERRLOG            LOG IT
         STB,R3   FB:EFLG,R1        ZERO OUT ENTRY
         B        CSMFIB            GET NEXT
         TITLE    'CSECOM   -  CSE%LOG%PRIMARY%PMFI'
CSE%LOG%PRIMARY%PFI  EQU  %
         LW,R3    =X'30020000'      CODE,COUNT,SHADED
         B        CSLP1
CSE%LOG%PRIMARY%MFI  EQU  %
         LW,R3    =X'31020000'      CODE,COUNT,SHADED
CSLP1    EQU      %
         OR,R3    S:ADR             MERGE CPU HARDWARE ADDRESS
         LI,R6    R3                ADDRESS OF MSG
         OR,R6    Y1                DONT ENABLE/DISABLE FLAG
         BAL,R5   ERRLOG            GO DO IT
         B        *R15              RETURN
         END

