/* scp.c: simulator control program Copyright (c) 1993-2012, 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. 20-Mar-12 MP Fixes to "SHOW SHOW" commands 06-Jan-12 JDB Fixed "SHOW DEVICE" with only one enabled unit (Dave Bryan) 25-Sep-11 MP Added the ability for a simulator built with SIM_ASYNCH_IO to change whether I/O is actually done asynchronously by the new scp command SET ASYNCH and SET NOASYNCH 22-Sep-11 MP Added signal catching of SIGHUP and SIGTERM to cause simulator STOP. This allows an externally signalled event (i.e. system shutdown, or logoff) to signal a running simulator of these events and to allow reasonable actions to be taken. This will facilitate running a simulator as a 'service' on *nix platforms, given a sufficiently flexible simulator .ini file. 20-Apr-11 MP Added expansion of %STATUS% and %TSTATUS% in do command arguments. STATUS is the numeric value of the last command error status and TSTATUS is the text message relating to the last command error status 17-Apr-11 MP Changed sim_rest to defer attaching devices until after device register contents have been restored since some attach activities may reference register contained info. 29-Jan-11 MP Adjusted sim_debug to: - include the simulator timestamp (sim_gtime) as part of the prefix for each line of output - write complete lines at a time (avoid asynch I/O issues). 05-Jan-11 MP Added Asynch I/O support 22-Jan-11 MP Added SET ON, SET NOON, ON, GOTO and RETURN command support 13-Jan-11 MP Added "SHOW SHOW" and "SHOW 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) 08-Nov-10 RMS Fixed handling of DO with no arguments (Dave Bryan) 22-May-10 RMS Added *nix READLINE support (Mark Pizzolato) 08-Feb-09 RMS Fixed warnings in help printouts 29-Dec-08 RMS Fixed implementation of MTAB_NC 24-Nov-08 RMS Revised RESTORE unit logic for consistency 05-Sep-08 JDB "detach_all" ignores error status returns if shutting down 17-Aug-08 RMS Revert RUN/BOOT to standard, rather than powerup, reset 25-Jul-08 JDB DO cmd missing params now default to null string 29-Jun-08 JDB DO cmd sub_args now allows "\\" to specify literal backslash 31-Mar-08 RMS Fixed bug in local/global register search (Mark Pizzolato) Fixed bug in restore of RO units (Mark Pizzolato) 06-Feb-08 RMS Added SET/SHO/NO BR with default argument 18-Jul-07 RMS Modified match_ext for VMS ext;version support 28-Apr-07 RMS Modified sim_instr invocation to call sim_rtcn_init_all Fixed bug in get_sim_opt Fixed bug in restoration with changed memory size 08-Mar-07 JDB Fixed breakpoint actions in DO command file processing 30-Jan-07 RMS Fixed bugs in get_ipaddr 17-Oct-06 RMS Added idle support 04-Oct-06 JDB DO cmd failure now echoes cmd unless -q 14-Jul-06 RMS Added sim_activate_abs 02-Jun-06 JDB Fixed do_cmd to exit nested files on assertion failure Added -E switch to do_cmd to exit on any error 14-Feb-06 RMS Upgraded save file format to V3.5 18-Jan-06 RMS Added fprint_stopped_gen Added breakpoint spaces Fixed unaligned register access (Doug Carman) 22-Sep-05 RMS Fixed declarations (Sterling Garwood) 30-Aug-05 RMS Revised to trim trailing spaces on file names 25-Aug-05 RMS Added variable default device support 23-Aug-05 RMS Added Linux line history support 16-Aug-05 RMS Fixed C++ declaration and cast problems 01-May-05 RMS Revised syntax for SET DEBUG (Dave Bryan) 22-Mar-05 JDB Modified DO command to allow ten-level nesting 18-Mar-05 RMS Moved DETACH tests into detach_unit (Dave Bryan) Revised interface to fprint_sym, fparse_sym 07-Feb-05 RMS Added ASSERT command (Dave Bryan) 02-Feb-05 RMS Fixed bug in global register search 26-Dec-04 RMS Qualified SAVE examine, RESTORE deposit with SIM_SW_REST 10-Nov-04 JDB Fixed logging of errors from cmds in "do" file 05-Nov-04 RMS Moved SET/SHOW DEBUG under CONSOLE hierarchy Renamed unit OFFLINE/ONLINE to DISABLED/ENABLED (Dave Bryan) Revised to flush output files after simulation stop (Dave Bryan) 15-Oct-04 RMS Fixed HELP to suppress duplicate descriptions 27-Sep-04 RMS Fixed comma-separation options in set (David Bryan) 09-Sep-04 RMS Added -p option for RESET 13-Aug-04 RMS Qualified RESTORE detach with SIM_SW_REST 17-Jul-04 RMS Added ECHO command (Dave Bryan) 12-Jul-04 RMS Fixed problem ATTACHing to read only files (John Dundas) 28-May-04 RMS Added SET/SHOW CONSOLE 14-Feb-04 RMS Updated SAVE/RESTORE (V3.2) RMS Added debug print routines (Dave Hittner) RMS Added sim_vm_parse_addr and sim_vm_fprint_addr RMS Added REG_VMAD support RMS Split out libraries RMS Moved logging function to SCP RMS Exposed step counter interface(s) RMS Fixed double logging of SHOW BREAK (Mark Pizzolato) RMS Fixed implementation of REG_VMIO RMS Added SET/SHOW DEBUG, SET/SHOW DEBUG, SHOW MODIFIERS, SHOW RADIX RMS Changed sim_fsize to take uptr argument 29-Dec-03 RMS Added Telnet console output stall support 01-Nov-03 RMS Cleaned up implicit detach on attach/restore Fixed bug in command line read while logging (Mark Pizzolato) 01-Sep-03 RMS Fixed end-of-file problem in dep, idep Fixed error on trailing spaces in dep, idep 15-Jul-03 RMS Removed unnecessary test in reset_all 15-Jun-03 RMS Added register flag REG_VMIO 25-Apr-03 RMS Added extended address support (V3.0) Fixed bug in SAVE (Peter Schorn) Added u5, u6 fields Added logical name support 03-Mar-03 RMS Added sim_fsize 27-Feb-03 RMS Fixed bug in multiword deposits to files 08-Feb-03 RMS Changed sim_os_sleep to void, match_ext to char* Added multiple actions, .ini file support Added multiple switch evaluations per line 07-Feb-03 RMS Added VMS support for ! (Mark Pizzolato) 01-Feb-03 RMS Added breakpoint table extension, actions 14-Jan-03 RMS Added missing function prototypes 10-Jan-03 RMS Added attach/restore flag, dynamic memory size support, case sensitive SET options 22-Dec-02 RMS Added ! (OS command) feature (Mark Pizzolato) 17-Dec-02 RMS Added get_ipaddr 02-Dec-02 RMS Added EValuate command 16-Nov-02 RMS Fixed bug in register name match algorithm 13-Oct-02 RMS Fixed Borland compiler warnings (Hans Pufal) 05-Oct-02 RMS Fixed bugs in set_logon, ssh_break (David Hittner) Added support for fixed buffer devices Added support for Telnet console, removed VT support Added help Added VMS file optimizations (Robert Alan Byer) Added quiet mode, DO with parameters, GUI interface, extensible commands (Brian Knittel) Added device enable/disable commands 14-Jul-02 RMS Fixed exit bug in do, added -v switch (Brian Knittel) 17-May-02 RMS Fixed bug in fxread/fxwrite error usage (found by Norm Lastovic) 02-May-02 RMS Added VT emulation interface, changed {NO}LOG to SET {NO}LOG 22-Apr-02 RMS Fixed laptop sleep problem in clock calibration, added magtape record length error (Jonathan Engdahl) 26-Feb-02 RMS Fixed initialization bugs in do_cmd, get_aval (Brian Knittel) 10-Feb-02 RMS Fixed problem in clock calibration 06-Jan-02 RMS Moved device enable/disable to simulators 30-Dec-01 RMS Generalized timer packaged, added circular arrays 19-Dec-01 RMS Fixed DO command bug (John Dundas) 07-Dec-01 RMS Implemented breakpoint package 05-Dec-01 RMS Fixed bug in universal register logic 03-Dec-01 RMS Added read-only units, extended SET/SHOW, universal registers 24-Nov-01 RMS Added unit-based registers 16-Nov-01 RMS Added DO command 28-Oct-01 RMS Added relative range addressing 08-Oct-01 RMS Added SHOW VERSION 30-Sep-01 RMS Relaxed attach test in BOOT 27-Sep-01 RMS Added queue count routine, fixed typo in ex/mod 17-Sep-01 RMS Removed multiple console support 07-Sep-01 RMS Removed conditional externs on function prototypes Added special modifier print 31-Aug-01 RMS Changed int64 to t_int64 for Windoze (V2.7) 18-Jul-01 RMS Minor changes for Macintosh port 12-Jun-01 RMS Fixed bug in big-endian I/O (Dave Conroy) 27-May-01 RMS Added multiple console support 16-May-01 RMS Added logging 15-May-01 RMS Added features from Tim Litt 12-May-01 RMS Fixed missing return in disable_cmd 25-Mar-01 RMS Added ENABLE/DISABLE 14-Mar-01 RMS Revised LOAD/DUMP interface (again) 05-Mar-01 RMS Added clock calibration support 05-Feb-01 RMS Fixed bug, DETACH buffered unit with hwmark = 0 04-Feb-01 RMS Fixed bug, RESTORE not using device's attach routine 21-Jan-01 RMS Added relative time 22-Dec-00 RMS Fixed find_device for devices ending in numbers 08-Dec-00 RMS V2.5a changes 30-Oct-00 RMS Added output file option to examine 11-Jul-99 RMS V2.5 changes 13-Apr-99 RMS Fixed handling of 32b addresses 04-Oct-98 RMS V2.4 changes 20-Aug-98 RMS Added radix commands 05-Jun-98 RMS Fixed bug in ^D handling for UNIX 10-Apr-98 RMS Added switches to all commands 26-Oct-97 RMS Added search capability 25-Jan-97 RMS Revised data types 23-Jan-97 RMS Added bi-endian I/O 06-Sep-96 RMS Fixed bug in variable length IEXAMINE 16-Jun-96 RMS Changed interface to parse/print_sym 06-Apr-96 RMS Added error checking in reset all 07-Jan-96 RMS Added register buffers in save/restore 11-Dec-95 RMS Fixed ordering bug in save/restore 22-May-95 RMS Added symbolic input 13-Apr-95 RMS Added symbolic printouts */ /* Macros and data structures */ #include "sim_defs.h" #include "sim_rev.h" #include #include #include #include #if defined(HAVE_DLOPEN) /* Dynamic Readline support */ #include #endif #define EX_D 0 /* deposit */ #define EX_E 1 /* examine */ #define EX_I 2 /* interactive */ #define SCH_OR 0 /* search logicals */ #define SCH_AND 1 #define SCH_XOR 2 #define SCH_E 0 /* search booleans */ #define SCH_N 1 #define SCH_G 2 #define SCH_L 3 #define SCH_EE 4 #define SCH_NE 5 #define SCH_GE 6 #define SCH_LE 7 #define SSH_ST 0 /* set */ #define SSH_SH 1 /* show */ #define SSH_CL 2 /* clear */ #define MAX_DO_NEST_LVL 10 /* DO cmd nesting level */ #define SRBSIZ 1024 /* save/restore buffer */ #define SIM_BRK_INILNT 4096 /* bpt tbl length */ #define SIM_BRK_ALLTYP 0xFFFFFFFF #define UPDATE_SIM_TIME(x) sim_time = sim_time + (x - sim_interval); \ sim_rtime = sim_rtime + ((uint32) (x - sim_interval)); \ x = sim_interval #define SZ_D(dp) (size_map[((dp)->dwidth + CHAR_BIT - 1) / CHAR_BIT]) #define SZ_R(rp) \ (size_map[((rp)->width + (rp)->offset + CHAR_BIT - 1) / CHAR_BIT]) #if defined (USE_INT64) #define SZ_LOAD(sz,v,mb,j) \ if (sz == sizeof (uint8)) v = *(((uint8 *) mb) + ((uint32) j)); \ else if (sz == sizeof (uint16)) v = *(((uint16 *) mb) + ((uint32) j)); \ else if (sz == sizeof (uint32)) v = *(((uint32 *) mb) + ((uint32) j)); \ else v = *(((t_uint64 *) mb) + ((uint32) j)); #define SZ_STORE(sz,v,mb,j) \ if (sz == sizeof (uint8)) *(((uint8 *) mb) + j) = (uint8) v; \ else if (sz == sizeof (uint16)) *(((uint16 *) mb) + ((uint32) j)) = (uint16) v; \ else if (sz == sizeof (uint32)) *(((uint32 *) mb) + ((uint32) j)) = (uint32) v; \ else *(((t_uint64 *) mb) + ((uint32) j)) = v; #else #define SZ_LOAD(sz,v,mb,j) \ if (sz == sizeof (uint8)) v = *(((uint8 *) mb) + ((uint32) j)); \ else if (sz == sizeof (uint16)) v = *(((uint16 *) mb) + ((uint32) j)); \ else v = *(((uint32 *) mb) + ((uint32) j)); #define SZ_STORE(sz,v,mb,j) \ if (sz == sizeof (uint8)) *(((uint8 *) mb) + ((uint32) j)) = (uint8) v; \ else if (sz == sizeof (uint16)) *(((uint16 *) mb) + ((uint32) j)) = (uint16) v; \ else *(((uint32 *) mb) + ((uint32) j)) = v; #endif #define GET_SWITCHES(cp) \ if ((cp = get_sim_sw (cp)) == NULL) return SCPE_INVSW #define GET_RADIX(val,dft) \ if (sim_switches & SWMASK ('O')) val = 8; \ else if (sim_switches & SWMASK ('D')) val = 10; \ else if (sim_switches & SWMASK ('H')) val = 16; \ else val = dft; /* Asynch I/O support */ #if defined (SIM_ASYNCH_IO) pthread_mutex_t sim_asynch_lock = PTHREAD_MUTEX_INITIALIZER; pthread_cond_t sim_asynch_wake = PTHREAD_COND_INITIALIZER; pthread_t sim_asynch_main_threadid; struct sim_unit *sim_asynch_queue = NULL; t_bool sim_asynch_enabled = TRUE; int32 sim_asynch_check; int32 sim_asynch_latency = 4000; /* 4 usec interrupt latency */ int32 sim_asynch_inst_latency = 20; /* assume 5 mip simulator */ #endif /* VM interface */ extern char sim_name[]; extern DEVICE *sim_devices[]; extern REG *sim_PC; extern const char *sim_stop_messages[]; extern t_stat sim_instr (void); extern t_stat sim_load (FILE *ptr, char *cptr, char *fnam, int32 flag); extern int32 sim_emax; extern t_stat fprint_sym (FILE *ofile, t_addr addr, t_value *val, UNIT *uptr, int32 sw); 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 */ 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; void (*sim_vm_fprint_addr) (FILE *st, DEVICE *dptr, t_addr addr) = NULL; t_addr (*sim_vm_parse_addr) (DEVICE *dptr, char *cptr, char **tptr) = NULL; /* Prototypes */ /* Set and show command processors */ 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_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); t_stat show_config (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, char *cptr); t_stat show_queue (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, char *cptr); t_stat show_time (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, char *cptr); t_stat show_mod_names (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, char *cptr); t_stat show_show_commands (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, char *cptr); t_stat show_log_names (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, char *cptr); t_stat show_dev_radix (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, char *cptr); t_stat show_dev_debug (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, char *cptr); t_stat show_dev_logicals (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, char *cptr); t_stat show_dev_modifiers (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, char *cptr); t_stat show_dev_show_commands (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, char *cptr); t_stat show_version (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, char *cptr); t_stat show_break (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, char *cptr); t_stat show_on (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, char *cptr); t_stat show_device (FILE *st, DEVICE *dptr, int32 flag); t_stat show_unit (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag); t_stat show_all_mods (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flg); t_stat show_one_mod (FILE *st, DEVICE *dptr, UNIT *uptr, MTAB *mptr, char *cptr, int32 flag); t_stat sim_check_console (int32 sec); t_stat sim_save (FILE *sfile); t_stat sim_rest (FILE *rfile); /* Breakpoint package */ t_stat sim_brk_init (void); t_stat sim_brk_set (t_addr loc, int32 sw, int32 ncnt, char *act); t_stat sim_brk_clr (t_addr loc, int32 sw); t_stat sim_brk_clrall (int32 sw); t_stat sim_brk_show (FILE *st, t_addr loc, int32 sw); t_stat sim_brk_showall (FILE *st, int32 sw); char *sim_brk_getact (char *buf, int32 size); void sim_brk_clract (void); void sim_brk_npc (uint32 cnt); BRKTAB *sim_brk_new (t_addr loc); /* Commands support routines */ SCHTAB *get_search (char *cptr, int32 radix, SCHTAB *schptr); int32 test_search (t_value val, SCHTAB *schptr); char *get_glyph_gen (char *iptr, char *optr, char mchar, t_bool uc); int32 get_switches (char *cptr); char *get_sim_sw (char *cptr); t_stat get_aval (t_addr addr, DEVICE *dptr, UNIT *uptr); t_value get_rval (REG *rptr, uint32 idx); void put_rval (REG *rptr, uint32 idx, t_value val); t_value strtotv (char *inptr, char **endptr, uint32 radix); void fprint_help (FILE *st); void fprint_stopped (FILE *st, t_stat r); void fprint_capac (FILE *st, DEVICE *dptr, UNIT *uptr); char *read_line (char *ptr, int32 size, FILE *stream); char *read_line_p (char *prompt, char *ptr, int32 size, FILE *stream); REG *find_reg_glob (char *ptr, char **optr, DEVICE **gdptr); char *sim_trim_endspc (char *cptr); /* Forward references */ t_stat scp_attach_unit (DEVICE *dptr, UNIT *uptr, char *cptr); t_stat scp_detach_unit (DEVICE *dptr, UNIT *uptr); t_bool qdisable (DEVICE *dptr); t_stat attach_err (UNIT *uptr, t_stat stat); t_stat detach_all (int32 start_device, t_bool shutdown); t_stat assign_device (DEVICE *dptr, char *cptr); t_stat deassign_device (DEVICE *dptr); t_stat ssh_break_one (FILE *st, int32 flg, t_addr lo, int32 cnt, char *aptr); t_stat run_boot_prep (void); t_stat exdep_reg_loop (FILE *ofile, SCHTAB *schptr, int32 flag, char *cptr, REG *lowr, REG *highr, uint32 lows, uint32 highs); t_stat ex_reg (FILE *ofile, t_value val, int32 flag, REG *rptr, uint32 idx); t_stat dep_reg (int32 flag, char *cptr, REG *rptr, uint32 idx); t_stat exdep_addr_loop (FILE *ofile, SCHTAB *schptr, int32 flag, char *cptr, t_addr low, t_addr high, DEVICE *dptr, UNIT *uptr); t_stat ex_addr (FILE *ofile, int32 flag, t_addr addr, DEVICE *dptr, UNIT *uptr); t_stat dep_addr (int32 flag, char *cptr, t_addr addr, DEVICE *dptr, UNIT *uptr, int32 dfltinc); t_stat step_svc (UNIT *ptr); void sub_args (char *instr, char *tmpbuf, int32 maxstr, char *do_arg[]); t_stat set_on (int32 flag, char *cptr); t_stat set_asynch (int32 flag, char *cptr); /* Global data */ DEVICE *sim_dflt_dev = NULL; UNIT *sim_clock_queue = NULL; int32 sim_interval = 0; int32 sim_switches = 0; FILE *sim_ofile = NULL; SCHTAB *sim_schptr = FALSE; DEVICE *sim_dfdev = NULL; UNIT *sim_dfunit = NULL; int32 sim_opt_out = 0; int32 sim_is_running = 0; uint32 sim_brk_summ = 0; uint32 sim_brk_types = 0; uint32 sim_brk_dflt = 0; char *sim_brk_act[MAX_DO_NEST_LVL]; BRKTAB *sim_brk_tab = NULL; int32 sim_brk_ent = 0; int32 sim_brk_lnt = 0; int32 sim_brk_ins = 0; t_bool sim_brk_pend[SIM_BKPT_N_SPC] = { FALSE }; t_addr sim_brk_ploc[SIM_BKPT_N_SPC] = { 0 }; int32 sim_quiet = 0; int32 sim_step = 0; static double sim_time; static uint32 sim_rtime; static int32 noqueue_time; volatile int32 stop_cpu = 0; t_value *sim_eval = NULL; FILE *sim_log = NULL; /* log file */ FILEREF *sim_log_ref = NULL; /* log file file reference */ FILE *sim_deb = NULL; /* debug file */ FILEREF *sim_deb_ref = NULL; /* debug file file reference */ static FILE *sim_gotofile; /* the currently open do file */ static int32 sim_do_echo = 0; /* the echo status of the currently open do file */ int32 sim_do_depth = 0; static int32 sim_on_check[MAX_DO_NEST_LVL+1]; static char *sim_on_actions[MAX_DO_NEST_LVL+1][SCPE_MAX_ERR+1]; static t_stat sim_last_cmd_stat; /* Command Status */ static SCHTAB sim_stab; static UNIT sim_step_unit = { UDATA (&step_svc, 0, 0) }; #if defined USE_INT64 static const char *sim_si64 = "64b data"; #else static const char *sim_si64 = "32b data"; #endif #if defined USE_ADDR64 static const char *sim_sa64 = "64b addresses"; #else static const char *sim_sa64 = "32b addresses"; #endif #if defined (USE_NETWORK) || defined (USE_SHARED) static const char *sim_snet = "Ethernet support"; #else static const char *sim_snet = "no Ethernet"; #endif /* Tables and strings */ const char save_vercur[] = "V3.5"; const char save_ver32[] = "V3.2"; const char save_ver30[] = "V3.0"; const struct scp_error { char *code; char *message; } scp_errors[1+SCPE_MAX_ERR-SCPE_BASE] = {{"NXM", "Address space exceeded"}, {"UNATT", "Unit not attached"}, {"IOERR", "I/O error"}, {"CSUM", "Checksum error"}, {"FMT", "Format error"}, {"NOATT", "Unit not attachable"}, {"OPENERR", "File open error"}, {"MEM", "Memory exhausted"}, {"ARG", "Invalid argument"}, {"STEP", "Step expired"}, {"UNK", "Unknown command"}, {"RO", "Read only argument"}, {"INCOMP", "Command not completed"}, {"STOP", "Simulation stopped"}, {"EXIT", "Goodbye"}, {"TTIERR", "Console input I/O error"}, {"TTOERR", "Console output I/O error"}, {"EOF", "End of file"}, {"REL", "Relocation error"}, {"NOPARAM", "No settable parameters"}, {"ALATT", "Unit already attached"}, {"TIMER", "Hardware timer error"}, {"SIGERR", "SIGINT handler setup error"}, {"TTYERR", "Console terminal setup error"}, {"SUB", "Subscript out of range"}, {"NOFNC", "Command not allowed"}, {"UDIS", "Unit disabled"}, {"NORO", "Read only operation not allowed"}, {"INVSW", "Invalid switch"}, {"MISVAL", "Missing value"}, {"2FARG", "Too few arguments"}, {"2MARG", "Too many arguments"}, {"NXDEV", "Non-existent device"}, {"NXUN", "Non-existent unit"}, {"NXREG", "Non-existent register"}, {"NXPAR", "Non-existent parameter"}, {"NEST", "Nested DO command limit exceeded"}, {"IERR", "Internal error"}, {"MTRLNT", "Invalid magtape record length"}, {"LOST", "Console Telnet connection lost"}, {"TTMO", "Console Telnet connection timed out"}, {"STALL", "Console Telnet output stall"}, {"AFAIL", "Assertion failed"}, }; const size_t size_map[] = { sizeof (int8), sizeof (int8), sizeof (int16), sizeof (int32), sizeof (int32) #if defined (USE_INT64) , sizeof (t_int64), sizeof (t_int64), sizeof (t_int64), sizeof (t_int64) #endif }; const t_value width_mask[] = { 0, 0x1, 0x3, 0x7, 0xF, 0x1F, 0x3F, 0x7F, 0xFF, 0x1FF, 0x3FF, 0x7FF, 0xFFF, 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF, 0x1FFFF, 0x3FFFF, 0x7FFFF, 0xFFFFF, 0x1FFFFF, 0x3FFFFF, 0x7FFFFF, 0xFFFFFF, 0x1FFFFFF, 0x3FFFFFF, 0x7FFFFFF, 0xFFFFFFF, 0x1FFFFFFF, 0x3FFFFFFF, 0x7FFFFFFF, 0xFFFFFFFF #if defined (USE_INT64) , 0x1FFFFFFFF, 0x3FFFFFFFF, 0x7FFFFFFFF, 0xFFFFFFFFF, 0x1FFFFFFFFF, 0x3FFFFFFFFF, 0x7FFFFFFFFF, 0xFFFFFFFFFF, 0x1FFFFFFFFFF, 0x3FFFFFFFFFF, 0x7FFFFFFFFFF, 0xFFFFFFFFFFF, 0x1FFFFFFFFFFF, 0x3FFFFFFFFFFF, 0x7FFFFFFFFFFF, 0xFFFFFFFFFFFF, 0x1FFFFFFFFFFFF, 0x3FFFFFFFFFFFF, 0x7FFFFFFFFFFFF, 0xFFFFFFFFFFFFF, 0x1FFFFFFFFFFFFF, 0x3FFFFFFFFFFFFF, 0x7FFFFFFFFFFFFF, 0xFFFFFFFFFFFFFF, 0x1FFFFFFFFFFFFFF, 0x3FFFFFFFFFFFFFF, 0x7FFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFF, 0x1FFFFFFFFFFFFFFF, 0x3FFFFFFFFFFFFFFF, 0x7FFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF #endif }; static CTAB cmd_table[] = { { "RESET", &reset_cmd, 0, "r{eset} {ALL|} reset simulator\n" }, { "EXAMINE", &exdep_cmd, EX_E, "e{xamine} examine memory or registers\n" }, { "IEXAMINE", &exdep_cmd, EX_E+EX_I, "ie{xamine} interactive examine memory or registers\n" }, { "DEPOSIT", &exdep_cmd, EX_D, "d{eposit} deposit in memory or registers\n" }, { "IDEPOSIT", &exdep_cmd, EX_D+EX_I, "id{eposit} interactive deposit in memory or registers\n" }, { "EVALUATE", &eval_cmd, 0, "ev{aluate} evaluate symbolic expression\n" }, { "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" }, { "STEP", &run_cmd, RU_STEP, "s{tep} {n} simulate n instructions\n" }, { "CONT", &run_cmd, RU_CONT, "c{ont} continue simulation\n" }, { "BOOT", &run_cmd, RU_BOOT, "b{oot} bootstrap unit\n" }, { "BREAK", &brk_cmd, SSH_ST, "br{eak} set breakpoints\n" }, { "NOBREAK", &brk_cmd, SSH_CL, "nobr{eak} clear breakpoints\n" }, { "ATTACH", &attach_cmd, 0, "at{tach} attach file to simulated unit\n" }, { "DETACH", &detach_cmd, 0, "det{ach} detach file from simulated unit\n" }, { "ASSIGN", &assign_cmd, 0, "as{sign} assign logical name for device\n" }, { "DEASSIGN", &deassign_cmd, 0, "dea{ssign} deassign logical name for device\n" }, { "SAVE", &save_cmd, 0, "sa{ve} save simulator to file\n" }, { "RESTORE", &restore_cmd, 0, "rest{ore}|ge{t} restore simulator from file\n" }, { "GET", &restore_cmd, 0, NULL }, { "LOAD", &load_cmd, 0, "l{oad} {} load binary file\n" }, { "DUMP", &load_cmd, 1, "du(mp) {} dump binary file\n" }, { "EXIT", &exit_cmd, 0, "exi{t}|q{uit}|by{e} exit from simulation\n" }, { "QUIT", &exit_cmd, 0, NULL }, { "BYE", &exit_cmd, 0, NULL }, { "SET", &set_cmd, 0, "set console arg{,arg...} set console options\n" "set console WRU specify console drop to simh char\n" "set console BRK specify console Break character\n" "set console DEL specify console delete char\n" "set console PCHAR specify console printable chars\n" "set console TELNET=port specify console telnet port\n" "set console TELNET=LOG specify console telnet logging\n" "set console TELNET=NOLOG disables console telnet logging\n" "set console TELNET=BUFFERED[=bufsize]\n" " specify console telnet buffering\n" "set console TELNET=NOBUFFERED\n" " disables console telnet buffering\n" "set console TELNET=UNBUFFERED\n" " disables console telnet buffering\n" "set console NOTELNET disable console telnet\n" "set console LOG enable console logging\n" "set console NOLOG disable console logging\n" "set console DEBUG enable console debugging\n" "set console NODEBUG disable console debugging\n" "set break set breakpoints\n" "set nobreak clear breakpoints\n" "set throttle {x{M|K|%}}|{x/t}\n" " set simulation rate\n" "set nothrottle set simulation rate to maximum\n" "set asynch enable asynchronous I/O\n" "set noasynch disable asynchronous I/O\n" "set environment name=val set environment variable\n" "set OCT|DEC|HEX set device display radix\n" "set ENABLED enable device\n" "set DISABLED disable device\n" "set DEBUG{=arg} set device debug flags\n" "set NODEBUG={arg} clear device debug flags\n" "set arg{,arg...} set device parameters (see show modifiers)\n" "set ENABLED enable unit\n" "set DISABLED disable unit\n" "set arg{,arg...} set unit parameters (see show modifiers)\n" "set on enables error checking after command execution\n" "set noon disables error checking after command execution\n" }, { "SHOW", &show_cmd, 0, "sh{ow} br{eak} 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} ti{me} show simulated time\n" "sh{ow} th{rottle} show simulation rate\n" "sh{ow} a{synch} show asynchronouse I/O state\n" "sh{ow} ve{rsion} show simulator version\n" "sh{ow} RADIX show device display radix\n" "sh{ow} DEBUG show device debug flags\n" "sh{ow} MODIFIERS show device modifiers\n" "sh{ow} NAMES show device logical name\n" "sh{ow} SHOW show device SHOW commands\n" "sh{ow} {arg,...} show device parameters\n" "sh{ow} {arg,...} show unit parameters\n" "sh{ow} on show on condition actions\n" }, { "DO", &do_cmd, 1, "do {arg,arg...} process command file\n" }, { "GOTO", &goto_cmd, 1, "goto