1 /****^  ***********************************************************
  2         *                                                         *
  3         * Copyright, (C) BULL HN Information Systems Inc., 1989   *
  4         *                                                         *
  5         * Copyright, (C) Honeywell Bull Inc., 1987                *
  6         *                                                         *
  7         * Copyright, (C) Honeywell Information Systems Inc., 1982 *
  8         *                                                         *
  9         * Copyright (c) 1972 by Massachusetts Institute of        *
 10         * Technology and Honeywell Information Systems, Inc.      *
 11         *                                                         *
 12         *********************************************************** */
 13 
 14 
 15 
 16 
 17 /****^  HISTORY COMMENTS:
 18   1) change(88-06-14,Berno), approve(88-07-13,MCR7928),
 19      audit(88-06-14,Parisek), install(88-07-19,MR12.2-1061):
 20      Add support for the uncp multiplexer to implement the DSA gateway
 21      interface.
 22   2) change(89-03-20,Parisek), approve(89-06-01,MCR8110),
 23      audit(89-10-09,Farley), install(89-10-25,MR12.3-1100):
 24      Add support of protocol mpx.
 25                                                    END HISTORY COMMENTS */
 26 
 27 
 28 /* format: style4,delnl,insnl,tree,ifthenstmt,indnoniterend */
 29 fnp_init:
 30      procedure;                                             /* FNP initialization for hardcore */
 31 
 32 /* extracted from fnp_init on 5/11/76 by Robert S. Coren */
 33 /* Modified 9/12/78 by J. Stern to initialize tty_buf, tty_area, and tty_tables */
 34 /* Modified January 1980 by C. Hornig for MCM tracing */
 35 /* Modified April 1981 by Chris Jones for io_manager conversion */
 36 /* Modified February 1982 by C. Hornig for MR10 io_manager */
 37 /* Modified November 1982 by Robert Coren to explicitly clear dn355_mailbox */
 38 /* Modified 83-12-14 BIM to leave iom_manager assignment for FNP bootload time. */
 39 /* Modified 84-07-09 MMP (and BIM) to insert model in prph fnp card. */
 40 /* Modified 1984-07-30 BIM for paged mode IOM. */
 41 /* Modified 1984-10-18 BIM to abs_wire tty_buf. *BLUSH!* */
 42 /* Modified November 1984 by Robert Coren to initialize tty_area_lock.event. */
 43 /*                         UNCP MPX                                         */
 44 /* Report modifications for the Datanet 7100, August 85 */
 45 
 46 /**** NOTE: two undocumented parameters are checked here:
 47 
 48       dfnp turns on dn355_data.debug_stop,
 49       tfnp turns on dn533_data.trace.
 50 
 51       See the code of fnp_util and fnp_multiplexer to see what they do. */
 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);                   /* allow 300(8) per mbx */
 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 /* CONSTANTS */
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$);                          /* get ptrs to tty_buf and dn355_data */
119           infop = addr (dn355_data$);
120 
121 /* allocate and setup tty_buf now. */
122 
123           call config_$find_parm ("ttyb", cptr);            /* get ptr to ttyb parameter */
124           if cptr = null
125           then bufsize = DEFAULT_BUFSIZE;                   /* default size of tty_buf is 5K */
126           else bufsize = tty_parm.size;                     /* unless TTYB nnnn was given */
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;                            /* make_sdw will not wire the right way */
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));          /* swap in the sdw setup by get_main */
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                                                             /* origin in IO segment */
148           tty_buf.lct_ptr = null;
149 
150           p = addr (tty_buf.free_space);                    /* get ptr to start of free space */
151 
152 /**** tty_buf is not at location 0 of the I/O segment */
153 
154           i = bin (rel (p), 18);                            /* mod pointer to next 16 words */
155 
156           string (tty_buf.trace) = ""b;
157           call config_$find_parm ("ttyt", cptr);            /* need a trace table be allocated */
158           if cptr ^= null () then do;
159                i = i + mod (i, 2);                          /* must be at even word */
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);            /* free list of blocks starts here */
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;                           /* one block */
177           free_block.size = tty_buf.bleft;
178 
179           tty_buf.tty_area_lock.event = TTY_AREA_LOCK_EVENT;
180 
181 /* initialize tty_area */
182 
183           tty_area_size = get_seg_size (addr (tty_area$));
184           tty_area = empty ();
185 
186 /* initialize tty_tables segment */
187 
188           ttytp = addr (tty_tables$);
189           tty_tables_hdr.event = tty_ev;                    /* init wait event for tty_tables lock */
190           tty_tables_hdr.table_area_size = get_seg_size (ttytp) - currentsize (tty_tables_hdr);
191           tty_tables_hdr.table_area = empty ();             /* init table area */
192 
193 /* search for protocol "prot" parameter in the config deck then do
194    allocation/initialization of protocol_data if one is found */
195 
196           call config_$find_parm ("prot", prot_ptr);        /* get ptr to PROT parameter */
197           if prot_ptr = null                                /* site not running "protocol_mpx" software */
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 /* read FNP cards and do init */
211 
212           tty_buf.fnp_config_flags (*) = "0"b;              /* start with no fnps configured */
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;                          /* set up la indices */
218                fnpp = addr (datanet_info.per_datanet (i));
219                fnp_info.mbx_pt = null;                      /* start null */
220                fnp_info.lcte_ptr = null;
221                do j = lbound(fnp_info.lsla_idx, 1) to hbound(fnp_info.lsla_idx, 1);
222                                                             /* initialize HSLA/LSLA indices */
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));            /* get addr of this mbx */
229                unspec (datanet_mbx) = ""b;                  /* make sure whole mailbox starts out 0 */
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;    /* its in the config deck */
247                     fnp_info.available = prph_fnp_card.state = "on";
248                     fnp_info.mbx_pt = mbxp;                 /* place ptr to mbx in per dn slot */
249                     fnp_info.fnp_number = i;
250                     fnp_info.fnp_tag = substr (get_fnp_name_ (i), 1, 1);
251                     fnp_info.ptx = -1;                      /* not yet known */
252                     fnp_info.ptp = null ();                 /* don't allocate until/unless loaded */
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                                                             /* something wrong here... */
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  /* Add for the Datanet 7100. */
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;     /* Start of the free space */
271                uncp_buf.cq_hbound = uncp_buf.cq_max_size - 1;
272                                                             /* The circular queue is a table (0:cq_max_size - 1) */
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));                  /* gets segment sizes from the slt */
287 
288 dcl  segp ptr;                                              /* ptr to seg whose size is wanted */
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 /* BEGIN MESSAGE DOCUMENTATION
317 
318    Message:
319    fnp_init: Less than 256 words of free space in tty_buf:  N
320 
321    S:  $crash
322 
323    T:  $init
324 
325    M:  Only N words of free space remain in tty_buf after
326    allocating the header and circular queue.  A minimum of
327    256 words is required and ordinarily more free
328    space is desirable.  Either the size of tty_buf, as specified
329    by the PARM TTYB config card, must be increased or the
330    circular queue size, as specified by the PARM TTYQ config
331    card, must be decreased.
332 
333    A:  Correct the config deck and reboot the system.
334 
335 
336    Message:
337    fnp_init: no fnp cards in config deck
338 
339    S:  $info
340 
341    T:  $init
342 
343    M:  There are no fnp cards in the config deck and therefore,
344    no FNP will be initialized.  Usually this indicates an error,
345    although it is possible to run Multics without an FNP.
346 
347    A:  If an FNP is wanted, reboot the system with an appropriate
348    config deck.
349 
350 
351    Message:
352    fnp_init: FNP number N > max allowed number (MAX) of FNPs
353 
354    S:  $crash
355 
356    T:  $init
357 
358    M:  An fnp card from the config deck specifies an FNP tag
359    other than A, B, C, D, E, F, G, or H.
360 
361    A:  Replace the bad fnp card and reboot.
362 
363 
364    Message:
365    fnp_init: inconsistent fnp cards.
366 
367    S:  $crash
368 
369    T:  $init
370 
371    M:  Two or more fnp cards from the config deck specify the same
372    FNP tag.
373 
374    A:  Replace or remove the bad fnp card(s) and reboot.
375 
376 
377    Message:
378    fnp_init: Unable to abs_wire tty_buf. ERROR_CODE_MESSAGE
379 
380    S:  $crash
381 
382    T:  $init
383 
384    M:  The call to allocate memory in the bootload memory controller
385    for tty_buf failed.
386 
387    A:  $contact
388 
389 
390    Message:
391    fnp_init: Invalid state on prph fnpX card.
392 
393    S:  $crash
394 
395    T:  $init
396 
397    M:  The only valid states are "on" or "off".
398 
399    A:  $contact
400 
401 
402    Message:
403    fnp_init: Invalid model # (MODELN) on prph fnpX card.
404 
405    S:  $crash
406 
407    T:  $init
408 
409    M:  The current fnp model number MODELN, is not a supported number.
410 
411    A:  $contact
412 
413 
414    Message:
415    fnp_init: The number of configured protocol channels of N
416    exceeds the maximum allowed of N.
417 
418    S:  $crash
419 
420    T:  $init
421 
422    M:  The prot parm from the config deck specifies too many protocol channels.
423 
424    A:  $contact
425 
426    END MESSAGE DOCUMENTATION */
427 
428 
429      end fnp_init;