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
28
29 fnp_init:
30 procedure;
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46 NOTE
47
48
49
50
51
52
53
54 dcl astep pointer;
55 dcl i fixed bin;
56 dcl j fixed bin;
57 dcl bufsize fixed bin;
58 dcl cptr ptr;
59 dcl prot_ptr ptr;
60 dcl p ptr;
61 dcl tsdw fixed bin (71);
62 dcl tty_area_size fixed bin (18);
63 dcl code fixed bin (35);
64 dcl cl fixed bin;
65 dcl ptp pointer;
66 dcl modelx fixed bin (17);
67 dcl uncp_fnp_configured bit (1);
68
69 dcl syserr entry options (variable);
70 dcl syserr$error_code entry options (variable);
71 dcl config_$find_2 entry (character (4) aligned, character (4) aligned, pointer);
72 dcl config_$find_parm entry (char (*), ptr);
73 dcl make_sdw$unthreaded entry (fixed bin (18), fixed bin (71), ptr, ptr);
74 dcl pc_abs$wire_abs entry (ptr, fixed bin, fixed bin, fixed bin (35));
75 dcl pmut$swap_sdw entry (ptr, ptr);
76 dcl get_fnp_name_ entry (fixed bin) returns (char (32));
77 dcl tty_space_man$get_perm_space entry (fixed bin, ptr);
78
79 dcl slt$ external;
80 dcl sys_info$page_size fixed bin external;
81
82 dcl (addr, addrel, bin, currentsize, divide, empty, hbound, lbound,
83 mod, null, pointer, ptr, rel, segno, size, string, substr, unspec) builtin;
84
85 dcl 1 prot_parm aligned based (prot_ptr),
86 2 name char (4),
87 2 size fixed bin;
88
89 dcl 1 tty_parm aligned based (cptr),
90 2 name char (4),
91 2 size fixed bin;
92
93 dcl dn355_mailbox$ fixed bin ext;
94
95 dcl 1 dn355mbx_array (max_no_355s) based (addr (dn355_mailbox$)) aligned,
96 2 actual_mbx (192) fixed bin (35);
97
98 dcl tty_area area (tty_area_size) based (addr (tty_area$));
99 dcl tty_area$ external;
100
101 declare FNP_CONFIG_EVENT char (4) aligned init ("fnpc");
102
103
104
105 dcl DEFAULT_BUFSIZE fixed bin int static options (constant) init (5120);
106 dcl MAX_PROT_CHNLS fixed bin int static options (constant) init (128);
107 dcl MIN_BUFSIZE fixed bin int static options (constant) init (256);
108 dcl TTY_PERM_SPACE fixed bin int static options (constant) init (2048);
109 dcl UNCP_CQ_SIZE fixed bin int static options (constant) init (2000);
110 dcl EXPECTED_FIELDS fixed bin int static options (constant) init (5);
111 dcl PAGE fixed bin int static options (constant) init (1024);
112 dcl WORD15 fixed bin int static options (constant) init (15);
113 dcl BIT36 fixed bin int static options (constant) init (36);
114 dcl TRACE_INDEX bit (36) int static options (constant) init ("000000000001"b3);
115
116 ^L
117
118 ttybp = addr (tty_buf$);
119 infop = addr (dn355_data$);
120
121
122
123 call config_$find_parm ("ttyb", cptr);
124 if cptr = null
125 then bufsize = DEFAULT_BUFSIZE;
126 else bufsize = tty_parm.size;
127 sltp = addr (slt$);
128 sltep = addr (slt.seg (segno (ttybp)));
129
130 cl = divide (bufsize + sys_info$page_size - 1, sys_info$page_size, 18, 0);
131
132 slte_uns.bit_count = cl * BIT36 * PAGE;
133 slte_uns.max_length, slte_uns.cur_length = cl;
134 slte_uns.wired = "0"b;
135
136 call make_sdw$unthreaded (segno (ttybp), tsdw, astep, ptp);
137 call pc_abs$wire_abs (astep, 0, cl, code);
138 if code ^= 0 then call syserr$error_code (CRASH, code, "fnp_init: Unable to abs_wire tty_buf.");
139
140 call pmut$swap_sdw (ttybp, addr (tsdw));
141 begin;
142 declare tty_buf_pages (slte_uns.cur_length, 1024) bit (36) aligned based (ttybp);
143 tty_buf_pages = ""b;
144 end;
145
146 tty_buf.absorig = sys_info$page_size * FIRST_TTY_BUF_PAGEX;
147
148 tty_buf.lct_ptr = null;
149
150 p = addr (tty_buf.free_space);
151
152
153
154 i = bin (rel (p), 18);
155
156 string (tty_buf.trace) = ""b;
157 call config_$find_parm ("ttyt", cptr);
158 if cptr ^= null () then do;
159 i = i + mod (i, 2);
160 trace_array_ptr = pointer (ttybp, i);
161 trace_array.num_entries = tty_parm.size;
162 trace_array.idx = TRACE_INDEX;
163 tty_buf.trace.data_offset = rel (trace_array_ptr);
164 i = bin (rel (addrel (trace_array_ptr, currentsize (trace_array))));
165 end;
166
167 i = i + WORD15;
168 i = i - mod (i, WORD15+1);
169 p = ptr (p, i);
170 tty_buf.borig, tty_buf.free = rel (p);
171
172 tty_buf.bleft = bufsize - bin (tty_buf.borig);
173 if tty_buf.bleft < MIN_BUFSIZE
174 then call syserr (CRASH, "fnp_init: Less than 256 words of free space in tty_buf: ^d", tty_buf.bleft);
175 free_blockp = p;
176 free_block.next = "0"b;
177 free_block.size = tty_buf.bleft;
178
179 tty_buf.tty_area_lock.event = TTY_AREA_LOCK_EVENT;
180
181
182
183 tty_area_size = get_seg_size (addr (tty_area$));
184 tty_area = empty ();
185
186
187
188 ttytp = addr (tty_tables$);
189 tty_tables_hdr.event = tty_ev;
190 tty_tables_hdr.table_area_size = get_seg_size (ttytp) - currentsize (tty_tables_hdr);
191 tty_tables_hdr.table_area = empty ();
192
193
194
195
196 call config_$find_parm ("prot", prot_ptr);
197 if prot_ptr = null
198 then datanet_info.protocol_datap = null;
199 else do;
200 if prot_parm.size > MAX_PROT_CHNLS then
201 call syserr (CRASH, "fnp_init: The number of configured protocol channels of ^d^/^-exceeds the maximum allowed of ^d.",
202 prot_parm.size, MAX_PROT_CHNLS);
203 else protocol_channels = prot_parm.size;
204 call tty_space_man$get_perm_space (size (protocol_data), protocol_data_ptr);
205 protocol_data.max_channels = protocol_channels;
206 datanet_info.protocol_datap = protocol_data_ptr;
207 end;
208
209
210
211
212 tty_buf.fnp_config_flags (*) = "0"b;
213 datanet_info.configuration_lock.pid = ""b;
214 datanet_info.configuration_lock.event = unspec (FNP_CONFIG_EVENT);
215 datanet_info.configuration_lock.flags = "0"b;
216 uncp_fnp_configured = "0"b;
217 do i = 1 to max_no_355s;
218 fnpp = addr (datanet_info.per_datanet (i));
219 fnp_info.mbx_pt = null;
220 fnp_info.lcte_ptr = null;
221 do j = lbound(fnp_info.lsla_idx, 1) to hbound(fnp_info.lsla_idx, 1);
222
223 if j <= hbound(fnp_info.hsla_idx, 1) then
224 fnp_info.hsla_idx (j) = -1;
225 fnp_info.lsla_idx (j) = -1;
226 end;
227
228 mbxp = addr (dn355mbx_array (i));
229 unspec (datanet_mbx) = ""b;
230
231 prph_fnp_cardp = null ();
232 call config_$find_2 ("prph", "fnp" || substr (get_fnp_name_ (i), 1, 1), prph_fnp_cardp);
233 if prph_fnp_cardp ^= null () then do;
234 if prph_fnp_card.n_fields ^= EXPECTED_FIELDS | (prph_fnp_card.field_type (5) ^= CONFIG_STRING_TYPE)
235 | (prph_fnp_card.state ^= "on" & prph_fnp_card.state ^= "off")
236 then call syserr (CRASH, "fnp_init: Invalid state on prph ^a card.", prph_fnp_card.name);
237
238 do modelx = 1 to hbound (fnp_models, 1) while (prph_fnp_card.model ^= fnp_models (modelx));
239 end;
240 if modelx > hbound (fnp_models, 1) | ^supported_fnp (modelx)
241 then call syserr (CRASH, "fnp_init: Invalid model # (^d) on prph ^a card.",
242 prph_fnp_card.model, prph_fnp_card.name);
243 if modelx = DN7100 then uncp_fnp_configured = "1"b;
244
245 fnpp = addr (datanet_info.per_datanet (i));
246 tty_buf.fnp_config_flags (i) = "1"b;
247 fnp_info.available = prph_fnp_card.state = "on";
248 fnp_info.mbx_pt = mbxp;
249 fnp_info.fnp_number = i;
250 fnp_info.fnp_tag = substr (get_fnp_name_ (i), 1, 1);
251 fnp_info.ptx = -1;
252 fnp_info.ptp = null ();
253 datanet_info.no_of_355s = datanet_info.no_of_355s + 1;
254
255 call io_chnl_util$iom_to_name (prph_fnp_card.iom, (prph_fnp_card.chan), fnp_info.io_chanid, code);
256 if code ^= 0 then call syserr (CRASH, "fnp_init: code ^o from io_chnl_util$iom_to_name.", code);
257
258
259 end;
260 end;
261 if datanet_info.no_of_355s = 0 then call syserr (ANNOUNCE, "fnp_init: Warning: no FNP's configured.");
262
263
264
265 if uncp_fnp_configured then do;
266 call tty_space_man$get_perm_space (TTY_PERM_SPACE, datanet_info.uncp_bufp);
267
268 uncpbp = datanet_info.uncp_bufp;
269 uncp_buf.cq_max_size = UNCP_CQ_SIZE;
270 uncp_buf.cq_free = uncp_buf.cq_max_size;
271 uncp_buf.cq_hbound = uncp_buf.cq_max_size - 1;
272
273 end;
274 else datanet_info.uncp_bufp = null ();
275
276 cptr = null ();
277 call config_$find_parm ("tfnp", cptr);
278 datanet_info.trace = (cptr ^= null ());
279 cptr = null ();
280 call config_$find_parm ("dfnp", cptr);
281 datanet_info.debug_stop = (cptr ^= null ());
282
283 return;
284 %page;
285 get_seg_size:
286 proc (segp) returns (fixed bin (18));
287
288 dcl segp ptr;
289 dcl seg_no fixed bin (18);
290
291
292 seg_no = segno (segp);
293 sltp = addr (slt$);
294 sltep = addr (slt.seg (seg_no));
295
296 return (slte_uns.max_length * sys_info$page_size);
297
298 end get_seg_size;
299 %page;
300 %include tty_buf;
301 %include uncp_buf;
302 %include mcs_trace_data;
303 %include tty_buffer_block;
304 %include tty_tables;
305 %include config_deck;
306 %include config_prph_fnp_card;
307 %include dn355_data;
308 %include slt;
309 %include slte;
310 %include syserr_constants;
311 %include dn355_mailbox;
312 %include io_chnl_util_dcls;
313 %include fnp_types;
314 %include protocol_data;
315 %page;
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429 end fnp_init;