root/src/dps8/dps8_sys.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. print_default_base_system_script
  2. do_ini_line
  3. set_default_base_system
  4. boot_skip
  5. do_execute_fault
  6. do_execute_switches
  7. do_restart
  8. set_sys_polling_interval
  9. set_sys_slow_polling_interval
  10. set_sys_poll_check_rate
  11. dps_debug_mme_cntdwn
  12. dps_debug_skip
  13. dps_debug_start
  14. dps_debug_stop
  15. dps_debug_break
  16. dps_debug_segno
  17. dps_debug_ringno
  18. dps_debug_bar
  19. abs_addr_n
  20. abs_addr
  21. lookup_book_segment
  22. add_book_segment
  23. add_book_component
  24. lookup_system_book_address
  25. lookup_address
  26. lookup_system_book_name
  27. list_source
  28. stack_trace
  29. list_source_at
  30. load_system_book
  31. add_system_book_entry
  32. lookup_system_book
  33. fetchSDW
  34. virtAddrN
  35. virt_address
  36. set_search_path
  37. brkbrk
  38. sbreak
  39. dfx1entry
  40. dfx1exit
  41. dv2scale
  42. dfx2entry
  43. mdfx3entry
  44. smfx1entry
  45. search_memory
  46. set_dbg_cpu_mask
  47. scraper
  48. clear_yield
  49. yield
  50. set_luf
  51. dbgevent_compar
  52. dbgevent_lookup
  53. set_dbgevent
  54. rewind_media
  55. load_media
  56. ready_media
  57. trkw
  58. trkr
  59. usr1_signal_handler
  60. systabInit
  61. hash32s
  62. dps8_init
  63. dps8_exit
  64. getAddress
  65. parse_addr
  66. fprint_addr
  67. fprint_sym
  68. parse_sym
  69. sys_show_config
  70. sys_set_break
  71. sys_show_break
  72. sys_set_config
  73. sys_reset
  74. dps8_init_strip

   1 /*
   2  * vim: filetype=c:tabstop=4:ai:expandtab
   3  * SPDX-License-Identifier: ICU
   4  * SPDX-License-Identifier: Multics
   5  * scspell-id: ff1a12fc-f62e-11ec-aea6-80ee73e9b8e7
   6  *
   7  * ---------------------------------------------------------------------------
   8  *
   9  * Copyright (c) 2007-2013 Michael Mondy
  10  * Copyright (c) 2012-2016 Harry Reed
  11  * Copyright (c) 2013-2021 Charles Anthony
  12  * Copyright (c) 2016 Michal Tomek
  13  * Copyright (c) 2026 Eric Swenson
  14  * Copyright (c) 2021-2026 Jeffrey H. Johnson
  15  * Copyright (c) 2021-2026 The DPS8M Development Team
  16  *
  17  * This software is made available under the terms of the ICU License.
  18  * See the LICENSE.md file at the top-level directory of this distribution.
  19  *
  20  * ---------------------------------------------------------------------------
  21  *
  22  * This source file may contain code comments that adapt, include, and/or
  23  * incorporate Multics program code and/or documentation distributed under
  24  * the Multics License.  In the event of any discrepancy between code
  25  * comments herein and the original Multics materials, the original Multics
  26  * materials should be considered authoritative unless otherwise noted.
  27  * For more details and historical background, see the LICENSE.md file at
  28  * the top-level directory of this distribution.
  29  *
  30  * ---------------------------------------------------------------------------
  31  */
  32 
  33 #include <stdio.h>
  34 #if !defined(__MINGW64__) && !defined(__MINGW32__) && !defined(CROSS_MINGW64) && !defined(CROSS_MINGW32)
  35 # include <signal.h>
  36 # include <sys/mman.h>
  37 #endif /* if !defined(__MINGW64__) && !defined(__MINGW32__) && !defined(CROSS_MINGW64) && !defined(CROSS_MINGW32) */
  38 #include <time.h>
  39 #include <stdint.h>
  40 #include <unistd.h>
  41 #include <ctype.h>
  42 
  43 #if defined(__APPLE__)
  44 # include <pthread.h>
  45 #endif /* if defined(__APPLE__) */
  46 
  47 #include "dps8.h"
  48 #include "dps8_sys.h"
  49 #include "dps8_sir.h"
  50 #include "dps8_iom.h"
  51 #include "dps8_console.h"
  52 #include "dps8_cable.h"
  53 #include "dps8_cpu.h"
  54 #include "dps8_faults.h"
  55 #include "dps8_scu.h"
  56 #include "dps8_state.h"
  57 #include "dps8_ins.h"
  58 #include "dps8_math.h"
  59 #include "dps8_mt.h"
  60 #include "dps8_socket_dev.h"
  61 #include "dps8_disk.h"
  62 #include "dps8_append.h"
  63 #include "dps8_fnp2.h"
  64 #include "dps8_crdrdr.h"
  65 #include "dps8_crdpun.h"
  66 #include "dps8_prt.h"
  67 #include "dps8_urp.h"
  68 #include "dps8_absi.h"
  69 #include "dps8_mgp.h"
  70 #include "dps8_net.h"
  71 #include "dps8_utils.h"
  72 #include "dps8_memalign.h"
  73 #include "dps8_cache.h"
  74 #include "shm.h"
  75 #include "ver.h"
  76 
  77 #include "../simh/sim_os_mem.h"
  78 
  79 #if defined(THREADZ) || defined(LOCKLESS)
  80 # include "threadz.h"
  81 #endif /* if defined(THREADZ) || defined(LOCKLESS) */
  82 
  83 #include "panelScraper.h"
  84 
  85 #include "segldr.h"
  86 
  87 #if defined(NO_LOCALE)
  88 # define xstrerror_l strerror
  89 #endif
  90 
  91 #define DBG_CTR cpu.cycleCnt
  92 
  93 #define ASSUME0 0
  94 
  95 #if defined(FREE)
  96 # undef FREE
  97 #endif /* if defined(FREE) */
  98 #define FREE(p) do  \
  99   {                 \
 100     free((p));      \
 101     (p) = NULL;     \
 102   } while(0)
 103 
 104 // Strictly speaking, memory belongs in the SCU.
 105 // We will treat memory as viewed from the CPU and elide the
 106 // SCU configuration that maps memory across multiple SCUs.
 107 // I would guess that multiple SCUs helped relieve memory
 108 // contention across multiple CPUs, but that is a level of
 109 // emulation that will be ignored.
 110 
 111 struct system_state_s * system_state;
 112 
 113 volAtomic word36 * M = NULL;  //-V707   // memory
 114 
 115 //
 116 // These are part of the scp interface
 117 //
 118 
 119 const char* appname = "dps8";
 120 char sim_name[] = "DPS8/M";
 121 int32 sim_emax = 4;  // some EIS can take up to 4-words
 122 static void dps8_init(void);
 123 static void dps8_exit (void);
 124 void (*sim_vm_init) (void) = & dps8_init;  // CustomCmds;
 125 void (*sim_vm_exit) (void) = & dps8_exit;  // CustomCmds;
 126 
 127 #if defined(TESTING)
 128 static t_addr parse_addr(DEVICE *dptr, const char *cptr, const char **optr);
 129 static void fprint_addr(FILE *stream, DEVICE *dptr, t_addr addr);
 130 #endif // TESTING
 131 
 132 int32 luf_flag = 1;
 133 
 134 ////////////////////////////////////////////////////////////////////////////////
 135 //
 136 // SCP Commands
 137 //
 138 
 139 //
 140 // System configuration commands
 141 //
 142 
 143 // Script to string cables and set switches
 144 
 145 #if !defined(PERF_STRIP)
 146 static char * default_base_system_script [] =
 147   {
 148     // ;
 149     // ; Configure test system
 150     // ;
 151     // ; CPU, IOM * 2, MPC, TAPE * 16, DISK * 16, SCU * 4, OPC * 2, FNP, URP * 3,
 152     // ; PRT, RDR, PUN
 153     // ;
 154     // ;
 155     // ; From AN70-1 System Initialization PLM May 84, pg 8-4:
 156     // ;
 157     // ; All CPUs and IOMs must share the same layout of port assignments to
 158     // ; SCUs. Thus, if memory port B of CPU C goes to SCU D, the memory port
 159     // ; B of all other CPUs and IOMs must go to SCU D. All CPUs and IOMs must
 160     // ; describe this SCU the same; all must agree in memory sizes. Also, all
 161     // ; SCUs must agree on port assignments of CPUs and IOMs. This, if port 3
 162     // ; of SCU C goes to CPU A, the port 3 of all other SCUs must also go to
 163     // ; CPU A.
 164     // ;
 165     // ; Pg. 8-6:
 166     // ;
 167     // ; The actual memory size of the memory attached to the SCU attached to
 168     // ; the processor port in questions is 32K * 2 ** (encoded memory size).
 169     // ; The port assignment couples with the memory size to determine the base
 170     // ; address of the SCU connected to the specified CPU port (absolute
 171     // ; address of the first location in the memory attached to that SCU). The
 172     // ; base address of the SCU is the (actual memory size) * (port assignment).
 173     // ;
 174     // ; Pg. 8-6
 175     // ;
 176     // ; [bits 09-11 lower store size]
 177     // ;
 178     // ; A DPS-8 SCU may have up to four store units attached to it. If this is
 179     // ; the case, two stores units form a pair of units. The size of a pair of
 180     // ; units (or a single unit) is 32K * 2 ** (lower store size) above.
 181     // ;
 182     // ;
 183     // ;
 184     // ; Looking at bootload_io, it would appear that Multics is happier with
 185     // ; IOM0 being the bootload IOM, despite suggestions elsewhere that was
 186     // ; not a requirement.
 187 
 188 //
 189 // IOM channel assignments
 190 //
 191 // IOM A
 192 //
 193 //  012 MTP0           tape drives
 194 //  013 IPC0 port 0    FIPS disk controller
 195 //  014 MSP0 port 0    disk controller
 196 //  015 URP0           card reader controller
 197 //  016 URP1           card punch controller
 198 //  017 URP2           printer controller
 199 //  020 FNPD           comm line controller
 200 //  021 FNPA           comm line controller
 201 //  022 FNPB           comm line controller
 202 //  023 FNPC           comm line controller
 203 //  024 FNPE           comm line controller
 204 //  025 FNPF           comm line controller
 205 //  026 FNPG           comm line controller
 206 //  027 FNPH           comm line controller
 207 //  032 ABSI0          IMP controller
 208 //  033 MGP0           MGP Read controller
 209 //  034 MGP1           MGP Write controller
 210 //  036 OPC0           operator console
 211 //  040 SKCA
 212 //  041 SKCB
 213 //  042 SKCC
 214 //  043 SKCD
 215 //  044 SKCE
 216 //  045 SKCF
 217 //  046 SKCG
 218 //  047 SKCH
 219 //  050 PRT1
 220 //  051 PRT2
 221 //  052 PRT3
 222 //  053 OPC1
 223 //  055 RDRB
 224 //  056 RDRC
 225 //  057 PUNB
 226 //  060 PUNC
 227 //  061 NET0           NET Read controller
 228 //  062 NET1           NET Write controller
 229 //
 230 // IOM B
 231 //
 232 //  013 IPC0 port 1    FIPS disk controller
 233 //  014 MSP0 port 1    disk controller
 234 
 235     // ; Disconnect everything...
 236     "CABLE_RIPOUT",
 237 
 238     "SET CPU NUNITS=6",
 239     "SET IOM NUNITS=2",
 240     // ; 16 drives plus a placeholder for the controller
 241     "SET TAPE NUNITS=17",
 242     "SET MTP NUNITS=1",
 243     // ; 4 3381 drives; 2 controllers
 244     // ; 4 d501 drives; 2 controller
 245     // ; 4 d451 drives; same controller has d501s
 246     // ; 2 d500 drives; same controller has d501s
 247     "SET IPC NUNITS=2",
 248     "SET MSP NUNITS=2",
 249     "SET DISK NUNITS=26",
 250     "SET SCU NUNITS=4",
 251     "SET OPC NUNITS=2",
 252     "SET FNP NUNITS=8",
 253     "SET URP NUNITS=10",
 254     "SET RDR NUNITS=3",
 255     "SET PUN NUNITS=3",
 256     "SET PRT NUNITS=4",
 257 # if defined (WITH_ABSI_DEV)
 258 #  if !defined(__MINGW64__) && !defined(__MINGW32__) && !defined(CROSS_MINGW64) && !defined(CROSS_MINGW32)
 259     "SET ABSI NUNITS=1",
 260 #  endif /* if !defined(__MINGW64__) && !defined(__MINGW32__) && !defined(CROSS_MINGW64) && !defined(CROSS_MINGW32) */
 261 # endif /* if defined(WITH_ABSI_DEV) */
 262 
 263 # if defined(WITH_MGP_DEV)
 264     "SET MGP NUNITS=2",
 265 # endif /* if defined(WITH_MGP_DEV) */
 266 
 267 # if defined(WITH_NET_DEV)
 268     "SET NET NUNITS=2",
 269 # endif /* if defined(WITH_NET_DEV) */
 270 
 271 # if defined(WITH_SOCKET_DEV)
 272 #  if !defined(__MINGW64__) && !defined(__MINGW32__) && !defined(CROSS_MINGW64) && !defined(CROSS_MINGW32)
 273     "SET SKC NUNITS=64",
 274 #  endif /* if !defined(__MINGW64__) && !defined(__MINGW32__) && !defined(CROSS_MINGW64) && !defined(CROSS_MINGW32) */
 275 # endif /* if defined(WITH_SOCKET_DEV) */
 276 
 277 // CPU0
 278 
 279     "SET CPU0 CONFIG=FAULTBASE=Multics",
 280 
 281     "SET CPU0 CONFIG=NUM=0",
 282     // ; As per GB61-01 Operators Guide, App. A
 283     // ; switches: 4, 6, 18, 19, 20, 23, 24, 25, 26, 28
 284     "SET CPU0 CONFIG=DATA=024000717200",
 285     "SET CPU0 CONFIG=ADDRESS=000000000000",
 286 
 287     // ; enable ports 0 and 1 (scu connections)
 288     // ; portconfig: ABCD
 289     // ;   each is 3 bits addr assignment
 290     // ;           1 bit enabled
 291     // ;           1 bit sysinit enabled
 292     // ;           1 bit interlace enabled (interlace?)
 293     // ;           3 bit memory size
 294     // ;              0 - 32K
 295     // ;              1 - 64K
 296     // ;              2 - 128K
 297     // ;              3 - 256K
 298     // ;              4 - 512K
 299     // ;              5 - 1M
 300     // ;              6 - 2M
 301     // ;              7 - 4M
 302 
 303     "SET CPU0 CONFIG=PORT=A",
 304     "SET CPU0   CONFIG=ASSIGNMENT=0",
 305     "SET CPU0   CONFIG=INTERLACE=0",
 306     "SET CPU0   CONFIG=ENABLE=1",
 307     "SET CPU0   CONFIG=INIT_ENABLE=1",
 308     "SET CPU0   CONFIG=STORE_SIZE=4M",
 309 
 310     "SET CPU0 CONFIG=PORT=B",
 311     "SET CPU0   CONFIG=ASSIGNMENT=1",
 312     "SET CPU0   CONFIG=INTERLACE=0",
 313     "SET CPU0   CONFIG=ENABLE=1",
 314     "SET CPU0   CONFIG=INIT_ENABLE=1",
 315     "SET CPU0   CONFIG=STORE_SIZE=4M",
 316 
 317     "SET CPU0 CONFIG=PORT=C",
 318     "SET CPU0   CONFIG=ASSIGNMENT=2",
 319     "SET CPU0   CONFIG=INTERLACE=0",
 320     "SET CPU0   CONFIG=ENABLE=1",
 321     "SET CPU0   CONFIG=INIT_ENABLE=1",
 322     "SET CPU0   CONFIG=STORE_SIZE=4M",
 323 
 324     "SET CPU0 CONFIG=PORT=D",
 325     "SET CPU0   CONFIG=ASSIGNMENT=3",
 326     "SET CPU0   CONFIG=INTERLACE=0",
 327     "SET CPU0   CONFIG=ENABLE=1",
 328     "SET CPU0   CONFIG=INIT_ENABLE=1",
 329     "SET CPU0   CONFIG=STORE_SIZE=4M",
 330 
 331     // ; 0 = GCOS 1 = VMS
 332     "SET CPU0 CONFIG=MODE=Multics",
 333 
 334     "SET CPU0 CONFIG=ENABLE_CACHE=enable",
 335     "SET CPU0 CONFIG=SDWAM=enable",
 336     "SET CPU0 CONFIG=PTWAM=enable",
 337 
 338     // ; 0 = 8/70
 339     "SET CPU0 CONFIG=SPEED=0",
 340 
 341     "SET CPU0 CONFIG=DIS_ENABLE=enable",
 342     "SET CPU0 CONFIG=STEADY_CLOCK=disable",
 343     "SET CPU0 CONFIG=HALT_ON_UNIMPLEMENTED=disable",
 344     "SET CPU0 CONFIG=ENABLE_WAM=disable",
 345     "SET CPU0 CONFIG=REPORT_FAULTS=disable",
 346     "SET CPU0 CONFIG=TRO_ENABLE=enable",
 347     "SET CPU0 CONFIG=DRL_FATAL=disable",
 348     "SET CPU0 CONFIG=USEMAP=disable",
 349     "SET CPU0 CONFIG=PROM_INSTALLED=enable",
 350     "SET CPU0 CONFIG=HEX_MODE_INSTALLED=disable",
 351     "SET CPU0 CONFIG=CACHE_INSTALLED=enable",
 352     "SET CPU0 CONFIG=CLOCK_SLAVE_INSTALLED=enable",
 353 
 354 // CPU1
 355 
 356     "SET CPU1 CONFIG=FAULTBASE=Multics",
 357 
 358     "SET CPU1 CONFIG=NUM=1",
 359     // ; As per GB61-01 Operators Guide, App. A
 360     // ; switches: 4, 6, 18, 19, 20, 23, 24, 25, 26, 28
 361     "SET CPU1 CONFIG=DATA=024000717200",
 362     "SET CPU1 CONFIG=ADDRESS=000000000000",
 363 
 364     // ; enable ports 0 and 1 (scu connections)
 365     // ; portconfig: ABCD
 366     // ;   each is 3 bits addr assignment
 367     // ;           1 bit enabled
 368     // ;           1 bit sysinit enabled
 369     // ;           1 bit interlace enabled (interlace?)
 370     // ;           3 bit memory size
 371     // ;              0 - 32K
 372     // ;              1 - 64K
 373     // ;              2 - 128K
 374     // ;              3 - 256K
 375     // ;              4 - 512K
 376     // ;              5 - 1M
 377     // ;              6 - 2M
 378     // ;              7 - 4M
 379 
 380     "SET CPU1 CONFIG=PORT=A",
 381     "SET CPU1   CONFIG=ASSIGNMENT=0",
 382     "SET CPU1   CONFIG=INTERLACE=0",
 383     "SET CPU1   CONFIG=ENABLE=1",
 384     "SET CPU1   CONFIG=INIT_ENABLE=1",
 385     "SET CPU1   CONFIG=STORE_SIZE=4M",
 386 
 387     "SET CPU1 CONFIG=PORT=B",
 388     "SET CPU1   CONFIG=ASSIGNMENT=1",
 389     "SET CPU1   CONFIG=INTERLACE=0",
 390     "SET CPU1   CONFIG=ENABLE=1",
 391     "SET CPU1   CONFIG=INIT_ENABLE=1",
 392     "SET CPU1   CONFIG=STORE_SIZE=4M",
 393 
 394     "SET CPU1 CONFIG=PORT=C",
 395     "SET CPU1   CONFIG=ASSIGNMENT=2",
 396     "SET CPU1   CONFIG=INTERLACE=0",
 397     "SET CPU1   CONFIG=ENABLE=1",
 398     "SET CPU1   CONFIG=INIT_ENABLE=1",
 399     "SET CPU1   CONFIG=STORE_SIZE=4M",
 400 
 401     "SET CPU1 CONFIG=PORT=D",
 402     "SET CPU1   CONFIG=ASSIGNMENT=3",
 403     "SET CPU1   CONFIG=INTERLACE=0",
 404     "SET CPU1   CONFIG=ENABLE=1",
 405     "SET CPU1   CONFIG=INIT_ENABLE=1",
 406     "SET CPU1   CONFIG=STORE_SIZE=4M",
 407 
 408     // ; 0 = GCOS 1 = VMS
 409     "SET CPU1 CONFIG=MODE=Multics",
 410 
 411     "SET CPU1 CONFIG=ENABLE_CACHE=enable",
 412     "SET CPU1 CONFIG=SDWAM=enable",
 413     "SET CPU1 CONFIG=PTWAM=enable",
 414 
 415     // ; 0 = 8/70
 416     "SET CPU1 CONFIG=SPEED=0",
 417 
 418     "SET CPU1 CONFIG=DIS_ENABLE=enable",
 419     "SET CPU1 CONFIG=STEADY_CLOCK=disable",
 420     "SET CPU1 CONFIG=HALT_ON_UNIMPLEMENTED=disable",
 421     "SET CPU1 CONFIG=ENABLE_WAM=disable",
 422     "SET CPU1 CONFIG=REPORT_FAULTS=disable",
 423     "SET CPU1 CONFIG=TRO_ENABLE=enable",
 424     "SET CPU1 CONFIG=DRL_FATAL=disable",
 425     "SET CPU1 CONFIG=USEMAP=disable",
 426     "SET CPU1 CONFIG=PROM_INSTALLED=enable",
 427     "SET CPU1 CONFIG=HEX_MODE_INSTALLED=disable",
 428     "SET CPU1 CONFIG=CACHE_INSTALLED=enable",
 429     "SET CPU1 CONFIG=CLOCK_SLAVE_INSTALLED=enable",
 430 
 431 // CPU2
 432 
 433     "SET CPU2 CONFIG=FAULTBASE=Multics",
 434 
 435     "SET CPU2 CONFIG=NUM=2",
 436     // ; As per GB61-01 Operators Guide, App. A
 437     // ; switches: 4, 6, 18, 19, 20, 23, 24, 25, 26, 28
 438     "SET CPU2 CONFIG=DATA=024000717200",
 439     "SET CPU2 CONFIG=ADDRESS=000000000000",
 440 
 441     // ; enable ports 0 and 1 (scu connections)
 442     // ; portconfig: ABCD
 443     // ;   each is 3 bits addr assignment
 444     // ;           1 bit enabled
 445     // ;           1 bit sysinit enabled
 446     // ;           1 bit interlace enabled (interlace?)
 447     // ;           3 bit memory size
 448     // ;              0 - 32K
 449     // ;              1 - 64K
 450     // ;              2 - 128K
 451     // ;              3 - 256K
 452     // ;              4 - 512K
 453     // ;              5 - 1M
 454     // ;              6 - 2M
 455     // ;              7 - 4M
 456 
 457     "SET CPU2 CONFIG=PORT=A",
 458     "SET CPU2   CONFIG=ASSIGNMENT=0",
 459     "SET CPU2   CONFIG=INTERLACE=0",
 460     "SET CPU2   CONFIG=ENABLE=1",
 461     "SET CPU2   CONFIG=INIT_ENABLE=1",
 462     "SET CPU2   CONFIG=STORE_SIZE=4M",
 463 
 464     "SET CPU2 CONFIG=PORT=B",
 465     "SET CPU2   CONFIG=ASSIGNMENT=1",
 466     "SET CPU2   CONFIG=INTERLACE=0",
 467     "SET CPU2   CONFIG=ENABLE=1",
 468     "SET CPU2   CONFIG=INIT_ENABLE=1",
 469     "SET CPU2   CONFIG=STORE_SIZE=4M",
 470 
 471     "SET CPU2 CONFIG=PORT=C",
 472     "SET CPU2   CONFIG=ASSIGNMENT=2",
 473     "SET CPU2   CONFIG=INTERLACE=0",
 474     "SET CPU2   CONFIG=ENABLE=1",
 475     "SET CPU2   CONFIG=INIT_ENABLE=1",
 476     "SET CPU2   CONFIG=STORE_SIZE=4M",
 477 
 478     "SET CPU2 CONFIG=PORT=D",
 479     "SET CPU2   CONFIG=ASSIGNMENT=3",
 480     "SET CPU2   CONFIG=INTERLACE=0",
 481     "SET CPU2   CONFIG=ENABLE=1",
 482     "SET CPU2   CONFIG=INIT_ENABLE=1",
 483     "SET CPU2   CONFIG=STORE_SIZE=4M",
 484 
 485     // ; 0 = GCOS 1 = VMS
 486     "SET CPU2 CONFIG=MODE=Multics",
 487 
 488     "SET CPU2 CONFIG=ENABLE_CACHE=enable",
 489     "SET CPU2 CONFIG=SDWAM=enable",
 490     "SET CPU2 CONFIG=PTWAM=enable",
 491 
 492     // ; 0 = 8/70
 493     "SET CPU2 CONFIG=SPEED=0",
 494 
 495     "SET CPU2 CONFIG=DIS_ENABLE=enable",
 496     "SET CPU2 CONFIG=STEADY_CLOCK=disable",
 497     "SET CPU2 CONFIG=HALT_ON_UNIMPLEMENTED=disable",
 498     "SET CPU2 CONFIG=ENABLE_WAM=disable",
 499     "SET CPU2 CONFIG=REPORT_FAULTS=disable",
 500     "SET CPU2 CONFIG=TRO_ENABLE=enable",
 501     "SET CPU2 CONFIG=DRL_FATAL=disable",
 502     "SET CPU2 CONFIG=USEMAP=disable",
 503     "SET CPU2 CONFIG=PROM_INSTALLED=enable",
 504     "SET CPU2 CONFIG=HEX_MODE_INSTALLED=disable",
 505     "SET CPU2 CONFIG=CACHE_INSTALLED=enable",
 506     "SET CPU2 CONFIG=CLOCK_SLAVE_INSTALLED=enable",
 507 
 508 // CPU3
 509 
 510     "SET CPU3 CONFIG=FAULTBASE=Multics",
 511 
 512     "SET CPU3 CONFIG=NUM=3",
 513     // ; As per GB61-01 Operators Guide, App. A
 514     // ; switches: 4, 6, 18, 19, 20, 23, 24, 25, 26, 28
 515     "SET CPU3 CONFIG=DATA=024000717200",
 516     "SET CPU3 CONFIG=ADDRESS=000000000000",
 517 
 518     // ; enable ports 0 and 1 (scu connections)
 519     // ; portconfig: ABCD
 520     // ;   each is 3 bits addr assignment
 521     // ;           1 bit enabled
 522     // ;           1 bit sysinit enabled
 523     // ;           1 bit interlace enabled (interlace?)
 524     // ;           3 bit memory size
 525     // ;              0 - 32K
 526     // ;              1 - 64K
 527     // ;              2 - 128K
 528     // ;              3 - 256K
 529     // ;              4 - 512K
 530     // ;              5 - 1M
 531     // ;              6 - 2M
 532     // ;              7 - 4M
 533 
 534     "SET CPU3 CONFIG=PORT=A",
 535     "SET CPU3   CONFIG=ASSIGNMENT=0",
 536     "SET CPU3   CONFIG=INTERLACE=0",
 537     "SET CPU3   CONFIG=ENABLE=1",
 538     "SET CPU3   CONFIG=INIT_ENABLE=1",
 539     "SET CPU3   CONFIG=STORE_SIZE=4M",
 540 
 541     "SET CPU3 CONFIG=PORT=B",
 542     "SET CPU3   CONFIG=ASSIGNMENT=1",
 543     "SET CPU3   CONFIG=INTERLACE=0",
 544     "SET CPU3   CONFIG=ENABLE=1",
 545     "SET CPU3   CONFIG=INIT_ENABLE=1",
 546     "SET CPU3   CONFIG=STORE_SIZE=4M",
 547 
 548     "SET CPU3 CONFIG=PORT=C",
 549     "SET CPU3   CONFIG=ASSIGNMENT=2",
 550     "SET CPU3   CONFIG=INTERLACE=0",
 551     "SET CPU3   CONFIG=ENABLE=1",
 552     "SET CPU3   CONFIG=INIT_ENABLE=1",
 553     "SET CPU3   CONFIG=STORE_SIZE=4M",
 554 
 555     "SET CPU3 CONFIG=PORT=D",
 556     "SET CPU3   CONFIG=ASSIGNMENT=3",
 557     "SET CPU3   CONFIG=INTERLACE=0",
 558     "SET CPU3   CONFIG=ENABLE=1",
 559     "SET CPU3   CONFIG=INIT_ENABLE=1",
 560     "SET CPU3   CONFIG=STORE_SIZE=4M",
 561 
 562     // ; 0 = GCOS 1 = VMS
 563     "SET CPU3 CONFIG=MODE=Multics",
 564 
 565     "SET CPU3 CONFIG=ENABLE_CACHE=enable",
 566     "SET CPU3 CONFIG=SDWAM=enable",
 567     "SET CPU3 CONFIG=PTWAM=enable",
 568 
 569     // ; 0 = 8/70
 570     "SET CPU3 CONFIG=SPEED=0",
 571 
 572     "SET CPU3 CONFIG=DIS_ENABLE=enable",
 573     "SET CPU3 CONFIG=STEADY_CLOCK=disable",
 574     "SET CPU3 CONFIG=HALT_ON_UNIMPLEMENTED=disable",
 575     "SET CPU3 CONFIG=ENABLE_WAM=disable",
 576     "SET CPU3 CONFIG=REPORT_FAULTS=disable",
 577     "SET CPU3 CONFIG=TRO_ENABLE=enable",
 578     "SET CPU3 CONFIG=DRL_FATAL=disable",
 579     "SET CPU3 CONFIG=USEMAP=disable",
 580     "SET CPU3 CONFIG=PROM_INSTALLED=enable",
 581     "SET CPU3 CONFIG=HEX_MODE_INSTALLED=disable",
 582     "SET CPU3 CONFIG=CACHE_INSTALLED=enable",
 583     "SET CPU3 CONFIG=CLOCK_SLAVE_INSTALLED=enable",
 584 
 585 // CPU4
 586 
 587     "SET CPU4 CONFIG=FAULTBASE=Multics",
 588 
 589     "SET CPU4 CONFIG=NUM=4",
 590     // ; As per GB61-01 Operators Guide, App. A
 591     // ; switches: 4, 6, 18, 19, 20, 23, 24, 25, 26, 28
 592     "SET CPU4 CONFIG=DATA=024000717200",
 593     "SET CPU4 CONFIG=ADDRESS=000000000000",
 594 
 595     // ; enable ports 0 and 1 (scu connections)
 596     // ; portconfig: ABCD
 597     // ;   each is 3 bits addr assignment
 598     // ;           1 bit enabled
 599     // ;           1 bit sysinit enabled
 600     // ;           1 bit interlace enabled (interlace?)
 601     // ;           3 bit memory size
 602     // ;              0 - 32K
 603     // ;              1 - 64K
 604     // ;              2 - 128K
 605     // ;              3 - 256K
 606     // ;              4 - 512K
 607     // ;              5 - 1M
 608     // ;              6 - 2M
 609     // ;              7 - 4M
 610 
 611     "SET CPU4 CONFIG=PORT=A",
 612     "SET CPU4   CONFIG=ASSIGNMENT=0",
 613     "SET CPU4   CONFIG=INTERLACE=0",
 614     "SET CPU4   CONFIG=ENABLE=1",
 615     "SET CPU4   CONFIG=INIT_ENABLE=1",
 616     "SET CPU4   CONFIG=STORE_SIZE=4M",
 617 
 618     "SET CPU4 CONFIG=PORT=B",
 619     "SET CPU4   CONFIG=ASSIGNMENT=1",
 620     "SET CPU4   CONFIG=INTERLACE=0",
 621     "SET CPU4   CONFIG=ENABLE=1",
 622     "SET CPU4   CONFIG=INIT_ENABLE=1",
 623     "SET CPU4   CONFIG=STORE_SIZE=4M",
 624 
 625     "SET CPU4 CONFIG=PORT=C",
 626     "SET CPU4   CONFIG=ASSIGNMENT=2",
 627     "SET CPU4   CONFIG=INTERLACE=0",
 628     "SET CPU4   CONFIG=ENABLE=1",
 629     "SET CPU4   CONFIG=INIT_ENABLE=1",
 630     "SET CPU4   CONFIG=STORE_SIZE=4M",
 631 
 632     "SET CPU4 CONFIG=PORT=D",
 633     "SET CPU4   CONFIG=ASSIGNMENT=3",
 634     "SET CPU4   CONFIG=INTERLACE=0",
 635     "SET CPU4   CONFIG=ENABLE=1",
 636     "SET CPU4   CONFIG=INIT_ENABLE=1",
 637     "SET CPU4   CONFIG=STORE_SIZE=4M",
 638 
 639     // ; 0 = GCOS 1 = VMS
 640     "SET CPU4 CONFIG=MODE=Multics",
 641 
 642     "SET CPU4 CONFIG=ENABLE_CACHE=enable",
 643     "SET CPU4 CONFIG=SDWAM=enable",
 644     "SET CPU4 CONFIG=PTWAM=enable",
 645 
 646     // ; 0 = 8/70
 647     "SET CPU4 CONFIG=SPEED=0",
 648 
 649     "SET CPU4 CONFIG=DIS_ENABLE=enable",
 650     "SET CPU4 CONFIG=STEADY_CLOCK=disable",
 651     "SET CPU4 CONFIG=HALT_ON_UNIMPLEMENTED=disable",
 652     "SET CPU4 CONFIG=ENABLE_WAM=disable",
 653     "SET CPU4 CONFIG=REPORT_FAULTS=disable",
 654     "SET CPU4 CONFIG=TRO_ENABLE=enable",
 655     "SET CPU4 CONFIG=DRL_FATAL=disable",
 656     "SET CPU4 CONFIG=USEMAP=disable",
 657     "SET CPU4 CONFIG=PROM_INSTALLED=enable",
 658     "SET CPU4 CONFIG=HEX_MODE_INSTALLED=disable",
 659     "SET CPU4 CONFIG=CACHE_INSTALLED=enable",
 660     "SET CPU4 CONFIG=CLOCK_SLAVE_INSTALLED=enable",
 661 
 662 // CPU5
 663 
 664     "SET CPU5 CONFIG=FAULTBASE=Multics",
 665 
 666     "SET CPU5 CONFIG=NUM=5",
 667     // ; As per GB61-01 Operators Guide, App. A
 668     // ; switches: 4, 6, 18, 19, 20, 23, 24, 25, 26, 28
 669     "SET CPU5 CONFIG=DATA=024000717200",
 670     "SET CPU5 CONFIG=ADDRESS=000000000000",
 671 
 672     // ; enable ports 0 and 1 (scu connections)
 673     // ; portconfig: ABCD
 674     // ;   each is 3 bits addr assignment
 675     // ;           1 bit enabled
 676     // ;           1 bit sysinit enabled
 677     // ;           1 bit interlace enabled (interlace?)
 678     // ;           3 bit memory size
 679     // ;              0 - 32K
 680     // ;              1 - 64K
 681     // ;              2 - 128K
 682     // ;              3 - 256K
 683     // ;              4 - 512K
 684     // ;              5 - 1M
 685     // ;              6 - 2M
 686     // ;              7 - 4M
 687 
 688     "SET CPU5 CONFIG=PORT=A",
 689     "SET CPU5   CONFIG=ASSIGNMENT=0",
 690     "SET CPU5   CONFIG=INTERLACE=0",
 691     "SET CPU5   CONFIG=ENABLE=1",
 692     "SET CPU5   CONFIG=INIT_ENABLE=1",
 693     "SET CPU5   CONFIG=STORE_SIZE=4M",
 694 
 695     "SET CPU5 CONFIG=PORT=B",
 696     "SET CPU5   CONFIG=ASSIGNMENT=1",
 697     "SET CPU5   CONFIG=INTERLACE=0",
 698     "SET CPU5   CONFIG=ENABLE=1",
 699     "SET CPU5   CONFIG=INIT_ENABLE=1",
 700     "SET CPU5   CONFIG=STORE_SIZE=4M",
 701 
 702     "SET CPU5 CONFIG=PORT=C",
 703     "SET CPU5   CONFIG=ASSIGNMENT=2",
 704     "SET CPU5   CONFIG=INTERLACE=0",
 705     "SET CPU5   CONFIG=ENABLE=1",
 706     "SET CPU5   CONFIG=INIT_ENABLE=1",
 707     "SET CPU5   CONFIG=STORE_SIZE=4M",
 708 
 709     "SET CPU5 CONFIG=PORT=D",
 710     "SET CPU5   CONFIG=ASSIGNMENT=3",
 711     "SET CPU5   CONFIG=INTERLACE=0",
 712     "SET CPU5   CONFIG=ENABLE=1",
 713     "SET CPU5   CONFIG=INIT_ENABLE=1",
 714     "SET CPU5   CONFIG=STORE_SIZE=4M",
 715 
 716     // ; 0 = GCOS 1 = VMS
 717     "SET CPU5 CONFIG=MODE=Multics",
 718 
 719     "SET CPU5 CONFIG=ENABLE_CACHE=enable",
 720     "SET CPU5 CONFIG=SDWAM=enable",
 721     "SET CPU5 CONFIG=PTWAM=enable",
 722 
 723     // ; 0 = 8/70
 724     "SET CPU5 CONFIG=SPEED=0",
 725 
 726     "SET CPU5 CONFIG=DIS_ENABLE=enable",
 727     "SET CPU5 CONFIG=STEADY_CLOCK=disable",
 728     "SET CPU5 CONFIG=HALT_ON_UNIMPLEMENTED=disable",
 729     "SET CPU5 CONFIG=ENABLE_WAM=disable",
 730     "SET CPU5 CONFIG=REPORT_FAULTS=disable",
 731     "SET CPU5 CONFIG=TRO_ENABLE=enable",
 732     "SET CPU5 CONFIG=DRL_FATAL=disable",
 733     "SET CPU5 CONFIG=USEMAP=disable",
 734     "SET CPU5 CONFIG=PROM_INSTALLED=enable",
 735     "SET CPU5 CONFIG=HEX_MODE_INSTALLED=disable",
 736     "SET CPU5 CONFIG=CACHE_INSTALLED=enable",
 737     "SET CPU5 CONFIG=CLOCK_SLAVE_INSTALLED=enable",
 738 
 739 
 740 
 741 
 742 
 743 
 744 
 745 
 746 
 747 
 748 
 749 
 750 
 751 
 752 
 753 
 754 
 755 
 756 
 757 
 758 
 759 
 760 
 761 
 762 
 763 
 764 
 765 
 766 
 767 
 768 
 769 
 770 
 771 
 772 
 773 
 774 
 775 
 776 
 777 
 778 
 779 
 780 
 781 
 782 
 783 
 784 
 785 
 786 
 787 
 788 
 789 
 790 
 791 
 792 
 793 
 794 
 795 
 796 
 797 
 798 
 799 
 800 
 801 
 802 
 803 
 804 
 805 
 806 
 807 
 808 
 809 
 810 
 811 
 812 
 813 
 814 
 815 
 816 
 817 
 818 
 819 
 820 
 821 
 822 
 823 
 824 
 825 
 826 
 827 
 828 
 829 
 830 
 831 
 832 
 833 
 834 
 835 
 836 
 837 
 838 
 839 
 840 
 841 
 842 
 843 
 844 
 845 
 846 
 847 
 848 
 849 
 850 
 851 
 852 
 853 
 854 
 855 
 856 
 857 
 858 
 859 
 860 
 861 
 862 
 863 
 864 
 865 
 866 
 867 
 868 
 869 
 870 
 871 
 872 
 873 
 874 
 875 
 876 
 877 
 878 
 879 
 880 
 881 
 882 
 883 
 884 
 885 
 886 
 887 
 888 
 889 
 890 
 891 
 892 
 893 
 894 
 895 
 896 
 897 
 898 
 899 
 900 // IOM0
 901 
 902     "SET IOM0 CONFIG=IOM_BASE=Multics",
 903     "SET IOM0 CONFIG=MULTIPLEX_BASE=0120",
 904     "SET IOM0 CONFIG=OS=Multics",
 905     "SET IOM0 CONFIG=BOOT=tape",
 906     "SET IOM0 CONFIG=TAPECHAN=012",
 907     "SET IOM0 CONFIG=CARDCHAN=011",
 908     "SET IOM0 CONFIG=SCUPORT=0",
 909 
 910     "SET IOM0 CONFIG=PORT=0",
 911     "SET IOM0   CONFIG=ADDR=0",
 912     "SET IOM0   CONFIG=INTERLACE=0",
 913     "SET IOM0   CONFIG=ENABLE=1",
 914     "SET IOM0   CONFIG=INITENABLE=0",
 915     "SET IOM0   CONFIG=HALFSIZE=0",
 916     "SET IOM0   CONFIG=STORE_SIZE=4M",
 917 
 918     "SET IOM0 CONFIG=PORT=1",
 919     "SET IOM0   CONFIG=ADDR=1",
 920     "SET IOM0   CONFIG=INTERLACE=0",
 921     "SET IOM0   CONFIG=ENABLE=1",
 922     "SET IOM0   CONFIG=INITENABLE=0",
 923     "SET IOM0   CONFIG=HALFSIZE=0",
 924     "SET IOM0   CONFIG=STORE_SIZE=4M",
 925 
 926     "SET IOM0 CONFIG=PORT=2",
 927     "SET IOM0   CONFIG=ADDR=2",
 928     "SET IOM0   CONFIG=INTERLACE=0",
 929     "SET IOM0   CONFIG=ENABLE=1",
 930     "SET IOM0   CONFIG=INITENABLE=0",
 931     "SET IOM0   CONFIG=HALFSIZE=0",
 932     "SET IOM0   CONFIG=STORE_SIZE=4M",
 933 
 934     "SET IOM0 CONFIG=PORT=3",
 935     "SET IOM0   CONFIG=ADDR=3",
 936     "SET IOM0   CONFIG=INTERLACE=0",
 937     "SET IOM0   CONFIG=ENABLE=1",
 938     "SET IOM0   CONFIG=INITENABLE=0",
 939     "SET IOM0   CONFIG=HALFSIZE=0",
 940     "SET IOM0   CONFIG=STORE_SIZE=4M",
 941 
 942     "SET IOM0 CONFIG=PORT=4",
 943     "SET IOM0   CONFIG=ENABLE=0",
 944 
 945     "SET IOM0 CONFIG=PORT=5",
 946     "SET IOM0   CONFIG=ENABLE=0",
 947 
 948     "SET IOM0 CONFIG=PORT=6",
 949     "SET IOM0   CONFIG=ENABLE=0",
 950 
 951     "SET IOM0 CONFIG=PORT=7",
 952     "SET IOM0   CONFIG=ENABLE=0",
 953 
 954 // IOM1
 955 
 956     "SET IOM1 CONFIG=IOM_BASE=Multics2",
 957     "SET IOM1 CONFIG=MULTIPLEX_BASE=0121",
 958     "SET IOM1 CONFIG=OS=Multics",
 959     "SET IOM1 CONFIG=BOOT=tape",
 960     "SET IOM1 CONFIG=TAPECHAN=012",
 961     "SET IOM1 CONFIG=CARDCHAN=011",
 962     "SET IOM1 CONFIG=SCUPORT=0",
 963 
 964     "SET IOM1 CONFIG=PORT=0",
 965     "SET IOM1   CONFIG=ADDR=0",
 966     "SET IOM1   CONFIG=INTERLACE=0",
 967     "SET IOM1   CONFIG=ENABLE=1",
 968     "SET IOM1   CONFIG=INITENABLE=0",
 969     "SET IOM1   CONFIG=HALFSIZE=0",
 970 
 971     "SET IOM1 CONFIG=PORT=1",
 972     "SET IOM1   CONFIG=ADDR=1",
 973     "SET IOM1   CONFIG=INTERLACE=0",
 974     "SET IOM1   CONFIG=ENABLE=1",
 975     "SET IOM1   CONFIG=INITENABLE=0",
 976     "SET IOM1   CONFIG=HALFSIZE=0",
 977 
 978     "SET IOM1 CONFIG=PORT=2",
 979     "SET IOM1   CONFIG=ENABLE=0",
 980     "SET IOM1 CONFIG=PORT=3",
 981     "SET IOM1   CONFIG=ENABLE=0",
 982     "SET IOM1 CONFIG=PORT=4",
 983     "SET IOM1   CONFIG=ENABLE=0",
 984     "SET IOM1 CONFIG=PORT=5",
 985     "SET IOM1   CONFIG=ENABLE=0",
 986     "SET IOM1 CONFIG=PORT=6",
 987     "SET IOM1   CONFIG=ENABLE=0",
 988     "SET IOM1 CONFIG=PORT=7",
 989     "SET IOM1   CONFIG=ENABLE=0",
 990 
 991 
 992 
 993 
 994 
 995 
 996 
 997 
 998 
 999 
1000 
1001 
1002 
1003 
1004 
1005 
1006 
1007 
1008 
1009 
1010 
1011 
1012 
1013 
1014 
1015 
1016 
1017 
1018 
1019 
1020 
1021 
1022 
1023 
1024 
1025 
1026 
1027 
1028 
1029 
1030 
1031 
1032 
1033 
1034 
1035 
1036 
1037 
1038 
1039 
1040 
1041 
1042 
1043 
1044 
1045 
1046 
1047 
1048 
1049 
1050 
1051 
1052 
1053 
1054 
1055 
1056 
1057 
1058 
1059 
1060 
1061 
1062 
1063 
1064 
1065 
1066 
1067 
1068 // SCU0
1069 
1070     "SET SCU0 CONFIG=MODE=program",
1071     "SET SCU0 CONFIG=PORT0=enable",
1072     "SET SCU0 CONFIG=PORT1=enable",
1073     "SET SCU0 CONFIG=PORT2=enable",
1074     "SET SCU0 CONFIG=PORT3=enable",
1075     "SET SCU0 CONFIG=PORT4=enable",
1076     "SET SCU0 CONFIG=PORT5=enable",
1077     "SET SCU0 CONFIG=PORT6=enable",
1078     "SET SCU0 CONFIG=PORT7=enable",
1079     "SET SCU0 CONFIG=MASKA=7",
1080     "SET SCU0 CONFIG=MASKB=off",
1081     "SET SCU0 CONFIG=LWRSTORESIZE=7",
1082     "SET SCU0 CONFIG=CYCLIC=0040",
1083     "SET SCU0 CONFIG=NEA=0200",
1084     "SET SCU0 CONFIG=ONL=014",
1085     "SET SCU0 CONFIG=INT=0",
1086     "SET SCU0 CONFIG=LWR=0",
1087     "SET SCU0 CONFIG=CLOCK_DELTA=0",
1088 
1089 // SCU1
1090 
1091     "SET SCU1 CONFIG=MODE=program",
1092     "SET SCU1 CONFIG=PORT0=enable",
1093     "SET SCU1 CONFIG=PORT1=enable",
1094     "SET SCU1 CONFIG=PORT2=enable",
1095     "SET SCU1 CONFIG=PORT3=enable",
1096     "SET SCU1 CONFIG=PORT4=enable",
1097     "SET SCU1 CONFIG=PORT5=enable",
1098     "SET SCU1 CONFIG=PORT6=enable",
1099     "SET SCU1 CONFIG=PORT7=enable",
1100     "SET SCU1 CONFIG=MASKA=off",
1101     "SET SCU1 CONFIG=MASKB=off",
1102     "SET SCU1 CONFIG=LWRSTORESIZE=7",
1103     "SET SCU1 CONFIG=CYCLIC=0040",
1104     "SET SCU1 CONFIG=NEA=0200",
1105     "SET SCU1 CONFIG=ONL=014",
1106     "SET SCU1 CONFIG=INT=0",
1107     "SET SCU1 CONFIG=LWR=0",
1108     "SET SCU1 CONFIG=CLOCK_DELTA=0",
1109 
1110 // SCU2
1111 
1112     "SET SCU2 CONFIG=MODE=program",
1113     "SET SCU2 CONFIG=PORT0=enable",
1114     "SET SCU2 CONFIG=PORT1=enable",
1115     "SET SCU2 CONFIG=PORT2=enable",
1116     "SET SCU2 CONFIG=PORT3=enable",
1117     "SET SCU2 CONFIG=PORT4=enable",
1118     "SET SCU2 CONFIG=PORT5=enable",
1119     "SET SCU2 CONFIG=PORT6=enable",
1120     "SET SCU2 CONFIG=PORT7=enable",
1121     "SET SCU2 CONFIG=MASKA=off",
1122     "SET SCU2 CONFIG=MASKB=off",
1123     "SET SCU2 CONFIG=LWRSTORESIZE=7",
1124     "SET SCU2 CONFIG=CYCLIC=0040",
1125     "SET SCU2 CONFIG=NEA=0200",
1126     "SET SCU2 CONFIG=ONL=014",
1127     "SET SCU2 CONFIG=INT=0",
1128     "SET SCU2 CONFIG=LWR=0",
1129     "SET SCU2 CONFIG=CLOCK_DELTA=0",
1130 
1131 // SCU3
1132 
1133     "SET SCU3 CONFIG=MODE=program",
1134     "SET SCU3 CONFIG=PORT0=enable",
1135     "SET SCU3 CONFIG=PORT1=enable",
1136     "SET SCU3 CONFIG=PORT2=enable",
1137     "SET SCU3 CONFIG=PORT3=enable",
1138     "SET SCU3 CONFIG=PORT4=enable",
1139     "SET SCU3 CONFIG=PORT5=enable",
1140     "SET SCU3 CONFIG=PORT6=enable",
1141     "SET SCU3 CONFIG=PORT7=enable",
1142     "SET SCU3 CONFIG=MASKA=off",
1143     "SET SCU3 CONFIG=MASKB=off",
1144     "SET SCU3 CONFIG=LWRSTORESIZE=7",
1145     "SET SCU3 CONFIG=CYCLIC=0040",
1146     "SET SCU3 CONFIG=NEA=0200",
1147     "SET SCU3 CONFIG=ONL=014",
1148     "SET SCU3 CONFIG=INT=0",
1149     "SET SCU3 CONFIG=LWR=0",
1150     "SET SCU3 CONFIG=CLOCK_DELTA=0",
1151 
1152 
1153 
1154 
1155 
1156 
1157 
1158 
1159 
1160 
1161 
1162 
1163 
1164 
1165 
1166 
1167 
1168 
1169 
1170 
1171 
1172 
1173 
1174 
1175 
1176 
1177 
1178 
1179 
1180 
1181 
1182 
1183 
1184 
1185 
1186 
1187 
1188 
1189 
1190 
1191 
1192 
1193 
1194 
1195 
1196 
1197 
1198 
1199 
1200 
1201 
1202 
1203 
1204 
1205 
1206 
1207 
1208 
1209 
1210 
1211 
1212 
1213 
1214 
1215 
1216 
1217 
1218 
1219 
1220 
1221 
1222 
1223 
1224 
1225 
1226 
1227 
1228 
1229 
1230 
1231 
1232 
1233 
1234 
1235 
1236 
1237 
1238     // ; DO NOT CHANGE THE CONFIGURATION OF THE FNP UNITS.
1239     // ; Restrictions in the FNP code that REQUIRE the simulator
1240     // ; unit numbers to be the same as the Multics unit numbers!
1241     // ; i.e. fnp0 == fnpa, etc.
1242     // ;
1243     // ; FNP a 3400
1244     // ; FNP b 3700
1245     // ; FNP c 4200
1246     // ; FNP d 4500
1247     // ; FNP e 5000
1248     // ; FNP f 5300
1249     // ; FNP g 5600
1250     // ; FNP h 6100
1251 
1252     "SET FNP0 CONFIG=MAILBOX=03400",
1253     "SET FNP0 IPC_NAME=fnp-a",
1254     "SET FNP1 CONFIG=MAILBOX=03700",
1255     "SET FNP1 IPC_NAME=fnp-b",
1256     "SET FNP2 CONFIG=MAILBOX=04200",
1257     "SET FNP2 IPC_NAME=fnp-c",
1258     "SET FNP3 CONFIG=MAILBOX=04500",
1259     "SET FNP3 IPC_NAME=fnp-d",
1260     "SET FNP4 CONFIG=MAILBOX=05000",
1261     "SET FNP4 IPC_NAME=fnp-e",
1262     "SET FNP5 CONFIG=MAILBOX=05300",
1263     "SET FNP5 IPC_NAME=fnp-f",
1264     "SET FNP6 CONFIG=MAILBOX=05600",
1265     "SET FNP6 IPC_NAME=fnp-g",
1266     "SET FNP7 CONFIG=MAILBOX=06100",
1267     "SET FNP7 IPC_NAME=fnp-h",
1268 
1269     //XXX"set mtp0 boot_drive=1",
1270     // ; Attach tape MPC to IOM 0, chan 012, dev_code 0
1271     "SET MTP0 BOOT_DRIVE=0",
1272     "SET MTP0 NAME=MTP0",
1273     // ; Attach TAPE unit 0 to IOM 0, chan 012, dev_code 1
1274     "CABLE IOM0 012 MTP0 0",
1275     "CABLE IOM1 012 MTP0 1",
1276     "CABLE MTP0 1 TAPE1",
1277     "SET TAPE1 NAME=tapa_01",
1278     "CABLE MTP0 2 TAPE2",
1279     "SET TAPE2 NAME=tapa_02",
1280     "CABLE MTP0 3 TAPE3",
1281     "SET TAPE3 NAME=tapa_03",
1282     "CABLE MTP0 4 TAPE4",
1283     "SET TAPE4 NAME=tapa_04",
1284     "CABLE MTP0 5 TAPE5",
1285     "SET TAPE5 NAME=tapa_05",
1286     "CABLE MTP0 6 TAPE6",
1287     "SET TAPE6 NAME=tapa_06",
1288     "CABLE MTP0 7 TAPE7",
1289     "SET TAPE7 NAME=tapa_07",
1290     "CABLE MTP0 8 TAPE8",
1291     "SET TAPE8 NAME=tapa_08",
1292     "CABLE MTP0 9 TAPE9",
1293     "SET TAPE9 NAME=tapa_09",
1294     "CABLE MTP0 10 TAPE10",
1295     "SET TAPE10 NAME=tapa_10",
1296     "CABLE MTP0 11 TAPE11",
1297     "SET TAPE11 NAME=tapa_11",
1298     "CABLE MTP0 12 TAPE12",
1299     "SET TAPE12 NAME=tapa_12",
1300     "CABLE MTP0 13 TAPE13",
1301     "SET TAPE13 NAME=tapa_13",
1302     "CABLE MTP0 14 TAPE14",
1303     "SET TAPE14 NAME=tapa_14",
1304     "CABLE MTP0 15 TAPE15",
1305     "SET TAPE15 NAME=tapa_15",
1306     "CABLE MTP0 16 TAPE16",
1307     "SET TAPE16 NAME=tapa_16",
1308 
1309 // 4 3381 disks
1310 
1311     "SET IPC0 NAME=IPC0",
1312     "CABLE IOM0 013 IPC0 0",
1313     "CABLE IOM1 013 IPC0 1",
1314     // ; Attach DISK unit 0 to IPC0 dev_code 0",
1315     "CABLE IPC0 0 DISK0",
1316     "SET DISK0 TYPE=3381",
1317     "SET DISK0 NAME=dska_00",
1318     // ; Attach DISK unit 1 to IPC0 dev_code 1",
1319     "cable IPC0 1 DISK1",
1320     "set disk1 type=3381",
1321     "set disk1 name=dska_01",
1322     // ; Attach DISK unit 2 to IPC0 dev_code 2",
1323     "CABLE IPC0 2 DISK2",
1324     "SET DISK2 TYPE=3381",
1325     "SET DISK2 NAME=dska_02",
1326     // ; Attach DISK unit 3 to IPC0 dev_code 3",
1327     "CABLE IPC0 3 DISK3",
1328     "SET DISK3 TYPE=3381",
1329     "SET DISK3 NAME=dska_03",
1330 
1331 // 4 d501 disks + 4 d451 disks + 2 d500 disks
1332     "SET MSP0 NAME=MSP0",
1333     "CABLE IOM0 014 MSP0 0",
1334     "CABLE IOM1 014 MSP0 1",
1335 
1336     // ; Attach DISK unit 4 to MSP0 dev_code 1",
1337     "CABLE MSP0 1 DISK4",
1338     "SET disk4 TYPE=d501",
1339     "SET disk4 NAME=dskb_01",
1340     // ; Attach DISK unit 5 to MSP0 dev_code 2",
1341     "CABLE MSP0 2 DISK5",
1342     "SET DISK5 TYPE=d501",
1343     "SET DISK5 NAME=dskb_02",
1344     // ; Attach DISK unit 6 to MSP0 dev_code 3",
1345     "CABLE MSP0 3 DISK6",
1346     "SET DISK6 TYPE=d501",
1347     "SET DISK6 NAME=dskb_03",
1348     // ; Attach DISK unit 7 to MSP0 dev_code 4",
1349     "CABLE MSP0 4 DISK7",
1350     "SET DISK7 TYPE=d501",
1351     "SET DISK7 NAME=dskb_04",
1352 
1353     // ; Attach DISK unit 8 to MSP0 dev_code 5",
1354     "CABLE MSP0 5 DISK8",
1355     "SET DISK8 TYPE=d451",
1356     "SET DISK8 NAME=dskb_05",
1357     // ; Attach DISK unit 9 to MSP0 dev_code 6",
1358     "CABLE MSP0 6 DISK9",
1359     "SET DISK9 TYPE=d451",
1360     "SET DISK9 NAME=dskb_06",
1361     // ; Attach DISK unit 10 to MSP0 dev_code 7",
1362     "CABLE MSP0 7 DISK10",
1363     "SET DISK10 TYPE=d451",
1364     "SET DISK10 NAME=dskb_07",
1365     // ; Attach DISK unit 11 to MSP0 dev_code 8",
1366     "CABLE MSP0 8 DISK11",
1367     "SET DISK11 TYPE=d451",
1368     "SET DISK11 NAME=dskb_08",
1369     // ; Attach DISK unit 12 to MSP0 dev_code 9",
1370     "CABLE MSP0 9 DISK12",
1371     "SET DISK12 TYPE=d500",
1372     "SET DISK12 NAME=dskb_09",
1373     // ; Attach DISK unit 13 to MSP0 dev_code 10",
1374     "CABLE MSP0 10 DISK13",
1375     "SET DISK13 TYPE=d500",
1376     "SET DISK13 NAME=dskb_10",
1377 
1378     // since we define 16 (decimal) 3381s in the default config deck, we need to add another 12
1379     // ; Attach DISK unit 14 to IPC0 dev_code 4",
1380     "CABLE IPC0 4 DISK14",
1381     "SET DISK14 TYPE=3381",
1382     "SET DISK14 NAME=dska_04",
1383     // ; Attach DISK unit 15 to IPC0 dev_code 5",
1384     "CABLE IPC0 5 DISK15",
1385     "SET DISK15 TYPE=3381",
1386     "SET DISK15 NAME=dska_05",
1387     // ; Attach DISK unit 16 to IPC0 dev_code 6",
1388     "CABLE IPC0 6 DISK16",
1389     "SET DISK16 TYPE=3381",
1390     "SET DISK16 NAME=dska_06",
1391     // ; Attach DISK unit 17 to IPC0 dev_code 7",
1392     "CABLE IPC0 7 DISK17",
1393     "SET DISK17 TYPE=3381",
1394     "SET DISK17 NAME=dska_07",
1395     // ; Attach DISK unit 18 to IPC0 dev_code 8",
1396     "CABLE IPC0 8 DISK18",
1397     "SET DISK18 TYPE=3381",
1398     "SET DISK18 NAME=dska_08",
1399     // ; Attach DISK unit 19 to IPC0 dev_code 9",
1400     "CABLE IPC0 9 DISK19",
1401     "SET DISK19 TYPE=3381",
1402     "SET DISK19 NAME=dska_09",
1403     // ; Attach DISK unit 20 to IPC0 dev_code 10",
1404     "CABLE IPC0 10 DISK20",
1405     "SET DISK20 TYPE=3381",
1406     "SET DISK20 NAME=dska_10",
1407     // ; Attach DISK unit 21 to IPC0 dev_code 11",
1408     "CABLE IPC0 11 DISK21",
1409     "SET DISK21 TYPE=3381",
1410     "SET DISK21 NAME=dska_11",
1411     // ; Attach DISK unit 22 to IPC0 dev_code 12",
1412     "CABLE IPC0 12 DISK22",
1413     "SET DISK22 TYPE=3381",
1414     "SET DISK22 NAME=dska_12",
1415     // ; Attach DISK unit 23 to IPC0 dev_code 13",
1416     "CABLE IPC0 13 DISK23",
1417     "SET DISK23 TYPE=3381",
1418     "SET DISK23 NAME=dska_13",
1419     // ; Attach DISK unit 24 to IPC0 dev_code 14",
1420     "CABLE IPC0 14 DISK24",
1421     "SET DISK24 TYPE=3381",
1422     "SET DISK24 NAME=dska_14",
1423     // ; Attach DISK unit 25 to IPC0 dev_code 15",
1424     "CABLE IPC0 15 DISK25",
1425     "SET DISK25 TYPE=3381",
1426     "SET DISK25 NAME=dska_15",
1427 
1428     // ; Attach OPC unit 0 to IOM A, chan 036, dev_code 0
1429     "CABLE IOMA 036 OPC0",
1430     // ; Attach OPC unit 1 to IOM A, chan 053, dev_code 0
1431     "CABLE IOMA 053 OPC1",
1432     "SET OPC1 CONFIG=MODEL=m6601",
1433     // No "devices" for console, so no 'CABLE OPC0 # CONx', etc.
1434 
1435     // ;;;
1436     // ;;; FNP
1437     // ;;;
1438 
1439     // ; Attach FNP unit 3 (d) to IOM A, chan 020, dev_code 0
1440     "CABLE IOMA 020 FNPD",
1441     // ; Attach FNP unit 0 (a) to IOM A, chan 021, dev_code 0
1442     "CABLE IOMA 021 FNPA",
1443     // ; Attach FNP unit 1 (b) to IOM A, chan 022, dev_code 0
1444     "CABLE IOMA 022 FNPB",
1445     // ; Attach FNP unit 2 (c) to IOM A, chan 023, dev_code 0
1446     "CABLE IOMA 023 FNPC",
1447     // ; Attach FNP unit 4 (e) to IOM A, chan 024, dev_code 0
1448     "CABLE IOMA 024 FNPE",
1449     // ; Attach FNP unit 5 (f) to IOM A, chan 025, dev_code 0
1450     "CABLE IOMA 025 FNPF",
1451     // ; Attach FNP unit 6 (g) to IOM A, chan 026, dev_code 0
1452     "CABLE IOMA 026 FNPG",
1453     // ; Attach FNP unit 7 (h) to IOM A, chan 027, dev_code 0
1454     "CABLE IOMA 027 FNPH",
1455 
1456     // ;;;
1457     // ;;; MPC
1458     // ;;;
1459 
1460     // ; Attach MPC unit 0 to IOM 0, char 015, dev_code 0
1461     "CABLE IOM0 015 URP0",
1462     "SET URP0 NAME=urpa",
1463 
1464     // ; Attach RDR unit 0 to IOM 0, chan 015, dev_code 1
1465     "CABLE URP0 1 RDR0",
1466     "SET RDR0 NAME=rdra",
1467 
1468     // ; Attach MPC unit 1 to IOM 0, char 016, dev_code 0
1469     "CABLE IOM0 016 URP1",
1470     "SET URP1 NAME=urpb",
1471 
1472     // ; Attach PUN unit 0 to IOM 0, chan 016, dev_code 1
1473     "CABLE URP1 1 PUN0",
1474     "SET PUN0 NAME=puna",
1475 
1476     // ; Attach MPC unit 2 to IOM 0, char 017, dev_code 0
1477     "CABLE IOM0 017 URP2",
1478     "SET URP2 NAME=urpc",
1479 
1480     // ; Attach PRT unit 0 to IOM 0, chan 017, dev_code 1
1481     "CABLE URP2 1 PRT0",
1482     "SET PRT0 NAME=prta",
1483 //    "SET PRT0 MODEL=1600",    // Needs polts fixes
1484 
1485     // ; Attach MPC unit 3 to IOM 0, char 050, dev_code 0
1486     "CABLE IOMA 050 URP3",
1487     "SET URP3 NAME=urpd",
1488 
1489     // ; Attach PRT unit 1 to IOM 0, chan 050, dev_code 1
1490     "CABLE URP3 1 PRT1",
1491     "SET PRT1 NAME=prtb",
1492 //    "SET PRT1 MODEL=303",    // Needs polts fixes
1493 
1494     // ; Attach MPC unit 4 to IOM 0, char 051, dev_code 0
1495     "CABLE IOMA 051 URP4",
1496     "SET URP4 NAME=urpe",
1497 
1498     // ; Attach PRT unit 2 to IOM 0, chan 051, dev_code 1
1499     "CABLE URP4 1 PRT2",
1500     "SET PRT2 NAME=prtc",
1501 //    "SET PRT2 MODEL=300",    // Needs polts fixes
1502 
1503     // ; Attach MPC unit 5 to IOM 0, chan 052, dev_code 0
1504     "CABLE IOMA 052 URP5",
1505     "SET URP5 NAME=urpf",
1506 
1507     // ; Attach PRT unit 3 to IOM 0, chan 052, dev_code 1
1508     "CABLE URP5 1 PRT3",
1509     "SET PRT3 NAME=prtd",
1510 //    "SET PRT3 MODEL=202",    // Needs polts fixes
1511 
1512     // ; Attach MPC unit 6 to IOM 0, chan 055, dev_code 0
1513     "CABLE IOMA 055 URP6",
1514     "SET URP6 NAME=urpg",
1515 
1516     // ; Attach RDR unit 1 to IOM 0, chan 055, dev_code 1
1517     "CABLE URP6 1 RDRB",
1518     "SET RDR1 NAME=rdrb",
1519 
1520     // ; Attach MPC unit 7 to IOM 0, chan 056, dev_code 0
1521     "CABLE IOMA 056 URP7",
1522     "SET URP7 NAME=urph",
1523 
1524     // ; Attach RDR unit 2 to IOM 0, chan 056, dev_code 1
1525     "CABLE URP7 1 RDRC",
1526     "SET RDR2 NAME=rdrc",
1527 
1528     // ; Attach MPC unit 8 to IOM 0, chan 057, dev_code 0
1529     "CABLE IOMA 057 URP8",
1530     "SET URP8 NAME=urpi",
1531 
1532     // ; Attach PUN unit 1 to IOM 0, chan 057, dev_code 1
1533     "CABLE URP8 1 PUNB",
1534     "SET PUN1 NAME=punb",
1535 
1536     // ; Attach MPC unit 9 to IOM 0, chan 060, dev_code 0
1537     "CABLE IOMA 060 URP9",
1538     "SET URP9 NAME=urpj",
1539 
1540     // ; Attach PUN unit 2 to IOM 0, chan 060, dev_code 1
1541     "CABLE URP9 1 PUNC",
1542     "SET PUN2 NAME=punc",
1543 
1544 # if defined(WITH_SOCKET_DEV)
1545 #  if !defined(__MINGW64__) && !defined(__MINGW32__) && !defined(CROSS_MINGW32) && !defined(CROSS_MINGW64)
1546     "CABLE IOMA 040 SKCA",
1547     "CABLE IOMA 041 SKCB",
1548     "CABLE IOMA 042 SKCC",
1549     "CABLE IOMA 043 SKCD",
1550     "CABLE IOMA 044 SKCE",
1551     "CABLE IOMA 045 SKCF",
1552     "CABLE IOMA 046 SKCG",
1553     "CABLE IOMA 047 SKCH",
1554 #  endif /* if !defined(__MINGW64__) && !defined(__MINGW32__) && !defined(CROSS_MINGW32) && !defined(CROSS_MINGW64) */
1555 # endif /* if defined(WITH_SOCKET_DEV) */
1556 
1557 
1558 
1559 
1560 
1561 
1562 
1563 
1564 
1565 
1566 
1567 
1568 
1569 
1570 
1571 
1572 
1573 
1574 
1575 
1576 
1577 
1578 
1579 
1580 
1581 
1582 
1583 
1584 
1585 
1586 
1587 
1588 
1589 
1590 
1591 
1592 
1593 
1594 
1595 
1596 
1597 
1598 
1599 
1600 
1601 
1602 
1603 
1604 
1605 
1606 
1607 
1608 
1609 
1610 
1611 
1612 
1613 
1614 
1615 
1616 
1617 
1618 
1619 
1620 
1621 # if defined(WITH_ABSI_DEV)
1622 #  if !defined(__MINGW64__) && !defined(__MINGW32__) && !defined(CROSS_MINGW64) && !defined(CROSS_MINGW32)
1623     // ; Attach ABSI unit 0 to IOM 0, chan 032, dev_code 0
1624     "CABLE IOM0 032 ABSI0",
1625 #  endif /* if !defined(__MINGW64__) && !defined(__MINGW32__) && !defined(CROSS_MINGW64) && !defined(CROSS_MINGW32) */
1626 # endif /* if defined(WITH_ABSI_DEV) */
1627 
1628 # if defined(WITH_MGP_DEV)
1629     // ; Attach MGPR unit 0 to IOM 0, chan 033, dev_code 0
1630     "CABLE IOM0 033 MGP0",
1631     // ; Attach MGPW unit 1 to IOM 0, chan 034, dev_code 0
1632     "CABLE IOM0 034 MGP1",
1633 # endif /* if defined(WITH_MGP_DEV) */
1634 
1635 # if defined(WITH_NET_DEV)
1636     // ; Attach NETR unit 0 to IOM 0, chan 061, dev_code 0
1637     "CABLE IOM0 061 NET0",
1638     // ; Attach NETW unit 1 to IOM 0, chan 062, dev_code 0
1639     "CABLE IOM0 062 NET1",
1640 # endif /* if defined(WITH_NET_DEV) */
1641 
1642     // ; Attach IOM unit 0 port A (0) to SCU unit 0, port 0
1643     "CABLE SCU0 0 IOM0 0", // SCU0 port 0 IOM0 port 0
1644 
1645     // ; Attach IOM unit 0 port B (1) to SCU unit 1, port 0
1646     "CABLE SCU1 0 IOM0 1", // SCU1 port 0 IOM0 port 1
1647 
1648     // ; Attach IOM unit 0 port C (2) to SCU unit 2, port 0
1649     "CABLE SCU2 0 IOM0 2", // SCU2 port 0 IOM0 port 2
1650 
1651     // ; Attach IOM unit 0 port D (3) to SCU unit 3, port 0
1652     "CABLE SCU3 0 IOM0 3", // SCU3 port 0 IOM0 port 3
1653 
1654     // ; Attach IOM unit 1 port A (0) to SCU unit 0, port 1
1655     "CABLE SCU0 1 IOM1 0", // SCU0 port 0 IOM0 port 0
1656 
1657     // ; Attach IOM unit 1 port B (1) to SCU unit 1, port 1
1658     "CABLE SCU1 1 IOM1 1", // SCU1 port 0 IOM0 port 1
1659 
1660     // ; Attach IOM unit 1 port C (2) to SCU unit 2, port 1
1661     "CABLE SCU2 1 IOM1 2", // SCU2 port 0 IOM0 port 2
1662 
1663     // ; Attach IOM unit 1 port D (3) to SCU unit 3, port 1
1664     "CABLE SCU3 1 IOM1 3", // SCU3 port 0 IOM0 port 3
1665 
1666 // SCU0 --> CPU0-5
1667 
1668     // ; Attach SCU unit 0 port 7 to CPU unit A (1), port 0
1669     "CABLE SCU0 7 CPU0 0",
1670 
1671     // ; Attach SCU unit 0 port 6 to CPU unit B (1), port 0
1672     "CABLE SCU0 6 CPU1 0",
1673 
1674     // ; Attach SCU unit 0 port 5 to CPU unit C (2), port 0
1675     "CABLE SCU0 5 CPU2 0",
1676 
1677     // ; Attach SCU unit 0 port 4 to CPU unit D (3), port 0
1678     "CABLE SCU0 4 CPU3 0",
1679 
1680     // ; Attach SCU unit 0 port 3 to CPU unit E (4), port 0
1681     "CABLE SCU0 3 CPU4 0",
1682 
1683     // ; Attach SCU unit 0 port 2 to CPU unit F (5), port 0
1684     "CABLE SCU0 2 CPU5 0",
1685 
1686 // SCU1 --> CPU0-5
1687 
1688     // ; Attach SCU unit 1 port 7 to CPU unit A (1), port 1
1689     "CABLE SCU1 7 CPU0 1",
1690 
1691     // ; Attach SCU unit 1 port 6 to CPU unit B (1), port 1
1692     "CABLE SCU1 6 CPU1 1",
1693 
1694     // ; Attach SCU unit 1 port 5 to CPU unit C (2), port 1
1695     "CABLE SCU1 5 CPU2 1",
1696 
1697     // ; Attach SCU unit 1 port 4 to CPU unit D (3), port 1
1698     "CABLE SCU1 4 CPU3 1",
1699 
1700     // ; Attach SCU unit 1 port 3 to CPU unit E (4), port 0
1701     "CABLE SCU1 3 CPU4 1",
1702 
1703     // ; Attach SCU unit 1 port 2 to CPU unit F (5), port 0
1704     "CABLE SCU1 2 CPU5 1",
1705 
1706 // SCU2 --> CPU0-5
1707 
1708     // ; Attach SCU unit 2 port 7 to CPU unit A (1), port 2
1709     "CABLE SCU2 7 CPU0 2",
1710 
1711     // ; Attach SCU unit 2 port 6 to CPU unit B (1), port 2
1712     "CABLE SCU2 6 CPU1 2",
1713 
1714     // ; Attach SCU unit 2 port 5 to CPU unit C (2), port 2
1715     "CABLE SCU2 5 CPU2 2",
1716 
1717     // ; Attach SCU unit 2 port 4 to CPU unit D (3), port 2
1718     "CABLE SCU2 4 CPU3 2",
1719 
1720     // ; Attach SCU unit 2 port 3 to CPU unit E (4), port 0
1721     "CABLE SCU2 3 CPU4 2",
1722 
1723     // ; Attach SCU unit 2 port 2 to CPU unit F (5), port 0
1724     "CABLE SCU2 2 CPU5 2",
1725 
1726 // SCU3 --> CPU0-5
1727 
1728     // ; Attach SCU unit 3 port 7 to CPU unit A (1), port 3
1729     "CABLE SCU3 7 CPU0 3",
1730 
1731     // ; Attach SCU unit 3 port 6 to CPU unit B (1), port 3
1732     "CABLE SCU3 6 CPU1 3",
1733 
1734     // ; Attach SCU unit 3 port 5 to CPU unit C (2), port 3
1735     "CABLE SCU3 5 CPU2 3",
1736 
1737     // ; Attach SCU unit 3 port 4 to CPU unit D (3), port 3
1738     "CABLE SCU3 4 CPU3 3",
1739 
1740     // ; Attach SCU unit 3 port 3 to CPU unit E (4), port 0
1741     "CABLE SCU3 3 CPU4 3",
1742 
1743     // ; Attach SCU unit 3 port 2 to CPU unit F (5), port 0
1744     "CABLE SCU3 2 CPU5 3",
1745 
1746     "SET CPU0 RESET",
1747     "SET SCU0 RESET",
1748     "SET SCU1 RESET",
1749     "SET SCU2 RESET",
1750     "SET SCU3 RESET",
1751     "SET IOM0 RESET",
1752 
1753 # if defined(THREADZ) || defined(LOCKLESS)
1754     "SET CPU NUNITS=6",
1755 # else
1756     "SET CPU NUNITS=1",
1757 # endif // THREADZ
1758     // "SET SYS CONFIG=ACTIVATE_TIME=8",
1759     // "SET SYS CONFIG=TERMINATE_TIME=8",
1760     "SET SYS CONFIG=CONNECT_TIME=-1",
1761   }; // default_base_system_script
1762 
1763 void print_default_base_system_script (void)
     /* [previous][next][first][last][top][bottom][index][help] */
1764   {
1765     int n_lines = sizeof (default_base_system_script) / sizeof (char *);
1766     sim_printf ("; DEFAULT_BASE_SYSTEM_SCRIPT (%lu lines follow)\r\n",
1767             (unsigned long)n_lines);
1768     for (int line = 0; line < n_lines; line ++)
1769     sim_printf ("%s\r\n", default_base_system_script[line]);
1770   }
1771 
1772 // Execute a line of script
1773 
1774 static void do_ini_line (char * text)
     /* [previous][next][first][last][top][bottom][index][help] */
1775   {
1776     //sim_msg ("<%s?\r\n", text);
1777     char gbuf[257];
1778     const char * cptr = get_glyph (text, gbuf, 0); /* get command glyph */
1779     CTAB *cmdp;
1780     if ((cmdp = find_cmd (gbuf)))            /* lookup command */
1781       {
1782         t_stat stat = cmdp->action (cmdp->arg, cptr); /* if found, exec */
1783         if (stat != SCPE_OK)
1784           sim_warn ("%s: %s\r\n", sim_error_text (SCPE_UNK), text);
1785       }
1786     else
1787       sim_warn ("%s: %s\r\n", sim_error_text (SCPE_UNK), text);
1788   }
1789 
1790 // Execute the base system script; this strings the cables
1791 // and sets the switches
1792 
1793 static t_stat set_default_base_system (UNUSED int32 arg, UNUSED const char * buf)
     /* [previous][next][first][last][top][bottom][index][help] */
1794   {
1795 # if defined(PERF_STRIP)
1796     cpu_dev.numunits = 1;
1797 # else
1798     int n_lines = sizeof (default_base_system_script) / sizeof (char *);
1799     for (int line = 0; line < n_lines; line ++)
1800       do_ini_line (default_base_system_script [line]);
1801 # endif
1802     return SCPE_OK;
1803   }
1804 
1805 // Skip records on the boot tape.
1806 // The T&D tape first record is for testing DPS8s, the
1807 // second record (1st record / tape mark / 2nd record)
1808 // is for testing DPS8/Ms.
1809 // XXX assumes the boot tape is on tape unit 0
1810 
1811 // SKIPBOOT [UNIT]: skip a record on the boot tape (default unit 0). The
1812 // T&D tape's first record is for DPS8s; the second (after the tape mark)
1813 // is for DPS8/Ms. T&D boots from drive 1 (device 0 of a tape controller
1814 // is the controller), so it needs "SKIPBOOT 1".
1815 
1816 static t_stat boot_skip (int32 UNUSED arg, const char * buf)
     /* [previous][next][first][last][top][bottom][index][help] */
1817   {
1818     uint32 skipped;
1819     uint unit = 0;
1820     if (buf && * buf && sscanf (buf, "%u", & unit) != 1)
1821       return SCPE_ARG;
1822     if (unit >= N_MT_UNITS_MAX)
1823       return SCPE_ARG;
1824     t_stat rc = sim_tape_sprecsf (& mt_unit[unit], 1, & skipped);
1825     if (rc == SCPE_OK)
1826       tape_states[unit].rec_num ++;
1827     return rc;
1828   }
1829 
1830 // Simulate pressing the 'EXECUTE FAULT' button. Used as an
1831 // emergency interrupt of Multics if it hangs and becomes
1832 // unresponsive to the operators console.
1833 
1834 static t_stat do_execute_fault (UNUSED int32 arg,  UNUSED const char * buf)
     /* [previous][next][first][last][top][bottom][index][help] */
1835   {
1836     // Assume bootload CPU
1837     setG7fault (0, FAULT_EXF);
1838     return SCPE_OK;
1839   }
1840 
1841 // EXECUTE DATA SWITCHES: execute the instruction in the data switches
1842 // (set them first, e.g. "set cpu0 config=data=000124717000" for XED 124)
1843 
1844 static t_stat do_execute_switches (UNUSED int32 arg,  UNUSED const char * buf)
     /* [previous][next][first][last][top][bottom][index][help] */
1845   {
1846     // Assume bootload CPU
1847     press_execute_switches (0);
1848     return SCPE_OK;
1849   }
1850 
1851 // Simulate pressing the 'XED 10000' sequence; this starts BCE
1852 //
1853 //  sim> restart
1854 //  sim> go
1855 
1856 static t_stat do_restart (UNUSED int32 arg,  UNUSED const char * buf)
     /* [previous][next][first][last][top][bottom][index][help] */
1857   {
1858     if (sim_is_running)
1859       {
1860         sim_printf ("Don't restart a running system....\r\n");
1861         return SCPE_ARG;
1862       }
1863     int n = 010000; //-V536
1864     if (buf)
1865       {
1866         n = (int) strtol (buf, NULL, 0);
1867       }
1868     sim_printf ("Restart entry 0%o\r\n", n);
1869 
1870     cpu_state_t * cpup = _cpup;
1871 
1872 
1873 
1874 
1875 
1876 
1877 
1878 
1879 
1880 
1881 
1882 
1883 
1884     cpu_reset_unit_idx (0, false);
1885     cpu.restart         = true;
1886     cpu.restart_address = (uint) n;
1887 
1888     t_stat rc = run_cmd (RU_CONT, "");
1889     return rc;
1890   }
1891 
1892 static t_stat set_sys_polling_interval (UNUSED int32 arg, const char * buf)
     /* [previous][next][first][last][top][bottom][index][help] */
1893   {
1894     if (! buf)
1895       return SCPE_ARG;
1896     int n = atoi (buf);
1897     if (n < 1 || n > 1000) // 1 millisecond to 1 second
1898       {
1899         sim_printf ("POLL %d: must be 1 (1 millisecond) to 1000 (1 second)\r\n", n);
1900         return SCPE_ARG;
1901       }
1902     sim_printf ("Polling set to %d milliseconds\r\n", n);
1903     sys_opts.sys_poll_interval = (uint) n;
1904     return SCPE_OK;
1905   }
1906 
1907 static t_stat set_sys_slow_polling_interval (UNUSED int32 arg, const char * buf)
     /* [previous][next][first][last][top][bottom][index][help] */
1908   {
1909     if (! buf)
1910       return SCPE_ARG;
1911     int n = atoi (buf);
1912     if (n < 1 || n > 1000) // 1 - slow poll every pool; 1000 - slow poll every 1000 polls
1913       {
1914         sim_printf ("SLOWPOLL %d: must be 1 (1 slow poll per pol) to 1000 (1 slow poll per 1000 polls)\r\n", n);
1915         return SCPE_ARG;
1916       }
1917     sim_printf ("Slow polling set to %d polls\r\n", n);
1918     sys_opts.sys_slow_poll_interval = (uint) n;
1919     return SCPE_OK;
1920   }
1921 
1922 static t_stat set_sys_poll_check_rate (UNUSED int32 arg, const char * buf)
     /* [previous][next][first][last][top][bottom][index][help] */
1923   {
1924     if (! buf)
1925       return SCPE_ARG;
1926     int n = atoi (buf);
1927     if (n < 1 || n > 1024*1024) // 1 - poll check rate in CPY cycles: 1 - check every cycle; 1024 check every 1024 cycles
1928       {
1929         sim_printf ("CHECKPOLL %d: must be 1 (check every cycle) to 1048576 (check every million cycles\r\n", n);
1930         return SCPE_ARG;
1931       }
1932     sim_printf ("Poll check rate set to %d CPU cycles\r\n", n);
1933     sys_opts.sys_poll_check_rate = (uint) n;
1934     return SCPE_OK;
1935   }
1936 #endif /* if !defined(PERF_STRIP) */
1937 
1938 //
1939 // Debugging commands
1940 //
1941 
1942 #if defined(TESTING)
1943 
1944 // Filter settings for our customized sim_debug
1945 
1946 // Start debug output at CPU cycle N.
1947 uint64 sim_deb_start      = 0;
1948 // Stop debug output at CPU cycle N.
1949 uint64 sim_deb_stop       = 0;
1950 // Break to scp prompt at CPU cycle N.
1951 uint64 sim_deb_break      = 0;
1952 // Enable CPU sim_debug iff PPR.PSR == N
1953 bool sim_deb_segno_on     = false;
1954 # if defined(NO_C_ELLIPSIS)
1955 bool sim_deb_segno[DEBUG_SEGNO_LIMIT];
1956 # else
1957 bool sim_deb_segno[DEBUG_SEGNO_LIMIT] = { [0 ... DEBUG_SEGNO_LIMIT - 1] = false };
1958 # endif
1959 // Enable CPU sim_debug iff PPR.PRR == N
1960 uint64 sim_deb_ringno     = NO_SUCH_RINGNO;
1961 // Suppress CPU sim_debug calls that pass all
1962 // of the filters after N times
1963 uint64 sim_deb_skip_limit = 0;
1964 // Suppress the first N CPU sim_debug calls
1965 // that pass all of the filters
1966 uint64 sim_deb_skip_cnt   = 0;
1967 // Suppress sim_debug until the MME instruction
1968 // has been executed N times
1969 uint64 sim_deb_mme_cntdwn = 0;
1970 // Suppress CPU sim_debug unless CPU number bit set
1971 uint dbgCPUMask           = 0377; // default all 8 on
1972 
1973 // Suppress CPU sim_debug unless BAR mode
1974 bool sim_deb_bar          = false;
1975 
1976 // Set the various filters
1977 
1978 static t_stat dps_debug_mme_cntdwn (UNUSED int32 arg, const char * buf)
     /* [previous][next][first][last][top][bottom][index][help] */
1979   {
1980     sim_deb_mme_cntdwn = strtoull (buf, NULL, 0);
1981     sim_msg ("Debug MME countdown set to %llu\r\n", (long long unsigned int)sim_deb_mme_cntdwn);
1982     return SCPE_OK;
1983   }
1984 
1985 static t_stat dps_debug_skip (UNUSED int32 arg, const char * buf)
     /* [previous][next][first][last][top][bottom][index][help] */
1986   {
1987     sim_deb_skip_cnt   = 0;
1988     sim_deb_skip_limit = strtoull (buf, NULL, 0);
1989     sim_msg ("Debug skip set to %llu\r\n", (long long unsigned int)sim_deb_skip_limit);
1990     return SCPE_OK;
1991   }
1992 
1993 static t_stat dps_debug_start (UNUSED int32 arg, const char * buf)
     /* [previous][next][first][last][top][bottom][index][help] */
1994   {
1995     sim_deb_start = strtoull (buf, NULL, 0);
1996     sim_msg ("Debug set to start at cycle: %llu\r\n", (long long unsigned int)sim_deb_start);
1997     return SCPE_OK;
1998   }
1999 
2000 static t_stat dps_debug_stop (UNUSED int32 arg, const char * buf)
     /* [previous][next][first][last][top][bottom][index][help] */
2001   {
2002     sim_deb_stop = strtoull (buf, NULL, 0);
2003     sim_msg ("Debug set to stop at cycle: %llu\r\n", (long long unsigned int)sim_deb_stop);
2004     return SCPE_OK;
2005   }
2006 
2007 static t_stat dps_debug_break (UNUSED int32 arg, const char * buf)
     /* [previous][next][first][last][top][bottom][index][help] */
2008   {
2009     sim_deb_break = strtoull (buf, NULL, 0);
2010     if (buf[0] == '+')
2011       sim_deb_break += sim_deb_start;
2012     sim_msg ("Debug set to break at cycle: %llu\r\n", (long long unsigned int)sim_deb_break);
2013     return SCPE_OK;
2014   }
2015 
2016 static t_stat dps_debug_segno (int32 arg, const char * buf)
     /* [previous][next][first][last][top][bottom][index][help] */
2017   {
2018     if (arg)
2019       {
2020         unsigned long segno = strtoul (buf, NULL, 0);
2021         if (segno >= DEBUG_SEGNO_LIMIT)
2022           {
2023             sim_printf ("out of range; 0 to %u %d.\r\n", DEBUG_SEGNO_LIMIT, DEBUG_SEGNO_LIMIT);
2024             return SCPE_ARG;
2025           }
2026         sim_deb_segno[segno] = true;
2027         sim_deb_segno_on     = true;
2028         sim_msg ("Debug set for segno %llo %llu.\r\n",
2029                 (long long unsigned int)segno, (long long unsigned int) segno);
2030       }
2031     else
2032       {
2033         (void)memset (sim_deb_segno, 0, sizeof (sim_deb_segno));
2034         sim_deb_segno_on = false;
2035         sim_msg ("Debug set for all segments\r\n");
2036       }
2037     return SCPE_OK;
2038   }
2039 
2040 static t_stat dps_debug_ringno (UNUSED int32 arg, const char * buf)
     /* [previous][next][first][last][top][bottom][index][help] */
2041   {
2042     sim_deb_ringno = strtoull (buf, NULL, 0);
2043     sim_msg ("Debug set to ringno %llo\r\n", (long long unsigned int)sim_deb_ringno);
2044     return SCPE_OK;
2045   }
2046 
2047 static t_stat dps_debug_bar (int32 arg, UNUSED const char * buf)
     /* [previous][next][first][last][top][bottom][index][help] */
2048   {
2049     sim_deb_bar = arg;
2050     if (arg)
2051       sim_msg ("Debug set BAR %llo\r\n", (long long unsigned int)sim_deb_ringno);
2052     else
2053       sim_msg ("Debug unset BAR %llo\r\n", (long long unsigned int)sim_deb_ringno);
2054     return SCPE_OK;
2055   }
2056 
2057 
2058 
2059 
2060 
2061 
2062 
2063 
2064 
2065 
2066 
2067 
2068 
2069 
2070 
2071 
2072 
2073 
2074 
2075 
2076 
2077 
2078 
2079 
2080 
2081 
2082 
2083 
2084 
2085 
2086 
2087 
2088 
2089 
2090 
2091 
2092 
2093 
2094 
2095 
2096 
2097 
2098 
2099 
2100 
2101 
2102 
2103 
2104 
2105 
2106 
2107 
2108 
2109 
2110 
2111 
2112 
2113 
2114 
2115 
2116 
2117 
2118 
2119 
2120 
2121 
2122 
2123 
2124 
2125 
2126 
2127 
2128 
2129 
2130 
2131 
2132 
2133 
2134 
2135 
2136 
2137 
2138 
2139 
2140 
2141 
2142 
2143 
2144 
2145 
2146 
2147 
2148 
2149 
2150 
2151 
2152 
2153 
2154 
2155 
2156 
2157 
2158 
2159 
2160 
2161 
2162 
2163 
2164 
2165 
2166 
2167 
2168 
2169 
2170 
2171 
2172 
2173 
2174 
2175 
2176 
2177 
2178 
2179 
2180 
2181 
2182 
2183 
2184 
2185 
2186 
2187 
2188 
2189 
2190 
2191 
2192 
2193 
2194 
2195 
2196 
2197 
2198 
2199 
2200 
2201 
2202 
2203 
2204 
2205 
2206 
2207 
2208 
2209 
2210 
2211 
2212 
2213 
2214 
2215 
2216 
2217 
2218 
2219 
2220 
2221 
2222 
2223 
2224 
2225 
2226 
2227 
2228 
2229 
2230 
2231 
2232 
2233 
2234 
2235 
2236 
2237 
2238 
2239 
2240 
2241 
2242 
2243 
2244 
2245 
2246 
2247 
2248 
2249 
2250 
2251 
2252 
2253 
2254 
2255 
2256 
2257 
2258 
2259 
2260 
2261 
2262 
2263 
2264 
2265 
2266 
2267 // Translate seg:offset to absolute address
2268 
2269 static t_stat abs_addr_n (int segno, uint offset)
     /* [previous][next][first][last][top][bottom][index][help] */
2270   {
2271     word24 res;
2272 
2273     //t_stat rc = computeAbsAddrN (& res, segno, offset);
2274     if (dbgLookupAddress ((word18) segno, offset, & res, NULL))
2275       return SCPE_ARG;
2276 
2277     sim_msg ("Address is %08o\r\n", res);
2278     return SCPE_OK;
2279   }
2280 
2281 // ABS segno:offset
2282 // scp command to translate segno:offset to absolute address
2283 
2284 static t_stat abs_addr (UNUSED int32 arg, const char * buf)
     /* [previous][next][first][last][top][bottom][index][help] */
2285   {
2286     uint segno;
2287     uint offset;
2288     if (sscanf (buf, "%o:%o", & segno, & offset) != 2)
2289       return SCPE_ARG;
2290     return abs_addr_n ((int) segno, offset);
2291   }
2292 
2293 // LOAD_SYSTEM_BOOK <filename>
2294 
2295 // Read a system_book segment, extracting segment names and numbers
2296 // and component names, offsets, and lengths
2297 
2298 # define BOOT_SEGMENTS_MAX 1024
2299 # define BOOT_COMPONENTS_MAX 4096
2300 # define BOOK_SEGMENT_NAME_LEN 33
2301 
2302 static struct book_segment
2303   {
2304     char * segname;
2305     int  segno;
2306   } book_segments[BOOT_SEGMENTS_MAX];
2307 
2308 static int n_book_segments = 0;
2309 
2310 static struct book_component
2311   {
2312     char * compname;
2313     int  book_segment_number;
2314     uint txt_start, txt_length;
2315     int  intstat_start, intstat_length, symbol_start, symbol_length;
2316   } book_components[BOOT_COMPONENTS_MAX];
2317 
2318 static int n_book_components = 0;
2319 
2320 static int lookup_book_segment (char * name)
     /* [previous][next][first][last][top][bottom][index][help] */
2321   {
2322     for (int i = 0; i < n_book_segments; i ++)
2323       if (strcmp (name, book_segments[i].segname) == 0)
2324         return i;
2325     return -1;
2326   }
2327 
2328 static int add_book_segment (char * name, int segno)
     /* [previous][next][first][last][top][bottom][index][help] */
2329   {
2330     int n = lookup_book_segment (name);
2331     if (n >= 0)
2332       return n;
2333     if (n_book_segments >= BOOT_SEGMENTS_MAX)
2334       return -1;
2335     book_segments[n_book_segments].segname = strdup (name);
2336     if (!book_segments[n_book_segments].segname)
2337       {
2338         (void)sir_emerg ("FATAL: Out of memory! Aborting at %s[%s:%d]",
2339                          __func__, __FILE__, __LINE__);
2340 # if defined(USE_BACKTRACE)
2341 #  if defined(SIGUSR2)
2342         (void)raise(SIGUSR2);
2343         /*NOTREACHED*/ /* unreachable */
2344 #  endif /* if defined(SIGUSR2) */
2345 # endif /* if defined(USE_BACKTRACE) */
2346         abort();
2347       }
2348     book_segments[n_book_segments].segno   = segno;
2349     n = n_book_segments;
2350     n_book_segments ++;
2351     return n;
2352   }
2353 
2354 static int add_book_component (int segnum, char * name, uint txt_start,
     /* [previous][next][first][last][top][bottom][index][help] */
2355                                uint txt_length, int intstat_start,
2356                                int intstat_length, int symbol_start,
2357                                int symbol_length)
2358   {
2359     if (n_book_components >= BOOT_COMPONENTS_MAX)
2360       return -1;
2361     book_components[n_book_components].compname            = strdup (name);
2362     if (!book_components[n_book_components].compname)
2363       {
2364         (void)sir_emerg ("FATAL: Out of memory! Aborting at %s[%s:%d]",
2365                          __func__, __FILE__, __LINE__);
2366 # if defined(USE_BACKTRACE)
2367 #  if defined(SIGUSR2)
2368         (void)raise(SIGUSR2);
2369         /*NOTREACHED*/ /* unreachable */
2370 #  endif /* if defined(SIGUSR2) */
2371 # endif /* if defined(USE_BACKTRACE) */
2372         abort();
2373       }
2374     book_components[n_book_components].book_segment_number = segnum;
2375     book_components[n_book_components].txt_start           = txt_start;
2376     book_components[n_book_components].txt_length          = txt_length;
2377     book_components[n_book_components].intstat_start       = intstat_start;
2378     book_components[n_book_components].intstat_length      = intstat_length;
2379     book_components[n_book_components].symbol_start        = symbol_start;
2380     book_components[n_book_components].symbol_length       = symbol_length;
2381     int n = n_book_components;
2382     n_book_components ++;
2383     return n;
2384   }
2385 
2386 // Given a segno:offset, try to translate to
2387 // component name and offset in the component
2388 
2389 // Warning: returns ptr to static buffer
2390 static char * lookup_system_book_address (word18 segno, word18 offset,
     /* [previous][next][first][last][top][bottom][index][help] */
2391                                          char * * compname, word18 * compoffset)
2392   {
2393     static char buf[129];
2394     int i;
2395 
2396     for (i = 0; i < n_book_segments; i ++)
2397       if (book_segments[i].segno == (int) segno)
2398         break;
2399 
2400     if (i >= n_book_segments)
2401       return NULL;
2402 
2403     int best = -1;
2404     uint bestoffset = 0;
2405 
2406     for (int j = 0; j < n_book_components; j ++)
2407       {
2408         if (book_components[j].book_segment_number != i)
2409           continue;
2410         if (book_components[j].txt_start <= offset &&
2411             book_components[j].txt_start + book_components[j].txt_length > offset)
2412           {
2413             (void)sprintf (buf, "%s:%s+0%0o", book_segments[i].segname,
2414                            book_components[j].compname,
2415                            offset - book_components[j].txt_start);
2416             if (compname)
2417               * compname = book_components[j].compname;
2418             if (compoffset)
2419               * compoffset = offset - book_components[j].txt_start;
2420             return buf;
2421           }
2422         if (book_components[j].txt_start <= offset &&
2423             book_components[j].txt_start > bestoffset)
2424           {
2425             best = j;
2426             bestoffset = book_components[j].txt_start;
2427           }
2428       }
2429 
2430     if (best != -1)
2431       {
2432         // Didn't find a component track bracketed the offset; return the
2433         // component that was before the offset
2434         if (compname)
2435           * compname = book_components[best].compname;
2436         if (compoffset)
2437           * compoffset = offset - book_components[best].txt_start;
2438         (void)sprintf (buf, "%s:%s+0%0o", book_segments[i].segname,
2439                        book_components[best].compname,
2440                        offset - book_components[best].txt_start);
2441         return buf;
2442       }
2443 
2444     // Found a segment, but it had no components. Return the segment name
2445     // as the component name
2446 
2447     if (compname)
2448       * compname = book_segments[i].segname;
2449     if (compoffset)
2450       * compoffset = offset;
2451     (void)sprintf (buf, "%s:+0%0o", book_segments[i].segname,
2452                    offset);
2453     return buf;
2454   }
2455 
2456 // Given a segno and offset, find the component name and its
2457 // offset in the segment
2458 
2459 char * lookup_address (word18 segno, word18 offset, char * * compname,
     /* [previous][next][first][last][top][bottom][index][help] */
2460                        word18 * compoffset)
2461   {
2462     if (compname)
2463       * compname = NULL;
2464     if (compoffset)
2465       * compoffset = 0;
2466 
2467     // Magic numbers!
2468     // Multics seems to have a copy of hpchs_ (segno 0162) in segment 0322;
2469     // This little tweak allows source code level tracing for segment 0322,
2470     // and has no operational significance to the emulator
2471     // Hmmm. What is happening is that these segments are being loaded into
2472     // ring 4, and assigned segment #'s; the assigned number will vary
2473     // depending on the exact sequence of events.
2474     if (segno == 0322)
2475       segno = 0162;
2476     if (segno == 0310)
2477       segno = 041;
2478     if (segno == 0314)
2479       segno = 041;
2480     if (segno == 0313)
2481       segno = 040;
2482     if (segno == 0317)
2483       segno = 0161;
2484 
2485 
2486 
2487 
2488 
2489 
2490 
2491 
2492 
2493 
2494 
2495 
2496 
2497 
2498 
2499 
2500 
2501 
2502 
2503 
2504 
2505 
2506 
2507 
2508 
2509 
2510 
2511 
2512 
2513 
2514 
2515 
2516     char * ret = lookup_system_book_address (segno, offset, compname, compoffset);
2517     return ret;
2518   }
2519 
2520 // Given a segment name and component name, return the
2521 // components segment number and offset
2522 
2523 // Warning: returns ptr to static buffer
2524 static int lookup_system_book_name (char * segname, char * compname, long * segno,
     /* [previous][next][first][last][top][bottom][index][help] */
2525                                     long * offset)
2526   {
2527     int i;
2528     for (i = 0; i < n_book_segments; i ++)
2529       if (strcmp (book_segments[i].segname, segname) == 0)
2530         break;
2531     if (i >= n_book_segments)
2532       return -1;
2533 
2534     for (int j = 0; j < n_book_components; j ++)
2535       {
2536         if (book_components[j].book_segment_number != i)
2537           continue;
2538         if (strcmp (book_components[j].compname, compname) == 0)
2539           {
2540             * segno = book_segments[i].segno;
2541             * offset = (long) book_components[j].txt_start;
2542             return 0;
2543           }
2544       }
2545 
2546    return -1;
2547  }
2548 
2549 static char * source_search_path = NULL;
2550 
2551 // Given a component name and an offset in the component,
2552 // find the listing file of the component and try to
2553 // print the source code line that generated the code at
2554 // component:offset
2555 
2556 void list_source (char * compname, word18 offset, uint dflag)
     /* [previous][next][first][last][top][bottom][index][help] */
2557   {
2558     cpu_state_t * cpup = _cpup;
2559     const int offset_str_len = 10;
2560     //char offset_str[offset_str_len + 1];
2561     char offset_str[17];
2562     (void)sprintf (offset_str, "    %06o", offset);
2563 
2564     char path[(source_search_path ? strlen (source_search_path) : 1) +
2565                1 + // "/"
2566                (compname ? strlen (compname) : 1) +
2567                 1 + strlen (".list") + 1];
2568     char * searchp = source_search_path ? source_search_path : ".";
2569     // find <search path>/<compname>.list
2570     while (* searchp)
2571       {
2572         size_t pathlen = strcspn (searchp, ":");
2573         strncpy (path, searchp, pathlen);
2574         path[pathlen] = '\0';
2575         if (searchp[pathlen] == ':')
2576           searchp += pathlen + 1;
2577         else
2578           searchp += pathlen;
2579 
2580         if (compname)
2581           {
2582             strcat (path, "/");
2583             strcat (path, compname);
2584           }
2585         strcat (path, ".list");
2586         //sim_msg ("<%s>\r\n", path);
2587         FILE * listing = fopen (path, "r");
2588         if (listing)
2589           {
2590             char line[1025];
2591             if (feof (listing))
2592               goto fileDone;
2593             fgets (line, 1024, listing);
2594             if (strncmp (line, "ASSEMBLY LISTING", 16) == 0)
2595               {
2596                 // Search ALM listing file
2597                 // sim_msg ("found <%s>\r\n", path);
2598 
2599                 // ALM listing files look like:
2600                 //     000226  4a  4 00010 7421 20  \tstx2]tbootload_0$entry_stack_ptr,id
2601                 while (! feof (listing))
2602                   {
2603                     fgets (line, 1024, listing);
2604                     if (strncmp (line, offset_str, (size_t) offset_str_len) == 0)
2605                       {
2606                         if (! dflag)
2607                           sim_msg ("%s", line);
2608                         else
2609                           sim_debug (dflag, & cpu_dev, "%s", line);
2610                         //break;
2611                       }
2612                     if (strcmp (line, "\fLITERALS\n") == 0) //-NLOK
2613                       break;
2614                   }
2615               } // if assembly listing
2616             else if (strncmp (line, "\tCOMPILATION LISTING", 20) == 0)
2617               {
2618                 // Search PL/I listing file
2619 
2620                 // PL/I files have a line location table
2621                 //     "   LINE    LOC      LINE    LOC ...."
2622 
2623                 bool foundTable = false;
2624                 while (! feof (listing))
2625                   {
2626                     fgets (line, 1024, listing);
2627                     if (strncmp (line, "   LINE    LOC", 14) != 0)
2628                       continue;
2629                     foundTable = true;
2630                     // Found the table
2631                     // Table lines look like
2632                     //     "     13 000705    275 000713 ...
2633                     // But some times
2634                     //     "     10 000156 21  84 000164
2635                     //     "      8 000214     65 000222   4  84 000225
2636                     //
2637                     //     "    349 001442    351 001445     353 001454 1   9 001456 1  11 001461 1  12 001463 1  13 001470
2638                     //     " 1   18 001477    357 001522     361 001525   363 001544   364 001546   365 001547   366 001553
2639 
2640                     //  I think the numbers refer to include files...
2641                     //   But of course the format is slightly off...
2642                     //    table    ".1...18
2643                     //    listing  ".1....18
2644                     int best = -1;
2645                     char bestLines[8] = {0, 0, 0, 0, 0, 0, 0};
2646                     while (! feof (listing))
2647                       {
2648                         int loc[7];
2649                         char linenos[7][8];
2650                         (void)memset (linenos, 0, sizeof (linenos));
2651                         fgets (line, 1024, listing);
2652                         // sometimes the leading columns are blank...
2653                         while (strncmp (line,
2654                                         "                 ", 8 + 6 + 3) == 0)
2655                           memmove (line, line + 8 + 6 + 3,
2656                                    strlen (line + 8 + 6 + 3));
2657                         // deal with the extra numbers...
2658 
2659                         int cnt = sscanf (line,
2660                           // " %d %o %d %o %d %o %d %o %d %o %d %o %d %o",
2661                           "%8c%o%*3c"
2662                           "%8c%o%*3c"
2663                           "%8c%o%*3c"
2664                           "%8c%o%*3c"
2665                           "%8c%o%*3c"
2666                           "%8c%o%*3c"
2667                           "%8c%o",
2668                           (char *) & linenos[0], (uint *) & loc[0],
2669                           (char *) & linenos[1], (uint *) & loc[1],
2670                           (char *) & linenos[2], (uint *) & loc[2],
2671                           (char *) & linenos[3], (uint *) & loc[3],
2672                           (char *) & linenos[4], (uint *) & loc[4],
2673                           (char *) & linenos[5], (uint *) & loc[5],
2674                           (char *) & linenos[6], (uint *) & loc[6]);
2675                         if (! (cnt == 2 || cnt == 4  || cnt == 6  ||
2676                                cnt == 8 || cnt == 10 || cnt == 12 ||
2677                                cnt == 14))
2678                           break; // end of table
2679                         int n;
2680                         for (n = 0; n < cnt / 2; n ++)
2681                           {
2682                             if (loc[n] > best && loc[n] <= (int) offset)
2683                               {
2684                                 best = loc[n];
2685                                 memcpy (bestLines, linenos[n],
2686                                         sizeof (bestLines));
2687                               }
2688                           }
2689                         if (best == (int) offset)
2690                           break;
2691                       }
2692                     if (best == -1)
2693                       goto fileDone; // Not found in table
2694 
2695                     //   But of course the format is slightly off...
2696                     //    table    ".1...18
2697                     //    listing  ".1....18
2698                     // bestLines "21   84 "
2699                     // listing   " 21    84 "
2700                     char searchPrefix[10];
2701                     searchPrefix[0] = ' ';
2702                     searchPrefix[1] = bestLines[0];
2703                     searchPrefix[2] = bestLines[1];
2704                     searchPrefix[3] = ' ';
2705                     searchPrefix[4] = bestLines[2];
2706                     searchPrefix[5] = bestLines[3];
2707                     searchPrefix[6] = bestLines[4];
2708                     searchPrefix[7] = bestLines[5];
2709                     searchPrefix[8] = bestLines[6];
2710                     // ignore trailing space; some times it's a tab
2711                     // searchPrefix[ 9] = bestLines[ 7];
2712                     searchPrefix[9] = '\0';
2713 
2714                     // Look for the line in the listing
2715                     rewind (listing);
2716                     while (! feof (listing))
2717                       {
2718                         fgets (line, 1024, listing);
2719                         if (strncmp (line, "\f\tSOURCE", 8) == 0)
2720                           goto fileDone; // end of source code listing
2721                         char prefix[10];
2722                         strncpy (prefix, line, 9);
2723                         prefix[9] = '\0';
2724                         if (strcmp (prefix, searchPrefix) != 0)
2725                           continue;
2726                         // Got it
2727                         if (!dflag)
2728                           sim_msg ("%s", line);
2729                         else
2730                           sim_debug (dflag, & cpu_dev, "%s", line);
2731                         //break;
2732                       }
2733                     goto fileDone;
2734                   } // if table start
2735                 if (! foundTable)
2736                   {
2737                     // Can't find the LINE/LOC table; look for listing
2738                     rewind (listing);
2739                     while (! feof (listing))
2740                       {
2741                         fgets (line, 1024, listing);
2742                         if (strncmp (line,
2743                                      offset_str + 4,
2744                                      offset_str_len - 4) == 0)
2745                           {
2746                             if (! dflag)
2747                               sim_msg ("%s", line);
2748                             else
2749                               sim_debug (dflag, & cpu_dev, "%s", line);
2750                             //break;
2751                           }
2752                         //if (strcmp (line, "\fLITERALS\n") == 0) //-NLOK
2753                           //break;
2754                       }
2755                   } // if ! tableFound
2756               } // if PL/I listing
2757 
2758 fileDone:
2759             fclose (listing);
2760           } // if (listing)
2761       }
2762   }
2763 
2764 // STK
2765 
2766 static t_stat stack_trace (UNUSED int32 arg,  UNUSED const char * buf)
     /* [previous][next][first][last][top][bottom][index][help] */
2767   {
2768     cpu_state_t * cpup = _cpup;
2769     char * msg;
2770 
2771     word15 icSegno = cpu.PPR.PSR;
2772     word18 icOffset = cpu.PPR.IC;
2773 
2774     sim_msg ("Entry ptr   %05o:%06o\r\n", icSegno, icOffset);
2775 
2776     char * compname;
2777     word18 compoffset;
2778     char * where = lookup_address (icSegno, icOffset,
2779                                    & compname, & compoffset);
2780     if (where)
2781       {
2782         sim_msg ("%05o:%06o %s\r\n", icSegno, icOffset, where);
2783         list_source (compname, compoffset, 0);
2784       }
2785     sim_msg ("\r\n");
2786 
2787     // According to AK92
2788     //
2789     //  pr0/ap operator segment pointer
2790     //  pr6/sp stack frame pointer
2791     //  pr4/lp linkage section for the executing procedure
2792     //  pr7/sb stack base
2793 
2794     word15 fpSegno  = cpu.PR[6].SNR;
2795     word18 fpOffset = cpu.PR[6].WORDNO;
2796 
2797     for (uint frameNo = 1; ; frameNo ++)
2798       {
2799         sim_msg ("Frame %d %05o:%06o\r\n",
2800                     frameNo, fpSegno, fpOffset);
2801 
2802         word24 fp;
2803         if (dbgLookupAddress (fpSegno, fpOffset, & fp, & msg))
2804           {
2805             sim_msg ("can't lookup fp (%05o:%06o) because %s\r\n",
2806                     fpSegno, fpOffset, msg);
2807             break;
2808           }
2809 
2810         word15 prevfpSegno  = (word15) ((M[fp + 16] >> 18) & MASK15);
2811         word18 prevfpOffset = (word18) ((M[fp + 17] >> 18) & MASK18);
2812 
2813         sim_msg ("Previous FP %05o:%06o\r\n", prevfpSegno, prevfpOffset);
2814 
2815         word15 returnSegno  = (word15) ((M[fp + 20] >> 18) & MASK15);
2816         word18 returnOffset = (word18) ((M[fp + 21] >> 18) & MASK18);
2817 
2818         sim_msg ("Return ptr  %05o:%06o\r\n", returnSegno, returnOffset);
2819 
2820         if (returnOffset == 0)
2821           {
2822             if (frameNo == 1)
2823               {
2824                 // try rX[7] as the return address
2825                 sim_msg ("guessing X7 has a return address....\r\n");
2826                 where = lookup_address (icSegno, cpu.rX[7] - 1,
2827                                         & compname, & compoffset);
2828                 if (where)
2829                   {
2830                     sim_msg ("%05o:%06o %s\r\n", icSegno, cpu.rX[7] - 1, where);
2831                     list_source (compname, compoffset, 0);
2832                   }
2833               }
2834           }
2835         else
2836           {
2837             where = lookup_address (returnSegno, returnOffset - 1,
2838                                     & compname, & compoffset);
2839             if (where)
2840               {
2841                 sim_msg ("%05o:%06o %s\r\n",
2842                             returnSegno, returnOffset - 1, where);
2843                 list_source (compname, compoffset, 0);
2844               }
2845           }
2846 
2847         word15 entrySegno  = (word15) ((M[fp + 22] >> 18) & MASK15);
2848         word18 entryOffset = (word18) ((M[fp + 23] >> 18) & MASK18);
2849 
2850         sim_msg ("Entry ptr   %05o:%06o\r\n", entrySegno, entryOffset);
2851 
2852         where = lookup_address (entrySegno, entryOffset,
2853                                 & compname, & compoffset);
2854         if (where)
2855           {
2856             sim_msg ("%05o:%06o %s\r\n", entrySegno, entryOffset, where);
2857             list_source (compname, compoffset, 0);
2858           }
2859 
2860         word15 argSegno  = (word15) ((M[fp + 26] >> 18) & MASK15);
2861         word18 argOffset = (word18) ((M[fp + 27] >> 18) & MASK18);
2862         sim_msg ("Arg ptr     %05o:%06o\r\n", argSegno, argOffset);
2863 
2864         word24 ap;
2865         if (dbgLookupAddress (argSegno, argOffset, & ap, & msg))
2866           {
2867             sim_msg ("can't lookup arg ptr (%05o:%06o) because %s\r\n",
2868                     argSegno, argOffset, msg);
2869             goto skipArgs;
2870           }
2871 
2872         word16 argCount  = (word16) ((M[ap + 0] >> 19) & MASK17);
2873         word18 callType  = (word18) (M[ap + 0] & MASK18);
2874         word16 descCount = (word16) ((M[ap + 1] >> 19) & MASK17);
2875         sim_msg ("arg_count   %d\r\n", argCount);
2876         switch (callType)
2877           {
2878             case 0u:
2879               sim_msg ("call_type Quick internal call\r\n");
2880               break;
2881             case 4u:
2882               sim_msg ("call_type Inter-segment\r\n");
2883               break;
2884             case 8u:
2885               sim_msg ("call_type Environment pointer\r\n");
2886               break;
2887             default:
2888               sim_msg ("call_type Unknown (%o)\r\n", callType);
2889               goto skipArgs;
2890               }
2891         sim_msg ("desc_count  %d\r\n", descCount);
2892 
2893 
2894 
2895 
2896 
2897 
2898 
2899 
2900           {
2901             for (uint argno = 0; argno < argCount; argno ++)
2902               {
2903                 uint argnoos       = ap + 2 + argno * 2;
2904                 word15 argnoSegno  = (word15) ((M[argnoos] >> 18) & MASK15);
2905                 word18 argnoOffset = (word18) ((M[argnoos + 1] >> 18) & MASK18);
2906                 word24 argnop;
2907                 if (dbgLookupAddress (argnoSegno, argnoOffset, & argnop, & msg))
2908                   {
2909                     sim_msg ("can't lookup arg%d ptr (%05o:%06o) because %s\r\n",
2910                                 argno, argSegno, argOffset, msg);
2911                     continue;
2912                   }
2913                 word36 argv = M[argnop];
2914                 sim_msg ("arg%d value   %05o:%06o[%08o] "
2915                             "%012llo (%llu)\r\n",
2916                             argno, argSegno, argOffset, argnop,
2917                             (unsigned long long int)argv, (unsigned long long int)argv);
2918                 sim_msg ("\r\n");
2919              }
2920          }
2921 skipArgs:;
2922 
2923         sim_msg ("End of frame %d\r\n\r\n", frameNo);
2924 
2925         if (prevfpSegno == 077777 && prevfpOffset == 1)
2926           break;
2927         fpSegno  = prevfpSegno;
2928         fpOffset = prevfpOffset;
2929       }
2930     return SCPE_OK;
2931   }
2932 
2933 static t_stat list_source_at (UNUSED int32 arg, UNUSED const char *  buf)
     /* [previous][next][first][last][top][bottom][index][help] */
2934   {
2935     // list seg:offset
2936     uint segno;
2937     uint offset;
2938     if (sscanf (buf, "%o:%o", & segno, & offset) != 2)
2939       return SCPE_ARG;
2940     char * compname;
2941     word18 compoffset;
2942     char * where = lookup_address ((word18) segno, offset,
2943                                    & compname, & compoffset);
2944     if (where)
2945       {
2946         sim_msg ("%05o:%06o %s\r\n", segno, offset, where);
2947         list_source (compname, compoffset, 0);
2948       }
2949     return SCPE_OK;
2950   }
2951 
2952 static t_stat load_system_book (UNUSED int32 arg, UNUSED const char * buf)
     /* [previous][next][first][last][top][bottom][index][help] */
2953   {
2954 // Quietly ignore if not debug enabled
2955 # if !defined(SPEED)
2956     // Multics 12.5 assigns segment number to collection 3 starting at 0244.
2957     uint c3 = 0244;
2958 
2959 #  define bufSz 257
2960     char filebuf[bufSz];
2961     int  current = -1;
2962 
2963     FILE * fp = fopen (buf, "r");
2964     if (! fp)
2965       {
2966         sim_msg ("error opening file %s\r\n", buf);
2967         return SCPE_ARG;
2968       }
2969     for (;;)
2970       {
2971         char * bufp = fgets (filebuf, bufSz, fp);
2972         if (! bufp)
2973           break;
2974         //sim_msg ("<%s\n>", filebuf); //-NLOK
2975         char name[BOOK_SEGMENT_NAME_LEN];
2976         uint segno, p0, p1, p2;
2977 
2978         // 32 is BOOK_SEGMENT_NAME_LEN - 1
2979         int cnt = sscanf (filebuf, "%32s %o  (%o, %o, %o)", name, & segno,
2980           & p0, & p1, & p2);
2981         if (filebuf[0] != '\t' && cnt == 5)
2982           {
2983             //sim_msg ("A: %s %d\r\n", name, segno);
2984             int rc = add_book_segment (name, (int) segno);
2985             if (rc < 0)
2986               {
2987                 sim_warn ("error adding segment name\r\n");
2988                 fclose (fp);
2989                 return SCPE_ARG;
2990               }
2991             continue;
2992           }
2993         else
2994           {
2995             // Check for collection 3 segment
2996             // 32 is BOOK_SEGMENT_NAME_LEN - 1
2997             cnt = sscanf (filebuf, "%32s  (%o, %o, %o)", name,
2998               & p0, & p1, & p2);
2999             if (filebuf[0] != '\t' && cnt == 4)
3000               {
3001                 if (strstr (name, "fw.") || strstr (name, ".ec"))
3002                   continue;
3003                 //sim_msg ("A: %s %d\r\n", name, segno);
3004                 int rc = add_book_segment (name, (int) (c3 ++));
3005                 if (rc < 0)
3006                   {
3007                     sim_warn ("error adding segment name\r\n");
3008                     fclose (fp);
3009                     return SCPE_ARG;
3010                   }
3011                 continue;
3012               }
3013           }
3014         cnt = sscanf (filebuf, "Bindmap for >ldd>h>e>%32s", name);
3015         if (cnt != 1)
3016           cnt = sscanf (filebuf, "Bindmap for >ldd>hard>e>%32s", name);
3017         if (cnt == 1)
3018           {
3019             //sim_msg ("B: %s\r\n", name);
3020             //int rc = add_book_segment (name);
3021             int rc = lookup_book_segment (name);
3022             if (rc < 0)
3023               {
3024                 // The collection 3.0 segments do not have segment numbers,
3025                 // and the 1st digit of the 3-tuple is 1, not 0. Ignore
3026                 // them for now.
3027                 current = -1;
3028                 continue;
3029                 //sim_warn ("error adding segment name\r\n");
3030                 //return SCPE_ARG;
3031               }
3032             current = rc;
3033             continue;
3034           }
3035 
3036         uint txt_start, txt_length;
3037         int intstat_start, intstat_length, symbol_start, symbol_length;
3038         cnt = sscanf (filebuf, "%32s %o %o %o %o %o %o", name, & txt_start,
3039                       & txt_length, & intstat_start, & intstat_length,
3040                       & symbol_start, & symbol_length);
3041 
3042         if (cnt == 7)
3043           {
3044             //sim_msg ("C: %s\r\n", name);
3045             if (current >= 0)
3046               {
3047                 add_book_component (current, name, txt_start, txt_length,
3048                                     intstat_start, intstat_length, symbol_start,
3049                                     symbol_length);
3050               }
3051             continue;
3052           }
3053 
3054         cnt = sscanf (filebuf, "%32s %o  (%o, %o, %o)", name, & segno,
3055           & p0, & p1, & p2);
3056         if (filebuf[0] == '\t' && cnt == 5)
3057           {
3058             //sim_msg ("D: %s %d\r\n", name, segno);
3059             int rc = add_book_segment (name, (int) segno);
3060             if (rc < 0)
3061               {
3062                 sim_warn ("error adding segment name\r\n");
3063                 fclose (fp);
3064                 return SCPE_ARG;
3065               }
3066             continue;
3067           }
3068 
3069       }
3070     fclose (fp);
3071 
3072 
3073 
3074 
3075 
3076 
3077 
3078 
3079 
3080 
3081 
3082 
3083 
3084 
3085 
3086 
3087 
3088 
3089 
3090 
3091 
3092 # endif
3093     return SCPE_OK;
3094   }
3095 
3096 static t_stat add_system_book_entry (UNUSED int32 arg, const char * buf)
     /* [previous][next][first][last][top][bottom][index][help] */
3097   {
3098     // asbe segname compname seg txt_start txt_len intstat_start intstat_length
3099     // symbol_start symbol_length
3100     char segname[BOOK_SEGMENT_NAME_LEN];
3101     char compname[BOOK_SEGMENT_NAME_LEN];
3102     uint segno;
3103     uint txt_start, txt_len;
3104     uint  intstat_start, intstat_length;
3105     uint  symbol_start, symbol_length;
3106 
3107     // 32 is BOOK_SEGMENT_NAME_LEN - 1
3108     if (sscanf (buf, "%32s %32s %o %o %o %o %o %o %o",
3109                 segname, compname, & segno,
3110                 & txt_start, & txt_len, & intstat_start, & intstat_length,
3111                 & symbol_start, & symbol_length) != 9)
3112       return SCPE_ARG;
3113 
3114     int idx = add_book_segment (segname, (int) segno);
3115     if (idx < 0)
3116       return SCPE_ARG;
3117 
3118     if (add_book_component (idx, compname, txt_start, txt_len, (int) intstat_start,
3119                            (int) intstat_length, (int) symbol_start,
3120                            (int) symbol_length) < 0)
3121       return SCPE_ARG;
3122 
3123     return SCPE_OK;
3124   }
3125 
3126 // LSB n:n   given a segment number and offset, return a segment name,
3127 //           component and offset in that component
3128 //     sname:cname+offset
3129 //           given a segment name, component name and offset, return
3130 //           the segment number and offset
3131 
3132 static t_stat lookup_system_book (UNUSED int32  arg, const char * buf)
     /* [previous][next][first][last][top][bottom][index][help] */
3133   {
3134     char w1[strlen (buf)];
3135     char w2[strlen (buf)];
3136     char w3[strlen (buf)];
3137     long segno, offset;
3138 
3139     size_t colon = strcspn (buf, ":");
3140     if (buf[colon] != ':')
3141       return SCPE_ARG;
3142 
3143     strncpy (w1, buf, colon);
3144     w1[colon] = '\0';
3145     //sim_msg ("w1 <%s>\r\n", w1);
3146 
3147     size_t plus = strcspn (buf + colon + 1, "+");
3148     if (buf[colon + 1 + plus] == '+')
3149       {
3150         strncpy (w2, buf + colon + 1, plus);
3151         w2[plus] = '\0';
3152         (void)strcpy (w3, buf + colon + 1 + plus + 1);
3153       }
3154     else
3155       {
3156         (void)strcpy (w2, buf + colon + 1);
3157         (void)strcpy (w3, "");
3158       }
3159     //sim_msg ("w1 <%s>\r\n", w1);
3160     //sim_msg ("w2 <%s>\r\n", w2);
3161     //sim_msg ("w3 <%s>\r\n", w3);
3162 
3163     char * end1;
3164     segno = strtol (w1, & end1, 8);
3165     char * end2;
3166     offset = strtol (w2, & end2, 8);
3167 
3168     if (* end1 == '\0' && * end2 == '\0' && * w3 == '\0')
3169       {
3170         // n:n
3171         char * ans = lookup_address ((word18) segno, (word18) offset, NULL, NULL);
3172         sim_warn ("%s\r\n", ans ? ans : "not found");
3173       }
3174     else
3175       {
3176         if (* w3)
3177           {
3178             char * end3;
3179             offset = strtol (w3, & end3, 8);
3180             if (* end3 != '\0')
3181               return SCPE_ARG;
3182           }
3183         else
3184           offset = 0;
3185         long comp_offset;
3186         int rc = lookup_system_book_name (w1, w2, & segno, & comp_offset);
3187         if (rc)
3188           {
3189             sim_warn ("not found\r\n");
3190             return SCPE_OK;
3191           }
3192         sim_msg ("0%o:0%o\r\n", (uint) segno, (uint) (comp_offset + offset));
3193         abs_addr_n  ((int) segno, (uint) (comp_offset + offset));
3194       }
3195 /*
3196     if (sscanf (buf, "%o:%o", & segno, & offset) != 2)
3197       return SCPE_ARG;
3198     char * ans = lookup_address (segno, offset);
3199     sim_msg ("%s\r\n", ans ? ans : "not found");
3200 */
3201     return SCPE_OK;
3202   }
3203 
3204 // Assumes unpaged DSBR
3205 
3206 static sdw0_s *fetchSDW (word15 segno)
     /* [previous][next][first][last][top][bottom][index][help] */
3207   {
3208     cpu_state_t * cpup = _cpup;
3209     word36 SDWeven, SDWodd;
3210 
3211     core_read2 (cpup, (cpu.DSBR.ADDR + 2u * segno) & PAMASK, & SDWeven, & SDWodd, // NO_CACHE
3212                  __func__);
3213 
3214     // even word
3215 
3216     sdw0_s *SDW = & cpu._s;
3217     (void)memset (SDW, 0, sizeof (cpu._s));
3218 
3219     SDW->ADDR   = (SDWeven >> 12) & 077777777;
3220     SDW->R1     = (SDWeven >> 9)  & 7;
3221     SDW->R2     = (SDWeven >> 6)  & 7;
3222     SDW->R3     = (SDWeven >> 3)  & 7;
3223     SDW->DF     = TSTBIT (SDWeven,  2);
3224     SDW->FC     = SDWeven & 3;
3225 
3226     // odd word
3227     SDW->BOUND  = (SDWodd >> 21) & 037777;
3228     SDW->R      = TSTBIT (SDWodd,  20);
3229     SDW->E      = TSTBIT (SDWodd,  19);
3230     SDW->W      = TSTBIT (SDWodd,  18);
3231     SDW->P      = TSTBIT (SDWodd,  17);
3232     SDW->U      = TSTBIT (SDWodd,  16);
3233     SDW->G      = TSTBIT (SDWodd,  15);
3234     SDW->C      = TSTBIT (SDWodd,  14);
3235     SDW->EB     = SDWodd & 037777;
3236 
3237     return SDW;
3238   }
3239 
3240 static t_stat virtAddrN (uint address)
     /* [previous][next][first][last][top][bottom][index][help] */
3241   {
3242     cpu_state_t * cpup = _cpup;
3243     if (cpu.DSBR.U) {
3244         for(word15 segno = 0; 2u * segno < 16u * (cpu.DSBR.BND + 1u); segno += 1)
3245         {
3246             sdw0_s *s = fetchSDW(segno);
3247             if (address >= s -> ADDR && address < s -> ADDR + s -> BOUND * 16u)
3248               sim_msg ("  %06o:%06o\r\n", segno, address - s -> ADDR);
3249         }
3250     } else {
3251         for(word15 segno = 0;
3252             2u * segno < 16u * (cpu.DSBR.BND + 1u);
3253             segno += 512u)
3254         {
3255             word24 y1 = (2u * segno) % 1024u;
3256             word24 x1 = (2u * segno - y1) / 1024u;
3257             word36 PTWx1;
3258             core_read (cpup, (cpu.DSBR.ADDR + x1) & PAMASK, & PTWx1, __func__); // NO_CACHE
3259 
3260             ptw_s PTW1;
3261             PTW1.ADDR = GETHI(PTWx1);
3262             PTW1.U    = TSTBIT(PTWx1, 9);
3263             PTW1.M    = TSTBIT(PTWx1, 6);
3264             PTW1.DF   = TSTBIT(PTWx1, 2);
3265             PTW1.FC   = PTWx1 & 3;
3266 
3267             if (PTW1.DF == 0)
3268                 continue;
3269             //sim_msg ("%06o  Addr %06o U %o M %o DF %o FC %o\r\n",
3270             //            segno, PTW1.ADDR, PTW1.U, PTW1.M, PTW1.DF, PTW1.FC);
3271             //sim_msg ("    Target segment page table\r\n");
3272             for (word15 tspt = 0; tspt < 512u; tspt ++)
3273             {
3274                 word36 SDWeven, SDWodd;
3275                 core_read2(cpup, ((PTW1.ADDR << 6) + tspt * 2u) & PAMASK, & SDWeven, // NO_CACHE
3276                            & SDWodd, __func__);
3277                 sdw0_s SDW0;
3278                 // even word
3279                 SDW0.ADDR  = (SDWeven >> 12) & PAMASK;
3280                 SDW0.R1    = (SDWeven >> 9)  & 7u;
3281                 SDW0.R2    = (SDWeven >> 6)  & 7u;
3282                 SDW0.R3    = (SDWeven >> 3)  & 7u;
3283                 SDW0.DF    = TSTBIT(SDWeven,   2);
3284                 SDW0.FC    = SDWeven & 3u;
3285 
3286                 // odd word
3287                 SDW0.BOUND = (SDWodd >> 21) & 037777;
3288                 SDW0.R     = TSTBIT(SDWodd,   20);
3289                 SDW0.E     = TSTBIT(SDWodd,   19);
3290                 SDW0.W     = TSTBIT(SDWodd,   18);
3291                 SDW0.P     = TSTBIT(SDWodd,   17);
3292                 SDW0.U     = TSTBIT(SDWodd,   16);
3293                 SDW0.G     = TSTBIT(SDWodd,   15);
3294                 SDW0.C     = TSTBIT(SDWodd,   14);
3295                 SDW0.EB    = SDWodd & 037777;
3296 
3297                 if (SDW0.DF == 0)
3298                     continue;
3299                 //sim_msg ("    %06o Addr %06o %o,%o,%o F%o BOUND %06o "
3300                 //          "%c%c%c%c%c\r\n",
3301                 //          tspt, SDW0.ADDR, SDW0.R1, SDW0.R2, SDW0.R3, SDW0.F,
3302                 //          SDW0.BOUND, SDW0.R ? 'R' : '.', SDW0.E ? 'E' : '.',
3303                 //          SDW0.W ? 'W' : '.', SDW0.P ? 'P' : '.',
3304                 //          SDW0.U ? 'U' : '.');
3305                 if (SDW0.U == 0)
3306                 {
3307                     for (word18 offset = 0;
3308                          offset < 16u * (SDW0.BOUND + 1u);
3309                          offset += 1024)
3310                     {
3311                         word24 y2 = offset % 1024;
3312                         word24 x2 = (offset - y2) / 1024;
3313 
3314                         // 10. Fetch the target segment PTW(x2) from
3315                         //     SDW(segno).ADDR + x2.
3316 
3317                         word36 PTWx2;
3318                         core_read (cpup, (SDW0.ADDR + x2) & PAMASK, & PTWx2, __func__); // NO_CACHE
3319 
3320                         ptw_s PTW2;
3321                         PTW2.ADDR = GETHI(PTWx2);
3322                         PTW2.U    = TSTBIT(PTWx2, 9);
3323                         PTW2.M    = TSTBIT(PTWx2, 6);
3324                         PTW2.DF   = TSTBIT(PTWx2, 2);
3325                         PTW2.FC   = PTWx2 & 3;
3326 
3327                         //sim_msg ("        %06o  Addr %06o U %o M %o F %o "
3328                         //            "FC %o\r\n",
3329                         //            offset, PTW2.ADDR, PTW2.U, PTW2.M, PTW2.F,
3330                         //            PTW2.FC);
3331                         if (address >= PTW2.ADDR + offset &&
3332                             address < PTW2.ADDR + offset + 1024)
3333                           sim_msg ("  %06o:%06o\r\n", tspt, (address - offset) - PTW2.ADDR);
3334 
3335                       }
3336                   }
3337                 else
3338                   {
3339                     if (address >= SDW0.ADDR &&
3340                         address < SDW0.ADDR + SDW0.BOUND * 16u)
3341                       sim_msg ("  %06o:%06o\r\n", tspt, address - SDW0.ADDR);
3342                   }
3343             }
3344         }
3345     }
3346 
3347     return SCPE_OK;
3348 
3349   }
3350 
3351 // VIRTUAL address
3352 
3353 static t_stat virt_address (UNUSED int32 arg, const char * buf)
     /* [previous][next][first][last][top][bottom][index][help] */
3354   {
3355     uint address;
3356     if (sscanf (buf, "%o", & address) != 1)
3357       return SCPE_ARG;
3358     return virtAddrN (address);
3359   }
3360 
3361 // search path is path:path:path....
3362 
3363 static t_stat set_search_path (UNUSED int32 arg, UNUSED const char * buf)
     /* [previous][next][first][last][top][bottom][index][help] */
3364   {
3365 // Quietly ignore if debugging not enabled
3366 # if !defined(SPEED)
3367     if (source_search_path)
3368       FREE (source_search_path);
3369     source_search_path = strdup (buf);
3370     if (!source_search_path)
3371       {
3372         (void)sir_emerg ("FATAL: Out of memory! Aborting at %s[%s:%d]",
3373                          __func__, __FILE__, __LINE__);
3374 #  if defined(USE_BACKTRACE)
3375 #   if defined(SIGUSR2)
3376         (void)raise(SIGUSR2);
3377         /*NOTREACHED*/ /* unreachable */
3378 #   endif /* if defined(SIGUSR2) */
3379 #  endif /* if defined(USE_BACKTRACE) */
3380         abort();
3381       }
3382 # endif
3383     return SCPE_OK;
3384   }
3385 
3386 // Hook for gdb
3387 //
3388 // The idea is that if you want to set a gdb breakpoint for a particularly
3389 // complex condition, you can add a test for the condition to the emulator
3390 // code and call brkbrk() when the condition is met; by doing a gdb
3391 // 'b brkbrk', gdb will see when the condition is met.
3392 //
3393 
3394 t_stat brkbrk (UNUSED int32 arg, UNUSED const char *  buf)
     /* [previous][next][first][last][top][bottom][index][help] */
3395   {
3396     //list_source (buf, 0);
3397     return SCPE_OK;
3398   }
3399 
3400 // SBREAK segno:offset
3401 
3402 static t_stat sbreak (int32 arg, const char * buf)
     /* [previous][next][first][last][top][bottom][index][help] */
3403   {
3404     //(void)printf (">> <%s>\r\n", buf);
3405     int segno, offset;
3406     int where;
3407     int cnt = sscanf (buf, "%o:%o%n", & segno, & offset, & where);
3408     if (cnt != 2)
3409       {
3410         return SCPE_ARG;
3411       }
3412     char reformatted[strlen (buf) + 20];
3413     (void)sprintf (reformatted, "0%04o%06o%s", segno, offset, buf + where);
3414     //(void)printf (">> <%s>\r\n", reformatted);
3415     t_stat rc = brk_cmd (arg, reformatted);
3416     return rc;
3417   }
3418 
3419 # if defined(DVFDBG)
3420 static t_stat dfx1entry (UNUSED int32 arg, UNUSED const char * buf)
     /* [previous][next][first][last][top][bottom][index][help] */
3421   {
3422 // divide_fx1, divide_fx3
3423     sim_msg ("dfx1entry\r\n");
3424     sim_msg ("rA %012"PRIo64" (%llu)\r\n", rA, rA);
3425     sim_msg ("rQ %012"PRIo64" (%llu)\r\n", rQ, rQ);
3426     // Figure out the caller's text segment, according to pli_operators.
3427     // sp:tbp -> PR[6].SNR:046
3428     word24 pa;
3429     char * msg;
3430     if (dbgLookupAddress (cpu.PR[6].SNR, 046, & pa, & msg))
3431       {
3432         sim_msg ("text segment number lookup failed because %s\r\n", msg);
3433       }
3434     else
3435       {
3436         sim_msg ("text segno %012"PRIo64" (%llu)\r\n", M[pa], M[pa]);
3437       }
3438 sim_msg ("%05o:%06o\r\n", cpu.PR[2].SNR, cpu.rX[0]);
3439 //dbgStackTrace ();
3440     if (dbgLookupAddress (cpu.PR[2].SNR, cpu.rX[0], & pa, & msg))
3441       {
3442         sim_msg ("return address lookup failed because %s\r\n", msg);
3443       }
3444     else
3445       {
3446         sim_msg ("scale %012"PRIo64" (%llu)\r\n", M[pa], M[pa]);
3447       }
3448     if (dbgLookupAddress (cpu.PR[2].SNR, cpu.PR[2].WORDNO, & pa, & msg))
3449       {
3450         sim_msg ("divisor address lookup failed because %s\r\n", msg);
3451       }
3452     else
3453       {
3454         sim_msg ("divisor %012"PRIo64" (%llu)\r\n", M[pa], M[pa]);
3455       }
3456     return SCPE_OK;
3457   }
3458 
3459 static t_stat dfx1exit (UNUSED int32 arg, UNUSED const char * buf)
     /* [previous][next][first][last][top][bottom][index][help] */
3460   {
3461     sim_msg ("dfx1exit\r\n");
3462     sim_msg ("rA %012"PRIo64" (%llu)\r\n", rA, rA);
3463     sim_msg ("rQ %012"PRIo64" (%llu)\r\n", rQ, rQ);
3464     return SCPE_OK;
3465   }
3466 
3467 static t_stat dv2scale (UNUSED int32 arg, UNUSED const char * buf)
     /* [previous][next][first][last][top][bottom][index][help] */
3468   {
3469     sim_msg ("dv2scale\r\n");
3470     sim_msg ("rQ %012"PRIo64" (%llu)\r\n", rQ, rQ);
3471     return SCPE_OK;
3472   }
3473 
3474 static t_stat dfx2entry (UNUSED int32 arg, UNUSED const char * buf)
     /* [previous][next][first][last][top][bottom][index][help] */
3475   {
3476 // divide_fx2
3477     sim_msg ("dfx2entry\r\n");
3478     sim_msg ("rA %012"PRIo64" (%llu)\r\n", rA, rA);
3479     sim_msg ("rQ %012"PRIo64" (%llu)\r\n", rQ, rQ);
3480     // Figure out the caller's text segment, according to pli_operators.
3481     // sp:tbp -> PR[6].SNR:046
3482     word24 pa;
3483     char * msg;
3484     if (dbgLookupAddress (cpu.PR[6].SNR, 046, & pa, & msg))
3485       {
3486         sim_msg ("text segment number lookup failed because %s\r\n", msg);
3487       }
3488     else
3489       {
3490         sim_msg ("text segno %012"PRIo64" (%llu)\r\n", M[pa], M[pa]);
3491       }
3492 
3493 
3494 
3495 
3496 
3497 
3498 
3499 
3500 
3501 
3502 
3503 
3504 
3505 
3506 
3507 
3508 
3509 
3510 
3511 
3512 
3513 
3514 
3515 
3516 
3517 
3518     if (dbgLookupAddress (cpu.PR[2].SNR, cpu.PR[2].WORDNO, & pa, & msg))
3519       {
3520         sim_msg ("divisor address lookup failed because %s\r\n", msg);
3521       }
3522     else
3523       {
3524         sim_msg ("divisor %012"PRIo64" (%llu)\r\n", M[pa], M[pa]);
3525         sim_msg ("divisor %012"PRIo64" (%llu)\r\n", M[pa + 1], M[pa + 1]);
3526       }
3527     return SCPE_OK;
3528   }
3529 
3530 static t_stat mdfx3entry (UNUSED int32 arg, UNUSED const char * buf)
     /* [previous][next][first][last][top][bottom][index][help] */
3531   {
3532 // operator to form mod(fx2,fx1)
3533 // entered with first arg in q, bp pointing at second
3534 
3535 // divide_fx1, divide_fx2
3536     sim_msg ("mdfx3entry\r\n");
3537     //sim_msg ("rA %012"PRIo64" (%llu)\r\n", rA, rA);
3538     sim_msg ("rQ %012"PRIo64" (%llu)\r\n", rQ, rQ);
3539     // Figure out the caller's text segment, according to pli_operators.
3540     // sp:tbp -> PR[6].SNR:046
3541     word24 pa;
3542     char * msg;
3543     if (dbgLookupAddress (cpu.PR[6].SNR, 046, & pa, & msg))
3544       {
3545         sim_msg ("text segment number lookup failed because %s\r\n", msg);
3546       }
3547     else
3548       {
3549         sim_msg ("text segno %012"PRIo64" (%llu)\r\n", M[pa], M[pa]);
3550       }
3551 //sim_msg ("%05o:%06o\r\n", cpu.PR[2].SNR, cpu.rX[0]);
3552 //dbgStackTrace ();
3553 
3554 
3555 
3556 
3557 
3558 
3559 
3560 
3561 
3562 
3563     if (dbgLookupAddress (cpu.PR[2].SNR, cpu.PR[2].WORDNO, & pa, & msg))
3564       {
3565         sim_msg ("divisor address lookup failed because %s\r\n", msg);
3566       }
3567     else
3568       {
3569         sim_msg ("divisor %012"PRIo64" (%llu)\r\n", M[pa], M[pa]);
3570       }
3571     return SCPE_OK;
3572   }
3573 
3574 static t_stat smfx1entry (UNUSED int32 arg, UNUSED const char * buf)
     /* [previous][next][first][last][top][bottom][index][help] */
3575   {
3576 // operator to form mod(fx2,fx1)
3577 // entered with first arg in q, bp pointing at second
3578 
3579 // divide_fx1, divide_fx2
3580     sim_msg ("smfx1entry\r\n");
3581     //sim_msg ("rA %012"PRIo64" (%llu)\r\n", rA, rA);
3582     sim_msg ("rQ %012"PRIo64" (%llu)\r\n", rQ, rQ);
3583     // Figure out the caller's text segment, according to pli_operators.
3584     // sp:tbp -> PR[6].SNR:046
3585     word24 pa;
3586     char * msg;
3587     if (dbgLookupAddress (cpu.PR[6].SNR, 046, & pa, & msg))
3588       {
3589         sim_msg ("text segment number lookup failed because %s\r\n", msg);
3590       }
3591     else
3592       {
3593         sim_msg ("text segno %012"PRIo64" (%llu)\r\n", M[pa], M[pa]);
3594       }
3595 sim_msg ("%05o:%06o\r\n", cpu.PR[2].SNR, cpu.rX[0]);
3596 //dbgStackTrace ();
3597     if (dbgLookupAddress (cpu.PR[2].SNR, cpu.rX[0], & pa, & msg))
3598       {
3599         sim_msg ("return address lookup failed because %s\r\n", msg);
3600       }
3601     else
3602       {
3603         sim_msg ("scale %012"PRIo64" (%llu)\r\n", M[pa], M[pa]);
3604       }
3605     if (dbgLookupAddress (cpu.PR[2].SNR, cpu.PR[2].WORDNO, & pa, & msg))
3606       {
3607         sim_msg ("divisor address lookup failed because %s\r\n", msg);
3608       }
3609     else
3610       {
3611         sim_msg ("divisor %012"PRIo64" (%llu)\r\n", M[pa], M[pa]);
3612       }
3613     return SCPE_OK;
3614   }
3615 # endif // DVFDBG
3616 
3617 // SEARCHMEMORY value
3618 
3619 static t_stat search_memory (UNUSED int32 arg, const char * buf)
     /* [previous][next][first][last][top][bottom][index][help] */
3620   {
3621     word36 value;
3622     if (sscanf (buf, "%llo", & value) != 1)
3623       return SCPE_ARG;
3624 
3625     uint i;
3626     for (i = 0; i < MEMSIZE; i ++)
3627       if ((M[i] & DMASK) == value)
3628         sim_msg ("%08o\r\n", i);
3629     return SCPE_OK;
3630   }
3631 
3632 static t_stat set_dbg_cpu_mask (int32 UNUSED arg, const char * UNUSED buf)
     /* [previous][next][first][last][top][bottom][index][help] */
3633   {
3634     uint msk;
3635     int cnt = sscanf (buf, "%u", & msk);
3636     if (cnt != 1)
3637       {
3638         sim_msg ("Huh?\r\n");
3639         return SCPE_ARG;
3640       }
3641     sim_msg ("mask set to %u\r\n", msk);
3642     dbgCPUMask = msk;
3643     return SCPE_OK;
3644   }
3645 
3646 #endif // TESTING
3647 
3648 //
3649 // Misc. commands
3650 //
3651 
3652 #if defined(PANEL68)
3653 static t_stat scraper (UNUSED int32 arg, const char * buf)
     /* [previous][next][first][last][top][bottom][index][help] */
3654   {
3655     if (strcasecmp (buf, "start") == 0)
3656       return panelScraperStart ();
3657     if (strcasecmp (buf, "stop") == 0)
3658       return panelScraperStop ();
3659     if (strcasecmp (buf, "msg") == 0)
3660       {
3661         return panelScraperMsg (NULL);
3662       }
3663     if (strncasecmp (buf, "msg ", 4) == 0)
3664       {
3665         const char * p = buf + 4;
3666         while (* p == ' ')
3667           p ++;
3668         return panelScraperMsg (p);
3669       }
3670     sim_msg ("err: scraper start|stop|msg\r\n");
3671     return SCPE_ARG;
3672   }
3673 #endif
3674 
3675 #if defined(YIELD)
3676 static t_stat clear_yield (int32 flag, UNUSED const char * cptr)
     /* [previous][next][first][last][top][bottom][index][help] */
3677   {
3678     return SCPE_OK;
3679   }
3680 
3681 static t_stat yield (int32 flag, UNUSED const char * cptr)
     /* [previous][next][first][last][top][bottom][index][help] */
3682   {
3683     return SCPE_OK;
3684   }
3685 #endif
3686 
3687 #if !defined(PERF_STRIP)
3688 static t_stat set_luf (int32 flag, UNUSED const char * cptr)
     /* [previous][next][first][last][top][bottom][index][help] */
3689   {
3690     luf_flag = flag;
3691     return SCPE_OK;
3692   }
3693 #endif /* if !defined(PERF_STRIP) */
3694 
3695 #if defined(DBGEVENT)
3696 uint n_dbgevents;
3697 struct dbgevent_t dbgevents[max_dbgevents];
3698 struct timespec dbgevent_t0;
3699 
3700 static int dbgevent_compar (const void * a, const void * b)
     /* [previous][next][first][last][top][bottom][index][help] */
3701   {
3702     struct dbgevent_t * ea = (struct dbgevent_t *) a;
3703     struct dbgevent_t * eb = (struct dbgevent_t *) b;
3704     if (ea->segno < eb->segno)
3705       return -1;
3706     if (ea->segno > eb->segno)
3707       return 1;
3708     if (ea->offset < eb->offset)
3709       return -1;
3710     if (ea->offset > eb->offset)
3711       return 1;
3712     return 0;
3713   }
3714 
3715 int dbgevent_lookup (word15 segno, word18 offset)
     /* [previous][next][first][last][top][bottom][index][help] */
3716   {
3717     struct dbgevent_t key = {segno, offset, false};
3718     struct dbgevent_t * p = (struct dbgevent_t *) bsearch (& key, dbgevents, (size_t) n_dbgevents,
3719             sizeof (struct dbgevent_t), dbgevent_compar);
3720     if (! p)
3721       return -1;
3722     return (int) (p - dbgevents);
3723   }
3724 
3725 // "dbbevent segno:offset"
3726 //
3727 // arg: 0 set t0 event
3728 //      1 set event
3729 //      2 clear event
3730 //      3 list events
3731 //      4 clear all events
3732 
3733 // XXX think about per-thread timing?
3734 
3735 static t_stat set_dbgevent (int32 arg, const char * buf)
     /* [previous][next][first][last][top][bottom][index][help] */
3736   {
3737     if (arg == 0 || arg == 1)
3738       {
3739         if (n_dbgevents >= max_dbgevents)
3740           {
3741             sim_printf ("too many dbgevents %u/%u\r\n", n_dbgevents, max_dbgevents);
3742             return SCPE_ARG;
3743           }
3744         if (strlen (buf) > dbgevent_tagsize - 1)
3745           {
3746             sim_printf ("command too long %lu/%u\r\n", strlen (buf), dbgevent_tagsize -1);
3747             return SCPE_ARG;
3748           }
3749 
3750         uint segno;
3751         uint offset;
3752         if (sscanf (buf, "%o:%o", & segno, & offset) != 2)
3753           return SCPE_ARG;
3754         if (segno > MASK15 || offset > MASK18)
3755           return SCPE_ARG;
3756         if (dbgevent_lookup ((word15) segno, (word18) offset) != -1)
3757           {
3758             sim_printf ("not adding duplicate 0%o:0%o\r\n", segno, offset);
3759             return SCPE_ARG;
3760           }
3761         dbgevents[n_dbgevents].segno                     = (word15) segno;
3762         dbgevents[n_dbgevents].offset                    = (word18) offset;
3763         dbgevents[n_dbgevents].t0                        = arg == 0;
3764         strncpy (dbgevents[n_dbgevents].tag, buf, dbgevent_tagsize - 1);
3765         dbgevents[n_dbgevents].tag[dbgevent_tagsize - 1] = 0;
3766         sim_printf ("%o:%o %u(%d) %s\r\n", dbgevents[n_dbgevents].segno,
3767             dbgevents[n_dbgevents].offset,
3768                 dbgevents[n_dbgevents].t0, arg, dbgevents[n_dbgevents].tag);
3769         n_dbgevents ++;
3770         qsort (dbgevents, n_dbgevents, sizeof (struct dbgevent_t), dbgevent_compar);
3771       }
3772     else if (arg == 2)
3773       {
3774         uint segno;
3775         uint offset;
3776         if (sscanf (buf, "%o:%o", & segno, & offset) != 2)
3777           return SCPE_ARG;
3778         int n = dbgevent_lookup ((word15) segno, (word18) offset);
3779         if (n < 0)
3780           {
3781             sim_printf ("0%o:0%o not found\r\n", segno, offset);
3782             return SCPE_ARG;
3783           }
3784         for (int i = n; i < n_dbgevents - 1; i ++)
3785           dbgevents[i] = dbgevents[i + 1];
3786         n_dbgevents --;
3787       }
3788     else if (arg == 3)
3789       {
3790         for (int i = 0; i < n_dbgevents; i ++)
3791          sim_printf ("    %s %05o:%06o %s\r\n", dbgevents[i].t0 ? "T0" : "  ", dbgevents[i].segno,
3792                  dbgevents[i].offset,dbgevents[i].tag);
3793       }
3794     else if (arg == 4)
3795       {
3796         n_dbgevents = 0;
3797         sim_printf ("dbgevents cleared\r\n");
3798       }
3799     else
3800       {
3801         sim_printf ("set_dbgevent bad arg %d\r\n", arg);
3802         return SCPE_ARG;
3803       }
3804     return SCPE_OK;
3805   }
3806 #endif
3807 
3808 //  REWIND name
3809 //
3810 //  rewind tapa_05
3811 //
3812 
3813 t_stat rewind_media (int32 arg, const char * buf) {
     /* [previous][next][first][last][top][bottom][index][help] */
3814   char name[strlen (buf) + 1];
3815 
3816   int rc = sscanf (buf, "%s", name);
3817   if (rc != 1)
3818     return SCPE_ARG;
3819 
3820   for (uint i = 0; i < N_MT_UNITS_MAX; i ++) {
3821     if (strcmp (tape_states[i].device_name, name) == 0) {
3822       UNIT * unitp = & mt_unit [i];
3823       return sim_tape_rewind (unitp);
3824     }
3825   }
3826 
3827   sim_printf ("Can't find name '%s'\r\n", name);
3828   sim_printf ("REWIND device_name\r\n");
3829   return SCPE_ARG;
3830 }
3831 
3832 // [UN]LOAD  name  image_name ro|rw
3833 //
3834 //  load tapea_05  data.tap ro
3835 //
3836 //  load diskb_01  data.dsk rw
3837 //
3838 
3839 t_stat load_media (int32 arg, const char * buf)
     /* [previous][next][first][last][top][bottom][index][help] */
3840   {
3841     // arg 1: load
3842     //     0: unload
3843 
3844     char  name[strlen (buf) + 1];
3845     char fname[strlen (buf) + 1];
3846     char  perm[strlen (buf) + 1];
3847     bool ro = false;
3848     if (arg)
3849       {
3850         int rc = sscanf (buf, "%s %s %s", name, fname, perm);
3851         if (rc != 3)
3852           return SCPE_ARG;
3853         if (strcasecmp (perm, "rw") == 0)
3854           ro = false;
3855         else if (strcasecmp (perm, "ro") == 0)
3856           ro = true;
3857         else
3858           {
3859              sim_print ("'%s' not 'ro' or 'rw'\r\n", perm);
3860              goto usage;
3861           }
3862       }
3863     else
3864       {
3865         int rc = sscanf (buf, "%s", name);
3866         if (rc != 1)
3867           return SCPE_ARG;
3868       }
3869 
3870     for (uint i = 0; i < N_DSK_UNITS_MAX; i ++)
3871       if (strcmp (dsk_states[i].device_name, name) == 0)
3872         {
3873           if (arg)
3874             return loadDisk (i, fname, ro);
3875           return unloadDisk (i);
3876         }
3877 
3878     for (uint i = 0; i < N_MT_UNITS_MAX; i ++)
3879       if (strcmp (tape_states[i].device_name, name) == 0)
3880         {
3881           if (arg)
3882             return loadTape (i, fname, ro);
3883           return unloadTape (i);
3884         }
3885 
3886     sim_printf ("Can't find name '%s'\r\n", name);
3887 usage:
3888     sim_printf ("[UN]LOAD device_name image_name ro|rw\r\n");
3889     return SCPE_ARG;
3890   }
3891 
3892 t_stat ready_media (int32 arg, const char * buf) {
     /* [previous][next][first][last][top][bottom][index][help] */
3893   char name[strlen (buf) + 1];
3894   int rc = sscanf (buf, "%s", name);
3895   if (rc != 1)
3896     return SCPE_ARG;
3897 
3898   for (uint i = 0; i < N_DSK_UNITS_MAX; i ++) {
3899     if (strcmp (dsk_states[i].device_name, name) == 0) {
3900       return signal_disk_ready (i);
3901     }
3902   }
3903 
3904   for (uint i = 0; i < N_MT_UNITS_MAX; i ++) {
3905     if (strcmp (tape_states[i].device_name, name) == 0) {
3906       return signal_tape (i, 0, 020 /* tape drive to ready */); //-V536
3907     }
3908   }
3909 
3910   sim_printf ("Can't find name '%s'\r\n", name);
3911   sim_printf ("[UN]LOAD device_name image_name ro|rw\r\n");
3912   return SCPE_ARG;
3913 }
3914 
3915 ////////////////////////////////////////////////////////////////////////////////
3916 //
3917 // s*mh Command table
3918 //
3919 
3920 #if defined(TESTING)
3921 # include "tracker.h"
3922 
3923 static t_stat trkw (UNUSED int32 arg, const char * buf)
     /* [previous][next][first][last][top][bottom][index][help] */
3924   {
3925     trk_init (true);
3926     return SCPE_OK;
3927   }
3928 
3929 static t_stat trkr (UNUSED int32 arg, const char * buf)
     /* [previous][next][first][last][top][bottom][index][help] */
3930   {
3931     trk_init (false);
3932     return SCPE_OK;
3933   }
3934 #endif
3935 
3936 #if !defined(PERF_STRIP)
3937 static CTAB dps8_cmds[] =
3938   {
3939 //
3940 // System configuration
3941 //
3942 
3943     {"DEFAULT_BASE_SYSTEM", set_default_base_system,  0, "Set configuration to defaults\r\n",             NULL, NULL},
3944 
3945     {"CABLE",               sys_cable,                0, "String a cable.\r\n",                           NULL, NULL},
3946     {"UNCABLE",             sys_cable,                1, "Unstring a cable.\r\n",                         NULL, NULL},
3947     {"CABLE_RIPOUT",        sys_cable_ripout,         0, "Remove all cables from the configuration.\r\n", NULL, NULL},
3948     {"CABLE_SHOW",          sys_cable_show,           0, "Show the current cabling configuration.\r\n",   NULL, NULL},
3949 
3950     {"FNPSERVERPORT",       set_fnp_server_port,      0, "Set the FNP dialin TELNET port number\r\n",     NULL, NULL},
3951     {"FNPSERVERADDRESS",    set_fnp_server_address,   0, "Set the FNP dialin server binding address\r\n", NULL, NULL},
3952     {"FNPSERVER3270PORT",   set_fnp_3270_server_port, 0, "Set the FNP TN3270 dialin port number\r\n",     NULL, NULL},
3953 
3954 //
3955 // System control
3956 //
3957 
3958     {"SKIPBOOT",  boot_skip,                     0, "Skip forward on boot tape (SKIPBOOT [unit])\r\n",                  NULL, NULL},
3959     {"FNPSTART",  fnp_start,                     0, "Directs the simulator to immediately start listening for FNP connections.\r\n",
3960                                                                                                                         NULL, NULL},
3961     {"MOUNT",     mount_tape,                    0, "Mount tape image and signal Multics\r\n",                          NULL, NULL},
3962     {"LOAD",      load_media,                    1, "Mount disk or tape image and signal Multics\r\n",                  NULL, NULL},
3963     {"UNLOAD",    load_media,                    0, "Unmount disk or tape image and signal Multics\r\n",                NULL, NULL},
3964     {"READY",     ready_media,                   0, "Signal Multics that media is ready\r\n",                           NULL, NULL},
3965     {"REWIND",    rewind_media,                  0, "Rewind tape\r\n",                                                  NULL, NULL},
3966     {"XF",        do_execute_fault,              0, "Execute fault: Press the execute fault button\r\n",                NULL, NULL},
3967     {"XS",        do_execute_switches,           0, "Execute switches: Execute the instruction in the data switches\r\n", NULL, NULL},
3968     {"RESTART",   do_restart,                    0, "Execute fault: Press the execute fault button\r\n",                NULL, NULL},
3969     {"POLL",      set_sys_polling_interval,      0, "Set polling interval (in milliseconds)\r\n",                       NULL, NULL},
3970     {"SLOWPOLL",  set_sys_slow_polling_interval, 0, "Set slow polling interval (in polling intervals).\r\n",            NULL, NULL},
3971     {"CHECKPOLL", set_sys_poll_check_rate,       0, "Set polling check rate (in polling intervals).\r\n",               NULL, NULL},
3972     {"BURST",     burst_printer,                 0, "Burst process output from printer.\r\n",                           NULL, NULL},
3973 
3974 //
3975 // Debugging
3976 //
3977 
3978 # if defined(TESTING)
3979     {"TRKW",               trkw,                  0, "Start tracking to track.dat\r\n",                            NULL, NULL},
3980     {"TRKR",               trkr,                  0, "Start comparing with track.dat\r\n",                         NULL, NULL},
3981     {"DBGMMECNTDWN",       dps_debug_mme_cntdwn,  0, "Enable debug after n MMEs\r\n",                              NULL, NULL},
3982     {"DBGSKIP",            dps_debug_skip,        0, "Skip first n TRACE debugs\r\n",                              NULL, NULL},
3983     {"DBGSTART",           dps_debug_start,       0, "Limit debugging to N > Cycle count\r\n",                     NULL, NULL},
3984     {"DBGSTOP",            dps_debug_stop,        0, "Limit debugging to N < Cycle count\r\n",                     NULL, NULL},
3985     {"DBGBREAK",           dps_debug_break,       0, "Break when N >= Cycle count\r\n",                            NULL, NULL},
3986     {"DBGSEGNO",           dps_debug_segno,       1, "Limit debugging to PSR == segno\r\n",                        NULL, NULL},
3987     {"NODBGSEGNO",         dps_debug_segno,       0, "Reset to debugging all segments\r\n",                        NULL, NULL},
3988     {"DBGRINGNO",          dps_debug_ringno,      0, "Limit debugging to PRR == ringno\r\n",                       NULL, NULL},
3989     {"DBGBAR",             dps_debug_bar,         1, "Limit debugging to BAR mode\r\n",                            NULL, NULL},
3990     {"NODBGBAR",           dps_debug_bar,         0, "Limit debugging to BAR mode\r\n",                            NULL, NULL},
3991     {"HDBG",               hdbg_size,             0, "Set history debugger buffer size\r\n",                       NULL, NULL},
3992     {"HDSEG",              hdbgSegmentNumber,     0, "Set history debugger segment number\r\n",                    NULL, NULL},
3993     {"HDBL",               hdbgBlacklist,         0, "Set history debugger blacklist\r\n",                         NULL, NULL},
3994     {"PHDBG",              hdbg_print,            0, "Dump history buffer to 'hdbg0000.list'\r\n",                 NULL, NULL},
3995     {"HDBG_CPU_MASK",      hdbg_cpu_mask,         0, "Set which CPUs to track (by mask)\r\n",                      NULL, NULL},
3996     {"ABSOLUTE",           abs_addr,              0, "Compute the absolute address of segno:offset\r\n",           NULL, NULL},
3997     {"STK",                stack_trace,           0, "Print a stack trace\r\n",                                    NULL, NULL},
3998     {"LIST",               list_source_at,        0, "List source for address / segno:offset\r\n",                 NULL, NULL},
3999     {"LD_SYSTEM_BOOK",     load_system_book,      0, "Load a Multics system book for symbolic debugging\r\n",      NULL, NULL},
4000     {"ASBE",               add_system_book_entry, 0, "Add an entry to the system book\r\n",                        NULL, NULL},
4001     {"LOOKUP_SYSTEM_BOOK", lookup_system_book,    0, "Lookup an address or symbol in the Multics system book\r\n", NULL, NULL},
4002     {"LSB",                lookup_system_book,    0, "Lookup an address or symbol in the Multics system book\r\n", NULL, NULL},
4003     {"VIRTUAL",            virt_address,          0, "Compute the virtual address(es) of segno:offset\r\n",        NULL, NULL},
4004     {"SPATH",              set_search_path,       0, "Set source code search path\r\n",                            NULL, NULL},
4005     {"TEST",               brkbrk,                0, "GDB test hook\r\n",                                          NULL, NULL},
4006 #  if defined(DBGEVENT)
4007     {"DBG0EVENT",          set_dbgevent,          0, "Set t0 debug event\r\n",                                     NULL, NULL},
4008     {"DBGEVENT",           set_dbgevent,          1, "Set debug event\r\n",                                        NULL, NULL},
4009     {"DBGNOEVENT",         set_dbgevent,          2, "Clear debug event\r\n",                                      NULL, NULL},
4010     {"DBGLISTEVENTS",      set_dbgevent,          3, "List debug events\r\n",                                      NULL, NULL},
4011     {"DBGCLEAREVENTS",     set_dbgevent,          4, "Clear debug events\r\n",                                     NULL, NULL},
4012 #  endif /* if defined(DBGEVENT) */
4013 #  define SSH_ST 0        /* set */
4014 #  define SSH_SH 1        /* show */
4015 #  define SSH_CL 2        /* clear */
4016     {"SBREAK",       sbreak,           SSH_ST, "Set a breakpoint with segno:offset syntax\r\n", NULL, NULL},
4017     {"NOSBREAK",     sbreak,           SSH_CL, "Unset an SBREAK\r\n",                           NULL, NULL},
4018 #  if defined(DVFDBG)
4019     // dvf debugging
4020     {"DFX1ENTRY",    dfx1entry,        0,      "\r\n",                                          NULL, NULL},
4021     {"DFX2ENTRY",    dfx2entry,        0,      "\r\n",                                          NULL, NULL},
4022     {"DFX1EXIT",     dfx1exit,         0,      "\r\n",                                          NULL, NULL},
4023     {"DV2SCALE",     dv2scale,         0,      "\r\n",                                          NULL, NULL},
4024     {"MDFX3ENTRY",   mdfx3entry,       0,      "\r\n",                                          NULL, NULL},
4025     {"SMFX1ENTRY",   smfx1entry,       0,      "\r\n",                                          NULL, NULL},
4026 #  endif /* if defined(DVFDBG) */
4027 #  if !defined(SPEED)
4028     {"WATCH",        set_mem_watch,    1,      "Watch memory location\r\n",                     NULL, NULL},
4029     {"NOWATCH",      set_mem_watch,    0,      "Unwatch memory location\r\n",                   NULL, NULL},
4030 #  endif /* if !defined(SPEED) */
4031     {"SEARCHMEMORY", search_memory,    0,      "Search memory for value\r\n",                   NULL, NULL},
4032     {"DBGCPUMASK",   set_dbg_cpu_mask, 0,      "Set per-CPU debug enable mask\r\n",             NULL, NULL},
4033 # endif /* if defined(TESTING) */
4034 
4035     {"SEGLDR",       segment_loader,   0,      "Segment Loader\r\n",                            NULL, NULL},
4036 
4037 //
4038 // Statistics
4039 //
4040 
4041 # if defined(MATRIX)
4042     {"DISPLAYMATRIX", display_the_matrix,  0, "Display instruction usage counts\r\n", NULL, NULL},
4043 # endif
4044 
4045 //
4046 // Console scripting
4047 //
4048 
4049     {"AUTOINPUT",     add_opc_autoinput,   0, "Set primary console auto-input\r\n",     NULL, NULL},
4050     {"AI",            add_opc_autoinput,   0, "Set primary console auto-input\r\n",     NULL, NULL},
4051     {"AUTOINPUT2",    add_opc_autoinput,   1, "Set secondary console auto-input\r\n",   NULL, NULL},
4052     {"AI2",           add_opc_autoinput,   1, "Set secondary console auto-input\r\n",   NULL, NULL},
4053     {"CLRAUTOINPUT",  clear_opc_autoinput, 0, "Clear primary console auto-input\r\n",   NULL, NULL},
4054     {"CLRAUTOINPUT2", clear_opc_autoinput, 1, "Clear secondary console auto-input\r\n", NULL, NULL},
4055 
4056 //
4057 // Tuning
4058 //
4059 
4060 # if YIELD
4061     {"CLEAR_YIELD",   clear_yield,         1, "Clear yield data points\r\n",            NULL, NULL},
4062     {"YIELD",         yield,               1, "Define yield data point\r\n",            NULL, NULL},
4063 # endif
4064 
4065 //
4066 // Hacks
4067 //
4068 
4069     {"LUF",           set_luf,             1, "Enable normal LUF handling\r\n",         NULL, NULL},
4070     {"NOLUF",         set_luf,             0, "Disable normal LUF handling\r\n",        NULL, NULL},
4071 
4072 //
4073 // Misc.
4074 //
4075 
4076 # if defined(PANEL68)
4077     {"SCRAPER",       scraper,             0, "Control panel scraper\r\n", NULL, NULL},
4078 # endif /* if defined(PANEL68) */
4079     { NULL,           NULL,                0, NULL,                      NULL, NULL}
4080   }; // dps8_cmds
4081 
4082 # if !defined(__MINGW64__) && !defined(__MINGW32__) && !defined(CROSS_MINGW64) && !defined(CROSS_MINGW32) && !defined(PERF_STRIP)
4083 static void usr1_signal_handler (UNUSED int sig)
     /* [previous][next][first][last][top][bottom][index][help] */
4084   {
4085     sim_msg ("USR1 signal caught; pressing the EXF button\r\n");
4086     // Assume the bootload CPU
4087     setG7fault (ASSUME0, FAULT_EXF);
4088     return;
4089   }
4090 # endif
4091 
4092 static struct symbol_s symbols [] = {
4093     { "commit_id",              SYM_STATE_OFFSET,  SYM_STRING,    offsetof (struct system_state_s, commit_id)   },
4094     { "M[]",                    SYM_STATE_OFFSET,  SYM_ARRAY,     offsetof (struct system_state_s, M)           },
4095     { "sizeof(*M)",             SYM_STRUCT_SZ,     SYM_SZ,        sizeof (word36) },
4096 
4097     { "cpus[]",                 SYM_STATE_OFFSET,  SYM_ARRAY,     offsetof (struct system_state_s, cpus)        },
4098     { "sizeof(*cpus)",          SYM_STRUCT_SZ,     SYM_SZ,        sizeof (cpu_state_t) },
4099 
4100     { "cpus[].PPR",             SYM_STRUCT_OFFSET, SYM_PTR,       offsetof (cpu_state_t,           PPR)         },
4101     { "cpus[].PPR.PRR",         SYM_STRUCT_OFFSET, SYM_UINT8_3,   offsetof (struct ppr_s,          PRR)         },
4102     { "cpus[].PPR.PSR",         SYM_STRUCT_OFFSET, SYM_UINT16_15, offsetof (struct ppr_s,          PSR)         },
4103     { "cpus[].PPR.P",           SYM_STRUCT_OFFSET, SYM_UINT8_1,   offsetof (struct ppr_s,          P)           },
4104     { "cpus[].PPR.IC",          SYM_STRUCT_OFFSET, SYM_UINT32_18, offsetof (struct ppr_s,          IC)          },
4105 
4106     { "cpus[].cu",              SYM_STRUCT_OFFSET, SYM_PTR,       offsetof (cpu_state_t,           cu)          },
4107     { "cpus[].cu.IWB",          SYM_STRUCT_OFFSET, SYM_UINT64_36, offsetof (ctl_unit_data_t,       IWB)         },
4108     { "cpus[].cu.IR",           SYM_STRUCT_OFFSET, SYM_UINT32_18, offsetof (ctl_unit_data_t,       IR)          },
4109 
4110     { "cpus[].rA",              SYM_STRUCT_OFFSET, SYM_UINT64_36, offsetof (cpu_state_t,           rA)          },
4111 
4112     { "cpus[].rQ",              SYM_STRUCT_OFFSET, SYM_UINT64_36, offsetof (cpu_state_t,           rQ)          },
4113 
4114     { "cpus[].rE",              SYM_STRUCT_OFFSET, SYM_UINT64_36, offsetof (cpu_state_t,           rE)          },
4115 
4116     { "cpus[].rX[]",            SYM_STRUCT_OFFSET, SYM_ARRAY,     offsetof (cpu_state_t,           rX)          },
4117     { "sizeof(*rX)",            SYM_STRUCT_SZ,     SYM_SZ,        sizeof (word18) },
4118     { "cpus[].rX",              SYM_STRUCT_OFFSET, SYM_UINT32_18, 0 },
4119 
4120     { "cpus[].rTR",             SYM_STRUCT_OFFSET, SYM_UINT32_27, offsetof (cpu_state_t,           rTR)         },
4121 
4122     { "cpus[].rRALR",           SYM_STRUCT_OFFSET, SYM_UINT8_3,   offsetof (cpu_state_t,           rRALR)       },
4123 
4124     { "cpus[].PAR[]",           SYM_STRUCT_OFFSET, SYM_ARRAY,     offsetof (cpu_state_t,           PAR)         },
4125     { "sizeof(*PAR)",           SYM_STRUCT_SZ,     SYM_SZ,        sizeof (struct par_s) },
4126 
4127     { "cpus[].PAR[].SNR",       SYM_STRUCT_OFFSET, SYM_UINT16_15, offsetof (struct par_s,          SNR)         },
4128     { "cpus[].PAR[].RNR",       SYM_STRUCT_OFFSET, SYM_UINT8_3,   offsetof (struct par_s,          RNR)         },
4129     { "cpus[].PAR[].PR_BITNO",  SYM_STRUCT_OFFSET, SYM_UINT8_6,   offsetof (struct par_s,          PR_BITNO)    },
4130     { "cpus[].PAR[].WORDNO",    SYM_STRUCT_OFFSET, SYM_UINT32_18, offsetof (struct par_s,          WORDNO)      },
4131 
4132     { "cpus[].BAR",             SYM_STRUCT_OFFSET, SYM_PTR,       offsetof (cpu_state_t,           BAR)         },
4133     { "cpus[].BAR.BASE",        SYM_STRUCT_OFFSET, SYM_UINT16_9,  offsetof (struct bar_s,          BASE)        },
4134     { "cpus[].BAR.BOUND",       SYM_STRUCT_OFFSET, SYM_UINT16_9,  offsetof (struct bar_s,          BOUND)       },
4135 
4136     { "cpus[].TPR",             SYM_STRUCT_OFFSET, SYM_PTR,       offsetof (cpu_state_t,           TPR)         },
4137     { "cpus[].TPR.TRR",         SYM_STRUCT_OFFSET, SYM_UINT8_3,   offsetof (struct tpr_s,          TRR)         },
4138     { "cpus[].TPR.TSR",         SYM_STRUCT_OFFSET, SYM_UINT16_15, offsetof (struct tpr_s,          TSR)         },
4139     { "cpus[].TPR.TBR",         SYM_STRUCT_OFFSET, SYM_UINT8_6,   offsetof (struct tpr_s,          TBR)         },
4140     { "cpus[].TPR.CA",          SYM_STRUCT_OFFSET, SYM_UINT32_18, offsetof (struct tpr_s,          CA)          },
4141 
4142     { "cpus[].DSBR",            SYM_STRUCT_OFFSET, SYM_PTR,       offsetof (cpu_state_t,           DSBR)        },
4143     { "cpus[].DSBR.ADDR",       SYM_STRUCT_OFFSET, SYM_UINT32_24, offsetof (struct dsbr_s,         ADDR)        },
4144     { "cpus[].DSBR.BND",        SYM_STRUCT_OFFSET, SYM_UINT16_14, offsetof (struct dsbr_s,         BND)         },
4145     { "cpus[].DSBR.U",          SYM_STRUCT_OFFSET, SYM_UINT8_1,   offsetof (struct dsbr_s,         U)           },
4146     { "cpus[].DSBR.STACK",      SYM_STRUCT_OFFSET, SYM_UINT16_12, offsetof (struct dsbr_s,         STACK)       },
4147 
4148     { "cpus[].faultNumber",     SYM_STRUCT_OFFSET, SYM_UINT32,    offsetof (cpu_state_t,           faultNumber) },
4149 # define SYMTAB_ENUM32(e) { #e, SYM_ENUM,          SYM_UINT32,    e }
4150     SYMTAB_ENUM32 (FAULT_SDF),
4151     SYMTAB_ENUM32 (FAULT_STR),
4152     SYMTAB_ENUM32 (FAULT_MME),
4153     SYMTAB_ENUM32 (FAULT_F1),
4154     SYMTAB_ENUM32 (FAULT_TRO),
4155     SYMTAB_ENUM32 (FAULT_CMD),
4156     SYMTAB_ENUM32 (FAULT_DRL),
4157     SYMTAB_ENUM32 (FAULT_LUF),
4158     SYMTAB_ENUM32 (FAULT_CON),
4159     SYMTAB_ENUM32 (FAULT_PAR),
4160     SYMTAB_ENUM32 (FAULT_IPR),
4161     SYMTAB_ENUM32 (FAULT_ONC),
4162     SYMTAB_ENUM32 (FAULT_SUF),
4163     SYMTAB_ENUM32 (FAULT_OFL),
4164     SYMTAB_ENUM32 (FAULT_DIV),
4165     SYMTAB_ENUM32 (FAULT_EXF),
4166     SYMTAB_ENUM32 (FAULT_DF0),
4167     SYMTAB_ENUM32 (FAULT_DF1),
4168     SYMTAB_ENUM32 (FAULT_DF2),
4169     SYMTAB_ENUM32 (FAULT_DF3),
4170     SYMTAB_ENUM32 (FAULT_ACV),
4171     SYMTAB_ENUM32 (FAULT_MME2),
4172     SYMTAB_ENUM32 (FAULT_MME3),
4173     SYMTAB_ENUM32 (FAULT_MME4),
4174     SYMTAB_ENUM32 (FAULT_F2),
4175     SYMTAB_ENUM32 (FAULT_F3),
4176     SYMTAB_ENUM32 (FAULT_UN1),
4177     SYMTAB_ENUM32 (FAULT_UN2),
4178     SYMTAB_ENUM32 (FAULT_UN3),
4179     SYMTAB_ENUM32 (FAULT_UN4),
4180     SYMTAB_ENUM32 (FAULT_UN5),
4181     SYMTAB_ENUM32 (FAULT_TRB),
4182 
4183     { "",                       SYM_EMPTY,         SYM_UNDEF,     0 },
4184   };
4185 
4186 static void systabInit (void) {
     /* [previous][next][first][last][top][bottom][index][help] */
4187   strncpy (system_state->symbolTable.symtabHdr, SYMTAB_HDR, sizeof (system_state->symbolTable.symtabHdr));
4188   system_state->symbolTable.symtabVer = SYMTAB_VER;
4189   memcpy (system_state->symbolTable.symbols, symbols, sizeof (symbols)); //-V1086
4190 }
4191 #endif /* if !defined(PERF_STRIP) */
4192 
4193 static inline uint32_t
4194 hash32s(const void *buf, size_t len, uint32_t h)
     /* [previous][next][first][last][top][bottom][index][help] */
4195 {
4196   const unsigned char *p = buf;
4197 
4198   for (size_t i = 0; i < len; i++)
4199     h = h * 31 + p[i];
4200 
4201   h ^= h >> 17;
4202   h *= UINT32_C(0xed5ad4bb);
4203   h ^= h >> 11;
4204   h *= UINT32_C(0xac4c1b51);
4205   h ^= h >> 15;
4206   h *= UINT32_C(0x31848bab);
4207   h ^= h >> 14;
4208 
4209   return h;
4210 }
4211 
4212 // Once-only initialization; invoked via SCP
4213 
4214 static void dps8_init (void) {
     /* [previous][next][first][last][top][bottom][index][help] */
4215   int st1ret;
4216   (void)fflush(stderr);
4217   (void)fflush(stdout);
4218 #if !defined(PERF_STRIP)
4219   if (!sim_quiet) {
4220 # if defined(GENERATED_MAKE_VER_H) && defined(VER_H_GIT_VERSION)
4221 #  if defined(VER_H_GIT_PATCH_INT) && defined(VER_H_GIT_PATCH)
4222 #   if VER_H_GIT_PATCH_INT < 1
4223     sim_msg ("%s simulator %s (%ld-bit)",
4224              sim_name, VER_H_GIT_VERSION,
4225              (long)(CHAR_BIT*sizeof(void *)));
4226 #   else
4227     sim_msg ("%s simulator %s+%s (%ld-bit)",
4228              sim_name, VER_H_GIT_VERSION, VER_H_GIT_PATCH,
4229              (long)(CHAR_BIT*sizeof(void *)));
4230 #   endif
4231 #  else
4232     sim_msg ("%s simulator %s (%ld-bit)",
4233              sim_name, VER_H_GIT_VERSION,
4234              (long)(CHAR_BIT*sizeof(void *)));
4235 #  endif
4236 # endif
4237 # if !defined(VER_H_GIT_VERSION) || !defined(GENERATED_MAKE_VER_H)
4238     sim_msg ("%s simulator (%ld-bit)",
4239              sim_name, (long)(CHAR_BIT*sizeof(void *)));
4240 # endif
4241 
4242 /* TESTING */
4243 # if defined(TESTING)
4244     sim_msg ("\r\n Options: ");
4245 #  if !defined(HAVE_DPSOPT)
4246 #   define HAVE_DPSOPT 1
4247 #  endif
4248     sim_msg ("TESTING");
4249 # endif /* if defined(TESTING) */
4250 
4251 /* ISOLTS */
4252 # if defined(ISOLTS)
4253 #  if defined(HAVE_DPSOPT)
4254     sim_msg (", ");
4255 #  else
4256     sim_msg ("\r\n Options: ");
4257 #  endif
4258 #  if !defined(HAVE_DPSOPT)
4259 #   define HAVE_DPSOPT 1
4260 #  endif
4261     sim_msg ("ISOLTS");
4262 # endif /* if defined(ISOLTS) */
4263 
4264 /* NEED_128 */
4265 # if defined(NEED_128)
4266 #  if defined(HAVE_DPSOPT)
4267     sim_msg (", ");
4268 #  else
4269     sim_msg ("\r\n Options: ");
4270 #  endif
4271 #  if !defined(HAVE_DPSOPT)
4272 #   define HAVE_DPSOPT 1
4273 #  endif
4274     sim_msg ("NEED_128");
4275 # endif /* if defined(NEED_128) */
4276 
4277 /* NO_LOCKLESS */
4278 # if !defined(LOCKLESS)
4279 #  if defined(HAVE_DPSOPT)
4280     sim_msg (", ");
4281 #  else
4282     sim_msg ("\r\n Options: ");
4283 #  endif
4284 #  if !defined(HAVE_DPSOPT)
4285 #   define HAVE_DPSOPT 1
4286 #  endif
4287     sim_msg ("NO_LOCKLESS");
4288 # endif /* if !defined(LOCKLESS) */
4289 
4290 /* PANEL68 */
4291 # if defined(PANEL68)
4292 #  if defined(HAVE_DPSOPT)
4293     sim_msg (", ");
4294 #  else
4295     sim_msg ("\r\n Options: ");
4296 #  endif
4297 #  if !defined(HAVE_DPSOPT)
4298 #   define HAVE_DPSOPT 1
4299 #  endif
4300     sim_msg ("PANEL68");
4301 # endif /* if defined(PANEL68) */
4302 
4303 /* ABSI */  /* XXX: Change to !ABSI once code is non-experimental */
4304 # if defined(WITH_ABSI_DEV)
4305 #  if defined(HAVE_DPSOPT)
4306     sim_msg (", ");
4307 #  else
4308     sim_msg ("\r\n Options: ");
4309 #  endif
4310 #  if !defined(HAVE_DPSOPT)
4311 #   define HAVE_DPSOPT 1
4312 #  endif
4313     sim_msg ("ABSI");
4314 # endif /* if defined(WITH_ABSI_DEV) */
4315 
4316 /* SOCKET */  /* XXX: Change to !SOCKET once code is non-experimental */
4317 # if defined(WITH_SOCKET_DEV)
4318 #  if defined(HAVE_DPSOPT)
4319     sim_msg (", ");
4320 #  else
4321     sim_msg ("\r\n Options: ");
4322 #  endif
4323 #  if !defined(HAVE_DPSOPT)
4324 #   define HAVE_DPSOPT 1
4325 #  endif
4326     sim_msg ("SOCKET");
4327 # endif /* if defined(WITH_SOCKET_DEV) */
4328 
4329 /* CHAOSNET */
4330 # if !defined(WITH_MGP_DEV)
4331 #  if defined(HAVE_DPSOPT)
4332     sim_msg (", ");
4333 #  else
4334     sim_msg ("\r\n Options: ");
4335 #  endif
4336 #  if !defined(HAVE_DPSOPT)
4337 #   define HAVE_DPSOPT 1
4338 #  endif
4339     sim_msg ("NO_CHAOSNET");
4340 # endif /* if !defined(WITH_MGP_DEV) */
4341 
4342 /* INTERNET */
4343 # if !defined(WITH_NET_DEV)
4344 #  if defined(HAVE_DPSOPT)
4345     sim_msg (", ");
4346 #  else
4347     sim_msg ("\r\n Options: ");
4348 #  endif
4349 #  if !defined(HAVE_DPSOPT)
4350 #   define HAVE_DPSOPT 1
4351 #  endif
4352     sim_msg ("NO_INTERNET");
4353 # endif /* if !defined(WITH_NET_DEV) */
4354 
4355 /* DUMA */
4356 # if defined(USE_DUMA)
4357 #  if defined(HAVE_DPSOPT)
4358     sim_msg (", ");
4359 #  else
4360     sim_msg ("\r\n Options: ");
4361 #  endif
4362 #  if !defined(HAVE_DPSOPT)
4363 #   define HAVE_DPSOPT 1
4364 #  endif
4365     sim_msg ("DUMA");
4366 # endif /* if defined(USE_DUMA) */
4367 
4368 # if defined(GENERATED_MAKE_VER_H) && defined(VER_H_GIT_HASH)
4369     sim_msg ("\r\n  Commit: %s", VER_H_GIT_HASH);
4370 # endif
4371     sim_msg ("\r\n\r\n");
4372     (void)fflush(stderr);
4373     (void)fflush(stdout);
4374   }
4375 
4376   // special dps8 initialization stuff that can't be done in reset, etc. ...
4377 
4378 # if defined(TESTING)
4379   // These are part of the scp interface
4380   sim_vm_parse_addr  = parse_addr;
4381   sim_vm_fprint_addr = fprint_addr;
4382 # endif /* if defined(TESTING) */
4383 
4384   sim_vm_cmd = dps8_cmds;
4385 
4386   // This is needed to make sbreak work
4387   sim_brk_types = sim_brk_dflt = SWMASK ('E');
4388 
4389 # if !defined(__MINGW64__) && !defined(__MINGW32__) && !defined(CROSS_MINGW32) && !defined(CROSS_MINGW64)
4390   // Wire the XF button to signal USR1
4391   signal (SIGUSR1, usr1_signal_handler);
4392   // On line 4,739 of the libuv man page, it recommends this.
4393   signal(SIGPIPE, SIG_IGN);
4394 # endif /* if !defined(__MINGW64__) && !defined(__MINGW32__) && !defined(CROSS_MINGW32) && !defined(CROSS_MINGW64) */
4395 
4396 #endif
4397 
4398 #if defined(__MINGW64__) || defined(__MINGW32__)
4399 # include "bsd_random.h"
4400 # define random  bsd_random
4401 # define srandom bsd_srandom
4402 #endif /* if defined(__MINGW64__) || defined(__MINGW32__) */
4403 
4404   char   rcap = 0;
4405   char   rnum = 0;
4406   struct timespec ts;
4407 
4408   char   rssuffix[24];
4409   (void)memset(rssuffix, 0, 24);
4410 
4411   char   statenme[32];
4412   (void)memset(statenme, 0, 32);
4413 
4414 #if defined(USE_MONOTONIC)
4415   st1ret = clock_gettime(CLOCK_MONOTONIC, &ts);
4416 #else
4417   st1ret = clock_gettime(CLOCK_REALTIME, &ts);
4418 #endif /* if defined(USE_MONOTONIC) */
4419   if (st1ret != 0)
4420     {
4421       (void)sir_emerg ("FATAL: clock_gettime failure! Aborting at %s[%s:%d]",
4422                        __func__, __FILE__, __LINE__);
4423 #if defined(USE_BACKTRACE)
4424 # if defined(SIGUSR2)
4425       (void)raise(SIGUSR2);
4426       /*NOTREACHED*/ /* unreachable */
4427 # endif /* if defined(SIGUSR2) */
4428 #endif /* if defined(USE_BACKTRACE) */
4429       abort();
4430     }
4431 
4432   uint32_t h = 0;  /* initial hash value */
4433 #if __STDC_VERSION__ < 201112L
4434   /* LINTED E_OLD_STYLE_FUNC_DECL */
4435   void *(*mallocptr)() = malloc;
4436   h = hash32s(&mallocptr, sizeof(mallocptr), h);
4437 #endif /* if __STDC_VERSION__ < 201112L */
4438   void *ptr = &ptr;
4439   h = hash32s(&ptr, sizeof(ptr), h);
4440   time_t t = time(0);
4441   h = hash32s(&t, sizeof(t), h);
4442 #if !defined(_AIX) && !defined(__managarm__)
4443   for (int i = 0; i < 1000; i++)
4444     {
4445       unsigned long counter = 0;
4446       clock_t start = clock();
4447       while (clock() == start)
4448         {
4449           counter++;
4450         }
4451       h = hash32s(&start, sizeof(start), h);
4452       h = hash32s(&counter, sizeof(counter), h);
4453     }
4454 #endif /* if !defined(_AIX) */
4455   int mypid = (int)_sir_getpid();
4456   h = hash32s(&mypid, sizeof(mypid), h);
4457   char rnd[4];
4458   FILE *f = fopen("/dev/urandom", "rb");
4459   if (f)
4460     {
4461       if (fread(rnd, sizeof(rnd), 1, f))
4462         {
4463           h = hash32s(rnd, sizeof(rnd), h);
4464         }
4465       fclose(f);
4466     }
4467   srandom(h); /* seed rng */
4468 
4469   for (int i = 1; i < 21; ++i) {
4470     rcap = (int)random() % 2;
4471     rnum = (int)random() % 3;
4472     if (!rnum) rnum = (((int)random() % 10) + 48);
4473     if (!rcap) rcap = 33;
4474     if (rnum >= 48) rssuffix[i-1]=rnum;
4475     else rssuffix[i-1]=(char)(((long)random() % 26) + 64) + rcap;
4476   }
4477 
4478 #if defined(__MINGW64__)   || \
4479     defined(__MINGW32__)   || \
4480     defined(CROSS_MINGW32) || \
4481     defined(CROSS_MINGW64)
4482   system_state = aligned_malloc (sizeof (struct system_state_s));
4483 #else
4484   if (sim_randstate)
4485     (void)sprintf(statenme, "%s.state", rssuffix);
4486   else
4487     (void)sprintf(statenme, "state");
4488   if (!sim_nostate)
4489     system_state = (struct system_state_s *)
4490       create_shm (statenme, sizeof (struct system_state_s));
4491   else
4492 # if !defined(_AIX)
4493     system_state = aligned_malloc (sizeof (struct system_state_s));
4494 # else
4495     system_state = malloc (sizeof (struct system_state_s));
4496 # endif
4497 #endif
4498 
4499   if (!system_state) {
4500     int svErrno = errno;
4501     (void)fflush(stderr);
4502     (void)fflush(stdout);
4503     (void)sir_emerg ("FATAL: %s: aborting at %s[%s:%d]",
4504                      xstrerror_l(svErrno), __func__, __FILE__, __LINE__);
4505 #if defined(USE_BACKTRACE)
4506 # if defined(SIGUSR2)
4507     (void)raise(SIGUSR2);
4508     /*NOTREACHED*/ /* unreachable */
4509 # endif /* if defined(SIGUSR2) */
4510 #endif /* if defined(USE_BACKTRACE) */
4511     exit (svErrno);
4512   }
4513 #if !defined(__MINGW64__) && !defined(__MINGW32__) && !defined(CROSS_MINGW64) && !defined(CROSS_MINGW32) && !defined(__PASE__)
4514   if (!sim_nostate) {
4515     if (0 == sim_free_memory || sim_free_memory >= 192000000) {
4516       if (mlock(system_state, sizeof(struct system_state_s)) == -1) {
4517         mlock_failure = true;
4518       }
4519     } else {
4520 # if defined(TESTING)
4521       sim_warn ("No memory locking attempted.\r\n");
4522 # else
4523       (void)system_state;
4524 # endif
4525     }
4526   }
4527 #endif
4528 
4529 #if !defined(PERF_STRIP)
4530 
4531 # if !defined(VER_H_GIT_HASH)
4532 #  define VER_H_GIT_HASH "0000000000000000000000000000000000000000"
4533 # endif /* if !defined(VER_H_GIT_HASH) */
4534 
4535   (void)fflush(stdout);
4536   (void)fflush(stderr);
4537   // An unshared state allocation contains no saved header.  In particular,
4538   // its contents must not be inspected before initialization under MSan.
4539   bool fresh_state = sim_nostate;
4540 # if defined(__MINGW64__) || defined(__MINGW32__) || defined(CROSS_MINGW64) || defined(CROSS_MINGW32)
4541   fresh_state = true; // Windows always uses a fresh aligned allocation above.
4542 # endif
4543   if (fresh_state) {
4544     (void)memset (system_state, 0, sizeof (*system_state));
4545   } else if (system_state->commit_id[0] == '\0') {
4546     if (!sim_quiet && sim_randstate && sim_randompst)
4547       sim_printf ("Initialized new system state file \"dps8m.%s\"\r\n",
4548                   statenme);
4549   } else {
4550     if (strncmp (system_state->commit_id, VER_H_GIT_HASH,
4551                  sizeof (system_state->commit_id)) != 0) {
4552       (void)memset(system_state, 0, sizeof(*system_state));
4553       sim_warn ("NOTE: State hash mismatch; system state reset.\r\n");
4554     }
4555   }
4556   (void)fflush(stderr);
4557   (void)fflush(stdout);
4558 
4559   strncpy (system_state->stateHdr, STATE_HDR, sizeof (system_state->stateHdr));
4560   system_state->stateVer = STATE_VER;
4561   strncpy (system_state->commit_id, VER_H_GIT_HASH, sizeof (system_state->commit_id));
4562 
4563   systabInit ();
4564 
4565   // sets connect to 0
4566   (void)memset (& sys_opts, 0, sizeof (sys_opts));
4567   // sys_poll_interval 10 ms (100 Hz)
4568   sys_opts.sys_poll_interval      = 10;
4569   // sys_slow_poll_interval 100 polls (1 Hz)
4570   sys_opts.sys_slow_poll_interval = 100;
4571   // sys_poll_check_rate in CPU cycles
4572   sys_opts.sys_poll_check_rate    = 1024;
4573 #endif // ! PERF_STRIP
4574 
4575 #if defined(PERF_STRIP)
4576   cpu_init ();
4577 #else
4578   sysCableInit ();
4579   iom_init ();
4580   disk_init ();
4581   mt_init ();
4582 # if defined(WITH_SOCKET_DEV)
4583 #  if !defined(__MINGW64__) && !defined(__MINGW32__) && !defined(CROSS_MINGW64) && !defined(CROSS_MINGW32)
4584   sk_init ();
4585 #  endif /* if !defined(__MINGW64__) && !defined(__MINGW32__) && !defined(CROSS_MINGW64) && !defined(CROSS_MINGW32) */
4586 # endif /* if defined(WITH_SOCKET_DEV) */
4587   fnpInit ();
4588   console_init (); // must come after fnpInit due to libuv initialization
4589   scu_init ();
4590   cpu_init ();
4591   rdr_init ();
4592   pun_init ();
4593   prt_init ();
4594   urp_init ();
4595 
4596 # if defined(WITH_ABSI_DEV)
4597 #  if !defined(__MINGW64__) && !defined(__MINGW32__) && !defined(CROSS_MINGW64) && !defined(CROSS_MINGW32)
4598   absi_init ();
4599 #  endif /* if !defined(__MINGW64__) && !defined(__MINGW32__) && !defined(CROSS_MINGW64) && !defined(CROSS_MINGW32) */
4600 # endif /* if defined(WITH_ABSI_DEV) */
4601 
4602 # if defined(WITH_MGP_DEV)
4603   mgp_init ();
4604 # endif /* if defined(WITH_MGP_DEV) */
4605 
4606 # if defined(WITH_NET_DEV)
4607   net_init ();
4608 # endif /* if defined(WITH_NET_DEV) */
4609 
4610   set_default_base_system (0, NULL);
4611 # if defined(PANEL68)
4612   panelScraperInit ();
4613 # endif /* if defined(PANEL68) */
4614 #endif
4615 #if defined(THREADZ) || defined(LOCKLESS)
4616   initThreadz ();
4617 #endif /* if defined(THREADZ) || defined(LOCKLESS) */
4618 }
4619 
4620 // Once-only shutdown; invoked via SCP
4621 
4622 static void dps8_exit (void) {
     /* [previous][next][first][last][top][bottom][index][help] */
4623   cpu_stop_poll_timer ();
4624   console_exit ();
4625   mt_exit ();
4626   fnpExit ();
4627 }
4628 
4629 #if defined(TESTING)
4630 static struct pr_table
4631   {
4632     char  * alias;    // pr alias
4633     int   n;          // number alias represents ....
4634   } _prtab[] =
4635   {
4636     { "pr0",   0 }, ///< pr0 - 7
4637     { "pr1",   1 },
4638     { "pr2",   2 },
4639     { "pr3",   3 },
4640     { "pr4",   4 },
4641     { "pr5",   5 },
4642     { "pr6",   6 },
4643     { "pr7",   7 },
4644 
4645     { "pr[0]", 0 }, ///< pr0 - 7
4646     { "pr[1]", 1 },
4647     { "pr[2]", 2 },
4648     { "pr[3]", 3 },
4649     { "pr[4]", 4 },
4650     { "pr[5]", 5 },
4651     { "pr[6]", 6 },
4652     { "pr[7]", 7 },
4653 
4654     // See: https://multicians.org/pg/mvm.html
4655     { "ap",    0 },
4656     { "ab",    1 },
4657     { "bp",    2 },
4658     { "bb",    3 },
4659     { "lp",    4 },
4660     { "lb",    5 },
4661     { "sp",    6 },
4662     { "sb",    7 },
4663     {    0,    0 }
4664   };
4665 
4666 static int getAddress(int segno, int offset)
     /* [previous][next][first][last][top][bottom][index][help] */
4667 {
4668     // XXX Do we need to 1st check SDWAM for segment entry?
4669 
4670     // get address of in-core segment descriptor word from DSBR
4671     sdw0_s *s = fetchSDW ((word15) segno);
4672 
4673     return (s->ADDR + (word18) offset) & 0xffffff; // keep to 24-bits
4674 }
4675 
4676 static t_addr parse_addr (UNUSED DEVICE * dptr, const char *cptr,
     /* [previous][next][first][last][top][bottom][index][help] */
4677                           const char **optr)
4678   {
4679     cpu_state_t * cpup = _cpup;
4680     // a segment reference?
4681     if (strchr(cptr, '|'))
4682     {
4683         static char addspec[256];
4684         (void)strcpy(addspec, cptr);
4685 
4686         *strchr(addspec, '|') = ' ';
4687 
4688         char seg[256], off[256];
4689         int params = sscanf(addspec, "%s %s", seg, off);
4690         if (params != 2)
4691         {
4692             sim_warn("parse_addr(): illegal number of parameters\r\n");
4693             *optr = cptr;   // signal error
4694             return 0;
4695         }
4696 
4697         // determine if segment is numeric or symbolic...
4698         char *endp;
4699         word18 PRoffset = 0;   // offset from PR[n] register (if any)
4700         int segno = (int)strtoll(seg, &endp, 8);
4701         if (endp == seg)
4702         {
4703             // not numeric...
4704             // 1st, see if it's a PR or alias thereof
4705             struct pr_table *prt = _prtab;
4706             while (prt->alias)
4707             {
4708                 if (strcasecmp(seg, prt->alias) == 0)
4709                 {
4710                     segno = cpu.PR[prt->n].SNR;
4711                     PRoffset = cpu.PR[prt->n].WORDNO;
4712                     break;
4713                 }
4714 
4715                 prt += 1;
4716             }
4717 
4718             if (!prt->alias)    // not a PR or alias
4719             {
4720               return 0;
4721             }
4722         }
4723 
4724         // determine if offset is numeric or symbolic entry point/segdef...
4725         uint offset = (uint)strtoll(off, &endp, 8);
4726         if (endp == off)
4727         {
4728             // not numeric...
4729             return 0;
4730         }
4731 
4732         // if we get here then seg contains a segment# and offset.
4733         // So, fetch the actual address given the segment & offset ...
4734         // ... and return this absolute, 24-bit address
4735 
4736         word24 abs_addr = (word24) getAddress(segno, (int) (offset + PRoffset));
4737 
4738         // TODO: only by luck does this work FixMe
4739         *optr = endp;   //cptr + strlen(cptr);
4740 
4741         return abs_addr;
4742     }
4743     else
4744     {
4745         // a PR or alias thereof
4746         int segno = 0;
4747         word24 offset = 0;
4748         struct pr_table *prt = _prtab;
4749         while (prt->alias)
4750         {
4751             if (strncasecmp(cptr, prt->alias, strlen(prt->alias)) == 0)
4752             {
4753                 segno  = cpu.PR[prt->n].SNR;
4754                 offset = cpu.PR[prt->n].WORDNO;
4755                 break;
4756             }
4757 
4758             prt += 1;
4759         }
4760         if (prt->alias)    // a PR or alias
4761         {
4762             word24 abs_addr = (word24) getAddress(segno, (int) offset);
4763             *optr = cptr + strlen(prt->alias);
4764 
4765             return abs_addr;
4766         }
4767     }
4768 
4769     // No, determine absolute address given by cptr
4770     return (t_addr)strtol(cptr, (char **) optr, 8);
4771 }
4772 #endif // TESTING
4773 
4774 #if defined(TESTING)
4775 static void fprint_addr (FILE * stream, UNUSED DEVICE *  dptr, t_addr simh_addr)
     /* [previous][next][first][last][top][bottom][index][help] */
4776 {
4777     (void)fprintf(stream, "%06o", simh_addr);
4778 }
4779 #endif // TESTING
4780 
4781 // This is part of the scp interface
4782 // Based on the switch variable, symbolically output to stream ofile the data in
4783 //  array val at the specified addr in unit uptr.
4784 // "fprint_sym" - Based on the switch variable, symbolically output to
4785 // stream ofile the data in array val at the specified addr in unit uptr.
4786 
4787 t_stat fprint_sym (UNUSED FILE * ofile, UNUSED t_addr addr,
     /* [previous][next][first][last][top][bottom][index][help] */
4788                    UNUSED t_value *val, UNUSED UNIT *uptr, int32 UNUSED sw)
4789 {
4790 #if defined(TESTING)
4791 // XXX Bug: assumes single cpu
4792 // XXX CAC: This seems rather bogus; deciding the output format based on the
4793 // address of the UNIT? Would it be better to use sim_unit.u3 (or some such
4794 // as a word width?
4795 
4796     cpu_state_t * cpup = _cpup;
4797 
4798     if (!((uint) sw & SWMASK ('M')))
4799         return SCPE_ARG;
4800 
4801     if (uptr == &cpu_dev.units[0])
4802     {
4803         word36 word1 = *val;
4804         char buf[256];
4805         // get base syntax
4806         char *d = disassemble(buf, word1);
4807 
4808         (void)fprintf(ofile, "%s", d);
4809 
4810         // decode instruction
4811         DCDstruct ci;
4812         DCDstruct * p = & ci;
4813         decode_instruction (cpup, word1, p);
4814 
4815         // MW EIS?
4816         if (p->info->ndes > 1)
4817         {
4818             // Yup, just output word values (for now)
4819             // XXX Need to complete MW EIS support in disassemble()
4820 
4821             for(uint n = 0 ; n < p->info->ndes; n += 1)
4822                 (void)fprintf(ofile, " %012llo", (unsigned long long int)val[n + 1]);
4823 
4824             return (t_stat) -p->info->ndes;
4825         }
4826 
4827         return SCPE_OK;
4828 
4829         //(void)fprintf(ofile, "%012"PRIo64"", *val);
4830         //return SCPE_OK;
4831     }
4832 #endif
4833     return SCPE_ARG;
4834 }
4835 
4836 // This is part of the scp interface
4837 //  - Based on the switch variable, parse character string cptr for a
4838 //  symbolic value val at the specified addr in unit uptr.
4839 
4840 t_stat parse_sym (UNUSED const char * cptr, UNUSED t_addr addr,
     /* [previous][next][first][last][top][bottom][index][help] */
4841                   UNUSED UNIT * uptr, UNUSED t_value * val, UNUSED int32 sswitch)
4842   {
4843     return SCPE_ARG;
4844   }
4845 
4846 #if defined(THREADZ) || defined(LOCKLESS)
4847 volAtomic bool syncClockMode;
4848 volAtomic uint syncClockModeMasterIdx; // The CPU sync master
4849 #endif
4850 
4851 // from MM
4852 
4853 sysinfo_t sys_opts;
4854 
4855 static t_stat sys_show_config (UNUSED FILE * st, UNUSED UNIT * uptr,
     /* [previous][next][first][last][top][bottom][index][help] */
4856                                UNUSED int  val, UNUSED const void * desc)
4857   {
4858     sim_msg ("IOM connect time:         %d\r\n", sys_opts.iom_times.connect);
4859     sim_msg ("nosync                    %d\r\n", sys_opts.nosync);
4860     sim_msg ("tandd_io                  %d\r\n", sys_opts.tandd_io);
4861     return SCPE_OK;
4862 }
4863 
4864 static config_value_list_t cfg_timing_list[] =
4865   {
4866     { "disable", -1 },
4867     {  NULL,      0 }
4868   };
4869 
4870 bool breakEnable = false;
4871 
4872 static t_stat sys_set_break (UNUSED UNIT *  uptr, int32 value,
     /* [previous][next][first][last][top][bottom][index][help] */
4873                              UNUSED const char * cptr, UNUSED void * desc)
4874   {
4875     breakEnable = !! value;
4876     return SCPE_OK;
4877   }
4878 
4879 static t_stat sys_show_break (UNUSED FILE * st, UNUSED UNIT * uptr,
     /* [previous][next][first][last][top][bottom][index][help] */
4880                               UNUSED int  val, UNUSED const void * desc)
4881   {
4882     sim_msg ("BREAK %s\r\n", breakEnable ? "ON" : "OFF" );
4883     return SCPE_OK;
4884   }
4885 
4886 static config_value_list_t cfg_on_off [] =
4887   {
4888     { "off",     0 },
4889     { "on",      1 },
4890     { "disable", 0 },
4891     { "enable",  1 },
4892     {  NULL,     0 }
4893   };
4894 
4895 static config_list_t sys_config_list[] =
4896   {
4897     { "connect_time", -1,  100000, cfg_timing_list },
4898     { "nosync",        0,  1,      cfg_on_off      },
4899     { "color",         0,  1,      cfg_on_off      },
4900     { "tandd_io",      0,  1,      cfg_on_off      },
4901     { NULL,            0,  0,      NULL            }
4902  };
4903 
4904 static t_stat sys_set_config (UNUSED UNIT *  uptr, UNUSED int32 value,
     /* [previous][next][first][last][top][bottom][index][help] */
4905                               const char * cptr, UNUSED void * desc)
4906   {
4907     config_state_t cfg_state = { NULL, NULL };
4908 
4909     for (;;)
4910       {
4911         int64_t v;
4912         int rc = cfg_parse ("sys_set_config", cptr, sys_config_list, & cfg_state,
4913                            & v);
4914         if (rc == -1) // done
4915           {
4916             break;
4917           }
4918         if (rc == -2) // error
4919           {
4920             cfg_parse_done (& cfg_state);
4921             return SCPE_ARG;
4922           }
4923 
4924         const char * p = sys_config_list[rc].name;
4925         if (strcmp (p, "connect_time") == 0)
4926           sys_opts.iom_times.connect = (int) v;
4927         else if (strcmp (p, "color") == 0)
4928           sys_opts.no_color = ! v;
4929         else if (strcmp (p, "nosync") == 0)
4930           sys_opts.nosync = !! v;
4931         else if (strcmp (p, "tandd_io") == 0)
4932           sys_opts.tandd_io = !! v;
4933         else
4934           {
4935             sim_msg ("error: sys_set_config: Invalid cfg_parse rc <%ld>\r\n", (long) rc);
4936             cfg_parse_done (& cfg_state);
4937             return SCPE_ARG;
4938           }
4939       } // process statements
4940     cfg_parse_done (& cfg_state);
4941     return SCPE_OK;
4942   }
4943 
4944 static MTAB sys_mod[] =
4945   {
4946     {
4947       MTAB_dev_value,           /* Mask               */
4948       0,                        /* Match              */
4949       (char *) "CONFIG",        /* Print string       */
4950       (char *) "CONFIG",        /* Match string       */
4951       sys_set_config,           /* Validation routine */
4952       sys_show_config,          /* Display routine    */
4953       NULL,                     /* Value descriptor   */
4954       NULL,                     /* Help               */
4955     },
4956     {
4957       MTAB_dev_novalue,         /* Mask               */
4958       1,                        /* Match              */
4959       (char *) "BREAK",         /* Print string       */
4960       (char *) "BREAK",         /* Match string       */
4961       sys_set_break,            /* Validation routine */
4962       sys_show_break,           /* Display routine    */
4963       NULL,                     /* Value descriptor   */
4964       NULL,                     /* Help               */
4965     },
4966     {
4967       MTAB_dev_novalue,         /* Mask               */
4968       0,                        /* Match              */
4969       (char *) "NOBREAK",       /* Print string       */
4970       (char *) "NOBREAK",       /* Match string       */
4971       sys_set_break,            /* Validation routine */
4972       sys_show_break,           /* Display routine    */
4973       NULL,                     /* Value descriptor   */
4974       NULL,                     /* Help               */
4975     },
4976     MTAB_eol
4977   };
4978 
4979 static t_stat sys_reset (UNUSED DEVICE  * dptr)
     /* [previous][next][first][last][top][bottom][index][help] */
4980   {
4981     return SCPE_OK;
4982   }
4983 
4984 static DEVICE sys_dev = {
4985     "SYS",       /* Name                */
4986     NULL,        /* Units               */
4987     NULL,        /* Registers           */
4988     sys_mod,     /* Modifiers           */
4989     0,           /* #Units              */
4990     8,           /* Address radix       */
4991     PASIZE,      /* Address width       */
4992     1,           /* Address increment   */
4993     8,           /* Data radix          */
4994     36,          /* Data width          */
4995     NULL,        /* Examine routine     */
4996     NULL,        /* Deposit routine     */
4997     & sys_reset, /* Reset routine       */
4998     NULL,        /* Boot routine        */
4999     NULL,        /* Attach routine      */
5000     NULL,        /* Detach routine      */
5001     NULL,        /* Context             */
5002     0,           /* Flags               */
5003     0,           /* Debug control flags */
5004     0,           /* Debug flag names    */
5005     NULL,        /* Memory size change  */
5006     NULL,        /* Logical name        */
5007     NULL,        /* Help                */
5008     NULL,        /* Attach_help         */
5009     NULL,        /* Help_ctx            */
5010     NULL,        /* Description         */
5011     NULL         /* End                 */
5012 };
5013 
5014 // This is part of the scp interface
5015 DEVICE * sim_devices[] =
5016   {
5017     & cpu_dev, // dev[0] is special to the scp interface; it is the 'default device'
5018     & iom_dev,
5019     & tape_dev,
5020 #if defined(WITH_SOCKET_DEV)
5021 # if !defined(__MINGW64__) && !defined(__MINGW32__) && !defined(CROSS_MINGW32) && !defined(CROSS_MINGW64)
5022     & skc_dev,
5023 # endif /* if !defined(__MINGW64__) && !defined(__MINGW32__) && !defined(CROSS_MINGW32) && !defined(CROSS_MINGW64) */
5024 #endif /* if defined(WITH_SOCKET_DEV) */
5025     & mtp_dev,
5026     & fnp_dev,
5027     & dsk_dev,
5028     & ipc_dev,
5029     & msp_dev,
5030     & scu_dev,
5031     & opc_dev,
5032     & sys_dev,
5033     & urp_dev,
5034     & rdr_dev,
5035     & pun_dev,
5036     & prt_dev,
5037 
5038 #if defined(WITH_ABSI_DEV)
5039 # if !defined(__MINGW64__) && !defined(__MINGW32__) && !defined(CROSS_MINGW32) && !defined(CROSS_MINGW64)
5040     & absi_dev,
5041 # endif /* if !defined(__MINGW64__) && !defined(__MINGW32__) && !defined(CROSS_MINGW32) && !defined(CROSS_MINGW64) */
5042 #endif /* if defined(WITH_ABSI_DEV) */
5043 
5044 #if defined(WITH_MGP_DEV)
5045     & mgp_dev,
5046 #endif /* if defined(WITH_MGP_DEV) */
5047 
5048 #if defined(WITH_NET_DEV)
5049     & net_dev,
5050 #endif /* if defined(WITH_NET_DEV) */
5051 
5052     NULL
5053   };
5054 
5055 #if defined(PERF_STRIP)
5056 void dps8_init_strip (void)
     /* [previous][next][first][last][top][bottom][index][help] */
5057   {
5058     dps8_init ();
5059   }
5060 #endif /* if defined(PERF_STRIP) */

/* [previous][next][first][last][top][bottom][index][help] */