| 1 | \r |
| 2 | /* sim_defs.h: simulator definitions\r |
| 3 | \r |
| 4 | Copyright (c) 1993-2008, Robert M Supnik\r |
| 5 | \r |
| 6 | Permission is hereby granted, free of charge, to any person obtaining a\r |
| 7 | copy of this software and associated documentation files (the "Software"),\r |
| 8 | to deal in the Software without restriction, including without limitation\r |
| 9 | the rights to use, copy, modify, merge, publish, distribute, sublicense,\r |
| 10 | and/or sell copies of the Software, and to permit persons to whom the\r |
| 11 | Software is furnished to do so, subject to the following conditions:\r |
| 12 | \r |
| 13 | The above copyright notice and this permission notice shall be included in\r |
| 14 | all copies or substantial portions of the Software.\r |
| 15 | \r |
| 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r |
| 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r |
| 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\r |
| 19 | ROBERT M SUPNIK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r |
| 20 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r |
| 21 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r |
| 22 | \r |
| 23 | Except as contained in this notice, the name of Robert M Supnik shall not be\r |
| 24 | used in advertising or otherwise to promote the sale, use or other dealings\r |
| 25 | in this Software without prior written authorization from Robert M Supnik.\r |
| 26 | \r |
| 27 | 28-May-08 RMS Added inlining support\r |
| 28 | 28-Jun-07 RMS Added IA64 VMS support (from Norm Lastovica)\r |
| 29 | 18-Jun-07 RMS Added UNIT_IDLE flag\r |
| 30 | 18-Mar-07 RMS Added UNIT_TEXT flag\r |
| 31 | 07-Mar-07 JDB Added DEBUG_PRJ macro\r |
| 32 | 18-Oct-06 RMS Added limit check for clock synchronized keyboard waits\r |
| 33 | 13-Jul-06 RMS Guarantee CBUFSIZE is at least 256\r |
| 34 | 07-Jan-06 RMS Added support for breakpoint spaces\r |
| 35 | Added REG_FIT flag\r |
| 36 | 16-Aug-05 RMS Fixed C++ declaration and cast problems\r |
| 37 | 11-Mar-05 RMS Moved 64b data type definitions outside USE_INT64\r |
| 38 | 07-Feb-05 RMS Added assertion fail stop\r |
| 39 | 05-Nov-04 RMS Added support for SHOW opt=val\r |
| 40 | 20-Oct-04 RMS Converted all base types to typedefs\r |
| 41 | 21-Sep-04 RMS Added switch to flag stop message printout\r |
| 42 | 06-Feb-04 RMS Moved device and unit user flags fields (V3.2)\r |
| 43 | RMS Added REG_VMAD\r |
| 44 | 29-Dec-03 RMS Added output stall status\r |
| 45 | 15-Jun-03 RMS Added register flag REG_VMIO\r |
| 46 | 23-Apr-03 RMS Revised for 32b/64b t_addr\r |
| 47 | 14-Mar-03 RMS Lengthened default serial output wait\r |
| 48 | 31-Mar-03 RMS Added u5, u6 fields\r |
| 49 | 18-Mar-03 RMS Added logical name support\r |
| 50 | Moved magtape definitions to sim_tape.h\r |
| 51 | Moved breakpoint definitions from scp.c\r |
| 52 | 03-Mar-03 RMS Added sim_fsize\r |
| 53 | 08-Feb-03 RMS Changed sim_os_sleep to void, added match_ext\r |
| 54 | 05-Jan-03 RMS Added hidden switch definitions, device dyn memory support,\r |
| 55 | parameters for function pointers, case sensitive SET support\r |
| 56 | 22-Dec-02 RMS Added break flag\r |
| 57 | 08-Oct-02 RMS Increased simulator error code space\r |
| 58 | Added Telnet errors\r |
| 59 | Added end of medium support\r |
| 60 | Added help messages to CTAB\r |
| 61 | Added flag and context fields to DEVICE\r |
| 62 | Added restore flag masks\r |
| 63 | Revised 64b definitions\r |
| 64 | 02-May-02 RMS Removed log status codes\r |
| 65 | 22-Apr-02 RMS Added magtape record length error\r |
| 66 | 30-Dec-01 RMS Generalized timer package, added circular arrays\r |
| 67 | 07-Dec-01 RMS Added breakpoint package\r |
| 68 | 01-Dec-01 RMS Added read-only unit support, extended SET/SHOW features,\r |
| 69 | improved error messages\r |
| 70 | 24-Nov-01 RMS Added unit-based registers\r |
| 71 | 27-Sep-01 RMS Added queue count prototype\r |
| 72 | 17-Sep-01 RMS Removed multiple console support\r |
| 73 | 07-Sep-01 RMS Removed conditional externs on function prototypes\r |
| 74 | 31-Aug-01 RMS Changed int64 to t_int64 for Windoze\r |
| 75 | 17-Jul-01 RMS Added additional function prototypes\r |
| 76 | 27-May-01 RMS Added multiple console support\r |
| 77 | 15-May-01 RMS Increased string buffer size\r |
| 78 | 25-Feb-01 RMS Revisions for V2.6\r |
| 79 | 15-Oct-00 RMS Editorial revisions for V2.5\r |
| 80 | 11-Jul-99 RMS Added unsigned int data types\r |
| 81 | 14-Apr-99 RMS Converted t_addr to unsigned\r |
| 82 | 04-Oct-98 RMS Additional definitions for V2.4\r |
| 83 | \r |
| 84 | The interface between the simulator control package (SCP) and the\r |
| 85 | simulator consists of the following routines and data structures\r |
| 86 | \r |
| 87 | sim_name simulator name string\r |
| 88 | sim_devices[] array of pointers to simulated devices\r |
| 89 | sim_PC pointer to saved PC register descriptor\r |
| 90 | sim_interval simulator interval to next event\r |
| 91 | sim_stop_messages[] array of pointers to stop messages\r |
| 92 | sim_instr() instruction execution routine\r |
| 93 | sim_load() binary loader routine\r |
| 94 | sim_emax maximum number of words in an instruction\r |
| 95 | \r |
| 96 | In addition, the simulator must supply routines to print and parse\r |
| 97 | architecture specific formats\r |
| 98 | \r |
| 99 | print_sym print symbolic output\r |
| 100 | parse_sym parse symbolic input\r |
| 101 | */\r |
| 102 | \r |
| 103 | #ifndef _SIM_DEFS_H_\r |
| 104 | #define _SIM_DEFS_H_ 0\r |
| 105 | \r |
| 106 | #include <stddef.h>\r |
| 107 | #include <stdlib.h>\r |
| 108 | #include <stdio.h>\r |
| 109 | #include <stdarg.h>\r |
| 110 | #include <string.h>\r |
| 111 | #include <errno.h>\r |
| 112 | #include <limits.h>\r |
| 113 | \r |
| 114 | #ifndef TRUE\r |
| 115 | #define TRUE 1\r |
| 116 | #define FALSE 0\r |
| 117 | #endif\r |
| 118 | \r |
| 119 | /* Length specific integer declarations */\r |
| 120 | \r |
| 121 | typedef signed char int8;\r |
| 122 | typedef signed short int16;\r |
| 123 | typedef signed int int32;\r |
| 124 | typedef unsigned char uint8;\r |
| 125 | typedef unsigned short uint16;\r |
| 126 | typedef unsigned int uint32; \r |
| 127 | typedef int t_stat; /* status */\r |
| 128 | typedef int t_bool; /* boolean */\r |
| 129 | \r |
| 130 | /* 64b integers */\r |
| 131 | \r |
| 132 | #if defined (__GNUC__) /* GCC */\r |
| 133 | typedef signed long long t_int64;\r |
| 134 | typedef unsigned long long t_uint64;\r |
| 135 | #elif defined (_WIN32) /* Windows */\r |
| 136 | typedef signed __int64 t_int64;\r |
| 137 | typedef unsigned __int64 t_uint64;\r |
| 138 | #elif (defined (__ALPHA) || defined (__ia64)) && defined (VMS) /* 64b VMS */\r |
| 139 | typedef signed __int64 t_int64;\r |
| 140 | typedef unsigned __int64 t_uint64;\r |
| 141 | #elif defined (__ALPHA) && defined (__unix__) /* Alpha UNIX */\r |
| 142 | typedef signed long t_int64;\r |
| 143 | typedef unsigned long t_uint64;\r |
| 144 | #else /* default */\r |
| 145 | #define t_int64 signed long long\r |
| 146 | #define t_uint64 unsigned long long\r |
| 147 | #endif /* end 64b */\r |
| 148 | \r |
| 149 | #if defined (USE_INT64) /* 64b data */\r |
| 150 | typedef t_int64 t_svalue; /* signed value */\r |
| 151 | typedef t_uint64 t_value; /* value */\r |
| 152 | #else /* 32b data */\r |
| 153 | typedef int32 t_svalue;\r |
| 154 | typedef uint32 t_value;\r |
| 155 | #endif /* end 64b data */\r |
| 156 | \r |
| 157 | #if defined (USE_INT64) && defined (USE_ADDR64) /* 64b address */\r |
| 158 | typedef t_uint64 t_addr;\r |
| 159 | #define T_ADDR_W 64\r |
| 160 | #else /* 32b address */\r |
| 161 | typedef uint32 t_addr;\r |
| 162 | #define T_ADDR_W 32\r |
| 163 | #endif /* end 64b address */\r |
| 164 | \r |
| 165 | /* Inlining */\r |
| 166 | \r |
| 167 | #if defined (__GNUC__) /* GCC */\r |
| 168 | #define SIM_INLINE inline\r |
| 169 | #define SIM_INLINE_GCC\r |
| 170 | #elif defined (_MSC_VER) /* Microsoft C Compilers */\r |
| 171 | #define SIM_INLINE __inline\r |
| 172 | #else /* default */\r |
| 173 | #define SIM_INLINE\r |
| 174 | #endif\r |
| 175 | \r |
| 176 | /* System independent definitions */\r |
| 177 | \r |
| 178 | #define FLIP_SIZE (1 << 16) /* flip buf size */\r |
| 179 | #if !defined (PATH_MAX) /* usually in limits */\r |
| 180 | #define PATH_MAX 512\r |
| 181 | #endif\r |
| 182 | #if (PATH_MAX >= 128)\r |
| 183 | #define CBUFSIZE (128 + PATH_MAX) /* string buf size */\r |
| 184 | #else\r |
| 185 | #define CBUFSIZE 256\r |
| 186 | #endif\r |
| 187 | \r |
| 188 | /* Breakpoint spaces definitions */\r |
| 189 | \r |
| 190 | #define SIM_BKPT_N_SPC 64 /* max number spaces */\r |
| 191 | #define SIM_BKPT_V_SPC 26 /* location in arg */\r |
| 192 | \r |
| 193 | /* Extended switch definitions (bits >= 26) */\r |
| 194 | \r |
| 195 | #define SIM_SW_HIDE (1u << 26) /* enable hiding */\r |
| 196 | #define SIM_SW_REST (1u << 27) /* attach/restore */\r |
| 197 | #define SIM_SW_REG (1u << 28) /* register value */\r |
| 198 | #define SIM_SW_STOP (1u << 29) /* stop message */\r |
| 199 | \r |
| 200 | /* Simulator status codes\r |
| 201 | \r |
| 202 | 0 ok\r |
| 203 | 1 - (SCPE_BASE - 1) simulator specific\r |
| 204 | SCPE_BASE - n general\r |
| 205 | */\r |
| 206 | \r |
| 207 | #define SCPE_OK 0 /* normal return */\r |
| 208 | #define SCPE_BASE 64 /* base for messages */\r |
| 209 | #define SCPE_NXM (SCPE_BASE + 0) /* nxm */\r |
| 210 | #define SCPE_UNATT (SCPE_BASE + 1) /* no file */\r |
| 211 | #define SCPE_IOERR (SCPE_BASE + 2) /* I/O error */\r |
| 212 | #define SCPE_CSUM (SCPE_BASE + 3) /* loader cksum */\r |
| 213 | #define SCPE_FMT (SCPE_BASE + 4) /* loader format */\r |
| 214 | #define SCPE_NOATT (SCPE_BASE + 5) /* not attachable */\r |
| 215 | #define SCPE_OPENERR (SCPE_BASE + 6) /* open error */\r |
| 216 | #define SCPE_MEM (SCPE_BASE + 7) /* alloc error */\r |
| 217 | #define SCPE_ARG (SCPE_BASE + 8) /* argument error */\r |
| 218 | #define SCPE_STEP (SCPE_BASE + 9) /* step expired */\r |
| 219 | #define SCPE_UNK (SCPE_BASE + 10) /* unknown command */\r |
| 220 | #define SCPE_RO (SCPE_BASE + 11) /* read only */\r |
| 221 | #define SCPE_INCOMP (SCPE_BASE + 12) /* incomplete */\r |
| 222 | #define SCPE_STOP (SCPE_BASE + 13) /* sim stopped */\r |
| 223 | #define SCPE_EXIT (SCPE_BASE + 14) /* sim exit */\r |
| 224 | #define SCPE_TTIERR (SCPE_BASE + 15) /* console tti err */\r |
| 225 | #define SCPE_TTOERR (SCPE_BASE + 16) /* console tto err */\r |
| 226 | #define SCPE_EOF (SCPE_BASE + 17) /* end of file */\r |
| 227 | #define SCPE_REL (SCPE_BASE + 18) /* relocation error */\r |
| 228 | #define SCPE_NOPARAM (SCPE_BASE + 19) /* no parameters */\r |
| 229 | #define SCPE_ALATT (SCPE_BASE + 20) /* already attached */\r |
| 230 | #define SCPE_TIMER (SCPE_BASE + 21) /* hwre timer err */\r |
| 231 | #define SCPE_SIGERR (SCPE_BASE + 22) /* signal err */\r |
| 232 | #define SCPE_TTYERR (SCPE_BASE + 23) /* tty setup err */\r |
| 233 | #define SCPE_SUB (SCPE_BASE + 24) /* subscript err */\r |
| 234 | #define SCPE_NOFNC (SCPE_BASE + 25) /* func not imp */\r |
| 235 | #define SCPE_UDIS (SCPE_BASE + 26) /* unit disabled */\r |
| 236 | #define SCPE_NORO (SCPE_BASE + 27) /* rd only not ok */\r |
| 237 | #define SCPE_INVSW (SCPE_BASE + 28) /* invalid switch */\r |
| 238 | #define SCPE_MISVAL (SCPE_BASE + 29) /* missing value */\r |
| 239 | #define SCPE_2FARG (SCPE_BASE + 30) /* too few arguments */\r |
| 240 | #define SCPE_2MARG (SCPE_BASE + 31) /* too many arguments */\r |
| 241 | #define SCPE_NXDEV (SCPE_BASE + 32) /* nx device */\r |
| 242 | #define SCPE_NXUN (SCPE_BASE + 33) /* nx unit */\r |
| 243 | #define SCPE_NXREG (SCPE_BASE + 34) /* nx register */\r |
| 244 | #define SCPE_NXPAR (SCPE_BASE + 35) /* nx parameter */\r |
| 245 | #define SCPE_NEST (SCPE_BASE + 36) /* nested DO */\r |
| 246 | #define SCPE_IERR (SCPE_BASE + 37) /* internal error */\r |
| 247 | #define SCPE_MTRLNT (SCPE_BASE + 38) /* tape rec lnt error */\r |
| 248 | #define SCPE_LOST (SCPE_BASE + 39) /* Telnet conn lost */\r |
| 249 | #define SCPE_TTMO (SCPE_BASE + 40) /* Telnet conn timeout */\r |
| 250 | #define SCPE_STALL (SCPE_BASE + 41) /* Telnet conn stall */\r |
| 251 | #define SCPE_AFAIL (SCPE_BASE + 42) /* assert failed */\r |
| 252 | #define SCPE_KFLAG 0010000 /* tti data flag */\r |
| 253 | #define SCPE_BREAK 0020000 /* tti break flag */\r |
| 254 | \r |
| 255 | /* Print value format codes */\r |
| 256 | \r |
| 257 | #define PV_RZRO 0 /* right, zero fill */\r |
| 258 | #define PV_RSPC 1 /* right, space fill */\r |
| 259 | #define PV_LEFT 2 /* left justify */\r |
| 260 | \r |
| 261 | /* Default timing parameters */\r |
| 262 | \r |
| 263 | #define KBD_POLL_WAIT 5000 /* keyboard poll */\r |
| 264 | #define KBD_MAX_WAIT 500000\r |
| 265 | #define SERIAL_IN_WAIT 100 /* serial in time */\r |
| 266 | #define SERIAL_OUT_WAIT 100 /* serial output */\r |
| 267 | #define NOQUEUE_WAIT 10000 /* min check time */\r |
| 268 | #define KBD_LIM_WAIT(x) (((x) > KBD_MAX_WAIT)? KBD_MAX_WAIT: (x))\r |
| 269 | #define KBD_WAIT(w,s) ((w)? w: KBD_LIM_WAIT (s))\r |
| 270 | \r |
| 271 | /* Convert switch letter to bit mask */\r |
| 272 | \r |
| 273 | #define SWMASK(x) (1u << (((int) (x)) - ((int) 'A')))\r |
| 274 | \r |
| 275 | /* String match */\r |
| 276 | \r |
| 277 | #define MATCH_CMD(ptr,cmd) strncmp ((ptr), (cmd), strlen (ptr))\r |
| 278 | \r |
| 279 | /* Device data structure */\r |
| 280 | \r |
| 281 | struct sim_device {\r |
| 282 | char *name; /* name */\r |
| 283 | struct sim_unit *units; /* units */\r |
| 284 | struct sim_reg *registers; /* registers */\r |
| 285 | struct sim_mtab *modifiers; /* modifiers */\r |
| 286 | uint32 numunits; /* #units */\r |
| 287 | uint32 aradix; /* address radix */\r |
| 288 | uint32 awidth; /* address width */\r |
| 289 | uint32 aincr; /* addr increment */\r |
| 290 | uint32 dradix; /* data radix */\r |
| 291 | uint32 dwidth; /* data width */\r |
| 292 | t_stat (*examine)(t_value *v, t_addr a, struct sim_unit *up,\r |
| 293 | int32 sw); /* examine routine */\r |
| 294 | t_stat (*deposit)(t_value v, t_addr a, struct sim_unit *up,\r |
| 295 | int32 sw); /* deposit routine */\r |
| 296 | t_stat (*reset)(struct sim_device *dp);/* reset routine */\r |
| 297 | t_stat (*boot)(int32 u, struct sim_device *dp);\r |
| 298 | /* boot routine */\r |
| 299 | t_stat (*attach)(struct sim_unit *up, char *cp);\r |
| 300 | /* attach routine */\r |
| 301 | t_stat (*detach)(struct sim_unit *up); /* detach routine */\r |
| 302 | void *ctxt; /* context */\r |
| 303 | uint32 flags; /* flags */\r |
| 304 | uint32 dctrl; /* debug control */\r |
| 305 | struct sim_debtab *debflags; /* debug flags */\r |
| 306 | t_stat (*msize)(struct sim_unit *up, int32 v, char *cp, void *dp);\r |
| 307 | /* mem size routine */\r |
| 308 | char *lname; /* logical name */\r |
| 309 | };\r |
| 310 | \r |
| 311 | /* Device flags */\r |
| 312 | \r |
| 313 | #define DEV_V_DIS 0 /* dev disabled */\r |
| 314 | #define DEV_V_DISABLE 1 /* dev disable-able */\r |
| 315 | #define DEV_V_DYNM 2 /* mem size dynamic */\r |
| 316 | #define DEV_V_NET 3 /* network attach */\r |
| 317 | #define DEV_V_DEBUG 4 /* debug capability */\r |
| 318 | #define DEV_V_RAW 5 /* raw supported */\r |
| 319 | #define DEV_V_RAWONLY 6 /* only raw supported */\r |
| 320 | #define DEV_V_UF_31 12 /* user flags, V3.1 */\r |
| 321 | #define DEV_V_UF 16 /* user flags */\r |
| 322 | #define DEV_V_RSV 31 /* reserved */\r |
| 323 | \r |
| 324 | #define DEV_DIS (1 << DEV_V_DIS)\r |
| 325 | #define DEV_DISABLE (1 << DEV_V_DISABLE)\r |
| 326 | #define DEV_DYNM (1 << DEV_V_DYNM)\r |
| 327 | #define DEV_NET (1 << DEV_V_NET)\r |
| 328 | #define DEV_DEBUG (1 << DEV_V_DEBUG)\r |
| 329 | #define DEV_RAW (1 << DEV_V_RAW)\r |
| 330 | #define DEV_RAWONLY (1 << DEV_V_RAWONLY)\r |
| 331 | \r |
| 332 | #define DEV_UFMASK_31 (((1u << DEV_V_RSV) - 1) & ~((1u << DEV_V_UF_31) - 1))\r |
| 333 | #define DEV_UFMASK (((1u << DEV_V_RSV) - 1) & ~((1u << DEV_V_UF) - 1))\r |
| 334 | #define DEV_RFLAGS (DEV_UFMASK|DEV_DIS) /* restored flags */\r |
| 335 | \r |
| 336 | /* Unit data structure\r |
| 337 | \r |
| 338 | Parts of the unit structure are device specific, that is, they are\r |
| 339 | not referenced by the simulator control package and can be freely\r |
| 340 | used by device simulators. Fields starting with 'buf', and flags\r |
| 341 | starting with 'UF', are device specific. The definitions given here\r |
| 342 | are for a typical sequential device.\r |
| 343 | */\r |
| 344 | \r |
| 345 | struct sim_unit {\r |
| 346 | struct sim_unit *next; /* next active */\r |
| 347 | t_stat (*action)(struct sim_unit *up); /* action routine */\r |
| 348 | char *filename; /* open file name */\r |
| 349 | FILE *fileref; /* file reference */\r |
| 350 | void *filebuf; /* memory buffer */\r |
| 351 | uint32 hwmark; /* high water mark */\r |
| 352 | int32 time; /* time out */\r |
| 353 | uint32 flags; /* flags */\r |
| 354 | t_addr capac; /* capacity */\r |
| 355 | t_addr pos; /* file position */\r |
| 356 | int32 buf; /* buffer */\r |
| 357 | int32 wait; /* wait */\r |
| 358 | int32 u3; /* device specific */\r |
| 359 | int32 u4; /* device specific */\r |
| 360 | int32 u5; /* device specific */\r |
| 361 | int32 u6; /* device specific */\r |
| 362 | };\r |
| 363 | \r |
| 364 | /* Unit flags */\r |
| 365 | \r |
| 366 | #define UNIT_V_UF_31 12 /* dev spec, V3.1 */\r |
| 367 | #define UNIT_V_UF 16 /* device specific */\r |
| 368 | #define UNIT_V_RSV 31 /* reserved!! */\r |
| 369 | \r |
| 370 | #define UNIT_ATTABLE 000001 /* attachable */\r |
| 371 | #define UNIT_RO 000002 /* read only */\r |
| 372 | #define UNIT_FIX 000004 /* fixed capacity */\r |
| 373 | #define UNIT_SEQ 000010 /* sequential */\r |
| 374 | #define UNIT_ATT 000020 /* attached */\r |
| 375 | #define UNIT_BINK 000040 /* K = power of 2 */\r |
| 376 | #define UNIT_BUFABLE 000100 /* bufferable */\r |
| 377 | #define UNIT_MUSTBUF 000200 /* must buffer */\r |
| 378 | #define UNIT_BUF 000400 /* buffered */\r |
| 379 | #define UNIT_ROABLE 001000 /* read only ok */\r |
| 380 | #define UNIT_DISABLE 002000 /* disable-able */\r |
| 381 | #define UNIT_DIS 004000 /* disabled */\r |
| 382 | #define UNIT_RAW 010000 /* raw mode */\r |
| 383 | #define UNIT_TEXT 020000 /* text mode */\r |
| 384 | #define UNIT_IDLE 040000 /* idle eligible */\r |
| 385 | \r |
| 386 | #define UNIT_UFMASK_31 (((1u << UNIT_V_RSV) - 1) & ~((1u << UNIT_V_UF_31) - 1))\r |
| 387 | #define UNIT_UFMASK (((1u << UNIT_V_RSV) - 1) & ~((1u << UNIT_V_UF) - 1))\r |
| 388 | #define UNIT_RFLAGS (UNIT_UFMASK|UNIT_DIS) /* restored flags */\r |
| 389 | \r |
| 390 | /* Register data structure */\r |
| 391 | \r |
| 392 | struct sim_reg {\r |
| 393 | char *name; /* name */\r |
| 394 | void *loc; /* location */\r |
| 395 | uint32 radix; /* radix */\r |
| 396 | uint32 width; /* width */\r |
| 397 | uint32 offset; /* starting bit */\r |
| 398 | uint32 depth; /* save depth */\r |
| 399 | uint32 flags; /* flags */\r |
| 400 | uint32 qptr; /* circ q ptr */\r |
| 401 | };\r |
| 402 | \r |
| 403 | #define REG_FMT 00003 /* see PV_x */\r |
| 404 | #define REG_RO 00004 /* read only */\r |
| 405 | #define REG_HIDDEN 00010 /* hidden */\r |
| 406 | #define REG_NZ 00020 /* must be non-zero */\r |
| 407 | #define REG_UNIT 00040 /* in unit struct */\r |
| 408 | #define REG_CIRC 00100 /* circular array */\r |
| 409 | #define REG_VMIO 00200 /* use VM data print/parse */\r |
| 410 | #define REG_VMAD 00400 /* use VM addr print/parse */\r |
| 411 | #define REG_FIT 01000 /* fit access to size */\r |
| 412 | #define REG_HRO (REG_RO | REG_HIDDEN) /* hidden, read only */\r |
| 413 | \r |
| 414 | /* Command tables, base and alternate formats */\r |
| 415 | \r |
| 416 | struct sim_ctab {\r |
| 417 | char *name; /* name */\r |
| 418 | t_stat (*action)(int32 flag, char *cptr);\r |
| 419 | /* action routine */\r |
| 420 | int32 arg; /* argument */\r |
| 421 | char *help; /* help string */\r |
| 422 | };\r |
| 423 | \r |
| 424 | struct sim_c1tab {\r |
| 425 | char *name; /* name */\r |
| 426 | t_stat (*action)(struct sim_device *dptr, struct sim_unit *uptr,\r |
| 427 | int32 flag, char *cptr); /* action routine */\r |
| 428 | int32 arg; /* argument */\r |
| 429 | char *help; /* help string */\r |
| 430 | };\r |
| 431 | \r |
| 432 | struct sim_shtab {\r |
| 433 | char *name; /* name */\r |
| 434 | t_stat (*action)(FILE *st, struct sim_device *dptr,\r |
| 435 | struct sim_unit *uptr, int32 flag, char *cptr);\r |
| 436 | int32 arg; /* argument */\r |
| 437 | char *help; /* help string */\r |
| 438 | };\r |
| 439 | \r |
| 440 | /* Modifier table - only extended entries have disp, reg, or flags */\r |
| 441 | \r |
| 442 | struct sim_mtab {\r |
| 443 | uint32 mask; /* mask */\r |
| 444 | uint32 match; /* match */\r |
| 445 | char *pstring; /* print string */\r |
| 446 | char *mstring; /* match string */\r |
| 447 | t_stat (*valid)(struct sim_unit *up, int32 v, char *cp, void *dp);\r |
| 448 | /* validation routine */\r |
| 449 | t_stat (*disp)(FILE *st, struct sim_unit *up, int32 v, void *dp);\r |
| 450 | /* display routine */\r |
| 451 | void *desc; /* value descriptor */\r |
| 452 | /* REG * if MTAB_VAL */\r |
| 453 | /* int * if not */\r |
| 454 | };\r |
| 455 | \r |
| 456 | #define MTAB_XTD (1u << UNIT_V_RSV) /* ext entry flag */\r |
| 457 | #define MTAB_VDV 001 /* valid for dev */\r |
| 458 | #define MTAB_VUN 002 /* valid for unit */\r |
| 459 | #define MTAB_VAL 004 /* takes a value */\r |
| 460 | #define MTAB_NMO 010 /* only if named */\r |
| 461 | #define MTAB_NC 020 /* no UC conversion */\r |
| 462 | #define MTAB_SHP 040 /* show takes parameter */\r |
| 463 | \r |
| 464 | /* Search table */\r |
| 465 | \r |
| 466 | struct sim_schtab {\r |
| 467 | int32 logic; /* logical operator */\r |
| 468 | int32 boolop; /* boolean operator */\r |
| 469 | t_value mask; /* mask for logical */\r |
| 470 | t_value comp; /* comparison for boolean */\r |
| 471 | };\r |
| 472 | \r |
| 473 | /* Breakpoint table */\r |
| 474 | \r |
| 475 | struct sim_brktab {\r |
| 476 | t_addr addr; /* address */\r |
| 477 | int32 typ; /* mask of types */\r |
| 478 | int32 cnt; /* proceed count */ \r |
| 479 | char *act; /* action string */\r |
| 480 | };\r |
| 481 | \r |
| 482 | /* Debug table */\r |
| 483 | \r |
| 484 | struct sim_debtab {\r |
| 485 | char *name; /* control name */\r |
| 486 | uint32 mask; /* control bit */\r |
| 487 | };\r |
| 488 | \r |
| 489 | #define DEBUG_PRS(d) (sim_deb && d.dctrl)\r |
| 490 | #define DEBUG_PRD(d) (sim_deb && d->dctrl)\r |
| 491 | #define DEBUG_PRI(d,m) (sim_deb && (d.dctrl & (m)))\r |
| 492 | #define DEBUG_PRJ(d,m) (sim_deb && (d->dctrl & (m)))\r |
| 493 | \r |
| 494 | /* The following macros define structure contents */\r |
| 495 | \r |
| 496 | #define UDATA(act,fl,cap) NULL,act,NULL,NULL,NULL,0,0,(fl),(cap),0,0\r |
| 497 | \r |
| 498 | #if defined (__STDC__) || defined (_WIN32)\r |
| 499 | #define ORDATA(nm,loc,wd) #nm, &(loc), 8, (wd), 0, 1\r |
| 500 | #define DRDATA(nm,loc,wd) #nm, &(loc), 10, (wd), 0, 1\r |
| 501 | #define HRDATA(nm,loc,wd) #nm, &(loc), 16, (wd), 0, 1\r |
| 502 | #define FLDATA(nm,loc,pos) #nm, &(loc), 2, 1, (pos), 1\r |
| 503 | #define GRDATA(nm,loc,rdx,wd,pos) #nm, &(loc), (rdx), (wd), (pos), 1\r |
| 504 | #define BRDATA(nm,loc,rdx,wd,dep) #nm, (loc), (rdx), (wd), 0, (dep)\r |
| 505 | #define URDATA(nm,loc,rdx,wd,off,dep,fl) \\r |
| 506 | #nm, &(loc), (rdx), (wd), (off), (dep), ((fl) | REG_UNIT)\r |
| 507 | #else\r |
| 508 | #define ORDATA(nm,loc,wd) "nm", &(loc), 8, (wd), 0, 1\r |
| 509 | #define DRDATA(nm,loc,wd) "nm", &(loc), 10, (wd), 0, 1\r |
| 510 | #define HRDATA(nm,loc,wd) "nm", &(loc), 16, (wd), 0, 1\r |
| 511 | #define FLDATA(nm,loc,pos) "nm", &(loc), 2, 1, (pos), 1\r |
| 512 | #define GRDATA(nm,loc,rdx,wd,pos) "nm", &(loc), (rdx), (wd), (pos), 1\r |
| 513 | #define BRDATA(nm,loc,rdx,wd,dep) "nm", (loc), (rdx), (wd), 0, (dep)\r |
| 514 | #define URDATA(nm,loc,rdx,wd,off,dep,fl) \\r |
| 515 | "nm", &(loc), (rdx), (wd), (off), (dep), ((fl) | REG_UNIT)\r |
| 516 | #endif\r |
| 517 | \r |
| 518 | /* Typedefs for principal structures */\r |
| 519 | \r |
| 520 | typedef struct sim_device DEVICE;\r |
| 521 | typedef struct sim_unit UNIT;\r |
| 522 | typedef struct sim_reg REG;\r |
| 523 | typedef struct sim_ctab CTAB;\r |
| 524 | typedef struct sim_c1tab C1TAB;\r |
| 525 | typedef struct sim_shtab SHTAB;\r |
| 526 | typedef struct sim_mtab MTAB;\r |
| 527 | typedef struct sim_schtab SCHTAB;\r |
| 528 | typedef struct sim_brktab BRKTAB;\r |
| 529 | typedef struct sim_debtab DEBTAB;\r |
| 530 | \r |
| 531 | /* Function prototypes */\r |
| 532 | \r |
| 533 | #include "scp.h"\r |
| 534 | #include "sim_console.h"\r |
| 535 | #include "sim_timer.h"\r |
| 536 | #include "sim_fio.h"\r |
| 537 | \r |
| 538 | #endif\r |