         SYSTEM   SIG7FDP
         PCC      0
*
         DEF      PCPNAME,JDLNAME,GPATCH,OCPGST
*
         REF      SSTAT,DCT16
         REF      SSIG,DCT8,OCPIO,SNDDX,OCPFLGS
         REF      DCT7,J:JIT,GMB,NEWQ,DCT1,RMB
         REF      M:EI,M:EO,M:OC,M:LL
*
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
*
BOOT     EQU      1
BACKUP   EQU      2
BOTTYC   EQU      6
REWBIT   EQU      X'10'
RUNBIT   EQU      X'20'
*
BUFSIZ   EQU      1024*4
*
FC       EQU      1
PRI      EQU      X'FF'
NRT      EQU      1
*
PX       SET      2                 TURN PROC EXPANSION ON
PX       SET      1                 TURN PROC EXPANSION OFF
         PAGE
*
* THIS PROGRAM OPERATES IN TWO PARTS
*
*        1) AS A GHOST PROGRAM (LOAD MODULE NAME = OCPGHST) WHO
*           IS CALLED VIA KEYIN WHEN KEYIN DETECTS A !SNNXXX,B.
*           THE GHOSTS RESPONSIBILITY IS THE LOADING OF THE
*           PRINTER CONTROL PROGRAM (FILE NAME = PCP) AND THE
*           JOB DESCRIPTOR LIBRARIES (FILE NAME = JDL) INTO
*           THE OCP.
*
*        2) AS A BATCH OR ON-LINE PROGRAM WHO IS CALLED VIA A
*           !OCPGHST. THE PROGRAMS RESPONSIBILITY IS TO BUILD
*           FROM A SOFTWARE SUPPLIED PRINTER CONTROL PROGRAM
*           TAPE, A PCP FILE (FILE NAME = PCP), AND FROM A USER
*           SUPPLIED TAPE OR FILE, A JOB DESCRIPTOR LIBRARY
*           FILE (FILE NAME = JDL).
*
*           THE INPUT IS READ THRU THE M:EI DCB AND MUST BE
*           PROPERLY ASSIGNED.
*           THE OUTPUT IS WRITTEN THRU THE M:EO DCB AND MUST
*           BE PROPERLY ASSIGNED.
*
         PAGE
*
* SAMPLE JCL FOR THE CREATION OF BOTH PCP AND JDL FILES
*
*        1) PCP FILE
*
*           !JOB ACCN,NAME,PRI
*           !ASSIGN M:EI,(DEVICE,9T),(INSN,XXXX)
*           !ASSIGN M:EO,(FILE,PCP)
*           !OCPGHST
*
*        2) JDL FILE
*
*           !JOB ACCN,NAME,PRI
*           !ASSIGN M:EI,(FILE,USERFILE) OR (DEVICE,9T),(INSN,XXXX)
*           !ASSIGN M:EO,(FILE,JDL)
*           !OCPGHST
*
         PAGE
*
* ERROR MESSAGES - THEIR MEANING
*
* 1) BOOT - CAN'T GET MASTER MODE
*    PRIVILEGE LEVEL OF GHOST JOB IS NOT HIGH ENUFF
*    FOR THE EXECUTION OF AN M:SYS CAL
*
* 2) BOOT - CAN'T FIND DCT INDEX OF XEROX PRINTER
*    THE GHOST JOB IS UNABLE TO FIND THE 'B' (BOOT)
*    IN SSIG (SYMBIONT SIGNAL)
*
* 3) BOOT - DEVICE OTHER THAN A XEROX PRINTER
*    A 'B' (BOOT) WAS ATTEMPTED ON A DEVICE THAT WAS
*    NOT A XEROX PRINTER (1200)
*
* 4) BOOT - CAN'T OPEN PCP FILE
*    THE PCP FILE DOES NOT EXIST OR IT IS BUSY
*
* 5) BOOT - READ ERROR ON PCP/JDL FILE
*    READ ERROR OCCURED WHILE READING THE PCP OR JDL
*    FILE
*
* 6) BOOT - ERROR RETURN FROM NEWQ
*    WHEN AN ATTEMPT WAS MADE TO SEND DATA TO THE XEROX
*    PRINTER, THE I/O SYSTEM REJECTED THE DEVICE. THIS
*    SHOULD NEVER HAPPEN
*
* 7) BOOT - BACKUP THRU BEGINNING OF FILE
*    THE XEROX PRINTER ATTEMPTED TO BACK UP RECORDS AND
*    IN THE PROCESS, BACKED UP TOO FAR. RESET THE XEROX PRINTER
*    AND BOOT AGAIN.
*
* 8) NNDDD - NOT RUN STATUS
*    ANYTIME THE XEROX PRINTER HALTS WITH A STATUS CODE
*    DISPLAYED, IT IS NOT IN THE RUN STATUS
*
* 9) ERROR OPENING/WRITING PCP/JDL FILE
*    AN OPEN ERROR OR WRITE ERROR OCCURED WHILE
*    CREATING THE PCP OR JDL FILE
*
*10) ERROR READING INPUT
*    WHILE CREATING THE PCP OR JDL FILE, AN ERROR OCCURED
*    ON THE INPUT DEVICE
*
*11) BOOT - BAD PCP FILE
*    AN END OF FILE WAS ENCOUNTERED DURRING THE BOOT OF THE
*    PCP FILE. AN END OF FILE SHOULD NOT BE ENCOUNTERED
*
*12) FINI
*    PCP/JDL FILE WAS CREATED SUCCESSFULLY
*
         PAGE
*
* PROCS USED BY PROGRAM
*
SETXT    CNAME
         PROC
         USECT    TXT%
P%       SET      %
         TEXTC    AF
         USECT    PROG%
         LI,R10   P%
         PEND
*
SEND     CNAME    0
SEND1    CNAME    1
         PROC
         LIST     PX-1
LF       EQU      %
         SETXT    AF
         DO       NAME=1
         BAL,R9   SETDEV
         FIN
         CAL1,2   TYPE
         LIST     PX
         PEND
*
TEXIT    CNAME    0
TEXIT1   CNAME    1
         PROC
         DISP     %
         LIST     PX-1
LF       EQU      %
         DO       NAME=1
         LW,R8    R10
         SETXT    AF
         BAL,R9   SETABN
         ELSE
         SETXT    AF
         FIN
         CAL1,2   TYPE
         B        ZAPSTAT
         LIST     PX
         PEND
*
PEXIT    CNAME    0
PEXIT1   CNAME    1
         PROC
         DISP     %
         LIST     PX-1
LF       EQU      %
         DO       NAME=1
         LW,R8    R10
         SETXT    AF
         BAL,R9   SETABN
         ELSE
         SETXT    AF
         FIN
         CAL1,2   PRINT
         CAL1,9   1
         LIST     PX
         PEND
*
:BTBL    CNAME
         PROC
         DATA,1   AF-BASE:
         PEND
*
         PAGE
*
TXT%     CSECT    0
PROG%    CSECT    0
*
BASE:    EQU      %                 MUST BE FIRST LOC IN PROG%
*
* START OF PROGRAM - GET MASTER MODE
*
OCPGST   LW,R0    Y4
         CW,R0    J:JIT             ARE WE A GHOST
         BAZ      CPYPPJE           NO-BUILD PCP/JDL FILE
         CAL1,6   SYS               GET MASTER
         BCR,8    WEGOTIT           GO
         TEXIT    'BOOT - CAN''T GET MASTER MODE'
*
* LOOK FOR 'B' IN SSIG
*
WEGOTIT  LB,R1    SNDDX             R1 # OF SYMB DEVICES
WEGOT0   LB,R0    SSIG,R1           SYMBIONT SIGNAL
         CI,R0    'B'               BOOT
         BE       CHKOCP            YEP
         BDR,R1   WEGOT0
         TEXIT    'BOOT - CAN''T FIND DCT INDEX OF XEROX PRINTER'
*
* CHECK IF 'B' BELONGS TO OCP
*
CHKOCP   STW,R1   SYMINDX           SAVE FOR LATER
         LB,R1    SNDDX,R1          R1 DCT X
         LW,R0    DCT8,R1           R0 PRE-PROCESSOR
         CI,R0    OCPIO             DOES IT POINT TO OCP
         BE       WEGO              YES
         TEXIT    'BOOT - DEVICE OTHER THAN A XEROX PRINTER'
*
* CLEAR FLAGS IN HANDLER AND SET TO LOAD PCP FILE
*
WEGO     STW,R1   DCTX              SAVE DCT INDEX
         LH,R1    DCT7,R1           R1 DBL WD ADD OF COMLIST
         SLS,R1   1                 TO WORD ADD.
         STW,R1   COMLSTAD          SAVE IT
         BAL,R7   CLRFLGS           CLEAR THE HANDLERS FLAGS
         LI,R0    PCPNAME           POINT TO PCP NAME
*
* READ THE PCP/JDL AND SEND TO THE OCP
*
LOAD     LCI      8
         LM,R1    *R0               GET NAME
         STM,R1   OPENEINM          AND SET INTO OPEN FPT
         CAL1,1   OPENEI            OPEN IT
READ     CAL1,1   READEI            READ IT
         LW,R7    M:EI+4            GET RECL
         SLS,R7   -17
         STW,R7   EIRECL            AND SAVE IT
         MTW,1    EICNT             BUMP RECORD COUNTER
READ0    BAL,R7   GETBUF            SET END AC INTO MON BUFF
         BAL,R7   SETQARGS          SET ARGS FOR NEWQ
         BAL,R7   CHKSTAT           CHECK STATUS BEFORE WE SEND
         BAL,R11  NEWQ              GO
         B        NOOCP             OCP DISAPPEARED
*
* RETURN FROM NEWQ
*
         LW,R1    MONBUF            R1 ADD OF MON BUFF
         LW,R14   MONBUF            R14 SET FOR RELEASE
         LW,R10   TYC,R1            GET TYC
         BAL,R11  RMB               RELEASE THE BUFFER
         LB,R1    R10               TYC
         CI,R1    BOTTYC            IS TYC RECOGNIZABLE
         BG       READ              NOPE
         LB,R1    OCPTYCBT,R1       GET DISP
         B        BASE:,R1          AND GO
*
* BRANCH TABLE FOR END ACTION
*
OCPTYCBT EQU      %                 TYC
         :BTBL    READ              0
         :BTBL    READ              1
         :BTBL    OCPBKUP           2
         :BTBL    READ              3
         :BTBL    READ              4
         :BTBL    READ              5
         :BTBL    DONE              6
*
         BOUND    4
*
         PAGE
*
* OCP REQUESTED BACKUP
*
OCPBKUP  INT,R1   R10               R1 COUNT
         CI,R1    X'FFFF'           IS IT ALL (REWIND)
         BE       OCPREW            REWIND
         CAL1,1   PRECORD           BACKUP
         BDR,R1   %-1
         B        READ              AND READ
*
* REWIND ENCOUNTERED
*
OCPREW   CAL1,1   PFIL              REWIND
         B        READ              GO
*
OPENEI   GEN,8,24 20,M:EI
         DATA     X'C0000001'
         DATA     ABNOPN
         DATA     ABNOPN
         DATA     X'01010808'
OPENEINM RES      8
READEI   GEN,8,24 16,M:EI
         GEN,4,28 7,0
         DATA     ABNRD
         DATA     BUFF
         DATA     BUFSIZ*4
PRECORD  GEN,8,24 29,M:EI
         DATA     X'C0000010'
         DATA     1
         DATA     ABNPRE
PFIL     GEN,8,24 28,M:EI
         DATA     X'10'
SYS      GEN,8,24 8,0
PRINT    GEN,8,24 1,0
         PZE      *0
         PZE      *R10
TYPE     GEN,8,24 2,0
         PZE      *0
         PZE      *R10
Y4       DATA     X'40000000'
DCTX     DATA     0
COMLSTAD DATA     0
MONBUF   DATA     0
EICNT    DATA     0
EIRECL   DATA     0
PCPNAME  TEXTC    'PCP'
         RES      7                 FOR GENMDS TO NAME
JDLNAME  TEXTC    'JDL'
         RES      7                 ...DITTO
*
         PAGE
*
* ABNORMAL FROM PCP/JDL OPEN
*
ABNOPN   MTW,0    JDLFLG            IS OPEN ON JDL
         BNEZ     DONE0             THATS O.K
         TEXIT1   'BOOT - CAN''T OPEN PCP FILE. XX-XX'
*
* ABNORMAL FROM PCP/JDL READ
*
ABNRD    LB,R8    R10               GET ABN CODE
         CI,R8    6                 EOF
         BE       ABNRD0            YES
         TEXIT1   'BOOT - READ ERROR ON PCP/JDL FILE. XX-XX'
ABNRD0   MTW,0    JDLFLG            ON JDL
         BNEZ     ABNRD1            YES
         TEXIT    'BOOT - BAD PCP FILE'
ABNRD1   MTW,0    EICNT             ANY RECORDS IN AT ALL
         BEZ      DONE0             YES
         LI,R7    0
         STW,R7   EIRECL            SET NULL RECORD
         B        READ0             AND SEND IT
*
* ERROR FROM NEWQ
*
NOOCP    TEXIT    'BOOT - ERROR RETURN FROM NEWQ'
*
* ABNORMAL FROM PRECORD
*
ABNPRE   LW,R1    M:EI+4
         SLS,R1   -17               # LEFT
         AI,R1    0
         BEZ      READ              O.K
         TEXIT    'BOOT - BACKUP THRU BEGINNING OF FILE'
*
         PAGE
*
* DONE - CONTINUE IF PCP JUST LOADED
*
DONE     CAL1,1   CLOSEEI           CLOSE PCP/JDL FILE
         BAL,R7   CLRFLGS           CLEAR HANDLERS FLAGS
         LW,R0    JDLFLG            DID WE LOAD JDL
         BEZ      DONE1             NOPE - GO LOAD IT
         STW,R0   OCPFLGS,R2        YES - SET BOOT BIT
         SEND1    '      - JDL LOADED'
DONE0    TEXIT    'BOOT - INITIALIZATION COMPLETE'
DONE1    SEND1    '      - PCP BOOTED'
         MTW,BOOT JDLFLG            SET FLAG
         MTW,1    TYPFLG            DON'T TYPE MESSAGE
         BAL,R7   CHKSTAT0          WHILE STATUS CHECKING
         LI,R0    0
         STW,R0   EICNT             ZAP RECORD COUNTER
         LI,R0    JDLNAME           POINT TO JDL
         B        LOAD              AND LOAD IT
*
JDLFLG   DATA     0
CLOSEEI  GEN,8,24 21,M:EI
         PZE      *0
         DATA     2
*
         PAGE
*
* CLEAR HANDLERS FLAGS
*
CLRFLGS  LW,R2    COMLSTAD          R2 ADDRESS OF COMLIST
         LI,R10   0
         LCI      #WDS              NUMBER OF WORDS TO CLEAR
         STM,R10  R11               CLEAR REGS
         STM,R10  OCPFLGS,R2        CLEAR HANDLER
         B        0,R7              RETURN
*
* GET A MONITOR BUFFER AND MOVE END ACTION INTO IT
*
GETBUF   BAL,R11  GMB               GET A BUFFER
         BNEZ     GETBUF0           WE GOT ONE
         CAL1,8   SLEEP             WAIT A WHILE
         B        GETBUF
GETBUF0  STW,R14  MONBUF            SAVE ITS ADDRESS
         LCI      EASZ              SIZE OF END ACTION ROUTINE
         LM,R10   ENDAC             GET IT
         STM,R10  *R14              AND STORE
         B        0,R7              RETURN
*
* SET ARGS FOR NEWQ
*
SETQARGS LCI      4
         LM,R12   NQARGS            GET ARGS
         OR,R12   DCTX              R12 FC,PRI,NRT,DCTX
         LW,R14   EIRECL            GET RECORD LEN.
         LW,R0    MONBUF            END ACTION ADD
         LW,R1    MONBUF            END ACTION INFO
         B        0,R7              RETURN
*
* CHECK STATUS OF OCP
*
CHKSTAT  LI,R4    0
         STW,R4   TYPFLG            ZAP PRINT FLAG
CHKSTAT0 LW,R2    DCTX              DCTX OF OCP
         LH,R2    DCT1,R2           R2 DEVICE ADDRESS
CHKSTAT1 TDV,R4   0,R2              GET STATUS
         LB,R4    R5                RUN BITS
         CI,R4    RUNBIT+REWBIT     IS IT RUN OR REWIND
         BANZ     0,R7              YES -GO
         MTW,0    TYPFLG            HAVE WE SENT A MESSAGE
         BNEZ     CHKSTAT2          YES
         MTW,1    TYPFLG            SET FLAG
         SEND1    '      - NOT RUN STATUS'
CHKSTAT2 CAL1,8   SLEEP             WAIT FOR A WHILE
         B        CHKSTAT1          TRY AGAIN
*
* CLEAR SSTAT AND SSIG TO ALLOW SYMBIONT TO RUN
*
ZAPSTAT  LW,R1    SYMINDX           GET INDEX INTO TABLE
         BLZ      ZAPSTAT0          NEVER FOUND IT
         LI,R0    0                 SET FRO ZAP
         STB,R0   SSTAT,R1          SET SYMBIONT NOT BUSY
         STB,R0   SSIG,R1           CLEAR THE 'B'
ZAPSTAT0 CAL1,9   1                 EXIT
*
* SET NNDDD INTO MESSAGE
*
SETDEV   LW,R5    DCTX              DCT INDEX OF DEVICE
         LD,R4    DCT16,R5          GET NAME
         SLD,R4   24
         SLD,R4   -8
         LW,R6    R10               R6 MESSAGE ADDRESS
         OR,R4    0,R6
         OR,R5    1,R6              PACK WITH REST OF MESSAGE
         LCI      2
         STM,R4   0,R6              PUT AWAY
         B        *R9               RETURN
*
* SET ABN CODE AND SUB CODE INTO MESSAGE
*
SETABN   LB,R3    R8                GET CODE
         LB,R6    *R10              R6=BYTE COUNT OF MESSAGE
         AI,R6    -4                BACK OFF TO CODE
         BAL,R7   CONVERT           CONVERT TO EBCDIC
         AI,R6    1                 POINT TO SUBCODE
         SLS,R8   8                 GET SUB CODE
         SLS,R8   -1                ONLY 7 BITS
         LB,R3    R8
         BAL,R7   CONVERT           CONVERT TO EBCDIC
         B        *R9               DONE
*
* CONVERT HEX TO EBCDIC AND STORE IN MESSAGE
*
CONVERT  LI,R1    2                 LOOP TWICE
         STB,R3   R3                LEFT JUSTIFY
CONV0    LI,R2    0                 CLEAR FOR SHIFT
         SLD,R2   4                 GET FOUR BITS
         AI,R2    '0'               MAKE EBCDIC
         CI,R2    '9'               IS IT ZERO THRU NINE
         BLE      %+2               YES
         AI,R2    -X'39'            NOPE - MAKE IT A THRU F
         STB,R2   *R10,R6           PUT IN MESSAGE
         AI,R6    1                 BUMP FOR NEXT
         BDR,R1   CONV0
         B        0,R7              RETURN
*
* END ACTION ROUTINE - GETS MOVED TO MONITOR BUFFER
*
ENDAC    LW,R1    R14               R1 IS WHERE WE ARE
         STW,R12  TYC,R1            SET TYC IN
         B        *R11              RETURN TO I/O
ENDACEND EQU      %
*
#WDS     EQU      3
EASZ     EQU      ENDACEND-ENDAC
TYC      EQU      EASZ
NQARGS   GEN,8,8,8,8 FC,PRI,NRT,0
         DATA     BA(BUFF)          BUFF ADD (BYTE)
         DATA     0                 RECL
         DATA     0                 SEEK
SLEEP    GEN,8,24 15,4
TYPFLG   DATA     0
SYMINDX  DATA     -1
*
         PAGE
*
* OPEN OUTPUT FILE KEYED
*
CPYPPJE  CAL1,1   CPYOPNEO          OPEN THE OUTPUT FILE
*
* READ RECORDS FROM EI
*
CPYRD    CAL1,1   CPYRDEI           GET INPUT
         LI,R1    0
         STW,R1   CPYEOFCT          WE DIDN'T GET AN EOF
         LW,R1    M:EI+4
         SLS,R1   -17               RECL
         BAL,R7   CPYSND            WRITE RECORD KEYED
         B        CPYRD
*
* WRITE RECORDS TO EO
*
CPYSND   CAL1,1   CPYWTEO           WRITE IT
         MTW,1    CPYKBUFF+1        BUMP KEY
         B        0,R7              RETURN
*
CPYOPNEO GEN,8,24 20,M:EO
         DATA     X'C5400001'
         DATA     CPYABNO
         DATA     CPYABNO
         DATA     2
         DATA     2
         DATA     2
         DATA     X'10000'
CPYRDEI  GEN,8,24 16,M:EI
         GEN,4,28 7,0
         DATA     CPYABR
         DATA     BUFF
         DATA     BUFSIZ*4
CPYWTEO  GEN,8,24 17,M:EO
         DATA     X'78000060'
         DATA     CPYABNO
         DATA     BUFF
         PZE      *R1
         DATA     CPYKBUFF
CPYKBUFF GEN,8,8,8,8 7,'O','C','P'
         DATA     0
CPYEOFCT DATA     0
*
         PAGE
*
* ABNORMAL FROM OPENING OUTPUT FILE
*
CPYABNO  PEXIT1   'ERROR OPENING/WRITEING PCP/JDL FILE. XX-XX'
*
* ABNORMAL FROM READING INPUT FILE
*
CPYABR   LB,R8    R10               GET CODE
         CI,R8    5                 EOD
         BE       CPYABR0
         CI,R8    6                 EOF
         BE       CPYABR0           YES
         PEXIT1   'ERROR READING INPUT. XX-XX'
CPYABR0  MTW,1    CPYEOFCT          BUMP COUNT
         LW,R1    CPYEOFCT          GET IT
         CI,R1    2                 TWO CONSEC EOFS
         BE       CPYABR1           YES
         BAL,R6   CPYSNULL          NO-SEND NULL RECORD
         B        CPYRD
CPYABR1  BAL,R6   CPYSNULL          SEND NULL RECORD
         CAL1,1   CPYCLSEI          CLOSE INPUT
         CAL1,1   CPYCLSEO          CLOSE OUTPUT
         PEXIT    'FINI'
*
CPYCLSEO GEN,8,24 21,M:EO
         PZE      *0
         DATA     2
CPYCLSEI GEN,8,24 21,M:EI
         PZE      *0
         DATA     2
*
         PAGE
*
* SEND NULL RECORDS TO OUTPUT FILE
*
CPYSNULL LI,R1    0                 RECL
         BAL,R7   CPYSND            SEND IT
         B        0,R6              RETURN
*
BUFF     RES      BUFSIZ
GPATCH   RES      50
*
         END      OCPGST

