         PCC      0                 DONT PRINT GARBAGE
         TITLE    'IOQM - MAPPED SEGMENT FOR I/O QUEUEING'
*M*      NAME:    IOQM - MAPPED ROUTINES AND ENTRY POINTS TO I/O QUEUEING
*P*
*P*      THE FOLLOWING ROUTINES MAY BE FOUND IN THIS MODULE
*P*
*P*      ROUTINE        FUNCTION
*P*      -----------    -----------------------------------------------
*P*      CHKDA       ENTRY TO CHECK DISC ADDRS AND SAVE 4 THRU 6
*P*      CHKDAQ      ENTRY TO CHECK DISC ADDRS - NO REGISTER SAVE
*P*      MSGOUT      SEND MSG TO OPERATOR'S CONSOLE
*P*      NEWQ        MONITOR TYPE I/O ENTRY
*P*      NEWQNW      ENTRY TO NEWQ FOR NO-WAIT I/O
*P*      NEWQNWM     ENTRY TO NEWQ (MAPPED) FOR NO-WIAT I/O
*P*      OCQUEUE     QUEUE MSG FOR OPERATOR'S CONSOLE
*P*      OLWRITE     WRITE TAPE ERROR MESSAGES TO THE ONLINE USER
*P*      PVCHKDA     CHECK PRIVATE PACK DISC ADDRS
*P*      QUEUE       ENTRY FOR I/O WITH DCB AND NO END ACTION
*P*      QUEUE1      ENTRY FOR I/O WITH DCB AND END ACTION
*P*
*
*        SET CONTROL SETTINGS FOR UTS PROCEDURES  AND INTERNAL
*        VERSIONS
*
MONPROC  SET          1
DISCBPROC SET         1
BITS     SET          1
         SYSTEM       UTS
*
DEFER    SET          0          DO NOT DEFER START/CLEANUP
*
         PAGE
*
*        IOQM EXTERNAL REFERENCES
*
WABLK    EQU      BLK            *                                            .
         REF      BUFLIMS        * LIMITS OF WA FROM MPOOL TO TOP             .
         REF      C:RTRW         *                                            .
         REF      CFUBIT                                                      .
         REF      CIT1              CHANNEL INDEX TABLE 1
         REF      DCT2              DCT2 - CIT HEAD
         REF      CJOB           * JIT POINTER AT LOC X'4F'                   .
         REF      COCIO          *                                            .
         REF      CTACT          *                                            .
         REF      CTFLAGS        *                                            .
         SREF     CTGL           *                                            .
         SREF     CTINT          *                                            .
         REF      CTOC           *                                            .
         SREF     CTWD           *                                            .
         REF      DCACCESS       *                                            .
         REF      DCT%MASK       *                                            .
         REF      DCT%MASK%2     *                                            .
         REF      DCTSIZ         * LENGTH OF DCT TABLES                       .
         REF      DCT11          * DEVICE I/O OVERDUE TIME BUCKET             .
         REF      DCT16          * DEVICE NAME IN EBCDIC                      .
         REF      DCT22          * INDEX  INTO SEEK CONVERT TABLES            .
         REF      DCT24          * RMA TABLE (PARTITION...ETC)                .
         REF      DCT4           * OH:NM INDEX                                .
         REF      DCT6           * QUEUE HEAD INDEX                           .
         REF      DISCLIMS       *                                            .
         REF      DPACCESS       *                                            .
         REF      E:IP           * I/O IN PROGRESS EVENT CODE                 .
         REF      IOCLOCK        * # OF 5 SECOND INTERVALS ELAPSED
         REF      IOCTQ          *                                            .
         REF      IOQ2              IOQ FLINK
         REF      IOQ4           * CALLERS FUNCTION CODE                      .
         REF      IOQ7           * DCT INDEX OF DEVICE                        .
         REF      IOQ8           * BA OF BUF OR DBL-WORD OF CDW               .
         REF      IOQ9           * #  CDWS  `OR # OF BYTES                    .
         REF      IOQ12             DCT INDEX OF DEV. ERR. MSG
         REF      IOQ15             USER NUMBER
         REF      IOSCHED           * ENTRY TO I/O SCHEDULER
         REF      J:CTIME        *                                            .
         REF      J:DCBLINK      * DCB POINTER IN USER JIT                    .
         REF      J:JIT          * WA OF JIT                                  .
         REF      J:RWECB        *                                            .
         REF      JIT            * WA OF THE JIT                              .
         REF      JOVVP          *                                            .
         REF      JOVVPA         *                                            .
         REF      JX:CMAP        *                                            .
         REF      JXCMAP         *                                            .
         REF      KEYINBUF       * OPERTOR KEYIN INTO THISBUFFER              .
         REF      MPOOL          * MON POOL CHAIN                             .
         REF      MPOOLIM        *                                            .
XFF      EQU      M8             * DATA OF X'000000FF'                        .
         REF      OCDCT          * DCT INDEX OF OC DEVICE                     .
         REF      REGIPSD        *                                            .
         REF      S:CUN          * CURRENT USER # SLOT                        .
         REF      SC1900         *                                            .
         REF      SL:BXMF        * LIMIT I/O MAX FOR BATCH JOBS
         REF      SL:OXMF        * LIMIT I/O MAX FOR ONLINE JOBS
         REF      SL:BIOTA          * TABLE OF IOTA'S (B-G-O)
         REF      T:REG          * REPORT EVENT AND GIVEUP CONTROL            .
         REF      TB:FLGS        *                                            .
         REF      TPACCESS       *                                            .
         REF      TP33              *
         REF      UB:PRIO        * USER'S CURRENT PRIO TABLE                  .
         REF      UB:MF          * USER COUNT OF OUTSTANDING I/O'S
         REF      UNMAP          * GOES UNMAPPED ROUTINEIN ERHNDLR            .
         REF      UNEWQ             * ENTRY TO UNMAPPED NEWQ SEGMENT
         REF      UQUEUE            * ENTRY TO UNMAPPED QUEUE SEGMENT
         REF      YFF            * DATA OF X'FF000000'                        .
         REF      Y03               * CONSTANT X'03000000'
         REF      Y06            * DATA OF X'06000000'                        .
         REF      1Q2               UNMAP POINT IN FRONTEND
         REF      T:GJOBSTRT        * START UP GHOST
         REF      PIGHEAD           *  CHAIN FOR PIGEONS BUFFERS HEAD
         REF      IOQ3              * STATUS CONTAINING ERROR BIT
         REF      J:TELFLGS         * TEL FLAGS CONTAINING ERROR BIT
         REF      BATAPE            * CONVERSION FACTOR DCTX/AVRX
         REF      AVRID             * ID OF THE TAPE UNIT
         REF      ECBGBLK           *  ROUTINE TO STEAL COC BUFFER
         REF      #DLBLKS           * # OF DO LIST BLOCKS IN USE BY PIGEON
         REF      HRBA              * # COC BUFFERS * 4
         REF      AVRTBL            * AVR TABLE CONTAINING SERIAL #
         REF      ANSFLGS           * AVR TABLE CONTAINT TYPE TAPE
         PAGE
*
*        IOQM INTERNAL DEFINITIONS
*
         DEF      IOQM:             * MODULE BASE ADDRESS
*
         DEF      CHAINCHK          * CHECK FOR DATA CHAINING IOCD
         DEF      CHKDA          *
         DEF      CHKDAQ         *
         DEF      CTRIG1            DISABLED ENTRY POINT
         DEF      CTRIG             CONTROL TASK TRIGGER
         DEF      ENBSR4            ENABLE RETURN *SR4(R11)
         DEF      MSGOUT         * WRITES MSG AS PASSED
         DEF      MSG1
         DEF      MSG2           *
         DEF      MSG3           *
         DEF      MSG4           *
         DEF      MSG5           *
         DEF      MSG7           *
         DEF      MSG9           *
         DEF      MSG9A          *
         DEF      NEWQ           * MONITOR TYPE I/O
         DEF      NEWQNW         * NEWQ ENTRY NO-WAIT
         DEF      NEWQNWM        * NEWQ ENTRY MAPPED-NO WAIT
         DEF      OCQUEUE        *
         DEF      OCWRITE
         DEF      TP30
         DEF      TP31
         DEF      TP32
         DEF      TYPEMSG
         DEF      TYPERSP
         DEF      PVCHKDA        *
         DEF      QUEUE          * I/O THRU DCB WITH END ACTION
         DEF      QUEUE1         * I/O THRU DCB W/O END ACTION
         DEF      OLWRITE           *  ROUTINE TO TRIGGER PIGEON
         DEF      ERR:CHK           *  ROUTINE TO CHECK FOR CONTROL Y CONTROL
IOQM:    EQU      %                 MODULE NAME FOR PATCHING
         PAGE
*
*   REGISTER DEFINITIONS
*
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
*
*        BASIC I/O ROUTINES
*
*        NEWQ CALLING SEQUENCE;
*
*   R12       FC/PRI/NRT/DCTX                         (8,8,8,8)
*   R13       DATA CHAIN,CMND CHAIN,BA OF BUFFER      (1,1,6,24)
*   R14       BUFFER SIZE IN BYTES                    (0,16)
*   R15       GENERALIZED DISC ADDRESS                (32)
*   R0        END ACTION WORD ADDRESS                 (32)
*   R1        END ACTION INFO  TO RETURN              (32)
*
*
*          QUEUE/QUEUE1  CALLING SEQUENCE;
*
*   R8        FC/DCB ADDRESS                          (8,0,17)
*   R9        END ACTION ADDRESS                      (32)
*   R10       END ACTION INFO                         (32)
*
*          BOTH ROUTINES ENTERED  ON  BAL,11
*
         PAGE
*
*        FRONTEND - PROVIDES SCHEDULER INTERFACE FOR I/O REQUESTS
*                   FROM MAPPED USERS.  A CHECK IS MADE TO SEE IF
*                   THE USER HAS MORE THAN THE ALLOWED NUMBER OF
*                   I/O REQUESTS ALREADY IN PROGRESS BEFORE PERMITTING
*                   ANOTHER TO BE ENQUEUED.  THE USER IS BLOCKED
*                   BY PLACING HIM IN 'SIOMF'.
*
*                   THE USER MASTER FUNCTION COUNT IS INCREMENTED
*                   BEFORE THE USERS I/O IS INITIATED.
*
*                   FOR MAPPED REQUESTS, THE REAL RETURN FROM IOQ(R11)
*                   IS SAVED IN THE MAPPED TSTACK AND A DUMMY RETURN
*                   TO THE BACKEND OF FRONTEND IS SET IN R11.
*
*        CALLING SEQUENCE:
*
*        BAL,R2   FRONTEND
*        B        <PROPER BACKEND ENTRY>
*        B        <PROPER RECYLCE ENTRY>      FOR IOMF UNBLOCK
*        ....     ......            NORMAL EXIT IS TO BAL+3
*
*
*
IOUNMAP  :PSD     (IA,1Q2),(WK,1),(INH)
FRONTEND EQU      %
*------------------------------------*
         LW,4     1
         BLOCK
*------------------------------------*
         LW,1     4
         LB,R4    CJOB              ASSUME UNMAPPED
         LW,3     JIT               IF NO SYSID MUST BE MONITOR
         BEZ      SKREG2            YES IT IS
*                                   MAPPED USER MAKING THIS REQUEST
*
         MTW,1    C:RTRW            INCREMENT I/O COUNT
         LC       J:DCBLINK         GET NEWQNW/NEWQNWM FLAGS
         BCR,8    CHECKMF           NOT NW OR NWM
         LI,R3    0                 ZAPPER FOR FLAGS
         STB,R3   J:DCBLINK         CLEARE THEM
         BCR,4    %+2               NEWQNW
         LI,3     X'FF'             SET MAGIC USER NO FOR NEWQNWM
         PUSH     R11               SAVE REAL RETURN IN MAPPED STACK
         LI,R11   1Q3               SET RETURN TO BACKEND OF FRONTEND
         B        SKREG2            AND GO GET A QUEUE ENTRY
CHECKMF  RES      0
         LW,3     S:CUN
*
*        CODE ADDED 08-18-77 TO ACCESS SEPARATE IOTA'S BASED
*        ON TYPE OF USER
*
         LB,4     J:JIT             * TO GET INDEX TO IOTA'S
         SLS,4    -6                * IN LAST BYTE
         LW,4     SL:BIOTA,4        * FROM BEGINNING OF TABLE
         AWM,4    J:CTIME           ADD IT IN
         LB,4     JIT               FETCH USER TYPE BITS
         LB,3     UB:MF,3           GET MASTER FUNCTION COUNT
         SLS,4    -6                ISOLATE USER TYPE TO USE AS INDEX
         EXU      IPREGV,4          EXUCUTE PROPER INSTRUCTION
         BL       SKIPREG           LESS THAN LIMIT, SKIP REG
         PUSH     6
         PUSH     11
         LI,6     E:IP              REPORT
         BAL,11   T:REG               I/O PERMISSION REQUEST
         PULL     11
         PULL     6
         B        1,R2              RETURN IN IOMF BLOCK
IPREGV   CW,3     SL:BXMF           BATCH - USER TYPE = 0
         B        SKIPREG           GHOST - USER TYPE = 1
         CW,3     SL:OXMF           ONLINE  USER TYPE = 2
SKIPREG  LW,3     S:CUN             GET USER NO
         MTB,1    UB:MF,3           INCREMENT MASTER FUNCTION COUNT
*
SKREG    RES      0
         PUSH     R11               SAVE REAL RETURN
         LW,R11   R2                SET RETURN TO BACKEND POINTER
SKREG1   LB,4     UB:PRIO,3         GET USER PRIORITY
SKREG2   LPSD,0   IOUNMAP           UNMAP AND DISABLE
*
*     BACKEND OF FRONTEND FOR NEWQ
*
1Q1      RES      0
         MAP                        GO MAPPED FOR REG
         PUSH     6
         LI,6     0                 DCB ADDRESS OF ZERO FOR NEWQ
         XPSD,0   REGIPSD           REPORT TO SCHEDULER
         PULL     6                 RESTORE REG
1Q3      MAP                        * GO MAPPED FOR HIS JIT
         PULL     11                * RESTORE REAL RETURN
         LB,R2    DCT4,R2           * GET DEVICE TYPE INDEX
         LI,R1    DCACCESS          * ASSUME PUB RAD
         LC       TB:FLGS,R2        * GET DEVICE ATTRIBUTE FLAGS
         BCR,8    1Q4               * NOT TAPE OR DISC,NO ACCOUNTING
         BCR,4    INCTP             * TAPE ACCESS
         BCR,3    INCDC             * RAD ACCESS
*                                   * PACK ACCESS
         AI,R1    DPACCESS-TPACCESS **
INCTP    AI,R1    TPACCESS-DCACCESS **
INCDC    EQU      %                 **
         MTW,+1   J:JIT,R1          * ACCOUNT FOR IT
1Q4      RES      0
BISR4    RES      0
         B        *11
*
         PAGE
NEWQNWM  EQU      %                 NO WAIT MAPPED ENTRY
         LW,3     Y4
         STS,3    J:DCBLINK
NEWQNW   EQU      %
         LW,R3    Y8
         STS,R3   J:DCBLINK
*F*
*F*      NAME:       NEWQ
*F*
*F*      PURPOSE:    TO ENQUEUE A REQUEST FOR I/O
*F*
*F*      DESCRIPTION: CALL HERE WITH REGISTER SETUP AS  DEFINED
*F*                    IN  THE C00 DATA BASE TECH MANUAL.
*F*
NEWQ     RES      0                 NORMAL ENTRY
*
*
Q10      EQU      %
         AND,R12  DCT%MASK%2        CLEAN UP DCT FOR 7275
         LW,3     DCT%MASK
         AND,R3   R12
         LC       DCT24,R3          IS CAL1,1 DIAG USE BIT SET
         BCS,4    BISR4             YES, ERROR EXIT
         AI,R11   1                 INC RETURN ADDR
*
         BAL,2    FRONTEND          UTS INTERFACE
         B        1Q1               POINTER TO NEWQ BACKEND OF FRONTEND
         B        FRONTEND          REPEAT FRONTEND IF IOMF UNBLOCK
         B        UNEWQ             GO TO UNMAPPED SEGMENT
         PAGE
*
*        THIS ROUTINE CHECKS THE REQUEST FOR OVERLAPPING A PAGE
*        BOUNDARY (IF A USER REQUEST). IF IT OVERLAPS, A NONITOR
*        BUFFER IS ACQUIRED AND THE OPERATION IS DIVIDED INTO
*        PAGE SIZE OR SMALLER CHUNKS AND THE REQUEST IS FLAGGED
*        AS A DATA CHAIN. IT ALSO CONVERTS THE BUFFER ADDRESS FROM
*        VIRTUAL TO PHYSICAL. IF THE OPERATION IS TO RAD, DISC OR
*
*
*
*        R2       COUNT OF COMMAND PAIRS IN CHAIN
*        R3       Q ENTRY
*        R4       WA OF MONITOR BUFFER CONTINUING DATA CHAIN
*        R9       LINK
*        R13      BYTE COUNT
*        R14      WA OF VIRTUAL PAGE
*        R15      BA OF PHYSICAL PAGE
*
CHAINCHK EQU      %
         LW,6     IOQ8,3            GET BUFFER ADDRESS
         AND,6    M19               SCRUB TO VIRTUAL BYTE ADDRESS
         STW,6    IOQ8,3
         SLD,6    -11               GET PAGE NUMBER
         CI,6     JOVVP             IS THE BUFFER IN THE MONITOR
         BL       *9                YES GET OUT
         BAL,1    MAP               GO MAPPED TO SEE USER JIT
         LOAD,6   JX:CMAP,6         VIRTUAL TO PHYSICAL
         SLD,6    11                MAKE BYTE ADDRESS AGAIN
         LW,13    IOQ8,3            GET BUFFER ADDRESS
         LH,14    IOQ9,3            AND BYTE COUNT
         AND,13   M11               SCRUB PAGE DISP INTO BUFFER
*                                   R13 CONTAINS IOQ8 UPON ENTRY
         AH,13    IOQ9,3            ADD BYTE COUNT
         BLEZ     CHAIN             32K BYTES OR GREATER
         AI,13    -2048             CHECK FOR CROSSING PAGE
         BG       CHAIN             YES
         STW,6    IOQ8,3            STORE PHYSICAL BUFFER ADR
CHNEX    BAL,1    UNMAP             GO UNMAPPED AGAIN
         LB,1     IOQ7,3            RESTORE DCT INDEX TO R1
         B        *9                RETURN
*
*        DATA CHAIN IS NEEDED
*
CHAIN    DISABLE                    ***  DISABLE   ***
         LW,4     MPOOL             GET A MONITOR BUFFER(34 WDS)
         BNEZ     CH21              GOT ONE
         ENABLE                     ***  ENABLE  ***
         B        CHAIN             GO TRY AGAIN
CH21     LW,5     0,4               GET POINTER TO NEXT MBUF
         BEZ      CH22
         CLM,5    BUFLIMS+MPOOLIM+MPOOLIM   CHECK MPOOL WITHIN LIMITS
         BCS,9    SC1900            SOFTWARE CHECK 19-00
CH22     CLM,4    BUFLIMS+MPOOLIM+MPOOLIM
         BCS,9    SC1900            SOFTWARE CHECK 19-00
         STW,5    MPOOL             MAKE IT THE NEW HEAD
         ENABLE                     ***  ENABLE  ***
         SLS,4    -1                MAKE DOUBLEWORD ADR
         OR,4     Y8                SET DATA CHAIN BIT
         LW,5     IOQ8,3            GET BUFFER VIRTUAL ADDRESS
         STW,4    IOQ8,3            SAVE POINTER TO DATA CHAIN
         AND,R4   M21               SCRUB ANY DATA CHAINING BITS
         AND,14   M16               SCRUB BYTE COUNT
*                                   R14 CONTAINS BYTE COUNT UPON ENTRY
         LCW,7    6                 FIND REMAINING BYTES IN PAGE
         AND,7    M11               SCRUB
         BNE      %+2               NOT ON PAGE BOUNDARY
         LI,7     2048              WHOLE PAGE
         SW,14    7                 ACCOUNT FOR FIRST PAGE
         STD,6    0,4               STORE FIRST COMMAND PAIR
         SLS,5    -11               VIRTUAL PAGE OF BUFFER START
         LI,7     X'800'            ALL BUT FIRST AND LAST GET COUNT OF 2048
CH50     AI,5     1                 BUMP TO NEXT PAGE
         AI,4     1                  AND NEXT COMMAND POSITION
         LOAD,6   JX:CMAP,5         VIRTUAL TO PHYSICAL
         SLS,6    11                BYTE ADDRESS
         AI,14    -2048             COUNT FOR THIS COMMAND
         BLEZ     CH55              LAST COMMAND
         STD,6    0,4               STORE COMMAND
         B        CH50              CONTINUE
CH55     AW,7     14                CORRECT BYTE COUNT
         STD,6    0,4               AND STORE LAST COMMAND
         SW,4     IOQ8,3            CALCULATE NO OF COMMANDS
         AND,R4   M21               SCRUB OFF DATA CHAINING RESIDUE.
         AI,4     1                 IN DATA CHAIN
         STH,4    IOQ9,3            AND SAVE IN IOQ9
         BAL,1    UNMAP             UNMAPPED AGAIN
         LB,1     IOQ7,3            RESTORE DCT INDEX
*
         LI,0     2
         CB,0     IOQ4,3
         BNE      BISR2
         LB,6     DCT4,1            GET DEVICE TYPE
         LB,0     TB:FLGS,6         CHECK REVERSE BIT(=> 9 TRACK)
         CI,0     4
         BAZ      BISR2
*
*        WE HAVE A READ BACKWARD DATA CHAINED ON A 9T DRIVE
*        THE COMMAND LIST AND EACH PAIR IN IT MUST BE
*        INVERTED BECAUSE 9T HARDWARE ACTUALLY READS BACKWARD.
*        7T READ BACKWARD IS SOFTWARE SIMULATED
*        R2       HIGH INDEX
*        R4       COUNT
*        R5       LOW INDEX
*        R7       DA OF COMMAND LIST
*        R12-R15  TEMP
*
         LB,R2    DCT24,R1          DEVICE FLAGS
         CI,R2    4                 MPC CONTROLED DEVICE
         BANZ     BISR2             YES-KEEP CLIST AS IS
*
         LW,2     4                 COMPUTE NO OF PASSES NEEDED
*                                   TO INVERT
         AI,4     1                 THE COMMAND LIST
         SLS,4    -1
         AI,2     -1
         SLS,2    1
         LW,7     IOQ8,3            GET DA OF COMMAND LIST
         AND,7    M21
         LI,5     0                 LOW INDEX
CH60     EQU      %
         LD,12    *5,7
         LD,14    *2,7
         AI,12    -1
         AI,14    -1
         AW,12    13                INVERT EACH COMMAND PAIR
         AW,14    15
         STD,14   *5,7              AND INVERT THEIR POSITIONS
         STD,12   *2,7
         AI,2     -2
         AI,5     2
         BDR,4    CH60
*
BISR2    RES      0
         B        *9
         PAGE
*
*        THIS ROUTINE DETERMINES IF THE IOQ3 ENTRY SHOULD HAVE
*        THE ERROR ON CONTROL Y BIT SET.
*
ERR:CHK  EQU      %
         LB,R7    DCT4,R1           GET DEVICE TYPE
         LC       TB:FLGS,R7        GET THE TYPE FLAGS
         BCR,8    *R9               NOT TAPE OR PACK-->RETURN
         BAL,R1   MAP               GO MAPPED
         LC       J:JIT             SEE WHAT TYPE
         BCR,8    CHNEX             NOT ONLINE-->BRANCH
         LW,R7    J:TELFLGS         GET TEL FLAGS
         AND,R7   Y01               GET ERROR BIT
         BEZ      CHNEX             NO ON-->BRANCH
         AI,R15   8                 TURN ON THE ERROR BIT IN IOQ3
         B        CHNEX             AND GET OUT
         PAGE
*F*
*F*      NAME:       CHKDA
*F*
*F*      PURPOSE:     TO CHECK DISC  ADDRESS  IN R8 FOR VALIDITY
*F*
*F*      DESCRIPTION: CALL W/ADDRS  INR8  AND CHKDA WILL INSURE
*F*                   THAT IT IS LEGAL.
*F*
*F*                   RETURNS W/CC = 0 IF D/A OK
*F*
*F*                   RETURNS W/CC = 15 IF D/A NOT OK
*F*
CHKDA    EQU      %
         PUSH     3,4               SAVE 4,5,6
         LI,6     CHKDA1            SET INTERNAL RETURN
CHKDAQ   EQU      %                                                     DISCB
         LH,R4    R8                GET DCT INDEX + POSIIBLE SECTOR ADR
PVCHKDA  EQU      %
         AND,R4   DCT%MASK          SCRUB OF EXTRA BITS
         BEZ      CHKDA2            ERROR                               DISCB
         CI,4     DCTSIZ            CHECK FOR LEGAL                     DISCB
         BG       CHKDA2            NO                                  DISCB
         LB,R4    DCT22,R4          GET SUBTYPE                         DISCB
         BEZ      CHKDA2            NOT A DISC                          DISCB
         LSECTA,R5   R8             REL SECTOR IN 5                     DISCB
         CW,5     DISCLIMS,4        COMPARE
         BGE      CHKDA2            BAD
         LCI      15                SET CC
         B        0,6               RETURN
CHKDA2   LCI      0                 ERROR
         B        0,6               RETURN
CHKDA1   STCF     11                SAVE CC
         PULL     3,4               RESTORE REGS
         LCF      11                RESTORE CC
         B        *11               RETURN
*
*
         PAGE
*F*
*F*      NAME:        QUEUE
*F*
*F*      PURPOSE:     ENTRY FOR I/O WITH A DCB AND END  ACTION
*F*
*F*      DESCRIPTION: CALL HERE WITH REGISTERS AS DESCRIBED IN
*F*                   THE C00 DATA BASE TECH MANUAL.
*F*
*
QUEUE1   LW,R0    R9                MOVE END ACTION ADDRESS
         B        QD4
*F*
*F*      NAME:        QUEUE1
*F*
*F*      PURPOSE:     ENTRY FOR I/O WITH A DCB AND NO END ACTION
*F*
*F*      DESCRIPTION: CALL HERE WITH REGISTERS AS DESCRIBED IN
*F*                   THE C00 DATA BASE TECH MANUAL.
*F*
QUEUE    LI,R0    0
*
*        MERGE HERE FROM IORT AND VARIOUS OTHER PLACES
*
*        FOR COC I/O WE MUST PARK THE SLAVE CPU USER NOW.
*
*---------------------------*
QD4      EQU      %
         BLOCK
*---------------------------*
         LW,R1    R10               MOVE END ACTION INFO WORD
         LI,R2    X'1FFFF'          MASK FOR DCB ADDREjj
         AND,R2   R8                EXTRACT FROM ARGUMENT
         LW,R3    FCN,R2            CHECK FOR FUNCTION COUNT
         AND,R3   YFF               NON-ZERO
         BEZ      BISR4             NO, GET OUT
*
         LI,R15   3                 EXTRACT ASN
         AND,R15  ASN,R2            FROM DCB.
         CI,R15   CFUBIT            CHECK FOR FILE ASSIGNMENT.
         BE       QD30              ---> YES.
         LW,R12   DSI,R2            NOT FILE.
         LI,R13   X'BF00'           CHECK DEVICE TYPE.
         CS,R12   L(X'9000')        IS IT COC...
         BE       COCIO             ---> YES.
         CI,R12   X'8000'           NOT FILE; NOT COC. TEST OPLABEL BIT.
         AND,R12  XFF                 (EXTRACT DCT INDEX)
         BANZ     QD31              ---> NOT OPLABEL.
         SUA      X'32'           -----> OPLABEL IMPOSSIBLE W/ OPEN DCB.
QD30     INT,R12  CDA,R2            FILE DCB.
         AND,R12  DCT%MASK          R12= DCT INDEX.
*
QD31     CI,R2    JOVVPA            IS DCB IN THE MONITOR...
         BL       QD33              ---> YES. ALREADY REAL ADDRESS.
         SLD,R2   -9                TRANSLATE
         LOAD,R2  JX:CMAP,R2        VIRTUAL TO PHYSICAL
         SLD,R2   +9                DCB ADDRESS.
QD33     EQU      %
         LW,R13   R2                SAVE TRANSLATED DCB ADDRESS
         LW,R14   J:RWECB           GET ECB ADDRESS (IF ANY) INTO R14.
         BAL,R2   FRONTEND          SCHEDULER INTERFACE AND GETQ
         B        1Q3               POINTER TO QUEUE BACKEND OF FRONTEND
         B        QD4               RECYCLE IF IOMF UNBLOCK
         B        UQUEUE            GO TO UNMAPPED SEGMENT
         PAGE
         SPACE
*        CTRIG .. TRIGGER CONTROL TASK ROUTINE.
*        CALLING SEQUENCE ..
*
*                 ...      ...         CONTROL TASK FUNCTION WORD IN R8
*                 BAL,R11  CTRIG       CALL TO STACK IN 'IOCTQ'
*
*        NO VULNERABLE REGISTERS.  RETURNS WITH INTERRUPTS ENABLED.
*        NOTE: MAY USE 'CTRIG1' IF ALREADY DISABLED UPON ENTRY.
         SPACE
TP30     LD,R8    KEYINBUF          GET MESSAGE FROM KEYIN BUFFER
         SCD,R8   -24               ALIGN ADDRESS FOR SEARCH
         LI,R1    DCTSIZ+DCTSIZ+1   INITIAL INDEX
         CW,R9    DCT16,R1          CHECK ONE
         BE       TP31              GOT IT
         AI,R1    -2                BACK UP AN ENTRY
         BGZ      %-3               CONTINUE
TP30A    LW,R8    Y03               SPECIAL ENTRY FOR KEYIN EA
CTRIG    DISABLE                    SET ALL INTERRUPT INHIBITS
CTRIG1   PSW,R8   IOCTQ             PUSH CONTROL WORD INTO C.T. STACK
         LI,R8    1                 SET FLAG FOR CONTROL TASK PROCESSOR
         OR,R8    CTFLAGS           ..
         STW,R8   CTFLAGS           ..
         LI,R8    CTINT             IS THERE INTERRUPT FOR CONTROL TASK.
         BEZ      CTOCINT           NO, GO TRIGGER CONSOLE INTERRUPT
         LW,R8    CTGL              YES, GET GROUP LEVEL OF INTERRUPT
         WD,R8   *CTWD              TRIGGER CONTROL TASK LEVEL
         B        ENBSR4            RETURN TO CALLING PROGRAM
         SPACE
CTOCINT  LI,R8    X'10'             SELECT OPERATOR CONSOLE INTERRUPT
         WD,R8    X'1700'           TRIGGER FOR CONTROL TASK
         MTW,1    CTOC              AND FLAG INTERRUPT HANDLER
         SPACE
ENBSR4   ENABLE                     REMOVE INTERRUPT INHIBITS **ENABLE**
         B       *R11               RETURN TO CALLING PROGRAM
         PAGE
TYPERSP  LI,R13   MSG6              WAITING KEYIN
TYPEMSG  LI,R10   10                TIME IN
         AW,R10   IOCLOCK           CURRENT TIME
         STW,R10  DCT11,R1          TIME OUT
         LB,R3    DCT6,R1           Q PNTR
         ENABLE
         LI,R5    IOSCHED           FORCE RETURN
*F*
*F*      NAME:        MSGOUT
*F*
*F*      PURPOSE:     TO WRITE EITHER A CANNED MSG/MSG INTERNALLY
*F*                   TO THE OPERATOR.
*F*
*F*      DESCRIPTION: CALL HERE WITH;
*F*
*F*      R1           DCT INDEX
*F*      R3           IOQ INDEX
*F*      R5           RETURN LINK
*F*      R13          MESSAGE WORD  ADDRESS
*F*
*F*                   NOTE THAT ALL REGISTERS ARE SAVED
*F*
*F*
*F*               NOTE:  IF THE MESSAGE WORD ADDRESS AND DCT INDEX
*F*               (I.E., R13 AND R1) PASSED TO MSGOUT ARE DUPLICATES
*F*               OF THE CORRESPONDING IOQ ENTRIES (IOQ8 (AFTER
*F*               ADJUSTMENT) AND IOQ12) OF A MESSAGE THAT IS CURRENTLY
*F*               QUEUED FOR THE CONSOLE,  MSGOUT WILL RETURN WITHOUT
*F*               ADDING THE MESSAGE TO THE QUEUE.  THIS AVOIDS
*F*               FLOODING THE CONSOLE WITH "YYNDD ERROR" MESSAGES
*F*               IF A TAPE DRIVE (OR OTHER DEVICE) GOES REALLY
*F*               SOUR, AND ALSO AVOIDS GETTING SOFTWARE CHECKS
*F*               (CODE 79-00) IF THE OPERATOR REPEATEDLY SINGLE-
*F*               STEPS A LINE PRINTER (OR OTHER DEVICE) FASTER THAN
*F*               THE CONSOLE CAN PRINT THE ERROR MESSAGES.
MSGOUT   EQU          %
         PUSH     10,R11            SAVE R11-R4
         LW,R11   R13               COPY WORD ADDRESS
         SLS,R11  2                 MAKE IT A BYTE ADDRESS
         AI,R11   1                 SKIP OVER BYTE COUNT
         LI,R2    OCDCT             DCT INDEX OF OPERATOR'S CONSOLE
         LB,R2    DCT2,R2           GET CIT INDEX OF CONSOLE
         LB,R2    CIT1,R2           GET IOQ HEAD FOR CONSOLE
         BEZ      MSGOK             IF NONE, SEND MESSAGE
NEXTMSG  CW,R11   IOQ8,R2           IS MESSAGE TEXT THE SAME?
         BNE      %+3               IF NOT, MESSAGE IS ACCEPTABLE
         CW,R1    IOQ12,R2          IS IT FOR THE SAME DEVICE?
         BE       MSGFINI           IF SO, DON'T SEND IT
         LB,R2    IOQ2,R2           GET IOQ FLINK
         BNEZ     NEXTMSG           GO BACK AND TEST IT IF IT'S THERE
MSGOK    LW,R12   Y06               FUNCTION
         LW,R15   R1                DCT INDEX
         CLM,R13  DEV:ERR:LIM       SEE IF ITS A DEVICE ERROR
         BCS,9    MSGOUT10          OUT OF BOUND-->BRANCH
         BAL,R11  OLWRITE           GO SEE IF NEED TO WRITE ONLINE
MSGOUT10 EQU      %
         LW,R1    R13               MESSAGE ADDRESS
         BAL,R11  OCWRITE1          WRITE IT
MSGFINI  PULL     10,R11            RESTORE REGS
         B        *R5               RETURN
*
*
*        BETWEEN MSG1 AND MSG9A ARE MESSAGES USED BY THE HANDLERS
*
*        IF ANY NEW MESSAGES ARE ADDED THEY SHOULD BE BETWEEN THEM
MSG1     TEXTC    ' MANUAL'
MSG2     TEXTC    ' ERROR'
MSG3     TEXTC    ' TIMED OUT'
MSG4     TEXTC    ' NOT OPERATIONAL'
MSG5     TEXTC    ' WRITE PROTECTED'
MSG6     TEXTC    ' PLEASE RESPOND'
MSG7     TEXTC    ' CODE DISC ERR'
MSG9     TEXTC    ' REQ RETRY'
MSG9A    TEXTC    ' INCONSISTENT STATUS'
*
*
         BOUND    8
DEV:ERR:LIM DATA  MSG1,MSG9A        LIMITS OF DEVICE ERRORS
*
PIGEON   TEXTC    'PIGEON'
*
*F*
*F*      NAME:    OLWRITE
*F*
*F*      PURPOSE: TO CAUSE A DEVICE ERROR MESSAGE TO BE PASSED TO PIGEON
*F*               IF ONLINE USER.  OTHERWISE RETURN.
*F*
*F*      DESCRIPTION:
*F*
*F*               R1 = DCT INDEX
*F*               R3 = IOQ INDEX
*F*               R11 = RETURN LINK
*F*               R13 = MESSAGE ADDRESS/DEVICE KEYIN INDEX
*F*               R15 = DCT INDEX
*F*
OLWRITE  EQU      %
         LB,R4    IOQ3,R3
         CI,R4    8                 DID ONLINE USER SAY !ERROR
         BAZ      *R11              NO, DON'T SEND MESSAGE
         AI,R1    -BATAPE           CONVERT DCTX TO AVRX
         LH,R4    AVRID,R1          IS THERE A USER # HERE
         BGZ      OLWRT10           YES
         LB,R4    IOQ15,R3          NO, TRY THE IOQ ENTRY
         BEZ      *R11              NOT HERE
         CI,R4    X'FE'
         BGE      *R11              IGNORE SPECIALS
OLWRT10  LI,R1    HRBA              GET # COC BUFFERS * 4
         SLS,R1   -5                / 32 OR 12 1/2% OF COC BUF
         CW,R1    #DLBLKS           SEE IF PIGEON CAN HAVE MORE
         BL       *R11              NO MORE-->BRANCH
         BAL,R1   ECBGBLK           GET COC BLOCK FOR PIGEON MESSAGE
         BEZ      *R11              NO MORE-->BRANCH
         MTW,+1   #DLBLKS           COUNT UP # OF BLOCKS IN USE
         PUSH     16,R0             SAVE ALL THE REGS
         LI,R5    0
         STW,R5   0,R2              ZERO OUT THE FORWARD LINK
         LW,R3    R15               GET DCT INDEX
         AI,R3    -BATAPE           CONVERT IT TO AVR INDEX
         STW,R4   1,R2              SAVE USER # FOR PIGEON
         STW,R13  3,R2              SAVE MESSAGE ADDRESS/INDEX
         LD,R4    AVRTBL,R3         GET THE SERIAL # OF THE TAPE
         STW,R4   2,R2              SAVE IT IN THE BUFFER
         LB,R4    ANSFLGS,R3        GET THE FLAG BYTE
         LI,R3    5                 GET FLAG BYTE INDEX
         STB,R4   *R2,R3            INTO THE ECB BLOCK
         LI,R3    12                GET THE DCT INDEX INDEX
         STB,R15  *R2,R3            AND STORE IT INTO THE BLOCK
         LI,R3    PIGHEAD           GET THE HEAD OF PIGEONS CHAIN
         DISABLE                    LINK ON PIGEONS CHAIN
OLWRT20  EQU      %
         LW,R4    0,R3              GET THE FORWARD LINK
         BEZ      OLWRT25           END OF CHAIN-->BRANCH
         LW,R3    R4                SET UP FOR NEXT LINK
         B        OLWRT20           LOOP FOR NEXT ON CHAIN
OLWRT25  EQU      %
         STW,R2   0,R3              STORE AWAY THE LINK
         ENABLE
         LD,R0    PIGEON            START UP PIGEON
         BAL,R10  T:GJOBSTRT        GO START IT UP
OLWRT90  EQU      %
         PULL     16,R0             RESTORE REGS
         B        *R11              AND GET OUT
         PAGE
*
DEVKEYN  DATA,1   0,'C','R','E','F'   NOTE:  IF YOU ADD ENTRIES TO
*                                     THIS TABLE, BE SURE TO ALSO ADD
*                                     THEM TO THE TABLE IN PIGEON.
NDEVKEYN EQU      BA(%)-BA(DEVKEYN)-1
         BOUND    4
TP31     SLS,R1   -1                DCTINDEX
         LB,R7    R8                CHECK SYNTAX
         CI,R7    ','               COMMA
         BNE      TP32              ERROR
         LI,R4    NDEVKEYN          GET NUMBER OF DEVICE KEYINS
         LH,R8    R8                GET COMMAND BYTE
         CB,R8    DEVKEYN,R4        CHECK IT
         BE       TP33              GOT IT
         BDR,R4   %-2               LOOP UNTIL NO MORE
TP32     ENABLE                            ***** ENABLE *****
         LI,R1    4                 EH MESSAGE
OCWRITE  RES      0
OCQC     LI,R7    0                 CANNED MESSAGE
*F*
*F*      NAME:        OCQUEUE
*F*
*F*      PURPOSE:     TO ENQUEUE  A I/O REQUEST TO  THE OC.
*F*
*F*      DESCRIPTION: CALL HERE WITH;
*F*
*F*      R1           MESSAGE CODE
*F*      R7           DCT INDEX (0 MEANS CANNED MSG)
*F*      R11          RETURN LINK
*F*
*F*                   SAVES R5 THRU R11 (SEE  MSGOUT)
*F*
OCQUEUE EQU       %
         LW,R12   Y01               SET ASSUMED FUNCTION CODE
         LW,R15   R7                SET DCT INDEX
         BEZ      %+2               ASSUMPTION IS RIGHT
         LW,R12   Y02               SET TO WRITE WITH DEVICE NAME
         CI,R1    NMSG              CHECK FOR RECOGNIZED MESSAGE
         BG       OCWRITE1          NO
         LB,R1    MSGBASE,R1        TRANSLATE CODE TO ADDRESS
         AI,R1    MSGBASE           ADD BASE ADDRESS FOR MESSAGES
OCWRITE1 LI,R0    0                 SET NO END ACTION
OC22     LB,R2    CJOB              PRIORITY
         SLS,R2   16
         OR,R12   R2
         AI,R12   OCDCT             DCTX OF OC DEVICE
OC23     LB,R14   *R1               BYTE COUNT FOR MESSAGE
         ANLZ,R13 OC23              GET BYTE ADDRESS TO R13
         AI,R11   -1                FIX RETURN
         AI,R13   1                 SKIP COUNT
         B        NEWQ              OUTPUT MSG
MSG      CNAME    0
         PROC
LF       GEN,8    AF(1)-MSGBASE
         PEND
MSGBASE  MSG      OC53              0 => EH MESSAGE
         MSG      OC53              1 => EH MESSAGE
         MSG      OC51              2 => AVRERR MESSAGE
         MSG      OC52              3 => LATER MESSAGE
         MSG      OC53              4 => EH MESSAGE
         MSG      OC60              5 => AVAIL
         MSG      OC53              6 => ???
         MSG      OC53              7 => ???
         MSG      OC70              8 => SYMB NOT ACTIVE
         MSG      OC71              9 => SYMB ACTIVE
         MSG      OC72              10=> SYMB NOT SUSP
         MSG      OC73              11=> NOT AVAIL
         MSG      OC74              12=> SYMB NOT SUSPENDED
         MSG      OC75              13=> KEYIN BUSY, TRY LATER
         MSG      OC80              14=> ERRORED BY USER
         MSG      OC95              15=> MESSAGE TRUNCATED
NMSG     EQU      BA(%)-BA(MSGBASE)
         BOUND    4
OC51     RES      0
         TEXTC    '
!!AVRERR
'
OC52     RES      0
         DATA,1   8,X'15',5,'L','A','T','E','R',X'15',0,0,0
OC53     RES      0
         TEXTC    '
  EH? 
'
*
OC60     TEXTC    ' AVAIL
'         DEVICE
*
OC70     TEXTC    ' SYMB NOT ACTIVE
'  SYMBIONT
OC71     RES      0
         TEXTC    ' SYMB ACTIVE
'
OC72     RES      0
         TEXTC    ' SYMB NOT SUSP
'
OC73     RES      0
         TEXTC    ' SYMB NOT AVAIL
'
OC74     RES      0
         TEXTC    ' SYMB SUSPENDED
'
KEYBUSY  EQU      'KEYIN BUSY'
OC75     DATA,1   2+S:NUMC(KEYBUSY),X'15',X'05',S:UT(KEYBUSY)
OC80     TEXTC    ' ERRORED BY USER'
TRUNCMSG EQU      'MESSAGE TRUNCATED'
OC95     DATA,1   2+S:NUMC(TRUNCMSG),X'15',X'05',S:UT(TRUNCMSG)
*
         LOCAL
*
         END

