*M*      SAVGET   HANDLES SAVE AND GET COMMANDS FOR TEL
         SYSTEM   SIG7FDP
UTSPROC  SET      0
S69PROC  SET      1
BITS     SET      1
         SYSTEM   UTS
         SPACE    3
************************************************************************
*P*      NAME:    SAVGET                                               *
*P*      PURPOSE:                                                      *
*P*               PROCESSES THE SAVE AND GET COMMANDS FOR TEL.         *
*P*      DESCRIPTION:                                                  *
*P*               FOR THE SAVE COMMAND, THE SAVE CAL IS EXECUTED AND   *
*P*               THE USER'S DCBS ARE TRUNCATED.  HIS JIT IS THEN      *
*P*               COPIED TO THE SAVE FILE, FOLOWED BY THE REST OF      *
*P*               HIS PAGES.                                           *
*P*                  FOR THE GET COMMAND, THE JIT IS READ FROM THE     *
*P*               SAVE FILE AND SOME OF THE FIELDS ARE TRANSFERRED TO  *
*P*               THE USER'S REAL JIT.  THE SAVED PAGES ARE TRANSFERRED*
*P*               TO CORE PAGES OBTAINED BY M:GVP, AND THEN THE GET    *
*P*               CAL IS EXECUTED.  EXTENSIVE SECURITY CHECKING IS     *
*P*               PERFORMED BOTH BY THIS ROUTINE AND IN PROCESSING     *
*P*               THE GET CAL TO INSURE THAT THE USER DOES NOT RESTORE *
*P*               AN ENVIRONMENT WHICH WILL HURT THE SYSTEM.           *
*P*      REFERENCE:                                                    *
************************************************************************
         SPACE    3
*        **********
*        *  DEFS  *
*        **********
         DEF      GET               PROCESSES GET COMMAND
         DEF      SAVE              PROCESSES SAVE COMMAND
         TITLE    'SAVGET'
*        **********
*        *  REFS  *
*        **********
         REF      J:TELFLGS         JIT FLAGS UNIQUE TO TEL
         REF      JSTEP             JOB STEP BIT IN J:TELFLGS
         REF      J:EXLY            EXECUTE ONLY FLAG WORD IN JIT
         REF      EXLYBIT           EXECUTE ONLY BIT IN J:EXLY
         REF      GETFIELD          SCANS INTO REGISTERS D1-D4
         REF      VERSCELL          ABS LOCATION CONTAINING RELEASE LEVEL
         REF      J:START           RUNNING PRGM'S START ADDRESS
         REF      J:JIT             START OF JIT
         REF      ON                TEXT 'ON'
         REF      OVER              TEXT 'OVER'
         REF      ONBIT             J:TELFLGS BIT
         REF      ONERR             TYPES ERROR MSG
         REF      OVERBIT           J:TELFLGS BIT
         REF      SYNTAX            TYPES 'EH' MSG
         REF      M:XX              DCB IN JIT
         REF      FLOP              OPENS M:XX TO A FILE
         REF      J:DCBLINK         ADDRESS OF DCB TABLE
         REF      DCBLINK           JIT DISPL. OF J:DCBLINK
         REF      OPENBIT           FCDBIT IN DCB WORD 0
         REF      J:ABUF            ADDRESS OF A/M IF IN CORE
         REF      AMBUF             WINDOW PG, NRMLY USED FOR A/M
         REF      GPFPT             GET VIRTUAL PAGE FPT
         REF      JBUP              JIT DISPL OF BEG. USER PAGE
         REF      JBUPVP            VP # OF USER'S BEG. PAGE
         REF      JEUP              JIT DISPL OF ENDING USR PG
         REF      JEUPVP            VP # OF USER'S ENDING PG
         REF      J:ASSIGN          SPECIAL FLAGS
         REF      J:RNST            RUN STATUS
         REF      JRNST             JIT DISPL. TO J:RNST
         REF      J:EXTENT
         REF      J:INTENT
         REF      J:USENT
         REF      UTS               USER TEMP STACK IN JIT
         REF,1    JB:PROMPT         USER'S PROMPT CHAR
         REF      FID               FORMS FILE N.A.P
         REF      CLEANSTACK        RESETS TELSTACK & PROMPTS
         REF      T%ERR             GETS ERRMSG & TYPES  IT
         REF      FMTELCL           FORCES M:TEL CLOSED
         REF      M:TEL             TEL'S  DYNAMIC DCB
         REF      Y03               LITERALS DATA
         REF      Y6                LITERALS DATA
         REF      FLOPBUF           TEST OPEN FPT IN SBUF1
         REF      NTJBST            TYPES ERROR MESSAGE
         REF      J:CPROCS          USER'S ASS. PROCS AT SAVE
         REF      INTENT            JIT DISPL. TO J:INTENT
         REF      MSTRMODE          FPT FOR M:MASTER BEFORE SUA
         REF      TSTACK            USER TEMP STACK IN JIT (UTS)
         REF      J:CFLGS           USED BY T:GET (UH:FLGS)
         REF      FPFPT             FREE VIRTUAL PAGE FPT
         REF      TEL               START OF TEL
         REF      INBREAK1          ABORT ENTRY TO TELMN
         REF      FREEBUF1          RELEASES SBUF1
         REF      J:CLL             CONTEXT LOWER LIMIT
         REF      JPLL              JIT DISPL. TO J:PLL
         REF      J:BUP             BEGINNING USER PAGE
         REF      J:EUP             ENDING USER PAGE
         REF      J:PLL             PURE PROCEDURE LOWER LIMIT
         REF      JJITVP            PAGE NUMBER OF JIT
         REF,1    JBTDP             BYTE DISPL. TO JB:TDP
         REF,1    JBBCP             BYTE DISPL. TO BOTTOM COMN PAGE
         REF,1    JBVLH             BYTE DISPL. TO VIRT. LINK HEAD
         REF      JLMAP             JIT DISPL. TO JB:LMAP
         REF      JCMAP             JIT DISPL. TO JX:CMAP
         REF      J:XPSD            CAL3 XPSD, TEMP WORD IN JIT
         REF      SETBUF            TEMP STORE USED DURING FILE WRITE
         REF      DCBTAB2           DYN. DCB NAME TBL IN CONTEXT PG.
         REF      BLDMTEL           BUILDS DYNAMIC DCB
         REF      KILLMTEL          REMOVES DYNAMIC DCB
R0       EQU      0
R1       EQU      1
R2       EQU      2
R3       EQU      3
R4       EQU      4
R5       EQU      5
R6       EQU      6
R7       EQU      7
SR1      EQU      8
SR2      EQU      9
SR3      EQU      10
SR4      EQU      11
D1       EQU      12
D2       EQU      13
D3       EQU      14
D4       EQU      15
         SPACE    3
GETFPT   EQU      Y03
         PAGE
************************************************************************
*  THESE PROCS ARE USED TO MANIPULATE TEL'S STACK IN SBUF1VPA          *
************************************************************************
*
*
* PROC TO CHANGE STACK POINTER THE AMOUNT SPECIFIED BY THE 1ST ARGUMENT
* USING THE REGISTER SPECIFIED BY THE 2ND ARGUMENT.
*
BUMP     CNAME
         PROC
LF       LI,AF(2) AF(1)
         MSP,AF(2)  TELSTACK
         PEND
*
* PUSH OR PULL N WORDS SPECIFIED BY 1ST ARGUMENT INTO REGS STARTING
* AT 2ND ARGUMENT.
*
PUSH     CNAME    X'9',X'B'
PULL     CNAME    X'8',X'A'
         PROC
         DO       NUM(AF)=1
LF       GEN,1,7,4,3,17  0,NAME(1),AF(1),0,TELSTACK
         ELSE
         DO       AF(1)=1
LF       GEN,1,7,4,3,17  0,NAME(1),AF(2),0,TELSTACK
         ELSE
         DO       AF(1)=16
LF       LCI      0
         ELSE
LF       LCI      AF(1)
         FIN
         GEN,1,7,4,3,17  0,NAME(2),AF(2),0,TELSTACK
         FIN
         FIN
         PEND
         TITLE    'SAVE COMMAND'
************************************************************************
*E*      ERROR:                                                        *
*E*               GROUP 03, CODE=04, SUBCODE=00                        *
*E*      DESCRIPTION:                                                  *
*E*               USER DID A SAVE WHILE AT JOB STEP, SO THERE'S        *
*E*               NOTHING TO SAVE.                                     *
************************************************************************
SAVE     EQU      %
         LW,R5    J:TELFLGS
         CI,R5    JSTEP             ARE WE AT JOB STEP?
         BAZ      %+3               NO, CONTINUE
         LI,D1    X'030400'         YES, ERROR CODE & SUBCODE
         B        CMNERR2           REPORT W/O ABORT
         SPACE    3
************************************************************************
*E*      ERROR:                                                        *
*E*               GROUP 03, CODE=04, SUBCODE=01                        *
*E*      DESCRIPTION:                                                  *
*E*               USER TRIED TO SAVE EITHER AN EXECUTE ONLY LM         *
*E*               OR A PRIVILEGED PROCESSOR.                           *
************************************************************************
         LW,R5    J:EXLY
         CW,R5    EXLYBIT           ARE WE SAVING EXEC ONLY PGM?
         BAZ      %+3               NO, CONTINUE
         LI,D1    X'030401'         YES, ERROR CODE & SUBCODE
         B        CMNERR2           REPORT W/O ABORT
*
*  INSERT CODE HERE FOR PARTICULAR PROCESSES WHICH CAN BE SAVED
*
***  DO THE SAVE CAL  ***
*
         CAL1,4   SAVEFPT           LOADS J:CPROCS & J:CFLGS
         BAL,R4   FMTELCL           CLOSE M:TEL
         BAL,SR3  GETFIELD          SCAN FOR NEXT FIELD
************************************************************************
*E*      ERROR:                                                        *
*E*               GROUP 03, CODE=04, SUBCODE=02                        *
*E*      DESCRIPTION:                                                  *
*E*               USER SAID SAVE BUT DIDN'T GIVE A FILE NAME TO        *
*E*               SAVE ON.                                             *
************************************************************************
         CI,R7    0                 ANYTHING
         BGZ      %+3               FID OR ON OR OVER
         LI,D1    X'030402'         NOPE, ERROR CODE & SUBCODE
         B        CMNERR2           REPORRT W/O ABORT
*
*  '.' TERMINATOR IS TAKEN TO MEAN 'ON' THE FILE
         CI,R6    C'.'
         BE       SAVE00
         CW,D1    ON
         BE       SAVEON
         CW,D1    OVER
         BNE      SAVE00
*                 SAVE OVER FID
         LI,R3    OVERBIT
SAVEOVR1 STS,R3   J:TELFLGS         ON/OVER
         BAL,SR3  GETFIELD
         CI,R7    0
         BE       SYNTAX
SAVEOVR2 BAL,SR4  FID               BREAK OUT N.A.P
         BAL,SR4  FLOP              YES
         LI,R5    ONBIT
         LS,R5    J:TELFLGS         IS THIS SAVE ON?
         BEZ      SAVEOK            NO
         CI,R0    0
         BE       ONERR             'ON' FILE EXISTS
SAVEOK   EQU      %
         LW,R4    Y0008             TURN OFF TEST BIT
         EOR,R4   FLOPBUF              IN OPEN FPT
         STW,R4   FLOPBUF
         LI,R4    SAVERR            SET ERR & ABN
         STW,R4   FLOPBUF+2
         STW,R4   FLOPBUF+3
         CAL1,1   FLOPBUF           OPEN THE SAVE FILE
* THE SUPERCLOSE WHICH USED TO BE HERE PRIOR TO CP-V C01 WAS
* SUPERFLUOUS AND HAS BEEN REMOVED.
         BAL,11   TRUNK             TRUNK DCB'S
*
         LH,R4    VERSCELL          CURRENT SYST&VERS
         XW,R4    J:START
*  SAVE USER'S DCBLINK IN J:ALB OF SAVED JIT
         LW,R5    *DCBTAB2          GET OLD DCBLINK
         XW,R5    J:TELFLGS            & SAVE IT TEMPORARILY
         STD,R4   SETBUF            SAVE J:START & J:TELFLGS
*                                   INCASE OF WRITE ERROR.
         LI,R1    J:JIT
         LI,R2    2048
         CAL1,1   WRITERAD          WRITE JIT AS FIRST RECORD
         STW,R4   J:START           RESTORE OLD
         STW,R5   J:TELFLGS            VALUES.
         LI,7    J:JIT
*
         LI,D2    WRITERAD
         BAL,0    JJEND
ENDPRO   BAL,R4   FMTELCL           CLOSE M:TEL
         B        CLEANSTACK
SAVEON   RES
         LI,R3    ONBIT             SET ON BIT
         B        SAVEOVR1
SAVE00   RES      0
         LI,R3    ONBIT
         STS,R3   J:TELFLGS         ASSUME ON
         B        SAVEOVR2
         PAGE
************************************************************************
*E*      ERROR:                                                        *
*E*               GROUP 03, CODE=04, SUBCODE=08                        *
*E*      DESCRIPTION:                                                  *
*E*               WRITE ERROR WHILE WRITING SAVE FILE. CLOSE           *
*E*               FILE WITH REL & TELL USER.                           *
************************************************************************
SAVERR   EQU      %
         LW,R4    SETBUF            GET SAVED J:START
         STW,R4   J:START              AND RESTORE IT.
         LW,R4    SETBUF+1          GET OLD J:TELFLGS
         STW,R4   J:TELFLGS            AND RESTORE IT.
         LW,D1    OPENBIT           DON'T  CLOSE
         CW,D1    M:TEL                FILE IF
         BAZ      %+2                  NOT OPEN.
         CAL1,1   CLOSREL           CLOSE FILE WITH REL
         LI,D1    X'030408'         ERROR CODE & SUBCODE
         B        CMNERR2           GO TELL USER
************************************************************************
*D*      NAME:    TRUNK                                                *
*D*      CALL:                                                         *
*D*               BAL,SR4   TRUNK                                      *
*D*               CALLED BY SAVE                                       *
*D*      REGISTERS:                                                    *
*D*               CLOBBERS R3,R4,R5,R6                                 *
*D*      INPUT:                                                        *
*D*               J:DCBLINK - JIT POINTER TO DCB NAME TABLE            *
*D*      OUTPUT:                                                       *
*D*               ALL OPEN DCBS ARE TRUNCATED                          *
*D*      DESCRIPTION:                                                  *
*D*               TRUNK RUNS DOWN THE LINKED DCBTABS POINTED TO BY     *
*D*               J:DCBLINK, & THEN CHECKS M:XX.  EACH OPEN DCB IS     *
*D*               TRUNCATED.  THIS IS NECESSARY TO PREVENT UNPREDICT-  *
*D*               ABLE RESULTS DUE TO OUTSTANDING READ OR WRITE        *
*D*               AHEAD I/O.                                           *
************************************************************************
TRUNK    EQU      %
         LW,R4    J:DCBLINK         (NEVER 0 BECAUSE OF M:TEL)
TRUNK3   LW,R5    0,R4              FLINK POINTER TO R5
TRUNK1   CI,R4    0                 ARE WE DONE (NO MORE)?
         BE       *SR4              YES, WHEW...
         AI,R4    1                 BUMP PAST FLINK POINTER
         CW,R4    R5                ARE WE AT END OF THIS TABLE?
         BGE      TRUNK2            YES, DO NEXT...
         LB,R3    *R4               GET DCB BYTE COUNT
         AI,R3    4                    & CONVERT TO
         SLS,R3   -2                   WORDS
         AW,R4    R3                POINT TO DCB ADDR.
         LW,R6    0,R4              GET DCB ADDR IN R6
TRUNKIT  LW,R3    0,R6              GET DCB WORD 0
         CW,R3    OPENBIT           IS IT OPEN?
         BAZ      TRUNK1            NO, CHECK NEXT
         CAL1,1   TRUNKFPT          YES, TRUNCATE BLOCKING BUFFER
         B        TRUNK1            GO LOOK AT NEXT
*
TRUNK2   LW,R4    0,R5              GET FLINK
         BNEZ     TRUNK3            NON-ZERO, DO NEXT TABLE
*  SPECIAL CASE M:XX 'CAUSE IT'S NOT IN DCBTAB
         LI,R6    M:XX              NO...
         B        TRUNKIT              SO DO IT.
*
TRUNKFPT GEN,1,7,24   1,2,R6
         DATA     0
*
WRITERAD GEN,8,24   X'11',M:TEL
         GEN,4,4,24    15,4,0
         DATA     SAVERR
         DATA     SAVERR
         PZE      *1
         PZE      *2
         PZE      0
READAD   GEN,8,24   X'10',M:TEL
         GEN,4,4,24    15,4,0
         DATA     GETNG1
         DATA     GETNG1
         PZE      *1
         PZE      *2
         PZE      0
CLOSREL  GEN,8,24   X'15',M:TEL
         PZE      *0
         DATA     1
         TITLE     'GET'
GET      RES      0
         LW,R5    J:TELFLGS         JOB STEP?
         CI,R5    JSTEP
         BAZ      NTJBST            COMMAND ILLEGAL UNLESS JOB STEP TIME
         BAL,SR3  GETFIELD
         CI,R7    0                 FID
         BGZ      %+3               A FILE WAS NAMED
************************************************************************
*E*      ERROR:                                                        *
*E*               GROUP 03, CODE=04, SUBCODE=07                        *
*E*      DESCRIPTION:                                                  *
*E*               NO GET FILE NAMED                                    *
************************************************************************
         LI,D1    X'030407'         ERROR CODE & SUBCODE
         B        CMNERR2
*
         BAL,R4   FMTELCL           SAFETY CLOSE
         BAL,SR4  FID               N.A.P.                           RL2
         BAL,SR4  FLOP              OPEN
         CI,R0    0
         BEZ      %+3               FILE EXISTS
************************************************************************
*E*      ERROR:                                                        *
*E*               GROUP 03, CODE=02,SUBCODE=02                         *
*E*      DESCRIPTION:                                                  *
*E*               THE FILE NAMED ON THE GET COMMAND DOESN'T EXIST      *
************************************************************************
         LI,D1    X'030202'         ERROR CODE & SUBCODE
         B        CMNERR2
*
         LI,7     0                 IN CASE ABUF IS HANGING
         XW,7     J:ABUF            AROUND, USE IT.
         BNEZ     GT10
         LI,SR2   AMBUF             GET SECOND SPEC BUFFER IN
         CAL1,8   GPFPT              CONTEXT AREA TO READ JIT
         BCR,8    SB2OK             INTO.  SCREECH IF NOPAGE
         PAGE
************************************************************************
*S*      SCREECH CODE:     60-02                                       *
*S*      REPORTED BY:     TEL                                          *
*S*      MESSAGE: TEL ISSUED SINGLE USER ABORT ON YOU                  *
*S*      TYPE:    SINGLE USER ABORT                                    *
*S*      REGISTERS:     NO REGISTERS ARE SIGNIFICANT.                  *
*S*      REMARKS: WE FAILED TO GET SBUF2 FOR A GET.  THIS              *
*S*               IS ESSENTIALLY THE SAME AS SUA 60-01 (FAILED TO      *
*S*               GET SBUF2 FOR READAM).  A TEL LOGIC PROBLEM OR       *
*S*               MEMORY MANAGEMENT FAILURE IS INDICATED.              *
************************************************************************
         CAL1,6   MSTRMODE
         SUA      X'60',2
*
SB2OK    EQU      %
         LI,7     AMBUF
GT10     EQU      %
         LW,1     7
         LI,R2    2048
         CAL1,1   READAD            JIT TO BUFF
         LW,D1    0,R7
         BGZ      BADJIT            NOT ON-LINE
         LH,R4    VERSCELL          GET RUNNING CELL
         LW,R5    J:START-J:JIT,R7  SAVED VERS&SYST
         CW,R4    R5
         BNE      GETNG2
         LW,SR4   JBUP,R7
         CI,SR4   JBUPVP            BEGIN-USER-PAGE
         BNE      GETNG1
         LW,SR4   JEUP,R7             AND END-USER-PAGE
         CI,SR4   JEUPVP              MUST BE CORRECT
         BNE      GETNG1
*
*  READ IN ALL PAGES
*
         LI,D2    READAD            FPT FOR READ
         BAL,R0   JJEND             READ THE PAGES IN
*
*
         LW,D2    J:ASSIGN-J:JIT,7
         STS,D2    J:ASSIGN       INSERT ASSIGN OR NO ASSIGN CODE TO
*                                  ASSIGN CHK WORD
         LW,R5    JRNST,R7          GET RUNFLAGS FROM OLF JIT TABLE
         AND,R5   PGMTYPE           SAVE ONLY FLAG BITS
         STS,R5   J:JIT+JRNST
*  RESTORE EXIT CONTROL ADDRESS
         LW,D2    XCONMSK           MASK FLAGS EXCEPT XCON
         LS,D2    J:EXTENT-J:JIT,R7 GET OLD XCON ADDR
         STW,D2   J:EXTENT             AND PUT INTO REAL JIT
         LW,D1    J:CPROCS-J:JIT,7
         STW,D1   J:CPROCS
         LW,D1    J:CFLGS-J:JIT,7
         STW,D1   J:CFLGS
         LW,D1    INTENT,7
         STW,D1   J:INTENT
         LCI      3
         LM,D1    J:USENT-J:JIT,7
         STM,D1   J:USENT           +JCB AND TREE
*        RESTORE CAL3 CONTROL, LET CAL DO VALIDATION
         LCI      2
         LM,D1    J:XPSD-J:JIT,7    OLD ENTRY PSD
         STM,D1   J:XPSD            MOVE INTO THE JIT.
         LI,D1    6
         STB,D1   D1                FORM FPT WORD (X'06000000')
         LW,D2    2+J:XPSD-J:JIT,7  FIRST WORD OF XPSD
         LW,D3    3+J:XPSD-J:JIT,7  SECOND WORD OF XPSD
         CAL1,5   D1                M:CAL TO SET THINGS UP.
         BCS,12   BADJIT            B/CAL3 RESTORE NOT ALLOWED.
*
*        MOVE     TSTACK
*
         LI,R1    X'7FFF'           ADJUST
         LS,R1    UTS+1             TSTACK
         LCW,R1   R1
         AI,R1    19
         MSP,R1   UTS
         LI,R1    JB:PROMPT-BA(J:JIT)
         LB,R0    *7,1
         BEZ      NOPROMPT                                           RL2
         AW,R0    PCFPT             FPT IN R0
         CAL1,1   0                                                  RL2
NOPROMPT   RES    0                                                  RL2
         LI,R1    19                SET STACK TO 19
         LI,2     TSTACK-J:JIT+1
         AW,2     R7
         LW,D1    *2,1
         STW,D1   TSTACK+1,R1
         BDR,R1  %-2
         STW,R1   TSTACK+3   SET WK/CI/II/EI/RP  =0
         LW,R1    =X'00C00000'
         STS,R1   TSTACK+2   SET MAP AND SLAVE
*
PROCSEXIT EQU     %
* BEFORE DOING THE GET CAL, WE MUST DELETE M:TEL & STUFF THE
* USER'S DCB TABLE ADDRESS INTO J:DCBLINK TO KEEP THE DCB CHECKER
* HAPPY.
         BAL,R4   KILLMTEL          DELETE M:TEL (ALSO DOES CLOSE)
         LW,R1    J:TELFLGS-J:JIT,R7   GET SAVED DCBLINK
         STW,R1   J:DCBLINK            TO RUNNING JIT
         LI,R7    -2                INDICATE AMBUF RELEASED
         LI,SR2   AMBUF
         CAL1,8   FPFPT
         CAL1,4   GETFPT
         BCS,8    GETBAD
         BAL,D4   FREEBUF1          RELEASE CURRENT CONTEXT PAGE
         LI,1     2
         STW,1    J:TELFLGS         SET NOT AT JOB STEP.
         B        TEL               RECYCLE
*
*  COMMON ERROR REPORTING POINT
*
CMNERR2  LI,R0    CLEANSTACK        SIMULATE BAL
         B        T%ERR             ERROR CODE IN D1
*
************************************************************************
*E*      ERROR:                                                        *
*E*               GROUP 03, CODE=04, SUBCODE=05                        *
*E*      DESCRIPTION:                                                  *
*E*               FOUND ERROR WHILE ANLYZING SAVED JIT IMAGE.          *
************************************************************************
BADJIT   LI,D1    X'030405'         ERROR CODE & SUBCODE
CMNERR3  EQU      %
         BAL,R0   T%ERR             TELL USER
         LI,R0    0
         LW,R1    Y6
         STS,R0   J:ASSIGN          RESET PPS AND IORT FLAG
         CI,7     AMBUF
         BNE      LATERX1
         LI,SR2   AMBUF             RELEASE SPEC BUFFER PAGE
         CAL1,8   FPFPT
LATERX1  EQU      %
         BAL,R4   FMTELCL           SAFETY CLOSE
         B        INBREAK1           RELEASE IBUF AND ABORT          RL2
*
PAGERR   LI,R2    JJITVP
         LI,R3    JBUPVP-1
         STD,R2   J:CLL             RESET CONTEXT LIMITS
         SPACE    3
************************************************************************
*E*      ERROR:                                                        *
*E*               GROUP 03, CODE=04, SUBCODE=04                        *
*E*      DESCRIPTION:                                                  *
*E*               PAGES IN GET FILE ARE OUTSIDE LEGAL JIT              *
*E*               LIMITS OR RECORD IS > 2048 BYTES.                    *
************************************************************************
GETNG1   LI,D1    X'030404'         ERROR CODE & SUBCODE
         B        CMNERR3
         SPACE    3
************************************************************************
*E*      ERROR:                                                        *
*E*               GROUP 03, CODE=04, SUBCODE=03                        *
*E*      DESCRIPTION:                                                  *
*E*               GET FILE SYSTEM VERSION DOESN'T MATCH CURRENT        *
*E*               SYSTEM VERSION (CELL X'2B')                          *
************************************************************************
GETNG2   LI,D1    X'030403'         ERROR CODE & SUBCODE
         B        CMNERR3
         SPACE    3
************************************************************************
*E*      ERROR:                                                        *
*E*               GROUP 03, CODE=04, SUBCODE=06                        *
*E*      DESCRIPTION:                                                  *
*E*               THE GET CAL FAILED. THIS MEANS THAT UCAL OR          *
*E*               (MOST LIKELY) THE DCB CHECKER FOUND AN ERROR.        *
************************************************************************
GETBAD   EQU      %
         BAL,R0   BLDMTEL           REBUILD M:TEL FOR ERROR MSG WRITE
         LI,D1    X'030406'         ERROR CODE & SUBCODE
         B        CMNERR3
         SPACE    3
************************************************************************
*E*      ERROR:                                                        *
*E*               GROUP 03, CODE=04, SUBCODE=09                        *
*E*      DESCRIPTION:                                                  *
*E*               M:CVM FAILED WHILE ATTEMPTING TO RESTORE THE USERS   *
*E*               MAP IMAGE FROM THE GET FILE.                         *
************************************************************************
CVMERR   LI,D1    X'030409'         ERROR CODE & SUBCODE
         B        CMNERR3
         PAGE
************************************************************************
*E*      ERROR:                                                        *
*E*               GROUP 03, CODE=04, SUBCODE=0A                        *
*E*      DESCRIPTION:                                                  *
*E*               COULDN'T GET A PAGE TO RESTORE THE SAVED             *
*E*               PROGRAM.  THIS IMPLIES THE SAVED PROGRAM IS          *
*E*               BIGGER THAN THE PRESENTLY AVAILABLE CORE.            *
************************************************************************
NOTGVP   LI,D1    X'03040A'         ERROR CODE & SUBCODE
         B        CMNERR3
*
*
PGMTYPE  DATA     X'380000'         J:RNST BITS
XCONMSK  DATA     X'1011FFFF'       MASK FOR J:EXTENT
PCFPT    GEN,8,24   X'2C',0         FPT TO SET PROMPT CHAR
SAVEFPT  GEN,8,24   2,0             FPT FOR SAVE CAL
CVMFPT   GEN,1,7,24   1,7,5         FPT FOR SAD CAL
         GEN,1,7,24   1,0,4
         TITLE    'SAVE/GET COMMON ROUTINES'
*        D2=      PLIST
*        R0=      ENTRY
*        R7=      JIT
*
JJEND    RES      0
         CI,R7    J:JIT
         BE       JRDWRT            BR IF SAVE
*
*  VALIDATE MEMORY MANAGEMENT POINTERS
*
         LI,R5    JBUPVP            SET CONTEXT LIMITS
         LW,R4    R7                  TO PASS TESTS BELOW
         AI,R4    J:CLL-J:JIT
         STD,R5   *R4
         LW,R5    R7                ADDRESS OF JIT
         AI,R5    JPLL-2
         LI,R4    5                 # DOUBLEWORDS
JMMLOOP  LD,R2    *R5,R4            GET NEXT PAIR
         CI,R2    X'FFF00'
         BANZ     PAGERR            PAGE NUMBER MUST
         CI,R3    X'FFF00'            BE <= X'FF'
         BANZ     PAGERR
         CW,R2    J:BUP             LOWER LIMIT MUST
         BL       PAGERR              BE >= BUP
         CW,R3    J:EUP             UPPER LIMIT MUST
         BG       PAGERR              BE <= EUP
         STD,R2   J:PLL-2,R4        PUT IN REAL JIT
         BDR,R4   JMMLOOP
         LI,R2    JJITVP
         LI,R3    JBUPVP-1
         STD,R2   J:CLL             SET CONTEXT LIMITS
*
         LI,R5    JBTDP
         LB,SR4   *R7,R5            TOP DYNAMIC PAGE
         CLM,SR4  J:BUP
         BCS,9    PAGERR
         STB,SR4  J:JIT,R5
*
         LI,R5    JBBCP
         LB,SR4   *R7,R5            BOTTOM COMMON PAGE
         CLM,SR4  J:BUP
         BCS,9    PAGERR
         STB,SR4  J:JIT,R5
*
*  READ/WRITE USER PAGES
*
JRDWRT   EQU      %
         LW,R4    R7
         AI,R4    JLMAP             ADDRESS OF LMAP
         LI,R1    JBVLH             HEAD OF LMAP
         LB,R1    *R7,R1            FIRST LMAP ENTRY
         B        JJITLP2
*
JJITLOOP LB,R1    *R4,R1            NEXT LMAP ENTRY
JJITLP2  BEZ      CVMPGS            END OF LMAP
         CI,R1    JBUPVP
         BL       JJITLOOP          IGNORE FPOOL BUFFERS
         CI,R7    J:JIT
         BE       JRW10             BR IF SAVE
         LI,R2    TEL
         SLS,R2   -9
         AI,R2    -1                FIRST PAGE BELOW TEL
         CW,R1    R2
         BG       PAGERR            NO PAGES ALLOWED WHERE TEL IS
         STW,R2   J:EUP             INCREASE J:EUP FOR DELTA DATA
         SLS,R1   9                 WORD ADDRESS
         CAL1,8   =X'84000001'      M:GVP  *R1
         STCF     SR4
         LI,R3    JEUPVP
         STW,R3   J:EUP             RESET J:EUP
         LCF      SR4
         BCS,8    NOTGVP            COULDN'T GET PAGE
         LW,R3    Y6                SET PP SWAP, ALLOW
         STS,R3   J:ASSIGN            READ INTO PROCEDURE
         B        JRW15
*
JRW10    SLS,R1   9                 WORD ADDRESS OF BUFFER
JRW15    LI,R2    2048              BYTE COUNT
         CAL1,1   *D2               READ/WRITE
         SLS,R1   -9
         LW,R2    M:TEL+13          RECORD SIZE
         CI,R2    2048
         BNE      GETNG1            ERROR
         B        JJITLOOP
*
*  PROCESS M:CVM PAGES
*
CVMPGS   EQU      %
         CI,R7    J:JIT
         BE       JJXIT             BR IF SAVE
         LW,SR1   R7
         AI,SR1   JLMAP
         LW,SR2   R7
         AI,SR2   JCMAP
         LI,R1    X'FF'             LAST VIRTUAL PAGE
CVM10    LB,R4    *SR1,R1           GET NEXT LMAP ENTRY
         CI,R4    1
         BNE      CVM20             NOT CVM PAGE
         LOAD,R5  *SR2,R1           PHYSICAL PAGE
         LW,R4    R1                VIRTUAL PAGE
         SLD,R4   9                 CONVERT TO WORD ADDRESSES
         CAL1,8   CVMFPT            M:CVM
         BCS,8    CVMERR            CAN'T DO IT
CVM20    AI,R1    -1
         CI,R1    JBUPVP
         BGE      CVM10             NOT DONE YET
*
JJXIT    B        *R0               DONE
         END

