*M*      OPND     DEVICE DCB OPEN MODULE OF THE FILE MGT OPEN PROCESS.
*P*      NAME:    OPND
*P*      PURPOSE: TO CONTINUE OR TO COMPLETE PROCESSING A DEVICE DCB.
*P*      DESCRIPTION: THIS MODULE IS ENTERED FROM THE OPN MODULE FOR
*P*               A DEVICE-ASSIGNED DCB (I.E. ASN=3) AFTER FPT AND
*P*               VLP PROCESSING HAS BEEN COMPLETED. IF THE DEVICE IS
*P*               A TAPE OR A DISK PACK, CONTROL IS TRANSFERRED TO
*P*               THE OPNT MODULE FOR FURTHER PROCESSING. IN ALL OTHER
*P*               CASES, DCB PROCESSING IS COMPLETED IN THIS MODULE.
*P*      REFERENCE: NONE.
OPND:    EQU      %
         DEF      OPND:             * MODULE BASE UDEFED FOR XDELTA
*,*                                 * PATCHES.
         PCC      0
CNM      SET      1            ***   FOR SLAVE-LINE STUFF   ***
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
SR1      EQU      8
SR2      EQU      9
SR3      EQU      10
SR4      EQU      11
D1       EQU      12
D2       EQU      13
D3       EQU      14
D4       EQU      15
         PAGE
         REF      DCTSIZ       * # DEVICES IN SYSTEM
         REF      DCT1         * DEVICE ADDRESS TABLE (INPUT)
         REF      DCT3         * DEVICE I/O LEGALITY TABLE(INPUT)
         REF      DCT4         * DEVICE TYPE TABLE (INPUT)
         REF      DCT23        * DEVICE OWNERSHIP SLAVE LINES(I-O)
         REF      DCT24        * DEVICE DIAGNOSTICALLY-OPEN FLAG (I-O)
         REF      SNDDX        * SYMBIONT DCTX TABLE (INPUT)
         REF      SSTAT        * SYMBIONT ACTIVE TABLE (INPUT)
         REF      SV:RSIZ      * # RESOURCES IN SYSTEM
         REF      SB:RTY       * RESOURCE DEVTYPE TABLE (INPUT)
         REF      JB:MAX       * RESOURCE MAX ALLOWED TABLE (INPUT)
         REF      JB:CUR       * RESOURCE CURR USING TABLE (I-O)
         REF      SV:LSIZ      * # STREAMS IN SYSTEM (SEE ALSO OH:NM)
         REF      SB:LTY       * STREAM DEVTYPE TABLE (INPUT)
         REF      TYPMNSZ      * # DEVTYPES+1 IN SYSTEM (SEE OH:NM)
         REF      TB:FLGS      * DEVTYPE ATTRIBUTE TABLE (INPUT)
         REF      OV:NMSZ      * # NAMES IN SYSTEM (SEE OH:NM)
         REF      OV:SIZ       * # OPLABELS IN SYSTEM (SEE OH:NM)
         REF      OH:NM        * NAME TEXT TABLE (INPUT) CONTAINS
*,*                              DEVTYPE,OPLABEL,STREAM NAMES.
         REF      GETOBTX      * EXU GETOBTX,(BGO) CONVERTS DEVTYPE/
*,*                              OPLABEL TO DCTX/RESOURCE/STREAM.
         SREF     RAS:DOL      * BITS 24-31 INPUT= REMOTE ASSIST DCTX
         REF      DHHIT        * ROUTINE.DOES USER OWN THIS DEVICE?
         REF      SPINS        * ROUTINE.DOES ANOTHER USER OWN DEVICE?
         REF      SETSPIN      * ROUTINE.SAY USER OWNS THIS DEVICE.
         REF      INCGLOB      * ROUTINE.BUMP #DEVICES NOW OWNED.
*
         REF      J:JIT        * BITS 0-1 INPUT= USER TYPE (B,G,O)
*,*                              BIT 2 INPUT= REMOTE ASSIST USER.
         REF      JB:PRIV      * USER PRIVILEGE (INPUT)
         REF      S:CUN        * USER'S USER NUMBER (INPUT)
         REF      BOOTFLG      * NONZERO GHOST1 IS RUNNING (INPUT)
         REF      M:UC         * TERMINAL DCB; SPECIALLY TREATED.
         REF      ERO          * DIAG ERR SUBCODE OUTPUT HERE (WHY?)
         DO       CNM
         SREF     LB:UN        * LINE OWNERSHIP SLAVE LINES (INPUT)
         SREF     MODE5        * LINE DCB OPEN, SLAVE LINES (INPUT)
         REF      ADR:LIST     * = DCB WORD# SLAVE LINE LIST ADDRESS.
         REF      ADR:LNID     * = DCB WORD# SLAVE LINE ID ADDRESS.
         REF      LNDEVCD      * = NAME OF SLAVE LINE.
         REF      CNMLNDCB     * = DCB CODE FOR SLAVE-LINE DCB.
         REF      INUSEL       * = SLAVE LINE LIST BIT .. LIST IN USE.
         REF      OPNBIT       * = SLAVE LINE BIT .. DCB OPEN TO LINE.
         FIN
         REF      YFF          * MASK
         REF      YFFFF        * MASK
*
         REF      MSRWRTX      * MONITOR EXIT NO ERRORS.
         REF      MSR01EXIT    * MONITOR ERROR EXIT (CODE IN SR3).
         REF      SETTYC       * ROUTINE.SET DCB:TYC, CLEAR EGV.
         REF      OPNLD        * ROUTINE.OPENS STREAM ASSOC WITH DCB.
         REF      OPNTPSEG     * OVERLAY # FOR OPEN-TAPE MON OVLY.
         REF      OPNT#        * ENTRY # FOR OPEN-TAPE ROUTINE.
         DO       CNM
         SREF     KILLIO       * ROUTINE.KILL I/O ON SLAVE LINE.
         SREF     MOCIOP       * ROUTINE.MUST EXIST FOR MSG SLAVES.
         REF      T:IACU       * ROUTINE.GETS ACCESS-PROT ON PAGE.
         REF      TQOV2SEG     * OVERLAY # FOR LINE-ID CONVERT OVLY.
         REF      CNMPROC9#    * E.P.# FOR LINE-ID CONVERT ROUTINE.
         FIN
         PAGE
         DEF      OPENDEV           *ENTRY TO OPEN DEVICE DCB(ASN=3).
*F*      NAME:    OPENDEV
*F*      PURPOSE: OPEN A DEVICE DCB AFTER FPT MERGED BY OPN.
*D*      NAME:    OPENDEV
*D*      CALL:    B OPENDEV  (OVERTO MULSEG,OPNDEV#)
*D*      ENVIRONMENT: MASTER MAPPED.
*D*      INPUT:   R6=DCB ADDRESS.  PUSHALL IN TSTACK.
*D*      DESCRIPTION:
OPENDEV  EQU      %
*D*               CLEAR DCB FIELDS CLK(SYMBIONT),NVA(REWFLAG),DIAG.
         LI,SR3   0
         STW,SR3  CLK,R6            CLEAR SYMBIONTNESS INDICATOR.
         STW,SR3  NVA,R6            CLEAR REW-WAS-LAST-OP FLAG.
         LW,SR4   Y2
         STS,SR3  5,R6              CLEAR DIAGNOSTIC-DCB FLAG.
*D* EXAMINE DSI FIELD & GO TO PROPER ROUTINE FOR INPUT SPECIFICATION.
*D* STREAM/STREAM-NAME              00.SS DCB PREV OPEN->STREAM.
*D*   --->OPN:LDEV R3=STREAM#       00.OO     NOT      ->OPLABEL.
*D* DEVTYPE/OPLABEL/NOTSTREAM-NAME  04.SS DCB PREV OPEN->STREAM. 'L'
*D*   --->OPN:CVT  R3=INDEX         04.OO     NOT      ->OPLABEL.'L'
*D* DEVTYPE-DCTX   R2=TYP           08TDD ->DEVTYPE-DCTX.
*D*   --->OPN:NOCV R3=DCTX          08T.. ->DEVTYPE.
*D* DEVADDR                         0CTDD ->DEVTYPE-DCTX.        'L'
*D*   --->OPN:DIAG D1=DEVADDR       0CT.. ->DEVTYPE.             'L'
*D*(SLAVE LINE NAME)                10.SS DCB PREV OPEN->STREAM.
*D*   --->OPN:CNM                   10.OO     NOT      ->OPLABEL.
*D* SR3='L' LIST INDICATOR.         14AAA ->DEVADDR.(DIAGNOSTIC OPEN)
*D*      (4000 OR 0)                18NNN NAME;LOOK UP IN OH:NM TABLE
         LW,D1    DSI,R6            D1=DEVICE INDICATOR FROM DCB.
         CI,D1    X'10000'
         BANZ     OPD01             ---> 10000.
         LI,SR3   X'4000'             IF NOT 10000, 'L' BIT APPLIES.
         AND,SR3  DSI,R6            SR3='L' BIT.
         CI,D1    X'8000'
         BAZ      OPD000            ---> NOT 10000. NOT 8000.
         LI,R3    X'3F00'           --V  NOT 10000. 8000.
         AND,R3   DSI,R6
         SLS,R3   -8                R3= DEVTYPE.
         CI,R3    TYPMNSZ-1
         BG       OPNERAB           ***>INVALID DEVICE TYPE.
         CI,R6    M:UC                  * LOOK FOR
         BNE      OPD008                * M:UC DCB
         LC       J:JIT                 * BEING OPENED BY
         BCR,8    OPD008                * ON-LINE
         BCS,2    OPD008                * NON-REMOTE-ASSIST USER.
         LW,D2    Y004                  * IF SO, JUST SET
         STS,D2   M:UC+FCD              * DCB PREV OPENED AND
         LI,D1    3                     * SET DCB:FUN=3 (IN+OUT)
         B        SETFUN1           -----> AND FINISH OFF.
OPD008   LI,R2    X'FF'               DISTINGUISH TYP FROM TYP/DCTX.
         AND,R2   DSI,R6            R2= DCTX MAYBE.
         BEZ      OPN:CVT           ---> TYPE ONLY.
         CI,R2    DCTSIZ
         BG       OPN:CVT           ---> TYPE ONLY.
         XW,R2    R3                R2=TYPE,       TYPE/DCTX.
         CB,R2    DCT4,R3           R3=DCTX.
         BE       OPN:NOCV          ---> GO IF TYPE MATCHES DCTX.
         B        OPNERAB           ***>TYPE DOESN'T MATCH DCTX.
OPD01    CI,D1    X'8000'
         BANZ     OPD018            ---> 10000. 8000.
         CI,D1    X'4000'
         BANZ     OPN:DIAG          ---> DIAGNOSTIC OPEN.
OPD000   LI,R3    X'FF'
         AND,R3   DSI,R6            R3= OPLABEL# OR STREAM INDEX,
         LW,D2    Y004                DEPENDING ON WHETHER DCB
         AND,D2   FCD,R6              WAS PREVIOUSLY OPENED.
         BEZ      OPD000N           ---> NOT OPENED.
         AI,R3    -DCTSIZ-1-SV:RSIZ-1  OPENED.
         B        OPN:LDEV          --->STREAM. R3=STREAM#,CC FROM R3.
OPD000N  AI,R3    TYPMNSZ           R3=CONVERSION INDEX FOR OPLABEL.
         CI,R3    TYPMNSZ+OV:SIZ      MAKE SURE OPLABEL VALID,
         BLE      OPN:CVT           ---> AND GO.
         B        OPNERAB           ***>INVALID OPLABEL.
OPD018   OR,D1    YFFFF
         LI,R3    OV:NMSZ             LOOK UP NAME IN NAME TABLE.
OPD018A  CH,D1    OH:NM,R3
         BNE      OPD018B
         CI,R3    TYPMNSZ+OV:SIZ+1    IS IT DEVTYPE/RESOURCE...
         BL       OPN:CVT           ---> YES. R3=INDEX.
         AI,R3    -TYPMNSZ-OV:SIZ-1   NO. STREAM.
         B        OPN:LDEV          --->STREAM. R3=STREAM#,CC FROM R3.
OPD018B  AI,R3    -1
         BGEZ     OPD018A             LOOK EVEN AT ZEROTH NAME.
         DO       CNM
         CI,D1    LNDEVCD+X'F0000'    LAST CHANCE. IS IT SLAVE LINE..
         BE       OPN:CNM           ---> YES.
         FIN
         B        OPNERAB           ***>INVALID NAME.
         PAGE
*D* OPN:DIAG DIAGNOSTIC OPEN. D1=DEV ADDR. CVT TO TYPE/DCTX IN R2/R3.
*D*      USER MUST HAVE 'A0' PRIVILEGE, DEVICE CAN'T NOW BE OPEN
*D*      DIAG, AND DEVICE MUST BE SYMBIONT OR TAPE.
OPN:DIAG EQU      %
         LB,R4    JB:PRIV
         CI,R4    X'A0'
         BL       DIAGERR0          ***>NOT ENUFF PRIV FOR DIAG OPEN.
         AND,D1   M13               D1= DEVIC ADDDRESS ONLY.
         LI,R3    DCTSIZ              SEARCH DEVADDR TABLE FOR DEVICE.
         CH,D1    DCT1,R3
         BE       %+3               R3= DCTX.
         BDR,R3   %-2
         B        DIAGERR1          ***>INVALID DEVICE ADDRESS.
         LB,R2    DCT4,R3           R2= DEVTYPE.
         LB,D3    DCT24,R3          D3= DIAGNOSTICALLY-OPEN FLAG.
         CI,D3    X'40'
         BANZ     DIAGERR2          ***>DEVICE ALREADY DIAG OPEN.
         MTW,0    BOOTFLG             IF THIS IS GHOST1,
         BNEZ     OPN:NCNR          ---> WE GOT IT.
         LB,R4    SNDDX
         CB,R3    SNDDX,R4
         BE       OPD46             --->SYMBIONT.
         BDR,R4   %-2
         LC       TB:FLGS,R2
         BCR,8    DIAGERR1          ***>DEVICE NOT SYMBIONT OR TAPE.
         BCS,4    DIAGERR1          ***>DEVICE NOT SYMBIONT OR TAPE.
         B        OPD47
OPD46    LB,R4    SSTAT,R4
         CI,R4    1
         BANZ     DIAGERR3          ***>SYMB DEVICE STILL ACTIVE.
OPD47    AI,D3    X'40'
         STB,D3   DCT24,R3            SET DEVICE DIAGNOSTICALLY OPEN.
         LW,D2    Y2
         STS,D2   5,R6                SET DCB DIAGNOSTICALLY OPEN.
         B        OPN:NCNR          ---> AND PROCEED.
         PAGE
*D* OPN:CVT CONVERTS R3 (= DEVTYPE OR = OPLABEL AS OPL# + TYPMNSZ) TO
*D*      DEVICE(DCTX), RESOURCE(RES# +DCTSIZ+1), OR STREAM(STREAM#
*D*      +DCTSIZ+1+SV:RSIZ+1).  STREAM GOES TO OPN:LDEV.
*D*      DEVICE GOES TO OPN:NOCV TO CHK FOR COC DEV W/ RAS USER.
*D*      RESOURCE GOES TO OPN:NCNR BYPASSING RAS CHECK.
OPN:CVT  EQU      %
         LB,R4    J:JIT
         SLS,R4   -6                R4= 0 BATCH, 1 GHOST, 2 ONLINE.
         EXU      GETOBTX,R4          CVT TYP/OPL TO DEV/RES/STR.
         AI,R3    -DCTSIZ-1-SV:RSIZ-1 WHAT IS IT...
         BGEZ     OPN:LDEV          --->STREAM. R3=STREAM#,CC FROM R3.
         AI,R3    SV:RSIZ+1
         BLZ      OPD2
         LW,R1    R3                --V RESOURCE. R1=RATX.
         LI,R3    0                 R3=0 MEANS RESOURCE.
         LB,R2    SB:RTY,R1         R2= TYPE.
         BEZ      OPNERAB           ***>NON-DEVICE RESOURCE.
         CI,R2    TYPMNSZ-1
         BLE      OPN:NCNR          ---> OKAY.
         B        OPNERAB           ***>NON-DEVICE RESOURCE.
OPD2     AI,R3    DCTSIZ+1          --V  DEVICE. R3=DCTX,
         LB,R2    DCT4,R3           R2= DEVTYPE.
*D* OPN:NOCV ENTERED WITH R2=DEVTYPE, R3=DCTX. IF THIS IS THE REMOTE-
*D*      ASSIST USER & DEVTYPE IS COC, CONVERT TO RAS:DOL DEVICE.
OPN:NOCV EQU      %
         LC       J:JIT
         BCR,2    OPN:NCNR
         CI,R2    X'10'
         BNE      OPN:NCNR
         LI,R3    RAS:DOL
         BEZ      OPNERAB           ***>RAS USER IN NON-RAS SYSTEM.
         LI,R3    X'FF'               IF THIS IS RAS USER HOOKING TO
         AND,R3   RAS:DOL             COC DCB, SET R3=RASDCTX,
         LB,R2    DCT4,R3           R2=RASDEVTYPE.
*D* OPN:NCNR HAS R2=DEVTYPE, R3=DCTX (0 FOR RESOURCE).
*D*      IF DEVTYPE HAS NEITHER IN NOR OUT LEGAL, ERROR.
*D*      IF DEVTYPE IS TAPE OR DISK, GO TO OPN:TAPE.
*D*      SET DCB:DSI= X'8000'+(X'4000' L BIT MAYBE) +TYP*X'100'+DCTX.
*D*      IF TRUE DEVICE (DCTX>0 OR TYP=0'NO') FINISH OFF @ SETFUN.
OPN:NCNR EQU      %
         LC       TB:FLGS,R2          WHAT KIND OF DEVICE...
         BCR,3    OPNERAB           ***>UNALLOCATABLE DEVICE; ERROR.
         BCS,8    OPN:TAPE          ---> TAPE/DISK; GO.
         BAL,SR4  SETDSI8           DCB:DSI<-8000+R2*100+R3;
         AND,R2   M8                R2<-DCTX FROM R3 + EXTRAS.
         BNEZ     SETFUN            ---> REAL DEVICE.
         LW,R3    R4                R4<- DEVTYPE FROM R2 (SETDSI8).
         BEZ      SETFUN            ---> REAL 'NO' DEVICE.
*D* ***  NOW HAVE R3=TYPE, R1=RATX OF RESOURCE.  FIND DEVICE OF THAT
*D*      TYPE THAT USER CAN (OR DOES) HAVE AND GIVE IT TO THE USER.
*D*      USER.  STORE ITS DCTX IN DCB:DSI.  THEN ON TO SETFUN.
         LI,12    0                 12= DCTX OF PART'ED DEV RIGHT TYP.
         LI,R2    DCTSIZ              SEARCH DCT FOR RIGHT TYPE DEVICE
NXTY     CB,R3    DCT4,R2
         BNE      NXTYL             ---> WRONG TYPE.
         BAL,SR4  DHHIT             I:2=DCTX O:0=BIT#,4=WORD#.
         BANZ     KRD8X             ---> USER OWNS ALREADY; GOT IT.
         BAL,SR4  SPINS                      I:0=BIT#,4=WORD#.
         BANZ     NXTYL             ---> USER CAN'T HAVE IT.
         LB,SR4   JB:MAX,R1
         CB,SR4   JB:CUR,R1
         BLE      RATERR02          ***>USER CAN'T HAVE ANY MORE.
         LC       DCT3,R2
         BCR,2    KRD5X             --->NOT PART DEV; TAKE IT.
         CI,12    0
         BNE      NXTYL             --->ONLY REMEMBER ONE PARTDEV.
         LW,12    R2                  REMEMBER DCTX.
NXTYL    BDR,R2   NXTY
         LW,R2    12                  IF ANY.
         BEZ      RATERR01          ***>NONE; USER CAN'T HAVE ONE.
KRD5X    BAL,SR4  INCGLOB           I:1=RATX U:0,8.
         BAL,SR4  KRD10X              INCGLOB HERE IF NOMORE GLOBAL.
         MTB,1    JB:CUR,R1           OK TO HAVE; BUMP USER'S #.
         BAL,SR4  SETSPIN           I:2=DCTX U:0,4,14,15.
KRD8X    LI,R4    BADSI
         STB,R2   *R6,R4              ADD DCTX TO DCB.
         B        SETFUN            ---> GO ON.
KRD10X   CI,12    0                   OVERALLOCATION IS OKAY IF
         BNE      *SR4              --->WE HAVE A PART'ED DEVICE.
         B        RATERR01          ***>USER CAN'T HAVE ONE.
         PAGE
*D* OPN:LDEV OPENS DCB TO A STREAM. IT FIRST SETS UP DSI FIELD OF
*D*      DCB, THEN CALLS OPNLD TO HOOK THE DCB UP TO THE STREAM.
OPN:LDEV EQU      %
         BLEZ     OPNERAB           ***>INVALID STREAM NUMBER.
         CI,R3    SV:LSIZ
         BG       OPNERAB           ***>INVALID STREAM NUMBER.
         LB,R2    SB:LTY,R3         R2= DEVTYPE OF STREAM.
         AI,R3    DCTSIZ+1+SV:RSIZ+1  R3= STREAM# INTERNAL.
         BAL,SR4  SETDSI
         BAL,SR4  OPNLD
         B        OPNX              ---> ALL DONE; OKAY.
         B        OERX              ***>BAD. ERRCODE IN SR3.
*D*
*D* OPN:TAPE OPENS DCB TO TAPE OR DISK BY GOING TO OPNT. USER
*D*      MUST HAVE 'C0' PRIVILEGE TO OPEN TO PACK.
OPN:TAPE EQU      %
         BCR,4    %+4               ---> TAPE.
         LB,R4    JB:PRIV
         CI,R4    X'C0'
         BL       OPNERAB           ***>C0 PRIV NEEDED TO OPEN PACK.
         BAL,SR4  SETDSI8             SET UP GOOD DSI FIELD FIRST,
         OVERTO   OPNTPSEG,OPNT#    --->THEN OFF TO OPNT.
         PAGE
         DO       CNM
*D* OPN:CNM HOOKS THE DCB TO A SLAVE LINE. DCB'S ADR:LNID POINTS TO
*D*      LINE NAME; CONVERT IT TO COC LINE# OR MOC DCTX BY CALLING
*D*      CNMPROC9. MOC LINE MUST HAVE A POL/SEL LIST IN DCB, MOCIOP
*D*      MUST EXIST, LIST MUST BE IN (01) SPACE, LIST NOT IN USE,
*D*      AND DEVICE BELONG TO USER & NOT YET BE OPEN.
*D*      COC LINE MUST BELONG TO USER & NOT BE OPEN.
*D*      DCB:RNDEV BECOMES LINE#+1(COC), 0(MOC).  DCB:DSI BECOMES
*D*      X'9000'+LINE#(COC), X'8000'+DEVTYP*X'100'+DCTX(MOC).
*D*      SET 'CNMLNDCB' CODE INTO DCB:ASN.  THEN SET DCB:FUN=IN+OUT.
OPN:CNM  EQU      %
         LI,R3    X'1FFFF'
         AND,R3   ADR:LNID,R6       R3= ADDR OF SLAVE LINE NAME.
         BEZ      CNMERR03          ***>NO LINE ID IN DCB.
         OVERLAY  TQOV2SEG,CNMPROC9#  CVT TO LINE# IN D1.
         LW,R3    S:CUN             R3= USER# FOR LATER USE.
         LW,R2    D1                R2= LINE# SPEC.
         BEZ      CNMERR03          ***>ILLEGAL SLAVE LINE NAME.
         BLZ      OPNCCOC           ---> COC SLAVE LINE.
         LI,R7    MOCIOP            --V  MOC SLAVE LINE.
         BEZ      CNMERR20          ***>NO MOCIOP IN SYSTEM.
         LI,R7    X'1FFFF'
         AND,R7   ADR:LIST,R6       R7= POL/SEL LIST ADDRESS.
         SCS,R7   -9
         BAL,SR4  T:IACU              CHK LIST PROTECTION.
         BCS,2    CNMERR04          ***>LIST BAD (PROT 10/11)
         BCR,1    CNMERR04          ***>LIST BAD (PROT 00)
         SCS,R7   +9
         LW,D4    INUSEL
         CS,D4    0,R7
         BE       CNMERR08          ***>LIST ALREADY IN USE.
         LH,D3    DCT23,R2
         LI,R4    2
         CB,R3    D3,R4
         BNE      CNMERR01          ***>LINE NOT OWNED BY USER.
         OR,D3    OPNBIT              SET LINE-IS-OPEN.
         STH,D3   DCT23,R2
         STS,D4   0,R7                SET LIST-IS-IN-USE.
         LB,R3    DCT4,R2           R3= DEVTYPE.
         LI,D1    0                 D1 INTO RNDEV.
         B        OPNCALL
OPNCCOC  AI,R2    -1                R2= COC LINE#.
         CB,R3    LB:UN,R2
         BNE      CNMERR01          ***>LINE NOT OWNED BY USER.
         BAL,SR4  KILLIO              PURGE I/O ON LINE.
         LB,R4    MODE5,R2
         OR,R4    OPNBIT              SET LINE-IS-OPEN.
         STB,R4   MODE5,R2
         LI,R3    X'10'             R3= DEVTYPE.
         SLS,D1   +8                D1 INTO RNDEV.
OPNCALL  LI,D2    X'FF00'
         STS,D1   RNDEV,R6            SET LINE# OR 0 INTO RNDEV.
         LW,D2    CNMLNDCB
         STS,D2   ASN,R6              SET 'CNMLNDCB' FLAG IN DCB.
         XW,R2    R3                R2= DEVTYPE, R3= DCTX OR LINE#.
         LI,SR3   0                   DON'T EVER SET 'L' BIT.
         BAL,SR4  SETDSI8           DCB:DSI<-8000+R2*100+R3.
         LI,D1    3                   SET DCB:FUN=3 (IN+OUT)
         B        SETFUN1           --->AND FINISH UP.
         FIN
         PAGE
SETDSI8  EQU      %                 SET UP DSI WITH X'8000'
         OR,R3    X8000
SETDSI   EQU      %                 SET UP DSI WITOUT 8000.
         OR,R3    SR3               ADD 'L' BIT SPEC.
         LW,R4    R2                PRESERVE DEVTYPE.
         SLS,R2   8
         OR,R2    R3
         LC       TB:FLGS,R4
         BCS,8    %+3
         BCR,4    %+2
         OR,R2    X4000             LP ALWAYS GETS 'L' BIT.
         LI,R3    X'1FFFF'
         STS,R2   DSI,R6
         LW,R3    Y004
         STS,R3   FCD,R6            SET DCB-PREV-OPEN.
         B        *SR4
*D* SETFUN SETS DCB:FUN FIELD FROM DCT3 AND SETS DCB OPEN.
SETFUN   EQU      %
         LB,D1    DCT3,R2
         SLS,D1   -6                D1= IN-OUT LEGALITY FLAGS.
SETFUN1  EQU      %
         LI,D2    X'7F'
         SLD,D1   +17
         STS,D1   FUN,R6              INTO DCB:FUN.
OPNX     EQU      %
         LW,D1    Y002
         LW,D2    YFF
         STS,D1   COS,R6              COS=0 MEANS NOT TAPE/PACK.
         LW,D2    Y002C3              SET FCD,
         STS,D1   FCD,R6              CLEAR EOP,AGV,EGV.
         BAL,R0   SETTYC              SET TYC=0, EGV=0.
         DESTRUCT MSRWRTX           ---> ALL DONE.
Y002C3   DATA     X'002C3000'
         PAGE
DIAGERR0 BAL,SR3  DIAGERR
*E*      ERROR:   09-00.
*E*      DESCRIPTION: USER ATTEMPTED DIAGNOSTIC OPEN WITH INSUFF.
*E*               PRIVILEGE.
DIAGERR1 BAL,SR3  DIAGERR
*E*      ERROR:   09-01.
*E*      MESSAGE: NONEXISTENT DEVICE.
DIAGERR2 BAL,SR3  DIAGERR
*E*      ERROR:   09-02.
*E*      MESSAGE: DEVICE BUSY.
DIAGERR3 BAL,SR3  DIAGERR
*E*      ERROR:   09-03
*E*      MESSAGE: SYMBIONT DEVICE BUSY.
DIAGERR  EQU      %
         AI,SR3   -DIAGERR0-1       SR3= ERROR SUBCODE.
         LI,SR4   X'FF'
         STS,SR3  J:JIT+ERO         I DUNNO WHY, BUT I DO IT ANYWAY.
         AI,SR3   X'09'**7          SR3= ERROR CODE & SUBCODE.
         B        OERX0
OPNERAB  LI,SR3   X'14'**7+X'05'
*E*      ERROR:   14-05.
*E*      MESSAGE: INVALID OP LABEL IN DCB.
         B        OERX0
RATERR01 LI,SR3   X'49'**7+X'01'
*E*      ERROR:   49-01
*E*      MESSAGE: REQUESTED REMOVABLE DEVICE IS NOT AVAILABLE.
         B        OERX0
RATERR02 LI,SR3   X'49'**7+X'02'
*E*      ERROR:   49-02.
*E*      MESSAGE: USER DISMOUNTABLE RESOURCE LIMIT EXCEEDED.
         B        OERX0
CNMERR01 LI,SR3   X'32'**7+X'06'
*E*      ERROR:   32-06.
*E*      MESSAGE: ATTEMPTED TO OPEN DCB TO UNOWNED SLAVE LINE.
         B        OERX0
CNMERR03 LI,SR3   X'32'**7+X'05'
*E*      ERROR:   32-05.
*E*      MESSAGE: UNABLE TO INITIALIZE SLAVE LINE; BAD SLAVE LINE ID.
         B        OERX0
CNMERR04 LI,SR3   X'32'**7+X'04'
*E*      ERROR:   32-04.
*E*      MESSAGE: BAD POLLING/SELECTION LIST ADDRESS.
         B        OERX0
CNMERR08 LI,SR3   X'32'**7+X'03'
*E*      ERROR:   32-03.
*E*      MESSAGE: POLLING/SELECTION LIST ALREADY IN USE.
         B        OERX0
CNMERR20 LI,SR3   X'32'**7+X'09'
*E*      ERROR:   32-09.
*E*      MESSAGE: MOCIOP MODULE OR COC SLAVE LINE CODE NOT IN THIS
*E*               SYSTEM.
         B        OERX0
*
OERX0    SCS,SR3  -7                SR3= ALIGNED ERROR CODE/SUBCODE.
OERX     EQU      %
         DESTRUCT MSR01EXIT         ---> GO REPORT BAD NEWS.
         END

