$CONTROL MAP,CODE,USLINIT                                               00010000
<< MEASIO - MODULE 88 >>                                                00012000
<< HP32033C MPE SOURCE C.00.00 >>                                       00014000
$COPYRIGHT     "(C) COPYRIGHT HEWLETT-PACKARD CO. 1980. ",            & 00016000
$     "THIS PROGRAM MAY BE USED WITH ONE COMPUTER SYSTEM AT A ",      & 00018000
$     "TIME AND SHALL NOT OTHERWISE BE RECORDED, TRANSMITTED OR ",    & 00020000
$     "STORED IN A RETRIEVAL SYSTEM.  COPYING OR OTHER REPRODUCTION ",& 00022000
$     "OF THIS PROGRAM EXCEPT FOR ARCHIVAL PURPOSES IS PROHIBITED ",  & 00024000
$     "WITHOUT THE PRIOR WRITTEN CONSENT OF HEWLETT-PACKARD COMPANY."   00026000
$CONTROL  LIST, SEGMENT=MIO'SEGMENT                                     00028000
                                                                        00030000
                                                                        00032000
<<**********************************************************************00034000
                                                                        00036000
             Measurement I/O System                                     00038000
                                                                        00040000
                                                                        00042000
                                                                        00044000
Declaration:                                                            00046000
                                                                        00048000
   INTEGER PROCEDURE MEASIO(LDEV,FCODE,BANK,ADDR,COUNT);                00050000
      VALUE LDEV, FCODE, BANK, ADDR, COUNT;                             00052000
      INTEGER LDEV, FCODE, BANK, ADDR, COUNT;                           00054000
      OPTION PRIVILEGED, UNCALLABLE, EXTERNAL;                          00056000
                                                                        00058000
                                                                        00060000
Function:                                                               00062000
                                                                        00064000
   MEASIO is a self contained, core resident I/O system used by         00066000
   various performance measurement subsystems (Monitor, Sampler,        00068000
   Tracer, etc.) to write data to magnetic tape.  Generally speak-      00070000
   ing, it is independent of, and unknown to MPE in order to min-       00072000
   imize the effects of the measurement subsystems on the system's      00074000
   operation.                                                           00076000
                                                                        00078000
                                                                        00080000
Parameters:                                                             00082000
                                                                        00084000
   LDEV     The logical device number of the tape drive.                00086000
                                                                        00088000
   FCODE    The function to be performed:                               00090000
                                                                        00092000
            0 -- Read Status                                            00094000
            1 -- Write Data                                             00096000
            2 -- Write File Mark                                        00098000
            3 -- Rewind                                                 00100000
            4 -- Rewind/unload                                          00102000
                                                                        00104000
   BANK     The bank number of the data to be written.                  00106000
                                                                        00108000
   ADDR     The absolute address of the data to be written.             00110000
                                                                        00112000
   COUNT    The amount of data to be written:                           00114000
            >0 => Word count     <0 => Byte count                       00116000
            The maximum count allowed is 16383 words or 32766 bytes.    00118000
                                                                        00120000
                                                                        00122000
Condition Codes and Returned Values:                                    00124000
                                                                        00126000
   CCE      Condition code CCE indicates that the previous request      00128000
            (if any) has been completed successfully and the cur-       00130000
            rent request has been started.  The returned value will     00132000
            be zero for all functions except Read Status which will     00134000
            return the following information obtained from the hard-    00136000
            ware status word:                                           00138000
                                                                        00140000
             Bits     Meaning                                           00142000
                                                                        00144000
            (0:12) -- Not Used                                          00146000
            (12:1) -- End of Tape (EOT)                                 00148000
            (13:1) -- Write Protect                                     00150000
            (14:1) -- Ready (On Line)                                   00152000
            (15:1) -- Load Point (BOT)                                  00154000
                                                                        00156000
   CCG      Condition code CCG is identical to CCE except that it       00158000
            also indicates that the tape's EOT reflective spot has      00160000
            been passed.                                                00162000
                                                                        00164000
   CCL      Condition code CCL indicates that an error has occured.     00166000
            The returned value indicates the type of error:             00168000
                                                                        00170000
            1 -- LDEV is invalid or not enabled.                        00172000
            2 -- FCODE is invalid or COUNT is too large.                00174000
            3 -- An irrecoverable error has occured.                    00176000
            4 -- FCODE is something other than Read Status but the      00178000
                 tape drive is not ready.                               00180000
            5 -- FCODE is Write Data or Write File Mark but there       00182000
                 is no write ring.                                      00184000
                                                                        00186000
            Error codes 1 and 2 indicate an invalid parameter; the      00188000
            status of the previous request has not been checked         00190000
            and the current request is rejected.  Error code 3          00192000
            indicates that an irrecoverable error has occured on a      00194000
            previous request; the current request was not started.      00196000
            Once an irrecoverable error has occured, the only fun-      00198000
            tions that will be accepted are Read Status and Rewind      00200000
            unload.  A successful Rewind & Reset request will clear     00202000
            the irrecoverable error.  A new tape should be mounted      00204000
            and the drive made ready.  Error codes 4 and 5 indicate     00206000
            that the previous request has been completed successfully   00208000
            but the current request was not started.                    00210000
                                                                        00212000
                                                                        00214000
Comments:                                                               00216000
                                                                        00218000
   MEASIO must be called with DB set to SYSDB.                          00220000
                                                                        00222000
   For Write Data requests, it is the caller's responsibility to        00224000
   freeze the data.  The data must not be altered or unfrozen           00226000
   until a subsequent request indicates that the I/O has been           00228000
   completed successfully or an irrecoverable error has occured.        00230000
                                                                        00232000
   MEASIO requires the exclusive use of the specified tape drive        00234000
   and its controller.  In order to avoid conflicts with MPE, it        00236000
   must be enabled with a console command that puts all drives on       00238000
   the controller (including MEASIO's drive) in the DOWN state and      00240000
   properly initializes the DRT, DIT, and SIO Program area.  An-        00242000
   other console command is used to disable MEASIO and reset the        00244000
   tables for normal MPE operation.                                     00246000
                                                                        00248000
   Since Read Status requests require running an SIO program, they      00250000
   should not be issued capriciously.  In most applications, the        00252000
   status is only checked before the first I/O request and after        00254000
   a new tape is mounted.                                               00256000
                                                                        00258000
   For a variety of performance related reasons, it is preferable       00260000
   to call MEASIO with the interrupt system enabled.  It may, how-      00262000
   ever, be called with the interrupt system enabled or disabled.       00264000
   MEASIO will not enable the interrupt system if it was called         00266000
   while the system was disabled.                                       00268000
                                                                        00270000
NOTE:  If MEASIO is called from an interrupt processor, the inter-      00272000
   rupt system should be disabled.  Otherwise, MEASIO could loop,       00274000
   waiting for an interrupt, at a time when the interrupt priority      00276000
   poll prevents the tape controller from interrupting.                 00278000
                                                                        00280000
**********************************************************************>>00282000
$PAGE "     MEASUREMENT I/O SYSTEM -- OPERATION ON THE SERIES 33"       00284000
<<**********************************************************************00286000
                                                                        00288000
             Operation on the Series 33                                 00290000
                                                                        00292000
                                                                        00294000
                                                                        00296000
   MEASIO uses a portion of its tape drive's DIT and SIO Program        00298000
   area for global data; the words used, their significance, and        00300000
   their initial values are:                                            00302000
                                                                        00304000
   MIO'ENABLE  DIT(8)   A flag word containing "OK" (%47513) to         00306000
                        indicate that MEASIO is enabled for some        00308000
                        unit on this controller.                        00310000
                                                                        00312000
   MIO'STATE   DIT(9)   Current device state:                           00314000
                       -1 -- Irrecoverable Error                        00316000
                        0 -- No Activity                                00318000
                        1 -- I/O in Progress                            00320000
                        2 -- Backspace Record for Retry                 00322000
                        3 -- Tape Gap for Retry                         00324000
                        4 -- Wait for Rewind Completion                 00326000
                        Initialized to zero.                            00328000
                                                                        00330000
   MIO'RETRY   DIT(10)  Number of retries for this request.             00332000
                        Initialized to zero.                            00334000
                                                                        00336000
   MIO'LDEV    SIO(75).(0:4)  DOWNed unit flags.                        00338000
                      .(8:8)  The logical device number that            00340000
                              has been enabled for MEASIO.              00342000
                                                                        00344000
   MIO'UNIT    SIO(95)  The Unit Number + 1 of the MEASIO tape          00346000
                                                                        00348000
   MIO'STATUS  SIO(99)  Last known hardware status.                     00350000
                        Initialized to zero.                            00352000
                                                                        00354000
   MIO'FCODE   SIO(101) /                                               00356000
                        |                                               00358000
   MIO'BANK    SIO(102) |  Saved parameters for retry.                  00360000
                        |                                               00362000
   MIO'ADDR    SIO(103) |  Uninitialized.                               00364000
                        |                                               00366000
   MIO'COUNT   SIO(104) \                                               00368000
                                                                        00370000
                                                                        00372000
   In addition to MEASIO, the measurement I/O system includes five      00374000
   supporting procedures:                                               00376000
                                                                        00378000
   MIO'INITIATOR -- This procedure builds and starts the necessary      00380000
                    SIO programs and updates MIO'STATE.                 00382000
                                                                        00384000
   MIO'COMPLETOR -- This procedure checks the I/O completion status     00386000
                    and updates MIO'STATE.  If necessary, it calls      00388000
                    MIO'INITIATOR to start a retry.                     00390000
                                                                        00392000
   MIO'INTRPT'PROC -- This is the interrupt processor.  When an in-     00394000
                      terrupt is received from the MEASIO tape con-     00396000
                      troller, it saves the hardware status and         00398000
                      calls MIO'COMPLETOR.                              00400000
                                                                        00402000
   MIO'INIT -- This procedure initializes the DRT, DIT, and SIO         00404000
               program area as required by the 3000 Series 33           00406000
               Measurement I/O system.  This procedure also halts the   00408000
               mag tape's Idle Channel Program.                         00410000
                                                                        00412000
   MIO'RESET -- This procedure resets the DRT, DIT, and SIO program     00414000
                area for normal use by the Series 33 I/O system and     00416000
                it starts an Idle Channel Program for the mag tape      00418000
                driver.                                                 00420000
                                                                        00422000
                                                                        00424000
   Each time MEASIO is called, it verifies that the logical device      00426000
   is valid and enabled and that the function is valid.  It then        00428000
   checks the previous request and waits for completion.  If MEASIO     00430000
   was called with the interrupt system enabled, the wait loop is       00432000
   simply a test of MIO'STATE; otherwise, the wait loop checks the      00434000
   DRT to test for SIO Ready, followed by a call to MIO'COMPLETOR.      00436000
                                                                        00438000
   After waiting for the completion of any previous request, MEASIO     00440000
   disables the interrupt system in order to prevent any recursive      00442000
   calls while the current request is being processed.  If the cur-     00444000
   rent request is Read Status, the hardware status is read and re-     00446000
   turned to the caller.  Otherwise, the previous request is check-     00448000
   ed for an irrecoverable error.  If there has been no error,          00450000
   MEASIO verifies the unit ready and write enable status and calls     00452000
   MIO'INITIATOR to start the current request.                          00454000
                                                                        00456000
                                                                        00458000
7970E HP-IB Mag Tape Controller Status                                  00460000
                                                                        00462000
  Bits       Meaning                                                    00464000
                                                                        00466000
    0    End of File                                                    00468000
                                                                        00470000
    1    Beginning of Tape                                              00472000
    2    End of Tape                                                    00474000
    3    Single Track Error                                             00476000
                                                                        00478000
    4    Command Reject                                                 00480000
    5    File Protect                                                   00482000
    6    Multiple Track Error                                           00484000
                                                                        00486000
    7    Unit Online                                                    00488000
    8    (not used)                                                     00490000
    9    Unit number (MSB)                                              00492000
                                                                        00494000
   10    Unit number (LSB)                                              00496000
   11    Timing Error                                                   00498000
   12    Tape Error                                                     00500000
                                                                        00502000
   13    Rewinding                                                      00504000
   14    Unit Busy                                                      00506000
   15    Interface Busy                                                 00508000
                                                                        00510000
**********************************************************************>>00512000
$PAGE "     MEASUREMENT I/O SYSTEM -- CHANNEL PROGRAM"                  00514000
<<*************************************************************<<04118>>00516000
*                                                             *<<04118>>00518000
*                                                             *<<04118>>00520000
***************************************************************<<04118>>00522000
<<                                                                      00524000
                 7970E HP-IB Channel Program                            00526000
                                                                        00528000
The following is a listing of the 3000 Series 33 Mag Tape Driver        00530000
Channel Program for the 7970E HP-IB Magnetic Tape.  If any changes      00532000
are made to the mag tape driver's channel program, appropriate          00534000
changes must be made to the MEASIO procedures.  The comments shown      00536000
are for the MEASIO usage of the Channel Program.                        00538000
                                                                        00540000
                                                                        00542000
( 0)  WRITE COMMAND     %2001,   Select Unit Command                    00544000
( 1)                        1,                                          00546000
( 2)                        0,                                          00548000
( 3)                   %42000,                                          00550000
( 4)                        0,                                          00552000
                                                                        00554000
( 5)  WAIT              %1000,   Wait for Command Completion            00556000
( 6)                        0,                                          00558000
                                                                        00560000
( 7)  DSJ               %2401,   Check Mag Tape's Condition             00562000
( 8)                        0,                                          00564000
( 9)  DSJ'CMDJMP            0,   JMP*+0/50, MIN CMD/RD XFER CNT         00566000
(10)                       43,   JMP *+43, Read Status                  00568000
                                                                        00570000
(11)  WRITE COMMAND     %2001,   Issue Motion Command                   00572000
(12)                        1,                                          00574000
(13)                        0,                                          00576000
(14)                   %42000,                                          00578000
(15)                        0,                                          00580000
                                                                        00582000
(16)  WAIT              %1000,   Wait for Command Completion            00584000
(17)                        0,                                          00586000
                                                                        00588000
(18)  DSJ               %2401,   Check Mag Tape's Condition             00590000
(19)                        0,                                          00592000
(20)                        0,   JMP*+0/25, RD/WRT DATA BYPASS          00594000
(21)                       32,   JMP *+32, Read Status                  00596000
                                                                        00598000
(22)  READ/WRITE DATA     %20,   Read/Write Record Command              00600000
(23)  BYTECNT               0,                                          00602000
(24)  TDBL              %2000,   TERMINATION DISP. *+4                  00604000
(25)  MEMX            %000000,   RECORD MODE                            00606000
(26)  BADDR                 0,                                          00608000
(27)  JUMP                  0,   EOI RECEIVED - XFER COMPLETED          00610000
(28)  EOI'JMP               2,     JMP *+2/12, READ/WRITE COMPLETION    00612000
(29)  JMP                   0,   Burst Completion Exit                  00614000
(30)                      -15,     JMP *-15 TO WAIT INSTRUCTION         00616000
(31)  WRITE END         %2007,   ISSUE STOP POLLING FOR DATA            00618000
                                                                        00620000
(32)                        1,                                          00622000
(33)                        0,                                          00624000
                                                                        00626000
(34)                   %42000,                                          00628000
(35)                        0,                                          00630000
                                                                        00632000
(36)  READ COUNT        %1402,   READ TRANSFER COUNT TO                 00634000
(37)                        2,   PROVIDED DELAY NEEDED                  00636000
(38)                        0,   FOR READS - KLUDGE                     00638000
(39)                    %2000,                                          00640000
(40)                        0,                                          00642000
                                                                        00644000
(41)  WAIT              %1000,   WAIT FOR OPERATION COMPLETION          00646000
(42)                        0,                                          00648000
(43)  DSJ               %2401,   CHECK MAG TAPE'S CONDITION             00650000
(44)                        0,                                          00652000
(45)                        0,   JMP *+0, UNIT OK                       00654000
                                                                        00656000
(46)                        7,   JMP *+7, READ STATUS                   00658000
(47)  READ STATUS       %1401,   READ STATUS BYTE                       00660000
                                                                        00662000
(48)                        3,                                          00664000
(49)                        0,                                          00666000
(50)                    %2000,                                          00668000
(51)                        0,                                          00670000
                                                                        00672000
(52)  INT/HLT            %601,   INTERUPT/HALT, HALT CODE =0            00674000
(53)                        0,   STATUS CHECK NOT REQUIRED              00676000
(54)  READ STATUS       %1401,   READ STATUS BYTES                      00678000
(55)                        3,                                          00680000
(56)                        0,                                          00682000
                                                                        00684000
(57)                    %2000,                                          00686000
(58)                        0,                                          00688000
                                                                        00690000
(59)  INT/HLT            %601,   INTERUPT/HALT, HALT CODE =1            00692000
(60)                        1,   STATUS CHECK REQUIRED                  00694000
(61)  READ COUNT        %1402,   READ TRANSFER COUNT                    00696000
(62)                        2,                                          00698000
(63)                        0,                                          00700000
                                                                        00702000
(64)  MEMX'RC           %2000,                                          00704000
(65)                        0,                                          00706000
                                                                        00708000
(66)  JMP                   0,   JUMP BACK TO DSJ INSTRUCTION           00710000
(67)                      -25,                                          00712000
(68)  WRITE END         %2007,   ISSUE END COMMAND                      00714000
(69)                        1,   IDLE CHANNEL PROGRAM                   00716000
(70)                        0,                                          00718000
                                                                        00720000
(71)                   %42000,                                          00722000
(72)                        0,                                          00724000
                                                                        00726000
                                                                        00728000
                                                                        00730000
(73)  WAIT              %1000,   WAIT FOR MT TO POLL                    00732000
(74)                        0,                                          00734000
(75)  DSJ               %2400,   CLEAR ANY PENDING DSJ'S                00736000
(76)                        0,                                          00738000
(77)                        0,                                          00740000
                                                                        00742000
(78)  READ STATUS       %1401,   READ STATUS TO ILT                     00744000
(79)                        3,                                          00746000
                                                                        00748000
(80)                        0,                                          00750000
(81)                    %2000,                                          00752000
(82)                        0,                                          00754000
                                                                        00756000
(83)  INT/HLT            %601,   INTERUPT/HALT, HALT CODE =0            00758000
(84)                        0,                                          00760000
(85)  WRITE END         %2007,   ISSUE END COMMAND                      00762000
(86)                        1,                                          00764000
(87)                        0,                                          00766000
                                                                        00768000
(88)                   %42000,                                          00770000
(89)                        0,                                          00772000
                                                                        00774000
                                                                        00776000
(90)  DSJ               %2400,   CLEAR ANY PENDING DSJ'S                00778000
(91)                        0,                                          00780000
(92)                        0,                                          00782000
(93)  INT/HLT            %601,                                          00784000
(94)                        0,                                          00786000
(95)  STORAGE(SCLTUNIT)     0,   SELECT COMMAND UNIT NUMBER             00788000
(96)  CMDWORD               0,   MOTION COMMAND WORD                    00790000
(97)                      %23,   STOP POLLING FOR DATA COMMAND          00792000
(98)                      %25,   END COMMAND                            00794000
(99)                        0,   STATUS BUFFER AREA                     00796000
(100)                       0,                                          00798000
(101)                       0,   6 BYTE SHORT READ BUFFER               00800000
(102)                       0,                                          00802000
(103)                       0,                                          00804000
(104)                       0,   DUMMY BUFFER                           00806000
(105)                     %63;   ABORT END COMMAND                      00808000
                                                                        00810000
***************************************************************<<04118>>00812000
*************************************************************>><<04118>>00814000
$PAGE "     MEASUREMENT I/O SYSTEM -- MEASIO"                           00816000
BEGIN                                                                   00818000
    << MEASIO GLOBAL EQUATES AND DEFINES >>                             00820000
                                                                        00822000
EQUATE                                                                  00824000
  CCG         =     0,  << GREATER THAN CONDITION CODE >>               00826000
  CCL         =     1,  << LESS THAN CODITION CODE >>                   00828000
  CCE         =     2,  << EQUALS CONDITION CODE >>                     00830000
  CMDWORD     =    96,   << SIOP, MOTION COMMAND WORD >>       <<04118>>00832000
  DILTP       =     5,  << DIT, INTERRUPT LINKAGE TABLE POINTER >>      00834000
  DLDEV       =     3,  << DIT, CONTAINS CONTROLLER UNIT NUMBER >>      00836000
  DRTSIZE     =     4,  << LENGTH OF DRT ENTRY >>                       00838000
  DSJ'CMDJMP  =     9,  << SIO, COMMAND SWITCH >>                       00840000
  DSJ'RWJMP   =    20,  << SIO, WRITE DATA BYPASS SWITCH >>             00842000
  ICNTRL      =     7,  << ILT, CONTAINS DRT NUMBER IN BITS 8:8 >>      00844000
  IDITP0      =    14,  << ILT, POINTER TO DIT 0 >>                     00846000
  IFLAG       =    13,  << ILT, FLAG WORD >>                            00848000
  ISIOP       =     8,  << ILT, CHANNEL PROGRAM AREA POINTER >>         00850000
  LR          =    17,   << STORAGE FOR INTERRUPT INTERVAL >>  <<01185>>00852000
  SYSDB       = %1000,  << LOCATION OF SYSDB >>                         00854000
ENDEQ         =     0;                                                  00856000
                                                                        00858000
                                                                        00860000
DEFINE                                                                  00862000
  ASMB        = ASSEMBLE#,                                              00864000
  DISABLE     = ASMB(SED 1)#,                                           00866000
  IDRTN       = ( 7:9)#,   << 9 BIT DRT NUMBER IN ILT >>       <<04850>>00868000
  ENABLE      = ASMB(SED 0)#,                                           00870000
  SIOPG       = CON %20302;CON 0#,                                      00872000
  CC          = STATUS.(6:2)#,                                 <<01185>>00874000
  IGNOREHI    = ( 2:1)#,   << ILT, IGNORE INTERRUPT FLAG >>             00876000
  EOT         = ( 2:1)#,   << END OF TAPE STATUS BIT >>                 00878000
  FILEPRTCT   = ( 5:1)#,   << FILE PROTECT STATUS BIT >>                00880000
  LDPOINT     = ( 1:1)#,   << LOAD POINT STATUS BIT >>                  00882000
  ONLINE      = ( 7:1)#,   << ONLINE STATUS BIT >>                      00884000
  UNIT'FIELD  = ( 2:6)#,   << UNIT FIELD IN DIT >>             <<01430>>00886000
  LMIO'STATUS = LOGICAL(SIOP(99))#,                            <<04118>>00888000
  MIO'ADDR    = SIOP(103)#,<< STORAGE OF USER BUFFER ADDRESS >><<04118>>00890000
  MIO'BANK    = SIOP(102)#,<< STORAGE OF USER BANK ADDRESS >>  <<04118>>00892000
  MIO'COUNT   = SIOP(104)#,<< STORAGE OF BUFFER LENGTH >>      <<04118>>00894000
  MIO'ENABLE  = DITP(8)#,  << MEASIO FLAG WORD >>                       00896000
  MIO'FCODE   = SIOP(101)#,<< FUNCTION REQUEST CODE >>         <<04118>>00898000
  MIO'LDEV    = SIOP(65)#, << LOGICAL DEVICE NUMBER >>         <<04118>>00900000
  MIO'RETRY   = DITP(10)#, << RETRY COUNTER >>                          00902000
  MIO'STATE   = DITP(9)#,  << CURRENT PROCESS STATE >>                  00904000
  MIO'STATUS  = SIOP(99)#, << CURRENT MAG TAPE STATUS >>       <<04118>>00906000
  MIO'UNIT    = SIOP(95)#, << MAG TAPE UNIT NUMBER PLUS ONE >> <<04118>>00908000
  ABS         = ABSOLUTE#,                                     <<01185>>00910000
  TRAPOFF     = PUSH(STATUS);                                  <<01185>>00912000
                TOS.(2:1) := 0;                                <<01185>>00914000
                SET(STATUS)#,                                  <<01185>>00916000
  PDISABLE    = ASMB(PSDB)#,                                   <<01185>>00918000
  PENABLE     = ASMB(PSEB)#,                                   <<01185>>00920000
  WAITPROG    = ( 1:1)#,   << WAIT PGM RUNNING FLAG IN ILT >>  <<04850>>00922000
ENDDEF        = 0#;                                                     00924000
                                                                        00926000
  INTEGER STATUS=Q-1, S0=S-0, X=X;                             <<01185>>00928000
  INTEGER POINTER CSTI=1, DSTI=2, LPDT=DB+%10;                 <<01185>>00930000
$PAGE                                                                   00932000
     << PROCEDURE DECLARATIONS >>                                       00934000
                                                               <<04850>>00936000
PROCEDURE AWAKEIO(DITP,FLAGS);                                 <<04850>>00938000
  VALUE FLAGS;                                                 <<04850>>00940000
  ARRAY DITP;                                                  <<04850>>00942000
  LOGICAL FLAGS;                                               <<04850>>00944000
  OPTION EXTERNAL;                                             <<04850>>00946000
                                                                        00948000
                                                               <<04850>>00950000
INTEGER PROCEDURE GETDRT(DRTN,OFFSET);                         <<04850>>00952000
  VALUE DRTN,OFFSET;                                           <<04850>>00954000
  INTEGER DRTN,OFFSET;                                         <<04850>>00956000
  OPTION EXTERNAL;                                             <<04850>>00958000
                                                                        00960000
PROCEDURE MIO'INITIATOR(DRT,DITP,SIOP,FCODE,BANK,ADDR,COUNT);           00962000
  VALUE  DRT, DITP, SIOP, FCODE, BANK, ADDR, COUNT;                     00964000
  INTEGER  DRT, FCODE, BANK, ADDR, COUNT;                               00966000
  INTEGER POINTER  DITP, SIOP;                                          00968000
  OPTION  FORWARD;                                                      00970000
                                                                        00972000
PROCEDURE MIO'COMPLETOR(DRT,DITP,SIOP);                                 00974000
  VALUE  DRT, DITP, SIOP;                                               00976000
  INTEGER  DRT;                                                         00978000
  INTEGER POINTER  DITP, SIOP;                                          00980000
  OPTION  FORWARD;                                                      00982000
                                                                        00984000
PROCEDURE MIO'INTRPT'PROC;                                              00986000
  OPTION  FORWARD;                                                      00988000
                                                                        00990000
PROCEDURE MIO'INIT(LDEV);                                               00992000
  VALUE  LDEV;                                                          00994000
  INTEGER  LDEV;                                                        00996000
  OPTION  FORWARD;                                                      00998000
                                                                        01000000
INTEGER PROCEDURE MIO'RESET(LDEV);                                      01002000
  VALUE  LDEV;                                                          01004000
  INTEGER  LDEV;                                                        01006000
  OPTION  FORWARD;                                                      01008000
                                                                        01010000
PROCEDURE GIP'HPIB;                                            <<01301>>01012000
  OPTION  PRIVILEGED, UNCALLABLE, EXTERNAL;                             01014000
                                                                        01016000
PROCEDURE IOFAILURE(DRT,DITP);                                          01018000
  VALUE  DRT, DITP;                                                     01020000
  INTEGER  DRT;                                                         01022000
  INTEGER POINTER  DITP;                                                01024000
  OPTION  PRIVILEGED, UNCALLABLE, EXTERNAL;                             01026000
                                                                        01028000
PROCEDURE PUTDRT(DRTN,OFFSET,DTA);                             <<04850>>01030000
  VALUE DRTN,OFFSET,DTA;                                       <<04850>>01032000
  INTEGER DRTN,OFFSET;                                         <<04850>>01034000
  LOGICAL DTA;                                                 <<04850>>01036000
  OPTION EXTERNAL;                                             <<04850>>01038000
                                                               <<04850>>01040000
PROCEDURE START'HPIB(DITP,SIOP,QFLAG);                         <<01301>>01042000
  VALUE  DITP, SIOP, QFLAG;                                             01044000
  LOGICAL  QFLAG;                                                       01046000
  INTEGER POINTER  DITP, SIOP;                                          01048000
  OPTION  PRIVILEGED, UNCALLABLE, EXTERNAL;                             01050000
                                                                        01052000
PROCEDURE HALT'HPIB(DITP);                                     <<01301>>01054000
  VALUE  DITP;                                                          01056000
  INTEGER POINTER  DITP;                                                01058000
  OPTION  PRIVILEGED, UNCALLABLE, EXTERNAL;                             01060000
                                                               <<04850>>01062000
PROCEDURE WIOC'HPIB(CMD,CHANNEL,DEVICE);                       <<04850>>01064000
VALUE CMD,CHANNEL,DEVICE;                                      <<04850>>01066000
INTEGER CMD,CHANNEL,DEVICE;                                    <<04850>>01068000
OPTION EXTERNAL;                                               <<04850>>01070000
$PAGE                                                          <<04850>>01072000
<< This procedure gets DRT into a known state >>               <<04850>>01074000
procedure QUIESCE'DRT(DRT);                                    <<04850>>01076000
value DRT;                                                     <<04850>>01078000
integer DRT;                                                   <<04850>>01080000
option internal,privileged;                                    <<04850>>01082000
begin                                                          <<04850>>01084000
                                                               <<04850>>01086000
DISABLE;                                                       <<04850>>01088000
<< First, kill the channel program (if any) >>                 <<04850>>01090000
tos := DRT;                                                    <<04850>>01092000
assemble(con %20302;con %1);  << HIOP instruction >>           <<04850>>01094000
                                                               <<04850>>01096000
<< Loop until it actually stops >>                             <<04850>>01098000
Loop:                                                          <<04850>>01100000
                                                               <<04850>>01102000
if GETDRT(DRT,3) <> 0 then                                     <<04850>>01104000
  go to Loop;                                                  <<04850>>01106000
                                                               <<04850>>01108000
<< Clear any pending interrupts on device >>                   <<04850>>01110000
tos := %006000;   << Write register "C" on GIC >>              <<04850>>01112000
tos := DRT;                                                    <<04850>>01114000
tos := logical(DRT) land %7;  << Device number >>              <<04850>>01116000
WIOC'HPIB(*,*,*);   << issue command >>                        <<04850>>01118000
                                                               <<04850>>01120000
end;                                                           <<04850>>01122000
$PAGE                                                                   01124000
INTEGER PROCEDURE MEASIO(LDEV,FCODE,BANK,ADDR,COUNT);                   01126000
  VALUE  LDEV, FCODE, BANK, ADDR, COUNT;                                01128000
  INTEGER  LDEV, FCODE, BANK, ADDR, COUNT;                              01130000
  OPTION  PRIVILEGED, UNCALLABLE;                                       01132000
BEGIN                                                                   01134000
                                                                        01136000
  INTEGER  RTNSTAT=Q-1;                                                 01138000
  INTEGER CPU'NUMBER, DRT, S0=S-0;                             <<04850>>01140000
  DOUBLE COUNTER,OLDDB;                                        <<04850>>01142000
  INTEGER POINTER  DITP, SIOP, ILTP;                                    01144000
  DEFINE  INTRPTS'ENABLED = LOGICAL(TOS.(1:1))#;                        01146000
  EQUATE  MAXCOUNT = 32766;                                             01148000
                                                                        01150000
                                                                        01152000
                                                                        01154000
  SUBROUTINE WAIT'FOR'IO;                                               01156000
    BEGIN                                                               01158000
      WHILE MIO'STATE>0 DO                                              01160000
        BEGIN                                                           01162000
          PUSH(STATUS);                                                 01164000
          IF INTRPTS'ENABLED THEN   << SIT TIGHT >>                     01166000
          ELSE                                                          01168000
            BEGIN                                                       01170000
                                                               <<04850>>01172000
              TOS := GETDRT(DRT,3);  << GET 4TH WORD OF DRT >> <<04850>>01174000
                                                               <<04850>>01176000
              IF TOS.(0:2)=0 THEN   << I/O PROGRAM COMPLETED >>         01178000
                MIO'COMPLETOR(DRT,DITP,SIOP);  << CALL COMPLETOR >>     01180000
            END;                                                        01182000
        END;                                                            01184000
    END;                                                                01186000
                                                                        01188000
                                                                        01190000
                                                                        01192000
     << PROCEDURE ENTRY POINT >>                                        01194000
                                                               <<04850>>01196000
  << SET DB TO SYSDB >>                                        <<04850>>01198000
  PDISABLE;                                                    <<04850>>01200000
  TOS := 0;                                                    <<04850>>01202000
  TOS := SYSDB;                                                <<04850>>01204000
  ASMB(XCHD);                                                  <<04850>>01206000
  OLDDB := TOS;                                                <<04850>>01208000
                                                                        01210000
  IF NOT (1 <= LDEV <= LPDT.(0:8)) THEN   << BAD LDEV >>                01212000
BAD'LDEV:                                                               01214000
    BEGIN                                                               01216000
      MEASIO := 1;   << RETURN INVALID LDEV INDICATOR >>                01218000
BAD'EXIT:                                                               01220000
      TOS := OLDDB;                                            <<04850>>01222000
      ASMB(XCHD);                                              <<04850>>01224000
      PENABLE;                                                 <<04850>>01226000
      CC := CCL;    << SET RETURN CONDITION CODE TO FAILURE >> <<01185>>01228000
      RETURN;                                                           01230000
    END;                                                                01232000
                                                                        01234000
  @DITP := LPDT(LDEV&LSL(1));   << SETUP DIT POINTER >>                 01236000
  IF < THEN GOTO BAD'LDEV;                                              01238000
                                                                        01240000
  @ILTP := DITP(DILTP);    << SETUP ILT POINTER >>                      01242000
  @SIOP := ILTP(ISIOP);    << SETUP SIO POINTER >>                      01244000
                                                                        01246000
  IF MIO'ENABLE <> "OK" OR    << CHECK FOR MEASIO ENABLED >>            01248000
    LDEV <> MIO'LDEV.(8:8) THEN GOTO BAD'LDEV;                          01250000
                                                                        01252000
  IF NOT (0 <= FCODE <= 4) THEN   << BAD FUNCTION CODE >>               01254000
    BEGIN                                                               01256000
      MEASIO := 2;   << RETURN BAD FUNCTION CODE INDICATOR>>            01258000
      GOTO BAD'EXIT;                                                    01260000
    END;                                                                01262000
                                                                        01264000
  DRT := ILTP(ICNTRL).IDRTN;  << EXTRACT DRT NUMBER FROM ILT >><<04850>>01266000
                                                                        01268000
  WAIT'FOR'IO;       << COMPLETE PREVIOUS I/O >>                        01270000
                                                                        01272000
  DISABLE;                                                              01274000
                                                                        01276000
  IF FCODE=0 OR MIO'STATUS=0 THEN  << GET UNIT'S STATUS >>              01278000
    BEGIN                                                               01280000
      ILTP(IFLAG).IGNOREHI := 1;  << SET IGNORE INTERRUPT FLAG >>       01282000
      SIOP(DSJ'CMDJMP) := 36;     << SET UP CMD JMP SWITCH >>  <<04118>>01284000
      << GET CPU NUMBER >>                                     <<04850>>01286000
      ASSEMBLE(PCN);                                           <<04850>>01288000
      CPU'NUMBER := TOS;   << SAVE CPU NUMBER >>               <<04850>>01290000
                                                               <<04850>>01292000
      << FIGURE DELAY ACCORDING TO CPU TYPE >>                 <<04850>>01294000
      IF CPU'NUMBER = 4 THEN                                   <<04850>>01296000
        TOS := 256000D         << Series/64 >>                 <<04850>>01298000
      ELSE IF CPU'NUMBER = 3 THEN                              <<04850>>01300000
        TOS := 128000D         << Series/44 >>                 <<04850>>01302000
      ELSE TOS := 32000D;      << Series/33 >>                 <<04850>>01304000
                                                               <<04850>>01306000
      COUNTER := TOS;                                          <<04850>>01308000
                                                               <<04850>>01310000
      QUIESCE'DRT(DRT);                                        <<04850>>01312000
      TOS := DRT;                                                       01314000
      TOS := @SIOP+SYSDB;                                               01316000
      ASMB(DDUP;SIOPG;BL*-3;BE*+2;BR*-5;DDEL);                          01318000
WAITLOOP:                                                               01320000
                                                               <<04850>>01322000
      TOS := GETDRT(DRT,3);  << GET 4TH WORD OF DRT >>         <<04850>>01324000
                                                               <<04850>>01326000
      IF TOS.(0:2) <> 0 THEN   << I/O PROGRAM NOT DONE >>               01328000
        BEGIN                                                           01330000
          IF (COUNTER:=COUNTER+1D)= 0D THEN                    <<04850>>01332000
            MIO'STATE := -1   << FATAL ERROR >>                <<04850>>01334000
          ELSE                                                 <<04850>>01336000
            GO TO WAITLOOP;                                    <<04850>>01338000
        END;                                                            01340000
    END;                                                                01342000
                                                                        01344000
                                                                        01346000
  IF FCODE = 0 AND MIO'STATE <> -1 THEN << RET. HDWE STATUS >> <<04850>>01348000
    BEGIN                                                               01350000
      TOS := 0;                                                         01352000
      IF LMIO'STATUS.EOT THEN TOS.(12:1) := 1;  << EOT >>               01354000
      IF LMIO'STATUS.FILEPRTCT THEN TOS.(13:1) := 1;  << FILE PROTECT >>01356000
      IF LMIO'STATUS.ONLINE THEN TOS.(14:1) := 1;  << UNIT ONLINE >>    01358000
      IF LMIO'STATUS.LDPOINT THEN TOS.(15:1) := 1;  << LOAD POINT >>    01360000
      MEASIO := TOS;    << RETURN ENCODED STATUS >>                     01362000
      GOTO GOOD'EXIT;                                                   01364000
    END;                                                                01366000
                                                                        01368000
  IF MIO'STATE=-1 AND FCODE<4 THEN  << IRRECOVERABLE ERROR STATE >>     01370000
    BEGIN                                                               01372000
      MEASIO := 3;  << RETURN IRRECOVERABLE ERROR INDICATOR >>          01374000
      GOTO BAD'EXIT;                                                    01376000
    END;                                                                01378000
                                                                        01380000
  IF NOT LMIO'STATUS.ONLINE THEN  << UNIT NOT READY >>                  01382000
    BEGIN                                                               01384000
      MEASIO := 4;   << RETURN UNIT NOT READY INDICATOR >>              01386000
      GOTO BAD'EXIT;                                                    01388000
    END;                                                                01390000
                                                                        01392000
  IF LMIO'STATUS.FILEPRTCT AND FCODE<3 THEN  << FILE PROTECT ERROR >>   01394000
    BEGIN                                                               01396000
      MEASIO := 5;   << RETURN FILE PROTECT INDICATOR >>                01398000
      GOTO BAD'EXIT;                                                    01400000
    END;                                                                01402000
                                                                        01404000
  MEASIO := 0;                                                          01406000
                                                                        01408000
  IF FCODE=1 THEN   << PERFORM COUNT CHECKS >>                          01410000
    BEGIN                                                               01412000
      IF COUNT<0 THEN COUNT := -COUNT    << SETUP COUNT AS >>           01414000
      ELSE COUNT := COUNT&LSL(1);        << POSITIVE BYTES >>  <<04850>>01416000
      IF COUNT=0 THEN GOTO GOOD'EXIT;                                   01418000
      IF COUNT>MAXCOUNT THEN                                            01420000
        BEGIN                                                           01422000
          MEASIO := 2;   << RETURN INVALID COUNT INDICATOR >>           01424000
          GOTO BAD'EXIT;                                                01426000
        END;                                                            01428000
    END;                                                                01430000
                                                                        01432000
  MIO'FCODE := FCODE;    << SAVE PARAMETERS FOR RETRY >>                01434000
  MIO'BANK := BANK;                                                     01436000
  MIO'ADDR := ADDR;                                                     01438000
  MIO'COUNT := COUNT;                                                   01440000
  MIO'RETRY := 0;                                                       01442000
                                                                        01444000
  MIO'INITIATOR(DRT,DITP,SIOP,FCODE,   << START CURRENT REQUEST >>      01446000
                BANK,ADDR,COUNT);                                       01448000
                                                                        01450000
GOOD'EXIT:                                                              01452000
  TOS := OLDDB;                                                <<04850>>01454000
  ASMB(XCHD);                                                  <<04850>>01456000
  PENABLE;                                                     <<04850>>01458000
  CC := IF LMIO'STATUS.EOT  THEN  CCG  ELSE  CCE;              <<01185>>01460000
END;                                                                    01462000
$PAGE "     MEASUREMENT I/O SYSTEM -- INITIATOR"                        01464000
PROCEDURE MIO'INITIATOR(DRT,DITP,SIOP,FCODE,BANK,ADDR,COUNT);           01466000
  VALUE  DRT, DITP, SIOP, FCODE, BANK, ADDR, COUNT;                     01468000
  INTEGER  DRT, FCODE, BANK, ADDR, COUNT;                               01470000
  INTEGER POINTER  DITP, SIOP;                                          01472000
  OPTION  PRIVILEGED, UNCALLABLE, INTERNAL;                             01474000
BEGIN                                                                   01476000
                                                                        01478000
  EQUATE                                                                01480000
    BSRECORDCMD = %12,                                                  01482000
    REWINDCMD   = %15,                                                  01484000
    REWUNLDCMD  = %16,                                                  01486000
    TAPEGAPCMD  =   7,                                                  01488000
    WRITECMD    =   5,                                                  01490000
    WRTFMARKCMD =   6,                                                  01492000
                                                                        01494000
    BADDR1      =  26,                                                  01496000
    BYTECNT1    =  23,                                                  01498000
    BYTECNT2    =  28,                                                  01500000
    CMDWORD     =  96,                                         <<04118>>01502000
    MEMX1       =  25,                                                  01504000
    MEMX2       =  30,                                                  01506000
    RWDATA      =  22,                                                  01508000
    TDBL1       =  24,                                                  01510000
    TDBL2       =  29;                                                  01512000
                                                                        01514000
  SWITCH SW := BSRECORD,READSTAT,WRITEREC,WRITEFMARK,REWIND,RWDUNLOAD;  01516000
                                                                        01518000
  IF NOT (-1 <= FCODE <= 4) THEN RETURN;   << INVALID FUNCTION CODE >>  01520000
                                                                        01522000
  DISABLE;                                                              01524000
                                                               <<04850>>01526000
  << GET INTO KNOWN STATE BEFORE MODIFYING CHANNEL PGM >>      <<04850>>01528000
  QUIESCE'DRT(DRT);                                            <<04850>>01530000
                                                                        01532000
  GOTO SW(FCODE+1);   << BRANCH TO LABEL >>                             01534000
                                                                        01536000
WRITEREC:                                                               01538000
  SIOP(RWDATA) := %2000;          << WRITE COMMAND >>                   01540000
  SIOP(BYTECNT1) := COUNT;        << BYTE COUNT >>                      01542000
  IF COUNT = 0 THEN ASSEMBLE ( HALT);                                   01544000
  SIOP(TDBL1) := 0;               << TERM DISP >>              <<04118>>01546000
  SIOP(MEMX1) := BANK + %20000;   << BURST MODE/NO EOT/BANK >> <<04118>>01548000
  SIOP(BADDR1) := ADDR;           << BUFFER ADDRESS >>                  01550000
  SIOP(BYTECNT2) := 12;           << SETUP EOI EXIT JUMP >>    <<04118>>01552000
  SIOP(TDBL2) := 0;               << SETUP BURST COMPLETION >>          01554000
  SIOP(MEMX2) := -15;             <<   RETURN JUMP          >>          01556000
  SIOP(DSJ'RWJMP) := 0;           << SET SWITCH TO WRITE BRANCH >>      01558000
  TOS := WRITECMD;       << WRITE MOTION COMMAND >>                     01560000
                                                                        01562000
INITIO:                                                                 01564000
  SIOP(CMDWORD) := TOS;   << SETUP MOTION COMMAND >>                    01566000
  SIOP(DSJ'CMDJMP) := 0;  << SET SWITCH TO MOTION COMMAND BRANCH >>     01568000
                                                                        01570000
  TOS := DRT;             << START CHANNEL PROGRAM >>                   01572000
  TOS := @SIOP+SYSDB;                                                   01574000
  ASMB(DDUP;SIOPG;BL*-3;BE*+2;BR*-5;DDEL);                              01576000
  MIO'STATE := IF FCODE>=0 THEN 1 ELSE 2;   << SET PROCESS STATE >>     01578000
                                                                        01580000
READSTAT:                                                               01582000
  RETURN;                                                               01584000
                                                                        01586000
                                                                        01588000
WRITEFMARK:                                                             01590000
  TOS := WRTFMARKCMD;   << WRITE FILE MARK COMMAND >>                   01592000
                                                                        01594000
CONTROLCONT:                                                            01596000
  SIOP(DSJ'RWJMP) := 25;   << BRANCH AROUND WRITE LOGIC >>     <<04118>>01598000
  GOTO INITIO;                                                          01600000
                                                                        01602000
                                                                        01604000
BSRECORD:                                                               01606000
  TOS := BSRECORDCMD;   << BACKSPACE RECORD COMMAND >>                  01608000
  GOTO CONTROLCONT;                                                     01610000
                                                                        01612000
                                                                        01614000
REWIND:                                                                 01616000
  IF LMIO'STATUS.LDPOINT THEN  << ALREADY AT LOADPOINT >>               01618000
    BEGIN                                                               01620000
      MIO'STATE := 0;   << INDICATE COMPLETION >>                       01622000
      RETURN;                                                           01624000
    END;                                                                01626000
  TOS := REWINDCMD;   << REWIND COMMAND >>                              01628000
  GOTO CONTROLCONT;                                                     01630000
                                                                        01632000
RWDUNLOAD:                                                              01634000
  TOS := REWUNLDCMD;   << REWIND/UNLOAD COMMAND >>                      01636000
  GOTO CONTROLCONT;                                                     01638000
                                                                        01640000
END;                                                                    01642000
$PAGE "     MEASUREMENT I/O SYSTEM -- COMPLETOR"                        01644000
PROCEDURE MIO'COMPLETOR(DRT,DITP,SIOP);                                 01646000
  VALUE  DRT, DITP, SIOP;                                               01648000
  INTEGER  DRT;                                                         01650000
  INTEGER POINTER  DITP, SIOP;                                          01652000
  OPTION  PRIVILEGED, UNCALLABLE, INTERNAL;                             01654000
BEGIN                                                                   01656000
                                                                        01658000
  INTEGER POINTER  ILTP;                                                01660000
  DEFINE  ERRCODE = (0:3)#;                                             01662000
  EQUATE  ERRMASK = %11020,                                             01664000
          FATAL   = %4010,                                              01666000
          TAPEGAPCMD = 7;                                               01668000
                                                                        01670000
                                                                        01672000
  @ILTP := DITP(DILTP);   << SETUP ILT POINTER >>                       01674000
  IF ILTP.ERRCODE > 5 THEN                     << CHAN ERR >>  <<04850>>01676000
    BEGIN                                                               01678000
ERR'EXIT:                                                               01680000
      MIO'STATE := -1;   << RETURN FAILURE INDICATOR >>                 01682000
      RETURN;                                                           01684000
    END;                                                                01686000
                                                               <<04850>>01688000
  QUIESCE'DRT(DRT);                                            <<04850>>01690000
                                                               <<04850>>01692000
  IF (LMIO'STATUS LAND FATAL) <> 0 THEN GOTO ERR'EXIT;                  01694000
                                                                        01696000
  IF MIO'STATE=1 THEN   << I/O IN PROGRESS >>                           01698000
    BEGIN                                                               01700000
      IF (MIO'FCODE=1 OR MIO'FCODE=2) AND                               01702000
         ((LMIO'STATUS LAND ERRMASK) <> 0) THEN   << RETRY >>           01704000
        BEGIN                                                           01706000
        MIO'STATUS := 0;                                       <<04850>>01708000
          IF (MIO'RETRY := MIO'RETRY+1) <= 2 THEN                       01710000
            BEGIN                                                       01712000
              MIO'INITIATOR(DRT,DITP,SIOP,-1,0,0,0);                    01714000
              RETURN;                                                   01716000
            END                                                         01718000
          ELSE                                                          01720000
            GOTO ERR'EXIT;                                              01722000
        END;                                                            01724000
                                                                        01726000
      IF MIO'FCODE=3 THEN   << REWIND OPERATION STARTED >>              01728000
        BEGIN                                                           01730000
          SIOP(DSJ'CMDJMP) := 57;                              <<04118>>01732000
          MIO'STATE := 4;   << REWIND COMPLETION WAIT >>                01734000
          GOTO IOCONT;                                                  01736000
        END;                                                            01738000
                                                                        01740000
      MIO'STATE := 0;   << INDICATE SUCCESSFUL COMPLETION >>            01742000
    END                                                                 01744000
                                                                        01746000
  ELSE IF MIO'STATE=2 THEN   << BACKSPACE RECORD COMPLETED >>           01748000
    BEGIN                                                               01750000
      SIOP(CMDWORD) := TAPEGAPCMD;   << TAPE GAP COMMAND >>             01752000
      MIO'STATE := 3;                                                   01754000
IOCONT:                                                                 01756000
      TOS := DRT;        << START CHANNEL PROGRAM >>                    01758000
      TOS := @SIOP+SYSDB;                                               01760000
      ASMB(DDUP;SIOPG;BL*-3;BE*+2;BR*-5;DDEL);                          01762000
    END                                                                 01764000
                                                                        01766000
  ELSE IF MIO'STATE=3 THEN   << TAPE GAP COMPLETED >>                   01768000
    BEGIN                                                               01770000
      MIO'INITIATOR(DRT,DITP,SIOP,MIO'FCODE,                            01772000
                    MIO'BANK,MIO'ADDR,MIO'COUNT);                       01774000
    END                                                                 01776000
                                                                        01778000
  ELSE IF MIO'STATE=4 THEN   << REWIND COMPLETED >>                     01780000
    BEGIN                                                               01782000
      MIO'STATUS.LDPOINT :=1;                                           01784000
      MIO'STATE := 0;                                                   01786000
    END;                                                                01788000
END;                                                                    01790000
$PAGE "     MEASUREMENT I/O SYSTEM -- INTERRUPT PROCESSOR"              01792000
PROCEDURE MIO'INTRPT'PROC;                                              01794000
  OPTION  PRIVILEGED, UNCALLABLE, INTERRUPT;                            01796000
BEGIN                                                                   01798000
                                                                        01800000
  INTEGER                                                               01802000
    DRT         = Q+3,    << LOCATED AT S-1 WHEN PROCEDURE IS ENTERED >>01804000
    UNIT        = Q+5;    << UNIT NUMBER OF INTERRUPTING MAG TAPE >>    01806000
                                                                        01808000
  INTEGER POINTER                                                       01810000
    SIOP        = Q+4,    << CHANNEL PROGRAM POINTER >>                 01812000
    DITP        = Q+6;    << DIT POINTER >>                             01814000
                                                                        01816000
  INTEGER                                                               01818000
    ILT'SIOP    = DB+ISIOP,  << ILT CHANNEL PROGRAM POINTER >>          01820000
    ILT'FLAG    = DB+IFLAG;  << ILT FLAG WORD >>                        01822000
                                                                        01824000
  INTEGER ARRAY                                                         01826000
    ILT'DITP(*) = DB+IDITP0;  << ILT POINTER FOR DIT 0 >>               01828000
                                                                        01830000
  LOGICAL  LS0=S-0;                                                     01832000
  INTEGER  X=X;                                                         01834000
                                                                        01836000
                                                                        01838000
  TOS := ILT'SIOP;        << SIOP >>                                    01840000
                                                                        01842000
  X := LS0 + SYSDB + 94;                                                01844000
  TOS := ABSOLUTE(X).(9:2);  << UNIT >>                                 01846000
                                                                        01848000
  TOS := ILT'DITP(UNIT);  << DITP >>                                    01850000
  IF <= THEN RETURN;        << UNCONFIGURED UNIT >>                     01852000
                                                                        01854000
                                                               <<04850>>01856000
                                                               <<04850>>01858000
                                                                        01860000
  TOS := 0;                                                             01862000
  TOS := SYSDB;                                                         01864000
  ASMB(XCHD);       << SET DB TO SYSDB >>                               01866000
                                                                        01868000
                                                               <<04850>>01870000
  MIO'COMPLETOR(DRT,DITP,SIOP);    << CALL COMPLETOR >>                 01872000
END;                                                                    01874000
$PAGE "     MEASUREMENT I/O SYSTEM -- DATA INITIALIZATION"              01876000
PROCEDURE MIO'INIT(LDEV);                                               01878000
  VALUE  LDEV;                                                          01880000
  INTEGER  LDEV;                                                        01882000
  OPTION  PRIVILEGED, UNCALLABLE;                                       01884000
BEGIN                                                                   01886000
                                                                        01888000
<<  This procedure intializes the DRT, DIT, and SIO program area  >>    01890000
<<  as required by the Series 33 Measurement I/O System.  It also >>    01892000
<<  halts the 7970E HP-IB Mag Tape Driver's Idle Channel Program. >>    01894000
                                                                        01896000
<<  The parameter, LDEV, is an integer containing the measurement >>    01898000
<<  logical device number in bits (8:8) and a "unit downed" bit   >>    01900000
<<  map in bits(0:4).                                             >>    01902000
                                                                        01904000
  INTEGER  DRT;                                                         01906000
  INTEGER POINTER  DITP, ILTP, SIOP;                                    01908000
                                                                        01910000
                                                                        01912000
  DISABLE;                                                              01914000
  TOS := 0;                                                             01916000
  TOS := SYSDB;                                                         01918000
  ASMB(XCHD);        << SET DB TO SYSDB >>                              01920000
                                                                        01922000
  @DITP := LPDT(LDEV.(8:8)&LSL(1));   << SETUP POINTERS >>              01924000
  @ILTP := DITP(DILTP);                                                 01926000
  @SIOP := ILTP(ISIOP);                                                 01928000
  DRT := ILTP(ICNTRL).IDRTN;                                   <<04850>>01930000
                                                                        01932000
  QUIESCE'DRT(DRT);                                            <<04850>>01934000
                                                               <<04850>>01936000
                                                                        01938000
  MIO'ENABLE := "OK";     << INITIALIZE DIT >>                          01940000
  MIO'STATE  := 0;                                                      01942000
  MIO'RETRY  := 0;                                                      01944000
                                                                        01946000
  MIO'LDEV   := LDEV;     << INITIALIZE SIO AREA >>                     01948000
  MIO'UNIT   := DITP(DLDEV).UNIT'FIELD+1; <<UNIT # FROM DIT+1>><<01430>>01950000
  MIO'STATUS := 0;                                                      01952000
                                                                        01954000
  PUTDRT(DRT,2,@MIO'INTRPT'PROC); << INITIALIZE DRT >>         <<04850>>01956000
                                                               <<04850>>01958000
                                                                        01960000
  ASMB(XCHD);      << RESET DB >>                                       01962000
END;                                                                    01964000
$PAGE "     MEASUREMENT I/O SYSTEM -- RESET DATA"                       01966000
INTEGER PROCEDURE MIO'RESET(LDEV);                                      01968000
  VALUE  LDEV;                                                          01970000
  INTEGER  LDEV;                                                        01972000
  OPTION  PRIVILEGED, UNCALLABLE;                                       01974000
BEGIN                                                                   01976000
                                                                        01978000
<<  This procedure resets the DIT, DRT, and SIO program area for >>     01980000
<<  use by the Series 33 Mag Tape Driver.  It also starts an     >>     01982000
<<  Idle Channel Program for the mag tape controller.            >>     01984000
                                                                        01986000
<<  This procedure returns an integer containing the measurement >>     01988000
<<  logical device number in bits (8:8) and the "unit downed"    >>     01990000
<<  bit map in bits (0:4).                                       >>     01992000
                                                                        01994000
  INTEGER  DRT;                                                         01996000
  INTEGER POINTER  DITP, ILTP, SIOP, IDLESIO;                           01998000
  EQUATE IDLE = 68;                                            <<04850>>02000000
                                                                        02002000
                                                                        02004000
  DISABLE;                                                              02006000
  TOS := 0;                                                             02008000
  TOS := SYSDB;                                                         02010000
  ASMB(XCHD);       << SET DB TO SYSDB >>                               02012000
                                                                        02014000
  @DITP := LPDT(LDEV.(8:8)&LSL(1));   << SETUP POINTERS >>              02016000
  @ILTP := DITP(DILTP);                                                 02018000
  @SIOP := ILTP(ISIOP);                                                 02020000
  @IDLESIO := @SIOP+IDLE;                                               02022000
  DRT := ILTP(ICNTRL).IDRTN;                                   <<04850>>02024000
                                                                        02026000
  MIO'RESET := MIO'LDEV;    << SAVE RETURN VALUE >>                     02028000
                                                                        02030000
  MOVE DITP(8) := (3(0));   << RESET DIT >>                             02032000
  MIO'STATUS   := 0;        << RESET SIO STATUS WORD >>                 02034000
                                                                        02036000
  PUTDRT(DRT,2,@GIP'HPIB); << RESET DRT >>                     <<04850>>02038000
                                                                        02040000
  << TURN OFF BIT INDICATING THAT IDLE CHANNEL PROGRAM IS RUNNI<<04850>>02042000
  ILTP(IFLAG).WAITPROG := 0;                                   <<04850>>02044000
                                                               <<04850>>02046000
  AWAKEIO(DITP,0); << START IDLE CHANP, NO IMPEDE >>           <<04850>>02048000
<< IF < THEN IOFAILURE(DRT,DITP); >>                           <<04850>>02050000
                                                                        02052000
  ASMB(XCHD);     << RESET DB >>                                        02054000
END;                                                                    02056000
$CONTROL SEGMENT=SEG'                                          <<01549>>02058000
END.                                                           <<01549>>02060000
