$CONTROL MAP,CODE,USLINIT                                               00010000
  <<    hiolprt2 [module 21] -- hp2619a lp driver [hpib]    >>          00015000
<< hp32002c mpe source c.00.00 >>                                       00020000
<< COPYRIGHT     "(C) COPYRIGHT HEWLETT-PACKARD CO. 1980.           >>  00025000
<<     this program may be used with one computer system at a       >>  00030000
<<     time and shall not otherwise be recorded, transmitted or     >>  00035000
<<     stored in a retrieval system.  copying or other reproduction >>  00040000
<<     of this program except for archival purposes is prohibited   >>  00045000
<<     without the prior written consent of hewlett-packard company.>>  00050000
<< **** note - dollar copyright cannot be used with this module *** >>  00055000
$title "HP2619A LINE PRINTER DRIVER - HPIB"                             00060000
$control privileged,uncallable                                          00065000
$tp                                                                     00070000
     <<*********************************************************>>      00075000
     <<                                                         >>      00080000
     <<  hiolprt2 [module 21] -- hp2619a lp driver [hpib]       >>      00085000
     <<                                                         >>      00090000
     <<  copyright (c) 1980, hewlett packard co.  this program  >>      00095000
     <<  may be used with one computer system at at time and    >>      00100000
     <<  shall not otherwise be recorded, transmitted or stored >>      00105000
     <<  in a retrieval system.  copying or other reproduction  >>      00110000
     <<  of this program except for archival purposes is pro-   >>      00115000
     <<  hibited without the prior written consent of hewlett-  >>      00120000
     <<  packard company.                                       >>      00125000
     <<                                                         >>      00130000
     <<*********************************************************>>      00135000
                                                                        00140000
comment                                                        <<04744>>00145000
                                                                        00150000
                                                                        00155000
        hp2619a line printer driver 3000 series - hiolprt2              00160000
        ----------------------------------------------------            00165000
                                                                        00170000
                                                                        00175000
structure of hiolprt2:                                                  00180000
                                                                        00185000
hiolprt2, together with the sio device monitor (siodm) constitute a     00190000
standard mpe type 1 i/o driver/monitor.  this means that it does not    00195000
run in its own process, but executes on any stack and therefore must    00200000
run to completion.  during initialization it executes on progen's       00205000
stack, during request initiation it executes on attachio's stack, and   00210000
during interrupt processing it executes on the interrupt control        00215000
stack (ics).                                                            00220000
                                                                        00225000
HIOLPRT2 consists of a global area, two procedures, and an "outer       00230000
block" which is really a linkage area for INITIAL.  The global area     00235000
contains an array called initial which is comprised of three parts.     00240000
the first part specifies the size of the other two, the unit extract    00245000
instruction, and various parameters which are used by initial.  this    00250000
section is deleted after initial is through with it.  the other two     00255000
parts are the device information table (dit) and the channel program    00260000
area, which is part of the interrupt linkage table (ilt).  initial      00265000
will put each of these items in the area of memory where it belongs.    00270000
the linkage area specifies the procedure labels (p-labels) of the       00275000
associated monitor (siodm), the request initiator (lpdrvr), the         00280000
request completor (lpdrvr), the initialization procedure (lpinit,       00285000
called by progen at system startup), and the interrupt handler (gip).   00290000
                                                                        00295000
                                                                        00300000
operation of hiolprt2:                                                  00305000
                                                                        00310000
the primary working code of hiolprt2 is a procedure lpdrvr.  lpdrvr     00315000
is called with six parameters.   two of these parameters, bank and      00320000
buffaddr, are the absolute buffer address of the data to be processed.  00325000
the other three, ditp, ioqp, and siop are pointers to three arrays.     00330000
ditp is a pointer to the device information table which contains        00335000
information about its associated line printer.  there is one dit for    00340000
each unit on the controller and they contain information which must     00345000
be saved between i/o requests to the driver.  ioqp is a pointer to the  00350000
input/output table which contains information relevent to the current   00355000
request.  siop is a pointer to the first element of the channel pro-    00360000
gram which is actually part of the interrupt linkage table.  the last   00365000
parameter drtn is the device reference table (drt) number of the        00370000
device.  these three elements are described in more detail elsewhere    00375000
in this listing.                                                        00380000
                                                                        00385000
lpdrvr is always called by the sio device monitor (siodm) and it        00390000
determines the reason for the call by examining the ioq and the dit.    00395000
when a new request is initiated, lpdrvr examines the function code      00400000
and parameter fields contained in the ioq element to determine the      00405000
task that is desired.  the proper command codes and program branches    00410000
are then placed in the channel program and its execution is begun.      00415000
                                                                        00420000
upon completion of the request, an interrupt is generated and lpdrvr    00425000
is again called.  the code checks for current activity in progress,     00430000
and this being the case, branches to the completion section of the      00435000
driver.  here several status words are examined for errors or special   00440000
conditions which might have occurred during the execution of the        00445000
channel program, during the data transfer, or during the operation of   00450000
the line printer.  these conditions can cause error retries and/or      00455000
special notation back to the caller.  a list of the conditions and      00460000
the return codes is provided in this listing.                           00465000
                                                               <<04744>>00470000
fix history                                                    <<04744>>00475000
-----------                                                    <<04744>>00480000
                                                               <<04744>>00485000
8-4-82 sotoji watanabe (submitted by dave cassafer) -          <<04744>>00490000
       selection of vfc channel 9-12 will be changed to        <<04744>>00495000
       single space if subtype = 3 (katakana printer).         <<04744>>00500000
                                                               <<04744>>00505000
       dave cassafer - change timeout from 2 to 5 sec.         <<04744>>00510000
       because kanji printers need the extra time for          <<04744>>00515000
                                                               <<06718>>00520000
3-25-83 david sm chang                                         <<06718>>00525000
        initial mpev incl5 program.                            <<06718>>00530000
                                                               << 8647>>00535000
5-2-84  frank weger                                            << 8647>>00540000
        bug in pre'to'post space fixed                         << 8647>>00545000
        at end of driver completor.                            << 8647>>00550000
                                                               << 8647>>00555000
                                                               << 8647>>00560000
                device information table (dit)                          00565000
                ------------------------------                          00570000
                                                                        00575000
                                                                        00580000
there is one dit per physical device.  if a physical device represents  00585000
more than one logical device, the logical device number is obtained     00590000
from the ioq element (however, there is only one device per hp2619a     00595000
controller.)  the following diagram shows the dit used for the hp2619a  00600000
line printer driver.                                                    00605000
                                                                        00610000
     0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15   mnemonic          00615000
   +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+                    00620000
  0| 0| 0|ac|rq| 0| 0| 0|io|ia|no|st| 0|   state   |   dflag            00625000
   +--+--+--+--+--+--+--+--+--+--+--+--+-----------+                    00630000
  1| sysdb relative pointer to the dit for the next|   dlink            00635000
   | device requesting this resource or service    |                    00640000
   +-----------------------------------------------+                    00645000
  2| sysdb relative pointer to the first ioq in    |   dioqp            00650000
   | request list for this device                  |                    00655000
   +-----+-----------------+-----------------------+                    00660000
  3| logical device number                         |   dldev   <<06718>>00665000
   +-----+-----------------+-----------------------+                    00670000
  4| sysdb relative pointer to device linkage table|   ddltp            00675000
   +-----------------------------------------------+                    00680000
  5| sysdb relative pointer to intrp linkage table |   diltp            00685000
   +-----------------------------------------------+                    00690000
  6|                                |bj|ab|ps|fl|tp|   dsave            00695000
   +-----------------------------------------------+                    00700000
  7| hardware error status.  set when the driver   |   dserr            00705000
   | detects an error.  whenever <>0, the driver   |                    00710000
   | monitor logs an i/o error and clears this word|                    00715000
   +-----------------------------------------------+                    00720000
%10| bit 0 is set at completion of timer           |   dtime            00725000
   +-----------------------------------------------+                    00730000
%11| interrupt status for this unit. set by the    |   dstat   <<06718>>00735000
   | driver each time it processes an interrupt.   |           <<06718>>00740000
   +-----------------------------------------------+           <<06718>>00745000
%12|iot  |    physical device unit.                |   dunit   <<06718>>00750000
   +-----------------------------------------------+           <<06718>>00755000
   |                                               |           <<06718>>00760000
%13|          hardware logged error status         |dlogerror  <<06718>>00765000
   +-----------------------------------------------+           <<06718>>00770000
%14|          hardware logged error status + 1     |dlogerror+1<<06718>>00775000
   +-----------------------------------------------+           <<06718>>00780000
%15| holds the time out request entry index while  |   drqst   <<06718>>00785000
   | a time is active.                             |           <<06718>>00790000
   +-----------------------------------------------+           <<06718>>00795000
dflag - flags and request state                                         00800000
  ac  active  - a monitor is currently servicing this device.           00805000
  rq  request - a service request is pending while the monitor is       00810000
                active.                                                 00815000
  io  ioprog  - an i/o channel program is running for this device.      00820000
  ia  iak     - an interrupt or response has occurred for this device.  00825000
  no  notrdy  - go to state %10 after idle channel program is started.  00830000
  st  stwait  - the device monitor is starting an idle channel program  00835000
                for this device.  there is no ioq associated with this  00840000
                type of request.                                        00845000
  state       - state of the device monitor.  specifies the next action 00850000
                to be taken in siodm in servicing the request:          00855000
                                                                        00860000
                  0 - start new request                                 00865000
                  1 - not used                                          00870000
                  2 - call driver initiator procedure                   00875000
                  3 - call driver completor procedure                   00880000
                  4 - not used                                          00885000
                  5 - process request completed                         00890000
                  6 - initiate device recognition sequence              00895000
                  7 - start operator intervention wait                  00900000
                %10 - wait for interrupt (operator intervention)        00905000
                      restart at state 0                                00910000
                %11 - wait for data segment freeze, then state 2        00915000
                %12 - wait for driver initiator to be frozen, then      00920000
                      allocate controller (state 2)                     00925000
                %13 - wait for i/o completion interrupt, then state 3   00930000
                %14 - wait for controller, then call driver initiator   00935000
                %15 - not used                                          00940000
                %16 - wait for initiator make present, then state 2     00945000
                %17 - wait for completor make present, then state 3     00950000
                                                                        00955000
dldev - i/o system type, unit and logical device number                 00960000
    0 - hp3000 series 2/3                                               00965000
    1 - hp3000 series 33 (hpib)                                         00970000
    2 - unused                                                          00975000
    3 - unused                                                          00980000
                                                                        00985000
dsave - device processing flags                                         00990000
  bj   betjob    - between jobs flg, if set suppress powerfail msg.     00995000
  ab   abort     - abort (caused by pfail or operator) has occurred.    01000000
  ps   prespace  - last request used prespacing.                        01005000
  fl   full      - line printer buffer is full.                         01010000
  tp   top       - printer is at top of form.                           01015000
                                                                        01020000
dserr - pointer to status to be logged.                                 01025000
        bits(0:7)  - number of words to be logged.                      01030000
        bits(8:15) - offset relative to ditp(0).                        01035000
                                                                        01040000
                                                                        01045000
hp2619a line printer status                                             01050000
---------------------------                                             01055000
                                                                        01060000
  bits         use                                                      01065000
                                                                        01070000
    0     on line          [msb]                                        01075000
    1     i/o buffer ready                                              01080000
    2     (reserved)                                                    01085000
    3     protocol error                                                01090000
    4     parity error in a command on the hpib                         01095000
    5     (reserved)                                                    01100000
    6     paper out/paper jam/gate open/platen open/etc.                01105000
    7     power fail       [lsb]                                        01110000
                                                                        01115000
$page                                                                   01120000
                interrupt linkage table (ilt)                           01125000
                -----------------------------                           01130000
                                                                        01135000
                                                                        01140000
there is one ilt for each device controller configured on the system.   01145000
a controller may support more than one unit, however the hp2619a con-   01150000
troller currently only supports one unit.                               01155000
                                                                        01160000
     0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15   mnemonic          01165000
   +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+                    01170000
  0|         channel                               |   icpva0           01175000
  1|              program                          |   icpva1           01180000
  2|                  variable                     |   icpva2           01185000
  3|                       area (icpva)            |   icpva3           01190000
   +-----------------------------------------------+                    01195000
  4|         dma abort                             |   icpva4           01200000
  5|              address                          |   icpva5           01205000
   +-----------------------------------------------+                    01210000
  6|                      0                        |   isrql            01215000
   +--+-----------------+-----+-----------+--------+                    01220000
  7|li|     chanque     |     |   chan    |  dev   |   icntrl           01225000
   +--+-----------------+-----+-----------+--------+                    01230000
%10| sysdb relative pointer to channel program area|   isiop            01235000
   +-----------------------------------------------+                    01240000
%11| sysdb relative pointer to status return area. |   istap            01245000
   | (the hp2619a driver does not use the status   |                    01250000
   |  return area so this entry is 0.)             |                    01255000
   +-----------------------------------------------+                    01260000
%12| single instruction that is executed to extract|   iunit            01265000
   | the device unit number from the status pointed|                    01270000
   | to by istap.  (since there is only one unit   |                    01275000
   | on the controller, this entry is not used.)   |                    01280000
   +-----------------------------------------------+                    01285000
%13| sysdb relative dit pointer of the device      |   icdp             01290000
   | currently using the channel to perform a      |                    01295000
   | data operation.                               |                    01300000
   +-----------------------+-----------------------+                    01305000
%14|       siopsize        |        cquen          |   iqueue           01310000
   +--+--+--+--------------+-----------+-----------+                    01315000
%15|rw|wp|ig|                          |  hcunit   |   iflag            01320000
   +--+--+--+--------------------------+-----------+                    01325000
%16| sysdb relative dit pointer for unit 0         |   iditp0           01330000
   +-----------------------------------------------+                    01335000
%17|             line printer                      |                    01340000
   .               channel                         .                    01345000
   |                 program                       |                    01350000
   +-----------------------------------------------+                    01355000
                                                                        01360000
                                                                        01365000
icpva0 - channel program variable area                                  01370000
                                                                        01375000
  the first word is used by the channel program processor to store      01380000
  status information after i/o channel aborts.  the next word is used   01385000
  by the driver to indicate if status should be examined for special    01390000
  conditions or errors.  the other two words are not used.              01395000
                                                                        01400000
                                                                        01405000
icpva4 - dma abort address                                              01410000
                                                                        01415000
  if a dma abort occurs, the absolute address where the abort occurred  01420000
  is stored in this area.                                               01425000
                                                                        01430000
                                                                        01435000
icntrl - contains controller information                                01440000
                                                                        01445000
  lim     - if this bit is set, the controller is sharing a software    01450000
            channel resource in order to limit bandwidth.               01455000
  chanque - the software channel resource number.                       01460000
  chan    - channel number (four most significant bits of drtn).        01465000
  dev     - device number (three least significant bits of drtn).       01470000
                                                                        01475000
                                                                        01480000
iqueue -                                                                01485000
                                                                        01490000
  siopsize - (number of words + 1)/2 in the channel program area.       01495000
  cquen    - for a multi-unit controller this field contains the        01500000
             software controller resource number.                       01505000
                                                                        01510000
                                                                        01515000
iflag - controller and channel program state flags                      01520000
                                                                        01525000
  runwait  - an idle channel program should be started when there       01530000
             are no active requests to process.  this flag is always    01535000
             0 for the hp2619a.                                         01540000
  waitprog - an idle channel program has been started for this          01545000
             controller.  this bit is reset by an interrupt.            01550000
  ignorehi - an hiop instruction has been issued against this con-      01555000
             troller but the channel program was not in a wait          01560000
             statement.  therefore ignore the interrupt generated by    01565000
             the channel code when this program halts.                  01570000
  hcunit   - highest configured unit number for this controller.        01575000
                                                                        01580000
                                                                        01585000
                                                                        01590000
            device reference table drt                                  01595000
            --------------------------                                  01600000
                                                                        01605000
there is one drt per device controller.  the the contents of this       01610000
table are used for processing interrupts.                               01615000
                                                                        01620000
     word 0  siop   - absolute address of the current i/o               01625000
                      instruction in execution.                         01630000
     word 1  dbi    - absolute address of the base of the ilt           01635000
                      for this controller.                              01640000
     word 2  plable - the external program label of the interrupt       01645000
                      service routine for this controller.              01650000
     word 3  chan   - contains channel program status information       01655000
                      which is used by the channel program interpreter. 01660000
$page                                                                   01665000
            i/o queue element (ioq)                                     01670000
            -----------------------                                     01675000
                                                                        01680000
                                                                        01685000
     0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15   mnemonic          01690000
   +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+                    01695000
  0|      request dependent flags (see below)      |   qflag            01700000
   +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+                    01705000
  1| sysdb relative pointer to next ioq element.   |   qlink            01710000
   | points to first word of element.              |                    01715000
   +-----------------------+-----------------------+                    01720000
  2|                       | logical device number |   qldev            01725000
   +--+--+--+--+--+--------+-----------+-----------+                    01730000
  3|pp|pe|po|to|bf|                    | waitcode  |   qmisc            01735000
   +--+--+--+--+--+--------------------+-----------+                    01740000
  4| s| if qflag.(3:1) is clear then this is the   |   qdstn            01745000
   |  | dst number of the target data segment.  if |                    01750000
   |  | s is set, qaddr is db relative.            |                    01755000
   +--+--------------------------------------------+                    01760000
  5| offset in the data segment or system buffer   |   qaddr            01765000
   | table to the target data buffer.              |                    01770000
   +-----------------------+-----------------------+                    01775000
  6|                       | function code for     |   qfunc            01780000
   |                       | this request.  (see   |                    01785000
   |                       | next section.)        |                    01790000
   +-----------------------+-----------------------+                    01795000
  7| on initiation, specifies the word count (>0)  |   qwbct            01800000
   | or byte count (<0).  at completion of the     |                    01805000
   | request this location contains the actual     |                    01810000
   | transmission count in the same units (bytes   |                    01815000
   | or words) as in the request.                  |                    01820000
   +-----------------------------------------------+                    01825000
%10| parameter 1.  vertical format specification.  |   qpar1            01830000
   | (see next section for detail.)                |                    01835000
   +-----------------------------------------------+                    01840000
%11| parameter 2.  space mode flags.  (see next    |   qpar2            01845000
   | section for details.)                         |                    01850000
   +-----------------------+--------------+--------+                    01855000
%12|         pcbn          |  qualifier   | status |   qstat            01860000
   +-----------------------+--------------+--------+                    01865000
                                                                        01870000
                                                                        01875000
qflag - request dependent flags                                         01880000
                                                                        01885000
  bit 0  abort     - abort this request and return an error indication  01890000
                     to the caller.                                     01895000
  bit 1  special   - apply special handling to this request.  (not used)01900000
  bit 2  diag      - this is a request from the diagnostic subsystem.   01905000
  bit 3  sysbuff   - target is an index relative to the sbuf table of   01910000
                     the data buffer.                                   01915000
  bit 4  iowake    - wake caller on completion of request.              01920000
  bit 5  blocked   - blocked i/o.  the caller is waited in attachio     01925000
                     until the request is completed.  implies iowake.   01930000
  bit 6  completed - the request has been completed and the caller      01935000
                     awakened if he had requested (with iowake).        01940000
  bit 7  datafrzn  - set by the memory management routines (mam) when a 01945000
                     makepresent request is successfully completed and  01950000
                     indicates the data segment is frozen in memory.    01955000
  bit 8  mamerrord - an error has occurred while mam was trying to      01960000
                     make the target data segment present and freeze    01965000
                     it in memory.                                      01970000
  bit 9  preq      - (not used)                                         01975000
  bit 10 sfail     - delayed failure of sio instruction.  if a call to  01980000
                     startio resulted in the request being added to     01985000
                     the channel queue, this bit indicates that the sio 01990000
                     instruction failed when the request was selected   01995000
                     for execution.                                     02000000
  bit 11 pfail     - the request was aborted because of a system power  02005000
                     failure.                                           02010000
                                                                        02015000
                                                                        02020000
qmisc - driver request dependent flags and counters.                    02025000
                                                                        02030000
  pre'to'post - pre to post spacing change flag.                        02035000
  peject      - last operation was a page eject.                        02040000
  power on    - power on in process.                                    02045000
  tout        - channel timed out flag.                                 02050000
  buf'fill    - buffer fill operation in process.                       02055000
  waitcode    - indicates type of wait:                                 02060000
                                                                        02065000
                  0 - new request                                       02070000
                  1 - completion wait                                   02075000
                  2 - not ready wait                                    02080000
                  3 - initiation wait                                   02085000
                                                                        02090000
                                                                        02095000
qstat - pcb number and request completion status.                       02100000
                                                                        02105000
  pcbn    - the process control block (pcb) number of the process       02110000
            which made this request.  if zero, the request is not       02115000
            associated with any process and the ioq element is to       02120000
            be returned by the system when the request has completed.   02125000
  status  - general status indicating the final state of the request.   02130000
            the following codes are used:                               02135000
                                                                        02140000
              0 - not started or awaiting completion.                   02145000
              1 - successful completion.                                02150000
              2 - end-of-file detected.                                 02155000
              3 - unusual, but recoverable, condition detected.         02160000
              4 - irrecoverable error has occurred.                     02165000
                                                                        02170000
  qualifier - a code which further defines or qualifies the general     02175000
              status.  (see the section driver return status codes.)    02180000
                                                                        02185000
$page                                                                   02190000
         2619 line printer request codes                                02195000
         -------------------------------                                02200000
                                                                        02205000
operation  function  parameters                                         02210000
---------  --------  ----------                                         02215000
                                                                        02220000
 write          1    p1  [vertical format specification]                02225000
                                                                        02230000
                       1 - use 1st data character as format             02235000
                           specification                                02240000
                                                                        02245000
                     %53 - "+", print and suppress spacing              02250000
                     %55 - "-", print and triple space                  02255000
                     %60 - "0", print and double space                  02260000
                     %61 - "1", print and top of form                   02265000
                                                                        02270000
                     %200-%277, print and space n-%200 lines            02275000
                     %300-%312, print with channel n-%277               02280000
                                                                        02285000
                     %320 - fill line printer buffer only               02290000
                                                                        02295000
                     all others - print and single space                02300000
                                                                        02305000
                                                                        02310000
                     p2  [space mode flags]                             02315000
                                                                        02320000
                     (15:1)   - prespace flag                           02325000
                     if set   - print then fill buffer                  02330000
                     if clear - fill buffer then print                  02335000
                                                                        02340000
                     (14:1)    - no page stepover flag                  02345000
                     if set    - single and double space without        02350000
                                 stepover (66 lines/page)               02355000
                     if clear  - single and double space with           02360000
                                 stepover (60 lines/page)               02365000
                                                                        02370000
 file open      2    page eject if not at top of form                   02375000
                                                                        02380000
 file close     3    page eject if not at top of form                   02385000
                                                                        02390000
 device close   4    page eject if not at top of form                   02395000
                                                                        02400000
 read status  %17    read i/o status                                    02405000
                     count - buffer size                                02410000
                                                                        02415000
                                                                        02420000
*identify    %110    return id value in bank & buffaddr                 02425000
                                                                        02430000
*self test:                                                             02435000
  initiate   %111    subtest number to execute in bank & buffaddr       02440000
                     (subtest# ranges from 0 to 7)                      02445000
  status     %112    subtest result returned in bank & buffaddr         02450000
                                                                        02455000
*loopback test:                                                         02460000
  wrt data   %113    data to lp in bank & buffaddr [ping]               02465000
  read data  %114    data from lp read into bank & buffaddr [pong]      02470000
                     count - buffer size (256 bytes max)                02475000
                                                                        02480000
                                                                        02485000
                                                                        02490000
                                                                        02495000
                                                                        02500000
                                                                        02505000
*diagnostic function:  the diagnostic request bit in the 1st word       02510000
                       (qflag) of the ioq table must be set before      02515000
                       any diagnostic functions can be executed.        02520000
                                                                        02525000
                                                                        02530000
$page                                                                   02535000
                  logging considerations                                02540000
                  ----------------------                                02545000
                                                                        02550000
 dma abort & channel program abort - cpva(0) is logged.                 02555000
 parity error - a value ot -1 is logged.                                02560000
 protocol error - status is logged to denote a unit failure.            02565000
                                                                        02570000
 [in the case of a channel program abort due to a channel hard-         02575000
 ware timeout, status is checked to determine if this was caused        02580000
 by parity error. if so, the parity error value -1 is logged            02585000
 instead of cpva(0)]                                                    02590000
                                                                        02595000
                                                                        02600000
                  parallel poll considerations                          02605000
                  ----------------------------                          02610000
                                                                        02615000
    on power on (pon) condition, the controller (driver) will get an    02620000
 affirmative response to parallel poll (arpp) the first time due to     02625000
 the pon condition.  afterwards, the controller (driver) will not get   02630000
 an arpp unless there is a buffer available to accept data, the prin-   02635000
 ter is online and no problems exist.                                   02640000
                                                                        02645000
  for pon with offline condition:                                       02650000
                                                                        02655000
     the first arpp cause status to be read, afterward the idle chan-   02660000
  nel program is run until the second arpp is received.                 02665000
                                                                        02670000
  for pon with online conditon:                                         02675000
                                                                        02680000
     the first arpp cause status to be read, afterward the idle chan-   02685000
  nel program is ran through one pass to assure synchronization bet-    02690000
  ween the firmware and the driver.                                     02695000
                                                                        02700000
  for power off when ioq is issued:                                     02705000
                                                                        02710000
     the driver will time out and the idle channel program is run.      02715000
  when power finally gets turned on, the condition specified above      02720000
  will occur in respect to pon being online or offline.                 02725000
                                                                        02730000
  for regular offline condition:                                        02735000
                                                                        02740000
     the driver will not get an arpp unless there is a buffer avail-    02745000
  able to accept data, the printer is online, and no error conditions   02750000
  exist (ie. paper out, paper jam, platen open, etc).                   02755000
                                                                        02760000
                                                                        02765000
                  abort/powerfail considerations                        02770000
                  ------------------------------                        02775000
                                                                        02780000
    on an abort caused either by a powerfail or an operator abort, a    02785000
device clear must be sent to the line printer to clear out the last     02790000
request and reset the firmware to a known state. this is necessary,     02795000
since an abort has high priority and can interrupt the channel pro-     02800000
gram prior to it completing.                                            02805000
$page                                                                   02810000
                                                                        02815000
                  extra handshake requirement                           02820000
                  ---------------------------                           02825000
                                                                        02830000
    at any point in the driver when a "2" is returned from a dsj        02835000
 denoting i/o status should be interrogated, an extra wait [wait,       02840000
 dsj] for an arpp (denoting that a buffer is available to receive       02845000
 the next secondary) is required. this assures that the firmware        02850000
 will not get out of synchronization with the driver. omission of       02855000
 this extra handshake can result in the protocol error bit being        02860000
 set in the status word. under the driver completion section, this      02865000
 extra handshake is done under the following conditions:                02870000
                                                                        02875000
    - pon condition (flagged with dsj 2)                                02880000
    - alarm condition which cleared up showing a clean status           02885000
      but retained the dsj 2 condition (ie. user opens and              02890000
      closes the yoke between jobs)                                     02895000
    - buffer ready bit not set in the status word possibly due          02900000
      to noise on the bus                                               02905000
                                                                        02910000
                                                                        02915000
$page                                                                   02920000
                       driver return status codes                       02925000
                       --------------------------                       02930000
                                                                        02935000
                                                                        02940000
 general status (13:3)       qualifying status (8:5)      overall (8:8) 02945000
                                                                        02950000
 0 - pending                1 - waiting for completion         %10      02955000
                            3 - not ready wait                 %30      02960000
                                                                        02965000
 1 - successful             0 - no errors                       %1      02970000
                                                                        02975000
 2 - end of file            (not used)                                  02980000
                                                                        02985000
 3 - unusual condition      3 - request aborted                %33      02990000
                            6 - powerfail abort                %63      02995000
                          %21 - device powered up             %213      03000000
                                                                        03005000
 4 - irrecoverable error    0 - invalid request                 %4      03010000
                            2 - i/o timed out before complete  %24      03015000
                            4 - sio failure                    %44      03020000
                            5 - unit failure                   %54      03025000
                          %12 - system error                  %124      03030000
                          %14 - channel failure               %144      03035000
                          %21 - parity error                  %214      03040000
                                                                        03045000
                                                                        03050000
endcomment;                                                    <<04744>>03055000
$page                                                                   03060000
begin                                                                   03065000
$include inclioq                                               <<06718>>03070000
$include incllpdt                                              <<06718>>03075000
  equate                                                                03080000
                                                                        03085000
       << ditp parameters >>                                            03090000
                                                                        03095000
    diltp     =  5,  << interrupt linkage table pointer >>              03100000
    dldev     =  3,  << logical device and unit numbers >>              03105000
    dlogerror =%13,  << dit hardware logged error status >>    <<06718>>03110000
    dlogerror2= dlogerror+1,<< =%14 dit h/w log status+1 >>    <<06718>>03115000
    drqst     =%15,  << driver request flags >>                <<06718>>03120000
    dsave     =  6,  << driver flags >>                                 03125000
    dserr     =  7,  << dit hardware count & index >>                   03130000
    dtime     =  8,  << time-out request entry index >>                 03135000
    dflag     =  0,  << device flag index >>                   <<06718>>03140000
    dlink     =  1,  << dit link pointer index >>              <<06718>>03145000
    dioqp     =  2,  << ioq pointer index >>                   <<06718>>03150000
    ddltp     =  4,  << dlt pointer index >>                   <<06718>>03155000
    dstat     =%11,  << interrupt status index >>              <<06718>>03160000
    dunit     =%12,  << physical device unit index >>          <<06718>>03165000
                                                                        03170000
       << ioqp parameters >>                                            03175000
    << specify by include-5 file >>                            <<06718>>03180000
                                                                        03185000
                                                               <<06718>>03190000
                                                               <<06718>>03195000
                                                               <<06718>>03200000
                                                               <<06718>>03205000
                                                               <<06718>>03210000
                                                               <<06718>>03215000
                                                               <<06718>>03220000
                                                                        03225000
       << channel program addresses relative to siop >>                 03230000
                                                                        03235000
    baddr      =  47,  << write instruction buffer address >>           03240000
    bcount     =  44,  << write instruction byte count >>               03245000
    buffjmp    =  42,  << switch for buffer fill >>                     03250000
    diagjmp    = 116,  << diagnostic complete jmp >>                    03255000
    dsbank     = 113,  << diag/status bank addr  >>                     03260000
    dscount    = 111,  << diag/status byte count >>                     03265000
    dstatadr   = 114,  << diag/status buffer addr >>                    03270000
    dsb'esc    = 127,  << disable esc seq byte >>                       03275000
    enb'esc    = 126,  << enable esc seq byte >>                        03280000
    esc'adr    = 121,  << esc seq address >>                            03285000
    esc'alpha  = 124,  << esc seq alpha terminator >>                   03290000
    esc'parm   = 123,  << esc seq parameter >>                          03295000
    init       = 117,  << start of initialization routine >>            03300000
    memx       =  46,  << write instruction bank number >>              03305000
    post'cnt   =  76,  << postspace count >>                            03310000
    post'dadr  =  91,  << postspace disable esc seq adr >>              03315000
    post'dcnt  =  89,  << postspace disable esc seq cnt >>              03320000
    post'esc   =  79,  << postspace esc seq address >>                  03325000
    postjmp    =  61,  << switch for post spacing >>                    03330000
    pre'cnt    =  16,  << prespace count >>                             03335000
    pre'dadr   =  31,  << prespace disable esc seq adr >>               03340000
    pre'dcnt   =  29,  << prespace disable esc seq cnt >>               03345000
    pre'esc    =  19,  << prespace esc seq address >>                   03350000
    prejmp     =   1,  << switch for prespacing >>                      03355000
    rwctl      = 110,  << diag/status read/wrt ctrl >>                  03360000
    status     = 125,  << i/o status buffer >>                          03365000
                                                                        03370000
       << channel program entries relative to siop >>                   03375000
                                                                        03380000
    branchpt      =   1,  << branch point to cp entry points >>         03385000
    dstatsiop     = 108,  << diag/status entry point >>                 03390000
    fillsiop      =  41,  << offline restart entry point >>             03395000
    idlesiop      =  91,  << idle cp entry point >>                     03400000
    idsiop        = 111,  << identify entry point >>                    03405000
    initsiop      = 115,  << initiation entry point >>                  03410000
    pre'dsbsiop   =  26,  << prespace disable esc seq entry >>          03415000
    post'dsbsiop  =  86,  << postspace disable esc seq entry >>         03420000
    post'enbsiop  =  60,  << postspace enable esc seq entry >>          03425000
    statsiop      = 101,  << status interrogation entry point >>        03430000
                                                                        03435000
       << completion statuses >>                                        03440000
                                                                        03445000
    aborted   =  %33,  << request aborted >>                            03450000
    chanfail  = %144,  << i/o channel error >>                          03455000
    goodio    =    1,  << successful i/o completion >>                  03460000
    invalidop =    4,  << invalid operation requested >>                03465000
    parity    = %214,  << parity error >>                               03470000
    pfabort   =  %63,  << request aborted due to power failure >>       03475000
    powerup   = %213,  << unit reset due to power fail or reset >>      03480000
    siofail   =  %44,  << sio failure >>                                03485000
    syserror  = %124,  << system error >>                               03490000
    timouterr =  %24,  << timed out error >>                            03495000
    uniterr   =  %54,  << unit failure >>                               03500000
$page                                                                   03505000
                                                                        03510000
       << driver states >>                                              03515000
                                                                        03520000
    cmpltionwait  = 1,  << waiting for i/o completion interrupt >>      03525000
    notrdywait    = 2,  << not ready wait in progress >>                03530000
    initiowait    = 3,  << init unit via dev clear in progress >>       03535000
                                                                        03540000
       << siodm states >>                                               03545000
                                                                        03550000
    intrptwait  = %13,  << wait for i/o completion >>                   03555000
    notready    =   7,  << unit not ready >>                            03560000
    requestdone =   5,  << request done >>                              03565000
                                                                        03570000
       << iomessage parameters >>                                       03575000
                                                                        03580000
    notrdymsg    = 11,  << not ready message >>                         03585000
    opconsole    =  0,  << output message to system console >>          03590000
    powerupmsg   = 13,  << power restored/unit reset message >>         03595000
                                                                        03600000
       << miscellaneous equates >>                                      03605000
                                                                        03610000
    dclose      =     4,  << device close function >>                   03615000
    fopen       =     2,  << file open function >>                      03620000
    fclose      =     3,  << file close function >>                     03625000
    full'       =    14,  << line printer buffer full >>                03630000
    hp2617j     =     3,  << device subtype for hp2613/17j>>   <<04744>>03635000
    iotimer     =   %20,  << io timer parameter >>                      03640000
    isiop       =     8,  << ilt channel program area pointer >>        03645000
    parityerr   =    -1,  << parity error logging value >>              03650000
    prespace'   =    13,  << last request used prespacing >>            03655000
    sysdb       = %1000,  << address of sysdb area >>                   03660000
    syslpdt     =   %10,  << db relative base of lpdt >>       <<04744>>03665000
  endeq         =     0;                                                03670000
                                                               <<04744>>03675000
    << useful declarations >>                                  <<04744>>03680000
                                                               <<06718>>03685000
$page                                                                   03690000
                                                                        03695000
       << i/o status bit definitions >>                                 03700000
                                                                        03705000
     define                                                             03710000
       online     = ( 0:1)#, << online bit >>                           03715000
       protobit   = ( 3:1)#, << protocol error bit >>                   03720000
       paritybit  = ( 4:1)#, << parity error bit >>                     03725000
       paperbit   = ( 6:1)#, << paper error bit >>                      03730000
       pon        = ( 7:1)#, << unit powered up or was reset >>         03735000
                                                                        03740000
       << qmisc bit definitions >>                                      03745000
                                                                        03750000
       buf'fill   = ( 5:1)#, << buff fill operation in process >>       03755000
       pre'to'post= ( 0:1)#, << pre to post spacing change flag >>      03760000
       peject     = ( 1:1)#, << last operation was a page eject >>      03765000
       ponbit     = ( 2:1)#, << power on in progress >>                 03770000
       tout       = ( 3:1)#, << channel timed out once flag >>          03775000
       waitcode   = (12:4)#, << indicates type of wait >>               03780000
                             <<   0 - new request      >>               03785000
                             <<   1 - completion wait  >>               03790000
                             <<   2 - not ready wait   >>               03795000
                             <<   3 - initiation wait  >>               03800000
                                                                        03805000
       << dsave bit definitions >>                                      03810000
                                                                        03815000
       betjob     = (11:1)#, << between printing a job >>               03820000
       abortbit   = (12:1)#, << pfail/oper abort occurred >>            03825000
       prespace   = (13:1)#, << last request used prespacing >>         03830000
       full       = (14:1)#, << line printer buffer is full >>          03835000
       top        = (15:1)#, << printer is at top-of-form (tof) >>      03840000
                                                                        03845000
       << miscellaneous bit definitions >>                              03850000
                                                                        03855000
        abs        = absolute#, << absolute command >>         <<06718>>03860000
       cmd        = (12:4)#, << secondary command >>                    03865000
       dcode      = ( 0:8)#, << command code >>                         03870000
       diag       = ( 2:1)#, << qflag, diagnostic bit >>                03875000
       dldevn     = ( 8:8)#, << logical device number of dit >>         03880000
       errorcode  = ( 0:3)#, << cpvap, error code >>                    03885000
       func       = ( 8:8)#, << qfunc, function code >>                 03890000
       iostat     = ( 8:8)#, << qstat, request status returned >>       03895000
       lrbit      = ( 1:1)#, << wrt instruction left/right byte bit >>  03900000
       pfail      = (11:1)#, << qflag, abort set due to power fail >>   03905000
       sfail      = (10:1)#, << qflag, failure on delayed start sio >>  03910000
       stepover   = (14:1)#, << if set then no page stepover >>         03915000
       timedout   = (13:1)#, << cpvap, transfer aborted-timed out >>    03920000
       loadmemory = assemble(lsea)#,                                    03925000
       storememory= assemble(ssea)#,                                    03930000
     enddef       = 0#;                                                 03935000
                                                                        03940000
                                                                        03945000
$page                                                                   03950000
<<                                                                      03955000
        *********************************                               03960000
        *                               *                               03965000
        *   driver db area definition   *                               03970000
        *                               *                               03975000
        *********************************                               03980000
>>                                                                      03985000
                                                                        03990000
        array initial(0:145) = db :=                           <<06718>>03995000
        [8/14,8/1],   << lp dit size, not core resident >>     <<06718>>04000000
                      << no idle channel program, driver type >>        04005000
                 0,   << not used >>                                    04010000
                 0,   << unit extract instruction - not used >>         04015000
        [8/64,8/1],   << channel prog size/2, ret stat size >> <<06718>>04020000
                                                                        04025000
        << lp dit >>                                                    04030000
                 0,   << dflag >>                                       04035000
                 0,   << dlink >>                                       04040000
                 0,   << dioqp >>                                       04045000
                 0,   << dldev >>                              <<06718>>04050000
                 0,   << ddltp >>                                       04055000
                 0,   << diltp >>                                       04060000
                 0,   << dsave >>                                       04065000
                 0,   << dserr >>                                       04070000
                 0,   << dtime >>                                       04075000
                 0,   << dstat >>                              <<06718>>04080000
            %40000,   << dunit >>                              <<06718>>04085000
                 0,   << dlogerror >>                                   04090000
                 0,   << dlogerr+1 >>                          <<06718>>04095000
                 0,   << drqst >>                              <<06718>>04100000
                                                                        04105000
                                                                        04110000
        << channel program >>                                           04115000
                                                                        04120000
                                                                        04125000
<< 0>>  << jump >>              0,  << branch point to cp section >>    04130000
<< 1>>                          0,  << jmp *+0 pre, jmp *+26 post >>    04135000
                                                                        04140000
                                                                        04145000
        << prespace mode section >>                                     04150000
                                                                        04155000
                                                                        04160000
<< 2>>  << write ctrl >>    %2002,  << enable all escape sequences >>   04165000
<< 3>>                          1,                                      04170000
<< 4>>                          0,                                      04175000
<< 5>>                     %42000,                                      04180000
<< 6>>                          0,                                      04185000
                                                                        04190000
<< 7>>  << wait >>          %1000,  << make sure unit is responding >>  04195000
<< 8>>                          0,                                      04200000
                                                                        04205000
<< 9>>  << dsj >>           %2403,  << check printer's condition >>     04210000
<<10>>                          0,  << return byte >>                   04215000
<<11>>                          0,  << printer rdy to accept data >>    04220000
<<12>>                         88,  << invalid byte-read status >>      04225000
<<13>>                         88,  << read status required >>          04230000
<<14>>                         88,  << invalid byte-read status >>      04235000
                                                                        04240000
<<15>>  << write data >>    %2000,  << write out escape sequence >>     04245000
<<16>>                          0,                                      04250000
<<17>>                          0,                                      04255000
<<18>>                          0,                                      04260000
<<19>>                          0,                                      04265000
                                                                        04270000
<<20>>  << wait >>          %1000,  << make sure unit is responding >>  04275000
<<21>>                          0,                                      04280000
                                                                        04285000
<<22>>  << dsj >>           %2403,  << check printer's condition >>     04290000
<<23>>                          0,  << return byte >>                   04295000
<<24>>                          0,  << printer rdy to accept data >>    04300000
<<25>>                         75,  << invalid byte-read status >>      04305000
<<26>>                         75,  << read status required >>          04310000
<<27>>                         75,  << invalid byte-read status >>      04315000
                                                                        04320000
<<28>>  << write ctrl >>    %2002,  << disable all escape sequence >>   04325000
<<29>>                          1,                                      04330000
<<30>>                          0,                                      04335000
<<31>>                     %44000,                                      04340000
<<32>>                          0,                                      04345000
                                                                        04350000
<<33>>  << wait >>          %1000,  << wait for unit to // poll >>      04355000
<<34>>                          0,                                      04360000
                                                                        04365000
<<35>>  << dsj >>           %2403,  << check printer's condition >>     04370000
<<36>>                          0,  << return byte >>                   04375000
<<37>>                          0,  << printer rdy to accept data >>    04380000
<<38>>                         62,  << invalid byte-read status >>      04385000
<<39>>                         62,  << read status required >>          04390000
<<40>>                         62,  << invalid byte-read status >>      04395000
                                                                        04400000
                                                                        04405000
        << write out data section >>                                    04410000
                                                                        04415000
                                                                        04420000
<<41>>  << jump >>              0,  << jmp *+0 to fill buffer >>        04425000
<<42>>                          0,  << jmp *+17 otherwise >>            04430000
                                                                        04435000
<<43>>  << write data >>    %2000,  << write out data buffer >>         04440000
<<44>>                          0,                                      04445000
<<45>>                        128,                                      04450000
<<46>>                    %100000,                                      04455000
<<47>>                          0,                                      04460000
                                                                        04465000
<<48>>  << jump >>              0,                                      04470000
<<49>>                          2,  << jmp *+2, end of transfer >>      04475000
                                                                        04480000
<<50>>  << jump >>              0,                                      04485000
<<51>>                    %177755,  << jmp *-19, end of burst >>        04490000
                                                                        04495000
<<52>>  << wait >>          %1000,  << wait for unit to // poll >>      04500000
<<53>>                          0,                                      04505000
                                                                        04510000
<<54>>  << dsj >>           %2403,  << check printer's condition >>     04515000
<<55>>                          0,  << return byte >>                   04520000
<<56>>                          0,  << printer rdy to accept data >>    04525000
<<57>>                         43,  << invalid byte-read status >>      04530000
<<58>>                         43,  << read status required >>          04535000
<<59>>                         43,  << invalid byte-read status >>      04540000
                                                                        04545000
                                                                        04550000
        << postspace mode section >>                                    04555000
                                                                        04560000
                                                                        04565000
<<60>>  << jump >>              0,  << jmp *+0 for postspace req >>     04570000
<<61>>                          0,  << jmp *+39 otherwise >>            04575000
                                                                        04580000
<<62>>  << write ctrl >>    %2002,  << enable all escape sequences >>   04585000
<<63>>                          1,                                      04590000
<<64>>                          0,                                      04595000
<<65>>                     %42000,                                      04600000
<<66>>                          0,                                      04605000
                                                                        04610000
<<67>>  << wait >>          %1000,  << make sure unit is responding >>  04615000
<<68>>                          0,                                      04620000
                                                                        04625000
<<69>>  << dsj >>           %2403,  << check printer's condition >>     04630000
<<70>>                          0,  << return byte >>                   04635000
<<71>>                          0,  << printer rdy to accept data >>    04640000
<<72>>                         28,  << invalid byte-read status >>      04645000
<<73>>                         28,  << read status required >>          04650000
<<74>>                         28,  << invalid byte-read status >>      04655000
                                                                        04660000
<<75>>  << write data >>    %2000,  << write out escape sequence >>     04665000
<<76>>                          0,                                      04670000
<<77>>                          0,                                      04675000
<<78>>                          0,                                      04680000
<<79>>                          0,                                      04685000
                                                                        04690000
<<80>>  << wait >>          %1000,  << make sure unit is responding >>  04695000
<<81>>                          0,                                      04700000
                                                                        04705000
<<82>>  << dsj >>           %2403,  << check printer's condition >>     04710000
<<83>>                          0,  << return byte >>                   04715000
<<84>>                          0,  << printer rdy to accept data >>    04720000
<<85>>                         15,  << invalid byte-read status >>      04725000
<<86>>                         15,  << read status required >>          04730000
<<87>>                         15,  << invalid byte-read status >>      04735000
                                                                        04740000
<<88>>  << write ctrl >>    %2002,  << disable all escape sequence >>   04745000
<<89>>                          1,                                      04750000
<<90>>                          0,                                      04755000
<<91>>                     %44000,                                      04760000
<<92>>                          0,                                      04765000
                                                                        04770000
                                                                        04775000
        << idle channel program section >>                              04780000
                                                                        04785000
                                                                        04790000
<<93>>  << wait >>          %1000,  << wait for unit to // poll >>      04795000
<<94>>                          0,                                      04800000
                                                                        04805000
<<95>>  << dsj >>           %2403,  << check printer's state >>         04810000
<<96>>                          0,  << return byte >>                   04815000
<<97>>                          0,  << printer rdy to accept data >>    04820000
<<98>>                          2,  << invalid byte-read status >>      04825000
<<99>>                          2,  << read status required >>          04830000
<<100>>                         2,  << invalid byte-read status >>      04835000
                                                                        04840000
<<101>> << int/hlt >>        %601,  << interrupt/halt >>                04845000
<<102>>                         1,  << code of 1 in cpva(1) >>          04850000
                                                                        04855000
                                                                        04860000
        << i/o status interrogation section >>                          04865000
                                                                        04870000
                                                                        04875000
<<103>> << read status >>   %1416,  << read status bytes >>             04880000
<<104>>                         1,  << #bytes >>                        04885000
<<105>>                         0,                                      04890000
<<106>>                     %2000,                                      04895000
<<107>>                         0,                                      04900000
                                                                        04905000
<<108>> << int/halt >>       %601,  << interrupt/halt >>                04910000
<<109>>                         2,  << code of 2 in cpva(1) >>          04915000
                                                                        04920000
                                                                        04925000
         << diagnostics and read status section >>                      04930000
                                                                        04935000
                                                                        04940000
<<110>> << rd/wrt ctrl >>   %2002,  << send diag/status cmd byte >>     04945000
<<111>>                         0,                                      04950000
<<112>>                         0,                                      04955000
<<113>> << identify >>          0,                                      04960000
<<114>>                         0,                                      04965000
                                                                        04970000
<<115>> << jump >>              0,                                      04975000
<<116>>                         0,  << jump * - 16/24 >>                04980000
                                                                        04985000
                                                                        04990000
        << initialization section >>                                    04995000
                                                                        05000000
                                                                        05005000
<<117>> << clear >>         %4401,  << clear dev w/parity check >>      05010000
<<118>>                         0,                                      05015000
                                                                        05020000
<<119>> << int/hlt >>        %601,  << interrupt/halt >>                05025000
<<120>>                         0,  << code of 0 in cpva(1) >>          05030000
                                                                        05035000
                                                                        05040000
        << control codes, escape sequences, & misc. storages >>         05045000
                                                                        05050000
                                                                        05055000
<<121>> << esc'adr >>     %015446,  << esc & >>                         05060000
<<122>>                   %066040,  << l [space] >>                     05065000
<<123>> << esc'parm >>    %020040,  << #slew, vfc chan# >>              05070000
<<124>> << esc'alpha >>   %020040,  << "U", "V" >>                      05075000
<<125>> << status >>            0,  << status buffer >>                 05080000
<<126>> << enb'esc >>        %200,  << enable esc seq byte >>           05085000
<<127>> << dsb'esc >>        %202;  << disable esc seq byte >>          05090000
$page                                                                   05095000
<<                                                                      05100000
         ***************************************                        05105000
         *                                     *                        05110000
         *   external procedure declarations   *                        05115000
         *                                     *                        05120000
         ***************************************                        05125000
>>                                                                      05130000
                                                                        05135000
   procedure aborttimereq(trlx);                                        05140000
     value trlx;   integer trlx;                                        05145000
     option external;                                                   05150000
                                                                        05155000
   procedure gip'hpib;                                                  05160000
     option external;                                                   05165000
                                                                        05170000
   procedure help;                                                      05175000
     option external;                                                   05180000
                                                                        05185000
   logical procedure iomessage(setno,msgno,mask,p1,p2,p3,p4,p5,         05190000
                               dest,reply,offset,ditp,iotype);          05195000
     value setno,msgno,mask,p1,p2,p3,p4,p5,dest,reply,offset,           05200000
           ditp,iotype;                                                 05205000
     integer setno,msgno,mask,p1,p2,p3,p4,p5,dest,reply,offset;         05210000
     integer iotype;                                                    05215000
     integer pointer ditp;                                              05220000
     option variable, external;                                         05225000
                                                                        05230000
   procedure siodm(ditp,flags);                                         05235000
     value ditp,flags;   logical flags;                                 05240000
     pointer ditp;   option external;                                   05245000
                                                                        05250000
   procedure masterclearhpib(ditp);                                     05255000
     array ditp;   option external;                                     05260000
                                                                        05265000
   procedure start'hpib(ditp,siop,qflag);                               05270000
     value ditp,siop,qflag;   logical qflag;                            05275000
     pointer ditp,siop;   option external;                              05280000
                                                                        05285000
   integer procedure timereq(code,req,time);                            05290000
     value code,req,time;                                               05295000
     integer code,req;   double time;                                   05300000
     option external;                                                   05305000
$page                                                                   05310000
   double procedure int2asc(number,count);                              05315000
                                                                        05320000
<<---------------------------------------------------->>                05325000
<<                                                    >>                05330000
<<   this procedure converts an integer number to     >>                05335000
<<   its ascii equivalent.                            >>                05340000
<<                                                    >>                05345000
<<     number = decimal number                        >>                05350000
<<     count  = number of ascii char to return        >>                05355000
<<                                                    >>                05360000
<<   function ret: 2 ascii words for integer value    >>                05365000
<<                                                    >>                05370000
<<---------------------------------------------------->>                05375000
                                                                        05380000
     value number,count;                                                05385000
     integer number,count;                                              05390000
                                                                        05395000
     begin                                                              05400000
                                                                        05405000
     double ascbuf = q + 1;                                             05410000
                                                                        05415000
     byte array                                                         05420000
       bscbuf(*) = ascbuf;                                              05425000
                                                                        05430000
     integer xreg = x;                                                  05435000
                                                                        05440000
     tos := %20040;  << init ret buffer area >>                         05445000
     tos := %20040;                                                     05450000
                                                                        05455000
     tos := number;  << get integer number >>                           05460000
     xreg := count;  << number of ascii char >>                         05465000
                                                                        05470000
     do begin                                                           05475000
       tos := 10;  << base 10 >>                                        05480000
       assemble(div,decx);  << number/10 >>                             05485000
       bscbuf(xreg) := tos + %60;                                       05490000
       assemble (test);                                                 05495000
       end                                                              05500000
     until = ;                                                          05505000
                                                                        05510000
     int2asc := ascbuf;  << ret. ascii values >>                        05515000
                                                                        05520000
     end;                                                               05525000
                                                                        05530000
$page                                                                   05535000
<<       ******************************************                     05540000
         *                                        *                     05545000
         *   lp driver initialization procedure   *                     05550000
         *                                        *                     05555000
         ******************************************                     05560000
>>                                                                      05565000
                                                                        05570000
                                                                        05575000
   procedure lpinit(ditp);                                              05580000
     integer array ditp;                                                05585000
                                                                        05590000
<<---------------------------------------------------->>                05595000
<<                                                    >>                05600000
<<   this procedure initializes the restricted mode   >>                05605000
<<   addresses and the status buffer addresses in     >>                05610000
<<   the channel program.                             >>                05615000
<<                                                    >>                05620000
<<---------------------------------------------------->>                05625000
                                                                        05630000
     begin                                                              05635000
       integer pointer iltp   = q+1;                                    05640000
       integer pointer siop   = q+2;                                    05645000
       integer siobase        = q+3;                                    05650000
       integer pointer initcp = q+4;                                    05655000
                                                                        05660000
       tos := ditp(diltp);      << iltp    >>                           05665000
       tos := iltp(isiop);      << siop    >>                           05670000
       tos := @siop + sysdb;    << siobase >>                           05675000
       tos := @siop + init;     << initcp >>                            05680000
                                                                        05685000
       siop(6) := siop(66) := siobase + enb'esc;                        05690000
       siop(32) := siop(92) := siobase + dsb'esc;                       05695000
       siop(107) := siobase + status;                                   05700000
                                                                        05705000
     end;                                                               05710000
$page                                                                   05715000
<<       ************************************************               05720000
         *                                              *               05725000
         *   line printer driver procedure  -  lpdrvr   *               05730000
         *                                              *               05735000
         ************************************************               05740000
>>                                                                      05745000
                                                                        05750000
   integer procedure lpdrvr                                    <<06718>>05755000
           (ioq'entry'index,ditp,bank,buffaddr,siop,drtn);     <<06718>>05760000
                                                                        05765000
<<--------------------------------------------------------->>           05770000
<<                                                         >>           05775000
<<   this procedure initiates and completes i/o requests   >>           05780000
<<   for the hp2619a line printer connected to the hp-ib   >>           05785000
<<   and controlled by the gic.                            >>           05790000
<<                                                         >>           05795000
<<   mode returns in lpdrvr -                              >>           05800000
<<     5 - request completed                               >>           05805000
<<     7 - not ready wait                                  >>           05810000
<<   %13 - wait for completion                             >>           05815000
<<                                                         >>           05820000
<<--------------------------------------------------------->>           05825000
                                                                        05830000
   value ditp,ioq'entry'index,bank,buffaddr,siop,drtn;         <<06718>>05835000
   integer bank,buffaddr,drtn;                                          05840000
   integer pointer ditp,siop;                                  <<06718>>05845000
   integer ioq'entry'index;                                    <<06718>>05850000
   option privileged,uncallable;                                        05855000
                                                                        05860000
   begin                                                                05865000
     logical array                                                      05870000
       ditpl(*) = ditp;                                        <<06718>>05875000
                                                                        05880000
     double                                                             05885000
       buffaddrd = q- 7,   << bank and buffer address >>                05890000
       asciiarea;          << ascii ctrl byte area >>          <<06718>>05895000
                                                                        05900000
     integer pointer                                                    05905000
       cpvap;             << holds channel i/o status >>       <<06718>>05910000
                                                                        05915000
     integer                                                            05920000
       count,             << buffer byte count >>              <<06718>>05925000
       param,             << control parameter >>              <<06718>>05930000
       printctl,          << print control byte >>             <<06718>>05935000
       fcode,             << function code >>                  <<06718>>05940000
       s0       = s-0;                                                  05945000
                                                               <<04744>>05950000
     integer                                                   <<04744>>05955000
       subtype;           << printer subtype >>                <<06718>>05960000
                                                                        05965000
    integer array                                                       05970000
      temp(*)   = asciiarea;                                            05975000
                                                                        05980000
    byte array                                                          05985000
      btemp(*)  = temp;                                                 05990000
                                                                        05995000
    integer lpdt'index;                                        <<06718>>06000000
                                                                        06005000
$page                                                                   06010000
<<---------------------------------------------------->>                06015000
<<                                                    >>                06020000
<<   initialize local pointers and variables          >>                06025000
<<                                                    >>                06030000
<<---------------------------------------------------->>                06035000
                                                                        06040000
     @cpvap := ditp(diltp);    << cpvap >>                     <<06718>>06045000
     count := ioq'count;       << count >>                     <<06718>>06050000
     param := 0;               << param >>                     <<06718>>06055000
     printctl := 0;            << printctl >>                  <<06718>>06060000
     fcode := ioq'func;        << fcode >>                     <<06718>>06065000
     temp(0) := %20040;        << temp(0) >>                   <<06718>>06070000
     temp(1) := %20040;        << temp(1) >>                   <<06718>>06075000
                                                               <<06718>>06080000
     lpdt'index := ditp(dldev) * integer(lpdt'entry'size);     <<06718>>06085000
     subtype := lpdt'subtype;   << lpdt.subtype >>             <<06718>>06090000
                                                                        06095000
     if ioq'entry'index=0 then go to exit;<<nothing to do >>   <<06718>>06100000
                                                                        06105000
     if ioq'qmisc.waitcode = cmpltionwait then                 <<06718>>06110000
       aborttimereq(ditp(drqst));                                       06115000
                                                                        06120000
     if ioq'abort then  << abort process >>                    <<06718>>06125000
       begin                                                            06130000
         if ditp(dsave).abortbit <> 0 then   << abort occurred >>       06135000
           begin   << clean up excess ioq's returning abort status >>   06140000
             ditp(dsave).(13:3) := 0;   << clear driver flags >>        06145000
             tos := if ioq'pfail then pfabort else aborted;    <<06718>>06150000
             goto iodone;                                               06155000
           end;                                                         06160000
         ditp(dsave).abortbit := 1;  << set abort flg >>                06165000
         goto initdev;   << do initialization >>                        06170000
         help;   << link for debugger help >>                           06175000
       end                                                              06180000
                                                                        06185000
     else ditp(dsave).abortbit := 0;   << reset abort flg >>            06190000
                                                                        06195000
<<---------------------------------------------------->>                06200000
<<                                                    >>                06205000
<<   check for return from notready condition         >>                06210000
<<                                                    >>                06215000
<<---------------------------------------------------->>                06220000
                                                                        06225000
     if ioq'qmisc.waitcode = notrdywait then                   <<06718>>06230000
       begin                                                            06235000
         if siop(status).pon = 1 then   << pon just occur >>            06240000
           begin                                                        06245000
           ioq'qmisc.ponbit := 1;                              <<06718>>06250000
           ditp(dsave).betjob := 0;   << in between job >>              06255000
           goto idlecp;   << check for online or offline >>             06260000
           end;                                                         06265000
         ioq'qmisc.ponbit :=0;                                 <<06718>>06270000
         if ioq'qmisc.ponbit=1 then <<pon occured previously>> <<06718>>06275000
           begin                                                        06280000
             ioq'qmisc.ponbit := 1;   << set pon flg >>        <<06718>>06285000
             goto initdev;   << do initialization >>                    06290000
           end;                                                         06295000
         goto restart;                                                  06300000
       end;                                                             06305000
                                                                        06310000
     if ioq'qmisc.waitcode = cmpltionwait then                 <<06718>>06315000
       goto lpcont;   << completion interrupt >>                        06320000
                                                                        06325000
     if ioq'qmisc.waitcode = initiowait then                   <<06718>>06330000
       begin                                                            06335000
         ioq'qmisc.ponbit := 0;                                <<06718>>06340000
         if ioq'qmisc.ponbit=1 then <<powerup/reset performed>><<06718>>06345000
           begin                                                        06350000
             if ioq'diag then     << diagnostic completion >>  <<06718>>06355000
               begin                                                    06360000
                 tos := powerup;                                        06365000
                 goto iodone;                                           06370000
               end else                                                 06375000
                                                                        06380000
             if iomessage(1,powerupmsg,%10000,ditp(dldev),     <<06718>>06385000
                          ,,,,opconsole) then                           06390000
               begin                                                    06395000
                 if ditp(dsave).betjob = 1 then                         06400000
                   goto lpinit   << suppress power fail msg >>          06405000
                 else                                                   06410000
                   begin   << report power fail status >>               06415000
                     tos := powerup;                                    06420000
                     goto iodone;                                       06425000
                   end;                                                 06430000
               end;                                                     06435000
                                                                        06440000
             tos := syserror;   << indicate failure as there >>         06445000
             goto iodone;       << are no message link buffs >>         06450000
           end                                                          06455000
                                                                        06460000
         else                                                           06465000
           begin   << badio completion >>                               06470000
             lpdrvr := requestdone;                                     06475000
             return;                                                    06480000
           end;                                                         06485000
       end;                                                             06490000
                                                                        06495000
     goto lpinit;                                                       06500000
                                                                        06505000
<<---------------------------------------------------->>                06510000
<<                                                    >>                06515000
<<   printer initialization - device clear to clear   >>                06520000
<<      buffers and reset firmwire to a known state   >>                06525000
<<                                                    >>                06530000
<<---------------------------------------------------->>                06535000
                                                                        06540000
  initdev:                                                              06545000
     siop(branchpt) := initsiop;   << init cp entry >>                  06550000
     start'hpib(ditp,siop,true);                                        06555000
     if < then                                                          06560000
       begin                                                            06565000
         tos := siofail;                                                06570000
         goto iodone;                                                   06575000
       end;                                                             06580000
     ioq'qmisc.waitcode := initiowait;                         <<06718>>06585000
     lpdrvr := intrptwait;                                              06590000
     return;                                                            06595000
$page                                                                   06600000
<<****************************************************>>                06605000
<<                                                    >>                06610000
<<   line printer initialization section              >>                06615000
<<                                                    >>                06620000
<<****************************************************>>                06625000
                                                                        06630000
  lpinit:                                                               06635000
     siop(prejmp) := 26;   << init w/prespace bypassed in cp >>         06640000
     siop(postjmp) := 39;   << init w/postspace bypassed in cp >>       06645000
     siop(buffjmp) := 17;   << init w/buffer wrt bypassed in cp >>      06650000
                                                                        06655000
     siop(pre'dcnt) := 1;   << init prespace dsb esc seq cnt >>         06660000
     siop(pre'dadr).lrbit := 1;   << init to start w/rt byte >>         06665000
     siop(post'dcnt) := 1;   << init postspace dsb esc seq cnt >>       06670000
     siop(post'dadr).lrbit := 1;   << init to start w/rt byte >>        06675000
                                                                        06680000
     siop(pre'esc) := siop(post'esc) := @siop+sysdb+esc'adr;            06685000
     siop(pre'cnt) := siop(post'cnt) := 8;   << #esc bytes >>           06690000
     siop(esc'parm) := siop(esc'alpha) := %20040;   << init area >>     06695000
                                                                        06700000
<<---------------------------------------------------->>                06705000
<<                                                    >>                06710000
<<   file open [fopen with fcode = 2]                 >>                06715000
<<   file close [fclose with fcode = 3]               >>                06720000
<<   device close [dclose with fcode = 4]             >>                06725000
<<                                                    >>                06730000
<<---------------------------------------------------->>                06735000
                                                                        06740000
     if fcode=dclose or fcode=fopen or fcode=fclose then                06745000
                                                                        06750000
       begin                                                            06755000
         if ditp(dsave).(full':2) = 1 then                     <<02697>>06760000
           go to printdone; << empty buffer & already at top >><<02697>>06765000
         siop(prejmp) := 0;                                             06770000
         siop(esc'parm) := %20061;   << tof-select chan 1 >>            06775000
         siop(esc'alpha) := %20126;   << esc code v >>                  06780000
         siop(pre'cnt) := 8;   << esc seq count >>                      06785000
         ditp(dsave).full := 0;  << set buffer empty >>        <<02697>>06790000
         if fcode=dclose then                                           06795000
           ditp(dsave).(13:3) := 1;   << set tof flag >>                06800000
         ioq'qmisc.peject := 1;                                <<06718>>06805000
         goto startprint;                                               06810000
       end                                                              06815000
                                                                        06820000
<<---------------------------------------------------->>                06825000
<<                                                    >>                06830000
<<   file write [fwrite with fcode = 1]               >>                06835000
<<                                                    >>                06840000
<<---------------------------------------------------->>                06845000
                                                                        06850000
   else if fcode = 1 then                                               06855000
                                                                        06860000
     begin                                                              06865000
     if ditp(dsave).(prespace':2)=3 and not ioq'parm2 then     <<06718>>06870000
       begin                                                            06875000
         siop(prejmp) := 0;                                             06880000
         if ioq'parm2.stepover then                            <<06718>>06885000
           begin  << no auto page eject >>                     <<02697>>06890000
             siop(esc'parm) := %20061;  << single space slew >><<02697>>06895000
             siop(esc'alpha) := %20125;  << esc code u >>      <<02697>>06900000
           end                                                 <<02697>>06905000
         else                                                  <<02697>>06910000
           begin  << auto page eject >>                        <<02697>>06915000
         siop(esc'parm) := %20063;   << single space chan 3 >>          06920000
         siop(esc'alpha) := %20126;   << esc code v >>                  06925000
           end;                                                <<02697>>06930000
         siop(pre'cnt) := 8;   << esc seq count >>                      06935000
         ditp(dsave).full := 0;   << set buffer empty >>                06940000
        ioq'qmisc.pre'to'post := 1;                            <<06718>>06945000
         goto startprint;                                               06950000
       end;                                                             06955000
                                                                        06960000
     tos := ioq'count;                                         <<06718>>06965000
     if < then   << byte count >>                                       06970000
       count := -tos   << make positive >>                              06975000
     else   << word count >>                                            06980000
       count := tos&asl(1);   << change to byte count >>                06985000
                                                                        06990000
     if ioq'parm1 = 1 then     << imbedded control >>          <<06718>>06995000
       begin                                                            07000000
         if count = 0 then   << invalid operation >>                    07005000
           begin                                                        07010000
             tos := invalidop;                                          07015000
             goto iodone;                                               07020000
           end;                                                         07025000
         tos := buffaddrd;   << load bank and buff address >>           07030000
         loadmemory;   << load first word >>                            07035000
         param := tos&lsr(8);   << isolate and save control param >>    07040000
         count := count - 1;   << decrement byte count >>               07045000
       end                                                              07050000
     else                                                               07055000
       param := ioq'parm1;     << control in param word >>     <<06718>>07060000
                                                                        07065000
     ditp(dsave).prespace := if ioq'parm2                      <<06718>>07070000
       then 1 else 0;   << set prespace flag >>                         07075000
                                                                        07080000
<<---------------------------------------------------->>                07085000
<<                                                    >>                07090000
<<   initalize print control byte                     >>                07095000
<<                                                    >>                07100000
<<---------------------------------------------------->>                07105000
                                                                        07110000
     if ioq'parm2.stepover then                                <<06718>>07115000
       printctl := 1   << single space without stepover >>              07120000
     else                                                               07125000
       printctl := %102;   << single space with stepover >>             07130000
                                                                        07135000
     << setup print control byte >>                                     07140000
                                                                        07145000
     if param = "+" then   << suppress spacing >>                       07150000
       printctl := 0                                                    07155000
                                                                        07160000
     else if param = "0" then   << double space >>                      07165000
       printctl := printctl + 1                                         07170000
                                                                        07175000
     else if param = "-" then   << triple space >>                      07180000
       printctl := printctl + 2                                         07185000
                                                                        07190000
     else if param = "1" then   << top of form >>                       07195000
       begin                                                            07200000
         if count=0 and ditp(dsave).(full':2)=1 then                    07205000
           goto printdone;   << empty buffer and already at top >>      07210000
         printctl := %100;                                              07215000
         ioq'qmisc.peject := 1;  << set page eject flag >>     <<06718>>07220000
       end                                                              07225000
                                                                        07230000
     else if %200 <= param <= %277 then   << slew n lines >>            07235000
       printctl := param - %200                                         07240000
                                                                        07245000
     else if %300 <= param <= %313 then   << select channel n >>        07250000
      if subtype <> hp2617j or param <= %307 then              <<04744>>07255000
       printctl := param - %200                                         07260000
      else  << this else is just a place keeper to keep the  >><<04744>>07265000
            << original structure of this section of code    >><<04744>>07270000
            << intact.  if (subtype = hp2617j) and           >><<04744>>07275000
            << (%310 <= param <= %313) then printctl will be >><<04744>>07280000
            << unchanged from its earlier initialization to  >><<04744>>07285000
            << single space and control goes to printsetup:  >><<04744>>07290000
                                                                        07295000
     else if param = %320 then   << buffer fill only >>                 07300000
       begin                                                            07305000
         printctl := -1;                                                07310000
         if count=0 then goto printdone;                                07315000
         ioq'qmisc.buf'fill := 1; << set buf fill flag >>      <<06718>>07320000
       end;                                                             07325000
                                                                        07330000
$page                                                                   07335000
<<---------------------------------------------------->>                07340000
<<                                                    >>                07345000
<<   set chan prog for buffer fill & print control    >>                07350000
<<                                                    >>                07355000
<<---------------------------------------------------->>                07360000
                                                                        07365000
  printsetup:                                                           07370000
     if printctl >= 0 then   << setup print control >>                  07375000
       begin                                                            07380000
         ditp(dsave).full := 0;                                         07385000
         if printctl >= %100 then                                       07390000
                                                                        07395000
           begin   << set esc code for vfc chan select >>               07400000
           siop(esc'alpha) := %20126;   << v >>                         07405000
           printctl := printctl - %77;                                  07410000
           end                                                          07415000
                                                                        07420000
         else   << set esc code for slewing >>                          07425000
           siop(esc'alpha) := %20125;   << u >>                         07430000
                                                                        07435000
         asciiarea := int2asc(printctl,2);                              07440000
         siop(esc'parm) := temp;   << ascii parameter >>                07445000
                                                                        07450000
         if ditp(dsave).prespace=1 then   << prespace >>                07455000
           siop(prejmp) := 0                                            07460000
                                                                        07465000
         else                             << postspace >>               07470000
           siop(postjmp) := 0;                                          07475000
       end;                                                             07480000
                                                                        07485000
                                                                        07490000
     if count <> 0 then   << setup buffer fill >>                       07495000
       begin                                                            07500000
         siop(buffjmp) := 0;                                            07505000
         siop(bcount) := count;                                         07510000
         siop(memx).(8:8) := bank;                                      07515000
         siop(memx).lrbit := if ioq'parm1=1 <<imbedded contrl>><<06718>>07520000
           then 1 else 0;   << start with right byte >>                 07525000
         siop(baddr) := buffaddr;                                       07530000
         ditp(dsave).full := if ditpl(dsave).prespace                   07535000
           then 1 else 0;   << if prespacing indicate buff is full >>   07540000
       end;                                                             07545000
                                                                        07550000
<<---------------------------------------------------->>                07555000
<<                                                    >>                07560000
<<   start channel program                            >>                07565000
<<                                                    >>                07570000
<<---------------------------------------------------->>                07575000
                                                                        07580000
  startprint:                                                           07585000
     cpvap := 0;           << clear channel status word >>              07590000
     siop(status) := 0;    << clear cp status word >>                   07595000
                                                                        07600000
     start'hpib(ditp,siop,true);   << start channel program >>          07605000
                                                                        07610000
printcont:                                                              07615000
     if < then   << sio failure >>                                      07620000
       begin                                                            07625000
         tos := siofail;                                                07630000
         goto badio;                                                    07635000
       end;                                                             07640000
                                                                        07645000
     ioq'qmisc.waitcode := cmpltionwait;<<set request state>>  <<06718>>07650000
     ditp(dtime) := 0;                                                  07655000
     if ioq'diag then  << lengthen timer for diagnostics >>    <<06718>>07660000
       ditp(drqst) := timereq(iotimer,@ditp,50000d)                     07665000
     else                                                               07670000
       ditp(drqst) := timereq(iotimer,@ditp,5000d);            <<04744>>07675000
       <<timer was changed from 2 to 5 sec for kanji printers>><<04744>>07680000
     lpdrvr := intrptwait;                                              07685000
     return;                                                            07690000
                                                                        07695000
     end   << of write logic (function code = 1) >>                     07700000
                                                                        07705000
$page                                                                   07710000
<<---------------------------------------------------->>                07715000
<<                                                    >>                07720000
<<   read status [fcode = %17]                        >>                07725000
<<                                                    >>                07730000
<<---------------------------------------------------->>                07735000
                                                                        07740000
  else  if fcode = %17 then                                             07745000
                                                                        07750000
    begin   << read status processing >>                                07755000
      tos := ioq'count;     << get count >>                    <<06718>>07760000
      if < then   << negative byte count >>                             07765000
        count := -tos   << make positive >>                             07770000
      else   << positive word count >>                                  07775000
        count := tos & asl(1);   << change to byte >>                   07780000
                                                                        07785000
      if count < 1 then   << invalid request >>                         07790000
        begin                                                           07795000
          tos := invalidop;                                             07800000
          goto badio;                                                   07805000
        end;                                                            07810000
                                                                        07815000
      if count > 1 then   << exceed max status >>                       07820000
        count := 1;   << set max status avail >>                        07825000
                                                                        07830000
      siop(rwctl).dcode := 3;   << read code >>                         07835000
      siop(rwctl).cmd := %16;   << read status secondary >>             07840000
      siop(dscount) := count;                                           07845000
      siop(dsbank).(0:8) := 0;   << no special options >>               07850000
      siop(dsbank).(8:8) := bank;   << set bank >>                      07855000
      siop(dstatadr) := buffaddr;   << set abs adr >>                   07860000
                                                                        07865000
      cpvap := 0;                                                       07870000
      siop(status) := 0;                                                07875000
      siop(branchpt) := dstatsiop;   << read status entry >>            07880000
      siop(diagjmp) := -16;  << complete w/intrp hlt >>                 07885000
      start'hpib(ditp,siop,true);   << start chan prog >>               07890000
      goto printcont;   << for wrap-up >>                               07895000
                                                                        07900000
    end   << of read status processing >>                               07905000
                                                                        07910000
$page                                                                   07915000
<<---------------------------------------------------->>                07920000
<<                                                    >>                07925000
<<   identify [fcode=%110]                            >>                07930000
<<                                                    >>                07935000
                                                                        07940000
<<---------------------------------------------------->>                07945000
                                                                        07950000
   else if fcode = %110 and ioq'diag then                      <<06718>>07955000
                                                                        07960000
     begin                                                              07965000
       siop(dsbank) := %3000;   << identify cmd code >>                 07970000
       siop(dstatadr) := 0;   << initialize return id >>                07975000
                                                                        07980000
       cpvap := 0;                                                      07985000
       siop(status) := 0;                                               07990000
       siop(branchpt) := idsiop;   << branch-identify section >>        07995000
       siop(diagjmp) := -16;  << complete w/intrp hlt >>                08000000
       start'hpib(ditp,siop,true);   << start chan prog >>              08005000
       goto printcont;                                                  08010000
                                                                        08015000
     end   << of identify >>                                            08020000
                                                                        08025000
$page                                                                   08030000
<<---------------------------------------------------->>                08035000
<<                                                    >>                08040000
<<   self test initiate [fcode = %111]                >>                08045000
<<   self test result   [fcode = %112]                >>                08050000
<<                                                    >>                08055000
<<---------------------------------------------------->>                08060000
                                                                        08065000
   else if (fcode = %111 or fcode = %112) and ioq'diag then    <<06718>>08070000
                                                                        08075000
     begin                                                              08080000
       if fcode=%111 then                                               08085000
         begin                                                          08090000
         siop(rwctl).dcode := %10;  << write ctrl code >>               08095000
         siop(diagjmp) := -24;  << wait, dsj w/intrp hlt >>             08100000
         end                                                            08105000
       else                                                             08110000
         begin                                                          08115000
         siop(rwctl).dcode := 7;   << read ctrl code >>                 08120000
         siop(diagjmp) := -16;  << complete w/intrp hlt >>              08125000
         end;                                                           08130000
                                                                        08135000
       siop(rwctl).cmd := %17;   << self test secondary >>              08140000
       siop(dscount) := 1;   << 1 byte with subtest# >>                 08145000
       siop(dsbank).(0:8) := %100;   << start w/right byte >>           08150000
                                                                        08155000
       if fcode=%111 then   << check subtest# for initiate >>           08160000
         begin                                                          08165000
           tos := buffaddrd;  << load bank & buffer addr >>             08170000
           loadmemory;  << load first word >>                           08175000
           param := tos;  << subtest# >>                                08180000
           if param < 0 or param > 7 then  << not in range >>           08185000
             begin                                                      08190000
               tos := invalidop;                                        08195000
               goto iodone;                                             08200000
             end;                                                       08205000
         end;                                                           08210000
                                                                        08215000
       siop(dsbank).(8:8) := bank;                                      08220000
       siop(dstatadr) := buffaddr;                                      08225000
                                                                        08230000
       cpvap := 0;                                                      08235000
       siop(status) := 0;                                               08240000
       siop(branchpt) := dstatsiop;   << diagnostic entry >>            08245000
       start'hpib(ditp,siop,true);                                      08250000
       goto printcont;                                                  08255000
                                                                        08260000
     end   << of self test logic >>                                     08265000
                                                                        08270000
$page                                                                   08275000
<<---------------------------------------------------->>                08280000
<<                                                    >>                08285000
<<   loopback test:                                   >>                08290000
<<   write data - ping [fcode = %113]                 >>                08295000
<<   read data  - pong [fcode = %114]                 >>                08300000
<<                                                    >>                08305000
<<---------------------------------------------------->>                08310000
                                                                        08315000
   else if (fcode = %113 or fcode = %114) and ioq'diag then    <<06718>>08320000
                                                                        08325000
     begin                                                              08330000
       if fcode=%113 then                                               08335000
         begin                                                          08340000
         siop(rwctl).dcode := %10;  << write ctrl code >>               08345000
         siop(diagjmp) := -24;  << wait, dsj w/intrp hlt >>             08350000
         end                                                            08355000
       else                                                             08360000
         begin                                                          08365000
         siop(rwctl).dcode := 7;   << read ctrl code >>                 08370000
         siop(diagjmp) := -16;  << complete w/intrp hlt >>              08375000
         end;                                                           08380000
                                                                        08385000
      tos := ioq'count;                                        <<06718>>08390000
       if < then   << byte count >>                                     08395000
         count := -tos   << make positive >>                            08400000
       else   << word count >>                                          08405000
         count := tos&asl(1);   << change to byte count >>              08410000
                                                                        08415000
       if count<1 or count>256 then   << invalid req >>                 08420000
         begin                                                          08425000
         tos := invalidop;                                              08430000
         goto iodone;                                                   08435000
         end;                                                           08440000
                                                                        08445000
       siop(rwctl).cmd := %16;   << ping/pong secondary >>              08450000
       siop(dscount) := count;   << loopback data count >>              08455000
       siop(dsbank).(0:8) := 0;   << no special options >>              08460000
       siop(dsbank).(8:8) := bank;                                      08465000
       siop(dstatadr) := buffaddr;                                      08470000
                                                                        08475000
       cpvap := 0;                                                      08480000
       siop(status) := 0;                                               08485000
       siop(branchpt) := dstatsiop;   << diagnostic entry >>            08490000
       start'hpib(ditp,siop,true);                                      08495000
       goto printcont;                                                  08500000
                                                                        08505000
     end   << of loopback test logic >>                                 08510000
                                                                        08515000
                                                                        08520000
   else   << fall through >>                                            08525000
                                                                        08530000
                                                                        08535000
$page                                                                   08540000
                                                                        08545000
  printdone:                                                            08550000
     tos := goodio;                                                     08555000
                                                                        08560000
  iodone:                                                               08565000
     ioq'stat := tos;  << store return status >>               <<06718>>08570000
                                                               <<02697>>08575000
  exit:                                                        <<02697>>08580000
     lpdrvr := requestdone;                                             08585000
     return;                                                            08590000
                                                                        08595000
  chanerror:                                                            08600000
     tos := chanfail;                                                   08605000
     ditp(dserr) := [8/1,8/dlogerror];                                  08610000
     ditp(dlogerror) := cpvap;   << log error status >>                 08615000
                                                                        08620000
  badio:                                                                08625000
     ditp(dsave).(13:3) := 0;   << clear driver flags >>                08630000
     ioq'stat := tos;                                          <<06718>>08635000
     goto initdev;                                                      08640000
                                                                        08645000
  parityerror:                                                          08650000
     tos := parity;                                                     08655000
     ditp(dserr) := [8/1,8/dlogerror];                                  08660000
     ditp(dlogerror) := parityerr;                                      08665000
     goto badio;                                                        08670000
                                                                        08675000
  timeout:                                                              08680000
     tos := timouterr;                                                  08685000
     if ioq'diag then goto badio;                              <<06718>>08690000
     ditp(dserr) := [8/1,8/dlogerror];                                  08695000
     ditp(dlogerror) := cpvap;                                          08700000
     goto badio;                                                        08705000
                                                                        08710000
  uniterror:                                                            08715000
     tos := uniterr;                                                    08720000
     ditp(dserr) := [8/1,8/dlogerror];                                  08725000
     ditp(dlogerror) := siop(status);                                   08730000
     goto badio;                                                        08735000
                                                                        08740000
$page                                                                   08745000
<<****************************************************>>                08750000
<<                                                    >>                08755000
<<   line printer continuator section                 >>                08760000
<<                                                    >>                08765000
<<****************************************************>>                08770000
                                                                        08775000
  lpcont:                                                               08780000
     if cpvap.errorcode = 6 then   << dma abort >>                      08785000
       goto chanerror;                                                  08790000
                                                                        08795000
     if cpvap.errorcode = 7 then   << channel abort >>                  08800000
       begin                                                            08805000
         if cpvap.timedout = 1 then   << gic timeout >>                 08810000
           begin                                                        08815000
            ioq'qmisc.tout := 0;                               <<06718>>08820000
            if ioq'qmisc.tout=1 then <<2nd timeout reported>>  <<06718>>08825000
               goto timeout;                                            08830000
            ioq'qmisc.tout := 1;   << 1st time out >>          <<06718>>08835000
             cpvap := 0;                                                08840000
             siop(status) := 0;                                         08845000
             siop(branchpt) := statsiop;   << read status >>            08850000
             start'hpib(ditp,siop,true);   << maybe parity >>           08855000
             goto printcont;                                            08860000
           end else goto chanerror;                                     08865000
       end;                                                             08870000
                                                                        08875000
    if ioq'sfail then   << failure on delayed start i/o >>     <<06718>>08880000
       begin                                                            08885000
         tos := siofail;                                                08890000
         goto badio;                                                    08895000
       end;                                                             08900000
                                                                        08905000
<<---------------------------------------------------->>                08910000
<<                                                    >>                08915000
<<   lp not ready completion                          >>                08920000
<<                                                    >>                08925000
<<---------------------------------------------------->>                08930000
                                                                        08935000
     ditp(dtime).(0:1) := 0;                                            08940000
     if <> then   << timer popped >>                                    08945000
       begin                                                            08950000
                                                                        08955000
   lpnotready:                                                          08960000
        if ioq'diag then    << diagnostic completion >>        <<06718>>08965000
           goto timeout                                                 08970000
         else                                                           08975000
                                                                        08980000
        if iomessage(1,notrdymsg,%10000,ditp(dldev),           <<06718>>08985000
                      ,,,,opconsole) then                               08990000
   idlecp:                                                              08995000
           begin                                                        09000000
             cpvap := 0;                                                09005000
             siop(status) := 0;                                         09010000
             siop(branchpt) := idlesiop;   << idle cp entry >>          09015000
             start'hpib(ditp,siop,false);                               09020000
             if < then                                                  09025000
               begin                                                    09030000
                 tos := siofail;                                        09035000
                 goto badio;                                            09040000
               end;                                                     09045000
             ioq'qmisc.waitcode := notrdywait;<<set req state>><<06718>>09050000
             lpdrvr := notready;                                        09055000
             return;                                                    09060000
           end;                                                         09065000
                                                                        09070000
         tos := syserror;   << indicate failure because there >>        09075000
         goto badio;        << are no message link buffers >>           09080000
       end;                                                             09085000
                                                                        09090000
<<---------------------------------------------------->>                09095000
<<                                                    >>                09100000
<<   i/o status interrogation completion              >>                09105000
<<                                                    >>                09110000
<<---------------------------------------------------->>                09115000
                                                                        09120000
     if cpvap(1).(14:2) = 2 then   << status diagnosis is required >>   09125000
                                                                        09130000
       begin                                                            09135000
         if siop(status).pon = 1 then   << pon occurred >>              09140000
           begin                                                        09145000
             ioq'qmisc.ponbit := 1;  << set pon flag >>        <<06718>>09150000
             ditp(dsave).betjob := 1;   << between job >>               09155000
           end;                                                         09160000
                                                                        09165000
         if siop(status).online <> 1 then   << unit notready >>         09170000
           goto lpnotready;                                             09175000
                                                                        09180000
         if siop(status).paperbit = 1 then   << paper error >>          09185000
           goto lpnotready;                                             09190000
                                                                        09195000
         if siop(status).paritybit = 1 then                             09200000
           goto parityerror;   << parity error >>                       09205000
                                                                        09210000
         if siop(status).protobit = 1 then                              09215000
           goto uniterror;   << protocol error >>                       09220000
                                                                        09225000
                                                                        09230000
     <<                                            >>                   09235000
     <<  at this point, an extra pass of the idle  >>                   09240000
     <<  cp must be made to assure that a buffer   >>                   09245000
     <<  is ready for the next secondary command,  >>                   09250000
     <<  so the driver will not get out of synch   >>                   09255000
     <<  with the firmware.  this will be done     >>                   09260000
     <<  under the following conditions:           >>                   09265000
     <<                                            >>                   09270000
     <<    - pon condition (flagged by dsj 2)      >>                   09275000
     <<    - alarm condition which cleared up      >>                   09280000
     <<      showing a clean status but retained   >>                   09285000
     <<      the dsj 2 condition.                  >>                   09290000
     <<    - buffer ready bit not set in the       >>                   09295000
     <<      status word possibly due to noise     >>                   09300000
     <<      on the bus.                           >>                   09305000
     <<                                            >>                   09310000
                                                                        09315000
                                                                        09320000
         goto idlecp;                                                   09325000
                                                                        09330000
   restart:                                                             09335000
         if fcode = 1 then   << restart incomplete wrt operation >>     09340000
           begin                                                        09345000
                                                                        09350000
             if ioq'qmisc.buf'fill <> 0 then                   <<06718>>09355000
               begin   << fill buffer restart >>                        09360000
                 if siop(bcount) = 0 then   << oper done >>             09365000
                   goto printdone;                                      09370000
                 siop(branchpt) := fillsiop;                            09375000
                 goto contd;                                            09380000
               end;                                                     09385000
                                                                        09390000
             if ditp(dsave).prespace = 1 then                           09395000
               begin   << restart prespace operation >>                 09400000
                 if siop(bcount) <> 0 then                              09405000
                   siop(branchpt) := fillsiop                           09410000
                 else goto printdone;                                   09415000
                 if siop(pre'dcnt) <> 0 then                            09420000
                   siop(branchpt) := pre'dsbsiop;                       09425000
                 if siop(pre'cnt) <> 0 then                             09430000
                   siop(branchpt) := 0;                                 09435000
               end;                                                     09440000
                                                                        09445000
             if ditp(dsave).prespace = 0 then                           09450000
               begin   << restart postspace operation >>                09455000
                 if siop(post'dcnt) <> 0 then                           09460000
                   siop(branchpt) := post'dsbsiop                       09465000
                 else goto printdone;                                   09470000
                 if siop(post'cnt) <> 0 then                            09475000
                   siop(branchpt) := post'enbsiop;                      09480000
                 if siop(bcount) <> 0 then                              09485000
                   siop(branchpt) := fillsiop;                          09490000
                 if siop(pre'dcnt) <> 0 then                            09495000
                   siop(branchpt) := pre'dsbsiop;                       09500000
               end;                                                     09505000
                                                                        09510000
   contd:                                                               09515000
             if siop(bcount) <> 0 then                                  09520000
               begin   << recalculate buffer write >>                   09525000
                 tos := ioq'count;  << get total count >>      <<06718>>09530000
                 if < then                                              09535000
                   count := -tos                                        09540000
                 else                                                   09545000
                   count := tos & asl(1);   << change to byte >>        09550000
                 siop(memx).(8:8) := bank;   << reset bank >>           09555000
                 siop(baddr) := buffaddr +                              09560000
                 (count - siop(bcount))/2;   << reset adr w/offset >>   09565000
               end;                                                     09570000
                                                                        09575000
             start'hpib(ditp,siop,true);                                09580000
             goto printcont;                                            09585000
           end;                                                         09590000
                                                                        09595000
       end;                                                             09600000
                                                                        09605000
<<---------------------------------------------------->>                09610000
<<                                                    >>                09615000
<<   function dependencies completion                 >>                09620000
<<                                                    >>                09625000
<<---------------------------------------------------->>                09630000
                                                                        09635000
     if fcode = %17 then   << read status completion >>                 09640000
       goto printdone;                                                  09645000
                                                                        09650000
     if fcode = %110 then   << identify completion >>                   09655000
       begin                                                            09660000
       tos := buffaddrd;                                                09665000
       tos := siop(dstatadr);   << device id >>                         09670000
       storememory;                                                     09675000
       goto printdone;                                                  09680000
       end;                                                             09685000
                                                                        09690000
                                                                        09695000
    if ioq'qmisc.pre'to'post then                              << 8647>>09700000
      begin                                                    << 8647>>09705000
        ioq'qmisc.pre'to'post:=0;                              << 8647>>09710000
        goto lpinit;                                           << 8647>>09715000
      end;                                                     << 8647>>09720000
                   << do post for pre-to-post >>               <<06718>>09725000
    ditp(dsave).top := ioq'qmisc.peject;                       <<06718>>09730000
     goto printdone;     << got here - request completed >>             09735000
                                                                        09740000
                                                                        09745000
   end;                                                                 09750000
$page                                                                   09755000
   assemble(                                                            09760000
     pcal siodm;     << monitor >>                                      09765000
     pcal lpdrvr;    << initiator >>                                    09770000
     pcal lpdrvr;    << completor >>                                    09775000
     con  0;         << no io process >>                                09780000
     pcal lpinit;    << initialization >>                               09785000
     con  1;         << one interrupt handler >>                        09790000
     pcal gip'hpib); << interrupt handler >>                            09795000
   end.                                                                 09800000
