This source file includes following definitions.
- parseval
- getval
- name_match
- back_cable_iom_to_scu
- cable_scu_to_iom
- back_cable_cpu_to_scu
- cable_scu_to_cpu
- cable_scu
- cable_ctlr_to_iom
- cable_ctlr
- cable_iom
- cable_periph_to_ctlr
- cable_periph
- cable_mtp
- cable_ipc
- cable_msp
- cable_urp
- sys_cable
- cable_init
- sys_cable_graph
- sys_cable_show
- sys_cable_ripout
- sysCableInit
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114 #include <ctype.h>
115
116 #include "dps8.h"
117 #include "dps8_simh.h"
118 #include "dps8_iom.h"
119 #include "dps8_mt.h"
120 #include "dps8_socket_dev.h"
121 #include "dps8_sys.h"
122 #include "dps8_cable.h"
123 #include "dps8_cpu.h"
124 #include "dps8_faults.h"
125 #include "dps8_scu.h"
126 #include "dps8_state.h"
127 #include "dps8_console.h"
128 #include "dps8_disk.h"
129 #include "dps8_fnp2.h"
130 #include "dps8_urp.h"
131 #include "dps8_crdrdr.h"
132 #include "dps8_crdpun.h"
133 #include "dps8_prt.h"
134 #include "dps8_utils.h"
135 #if !defined(__MINGW64__) && !defined(__MINGW32__) && !defined (CROSS_MINGW64) && !defined (CROSS_MINGW32)
136 # include "dps8_absi.h"
137 #endif
138 #include "dps8_mgp.h"
139 #include "dps8_net.h"
140 #if defined(M_SHARED)
141 # include <unistd.h>
142 # include "shm.h"
143 #endif
144
145 #define DBG_CTR 1
146
147 #if defined(FREE)
148 # undef FREE
149 #endif
150 #define FREE(p) do \
151 { \
152 free((p)); \
153 (p) = NULL; \
154 } while(0)
155
156 struct cables_s * cables = NULL;
157
158 char * ctlr_type_strs [] =
159 {
160 "none",
161 "MTP", "MSP", "IPC", "OPC",
162 "URP", "FNP", "ABSI", "MGP", "NET", "SKC"
163 };
164
165 char * chan_type_strs [] =
166 {
167 "CPI", "PSI", "Direct"
168 };
169
170 static t_stat sys_cable_graph (void);
171
172 static int parseval (char * value)
173 {
174 if (! value)
175 return -1;
176 if (strlen (value) == 1 && value[0] >= 'a' && value[0] <= 'z')
177 return (int) (value[0] - 'a');
178 if (strlen (value) == 1 && value[0] >= 'A' && value[0] <= 'Z')
179 return (int) (value[0] - 'A');
180 char * endptr;
181 long l = strtol (value, & endptr, 0);
182 if (* endptr || l < 0 || l > INT_MAX)
183 {
184 sim_printf ("error: CABLE: can't parse %s\r\n", value);
185 return -1;
186 }
187 return (int) l;
188 }
189
190 static int getval (char * * save, char * text)
191 {
192 char * value;
193 value = strtok_r (NULL, ", ", save);
194 if (! value)
195 {
196 sim_printf ("error: CABLE: can't parse %s\r\n", text);
197 return -1;
198 }
199 return parseval (value);
200 }
201
202
203
204
205
206
207 static bool name_match (const char * str, const char * pattern, uint * val)
208 {
209
210 size_t pat_len = strlen (pattern);
211 if (strncasecmp (pattern, str, pat_len))
212 return false;
213
214
215 size_t rest = strlen (str) - pat_len;
216 const char * p = str + pat_len;
217
218
219 if (! rest)
220 return false;
221
222
223 char * q;
224 char * tags = "abcdefghijklmnopqrstuvwxyz";
225 if (rest == 1 && (q = strchr (tags, tolower (*p))))
226 {
227 * val = (uint) (q - tags);
228 return true;
229 }
230
231
232 char * digits = "0123456789";
233 q = strchr (digits, tolower (*p));
234 if (! q)
235 return false;
236
237 long l = strtol (p, & q, 0);
238 if (* q || l < 0 || l > INT_MAX)
239 {
240 sim_printf ("error: sys_cable: can't parse %s\r\n", str);
241 return false;
242 }
243 * val = (uint) l;
244 return true;
245 }
246
247
248
249 static t_stat back_cable_iom_to_scu (int uncable, uint iom_unit_idx, uint iom_port_num, uint scu_unit_idx, uint scu_port_num)
250 {
251 struct iom_to_scu_s * p = & cables->iom_to_scu[iom_unit_idx][iom_port_num];
252 iom_addr_map_changed (iom_unit_idx);
253 if (uncable)
254 {
255 p->in_use = false;
256 }
257 else
258 {
259 if (p->in_use)
260 {
261 sim_printf ("cable SCU: IOM%u port %u in use.\r\n", iom_unit_idx, iom_port_num);
262 return SCPE_ARG;
263 }
264 p->in_use = true;
265 p->scu_unit_idx = scu_unit_idx;
266 p->scu_port_num = scu_port_num;
267 }
268 return SCPE_OK;
269 }
270
271
272
273 static t_stat cable_scu_to_iom (int uncable, uint scu_unit_idx, uint scu_port_num, uint iom_unit_idx, uint iom_port_num)
274 {
275 struct scu_to_iom_s * p = & cables->scu_to_iom[scu_unit_idx][scu_port_num];
276 if (uncable)
277 {
278 if (! p->in_use)
279 {
280 sim_printf ("uncable SCU%u port %d: not cabled\r\n", scu_unit_idx, scu_port_num);
281 return SCPE_ARG;
282 }
283
284
285 t_stat rc = back_cable_iom_to_scu (uncable, iom_unit_idx, iom_port_num,
286 scu_unit_idx, scu_port_num);
287 if (rc)
288 {
289 return rc;
290 }
291
292 p->in_use = false;
293 scu[scu_unit_idx].ports[scu_port_num].type = ADEV_NONE;
294 scu[scu_unit_idx].ports[scu_port_num].dev_idx = 0;
295
296 scu[scu_unit_idx].ports[scu_port_num].is_exp = false;
297
298 }
299 else
300 {
301 if (p->in_use)
302 {
303 sim_printf ("cable_scu: SCU %d port %d in use.\r\n", scu_unit_idx, scu_port_num);
304 return SCPE_ARG;
305 }
306
307
308 t_stat rc = back_cable_iom_to_scu (uncable, iom_unit_idx, iom_port_num,
309 scu_unit_idx, scu_port_num);
310 if (rc)
311 {
312 return rc;
313 }
314
315 p->in_use = true;
316 p->iom_unit_idx = iom_unit_idx;
317 p->iom_port_num = (uint) iom_port_num;
318
319 scu[scu_unit_idx].ports[scu_port_num].type = ADEV_IOM;
320 scu[scu_unit_idx].ports[scu_port_num].dev_idx = (int) iom_unit_idx;
321 scu[scu_unit_idx].ports[scu_port_num].dev_port[0] = (int) iom_port_num;
322
323 scu[scu_unit_idx].ports[scu_port_num].is_exp = 0;
324
325 }
326 return SCPE_OK;
327 }
328
329
330
331 static t_stat back_cable_cpu_to_scu (int uncable, uint cpu_unit_idx, uint cpu_port_num,
332 uint scu_unit_idx, uint scu_port_num, uint scu_subport_num)
333 {
334 struct cpu_to_scu_s * p = & cables->cpu_to_scu[cpu_unit_idx][cpu_port_num];
335 if (uncable)
336 {
337 p->in_use = false;
338 }
339 else
340 {
341 if (p->in_use)
342 {
343 sim_printf ("cable SCU: CPU%u port %u in use.\r\n", cpu_unit_idx, cpu_port_num);
344 return SCPE_ARG;
345 }
346 p->in_use = true;
347 p->scu_unit_idx = scu_unit_idx;
348 p->scu_port_num = scu_port_num;
349 p->scu_subport_num = scu_subport_num;
350 }
351 return SCPE_OK;
352 }
353
354
355
356 static t_stat cable_scu_to_cpu (int uncable, uint scu_unit_idx, uint scu_port_num,
357 uint scu_subport_num, uint cpu_unit_idx, uint cpu_port_num, bool is_exp)
358 {
359 struct scu_to_cpu_s * p = & cables->scu_to_cpu[scu_unit_idx][scu_port_num][scu_subport_num];
360 if (uncable)
361 {
362 if (! p->in_use)
363 {
364 sim_printf ("uncable SCU%u port %u subport %u: not cabled\r\n",
365 scu_unit_idx, scu_port_num, scu_subport_num);
366 return SCPE_ARG;
367 }
368
369
370 t_stat rc = back_cable_cpu_to_scu (uncable, cpu_unit_idx, cpu_port_num,
371 scu_unit_idx, scu_port_num, scu_subport_num);
372 if (rc)
373 {
374 return rc;
375 }
376
377 p->in_use = false;
378 scu[scu_unit_idx].ports[scu_port_num].type = ADEV_NONE;
379 scu[scu_unit_idx].ports[scu_port_num].dev_idx = 0;
380
381 scu[scu_unit_idx].ports[scu_port_num].is_exp = false;
382 scu[scu_unit_idx].ports[scu_port_num].dev_port[scu_subport_num] = 0;
383 }
384 else
385 {
386 if (p->in_use)
387 {
388 sim_printf ("cable_scu: SCU %u port %u subport %u in use.\r\n",
389 scu_unit_idx, scu_port_num, scu_subport_num);
390 return SCPE_ARG;
391 }
392
393
394 t_stat rc = back_cable_cpu_to_scu (uncable, cpu_unit_idx, cpu_port_num,
395 scu_unit_idx, scu_port_num, scu_subport_num);
396 if (rc)
397 {
398 return rc;
399 }
400
401 p->in_use = true;
402 p->cpu_unit_idx = cpu_unit_idx;
403 p->cpu_port_num = (uint) cpu_port_num;
404
405 scu[scu_unit_idx].ports[scu_port_num].type = ADEV_CPU;
406 scu[scu_unit_idx].ports[scu_port_num].dev_idx = (int) cpu_unit_idx;
407 scu[scu_unit_idx].ports[scu_port_num].dev_port[0] = (int) cpu_port_num;
408
409 scu[scu_unit_idx].ports[scu_port_num].is_exp = is_exp;
410 scu[scu_unit_idx].ports[scu_port_num].dev_port[scu_subport_num] = (int) cpu_port_num;
411
412 cpus[cpu_unit_idx].scu_port[scu_unit_idx] = scu_port_num;
413 }
414
415 setup_scbank_map (_cpup);
416 return SCPE_OK;
417 }
418
419
420
421
422 static t_stat cable_scu (int uncable, uint scu_unit_idx, char * * name_save)
423 {
424 if (scu_unit_idx >= scu_dev.numunits)
425 {
426 sim_printf ("cable_scu: SCU unit number out of range <%d>\r\n",
427 scu_unit_idx);
428 return SCPE_ARG;
429 }
430
431 int scu_port_num = getval (name_save, "SCU port number");
432
433
434
435
436
437
438
439
440
441
442
443
444
445 char * param = strtok_r (NULL, ", ", name_save);
446 if (! param)
447 {
448 sim_printf ("cable_scu: can't parse IOM\r\n");
449 return SCPE_ARG;
450 }
451 uint unit_idx;
452
453
454 if (name_match (param, "IOM", & unit_idx))
455 {
456 if (unit_idx >= N_IOM_UNITS_MAX)
457 {
458 sim_printf ("cable SCU: IOM unit number out of range <%d>\r\n", unit_idx);
459 return SCPE_ARG;
460 }
461
462 if (scu_port_num < 0 || scu_port_num >= N_SCU_PORTS)
463 {
464 sim_printf ("cable_scu: SCU port number out of range <%d>\r\n",
465 scu_port_num);
466 return SCPE_ARG;
467 }
468
469
470 param = strtok_r (NULL, ", ", name_save);
471 if (! param)
472 {
473 sim_printf ("cable SCU: can't parse IOM port number\r\n");
474 return SCPE_ARG;
475 }
476 int iom_port_num = parseval (param);
477
478 if (iom_port_num < 0 || iom_port_num >= N_IOM_PORTS)
479 {
480 sim_printf ("cable SCU: IOM port number out of range <%d>\r\n", iom_port_num);
481 return SCPE_ARG;
482 }
483 return cable_scu_to_iom (uncable, scu_unit_idx, (uint) scu_port_num,
484 unit_idx, (uint) iom_port_num);
485 }
486
487
488 else if (name_match (param, "CPU", & unit_idx))
489 {
490 if (unit_idx >= N_CPU_UNITS_MAX)
491 {
492 sim_printf ("cable SCU: IOM unit number out of range <%d>\r\n", unit_idx);
493 return SCPE_ARG;
494 }
495
496
497
498
499
500
501
502
503
504 int scu_subport_num = 0;
505 bool is_exp = false;
506 int exp_port = scu_port_num / 10;
507 if (exp_port)
508 {
509 scu_subport_num = scu_port_num % 10;
510 if (scu_subport_num < 0 || scu_subport_num >= N_SCU_SUBPORTS)
511 {
512 sim_printf ("cable SCU: subport number out of range <%d>\r\n",
513 scu_subport_num);
514 return SCPE_ARG;
515 }
516 scu_port_num /= 10;
517 is_exp = true;
518 }
519 if (scu_port_num < 0 || scu_port_num >= N_SCU_PORTS)
520 {
521 sim_printf ("cable SCU: port number out of range <%d>\r\n",
522 scu_port_num);
523 return SCPE_ARG;
524 }
525
526
527 param = strtok_r (NULL, ", ", name_save);
528 if (! param)
529 {
530 sim_printf ("cable SCU: can't parse CPU port number\r\n");
531 return SCPE_ARG;
532 }
533 int cpu_port_num = parseval (param);
534
535 if (cpu_port_num < 0 || cpu_port_num >= N_CPU_PORTS)
536 {
537 sim_printf ("cable SCU: CPU port number out of range <%d>\r\n", cpu_port_num);
538 return SCPE_ARG;
539 }
540 return cable_scu_to_cpu (uncable, scu_unit_idx, (uint) scu_port_num,
541 (uint) scu_subport_num, unit_idx, (uint) cpu_port_num, is_exp);
542 }
543 else
544 {
545 sim_printf ("cable SCU: can't parse IOM or CPU\r\n");
546 return SCPE_ARG;
547 }
548 }
549
550 static t_stat cable_ctlr_to_iom (int uncable, struct ctlr_to_iom_s * there,
551 uint iom_unit_idx, uint chan_num)
552 {
553 if (uncable)
554 {
555 if (! there->in_use)
556 {
557 sim_printf ("error: UNCABLE: controller not cabled\r\n");
558 return SCPE_ARG;
559 }
560 if (there->iom_unit_idx != iom_unit_idx ||
561 there->chan_num != chan_num)
562 {
563 sim_printf ("error: UNCABLE: wrong controller\r\n");
564 return SCPE_ARG;
565 }
566 there->in_use = false;
567 }
568 else
569 {
570 if (there->in_use)
571 {
572 sim_printf ("error: CABLE: controller in use\r\n");
573 return SCPE_ARG;
574 }
575 there->in_use = true;
576 there->iom_unit_idx = iom_unit_idx;
577 there->chan_num = chan_num;
578 }
579 return SCPE_OK;
580 }
581
582 static t_stat cable_ctlr (int uncable,
583 uint iom_unit_idx, uint chan_num,
584 uint ctlr_unit_idx, uint port_num,
585 char * service,
586 DEVICE * devp,
587 struct ctlr_to_iom_s * there,
588 enum ctlr_type_e ctlr_type, enum chan_type_e chan_type,
589 UNIT * unitp, iom_cmd_t * iom_cmd)
590 {
591 if (ctlr_unit_idx >= devp->numunits)
592 {
593 sim_printf ("%s: unit index out of range <%d>\r\n",
594 service, ctlr_unit_idx);
595 return SCPE_ARG;
596 }
597
598 struct iom_to_ctlr_s * p = & cables->iom_to_ctlr[iom_unit_idx][chan_num];
599
600 if (uncable)
601 {
602 if (! p->in_use)
603 {
604 sim_printf ("%s: not cabled\r\n", service);
605 return SCPE_ARG;
606 }
607
608 if (p->ctlr_unit_idx != ctlr_unit_idx)
609 {
610 sim_printf ("%s: Wrong IOM expected %d, found %d\r\n",
611 service, ctlr_unit_idx, p->ctlr_unit_idx);
612 return SCPE_ARG;
613 }
614
615
616 t_stat rc = cable_ctlr_to_iom (uncable, there,
617 iom_unit_idx, chan_num);
618 if (rc)
619 {
620 return rc;
621 }
622 p->in_use = false;
623 p->iom_cmd = NULL;
624 }
625 else
626 {
627 if (p->in_use)
628 {
629 sim_printf ("%s: socket in use; unit number %d. (%o); "
630 "not cabling.\r\n", service, iom_unit_idx, iom_unit_idx);
631 return SCPE_ARG;
632 }
633
634
635 t_stat rc = cable_ctlr_to_iom (uncable, there,
636 iom_unit_idx, chan_num);
637 if (rc)
638 {
639 return rc;
640 }
641 p->in_use = true;
642 p->ctlr_unit_idx = ctlr_unit_idx;
643 p->port_num = port_num;
644 p->ctlr_type = ctlr_type;
645 p->chan_type = chan_type;
646 p->dev = devp;
647 p->board = unitp;
648 p->iom_cmd = iom_cmd;
649 }
650
651 return SCPE_OK;
652 }
653
654
655
656
657
658
659
660
661
662
663
664 static t_stat cable_iom (int uncable, uint iom_unit_idx, char * * name_save)
665 {
666 if (iom_unit_idx >= iom_dev.numunits)
667 {
668 sim_printf ("error: CABLE IOM: unit number out of range <%d>\r\n",
669 iom_unit_idx);
670 return SCPE_ARG;
671 }
672
673 int chan_num = getval (name_save, "IOM channel number");
674
675 if (chan_num < 0 || chan_num >= MAX_CHANNELS)
676 {
677 sim_printf ("error: CABLE IOM channel number out of range <%d>\r\n",
678 chan_num);
679 return SCPE_ARG;
680 }
681
682
683 char * param = strtok_r (NULL, ", ", name_save);
684 if (! param)
685 {
686 sim_printf ("error: CABLE IOM can't parse controller type\r\n");
687 return SCPE_ARG;
688 }
689 uint unit_idx;
690
691
692 if (name_match (param, "IPC", & unit_idx))
693 {
694 if (unit_idx >= N_IPC_UNITS_MAX)
695 {
696 sim_printf ("error: CABLE IOM: IPC unit number out of range <%d>\r\n", unit_idx);
697 return SCPE_ARG;
698 }
699
700
701 int ipc_port_num = 0;
702 param = strtok_r (NULL, ", ", name_save);
703 if (param)
704 ipc_port_num = parseval (param);
705
706 if (ipc_port_num < 0 || ipc_port_num >= MAX_CTLR_PORTS)
707 {
708 sim_printf ("error: CABLE IOM: IPC port number out of range <%d>\r\n", ipc_port_num);
709 return SCPE_ARG;
710 }
711 return cable_ctlr (uncable,
712 iom_unit_idx, (uint) chan_num,
713 unit_idx, (uint) ipc_port_num,
714 "CABLE IOMx IPCx",
715 & ipc_dev,
716 & cables->ipc_to_iom[unit_idx][ipc_port_num],
717 CTLR_T_IPC, chan_type_PSI,
718 & ipc_unit [unit_idx], dsk_iom_cmd);
719 }
720
721
722 if (name_match (param, "MSP", & unit_idx))
723 {
724 if (unit_idx >= N_MSP_UNITS_MAX)
725 {
726 sim_printf ("error: CABLE IOM: MSP unit number out of range <%d>\r\n", unit_idx);
727 return SCPE_ARG;
728 }
729
730
731 int msp_port_num = 0;
732 param = strtok_r (NULL, ", ", name_save);
733 if (param)
734 msp_port_num = parseval (param);
735
736 if (msp_port_num < 0 || msp_port_num >= MAX_CTLR_PORTS)
737 {
738 sim_printf ("error: CABLE IOM: MSP port number out of range <%d>\r\n", msp_port_num);
739 return SCPE_ARG;
740 }
741 return cable_ctlr (uncable,
742 iom_unit_idx, (uint) chan_num,
743 unit_idx, (uint) msp_port_num,
744 "CABLE IOMx MSPx",
745 & msp_dev,
746 & cables->msp_to_iom[unit_idx][msp_port_num],
747 CTLR_T_MSP, chan_type_PSI,
748 & msp_unit [unit_idx], dsk_iom_cmd);
749 }
750
751
752 if (name_match (param, "MTP", & unit_idx))
753 {
754 if (unit_idx >= N_MTP_UNITS_MAX)
755 {
756 sim_printf ("error: CABLE IOM: MTP unit number out of range <%d>\r\n", unit_idx);
757 return SCPE_ARG;
758 }
759
760
761 int mtp_port_num = 0;
762 param = strtok_r (NULL, ", ", name_save);
763 if (param)
764 mtp_port_num = parseval (param);
765
766 if (mtp_port_num < 0 || mtp_port_num >= MAX_CTLR_PORTS)
767 {
768 sim_printf ("error: CABLE IOM: MTP port number out of range <%d>\r\n", mtp_port_num);
769 return SCPE_ARG;
770 }
771 return cable_ctlr (uncable,
772 iom_unit_idx, (uint) chan_num,
773 unit_idx, (uint) mtp_port_num,
774 "CABLE IOMx MTPx",
775 & mtp_dev,
776 & cables->mtp_to_iom[unit_idx][mtp_port_num],
777 CTLR_T_MTP, chan_type_PSI,
778 & mtp_unit [unit_idx], mt_iom_cmd);
779 }
780
781
782 if (name_match (param, "URP", & unit_idx))
783 {
784 if (unit_idx >= N_URP_UNITS_MAX)
785 {
786 sim_printf ("error: CABLE IOM: URP unit number out of range <%d>\r\n", unit_idx);
787 return SCPE_ARG;
788 }
789
790
791 int urp_port_num = 0;
792 param = strtok_r (NULL, ", ", name_save);
793 if (param)
794 urp_port_num = parseval (param);
795
796 if (urp_port_num < 0 || urp_port_num >= MAX_CTLR_PORTS)
797 {
798 sim_printf ("error: CABLE IOM: URP port number out of range <%d>\r\n", urp_port_num);
799 return SCPE_ARG;
800 }
801
802 return cable_ctlr (uncable,
803 iom_unit_idx, (uint) chan_num,
804 unit_idx, (uint) urp_port_num,
805 "CABLE IOMx URPx",
806 & urp_dev,
807 & cables->urp_to_iom[unit_idx][urp_port_num],
808 CTLR_T_URP, chan_type_PSI,
809 & urp_unit [unit_idx], urp_iom_cmd);
810 }
811
812
813 if (name_match (param, "OPC", & unit_idx))
814 {
815 if (unit_idx >= N_OPC_UNITS_MAX)
816 {
817 sim_printf ("error: CABLE IOM: OPC unit number out of range <%d>\r\n", unit_idx);
818 return SCPE_ARG;
819 }
820
821 uint opc_port_num = 0;
822 return cable_ctlr (uncable,
823 iom_unit_idx, (uint) chan_num,
824 unit_idx, opc_port_num,
825 "CABLE IOMx OPCx",
826 & opc_dev,
827 & cables->opc_to_iom[unit_idx][opc_port_num],
828 CTLR_T_OPC, chan_type_CPI,
829 & opc_unit [unit_idx], opc_iom_cmd);
830 }
831
832
833 if (name_match (param, "FNP", & unit_idx))
834 {
835 if (unit_idx >= N_FNP_UNITS_MAX)
836 {
837 sim_printf ("error: CABLE IOM: FNP unit number out of range <%d>\r\n", unit_idx);
838 return SCPE_ARG;
839 }
840
841 uint fnp_port_num = 0;
842 return cable_ctlr (uncable,
843 iom_unit_idx, (uint) chan_num,
844 unit_idx, fnp_port_num,
845 "CABLE IOMx FNPx",
846 & fnp_dev,
847 & cables->fnp_to_iom[unit_idx][fnp_port_num],
848 CTLR_T_FNP, chan_type_direct,
849 & fnp_unit [unit_idx], fnp_iom_cmd);
850 }
851
852 #if defined(WITH_ABSI_DEV)
853 # if !defined(__MINGW64__) && !defined(__MINGW32__) && !defined (CROSS_MINGW64) && !defined(CROSS_MINGW32)
854
855 if (name_match (param, "ABSI", & unit_idx))
856 {
857 if (unit_idx >= N_ABSI_UNITS_MAX)
858 {
859 sim_printf ("error: CABLE IOM: ABSI unit number out of range <%d>\r\n", unit_idx);
860 return SCPE_ARG;
861 }
862
863 uint absi_port_num = 0;
864 return cable_ctlr (uncable,
865 iom_unit_idx, (uint) chan_num,
866 unit_idx, absi_port_num,
867 "CABLE IOMx ABSIx",
868 & absi_dev,
869 & cables->absi_to_iom[unit_idx][absi_port_num],
870 CTLR_T_ABSI, chan_type_direct,
871 & absi_unit [unit_idx], absi_iom_cmd);
872 }
873 # endif
874 #endif
875
876 #if defined(WITH_MGP_DEV)
877
878 if (name_match (param, "MGP", & unit_idx))
879 {
880 if (unit_idx >= N_MGP_UNITS_MAX)
881 {
882 sim_printf ("error: CABLE IOM: MGP unit number out of range <%d>\r\n", unit_idx);
883 return SCPE_ARG;
884 }
885
886 uint mgp_port_num = 0;
887 return cable_ctlr (uncable,
888 iom_unit_idx, (uint) chan_num,
889 unit_idx, mgp_port_num,
890 "CABLE IOMx MGPx",
891 & mgp_dev,
892 & cables->mgp_to_iom[unit_idx][mgp_port_num],
893 CTLR_T_MGP, chan_type_direct,
894 & mgp_unit [unit_idx], mgp_iom_cmd);
895 }
896 #endif
897
898 #if defined(WITH_NET_DEV)
899
900 if (name_match (param, "NET", & unit_idx))
901 {
902 if (unit_idx >= N_NET_UNITS_MAX)
903 {
904 sim_printf ("error: CABLE IOM: NET unit number out of range <%d>\r\n", unit_idx);
905 return SCPE_ARG;
906 }
907
908 uint net_port_num = 0;
909 return cable_ctlr (uncable,
910 iom_unit_idx, (uint) chan_num,
911 unit_idx, net_port_num,
912 "CABLE IOMx NETx",
913 & net_dev,
914 & cables->net_to_iom[unit_idx][net_port_num],
915 CTLR_T_NET, chan_type_direct,
916 & net_unit [unit_idx], net_iom_cmd);
917 }
918 #endif
919
920 #if defined(WITH_SOCKET_DEV)
921 # if !defined(__MINGW64__) && !defined(__MINGW32__) && !defined(CROSS_MINGW64) && !defined(CROSS_MINGW32)
922
923 if (name_match (param, "SKC", & unit_idx))
924 {
925 if (unit_idx >= N_SKC_UNITS_MAX)
926 {
927 sim_printf ("error: CABLE IOM: SKC unit number out of range <%d>\r\n", unit_idx);
928 return SCPE_ARG;
929 }
930
931 uint skc_port_num = 0;
932 return cable_ctlr (uncable,
933 iom_unit_idx, (uint) chan_num,
934 unit_idx, skc_port_num,
935 "CABLE IOMx SKCx",
936 & skc_dev,
937 & cables->sk_to_iom[unit_idx][skc_port_num],
938 CTLR_T_SKC, chan_type_direct,
939 & sk_unit [unit_idx], skc_iom_cmd);
940 }
941 # endif
942 #endif
943
944 sim_printf ("cable IOM: can't parse controller type\r\n");
945 return SCPE_ARG;
946 }
947
948 static t_stat cable_periph_to_ctlr (int uncable,
949 uint ctlr_unit_idx, uint dev_code,
950 enum ctlr_type_e ctlr_type,
951 struct dev_to_ctlr_s * there,
952 UNUSED iom_cmd_t * iom_cmd)
953 {
954 if (uncable)
955 {
956 if (! there->in_use)
957 {
958 sim_printf ("error: UNCABLE: device not cabled\r\n");
959 return SCPE_ARG;
960 }
961 if (there->ctlr_unit_idx != ctlr_unit_idx ||
962 there->dev_code != dev_code)
963 {
964 sim_printf ("error: UNCABLE: wrong controller\r\n");
965 return SCPE_ARG;
966 }
967 there->in_use = false;
968 }
969 else
970 {
971 if (there->in_use)
972 {
973 sim_printf ("error: CABLE: device in use\r\n");
974 return SCPE_ARG;
975 }
976 there->in_use = true;
977 there->ctlr_unit_idx = ctlr_unit_idx;
978 there->dev_code = dev_code;
979 there->ctlr_type = ctlr_type;
980 }
981 return SCPE_OK;
982 }
983
984 static t_stat cable_periph (int uncable,
985 uint ctlr_unit_idx,
986 uint dev_code,
987 enum ctlr_type_e ctlr_type,
988 struct ctlr_to_dev_s * here,
989 uint unit_idx,
990 iom_cmd_t * iom_cmd,
991 struct dev_to_ctlr_s * there,
992 char * service)
993 {
994 if (uncable)
995 {
996 if (! here->in_use)
997 {
998 sim_printf ("%s: socket not in use\r\n", service);
999 return SCPE_ARG;
1000 }
1001
1002 t_stat rc = cable_periph_to_ctlr (uncable,
1003 ctlr_unit_idx, dev_code, ctlr_type,
1004 there,
1005 iom_cmd);
1006 if (rc)
1007 {
1008 return rc;
1009 }
1010
1011 here->in_use = false;
1012 here->iom_cmd = NULL;
1013 }
1014 else
1015 {
1016 if (here->in_use)
1017 {
1018 sim_printf ("%s: controller socket in use; unit number %u. dev_code %oo\r\n",
1019 service, ctlr_unit_idx, dev_code);
1020 return SCPE_ARG;
1021 }
1022
1023
1024 t_stat rc = cable_periph_to_ctlr (uncable,
1025 ctlr_unit_idx, dev_code, ctlr_type,
1026 there,
1027 iom_cmd);
1028 if (rc)
1029 {
1030 return rc;
1031 }
1032
1033 here->in_use = true;
1034 here->unit_idx = unit_idx;
1035 here->iom_cmd = iom_cmd;
1036 }
1037
1038 return SCPE_OK;
1039 }
1040
1041
1042
1043 static t_stat cable_mtp (int uncable, uint ctlr_unit_idx, char * * name_save)
1044 {
1045 if (ctlr_unit_idx >= mtp_dev.numunits)
1046 {
1047 sim_printf ("error: CABLE MTP: controller unit number out of range <%d>\r\n",
1048 ctlr_unit_idx);
1049 return SCPE_ARG;
1050 }
1051
1052 int dev_code = getval (name_save, "MTP device code");
1053
1054 if (dev_code < 0 || dev_code >= MAX_CHANNELS)
1055 {
1056 sim_printf ("error: CABLE MTP device code out of range <%d>\r\n",
1057 dev_code);
1058 return SCPE_ARG;
1059 }
1060
1061
1062 char * param = strtok_r (NULL, ", ", name_save);
1063 if (! param)
1064 {
1065 sim_printf ("error: CABLE IOM can't parse device name\r\n");
1066 return SCPE_ARG;
1067 }
1068 uint mt_unit_idx;
1069
1070
1071 if (name_match (param, "TAPE", & mt_unit_idx))
1072 {
1073 if (mt_unit_idx >= N_MT_UNITS_MAX)
1074 {
1075 sim_printf ("error: CABLE IOM: TAPE unit number out of range <%d>\r\n", mt_unit_idx);
1076 return SCPE_ARG;
1077 }
1078
1079 return cable_periph (uncable,
1080 ctlr_unit_idx,
1081 (uint) dev_code,
1082 CTLR_T_MTP,
1083 & cables->mtp_to_tape[ctlr_unit_idx][dev_code],
1084 mt_unit_idx,
1085 mt_iom_cmd,
1086 & cables->tape_to_mtp[mt_unit_idx],
1087 "CABLE MTPx TAPEx");
1088 }
1089
1090 sim_printf ("cable MTP: can't parse device name\r\n");
1091 return SCPE_ARG;
1092 }
1093
1094
1095
1096 static t_stat cable_ipc (int uncable, uint ctlr_unit_idx, char * * name_save)
1097 {
1098 if (ctlr_unit_idx >= ipc_dev.numunits)
1099 {
1100 sim_printf ("error: CABLE IPC: controller unit number out of range <%d>\r\n",
1101 ctlr_unit_idx);
1102 return SCPE_ARG;
1103 }
1104
1105 int dev_code = getval (name_save, "IPC device code");
1106
1107 if (dev_code < 0 || dev_code >= MAX_CHANNELS)
1108 {
1109 sim_printf ("error: CABLE IPC device code out of range <%d>\r\n",
1110 dev_code);
1111 return SCPE_ARG;
1112 }
1113
1114
1115 char * param = strtok_r (NULL, ", ", name_save);
1116 if (! param)
1117 {
1118 sim_printf ("error: CABLE IOM can't parse device name\r\n");
1119 return SCPE_ARG;
1120 }
1121 uint dsk_unit_idx;
1122
1123
1124 if (name_match (param, "DISK", & dsk_unit_idx))
1125 {
1126 if (dsk_unit_idx >= N_DSK_UNITS_MAX)
1127 {
1128 sim_printf ("error: CABLE IOM: DISK unit number out of range <%d>\r\n", dsk_unit_idx);
1129 return SCPE_ARG;
1130 }
1131
1132 return cable_periph (uncable,
1133 ctlr_unit_idx,
1134 (uint) dev_code,
1135 CTLR_T_IPC,
1136 & cables->ipc_to_dsk[ctlr_unit_idx][dev_code],
1137 dsk_unit_idx,
1138 dsk_iom_cmd,
1139 & cables->dsk_to_ctlr[dsk_unit_idx],
1140 "CABLE IPCx DISKx");
1141 }
1142
1143 sim_printf ("cable IPC: can't parse device name\r\n");
1144 return SCPE_ARG;
1145 }
1146
1147
1148
1149 static t_stat cable_msp (int uncable, uint ctlr_unit_idx, char * * name_save)
1150 {
1151 if (ctlr_unit_idx >= msp_dev.numunits)
1152 {
1153 sim_printf ("error: CABLE MSP: controller unit number out of range <%d>\r\n",
1154 ctlr_unit_idx);
1155 return SCPE_ARG;
1156 }
1157
1158 int dev_code = getval (name_save, "MSP device code");
1159
1160 if (dev_code < 0 || dev_code >= MAX_CHANNELS)
1161 {
1162 sim_printf ("error: CABLE MSP device code out of range <%d>\r\n",
1163 dev_code);
1164 return SCPE_ARG;
1165 }
1166
1167
1168 char * param = strtok_r (NULL, ", ", name_save);
1169 if (! param)
1170 {
1171 sim_printf ("error: CABLE IOM can't parse device name\r\n");
1172 return SCPE_ARG;
1173 }
1174 uint dsk_unit_idx;
1175
1176
1177 if (name_match (param, "DISK", & dsk_unit_idx))
1178 {
1179 if (dsk_unit_idx >= N_DSK_UNITS_MAX)
1180 {
1181 sim_printf ("error: CABLE IOM: DISK unit number out of range <%d>\r\n", dsk_unit_idx);
1182 return SCPE_ARG;
1183 }
1184
1185 return cable_periph (uncable,
1186 ctlr_unit_idx,
1187 (uint) dev_code,
1188 CTLR_T_MSP,
1189 & cables->msp_to_dsk[ctlr_unit_idx][dev_code],
1190 dsk_unit_idx,
1191 dsk_iom_cmd,
1192 & cables->dsk_to_ctlr[dsk_unit_idx],
1193 "CABLE MSPx DISKx");
1194 }
1195
1196 sim_printf ("cable MSP: can't parse device name\r\n");
1197 return SCPE_ARG;
1198 }
1199
1200
1201
1202 static t_stat cable_urp (int uncable, uint ctlr_unit_idx, char * * name_save)
1203 {
1204 if (ctlr_unit_idx >= urp_dev.numunits)
1205 {
1206 sim_printf ("error: CABLE URP: controller unit number out of range <%d>\r\n",
1207 ctlr_unit_idx);
1208 return SCPE_ARG;
1209 }
1210
1211 int dev_code = getval (name_save, "URP device code");
1212
1213 if (dev_code < 0 || dev_code >= MAX_CHANNELS)
1214 {
1215 sim_printf ("error: CABLE URP device code out of range <%d>\r\n",
1216 dev_code);
1217 return SCPE_ARG;
1218 }
1219
1220
1221 char * param = strtok_r (NULL, ", ", name_save);
1222 if (! param)
1223 {
1224 sim_printf ("error: CABLE IOM can't parse device name\r\n");
1225 return SCPE_ARG;
1226 }
1227 uint unit_idx;
1228
1229
1230 if (name_match (param, "RDR", & unit_idx))
1231 {
1232 if (unit_idx >= N_RDR_UNITS_MAX)
1233 {
1234 sim_printf ("error: CABLE IOM: DISK unit number out of range <%d>\r\n", unit_idx);
1235 return SCPE_ARG;
1236 }
1237
1238 return cable_periph (uncable,
1239 ctlr_unit_idx,
1240 (uint) dev_code,
1241 CTLR_T_URP,
1242 & cables->urp_to_urd[ctlr_unit_idx][dev_code],
1243 unit_idx,
1244 rdr_iom_cmd,
1245 & cables->rdr_to_urp[unit_idx],
1246 "CABLE URPx RDRx");
1247 }
1248
1249
1250 if (name_match (param, "PUN", & unit_idx))
1251 {
1252 if (unit_idx >= N_PUN_UNITS_MAX)
1253 {
1254 sim_printf ("error: CABLE IOM: DISK unit number out of range <%d>\r\n", unit_idx);
1255 return SCPE_ARG;
1256 }
1257
1258 return cable_periph (uncable,
1259 ctlr_unit_idx,
1260 (uint) dev_code,
1261 CTLR_T_URP,
1262 & cables->urp_to_urd[ctlr_unit_idx][dev_code],
1263 unit_idx,
1264 pun_iom_cmd,
1265 & cables->pun_to_urp[unit_idx],
1266 "CABLE URPx PUNx");
1267 }
1268
1269
1270 if (name_match (param, "PRT", & unit_idx))
1271 {
1272 if (unit_idx >= N_PRT_UNITS_MAX)
1273 {
1274 sim_printf ("error: CABLE IOM: DISK unit number out of range <%d>\r\n", unit_idx);
1275 return SCPE_ARG;
1276 }
1277
1278 return cable_periph (uncable,
1279 ctlr_unit_idx,
1280 (uint) dev_code,
1281 CTLR_T_URP,
1282 & cables->urp_to_urd[ctlr_unit_idx][dev_code],
1283 unit_idx,
1284 prt_iom_cmd,
1285 & cables->prt_to_urp[unit_idx],
1286 "CABLE URPx PRTx");
1287 }
1288
1289 sim_printf ("cable URP: can't parse device name\r\n");
1290 return SCPE_ARG;
1291 }
1292
1293 t_stat sys_cable (int32 arg, const char * buf)
1294 {
1295 char * copy = strdup (buf);
1296 if (!copy)
1297 {
1298 (void)fprintf (stderr, "\rFATAL: Out of memory! Aborting at %s[%s:%d]\r\n",
1299 __func__, __FILE__, __LINE__);
1300 #if defined(USE_BACKTRACE)
1301 # if defined(SIGUSR2)
1302 (void)raise(SIGUSR2);
1303
1304 # endif
1305 #endif
1306 abort();
1307 }
1308 t_stat rc = SCPE_ARG;
1309
1310
1311
1312
1313 char * name_save = NULL;
1314 char * name;
1315 name = strtok_r (copy, ", \t", & name_save);
1316 if (! name)
1317 {
1318
1319 sim_printf ("error: CABLE: sys_cable could not parse name\r\n");
1320 goto exit;
1321 }
1322
1323 uint unit_num;
1324 if (strcasecmp (name, "RIPOUT") == 0)
1325 rc = sys_cable_ripout (0, NULL);
1326 else if (strcasecmp (name, "SHOW") == 0)
1327 rc = sys_cable_show (0, NULL);
1328 else if (strcasecmp (name, "DUMP") == 0)
1329 rc = sys_cable_show (1, NULL);
1330 else if (strcasecmp (name, "GRAPH") == 0)
1331 rc = sys_cable_graph ();
1332 else if (name_match (name, "SCU", & unit_num))
1333 rc = cable_scu (arg, unit_num, & name_save);
1334 else if (name_match (name, "IOM", & unit_num))
1335 rc = cable_iom (arg, unit_num, & name_save);
1336 else if (name_match (name, "MTP", & unit_num))
1337 rc = cable_mtp (arg, unit_num, & name_save);
1338 else if (name_match (name, "IPC", & unit_num))
1339 rc = cable_ipc (arg, unit_num, & name_save);
1340 else if (name_match (name, "MSP", & unit_num))
1341 rc = cable_msp (arg, unit_num, & name_save);
1342 else if (name_match (name, "URP", & unit_num))
1343 rc = cable_urp (arg, unit_num, & name_save);
1344 else
1345 {
1346 sim_printf ("error: CABLE: Invalid name <%s>\r\n", name);
1347 goto exit;
1348 }
1349 if (name_save && strlen (name_save))
1350 {
1351 sim_printf ("CABLE ignored '%s'\r\n", name_save);
1352 }
1353 exit:
1354 FREE (copy);
1355 return rc;
1356 }
1357
1358 static void cable_init (void)
1359 {
1360
1361
1362
1363 (void)memset (cables, 0, sizeof (struct cables_s));
1364 }
1365
1366 #define all(i,n) \
1367 for (uint i = 0; i < n; i ++)
1368
1369 static t_stat
1370 sys_cable_graph (void)
1371 {
1372
1373 bool cpus_used[N_CPU_UNITS_MAX];
1374 (void)memset (cpus_used, 0, sizeof (cpus_used));
1375
1376 all (u, N_CPU_UNITS_MAX) all (prt, N_CPU_PORTS)
1377 {
1378 struct cpu_to_scu_s *p = &cables->cpu_to_scu[u][prt];
1379 if (p->in_use)
1380 cpus_used[u] = true;
1381 }
1382
1383
1384 bool scus_used[N_SCU_UNITS_MAX];
1385 (void)memset (scus_used, 0, sizeof (scus_used));
1386
1387 all (u, N_SCU_UNITS_MAX) all (prt, N_SCU_PORTS)
1388 {
1389 struct scu_to_iom_s *p = &cables->scu_to_iom[u][prt];
1390 if (p->in_use)
1391 scus_used[u] = true;
1392 }
1393 all (u, N_CPU_UNITS_MAX) all (prt, N_CPU_PORTS)
1394 {
1395 struct cpu_to_scu_s *p = &cables->cpu_to_scu[u][prt];
1396 if (p->in_use)
1397 scus_used[p->scu_unit_idx] = true;
1398 }
1399
1400
1401 bool ioms_used[N_IOM_UNITS_MAX];
1402 (void)memset (ioms_used, 0, sizeof (ioms_used));
1403
1404 all (u, N_SCU_UNITS_MAX) all (prt, N_SCU_PORTS)
1405 {
1406 struct scu_to_iom_s *p = &cables->scu_to_iom[u][prt];
1407 if (p->in_use)
1408 ioms_used[p->iom_unit_idx] = true;
1409 }
1410
1411
1412 sim_printf ("graph {\r\n");
1413 sim_printf (" rankdir=TD;\r\n");
1414
1415
1416 sim_printf (" { rank=same; ");
1417 for (int i = 0; i < N_CPU_UNITS_MAX; i++)
1418 if (cpus_used[i])
1419 sim_printf (" CPU%c [shape=diamond, \
1420 color=lightgreen, \
1421 style=filled];",
1422 i + 'A');
1423 sim_printf ("}\r\n");
1424
1425
1426 sim_printf (" { rank=same; ");
1427 for (int i = 0; i < N_SCU_UNITS_MAX; i++)
1428 if (scus_used[i])
1429 sim_printf (" SCU%c [shape=doubleoctagon, \
1430 color=deepskyblue4, \
1431 style=filled];",
1432 i + 'A');
1433 sim_printf ("}\r\n");
1434
1435
1436 sim_printf (" { rank=same; ");
1437 for (int i = 0; i < N_IOM_UNITS_MAX; i++)
1438 if (ioms_used[i])
1439 sim_printf (" IOM%c [shape=doublecircle, \
1440 color=cadetblue4, \
1441 style=filled];",
1442 i + 'A');
1443 sim_printf ("}\r\n");
1444
1445 #define R_CTLR_IOM(big, small, shape, color) \
1446 sim_printf (" { rank=same; "); \
1447 all (u, N_ ## big ## _UNITS_MAX) all (prt, MAX_CTLR_PORTS) \
1448 { \
1449 struct ctlr_to_iom_s *p = &cables->small ## _to_iom[u][prt]; \
1450 if (p->in_use) \
1451 sim_printf (" %s%d [shape=%s, color=%s, style=filled];", \
1452 #big, u, #shape, #color); \
1453 } \
1454 sim_printf ("}\r\n");
1455
1456 R_CTLR_IOM (MTP, mtp, oval, firebrick1)
1457 R_CTLR_IOM (MSP, msp, oval, firebrick2)
1458 R_CTLR_IOM (IPC, ipc, oval, firebrick3)
1459 R_CTLR_IOM (FNP, fnp, egg, snow2)
1460 R_CTLR_IOM (URP, urp, polygon, gold4)
1461 R_CTLR_IOM (DIA, dia, oval, orange)
1462 #if defined(WITH_ABSI_DEV)
1463 # if !defined(__MINGW64__)
1464 R_CTLR_IOM (ABSI, absi, oval, teal)
1465 # endif
1466 #endif
1467 #if defined(WITH_MGP_DEV)
1468 R_CTLR_IOM (MGP, mgp, oval, teal)
1469 #endif
1470 #if defined(WITH_NET_DEV)
1471 R_CTLR_IOM (NET, net, oval, teal)
1472 #endif
1473 R_CTLR_IOM (OPC, opc, oval, hotpink)
1474
1475 #define R_DEV_CTLR(from_big, from_small, to_label, \
1476 to_big, to_small, shape, color) \
1477 sim_printf (" { rank=same; "); \
1478 all (u, N_ ## to_big ## _UNITS_MAX) \
1479 { \
1480 struct dev_to_ctlr_s *p = \
1481 &cables->to_small ## _to_ ## from_small[u]; \
1482 if (p->in_use) \
1483 sim_printf (" %s%d [shape=%s, style=filled, color=%s];", \
1484 #to_label, u, #shape, #color); \
1485 } \
1486 sim_printf ("}\r\n");
1487
1488 R_DEV_CTLR (MTP, mtp, TAPE, MT, tape, oval, aquamarine3);
1489 R_DEV_CTLR (CTLR, ctlr, DISK, DSK, dsk, cylinder, bisque3);
1490 R_DEV_CTLR (URP, urp, RDR, RDR, rdr, septagon, mediumpurple1);
1491 R_DEV_CTLR (URP, urp, PUN, PUN, pun, pentagon, maroon3);
1492 R_DEV_CTLR (URP, urp, PRT, PRT, prt, octagon, yellowgreen);
1493
1494
1495 all (u, N_CPU_UNITS_MAX) all (prt, N_CPU_PORTS)
1496 {
1497 struct cpu_to_scu_s *p = &cables->cpu_to_scu[u][prt];
1498 if (p->in_use)
1499 sim_printf (" CPU%c -- SCU%c;\r\n", u + 'A',
1500 p->scu_unit_idx + 'A');
1501 }
1502
1503
1504 all (u, N_SCU_UNITS_MAX) all (prt, N_SCU_PORTS)
1505 {
1506 struct scu_to_iom_s *p = &cables->scu_to_iom[u][prt];
1507 if (p->in_use)
1508 sim_printf (" SCU%c -- IOM%c;\r\n", u + 'A',
1509 p->iom_unit_idx + 'A');
1510 }
1511
1512
1513 all (u, N_IOM_UNITS_MAX) all (c, MAX_CHANNELS)
1514 {
1515 struct iom_to_ctlr_s *p = &cables->iom_to_ctlr[u][c];
1516 if (p->in_use)
1517 sim_printf (" IOM%c -- %s%d;\r\n", u + 'A',
1518 ctlr_type_strs[p->ctlr_type],
1519 p->ctlr_unit_idx);
1520 }
1521
1522
1523 #define G_DEV_CTLR(from_big, from_small, to_label, to_big, to_small) \
1524 all (u, N_ ## to_big ## _UNITS_MAX) \
1525 { \
1526 struct dev_to_ctlr_s *p = \
1527 &cables->to_small ## _to_ ## from_small[u]; \
1528 if (p->in_use) \
1529 sim_printf (" %s%d -- %s%d;\r\n", \
1530 ctlr_type_strs[p->ctlr_type], \
1531 p->ctlr_unit_idx, #to_label, u); \
1532 }
1533
1534 G_DEV_CTLR (MTP, mtp, TAPE, MT, tape);
1535 G_DEV_CTLR (CTLR, ctlr, DISK, DSK, dsk);
1536 G_DEV_CTLR (URP, urp, RDR, RDR, rdr);
1537 G_DEV_CTLR (URP, urp, PUN, PUN, pun);
1538 G_DEV_CTLR (URP, urp, PRT, PRT, prt);
1539
1540 sim_printf ("}\r\n");
1541 return SCPE_OK;
1542 }
1543
1544 t_stat sys_cable_show (int32 dump, UNUSED const char * buf)
1545 {
1546 sim_printf ("SCU <--> IOM\r\n");
1547 sim_printf (" SCU port --> IOM port\r\n");
1548 all (u, N_SCU_UNITS_MAX)
1549 all (prt, N_SCU_PORTS)
1550 {
1551 struct scu_to_iom_s * p = & cables->scu_to_iom[u][prt];
1552 if (p->in_use)
1553 sim_printf (" %4u %4u %4u %4u\r\n", u, prt, p->iom_unit_idx, p->iom_port_num);
1554 }
1555
1556 if (dump)
1557 {
1558 sim_printf (" IOM port --> SCU port\r\n");
1559 all (u, N_IOM_UNITS_MAX)
1560 all (prt, N_IOM_PORTS)
1561 {
1562 struct iom_to_scu_s * p = & cables->iom_to_scu[u][prt];
1563 if (p->in_use)
1564 sim_printf (" %4u %4u %4u %4u\r\n", u, prt, p->scu_unit_idx, p->scu_port_num);
1565 }
1566 }
1567 sim_printf ("\r\n");
1568
1569 sim_printf ("SCU <--> CPU\r\n");
1570 sim_printf (" SCU port --> CPU port\r\n");
1571 all (u, N_SCU_UNITS_MAX)
1572 all (prt, N_SCU_PORTS)
1573 all (sp, N_SCU_SUBPORTS)
1574 {
1575 struct scu_to_cpu_s * p = & cables->scu_to_cpu[u][prt][sp];
1576 if (p->in_use)
1577 sim_printf (" %4u %4u %4u %4u\r\n", u, prt, p->cpu_unit_idx, p->cpu_port_num);
1578 }
1579
1580 if (dump)
1581 {
1582 sim_printf (" CPU port --> SCU port subport\r\n");
1583 all (u, N_CPU_UNITS_MAX)
1584 all (prt, N_CPU_PORTS)
1585 {
1586 struct cpu_to_scu_s * p = & cables->cpu_to_scu[u][prt];
1587 if (p->in_use)
1588 sim_printf (" %4u %4u %4u %4u %4u\r\n",
1589 u, prt, p->scu_unit_idx, p->scu_port_num, p->scu_subport_num);
1590 }
1591 }
1592 sim_printf ("\r\n");
1593
1594 sim_printf ("IOM <--> controller\r\n");
1595 sim_printf (" ctlr ctlr chan\r\n");
1596 sim_printf (" IOM chan --> idx port type type device board command\r\n");
1597 all (u, N_IOM_UNITS_MAX)
1598 all (c, MAX_CHANNELS)
1599 {
1600 struct iom_to_ctlr_s * p = & cables->iom_to_ctlr[u][c];
1601 if (p->in_use)
1602 sim_printf (" %4u %4u %4u %4u %-6s %-6s %10p %10p %10p\r\n",
1603 u, c, p->ctlr_unit_idx, p->port_num, ctlr_type_strs[p->ctlr_type],
1604 chan_type_strs[p->chan_type], (void *) p->dev,
1605 (void *) p->board, (void *) p->iom_cmd);
1606 }
1607
1608 if (dump)
1609 {
1610 #define CTLR_IOM(big,small) \
1611 sim_printf (" %-4s port --> IOM channel\r\n", #big); \
1612 all (u, N_ ## big ## _UNITS_MAX) \
1613 all (prt, MAX_CTLR_PORTS) \
1614 { \
1615 struct ctlr_to_iom_s * p = & cables->small ## _to_iom[u][prt]; \
1616 if (p->in_use) \
1617 sim_printf (" %4u %4u %4u %4u\r\n", u, prt, p->iom_unit_idx, p->chan_num); \
1618 }
1619 CTLR_IOM (MTP, mtp)
1620 CTLR_IOM (MSP, msp)
1621 CTLR_IOM (IPC, ipc)
1622 CTLR_IOM (URP, urp)
1623 CTLR_IOM (FNP, fnp)
1624 CTLR_IOM (DIA, dia)
1625 #if defined(WITH_ABSI_DEV)
1626 # if !defined(__MINGW64__) && !defined(__MINGW32__) && !defined(CROSS_MINGW32) && !defined(CROSS_MINGW64)
1627 CTLR_IOM (ABSI, absi)
1628 # endif
1629 #endif
1630 #if defined(WITH_MGP_DEV)
1631 CTLR_IOM (MGP, mgp)
1632 #endif
1633 #if defined(WITH_NET_DEV)
1634 CTLR_IOM (NET, net)
1635 #endif
1636 #if defined(WITH_SOCKET_DEV)
1637 # if !defined(__MINGW32__) && !defined(__MINGW64__) && !defined(CROSS_MINGW32) && !defined(CROSS_MINGW64)
1638 CTLR_IOM (SKC, sk)
1639 # endif
1640 #endif
1641 CTLR_IOM (OPC, opc)
1642 }
1643 sim_printf ("\r\n");
1644
1645 sim_printf ("controller <--> device\r\n");
1646
1647 #define CTLR_DEV(from_big,from_small, to_label, to_big, to_small) \
1648 sim_printf (" %-4s dev_code --> %-4s command\r\n", #from_big, #to_label); \
1649 all (u, N_ ## from_big ## _UNITS_MAX) \
1650 all (prt, N_DEV_CODES) \
1651 { \
1652 struct ctlr_to_dev_s * p = & cables->from_small ## _to_ ## to_small[u][prt]; \
1653 if (p->in_use) \
1654 sim_printf (" %4u %4u %4u %10p\r\n", u, prt, p->unit_idx, (void *) p->iom_cmd); \
1655 }
1656 #define DEV_CTLR(from_big,from_small, to_label, to_big, to_small) \
1657 sim_printf (" %-4s --> %-4s dev_code type\r\n", #to_label, #from_big); \
1658 all (u, N_ ## to_big ## _UNITS_MAX) \
1659 { \
1660 struct dev_to_ctlr_s * p = & cables->to_small ## _to_ ## from_small[u]; \
1661 if (p->in_use) \
1662 sim_printf (" %4u %4u %4u %5s\r\n", u, p->ctlr_unit_idx, \
1663 p->dev_code, ctlr_type_strs[p->ctlr_type]); \
1664 }
1665 CTLR_DEV (MTP, mtp, TAPE, MT, tape);
1666 if (dump)
1667 {
1668 DEV_CTLR (MTP, mtp, TAPE, MT, tape);
1669 }
1670 CTLR_DEV (IPC, ipc, DISK, DSK, dsk);
1671 CTLR_DEV (MSP, msp, DISK, DSK, dsk);
1672 if (dump)
1673 {
1674 DEV_CTLR (CTLR, ctlr, DISK, DSK, dsk);
1675 }
1676 CTLR_DEV (URP, urp, URP, URP, urd);
1677 if (dump)
1678 {
1679 DEV_CTLR (URP, urp, RDR, RDR, rdr);
1680 }
1681 if (dump)
1682 {
1683 DEV_CTLR (URP, urp, PUN, PUN, pun);
1684 }
1685 if (dump)
1686 {
1687 DEV_CTLR (URP, urp, PRT, PRT, prt);
1688 }
1689
1690 return SCPE_OK;
1691 }
1692
1693 t_stat sys_cable_ripout (UNUSED int32 arg, UNUSED const char * buf)
1694 {
1695 cable_init ();
1696 scu_init ();
1697 return SCPE_OK;
1698 }
1699
1700 void sysCableInit (void)
1701 {
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718 cables = & system_state->cables;
1719
1720
1721 cable_init ();
1722 }