         DEF      GHOST1D
GHOST1D  CSECT    1
         DEF      GHOST1
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
*
DISCBPROC SET     1
         REF      BOOTFLG
         SYSTEM   UTS
         SYSTEM   BPM
         DEF      PAS0RTN
*
         SREF     COD:LPC
         SREF     CO:RCVDOFF
         SREF     COCINIT
         SREF     LCOC
         SREF     LNOL
         SREF     COCHPB
         SREF     MODE4
         SREF     MODE4INIT
         SREF     COC
         SREF     COH:DN
         SREF     CO:XPSDO
         SREF     COH:II
         SREF     COH:IO
         SREF     NSCPU             #SLAVES
         SREF     SB:RCVR           MASTER RECOVER FLAG
         SREF     SB:RCVA           SLAVE RECOVER FLAG
         SREF     SB:INIT           SLAVE FLAGS
         SREF     SL:BSTRT          SLAVE OVERRIDE FLAG
         REF      XFC               MASK
*
         REF      DCT1,OCNDD
         REF      M:DO,M:LL,M:LO
         REF      LLNDD
         REF      M:BI
         REF         SL:STLM,S:STLC,SL:RSVP,S:ACORE,SL:CORE
         REF      DCT8,RBLIMS
         SREF     HASPIO
         REF      SNDDX
         REF      JX:CMAP
         REF      ERRLOG,RCVCODE
         REF      RECOVER2
         REF      PASS0
         REF      SYSMAK
         REF      DATE
         REF      HGPRECON
         REF      T:GJOBSTRT,S:GJOBTBL,SYSACCT
         REF      DLTBIAS,DLTSZ,LEE20
         REF      MX:PPUT,M:FPPT,M:FPPC,S:PCORE
         REF      T:BTSCHED
         REF      RT:REBOOT
         SREF     RASIZE
         REF      1MIN
         REF,1    JB:PNR
         REF      DUMPFILE
         REF      75BUF
         REF      DCT3,DCT16,DCT24,DCTSIZ
         PCC      0
BOOTYPE  EQU      %
         DATA,2   'NO'
         DATA,2   X'2210'
         DATA,2   X'FFFF'
         DATA,2   X'6C00'
         DATA,2   X'0000'
         DATA,2   X'0001'
#BOOTS   EQU      HA(%)-HA(BOOTYPE)-1
*
*
*        INDEXING THE ABOVE TABLE THE TYPE OF BOOT COMES OUT
*        TO BE:
*
*        INDEXX   TYPE OF BOOT
*        ------   --------------------------
*        0        INDETERMINATE
*        1        COLD TAPE BOOT
*        2        BOOT UNDER FILES
*        3        RAD BOOT
*        4        RECOVERY
*        5        OPERATOR RECOVERY
*
         PAGE
GHOST1   EQU      %
         CAL1,6   MASTER
         LI,6     0
         CW,6     BOOTFLG           DONT RUN IF WE ARE ALREADY UP
         BE       EXIT
         LI,1     M:DO              M:DO DCB
         LI,2     X'3FFF'
         AND,2    LLNDD             'LL' DEVICE ADDRESS
         AI,2     X'4000'           DIAG BIT
         CAL1,1   DEVOPN            OPEN M:DO DCB
         LI,1     M:LO              M:LO DCB
         CAL1,1   DEVOPN            OPEN M:LO DCB
         LI,1     M:LL              OPEN LL
         LC       BOOTFLG           TO 'NO' IF NO LP OUTPUT
         BCS,4    %+2               SET ON ANY RAD BOOT(RECOV, ETC.)
         LI,2     'NO'
         MTB,0    X'2A'             TO SYMB LP IF RECOVERY
         BNEZ     %+2
         LI,2     'LP'
         CAL1,1   DEVOPN
*
*  SET UP PAGE STEALING CELLS SO THAT WRITE-AHEAD CAN
*  BE DONE DURING BOOT
*
         LB,1     SNDDX
         SLS,1    -1
         AI,1     RASIZE            ADD # READ-AHEAD ENTRIES
         STW,1    SL:STLM
         STW,1    S:STLC
         LI,10    3
         LI,11    2
         LI,0     HASPIO
         BNEZ     SETSTL-1
         SREF     2780IO
         LI,0     2780IO
         BEZ      SETSTL1
         LI,11    1
         LW,1     RBLIMS+1
SETSTL   CW,1     RBLIMS
         BL       SETSTL1
         LW,0     DCT8,1
         CI,0     HASPIO
         BE       %+3
         CI,0     2780IO
         BNE      %+2
         AW,10    11
         AI,1     -1
         B        SETSTL
*
SETSTL1  EQU      %
         SLS,10   -1
         STW,10   SL:RSVP
         LW,1     S:ACORE
         SW,1     10
         CW,1     SL:CORE
         BGE      %+2
         STW,1    SL:CORE
         STW,1    S:ACORE
         LCW,10   10
         AWM,10   S:PCORE
*
         LC       X'2A'             GET BOOT TYPE
         BCS,15   PAS0CHK           NOT RECOVERY
RECOV    EQU      %
         BAL,11   RECOVER2
         MTB,-1   ERFLG             ERROR, DONT RESTART USERS
         B        RECVRTN
PAS0CHK  EQU      %
         LI,11    PASS0             EXIT TO PASS0 FROM RECOVER2
         BCS,8    RECOVER2          IF BOOT UNDER FILES
         BCR,4    PASS0             TAPE BOOT
         BAL,11   RECOVER2          RESTORE ZAPPED DATA IF RAD BOOT
         B        RECVRTN
         PAGE
         REF      M:PATCH
CLSPATCH GEN,8,24 X'15',M:PATCH
         DATA     X'80000000',2     CLOSE AND SAVE PATCH FILE
         REF      M:TM
RSTTM    GEN,8,24 X'14',M:TM
         DATA     X'7001'
         DATA     1
         DATA,1   3,,,,4,,,,5,,,,6,,,,11,1,,
OPNDUMP  GEN,8,24 X'14',M:TM
         DATA     X'C5401001'
         DATA     DABN,DABN
         DATA     3,2,2             RANDOM,OUT,SAVE
         PZE      *3
         DATA,1   1,1,3,3
         TEXTC    'DUMPFILE'
DABN     RES
         LI,R2    -1
         STW,R2   DUMPFILE          SET DUMPFILE TO CANT GET FILE
         B        OPNAB
CLSDUMP  GEN,8,24 X'15',M:TM
         DATA     X'80000000',2
PAS0RTN  EQU      %
         CAL1,1   CLSPATCH          CLOSE AND SAVE THE PATCH FILE AFTER DATE
RECVRTN  EQU      %
         BAL,11   SYSMAK            INITIALIZE PROCESSORS
*
*        THE FOLLOWING INSTRUCTION BECOMES A BRANCH IF
*        RECOVER2 OR HGPRECONSTRUCT ABORT
*        USER REINITIALIZATION CODE SHOULD THEREFORE BE
*        PLACED BETWEEN ERFLG AND ERSKIP
*
ERFLG    BCS,0    ERSKIP
         BAL,R11  COCINITNR         BAL/INITIALIZE COC
         BAL,11   T:BTSCHED
         BAL,R11  RT:REBOOT         REAL-TIME USER INITIALIZATION
ERSKIP   EQU      %
         M:PT     1           ****  PUT FPT'S INTO PROT.TYPE 01
         LC       BOOTFLG
         BCR,4    CONTINU     NO--- OUTPUT TO LL
*                             YES--
         LI,R10   0                 =0 DEVICE, >0 CONTROLLER
         LI,R11   -1                1ST TIME FLAG (I.E., DEVICE)
         LI,R1    1                 DCT INDEX (FOR DEVICE)
NXTDEV   EQU      %
         LB,R3    DCT3,R1           GET FLAGS
         CI,R3    DOWND
         BANZ     DEVDOWN     YES-- DEV.PARTITIONED
2NXTDEV  EQU      %           NO---
         AI,R1    1                 2 NEXT DCT
         CI,R1    DCTSIZ
         BLE      NXTDEV      NO--- DONE
         LW,R10   CONT        YES-- SET MESSAGE
         STW,R10  MSGPRT+1            FOR CONTROLLER
         LI,R1    1                 DCT INDEX (FOR CONTROLLER)
NXTCONT  EQU      %
         LB,R3    DCT24,R1          GET FLAGS
         CI,R3    DOWNC
         BANZ     CONTDOWN    YES-- CONT.PARTITIONED
2NXTCONT EQU      %           NO---
         AI,R1    1                 2 NEXT DCT
         CI,R1    DCTSIZ
         BLE      NXTCONT     NO--- DONE
         CI,R11   0           YES--
         BGEZ     ENDPRT      YES-- ANY PARTITIONED ITEMS
*                             NO---
         EXU      VFC:LP
BLNKLN   M:PRINT  (MESS,BLANK)      'BLANK LINE'
         M:PRINT  (MESS,NOPART)     'NOTHING PARTITIONED'
         EXU      BLNKLN            'BLANK LINE'
         B        CONTINU0
*----------------
DEVDOWN  EQU      %
CONTDOWN EQU      %
         AI,R11   1                 SET FLAG TO NOT 1ST TIME
         BGZ      DISPLAY     NO--- WAS THIS THE 1ST TIME
*                             YES--
VFC:LP   EQU      %
         M:DEVICE M:LL,(VFC)  ****  SET VERTICAL CONTROL
TOP:PAGE EQU      %
         M:DEVICE M:LL,(PAGE) ****  TOP OF PAGE
         M:PRINT  (MESS,ITMPRT)     'ITEMS PARTITIONED'
         EXU      BLNKLN            'BLANK LINE'
DISPLAY  EQU      %
         LD,R2    DCT16,R1          GET 'YYNDD'
         SLD,R2   8
         AI,R3    ' '
         STW,R3   MSGPRT+3          PUT 'NDD' INTO MESSAGE
         LI,R3    1
         STH,R2   MSGPRT+2,R3       PUT 'YY' INTO MESSAGE
         M:PRINT  (MESS,MSGPRT)     'DEV/CONT YYNDD PART'
         CI,R10   0
         BEZ      2NXTDEV     YES-- DEV.TYPE
         B        2NXTCONT    NO--- CONT.
*----------------
ENDPRT   EQU      %
         EXU      BLNKLN            'BLANK LINE'
         M:PRINT  (MESS,ENDITMS)    'END OF PART ITEMS'
CONTINU0 EQU      %
         EXU      TOP:PAGE          TOP OF PAGE
CONTINU  EQU      %
         REF      HIGH,SMUIS
         LW,3     HIGH              SET DUMPFILE INFO
         STH,3    DUMPFILE+1
         AI,3     SMUIS+1           PLUS ROOM FOR USER JITS
         CAL1,1   RSTTM             CLEAN OUT THE M:TM DCB
         LI,R2    0                 ZAP RNDEV SO TRY BOTH
         STW,R2   M:TM+5            PACK AND RAD IF NECESSARY
         CAL1,1   OPNDUMP           OPEN THE FILE
         LW,1     M:TM+1            CFUADDRESS
         LW,2     1,1               FDA
         LW,3     5,1               SIZE
         CAL1,1   CLSDUMP
         STW,R2   DUMPFILE+3        FDA OF SUA RANDOM FILE
         STW,R3   DUMPFILE+4        NUMBER OF SECTOES IN FILE
*
         LSECTA,R7  R2
         AI,R7    X'40'             POINT TO DA OF X'4000'
         STSECTA,R7,R11 R2
         LW,R8    R2
         BAL,R11  DSCCVT            GO-CONVERT TO SEEK
         STW,R8   SEEK4000-1        SEEK OF X'4000'
         REF      DSCCVT,SEEK4000
OPNAB    EQU      %
*
*        INSERT SYSTEM START-UP ERROR LOG MESSAGE
*
*
         LI,1     #BOOTS            MAX LOOP
         LH,2     X'2A'             GET INDICATOR
         CH,2     BOOTYPE,1         FIND MATCHUP
         BE       GOTYPE            GOTCHA
         BDR,1    %-2
GOTYPE   LI,10    X'1804'           CODE/COUNT FOR MSG
         LI,3     7                 MASK TO GET
         LS,3     RCVRCNT           COUNT
         REF      RCVRCNT
         STH,3    10                TO PUT AWAY COUNT
         STB,1    10                PUT AWAY TYPE
         SCS,10   16                AND POSITION PROPERLY
         LW,11    TIME              NOW COMPLETE ERROR LOG MSG
         LW,12    DATE+1            YEAR IN EBCDIC
         SLS,12   16                POSITIONED
         LW,13    RCVCODE           GET SCREECH CODE/SUBCODE
         SCS,13   16                POSITION PROPERPY
         STB,13   13
         REF      TIME
         BAL,6    MSMSET            GO SET UP MILS SINCE MIDNIGHT
         LI,6     10                LOC OF ERR MSG
         BAL,5    ERRLOG            AND INSERT IT INTO LOG
         LI,1     0                 SET RUNNING FILA
         STW,1    BOOTFLG
*
         LD,0     TXCRBBAT
         BAL,10   T:GJOBSTRT        START SYMBIONT GHOST
*  NOTE:  ANLZ MUST BE FIRST GHOST STARTED AFTER RBBAT
         MTB,0    X'2A'
         BNEZ     LOGRCVG
         CAL1,9   6                 SUPER CLOSE
         LD,0     ANLZT
         BAL,10   T:GJOBSTRT        START ANLZ
*
LOGRCVG  EQU      %
         MTW,0    DUMPFILE
         BLEZ     %+3               SINGLE USER ABORT 'DUMPFILE' FREE
         LD,0     TXCRVGST
         BAL,10   T:GJOBSTRT        START THE RECOVER GHOST
*  START ERR:FIL
*
         LD,R0    TXCE:FIL
         BAL,R10  T:GJOBSTRT
         LW,R0    75BUF
         BLZ      LOGFIL            NO AUTO START UP
         LD,R0    FNAME
         BAL,R10  T:GJOBSTRT        START IT
*
LOGFIL   EQU      %
         LI,1     NSCPU             MP SYSTEM
         BEZ      LOGFIL2           NO
         LI,0     0
         STW,0    SB:RCVR           ZERO OUT MASTER RCVR FLAG
         STW,0    SB:RCVA           ZERO OUT SLAVE RCVR FLAG
         MTW,0    SL:BSTRT          SLAVE OVERRIDE SET
         BEZ      GOGJOB            NO,  START MOOSE
MOSTOP   LB,10    SB:INIT,1         GET FLAGS
         AND,10   XFC               MASK OUT START/STOP
         AI,10    2                 SET STOP FLAG
         STB,10   SB:INIT,1         RESTORE FLAG
         BDR,1    MOSTOP            DONE ALL
         B        LOGFIL2           YES,SKIP MOOSE
GOGJOB   EQU      %
         LD,0     TXMOOSE           NO OVERRIDE,START
         BAL,10   T:GJOBSTRT        MOOSE
LOGFIL2  EQU      %
         NOP
         LI,1     JB:PNR
         LB,1     0,1               GHOST1/FILL USER NUMBER
         LD,6     FILLT
         STD,6    S:GJOBTBL,1       CHANGE GHOST1 ENTRY INTO FILL
         LI,0     0
         LCI      15
         STM,0    1                 CLEAR ALL REGISTERS TO ZERO
         LD,6     FILLT
         LCI      2
         LM,13    SYSACCT
EXIT     EQU      %
         CAL1,9   1                 EXIT TO FILL
         BOUND    8
ANLZT    TEXTC    'ANLZ'
FILLT    TEXTC    'FILL'
TXCRBBAT TEXTC    'RBBAT'
TXCRVGST TEXTC    'RVGHOST'
FNAME    TEXTC    'FREPORT'
TXCE:FIL TEXTC    'ERR:FIL'
TXMOOSE  TEXTC    'MOOSE'
MASTER   DATA,1   8,0,0,0
         PAGE
********
DOWND    EQU      X'20'             DEV.DOWN
DOWNC    EQU      X'04'             CONT.DOWN
********
CONT     TEXT     'CONT'
********
BLANK    EQU      %
         TEXTC    ' '
********
NOPART   EQU      %
         TEXTC    '*** NOTHING PARTITIONED'
********
ITMPRT   EQU      %
         TEXTC    '***** ITEMS PARTITIONED ******'
********
MSGPRT   EQU      %
         TEXTC    '   DEV   YYNDD     PARTITIONED'
********
ENDITMS  EQU      %
         TEXTC    '** END OF PARTITIONED ITEMS **'
********
         PAGE
*        .RMA TIME CHANGE
*
*        CHANGE TIME IN R11 INTO MCS
*
         REF      C:MSM
*
MSMSET   LW,14    11                HHMM IN 11 RIGHT NOW
         AND,14   =X'0F0F0F0F'      MASK IT
         LB,3     14                GET FIRST BYTE OF HOUR
         MI,3     10                CHANGE RESOLUTION
         SLS,14   8                 SHIFT NEXT BYTE OVER
         LB,5     14                GET NEXT BYTE OF HOUR
         AW,3     5                 ADD EM UP
         SLS,14   8                 SHIFT OVER TO FIRST BYTE OF MIN
         LB,5     14                GET IT
         MI,5     10
         SLS,14   8                 NEXT BYTE OF MIN
         LB,2     14
         AW,5     2                 ADD UP MINUTES
         MI,5     60                CHANGE MINUTES TO SECONDS
         MI,3     60*60             CHANGE HOURS TO SECONDS
         AW,5     3                 ADD UP TOTAL SECONDS
         MI,5     500               THE WHOLE THING INTO MILSECS
         STW,5    C:MSM             STORE IT AWAY
         B        0,6               RETURN
         PAGE
********************************************************************************
*
*  COC INITIALIZATION
*
*  RETURN IF THIS IS A NON-COC SYSTEM.
*
*  SET UP THE COC INPUT AND OUTPUT INTERRUPT XPSD INSTRUCTIONS.
*
*  IF THIS IS A RAD OR TAPE BOOT (AS OPPOSED TO A RECOVERY),
*  AND IF SENSE SWITCH 2 IS IN THE UP POSITION,
*  WE EXECUTE A 'TURN RECEIVER L DATASET OFF - TURN BACK-TO-BACK
*  TEST OFF' WRITE DIRECT TO EACH RECEIVER.  THIS IS IN CASE THE CE'S
*  HAVE TURNED THE BACK-TO-BACK TEST FEATURE ON WITH THEIR DIAGNOSTICS.
*  WE THEN DELAY FOR AT LEAST 80 MILLI-SECONDS BEFORE TURNING THE
*  RECEIVERS ON (IN COCINIT).  NOTE THAT THIS WILL HANG UP THE
*  PHONE LINE IF DIAL-UP.
*
*  CALL COCINIT (IN THE COC MODULE IN THE ROOT) TO COMPLETE
*  INITIALIZATION.
*
********************************************************************************
COCINITNR    EQU  %
         LI,R0    COC               SEE IF NON-COC SYSTEM
         BEZ      *R11              B/NON-COC; RETURN
*******************************************************************************
*  STEAL ENOUGH COC BUFFERS TO PROVIDE A TABLE (MODE4INIT) PARALLEL
*  TO MODE4 FOR LOGON INITIALIZATION PURPOSES.
*******************************************************************************
         LI,R0    LNOL-1+16         L/# OF LINES-1+16
         SLS,R0   -4                /16; G/# BUFFERS; 16 BYTES/BUFFER
         SLS,R0   2                 X4; G/# WORDS; 4 WORDS/BUFFER
         AWM,R0   COCHPB            BUMP COCBUF FREE POOL POINTER
         LW,R1    MBSMD4            L/SET-UP FOR MBS
         MBS,R1   BA(MODE4)-BA(MODE4INIT)    M/MODE4 TO MODE4INIT
         LI,R3    0                 L/0; COC #
CINIT050 EQU      %
         LW,R1    CO:XPSDO,R3       L/OUTPUT INTERRUPT XPSD INSTRUCTION
         LH,R5    COH:IO,R3         L/OUTPUT INTERRUPT ADR
         STW,R1   0,R5              S/XPSD
         AI,R3    1                 +1 TO COC #
         CI,R3    LCOC              C/COC # W/LAST COC #
         BLE      CINIT050          BLE; SET UP NEXT COC'S INTERRUPTS
*******************************************************************************
*  NOP THE FOLLOWING INSTRUCTION TO TURN ON THE BACK-TO-BACK MODE CHECK.
*******************************************************************************
         B        COCINIT           B/COCINIT; NO BACK-TO-BACK MODE TESTS
         LC       X'2A'             CHECK TYPE OF SYSTEM STARTUP
         BCR,15   COCINIT           B/RECOVERY; DON'T TURN DATA SETS OFF;
*                                      GO TO COCINIT; R11 IS RETURN REG
         RD,0     0                 CHECK SENSE SWITCHES
         BCR,4    COCINIT           B/SS2 DOWN; DON'T CHECK BACK-TO-BACK
         LI,R3    0                 L/0; COC NUMBER
NXTCOC   EQU      %
         LH,R0    COH:DN,R3         L/COC DEVICE ADR
         :TIO,R0  *R0               TIO, SEE IF COC IS THERE
         BCS,12   GTNXTCOC          B/COC NOT THERE; SKIP TO NEXT
         LI,R7    0                 L/0; LINE NUMBER
NXTLINE  EQU      %
         EXU      CO:RCVDOFF,R3     TURN RECEIVER L DATASET OFF -
*                                   TURN BACK-TO-BACK TEST OFF
         AI,R7    1                 +1 TO LINE NUMBER
         LD,R4    COD:LPC,R3        L/LIMITS OF LOGICAL LINES FOR COC
         SW,R5    R4                LAST PHYSICAL LINE # = LAST LOGICAL -
*                                   FIRST LOGICAL LINE #
         CW,R7    R5                C/CURRENT LINE # W/LAST LINE #
         BLE      NXTLINE           BLE; CHECK NEXT LINE
GTNXTCOC EQU      %
         AI,R3    1                 +1 TO COC NUMBER
         CI,R3    LCOC              C/CURRENT COC # W/LAST COC #
         BLE      NXTCOC            BLE; CHECK NEXT COC
         LI,R8    X'17000'          DELAY FOR AT LEAST 80 MILLI-SECONDS
         BDR,R8   %                    BEFORE INITIALIZING COC
         B        COCINIT           B/COCINIT; R11 IS RETURN REG
MBSMD4   GEN,8,24 LNOL,BA(MODE4INIT)
         PAGE
*
*
DEVOPN   GEN,1,7,7,17  1,X'14',0,1  OPEN *1
         DATA     X'00040003'       DEVICE
         PZE      *2
         END      GHOST1

