From ef6528bf32e3bd1dd49d168e73b80e8ef4a8b0f7 Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Fri, 3 Apr 2015 16:05:01 -0700 Subject: [PATCH] SCP: Added automatic saving of console WRU, DEL, BRK and PCHAR console variables and provided a way for a simulator to declare that is doesn't have a console port so automatic WRU detection can be performed. --- scp.c | 11 +++++++++-- sim_console.c | 32 +++++++++++++++++++++++++++----- sim_console.h | 1 + sim_defs.h | 2 ++ sim_timer.c | 2 +- 5 files changed, 40 insertions(+), 8 deletions(-) diff --git a/scp.c b/scp.c index 35914f2f..15032b42 100644 --- a/scp.c +++ b/scp.c @@ -5402,7 +5402,7 @@ t_stat sim_save (FILE *sfile) { void *mbuf; int32 l, t; -uint32 i, j; +uint32 i, j, device_count; t_addr k, high; t_value val; t_stat r; @@ -5423,7 +5423,14 @@ fprintf (sfile, "%s\n%s\n%s\n%s\n%s\n%.0f\n", sim_time); /* [V3.2] sim time */ WRITE_I (sim_rtime); /* [V2.6] sim rel time */ -for (i = 0; (dptr = sim_devices[i]) != NULL; i++) { /* loop thru devices */ +for (device_count = 0; sim_devices[device_count]; device_count++);/* count devices */ +for (i = 0; i < (device_count + sim_internal_device_count); i++) {/* loop thru devices */ + if (i < device_count) + dptr = sim_devices[i]; + else + dptr = sim_internal_devices[i - device_count]; + if (dptr->flags & DEV_NOSAVE) + continue; fputs (dptr->name, sfile); /* device name */ fputc ('\n', sfile); if (dptr->lname) /* [V3.0] logical name */ diff --git a/sim_console.c b/sim_console.c index cdc6bebe..09096a15 100644 --- a/sim_console.c +++ b/sim_console.c @@ -194,12 +194,20 @@ static DEBTAB sim_con_debug[] = { {0} }; +static REG sim_con_reg[] = { + { ORDATAD (WRU, sim_int_char, 8, "interrupt character") }, + { ORDATAD (BRK, sim_brk_char, 8, "break character") }, + { ORDATAD (DEL, sim_del_char, 8, "delete character ") }, + { ORDATAD (PCHAR, sim_tt_pchar, 32, "printable character mask") }, + { 0 }, +}; + static MTAB sim_con_mod[] = { { 0 }, }; DEVICE sim_con_telnet = { - "CON-TEL", &sim_con_unit, NULL, sim_con_mod, + "CON-TEL", &sim_con_unit, sim_con_reg, sim_con_mod, 1, 0, 0, 0, 0, 0, NULL, NULL, sim_con_reset, NULL, NULL, NULL, NULL, DEV_DEBUG, 0, sim_con_debug}; @@ -210,16 +218,29 @@ TMXR sim_con_tmxr = { 1, 0, 0, &sim_con_ldsc, NULL, &sim_con_telnet };/* console SEND sim_con_send = {SEND_DEFAULT_DELAY, &sim_con_telnet, DBG_SND}; EXPECT sim_con_expect = {&sim_con_telnet, DBG_EXP}; +static t_bool sim_con_console_port = TRUE; + +/* Enable automatic WRU console polling */ + +t_stat sim_set_noconsole_port (void) +{ +sim_con_console_port = FALSE; +return SCPE_OK; +} + /* Unit service for console connection polling */ static t_stat sim_con_poll_svc (UNIT *uptr) { -if ((sim_con_tmxr.master == 0) && /* not Telnet and not serial? */ - (sim_con_ldsc.serport == 0)) +if ((sim_con_tmxr.master == 0) && /* not Telnet and not serial and not WRU polling? */ + (sim_con_ldsc.serport == 0) && + (sim_con_console_port)) return SCPE_OK; /* done */ if (tmxr_poll_conn (&sim_con_tmxr) >= 0) /* poll connect */ sim_con_ldsc.rcve = 1; /* rcv enabled */ sim_activate_after(uptr, 1000000); /* check again in 1 second */ +if (!sim_con_console_port) /* WRU poll needed */ + sim_poll_kbd(); /* sets global stop_cpu when WRU received */ if (sim_con_ldsc.conn) tmxr_send_buffered_data (&sim_con_ldsc); /* try to flush any buffered data */ return SCPE_OK; @@ -380,7 +401,7 @@ DEVICE sim_remote_console = { "REM-CON", sim_rem_con_unit, NULL, sim_rem_con_mod, 2, 0, 0, 0, 0, 0, NULL, NULL, sim_rem_con_reset, NULL, NULL, NULL, - NULL, DEV_DEBUG, 0, sim_rem_con_debug}; + NULL, DEV_DEBUG | DEV_NOSAVE, 0, sim_rem_con_debug}; #define MAX_REMOTE_SESSIONS 40 /* Arbitrary Session Limit */ static int32 *sim_rem_buf_size = NULL; static int32 *sim_rem_buf_ptr = NULL; @@ -1206,7 +1227,8 @@ if (sim_rem_master_mode) { t_stat stat_nomessage; if ((!sim_con_ldsc.serport) && - (sim_con_tmxr.master == 0)) { + (sim_con_tmxr.master == 0) && + (sim_con_console_port)) { sim_printf ("Console port must be Telnet or Serial with Master Remote Console\r\n"); return SCPE_IERR|SCPE_NOMESSAGE; } diff --git a/sim_console.h b/sim_console.h index 4e51c770..33eef6cd 100644 --- a/sim_console.h +++ b/sim_console.h @@ -106,6 +106,7 @@ const char *sim_logfile_name (FILE *st, FILEREF *ref); SEND *sim_cons_get_send (void); EXPECT *sim_cons_get_expect (void); t_stat sim_show_cons_send_input (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, char *cptr); +t_stat sim_set_noconsole_port (void); t_stat sim_poll_kbd (void); t_stat sim_putchar (int32 c); t_stat sim_putchar_s (int32 c); diff --git a/sim_defs.h b/sim_defs.h index a7a8f7fb..4e5e28f0 100644 --- a/sim_defs.h +++ b/sim_defs.h @@ -426,6 +426,7 @@ struct sim_device { #define DEV_V_SECTORS 7 /* Unit Capacity is in 512byte sectors */ #define DEV_V_DONTAUTO 8 /* Do not auto detach already attached units */ #define DEV_V_FLATHELP 9 /* Use traditional (unstructured) help */ +#define DEV_V_NOSAVE 10 /* Don't save device state */ #define DEV_V_UF_31 12 /* user flags, V3.1 */ #define DEV_V_UF 16 /* user flags */ #define DEV_V_RSV 31 /* reserved */ @@ -437,6 +438,7 @@ struct sim_device { #define DEV_SECTORS (1 << DEV_V_SECTORS) /* capacity is 512 byte sectors */ #define DEV_DONTAUTO (1 << DEV_V_DONTAUTO) /* Do not auto detach already attached units */ #define DEV_FLATHELP (1 << DEV_V_FLATHELP) /* Use traditional (unstructured) help */ +#define DEV_NOSAVE (1 << DEV_V_NOSAVE) /* Don't save device state */ #define DEV_NET 0 /* Deprecated - meaningless */ diff --git a/sim_timer.c b/sim_timer.c index 7e6a6a53..bff008b7 100644 --- a/sim_timer.c +++ b/sim_timer.c @@ -873,7 +873,7 @@ DEVICE sim_timer_dev = { "TIMER", sim_timer_units, sim_timer_reg, sim_timer_mod, SIM_NTIMERS+1, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, DEV_DEBUG, 0, sim_timer_debug}; + NULL, DEV_DEBUG | DEV_NOSAVE, 0, sim_timer_debug}; /* sim_idle - idle simulator until next event or for specified interval