$CONTROL MAP,CODE,USLINIT                                               00010000
<< MEASIO - MODULE 88 >>                                                00012000
<< HP32002C 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
BEGIN                                                                   00030000
    INTEGER STATUS=Q-1, S0=S-0, X=X;                           <<01150>>00032000
    INTEGER POINTER CSTI=1, DSTI=2, LPDT=DB+%10;               <<01150>>00034000
    DEFINE CC = STATUS.(6:2)#,                                 <<01150>>00036000
           ABS = ABSOLUTE#,                                    <<01150>>00038000
           ASMB = ASSEMBLE#,                                   <<01150>>00040000
           TRAPOFF = PUSH(STATUS);                             <<01150>>00042000
                     TOS.(2:1) := 0;                           <<01150>>00044000
                     SET(STATUS)#,                             <<01150>>00046000
           ENABLE = ASMB(SED 1)#,                              <<01150>>00048000
           DISABLE = ASMB(SED 0)#,                             <<01150>>00050000
           PDISABLE = ASMB(PSDB)#,                             <<01150>>00052000
           PENABLE = ASMB(PSEB)#;                              <<01150>>00054000
    EQUATE CCG = 0,                                            <<01150>>00056000
           CCL = 1,                                            <<01150>>00058000
           CCE = 2,                                            <<01150>>00060000
           SYSDB = %1000;                                      <<01150>>00062000
<< MEASUREMENT I/O GLOBAL EQUATES AND DEFINES >>                        00064000
                                                                        00066000
EQUATE SET'BANK'ORDER  = %14000,                                        00068000
       END'ORDER       = %30000,                                        00070000
       END'INT'ORDER   = %34000,                                        00072000
       CONTROL'ORDER   = %40000,                                        00074000
       SENSE'ORDER     = %50000,                                        00076000
       WRITE'ORDER     = %60000,                                        00078000
       WRT'CHAIN'ORDER = %160000;                                       00080000
                                                                        00082000
EQUATE WRR = %04,                                                       00084000
       GAP = %05,                                                       00086000
       REW = %10,                                                       00088000
       RST = %11,                                                       00090000
       BSR = %12,                                                       00092000
       WFM = %15;                                                       00094000
                                                                        00096000
DEFINE MIO'STATUS = DITP(6)#,                                           00098000
       MIO'STATE  = DITP(7)#,                                           00100000
       MIO'RETRY  = DITP(8)#,                                           00102000
       MIO'FCTN   = SIOP(33)#,                                          00104000
       MIO'BANK   = SIOP(34)#,                                          00106000
       MIO'ADDR   = SIOP(35)#,                                          00108000
       MIO'COUNT  = SIOP(36)#,                                          00110000
       MIO'LDEV   = SIOP(37)#,                                          00112000
       MIO'UNIT   = SIOP(38)#,                                          00114000
       MIO'ENABLE = SIOP(39)#;                                          00116000
                                                                        00118000
INTEGER PROCEDURE MEASIO(LDEV,FCTN,BANK,ADDR,COUNT);                    00120000
   VALUE LDEV, FCTN, BANK, ADDR, COUNT;                                 00122000
   INTEGER LDEV, FCTN, BANK, ADDR, COUNT;                               00124000
   OPTION FORWARD;                                                      00126000
                                                                        00128000
PROCEDURE MIO'INITIATOR(DRT,DITP,SIOP,FCTN,BANK,ADDR,COUNT);            00130000
   VALUE DRT, DITP, SIOP, FCTN, BANK, ADDR, COUNT;                      00132000
   INTEGER DRT, FCTN, COUNT;                                            00134000
   LOGICAL BANK, ADDR;                                                  00136000
   INTEGER POINTER DITP, SIOP;                                          00138000
   OPTION FORWARD;                                                      00140000
                                                                        00142000
PROCEDURE MIO'COMPLETOR(DRT,DITP,SIOP);                                 00144000
   VALUE DRT, DITP, SIOP;                                               00146000
   INTEGER DRT;                                                         00148000
   INTEGER POINTER DITP, SIOP;                                          00150000
   OPTION FORWARD;                                                      00152000
                                                                        00154000
PROCEDURE MIO'INTRPT'PROC;                                              00156000
   OPTION FORWARD;                                                      00158000
                                                                        00160000
PROCEDURE MIO'INIT(LDEV);                                               00162000
   VALUE LDEV;                                                          00164000
   INTEGER LDEV;                                                        00166000
   OPTION FORWARD;                                                      00168000
                                                                        00170000
INTEGER PROCEDURE MIO'RESET(LDEV);                                      00172000
   VALUE LDEV;                                                          00174000
   INTEGER LDEV;                                                        00176000
   OPTION FORWARD;                                                      00178000
                                                                        00180000
PROCEDURE IOFAILURE(DRT,DITP);                                          00182000
   VALUE DRT, DITP;                                                     00184000
   INTEGER DRT;                                                         00186000
   INTEGER POINTER DITP;                                                00188000
   OPTION PRIVILEGED, UNCALLABLE, EXTERNAL;                             00190000
                                                                        00192000
PROCEDURE HELP;                                                         00194000
   OPTION EXTERNAL;                                                     00196000
                                                                        00198000
PROCEDURE GIP;                                                          00200000
   OPTION PRIVILEGED, UNCALLABLE, EXTERNAL;                             00202000
$PAGE "     MEASUREMENT I/O SYSTEM -- DESCRIPTION"                      00204000
<<**********************************************************************00206000
                                                                        00208000
             Measurement I/O System                                     00210000
                                                                        00212000
                                                                        00214000
                                                                        00216000
Declaration:                                                            00218000
                                                                        00220000
   INTEGER PROCEDURE MEASIO(LDEV,FCTN,BANK,ADDR,COUNT);                 00222000
      VALUE LDEV, FCTN, BANK, ADDR, COUNT;                              00224000
      INTEGER LDEV, FCTN, BANK, ADDR, COUNT;                            00226000
      OPTION PRIVILEGED, UNCALLABLE, EXTERNAL;                          00228000
                                                                        00230000
                                                                        00232000
Function:                                                               00234000
                                                                        00236000
   MEASIO is a self contained, core resident I/O system used by         00238000
   various performance measurement subsystems (Monitor, Sampler,        00240000
   Tracer, etc.) to write data to magnetic tape.  Generally speak-      00242000
   ing, it is independent of, and unknown to MPE in order to min-       00244000
   imize the effects of the measurement subsystems on the system's      00246000
   operation.                                                           00248000
                                                                        00250000
                                                                        00252000
Parameters:                                                             00254000
                                                                        00256000
   LDEV     The logical device number of the tape drive.                00258000
                                                                        00260000
   FCTN     The function to be performed:                               00262000
                                                                        00264000
            0 -- Read Status                                            00266000
            1 -- Write Data                                             00268000
            2 -- Write File Mark                                        00270000
            3 -- Rewind                                                 00272000
            4 -- Rewind & Reset                                         00274000
                                                                        00276000
   BANK     The bank number of the data to be written.                  00278000
                                                                        00280000
   ADDR     The absolute address of the data to be written.             00282000
                                                                        00284000
   COUNT    The amount of data to be written:                           00286000
            >0 => Word count     <0 => Byte count                       00288000
            The maximum count allowed is 16383 words or 32766 bytes.    00290000
                                                                        00292000
                                                                        00294000
Condition Codes and Returned Values:                                    00296000
                                                                        00298000
   CCE      Condition code CCE indicates that the previous request      00300000
            (if any) has been completed successfully and the cur-       00302000
            rent request has been started.  The returned value will     00304000
            be zero for all functions except Read Status which will     00306000
            return the following information obtained from the hard-    00308000
            ware status word:                                           00310000
                                                                        00312000
             Bits     Meaning                                           00314000
                                                                        00316000
            (0:12) -- Not Used                                          00318000
            (12:1) -- End of Tape (EOT)                                 00320000
            (13:1) -- Write Protect                                     00322000
            (14:1) -- Ready (On Line)                                   00324000
            (15:1) -- Load Point (BOT)                                  00326000
                                                                        00328000
   CCG      Condition code CCG is identical to CCE except that it       00330000
            also indicates that the tape's EOT reflective spot has      00332000
            been passed.                                                00334000
                                                                        00336000
   CCL      Condition code CCL indicates that an error has occured.     00338000
            The returned value indicates the type of error:             00340000
                                                                        00342000
            1 -- LDEV is invalid or not enabled.                        00344000
            2 -- FCTN is invalid or COUNT is too large.                 00346000
            3 -- An irrecoverable error has occured.                    00348000
            4 -- FCTN is something other than Read Status but the       00350000
                 tape drive is not ready.                               00352000
            5 -- FCTN is Write Data or Write File Mark but there        00354000
                 is no write ring.                                      00356000
                                                                        00358000
            Error codes 1 and 2 indicate an invalid parameter; the      00360000
            status of the previous request has not been checked         00362000
            and the current request is rejected.  Error code 3 in-      00364000
            dicates that an irrecoverable error has occured on a        00366000
            previous request; the current request was not started.      00368000
            Once an irrecoverable error has occured, the only fun-      00370000
            tions that will be accepted are Read Status and Rewind      00372000
            & Reset.  A successful Rewind & Reset request will clear    00374000
            the irrecoverable error.  A new tape should be mounted      00376000
            and the drive made ready.  Error codes 4 and 5 indicate     00378000
            that the previous request has been completed successfully   00380000
            but the current request was not started.                    00382000
                                                                        00384000
                                                                        00386000
Comments:                                                               00388000
                                                                        00390000
   MEASIO must be called with DB set to SYSDB.                          00392000
                                                                        00394000
   For Write Data requests, it is the caller's responsibility to        00396000
   freeze the data.  The data must not be altered or unfrozen un-       00398000
   til a subsequent request indicates that the I/O has been com-        00400000
   pleted successfully or an irrecoverable error has occured.           00402000
                                                                        00404000
   MEASIO requires the exclusive use of the specified tape drive        00406000
   and its controller.  In order to avoid conflicts with MPE, it        00408000
   must be enabled with a console command that puts all drives on       00410000
   the controller (including MEASIO's drive) in the DOWN state and      00412000
   properly initializes the DRT, DIT, and SIO Program area.  An-        00414000
   other console command is used to disable MEASIO and reset the        00416000
   tables for normal MPE operation.                                     00418000
                                                                        00420000
   Since Read Status requests require running an SIO program, they      00422000
   should not be issued capriciously.  In most applications, the        00424000
   status is only checked before the first I/O request and after        00426000
   a new tape is mounted.                                               00428000
                                                                        00430000
   For a variety of performance related reasons, it is preferable       00432000
   to call MEASIO with the interrupt system enabled.  It may, how-      00434000
   ever, be called with the interrupt system enabled or disabled.       00436000
   MEASIO will not enable the interrupt system if it was called         00438000
   while the system was disabled.                                       00440000
                                                                        00442000
NOTE:  If MEASIO is called from an interrupt processor, the inter-      00444000
   rupt system should be disabled.  Otherwise, MEASIO could loop,       00446000
   waiting for an interrupt, at a time when the interrupt priority      00448000
   poll prevents the tape controller from interrupting.                 00450000
                                                                        00452000
**********************************************************************>>00454000
$PAGE "     MEASUREMENT I/O SYSTEM -- OPERATION ON THE SERIES III"      00456000
<<**********************************************************************00458000
                                                                        00460000
             Operation on the Series III                                00462000
                                                                        00464000
                                                                        00466000
                                                                        00468000
   MEASIO uses a portion of its tape drive's DIT and SIO Program        00470000
   area for global data; the words used, their significance, and        00472000
   their initial values are:                                            00474000
                                                                        00476000
   MIO'STATUS  DIT(6)   Last known hardware status.                     00478000
                        Initialized to zero.                            00480000
                                                                        00482000
   MIO'STATE   DIT(7)   Current device state:                           00484000
                       -1 -- Irrecoverable Error                        00486000
                        0 -- No Activity                                00488000
                        1 -- I/O in Progress                            00490000
                        2 -- BSR/GAP for Retry                          00492000
                        Initialized to zero.                            00494000
                                                                        00496000
   MIO'RETRY   DIT(8)   Number of retries for this request.             00498000
                        Initialized to zero.                            00500000
                                                                        00502000
   MIO'FCTN    SIO(33)  /                                               00504000
                        |                                               00506000
   MIO'BANK    SIO(34)  |  Saved parameters for retry.                  00508000
                        |                                               00510000
   MIO'ADDR    SIO(35)  |  Uninitialized                                00512000
                        |                                               00514000
   MIO'COUNT   SIO(36)  \                                               00516000
                                                                        00518000
   MIO'LDEV    SIO(37).(0:4)  DOWNed unit flags.                        00520000
                      .(8:8)  The logical device number that            00522000
                              has been enabled for MEASIO.              00524000
                                                                        00526000
   MIO'UNIT    SIO(38)  The unit number of the MEASIO tape.             00528000
                                                                        00530000
   MIO'ENABLE  SIO(39)  A flag word containing "OK" (%47513) to         00532000
                        indicate that MEASIO is enabled for some        00534000
                        unit on this controller.                        00536000
                                                                        00538000
                                                                        00540000
   In addition to MEASIO, the measurement I/O system includes five      00542000
   supporting procedures:                                               00544000
                                                                        00546000
   MIO'INITIATOR -- This procedure builds and starts the necessary      00548000
                    SIO programs and updates MIO'STATE.                 00550000
                                                                        00552000
   MIO'COMPLETOR -- This procedure checks the I/O completion status     00554000
                    and updates MIO'STATE.  If necessary, it calls      00556000
                    MIO'INITIATOR to start a retry.                     00558000
                                                                        00560000
   MIO'INTRPT'PROC -- This is the interrupt processor.  When an in-     00562000
                      terrupt is received from the MEASIO tape con-     00564000
                      troller, it saves the hardware status and         00566000
                      calls MIO'COMPLETOR.                              00568000
                                                                        00570000
   MIO'INIT -- This procedure initializes the DRT, DIT, and SIO         00572000
               program area as required by the Series III Measure-      00574000
               ment I/O system.                                         00576000
                                                                        00578000
   MIO'RESET -- This procedure resets the DRT, DIT, and SIO program     00580000
                area for normal use by the Series III I/O system.       00582000
                                                                        00584000
                                                                        00586000
   Each time MEASIO is called, it verifies that the logical device      00588000
   is valid and enabled and that the function is valid.  It then        00590000
   checks the previous request and waits for completion.  If MEASIO     00592000
   was called with the interrupt system enabled, the wait loop is       00594000
   simply a test of MIO'STATE; otherwise, the wait loop includes a      00596000
   TIO to test for SIO Ready, followed by a call to MIO'COMPLETOR.      00598000
                                                                        00600000
   After waiting for the completion of any previous request, MEASIO     00602000
   disables the interrupt system in order to prevent any recursive      00604000
   calls while the current request is being processed.  If the cur-     00606000
   rent request is Read Status, the hardware status is read and re-     00608000
   turned to the caller.  Otherwise, the previous request is check-     00610000
   ed for an irrecoverable error.  If there has been no error,          00612000
   MEASIO verifies the unit ready and write enable status and calls     00614000
   MIO'INITIATOR to start the current request.                          00616000
                                                                        00618000
                                                                        00620000
   The format of the hardware status word obtained from the 30115       00622000
   Magnetic Tape subsystem and saved in MIO'STATUS is:                  00624000
                                                                        00626000
       Bits     Meaning                Encoded Error Field              00628000
                                                                        00630000
       (0:1) -- SIO OK                 0 -- Unit Interrupt              00632000
       (1:1) -- Odd Byte Count         1 -- Transfer Error              00634000
       (2:1) -- Interrupt Request      2 -- Command Reject              00636000
       (3:2) -- Unit Number            3 -- Tape Runaway                00638000
       (5:1) -- End of Tape (EOT)      4 -- Timing Error                00640000
       (6:1) -- Write Protect          5 -- Tape Error                  00642000
       (7:1) -- On Line                6 -- Reserved Code               00644000
       (8:1) -- Load Point (BOT)       7 -- Error Free                  00646000
       (9:1) -- 800/1600 CPI                                            00648000
      (10:1) -- Write Status                                            00650000
      (11:1) -- Tape Mark                                               00652000
      (12:3) -- Encoded Error                                           00654000
      (15:1) -- 9/7 Track                                               00656000
                                                                        00658000
**********************************************************************>>00660000
$PAGE "     MEASUREMENT I/O SYSTEM -- MEASIO"                           00662000
INTEGER PROCEDURE MEASIO(LDEV,FCTN,BANK,ADDR,COUNT);                    00664000
   VALUE LDEV, FCTN, BANK, ADDR, COUNT;                                 00666000
   INTEGER LDEV, FCTN, BANK, ADDR, COUNT;                               00668000
   OPTION PRIVILEGED, UNCALLABLE;                                       00670000
BEGIN                                                                   00672000
                                                                        00674000
INTEGER DRT;                                                            00676000
INTEGER POINTER DITP, SIOP, ILTP;                                       00678000
DEFINE INTRPTS'ENABLED = LOGICAL(TOS.(1:1))#;                           00680000
DEFINE EOT = (5:1)#,                                                    00682000
       READY = (7:1)#,                                                  00684000
       WRITE'PROTECT = (6:1)#;                                          00686000
EQUATE MAXCOUNT = 16383;                                                00688000
                                                                        00690000
SUBROUTINE WAIT'FOR'IO;                                                 00692000
BEGIN                                                                   00694000
WHILE MIO'STATE > 0 DO                                                  00696000
   BEGIN                                                                00698000
   PUSH(STATUS);                                                        00700000
   IF INTRPTS'ENABLED THEN      << SIT TIGHT >>                         00702000
   ELSE                                                                 00704000
      BEGIN                                                             00706000
      TOS := DRT;                                                       00708000
      ASSEMBLE(TIO 0);                 << GET CONTROLLER STATUS >>      00710000
      IF < THEN IOFAILURE(DRT,DITP);                                    00712000
      ASSEMBLE(TBC 0);                 << CHECK FOR SIO READY >>        00714000
      IF = THEN DDEL                   << NOT READY YET >>              00716000
      ELSE                                                              00718000
         BEGIN                                                          00720000
         MIO'STATUS := TOS;            << SAVE STATUS >>                00722000
         TOS := %40000;                                                 00724000
         ASSEMBLE(CIO 1);              << RESET INTERRUPT REQUEST >>    00726000
         IF < THEN IOFAILURE(DRT,DITP);                                 00728000
         MIO'COMPLETOR(*,DITP,SIOP);   << CALL COMPLETOR >>             00730000
         END;                                                           00732000
      END;                                                              00734000
   END;                                                                 00736000
END;                                                                    00738000
                                                                        00740000
IF NOT (1 <= LDEV <= LPDT.(0:8)) THEN  << CHECK FOR VALID LDEV >>       00742000
   BEGIN                                                                00744000
BAD'LDEV:                                                               00746000
   MEASIO := 1;                                                         00748000
BAD'EXIT:                                                               00750000
   CC := CCL;                                                  <<01150>>00752000
   RETURN;                                                              00754000
   HELP;                                                                00756000
   END;                                                                 00758000
                                                                        00760000
@DITP := LPDT(LDEV&LSL(1));            << GET DIT POINTER >>            00762000
IF < THEN GOTO BAD'LDEV;                                                00764000
                                                                        00766000
@ILTP := DITP(5);                      << GET ILT POINTER >>            00768000
@SIOP := ILTP(%10);                    << GET SIO POINTER >>   <<01300>>00770000
                                                                        00772000
IF MIO'ENABLE <> "OK" OR               << CHECK FOR ENABLE >>           00774000
   LDEV <> MIO'LDEV.(8:8) THEN GOTO BAD'LDEV;                           00776000
                                                                        00778000
IF NOT (0 <= FCTN <= 4) THEN                                            00780000
   BEGIN                               << INVALID FCTN >>               00782000
   MEASIO := 2;                                                         00784000
   GOTO BAD'EXIT;                                                       00786000
   END;                                                                 00788000
                                                                        00790000
DRT := ILTP(7).(8:8);                  << GET DRT NUMBER >>    <<01300>>00792000
                                                                        00794000
WAIT'FOR'IO;                           << COMPLETE PREVIOUS I/O >>      00796000
                                                                        00798000
DISABLE;                                                                00800000
                                                                        00802000
IF FCTN = 0 OR MIO'STATUS = 0 THEN                                      00804000
   BEGIN                                                                00806000
   MOVE SIOP := (SET'BANK'ORDER, 0,    << BUILD SIO PGM TO GET STATUS >>00808000
                 CONTROL'ORDER,  0,                                     00810000
                 SENSE'ORDER,    0,                                     00812000
                 END'ORDER,      0);                                    00814000
   SIOP(3) := MIO'UNIT&LSL(8);                                          00816000
                                                                        00818000
   TOS := DRT;                                                          00820000
   TOS := @SIOP + SYSDB;                                                00822000
   ASSEMBLE(SIO 1);                    << START I/O PROGRAM >>          00824000
   IF <> THEN IOFAILURE(DRT,DITP);                                      00826000
                                                                        00828000
GET'STATUS:                                                             00830000
   ASSEMBLE(TIO 0);                    << GET STATUS >>                 00832000
   IF < THEN IOFAILURE(DRT,DITP);                                       00834000
   ASSEMBLE(TBC 0);                    << CHECK FOR SIO READY >>        00836000
   IF = THEN                                                            00838000
      BEGIN                            << NOT READY -- LOOP >>          00840000
      DEL;                                                              00842000
      GO GET'STATUS;                                                    00844000
      END;                                                              00846000
   MIO'STATUS := TOS;                  << SAVE STATUS >>                00848000
   DEL;                                << DELETE DRT >>                 00850000
   END;                                                                 00852000
                                                                        00854000
IF FCTN = 0 THEN                                                        00856000
   BEGIN                               << RETURN HARDWARE STATUS >>     00858000
   MEASIO := MIO'STATUS.(5:4);                                          00860000
   GOTO GOOD'EXIT;                                                      00862000
   END;                                                                 00864000
                                                                        00866000
IF MIO'STATE = -1 AND FCTN < 4 THEN                                     00868000
   BEGIN                               << IRRECOVERABLE ERROR >>        00870000
   MEASIO := 3;                                                         00872000
   GOTO BAD'EXIT;                                                       00874000
   END;                                                                 00876000
                                                                        00878000
IF NOT LOGICAL(MIO'STATUS.READY) THEN                                   00880000
   BEGIN                               << TAPE NOT READY >>             00882000
   MEASIO := 4;                                                         00884000
   GOTO BAD'EXIT;                                                       00886000
   END;                                                                 00888000
                                                                        00890000
IF LOGICAL(MIO'STATUS.WRITE'PROTECT) AND FCTN < 3 THEN                  00892000
   BEGIN                               << NO WRITE RING >>              00894000
   MEASIO := 5;                                                         00896000
   GOTO BAD'EXIT;                                                       00898000
   END;                                                                 00900000
                                                                        00902000
MEASIO := 0;                                                            00904000
                                                                        00906000
IF FCTN = 1 THEN                                                        00908000
   BEGIN                               << CHECK FOR BYTE COUNT >>       00910000
   IF COUNT = 0 THEN GOTO GOOD'EXIT                                     00912000
   ELSE                                                                 00914000
      IF < THEN COUNT := (1-COUNT)&LSR(1);                              00916000
   IF COUNT > MAXCOUNT THEN                                             00918000
      BEGIN                            << INVALID COUNT >>              00920000
      MEASIO := 2;                                                      00922000
      GOTO BAD'EXIT;                                                    00924000
      END;                                                              00926000
   END;                                                                 00928000
                                                                        00930000
MIO'FCTN := FCTN;                      << SAVE PARMS FOR RETRY >>       00932000
MIO'BANK := BANK;                                                       00934000
MIO'ADDR := ADDR;                                                       00936000
MIO'COUNT := COUNT;                                                     00938000
MIO'RETRY := 0;                                                         00940000
                                                                        00942000
MIO'INITIATOR(DRT,DITP,SIOP,           << START CURRENT REQUEST >>      00944000
              FCTN,BANK,ADDR,COUNT);                                    00946000
                                                                        00948000
GOOD'EXIT:                                                              00950000
CC := IF LOGICAL(MIO'STATUS.EOT)  THEN  CCG                    <<01150>>00952000
                                  ELSE  CCE;                   <<01150>>00954000
END;                                                                    00956000
$PAGE "     MEASUREMENT I/O SYSTEM -- INITIATOR"                        00958000
PROCEDURE MIO'INITIATOR(DRT,DITP,SIOP,FCTN,BANK,ADDR,COUNT);            00960000
   VALUE DRT, DITP, SIOP, FCTN, BANK, ADDR, COUNT;                      00962000
   INTEGER DRT, FCTN, COUNT;                                            00964000
   LOGICAL BANK, ADDR;                                                  00966000
   INTEGER POINTER DITP, SIOP;                                          00968000
   OPTION PRIVILEGED, UNCALLABLE, INTERNAL;                             00970000
BEGIN                                                                   00972000
                                                                        00974000
INTEGER I;                                                              00976000
DOUBLE POINTER SIOPD=SIOP;                                              00978000
                                                                        00980000
IF NOT (-1 <= FCTN <= 4) THEN RETURN;  << INVALID FUNCTION >>           00982000
                                                                        00984000
DISABLE;                                                                00986000
                                                                        00988000
CASE *(FCTN+1) OF                                                       00990000
   BEGIN                               << BUILD SIO PROGRAM >>          00992000
                                                                        00994000
   BEGIN                               << FCTN = -1 -- BSR/GAP >>       00996000
   SIOPD(2) := [16/CONTROL'ORDER, 16/BSR]D;                             00998000
   SIOPD(3) := [16/CONTROL'ORDER, 16/GAP]D;                             01000000
   I := 4;                                                              01002000
   END;                                                                 01004000
                                                                        01006000
   BEGIN                               << FCTN = 0 -- IGNORE >>         01008000
   RETURN;                                                              01010000
   END;                                                                 01012000
                                                                        01014000
   BEGIN                               << FCTN = 1 -- WRITE >>          01016000
   SIOPD(2) := [16/CONTROL'ORDER, 16/WRR]D;                             01018000
   I := 3;                                                              01020000
   WHILE COUNT > 4096 DO                                                01022000
      BEGIN                                                             01024000
      TOS := WRT'CHAIN'ORDER;                                           01026000
      TOS := ADDR;                                                      01028000
      SIOPD(I) := TOS;                                                  01030000
      I := I + 1;                                                       01032000
      ADDR := ADDR + 4096;                                              01034000
      COUNT := COUNT - 4096;                                            01036000
      END;                                                              01038000
   TOS := WRITE'ORDER + (4096 - COUNT);                                 01040000
   TOS := ADDR;                                                         01042000
   SIOPD(I) := TOS;                                                     01044000
   I := I + 1;                                                          01046000
   END;                                                                 01048000
                                                                        01050000
   BEGIN                               << FCTN = 2 -- TAPE MARK >>      01052000
   SIOPD(2) := [16/CONTROL'ORDER, 16/WFM]D;                             01054000
   I := 3;                                                              01056000
   END;                                                                 01058000
                                                                        01060000
   BEGIN                               << FCTN = 3 -- REWIND >>         01062000
   SIOPD(2) := [16/CONTROL'ORDER, 16/REW]D;                             01064000
   I := 3;                                                              01066000
   END;                                                                 01068000
                                                                        01070000
   BEGIN                               << FCTN = 4 -- RESET >>          01072000
   SIOPD(2) := [16/CONTROL'ORDER, 16/RST]D;                             01074000
   I := 3;                                                              01076000
   END;                                                                 01078000
                                                                        01080000
   END;  << OF CASE STATEMENT >>                                        01082000
                                                                        01084000
SIOP    := SET'BANK'ORDER;             << FINISH SIO PROGRAM >>         01086000
SIOP(1) := BANK;                                                        01088000
SIOP(2) := CONTROL'ORDER;                                               01090000
SIOP(3) := MIO'UNIT&LSL(8);                                             01092000
SIOPD(I) := [16/END'INT'ORDER, 16/%177777]D;                            01094000
                                                                        01096000
TOS := DRT;                                                             01098000
TOS := %40000;                                                          01100000
ASSEMBLE(CIO 1);                       << RESET PENDING INTERRUPTS >>   01102000
IF < THEN IOFAILURE(DRT,DITP);                                          01104000
                                                                        01106000
TOS := @SIOP + SYSDB;                                                   01108000
ASSEMBLE(SIO 1);                       << START I/O PROGRAM >>          01110000
IF <> THEN IOFAILURE(DRT,DITP);                                         01112000
DEL;                                   << DELETE DRT NUMBER >>          01114000
                                                                        01116000
MIO'STATE := IF FCTN >= 0 THEN 1       << SET DEVICE STATE >>           01118000
                          ELSE 2;                                       01120000
END;                                                                    01122000
$PAGE "     MEASUREMENT I/O SYSTEM -- COMPLETOR"                        01124000
PROCEDURE MIO'COMPLETOR(DRT,DITP,SIOP);                                 01126000
   VALUE DRT, DITP, SIOP;                                               01128000
   INTEGER DRT;                                                         01130000
   INTEGER POINTER DITP, SIOP;                                          01132000
   OPTION PRIVILEGED, UNCALLABLE, INTERNAL;                             01134000
BEGIN                                                                   01136000
                                                                        01138000
INTEGER ERR'CODE;                                                       01140000
                                                                        01142000
ERR'CODE := MIO'STATUS.(12:3);         << GET ERROR CODE >>             01144000
                                                                        01146000
CASE MIO'STATE OF                                                       01148000
   BEGIN                               << CASE ON STATE >>              01150000
                                                                        01152000
   BEGIN                               << 0 -- NO ACTIVITY >>           01154000
   IF ERR'CODE <> 0 THEN MIO'STATE := -1;                               01156000
   END;                                                                 01158000
                                                                        01160000
   BEGIN                               << 1 -- I/O IN PROGRESS >>       01162000
   IF ERR'CODE = 7 THEN                                                 01164000
      MIO'STATE := 0                   << NO ERROR >>                   01166000
   ELSE IF (ERR'CODE=4 OR ERR'CODE=5) AND                               01168000
           (MIO'FCTN=1 OR MIO'FCTN=2) AND                               01170000
           (MIO'RETRY:=MIO'RETRY+1) <= 2 THEN                           01172000
      BEGIN                            << RECOVERABLE ERROR >>          01174000
      MIO'INITIATOR(DRT,DITP,SIOP,-1,0,0,0);                            01176000
      END                                                               01178000
   ELSE                                                                 01180000
      MIO'STATE := -1;                 << IRRECOVERABLE ERROR >>        01182000
   END;                                                                 01184000
                                                                        01186000
   BEGIN                               << 2 -- BACKSPACE/GAP >>         01188000
   IF ERR'CODE = 7 THEN                                                 01190000
      BEGIN                            << RETRY PREVIOUS I/O >>         01192000
      MIO'INITIATOR(DRT,DITP,SIOP,                                      01194000
                    MIO'FCTN,MIO'BANK,MIO'ADDR,MIO'COUNT);              01196000
      END                                                               01198000
   ELSE                                                                 01200000
      MIO'STATE := -1;                 << FAILURE ON BSR/GAP >>         01202000
   END;                                                                 01204000
                                                                        01206000
   END;                                << END OF CASE >>                01208000
END;                                                                    01210000
$PAGE "     MEASUREMENT I/O SYSTEM -- INTERRUPT PROCESSOR"              01212000
PROCEDURE MIO'INTRPT'PROC;                                              01214000
   OPTION PRIVILEGED, UNCALLABLE, INTERRUPT;                            01216000
BEGIN                                                                   01218000
                                                                        01220000
INTEGER DRT=Q+3, STAT=Q+4, UNIT=Q+5;                                    01222000
INTEGER POINTER DITP=Q+6, SIOP=Q+7;                                     01224000
INTEGER ILT'SIOP=DB+%10;                                       <<01300>>01226000
INTEGER ARRAY ILT'DITP(*)=DB+%16;                              <<01300>>01228000
INTEGER ARRAY DUMMY'DITP(*)=DB+7;                              <<01300>>01230000
                                                                        01232000
ASSEMBLE(TIO 0);                       << GET HARDWARE STATUS >>        01234000
IF < THEN IOFAILURE(DRT,DUMMY'DITP);                                    01236000
                                                                        01238000
TOS := S0.(3:2);                       << EXTRACT UNIT NUMBER >>        01240000
                                                                        01242000
TOS := ILT'DITP(UNIT);                 << GET DIT POINTER >>            01244000
IF <= THEN RETURN;                     << UNCONFIGURED UNIT >>          01246000
                                                                        01248000
TOS := ILT'SIOP;                       << GET SIO POINTER >>            01250000
                                                                        01252000
TOS := SYSDB D;                                                         01254000
ASSEMBLE(XCHD);                        << SET SYSTEM DB >>              01256000
                                                                        01258000
IF UNIT <> MIO'UNIT THEN RETURN;       << WRONG UNIT INTERRUPTED >>     01260000
                                                                        01262000
DISABLE;                                                                01264000
MIO'STATUS := STAT;                    << SAVE HARDWARE STATUS >>       01266000
MIO'COMPLETOR(DRT,DITP,SIOP);          << CALL COMPLETOR >>             01268000
END;                                                                    01270000
$PAGE "     MEASUREMENT I/O SYSTEM -- DATA INITIALIZATION"              01272000
PROCEDURE MIO'INIT(LDEV);                                               01274000
   VALUE LDEV;                                                          01276000
   INTEGER LDEV;                                                        01278000
   OPTION PRIVILEGED, UNCALLABLE;                                       01280000
BEGIN                                                                   01282000
                                                                        01284000
<< This procedure initializes the DRT, DIT, and SIO program area   >>   01286000
<< as required by the Series III Measurement I/O System.           >>   01288000
<<                                                                 >>   01290000
<< Parameter:                                                      >>   01292000
<<    LDEV -- An integer containing the measurement logical device >>   01294000
<<            number in bits (8:8) and a "unit downed" bit map in  >>   01296000
<<            bits (0:4).  Bits (4:4) are not used.                >>   01298000
                                                                        01300000
INTEGER DRT;                                                            01302000
INTEGER POINTER DITP, ILTP, SIOP;                                       01304000
                                                                        01306000
DISABLE;                                                                01308000
TOS := SYSDB D;                                                         01310000
ASSEMBLE(XCHD);                        << SET DB TO SYSDB >>            01312000
                                                                        01314000
@DITP := LPDT(LDEV.(8:8)&LSL(1));      << SET UP POINTERS >>            01316000
@ILTP := DITP(5);                                                       01318000
@SIOP := ILTP(%10);                                            <<01300>>01320000
DRT := ILTP(7).(8:8);                                          <<01300>>01322000
                                                                        01324000
MIO'STATUS := 0;                       << INITIALIZE DIT >>             01326000
MIO'STATE  := 0;                                                        01328000
MIO'RETRY  := 0;                                                        01330000
                                                                        01332000
MIO'LDEV := LDEV;                      << INITIALIZE SIO AREA >>        01334000
MIO'UNIT := DITP(3).(0:8);                                              01336000
MIO'ENABLE := "OK";                                                     01338000
                                                                        01340000
ABSOLUTE(DRT&LSL(2)+1) :=              << INITIALIZE DRT >>             01342000
   @MIO'INTRPT'PROC;                                                    01344000
                                                                        01346000
ASSEMBLE(XCHD);                        << RESET DB >>                   01348000
END;                                                                    01350000
$PAGE "     MEASUREMENT I/O SYSTEM -- RESET DATA"                       01352000
INTEGER PROCEDURE MIO'RESET(LDEV);                                      01354000
   VALUE LDEV;                                                          01356000
   INTEGER LDEV;                                                        01358000
   OPTION PRIVILEGED, UNCALLABLE;                                       01360000
BEGIN                                                                   01362000
                                                                        01364000
<< This procedure resets the DRT, DIT, and SIO program area for    >>   01366000
<< use by the Series III I/O system.                               >>   01368000
<<                                                                 >>   01370000
<< Parameter:                                                      >>   01372000
<<    LDEV -- An integer containing the measurement logical device >>   01374000
<<            number in bits (8:8).  Bits (0:8) are not used.      >>   01376000
<<                                                                 >>   01378000
<< Result:                                                         >>   01380000
<<    An integer containing the measurement logical device number  >>   01382000
<<    in bits (8:8) and the "unit downed" bit map in bits (0:4).   >>   01384000
                                                                        01386000
INTEGER DRT;                                                            01388000
INTEGER POINTER DITP, ILTP, SIOP;                                       01390000
                                                                        01392000
DISABLE;                                                                01394000
TOS := SYSDB D;                                                         01396000
ASSEMBLE(XCHD);                        << SET DB TO SYSDB >>            01398000
                                                                        01400000
@DITP := LPDT(LDEV.(8:8)&LSL(1));      << SET UP POINTERS >>            01402000
@ILTP := DITP(5);                                                       01404000
@SIOP := ILTP(%10);                                            <<01300>>01406000
DRT := ILTP(7).(8:8);                                          <<01300>>01408000
                                                                        01410000
MIO'RESET := MIO'LDEV;                 << RETURN DOWNED UNIT FLAGS >>   01412000
                                                                        01414000
MOVE DITP(6) := (3(0));                << RESET DIT >>                  01416000
                                                                        01418000
MOVE SIOP := (SET'BANK'ORDER, 0,       << RESET SIO AREA >>             01420000
              CONTROL'ORDER,  0,                                        01422000
              CONTROL'ORDER,  0,                                        01424000
              34(0)            );                                       01426000
                                                                        01428000
ABSOLUTE(DRT&LSL(2)+1) :=              << RESET DRT >>                  01430000
   @GIP;                                                                01432000
                                                                        01434000
ASSEMBLE(XCHD);                        << RESET DB >>                   01436000
END;                                                                    01438000
$CONTROL SEGMENT=SEG'                                          <<01549>>01440000
END.                                                           <<01549>>01442000
