1 /* sim_defs.h: simulator definitions
2 
3    Copyright (c) 1993-2021, Robert M Supnik
4 
5    Permission is hereby granted, free of charge, to any person obtaining a
6    copy of this software and associated documentation files (the "Software"),
7    to deal in the Software without restriction, including without limitation
8    the rights to use, copy, modify, merge, publish, distribute, sublicense,
9    and/or sell copies of the Software, and to permit persons to whom the
10    Software is furnished to do so, subject to the following conditions:
11 
12    The above copyright notice and this permission notice shall be included in
13    all copies or substantial portions of the Software.
14 
15    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18    ROBERT M SUPNIK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19    IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20    CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 
22    Except as contained in this notice, the name of Robert M Supnik shall not be
23    used in advertising or otherwise to promote the sale, use or other dealings
24    in this Software without prior written authorization from Robert M Supnik.
25 
26    17-Mar-21    JDB     Added UNIT_PIPE dynamic flag
27    16-Feb-21    JDB     Added "stride" to REG to support arrays of structures
28                         Modified REG macros to initialize strides
29    21-Jan-21    JDB     Added "size" and "maxval" fields to the REG structure
30                         Modified REG macros to initialize access sizes
31    09-Nov-20    RMS     More V4.X compatibility hooks (Mark Pizzolato)
32    26-Oct-19    RMS     Removed MTAB_VAL definition
33    23-Jun-17    RMS     Added #include sim_rev.h (Mark Pizzolato)
34    25-Sep-16    RMS     Removed KBD_WAIT and friends
35    08-Mar-16    RMS     Added shutdown invisible switch
36    03-Feb-16    JDB     [4.0] Added "help_base" and "message" fields to sim_ctab
37    24-Dec-14    JDB     Added T_ADDR_FMT
38    14-Dec-14    JDB     Extended sim_device for compatibility
39    04-Nov-14    JDB     Added UNIT.dynflags field for tape density support
40    05-Feb-13    JDB     Added REG_V_UF and REG_UFMASK for VM-specific register flags
41    21-Jul-08    RMS     Removed inlining support
42    28-May-08    RMS     Added inlining support
43    28-Jun-07    RMS     Added IA64 VMS support (Norm Lastovica)
44    18-Jun-07    RMS     Added UNIT_IDLE flag
45    18-Mar-07    RMS     Added UNIT_TEXT flag
46    07-Mar-07    JDB     Added DEBUG_PRJ macro
47    18-Oct-06    RMS     Added limit check for clock synchronized keyboard waits
48    13-Jul-06    RMS     Guarantee CBUFSIZE is at least 256
49    07-Jan-06    RMS     Added support for breakpoint spaces
50                         Added REG_FIT flag
51    16-Aug-05    RMS     Fixed C++ declaration and cast problems
52    11-Mar-05    RMS     Moved 64b data type definitions outside USE_INT64
53    07-Feb-05    RMS     Added assertion fail stop
54    05-Nov-04    RMS     Added support for SHOW opt=val
55    20-Oct-04    RMS     Converted all base types to typedefs
56    21-Sep-04    RMS     Added switch to flag stop message printout
57    06-Feb-04    RMS     Moved device and unit user flags fields (V3.2)
58                 RMS     Added REG_VMAD
59    29-Dec-03    RMS     Added output stall status
60    15-Jun-03    RMS     Added register flag REG_VMIO
61    23-Apr-03    RMS     Revised for 32b/64b t_addr
62    14-Mar-03    RMS     Lengthened default serial output wait
63    31-Mar-03    RMS     Added u5, u6 fields
64    18-Mar-03    RMS     Added logical name support
65                         Moved magtape definitions to sim_tape.h
66                         Moved breakpoint definitions from scp.c
67    03-Mar-03    RMS     Added sim_fsize
68    08-Feb-03    RMS     Changed sim_os_sleep to void, added match_ext
69    05-Jan-03    RMS     Added hidden switch definitions, device dyn memory support,
70                         parameters for function pointers, case sensitive SET support
71    22-Dec-02    RMS     Added break flag
72    08-Oct-02    RMS     Increased simulator error code space
73                         Added Telnet errors
74                         Added end of medium support
75                         Added help messages to CTAB
76                         Added flag and context fields to DEVICE
77                         Added restore flag masks
78                         Revised 64b definitions
79    02-May-02    RMS     Removed log status codes
80    22-Apr-02    RMS     Added magtape record length error
81    30-Dec-01    RMS     Generalized timer package, added circular arrays
82    07-Dec-01    RMS     Added breakpoint package
83    01-Dec-01    RMS     Added read-only unit support, extended SET/SHOW features,
84                         improved error messages
85    24-Nov-01    RMS     Added unit-based registers
86    27-Sep-01    RMS     Added queue count prototype
87    17-Sep-01    RMS     Removed multiple console support
88    07-Sep-01    RMS     Removed conditional externs on function prototypes
89    31-Aug-01    RMS     Changed int64 to t_int64 for Windoze
90    17-Jul-01    RMS     Added additional function prototypes
91    27-May-01    RMS     Added multiple console support
92    15-May-01    RMS     Increased string buffer size
93    25-Feb-01    RMS     Revisions for V2.6
94    15-Oct-00    RMS     Editorial revisions for V2.5
95    11-Jul-99    RMS     Added unsigned int data types
96    14-Apr-99    RMS     Converted t_addr to unsigned
97    04-Oct-98    RMS     Additional definitions for V2.4
98 
99    The interface between the simulator control package (SCP) and the
100    simulator consists of the following routines and data structures
101 
102         sim_name                simulator name string
103         sim_devices[]           array of pointers to simulated devices
104         sim_PC                  pointer to saved PC register descriptor
105         sim_interval            simulator interval to next event
106         sim_stop_messages[]     array of pointers to stop messages
107         sim_instr()             instruction execution routine
108         sim_load()              binary loader routine
109         sim_emax                maximum number of words in an instruction
110 
111    In addition, the simulator must supply routines to print and parse
112    architecture specific formats
113 
114         print_sym               print symbolic output
115         parse_sym               parse symbolic input
116 */
117 
118 #ifndef _SIM_DEFS_H_
119 #define _SIM_DEFS_H_    0
120 
121 #include "sim_rev.h"
122 #include <stddef.h>
123 #include <stdlib.h>
124 #include <stdio.h>
125 #if defined(_MSC_VER) && (_MSC_VER < 1900)
126 #define snprintf _snprintf      /* poor man's snprintf which will work most of the time but has different return value */
127 #endif
128 #include <stdarg.h>
129 #include <string.h>
130 #include <errno.h>
131 #include <limits.h>
132 
133 #ifndef TRUE
134 #define TRUE            1
135 #define FALSE           0
136 #endif
137 
138 /* Length specific integer declarations */
139 
140 typedef signed char     int8;
141 typedef signed short    int16;
142 typedef signed int      int32;
143 typedef unsigned char   uint8;
144 typedef unsigned short  uint16;
145 typedef unsigned int    uint32;
146 typedef int             t_stat;                         /* status */
147 typedef int             t_bool;                         /* boolean */
148 
149 /* 64b integers */
150 
151 #if defined (__GNUC__)                                  /* GCC */
152 typedef signed long long        t_int64;
153 typedef unsigned long long      t_uint64;
154 #elif defined (_WIN32)                                  /* Windows */
155 typedef signed __int64          t_int64;
156 typedef unsigned __int64        t_uint64;
157 #elif (defined (__ALPHA) || defined (__ia64)) && defined (VMS) /* 64b VMS */
158 typedef signed __int64          t_int64;
159 typedef unsigned __int64        t_uint64;
160 #elif defined (__ALPHA) && defined (__unix__)           /* Alpha UNIX */
161 typedef signed long             t_int64;
162 typedef unsigned long           t_uint64;
163 #else                                                   /* default */
164 #define t_int64                 signed long long
165 #define t_uint64                unsigned long long
166 #endif                                                  /* end 64b */
167 
168 #if defined (USE_INT64)                                 /* 64b data */
169 typedef t_int64         t_svalue;                       /* signed value */
170 typedef t_uint64        t_value;                        /* value */
171 #else                                                   /* 32b data */
172 typedef int32           t_svalue;
173 typedef uint32          t_value;
174 #endif                                                  /* end 64b data */
175 
176 #if defined (USE_INT64) && defined (USE_ADDR64)         /* 64b address */
177 typedef t_uint64        t_addr;
178 #define T_ADDR_W        64
179 #define T_ADDR_FMT      LL_FMT
180 #else                                                   /* 32b address */
181 typedef uint32          t_addr;
182 #define T_ADDR_W        32
183 #define T_ADDR_FMT      ""
184 #endif                                                  /* end 64b address */
185 
186 #if defined (_WIN32)
187 #define LL_FMT "I64"
188 #else
189 #define LL_FMT "ll"
190 #endif
191 
192 /* Stubs for inlining */
193 
194 #define SIM_INLINE
195 
196 /* System independent definitions */
197 
198 #define FLIP_SIZE       (1 << 16)                       /* flip buf size */
199 #if !defined (PATH_MAX)                                 /* usually in limits */
200 #define PATH_MAX        512
201 #endif
202 #if (PATH_MAX >= 128)
203 #define CBUFSIZE        (128 + PATH_MAX)                /* string buf size */
204 #else
205 #define CBUFSIZE        256
206 #endif
207 
208 /* Breakpoint spaces definitions */
209 
210 #define SIM_BKPT_N_SPC  64                              /* max number spaces */
211 #define SIM_BKPT_V_SPC  26                              /* location in arg */
212 
213 /* Extended switch definitions (bits >= 26) */
214 
215 #define SIM_SW_HIDE     (1u << 26)                      /* enable hiding */
216 #define SIM_SW_REST     (1u << 27)                      /* attach/restore */
217 #define SIM_SW_REG      (1u << 28)                      /* register value */
218 #define SIM_SW_STOP     (1u << 29)                      /* stop message */
219 #define SIM_SW_SHUT     (1u << 30)                      /* shutdown */
220 
221 /* Simulator status codes
222 
223    0                    ok
224    1 - (SCPE_BASE - 1)  simulator specific
225    SCPE_BASE - n        general
226 */
227 
228 #define SCPE_OK         0                               /* normal return */
229 #define SCPE_BASE       64                              /* base for messages */
230 #define SCPE_NXM        (SCPE_BASE + 0)                 /* nxm */
231 #define SCPE_UNATT      (SCPE_BASE + 1)                 /* no file */
232 #define SCPE_IOERR      (SCPE_BASE + 2)                 /* I/O error */
233 #define SCPE_CSUM       (SCPE_BASE + 3)                 /* loader cksum */
234 #define SCPE_FMT        (SCPE_BASE + 4)                 /* loader format */
235 #define SCPE_NOATT      (SCPE_BASE + 5)                 /* not attachable */
236 #define SCPE_OPENERR    (SCPE_BASE + 6)                 /* open error */
237 #define SCPE_MEM        (SCPE_BASE + 7)                 /* alloc error */
238 #define SCPE_ARG        (SCPE_BASE + 8)                 /* argument error */
239 #define SCPE_STEP       (SCPE_BASE + 9)                 /* step expired */
240 #define SCPE_UNK        (SCPE_BASE + 10)                /* unknown command */
241 #define SCPE_RO         (SCPE_BASE + 11)                /* read only */
242 #define SCPE_INCOMP     (SCPE_BASE + 12)                /* incomplete */
243 #define SCPE_STOP       (SCPE_BASE + 13)                /* sim stopped */
244 #define SCPE_EXIT       (SCPE_BASE + 14)                /* sim exit */
245 #define SCPE_TTIERR     (SCPE_BASE + 15)                /* console tti err */
246 #define SCPE_TTOERR     (SCPE_BASE + 16)                /* console tto err */
247 #define SCPE_EOF        (SCPE_BASE + 17)                /* end of file */
248 #define SCPE_REL        (SCPE_BASE + 18)                /* relocation error */
249 #define SCPE_NOPARAM    (SCPE_BASE + 19)                /* no parameters */
250 #define SCPE_ALATT      (SCPE_BASE + 20)                /* already attached */
251 #define SCPE_TIMER      (SCPE_BASE + 21)                /* hwre timer err */
252 #define SCPE_SIGERR     (SCPE_BASE + 22)                /* signal err */
253 #define SCPE_TTYERR     (SCPE_BASE + 23)                /* tty setup err */
254 #define SCPE_SUB        (SCPE_BASE + 24)                /* subscript err */
255 #define SCPE_NOFNC      (SCPE_BASE + 25)                /* func not imp */
256 #define SCPE_UDIS       (SCPE_BASE + 26)                /* unit disabled */
257 #define SCPE_NORO       (SCPE_BASE + 27)                /* rd only not ok */
258 #define SCPE_INVSW      (SCPE_BASE + 28)                /* invalid switch */
259 #define SCPE_MISVAL     (SCPE_BASE + 29)                /* missing value */
260 #define SCPE_2FARG      (SCPE_BASE + 30)                /* too few arguments */
261 #define SCPE_2MARG      (SCPE_BASE + 31)                /* too many arguments */
262 #define SCPE_NXDEV      (SCPE_BASE + 32)                /* nx device */
263 #define SCPE_NXUN       (SCPE_BASE + 33)                /* nx unit */
264 #define SCPE_NXREG      (SCPE_BASE + 34)                /* nx register */
265 #define SCPE_NXPAR      (SCPE_BASE + 35)                /* nx parameter */
266 #define SCPE_NEST       (SCPE_BASE + 36)                /* nested DO */
267 #define SCPE_IERR       (SCPE_BASE + 37)                /* internal error */
268 #define SCPE_MTRLNT     (SCPE_BASE + 38)                /* tape rec lnt error */
269 #define SCPE_LOST       (SCPE_BASE + 39)                /* Telnet conn lost */
270 #define SCPE_TTMO       (SCPE_BASE + 40)                /* Telnet conn timeout */
271 #define SCPE_STALL      (SCPE_BASE + 41)                /* Telnet conn stall */
272 #define SCPE_AFAIL      (SCPE_BASE + 42)                /* assert failed */
273 #define SCPE_KFLAG      0010000                         /* tti data flag */
274 #define SCPE_BREAK      0020000                         /* tti break flag */
275 #define SCPE_DOFAILED   0040000                         /* fail in DO, not subproc */
276 
277 #define SCPE_NOMESSAGE  0                               /* 4.x compatiblity */
278 
279 /* Print value format codes */
280 
281 #define PV_RZRO         0                               /* right, zero fill */
282 #define PV_RSPC         1                               /* right, space fill */
283 #define PV_LEFT         2                               /* left justify */
284 
285 /* Default timing parameters */
286 
287 #define KBD_POLL_WAIT   5000                            /* keyboard poll */
288 #define SERIAL_IN_WAIT  100                             /* serial in time */
289 #define SERIAL_OUT_WAIT 100                             /* serial output */
290 #define NOQUEUE_WAIT    10000                           /* min check time */
291 
292 /* Convert switch letter to bit mask */
293 
294 #define SWMASK(x) (1u << (((int) (x)) - ((int) 'A')))
295 
296 /* String match */
297 
298 #define MATCH_CMD(ptr,cmd) strncmp ((ptr), (cmd), strlen (ptr))
299 
300 /* Device data structure */
301 
302 struct sim_device {
303     char                *name;                          /* name */
304     struct sim_unit     *units;                         /* units */
305     struct sim_reg      *registers;                     /* registers */
306     struct sim_mtab     *modifiers;                     /* modifiers */
307     uint32              numunits;                       /* #units */
308     uint32              aradix;                         /* address radix */
309     uint32              awidth;                         /* address width */
310     uint32              aincr;                          /* addr increment */
311     uint32              dradix;                         /* data radix */
312     uint32              dwidth;                         /* data width */
313     t_stat              (*examine)(t_value *v, t_addr a, struct sim_unit *up,
314                             int32 sw);                  /* examine routine */
315     t_stat              (*deposit)(t_value v, t_addr a, struct sim_unit *up,
316                             int32 sw);                  /* deposit routine */
317     t_stat              (*reset)(struct sim_device *dp);/* reset routine */
318     t_stat              (*boot)(int32 u, struct sim_device *dp);
319                                                         /* boot routine */
320     t_stat              (*attach)(struct sim_unit *up, char *cp);
321                                                         /* attach routine */
322     t_stat              (*detach)(struct sim_unit *up); /* detach routine */
323     void                *ctxt;                          /* context */
324     uint32              flags;                          /* flags */
325     uint32              dctrl;                          /* debug control */
326     struct sim_debtab   *debflags;                      /* debug flags */
327     t_stat              (*msize)(struct sim_unit *up, int32 v, char *cp, void *dp);
328                                                         /* mem size routine */
329     char                *lname;                         /* logical name */
330     void                *help;                          /* (4.0 dummy) help routine */
331     void                *attach_help;                   /* (4.0 dummy) help attach routine*/
332     void                *help_context;                  /* (4.0 dummy) help context */
333     void                *description;                   /* (4.0 dummy) description */
334     };
335 
336 /* Device flags */
337 
338 #define DEV_V_DIS       0                               /* dev disabled */
339 #define DEV_V_DISABLE   1                               /* dev disable-able */
340 #define DEV_V_DYNM      2                               /* mem size dynamic */
341 #define DEV_V_NET       3                               /* network attach */
342 #define DEV_V_DEBUG     4                               /* debug capability */
343 #define DEV_V_RAW       5                               /* raw supported */
344 #define DEV_V_RAWONLY   6                               /* only raw supported */
345 #define DEV_V_UF_31     12                              /* user flags, V3.1 */
346 #define DEV_V_UF        16                              /* user flags */
347 #define DEV_V_RSV       31                              /* reserved */
348 
349 #define DEV_DIS         (1 << DEV_V_DIS)
350 #define DEV_DISABLE     (1 << DEV_V_DISABLE)
351 #define DEV_DYNM        (1 << DEV_V_DYNM)
352 #define DEV_NET         (1 << DEV_V_NET)
353 #define DEV_DEBUG       (1 << DEV_V_DEBUG)
354 #define DEV_RAW         (1 << DEV_V_RAW)
355 #define DEV_RAWONLY     (1 << DEV_V_RAWONLY)
356 
357 #define DEV_DISK        0                               /* (4.0 dummy) */
358 #define DEV_TAPE        0                               /* (4.0 dummy) */
359 #define DEV_MUX         (DEV_NET)                       /* (4.0 dummy) */
360 #define DEV_DISPLAY     0                               /* (4.0 dummy) */
361 #define DEV_ETHER       0                               /* (4.0 dummy) */
362 #define DEV_CARD        0                               /* (4.0 dummy) */
363 
364 #define DEV_UFMASK_31   (((1u << DEV_V_RSV) - 1) & ~((1u << DEV_V_UF_31) - 1))
365 #define DEV_UFMASK      (((1u << DEV_V_RSV) - 1) & ~((1u << DEV_V_UF) - 1))
366 #define DEV_RFLAGS      (DEV_UFMASK|DEV_DIS)            /* restored flags */
367 
368 /* Unit data structure
369 
370    Parts of the unit structure are device specific, that is, they are
371    not referenced by the simulator control package and can be freely
372    used by device simulators.  Fields starting with 'buf', and flags
373    starting with 'UF', are device specific.  The definitions given here
374    are for a typical sequential device.
375 */
376 
377 struct sim_unit {
378     struct sim_unit     *next;                          /* next active */
379     t_stat              (*action)(struct sim_unit *up); /* action routine */
380     char                *filename;                      /* open file name */
381     FILE                *fileref;                       /* file reference */
382     void                *filebuf;                       /* memory buffer */
383     uint32              hwmark;                         /* high water mark */
384     int32               time;                           /* time out */
385     uint32              flags;                          /* flags */
386     uint32              dynflags;                       /* dynamic flags */
387     t_addr              capac;                          /* capacity */
388     t_addr              pos;                            /* file position */
389     int32               buf;                            /* buffer */
390     int32               wait;                           /* wait */
391     int32               u3;                             /* device specific */
392     int32               u4;                             /* device specific */
393     int32               u5;                             /* device specific */
394     int32               u6;                             /* device specific */
395     void                *up7;                           /* (4.0 dummy) */
396     void                *up8;                           /* (4.0 dummy) */
397     };
398 
399 /* Unit flags */
400 
401 #define UNIT_V_UF_31    12                              /* dev spec, V3.1 */
402 #define UNIT_V_UF       16                              /* device specific */
403 #define UNIT_V_RSV      31                              /* reserved!! */
404 
405 #define UNIT_ATTABLE    000001                          /* attachable */
406 #define UNIT_RO         000002                          /* read only */
407 #define UNIT_FIX        000004                          /* fixed capacity */
408 #define UNIT_SEQ        000010                          /* sequential */
409 #define UNIT_ATT        000020                          /* attached */
410 #define UNIT_BINK       000040                          /* K = power of 2 */
411 #define UNIT_BUFABLE    000100                          /* bufferable */
412 #define UNIT_MUSTBUF    000200                          /* must buffer */
413 #define UNIT_BUF        000400                          /* buffered */
414 #define UNIT_ROABLE     001000                          /* read only ok */
415 #define UNIT_DISABLE    002000                          /* disable-able */
416 #define UNIT_DIS        004000                          /* disabled */
417 #define UNIT_RAW        010000                          /* raw mode */
418 #define UNIT_TEXT       020000                          /* text mode */
419 #define UNIT_IDLE       040000                          /* idle eligible */
420 
421 #define UNIT_UFMASK_31  (((1u << UNIT_V_RSV) - 1) & ~((1u << UNIT_V_UF_31) - 1))
422 #define UNIT_UFMASK     (((1u << UNIT_V_RSV) - 1) & ~((1u << UNIT_V_UF) - 1))
423 #define UNIT_RFLAGS     (UNIT_UFMASK|UNIT_DIS)          /* restored flags */
424 
425 /* Unit dynamic flags (dynflags) (from 4.0)
426    These flags are only set dynamically */
427 
428 #define UNIT_ATTMULT    000001                          /* allow multiple ATT cmd */
429 #define UNIT_PIPE       000002                          /* file is a pipe */
430 #define UNIT_V_DF_TAPE  3                               /* tape density reservation (bits 3-5) */
431 #define UNIT_W_DF_TAPE  3
432 
433 /* Register data structure */
434 
435 struct sim_reg {
436     char                *name;                          /* name */
437     void                *loc;                           /* location */
438     uint32              radix;                          /* radix */
439     uint32              width;                          /* width */
440     uint32              offset;                         /* starting bit */
441     uint32              depth;                          /* save depth */
442     size_t              size;                           /* size of location in bytes */
443     size_t              stride;                         /* spacing of array elements in bytes */
444     uint32              flags;                          /* flags */
445     t_value             maxval;                         /* maximum value */
446     uint32              qptr;                           /* circ q ptr */
447     };
448 
449 /* Register flags */
450 
451 #define REG_FMT         00003                           /* see PV_x */
452 #define REG_RO          00004                           /* read only */
453 #define REG_HIDDEN      00010                           /* hidden */
454 #define REG_NZ          00020                           /* must be non-zero */
455 #define REG_UNIT        00000                           /* in unit struct (obsolete) */
456 #define REG_CIRC        00100                           /* circular array */
457 #define REG_VMIO        00200                           /* use VM data print/parse */
458 #define REG_VMAD        00400                           /* use VM addr print/parse */
459 #define REG_FIT         00000                           /* fit access to size (obsolete) */
460 #define REG_HRO         (REG_RO | REG_HIDDEN)           /* hidden, read only */
461 
462 #define REG_V_UF        16                              /* device specific */
463 #define REG_UFMASK      (~((1u << REG_V_UF) - 1))       /* user flags mask */
464 #define REG_VMFLAGS     (REG_VMIO | REG_UFMASK)         /* call VM routine if any of these are set */
465 
466 /* Command tables, base and alternate formats */
467 
468 struct sim_ctab {
469     char                *name;                          /* name */
470     t_stat              (*action)(int32 flag, char *cptr);
471                                                         /* action routine */
472     int32               arg;                            /* argument */
473     char                *help;                          /* help string */
474     const char          *help_base;                     /* [4.0] structured help base */
475     void                (*message)(const char *unechoed_cmdline, t_stat stat);
476                                                         /* [4.0] message printing routine */
477     };
478 
479 struct sim_c1tab {
480     char                *name;                          /* name */
481     t_stat              (*action)(struct sim_device *dptr, struct sim_unit *uptr,
482                             int32 flag, char *cptr);    /* action routine */
483     int32               arg;                            /* argument */
484     char                *help;                          /* help string */
485     };
486 
487 struct sim_shtab {
488     char                *name;                          /* name */
489     t_stat              (*action)(FILE *st, struct sim_device *dptr,
490                             struct sim_unit *uptr, int32 flag, char *cptr);
491     int32               arg;                            /* argument */
492     char                *help;                          /* help string */
493     };
494 
495 /* Modifier table - only extended entries have disp, reg, or flags */
496 
497 struct sim_mtab {
498     uint32              mask;                           /* mask */
499     uint32              match;                          /* match */
500     char                *pstring;                       /* print string */
501     char                *mstring;                       /* match string */
502     t_stat              (*valid)(struct sim_unit *up, int32 v, char *cp, void *dp);
503                                                         /* validation routine */
504     t_stat              (*disp)(FILE *st, struct sim_unit *up, int32 v, void *dp);
505                                                         /* display routine */
506     void                *desc;                          /* value descriptor */
507     void                *help;                          /* [4.0] help */
508     };
509 
510 #define MTAB_XTD        (1u << UNIT_V_RSV)              /* ext entry flag */
511 #define MTAB_VDV        001                             /* valid for dev */
512 #define MTAB_VUN        002                             /* valid for unit */
513 // #define MTAB_VAL        004                             /* REMOVED */
514 #define MTAB_NMO        010                             /* only if named */
515 #define MTAB_NC         020                             /* no UC conversion */
516 #define MTAB_SHP        040                             /* show takes parameter */
517 
518 /* Search table */
519 
520 struct sim_schtab {
521     int32               logic;                          /* logical operator */
522     int32               boolop;                         /* boolean operator */
523     t_value             mask;                           /* mask for logical */
524     t_value             comp;                           /* comparison for boolean */
525     };
526 
527 /* Breakpoint table */
528 
529 struct sim_brktab {
530     t_addr              addr;                           /* address */
531     int32               typ;                            /* mask of types */
532     int32               cnt;                            /* proceed count */
533     char                *act;                           /* action string */
534     };
535 
536 /* Debug table */
537 
538 struct sim_debtab {
539     char                *name;                          /* control name */
540     uint32              mask;                           /* control bit */
541     };
542 
543 #define DEBUG_PRS(d)    (sim_deb && d.dctrl)
544 #define DEBUG_PRD(d)    (sim_deb && d->dctrl)
545 #define DEBUG_PRI(d,m)  (sim_deb && (d.dctrl & (m)))
546 #define DEBUG_PRJ(d,m)  (sim_deb && (d->dctrl & (m)))
547 
548 /* The following macros define structure contents */
549 
550 #define UDATA(act,fl,cap) NULL,act,NULL,NULL,NULL,0,0,(fl),0,(cap),0,0
551 
552 /* Register initialization macros.
553 
554    The following macros should be used to initialize the elements of a
555    simulator's register array.  The macros provide simplified initialization,
556    ensure that unspecified fields are set appropriately, and insulate the
557    simulator writer from changes in the underlying REG structure.
558 
559    The macros take varying numbers of parameters with the following meanings:
560 
561      Param  Meaning
562      -----  ------------------------------------------
563       nm    Register symbolic name
564       loc   Location of the associated variable
565       aloc  Location of the associated array
566       floc  Location of the associated structure field
567       rdx   Display and entry radix
568       wd    Field width in bits
569       off   Field offset in bits from LSB
570       dep   Number of array elements
571       siz   Element size in bytes
572       str   Array element spacing in bytes
573 
574    The macros have the following uses:
575 
576      Macro   Use with
577      ------  ---------------------------------------------------------------
578      XRDATA  Generic type with specification of all parameters
579 
580      ORDATA  Scalar with octal display/entry
581      DRDATA  Scalar with decimal display/entry
582      HRDATA  Scalar with hexadecimal display/entry
583      FLDATA  Scalar with single bit display/entry
584      GRDATA  Scalar with with specification of radix/width/offset parameters
585 
586      BRDATA  Singly-subscripted array
587      CRDATA  Doubly-subscripted array
588 
589      SRDATA  Singly-subscripted array of general structure fields
590      URDATA  Singly-subscripted array of UNIT structure fields
591 
592    Normally, scalar and array locations specify the variable name; the names are
593    converted internally to pointers as needed.  However, the starting point of
594    a parital array may be specified by passing a pointer to the desired element.
595    For example:
596 
597      BRDATA (SYM, array, ...)
598 
599    ...specifies a register starting with array element zero, while:
600 
601      BRDATA (SYM, &array[3], ...)
602 
603    ...specifies a register starting with array element three.
604 
605    For arrays of general structures, the names of the array and selected field
606    are given:
607 
608      SRDATA (SYM, array, field, ...)
609 
610    This specifies a arrayed register whose elements are array[0].field,
611    array[1].field, etc.
612 */
613 
614 #if defined (__STDC__) || defined (_WIN32)
615   #define XRDATA(nm,loc,rdx,wd,off,dep,siz,str) #nm, (loc), (rdx), (wd), (off), (dep), (siz), (str)
616 #else
617   #define XRDATA(nm,loc,rdx,wd,off,dep,siz,str) "nm", (loc), (rdx), (wd), (off), (dep), (siz), (str)
618 #endif
619 
620 #define ORDATA(nm,loc,wd)           XRDATA (nm, &(loc),  8, (wd), 0, 1, sizeof (loc), 0)
621 #define DRDATA(nm,loc,wd)           XRDATA (nm, &(loc), 10, (wd), 0, 1, sizeof (loc), 0)
622 #define HRDATA(nm,loc,wd)           XRDATA (nm, &(loc), 16, (wd), 0, 1, sizeof (loc), 0)
623 #define FLDATA(nm,loc,off)          XRDATA (nm, &(loc), 2, 1, (off), 1, sizeof (loc), 0)
624 #define GRDATA(nm,loc,rdx,wd,off)   XRDATA (nm, &(loc), (rdx), (wd), (off), 1, sizeof (loc), 0)
625 
626 #define BRDATA(nm,aloc,rdx,wd,dep)  XRDATA (nm, (aloc), (rdx), (wd), 0, (dep), sizeof  *(aloc), sizeof  *(aloc))
627 #define CRDATA(nm,aloc,rdx,wd,dep)  XRDATA (nm, (aloc), (rdx), (wd), 0, (dep), sizeof **(aloc), sizeof **(aloc))
628 
629 #define SRDATA(nm,aloc,floc,rdx,wd,off,dep) \
630                                     XRDATA (nm, &((aloc)->floc), (rdx), (wd), (off), (dep), \
631                                             sizeof ((aloc)->floc), sizeof (*(aloc)))
632 #define URDATA(nm,loc,rdx,wd,off,dep,fl) \
633                                     XRDATA (nm, &(loc), (rdx), (wd), (off), (dep), \
634                                             sizeof (loc), sizeof (UNIT)), (fl)
635 
636 #define SAVEDATA(nm,loc)            XRDATA (nm, &(loc), 8, 8, 0, sizeof (loc), 1, 1), REG_HRO
637 
638 /* Typedefs for principal structures */
639 
640 typedef struct sim_device DEVICE;
641 typedef struct sim_unit UNIT;
642 typedef struct sim_reg REG;
643 typedef struct sim_ctab CTAB;
644 typedef struct sim_c1tab C1TAB;
645 typedef struct sim_shtab SHTAB;
646 typedef struct sim_mtab MTAB;
647 typedef struct sim_schtab SCHTAB;
648 typedef struct sim_brktab BRKTAB;
649 typedef struct sim_debtab DEBTAB;
650 
651 /* Function prototypes */
652 
653 #include "scp.h"
654 #include "sim_console.h"
655 #include "sim_timer.h"
656 #include "sim_fio.h"
657 #include "sim_sock.h"
658 
659 /* V4 compatibility definitions
660 
661    The SCP API for version 4.0 introduces a number of "pointer-to-const"
662    parameter qualifiers that were not present in the 3.x versions.  To maintain
663    compatibility with the earlier versions, the new qualifiers are expressed as
664    "CONST" rather than "const".  This allows macro removal of the qualifiers
665    when compiling for SIMH 3.x.
666 */
667 
668 #define ORDATAD(nm,loc,wd,desc)                       ORDATA (nm,loc,wd)
669 #define DRDATAD(nm,loc,wd,desc)                       DRDATA (nm,loc,wd)
670 #define HRDATAD(nm,loc,wd,desc)                       HRDATA (nm,loc,wd)
671 #define FLDATAD(nm,loc,off,desc)                      FLDATA (nm,loc,off)
672 #define GRDATAD(nm,loc,rdx,wd,off,desc)               GRDATA (nm,loc,rdx,wd,off)
673 #define BRDATAD(nm,loc,rdx,wd,dep,desc)               BRDATA (nm,loc,rdx,wd,dep)
674 #define URDATAD(nm,loc,rdx,wd,off,dep,fl,desc)        URDATA (nm,loc,rdx,wd,off,dep,fl)
675 
676 #define ORDATADF(nm,loc,wd,desc,flds)                 ORDATA (nm,loc,wd)
677 #define DRDATADF(nm,loc,wd,desc,flds)                 DRDATA (nm,loc,wd)
678 #define HRDATADF(nm,loc,wd,desc,flds)                 HRDATA (nm,loc,wd)
679 #define FLDATADF(nm,loc,off,desc,flds)                FLDATA (nm,loc,off)
680 #define GRDATADF(nm,loc,rdx,wd,off,desc,flds)         GRDATA (nm,loc,rdx,wd,off)
681 #define BRDATADF(nm,loc,rdx,wd,dep,desc,flds)         BRDATA (nm,loc,rdx,wd,dep)
682 #define URDATADF(nm,loc,rdx,wd,off,dep,fl,desc,flds)  URDATA (nm,loc,rdx,wd,off,dep,fl
683 
684 #ifndef INT64_C
685 #define INT64_C(x)      (x##LL)
686 #endif
687 
688 #ifdef PF_USER
689 #undef PF_USER
690 #endif /* PF_USER */
691 #ifdef I_POP
692 #undef I_POP
693 #endif /* I_POP */
694 #ifdef CONST
695 #undef CONST
696 #endif /* CONST */
697 #define CONST
698 #ifndef PRIORITY_ABOVE_NORMAL
699 #define PRIORITY_ABOVE_NORMAL 0
700 #endif
701 #define sim_os_set_thread_priority(prio)
702 
703 #define BRK_TYP_DYN_STEPOVER 0
704 
705 #endif
706