*****************
*M*      BITOTM   COPY LABELED PORTION OF PO TAPE TO SYSTEM DEVICE
*****************
*                 CATALOG NO. 704878 - BPM M:BITOTM
         SYSTEM   SIG7FDP
*P*
*P*      NAME:    BITOTM
*P*      PURPOSE: COPY THE TAPE FILES FROM THE BOOT TAPE TO
*P*               THE SYSTEM DEVICE.
*P*      DESCRIPTION:  IF THE BOOT TAPE PROCEDURE REQUESTED
*P*               THAT TAPE FILES SHOULD BE COPIED TO THE
*P*               SYSTEM DEVICE, THEN BITOTM PERFORMS THAT
*P*               COPY. BITOTM RELEASES ALL OF GHOST1'S
*P*               DATA AREA BACK TO THE MONITOR EVEN IF
*P*               THE TAPE FILE COPY DOES NOT HAPPEN.
*P*
         PAGE
         REF      GENMD             ROUTINE
*,*                           BITOTM EXITS TO GENMD MODULE UPON
*,*                           COMPLETION
         REF      BOOTFLG           INPUT BYTE 0 OF WORD
*,*                           OBTAIN BOOT TYPE FLAGS TO
*,*                           DETERMINE IF TAPE FILES ARE
*,*                           TO BE COPIED.
*,*                                 = 08 PERFORM TAPE FILE COPY
*,*                                 = 02 PERFORM :SYS FILE COPY
         REF      MASKS             CONSTANT TABLE
         REF      Y00FF             CONSTANT X'00FF0000'
         REF      M:BI              DCB
*,*                           TAPE INPUT DCB
         REF      M:TM              DCB
*,*                           SYSTEM DEVICE OUTPUT DCB
         REF      J:DLL             INPUT DOUBLE WORD
*,*                           ASSUMES THAT J:DLL IS ON
*,*                           DOUBLE WORD BOUND IN JIT SO THAT
*,*                           J:DUL CAN ALSO BE OBTAINED.
*,*                           USED TO RELEASE ALL OF GHOST1'S
*,*                           DATA AREA.
         DEF      ERRABN0           ERROR/ABNORMAL ROUTINE
*,*                                 FOR I/O ERRORS FROM
*,*                                 M:BI & M:TM
         PAGE
*                                   REGISTERS
R0       EQU      0
R1       EQU      1
R2       EQU      2
R3       EQU      3
R4       EQU      4
R6       EQU      6
SR3      EQU      10
SR4      EQU      11
F:IN     EQU      M:BI
F:OUT    EQU      M:TM
ORG      EQU      5
KEYM     EQU      12
         PAGE
*F*
*F*      NAME:    BITOTM
*F*      PURPOSE: RELEASE ALL DATA AREA FROM GHOST1, & THEN IF
*F*               DESIRED, COPY ALL BOOT TAPE FILES TO SYSTEM
*F*               DEVICE.
*F*
*D*
*D*      NAME:    BITOTM
*D*      ENTRY:   CLSIN
*D*      ENTRY:   CLSOUT
*D*      ENTRY:   LOSDATA
*D*      ENTRY:   ABNTPE0
*D*      DESCRIPTION:  BITOTM INITIALLY RELEASE ALL OF GHOST1'S
*D*               DATA AREA, THAT IS, PROTECTION TYPE 0. IF BOOT
*D*               UNDER THE FILES IS REQUESTED, BITOTM EXITS TO
*D*               GENMD (GENMDG MODULE). IF OTHER TYPE OF BOOT,
*D*               BITOTM COPIES EACH FILE FROM THE BOOT TAPE
*D*               TO THE SYSTEM DEVICE. BITOTM TERMINATES
*D*               WITH THE FILENAME: 'LASTLM'.
*D*               BITOTM THEN ENTERS GENMD (GENMDG MODULE).
*D*               THE 1ST 5 LOC.IN BITOTM ARE USED FOR REGISTER
*D*               STORAGE DURING EXECUTION OF THIS MODULE.
*D*
*D*               CLSIN - DISC I/O ERROR, CLOSE INPUT.
*D*               CLSOUT - EOF ON INPUT, CLOSE IN & OUT.
*D*               LOSDATA - LOST DATA ON INPUT, SKIP FILE.
*D*               ABNTPE0 - CLOSE IN & OUT & EXIT TO GENMD.
*D*
*D*      INTERFACE:  GENMD
*D*      ENVIRONMENT:  MAPPED, MASTER
*D*
BITOTM   DSECT    1
         LD,6     J:DLL             RELEASE ALL UNUSED CORE
         SW,7     6
         AI,7     1
         SLS,6    9                 MAKE WORD ADDRESS
         MTB,5    6                 MAKE FVP FPT
         CAL1,8   6
         AI,6     512
         BDR,7    %-2
         LH,3     BOOTFLG           ARE WE COPYING FILES
         CI,3     X'A00'
         BAZ      GENMD
         CAL1,8   GP                GET A BUNCH OF MEMORY
         SLS,8    9                 SIZE IN WORDS
         AW,8     9                 END IN WORDS
         AI,8     -BUFFER           REAL SIZE IN WORDS
         SLS,8    2                 IN BTES
         STW,8    BUFSZ
*                                   TAPE TO DISK
*
TTD      EQU      %
         CAL1,1   OPNTPE
         BCS,0    TTD
         LCI      2
         LM,3     M:BI+23           IS THIS LASTLM
         CW,R3    TXLAS
         BNE      %+4
         SLS,4    -8
         CW,4     TXLAS+1
         BE       ABNTPE1
         CAL1,1   RSTTM             CLEAN OUT DC DCB
*
         LI,R3    X'F0'             ORG
         AND,R3   ORG+F:IN
         SLS,R3   -4
         LB,R4    KEYM+F:IN
         LI,R1    2                 OPEN OUTPUT UNLESS THERE IS A SYNON
         LI,R2    X'80000'          VLP
TTD0     LW,12    FPARAM,2
         LB,13    12
         CI,13    11                IS THIS IT
         BNE      %+4               NO
         MTB,0    12,1              IS IT EMPTY
         BEZ      %+2               YES, FERGETIT
         LI,1     4                 GOT ONE, OPEN UPDATE
         CW,12    Y00FF             ARE WE DONE LOOKING
         BANZ     TTD1              YES
         AND,12   MASKS+8           NO, GO TO NEXT
         AW,2     12
         BIR,2    TTD0
TTD1     EQU      %
         CAL1,1   OPNDSK
         BCS,0    CLSIN
*
*                                   COPY RECORDS
TTD2     EQU      %
         CAL1,1   RDTPE
         CAL1,1   WRTDSK
         B        TTD2
         PAGE
*
*
RSTTM    GEN,8,24 X'14',M:TM
         DATA     X'7001'
         DATA     1
RST      COM,8,8,16 AF,CF(2),0
         RST      3
         RST      5
         RST      6
         RST      11
         RST      20
         RST,1    21
OPNDSK   EQU      %
         GEN,8,24 X'14',F:OUT
         DATA     X'05480001'
         PZE      *3
         PZE      *1
         DATA     2                 SAVE
         DATA     X'80000004'       KEYM
FPARAM   EQU      %
         RES      90
*
*
*
OPNTPE   EQU      %
         GEN,8,24 X'14',F:IN
         DATA     X'01200402'
         DATA     1                 FUN
         DATA     FPARAM
         DATA     X'10000'
*
*
RDTPE    EQU      %
         GEN,8,24 X'10',F:IN
         DATA     X'F0000010'
         PZE      ERRABN0
         PZE      ERRABN0
         PZE      BUFFER
BUFSZ    DATA     0
*
*
WRTDSK   EQU      %
         GEN,8,24 X'11',F:OUT
         DATA     X'F8000050'
         PZE      ERRABN0
         PZE      ERRABN0
         PZE      BUFFER
         GEN,1,31 1,F:IN+13
         GEN,1,31 1,F:IN+10
         PAGE
*
ABNTPE0  CAL1,1   OPND              OPEN DEVICE TAPE
ABNTPE1  CAL1,1   CLSR
GENMD0   CAL1,8   FP
         B        GENMD             RETURN
         PAGE
FP       DATA     X'90000FF'
GP       DATA     X'80000FF'
M7       DATA     X'7F'
         PAGE
*
CLSOUT   EQU      %
         LI,1     F:OUT
         CAL1,1   CLS
CLSIN    EQU      %
         LI,1     F:IN
         CAL1,1   CLS
         B        TTD
*
LOSDATA  CAL1,1   CLSFIL
         CAL1,2   PR1
         CAL1,2   PR2
         B        CLSIN
         PAGE
CLSFIL   GEN,8,24 X'15',F:OUT
         DATA
PR1      GEN,8,24 1,0
         PZE      *0
         PZE      SKPMES
PR2      GEN,8,24 1,0
         PZE      *0
         PZE      F:IN+23
SKPMES   TEXTC    'CANNOT BOOT LMN'
CLS      EQU      %
         GEN,8,24 X'95',1
         DATA     X'80000000'
         DATA     2
*
*
*
*
*
EOFFIN   GEN,8,24 6,F:IN
TXLAS    DATA,1   6,'L','A','S',,'T','L','M'
CLSR     GEN,8,24 21,F:IN
         DATA     X'20'             REMOVE
OPND     GEN,8,24 20,F:IN
         DATA     3,-1
         PAGE
*D*
*D*      NAME:    ERRABN0
*D*      DESCRIPTION:  I/O ERROR/ABNORMAL ROUTINE ENTERED WHEN
*D*               I/O ERRORS/ABNORMALS OCCUR WHEN COPYING THE
*D*               BOOT TAPE FILES TO THE SYSTEM DEVICE.
*D*               ERRABN0 IS ENTERED AS A RESULT OF AN I/O
*D*               ERROR/ABNORMAL FROM A READ/WRITE TAPE/DISC
*D*               RESPECTIVELY, OR FROM OPEN/CLOSE.
*D*               FOLLOWING THE OPEN CALS IN THE CODE
*D*               IS A 'BCS,0  ADDRESS', WHILE FOLLOWING THE
*D*               READ/WRITE/CLOSE CALS THERE IS NORMAL CODE. THE
*D*               SPECIAL 'BCS,0  ADDRESS' INSTRUCTION IS USED
*D*               AS A FLAG IN ARRABN0 & THE 'ADDRESS' IS USED
*D*               BY ERRABN0 TO TRANSFER TO WHEN AN
*D*               ERROR/ABNORMAL OCCURS ON OPEN. WHEN AN
*D*               ERROR/ABNORMAL OCCURS ON READ/WRITE/CLOSE,
*D*               ERRABN0 RETURNS TO CAL +1.
*D*               ERRABN0 DOES EXIT TO OTHER ROUTINES WHEN
*D*               SPECIAL ERROR/ABNORMAL CONDITIONS ARISE.
*D*
*D*      INTERFACE:  ABNTPE0,CLSIN,CLSOUT,LOSDATA.
*D*      REGISTERS:  R7-R11 SAVED
*D*      ENVIRONMENT:  MAPPED, MASTER
*D*
ERRABN0   LCI     5
         STM,7    REGS
         LI,11    0
         LI,9     X'1FFFF'
         CW,10    LASTTM
         BE       ABNTPE0
         CW,10    BUSYTM            IF BUSY MUST BE PATCH FILE
         BE       CLSIN             IGNORE ONE ON TAPE
         CW,10    EOFFIN            END OF THIS FILE ON TAPE
         BE       CLSOUT            YES  CLOSE OUTPUT FILE AND INTPUT
         CW,10    LOSDIN            LOST DATA INPUT
         BE       LOSDATA           YES, DO MESSAGEES, ETC.
         AI,8     -1                CAL ADDR
         ANLZ,7   *8                GET FPT ADDR
         LB,7     *7                GET OP CODE
         AND,7    M7
         AI,7     -X'12'
         BGEZ     %+2
         AI,7     2
         LW,7     OPS,7
         STW,7    MSG+4             PUT OP IN MSG
         SCS,10   8                 CONV CODE TO EBCDIC
         SLD,10   -4
         SLS,11   -28
         CI,11    9
         BG       %+2
         AI,11    10+'0'-'A'
         SLS,11   24
         SLD,10   -4
         SLS,11   -20
         AI,11    '0A'-10
         STH,11   MSG+3             PUT IN MSG
         LW,8     DCBS+1            GET WHAT
         LI,10    X'1FFFF'
         AND,10   REGS+3            DCB ADDR.IN REGS.(SR3)
         CI,10    M:TM
         BE       %+2
         LW,8     DCBS
         STW,8    MSG+11            PUT IN MSG
         AI,10    23
         LI,7     11
         LI,8     ' '                LAANK
         STB,8    MSG+7,7           BLANK HOLE
         BDR,7    %-1
         LB,7     *10               GET BYTE COUNT
         BEZ      %+4               NO NAME
         LB,8     *10,7             GET CHARS
         STB,8    MSG+7,7           OUT IN MSG
         BDR,7    %-2
         LI,10    MSG
         CAL1,2   MSGFPT
         LW,10    REGS+3            GET OLD REG.10 (R10)
         CW,10    RD:ERR
         BE       LOSDATA           YES, READ ERROR, CLOSE & GET NEXT
         LI,10    X'69'
         LW,8     REGS+1
         CB,10    *8
         BE       %+2               RETURN TO *CAL+1
         LI,8     8                 RETURN TO CAL+1
         STS,8    RETB
RESREGS  LCI      5
         LM,7     REGS
RETB     B        *0
         PAGE
MSG      TEXTC    'IO ERR/ABN XX, XXXXING FILE XXXXXXXXXXX ON XXXX'
OPS      TEXT     'READWRITOPENCLOS'
DCBS     TEXT     'TAPEDISC'
MSGFPT   DATA     2**24,1**31,1**31+10
LASTTM   GEN,8,24 2,M:BI
REGS     EQU      BITOTM
LOSDIN   GEN,8,24 7,M:BI
BUSYTM   GEN,8,7,17 20,1,M:TM
RD:ERR   GEN,8,24 X'41',M:BI
BUFFER   EQU      %
         END

