-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhp2100_mux.c
1821 lines (1348 loc) · 82.6 KB
/
hp2100_mux.c
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
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
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* hp2100_mux.c: HP 2100 12920A Asynchronous Multiplexer Interface simulator
Copyright (c) 2002-2016, Robert M. Supnik
Copyright (c) 2017-2019 J. David Bryan
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the names of the authors shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from the authors.
MUX,MUXL,MUXC 12920A Asynchronous Multiplexer Interface
23-Jan-19 JDB Removed DEV_MUX to avoid TMXR debug flags
11-Jul-18 JDB Revised I/O model
06-Jun-18 JDB Corrected incorrect initialization of "upper_status_names"
01-May-18 JDB Removed ioCRS counter, as consecutive ioCRS calls are no longer made
28-Apr-18 JDB Fixed output completion IRQ when port is not connected
03-Aug-17 JDB Control card device renamed from MUXM to MUXC
MUXC now enabled/disabled independently of MUX and MUXL
Modified to use the "odd_parity" array in hp2100_sys.c
15-Mar-17 JDB Trace flags are now global
Changed DEBUG_PRI calls to tprintfs
10-Mar-17 JDB Added IOBUS to the debug table
17-Jan-17 JDB Changed "hp_---sc" and "hp_---dev" to "hp_---_dib"
13-May-16 JDB Modified for revised SCP API function parameter types
29-Jun-15 JDB Corrected typo in RTS macro definition
24-Dec-14 JDB Added casts for explicit downward conversions
10-Jan-13 MP Added DEV_MUX and additional DEVICE field values
10-Feb-12 JDB Deprecated DEVNO in favor of SC
Removed DEV_NET to allow restoration of listening port
28-Mar-11 JDB Tidied up signal handling
26-Oct-10 JDB Changed I/O signal handler for revised signal model
25-Nov-08 JDB Revised for new multiplexer library SHOW routines
09-Oct-08 JDB "muxl_unit" defined one too many units (17 instead of 16)
10-Sep-08 JDB SHOW MUX CONN/STAT with SET MUX DIAG is no longer disallowed
07-Sep-08 JDB Changed Telnet poll to connect immediately after reset or attach
27-Aug-08 JDB Added LINEORDER support
12-Aug-08 JDB Added BREAK deferral to allow RTE break-mode to work
26-Jun-08 JDB Rewrote device I/O to model backplane signals
16-Apr-08 JDB Sync mux poll with console poll for idle compatibility
06-Mar-07 JDB Corrected "mux_sta" size from 16 to 21 elements
Fixed "muxc_reset" to clear lines 16-20
26-Feb-07 JDB Added debug printouts
Fixed control card OTx to set current channel number
Fixed to set "muxl_ibuf" in response to a transmit interrupt
Changed "mux_xbuf", "mux_rbuf" declarations from 8 to 16 bits
Fixed to set "mux_rchp" when a line break is received
Fixed incorrect "odd_par" table values
Reversed test in "RCV_PAR" to return "LIL_PAR" on odd parity
Fixed mux reset (ioCRS) to clear port parameters
Fixed to use PUT_DCH instead of PUT_CCH for data channel status
10-Feb-07 JDB Added DIAG/TERM modifiers to implement diagnostic mode
28-Dec-06 JDB Added ioCRS state to I/O decoders
02-Jun-06 JDB Fixed compiler warning for mux_ldsc init
22-Nov-05 RMS Revised for new terminal processing routines
29-Jun-05 RMS Added SET MUXLn DISCONNECT
07-Oct-04 JDB Allow enable/disable from any device
26-Apr-04 RMS Fixed SFS x,C and SFC x,C
Implemented DMA SRQ (follows FLG)
05-Jan-04 RMS Revised for tmxr library changes
21-Dec-03 RMS Added invalid character screening for TSB (from Mike Gemeny)
09-May-03 RMS Added network device flag
01-Nov-02 RMS Added 7B/8B support
22-Aug-02 RMS Updated for changes to sim_tmxr
Reference:
- 12920A Asynchronous Multiplexer Interface Kits Operating and Service Manual
(12920-90001, Oct-1972)
The 12920A was a 16-channel asynchronous terminal multiplexer. It supported
direct-connected terminals as well as modems at speeds up to 2400 baud. It
was the primary terminal multiplexer for the HP 2000 series of Time-Shared
BASIC systems.
The multiplexer was implemented as a three-card set consisting of a lower
data card, an upper data card, and a modem control card. Under simulation,
these are implemented by three devices:
MUXL lower data card (lines)
MUX upper data card (scanner)
MUXC control card (modem control)
The lower and upper data cards must be in adjacent I/O slots. The control
card may be placed in any slot, although in practice it was placed in the
slot above the upper data card, so that all three cards were physically
together.
The 12920A supported one or two control cards (two cards were used with
801-type automatic dialers). Under simulation, only one control card is
supported.
The multiplexer responds to I/O instructions as follows:
Upper Data Card output word format (OTA and OTB):
15 |14 13 12 |11 10 9 | 8 7 6 | 5 4 3 | 2 1 0
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
| - | channel number | - - - - - - - - - - |
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
Upper Data Card input word format (LIA, LIB, MIA, and MIB):
15 |14 13 12 |11 10 9 | 8 7 6 | 5 4 3 | 2 1 0
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
| S | channel number | - - - - - - | D | B | L | R |
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
Where:
S = Seeking
D = Diagnose
B = Break status
L = Character lost
R = Receive/send (0/1) character interrupt
Lower Data Card output control word format (OTA and OTB):
15 |14 13 12 |11 10 9 | 8 7 6 | 5 4 3 | 2 1 0
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
| 1 | R | I | E | D | char size | baud rate |
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
Where:
R = Receive/send (0/1) configuration
I = Enable interrupt
E = Echo (receive)/parity (send)
D = Diagnose
Character size:
The three least-significant bits of the sum of the data, parity, and stop
bits. For example, 7E1 is 1001, so 001 is coded.
Baud rate:
The value (14400 / device bit rate) - 1. For example, 2400 baud is 005.
Lower Data Card output data word format (OTA and OTB):
15 |14 13 12 |11 10 9 | 8 7 6 | 5 4 3 | 2 1 0
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
| 0 | 1 | - - | S | transmit data |
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
Where:
S = Sync bit
Transmit data:
Right-justified with leading one bits.
Lower Data Card input word format (LIA, LIB, MIA, and MIB):
15 |14 13 12 |11 10 9 | 8 7 6 | 5 4 3 | 2 1 0
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
| P | channel | receive data |
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
Where:
P = Computed parity
Receive data:
Right-justified with leading one bits
Control Card output word format (OTA and OTB):
15 |14 13 12 |11 10 9 | 8 7 6 | 5 4 3 | 2 1 0
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
| S | U |channel number | - - |EC2|EC1|C2 |C1 |ES2|ES1|SS2|SS1|
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
Control Card input word format (LIA, LIB, MIA, and MIB):
15 |14 13 12 |11 10 9 | 8 7 6 | 5 4 3 | 2 1 0
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
| 1 1 |channel number |I2 |I1 | 0 0 0 0 |ES2|ES1|S2 |S1 |
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
Where:
S = Scan
U = Update
ECx = Enable command bit x
Cx = Command bit x
ESx = Enable status bit x
Sx = Status bit x
SSx = Stored status bit x
Ix = Interrupt bit x
The control card provides two serial control outputs and two serial status
inputs for each of the 16 channels. The card connects to the Request to Send
(CA) and Data Terminal Ready (CD) control lines and the Data Carrier Detect
(CF) and Data Set Ready (CC) status lines. Addressable latches hold the
control line values and assert them continuously to the 16 channels. In
addition, a 16-word by 4-bit RAM holds the expected state for each channel's
status lines and the corresponding interrupt enable bits to provide
notification if those lines change.
Implementation notes:
1. If a BREAK is detected during an input poll, and we are not in diagnostic
mode, we defer recognition until either a character is output or a second
successive input poll occurs. This is necessary for RTE break-mode
operation. Without this deferral, a BREAK during output would be ignored
by the RTE driver, making it impossible to stop a long listing.
The problem is due to timing differences between simulated and real time.
The RTE multiplexer driver is a privileged driver. Privileged drivers
bypass RTE to provide rapid interrupt handling. To inform RTE that an
operation is complete, e.g., that a line has been written, the interrupt
section of the driver sets a device timeout of one clock tick (10
milliseconds). When that timeout occurs, RTE is entered normally to
complete the I/O transaction. While the completion timeout is pending,
the driver ignores any further interrupts from the multiplexer line.
The maximum communication rate for the multiplexer is 2400 baud, or
approximately 4.2 milliseconds per character transferred. A typical line
of 20 characters would therefore take ~85 milliseconds, plus the 10
millisecond completion timeout, or about 95 milliseconds total. BREAK
recognition would be ignored for roughly 10% of that time. At lower baud
rates, recognition would be ignored for a correspondingly smaller
percentage of the time.
However, SIMH uses an optimized timing of 500 instructions per character
transfer, rather than the ~6600 instructions that a character transfer
should take, and so a typical 20-character line will take about 11,000
instructions. On the other hand, the clock tick is calibrated to real
time, and 10 milliseconds of real time takes about 420,000 instructions
on a 2.0 GHz PC. To be recognized, then, the BREAK key must be pressed
in a window that is open for about 2.5% of the time. Therefore, the
BREAK key will be ignored about 97.5% of the time, and RTE break-mode
effectively will not work.
Deferring BREAK recognition until the next character is output ensures
that the BREAK interrupt will be accepted (the simulator delivers input
interrupts before output interrupts, so the BREAK interrupt arrives
before the output character transmit interrupt). If an output operation
is not in progress, then the BREAK will be recognized at the next input
poll.
2. In simulation, establishing a port connection asserts DSR to the control
card. If the port is configured as a dataset connection (SET MUXLn
DATASET), DCD is also asserted. Disconnecting denies DSR and DCD. The
control card responds to DTR denying by dropping the port connection.
The RTS setting has no effect.
3. When a Bell 103 dataset answers a call, it asserts DSR first. After the
handshake with the remote dataset completes, DCD asserts, typically
between 1.3 and 3.6 seconds later. Similarly, when the remote dataset
terminates the call by sending a long (1.5 second) space, the local
dataset drops DSR first, followed by DCD after approximately 30
milliseconds. The dataset simulation does not model these delays; DSR
and DCD transition up and down together. This implies that the control
card software driver will see only one interrupt for each transition pair
instead of the expected two (presuming both DSR and DCD are enabled to
interrupt).
*/
#include <ctype.h>
#include "hp2100_defs.h"
#include "hp2100_io.h"
#include "sim_tmxr.h"
/* Program limits */
#define TERM_COUNT 16 /* number of terminal channels */
#define AUX_COUNT 5 /* number of auxiliary channels */
#define RECV_CHAN_COUNT (TERM_COUNT + AUX_COUNT) /* number of receive channels */
#define SEND_CHAN_COUNT TERM_COUNT /* number of send channels */
#define UNIT_COUNT TERM_COUNT /* number of units */
#define FIRST_TERM 0 /* first terminal index */
#define LAST_TERM (FIRST_TERM + TERM_COUNT - 1) /* last terminal index */
#define FIRST_AUX TERM_COUNT /* first auxiliary index */
#define LAST_AUX (FIRST_AUX + AUX_COUNT - 1) /* last auxiliary index */
/* Service times */
#define MUXL_WAIT 500 /* initial fast receive/send time in event ticks */
/* Unit flags */
#define UNIT_V_MDM (TTUF_V_UF + 0) /* modem control */
#define UNIT_V_DIAG (TTUF_V_UF + 1) /* loopback diagnostic */
#define UNIT_MDM (1 << UNIT_V_MDM)
#define UNIT_DIAG (1 << UNIT_V_DIAG)
/* Channel number (OTA upper, LIA lower or upper) */
#define MUX_V_CHAN 10 /* channel num */
#define MUX_M_CHAN 037
#define MUX_CHAN(x) (((x) >> MUX_V_CHAN) & MUX_M_CHAN)
/* OTA, lower = parameters or data */
#define OTL_P 0100000 /* parameter */
#define OTL_TX 0040000 /* transmit */
#define OTL_ENB 0020000 /* enable */
#define OTL_TPAR 0010000 /* xmt parity */
#define OTL_ECHO 0010000 /* rcv echo */
#define OTL_DIAG 0004000 /* diagnose */
#define OTL_SYNC 0004000 /* sync */
#define OTL_V_LNT 8 /* char length */
#define OTL_M_LNT 07
#define OTL_LNT(x) (((x) >> OTL_V_LNT) & OTL_M_LNT)
#define OTL_V_BAUD 0 /* baud rate */
#define OTL_M_BAUD 0377
#define OTL_BAUD(x) (((x) >> OTL_V_BAUD) & OTL_M_BAUD)
#define OTL_CHAR 03777 /* char mask */
#define OTL_PAR 0200 /* char parity */
#define BAUD_RATE(p) ((28800 / (OTL_BAUD (p) + 1) + 1) / 2)
static const uint32 bits_per_char [8] = { /* bits per character, indexed by OTL_LNT encoding */
9, 10, 11, 12, 5, 6, 7, 8
};
static const BITSET_NAME lower_parameter_names [] = { /* lower data card parameter word names */
"\1send\0receive", /* bit 14 */
"enable interrupt", /* bit 13 */
"enable parity/echo", /* bit 12 */
"diagnose" /* bit 11 */
};
static const BITSET_FORMAT lower_parameter_format = /* names, offset, direction, alternates, bar */
{ FMT_INIT (lower_parameter_names, 11, msb_first, has_alt, append_bar) };
static const BITSET_NAME lower_data_names [] = { /* lower data card output data word names */
"send", /* bit 14 */
NULL, /* bit 13 */
NULL, /* bit 12 */
"sync" /* bit 11 */
};
static const BITSET_FORMAT lower_data_format = /* names, offset, direction, alternates, bar */
{ FMT_INIT (lower_data_names, 11, msb_first, no_alt, append_bar) };
/* LIA, lower = received data */
#define LIL_PAR 0100000 /* parity */
#define PUT_DCH(x) (((x) & MUX_M_CHAN) << MUX_V_CHAN)
#define LIL_CHAR 01777 /* character */
static const BITSET_NAME lower_input_names [] = { /* lower data card input data word names */
"\1odd parity\0even parity", /* bit 15 */
};
static const BITSET_FORMAT lower_input_format = /* names, offset, direction, alternates, bar */
{ FMT_INIT (lower_input_names, 0, msb_first, has_alt, append_bar) };
/* LIA, upper = status */
#define LIU_SEEK 0100000 /* seeking NI */
#define LIU_DG 0000010 /* diagnose */
#define LIU_BRK 0000004 /* break */
#define LIU_LOST 0000002 /* char lost */
#define LIU_TR 0000001 /* trans/rcv */
static const BITSET_NAME upper_status_names [] = { /* upper data card status word names */
"seeking", /* bit 15 */
NULL, /* bit 14 */
NULL, /* bit 13 */
NULL, /* bit 12 */
NULL, /* bit 11 */
NULL, /* bit 10 */
NULL, /* bit 9 */
NULL, /* bit 8 */
NULL, /* bit 7 */
NULL, /* bit 6 */
NULL, /* bit 5 */
NULL, /* bit 4 */
"diagnose", /* bit 3 */
"break", /* bit 2 */
"lost", /* bit 1 */
"\1send\0receive" /* bit 0 */
};
static const BITSET_FORMAT upper_status_format = /* names, offset, direction, alternates, bar */
{ FMT_INIT (upper_status_names, 0, msb_first, has_alt, no_bar) };
/* OTA, control */
#define OTC_SCAN 0100000 /* scan */
#define OTC_UPD 0040000 /* update */
#define OTC_V_CHAN 10 /* channel */
#define OTC_M_CHAN 017
#define OTC_CHAN(x) (((x) >> OTC_V_CHAN) & OTC_M_CHAN)
#define OTC_EC2 0000200 /* enable Cn upd */
#define OTC_EC1 0000100
#define OTC_C2 0000040 /* Cn flops */
#define OTC_C1 0000020
#define OTC_V_C 4 /* S1 to C1 */
#define OTC_ES2 0000010 /* enb comparison */
#define OTC_ES1 0000004
#define OTC_V_ES 2
#define OTC_SS2 0000002 /* SSn flops */
#define OTC_SS1 0000001
#define OTC_RW (OTC_ES2|OTC_ES1|OTC_SS2|OTC_SS1)
static const BITSET_NAME cntl_control_names [] = { /* control card control word names */
"scan", /* bit 15 */
"update", /* bit 14 */
NULL, /* bit 13 */
NULL, /* bit 12 */
NULL, /* bit 11 */
NULL, /* bit 10 */
NULL, /* bit 9 */
NULL, /* bit 8 */
"EC2", /* bit 7 */
"EC1", /* bit 6 */
"\1C2\0~C2", /* bit 5 */
"\1C1\0~C1", /* bit 4 */
"ES2", /* bit 3 */
"ES1", /* bit 2 */
"\1S2\0~S2", /* bit 1 */
"\1S1\0~S1" /* bit 0 */
};
static const BITSET_FORMAT cntl_control_format = /* names, offset, direction, alternates, bar */
{ FMT_INIT (cntl_control_names, 0, msb_first, has_alt, no_bar) };
/* LIA, control */
#define LIC_MBO 0140000 /* always set */
#define LIC_V_CHAN 10 /* channel */
#define LIC_M_CHAN 017
#define PUT_CCH(x) (((x) & OTC_M_CHAN) << OTC_V_CHAN)
#define LIC_I2 0001000 /* change flags */
#define LIC_I1 0000400
#define LIC_S2 0000002 /* Sn flops */
#define LIC_S1 0000001
#define LIC_V_I 8 /* S1 to I1 */
#define LIC_TSTI(ch) (((muxc_lia[ch] ^ muxc_ota[ch]) & \
((muxc_ota[ch] & (OTC_ES2|OTC_ES1)) >> OTC_V_ES)) \
<< LIC_V_I)
static const BITSET_NAME cntl_status_names [] = { /* control card status word names */
"I2", /* bit 9 */
"I1", /* bit 8 */
NULL, /* bit 7 */
NULL, /* bit 6 */
NULL, /* bit 5 */
NULL, /* bit 4 */
"ES2", /* bit 3 */
"ES1", /* bit 2 */
"\1S2\0~S2", /* bit 1 */
"\1S1\0~S1" /* bit 0 */
};
static const BITSET_FORMAT cntl_status_format = /* names, offset, direction, alternates, bar */
{ FMT_INIT (cntl_status_names, 0, msb_first, has_alt, no_bar) };
/* Control card #1 serial line bits */
#define RTS OTC_C2 /* Control card #1 C2 = Request to Send */
#define DTR OTC_C1 /* Control card #1 C1 = Data Terminal Ready */
#define DCD LIC_S2 /* Control card #1 S2 = Data Carrier Detect */
#define DSR LIC_S1 /* Control card #1 S1 = Data Set Ready */
static const BITSET_NAME cntl_line_names [] = { /* Control card serial line status names */
"RTS", /* bit 5 */
"DTR", /* bit 4 */
NULL, /* bit 3 */
NULL, /* bit 2 */
"DCD", /* bit 1 */
"DSR" /* bit 0 */
};
static const BITSET_FORMAT cntl_line_format = /* names, offset, direction, alternates, bar */
{ FMT_INIT (cntl_line_names, 0, msb_first, no_alt, no_bar) };
/* Program constants */
#define RCV_PAR(x) (odd_parity [(x) & 0377] ? 0 : LIL_PAR)
#define XMT_PAR(x) (odd_parity [(x) & 0377] ? 0 : OTL_PAR)
/* Multiplexer controller state variables */
typedef struct {
FLIP_FLOP control; /* control flip-flop */
FLIP_FLOP flag; /* flag flip-flop */
FLIP_FLOP flag_buffer; /* flag buffer flip-flop */
} CARD_STATE;
static CARD_STATE muxl; /* per-card state */
static CARD_STATE muxc; /* per-card state */
static uint32 muxl_ibuf = 0; /* low in: rcv data */
static uint32 muxl_obuf = 0; /* low out: param */
static uint32 muxu_ibuf = 0; /* upr in: status */
static uint32 muxu_obuf = 0; /* upr out: chan */
static uint32 muxc_chan = 0; /* ctrl chan */
static uint32 muxc_scan = 0; /* ctrl scan */
/* Multiplexer per-line state variables */
static uint16 mux_sta [RECV_CHAN_COUNT]; /* line status */
static uint16 mux_rpar [RECV_CHAN_COUNT]; /* rcv param */
static uint16 mux_xpar [SEND_CHAN_COUNT]; /* xmt param */
static uint8 mux_rchp [RECV_CHAN_COUNT]; /* rcv chr pend */
static uint8 mux_defer [RECV_CHAN_COUNT]; /* rcv break deferred flags */
static uint8 mux_xdon [SEND_CHAN_COUNT]; /* xmt done */
static uint8 muxc_ota [TERM_COUNT]; /* ctrl: Cn,ESn,SSn */
static uint8 muxc_lia [TERM_COUNT]; /* ctrl: Sn */
/* Multiplexer per-line buffer variables */
static uint16 mux_rbuf [RECV_CHAN_COUNT]; /* rcv buf */
static uint16 mux_xbuf [SEND_CHAN_COUNT]; /* xmt buf */
/* Multiplexer local routines */
static void mux_receive (int32 ln, int32 c, t_bool diag);
static void mux_data_int (void);
static void mux_ctrl_int (void);
static void mux_diag (int32 c);
/* Multiplexer local SCP support routines */
static INTERFACE muxl_interface;
static INTERFACE muxu_interface;
static INTERFACE muxc_interface;
static t_stat muxi_svc (UNIT *uptr);
static t_stat muxo_svc (UNIT *uptr);
static t_stat muxc_reset (DEVICE *dptr);
static t_stat mux_attach (UNIT *uptr, CONST char *cptr);
static t_stat mux_detach (UNIT *uptr);
static t_stat mux_setdiag (UNIT *uptr, int32 val, CONST char *cptr, void *desc);
/* Multiplexer SCP data structures */
/* Terminal multiplexer library structures */
static int32 mux_order [TERM_COUNT] = { /* line connection order */
-1 /* use the default order */
};
static TMLN mux_ldsc [TERM_COUNT] = { /* line descriptors */
{ 0 }
};
static TMXR mux_desc = { /* multiplexer descriptor */
TERM_COUNT, /* number of terminal lines */
0, /* listening port (reserved) */
0, /* master socket (reserved) */
mux_ldsc, /* line descriptors */
mux_order, /* line connection order */
NULL /* multiplexer device (derived internally) */
};
/* Device information blocks.
The DIBs of adjacent cards must be contained in an array, so they are defined
here and referenced in the lower and upper card device structures.
*/
static DIB mux_dib [] = {
{ &muxl_interface, /* the device's I/O interface function pointer */
MUXL, /* the device's select code (02-77) */
0, /* the card index */
"12920A Asynchronous Multiplexer Interface Lower Data PCA", /* the card description */
NULL }, /* the ROM description */
{ &muxu_interface, /* the device's I/O interface function pointer */
MUXU, /* the device's select code (02-77) */
0, /* the card index */
"12920A Asynchronous Multiplexer Interface Upper Data PCA", /* the card description */
NULL } /* the ROM description */
};
/* Device information block references */
#define muxl_dib mux_dib [0] /* lower data card DIB */
#define muxu_dib mux_dib [1] /* upper data card DIB */
/* Unit list */
static UNIT muxl_unit [UNIT_COUNT] = {
{ UDATA (&muxo_svc, TT_MODE_UC, 0), MUXL_WAIT },
{ UDATA (&muxo_svc, TT_MODE_UC, 0), MUXL_WAIT },
{ UDATA (&muxo_svc, TT_MODE_UC, 0), MUXL_WAIT },
{ UDATA (&muxo_svc, TT_MODE_UC, 0), MUXL_WAIT },
{ UDATA (&muxo_svc, TT_MODE_UC, 0), MUXL_WAIT },
{ UDATA (&muxo_svc, TT_MODE_UC, 0), MUXL_WAIT },
{ UDATA (&muxo_svc, TT_MODE_UC, 0), MUXL_WAIT },
{ UDATA (&muxo_svc, TT_MODE_UC, 0), MUXL_WAIT },
{ UDATA (&muxo_svc, TT_MODE_UC, 0), MUXL_WAIT },
{ UDATA (&muxo_svc, TT_MODE_UC, 0), MUXL_WAIT },
{ UDATA (&muxo_svc, TT_MODE_UC, 0), MUXL_WAIT },
{ UDATA (&muxo_svc, TT_MODE_UC, 0), MUXL_WAIT },
{ UDATA (&muxo_svc, TT_MODE_UC, 0), MUXL_WAIT },
{ UDATA (&muxo_svc, TT_MODE_UC, 0), MUXL_WAIT },
{ UDATA (&muxo_svc, TT_MODE_UC, 0), MUXL_WAIT },
{ UDATA (&muxo_svc, TT_MODE_UC, 0), MUXL_WAIT }
};
/* Register list */
static REG muxl_reg [] = {
/* Macro Name Location Radix Width Offset Depth Flags */
/* ------ ----- -------------------- ----- ----- ------ ----------------- ----------------- */
{ FLDATA (CTL, muxl.control, 0) },
{ FLDATA (FLG, muxl.flag, 0) },
{ FLDATA (FBF, muxl.flag_buffer, 0) },
{ BRDATA (STA, mux_sta, 8, 16, RECV_CHAN_COUNT) },
{ BRDATA (RPAR, mux_rpar, 8, 16, RECV_CHAN_COUNT) },
{ BRDATA (XPAR, mux_xpar, 8, 16, SEND_CHAN_COUNT) },
{ BRDATA (RBUF, mux_rbuf, 8, 16, RECV_CHAN_COUNT), REG_A },
{ BRDATA (XBUF, mux_xbuf, 8, 16, SEND_CHAN_COUNT), REG_A },
{ BRDATA (RCHP, mux_rchp, 8, 1, RECV_CHAN_COUNT) },
{ BRDATA (XDON, mux_xdon, 8, 1, SEND_CHAN_COUNT) },
{ BRDATA (BDFR, mux_defer, 8, 1, sizeof (mux_defer)) },
{ URDATA (TIME, muxl_unit[0].wait, 10, 24, 0, TERM_COUNT, REG_NZ | PV_LEFT) },
DIB_REGS (muxl_dib),
{ NULL }
};
/* Modifier list */
static MTAB muxl_mod [] = {
/* Mask Value Match Value Print String Match String Validation Display Descriptor */
/* ------------- ------------- ------------------ ------------ ---------- ------- ---------- */
{ TT_MODE, TT_MODE_UC, "UC", "UC", NULL, NULL, NULL },
{ TT_MODE, TT_MODE_7B, "7b", "7B", NULL, NULL, NULL },
{ TT_MODE, TT_MODE_8B, "8b", "8B", NULL, NULL, NULL },
{ TT_MODE, TT_MODE_7P, "7p", "7P", NULL, NULL, NULL },
{ UNIT_MDM, UNIT_MDM, "data set", "DATASET", NULL, NULL, NULL },
{ UNIT_MDM, 0, "direct", "NODATASET", NULL, NULL, NULL },
/* Entry Flags Value Print String Match String Validation Display Descriptor */
/* ------------------- ----- ------------ ------------- ----------------- ------------------ ------------------ */
{ MTAB_XUN | MTAB_NC, 0, "LOG", "LOG", &tmxr_set_log, &tmxr_show_log, (void *) &mux_desc },
{ MTAB_XUN | MTAB_NC, 0, NULL, "NOLOG", &tmxr_set_nolog, NULL, (void *) &mux_desc },
{ MTAB_XUN, 0, NULL, "DISCONNECT", &tmxr_dscln, NULL, (void *) &mux_desc },
{ MTAB_XDV, 2u, "SC", "SC", &hp_set_dib, &hp_show_dib, (void *) &mux_dib },
{ MTAB_XDV | MTAB_NMO, ~2u, "DEVNO", "DEVNO", &hp_set_dib, &hp_show_dib, (void *) &mux_dib },
{ 0 }
};
/* Debugging trace list */
static DEBTAB muxl_deb [] = {
{ "CSRW", TRACE_CSRW }, /* Interface control, status, read, and write actions */
{ "SERV", TRACE_SERV }, /* Channel unit service scheduling calls */
{ "XFER", TRACE_XFER }, /* Data receptions and transmissions */
{ "IOBUS", TRACE_IOBUS }, /* interface I/O bus signals and data words */
{ NULL, 0 }
};
/* Device descriptor */
DEVICE muxl_dev = {
"MUXL", /* device name */
muxl_unit, /* unit array */
muxl_reg, /* register array */
muxl_mod, /* modifier array */
UNIT_COUNT, /* number of units */
10, /* address radix */
31, /* address width */
1, /* address increment */
8, /* data radix */
8, /* data width */
NULL, /* examine routine */
NULL, /* deposit routine */
&muxc_reset, /* reset routine */
NULL, /* boot routine */
NULL, /* attach routine */
NULL, /* detach routine */
&muxl_dib, /* device information block pointer */
DEV_DISABLE | DEV_DEBUG, /* device flags */
0, /* debug control flags */
muxl_deb, /* debug flag name array */
NULL, /* memory size change routine */
NULL, /* logical device name */
NULL, /* help routine */
NULL, /* help attach routine*/
NULL /* help context */
};
/* Unit list */
static UNIT muxu_unit [] = {
{ UDATA (&muxi_svc, UNIT_ATTABLE, 0), POLL_FIRST }
};
/* Register list */
static REG muxu_reg [] = {
/* Macro Name Location Width Flags */
/* ------ ----- -------------------- ----- ------- */
{ ORDATA (IBUF, muxu_ibuf, 16) },
{ ORDATA (OBUF, muxu_obuf, 16) },
DIB_REGS (muxu_dib),
{ NULL }
};
/* Modifier list */
static MTAB muxu_mod [] = {
/* Mask Value Match Value Print String Match String Validation Display Descriptor */
/* ------------- ----------- ------------------ ------------ ------------ --------------- ------------------ */
{ UNIT_DIAG, UNIT_DIAG, "diagnostic mode", "DIAGNOSTIC", &mux_setdiag, NULL, NULL },
{ UNIT_DIAG, 0, "terminal mode", "TERMINAL", &mux_setdiag, NULL, NULL },
{ UNIT_ATT, UNIT_ATT, "", NULL, NULL, &tmxr_show_summ, (void *) &mux_desc },
/* Entry Flags Value Print String Match String Validation Display Descriptor */
/* ------------------- ----- ------------- ------------- ----------------- ------------------ ------------------ */
{ MTAB_XDV | MTAB_NMO, 0, "LINEORDER", "LINEORDER", &tmxr_set_lnorder, &tmxr_show_lnorder, (void *) &mux_desc },
{ MTAB_XDV | MTAB_NMO, 1, "CONNECTIONS", NULL, NULL, &tmxr_show_cstat, (void *) &mux_desc },
{ MTAB_XDV | MTAB_NMO, 0, "STATISTICS", NULL, NULL, &tmxr_show_cstat, (void *) &mux_desc },
{ MTAB_XDV, 1, NULL, "DISCONNECT", &tmxr_dscln, NULL, (void *) &mux_desc },
{ MTAB_XDV, 2u, "SC", "SC", &hp_set_dib, &hp_show_dib, (void *) &mux_dib },
{ MTAB_XDV | MTAB_NMO, ~2u, "DEVNO", "DEVNO", &hp_set_dib, &hp_show_dib, (void *) &mux_dib },
{ 0 }
};
/* Debugging trace list */
static DEBTAB muxu_deb [] = {
{ "CSRW", TRACE_CSRW }, /* Interface control, status, read, and write actions */
{ "PSERV", TRACE_PSERV }, /* Poll unit service scheduling calls */
{ "IOBUS", TRACE_IOBUS }, /* interface I/O bus signals and data words */
{ NULL, 0 }
};
/* Device descriptor */
DEVICE muxu_dev = {
"MUX", /* device name */
muxu_unit, /* unit array */
muxu_reg, /* register array */
muxu_mod, /* modifier array */
1, /* number of units */
10, /* address radix */
31, /* address width */
1, /* address increment */
8, /* data radix */
8, /* data width */
&tmxr_ex, /* examine routine */
&tmxr_dep, /* deposit routine */
&muxc_reset, /* reset routine */
NULL, /* boot routine */
&mux_attach, /* attach routine */
&mux_detach, /* detach routine */
&muxu_dib, /* device information block pointer */
DEV_DISABLE | DEV_DEBUG, /* device flags */
0, /* debug control flags */
muxu_deb, /* debug flag name array */
NULL, /* memory size change routine */
NULL, /* logical device name */
NULL, /* help routine */
NULL, /* help attach routine*/
(void *) &mux_desc /* help context */
};
/* Device information block */
static DIB muxc_dib = {
&muxc_interface, /* the device's I/O interface function pointer */
MUXC, /* the device's select code (02-77) */
0, /* the card index */
"12920A Asynchronous Multiplexer Interface Control PCA", /* the card description */
NULL /* the ROM description */
};
/* Unit list */
static UNIT muxc_unit [] = {
{ UDATA (NULL, 0, 0) }
};
/* Register list */
static REG muxc_reg [] = {
/* Macro Name Location Radix Width Offset Depth Flags */
/* ------ ----- -------------------- ----- ----- ------ ----------------- ----------------- */
{ FLDATA (CTL, muxc.control, 0) },
{ FLDATA (FLG, muxc.flag, 0) },
{ FLDATA (FBF, muxc.flag_buffer, 0) },
{ FLDATA (SCAN, muxc_scan, 0) },
{ ORDATA (CHAN, muxc_chan, 4) },
{ BRDATA (DSO, muxc_ota, 2, 6, TERM_COUNT) },
{ BRDATA (DSI, muxc_lia, 2, 2, TERM_COUNT) },
DIB_REGS (muxc_dib),
{ NULL }
};
/* Modifier list */
static MTAB muxc_mod [] = {
/* Entry Flags Value Print String Match String Validation Display Descriptor */
/* ------------------- ----- ------------ ------------ ------------ ------------- ------------------ */
{ MTAB_XDV, 1u, "SC", "SC", &hp_set_dib, &hp_show_dib, (void *) &muxc_dib },
{ MTAB_XDV | MTAB_NMO, ~1u, "DEVNO", "DEVNO", &hp_set_dib, &hp_show_dib, (void *) &muxc_dib },
{ 0 }
};
/* Debugging trace list */
static DEBTAB muxc_deb [] = {
{ "CSRW", TRACE_CSRW }, /* Interface control, status, read, and write actions */
{ "XFER", TRACE_XFER }, /* Data receptions and transmissions */
{ "IOBUS", TRACE_IOBUS }, /* interface I/O bus signals and data words */
{ NULL, 0 }
};
/* Device descriptor */
DEVICE muxc_dev = {
"MUXM", /* device name (deprecated; use MUXC) */
muxc_unit, /* unit array */
muxc_reg, /* register array */
muxc_mod, /* modifier array */
1, /* number of units */
10, /* address radix */
31, /* address width */
1, /* address increment */
8, /* data radix */
8, /* data width */
NULL, /* examine routine */
NULL, /* deposit routine */
&muxc_reset, /* reset routine */
NULL, /* boot routine */
NULL, /* attach routine */
NULL, /* detach routine */
&muxc_dib, /* device information block pointer */
DEV_DISABLE | DEV_DEBUG, /* device flags */
0, /* debug control flags */
muxc_deb, /* debug flag name array */
NULL, /* memory size change routine */
NULL, /* logical device name */
NULL, /* help routine */
NULL, /* help attach routine*/
NULL /* help context */
};
/* Lower data card interface.
Implementation notes:
1. The operating manual says that "at least 100 milliseconds of CLC 0s must
be programmed" by systems employing the multiplexer to ensure that the
multiplexer resets. In practice, such systems issue 128K CLC 0
instructions. In simulation, only one ioCRS invocation is required to
reset the multiplexer.
*/
static SIGNALS_VALUE muxl_interface (const DIB *dibptr, INBOUND_SET inbound_signals, HP_WORD inbound_value)
{
int32 ln;
INBOUND_SIGNAL signal;
INBOUND_SET working_set = inbound_signals;
SIGNALS_VALUE outbound = { ioNONE, 0 };
t_bool irq_enabled = FALSE;
while (working_set) { /* while signals remain */
signal = IONEXTSIG (working_set); /* isolate the next signal */
switch (signal) { /* dispatch the I/O signal */
case ioCLF: /* Clear Flag flip-flop */
muxl.flag_buffer = CLEAR; /* reset the flag buffer */
muxl.flag = CLEAR; /* and flag flip-flops */
mux_data_int (); /* look for new int */
break;
case ioSTF: /* Set Flag flip-flop */
muxl.flag_buffer = SET; /* set the flag buffer flip-flop */
break;
case ioENF: /* Enable Flag */
if (muxl.flag_buffer == SET) /* if the flag buffer flip-flop is set */
muxl.flag = SET; /* then set the flag flip-flop */
break;
case ioSFC: /* Skip if Flag is Clear */
if (muxl.flag == CLEAR) /* if the flag flip-flop is clear */
outbound.signals |= ioSKF; /* then assert the Skip on Flag signal */
break;
case ioSFS: /* Skip if Flag is Set */
if (muxl.flag == SET) /* if the flag flip-flop is set */
outbound.signals |= ioSKF; /* then assert the Skip on Flag signal */
break;
case ioIOI: /* I/O data input */
tprintf (muxl_dev, TRACE_CSRW, "Input data is channel %u | %s%04o\n",
MUX_CHAN (muxl_ibuf),
fmt_bitset (muxl_ibuf, lower_input_format),
muxl_ibuf & LIL_CHAR);
outbound.value = muxl_ibuf; /* merge in return status */
break;
case ioIOO: /* I/O data output */
muxl_obuf = inbound_value; /* store data */
if (muxl_obuf & OTL_P)
tprintf (muxl_dev, TRACE_CSRW, "Parameter is %s%u bits | %u baud\n",
fmt_bitset (muxl_obuf, lower_parameter_format),
bits_per_char [OTL_LNT (muxl_obuf)],
BAUD_RATE (muxl_obuf));