*M*      MMNR     MEMORY MANAGEMENT CAL PROCESSOR
*P*
*P*      NAME:    MMNR
*P*
*P*      PURPOSE: TO PROCESS THE FOLLOWING CALS
*P*                 M:GL     GET COMMON LIMITS
*P*                 M:GCP    GET COMMON PAGES
*P*                 M:FCP    FREE COMMON PAGES
*P*                 M:GP     GET DYNAMIC PAGES
*P*                 M:FP     FREE DYNAMIC PAGES
*P*                 M:GVP    GET VIRTUAL PAGE
*P*                 M:FVP    FREE VIRTUAL PAGE
*P*                 M:SMPRT  SET MEMORY PROTECT
*P*                 M:CVM    CHANGE VIRTUAL MAP
*P*
*P*      DESCRIPTION:  MMNR IS PART OF THE LNKTRC OVERLAY. IT IS CALLED
*P*               FROM ALTCP TO PROCESS THE MEMORY MANAGEMENT CALS.
*P*               THE CODE IN MMNR IS EXECUTED MAPPED AND IN THE
*P*               MASTER MODE.
*P*
         PAGE
UFLAGS   SET      1                 UH:FLG EQU'S
         SYSTEM   UTS
*
*        MODULE DEFS
*
         DEF      MMNR:             PATCHING DEF
MMNR:    RES
         DEF      T:GDP             PROCESS THE M:GP CAL
         DEF      T:GCP             PROCESS THE M:GCP CAL
         DEF      T:GVP             PROCESS THE M:GVP CAL
         DEF      T:FDP             PROCESS THE M:FP CAL
         DEF      T:FCP             PROCESS THE M:FCP CAL
         DEF      T:FVP             PROCESS THE M:FVP CAL
         DEF      T:GL              PROCESS THE M:GL CAL
         DEF      T:SMP             PROCESS THE M:SMPRT CAL
         DEF      T:SAD             PROCESS THE M:CVM CAL
*
*        JIT REFS
*
J        EQU      BA(J:JIT)
         REF      J:JIT             USERS JIT
         REF      J:BASE            USERS REGISTERS
         REF      J:BUP             BEGINNING USER PAGE
         REF      J:EUP             ENDING USER PAGE
         REF      J:DLL             DATA LOWER LIMIT PAGE
         REF      J:PLL             PROCEDURE LOWER LIMIT PAGE
         REF      J:PUL             PROCEDURE UPPER LIMIT PAGE
         REF      J:DDLL            DYNAMIC DATA LOWER LIMIT PAGE
         REF      J:DDUL            DYNAMIC DATA UPPER LIMIT PAGE
         REF      J:DCBLL           DCB LOWER LIMIT PAGE
         REF      JX:CMAP           PHYSICAL PAGES
         REF      JB:LMAP           USERS VIRTUAL PAGE CHAIN
         REF      JB:PRIV           USERS PRIV.
         REF      JB:TDP            TOP DYNAMIC PAGE
         REF      JBTDP             TOP DYNAMIC PAGE
         REF      JBBCP             BOTTOM COMMON PAGE
         REF      JSBUF1VP          VIRTUAL PAGE  OF SPECIAL BUFFER 1
         REF      JSBUF2VP          VIRTUAL PAGE  OF SPECIAL BUFFER 2
*
*        MM REFS
*
         REF      PAGEZAP           CLEAN USER PAGE
         REF      T:GBUF            GET SP. BUFFER FOR PROCESSOR GVP CAL
         REF      T:RBUF            RELEASE SP. BUFFER FOR PROCESSOR FVP CAL
         REF      T:GVPI            GET USER VIRTUAL PAGE
         REF      T:RVPI            FREE USER VIRTUAL PAGE
         REF      T:SAC             SET ACCESS CODES
         REF      T:SACP1           SET ACCESS CODES
         REF      T:SAD1            SET ACCESS CODES AND LOAD THE MAP
         REF      T:SXACM3          SET UP AND EXECUTE MMC FOR AC AND MAAP
         REF      T:SXMAPM3         SET UP AND EXECUTE MMC FOR AC AND MAP
         REF      T:XMMC1           SET UP AND EXECUTE MMC FOR AC AND MAP
         REF      T:SELFDESTRUCT    ZAP OVERLAY
*
*        ALTCP REFS
*
         REF      RTCHK             SEE IF REAL-TIME USER IS LOCKED IN CORE
         REF      CALBAD            ABORT REAL-TIME USER LOCKED IN CORE
         REF      RTERR             ERROR CODE FOR REAL-TIME USER
*
*        SCHED REFS
*
         REF      T:REG             TO REG USER FOR NO CORE
         REF      E:NC              NO CORE EVENT
*
*        SYSTEM TABLES
*
         REF      UH:FLG            TO CHECK FOR SPECIAL JIT ACCESS
         REF      S:CUN             TO ACCESS UH:FLG
*
*        CONSTANTS/MASKS
         REF      M8                TO ISOLATE A BYTE
         REF      M17               TO ISOLATE A WORD ADDRESS
         REF      YC                TO CHECK BITS0-1
         REF      Y8                TO CHECK BIT 0
         REF      FPMC              TO CHECK FOR FREE PAGE
         REF      X80               TABLE BIT
         REF      Y008              TO CHECK CVM ACCESS TYPE
         PAGE
*F*
*F*      NAME:    T:GDP
*F*
*F*      PURPOSE: TO PROCESS THE M:GP CAL.
*F*
*F*      DESCRIPTION:  T:GDP SETS UP THE REGISTERS FOR ACQUIRING DYNAMIC
*F*               DATA PAGES AND TRANSFERS CONTROL TO THE COMMON GET PAGE
*F*               ROUTINE, GAP1.
*F*
*D*      NAME:    T:GDP
*D*
*D*      REGISTERS:  R5-R11 SAVED
*D*                  R0-R4  AND  R12-R15 VULNERABLE
*D*
*D*      INPUT:   R6= NUMBER OF PAGES TO ACQUIRE
*D*               R11= RETURN TO 'TRAPEXIT'
*D*
*D*      OUTPUT:  R5= BYTE ADDRESS OF JB:TDP(TOP DYNAMIC PAGE #)
*D*               R7= CONTENTS OF JB:TDP (PAGE # OF NEXT DYNAMIC PAGE
*D*                                    THAT MAY BE ALLOCATED)
*D*               R10= 1  TO INCREMENT FOR NEXT HIGHER DYNAMIC PAGE
*D*                                        TO ACQUIRE
*D*
T:GDP    EQU      %
         PUSH     7,5
         LI,10    1                 REQUESTS FOR DYNAMIC PGS INCREASE
         LI,5     J+JBTDP
         LB,7     JB:TDP             PG # OF NXT DYN PG TO REQ
         B        GAP1
         PAGE
*F*
*F*      NAME:    T:GCP
*F*
*F*      PURPOSE: TO PROCESS THE M:GCP CAL
*F*
*F*      DESCRIPTION:  T:GCP SETS UP THE REGISTERS FOR ACQUIRING COMMON
*F*               DATA PAGES AND TRANSFERS CONTROL TO THE COMMON GET PAGE
*F*               ROUTINE, GAP1.
*F*
*D*      NAME:    T:GCP
*D*
*D*      REGISTERS:  R5-R11 SAVED
*D*                  R0-R4  AND  R12-R15 VULNERABLE
*D*
*D*      INPUT:   R6= NUMBER OF PAGES TO ACQUIRE
*D*               R11= RETURN TO 'TRAPEXIT'
*D*
*D*      OUTPUT:  R5= BYTE ADDRESS OF JB:BCP(TOP COMMON  PAGE #)
*D*               R7= CONTENTS OF JB:BCP (PAGE # OF NEXT COMMON  PAGE
*D*                                    THAT MAY BE ALLOCATED)
*D*               R10= -1 TO DECREMENT FOR NEXT LOWER  COMMON  PAGE
*D*                                        TO ACQUIRE
*D*
T:GCP    EQU      %
         PUSH     7,5
         LI,10    -1                REQUESTS FOR COMMON DYN PGS DECREASE
         LI,5     J+JBBCP
         LB,7     0,5               PG # OF NEXT COM PG TO REQUEST
         B        GAP1
         PAGE
*F*
*F*      NAME:    T:GVP
*F*
*F*      PURPOSE: TO PROCESS THE M:GVP CAL
*F*
*F*      DESCRIPTION:  T:GVP SETS UP THE REGISTERS FOR ACQUIRING
*F*               A VIRTUAL PAGE AND TRANSFERS CONTROL TO THE COMMON
*F*               GET PAGE ROUTINE, GAP1.
*F*
*D*      NAME:    T:GVP
*D*
*D*      REGISTERS:  R5-R11 SAVED
*D*                  R0-R4  AND  R12-R15 VULNERABLE
*D*
*D*      INPUT:   R6= WORD ADDRESS OF VIRTUAL PAGE TO ACQUIRE
*D*               R11= RETURN TO 'TRAPEXIT'
*D*
*D*      OUTPUT:  R5= 20  USED AS KEY TO INDICATE GET VIRTUAL PAGE
*D*               R6= 1   NUMBER OF PAGES TO ACQUIRE
*D*               R7= PAGE # OF VIRTUAL PAGE TO ACQUIRE
*D*               R10= 0
*D*
T:GVP    EQU      %
         PUSH     7,5
         LI,10    0
         LI,5     20                BA(REG 5) TO KAE UPDATE NXT PG INST
         LW,7     6                 VP ADR REQUESTED
         SLS,7    -9                VP #
         LI,6     1                 # OF PGS TO ACQUIRE
        AND,7    M8
         PAGE
*F*
*F*      NAME:    GAP1
*F*
*F*      PURPOSE: COMMON GET PAGE ROUTINE
*F*
*F*      DESCRIPTION:  GAP1 CALLS THE RESIDENT MM ROUTINE, T:GVPI,
*F*               FOR EACH PAGE THAT IS TO BE ACQUIRED.
*F*               ENTERED FROM T:GDP, T:GCP, T:GVP
*F*
*D*      NAME:    GAP1
*D*
*D*
*D*      INPUT:   R5= BYTE ADDR. OF JB:TDP OR JB:BCP
*D*               R6= # OF PAGES TO ACQUIRE
*D*               R7= PAGE # OF FIRST PAGE TO ACQUIRE
*D*               R10= INCREMENT OR DECREMENT FROM FIRST PAGE TO
*D*                    NEXT PAGE TO ACQUIRE
*D*               R11= RETURN TO 'TRAPEXIT'
*D*
*D*      OUTPUT:  R8= # OF PAGES ACQUIRED
*D*               R9= WORD ADDRESS OF LOWEST PAGE ACQUIRED
*D*
GAP1     EQU      %
         BAL,1    RTCHK             CHECK IF THIS USER IS A REAL-TIME
*                                   USER WHO HAS LOCKED HIMSELF IN CORE
         BCS,4    RTCHKERR          YES, HE IS; ABORT HIM
         LI,8     0
         LW,9     7
         AND,6    M17
         BEZ      GAP4-2
*  GET VIRTUAL PG
GAP2     EQU      %
         BAL,11   T:GVPM            GET VIRTUAL PG
*  ERRORS RETURN TO BAL+1
*  BOTH NORMAL & NO PHY RETURN TO BAL+2
         B        GAP4              SOME ERROR OCCURRED - CC ALREADY SET
         BCR,15   GAP3              OBTAINED PHY PG - SKIP SETTING FLAG
         STB,7    9                 COULDN'T GET PHY - SET FLAG & CONT
*  PREPARE TO GET MORE
GAP3     EQU      %
         AW,7     10                UPDATE TO NEXT PG TO REQUEST
         AI,8     1                 UPDATE # OF PGS ACQUIRED
         BDR,6    GAP2              GET REST OF PGS
         LI,12    0                 SET CC TO OR
         B        GAP4+1
*  GOT ALL VIRTUAL PAGES - WHAT ABOUT PHY
GAP4     EQU      %
         LI,12    -1
         STB,7    0,5               UPDATE TDP OR BCP TO LAST ACQUIRED+1
         LB,11    9                 IS FLAG SET,11E VIRTUAL NO PHYSICAL
         BEZ      GAP5              NO
         LI,6     E:NC              NO CORE EVENT #
         BAL,11   T:REG
         AND,9    M17
*  PREPARE TO RETURN TO USER
GAP5     EQU      %
         LW,6     8                 GET # GOTTEN
         BAL,5    PAGEZAP           ZAPEM
         AI,10    0                 10 HAS BEEN SHIFTED NOW
         BEZ      SAD3              BUT SING IS THE SAME
         BGZ      %+3
         SW,9     8
         AI,9     1
         LW,1     TSTACK
         SLS,9    9
         STW,9    -X'D',1
         B        RAP5P1
RTCHKERR EQU      % ***************************************************
*                 THIS ROUTINE IS CALLED TO ABORT A REAL-TIME USER
*                 WHO HAS ISSUED A 'GET PAGE' TYPE OF CAL1 AFTER HAVING
*                 LOCKED HIMSELF IN CORE
*
         PULL     7,5               RESTORE STACK
         LW,14    RTERR             ABORT CODE
         B        CALBAD            ALTCP ERROR EXIT
         PAGE
*F*
*F*      NAME:    T:FDP
*F*
*F*      PURPOSE: TO PROCESS THE M:FP CAL
*F*
*F*      DESCRIPTION:  T:FDP SETS UP THE REGISTERS FOR RELEASING
*F*               DYNAMIC DATA PAGES AND TRANSFERS CONTROL TO THE
*F*               COMMON FREE PAGE LOGIC, RAP1.
*F*
*D*      NAME:    T:FDP
*D*
*D*      REGISTERS:  R5-R11 SAVED
*D*                  R0-R4  AND  R12-R15 VULNERABLE
*D*
*D*      INPUT:   R6= NUMBER OF PAGES TO RELEASE
*D*               R11= RETURN TO 'TRAPEXIT'
*D*
*D*      OUTPUT:  R5= BYTE ADDRESS OF JB:TDP(TOP DYNAMIC PAGE #)
*D*               R7= CONTENTS OF JB:TDP (PAGE # OF NEXT DYNAMIC PAGE
*D*                                    THAT MAY BE ALLOCATED)
*D*               R10= -1 TO DECREMENT FOR NEXT LOWER DYNAMIC
*D*                              DATA PAGE TO RELEASE
*D*
T:FDP    EQU      %
         PUSH     7,5
         LI,10     -1               DECR TO RELEASE DYN PGS
         LI,5     J+JBTDP
         LB,7     JB:TDP             PG # & 1 TO REL
         B        RAP1
         PAGE
*F*
*F*      NAME:    T:FCP
*F*
*F*      PURPOSE: TO PROCESS THE M:FCP CAL
*F*
*F*      DESCRIPTION:  T:FCP SETS UP THE REGISTERS FOR RELEASING
*F*               COMMON DATA PAGES AND TRANSFERS CONTROL TO THE
*F*               COMMON FREE PAGE LOGIC, RAP1.
*F*
*D*      NAME:    T:FCP
*D*
*D*      REGISTERS:  R5-R11 SAVED
*D*                  R0-R4  AND  R12-R15 VULNERABLE
*D*
*D*      INPUT:   R6= NUMBER OF PAGES TO RELEASE
*D*               R11= RETURN TO 'TRAPEXIT'
*D*
*D*      OUTPUT:  R5= BYTE ADDRESS OF JB:BCP(TOP COMMON  PAGE #)
*D*               R7= CONTENTS OF JB:BCP (PAGE # OF NEXT COMMON  PAGE
*D*                                    THAT MAY BE ALLOCATED)
*D*               R10= 1  TO INCREMENT FOR NEXT HIGHER COMMON  PAGE
*D*                                        TO RELEASE
*D*
T:FCP    EQU      %
         PUSH     7,5
         LI,10    1                 INCR TO RELEASE COM PGS
         LI,5     J+JBBCP
         LB,7     0,5             PG # -1 TO REL
         B        RAP1
         PAGE
*F*
*F*      NAME:    T:FVP
*F*
*F*      PURPOSE: TO PROCESS THE M:FVP CAL
*F*
*F*      DESCRIPTION: T:FVP SETS UP THE REGISTERS FOR RELEASING A
*F*               VIRTUAL PAGE AND TRANSFERS CONTROL TO THE COMMON
*F*               FREE PAGE LOGIC, RAP1.
*F*
*D*      NAME:    T:FVP
*D*
*D*      REGISTERS:  R5-R11 SAVED
*D*                  R0-R4  AND  R12-R15 VULNERABLE
*D*
*D*      INPUT:   R6= WORD ADDRESS OF VIRTUAL PAGE TO RELEASE
*D*               R11= RETURN TO 'TRAPEXIT'
*D*
*D*      OUTPUT:  R5= 20  USED AS KEY TO INDICATE FREE VIRTUAL PAGE
*D*               R6= 1   NUMBER OF PAGES TO RELEASE
*D*               R7= PAGE # OF VIRTUAL PAGE TO RELEASE
*D*               R10= 0
*D*
T:FVP    EQU      %
         PUSH     7,5
         LI,10    0
         LI,5     20                BA(REG 5)
         LW,7     6                 VP ADR
         SLS,7    -9                VP # TO REL
         LI,6     1                 # OF PGS TO RELEASE
         PAGE
*F*
*F*      NAME:    RAP1
*F*
*F*      PURPOSE: COMMON FREE PAGE ROUTINE
*F*
*F*      DESCRIPTION:  RAP1 CALLS THE RESIDENT MM ROUTINE, T:RVPI,
*F*               FOR EACH PAGE THAT IS TO BE RELEASED.
*F*               ENTERED FROM T:FDP, T:FCP, T:FVP
*F*
*D*      NAME:    RAP1
*D*
*D*
*D*      INPUT:   R5= BYTE ADDR. OF JB:TDP OR JB:BCP
*D*               R6= # OF PAGES TO RELEASE
*D*               R7= PAGE # OF FIRST PAGE TO RELEASE
*D*               R10= INCREMENT OR DECREMENT FROM FIRST PAGE TO
*D*                    NEXT PAGE TO RELEASE
*D*               R11= RETURN TO 'TRAPEXIT'
*D*
*D*      OUTPUT:  R8= # OF PAGES RELEASED
*D*               R9= WORD ADDRESS OF LOWEST PAGE RELEASED
*D*
RAP1     EQU      %
         LI,12    0
         LI,8     0                 # OF PGS RELEASED
         AND,6    M17
         BEZ      RAP5
         AW,7     10                INCR OR DECR TO 1ST PG TO RELEASE
         AND,7    M8
         LW,9     7                 SAVE 1ST PG TO RELEASE
*  RELEASE VIRTUAL PG
RAP2     RES      0
         LI,12    FPMC              CHK TDP >=VP<=BCP
         COMPARE,12 JX:CMAP,7
         BE       RVP0
         CLM,7    J:BUP
         BCS,9    RVP0
         LB,4     JB:LMAP,7         FETCH VIRTUAL LINKING VALUE
         CI,4     1                 IS IT A SAD PAGE
         BE       RAP2M             YES
         CI,4     2                 IS IT APWP
         BNE      RVP0              NO
         LI,12    -1                DON'T RELEASE APWP
         B        SAD3              EXIT
RAP2M    EQU      %
         LI,4     3                 R4 MUST BE ONE FOR SAD PAGE RLS
         LI,1     128               BELOW PPUT, CHK SAD RELEASE
         LW,2     S:CUN
         CH,1     UH:FLG,2          LET TEL RELEASE SAD PAGES.
         BANZ     RAP2E             R1=TIC
         CB,1     JB:PRIV
         BLE      RAP2E
         SUA      X'6A'
RAP2E    EQU      %
         STORE,12 JX:CMAP,7
         MTB,-1   JB:LMAP,7         CLEAR 'SAD PAGE' FLAG
         BAL,2    T:SAC
         BAL,11   T:SXACM3
         BAL,11   T:SXMAPM3
         LI,12    0
         B        SAD3
RAP2P    RES      0
         B        RAP4              SOME ERROR OCCURRED - CC ALREADY SET
*  PREPARE TO RELEASE MORE
         AW,7     10                UPDATE TO NEXT PG TO REL
         AI,8     1                 # OF PG REL
         BDR,6    RAP2              REL REST
         LI,12    0                 SET CC TO 0
         B        RAP4+1
*  PREPARE TO RETURN TO USER
RAP4     EQU      %
         LI,12    -1
         SW,7     10                UPDATE TO NEXT PG TO ACQ
         STB,7    0,5               UPDATE TDP OR DCP TO LAST REL
RAP5     EQU      %
         LW,1     TSTACK
RAP5P1   RES      0
         STW,8    -X'E',1
         B        SAD3
         PAGE
*F*
*F*      NAME:    T:GL
*F*
*F*      PURPOSE: TO PROCESS THE M:GL CAL
*F*
*F*      DESCRIPTION:  T:GL SETS THE USER'S R8 TO THE WORD ADDRESS OF
*F*               THE LOWEST COMMON PAGE CURRENTLY ALLOCATED AND SETS
*F*               THE USER'S R9 TO THE WORD ADDRESS OF THE LAST WORD
*F*               IN THE HIGHEST COMMON PAGE CURRENTLY ALLOCATED.
*F*
*F*               IF NO COMMON PAGES ARE CURRENTLY ALLOCATED, BOTH
*F*               R8 AND R9 ARE SET TO THE ADDRESS OF THE LAST WORD IN
*F*               THE FIRST COMMON PAGE THAT COULD BE ALLOCATED.
*F*
T:GL     EQU      %
         LI,1     J+JBBCP
         LB,8     0,1               NXT PG #
         AI,8     1                 LAST PG OBTAINED
         LW,9     J:DDUL            UPPER LIMIT - 1ST PG EVER OBTAINED
         SLD,8    9
         AI,9     X'1FF'
         AI,8     -1
         CW,8     9                 TOP & BOTTOM LIMITS =
         BE       %+2               YES
         AI,8     1                 NO - RESTORE BOTTOM TO 1ST WD OF PG
         LW,1     TSTACK
         STW,8    -7,1
         STW,9    -6,1
         B        T:SELFDESTRUCT
         PAGE
*F*
*F*      NAME:    T:SMP
*F*
*F*      PURPOSE: TO PROCESS THE M:SMPRT CAL
*F*
*F*      DESCRIPTION:  THE T:SACP1 ROUTINE IN THE RESIDENT MM MODULE
*F*               IS CALLED FOR EACH PAGE SPECIFIED.
*F*
*D*      NAME:    T:SMP
*D*
*D*      REGISTERS:  R5-R11 SAVED
*D*                  R0-R4  AND  R12-R15 VULNERABLE
*D*
*D*      INPUT:   R6= ADDRESS OF FIRST PAGE
*D*               R7= ADDRESS OF FPT+1 WHICH CONTAINS MEMORY PROTECT
*D*                   VALUE AND ADDRESS OF LAST PAGE.
*D*
T:SMP    EQU      %
         PUSH     7,5
         LB,4     *7                AC
         BAL,11   GETARG2           GET USER'S SECOND ARGUMENT INTO R7
         SLS,6    -9
         AND,6    M8
         XW,6     7                 7 = 1ST VP #
         SLS,6    -9
         AND,6    M8                6 = LAST VP #
         LI,10    0
         LI,13    -2                SET FLG FOR SMP CAL
         LI,14    FPMC
SMP4     EQU      %
         LI,2     SMP4P
         CLM,7    J:BUP
         BCS,9    SMP7
         CLM,7    J:DCBLL           DON'T LET USER UP DCB ACCESS TO 11
         BCR,9    SMP7
         COMPARE,14 JX:CMAP,7       DOES USER HAVE PAGE
         BE       SMP7
         LB,1     JB:LMAP,7         IS THIS A SAD PAGE
         CI,1     1
         BNE      T:SACP1           NO,SET MPRT
SMP7     RES      0
         OR,10    X80
SMP4P    RES      0
         AI,7     1
SMP6     RES      0
         CW,7     6                 MORE PGS TO DO
         BLE      SMP4              YES
         LW,4     S:CUN
         BAL,1    T:XMMC1
         LW,13    YC
         STB,10   12                SET UP CC IN REG 12
         B        SAD4
         PAGE
*************************************
*        GET VIRTUAL PAGE           *
*        MASTER                     *
*************************************
*   I    7  = VP # REQUESTED
*        3  = PP #
*        15 = DA
*        0  = UH:FLG
*        1  = INDEXING
*        2  = FOR SUBR
*        4  = INDEX ADR
*        6  = EVENT # (PUSHED)
*        11 = EXIT & INTERNAL SUBR LINK (PUSHED)
*        12 = ACCUM
*        13 = FOR SUBR
*        14 = FOR SUBR
*        5  = NEG IF NO PHY PGS DESIRED
*
T:GVPM   EQU      %
*  TEST WHETHER REQUESTED VP IS WITHIN PROGRAM LIMITS
         CI,5     20                GVP REQ
         BNE      GVP1              NO
 LH,12 JB:TDP
 SLD,12 -8
 LB,13 13 BCP
 CLR,12 7 TDP< VP# <BCP
 BCR,6 T:GVPI YES.
 CW,7 J:PUL
 BLE %+3
 CW,7 J:EUP
         BLE      T:GVPI            PUL< VP# <EUP
         CLM,7    J:DLL
         BCS,9    GVP9
         B        T:GVPI            NO, ALL OK FOR VIRTUAL.
GVP1     EQU      %
         CLM,7    J:DDLL            IN DATA
         BCS,9    GAP4
         B        T:GVPI
         PAGE
*
*        GET SPECIAL BUFFER PAGE FOR GVP CAL BY PROCESSOR
*
GVP9     LW,4     S:CUN
         LH,12    UH:FLG,4
         CI,12    SJAC              IF NO JIT ACCESS IT IS A BAD CAL
         BAZ      GAP4
         CI,7     JSBUF1VP
         BE       GVP9A             SPECIAL BUFFER #1
         CI,7     JSBUF2VP
         BE       GVP9A             SPECIAL BUFFER #2
         CLM,7    J:BUP             ALLOW TEL TO GET ANY USER PAGE
         BCS,9    GAP4              NOT A USER PAGE
         B        T:GVPI            GET IT..
*
GVP9A    EQU      %
         LW,14    7
         SLS,14   9                 CONVERT TO PAGE ADDRESS
         BAL,2    T:GBUF            GET BUFFER PAGE
         LI,12    0                 ASSUME NO ERROR
         LW,4     10                SAVE BUFFER INDEX
         BNEZ     SAD3              GOOD RETURN IF NON-ZERO
         LI,12    -1                SET CC IF NO BUFFER AVAILABLE
         B        SAD3
         PAGE
*************************************
*        FELEASE VIRTUAL PAGE       *
*        MASTER                     *
*************************************
RVP0     EQU      %
         CI,5     20                IS THIS A FVP REQUEST
         BNE      RVP1              NO
         CLM,7    J:BUP             IS IT A USER PAGE.
         BCS,9    RAP9              NO...
         CLM,7    J:PLL             IS IT PROCEDURE
         BCR,9    RAP4              YES. DON'T RELEASE IT.
         CLM,7    J:DCBLL           IS IT A DCB PAGE
         BCR,9    RAP4              YES.
         B        T:RVPIM           IT'S COOL.
RVP1     EQU      %
         CLM,7    J:DDLL            IN DATA AREA
         BCS,9    RAP4
T:RVPIM  LI,11    RAP2P
         B        T:RVPI
         PAGE
*
*        RELEASE SPECIAL BUFFER PAGE FOR M:FVP CAL BY PROCESSOR
*
RAP9     LW,4     S:CUN
         LH,12    UH:FLG,4
         CI,12    SJAC
         BAZ      RAP4              MUST HAVE SJAC AND PROPER VIRTUAL
         CI,7     JSBUF1VP          PAGE NUMBERS
         BE       %+3
         CI,7     JSBUF2VP
         BNE      RAP4
         LW,14    7                 SET UP VP# ARG
         SLS,14   9                 CONVERT TO PAGE ADDRESS
         PUSH     7,5
         LI,5     0                 RELEASE EVERYTHING
         BAL,2    T:RBUF
         PULL     7,5
         B        RAP2P+1           EXIT
         PAGE
*F*
*F*      NAME:    T:SAD
*F*
*F*      PURPOSE: TO PROCESS THE M:CVM CAL
*F*
*F*      DESCRIPTION:  THE T:SAD1 ROUTINE IN THE RESIDENT MM MODULE IS
*F*               CALLED TO MAP THE VIRTUAL PAGE AS SPECIFIED.
*F*
*D*      NAME:    T:SAD
*D*
*D*      REGISTERS:  R5-R11 SAVED
*D*                  R0-R4  AND  R12-R15 VULNERABLE
*D*
*D*      INPUT:   R6= PHYSICAL PAGE ADDRESS TO BE PLACED IN THE
*D*                   SPECIFIED VIRTUAL PAGE
*D*               R7= ADDRESS OF FPT+1 WHICH CONTAINS THE VIRTUAL PAGE
*D*               ADDRESS INTO WHICH THE PHYSICAL PAGE IS TO BE MAPPED
*D*
T:SAD    EQU      %
         PUSH     11
         LI,11    SAD2              BUILD RETURN FROM RESIDENT
         PUSH     7,5
         BAL,11   GETARG2           GET USER'S SECOND ARGUMENT INTO R7
         LI,12    -1                FOR ERRORS
         LB,8     JB:PRIV
         AI,8     -X'80'
         BGE      PRIVOK
         LW,4     S:CUN
         LH,0     UH:FLG,4
         CI,0     TIC
         BANZ     PRIVOK            LET TEL DO IT
         PULL     7,5
         B        *11
PRIVOK   CW,6     Y008              CHECK IF HE WANTED READ ONLY ACCESS
         BAZ      %+2               NO.
         LI,8     X'20'             SET PRIVILEGE SO HE GETS RD ONLY
         LI,4     1                 INDICATE SAD ENTRY AND LMAP CONSTANT
         SLD,6    -9                ADRS TO +S
         B        T:SAD1            DO RESIDENT PORTION OF SAD
SAD2     PULL     11                RETRIEVE RETURN
         PUSH     7,5               BALANCE STACK
SAD3     LW,13    Y8
SAD4     LI,1     X'FFFFE'
         AND,1    TSTACK
         STS,12   -24,1             SET CC
SAD5     PULL     7,5
IACU7    LC       11                FOR IACU & GNVPI
         B        T:SELFDESTRUCT
*
*  LOAD USER'S SECOND ARGUMENT INTO R7
*
GETARG2  LW,7     0,7               L/WD 1 OF FPT
         BGEZ     *11               BGEZ; NOT INDIRECT, RETURN
         CI,7     X'1FFF0'          C/ADR W/X'1FFF0'
         BANZ     %+2               BANZ; ARG NOT IN REGISTER
         AW,7     J:BASE            +J:BASE; ARG IN REG, LOAD FROM TSTACK
         LW,7     0,7               L/ARG
         B        *11               RETURN
         END

