TITLE  'ICATS EXTERNAL INTERRUPT HANDLING ROUTINE'             ICA00010
*********************************************************************** ICA00020
*                                                                     * ICA00030
*  MODULE NAME =  ICATS EXTERNAL INTERRUPT HANDLER                    * ICA00040
*                                                                     * ICA00050
*  FUNCTION =  HANDLE EXTERNAL INTERRUPTS TO THE ICATS VIRTUAL        * ICA00060
*              MACHINE, SPECIFICALLY TO ACCEPT SMSG'S FROM            * ICA00070
*              OTHER VIRTUAL MACHINES.                                * ICA00080
*                                                                     * ICA00090
*  ENTRY POINTS =  ICATEXIH                                           * ICA00100
*                                                                     * ICA00110
*  LINKAGE =  BALR R14,R15 FROM CMS'S EXTERNAL INTERRUPT HANDLER.     * ICA00120
*             THE ICATS MAINLINE TELLS CMS THAT WE WANT TO HANDLE     * ICA00130
*             EXTERNAL INTERRUPTS AND GIVES THE ADDRESS OF THIS       * ICA00140
*             MODULE AS OUR INTERRUPT HANDLING ROUTINE.               * ICA00150
*             WHEN AN SMSG COMES IN, THIS VIRTUAL MACHINE SEES AN     * ICA00160
*             EXTERNAL INTERRUPT (INTERRUPT CODE = X'4001').          * ICA00170
*             CMS'S EXTERNAL INTERRUPT HANDLING ROUTINE PASSES        * ICA00180
*             CONTROL TO THIS ROUTINE (WITH INTERRUPTS STILL          * ICA00190
*             DISABLED) WHICH MUST PASS CONTROL BACK TO CMS           * ICA00200
*             VIA A BR R14.                                           * ICA00210
*                                                                     * ICA00220
*  REGISTER CONTENTS UPON ENTRY (SET UP BY CMS) =                     * ICA00230
*     R1  = ADDRESS OF CMS DATA AREA (SEE XOLD DSECT)                 * ICA00240
*     R13 = ADDRESS OF A USER SAVE AREA                               * ICA00250
*     R14 = ADDRESS I MUST RETURN TO CMS WITH                         * ICA00260
*     R15 = ADDRESS OF THIS ROUTINE (USED AS BASE REGISTER)           * ICA00270
*                                                                     * ICA00280
*     REGISTER USAGE:                                                 * ICA00290
*     R0  = FREE                                                      * ICA00300
*     R1  = ADDRESS OF MY TRACE TABLE ENTRY FOR ETTE SUBROUTINE       * ICA00310
*     R2  = ICATS COMMON DATA AREA BASE REGISTER (ICDATA)             * ICA00320
*     R3  = CMS DATA AREA BASE REGISTER (XOLD)                        * ICA00330
*  R4-R5  = FREE                                                      * ICA00340
*     R6  = SMSG BUFFER BASE REGISTER (SMSG)                          * ICA00350
*     R7  = SMSG QUEUE BASE REGISTER (SMSGNTRY)                       * ICA00360
*     R8  = WORK REGISTER                                             * ICA00370
*  R9-R10 = FREE                                                      * ICA00380
*     R11 = BASE REGISTER FOR THIS ROUTINE                            * ICA00390
* R12-R13 = FREE                                                      * ICA00400
*     R14 = RETURN ADDRESS FOR WHEN I CALL SUBROUTINES                * ICA00410
*     R15 = SUBROUTINE ADDRESS                                        * ICA00420
*                                                                     * ICA00430
*  MODULE LOGIC =                                                     * ICA00440
*      I)  PUT AN ENTRY INTO THE TRACE TABLE INDICATING THAT I'VE     * ICA00450
*          SEEN AN EXTERNAL INTERRUPT.                                * ICA00460
*     II)  SEE IF THE EXTERNAL OLD PSW IS MY WAIT STATE PSW.          * ICA00470
*          IF IT IS, THEN TURN OFF THE WAIT BIT, SO THAT WE GO        * ICA00480
*          THROUGH THE DISPATCHER AGAIN.                              * ICA00490
*    III)  SEE IF THIS EXTERNAL INTERRUPT IS BECAUSE OF AN SMSG.      * ICA00500
*          IF NOT, PUT A ENTRY INTO THE TRACE TABLE SAYING THAT       * ICA00510
*          WE'RE GOINT TO IGNORE THIS UNKNOWN INTERRUPT.              * ICA00520
*     IV)  ELSE MOVE THIS GUY'S SMSG INTO MY SMSG CIRCULAR QUEUE.     * ICA00530
*          THE SMSG CIRCULAR QUEUE IS BIG ENOUGH TO HANDLE 10 SMSG'S  * ICA00540
*          AT A TIME.  THE SMSG'S GET QUEUED UNTIL THEY CAN BE        * ICA00550
*          DISPATCHED.  IF THE QUEUE GETS FILLED (11 UNSERVICED       * ICA00560
*          SMSG'S AT THE SAME TIME), THEN THE FIRST SMSG GETS         * ICA00570
*          OVERLAYED WITH THIS MOST CURRENT SMSG, AND THUS GETS       * ICA00580
*          IGNORED.  THAT'S JUST TOO BAD, BUT SHOULD NEVER HAPPEN.    * ICA00590
*                                                                     * ICA00600
*  NORMAL EXIT =                                                      * ICA00610
*      R15 = 0                                                        * ICA00620
*                                                                     * ICA00630
*  EXTERNAL REFERENCES = ICDATA - UNLIKE THE REST OF THE ICATS        * ICA00640
*                                 SOFTWARE, THIS MODULE MUST USE      * ICA00650
*                        AN EXTERNAL REFERENCE TO ICDATA INSTEAD      * ICA00660
*                        OF ITS ADDRESS BEING PASSED IN R2, SINCE     * ICA00670
*                        I CAN'T INSURE THIS EXTERNAL INTERRUPT       * ICA00680
*                        CAME IN WHEN ONE OF MY MODULES WAS RUNNING   * ICA00690
*                        (BOY, WHAT A LONG RUN-ON SENTENCE).          * ICA00700
*                                                                     * ICA00710
*  CONTROL BLOCKS =  ICDATA   (ICATS COMMON DATA AREA)                * ICA00720
*                                                                     * ICA00730
*  NON-STANDARD MACROS (FOUND IN ICATS MACLIB)                        * ICA00740
*            ICDATA = ICATS COMMON DATA AREA DSECT.                   * ICA00750
*            ETTE   = ENTER TRACE TABLE ENTRY SUBROUTINE              * ICA00760
*                                                                     * ICA00770
*  CHANGE ACTIVITY                                                    * ICA00780
*    DATE        NAME       REASON FOR CHANGE                         * ICA00790
*  04/18/83  RICK JASPER    BROKEN AWAY FROM ICATS MAINLINE INTO      * ICA00800
*                           SEPARATE SUBROUTINE                       * ICA00810
*                                                                     * ICA00820
*********************************************************************** ICA00830
         EJECT                                                          ICA00840
         PRINT GEN,NODATA                                               ICA00850
ICATEXIH CSECT                                                          ICA00860
         USING ICDATA,R2            ADDRESS ICATS COMMON DATA AREA      ICA00870
         USING XOLD,R3                                                  ICA00880
         USING SMSG,R6                                                  ICA00890
         USING SMSGNTRY,R7          SMSG BUFFER BASE REGISTER.          ICA00900
         USING *,R11          USE R11, NOT R15, FOR MY BASE REGISTER    ICA00910
         STM   R0,R15,0(R13)      STORE REGISTERS IN CMS'S SAVE AREA    ICA00920
         LR    R11,R15                                                  ICA00930
         LR    R3,R1              USE R3, NOT R1, FOR CMS DATA AREA     ICA00940
         L     R2,AICDATA         REESTABLISH DATA AREA ADDRESSABILITY  ICA00950
         MVC   XINTTTET(8),XOLDPSW     PUT EXT. OLD PSW IN TTE          ICA00960
         ETTE  XINTTTE                 PUT ENTRY INTO TRACE TABLE       ICA00970
         CLC   XOLDPSW+4(4),WAITPSW+4   INSURE IT'S MY WAIT PSW         ICA00980
         BNE   XCONTA                   OOPS, DON'T KNOW WHOSE THIS IS  ICA00990
         NI    XOLDPSW+1,X'FD'    TURN OFF WAIT BIT IN OLD PSW IF MINE  ICA01000
         B     XCONTB             CONTINUE ON                           ICA01010
XCONTA   DS    0H                                                       ICA01020
*        ETTE  XBADPSW            NOTE UNEXPECTED PSW ENCOUNTERED       ICA01030
XCONTB   DS    0H                                                       ICA01040
         CLC   XOLDPSW+2(2),=X'4001'    INSURE IT'S AN SMSG INTERRUPT   ICA01050
         BE    XCONTC                   GOOD, IT'S WHAT I THINK IT IS   ICA01060
         ETTE  XBADPSW            NOTE UNKNOWN EXTERNAL INTERRUPT       ICA01070
         B     XCONTE             IGNORE THIS INTERRUPT                 ICA01080
*********************************************************************** ICA01090
*    NOW WE KNOW IT'S THIS EXTERNAL INTERRUPT WAS CAUSED BY AN SMSG.  * ICA01100
*    MOVE THE SMSG FROM THE SMSG BUFFER INTO THE SMSG QUEUE.          * ICA01110
*********************************************************************** ICA01120
XCONTC   DS    0H                                                       ICA01130
         LA    R6,SMSGBUFF            GET ADDRESS OF SMSG BUFFER        ICA01140
         L     R7,NEXTSMSG            GET ADDRESS OF NEXT QUEUE SLOT    ICA01150
         MVC   SMSGUID,VMCMUSE        MOVE VM USER ID OF SMSG SENDER    ICA01160
         MVC   SMSGLEN,VMCMLENA+2     MOVE SMSG LENGTH                  ICA01170
         MVC   SMSGTEXT,VMCMBUF       MOVE IN SMSG TEXT, BLANKS AND ALL ICA01180
         LA    R7,139(R7)             BUMP SMSG BUFFER POINTER          ICA01190
         C     R7,LASTSMSG            TOO BIG YET ??                    ICA01200
         BNH   XCONTD                 NOPE, CONTINUE ON                 ICA01210
         L     R7,FRSTSMSG            ELSE USE FIRST SMSG BUFFER AGAIN  ICA01220
XCONTD   DS    0H                                                       ICA01230
         ST    R7,NEXTSMSG        STORE NEXT SMSG BUFFER POINTER        ICA01240
XCONTE   DS    0H                                                       ICA01250
         LM    R0,R15,0(R13)      RESTORE THE REGISTERS                 ICA01260
         BR    R14                GO BACK TO WHAT YOU WERE DOING        ICA01270
AICDATA  DC    V(ICDATA)         START OF ICATS COMMON DATA AREA        ICA01280
XINTTTE  DC    AL1(L'XINTTTET)                                          ICA01290
XINTTTET DC    C'*OLDPSW*  EXTERNAL INTERRUPT RECEIVED.'                ICA01300
XBADPSW  DC    AL1(L'XBADPSWT)                                          ICA01310
XBADPSWT DC    C'UNEXPECTED INTERRUPT CODE FOR THIS EXTERNAL INTERRUPT' ICA01320
*                                                                       ICA01330
SMSG     DSECT                   SMSG HEADER                            ICA01340
         DS    5F                      JUNK                             ICA01350
VMCMLENA DS    1F                      LENGTH OF SMSG TEXT              ICA01360
         DS    2F                      MORE JUNK                        ICA01370
VMCMUSE  DS    2F                      VM USER ID OF THE SMSG SENDER    ICA01380
VMCMBUF  DS    129C' '           SMSG TEXT                              ICA01390
ICATEXIH CSECT           RETURN TO NORMAL CSECT                         ICA01400
         ICDATA                                                         ICA01410
*                                                                       ICA01420
*                                                                       ICA01430
XOLD     DSECT           R1 POINTS HERE AFTER AN EXTERNAL INTERRUPT     ICA01440
XOLDGR   DS 16F                     GENERAL PURPOSE REGISTERS           ICA01450
         DS 4D                      FLOATING POINT REGISTERS            ICA01460
XOLDPSW  DS D                                                           ICA01470
XOLDSAVE DS 18F                                                         ICA01480
ICATEXIH CSECT           RETURN TO NORMAL CSECT                         ICA01490
         END                                                            ICA01500