*M*      MOCIOP PREPARES MOC SLAVE LINE I/O REQUESTS FOR NEWQNW.
         DEF      MOCIOP:           XDELTA LABEL FOR MOCIOP MODULE.
MOCIOP:  EQU      %
BITS     SET      1                 GET DEFINITIONS OF XN,YN,MN.
MONPROC  SET      1
         SYSTEM   UTS
R0       EQU      0
R1       EQU      1
R2       EQU      2
R3       EQU      3
R4       EQU      4
R5       EQU      5
R6       EQU      6
R7       EQU      7
R8,SR1   EQU      8
R9,SR2   EQU      9
R10,SR3  EQU      10
R11,SR4  EQU      11
R12,D1   EQU      12
R13,D2   EQU      13
R14,D3   EQU      14
R15,D4   EQU      15
*
*        THE FOLLOWING ARE OFFSETS INTO THE 4-WORD BLOCK GOT BY IORT
*        AND POINTED TO BY (J:RWECB) IN THE USER'S JIT.
*
*
LSTLOC   EQU      0                 WORD OFFSET
ECBLOC   EQU      1                 WORD OFFSET
BUFLOC   EQU      2                 WORD OFFSET
XLSTPG#  EQU      6                 HALF-WORD OFFSET
XBUFPG#  EQU      7                 HALF-WORD OFFSET
*
MULNRDCD EQU      0                 MULTI-PNT LINE READ FC
MULNWTCD EQU      X'80'             MULTI-PNT LINE WRITE FC
         PAGE
         DEF      MOCIOP            MODULE NAME
         DEF      CLRMULIO          RUN DOWN MOC SLAVE LINE I/O
         DEF      LNERRTBL          SLAVE LINE TABLE OF ERRORS
*
         REF      ADR:LIST          +14 WDS INTO DCB = POL/SEL LIST ADR
         REF      AUTORDL           MASK FOR LIST'S AUTO BIT =X'80000'
         REF      HALTL             MASK FOR LIST'S HALT BIT =X'40000'
         REF      TQUNMAP           GO UNMAPPED, SAVE INHIBIT STATUS
         REF      TQMAP             GO MAPPED, SAVE INHIBIT STATUS
         REF      VAL:INDX          +21 WDS INTO DCB = LIST INDEX VALUE
         REF      MSR01EXIT         GO HERE FOR PRE-I/O ERROR.
         REF      J:RWECB           4-WORD BLOCK ADDRESS IN JIT
         REF      UH:FLG            USED TO SET PPSWP BIT
         REF      T:IACU            CK LIST PAGE(S) ACCESS CODE
         REF      S:CUN             CURRENT USER# SAVED AS EAI
         REF      CJOB              CURRENT JOB PRIORITY FOR NEWQNW CALL
         REF      JX:CMAP           FOR FINDING BUFFER'S & LIST'S PP#
         REF      NEWQNW            MOCIOP CALLS IOQ AT THIS LABEL
         REF      CHKWAT            TO CK DCB'S WAIT/NO-WAIT FLAG
         REF      MSRWRTX           EXIT ADDRESS IF NO-WAIT REQUEST
         REF      APWP              TO ASSIGN BUFFER & LIST PAGES
         REF      RPWP              TO RELEASE BUFFER & LIST PAGES
         REF      ECBPOST1          TO POST USER'S ECB AT END ACTION
         REF      CALLCK1           EXIT TO IORT IF WAIT REQUEST
         REF      ECBCHCK1          WAIT FOR ECB POSTING AT I/O RUNDOWN
         REF      DCT2              TABLE HOLDS CIT INDEX OF DEVICES.
         REF      DCT6              TABLE HOLDS CURRENT IOQX OF DEVICE.
         REF      CIT1              TABLE =>HEAD OF IOQ'S THIS CHANNEL
         REF      CIT2              TABLE =>TAIL OF IOQ'S THIS CHANNEL
         REF      IOQ3              TABLE X'80' SET MEANS REQ BUSY.
         REF      IOQ13             TABLE EA-ADDR,EAINFO THIS REQ.
         REF      RC20              ROUTINE CLEANSUP I/O REQ @ COMP.
         REF      DCT23             HOLDS 'DCB-IS-OPEN' LINE BIT.
         REF      OPNBIT            BIT SAYS 'DCB OPEN' IN DCT23.
         REF      INUSEL            BIT SAYS LIST IN USE BY DCB.
         PAGE
*P*      NAME:    MOCIOP
*P*      PURPOSE: MOCIOP PREPARES MOC SLAVE LINE I/O REQUESTS FOR
*P*               NEWQNW AND HANDLES TASKS ASSOCIATED WITH I/O
*P*               COMPLETION, INCLUDING PURGING I/O REQUESTS
*P*               WHEN THE DCB ASSOCIATED WITH THE LINE IS CLOSED.
*P*      DESCRIPTION: MOCIOP CHECKS VALIDITY OF THE I/O REQUEST,
*P*               INCLUDING VERIFYING EXISTENCE OF AN ECB, VALIDITY
*P*               OF THE POLLING/SELECTION LIST OF THE DCB, COMPATI-
*P*               BILITY OF AN AUTOMATIC POLLING OPERATION IF
*P*               REQUESTED WITH THE STATE OF THE LIST, LOCKING LIST
*P*               AND CORE BUFFER PAGES INTO CORE, AND VALIDITY
*P*               CHECKING BUFFER SIZE, LIST LENGTH, AND INDEX VALUE.
*P*               IT THEN INVOKES NEWQNW SPECIFYING AN END-ACTION
*P*               ROUTINE WHICH UNLOCKS THE PAGES FROM CORE AND POSTS
*P*               THE ECB.
*P*               A SEPARATE ENTRY PURGES ALL PENDING I/O REQUESTS
*P*               FOR THE LINE FROM THE IOQ TABLES AND SETS THE LIST
*P*               AND THE LINE'S DEVICE TABLES TO INDICATE NOT-IN-USE.
*
*
*F*      NAME:    MOCIOP
*F*      PURPOSE: MOCIOP PREPARES MOC SLAVE LINE I/O REQUESTS FOR
*F*               NEWQNW AND HANDLES I/O COMPLETION TASKS.
*F*      REFERENCE: REPORT D.
*D*      NAME:    MOCIOP
*D*      REGISTERS: ALL BUT R6 ARE VULNERABLE.
*D*      CALL:    B MOCIOP
*D*               RETURNS TO MSRWRTX OR MSR01EXIT.
*D*      INTERFACE: T:IACU,APWP,RPWP,NEWQNW,CHKWAT,ECBPOST1.
*D*      ENVIRONMENT: MASTER MAPPED.  RETURNS ENABLED.
*D*               AN INTERNAL END-ACTION ROUTINE IS INVOKED UNMAPPED.
*D*      DATA:    4-WORD BLOCK AS USED BY MOCIOP --
*D*               WORD0- INDEX(0-7), REAL WA(LIST)(8-31).
*D*               WORD1- USER#(0-7), VIRTUAL WA(ECB)(8-31). FROM IORT
*D*               WORD2- REAL BA(BUFFER) (0-31).
*D*               WORD3- RP#(2ND LISTPG)(0-15),RP#(2ND BUFPG)(16-31).
*D*                     ZERO IF LIST/BUF DON'T CROSS PAGE BOUND.
*D*      INPUT:   R6= DCB ADDRESS OF A MOC SLAVE LINE DCB.
*D*                  ADR:LIST OF THE DCB POINTS TO A POL/SEL LIST.
*D*               J:RWECB= ADDRESS OF AN ECB 4-WORD BLOCK.
*D*                        SECOND WORD OF BLOCK HAS USER#,ECBADDR.
*D*               JX:CMAP CONVERTS VIRTUAL PAGES TO PHYSICAL PAGES.
*D*      OUTPUT:  J:RWECB=0; 4-WORD BLOCK PASSED TO NEWQNW TO HOLD
*D*                       REAL PAGE #'S & FOR POSTING ECB @ ENDACTION.
*D*               SR3= ERROR CODE IF ERROR ENCOUNTERED. (IN WHICH CASE
*D*                   J:RWECB NOT ZEROED).
*D*      DESCRIPTION: MOCIOP VERIFIES VALIDITY OF CALL --
*D*                .. POL/SEL LIST MUST EXIST & BE IN (01) SPACE.
*D*                .. ECB MUST EXIST (J:RWECB NONZERO).
*D*                .. IF 'AUTO' SPEC ON I/O CALL, I/O COUNT IN LIST
*D*                   MUST BE ZERO.
*D*                .. POL/SEL LIST SIZE NO MORE THAN 254.
*D*                .. 'INDX' VALUE IN I/O CALL NO MORE THAN LIST SIZE.
*D*                .. INDEXED LIST ELEMENT NOT EXCLUDED OR DUMMY.
*D*                .. USER BUFFER SIZE NO MORE THAN 2049 BYTES.
*D*                .. ALL LIST & BUFFER PAGES CAN BE LOCKED IN CORE.
*D*               IT THEN CALLS NEWQNW WITH 4-WORD BLOCK ADDRESS AS
*D*               END-ACTION INFO AND RETURNS TO MSRWRTX.
*D*               END-ACTION ROUTINE UNLOCKS PAGES AND POSTS ECB.
         PAGE
MOCIOP   EQU      %
*
*        SLAVE CPU USERS WILL BE SUSPENDED HERE IN ORDER
*        TO COMPLETE THIS CAL ON THE MASTER CPU
*
*------------------------*
         BLOCK
*------------------------*
         LI,R4    X'1FFFF'
         AND,R4   ADR:LIST,R6       R4 => DCB'S POL/SEL LIST.
         BEZ      LISTERR           *****> NO LIST IS AN ERROR.
*E*      ERROR:   32-04.
*E*      MESSAGE: BAD POLLING/SELECTION LIST ADDRESS.
         LW,R2    R4
         SLD,R2   -9                R2/R3 = PAGE#,WORD# OF P/S LIST.
         LW,R7    R2
         BAL,SR4  T:IACU              CHECK ACCESS ON LIST.
         BCS,2    LISTERR           *****>ERROR IF AC=2 OR 3.
         BCR,1    LISTERR           *****>ERROR IF AC=0. (IE AC=1)
         LI,R7    X'1FFFF'
         AND,R7   J:RWECB           R7 => ECB 4-WORD BLOCK.
         BEZ      ECBERR            *****> NO ECB IS AN ERROR.
*E*      ERROR:   5A-00.
*E*      MESSAGE: NO ECB SUPPLIED WITH SLAVE LINE I/O CALL.
         INT,R15  VAL:INDX,R6       R15= INDEX VALUE FROM I/O CALL.
*                                     (Y1 BIT MEANS 'AUTO' SPECIFIED)
         BCR,1    NOAUTO            --->AUTO NOT REQUESTED.
         OR,R7    Y8                  REMEMBER AUTO REQUESTED.
         MTB,0    *R4                 SEE IF ANY I/O OUTSTANDING.
         BNEZ     AUTOERR           *****> AUTO ILLEGAL WITH I/O.
*E*      ERROR:   59-03.
*E*      MESSAGE: AUTOREAD CONFLICTS WITH OUTSTANDING I/O REQUESTS.
NOAUTO   EQU      %
         INT,R13  0,R4              R13= LIST LENGTH.
         CI,R13   254
         BG       LSTLERR           *****> LIST TOO LONG; ERROR.
*E*      ERROR:   32-07.
*E*      MESSAGE: NUMBER OF POL/SEL LIST COMPONENTS EXCEEDS 254.
         AI,R15   0                   DID USER SPECIFY INDEX...
         BEZ      NOINDX            ---> NOT SPECIFIED.
         CW,R15   R13
         BG       INDXERR           *****> INDEX > LISTLEN; ERROR.
*E*      ERROR:   59-01.
*E*      MESSAGE: INVALID POL/SEL LIST INDEX VALUE.
         LCI      2                   THIS IS A CHEAT TO GET
         LM,R0    *R15,R4           R1 = LIST ENTRY POINTED BY INDEX.
         CW,SR1   Y04                 IS THIS A WRITE...
         BAZ      %+2               ---> NO.
         SLS,R1   +8                R1 (0-7) = POL OR SEL FLINK.
         LB,R1    R1                R1 = POL OR SEL FLINK.
         BEZ      EXCLERR           *****> EXCLUDED ELEMENT; ERROR.
*E*      ERROR:   59-02.
*E*      MESSAGE: POL/SEL LIST INDEX POINTS TO EXCLUDED OR DUMMY.
         CI,R1    X'FF'
         BE       EXCLERR           *****> DUMMY ELEMENT; ERROR.
NOINDX   EQU      %
         LW,R14   BLK,R6
         SLS,R14  -17               R14= BUFFER SIZE.
         CI,R14   2049                MUST FOR SURE FIT IN 2 PAGES.
         BG       BUFLERR           *****> ERROR; BUFFER TOO BIG.
*E*      ERROR:   32-00.
*E*      MESSAGE: MULTIPOINT LINE BUFFER SIZE MORE THAN 2049 BYTES.
*
*        NOW START LOCKING BUFFER/LIST PAGES IN CORE (APWP).
*
*4>LIST,6>DCB,7>4WB,8=FC/DCB,
*        2=VP#LIST,3=VW#LIST,13=LISTLEN,14=BUFLEN,15=INDX.
*
         LW,R5    R2                  SAVE IT IN R5 TOO.
         LOAD,SR3 JX:CMAP,R5
         BAL,SR4  APWP                ASSOCIATE LIST PAGE.
         BNEZ     APWPERR           *****>CANT ASSOCIATE.
         LOAD,R2  JX:CMAP,R5
         SLD,R2   +9                R2 = REAL WA(LIST).
         STB,R15  R2                R2 = INDX,RWA(LIST)  8,24.
         STW,R2   LSTLOC,R7           <<INTO 4-WORD BLOCK>>
         AND,R2   M9
         AW,R2    R13                 GET DISPL OF LIST END IN PAGE.
         CI,R2    511                 CROSSED A PAGE BOUND...
         BL       NOXLSTPG          --->NO.
         AI,R5    1                   ON TO NEXT PAGE.
         LOAD,SR3 JX:CMAP,R5
         BAL,SR4  APWP                ASSOCIATE SECOND LIST PAGE.
         BNEZ     APWPERR           *****>CANT ASSOCIATE.
         LOAD,R2  JX:CMAP,R5
         LI,R5    XLSTPG#
         STH,R2   *R7,R5              <<INTO 4-WORD BLOCK>>
NOXLSTPG EQU      %
         LW,R2    QBUF,R6
         LW,R3    BTD,R6
         STB,R3   R3
         SLD,R2   -9                R3 = BYTE# OF BUFFER.
         AND,R2   M8                R2 = PAGE# OF BUFFER.
         LW,R5    R2                  SAVE IT IN R5 TOO.
         LOAD,SR3 JX:CMAP,R5
         BAL,SR4  APWP                ASSOCIATE BUFFER PAGE.
         BNEZ     APWPERR           *****>CANT ASSOCIATE.
         LOAD,R2  JX:CMAP,R5
         SLD,R2   +11               R2=  REAL BA(BUFFER).
         STW,R2   BUFLOC,R7           <<INTO 4-WORD BLOCK>>
         AND,R2   M11
         AW,R2    R14                 GET DISPL OF BUFFEND+1 IN PAGE.
         CI,R2    2049                CROSSED A PAGE BOUND...
         BL       NOXBUFPG          --->NO.
         AI,R5    1                   ON TO NEXT PAGE.
         LOAD,SR3 JX:CMAP,R5
         BAL,SR4  APWP                ASSOCIATE SECOND BUFFER PAGE.
         BNEZ     APWPERR           *****>CANT ASSOCIATE.
         LOAD,R2  JX:CMAP,R5
         LI,R5    XBUFPG#
         STH,R2   *R7,R5              <<INTO 4-WORD BLOCK>>
NOXBUFPG EQU      %
*
*        NOW BUILD CALL TO NEWQNW.
*I:  4>LIST,6>DCB,7>4WB,8=FC/DCB,14=BUFLEN, 4WB= --,VAECB,RABUF,--.
*O:  12=FC/PRI/NRT/DCT,13=BUF,14=BUFLEN,15=SEEK,0=EAADDR,1=EAINFO.
*
         LW,R12   2,R6              L/# OF RETRIES
         SLS,R12  -16               POSITION # OF RETRIES
         LI,R13   X'FF'             L/MASK FOR LOADING DCTX
         LS,R12   DSI,R6            L/DCTX
         LB,R3    CJOB                GET CURRENT USER'S PRIORITY.
         STH,R3   R12               R12=   /PRI/NRT/DCT
         LW,R5    ECBLOC,R7         GET ECB ADDR. INTO R5
         DO1      MULNRDCD>0          (WE'LL CHEAT HERE SINCE THE
         AW,R12   L(MULNRDCD**24)      FC FOR READ IS ZERO)
         CW,SR1   Y04                 SEE IF THIS IS A WRITE OPERATION
         BAZ      %+2               --->NO.
         AW,R12   L((MULNWTCD-MULNRDCD)**24)  R12= FC/PRI/NRT/DCT
         LW,R13   BUFLOC,R7         R13= REAL BA(BUFFER).
*                                   R14= SIZE OF BUFFER.
         LI,R15   0                 R15= 0 SEEK ADDRESS.
         LI,R0    EAMULN            R0 = END-ACTION ROUTINE ADDRESS.
         LW,R1    R7                R1(16-31)=4WB ADDR; TEST SIGN.
         BGZ      %+3               --->'AUTO' NOT SPECIFIED.
         LW,R3    AUTORDL
         STS,R3   0,R4                SET 'AUTO' IN LIST IF SPEC'ED.
         MTB,1    *R4                 BUMP I/O COUNT IN LIST.
         STH,R14  R1                R1 = BUFLEN,4WBADDR (EA INFO)
*                                     CALL NEWQ 'UNMAPPED' FOR NO BUF
         BAL,SR4  NEWQNW              CHKS, NOWAIT FOR NO MF BUMP.
         B        DOWNERR           *****>ERROR, DEVICE IS DOWN.
*E*      ERROR:   59-04.
*E*      MESSAGE: MULTI-POINT LINE CONTROLLER DOWN.
         LI,R2    0
         LI,R3    X'1000'
         STS,R2   EGV,R6              CLEAR EGV IN DCB.
         LI,R3    X'1FFFF'
         STS,R2   J:RWECB             WE, NOT IORT, WILL DO ECB NOW.
         LW,R2    R5             R2 GETS ECBADDR IN CASE OF WAIT I/O
         BAL,R1   CHKWAT            SEE IF THIS WAS A NO-WAIT I/O REQUEST
         BEZ      MSRWRTX           ****B, IF SO TO COMMON EXIT CODE*****
         LI,D3    0                 SO THAT BAL,R1 JHKBIT (IN IORT) WORKS
         B        CALLCK1           CALL ECBCHCK1 & WAIT 'TIL ECB POSTED
         PAGE
CNMERRX4 EQU      %                 **  ERROR; FIX LIST & UNLOCK PGS.
         LW,R4    ADR:LIST,R6       R4 = LIST ADDESS.
         MTB,-1   *R4                 DECREMENT I/O COUNT IN LIST.
         AI,R7    0                   SEE IF AUTO SPECIFIED.
         BGEZ     %+3               --->NO.
         LCW,R2   AUTORDL
         AWM,R2   0,R4                CLEAR 'AUTO' IN LIST.
*
CNMERRX3 EQU      %                 **  ERROR; UNLOCK PAGES.
         LW,SR2   S:CUN               RPWP NEEDS USER# IN SR2.
         BAL,R1   CALLRPWP            UNLOCK ANY ASSIGNED PAGES.
         STW,SR3  0,R7                ZERO
         STW,SR3  2,R7                4-WORD
         STW,SR3  3,R7                BLOCK.
*
TOMSR01  LW,SR3   *R12              SR3= ERROR CODE.
         B        MSR01EXIT         ---> GO REPORT ERROR.
*
*
ECBERR   BAL,R12  TOMSR01
         DATA     X'0000005A'       5A-00.
LISTERR  BAL,R12  TOMSR01
         DATA     X'08000032'       32-04.
AUTOERR  BAL,R12  TOMSR01
         DATA     X'06000059'       59-03.
LSTLERR  BAL,R12  TOMSR01
         DATA     X'0E000032'       32-07.
INDXERR  BAL,R12  TOMSR01
         DATA     X'02000059'       59-01.
EXCLERR  BAL,R12  TOMSR01
         DATA     X'04000059'       59-02.
BUFLERR  BAL,R12  TOMSR01
         DATA     X'00000032'       32-00.
*
APWPERR  BLZ      APNOERR           *****  APWP ERROR.
         BAL,R12  CNMERRX3
         DATA     X'02000032'
*E*      ERROR:   32-01.
*E*      MESSAGE: UNABLE TO ASSIGN PWP: LIMIT REACHED.
APNOERR  BAL,R12  CNMERRX3
         DATA     X'04000032'
*E*      ERROR:   32-02.
*E*      MESSAGE: UNABLE TO ASSIGN PWP: PAGE NOT OWNED BY USER.
*
DOWNERR  BAL,R12  CNMERRX4
         DATA     X'08000059'       59-04.
         PAGE
*        UNLOCK LOCKED-IN-CORE PHYSICAL PAGES.
*        R7>4WORD BLOCK, R1=LINK, SR2=USER#.
*        USES R2,SR3,SR4.  RETURNS SR3=0.
CALLRPWP EQU      %
         LW,SR3   LSTLOC,R7           GET ADDRESS OF LIST.
         SLS,SR3  -9                  GET PAGE#.
         BAL,R2   FREEPWP             UNLOCK IT.
         LW,SR3   BUFLOC,R7
         SLS,SR3  -11                 GET PAGE# OF BUFFER.
         BAL,R2   FREEPWP             UNLOCK IT.
         LI,R2    XLSTPG#
         LH,SR3   *R7,R2              GET PAGE# OF LIST SECOND PAGE.
         BAL,R2   FREEPWP             UNLOCK IT.
         LI,R2    XBUFPG#
         LH,SR3   *R7,R2              GET PAGE# OF BUFF SECOND PAGE.
         BAL,R2   FREEPWP             UNLOCK IT.
         B        0,R1              ---> ALL DONE.
*
FREEPWP  EQU      %
         AND,SR3  M13                 SEE IF WE REALLY LOCKED A PAGE.
         BEZ      0,R2              --->IF NO PAGE, DON'D UNLOCK IT.
         BAL,SR4  RPWP                UNLOCK THE PHYSICAL PAGE.
         BEZ      0,R2              --->UNLOCKED OKAY; RETURN.
*S*      SCREECH CODE: 56-00.
*S*      REPORTED BY: MOCIOP.
*S*      MESSAGE: UNABLE TO RELEASE ASSIGNED PHYSICAL WORK PAGE.
*S*      REGISTERS: R7=>4WORD BLOCK FOR MOCIOP I/O CALL.
*S*               R10=PAGE#. R9=USER#.
*S*      REMARKS: MOCIOP WAS UNABLE TO RELEASE A PHYSICAL WORK PAGE
*S*               LOCKED IN CORE DURING TRANSACTION PROCESSING I/O
*S*               ON A MESSAGE-MODE LINE (I.E., 7605).
         SCREECH  X'56'
         PAGE
*        END-ACTION ROUTINE CALLED WHEN I/O COMPLETE.
*        CALLED UNMAPPED.  R11=RETURN,R12=TYC//RBC,R14=EA INFO.
EAMULN   EQU      %
         PUSH     R11
         INT,R7   R14               R7 = ADDRESS OF 4-WORD BLOCK.
         LW,R3    LSTLOC,R7         R3 = REAL WA(LIST).
         LI,R4    0
         LW,R5    AUTORDL
         OR,R5    HALTL               TURN OFF 'AUTO' AND 'HALT'
         STS,R4   0,R3                IN LIST.
         MTB,-1   *R3                 DECREMENT I/O COUNT IN LIST.
         LW,R5    ECBLOC,R7
         LB,SR2   R5                SR2= USER#.
         BAL,R1   CALLRPWP            UNLOCK BUFFER AND LIST PAGES.
*                                   R7 = 4-WORD BLOCK ADDRESS.
         LW,SR1   SR2               SR1= USER#.
         LH,SR2   R14
         SW,SR2   R12               SR2=(BUFSIZ-RBC)= # BYTES XFERRED.
         LW,R5    LSTLOC,R7
         LB,R5    R5                  GET LIST INDEX.
         STH,R5   SR2               SR2=     INDX/BYTEXFER.
         LB,R5    R12
         STB,R5   SR2               SR2= TYC/INDX/BYTEXFER.
         LW,SR3   ECBLOC,R7         SR3= ECB ADDRESS.
         LI,R5    0
         STW,R5   0,R7                MAKE SURE BLOCK ISN'T 'PERM'.
         BAL,SR4  ECBPOST1            POST THE ECB.
         PULL     R11
         B        *R11              --->RETURN (TO IOQ).
         PAGE
*F*      NAME:    CLRMULIO
*F*      PURPOSE: CLRMULIO RUNS DOWN I/O ON A SLAVE MESSAGE-MODE LINE.
*F*      DESCRIPTION: REQUESTS ARE TAKEN FROM THE BOTTOM OF THE LINE'S
*F*               IOQ ENTRY CHAIN. IF NOT BUSY, THE IOQ ENTRY IS
*F*               FREED. IF BUSY, 'HALT' IS SET IN THE LINE'S LIST AND
*F*               ECBCHCK1 IS CALLED TO AWAIT COMPLETION OF REQUEST.
*F*      REFERENCE: REPORT D.
*D*      NAME:    CLRMULIO
*D*      REGISTERS: ALL ARE PRESERVED.
*D*      CALL:    BAL,SR4 CLRMULIO
*D*      INTERFACE: ECBCHCK1,TQMAP/UNMAP,RC20(REQCOM).
*D*      ENVIRONMENT: MASTER MAPPED. (GOES UNMAPPED INTERNALLY).
*D*               RETURNS WITH INTERRUPTS ENABLED.
*D*      INPUT:   R6= DCB ADDRESS HOOKED TO LINE.
*D*               SR4= LINK.
*D*      OUTPUT:  'IN USE' RESET IN POL-SEL LIST OF DCB.
*D*               PPSWAP SET IN USER'S UH:FLG. (LIST IS IN PP).
*D*               OPNBIT RESET IN DCT23. (NO DCB OPEN NOW TO LINE).
*D*      DESCRIPTION: THE CHAIN OF IOQ ENTRIES FOR THE LINE, POINTED
*D*               TO BY CIT1/CIT2, IS SEARCHED TAIL-TO-HEAD. IF AN
*D*               ENTRY FOR THE LINE HAS X'80'(BUSY) CLEARED IN IOQ3,
*D*               THE ENTRY IS FREED BY ENTERING REQCOM AT RC20.
*D*               IF BUSY IS SET, 'HALTL' IS SET IN THE DCB'S POL-SEL
*D*               LIST (AND PPSWAP IS SET SINCE LIST IS IN PURE
*D*               PROCEDURE) AND ECBCHCK1 IS CALLED TO AWAIT CLOCKED
*D*               PURGING OF THE REQUEST.
CLRMULIO EQU      %
         LI,R4    X'1FFFF'
         AND,R4   ADR:LIST,R6       R4 = POL/SEL LIST ADDRESS.
         BEZ      *SR4              --->NO LIST; FORGET IT.
         PUSH     16,R0               SAVE ALL REGS.
         LI,R13   X'FF'
         AND,R13  DSI,R6            R13= DCTX OF LINE.
*
CKCIT1   EQU      %
         LW,R1    R13               R1 = DCT INDEX.
         LB,R2    DCT2,R1           GET CIT INDEX
         DISABLE                    **INHIBIT INTERRUPTS
         LB,R3    CIT1,R2           GET HEAD OF CHANNEL QUEUE
         BEZ      CLRMULX           B, IF EMPTY; NO OUTSTANDING I/O
         LB,R3    CIT2,R2           R3=> LAST REQUEST IN CHAN QUEUE.
         CB,R3    DCT6,R1             SEE IF REQUEST LINKED TO DEVICE.
         BE       %+3               --->YES. WAIT FOR IT TO FINISH.
         LC       IOQ3,R3             SEE IF REQUEST IS BUSY.
         BCR,8    RLSQSLOT          --->NO. CLEAN OUT Q ENTRY.
         LW,R5    HALTL               SET 'HALT' IN LIST, SO HANDLER
         STS,R5   0,R4                WILL TERMINATE I/O SOON.
         LD,R6    IOQ13,R3            MUST WAIT FOR REQ TO FINISH.
         AND,R7   M16                 GET 4-WORD BLOCK ADDR FROM EA.
         LW,R5    ECBLOC,R7         R5 = ECB ADDRESS.
         ENABLE                     **UNINHIBIT INTERRUPTS
         BAL,SR4  ECBCHCK1          WAIT FOR ECB TO BE POSTED
         B        CKCIT1            GO CHECK CHANNEL QUEUE AGAIN
*
RLSQSLOT EQU      %
         BAL,R1   TQUNMAP             GO TO RC20 UNMAPPED.
         BAL,R4   GOTORC20          DO BACK END OF REQCOM
         BAL,R1   TQMAP               GET MAPPED AGAIN.
         B        CKCIT1            --->CONTINUE DOWN IOQ CHAIN.
*
GOTORC20 PUSH     4,R1              REQCOM WILL WANT TO PULL THESE
         B        RC20              --->ENTER REQCOM.
*
CLRMULX  EQU      %
         ENABLE                     **UNINHIBIT INTERRUPTS
         LH,R2    DCT23,R1
         EOR,R2   OPNBIT              SAY LINE NO LONGER OPEN.
         STH,R2   DCT23,R1
         LW,R3    INUSEL              (NOTE R2 HAS SMALL # IN IT)
         STS,R2   0,R4                RESET 'IN-USE' IN LIST.
         LW,R5    S:CUN
         LH,SR3   UH:FLG,R5
         OR,SR3   X10                 SET 'PPSWAP'; LIST IS IN (01).
         STH,SR3  UH:FLG,R5
         PULL     16,R0               RESTORE REGS.
         B        *SR4              ---> RETURN TO CALLER.
         PAGE
LNERRTBL EQU      %                 FOLLOWING ARE CNM MOC ERR/ABN CODES
         DATA,2   0
         DATA,2   0                 DATA READ; NORMAL COMPLETE (READ)
         DATA,2   X'590A'           NO RESPONSE FROM TERMINAL (READ)
         DATA,2   X'590C'           TERMINAL NOT IN TRANSMIT STATE(READ)
*                                   OR HALT SPECIFIED;OR END OF OPN
*                                   LIST HIT.
         DATA,2   X'590E'           BAD TRAILER (READ)
         DATA,2   X'5910'           PARITY ERR IN RECORD RECEIVED (READ)
         DATA,2   X'5912'           BAD HEADER (READ)
         DATA,2   X'5914'           NO RESPONSE FROM TERMINAL (WRITE)
         DATA,2   X'5916'           BAD 1ST CHAR IN RESPONSE HDR (WRITE)
         DATA,2   X'5918'           TERMINAL NOT IN RECEIVE STATE (WRITE)
         DATA,2   X'591A'           INTERNAL TERMINAL ERROR (READ)
         DATA,2   0                 DATA SENT; NORMAL COMPLETE (WRITE)
         DATA,2   X'591C'           TERMINAL NAK RECORD (WRITE)
         DATA,2   X'591E'           LOST DATA (WRITE)
         DATA,2   X'5920'           ILLEGAL RESPONSE (READ)
         DATA,2   X'3210'           END OF OPEN LIST HIT ON AUTO READ
         DATA,2   X'32E0'           STATUS INSTEAD OF DATA IN BUFF(READ)
         END

