         PCC      0
         TITLE    'M O O S E - MULTIPROCESSING INITIALIZATION'
*M*      MOOSE    INITIALIZATION OF SECONDARY CPUS
MPBITS   SET      1
         SYSTEM   UTS
         SXSTEM   BPM
*P*      NAME:    MOOSE
         SPACE    1
*P*      PURPOSE:
         SPACE    1
*P*
*P*
*P*      A. TO START ALL SLAVE CPUS BY OBTAINING A PRIVATE
*P*          PAGE AND INITIALZING IT,SETTING UP S:PNO,
*P*          S:INTBIT, AND SX:SPP AND INSURING THAT
*P*          X'26' CONTAINS A B T:SINIT. THEN WHEN
*P*          THE SLAVE HAS STARTED TO LOG THIS EVENT
*P*          IN THE ERRLOG AND ON THE OC.
*P*
*P*      B. TO RELEASE THE PRIVATE PAGE OF A STOPPED SLAVE
*P*          CPU, RESET S:CLAIM FOR THIS ENTRY RESET SX:SPP
*P*          AND THEN LOG THIS EVENT IN THE ERRLOG AND
*P*          ON THE OC. IF THE SLAVE CPU HAS SHUT DOWN BECAUSE
*P*          OF A HARDWARE FAULT, MOOSE ALSO LOGS THE ENTRY
*P*          AS CREATED BY THE SLAVE CPU AND OUTPUTS A MESSAGE
*P*          ON THE OC.
*P*
*P*      C. TO DISPLAY THE CURRENT STATE OF ALL SLAVE CPUS
*P*          IN RESPONSE TO A DISPLAY CPU KEYIN
*P*          WHICH HAS CAUSED S:MPDISP  TO BE SET
*P*
         SPACE    1
*P*      DESCRIPTION:
*P*               SEE PURPOSE  OF REPORT P
         PAGE
************************************************************
*                                                          *
*                   PROCESSOR  STATES                      *
*                                                          *
*               START      STOP       SX:SPP     SB:STATE  *
*                                                          *
*TO BE STARTED    1          0          0          0       *
*TO RELEASE PG    0          1         >0         >0       *
*ACTIVE ENTRY     1          0         >0         >0       *
*GOING ACTIVE     1          0         >0          0       *
*NOT YET STOPPED  0          1         >0         >0       *
*STOPPED          0          1          0          0       *
*                                                          *
*                                                          *
************************************************************
         PAGE
*
*        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
         PAGE
*
*        REFS AND DEFS
*
*
*        CPU TABLES
*
         REF      SX:SPP            SLAVE PRIVATE PAGE NUMBER
         REF      SB:STATE          SLAVE CPU STATE
         REF      SB:INIT           CPU START STOP FLAGS
         REF      S:CLAIM           ENTRY CLAIMING SWITCH
         REF      S:ADR             PROCESSOR HARDWARE ADDRESS
         REF      SB:MINT           SLAVE TO MASTER INTERRUPT NO
         REF      S:STOUT           TIMEOUT VALUE FOR LOOP CONTROL
         REF      FB:EFLG           SLAVE HARDWARE FAULT FLAG
         REF      F:EADDR           ADDR OF ERRLOG ENTRY FROM SLAVE
         REF      FB:FLT            SLAVE FAULT TYPE
*
*        PRIVATE PAGE DATA
*
         REF      S:INTBIT          INTERRUPT GROUP AND MASK BIT
         REF      S:PNO             PROCESSOR NUMBER
*
*        CENTRAL MONITOR ROUTINES AND DATA CELLS
*
         REF      T:STLPP           STEAL A PAGE
         REF      T:RSPP            RELEASE STOLEN PAGE
         REF      TIME              TIME OF DAY CELL
         REF      ERRLOG            ERRLOG THE ENTRY
         REF      SYSTRT            SYSTEM START LOCATION
         REF      XFE               MASK
         REF      JIT               JIT LOCATION
         REF      XFC               MASK
         REF      Y002              TIMEOUT VALUE
*
*        SPECIAL GLOBAL CELLS
*
         REF      S:MPKYN           KEYIN RE-ENTRANCY COUNTER
         REF      S:MPDISP          DISPLAY KEYIN FLAG
         REF      TPSDBASE          START OF PSDS IN ROOT
         REF      T:SINIT           SLAVE INITIALIZATION ENTRY POINT
         REF      MPIPI             INTERPROCESSOR INTERRUPT FLAG
         REF      OCWRITE           IOQ ENTRY FOR OC
         REF      J:TCB             TO OBTAIN USERS TSTACK
*
*        MOOSE DATA CELLS
*
         DEF      INMOOSE           ENTRY POINT
         DEF      DMOOSE            MOOSE DATA PAGE START
         DEF      IMP               PATCH AREA OF MOOSE
         REF      MOOSD             START OF DATA TO BE MOVED
         REF      MOOSDSZ           LENGTH OF DATA TO BE MOVED
*
*        MASTER CPU REFS,SREFS
*
         SREF     SIPSD1            PSD BLOCK MASTER/SLAVE INTERRUPT
         SREF     SIPSD2            PSD BLOCK MASTER/SLAVE INTERRUPT
         SREF     SIPSD3            PSD BLOCK MASTER/SLAVE INTERRUPT
         PAGE
*
*        FLAGS AND VALUE DEFINITIONS
*
VPA      EQU      X'10000'          VIRTUAL PAGE TO BE USED
DISP     EQU      X'10000'-X'200'   DISPLACEMENT TO START OF PAGE
         PAGE
*
*        MOOSE DATA PAGE
*
         CSECT    0
DMOOSE   EQU      %
WKPSD    :PSD     (IA,RECALL),(WK,1),(MAP)
XPSDT    DATA     0                 TABLE OF XPSDS TO BE
         XPSD,10  SIPSD1            STORED IN MASTER
         XPSD,10  SIPSD2            INTERRUPT LEVEL
         XPSD,10  SIPSD3
*
SMPKYN   DATA     0                 CELL FOR RE-ENTRANCY COUNTER
BRANCH   B        T:SINIT           TO BE LOADED IN X'26'
NOBRANCH B        SYSTRT            B TO SELF BEFORE MOOSE STOPS
GOCODE   DATA     X'18040600'       SYSTEM START UP ENTRY WORD 0
STOPCODE DATA     X'18040700'       SYSTEM START UP ENTRY WORD 0
*
*
         PAGE
************************************************************
*        MESSAGES TO BE OUTPUT
************************************************************
T1       DATA,1   OFFCO,X'15',X'05',X'05'
TEXTOFF  TEXT     ' CPU     LOGGED OFF'     FORMAT  N-A
         DATA,1   X'15'
OFFCO    EQU      BA(%)-BA(T1)-1
         SPACE    3
************************************************************
         BOUND    4
OP1      DATA,1   OPCO,X'15',X'05',X'05'
OPER     TEXT     ' CPU     PLEASE RESPOND' FORMAT  #N
         DATA,1   X'15'
OPCO     EQU      BA(%)-BA(OP1)-1
************************************************************
         PAGE
************************************************************
         BOUND    4
T2       DATA,1   ONCO,X'15',X'05',X'05'
TEXTON   TEXT     ' CPU     LOGGED ON'      FORMAT  N-A
         DATA,1   X'15'
ONCO     EQU      BA(%)-BA(T2)-1
         SPACE    3
************************************************************
         BOUND    4
D1       DATA,1   DICO,X'15',X'05',X'05'
DISPTB   TEXT     ' CPU                 '   FORMAT  #N - A DISTYPE
         DATA,1   X'15'
DICO     EQU      BA(%)-BA(D1)-1
************************************************************
         PAGE
************************************************************
         BOUND    4
N1       DATA,1   NOTCO,X'15',X'05',X'05'
NOTNOW   TEXT     ' CPU     CANT BE STOPPED' FORMAT N-A
         DATA,1   X'15'
NOTCO    EQU      BA(%)-BA(N1)-1
         SPACE    3
************************************************************
         BOUND    4
FLT1     DATA,1   F1CO,X'15',X'05',X'05'
FALCPU   TEXT     ' CPU         FAULT'    FORMAT N-A MTYP
         DATA,1   X'15'
F1CO     EQU      BA(%)-BA(FLT1)-1
************************************************************
         PAGE
************************************************************
         BOUND    4
ERRORM   DATA,1   ERCO,X'15',X'05',X'05'
         TEXT     'ERROR IN M:CVM - MOOSE IN TROUBLE'
         DATA,1   X'15'
ERCO     EQU      BA(%)-BA(ERRORM)-1
         SPACE    3
************************************************************
         BOUND    4
NOPGE    DATA,1   NOCO,X'15',X'05',X'05'
         TEXT     'MOOSE UNABLE TO STEAL PAGE'
         DATA,1   X'15'
NOCO     EQU      BA(%)-BA(NOPGE)-1
************************************************************
         PAGE
************************************************************
         BOUND    8
DISTYPE  TEXT     'STOPPED'
         TEXT     'IDLE    '
         TEXT     'ACTIVE  '
         SPACE    3
MTYP     EQU      %
         TEXT     '    '
         TEXT     ' T46'
         TEXT     ' T4D'
         TEXT     ' BUS'
         TEXT     ' MAP'
         TEXT     ' MEM'
         SPACE    3
*************************************************************
*        PATCH AREA
*************************************************************
IMP      RES      32                PATCH AREA
         PAGE
*F*      NAME:    MOOSECALL
         SPACE    1
*F*      PURPOSE:
*F*               TO INITIATE SECONDARY CPUS
         SPACE    1
*F*      DESCRIPTION:
*F*               THIS IS THE MAIN MOOSE DRIVER
*F*               IN WHICH EACH CPU ENTRY IS
*F*               EXAMINED AND PROCESSED AS APPROPRIATE
         PAGE
*D*      NAME:    MOOSECALL
         SPACE    1
*D*      REGISTERS:
*D*               ALL REGISTERS ARE VOLATILE
         SPACE    1
*D*      CALL:
*D*               MOOSE IS CALLED AS A GHOST ONLY
*D*               EITHER AS A RESULT OF
*D*                    1) A KEYIN TO START,STOP A CPU
*D*                       (SCPU N OR XCPU N)
*D*                       OR TO DISPLAY THE CURRENT SECONDARY
*D*                       CPU STATUS (DISP CPU)
*D*                    2) AUTOMATICALLY AT INITIALIZATION OR AFTER
*D*                       RECOVERY UNLESS THE OVERRIDE FLAG IS SET
*D*                       (S:BSTRT)
*D*                    3) AFTER MPSCHED HAS DETERMINED THAT A HARDWARE
*D*                       FAULT HAS CAUSED A SLAVE CPU TO SHUT DOWN
         SPACE    1
*D*      ENVIRONMENT:
*D*               MAPPED, GOES MASTER MODE AS SOON AS
*D*               VERIFIED THAT IS CALLED AS GHOST
*D*               DISABLES ONLY AT END WHEN PICKING UP
*D*               REENTRANCY CELL (S:MPKYN) TO
*D*               DETERMINE IF THERE HAS BEEN A KEYIN SINCE
*D*               LAST  CALLED
         SPACE    1
*D*      INPUT:
*D*               S:MPKYN   - KEYIN COUNTER FLAG FOR REENTRANCY CHECK
*D*               S:MPDISP  - KEYIN FLAG TO PERFORM A DISP CPU
*D*               SB:INIT   - BYTE TABLE OF FLAGS INDEXED BY CPU #
*D*                           START & STOP  FLAGS OF INTEREST
         SPACE    1
*D*      OUTPUT:
*D*               AT EXITING TO PROCESS AN ENTRY
*D*                   R9 = THE MASTER LOOP COUNTER
*D*                   R1 = THE SPECIFIC CPU INDEX BEING PROCESSED
*D*               BOTH MUST BE PRESERVED
*D*               AT FINAL EXIT
*D*                   S:MPDISP = 0
         SPACE    1
*D*      DESCRIPTION:
*D*               UPON ENTRY MOOSE CHECKS TO SEE IF IT HAS BEEN
*D*               CALLED AS A GHOST, IF NOT IT IMMEDIATELY EXITS.
*D*               OTHERWISE INT CONTROL AND EXIT CONTROL ARE
*D*               ESTABLISHED AND MOOSE GOES MASTER MODE.
         SPACE    1
*D*               ENABLED THE KEYIN COUNTER (S:MPKYN) IS FETCHED AND
*D*               SAVED FOR LATER CHECKING AND THE MAIN LOOP OF
*D*               THE ROUTINE IS ENTERED
         SPACE    1
*D*               IN THIS LOOP EACH SLAVE CPU'S SB:INIT ENTRY
*D*               IS EXAMINED TO SEE IF THE START/STOP FLAG IS SET
*D*               WHICH CAUSES AN EXIT TO THE APPROPRIATE
*D*               ROUTINE   (STARTEM/STOPEM)  FOR FURTHER PROCESSING
         SPACE    1
*D*               UPON RETURN FROM EITHER ROUTINE OR IF
*D*               NEITHER BIT IS SET, THE LOOP CONTROL
*D*               IS ADJUSTED AND THE LOOP REENTERED
*D*               TO PROCESS THE NEXT ENTRY
         SPACE    1
*D*               WHEN ALL HAVE BEEN EXAMINED S:MPDISP IS FETCHED AND
*D*               RESET. IF THE FLAG WAS NON-ZERO THEN THE
*D*               DISPLAY ROUTINE IS ENTERED TO DISPLAY THE
*D*               CURRENT STATUS OF THE SECONDARY CPUS
         SPACE    1
*D*               FINALLY DISABLED THE KEYIN COUNTER (S:MPKYN) IS
*D*               FETCHED AND COMPARED WITH THE VALUE PREVIOUSLY SAVED
*D*               IF NOT EQUAL THEN SOME KEYINS HAVE OCCURRED
*D*               SINCE THE PROCESSING BEGAN AND THE ENTIRE
*D*               LOOP ROUTINE IS REPEATED.
*D*               OTHERWISE MOOSE EXITS
         PAGE
         CSECT    1
*************************************************************
*        M O O S E  ENTRY AND PROCESSING ROUTINE            *
*************************************************************
INMOOSE  EQU      %
MOOSECALL  EQU    %
         LC       JIT               CHECK IF GHOST
         BCR,4    EXOUT             NOWAY
         BCS,8    EXOUT             NO NO
         M:INT    INTCNTRL          SET UP IN CONTROL
         M:XCON   EXITCNTRL         ESTAB EXIT CONTROL
         M:SYS                      GO MASTER MODE
         LPSD,0   WKPSD             CHANGE WRITE KEY TO 1
RECALL   EQU      %
         ENABLE
         LW,R9    S:MPKYN           GET RE-ENTRANCY COUNTER
         STW,R9   SMPKYN            SAVE IN PRIVATE CELL
         LI,R9    NSCPU             #SLAVE CPUS
         BEZ      EXOUT             NOT DEFINED
         LI,R1    1                 INITIALIZE LOOP COUNTER
NXTONE   LB,R8    SB:INIT,R1        GET STOP &START BITS
         AND,R8   =STARTBIT+STOPBIT GET THE BITS
         CI,R8    STARTBIT
         BG       STOPEM            STOP BIT SET
         BE       STARTEM           START BIT SET
NXTENTRY AI,R1    1                 GET NEXT ENTRY
         BDR,R9   NXTONE            ALL DONE ALL ENTRIES ?
         XW,R9    S:MPDISP          YES,ANY DISPLAY KEYINS
         BNEZ     DISPLAY           YES,GO DO IT
LSTCHK   DISABLE                    NOW CHECK RE-ENTRANCY
         LW,R9    S:MPKYN           ANY KEYINS SINCE START
         CW,R9    SMPKYN            :
         BNE      RECALL            YES,GO BACK AND START AGAIN
EXOUT    M:EXIT                     EXIT
         PAGE
*F*      NAME:    STARTEM
         SPACE    1
*F*      PURPOSE:
*F*               TO "START" A SECONDARY CPU BY
*F*               OBTAINING A PRIVATE PAGE,INITIALIZING
*F*               DATA IN IT AND LOGGING THE EVENT IN
*F*               THE ERRLOG AND ON THE OC
         PAGE
*D*      NAME:    STARTEM
         SPACE    1
*D*      REGISTERS:
*D*               R9 = MASTER LOOP INDEX
*D*               R1 = SPECIFIC CPU INDEX TO BE PROCESSED
*D*               THESE ARE PRESERVED
*D*               ALL OTHERS VOLATILE
         SPACE    1
*D*      CALL:
*D*               CALLED FROM MOOSECALL WHEN SB:INIT
*D*               START FLAG IS SET
         SPACE    1
*D*      INPUT:
*D*               MOOSD = START OF MOOSE'S COPY OF PRIVATE DATA PAGE
*D*               MOOSDZ = LENGTH OF PRIVATE DATA AREA
*D*               SB:MINT = INTERPROCESSOR INTERRUPTS
*D*               MPIPI = INTERPROCESSOR INTERRUPT FLAG
*D*                       1=EVEN/ODD PAIR OF INTERRUPTS
*D*               XPSDT = TABLE  OF XPSDS TO BE STORED
*D*                       BY MOOSE IN THE MASTER CPU'S
*D*                       INTERPROCESSOR INTERRUPT LOCATION
*D*               VPA = VIRTUAL PAGE X'10000' WHICH IS
*D*                     MAPPED ONTO MOOSE TO STORE SECONDARY CPU
*D*                     DATA
*D*               TPSDBASE = START OF PSDS IN ROOT
         SPACE    1
*D*      OUTPUT:
*D*               S:PNO = SECONDARY CPU PROCESSOR NUMBER
*D*                       (INDEX INTO TABLES)
*D*               SX:SPP = PHYSICAL PAGE # OF SECONDARY
*D*                        CPU'S PRIVATE PAGE
*D*               S:INTBIT = INTERRUPT GROUP AND MASK
*D*                          DOUBLE WORD CALCULATED BY MOOSE
*D*                          FROM SB:MINT AND MPIPI
*D*               SYSTRT = THE BRANCH TO T:SINIT SO THAT SECONDARY
*D*                        CPU CAN DO ITS FINAL INITIALIZATION
*D*               ALSO ERRLOG AND OC ENTRIES TO INDICATE
*d*               cpu has logged on
         SPACE    1
*d*      interface:
*d*               t:stlpp - to steal a page
*D*               OCWRITE - TO OUTPUT MESSAGE ON OC
*d*               errlog  - to log start of secondary cpu
*d*               m:cvm   - to map onto private page
*D*               M:FVP   - TO FREE VIRTUAL PAGE
         SPACE    1
*D*      DESCRIPTION:
*D*               1. UPON ENTRY, IF SX:SPP (PRIVATE PAGE) ENTRY
*D*                  IS NON ZERO,RETURN IS MADE TO NXTENTRY
*D*               2. OTHERWISE,  R1 AND R9 ARE SAVED
*D*               3. T:STLPP IS CALLED TO STEAL A PAGE
*D*                  R3  UPON RETURN CONTAINS THE PAGE NUMBER,
*D*                  OR ZERO OR MINUS 1
*D*                  A. IF THE PAGE IS AVAILABLE CONTROL IS TRANSFERRED
*D*                     DIRECTLY TO STARTOK FOR FURTHER INITIALIZATION
*D*                  B. A ZERO CAUSES MOOSE TO WAIT A BIT AND
*D*                     TRY AGAIN
*D*                  C. A -1 INDICATES THAT NO PAGE IS AVAILABLE OR
*D*                     WILL BE AVAILABLE CAUSING MOOSE TO OUTPUT AN
*D*                     ERROR MESSAGE AND THEN ERROR EXIT.
*D*                     SEE REPORT E
*D*               4. AT STARTOK MOOSE MAPS ONTO THE PHYSICAL PAGE
*D*                  VIA AN M:CVM AND SETS UP A RETURN AND FALLS
*D*                  INTO GETLEVEL ROUTINE THAN COMPUTES THE
*D*                  GROUP AND WRITE DIRECT BIT VALUES FOR THE
*D*                  FOR THE INTERPROCESSOR INTERRUPT
*D*               5. UPON RETURN THESE VALUES ARE STORED IN S:INTBIT
*D*                  AND THE MASTER CPU'S INTERRUPT IS ARMED AND
*D*                  ENABLED.  THEN THE CPU INDEX IS STORED IN MOOSE'S
*D*                  COPY OF THE PRIVATE PG (S:PNO). THE ENTIRE CONTENTS
*D*                  OF THE ROOT PAGE IS MOVED TO THE PRIVATE PAGE AND
*D*                  OVERLAID WITH MOOSE'S COPY OF
*D*                  THE PRIVATE PAGE DATA AREA
*D*               6. THE XPSD FOR THE MASTER CPU IS THEN STORED INTO THE
*D*                  INTERPROCESSOR INTERRUPT LOCATION
*D*                  FOR THE MASTER CPU, THE PAGE # IS STORED INTO
*D*                  SX:SPP, THE BRANCH TO T:SINIT IN SYSTRT
*D*               7. THE VIRTUAL PAGE IS RELEASED VIA AN M:FVP
*D*               8. MOOSE WAITS A BIT AND TESTS SB:STATE TO SEE
*D*                  IF THE CPU IS 'STARTED', IF SB:STATE IN NON-ZERO
*D*                  CONTROL IS TRANSFERRED TO GOING TO FINISH
*D*                  PROCESSING THIS ENTRY, ELSE A MESSAGE IS OUTPUT ON
*D*                  THE OC  CPU # PLEASE RESPOND. THIS
*D*                  OPERTION IS REPEATED 10 TIMES IF NOT STARTED
*D*                  A REFLEXIVE BRANCH IS  PUT IN SYSTRT AND MOOSE
*D*                  DISABLES,RESETS THE START BIT, SETS THE STOP
*D*                  BIT AND EFFECTIVELY ENTERS THE STOPEM ROUTINE
*D*               9.AT GOING THE ERRLOG ENTRY IS PREPARED AND
*D*                  A CALL IS MADE ON ERRLOG AND THE MESSAGE
*D*                  CPU # LOGGED ON OUTPUT ON THE OC
*D*                  RETURN IN MADE TO NXTENTRY
         PAGE
*************************************************************
*        STARTEM ROUTINE                                    *
*************************************************************
STARTEM  EQU      %
         LOAD,R3  SX:SPP,R1         HAS HE GOT A PAGE
         BNEZ     NXTENTRY          HE'S GOT A PAGE,IGNORE
         PSW,R9   *J:TCB            SAVE CURRENT VALUE OF NSCPU
         PSW,R1   *J:TCB            SAVE CURRENT ENTRY INDEX
STEALONE BAL,R11  T:STLPP           GET A PAGE
         AI,3     0                 DID WE GET ONE
         BGZ      STARTOK           YES,GO INITIALIZE
         BLZ      NOGO              NO,AND CANT GET ONE
         M:WAIT   25                WAIT A BIT & TRY AGAIN
         B        STEALONE
*
STARTOK  LW,R4    R3                R3=WA OF PHYSICAL PAGE
         SLS,R4   -9                R4=PHYSICAL PAGE NO.
         M:CVM    *R3,VPA           MAP ONTO PAGE
         BCS,8    ERROR             DIDN'T DO IT,PROBLEM TIME
         PLW,R1   *J:TCB            RESTORE INDEX
         PLW,R9   *J:TCB            RESTORE VALUE OF NSPCU
         LI,R11   START2            SET UP RETURN
GETLEVEL LI,R12   X'8000'
         LB,R13   SB:MINT,R1        GET INTERRUPT LOCATION
         LI,R2    MPIPI             CHECK INTERPROCESSOR FLAG TYPE
         BEZ      %+2               SINGLE INTERRUPT
         AND,R13  XFE               A PAIR/BE SURE IS EVEN NO
         LI,R2    X'F'
         AND,R2   R13               COMPUTE WD REG BIT
         LCW,R2   R2
         SLS,R12  0,R2              THIS DOES IT
         SLS,R13  -4                COMPUTE GROUP INDEX
         AI,R13   -4
         CI,R13   1                 NO GROUP 1
         BNE      %+3               NOT 1
         LI,R13   0                 FORCE TO GROUP 0
         SLS,R12  2                 CORRECT BIT IN GROUP 0
         B        *R11              RETURN
START2   STD,R12  S:INTBIT          STORE IN DATA FOR LATER MOVE
         LD,R2    S:INTBIT          GET THE INFO TO ARM & ENABLE
         SLS,R2   -MPIPI            THE MASTER CPU LEVEL
         WD,R2    X'1200',R3
         STW,R1   S:PNO             PRC # IN MOOSE PRIV PG MOVED AS UNIT
         LI,R3    0
         LI,R2    512
         LW,R8    X'200',R3         MOVE ENTIRE CONTENTS OF
         STW,R8   VPA,R3            ROOT PAGE TO PRIVATE PAGE
         AI,R3    1                 BEFORE PUTTING SPECIAL
         BDR,R2   %-3               CELLS INTO IT
         LI,R3    0                 INDEX FOR STORING ON PAGE
         LI,R2    MOOSDSZ           NUMBER OF WORDS TO STORE
         LW,R8    MOOSD,R3          GET A WORD
         STW,R8   TPSDBASE+DISP,R3  STORE IT
         AI,R3    1
         BDR,R2   %-3               STORE SOME MORE
         LB,R13   SB:MINT,R1        GET INTERRUPT LEVEL
         OR,R13   =MPIPI            GET MASTER INTERRUPT LEVEL
         LW,R12   XPSDT,R1          GET THE XPSD AND STORE
         STW,R12  *R13              IN LOCATION OF MASTER CPU
         LW,R5    BRANCH            GET INSTRUCTION FOR X'26'
         STORE,R4 SX:SPP,R1         STORE PRIVATE PAGE NUMBER
         STW,R5   SYSTRT            SET INSTRUCTION IN X'26'
*
*        AWAY WE GO
*
         M:FVP    VPA               FREE THE PAGE NOW
ONMO     LI,R8    10                NUMBER OF CHANCES FOR OPERATOR
         LI,R5    10000             COUNTER FOR WAIT A BIT
         BDR,R5   %                 FOR SLAVE TO GET SET UP
TSTATE   MTB,0    SB:STATE,R1       IS HE GOING
         BNEZ     GOING             YES
         LB,R5    SB:INIT,R1        HAS HE BEEN STOPPED
         CI,R5    STOPBIT
         BANZ     STOPEM            YES,ABORT ATTEMPT
         LW,R5    =X'40407BF0'
         OR,R5    R1
         SCS,R5   8
         STW,R5   OPER+1
         PSW,R1   *J:TCB            SAVE R1
         LI,R1    OP1               AWAKEN THE OPERATOR
         BAL,R11  OCWRITE
         PLW,R1   *J:TCB
         BDR,R8   SLEEP             THAT'SA 1.....
         LW,R8    NOBRANCH          SET B TO SELF
         STW,R8   SYSTRT            TO BLOCK SLAVE
         DISABLE
         LB,R8    SB:INIT,R1        GET INIT FLAGS
         AND,R8   XFC               RESET START & STOP
         AI,R8    STOPBIT           SET STOPBIT
         STB,R8   SB:INIT,R1        SET FLAGS BACK
         ENABLE
         B        ONMO              GO BACK FOR ONE LAST CHECK
SLEEP    M:WAIT   25                GOTO SLEEP A BIT
         B        TSTATE
*
*        NOW LOG EVENT
*
GOING    PSW,R1   *J:TCB
         PSW,R9   *J:TCB            SAVE COUNTERS AGAIN
         LW,R7    GOCODE            SYSTEM START UP X'18040600'
         BAL,R11  ELOG              PREPARE ERRLOG ENTRY
         LW,R10   =X'60F040F0'      FORMAT WILL BE
         OR,R10   R1                N - A
         SCS,R10  16
         OR,R10   S:ADR,R1          FORMAT HIS ADDRESS
         STW,R10  TEXTON+1          MESSAGE IS
         LI,R1    T2                CPU N-A LOGGED ON
         BAL,R11  OCWRITE
         PLW,R9   *J:TCB
         PLW,R1   *J:TCB
         B        NXTENTRY          GET NEXT ENTRY
*
*        PREPARE ERRLOG ENTRY AND CALL ERRLOG
*
ELOG     EQU      %                 R7 CONTAINS CODE WORD
         LW,R10   S:ADR,R1          R8-R9 FILLED IN LATER
*                                   R10 HARDWARE ADDRESS
         LI,R6    R7                R6 POINTER TO ERRLOG ENTRY
         BAL,R5   ERRLOG            GO DO IT
         B        *R11              RETURN
         PAGE
*F*      NAME:    STOPEM
         SPACE    1
*F*      PURPOSE:
*F*               TO RELEASE THE PRIVATE PAGE OF A 'STOPPED'
*F*               SECONDARY CPU AND LOG THE EVENT IN THE ERRLOG AND
*F*               ON THE OC.
*F*               SECONDARY PURPOSE TO OUTPUT THE ERRLOG ENTRY FROM
*F*               A SECONDARY CPU FOR HARDWARE FAULT CONDITIONS
*F*               AND TO LOG APPROPRIATE MESSAGE ON THE OC AND
*F*               THEN TO FINISH THE SHUT DOWN PROCESS FOR THE CPU.
         PAGE
*D*      NAME:    STOPEM
         SPACE    1
*D*      REGISTERS:
*D*               R9 = MASTER LOOP INDEX
*D*               R1 = SPECIFIC CPU INDEX TO BE PROCESSED
*D*               THESE ARE PRESERVED
*D*               ALL OTHERS ARE VOLATILE
         SPACE    1
*D*      INPUT:
*D*               SX:SPP = PHYSICAL PAGE # OF PRIVATE PAGE
*D*               SB:STATE = STATE ENTRY OF SECONDARY CPU
*D*               S:ADR = HARDWARE ADDRESS OF SECONDARY CPU
*D*               FB:EFLG = SLAVE HARDWARE FAULT FLAG
*D*               F:EADDR = ERRLOG BUFFER ADDR FROM SLAVE FLT HANDLER
         SPACE    1
*D*      OUTPUT:
*D*               SX:SPP = 0 IF CPU IS STOPPED
*D*               S:CLAIM = 0 FOR LOCK TABLE ENTRY
*D*               FB:EFLG = 0
*D*               F:EADDR = 0
*D*               FB:FLT = 0
         SPACE    1
*D*      INTERFACE:
*D*               M:CVM - TO MAP ONTO PRIVATE PAGE
*D*               M:FVP - TO FREE VIRTUAL PAGE
*D*               T:RSPP - TO RELEASE THE STOLEN PAGE
*D*               ERRLOG - TO LOG THE STOPPING OF SECONDARY CPU
*D*               OCWRITE - TO OUTPUT MESSAGE ON OC
         SPACE    1
*D*      DESCRIPTION:
*D*               1. IF THERE IS NO PRIVATE PAGE # IN SX:SPP,
*D*                  THEN AN IMMEDIATE EXIT IS MADE TO NXTENTRY
*D*               2. OTHERWISE THE SB:STATE ENTRY FOR THE CPU
*D*                  IS  TESTED, IF ZERO THEN CONTROL IS TRANSFERRED
*D*                  TO STOP2 TO CONTINUE PROCESSING
*D*               3. IF SB:STATE IS NON ZERO THEN A TIMEOUT LOOP IS
*D*                  IS ENTERED TO CHECK THAT THE CPU HAS STOPPED .
*D*                  IF THE LOOP IS EXHAUSTED THEN A MESSAGE IS OUTPUT
*D*                  ON THE OC CPU # CANT BE STOPPED NOW
*D*                  AND CONTROL IS RETURNED TO NXTENTRY
*D*                  SB:STATE NOT GOING TO ZERO MAY  BE CAUSED
*D*                  BY SUCH EVENTS AS
*D*                     CPU HAS BEEN MANUALLY PLACED IN IDLE
*D*                     CPU HAS HARDWARE FAULTED
*D*               4. AT STOP2 MOOSE CHECKS THE FB:EFLG TO DETERMINE
*D*                  IF THE SLAVE CPU HAS HAD A HARDWARE FAULT
*D*                  CAUSING IT TO SHUT DOWN. IF SO, CONTROL
*D*                  IS TRANSFERRED TO THE STOPFLT SUBROUTINE
*D*                  OTHERWISE NORMAL PROCESSING CONTINUES AT STOP3.
*D*               5. IF AN ERROR LOG BUFFER ENTRY IS PRESENT,THEN
*D*                  THE STOPFLT SUBROUTINE MAPS ONTO THE REFERENCED
*D*                  PAGE VIA M:CVM & CONVERTS ADDRESS IN F:EADDR
*D*                  TO THE APPROPRIATE VIRTUAL ADDRESS THEN CALLS THE
*D*                  ERRLOG. UPON RETURN THE VIRTUAL PAGE IS FREED VIA
*D*                  AN M:FVP.  THEN A MESSAGE APPROPRIATE TO THE
*D*                  PARTICULAR FAULT AS DETERMINED BY THE
*D*                  VALUE IN FB:EFLG IS FORMED.
*D*                  UPON RETURN FROM OCWRITE
*D*                  FAULT TABLE ENTRIES ARE ZEROED OUT
*D*                  THE PHYSICAL PAGE # IS RESTORED & CONTROL
*D*                  RETURNS TO STOP3.
*D*               6. AT STOP3 A CALL IS MADE TO T:RSPP TO RELEASE THE
*D*                  STOLEN PAGE AND A CALL TO GETLEVEL MADE TO GET THE
*D*                  GROUP AND WRITE DIRECT BITS FOR THE MASTER
*D*                  CPU INTERPROCESSOR INTERRUPT WHICH IS
*D*                  DISARMED UPON RETURN
*D*               7. THE ERRLOG ENTRY IS PREPARED AND A CALL TO ERRLOG
*D*                  MADE TO INDICATE THE CPU HAS BEEN LOGGED OFF
*D*                  THE MESSAGE IS ALSO OUTPUT ON THE OC
*D*                  RETURN IS THEN MADE TO NXTENTRY
         PAGE
***************************************************************
*        STOPEM ROUTINE                                       *
***************************************************************
STOPEM   EQU      %
         LOAD,R3  SX:SPP,R1         HAS HE GOT A PAGE
         BEZ      NXTENTRY          NO,IGNORE IT
         LW,R11   Y002              GET COUNTER
STOP1    MTB,0    SB:STATE,R1       IS HE STOPPED
         BEZ      STOP2             YES,GO FINISH HIM OFF
         BDR,R11  STOP1             GO CHECK NOW
         LW,R7    =X'60F040F0'      FORMAT N-A
         OR,R7    R1                FOR MESSAGE
         SCS,R7   16                CPU N-A CANT BE STOPPED NOW
         OR,R7    S:ADR,R1
         STW,R7   NOTNOW+1
         PSW,R1   *J:TCB            SAVE R1
         LI,R1    N1
         BAL,R11  OCWRITE           MESSAGE TO OPERATOR
         PLW,R1   *J:TCB
         B        NXTENTRY
*
STOP2    PSW,R9   *J:TCB            SAVE NSCPU CURRENT
         LB,R2    FB:EFLG,R1        TEST FLAG FOR HARDWARE FAULT
         BNEZ     STOPFLT           BAD NEWS, GO PROCESS IT
STOP3    EQU      %
         PSW,R1   *J:TCB            SAVE LOOP CONTROL
         SLS,R3   9                 CONVERT PAGE TO WA
         BAL,R11  T:RSPP            GIVE IT BACK
         PLW,R1   *J:TCB            NEED THE INDEX
         BAL,R11  GETLEVEL          INTERRUPT BIT AND GROUP
         LD,R4    R12               PUT IN INDEX REGISTERS
         SLS,R4   -MPIPI            GET RIGHT LEVEL BIT
         WD,R4    X'1100',R5        DISARM IT
         LW,R7    STOPCODE          SYSTEM ERRLOG ENTRY
         BAL,R11  ELOG              GO DO IT
         LW,R10   =X'60F040F0'      FORMAT IS N-A
         OR,R10   R1                FOR OC MESSAGE
         SCS,R10  16                CPU N-A LOGGED OFF
         OR,R10   S:ADR,R1
         STW,R10  TEXTOFF+1
         PSW,R1   *J:TCB
         LI,R5    0
         DISABLE
         STW,R5   S:ADR,R1          ZERO OUT HARDWARE ADDRESS ENTRY
         STORE,R5 SX:SPP,R1         ZERO OUT PAGE
         STW,R5   S:CLAIM,R1        RESET ENTRY
         ENABLE
         LI,R1    T1
         BAL,R11  OCWRITE
         PLW,R1   *J:TCB
         PLW,R9   *J:TCB            RESTORE COUNTERS
         B        NXTENTRY          GET NEXT ENTRY
         PAGE
*
*        STOPFLT SUBROUTINE
*
STOPFLT  EQU      %
         PSW,R1   *J:TCB            SAVE R1
         LW,R6    F:EADDR,R1        GET ERRLOG BUFFER ADDRESS
         BEZ      NOLOG             NO BUFFER
         M:GVP    VPA               GET A PAGE FIRST...
         M:FVP    VPA               BE SURE CLEAR
         M:CVM    *R6,VPA           MAP ONTO PAGE
         BCS,8    NOLOG             DIDN'T DO IT,SKIP IT
         SLD,R6   -9                SAVE DISPLACEMENT
         LI,R6    VPA**-9           FORM VIRTUAL ADDRESS
         SLD,R6   9
         BAL,R5   ERRLOG            LOG IT
         M:FVP    VPA               RELEASE IT
NOLOG    EQU      %
         LW,R5    MTYP,R2           GET TEXT OF FAULT TYPE
         STW,R5   FALCPU+2          PUT IN MESSAGE BUFFER
         LW,R7    =X'60F040F0'      FORMAT IS N-A
         OR,R7    R1                IN GOES N
         SCS,R7   16                POSITION IT
         OR,R7    S:ADR,R1          PUT IN A
         STW,R7   FALCPU+1          MESSAGE SAYS
         LI,R1    FLT1              CPU N-A (MTYP) FAULT
         BAL,R11  OCWRITE           OUTPUT IT
         PLW,R1   *J:TCB            RESTORE R1
         LI,R11   0                 ZERO OUT ENTRIES
         STB,R11  FB:FLT,R1
         STB,R11  FB:EFLG,R1
         STW,R11  F:EADDR,R1
         LOAD,R3  SX:SPP,R1         RESTORE PHYSICAL PAGE #
         B        STOP3             CONTINUE PROCESSING
         PAGE
*F*      NAME:    DISPLAY
         SPACE    1
*F*      PURPOSE:
*F*               TO DISPLAY ON THE OC THE CURRENT STATE OF ALL
*F*               THE SECONDARY CPUS IN RESPONSE TO A DISP CPU
*F*               KEYIN
         PAGE
*D*      NAME:    DISPLAY
         SPACE    1
*D*      REGISTERS:
*D*               ALL REGISTERS ARE VOLATILE
         SPACE    1
*D*      INPUT:
*D*               S:ADR = HARDWARE ADDRESS OF SECONDARY CPUS
*D*               SB:STATE = STATE TABLE FOR SECONDARY CPUS
         SPACE    1
*D*      OUTPUT:
*D*               THE CURRENT STATE OF EACH OF THE SECONDARY CPUS
*D*               ON THE OC
         SPACE    1
*D*      INTERFACE:
*D*               OCWRITE - TO OUTPUT THE MESSAGES ON THE OC
         SPACE    1
*D*      DESCRIPTION:
*D*               1. UPON ENTRY THE STATE OF EACH SECONDARY CPU
*D*                  IS ASCERTAINED AND A MESSAGE IS FORMATTED
*D*                  INDICATING THAT THE CPU # IS STOPPED,
*D*                  IDLE, OR ACTIVE  DEPENDING ON SB:STATE
*D*                  BEING 0,1,2 RESPECTIVELY
*D*               2. THE MESSAGE FOR EACH CPU IS OUTPUT ON THE OC
*D*                  VIA SEPARATE CALLS TO OCQUEUE
*D*               3. RETURN IS MADE TO THE MAIN DRIVER AT LSTCHK
*D*                  WHEN ALL ENTRIES HAVE BEEN PROCESSED
         PAGE
***************************************************************
*        DISPLAY ROUTINE                                      *
***************************************************************
DISPLAY  EQU      %
         LI,R9    NSCPU             TOTAL NUMBER OF SLAVE CPUS
         LI,R1    1                 INDEX THROUGH TABLES
DISP2    LW,R4    S:ADR,R1          GET HIS ADDRESS
         OR,R4    =X'406040F0'
         SCS,R4   8                 POSITION IT
         STW,R4   DISPTB+2          STORE IN MESSAGE
         LW,R4    R1                GET INDEX
         SLS,R4   8
         OR,R4    =X'407BF040'      CONCATENATE INDEX
         STW,R4   DISPTB+1          STORE IN MESSAGE
         LB,R2    SB:STATE,R1       NOW GET HIS STATE
         LD,R4    DISTYPE,R2        GET THE TEXT FOR IT
         STW,R4   DISPTB+3          STORE
         STW,R5   DISPTB+4          IT IN MESSAGE
         PSW,R1   *J:TCB
         LI,R1    D1
         BAL,R11  OCWRITE
         PLW,R1   *J:TCB
         AI,R1    1                 BUMP UP INDEX
         BDR,R9   DISP2             GO DO NEXT
         B        LSTCHK            ALL DONE
*
         PAGE
*E*      ERROR:   UNABLE TO MAP ONTO PHYSICAL PAGE
         SPACE    1
*E*      MESSAGE: ERROR IN M:CVM - MOOSE IN TROUBLE
         SPACE    1
*E*      DESCRIPTION:
*E*               MOOSE HAS BEEN UNABLE TO MAP ONTO THE PHYSICAL
*E*               PAGE OBTAINED TO INTIALIZE THE SECONDARY CPU'S
*E*               PRIVATE DATA PAGE
*E*               AN ABORT EXIT IS MADE AFTER OUTPUT ON THE OC
         SPACE    3
*E*      ERROR:   UNABLE TO STEAL A PAGE EVER
         SPACE    1
*E*      MESSAGE: MOOSE UNABLE TO STEAL A PAGE
         SPACE    1
*E*      DESCRIPTION:
*E*               RETURN FROM T:STLPP INDICATES THAT NO
*E*               PAGE CAN BE STOLEN. MOOSE DOES AN ABORT
*E*               EXIT AFTER OUTPUT ON THE OC
         SPACE    3
*E*      ERROR:   J:RNST  AT EXIT CONTROL INDICATES LIMIT/I/O/TRAP
         SPACE    1
*E*      MESSAGE: NONE, SNAPS OF AREAS OF MOOSE OUTPUT ON DO
         SPACE    1
*E*      DESCRIPTION:
*E*               AT EXIT CONTROL J:RNST (CONTENTS OF R8) INDICATES
*E*               A LIMIT EXCEEDED,I/O ERROR , OR  TRAP CONDITION
*E*               HAS OCCURRED
*E*               SNAPS ARE TAKE OF THE MOOSE DATA AREA,JIT AND
*E*               PRIVATE DATA PAGE ARE TAKEN AND OUTPUT ON
*E*               THE DO DEVICE LABELED DATA,JIT AND MOOSD RESPECTIVELY
         PAGE
**************************************************************
*        ERROR ROUTINES                                      *
**************************************************************
ERROR    EQU      %
         BAL,R11  T:RSPP            RELEASE THE PAGE IN R3
         LI,R1    ERRORM
         BAL,R11  OCWRITE
         M:XXX
*
NOGO     EQU      %
         LI,R1    NOPGE
         BAL,R11  OCWRITE
         M:ERR
*
*
INTCNTRL EQU      %
         M:TRTN                     RETURN
*
*
EXITCNTRL  EQU    %
         CI,8     X'7'              LIMIT/I/O/TRAP ERROR
         BAZ      FINEXIT           NO
         LW,R0    J:TCB
         M:SNAP   'DATA',(DMOOSE,IMP+31)
         M:SNAP   'JIT',(JIT,JIT+X'1FF')
         M:SNAP   'MOOSD',(MOOSD,MOOSD+MOOSDSZ)
FINEXIT  M:EXIT
*
*
         END      MOOSECALL

