<< LINES .001/.009 ARE RESERVED FOR SYSTEMS INTEGRATION>>               00005000
$CONTROL MAP,CODE,USLINIT                                               00010000
<<LABSEG - MODULE 86>>                                                  00015000
<< HP32002C MPE SOURCE C.00.00 >>                                       00020000
$COPYRIGHT     "(C) COPYRIGHT HEWLETT-PACKARD CO. 1980. ",            & 00025000
$     "THIS PROGRAM MAY BE USED WITH ONE COMPUTER SYSTEM AT A ",      & 00030000
$     "TIME AND SHALL NOT OTHERWISE BE RECORDED, TRANSMITTED OR ",    & 00035000
$     "STORED IN A RETRIEVAL SYSTEM.  COPYING OR OTHER REPRODUCTION ",& 00040000
$     "OF THIS PROGRAM EXCEPT FOR ARCHIVAL PURPOSES IS PROHIBITED ",  & 00045000
$     "WITHOUT THE PRIOR WRITTEN CONSENT OF HEWLETT-PACKARD COMPANY.",& 00050000
$     "LABSEG JANUARY 17, 1983."                               <<06135>>00055000
$CONTROL USLINIT,CODE,MAP                                               00060000
<< LABSEG - module 86 >>                                       <<02547>>00065000
<< HP32002B MPE Source C.00.00 >>                                       00070000
<<" (C) Copyright Hewlett-Packard Company, 1980.                        00075000
  All rights reserved.  No part of this program may                     00080000
  be photocopied, reproduced, or translated to                          00085000
  another program language without the prior written                    00090000
  consent of Hewlett-Packard Company. "   >>                            00095000
                                                                        00100000
$CONTROL MAIN=LABSEG                                                    00105000
$CONTROL SEGMENT=LABSEG                                                 00110000
                                                                        00115000
BEGIN                                                                   00120000
                                                               <<03581>>00125000
COMMENT                                                        <<03581>>00130000
                                                               <<03581>>00135000
           Fix History since D-MIT                             <<03581>>00140000
                                                               <<03581>>00145000
Fix #      Description of fix                                  <<03581>>00150000
                                                               <<03581>>00155000
                                                               <<03581>>00160000
<<02547>>  New Source                                          <<03581>>00165000
                                                               <<03581>>00170000
<<02563>>  Support for variable density tape drives.           <<03581>>00175000
           Improve error handling for AVR of tapes.            <<03581>>00180000
                                                               <<03581>>00185000
<<02575>>  Parameter of DADDR of CLEANLDEV is now passed       <<03581>>00190000
           by value.                                           <<03581>>00195000
                                                               <<03581>>00200000
<<02616>>  Change to PVOLID.                                   <<03581>>00205000
                                                               <<03581>>00210000
<<02621>>  1) Ensure UVL labels skipped when 1st file on       <<03581>>00215000
              reel is FOPEN'd                                  <<03581>>00220000
           2) Correct SF 86's due to :                         <<03581>>00225000
              a) a REPLY <pin>,0 to a reelswitch request       <<03581>>00230000
                 during a labeled tape RESTORE.                <<03581>>00235000
              b) mounting 2nd or later reel as 1st reel        <<03581>>00240000
                 during a labeled tape RESTORE.                <<03581>>00245000
                                                               <<03581>>00250000
<<02622>>  1) Fix problems with reelswitching when STORE/      <<03581>>00255000
              RESTORE to/from labeled tape.                    <<03581>>00260000
           2) Disallow more than one file opened on a          <<03581>>00265000
              labeled tape concurrently.                       <<03581>>00270000
                                                               <<03581>>00275000
<<02648>>  Correct GOODREEL, add delays for DEVREC, Allow      <<03581>>00280000
           any printing chars in vol label.                    <<03581>>00285000
                                                               <<03581>>00290000
<<02622>>  Add error reporting to ATTACHIO calls.              <<03581>>00295000
                                                               <<03581>>00300000
<<02673>>  Correct system log record, put I/O error messages   <<03581>>00305000
           on console, please return of CCE to mean tape is    <<03581>>00310000
           mounted on a tape drive in PVOLID, don't wait       <<03581>>00315000
           on a DCLOSE in FREEDEVICE for CLEANTAPE.            <<03581>>00320000
                                                               <<03581>>00325000
<<02689>>  1) Allow writes and WTM to occur after TM.          <<03581>>00330000
           2) Clean up after =REPLY <pin>,0 to REELSWITCH      <<03581>>00335000
              request in a more timely manner.                 <<03581>>00340000
                                                               <<03581>>00345000
<<02690>>  Permit override of HDR2 label file characteristics. <<03581>>00350000
           Correct cleanup on process termination.             <<03581>>00355000
           Correct some problems with tape positioning on      <<03581>>00360000
           REELSWITCH.                                         <<03581>>00365000
                                                               <<03581>>00370000
<<02703>>  Allow STORE/RESTORE to return file system error     <<03581>>00375000
           numbers in the event of an error in advancing from  <<03581>>00380000
           one labeled tape to another.                        <<03581>>00385000
                                                               <<03581>>00390000
<<02722>>  1) Make AVR of tapes more forgiving when I/O errors <<03581>>00395000
              occur.                                           <<03581>>00400000
           2) Prevent RECOGNIZE and AVREC from both attempting <<03581>>00405000
              AVR on the same tape (SR#22254).                 <<03581>>00410000
           3) Prevent I/O's from occuring while holding the    <<03581>>00415000
              TLTSIR (SR#22907).                               <<03581>>00420000
           4) Prevent I/O's during FCLOSE of labeled tape after<<03581>>00425000
              a =REPLY <pin>,0.                                <<03581>>00430000
                                                               <<03581>>00435000
<<*cub*>>  1) Support of Labeled Serial Disc for CUB.          <<03581>>00440000
           2) Addition of Tape Trouble codes.                  <<03581>>00445000
           3) Addition of Fix Log.                             <<03581>>00450000
                                                               <<03618>>00455000
(Fix number col. 64/72)                                        <<03618>>00460000
                                                               <<03618>>00465000
          Allowing reelswitch on labeled serial disc.          <<03618>>00470000
                                                               <<03618>>00475000
          CLEANTAPE will deallocate the XDS for SDISC on       <<03634>>00480000
          a volume set that is not a tape.                     <<03634>>00485000
                                                               <<03634>>00490000
          Return an illegal value to a caller of FFILEINFO     <<04612>>00495000
          items (26/33,45)  when a non labeled tape file.      <<04612>>00500000
                                                               <<04612>>00505000
   A problem with the ownership bits for reelswitching         <<04647>>00510000
   labeled serial disc.                                        <<04647>>00515000
                                                               <<04647>>00520000
   Fix a problem that the TLT will not be updated before the   <<04698>>00525000
     ownership bits in the LPDT are set, thus allowing AVR     <<04698>>00530000
     before REELSWITCH has set up everything.                  <<04698>>00535000
                                                               <<04698>>00540000
          Allow use to write over a label if we have           <<04819>>00545000
          operator permission and we have write access.        <<04819>>00550000
                                                               <<04819>>00555000
          When a reelswitch is occuring and the mounted tape   <<04739>>00560000
          is already labeled and not expired and the operator  <<04739>>00565000
          replys N to the OK to write on unexpired volume,     <<04739>>00570000
          then we will set up the tape drive for another tape  <<04739>>00575000
          instead of returning a FWRITE error.                 <<04739>>00580000
                                                               <<04739>>00585000
                                                               <<04740>>00590000
          Update the ANSI standard version from 1 to 3         <<04740>>00595000
                                                               <<04740>>00600000
          one tape mark will be written (for LINUS).           <<04736>>00605000
                                                               <<04736>>00610000
     Fix a problem with the reelswitch reel number on the      <<04872>>00615000
   Fix problem with fixno 4612. TGETINFO also needs to return  <<04873>>00620000
   condition codes for when it's called from OPLOW (for the    <<04873>>00625000
   measurement interface).                                     <<04873>>00630000
                                                               <<04873>>00635000
     third reel on.                                            <<04872>>00640000
                                                               <<04872>>00645000
           Fix up the catalog                                           00650000
                                                             <<gg.32>>  00655000
      Fix the calling sequence for CKFORLABEL so that the    <<gg.32>>  00660000
    expired/unexpired checks will be made.                   <<gg.32>>  00665000
                                                             <<gg.32>>  00670000
  Fix a problem with fix 4872.  The condition codes are still           00675000
not getting set correctly.                                              00680000
                                                                        00685000
   Parse forms message of FOPEN call correctly so that default <<06024>>00690000
expiration date (00/00/00) can be specified.                   <<06024>>00695000
                                                               <<06024>>00700000
   1) When reopening a file closed with rewind disposition,    <<06026>>00705000
      will check file expiration date properly.                <<06026>>00710000
   2) Checks file expiration date of file being opened, not    <<06026>>00715000
      first file on reel.  Also enforces rule that files       <<06026>>00720000
      added must have an exp. date earlier (or the same) than  <<06026>>00725000
      that of the preceding file.                              <<06026>>00730000
   3) A labelled tape being opened for read access can no      <<06026>>00735000
      longer sneakily overwrite the volume label.              <<06026>>00740000
                                                               <<06026>>00745000
   Allows ANSI "D" labelled tape written by HP (pre D-MIT) to  <<06135>>00750000
   be used.  Treated as variable length record file.           <<06135>>00755000
                                                               <<06135>>00760000
   MPE5 changes:  This module was converted to use the LDT and <<06333>>00765000
   LPDT include files for MPE4 and 5.  No changes were required<<06333>>00770000
   to go from MPE4 to MPE5.                                    <<06333>>00775000
                                                               <<06424>>00780000
   MPE4 PCB include file changes.                              <<06424>>00785000
                                                               <<06939>>00790000
   Made changes to accomodate new tape labels log record       <<06939>>00795000
   format for MPE5.                                            <<06939>>00800000
                                                               <<07113>>00805000
   Fix up fix #6026 so that the expiration date checks will    <<07113>>00810000
   be made after a tape file has been FOPENed and FCLOSEd with <<07113>>00815000
   disposition 2 or 3 (rewind).                                <<07113>>00820000
                                                               <<07338>>00825000
   Fix PVOLID so that parameters will be aligned properly when <<07338>>00830000
   doing a SHOWDEV TAPE.                                       <<07338>>00835000
                                                               <<07493>>00840000
   Add support for the HP7974 and HP7978 variable density tape <<07493>>00845000
   drives (Buckhorn and Antelope).                             <<07493>>00850000
                                                               <<r7493>>00855000
   Fixed reel numbers written on header and trailer labels by  <<r7493>>00860000
   NEXTTAPEFILE (called by STORE).                             <<r7493>>00865000
                                                               <<d8615>>00870000
   Fixed HP7974/7978 (Antelope and Buckhorn) default tape      <<d8615>>00875000
   density assignments.                                        <<d8615>>00880000
                                                                        00885000
                                                               <<04647>>00890000
                                                               <<04647>>00895000
                                                               <<04647>>00900000
;                                                              <<04647>>00905000
<< New source, 1981 Jan 2. >>                                           00910000
                                                                        00915000
   << Definitions for Tape Label Table Logical Device Blocks >>         00920000
                                                                        00925000
EQUATE LTESIZE =26;                                                     00930000
DEFINE                                                                  00935000
 LCB'FLAGS  =LTBUF#,            << state bits >>                        00940000
   LCB'LABTYP =LCB'FLAGS.(4:2)#,  << label type >>                      00945000
   LCB'TAPE   =LCB'FLAGS.(6:1)#,   << Tape device >>           <<03581>>00950000
   LCB'LOCKFLG=LCB'FLAGS.(7:1)#,  << lockword flag 1:53,1 >>            00955000
   LCB'B5000  =LCB'FLAGS.(8:1)#,  << Burroughs tape >>                  00960000
   LCB'HP     =LCB'FLAGS.(9:1)#,  << HP tape >>                         00965000
 LCB'LDEV      =LTBUF(1)#,                                              00970000
 LCB'VCB       =LTBUF(2)#,                                              00975000
 LCB'FLAG2     =LTBUF(3)#,                                              00980000
   LCB'REEL   =LCB'FLAG2#,        << reel nr.  1:27,4 >>                00985000
 LCB'FSEQ      =LTBUF(4)#,      << file seq. nr.  1:31,4 >>             00990000
 LCB'CDATE     =LTBUF(5)#,      << creation date 1:41,6 >>              00995000
 LCB'EXDATE    =LTBUF(6)#,      << expiration date 1:47,6 >>            01000000
 LCB'FNAME     =LTBUFB(14)#,    << file name  1:4,17 >>                 01005000
 LCB'VSETID    =LTBUFB(40)#,    << volume set ID 1:21,6 >>              01010000
 LCB'VOLID     =LTBUFB(46)#;    << volume ID 0:4,6 >>                   01015000
                                                                        01020000
DEFINE BUILDLCB =                                                       01025000
   BYTE ARRAY LTBUFB(*) = LTBUF#;                                       01030000
                                                                        01035000
   << Definitions for Tape Label Table Volume Control Blocks >>         01040000
                                                                        01045000
EQUATE VTESIZE =26;                                                     01050000
DEFINE                                                                  01055000
 VCB'FLAGS  =VTBUF#,            << state bits >>                        01060000
   VCB'ASCII  =VCB'FLAGS.(0:1)#,  << ASCII F-option >>                  01065000
   VCB'FLUSH  =VCB'FLAGS.(1:1)#,  << =REPLY 0 done >>                   01070000
   VCB'DR'WAIT=VCB'FLAGS.(2:1)#,  << DEVREC wait   >>          <<03618>>01075000
   VCB'POSN   =VCB'FLAGS.(3:4)#,  << tape position >>                   01080000
   VCB'WRITE  =VCB'FLAGS.(7:1)#,  << write access >>                    01085000
   VCB'SEQTYP =VCB'FLAGS.(8:2)#,  << sequencing type >>                 01090000
   VCB'LABTYP =VCB'FLAGS.(10:2)#, << label type >>                      01095000
   VCB'LNKWAIT=VCB'FLAGS.(12:1)#, << waiting for link >>                01100000
   VCB'MNTWAIT=VCB'FLAGS.(13:1)#, << waiting for mount >>               01105000
   VCB'RSWAIT =VCB'FLAGS.(14:1)#, << wait for reelswitch >>             01110000
   VCB'INUSE  =VCB'FLAGS.(15:1)#, << this entry in use >>               01115000
 VCB'LDEV      =VTBUF(1)#,                                              01120000
 VCB'PIN       =VTBUF(2)#,                                              01125000
 VCB'FNUM      =VTBUF(3)#,      << FOPEN nr. >>                         01130000
 VCB'FSEQ      =VTBUF(4)#,      << file seq. nr.  1:31,4 >>             01135000
 VCB'FLAG2     =VTBUF(5)#,                                              01140000
   VCB'STORTAP=VCB'FLAG2.(0:1)#,  << STORE tape >>                      01145000
   VCB'RSWDONE=VCB'FLAG2.(1:1)#,  << Reelswitch was done >>             01150000
   VCB'WRITDIR=VCB'FLAG2.(2:1)#,  << next file is directory >>          01155000
   VCB'NEEDVOL=VCB'FLAG2.(3:1)#,    << VOL1 write flag >>      <<03581>>01160000
   VCB'DENSITY=VCB'FLAG2.(4:3)#,  << requested density >>      <<03581>>01165000
   VCB'VSETOPEN=VCB'FLAG2.(7:1)#, << First open of volset >>   <<03581>>01170000
   VCB'REEL   =VCB'FLAG2.(8:8)#,  << reel nr.  1:27,4 >>                01175000
 VCB'EXDATE    =VTBUF(6)#,      << expiration date 1:47,6 >>            01180000
 VCB'FNAME     =VTBUFB(14)#,    << file name  1:4,17 >>                 01185000
 VCB'LOCKWRD   =VTBUFB(32)#,    << lockword  2:15,8 >>                  01190000
 VCB'VSETID    =VTBUFB(40)#,    << volume set ID 1:21,6 >>              01195000
 VCB'VOLID     =VTBUFB(46)#;    << volume ID 0:4,6 >>                   01200000
                                                                        01205000
DEFINE BUILDVCB =                                                       01210000
   BYTE ARRAY VTBUFB(*) =VTBUF;                                         01215000
   LOGICAL INUSE = VTBUF#;                                              01220000
                                                                        01225000
<< VCB'POSN states describe head position on tape. >>                   01230000
                                                                        01235000
EQUATE                                                                  01240000
   LDPNT = 0,     << VOL1 >>                                            01245000
   H1NX  = 1,     << HDR1&2 >>                                          01250000
   AH2   = 3,     << UHLx >>                                            01255000
   AHU   = 4,      << tapemark here >>                                  01260000
   DNX   = 6,     << data >>                                            01265000
   AD    = 7,      << tapemark here >>                                  01270000
   T1NX  = 8,     << EOV1&2 >>                                          01275000
   AT2   =10,     << UTLx >>                                            01280000
   ATU   =11;      << tapemark >>                                       01285000
                                                                        01290000
  << Tape label structure definitions >>                                01295000
                                                                        01300000
EQUATE LBLSIZE =40;     << words >>                                     01305000
DEFINE ANSI'VERSION = "3"#;                                    <<04740>>01310000
DEFINE                                                                  01315000
      L0VOLID  =BLABEL0(4)#,                                            01320000
      L0ACCESS =BLABEL0(10)#,                                           01325000
      L0SMARK  =BLABEL0(79)#;                                           01330000
DEFINE                                                                  01335000
      L1FNAME  =BTLABEL(4)#,                                            01340000
      L1VSETID =BTLABEL(21)#,                                           01345000
      L1REEL   =BTLABEL(27)#,                                           01350000
      L1FSEQ   =BTLABEL(31)#,                                           01355000
      L1CYR    =BTLABEL(42)#,                                           01360000
      L1CDAY   =BTLABEL(44)#,                                           01365000
      L1XYR    =BTLABEL(48)#,                                           01370000
      L1XDAY   =BTLABEL(50)#,                                           01375000
      L1ACC    =BTLABEL(53)#,                                           01380000
      L1NBLKS  =BTLABEL(54)#,                                  <<0196>> 01385000
      L1SYSTEM =BTLABEL(60)#;                                           01390000
DEFINE                                                                  01395000
      L2RFMT   =BTLABEL(4)#,                                            01400000
      L2BSIZE  =BTLABEL(5)#,                                            01405000
      L2RSIZE  =BTLABEL(10)#,                                           01410000
      L2BUFOFF =BTLABEL(50)#,                                           01415000
      L2LOCK   =BTLABEL(15)#,     << HP only >>                         01420000
      L2FTYPE  =BTLABEL(36)#,                                           01425000
      L2CCTL   =BTLABEL(37)#,                                           01430000
      L2DSPOSN =BTLABEL(16)#,    << IBM only >>                         01435000
      L2BLKATT =BTLABEL(38)#;                                           01440000
                                                                        01445000
DEFINE                                                                  01450000
      HPSYSTEM  ="HP MPE 3000 "#,                                       01455000
      FOPASCII  =FOPS.(13:1)#,                                          01460000
      FOPFTYPE  =FOPS.(8:2)#,                                           01465000
      FOPCCTL   =FOPS.(7:1)#;                                           01470000
                                                                        01475000
   << Functions for ATTACHIO >>                                         01480000
                                                                        01485000
EQUATE READ=0,                                                          01490000
       WRITE=1,                                                <<02563>>01495000
       DCLOSE=4,         << Device close >>                    <<02563>>01500000
       READ'STATUS=15,   << Read Status for 7976 >>            <<02563>>01505000
       DEN'FUNC=16,      << Set Density for 7976 >>            <<02563>>01510000
                                                               <<02563>>01515000
   << Important status returns from ATTACHIO >>                <<02563>>01520000
                                                               <<02563>>01525000
      PFAIL'ABORT =  %63,  << Power fail abort >>              <<02563>>01530000
      RUNAWAY'    = %103,  << Tape runaway, new tape >>        <<06333>>01535000
      POWER'UP    = %213,  << Device powered up >>             <<02563>>01540000
      TRANS'ERROR =  %14,  << Transmission error/track error >><<02563>>01545000
      PARITY'ERR  =  %74;  << Parity error (Series II/III) >>  <<02563>>01550000
                                                               <<02563>>01555000
EQUATE TLTDST=26;                                                       01560000
EQUATE TLTSIR=39;                                                       01565000
                                                                        01570000
<< TLT Base Entry Structure definitions >>                              01575000
                                                                        01580000
EQUATE XESIZE   =1,   << entry size >>                                  01585000
       XLTBASE  =2,   << bottom of LDEV part >>                         01590000
       XVTBASE  =3,   << top of LDEV - bottom of Vol T >>               01595000
       XVTTOP   =4,   << top of current Vol Table >>                    01600000
       XVTMAX   =5,   << upper limit for Vol Table >>          <<03581>>01605000
       XVREST   =6;  << begining of the rest of the entry >>   <<03581>>01610000
                                                                        01615000
   INTEGER STATUS=Q-1;                                                  01620000
   INTEGER RTNX=Q-3;                                                    01625000
   INTEGER S0=S-0;                                                      01630000
   LOGICAL LS0=S-0;                                                     01635000
   INTEGER X=X;                                                         01640000
EQUATE CCG=0, CCL=1, CCE=2;                                             01645000
EQUATE                                                         <<06424>>01650000
       EOFSTAT = %12,                                                   01655000
       INVALID  = 4;                                                    01660000
DEFINE CC=STATUS.(6:2)#,                                                01665000
   S0STAT=S0.(8:8)#,                                                    01670000
   ASMB  =ASSEMBLE#;                                                    01675000
DEFINE ENABLE = ASSEMBLE(SED 1)#;                                       01680000
DEFINE DISABLE = ASSEMBLE(SED 0)#;                                      01685000
                                                                        01690000
$INCLUDE INCLFERR                                              <<06333>>01695000
$INCLUDE INCLPCB5                                              <<06424>>01700000
$SET X8=ON                                                              01705000
$INCLUDE INCLLPDT                                              <<06333>>01710000
DEFINE                                                         <<02563>>01715000
$PAGE                                                          <<07339>>01720000
<<----------------------------------------------------------->><<06333>>01725000
<<                                                           >><<06333>>01730000
<<      LPDT density definitions for this module only        >><<06333>>01735000
<<                                                           >><<06333>>01740000
<<----------------------------------------------------------->><<06333>>01745000
      HP7970      =  0#,           << Subtype for HP7970 >>    <<02563>>01750000
      HP7976      =  1#,           << Subtype for HP7976 >>    <<02563>>01755000
      HP7978      =  2#,           << Subtype for HP7978 >>    <<07339>>01760000
      HP7974      =  3#,           << Subtype for HP7974 >>    <<07339>>01765000
   TAPE'DEVICE =                                               <<03581>>01770000
      LDEVTOTYPE(LDEV)=24#,                                    <<03581>>01775000
   NOT'TAPE'DEVICE =                                           <<07339>>01780000
      (LDEVTOTYPE(LDEV)<>24)#,                                 <<07339>>01785000
   SET'BOT'ON =                                                <<03581>>01790000
      SET'LPDT'BOT(LDEV,1)#,                                   <<03581>>01795000
   SET'BOT'OFF =                                               <<03581>>01800000
      SET'LPDT'BOT(LDEV,0)#,                                   <<03581>>01805000
   VARIABLE'DENSITY =       <<Test for var. dens. tape drive>> <<07339>>01810000
      TAPE'DEVICE LAND                                         <<07339>>01815000
      ((LPDT'AUTO'SUBTYPE = HP7974) LOR                        <<07339>>01820000
       (LPDT'AUTO'SUBTYPE = HP7976) LOR                        <<07339>>01825000
       (LPDT'AUTO'SUBTYPE = HP7978))#,                         <<07339>>01830000
   NOT'VARIABLE'DENSITY =   << Test for non var. density    >> <<07339>>01835000
      NOT'TAPE'DEVICE LOR                                      <<07339>>01840000
      ((LPDT'AUTO'SUBTYPE <> HP7974) LAND                      <<07339>>01845000
       (LPDT'AUTO'SUBTYPE <> HP7976) LAND                      <<07339>>01850000
       (LPDT'AUTO'SUBTYPE <> HP7978))#;                        <<07339>>01855000
            <<Remember that LDEV could be SDISC>>              <<03581>>01860000
$INCLUDE INCLLDT5                                              <<06333>>01865000
                                                               <<02563>>01870000
  << Tape trouble codes  >>                                    <<03581>>01875000
EQUATE                                                         <<03581>>01880000
  TT5 =5,                                                      <<03581>>01885000
  TT6 =6,                                                      <<03581>>01890000
  TT7 =7,                                                      <<03581>>01895000
  TT9 =9,                                                      <<03581>>01900000
  TT10=10,                                                     <<03581>>01905000
  TT11=11,                                                     <<03618>>01910000
  TT12=12,                                                     <<03618>>01915000
  TT13=13,                                                     <<03618>>01920000
  TT14=14,                                                     <<03618>>01925000
  TT15=15,                                                     <<03581>>01930000
  TT16=16,                                                     <<03581>>01935000
  TT23=23,                                                     <<03581>>01940000
  TT24=24,                                                     <<03581>>01945000
  TT25=25,                                                     <<03581>>01950000
  TT27=27,                                                     <<03581>>01955000
  TT29=29,                                                     <<03581>>01960000
  TT41=41,                                                     <<03581>>01965000
  TT42=42,                                                     <<03581>>01970000
  TT43=43,                                                     <<03581>>01975000
  TT52=52,                                                     <<03581>>01980000
  TT53=53;                                                     <<03581>>01985000
EQUATE MONITOR = %1077;   << FILESYS SYSGLOB cell >>           <<02648>>01990000
DEFINE DISABL'IBM = NOT ABSOLUTE(MONITOR).(12:1)#;             <<02648>>01995000
                                                               <<02648>>02000000
$PAGE " FORWARD AND EXTERNAL DECLARATIONS "                             02005000
LOGICAL PROCEDURE CKFORLDEV(LDEV);                             <<06026>>02010000
   VALUE LDEV;                                                 <<06026>>02015000
   INTEGER LDEV;                                               <<06026>>02020000
   OPTION FORWARD;                                             <<06026>>02025000
                                                               <<06026>>02030000
LOGICAL PROCEDURE CKFOREXDATE(LDEV,RDWR,LBLED);                <<06026>>02035000
   VALUE LDEV,RDWR,LBLED;                                      <<06026>>02040000
   INTEGER LDEV,RDWR; LOGICAL LBLED;                           <<06026>>02045000
   OPTION FORWARD;                                             <<06026>>02050000
                                                                        02055000
PROCEDURE CLEANLDEV(LDEV);                                     <<02563>>02060000
   VALUE LDEV;                                                 <<02575>>02065000
   INTEGER LDEV;                                               <<02563>>02070000
   OPTION FORWARD;                                             <<02563>>02075000
                                                               <<02563>>02080000
PROCEDURE STORE'DENSITY(LDEV,DENSITY,MODE);                    <<02563>>02085000
   VALUE LDEV,MODE;                                            <<02563>>02090000
   INTEGER LDEV,MODE;                                          <<02563>>02095000
   ARRAY DENSITY;                                              <<02563>>02100000
   OPTION FORWARD;                                             <<02563>>02105000
                                                               <<02563>>02110000
INTEGER PROCEDURE CONVERTDATE(DATE);                           <<0196>> 02115000
    VALUE DATE;                                                <<0196>> 02120000
    BYTE POINTER DATE;                                         <<0196>> 02125000
    OPTION EXTERNAL;                                           <<0196>> 02130000
<< Converts string of form "MM/DD/YY" to CALENDAR format. >>            02135000
                                                                        02140000
LOGICAL PROCEDURE GETSIR(SIRNUM);                                       02145000
   VALUE SIRNUM;                                                        02150000
   INTEGER SIRNUM;                                                      02155000
   OPTION EXTERNAL;                                                     02160000
                                                                        02165000
LOGICAL PROCEDURE RELSIR(SIRNUM,ALREADY);                               02170000
   VALUE SIRNUM,ALREADY;                                                02175000
   INTEGER SIRNUM;                                                      02180000
   LOGICAL ALREADY;                                                     02185000
   OPTION EXTERNAL;                                                     02190000
                                                                        02195000
LOGICAL PROCEDURE EXCHANGEDB(DSTX);                                     02200000
   VALUE DSTX;                                                          02205000
   LOGICAL DSTX;                                                        02210000
   OPTION EXTERNAL;                                                     02215000
                                                                        02220000
PROCEDURE SUDDENDEATH(CRASH);                                           02225000
   VALUE CRASH; INTEGER CRASH;                                          02230000
   OPTION EXTERNAL;                                                     02235000
                                                                        02240000
DOUBLE PROCEDURE ATTACHIO(LDEV,QMISC,DSTX,ADDR,FUNC,CNT,P1,P2,FLAGS);   02245000
   VALUE LDEV,QMISC,DSTX,ADDR,FUNC,CNT,P1,P2,FLAGS;                     02250000
   INTEGER LDEV,QMISC,DSTX,ADDR,FUNC,CNT,P1,P2,FLAGS;                   02255000
   OPTION EXTERNAL;                                                     02260000
                                                                        02265000
PROCEDURE REPORT'IOERROR(LDEV,IOSTATUS);                       <<02673>>02270000
   VALUE LDEV,IOSTATUS;                                        <<02673>>02275000
   INTEGER LDEV,IOSTATUS;                                      <<02673>>02280000
   OPTION EXTERNAL;                                            <<02673>>02285000
                                                               <<02673>>02290000
INTEGER PROCEDURE REMRITENTRY(ADR);                                     02295000
   VALUE ADR;                                                           02300000
   INTEGER ADR;                                                         02305000
   OPTION EXTERNAL;                                                     02310000
                                                                        02315000
PROCEDURE FREEDEVICE(LDEV,WAIT,NOREW);                                  02320000
   VALUE WAIT,LDEV,NOREW;                                               02325000
   INTEGER LDEV;                                                        02330000
   LOGICAL WAIT,NOREW;                                                  02335000
   OPTION VARIABLE,EXTERNAL;                                            02340000
                                                                        02345000
PROCEDURE SET'LPDT'BOT(LDEV,VAL);                              <<02563>>02350000
   VALUE LDEV,VAL; LOGICAL LDEV,VAL;                           <<02563>>02355000
   OPTION EXTERNAL;                                            <<02563>>02360000
                                                               <<02563>>02365000
PROCEDURE LOG14;                                                        02370000
  OPTION EXTERNAL;                                                      02375000
                                                                        02380000
PROCEDURE DEBUG;                                                        02385000
   OPTION EXTERNAL;                                                     02390000
                                                                        02395000
PROCEDURE DELAY(T);                                            <<02563>>02400000
   VALUE T; DOUBLE T;                                          <<02563>>02405000
   OPTION EXTERNAL;                                            <<02563>>02410000
                                                               <<02563>>02415000
INTEGER PROCEDURE GENMSG(SETNO,MSGNO,MASK,PARM1,PARM2,                  02420000
      PARM3,PARM4,PARM5,DEST,REPLY,OFFSET,DST,CONTROL);                 02425000
   VALUE   SETNO,MSGNO,MASK,PARM1,PARM2,PARM3,PARM4,PARM5,              02430000
           DEST,REPLY,OFFSET,DST,CONTROL;                               02435000
   INTEGER SETNO,MSGNO,DEST,DST;                                        02440000
   LOGICAL MASK,PARM1,PARM2,PARM3,PARM4,PARM5,REPLY,OFFSET,             02445000
      CONTROL;                                                          02450000
   OPTION VARIABLE,EXTERNAL;                                            02455000
                                                                        02460000
PROCEDURE POST'ACB'ERROR(FILENUM,THEIRSTATUS,ERROR);           <<02703>>02465000
  VALUE FILENUM,THEIRSTATUS,ERROR;                             <<02703>>02470000
  INTEGER FILENUM,ERROR;                                       <<02703>>02475000
  LOGICAL THEIRSTATUS;                                         <<02703>>02480000
  OPTION EXTERNAL;                                             <<02703>>02485000
                                                               <<03581>>02490000
INTEGER PROCEDURE LDEVTOTYPE(LDEV);                            <<03581>>02495000
  VALUE LDEV; INTEGER LDEV; OPTION EXTERNAL;                   <<03581>>02500000
                                                               <<03581>>02505000
PROCEDURE FORS'XDS'DEALLOC(LDEV);                              <<03634>>02510000
  VALUE LDEV;                                                  <<03634>>02515000
  INTEGER LDEV;                                                <<03634>>02520000
  OPTION EXTERNAL;                                             <<03634>>02525000
                                                               <<03634>>02530000
INTRINSIC CALENDAR,CTRANSLATE,FGETINFO,FCONTROL,PRINTOPREPLY;           02535000
INTRINSIC ASCII;                                               <<02722>>02540000
$PAGE " UTILITIES "                                                     02545000
PROCEDURE TAPETROUBLE(CRASH);                                           02550000
   VALUE CRASH; INTEGER CRASH;                                          02555000
   OPTION INTERNAL;                                            <<02621>>02560000
                                                                        02565000
   BEGIN                                                                02570000
   SUDDENDEATH(86);                                                     02575000
   END;                                                                 02580000
INTEGER PROCEDURE SETOWNED(LDEV,N);                                     02585000
   VALUE LDEV,N;                                                        02590000
   INTEGER LDEV,N;                                                      02595000
   OPTION INTERNAL;                                            <<02621>>02600000
                                                                        02605000
<< Get or set ownership bits in the LPDT entry. >>                      02610000
                                                                        02615000
   BEGIN                                                                02620000
   INTEGER LPDT'INDEX;                                         <<06333>>02625000
                                                                        02630000
   DISABLE;                                                             02635000
   LPDT'INDEX := LDEV * SIZE'OF'LPDT'ENTRY;                    <<06333>>02640000
   SETOWNED := LPDT'DEV'OWN'STATE;                             <<06333>>02645000
   IF N >= 0 THEN                                              <<06333>>02650000
      LPDT'DEV'OWN'STATE := N;     << new value >>             <<06333>>02655000
   ENABLE;                                                              02660000
   END;                                                                 02665000
PROCEDURE ATTIO(LDEV,FUNC);                                             02670000
VALUE LDEV,FUNC; INTEGER LDEV,FUNC;                                     02675000
   OPTION INTERNAL;                                            <<02621>>02680000
                                                                        02685000
   BEGIN                                                                02690000
   IF LDEV=0 THEN TAPETROUBLE(TT5);  << oops! >>               <<03581>>02695000
   TOS := ATTACHIO(LDEV,0,0,0,FUNC,0,0,0,%11);                          02700000
   DEL;                                                                 02705000
   CC := IF S0.(13:3) = 1 THEN CCE ELSE                                 02710000
      IF S0.(13:3) = 2 THEN CCG ELSE CCL;                               02715000
   RTNX := TOS;                                                         02720000
   END;                                                                 02725000
PROCEDURE LOGIT(VTBUF);                                                 02730000
  ARRAY VTBUF;                                                          02735000
   OPTION INTERNAL;                                            <<02621>>02740000
                                                                        02745000
<< Write Log record.  The record is built by shuffling                  02750000
the VCB, so caller must have finished using it.  DB is                  02755000
at the stack. >>                                                        02760000
                                                                        02765000
   BEGIN                                                                02770000
   VTBUF(26) := VCB'PIN;                                       <<06939>>02775000
   VTBUF(2) := VCB'LDEV;                                       <<02673>>02780000
   TOS := VCB'FNUM;   << Get file num. out of the way. >>      <<02673>>02785000
   VTBUF(3) := VCB'FSEQ;                                       <<02673>>02790000
   VTBUF(4).(0:8) := TOS;                                      <<02673>>02795000
   VTBUF(4).(8:8) := VTBUF(0).(8:8);   << seq flags >>                  02800000
                                                                        02805000
   TOS := @VTBUF+2;                                                     02810000
   TOS := 25;                                                  <<06939>>02815000
   TOS := 14;    << log record # >>                                     02820000
   LOG14;                                                               02825000
   END;       << procedure LOGIT>>                                      02830000
$PAGE " NUMERICAL CONVERSION "                                          02835000
PROCEDURE BIN2ASC(NUM,FPTR,FSIZE);                                      02840000
VALUE NUM,FSIZE;                                                        02845000
DOUBLE NUM;                                                             02850000
BYTE ARRAY FPTR;                                                        02855000
INTEGER FSIZE;                                                          02860000
   OPTION INTERNAL;                                            <<02621>>02865000
                                                                        02870000
   BEGIN    << convert to ASCII, with leading zeroes. >>                02875000
   TOS := NUM;                                                          02880000
   WHILE (FSIZE := FSIZE-1) >= 0 DO                                     02885000
      BEGIN                                                             02890000
      TOS := 10;                                                        02895000
      ASMB(LDIV);                                                       02900000
      FPTR(FSIZE) := TOS+"0";   << remainder >>                         02905000
      ASMB(ZERO,XCH);           << restore double >>                    02910000
      END;                                                              02915000
   END;                                                                 02920000
LOGICAL PROCEDURE BINARY'(STRING,NCHARS);                               02925000
VALUE NCHARS;                                                           02930000
BYTE ARRAY STRING;                                                      02935000
INTEGER NCHARS;                                                         02940000
   OPTION INTERNAL;                                            <<02621>>02945000
                                                                        02950000
<< Similar to the intrinsic, but is more forgiving of                   02955000
leading and trailing blanks. >>                                         02960000
                                                                        02965000
   BEGIN                                                                02970000
   INTEGER IX;                                                          02975000
   LOGICAL RESULT = BINARY';                                            02980000
                                                                        02985000
   CC := CCE;                                                           02990000
   IX := 0;                                                             02995000
   WHILE IX < NCHARS AND STRING(IX) = " " DO IX := IX+1;                03000000
   WHILE IX < NCHARS AND STRING(IX) <> " " DO                           03005000
      BEGIN                                                             03010000
      IF ("0" <= INTEGER(STRING(IX)) <= "9") THEN                       03015000
         RESULT := RESULT*10+LOGICAL(STRING(IX)-"0") ELSE               03020000
         CC := CCL;                                                     03025000
      IX := IX+1;                                                       03030000
      END;                                                              03035000
   END;                                                                 03040000
$PAGE " TAPE LABEL TABLE MANAGEMENT "                                   03045000
PROCEDURE GETXDSW(TARGET,DSTN,OFFSET,WC);                               03050000
   VALUE DSTN,OFFSET,WC;                                                03055000
   INTEGER DSTN,OFFSET,WC;                                              03060000
   ARRAY TARGET;                                                        03065000
   OPTION INTERNAL;                                            <<02621>>03070000
                                                                        03075000
<< A dress suit for an MFDS instruction. >>                             03080000
                                                                        03085000
   BEGIN                                                                03090000
   TOS := @TARGET;                                                      03095000
   TOS := DSTN; TOS := OFFSET;                                          03100000
   TOS := WC;                                                           03105000
   ASMB(MFDS 4);                                                        03110000
   END;                                                                 03115000
PROCEDURE PUTXDSW(DSTN,OFFSET,SOURCE,WC);                               03120000
   VALUE DSTN,OFFSET,WC;                                                03125000
   INTEGER DSTN,OFFSET,WC;                                              03130000
   ARRAY SOURCE;                                                        03135000
   OPTION INTERNAL;                                            <<02621>>03140000
                                                                        03145000
<< Fancy clothes for an MTDS instruction. >>                            03150000
                                                                        03155000
   BEGIN                                                                03160000
   TOS := DSTN; TOS := OFFSET;                                          03165000
   TOS := @SOURCE;                                                      03170000
   TOS := WC;                                                           03175000
   ASMB(MTDS 4);                                                        03180000
   END;                                                                 03185000
$PAGE                                                                   03190000
INTEGER PROCEDURE GETFNUM(FNUM,VTBUF);                                  03195000
VALUE FNUM; LOGICAL FNUM;                                               03200000
LOGICAL ARRAY VTBUF;                                                    03205000
   OPTION INTERNAL;                                            <<02621>>03210000
                                                                        03215000
<< Search for volume entry to match FNUM.  For present version,         03220000
match PIN and Filenum; eventually this should become ACB                03225000
location.  DB is at stack. >>                                           03230000
                                                                        03235000
   BEGIN                                                                03240000
   LOGICAL I = GETFNUM;                                                 03245000
   LOGICAL OLDSIR,PIN;                                                  03250000
   DEFINE  INUSE = VTBUF(0)#;                                           03255000
   DOUBLE VTBOUNDS;                                                     03260000
      LOGICAL VTBASE = VTBOUNDS;                                        03265000
      LOGICAL VTTOP = VTBOUNDS+1;                                       03270000
                                                                        03275000
   CC := CCE;                                                           03280000
   PIN := CURPRC/PCBSIZE;                                      <<06424>>03285000
   OLDSIR := GETSIR(TLTSIR);                                            03290000
   GETXDSW(VTBOUNDS,TLTDST,XVTBASE,2);                                  03295000
   I := VTBASE;                                                         03300000
   WHILE I < VTTOP DO                                                   03305000
      BEGIN                                                             03310000
      TOS := @VTBUF;                                                    03315000
      TOS := TLTDST; TOS := I;                                          03320000
      TOS := VTESIZE;                                                   03325000
      ASMB(MFDS 4);                                                     03330000
      IF INUSE AND (VCB'FNUM = FNUM) AND (VCB'PIN = PIN) THEN GO OUT;   03335000
      I := I+VTESIZE;                                                   03340000
      END;                                                              03345000
   CC := CCL;    << Not found. >>                                       03350000
   GETFNUM := -1;      << Rat trap. >>                                  03355000
OUT:                                                                    03360000
   RELSIR(TLTSIR,OLDSIR);                                               03365000
   END;        << procedure GETFNUM >>                                  03370000
INTEGER PROCEDURE GETLDEV(LDEV,LTBUF);                                  03375000
VALUE LDEV; LOGICAL LDEV;                                               03380000
LOGICAL ARRAY LTBUF;                                                    03385000
   OPTION INTERNAL;                                            <<02621>>03390000
                                                                        03395000
<< Search VT for entry matching LDEV.  DB is at stack. >>               03400000
                                                                        03405000
   BEGIN                                                                03410000
   LOGICAL I = GETLDEV;                                                 03415000
   INTEGER OLDSIR;                                                      03420000
   LOGICAL LTTOP;                                                       03425000
                                                                        03430000
   IF LDEV=0 THEN TAPETROUBLE(TT6);                            <<03581>>03435000
   CC := CCE;                                                           03440000
   OLDSIR := GETSIR(TLTSIR);                                            03445000
   GETXDSW(LTTOP,TLTDST,XVTBASE,1);                                     03450000
   I := LTESIZE;                                                        03455000
                                                               <<02563>>03460000
WHILE I < LTTOP DO                                             <<02563>>03465000
   BEGIN                                                       <<02563>>03470000
   TOS := @LTBUF;                                                       03475000
   TOS := TLTDST; TOS := I;                                             03480000
   TOS := VTESIZE;                                                      03485000
   ASMB(MFDS 4);                                                        03490000
   IF LCB'LDEV = LDEV THEN GO OUT;                                      03495000
   I := I+LTESIZE;                                                      03500000
   END;                                                        <<02563>>03505000
                                                               <<02563>>03510000
   CC := CCL;    << Not found. >>                                       03515000
OUT:                                                                    03520000
   RELSIR(TLTSIR,OLDSIR);                                               03525000
   END;        << procedure GETLDEV >>                                  03530000
$PAGE                                                                   03535000
PROCEDURE POSTVTENT(VTBUF,VTADDR,SCODE);                                03540000
VALUE SCODE; LOGICAL VTADDR,SCODE; ARRAY VTBUF;                         03545000
   OPTION INTERNAL;                                            <<02621>>03550000
                                                                        03555000
<< Stores entry into VT. DB must be at stack.  VTADDR=0                 03560000
means create a new entry (only in Volume section).  >>                  03565000
                                                                        03570000
   BEGIN                                                                03575000
   LOGICAL INUSE;                                                       03580000
   ARRAY VTBOUNDS(0:2) =Q;                                              03585000
      LOGICAL VTBASE = VTBOUNDS;                                        03590000
      LOGICAL VTTOP = VTBOUNDS+1;                                       03595000
      LOGICAL VTMAX = VTBOUNDS+2;                                       03600000
                                                                        03605000
   GETXDSW(VTBOUNDS,TLTDST,XVTBASE,3);                                  03610000
   IF INTEGER(VTADDR) < 0 THEN TAPETROUBLE(TT6);               <<03581>>03615000
   IF VTADDR <> 0 THEN GO STUFF;                                        03620000
                                                                        03625000
 << Create new entry; find hole for it. >>                              03630000
                                                                        03635000
   VCB'INUSE := 1;                                                      03640000
   VTADDR := VTBASE;                                                    03645000
LOOP:                                                                   03650000
   IF VTADDR >= VTTOP THEN GO EXPAND;                                   03655000
   TOS := @INUSE;                                                       03660000
   TOS := TLTDST; TOS := VTADDR;                                        03665000
   TOS := 1;                                                            03670000
   ASMB(MFDS 4);                                                        03675000
   IF NOT INUSE THEN GO STUFF;                                          03680000
   VTADDR := VTADDR+VTESIZE;                                            03685000
   GO LOOP;                                                             03690000
                                                                        03695000
EXPAND:                                                                 03700000
   CC := CCL;                                                           03705000
   VTTOP := VTTOP+VTESIZE;                                              03710000
   IF VTTOP >= VTMAX THEN GO BYEBYE;     << Burp! >>                    03715000
   PUTXDSW(TLTDST,XVTTOP,VTTOP,1);     << update size >>                03720000
STUFF:                                                                  03725000
   PUTXDSW(TLTDST,VTADDR,VTBUF,VTESIZE);   << post new entry. >>        03730000
   CC := CCE;                                                           03735000
BYEBYE:                                                                 03740000
   IF SCODE <> -1 THEN RELSIR(TLTSIR,SCODE);                            03745000
   END;        << procedure POSTVTENT >>                                03750000
$PAGE                                                          <<03618>>03755000
PROCEDURE LABELED'DEV'MOUNTED(LDEV);                           <<03618>>03760000
  VALUE LDEV;                                                  <<03618>>03765000
  LOGICAL LDEV;                                                <<03618>>03770000
  OPTION UNCALLABLE;                                           <<03618>>03775000
COMMENT                                                        <<03618>>03780000
                                                               <<03618>>03785000
   This procedure allows DEVREC and PVPROC to let REELSWITCH   <<03618>>03790000
know that the "tape" has been mounted.  It will set the        <<03618>>03795000
DEVREC wait bit in the VCB of the table.                       <<03618>>03800000
                                                               <<03618>>03805000
Will be rewritten when we allow different LDEVs for            <<03618>>03810000
reswitches.                                                    <<03618>>03815000
                                                               <<03618>>03820000
;                                                              <<03618>>03825000
BEGIN                                                          <<03618>>03830000
LOGICAL VTADDR,LTADDR;                                         <<03618>>03835000
INTEGER SCODE;                                                 <<03618>>03840000
LOGICAL ARRAY VTBUF(0:VTESIZE-1)=Q;                            <<03618>>03845000
  BUILDVCB;                                                    <<03618>>03850000
LOGICAL ARRAY LTBUF(0:LTESIZE-1)=Q;                            <<03618>>03855000
  BUILDLCB;                                                    <<03618>>03860000
                                                               <<03618>>03865000
LTADDR := GETLDEV(LDEV,LTBUF);                                 <<03618>>03870000
IF < THEN TAPETROUBLE(TT11);                                   <<03618>>03875000
IF LCB'VCB > 0    <<  Tape device is linked up  >>             <<03618>>03880000
  THEN BEGIN                                                   <<03618>>03885000
    VTADDR := LCB'VCB;                                         <<03618>>03890000
    GETXDSW(VTBUF,TLTDST,VTADDR,VTESIZE);                      <<03618>>03895000
    IF LDEV <> VCB'LDEV THEN TAPETROUBLE(TT12);                <<03618>>03900000
    VCB'DR'WAIT := 1;                                          <<03618>>03905000
    SCODE := GETSIR(TLTSIR);                                   <<03618>>03910000
    POSTVTENT(VTBUF,VTADDR,SCODE);                             <<03618>>03915000
    END;                                                       <<03618>>03920000
END;                                                           <<03618>>03925000
$PAGE                                                          <<03618>>03930000
LOGICAL PROCEDURE TEST'FOR'REELSWITCH(LDEV);                   <<03618>>03935000
VALUE LDEV;                                                    <<03618>>03940000
LOGICAL LDEV;                                                  <<03618>>03945000
OPTION UNCALLABLE;                                             <<03618>>03950000
COMMENT                                                        <<03618>>03955000
                                                               <<03618>>03960000
  This procedure will let the caller (PVPROC) know if we       <<03618>>03965000
are waiting for a REELSWITCH.  It will check the               <<03618>>03970000
VCB'RSWAIT bit in the VCB for the volume mounted on the        <<03618>>03975000
LDEV.                                                          <<03618>>03980000
                                                               <<03618>>03985000
  Returns: TRUE if waiting for a reelswitch,                   <<03618>>03990000
           FALSE if not waiting for a reelswitch.              <<03618>>03995000
                                                               <<03618>>04000000
Will be rewritten when we allow different LDEVs for            <<03618>>04005000
reelswitches.                                                  <<03618>>04010000
                                                               <<03618>>04015000
;                                                              <<03618>>04020000
BEGIN                                                          <<03618>>04025000
LOGICAL VTADDR,LTADDR;                                         <<03618>>04030000
INTEGER SCODE;                                                 <<03618>>04035000
LOGICAL ARRAY VTBUF(0:VTESIZE-1)=Q;                            <<03618>>04040000
  BUILDVCB;                                                    <<03618>>04045000
LOGICAL ARRAY LTBUF(0:VTESIZE-1)=Q;                            <<03618>>04050000
  BUILDLCB;                                                    <<03618>>04055000
                                                               <<03618>>04060000
LTADDR := GETLDEV(LDEV,LTBUF);                                 <<03618>>04065000
IF < THEN TAPETROUBLE(TT13);                                   <<03618>>04070000
IF LCB'VCB > 0       <<  Tape device is linked up  >>          <<03618>>04075000
  THEN BEGIN                                                   <<03618>>04080000
    VTADDR := LCB'VCB;                                         <<03618>>04085000
    GETXDSW(VTBUF,TLTDST,VTADDR,VTESIZE);                      <<03618>>04090000
    IF LDEV <> VCB'LDEV THEN TAPETROUBLE(TT14);                <<03618>>04095000
    TEST'FOR'REELSWITCH := VCB'RSWAIT;                         <<03618>>04100000
    END                                                        <<03618>>04105000
  ELSE TEST'FOR'REELSWITCH := FALSE;                           <<03618>>04110000
END;                                                           <<03618>>04115000
PROCEDURE SETUP'TAPES;                                         <<02563>>04120000
OPTION PRIVILEGED,UNCALLABLE;                                           04125000
COMMENT                                                        <<03581>>04130000
                                                               <<03581>>04135000
     Re-format TLTDST as required.  Also, initialize other     <<03581>>04140000
     tape data structures.  Runs only once.  Gets the table    <<03581>>04145000
     in unformated condition (as follows).                     <<03581>>04150000
                                                               <<03581>>04155000
   Word 0 - Size of TLTDST                                     <<03581>>04160000
   Word 1 - N: Number of LDEVs in table.                       <<03581>>04165000
   Word 2 - In (0:14): LDEV number, In (14:2): 1 if tape       <<06202>>04170000
     ~    -     otherwise 0.                                   <<03581>>04175000
   Word N+2                                                    <<03581>>04180000
                                                               <<03581>>04185000
;                                                              <<03581>>04190000
                                                                        04195000
   BEGIN                                                                04200000
   INTEGER POINTER OLDLDEV,NEWLDEV;                                     04205000
   INTEGER                                                     <<03581>>04210000
      MAXSIZE,                                                 <<03581>>04215000
      SCODE,                                                   <<02563>>04220000
      USERDB,                                                  <<02563>>04225000
      NUMLDEVS,       << Number of tape LDEVs >>               <<02563>>04230000
      INDEX := 0,     << Index for TAPE'LDEVS >>               <<02563>>04235000
      LDEV;                                                    <<02563>>04240000
   EQUATE                                                               04245000
      OLDLDEVBASE = 2,                                         <<03581>>04250000
      NEWLDEVBASE = LTESIZE+1;                                          04255000
   INTEGER OLDNUMLDEVW = DB+1;                                 <<03581>>04260000
   INTEGER MAXSIZEW = DB;                                      <<03581>>04265000
<< The next declaration must be the last one in the >>         <<02563>>04270000
<< procedure.  A dynamic direct array will be built >>         <<02563>>04275000
<< on Top Of Stack with an ADDS instruction. >>                <<02563>>04280000
   INTEGER ARRAY TAPE'LDEVS(*) = Q;                            <<02563>>04285000
                                                               <<02563>>04290000
   DEFINE                                                      <<03581>>04295000
     DEV=(0:14)#,                                              <<06202>>04300000
     TAPE=(14:2)#;                                             <<06202>>04305000
                                                               <<03581>>04310000
                                                                        04315000
   SCODE := GETSIR(TLTSIR);                                    <<02563>>04320000
   USERDB := EXCHANGEDB(TLTDST);                               <<02563>>04325000
                                                               <<02563>>04330000
<< Get stack space for TAPE'LDEVS array >>                     <<02563>>04335000
                                                               <<02563>>04340000
   NUMLDEVS := OLDNUMLDEVW;                                    <<03581>>04345000
   MAXSIZE := MAXSIZEW;                                        <<03581>>04350000
   TOS := NUMLDEVS;                                            <<02563>>04355000
   ASMB( ADDS 0 );                                             <<02563>>04360000
                                                               <<02563>>04365000
<< Move LDEV numbers into local array. >>                      <<02563>>04370000
                                                               <<02563>>04375000
   @OLDLDEV := OLDLDEVBASE;                                    <<02563>>04380000
                                                               <<02563>>04385000
   WHILE NUMLDEVS > 0  DO                                      <<02563>>04390000
      BEGIN                                                    <<02563>>04395000
                                                               <<02563>>04400000
      TAPE'LDEVS(INDEX) := OLDLDEV;                            <<03581>>04405000
                                                               <<02563>>04410000
      @OLDLDEV := @OLDLDEV + 1;                                <<03581>>04415000
      NUMLDEVS := NUMLDEVS - 1;                                <<02563>>04420000
      INDEX := INDEX + 1;                                      <<02563>>04425000
      END;                                                     <<02563>>04430000
                                                               <<02563>>04435000
<< Restructure table into new format. >>                       <<02563>>04440000
                                                               <<02563>>04445000
   @NEWLDEV := NEWLDEVBASE;                                    <<02563>>04450000
   NUMLDEVS := INDEX;                                          <<02563>>04455000
   INDEX := 0;                                                 <<02563>>04460000
                                                               <<02563>>04465000
   WHILE NUMLDEVS > 0  DO                                      <<02563>>04470000
      BEGIN                                                    <<02563>>04475000
      << Zero out TLT entry >>                                 <<02563>>04480000
      NEWLDEV(-1) := 0;                                        <<02563>>04485000
      MOVE NEWLDEV(0) := NEWLDEV(-1),(LTESIZE-1);              <<02563>>04490000
                                                               <<02563>>04495000
      NEWLDEV := TAPE'LDEVS(INDEX).DEV;                        <<03581>>04500000
                                                               <<02563>>04505000
      NEWLDEV(-1).(6:1) := TAPE'LDEVS(INDEX).TAPE;             <<03581>>04510000
                                                               <<03581>>04515000
      @NEWLDEV := @NEWLDEV + LTESIZE;                          <<02563>>04520000
      NUMLDEVS := NUMLDEVS - 1;                                <<02563>>04525000
      INDEX := INDEX + 1;                                      <<02563>>04530000
      END;                                                     <<02563>>04535000
                                                               <<02563>>04540000
<< Make base entry. >>                                                  04545000
                                                                        04550000
   @NEWLDEV := @NEWLDEV-1;                                              04555000
   @OLDLDEV := 0;                                                       04560000
   OLDLDEV(0) := 1;      << initialized >>                              04565000
   OLDLDEV(XESIZE) := LTESIZE;                                          04570000
   OLDLDEV(XLTBASE) := LTESIZE;                                         04575000
   OLDLDEV(XVTBASE) := @NEWLDEV;                                        04580000
   OLDLDEV(XVTTOP) := @NEWLDEV;                                         04585000
   OLDLDEV(XVTMAX) := MAXSIZE;                                          04590000
   OLDLDEV(XVREST) := 0;                                       <<03581>>04595000
   MOVE OLDLDEV(XVREST+1) := OLDLDEV(XVREST),(19);             <<03581>>04600000
                                                                        04605000
   RELSIR(TLTSIR,SCODE);                                                04610000
   EXCHANGEDB(USERDB);                                                  04615000
                                                               <<02563>>04620000
<< Initialize tape density data structures.  >>                <<02563>>04625000
<< Zero density fields, and turn on BOT bit. >>                <<02563>>04630000
                                                               <<02563>>04635000
   WHILE (INDEX := INDEX - 1) >= 0  DO                         <<02563>>04640000
      BEGIN                                                    <<02563>>04645000
      LDEV := TAPE'LDEVS(INDEX);                               <<02563>>04650000
      STORE'DENSITY(LDEV,SCODE,2);   << SCODE is a dummy >>    <<02563>>04655000
      IF TAPE'DEVICE THEN SET'BOT'ON;                          <<03581>>04660000
      END;                                                     <<02563>>04665000
                                                               <<02563>>04670000
   END;         << procedure SETUP'TAPES >>                    <<02563>>04675000
$PAGE " SEGMENT INTERNAL DENSITY MANAGEMENT UTILITIES "        <<02563>>04680000
INTEGER PROCEDURE GET'DENSITY(LDEV);                           <<02563>>04685000
   VALUE LDEV; LOGICAL LDEV;                                   <<02563>>04690000
   OPTION INTERNAL;                                            <<02563>>04695000
                                                               <<02563>>04700000
COMMENT                                                        <<02563>>04705000
                                                               <<02563>>04710000
   This procedure returns the density of the tape on LDEV in   <<02563>>04715000
its internal representation.  Its sole purpose is to hide the  <<02563>>04720000
density data structure from other procedures.                  <<02563>>04725000
                                                               <<02563>>04730000
;       << end of comment >>                                   <<02563>>04735000
                                                               <<02563>>04740000
BEGIN                                                          <<02563>>04745000
INTEGER LDT'INDEX;                                             <<06333>>04750000
LOGICAL ARRAY LDT(0:SIZE'OF'LDT'ENTRY-1);                      <<06333>>04755000
                                                               <<02563>>04760000
   LDT'INDEX := 0;                                             <<06333>>04765000
   GETXDSW(LDT, LDT'DST, LDEV * SIZE'OF'LDT'ENTRY,             <<06333>>04770000
           SIZE'OF'LDT'ENTRY);                                 <<06333>>04775000
   GET'DENSITY := LDT'ACTUAL'TAPE'DENS;                        <<06333>>04780000
END;                                                           <<02563>>04785000
                                                               <<02563>>04790000
LOGICAL PROCEDURE WRONG'DENSITY(VTBUF);                        <<02563>>04795000
   INTEGER ARRAY VTBUF;                                        <<02563>>04800000
   OPTION INTERNAL;                                            <<02563>>04805000
                                                               <<02563>>04810000
COMMENT                                                        <<02563>>04815000
                                                               <<02563>>04820000
   This procedure returns TRUE when the user has made a        <<02563>>04825000
specific density request (i.e. not default) and the tape       <<02563>>04830000
associated with the request is of a different density.         <<02563>>04835000
                                                               <<02563>>04840000
;    << end of comment >>                                      <<02563>>04845000
                                                               <<02563>>04850000
BEGIN                                                          <<02563>>04855000
   IF VCB'DENSITY <> LDT'NO'DENSITY AND                        <<06333>>04860000
     GET'DENSITY(VCB'LDEV) <> VCB'DENSITY  THEN                <<02563>>04865000
      WRONG'DENSITY := TRUE;                                   <<02563>>04870000
END;                                                           <<02563>>04875000
                                                               <<02563>>04880000
LOGICAL PROCEDURE SET'DENSITY(LDEV,DENSITY);                   <<02662>>04885000
   VALUE LDEV,DENSITY;                                         <<02563>>04890000
   LOGICAL LDEV;                                               <<02563>>04895000
   INTEGER DENSITY;                                            <<02563>>04900000
   OPTION INTERNAL;                                            <<02563>>04905000
                                                               <<02563>>04910000
COMMENT                                                        <<02563>>04915000
                                                               <<02563>>04920000
   This procedure sets the density of a multiple density       <<02563>>04925000
mag tape drive.  It is very similar to WRITE'DENSITY in        <<02563>>04930000
module FILEIO.  However, there are certain differences:        <<02563>>04935000
   1)  the BOT bit is handled differently for labelled         <<02563>>04940000
       and unlabelled tapes,                                   <<02563>>04945000
   2)  the requested density is kept in different places       <<02563>>04950000
       for labelled and unlabelled tapes,                      <<02563>>04955000
   3)  DB will always be at the stack,                         <<02563>>04960000
   4)  for now, tape errors are generally ignored in LABSEG,   <<02563>>04965000
   5)  the LDT need not be locked since only one process at    <<02563>>04970000
       a time can access a labelled tape.                      <<02563>>04975000
Returns TRUE if an error occurs.                               <<02662>>04980000
;      << end of comment >>                                    <<02563>>04985000
                                                               <<02563>>04990000
BEGIN                                                          <<02563>>04995000
LOGICAL ARRAY LDT(0:SIZE'OF'LDT'ENTRY-1);                      <<06333>>05000000
INTEGER                                                        <<02563>>05005000
   LPDT'INDEX,                                                 <<06333>>05010000
   LDT'INDEX,                                                  <<06333>>05015000
   ATTIO'STAT,      << Holds ATTACHIO status return >>         <<02563>>05020000
   P2;              << Parameter 2 to ATTACHIO >>              <<02563>>05025000
EQUATE                                                         <<02563>>05030000
   SUCCESSFUL  = 1, << General status, OK >>                   <<02563>>05035000
   BFLAGS      = 1, << Blocked IO flags >>                     <<02563>>05040000
   P2'6250     = 0, << P2 value for 6250 BPI >>                <<02563>>05045000
   P2'1600     = 1, << P2 value for 1600 BPI >>                <<07339>>05050000
   P2'800      = 2; << P2 value for 800  BPI >>                <<07339>>05055000
ARRAY                                                          <<07339>>05060000
   DENSITY'TO'P2'PARM(0:3)=PB := 0,P2'1600,P2'6250,P2'800;     <<07339>>05065000
                                                               <<02563>>05070000
                                                               <<02563>>05075000
   LPDT'INDEX := LDEV * SIZE'OF'LPDT'ENTRY;                    <<06333>>05080000
   IF (NOT'VARIABLE'DENSITY) THEN RETURN;                      <<07339>>05085000
                                                               <<02563>>05090000
   IF DENSITY <> LDT'NO'DENSITY THEN                           <<07339>>05095000
      P2 := DENSITY'TO'P2'PARM(DENSITY)                        <<07339>>05100000
   ELSE IF LPDT'AUTO'SUBTYPE = HP7974 THEN                     <<d8615>>05105000
      P2 := P2'1600    << Default for 7974                  >> <<07339>>05110000
   ELSE                                                        <<07339>>05115000
      P2 := P2'6250;   << Default for 7976 or 7978          >> <<07339>>05120000
                                                               <<02563>>05125000
<< Retry set density if power problems >>                      <<02563>>05130000
                                                               <<02563>>05135000
   DO BEGIN                                                    <<02563>>05140000
      TOS := ATTACHIO(LDEV,0,0,0,DEN'FUNC,0,0,P2,BFLAGS);      <<02563>>05145000
      DEL;                                                     <<02563>>05150000
      ATTIO'STAT := TOS.(8:8);                                 <<02563>>05155000
      END                                                      <<02563>>05160000
   UNTIL ATTIO'STAT <> POWER'UP  AND                           <<02563>>05165000
         ATTIO'STAT <> PFAIL'ABORT;                            <<02563>>05170000
                                                               <<02563>>05175000
   IF ATTIO'STAT.(13:3) = SUCCESSFUL THEN                      <<02563>>05180000
      BEGIN                                                    <<02563>>05185000
      LDT'INDEX := 0;                                          <<06333>>05190000
      GETXDSW(LDT, LDT'DST, LDEV * SIZE'OF'LDT'ENTRY,          <<06333>>05195000
              SIZE'OF'LDT'ENTRY);                              <<06333>>05200000
                                                               <<02563>>05205000
      LDT'ACTUAL'TAPE'DENS := DENSITY;                         <<06333>>05210000
                                                               <<02563>>05215000
      PUTXDSW(LDT'DST, LDEV * SIZE'OF'LDT'ENTRY, LDT,          <<06333>>05220000
              SIZE'OF'LDT'ENTRY);                              <<06333>>05225000
      END                                                       <<2563>>05230000
   ELSE SET'DENSITY := TRUE;    << error >>                     <<2563>>05235000
   END;       << of procedure SET'DENSITY >>                    <<2563>>05240000
$PAGE " GOODREEL  "                                            <<02563>>05245000
LOGICAL PROCEDURE GOODREEL(VTBUF,LTBUF);                       <<02648>>05250000
LOGICAL ARRAY VTBUF,LTBUF;                                              05255000
OPTION INTERNAL;                                                        05260000
                                                                        05265000
<< Decides if a mounted volume is suitable to a tape request.  >>       05270000
                                                                        05275000
   BEGIN                                                                05280000
   BUILDLCB;                                                            05285000
   BUILDVCB;                                                            05290000
                                                                        05295000
   IF VCB'LABTYP <> LCB'LABTYP THEN GO NG;                              05300000
   IF VCB'WRITE AND (VCB'SEQTYP=1) THEN    << NEXT >>                   05305000
      IF VCB'VOLID=LCB'VOLID,(6) THEN GO OK ELSE GO NG;                 05310000
   IF VCB'VSETID=LCB'VSETID,(6) THEN GO MAYBE;                          05315000
   IF VCB'VOLID <> LCB'VOLID,(6) THEN GO NG;                            05320000
MAYBE:                                                                  05325000
   IF (VCB'SEQTYP=0) AND VCB'FNAME =LCB'FNAME,(IF LCB'HP THEN 17 ELSE 8)05330000
      AND (LCB'REEL <> 1) THEN GO NG;   << Name - need reel 1 >>        05335000
   IF (VCB'SEQTYP=3) THEN IF (LCB'FSEQ > VCB'FSEQ) OR                   05340000
      (LCB'FSEQ = VCB'FSEQ) AND (LCB'REEL <> 1) THEN                    05345000
      GO NG;       << By file number - need prior reel >>               05350000
OK:                                                                     05355000
   GOODREEL := TRUE;     << We'll buy it. >>                            05360000
NG:                                                                     05365000
   END;       << procedure GOODREEL >>                                  05370000
$PAGE " WRITE HEADER AND TRAILER LABELS "                               05375000
LOGICAL PROCEDURE WRITLAB0(VTBUF);                             <<02662>>05380000
   ARRAY VTBUF;                                                         05385000
   OPTION INTERNAL;                                            <<02621>>05390000
                                                                        05395000
<< Write Volume label [VOL1] per info in VCB. >>                        05400000
                                                                        05405000
   BEGIN                                                                05410000
   BYTE ARRAY VTBUFB(*) = VTBUF;                                        05415000
   ARRAY LABEL0(0:LBLSIZE-1) =Q;                                        05420000
      DOUBLE LTYPE = LABEL0;                                            05425000
      BYTE ARRAY BLABEL0(*) = LABEL0;                                   05430000
                                                                        05435000
   IF SET'DENSITY(VCB'LDEV,VCB'DENSITY) THEN WRITLAB0 := TRUE; <<02662>>05440000
                                                               <<02563>>05445000
   LABEL0 := "  ";                                                      05450000
   MOVE LABEL0(1) := LABEL0,(LBLSIZE-1);                                05455000
   LTYPE := "VOL1";                                                     05460000
   MOVE L0VOLID := VCB'VOLID,(6);                                       05465000
   IF VCB'LABTYP = 2 THEN L0SMARK := ANSI'VERSION ELSE         <<04740>>05470000
      BEGIN          << IBM >>                                          05475000
      L0ACCESS := "0";                                                  05480000
      CTRANSLATE(2,BLABEL0,,80);                                        05485000
      END;                                                              05490000
   TOS := ATTACHIO(VCB'LDEV,0,0,@LABEL0,WRITE,LBLSIZE,0,4,1);  <<02662>>05495000
   DEL;                                                        <<02662>>05500000
   IF TOS.(13:3) <> 1 THEN WRITLAB0 := TRUE;   << error >>     <<02662>>05505000
   END;      << procedure WRITLAB0 >>                                   05510000
$PAGE                                                                   05515000
LOGICAL PROCEDURE WRITELAB(VTBUF,LTYPE);                       <<02662>>05520000
VALUE LTYPE;                                                            05525000
ARRAY VTBUF;                                                            05530000
LOGICAL LTYPE;                                                          05535000
   OPTION INTERNAL;                                            <<02621>>05540000
                                                                        05545000
<< Called from REELSWITCH and CHECKUL to write HDR, EOF,                05550000
and EOV labels.  LTYPE specifies:                                       05555000
   0 - HDR                                                              05560000
   1 - EOF                                                              05565000
   2 - EOV                                                              05570000
DB must be at the stack. Returns True if error occured. >>     <<02662>>05575000
                                                                        05580000
   BEGIN                                                                05585000
   INTEGER LDEV;                                                        05590000
   LOGICAL DATE;                                                        05595000
   INTEGER RECSIZE;                                                     05600000
   INTEGER BLKSIZE;                                                     05605000
   DOUBLE NBLKS;                                                        05610000
   LOGICAL FOPS;                                                        05615000
   LOGICAL ARRAY TLABEL(0:LBLSIZE-1) =Q;                                05620000
      BYTE ARRAY BTLABEL(*)=TLABEL;                                     05625000
      DOUBLE L1TYPE = TLABEL;                                           05630000
      BUILDVCB;                                                         05635000
   DOUBLE ARRAY LTYPECODE(0:2) =PB := "HDR1","EOF1","EOV1";             05640000
   ARRAY FTYPECODE(0:3) =PB := "FFVVUUVV";                              05645000
   EQUATE FLAGS=1;                                                      05650000
                                                                        05655000
                                                               <<02689>>05660000
SUBROUTINE ATTIOS(FUNC);                                       <<02689>>05665000
VALUE FUNC; INTEGER FUNC;                                      <<02689>>05670000
                                                               <<02689>>05675000
   BEGIN                                                       <<02689>>05680000
   IF LDEV=0 THEN TAPETROUBLE(TT5);  << oops! >>               <<03581>>05685000
   TOS := ATTACHIO(LDEV,0,0,@TLABEL,FUNC,LBLSIZE,0,4,FLAGS);   <<02689>>05690000
   DEL;                                                        <<02689>>05695000
   IF S0.(13:3) <> 1 THEN WRITELAB := TRUE; << Report error! >><<02689>>05700000
   X := TOS;                                                   <<02689>>05705000
   END;                                                        <<02689>>05710000
                                                               <<02689>>05715000
                                                               <<02689>>05720000
 << Write HDR1 - EOF1 - EOV1  >>                                        05725000
                                                                        05730000
   TLABEL := "  ";                                                      05735000
   MOVE TLABEL(1) := TLABEL,(39);                                       05740000
   FGETINFO(VCB'FNUM,,FOPS,,RECSIZE,,LDEV,,,,,,,NBLKS,BLKSIZE);         05745000
   IF LTYPE <> 0 THEN ATTIOS(6);  << TM ends data >>           <<02689>>05750000
   L1TYPE := LTYPECODE(LTYPE);                                          05755000
   MOVE L1FNAME := VCB'FNAME,(17);                                      05760000
   BIN2ASC(DOUBLE(VCB'REEL),L1REEL,4);      << put in reel # >>         05765000
   BIN2ASC(DOUBLE(VCB'FSEQ),L1FSEQ,4);       << put in file seq # >>    05770000
   BIN2ASC(DOUBLE(VCB'EXDATE.(0:7)),L1XYR,2);   << put in exp date >>   05775000
   BIN2ASC(DOUBLE(VCB'EXDATE.(7:9)),L1XDAY,3);                          05780000
   DATE := CALENDAR;                                                    05785000
   BIN2ASC(DOUBLE(DATE.(0:7)),L1CYR,2);                                 05790000
   BIN2ASC(DOUBLE(DATE.(7:9)),L1CDAY,3);                                05795000
   MOVE L1VSETID := VCB'VSETID,(6);                                     05800000
   BIN2ASC(IF LTYPE=0 THEN 0D         << HDR1 >>                        05805000
      ELSE IF LTYPE=1 THEN NBLKS      << EOF1 >>                        05810000
      ELSE NBLKS+1D,L1NBLKS,6);       << EOV1 >>                        05815000
   MOVE L1SYSTEM := HPSYSTEM;                                           05820000
   IF VCB'LABTYP = 2 THEN                                               05825000
      BEGIN       << ANSI label >>                                      05830000
      IF VCB'LOCKWRD <> " " THEN L1ACC := %230;                         05835000
      END                                                               05840000
   ELSE                                                                 05845000
      BEGIN      << IBM >>                                              05850000
      L1ACC := "0";                                                     05855000
      CTRANSLATE(2,BTLABEL,,80);                                        05860000
      END;                                                              05865000
   ATTIOS(WRITE);                                              <<02689>>05870000
                                                                        05875000
 << Write HDR2 - EOF2 - EOV2  >>                                        05880000
                                                                        05885000
   TLABEL := "  ";                                                      05890000
   MOVE TLABEL(1) := TLABEL,(39);                                       05895000
   L1TYPE := LTYPECODE(LTYPE)+1D;                                       05900000
   L2RFMT := BYTE(FTYPECODE(FOPFTYPE));                                 05905000
   IF BLKSIZE < 1 THEN BLKSIZE := -BLKSIZE                              05910000
      ELSE BLKSIZE := BLKSIZE*2;       << make +bytes >>                05915000
   IF RECSIZE < 1 THEN RECSIZE := -RECSIZE                              05920000
      ELSE RECSIZE := RECSIZE*2;                                        05925000
   IF LOGICAL(RECSIZE) THEN                                             05930000
      BEGIN    << Round up rec size if block fact > 1. >>               05935000
      IF BLKSIZE <> RECSIZE THEN                                        05940000
         RECSIZE := RECSIZE+1;                                          05945000
      END;                                                              05950000
   BIN2ASC(DOUBLE(BLKSIZE),L2BSIZE,5);                                  05955000
   BIN2ASC(DOUBLE(RECSIZE),L2RSIZE,5);                                  05960000
   IF VCB'LABTYP = 2 THEN                                               05965000
      BEGIN       << ANSI label, with HP features. >>                   05970000
      MOVE L2LOCK := VCB'LOCKWRD,(8);                                   05975000
      L2FTYPE := BYTE("B"-VCB'ASCII);                                   05980000
      IF FOPCCTL THEN L2CCTL := "C";                                    05985000
      MOVE L2BUFOFF := "00";                                            05990000
      END                                                               05995000
   ELSE                                                                 06000000
      BEGIN        << IBM label. >>                                     06005000
      L2DSPOSN := IF LTYPE = 0 THEN "0" ELSE IF LTYPE = 2 THEN "1"      06010000
         ELSE "1";     << needs more >>                                 06015000
      L2BLKATT := IF BLKSIZE = RECSIZE THEN " " ELSE "B";               06020000
      CTRANSLATE(2,BTLABEL,,80);                                        06025000
      END;                                                              06030000
   ATTIOS(WRITE);                                              <<02689>>06035000
   END;      << procedure WRITELAB >>                                   06040000
$PAGE " CHECK1 "                                                        06045000
LOGICAL PROCEDURE CHECK1(LTBUF);                                        06050000
LOGICAL ARRAY LTBUF;                                                    06055000
   OPTION INTERNAL;                                            <<02621>>06060000
   BEGIN                                                                06065000
                                                                        06070000
<< Called from REELSWITCH, CHECKUL, and POSITION to                     06075000
read and validate HDR1, EOF1, and EOV1.  Returns:                       06080000
         =-1 - EOF                                                      06085000
         =0  - HDR1 label                                               06090000
         =1  - EOF1 label                                               06095000
         =2  - EOV1 label                                               06100000
         =3  - VOL1 label  [FCONTROL REWIND]                            06105000
         =4  - violation or none of the above                           06110000
         =5  - UVL label                                         MP.68  06115000
DB must be at the stack.                    >>                          06120000
                                                                        06125000
   LOGICAL RESULT=CHECK1;                                               06130000
   LOGICAL LDEV;                                                        06135000
      BUILDLCB;                                                         06140000
   LOGICAL ARRAY LABEL1(0:LBLSIZE-1) =Q;                                06145000
      DOUBLE L1TYPE = LABEL1;                                           06150000
      BYTE ARRAY BTLABEL(*)=LABEL1;                                     06155000
   EQUATE FLAGS=1;                                                      06160000
                                                                        06165000
 << Begin execution >>                                                  06170000
                                                                        06175000
   CC := CCE;                                                           06180000
   LDEV := LCB'LDEV;                                                    06185000
   TOS := ATTACHIO(LDEV,0,0,@LABEL1,READ,LBLSIZE,0,0,FLAGS);            06190000
   DEL;                                                                 06195000
   IF S0STAT=EOFSTAT THEN                                               06200000
      BEGIN     << Tapemark: end of vol set >>                          06205000
      DEL;                                                              06210000
      CC := CCG;     << report EOF. >>                                  06215000
      RESULT := -1;                                                     06220000
      GO OUTD;                                                          06225000
      END;                                                              06230000
   IF TOS.(13:3) <> 1 THEN                                              06235000
      BEGIN                                                             06240000
      CC := CCL;     << report Error. >>                                06245000
      RESULT := 2;                                                      06250000
      GO OUTD;                                                          06255000
      END;                                                              06260000
   IF LCB'LABTYP = 3 THEN   << IBM >>                                   06265000
      CTRANSLATE(1,BTLABEL,,80);    << to ASCII >>                      06270000
   IF L1TYPE="HDR1" THEN TOS := 0                                       06275000
   ELSE IF L1TYPE="EOF1" THEN TOS := 1                                  06280000
   ELSE IF L1TYPE="EOV1" THEN TOS := 2                                  06285000
   ELSE IF L1TYPE="VOL1" THEN TOS := 3                                  06290000
   ELSE IF BTLABEL="UVL" THEN TOS := 5                         <<02621>>06295000
   ELSE TOS := 4;                                                       06300000
   RESULT := S0;                                                        06305000
   IF TOS < 3 THEN                                                      06310000
      BEGIN       << HDR1/EOF1/EOV1 >>                                  06315000
      MOVE LCB'FNAME := L1FNAME,(17);                                   06320000
      MOVE LCB'VSETID := L1VSETID,(6);                                  06325000
      LCB'HP := IF L1SYSTEM = HPSYSTEM AND (LCB'LABTYP = 2)    <<02690>>06330000
         THEN 1 ELSE 0;                                        <<02690>>06335000
      LCB'LOCKFLG := IF LCB'HP AND (L1ACC=%230) THEN 1 ELSE 0;          06340000
      LCB'CDATE := BINARY'(L1CDAY,3);                                   06345000
      LCB'CDATE.(0:7) := BINARY'(L1CYR,2);                              06350000
      LCB'EXDATE := BINARY'(L1XDAY,3);                                  06355000
      LCB'EXDATE.(0:7) := BINARY'(L1XYR,2);                             06360000
      LCB'FSEQ := BINARY'(L1FSEQ,4);                                    06365000
      LCB'REEL := BINARY'(L1REEL,4);                                    06370000
      END;                                                              06375000
OUTD:                                                                   06380000
   END;      << procedure CHECK1 >>                                     06385000
$PAGE " CREATETLTENT "                                                  06390000
INTEGER PROCEDURE CREATETLTENT(FMSG,ID,FNUM,ACCESS,DENSITY);   <<02563>>06395000
   VALUE FNUM,ACCESS,DENSITY;                                  <<02563>>06400000
   BYTE ARRAY FMSG;                                                     06405000
   ARRAY ID;                                                            06410000
   INTEGER FNUM,ACCESS,DENSITY;                                <<02563>>06415000
   OPTION UNCALLABLE;                                                   06420000
                                                                        06425000
<<  Called from FOPEN to get tape label parameters from the             06430000
Forms message or from the file equation, and make a Volume              06435000
entry in the tape label table.  If no volume ID is specified,           06440000
operator will be asked for a volume ID.  If the first open for          06445000
this volume set, a new file entry will be made in the tape label        06450000
table; otherwise the entry is updated.  Parameters:                     06455000
   FMSG  - Forms msg, e.g. ".VSET01,ANS,12/3/80,NEXT;"                  06460000
   ID  - file name and lockword, as supplied to FOPEN.                  06465000
   FNUM - File number (AFT index)                                       06470000
   ACCESS - Access type (AOPTIONS.(12:4))                               06475000
   DENSITY - Density requested by user (internal form)           MP.60  06480000
                                                                        06485000
Returns 0 if OK, otherwise error number.  DB at stack. >>               06490000
                                                                        06495000
                                                                        06500000
BEGIN                                                                   06505000
   LOGICAL VTADDR;                                                      06510000
   INTEGER SCODE,IX,IXD;                                                06515000
   INTEGER LGTH;                                                        06520000
   LOGICAL PINNO,LABELTYPE;                                             06525000
   LOGICAL VSETOP;                                                      06530000
   LOGICAL EXDATE,SEQTYPE,FSEQ;                                         06535000
   INTEGER RESULT = CREATETLTENT;                                       06540000
   DOUBLE VTBOUNDS;                                                     06545000
      LOGICAL VTBASE = VTBOUNDS;                                        06550000
      LOGICAL VTTOP = VTBOUNDS+1;                                       06555000
   INTEGER ARRAY BUFFER(0:12);                                          06560000
      BYTE ARRAY BBUF(*) = BUFFER;                                      06565000
   INTEGER ARRAY REPLY(0:2) =Q;                                         06570000
      BYTE ARRAY REPLYB(*) =REPLY;                                      06575000
   INTEGER ARRAY VOLSETID(0:5);                                         06580000
      BYTE ARRAY BVSETID(*) = VOLSETID;                                 06585000
   BYTE ARRAY BFNAME(0:17);                                             06590000
   LOGICAL ARRAY VTBUF(0:VTESIZE-1) =Q;                                 06595000
      BUILDVCB;                                                         06600000
   BYTE ARRAY BID(*) = ID;                                              06605000
                                                                        06610000
 << Begin execution >>                                                  06615000
                                                                        06620000
   IF ACCESS = 3 THEN                                                   06625000
      BEGIN       << APPEND - illegal. >>                               06630000
      RESULT := LBTAPPEND;                                              06635000
      GO ENDZ;                                                          06640000
      END;                                                              06645000
   IX := 0;       << index into forms message >>                        06650000
   WHILE FMSG(IX) <> "." DO                                             06655000
      BEGIN       << Skip anything preceding the "." >>                 06660000
      IX := IX+1;                                                       06665000
      IF IX > 49 THEN GO ERRF;                                          06670000
      END;                                                              06675000
   PINNO := CURPRC/PCBSIZE;                                    <<06424>>06680000
   LABELTYPE := 2;      << default: ANSI >>                             06685000
   EXDATE := 0;                                                         06690000
   SEQTYPE := 1;        << NEXT >>                                      06695000
   FSEQ := 0;                                                           06700000
                                                                        06705000
<< Get parms from Forms Message here >>                                 06710000
                                                                        06715000
   MOVE BVSETID := "      ";                                            06720000
   IX := IX+1;          << skip over "." >>                             06725000
   IXD := 0;                                                            06730000
   WHILE IXD < 6 DO                                                     06735000
      BEGIN       << get Volume set ID >>                               06740000
      TOS := FMSG(IX);                                                  06745000
      IF NOT(" " <= S0 <= %176) THEN GO ERRF;                  <<02648>>06750000
      IF S0 = ";" OR S0 = "," THEN GO ELABN;  << end >>        <<02648>>06755000
      BVSETID(IXD) := TOS;                                              06760000
      IX := IX+1;                                                       06765000
      IXD := IXD+1;                                                     06770000
      END;                                                              06775000
   TOS := 0;                                                   <<02648>>06780000
ELABN:                                                                  06785000
   DEL;                                                        <<02648>>06790000
   IF IXD = 0 THEN                                                      06795000
      BEGIN    << No vol set ID; request it >>                          06800000
      MOVE BUFFER :=                                                    06805000
         "Volume ID for XXXXXXXX";                                      06810000
      MOVE BBUF(14) := BID,(8);    << copy file name >>                 06815000
      LGTH := PRINTOPREPLY(BUFFER,11,0,REPLY,-6);                       06820000
<< Need to validate input. >>                                           06825000
      MOVE BVSETID := REPLYB,(LGTH);                                    06830000
      END;      << request vol set ID >>                                06835000
   IF FMSG(IX) = ";" THEN GO CHECKVS;    << default all. >>             06840000
   IF FMSG(IX) <> "," THEN GO ERRF;                            <<02648>>06845000
   IX := IX+1;                                                          06850000
   IF FMSG(IX) = "," THEN GO GETDATE;   << labeltype omitted >>         06855000
   IF FMSG(IX) = "ANS" THEN                                             06860000
      IX := IX+3      << step to next , >>                              06865000
   ELSE                                                                 06870000
      BEGIN      << IBM >>                                              06875000
      IF FMSG(IX) <> "IBM" THEN GO ERRF;                                06880000
      IF ACCESS <> READ THEN IF DISABL'IBM THEN                         06885000
         BEGIN RESULT := LBTIBMWRIT; GO ENDZ END;              <<02648>>06890000
      LABELTYPE := 3;    << type to IBM >>                              06895000
      IX := IX+3;      << step to next , >>                             06900000
      END;                                                              06905000
   IF FMSG(IX) = ";" THEN GO CHECKVS;                                   06910000
   IF FMSG(IX) <> "," THEN                                              06915000
      BEGIN    << Error in format >>                                    06920000
ERRF:                                                                   06925000
      RESULT := LBTSYNTAX;                                              06930000
      GO ENDZ;                                                          06935000
      DEBUG;      << dummy call >>                                      06940000
      END;                                                              06945000
                                                                        06950000
GETDATE:                                                                06955000
   IX := IX+1;                                                          06960000
   IF FMSG(IX) <> "," THEN                                              06965000
      BEGIN     << get length of date field >>                          06970000
      IXD := 0;                                                         06975000
      WHILE FMSG(IX+IXD) <> "," AND FMSG(IX+IXD) <> ";" DO              06980000
         BEGIN                                                          06985000
         IF IXD > 12 THEN GO ERRF;                                      06990000
         IXD := IXD+1;                                                  06995000
         END;                                                           07000000
   << IXD = length of date>>                                            07005000
      IF FMSG(IX) = "+" THEN                                            07010000
         BEGIN       << Get increment to today's date. >>               07015000
         EXDATE := CALENDAR;                                            07020000
         TOS := BINARY'(FMSG(IX+1),IXD-1);                              07025000
         IF <> THEN GO ERRF;                                            07030000
         TOS := TOS+EXDATE.(7:9);                                       07035000
         TOS := DOUBLE(TOS-1);                                          07040000
         TOS := 365;                                                    07045000
         ASMB(LDIV);                                                    07050000
         EXDATE.(7:9) := TOS+1;    << remainder = days >>               07055000
         EXDATE.(0:7) := TOS+EXDATE.(0:7);   << quot - yrs >>           07060000
         END                                                            07065000
      ELSE                                                              07070000
         BEGIN        << Expect DD/MM/YY >>                             07075000
         IF IXD < 5 THEN GO ERRF;                                       07080000
         IF FMSG(IX) = "00/00/00" THEN GO BUMP;                         07085000
         EXDATE := CONVERTDATE(FMSG(IX));                               07090000
         IF <> THEN GO ERRF;   << invalid date. >>                      07095000
         END;                                                           07100000
BUMP: IX := IX+IXD;                                                     07105000
      IF FMSG(IX) = ";" THEN GO CHECKVS;                       <<06024>>07110000
      END;    << convert date >>                                        07115000
                                                                        07120000
  << Get here to get seq type or # >>                                   07125000
                                                                        07130000
   IX := IX+1;   << step past , >>                                      07135000
   IXD := 0;     << Measure length of sequence field >>                 07140000
   WHILE IXD < 4 AND FMSG(IX+IXD) <> ";" AND                            07145000
      FMSG(IX+IXD) <> "," DO IXD := IXD+1;                              07150000
   IF IXD=0 OR FMSG(IX)= "NEXT" THEN  << SEQTYPE := 1 >>                07155000
   ELSE IF FMSG(IX) = "ADDF" THEN                                       07160000
      BEGIN                                                             07165000
      IF ACCESS = READ THEN                                             07170000
         BEGIN           << Lose: need Write access. >>                 07175000
         RESULT := INVOP;                                      <<06333>>07180000
         GO ENDZ;                                                       07185000
         END;                                                           07190000
      SEQTYPE := 2;                                                     07195000
      END                                                               07200000
   ELSE                                                                 07205000
      BEGIN      << Match file sequence nr. >>                          07210000
      SEQTYPE := 3;                                                     07215000
      FSEQ := BINARY'(FMSG(IX),IXD);                                    07220000
      IF < THEN GO ERRF;                                                07225000
      IF FSEQ = 0 THEN SEQTYPE := 0;  << match filename. >>             07230000
      END;                                                              07235000
                                                                        07240000
<< Search for volume set entry matching specified volume ID.            07245000
If one is found, this is an open of a file on the volume set. >>        07250000
                                                                        07255000
CHECKVS:                                                                07260000
   VSETOP := FALSE;                                                     07265000
   SCODE := GETSIR(TLTSIR);                                             07270000
   GETXDSW(VTBOUNDS,TLTDST,XVTBASE,2);                                  07275000
   VTADDR := VTBASE;                                                    07280000
   WHILE VTADDR < VTTOP DO                                              07285000
      BEGIN                                                             07290000
      GETXDSW(VTBUF,TLTDST,VTADDR,VTESIZE);                             07295000
      IF INUSE AND (VCB'FNUM=0) AND                                     07300000
         (VCB'PIN=PINNO) AND (VCB'LABTYP=LABELTYPE) AND                 07305000
         BVSETID=VCB'VSETID,(6) THEN GO OLDVSET;                        07310000
      VTADDR := VTADDR+VTESIZE;                                         07315000
      END;                                                              07320000
                                                                        07325000
<< Volume set being opened; need new entry. >>                          07330000
                                                                        07335000
   VTADDR := 0;         << forces new entry >>                          07340000
   VSETOP := TRUE;                                                      07345000
   VTBUF := 0;          << zero binary part >>                          07350000
   MOVE VTBUF(1) := VTBUF,(6);                                          07355000
   VTBUF(7) := "  ";    << blank ASCII part >>                          07360000
   MOVE VTBUF(8) := VTBUF(7),(18);                                      07365000
   VCB'LDEV := 0;                                              <<02648>>07370000
   VCB'VSETOPEN := 1;   << 1st open of volume set >>           <<02563>>07375000
   MOVE VCB'VOLID := BVSETID,(6);                                       07380000
   MOVE VCB'VSETID := BVSETID,(6);    << vset ID in new ent >>          07385000
   VCB'FSEQ := FSEQ;                                                    07390000
   VCB'LABTYP := LABELTYPE;                                             07395000
<< Density is a volset attribute. Set only on 1st open. >>     <<02563>>07400000
   VCB'DENSITY := DENSITY;                                     <<02563>>07405000
OLDVSET:                                                                07410000
   MOVE BFNAME := BID,(8);       << file name >>                        07415000
   BFNAME(8) := IF VCB'LABTYP=3 THEN " " ELSE ".";             <<02662>>07420000
   MOVE BFNAME(9) := BID(8),(8);   << group name >>                     07425000
   BFNAME(17) := " ";                                                   07430000
   MOVE VCB'FNAME := BFNAME,(18);   << file name >>                     07435000
   MOVE VCB'LOCKWRD := BID(24),(8);   << lockword >>                    07440000
   VCB'PIN := PINNO;                                                    07445000
   VCB'FNUM := FNUM;                                                    07450000
                                                                        07455000
   VCB'EXDATE := EXDATE;                                                07460000
   VCB'SEQTYP := SEQTYPE;                                               07465000
   IF SEQTYPE=3 THEN VCB'FSEQ := FSEQ;                                  07470000
   VCB'REEL := 1;     << All files begin with this >>                   07475000
   IF VCB'FSEQ = 0 THEN VCB'FSEQ := 1;                                  07480000
   VCB'WRITE := IF ACCESS > READ THEN 1 ELSE 0;                         07485000
   VCB'LNKWAIT := 1;     << flag for LINKLABEL >>                       07490000
   POSTVTENT(VTBUF,VTADDR,SCODE);                                       07495000
   IF < THEN RESULT := LBTOFLOW;                                        07500000
   IF VSETOP THEN LOGIT(VTBUF);    << write Log record >>               07505000
ENDZ:                                                                   07510000
   END;     << procedure CREATETLTENT >>                                07515000
$PAGE " STORE'DENSITY "                                        <<02563>>07520000
PROCEDURE STORE'DENSITY(LDEV,DENSITY,MODE);                    <<02563>>07525000
   VALUE LDEV,MODE;                                            <<02563>>07530000
   INTEGER LDEV,MODE;                                          <<02563>>07535000
   ARRAY DENSITY;                                              <<02563>>07540000
   OPTION PRIVILEGED,UNCALLABLE;                               <<02563>>07545000
                                                               <<02563>>07550000
COMMENT                                                        <<02563>>07555000
                                                               <<02563>>07560000
   This procedure posts density information into the density   <<02563>>07565000
data structure.  The procedure can be called in three modes:   <<02563>>07570000
                                                               <<02563>>07575000
   MODE = 0, FOPEN-type call.  DENSITY is defined as           <<d8615>>07580000
   $EDIT VOID=2974000                                          <<d8615>>07585000
      an array.  It contains the user requested density        <<d8615>>07590000
      for the tape LDEV.  If this is the first call of this    <<02563>>07595000
      type -- that is REQUEST'DENSITY contains a null value -- <<02563>>07600000
      and the "default" density was requested, then the        <<02563>>07605000
      tape request is set to 6250 BPI for 7976 or 7978 and     <<07339>>07610000
      1600 for 7974.  In all other cases, default density      <<07339>>07615000
      requests are ignored.                                    <<07339>>07620000
      Called by:  FOPEN.                                       <<02563>>07625000
   MODE = 1, AVR-type call.  Generally, the caller has just    <<02563>>07630000
      finished AVR on the device LDEV.  DENSITY contains the   <<02563>>07635000
      results of a "read status" request to the mag tape dri-  <<02563>>07640000
      ver.  This procedure then interprets the status bytes and<<02563>>07645000
      stores the actual tape density into the data structure.  <<02563>>07650000
      Called by:  DEVREC and RECOGNIZE (in LABSEG).            <<02563>>07655000
   MODE = 2, DEALLOCATE-type call.  The density data structure <<02563>>07660000
      is to be reinitialized.  This call is made during the    <<02563>>07665000
      final release of a tape drive by its current owner.      <<02563>>07670000
      DENSITY for this call is a dummy.                        <<02563>>07675000
      Called by:  DEALLOCATE, REELSWITH, and CHECKUL.          <<02689>>07680000
                                                               <<02563>>07685000
   CALLER'S RESPONSIBILITIES:                                  <<02563>>07690000
   1)  DB must be at the stack.                                <<02563>>07695000
   2)  The caller should ensure that LDEV is a mag tape drive. <<02563>>07700000
                                                               <<02563>>07705000
;    << end of comment >>                                      <<02563>>07710000
                                                               <<02563>>07715000
BEGIN                                                          <<02563>>07720000
LOGICAL ARRAY LDT(0:SIZE'OF'LDT'ENTRY-1);                      <<06333>>07725000
INTEGER                                                        <<02563>>07730000
   LDT'INDEX,                                                  <<06333>>07735000
   LPDT'INDEX,                                                 <<06333>>07740000
   SAVESIR;                                                    <<02563>>07745000
DEFINE                                                         <<02563>>07750000
   STAT'6250 = DENSITY.(8:1)#,  << Status bit for 7974/76/78 >><<d8615>>07755000
   STAT'1600 = DENSITY(1).(0:1)#, << For 7974/7978          >> <<d8615>>07760000
   STAT'800  = DENSITY(1).(1:1)#; << For 7974/7978          >> <<d8615>>07765000
                                                               <<02563>>07770000
   << Only continue if tape drive is variable density. >>      <<02563>>07775000
   LPDT'INDEX := LDEV * SIZE'OF'LPDT'ENTRY;                    <<06333>>07780000
   IF (NOT'VARIABLE'DENSITY) THEN RETURN;                      <<07339>>07785000
                                                               <<02563>>07790000
   SAVESIR := GETSIR(LDT'SIR);                                 <<06333>>07795000
                                                               <<02563>>07800000
   LDT'INDEX := 0;                                             <<06333>>07805000
   GETXDSW(LDT, LDT'DST, LDEV * SIZE'OF'LDT'ENTRY,             <<06333>>07810000
           SIZE'OF'LDT'ENTRY);                                 <<06333>>07815000
                                                               <<02563>>07820000
   CASE MODE OF                                                <<02563>>07825000
      BEGIN                                                    <<02563>>07830000
                                                               <<02563>>07835000
      BEGIN  << 0 - FOPEN mode - Density is user requested  >> <<07339>>07840000
      IF DENSITY <> LDT'NO'DENSITY THEN                        <<06333>>07845000
         LDT'RQST'TAPE'DENS := DENSITY  << Specific request >> <<06333>>07850000
      ELSE                                                     <<02563>>07855000
         << If 1st request, take the default (6250 or 1600) >> <<07339>>07860000
         << Else, default is no change.                     >> <<07339>>07865000
         IF LDT'RQST'TAPE'DENS = LDT'NO'DENSITY THEN           <<06333>>07870000
            IF LPDT'AUTO'SUBTYPE = HP7974                      <<07339>>07875000
               THEN LDT'RQST'TAPE'DENS := LDT'DENSITY'1600     <<07339>>07880000
               ELSE LDT'RQST'TAPE'DENS := LDT'DENSITY'6250     <<07339>>07885000
      END;   << 0 - FOPEN mode                              >> <<07339>>07890000
                                                               <<02563>>07895000
      BEGIN  << 1 - AVR mode - DENSITY array has status.    >> <<07339>>07900000
      IF LPDT'AUTO'SUBTYPE = HP7974 THEN                       <<d8615>>07905000
         IF STAT'800 THEN                                      <<d8615>>07910000
            LDT'ACTUAL'TAPE'DENS := LDT'DENSITY'800            <<d8615>>07915000
         ELSE                                                  <<d8615>>07920000
            LDT'ACTUAL'TAPE'DENS := LDT'DENSITY'1600           <<d8615>>07925000
      ELSE       << HP7976 or HP7978 >>                        <<d8615>>07930000
         IF NOT STAT'6250 THEN                                 <<d8615>>07935000
            LDT'ACTUAL'TAPE'DENS := LDT'DENSITY'1600           <<d8615>>07940000
         ELSE                                                  <<d8615>>07945000
            LDT'ACTUAL'TAPE'DENS := LDT'DENSITY'6250           <<d8615>>07950000
      END;   << 1 - AVR mode                                >> <<07339>>07955000
                                                               <<02563>>07960000
      << FREE mode - DENSITY is a dummy.  Clear fields. >>     <<02563>>07965000
      BEGIN                                                    <<02563>>07970000
      LDT'RQST'TAPE'DENS := LDT'NO'DENSITY;                    <<06333>>07975000
      LDT'ACTUAL'TAPE'DENS := LDT'NO'DENSITY;                  <<06333>>07980000
      END;                                                     <<02563>>07985000
                                                               <<02563>>07990000
      END;   << of case >>                                     <<02563>>07995000
                                                               <<02563>>08000000
   << Write word back >>                                       <<02563>>08005000
   PUTXDSW(LDT'DST, LDEV * SIZE'OF'LDT'ENTRY, LDT,             <<06333>>08010000
           SIZE'OF'LDT'ENTRY);                                 <<06333>>08015000
                                                               <<02563>>08020000
   RELSIR(LDT'SIR,SAVESIR);                                    <<06333>>08025000
                                                               <<02563>>08030000
END;     << of STORE'DENSITY >>                                <<02563>>08035000
$PAGE "  CHECK'AVR'STATUS"                                     <<02722>>08040000
INTEGER PROCEDURE CHECK'AVR'STATUS(LDEV,STATUS,IGNORE);        <<02722>>08045000
   VALUE LDEV,STATUS,IGNORE;                                   <<02722>>08050000
   INTEGER LDEV,STATUS;                                        <<02722>>08055000
   LOGICAL IGNORE;                                             <<02722>>08060000
   OPTION PRIVILEGED,UNCALLABLE;                               <<02722>>08065000
                                                               <<02722>>08070000
COMMENT                                                        <<02722>>08075000
                                                               <<02722>>08080000
   This procedure examines the status returned by ATTACHIO     <<02722>>08085000
during Automatic Volume Recognition.  If there was an error,   <<02722>>08090000
an appropriate error message is printed and the procedure      <<02722>>08095000
return tells the caller what kind of error occured.            <<02722>>08100000
                                                               <<02722>>08105000
INPUT:                                                         <<02722>>08110000
   LDEV   -- the logical device in question.                   <<02722>>08115000
   STATUS -- the last 8 bits of ATTACHIO's status return.      <<02722>>08120000
   IGNORE -- During AVR, certain errors which occur as the     <<02722>>08125000
             result of a READ should be ignored.  For example, <<02722>>08130000
             a tape parity error indicates a problem with the  <<02722>>08135000
             tape surface.  Although the tape cannot be read,  <<02722>>08140000
             it should still be made available to the system   <<02722>>08145000
             as an unlabelled tape.  If IGNORE is TRUE, the    <<02722>>08150000
             following errors should be ignored:               <<02722>>08155000
                                                               <<02722>>08160000
             RUNAWAY'    - %103                                <<06333>>08165000
             TRANS'ERROR -  %14                                <<02722>>08170000
             TIMING'ERR  -  %34                                <<02722>>08175000
             UNIT'FAIL   -  %54                                <<02722>>08180000
             PARITY'ERR  -  %74                                <<02722>>08185000
                                                               <<02722>>08190000
             For now, all errors are included because it is not<<02722>>08195000
             clear which errors should be considered fatal.    <<02722>>08200000
                                                               <<02722>>08205000
PROCEDURE RETURN:                                              <<02722>>08210000
                                                               <<02722>>08215000
   0 -- No error.                                              <<02722>>08220000
   1 -- Error indicating power problems.  (No console message) <<02722>>08225000
   2 -- Fatal error.                                           <<02722>>08230000
   3 -- Ignored error.  (Only returned if IGNORE = TRUE.)      <<02722>>08235000
                                                               <<02722>>08240000
DB MUST BE AT STACK.                                           <<02722>>08245000
                                                               <<02722>>08250000
;   << end of comment >>                                       <<02722>>08255000
                                                               <<02722>>08260000
BEGIN                                                          <<02722>>08265000
   INTEGER                                                     <<02722>>08270000
      RESULT = CHECK'AVR'STATUS,   << Procedure return >>      <<02722>>08275000
      LENGTH;                                                  <<02722>>08280000
   BYTE ARRAY                                                  <<02722>>08285000
      STATBUF(0:6);                                            <<02722>>08290000
                                                               <<02722>>08295000
                                                               <<02722>>08300000
   IF STATUS.(13:3) = 1 THEN                                   <<02722>>08305000
      BEGIN                                                    <<02722>>08310000
      RESULT := 0;   << No error >>                            <<02722>>08315000
      RETURN;                                                  <<02722>>08320000
      END;                                                     <<02722>>08325000
                                                               <<02722>>08330000
   IF STATUS = PFAIL'ABORT OR                                  <<02722>>08335000
     STATUS = POWER'UP  THEN                                   <<02722>>08340000
      BEGIN                                                    <<02722>>08345000
      RESULT := 1;   << Power problem >>                       <<02722>>08350000
      RETURN;                                                  <<02722>>08355000
      END;                                                     <<02722>>08360000
                                                               <<02722>>08365000
   IF IGNORE THEN                                              <<02722>>08370000
      BEGIN                                                    <<02722>>08375000
                                                               <<02722>>08380000
<< Eventually, the following IF FALSE THEN clause will >>      <<02722>>08385000
<< determine those status returns which are to be con- >>      <<02722>>08390000
<< sidered fatal even if IGNORE is TRUE. >>                    <<02722>>08395000
                                                               <<02722>>08400000
      IF FALSE THEN                                            <<02722>>08405000
         IGNORE := FALSE                                       <<02722>>08410000
      ELSE                                                     <<02722>>08415000
         BEGIN                                                 <<02722>>08420000
   << Don't report EOF or tape runaway as an error.  They >>   <<03581>>08425000
   << are expected status returns during AVR reads. >>         <<03581>>08430000
         IF STATUS <> EOFSTAT LAND STATUS <> RUNAWAY' THEN     <<06333>>08435000
            BEGIN                                              <<02722>>08440000
            LENGTH := ASCII(STATUS,8,STATBUF);                 <<02722>>08445000
            STATBUF(6) := 0;   << GENMSG terminator >>         <<02722>>08450000
            GENMSG(1,IGNORE'ERR,%10000,LDEV,                   <<02722>>08455000
                                @STATBUF(6-LENGTH),,,,0);      <<02722>>08460000
            END;                                               <<02722>>08465000
         END;                                                  <<02722>>08470000
                                                               <<02722>>08475000
      END;   << of IGNORE >>                                   <<02722>>08480000
                                                               <<02722>>08485000
   IF IGNORE THEN                                              <<02722>>08490000
      RESULT := 3                                              <<02722>>08495000
   ELSE                                                        <<02722>>08500000
      BEGIN   << Report fatal I/O error >>                     <<02722>>08505000
      RESULT := 2;                                             <<02722>>08510000
      REPORT'IOERROR(LDEV,STATUS);                             <<02722>>08515000
      END;                                                     <<02722>>08520000
                                                               <<02722>>08525000
END;   << of CHECK'AVR'STATUS >>                               <<02722>>08530000
$PAGE " AVREC "                                                         08535000
LOGICAL PROCEDURE AVREC(LDEV,BUFF,COUNT,CMD);                           08540000
  VALUE LDEV,COUNT,CMD;                                                 08545000
  INTEGER LDEV,COUNT,CMD;                                               08550000
  ARRAY BUFF;                                                           08555000
  OPTION UNCALLABLE;                                                    08560000
                                                                        08565000
<<  DEVREC reads the first record on a newly mounted tape,              08570000
then calls AVREC.  We see if the record is a tape label;                08575000
if so, and if there is a process waiting for this tape, the             08580000
process is re-started by pulling its entry out of the RIT.              08585000
AVREC can be called twice: once to scan the volume label,               08590000
and then to scan the header label.  DB must be at the stack.            08595000
   COUNT - +words.                                                      08600000
   CMD   - 1 if first call, 2 if second.                                08605000
Returns TRUE if done; FALSE if second call is needed.  The              08610000
two-call kluge is needed because DEVREC does unblocked I/O              08615000
and can't be impeded while we do I/O.  Tape is rewound at final         08620000
exit.   >>                                                              08625000
                                                                        08630000
BEGIN                                                                   08635000
   LOGICAL VTADDR,LTADDR;                                               08640000
   LOGICAL RESULT = AVREC;                                              08645000
   DOUBLE VTBOUNDS;                                                     08650000
      LOGICAL VTBASE = VTBOUNDS;                                        08655000
      LOGICAL VTTOP = VTBOUNDS+1;                                       08660000
   LOGICAL ARRAY TLABEL(0:LBLSIZE-1) =Q;                                08665000
      BYTE ARRAY BLABEL0(*) = TLABEL;                                   08670000
      BYTE ARRAY BTLABEL(*) = TLABEL;                                   08675000
      DOUBLE LTYPE = TLABEL;                                            08680000
   ARRAY MSG(0:20);                                                     08685000
      BYTE ARRAY MSGB(*)=MSG;                                  <<1136>> 08690000
   LOGICAL ARRAY VTBUF(0:VTESIZE-1) =Q;                                 08695000
      BUILDVCB;                                                         08700000
   LOGICAL ARRAY LTBUF(0:LTESIZE-1) =Q;                                 08705000
      BUILDLCB;                                                         08710000
   LOGICAL SCODE;                                                       08715000
   LOGICAL EXDAY;                                                       08720000
                                                                        08725000
   TLABEL := "  ";                                                      08730000
   MOVE TLABEL(1) := TLABEL,(LBLSIZE-1);                                08735000
   MOVE TLABEL := BUFF,(COUNT);  << local copy, for no good reason >>   08740000
   SCODE := GETSIR(TLTSIR);                                             08745000
   LTADDR := GETLDEV(LDEV,LTBUF);                                       08750000
   IF < THEN TAPETROUBLE(TT7);                                 <<03581>>08755000
   VCB'FLAGS := 0;     << default >>                                    08760000
   VTADDR := LCB'VCB;                                                   08765000
   IF <> THEN                                                           08770000
      BEGIN      << A volume is associated with this drive. >>          08775000
      GETXDSW(VTBUF,TLTDST,VTADDR,VTESIZE);                             08780000
      END;                                                              08785000
   IF CMD >= 2 THEN GO TRYH1;                                           08790000
   LCB'FLAGS := LCB'FLAGS LAND %1000; << Leave Tape Bit >>     <<03581>>08795000
   LTBUF(2) := 0;      << first call: clear LDEV entry >>               08800000
   MOVE LTBUF(3) := LTBUF(2),(4);                                       08805000
   LTBUF(7) := "  ";                                                    08810000
   MOVE LTBUF(8) := LTBUF(7),(18);                                      08815000
   LCB'VCB := VTADDR;      << restore this word >>                      08820000
                                                                        08825000
<< Process VOL1 label, if present. >>                                   08830000
                                                                        08835000
   IF TLABEL(0)=%162726 AND TLABEL(1)=%151761 AND COUNT=40 THEN         08840000
      BEGIN       << EBCDIC "VOL1" >>                                   08845000
      LCB'LABTYP := 3;      << set to IBM >>                            08850000
      CTRANSLATE(1,TLABEL,,80);                                         08855000
      END                                                               08860000
   ELSE IF LTYPE="VOL1" THEN LCB'LABTYP := 2                            08865000
      ELSE GO NL;                                                       08870000
   MOVE LCB'VOLID := L0VOLID,(6);                                       08875000
   MOVE LCB'VSETID := L0VOLID,(6);  << default >>                       08880000
   GO POSTLCB;                                                          08885000
                                                                        08890000
<< Process HDR1 label. >>                                               08895000
                                                                        08900000
TRYH1:                                                                  08905000
   IF LCB'LABTYP=3 THEN CTRANSLATE(1,TLABEL,,80);                       08910000
   IF BLABEL0 = "UVL" THEN GO POSTLCB;  << ignore these >>              08915000
   RESULT := TRUE;      << don't read again. >>                         08920000
   IF LTYPE = "HDR1" THEN                                               08925000
      BEGIN                                                             08930000
      EXDAY := BINARY'(L1XDAY,3);         << Julian day >>              08935000
      EXDAY.(0:7) := BINARY'(L1XYR,2);    << year >>                    08940000
      LCB'EXDATE := EXDAY;                                              08945000
      LCB'REEL := BINARY'(L1REEL,4);                                    08950000
      LCB'FSEQ := BINARY'(L1FSEQ,4);                                    08955000
      MOVE LCB'VSETID := L1VSETID,(6);                                  08960000
      MOVE LCB'FNAME := L1FNAME,(17);                                   08965000
      LCB'HP := IF L1SYSTEM = HPSYSTEM AND (LCB'LABTYP = 2)    <<02662>>08970000
         THEN 1 ELSE 0;                                        <<02662>>08975000
      IF BTLABEL(68) = "B" THEN LCB'B5000 := 1;                         08980000
      END;                                                              08985000
   ATTACHIO(LDEV,0,0,0,5,0,0,0,%13);    << rewind >>                    08990000
   IF LCB'TAPE THEN SET'BOT'ON; <<Tape at Load point>>         <<03581>>08995000
                                                                        09000000
<< See if anyone wants this particular volume.  If REELSWITCH,          09005000
we can restart the user waiting on this LDEV.  If LINKLABEL,            09010000
we search the volume entries for one matching the volume. >>            09015000
                                                                        09020000
   IF VCB'RSWAIT THEN GO RESTART;                                       09025000
   GETXDSW(VTBOUNDS,TLTDST,XVTBASE,2);                                  09030000
   VTADDR := VTBASE;                                                    09035000
   WHILE VTADDR < VTTOP DO                                              09040000
      BEGIN         << LINKLABEL waiting? >>                            09045000
      GETXDSW(VTBUF,TLTDST,VTADDR,VTESIZE);                             09050000
      IF INUSE AND (VCB'LDEV=0) AND VCB'MNTWAIT AND                     09055000
          GOODREEL(VTBUF,LTBUF) THEN                           <<02648>>09060000
         BEGIN               << Match. >>                               09065000
         LCB'VCB := VTADDR;    << Link up >>                            09070000
         VCB'LDEV := LDEV;                                              09075000
RESTART: POSTVTENT(VTBUF,VTADDR,-1);                                    09080000
         REMRITENTRY(VCB'PIN);                                          09085000
         GO REPORT;                                                     09090000
         END;                                                           09095000
      VTADDR := VTADDR+VTESIZE;                                         09100000
      END;                                                              09105000
                                                                        09110000
<< No one is waiting for this volume, so just post the LDEV             09115000
entry.  >>                                                              09120000
<< 285 Vol ! mounted on LDEV# \  >>                                     09125000
                                                                        09130000
REPORT:                                                                 09135000
   MOVE MSGB := LCB'VOLID,(6);                                          09140000
   MOVE MSGB(6) := " (ANS) of ";                                        09145000
   IF LCB'LABTYP = 3 THEN MOVE MSGB(6) := " (IBM)";                     09150000
   IF LCB'VOLID <> LCB'VSETID,(6) THEN                                  09155000
      BEGIN       << Not first vol of vset >>                           09160000
      MOVE MSGB(16) := LCB'VSETID,(6);                                  09165000
      MSGB(22) := 0;                                                    09170000
      END                                                               09175000
   ELSE MSGB(12) := 0;   << Zero terminator for GENMSG >>               09180000
   GENMSG(1,285,%01000,@MSGB,LDEV,,,,0);                                09185000
                                                                        09190000
POSTLCB:                                                                09195000
   POSTVTENT(LTBUF,LTADDR,SCODE);                                       09200000
   RETURN;                                                              09205000
                                                                        09210000
<< Unlabelled tape: report, rewind, and exit. >>                        09215000
<< 286 Vol (unlabelled) mounted on LDEV# \ >>                           09220000
                                                                        09225000
NL:                                                                     09230000
   LCB'LABTYP := 1;      << unlabelled >>                               09235000
   RESULT := TRUE;                                                      09240000
   POSTVTENT(LTBUF,LTADDR,SCODE);                                       09245000
   ATTACHIO(LDEV,0,0,0,5,0,0,0,%13);    << Rewind >>                    09250000
   IF LCB'TAPE THEN SET'BOT'ON; <<Tape at load point>>         <<03581>>09255000
   IF VCB'RSWAIT THEN REMRITENTRY(VCB'PIN);                             09260000
   GENMSG(1,286,%10000,LDEV,,,,,0);                                     09265000
   END;      << procedure AVREC >>                                      09270000
$PAGE " RECOGNIZE "                                                     09275000
PROCEDURE RECOGNIZE(LDEV);                                              09280000
VALUE LDEV; INTEGER LDEV;                                               09285000
   OPTION UNCALLABLE;                                          <<03581>>09290000
                                                                        09295000
<< If a tape drive is on-line when the system comes up, there           09300000
will be no interrupt to cause AVR, so we call AVREC "by hand"           09305000
to see what's up. >>                                                    09310000
                                                                        09315000
   BEGIN                                                                09320000
   INTEGER CMD,COUNT;                                                   09325000
   INTEGER IOSTATW;                                                     09330000
   INTEGER LPDT'INDEX;                                         <<06333>>09335000
   ARRAY TLABEL(0:39);                                                  09340000
   INTEGER ORIGINAL'STATE;                                     <<*7477>>09345000
                                                                        09350000
<< It is possible for DEVREC and RECOGNIZE to both be       >> <<02722>>09355000
<< attempting AVR on the same tape drive.  The state bits   >> <<02722>>09360000
<< in the LPDT tell whether DEVREC is working on the drive. >> <<02722>>09365000
<< If the device is unowned, setting the state bits to 3    >> <<02722>>09370000
<< will prevent DEVREC from working on the same drive.      >> <<02722>>09375000
<< We will remember the original state of the device and    >> <<*7477>>09380000
<< reset the device to this state on exit.                  >> <<*7477>>09385000
                                                               <<02722>>09390000
   DISABLE;                                                    <<02722>>09395000
   ORIGINAL'STATE := SETOWNED(LDEV,-1);  <<SAVE DEVICE STATE>> <<*7477>>09400000
   IF (ORIGINAL'STATE=2) OR (ORIGINAL'STATE=3) THEN            <<*7477>>09405000
      BEGIN   << Some process (DEVREC?) owns drive. >>         <<02722>>09410000
      ENABLE;                                                  <<02722>>09415000
      CC := CCL;   << Indicate a problem >>                    <<02722>>09420000
      RETURN;                                                  <<02722>>09425000
      END;                                                     <<02722>>09430000
                                                               <<02722>>09435000
   SETOWNED(LDEV,1);                                           <<*7477>>09440000
   ENABLE;                                                     <<02722>>09445000
                                                               <<02722>>09450000
START:                                                                  09455000
   ATTIO(LDEV,5);       << Insure Rewound for AVR >>                    09460000
   IOSTATW := X.(8:8);   << Pick up ATTACHIO status >>         <<02722>>09465000
                                                               <<02722>>09470000
   CASE CHECK'AVR'STATUS(LDEV,IOSTATW,FALSE) OF                <<02722>>09475000
      BEGIN                                                    <<02722>>09480000
                                                               <<02722>>09485000
      ;              << 0 - OK.  Continue >>                   <<02722>>09490000
                                                               <<02722>>09495000
      GO START;      << 1 - Restart on power problems >>       <<02722>>09500000
                                                               <<02722>>09505000
      GO IO'ERROR;   << 2 - I/O error.  Quit >>                <<02722>>09510000
                                                               <<02722>>09515000
      ;              << 3 - Can't happen, IGNORE = FALSE >>    <<02722>>09520000
                                                               <<02722>>09525000
      END;   << of case statement >>                           <<02722>>09530000
                                                               <<02722>>09535000
   CMD := 0;                                                            09540000
LOOP:                                                                   09545000
   CMD := CMD+1;                                                        09550000
   TOS := ATTACHIO(LDEV,0,0,@TLABEL,READ,40,0,0,1);   <<Read>>          09555000
   COUNT := TOS;                                                        09560000
   IOSTATW := TOS.(8:8);                                                09565000
                                                               <<02563>>09570000
   CASE CHECK'AVR'STATUS(LDEV,IOSTATW,TRUE) OF                 <<02722>>09575000
      BEGIN                                                    <<02722>>09580000
                                                               <<02722>>09585000
      ;              << 0 - OK.  Continue >>                   <<02722>>09590000
                                                               <<02722>>09595000
      GO START;      << 1 - Restart on power problems >>       <<02722>>09600000
                                                               <<02722>>09605000
      GO IO'ERROR;   << 2 - I/O error.  Quit >>                <<02722>>09610000
                                                               <<02722>>09615000
      COUNT := 0;    << 3 - Ignored error >>                   <<02722>>09620000
                                                               <<02722>>09625000
      END;   << of case statement >>                           <<02722>>09630000
                                                               <<02722>>09635000
   IF NOT AVREC(LDEV,TLABEL,COUNT,CMD)                                  09640000
      THEN GO LOOP;                                                     09645000
                                                               <<02563>>09650000
   << AVREC has taken care of marking the BOT bit for all >>   <<02563>>09655000
   << tape drives.  Now, if variable density drive, must  >>   <<02563>>09660000
   << determine density of tape on drive.                 >>   <<02563>>09665000
                                                               <<s8834>>09670000
   LPDT'INDEX := LDEV * SIZE'OF'LPDT'ENTRY;                    <<s8834>>09675000
                                                               <<02563>>09680000
   IF (VARIABLE'DENSITY) THEN                                  <<02563>>09685000
      BEGIN    << Get status of tape drive >>                  <<02563>>09690000
                                                               <<02563>>09695000
      TOS := ATTACHIO(LDEV,0,0,@TLABEL,READ'STATUS,-5,0,0,1);  <<02563>>09700000
      DEL;                                                     <<02563>>09705000
      IOSTATW := TOS.(8:8);                                    <<02563>>09710000
                                                               <<02563>>09715000
      CASE CHECK'AVR'STATUS(LDEV,IOSTATW,FALSE) OF             <<02722>>09720000
         BEGIN                                                 <<02722>>09725000
                                                               <<02722>>09730000
         ;              << 0 - OK.  Continue >>                <<02722>>09735000
                                                               <<02722>>09740000
         GO START;      << 1 - Restart on power problems >>    <<02722>>09745000
                                                               <<02722>>09750000
         GO IO'ERROR;   << 2 - I/O error.  Quit >>             <<02722>>09755000
                                                               <<02722>>09760000
         ;              << 3 - Can't happen, IGNORE = FALSE >> <<02722>>09765000
                                                               <<02722>>09770000
         END;   << of case statement >>                        <<02722>>09775000
                                                               <<02722>>09780000
      << Put density in data structure. >>                     <<02722>>09785000
      STORE'DENSITY(LDEV,TLABEL,1);                            <<02722>>09790000
                                                               <<02722>>09795000
      END;   << of variable density drive. >>                  <<02722>>09800000
                                                               <<02722>>09805000
   SETOWNED(LDEV,ORIGINAL'STATE); <<RESET STATE OF DEVICE>>    <<*7477>>09810000
   CC := CCE;                                                  <<02722>>09815000
   RETURN;             << Only good exit from procedure >>     <<02722>>09820000
                                                               <<02722>>09825000
                                                               <<02722>>09830000
IO'ERROR:      << Branch to here on I/O error >>               <<02722>>09835000
                                                               <<02722>>09840000
   CLEANLDEV(LDEV);      << Zero out TLT entry >>              <<02722>>09845000
   ATTACHIO(LDEV,0,0,0,DCLOSE,0,0,0,%13);                      <<02722>>09850000
   SETOWNED(LDEV,ORIGINAL'STATE);  <<RESET STATE OF DEVICE>>   <<*7477>>09855000
   CC := CCL;                                                  <<02722>>09860000
                                                               <<02722>>09865000
   END;       << procedure RECOGNIZE >>                                 09870000
$PAGE  " LINKLABEL "                                                    09875000
INTEGER PROCEDURE LINKLABEL(LDEVN,ACCESS);                              09880000
 VALUE ACCESS;                                                          09885000
 INTEGER LDEVN,ACCESS;                                                  09890000
  OPTION UNCALLABLE;                                                    09895000
  COMMENT                                                      <<03581>>09900000
                                                               <<03581>>09905000
     Called from ASKOP in ALLOCATE to link the file to the     <<03581>>09910000
a mount device in the tape label table.  If the volume is not  <<03581>>09915000
mounted, request is issued and the process awaits a reply or   <<03581>>09920000
for the volume to be mounted.  If the operator replies a       <<03581>>09925000
logical device the C field in word 5 of the VCB is set so      <<03581>>09930000
that the VOL1 label will be written later provided that        <<03581>>09935000
device is a tape (or serial disc), the tape is unlabeled or    <<03581>>09940000
expired, and is open for write.  The LDEV is returned.         <<03581>>09945000
                                                               <<03581>>09950000
DB is at the stack.                                            <<03581>>09955000
                                                               <<03581>>09960000
   ACCESS - depends on AOPTIONS.(12:4)                         <<03581>>09965000
    0 - read only                                              <<03581>>09970000
    1 - write only (write,write-save,append)                   <<03581>>09975000
    2 - read-write (read-write or update)                      <<03581>>09980000
                                                               <<03581>>09985000
Exit with tape at Load point.  FOPEN will call POSITION to     <<03581>>09990000
get to the required file.                                      <<03581>>09995000
;                                                              <<03581>>10000000
                                                                        10005000
   BEGIN                                                                10010000
   LOGICAL VTADDR,LTADDR;                                               10015000
   LOGICAL PINNO;                                                       10020000
   INTEGER SCODE,LDEV;                                                  10025000
   INTEGER LPDT'INDEX;                                         <<d8615>>10030000
      INTEGER RESULT = LINKLABEL;                                       10035000
   ARRAY LTBOUNDS(0:2) =Q;                                              10040000
      LOGICAL LTBASE = LTBOUNDS;                                        10045000
      LOGICAL LTTOP = LTBOUNDS+1;                                       10050000
      LOGICAL VTBASE = LTBOUNDS+1;                                      10055000
      LOGICAL VTTOP = LTBOUNDS+2;                                       10060000
   INTEGER ARRAY BUFFER(0:20);                                          10065000
      BYTE ARRAY BBUF(*) = BUFFER;                                      10070000
   INTEGER ARRAY REPLY(0:2) =Q;                                         10075000
      BYTE ARRAY REPLYB(*) =REPLY+1;   << Text of Reply >>              10080000
      INTEGER RCNT =REPLY;        << char count of Reply >>             10085000
   LOGICAL ARRAY VTBUF(0:VTESIZE-1) =Q;                                 10090000
      BUILDVCB;                                                         10095000
   LOGICAL ARRAY LTBUF(0:LTESIZE-1) =Q;                                 10100000
      BUILDLCB;                                                         10105000
   EQUATE REJECTED=3,                                                   10110000
        OKAY=2;                                                         10115000
                                                                        10120000
 << Find the VCB entry created by CREATETLTENT. >>                      10125000
                                                                        10130000
   RESULT := REJECTED;                                                  10135000
   PINNO := CURPRC/PCBSIZE;                                    <<06424>>10140000
   SCODE := GETSIR(TLTSIR);                                             10145000
   GETXDSW(LTBOUNDS,TLTDST,XLTBASE,3);                                  10150000
   VTADDR := VTBASE;                                                    10155000
   WHILE VTADDR < VTTOP DO                                              10160000
      BEGIN                                                             10165000
      GETXDSW(VTBUF,TLTDST,VTADDR,VTESIZE);                             10170000
      IF INUSE AND (VCB'PIN = PINNO) AND                                10175000
         VCB'LNKWAIT THEN GO PINMATCH;                                  10180000
      VTADDR := VTADDR+VTESIZE;                                         10185000
      END;                                                              10190000
   TAPETROUBLE(TT9);    << It should be there. >>              <<03581>>10195000
                                                                        10200000
PINMATCH:                                                               10205000
   VCB'LNKWAIT := 0;                                                    10210000
   IF (LDEV := VCB'LDEV) <> 0 THEN                             <<02648>>10215000
      BEGIN       << Re-open volume of mounted vol set. >>     <<02648>>10220000
      LTADDR := GETLDEV(LDEV,LTBUF);                           <<02648>>10225000
      IF <> THEN TAPETROUBLE(TT10);                            <<03581>>10230000
      GO WRCHK;                                                <<02648>>10235000
      END;                                                     <<02648>>10240000
                                                                        10245000
<< Search LDEV's to see if the needed volume has been mounted           10250000
and recognized by AVR.  Even if mounted, it won't yet be linked         10255000
to the volume entry, since we just finished constructing it.   >>       10260000
                                                                        10265000
   LTADDR := LTBASE;                                                    10270000
   WHILE LTADDR < LTTOP DO                                              10275000
      BEGIN                                                             10280000
      GETXDSW(LTBUF,TLTDST,LTADDR,LTESIZE);                             10285000
      LDEV := LCB'LDEV;                                                 10290000
      IF (LCB'VCB=0) AND GOODREEL(VTBUF,LTBUF) THEN GO WRCHK;  <<02648>>10295000
      LTADDR := LTADDR+VTESIZE;                                         10300000
      END;                                                              10305000
                                                                        10310000
<< Volume not mounted; harass opr for it. >>                            10315000
<< 287 Mount tape of volumeset ! >>                                     10320000
                                                                        10325000
   VCB'MNTWAIT := 1;        << Turn on Wait bit >>                      10330000
   POSTVTENT(VTBUF,VTADDR,SCODE);                                       10335000
   MOVE BBUF := VCB'VSETID,(6);                                         10340000
   MOVE BBUF(6) := " (ANS)";                                            10345000
   IF VCB'LABTYP=3 THEN MOVE BBUF(8) := "IBM";                          10350000
   BBUF(12) := 0;    << GENMSG terminator >>                            10355000
BUGOPR:                                                                 10360000
   RCNT := -1;                                                          10365000
   GENMSG(1,287,0,@BBUF,,,,,0,%1404,@REPLY);                   <<07112>>10370000
                                                                        10375000
<< Opr can either mount requested volume, which will be                 10380000
picked up by DEVREC and AVREC, or =REPLY an LDEV, which                 10385000
gets us here.  We check the LDEV to see if it is an                     10390000
appropriate tape.  >>                                                   10395000
                                                                        10400000
   IF REPLY < 0 THEN                                                    10405000
      BEGIN      << AVR, presumably; see what we got. >>                10410000
      SCODE := GETSIR(TLTSIR);                                          10415000
      GETXDSW(VTBUF,TLTDST,VTADDR,VTESIZE);                             10420000
      LDEV := VCB'LDEV;                                                 10425000
      LTADDR := GETLDEV(LDEV,LTBUF);                                    10430000
      IF < THEN TAPETROUBLE(TT10);    << AVR screwup >>        <<03581>>10435000
      GO WRCHK;                                                         10440000
      END;                                                              10445000
                                                                        10450000
<< Opr specified an LDEV.  See if it is legitimate. >>                  10455000
                                                                        10460000
   LDEV := BINARY'(REPLYB,RCNT);                                        10465000
   IF <> THEN GO BUGOPR;      << not a number >>                        10470000
   SCODE := GETSIR(TLTSIR);                                             10475000
   IF LDEV = 0 THEN GO REJECT;   << Opr rejected request. >>            10480000
   LTADDR := GETLDEV(LDEV,LTBUF);                                       10485000
   IF < OR (LCB'VCB <> 0) THEN GO WRONGLU;   << not tape, or in use. >> 10490000
   IF SETOWNED(LDEV,-1) <> 0 THEN GO WRONGLU; << it's owned >> <<06333>>10495000
   IF LCB'LABTYP = 0 THEN                                               10500000
      BEGIN                                                             10505000
                                                                        10510000
<<  The tape on the specified drive has not been identified; it         10515000
may have been Ready when the system came up.                            10520000
Read it and try AVR to spot a labeled tape; if the correct tape         10525000
is mounted, it will be linked by AVR. >>                                10530000
                                                                        10535000
      RELSIR(TLTSIR,SCODE);                                             10540000
      IF LCB'TAPE THEN RECOGNIZE(LDEV)                         <<03581>>10545000
                  ELSE CC := CCL;                              <<03581>>10550000
      IF < THEN GO BUGOPR;     << I/O error >>                          10555000
      SCODE := GETSIR(TLTSIR);     << Tape is at load point. >>         10560000
      LTADDR := GETLDEV(LDEV,LTBUF);                                    10565000
      END;                                                              10570000
   << Unlabbeled? >>                                                    10575000
   IF (LCB'LABTYP=1) AND ACCESS > READ THEN GO WVL;                     10580000
   IF LCB'VCB = VTADDR THEN GO WRCHK;  << correct tape - linked >>      10585000
   IF CKFORLDEV(LDEV) THEN GO WRTAPE;                          <<06026>>10590000
       << if read access, must be the exact tape requested >>  <<06026>>10595000
       << or we'll wipe out VOL1 label without permission. >>  <<06026>>10600000
   IF ACCESS = READ THEN                                       <<08277>>10605000
      BEGIN                                                    <<06026>>10610000
      IF GOODREEL(VTBUF,LTBUF) THEN GO WVL;                    <<06026>>10615000
      END                                                      <<06026>>10620000
   ELSE                                                        <<06026>>10625000
      GO WVL;                                                  <<06026>>10630000
                                                               <<06026>>10635000
       << If we have the correct access, let us use it     >>  <<06026>>10640000
       << for now as if it were unlabelled.                >>  <<06026>>10645000
                                                               <<02722>>10650000
<< Wrong tape.  Clean LDEV entry & rewind-unload. >>           <<02722>>10655000
                                                               <<02722>>10660000
WRTAPE:                                                        <<06026>>10665000
   CLEANLDEV(LDEV);                                            <<02722>>10670000
   RELSIR(TLTSIR,SCODE);                                       <<02722>>10675000
   ATTIO(LDEV,9);                                              <<02722>>10680000
   GO BUGOPR;                                                  <<02722>>10685000
                                                               <<02722>>10690000
<< Something wrong with operator's reply, ask again. >>        <<02722>>10695000
                                                               <<02722>>10700000
WRONGLU:                                                       <<02722>>10705000
   RELSIR(TLTSIR,SCODE);                                                10710000
   GO BUGOPR;                                                           10715000
                                                                        10720000
<< It's either an unlabelled tape, or we're overwriting a  >>  <<07113>>10725000
<< labelled tape with a new volume id.                     >>  <<07113>>10730000
                                                                        10735000
WVL:                                                                    10740000
   LCB'FSEQ := 1;                                                       10745000
   LCB'REEL := 1;                                                       10750000
   LCB'VCB := VTADDR;                                                   10755000
   VCB'MNTWAIT := 0;                                                    10760000
   VCB'LDEV := LDEV;                                                    10765000
                                                               <<d8615>>10770000
   << VCB'DENSITY is only used for variable density drives. >> <<d8615>>10775000
   << If no specific density request has been made by the   >> <<d8615>>10780000
   << user, set it to the default density of the drive.     >> <<d8615>>10785000
                                                               <<d8615>>10790000
   LPDT'INDEX := LDEV * SIZE'OF'LPDT'ENTRY;                    <<d8615>>10795000
   IF VCB'DENSITY = LDT'NO'DENSITY THEN                        <<d8615>>10800000
      BEGIN                                                    <<d8615>>10805000
      IF (LPDT'AUTO'SUBTYPE = HP7976) OR                       <<d8615>>10810000
         (LPDT'AUTO'SUBTYPE = HP7978) THEN                     <<d8615>>10815000
         VCB'DENSITY := LDT'DENSITY'6250                       <<d8615>>10820000
      ELSE    << HP7974 or HP7970 (not used) >>                <<d8615>>10825000
         VCB'DENSITY := LDT'DENSITY'1600;                      <<d8615>>10830000
      END;                                                     <<d8615>>10835000
                                                                        10840000
   IF ACCESS <> 0 THEN                                         <<06026>>10845000
      VCB'NEEDVOL := 1;   << Write a VOL1 later >>             <<06026>>10850000
   POSTVTENT(LTBUF,LTADDR,-1);                                          10855000
   POSTVTENT(VTBUF,VTADDR,SCODE);                                       10860000
   GO GOODEXIT;                                                         10865000
                                                                        10870000
<<  A labelled tape of the vol set is mounted and at load point;        10875000
determine if it is suitable.   >>                                       10880000
                                                                        10885000
WRCHK:                                                                  10890000
   IF ACCESS <> READ THEN                                      <<08277>>10895000
      BEGIN     << Write access. >>                                     10900000
      RELSIR(TLTSIR,SCODE);                                             10905000
      IF CKFORLDEV(LDEV) THEN                                  <<06026>>10910000
         BEGIN           << Not OK to write. >>                         10915000
         SCODE := GETSIR(TLTSIR);                                       10920000
         LCB'VCB := 0;          << De-link >>                           10925000
         POSTVTENT(LTBUF,LTADDR,-1);                                    10930000
REJECT:                                                                 10935000
         VCB'LDEV := 0;                                                 10940000
         VCB'FLAGS := 0;      << Release Volume entry. >>               10945000
         POSTVTENT(VTBUF,VTADDR,SCODE);                                 10950000
         GO NOLINK;                                                     10955000
         END;                                                           10960000
      SCODE := GETSIR(TLTSIR);                                          10965000
      END;                                                              10970000
   LCB'VCB := VTADDR;                                                   10975000
   VCB'MNTWAIT := 0;                                                    10980000
   VCB'LDEV := LDEV;                                                    10985000
                                                                        10990000
   POSTVTENT(LTBUF,LTADDR,-1);                                          10995000
   POSTVTENT(VTBUF,VTADDR,SCODE);                                       11000000
                                                                        11005000
GOODEXIT:                                                               11010000
   LDEVN := LDEV;                                                       11015000
   RESULT := OKAY;                                                      11020000
NOLINK:                                                                 11025000
   END;       << procedure LINKLABEL >>                                 11030000
$PAGE " CLEANLDEV "                                                     11035000
PROCEDURE CLEANLDEV(LDEV);                                              11040000
  VALUE LDEV;                                                  <<02575>>11045000
  INTEGER LDEV;                                                         11050000
  OPTION UNCALLABLE;                                                    11055000
                                                                        11060000
<< Called from FCLOSE and CHECKUL for FCLOSE to purge an LDEV entry     11065000
from the TLT.  Caller should Rewind-Unload. DB at the stack.  >>        11070000
                                                                        11075000
   BEGIN                                                                11080000
   INTEGER LTADDR,SCODE;                                                11085000
   LOGICAL ARRAY LTBUF(0:LTESIZE-1) =Q;                                 11090000
                                                                        11095000
   SCODE := GETSIR(TLTSIR);                                             11100000
   LTADDR := GETLDEV(LDEV,LTBUF);                                       11105000
   IF < THEN TAPETROUBLE(TT15);                                <<03581>>11110000
    LCB'FLAGS := LCB'FLAGS LAND %1000;  << Leave Tape Bit >>   <<03581>>11115000
   LTBUF(2) := 0;                                                       11120000
   MOVE LTBUF(3) := LTBUF(2),(VTESIZE-3);                               11125000
   POSTVTENT(LTBUF,LTADDR,SCODE);                                       11130000
   END;   << procedure CLEANLDEV >>                                     11135000
$PAGE " REELSWITCH "                                                    11140000
INTEGER PROCEDURE REELSWITCH(LDEV,RDWR);                                11145000
VALUE LDEV,RDWR;                                                        11150000
LOGICAL LDEV;                                                           11155000
INTEGER RDWR;                                                           11160000
  OPTION UNCALLABLE;                                                    11165000
                                                                        11170000
<< Called from POSITION, IOMOVE, RESTORE, etc. when a tapemark          11175000
or EOT marker is encountered in the data area to switch to the          11180000
next reel of a multi-volume file.  If writing, or if reading            11185000
and EOV follows, REELSWITCH calls for the next reel, positions          11190000
it to the data area, and returns True.  If read other than EOV,         11195000
positions tape to tapemark at end of data and returns                   11200000
False.  DB can be anywhere, typically at the user's buffer.             11205000
   RDWR = 0:  Read; next sequential vol of vol set required.            11210000
          1:  Write; any tape OK; any vol label is kept.                11215000
          2:  Read for POSITION; any vol of vol set OK.                 11220000
                                                                        11225000
Returns:  LDEV and CCE if next reel mounted                             11230000
          LDEV and CCG if EOF label found                               11235000
          LDEV and CCL if operator did =REPLY 0.   >>                   11240000
                                                                        11245000
<< Note: although it is planned to allow subsequent volumes             11250000
on different LDEV's, callers can't handle this now, so that             11255000
is not provided for in this code. >>                                    11260000
                                                                        11265000
   BEGIN                                                                11270000
   LOGICAL VTADDR,LTADDR,XLDEV;                                         11275000
   INTEGER SCODE,USERDB;                                                11280000
   LOGICAL RESTOR := FALSE;                                    <<0615>> 11285000
   LOGICAL WRITE = RDWR;                                                11290000
   INTEGER LPDT'INDEX;                                         <<06333>>11295000
   INTEGER RESULT = REELSWITCH;                                         11300000
   INTEGER LTYPE;                                                       11305000
   LOGICAL ARRAY VTBUF(0:VTESIZE-1) =Q;                                 11310000
      BUILDVCB;                                                         11315000
   LOGICAL ARRAY LTBUF(0:LTESIZE-1) =Q;                                 11320000
      BUILDLCB;                                                         11325000
   INTEGER ARRAY BUFFER(0:30);                                          11330000
      BYTE ARRAY BBUF(*) = BUFFER;                                      11335000
   INTEGER ARRAY REPLY(0:3) =Q;                                         11340000
      BYTE ARRAY REPLYB(*) =REPLY+1;                                    11345000
      INTEGER RCNT = REPLY;                                             11350000
                                                               <<02648>>11355000
SUBROUTINE ATTIOS(FUNC);                                       <<02648>>11360000
VALUE FUNC; INTEGER FUNC;                                      <<02648>>11365000
                                                               <<02648>>11370000
   BEGIN                                                       <<02648>>11375000
   IF LDEV=0 THEN TAPETROUBLE(TT5);    << oops! >>             <<03581>>11380000
   TOS := ATTACHIO(LDEV,0,0,0,FUNC,0,0,4,%11);                 <<02689>>11385000
   DEL;                                                        <<02648>>11390000
   IF S0.(13:3) > 2 THEN                                       <<02648>>11395000
      BEGIN                                                    <<02673>>11400000
      REPORT'IOERROR(LDEV,S0.(8:8));   << gripe >>             <<02673>>11405000
      END;                                                     <<02648>>11410000
   X := TOS;                                                   <<02648>>11415000
   END;                                                        <<02648>>11420000
                                                               <<02648>>11425000
 << Begin execution >>                                                  11430000
                                                                        11435000
   CC := CCE;                                                           11440000
   USERDB := EXCHANGEDB(0);                                             11445000
   LTADDR := GETLDEV(LDEV,LTBUF);                                       11450000
   IF < THEN TAPETROUBLE(TT15);                                <<03581>>11455000
   VTADDR := LCB'VCB;                                                   11460000
   GETXDSW(VTBUF,TLTDST,VTADDR,VTESIZE);                                11465000
   IF LDEV <> VCB'LDEV THEN TAPETROUBLE(TT16);                 <<03581>>11470000
   IF RDWR < 0 THEN                                            <<0615>> 11475000
      BEGIN     << called from STARTVOLUME in RESTORE >>       <<0615>> 11480000
      RDWR := 2;      << set to READ >>                        <<02662>>11485000
      RESTOR := 1;    << GENMSG ask for "prior" reel. >>       <<0615>> 11490000
      GO UNLOAD;                                               <<0615>> 11495000
      END;                                                              11500000
                                                                        11505000
   IF WRITE THEN                                                        11510000
      BEGIN         << Write; finish off this reel. >>                  11515000
      WRITELAB(VTBUF,2);        << write TM,EOV1&2 >>                   11520000
      ATTIOS(6);         << write TM ending labels >>          <<02648>>11525000
      ATTIOS(6);         << write TM ending everything >>      <<02648>>11530000
      END                                                               11535000
   ELSE                                                                 11540000
      BEGIN    << Read.  If EOV1 follows, need next reel. >>            11545000
      LTYPE := CHECK1(LTBUF);      << ** need err check >>              11550000
      IF LTYPE <> 2 THEN                                                11555000
         BEGIN      << should be EOF1. Other cases illegal >>           11560000
         ATTIOS(12);   << BSR over what we just read >>        <<02648>>11565000
         ATTIOS(12);   << BSR over tape mark >>                <<02648>>11570000
         CC := CCG;        << report EOF >>                             11575000
         GO DONE;       << No more; FREAD will return EOF. >>  <<02563>>11580000
         END;                                                           11585000
      END;    << Read >>                                                11590000
UNLOAD:                                                        <<0615>> 11595000
   ATTIOS(9);       << Rewind Unload >>                        <<02648>>11600000
   SCODE := GETSIR(TLTSIR);                                             11605000
                                                                        11610000
<< The old reel has been disposed of.  Figure out which                 11615000
one comes next. >>                                                      11620000
<< 288 Mount next volume of set ! on LDEV# \ >>                         11625000
<< 289 Mount prior volume of set ! on LDEV# \ >>                        11630000
                                                                        11635000
   VCB'REEL := VCB'REEL+1;                                     <<04872>>11640000
   VCB'RSWAIT := 1;                                                     11645000
   VCB'DR'WAIT := 0;  <<  Set to wait on DEVREC >>             <<04698>>11650000
   POSTVTENT(VTBUF,VTADDR,SCODE);                                       11655000
   SETOWNED(LDEV,0);    << set unowned to enable AVR >>        <<04698>>11660000
                                                                        11665000
   MOVE BBUF := VCB'VSETID,(6);                                         11670000
   BBUF(6) := 0;    << GENMSG terminator >>                             11675000
BUGOPR:                                                                 11680000
   RCNT := -1;                                                          11685000
   GENMSG(1,288+RESTOR,%01000,@BBUF,LDEV,,,,0,%1404,@REPLY);   <<07112>>11690000
   IF RCNT < 0 THEN GO DIDAVR;                                          11695000
   XLDEV := BINARY'(REPLYB,RCNT);                                       11700000
   IF <> THEN GO BUGOPR;                                                11705000
   IF XLDEV = 0 THEN GO FLUSH;    << Opr reject. >>                     11710000
   GO BUGOPR;        << other replies invalid. >>                       11715000
                                                                        11720000
<< AVR has happened.  See what tape has been mounted. >>                11725000
                                                                        11730000
<< After AVREC has woken us up, DEVREC still modifies some >>  <<02563>>11735000
<< of the tape data structures.  In particular, it sets    >>  <<02563>>11740000
<< the device state to unowned and determines the tape's   >>  <<02563>>11745000
<< density.  We cannot continue until DEVREC has finished. >>  <<02563>>11750000
<< By waiting on the TAPEREC bit in the LPDT, we can be    >>  <<02563>>11755000
<< sure that AVR has finished. >>                              <<02563>>11760000
                                                               <<02563>>11765000
DIDAVR:                                                                 11770000
   GETXDSW(VTBUF,TLTDST,VTADDR,VTESIZE);                       <<03618>>11775000
   WHILE NOT VCB'DR'WAIT DO                                    <<03618>>11780000
     BEGIN                                                     <<03618>>11785000
     DELAY(100D);       <<  Wait for DEVREC to finish  >>      <<03618>>11790000
     GETXDSW(VTBUF,TLTDST,VTADDR,VTESIZE);                     <<03618>>11795000
     END;                                                      <<03618>>11800000
   SCODE := GETSIR(TLTSIR);                                             11805000
   LTADDR := GETLDEV(LDEV,LTBUF);                                       11810000
   IF < THEN TAPETROUBLE(TT16);                                <<03581>>11815000
   IF WRITE THEN                                               <<02648>>11820000
      BEGIN                                                    <<02648>>11825000
      IF LCB'LABTYP=1 THEN GO WVL      << unlabelled >>        <<02648>>11830000
      ELSE IF LCB'LABTYP=VCB'LABTYP THEN GO WRCHK;             <<02648>>11835000
      END                                                      <<02648>>11840000
   ELSE                                                        <<02648>>11845000
      BEGIN      << Read >>                                    <<02648>>11850000
      IF (LCB'LABTYP=VCB'LABTYP) AND LCB'VSETID=VCB'VSETID,(6) <<02648>>11855000
      THEN BEGIN                                               <<S8980>>11860000
         IF (RDWR=2) OR (LCB'REEL=VCB'REEL) AND                <<S8980>>11865000
            (LCB'FSEQ=VCB'FSEQ) THEN GO READIT                 <<S8980>>11870000
         ELSE IF (NOT RESTOR) AND (LCB'REEL < VCB'REEL) THEN   <<S8980>>11875000
            GENMSG (1, 10, %10000, LDEV, , , , , 0, 1, @REPLY);<<S8980>>11880000
      END;                                                     <<S8980>>11885000
      END;                                                     <<02648>>11890000
   RELSIR(TLTSIR,SCODE);                                       <<02722>>11895000
   ATTIOS(9);            << Wrong tape; unload it. >>          <<02722>>11900000
   GO BUGOPR;                                                           11905000
                                                               <<04739>>11910000
                                                                        11915000
                                                               <<04739>>11920000
FLUSH:                                                         <<04739>>11925000
                                                               <<04739>>11930000
   IF NOT LCB'TAPE THEN << So we may do I/O to serial >>       <<04739>>11935000
     SETOWNED(LDEV,1);  <<disc, we must set owned, in >>       <<04739>>11940000
                 <<additon we leave it owned until the>>       <<04739>>11945000
                 <<SDISC XDS gets cleaned up.         >>       <<04739>>11950000
   SCODE := GETSIR(TLTSIR);                                    <<04739>>11955000
   VCB'FLUSH := 1;                                             <<04739>>11960000
   POSTVTENT(VTBUF,VTADDR,SCODE);                              <<04739>>11965000
                                                               <<04739>>11970000
   << Done with tape drive, clean up data structure. >>        <<04739>>11975000
   CLEANLDEV(LDEV);                                            <<04739>>11980000
   IF LCB'TAPE THEN SET'BOT'ON; <<Tape at BOT>>                <<04739>>11985000
   STORE'DENSITY(LDEV,LDEV,2);   << Clean density >>           <<04739>>11990000
                                                               <<04739>>11995000
   CC := CCL;                                                  <<04739>>12000000
   SETOWNED(LDEV,0);  <<Just in case we are owned >>           <<04739>>12005000
   GO DONE;          << Report lossage. >>                     <<04739>>12010000
                                                               <<04739>>12015000
<< There is now a blank (unlabelled) tape to write on LDEV.             12020000
We'll cook a VOL1 label.  >>                                            12025000
<< 290 Vol ID for volume of set ! on LDEV# \? >>                        12030000
                                                                        12035000
WVL:                                                                    12040000
   RELSIR(TLTSIR,SCODE);                                                12045000
   GENMSG(1,290,%01000,@BBUF,LDEV,,,,0,%3004,@REPLY);                   12050000
   MOVE VCB'VOLID := "      ";                                          12055000
<< Need to bless the input. >>                                 <<02648>>12060000
   MOVE VCB'VOLID := REPLYB,(RCNT);                                     12065000
                                                                        12070000
   LCB'LABTYP := VCB'LABTYP;                                            12075000
   MOVE LCB'VOLID := VCB'VOLID,(6);                                     12080000
   MOVE LCB'VSETID := VCB'VSETID,(6);                                   12085000
   LCB'FSEQ := VCB'FSEQ;                                                12090000
   LCB'REEL := VCB'REEL;                                                12095000
   LCB'EXDATE := VCB'EXDATE;                                            12100000
   VCB'POSN := IF VCB'STORTAP THEN AH2 ELSE AD;                         12105000
   VCB'RSWDONE := 1;                                                    12110000
   VCB'WRITDIR := VCB'STORTAP;                                          12115000
   VCB'RSWAIT := 0;                                                     12120000
   SCODE := GETSIR(TLTSIR);                                             12125000
   POSTVTENT(VTBUF,VTADDR,-1);                                          12130000
   POSTVTENT(LTBUF,LTADDR,SCODE);                                       12135000
   SETOWNED(LDEV,1);                                           <<02563>>12140000
   WRITLAB0(VTBUF);                                            <<02563>>12145000
   GO WRITING;                                                          12150000
                                                                        12155000
<< Reading: correct labeled tape is mounted and at loadpoint. >>        12160000
                                                                        12165000
READIT:                                                                 12170000
   VCB'RSWAIT := 0;     << turn off Wait for REELSWITCH >>              12175000
   MOVE VCB'VOLID := LCB'VOLID,(6);                                     12180000
   VCB'POSN := IF RESTOR THEN AH2 ELSE AD;                              12185000
   IF RDWR <> 2 THEN VCB'RSWDONE := 1;                         <<02690>>12190000
   POSTVTENT(VTBUF,VTADDR,SCODE);                                       12195000
   SETOWNED(LDEV,1);                                                    12200000
   ATTIOS(7);     << FSF over VOL1 and hdr lbls >>             <<02648>>12205000
   IF RESTOR THEN                                              <<0615>> 12210000
      BEGIN         << Go to user hdr lbl (STORE label) >>              12215000
      ATTIOS(12);   << BSR over tapemark >>                    <<02648>>12220000
      ATTIOS(12);   << BSR over last header label >>           <<02648>>12225000
      END;                                                              12230000
   GO GOODEXIT;                                                         12235000
                                                                        12240000
<< Writing: the correct labeled tape has been mounted and is            12245000
at loadpoint; see if it is writeable.  >>                               12250000
                                                                        12255000
WRCHK:                                                                  12260000
   VCB'RSWAIT := 0;     << turn off Wait for REELSWITCH >>              12265000
   MOVE VCB'VOLID := LCB'VOLID,(6);                                     12270000
   VCB'POSN := IF VCB'STORTAP THEN AH2 ELSE AD;                         12275000
   VCB'RSWDONE := 1;                                                    12280000
   VCB'WRITDIR := VCB'STORTAP;                                          12285000
   POSTVTENT(VTBUF,VTADDR,SCODE);                                       12290000
   IF NOT LCB'TAPE THEN SETOWNED(LDEV,0);  << Kludge because >><<04647>>12295000
                              << serial disc will be owned   >><<04647>>12300000
   IF CKFORLDEV(LDEV) OR CKFOREXDATE(LDEV,1,2) THEN            <<06026>>12305000
      BEGIN  << Wrong tape, Set up to mount another tape >>    <<04739>>12310000
      SETOWNED(LDEV,1);  << Disable AVR >>                     <<04739>>12315000
      SCODE := GETSIR(TLTSIR);                                 <<04739>>12320000
      VCB'RSWAIT := 1;   << turn on wait for reelswitch >>     <<04739>>12325000
      VCB'DR'WAIT := 0;  << set to wait on DEVREC >>           <<04739>>12330000
      MOVE BBUF := VCB'VSETID,(6);                             <<04739>>12335000
      MOVE BBUF(6) := 0; << GENMSG terminator     >>           <<04739>>12340000
      POSTVTENT(VTBUF,VTADDR,SCODE);                           <<04739>>12345000
      ATTIOS(9);   << Rewind-unload >>                         <<04739>>12350000
      SETOWNED(LDEV,0); << Enable AVR >>                       <<04739>>12355000
      GOTO BUGOPR;                                             <<04739>>12360000
      END;                                                     <<04739>>12365000
   SETOWNED(LDEV,1);                                           <<02563>>12370000
                                                               <<02563>>12375000
<< If the new reel is on a variable density drive, then >>     <<02563>>12380000
<< the VOL1 label will be rewritten if the tape is not  >>     <<02563>>12385000
<< at the correct density. >>                                  <<02563>>12390000
                                                               <<02563>>12395000
   LPDT'INDEX := LDEV * SIZE'OF'LPDT'ENTRY;                    <<06333>>12400000
   IF (VARIABLE'DENSITY) AND WRONG'DENSITY(VTBUF) THEN         <<02563>>12405000
      BEGIN             << Need a new VOL1 >>                  <<02563>>12410000
      ATTIOS(5);    << Rewind >>                               <<02648>>12415000
      WRITLAB0(VTBUF);                                         <<02563>>12420000
      END                                                      <<02563>>12425000
   ELSE                                                        <<02563>>12430000
      ATTIOS(11);   << FSR over VOL1 >>                        <<02648>>12435000
WRITING:                                                       <<02563>>12440000
   WRITELAB(VTBUF,0);       << write header labels >>                   12445000
   IF NOT VCB'STORTAP THEN ATTIOS(6);  << TM ends lbls >>      <<02648>>12450000
   LOGIT(VTBUF);          << write Log record >>                        12455000
GOODEXIT:                                                               12460000
   IF LCB'TAPE THEN SET'BOT'OFF; <<BOT is off for labtape>>    <<03581>>12465000
DONE:                                                          <<02563>>12470000
   RESULT := LDEV;                                                      12475000
   EXCHANGEDB(USERDB);                                                  12480000
   END;    << procedure REELSWITCH >>                                   12485000
$PAGE " CHECKUL "                                                       12490000
INTEGER PROCEDURE CHECKUL(FNUM,CODE,FUNC);                     <<02690>>12495000
  VALUE FNUM,CODE,FUNC;                                                 12500000
  INTEGER FNUM,CODE,FUNC;                                      <<02690>>12505000
  OPTION UNCALLABLE;                                                    12510000
                                                                        12515000
COMMENT                                                        <<02690>>12520000
                                                               <<02690>>12525000
Called by file system intrinsics that effect tape motion,      <<02690>>12530000
this procedure keeps track of tape position and handles user            12535000
and system tape labels.  DB can be anywhere.  Called from:              12540000
 C,F  Procedure                                                         12545000
 0,0  FREAD                                                             12550000
 1,E  FWRITE             E = ACB'NEWEOF                        <<02690>>12555000
 2,L  FREADLABEL         L = Label number                      <<02690>>12560000
 3,0  FWRITELABEL                                                       12565000
 4,D  FCLOSE             D = Disposition                       <<02690>>12570000
 5,E  FCONTROL RWND      E = ACB'NEWEOF                        <<02690>>12575000
 6,F  FSPACE             F.(14:1) = ACB'NEWEOF                 <<02690>>12580000
                         F.(15:1) = 0, BSR                     <<02690>>12585000
                                  = 1, FSR                     <<02690>>12590000
 7,0  FCONTROL FSF                                                      12595000
Returns error code and CCL if error, else 0 and CCE.           <<02690>>12600000
                                                               <<02690>>12605000
;   << End of comment >>                                       <<02690>>12610000
                                                                        12615000
BEGIN                                                                   12620000
   INTEGER VTADDR,LTADDR,SCODE,USERDB;                                  12625000
   INTEGER LDEV,POSN,LTYPE;                                             12630000
   INTEGER RESULT=CHECKUL;                                     <<02690>>12635000
   LOGICAL LFUNC=FUNC;                                         <<02690>>12640000
   LOGICAL MUSTCLOSE := FALSE;                                 <<02690>>12645000
   LOGICAL ARRAY VTBUF(0:VTESIZE-1) =Q;                                 12650000
   LOGICAL ARRAY LTBUF(0:LTESIZE-1) =Q;                                 12655000
   ARRAY LABEL2(0:3) =Q;                                       <<02662>>12660000
      DOUBLE LABELTYPE=LABEL2;                                 <<02662>>12665000
      BYTE ARRAY BTLABEL(*) = LABEL2;                          <<02662>>12670000
                                                                        12675000
SUBROUTINE ERREXIT(HACK);                                               12680000
VALUE HACK; INTEGER HACK;                                               12685000
   BEGIN                                                                12690000
   RESULT := HACK;                                             <<02690>>12695000
   IF MUSTCLOSE THEN RETURN;   << Finish all processing. >>    <<02690>>12700000
   CC := CCL;                                                           12705000
   GO OUT;                                                              12710000
   END;                                                                 12715000
SUBROUTINE ATTIOS(FUNC);                                                12720000
VALUE FUNC; INTEGER FUNC;                                               12725000
                                                                        12730000
   BEGIN                                                                12735000
   IF LDEV=0 THEN TAPETROUBLE(TT5);    << oops! >>             <<03581>>12740000
   TOS := ATTACHIO(LDEV,0,0,0,FUNC,0,0,4,%11);                 <<02689>>12745000
   DEL;                                                                 12750000
   IF S0.(13:3) > 2 THEN ERREXIT(LBTPOSERR);                            12755000
   X := TOS;                                                            12760000
   END;                                                                 12765000
SUBROUTINE FSFDATA(SKPE2);                                     <<02662>>12770000
   VALUE SKPE2; LOGICAL SKPE2;                                 <<02662>>12775000
   BEGIN       << Advance tape to EOF2 or first UTL. >>        <<02662>>12780000
SKIP:                                                                   12785000
   ATTIOS(7);       << FSF over data >>                                 12790000
   LTYPE := CHECK1(LTBUF);   << read EOF1/EOV1 >>                       12795000
   IF LTYPE = 2 THEN                                                    12800000
      BEGIN        << EOV found; need next reel. >>                     12805000
      ATTIOS(12);    << BSR over EOV1 >>                                12810000
      REELSWITCH(LDEV,0);                                               12815000
      IF < THEN ERREXIT(NAVAILDEV);     << never return... >>  <<06333>>12820000
      IF > THEN ERREXIT(LBTPOSERR);    << not EOV1?? >>                 12825000
      GETXDSW(VTBUF,TLTDST,VTADDR,VTESIZE);                             12830000
      GETXDSW(LTBUF,TLTDST,LTADDR,LTESIZE);                             12835000
      GO SKIP;                                                          12840000
      END;                                                              12845000
   IF LTYPE <> 1 THEN ERREXIT(LBTFMTERR);   << should be EOF1. >>       12850000
   IF NOT SKPE2 THEN RETURN;    << done. >>                    <<02662>>12855000
   TOS := ATTACHIO(LDEV,0,0,@LABEL2,READ,4,0,0,1);             <<02662>>12860000
   DEL;                                                        <<02662>>12865000
   TOS := TOS.(13:3);                                          <<02662>>12870000
   IF S0 > 2 THEN ERREXIT(LBTPOSERR);                          <<02662>>12875000
   IF LCB'LABTYP = 3 THEN CTRANSLATE(1,BTLABEL,,4);            <<02662>>12880000
   IF TOS=2 OR LABELTYPE <> "EOF2" THEN ATTIOS(12);   << BSR >><<02662>>12885000
   END;      << subroutine FSFDATA >>                                   12890000
   IF NOT (0 <= CODE <= 7) THEN TAPETROUBLE(TT41);             <<03581>>12895000
                                                               <<02690>>12900000
   CC := CCE;   << Anticipate no error. >>                     <<02690>>12905000
   USERDB := EXCHANGEDB(0);     << DB to stack >>                       12910000
   VTADDR := GETFNUM(FNUM,VTBUF);                                       12915000
   IF < THEN TAPETROUBLE(TT42);                                <<03581>>12920000
   POSN := VCB'POSN;                                                    12925000
   LDEV := VCB'LDEV;                                                    12930000
   IF VCB'FLUSH AND CODE <> 4 THEN                                      12935000
      BEGIN       << device unavailable (=REPLY 0) >>                   12940000
      ERREXIT(NAVAILDEV);                                      <<06333>>12945000
      END;                                                              12950000
   LTADDR := GETLDEV(LDEV,LTBUF);                                       12955000
   IF < THEN TAPETROUBLE(TT43);                                <<03581>>12960000
   CASE * CODE OF BEGIN                                                 12965000
      BEGIN         << 0: FREAD >>                                      12970000
      IF POSN > AD THEN ERREXIT(INVOP);                        <<06333>>12975000
      IF POSN < DNX THEN                                                12980000
         ATTIOS(7);     << FSF over hdr lbls >>                         12985000
      POSN := AD;                                                       12990000
      END;                                                              12995000
                                                                        13000000
      BEGIN       << 1: FWRITE: complete header labels. >>              13005000
      IF POSN > AD THEN ERREXIT(INVOP);                        <<06333>>13010000
      IF POSN < AH2 AND WRITELAB(VTBUF,0) THEN                 <<02662>>13015000
         ERREXIT(LBTPOSERR);          << write HDR1&2 >>       <<02662>>13020000
      IF POSN < DNX THEN ATTIOS(6);   << WTM ending hdr lbls >>         13025000
      POSN := AD;                                                       13030000
      END;     << Header labels are now complete. >>                    13035000
                                                                        13040000
      BEGIN      << 2: FREADLABEL >>                                    13045000
      IF POSN <= AHU THEN GO OUT;   << OK to read hdr >>                13050000
      IF POSN <= AD THEN FSFDATA(1);   << set to user trlr lbls<<02662>>13055000
      POSN := ATU;                                                      13060000
      END;                                                              13065000
                                                                        13070000
      BEGIN      << 3: FWRITELABEL >>                                   13075000
      IF POSN < AH2 THEN                                                13080000
         BEGIN      << write header labels >>                           13085000
         IF WRITELAB(VTBUF,0) THEN ERREXIT(LBTPOSERR);         <<02662>>13090000
         POSN := AHU;                                                   13095000
         END;                                                           13100000
      IF POSN = AD THEN                                                 13105000
         BEGIN         << Set to write trlr labels >>                   13110000
         IF WRITELAB(VTBUF,1) THEN ERREXIT(LBTPOSERR);   << TM,EOF1&2 >>13115000
         POSN := ATU;                                                   13120000
         END;                                                           13125000
      END;                                                              13130000
                                                                        13135000
      BEGIN            << 4: FCLOSE >>                                  13140000
      IF FUNC < 0 THEN MUSTCLOSE := TRUE;                      <<02690>>13145000
      IF VCB'FLUSH THEN                                        <<02722>>13150000
         BEGIN                                                 <<02722>>13155000
         RESULT := NAVAILDEV; << Tape drive is already free. >><<06333>>13160000
         GO CVOL;                                              <<02722>>13165000
         END;                                                  <<02722>>13170000
      IF VCB'WRITE THEN                                         <<2622>>13175000
         BEGIN          << Write access >>                      <<2622>>13180000
         IF POSN > H1NX THEN                                    <<2622>>13185000
            BEGIN       << Header labels written >>             <<2622>>13190000
            IF POSN < DNX THEN ATTIOS(6);  << WTM ending hdrs >><<2648>>13195000
            IF POSN < T1NX AND WRITELAB(VTBUF,1) THEN          <<02662>>13200000
               ERREXIT(LBTPOSERR);   << write TM,EOF1&2 >>     <<02662>>13205000
            ATTIOS(6);       << WTM ending trlr lbls >>                 13210000
            ATTIOS(6);       << WTM for EOV >>                          13215000
            IF FUNC < 2 THEN GO VSETCL;                                 13220000
            ATTIOS(12);       << BSR over EOV TM >>                     13225000
            IF FUNC = 2 THEN                                            13230000
               BEGIN          << Rewind file >>                         13235000
               ATTIOS(12);     << BSR over new TM >>                    13240000
               ATTIOS(8);      << BSF over trlr lbls >>                 13245000
               ATTIOS(8);      << BSF over data. (*** Need REELSW) >>   13250000
               ATTIOS(8);      << BSF over hdr lbls >>                  13255000
               ATTIOS(11);     << FSR over TM or VOL1 >>                13260000
               END                                                      13265000
            ELSE VCB'FSEQ := VCB'FSEQ+1;    << at next file >>          13270000
            END         << Header labels written >>             <<2622>>13275000
         ELSE                                                   <<2622>>13280000
            IF FUNC < 2 THEN GO VSETCL;                         <<2622>>13285000
         END            << Write access >>                      <<2622>>13290000
      ELSE                                                              13295000
         BEGIN       << Read access >>                                  13300000
         IF FUNC < 2 THEN                                               13305000
            BEGIN         << Close volume set >>                        13310000
VSETCL:     ATTIOS(9);      << Rewind-unload >>                         13315000
            CLEANLDEV(LDEV);                                   <<02689>>13320000
CVOL:       VTBUF := 0;      << CLEANTLT >>                    <<02689>>13325000
            POSN := 0;                                                  13330000
            MOVE VTBUF(1) := VTBUF,(VTESIZE-1);                         13335000
            GO OUT;                                                     13340000
            END;                                                        13345000
                                                                        13350000
         IF FUNC = 2 THEN                                               13355000
            BEGIN       << Rewind file: close vol but not vset. >>      13360000
            IF POSN >= T1NX THEN ATTIOS(8);  << BSF/trlrs >>            13365000
            IF POSN >= DNX THEN                                         13370000
               BEGIN          << backspace over data >>                 13375000
               ATTIOS(8);   << Loose end: add REELSWITCH. >>            13380000
               END;                                                     13385000
            ATTIOS(8);      << BSF over hdr lbls >>                     13390000
            ATTIOS(11);     << FSR over TM >>                           13395000
            END                                                         13400000
         ELSE                                                           13405000
            BEGIN       << advance to next file. >>                     13410000
            IF POSN < DNX THEN ATTIOS(7);  << FSF hdr lbls >>           13415000
            IF POSN < T1NX THEN FSFDATA(0);                    <<02662>>13420000
            ATTIOS(7);     << FSF over trlr lbls >>                     13425000
            VCB'FSEQ := VCB'FSEQ+1;                                     13430000
            END;                                                        13435000
         END;                                                           13440000
      POSN := H1NX;                                                     13445000
      VCB'FNUM := 0;   << CLEANTLTF: close vol but not vset. >>         13450000
      END;      << Exit with tape before HDR1. >>                       13455000
                                                                        13460000
      BEGIN         << 5: Rewind - write EOF & trlr labels >>           13465000
      IF VCB'STORTAP AND POSN = AD THEN GO OUT;    << Done. >>          13470000
      IF VCB'WRITE THEN                                                 13475000
         BEGIN             << WRITE access >>                           13480000
         IF POSN <= H1NX THEN GO OUT;  << no I/O. >>                    13485000
         IF POSN < DNX THEN                                             13490000
            ATTIOS(6);     << WTM: end of hdr labels >>                 13495000
         IF POSN < T1NX AND WRITELAB(VTBUF,1) THEN             <<02662>>13500000
            ERREXIT(LBTPOSERR);      << write TM,EOF1&2 >>     <<02662>>13505000
         ATTIOS(6);     << WTM: end of trlr labels >>                   13510000
         ATTIOS(6);     << WTM: end of vol set >>                       13515000
         ATTIOS(8);     << BSF over EOV TM >>                           13520000
         ATTIOS(8);     << BSF over end of trlr labels >>               13525000
         POSN := ATU;                                                   13530000
         END;         << Write access >>                                13535000
      IF POSN > AD THEN                                                 13540000
         ATTIOS(8);    << BSF over trlr labels >>                       13545000
      IF POSN >= DNX THEN                                               13550000
         BEGIN                                                          13555000
         ATTIOS(8);    << BSF over data (*** need reelswitch) >>        13560000
         END;                                                           13565000
      ATTIOS(8);    << BSF over header labels >>                        13570000
      IF CHECK1(LTBUF) = 3  << VOL1 >> THEN                             13575000
         ATTIOS(11);    << FSR over HDR1 >>                             13580000
      TOS := ATTACHIO(LDEV,0,0,@LABEL2,READ,4,0,0,1);          <<02662>>13585000
      DEL;                                                     <<02662>>13590000
      TOS := TOS.(13:3);                                       <<02662>>13595000
      IF S0 > 2 THEN ERREXIT(LBTPOSERR);                       <<02662>>13600000
      IF LCB'LABTYP = 3 THEN CTRANSLATE(1,BTLABEL,,4);         <<02662>>13605000
      IF TOS=2 OR LABELTYPE <> "HDR2" THEN ATTIOS(12);   << BSR >>      13610000
      POSN := AHU;                                                      13615000
      END;                                                              13620000
                                                                        13625000
      BEGIN         << 6: FSPACE >>                                     13630000
      IF POSN > AD THEN ERREXIT(INVOP);                        <<06333>>13635000
      IF POSN < DNX THEN     << in header label area >>                 13640000
       IF NOT LFUNC THEN ERREXIT(INVOP)  <<BSR in hdr lbls>>   <<06333>>13645000
         ELSE BEGIN                                                     13650000
         ATTIOS(7);     << FSF over hdr labels >>                       13655000
         POSN := DNX;                                                   13660000
         END;                                                           13665000
      IF LFUNC.(14:1) THEN                                     <<02690>>13670000
         BEGIN    << Backspace after write: TM needed. >>               13675000
         IF WRITELAB(VTBUF,1) THEN ERREXIT(LBTPOSERR);  << TM,EOF1&2 >> 13680000
         ATTIOS(6);    << WTM ending trlr labels >>                     13685000
         ATTIOS(6);    << WTM ending reel >>                            13690000
         ATTIOS(8);    << BSF over TM >>                                13695000
         ATTIOS(8);    << BSF over TM >>                                13700000
         ATTIOS(8);    << BSF over labels to end of data >>             13705000
         END;        << write trailer labels >>                         13710000
      POSN := AD;                                                       13715000
      END;                                                              13720000
                                                                        13725000
      BEGIN       << 7: FCONTROL 7 - FSF - go to UTL's >>               13730000
      IF POSN > AD THEN                                                 13735000
         ATTIOS(8)      << BSF over trlr labels >>                      13740000
      ELSE IF POSN < DNX THEN                                           13745000
         ATTIOS(7);     << FSF over header lbls >>                      13750000
      FSFDATA(1);       << FSF over data >>                    <<02662>>13755000
      POSN := AT2;                                                      13760000
      END;                                                              13765000
   END;     << CASE >>                                                  13770000
                                                                        13775000
OUT:                                                                    13780000
   SCODE := GETSIR(TLTSIR);                                             13785000
   VCB'POSN := POSN;                                                    13790000
   POSTVTENT(VTBUF,VTADDR,SCODE);                                       13795000
   EXCHANGEDB(USERDB);                                                  13800000
   END;     << procedure CHECKUL>>                                      13805000
$PAGE " POSITION "                                                      13810000
INTEGER PROCEDURE POSITION(LDEV,FNUM,BLKFACT,RSIZ,FOPS,AOPACTYPE);      13815000
   VALUE LDEV,FNUM,AOPACTYPE;                                           13820000
   INTEGER FNUM,BLKFACT,RSIZ;                                           13825000
   LOGICAL LDEV,FOPS,AOPACTYPE;                                         13830000
  OPTION UNCALLABLE;                                                    13835000
                                                                        13840000
COMMENT                                                        <<03581>>13845000
                                                               <<03581>>13850000
   Called from FOPEN to get to the beginning of the specified  <<03581>>13855000
file.  Tape is assumed to be at load point or at a HDR1 label. <<03581>>13860000
File expiration date is checked after positioning tape to the  <<06026>>13865000
specific file.  If adding a file at end of reel, its expiration<<06026>>13870000
date must be no later than that of the file preceding it.      <<06026>>13875000
If reading, exits with tape after HDR2 label, if writing,      <<03581>>13880000
positioned to write HDR1 after writing VOL1 label if C         <<03581>>13885000
flag in word 5 of VCB is set.  Returns error code, 0 if OK;    <<03581>>13890000
                                                                        13895000
   BEGIN                                                                13900000
   LOGICAL VTADDR,LTADDR,SCODE;                                         13905000
   INTEGER RECSIZE;                                                     13910000
   INTEGER BLKSIZE;                                                     13915000
   INTEGER LTYPE;                                                       13920000
   INTEGER LPDT'INDEX;                                         <<06333>>13925000
   LOGICAL                                                     <<02563>>13930000
      FIRSTFILE,      << denotes first file on reel >>         <<02563>>13935000
      COUNT,          << for kludgy fseq position >>           <<02563>>13940000
   LASTEXDATE,        << exp date of previous file on reel >>  <<06026>>13945000
      ADDING;         << adding file to end of vset >>         <<02563>>13950000
   LOGICAL ARRAY TLABEL(0:LBLSIZE-1) =Q;                                13955000
      BYTE ARRAY BTLABEL(*)=TLABEL;                                     13960000
      DOUBLE LTBUFTYPE = TLABEL;                                        13965000
   LOGICAL ARRAY VTBUF(0:VTESIZE-1) =Q;                                 13970000
      BUILDVCB;                                                         13975000
   LOGICAL ARRAY LTBUF(0:LTESIZE-1) =Q;                                 13980000
      BUILDLCB;                                                         13985000
EQUATE FLAGS = 1;                                                       13990000
                                                                        13995000
<< Error subroutine >>                                                  14000000
                                                                        14005000
SUBROUTINE ERREXIT(ERRCODE);                                            14010000
VALUE ERRCODE; INTEGER ERRCODE;                                         14015000
   BEGIN                                                                14020000
   SCODE := GETSIR(TLTSIR);                                             14025000
   VTBUF := 0;     << CLEANTLT - close vol & volset >>                  14030000
   MOVE VTBUF(1) := VTBUF,(VTESIZE-1);                                  14035000
   LCB'FLAGS := LCB'FLAGS LAND %1000; << Leave Tape Bit >>     <<03581>>14040000
   LTBUF(2) := 0;                                                       14045000
   MOVE LTBUF(3) := LTBUF(2),(VTESIZE-3);                               14050000
   POSITION := ERRCODE;   << report error >>                            14055000
   GO POSERR;                                                           14060000
   END;                                                                 14065000
SUBROUTINE ATTIOS(FUNC);                                                14070000
VALUE FUNC; INTEGER FUNC;                                               14075000
                                                                        14080000
   BEGIN                                                                14085000
   IF LDEV=0 THEN TAPETROUBLE(TT5);  << oops! >>               <<03581>>14090000
   TOS := ATTACHIO(LDEV,0,0,0,FUNC,0,0,4,%11);                 <<02689>>14095000
   DEL;                                                                 14100000
   IF S0.(13:3) > 2 THEN ERREXIT(LBTPOSERR);                            14105000
   X := TOS;                                                            14110000
   END;                                                                 14115000
 << Forward Space 1 file from HDR2 to next HDR2. >>                     14120000
                                                                        14125000
SUBROUTINE FSFILE;                                                      14130000
   BEGIN                                                                14135000
   FIRSTFILE := FALSE;                                                  14140000
   ATTIOS(7);     << FSF over header lbls >>                            14145000
SKIP:                                                                   14150000
   ATTIOS(7);     << FSF over data >>                                   14155000
   LTYPE := CHECK1(LTBUF);   << read EOF1/EOV1 >>                       14160000
   IF < THEN ERREXIT(LBTPOSERR);                                        14165000
   IF LTYPE = 2 THEN                                                    14170000
      BEGIN        << EOV found; need next reel. >>                     14175000
      ATTIOS(12);    << BSR over EOV1 >>                                14180000
      REELSWITCH(LDEV,2);                                               14185000
      IF < THEN ERREXIT(NAVAILDEV);     << never return... >>  <<06333>>14190000
      IF > THEN ERREXIT(LBTPOSERR);    << not EOV1?? >>                 14195000
      GETXDSW(VTBUF,TLTDST,VTADDR,VTESIZE);                             14200000
      GETXDSW(LTBUF,TLTDST,LTADDR,LTESIZE);                             14205000
      GO SKIP;                                                          14210000
      END;                                                              14215000
   IF LTYPE <> 1 THEN ERREXIT(LBTFMTERR);   << should be EOF1. >>       14220000
   LASTEXDATE := LCB'EXDATE;                                   <<06026>>14225000
   ATTIOS(7);     << FSF over trlr lbls >>                              14230000
   LTYPE := CHECK1(LTBUF);     << read TM/HDR1 >>                       14235000
   IF < THEN ERREXIT(LBTPOSERR);                                        14240000
   IF LTYPE > 0 THEN ERREXIT(LBTFMTERR);  << wasn't >>                  14245000
   IF LTYPE < 0 THEN LCB'FSEQ := LCB'FSEQ+1;                            14250000
   END;          << subroutine FSFILE >>                                14255000
<< Begin execution >>                                                   14260000
                                                                        14265000
   VTADDR := GETFNUM(FNUM,VTBUF);                                       14270000
   IF < THEN TAPETROUBLE(TT23);                                <<03581>>14275000
   IF LDEV <> VCB'LDEV THEN TAPETROUBLE(TT24);                 <<03581>>14280000
   LTADDR := GETLDEV(LDEV,LTBUF);                                       14285000
   IF AOPACTYPE <> 0 THEN                                               14290000
      ATTIOS(1);      << check for write ring >>                        14295000
   FIRSTFILE := FALSE;                                                  14300000
   ADDING := FALSE;                                            <<02563>>14305000
   LCB'FSEQ := VCB'FSEQ;   << default >>                                14310000
   IF VCB'NEEDVOL THEN                                         <<03581>>14315000
      BEGIN                                                    <<03581>>14320000
      << check expiration date to see if VOL1 label can      >><<06026>>14325000
      << be overwritten.                                     >><<06026>>14330000
      IF CKFOREXDATE(LDEV,1,1) THEN ERREXIT(LBTUNEXP);         <<06026>>14335000
      WRITLAB0(VTBUF);                                         <<03581>>14340000
      ATTIO(LDEV,6);  << write TM in lieu of HDR1 >>           <<03581>>14345000
      ATTIO(LDEV,5);  <<rewind>>                               <<03581>>14350000
      END;                                                     <<03581>>14355000
                                                                        14360000
   << If this is a new volume set open, set previous file's  >><<07113>>14365000
   << expiration date to 12/31/99 for comparing with first   >><<07113>>14370000
   << file's, which will then never be later.  Else, use the >><<07113>>14375000
   << previous file exp date in LCB'EXDATE.  This is accu-   >><<07113>>14380000
   << rate if the file was closed with disp=3, but not for   >><<07113>>14385000
   << disp=2, since LCB'EXDATE refers to the same file we    >><<07113>>14390000
   << are opening.  The check will be more restrictive than  >><<07113>>14395000
   << necessary in this case.  We make up for this partially >><<07113>>14400000
   << by setting LASTEXDATE to 12/31/99 if the first file of >><<07113>>14405000
   << the volume set is being re-opened.                     >><<07113>>14410000
                                                               <<07113>>14415000
   IF VCB'VSETOPEN OR (VCB'FSEQ=1) THEN                        <<07113>>14420000
      BEGIN                                                    <<07113>>14425000
      LASTEXDATE := 365;                                       <<07113>>14430000
      LASTEXDATE.(0:7) := 99;                                  <<07113>>14435000
      END                                                      <<07113>>14440000
   ELSE                                                        <<07113>>14445000
      LASTEXDATE := LCB'EXDATE;                                <<07113>>14450000
                                                               <<07113>>14455000
SV:                                                            <<07113>>14460000
   LTYPE := CHECK1(LTBUF);    << read TM, VOL1, or HDR1 >>              14465000
   IF < THEN ERREXIT(LBTPOSERR);                                        14470000
   IF LTYPE = 3 THEN                                                    14475000
      BEGIN     << VOL1 >>                                              14480000
      FIRSTFILE := TRUE;                                                14485000
      GO SV;                                                            14490000
      END;                                                              14495000
   IF LTYPE = 5 AND FIRSTFILE THEN GO SV;    << skip UVL's >>  <<02621>>14500000
   IF LTYPE > 0 THEN ERREXIT(LBTFMTERR);                                14505000
                                                               <<07113>>14510000
   << now at HDR1 label or EOT >>                              <<07113>>14515000
                                                               <<07113>>14520000
   CASE * VCB'SEQTYP OF BEGIN                                           14525000
      BEGIN       << 0: search for file name >>                         14530000
AGIN:                                                                   14535000
      IF LTYPE < 0 THEN ERREXIT(LBTEOVSET);                             14540000
      IF VCB'FNAME = LCB'FNAME,(IF LCB'HP THEN 17 ELSE 8) THEN <<06026>>14545000
         BEGIN          << match found >>                      <<06026>>14550000
         IF AOPACTYPE > 0 THEN                                 <<06026>>14555000
            BEGIN                                              <<06026>>14560000
            IF NOT FIRSTFILE THEN                              <<06026>>14565000
               << must update LCB entry to file being opened >><<06026>>14570000
               << before calling CKFOREXDATE, since it grabs >><<06026>>14575000
               << the entry out of the TLT.                  >><<06026>>14580000
               BEGIN                                           <<06026>>14585000
                  SCODE := GETSIR(TLTSIR);                     <<06026>>14590000
                  POSTVTENT(LTBUF,LTADDR,SCODE);               <<06026>>14595000
               END;                                            <<06026>>14600000
            IF CKFOREXDATE(LDEV,1,2) THEN ERREXIT(LBTUNEXP);   <<06026>>14605000
            IF VCB'EXDATE > LASTEXDATE THEN ERREXIT(LATEREXP); <<06026>>14610000
            END;                                               <<06026>>14615000
         GO FMATCH;                                            <<06026>>14620000
         END;                                                  <<06026>>14625000
      FSFILE;                                                           14630000
      GO AGIN;                                                          14635000
      END;                                                              14640000
                                                                        14645000
      BEGIN      << 1: NEXT >>                                          14650000
      IF AOPACTYPE <> READ THEN GO ADDEND;                              14655000
      IF LTYPE < 0 THEN ERREXIT(LBTEOVSET);  << TM found >>             14660000
      GO FMATCH;                                                        14665000
      END;                                                              14670000
                                                                        14675000
      BEGIN       << 2: Add a file to end of volume set >>              14680000
ADDF:                                                                   14685000
      IF LTYPE < 0 THEN GO ADDEND;   << TM: end of vset. >>             14690000
      FSFILE;                                                           14695000
      GO ADDF;                                                          14700000
      END;                                                              14705000
                                                                        14710000
      BEGIN       << 3: Specified file seq # >>                         14715000
      COUNT := 0;                                                       14720000
BUMP:                                                                   14725000
      IF LTYPE < 0 THEN        << tapemark: end of vol set. >>          14730000
<<       IF LCB'FSEQ = VCB'FSEQ AND AOPACTYPE <> READ      >>           14735000
         IF (COUNT+1 = VCB'FSEQ) AND AOPACTYPE <> READ                  14740000
           THEN GO ADDEND ELSE ERREXIT(LBTEOVSET);                      14745000
<<    IF LCB'FSEQ = VCB'FSEQ THEN GO FMATCH;    >>                      14750000
      IF (COUNT := COUNT+1) >= VCB'FSEQ THEN                   <<06026>>14755000
         BEGIN                                                 <<06026>>14760000
         IF AOPACTYPE > 0 THEN                                 <<06026>>14765000
            BEGIN                                              <<06026>>14770000
            IF NOT FIRSTFILE THEN                              <<06026>>14775000
               BEGIN                                           <<06026>>14780000
                  SCODE := GETSIR(TLTSIR);                     <<06026>>14785000
                  POSTVTENT(LTBUF,LTADDR,SCODE);               <<06026>>14790000
               END;                                            <<06026>>14795000
            IF CKFOREXDATE(LDEV,1,2) THEN ERREXIT(LBTUNEXP);   <<06026>>14800000
            IF VCB'EXDATE > LASTEXDATE THEN ERREXIT(LATEREXP); <<06026>>14805000
            END;                                               <<06026>>14810000
         GO FMATCH;                                            <<06026>>14815000
         END;                                                  <<06026>>14820000
      FSFILE;                                                           14825000
      GO BUMP;                                                          14830000
      END;                                                              14835000
   END;   << CASE >>                                                    14840000
                                                                        14845000
ADDEND:               << Write new file at end of vset. >>              14850000
   IF FIRSTFILE THEN                                                    14855000
      BEGIN      << Start file sequencing. >>                           14860000
      LCB'FSEQ := 1;                                                    14865000
      IF VCB'NEEDVOL THEN                                      <<06026>>14870000
        << CKFOREXDATE already called, just clear bit >>       <<06026>>14875000
         VCB'NEEDVOL := 0                                      <<06026>>14880000
      ELSE                                                     <<06026>>14885000
         IF CKFOREXDATE(LDEV,1,2) THEN ERREXIT(LBTUNEXP);      <<06026>>14890000
      END                                                      <<06026>>14895000
   ELSE                                                        <<06026>>14900000
      BEGIN                                                    <<06026>>14905000
      IF LTYPE = 0 THEN << at HDR1, about to overwrite file >> <<07113>>14910000
         BEGIN                                                 <<06026>>14915000
         SCODE := GETSIR(TLTSIR);                              <<06026>>14920000
         POSTVTENT(LTBUF,LTADDR,SCODE);                        <<06026>>14925000
         IF CKFOREXDATE(LDEV,1,2) THEN ERREXIT(LBTUNEXP);      <<06026>>14930000
         END;                                                  <<06026>>14935000
      IF VCB'EXDATE > LASTEXDATE THEN ERREXIT(LATEREXP);       <<06026>>14940000
      END;                                                     <<06026>>14945000
   ADDING := TRUE;                                             <<02563>>14950000
FMATCH:                                                                 14955000
                                                               <<02563>>14960000
   IF AOPACTYPE <> 0 THEN                                      <<07113>>14965000
      BEGIN                                                    <<07113>>14970000
      << set remainder of LCB entry >>                         <<07113>>14975000
      LCB'EXDATE := VCB'EXDATE;                                <<07113>>14980000
      LCB'LABTYP := VCB'LABTYP;                                <<07113>>14985000
      MOVE LCB'VOLID := VCB'VOLID,(6);                         <<07113>>14990000
      MOVE LCB'VSETID := VCB'VOLID,(6);                        <<07113>>14995000
      END;                                                     <<07113>>15000000
                                                               <<07113>>15005000
<< If this is the volume set open, then must resolve density >><<02563>>15010000
<< for tapes on variable density drives.  If we're adding a  >><<02563>>15015000
<< file to an empty volume set or accessing the reel in NEXT >><<02563>>15020000
<< mode, then we'll rewrite the VOL1 label at the density    >><<02563>>15025000
<< requested by the user.  In all other cases, VCB'DENSITY   >><<02563>>15030000
<< must be updated to reflect the real density of the tape.  >><<02563>>15035000
                                                               <<02563>>15040000
   LPDT'INDEX := LDEV * SIZE'OF'LPDT'ENTRY;                    <<06333>>15045000
   IF VCB'VSETOPEN AND (VARIABLE'DENSITY) THEN                 <<02563>>15050000
      BEGIN                                                    <<02563>>15055000
      IF ADDING AND FIRSTFILE AND                              <<02563>>15060000
        WRONG'DENSITY(VTBUF)   THEN                            <<02563>>15065000
         BEGIN           << Rewrite VOL1 at new density >>     <<02563>>15070000
         ATTIOS(5);      << Rewind >>                          <<02563>>15075000
         IF WRITLAB0(VTBUF) THEN ERREXIT(LBTPOSERR);           <<02662>>15080000
         ATTIOS(6);      << Terminate VOL1 with TM >>          <<02563>>15085000
         END                                                   <<02563>>15090000
      ELSE                                                     <<02563>>15095000
         VCB'DENSITY := GET'DENSITY(LDEV);                     <<02563>>15100000
      END;                                                     <<02563>>15105000
                                                               <<02563>>15110000
   IF AOPACTYPE <> READ THEN                                            15115000
      BEGIN       << Write access >>                                    15120000
      ATTIOS(12);       << BSR over TM/HDR1 >>                          15125000
      VCB'POSN := H1NX;                                        <<02690>>15130000
      END                                                               15135000
   ELSE                                                                 15140000
      BEGIN       << Read access; check HDR2 label >>                   15145000
      TLABEL := 0;                                             <<02662>>15150000
      TOS := ATTACHIO(LDEV,0,0,@TLABEL,READ,LBLSIZE,0,0,FLAGS);         15155000
      DEL;                                                              15160000
      IF TOS.(13:3) > 2 THEN ERREXIT(LBTPOSERR);               <<02648>>15165000
      IF LCB'LABTYP = 3 THEN                                            15170000
         CTRANSLATE(1,BTLABEL,,80);    << from EBCDIC >>                15175000
      IF LTBUFTYPE = "HDR2" THEN                                        15180000
         BEGIN        << Process HDR2 label. >>                         15185000
                                                               <<02690>>15190000
  <<  If the file is an HP ANSI file, always use the  >>       <<02690>>15195000
  <<  HDR2 label to override the FOPEN FOPTIONS.  If  >>       <<02690>>15200000
  <<  the tape is a foreign tape, opening the file    >>       <<02690>>15205000
  <<  as Undefined means ignore the HDR2 label format >>       <<02690>>15210000
  <<  field.  Otherwise, return fixed for "F" and     >>       <<02690>>15215000
  <<  undefined for "V", "D" and "U". >>                       <<02690>>15220000
                                                               <<02690>>15225000
                                                               <<02690>>15230000
         IF LCB'HP THEN                                        <<06135>>15235000
            BEGIN                                              <<06135>>15240000
            IF (L2RFMT = "F") THEN FOPFTYPE := 0               <<06135>>15245000
            ELSE                                               <<06135>>15250000
               IF (L2RFMT = "V") OR (L2RFMT = "D") THEN        <<06135>>15255000
                  FOPFTYPE := 1                                <<06135>>15260000
               ELSE FOPFTYPE := 2;  << undefined >>            <<06135>>15265000
            END                                                <<06135>>15270000
         ELSE     << non-HP tape >>                            <<06135>>15275000
            FOPFTYPE :=                                        <<06135>>15280000
               IF (FOPFTYPE <> 2) AND L2RFMT = "F" THEN 0      <<06135>>15285000
                                                   ELSE 2;     <<06135>>15290000
         RECSIZE := BINARY'(L2RSIZE,5);     << bytes >>                 15295000
         BLKSIZE := BINARY'(L2BSIZE,5);     << bytes >>                 15300000
                                                               <<02690>>15305000
  <<  If the file is not an HP ANSI file and is being >>       <<02690>>15310000
  <<  accessed with undefined record format, then use >>       <<02690>>15315000
  <<  the BLOCKSIZE field for the record size. >>              <<02690>>15320000
                                                               <<02690>>15325000
         IF (FOPFTYPE = 2) AND NOT LCB'HP THEN                 <<02690>>15330000
            RECSIZE := BLKSIZE;                                <<02690>>15335000
                                                               <<02690>>15340000
         IF RECSIZE <> 0 THEN                                           15345000
            BEGIN                                                       15350000
                                                               <<02690>>15355000
<<   If the label shows carriage control, then we must     >>  <<02690>>15360000
<<   decrement RECSIZE by one since RBSIZE in FOPEN will   >>  <<02690>>15365000
<<   add one to RECSIZE for CCTL files.                    >>  <<02690>>15370000
                                                               <<02690>>15375000
            IF LCB'HP AND L2CCTL = "C" THEN                    <<02690>>15380000
               RECSIZE := RECSIZE - 1;                         <<02690>>15385000
                                                               <<02690>>15390000
            IF BLKSIZE <> 0 THEN BLKFACT := BLKSIZE/RECSIZE;            15395000
            IF LCB'B5000 THEN RECSIZE := RECSIZE*1;   << patch >>       15400000
            RSIZ := -RECSIZE;                                           15405000
            END;                                                        15410000
         IF LCB'HP THEN                                                 15415000
            BEGIN       << Process HP features in HDR2 >>               15420000
            IF L2FTYPE = "A" THEN FOPASCII := 1;                        15425000
            IF L2FTYPE = "B" THEN FOPASCII := 0;                        15430000
            IF L2CCTL = "C" THEN FOPCCTL := 1;                          15435000
            IF LCB'LOCKFLG AND                                          15440000
               VCB'LOCKWRD <> L2LOCK,(8) THEN ERREXIT(LBTLWERR);        15445000
            END;                                                        15450000
         END         << process HDR2 label >>                           15455000
      ELSE                                                              15460000
         ATTIOS(12);     << HDR2 label missing: BSR. >>                 15465000
      VCB'POSN := AH2;                                         <<02690>>15470000
      END;     << Read >>                                               15475000
   SCODE := GETSIR(TLTSIR);                                             15480000
   IF AOPACTYPE = READ                                         << 8277>>15485000
      THEN VCB'REEL := LCB'REEL << Set up proper reelswitch >> << 8277>>15490000
      ELSE LCB'REEL := 1;       << Reset reel set.          >> << 8277>>15495000
   VCB'ASCII := FOPASCII;                                               15500000
   VCB'FSEQ := LCB'FSEQ;                                                15505000
   IF VCB'VSETOPEN THEN                                        <<02563>>15510000
      BEGIN                                                    <<02563>>15515000
      VCB'VSETOPEN := 0;     << Done with VOL set open >>      <<02563>>15520000
      IF LCB'TAPE THEN SET'BOT'OFF; <<BOT off for labtape>>    <<03581>>15525000
      END;                                                     <<02563>>15530000
POSERR:                                                                 15535000
   POSTVTENT(VTBUF,VTADDR,-1);                                          15540000
   POSTVTENT(LTBUF,LTADDR,SCODE);    << save header lbl info >>         15545000
   END;     << procedure POSITION >>                                    15550000
$PAGE " CKFOREXDATE "                                                   15555000
LOGICAL PROCEDURE CKFOREXDATE(LDEV,ACCESS,LBLED);              <<06026>>15560000
 VALUE LDEV,ACCESS,LBLED;                                               15565000
 INTEGER LDEV,ACCESS; LOGICAL LBLED;                                    15570000
  OPTION UNCALLABLE;                                                    15575000
COMMENT                                                        <<04819>>15580000
                                                                        15585000
    Called from POSITION, REELSWITCH, and ASKOP in ALLOCATE,   <<06026>>15590000
this procedure determines whether the tape may be written.     <<04819>>15595000
Writing is allowed (CKFOREXDATE=FALSE) if the tape is          <<06026>>15600000
unlabelled, or labelled but is permitted by the operator.      <<06026>>15605000
DB at the stack.                                               <<04819>>15610000
   ACCESS - access mode as in AOPTIONS(12:4), 1 unless call    <<06026>>15615000
              from ASKOP.                                      <<04819>>15620000
   LBLED - 2 if the tape is labelled and we don't want to      <<04819>>15625000
           ask the operator for an expired tape (the Volids    <<04819>>15630000
           match).                                             <<04819>>15635000
                                                               <<04819>>15640000
           1 if the tape is supposed to be labelled            <<04819>>15645000
                 (per FOPTIONS)                                <<04819>>15650000
           0 if unlabelled (ASKOP call only).                  <<04819>>15655000
                                                                        15660000
;                                                              <<04819>>15665000
BEGIN                                                                   15670000
   LOGICAL RESULT=CKFOREXDATE;                                 <<06026>>15675000
   INTEGER LTADDR,SCODE,MSG'NUM;                               <<04819>>15680000
   LOGICAL ARRAY LTBUF(0:LTESIZE-1) =Q;                                 15685000
      BYTE ARRAY LTBUFB(*) = LTBUF;                            <<04819>>15690000
   INTEGER ARRAY BUFFER(0:39);                                          15695000
      BYTE ARRAY BBUF(*) = BUFFER;                                      15700000
   LOGICAL ARRAY REPLY(0:2) =Q;                                         15705000
   LOGICAL ARRAY MSG(0:3) = Q;                                 <<04819>>15710000
      BYTE ARRAY MSGB(*) = MSG;                                <<04819>>15715000
                                                                        15720000
 <<  Begin execution.  >>                                               15725000
                                                                        15730000
 RESULT := TRUE;      << default: no write. >>                 <<04819>>15735000
   LTADDR := GETLDEV(LDEV,LTBUF);                                       15740000
   IF < THEN TAPETROUBLE(TT25);                                <<03581>>15745000
                                                                        15750000
   IF LCB'LABTYP < 2 THEN                                      <<06026>>15755000
      RESULT := FALSE                                          <<06026>>15760000
   ELSE       << labelled tape >>                              <<06026>>15765000
      BEGIN                                                    <<04819>>15770000
      IF ACCESS = 1 AND NOT(LBLED=2 LAND CALENDAR>LCB'EXDATE)  <<04819>>15775000
        THEN BEGIN                                             <<04819>>15780000
        << Ask if it is OK to write on volume >>               <<04819>>15785000
        MOVE MSGB := LCB'VOLID,(6);                            <<04819>>15790000
        MSGB(6) := 0;  << GENMSG terminator >>                 <<04819>>15795000
        MSG'NUM := (IF CALENDAR > LCB'EXDATE                   <<04819>>15800000
           THEN 282 ELSE 291);                                 <<04901>>15805000
        GENMSG(1,MSG'NUM,%01000,@MSGB,LDEV,,,,0,1,@REPLY);     <<04819>>15810000
   <<291 OK to write on unexpired vol (!) on LDEV# \? (Y/N)>>  <<04819>>15815000
   <<282 OK to write on expired vol (!) on LDEV# \? (Y/N)>>    <<04901>>15820000
                                                               <<04819>>15825000
        IF REPLY                                               <<04819>>15830000
          THEN BEGIN                                           <<04819>>15835000
          LCB'EXDATE := 0;  << Set Expired >>                  <<04819>>15840000
          IF NOT LBLED                                         <<04819>>15845000
            THEN LCB'LABTYP := 1;                              <<04819>>15850000
          SCODE := GETSIR(TLTSIR);                             <<04819>>15855000
          POSTVTENT(LTBUF,LTADDR,SCODE);                       <<04819>>15860000
          RESULT := FALSE;                                     <<04819>>15865000
          END;                                                 <<04819>>15870000
        END                                                    <<04819>>15875000
      ELSE RESULT := FALSE;  << OK to write >>                 <<04819>>15880000
      END;    << labelled tape >>                                       15885000
OUT:    << For I/O errors >>                                   <<04819>>15890000
END;      << procedure CKFOREXDATE >>                          <<06026>>15895000
$PAGE " CKFORLDEV "                                                     15900000
LOGICAL PROCEDURE CKFORLDEV(LDEV);                             <<06026>>15905000
 VALUE LDEV;                                                   <<06026>>15910000
 INTEGER LDEV;                                                 <<06026>>15915000
 OPTION UNCALLABLE;                                            <<06026>>15920000
COMMENT                                                        <<06026>>15925000
                                                               <<06026>>15930000
    Called from LINKLABEL, REELSWITCH, and ASKOP in ALLOCATE,  <<06026>>15935000
this procedure determines if the LDEV on which the tape is to  <<06026>>15940000
be written is useable.  It's OK if CKFORLDEV=FALSE.            <<06026>>15945000
DB is at the stack.                                            <<06026>>15950000
;                                                              <<06026>>15955000
BEGIN                                                          <<06026>>15960000
   LOGICAL RESULT=CKFORLDEV;                                   <<06026>>15965000
   INTEGER LTADDR;                                             <<06026>>15970000
   LOGICAL ARRAY LTBUF(0:LTESIZE-1) =Q;                        <<06026>>15975000
      BYTE ARRAY LTBUFB(*) = LTBUF;                            <<06026>>15980000
                                                               <<06026>>15985000
 <<  Begin execution.  >>                                      <<06026>>15990000
                                                               <<06026>>15995000
 RESULT := TRUE;      << default: no write. >>                 <<06026>>16000000
 IF SETOWNED(LDEV,-1) <> 1 THEN                                <<06938>>16005000
   BEGIN             << LDEV is not owned or recognized >>     <<06026>>16010000
   LTADDR := GETLDEV(LDEV,LTBUF);                              <<06026>>16015000
   IF < THEN TAPETROUBLE(TT25);                                <<06026>>16020000
   IF LCB'LABTYP = 0 THEN      << no tape mounted >>           <<06026>>16025000
      BEGIN                                                    <<06026>>16030000
                                                               <<06026>>16035000
<< On the ALLOCATE call, there may be a tape that was          <<06026>>16040000
<< Ready when the system came up, so try AVR. >>               <<06026>>16045000
                                                               <<06026>>16050000
      IF LCB'TAPE THEN RECOGNIZE(LDEV)                         <<06026>>16055000
                  ELSE CC := CCL;                              <<06026>>16060000
      IF < THEN GO ERREXIT;       << I/O error. >>             <<06026>>16065000
      END;     << Tape is again at load point. >>              <<06026>>16070000
   END;                                                        <<06026>>16075000
   RESULT := FALSE;      << ldev is OK >>                      <<06026>>16080000
ERREXIT:                                                       <<06026>>16085000
END;        << procedure CKFORLDEV >>                          <<06026>>16090000
$PAGE " NEXTTAPEFILE "                                                  16095000
INTEGER PROCEDURE NEXTTAPEFILE(FNUM);                                   16100000
INTEGER FNUM;                                                           16105000
OPTION UNCALLABLE;                                                      16110000
                                                                        16115000
<< Used by Store-Restore to advance to the next file on a               16120000
labeled tape.  Returns 0, or error code and CCL if error.  >>           16125000
                                                                        16130000
   BEGIN                                                                16135000
   INTEGER VTADDR,LTADDR,SCODE;                                         16140000
   INTEGER LDEV,LTYPE,LOC'ACB'STAT;                            <<02703>>16145000
   LOGICAL ARRAY VTBUF(0:VTESIZE-1) =Q;                                 16150000
   LOGICAL ARRAY LTBUF(0:LTESIZE-1) =Q;                                 16155000
                                                                        16160000
<< Error subroutine >>                                                  16165000
                                                                        16170000
SUBROUTINE ERREXIT(ERRCODE);                                            16175000
VALUE ERRCODE; INTEGER ERRCODE;                                         16180000
   BEGIN                                                                16185000
   IF ERRCODE = LBTEOVSET THEN CC := CCG;                      <<02648>>16190000
   NEXTTAPEFILE := ERRCODE;   << report error >>                        16195000
   POST'ACB'ERROR(FNUM,LOC'ACB'STAT,ERRCODE);                  <<02703>>16200000
   GO POSERR;                                                           16205000
   END;                                                                 16210000
                                                                        16215000
SUBROUTINE ATTIOS(FUNC);                                       <<02662>>16220000
VALUE FUNC; INTEGER FUNC;                                               16225000
                                                                        16230000
   BEGIN                                                                16235000
   IF LDEV=0 THEN TAPETROUBLE(TT5);    << oops! >>             <<03581>>16240000
   TOS := ATTACHIO(LDEV,0,0,0,FUNC,0,0,4,%11);                 <<02689>>16245000
   DEL;                                                                 16250000
   IF S0.(13:3) > 2 THEN ERREXIT(LBTPOSERR);                            16255000
   X := TOS;                                                            16260000
   END;                                                                 16265000
                                                                        16270000
   CC := CCL;                                                           16275000
   VTADDR := GETFNUM(FNUM,VTBUF);                                       16280000
   IF < THEN TAPETROUBLE(TT52);                                <<03581>>16285000
   IF VCB'FLUSH THEN                                           <<02621>>16290000
      BEGIN          << device unavailable (=REPLY 0) >>       <<02621>>16295000
      ERREXIT(NAVAILDEV);                                      <<06333>>16300000
      END;                                                     <<02621>>16305000
   LDEV := VCB'LDEV;                                                    16310000
   LTADDR := GETLDEV(LDEV,LTBUF);                                       16315000
   IF < THEN TAPETROUBLE(TT53);                                <<03581>>16320000
   IF VCB'WRITE THEN                                                    16325000
      BEGIN        << STORE: terminate present file. >>                 16330000
      IF VCB'POSN > H1NX THEN                                  <<02622>>16335000
         BEGIN                                                 <<02622>>16340000
         IF VCB'POSN < DNX THEN ATTIOS(6);  << end hdrs >>     <<02662>>16345000
         IF WRITELAB(VTBUF,1) THEN ERREXIT(LBTPOSERR); << TM,EOF1&2 >>  16350000
         ATTIOS(6);        << WTM ending trlr lbls >>          <<02662>>16355000
         VCB'FSEQ := VCB'FSEQ+1;    << at next file >>         <<02622>>16360000
         END;                                                  <<02622>>16365000
      VCB'POSN := H1NX;                                        <<02622>>16370000
      LCB'FSEQ := VCB'FSEQ;                                    <<r7493>>16375000
      END                                                               16380000
   ELSE                                                                 16385000
      BEGIN       << RESTORE: advance tape to next file. >>             16390000
      IF VCB'POSN < DNX THEN ATTIOS(7);   << skip hdr lbls >>  <<02662>>16395000
SKIP:                                                                   16400000
      ATTIOS(7);               << FSF over data >>             <<02662>>16405000
      LTYPE := CHECK1(LTBUF);   << read EOF1/EOV1 >>                    16410000
      IF LTYPE = 2 THEN                                                 16415000
         BEGIN        << EOV found; need next reel. >>                  16420000
         ATTIOS(12);    << BSR over EOV1 >>                    <<02662>>16425000
         REELSWITCH(LDEV,IF VCB'POSN > DNX THEN 0 ELSE 2);              16430000
         IF < THEN ERREXIT(NAVAILDEV);    << never return... >><<06333>>16435000
         IF > THEN ERREXIT(LBTPOSERR);    << not EOV1?? >>              16440000
         GETXDSW(VTBUF,TLTDST,VTADDR,VTESIZE);                          16445000
         GETXDSW(LTBUF,TLTDST,LTADDR,LTESIZE);                          16450000
         VCB'RSWDONE := 1;                                     <<02690>>16455000
         GO SKIP;                                                       16460000
         END;                                                           16465000
      IF LTYPE <> 1 THEN ERREXIT(LBTFMTERR);   << should be EOF1. >>    16470000
      ATTIOS(7);         << FSF over trlr lbls >>              <<02662>>16475000
      VCB'REEL := 1;                                           <<02622>>16480000
      LTYPE := CHECK1(LTBUF);     << read TM/HDR1 >>                    16485000
      IF < THEN ERREXIT(LBTPOSERR);                                     16490000
      IF LTYPE > 0 THEN ERREXIT(LBTFMTERR);  << wasn't >>               16495000
      IF LTYPE < 0 THEN ERREXIT(LBTEOVSET);                             16500000
      ATTIOS(11);        << FSR over HDR2 label >>             <<02662>>16505000
      VCB'POSN := AH2;                                         <<02690>>16510000
      VCB'FSEQ := LCB'FSEQ;                                    <<02622>>16515000
      END;                                                              16520000
   CC := CCE;                                                           16525000
   SCODE := GETSIR(TLTSIR);                                             16530000
   POSTVTENT(VTBUF,VTADDR,-1);                                          16535000
   POSTVTENT(LTBUF,LTADDR,SCODE);    << save header lbl info >>         16540000
   FCONTROL(FNUM,5,FNUM);   << reset block xfer count >>                16545000
POSERR:                                                                 16550000
   END;        << procedure NEXTTAPEFILE >>                             16555000
$PAGE " LDIRECTF "                                                      16560000
LOGICAL PROCEDURE LDIRECTF(FNUM);                                       16565000
   VALUE FNUM; INTEGER FNUM;                                            16570000
 OPTION UNCALLABLE;                                                     16575000
                                                                        16580000
<< Called from FSTORE in STORE after writing a file to see              16585000
if a Reelswitch occurred somewhere in the middle of the file.           16590000
If so, FSTORE will write a directory file following the                 16595000
(partial) file just written on the new reel.  DB at the stack.  >>      16600000
                                                                        16605000
   BEGIN                                                                16610000
   INTEGER VTADDR,SCODE;                                                16615000
   LOGICAL ARRAY VTBUF(0:VTESIZE-1) =Q;                                 16620000
                                                                        16625000
   SCODE := GETSIR(TLTSIR);                                             16630000
   VTADDR := GETFNUM(FNUM,VTBUF);                                       16635000
   IF < THEN TAPETROUBLE(TT27);                                <<03581>>16640000
   LDIRECTF := VCB'WRITDIR;                                             16645000
   VCB'WRITDIR := 0;                                                    16650000
   POSTVTENT(VTBUF,VTADDR,SCODE);                                       16655000
   END;     << procedure LDIRECTF >>                                    16660000
$PAGE " LRELSW "                                                        16665000
LOGICAL PROCEDURE LRELSW(FNUM);                                <<0615>> 16670000
   VALUE FNUM; INTEGER FNUM;                                            16675000
 OPTION UNCALLABLE;                                                     16680000
                                                                        16685000
<< STORE/RESTORE: Check and reset Reelswitch Done bit. Callers:         16690000
  WRITETAPE for FSTORE. If Reelswitch, write header label.              16695000
  IRESTORE to set Store tape bit.                                       16700000
  READTAPE of FRESTORE. If Reelswitch, skip directory file.             16705000
DB at stack.  >>                                                        16710000
                                                                        16715000
   BEGIN                                                                16720000
   INTEGER VTADDR,SCODE;                                                16725000
   LOGICAL ARRAY VTBUF(0:VTESIZE-1) =Q;                                 16730000
                                                                        16735000
   SCODE := GETSIR(TLTSIR);                                             16740000
   VTADDR := GETFNUM(FNUM,VTBUF);                                       16745000
   IF < THEN TAPETROUBLE(TT29);                                <<03581>>16750000
   LRELSW := VCB'RSWDONE;                                               16755000
   VCB'RSWDONE := 0;                                                    16760000
   VCB'STORTAP := 1;                                                    16765000
   POSTVTENT(VTBUF,VTADDR,SCODE);                                       16770000
   END;        << procedure LRELSW >>                                   16775000
$PAGE " PVOLID "                                                        16780000
INTEGER PROCEDURE PVOLID(LDEV,BUF);                                     16785000
VALUE LDEV; INTEGER LDEV;                                               16790000
BYTE ARRAY BUF;                                                         16795000
OPTION UNCALLABLE;                                                      16800000
                                                                        16805000
<< Used by :SHOWDEV in OPCOMMAND to print Volume ID >>         <<07338>>16810000
<< and tape density (for variable density drives).  >>         <<02616>>16815000
                                                                        16820000
   BEGIN                                                                16825000
   LOGICAL ARRAY LTBUF(0:LTESIZE-1);                                    16830000
      BUILDLCB;                                                         16835000
   EQUATE                                                      <<02616>>16840000
      LABELPOS    = 6,   << Buffer rel. index for label type >><<02616>>16845000
      DENSITYPOS  = 14,  << Buffer rel. index for density >>   <<02616>>16850000
      VOLIDLEN    = 50,  << Total line len. including VOLID >> <<07338>>16855000
      DENSITYLEN  = 56;  << Total line len. including dens. >> <<07338>>16860000
   INTEGER                                                     <<02616>>16865000
      LPDT'INDEX,                                              <<06333>>16870000
      DENSITY;                                                 <<02616>>16875000
                                                                        16880000
   CC := CCL;                                                  <<02648>>16885000
   GETLDEV(LDEV,LTBUF);                                                 16890000
   IF < THEN RETURN;         << Not a tape. >>                          16895000
   CASE LCB'LABTYP OF                                                   16900000
      BEGIN                                                             16905000
      RETURN;                      << 0 >>                              16910000
      MOVE BUF := "(Nolabel)";     << 1 >>                     <<02616>>16915000
                                                               <<02616>>16920000
      BEGIN                        << 2 >>                     <<02616>>16925000
      MOVE BUF := LCB'VOLID,(6);                               <<02616>>16930000
      MOVE BUF(LABELPOS) := "(ANSI)";                          <<02616>>16935000
      END;                                                     <<02616>>16940000
                                                               <<02616>>16945000
      BEGIN                        << 3 >>                     <<02616>>16950000
      MOVE BUF := LCB'VOLID,(6);                               <<02616>>16955000
      MOVE BUF(LABELPOS) := "(IBM)";                           <<02616>>16960000
      END;                                                     <<02616>>16965000
                                                               <<02616>>16970000
      END;                                                              16975000
   PVOLID := VOLIDLEN;                                         <<02616>>16980000
   CC := CCE;   << A tape is mounted on drive. >>              <<02673>>16985000
                                                               <<02616>>16990000
<< If variable density drive, report tape density >>           <<02616>>16995000
                                                               <<02616>>17000000
   LPDT'INDEX := LDEV * SIZE'OF'LPDT'ENTRY;                    <<06333>>17005000
   IF (VARIABLE'DENSITY) THEN                                  <<02616>>17010000
      BEGIN                                                    <<02616>>17015000
      DENSITY := GET'DENSITY(LDEV);                            <<02616>>17020000
      IF DENSITY <= LDT'DENSITY'800 THEN                       <<07339>>17025000
         BEGIN                                                 <<02616>>17030000
         CASE DENSITY OF                                       <<02616>>17035000
            BEGIN                                              <<02616>>17040000
            RETURN;                          << 0 - Null >>    <<02616>>17045000
            MOVE BUF(DENSITYPOS) := "1600";  << 1 - DEN'1600 >><<02616>>17050000
            MOVE BUF(DENSITYPOS) := "6250";  << 2 - DEN'6250 >><<02616>>17055000
            MOVE BUF(DENSITYPOS) := "800";   << 3 - DEN7800  >><<07339>>17060000
            END;                                               <<02616>>17065000
         PVOLID := DENSITYLEN;                                 <<02616>>17070000
         END;   << of valid density >>                         <<02616>>17075000
      END;   << of variable density drive >>                   <<02616>>17080000
   END;         << procedure PVOLID >>                                  17085000
$PAGE " TGETINFO "                                                      17090000
PROCEDURE TGETINFO(LDEV,FBUF,ITEMNUM);                                  17095000
   VALUE LDEV,ITEMNUM; INTEGER LDEV,ITEMNUM;                            17100000
   ARRAY FBUF;                                                          17105000
   OPTION UNCALLABLE;                                                   17110000
                                                                        17115000
<< Called from FFILEINFO in FILEIO to report various tape label         17120000
info items to the user. >>                                              17125000
                                                                        17130000
   BEGIN                                                                17135000
   BYTE ARRAY FBUFB(*) = FBUF;                                          17140000
   LOGICAL LEGAL'CALL;                                         <<04612>>17145000
   LOGICAL ARRAY LTBUF(0:LTESIZE-1) =Q;                                 17150000
      BUILDLCB;                                                         17155000
                                                                        17160000
   LEGAL'CALL := TRUE;                                         <<04612>>17165000
   GETLDEV(LDEV,LTBUF);                                                 17170000
   IF < OR LCB'LABTYP < 2 THEN    << not labeled tape. >>      <<04612>>17175000
     LEGAL'CALL := FALSE;                                      <<04612>>17180000
   CASE ITEMNUM OF                                                      17185000
    BEGIN                                                               17190000
      BEGIN       << 00 Volume ID >>                                    17195000
      IF LEGAL'CALL THEN                                       <<04612>>17200000
        MOVE FBUFB := LCB'VOLID,(6)                            <<04612>>17205000
      ELSE MOVE FBUFB := "      ";                             <<04612>>17210000
      END;                                                              17215000
                                                                        17220000
      BEGIN      << 01 Volume Set ID >>                                 17225000
      IF LEGAL'CALL THEN                                       <<04612>>17230000
        MOVE FBUFB := LCB'VSETID,(6)                           <<04612>>17235000
      ELSE MOVE FBUFB := "      ";                             <<04612>>17240000
      END;                                                              17245000
                                                                        17250000
      BEGIN      << 02 Expiration date >>                               17255000
      FBUF := IF LEGAL'CALL THEN LCB'EXDATE ELSE -1;           <<04612>>17260000
      END;                                                              17265000
                                                                        17270000
      BEGIN      << 03 File seq number >>                               17275000
      FBUF := IF LEGAL'CALL THEN LCB'FSEQ ELSE -1;             <<04612>>17280000
      END;                                                              17285000
                                                                        17290000
      BEGIN      << 04 Reel number >>                                   17295000
      FBUF := IF LEGAL'CALL THEN LCB'REEL ELSE -1;             <<04612>>17300000
      END;                                                              17305000
                                                                        17310000
      BEGIN      << 05 Seq type >>                                      17315000
      FBUF := IF LEGAL'CALL THEN 0 ELSE -1;  << LCB'SEQTYP;  >><<04612>>17320000
      END;                                                              17325000
                                                                        17330000
      BEGIN      << 06 Creation date >>                                 17335000
      FBUF := IF LEGAL'CALL THEN LCB'CDATE ELSE -1;            <<04612>>17340000
      END;                                                              17345000
                                                                        17350000
      BEGIN      << 07 Label type >>                                    17355000
      FBUF := IF LEGAL'CALL THEN LCB'LABTYP ELSE -1;           <<04612>>17360000
      END;                                                              17365000
                                                                        17370000
      BEGIN      << 08 Tape file name >>                                17375000
      IF LEGAL'CALL THEN                                       <<04612>>17380000
        BEGIN                                                  <<04873>>17385000
        MOVE FBUFB := LCB'FNAME,(17);                          <<04873>>17390000
        END                                                    <<04873>>17395000
      ELSE                                                     <<04873>>17400000
        BEGIN                                                  <<04873>>17405000
        MOVE FBUFB := "                 ";                     <<04873>>17410000
        END;                                                   <<04873>>17415000
      END;                                                              17420000
                                                                        17425000
    END;                                                                17430000
    IF LEGAL'CALL THEN                                                  17435000
      CC := CCE                                                         17440000
    ELSE CC := CCL;                                                     17445000
   END;     << procedure TGETINFO >>                                    17450000
$PAGE " CLEANTAPE "                                                     17455000
PROCEDURE CLEANTAPE(PINNO);                                             17460000
VALUE PINNO; LOGICAL PINNO;                                             17465000
OPTION UNCALLABLE;                                                      17470000
                                                                        17475000
<< Called from Morgue at process termination, following call            17480000
to FPROCTERM.  Files which were closed to close volume but              17485000
not volume set will have volume entries remaining in the TLT            17490000
which we remove here.  FREEDEVICE is called to return associated        17495000
tape drives to the Available pool and rewind them.  >>                  17500000
                                                                        17505000
   BEGIN                                                                17510000
   LOGICAL VTADDR;                                                      17515000
   INTEGER LDEV,SCODE;                                                  17520000
   DOUBLE VTBOUNDS;                                                     17525000
      LOGICAL VTBASE = VTBOUNDS;                                        17530000
      LOGICAL VTTOP = VTBOUNDS+1;                                       17535000
   LOGICAL ARRAY VTBUF(0:VTESIZE-1) =Q;                                 17540000
      BUILDVCB;                                                         17545000
   LOGICAL WAIT := FALSE;                                      <<02673>>17550000
                                                                        17555000
   SCODE := GETSIR(TLTSIR);                                             17560000
   GETXDSW(VTBOUNDS,TLTDST,XVTBASE,2);                                  17565000
   VTADDR := VTBASE;                                                    17570000
   WHILE VTADDR < VTTOP DO                                              17575000
      BEGIN      << search Volume entries >>                            17580000
      GETXDSW(VTBUF,TLTDST,VTADDR,VTESIZE);                             17585000
      IF INUSE AND VCB'PIN=PINNO THEN                                   17590000
         BEGIN         << release Volume entry. >>                      17595000
         LDEV := VCB'LDEV;                                              17600000
         IF <> THEN                                                     17605000
            BEGIN      << release LDEV. >>                              17610000
            RELSIR(TLTSIR,SCODE);                                       17615000
            FREEDEVICE(LDEV,WAIT);                                      17620000
            IF NOT (TAPE'DEVICE)                               <<03634>>17625000
              THEN FORS'XDS'DEALLOC(LDEV);                     <<03634>>17630000
            SCODE := GETSIR(TLTSIR);                                    17635000
            CLEANLDEV(LDEV);                                            17640000
            END;                                                        17645000
         VTBUF := 0;                                                    17650000
         MOVE VTBUF(1) := VTBUF,(VTESIZE-1);                            17655000
         POSTVTENT(VTBUF,VTADDR,-1);                                    17660000
         END;                                                           17665000
      VTADDR := VTADDR+VTESIZE;                                         17670000
      END;                                                              17675000
   RELSIR(TLTSIR,SCODE);                                                17680000
   END;             << procedure CLEANTAPE >>                           17685000
$PAGE " OUTER BLOCK "                                                   17690000
$CONTROL SEGMENT=OUTERBLOCK                                             17695000
END.                                                                    17700000
