*M*      RTROOT RESIDENT REAL-TIME MODULE
*
         DEF      RTROOT:           PATCHING DEF
RTROOT:  RES
***********************************************************************
*P*      NAME:    RTROOT
*,*
*,*      PURPOSE: TO PROVIDE THE RESIDENT INTERFACE FOR ALL CAL1,5'S
*,*               (EXCEPT M:EXU, M:MASTER & M:SLAVE WHICH ARE HANDLED
*,*               IN ALTCP.
*,*
*,*               TO PROVIDE THE INTERRUPT HANDLERS FOR REAL AND PSEUDO
*,*               INTERRUPTS.
*,*
*,*               TO PROVIDE THE IOQ SUBROUTINES WHICH ARE REQUIRED ONLY
*,*               AS THE RESULT OF M:IOEX (REAL-TIME) CAL1,5'S.
*,*
*,*      DESCRIPTION:   ALL CAL1,5'S (EXCEPT AS NOTED ABOVE) PASS
*,*               THROUGH RTROOT.  CONTROL IS PASSED TO THE RTNR MODULE
*,*               IN THE RTOV OVERLAY FOR THE FOLLOWING CAL1,5'S:
*,*                                 RESDF MEMORY   (FPT CODE = .1B)
*,*                                 M:STOPIO                   .1C
*,*                                 M:STARTIO                  .1D
*,*                                 M:GJOBCON                  .20
*,*                                 M:CONNECT                  .21
*,*                                 M:DISCONNECT               .22
*,*                                 M:CLOCK                    .26
*,*               ALL OTHERS ARE HANDLED IN RTROOT:
*,*                                 M:IOEX (SIO)   (FPT CODE = .1E)
*,*                                 M:IOEX (TIO/TDV/HIO)       .1F
*,*                                 M:INTCON/M:INHIBIT         .23
*,*                                 M:QFI                      .24
*,*                                 M:HOLD                     .25
*,*                                 M:INTSTAT                  .27
*,*
*,*               REAL-TIME INTERRUPT-RECEIVING ROUTINES ALSO RESIDE
*,*               IN RTROOT (THEY INTERFACE TO THE SCHEDULER)-
*,*               THE OCCURRENCES OF REAL & PSEUDO INTERRUPTS CAUSE
*,*               THE MAPPED REAL-TIME USER (CENTRALLY CONNECTED) TO BE
*,*               SCHEDULED BASED UPON INFORMATION CONTAINED IN THE
*,*               INTERRUPT CONTROL BLOCK (ICB) ASSOCIATED WITH THE
*,*               OCCURRING INTERRUPT.
*,*
*,*               CERTAIN IOQ SUBROUTINES THAT NEED BE PRESENT ONLY IN
*,*               A REAL-TIME SYSTEM ALSO RESIDE IN RTROOT.
*,*               THESE PERFORM THE SPECIAL PROCESSING REQUIRED (OF
*,*               IOEX-TYPE REQUESTS) FOR INTERRUPT END-ACTION INTER-
*,*               FACE TO USER'S PROGRAM, TIME-OUT INTERFACE TO USER'S
*,*               PROGRAM, AND CLEAN-UP OPERATIONS.
*
*K* PSEUDO-INTERRUPT AN INTERRUPT WHOSE ADDRESS IS GIVEN AS A VALUE
*,*                  BETWEEN X'1000' AND X'7FFF'; SUCH INTERRUPTS ARE
*,*                  CAPABLE OF BEING TRIGGERED ONLY VIA THE M:INTCON
*,*                  (INTERRUPT CONTROL) CAL1,5 AND ARE USEFUL FOR
*,*                  INTER-PROGRAM COMMUNICATION.
*
*K* CENTRALLY-CONNECTED-INTERRUPT ANY INTERRUPT (REAL OR PSEUDO) WHICH
*,*                               HAS BEEN ASSOCIATED WITH A USER VIA
*,*                               A CAL1,5 (E.G., M:CONNECT/M:GJOBCON).
*,*                               INFORMATION ABOUT THE 'CONNECTED'
*,*                               INTERRUPT AND USER IS CARRIED IN AN
*,*                               INTERRUPT CONTROL BLOCK (ICB).
*
*K* INTERRUPT-CONTROL-BLOCK A 12-WORD, SYSGEN-BUILT DATA BLOCK USED TO
*,*                         STORE INFORMATION ABOUT AN INTERRUPT AND THE
*,*                         USER WHO IS 'CONNECTED' TO THAT INTERRUPT.
***********************************************************************
         TITLE    'R T R O O T    D A T A'
*********************************************************************
*                                   S E C T I O N    I:
*
*                                     DATA DEFINITIONS
*********************************************************************
*
MONPROC  SET      1                 PICK-UP DCB DEFINITIONS
UTSPROC  SET      1                 PICK-UP X560 PROC
UFLAGS   SET      1                 PICK-UP UH:FLG BIT DEFINITIONS
         SYSTEM   UTS
*        SYSTEM   RT:ICBTD          ICB TABLE DEFINITIONS
**********************************************************************
*        NOTE:  THE FOLLOWING SYMBOL DEFINITIONS APPEAR AlSO
*               IN THE MODULE 'RTNR'; ANY CHANGES TO THE ICB
*               TABLE MUST BE MADE IN BOTH MODULES*****************
***********************************************************************
*
         REF      Y06               MASK:  ARMED/ENABLED BITS IN ICBSTAT
*
D        EQU      1                 RESOLUTION DISPLACEMENT WITHIN TABLE
W        EQU      2                 WORD DISPLACEMENT WITHIN TABLE
*
*
ICBSTAT  EQU      0,0               HALFWORD
ICBLNK   EQU      0,0               WORD
ICBXPSD  EQU      1,1               WORD
ICBPSD1  EQU      1,2               DOUBLE-WORD
ICBPSD2  EQU      2,4               DOUBLE-WORD
ICBPRIO  EQU      24,6              BYTE
ICBINT   EQU      13,6              HALFWORD
ICBUN    EQU      28,7              BYTE
ICBDL    EQU      8,8               WORD
ICBPRI   EQU      32,8              BYTE
ICBDLFLG EQU      33,8              BYTE
ICBENTPSD0  EQU   9,9               WORD
ICBDLDATA   EQU   10,10             WORD
ICBICBADR   EQU   11,11             WORD
ICBGJPRI EQU      24,6              BYTE
ICBGUN   EQU      29,7              BYTE
ICBGJNME EQU      4,8               DOUBLE-WORD
ICBGJACN EQU      5,10              DOUBLE-WORD
ICBTUN   EQU      1,1               WORD
ICBCLK   EQU      2,2               WORD
ICBBLNK  EQU      4,4               WORD
ICBSYSEP EQU      3,3               WORD
*
ICBTYP1  EQU      0                 ICBSTATYP FOR TYPE-I ICB
ICBTYP2  EQU      1                 ICBSTATYP FOR TYPE-II ICB
ICBTYP3  EQU      2                 ICBSTATYP FOR TYPE-III ICB
*
STATAR   EQU      NB31TO0+X'1A'     ICBSTAT MASK:ARMED BIT RESET
STATAE   EQU      Y06                            ARMED AND ENABLED
STATA    EQU      BT31TO0+26                     ARMED
STATE    EQU      BT31TO0+27                     ENABLED
STATER   EQU      NB31TO0+X'1B'                  ENABLED BIT RESET
STATRIG  EQU      BT31TO0+28                     TRIGGERED
STATRIGR EQU      NB31TO0+X'1C'                  TRIGGERED BIT RESET
STATO    EQU      BT31TO0+29                     ONESHOT BIT
STATC    EQU      BT31TO0+31                     CLEAR BIT
*
STATYPSHFT    EQU -23               SHIFT-COUNT TO RIGHT-JUSTIFY STATYP
STATINTSHFT   EQU -25               SHIFT-COUNT TO RIGHT-JUSTIFY STATINT
*        END
**********************************************************************
         PAGE
         DEF      RTALTCP           CAL1,5 DRIVER
         DEF      RTWD              SUBR TO FORMAT & ISSUE WD INSTR
         DEF      RTCHKPRIV         SUBR TO CHECK USER PRIVILEGE
         DEF      RTLOCICB          SUBR TO LOCATE A GIVEN ICB
         DEF      RTCNVTXT          SUBR TO CONVERT INT LBL TO INT ADR
         DEF      RTICBTYP          SUBR TO EXTRACT ICBSTATYP
         DEF      RTDCBCHK          SUBR TO VALIDATE IOEX DCB
         DEF      RTDEVCHK          SUBR TO VALIDATE IOEX DEVICE ADR
         DEF      RTVTP             SUBR TO CONVERT VIRT ADR TO PHY ADR
         DEF      RTLCT             SUBR TO ADJUST PB:LCT
         DEF      RTINTRTN          HANDLER FOR M:INTRTN CAL1,5
         DEF      RTCHKGUN          SUBR TO VALIDATE ICBGUN
         DEF      INTSTAT           SUBR FOR M:INTSTAT HANDLER
         DEF      RTSIZE            SUBR TO SIZE-UP USER
         DEF      RTIOSTRT          IOQ SUBR FOLLOWING IOEX SIO
         DEF      RTINT             IOQ SUBR FOR IOEX INTERRUPT
         DEF      RTCU              IOQ SUBR FOR IOEX CLEAN-UP
         DEF      RTTO              IOQ SUBR FOR IOEX TIME-OUT
         DEF      RT:GINT           INTERRUPT HANDLER (M:GJOBCON)
         DEF      RT:UINT           INTERRUPT HANDLER (M:CONNECT)
         DEF      RT:INTENTRY       ROUTINE TO PROCESS INTERRUPT DO-LIST
         DEF      UINTQ             SUBR TO QUE INTERRUPT DO-LIST ITEM
*
*
*
         REF      ALTERR            TO REPORT TCB STACK ERROR
         REF      BLCKD:MASK        TO DERIVE USER'S STATE
         REF      BT31TO0           MASKS
         REF      CALBAD            TO RETURN ERROR CODE TO USER
         REF      CHKBIT            TO SCAN CAL1,5 FPT'S
         REF      CHKBIT1           TO SCAN CAL1,5 FPT'S
         REF      DCTSIZ            SIZE OF DCT TABLES
         REF      DCT1A             FOR IOEX DEV ADR VERIFICATION
         REF      DCT1P             FOR IOEX DEV ADR VERIFICATION
         REF      DCT12             TO SAVE END-ACTION ADDRESS
         REF      DCT13             TO SAVE SIO STATUS REGISTERS
         REF      DCT15             CONTAINS RT-IOEX USER'S #
         REF      DCT19             TO RETRIEVE SIO CC'S ON IOEX FAILURES
         REF      DCT3              'DEVICE DOWN' BIT (M:STOPIO)
         REF      DRIVEIO           TO SERVICE CHANNEL FOLLOWING IOEX HIO
         REF      E:ART             EVENT FOR 'REAL-TIME INTERRUPT'
         REF      E:QFI             EVENT FOR 'QUEUE FOR INTERRUPT'
         REF      ENBSR4            TO RETURN ON R11 (ENABLED)
         REF      EXU:MASK          TO DERIVE USER'S STATE
         REF      ICB               ICBS START THERE
         REF      ICBSIZE           SIZE OF AN ICB
         REF      INTLBSIZ          SIZE OF INTLB1/2/3 TABLES
         REF      INTLB1            TO DECODE INTRRUPT LABELS
         REF      INTLB2            TO DECODE INTERRUPT LABELS
         REF      INTLB3            TO DERIVE DEFAULT PRIO FOR INT LABELS
         REF      INTSIM            TO SET 'CLEANUP PEND' FOLLOWING HIO
         REF      IOQ8              'REL' BIT (M:IOEX)
         REF      IOSCU             TO RETURN TO IOQ AFTER IOEX CLEANUP
         REF      IOWAIT:MASK       TO DERIVE USER'S STATE
         REF      J:DCBLL           TO VERIFY IOEX DCB ADDRESS
         REF      J:ICBHDR          PTR TO CURRENTLY ACT. ICB AT INTRTN
         REF      J:TCB             TO FIND USER'S TCB STACK
         REF      JB:PRIV           USER MUST HAVE X'E0' PRIV FOR CAL1,5
         REF      JX:CMAP           TO CONVERT VIRTUAL TO PHYSICAL
         REF      MAP               TO RE-MAP FOLLOWING IOEX (HIO)
         REF      MASKS             MASKS
         REF      MAXG              SIZE OF GHOST-JOB TABLES
         REF      MONORG            DETERMINES HIGHEST INTERRUPT ADR
         REF      MTRTN0            TO RETURN TO USER FOLLOWING M:INTRTN
         REF      NB31TO0           MASKS
         REF      NEWQNW            M:IOEX (SIO) REQUESTS GO THERE
         REF      NINTS             # OF POSSIBLE ACTIVE ICBS
         REF      PB:LCT            FOR S:RTCORE CALCULATIONS
         REF      RT:GINTP          TO DERIVE ICB ADR FOLLOWING RT INT
         REF      RT:UINTP          TO DERIVE ICB ADR FOLLOWING RT INT
         REF      RTCLOCK#          TO CALL RTOV
         REF      RTCONNECT#        TO CALL RTOV
         REF      RTDISCON#         TO CALL RTOV
         REF      RTGJOBCON#        TO CALL RTOV
         REF      RTICBHDR          FOR ICB CHAINING
         REF      RTNRRTSEG         TO TRANSFER TO RTOV OVERLAY
         REF      RTRESDF#          TO CALL RTOV
         REF      RTRET1            TO RETURN TO IOQ FOLLOWING IOEX INT
         REF      RTRET2            TO RETURN TO IOQ FOLLOWING IOEX INT
         REF      RTSTARTIO#        TO CALL RTOV
         REF      RTSTOPIO#         TO CALL RTOV
         REF      S:ACORE           TO CALCULATE 'UNLOCKED' CORE
         REF      S:BADFLG          REAL-TIME ACTIVITY BITS
         REF      S:CUN             (OBVIOUS)
         REF      S:CUP             TO REMEMBER CURRENT (RT) USER'S PRIO
         REF      S:GJOBACN         TO SEE IF RT GHOST ALREADY EXISTS
         REF      S:GJOBTBL         TO SEE IF RT GHOST ALREADY EXISTS
         REF      S:RTCORE          TO ACCOUNT FOR 'LOCKED' CORE
         REF      S:RTIR            ZEROED AS QMIN FLG FOLLOWING INT
         REF      S:RTUN            TO REMEMBER HIGH-PRIO RT USER
         REF      S:STL#            FOR S:RTCORE CALCULATIONS
         REF      SB:GJOBUN         TO SEE IF RT GHOST ALREADY EXISTS
         REF      SCU               'CURRENT USER' CHK FOR PRIO SETTING
         REF      SL:RSVP           FOR S:RTCORE CALCULATIONS
         REF      SSE40             TO DRIVE TO USER'S INTERRUPT ROUTINE
         REF      T:GJOB            TO INITIATE A RT GHOST FOLLOWING INT
         REF      T:OVERLAY         TO CALL RTOV
         REF      T:PULLE           TO EXIT INTERRUPT PROCESSING ROUTINE
         REF      T:REG             TO QUEUE USER FOR INTERRUPTS
         REF      T:RUE             TO REPORT E:ART/E:QFI EVENTS
         REF      T:SAVE            TO SAVE A STD ENVIR ON INTERRUPT
         REF      T:SSE             TO EXIT TO SCHED FOLLOWING RT INT
         REF      T:SSEM            TO EXIT TO SCHED FOLLOWING M:INTRTN
         REF      T:TOTSZ           TO SIZE-UP USER FOR LOCK-IN-CORE
         REF      T:UTSXTS          TO MOVE INTERRUPTED ENVIRONMENT
         REF      TQUNMAP           TO UN-MAP DURING IOEX (HIO)
         REF      TRAPEXIT          TO RETURN TO USER FOLLOWING CAL
         REF      U:MISC            TO SET UP RETURN TO SCHED
         REF      UB:ACP            FOR S:RTCORE CALCULATIONS
         REF      UB:APO            FOR S:RTCORE CALCULATIONS
         REF      UB:APR            FOR S:RTCORE CALCULATIONS
         REF      UB:ASP            FOR S:RTCORE CALCULATIONS
         REF      UB:DB             FOR S:RTCORE CALCULATIONS
         REF      UB:OV             FOR S:RTCORE CALCULATIONS
         REF      UB:PRIO           FOR ICB PRIORITIZED SCHEDULING
         REF      UB:PRIOB          FOR ICB PRIORITIZED SCHEDULING
         REF      UB:US             TO DERIVE USER'S STATE
         REF      UH:DL             TO CHAIN ICB INTERRUPT REQUESTS
         REF      UH:FLG            'INHIBIT' BIT (M:INHIBIT)
         REF      UH:FLG2           'LOCKED-IN-CORE' BIT (M:HOLD)
         REF      WAIT:MASK         TO DERIVE USER'S STATE
         REF      XF0               MASK
         REF      XF1FFFFFF         MASK
         REF      X1FFFE            MASK
         REF      X3FFE00           MASK
         REF      YC                MASK
         REF      YF                MASK
         REF      YFF               MASK
         REF      YFFFF             MASK
         REF      24BM14            MASK
         REF      24BM18            MASK
*
*
*                                   SYMBOLIC REGISTER DEFINITIONS
R0       EQU      0
R1       EQU      1
R2       EQU      2
R3       EQU      3
R4       EQU      4
R5       EQU      5
R6       EQU      6
R7       EQU      7
R8       EQU      8
R9       EQU      9
R10      EQU      10
R11      EQU      11
R12      EQU      12
R13      EQU      13
R14      EQU      14
R15      EQU      15
*
C15LOW   EQU      X'1B'             L0WEST CAL1,5 FPT CODE, EXCEPT:
*                                   M:MASTER/M:SLAVE WHICH ARE HANDLED
*                                   IN ALTCP
C15HIGH  EQU      X'27'             HIGHEST CAL1,5 FPT CODE, EXCEPT:
*                                   M:EXU WHICH IS HANDLED IN ALTCP
         BOUND    8
RTCAL15CODES DATA C15LOW,C15HIGH
*
C19CS    EQU      -8                SHIFT COUNT TO RIGHT-JUSTIFY CODE
*
FPTF1    EQU      1                 ON/OFF BIT (M:HOLD)
FPTEA    EQU      BT31TO0+31        'EA' PRESENCE BIT (M:IOEX)
FPTDCB   EQU      X'8000'           'DCB' PRESENCE BIT (M:IOEX)
Y2       EQU      BT31TO0+30        'ON-DO-LIST' FLAG
X1       EQU      BT31TO0+1
*
DEV      EQU      1                 WA(DCBDEV)
*
STATEXU  EQU      X'80'             'EXECUTABLE' CODE (M:INTSTAT)
STATWAIT EQU      X'40'             'QFI' CODE (M:INTSTAT)
STATIOW  EQU      X'20'             'IO/WAIT' CODE (M:INTSTAT)
STATBLK  EQU      X'10'             'BLOCKED' CODE (M:INTSTAT)
STATNA   EQU      1                 'NOT ACTIVE' CODE (M:INTSTAT)
*
STATAETR EQU      XF1FFFFFF         'ARMD/ENBLD/TRGRD' BITS RESET
*
RTERR:BADCAL EQU  X'AE'
RTERR:QFI    DATA X'010000B8'
RTERR:INTRTN DATA X'020000B8'
RTERR:PARAM  DATA X'050000B8'
RTERR:IOEX1  DATA X'010000B9'
RTERR:IOEX2  DATA X'020000B9'
*
FLG:LIC  EQU      BT31TO0+12        UH:FLG2 MASK: LOCKED-IN-CORE BIT
FLG:LICR EQU      NB31TO0+12                      LIC BIT RESET
*
FLG:INH  EQU      BT31TO0+2         UH:FLG MASK: SOFTWARE INHIBIT BIT
FLG:INHR EQU      NB31TO0+2                      SOFTWARE INHIBIT-RESET
*
DOWND    EQU      X'20'             DCT3 FLAG - 'DEVICE DOWN'(PRE-EMPTED)
SIOREJECT     EQU BT31TO0+4         SIO REJECT BIT MASK OF DCT3
*
ALLOCAT:UN    EQU 2                 ALLOCAT'S USER #
RBBAT:UN      EQU 3                 RBBAT'S USER #
*
         TITLE    'RT USER-SERVICE SUBROUTINES'
*********************************************************************
*                                   S E C T I O N    II:
*
*                                        SUBROUTINES
*********************************************************************
*
RTWD     EQU      % **************************************************
*
*F*      NAME:    RTWD
*,*
*,*      PURPOSE: FORMAT AND ISSUE AN INTERRUPT CONTROL WD INSTRUCTION.
*,*
*,*      DESCRIPTION:  (SEE 'D' REPORT)
***********************************************************************
*
*D*      NAME:    RTWD
*,*
*,*      REGISTERS:  R3, R13, R14 ARE VULNERABLE.
*,*
*,*      CALL:    BAL,R0
*,*
*,*      INTERFACE:  NONE
*,*
*,*      ENVIRONMENT:  MASTER/MAPPED OR UNMAPPED.
*,*
*,*      INPUT:   R3 = EFFECTIVE ADDRESS OF 'WD' INSTRUCTION
*,*                    (E.G., X'1X00' WHERE X = WD CODE)
*,*               R10= INTERRUPT ADDRESS
*,*
*,*      OUTPUT:  (HARDWARE INTERRUPT STATUS IS ALTERED)
*,*
*,*      DESCRIPTION:  INTERRUPT CONTROL SUBROUTINE -
*,*               FROM THE INTERRUPT ADDRESS, THE GROUP CODE IS
*,*               DERIVED AS WELL AS THE BIT MASK FOR THE 'WD'
*,*               INSTRUCTION'S REGISTER.  FINALLY, A 'WD' INSTRUCTION
*,*               IS EXECUTED TO CHANGE THE INTERRUPT'S STATUS.
***********************************************************************
*
         LW,R13   R10               PICK UP INT. ADR.
         AI,R13   -X'40'            * DEVELOP *
         SLS,R13  -4                *  GROUP  *
         STS,R13  R3                *   CODE  *
         LI,R14   X'8000'           SET UP SHFT INST BITS FOR EXT GRP
         LW,R13   R10               PICK UP INT. ADR. AGAIN
         CI,R13   X'60'             IS IT EXTERNAL?
         BGE      WD1               YES
         AI,R3    -1                NO; MUST BE CEZ; BACK-OFF TO GRP 0
         LI,R14   X'20000'          RESET SHFT INST BITS FOR GRP 0
WD1      ;
         AND,R13  MASKS+4           MASK OFF LEVEL
         LCW,R13  R13
         AND,R13  MASKS+7           MASK OFF SHIFT COUNT
         S,R14    *R13              SHIFT IT
         WD,R14   *R3               **********************************
         B        *R0               RETURN
         PAGE
RTCHKPRIV  EQU    % **************************************************
*
*F*      NAME:    RTCHKPRIV
*,*
*,*      PURPOSE: VALIDATE USER'S PRIVILEGE LEVEL.
*,*
*,*      DESCRIPTION:  (SEE 'D' REPORT)
**************************************************************************
*D*      NAME:    RTCHKPRIV
*,*
*,*      REGISTERS:  R15 IS VULNERABLE.
*,*
*,*      CALL:    BAL,R0
*,*
*,*      INTERFACE:  NONE
*,*
*,*      ENVIRONMENT:  MASTER/MAPPED
*,*
*,*      INPUT:   JB:PRIV
*,*
*,*      OUTPUT:  CONDITION CODE 1 IS SET = 0 (IF JB:PRIV >= X'E0')
*,*                                         1 (IF JB:PRIV <  X'E0')
*,*
*,*      DESCRIPTION:  JB:PRIV IS COMPARED AGAINST THE VALUE X'E0' AND
*,*               CONDITION CODE 1 IS SET AS INDICATED ABOVE.
***********************************************************************
*
         LI,R15   X'E0'             MINIMUM REAL-TIME PRIVILEGE
         LCI      0                 SET NORMAL RETURN
         CB,R15   JB:PRIV           X'E0' : JB:PRIV
         BLE      CHK1              PRIV. OK
         LCI      8                 SET ABNORMAL RETURN
CHK1     B        *R0               RETURN
         PAGE
RTSETCC1 EQU      % **************************************************
*                 PASSES CC SETTING VIA R2 TO RTRETC
*
         LW,R2    BT31TO0+32
         B        RTRETC
         SPACE    5
RTSETCC2 EQU      % **************************************************
*                 PASSES CC SETTING VIA R2 TO RTRETC
*
         LW,R2    BT31TO0+31
         B        RTRETC
         SPACE    5
RTSETCC3 EQU      % ***************************************************
*                 PASSES CC SETTING VIA R2 TO RTRETC
*
         LW,R2    BT31TO0+30
         B        RTRETC
         SPACE    5
RTSETCC0 EQU      % **************************************************
*                 PASSES CC SETTING VIA R2 TO RTRETC
*
         LW,R3    BT31TO0+32
         STS,R3   S:BADFLG          SET 'RT-ACTIVITY' BIT
         LI,R2    0
RTRETC   EQU      % **************************************************
*                 STORES CONDITION CODE (PASSED IN R2) INTO USER PSD
*
         ENABLE                     **********************************
         LW,R3    YF                CC MASK
         LI,R5    -17               DISPL. BACK INTO TSTACK
         AW,R5    TSTACK
         AND,R5   X1FFFE            INSURE DOUBLE-WORD BOUND
         STS,R2   0,R5              SET CC'S
         B        TRAPEXIT          EXIT CAL1 PROCESSING
         PAGE
RTLOCICB EQU      % **************************************************
*
*F*      NAME:    RTLOCICB
*,*
*,*      PURPOSE: FIND AN ACTIVE ICB ASSOCIATED WITH A GIVEN INTERRUPT
*,*               ADDRESS OR LABEL.
*,*
*,*      DESCRIPTION:  (SEE 'D' REPORT)
***********************************************************************
*D*      NAME:    RTLOCICB
*,*
*,*      REGISTERS:  R1, R4, R5, R14, R15 ARE VULNERABLE.
*,*
*,*      CALL:    BAL,R0
*,*
*,*      INTERFACE:  RTCNVTXT
*,*
*,*      ENVIRONMENT:  MASTER/MAPPED OR UNMAPPED
*,*
*,*      INPUT:   R6 = INTERRUPT ADDRESS OR TEXT LABEL.
*,*               ICB TABLES
*,*
*,*      OUTPUT:  R2 = ADDRESS OF CORRESPONDING ICB (IF THERE IS ONE)
*,*                    CONDITION CODES 3/4 = 0 (IF THERE ISN'T AN ICB
*,*                                             ASSOCIATED)
*,*
*,*      DESCRIPTION:  WE ARE TRYING TO LOCATE THE ICB THAT IS
*,*               ASSOCIATED WITH THE SPECIFIED INTERRUPT ADDRESS OR
*,*               TEXT LABEL.  IF THE X'8000' BIT OF R6 IS SET THEN
*,*               RTCNVTXT IS CALLED TO CONVERT THE TEXT LABEL TO AN
*,*               INTERRUPT ADDRESS.  NEXT THE ICBINT AND ICBSTAT
*,*               FIELDS OF ALL ICBS ARE SCANNED TO FIND THE ACTIVE ICB
*,*               ASSOCIATED WITH THE SPECIFIED INTERRUPT AND R2 AND
*,*               CONDITION CODES 3/4 ARE SET ACCORDINGLY.
***********************************************************************
*
         CI,R6    X'8000'           IS IT A TEXT LBL?
         BAZ      LOCICB1           NO
         BAL,R15  RTCNVTXT          CONVERT TEXT LBL.TO INT.ADR.(VIA R6)
         BCR,3    *R0               NOT FOUND; RETURN WITH CC3/CC4=0
LOCICB1  LI,R15   NINTS             SET UP LOOP THROUGH ICB'S
         LI,R4    ICBINT(D)
         LI,R5    ICB
LOOP     LW,R2    ICBSTAT(W),R5     ACTIVE BIT SET (BIT 0)?
         BGEZ     LOCNA             NO
         CH,R6    *R5,R4            COMPARE INT. ADR. IN ICB
         BE       LOCATE            YES
LOCNA    AI,R5    ICBSIZE           INCREMENT TO NEXT ICB
         BDR,R15  LOOP
         LI,R2    0                 DIDN'T FIND IT
         B        *R0               ABNORMAL RETURN
LOCATE   LW,R2    R5                SET UP R2=ICB ADR. AND SET CC'S
         B        *R0               RETURN
         PAGE
RTCNVTXT EQU      % **************************************************
*
*F*      NAME:    RTCNVTXT
*,*
*,*      PURPOSE: CONVERT AN INTERRUPT LABEL TO AN INTERRUPT ADDRESS
*,*               AND PROVIDE A DEFAULT EXECUTION PRIORITY.
*,*
*,*      DESCRIPTION:  (SEE 'D' REPORT)
***********************************************************************
*D*      NAME:    RTCNVTXT
*,*
*,*      REGISTERS:  R1 IS VULNERABLE.
*,*
*,*      CALL:    BAL,R15
*,*
*,*      INTERFACE:  NONE
*,*
*,*      ENVIRONMENT:  MASTER/MAPPER OR UNMAPPED.
*,*
*,*      INPUT:   R6 = TEXT LABEL
*,*               INTLB1, INTLB2, INTLB3.
*,*
*,*      OUTPUT:  R6 = INTERRUPT ADDRESS ASSOCIATED WITH TEXT LABEL.
*,*               R14= DEFAULT EXECUTION PRIORITY ASSOCIATED WITH TEXT
*,*                    LABEL DEFINED BY SYSGEN.
*,*               CONDITION CODES 3/4 ARE SET = 0 (IF TEXT LABEL IS
*,*                                                UNKNOWN)
*,*
*,*      DESCRIPTION:  INTLB1 IS SCANNED FOR A MATCH WITH THE TEXT
*,*               LABEL; IF FOUND, INTLB2 AND INTLB3 ARE USED TO
*,*               SUPPLY THE INTERRUPT'S ADDRESS AND DEFAULT EXECUTION
*,*               PRIORITY.
***********************************************************************
*
         OR,R6    YFFFF             SIGN-EXTEND THE TEXT LABEL
         LI,R1    INTLBSIZ-1        SYSGEN-DEFINED  SIZE OF TABLE
CNVL     CH,R6    INTLB1,R1         FIND TEXT LBL. IN TABLE
         BE       CNVOK             FOUND IT
         BDR,R1   CNVL
         LI,R6    0                 DIDN'T FIND IT
         B        *R15              ABNORMAL RETURN WITH R2=0
CNVOK    LH,R6    INTLB2,R1         PICK UP INT. ADR. FROM PARALLEL TABLE
         LB,R14   INTLB3,R1         PICK UP DEFAULT EXEC.PRIO.
         B        *R15              RETURN
         PAGE
RTICBTYP EQU      % **************************************************
*
*F*      NAME:    RTICBTYP
*,*
*,*      PURPOSE: DETERMINE ICB-TYPE.
*,*
*,*      DESCRIPTION:  (SEE 'D' REPORT)
***********************************************************************
*D*      NAME:    RTICBTYP
*,*
*,*      REGISTERS:  NONE
*,*
*,*      CALL:    BAL,R12
*,*
*,*      INTERFACE:  NONE
*,*
*,*      ENVIRONMENT:  MASTER/MAPPED OR UNMAPPED.
*,*
*,*      INPUT:   R2 = ICB ADDRESS
*,*               ASSOCIATED ICB.
*,*
*,*      OUTPUT:  R3 = RIGHT-JUSTIFIED VALUE FROM ICBSTATYP (ICB TYPE)
*,*
*,*      DESCRIPTION:  THE VALUE IN ICBTYP IS EXTRACTED FROM THE ICB
*,*               AND RIGHT-JUSTIFIED IN R3.
***********************************************************************
*
         LW,R3    ICBSTAT(W),R2     PICK UP ICBSTAT WORD
         SLS,R3   STATYPSHFT        RIGHT-JUSTIFY ICBSTATYP
         AND,R3   MASKS+2           MASK IT OFF
         B        *R12              RETURN
         PAGE
RTINTCONTROL  EQU % ******************************************
*
*F*      NAME:    RTINTCONTROL
*,*
*,*      PURPOSE: CHANGE THE STATUS OF THE INTERRUPT ASSOCIATED WITH A
*,*               GIVEN ICB.
*,*
*,*      DESCRIPTION:  (SEE 'D' REPORT)
***********************************************************************
*D*      NAME:    RTINTCONTROL
*,*
*,*      REGISTERS:  R0, R3, R6, R7, R10, R13, R14 ARE VULNERABLE.
*,*
*,*      CALL:    BAL,R15
*,*
*,*      INTERFACE:  RTWD
*,*
*,*      ENVIRONMENT:  MASTER/MAPPED OR UNMAPPED.
*,*
*,*      INPUT:   R2 = ICB ADDRESS
*,*               R6 = 'WD' CODE (FOR CHANGING INTERRUPT'S STATUS)
*,*               ASSOCIATED ICB, MONORG
*,*
*,*      OUTPUT:  ICBSTAT REFLECTS CURRENT STATUS OF INTERRUPT.
*,*               (INTERRUPT'S STATUS IS CHANGED PER REQUEST).
*,*
*,*      DESCRIPTION:  INTERRUPT CONTROL SUBROUTINE -
*,*               ICBSTAT FIELD OF THE ASSOCIATED ICB IS UPDATED
*,*               TO REFLECT THE CURRENT REQUEST'S ACTIVITY.  THEN, IF
*,*               A REAL INTERRUPT, ITS STATUS IS CHANGED VIA A CALL TO
*,*               RTWD.  IF A PSEUDO INTERRUPT, THE CURRENT STATUS
*,*               OF THE INTERRUPT (FROM ICBSTAT) IS CHECKED TO SEE IF
*,*               FURTHER ACTION IS NECESSARY (E.G., A TRIGGER REQUEST
*,*               MUST INSURE THAT THE PSEUDO INTERRUPT IS ARMED AND
*,*               ENABLED FIRST BEFORE XPSD'ING INTO THE ASSOCIATED ICB)
***********************************************************************
*
         EXU      INTCONEXU1,R6     * SET UP *
         EXU      INTCONEXU2,R6     *ICBSTATINT*
INTCON3  LI,R7    ICBINT(D)
         LH,R10   *R2,R7            PICK UP INT. ADR. FROM ICB
         CI,R10   MONORG            IS IT REAL OR PSEUDO?
         BG       INTCON2           MUST BE PSEUDO
         SLS,R6   8                 SHIFT WD-CODE TO POSITION IN WD INSTR.
         LI,R3    X'1000'           SET UP EFFECTIVE ADR. OF WD
         LI,R7    X'0700'           WD-CODE MASK
         STS,R6   R3                SET CODE
         BAL,R0   RTWD              ISSUE WD INSTR.
         CI,R6    X'700'            TRIGGER REQUEST?
         BNE      *R15              NO
         LW,R7    ICBSTAT(W),R2
         CW,R7    STATA             IS INT. ARMED?
         BANZ     *R15              YES, THEN LEAVE 'TRIG' BIT SET
         B        INTCON6           RESET 'TRIG' BIT IN ICBSTAT
*
*
*
INTCONEXU1 EQU    %                 FPT-WD CODE
           B      *R15                 0
           LW,R7  STATAETR             1
           LW,R7  STATAE               2
           LW,R7  STATA                3
           LW,R7  STATE                4
           LW,R7  STATER               5
           B      *R15                 6
           LW,R7  STATRIG              7
*
*
*
INTCONEXU2 EQU    %                 FPT-WD CODE
           NOP                         0
           B      INTCONR              1
           STS,R7 ICBSTAT(W),R2        2
           B      INTCONAD             3
           STS,R7 ICBSTAT(W),R2        4
           B      INTCONR              5
           NOP                         6
           STS,R7 ICBSTAT(W),R2        7
*
INTCONAD STS,R7   ICBSTAT(W),R2     SET 'ARMED BIT IN ICBSTAT
         LW,R7    STATER            ICBSTAT MASK
INTCONR  AND,R7   ICBSTAT(W),R2     RESET  VARIOUS BITS IN ICBSTAT
         STW,R7   ICBSTAT(W),R2
         B        INTCON3           RETURN
*
*                                   SPECIAL PROCESSING FOR PSEUDO INTS.
*
INTCON2  LW,R7    ICBSTAT(W),R2
         CI,R6    7                 IS THE REQUEST 'TRIGGER'?
         BE       INTCON4           YES
         CI,R6    4                 IS THE REQUEST 'ENABLE'?
         BNE      *R15              NO
         CW,R7    STATRIG           IS THERE A TRIGGER PENDING?
         BANZ     INTCON5           YES
         B        *R15              RETURN
INTCON4  CW,R7    STATA            IS THE ICB ARMED?
         BANZ     INTCON5           YES
INTCON6  AND,R7   STATRIGR          RESET ICBSTAT TRIGGER BIT
         STW,R7   ICBSTAT(W),R2
         B        *R15              RETURN
INTCON5  CW,R7    STATE             IS THE ICB ENABLED?
         BAZ      *R15              NO
         LI,R6    ICBPSD1(D)
         XPSD,2   *R2,R6            'TRIGGER' THE PSEUDO INTERRUPT
         B        *R15
         PAGE
RTCHKGUN EQU      % ****************************************************
*
*F*      NAME:    RTCHKGUN
*,*
*,*      PURPOSE: DETERMINE IF ICBGUN CONTAINS A VALID USER # FOR A
*,*               GHOST JOB ASSOCIATED WITH A TYPE-2 ICB.
*,*
*,*      DESCRIPTION:  (SEE 'D' REPORT)
***********************************************************************
*D*      NAME:    RTCHKGUN
*,*
*,*      REGISTERS:  R1, R3, R6, R7 ARE VULNERABLE.
*,*
*,*      CALL:    BAL,R0
*,*
*,*      INTERFACE:  NONE
*,*
*,*      ENVIRONMENT:  MASTER/MAPPED OR UNMAPPED.
*,*
*,*      INPUT:   R2 = ICB ADDRESS
*,*               SB:GJOBUN, S:GJOBTBL, S:GJOBACN
*,*               ASSOCIATED ICB
*,*
*,*      OUTPUT:  R5 = USER # OF GHOST JOB ASSOCIATED WITH THE ICB
*,*                    (IF THE GHOST JOB IS, IN FACT ACTIVE).
*,*                    0 IF NOT ACTIVE AT THE TIME OF THE REQUEST.
*,*
*,*      DESCRIPTION:  VERIFIES THAT ICBGUN CONTAINS A VALID USER # FOR
*,*               AN ACTIVE (OR SLEEPING) GHOST JOB.
*,*               SB:GJOBUN IS SEARCHED TO FIND THE MATCHING USER
*,*               # OF ICBGUN; IF FOUND, S:GJOBTBL AND S:GJOBACN ARE
*,*               VERIFIED AGAINST ICBGJNME AND ICBGJACN; IF EVERYTHING
*,*               MATCHES, THE USER # OF THE ACTIVE (OR SLEEPING) GHOST
*,*               IS PASSED TO THE CALLER.
***********************************************************************
*
         LI,R3    ICBGUN(D)
         LB,R5    *R2,R3            PICK UP GJOB USER #
         LI,R3    MAXG              SET UP LOOP THROUGH GJOB TABLES
LOOP1    CB,R5    SB:GJOBUN,R3      IS THIS THE ONE?
         BE       CHKG2             YES
CHKG1    BDR,R3   LOOP1             NO
         LI,R5    0                 SET UP 'NOT ACTIVE' RETURN
         B        *R0               RETURN
CHKG2    LI,R1    ICBGJNME(D)
         LD,R6    *R2,R1            PICK UP GJOB NAME
         CD,R6    S:GJOBTBL,R3      IS THIS IT?
         BNE      CHKG1             NO
         LI,R1    ICBGJACN(D)
         LD,R6    *R2,R1            PICK UP GJOB ACCOUNT
         CD,R6    S:GJOBACN,R3      IS THIS IT?
         BNE      CHKG1             NO
         B        *R0               RETURN WITH R5=GJOB USER #
         PAGE
RTDCBCHK EQU      % ***************************************************
*
*F*      NAME:    RTDCBCHK
*,*
*,*      PURPOSE: VALIDATE THE DCB PASSED VIA STOPIO/STARTIO/IOEX
*,*               CAL1,5'S.
*,*
*,*      DESCRIPTION:  (SEE 'D' REPORT)
***********************************************************************
*D*      NAME:    RTDCBCHK
*,*
*,*      REGISTERS:  R3 IS VULNERABLE.
*,*
*,*      CALL:    BAL,R5
*,*
*,*      INTERFACE:  NONE
*,*
*,*      ENVIRONMENT:  MASTER/MAPPED
*,*
*,*      INPUT:   R6 = DCB ADDRESS
*,*               ASSOCIATED DCB, DCT1P, J:DCBLL
*,*
*,*      OUTPUT:  CONDITION CODES SET = 0 (IF DCB IS OK FOR AN IOEX CALL)
*,*               R2 = DCT INDEX ASSOCIATED WITH DEVICE DCB
*,*               R6 = DEVICE ADDRESS ASSOCIATED WITH DCB
*,*
*,*      DESCRIPTION:  VERIFIES THAT THE DCB PASSED VIA AN M:STOPIO/
*,*               STARTIO/IOEX REQUEST IS A VALID, OPEN, DEVICE-ASSIGNED
*,*               DCB.
***********************************************************************
*
         LW,R2    R6                PICK UP DCB ADR.
         SLS,R2   -9                CONVERT TO PAGE #
         CLM,R2   J:DCBLL           IS IT A DCB?
         BCS,9    0,R5              NO
         LW,R2    FCD,R6            ASSUME IT'S OK
         CW,R2    BT31TO0+22        IS IT OPEN?
         BAZ      0,R5              NO
         AND,R2   MASKS+4           PICK UP DCBASN
         CI,R2    3                 IS IT DEVICE-TYPE?
         BNE      0,R5              NO
         LW,R2    DEV,R6
         AND,R2   MASKS+8           DCBDEV
         CI,R2    DCTSIZ            VALID DCT INDEX?
         BG       0,R5              NO
         LH,R6    DCT1P,R2          PICK UP DEVICE ADDRESS
         LCI      0
         B        0,R5              RETURN
         PAGE
RTDEVCHK EQU      % ***************************************************
*
*F*      NAME:    RTDEVCHK
*,*
*,*      PURPOSE: VALIDATE THE DEVICE ADDRESS PASSED VIA STOPIO/
*,*               STARTIO/IOEX CAL1,5'S.
*,*
*,*      DESCRIPTION:  (SEE 'D' REPORT)
************************************************************************
*D*      NAME:    RTDEVCHK
*,*
*,*      REGISTERS:  NONE
*,*
*,*      CALL:    BAL,R5
*,*
*,*      INTERFACE:  NONE
*,*
*,*      ENVIRONMENT:  MASTER/MAPPED OR UNMAPPED
*,*
*,*      INPUT:   R6 = DEVICE ADDRESS
*,*               DCT1P, DCT1A
*,*
*,*      OUTPUT:  CONDITION CODES 3/4 SET = 0 (IF DEVICE ADDRESS IS
*,*                                            VALID)
*,*               R2 = DCT INDEX ASSOCIATED WITH DEVICE ADDRESS.
*,*               R6 = DEVICE ADDRESS (UNCHANGED)
*,*
*,*      DESCRIPTION:  THE DEVICE ADDRESS PASSED BY THE CALLER IS
*,*               VERIFIED AGAINST DCT1P/DCT1A.
***********************************************************************
*
         LI,R2    DCTSIZ
NXTDCT   CH,R6    DCT1P,R2          IS THIS THE ONE
         BE       0,R5              YES-RETURN WITH CC3/4 = 0
         CH,R6    DCT1A,R2          NO-TRY ALTERNATE
         BE       0,R5              YES-RETURN WITH CC3/4 = 0
         BDR,R2   NXTDCT            LOOP
         B        0,R5              RETURN WITH CC3 OR CC4 SET
         PAGE
RTVTP    EQU      % ***************************************************
*
*F*      NAME:    RTVTP
*,*
*,*      PURPOSE: CONVERT A GIVEN VIRTUAL ADDRESS TO A PHYSICAL ADDRESS.
*,*
*,*      DESCRIPTION:  (SEE 'D' REPORT)
***********************************************************************
*D*      NAME:    RTVTP
*,*
*,*      REGISTERS:  R4 AND R5 ARE VULNERABLE.
*,*
*,*      CALL:    BAL,R3
*,*
*,*      INTERFACE:  NONE
*,*
*,*      ENVIRONMENT:  MASTER/MAPPED
*,*
*,*      INPUT:   R6 = VIRTUAL ADDRESS
*,*               JX:CMAP
*,*
*,*      OUTPUT:  R6 = PHYSICAL ADDRESS
*,*
*,*      DESCRIPTION:  CONVERTS A GIVEN VIRTUAL ADDRESS TO A PHYSICAL
*,*               ADDRESS BY FILTERING THE ADDRESS THRU JX:CMAP IN
*,*               THE USER'S JIT.
***********************************************************************
*
         LW,R4    R6                USE R4 TO CONVERT TO VIRT PG #
         SLS,R4   -9
         LOAD,R4  JX:CMAP,R4        PICK UP PHYSICAL PG #
         SLS,R4   9                 CONVERT IT TO PG ADDRESS
         LW,R5    X3FFE00           PAGE MASK
         STS,R4   R6                CONVERT R6 TO A PHYSICAL ADR
         CI,R6    X'1FFFF'          IS PHY ADR < 128K?
         B        0,R3              LET CALLER DECIDE
         TITLE    'RT CAL1 SERVICE ENTRY POINTS'
*********************************************************************
*                                   S E C T I O N    III:
*
*                                    CAL1 ENTRY POINTS
*********************************************************************
*
RTALTCP  EQU      % **************************************************
*
*F*      NAME:    RTALTCP
*,*
*,*      PURPOSE: TO CHANNEL ALL CAL1,5 REQUESTS (EXCEPT M:EXU, M:MASTER
*,*               & M:SLAVE) TO THE APPROPRIATE RECEIVER.
*,*
*,*      DESCRIPTION:   ALL CAL1,5'S (EXCEPT AS NOTED ABOVE) ARE PASSED
*,*               HERE VIA CALPROC AND ALTCP FOR DISPATCHING.
***********************************************************************
*D*      NAME:    RTALTCP
*,*
*,*      REGISTERS:   STANDARD CAL1 REGISTER SETUP
*,*
*,*      CALL:    BAL,R11 (FROM ALTCP, IF SYSTEM IS REAL-TIME)
*,*               RETURN IS TO TRAPEXIT
*,*
*,*      INTERFACE:   TRANSFERS TO APPROPRIATE CAL1,5 RECEIVER IN
*,*               EITHER RTROOT (RESIDENT)  OR RTNR (RTOV OVERLAY).
*,*               IF FPT CODE IS ILLEGAL, USER IS ABORTED VIA
*,*               CALBAD (IN ALTCP).
*,*
*,*      ENVIRONMENT:   MAPPED/MASTER;  CAL1,5 RECEIVERS REQUIRE REAL-
*,*               TIME PRIVILEGE LEVEL (X'E0') FOR ALL CAL1,5'S
*,*               EXCEPT M:CLOCK (X'80') AND M:INTSTAT.
*,*
*,*      INPUT:   R6 = WORD 0 OF CAL1,5 FPT
*,*               R7 = POINTER TO WORD 1 OF FPT
*,*               R8 = FPT CODE (BYTE 0 OF WORD 0 OF FPT)
*,*               R11= RETURN ADDRESS (TRAPEXIT)
*,*
*,*      DESCRIPTION:  R8 IS VERIFIED AS BEING A LEGAL FPT CODE FOR A
*,*               CAL1,5 (ABORT CODE OF X'AE' IF ILLEGAL).
*,*               CONTROL IS THEN PASSED TO APPROPRIATE RECEIVER
*,*               IN RTROOT OR RTNR (RTOV OVERLAY) VIA C15TV (TRANS-
*,*               FER VECTOR.
***********************************************************************
*
         CLM,R8   RTCAL15CODES      IS THIS A VALID FPT CODE?
         BCR,9    RTCALOK           YES
***********************************************************************
*E*      ERROR:   AE-00
*,*
*,*      MESSAGE: THE USER ISSUED A CAL WITH UNKNOWN CODES.
*,*
*,*      DESCRIPTION:  THE USER HAS ISSUED A CAL1,5 WITH AN INVALID
*,*               FPT CODE.
*,*
*,*      REGISTERS:  R8 = THE INVALID FPT CODE
***********************************************************************
         LI,R14   RTERR:BADCAL
         B        CALBAD            ERROR EXIT
RTCALOK  LI,R1    C15TV-C15LOW      SET UP TRANSFER VECTOR
         EXU      *R8,R1            GO TO APPROPRIATE ROUTINE OR:
         LI,R2    RTNRRTSEG               LOAD OVERLAY SEGMENT
         B        T:OVERLAY                    *******
*
*
*
C15TV    EQU      %
         LI,R0    RTRESDF#          X'1B' RESDP PAGES CAL
         LI,R0    RTSTOPIO#         X'1C' M:STOPIO
         LI,R0    RTSTARTIO#        X'1D' M:STARTIO
         B        RTIOEX1           X'1E' M:IOEX (SIO)
         B        RTIOEX2           X'1F' M:IOEX (TIO/TDV/HIO)
         LI,R0    RTGJOBCON#        X'20' M:GJOBCON
         LI,R0    RTCONNECT#        X'21' M:CONNECT
         LI,R0    RTDISCON#         X'22' M:DISCONNECT
         B        RTINTCON          X'23' M:INTCON
         B        RTQFI             X'24' M:QFI
         B        RTHOLD            X'25' M:HOLD
         LI,R0    RTCLOCK#          X'26' M:CLOCK
         B        RTINTSTAT         X'27' M:INTSTAT
         PAGE
RTINTCON EQU      % **************************************************
*
*F*      NAME:    RTINTCON
*,*
*,*      PURPOSE: TO PROCESS THE M:INTCON & M:INHIBIT CAL1,5'S
*,*
*,*      DESCRIPTION:   ALLOWS ANY USER WITH REAL-TIME PRIVILEGES TO
*,*               CONTROL THE STATE OF A REAL OR PSEUDO INTERRUPT.
*,*               PERMISSABLE REQUESTS:
*,*                           ARM & ENABLE
*,*                           ARM & DISABLE
*,*                           DISARM
*,*                           ENABLE
*,*                           DISABLE
*,*                           TRIGGER
*,*                           INHIBIT (VIA SOFTWARE)
*,*
*,*      REFERENCE:   CP-V SYSTEMS PROGRAMMER REFERENCE MANUAL
***********************************************************************
*D*      NAME:    RTINTCON
*,*
*,*      REGISTERS:   STANDARD CAL1 REGISTER SETUP
*,*
*,*      CALL:    VIA RTALTCP (NOT CALLABLE EXTERNALLY)
*,*
*,*      INTERFACE:  RTCHKPRIV, RTLOCICB, RTINTCONTROL
*,*
*,*      ENVIRONMENT:   MAPPED/MASTER; PRIVILEGE LEVEL MUST = X'E0'.
*,*               THERE MUST BE A CURRENTLY ACTIVE ICB ASSOCIATED WITH
*,*               THE INTERRUPT TO BE CONTROLLED (IF M:INTCON)
*,*
*,*
*,*      INPUT:   R6 = WORD 0 OF CAL1,5 FPT
*,*               R7 = POINTER TO WORD 1 OF FPT
*,*               R11= RETURN ADDRESS (TRAPEXIT)
*,*               ASSOCIATED ICB
*,*
*,*      OUTPUT:  IF M:INTCON - ICB (ICBSTAT)
*,*               IF M:INHIBIT - UH:FLG
*,*               S:BADFLG
*,*
*,*      DESCRIPTION: IF M:INTCON - THE ICB (ICBSTAT) WILL BE MARKED PER
*,*                                 THE REQUEST AND THE SPECIFIED
*,*                                 INTERRUPT'S STATE WILL BE MODIFIED VIA
*,*                                 A 'WD' INSTRUCTION (IF REAL).
*,*                   IF M:INHIBIT - THE 'REAL-TIME INHIBIT' BIT OF
*,*                                  UH:FLG WILL BE SET/RESET DEPENDING
*,*                                  UPON THE REQUEST.
***********************************************************************
*
         BAL,R0   RTCHKPRIV         JB:PRIV >= X'E0'?
         BCS,8    RTSETCC1          NO
         LW,R6    R6                M:INHIBIT ?
         BEZ      INHIBIT           YES
         BAL,R0   RTLOCICB          RETURNS ICB ADR. IN R2
         BCR,3    RTSETCC2          NOT FOUND; ABNORMAL RETURN
         LW,R6    0,R7              PICK UP       WD-CODE FROM FPT
         AND,R6   MASKS+3           MASK IT
         BAL,R15  RTINTCONTROL      SET UP ICBSTAT; SET INTERRUPT STATE
         B        RTSETCC0          RETURN
*
*
*
INHIBIT  EQU      %                 M:INHIBIT (SOFTWARE INT. INHIBIT)
         LW,R4    S:CUN
         LH,R5    UH:FLG,R4
         LW,R6    0,R7              ON/OFF SPECIFIED ?
         BEZ      INHOFF            OFF
         OR,R5    FLG:INH           SET 'INHIBIT' BIT IN UH:FLG
INHRET   STH,R5   UH:FLG,R4         PUT IT AWAY
         B        RTSETCC0          RETURN TO USER
INHOFF   AND,R5   FLG:INHR          RESET 'INHIBIT' BIT IN UH:FLG
         B        INHRET
         PAGE
RTQFI    EQU      % **************************************************
*
*F*      NAME:    RTQFI
*,*
*,*      PURPOSE: TO PROCESS THE M:QFI CAL1,5
*,*
*,*      DESCRIPTION:  ALLOWS ANY REAL-TIME USER WHO IS CENTRALLY
*,*               CONNECTED TO ONE OR MORE INTERRUPTS TO BE PLACED IN
*,*               THE 'SQFI' STATE TO AWAIT AN INTERRUPT.
*,*
*,*      REFERENCE:  CP-V SYSTEMS PROGRAMMER REFERENCE MANUAL
***********************************************************************
*D*      NAME:    RTQFI
*,*
*,*      REGISTERS:  STANDARD CAL1 REGISTER SETUP
*,*
*,*      CALL:    VIA RTALTCP (NOT CALLABLE EXTERNALLY)
*,*
*,*      INTERFACE:  T:REG, CALBAD (IF NO ICB IS ASSOCIATED WITH THE
*,*               USER), RTICBTYP.
*,*
*,*      ENVIRONMENT:  MAPPED/MASTER; USER MUST BE CENTRALLY CONNECTED
*,*               TO ONE OR MORE INTERRUPTS PRIOR TO CAL1,5.
*,*
*,*      INPUT:   R6 = WORD 0 OF CAL1,5 FPT.
*,*               R7 = POINTER TO WORD 1 OF FPT.
*,*               R11= RETURN ADDRESS (TRAPEXIT)
*,*               ICB TABLES
*,*
*,*      OUTPUT:  UH:FLG
*,*
*,*      DESCRIPTION:  ALL ICBS ARE SCANNED TO INSURE THAT THE
*,*               USER IS CENTRALLY CONNECTED TO AT LEAST ONE INTERRUPT.
*,*               IF NO ACTIVE ICB BELONGING TO THE USER IS FOUND, HE
*,*               IS ABORTED (B8/01); OTHERWISE THE 'INHIBIT' BIT OF
*,*               UH:FLG IS RESET AND THE USER'S UH:DL IS CHECKED TO SEE
*,*               IF ANY INTERRUPT IS PENDING.  IF NONE IS PENDING
*,*               AN E:QFI EVENT IS REPORTED ON THE USER (VIA T:REG),
*,*               OTHERWISE RETURN IS MADE DIRECTLY TO TRAPEXIT TO
*,*               WHERE THE UH:DL ITEM WILL BE SERVICED.
***********************************************************************
*
         LW,R1    S:CUN             SET UP LOOP THROUGH ICB'S
         LI,R2    ICB
         LI,R4    ICBUN(D)
         LI,R5    ICBPRI(D)
         LI,R10   NINTS
LOOP2    LW,R9    ICBSTAT(W),R2     FIND AN ACTIVE ICB BELONGING TO USER
         BGEZ     QFINA             NOT ACTIVE IF BIT 0 IS RESET
         CB,R1    *R2,R4            BELONG TO THIS USER?
         BE       QFI1              YES
QFINA    AI,R2    ICBSIZE           INCREMENT TO NEXT ICB
         BDR,R10  LOOP2             GO LOOK AT NEXT ONE
***********************************************************************
*E*      ERROR:   B8-01
*,*
*,*      MESSAGE: M:QFI WAS ATTEMPTED WHEN NO ICBS WERE ASSOCIATED WITH
*,*               THE USER.
*,*
*,*      DESCRIPTION:  AN M:QFI HAS BEEN ISSUED WHEN NO ICBS WERE
*,*               ASSOCIATED WITH THE USER.
*,*
*,*      REGISTERS:  (NOTHING RELEVANT)
***********************************************************************
         LW,R14   RTERR:QFI         DIDN'T FIND ONE
         B        CALBAD            ABORT USER
QFI1     BAL,R12  RTICBTYP          RETURNS ICBTYP IN R3
         CI,R3    ICBTYP2           IS IT A GJOB ICB?
         BE       QFIOK             NO NEED TO CHECK PRIORITY
         LB,R9    *R2,R5            ICBPRI
         CB,R9    UB:PRIOB,R1       ICBPRI <  UB:PRIOB?
         BG       QFINA             NO - GO CHECK NEXT ONE
QFIOK    LI,R2    0                 SET CONDITION CODE FOR EVENTUAL RET
         LW,R3    YF                CC MASK
         LI,R5    -17
         AW,R5    TSTACK            DEVELOP PSD ADR. IN TSTACK
         AND,R5   X1FFFE            MASK OFF ADR.
         STS,R2   0,R5              USER'S PSD IN TSTACK
         LW,R6    S:CUN
         LH,R5    UH:FLG,R6
         AND,R5   FLG:INHR          RESET 'INHIBIT' BIT IN UH:FLG
         STH,R5   UH:FLG,R6         PUT IT AWAY
         DISABLE                    ***********************************
         LH,R6    UH:DL,R6          ANYTHING TO DO?
         BNEZ     *R11              YES; EXIT TO TRAPEXIT
         LI,R6    E:QFI             'QUEUE FOR INTERRUPT' EVENT
         BAL,R11  T:REG             REPORT EVENT & GIVE UP CONTROL
         B        TRAPEXIT          RETURN FOR INTERRUPT PROCESSING
         PAGE
RTINTSTAT  EQU    % **************************************************
*
*F*      NAME:    RTINTSTAT
*,*
*,*      PURPOSE: TO PROCESS THE M:INTSTAT CAL1,5.
*,*
*,*      DESCRIPTION:  ALLOWS ANY USER IN A REAL-TIME SYSTEM TO QUERY
*,*               THE STATUS OF ANY CENTRALLY CONNECTED REAL OR PSEUDO
*,*               INTERRUPT.  INFORMATION RETURNED TO THE USER:
*,*                                 ARM/ENABLE/TRIGGER STATUS
*,*                                 USER # AND CURRENT STATE OF CENTRAL-
*,*                                      LY CONNECTED USER OF THAT
*,*                                      INTERRUPT
*,*                                 GJOB USER # (IF M:GJOBCON)
*,*
*,*      REFERENCE:  CP-V SYSTEMS PROGRAMMER REFERENCE MANUAL
***********************************************************************
*D*      NAME:    RTINTSTAT
*,*
*,*      ENTRY:   INTSTAT
*,*
*,*      REGISTERS:  IF RTINTSTAT:  STANDARD CAL1 REGISTER SETUP
*,*                  IF INTSTAT:    ALL REGISTERS ARE VULNERABLE.
*,*
*,*      CALL:    IF RTINTSTAT:  VIA RTALTCP (NOT CALLABLE EXTERNALLY)
*,*               IF INTSTAT:    BAL,R11
*,*
*,*      INTERFACE:  RTLOCICB, RTICBTYP, RTCHKGUN
*,*
*,*      ENVIRONMENT:  IF RTINTSTAT:  MAPPED/MASTER.
*,*                    IF INTSTAT:    MAPPED OR UNMAPPED; MASTER.
*,*
*,*      DATA:    WAIT:MASK, EXU:MASK, IOWAIT:MASK, BLCKD:MASK.
*,*
*,*      INPUT:   R6 = INTERRUPT ADDRESS
*,*               R11= RETURN ADDRESS (TRAPEXIT IF RTINTSTAT)
*,*               ASSOCIATED ICB, UB:US
*,*
*,*      OUTPUT:  R8 = STATUS INFORMATION.
*,*
*,*      DESCRIPTION:  RTINTSTAT IS THE CAL1,5 RECEIVER FOR M:INTSTAT.
*,*               INTSTAT IS THE EXTERNALLY CALLABLE ROUTINE WHICH
*,*               GATHERS AND FORMATS INFORMATION ABOUT THE SPECIFIED
*,*               INTERRUPT.  IF AN INTERRUPT IS CENTRALLY CONNECTED
*,*               IT WILL HAVE AN ICB ASSOCIATED WITH IT FROM WHICH
*,*               VARIOUS INFORMATION MAY BE EXTRACTED (E.G., THE
*,*               OWNER'S USER #, THE USER # OF THE GHOST JOB IF
*,*               M:GJOBCON WAS USED TO CONNECT THE INTERRUPT, ITS
*,*               ARM/ENABLE/TRIGGER STATUS).  UB:US IS USED TO
*,*               DETERMINE THE OWNER'S CURRENT STATE.
***********************************************************************
*
         BAL,R11  INTSTAT           MAKE IT CALLABLE EXTERNALLY
         LW,R3    TSTACK
         STW,R8   -7,R3             PUT R8 IN TSTACK FOR RET TO USER
         CI,R9    STATNA            WAS INT. NOT ACTIVE?
         BE       RTSETCC2          ABNORMAL RETURN
         B        RTSETCC0          NORMAL RETURN
*
*
*
INTSTAT  BAL,R0   RTLOCICB          RETURNS ICB ADR. IN R2
         BCS,3    INTSTAT2          FOUND IT
         LI,R8    0                 INITIALIZE R8
         LI,R9    STATNA            'NOT ACTIVE' CODE FOR R8 RETURN
         B        INTSTATX          EXIT
INTSTAT2 LW,R8    ICBSTAT(W),R2     PICK UP ICBSTAT WORD OF ICB
         SLS,R8   STATINTSHFT       RIGHT-JUSTIFY ICBSTATINT
         AND,R8   MASKS+3           MASK IT
         BAL,R12  RTICBTYP          DETERMINE ICB TYPE (RETURNED IN R3)
         CI,R3    ICBTYP2           IS IT TYPE-II (GHOST JOB)?
         BNE      INTSTAT3          NO
         BAL,R0   RTCHKGUN          RETURNS GJOB # IN R5
         LI,R3    2
         STB,R5   R8,R3             PUT IT AWAY
INTSTAT3 LI,R3    ICBUN(D)
         LB,R5    *R2,R3            PICK UP USER #
         LI,R1    1
         STB,R5   R8,R1             PUT IT AWAY
         LB,R5    UB:US,R5          PICK UP USER'S CURRENT STATE
         LI,R9    STATWAIT          INITIALIZE R9 WITH 'QFI' CODE
         LW,R5    X1,R5             PICK UP ONE-BIT MASK CORRESPONDING
*                                   TO USER'S STATE
         CW,R5    WAIT:MASK         IS THE STATE 'WAIT' OR 'QFI'?
         BANZ     INTSTATX          YES
         CW,R5    EXU:MASK          IS THE STATE 'EXECUTABLE'?
         BANZ     INTSTAT4          YES
         CW,R5    IOWAIT:MASK       IS THE STATE 'IO-WAIT'?
         BANZ     INTSTAT5          YES
         CW,R5    BLCKD:MASK        IS THE STATE 'BLOCKED'?
         BANZ     INTSTAT1          YES
***********************************************************************
*S*      SCREECH CODE:  41-01
*,*
*,*      REPORTED BY:  RTROOT
*,*
*,*      MESSAGE: FAILED TO FIND USER'S STATE (M:INTSTAT)
*,*
*,*      TYPE:    SCREECH
*,*
*,*      REGISTERS:  R2 = ADDRESS OF ICB BEING CHECKED
*,*
*,*      REMARKS: PROBABLY RESULTS FROM A STATE HAVING BEEN ADDED TO
*,*               SCHED WITHOUT UPDATING THE FOUR MASKS USED BY THE
*,*               M:INTSTAT ROUTINE (WAIT:MASK, EXU:MASK, IOWAIT:MASK,
*,*               BLCKD:MASK).
***********************************************************************
         SCREECH  X'41',1
INTSTAT1 ;
         LI,R9    STATBLK           'BLOCKED' CODE FOR R8 RETURN
         B        INTSTATX
INTSTAT4 LI,R9    STATEXU           'EXECUTABLE' CODE FOR R8 RETURN
         B        INTSTATX
INTSTAT5 LI,R9    STATIOW           'IO-WAIT' CODE FOR R8 RETURN
INTSTATX STB,R9   R8                PUT CODE AWAY
         B        *R11              RETURN TO CALLER
         PAGE
RTINTRTN EQU      % **************************************************
*
*F*      NAME:    RTINTRTN
*,*
*,*      PURPOSE: TO PROCESS THE M:INTRTN CAL1,5.
*,*
*,*      DESCRIPTION:  THE REAL-TIME USER'S CURRENT INTERRUPT PROCESSING
*,*               ROUTINE IS EXITED, THE INTERRUPT STATUS IS SET PER THE
*,*               USER'S REQUEST, AND CONTROL OF THE USER'S PROGRAM
*,*               IS PASSED TO THE ENVIRONMENT IN THE USER'S TCB STACK
*,*               (THIS WOULD USUALLY BE THE POINT OF INTERRUPTION).
*,*
*,*      REFERENCE:  CP-V SYSTEMS PROGRAMMER REFERENCE MANUAL
***********************************************************************
*D*      NAME:    RTINTRTN
*,*
*,*      REGISTERS:  STANDARD CAL1 REGISTER SETUP
*,*
*,*      CALL:    VIA RTALTCP (NOT CALLABLE EXTERNALLY)
*,*
*,*      INTERFACE:  RTICBTYP, RTINTCONTROL, CALBAD (IF THERE IS NO
*,*               CURRENTLY ACTIVE ICB); EXITS VIA MTRTN0 & T:SSEM.
*,*
*,*      ENVIRONMENT:  MAPPED/MASTER.
*,*
*,*      INPUT:   R4(BITS 22-23) = INTERRUPT CONTROL CODE FROM CAL1,9:
*,*                  WHERE:
*,*                  ---------------------------
*,*                    0     LEAVE
*,*                    1     DISARM
*,*                    2     ARM & ENABLE
*,*                    3     ARM & DISABLE
*,*
*,*               J:ICBHDR, UH:DL
*,*               ASSOCIATED ICB
*,*
*,*      OUTPUT:  UB:PRIO, UB:PRIOB, S:CUP, UH:FLG, RTICBHDR.
*,*
*,*      DESCRIPTION:  THE USER IS EXITING AN INTERRUPT PROCESSING
*,*               ROUTINE.  THE CURRENTLY ACTIVE ROUTINE'S ICB IS
*,*               POINTED TO BY THE ADDRESS IN J:ICBHDR (IF THIS POINTER
*,*               IS ZERO THE USER WILL BE ABORTED - B8/O2).  THE USER'S
*,*               INTERRUPTED ENVIRONMENT IS IN HIS TCB STACK
*,*               (THIS ENVIRONMENT MAY IN FACT HAVE BEEN ALTERED BY
*,*               THE USER PRIOR TO ISSUING THE M:INTRTN).  IN ANY CASE,
*,*               THE PRIORITY SAVED IN THE ICB (ICBPRIO) MUST BE RE-
*,*               STORED TO UB:PRIO/UB:PRIOB/S:CUP AND THE NEXT ICB IN
*,*               THE J:ICBHDR CHAIN (CHAINED THRU ICBDL) MUST BE
*,*               PROMOTED.  NEXT, UH:DL MUST BE SCANNED TO SEE IF
*,*               THERE MIGHT BE A RECENTLY-ARRIVED HIGHER PRIORITY
*,*               INTERRUPT WAITING (HIGHER THAN THE 'JUST RESTORED'
*,*               UB:PRIOB PRIORITY).  IF THERE IS, THEN UB:PRIOB IS
*,*               COMPARED WITH THE PREVIOUSLY SAVED PRIORITY (IN THE
*,*               ICB CHAINED INTO UH:DL) AND THE LOWER PRIORITY
*,*               (HIGHER VALUE) IS SAVED IN THIS HIGH-PRIORITY ICB
*,*               (ICBPRIO), AND UB:PRIO/UB:PRIOB/S:CUP ARE SET TO
*,*               REFLECT THE PRIORITY OF THIS NEW, HIGH-PRIORITY ICB.
*,*               FINALLY, THE CURRENT ICB'S INTERRUPT STATUS IS SET PER
*,*               THE USER'S REQUEST AND, IF A 'ONESHOT' M:CLOCK ICB,
*,*               THE ICB IS RETURNED TO THE FREE POOL OF ICBS
*,*               (RTICBHDR).  EXIT IS THRU MTRTN0 (IN ALTCP) AND
*,*               T:SSEM (IN SCHED).
***********************************************************************
*
         LW,R6    R4                PICK UP CODE BITS
         LI,R5    X'FFFF'
         DISABLE                    ************************************
         LW,R2    J:ICBHDR          HEAD OF ICB'S ASSOCIATED WITH USER'S
*                                   CURRENTLY ACTIVE INTERRUPTS
         AND,R2   R5                MASK OFF ADR. FIELD...DA(ICBDL)
         BEZ      INTRTNERR         THERE ISN'T ONE; ABORT USER
         SLS,R2   1                 CONVERT TO WA(ICBDL)
         AI,R2    -ICBDL(W)         R2=WA(ICB)
         LW,R4    ICBDL(W),R2       FIND NEXT ICB IN ACTIVE CHAIN
         STS,R4   J:ICBHDR          ICBDL  BECOMES HEAD;PRESERVE BIT 0
         LW,R3    S:CUN             GET CURRENT USER NUMBER
         LI,R5    ICBPRIO(D)        DISP TO OLD PRIORITY
         LB,R0    *R2,R5            GET IT FROM ICB
         STB,R0   UB:PRIOB,R3       STORE IT IN BASE PRIO
         STB,R0   UB:PRIO,R3        AND WORKING PRIO
         STW,R0   S:CUP             ANNOUNCE IT
         LW,R12   ICBSTAT(W),R2     PICK UP ICB STATUS
         AND,R12  NB31TO0+30        TURN OFF 'ON-DL' FLAG
         AND,R12  NB31TO0+28        TURN OFF 'TRIGGERED' BIT
         STW,R12  ICBSTAT(W),R2     PUT ICB STATUS BACK
         LH,R12   UH:FLG,R3
         AND,R12  FLG:INHR          RESET 'INHIBIT' BIT IN UH:FLG
         STH,R12  UH:FLG,R3         PUT IT AWAY
         LH,R12   UH:DL,R3          GET DO LIST
INTRTNB  LI,R5    X'FFF'            MASK FOR FLINK
         AND,R5   R12               GET POINTER
         BEZ      INTRTNA           NONE
         SLS,R5   1                 WORD ADDRESS
         LW,R12   0,R5              FLINK ON
         LH,R0    R12               GET TYPE
         AND,R0   MASKS+7           SCRUB
         CI,R0    2                 TEST FOR INTENTRY
         BNE      INTRTNB           NO
         LB,R0    R12               GET DO LIST PRIO
         CB,R0    UB:PRIOB,R3       COMPARE WITH CURRENT
         BG       INTRTNA           LESS, IGNORE IT
         AI,R5    -ICBPRI(W)        GET BASE OF DO LIST
         LI,R1    ICBPRIO(D)        DISP TO ICB OLD PRIO
         LB,R13   UB:PRIOB,R3       GET USERS CURRENT PRIO
         CB,R13   *R5,R1            CHECK FOR PREVIOUS SAVED PRIORITY
         BL       %+2               REMEMBER LOWEST PRIORITY(HIGHEST NUMBER)
         STB,R13  *R5,R1            SAVE IN TOP ICB
         STB,R0   UB:PRIO,R3        SET AS CURRENT
         STB,R0   UB:PRIOB,R3       FOR USER
         STW,R0   S:CUP             AND ANNOUNCE IT TO WORLD
INTRTNA  BAL,R12  RTICBTYP          RETURNS ICB-TYPE IN R3
         CI,R3    ICBTYP3           IS IT A CLOCK-TYPE ICB?
         BNE      INTRTN1           NO
         LW,R4    ICBSTAT(W),R2
         AND,R4   STATO             'ONESHOT' BIT IN ICBSTAT SET?
         BEZ      INTRTNX           NO;
         LW,R5    RTICBHDR          HEAD OF FREE ICB'S
         STW,R5   ICBLNK(W),R2      INITIALIZE ICBSTAT & ICBLNK
         STW,R2   RTICBHDR          FREED ICB BECOMES NEW HEAD OF CHAIN
         B        INTRTNX
INTRTN1  SLS,R6   C19CS             RIGHT-JUSTIFY WD-CODE FROM CAL1
         AND,R6   MASKS+2           MASK OFF LEGAL CODES
         CI,R6    1                 IS THE REQUEST 'DISARM'?
         BNE      INTRTN2           NO
         LI,R6    3                 ARM & DISABLE THE INT. FIRST
         BAL,R15  RTINTCONTROL      CLEAR INTERRUPT
         LI,R6    1                 NOW WE CAN DISARM IT
INTRTN2  BAL,R15  RTINTCONTROL      SET ICBSTAT;
INTRTNX  ENABLE                     ***********************************
         LI,R6    T:SSEM            SET UP RETURN ADR FOR MTRTN0
         B        MTRTN0            M:TRTN PROCESSING IN ALTCP
***********************************************************************
*E*      ERROR:   B8-02
*,*
*,*      MESSAGE: M:INTRTN WAS ATTEMPTED AND THERE WERE NO ACTIVE
*,*               INTERRUPTS ASSOCIATED WITH THE USER.
*,*
*,*      DESCRIPTION:  AN M:INTRTN HAS BEEN ISSUED AND THERE WERE NO
*,*               ACTIVE INTERRUPTS ASSOCIATED WITH THE USER (IE.,
*,*               J:ICBHDR CHAIN WAS EMPTY).
*,*
*,*      REGISTERS:  (NOTHING RELEVANT)
***********************************************************************
INTRTNERR  LW,R14 RTERR:INTRTN      ERROR CODE
         B        CALBAD            RETURN TO ALTCP TO ABORT USER
         PAGE
RTHOLD   EQU      % **************************************************
*
*F*      NAME:    RTHOLD
*,*
*,*      PURPOSE: TO PROCESS THE M:HOLD CAL1,5.
*,*
*,*      DESCRIPTION:   ALLOWS ANY USER WITH REAL-TIME PRIVILEGES TO
*,*               UNCONDITIONALLY LOCK HIMSELF IN CORE.
*,*
*,*      REFERENCE:   CP-V SYSTEMS PROGRAMMER REFERENCE MANUAL.
*,*********************************************************************
*D*      NAME:    RTHOLD
*,*
*,*      REGISTERS:   STANDARD CAL1 REGISTER SETUP.
*,*
*,*      CALL:    VIA RTALTCP (NOT CALLABLE EXTERNALLY)
*,*
*,*      INTERFACE:  RTCHKPRIV, RTLCT, RTSIZE, T:TOTSZ
*,*
*,*      ENVIRONMENT:   MAPPED/MASTER; PRIVILEGE LEVEL MUST = X'E0'.
*,*
*,*      INPUT:   R6 = WORD 0 OF CAL1,5 FPT.
*,*               R7 = POINTER TO WORD 1 OF FPT.
*,*               R11= RETURN ADDRESS (TRAPEXIT)
*,*
*,*      OUTPUT:  UH:FLG2, PB:LCT, S:RTCORE, J:ICBHDR, S:BADFLG.
*,*
*,*      DESCRIPTION:
*,*               IF HOLD(ON) - THE USER IS SIZED (VIA T:TOTSZ), THE
*,*                             RTHOLD-BIT OF UH:FLG2 IS SET, PB:LCT IS
*,*                             INCREMENTED FOR ALL SHARED PROCEDURE
*,*                             CURRENTLY ASSOCIATED WITH THE USER, AND
*,*                             S:RTCORE IS INCREMENTED BY THE NUMBER OF
*,*                             PAGES THAT THIS USER IS CAUSING TO BE
*,*                             LOCKED.  CONDITION CODES ARE PASSED BACK
*,*                             TO THE USER TO REFLECT WHETHER OR NOT
*,*                             ALLYCAT &/OR RBBAT WILL STILL FIT IN THE
*,*                             REMAINING FLUID CORE.  J:ICBHDR IS SET
*,*                             TO INDICATE WHETHER OR NOT TO PURGE THE
*,*                             USER'S DATA/PROCEDURE PAGES SHOULD HE
*,*                             EXIT WITHOUT UN:LOCKING.
*,*               IF HOLD(OFF)- UN-DUZ ALL OF THE ABOVE.
***********************************************************************
*
         BAL,R0   RTCHKPRIV         JB:PRIV >= X'E0'?
         BCS,8    RTSETCC1          NO
         LW,R4    S:CUN             USER #
         DISABLE                    ***********************************
         LH,R7    UH:FLG2,R4
         CI,R6    FPTF1             'OFF' SPECIFIED?
         BAZ      HOLDON            NO
         CW,R7    FLG:LIC           'LOCKED-IN-CORE' BIT SET?
         BAZ      RTSETCC0          NO
         AND,R7   FLG:LICR          UH:FLG2 MASK: LIC BIT RESET
         STH,R7   UH:FLG2,R4        RESET UH:FLG2 BITS
         LI,R5    1                 SET 'DECREMENT' FLAG
         BAL,R7   RTLCT             DECREMENT PB:LCT
         BAL,R7   T:TOTSZ           RETURNS USER'S 'UNLOCKABLE' SIZE(R0)
         LCW,R0   R0
         AWM,R0   S:RTCORE          DECREMENT COUNTER
         B        RTSETCC0          RETURN TO USER
*
*
*
HOLDON   EQU      %
         SLS,R6   28                SHIFT 'PURGE' BIT
         LW,R8    R6                MOVE IT TO R8
         LW,R9    BT31TO0+30        MASK
         STS,R8   J:ICBHDR          SET/RESET FLAG
         CW,R7    FLG:LIC           'LOCKED-IN-CORE' BIT SET?
         BANZ     HOLD2             YES
         OR,R7    FLG:LIC           UH:FLG2 MASK: LIC BIT SET
         STH,R7   UH:FLG2,R4        TURN ON 'LOCKED IN CORE' BIT
         LW,R3    BT31TO0+32
         STS,R3   J:ICBHDR          SET RT-CAL1-ISSUED BIT
         LW,R3    BT31TO0+31
         STS,R3   S:BADFLG          SET 'RT-LOCK-CORE' BIT
         BAL,R7   T:TOTSZ           RETURNS USER'S 'LOCKABLE' SIZE(R0)
         LI,R5    0                 SET 'INCREMENT' FLAG
         BAL,R7   RTLCT             INCREMENT PB:LCT
         AWM,R0   S:RTCORE          REFLECT USER'S 'LOCKABLE' SIZE
HOLD2    ENABLE                     ********************************
         LI,R4    ALLOCAT:UN        ALLY'S USER #
         BAL,R6   RTSIZE            SIZE HIM
         BCS,1    RTSETCC2          IF HE WON'T FIT
         LI,R4    RBBAT:UN          RBBAT'S USER #
         BAL,R6   RTSIZE            SIZE HIM
         BCS,1    RTSETCC2          IF HE WON'T FIT
         B        RTSETCC0          RETURN TO USER
         PAGE
RTLCT    EQU      % ***************************************************
*
*F*      NAME:    RTLCT
*,*
*,*      PURPOSE: TO PROVIDE A SUBROUTINE FOR RTROOT AND RTNR FOR KEEP-
*,*               ING TRACK OF COMMON SHARED PROCEDURE THAT IS LOCKED-IN
*,*               -CORE BY ALL REAL-TIME USERS.
*,*
*,*      DESCRIPTION:   INCREMENTS OR DECREMENTS PB:LCT FOR EVERY PIECE
*,*               OF SHARED PROCEDURE ASSOCIATED WITH THE USER.
***********************************************************************
*D*      NAME:    RTLCT
*,*
*,*      REGISTERS:   R1 AND R15 ARE VULNERABLE.
*,*
*,*      CALL:    BAL,R7
*,*
*,*      INTERFACE:  NONE.
*,*
*,*      ENVIRONMENT:   MASTER MODE; MAPPED/UNMAPPED.
*,*
*,*      INPUT:   R4 = USER #
*,*               R5 = 0 (IF PB:LCT IS TO BE INCREMENTED)
*,*                    1 (IF PB:LCT IS TO BE DECREMENTED)
*,*               UH:FLG, UB:APR, UB:APO, UB:ASP, UB:OV, UB:ACP, UB:DB.
*,*
*,*      OUTPUT:  PB:LCT (MODIFIED PER REQUEST).
*,*
*,*      DESCRIPTION:   PB:LCT IS INCREMENTED OR DECREMENTED FOR EVERY
*,*               PIECE OF SHARED PROCEDURE ASSOCIATED WITH THE USER.
*,*               THIS IS NECESSARY IN ORDER TO KEEP FROM MULTIPLY-
*,*               ACCOUNTING FOR SHARED PROCEDURE ASSOCIATED WITH USERS
*,*               WHO ISSUE M:HOLD CAL1S.
***********************************************************************
*
         LH,R15   UH:FLG,R4
         CI,R15   TIC               TEL IN CONTROL?
         BANZ     LCT1              YES
         CI,R15   DIC               DELTA IN CONTROL?
         BANZ     LCT2              YES
         LB,R1    UB:APR,R4
         EXU      MTBINST,R5        ACCOUNT FOR SHRD PROC ROOT
         LB,R1    UB:APO,R4
         EXU      MTBINST,R5        ACCOUNT FOR SHRD PROC OVERLY
         LB,R1    UB:ASP,R4         ANY SPECIAL SHRD PROCESSOR?
         BEZ      LCT2              NO...GO ACCOUNT FOR DELTA(MAYBE)
LCT3     EXU      MTBINST,R5        ACCOUNT FOR IT
         LB,R1    UB:OV,R4
         EXU      MTBINST,5         ACCOUNT FOR SHRD MON OVERLY
         B        0,R7              RETURN
LCT1     LB,R1    UB:ACP,R4         COMMAND PROCESSOR
         B        LCT3
LCT2     LB,R1    UB:DB,R4          DEBUGGER
         B        LCT3
*
*
MTBINST  MTB,1    PB:LCT,R1         COUNT IT UP
         MTB,-1   PB:LCT,R1         COUNT IT DOWN
         PAGE
RTSIZE   EQU      % ***************************************************
*
*F*      NAME:    RTSIZE
*,*
*,*      PURPOSE: TO PROVIDE A SUBROUTINE FOR CHECKING IF A USER WILL
*,*               FIT IN 'UNLOCKED' CORE.
*,*
*,*      DESCRIPTION:  THE TOTAL AVAILABLE 'UNLOCKED' CORE SIZE IS
*,*               COMPARED WITH THE USER'S CURRENT SIZE AND CONDITION
*,*               CODES ARE SET TO REFLECT WHETHER HE WILL FIT.
***********************************************************************
*D*      NAME:    RTSIZE
*,*
*,*      REGISTERS:   R15 THRU R7 ARE VULNERABLE.
*,*
*,*      CALL:    BAL,R6
*,*
*,*      INTERFACE:   T:TOTSZ
*,*
*,*      ENVIRONMENT:   MASTER MODE; MAPPED/UNMAPPED.
*,*
*,*      INPUT:   R4 = USER # OF USER TO BE SIZED.
*,*               S:ACORE, S:RTCORE, S:STL#, SL:RSVP.
*,*
*,*      OUTPUT:  CONDITION CODE 4 = 0 (IF THE USER FITS).
*,*                                  1 (IF HE DOESN'T).
*,*
*,*      DESCRIPTION:  T:TOTSZ IS CALLED TO SIZE UP THE USER; THEN HIS
*,*               SIZE IS COMPARED AGAINST:
*,*               S:ACORE - S:RTCORE + (S:STL# - SL:RSVP)
*,*                                     -------|--------
*,*                                            |
*,*                                            > IF POSITIVE
***********************************************************************
*
         BAL,R7   T:TOTSZ           RETURNS USER'S SIZE IN R0
         LW,R2    S:ACORE
         SW,R2    S:RTCORE          YIELDS 'UNLOCKED' AVAILABLE CORE
         SW,R2    R0                AVAILABLE CORE-USER SIZE
         LW,R1    S:STL#
         SW,R1    SL:RSVP           ARE THERE ANY STOLEN PAGES AROUND?
         BLEZ     RTS1              NO
         AW,R2    R1                YES...ADD THEM IN
RTS1     LW,R2    R2                SET CC'S
         B        0,R6              RETURN
         PAGE
RTIOEX1  EQU      % ***************************************************
*
*F*      NAME:    RTIOEX1
*,*
*,*      PURPOSE: TO PROCESS THE M:IOEX(SIO) CAL1,5.
*,*
*,*      DESCRIPTION:  PROVIDES A CAL1 INTERFACE TO QUEUE AN I/O REQUEST
*,*               FOR A PRE-EMPTED DEVICE FROM A REAL-TIME USER.
*,*
*,*      REFERENCE:  CP-V SYSTEMS PROGRAMMER REFERENCE MANUAL.
***********************************************************************
*D*      NAME:    RTIOEX1
*,*
*,*      REGISTERS:  STANDARD CAL1 REGISTER SETUP.
*,*
*,*      CALL:    VIA RTALTCP (NOT CALLABLE EXTERNALLY).
*,*
*,*      INTERFACE:  CHKBIT1, CHKBIT, NEWQNW, CALBAD, RTCHKPRIV,
*,*               RTDEVCHK, RTDCBCHK, RTVTP.
*,*
*,*      ENVIRONMENT:  MAPPED/MASTER; PRIVILEGE LEVEL MUST = X'E0'.
*,*
*,*      INPUT:   R6 = WORD 0 OF CAL1,5 FPT.
*,*               R7 = POINTER TO WORD 1 OF FPT.
*,*               R11= RETURN ADDRESS (TRAPEXIT).
*,*               DCT3, DCT12, DCT15, UB:PRIO.
*,*
*,*      OUTPUT:  J:ICBHDR, DCT15.
*,*
*,*      DESCRIPTION:  THE FOLLOWING SECURITY CHECKS ARE MADE:  USER'S
*,*               PRIVILEGE LEVEL MUST = X'EO'; 'CLIST' MUST HAVE BEEN
*,*               SPECIFIED; DCB/DEVICE VALIDATION; THE DEVICE MUST BE
*,*               PRE-EMPTED BY THIS USER; AND AN END-ACTION ADDRESS
*,*               MUST HAVE BEEN PROVIDED (THIS ADDRESS MUST BE IN THE
*,*               FIRST 128K OF MEMORY IF RUNNING ON A XEROX 560).
*,*               THE FPT PARAMETERS ARE THEN FORMATTED FOR A CALL TO
*,*               NEWQNW TO QUEUE THE I/O REQUEST.
***********************************************************************
*
         BAL,R0   RTCHKPRIV         JB:PRIV >= X'E0'
         BCS,8    RTSETCC1          NO; ABNORMAL RETURN
         LW,R14   0,R7              FPT(WORD 1)
         BLZ      EX12              IF PRESENCE BIT IS OK
***********************************************************************
*E*      ERROR:   B8-05
*,*
*,*      MESSAGE: A REAL-TIME USER PROVIDED AN FPT THAT IS ILLEGAL
*,*               BECAUSE IT IS MISSING A REQUIRED PARAMETER.
*,*
*,*      DESCRIPTION:  'CLIST' WAS NOT SPECIFIED IN AN M:IOEX (SIO) FPT.
*,*
*,*      REGISTERS:  R14 = FPT PRESENCE BITS (WORD 1)
***********************************************************************
         LW,R14   RTERR:PARAM       'CLIST' IS MISSING
         B        CALBAD            ABORT USER
EX12     LI,R5    EX11              SET POSSIBLE RETURN FROM RTDEVCHK
         CI,R14   FPTDCB            'DEV' OR 'DCB' SPECIFIED?
         BAZ      RTDEVCHK          'DEV'- RETURNS VIA R5 WITH DCTX(R2)
         BAL,R5   RTDCBCHK          VALIDATE DCB-RETURNS DCTX IN R2
         BCS,15   RTSETCC3          BAD DCB; ABNORMAL RETURN
EX11     BCS,3    RTSETCC3          BAD DEVICE ADR; ABN RETURN
         LB,R5    DCT3,R2
         CI,R5    DOWND             IS DEVICE PRE-EMPTED?
         BAZ      RTSETCC1          NO
         LB,R5    DCT15,R2          DOES DEVICE BELONG TO THIS USER?
         BEZ      EX18              IF NO USER IS ASSOCIATED WITH DEVICE
         CW,R5    S:CUN
         BNE      RTSETCC1          NO
EX14     PUSH     R2                SAVE DCTX
         BAL,R2   CHKBIT1           RETURNS 'CLIST' ADR IN R12
         LW,R6    R12               CLIST ADR
         BAL,R3   RTVTP             RETURNS PHYSICAL ADR IN R6
         SLS,R6   -1                CONVET TO DA(CLIST)
         STW,R6   R13               SET UP FOR NEWQ
         OR,R13   BT31TO0+31        SET 'C' BIT OF IOQ8
         BAL,R2   CHKBIT            'EA' SPECIFIED?
         B        EX15              YES
         LW,R2    *TSTACK           NO...GET DCTX
         LW,R12   DCT12,R2          WAS 'EA' ADDRESS SPECIFIED AT
         AND,R12  MASKS+22          TIME OF STOPIO REQUEST?
         BNEZ     EX17              YES...CONTINUE
EXIT     PULL     R2                NO....RESTORE STACK
         B        RTSETCC2          ABNORMAL RETURN
EX15     LW,R6    R12
         BAL,R3   RTVTP             RETURNS PHYSICAL ADR IN R6
         BLE      EX19              PHY ADR < 128K
         BIF,X560 EXIT              CAN'T ALLOW EXECUTION ADR > 128K
EX19     LW,R2    *TSTACK           GET     DCTX
         PUSH     R7                SAVE CHKBIT REGISTER
         LW,R7    MASKS+22          MASK FOR STS
         STS,R6   DCT12,R2          SAVE 'EA' ADR; PRESERVE BIT 0
         PULL     R7
EX17     BAL,R2   CHKBIT            WAS 'TO' SPECIFIED
         B        EX16              YES
         LI,R12   0                 NO, DEFAULT IS ZERO
EX16     PUSH     R12               SAVE 'TO' VALUE
         LI,R0    0                 NO END-ACTION FROM REQCOM
         BAL,R2   CHKBIT            RETURNS 'PRI' IN R12
         B        EX1A              IF 'PRI' WAS SPECIFIED
         LW,R5    S:CUN
         LB,R5    UB:PRIO,R5        CURRENT EXECUTION PRIORITY
EX1B     SLS,R14  25                R14 HAS BEEN SET UP BY CHKBIT
         OR,R13   R14               SET 'REL' BIT IF SPECIFIED IN FPT
         PULL     R14               GET 'TO' VALUE FROM STACK
         PULL     R12               RESTORE DCTX TO R12 FROM STACK
         STH,R5   R12               SET UP FOR NEWQ
         LI,R15   0                 SET UP FOR NEWQ
         BAL,R11  NEWQNW            ***********************************
         B        EXSC              BAD RETURN FROM NEWQ
         LW,R3    YC                SET 'RT-ACTIVITY' BIT &
         STS,R3   J:ICBHDR              'IOEX-ACTIVITY' BIT IN JIT
         B        RTSETCC0          RETURN TO USER
***********************************************************************
*S*      SCREECH CODE:  41-10
*,*
*,*      REPORTED BY:  RTROOT
*,*
*,*      MESSAGE: BAD IOEX CALL TO NEWQ
*,*
*,*      TYPE:    SCREECH
*,*
*,*      REGISTERS:  SET-UP FOR BAL,11 NEWQNW
*,*
*,*      REMARKS: NEWQNW RETURNED TO BAL+1.
***********************************************************************
EXSC     SCREECH  X'41',X'10'
EX18     ;                          SYSCON WAS USED TO PRE-EMPT DEVICE
         STW,R5   DCT12,R2          ZERO DCT12
         CW,R14   FPTEA             WAS 'EA' SPECIFIED?
         BAZ      RTSETCC2          NO; ABNORMAL RETURN
         LW,R5    S:CUN
         STB,R5   DCT15,R2          SINCE SYSCON DOESN'T SET DCT15
         B        EX14              CONTINUE
*
EX1A     LW,R5    R12               MOVE PRI TO R5
         B        EX1B              CONTINUE
         PAGE
RTIOEX2  EQU      % ***************************************************
*
*F*      NAME:    RTIOEX2
*,*
*,*      PURPOSE: TO PROCESS THE M:IOEX(TIO/TDV/HIO) CAL1,5.
*,*
*,*      DESCRIPTION:  PROVIDES A CAL1 INTERFACE TO ISSUE AN I/O
*,*               INSTRUCTION (TIO/TDV/HIO) TO A PRE-EMPTED DEVICE FOR
*,*               A REAL-TIME USER.
*,*
*,*      REFERENCE:  CP-V SYSTEMS PROGRAMMER REFERENCE MANUAL.
***********************************************************************
*D*      NAME:    RTIOEX2
*,*
*,*      REGISTERS:  STANDARD CAL1 REGISTER SETUP.
*,*
*,*      CALL:    VIA RTALTCP (NOT CALLABLE EXTERNALLY).
*,*
*,*      INTERFACE:  INTSIM AND DRIVEIO (IN IOQ) ARE CALLED (ON AN HIO
*,*               REQUEST); CALBAD (ON AN ABNORMAL CONDITION);
*,*               RTCHKPRIV, RTDEVCHK, RTDCBCHK, ENBSR4.
*,*
*,*      ENVIRONMENT:  MAPPED/MASTER; PRIVILEGE LEVEL MUST = X'E0'.
*,*
*,*      INPUT:   R6 = WORD 0 OF CAL1,5 FPT.
*,*               R7 = POINTER TO WORD 1 OF FPT.
*,*               R11= RETURN ADDRESS (TRAPEXIT).
*,*               DCT3, DCT12, DCT15.
*,*
*,*      OUTPUT:  J:ICBHDR, DCT12.
*,*
*,*      DESCRIPTION:  THE FOLLOWING SECURITY CHECKS ARE MADE:  USER'S
*,*               PRIVILEGE LEVEL MUST = X'E0'; DCB/DEVICE VALIDATION;
*,*               AND THE DEVICE MUST HAVE BEEN PRE-EMPTED BY THIS USER.
*,*               (SINCE THE CONDITION CODES RETURNED TO THE USER
*,*               (VIA THE STACK) ARE THOSE OF THE EXECUTED INSTRUCTION,
*,*               ABNORMAL CONDITIONS ARE REPORTED TO THE USER VIA
*,*               PROGRAM ABORTS).
*,*               NEXT THE SPECIFIED INSTRUCTION IS EXECUTED, THE STATUS
*,*               REGISTERS AND CONDITION CODES ARE PASSED TO THE USER
*,*               VIA THE STACK, AND, IF HIO, THE DEVICE IS CHECKED AND
*,*               IF BUSY, INTSIM AND DRIVEIO ARE CALLED (IN IOQ) TO
*,*               'UN-BUSY' THE DEVICE AND CLEANUP THE OPERATION.
***********************************************************************
*
         BAL,R0   RTCHKPRIV         JB:PRIV >= X'E0'
         BCR,8    EX21              YES
***********************************************************************
*E*      ERROR:   B9-01
*,*
*,*      MESSAGE: USER HAS INSUFFICIENT PRIVILEGE TO ISSUE THIS CAL1,5.
*,*
*,*      DESCRIPTION:  THE USER HAS INSUFFICIENT PRIVILEGE TO ISSUE
*,*               AN M:IOEX (TIO/TDV/HIO); X'E0' REQUIRED.
*,*
*,*      REGISTERS:  (NOTHING RELEVANT)
***********************************************************************
         LW,R14   RTERR:IOEX1       NO; ABORT USER
         B        CALBAD
EX21     LI,R5    EX22              SET UP POSSIBLE RETURN FROM RTDEVCHK
         LW,R4    0,R7              FPT(WORD 1)
         CI,R4    FPTDCB            'DEV' OR 'DCB' SPECIFIED?
         BAZ      RTDEVCHK          'DEV'; RETURNS VIA R5 WITH DCTX(R2)
         BAL,R5   RTDCBCHK          'DCB'-RET: DCTX(R2); DEV.ADR(R6)
         BCR,15   EX24              OK
***********************************************************************
*E*      ERROR:   B9-02
*,*
*,*      MESSAGE: THE DEVICE SPECIFIED VIA M:IOEX DOESN'T EXIST OR IS
*,*               NOT PRE-EMPTED, OR THE SPECIFIED DCB IS NOT OPENED
*,*               PROPERLY.
*,*
*,*      DESCRIPTION:  THE SPECIFIED DEVICE DOESN'T EXIST OR IS NOT
*,*               PRE-EMPTED, OR THE SPECIFIED DCB IS NOT OPENED
*,*               PROPERLY.
*,*
*,*      REGISTERS:  R6 = DEVICE OR DCB ADDRESS.
***********************************************************************
EX23     LW,R14   RTERR:IOEX2       NO; ABORT USER
         B        CALBAD
EX22     BCS,3    EX23              RETURN HERE FROM RTDEVCHK
EX24     LB,R5    DCT3,R2
         CI,R5    DOWND             IS DEVICE PRE-EMPTED?
         BAZ      EX23              NO; ABORT USER
         LW,R5    S:CUN
         CB,R5    DCT15,R2          DOES IT BELONG TO THIS USER?
         BNE      EX23              NO; ABORT
         AND,R4   MASKS+2           MASK OFF CODE
         EXU      IOINST,R4         EXECUTE INSTRUCTION
EX25     EQU      %
         STCF     R2                SAVE CONDITION CODES
         LW,R5    TSTACK
         STW,R8   -7,R5             SAVE R8 IN USER'S R8 IN STACK
         STW,R9   -6,R5             SAVE R9 IN USER'S R9 IN STACK
         AI,R5    -17               POINT TO PSD IN STACK
         AND,R5   X1FFFE            INSURE DBL-WD BOUND
         LW,R3    YF                CC MASK
         STS,R2   0,R5              PUT CC'S IN USER'S PSD
         LW,R3    YC                SET 'RT-ACTIVITY' BIT &
         STS,R3   J:ICBHDR              'IOEX-ACTIVITY' BIT IN JIT
         B        *R11              RETURN
*
*
*
IOINST   EQU      % ***************************************************
         TIO,R8   *R6
         TDV,R8   *R6
         B        EXHIO             HIO LOGIC REQUIRES IOQ MANIPULATION
*
*
*
EXHIO    EQU      %
         DISABLE                    *********************************
         HIO,R8   *R6
         BAL,R11  EX25              SAVE STATUS
         LI,R11   TRAPEXIT          SET RETURN ADR
         LB,R4    DCT15,R2          PRE-EMPTED DEVICE?
         BEZ      ENBSR4            NO, EXIT CAL1 PROCESSING
         LW,R4    DCT12,R2          INTERRUPT PENDING?
         BGEZ     ENBSR4            NO, EXIT CAL1 PROCESSING
         AND,R4   NB31TO0+32        YES...RESET 'INT PEND' FLAG
         STW,R4   DCT12,R2          PUT IT AWAY
         BAL,R1   TQUNMAP           GO UNMAPPED...REMAIN INHIBITED
         LW,R1    R2                SET UP R1(DCTX) FOR INTSIM(IOQ)
         LI,R5    HIORET            SET RETURN FROM INTSIM
         OR,R5    BT31TO0+32        SET FLAG IN LINK REGISTER
         B        INTSIM            SETS 'CLEANUP PENDING'
HIORET   BAL,R2   DRIVEIO           DO CLEANUP; RETURNS ENABLED
         BAL,R1   MAP               GO MAPPED FOR RETURN TO USER
         B        TRAPEXIT          EXIT
         TITLE    'I O Q      S U B R O U T I N E S'
RTIOSTRT EQU      % ***************************************************
*
*F*      NAME:    RTIOSTRT
*,*
*,*      PURPOSE: PROVIDES AN EXTENSION OF IOQ FOR IOEX REQUESTS FOLLOW-
*,*               ING A SUCCESSFUL 'SIO'.
*,*
*,*      DESCRIPTION:  PERFORMS THE SPECIAL PROCESSING REQUIRED OF IOQ
*,*               FOLLOWING A SUCCESSFUL 'SIO' IN ORDER TO MAKE THE
*,*               DEVICE LOOK 'NOT BUSY' TO THE 'REGULAR' I/O SYSTEM.
*,*********************************************************************
*D*      NAME:    RTIOSTRT
*,*
*,*      REGISTERS:  R0 AND R15 ARE VULNERABLE.
*,*
*,*      CALL:    BAL,R7 (FROM IOSTRT IN IOQ)
*,*
*,*      INTERFACE:  NONE
*,*
*,*      ENVIRONMENT:  MASTER/UNMAPPED.
*,*
*,*      INPUT:   R1 = DCT INDEX
*,*               R3 = IOQ INDEX
*,*               R9 = FUTURE CONTENTS OF DCT5
*,*               IOQ8 (HAS CHANNEL STATUS FLAG FROM IOEX REQUEST)
*,*
*,*      OUTPUT:  R4 = HANDLER FLAGS
*,*               R9 = DCT5
*,*               DCT12, DCT13
*,*
*,*      DESCRIPTION:  THE SIO STATUS REGISTERS ARE STORED INTO DCT13;
*,*               THE HIGH-ORDER BIT OF DCT12 IS SET (INDICATING THAT A
*,*               R/T I/O INTERRUPT IS EXPECTED); THE HIGH-ORDER BIT
*,*               OF R4 IS SET IF THE USER HAS REQUESTED THAT THE
*,*               CHANNEL BE FREED IMMEDIATELY; AND FINALLY, R9 IS SET-
*,*               UP SO THE DEVICE WILL APPEAR TO BE 'NOT BUSY' AFTER
*,*               IOSTRT3 (IN IOQ) MODIFIES R9 PRIOR TO STORING IT AWAY
*,*               IN DCT5.
***********************************************************************
*
         STD,R12  DCT13,R1          SAVE SIO REGISTERS
         LW,R0    DCT12,R1
         OR,R0    BT31TO0+32        SET 'INTERRUPT PENDING' BIT
         STW,R0   DCT12,R1          PUT IT AWAY
         INT,R15  IOQ8,R3           'REL' SPECIFIED ON CALL
         BCR,2    IOS1              NO
         OR,R4    BT31TO0+32        SET SUBCHANNEL-RELEASE BIT
IOS1     AI,R9    X'80'             SET-UP R9 AS DCT5
         B        0,R7              RETURN TO IOQ AT IOSTRT3
         PAGE
RTINT    EQU      % ***************************************************
*
*F*      NAME:    RTINT
*,*
*,*      PURPOSE: PROVIDES THE INTERFACE BETWEEN IOQ (AT I/O INTERRUPT-
*,*               TIME) AND THE REAL-TIME USER'S END ACTION ROUTINE.
*,*
*,*      DESCRIPTION:  'NOT-BUSY' DEVICE INTERRUPTS ARE PASSED TO RTINT
*,*               (IF DCT15 IS NON-ZERO AND BIT 0 OF DCT12 IS SET) WHERE
*,*               CONTROL IS PASSED TO THE REAL-TIME USER'S END-ACTION
*,*               ROUTINE (WHOSE ADDRESS IS CONTAINED IN DCT12).
*,*
*,*      REFERENCE:  CP-V SYSTEMS PROGRAMMER REFERENCE MANUAL (USER
*,*               INTERFACE IS DESCRIBED HERE).
***********************************************************************
*D*      NAME:    RTINT
*,*
*,*      REGISTERS:  NONE.
*,*
*,*      CALL:    DIRECT BRANCH FROM IOINT (IN IOQ); NOT CALLABLE
*,*               EXTERNALLY.
*,*
*,*      INTERFACE:  CALLS THE REAL-TIME USER'S END-ACTION ROUTINE
*,*
*,*      ENVIRONMENT:  MASTER/UNMAPPED.
*,*
*,*      INPUT:   R6 = CONTENTS OF DCT12 (USER'S END-ACTION RECEIVER).
*,*               R7 = DCT INDEX.
*,*               R2 = DEVICE ADDRESS.
*,*               R3 = AIO STATUS.
*,*
*,*      OUTPUT:  R4/R5 = TIO STATUS REGISTERS
*,*               DCT12
*,*
*,*      DESCRIPTION:  I/O INTERRUPTS RESULTING FROM M:IOEX REQUESTS
*,*               ARE PASSED TO RTINT.  THE TIO STATUS IS PUT IN R4/R5
*,*               AND CONTROL IS PASSED TO THE USER'S END-ACTION ROUTINE
*,*               (FROM DCT12) VIA A BAL ON R11.  UPON RETURN, ANOTHER
*,*               TIO IS ISSUED TO OBTAIN THE DEVICE/CHANNEL STATUS.
*,*               IF THE DEVICE/CHANNEL IS STILL ACTIVE, RETURN IS TO
*,*               RTRET2 (IN IOQ); IF NOT ACTIVE, RETURN IS TO RTRET1
*,*               (IN IOQ) AFTER FIRST RE-SETING THE HIGH-ORDER BIT OF
*,*               DCT12 (IOEX DEVICE BUSY BIT).
***********************************************************************
*
         TIO,R4   0,R2              TIO STATUS TO R4/R5
         STCF     R4                CC'S TOO
         PUSH     6,R2              SAVE R2, R3, & R7
         BAL,R11  0,R6              GOTO USER'S END ACTION ADDRESS
         PULL     6,R2              RESTORE REGS
         TIO,R4   0,R2              GET LATEST TIO STATUS
         BCS,8    RTRET2            NO...LEAVE CHANNEL BUSY
         CW,R5    YC                CHECK TIO STATUS FOR DEVICE STATUS
*                                   INT PENDING OR DEVICE UNAVAILABLE?
         BANZ     RTRET2            DEVICE/CHANNEL IS BUSY
         AND,R6   NB31TO0+32        RESET 'INT PEND' FLAG
         STW,R6   DCT12,R7          PUT IT BACK
         B        RTRET1            RETURN TO IOQ ... CLEAR CHANNEL
         PAGE
RTCU     EQU      % *************************************************
*
*F*      NAME:    RTCU
*,*
*,*      PURPOSE: PROVIDES THE INTERFACE BETWEEN IOQ (AT SIOREJECT-TIME)
*,*               AND THE REAL-TIME USER'S END ACTION ROUTINE.
*,*
*,*      DESCRIPTION:  CLEANUP (IN IOQ) PASSES CONTROL TO THE REAL-TIME
*,*               USER'S END-ACTION ROUTINE WHEN AN IOEX-DEVICE EXPER-
*,*               IENCES AN 'SIOREJECT' AT IOSTRT.
*,*
*,*      REFERENCE:  CP-V SYSTEMS PROGRAMMER REFERENCE MANUAL (USER
*,*               INTERFACE IS DESCRIBED HERE).
***********************************************************************
*D*      NAME:    RTCU
*,*
*,*      REGISTERS:  NONE
*,*
*,*      CALL:    DIRECT BRANCH FROM CLEANUP (IN IOQ); NOT CALLABLE
*,*               EXTERNALLY.
*,*
*,*      INTERFACE:  CALLS THE REAL-TIME USER'S END-ACTION ROUTINE.
*,*
*,*      ENVIRONMENT:  MASTER/UNMAPPED.
*,*
*,*      INPUT:   R1 = DCT INDEX
*,*               DCT12, DCT13, DCT19.
*,*
*,*      OUTPUT:  R12 = 0 (PSEUDO HANDLER POST-PROCESSOR CODES)
*,*
*,*      DESCRIPTION:  IOQ CLEANUP OPERATIONS FOR M:IOEX REQUESTS ARE
*,*               PASSED TO RTCU WHERE DCT3 IS CHECKED FOR AN 'SIO-
*,*               REJECT' STATUS.  IF SET, CONTROL IS PASSED TO THE
*,*               USER'S END-ACTION ROUTINE (VIA DCT12).  CONTROL IS
*,*               EVENTUALLY RETURNED TO IOSCU (IN IOQ) WITH R12 SET
*,*               TO 0 (PSEUDO POST-PROCESSOR HANDLER CODE INDICATING
*,*               'NORMAL' COMPLETION.
***********************************************************************
*
         LB,R12   DCT3,R1           PICK UP FLAGS
         AND,R12  SIOREJECT         ABNORMAL CLEANUP?
         BEZ      IOSCU             NO
*                                   YES...GO TO USER'S END-ACTION ADR.
         PUSH     7,R13
         LW,R7    R1                DCT INDEX
         LI,R1    -1                'SIOREJECT' FLAG
         LI,R2    0                 FLAG REGISTER TO EA ROUTINE
         LB,R3    DCT19,R7          SIO CONDITION CODES AT FAILURE
         STB,R3   R3                POSITION THEM
         LD,R4    DCT13,R7          SIO STATUS REGS AT FAILURE
         LW,R6    DCT12,R7          USER'S END-ACTION ADR.
         BAL,R11  0,R6              GO TO HIM
         PULL     7,R13
         LI,R12   0                 HANDLER FLAG
         B        IOSCU             RETURN TO IOQ
         PAGE
RTTO     EQU      % **************************************************
*
*F*      NAME:    RTTO
*,*
*,*      PURPOSE: PROVIDES THE INTERFACE BETWEEN IOQ (AT DEVICE TIME-
*,*               OUT TIME) AND THE REAL-TIME USER'S END ACTION ROUTINE.
*,*
*,*      DESCRIPTION:  DETECTION OF A TIME-OUT OF A PRE-EMPTED DEVICE
*,*               CAUSES CONTROL TO BE PASSED TO RTTO WHERE CONTROL IS,
*,*               IN TURN, PASSED TO THE REAL-TIME USER'S END-ACTION
*,*               ROUTINE.
*,*
*,*      REFERENCE:  CP-V SYSTEMS PROGRAMMER REFERENCE MANUAL (USER
*,*               INTERFACE IS DESCRIBED HERE).
***********************************************************************
*D*      NAME:    RTTO
*,*
*,*      REGISTERS:  R2 THRU R7 ARE VULNERABLE.
*,*
*,*      CALL:    BAL ON R11 FROM TIME-OUT PROCESSING IN IOQ; NOT
*,*               CALLABLE EXTERNALLY.
*,*
*,*      INTERFACE:  CALLS THE REAL-TIME USER'S END-ACTION ROUTINE.
*,*
*,*      ENVIRONMENT:  MASTER/UNMAPPED.
*,*
*,*      INPUT:   R1 = DCT INDEX.
*,*               R6 = USER'S END-ACTION ROUTINE ADDRESS.
*,*               DCT19, DCT13
*,*
*,*      OUTPUT:  NONE
*,*
*,*      DESCRIPTION:  UPON DETECTING AN OVER DUE INTERRUPT FROM AN
*,*               M:IOEX REQUEST, IOQ CALLS RTTO WHICH IN TURN PASSES
*,*               CONTROL TO THE USER'S END-ACTION ROUTINE (VIA DCT12).
***********************************************************************
*
         LI,R2    0                 SET 'TIME-OUT' FLAG
         LB,R3    DCT19,R1          PICK UP SIO CC'S
         STB,R3   R3                POSITION THEM
         LD,R4    DCT13,R1          SIO STATUS REGISTERS TO R4/R5
         PUSH     R1                SAVE DCTX
         PUSH     R11               SAVE RETURN
         LW,R7    R1                DCT INDEX TO R7
         LI,R1    0                 SET 'TIME-OUT' FLAG(#2)
         BAL,R11  0,R6              GO TO USER'S EA ROUTINE
         PULL     R11
         PULL     R1
         B        *R11              RETURN TO IOQ
         PAGE
*********************************************************************
*                                   S E C T I O N    IV:
*
*                               INTERRUPT PROCESSING ROUTINES
*********************************************************************
*
         PCC      0
         TITLE    'I N T E R R U P T      H A N D L E R'
RT:GINT  EQU      %
*
*F*      NAME:    RT:GINT
*,*
*,*      PURPOSE: TO HANDLE INTERRUPTS FROM INTERRUPTS WHICH HAVE BEEN
*,*               CENTRALLY CONNECTED TO REAL-TIME USERS VIA M:GJOBCON.
*,*
*,*      DESCRIPTION:  PLACES A SPECIFIED GHOST JOB INTO EXECUTION AS
*,*               THE RESULT OF THE OCCURRENCE OF A REAL OR PSEUDO
*,*               INTERRUPT WHICH HAS BEEN CENTRALLY-CONNECTED VIA
*,*               M:GJOBCON.
***********************************************************************
*D*      NAME:    RT:GINT
*,*
*,*      REGISTERS:  NONE
*,*
*,*      CALL:    INTERRUPT DRIVEN (REAL OR PSEUDO)
*,*
*,*      INTERFACE:  T:SAVE, T:GJOB, T:SSE
*,*
*,*      ENVIRONMENT:  MASTER/UNMAPPED.
*,*
*,*      INPUT:   ENTRY IS MADE VIA AN XPSD WHICH POINTS AT THE INTERRUPT
*,*               CONTROL BLOCK (ICB) FOR THIS INTERRUPT.
*,*
*,*      OUTPUT:  T:GJOB INITIATES THE SPECIFIED GHOST JOB.
*,*
*,*      DESCRIPTION:  A STANDARD ENVIRONMENT IS SAVED IN THE UNMAPPED
*,*               STACK; INFORMATION ABOUT THE INTERRUPT IS OBTAINED
*,*               FROM THE ASSOCIATED ICB AND, IF REAL, THE
*,*               INTERRUPT IS CLEARED (ARMED/ENABLED); THE SPECIFIED
*,*               GHOST JOB (FROM INFORMATION IN THE ICB) IS THEN ACT-
*,*               IVATED VIA A BAL TO T:GJOB; THE GHOST JOB'S USER
*,*               # IS SAVED IN THE ICB AND EXIT IS TAKEN THROUGH T:SSE.
*,*
***********************************************************************
         PUSH     6,13              SAVE SOME WORKING REGISTERS
         INT,1    RT:GINTP          GET POINTER TO ICB
         LD,0     *1                GET REAL PSD AT INTERRUPT
*                                   SINCE WE ARE HERE AS THE RESULT
*                                   OF TWO CONSECUTIVE XPSD EXECUTIONS
         BAL,2    T:SAVE            SAVE A STADARD ENVIRONMENT
         INT,1    RT:GINTP          RECONSTRUCT POINTER TO ICB
         AI,1     -ICBPSD1(W)       POINT TO BASE OF ICB
         INT,7    ICBINT(W),1       GET INTERRUPT ADDRESS
         CI,7     X'1000'           CHECK FOR PSEUDO INTERRUPT
         BGE      GINT1             YES
         LW,R10   R7                GET INTERRUPT ADDRESS
         LI,R3    X'1200'           ARM AND ENABLE (CLEAR)
         BAL,R0   RTWD              DO WRITE DIRECT
GINT1    LI,R2    ICBGJPRI(D)       POINT TO PRIORITY FOR GHOST
         LB,R15   *R1,R2            GET IT FOR GJOB START
         PUSH     R1                SAVE ICB ADDRESS
         LCI      2                 SET TO MOVE TWO WORDS
         LM,8     ICBGJACN(W),1     GET ACCOUNT
         LM,0     ICBGJNME(W),1     GET NAME FOR GHOST
         BAL,10   T:GJOB            INITIATE THAT GHOST
         PULL     R1                RESTORE ICB ADDRESS
         LI,R2    ICBGUN(D)         DISPLACEMENT TO USER NUMBER OF GHOST
         STB,R4   *R1,R2            SAVE USER NUMBER ASSIGNED
         B        T:SSE             GO SCHEDULE
*
         PAGE
RT:UINT  EQU      % **************************************************
*
*F*      NAME:    RT:UINT
*,*
*,*      PURPOSE: TO HANDLE INTERRUPTS FROM INTERRUPTS WHICH HAVE BEEN
*,*               CENTRALLY CONNECTED TO REAL-TIME USERS VIA M:CONNECT.
*,*
*,*      DESCRIPTION:  SAVES A STANDARD ENVIRONMENT AND THEN CALLS
*,*               UINTQ TO PROCESS THE INTERRUPT; EXITS THRU T:SSE.
***********************************************************************
*D*      NAME:    RT:UINT
*,*
*,*      REGISTERS:  NONE
*,*
*,*      CALL:    INTERRUPT DRIVEN (REAL OR PSEUDO)
*,*
*,*      INTERFACE:  T:SAVE, UINTQ, T:SSE
*,*
*,*      ENVIRONMENT:  MASTER/UNMAPPED
*,*
*,*      INPUT:   ENTRY IS MADE VIA AN XPSD WHICH POINTS AT THE
*,*               INTERRUPT CONTROL BLOCK (ICB) FOR THE INTERRUPT.
*,*
*,*      OUTPUT:  A STANDARD ENVIRONMENT IS SAVED AND UINTQ IS CALLED.
*,*
*,*      DESCRIPTION:  SAVES A STANDARD ENVIRONMENT AND THEN CALLS UINTQ
*,*               TO PROCESS THE INTERRUPT; EXITS THRU T:SSE.
***********************************************************************
*
         PUSH     6,13
         INT,1    RT:UINTP          GET ICB POINTER
         LD,0     *1                GET PSD
         BAL,2    T:SAVE            SAVE A STANDARD ENVIRONMENT
         INT,1    RT:UINTP          RESTORE ICB POINTER
         AI,1     -ICBPSD1(W)       POINT TO BASE OF ICB
         BAL,R11  UINTQ             QUEUE INTERRUPT FOR USER
*                                   AND REPORT TO SCHEDULER
         B        T:SSE             EXIT TO SWAPSCHEDULER
         PAGE
UINTQ    EQU      % ***************************************************
*
*F*      NAME:    UINTQ
*,*
*,*      PURPOSE: PROVIDES A SUBROUTINE FOR RT:UINT & CLOCK4 TO PROCESS
*,*               A CENTRALLY-CONNECTED REAL OR PSEUDO INTERRUPT
*,*               (M:CONNECT/M:CLOCK)
*,*
*,*      DESCRIPTION: PROVIDES A SUBROUTINE TO QUEUE 'DO' LIST ENTRY FOR
*,*               A USER RESULTING FROM A CENTRALLY CONNECTED INTERRUPT
*,*               AND TO REPORT IT TO THE SCHEDULER.
***********************************************************************
*D*      NAME:    UINTQ
*,*
*,*      REGISTERS:  ALL VOLATILE.
*,*
*,*      CALL:    BAL,R11
*,*
*,*      INTERFACE:  T:RUE, ENBSR4
*,*
*,*      ENVIRONMENT:  MASTER/UNMAPPED; CALLED DISABLED, ENABLES ON EXIT.
*,*
*,*      INPUT:   R1 = ADDRESS OF ASSOCIATED ICB.
*,*               ASSOCIATED ICB, UB:PRIOB, UH:DL, S:CUP
*,*
*,*      OUTPUT:  ASSOCIATED ICB, UH:DL, S:RTIR, S:RTUN, UB:PRIOB.
*,*
*,*      DESCRIPTION:  THE ICBDL PORTION OF THE ASSOCIATED ICB IS
*,*               CHAINED INTO UH:DL BASED UPON PRIORITY (ICBPRI).  IF
*,*               THE CURRENT ICB'S PRIORITY IS HIGHER THAN THE USER'S
*,*               UB:PRIOB, THEN UB:PRIOB IS SAVED IN ICBPRIO (OLD
*,*               PRIORITY) AND ICBPRI BECOMES UB:PRIOB.  OTHERWISE
*,*               UB:PRIOB REMAINS AS IS, AND ZERO IS SAVED IN ICBPRIO.
*,*               FINALLY, THE 'ON-DO-LIST' FLAG IS SET IN THE ICB (TO
*,*               PREVENT CIRCULAR CHAINS); ICBPRI IS COMPARED AGAINST
*,*               S:CUP (CURRENT USER'S PRIORITY), AND IF GREATER,
*,*               S:RTIR AND S:RTUN ARE SET TO FORCE A RE-SCHEDULE (TO
*,*               BY-PASS QMIN).  IN EITHER CASE, AN E:ART EVENT IS
*,*               REPORTED (VIA T:RUE) AND UINTQ EXITS TO THE CALLER.
***********************************************************************
*
         LI,2     ICBUN(D)          INDEX TO ASSOCIATED USER NUMBER
         LB,5     *1,2              GET USER NUMBER
UINT01   LW,8     ICBPRI(W),1       GET ICB PRIORITY
         LW,9     YFF               MASK FOR PRIO
         ANLZ,12  UINT01            WA OF ICB DO LIST BLOCK
         LC       *R1               CHECK FOR ALREADY ON DO LIST
         BCS,2    UINT8             YES...GET OUT SMARTLY
         SLS,12   -1                CONVERT TO DOUBLE WORD ADDRESS
         LH,2     UH:DL,5           GET USERS DO LIST ENTRY
         AND,2    MASKS+12          EXTRACT CHAIN POINTER
         BEZ      UINT4             NULL
         LW,3     2                 REMEMBER CURRENT ENTRY
         LD,6     0,2               GET HEADER OF FIRST BLOCK
         CS,8     6                 CHECK PRIORITY
         BL       UINT4             CHAIN AT HEAD
*
UINT1    AND,6    MASKS+12          MASK FLINK TO NEXT BLOCK
         BEZ      UINT2             AT END, QUEUE TO TAIL
         LW,2     6                 SAVE CURRENT ENTRY
         LD,6     0,6               FLINK
         CS,8     6                 CHECK PRIO
         BL       UINT2             THIS IS THE PLACE
         LW,3     2                 REMEMBER CURRENT ENTRY
         B        UINT1             KEEP GOING
*
UINT2    LI,13    X'FFF'            MASK FOR ACTIVE POINTER BITS
         LD,6     0,3               PICK UP FORWARD LINK FROM PREVIOUS
         SLS,3    1                 CONVERT TO WORD ADDRESS
         STS,12   0,3               MAKE PREVIOUS POINT TO US
         LI,7     X'FFF'            MASK
         STS,6    ICBPRI(W),1       AND MAKE US POINT TO FLINK
*
*
UINT3    LC       *1                GET CLEAR FLAG
         BCR,4    UINT6             EITHER: NO 'CLEAR' OR CLK-TYPE ICB
         LW,R10   ICBINT(W),R1      GET INTERRUPT ADDRESS
         AND,R10  MASKS+16          MASK OFF PRIO
         CI,R10   X'F000'           CHECK FOR PSEUDO
         BANZ     UINT5             YES
         LI,R3    X'1200'           ARM AND ENABLE (CLEAR)
         BAL,R0   RTWD              DO WRITE DIRECT
UINT5    LB,4     *1                GET INTERRUPT STATUS
         AND,4    XF0               RESET
         AI,4     6                 SET ARM AND ENABLE
         STB,4    *1                RESTORE
*
UINT6    LB,0     8                 GET CURRENT INTERRUPT PRIO
         LI,R4    0                 ZAPPER FOR OLD PRIO
         CB,R0    UB:PRIOB,R5       CHECK FOR CURRENT USER PRIO
         BG       UINT65            LOWER
         LB,R4    UB:PRIOB,R5       GET OLD VALUE
         STB,R0   UB:PRIOB,R5       RAISE HIS PRIO
         LB,R6    UB:US,R5          GET CURRENT STATE
         CI,R6    SCU               IS HE CURRENT USER?
         BNE      UINT65            NO...PRIO WILL STRAIGHTEN ITSELF OUT
         STB,R0   UB:PRIO,R5        YES..ADJUST PRIO ACCORDINGLY
         STW,R0   S:CUP             ANNOUNCE IT TO THE WORLD
UINT65   LI,R6    ICBPRIO(D)        DISP TO OLD PRIO
         STB,R4   *R1,R6            SAVE OLD PRIO
         LW,R3    Y2                SET ON-DO-LIST FLAG
         STS,R3   ICBSTAT(W),R1     TO PREVENT CIRCULAR CHAINS
         CW,0     S:CUP             CHECK AGAINST CURRENT USER
         BG       UINT7             LOWER
         LI,9     0                 SET FLAG
         STW,9    S:RTIR            IN S:RTIR TO BYPASS QMIN
         STW,5    S:RTUN            AND REMEMBER REAL TIME USER
UINT7    ENABLE
         LI,6     E:ART             ADD REAL TIME TASK
         B        T:RUE             REPORT USER EVENT
*
*
UINT4    LH,2     UH:DL,5           GET DO LIST POINTER
         LI,3     X'FFF'            MASK FOR POINTER BITS
         STS,2    ICBPRI(W),1       REMEBER FLINK
         LS,2     12                GET NEW HEAD
         STH,2    UH:DL,5           STORE NEW HEAD
         B        UINT3
*
*
*
UINT8    LW,10    ICBINT(W),1       GET INT ADR
         CI,10    X'F000'           CHECK FOR PSEUDO
         BANZ     ENBSR4            IF PSEUDO
         AND,10   MASKS+16          STRIP TO INT ADR.
         CI,10    X'5A'             CHECK FOR CLOCK
         BE       ENBSR4            IF CLOCK
         LI,3     X'1200'
         BAL,0    RTWD              CLEAR THE INTERRUPT(ARM & ENABLE)
         B        T:PULLE           GET OUT QUICKLY
         PAGE
*
RT:INTENTRY EQU   %
*
*F*      NAME:    RT:INTENTRY
*,*
*,*      PURPOSE: TO RESCHEDULE A USER BASED ON INFORMATION IN THE
*,*               DO-LIST CHAINED INTO THE HEAD OF UH:DL.
*,*
*,*      DESCRIPTION:  UPON DETECTING THAT AN ICB DO-LIST HAS BEEN
*,*               CHAINED ONTO THE HEAD OF A USER'S UH:DL, SCHED
*,*               EXITS TO RT:INTENTRY WHERE THE USER'S INTERRUPT
*,*               PROCESSING ROUTINE ENVIRONMENT IS MOVED INTO HIS STACK
*,*               AND CONTROL IS PASSED TO HIM.
***********************************************************************
*D*      NAME:    RT:INTENTRY
*,*
*,*      REGISTERS:  NOT RELEVANT
*,*
*,*      CALL:    DIRECT BRANCH FROM DO-LIST PROCESSING IN SCHED.
*,*
*,*      INTERFACE:  ALTERR, T:UTSXTS, T:PULLE.
*,*
*,*      ENVIRONMENT:  MASTER/MAPPED; CALLED DISABLED.
*,*
*,*      INPUT:   R4 = USER #
*,*               R5 = DOUBLEWORD ADDRESS OF DO-LIST BLOCK
*,*               ASSOCIATED ICB
*,*               J:ICBHDR
*,*
*,*      OUTPUT:  J:ICBHDR
*,*
*,*      DESCRIPTION:  ICBDL OF THE HIGHEST PRIORITY ICB IS UPDATED
*,*               WITH THE CURRENT CONTENTS OF J:ICBHDR (IN CASE WE
*,*               ARE INTERRUPTING AN INTERRUPT PROCESSING ROUTINE).
*,*               THE CURRENT ENVIRONMENT IS MOVED INTO THE USER'S TCB
*,*               STACK AND THE PSD OF THAT ENVIRONMENT IS UPDATED TO
*,*               REFLECT THE ADDRESS OF THE USER'S INTERRUPT PROCESSING
*,*               ROUTINE (FROM ICBENTPSD0).  THE ADDRESS OF THE
*,*               INTERRUPTING INTERRUPT IS STORED IN THE TOP OF THE
*,*               STACK AND WE EXIT TO THE USER VIA T:PULLE.
***********************************************************************
*
         LW,R6    R5                R5=DA(ICBDL)
         SLS,R5    1                CONVERT TO WA(ICBDL)
         LI,R7    X'FFFF'           MASK
         AI,R5    -ICBDL(W)         POINT TO BASE OF ICB
         LW,R8    J:ICBHDR          GET HEAD OF CURRENT CHAIN
         LI,R9    X'FFFF'           MASK
         STS,R8   ICBDL(W),R5       POINT TO REST OF CHAIN
         STS,R6   J:ICBHDR          SET NEW HEAD (DA(ICBDL))
         LW,R1    J:TCB             GET USERS TCB POINTER
         BEZ      ALTERR            NONE
         BAL,R4   T:UTSXTS          MOVE ENVIRONMENT TO STACK
         B        ALTERR            SOME KIND OF PROBLEM
         LW,R5    J:ICBHDR          PICK UP DA(ICBDL) OF 1ST ICB
         SLS,R5   1                 CONVERT TO WA(ICBDL)
         AI,R5    -ICBDL(W)         POINT TO TOP OF ICB
         LW,R10   ICBENTPSD0(W),R5  GET PSD
         LW,R6    TSTACK
         CI,R6    1                 CHECK FOR ODD
         BAZ      %+2               NO
         AI,R6    1
         STW,R10  *24BM18,R6        SET NEW PSD
         INT,R11  ICBINT(W),R5      GET INTERRUPT
         LW,R2    J:TCB
         LW,R3    0,R2              GET TOP OF TCB STACK
         STW,R11  0,R3              REMEMBER ADDRESS OF CURRENT INT
         AI,R3    -18
         LW,R2    TSTACK
         STW,R3   *24BM14,R2        SET PSD POINTER
         LW,R4    S:CUN             * SETUP
         LW,R13   U:MISC,R4         *     REGISTERS
         LH,R15   UH:FLG,R4         *             FOR
         B        SSE40             *               SCHED
         PAGE
         END

