*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      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.
         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      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      M:SWAPD
         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
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
*
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
*
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
         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
*
*
*  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       RCV1              ERROR-NO SUCH TYPE CRASH
         CW,R4    LOW               OVERLAP USER AREA
         BG       RCV1              YES-CANT SUA
         LH,D4    RCVCODE           SUA-SCREECHCODE
         REF      T:GJOBSTRT
         REF      MB:SDI
         REF      DCT5
         REF      DCT6
         SREF     CO:INTFL
         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
*
*   S I N G L E     U S E R    A B O R T
*
         LW,R1    S:CUN             CURRENT USER NUMBER
         CI,R1    MING              SYSTEM GHOST
         BL       RCV1              YES-CRASH IF SYSTEM GHOST
         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
         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
         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
         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     EQU      %
         :HIO,0   *M:SWAPD          HALT I/O ON SYSTEMM DEVICE
         LH,R0    DCT1,R2           ADDRESS OF DUMPFILE DEVICE
         :HIO,0   *0                HALT I/O ON DUMP DEVICE
         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,R6    -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)
         LW,R1    M:SWAPD           ADDRESS OF PRIMARY SWAPPER
         BAL,R11  IO                READ MONITOR UNDER RECOVERY
         B        %-3               ERROR RETURN-TRY AGAIN
         STW,R7   RCVDISC           RESTORE RECOVERY SEEK ADDRESS
         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
         LB,R1    MB:SDI            DCTX OF SYSTEM SWAPPER
         BAL,SR4  RESTRTIO          YES-RESTART THE IO
         LDCTX,R2 SUABTFLE
         CW,R1    R2                SWAP AND DUMP DEVICE THE SAME
         BE       KRD3              YES-THIS ALL THE IO NEEDED TO RESTARRT
         LW,R1    R2                DCTX OF DUMP DEVICE
         BAL,SR4  RESTRTIO          YES-RESTART THE IO
KRD3     EQU      %
         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
         LB,R1    MB:SDI            DCTX OF SWAPPER
         BAL,R2   FORCEIO           GO-START IO
         LDCTX,R1 SUABTFLE          DCTX OF DUMP DEVICE
         BAL,R2   FORCEIO           GO-START IO
         LI,R7    2
         LB,R1    SAVEDCTX,R7       DCTX SAVED
         BEZ      %+4               NO
         STB,R7   SAVEDCTX          SAVE R7
         BAL,R2   FORCEIO           GO START IO
         LB,R7    SAVEDCTX          RESTORE R7
         BDR,R7   %-5
         STW,R7   SAVEDCTX          ZERO SAVEDCTX
         LD,R0    TXCRVGST
         BAL,SR3  T:GJOBSTRT        GO-START RECOVER GHOST
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
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    2                 DEVICE RECONFIGURED OUT
         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
         :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,R6    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,R6
         LB,R1    MB:SDI            DCT OF SYSTEM SWAP
         CI,R6    0                 SUA
         BE       KRD10             NO
KRD9     LDCTX,R1 SUABTFLE          YES-GET DCT OF SUA FILE
KRD10    LH,R1    DCT1,R1           DEVICE ADDRESS
         STW,R2   SEEK              SEEK TO PUT CORE AT X'4000'
         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)
         LW,R1    M:SWAPD           ADDRESS OF PRIMARY SWAPPER
         BAL,R11  IO                READ RECOVERY
         B        %-3               ERROR RETURN-TRY AGAIN
         B        *RCVSTART,R6      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
IO       EQU      %                 I/O WITH ERROR CHECKING
         LI,R8    10                RETRY COUNT
IO2      :SIO,R4  *R1               START THE I/O
         BCS,12   IO3A              ERROR - SIO NOT ACCEPTED
         LI,R3    50000
IO1      LI,R2    41
         BDR,R2   %                 DELAY
         :TIO,R4  *R1               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
         :HIO,0   *R1               GIVE UP - HALT THE DEVICE AND
         B        IO3A                REPORT AN ERROR
*
IO1C     :TDV,R3  *R1               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     %+3               ERROR BIT SET TRY AGAIN
IO3      AI,R11   1                 SET TO NORMAL RETURN
         B        *R11              RETURN
         BDR,R8   IO2               YES-TRY AGAIN
IO3A     :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
         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
         CH,R6    DCT1P,R2          DATA TRANSFERING ON PRIMARY CHANNEL
         BNE      STOPIO2           NO-DO NOT STOP IO
         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
*
*
RCARIAGE LI,R0    DA(RESTORE)       RESTORE CARRIAGE ORDER CODE
         :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

