*M* INITRCVR RECEIVER FOR RCVPSD. READ RECOVER INTO CORE.
*P* NAME: INITRCVR
*P* DESCRIPTION:
*P* SCREECH:  HALT ALL I/O.
*P*           DUMP CORE X'4000'-X'7FFF' TO SWAPPER.
*P*           READ RECOVER AT X'4000'.
*P*           BRANCH TO RECOVERY ENTRY POINT.
*P* SUA:  CHECK ALL SUA CONDITIONS, IF NOT SATISFIED GO TO SCREECH.
*P*       HALT I/O ON SWAPPER CHANNEL AND DUMPFILE DEVICE CHANNEL
*P*         IN SUCH A WAY THAT I/O CAN BE RESTARTED.
*P*       DUMP CORE AT X'4000'-X'7FFF'.
*P*       READ RECOVER INTO CORE AT X'4000'.
*P*       BRANCH TO SUA ENTRY POINT IN RECOVER.
*P*       READ MONITOR BACK INTO CORE AT X'4000'.
*P*       RESTART I/O ON SWAPPER CHANNEL AND DUMPFILE DEVICE CHANNEL.
*P*       START GHOST JOB RVGHOST.
*P*       GO TO T:ABORTM MAPPED.
*P* DUMP:  CHECK FOR DUMPFILE BUSY, IF BUSY RETURN TO CALLER AT XPSD+2.
*P*        EXECUTE SUA TO TAKE CORE DUMP.
*P*        RETURN TO CALLER AT XPSD+2.
         DEF      STOPIO,STOPIOA
         DEF      INITRCVR:
*,*               PATCHING DEF FOR XDELTA
         DEF      RECOVER0
*,*               PATCHING DEF FOR XDELTA.
         DEF      RESTRTIO
*,*               ROUTINE TO CLEANUP I/O TABLES FOR SUA, DUMP AND
*,*               POWER FAIL-SAFE.
         DEF      SUARTN
*,*               RETURN POINT FOR SUA DUMP ROUTINE IN CYCUSR.
         DEF      MPCLD
         REF      DUMPFILE
*,*               INFORMATION WORD FOR THE SUA DUMPFILE.
         REF      MPPSEEK
*,*               DEVICE SEEK ADDRESS OF MONITOR LOCATION
*,*               X'4000' ON PRIMARY SWAPPER.
         REF      RCVCODE
*,*               CODE, SUBCODE OF LAST RECOVERY.
         REF      RCVDISC
*,*               DEVICE SEEK ADDRESS OF RECOVERY ON PRIMARY SWAPPER.
*
*
*,*               ENTRY PSD FOR SCREECH, SUA AND DUMP.
         REF      RCVSIZE
*,*               BYTE SIZE OF RECOVERY ON PRIMARY SWAPPER.
         REF      RCVSTART
*,*               START ADDRESS OF RECOVERY.
         REF      SAVEREGS
*,*               SAVE AREA FOR REGISTER BLOCK ZERO.
         REF      SAVEREGS1
*,*               SAVE AREA FOR REGISTER BLOCK ONE.
         REF      SEEK4000
*,*               DEVICE SEEK ADDRESS TO DUMP CORE X'4000'-X'7FFF'.
         REF      SUABTFLE
*,*               SYSTEM DISK ADDRESS OF SUA DUMPFILE.
         REF      SUACNT
*,*               COUNT OF SUA'S SINCE LAST CRASH.
         REF      SUACUN
*,*               USER NUMBER OF LAST FOUR SUA'S
         REF      SUATIME
*,*               TIME OF LAST FOUR SUA'S.
         REF      TRAPPSD
*,*               CELLS TO SAVE THE TRAP PSD.
         REF      CRASHTYP          TYPE OF CRASH PROCESSING.
*,*                                   0= DUMP
*,*                                   1= SUA
*,*                                   2= SLOW PATH
*,*                                   4= FAST PATH
         REF      RCVBASE
         REF      RCVPSD
         REF      REDDWD
         REF      SAVEDCTX
         REF      SEEK
         REF      SEEK1
         REF      TDV%STATUS
         REF      TIO%STATUS
         REF      BOOTFLG,UB:US,SCU
         REF      DCT9
         REF      DUMPCOM,COMMPACK
*
INITRCVR: EQU     %
*
         REF      CSED%PATH         TRACK BITS FOR FAULT HANDLERS
CSEI%PATH%RECOV EQU  X'02'
         REF      UB:OV
         REF      DCT1
         REF      LOW,DCT24
         REF      DCTSIZ,DCT3
         REF      CIT1,DCT1P,DCT2,DCT4,FORCEIO,INTSIM,IOQ2
         REF      IOQ3,IOQ4,IOQ5,IOQ7,M5,TB:FLGS,M7
         REF      RCVRCNT
         REF      RT:RCVR
         REF      PFSRSW
         SREF     SB:STATE          MP SLAVE STATE
         SREF     SYSTRT            SLAVE SYS START
         SREF     NSCPU             #SLAVES
         SREF     SB:RCVR           MASTER RCVR FLAG
         SREF     SB:RCVA           SLAVE ACK RCVR FLAG
         SREF     T:SIDLER          SLAVE RTN FOR SUA
         REF      MP:HPN            GET HARDWARE CPU ADDRESS
         REF      S:ADR             CPU HARDWARE ADDRESS TABLE
         SREF     SLVWAIT           SLAVE BAIL OUT IF GET HERE
         SREF     S:STOUT           SLAVE TIMEOUT VALUE
         REF      C:TIC,C:TINC
         REF      T:ABORTM
         REF      S:CUN
         REF      JX:CMAP
         REF      J:JIT
         REF      UX:JIT
         REF      CORED
         REF      SMUIS
         REF      MING,JTELFLGS
         REF      T:GJOBSTRT
         REF      MB:SDI
         REF      DCT5
         REF      DCT6
         SREF     CO:INTFL
         REF      DCT1A
         REF      MAXOVLY
         SREF     MPCNTBL
         REF      P:NAME
         REF      PH:PDA
         REF      S:DP
         SREF     PB:C#
         REF      MPCD2
         REF      MPCD3
         SREF     #MPC,MPCTYPE
         REF      MPCRTN
         REF      MPCCHN
         REF      MPCCLIST
         REF      MPCRESTR
         REF      MPCSEEK
         REF      MPCSEEK1
         REF      MPCWRITE
R0       EQU      0
R1       EQU      1
R2       EQU      2
R3       EQU      3
R4       EQU      4
R5       EQU      5
R6       EQU      6
R7       EQU      7
SR1      EQU      8
R8       EQU      8
SR2      EQU      9
R9       EQU      9
SR3      EQU      10
R10      EQU      10
SR4      EQU      11
R11      EQU      11
D1       EQU      12
R12      EQU      12
D2       EQU      13
R13      EQU      13
D3       EQU      14
R14      EQU      14
D4       EQU      15
R15      EQU      15
         PAGE
:CDW     CNAME
         PROC
         BOUND    8
LF       GEN,8,24,8,24  AF(1),;     ORDER CODE
                        AF(2),;     ADDRESS
                        AF(3),;     FLAGS
                        AF(4)       SIZE
         PEND
*
CC       EQU      X'28'             COMMAND CHAIN FLAGS
DC       EQU      X'A8'             DATA CHAIN FLAGS
SIL      EQU      X'2A'             SUPPRESS INCORRECT LENGTH FLAGS
NCC      EQU      X'08'             NO COMMAND CHAINING
DISCBPROC SET     1
         SYSTEM   UTS
         BOUND    8
DUMPCOMX EQU      %
         GEN,8,24 1,4*0             PRE-DUMP 0-X'3FFF'
         GEN,8,24 X'28',0
         GEN,8,24 1,4*X'4000'       PRE-DUMP X'4000'-X'7FFF'
         GEN,8,24 8,0
*
MPCRCAR  :CDW     3,BA(MPCRESTR),NCC,5
*
RESTORE  DATA     X'33000000'       RESTORE ORDER CODE
         DATA     0
MPBRANCH B        SYSTRT            SLAVE SYS STARTLOOP
MPBRANCH2 B       T:SIDLER          SLAVE RTN FOR SUA
X10      DATA     X'10'
Y004     DATA     X'00400000'
Y07      DATA     X'07000000'
M9       DATA     X'1FF'
         PAGE
*
*
*  ENTER FROM RCVPSD WITH INHIBITS ON, MAP OFF, AND CC = 0
*F*      NAME:        RECOVER0
*F*      PURPOSE:     RECEIVER FROM RCVPSD TO START A SCREECH,
*F*                   SUA, OR DUMP.
RECOVER0 EQU      %
         LRP      X10               GO TO RP 1
         STM,R0   SAVEREGS1         SAVE REGISTER BLOCK ONE
         LRP      Y004              GO TO REGISTER BLOCK ZERO
         STM,R0   SAVEREGS          SAVE REGISTER BLOCK ZERO
         RD,0     0                 GET SENSE SWITCH SETTINGS AT TIME OF F CRASH
         STCF     PFSRSW            SAVE FOR DUMP OUTPUT
         LI,13    CSEI%PATH%RECOV   SET FLAG FOR FAULT HANDLERS
         STS,13   CSED%PATH
         LI,1     NSCPU             MP SYSTEM
         BEZ      NOMP              NO,SKIP THIS
         LW,14    MPBRANCH          STORE SLAVE BRANCH
         STW,14   SYSTRT            IN SYSTRT
         BAL,R11  MP:HPN            GET HARDWARE ADDRESS
         CW,R8    S:ADR             AM I MASTER ?
         BE       %+2               YES
         BAL,R11  SLVWAIT           NO,SLAVE BAILOUT
         LI,R14   -1
         STW,R14  SB:RCVR
         LW,14    S:STOUT           MAX # OF TRIES
RESTRT   LI,13    0                 FLAG FOR ANY FAILURES
         LI,R1    NSCPU             #OF SLAVES
GETN     MTB,0    SB:RCVA,R1        SLAVE ACKED
         BNEZ     GTN               YES
         MTB,0    SB:STATE,R1       WAS IT STOPPED
         BEZ      GTN               YES
         AI,13    1                 NO,SET CHECK FAILURE
GTN      BDR,R1   GETN              ALL DONE
         AI,13    0                 ANY CHECK FAILURES
         BEZ      NOMP              NO:
         BDR,14   RESTRT            YES,GO TRY AGAIN
NOMP     EQU      %                 YEP
         LI,14    X'1FFFF'          L/WORD ADDRESS MASK
         AND,14   RCVPSD            & XPSD ADR + 1
         LI,13    X'30001'          L/SCREECH CODE FOR BAD SCREECHES
         CI,14    15                C/XPSD ADR + 1 W/15
         BG       RCV50             BG; SCREECH CODE NOT IN REGS
         AI,14    SAVEREGS          ASSUME IN REG BLK ZERO
         LW,R1    RCVPSD+1
         CI,R1    X'10'             CHECK REG BLK POINTER
         BAZ      RCV50             ZERO
         AI,14    SAVEREGS1-SAVEREGS  POINT TO BLK 1 REGISTERS
RCV50    LH,1     RCVPSD            L/LH OF WD 0 OF PSD
         CI,1     X'40'             CHECK MAP BIT
         BAZ      RCV60             B/RESET; NO MAPPING PROBLEMS
         CI,14    X'8000'           C/XPSD ADR + 1 W/.8000
         BL       RCV60             BL; XPSD IN ROOT
         LW,5     14                L/XPSD ADR + 1
         SLS,5    -9                SHIFT; G/VIRTUAL PAGE #
         LW,2     S:CUN             L/CURRENT USER #
         CI,2     SMUIS             C/CUR USER # W/MAX
         BG       RCV41             BG; ILLEGAL USER #; SCREECH 03-01
         LOAD,2   UX:JIT,2          L/PHYSICAL PAGE # OF USER'S JIT
         SLS,2    9                 SHIFT; GET WORD ADR OF JIT
         AI,2     JX:CMAP-J:JIT     +WORD DISP FROM JIT TO CMAP
         CW,2     CORED             C/ADR W/# OF WORDS OF PHYS CORE
         BGE      RCV42             BGE; UX:JIT PROBABLY BAD; SCR 03-02
         LOAD,2   *2,5              L/PHYSICAL PAGE # OF XPSD ADR + 1
         SLS,2    9                 SHIFT; GET WD ADDR OF PHYSICAL PAGE
         CW,2     CORED             C/ADR W/# OF WDS OF PHYS CORE
         BGE      RCV43             BGE; JX:CMAP PROBABLY BAD; SCR 03-03
         AND,14   M9                &(XPSD ADR + 1) W/.1FF
         AW,14    2                 G/PHYS WD ADR OF XPSD + 1
RCV60    LI,D2    X'F00FF'
         AND,D2   *D3               GET SCREECHCODE,SUBCODE
         BNEZ     RCV41             BNEZ
         LW,13    SAVEREGS+15       L/SCREECH CODES FROM SAVEREGS+15
         CI,13    -1**16            SEE IF LH OF R15 IS NON-ZERO
         BANZ     %+2               BANZ; R15 HAS CODE & SUBCODE
         SLS,13   16                SHIFT; R15 HAD ONLY SCREECH CODE
RCV41    STW,13   RCVCODE           S/SCREECH CODE AND SUBCODE
         LW,R4    RCVBASE           RECOVER BIAS
         AW,R4    RCVSIZE           PLUS SIZE
         AND,R4   =X'FFFFFF'
         AI,R4    X'7FF'            BOUND UP
         SLS,R4   -11               PAGE AFTER RECOVERY
         LI,D1    X'300'
         LI,D2    X'300'
         AND,D1   *D3               SCREECH,SUA,DUMP
         BEZ      RCV1              SCREECH
         STS,D1   RCVCODE           SAVE SCREECH,SUA,DUMP FOR ANLZ
         CI,D1    X'200'
         BE       DUMP              DUMP
         BG       MPC1              ',F' KEYIN DOWNLOAD FIRMWARE
         CW,R4    LOW               OVERLAP USER AREA
         BG       RCV1              YES-CANT SUA
         LH,D4    RCVCODE           SUA-SCREECHCODE
         LI,R0    0                 TEST R0 IN NON COC SYSTEM
         MTH,0    CO:INTFL          COC INTERRUPTS DISABLED
         BNEZ     RCV1              YES-CRASH
         LD,R2    TRAPPSD           TRAP PSD
         LI,R1    #CODES            NUMBER OF SUA CODES
         CB,D4    SCODES,R1         SUA CODE
         BE       KRD5              YES
         BDR,R1   %-2
         LD,R2    RCVPSD            RECOVER PSD
KRD5     CW,R3    Y07               INHIBITED
         BANZ     RCV1              YES-CRASH
         CW,R2    Y004              MAPPED
         BAZ      RCV1              NO-CRASH
         LW,R1    S:CUN             CURRENT USER NUMBER
         CI,R1    MING              SYSTEM GHOST
         BL       RCV1              YES-CRASH IF SYSTEM GHOST
         LB,R2    UB:OV,R1
         LD,R2    P:NAME,R2
         CW,R2    ='ENQ'+X'05000000'      USER IN ENQUE OVERLAY
         BE       RCV1              YES CRASH
         MTW,0    BOOTFLG           GHOST1 RUNNING
         BNEZ     RCV1              YES-CRASH IF GHOST1 RUNNING
         LB,R1    UB:US,R1          STATE OF CURRENT USER
         CI,R1    SCU               CHECK FOR CURRENT USER STATE
         BNE      RCV1              NO-CRASH.  CURRENT USER MUST BE SCU
         MTW,0    DUMPFILE          DUMP FILE BUSY
         BNEZ     RCV1              YES-CRASH
         LW,R1    S:CUN             CURRENT USER NUMBER
         LOAD,R2  UX:JIT,R1         PAGE NUMBER OF JIT
         SLS,R2   9                 ADDRESS OF JIT
         LW,R1    Y004
         CW,R1    JTELFLGS,R2       THIS USER SUA'D BEFORE
         BANZ     RCV1              YES-CRASH
         PAGE
*
*   S I N G L E     U S E R    A B O R T
*
         STS,R1   JTELFLGS,R2       NO-SET SUA'D
         MTW,1    CRASHTYP          INDICATE SUA IN CRASHTYP
DUMP     EQU      %
         MTW,0    SUABTFLE          RADOM FILE ABTAINED
         BEZ      DUMPRTN           NO-RETURN TO CALLER
         MTW,0    DUMPFILE          DUMP FILE BUSY
         BNEZ     DUMPRTN           YES-CANT DUMP RETURN TO CALLER
         CW,R4    LOW               RECOVERY OVERLAP USER AREA
         BG       DUMPRTN           YES-CANT DUMP
MPC1     EQU      %                 ',F' KEYIN DOWNLOAD FIRMWARE
         LI,R7    1                 INDEX TO SAVE DCTX
         LB,R1    MB:SDI            DCTX OF SWAPPER
         BAL,SR4  STOPIO            STOP IO ON THIS DEVICE
         CB,R1    MB:SDI            DID ANOTHER DEVICE ON THE CHANNEL GET ET STO
         BE       %+2               NO
         STB,R1   SAVEDCTX,R7       YES SAVE ITS DCTX
         LB,R2    MB:SDI            DCTX OF PRIMARY SWAPPER
         LH,R6    DCT1,R2           ADDRESS OF SWAPPER
         BAL,R11  STOPIOA           HALT IT
         CI,R12   X'300'            ',F' KEYIN
         BE       MPC2              YES-JUST STOP THE SWAPPER
         LDCTX,R1 SUABTFLE          DCTX OF DUMP DEVICE
         BAL,SR4  STOPIO            STOP IO ON THIS DEVICE
         LDCTX,R2 SUABTFLE
         CW,R1    R2                ANOTHER DEVICE ON THIS CHANNEL STOPED
         BE       KRD4              NO
         CB,R1    SAVEDCTX,R7       DEVICE ALL REDEADY REMEMBERED
         BE       KRD4              YES
         LI,R7    2                 INDEX TO SAVE DCTX
         STB,R1   SAVEDCTX,R7       SAVE DCTX
KRD4     LH,R6    DCT1,R2           ADDRESS OF DUMPFILE DEVICE
         BAL,R11  STOPIOA           HALT IT AND CARRAGE RESTORE IT
         LW,R6    C:TIC             TIME SINCE LAST CRASH
         SW,R6    C:TINC
         AI,R6    30                ADD TIME OF THIS QUANTUM
         LI,R1    3
         AND,R1   SUACNT            CIRCULAR BUFFER
         MTW,1    SUACNT            COUNT THIS SUA
         STW,R6   SUATIME,R1        SAVE TIME OF THIS SUA
         LW,R6    S:CUN
         STB,R6   SUACUN,R1         SAVE USER NUMBER OF THIS SUA
         LI,R7    -1                RECOVERY'S START ADDRESS-1 (S U A)
         B        KRD2
SUARTN   EQU      %                 RETURN FROM RECOVERY
         LCI      4
         LM,R0    DUMPCOMX
         STM,R0   DUMPCOM+2         RESTORE DUMPCOM AFTER SUA
         LW,R7    MPPSEEK           SEEK OF MONITOR UNDER RECOVERY
         XW,R7    RCVDISC           TO REED BACK AFTER SUA
         LI,0     DA(REDDWD)
         LB,R1    MB:SDI            DCTX OF SYSTEM SWAPPER
         BAL,R11  IO                READ MONITOR UNDER RECOVERY
         B        %-3               ERROR RETURN-TRY AGAIN
         STW,R7   RCVDISC           RESTORE RECOVERY SEEK ADDRESS
         LB,R1    MB:SDI            DCTX OF SYSTEM SWAPPER
         BAL,SR4  RESTRTIO          YES-RESTART THE IO
         LI,R7    2
         LB,R1    SAVEDCTX,R7       DCTX SAVED
         BEZ      %+4               NO
         STB,R7   SAVEDCTX          SAVE R7
         BAL,SR4  RESTRTIO          START IO
         LB,R7    SAVEDCTX          RESTORE R7
         BDR,R7   %-5
         STW,R7   SAVEDCTX          CLEAR SAVEDCTX
         LI,R7    X'300'
         AND,R7   RCVCODE           GET TYPE OF CALL
         CI,R7    X'300'            ',F' KEYIN FIRMWARE DOWNLOAD
         BE       MPC3              YES-SKIP S U A  CODE
         LDCTX,R1 SUABTFLE
         BAL,SR4  RESTRTIO          YES-RESTART THE IO
         MTW,1    DUMPFILE          SET TO INDICATE SUA TO RVGHOST
         MTW,1    RCVRCNT           INC RECOVER COUNT FOR SUA PATH
         LW,R1    RCVRCNT
         STB,R1   DUMPFILE          PUT MONDMP NO. IN DUMPFILE
         LDCTX,R1 SUABTFLE          DCTX OF DUMPFILE DEVICE
         LB,R2    DCT24,R1          MPC FLAG
         CI,R2    4                 MPC CONTROLED DEVICE
         BAZ      NOTMPC            NO-NO NEED TO RESTARTIO
         LB,R2    DCT2,R1           CITX FOR THIS CHANNEL
         LB,R3    CIT1,R2           IOQX FOR HEAD OF THIS CHANNEL CHAIN
MPCRSRT1 LC       IOQ3,R3           REQUEST BUSY
         BCR,8    MPCRSRT2          NO
         LB,R1    IOQ7,R3           DCTX OF DEVICE
         STW,R3   SAVEDCTX          SAVE IOQX
         BAL,R11  RESTRTIO          CLEAN UP TABLES FOR THIS ENTRY
         LW,R3    SAVEDCTX          RESTORE IOQX
MPCRSRT2 LB,R3    IOQ2,R3           CHAIN DOWN THE IOQ CHANNEL CHAIN
         BNEZ     MPCRSRT1          PROCESS NEXT IOQ ENTRY
         LI,R7    0
         STW,R7   SAVEDCTX          CLEAR SAVEDCTX
NOTMPC   EQU      %
         LDCTX,R1 SUABTFLE          DCTX OF DUMP DEVICE
         BAL,R2   FORCEIO           GO-START IO
         LD,R0    TXCRVGST
         BAL,SR3  T:GJOBSTRT        GO-START RECOVER GHOST
MPC3     LB,R1    MB:SDI            DCTX OF SWAPPER
         BAL,R2   FORCEIO           GO-START IO
DUMPRTN  EQU      %
         LI,15    NSCPU             MP SYSTEM
         BEZ      KRD61             NO
         LW,15    MPBRANCH2         SET UP SIDLER BRANCH
         STW,15   SYSTRT            IN SLAVE SYSTRT
         LI,15    0
         STW,15   SB:RCVR           ZERO RCVR MASTER FLAG
         STW,15   SB:RCVA           ZERO RCVR SLAVEFLAG
KRD61    EQU      %
         LI,D3    X'7F'             SUA CODE
         LH,D4    RCVCODE           CRASH CODE AS SUB-CODE
         STB,D4   D3
         LI,R12   0
         LI,R13   CSEI%PATH%RECOV
         STS,R12  CSED%PATH         CLEAR CSEI%PATH%RECOV FLAG AFTER SUA
         STW,R12  CRASHTYP          CLEAR CRASH TYPE
         LW,R7    RCVCODE           SCREECH CODE INFO
         CI,R7    X'200'            DUMP
         BAZ      KRD6              NO-SUA
         MTW,1    RCVPSD            RETURN TO XPSD+2
         LCI      0
         LM,R0    SAVEREGS          RESTORE REG BLOCK0
         LPSD,8   RCVPSD            RETURN TO XPSD+2
KRD6     EQU      %
         LPSD,0   RTNPSD            GO-TO T:ABORTM
         PAGE
*
*        F U L L  C R A S H
*
RCV1     EQU      %
         MTW,2    CRASHTYP          INDICATE AT LEAST SLOW PATH
*
*                 ALLOW REAL-TIME SYSTEMS TO SUPPLY THEIR OWN
*                 RECOVERY ROUTINE
*
         BAL,11   RT:RCVR
         LPSD,1   PDFPSD            CLEAR PDF FLAG
PDFOFF   LI,R1    DCTSIZ            HALT ALL SYSGEN DEVICES
KRD7     LB,R2    DCT24,R1
         CI,R2    6                 DEV CONFIG OUT/MPC DRIVE
         BANZ     KRD8              YES-DO NOT HALT
         LC       DCT3,R1           DEVICE PARTITIONED OUT
         BCR,2    KRD11             NO-HALT IT
         LW,R2    DCT9,R1           YES-SEE IF IN DIAG. OPEN
         LC       R2                DIAG OPEN
         BCR,2    KRD8              NO-DO NOT HALT
KRD11    LH,R6    DCT1,R1           DEVICE ADDRESS
         LI,R0    50000             LOOP COUNTER
         :TIO,R3  0,R6              IS DEVICE BUSY
         BCS,12   %+3               YES-LOOP
         LC       R3
         BCR,6    %+2               NO
         BDR,R0   :A                LOOP ON BUSY DEVICE
         :HIO,0   *R6               HALT THE DEVICE
         LB,R3    DCT4,R1           TYPE INDEX
         LB,R0    TB:FLGS,R3        L/ RAD OR PACK
         CI,R0    X'F0'
         BL       KRD8              B/ RAD
         BAL,R4   RCARIAGE          GO- RESET CARRIAGE ON PACK.
KRD8     BDR,R1   KRD7              LOOK AT ALL SYSGENED DEVICES
         LI,R7    0                 CRASH RECOVERY ENTRY
         AIO,0    0
         BCR,8    %-1               ACKNOWLEDGE EVERY INTERRUPT
         MTW,0    SUABTFLE          DUMPFILE PRESENT
         BEZ      KRD2              NO-DUMP TO SWAPPER
         MTW,0    DUMPFILE          DUMPFILE BUSY
         BNEZ     KRD2              YES-DUMP TO SWAPPER
         LW,R2    SEEK4000-1        SEEK FOR 4000 IN DUMPFILE
         MTW,2    CRASHTYP          INDICATE FAST PATH IN CRASHTYP
         B        KRD9
KRD2     EQU      %
         LW,R2    SEEK4000,R7       SEEK TO PUT PRE-DUMP
         LB,R1    MB:SDI            DCT OF SYSTEM SWAP
         CI,R7    0                 SUA
         BE       KRD10             NO
KRD9     LDCTX,R1 SUABTFLE          YES-GET DCT OF SUA FILE
KRD10    LI,R3    500000
         BDR,R3   %                 DELAY FOR A LONG TIME
         LB,R3    DCT24,R1          MPC FLAG
         CI,R3    4                 MPC CONTROLED DEVICE
         BAZ      KRD12             NO
*
         LI,R3    0
         SLD,R2   -4                SLIDE THE SEEK DOWN TO POSITION
         OR,R2    =X'08000000'      SECTOR COUNT LIMIT
         STD,R2   MPCSEEK1
         LH,R2    DCT1,R1           DEVICE ADDRESS
         LI,R3    X'F'              MASK
         SLD,R2   20                SLIDE DEVICE NUMBER TO POSITION
         STS,R2   MPCSEEK
         STS,R2   MPCWRITE
         LI,R0    DA(MPCCLIST)
         B        KRD1              DO THE MPC IO
KRD12    STW,R2   SEEK              SEEK TO WRITE PRE DUMP 0-X'7FFF'
         LI,R3    X'F0000'
         STS,R2   SEEK1             CYLINDER NUMBER
         LI,R0    DA(DUMPCOM)       DUMP COMM LIST
KRD1     BAL,R11  IO                DUMP X'4000'-X'7FFF'
         NOP                        ERROR RETURN
         AI,R5    1023
         AND,R5   =X'FFFFFC00'      ROUND UP TO SECTOR
         LI,R4    X'FFFF'
         XW,R4    R5
         STS,R4   TIO%STATUS+1
         LH,R5    TIO%STATUS+1      STATUS BITS
         LC       R3                SECTOR UNAVAILABLE
         BCR,2    %+3               NO-
         CI,R5    X'800'
         BANZ     UNEND             UNUSUAL END-CYL CROSSING
         LI,0     DA(REDDWD)
         LB,R1    MB:SDI            DCTX OF SYSTEM SWAPPER
         BAL,R11  IO                READ RECOVERY
         B        %-3               ERROR RETURN-TRY AGAIN
         B        *RCVSTART,R7      ENTER RECOVERY.
         BOUND    8
TXCRVGST TEXTC    'RVGHOST'
RTNPSD   :PSD     MAP,(IA,T:ABORTM),(WK,1)
PDFPSD   :PSD     (IA,PDFOFF),INH
RCV43    AI,13    1                 +1 TO RECOVERY SUBCODE (03-03)
RCV42    AI,13    1                 +1 TO RECOVERY SUBCODE (03-02)
         B        RCV41             B
SCODES   DATA,1   0,X'61',X'79',X'7E'
#CODES   EQU      BA(%)-BA(SCODES)-1
         BOUND    4
         PAGE
*        (R0)=  DA(CLIST)
*        (R1)=  DCTX
*
IO       EQU      %                 I/O WITH ERROR CHECKING
         LH,R6    DCT1,R1           DEVICE ADDRESS
IOA      EQU      %                 ENTRY WITH DEVICE ADDRESS
         LI,R8    10                RETRY COUNT
IO2      LCI      0                 CLEAN OUT CCS
         :SIO,R4  0,R6              START THE I/O
         BCS,12   IO5               ERROR-SIO NOT ACCEPTED
         LI,R3    50000
IO1      LI,R2    41
         BDR,R2   %                 DELAY
         :TIO,R4  0,R6              TIO STATUS
         STD,R4   TIO%STATUS        SAVE TIO STATUS
         BCS,12   %+3               I/O NOT COMPLETE
         LC       R5                RMP CAN GIVE FALSE CC
         BCR,6    IO1C              I/O COMPLETE
         BDR,R3   IO1               WAIT SOME MORE
         B        IO3A                REPORT AN ERROR
*
IO1C     :TDV,R3  0,R6              TDV STATUS
         STW,R3   TDV%STATUS        SAVE TDV STATUS
         LC       R3
         BCS,6    IO3               SECTOR UNAVAILABLE
         LH,R2    TIO%STATUS+1      TIO STATUS BITS
         CI,R2    X'7E'             ANY ERROR BITS SET
         BANZ     IO3A              ERROR-TRY AGAIN
IO3      AI,R11   1                 SET TO NORMAL RETURN
         B        *R11              RETURN
IO3A     EQU      %
         LB,R4    DCT24,R1          DEVICE FLAGS
         CI,R4    4                 MPC DEVICE
         BANZ     %+2               YES DO NOT HALT
         :HIO,0   0,R6              HALT THE BAD DEVICE
         LI,R4    100000
         BDR,R4   %                 HANG FOR A MOMENT
         BDR,R8   IO2               YES-TRY AGAIN
IO6      :HIO,0   1                 HALT THE OC
         LI,R0    DA(TYCOMM)
         :SIO,0   1                 TYPE ON OC 'RCIO ERR'
IO4      :TIO,0   1
         BCS,12   IO4
         LW,R15   RCVCODE           (R15) HAS RECOVER CODE
         B        %                 STOP FOR OPERATOR
         B        *R11              TAKE ERROR RETURN
*
IO5      STCF     R2                SAVE I/O CC
         LB,R2    R2                IN NEAT FORMAT
         LI,R3    X'FFFFF'          CC INDICATOR IN REG.
         B        IO6               REPORT ERROR
         BOUND    8
TYCOMM   GEN,8,24 5,BA(TYMESS)
         GEN,8,24 0,12
TYMESS   DATA     X'1515'
         TEXT     'RCIO ERR'
         PAGE
STOPIO   EQU      %                 DCTX IN R1
         LB,R3    DCT2,R1           CITX
         LB,R4    CIT1,R3           IOQX
         BEZ      *SR4              NO QUEUE CHAIN-RETURN
STOPIO3  LC       IOQ3,R4           REQUEST BUSY
         BCR,8    STOPIO2           NO
         LB,R2    IOQ7,R4           DCTX OF BUSY DEVICE
         LC       DCT5,R2           DEVICE BUSY
         BCR,8    STOPIO2           NO
         BCR,1    STOPIO2           NO DATA TRANSFERING
         LH,R6    DCT1,R2           DEVICE ADDRESS
STOPIOA  LB,R5    DCT4,R2           TYPE INDEX
         LB,R5    TB:FLGS,R5
         CI,R5    X'C0'             ROTATING DEVICE
         BGE      STOPIO1           YES-HALT THE IO
         LI,R2    X'2000'           LOOP COUNTER
STOPIO4  LI,R5    1000
         BDR,R5   %                 DELAY
         :TIO,R5  *R6               TIO TO GET STATUS
         LC       R5                INTERRUPT PENDING FOR TAPE
         BCS,8    *SR4              YES-RETURN CHANNEL QUIET
         BDR,R2   STOPIO4           LOOP
         B        *SR4              GIVE UP ON DELAY FOR TAPE
STOPIO1  :HIO,0   *R6               HALT I/O ON ROTATING DEVICE
         CI,R5    X'F0'             RAD
         BL       %+2               YES
         BAL,R4   RCARIAGE          PACK- RESET CARRIAGE
         LW,R1    R2                DCTX OF HALTED DEVICE
         B        *SR4              RETURN
STOPIO2  LB,R4    IOQ2,R4           CHAIN DOWN THE QUEUE
         BNEZ     STOPIO3
         B        *SR4              RETURN END OF CHAIN
*
*
*        BAL,R4   RCARIAGE
*
* IN:    (R1)=DCTX OF DISK TO RESTORE
*
RCARIAGE EQU      %
         LB,R3    DCT24,R1
         CI,R3    4                 MPC DEVICE
         BAZ      RCARIAG1          NO
*
         AND,R6   =X'F'             DEVICE NUMBER
         SLS,R6   20                SHIFT DEVICE NUMBER TO POSITION
         LW,R3    MPCRESTR
         AND,R3   =X'FF0FFFFF'      REMOVE DEVICE NUMBER
         OR,R3    R6                PUT IN NEW DEVOCE NUMBER
         STW,R3   MPCRESTR
         LH,R6    DCT1,R1           DEVICE ADDRESS
         LI,R0    DA(MPCRCAR)       CLIST TO RESTORE CARIAGE ON MPC
         B        %+2
RCARIAG1 LI,R0    DA(RESTORE)       NON MPC CLIST
         :SIO,0   *R6               RESTORE CARRIAGE ON PACK
         LI,R3    50000             LOOP COUNT
         :TIO,R5  *R6
         BCS,12   %+3               BUSY
         LC       R5
         BCR,6    *R4               RETURN ONLY WHEN STATUS BITS CLEAR
         BDR,R3   :A
         B        *R4               PREVENT LOOP
         PAGE
*F*      NAME:        RESTRTIO
*F*      PURPOSE:     RESTART I/O ON ROTATING DEVICE THAT WERE
*F*                   STOPPED DUE TO A SUA, DUMP OR POWER FAIL-
*F*                   SAFE.
RESTRTIO EQU      %
         LC       DCT5,R1           DEVICE BUSY
         BCR,X'E' *SR4              NO-NOTHING TO RESTART
         BCR,8    %+2
         BAL,R5   INTSIM            GO-SET DEVICE IN CLEANUP-PENDING STATE
         LB,R2    DCT5,R1
         AND,R2   M5
         STB,R2   DCT5,R1           CLEAN UP DCT5 FOR RESTART
         LB,R2    DCT6,R1           IOQX
         LB,R3    IOQ3,R2
         AND,R3   M7
         STB,R3   IOQ3,R2           CLEAR THE BUSY BIT FROM IOQ3
         LB,R3    IOQ4,R2
         STB,R3   IOQ5,R2           SET FUNCTION CODE
         B        *SR4              RETURN
         PAGE
UNEND    MTH,1    SEEK1             INC CURRENT CYLINDER NUMBER
         LI,R3    X'FFFF'
         LI,R2    X'FFFF'
         AND,R2   TIO%STATUS
         STS,R2   COMMPACK+2        DA(COMMRAD) ADDRESS
         SLS,R2   1                 ADDRESS OF COMMRAD ENTRY
         LI,R5    X'FFFF'
         LI,R4    X'FFFF'
         AND,R4   TIO%STATUS+1      REMAINGING BYTE COUNT
         BNEZ     %+2
         LI,R4    X'10000'          REMAING BYTE COUNT
         CI,R4    X'400'            ODD NUMBER OF SECTORS/CYLINDER
         BAZ      %+2               NO
         AI,R4    X'400'            YES-RE-WRITE THE LAST SECTOR
         INT,R3   1,R2              STARTING BYTE COUNT FROM COMMRAD
         CI,R3    0
         BNE      %+2
         LI,R3    X'10000'          STARTING BYTE COUNT
         STS,R4   1,R2              NEW BYTE COUNT
         SW,R3    R4
         AWM,R3   0,R2              INC MEMORY ADDRESS BY AMOUNT WRITTEN
         LI,R0    DA(COMMPACK)
         B        KRD1
         PAGE
*
*        LOAD THE MPCS
*
MPCLD    EQU       %
         LI,R13    #MPC             HOW MANY MPCS ON THIS SYSTEM
         BLEZ      *R11             S:  NONE..ALL THRU ALREADY!
         STW,R11   MPCRTN           SAVE RETURN ADDRESS
MPCNLOOP STW,R13   R7               JAM INTO INDEX REGISTER
         BAL,R14  MPCFETCH          GET THE FIRMWARE OFF THE SWAPPER
*
         LI,R0    0
         STW,R0   MPCCHN            CLEAR THE CURRENT CHANNEL INDEX
         LI,R1    DCTSIZ            NUMBER DCT ENTRIES
MPCLD6   EQU      %
         LH,R6    DCT1P,R1          ADDRESS OF PRIMARY PATH
         LB,R10   DCT24,R1
         CI,R10   4                 MPC CONTROLED DEVICE
         BAZ      MPCLD5            NO-NO INTEREST
         LB,R3    DCT4,R1           GEN'L DCT TYPE CODE
         LB,R3    TB:FLGS,R3        C(R3)=TYPE OF MPC ON DEVICE
         AND,R3   =X'C0'            ISOLATE BITS 0-1
         STW,R13  R7                JAM INTO INDEX REG
         CB,R3    MPCTYPE,R7        IS IT MPC TYPE I'M ON NOW
         BNE      MPCLD5            S:  NO..NOT INTERESTED
         CI,R10   2                 IS DEV PERM DOWN
         BANZ     MPCLD5            YES-NO INTEREST
         LB,R9    DCT2,R1           CHANNEL FOR THIS DEV
         CW,R9    MPCCHN            WAS CHAN ALREADY LOADED
         BE       MPCLD5            S:  YES..NOT INTERESTED
*                                   F:  NO..CHECK PRIM & ALT CHANS
         CI,R10   8                 IS THERE A PRIMARY CHAN
         BANZ     MPC2CHN           S:  NO..TRY SECONDARY CHAN
         LW,R12   DCT9,R1
         CW,R12   =X'08000000'      CONTROLER PARTITIONED
         BANZ     MPCLD5            YES-DON'T LOAD FIRMWARE
*                                   F:  YES..DOWNLOAD TO IT
         BAL,R14  MPCDWNLD          DOWNLOAD MPC F/W TO DEVICE
*                                   WHOSE ADDR IS IN R1
*        -        -                 MPCDWNLD NORMAL RETURN HERE
         STW,R9   MPCCHN            REMEMBER THIS CHAN AS DONE
MPC2CHN  LH,R6    DCT1A,R1          ALT PATH ADDR
         CH,R6    DCT1P,R1          IS THERE AN ALT PATH
         BE       MPCLD5            S:  NO..THIS DEV DONE
         CI,R10   X'10'             IS 2ND CONTROLLER PRESENT
         BANZ     MPCLD5            S:  NO..THRU W/ THIS DEV
         LW,R12   DCT9,R1
         LC       R12               CONTROLER PARTITIONED
         BCS,1    MPCLD5            YES-DONT LOAD FIRMWARE
         BAL,R14  MPCDWNLD          DOWNLOAD TO 2NDARY CONTROLLER
         STW,R9   MPCCHN            REMEMBER THIS CHAN AS DONE
*
MPCLD5   BDR,R1   MPCLD6            LOOP ON DCTSIZ
MPCLD51  BDR,R13  MPCNLOOP          LOOP ON #MPC
*
*        THIS SECTION  OF CODE RESTORES THE MONITOR PROCEDURE
*        THAT WAS CLOBBERED BY THE 'IO' SUBROUTINE
*
         LW,R7    MPPSEEK           SEEK OF MONITOR UNDER RECOVERY
         XW,R7    RCVDISC           TO REED BACK AFTER SUA
         LI,0     DA(REDDWD)
         LB,R1    MB:SDI            DCTX OF SYSTEM SWAPPER
         BAL,R11  IO                READ MONITOR UNDER RECOVERY
         B        %-3               ERROR RETURN-TRY AGAIN
         STW,R7   RCVDISC           RESTORE RECOVERY SEEK ADDRESS
         B        *MPCRTN           RETURN
*
*
         BOUND    8
IOCD1    GEN,8,24 7,BA(%+2)
         GEN,8,24 0,1               RESET MPC IOCD
*
*        AT THIS POINT, AN ERROR CONDITION EXISTS WHICH
*        PERSEVERED AFTER 10 RETRIES...
*        OC GETS MPC LOAD NAME, PGM HANGS, OPERATOR CAN
*        THEN TURN ON MPC, STEP PGM AND ALL IS WELL...
*        IF IT WAS A REAL ERR, IT'LL REAPPEAR
*
MPCERR   :HIO,0   1                 HALT THE OC
         LI,R0    DA(IOCD4)         OC MESSAGE
         :SIO,0   1                 SEND OC MESSAGE
         :TIO,0   1
         BCS,12   :A                DELAY UNTIL SENT
         B        %
         B        MPCDWNLD          LET OPERATOR TURN ON MPC
         BOUND    8
IOCD4    GEN,8,24 5,BA(%+2)
         GEN,8,24 0,20
         DATA     X'1515'
         TEXT     'CANT LOAD MPC'
MPCDWNLD EQU      %
NTRIES   EQU      10                # RETRIES FOR EACH ERR COND
         LI,R12   NTRIES
MPCDWN1  LCI      0                 CLEAN CCS
         :HIO,R4  0,R6              HALT THE MPC
         BCS,12   MPCBAD1           ERROR
         LH,R2    R5                ISOLATE STATUS
         CI,R2    X'800'            UN END
         BANZ     MPCBAD            YES-ERROR
         LI,R0    DA(IOCD1)         RESET IOCD
         BAL,R11  IOA               RESET THE MPC
         B        MPCBAD            ERROR-CANT RESET THE MPC
*
         LI,R2    500000
         BDR,R2   %                 DELAY FOR A LONG TIME
*
         LI,R0    DA(MPCD2)         ROS
         BAL,R11  IOA               WRITE ROS MEMORY
         B        MPCBAD            ERROR-CANT WRITE ROS MEMORY
         LH,R2    TIO%STATUS+1
         CI,R2    X'800'
         BANZ     MPCBAD            UNUSUAL END
*
         LI,R0    DA(MPCD3)         R/W
         BAL,R11  IOA               WRITE R/W MEMORY
         B        MPCBAD            ERROR-CANT WRITE R/W
         LH,R2    TIO%STATUS+1
         CI,R2    X'800'
         BANZ     MPCBAD            UNUSUAL END
*
         B        *R14              RETURN NORMALLY
*
MPCBAD   EQU      %
         BDR,R12  MPCDWN1
         B        MPCERR            GIVE UP TRYING
MPCBAD1  STCF     R2                SAVE CC
         LB,R2    R2                IN NEAT FORMAT
         LI,R3    X'FFFFF'          CC FLAG
         B        MPCERR            REPORT ON OC
*
*                 (R7)  MPC INDEX
*
MPCFETCH EQU      %                 GET THE FIRMWARE FROM SWAPPER
         LD,R4    MPCNTBL,R7        NAME OF MPC LOAD MON OVERLAY
         LI,R2    MAXOVLY           NUMBER OF MON OVERLAYS
         CD,R4    P:NAME,R2         FIND THE OVERLAY
         BE       MPCLD1
         BDR,R2   %-2
         B        MPCLD51           ERROR-CANT FIND OVERLAY
*
MPCLD1   EQU      %
         LH,R7    PH:PDA,R2         SEEK OF OVERLAY ON SWAPPER
         SLS,R7   16                SHIFT FOR RAD
         MTW,0    S:DP              PACK SWAPPER
         BEZ      MPCLD4            NO
         SLS,R7   -16               YES-SHIFT TRACK SECTOR
         LB,R3    PB:C#,R2          PACK SWAPPER CYLINDER NUMBER
         STH,R3   R7                FULL PACK SEEK
MPCLD4   XW,R7    RCVDISC
         LI,R0    DA(REDDWD)        IOCD TO READ OVER MON PP
         LB,R1    MB:SDI            DCTX OF SYSTEM SWAPPER
         BAL,R11  IO                READ MPC FIRM WARE LOAD
         B        MPCLD51           ERROR-CANT READ FIRMWARE
         STW,R7   RCVDISC           RESTORE SEEK
*
         LI,R5    X'7FFFF'
         LS,R4    RCVBASE           BYTE ADDRESS OF MON PP
         AI,R4    3*4               INC ABOVE INFO ITEMS
         STS,R4   MPCD2+2           WRITE ROS FROM HERE
         LS,R4    RCVBASE
         SLS,R4   -2                WORD ADDRESS OF FIRMWARE BUFFER
         LI,R3    X'7FFFF'
         LW,R2    0,R4              BYTES OF ROS
         STS,R2   MPCD2+3             INTO IOCD
*
         LW,R2    1,R4              BYTES OF R/W
         STS,R2   MPCD3+3             INTO IOCD
         AW,R4    2,R4
         AI,R4    3                 ADDRESS OF R/W
         SLS,R4   2                 BYTE ADDRESS OF R/W
         STS,R4   MPCD3+2             INTO IOCD
         B        *R14              RETURN
*
         PAGE
MPC2     EQU      %                 ',F' KEYIN DOWNLOAD FIRMWARE
         LW,R1    SAVEREGS+1        DCTX OF MPC DEVICE
         LB,R3    DCT4,R1           TYPE CODE
         LB,R3    TB:FLGS,R3        TYPE CODE
         AND,R3   =X'C0'            TYPE CODE
         LI,R7    #MPC              NO. MPC TYPES
         CB,R3    MPCTYPE,R7        GET A MATCH ON MPC TYPE
         BE       %+3               YES
         BDR,R7   %-2               LOOP ON MPC TYPES
         B        SUARTN            GIVE UP
         BAL,R14  MPCFETCH          GET FIRMWARE FROM SWAPPER
         LW,R1    SAVEREGS+1        DCTX OF MPC DEVICE
         LH,R6    DCT1,R1           ADDRESS OF MPC DEVICE
         BAL,R14  MPCDWNLD          PUT FIRMWARE INTO THE MPC
         B        SUARTN            RESTORE EVERYTHING
         END

