1 /* ***********************************************************
  2    *                                                         *
  3    * Copyright, (C) Honeywell Information Systems Inc., 1982 *
  4    *                                                         *
  5    *********************************************************** */
  6 /* ******************************************************
  7    *                                                    *
  8    *                                                    *
  9    * Copyright (c) 1972 by Massachusetts Institute of   *
 10    * Technology and Honeywell Information Systems, Inc. *
 11    *                                                    *
 12    *                                                    *
 13    ****************************************************** */
 14 
 15 /* PRTDIM_UTIL - Utility Functions for the Multics printer DIM.
 16    coded 6/12/75 by Noel I. Morris                          */
 17 /* Modified 83-10-21 by E. N. Kittlitz for eurc/urmpc partitioning */
 18 
 19 prtdim_util$init: proc (sdb_ptr, rcode);
 20 
 21 dcl  rcode fixed bin (35);                                  /* error code */
 22 
 23 dcl  temp_iom_stat bit (72) aligned,                        /* temp area to hold iom status */
 24      load_proc entry (ptr, ptr, entry, fixed bin (35)) variable, /* procedure to load train or VFC image */
 25      save_buffer (100) fixed bin (35),                      /* holding buffer for workspace */
 26      wseg_low (100) fixed bin (35) based (wsegp),           /* for saving and restoring workspace */
 27      ecode fixed bin (35);                                  /* internal error code */
 28 
 29 dcl  ipc_$block entry (ptr, ptr, fixed bin (35)),
 30      ioi_$connect entry (fixed bin, fixed bin (18), fixed bin (35)),
 31      init_printer_ entry (ptr, ptr, entry, fixed bin (35)),
 32      init_printer_$load_image entry (ptr, ptr, entry, fixed bin (35)),
 33      init_printer_$load_vfc entry (ptr, ptr, entry, fixed bin (35)),
 34      analyze_device_stat_ entry (char (*) aligned, ptr, bit (72) aligned, bit (18) aligned),
 35      analyze_system_fault_ entry (char (*) aligned, bit (72) aligned);
 36 
 37 dcl  error_table_$net_timeout fixed bin (35) ext,
 38      error_table_$no_operation fixed bin (35) ext,
 39      prt_status_table_$prt_status_table_ ext;
 40 
 41 dcl 1 ipc_message aligned,                                  /* structure for receiving ipc_ message */
 42     2 chname fixed bin (71),
 43     2 message fixed bin (71),
 44     2 sender bit (36),
 45     2 origin,
 46       3 devsignal bit (18),
 47       3 ring bit (18),
 48     2 channel_index fixed bin;
 49 
 50 dcl (addr, addrel, bit, rel, string) builtin;
 51 
 52 
 53 /* ^L */
 54 
 55 
 56 % include prt_sdb;
 57 
 58 % include prt_info;
 59 
 60 
 61 /* ^L */
 62 
 63 % include prt_conv_info;
 64 
 65 
 66 /* ^L */
 67 
 68 % include iom_pcw;
 69 
 70 % include iom_dcw;
 71 
 72 /* ^L */
 73 
 74 % include ioi_stat;
 75 
 76 
 77 /* ^L */
 78 
 79           pip = addr (sdb.info);                            /* Get pointer to printer info. */
 80           pcip = addr (sdb.conv_info);                      /* Get pointer to conversion info. */
 81 
 82           call init_printer_ (pip, pcip, sync_io, rcode);   /* Initialize the printer information. */
 83 
 84           sdb.stop_every,
 85                sdb.stop_counter = 0;                        /* Initialize page stop counters. */
 86           sdb.mode = "0"b;                                  /* Clear all mode bits. */
 87 
 88           return;
 89 
 90 
 91 /* ^L */
 92 
 93 load_image: entry (sdb_ptr, rcode);
 94 
 95 
 96           load_proc = init_printer_$load_image;             /* Set procedure pointer. */
 97           go to load_join;                                  /* Join common code. */
 98 
 99 
100 
101 
102 load_vfc: entry (sdb_ptr, rcode);
103 
104 
105           load_proc = init_printer_$load_vfc;               /* Set procedure pointer. */
106 
107 load_join:
108           pip = addr (sdb.info);                            /* Get pointer to printer info. */
109           pcip = addr (sdb.conv_info);                      /* Get pointer to conversion info. */
110 
111           save_buffer = wseg_low;                           /* Save the contents of the workspace. */
112 
113           call load_proc (pip, pcip, sync_io, rcode);       /* Call out to load the train or VFC image. */
114 
115           wseg_low = save_buffer;                           /* Restore the workspace. */
116 
117           if rcode = 5 then                                 /* If invalid operation for thi model ... */
118                rcode = error_table_$no_operation;           /* Reflect appropriate error code. */
119 
120           return;
121 
122 
123 /* ^L */
124 
125 sync_io:  proc (i, rw, d, l, e);                            /* internal proc to do synchronous I/O */
126 
127 dcl  i bit (36) aligned,                                    /* IDCW */
128      rw bit (2) aligned,                                    /* RW bits */
129      d ptr,                                                 /* pointer to data */
130      l fixed bin (12),                                      /* length of data */
131      e bit (1) aligned;                                     /* error flag */
132 
133 dcl  sdata (l) fixed bin based,                             /* for copying data */
134      dp ptr,                                                /* pointer to place for data */
135      b bit (18) aligned;                                    /* status flags */
136 
137 
138                idcwp = wsegp;                               /* Get pointer to place for IDCW. */
139                string (idcw) = i;                           /* Copy the IDCW. */
140 
141                dcwp = addrel (idcwp, 1);                    /* Get pointer to data xfer DCW. */
142                dp = addrel (dcwp, 1);                       /* Get pointer to place for data. */
143 
144                string (dcw) = "0"b;                         /* Clear the DCW. */
145                dcw.address = rel (dp);                      /* Insert address. */
146                dcw.tally = bit (l);                         /* And tally. */
147 
148                if rw & "01"b then                           /* If writing ... */
149                     dp -> sdata = d -> sdata;               /* Copy the data in workspace segment. */
150 
151 redo_sync:
152                call ioi_$connect (prt_info.devx, 0, ecode); /* Fire up the IOM. */
153                if ecode ^= 0 then do;                       /* This should not happen. */
154                     e = "1"b;
155                     return;
156                end;
157 
158 
159 /* ^L */
160 
161 sync_wait:
162                call ipc_$block (addr (sdb.ev_list), addr (ipc_message), ecode);
163                if ecode ^= 0 then do;                       /* Wait for I/O to complete. */
164                     e = "1"b;
165                     return;
166                end;
167 
168                imp = addr (ipc_message.message);            /* get pointer to ioi event message */
169                if imess.level = "111"b then go to redo_sync; /* if this is a special interupt */
170 
171                if imess.st then do;                         /* if status is present */
172                     if imess.time_out then do;              /* if timeout occured */
173                          e = "1"b;                          /* error occured */
174                          ecode = error_table_$net_timeout;  /* caused by time out */
175                          return;
176                     end;
177 
178                     temp_iom_stat = imess.status;           /* copy status to double word */
179                     if imess.level = "011"b then do;        /* If termination ... */
180                          if imess.er then                   /* If error ... */
181                               call analyze_device_stat_ (prt_info.devname, addr (prt_status_table_$prt_status_table_),
182                               temp_iom_stat, b);
183                     end;                                    /* Analyze the status. */
184 
185                     else if imess.level = "001"b then       /* If system fault ... */
186                          call analyze_system_fault_ (prt_info.devname, temp_iom_stat);
187 
188                     if imess.er then go to sync_wait;       /* If error, wait for special. */
189                end;
190                else go to sync_wait;                        /* If no status, try for more. */
191 
192                if rw & "10"b then                           /* If reading ... */
193                     d -> sdata = dp -> sdata;               /* Copy the data. */
194 
195                e = "0"b;                                    /* Clear the error switch. */
196 
197                return;                                      /* Return to caller. */
198 
199 
200           end sync_io;
201 
202 
203 
204 
205      end prtdim_util$init;