1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 prtdim_attach:
28 procedure (stream_name, prt, device, mode, iostatus, sdb_ptr);
29
30 dcl stream_name char (*);
31 dcl prt char (*);
32 dcl device char (*);
33 dcl mode char (*);
34 dcl iostatus bit (72) aligned;
35 dcl i fixed bin;
36 dcl area_ptr ptr;
37 dcl listen_based_area area ((16374)) based (area_ptr);
38 dcl wksp_max fixed bin (19);
39 dcl time_max fixed bin (52);
40 dcl rcp_state fixed bin;
41 dcl rcode fixed bin (35);
42 dcl char_cnt fixed bin (18);
43
44 dcl 1 ipc_message aligned like event_call_info;
45 dcl 1 rcp_info like printer_info aligned auto;
46
47 dcl CR char (1) init ("^M") int static options (constant);
48
49 dcl get_system_free_area_ entry (ptr);
50 dcl ipc_$create_ev_chn entry (fixed bin (71), fixed bin (35));
51 dcl ipc_$block entry (ptr, ptr, fixed bin (35));
52 dcl ipc_$delete_ev_chn entry (fixed bin (71), fixed bin (35));
53 dcl convert_ipc_code_ entry (fixed bin (35));
54 dcl rcp_$attach entry (char (*), ptr, fixed bin (71), char (*), bit (36) aligned, fixed bin (35));
55 dcl rcp_$check_attach entry (bit (36) aligned, ptr, char (*), fixed bin, fixed bin (19), fixed bin (52),
56 fixed bin, fixed bin (35));
57 dcl init_printer_$reset entry (ptr);
58 dcl ioi_$set_status entry (fixed bin, fixed bin (18), fixed bin (8), fixed bin (35));
59 dcl ioi_$workspace entry (fixed bin, ptr, fixed bin (18), fixed bin (35));
60 dcl rcp_$detach entry (bit (36) aligned, bit (*), fixed bin, char (*), fixed bin (35));
61 dcl prt_conv_ entry (ptr, fixed bin (18), ptr, fixed bin (18), ptr);
62 dcl prtdim_util$init entry (ptr, fixed bin (35));
63 dcl prtdim_eurc_util$init entry (ptr, fixed bin (35));
64 dcl prtdim_eurc_util$initialize_workspace entry (ptr);
65 dcl prtdim_util$load_vfc entry (ptr, fixed bin (35));
66 dcl prtdim_eurc_util$load_vfc entry (ptr, fixed bin (35));
67 dcl timer_manager_$reset_alarm_wakeup entry (fixed bin (71));
68 dcl config_$find entry (char (4) aligned, ptr);
69 dcl config_$find_periph entry (char (4) aligned, ptr);
70
71 dcl error_table_$bigarg fixed bin (35) ext static;
72 dcl error_table_$ionmat fixed bin (35) ext;
73 dcl error_table_$no_room_for_dsb fixed bin (35) ext;
74 dcl error_table_$no_operation fixed bin (35) ext;
75 dcl config_deck$ ext;
76
77 dcl (addr, addrel, null, ptr, rel, substr, unspec) builtin;
78 %page;
79
80 iostatus = "0"b;
81 if sdb_ptr ^= null () then do;
82 substr (iostatus, 1, 36) = unspec (error_table_$ionmat);
83 go to exit;
84 end;
85
86 call get_system_free_area_ (area_ptr);
87 allocate sdb in (listen_based_area) set (sdb_ptr);
88 if sdb_ptr = null then do;
89 substr (iostatus, 1, 36) = unspec (error_table_$no_room_for_dsb);
90 go to exit;
91 end;
92
93 sdb.areap = area_ptr;
94
95 outer_module_name = prt;
96 device_name_list_ptr = addr (sdb.device_name);
97 next_device_ptr = null;
98 name_size = 32;
99 sdb.name = device;
100 sdb.stream_name = stream_name;
101
102 call ipc_$create_ev_chn (sdb.evchan, rcode);
103
104 if rcode ^= 0 then do;
105 call convert_ipc_code_ (rcode);
106 go to free1;
107 end;
108 ev_list.count = 1;
109
110 pip = addr (sdb.info);
111 prt_info.devname = substr (sdb.name, 1, 4);
112
113 printer_info_ptr = addr (rcp_info);
114 rcp_info.version_num = PRINTER_INFO_VERSION_1;
115 rcp_info.usage_time = 0;
116 rcp_info.wait_time = 0;
117 rcp_info.system_flag = "0"b;
118 rcp_info.device_name = substr (sdb.name, 1, 8);
119
120 call rcp_$attach ("printer", printer_info_ptr, sdb.evchan, "", rcp_id, rcode);
121 if rcode ^= 0 then go to free;
122
123 check: call rcp_$check_attach (rcp_id, printer_info_ptr, "", prt_info.devx, wksp_max, time_max,
124 rcp_state, rcode);
125 if rcode ^= 0 then go to free;
126
127 go to attach_state (rcp_state);
128
129 attach_state (1):
130 call ipc_$block (addr (sdb.ev_list), addr (ipc_message), rcode);
131 if rcode ^= 0 then do;
132 call convert_ipc_code_ (rcode);
133 go to free;
134 end;
135 go to check;
136
137 attach_state (2):
138 attach_state (3):
139 go to free;
140
141 attach_state (0):
142 prt_info.model = rcp_info.model;
143 prt_info.train = rcp_info.print_train;
144 prt_info.line_length = rcp_info.line_length;
145
146 call set_mpc_type;
147 if ^sdb.flags.eurc then wksp_max = 1024;
148 else wksp_max = min (2048, wksp_max);
149 sdb.data_end = wksp_max;
150 call ioi_$workspace (prt_info.devx, sdb.wsegp, (wksp_max), rcode);
151 if rcode ^= 0 then go to free;
152
153 if sdb.flags.eurc then do;
154 sdb.max_dcw_size = 65;
155 if wksp_max < 2048 then sdb.max_dcws, sdb.n_dcws = 32;
156 else sdb.max_dcws, sdb.n_dcws = 62;
157 sdb.max_buffers, sdb.n_buffers = 3;
158 prt_bufferp = addr (prt_buffers (0));
159 sdb.data_end = sdb.data_end - size (null () -> istat);
160 call ioi_$set_status (prt_info.devx, (sdb.data_end), 1, rcode);
161 if rcode ^= 0 then go to free;
162 sdb.status_ptr = ptr (wsegp, sdb.data_end);
163 sdb.data_end = sdb.data_end - 1;
164 sdb.data_begin, sdb.bgin, sdb.stop = size (prt_buffers);
165 sdb.b_begin, sdb.b_stop = 0;
166 call prtdim_eurc_util$init (sdb_ptr, rcode);
167 if rcode ^= 0 then go to free;
168 pcip = addr (sdb.conv_info);
169 call prt_conv_ (addr (CR), 1, wsegp, char_cnt, pcip);
170 if char_cnt > 4 then do;
171 rcode = error_table_$bigarg;
172 go to free;
173 end;
174 sdb.null_line_data = wseg (0);
175 dcwp = addr (sdb.null_line_dcw);
176 string (dcw) = ""b;
177 dcw.address = bit (sdb.data_end);
178 dcw.tally = bit (bin (1, 12), 12);
179 call init_printer_$reset (pcip);
180 if mode ^= "save_vfc" then do;
181 call prtdim_eurc_util$load_vfc (sdb_ptr, rcode);
182 if rcode = error_table_$no_operation then rcode = 0;
183 else if rcode ^= 0 then go to free;
184 end;
185 end;
186 else do;
187 sdb.data_begin, sdb.bgin, sdb.stop = 0;
188 call prtdim_util$init (sdb_ptr, rcode);
189 if rcode ^= 0 then go to free;
190 if mode ^= "save_vfc" then do;
191 call prtdim_util$load_vfc (sdb_ptr, rcode);
192 if rcode = error_table_$no_operation then rcode = 0;
193 else if rcode ^= 0 then go to free;
194 end;
195 end;
196
197 idcwp = addr (prt_info.print_idcw);
198 if sdb.flags.eurc then idcw.control = "00"b;
199 else idcw.control = "10"b;
200
201 sdb.prev = 0;
202 sdb.wait_flag = "0"b;
203 sdb.running = "0"b;
204 sdb.marker_count = 0;
205 sdb.paper_low = "0"b;
206 sdb.error_count = 0;
207 sdb.reload_vfc_train_after_special = "0"b;
208 sdb.chars_printed = 0;
209 sdb.aborting = "0"b;
210 sdb.version = 1;
211
212 if sdb.flags.eurc then
213 call prtdim_eurc_util$initialize_workspace (sdb_ptr);
214
215 return;
216
217 %page;
218
219 free:
220 free1: substr (iostatus, 1, 36) = unspec (rcode);
221
222 go to detach;
223
224
225
226 prtdim_detach: entry (sdb_ptr, device, mode, iostatus);
227
228 iostatus = "0"b;
229
230 detach: call timer_manager_$reset_alarm_wakeup (sdb.evchan);
231 call ipc_$delete_ev_chn (sdb.evchan, rcode);
232 if rcode ^= 0 then if substr (iostatus, 1, 36) = "0"b then do;
233 call convert_ipc_code_ (rcode);
234 substr (iostatus, 1, 36) = unspec (rcode);
235 end;
236
237 pip = addr (sdb.info);
238
239 call rcp_$detach (rcp_id, "0"b, error_count, "", rcode);
240 if rcode ^= 0 then
241 if substr (iostatus, 1, 36) = "0"b then
242 substr (iostatus, 1, 36) = unspec (rcode);
243
244 area_ptr = sdb.areap;
245 free sdb in (listen_based_area);
246
247 exit: substr (iostatus, 52, 1) = "1"b;
248 substr (iostatus, 41, 1) = "1"b;
249 return;
250
251 %page;
252
253
254 set_mpc_type: proc;
255
256 call config_$find_periph (substr (sdb.name, 1, 4), prph_prt_cardp);
257 if prph_prt_cardp = null then return;
258 mpc_cardp = null;
259 do while ("1"b);
260 call config_$find ("mpc", mpc_cardp);
261 if mpc_cardp = null then do;
262
263
264
265
266 sdb.flags.eurc = "1"b;
267 return;
268 end;
269 if mpc_card.port (1).iom = prph_prt_card.iom &
270 mpc_card.port (1).chan <= prph_prt_card.chan &
271 prph_prt_card.chan < mpc_card.port (1).chan + mpc_card.port (1).nchan then do;
272 do i = 1 to hbound (eurc_model_numbers, 1);
273 if mpc_card.model = eurc_model_numbers (i) then do;
274 sdb.flags.eurc = "1"b;
275 return;
276 end;
277 end;
278 return;
279 end;
280 end;
281
282 end set_mpc_type;
283
284
285 %page; %include config_mpc_card;
286 %page; %include config_prph_prt_card;
287 %page; %include eurc_model_numbers;
288 %page; %include event_call_info;
289 %page; %include ioi_stat;
290 %page; %include iom_dcw;
291 %page; %include iom_pcw;
292 %page; %include prt_sdb;
293 %page; %include prt_info;
294 %page; %include prt_conv_info;
295 %page; %include rcp_printer_info;
296
297 end prtdim_attach;