*M*      INITIAL  MONITOR INITIALIZATION ROUTINE - RESIDENT
*P*
*P*      NAME:    INITIAL
*P*
*P*      PURPOSE: INITIALIZATION ROUTINE FOR RESIDENT MONITOR
*P*
*P*      DESCRIPTION: (1) SETS UP TRAP AND INTERRUPT LOCATIONS
*P*                   (2) BALS TO BOOTSUBR FOR FURTHER INITIALIZATION
*P*                                 AND/OR TAPE BOOT PROCESS
*P*                   (3) SETS UP THE HARDWARE WRITE LOCKS AND MAP
*P*                   (4) BUILDS MONITOR JIT
*P*                   (5) INITIATES ALLOCAT AND GHOST1
*P*                   (6) STARTS UP SYSTEM BY EXITING TO SCHEDULER
*P*
         PCC      0
         TITLE    'INITIAL - MONITOR INITIALIZATION ROUTINE'
         DEF      INITIAL:          MODULE NAME
INITIAL: EQU      %
DEBUG    SET      0                 SET TO 1 TO INCLUDE ABS PATCHER
OC       EQU      2
BITS     SET      1                 GET BT31TO0 AND MASKS
         SYSTEM   UTS
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 AND DEFS
         SPACE
         REF      NOPPSD            TRAP 40
         REF      UNIMPPSD          TRAP 41
         REF      STKLPSD           TRAP 42
         REF      FIXOVPSD          TRAP 43
         REF      FLTFPSD           TRAP 44
         REF      DECFPSD           TRAP 45
         REF      PSD%T46           TRAP 46 WATCHDOG TIMER
         REF      IPT47             TRAP 47 INTER-PROCESSOR TRAP
         REF      CAL1PSD           TRAP 48
         REF      CAL2PSD           TRAP 49
         REF      J:ALB             TRAP 4A VECTOR IN THE JIT
         REF      CAL4PSD           TRAP 4B
         REF      PSD%T4C           TRAP 4C HARDWARE ERROR TRAP
         REF      PSD%T4D           TRAP 4D REG EXCEPTION TRAP
         REF      LEE20             TRAP 4E XDLT ENTRY
         REF      POWRON            TRAP 50
         REF      POWROFF           TRAP 51
         REF      TINC              INTR 54 CLOCK 3 PULSE
         REF      S:CLOCK4          INTR 55 CLOCK 4 PULSE (         SPACE)
         REF      PSD%I56           INTR 56 MEM PE INTR OR PFI
         REF      PSD%I57           INTR 57 MEM FLT INTR
         REF      CLK3PSD           INTR 5A CLOCK3 ZERO
         REF      CLK4PSD           INTR 5B CLOCK4 ZERO
         REF      IOPSD             INTR 5C
         REF      OCPSD             INTR 5D
         SPACE
         REF      MONORG            START OF RESIDENT CODE
         SPACE
         REF      BOOTHLT           EMERGENCY HALT (BOOT OC INTR)
         SPACE
         REF      MONINIT           ENTRY POINT TO BOOTSUBR
         SPACE
         REF      PSA%END           SET UP FOR RECOVERY
         REF      HGP               SET UP FOR RECOVERY
         REF      BOOTSBAND         SET UP FOR RECOVERY
         REF      BOOTFLG           SIZE OF XDELTAS PATCH FILE
         SPACE
         REF      MB:GPT            USED TO REL GHOST1 SW SPACE
         REF      SL:CORE           USED TO REL GHOST1 SW SPACE
         REF      T:SGRNU           USED TO REL GHOST1 SW SPACE
         REF      MB:GAM4           USED TO REL GHOST1 SW SPACE
         SPACE
         REF      S:GJOBTBL         USED TO START ALLOCAT & GHOST1
         REF      MING              USED TO START ALLOCAT & GHOST1
         REF      T:GJOBSTRT        USED TO START ALLOCAT & GHOST1
         SPACE
         REF      SPOOL             INITIALIZED TO ZERO
         SPACE
         REF      T:SE              ENTRY TO SCHEDULER
         SPACE
         SREF     PPTABLE,PPTABLSZ  USED TO SET UP WRITE LOCKS
         SREF     SIM5BEG,SIM5END   USED TO SET UP WRITE LOCKS
         REF      PPSTART           USED TO SET UP WRITE LOCKS
         REF      JIT               USED TO SET UP WRITE LOCKS
         REF      LKIMG             USED TO SET UP WRITE LOCKS
         REF      PB:HVA            USED TO SET UP WRITE LOCKS
         REF      IOLOW             USED TO SET UP WRITE LOCKS
         REF      IOHIGH            USED TO SET UP WRITE LOCKS
         REF      SSDATU:           USED TO SET UP WRITE LOCKS
         REF      TOPUMVDTA         USED TO SET UP WRITE LOCKS
         REF      TSTACK            USED TO BUILD MONITOR JIT
         SPACE
         REF      :BIG              USED TO SET UP MAP
         DEF      INITIAL:MOS       * USED BY PFSR AND CSE TO SET RCE
*                                   * AND RCE FLIP-FLOPS (OF MOS MEMORY)
         REF      MOS:ADDR          * REF ME FOR CONTROL'S USE
         SPACE
         REF      SYSVERS           SET UP FROM X'2B'
         SPACE
         REF      OB:BOPTX          DCTX OF OC FOR ERROR MSG
         REF      DCT1              IO ADDR OF OC FOR ERROR MSG
         SPACE
         REF      CSED%PATH         CLEARED TO ZERO FOR FLT HANDLERS
         SPACE
         REF      LSWAP             NO. OF SWAPPERS IN SYSTEM
         REF      NSWAP             CELL CONTAINING NO. OF SWAPPERS IN SYSTEM
         REF      CORED             * MAXIMUM CORE SIZE (FOR THIS MACH.)
*,*                                 INITIALLY SET AT ONE.
         SREF     #MPC              NUMBER OF MPC TYPES IN SYSTEM
         SREF     MPCLD             MPC FIRMWARE LOAD ROUTINE
         SPACE
         DEF      INITIAL           ENTRY POINT AND MODULE BASE
         DEF      LMA               ENTRY TO RELOAD WRT LOCKS,MAP % ACC
         DEF      UMOV#             INSTR FILLED IN BY BOOTSUBR
         DEF      TOPROOT           TOP OF RESIDENT CODE
         SREF     MOSTAB            * MOS INDICATOR & THRESHOLD TABLE
         PAGE
*F*  NAME:  INITIAL
*F*
*F*  PURPOSE:  INITIAL ENTRY POINT FOR STARTUP OF SYSTEM
*F*            DURING ANY TYPE OF BOOT OR RECOVERY
         SPACE
INITIAL  LPSD,8   INITPSD           WKEY=0, UNMAP, RBLK=0
INIT2    RES
         LI,2     MONORG-X'60'
         LW,1     MTW0              'MTW,0   0' INSTRUCTION
         STW,1    X'5F',2
         BDR,2    %-1
         LI,1     X'5F'-X'3F'
         LW,2     XPSDS-1,1         SET TRAPS, INTERRUPTS, ETC
         STW,2    X'3F',1
         BDR,1    %-2
         DO       DEBUG
         XPSD,10  TRP51             DO WE WANT TO PATCH ?
         FIN
         LI,1     X'2030'           ARM/ENABLE I/O,CLOCK3,OC
         MTB,0    X'2A'             NO OC IF RECOVERY
         BNEZ     %+2
         AI,1     -X'10'
         :WD,1    ARM%ENABLE
         BAL,11   MONINIT
         BIF,S5ONLY INIT5           * ARE WE A 5?...SKIP BIGMAP TEST
         BIF,S9X560 INIT5           * SAME FOR THE 9 AND 560
         LPSD,0   BIG7Q1            * ATTEMPT TO LOAD THE MA BIT
INIT3    EQU      %
         XPSD,0   BIG7Q2            * AND STORE RESULT
INIT4    EQU      %
         LW,1     BIG7Q1+1          * GET THE MASK INTO R1
         CS,1     BIG7Q2+1          * WAS MA BIT SET IN TANGLE
         BNE      S7ERR             * ABOVE? NOPE -> TELL OPER
INIT5    EQU      %
         BAL,11   LMA
         LI,0     TSTACK+1          BUILD MONITOR JIT
         LI,1     JIT+512-TSTACK-2
         SLS,1    16
         LI,2     DA(TSTACK)-DA(JIT-2)
         STD,0    JIT-2,2
         SD,0     0
         BDR,2    %-2
         LW,9     PSA%END           REL SWAP SPACE FOR GH-1             DISCB
         SW,9     BOOTFLG           LEAVE PAACH FILE THERE
         STH,0    9                 ZAP GARBAGE
         CI,9     X'1480'           DON'T ALLOCATE LAST
         BL       %+2               4 GRAMS
         AI,9     -8
         STW,9    BOOTSBAND         INITIALIZE BOOTSBAND
         LH,7     HGP+1              FROM END OF PSA
         STH,7    BOOTSBAND         INSERT DCT INDEX
         LB,2     MB:GPT            GRAN PER TRACK
         SLS,2    1                 SECTORS PER TRACK
         LI,8     0
         DW,8     2
         LI,2     0                 SWAPI OF FIRST SWAPPER
         LB,3     MB:GAM4
         SLS,9    1,3
         AW,9     8
         LW,7     SL:CORE
         AI,7     3
         SAS,7    -2
         SAS,7    2
         AI,9     -2
         LW,15    9
         BAL,11   T:SGRNU           REL SL:CORE GRAN FOR GH1
         BCS,1    %-3
         MTW,-2   BOOTSBAND
         BDR,7    %-5
         LW,0     SYSVERS
         STW,0    X'2B'
         LI,R11   #MPC              ANY MPCS IN SYSTEM
         BEZ      %+2               NO
         BAL,R11  MPCLD             YES-GO LOAD THEM WITH FIRMWARE
         SPACE    1
*
*        IF ANY MOS MEMORY, SCAN, FIND ADRRESSES, AND INITIALIZE
*        THE THRESHOLDS AND SINGLE BIT CORRECTABLE ERROR REPORTING
*        (RSBCE)
*
         SPACE    1
*        LI,R11   MOSTAB            * DID WE GEN FOR MOS?
*        BEZ      %+3               * I GUESS NOT...
*        LI,R4    0                 * TELL HIM TO SETUP TABLES
*        BAL,R11  INITIAL:MOS       * GO SET RSBCE ON
         SPACE    1
         LD,0     IOXPSDS           REPLACE XPSDS
         STD,0    X'5C'             FOR I/O AND OC
         LI,R2    0                 LET TRAP HANDLERS
         STW,R2   CSED%PATH         KNOW INITIAL IS DONE
         LD,0     S:GJOBTBL+4       START UP ALLOCAT
         BAL,10   T:GJOBSTRT
         LD,0     S:GJOBTBL+MING+MING
         BAL,10   T:GJOBSTRT        START UP THE STARTER GHOST
         LI,R1    LSWAP+1           NO. OF SWAPPERS IN SYSTEM
         STW,R1   NSWAP
         LI,1     MOSTAB            * ARE WE A MOS SYSTEM
         BEZ      SIG7INIT          * NO --> USE NORMAL PATH
         LI,1     X'3CF0'           * ARM MFI AND MPI (ON A SIG7)
         BIF,S7   WD                *
SIG7INIT EQU      %
         LI,1     X'38F0'           ARM AND ENABLE: PANEL,IO,
*                                       C4Z,C3Z,C4P,C3P,C2P
         BIF,S7   WD                FOR SIG7, JUST MPI
         LI,R1    X'34F0'           FOR SIG9, JUST MFI
         BIF,S9   WD
         LI,R1    X'3CF0'           FOR X560, MFI AND PFI
WD       EQU      %
         :WD,1    ARM%ENABLE
         LI,1     0
         STW,1    *SPOOL            END CHAIN
         LI,1     X'80'
         :WD,1    TRIGGER
         B        T:SE
*
*
*        NAME     INITIAL:MOS
*        PURPOSE  TO SET UP THE RCE FLIP-FLOPS ON MOS MEMORY
*
*        THE ROUTINE WILL SCAN ALL OF AVAILABLE MEMORY, SETTING
*        UP THE MOSTAB (TABLE) ACCORDING TO WHAT IT FINDS
*        IN REGISTER 4
*
*                 IF R4 = 0 THEN INITIALIZE THRESHOLDS & RCE F-F
*                 IF R4 <>0 THEN INITIALIZE RCE F-F ONLY
*
INITIAL:MOS EQU   %
         SPACE    1
         CI,R4    0                 * DID HE PASS THE 'DONT SETUP' FLG?
         BNE      IMOS5             * YES/ SKIP SETUP CODE
         SPACE    1
         LI,R4    -1                * ZAP THE TABLES WE'RE GOING TO USE
         LI,R2    8                 * (8 ENTRIES EACH)
         SPACE    1
IMOS0    EQU      %
         STW,R4   MOS:ADDR-1,R2     * KILL ADDRESS TABLE
         STW,R4   MOSTAB-1,R2       * AND THRESHOLD/COUNT TABLE
         BDR,R2   IMOS0             * BACK AGAIN
         SPACE    1
         LI,R2    16                * INDEX TO MEMORY
         LI,R6    4                 * MAXIMUM INTLV CONSTANT
         LW,R5    CORED             * GET # OF WDS OF MEMORY
         AI,R5    -1                * AND HIGHEST ADDRESS
         SPACE    1
IMOS1    EQU      %
         LCI      X'9'              * FETCH MSW 1
         LMS,R1   0,R2              * ****
         SPACE    1
         AND,R1   Y001              * GET 'MOS' BIT
         BEZ      IMOS4             * *** CORE BANK...SKIP THIS ONE
         SPACE    1
         LCI      X'A'              * GET MSW 2
         LMS,R3   0,R2              * ****
         SLS,R3   -8                * POSITION BANK BITS IN
         SLS,R3   28                * HIGH NIBBLE
         SPACE    1
         LI,R1    0                 * **** SETUP FOR BANK/INDEX LOOP
         LI,R4    4                 * ****
         SPACE    1
IMOS2    EQU      %
         SLS,R3   1                 * SHIFT OFF A BIT
         BCS,X'8' IMOS3             * IF ONE SHIFTED, EXIT
         AI,R1    1                 * UP THE INDEX
         BDR,R4   IMOS2             * AND TRY AGAIN
         SPACE    1
IMOS3    EQU      %
         LCI      X'9'              * GET MSW1 BACK
         LMS,R3   0,R2              * ****
         SPACE    1
         AND,R3   Y01               * ISOLATE THE UNIT # BIT
         SLS,R3   -22               * SHIFT TO LOW NIBBLE
         AW,R3    R1                * AND CREATE UNIT/BANK INDEX
         SPACE    1
         LW,R1    MOS:ADDR,R3       * GET "OLD CONTENTS"
         BGZ      IMOS4             * IF ALREADY SETUP, SKIP
         SPACE    1
         STW,R2   MOS:ADDR,R3       * SAVE 1ST ADDRESS IN THIS BANK
         LW,R4    MOS:CONST         * GET THE INITIAL THRESHOLD VALUE
         STW,R4   MOSTAB,R3         * AND STORE IT
         SPACE    1
IMOS4    EQU      %
         AI,R2    1                 * TRY NEXT INTLVED WORD
         BDR,R6   IMOS1             * AND TRY AGAIN
         SPACE    1
         LI,R6    4                 * RE-INITIALIZE LOOP COUNTER
         AI,R2    8*1024            * UP BY 8K SO WE GET ALL MEMORY
         CW,R2    R5                * IS IT > CORED?
         BL       IMOS1             * *** NOPE, LOOP AGAIN
         SPACE    1
IMOS5    EQU      %
         LI,R1    8                 * INDEX TO TABLES
         SPACE    1
IMOS6    EQU      %
         LW,R2    MOS:ADDR-1,R1     * SEE IF THIS IS A MOS BANK
         BLZ      IMOS7             * -1 IMPLIES NO MOS HERE
         SPACE
         LCI      X'5'              * NOW THAT ITS MOS, RESET THE RCE
         LMS,R3   0,R2              * ON THE EFFECTIVE BANK
         SPACE
         LW,R3    MOSTAB-1,R1       * SEE IF 'DONT REPORT' SET
         BLZ      IMOS7             * IF NEGATIVE, SKIP SETTING LOGIC
         SPACE
         SPACE    1
         LCI      X'4'              * SET RSBCE ON INDEXED BANK
         LMS,R3   0,R2              * ****
         SPACE    1
IMOS7    EQU      %
         BDR,R1   IMOS6             * BACK TO NEXT BANK
         B        *R11              *  ***** RETURN TO CALLER
*
*F*      NAME:    LMA
*F*
*F*      PURPOSE: TO RELOAD WRITE LOCKS AND MAP AND ACCESS CODES
*F*
*F*      DESCRIPTION: CALLED DURING INITIALIZATION AND
*F*                   CALLED AFTER POWER FAIL/RESTORE OR AFTER
*F*                   PARITY ERROR TO RELOAD THE HARDWARE REGISTERS
*F*
*D*      NAME:    LMA
*D*
*D*      CALL:    BAL,11 LMA
*D*
*D*      REGISTERS: ALL REGISTERS VOLATILE
*
LMA      EQU      %
         LI,3     64
         SLS,R3   :BIG              SHIFT FOR BIG MAP MODE
         LW,2     MAPINIT
         LI,1     1
LODMAP   LI,0     2                 LOAD 1 MAP WORD AT A TIME
         STB,1    1
         LDMAP,0  0
         AW,2     MAPINC
         BDR,3    LODMAP            LOOP TO LOAD ENTIRE IDENTITY MAP
         LI,3     -16               NEXT, SET UP AC IMAGE
         BIF,S5ONLY LANOT5          IF NOT SIGMA 5 LEAVE 2ND
         LW,2     CJOBACC           PAGE PROTECTED...ELSE UNPROTECT
         B        LODAC             2ND PAGE FOR READ ACCESS ONLY
LANOT5   EQU      %                 SO THAT LAST%BREG CAN BE READ
         LW,2     CJOBACC5          BY ALL USERS
LODAC    EQU      %
         STW,2    ACIMG+16,3
         LI,2     -1
         BIR,3    LODAC             LOOP
         LI,12    ACIMG
         LI,1     SIM5BEG           SET SIMULATOR TO 01
         LI,4     SIM5END-1
         LW,2     FIVES
         BAL,13   LIMG
         LI,0     ACIMG             LOAD AC IMAGE TO HARDWARE
         LW,1     Y1
         LPC,0    0
         LI,3     -16               NEXT, SET UP WL IMAGE
         LI,2     0                 * SET ENTIRE WL IMG TO 0
LODWL    STW,2    LKIMG+16,3
         BIR,3    LODWL             LOOP
         LI,12    LKIMG
         LI,1     PPSTART+511       SET MON PURE PROCEDURE TO 11
         LI,4     TOPROOT-1-256     IF SPOOL BUFFER, DONT PROTECT IT
         LI,2     -1
         BAL,13   LIMG
         LI,1     JIT+512           SET UMOV TO 11
UMOV#    LI,5     0                 FILLED IN BY BOOTSUBR
         LB,4     PB:HVA,5
         SLS,4    9
         AI,4     -1
         BAL,13   LIMG              OK EVEN IF NO UMOV
         EXU      UMOV#
         BEZ      NOUMVDTA
         LI,1     SSDATU:           SET UMOV DATA TO 01
         LI,4     TOPUMVDTA
         LW,2     FIVES
         BAL,13   LIMG
NOUMVDTA EQU      %
         LI,1     0               * UNMAPPED FGD TO 01
         LI,4     PPSTART           *
         LW,2     FIVES             *
LKPPT1   BAL,13   LIMG
         LI,1     JIT               *
         LI,4     JIT+X'1FF'        * COVER THE JIT NOW
         BAL,13   LIMG              *
         LI,2     0                 *
         B        LKPPT3            *
LKPPT2   BIR,7    LKPPT1
LKPPT3   EQU      %
         BIF,S7S9 NOIOWL
         LI,1     IOLOW             SET IO BUFFERS TO 0 FOR 560
         LI,4     IOHIGH-1
         BAL,13   LIMG
NOIOWL   RES
         LW,3     CORED             * PHYS MEM SIZE
         SLS,3    -9-4              * TO PAGES
         LI,1     1
         LI,2     0
         LI,0     2
         STB,1    1                 *
         LLOCKS,0 0                 *
         BDR,3    %-3               *
         LI,0     LKIMG             *
         LI,1     128*1024          * 128K
         CW,1     CORED             * HOW MUCH LKIMG TO USE?
         BL       %+2               *
         LW,1     CORED             * USED CORED INSTEAD OF 128K
         SLS,1    -9-4              * INTO PAGES
         SCS,1    -8                *
         LLOCKS,0 0                 *
         B        *11               * BACK TO CALLER
*        SET WRITE LOCK IMAGE  FOR PAGES (1) THRU (4)
*        TO (2) (32 BITS)
*        R12 HAS WA OF IMAGE ORIGIN (WL OR AC)
LIMG     SLS,1    -9                CONVERT WA'S TO PAGE ADDRS
         SAS,4    -9
LIMGP    LI,0     0
         SCD,0    -4                R1 HAS BEG WORD OFFSET IN IMAGE
         SCS,0    5
         LCW,5    0
         LI,3     -1
         SLS,3    ,5                R3 HAS INITIAL MASK FOR STS
         LI,5     0
         SAD,4    -4                R4 HAS ENDING WORD OFFSET IN IMAGE
         SCS,5    5
         LCW,5    5
         LI,0     -1
         SLS,0    30,5              R0 HAS MASK FOR MAKING FINAL MASK
LWL1     CW,4     1
         BL       *13               RETURN IF DONE
         BNE      %+2
         AND,3    0                 SET FINAL MASK (MAY ALSO BE FIRST)
         STS,2    *12,1
         AI,1     1
         LI,3     -1                INTERMEDIATE MASK
         B        LWL1
*
MOS:CONST DATA,2  50,0              * INITIAL THRESHOLD VALUE FOR MOS
FIVES    DATA     X'55555555'
MAPINIT  GEN,15,1,6,1,7,1,1   0,1-:BIG,0,1-:BIG,0,1-:BIG,1
MAPINC   GEN,5,1,7,1,1,6,1,7,1,1,1   0,1-:BIG,0,1-:BIG,:BIG,0,1-:BIG,;
                                     0,1-:BIG,:BIG,0
CJOBACC  DATA     X'BFFFFFFF'
CJOBACC5 DATA     X'AFFFFFFF'
ACIMG    EQU      %
         DO       16
         DATA     -1
         FIN
TOPROOT  RES
XPSDS    XPSD,10  NOPPSD
         XPSD,10  UNIMPPSD
         XPSD,10  STKLPSD
         XPSD,10  FIXOVPSD
         XPSD,10  FLTFPSD
         XPSD,10  DECFPSD
         XPSD,2   PSD%T46
         XPSD,10  IPT47             INTER-PROCESSOR TRAP
         XPSD,10  CAL1PSD
         XPSD,10  CAL2PSD
         XPSD,10  *J:ALB            VECTOR CAL3 THRU THE JIT
         XPSD,10  CAL4PSD
         XPSD,2   PSD%T4C
         XPSD,2   PSD%T4D
         XPSD,8   LEE20             LEES WATERING HOLE
         DATA     JIT+255**24       CJOB
         XPSD,0   POWRON
         XPSD,10  POWROFF
         MTW,0    0
         MTW,0    0                 CLOCK2
         MTW,-1   TINC
         MTW,1    *S:CLOCK4         ACCOUNTING CLOCK (CLOCK4)
         XPSD,2   PSD%I56           * RETAIN MAPPING BIT FOR PFI AND MPI
         XPSD,0   PSD%I57
         MTW,0    0                 CLOCK1
MTW0     MTW,0    0                 CLOCK2
         XPSD,10  CLK3PSD
         XPSD,10  CLK4PSD
         XPSD,10  AIOPSD            INITIAL IO INTERRUPT XPSD
         XPSD,10  HLTPSD            BOOT RESTART HALT
         DATA     0,INITIAL         MON START ADR FOR DISCBOOT
         BOUND    8
IOXPSDS  XPSD,8   IOPSD
         XPSD,8   OCPSD
HLTPSD   :PSD     RES,(IA,BOOTHLT)
INITPSD  :PSD     (IA,INIT2)
AIOPSD   :PSD     RES,(IA,AIOSRV)
S7MSG    GEN,8,24,32 5,BA(S7TXT),39
*
*        GENERATE PSD'S FOR SIGMA 7 TEST CASE
*        IF UNABLE TO SET MA BIT (PSD40), THEN WE
*        AREN'T ON A BIG MAP SIGMA 7
*
         BOUND    8
BIG7Q1   EQU      %
         GEN,32   INIT3             * IA FOR PSD
         GEN,9,23 :BIG,0            * SET BIT 40
BIG7Q2   EQU      %
         DATA     0
         DATA     0
         DATA     INIT4
         DATA     0
*
*O*
*O*      MESSAGE: SYSTEM NEEDS BIG MAP MACHINE NOT SIG7
*O*
*O*      MEANING: THIS PO TAPE CANNOT BE BOOTED ON A SMALL
*O*               MAP SIGMA 7 BECAUSE IT REQUIRES A MACHINE
*O*               WITH A HALFWORD MAP FORMAT
*O*
*
S7ERR    EQU      %
         LI,1     OC                OC OP LEBEL INDEX
         LB,1     OB:BOPTX,1        DCTX OF OC
         LH,1     DCT1,1
         AI,R1    -X'C100'          MAKE INTO SIGMA7 ADDRESS
         LI,0     DA(S7MSG)         TELL OPERATOR AND QUIT.
         SIO,0    *1
         B        %
         B        %-2
S7TXT    DATA,1   X'15',X'15','S','Y'
         TEXT     'STEM NEEDS BIG MAP MACHINE NOT SIG7'
AIOSRV   AIO,0    0
         STCF     S9AIOCC           SAVE AIO CC
         LPSD,X'B'  AIOPSD          RETURN
S9AIOCC  DATA     0
         DO       DEBUG
         PAGE
*******************
*   B O O T   T I M E    P A T C H    R O U T I N E
*
*        PATCH CP-V MONITOR ROOT AND BOOT TIME ROUTINE
*        WITH ABSOLUTE PATCHES. PATCH FORMAT IS:
*
*        COL.1         COL.9
*
*        LOC.          VALUE
*
*                 WHERE: LOC    =5 HEX DIGIT ADDR
*                        VALUE  =8 HEX DIGIT VALUE
*
*   ENTRY  :      BY EXECUTING TRAP LOC. X'51' WHICH CONTAINS XPSD
*   EXIT   :       BY LPSD TO RESULT OF ENTRY XPSD
*
*
*        PATCHES ARE TERMINATED BY  A !EOD CARD, AND ARE
*        READ FROM THE CARD READER
*
*        PATCHES ARE PRINTED ON THE LINE PRINTER
*
******************
         SPACE    3
         SPACE    3
PACHER   EQU      %                 ENTRY-------
         LCI      0                 SAVE REGS.
         PSM,R0   STK
         LI,0     DA(PTHMSG)        ASK IF THEY WANT TO PATCH
         SIO,0    *TYNDD
         TIO,0    *TYNDD
         BCS,12   %-1
         LB,R1    ADDR              GET ANSWER
         CI,R1    'Y'               IS IT YES
         BNE      EXIT              B IF NOT
         LI,R0    DA(PRNTEST)
         SIO,R2   *LPNDD            EJECT A PAGE
         BCS,CC   %
         TIO,R4   *LPNDD
         BCS,CC   %-1
READCR   EQU      %
         LI,0     DA(READ)          READ A CARD
         SIO,R2   *CRNDD
         BCS,CC   %
         TIO,R4   *CRNDD            WAIT FOR
         BCS,CC   %-1               I/O DONE
PRNTOK   EQU      %
         LI,R0    DA(PRINT)
PRNTOK0  EQU      %
         SIO,R2   *LPNDD            PRINT CARD
         BCS,CC   %                 STOP SOMETHING IS WRONG
         TIO,R4   *LPNDD            WAIT FOR
         BCS,CC   %-1               I/O TO FINISH
PRNTOK1  EQU      %
         LW,R1    PACHBUF
         BEZ      EXIT              B IF END OF PATCHING
         CW,R1    L('!EOD')         NO----CHECK FOR
         BNE      PATCH             END OF PATCHES
         LI,R1    0                 WE ARE DONE, SO SET
         STW,R1   PACHBUF           PATCHING FLAG
         LI,R0    DA(PRNTEST)
         B        PRNTOK0           EJECT PAGE
*----------------------------
PATCH    EQU      %
         LI,R8    0                 FLAG FOR 'LOC' CONVERS.
         LD,R6    LOC               GET LOC FIELD
         BAL,R9   CONV              CONVERT TO HEX
*
*  RETURN WITH R10 = LOC.
*
         STW,R10  ADDR
         LI,R8    1                 VALUE CONVERS.
         LD,R6    VALUE             VALUE FIELD
         BAL,R9   CONV              CONVERT TO HEX
*
*  RETURN WITH R10 = VALUE
*
         STW,R10  *ADDR             PATCH MONITOR
         B        READCR            GET NEXT CARD
*
*
*
         PAGE
**************************
*
*  C O N V  R O U T I N E
*
*        PART OF BOOTPATCH ROUTINE. CONVERTS EIGHT (8)
*        EBC CHARACTERS TO 8 HEX CHARACTERS
*
*  ENTRY : R6-R7  = 8 EBC CHAR.
*          R8     = 0 CONVERT LOC
*                 = 1 CONVERT VALUE
*
*  EXIT  : R10    = 8 HEX CHAR (CONVERTED)
*
*  ENTERED BY :    BAL,R9
*
**************************
         SPACE    3
CONV     EQU      %           ENTRY..........
         CI,R8    0
         BNEZ     CONV1             NO---LOC CONV.
         OR,R7    L(' 000')         YES--5 CHAR LOC BECOMES
         SCD,R6   -24               8 CHAR
CONV1    EQU      %
         LI,R15   8                 8 DIGITS
CONV2    EQU      %
         LB,R11   R6                GET CHAR
         SLD,R6   8                 TO NEXT CHAR
         CI,R11   '0'
         BGE      %+2
         AI,R11   X'39'             CONVERT
         AI,R11   -'0'              EBC DIGIT
         SCS,R11  -4
         SLD,R10  4
         BDR,R15  CONV2             GET NEXT CHAR.
         B        *R9               ------- RETURN
***********************
         PAGE
***********************
*  D A T A  I N F O
***********************
         SPACE    3
***********
         BOUND    8
NEWPAGE  TEXT     '1   '            TOP OF FORM
PRNTBUF  TEXT     'A   '            UPSPACE ONE LINE
PACHBUF  RES      20                INPUT BUFFER FOR PATCHES
*******************
CC       EQU      X'C'              CONDITION CODE FOR I/O CHECK
LOC      EQU      PACHBUF+0         WD-0 IN BUF OF LOC (2 WDS TOTAL)
VALUE    EQU      PACHBUF+2         WD-2 IN BUF OF VALUE (2WDS TOTAL)
******
CRNDD    DATA     0003              CR ADDR
LPNDD    DATA     0002              LP ADDR
TYNDD    DATA     0001              TY ADDR
******
ADDR     PZE      0                 WHERE TO PATCH
********
         BOUND    8
STKSZ    EQU      16
STK      PZE      %+1
         GEN,16,16 STKSZ,0
         RES      STKSZ
******
         SPACE    3
*******
         BOUND    8
READ     EQU      %                 IOCD TO READ A CARD
         GEN,8,24  X'06',BA(PACHBUF)
         GEN,8,24  X'00',20*4
******
         BOUND    8
PRINT    EQU      %                 IOCD TO PRINT A CARD
         GEN,8,24  X'05',BA(PRNTBUF)
         GEN,8,24  X'00',21*4
******
         BOUND    8
PRNTEST  EQU      %                 IOCD TO DETERMINE PRINTER TYPE
         GEN,8,24  X'05',BA(NEWPAGE)      AND EJECT PAGE
         GEN,8,24  X'00',1*4
******
************
******************
EXIT     EQU      %
         LCI      0
         PLM,R0   STK
         LPSD,0   TRP51             RETURN
***************************
         BOUND    8
TRP51    DATA     0,0,PACHER,0
*
*
         BOUND    8
*
PTHMSG   GEN,8,24 X'05',BA(BUSH)
         GEN,8,24 X'20',BUSHSZE
         GEN,8,24  X'86',BA(ADDR)
         GEN,8,24 X'00',4
*
*
BUSH  TEXT  ' IF YOU WANT TO PATCH, ANSW. YES  '
BUSHSZE  EQU      BA(%)-BA(BUSH)
*
*
PATCHEE  RES    50
*
         FIN
         END

