TITLE  'ENTER TRACE TABLE ENTRY ROUTINE'                       ETT00010
*********************************************************************** ETT00020
*                                                                     * ETT00030
*  MODULE NAME =  ICATS ENTER TRACE TABLE ENTRY ROUTINE (ETTE)        * ETT00040
*                                                                     * ETT00050
*  FUNCTION =  IF ICATS TRACE MODE IS ON, PUT THIS ENTRY INTO         * ETT00060
*              ICATS TRACE TABLE.                                     * ETT00070
*                                                                     * ETT00080
*  ENTRY POINTS =  ETTE                                               * ETT00090
*                                                                     * ETT00100
*  LINKAGE =  BALR R14,R15 FROM ANYWHERE IN ICATS PROGRAM, EVEN       * ETT00110
*             FROM SOMEWHERE THAT RUNS DISABLED.                      * ETT00120
*             THE ADDRESS OF THIS ROUTINE IS KEPT IN AN ADDRESS       * ETT00130
*             CONSTANT IN THE ICATS COMMON DATA AREA (ICDATA).        * ETT00140
*             FOR EXAMPLE,                                            * ETT00150
*                 LA    R1,TTE        TTE = THE TRACE TABLE ENTRY     * ETT00160
*                 L     R15,AETTE                                     * ETT00170
*                 BALR  R14,R15                                       * ETT00180
*             OR JUST USE THE ETTE MACRO LIKE SO,                     * ETT00190
*                 ETTE  TTE           TTE = THE TRACE TABLE ENTRY     * ETT00200
*                                                                     * ETT00210
*  REGISTER CONTENTS UPON ENTRY =                                     * ETT00220
*     R1  = POINTS TO CALLER'S VARIABLE LENGTH TRACE TABLE            * ETT00230
*           IN THIS FORMAT;                                           * ETT00240
*              TTE      DC    AL1(L'TTETEXT)                          * ETT00250
*              TTETEXT  DC    C'UP TO 255 CHARACTERS OF TEXT'         * ETT00260
*     R2  = POINTS TO THE ICATS COMMON DATA AREA AS ALWAYS.           * ETT00270
*     R14 = RETURN ADDRESS BACK TO CALLER.                            * ETT00280
*     R15 = ADDRESS OF THIS SUBROUTINE (USED AS MY BASE REG).         * ETT00290
*                                                                     * ETT00300
*  ALSO, THESE AREAS ARE SET UP IN THE ICATS COMMON DATA AREA         * ETT00310
*     NEXTTTE  = ADDRESS OF THE NEXT TRACE TABLE ENTRY                * ETT00320
*     FIRSTTTE = ADDRESS OF FIRST TRACE TABLE ENTRY.                  * ETT00330
*     LASTTTE  = ADDRESS OF LAST TRACE TABLE ENTRY.                   * ETT00340
*                                                                     * ETT00350
*  REGISTER USAGE:                                                    * ETT00360
*     R0  = FREE                                                      * ETT00370
*     R14 = RETURN ADDRESS FOR WHEN I CALL SUBROUTINES                * ETT00380
*     R15 = SUBROUTINE ADDRESS                                        * ETT00390
*                                                                     * ETT00400
*  MODULE LOGIC =                                                     * ETT00410
*     THIS IS THE ROUTINE THAT PUTS AN ENTRY INTO THE TRACE TABLE.    * ETT00420
*     THIS ROUTINE WILL PREFIX THE CALLER'S TRACE TABLE ENTRY WITH    * ETT00430
*     AN 8-BYTE TIME STAMP.  TRACE TABLE ENTRIES ARE IN THIS FORMAT;  * ETT00440
*     |--------------|----------|---------------------------------|   * ETT00450
*     |  8-BYTE HEX  |  1-BYTE  |     VARIABLE LENGTH TRACE       |   * ETT00460
*     |  TIME STAMP  |  LENGTH  |          TABLE ENTRY            |   * ETT00470
*     |______________|__________|_________________________________|   * ETT00480
*                                                                     * ETT00490
*      I)  CHECK TRACE MODE.  IF OFF, EXIT RIGHT AWAY.                * ETT00500
*     II)  IS THIS A RECURSIVE CALL ??  IF SO, IGNORE THIS CALL.      * ETT00510
*    III)  ELSE PUT THE ENTRY INTO THE TRACE TABLE.                   * ETT00520
*          1)  WILL IT FIT AT THE NEXT TRACE TABLE SLOT ??            * ETT00530
*              A)  IF NOT, PAD THE UNUSED PORTION OF THE TRACE TABLE. * ETT00540
*              B)  RESET NEXTTTE POINTER TO BEGINNING OF TABLE.       * ETT00550
*          2)  GET CURRENT TIME VIA STORE CLOCK INSTRUCTION.          * ETT00560
*          3)  MOVE TRACE TABLE ENTRY INTO PLACE.                     * ETT00570
*          4)  PAD WITH BLANKS TO NEXT 32 BYTE BOUNDARY               * ETT00580
*              (MAKES FOR EASIER READING IN DUMPS).                   * ETT00590
*                                                                     * ETT00600
*  CONTROL BLOCKS =  ICDATA   (ICATS COMMON DATA AREA)                * ETT00610
*                                                                     * ETT00620
*  NON-STANDARD MACROS (FOUND IN ICATS MACLIB)                        * ETT00630
*            ICDATA = ICATS COMMON DATA AREA DSECT.                   * ETT00640
*                                                                     * ETT00650
*  CHANGE ACTIVITY                                                    * ETT00660
*    DATE        NAME       REASON FOR CHANGE                         * ETT00670
*  04/18/83  RICK JASPER    BROKEN AWAY FROM ICATS MAINLINE INTO      * ETT00680
*                           SEPARATE SUBROUTINE                       * ETT00690
*                                                                     * ETT00700
*********************************************************************** ETT00710
         EJECT                                                          ETT00720
         PRINT   GEN,NODATA                                             ETT00730
ETTE     CSECT                                                          ETT00740
         USING ICDATA,R2            ADDRESS ICATS COMMON DATA AREA      ETT00750
         USING *,R15             USE DIFFERENT BASE REGISTER            ETT00760
         TM    FLAGC,TRACEMOD    SEE IF TRACE MODE IS ON                ETT00770
         BNOR  R14               IF NOT, GET OUT OF HERE QUICK          ETT00780
         TM    FLAGC,INETTE      IS THIS A RECURSIVE CALL ??            ETT00790
         BOR   R14               IF SO, IGNORE THIS ETTE REQUEST        ETT00800
         OI    FLAGC,INETTE      GRAB ETTE LOCK                         ETT00810
         STM   R0,R15,ETTEREGS   ONLY NOW, CAN YOU SAVE THE REGISTERS   ETT00820
*    IF YOU DO ANY STORING BEFORE THE OI INSTRUCTION, YOU MIGHT GET     ETT00830
*    INTERRUPTED BY A UTS INTERRUPT AND THAT I/O FLIH WOULD COME        ETT00840
*    THROUGH HERE AND OVERLAY ETTEREGS.  THIS WAY, THE I/O FLIH'S       ETT00850
*    ETTE CALL WILL BE IGNORED (THAT'S THE BEST I CAN DO AND KISS       ETT00860
*    (KEEP IT SIMPLE, STUPID)).  NOT AS SOPHISTICATED A PROCEDURE       ETT00870
*    AS ANY REAL OPERATING SYSTEM, BUT IT'LL WORK (I HOPE).             ETT00880
         SR    R13,R13                                                  ETT00890
         IC    R13,0(R1)              GET TRACE TABLE ENTRY LENGTH      ETT00900
         LA    R13,9(R13)             ADJUST FOR TIME STAMP & LENGTH    ETT00910
*    R13 = LENGTH OF THIS TRACE TABLE ENTRY UNPADDED                    ETT00920
         SR    R4,R4                                                    ETT00930
         LR    R5,R13                                                   ETT00940
         D     R4,=F'16'         R4 = REMAINDER  R5 = QUOTIENT          ETT00950
         LA    R14,0             ASSUME PAD LENGTH = 0                  ETT00960
         LTR   R4,R4             IS TTE AN EXACT MULTIPLE OF 16 ?       ETT00970
         BZ    ETTECONA          YEP, WHAT LUCK.  NO PADDING NEEDED     ETT00980
         LA    R5,1(R5)          ADD ONE MORE 16-BYTE BLOCK FOR TTE     ETT00990
         LA    R14,16                                                   ETT01000
         SR    R14,R4            R14 = PAD LENGTH                       ETT01010
ETTECONA SLL   R5,4              R5 = BYTE COUNT OF THIS TTE PADDED     ETT01020
*    WILL THIS TTE FIT IN WHAT'S LEFT OF THE TRACE TABLE OR MUST WE     ETT01030
*    START AT THE BEGINNING OF THE TRACE TABLE AGAIN ??                 ETT01040
         L     R6,NEXTTTE        GET ADDRESS OF NEXT FREE BYTE IN TABLE ETT01050
         AR    R6,R5             ADD THIS TTE LENGTH                    ETT01060
         C     R6,LASTTTE        WILL IT OVERFLOW THE TRACE TABLE ?     ETT01070
         BL    ETTECONB          NOPE, IT'LL FIT.  GO PUT IT IN         ETT01080
*    TRACE TABLE WOULD HAVE OVERFLOWED IF WE PUT THIS TTE AT THE END.   ETT01090
*    NOW, WE'RE GOING TO HAVE TO PUT THIS TTE AT THE BEGINNING OF THE   ETT01100
*    TRACE TABLE, BUT FIRST PAD THE END OF THE TRACE TABLE.             ETT01110
         L     R6,NEXTTTE            R6 = DESTINATION ADDRESS           ETT01120
         L     R7,LASTTTE            R7 = DESTINATION LENGTH            ETT01130
         SR    R7,R6                    = LASTTTE - NEXTTTE             ETT01140
         L     R9,=X'60000000'       PAD CHARACTER = C'-', LENGTH = 0   ETT01150
         MVCL  R6,R8                                                    ETT01160
         MVC   NEXTTTE,FIRSTTTE      RESET NEXTTTE TO START OF TABLE    ETT01170
ETTECONB DS    0H                                                       ETT01180
*    NOW, NEXTTTE = ADDRESS OF WHERE THIS TTE IS DEFINITELY GOING       ETT01190
         L     R13,NEXTTTE                                              ETT01200
         STCK  0(R13)            TIME STAMP TRACE TABLE ENTRY           ETT01210
         LA    R6,8(R13)         DESTINATION ADDRESS = PAST TIME STAMP  ETT01220
         LR    R7,R5             SET DESTINATION LENGTH WHICH IS THIS   ETT01230
         S     R7,=F'8'          TTE LENGTH - TIME STAMP LENGTH         ETT01240
         LR    R8,R1             SET SOURCE ADDRESS                     ETT01250
         SR    R9,R9                                                    ETT01260
         IC    R9,0(R1)          SET SOURCE LENGTH = LENGTH OF THIS     ETT01270
         LA    R9,1(R9)              TTE + 1 ('CAUSE OF THE LENGTH)     ETT01280
         O     R9,=X'60000000'   PAD CHARACTER = C'-'                   ETT01290
         MVCL  R6,R8             AFTER THE MVCL, R6 = NEW NEXTTTE       ETT01300
         ST    R6,NEXTTTE        UPDATE NEXT TRACE TABLE ENTRY POINTER  ETT01310
         LM    R0,R15,ETTEREGS        RESTORE THE REGISTERS             ETT01320
         NI    FLAGC,ALL-INETTE       RELEASE ETTE LOCK                 ETT01330
         BR    R14                    RETURN TO CALLER                  ETT01340
ETTEREGS DS    16F               CALLER'S REGISTERS SAVE AREA           ETT01350
         LTORG                                                          ETT01360
         ICDATA                                                         ETT01370
         END                                                            ETT01380