RESTRICTION: The FP15 and XVM features of the PDP-15 are only partially debugged. Do NOT enable these features for normal operations. 1. New Features in 3.1-0 1.1 SCP and libraries - Added simulated Ethernet support for VMS, FreeBSD, Mac OS/X. - Added status return to tmxr_putc_ln. - Added sim_putchar_s to handle possible output stalls. 1.2 All DECtapes - Added "DECtape off reel" error stop. 1.3 All Asynchronous Consoles - Added support for output congestion stall if using a Telnet connection. 1.4 PDP-1 - Added Type 23 parallel drum support. 1.5 PDP-8 - Added instruction history. - Added TSC8-75 option support for ETOS. - Added TD8E DECtape support. 1.6 PDP-18b - Added instruction history. - Changed PDP-9, PDP-15 API default to enabled. 1.7 PDP-11 - Added support for 18b only Qbus devices. - Formalized bus and addressing definitions. - Added control to enable/disable autoconfiguration. - Added stub support for second Unibus Ethernet controller. 1.7 Interdata 32b - Added instruction history. 1.8 Eclipse - Added floating point support. - Added programmable interval timer support. 1.9 H316 - Added DMA/DMC support. - Added fixed head disk support. - Added moving head disk support. - Added magtape support. 1.10 IBM 1130 (Brian Knittel) - Added support for physical card reader, using the Cardread interface (www.ibm1130.org/sim/downloads). - Added support for physical printer (flushes output buffer after each line). 2. Bugs Fixed in 3.1-0 2.1 SCP and libraries - Fixed numerous bugs in Ethernet library. 2.2 All DECtapes - Fixed reverse checksum value in 'read all' mode. - Simplified (and sped up) timing. 2.3 PDP-8 - Fixed bug in RX28 read status (found by Charles Dickman). - Fixed RX28 double density write. 2.4 PDP-18b - Fixed autoincrement bug in PDP-4, PDP-7, PDP-9. 2.5 PDP-11/VAX - Revised RQ MB->LBN conversion for greater accuracy. - Fixed bug in IO configuration (found by David Hittner). - Fixed bug with multiple RQ RAUSER drives. - Fixed bug in second Qbus Ethernet controller interrupts. 2.6 Nova/Eclipse - Fixed bugs in DKP flag clear, map setup, map usage (Charles Owen). - Fixed bug in MT, reset completes despite I/O reset (Charles Owen). - Fixed bug in MT, space operations return word count (Charles Owen). 2.7 IBM 1130 (Brian Knittel) - Fixed bug in setting carry bit in subtract and subtract double. - Fixed timing problem in console printer simulation. 2.8 1620 - Fixed bug in branch digit (found by Dave Babcock). 3. New Features in 3.0 vs prior releases 3.1 SCP and Libraries - Added ASSIGN/DEASSIGN (logical name) commands. - Changed RESTORE to unconditionally detach files. - Added E11 and TPC format support to magtape library. - Fixed bug in SHOW CONNECTIONS. - Added USE_ADDR64 support. 3.2 All magtapes - Magtapes support SIMH format, E11 format, and TPC format (read only). - SET <tape_unit> FORMAT=format sets the specified tape unit's format. - SHOW <tape_unit> FORMAT displays the specified tape unit's format. - Tape format can also be set as part of the ATTACH command, using the -F switch. 3.3 VAX - VAX can be compiled without USE_INT64. - If compiled with USE_INT64 and USE_ADDR64, RQ and TQ controllers support files > 2GB. - VAX ROM has speed control (SET ROM DELAY/NODELAY). 3.4 PDP-1 - Added block loader format support to LOAD. - Changed BOOT PTR to allow loading of all of the first bank of memory. - The LOAD command takes an optional argument specifying the memory field to be loaded. - The PTR BOOT command takes its starting memory field from the TA (address switch) register. 3.5 PDP-18b Family - Added PDP-4 EAE support. - Added PDP-15 FP15 support. - Added PDP-15 XVM support. - Added PDP-15 "re-entrancy ECO". - Added PDP-7, PDP-9, PDP-15 hardware RIM loader support in BOOT PTR. 4. Bugs Fixed in 3.0 vs prior releases 4.1 SCP and Libraries - Fixed end of file problem in dep, idep. - Fixed handling of trailing spaces in dep, idep. 4.2 VAX - Fixed CVTfi bug: integer overflow not set if exponent out of range - Fixed EMODx bugs: o First and second operands reversed o Separated fraction received wrong exponent o Overflow calculation on separated integer incorrect o Fraction not set to zero if exponent out of range - Fixed interval timer and ROM access to pass power-up self-test even on very fast host processors (fixes from Mark Pizzolato). - Fixed bug in user disk size (found by Chaskiel M Grundman). 4.3 1401 - Fixed mnemonic, instruction lengths, and reverse scan length check bug for MCS. - Fixed MCE bug, BS off by 1 if zero suppress. - Fixed chaining bug, D lost if return to SCP. - Fixed H branch, branch occurs after continue. - Added check for invalid 8 character MCW, LCA. - Fixed magtape load-mode end of record response. - Revised fetch to model hardware more closely. - Fixed tape read end-of-record handling based on real 1401. - Added diagnostic read (space forward). 4.4 Nova - Fixed DSK variable size interaction with restore. - Fixed bug in DSK set size routine. 4.5 PDP-1 - Fixed DT variable size interaction with restore. - Updated CPU, line printer, standard devices to detect indefinite I/O wait. - Fixed incorrect logical, missing activate, break in drum simulator. - Fixed bugs in instruction decoding, overprinting for line printer. - Fixed system hang if continue after PTR error. - Fixed PTR to start/stop on successive rpa instructions. 4.6 PDP-11 - Fixed DT variable size interaction with restore. - Fixed bug in MMR1 update (found by Tim Stark). - Added XQ features and fixed bugs: o Corrected XQ interrupts on IE state transition (code by Tom Evans). o Added XQ interrupt clear on soft reset. o Removed XQ interrupt when setting XL or RL (multiple people). o Added SET/SHOW XQ STATS. o Added SHOW XQ FILTERS. o Added ability to split received packet into multiple buffers. o Added explicit runt and giant packet processing. - Fixed bug in user disk size (found by Chaskiel M Grundman). 4.7 PDP-18B - Fixed DT, RF variable size interaction with restore. - Fixed MT bug in MTTR. - Fixed bug in PDP-4 line printer overprinting. - Fixed bug in PDP-15 memory protect/skip interaction. - Fixed bug in RF set size routine. - Increased PTP TIME for PDP-15 operating systems. - Fixed priorities in PDP-15 API (differs from PDP-9). - Fixed sign handling in PDP-15 EAE unsigned mul/div (differs from PDP-9). - Fixed bug in CAF, clears API subsystem. 4.8 PDP-8 - Fixed DT, DF, RF, RX variable size interaction with restore. - Fixed MT bug in SKTR. - Fixed bug in DF, RF set size routine. 4.9 HP2100 - Fixed bug in DP (13210A controller only), DQ read status. - Fixed bug in DP, DQ seek complete. - Fixed DR drum sizes. - Fixed DR variable capacity interaction with SAVE/RESTORE. 4.10 GRI - Fixed bug in SC queue pointer management. 4.11 PDP-10 - Fixed bug in RP read header. 4.12 Ibm1130 - Fixed bugs found by APL 1130. 4.13 Altairz80 - Fixed bug in real-time clock on Windows host. 4.14 1620 - Fixed bug in immediate index add (found by Michael Short).
708 lines
24 KiB
C
708 lines
24 KiB
C
/* hp2100_mux.c: HP 2100 12920A terminal multiplexor simulator
|
||
|
||
Copyright (c) 2002-2003, Robert M Supnik
|
||
|
||
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
|
||
ROBERT M SUPNIK 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 name of Robert M Supnik shall not
|
||
be used in advertising or otherwise to promote the sale, use or other dealings
|
||
in this Software without prior written authorization from Robert M Supnik.
|
||
|
||
mux,muxl,muxc 12920A terminal multiplexor
|
||
|
||
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
|
||
|
||
The 12920A consists of three separate devices
|
||
|
||
mux scanner (upper data card)
|
||
muxl lines (lower data card)
|
||
muxm modem control (control card)
|
||
|
||
The lower data card has no CMD flop; the control card has no CMD flop.
|
||
The upper data card has none of the usual flops.
|
||
*/
|
||
|
||
#include "hp2100_defs.h"
|
||
#include "sim_sock.h"
|
||
#include "sim_tmxr.h"
|
||
#include <ctype.h>
|
||
|
||
#define MUX_LINES 16 /* user lines */
|
||
#define MUX_ILINES 5 /* diag rcv only */
|
||
#define UNIT_V_8B (UNIT_V_UF + 0) /* 8B */
|
||
#define UNIT_V_UC (UNIT_V_UF + 1) /* UC only */
|
||
#define UNIT_V_MDM (UNIT_V_UF + 2) /* modem control */
|
||
#define UNIT_8B (1 << UNIT_V_8B)
|
||
#define UNIT_UC (1 << UNIT_V_UC)
|
||
#define UNIT_MDM (1 << UNIT_V_MDM)
|
||
#define MUXU_INIT_POLL 8000
|
||
#define MUXL_WAIT 500
|
||
|
||
/* 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 01777 /* char mask */
|
||
|
||
/* 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 */
|
||
|
||
/* 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 */
|
||
|
||
/* 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_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)
|
||
#define RTS OCT_C2 /* C2 = rts */
|
||
#define DTR OTC_C1 /* C1 = dtr */
|
||
|
||
/* 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 CDET LIC_S2 /* S2 = cdet */
|
||
#define DSR LIC_S1 /* S1 = dsr */
|
||
|
||
#define LIC_TSTI(ch) (((muxc_lia[ch] ^ muxc_ota[ch]) & \
|
||
((muxc_ota[ch] & (OTC_ES2|OTC_ES1)) >> OTC_V_ES)) \
|
||
<< LIC_V_I)
|
||
|
||
extern uint32 PC;
|
||
extern uint32 dev_cmd[2], dev_ctl[2], dev_flg[2], dev_fbf[2];
|
||
|
||
uint16 mux_sta[MUX_LINES]; /* line status */
|
||
uint16 mux_rpar[MUX_LINES + MUX_ILINES]; /* rcv param */
|
||
uint16 mux_xpar[MUX_LINES]; /* xmt param */
|
||
uint8 mux_rbuf[MUX_LINES + MUX_ILINES]; /* rcv buf */
|
||
uint8 mux_xbuf[MUX_LINES]; /* xmt buf */
|
||
uint8 mux_rchp[MUX_LINES + MUX_ILINES]; /* rcv chr pend */
|
||
uint8 mux_xdon[MUX_LINES]; /* xmt done */
|
||
uint8 muxc_ota[MUX_LINES]; /* ctrl: Cn,ESn,SSn */
|
||
uint8 muxc_lia[MUX_LINES]; /* ctrl: Sn */
|
||
uint32 mux_tps = 100; /* polls/second */
|
||
uint32 muxl_ibuf = 0; /* low in: rcv data */
|
||
uint32 muxl_obuf = 0; /* low out: param */
|
||
uint32 muxu_ibuf = 0; /* upr in: status */
|
||
uint32 muxu_obuf = 0; /* upr out: chan */
|
||
uint32 muxc_chan = 0; /* ctrl chan */
|
||
uint32 muxc_scan = 0; /* ctrl scan */
|
||
|
||
TMLN mux_ldsc[MUX_LINES] = { 0 }; /* line descriptors */
|
||
TMXR mux_desc = { MUX_LINES, 0, 0, NULL }; /* mux descriptor */
|
||
|
||
DEVICE muxl_dev, muxu_dev, muxc_dev;
|
||
int32 muxlio (int32 inst, int32 IR, int32 dat);
|
||
int32 muxuio (int32 inst, int32 IR, int32 dat);
|
||
int32 muxcio (int32 inst, int32 IR, int32 dat);
|
||
t_stat muxi_svc (UNIT *uptr);
|
||
t_stat muxo_svc (UNIT *uptr);
|
||
t_stat mux_reset (DEVICE *dptr);
|
||
t_stat mux_attach (UNIT *uptr, char *cptr);
|
||
t_stat mux_detach (UNIT *uptr);
|
||
t_stat mux_summ (FILE *st, UNIT *uptr, int32 val, void *desc);
|
||
t_stat mux_show (FILE *st, UNIT *uptr, int32 val, void *desc);
|
||
void mux_data_int (void);
|
||
void mux_ctrl_int (void);
|
||
void mux_diag (int32 c);
|
||
|
||
static uint8 odd_par[256] = {
|
||
1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, /* 000-017 */
|
||
0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, /* 020-037 */
|
||
0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, /* 040-067 */
|
||
1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, /* 060-077 */
|
||
0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, /* 100-117 */
|
||
1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, /* 120-137 */
|
||
1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, /* 140-157 */
|
||
0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, /* 160-177 */
|
||
0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, /* 200-217 */
|
||
1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, /* 220-237 */
|
||
1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, /* 240-257 */
|
||
0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, /* 260-277 */
|
||
1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, /* 300-317 */
|
||
0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, /* 320-337 */
|
||
0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, /* 340-367 */
|
||
1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1 }; /* 360-377 */
|
||
|
||
#define RCV_PAR(x) (odd_par[(x) & 0377]? LIL_PAR: 0)
|
||
|
||
DIB mux_dib[] = {
|
||
{ MUXL, 0, 0, 0, 0, &muxlio },
|
||
{ MUXU, 0, 0, 0, 0, &muxuio } };
|
||
|
||
#define muxl_dib mux_dib[0]
|
||
#define muxu_dib mux_dib[1]
|
||
|
||
/* MUX data structures
|
||
|
||
muxu_dev MUX device descriptor
|
||
muxu_unit MUX unit descriptor
|
||
muxu_reg MUX register list
|
||
muxu_mod MUX modifiers list
|
||
*/
|
||
|
||
UNIT muxu_unit = { UDATA (&muxi_svc, UNIT_ATTABLE, 0), MUXU_INIT_POLL };
|
||
|
||
REG muxu_reg[] = {
|
||
{ ORDATA (IBUF, muxu_ibuf, 16) },
|
||
{ ORDATA (OBUF, muxu_obuf, 16) },
|
||
{ FLDATA (CMD, muxu_dib.cmd, 0), REG_HRO },
|
||
{ FLDATA (CTL, muxu_dib.ctl, 0), REG_HRO },
|
||
{ FLDATA (FLG, muxu_dib.flg, 0), REG_HRO },
|
||
{ FLDATA (FBF, muxu_dib.fbf, 0), REG_HRO },
|
||
{ ORDATA (DEVNO, muxu_dib.devno, 6), REG_HRO },
|
||
{ NULL } };
|
||
|
||
MTAB muxu_mod[] = {
|
||
{ UNIT_ATT, UNIT_ATT, "connections", NULL, NULL, &mux_summ },
|
||
{ MTAB_XTD | MTAB_VDV | MTAB_NMO, 1, "CONNECTIONS", NULL,
|
||
NULL, &mux_show, NULL },
|
||
{ MTAB_XTD | MTAB_VDV | MTAB_NMO, 0, "STATISTICS", NULL,
|
||
NULL, &mux_show, NULL },
|
||
{ MTAB_XTD|MTAB_VDV, 1, "DEVNO", "DEVNO",
|
||
&hp_setdev, &hp_showdev, &muxl_dev },
|
||
{ MTAB_XTD | MTAB_VDV, 1, NULL, "DISCONNECT",
|
||
&tmxr_dscln, NULL, &mux_desc },
|
||
{ 0 } };
|
||
|
||
DEVICE muxu_dev = {
|
||
"MUX", &muxu_unit, muxu_reg, muxu_mod,
|
||
1, 10, 31, 1, 8, 8,
|
||
&tmxr_ex, &tmxr_dep, &mux_reset,
|
||
NULL, &mux_attach, &mux_detach,
|
||
&muxu_dib, DEV_NET | DEV_DISABLE };
|
||
|
||
/* MUXL data structures
|
||
|
||
muxl_dev MUXL device descriptor
|
||
muxl_unit MUXL unit descriptor
|
||
muxl_reg MUXL register list
|
||
muxl_mod MUXL modifiers list
|
||
*/
|
||
|
||
UNIT muxl_unit[] = {
|
||
{ UDATA (&muxo_svc, UNIT_UC, 0), MUXL_WAIT },
|
||
{ UDATA (&muxo_svc, UNIT_UC, 0), MUXL_WAIT },
|
||
{ UDATA (&muxo_svc, UNIT_UC, 0), MUXL_WAIT },
|
||
{ UDATA (&muxo_svc, UNIT_UC, 0), MUXL_WAIT },
|
||
{ UDATA (&muxo_svc, UNIT_UC, 0), MUXL_WAIT },
|
||
{ UDATA (&muxo_svc, UNIT_UC, 0), MUXL_WAIT },
|
||
{ UDATA (&muxo_svc, UNIT_UC, 0), MUXL_WAIT },
|
||
{ UDATA (&muxo_svc, UNIT_UC, 0), MUXL_WAIT },
|
||
{ UDATA (&muxo_svc, UNIT_UC, 0), MUXL_WAIT },
|
||
{ UDATA (&muxo_svc, UNIT_UC, 0), MUXL_WAIT },
|
||
{ UDATA (&muxo_svc, UNIT_UC, 0), MUXL_WAIT },
|
||
{ UDATA (&muxo_svc, UNIT_UC, 0), MUXL_WAIT },
|
||
{ UDATA (&muxo_svc, UNIT_UC, 0), MUXL_WAIT },
|
||
{ UDATA (&muxo_svc, UNIT_UC, 0), MUXL_WAIT },
|
||
{ UDATA (&muxo_svc, UNIT_UC, 0), MUXL_WAIT },
|
||
{ UDATA (&muxo_svc, UNIT_UC, 0), MUXL_WAIT },
|
||
{ UDATA (&muxo_svc, UNIT_UC, 0), MUXL_WAIT } };
|
||
|
||
MTAB muxl_mod[] = {
|
||
{ UNIT_UC+UNIT_8B, UNIT_UC, "UC", "UC", NULL },
|
||
{ UNIT_UC+UNIT_8B, 0 , "7b", "7B", NULL },
|
||
{ UNIT_UC+UNIT_8B, UNIT_8B, "8b", "8B", NULL },
|
||
{ UNIT_MDM, 0, "no dataset", "NODATASET", NULL },
|
||
{ UNIT_MDM, UNIT_MDM, "dataset", "DATASET", NULL },
|
||
{ MTAB_XTD|MTAB_VDV, 1, "DEVNO", "DEVNO",
|
||
&hp_setdev, &hp_showdev, &muxl_dev },
|
||
{ 0 } };
|
||
|
||
REG muxl_reg[] = {
|
||
{ FLDATA (CMD, muxl_dib.cmd, 0), REG_HRO },
|
||
{ FLDATA (CTL, muxl_dib.ctl, 0) },
|
||
{ FLDATA (FLG, muxl_dib.flg, 0) },
|
||
{ FLDATA (FBF, muxl_dib.fbf, 0) },
|
||
{ BRDATA (STA, mux_sta, 8, 16, MUX_LINES) },
|
||
{ BRDATA (RPAR, mux_rpar, 8, 16, MUX_LINES + MUX_ILINES) },
|
||
{ BRDATA (XPAR, mux_xpar, 8, 16, MUX_LINES) },
|
||
{ BRDATA (RBUF, mux_rbuf, 8, 8, MUX_LINES + MUX_ILINES) },
|
||
{ BRDATA (XBUF, mux_xbuf, 8, 8, MUX_LINES) },
|
||
{ BRDATA (RCHP, mux_rchp, 8, 1, MUX_LINES + MUX_ILINES) },
|
||
{ BRDATA (XDON, mux_xdon, 8, 1, MUX_LINES) },
|
||
{ URDATA (TIME, muxl_unit[0].wait, 10, 24, 0,
|
||
MUX_LINES, REG_NZ + PV_LEFT) },
|
||
{ ORDATA (DEVNO, muxl_dib.devno, 6), REG_HRO },
|
||
{ NULL } };
|
||
|
||
DEVICE muxl_dev = {
|
||
"MUXL", muxl_unit, muxl_reg, muxl_mod,
|
||
MUX_LINES, 10, 31, 1, 8, 8,
|
||
NULL, NULL, &mux_reset,
|
||
NULL, NULL, NULL,
|
||
&muxl_dib, 0 };
|
||
|
||
/* MUXM data structures
|
||
|
||
muxc_dev MUXM device descriptor
|
||
muxc_unit MUXM unit descriptor
|
||
muxc_reg MUXM register list
|
||
muxc_mod MUXM modifiers list
|
||
*/
|
||
|
||
DIB muxc_dib = { MUXC, 0, 0, 0, 0, &muxcio };
|
||
|
||
UNIT muxc_unit = { UDATA (NULL, 0, 0) };
|
||
|
||
REG muxc_reg[] = {
|
||
{ FLDATA (CMD, muxc_dib.cmd, 0), REG_HRO },
|
||
{ FLDATA (CTL, muxc_dib.ctl, 0) },
|
||
{ FLDATA (FLG, muxc_dib.flg, 0) },
|
||
{ FLDATA (FBF, muxc_dib.fbf, 0) },
|
||
{ FLDATA (SCAN, muxc_scan, 0) },
|
||
{ ORDATA (CHAN, muxc_chan, 4) },
|
||
{ BRDATA (DSO, muxc_ota, 8, 6, MUX_LINES) },
|
||
{ BRDATA (DSI, muxc_lia, 8, 2, MUX_LINES) },
|
||
{ ORDATA (DEVNO, muxc_dib.devno, 6), REG_HRO },
|
||
{ NULL } };
|
||
|
||
MTAB muxc_mod[] = {
|
||
{ MTAB_XTD|MTAB_VDV, 0, "DEVNO", "DEVNO",
|
||
&hp_setdev, &hp_showdev, &muxc_dev },
|
||
{ 0 } };
|
||
|
||
DEVICE muxc_dev = {
|
||
"MUXM", &muxc_unit, muxc_reg, muxc_mod,
|
||
1, 10, 31, 1, 8, 8,
|
||
NULL, NULL, &mux_reset,
|
||
NULL, NULL, NULL,
|
||
&muxc_dib, 0 };
|
||
|
||
/* IOT routines: data cards */
|
||
|
||
int32 muxlio (int32 inst, int32 IR, int32 dat)
|
||
{
|
||
int32 dev, ln;
|
||
|
||
dev = IR & I_DEVMASK; /* get device no */
|
||
switch (inst) { /* case on opcode */
|
||
case ioFLG: /* flag clear/set */
|
||
if ((IR & I_HC) == 0) { setFLG (dev); } /* STF */
|
||
break;
|
||
case ioSFC: /* skip flag clear */
|
||
if (FLG (dev) == 0) PC = (PC + 1) & VAMASK;
|
||
return dat;
|
||
case ioSFS: /* skip flag set */
|
||
if (FLG (dev) != 0) PC = (PC + 1) & VAMASK;
|
||
return dat;
|
||
case ioOTX: /* output */
|
||
muxl_obuf = dat; /* store data */
|
||
break;
|
||
case ioMIX: /* merge */
|
||
dat = dat | muxl_ibuf;
|
||
break;
|
||
case ioLIX: /* load */
|
||
dat = muxl_ibuf;
|
||
break;
|
||
case ioCTL: /* control clear/set */
|
||
if (IR & I_CTL) { clrCTL (dev); } /* CLC */
|
||
else { /* STC */
|
||
setCTL (dev); /* set ctl */
|
||
ln = MUX_CHAN (muxu_obuf); /* get chan # */
|
||
if (muxl_obuf & OTL_P) { /* parameter set? */
|
||
if (muxl_obuf & OTL_TX) { /* transmit? */
|
||
if (ln < MUX_LINES) /* to valid line? */
|
||
mux_xpar[ln] = muxl_obuf; }
|
||
else if (ln < (MUX_LINES + MUX_ILINES)) /* rcv, valid line? */
|
||
mux_rpar[ln] = muxl_obuf; }
|
||
else if ((muxl_obuf & OTL_TX) && /* xmit data? */
|
||
(ln < MUX_LINES)) { /* to valid line? */
|
||
if (sim_is_active (&muxl_unit[ln])) /* still working? */
|
||
mux_sta[ln] = mux_sta[ln] | LIU_LOST;
|
||
else sim_activate (&muxl_unit[ln], muxl_unit[ln].wait);
|
||
mux_xbuf[ln] = muxl_obuf & OTL_CHAR; } /* load buffer */
|
||
} /* end STC */
|
||
break;
|
||
default:
|
||
break; }
|
||
if (IR & I_HC) { /* H/C option */
|
||
clrFLG (dev); /* clear flag */
|
||
mux_data_int (); } /* look for new int */
|
||
return dat;
|
||
}
|
||
|
||
int32 muxuio (int32 inst, int32 IR, int32 dat)
|
||
{
|
||
switch (inst) { /* case on opcode */
|
||
case ioOTX: /* output */
|
||
muxu_obuf = dat; /* store data */
|
||
break;
|
||
case ioMIX: /* merge */
|
||
dat = dat | muxu_ibuf;
|
||
break;
|
||
case ioLIX: /* load */
|
||
dat = muxu_ibuf;
|
||
break;
|
||
default:
|
||
break; }
|
||
return dat;
|
||
}
|
||
|
||
/* IOT routine: control card */
|
||
|
||
int32 muxcio (int32 inst, int32 IR, int32 dat)
|
||
{
|
||
int32 dev, ln, t, old;
|
||
|
||
dev = IR & I_DEVMASK; /* get device no */
|
||
switch (inst) { /* case on opcode */
|
||
case ioFLG: /* flag clear/set */
|
||
if ((IR & I_HC) == 0) { setFLG (dev); } /* STF */
|
||
break;
|
||
case ioSFC: /* skip flag clear */
|
||
if (FLG (dev) == 0) PC = (PC + 1) & VAMASK;
|
||
return dat;
|
||
case ioSFS: /* skip flag set */
|
||
if (FLG (dev) != 0) PC = (PC + 1) & VAMASK;
|
||
return dat;
|
||
case ioOTX: /* output */
|
||
if (dat & OTC_SCAN) muxc_scan = 1; /* set scan flag */
|
||
else muxc_scan = 0;
|
||
if (dat & OTC_UPD) { /* update? */
|
||
ln = OTC_CHAN (dat); /* get channel */
|
||
old = muxc_ota[ln]; /* save prior val */
|
||
muxc_ota[ln] = (muxc_ota[ln] & ~OTC_RW) | /* save ESn,SSn */
|
||
(dat & OTC_RW);
|
||
if (dat & OTC_EC2) muxc_ota[ln] = /* if EC2, upd C2 */
|
||
(muxc_ota[ln] & ~OTC_C2) | (dat & OTC_C2);
|
||
if (dat & OTC_EC1) muxc_ota[ln] = /* if EC1, upd C1 */
|
||
(muxc_ota[ln] & ~OTC_C1) | (dat & OTC_C1);
|
||
if ((muxl_unit[ln].flags & UNIT_MDM) && /* modem ctrl? */
|
||
(old & DTR) && !(muxc_ota[ln] & DTR)) { /* DTR drop? */
|
||
tmxr_msg (mux_ldsc[ln].conn, "\r\nLine hangup\r\n");
|
||
tmxr_reset_ln (&mux_ldsc[ln]); /* reset line */
|
||
muxc_lia[ln] = 0; } /* dataset off */
|
||
} /* end update */
|
||
break;
|
||
case ioLIX: /* load */
|
||
dat = 0;
|
||
case ioMIX: /* merge */
|
||
t = LIC_MBO | PUT_CCH (muxc_chan) | /* mbo, chan num */
|
||
LIC_TSTI (muxc_chan) | /* I2, I1 */
|
||
(muxc_ota[muxc_chan] & (OTC_ES2 | OTC_ES1)) | /* ES2, ES1 */
|
||
(muxc_lia[muxc_chan] & (LIC_S2 | LIC_S1)); /* S2, S1 */
|
||
dat = dat | t; /* return status */
|
||
muxc_chan = (muxc_chan + 1) & LIC_M_CHAN; /* incr channel */
|
||
break;
|
||
case ioCTL: /* ctrl clear/set */
|
||
if (IR & I_CTL) { clrCTL (dev); } /* CLC */
|
||
else { setCTL (dev); } /* STC */
|
||
break;
|
||
default:
|
||
break; }
|
||
if (IR & I_HC) { /* H/C option */
|
||
clrFLG (dev); /* clear flag */
|
||
mux_ctrl_int (); } /* look for new int */
|
||
return dat;
|
||
}
|
||
|
||
/* Unit service - receive side
|
||
|
||
Poll for new connections
|
||
Poll all active lines for input
|
||
*/
|
||
|
||
t_stat muxi_svc (UNIT *uptr)
|
||
{
|
||
int32 ln, c, t;
|
||
|
||
if ((uptr->flags & UNIT_ATT) == 0) return SCPE_OK; /* attached? */
|
||
t = sim_rtcn_calb (mux_tps, TMR_MUX); /* calibrate */
|
||
sim_activate (uptr, t); /* continue poll */
|
||
ln = tmxr_poll_conn (&mux_desc); /* look for connect */
|
||
if (ln >= 0) { /* got one? */
|
||
if ((muxl_unit[ln].flags & UNIT_MDM) && /* modem ctrl? */
|
||
(muxc_ota[ln] & DTR)) /* DTR? */
|
||
muxc_lia[ln] = muxc_lia[ln] | CDET; /* set cdet */
|
||
muxc_lia[ln] = muxc_lia[ln] | DSR; /* set dsr */
|
||
mux_ldsc[ln].rcve = 1; } /* rcv enabled */
|
||
tmxr_poll_rx (&mux_desc); /* poll for input */
|
||
for (ln = 0; ln < MUX_LINES; ln++) { /* loop thru lines */
|
||
if (mux_ldsc[ln].conn) { /* connected? */
|
||
if (c = tmxr_getc_ln (&mux_ldsc[ln])) { /* get char */
|
||
if (c & SCPE_BREAK) { /* break? */
|
||
mux_sta[ln] = mux_sta[ln] | LIU_BRK;
|
||
mux_rbuf[ln] = 0; } /* no char */
|
||
else { /* normal */
|
||
if (mux_rchp[ln]) mux_sta[ln] = mux_sta[ln] | LIU_LOST;
|
||
if (muxl_unit[ln].flags & UNIT_UC) { /* cvt to UC? */
|
||
c = c & 0177;
|
||
if (islower (c)) c = toupper (c); }
|
||
else c = c & ((muxl_unit[ln].flags & UNIT_8B)? 0377: 0177);
|
||
if (mux_rpar[ln] & OTL_ECHO) { /* echo? */
|
||
TMLN *lp = &mux_ldsc[ln]; /* get line */
|
||
tmxr_putc_ln (lp, c); /* output char */
|
||
tmxr_poll_tx (&mux_desc); } /* poll xmt */
|
||
mux_rbuf[ln] = c; /* save char */
|
||
mux_rchp[ln] = 1; } /* char pending */
|
||
if (mux_rpar[ln] & OTL_DIAG) mux_diag (c); /* rcv diag? */
|
||
} /* end if char */
|
||
} /* end if connected */
|
||
else muxc_lia[ln] = 0; /* disconnected */
|
||
} /* end for */
|
||
if (!FLG (muxl_dib.devno)) mux_data_int (); /* scan for data int */
|
||
if (!FLG (muxc_dib.devno)) mux_ctrl_int (); /* scan modem */
|
||
return SCPE_OK;
|
||
}
|
||
|
||
/* Unit service - transmit side */
|
||
|
||
t_stat muxo_svc (UNIT *uptr)
|
||
{
|
||
int32 c, ln = uptr - muxl_unit; /* line # */
|
||
|
||
if (mux_ldsc[ln].conn) { /* connected? */
|
||
if (mux_ldsc[ln].xmte) { /* xmt enabled? */
|
||
if ((mux_xbuf[ln] & OTL_SYNC) == 0) { /* start bit 0? */
|
||
TMLN *lp = &mux_ldsc[ln]; /* get line */
|
||
c = mux_xbuf[ln]; /* get char */
|
||
if (muxl_unit[ln].flags & UNIT_UC) { /* cvt to UC? */
|
||
c = c & 0177;
|
||
if (islower (c)) c = toupper (c); }
|
||
else c = c & ((muxl_unit[ln].flags & UNIT_8B)? 0377: 0177);
|
||
if (mux_xpar[ln] & OTL_DIAG) /* xmt diag? */
|
||
mux_diag (mux_xbuf[ln]); /* before munge */
|
||
mux_xdon[ln] = 1; /* set done */
|
||
if (!(muxl_unit[ln].flags & UNIT_8B) && /* not transparent? */
|
||
(c != 0x7f) && (c != 0x13) && /* not del, ^S? */
|
||
(c != 0x11) && (c != 0x5)) /* not ^Q, ^E? */
|
||
tmxr_putc_ln (lp, c); /* output char */
|
||
tmxr_poll_tx (&mux_desc); } } /* poll xmt */
|
||
else { /* buf full */
|
||
tmxr_poll_tx (&mux_desc); /* poll xmt */
|
||
sim_activate (uptr, muxl_unit[ln].wait); /* wait */
|
||
return SCPE_OK; } }
|
||
if (!FLG (muxl_dib.devno)) mux_data_int (); /* scan for int */
|
||
return SCPE_OK;
|
||
}
|
||
|
||
/* Look for data interrupt */
|
||
|
||
void mux_data_int (void)
|
||
{
|
||
int32 i;
|
||
|
||
for (i = 0; i < MUX_LINES; i++) { /* rcv lines */
|
||
if ((mux_rpar[i] & OTL_ENB) && mux_rchp[i]) { /* enabled, char? */
|
||
muxl_ibuf = PUT_CCH (i) | mux_rbuf[i] | /* lo buf = char */
|
||
RCV_PAR (mux_rbuf[i]);
|
||
muxu_ibuf = PUT_CCH (i) | mux_sta[i]; /* hi buf = stat */
|
||
mux_rchp[i] = 0; /* clr char, stat */
|
||
mux_sta[i] = 0;
|
||
setFLG (muxl_dib.devno); /* interrupt */
|
||
return; } }
|
||
for (i = 0; i < MUX_LINES; i++) { /* xmt lines */
|
||
if ((mux_xpar[i] & OTL_ENB) && mux_xdon[i]) { /* enabled, done? */
|
||
muxu_ibuf = PUT_CCH (i) | mux_sta[i] | LIU_TR; /* hi buf = stat */
|
||
mux_xdon[i] = 0; /* clr done, stat */
|
||
mux_sta[i] = 0;
|
||
setFLG (muxl_dib.devno); /* interrupt */
|
||
return; } }
|
||
for (i = MUX_LINES; i < (MUX_LINES + MUX_ILINES); i++) { /* diag lines */
|
||
if ((mux_rpar[i] & OTL_ENB) && mux_rchp[i]) { /* enabled, char? */
|
||
muxl_ibuf = PUT_CCH (i) | mux_rbuf[i] | /* lo buf = char */
|
||
RCV_PAR (mux_rbuf[i]);
|
||
muxu_ibuf = PUT_CCH (i) | mux_sta[i] | LIU_DG; /* hi buf = stat */
|
||
mux_rchp[i] = 0; /* clr char, stat */
|
||
mux_sta[i] = 0;
|
||
setFLG (muxl_dib.devno);
|
||
return; } }
|
||
return;
|
||
}
|
||
|
||
/* Look for control interrupt */
|
||
|
||
void mux_ctrl_int (void)
|
||
{
|
||
int32 i;
|
||
|
||
if (muxc_scan == 0) return;
|
||
for (i = 0; i < MUX_LINES; i++) {
|
||
muxc_chan = (muxc_chan + 1) & LIC_M_CHAN; /* step channel */
|
||
if (LIC_TSTI (muxc_chan)) { /* status change? */
|
||
setFLG (muxc_dib.devno); /* set flag */
|
||
break; } }
|
||
return;
|
||
}
|
||
|
||
/* Set diagnostic lines for given character */
|
||
|
||
void mux_diag (int32 c)
|
||
{
|
||
int32 i;
|
||
|
||
for (i = MUX_LINES; i < (MUX_LINES + MUX_ILINES); i++) {
|
||
if (c & SCPE_BREAK) { /* break? */
|
||
mux_sta[i] = mux_sta[i] | LIU_BRK;
|
||
mux_rbuf[i] = 0; } /* no char */
|
||
else {
|
||
if (mux_rchp[i]) mux_sta[i] = mux_sta[i] | LIU_LOST;
|
||
mux_rchp[i] = 1;
|
||
mux_rbuf[i] = c; } }
|
||
return;
|
||
}
|
||
|
||
/* Reset an individual line */
|
||
|
||
void mux_reset_ln (int32 i)
|
||
{
|
||
mux_rbuf[i] = mux_xbuf[i] = 0; /* clear state */
|
||
mux_rpar[i] = mux_xpar[i] = 0;
|
||
mux_rchp[i] = mux_xdon[i] = 0;
|
||
mux_sta[i] = 0;
|
||
muxc_ota[i] = muxc_lia[i] = 0; /* clear modem */
|
||
if (mux_ldsc[i].conn) /* connected? */
|
||
muxc_lia[i] = muxc_lia[i] | DSR | /* cdet, dsr */
|
||
(muxl_unit[i].flags & UNIT_MDM? CDET: 0);
|
||
sim_cancel (&muxl_unit[i]);
|
||
return;
|
||
}
|
||
|
||
/* Reset routine */
|
||
|
||
t_stat mux_reset (DEVICE *dptr)
|
||
{
|
||
int32 i, t;
|
||
|
||
if (muxu_dev.flags & DEV_DIS) { /* enb/dis dev */
|
||
muxl_dev.flags = muxu_dev.flags | DEV_DIS;
|
||
muxc_dev.flags = muxc_dev.flags | DEV_DIS; }
|
||
else { muxl_dev.flags = muxl_dev.flags & ~DEV_DIS;
|
||
muxc_dev.flags = muxc_dev.flags & ~DEV_DIS; }
|
||
muxl_dib.cmd = muxl_dib.ctl = 0; /* init lower */
|
||
muxl_dib.flg = muxl_dib.fbf = 1;
|
||
muxu_dib.cmd = muxu_dib.ctl = 0; /* upper not */
|
||
muxu_dib.flg = muxu_dib.fbf = 0; /* implemented */
|
||
muxc_dib.cmd = muxc_dib.ctl = 0; /* init ctrl */
|
||
muxc_dib.flg = muxc_dib.fbf = 1;
|
||
muxc_chan = muxc_scan = 0; /* init modem scan */
|
||
if (muxu_unit.flags & UNIT_ATT) { /* master att? */
|
||
if (!sim_is_active (&muxu_unit)) {
|
||
t = sim_rtcn_init (muxu_unit.wait, TMR_MUX);
|
||
sim_activate (&muxu_unit, t); } } /* activate */
|
||
else sim_cancel (&muxu_unit); /* else stop */
|
||
for (i = 0; i < MUX_LINES; i++) {
|
||
mux_desc.ldsc[i] = &mux_ldsc[i];
|
||
mux_reset_ln (i); }
|
||
return SCPE_OK;
|
||
}
|
||
|
||
/* Attach master unit */
|
||
|
||
t_stat mux_attach (UNIT *uptr, char *cptr)
|
||
{
|
||
t_stat r;
|
||
int32 t;
|
||
|
||
r = tmxr_attach (&mux_desc, uptr, cptr); /* attach */
|
||
if (r != SCPE_OK) return r; /* error */
|
||
t = sim_rtcn_init (muxu_unit.wait, TMR_MUX);
|
||
sim_activate (uptr, t); /* start poll */
|
||
return SCPE_OK;
|
||
}
|
||
|
||
/* Detach master unit */
|
||
|
||
t_stat mux_detach (UNIT *uptr)
|
||
{
|
||
int32 i;
|
||
t_stat r;
|
||
|
||
r = tmxr_detach (&mux_desc, uptr); /* detach */
|
||
for (i = 0; i < MUX_LINES; i++) mux_ldsc[i].rcve = 0; /* disable rcv */
|
||
sim_cancel (uptr); /* stop poll */
|
||
return r;
|
||
}
|
||
|
||
/* Show summary processor */
|
||
|
||
t_stat mux_summ (FILE *st, UNIT *uptr, int32 val, void *desc)
|
||
{
|
||
int32 i, t;
|
||
|
||
for (i = t = 0; i < MUX_LINES; i++) t = t + (mux_ldsc[i].conn != 0);
|
||
if (t == 1) fprintf (st, "1 connection");
|
||
else fprintf (st, "%d connections", t);
|
||
return SCPE_OK;
|
||
}
|
||
|
||
/* SHOW CONN/STAT processor */
|
||
|
||
t_stat mux_show (FILE *st, UNIT *uptr, int32 val, void *desc)
|
||
{
|
||
int32 i;
|
||
|
||
for (i = 0; (i < MUX_LINES) && (mux_ldsc[i].conn == 0); i++) ;
|
||
if (i < MUX_LINES) {
|
||
for (i = 0; i < MUX_LINES; i++) {
|
||
if (mux_ldsc[i].conn) {
|
||
if (val) tmxr_fconns (st, &mux_ldsc[i], i);
|
||
else tmxr_fstats (st, &mux_ldsc[i], i); } } }
|
||
else fprintf (st, "all disconnected\n");
|
||
return SCPE_OK;
|
||
}
|
||
|