         DEF      MPINT:            PATCHING DEF
MPINT:   RES
         TITLE    'MULTI - PROCESSING INTERFACE MODULE'
         SYSTEM   UTS
*P*********************************************************************
*M*      MPINT - MULTIPROCESSING HARDWARE INTERFACE
*P*
*P*      NAME: MPINT
*P*      PURPOSE: TO PACKAGE ALL CPU TYPE SENSITIVE CODE INTO
*P*               A SINGLE MODULE.
*P*      DESCRIPTION: MPINT CONTAINS A NUMBER OF VERY SHORT
*P*               SUBROUTINES WHICH PERFORM FUNCTIONS WHICH
*P*               REQUIRE DIFFERENT CODE ON DEFFERENT CPU
*P*               TYPES.  ASSEMBLY SWITCHES ARE PROVIDED TO
*P*               SPECIFY WHICH VERSION OF MPINT IS CREATED.
*P*
*P*********************************************************************
         SPACE    3
SIG9     SET      1                 SELECTS SIGMA 9
560M     SET      0                 SELECTS 560
         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/DEFS
*
         DEF      MP:SCA            SUBJECTIVE COUNTER ENABLE
         DEF      MP:SCD            SUBJECTIVE COUNTER DISABLE
         DEF      MP:MTRIG          TRIGGER MASTER CPU
         DEF      MP:LLK            LOAD INITIAL MAP AND WRITE LOCKS
         DEF      MP:HPN            READ HARDWARE CPU ADDRESS
*
*        PROCESSOR TABLES
*
         REF      S:INTBIT          INTERRUPT GROUP AND MASK
*
*        CENTRAL SUBROUTINES
*
         REF      LMA               LOAD MAP,ACCES AND LOCKS
         REF      UNMAP             GO UNMAPPED
*
*        DATA
*
         REF      C%CPU             CPU TYPE BITS
         REF      SYSTRT            SYSTEM START ADDRESS
         REF      MPIPI             INTER-PROCESSOR INTERRUPT TYPE
         PAGE
*D*******************************************************
*D*    MP:HPN - DETERMINE CPU ADDRESS                   *
*D*                                                     *
*D*    R11 - LINK                                       *
*D*    R8 - HARDWARE ADDRESS OF CPU                     *
*D*******************************************************
MP:HPN   EQU      %
         LC       C%CPU             GET CPU TYPE
         BCS,4    HPN9              SIG9
         BCS,2    HPN560            X560
*
*        SIGMA 6 AND 7 USE ZERO AS CPU NUMBER
*
         LI,R8    0                 FORCE PROC ADDR TO ZERO
         B        *R11              RETURN
*
*        CPU NUMBER FOR THE SIGMA 9 IS DERIVED FROM THE
*        MEMORY PORT NUMBER.
*
HPN9     LCI      8                 SET CC FOR LMS
         LMS,R8   SYSTRT            ACQUIRE MEMORY STAT WD0
         MTB,+6   R11               SET COUNTER TO
         MTB,+6   R11               X'0C'
HPN9L    SCS,R8   -1                SHIFT A BIT
         MTB,-1   R11               COUNT IN REG 11
         AI,R8    0                 TEST FOR PORT BIT
         BGEZ     HPN9L             LOOP FOR ALL PORTS
         LB,R8    R11               AND RETURN IN R8
         B        *R11              RETURN
*
*        CPU NUMBER FOR THE 560 IS THE CLUSTER NUMBER
*
HPN560   RD,R8    X'10'             READ BASIC PROCESS0R
         SLS,R8   -8                RIGHT ALIGN
         B        *R11              RETURN
         PAGE
*D*******************************************************
*D*    MP:LLK - LOAD INITIAL MAP, ACCESS AND            *
*D*             WRITE LOCKS.                            *
*D*                                                     *
*D*    R0,R1,R2,R3,R4,R5,R6,R10 VOLATILE                *
*D*    R11 - LINK                                       *
*D*******************************************************
MP:LLK   EQU      %
         BAL,R1   UNMAP             MAKE SURE WE ARE UNMAPPED
         B        LMA               USE INITIAL VERSION
         PAGE
*D*******************************************************
*D*    MP:MTRIG - TRIGGER MASTER CPU COMMUNICATION      *
*D*               INTERRUPT.                            *
*D*                                                     *
*D*    R6,R7 - VOLATILE                                 *
*D*    R11 - LINK                                       *
*D*******************************************************
MP:MTRIG EQU      %
         LD,R6    S:INTBIT          GET GROUP AND MASK BIT
         EXU,0    ARMDIS+MPIPI      NOP OR ARM AND DISABLE
         WD,R6    X'1700',R7        TRIGGER
         EXU,0    ARMDIS+MPIPI      NOP OR ARM AND DISABLE
         B        *R11              RETURN
         SPACE
ARMDIS   NOP                        NOP IF MPIPI=0
         WD,R6    X'1300',R7        ARM AND DISABLE IF MPIPI=1
         PAGE
*D*******************************************************
*D*    MP:SCA - ARM AND ENABLE SUBJECTIVE COUNTER       *
*D*                                                     *
*D*    R10 - VOLATILE                                   *
*D*    R11 - LINK                                       *
*D*******************************************************
MP:SCA   EQU      %
         LI,R10   X'1040'           SELECT CLOCK 4 COUNTER
*                                   AND COUNTER EQUALS ZERO
         WD,R10   X'1200'           ARM AND ENABLE
         B        *R11              RETURN
         PAGE
*D*******************************************************
*D*    MP:SCD - DISARM SUBJECTIVE COUNTER            *
*D*                                                      *
*D*    R10 - VOLATILE                                    *
*D*    R11 - LINK                                        *
*D********************************************************
MP:SCD   EQU      %
         LI,R10   X'1040'           SELECT CLOCK 4 COUNTER
*                                   AND COUNTER EQUALS ZERO
         WD,R10   X'1100'           DISARM BOTH
         B        *R11              RETURN
         PAGE
         END

