TITLE  'ICATS TERMINAL INTERRUPT HANDLING ROUTINE'             TER00010
*********************************************************************** TER00020
*                                                                     * TER00030
*  MODULE NAME =  TERMIOIH                                            * TER00040
*                                                                     * TER00050
*  FUNCTION =  HANDLE TERMINAL I/O INTERRUPTS.  FROM THE MOMENT WHEN  * TER00060
*              SOMEBODY DIALS THIS VIRTUAL MACHINE, WE START SEEING   * TER00070
*              EVERY INTERRUPT FROM THAT TERMINAL.  THIS ROUTINE      * TER00080
*              POSTS THAT INTERRUPT IN THAT TERMINAL'S CONTROL BLOCK. * TER00090
*                                                                     * TER00100
*  ENTRY POINTS =  TERMIOIH                                           * TER00110
*                                                                     * TER00120
*  LINKAGE =  FROM CMS (ROUTINE ADDRESS SPECIFIED IN THE HNDINT       * TER00130
*             MACRO ISSUED IN THE CONFIG ROUTINE).                    * TER00140
*                                                                     * TER00150
*  REGISTER CONTENTS UPON ENTRY =                                     * TER00160
*      R0-R1 = I/O OLD PSW                                            * TER00170
*      R2-R3 = CHANNEL STATUS WORD (CSW).                             * TER00180
*      R4 = DEVICE ADDRESS.                                           * TER00190
*      R14 = RETURN ADDRESS BACK TO CMS.                              * TER00200
*      R15 = ENTRY POINT TO THIS MODULE                               * TER00210
*                                                                     * TER00220
*  REGISTER USAGE =                                                   * TER00230
*      R0-R1 = USED TO PASS PARAMETERS TO SUBROUTINES.                * TER00240
*      R2 =  USED TO ADDRESS THE ICATS COMMON DATA AREA.              * TER00250
*      R3 =  USED TO ADDRESS THE TERM CONTROL BLOCKS.                 * TER00260
*      R4-R10 = FREE                                                  * TER00270
*      R11 = MY BASE REGISTER                                         * TER00280
*      R14 = MY RETURN ADDRESS WHEN I CALL SOMEBODY                   * TER00290
*      R15 = SUBROUTINE ADDRESS                                       * TER00300
*                                                                     * TER00310
*                                                                     * TER00320
*  MODULE LOGIC:                                                      * TER00330
*      1)  GO THROUGH THE TERMINAL CONTROL BLOCK CHAIN AND FIND       * TER00340
*          THE CONTROL BLOCK FOR THIS INTERRUPTING TERMINAL.  IF      * TER00350
*          NOT FOUND, THEN THIS INTERRUPTING DEVICE MUST NOT BE       * TER00360
*          A TERMINAL I'M HANDLING.  I DON'T KNOW WHAT IT IS, SO      * TER00370
*          JUST IGNORE IT.                                            * TER00380
*      2)  IF A CORRESPONDING TERMINAL CONTROL BLOCK IS FOUND,        * TER00390
*          POST THIS INTERRUPT AND SET THE BIT THAT SAYS A TERMINAL   * TER00400
*          INTERRUPT IS IN.  THE DISPATCHER WILL LOOK AT THAT         * TER00410
*          BIT LATER AND FIND OUT THAT THIS INTERRUPT NEEDS TO BE     * TER00420
*          TAKEN CARE OF.                                             * TER00430
*                                                                     * TER00440
*  NORMAL EXIT =                                                      * TER00450
*      R15 = 0                                                        * TER00460
*                                                                     * TER00470
*  EXTERNAL REFERENCES = NONE                                         * TER00480
*                                                                     * TER00490
*  MACROS =  ICDATA = ICATS COMMON DATA AREA                          * TER00500
*            ETTE   = ENTER TRACE TABLE ENTRY SUBROUTINE              * TER00510
*                                                                     * TER00520
*  CHANGE ACTIVITY                                                    * TER00530
*    DATE        NAME       REASON FOR CHANGE                         * TER00540
*  05/26/83  RICK JASPER    ORIGINAL PROGRAM CREATION.                * TER00550
*                                                                     * TER00560
*********************************************************************** TER00570
         PRINT GEN,NODATA                                               TER00580
TERMIOIH CSECT                                                          TER00590
         USING ICDATA,R2            ADDRESS ICATS COMMON DATA AREA      TER00600
         USING CBTERM,R3            ADDRESS TERMINAL CONTROL BLOCK      TER00610
         USING *,R15              USE R15 FOR NEXT INSTRUCTION ONLY     TER00620
         STM   R0,R14,TERMREGS    SAVE ALL THE REGISTERS                TER00630
         DROP  R15                                                      TER00640
         USING TERMIOIH,R11       SWITCH BASE REGISTER TO R11           TER00650
         LR    R11,R15                                                  TER00660
         L     R2,=V(ICDATA)      RELOAD ICDATA BASE REGISTER           TER00670
*    START OUT BY PUTTING AN ENTRY INTO THE TRACE TABLE RECORDING       TER00680
         TM    FLAGC,TRACEMOD        THE FACT WE SAW AN INTERRUPT       TER00690
         BNO   SKIPTTE               DO ONLY IF TRACE MODE IS ON.       TER00700
         LH    R1,TERMREGS+18                                           TER00710
         L     R15,ACONEHEX                                             TER00720
         BALR  R14,R15                                                  TER00730
         STCM  R1,B'0111',TTECUU                                        TER00740
         L     R1,TERMREGS      PUT 1ST HALF OF I/O OLD PSW IN TTE      TER00750
         L     R15,ACONEHEX                                             TER00760
         BALR  R14,R15                                                  TER00770
         STCM  R0,B'1111',TTEOLDA                                       TER00780
         STCM  R1,B'1111',TTEOLDA+4                                     TER00790
         L     R1,TERMREGS+4    PUT 2ND HALF OF I/O OLD PSW IN TTE      TER00800
         L     R15,ACONEHEX                                             TER00810
         BALR  R14,R15                                                  TER00820
         STCM  R0,B'1111',TTEOLDB                                       TER00830
         STCM  R1,B'1111',TTEOLDB+4                                     TER00840
         L     R1,TERMREGS+8    PUT 1ST HALF OF CSW IN TTE              TER00850
         L     R15,ACONEHEX                                             TER00860
         BALR  R14,R15                                                  TER00870
         STCM  R0,B'1111',TTECSWA                                       TER00880
         STCM  R1,B'1111',TTECSWA+4                                     TER00890
         L     R1,TERMREGS+12   PUT 2ND HALF OF CSW IN TTE              TER00900
         L     R15,ACONEHEX                                             TER00910
         BALR  R14,R15                                                  TER00920
         STCM  R0,B'1111',TTECSWB                                       TER00930
         STCM  R1,B'1111',TTECSWB+4                                     TER00940
         ETTE  IOTTE                                                    TER00950
SKIPTTE  EQU   *                                                        TER00960
         TM    TEST0916,TEST10                                          TER00970
         BNO   SKIPMSG                                                  TER00980
         LH    R8,TERMREGS+18              GET TERMINAL ADDRESS         TER00990
         LH    R9,TERMREGS+12              GET CSW STATUS               TER01000
         LINEDIT TEXT='GOT A TERMINAL INTERRUPT FROM ..., CSW STATUS = -TER01010
               ....',SUB=(HEX,(R8),HEX,(R9)),RENT=NO                    TER01020
SKIPMSG  EQU   *                                                        TER01030
*  GO FIND THIS TERMINAL MACHINE'S CONTROL BLOCK IN THE TERMCB CHAIN    TER01040
*     R3 = THE ADDRESS OF THE CURRENT TERMINAL CONTROL BLOCK            TER01050
         L     R3,TERM1ST        GET ADDRESS OF FIRST TERMINAL CB       TER01060
         LTR   R3,R3             ARE THERE ANY ??                       TER01070
         BZ    IOIGNORE          IF NOT, IGNORE THIS INTERRUPT          TER01080
IOLOOP   CLC   TERMREGS+18(2),CBTERMHA  IS THIS THE INTERRUPTING TERM?? TER01090
         BE    IOCONA            YES, GO TAKE CARE OF IT.               TER01100
         L     R3,CBTERMFP       GET POINTER TO NEXT TERMINAL CB.       TER01110
         LTR   R3,R3             ARE WE AT THE END OF THE CHAIN ??      TER01120
         BNE   IOLOOP            NOPE, GO CHECK THIS UTSCB              TER01130
         B     IOIGNORE          IF UTS NOT FOUND, IGNORE INTERRUPT     TER01140
*                                                                       TER01150
*     NOW R3 IS POINTING TO THE CORRECT TERMINAL CONTROL BLOCK.         TER01160
*     TURN ON THE I-NEED-SERVICING FLAG FOR THIS TERMINAL &             TER01170
*     TURN ON THE A-TERMINAL-NEEDS-SERVICING FLAG.                      TER01180
*     SAVE THE CSW TO LATER PASS IT ON TO THE UTS.                      TER01190
*     REMEMBER THE DATE AND TIME THIS INTERRUPT CAME IN.                TER01200
*    BUT FIRST OF ALL, SINCE CP RETURNS RIGHT AWAY WHEN DOING AN I/O    TER01210
*    OPERATION TO A TUBE WITH DIAGNOSE X'0058', I SEE ALL THE           TER01220
*    CHANNEL END & DEVICE END INTERRUPTS AFTER I COME BACK FROM         TER01230
*    THE DIAGNOSE (UNLIKE GENERAL I/O WITH DIAGNOSE X'0020').           TER01240
*    SO, I'M GOING TO IGNORE ALL TERMINAL INTERRUPTS WITH CHANNEL       TER01250
*    END OR DEVICE END ONLY, UNLESS THIS TERMINAL ISN'T LOOKING AT      TER01260
*    A MENU RIGHT NOW OR PLUGGED IN (I.E. HE HAS JUST DIALED TO ME).    TER01270
IOCONA   DS    0H                                                       TER01280
         TM    CBTERMFA,MENUUP+PLUGGED   IF BOTH BITS ARE OFF,          TER01290
         BZ    IOCON                     DON'T IGNORE THIS INTERRUPT.   TER01300
         TM    TERMREGS+12,X'F3'  CHECK FOR ANY BITS OTHER THAN CHANNEL TER01310
*                                 END AND DEVICE END IN THE UNIT STATUS TER01320
         BNZ   IOCON              IF ANY ARE ON, DON'T IGNORE INTERRUPT TER01330
         CLI   TERMREGS+13,X'00'  CHECK CHANNEL STATUS FOR ANY BITS ON  TER01340
         BE    IOIGNORE           IF NONE THERE, IGNORE THIS INTERRUPT  TER01350
IOCON    DS    0H                                                       TER01360
         OI    CBTERMFA,INTISIN                                         TER01370
         OI    FLAGA,TERMINT                                            TER01380
         MVC   CBTERMCS,TERMREGS+8    SAVE CSW (WAS IN R2 & R3)         TER01390
*-------------------------------------------------------------*         TER01400
*    GET THE TIME AND DATE FROM CP                            *         TER01410
*-------------------------------------------------------------*         TER01420
         LA    R1,CPDATA           ADDRESS OF DATA FROM DIAG            TER01430
         DIAG  R1,R0,X'000C'       REQUEST DATE AND TIME FROM CP        TER01440
*-------------------------------------------------------------*         TER01450
*    CPDATA IS NOW IN THE FORMAT OF                           *         TER01460
*           DC    CL8'MM/DD/YY'                               *         TER01470
*           DC    CL8'HH:MM:SS'                               *         TER01480
*           DS    2D     THE REST IS JUNK                     *         TER01490
*-------------------------------------------------------------*         TER01500
         MVC   CBTERMDA,CPDATA                                          TER01510
         MVC   CBTERMTI,CPDATA+8                                        TER01520
         ETTE  OKINTTTE                                                 TER01530
TERMBYE  DS    0H                                                       TER01540
         LM    R0,R14,TERMREGS                                          TER01550
         SR    R15,R15                RETURN CODE = 0                   TER01560
         BR    R14                    BYE                               TER01570
*                                                                       TER01580
IOIGNORE DS    0H                                                       TER01590
         ETTE  BADINTTE                                                 TER01600
         B     TERMBYE                                                  TER01610
*                                                                       TER01620
CPDATA   DS   4D                                                        TER01630
TERMREGS DS   15F                                                       TER01640
*                                                                       TER01650
IOTTE    DC    AL1(IOTTEQU)                                             TER01660
         DC    C'TERMINAL INTERRUPT RECEIVED FROM '                     TER01670
TTECUU   DS    CL3                                                      TER01680
         DC    C'.  I/O OLD PSW = '                                     TER01690
TTEOLDA  DS    CL8                                                      TER01700
         DC    C' '                                                     TER01710
TTEOLDB  DS    CL8                                                      TER01720
         DC    C'. CSW = '                                              TER01730
TTECSWA  DS    CL8                                                      TER01740
         DC    C' '                                                     TER01750
TTECSWB  DS    CL8                                                      TER01760
         DC    C'.'                                                     TER01770
IOTTEQU  EQU   *-IOTTE-1                                                TER01780
*                                                                       TER01790
OKINTTTE DC    AL1(OKEQU)                                               TER01800
         DC    C'INTERRUPT DULY RECORDED'                               TER01810
OKEQU    EQU   *-OKINTTTE-1                                             TER01820
*                                                                       TER01830
BADINTTE DC    AL1(BADEQU)                                              TER01840
         DC    C'INTERRUPT IGNORED'                                     TER01850
BADEQU   EQU   *-BADINTTE-1                                             TER01860
         LTORG                                                          TER01870
         ICDATA                                                         TER01880
         END                                                            TER01890