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