*M*      STEP     RESIDENT PORTION OF STEP
*P*
*P*      NAME:    STEP
*P*
*P*      PURPOSE: TO PERFORM THE STEP FUNCTIONS THAT CANNOT BE
*P*               DONE IN AN OVERLAY
*P*
*P*      DESCRIPTION:  TO DRIVE TO THE STEP OVERLAY R0 IS LOADED WITH
*P*               AN INDEX TO THE REQUESTED ROUTINE AND THE OVERLAY IS
*P*               IS ASSOCIATED AND ENTERED VIA THE T:OVER ROUTINE IN
*P*               T:OV.
*P*
*P*               TO COMPLETE THE DELETE USER FUNCTION, THE USER IS PUT
*P*               IN THE NULL STATE AND CONTROL RETURNS TO THE SCHEDULER.
*P*
         PAGE
MONPROC  SET      1
         SYSTEM   UTS
         DEF      STEP:             PATCHING DEF
STEP:    RES
*
*        STEP ENTRY POINTS
*
         DEF      T:EXIT            DRIVE TO M:EXIT CAL PROCESSOR
         DEF      T:ERROR           DRIVE TO M:ERR CAL PROCESSOR
         DEF      T:ABORT           DRIVE TO M:XXX CAL PROCESSOR
         DEF      XCONSETUP         FOR XIT CONTROL ON M:LINK/M:LDTRC
         DEF      KICKOFF           COC ABORT
         DEF      T:SCRATCH%USER    JIT SWAP ERROR
         DEF      T:ASP             M:LINK/M:LDTRC TO NEW PROGRAM
         DEF      T:ECCP            ASSOCIATE COMMAND PROCESSOR
         DEF      T:ABORTM          MONITOR ABORTING USER
         DEF      SETRNST           FROM SCHED-OPERATOR ERR OR ABORT
         DEF      T:TELDELCCI       T:ABORTM W/RNST SET
         DEF      T:DELUSZAP        SCHED DELETING A USER
         DEF      T:DELUS           SWAPPER DELETING A USER
         DEF      STEP70            FINAL DELETE USER FUNCTIONS (FROM STEP)
         DEF      XIT31RT           SET UP USER MAPPING AND ACCESS
         DEF      RSTRTN            ROUTINE TO RESET IMPLICIT RETURN
*,*                                 BITS IN J:RNST.
         DEF      PULL11B           PULL R11; B *R11
*
*        REFS
*
         REF      STEPOVRSEG        # OF STEP OVERLAY
         REF      T:TELDELCCI#      INDEX TO ROUTINE IN STPNR
         REF      T:DELUS#          INDEX TO ROUTINE IN STPNR
         REF      UH:DL             USER'S DO-LIST
         REF      J:RNST            RUN STATUS
         REF      UB:ACP            USER'S COMMAND PROCESSOR
         REF      UX:JIT            PHYS PG # OF JIT IF IN CORE
         REF      S:CUIS            TOTAL # OF USERS
         REF      MING              #RESERVED GHOST SLOTS
         REF      UB:US             USER STATE #
         REF      UB:OV             MON OVERLAY# ASSOC W USER
         REF      PB:REP            #USERS ASSOC. W PROC/OVERLAY
         REF      PB:UC             #USERS IN CORE ASSOC W PROC/OVERLAY
         REF      UB:BL             BLINK IN STATE QUEUE
         REF      UB:FL             FLINK IN STATE QUEUE
         REF      SB:HQ             USER # OF 1ST USER IN Q
         REF      SB:TQ             USER # OF LAST USER IN Q
         REF      T:CHS             STATE CHANGE ROUTINE
         REF      T:FPP             FREE PAGE ROUTINE
         REF      T:SE              EXECUTION SCHEDULER
         REF      S:GUIS            # GHOST USERS IN SYSTEM
         REF      S:OUIS            # ONLINE USERS IN SYSTEM
         REF      S:BUIS            # BATCH USERS IN SYSTEM
         REF      T:BTSCHED         SELECTS BATCH JOB FOR EXECUTION
         REF      T:XMMC            LOADS MEMORY MAP & ACCESS CODES
         PAGE
*F*
*F*      NAME:    OVER2
*F*
*F*      PURPOSE: TO ASSOCIATE AND ENTER THE STEP OVERLAY.
*F*
*F*      DESCRIPTION:  R0 IS LOADED WITH AN INDEX TO THE REQUESTED
*F*               ROUTINE IN STPNR AND THE OVERLAY IS ASSOCIATED
*F*               AND ENTERED VIA THE T:OVER ROUTINE IN T:OV.
*F*
*D*
*D*      NAME:    OVER2
*D*
*D*      DESCRIPTION:  R0 IS LOADED WITH AN INDEX TO THE REQUESTED
*D*               ROUTINE IN STPNR AND THE OVERLAY IS ASSOCIATED
*D*               AND ENTERED VIA THE T:OVER ROUTINE IN T:OV.
*D*
OVER2    AI,0     -T:ERROR          SCRUB ADDR PART GET INDEX
         OVERTO   STEPOVRSEG        COMMON ENTRY TO T:OVER
*
*
*
T:EXIT          BAL,0   OVER2
T:ERROR         BAL,0   OVER2
T:ABORT         BAL,0   OVER2
XCONSETUP       BAL,0   OVER2
KICKOFF         BAL,0   OVER2
T:SCRATCH%USER  BAL,0   OVER2
T:ASP           BAL,0   OVER2
T:ECCP          BAL,0   OVER2
T:ABORTM EQU      %
         BAL,1    RSTRTN            RESET IMPLICIT RETURN ON LDLNK
         LI,1     1
SETRNST         STB,1   J:RNST
T:TELDELCCI     LI,0    T:TELDELCCI#
                B       OVER2+1
T:DELUSZAP      LI,15   0
                LI,0    T:DELUS#
                B       OVER2+1
T:DELUS         LI,15   -1
                B       T:DELUSZAP+1
         PAGE
*F*
*F*      NAME:    RSTRTN
*F*      PURPOSE: TO RESET THE IMPLICIT RETURN BITS IN J:RNST
*F*               WHEN THE MONITOR DECIDES TO ABORT A USER OR
*F*               COMMAND PROCESSOR FOLLOWING AN M:LINK WHICH
*F*               REQUESTS IMPLICIT RETURN ON AN ERROR OR EXIT.
*F*      DESCRIPTION: RSTRTN RESETS THE IMPLICIT RETURN ON M:LINK
*F*               BITS IN J:RNST.
*D*      NAME:    RSTRTN
*D*      CALL:    BAL,1    RSTRTN
*D*      REGISTERS: R2 AND R3 VOLATILE.
*D*      DESCRIPTION: RSTRTN RESETS THE IMPLICIT RETURN ON M:LINK
*D*               BITS IN J:RNST.
RSTRTN   EQU      %
         LI,2     0
         LI,3     X'6000'
         STS,2    J:RNST
         B        0,1
         PAGE
*F*
*F*      NAME:    XIT31RT
*F*
*F*      PURPOSE: TO RELOAD MAP AND ACCESS CODES
*F*
*F*      DESCRIPTION:  XIT31RT UNMAPS, RELOADS THE MAP AND ACCESS CODES,
*F*               REMAPS AND RETURNS TO THE USER.
*F*
*D*      NAME:    XIT31RT
*D*
*D*      INPUT:   R4 = S:CUN
*D*
*D*      CALL:    BAL,11  XIT31RT
*D*
*D*      INTERFACE:  T:XMMC
*D*
*D*
*D*      REGISTERS: R0-R4 AND R12-R15 VOLITILE
*D*
*D*      DESCRIPTION:  XIT31RT UNMAPS, RELOADS THE MAP AND ACCESS CODES,
*D*               REMAPS AND RETURNS TO THE USER.
*D*
XIT31RT  PUSH     11
         UNMAP
         BAL,11   T:XMMC            RELOAD THE MAP & ACCESS
         MAP
PULL11B  EQU      %
         PULL     11
         B        *11
         PAGE
*F*
*F*      NAME:    STEP70
*F*
*F*      PURPOSE: TO COMPLETE THE PROCESS OF DELETING A USER FROM
*F*               THE SYSTEM.  PERFORMS THOSE FUNCTIONS THAT CANNOT
*F*               BE DONE FROM AN OVERLAY.
*F*
*F*      DESCRIPTION:  USER RUNDOWN FUNCTIONS ARE COMPLETED.  IF
*F*               THE USER WAS BATCH CONTROL THEN TRANSFERS TO
*F*               T:BTSCHED IN SCHED TO SCHEDULE A BATCH JOB.
*F*               OTHERWISE, CONTROL TRANSFERS TO T:SE IN SCHED.
*F*
*F*
*D*      NAME:    STEP70
*D*
*D*      CALL:    B  STEP70
*D*                 (ENTERED FROM STPNR)
*D*
*D*      INPUT:   R3 = SCU
*D*               R4 = S:CUN
*D*               R5 = S:CUN
*D*               R6 = 0
*D*               R8 = J:JIT, BYTE 0
*D*
*D*      INTERFACE: T:CHS, T:FPP, T:SE, T:BTSCHED
*D*
*D*      DESCRIPTION:  THE STEP OVERLAY IS DISASSOCIATED BY DECREMENTING
*D*               ITS UC AND REP AND SETTING UB:OV TO ZERO.
*D*
STEP70   EQU      %
         LB,2     UB:OV,5           L/CURRENT OVERLAY #
         MTB,-1   PB:UC,2           DEC USERS ASSOC WITH THIS OVERLAY (STEP)
         STB,6    UB:OV,5           0/CURRENT OVERLAY INDEX
         MTB,-1   PB:REP,2          DEC USERS ASSOC WITH THIS OVERLAY
         STB,6    UB:ACP,5          0/CURRENT COMMAND PROCESSOR INDEX
         UNMAP
         LOAD,5   UX:JIT,4
*D*
*D*               THE USER IS PUT INTO THE NULL STATE.
*D*
         DISABLE
         MTW,-1   S:CUIS
         REF      SNULL
         LI,2     SNULL             QUEUE TO NULL STATE
         PUSH     5                 SAVE 5
         CI,4     MING              IS THIS A RESERVED SLOT
         BGE      STEP75            NO
         STB,2    UB:US,4
         LI,2     0                 ZAPPER
         STH,2    UH:DL,4           ZAP ANYTHING THATS LEFT
         LB,5     UB:BL,4           GET BACK LINK
         LB,1     UB:FL,4           AND FORWARD LINK
         BNEZ     %+2               NOT TAIL
         STB,5    SB:TQ,3           SET NEW TAIL
         AI,5     0                 CHECK FOR HEAD
         BNEZ     %+2               NO
         STB,1    SB:HQ,3           SET NEW HEAD
         STB,5    UB:BL,1           CROSS LINK
         STB,1    UB:FL,5           REMAINING QUEUE MEMBERS
         STB,2    UB:BL,4           ZERO BACK LINK
         STB,2    UB:FL,4           ZERO FORWARD LINK
         B        %+2
STEP75   EQU      %
         BAL,11   T:CHS             DROP USER SLOT IN Q
*D*
*D*               THE PAGE CONTAINING THE USER'S JIT IS RETURNED
*D*               TO THE SYSTEM.
*D*
         PULL     3                 RESTORE JIT PAGE
         BAL,2    T:FPP
*D*
*D*               THE NUMBER OF USERS IN THE SYSTEM IS DECREMENTED.
*D*
*D*               IF THE USER WAS BATCH CONTROL TRANSFERS TO T:BTSCHED
*D*               TO SCHEDULE A BATCH JOB.
*D*
*D*               IF TH USER WAS GHOST OR ON-LINE CONTROL TRANSFERS
*D*               TO THE SCHEDULAR AT T:SE.
*D*
         LW,2     8
         SLS,2    -6
         EXU      DUC,2
         B        T:SE
DUC      BAL,11   BTSCHED
         MTW,-1   S:GUIS
         MTW,-1   S:OUIS
BTSCHED  MTW,-1   S:BUIS
         B        T:BTSCHED
         END

