         << LINES .001/.009 ARE RESERVED FOR SYSTEMS INTEGRATION >>     00000001
                                                               <<09421>>00071000
COMMENT --                                                     <<09421>>00072000
**********************************************************************  00075000
|Jesse Chin       8/28/84  Fix problem with handling IOQ'ABORT.      |  00121010
|                          BR#530, SR#115204                         |  00121020
|Jesse Chin       9/11/84  Fix problem in Initiator IOQ'ABORT        |  00121030
|                          BR#857, SR#124685 (part of it).           |  00121040
|Frank Weger      9/17/84  DIT'IGNORE'INT change in Initiator        |  00121050
|Larry Byler/    10/ 3/84  Recover lost on-line interrupts:          |  00121060
|  Gary O'Neall              1.  SIODM now bypasses State 6 when set |  00121070
|                                by GIP, iff driver's                |  00121080
|                                DITP(DUNIT).(3:1) is set.  Means    |  00121090
|                                that driver is smart enough to exit |  00121100
|                                into State 6 when AVR is needed.    |  00121110
|                            2.  DIT'IGNORE'INT deleted.  Not needed |  00121120
|                                because (1.) assures no unwanted    |  00121130
|                                interrupts.                         |  00121140
|                            3.  HIOCTAP1 exits into state 6 when an |  00121150
|                                on line or off line has been detect-|  00121160
|                                ed -AND- all IOQ's have been com-   |  00121170
|                                pleted.                             |  00121180
|Jesse Chin      11/06/84  Powerfail lost data during STORE.         |  00121190
|                BR#1094, SR#132126                                  |  00121200
|                Using DIT.DMISC(5:1) to indicate last operation was |  00121210
|                WRITE. Also use DIT.DMISC(6:1) if powerfail during  |  00121220
|                executing of idle, this bit means that driver PFAIL |  00121230
|                the next operation.                                 |  00121240
|Jesse Chin      11/28/84  Buffalo loses online interrupt when DSTAT |  00121250
|                          on Buffalo. BR#1177, SR#135475            |  00121260
|                CPVA'STATUS = 2 used in powerfail logic will cause  |  00121270
|                later code to lose a pending interrupt for buffalo  |  00121280
|                (see line 25977 for logic depending on CPVA'STATUS) |  00121290
|Frank Weger     11/12/84  Add FCODE 78                        <<f9442>>00122000
|                                                                    |  00122100
|Frank Weger     12/10/84  Continuator, XFER'CNT now updated before  |  00122200
|                          return with powerfail abort on write.     |  00122300
|Frank Weger     12/17/84  Changes to write protect logic. SR#136481.|  00122400
|Jesse Chin      01/15/85  fix problem with infinite retries SR141432|  00122500
|                          BR#1278, also add logic in WRITE'PROTECT, |  00122600
|                          don't abort request for READ function     |  00122700
|Frank Weger     01/16/85  Changes to byte count conversion logic.   |  00123000
|Ross McDonald   01/27/86  Need to re-initialize device after system |  00123100
|                          powerfail if device is not locked.        |  00123200
|                          SR#4700-169292  Patch #I027               |  00123300
|Jim Quintenz    01/27/86  Don't zero the DIT's 20 bytes of status if|  00123400
|                          this is a retry, because it will be logged|  00123500
|                          by SIODM in HARDRES.  SR#4700-162990.     |  00123600
|                          SCO#I027.  (Line#22615)                   |  00123700
|Cynthia Kay     05/7/86   sr#4700-255554                      <<c2238>>00123800
|                          The Buffalo would hang when the self-test |  00123900
|                     button was pressed because the driver was      |  00124000
|                     denying release.  In both the Initiator and    |  00124100
|                     Continutator sections, the driver would check  |  00124200
|                     for release bits set after a request status    |  00124300
|                     but - it forgot to check for the  diag release |  00124400
|                     request bit (DIT'I'DIAG'REL'REQ).  I added the |  00124500
|                     two lines in each section to do that.          |  00124600
|Cynthia Kay     05/7/86   SR#4700-255562                      <<c2238>>00124700
|                          The write protect status of a cartridge   |  00124800
|                     was recorded incorrectly in the function code  |  00124900
|                     Request Genereic Status.  I changed it so the  |  00125000
|                     status is now correct.                         |  00125100
|Cynthia Kay     05/7/86   SR#4700-255570                      <<c2238>>00125200
|                          The bit IOT in word DUNIT of the DIT      |  00125300
|                     should be a 1.  This identifies the Buffalo as |  00125400
|                     an HPIB device.  A zero in this bit identifies |  00125500
|                     it as a SIO device, which it is not.           |  00125600
|                     Other procedures outside of the driver use this|  00125700
|                     IOT bit.                                       |  00125800
      then calls P'ATTACHIO which in turn calls SIODM.         <<09421>>00780000
      SIODM freezes the data segment (if any)                  <<09421>>00785000
      calls AWAKEIO which calls SIODM.  SIODM calls the driver.<<09421>>00815000
$EDIT VOID=01525000                                            <<09421>>01505000
         The lock flag is initialized.  If TRUE, an operator   <<09421>>01506000
         release request will be denied, that is, the operator <<09421>>01507000
         will not be allowed to unload the device.  In the     <<09421>>01508000
         general CS80 case, the lock flag is set TRUE for sys- <<09421>>01509000
         tem volumes and is never cleared while the system is  <<09421>>01510000
         running (system volumes may not be dismounted).  For  <<09421>>01511000
         non-system volumes the lock flag is initialized FALSE <<09421>>01512000
         and is then managed by appropriate function calls to  <<09421>>01513000
         the driver.  Since the cartridge tape is supported    <<09421>>01514000
         only as a serial disc (non-system) device, BUFFALO'   <<09421>>01515000
         INIT should always initialize this flag to FALSE,     <<09421>>01516000
         however the system/non-system bit is always checked,  <<09421>>01517000
         just in case.  BUFFALO'INIT then initializes          <<09421>>01518000
                                                               <<f9442>>03600100
                                                               <<f9442>>03600200
          o DESCRIBE (function code 78)                        <<f9442>>03601000
                                                               <<f9442>>03601100
              This request returns the describe bytes from     <<f9442>>03602000
              the device.                                      <<f9442>>03603000
                                                               <<f9442>>03603100
              The transfer count must be non-zero and will     <<f9442>>03604000
              be considered invalid if not.  The maximum       <<f9442>>03605000
              number of bytes returned is 37.  A transfer      <<f9442>>03606000
              count greater than 37 will not be considered     <<f9442>>03607000
              an error and the 37 describe bytes will be       <<f9442>>03608000
              returned.  (Refer to the CS/80 Instruction       <<f9442>>03609000
              Set manual for definition and layout of the      <<f9442>>03609100
              device describe bytes.)                          <<f9442>>03609200
                                                               <<f9442>>03609300
    10    | IOT |  |AV|           | Physical Unit #       |  DUNIT      04610000
    11    |LK|NR|IM|PI|RG|LW|MP|              | SUBSTATE  |  DMISC      04620000
      DQTAIL - Not used.                                       <<09421>>04970000
                                                               <<09421>>04975000
      DUNIT - IOT      - I/O Type.  01 for this device.        <<c2238>>04975100
              AV       - AVR flag.  Set by driver,  tested  by <<09421>>04975200
                         SIODM.                                <<09421>>04975300
                         1 - Driver  can   detect   unexpected <<09421>>04975400
                             (AVR) conditions and will exit to <<09421>>04975500
                             SIODM State 6  when  safe.  SIODM <<09421>>04975600
                             should bypass State 6 when called <<09421>>04975700
                             from GIP.  New functionality.     <<09421>>04975800
                         0 - Driver cannot detect  AVR  condi- <<09421>>04975900
                             tion.  SIODM should honor a State <<09421>>04976000
                             6 call from GIP.  Previous  func- <<09421>>04976100
                             tionality.                        <<09421>>04976200
              Unit     - Unit number for  multi-unit  control- <<09421>>04976300
                         lers.  Always 0 for this driver.      <<09421>>04976400
              NR       - Not Ready.  Remembers  the  state  of <<09421>>05010000
                         DIT'DEV'NOT'RDY  the last time status <<09421>>05010100
                         was read from the  device.  Used  for <<09421>>05010200
                         detecting off-line transitions.       <<09421>>05010300
              PI       - Pending  Interrupt.  Device  came  on <<09421>>05025100
                         line while driver was waiting on com- <<09421>>05025200
                         mand completion (i.e.,  not  in  idle <<09421>>05025300
                         CP).  On  line  interrupt was used to <<09421>>05025400
                         complete  command,  so  SIODM  didn't <<09421>>05025500
                         wake  DEVREC.  The interrupt also set <<09421>>05025600
                         this bit.  If the  bit  is  set  when <<09421>>05025700
                         SIODM  starts  the idle CP, we return <<09421>>05025800
                         the  Unexpected  Interrupt  state  so <<09421>>05025900
                         that SIODM will wake DEVREC.          <<09421>>05026000
              RG       - Release Granted.  Device requested  a <<09421>>05026100
                         release  and  driver  O.K.'ed it.  If <<09421>>05026200
                         this bit is set when we are ready  to <<09421>>05026300
                         start  the idle CP, we issue a status <<09421>>05026400
                         request CP instead.  This is  because <<09421>>05026500
                         the  device  does  not set a DSJ of 2 <<09421>>05026600
                         when completing the  release  due  to <<09421>>05026700
                         coming on line! It needs an addition- <<09421>>05026800
                         al command to do so.  The status  re- <<09421>>05026900
                         quest  CP  ensures that we finish all <<09421>>05027000
                         on line processing before we exit.    <<09421>>05027100
              LW       - Last operation is a WRITE.            <<J9456>>05028010
              MP       - Must Powerfail the next operation.    <<J9456>>05028020
$EDIT VOID=07645000                                            <<09421>>07585000
    Earlier versions of this driver (as well as other CS80 de- <<09421>>07586000
    vice drivers) had to deal with so-called unexpected inter- <<09421>>07587000
    rupts, that is, interrupts generated by the device but not <<09421>>07588000
    in response to a driver-initiated I/O request. Historical- <<09421>>07589000
    ly, the only such interrupts before CS80 came  along  were <<09421>>07590000
    on  line and off line interrupts which should cause DEVREC <<09421>>07591000
    and PVPROC to run.                                         <<09421>>07592000
      With CS80 came other unexpected interrupts (release  re- <<09421>>07593000
    quests for internal maintenance, etc.).  DEVREC and PVPROC <<09421>>07594000
    are not interested in these. Trouble is, GIP and SIODM had <<09421>>07595000
    already AWAKEned DEVREC.  The best the driver could do was <<09421>>07596000
    support a cumbersome mechanism to tell PVPROC "Hey I real- <<09421>>07597000
    ly didn't mean it" when PVPROC came to call.               <<09421>>07598000
      By enlisting SIODM's co-operation, this version  of  the <<09421>>07599000
    driver has eliminated all that.  When GIP calls SIODM with <<09421>>07600000
    State 6 (Unexpected Interrupt), SIODM examines a previous- <<09421>>07601000
    ly unused DIT bit (DITP(DUNIT).(3:1)) which has  been  re- <<09421>>07602000
    served for this function.  Drivers which can tell the dif- <<09421>>07603000
    ference between on line/off line interrupts and other  un- <<09421>>07604000
    expected interrupts set this bit.  SIODM then goes direct- <<09421>>07605000
    ly to State 0, bypassing State 6. If the driver determines <<09421>>07606000
    that this interrupt should cause DEVREC to run,  it  exits <<09421>>07607000
    to State 6 of SIODM. If the interrupt came about while the <<09421>>07608000
    driver was processing an I/O request, it is deferred until <<09421>>07609000
    all IOQ entries for the device have been processed.        <<09421>>07610000
      Drivers which have not been enhanced initialize this bit <<09421>>07611000
    to 0, so SIODM works the way it did before for those driv- <<09421>>07612000
    ers (backward compatible).                                 <<09421>>07613000
Describe                 78      Count - Describe length       <<f9442>>08355100
                                                               <<f9442>>08355200
                                 Bank & Buffaddr returns       <<f9442>>08355300
                                 with the describe data        <<f9442>>08355400
                                                               <<f9442>>08355500
;                                                              <<09421>>08845000
$PAGE "MPE TABLE ACCESS:  I/O QUEUE HEAD (SBH)"                <<09421>>08865000
$PAGE "MPE TABLE ACCESS:  I/O QUEUE (IOQ)"                     <<09421>>08900000
$PAGE    "QMISC bit definitions"                               <<09421>>08935000
$PAGE  "Device Information Table (DIT)"                        <<09421>>09050000
   DUNIT'AV'BIT           = ( 3:1)#,                           <<09421>>09256000
   DUNIT'IO'BIT           = ( 0:2)#,                           <<c2238>>09259000
   DMISC'NR'BIT           = ( 1:1)#,                           <<09421>>09265000
   DMISC'PI'BIT           = ( 3:1)#,                           <<09421>>09271000
   DMISC'RG'BIT           = ( 4:1)#,                           <<09421>>09272000
   DMISC'LW'BIT           = ( 5:1)#,                           <<J9456>>09273000
   DMISC'MP'BIT           = ( 6:1)#,                           <<J9456>>09273010
   DIT'DVR'DETECTS'AVR  =  P'DIT (DUNIT       ).DUNIT'AV'BIT#, <<09421>>09561000
   DIT'IO'TYPE          =  P'DIT (DUNIT       ).DUNIT'IO'BIT#, <<c2238>>09561100
   DIT'NOT'RDY'EARLIER  =  P'DIT (DMISC       ).DMISC'NR'BIT#, <<09421>>09570000
   DIT'PENDING'INTERRUPT=  P'DIT (DMISC       ).DMISC'PI'BIT#, <<09421>>09576000
   DIT'RELEASE'GRANTED  =  P'DIT (DMISC       ).DMISC'RG'BIT#, <<09421>>09577000
   DIT'LAST'WAS'WRITE   =  P'DIT (DMISC       ).DMISC'LW'BIT#, <<J9456>>09578010
   DIT'MUST'PF'NEXT     =  P'DIT (DMISC       ).DMISC'MP'BIT#, <<J9456>>09578020
$PAGE   "Driver function codes"                                <<09421>>09820000
$PAGE   "IOQ Status return values"                             <<09421>>10000000
$PAGE  "Interrupt Linkage Table (ILT)"                         <<09421>>10135000
$PAGE  "Generic Status elements"                               <<09421>>10285000
$PAGE  "Type, subtype, CS80 and device commands"               <<09421>>10365000
$PAGE  "SIOP-relative channel program section offsets"         <<09421>>10635000
   CHAN'CLEAR    = PON+19,       << Channel clear offset    >> <<09421>>10701000
   STAT'CDB      = CHAN'CLEAR+19,<< Identify section offset?>> <<09421>>10705000
                                                               <<09421>>10790000
                                                               <<09421>>10791000
   ENTER'CHAN'CLEAR=CHAN'CLEAR-CP'BASE,<< Power on (up) entry  <<09421>>10840000
$PAGE  "CP offsets within sections"                            <<09421>>10850000
   CP'CCLR'CDB'OFFSET      = SIOP(CHAN'CLEAR+4 )      #,       <<09421>>11001000
   CP'CCLR'CDB'2'OFFSET    = SIOP(CHAN'CLEAR+16)      #,       <<09421>>11002000
$PAGE  "CS'80 BUFFALO DRIVER - HPIB"                           <<09421>>11015000
   UNXPCT'INTERRUPT =   6,  << Unexpected interrupt         >> <<09421>>11116000
$EDIT VOID=11250000                                            <<09421>>11250000
   FOUR               = 4,                                     <<09421>>11275000
   FIVE               = 5;       << continuing the madness  >> <<09421>>11276000
$PAGE "   Channel Program area"                                <<09421>>11595000
<< 2>>  << INT/HLT0 >>  %601, << Interrupt/halt        >>      <<09421>>11905000
<<17>>  << INT/HLT2 >>  %601, << Interrupt/halt        >>      <<09421>>12500000
$PAGE                                                          <<09421>>12505100
   <<-------------------------------------------------->>      <<09421>>12505200
   << [CHAN'CLEAR] Chennel independent clear, and      >>      <<09421>>12505300
   << turn parity on.  Same as PON except for CPVA(1)  >>      <<09421>>12505400
   << return code.  Separates Channel Clear from pend- >>      <<09421>>12505410
   << ing interrupt phenomena.                         >>      <<09421>>12505420
   <<-------------------------------------------------->>      <<09421>>12505500
                                                               <<09421>>12505600
<< 0>>  << WRITE TRAN>>%4002, << Trans msg secondary   >>      <<09421>>12505700
<< 1>>                     2, << Cmd buffer length     >>      <<09421>>12505800
<< 2>>                     0, << No Burst              >>      <<09421>>12505900
<< 3>>  <<CI CLEAR >>  %2000, << Cmd buffer bank       >>      <<09421>>12506000
<< 4>>                     0, << Cmd buffer abs addr   >>      <<09421>>12506100
                                                               <<09421>>12506200
<< 5>>  << WAIT >>     %1000, << Wait for PPOLL        >>      <<09421>>12506300
<< 6>>                     0,                                  <<09421>>12506400
                                                               <<09421>>12506500
<< 7>>  << DSJ >>      %2402, << Reporting msg secondary>>     <<09421>>12506600
<< 8>>                     0, << Return byte           >>      <<09421>>12506700
<< 9>>                     0, << Normal completion     >>      <<09421>>12506800
<<10>>                   -68, << Hard error /req status>>      <<09421>>12506900
<<11>>                   -31, << Power on occurred     >>      <<09421>>12507000
                                                               <<09421>>12507100
<<12>>  << WRITE TRAN>>%4002, << Trans msg secondary   >>      <<09421>>12507200
<<13>>                     2, << Cmd buffer length     >>      <<09421>>12507300
<<14>>                     0, << No Burst              >>      <<09421>>12507400
<<15>>                 %2000, << Cmd buffer bank       >>      <<09421>>12507500
<<16>>                     0, << Cmd buffer abs addr   >>      <<09421>>12507600
                                                               <<09421>>12507700
<<17>>  << INT/HLT5 >>  %601, << Interrupt/halt        >>      <<09421>>12507800
<<18>>                     5, << Code of 5 in CPVA(1)  >>      <<09421>>12507900
$PAGE "   External procedure declarations"                     <<09421>>12760000
                                                               <<09421>>13016000
PROCEDURE HELP;                                                <<09421>>13017000
   OPTION EXTERNAL;                                            <<09421>>13018000
$PAGE "   Procedure BUFFALO'INIT"                              <<09421>>13020000
       << Need to re-initialize after powerfail >>             <<01924>>13198000
       <<         if device is not locked       >>             <<01924>>13199000
     if spu'powerfail <> 0 and logical(dit'lock'flg) then      <<01924>>13200000
        return;                                                <<01924>>13205000
$EDIT VOID=13250000                                            <<09421>>13220000
                                                               <<09421>>13221000
<< Lock device only if it's a system volume (don't ask  why >> <<09421>>13222000
<< it's a system volume).                                   >> <<09421>>13223000
                                                               <<09421>>13224000
DIT'LOCK'FLG := NOT LPDT'NON'SYS'DOMAIN;                       <<09421>>13225000
DIT'PENDING'INTERRUPT := FALSE;                                <<09421>>13251000
DIT'NOT'RDY'EARLIER   := FALSE;                                <<09421>>13252000
<<  DIT'IO'TYPE =1 identifies Buffalo as as HPIB device >>     <<c2238>>13252005
DIT'IO'TYPE := 1;                                              <<c2238>>13252100
DIT'DVR'DETECTS'AVR   := TRUE;  << We're a sma-a-art driver >> <<09421>>13253000
CP'CCLR'CDB'OFFSET   := @SIOP  + SYSDB + PON'CDB'1;            <<09421>>13291000
CP'CCLR'CDB'2'OFFSET := @SIOP  + SYSDB + PON'CDB'2;            <<09421>>13292000
CP'FIRST'BRANCH      := ENTER'CHAN'CLEAR;                      <<09421>>13295000
$PAGE "   BUFFALO'DRIVER - local declarations"                 <<09421>>13345000
<<     6 - Unexpected (AVR) interrupt                      >>  <<09421>>13426000
$PAGE                                                          <<09421>>13620000
                                                               <<09421>>13665100
<<---------------------------------------------------->>       <<09421>>13665200
<<   Map from external to internal function code      >>       <<09421>>13665300
<<                                                    >>       <<09421>>13665400
<<   Function code 0 -4  --> Internal code 0 -4       >>       <<09421>>13665500
<<   Function code 5     --> Internal code 1          >>       <<09421>>13665600
<<   Function code 6     --> Internal code 1          >>       <<09421>>13665700
<<   Function code 7 -9  --> Internal code 5 -7       >>       <<09421>>13665800
<<   Function code 11    --> Internal code 1          >>       <<09421>>13665900
<<   Function code 13-18 --> Internal code 8 -13      >>       <<09421>>13666000
<<   Function code 29    --> Internal code 14         >>       <<09421>>13666100
<<   Function code 72-73 --> Internal code 15-16      >>       <<09421>>13666200
<<   Function code 74    --> Internal code 5          >>       <<09421>>13666300
<<   Function code 75-76 --> Internal code 17-18      >>       <<09421>>13666400
<<   Function code 78    --> Internal code 8          >>       <<f9442>>13666410
<<   Function code 79-82 --> Internal code 19-22      >>       <<09421>>13666500
<<   Function code 88    --> Internal code 23         >>       <<09421>>13666600
<<   Function code 91-94 --> Internal code 24-27      >>       <<09421>>13666700
<<   Function code 95    --> Internal code 5          >>       <<09421>>13666800
<<   Function code 100   --> Internal code 28         >>       <<09421>>13666900
<<   Function code 101   --> Internal code 25         >>       <<09421>>13667000
<<---------------------------------------------------->>       <<09421>>13667100
                                                               <<09421>>13667200
EQUATE                                                         <<09421>>13667300
   MAX'IOQ'FUNC       = 101,                                   <<09421>>13667400
   UNDEFINED'IOQ'FUNC =  -1;                                   <<09421>>13667410
                                                               <<09421>>13667500
LOGICAL ARRAY  << Can't use BYTE ARRAY, can't do PB-rel LDB >> <<09421>>13667600
   IOQ'FUNC'TO'FCODE(0:MAX'IOQ'FUNC) = PB :=                   <<09421>>13667700
                                                               <<09421>>13667800
<< IOQ'FUNC                                                 >> <<09421>>13667900
<<     UNITS  0    1    2    3    4    5    6    7    8    9>> <<09421>>13668000
<<  TENS                                                    >> <<09421>>13668100
<<    0 >>    0,   1,   2,   3,   4,   1,   1,   5,   6,   7,  <<09421>>13668200
<<    1 >>   -1,   1,  -1,   8,   9,  10,  11,  12,  13,  -1,  <<09421>>13668300
<<    2 >>   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  14,  <<09421>>13668400
<<    3 >>   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  <<09421>>13668500
<<    4 >>   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  <<09421>>13668600
<<    5 >>   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  <<09421>>13668700
<<    6 >>   -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  <<09421>>13668800
<<    7 >>   -1,  -1,  15,  16,   5,  17,  18,  -1,   8,  19,  <<f9442>>13668900
<<    8 >>   20,  21,  22,  -1,  -1,  -1,  -1,  -1,  23,  -1,  <<09421>>13669000
<<    9 >>   -1,  24,  25,  26,  27,   5,  -1,  -1,  -1,  -1,  <<09421>>13669100
<<   10 >>   28,  25;                                          <<09421>>13669200
$PAGE "   BUFFALO'DRIVER - subroutine SIOP'BYTE"               <<09421>>13670000
$PAGE "   BUFFALO'DRIVER - subroutine UPDATE'XFER'CNT"         <<09421>>13785000
$PAGE "   BUFFALO'DRIVER - subroutine ABORTING"                <<09421>>13956010
<<---------------------------->>                               <<J9110>>13956020
<<   ABORTING  -- Completor   >>                               <<J9110>>13956030
<<---------------------------->>                               <<J9110>>13956040
                                                               <<J9110>>13956050
LOGICAL SUBROUTINE ABORTING;                                   <<J9110>>13956060
BEGIN                                                          <<J9110>>13956070
  IF P'IOQ <> 0 AND IOQ'ABORT THEN                             <<J9110>>13956080
  BEGIN                                                        <<J9110>>13956090
<< don't PFAIL the READ operation >>                           <<09574>>13956091
    if ioq'pfail=1 and fcode=fc'read then                      <<09574>>13956092
    begin                                                      <<09574>>13956093
      ioq'pfail := 0;                                          <<09574>>13956094
      ioq'abort := 0;                                          <<09574>>13956095
      aborting := false;                                       <<09574>>13956096
      return;                                                  <<09574>>13956097
    end;                                                       <<09574>>13956098
    IOQ'STAT := IF IOQ'PFAIL=1 THEN POWERFAIL'ABORT            <<J9456>>13956100
                ELSE SYSTEM'ABORT;                             <<J9456>>13956101
    DRIVER'STATE := REQUEST'COMPLETE;                          <<J9110>>13956110
    IOQ'WAITCODE := 0;                                         <<J9110>>13956120
                                                               <<J9195>>13956130
    UPDATE'XFER'CNT;                                           <<J9110>>13956140
    ABORTING := TRUE;                                          <<J9110>>13956150
  END                                                          <<J9110>>13956160
  ELSE ABORTING := FALSE;                                      <<J9110>>13956170
END;   << End of ABORTING >>                                   <<J9110>>13956180
$PAGE "   BUFFALO'DRIVER - subroutine PENDING'INTERRUPT"       <<09421>>13956190
<<---------------------------------------------------------->> <<09421>>13956200
<<                     PENDING'INTERRUPT                    >> <<09421>>13956210
<<---------------------------------------------------------->> <<09421>>13956220
                                                               <<09421>>13956230
LOGICAL SUBROUTINE PENDING'INTERRUPT;                          <<09421>>13956240
                                                               <<09421>>13956250
BEGIN COMMENT --                                               <<09421>>13956260
  PENDING'INTERRUPT is called whenever the idle  channel  pro- <<09421>>13956270
gram is due to be started.  If an earlier IOQ (or the idle CP) <<09421>>13956280
completed with a PON (on-line transition), or we  detected  an <<09421>>13956290
off-line  transition, DIT'PENDING'INTERRUPT was set if the de- <<09421>>13956300
vice was not locked. If so, now is the time to create the (un- <<09421>>13956310
expected) interrupt associated with the PON.  We  do  this  by <<09421>>13956320
setting all necessary conditions and returning TRUE. The call- <<09421>>13956330
er is expected to RETURN from the driver. If there is no pend- <<09421>>13956340
ing interrupt, we return FALSE and the caller  can  then  con- <<09421>>13956350
tinue with the idle channel program.                           <<09421>>13956360
;                                                              <<09421>>13956370
PENDING'INTERRUPT := FALSE;                                    <<09421>>13956380
IF LOGICAL (DIT'PENDING'INTERRUPT) THEN                        <<09421>>13956390
   BEGIN   << Clear PI, only interrupt if not locked.       >> <<09421>>13956400
   DIT'PENDING'INTERRUPT := FALSE;   << Just do it once.    >> <<09421>>13956410
   IF NOT LOGICAL (DIT'LOCK'FLG) THEN                          <<09421>>13956420
      BEGIN   << Only interrupt if nobody's locked us.      >> <<09421>>13956430
      PENDING'INTERRUPT := TRUE;                               <<09421>>13956440
      DRIVER'STATE := UNXPCT'INTERRUPT;                        <<09421>>13956450
      END;    << Only interrupt if nobody's locked us.      >> <<09421>>13956460
   END;    << Clear PI, only interrupt if not locked.       >> <<09421>>13956470
END;       << of PENDING'INTERRUPT.                         >> <<09421>>13956480
$PAGE "   BUFFALO'DRIVER - subroutine LOCATE'AND'WRITE'0"      <<09421>>13956490
<<---------------------------------------------------------->> <<09421>>13956500
<<                     LOCATE'AND'WRITE'0                   >> <<09421>>13956510
<<---------------------------------------------------------->> <<09421>>13956520
                                                               <<09421>>13956530
SUBROUTINE LOCATE'AND'WRITE'0;                                 <<09421>>13956540
                                                               <<09421>>13956550
BEGIN COMMENT --                                               <<09421>>13956560
  This subroutine sets up a channel program  to  request  last <<09421>>13956570
status from the device.  The only way to do this, it seems, is <<09421>>13956580
via the CS80 command Locate And Write to block address 0  with <<09421>>13956590
length 0.  LOCATE'AND'WRITE'0 is invoked by the Request Device <<09421>>13956600
Status function processor.  It is also used by the  driver  on <<09421>>13956610
its  own behalf as a workaround to a strange condition, namely <<09421>>13956620
that the device does not  generate  an  unsolicited  interrupt <<09421>>13956630
(with DSJ of 2) when it goes on-line!  So we must solicit that <<09421>>13956640
interrupt via a status request. Because the conditions we test <<09421>>13956650
may be true at times other than when we actually come on line, <<09421>>13956660
we may run these status requests unnecessarily.                <<09421>>13956670
;                                                              <<09421>>13956680
CP'DIAG'CMD'TO'EXEC := WRT'CMD'SEC;                            <<09421>>13956690
CP'DIAG'CDB'LENGTH  := 7;                                      <<09421>>13956700
                                                               <<09421>>13956710
SETDB'SIOP;                                                    <<09421>>13956720
SIODB'BYTE'ARRAY(CDB'AREA'BYTE + 0 ) := CDB'SET'UNIT;          <<09421>>13956730
                                                               <<09421>>13956740
SIODB'BYTE'ARRAY(CDB'AREA'BYTE + 1 ) := CDB'SET'LENGTH;        <<09421>>13956750
SIODB'BYTE'ARRAY(CDB'AREA'BYTE + 2 ) := ZERO;                  <<09421>>13956760
SIODB'BYTE'ARRAY(CDB'AREA'BYTE + 3 ) := ZERO;                  <<09421>>13956770
SIODB'BYTE'ARRAY(CDB'AREA'BYTE + 4 ) := ZERO;                  <<09421>>13956780
SIODB'BYTE'ARRAY(CDB'AREA'BYTE + 5 ) := ZERO;                  <<09421>>13956790
                                                               <<09421>>13956800
SIODB'BYTE'ARRAY(CDB'AREA'BYTE + 6 ) := CDB'WRITE;             <<09421>>13956810
SETDB'SYS;                                                     <<09421>>13956820
                                                               <<09421>>13956830
CP'FIRST'BRANCH := ENTER'DIAG;                                 <<09421>>13956840
                                                               <<09421>>13956850
END;   << of LOCATE'AND'WRITE'0                             >> <<09421>>13956860
$PAGE "   BUFFALO'DRIVER - initiator section"                  <<09421>>13960000
<<           HP9144 driver initiator section          >>       <<09421>>13980000
                                                               <<09421>>14101000
   << Call to HELP assures STT entry, is never executed.    >> <<09421>>14102000
                                                               <<09421>>14103000
   HELP;                                                       <<09421>>14104000
$EDIT VOID=14290000                                            <<09421>>14280000
                                                               <<09421>>14301000
      <<---------------------------------------------------->> <<09421>>14302000
      <<  Device status available, see what it has to say.  >> <<09421>>14303000
      <<---------------------------------------------------->> <<09421>>14304000
                                                               <<09421>>14304100
      IF NOT LOGICAL (DIT'NOT'RDY'EARLIER)   << Dvc WAS rdy >> <<09421>>14311000
         AND LOGICAL (DIT'DEV'NOT'RDY) THEN  << Not rdy now >> <<09421>>14312000
                                                               <<09421>>14312100
         << Device went off line.                           >> <<09421>>14312200
                                                               <<09421>>14312300
         IF NOT LOGICAL (DIT'LOCK'FLG) THEN                    <<09421>>14313000
            BEGIN   << Recognize off-line transition.       >> <<09421>>14313100
            DIT'PENDING'INTERRUPT := TRUE;                     <<09421>>14314000
            DIT'RELEASE'GRANTED := FALSE;                      <<09421>>14314100
            DIT'NOT'RDY'EARLIER := DIT'DEV'NOT'RDY;            <<09421>>14314200
            END;    << Recognize off-line transition.       >> <<09421>>14314300
         CP'FIRST'BRANCH    := ENTER'CHAN'CLEAR;               <<09421>>14325000
$EDIT VOID=14355000                                            <<09421>>14355000
$EDIT VOID=14570000                                            <<09421>>14445000
         IF LOGICAL (DIT'INT'MAINT'REQ)   OR                   <<09421>>14446000
            LOGICAL (DIT'I'INT'MAINT'REQ) OR                   <<09421>>14447000
            LOGICAL (DIT'I'DIAG'REL'REQ) OR                    <<c2238>>14447100
            LOGICAL (DIT'I'OPR'REL'REQ)   AND                  <<09421>>14448000
              (    LOGICAL (DIT'DEV'NOT'RDY) OR                <<09421>>14449000
               NOT LOGICAL (DIT'LOCK'FLG))   THEN              <<09421>>14450000
            BEGIN   << O.K. to release, but remember it.    >> <<09421>>14451000
            SIOP'BYTE (CDB'AREA'BYTE + 1, CDB'RELEASE);        <<09421>>14452000
            DIT'RELEASE'GRANTED := TRUE;                       <<09421>>14453000
            END     << O.K. to release, but remember it.    >> <<09421>>14454000
         ELSE                                                  <<09421>>14455000
            BEGIN   << Can't release, probably LOCKed.      >> <<09421>>14456000
            SIOP'BYTE (CDB'AREA'BYTE + 1, CDB'RELEASE'DENY);   <<09421>>14457000
            IOMESSAGE (1, NSYS'DENY'MSG, %10000, DIT'LDEV,,,,, <<09421>>14458000
                       CONSOLE);                               <<09421>>14459000
            END;    << Can't release, probably LOCKed.      >> <<09421>>14460000
         BEGIN   << Error log area overflowed.              >> <<09421>>14625000
$EDIT VOID=14660000                                            <<09421>>14640000
         IF PENDING'INTERRUPT THEN                             <<09421>>14641000
            BEGIN                                              <<09421>>14642000
            DIT'SUBSTATE := NORMAL'IDLE;                       <<09421>>14643000
            RETURN;                                            <<09421>>14644000
            END;                                               <<09421>>14645000
                                                               <<09421>>14646000
         CP'FIRST'BRANCH := ENTER'IDLE;                        <<09421>>14647000
         IF DIT'SUBSTATE = IDLE'REQ'WAIT THEN                  <<09421>>14648000
            IF LOGICAL (DIT'RELEASE'GRANTED) THEN              <<09421>>14649000
            BEGIN                                              <<09421>>14650000
            LOCATE'AND'WRITE'0;  << Req Stat to force DSJ 2 >> <<09421>>14651000
            DIT'RELEASE'GRANTED := FALSE;                      <<09421>>14652000
            END                                                <<09421>>14653000
         ELSE                                                  <<09421>>14654000
            DIT'SUBSTATE := NORMAL'IDLE;                       <<09421>>14665000
         END;    << Error log area overflowed.              >> <<09421>>14695000
   <<------------------------------------------------------->> <<09421>>14706000
   <<   Check for Power On or coming on line (same thing)   >> <<09421>>14707000
   <<------------------------------------------------------->> <<09421>>14708000
                                                               <<09421>>14709000
   IF CPVA'STATUS = FOUR OR     << Idle PON occurred.       >> <<09421>>14710000
      CPVA'STATUS = TWO  THEN   << PON in CHAN'CLEAR/DIAG.  >> <<09421>>14711000
      IF DIT'IMMEDIATE'MODE = 1 AND                            <<J9456>>14716010
      DIT'LAST'WAS'WRITE = 1 THEN                              <<J9456>>14716020
      DIT'MUST'PF'NEXT := TRUE;                                <<J9456>>14716030
      IF NOT LOGICAL (DIT'LOCK'FLG) THEN                       <<09421>>14721000
         BEGIN   << Came on line unlocked, set for AVR.     >> <<09421>>14722000
         DIT'PENDING'INTERRUPT := TRUE;                        <<09421>>14723000
         DIT'RELEASE'GRANTED := FALSE;                         <<09421>>14724000
         END;    << Came on line unlocked, set for AVR.     >> <<09421>>14724100
      DIT'NOT'RDY'EARLIER := FALSE;                            <<09421>>14724200
      CP'FIRST'BRANCH    := ENTER'CHAN'CLEAR;                  <<09421>>14725000
$EDIT VOID=14750000                                            <<09421>>14750000
   <<------------------------------------------------------->> <<09421>>14781000
   <<   Check pending interrupt, past release, schedule     >> <<09421>>14782000
   <<   idle channel program if neither.                    >> <<09421>>14783000
   <<------------------------------------------------------->> <<09421>>14784000
                                                               <<09421>>14785000
$EDIT VOID=14810000                                            <<09421>>14785001
   IF PENDING'INTERRUPT THEN                                   <<09421>>14786000
      BEGIN                                                    <<09421>>14787000
      DIT'SUBSTATE := NORMAL'IDLE;                             <<09421>>14788000
      RETURN;                                                  <<09421>>14789000
      END;                                                     <<09421>>14790000
   CPVA'STATUS := ZERO;                                        <<09421>>14791000
   CP'FIRST'BRANCH := ENTER'IDLE;                              <<09421>>14792000
   IF DIT'SUBSTATE = IDLE'REQ'WAIT THEN                        <<09421>>14793000
      IF LOGICAL (DIT'RELEASE'GRANTED) THEN                    <<09421>>14794000
      BEGIN                                                    <<09421>>14795000
      LOCATE'AND'WRITE'0;   << Req Stat to force any DSJ 2. >> <<09421>>14796000
      DIT'RELEASE'GRANTED := FALSE;                            <<09421>>14797000
      END                                                      <<09421>>14798000
   ELSE                                                        <<09421>>14799000
      DIT'SUBSTATE := NORMAL'IDLE;                             <<09421>>14815000
   TRANSFER'COUNT := - DOUBLE(INTEGER(IOQ'COUNT))              <<09575>>14945000
<<   Function code 78    --> Internal code 8          >>       <<f9442>>15026000
$EDIT VOID=15230000                                            <<09421>>15070000
FCODE := IOQ'FUNC'TO'FCODE(IOQ'FUNC);                          <<09421>>15075000
IF FCODE = UNDEFINED'IOQ'FUNC THEN                             <<09421>>15080000
   BEGIN                                                       <<09421>>15235000
   END;                                                        <<09421>>15265000
                                                               <<f9546>>15466000
     IF IOQ'UNLOAD'RING <> 0 THEN                              <<f9546>>15467000
        BEGIN                                                  <<f9546>>15468000
        IOQ'UNLOAD'RING := 0;                                  <<f9546>>15469000
        DIT'TRANSFERED'COUNT := 0D;                            <<f9546>>15469100
        END;                                                   <<f9546>>15469200
     if aborting then return;                                  <<J9195>>15471010
     IF FCODE = FC'WRITE THEN DIT'LAST'WAS'WRITE := TRUE       <<J9456>>15471020
     ELSE DIT'LAST'WAS'WRITE := FALSE;                         <<J9456>>15471030
     IF DIT'MUST'PF'NEXT = 1 THEN                              <<J9456>>15536010
     BEGIN                                                     <<J9456>>15536020
       DIT'MUST'PF'NEXT := FALSE;                              <<J9456>>15536030
       IOQ'STAT         := POWERFAIL'ABORT;                    <<J9456>>15536040
       DRIVER'STATE     := REQUEST'COMPLETE;                   <<J9456>>15536050
       RETURN;                                                 <<J9456>>15536060
     END;                                                      <<J9456>>15536070
<<     78    Describe                          8           >>  <<f9442>>15701000
$EDIT VOID=17455000                                            <<09421>>17440000
$EDIT VOID=17695000                                            <<09421>>17530000
$EDIT VOID=17795000                                            <<09421>>17720000
   LOCATE'AND'WRITE'0;   << Sets up CP to force stat req.   >> <<09421>>17725000
<<   Request volume limit [function code = 13] and    >>       <<f9442>>18110000
<<   Describe             [function code = 78]        >>       <<f9442>>18111000
<<                     the maximum volume limit and   >>       <<f9442>>18125000
<<                     the describe bytes.            >>       <<f9442>>18126000
                                                               <<f9442>>18145100
   IF TRANSFER'COUNT = 0D THEN                                 <<f9442>>18146000
      BEGIN                    << Exit with invalid function >><<f9442>>18147000
      IOQ'STAT       := INVALID'REQUEST;                       <<f9442>>18148000
      IOQ'COUNT      := ZERO;                                  <<f9442>>18149000
      DRIVER'STATE   := REQUEST'COMPLETE;                      <<f9442>>18149100
      RETURN;                                                  <<f9442>>18151000
      END;                                                     <<f9442>>18152000
                                                               <<f9442>>18153000
      GS'FILE'PROTECT := TRUE;                                 <<c2238>>18985000
   DIT'RELEASE'GRANTED := FALSE;   << Normal CP will get us >> <<09421>>22631000
                                   << any pending DSJ of 2. >> <<09421>>22632000
   IF IOQ'RETRY'COUNT = 0 THEN                                          22651000
     BEGIN                                                              22652000
     INDEX := DSTATUS;                                                  22655000
     DO                                                                 22660000
       P'DIT(INDEX) := ZERO                                             22665000
     UNTIL (INDEX := INDEX + 1) > DSTATUS + (DEV'STAT'WORD'SIZE-1)      22670000
   END;                                                                 22671000
$PAGE "   BUFFALO'DRIVER - continuator section"                <<09421>>22760000
<<**********************************************************>> <<09421>>22765000
<<**********************************************************>> <<09421>>22770000
<<                                                          >> <<09421>>22775000
<<            HP9144 driver continuator section             >> <<09421>>22780000
<<                                                          >> <<09421>>22785000
<<**********************************************************>> <<09421>>22790000
<<**********************************************************>> <<09421>>22795000
IF DIT'SAVE'WORD = -1    OR            << System powerfail >>  <<J9456>>22815000
   IOQ'PFAIL = 1         OR                                    <<J9456>>22815010
   CPVA'STATUS = 2       OR                                    <<J9456>>22815020
   DIT'DEV'POWERFAIL = 1 and cpva'status = 1 then  <<Device>>  <<19502>>22815030
   IF DIT'IMMEDIATE'MODE = 1 AND DIT'LAST'WAS'WRITE = 1 THEN   <<J9456>>22826000
   BEGIN                                                       <<J9456>>22826010
                                                               <<f9521>>22826011
     UPDATE'XFER'CNT;                                          <<f9521>>22826012
     DRIVER'STATE := REQUEST'COMPLETE;                         <<J9456>>22826020
     CPVA'STATUS  := 0;                                        <<J9456>>22826030
     IOQ'STAT     := POWERFAIL'ABORT;                          <<J9456>>22826040
     RETURN;                                                   <<J9456>>22826050
   END;                                                        <<J9456>>22826060
$edit void=22835000                                            <<19502>>22827000
   if cpva'status <> 2 then                                    <<19502>>22827100
   begin                                                       <<19502>>22827200
     IOQ'SYS'PFAIL := ONE;                                     <<19502>>22830000
<< fix infinite retries condition when IOQ'PFAIL=1 >>          <<09574>>22831000
   if ioq'pfail then                                           <<09574>>22831100
   begin                                                       <<09574>>22831200
     ioq'pfail := 0;                                           <<09574>>22831300
     ioq'abort := 0;                                           <<09574>>22831400
   end;                                                        <<09574>>22831500
     GOTO RETRY'REQUEST;                                       <<19502>>22835000
   end;                                                        <<19502>>22836100
   CP'FIRST'BRANCH := ENTER'CHAN'CLEAR;                        <<09421>>22955000
<<          Current I/O aborted due to the DMA        >>       <<09421>>23065000
<<      Current I/O aborted due to the Channel        >>       <<09421>>23445000
      CP'FIRST'BRANCH := ENTER'CHAN'CLEAR;                     <<09421>>24060000
   IF DIT'WRITE'PROTECT = ONE AND FCODE=FC'WRITE THEN          <<09574>>24660000
      DIT'TRANSFERED'COUNT := 0D;                              <<f9546>>24761000
      END  << Of "if DIT'WRITE'PROTECT = ONE ..." >>           <<09574>>24840000
      else dit'write'protect := 0;                             <<09574>>24841000
            DIT'I'DIAG'REL'REQ  =  ONE OR                      <<c2238>>25197000
         DIT'TRANSFERED'COUNT := 0D;                           <<f9546>>25516000
<<   Power on/channel clear completion OR Abort IOQ   >>       <<09421>>25900000
IF CPVA'STATUS = TWO OR    << PON - ck pend. int., redo IOQ >> <<09421>>25920000
   CPVA'STATUS = FIVE THEN << CHAN CLEAR - just redo IOQ.   >> <<09421>>25921000
   I := CPVA'STATUS;   << Temp -- may need it again shortly >> <<09421>>25926000
   IF ABORTING THEN RETURN;                                    <<J9110>>25931010
      END;   << Of "if IOQ'DIAG then ..." >>                   <<09421>>25970000
   IF I = TWO THEN                                             <<09421>>25975000
      BEGIN   << Completed IOQ with PON, check/set PI, NR.  >> <<09421>>25975100
      IF NOT LOGICAL (DIT'LOCK'FLG) THEN                       <<09421>>25976000
         DIT'PENDING'INTERRUPT := TRUE;                        <<09421>>25977000
      DIT'NOT'RDY'EARLIER := FALSE;                            <<09421>>25977100
      END;    << Completed IOQ with PON, check/set PI, NR.  >> <<09421>>25977200
   IF IOQ'RETRY'COUNT = RETRY'LIMIT THEN                       <<09421>>25978000
   IF NOT LOGICAL (DIT'LOCK'FLG) THEN                          <<09421>>26281000
      BEGIN   << Came on line unlocked, set for AVR.        >> <<09421>>26281100
      DIT'PENDING'INTERRUPT := TRUE;                           <<09421>>26282000
      DIT'RELEASE'GRANTED := FALSE;   << Got on line w/o it >> <<09421>>26282100
      END;    << Came on line unlocked, set for AVR.        >> <<09421>>26282200
   DIT'NOT'RDY'EARLIER := FALSE;   << It's READY now.       >> <<09421>>26283000
   CP'FIRST'BRANCH := ENTER'CHAN'CLEAR;                        <<09421>>26285000
$edit void=26465000                                            <<J9110>>26391010
   DIT'TRANSFERED'COUNT := 0D;                                 <<f9546>>26831000
   DRIVER'STATE    := INTERRUPT'WAIT;                          <<f9546>>26845000
<<   Return the volume limit or all describe bytes    >>       <<f9442>>27060000
   IF P'IOQ  <> 0 THEN                                         <<f9442>>27076000
   IF INTEGER(IOQ'FUNC) <> 78 THEN                             <<f9442>>27077000
   END                                                         <<f9442>>27145000
                                                               <<f9442>>27146000
   ELSE                             << function code is 78 >>  <<f9442>>27147000
   BEGIN                                                       <<f9442>>27148000
                                    << make word count     >>  <<f9442>>27149000
   TRANSFER'COUNT := (TRANSFER'COUNT + 1D) /2D;                <<f9442>>27151000
   TOS := BANK'N'BUFF'ADDR;             << User's area     >>  <<f9442>>27152000
   TOS := ZERO;                                                <<f9442>>27153000
   TOS := @SIOP + SYSDB + DESC'AREA;    << Describe area   >>  <<f9442>>27154000
   TOS := INTEGER(TRANSFER'COUNT);      << #words to move  >>  <<f9442>>27154100
   ASSEMBLE (MABS);                     << Store desc.bytes>>  <<f9442>>27154200
                                                               <<f9442>>27154210
                                        <<Exit w/good trans>>  <<f9442>>27154220
   IOQ'STAT     := GOOD'IO;                                    <<f9442>>27154230
   IOQ'COUNT    := INTEGER(TRANSFER'COUNT);                    <<f9442>>27154240
   DRIVER'STATE := REQUEST'COMPLETE;                           <<f9442>>27154250
                                                               <<f9442>>27154260
   RETURN;                                                     <<f9442>>27154270
   END                                                         <<f9442>>27154280
                                                               <<f9442>>27154290
   ELSE                                                        <<f9442>>27154300
   BEGIN                                                       <<f9442>>27154310
                                                               <<f9442>>27154320
   IOQ'STAT       := INVALID'REQUEST;                          <<f9442>>27154330
   IOQ'COUNT      := ZERO;                                     <<f9442>>27154340
   DRIVER'STATE   := REQUEST'COMPLETE;                         <<f9442>>27154350
                                                               <<f9442>>27154360
   RETURN;                                                     <<f9442>>27154370
   END; << Of "if FCODE = FC'REQ'VOL'LIMIT . . ." >>           <<f9442>>27154380
$PAGE                                                          <<f9442>>27154400
$PAGE "   HP9144 driver - outer block"                         <<09421>>27480000
