*M*      TSIO     SWAPPING RAD I/O
*P*      NAME:    TSIO
*P*      PURPOSE: WHEN THE SWAPPER HAS SET UP A COMMAND CHAIN,
*P*               FOR WHICH SWAPPING RAD I/O MUST BE PERFORMED,
*P*               IT CALLS UPON T:SIO. TSIO CALLS UPON THE I/O
*P*               SYSTEM (IOQ) TO DO THE ACTUAL I/O AND INTERRUPT
*P*               PROCESSING. THE I/O SYSTEM RETURNS TO TSIO FOR
*P*               END ACTION.
*P*
*P*      DESCRIPTION: TSIO PERFORMS ERROR CHECKS ON THE CL CHAIN.
*P*               THIS INFORMATION IS PASSED TO NEWQ
*P*               TO QUEUE UP THE REQUEST.  WHEN THE INTERRUPT
*P*               OCCURS AND PROCESSING IS COMPLETE, THE I/O SYSTEM
*P*               TRANSFERS CONTROL TO THE END ACTION ROUTINE IN
*P*               TSIO.  IF AN ERROR OCCURRED, THE I/O SYSTEM HAS
*P*               ENTERED A RECORD IN THE ERROR LOG FILE,AND PASSED
*P*               INFORMATION ABOUT THE ERROR TO THE END ACTION
*P*               ROUTINE. THE END ACTION ROUTINE WILL RETRY THE
*P*               CALL N TIMES, AND IF THAT FAILS IT WILL SET A USER
*P*               FLAG INDICATING THE ERROR AND CONTINUE IF POSSIBLE
*P*               CRITICAL ERRORS MAY RESULT IN A SOFTWARE CHECK.
*P*               IF THE I/O WAS SUCCESSFUL, TSIO  RETURNS TO
*P*               THE SWAPPER STILL ON END ACTION. HOWEVER, IF THE
*P*               FUNCTION PERFORMED WAS A WRITE,THE I/O SYSTEM IS
*P*               CALLED UPON TO DO A CHECK WRITE. IF THE FUNCTION
*P*               WAS READING A USER, A SOFTWARE READ CHECK IS DONE
*P*               BEFORE RETURNING TO THE SWAPPER.
*P*
         SYSTEM   UTS
RDCK     EQU      0                 REMOVE READ CHECK CODE
WTCK     SET      1
TSIO:    RES
         DEF      TSIO:             PATCHING DEF
*
         REF      M:CLBGN           COMMAND LIST BEGINNING
         REF      MH:CLEND          COMMAND LIST END
         REF      M:HLTIC           TIC TO SENSE COMMAND
         REF      M:WCKBCL          BEGIN CLIST FOR WRITECHK
         REF      M:WCKECL          END CLIST FOR WRITE CHK
         REF      MB:#RTRY          NUMBER OF RETRIES TO DO
         REF      MB:SFC            SWAPPER FUNCTION CODE
         REF      MB:SDI            SWAP DEVICE DCT INDEX
         REF      M:SNSDA           SENSE BUFFER
         REF      JCLE              CLIST LENGTH IN JIT
         REF      JCLPA             CLIST PHYS ADDRESS IN JIT
         REF      JCMAP             PHYS PAGE TABLE IN JIT
         REF      S:BECL            BEGIN/END CLIST TABLE
         REF      S:ISUN            INSWAP USER NUMBER
         REF      S:JCL             JIT SHELL COMMAND LIST
         REF      SB:OSUL           OUTSWAP USER LIST
         REF      S:SWSTAT
         REF      UX:JIT            USER JIT PHY PG TABLE
         REF      UH:FLG2           SWAPPER ERROR FLAGS
         REF      X1                TABLE CONSTANT
         REF      X4                TABLE CONSTANT
         REF      X1FE00            ADDRESS MASK (PAGE)
         REF      Y01               TABLE CONSTANT
         REF      X7000             TABLE CONSTANT
         REF      XFFFF             TABLE CONSTANT
         REF      SB:HQ             CURRENT USER QUEUE HEAD
         REF      UB:FL             LINK TO NEXT CUN
         REF      UH:DL             USERS DO LIST
         REF      SCU               CURRENT USER STATE  NR.
         REF      HIGH              HIGHEST AVAILABE USER PAGE
         REF      M16               CONSTANT
         REF      M17               CONSTANT
         REF      M21               CONSTANT
         REF      M24               CONSTANT
         REF      Y4                CONSTANT
         REF      DCT13             TDV STATUS
         REF      DCT12             IO ADDRESS FROM AIO
         REF      M:SWPEND          END OF PSA AREA
         REF      NEWQ              DO IO WITH COMMAND LIST
         REF      S:#SWAP%DEV       NUMBER OF SWAP DEVICES TO
*,*                                 DO I/O TO
         REF      S:IOEA%ADR        SWAPPER RETURN ADDRESS
         REF,1    S:SECTOR          SENSE BUFFER FOR T:SENSE
         REF      DOWTCK            WRITE CHECK FLAG
         REF      JXBUFVP           SPARE BUFFER VIRT PAGE NR.
         REF      JAJITVP           AJIT VIRT PAGE NR.
         REF      JDCBLL            DCB LOWER LIMIT IN JIT
         REF      JDCBUL            DCB UPPER LIMIT IN JIT
         REF      SCLLIM            SHELL COMMAND LIST LIMITS
         REF      ERRLOG            LOG ERRORS
         REF      TIME              TIME OF DAY FOR ERR LOG
         REF      SWAP%PRI          SWAPPER PRIORITY FOR IOQ
*
         DEF      T:SENSE           SENSE RAD POSITION
         DEF      T:SEXIT            EXIT TO SCHED OR INTERRUPT
         DEF      T:SIO             ENTRY TO DO SWAP
         DEF      T:SIOEA           END ACTION ENTRY
*
         DO       RDCK
         REF      JHSWPCK           READ CHKSUM (NO LONGER USED)
         REF      DORDCK            READ CHK (NO LONGER USED)
         REF      RDCKDSP1          READ CHK (NO LONGER USED)
         REF      RDCKDSP2          READ CHK (NO LONGER USED)
         REF      RDCKDSP3          READ CHK (NO LONGER USED)
         REF      RDCKDSP4          READ CHK (NO LONGER USED)
         FIN
*
#SWAP%DEV EQU     S:#SWAP%DEV
IOEA%ADR EQU      S:IOEA%ADR
SECTOR   EQU      S:SECTOR
         PAGE
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
         PAGE
************************************************************************
*        SWAPPER I/O ERROR CODES                                       *
*        ***********************                                       *
*  INTERPRETATION OF                                                   *
*  BYTE IN REGISTER 15                                                 *
*                                                                      *
*         80          SENSE NOT = SEEK ON WRITE                        *
*         81          READ CHECK NOT SATISFIED                         *
*         82          WRT CK ERR - BAD ORDER ETC 7 = WHERE ERROR OCCURED
*         83          NOT DONE WITH CL ON WRITE BUT NO STATUS BITS SET *
*         90          DEV UNUSUAL END OR IOP HALT SET & NO OTHER BITS  *
*         91          WRT CHECK NOT IN SYSTEM BUT TRYING TO DO IT      *
*         92          IN LOGGING SECTOR, IOCD POINTS BAD               *
*                                                                      *
*  0 1 2 3 4 5 6 7                                                     *
*                                                                      *
*  1                  SWAPPER IO ERRER                                 *
*                                                                      *
*    0 0              BITS 3-7 NOT STATUS INDICATORS BUT RATHER AS ABOVE
*    0 1              WRITE FCN    BITS 3-7 STATUS ERRORS AS BELOW     *
*    1 0              READ  FCN     '    '    '      '    '    '       *
*    1 1              WRT CK FCN    '    '    '      '    '    '       *
*                                                                      *
*        1            TRANSMISSION DATA ERROR -|                       *
*          1                '      MEM    '    |   THESE ARE           *
*            1        MEMORY ADDRESS      '     >  STRAIGHT FROM       *
*              1      IOP MEMORY          '    |   STATUS BITS 9-13    *
*                1    IOP CONTROL         '   -|                       *
************************************************************************
         PAGE
*************************************
*        RECORD
*
*CODE 20 = WA(IOCD)
*     21 = ODD STATUS WD
*
*************************************
         PAGE
*                                   INTERRUPT COMES IN
#RETRIES EQU      10
         BOUND    8
SENSE%ORDR        ;
         EQU      %                 SNESE ORDER TO GET CURRENT SECTOR
         GEN,8,24 4,BA(SECTOR)        POSITION.
         GEN,8,24 30,4
JCLLIM   DATA     S:JCL,S:JCL+8
         REF      LOW
FCNSUBR  EQU      %-2
         DATA     ;
 RETRY,;          WRITE ERROR-RETRY
 WTCK0,;          WRITE OK-DO WRT CHK
 RETRY,;          READ ERROR-RETRY
 END,;            READ OK-DONE
 WRTAGN,;         WRT CHK ERROR-REWRITE
 WTCK1,;          WRT CHK OK-CONTINUE WRT CHK
 RETRY,;          READ USER,ERROR-RETRY
 RDCK0,;          READ USER,OK-READ CHK(SOFTWARE)
 RETRY,;          READ USER,ERR REREADING-RETRY
 RDCK1            READ USER,OK-CONTINUE REREADING
*
         PAGE
************************************************************************
*                                                                      *
*        START I/O ON SWAP RAD                                         *
*        R15 = LINK = ADDRESS TO RETURN TO WHEN I/O                    *
*        R6 = COMMAND LIST ADDRESS                                     *
*                                                                      *
************************************************************************
*D*      NAME:    TSIO
*D*      ENTRY:   T:SIO
*D*      REGISTERS: ALL VOLATILE
*D*      CALL:    BAL,15 T:SIO
*D*      INTERFACE:
*D*               NEWQ- PERFORMS ACTUAL I/O
*D*               ERRLOG- ERROR REPORTING
*D*      ENVIORNMENT: MASTER,UNMAPPED
*D*      INPUT:   R6=BEGINNING CL ADDRESS
*D*               R7=SWAPPER FUNCTION CODE
*D*               R14=SWAP DEVICE TABLE INDEX
*D*               IOEA%ADR=SWAPPER RETURN ADDRESS
*D*               MH:CLEND=CL END ADDRESS
*D*               M:HLTIC=ADDRESS TO SENSE INTO
*D*               MB:#RTRY=# OF I/O RETRIES
*D*               MB:SFC=SWAPPER FUNCTION CODE
*D*               DCT12=I/O ADDRESS AT END ACTION
*D*               DCT13=TDV STATUS AT END ACTION
*D*               DOWTCK=SOFTWARE SWITCH,REQUESTS WRITE CHECKING
*D*               UX:JIT=ERROR ANALYSIS
*D*               S:ISUN,S:JCL,SB:OSUL,S:BECL=ERROR ANALYSIS
*D*               LOW=LOWER LIMIT FOR PAGE ADDRESSES
*D*               HIGH=UPPER LIMIT FOR PAGE ADDRESSES IN CL
*D*      OUTPUT:  UH:FLG2-SWAP CONDITION FLAGS-ERROR REPORTING
*D*      DESCRIPTION: IF SOFTWARE CHECKING IS REQUIRED AS INDICATED
*D*               BY SENSE SWITCH 4 BEING SET, T:SIO RIPPLES
*D*               THROUGH THE COMPLETE CHAIN OF COMMAND LISTS
*D*               CHECKING FOR ERRORS. EACH COMMAND LIST ENTRY
*D*               CONSISTS OF 10 WORDS (1 SEEK AND 4 GRANULE GROUPS),
*D*               I.E. 5 IOCDS, THERE MUST BE A SEEK IOCD
*D*               FOLLOWED BY 4 IOCDS WITH READ OR WRITE ORDERS
*D*               IN ONE COMMAND LIST THERE MUST BE ONLY READS OR
*D*               WRITES BUT NOT BOTH. THE TRANSFER IN CHANNEL
*D*               COMMANDS (TIC IOCDS) MUST BE FOLLOWED BY AN IOCD
*D*               CONTAINING A SEEK OR SENSE ORDER. THE COMMAND
*D*               LIST MUST BE TERMINATED BY AN IOCD WITH A SENSE
*D*               ORDER WITH FLAGS '1E' OR AN IOCD WITH X'4C'
*D*               FLAGS. ALL PHYSICAL PAGE NUMBERS CONTAINED IN THE
*D*               BYTE ADDRESSES OF IOCDS WITH READ OR WRITE ORDERS
*D*               MUST BE WITHIN THE RANGE OF PHYSICAL PAGES, NOT
*D*               CONTAINING THE MONITOR,USED BY THE SYSTEM, AS
*D*               DEFINED(THE RANGE) BY THE VALUES CONTAINED
*D*               IN LOCATIONS LOW AND HIGH. IF ERRORS ARE FOUND
*D*               A SCREECH CODE IS REPORTED TO RECOVERY.
*D*               IF THERE ARE NO ERRORS, THE NUMBER OF RETRIES
*D*               IS INITIALIZED AND SET%REG IS CALLED TO SET UP THE
*D*               ARGUMENTS IN REGISTERS FOR NEWQ. NEWQ IS CALLED
*D*               UPON TO QUEUE UP THE REQUEST. UPON RETURN, T:SEXIT
*D*               IS EXECUTED.
*D*               T:SEXIT PULLS A RETURN ADDRESS FROM THE STACK AND
*D*               TRANSFERS CONTROL TO THAT LOCATION. WHEN THE SWAP
*D*               SCHEDULAR WAS ENTERED, THE ADDRESS OF THE CALLER
*D*               WAS PUSHED INTO THE STACK. THE 1ST TIME T:SEXIT
*D*               IS CALLED, IT WILL RETURN TO THAT CALLER.
*D*               WHEN THE I/O SYSTEM HAS FINISHED PROCESSING A
*D*               SWAPPER INTERRUPT, IT TRANSFERS CONTROL TO END
*D*               ACTION IN TSIO. THIS END ACTION ROUTINE PUSHES INTO
*D*               THE STACK THE RETURN LOCATION OF THE I/O SYSTEM
*D*               THE END ACTION RETURNS TO THE SWAPPER ( NOT BY
*D*               THE STACK , BUT BY IOEA%ADR) WHICH SETS UP ANOTHER
*D*               REQUEST AND CALLS TSIO AGAIN AND FINALLY T:SEXIT
*D*               GETS EXECUTED AGAIN, WHICH PULLS AND RETURNS
*D*               TO THE I/O SYSTEM AND TO THE POINT OF INTERRUPT
*D*                  WHEN THE I/O SYSTEM FINISHES THE I/O AND PROCESSES
*D*               THE INTERRUPT, IT TRANSFERW TO T:SIOEA,WITH
*D*               INFORMATION ABOUTANY ERRORS. T:SIOEA PUSHES
*D*               THE RETURN ADDRESS INTO THE STACK. IF THE I/O SYSTEM
*D*               DETECTED ANY ERRORS, TSIO RETRIES(BY CALLING
*D*               NEWQ) N TIMES. IF THESE RETRIES ARE ALL UNSUCCESSFUL
*D*               A USER FLAG IS SET (UH:FLG2) AND TSIO CONTINUES
*D*               I.E. RETURNS TO THE SWAPPER. PRIOR TO EXECUTION
*D*               OF THE USER IF ONE OF THESE FLAGS IS SET, THE
*D*               ERROR IS LOGGED AND APPROPRIATE ACTION TAKEN.
*D*               IF THE FLAG INDICATES THAT A WRITE OR WRITE CHECK
*D*               FAILED ON ANY PAGE OF THE USER OR A READ OR READ
*D*               CHECK FAILED AND IT WASN'T IN THE USER CONTEXT
*D*               AREA, AND ERROR MESSAGE IS OUTPUT TO THE USER
*D*               AND EXECUTION CONTINUES AS USUAL. IF THE ERROR
*D*               WAS IN READING THE CONTEXT OR JIT, THE USER
*D*               IS DELETED IN THE APPROPRIATE FASHION.
*D*               IF THE FUNCTION WAS A WRITE CHECK, RETRY CONSISTS
*D*               OF RE-WRITING AND THEN RETRYING THE WRITE CHECK.
*D*               ALL SUCCESSFUL WRITES ARE WRITE CHECKED IF DOWTCK
*D*               IS SET. NO MATTER HOW MANY CLS ARE IN CHAIN, IT
*D*               IS EXECUTED AT ONE TIME IF THE FUNCTION IS READ
*D*               OR WRITE. WRITE CHECKING REQUIRES THE CHAIN TO BE
*D*               PARTITIONED AND I/O INITIATED SEPARATELY FOR EACH
*D*               PART. THE AJIT AND JIT ARE WRITE CHECKED FIRST.
*D*               WHEN THIS IS COMPLETED, THE JIT CAN BE ALTERED
*D*               BY SETTING WRITE CHECK ORDERS IN THE USERS CL.
*D*               IF THERE IS ANOTHER USERS JIT CL FOLLOWING,
*D*               IT CAN BE DONE AT THE SAME TIME. SO THE ROUTINE
*D*               RIPPLES THROUGH THE CHAIN, CHANGING WRITE ORDERS
*D*               TO WRITE CHECKS, UNTIL IT FINDS A TIC FROM A JIT
*D*               CL TO A USER CL, AT WHICH POINT IT RESETS THE
*D*               CHAINING FLAG AND SETS THE INTERRUPT FLAG. AFTER
*D*               THIS I/O IS COMPLETED, IT CONTINUES WHERE IT LEFT
*D*               OFF UNTIL IT FINDS THE NEXT USER CL. AN UNSUCCESSFUL
*D*               WRITE CHECK RESULTS IN ONLY THAT SECTION BEING
*D*               REWRITTEN AND THEN RECHECKED.
*D*               WHEN ALL REQUESTED I/O HAS BEEN COMPLETED, TSIO
*D*               RETURNS TO THE SWAPPER.
T:SIO    EQU      %                                                    *
         NOP
         LW,R4    R14               SWAP DEVICE TABLE INDEX
         STW,R6   M:CLBGN,R4        SAVE  BEGINING OF  CL ADDRESS
         STB,R7   MB:SFC,R4         SAVE   SWAP I/O FUNCTION CODE
*  IF WRT FCN, SET UP LASTDA & NWTCKINT FOR WRT CK
         CI,7     01
         BNE      TSI001
         LW,R5    M:HLTIC,R4        TIC TO HALT COMMAND
         AND,R5   XFFFF
         SLS,R5   1                 COUNTERACT NEXT INSTRUCTION
TSI001   EQU      %
         SLS,5    -1
         STH,R5   MH:CLEND,R4        SAVE  COMMAND LIST END ADDRESS
         SLS,5    1
         RD,0     0
         BCR,1    T3                SKIP IF SW 4 RESET
         PUSH     6,R14
         LW,2     6
        LB,15    *5
         AI,5     1
        CI,15    X'1E'
        BE       T4
** E **
         CW,5     2
         BNE      T4
*S*      SCREECH CODE: 0E
*S*      REPORTED BY TSIO
*S*      MESSAGE:  I/O REQUEST WITH NULL COMMAND LIST.
*S*      REGISTERS: 2=BEGIN COMMAND LIST ADDRESS
*S*                 5=END COMMAND LIST ADDRESS
*S*      REMARKS: DETECTED WHEN SS4 SET.
         SCREECH  X'E'              SCREECH .E
T4       LI,3     8
** A **
         LB,3    *2,3
         BNEZ     T4C
SCR0A    SCREECH  X'A'              SCREECH .A
T4C      CI,3     2
         BG       SCR0A
         AI,5     -1
T1       LB,1     *2                CHECK FOR SEEK
** B **
T2       EQU      %
         CI,1     4
         BE       DONE
         CI,1     3
         BE       T2C
*S*      SCREECH CODE: 0B
*S*      REPORTED BY: TSIO
*S*      MESSAGE: INCORRECT ORDER CODE IN SWAP COMMAND LIST
*S*      REGISTERS: 1=INCORRECT ORDER CODE
*S*                 2=COMMAND LIST ADDRESS
*S*                 6=BEGIN COMMAND LIST ADDRESS
*S*      REMARKS: DETECTED WHEN SS4 SET
         SCREECH  X'B'              SCREECH .B
T2C      EQU      %
T33      LI,8     4
T35      EQU      %
         AI,2     2
         LW,1     0,2               CHECK BUFFER
         AND,1    M24
         SLS,1    -11
** C **
         CW,1     LOW
        REF      NPMC
         BGE      T35C
        CI,1     NPMC
         BE       T35B
         LW,R15   0,2
         LB,R15   R15               GET F.C.
         CI,R15   8                 IS IT A TIC
         BE       T35C              YES--NO S/C 'C'
*S*      SCREECH CODE: 0C
*S*      REPORTED BY: TSIO
*S*      MESSAGE: ATTEMPT TO SWAP MONITOR MEMORY
*S*      REGISTERS: 1=BUFFER ADDRESS
*S*                 2=COMMAND LIST ADDRESS
*S*                 6=BEGIN COMMAND LIST ADDRESS
*S*      REMARKS: DETECTED WHEN SS4 SET.
SCR0C    SCREECH  X'C'              SCREECH .C
T35B     CI,3     2
         BE       SCR0C
T35C     CW,1     HIGH
         BG       SCR0C
         LB,1     *2
** A **
         CW,1     3                 ALL READ OR ALL WRITE
         BE       T35G
*S*      SCREECH CODE: 0A
*S*      REPORTED BY: TSIO
*S*      MESSAGE: OPCODE IN SWAP COMMAND CHAIN IS INVALID
*S*      REGISTERS: 1=INCORRECT ORDER CODE
*S*                 2=COMMAND LIST ADDRESS
*S*                 6=BEGIN COMMAND LIST ADDRESS
*S*      REMARKS: DETECTED WHEN SS4 SET.
         SCREECH  X'A'              SCREECH .A
T35G     EQU      %
         AI,2     1
         LB,1     *2
         AI,2     -1
         CI,1     X'1C'             CHECK FOR NO CC
         BE       DON1
         AI,2     2
T20      EQU      %
         LB,1     *2                CHECK FOR TIC
         CI,1     8
         BE       T22
         MTW,-1   8
         BLEZ     T2
         CI,1     3
         BE       T2
         B        T35+1
T22      EQU      %
         LW,2     0,2
         AND,2     M21
         SLS,2    1
         B        T1
** D **
DONE     EQU      %
         LW,0     1,2
         LB,0     0
         CI,0     X'1E'
         BE       DON1
*S*      SCREECH CODE:  0D
*S*      REPORTED BY: TSIO
*S*      MESSAGE: HALT FLAGS MISSING IN SWAP COMMAND LIST
*S*      REGISTERS: 2=COMMAND LIST ADDRESS
*S*                 6=BEGIN COMMAND LIST ADDRESS
*S*      REMARKS: THE SENSE COMMAND AT THE END OF THE COMMAND
*S*                 LIST MUST HAVE FLAGS = X'1E'.
*S*               DETECTED WHEN SS4 SET.
         SCREECH  X'D'              SCREECH .D
DON1     EQU      %
         LB,R2    MB:SFC,R4         I/O FUNCTION CODE
         BGZ      DON1C
*S*      SCREECH CODE: 0F
*S*      REPORTED BY: TSIO
*S*      MESSAGE: INPUT FUNCTION CODE IS INVALID
*S*      REGISTERS: 2=SWAPPER FUNCTION CODE.
*S*      REMARKS: DETECTED WHEN SS4 SET.
SCR0F    SCREECH  X'F'              SCREECH .F
DON1C    CI,2     5
         BG       SCR0F
         PULL     6,R14
T3       EQU      %
         LI,R0    #RETRIES
         STB,R0   MB:#RTRY,R4        SAVE  # OF   RETRIES
         LW,0     6                 ADDRESS OF COMMAND LIST TO R0      *
         SLS,0    -1                FORM DOUBLEWORD ADR
         STW,15   IOEA%ADR          SAVE LINK AS END ACTION ADDRESS
DO%IO    EQU      %
         LW,14    4                 PUT RADX IN 14
         BAL,R15  SET%REG           SET REGS FOR NEWQ
         LI,15    0                 CLEAR NEWQ SEEK REG
         BAL,R11  NEWQ              QUEUE UP SWAP I/O REQUEST
         NOP                        RETURN IS +2
T:SEXIT  EQU      %
         PULL     R11               GET LINK
         B        *R11              RETURN TO IOQ CLEANUP
         PAGE
************************************************************************
*                                                                      *
*        SENSE CURRENT SECTOR POSITION OF SWAP RAD ROUTINE             *
*        LINK     R15                                                  *
*        TEMP     R5                                                   *
*        OUTPUT:
*                 R10 = CURRENT SECTOR POSITION                        *
*                                                                      *
************************************************************************
T:SENSE  EQU      %
         LI,0     DA(SENSE%ORDR)    DA OF COMMAND LIST FOR SENSE
         LW,R1    R15             SAVE LINK IN END ACTION REGISTER
         LW,2     14                GET SWAP INDEX AND BYPASS RETRY SETUP
         BAL,15   SET%REG+3         ON CALL TO SETUP NEWQ REGS.
         LI,R0    T:SENSE%EA        SENSE END ACTION ADDRESS
         BAL,R11  NEWQ              CALL NEWQ
         NOP
         B        T:SEXIT           RETURN TO WHEREVER
*
T:SENSE%EA EQU    %
         PUSH     R11               SAVE CLEANUP LINK
         LI,R5    2                 BYTE OFFSET
         LB,10    SECTOR,5          GET CURRNENT SECTOR POSITION
         B        *R14              (R14)=END ACTION INFO FROM ABOVE
         PAGE
*
*        LOAD ARGUMENTS FOR NEWQ CALL
*
SET%REG  EQU      %
         LW,R2    R14               GET SWAP RAD SPECIAL TABLE INDEX
         LB,1     MB:#RTRY,2        SET RETRY COUNTER IN CASE OF ERROR
         AI,1     #RETRIES**8       SET INITIAL RETRY COUNT.
         STB,R2   R1                INCLUDE SWP TBL NDX IN END INFO
         LB,R12   MB:SDI,R2         GET SWAP RAD DCT INDEX
         AI,12    X'100'            SET RETRIES TO 1 TO GET SEC ERR
         LI,13    SWAP%PRI+X'600'   LOG DONE BY HANDLER.
*                                   ADD PRIO AND FUNCTION CODE 6.
         STH,13   12
         LW,R13   R0                COMMAND LIST ADDRESS
         LI,R14   1                 ONE 5 SEC TIME OUT INCREMENT
         LI,R0    T:SIOEA           MOST PROBABLE END ACTION ADDRESS
         B        *R15              RETURN
         PAGE
************************************************************************
*                                                                      *
*        SWAP RAD I/O END ACTION ROUTINE                               *
*                                                                      *
************************************************************************
T:SIOEA  EQU      %                                                    *
         PUSH     R11               SAVE LINK
         LB,R4    R14                SWAP  DEVICE TABLE  INDEX
RDCK%RTRY EQU     %
         LB,R12   R12               I/O  TYPE  OF  COMPLETION
         CI,R12   1                  1 = NORMAL
         BE       ERCONT
*
         LD,2     S:SWSTAT          TDV STATUS SAVED BY HANDLER
         LC       3                 GET STATUS
         BCR,8    NOTOV
         DISABLE
         LI,3     SCU               GET CURRENT USERS
         LB,3     SB:HQ,3
         BEZ      OVCONT            NO CURRENT USERS
OVLOOP   LH,8     UH:DL,3           GET DOLIST
         OR,8     X7000             TURN ON BITS FOR O.V.
         STH,8    UH:DL,3
         LB,3     UB:FL,3           NEXT USER
         BNEZ     OVLOOP            YES
OVCONT   MTB,1    MB:#RTRY,4        KICK UP RETRY COUNT
         ENABLE
NOTOV    EQU      %
         LI,12    0
ERCONT   EQU      %
         LW,8     2                 DCT13 STATUS
         LB,2     MB:SFC,4          FUNCTION CODE
         SLS,2    1
         AW,2     12
         LW,2     FCNSUBR,2
         B        *2
*
RETRY    EQU    %
         LB,R3     MB:SFC,R4          FUNCTION CODE
         MTB,-1 MB:#RTRY,4
         BEZ      N%ERRORS
RETRY:1  EQU      %
         LW,0     15
         B        DO%IO
*
END      EQU      %
         MTW,-1   #SWAP%DEV         WAIT FOR END ACTION ON ALL DEVICES
         BNEZ     T:SEXIT           OTHERWISE RETURN IMMEDIATELY
         B        *IOEA%ADR
         PAGE
*************************************
*        SET UP WRITE CHECK         *
*************************************
*
WTCK0    EQU      %
         DO       WTCK
         MTW,0    DOWTCK
         BEZ      END
*  JUST COMPLETED WRT, IF WRT CK DESIRED, SET UP FOR IT
         LI,8     03                WRT CK FCN
         STB,R8   MB:SFC,R4
         LW,R8    M:CLBGN,R4
         STW,R8   M:WCKBCL,R4
         B        WTCK2
WTCK1    EQU      %
*  RESTORE FLGS IN SHELL CL
         LW,R7    M:HLTIC,R4        TIC TO HALT COMMAND
         AND,R7   XFFFF             ADDRESS ONLY
         SLS,R7   1                 WANT WA
         CW,R7    M:WCKBCL,R4       TEST IF DONE WITH WRITE CHECK
         BE       END
         LW,R5    M:WCKECL,R4
         LI,2     -4                OFFSET TO FLAG BYTE
         LB,8     *5,2
         AI,8     X'E'
         STB,8    *5,2              RESTORED WHERE DESTROYED BY INTR FLG
WTCK2    EQU      %
*  SET UP FOR NEXT SECTION OF WRT CK
         LI,2     12                DISP OF HALT FLGS FROM BEG OF ENTRY
         LI,12    08                TIC
         LI,13    04                HALT ORDER FOR WRT = SENSE
         LI,14    03                SEEK
         LI,15    01                WRITE
         LI,8     05                WRT CK
         LW,R6    M:WCKBCL,R4
WTCK3    EQU      %
*  IF ORDER IS TIC, SET WTCK ORDER-IF NOT,FIND OUT IF JIT OR USER
         CB,14    *6                IS THIS A SEEK
         BE       WTCK45            IF SO, SKIP IT
         CB,12    *6                IS THIS TIC
         BNE      WTCK4             NO
*  TIC - SAVE PRESENT POINTER TO CL & GET NEW
         LW,5     6                 SAVE PRESENT
         LW,6     0,6
         AND,6    M21
         SLS,6    1                 WA(NEXT SECTION OF CL)
         B        WTCK5
WTCK4    EQU      %
*  CHANGE WRITE TO WRITE CK AFTER SOME ERROR TESTS
         STB,8    *6                STORE WRTCK ORDER
WTCK45   EQU      %
         AI,6     2                 NEXT CL DBLWRD
         B        WTCK3
WTCK5    EQU      %
*  WHAT IS 1ST ORDER AFTER TIC
         CB,14    *6                IS IT SEEK
         BNE      WTCK7             SKIP IF ALL DONE
WTCK6    EQU      %
*  AFTER TIC ORDER WAS SEEK,IS CL JIT OR USER
         CLM,6    SCLLIM            IS CL IN SCL AREA IE. IS IT JIT
         BCR,9    WTCK45            YES CONTINUE PROCESSING
*  USER CL ENCOUNTERED SO SET INTERRUPT FLGS IN PREV JIT CL
         LI,2     -4
         LB,14    *5,2
         AI,14    -X'E'
         STB,14   *5,2              RESTORE FLAGS
WTCK7    EQU      %
         STW,R5   M:WCKECL,R4
         XW,R6    M:WCKBCL,R4
*  GO TO DO IO
         SLS,6    -1
         LW,14    4
         LW,0     6
         B        DO%IO
         PAGE
*                                 *
*        WRT IF WRT CK FAILS      *
*                                 *
*        IF WRT CK XMISSION ERR, RE WRITE THEN WRT CK
WRTAGN   EQU      %
         LI,2     1                 WRT ORDER
         LB,3     MB:SFC,4
         MTB,-1   MB:#RTRY,4        COUNT RETRIES
         BEZ      N%ERRORS          ALL THROUGH RETRYING..
         B        WRT2
WRT1     EQU      %
         PUSH     R11               SAVE CLEANUP LINK
         LI,2     5                 WRT CK ORDER
WRT2     EQU      %
         LB,14    14                RADX TO LO ORDR BYTE
         LW,R3    R15               COMMAND LIST ADR (RETURNED BY CLNUP)
         LW,R0    R15               SAVE FOR LATER
WRT3     EQU      %
         SLS,3    1
WRT4     EQU      %
         LB,1     *3
         CI,1     3                 IS IT SEEK
         BE       WRT5              YES
         CI,1     8                 IS IT TIC
         BNE      WRT7              NO WE MUST BE FINISHED
         LW,3     0,3               YES- GET DA OF NEXT PART OF CLIST
         AND,3    M21
         B        WRT3
WRT5     EQU      %
*        FOUND COMMAND TO CHANGE
         AI,3     2
         STB,2    *3                SET WRT OR WRT CK ORDER
         AI,3     1
         LC       *3                GET FLAGS
         BCR,2    WRT8              FINISHED IF NO CHAINING.
         AI,3     1                 YES DO MORE
         B        WRT4
WRT7     EQU      %
         CI,1     4                 IS IT A SENSE
         BNE      WRT5+1            NO, MUST BE WRITE.
*        FINISHED - SET LAST FLGS
         AI,3     1
WRT8     EQU      %
         LW,4     14                 GET RADX
         LD,8     DCT13,7           TDV STATUS W/CLIST ADR
         CI,2     5                 IS IT WRT CHK
         BE       RETRY:1
         BAL,R15  SET%REG           LOAD REGS FOR NEWQ
         LI,15    0                 CLEAR NEWQ SEEK REG
         LI,R0    WRT1              END ACTION ADDRESS FOR WRITE
         BAL,R11  NEWQ              Q I/O REQUEST
         NOP                        +2 RETURN FROM NEWQ
         B        T:SEXIT           ALL FOR NOW
         ELSE
         B        END
         FIN
*
         PAGE
*        READ CHECK USER            *
*
RDCK1    EQU      %
RDCK0    EQU      %
         LI,8     5
         STB,8    MB:SFC,4          SET FCN TO RD CK
         LI,8     #RETRIES
         STB,8    MB:#RTRY,4
*
         AND,7    M17
RDCK2 EQU      %
         LW,6     S:ISUN
         LI,2     0
         LOAD,5   UX:JIT,6
         SLS,5    9
         LW,13    JCLPA,5
         AW,13    JCLE,5            END OF CL
         DO       RDCK
         LW,6     5
         SLS,6    1
         AI,6     JHSWPCK
         LH,10    0,6
         AND,10   M16               GET INIT ID
         FIN
         LW,7     JCLPA,5
SICK1    EQU      %
         AI,7     2                 MEM ADR ENTRY OF CL
         LW,3     Y01
SICK2    EQU      %
         DO       RDCK
         LW,8     DORDCK
         BEZ      SICK6
*  LOOP, ONCE PER CL ENTRY IE PAGE
         CS,3     1,7               DON'T CHECK IF SKIP FLG SET
         BE       SICK6             YES, NO PHY PG ALLOC
         LW,5     0,7               GET BA OF MEM ADR
         SLS,5    -1
         AH,10    RDCKDSP1,5        COMPUTE CHECKSUM
         AH,10    RDCKDSP2,5
         AH,10    RDCKDSP3,5
         AH,10    RDCKDSP4,5
         FIN
SICK6    EQU      %
         STS,2    1,7               CLEAR NPMC FLG
SICK8    AI,7     2
         CW,7     13
         BGE      SICK7
         LB,8     *7
         CI,8     3
         BE       SICK8             SKIP SEEKS IN CLIST
         CI,8     8                 FINISHED IF TIC OR END CLIST
         BNE      SICK2
SICK7    EQU      %
         DO       RDCK
         LH,8     0,6
         AI,6     1                 NON-PURE  P FROM JIT
         AH,8     0,6
         CW,8     10                COMPARE WITH COMPUTED CKSUM
         BE       END               ALL RIGHT
         LB,7     MB:SDI,4
         STD,15   DCT13,7           SETUP CLIST ADDRESS
         B        RDCK%RTRY         AND RETRY.
         ELSE
         B        END
         FIN
         PAGE
*        FLAG ERRORED USER
*
N%ERRORS EQU      %
         AND,8    M21               TDV STATUS FROM DCT13.
         SLS,8    1
         CI,3     2
         BL       N%W0              WRITE ERR
         BE       N%R0              READ ERR
         CI,3     4
         BL       N%W0              WRT CHK ERR
         B        N%R0              READ ER
*
N%R0     EQU      %
         LW,1     S:ISUN
*
N%R2     EQU    %
         CLM,8    SCLLIM
         BOL      N%R2C
*S*      SCREECH CODE: 96
*S*      REPORTED BY: TSIO
*S*      MESSAGE: UNRECOVERABLE I/O ERROR READING
*S*               SHARED PROCESSOR.
*S*      REGISTERS: 8=COMMAND LIST ADDRESS FROM TDV STATUS
         SCREECH  X'96'             SCREECH .96
N%R2C    CLM,8    JCLLIM            CHECK IF ERROR IN JIT CLIST
         BOL      N%R5
*
*      ERROR READING JIT OR AJIT
         LH,9     UH:FLG2,1
         OR,9     X1                BAD JIT
         STH,9    UH:FLG2,1
         B        END
*
*        CHECK IF ERROR OUTSIDE OF USER CLIST
N%R5     EQU      %
         LOAD,2   UX:JIT,1
         SLS,2    9                 JIT PHYS ADDR
         LW,12    JCLPA,2
         LW,13    JCLPA,2
         AW,13    JCLE,2            BUILD CLIST LIMITS
         CLM,8    12
         BOL      N%W5F             SC 93 IF NOT IN USER CLIST
*
*        ERROR READING USER
         LB,12    *8
         CI,12    2                 IS IT READ ORDER
         BE       N%R6+1            YES
         CI,12    3                 IS IT SEEK
         BE       N%R6
         SCREECH  X'A'              SCREECH .A
*
N%R6     EQU      %
         AI,8     2
         LW,12    *8
         AND,12   M24            BYTE ADDR
         SLS,12   -11
         LOAD,9   UX:JIT,1
         SLS,9    9
         AI,9     JCMAP
         LI,10    2
         LI,2     JXBUFVP
         LI,13    JAJITVP+1
*
N%R7     EQU      %
         COMPARE,12 *9,2            PP IN CONTEXT
         BE       N%R8              YES
         AI,2     1
         CW,2     13
         BNE      N%R7
         CI,2     JAJITVP+1         END SPARES OR JITS
         BNE      N%R9              NO.. END DCBS...
         LI,2     JDCBUL-JCMAP
         LW,13    *9,2              UPPER LIMIT OF DCBS
         AI,13    1
         LI,2     JDCBLL-JCMAP      BEGIN SEARCHING FOR
         LW,2     *9,2              ERROR IN HIS DCBS.
         CW,2     13                ANY DCBS TO CHECK
         BNE      N%R7              YES
N%R9     EQU      %
         LI,10    4
*
N%R8     EQU      %
         LH,12    UH:FLG2,1
         OR,12    10
         STH,12   UH:FLG2,1
         AI,8     1
         LB,12    *8
         CI,12    X'20'             IS THERE CHAINING
         BAZ      END               NO
         AI,8     -1
         LI,12    #RETRIES
         STB,12   MB:#RTRY,4
         B        N%W7
         PAGE
*
N%W0     EQU      %
         LW,9     X1FE00
         LB,1     SB:OSUL
         LI,10    4                 ASSUME DATA ERROR
*
N%W3     EQU      %
         LD,12    S:BECL,1
         CW,8     12
         BL       N%W5              ERR NOT IN S:SCL
         AI,12    7
         CW,8     12                IS IT BTWN BCL,BCL+7
         BG       N%W4              NO, KEEP LOOKING
         LI,10    1                 YES, JIT/AJIT ERROR..
         B        N%W6              SET FLAG AND CONTINUE CLIST
*
N%W4     EQU      %
         CLM,13   SCLLIM
         BCR,9    N%W5
         CS,8     13
         BE       N%W6
*
N%W5     EQU      %
         BDR,1    N%W3
*S*      SCREECH CODE: 93
*S*       REPORTED BY: TSIO
*S*      MESSAGE: TDV COMMAND ADDRESS DOSN'T POINT TO COMMAND
*S*      LIST.
*S*      REGISTERS: 8=COMMAND LIST ADDRESS FROM TDV
*S*                 12,13=COMMAND LIST LIMITS.
*S*      REMARKS: OCCURS AFTER UNRECOVERABLE I/O ERROR
N%W5F    SCREECH  X'93'
*
N%W6     EQU      %
         LB,1     SB:OSUL,1
         LH,12    UH:FLG2,1
         OR,12    10                SET ERROR FLAG
         STH,12   UH:FLG2,1
         LI,12    #RETRIES
         STB,12   MB:#RTRY,4
         LW,12    M:HLTIC,4
         AND,12   XFFFF
         SLS,12   1
         CW,8     12                FINISHED YET
         BE       END
         LB,12    *8                ORDER CODE
         CI,12    3
         BL       N%W7              ITS READ OR WRITE
         CI,3     3
         BNE      N%W7
         LW,13    M:WCKECL,4
         AI,13    -2                ERROR ON WRITE CHECK
         CW,8     13
         BE       WTCK1             LAST IOCD IN CHAIN...
*
N%W7     EQU      %
         LI,1     5
*
N%W8     EQU      %
         AI,8     2
         LB,13    *8
         CI,13    3
         BE       N%W10
         CI,13    8
         BE       N%W10
         BDR,1    N%W8
*S*      SCREECH CODE 94
*S*      REPORTED BY: TSIO
*S*      MESSAGE: COMMAND LIST CLOBBERED DURING WRITE CHECK
*S*      REGOSTERS: 8=COMMAND LIST ADDRESS
*S*      REMARKS:  CANT FIND SEEK OR TIC WITHIN NEXT FIVE
*S*                COMMAND LIST ENTRIES.  OCCURS AFTER
*S*                UNRECOVERABLE ERROR DURING WRITE
*S*                OR WRITE CHECK.
         SCREECH  X'94'             SCREECH .94
N%W10    EQU      %
         SLS,8    -1
         LW,0     8
         B        DO%IO
         PAGE
         END

