mirror of
https://github.com/simh/simh.git
synced 2026-03-14 05:57:37 +00:00
SCP: HP Only SCP and additional 3.11.2 JDB SCP Extensions
This commit is contained in:
committed by
Mark Pizzolato
parent
79f71ce384
commit
685ca317a3
@@ -45,16 +45,17 @@ HP2100 = $(HP2100D)/hp2100_baci.c $(HP2100D)/hp2100_cpu.c $(HP2100D)/hp2100_cpu_
|
||||
$(HP2100D)/hp2100_mt.c $(HP2100D)/hp2100_mux.c $(HP2100D)/hp2100_pif.c \
|
||||
$(HP2100D)/hp2100_pt.c $(HP2100D)/hp2100_sys.c $(HP2100D)/hp2100_tbg.c \
|
||||
$(HP2100D)/hp2100_tty.c
|
||||
HP2100_OPT = /DHAVE_INT64 /I$(HP2100D)
|
||||
HP2100_OPT = /D USE_VM_INIT /DHAVE_INT64 /I$(HP2100D)
|
||||
|
||||
HP3000D = $(SCPD)\HP3000
|
||||
HP3000 = $(HP3000D)/hp_disclib.c $(HP3000D)/hp_tapelib.c $(HP3000D)/hp3000_atc.c \
|
||||
$(HP3000D)/hp3000_clk.c $(HP3000D)/hp3000_cpu.c $(HP3000D)/hp3000_cpu_base.c \
|
||||
$(HP3000D)/hp3000_cpu_fp.c $(HP3000D)/hp3000_cpu_cis.c $(HP3000D)/hp3000_ds.c \
|
||||
$(HP3000D)/hp3000_cpu_fp.c $(HP3000D)/hp3000_cpu_eis.c \
|
||||
$(HP3000D)/hp3000_cpu_cis.c $(HP3000D)/hp3000_ds.c \
|
||||
$(HP3000D)/hp3000_iop.c $(HP3000D)/hp3000_lp.c $(HP3000D)/hp3000_mem.c \
|
||||
$(HP3000D)/hp3000_mpx.c $(HP3000D)/hp3000_ms.c $(HP3000D)/hp3000_scmb.c \
|
||||
$(HP3000D)/hp3000_sel.c $(HP3000D)/hp3000_sys.c
|
||||
HP3000_OPT = /I$(HP3000D)
|
||||
HP3000_OPT = /D USE_VM_INIT /I$(HP3000D)
|
||||
|
||||
|
||||
clean :
|
||||
|
||||
13
makefile
13
makefile
@@ -321,8 +321,8 @@ ifeq ($(WIN32),) #*nix Environments (&& cygwin)
|
||||
ifeq (,$(NOASYNCH))
|
||||
OS_CCDEFS += -DSIM_ASYNCH_IO
|
||||
endif
|
||||
# OS_LDFLAGS += -lpthread
|
||||
# $(info using libpthread: $(call find_lib,pthread) $(call find_include,pthread))
|
||||
OS_LDFLAGS += -lpthread
|
||||
$(info using libpthread: $(call find_lib,pthread) $(call find_include,pthread))
|
||||
endif
|
||||
endif
|
||||
ifneq (,$(call find_include,semaphore))
|
||||
@@ -534,7 +534,7 @@ endif
|
||||
|
||||
# Shut up annoying clang default warnings.
|
||||
|
||||
ifeq ($(GCC),clang)
|
||||
ifeq ($(findstring clang,$(COMPILER_NAME)),clang)
|
||||
OS_CCDEFS += -Wno-parentheses -Wno-bitwise-op-parentheses -Wno-dangling-else
|
||||
endif
|
||||
|
||||
@@ -568,16 +568,17 @@ HP2100 = ${HP2100D}/hp2100_baci.c ${HP2100D}/hp2100_cpu.c ${HP2100D}/hp2100_cpu_
|
||||
${HP2100D}/hp2100_mt.c ${HP2100D}/hp2100_mux.c ${HP2100D}/hp2100_pif.c \
|
||||
${HP2100D}/hp2100_pt.c ${HP2100D}/hp2100_sys.c ${HP2100D}/hp2100_tbg.c \
|
||||
${HP2100D}/hp2100_tty.c
|
||||
HP2100_OPT = -D HAVE_INT64 -I ${HP2100D}
|
||||
HP2100_OPT = -D USE_VM_INIT -D HAVE_INT64 -I ${HP2100D}
|
||||
|
||||
HP3000D = HP3000
|
||||
HP3000 = ${HP3000D}/hp_disclib.c ${HP3000D}/hp_tapelib.c ${HP3000D}/hp3000_atc.c \
|
||||
${HP3000D}/hp3000_clk.c ${HP3000D}/hp3000_cpu.c ${HP3000D}/hp3000_cpu_base.c \
|
||||
${HP3000D}/hp3000_cpu_fp.c ${HP3000D}/hp3000_cpu_cis.c ${HP3000D}/hp3000_ds.c \
|
||||
${HP3000D}/hp3000_cpu_fp.c ${HP3000D}/hp3000_cpu_eis.c \
|
||||
${HP3000D}/hp3000_cpu_cis.c ${HP3000D}/hp3000_ds.c \
|
||||
${HP3000D}/hp3000_iop.c ${HP3000D}/hp3000_lp.c ${HP3000D}/hp3000_mem.c \
|
||||
${HP3000D}/hp3000_mpx.c ${HP3000D}/hp3000_ms.c ${HP3000D}/hp3000_scmb.c \
|
||||
${HP3000D}/hp3000_sel.c ${HP3000D}/hp3000_sys.c
|
||||
HP3000_OPT = -I ${HP3000D}
|
||||
HP3000_OPT = -D USE_VM_INIT -I ${HP3000D}
|
||||
|
||||
|
||||
#
|
||||
|
||||
109
scp.c
109
scp.c
@@ -23,6 +23,10 @@
|
||||
used in advertising or otherwise to promote the sale, use or other dealings
|
||||
in this Software without prior written authorization from Robert M Supnik.
|
||||
|
||||
23-Oct-20 JDB Added tmxr_post_logs calls to flush and close log files
|
||||
04-Jun-20 JDB Call of "sim_vm_init" is now conditional on USE_VM_INIT
|
||||
28-May-20 RMS Flush stdout after prompting (Mark Pizzolato)
|
||||
23-Mar-20 RMS Added SET <dev|unit> APPEND command
|
||||
13-Feb-20 RMS Spelled out CONTINUE in command table (Dave Bryan)
|
||||
09-Jan-20 JDB Added "sim_vm_unit_name" extension hook
|
||||
26-Oct-19 RMS Removed commented out MTAB_VAL code
|
||||
@@ -58,7 +62,7 @@
|
||||
Modified ex_reg and dep_reg to pass VM-specific register flags
|
||||
08-May-12 RMS Fixed memory leaks in save/restore (Peter Schorn)
|
||||
20-Mar-12 MP Fixes to "SHOW <x> SHOW" commands
|
||||
06-Jan-12 JDB Fixed "SHOW DEVICE" with only one enabled unit (Dave Bryan)
|
||||
06-Jan-12 JDB Fixed "SHOW DEVICE" with only one enabled unit (Dave Bryan)
|
||||
13-Jan-11 MP Added "SHOW SHOW" and "SHOW <dev> SHOW" commands
|
||||
05-Jan-11 RMS Fixed bug in deposit stride for numeric input (John Dundas)
|
||||
23-Dec-10 RMS Clarified some help messages (Mark Pizzolato)
|
||||
@@ -220,6 +224,7 @@
|
||||
/* Macros and data structures */
|
||||
|
||||
#include "sim_defs.h"
|
||||
#include "sim_tmxr.h"
|
||||
#include <signal.h>
|
||||
#include <ctype.h>
|
||||
|
||||
@@ -278,10 +283,8 @@
|
||||
#define GET_RADIX(val,dft) \
|
||||
val = sim_get_radix (NULL, sim_switches, dft);
|
||||
|
||||
/* The per-simulator init routine is a weak global that defaults to NULL
|
||||
The other per-simulator pointers can be overrriden by the init routine */
|
||||
/* The per-simulator pointers can be overrriden by a VM init routine */
|
||||
|
||||
void (*sim_vm_init) (void);
|
||||
char* (*sim_vm_read) (char *ptr, int32 size, FILE *stream) = NULL;
|
||||
void (*sim_vm_post) (t_bool from_scp) = NULL;
|
||||
CTAB *sim_vm_cmd = NULL;
|
||||
@@ -297,6 +300,7 @@ t_bool (*sim_vm_is_subroutine_call) (t_addr **ret_addrs) = NULL;
|
||||
t_stat set_dev_radix (DEVICE *dptr, UNIT *uptr, int32 flag, char *cptr);
|
||||
t_stat set_dev_enbdis (DEVICE *dptr, UNIT *uptr, int32 flag, char *cptr);
|
||||
t_stat set_dev_debug (DEVICE *dptr, UNIT *uptr, int32 flag, char *cptr);
|
||||
t_stat set_dev_unit_append (DEVICE *dptr, UNIT *uptr, int32 flag, char *cptr);
|
||||
t_stat set_unit_enbdis (DEVICE *dptr, UNIT *uptr, int32 flag, char *cptr);
|
||||
t_stat ssh_break (FILE *st, char *cptr, int32 flg);
|
||||
t_stat show_cmd_fi (FILE *ofile, int32 flag, char *cptr);
|
||||
@@ -531,7 +535,7 @@ static CTAB cmd_table[] = {
|
||||
{ "RUN", &run_cmd, RU_RUN,
|
||||
"ru{n} {new PC} reset and start simulation\n" },
|
||||
{ "GO", &run_cmd, RU_GO,
|
||||
"go {new PC} start simulation\n" },
|
||||
"go {new PC} start simulation\n" },
|
||||
{ "STEP", &run_cmd, RU_STEP,
|
||||
"s{tep} {n} simulate n instructions\n" },
|
||||
{ "CONTINUE", &run_cmd, RU_CONT,
|
||||
@@ -574,23 +578,25 @@ static CTAB cmd_table[] = {
|
||||
"set <dev> DISABLED disable device\n"
|
||||
"set <dev> DEBUG{=arg} set device debug flags\n"
|
||||
"set <dev> NODEBUG={arg} clear device debug flags\n"
|
||||
"set <dev> APPEND set first unit's position for appending\n"
|
||||
"set <dev> arg{,arg...} set device parameters (see show modifiers)\n"
|
||||
"set <unit> ENABLED enable unit\n"
|
||||
"set <unit> DISABLED disable unit\n"
|
||||
"set <unit> APPEND set unit's position for appending\n"
|
||||
"set <unit> arg{,arg...} set unit parameters (see show modifiers)\n"
|
||||
},
|
||||
{ "SHOW", &show_cmd, 0,
|
||||
"sh{ow} br{eak} <list> show breakpoints\n"
|
||||
"sh{ow} con{figuration} show configuration\n"
|
||||
"sh{ow} cons{ole} {arg} show console options\n"
|
||||
"sh{ow} dev{ices} show devices\n"
|
||||
"sh{ow} m{odifiers} show modifiers for all devices\n"
|
||||
"sh{ow} s{how} show SHOW commands for all devices\n"
|
||||
"sh{ow} n{ames} show logical names\n"
|
||||
"sh{ow} q{ueue} show event queue\n"
|
||||
"sh{ow} dev{ices} show devices\n"
|
||||
"sh{ow} m{odifiers} show modifiers for all devices\n"
|
||||
"sh{ow} s{how} show SHOW commands for all devices\n"
|
||||
"sh{ow} n{ames} show logical names\n"
|
||||
"sh{ow} q{ueue} show event queue\n"
|
||||
"sh{ow} ti{me} show simulated time\n"
|
||||
"sh{ow} th{rottle} show simulation rate\n"
|
||||
"sh{ow} ve{rsion} show simulator version\n"
|
||||
"sh{ow} th{rottle} show simulation rate\n"
|
||||
"sh{ow} ve{rsion} show simulator version\n"
|
||||
"sh{ow} <dev> RADIX show device display radix\n"
|
||||
"sh{ow} <dev> DEBUG show device debug flags\n"
|
||||
"sh{ow} <dev> MODIFIERS show device modifiers\n"
|
||||
@@ -636,6 +642,7 @@ static C1TAB set_dev_tab[] = {
|
||||
{ "HEX", &set_dev_radix, 16 },
|
||||
{ "ENABLED", &set_dev_enbdis, 1 },
|
||||
{ "DISABLED", &set_dev_enbdis, 0 },
|
||||
{ "APPEND", &set_dev_unit_append, 0 },
|
||||
{ "DEBUG", &set_dev_debug, 1 },
|
||||
{ "NODEBUG", &set_dev_debug, 0 },
|
||||
{ NULL, NULL, 0 }
|
||||
@@ -644,6 +651,7 @@ static C1TAB set_dev_tab[] = {
|
||||
static C1TAB set_unit_tab[] = {
|
||||
{ "ENABLED", &set_unit_enbdis, 1 },
|
||||
{ "DISABLED", &set_unit_enbdis, 0 },
|
||||
{ "APPEND", &set_dev_unit_append, 0 },
|
||||
{ NULL, NULL, 0 }
|
||||
};
|
||||
|
||||
@@ -717,7 +725,7 @@ for (i = 1; i < argc; i++) { /* loop thru args */
|
||||
return 0;
|
||||
}
|
||||
if (*cbuf) /* concat args */
|
||||
strcat (cbuf, " ");
|
||||
strcat (cbuf, " ");
|
||||
strcat (cbuf, argv[i]);
|
||||
lookswitch = FALSE; /* no more switches */
|
||||
}
|
||||
@@ -726,9 +734,10 @@ sim_quiet = sim_switches & SWMASK ('Q'); /* -q means quiet */
|
||||
|
||||
sim_init_sock (); /* init socket capabilities */
|
||||
|
||||
if (sim_vm_init != NULL) /* call once only */
|
||||
(*sim_vm_init)();
|
||||
sim_finit (); /* init fio package */
|
||||
#if defined (USE_VM_INIT)
|
||||
(*sim_vm_init)(); /* call once only */
|
||||
#endif
|
||||
sim_finit(); /* init fio package */
|
||||
stop_cpu = 0;
|
||||
sim_interval = 0;
|
||||
sim_time = sim_rtime = 0;
|
||||
@@ -804,7 +813,8 @@ while (stat != SCPE_EXIT) { /* in case exit */
|
||||
(*sim_vm_post) (TRUE);
|
||||
} /* end while */
|
||||
|
||||
detach_all (0, TRUE); /* close files */
|
||||
detach_all (0, TRUE); /* close device files */
|
||||
tmxr_post_logs (TRUE); /* close all mux log files */
|
||||
sim_set_deboff (0, NULL); /* close debug */
|
||||
sim_set_logoff (0, NULL); /* close log */
|
||||
sim_set_notelnet (0, NULL); /* close Telnet */
|
||||
@@ -913,7 +923,7 @@ return SCPE_OK;
|
||||
|
||||
Note that SCPE_STEP ("Step expired") is considered a note and not an error
|
||||
and so does not abort command execution when using -E.
|
||||
|
||||
|
||||
Inputs:
|
||||
flag = caller and nesting level indicator
|
||||
fcptr = filename and optional arguments, space-separated
|
||||
@@ -1081,10 +1091,10 @@ return;
|
||||
}
|
||||
|
||||
/* ASSERT command.
|
||||
|
||||
|
||||
The ASSERT command tests the value of a device register or memory location.
|
||||
The syntax is:
|
||||
|
||||
|
||||
ASSERT {<dev>} <reg/addr>{<logical-op><value>}<conditional-op><value>
|
||||
|
||||
If <dev> is not specified, CPU is assumed. If a register is specified, the
|
||||
@@ -1352,6 +1362,25 @@ else {
|
||||
return SCPE_OK;
|
||||
}
|
||||
|
||||
/* Set unit position to end for appending */
|
||||
|
||||
t_stat set_dev_unit_append (DEVICE *dptr, UNIT *uptr, int32 flag, char *cptr)
|
||||
{
|
||||
if (cptr)
|
||||
return SCPE_ARG;
|
||||
if (uptr == NULL)
|
||||
return SCPE_NOFNC;
|
||||
if (((uptr->flags & UNIT_SEQ) == 0) || /* must be sequential, */
|
||||
((uptr->flags & UNIT_ROABLE) != 0) || /* not RO settable */
|
||||
((uptr->flags & UNIT_MUSTBUF) != 0)) /* not buffered */
|
||||
return SCPE_NOFNC;
|
||||
if ((uptr->flags & UNIT_ATT) == 0) /* must be attached */
|
||||
return SCPE_UNATT;
|
||||
if (sim_fseek (uptr->fileref, 0, SEEK_END) != 0) /* seek to end */
|
||||
return SCPE_IOERR;
|
||||
uptr->pos = (t_addr) sim_ftell (uptr->fileref); /* set at EOF */
|
||||
return SCPE_OK;
|
||||
}
|
||||
/* Set device debug enabled/disabled routine */
|
||||
|
||||
t_stat set_dev_debug (DEVICE *dptr, UNIT *uptr, int32 flag, char *cptr)
|
||||
@@ -1452,7 +1481,7 @@ while (*cptr != 0) { /* do all mods */
|
||||
*cvptr++ = 0;
|
||||
for (mptr = dptr->modifiers; mptr && (mptr->mask != 0); mptr++) {
|
||||
if (((mptr->mask & MTAB_XTD)? /* right level? */
|
||||
(mptr->mask & lvl): (MTAB_VUN & lvl)) &&
|
||||
(mptr->mask & lvl): (MTAB_VUN & lvl)) &&
|
||||
((mptr->disp && mptr->pstring && /* named disp? */
|
||||
(MATCH_CMD (gbuf, mptr->pstring) == 0)))) {
|
||||
if (cvptr && !(mptr->mask & MTAB_SHP))
|
||||
@@ -1544,7 +1573,7 @@ if (uptr->flags & UNIT_ATT) {
|
||||
}
|
||||
else if (uptr->flags & UNIT_ATTABLE)
|
||||
fprintf (st, ", not attached");
|
||||
show_all_mods (st, dptr, uptr, MTAB_VUN); /* show unit mods */
|
||||
show_all_mods (st, dptr, uptr, MTAB_VUN); /* show unit mods */
|
||||
fprintf (st, "\n");
|
||||
return SCPE_OK;
|
||||
}
|
||||
@@ -1723,7 +1752,7 @@ DEVICE *dptr;
|
||||
|
||||
if (cptr && (*cptr != 0)) /* now eol? */
|
||||
return SCPE_2MARG;
|
||||
for (i = 0; (dptr = sim_devices[i]) != NULL; i++)
|
||||
for (i = 0; (dptr = sim_devices[i]) != NULL; i++)
|
||||
show_dev_modifiers (st, dptr, NULL, flag, cptr);
|
||||
return SCPE_OK;
|
||||
}
|
||||
@@ -1777,7 +1806,7 @@ if (dptr->modifiers == NULL)
|
||||
return SCPE_OK;
|
||||
for (mptr = dptr->modifiers; mptr->mask != 0; mptr++) {
|
||||
if (mptr->pstring && ((mptr->mask & MTAB_XTD)?
|
||||
((mptr->mask & flag) && !(mptr->mask & MTAB_NMO)):
|
||||
((mptr->mask & flag) && !(mptr->mask & MTAB_NMO)):
|
||||
((MTAB_VUN & flag) && ((uptr->flags & mptr->mask) == mptr->match)))) {
|
||||
fputs (", ", st);
|
||||
show_one_mod (st, dptr, uptr, mptr, NULL, 0);
|
||||
@@ -1815,7 +1844,7 @@ DEVICE *dptr;
|
||||
|
||||
if (cptr && (*cptr != 0)) /* now eol? */
|
||||
return SCPE_2MARG;
|
||||
for (i = 0; (dptr = sim_devices[i]) != NULL; i++)
|
||||
for (i = 0; (dptr = sim_devices[i]) != NULL; i++)
|
||||
show_dev_show_commands (st, dptr, NULL, flag, cptr);
|
||||
return SCPE_OK;
|
||||
}
|
||||
@@ -1875,7 +1904,7 @@ t_stat r;
|
||||
t_addr lo, hi, max;
|
||||
int32 cnt;
|
||||
|
||||
if (sim_brk_types == 0)
|
||||
if (sim_brk_types == 0)
|
||||
return SCPE_NOFNC;
|
||||
if (dptr == NULL) /* sanity checks */
|
||||
return SCPE_IERR;
|
||||
@@ -1913,7 +1942,7 @@ while (*cptr) {
|
||||
sim_brk_showall (st, sim_switches);
|
||||
else return SCPE_ARG;
|
||||
}
|
||||
else {
|
||||
else {
|
||||
for ( ; lo <= hi; lo = lo + 1) {
|
||||
r = ssh_break_one (st, flg, lo, cnt, aptr);
|
||||
if (r != SCPE_OK)
|
||||
@@ -2541,7 +2570,7 @@ sim_ref_type = REF_NONE; /* use no references */
|
||||
READ_S (buf); /* [V2.5+] read version */
|
||||
v35 = v32 = FALSE;
|
||||
if (strcmp (buf, save_vercur) == 0) /* version 3.5? */
|
||||
v35 = v32 = TRUE;
|
||||
v35 = v32 = TRUE;
|
||||
else if (strcmp (buf, save_ver32) == 0) /* version 3.2? */
|
||||
v32 = TRUE;
|
||||
else if (strcmp (buf, save_ver30) != 0) { /* version 3.0? */
|
||||
@@ -2583,7 +2612,7 @@ for ( ;; ) { /* device loop */
|
||||
}
|
||||
READ_S (buf); /* [V3.0+] logical name */
|
||||
deassign_device (dptr); /* delete old name */
|
||||
if ((buf[0] != 0) &&
|
||||
if ((buf[0] != 0) &&
|
||||
((r = assign_device (dptr, buf)) != SCPE_OK))
|
||||
return r;
|
||||
READ_I (flg); /* [V2.10+] ctlr flags */
|
||||
@@ -2842,6 +2871,7 @@ for (i = 1; (dptr = sim_devices[i]) != NULL; i++) { /* flush attached files
|
||||
fflush (uptr->fileref);
|
||||
}
|
||||
}
|
||||
tmxr_post_logs (FALSE); /* flush all mux log files */
|
||||
#if defined (VMS)
|
||||
sim_printf ("\n");
|
||||
#endif
|
||||
@@ -2879,7 +2909,7 @@ t_stat r = 0;
|
||||
t_addr k;
|
||||
t_value pcval;
|
||||
|
||||
fputc ('\n', st); /* skip a line */
|
||||
fputc ('\n', st); /* skip a line */
|
||||
|
||||
if (v >= SCPE_BASE) /* SCP error? */
|
||||
fputs (sim_error_text (v), st); /* print it from the SCP list */
|
||||
@@ -3012,7 +3042,7 @@ for (gptr = gbuf, reason = SCPE_OK;
|
||||
tdptr = sim_dfdev; /* working dptr */
|
||||
if (strncmp (gptr, "STATE", strlen ("STATE")) == 0) {
|
||||
tptr = gptr + strlen ("STATE");
|
||||
if (*tptr && (*tptr++ != ','))
|
||||
if (*tptr && (*tptr++ != ','))
|
||||
return SCPE_ARG;
|
||||
if ((lowr = sim_dfdev->registers) == NULL)
|
||||
return SCPE_NXREG;
|
||||
@@ -3071,7 +3101,7 @@ return reason;
|
||||
exdep_addr_loop examine/deposit range of addresses
|
||||
*/
|
||||
|
||||
t_stat exdep_reg_loop (FILE *ofile, SCHTAB *schptr, int32 flag, char *cptr,
|
||||
t_stat exdep_reg_loop (FILE *ofile, SCHTAB *schptr, int32 flag, char *cptr,
|
||||
REG *lowr, REG *highr, uint32 lows, uint32 highs)
|
||||
{
|
||||
t_stat reason;
|
||||
@@ -3317,13 +3347,13 @@ if ((rptr->depth > 1) && (rptr->flags & REG_UNIT)) {
|
||||
#if defined (USE_INT64)
|
||||
if (sz <= sizeof (uint32))
|
||||
*((uint32 *) uptr) = (*((uint32 *) uptr) &
|
||||
~(((uint32) mask) << rptr->offset)) |
|
||||
~(((uint32) mask) << rptr->offset)) |
|
||||
(((uint32) val) << rptr->offset);
|
||||
else *((t_uint64 *) uptr) = (*((t_uint64 *) uptr)
|
||||
& ~(mask << rptr->offset)) | (val << rptr->offset);
|
||||
#else
|
||||
*((uint32 *) uptr) = (*((uint32 *) uptr) &
|
||||
~(((uint32) mask) << rptr->offset)) |
|
||||
~(((uint32) mask) << rptr->offset)) |
|
||||
(((uint32) val) << rptr->offset);
|
||||
#endif
|
||||
}
|
||||
@@ -3505,7 +3535,7 @@ for (i = 0, j = addr; i < count; i++, j = j + dptr->aincr) {
|
||||
else {
|
||||
if (!(uptr->flags & UNIT_ATT))
|
||||
return SCPE_UNATT;
|
||||
if (uptr->flags & UNIT_RAW)
|
||||
if (uptr->flags & UNIT_RAW)
|
||||
return SCPE_NOFNC;
|
||||
if ((uptr->flags & UNIT_FIX) && (j >= uptr->capac))
|
||||
return SCPE_NXM;
|
||||
@@ -3513,7 +3543,7 @@ for (i = 0, j = addr; i < count; i++, j = j + dptr->aincr) {
|
||||
loc = j / dptr->aincr;
|
||||
if (uptr->flags & UNIT_BUF) {
|
||||
SZ_STORE (sz, sim_eval[i], uptr->filebuf, loc);
|
||||
if (loc >= uptr->hwmark)
|
||||
if (loc >= uptr->hwmark)
|
||||
uptr->hwmark = (uint32) loc + 1;
|
||||
}
|
||||
else {
|
||||
@@ -3636,13 +3666,16 @@ if (prompt) { /* interactive? */
|
||||
}
|
||||
else {
|
||||
printf ("%s", prompt); /* display prompt */
|
||||
fflush (stdout);
|
||||
cptr = fgets (cptr, size, stream); /* get cmd line */
|
||||
}
|
||||
}
|
||||
else cptr = fgets (cptr, size, stream); /* get cmd line */
|
||||
#else
|
||||
if (prompt) /* interactive? */
|
||||
if (prompt) { /* interactive? */
|
||||
printf ("%s", prompt); /* display prompt */
|
||||
fflush (stdout);
|
||||
}
|
||||
cptr = fgets (cptr, size, stream); /* get cmd line */
|
||||
#endif
|
||||
|
||||
@@ -4241,7 +4274,7 @@ while (*cptr) { /* loop through modifier
|
||||
cptr = get_glyph_nc (cptr + 1, gbuf, 0);
|
||||
sim_ofile = sim_fopen (gbuf, "a"); /* open for append */
|
||||
if (sim_ofile == NULL) { /* open failed? */
|
||||
*st = SCPE_OPENERR;
|
||||
*st = SCPE_OPENERR;
|
||||
return NULL;
|
||||
}
|
||||
sim_opt_out |= CMD_OPT_OF; /* got output file */
|
||||
|
||||
13
scp.h
13
scp.h
@@ -1,6 +1,6 @@
|
||||
/* scp.h: simulator control program headers
|
||||
|
||||
Copyright (c) 1993-2019, Robert M Supnik
|
||||
Copyright (c) 1993-2020, 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"),
|
||||
@@ -23,6 +23,7 @@
|
||||
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.
|
||||
|
||||
04-Jun-20 JDB Declaration of "sim_vm_init" is now conditional on USE_VM_INIT
|
||||
08-Dec-19 JDB Added "sim_vm_unit_name" extension hook
|
||||
09-Oct-19 JDB Added "detach_all" global declaration
|
||||
19-Jul-19 JDB Added "sim_get_radix" extension hook
|
||||
@@ -228,10 +229,14 @@ extern t_stat fprint_sym (FILE *ofile, t_addr addr, t_value *val,
|
||||
extern t_stat parse_sym (char *cptr, t_addr addr, UNIT *uptr, t_value *val,
|
||||
int32 sw);
|
||||
|
||||
/* The per-simulator init routine is a weak global that defaults to NULL
|
||||
The other per-simulator pointers can be overrriden by the init routine */
|
||||
/* The per-simulator init routine is declared (and called) only if the
|
||||
compilation defines the USE_VM_INIT symbol. The other per-simulator pointers
|
||||
can be overrriden by the init routine or by the CPU reset routine that is
|
||||
called during simulator startup, whichever is preferred. */
|
||||
|
||||
extern void (*sim_vm_init) (void);
|
||||
#if defined (USE_VM_INIT)
|
||||
extern void(*sim_vm_init) (void);
|
||||
#endif
|
||||
extern char* (*sim_vm_read) (char *ptr, int32 size, FILE *stream);
|
||||
extern void (*sim_vm_post) (t_bool from_scp);
|
||||
extern CTAB *sim_vm_cmd;
|
||||
|
||||
10
sim_defs.h
10
sim_defs.h
@@ -116,6 +116,9 @@
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#if defined(_MSC_VER) && (_MSC_VER < 1900)
|
||||
#define snprintf _snprintf /* poor man's snprintf which will work most of the time but has different return value */
|
||||
#endif
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
@@ -542,6 +545,9 @@ struct sim_debtab {
|
||||
#define FLDATA(nm,loc,pos) #nm, &(loc), 2, 1, (pos), 1
|
||||
#define GRDATA(nm,loc,rdx,wd,pos) #nm, &(loc), (rdx), (wd), (pos), 1
|
||||
#define BRDATA(nm,loc,rdx,wd,dep) #nm, (loc), (rdx), (wd), 0, (dep)
|
||||
#define VBRDATA(nm,loc,rdx,wd,dep) #nm, (loc), (rdx), (wd), 0, (dep)
|
||||
#define SAVEDATA(nm,loc) \
|
||||
#nm, &(loc), 8, 8, 0, sizeof(loc), REG_HRO
|
||||
#define URDATA(nm,loc,rdx,wd,off,dep,fl) \
|
||||
#nm, &(loc), (rdx), (wd), (off), (dep), ((fl) | REG_UNIT)
|
||||
#else
|
||||
@@ -551,6 +557,9 @@ struct sim_debtab {
|
||||
#define FLDATA(nm,loc,pos) "nm", &(loc), 2, 1, (pos), 1
|
||||
#define GRDATA(nm,loc,rdx,wd,pos) "nm", &(loc), (rdx), (wd), (pos), 1
|
||||
#define BRDATA(nm,loc,rdx,wd,dep) "nm", (loc), (rdx), (wd), 0, (dep)
|
||||
#define VBRDATA(nm,loc,rdx,wd,dep) "nm", (loc), (rdx), (wd), 0, (dep)
|
||||
#define SAVEDATA(nm,loc) \
|
||||
"nm", &(loc), 8, 8, 0, sizeof(loc), REG_HRO
|
||||
#define URDATA(nm,loc,rdx,wd,off,dep,fl) \
|
||||
"nm", &(loc), (rdx), (wd), (off), (dep), ((fl) | REG_UNIT)
|
||||
#endif
|
||||
@@ -585,7 +594,6 @@ typedef struct sim_debtab DEBTAB;
|
||||
when compiling for SIMH 3.x.
|
||||
*/
|
||||
|
||||
|
||||
#if defined (__STDC__) || defined (_WIN32)
|
||||
#define ORDATAD(nm,loc,wd,desc) #nm, &(loc), 8, (wd), 0, 1
|
||||
#define DRDATAD(nm,loc,wd,desc) #nm, &(loc), 10, (wd), 0, 1
|
||||
|
||||
110
sim_extension.c
110
sim_extension.c
@@ -23,6 +23,11 @@
|
||||
used in advertising or otherwise to promote the sale, use or other dealings
|
||||
in this Software without prior written authorization from the author.
|
||||
|
||||
21-Oct-20 JDB A NULL poll pointer is now valid for MUX attach and detach
|
||||
20-Oct-20 JDB Added FLUSH command to post file contents to disc
|
||||
25-Aug-20 JDB Call of "vm_sim_vm_init" is now conditional on USE_VM_INIT
|
||||
03-Aug-20 JDB IF now retains remainder of breakpoint command list
|
||||
06-Jul-20 JDB Silence spurious compiler warning in "ex_if_cmd"
|
||||
14-Feb-20 JDB First release version
|
||||
18-Mar-19 JDB Created
|
||||
|
||||
@@ -274,14 +279,11 @@ static void ex_initialize (void);
|
||||
void (*sim_vm_init) (void) = ex_initialize; /* use our one-time initializer */
|
||||
|
||||
|
||||
/* Hooks provided by us for the back end virtual machine */
|
||||
/* Hooks provided by us for use by the back end virtual machine */
|
||||
|
||||
CTAB *vm_sim_vm_cmd = NULL;
|
||||
|
||||
void (*vm_sim_vm_init) (void);
|
||||
|
||||
UNIT *vm_console_input_unit; /* console input unit pointer */
|
||||
UNIT *vm_console_output_unit; /* console output unit pointer */
|
||||
CTAB *vm_sim_vm_cmd = NULL; /* VM command extension table */
|
||||
UNIT *vm_console_input_unit = NULL; /* console input unit pointer */
|
||||
UNIT *vm_console_output_unit = NULL; /* console output unit pointer */
|
||||
|
||||
|
||||
/* Pointer to the VM handler for unit names */
|
||||
@@ -519,6 +521,7 @@ static t_stat ex_run_cmd (int32 flag, char *cptr);
|
||||
static t_stat ex_do_cmd (int32 flag, char *cptr);
|
||||
static t_stat ex_if_cmd (int32 flag, char *cptr);
|
||||
static t_stat ex_delete_cmd (int32 flag, char *cptr);
|
||||
static t_stat ex_flush_cmd (int32 flag, char *cptr);
|
||||
static t_stat ex_restricted_cmd (int32 flag, char *cptr);
|
||||
static t_stat ex_set_cmd (int32 flag, char *cptr);
|
||||
static t_stat ex_show_cmd (int32 flag, char *cptr);
|
||||
@@ -605,6 +608,7 @@ static CTAB ex_cmds [] = {
|
||||
|
||||
{ "IF", ex_if_cmd, 0, "if <cond> <cmd>;... execute commands if condition TRUE\n" },
|
||||
{ "DELETE", ex_delete_cmd, 0, "del{ete} <file> delete a file\n" },
|
||||
{ "FLUSH", ex_flush_cmd, 0, "f{lush} flush all open files to disc\n" },
|
||||
|
||||
{ "GOTO", ex_restricted_cmd, EX_GOTO, "goto <label> transfer control to the labeled line\n" },
|
||||
{ "CALL", ex_restricted_cmd, EX_CALL, "call <label> {<par>...} call the labeled subroutine\n" },
|
||||
@@ -739,8 +743,10 @@ sim_vm_cmd = ex_cmds; /* set up the extension
|
||||
sub_args = ex_substitute_args; /* and argument substituter */
|
||||
sim_get_radix = ex_get_radix; /* and EX/DEP/SET radix configuration */
|
||||
|
||||
#if defined (USE_VM_INIT)
|
||||
if (vm_sim_vm_init != NULL) /* if the VM has a one-time initializer */
|
||||
vm_sim_vm_init (); /* then call it now */
|
||||
#endif
|
||||
|
||||
vm_unit_name_handler = sim_vm_unit_name; /* save the unit name hook in case the VM set it */
|
||||
sim_vm_unit_name = breakpoint_name; /* and substitute our own */
|
||||
@@ -955,7 +961,8 @@ return;
|
||||
If a device is referenced, the poll unit specified by the "pptr" parameter is
|
||||
attached instead of the referenced unit. This is because a device reference
|
||||
passes a pointer to unit 0 (i.e., ATTACH MUX and ATTACH MUX0 both set "uptr"
|
||||
to point at unit 0).
|
||||
to point at unit 0). If the poll unit is not defined, then the device attach
|
||||
is rejected.
|
||||
|
||||
An attempt to attach the poll unit directly via a unit reference will be
|
||||
rejected by the "ex_tmxr_attach_line" routine because the unit does not
|
||||
@@ -967,9 +974,12 @@ t_stat ex_tmxr_attach_unit (TMXR *mp, UNIT *pptr, UNIT *uptr, char *cptr)
|
||||
t_stat status;
|
||||
|
||||
if (sim_ref_type == REF_DEVICE) /* if this is a device reference */
|
||||
uptr = pptr; /* then substitute the poll unit */
|
||||
if (pptr == NULL) /* then if the poll unit is not defined */
|
||||
return SCPE_NOATT; /* then report that the attach failed */
|
||||
else /* otherwise */
|
||||
uptr = pptr; /* substitute the poll unit */
|
||||
|
||||
if (mp == NULL || pptr == NULL || uptr == NULL) /* if the descriptor, poll, or unit pointer is null */
|
||||
if (mp == NULL || uptr == NULL) /* if the descriptor or unit pointer is null */
|
||||
status = SCPE_IERR; /* then report an internal error */
|
||||
|
||||
else if (sim_ref_type != REF_UNIT /* otherwise if this is a device or null reference */
|
||||
@@ -1000,7 +1010,8 @@ return status; /* return the status of
|
||||
If a device is referenced, the poll unit specified by the "pptr" parameter is
|
||||
detached instead of the referenced unit. This is because a device reference
|
||||
passes a pointer to unit 0 (i.e., DETACH MUX and DETACH MUX0 both set "uptr"
|
||||
to point at unit 0).
|
||||
to point at unit 0). If the poll unit is not defined, then the device detach
|
||||
is rejected.
|
||||
|
||||
An attempt to detach the poll unit directly via a unit reference will be
|
||||
rejected by the "ex_tmxr_detach_line" routine because the unit does not
|
||||
@@ -1012,9 +1023,12 @@ t_stat ex_tmxr_detach_unit (TMXR *mp, UNIT *pptr, UNIT *uptr)
|
||||
t_stat status;
|
||||
|
||||
if (sim_ref_type == REF_DEVICE) /* if this is a device reference */
|
||||
uptr = pptr; /* then substitute the poll unit */
|
||||
if (pptr == NULL) /* then if the poll unit is not defined */
|
||||
return SCPE_NOATT; /* then report that the attach failed */
|
||||
else /* otherwise */
|
||||
uptr = pptr; /* substitute the poll unit */
|
||||
|
||||
if (mp == NULL || pptr == NULL || uptr == NULL) /* if the descriptor, poll, or unit pointer is null */
|
||||
if (mp == NULL || uptr == NULL) /* if the descriptor or unit pointer is null */
|
||||
status = SCPE_IERR; /* then report an internal error */
|
||||
|
||||
else if (sim_ref_type != REF_UNIT /* otherwise if this is a device or null reference */
|
||||
@@ -1324,6 +1338,7 @@ return TRUE; /* the mux is free, as t
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Hooked terminal multiplexer replacement extension routines */
|
||||
|
||||
|
||||
@@ -2762,6 +2777,7 @@ static const char allowed_cmds [] = " " /* the list of u
|
||||
"DO " "ECHO " "ASSERT " "HELP "
|
||||
|
||||
"REPLY " "NOREPLY " "IF " "DELETE " "ABORT " /* extended commands */
|
||||
"FLUSH "
|
||||
|
||||
"POWER "; /* simulator-specific commands */
|
||||
|
||||
@@ -2819,6 +2835,7 @@ return status; /* return the search res
|
||||
CALL -- call the labeled subroutine
|
||||
RETURN -- return control from a subroutine
|
||||
ABORT -- abort nested command files
|
||||
FLUSH -- flush all buffered files
|
||||
|
||||
The RUN and GO commands are enhanced to add an UNTIL option that sets a
|
||||
temporary breakpoint, and all of the simulated execution commands are
|
||||
@@ -3521,6 +3538,17 @@ return status; /* return the command st
|
||||
results if the buffers overlap ("cptr" points into the command buffer, so
|
||||
"sim_brk_act" would be copying a command within the buffer to the start
|
||||
of the same buffer).
|
||||
|
||||
2. An IF command may appear as an action within a breakpoint command or
|
||||
another IF command. To support this, any actions of a true IF command
|
||||
are prefixed to any remaining breakpoint or IF actions by concatenating
|
||||
the two sets of actions in a temporary buffer. Were this not done, the
|
||||
remaining actions would be lost when "sim_brk_act" is pointed at the new
|
||||
IF actions.
|
||||
|
||||
3. Any unexecuted actions must be copied to a separate buffer before
|
||||
prefixing, as they will reside in the same buffer that will hold the
|
||||
prefix if they are the result of a prior IF command.
|
||||
*/
|
||||
|
||||
typedef enum { /* test operators */
|
||||
@@ -3539,8 +3567,9 @@ static t_stat ex_if_cmd (int32 flag, char *cptr)
|
||||
{
|
||||
static char tempbuf [CBUFSIZE];
|
||||
struct stat statbuf;
|
||||
int result, condition;
|
||||
char abuf [CBUFSIZE], bbuf [CBUFSIZE];
|
||||
int result, condition = 0; /* silence spurious gcc-9.2.0 compiler warning */
|
||||
char abuf [CBUFSIZE], bbuf [CBUFSIZE], *tptr;
|
||||
int32 bufsize;
|
||||
t_bool upshift, invert;
|
||||
TEST_OP test;
|
||||
LOGICAL_OP logical = Assign;
|
||||
@@ -3675,7 +3704,26 @@ do { /* loop until all condit
|
||||
while (not_done); /* continue to process logical comparisons until done */
|
||||
|
||||
if (condition) /* if the comparison is true */
|
||||
sim_brk_act = strcpy (tempbuf, cptr); /* then copy the action string and execute the commands */
|
||||
if (sim_brk_act == NULL) /* then if no unexecuted actions remain */
|
||||
sim_brk_act = strcpy (tempbuf, cptr); /* then copy our action string to a buffer */
|
||||
|
||||
else { /* otherwise */
|
||||
strcpy (abuf, sim_brk_act); /* save the unexecuted actions in a separate buffer */
|
||||
|
||||
tptr = tempbuf; /* point at the action buffer */
|
||||
bufsize = CBUFSIZE; /* and initialize the remaining size */
|
||||
|
||||
copy_string (&tptr, &bufsize, cptr, 0); /* copy the current actions as a prefix */
|
||||
|
||||
if (bufsize > 1) { /* if space remains */
|
||||
*tptr++ = ';'; /* then append the action separator */
|
||||
bufsize = bufsize - 1; /* and account for the space */
|
||||
|
||||
copy_string (&tptr, &bufsize, abuf, 0); /* copy the unexecuted actions */
|
||||
}
|
||||
|
||||
sim_brk_act = tempbuf; /* point at the concatenated action list */
|
||||
}
|
||||
|
||||
return SCPE_OK; /* either way, the command succeeded */
|
||||
}
|
||||
@@ -3705,6 +3753,36 @@ else /* otherwise */
|
||||
}
|
||||
|
||||
|
||||
/* Execute the FLUSH command.
|
||||
|
||||
This command processing routine adds a new FLUSH command to flush all
|
||||
buffered files to disc. The routine processes commands of the form:
|
||||
|
||||
FLUSH
|
||||
|
||||
For files that are open, the command flushes the console and debug log files,
|
||||
the files attached to all of the units of all devices, and log files
|
||||
associated with terminal multiplexer lines.
|
||||
|
||||
The command provides a way to flush buffered file contents to disc without
|
||||
having to stop and restart simulated execution. As such, it is useful when
|
||||
the console is in concurrent mode. In nonconcurrent mode, stopping the
|
||||
simulator to enter the FLUSH command will automatically flush all open files,
|
||||
so the command is redundant in that case.
|
||||
*/
|
||||
|
||||
static t_stat ex_flush_cmd (int32 flag, char *cptr)
|
||||
{
|
||||
if (*cptr != '\0') /* if something follows */
|
||||
return SCPE_2MARG; /* then report extraneous characters */
|
||||
|
||||
else { /* otherwise */
|
||||
fflush (NULL); /* flush all open files */
|
||||
return SCPE_OK;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Execute a restricted command.
|
||||
|
||||
This command processing routine is called when the user attempts to execute
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
used in advertising or otherwise to promote the sale, use or other dealings
|
||||
in this Software without prior written authorization from the author.
|
||||
|
||||
25-Aug-20 JDB Declaration of "vm_sim_vm_init" is now conditional on USE_VM_INIT
|
||||
31-Dec-19 JDB First release version
|
||||
18-Mar-19 JDB Created file
|
||||
*/
|
||||
@@ -91,19 +92,27 @@ t_stat ex_sim_putchar_s (int32 c);
|
||||
t_stat ex_sim_poll_kbd (void);
|
||||
uint32 ex_sim_brk_test (t_addr location, uint32 type);
|
||||
|
||||
t_stat ex_tmxr_attach_unit (TMXR *mp, UNIT *pptr, UNIT *uptr, char *cptr);
|
||||
t_stat ex_tmxr_detach_unit (TMXR *mp, UNIT *pptr, UNIT *uptr);
|
||||
t_stat ex_tmxr_detach_line (TMXR *mp, UNIT *uptr);
|
||||
t_stat ex_tmxr_control_line (TMLN *lp, TMCKT control);
|
||||
TMCKT ex_tmxr_line_status (TMLN *lp);
|
||||
int32 ex_tmxr_poll_conn (TMXR *mp);
|
||||
t_bool ex_tmxr_line_free (TMLN *lp);
|
||||
t_bool ex_tmxr_mux_free (TMXR *mp);
|
||||
t_stat ex_tmxr_attach_unit (TMXR *mp, UNIT *pptr, UNIT *uptr, char *cptr);
|
||||
t_stat ex_tmxr_detach_unit (TMXR *mp, UNIT *pptr, UNIT *uptr);
|
||||
t_stat ex_tmxr_detach_line (TMXR *mp, UNIT *uptr);
|
||||
t_stat ex_tmxr_control_line (TMLN *lp, TMCKT control);
|
||||
TMCKT ex_tmxr_line_status (TMLN *lp);
|
||||
int32 ex_tmxr_poll_conn (TMXR *mp);
|
||||
t_bool ex_tmxr_line_free (TMLN *lp);
|
||||
t_bool ex_tmxr_mux_free (TMXR *mp);
|
||||
|
||||
|
||||
extern void (*vm_sim_vm_init) (void);
|
||||
extern CTAB *vm_sim_vm_cmd;
|
||||
extern t_stat vm_sim_instr (void);
|
||||
/* The per-simulator init routine is declared (and called) only if the
|
||||
compilation defines the USE_VM_INIT symbol. The other per-simulator pointers
|
||||
can be overrriden by the init routine or by the CPU reset routine that is
|
||||
called during simulator startup, whichever is preferred.
|
||||
*/
|
||||
|
||||
extern UNIT *vm_console_input_unit; /* console input unit pointer */
|
||||
extern UNIT *vm_console_output_unit; /* console output unit pointer */
|
||||
#if defined (USE_VM_INIT)
|
||||
extern void (*vm_sim_vm_init) (void);
|
||||
#endif
|
||||
|
||||
extern t_stat vm_sim_instr (void);
|
||||
extern CTAB *vm_sim_vm_cmd; /* VM-specific command table pointer */
|
||||
extern UNIT *vm_console_input_unit; /* console input unit pointer */
|
||||
extern UNIT *vm_console_output_unit; /* console output unit pointer */
|
||||
|
||||
70
sim_rev.h
70
sim_rev.h
@@ -29,7 +29,7 @@
|
||||
|
||||
#define SIM_MAJOR 3
|
||||
#define SIM_MINOR 11
|
||||
#define SIM_PATCH 0
|
||||
#define SIM_PATCH 2
|
||||
#define SIM_DELTA 0
|
||||
|
||||
/* V3.11 revision history
|
||||
@@ -37,14 +37,82 @@
|
||||
V3.11 incorporates SCP additions and extensions by Dave Bryan to support his
|
||||
HP simulators.
|
||||
|
||||
patch date module(s) and fix(es)
|
||||
|
||||
2 tbd scp.h
|
||||
- changed sim_vm_init to build time option (Dave Bryan)
|
||||
|
||||
scp.c
|
||||
- changed sim_vm_init to build time option (Dave Bryan)
|
||||
- flush stdout after prompt (Mark Pizzolato)
|
||||
|
||||
pdp10_tu.c
|
||||
- fixed bad macro (Mark Pizzolata)
|
||||
|
||||
pdp11_cpumod.c
|
||||
- fixed KDJ11E programmable rate select (Paul Koning)
|
||||
|
||||
pdp11_stddev.c
|
||||
- added KSR option for TTI/TTO
|
||||
|
||||
pdp18b_dr15.c
|
||||
- zero out shared section on initial allocate (Dave Bryan)
|
||||
|
||||
s3_sys.c
|
||||
- fixed bldaddr length (Mark Pizzolatto)
|
||||
|
||||
vax_cpu.c
|
||||
- added idle test for VMS 5.0/5.1 (Mark Pizzolato)
|
||||
|
||||
1 31-Mar-2020 scp.c and sim_tmxr_c
|
||||
- new extensions to support HP simulators
|
||||
- added SET <dev|unit> APPEND command
|
||||
|
||||
sim_ether library
|
||||
- imported latest V4 revision
|
||||
|
||||
Alpha
|
||||
- fixed DMAPEN register definition
|
||||
|
||||
Interdata
|
||||
- fixed DP xTIME register definitions
|
||||
|
||||
NOVA
|
||||
- fixed processing of tape UNLOAD
|
||||
|
||||
PDP-1
|
||||
- generalized PTR ASCII mode handling of end-of-line and end-of-tape
|
||||
|
||||
PDP-10
|
||||
- fixed processing of tape UNLOAD
|
||||
|
||||
PDP-11
|
||||
- fixed PT INT definition
|
||||
- disabled VH11 (temporarily) because of multiline race condition
|
||||
- fixed processing of tape UNLOAD in TM, TU
|
||||
|
||||
PDP-8
|
||||
- fixed processing of tape UNLOAD
|
||||
|
||||
Sigma
|
||||
- fixed incorrect 550 interrupt register array declaration
|
||||
- fixed processing of tape UNLOAD
|
||||
|
||||
VAX
|
||||
- disabled VH11 (temporarily) because of multiline race condition
|
||||
|
||||
patch date module(s) and fix(es)
|
||||
|
||||
0 01-Dec-2019 scp.c and supporting libraries
|
||||
- new features and extensions to support the HP simulators
|
||||
- lengthened CONT to CONTNIUE for V4.x compatibility
|
||||
|
||||
sim_sock.c
|
||||
- latest bug fixes from V4.x
|
||||
|
||||
PDP-11
|
||||
- fixed race condition in DZ11 (Mark Pizzolato)
|
||||
|
||||
VAX
|
||||
- added hook for unpredictable indexed immediate in .aw flows
|
||||
- revamped Qbus memory simulation to behave as a Qbus peripheral
|
||||
|
||||
20
sim_shmem.c
20
sim_shmem.c
@@ -1,6 +1,6 @@
|
||||
/* sim_shmem.c: simulator shared memory library
|
||||
|
||||
Copyright (c) 2015-2016, Robert M Supnik
|
||||
Copyright (c) 2015-2020, 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"),
|
||||
@@ -23,6 +23,9 @@
|
||||
used in advertising or otherwise to promote the sale, use or other dealings
|
||||
in this Software without prior written authorization from Robert M Supnik.
|
||||
|
||||
25-Aug-20 JDB Added __FreeBSD__ define to Unix implementation guard
|
||||
01-Jul-20 JDB Added __CYGWIN__ define to Unix implementation guard
|
||||
|
||||
This library includes:
|
||||
|
||||
sim_shmem_open create or attach to a shared memory region
|
||||
@@ -119,7 +122,7 @@ t_bool sim_shmem_atomic_cas (int32 *ptr, int32 oldv, int32 newv)
|
||||
return (InterlockedCompareExchange ((LONG volatile *) ptr, newv, oldv) == oldv);
|
||||
}
|
||||
|
||||
#elif defined (__linux__) || defined (__APPLE__)
|
||||
#elif defined (__linux__) || defined (__APPLE__) || defined (__CYGWIN__) || defined (__FreeBSD__)
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
@@ -134,7 +137,7 @@ struct SHMEM {
|
||||
|
||||
t_stat sim_shmem_open (const char *name, size_t size, SHMEM **shmem, void **addr)
|
||||
{
|
||||
#ifdef HAVE_SHM_OPEN
|
||||
#if defined (HAVE_SHM_OPEN) && defined (__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)
|
||||
*shmem = (SHMEM *)calloc (1, sizeof(**shmem));
|
||||
mode_t orig_mask;
|
||||
|
||||
@@ -191,25 +194,30 @@ if ((*shmem)->shm_base == MAP_FAILED) {
|
||||
*addr = (*shmem)->shm_base;
|
||||
return SCPE_OK;
|
||||
#else
|
||||
*shmem = NULL;
|
||||
return SCPE_NOFNC;
|
||||
#endif
|
||||
}
|
||||
|
||||
void sim_shmem_close (SHMEM *shmem)
|
||||
{
|
||||
#if defined (HAVE_SHM_OPEN)
|
||||
if (shmem == NULL)
|
||||
return;
|
||||
if (shmem->shm_base != MAP_FAILED)
|
||||
munmap (shmem->shm_base, shmem->shm_size);
|
||||
if (shmem->shm_fd != -1)
|
||||
if (shmem->shm_fd != -1) {
|
||||
shm_unlink (shmem->shm_name);
|
||||
close (shmem->shm_fd);
|
||||
}
|
||||
free (shmem->shm_name);
|
||||
free (shmem);
|
||||
#endif
|
||||
}
|
||||
|
||||
int32 sim_shmem_atomic_add (int32 *p, int32 v)
|
||||
{
|
||||
#if defined (HAVE_GCC_SYNC_BUILTINS)
|
||||
#if defined (__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)
|
||||
return __sync_add_and_fetch((int *) p, v);
|
||||
#else
|
||||
return *p + v;
|
||||
@@ -218,7 +226,7 @@ return *p + v;
|
||||
|
||||
t_bool sim_shmem_atomic_cas (int32 *ptr, int32 oldv, int32 newv)
|
||||
{
|
||||
#if defined (HAVE_GCC_SYNC_BUILTINS)
|
||||
#if defined (__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)
|
||||
return __sync_bool_compare_and_swap (ptr, oldv, newv);
|
||||
#else
|
||||
if (*ptr == oldv) {
|
||||
|
||||
31
sim_sock.c
31
sim_sock.c
@@ -1,6 +1,6 @@
|
||||
/* sim_sock.c: OS-dependent socket routines
|
||||
|
||||
Copyright (c) 2001-2019, Robert M Supnik
|
||||
Copyright (c) 2001-2010, 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"),
|
||||
@@ -23,7 +23,6 @@
|
||||
used in advertising or otherwise to promote the sale, use or other dealings
|
||||
in this Software without prior written authorization from Robert M Supnik.
|
||||
|
||||
22-Nov-19 MP Latest 4.X changes
|
||||
15-Oct-12 MP Added definitions needed to detect possible tcp
|
||||
connect failures
|
||||
25-Sep-12 MP Reworked for RFC3493 interfaces supporting IPv6 and IPv4
|
||||
@@ -263,6 +262,7 @@ if (service) {
|
||||
char *c;
|
||||
|
||||
port = strtoul(service, &c, 10);
|
||||
port = htons((unsigned short)port);
|
||||
if ((port == 0) || (*c != '\0')) {
|
||||
switch (hints->ai_socktype)
|
||||
{
|
||||
@@ -432,6 +432,10 @@ return 0;
|
||||
#if !defined(IPV6_V6ONLY) /* Older XP environments may not define IPV6_V6ONLY */
|
||||
#define IPV6_V6ONLY 27 /* Treat wildcard bind as AF_INET6-only. */
|
||||
#endif
|
||||
#if defined(TEST_INFO_STUBS)
|
||||
#undef IPV6_V6ONLY
|
||||
#undef AF_INET6
|
||||
#endif
|
||||
/* Dynamic DLL load variables */
|
||||
#ifdef _WIN32
|
||||
static HINSTANCE hLib = 0; /* handle to DLL */
|
||||
@@ -684,7 +688,7 @@ return 0;
|
||||
port = pointer to buffer for IP port (may be NULL), 0 = none
|
||||
localport
|
||||
= pointer to buffer for local IP port (may be NULL), 0 = none
|
||||
result = status (SCPE_OK on complete success or SCPE_ARG if
|
||||
result = status (0 on complete success or -1 if
|
||||
parsing can't happen due to bad syntax, a value is
|
||||
out of range, a result can't fit into a result buffer,
|
||||
a service name doesn't exist, or a validation name
|
||||
@@ -739,6 +743,12 @@ load_ws2 ();
|
||||
#if defined (SIGPIPE)
|
||||
signal (SIGPIPE, SIG_IGN); /* no pipe signals */
|
||||
#endif
|
||||
#if defined(TEST_INFO_STUBS)
|
||||
/* force use of stubs */
|
||||
p_getaddrinfo = (getaddrinfo_func)s_getaddrinfo;
|
||||
p_getnameinfo = (getnameinfo_func)s_getnameinfo;
|
||||
p_freeaddrinfo = (freeaddrinfo_func)s_freeaddrinfo;
|
||||
#endif
|
||||
}
|
||||
|
||||
void sim_cleanup_sock (void)
|
||||
@@ -918,7 +928,7 @@ if (sta == SOCKET_ERROR) /* bind error? */
|
||||
if (!(opt_flags & SIM_SOCK_OPT_BLOCKING)) {
|
||||
sta = sim_setnonblock (newsock); /* set nonblocking */
|
||||
if (sta == SOCKET_ERROR) /* fcntl error? */
|
||||
return sim_err_sock (newsock, "fcntl");
|
||||
return sim_err_sock (newsock, "setnonblock");
|
||||
}
|
||||
sta = listen (newsock, 1); /* listen on socket */
|
||||
if (sta == SOCKET_ERROR) /* listen error? */
|
||||
@@ -990,7 +1000,7 @@ if (!(opt_flags & SIM_SOCK_OPT_BLOCKING)) {
|
||||
sta = sim_setnonblock (newsock); /* set nonblocking */
|
||||
if (sta == SOCKET_ERROR) { /* fcntl error? */
|
||||
p_freeaddrinfo (result);
|
||||
return sim_err_sock (newsock, "fcntl");
|
||||
return sim_err_sock (newsock, "setnonblock");
|
||||
}
|
||||
}
|
||||
if ((!(opt_flags & SIM_SOCK_OPT_DATAGRAM)) && (opt_flags & SIM_SOCK_OPT_NODELAY)) {
|
||||
@@ -1064,20 +1074,16 @@ if (newsock == INVALID_SOCKET) { /* error? */
|
||||
}
|
||||
if (connectaddr != NULL) {
|
||||
*connectaddr = (char *)calloc(1, NI_MAXHOST+1);
|
||||
#ifdef AF_INET6
|
||||
p_getnameinfo((struct sockaddr *)&clientname, size, *connectaddr, NI_MAXHOST, NULL, 0, NI_NUMERICHOST);
|
||||
if (0 == memcmp("::ffff:", *connectaddr, 7)) /* is this a IPv4-mapped IPv6 address? */
|
||||
memmove(*connectaddr, 7+*connectaddr, /* prefer bare IPv4 address */
|
||||
strlen(*connectaddr) - 7 + 1); /* length to include terminating \0 */
|
||||
#else
|
||||
strcpy(*connectaddr, inet_ntoa(((struct sockaddr_in *)&connectaddr)->s_addr));
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!(opt_flags & SIM_SOCK_OPT_BLOCKING)) {
|
||||
sta = sim_setnonblock (newsock); /* set nonblocking */
|
||||
if (sta == SOCKET_ERROR) /* fcntl error? */
|
||||
return sim_err_sock (newsock, "fcntl");
|
||||
return sim_err_sock (newsock, "setnonblock");
|
||||
}
|
||||
|
||||
if ((opt_flags & SIM_SOCK_OPT_NODELAY)) {
|
||||
@@ -1152,7 +1158,6 @@ size_t size = addrsize;
|
||||
#endif
|
||||
int ret = 0;
|
||||
|
||||
#ifdef AF_INET6
|
||||
*hostnamebuf = '\0';
|
||||
*portnamebuf = '\0';
|
||||
ret = p_getnameinfo(addr, size, hostnamebuf, NI_MAXHOST, NULL, 0, NI_NUMERICHOST);
|
||||
@@ -1161,10 +1166,6 @@ if (0 == memcmp("::ffff:", hostnamebuf, 7)) /* is this a IPv4-mapped IPv6
|
||||
strlen(hostnamebuf) + 7 - 1); /* length to include terminating \0 */
|
||||
if (!ret)
|
||||
ret = p_getnameinfo(addr, size, NULL, 0, portnamebuf, NI_MAXSERV, NI_NUMERICSERV);
|
||||
#else
|
||||
strcpy(hostnamebuf, inet_ntoa(((struct sockaddr_in *)addr)->s_addr));
|
||||
sprintf(portnamebuf, "%d", (int)ntohs(((struct sockaddr_in *)addr)->s_port)));
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -90,8 +90,10 @@ extern "C" {
|
||||
#endif
|
||||
#define WSAEACCES EACCES
|
||||
#define WSAEINTR EINTR
|
||||
#define INVALID_SOCKET ((SOCKET)-1)
|
||||
#define SOCKET_ERROR -1
|
||||
#define INVALID_SOCKET ((SOCKET)-1)
|
||||
#if !defined(SOCKET_ERROR)
|
||||
#define SOCKET_ERROR (-1)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined (VMS) /* VMS unique */
|
||||
@@ -118,7 +120,7 @@ int sim_parse_addr_ex (const char *cptr, char *host, size_t hostlen, const char
|
||||
SOCKET sim_master_sock_ex (const char *hostport, int *parse_status, int opt_flags);
|
||||
#define sim_master_sock(hostport, parse_status) sim_master_sock_ex(hostport, parse_status, ((sim_switches & SWMASK ('U')) ? SIM_SOCK_OPT_REUSEADDR : 0))
|
||||
SOCKET sim_connect_sock_ex (const char *sourcehostport, const char *hostport, const char *default_host, const char *default_port, int opt_flags);
|
||||
#define sim_connect_sock(hostport, default_host, default_port) sim_connect_sock_ex(NULL, hostport, default_host, default_port, 0)
|
||||
#define sim_connect_sock(hostport, default_host, default_port) sim_connect_sock_ex(NULL, hostport, default_host, default_port, SIM_SOCK_OPT_BLOCKING)
|
||||
SOCKET sim_accept_conn_ex (SOCKET master, char **connectaddr, int opt_flags);
|
||||
#define sim_accept_conn(master, connectaddr) sim_accept_conn_ex(master, connectaddr, 0)
|
||||
int sim_check_conn (SOCKET sock, int rd);
|
||||
|
||||
328
sim_tmxr.c
328
sim_tmxr.c
@@ -1,6 +1,6 @@
|
||||
/* sim_tmxr.c: Telnet terminal multiplexor library
|
||||
|
||||
Copyright (c) 2001-2019, Robert M Supnik
|
||||
Copyright (c) 2001-2020, 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"),
|
||||
@@ -26,6 +26,9 @@
|
||||
Based on the original DZ11 simulator by Thord Nilson, as updated by
|
||||
Arthur Krewat.
|
||||
|
||||
26-Oct-20 JDB Line order now supports partial connection lists
|
||||
23-Oct-20 JDB Added tmxr_table and tmxr_post_logs
|
||||
tmxr_set_log now takes -N switch for new file
|
||||
19-Dec-19 JDB Added tmxr_is_extended global hook
|
||||
19-Mar-19 JDB Added tmxr_read, tmxr_write, tmxr_show, tmxr_close
|
||||
global hooks and associated local hook routines;
|
||||
@@ -79,16 +82,25 @@
|
||||
tmxr_dep - (null) deposit
|
||||
tmxr_msg - send message to socket
|
||||
tmxr_linemsg - send message to line
|
||||
tmxr_fconns - output connection status
|
||||
tmxr_fstats - output connection statistics
|
||||
tmxr_fconns - output line connection status
|
||||
tmxr_fstats - output line connection statistics
|
||||
tmxr_set_log - open a log file for a terminal line
|
||||
tmxr_set_nolog - close a log file for a terminal line
|
||||
tmxr_post_logs - flush and optionally close all log files
|
||||
tmxr_show_log - output log file status
|
||||
tmxr_dscln - disconnect line (SET routine)
|
||||
tmxr_rqln - number of available characters for line
|
||||
tmxr_tqln - number of buffered characters for line
|
||||
tmxr_set_lnorder - set line connection order
|
||||
tmxr_show_lnorder - show line connection order
|
||||
tmxr_init_line - initialize the line data
|
||||
tmxr_report_connection - report a line connection to the port
|
||||
tmxr_disconnect_line - disconnect a line
|
||||
tmxr_show_summ - output the number of connections
|
||||
tmxr_show_cstat - output device connection status or statistics
|
||||
tmxr_show_lines - output the number of lines
|
||||
tmxr_find_ldsc - find a line descriptor
|
||||
tmxr_send_buffered_data - write the line data
|
||||
tmxr_init_line - initialize the line data
|
||||
tmxr_report_connection - report a line connection to the port
|
||||
tmxr_disconnect_line - disconnect a line
|
||||
|
||||
All routines are OS-independent.
|
||||
*/
|
||||
@@ -139,6 +151,21 @@
|
||||
#define TNS_CRPAD 005 /* CR padding */
|
||||
#define TNS_DO 006 /* DO request pending rejection */
|
||||
|
||||
/* Multiplexer-descriptor table.
|
||||
|
||||
Each device multiplexer declares a multiplexer descriptor (TMXR) structure to
|
||||
identify the mux and its terminal lines. The structure is local to the
|
||||
device simulator, and nothing in the DEVICE structure points to it, so there
|
||||
is no external way of accessing the line (TMLN) structures. Access is needed
|
||||
if the associated terminal line logs are to be flushed when a simulator stop
|
||||
occurs and closed when the simulator exits. This is provided by a global
|
||||
table of TMXR structures that is filled in when line logs are opened.
|
||||
*/
|
||||
|
||||
#define TABLE_COUNT 10 /* the number of table entries provided */
|
||||
|
||||
static TMXR *tmxr_table [TABLE_COUNT] = { NULL }; /* the table of multiplexer descriptors */
|
||||
|
||||
void tmxr_rmvrc (TMLN *lp, int32 p);
|
||||
|
||||
extern char sim_name[];
|
||||
@@ -165,15 +192,22 @@ t_bool (*tmxr_is_extended) (TMLN *lp) = NULL;
|
||||
line number activated, -1 if none
|
||||
|
||||
If a connection order is defined for the descriptor, and the first value is
|
||||
not -1 (indicating default order), then the order array is used to find an
|
||||
open line. Otherwise, a search is made of all lines in numerical sequence.
|
||||
not < 0 to indicate the default order, then the order array is used to find
|
||||
an open line. Otherwise, a search is made of all lines in numerical
|
||||
sequence.
|
||||
|
||||
If some valid lines are to be omitted from the connection order, a value < 0
|
||||
will appear after the last allowed line value. For example, specifying
|
||||
connection order values of 1, 0, 2, and -1 will allow connections to lines 1,
|
||||
0, and 2 in that order. Additional connection attempts will fail with "All
|
||||
connections busy," even though more lines are available in the device.
|
||||
*/
|
||||
|
||||
int32 tmxr_poll_conn (TMXR *mp)
|
||||
{
|
||||
SOCKET newsock;
|
||||
TMLN *lp;
|
||||
int32 *op;
|
||||
int32 *op, *fop;
|
||||
int32 i, j;
|
||||
char *ipaddr = NULL;
|
||||
|
||||
@@ -187,14 +221,20 @@ static char mantra[] = {
|
||||
|
||||
newsock = sim_accept_conn (mp->master, &ipaddr); /* poll connect */
|
||||
if (newsock != INVALID_SOCKET) { /* got a live one? */
|
||||
op = mp->lnorder; /* get line connection order list pointer */
|
||||
fop = op = mp->lnorder; /* get line connection order list pointer */
|
||||
i = mp->lines; /* play it safe in case lines == 0 */
|
||||
|
||||
for (j = 0; j < mp->lines; j++, i++) { /* find next avail line */
|
||||
if (op && (*op >= 0) && (*op < mp->lines)) /* order list present and valid? */
|
||||
i = *op++; /* get next line in list to try */
|
||||
else /* no list or not used or range error */
|
||||
i = j; /* get next sequential line */
|
||||
for (j = 0; j < mp->lines; j++, i++) { /* find the next available line */
|
||||
if (fop == NULL || *fop < 0) /* if the first list entry is undefined or defaulted */
|
||||
i = j; /* then use the next sequential line */
|
||||
|
||||
else if (*op >= 0 && *op < mp->lines) /* otherwise if the line number is legal */
|
||||
i = *op++; /* then use the next listed line */
|
||||
|
||||
else { /* otherwise the list entry is invalid */
|
||||
i = mp->lines; /* so abandon the search now */
|
||||
break; /* and report that no lines are free */
|
||||
}
|
||||
|
||||
lp = mp->ldsc + i; /* get pointer to line descriptor */
|
||||
if (lp->conn == 0) /* is the line available? */
|
||||
@@ -422,9 +462,9 @@ for (i = 0; i < mp->lines; i++) { /* loop thru lines */
|
||||
lp->tsta = TNS_SKIP; /* IAC + other */
|
||||
break;
|
||||
case TN_GA: case TN_EL: /* IAC + other 2 byte types */
|
||||
case TN_EC: case TN_AYT:
|
||||
case TN_EC: case TN_AYT:
|
||||
case TN_AO: case TN_IP:
|
||||
case TN_NOP:
|
||||
case TN_NOP:
|
||||
lp->tsta = TNS_NORM; /* ignore */
|
||||
break;
|
||||
case TN_SB: /* IAC + SB sub-opt negotiation */
|
||||
@@ -811,12 +851,28 @@ if (lp->conn) {
|
||||
return SCPE_OK;
|
||||
}
|
||||
|
||||
/* Enable logging for line */
|
||||
/* Enable logging for line.
|
||||
|
||||
This routine opens the log file whose name is specified by "cptr" for the
|
||||
multiplexer line associated with "uptr" or, if NULL, for the line number
|
||||
specified by "val". "desc" contains a pointer to the multiplexer descriptor.
|
||||
|
||||
If opening is successful, the routine then adds the descriptor pointer to the
|
||||
table of descriptors, which is used to flush and eventually close the log
|
||||
files.
|
||||
|
||||
|
||||
Implementation notes:
|
||||
|
||||
1. Table entries are not removed, so a NULL entry indicates both the end of
|
||||
the active list and the first available space.
|
||||
*/
|
||||
|
||||
t_stat tmxr_set_log (UNIT *uptr, int32 val, char *cptr, void *desc)
|
||||
{
|
||||
TMXR *mp = (TMXR *) desc;
|
||||
TMLN *lp;
|
||||
uint32 index;
|
||||
|
||||
if (cptr == NULL) /* no file name? */
|
||||
return SCPE_2FARG;
|
||||
@@ -829,12 +885,29 @@ lp->txlogname = (char *) calloc (CBUFSIZE, sizeof (char)); /* alloc namebuf */
|
||||
if (lp->txlogname == NULL) /* can't? */
|
||||
return SCPE_MEM;
|
||||
strncpy (lp->txlogname, cptr, CBUFSIZE); /* save file name */
|
||||
lp->txlog = fopen (cptr, "ab"); /* open log */
|
||||
if (sim_switches & SWMASK ('N')) /* if a new log file is requested */
|
||||
lp->txlog = fopen (cptr, "wb"); /* then open an empty file for writing */
|
||||
else /* otherwise */
|
||||
lp->txlog = fopen (cptr, "ab"); /* open an existing file for appending */
|
||||
if (lp->txlog == NULL) { /* error? */
|
||||
free (lp->txlogname); /* free buffer */
|
||||
return SCPE_OPENERR;
|
||||
}
|
||||
return SCPE_OK;
|
||||
else { /* otherwise if the open succeeded */
|
||||
for (index = 0; index < TABLE_COUNT; index++) /* loop through the table entries */
|
||||
if (tmxr_table [index] == mp) /* if the mux descriptor is already present */
|
||||
break; /* then we're done */
|
||||
|
||||
else if (tmxr_table [index] == NULL) { /* otherwise if the entry is empty */
|
||||
tmxr_table [index] = mp; /* then store the new descriptor */
|
||||
break; /* and we're done */
|
||||
}
|
||||
|
||||
if (index == TABLE_COUNT) /* if there are no empty entries */
|
||||
return SCPE_IERR; /* then report an internal error */
|
||||
else /* otherwise the descriptor was */
|
||||
return SCPE_OK; /* either already present or added */
|
||||
}
|
||||
}
|
||||
|
||||
/* Disable logging for line */
|
||||
@@ -858,6 +931,52 @@ if (lp->txlog) { /* logging? */
|
||||
return SCPE_OK;
|
||||
}
|
||||
|
||||
/* Flush and optionally close all log files.
|
||||
|
||||
This routine flushes or closes all active terminal multiplexer line logs,
|
||||
depending on the value of the boolean parameter. The routine uses the table
|
||||
of multiplexer descriptors constructed by the "tmxr_set_log" routine to
|
||||
identify the active lines. The line structure array associated with each
|
||||
descriptor is examined in sequence for active logs. Each one that is found
|
||||
is flushed to post the contents to disc and left open, or closed and marked
|
||||
inactive, as directed by the supplied parameter.
|
||||
|
||||
|
||||
Implementation notes:
|
||||
|
||||
1. The table is organized so that a NULL entry indicates that no additional
|
||||
descriptors will be found. That is, descriptors always appear at the
|
||||
beginning of the table.
|
||||
*/
|
||||
|
||||
void tmxr_post_logs (t_bool close_logs)
|
||||
{
|
||||
uint32 index;
|
||||
int32 line, line_count;
|
||||
TMXR *mptr;
|
||||
TMLN *lptr;
|
||||
|
||||
for (index = 0; index < TABLE_COUNT; index++) /* look through the descriptor list */
|
||||
if (tmxr_table [index] == NULL) /* until all entries */
|
||||
break; /* have been seen */
|
||||
|
||||
else { /* for each active entry */
|
||||
mptr = tmxr_table [index]; /* get the entry */
|
||||
lptr = mptr->ldsc; /* and the line array */
|
||||
line_count = mptr->lines; /* and the number of lines */
|
||||
|
||||
for (line = 0; line < line_count; line++, lptr++) /* for all lines in the array */
|
||||
if (lptr->txlog != NULL) /* if the current line's log is active */
|
||||
if (close_logs) /* then if closing is requested */
|
||||
tmxr_set_nolog (NULL, line, NULL, /* then close the log */
|
||||
(void *) mptr);
|
||||
else /* otherwise */
|
||||
fflush (lptr->txlog); /* flush the log and leave it open */
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* Show logging status for line */
|
||||
|
||||
t_stat tmxr_show_log (FILE *st, UNIT *uptr, int32 val, void *desc)
|
||||
@@ -880,7 +999,7 @@ return SCPE_OK;
|
||||
device indicated in the TMXR structure. That is, the multiplexer lines may
|
||||
belong to a device other than the one attached to the socket (the HP 2100 MUX
|
||||
device is one example). Therefore, we must look up the device from the unit
|
||||
at each call, rather than depending on the DPTR stored in the TMXR.
|
||||
at each call, rather than depending on the dptr stored in the TMXR.
|
||||
*/
|
||||
|
||||
TMLN *tmxr_find_ldsc (UNIT *uptr, int32 val, TMXR *mp)
|
||||
@@ -898,110 +1017,146 @@ return mp->ldsc + val; /* line descriptor */
|
||||
|
||||
/* Set the line connection order.
|
||||
|
||||
Example command for eight-line multiplexer:
|
||||
This validation routine is called to set the connection order for the
|
||||
multiplexer whose TMXR pointer is passed in the "desc" parameter. It parses
|
||||
the line order list, specified by the "cptr" parameter, of commands such as:
|
||||
|
||||
SET <dev> LINEORDER=1;5;2-4;7
|
||||
SET <dev> LINEORDER=4-7
|
||||
SET <dev> LINEORDER=1;5;2-4;7;ALL
|
||||
SET <dev> LINEORDER=ALL
|
||||
|
||||
Resulting connection order: 1,5,2,3,4,7,0,6.
|
||||
Assuming an 8-channel multiplexer, the first form sets the connection order
|
||||
to line numbers 4, 5, 6, and 7. The remaining lines will not be connected; a
|
||||
connection attempt will be refused with "All connections busy." The second
|
||||
form sets the connection order to line 1, 5, 2, 3, 4, 7, 0, and 6. The
|
||||
trailing "ALL" parameter causes any unspecified lines to be added to the
|
||||
connection order in ascending value. The third form sets the order to lines
|
||||
0-7, which is the default order in the absence of a line connection order
|
||||
array.
|
||||
|
||||
Parameters:
|
||||
- uptr = (not used)
|
||||
- val = (not used)
|
||||
- cptr = pointer to first character of range specification
|
||||
- desc = pointer to multiplexer's TMXR structure
|
||||
The range of accepted line numbers, including those implied by "ALL", can be
|
||||
restricted by specifying a non-zero "val" parameter, with the upper 16 bits
|
||||
specifying the maximum line number, and the lower 16 bits specifying the
|
||||
minimum line number. If a minimum is specified but a maximum is not (i.e.,
|
||||
is zero), the maximum is the last line number defined by the multiplexer
|
||||
descriptor.
|
||||
|
||||
On entry, cptr points to the value portion of the command string, which may
|
||||
be either a semicolon-separated list of line ranges or the keyword ALL.
|
||||
The "uptr" parameter is not used.
|
||||
|
||||
On entry, "cptr" points to the value portion of the command string, which may
|
||||
be either a semicolon-separated list of line ranges or the keyword "ALL". If
|
||||
"ALL" is specified, it must be the last (or only) item in the list.
|
||||
|
||||
If a line connection order array is not defined in the multiplexer
|
||||
descriptor, the command is rejected. If the specified range encompasses all
|
||||
of the lines, the first value of the connection order array is set to -1 to
|
||||
descriptor, or a line range string is not present, or the optional minimum
|
||||
and maximum restrictions in the "val" parameter are not valid, the command is
|
||||
rejected. If the specified range encompasses all of the lines defined by the
|
||||
multiplexer, the first value of the connection order array is set to -1 to
|
||||
indicate sequential connection order. Otherwise, the line values in the
|
||||
array are set to the order specified by the command string. All values are
|
||||
populated, first with those explicitly specified in the command string, and
|
||||
then in ascending sequence with those not specified.
|
||||
array are set to the order specified by the command string. If fewer values
|
||||
are supplied than there are lines supported by the device, and the final
|
||||
parameter is not ALL, the remaining lines will be inaccessible and are
|
||||
indicated by a -1 value after the last specified value.
|
||||
|
||||
If an error occurs, the original line order is not disturbed.
|
||||
*/
|
||||
|
||||
t_stat tmxr_set_lnorder (UNIT *uptr, int32 val, char *cptr, void *desc)
|
||||
{
|
||||
TMXR *mp = (TMXR *) desc;
|
||||
char *tptr;
|
||||
t_addr low, high, max = (t_addr) mp->lines - 1;
|
||||
int32 *list;
|
||||
TMXR *mp = (TMXR *) desc;
|
||||
char *tptr;
|
||||
t_addr low, high, min, max;
|
||||
int32 *list;
|
||||
t_bool *set;
|
||||
uint32 line, idx = 0;
|
||||
uint32 line, idx;
|
||||
t_addr lncount = (t_addr) (mp->lines - 1);
|
||||
t_stat result = SCPE_OK;
|
||||
|
||||
if (mp->lnorder == NULL) /* line connection order undefined? */
|
||||
return SCPE_NXPAR; /* "Non-existent parameter" error */
|
||||
if (mp->lnorder == NULL) /* if the connection order array is not defined */
|
||||
return SCPE_NXPAR; /* then report a "Non-existent parameter" error */
|
||||
|
||||
else if ((cptr == NULL) || (*cptr == '\0')) /* line range not supplied? */
|
||||
return SCPE_MISVAL; /* "Missing value" error */
|
||||
else if ((cptr == NULL) || (*cptr == '\0')) /* otherwise if a line range was not supplied */
|
||||
return SCPE_MISVAL; /* then report a "Missing value" error */
|
||||
|
||||
list = (int32 *) calloc (mp->lines, sizeof (int32)); /* allocate new line order array */
|
||||
else { /* otherwise */
|
||||
min = (t_addr) (val & 0xFFFF); /* split the restriction into */
|
||||
max = (t_addr) ((val >> 16) & 0xFFFF); /* minimum and maximum line numbers */
|
||||
|
||||
if (list == NULL) /* allocation failed? */
|
||||
return SCPE_MEM; /* report it */
|
||||
if (max == 0) /* if the maximum line number isn't specified */
|
||||
max = lncount; /* then use the defined maximum */
|
||||
|
||||
set = (t_bool *) calloc (mp->lines, sizeof (t_bool)); /* allocate line set tracking array */
|
||||
if (min > lncount || max > lncount || min > max) /* if the restriction isn't valid */
|
||||
return SCPE_IERR; /* then report an "Internal error" */
|
||||
}
|
||||
|
||||
if (set == NULL) { /* allocation failed? */
|
||||
free (list); /* free successful list allocation */
|
||||
return SCPE_MEM; /* report it */
|
||||
list = (int32 *) calloc (mp->lines, sizeof (int32)); /* allocate the new line order array */
|
||||
|
||||
if (list == NULL) /* if the allocation failed */
|
||||
return SCPE_MEM; /* then report a "Memory exhausted" error */
|
||||
|
||||
set = (t_bool *) calloc (mp->lines, sizeof (t_bool)); /* allocate the line set tracking array */
|
||||
|
||||
if (set == NULL) { /* if the allocation failed */
|
||||
free (list); /* then free the successful list allocation */
|
||||
return SCPE_MEM; /* and report a "Memory exhausted" error */
|
||||
}
|
||||
|
||||
tptr = cptr + strlen (cptr); /* append a semicolon */
|
||||
*tptr++ = ';'; /* to the command string */
|
||||
*tptr = '\0'; /* to make parsing easier for get_range */
|
||||
*tptr = '\0'; /* to make parsing easier */
|
||||
|
||||
idx = 0; /* initialize the index of ordered values */
|
||||
|
||||
while (*cptr != '\0') { /* while characters remain in the command string */
|
||||
if (strncmp (cptr, "ALL;", 4) == 0) { /* if the parameter is "ALL" */
|
||||
if (val != 0 || idx > 0 && idx <= max) /* then if some lines are restrictied or unspecified */
|
||||
for (line = min; line <= max; line++) /* then fill them in sequentially */
|
||||
if (set [line] == FALSE) /* setting each unspecified line */
|
||||
list [idx++] = line; /* into the line order */
|
||||
|
||||
cptr = cptr + 4; /* advance past "ALL" and the trailing semicolon */
|
||||
|
||||
if (*cptr != '\0') /* if "ALL" is not the last parameter */
|
||||
result = SCPE_2MARG; /* then report extraneous items */
|
||||
|
||||
break; /* "ALL" terminates the order list */
|
||||
}
|
||||
|
||||
while (*cptr) { /* parse command string */
|
||||
cptr = get_range (NULL, cptr, &low, &high, 10, max, ';'); /* get a line range */
|
||||
|
||||
if (cptr == NULL) { /* parsing error? */
|
||||
result = SCPE_ARG; /* "Invalid argument" error */
|
||||
break;
|
||||
if (cptr == NULL) { /* if a parsing error occurred */
|
||||
result = SCPE_ARG; /* then report an invalid argument */
|
||||
break; /* and terminate the parse */
|
||||
}
|
||||
|
||||
else if ((low > max) || (high > max)) { /* line out of range? */
|
||||
result = SCPE_SUB; /* "Subscript out of range" error */
|
||||
break;
|
||||
else if (low < min || low > max || high > max) { /* otherwise if the line number is invalid */
|
||||
result = SCPE_SUB; /* then report the subscript is out of range */
|
||||
break; /* and terminate the parse */
|
||||
}
|
||||
|
||||
else if ((low == 0) && (high == max)) { /* entire line range specified? */
|
||||
list [0] = -1; /* set sequential order flag */
|
||||
idx = (uint32) max + 1; /* indicate no fill-in needed */
|
||||
break;
|
||||
}
|
||||
|
||||
else
|
||||
for (line = (uint32) low; line <= (uint32) high; line++) /* see if previously specified */
|
||||
if (set [line] == FALSE) { /* not already specified? */
|
||||
set [line] = TRUE; /* now it is */
|
||||
list [idx] = line; /* add line to connection order */
|
||||
idx = idx + 1; /* bump "specified" count */
|
||||
else /* otherwise it's a valid range */
|
||||
for (line = (uint32) low; line <= (uint32) high; line++) /* so add the line(s) to the order */
|
||||
if (set [line] == FALSE) { /* if the line number has not been specified */
|
||||
set [line] = TRUE; /* then now it is */
|
||||
list [idx++] = line; /* and add it to the connection order */
|
||||
}
|
||||
}
|
||||
|
||||
if (result == SCPE_OK) { /* assignment successful? */
|
||||
if (idx <= max) /* any lines not specified? */
|
||||
for (line = 0; line <= max; line++) /* fill them in sequentially */
|
||||
if (set [line] == FALSE) { /* specified? */
|
||||
list [idx] = line; /* no, so add it */
|
||||
idx = idx + 1;
|
||||
}
|
||||
if (result == SCPE_OK) { /* if the assignment succeeded */
|
||||
if (idx <= max) /* then if any lines were not specified */
|
||||
list [idx] = -1; /* then terminate the order list after the last one */
|
||||
|
||||
memcpy (mp->lnorder, list, mp->lines * sizeof (int32)); /* copy working array to connection array */
|
||||
memcpy (mp->lnorder, list, /* copy the working array to the connection array */
|
||||
mp->lines * sizeof (int32));
|
||||
}
|
||||
|
||||
free (list); /* free list allocation */
|
||||
free (set); /* free set allocation */
|
||||
free (list); /* free the list allocation */
|
||||
free (set); /* and the set allocation */
|
||||
|
||||
return result;
|
||||
return result; /* return the status */
|
||||
}
|
||||
|
||||
/* Show line connection order.
|
||||
/* Show the line connection order.
|
||||
|
||||
Parameters:
|
||||
- st = stream on which output is to be written
|
||||
@@ -1013,7 +1168,8 @@ return result;
|
||||
command is rejected. If the first value of the connection order array is set
|
||||
to -1, then the connection order is sequential. Otherwise, the line values
|
||||
in the array are printed as a semicolon-separated list. Ranges are printed
|
||||
where possible to shorten the output.
|
||||
where possible to shorten the output. A -1 value within the array indicates
|
||||
the end of the order list.
|
||||
*/
|
||||
|
||||
t_stat tmxr_show_lnorder (FILE *st, UNIT *uptr, int32 val, void *desc)
|
||||
@@ -1032,7 +1188,7 @@ if (*iptr < 0) /* sequential order indi
|
||||
else {
|
||||
low = last = *iptr++; /* set first line value */
|
||||
|
||||
for (j = 1; j <= mp->lines; j++) { /* print remaining lines in order list */
|
||||
for (j = 1; last != -1; j++) { /* print the remaining lines in the order list */
|
||||
if (j < mp->lines) /* more lines to process? */
|
||||
i = *iptr++; /* get next line in list */
|
||||
else /* final iteration */
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* sim_tmxr.h: terminal multiplexor definitions
|
||||
|
||||
Copyright (c) 2001-2019, Robert M Supnik
|
||||
Copyright (c) 2001-2020, 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"),
|
||||
@@ -26,6 +26,7 @@
|
||||
Based on the original DZ11 simulator by Thord Nilson, as updated by
|
||||
Arthur Krewat.
|
||||
|
||||
23-Oct-20 JDB Added tmxr_post_logs global routine
|
||||
19-Dec-19 JDB Added tmxr_is_extended global hook
|
||||
19-Mar-19 JDB Added extension pointer to TMLN structure;
|
||||
added tmxr_read, tmxr_write, tmxr_show, tmxr_close global hooks;
|
||||
@@ -123,6 +124,7 @@ void tmxr_fconns (FILE *st, TMLN *lp, int32 ln);
|
||||
void tmxr_fstats (FILE *st, TMLN *lp, int32 ln);
|
||||
t_stat tmxr_set_log (UNIT *uptr, int32 val, char *cptr, void *desc);
|
||||
t_stat tmxr_set_nolog (UNIT *uptr, int32 val, char *cptr, void *desc);
|
||||
void tmxr_post_logs (t_bool close_logs);
|
||||
t_stat tmxr_show_log (FILE *st, UNIT *uptr, int32 val, void *desc);
|
||||
t_stat tmxr_dscln (UNIT *uptr, int32 val, char *cptr, void *desc);
|
||||
int32 tmxr_rqln (TMLN *lp);
|
||||
|
||||
Reference in New Issue
Block a user