TITLE  'ICATS ATTACH-A-UTS-TO-MYSELF ROUTINE'                  ATT00010
*********************************************************************** ATT00020
*                                                                     * ATT00030
*  MODULE NAME =  ATTACH                                              * ATT00040
*                                                                     * ATT00050
*  FUNCTION =  GO THROUGH THE UTS CONTROL BLOCK CHAIN AND TRY TO      * ATT00060
*              VARY ON AND ATTACH EACH UTS IN THE CHAIN THAT'S        * ATT00070
*              NOT ALREADY ATTACHED.                                  * ATT00080
*                                                                     * ATT00090
*  ENTRY POINTS =  ATTACH                                             * ATT00100
*                                                                     * ATT00110
*  LINKAGE =  BALR R14,R15 FROM ANY ICATS PROGRAM.                    * ATT00120
*                                                                     * ATT00130
*  REGISTER CONTENTS UPON ENTRY =                                     * ATT00140
*      R2  = POINTS TO THE ICATS COMMON DATA AREA, AS ALWAYS.         * ATT00150
*      R14 = RETURN ADDRESS BACK TO CALLER.                           * ATT00160
*      R15 = ENTRY POINT TO THIS MODULE.                              * ATT00170
*                                                                     * ATT00180
*  REGISTER USAGE =                                                   * ATT00190
*      R0-R1 = USED TO PASS PARAMETERS TO SUBROUTINES.                * ATT00200
*      R2 =  USED TO ADDRESS THE ICATS COMMON DATA AREA.              * ATT00210
*      R3 =  FREE                                                     * ATT00220
*      R4 =  USED TO ADDRESS THE UTS CONTROL BLOCKS.                  * ATT00230
*      R5-R9 = FREE                                                   * ATT00240
*      R10 = WORK REGISTER                                            * ATT00250
*      R11 = MY BASE REGISTER                                         * ATT00260
*      R14 = MY RETURN ADDRESS WHEN I CALL SOMEBODY                   * ATT00270
*      R15 = SUBROUTINE ADDRESS                                       * ATT00280
*                                                                     * ATT00290
*                                                                     * ATT00300
*  MODULE LOGIC:                                                      * ATT00310
*      1)  GO THROUGH THE UTS CONTROL BLOCK CHAIN.                    * ATT00320
*          IF THE ONLINE BIT IS OFF, THEN TRY TO ATTACH IT TO ME.     * ATT00330
*          A)  ISSUE A CP VARY ON COMMAND.                            * ATT00340
*          B)  IF THAT WORKED, DO A CP ATTACH XXX * YYY.              * ATT00350
*                                                                     * ATT00360
*  NORMAL EXIT =                                                      * ATT00370
*      R15 = 0                                                        * ATT00380
*                                                                     * ATT00390
*  EXTERNAL REFERENCES = NONE                                         * ATT00400
*                                                                     * ATT00410
*  MACROS =  ICDATA = ICATS COMMON DATA AREA                          * ATT00420
*            ETTE   = ENTER TRACE TABLE ENTRY SUBROUTINE              * ATT00430
*                                                                     * ATT00440
*  CHANGE ACTIVITY                                                    * ATT00450
*    DATE        NAME       REASON FOR CHANGE                         * ATT00460
*  04/25/83  RICK JASPER    INITIAL PROGRAM CREATION                  * ATT00470
*                                                                     * ATT00480
*********************************************************************** ATT00490
         PRINT   GEN,NODATA                                             ATT00500
ATTACH   CSECT                                                          ATT00510
         USING ICDATA,R2            ADDRESS ICATS COMMON DATA AREA      ATT00520
         USING CBUTS,R4             ADDRESS UTS CONTROL BLOCK           ATT00530
         USING *,R15              USE R15 FOR NEXT INSTRUCTION ONLY     ATT00540
         STM   R0,R14,ATTREGS     SAVE ALL THE REGISTERS                ATT00550
         DROP  R15                                                      ATT00560
         USING ATTACH,R11         SWITCH BASE REGISTER TO R11           ATT00570
         LR    R11,R15                                                  ATT00580
         L     R4,CBFIRST        GET ADDRESS OF FIRST UTSCB             ATT00590
         LTR   R4,R4             IS IT NULL ??  SHOULDN'T BE.           ATT00600
         BNZ   ATTLOOP           NOPE, GOOD.  GO GET THE UTS'S.         ATT00610
ATTNONE  LA    R1,NONEMSG                                               ATT00620
         L     R15,AMESSAGE      GIVE A MESSAGE SAYING                  ATT00630
         BALR  R14,R15           THERE ARE NO UTS'S TO GET              ATT00640
         B     ATTBYE            BYE BYE.                               ATT00650
*                                                                       ATT00660
ATTLOOP  TM    CBUTSFGA,ONLINE   IS THIS UTS ONLINE ??                  ATT00670
         BNO   GODOIT            NO, GO TRY TO GET HIM ATTACHED         ATT00680
ATTBACK  L     R4,CBUTSFP        GET POINTER TO NEXT UTSCB.             ATT00690
         LTR   R4,R4             ARE WE AT THE END OF THE CHAIN ??      ATT00700
         BNE   ATTLOOP           NOPE, GO CHECK THIS UTSCB              ATT00710
*    ALL DONE.  TIME TO RETURN.                                         ATT00720
ATTBYE   DS    0H                                                       ATT00730
         LM    R0,R14,ATTREGS                                           ATT00740
         SR    R15,R15                RETURN CODE = 0                   ATT00750
         BR    R14                    BYE                               ATT00760
*********************************************************************** ATT00770
*    R4 IS NOW POINTING TO A UTS CONTROL BLOCK THAT IS OFFLINE.       * ATT00780
*    ISSUE THE VARY ON AND ATTACH COMMANDS AND TRY TO GET THAT        * ATT00790
*    UTS ONLINE.                                                      * ATT00800
*********************************************************************** ATT00810
GODOIT   DS    0H                                                       ATT00820
         LH    R1,CBUTSRAD         CONVERT THE UTS'S REAL ADDRESS TO    ATT00830
         L     R15,ACONEHEX        EBCDIC AND PUT IT IN THE VARY ON     ATT00840
         BALR  R14,R15             COMMAND                              ATT00850
         STCM  R1,B'0111',QA                                            ATT00860
         STCM  R1,B'0111',VARYONA    WHILE WE'VE GOT THE UTS'S REAL     ATT00870
         STCM  R1,B'0111',ATTA       ADDRESS IN EBCDIC, LET'S HIT ALL   ATT00880
         STCM  R1,B'0111',FAIL1CUU   THE OTHER PLACES THAT NEED IT.     ATT00890
         STCM  R1,B'0111',FAILRCUU                                      ATT00900
         STCM  R1,B'0111',GOODRCUU                                      ATT00910
         STCM  R1,B'0111',FAIL3RAD                                      ATT00920
         STCM  R1,B'0111',FAIL4RAD                                      ATT00930
         STCM  R1,B'0111',FAIL5RAD                                      ATT00940
         LH    R1,CBUTSVAD         CONVERT THE UTS'S VIRTUAL ADDRESS    ATT00950
         L     R15,ACONEHEX        IN EBCDIC AND PUT IT IN THE          ATT00960
         BALR  R14,R15             ATTACH COMMAND                       ATT00970
         STCM  R1,B'0111',ATTB                                          ATT00980
         STCM  R1,B'0111',FAILVCUU     FILL IN THE MESSAGES ALSO        ATT00990
         STCM  R1,B'0111',GOODVCUU                                      ATT01000
         STCM  R1,B'0111',FAIL3VAD                                      ATT01010
         STCM  R1,B'0111',FAIL5VAD                                      ATT01020
*********************************************************************** ATT01030
*    SEE WHAT THE PRESENT STATUS OF THE UTS IS                        * ATT01040
*********************************************************************** ATT01050
         LA    R1,QCMD                                                  ATT01060
         SVC   202                                                      ATT01070
         DC    AL4(*+4)                                                 ATT01080
         RDTERM MYTEXT                                                  ATT01090
         STC   R0,MYTEXTL                                               ATT01100
         LA    R0,MYPARM1                                               ATT01110
         LA    R1,MYTEXTL                                               ATT01120
         L     R15,APARSE                                               ATT01130
         BALR  R14,R15                                                  ATT01140
*    MYPARM1-MYPARM15 = RESULT OF THE QUERY XXX COMMAND                 ATT01150
*    POSSIBLE RESULTS ARE    (ANYTHING ELSE ASSUME DOES NOT EXIST)      ATT01160
*    MYPARM1  MYPARM2  MYPARM3  MYPARM4  MYPARM5  MYPARM6  MYPARM7      ATT01170
*    *        DEV      XXX      OFFLINE                                 ATT01180
*    *        DEV      XXX      FREE                                    ATT01190
*    *        DEV      XXX      ATTACH   TO       ICATS    YYY          ATT01200
*    *        DMKCPT04 DEV      XXX      DOES     NOT      EXIST        ATT01210
*    *        DMKCQG02 VADDR    MISSING  OR       INVALID               ATT01220
         CLC   MYPARM4,=CL8'OFFLINE'                                    ATT01230
         BE    DOITCONA           IF OFFLINE, VARY IT ON THEN ATTACH    ATT01240
         CLC   MYPARM4,=CL8'FREE'                                       ATT01250
         BE    DOITCONA           IF FREE, VARY ON ANYWAY, THEN ATTACH  ATT01260
         CLC   MYPARM4,=CL8'ATTACH'                                     ATT01270
         BNE   DOITERRB           IF NOT ATTACHED, IT'S AN ERROR        ATT01280
         CLC   MYPARM6,MYVMUID      SEE IF IT'S ATTACHED TO ME OR NOT   ATT01290
         BNE   DOITERRA           IF ATTACHED TO SOMEONE ELSE, ERROR    ATT01300
         CLC   MYPARM7(3),GOODVCUU  SEE IF IT'S ATTACHED AS I WANT IT   ATT01310
         BE    DOITCONC             IF SO, DON'T VARY ON OR ATTACH -    ATT01320
*                                   IT'S ALREADY DONE.  JUST TELL CMS   ATT01330
*                                   WE WANT TO HANDLE THE INTERRUPTS.   ATT01340
*                                                                       ATT01350
*********************************************************************** ATT01360
*    THE DEVICE IS ATTACHED TO SOMEBODY ELSE OR IT'S ALREADY          * ATT01370
*    ATTACHED TO ME AS SOME OTHER DEVICE.                             * ATT01380
*********************************************************************** ATT01390
DOITERRA DS    0H                                                       ATT01400
         MVC   FAIL5UID,MYPARM6    MOVE OWNER'S VM USER ID              ATT01410
         MVC   FAIL5UVA,MYPARM7    MOVE HIS VIRTUAL ADDRESS             ATT01420
         LA    R1,FAIL5MSG         SAY CAN'T ATTACH XXX AS YYY,         ATT01430
         B     DOITMSG                 IT'S ATTACHED TO USERID AS ZZZ   ATT01440
*********************************************************************** ATT01450
*    THE STATUS OF THE UTS IS SUCH THAT WE CAN'T ATTACH IT TO OURSELVES ATT01460
*    THE WAY WE WANT IT.  GIVE A MESSAGE SAYING SOMETHING'S WRONG.      ATT01470
*********************************************************************** ATT01480
DOITERRB DS    0H                                                       ATT01490
         LA    R1,FAIL4MSG                                              ATT01500
         B     DOITMSG                                                  ATT01510
*********************************************************************** ATT01520
*    DO THE VARY ON AND ATTACH COMMANDS                               * ATT01530
*********************************************************************** ATT01540
DOITCONA LA    R1,VARYCMD                                               ATT01550
         SVC   202                                                      ATT01560
         DC    AL4(*+4)                                                 ATT01570
         LTR   R15,R15                                                  ATT01580
         BZ    DOITCONB                                                 ATT01590
         LA    R1,FAIL1MSG         SAY SORRY, XXX FAILED TO COME ONLINE ATT01600
         B     DOITMSG                                                  ATT01610
DOITCONB DS    0H                                                       ATT01620
         LA    R1,ATTCMD                                                ATT01630
         SVC   202                                                      ATT01640
         DC    AL4(*+4)                                                 ATT01650
         LA    R1,FAIL2MSG      ASSUME IT FAILED                        ATT01660
         LTR   R15,R15              DID IT ??                           ATT01670
         BNZ   DOITMSG              YEP, I KNEW IT.                     ATT01680
*                                                                       ATT01690
*    NOW THE UTS IS VARIED ONLINE AND ATTACHED TO ME.                   ATT01700
*    TELL CMS THAT I WANT TO HANDLE ITS INTERRUPTS.                     ATT01710
DOITCONC MVC   HNDLABEL+16(4),CBUTSUID                                  ATT01720
         MVC   HNDLABEL+20(4),=V(UTSIOIH)                               ATT01730
         MVC   HNDLABEL+24(2),CBUTSVAD                                  ATT01740
         CNOP  0,4                                                      ATT01750
HNDLABEL HNDINT SET,(JUNK,ATTACH,444,ASAP)                              ATT01760
         LA    R1,FAIL3MSG                                              ATT01770
         LTR   R15,R15          INSURE THAT HNDINT WORKED OK            ATT01780
         BNZ   DOITMSG                                                  ATT01790
*-------------------------------------------------------------*         ATT01800
*    GET THE TIME AND DATE FROM CP                            *         ATT01810
*-------------------------------------------------------------*         ATT01820
         LA    R1,CPDATA           ADDRESS OF DATA FROM DIAG            ATT01830
         DIAG  R1,R0,X'000C'       REQUEST DATE AND TIME FROM CP        ATT01840
*-------------------------------------------------------------*         ATT01850
*    CPDATA IS NOW IN THE FORMAT OF                           *         ATT01860
*           DC    CL8'MM/DD/YY'                               *         ATT01870
*           DC    CL8'HH:MM:SS'                               *         ATT01880
*           DS    2D     THE REST IS JUNK                     *         ATT01890
*-------------------------------------------------------------*         ATT01900
         MVC   CBUTSDAT,CPDATA                                          ATT01910
         MVC   CBUTSTIM,CPDATA+8                                        ATT01920
         LA    R1,GOODMSG       DONE AT LAST.  GIVE GOOD MESSAGE        ATT01930
         OI    CBUTSFGA,ONLINE  MARK THIS UTS AS BEING ONLINE           ATT01940
DOITMSG  EQU   *                                                        ATT01950
         L     R15,AMESSAGE                                             ATT01960
         BALR  R14,R15                                                  ATT01970
         B     ATTBACK                                                  ATT01980
*                                                                       ATT01990
CPDATA   DS   4D                                                        ATT02000
QCMD     DS   0D              MUST BE DOUBLEWORD ALIGNED                ATT02010
         DC   CL8'CPCOMMT'                                              ATT02020
         DC   CL8'LIFO'                                                 ATT02030
         DC   CL8'Q'                                                    ATT02040
QA       DC   CL8' '                                                    ATT02050
         DC   8X'FF'                                                    ATT02060
*                                                                       ATT02070
VARYCMD  DS   0D              MUST BE DOUBLEWORD ALIGNED                ATT02080
         DC   CL8'CP'                                                   ATT02090
         DC   CL8'VARY'                                                 ATT02100
         DC   CL8'ON'                                                   ATT02110
VARYONA  DC   CL8' '                                                    ATT02120
         DC   8X'FF'                                                    ATT02130
*                                                                       ATT02140
ATTCMD   DS   0D              MUST BE DOUBLEWORD ALIGNED                ATT02150
         DC   CL8'CP'                                                   ATT02160
         DC   CL8'ATTACH'                                               ATT02170
ATTA     DC   CL8' '                                                    ATT02180
         DC   CL8'*'                                                    ATT02190
ATTB     DC   CL8' '                                                    ATT02200
         DC   8X'FF'                                                    ATT02210
WORKA    DS   D          WORK AREAS FOR UNPACKING                       ATT02220
WORKB    DS   D                                                         ATT02230
MYPARM1  DS   D                                                         ATT02240
MYPARM2  DS   D                                                         ATT02250
MYPARM3  DS   D                                                         ATT02260
MYPARM4  DS   D                                                         ATT02270
MYPARM5  DS   D                                                         ATT02280
MYPARM6  DS   D                                                         ATT02290
MYPARM7  DS   D                                                         ATT02300
MYPARM8  DS   D                                                         ATT02310
MYPARM9  DS   D                                                         ATT02320
MYPARM10 DS   D                                                         ATT02330
MYPARM11 DS   D                                                         ATT02340
MYPARM12 DS   D                                                         ATT02350
MYPARM13 DS   D                                                         ATT02360
MYPARM14 DS   D                                                         ATT02370
MYPARM15 DS   D                                                         ATT02380
ATTREGS  DS   15F                                                       ATT02390
NONEMSG  DC    AL1(NONEMSGE)                                            ATT02400
         DC    C'SORRY, BUT THERE ARE NO UTS''S TO GET'                 ATT02410
NONEMSGE EQU   *-NONEMSG-1                                              ATT02420
FAIL1MSG DC    AL1(FAIL1EQU)                                            ATT02430
         DC    C'SORRY, BUT '                                           ATT02440
FAIL1CUU DC    CL3' '                                                   ATT02450
         DC    C' FAILED TO COME ONLINE'                                ATT02460
FAIL1EQU EQU   *-FAIL1MSG-1                                             ATT02470
FAIL2MSG DC    AL1(FAIL2EQU)                                            ATT02480
         DC    C'SORRY, '                                               ATT02490
FAILRCUU DC    CL3' '                                                   ATT02500
         DC    C' GOT VARIED ONLINE OK, BUT FAILED TO ATTACH AS '       ATT02510
FAILVCUU DC    CL3' '                                                   ATT02520
FAIL2EQU EQU   *-FAIL2MSG-1                                             ATT02530
FAIL3MSG DC    AL1(FAIL3EQU)                                            ATT02540
         DC    C'SORRY, '                                               ATT02550
FAIL3RAD DC    CL3' '                                                   ATT02560
         DC    C' GOT VARIED ONLINE AND ATTACHED OK AS '                ATT02570
FAIL3VAD DC    CL3' '                                                   ATT02580
         DC    C', BUT THE HNDINT MACRO FOR IT FAILED'                  ATT02590
FAIL3EQU EQU   *-FAIL3MSG-1                                             ATT02600
FAIL4MSG DC    AL1(FAIL4EQU)                                            ATT02610
         DC    C'SORRY, GOT A BAD ERROR WITH THE CP QUERY '             ATT02620
FAIL4RAD DC    CL3' '                                                   ATT02630
         DC    C' COMMAND'                                              ATT02640
FAIL4EQU EQU   *-FAIL4MSG-1                                             ATT02650
FAIL5MSG DC    AL1(FAIL5EQU)                                            ATT02660
         DC    C'SORRY, CAN''T ATTACH '                                 ATT02670
FAIL5RAD DC    CL3' '                                                   ATT02680
         DC    C' TO ME AS '                                            ATT02690
FAIL5VAD DC    CL3' '                                                   ATT02700
         DC    C', IT''S ATTACHED TO '                                  ATT02710
FAIL5UID DC    CL8' '                                                   ATT02720
         DC    C' AS '                                                  ATT02730
FAIL5UVA DC    CL3' '                                                   ATT02740
FAIL5EQU EQU   *-FAIL5MSG-1                                             ATT02750
GOODMSG  DC    AL1(GOODMSGE)                                            ATT02760
GOODRCUU DC    CL3' '                                                   ATT02770
         DC    C' IS ONLINE AND ATTACHED AS '                           ATT02780
GOODVCUU DC    CL3' '                                                   ATT02790
GOODMSGE EQU   *-GOODMSG-1                                              ATT02800
MYTEXTL  DS    X'00'                                                    ATT02810
MYTEXT   DS    CL130                                                    ATT02820
         LTORG                                                          ATT02830
         ICDATA                                                         ATT02840
         END                                                            ATT02850