root/src/dps8/dps8_cpu.h

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

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. SET_PR_BITNO
  2. SET_AR_CHAR_BITNO
  3. trackport
  4. core_read
  5. core_write
  6. core_write_zone
  7. core_read2
  8. core_write2
  9. core_readN
  10. core_writeN
  11. core_readN_fast
  12. core_writeN_fast
  13. setFetchAttention
  14. advanceG7Faults
  15. sdpap_store

   1 /*
   2  * vim: filetype=c:tabstop=4:ai:expandtab
   3  * SPDX-License-Identifier: ICU
   4  * scspell-id: 72d91a53-f62d-11ec-a98f-80ee73e9b8e7
   5  *
   6  * ---------------------------------------------------------------------------
   7  *
   8  * Copyright (c) 2007-2013 Michael Mondy
   9  * Copyright (c) 2012-2016 Harry Reed
  10  * Copyright (c) 2013-2022 Charles Anthony
  11  * Copyright (c) 2015-2021 Eric Swenson
  12  * Copyright (c) 2021-2025 The DPS8M Development Team
  13  *
  14  * This software is made available under the terms of the ICU License.
  15  * See the LICENSE.md file at the top-level directory of this distribution.
  16  *
  17  * ---------------------------------------------------------------------------
  18  */
  19 
  20 #if !defined(__STDC_WANT_IEC_60559_BFP_EXT__)
  21 # define __STDC_WANT_IEC_60559_BFP_EXT__ 1
  22 #endif /* if !defined(__STDC_WANT_IEC_60559_BFP_EXT__) */
  23 
  24 #include <sys/types.h>
  25 
  26 #if defined(__APPLE__)
  27 # undef SCHED_NEVER_YIELD
  28 # define SCHED_NEVER_YIELD 1
  29 # include <mach/thread_policy.h>
  30 # include <mach/task_info.h>
  31 # include <sys/types.h>
  32 # include <sys/sysctl.h>
  33 # include <mach/thread_policy.h>
  34 # include <mach/thread_act.h>
  35 #endif /* if defined(__APPLE__) */
  36 
  37 #include "../simh/sim_timer.h"
  38 #include "hdbg.h"
  39 
  40 extern unsigned int nprocs;
  41 extern unsigned int ncores;
  42 extern bool running_perf_test;
  43 
  44 #define N_CPU_UNITS 1 // Default
  45 
  46 // JMP_ENTRY must be 0, which is the return value of the setjmp initial entry
  47 #define JMP_ENTRY             0
  48 #define JMP_REENTRY           1
  49 #define JMP_STOP              2
  50 #define JMP_SYNC_FAULT_RETURN 3
  51 #define JMP_REFETCH           4
  52 #define JMP_RESTART           5
  53 #define JMP_FORCE_RESTART     6
  54 // Not a longjmp value: threadz_sim_instr changing copies of the loop
  55 #define JMP_CHANGE_COPY       7
  56 
  57 // The CPU supports 3 addressing modes
  58 // [CAC] I tell a lie: 4 modes...
  59 // [CAC] I tell another lie: 5 modes...
  60 
  61 typedef enum
  62   {
  63     ABSOLUTE_mode,
  64     APPEND_mode,
  65   } addr_modes_e;
  66 
  67 // The control unit of the CPU is always in one of several states. We
  68 // don't currently use all of the states used in the physical CPU.
  69 // The FAULT_EXEC cycle did not exist in the physical hardware.
  70 
  71 typedef enum
  72   {
  73     FAULT_cycle,
  74     EXEC_cycle,
  75     FAULT_EXEC_cycle,
  76     INTERRUPT_cycle,
  77     INTERRUPT_EXEC_cycle,
  78     FETCH_cycle,
  79     PSEUDO_FETCH_cycle,
  80     SYNC_FAULT_RTN_cycle,
  81   } cycles_e;
  82 
  83 struct tpr_s
  84   {
  85     word3   TRR; // The current effective ring number
  86     word15  TSR; // The current effective segment number
  87     word6   TBR; // The current bit offset as calculated from ITS and ITP
  88                  // pointer pairs.
  89     word18  CA;  // The current computed address relative to the origin of the
  90                  // segment whose segment number is in TPR.TSR
  91   };
  92 
  93 struct ppr_s
  94   {
  95     word3   PRR; // The number of the ring in which the process is executing.
  96                  // It is set to the effective ring number of the procedure
  97                  // segment when control is transferred to the procedure.
  98     word15  PSR; // The segment number of the procedure being executed.
  99     word1   P;   // A flag controlling execution of privileged instructions.
 100                  // Its value is 1 (permitting execution of privileged
 101                  // instructions) if PPR.PRR is 0 and the privileged bit in
 102                  // the segment descriptor word (SDW.P) for the procedure is
 103                  // 1; otherwise, its value is 0.
 104     word18  IC;  // The word offset from the origin of the procedure segment
 105                  //  to the current instruction. (same as PPR.IC)
 106   };
 107 
 108 /////
 109 // The terms "pointer register" and "address register" both apply to the same
 110 // physical hardware. The distinction arises from the manner in which the
 111 // register is used and in the interpretation of the register contents.
 112 // "Pointer register" refers to the register as used by the appending unit and
 113 // "address register" refers to the register as used by the decimal unit.
 114 //
 115 // The three forms are compatible and may be freely intermixed. For example,
 116 // PRn may be loaded in pointer register form with the Effective Pointer to
 117 // Pointer Register n (eppn) instruction, then modified in pointer register
 118 // form with the Effective Address to Word/Bit Number of Pointer Register n
 119 // (eawpn) instruction, then further modified in address register form
 120 // (assuming character size k) with the Add k-Bit Displacement to Address
 121 // Register (akbd) instruction, and finally invoked in operand descriptor form
 122 // by the use of MF.AR in an EIS multiword instruction .
 123 //
 124 // The reader's attention is directed to the presence of two bit number
 125 // registers, PRn.BITNO and ARn.BITNO. Because the Multics processor was
 126 // implemented as an enhancement to an existing design, certain apparent
 127 // anomalies appear. One of these is the difference in the handling of
 128 // unaligned data items by the appending unit and decimal unit. The decimal
 129 // unit handles all unaligned data items with a 9-bit byte number and bit
 130 // offset within the byte. Conversion from the description given in the EIS
 131 // operand descriptor is done automatically by the hardware. The appending unit
 132 // maintains compatibility with the earlier generation Multics processor by
 133 // handling all unaligned data items with a bit offset from the prior word
 134 // boundary; again with any necessary conversion done automatically by the
 135 // hardware. Thus, a pointer register, PRn, may be loaded from an ITS pointer
 136 // pair having a pure bit offset and modified by one of the EIS address
 137 // register instructions (a4bd, s9bd, etc.) using character displacement
 138 // counts. The automatic conversion performed ensures that the pointer
 139 // register, PRi, and its matching address register, ARi, both describe the
 140 // same physical bit in main memory.
 141 //
 142 // N.B. Subtle differences between the interpretation of PR/AR. Need to take
 143 // this into account.
 144 //
 145 //     * For Pointer Registers:
 146 //       - PRn.WORDNO The offset in words from the base or origin of the
 147 //                    segment to the data item.
 148 //       - PRn.BITNO  The number of the bit within PRn.WORDNO that is the
 149 //                    first bit of the data item. Data items aligned on word
 150 //                    boundaries always have the value 0. Unaligned data items
 151 //                    may have any value in the range [1,35].
 152 //
 153 //     * For Address Registers:
 154 //       - ARn.WORDNO The offset in words relative to the current addressing
 155 //                    base referent (segment origin, BAR.BASE, or absolute 0
 156 //                    depending on addressing mode) to the word containing the
 157 //                    next data item element.
 158 //       - ARn.CHAR   The number of the 9-bit byte within ARn.WORDNO
 159 //                    containing the first bit of the next data item element.
 160 //       - ARn.BITNO  The number of the bit within ARn.CHAR that is the
 161 //                    first bit of the next data item element.
 162 /////
 163 
 164 struct par_s
 165   {
 166     word15  SNR;      // The segment number of the segment containing the data
 167                       // item described by the pointer register.
 168     word3   RNR;      // The final effective ring number value calculated during
 169                       // execution of the instruction that last loaded the PR.
 170 
 171     word6  PR_BITNO;  // The number of the bit within PRn.WORDNO that is the
 172                       // first bit of the data item. Data items aligned on word
 173                       // boundaries always have the value 0. Unaligned data
 174                       //  items may have any value in the range [1,35].
 175     word2   AR_CHAR;
 176     word4   AR_BITNO;
 177 
 178     word18  WORDNO;   // The offset in words from the base or origin of the
 179                       // segment to the data item.
 180   };
 181 
 182 // N.B. remember there are subtle differences between AR/PR.BITNO
 183 
 184 #define AR    PAR
 185 #define PR    PAR
 186 
 187 struct bar_s
 188   {
 189     word9 BASE;     // Contains the 9 high-order bits of an 18-bit address
 190                     // relocation constant. The low-order bits are generated
 191                     // as zeros.
 192     word9 BOUND;    // Contains the 9 high-order bits of the unrelocated
 193                     // address limit. The low- order bits are generated as
 194                     // zeros. An attempt to access main memory beyond this
 195                     // limit causes a store fault, out of bounds. A value of
 196                     // 0 is truly 0, indicating a null memory range.
 197   };
 198 
 199 struct dsbr_s
 200   {
 201     word24  ADDR;   // If DSBR.U = 1, the 24-bit absolute main memory address
 202                     //  of the origin of the current descriptor segment;
 203                     //  otherwise, the 24-bit absolute main memory address of
 204                     //  the page table for the current descriptor segment.
 205     word14  BND;    // The 14 most significant bits of the highest Y-block16
 206                     //  address of the descriptor segment that can be
 207                     //  addressed without causing an access violation, out of
 208                     //  segment bounds, fault.
 209     word1   U;      // A flag specifying whether the descriptor segment is
 210                     // unpaged (U = 1) or paged (U = 0).
 211     word12  STACK;  // The upper 12 bits of the 15-bit stack base segment
 212                     // number. It is used only during the execution of the
 213                     // call6 instruction. (See Section 8 for a discussion
 214                     //  of generation of the stack segment number.)
 215   };
 216 
 217 // The segment descriptor word (SDW) pair contains information that controls
 218 // the access to a segment. The SDW for segment n is located at offset 2n in
 219 // the descriptor segment whose description is currently loaded into the
 220 // descriptor segment base register (DSBR).
 221 
 222 struct sdw_s
 223   {
 224     word24  ADDR;    // The 24-bit absolute main memory address of the page
 225                      //  table for the target segment if SDWAM.U = 0;
 226                      //  otherwise, the 24-bit absolute main memory address
 227                      //  of the origin of the target segment.
 228     word3   R1;      // Upper limit of read/write ring bracket
 229     word3   R2;      // Upper limit of read/execute ring bracket
 230     word3   R3;      // Upper limit of call ring bracket
 231     word14  BOUND;   // The 14 high-order bits of the last Y-block16 address
 232                      //  within the segment that can be referenced without an
 233                      //  access violation, out of segment bound, fault.
 234     word1   R;       // Read permission bit. If this bit is set ON, read
 235                      //  access requests are allowed.
 236     word1   E;       // Execute permission bit. If this bit is set ON, the SDW
 237                      //  may be loaded into the procedure pointer register
 238                      //  (PPR) and instructions fetched from the segment for
 239                      //  execution.
 240     word1   W;       // Write permission bit. If this bit is set ON, write
 241                      //  access requests are allowed.
 242     word1   P;       // Privileged flag bit. If this bit is set ON, privileged
 243                      //  instructions from the segment may be executed if
 244                      //  PPR.PRR is 0.
 245     word1   U;       // Unpaged flag bit. If this bit is set ON, the segment
 246                      //  is unpaged and SDWAM.ADDR is the 24-bit absolute
 247                      //  main memory address of the origin of the segment. If
 248                      //  this bit is set OFF, the segment is paged andis
 249                      //  SDWAM.ADDR the 24-bit absolute main memory address of
 250                      //  the page table for the segment.
 251     word1   G;       // Gate control bit. If this bit is set OFF, calls and
 252                      //  transfers into the segment must be to an offset no
 253                      //  greater than the value of SDWAM.CL as described
 254                      //  below.
 255     word1   C;       // Cache control bit. If this bit is set ON, data and/or
 256                      //  instructions from the segment may be placed in the
 257                      //  cache memory.
 258     word14  EB;      // Call limiter (entry bound) value. If SDWAM.G is set
 259                      //  OFF, transfers of control into the segment must be to
 260                      //  segment addresses no greater than this value.
 261     word15  POINTER; // The effective segment number used to fetch this SDW
 262                      //  from main memory.
 263     word1   DF;      // Directed fault flag (called F in AL39).
 264                      //  * 0 = page not in main memory; execute directed fault
 265                      //        FC
 266                      //  * 1 = page is in main memory
 267     word2   FC;      // Directed fault number for page fault.
 268     word1   FE;      // Full/empty bit. If this bit is set ON, the SDW in the
 269                      //  register is valid. If this bit is set OFF, a hit is
 270                      //  not possible. All SDWAM.F bits are set OFF by the
 271                      //  instructions that clear the SDWAM.
 272     // L68: word4
 273     // DPS8M: word6
 274     word6   USE;
 275                      // Usage count for the register. The SDWAM.USE field is
 276                      //  used to maintain a strict FIFO queue order among the
 277                      //  SDWs. When an SDW is matched, its USE value is set to
 278                      //  15 (newest) on the DPS/L68 and to 63 on the DPS 8M,
 279                      //  and the queue is reordered. SDWs newly fetched from
 280                      //  main memory replace the SDW with USE value 0 (oldest)
 281                      //  and the queue is reordered.
 282     bool    loaded;
 283                      // DPS8M AM register written since initialization;
 284                      //  its parity bit stays valid when F is cleared
 285   };
 286 
 287 typedef struct sdw_s sdw_s;
 288 typedef struct sdw_s sdw0_s;
 289 
 290 
 291 
 292 
 293 
 294 
 295 
 296 
 297 
 298 
 299 
 300 
 301 
 302 
 303 
 304 
 305 
 306 
 307 
 308 
 309 
 310 
 311 
 312 
 313 
 314 
 315 
 316 
 317 
 318 
 319 
 320 
 321 
 322 
 323 
 324 
 325 
 326 
 327 
 328 
 329 
 330 
 331 
 332 
 333 
 334 
 335 
 336 
 337 
 338 
 339 
 340 
 341 
 342 
 343 
 344 // PTW as used by APU
 345 
 346 struct ptw_s
 347  {
 348     word18  ADDR;    // The 18 high-order bits of the 24-bit absolute
 349                      //  main memory address of the page.
 350     word1   U;       // * 1 = page has been used (referenced)
 351     word1   M;       // Page modified flag bit. This bit is set ON whenever
 352                      //  the PTW is used for a store type instruction. When
 353                      //  the bit changes value from 0 to 1, a special
 354                      //  extra cycle is generated to write it back into the
 355                      //  PTW in the page table in main memory.
 356     word1   DF;      // Directed fault flag
 357                      // * 0 = page not in main memory; execute directed fault FC
 358                      // * 1 = page is in main memory
 359     word2   FC;      // Directed fault number for page fault.
 360     word15  POINTER; // The effective segment number used to fetch this PTW
 361                      //  from main memory.
 362     word12  PAGENO;  // The 12 high-order bits of the 18-bit computed
 363                      //  address (TPR.CA) used to fetch this PTW from main
 364                      //  memory.
 365     word1   FE;      // Full/empty bit. If this bit is set ON, the PTW in
 366                      //  the register is valid. If this bit is set OFF, a
 367                      //  hit is not possible. All PTWAM.F bits are set OFF
 368                      //  by the instructions that clear the PTWAM.
 369     // DPS8M: word6
 370     // L68: word4
 371     word6   USE;
 372                      // Usage count for the register. The PTWAM.USE field
 373                      //  is used to maintain a strict FIFO queue order
 374                      //  among the PTWs. When an PTW is matched its USE
 375                      // value is set to 15 (newest) on the DPS/L68 and to
 376                      //  63 on the DPS 8M, and the queue is reordered.
 377                      //  PTWs newly fetched from main memory replace the
 378                      //  PTW with USE value 0 (oldest) and the queue is
 379                      //  reordered.
 380     bool    loaded;
 381                      // DPS8M AM register written since initialization;
 382                      //  its parity bit stays valid when F is cleared
 383   };
 384 
 385 typedef struct ptw_s ptw_s;
 386 typedef struct ptw_s ptw0_s;
 387 
 388 
 389 
 390 
 391 
 392 
 393 
 394 
 395 
 396 
 397 
 398 
 399 
 400 
 401 
 402 
 403 
 404 
 405 
 406 
 407 //
 408 // Memory cache
 409 //
 410 
 411 // L68 has 2K words of cache
 412 // DPS8 has 8K words
 413 
 414 //#define L68_CACHE_SZ  2048
 415 //#define DPS8_CACHE_SZ 8192
 416 
 417 // L68 Cache layout
 418 //
 419 //  "Main memory is divided into N blocks of 4 words each arranged
 420 //  in ascending order and numbered with the value of Y15,21 of the first
 421 //  word of the block."
 422 //
 423 //  "All main memory blocks with numbers n modulo 128 are grouped
 424 //  associatively with cache memory column n."
 425 //
 426 // 2K addresses
 427 //    0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
 428 //  |              directory address             |       column       | word|
 429 //                                             15                    7     2
 430 // 8K addresses
 431 //    0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
 432 //  |           directory address          |          column          | word|
 433 //                                       13                          9     2
 434 // L68 128 columns
 435 // DPS8 512 columns
 436 //
 437 // Each column holds 4 words
 438 // column_index = address >> 2
 439 // column_number = column_index % 128 (or 512)
 440 //
 441 // 4 levels in each column
 442 
 443 #define BLOCK_SZ 4
 444 #define L68_N_COLUMNS 128
 445 #define DPS8_N_COLUMNS 512
 446 #define N_COLUMNS 512 // Larger of L68/DPS8
 447 #define N_LEVELS 4
 448 
 449 // From SDWAM code:
 450         // If the SDWAM match logic circuitry indicates a hit, all usage
 451         // counts (SDWAM.USE) greater than the usage count of the register
 452         // hit are decremented by one, the usage count of the register hit
 453         // is set to 15, and the contents of the register hit are read out
 454         // into the address preparation circuitry.
 455 
 456 // One cache directory entry (one level of one column). Lookups match
 457 // KEY, the real memory address of the block >> 11 (>> 9 on the L68): a
 458 // store by another CPU or an IOM knows only the real address. A block in
 459 // an SCU with internal interlace is not four consecutive words of M; it
 460 // is kept by its absolute address, tagged (see cacheAddr). DIRADDR is
 461 // Y0-12 as this CPU saw the block when it was loaded; the scpr ,06
 462 // directory readout reports it.
 463 typedef struct {
 464   word24 key;
 465   word13 dirAddr;
 466   bool FE;
 467   bool badParity;   // directory parity bad (PM893 06A)
 468   uint8_t badWord;  // words loaded with bad parity, bit w = word w (06D)
 469   word36 block[BLOCK_SZ];
 470 } directory;
 471 
 472 //
 473 // Cache Mode Register
 474 //
 475 
 476 struct cache_mode_register_s
 477   {
 478     word15   cache_dir_address;
 479     word1    par_bit;
 480     word1    lev_ful;
 481     word1    csh1_on; // 1: The lower half of the cache memory is active and
 482                       // enabled as per the state of inst_on
 483     word1    csh2_on; // 1: The upper half of the cache memory is active and
 484                       // enabled as per the state of inst_on
 485     // L68 only
 486     word1    opnd_on; // 1: The cache memory (if active) is used for operands.
 487 
 488     word1    inst_on; // 1: The cache memory (if active) is used for
 489                       //  instructions.
 490     // When the cache-to-register mode flag (bit 59 of the cache mode register)
 491     // is set ON, the processor is forced to fetch the operands of all
 492     // double-precision operations unit load operations from the cache memory.
 493     // Y0,12 are ignored, Y15,21 select a column, and Y13,14 select a level.
 494     // All other operations (e.g., instruction fetches, single-precision
 495     // operands, etc.) are treated normally.
 496     word1    csh_reg;
 497     word1    str_asd;
 498     word1    col_ful;
 499     word2    rro_AB;
 500     word1    bypass_cache; // DPS8M only
 501     word2    luf;          // LUF value
 502                            // 0   1   2   3
 503                            // Lockup time
 504                            // 2ms 4ms 8ms 16ms
 505                            // The lockup timer is set to 16ms when the
 506                            // processor is initialized.
 507   };
 508 
 509 typedef struct cache_mode_register_s cache_mode_register_s;
 510 
 511 typedef struct mode_register_s
 512   {
 513     word36 r;
 514     // L68 only
 515                     //  8M      L68
 516     word15 FFV;     //  0       FFV     0 - 14
 517     word1 OC_TRAP;  //  0       a           16
 518     word1 ADR_TRAP; //  0       b           17
 519     word9 OPCODE;   //  0       OPCODE 18 - 26
 520     word1 OPCODEX;  //  0       OPCODE      27
 521 
 522  // word1 cuolin;   //  a       c           18 control unit overlap inhibit
 523  // word1 solin;    //  b       d           19 store overlap inhibit
 524     word1 sdpap;    //  c       e           20 store incorrect data parity
 525     word1 separ;    //  d       f           21 store incorrect ZAC
 526  // word2 tm;       //  e       g      22 - 23 timing margins
 527  // word2 vm;       //  f       h      24 - 25 voltage margins
 528                     //  0       0           26 history register overflow trap
 529                     //  0       0           27 strobe HR on opcode match
 530     word1 hrhlt;    //  g       i           28 history register overflow trap
 531 
 532     // DPS8M only
 533     word1 hrxfr;    //  h       j           29 strobe HR on transfer made
 534     // L68 only
 535                     //  h       j           29 strobe HR on opcode match
 536     word1 ihr;      //  i       k           30 Enable HR
 537     word1 ihrrs;    //  j                   31 HR reset options
 538                     //          l           31 HR lock control
 539                     //  k                   32 margin control
 540                     //          m           32 test mode indicator
 541     // DPS8M only
 542     word1 hexfp;    //  l       0           33 hex mode
 543                     //  0       0           34
 544      word1 emr;     //  m       n           35 enable MR
 545   } mode_register_s;
 546 
 547 extern DEVICE cpu_dev;
 548 
 549 // address of an EIS operand
 550 typedef struct EISaddr_s
 551   {
 552 #if !defined(EIS_PTR)
 553     word18  address;    // 18-bit virtual address
 554 #endif /* if !defined(EIS_PTR) */
 555 
 556     word36  data;
 557     word1    bit;
 558     eRW     mode;
 559 
 560     int     last_bit_posn;  // track for caching tests
 561 
 562     // for type of data being address by this object
 563 
 564     // eisDataType _type;   // type of data - alphanumeric/numeric
 565 
 566 #if !defined(EIS_PTR3)
 567     int     TA;    // type of Alphanumeric chars in src
 568 #endif /* if !defined(EIS_PTR3) */
 569     int     TN;    // type of Numeric chars in src
 570     int     cPos;
 571     int     bPos;
 572 
 573 #if !defined(EIS_PTR4)
 574     // for when using AR/PR register addressing
 575     word15  SNR;                // The segment number of the segment containing the
 576                                 //  data item described by the pointer register.
 577     word3   RNR;                // The effective ring number value calculated during
 578                                 //  execution of the instruction that last loaded.
 579     MemoryAccessType    mat;    // Memory access type for operation.
 580 #endif /* if !defined(EIS_PTR4) */
 581 
 582     // Cache
 583 
 584     // There is a cache for each operand, but they do not cross check;
 585     // this means that if one of them has a cached dirty word, the
 586     // others will not check for a hit, and will use the old value.
 587     // AL39 warns that overlapping operands can cause unexpected behavior
 588     // due to caching issues, so the this behavior is closer to the actual
 589     // h/w then to the theoretical need for cache consistency.
 590 
 591     // We don't need to cache mat or TPR because they will be constant
 592     // across an instruction.
 593 
 594     bool cacheValid;
 595     bool cacheDirty;
 596 #define paragraphSz 8
 597 #define paragraphMask 077777770
 598 #define paragraphOffsetMask 07
 599     word36 cachedParagraph [paragraphSz];
 600     bool wordDirty [paragraphSz];
 601     word18 cachedAddr;
 602 
 603   } EISaddr;
 604 
 605 typedef struct EISstruct_s
 606   {
 607     word36  op [3];         // raw operand descriptors
 608 #define OP1 op [0]          // 1st descriptor (2nd ins word)
 609 #define OP2 op [1]          // 2nd descriptor (3rd ins word)
 610 #define OP3 op [2]          // 3rd descriptor (4th ins word)
 611 
 612     bool     P;             // 4-bit data sign character control
 613 
 614     uint    MF [3];
 615 #define MF1 MF [0]          // Modification field for operand descriptor 1
 616 #define MF2 MF [1]          // Modification field for operand descriptor 2
 617 #define MF3 MF [2]          // Modification field for operand descriptor 3
 618 
 619     uint    CN [3];
 620 #define CN1 CN [0]
 621 #define CN2 CN [1]
 622 #define CN3 CN [2]
 623 
 624     uint    WN [3];
 625 #define WN1 WN [0]
 626 #define WN2 WN [1]
 627 #define WN3 CN [2]
 628 
 629    uint     C [3];
 630 #define C1  C [0]
 631 #define C2  C [1]
 632 #define C3  C [2]
 633 
 634    uint     B [3];
 635 #define B1  B [0]
 636 #define B2  B [1]
 637 #define B3  B [2]
 638 
 639    uint     N [3];
 640 #define N1  N [0]
 641 #define N2  N [1]
 642 #define N3  N [2]
 643 
 644     uint    TN [3];         // type numeric
 645 #define TN1 TN [0]
 646 #define TN2 TN [1]
 647 #define TN3 TN [2]
 648 
 649 #if defined(EIS_PTR3)
 650 # define TA1 cpu.du.TAk[0]
 651 # define TA2 cpu.du.TAk[1]
 652 # define TA3 cpu.du.TAk[2]
 653 #else
 654 
 655     uint     TA [3];        // type alphanumeric
 656 # define TA1 TA [0]
 657 # define TA2 TA [1]
 658 # define TA3 TA [2]
 659 #endif /* if defined(EIS_PTR3) */
 660 
 661    uint     S [3];          // Sign and decimal type of number
 662 #define S1  S [0]
 663 #define S2  S [1]
 664 #define S3  S [2]
 665 
 666     int     SF [3];         // scale factor
 667 #define SF1 SF [0]
 668 #define SF2 SF [1]
 669 #define SF3 SF [2]
 670 
 671     word18 _flags;          // flags set during operation
 672     word18 _faults;         // faults generated by instruction
 673 
 674     word72s x;              // a signed, 128-bit integers for playing with ...
 675 
 676     // Stuff for Micro-operations and Edit instructions...
 677 
 678     word9   editInsertionTable [8];     // 8 9-bit chars
 679 
 680     int     mopIF;          // current micro-operation IF field
 681     struct MOP_struct_s *m;          // pointer to current MOP struct
 682 
 683     word9   inBuffer [64];  // decimal unit input buffer
 684     word9   *in;            // pointer to current read position in inBuffer
 685     uint    inBufferCnt;    // number of characters in inBuffer
 686     word9   outBuffer [64]; // output buffer
 687     word9   *out;           // pointer to current write position in outBuffer;
 688 
 689     int     exponent;       // For decimal floating-point (evil)
 690     int     sign;           // For signed decimal (1, -1)
 691 
 692 #if defined(EIS_PTR2)
 693 # define KMOP 1
 694 #else
 695     EISaddr *mopAddress;    // mopAddress, pointer to addr [0], [1], or [2]
 696 #endif /* if defined(EIS_PTR2) */
 697 
 698     int     mopTally;       // number of micro-ops
 699     int     mopPos;         // current mop char posn
 700 
 701     // Edit Flags
 702     // The processor provides the following four edit flags for use by the
 703     // micro operations.
 704 
 705     bool    mopES;          // End Suppression flag; initially OFF, set ON by
 706                             //  a micro operation when zero-suppression ends.
 707     bool    mopSN;          // Sign flag; initially set OFF if the sending
 708                             //  string has an alphanumeric descriptor or an
 709                             //  unsigned numeric descriptor. If the sending
 710                             //  string has a signed numeric descriptor, the
 711                             //  sign is initially read from the sending string
 712                             //  from the digit position defined by the sign
 713                             //  and the decimal type field (S); SN is set
 714                             //  OFF if positive, ON if negative. If all
 715                             //  digits are zero, the data is assumed positive
 716                             //  and the SN flag is set OFF, even when the
 717                             //  sign is negative.
 718     bool    mopZ;           // Zero flag; initially set ON. It is set OFF
 719                             //  whenever a sending string character that is not
 720                             //  decimal zero is moved into the receiving string.
 721     bool    mopBZ;          // Blank-when-zero flag; initially set OFF and
 722                             //  set ON by either the ENF or SES micro
 723                             //  operation. If, at the completion of a move
 724                             //  (L1 exhausted), both the Z and BZ flags are
 725                             //  ON, the receiving string is filled with
 726                             //  character 1 of the edit insertion table.
 727 
 728     EISaddr addr [3];
 729 
 730 #define ADDR1       addr [0]
 731     int     srcTally;       // number of chars in src (max 63)
 732     int     srcTA;          // type of Alphanumeric chars in src
 733     int     srcSZ;          // size of chars in src (4-, 6-, or 9-bits)
 734 
 735 #define ADDR2       addr [1]
 736 
 737 #define ADDR3       addr [2]
 738     int     dstTally;       // number of chars in dst (max 63)
 739     int     dstSZ;          // size of chars in dst (4-, 6-, or 9-bits)
 740 
 741     bool    mvne;           // for MSES micro-op. True when mvne, false when mve
 742   } EISstruct;
 743 
 744 // Instruction decode structure. Used to represent instruction information
 745 
 746 typedef struct DCDstruct_s
 747   {
 748     struct opcode_s * info; // opcode_s *
 749     uint32 opcode;          // opcode
 750     bool   opcodeX;         // opcode extension
 751     uint32 opcode10;        // opcode | (opcodeX ? 01000 : 0)
 752     word18 address;         // bits 0-17 of instruction
 753     word1  b29;             // bit-29 - address via pointer register. Usually.
 754     bool   i;               // interrupt inhibit bit.
 755     word6  tag;             // instruction tag
 756 
 757     bool stiTally;          // for sti instruction
 758     bool restart;           // instruction is to be restarted
 759   } DCDstruct;
 760 
 761 // Emulator-only interrupt and fault info
 762 
 763 typedef struct
 764   {
 765     volAtomic int fault [N_FAULT_GROUPS];
 766                             // only one fault in groups 1..6 can be pending
 767     volAtomic bool XIP [N_SCU_UNITS_MAX];
 768   } events_t;
 769 
 770 // Physical Switches
 771 
 772 enum procModeSettings { procModeGCOS = 1, procModeMultics = 0 };
 773 
 774 // Switches on the Processor's maintenance and configuration panels
 775 typedef struct
 776   {
 777     uint FLT_BASE; // normally 7 MSB of 12bit fault base addr
 778     uint cpu_num;  // zero for CPU 'A', one for 'B' etc.
 779     word36 data_switches;
 780     word18 addr_switches;
 781     uint assignment [N_CPU_PORTS];
 782     uint interlace [N_CPU_PORTS];    // 0/2/4
 783     uint enable [N_CPU_PORTS];
 784     uint init_enable [N_CPU_PORTS];
 785     uint store_size [N_CPU_PORTS];   // 0-7 encoding 32K-4M
 786     enum procModeSettings procMode;  // 1 bit  Read by rsw instruction; format unknown
 787 
 788     bool enable_cache;   // Enable 8K cache
 789     bool sdwam_enable;   // Enable Segment Descriptor WAM
 790     bool ptwam_enable;   // Enable Page Table WAM
 791 
 792     // CPU serial number; not strictly a switch; on DPS8/M, burned into the CPU PROM
 793     uint serno;
 794   } switches_t;
 795 
 796 // Optional H/W
 797 typedef struct {
 798   uint proc_speed; // 4 bits Read by rsw instruction; format unknown
 799   bool hex_mode_installed;
 800   bool prom_installed;
 801   bool cache_installed;
 802   bool clock_slave_installed;
 803 } optionsType;
 804 
 805 // Hardware tweaks
 806 typedef struct {
 807     uint report_faults;   // If set, faults are reported and ignored
 808     uint tro_enable;      // If set, Timer runout faults are generated.
 809     uint drl_fatal;       // If set, DRL instructions halt the CPU
 810     bool useMap;          // If set, consult memory configuration switches to translate memory
 811                           //          addresses to SCU memory banks
 812     uint dis_enable;      // If non-zero, DIS instruction works
 813     uint halt_on_unimp;   // If non-zero, halt CPU on unimplemented instruction instead of faulting
 814     bool isolts_mode;     // If true, CPU is configured to run ISOLTS.
 815     bool tandd_mode;      // If true, CPU runs the T&D tape: T&D-only
 816                           // behaviour; switches come from the ini.
 817     uint enable_wam;      // If zero, the simulated cache is ignored and always returns "miss";
 818                           //           turning it on incurs a large performance hit.
 819     bool enable_emcall;   // If set, the instruction set is extended with simulator debugging instructions
 820     bool nodis;           // If true, start CPU in FETCH cycle; else start in DIS instruction
 821     bool l68_mode;        // False: DPS8/M; True: 6180
 822 } tweaksType;
 823 
 824 enum ou_cycle_e
 825   {
 826     ou_GIN = 0400,
 827     ou_GOS = 0200,
 828     ou_GD1 = 0100,
 829     ou_GD2 = 0040,
 830     ou_GOE = 0020,
 831     ou_GOA = 0010,
 832     ou_GOM = 0004,
 833     ou_GON = 0002,
 834     ou_GOF = 0001
 835   };
 836 
 837 typedef struct
 838   {
 839     // Operations Unit/Address Modification
 840     bool   directOperandFlag;
 841     word36 directOperand;
 842     word6  characterOperandSize; // just the left most bit
 843     word3  characterOperandOffset;
 844     word18 character_address;
 845     word36 character_data;
 846     bool crflag;
 847 
 848     // L68 only
 849     word2 eac;
 850     word1 RB1_FULL;
 851     word1 RP_FULL;
 852     word1 RS_FULL;
 853     word9 cycle;
 854     word1 STR_OP;
 855     word9 RS;      // opcode, for the OU history register
 856     // End L68 only
 857 
 858 #if defined(PANEL68)
 859     word4 opsz;
 860     word10 reguse;
 861 #endif /* if defined(PANEL68) */
 862   } ou_unit_data_t;
 863 
 864 // APU history operation parameter
 865 
 866 enum APUH_e
 867   {
 868     APUH_FDSPTW = 1llu << (35 - 17),
 869     APUH_MDSPTW = 1llu << (35 - 18),
 870     APUH_FSDWP  = 1llu << (35 - 19),
 871     APUH_FPTW   = 1llu << (35 - 20),
 872     APUH_FPTW2  = 1llu << (35 - 21),
 873     APUH_MPTW   = 1llu << (35 - 22),
 874     APUH_FANP   = 1llu << (35 - 23),
 875     APUH_FAP    = 1llu << (35 - 24)
 876   };
 877 
 878 enum {
 879 //   AL39 pg 64 APU hist.
 880         apu_FLT = 1ll << (33 -  0), //  0   l FLT Access violation or directed
 881                                     //            fault on this cycle
 882                                     //  1-2 a BSY    Data source for ESN
 883     apu_ESN_PSR = 0,                //                  00 PPR.PSR
 884     apu_ESN_SNR = 1ll << (33 -  1), //                  01 PRn.SNR
 885     apu_ESN_TSR = 1ll << (33 -  2), //                  10 TPR.TSR
 886                                     //                  11 not used
 887                                     //  3     PRAP
 888        apu_HOLD = 1ll << (33 -  4), //  4     HOLD  An access violation or
 889                                     //              directed fault is waiting
 890                                     //  5     FRIW
 891                                     //  6     XSF
 892                                     //  7     STF
 893        apu_TP_P = 1ll << (33 -  8), //  8     TP P    Guessing PPR.p set from
 894                                     //                SDW.P
 895        apu_PP_P = 1ll << (33 -  9), //  9     PP P    PPR.P?
 896                                     // 10     ?
 897                                     // 11     S-ON   Segment on?
 898                                     // 12     ZMAS
 899                                     // 13     SDMF   Seg. Descr. Modify?
 900                                     // 14     SFND
 901                                     // 15     ?
 902                                     // 16     P-ON   Page on?
 903                                     // 17     ZMAP
 904                                     // 18     PTMF
 905                                     // 19     PFND
 906       apu_FDPT  = 1ll << (33 - 20), // 20   b FDPT   Fetch descriptor segment PTW
 907       apu_MDPT  = 1ll << (33 - 21), // 21   c MDPT   Modify descriptor segment PTW
 908       apu_FSDP  = 1ll << (33 - 22), // 22   d FSDP   Fetch SDW paged descr. seg.
 909       apu_FSDN  = 1ll << (33 - 23), // 23     FSDN   Fetch SDW non-paged
 910       apu_FPTW  = 1ll << (33 - 24), // 24   e FPTW   Fetch PTW
 911       apu_MPTW  = 1ll << (33 - 25), // 25   g MPTW   Modify PTW
 912       apu_FPTW2 = 1ll << (33 - 26), // 26   f FPT2   // Fetch prepage
 913       apu_FAP   = 1ll << (33 - 27), // 27   i FAP    Final address fetch from
 914                                     //               paged seg.
 915       apu_FANP  = 1ll << (33 - 28), // 28   h FANP   Final address fetch from
 916                                     //               non-paged segment
 917                                     // 29     FAAB   Final address absolute?
 918       apu_FA    = 1ll << (33 - 30), // 30     FA     Final address?
 919                                     // 31     EAAU
 920       apu_PIAU  = 1ll << (33 - 32)  // 32     PIAU   Instruction fetch?
 921                                     // 33     TGAU
 922   };
 923 
 924 typedef struct
 925   {
 926     processor_cycle_type lastCycle;
 927 #if defined(PANEL68)
 928     word34 state;
 929 #endif /* if defined(PANEL68) */
 930   } apu_unit_data_t;
 931 
 932 typedef struct
 933   {
 934     // NB: Some of the data normally stored here is represented
 935     // elsewhere -- e.g.,the PPR is a variable outside of this
 936     // struct.   Other data is live and only stored here.
 937 
 938     // This is a collection of flags and registers from the
 939     // appending unit and the control unit.  The scu and rcu
 940     // instructions store and load these values to an 8 word
 941     // memory block.
 942     //
 943     // The CU data may only be valid for use with the scu and
 944     // rcu instructions.
 945     //
 946     // Comments indicate format as stored in 8 words by the scu
 947     // instruction.
 948 
 949     // NOTE: PPR (procedure pointer register) is a combination of registers:
 950     //   From the Appending Unit
 951     //     PRR bits [0..2] of word 0
 952     //     PSR bits [3..17] of word 0
 953     //     P   bit 18 of word 0
 954     //   From the Control Unit
 955     //     IC  bits [0..17] of word 4
 956 
 957     /* word 0 */
 958                    // 0-2   PRR is stored in PPR
 959                    // 3-17  PSR is stored in PPR
 960                    // 18    P   is stored in PPR
 961     word1 XSF;     // 19    XSF External segment flag
 962     word1 SDWAMM;  // 20    SDWAMM Match on SDWAM
 963     word1 SD_ON;   // 21    SDWAM enabled
 964     word1 PTWAMM;  // 22    PTWAMM Match on PTWAM
 965     word1 PT_ON;   // 23    PTWAM enabled
 966 
 967 
 968 
 969 
 970 
 971 
 972 
 973 
 974 
 975 
 976 
 977 
 978 
 979     word12 APUCycleBits;
 980 
 981 
 982     /* word 1 */
 983                    //                 AVF Access Violation Fault
 984                    //                 SF  Store Fault
 985                    //                 IPF Illegal Procedure Fault
 986                    //
 987     word1 IRO_ISN; //  0    IRO       AVF Illegal Ring Order
 988                    //       ISN       SF  Illegal segment number
 989     word1 OEB_IOC; //  1    ORB       AVF Out of execute bracket [sic] should
 990                    //                     be OEB?
 991                    //       IOC       IPF Illegal op code
 992     word1 EOFF_IAIM;
 993                    //  2    E-OFF     AVF Execute bit is off
 994                    //       IA+IM     IPF Illegal address of modifier
 995     word1 ORB_ISP; //  3    ORB       AVF Out of read bracket
 996                    //       ISP       IPF Illegal slave procedure
 997     word1 ROFF_IPR;//  4    R-OFF     AVF Read bit is off
 998                    //       IPR       IPF Illegal EIS digit
 999     word1 OWB_NEA; //  5    OWB       AVF Out of write bracket
1000                    //       NEA       SF  Nonexistent address
1001     word1 WOFF_OOB;//  6    W-OFF     AVF Write bit is off
1002                    //       OOB       SF  Out of bounds (BAR mode)
1003     word1 NO_GA;   //  7    NO GA     AVF Not a gate
1004     word1 OCB;     //  8    OCB       AVF Out of call bracket
1005     word1 OCALL;   //  9    OCALL     AVF Outward call
1006     word1 BOC;     // 10    BOC       AVF Bad outward call
1007 // PTWAM error is DPS8M only
1008     word1 PTWAM_ER;// 11    PTWAM_ER  AVF PTWAM error // inward return
1009     word1 CRT;     // 12    CRT       AVF Cross ring transfer
1010     word1 RALR;    // 13    RALR      AVF Ring alarm
1011 // On DPS8M a SDWAM error, on DP8/L68 a WAM error
1012     word1 SDWAM_ER;// 14    SWWAM_ER  AVF SDWAM error
1013     word1 OOSB;    // 15    OOSB      AVF Out of segment bounds
1014     word1 PARU;    // 16    PARU      Parity fault - processor parity upper
1015     word1 PARL;    // 17    PARL      Parity fault - processor parity lower
1016     word1 ONC1;    // 18    ONC1      Operation not complete fault error #1
1017     word1 ONC2;    // 19    ONC2      Operation not complete fault error #2
1018     word4 IA;      // 20-23 IA        System control illegal action lines
1019     word3 IACHN;   // 24-26 IACHN     Illegal action processor port
1020     word3 CNCHN;   // 27-29 CNCHN     Connect fault - connect processor port
1021     word5 FI_ADDR; // 30-34 F/I ADDR  Modulo 2 fault/interrupt vector address
1022     word1 FLT_INT; // 35    F/I       0 = interrupt; 1 = fault
1023 
1024     /* word 2 */
1025                    //  0- 2 TRR
1026                    //  3-17 TSR
1027                    // 18-21 PTW
1028                    //                  18  PTWAM levels A, B enabled
1029                    //                  19  PTWAM levels C, D enabled
1030                    //                  20  PTWAM levels A, B match
1031                    //                  21  PTWAM levels C, D match
1032                    // 22-25 SDW
1033                    //                  22  SDWAM levels A, B enabled
1034                    //                  23  SDWAM levels C, D enabled
1035                    //                  24  SDWAM levels A, B match
1036                    //                  25  SDWAM levels C, D match
1037                    // 26             0
1038                    // 27-29 CPU      CPU Number
1039     word6 delta;   // 30-35 DELTA    addr increment for repeats
1040 
1041     /* word 3 */
1042                    //  0-17          0
1043                    // 18-21 TSNA     Pointer register number for non-EIS
1044                    //                operands or EIS Operand #1
1045                    //                  18-20 PRNO Pointer register number
1046                    //                  21       PRNO is valid
1047                    // 22-25 TSNB     Pointer register number for EIS operand #2
1048                    //                  22-24 PRNO Pointer register number
1049                    //                  25       PRNO is valid
1050                    // 26-29 TSNC     Pointer register number for EIS operand #2
1051                    //                  26-28 PRNO Pointer register number
1052                    //                  29       PRNO is valid
1053     word3 TSN_PRNO [3];
1054     word1 TSN_VALID [3];
1055 
1056                    // 30-35 TEMP BIT Current bit offset (TPR.TBR)
1057 
1058     /* word 4 */
1059                    //  0-17 PPR.IC
1060     word18 IR;     // 18-35 Indicator register
1061                    //    18 ZER0
1062                    //    19 NEG
1063                    //    20 CARY
1064                    //    21 OVFL
1065                    //    22 EOVF
1066                    //    23 EUFL
1067                    //    24 OFLM
1068                    //    25 TRO
1069                    //    26 PAR
1070                    //    27 PARM
1071                    //    28 -BM
1072                    //    29 TRU
1073                    //    30 MIF
1074                    //    31 ABS
1075                    //    32 HEX [sic] Figure 3-32 is wrong.
1076                    // 33-35 0
1077 
1078     /* word 5 */
1079 
1080                    //  0-17 COMPUTED ADDRESS (TPR.CA)
1081     word1 repeat_first;
1082                    // 18    RF  First cycle of all repeat instructions
1083     word1 rpt;     // 19    RPT Execute an Repeat (rpt) instruction
1084     word1 rd;      // 20    RD  Execute an Repeat Double (rpd) instruction
1085     word1 rl;      // 21    RL  Execute a Repeat Link (rpl) instruction
1086     word1 pot;     // 22    POT Prepare operand tally
1087                    // 23    PON Prepare operand no tally
1088     //xde xdo
1089     // 0   0   no execute           -> 0 0
1090     // 1   0   execute XEC          -> 0 0
1091     // 1   1   execute even of XED  -> 0 1
1092     // 0   1   execute odd of XED   -> 0 0
1093     word1 xde;     // 24    XDE Execute instruction from Execute Double even
1094                    //       pair
1095     word1 xdo;     // 25    XDO Execute instruction from Execute Double odd pair
1096     word1 itp;     // 26    ITP Execute ITP indirect cycle
1097     word1 rfi;     // 27    RFI Restart this instruction
1098     word1 its;     // 28    ITS Execute ITS indirect cycle
1099     word1 FIF;     // 29    FIF Fault occurred during instruction fetch
1100     word6 CT_HOLD; // 30-35 CT HOLD contents of the "remember modifier" register
1101 
1102     /* word 6 */
1103     word36 IWB;
1104 
1105     /* word 7 */
1106     word36 IRODD; /* Instr holding register; odd word of last pair fetched */
1107  } ctl_unit_data_t;
1108 
1109 #define USE_IRODD (cpu.cu.rd && ((cpu. PPR.IC & 1) != 0))
1110 #define IWB_IRODD (USE_IRODD ? cpu.cu.IRODD : cpu.cu.IWB)
1111 
1112 // L68 only
1113 enum du_cycle1_e
1114   {
1115     //  0 -FPOL Prepare operand length
1116     du1_nFPOL        = 0400000000000ull,
1117     //  1 -FPOP Prepare operand pointer
1118     du1_nFPOP        = 0200000000000ull,
1119     //  2 -NEED-DESC Need descriptor
1120     du1_nNEED_DESC   = 0100000000000ull,
1121     //  3 -SEL-ADR Select address register
1122     du1_nSEL_DIR     = 0040000000000ull,
1123     //  4 -DLEN=DIRECT Length equals direct
1124     du1_nDLEN_DIRECT = 0020000000000ull,
1125     //  5 -DFRST Descriptor processed for first time
1126     du1_nDFRST       = 0010000000000ull,
1127     //  6 -FEXR Extended register modification
1128     du1_nFEXR        = 0004000000000ull,
1129     //  7 -DLAST-FRST Last cycle of DFRST
1130     du1_nLAST_DFRST  = 0002000000000ull,
1131     //  8 -DDU-LDEA Decimal unit load  (lpl?)
1132     du1_nDDU_LDEA    = 0001000000000ull,
1133     //  9 -DDU-STAE Decimal unit store (spl?)
1134     du1_nDDU_STEA    = 0000400000000ull,
1135     // 10 -DREDO Redo operation without pointer and length update
1136     du1_nDREDO       = 0000200000000ull,
1137     // 11 -DLVL<WD-SZ Load with count less than word size
1138     du1_nDLVL_WD_SZ  = 0000100000000ull,
1139     // 12 -EXH Exhaust
1140     du1_nEXH         = 0000040000000ull,
1141     // 13 DEND-SEQ End of sequence
1142     du1_DEND_SEQ     = 0000020000000ull,
1143     // 14 -DEND End of instruction
1144     du1_nEND         = 0000010000000ull,
1145     // 15 -DU=RD+WRT Decimal unit write-back
1146     du1_nDU_RD_WRT   = 0000004000000ull,
1147     // 16 -PTRA00 PR address bit 0
1148     du1_nPTRA00      = 0000002000000ull,
1149     // 17 -PTRA01 PR address bit 1
1150     du1_nPTRA01      = 0000001000000ull,
1151     // 18 FA/Il Descriptor l active
1152     du1_FA_I1        = 0000000400000ull,
1153     // 19 FA/I2 Descriptor 2 active
1154     du1_FA_I2        = 0000000200000ull,
1155     // 20 FA/I3 Descriptor 3 active
1156     du1_FA_I3        = 0000000100000ull,
1157     // 21 -WRD Word operation
1158     du1_nWRD         = 0000000040000ull,
1159     // 22 -NINE 9-bit character operation
1160     du1_nNINE        = 0000000020000ull,
1161     // 23 -SIX 6-bit character operation
1162     du1_nSIX         = 0000000010000ull,
1163     // 24 -FOUR 4-bit character operation
1164     du1_nFOUR        = 0000000004000ull,
1165     // 25 -BIT Bit operation
1166     du1_nBIT         = 0000000002000ull,
1167     // 26 Unused
1168     //               = 0000000001000ull,
1169     // 27 Unused
1170     //               = 0000000000400ull,
1171     // 28 Unused
1172     //               = 0000000000200ull,
1173     // 29 Unused
1174     //               = 0000000000100ull,
1175     // 30 FSAMPL Sample for mid-instruction interrupt
1176     du1_FSAMPL       = 0000000000040ull,
1177     // 31 -DFRST-CT Specified first count of a sequence
1178     du1_nDFRST_CT    = 0000000000020ull,
1179     // 32 -ADJ-LENGTH Adjust length
1180     du1_nADJ_LENTGH  = 0000000000010ull,
1181     // 33 -INTRPTD Mid-instruction interrupt
1182     du1_nINTRPTD     = 0000000000004ull,
1183     // 34 -INHIB Inhibit STC1 (force "STC0")
1184     du1_nINHIB       = 0000000000002ull,
1185     // 35 Unused
1186     //               = 0000000000001ull,
1187   };
1188 
1189 // L68 only
1190 enum du_cycle2_e
1191   {
1192     // 36 DUD Decimal unit idle
1193     du2_DUD          = 0400000000000ull,
1194     // 37 -GDLDA Descriptor load gate A
1195     du2_nGDLDA       = 0200000000000ull,
1196     // 38 -GDLDB Descriptor load gate B
1197     du2_nGDLDB       = 0100000000000ull,
1198     // 39 -GDLDC Descriptor load gate C
1199     du2_nGDLDC       = 0040000000000ull,
1200     // 40 NLD1 Prepare alignment count for first numeric operand load
1201     du2_NLD1         = 0020000000000ull,
1202     // 41 GLDP1 Numeric operand one load gate
1203     du2_GLDP1        = 0010000000000ull,
1204     // 42 NLD2 Prepare alignment count for second numeric operand load
1205     du2_NLD2         = 0004000000000ull,
1206     // 43 GLDP2 Numeric operand two load gate
1207     du2_GLDP2        = 0002000000000ull,
1208     // 44 ANLD1 Alphanumeric operand one load gate
1209     du2_ANLD1        = 0001000000000ull,
1210     // 45 ANLD2 Alphanumeric operand two load gate
1211     du2_ANLD2        = 0000400000000ull,
1212     // 46 LDWRT1 Load rewrite register one gate (XXX Guess indirect desc. MFkID)
1213     du2_LDWRT1       = 0000200000000ull,
1214     // 47 LDWRT2 Load rewrite register two gate (XXX Guess indirect desc. MFkID)
1215     du2_LDWRT2       = 0000100000000ull,
1216     // 50 -DATA-AVLDU Decimal unit data available
1217     du2_nDATA_AVLDU  = 0000040000000ull,
1218     // 49 WRT1 Rewrite register one loaded
1219     du2_WRT1         = 0000020000000ull,
1220     // 50 GSTR Numeric store gate
1221     du2_GSTR         = 0000010000000ull,
1222     // 51 ANSTR Alphanumeric store gate
1223     du2_ANSTR        = 0000004000000ull,
1224     // 52 FSTR-OP-AV Operand available to be stored
1225     du2_FSTR_OP_AV   = 0000002000000ull,
1226     // 53 -FEND-SEQ End sequence flag
1227     du2_nFEND_SEQ    = 0000001000000ull,
1228     // 54 -FLEN<128 Length less than 128
1229     du2_nFLEN_128    = 0000000400000ull,
1230     // 55 FGCH Character operation gate
1231     du2_FGCH         = 0000000200000ull,
1232     // 56 FANPK Alphanumeric packing cycle gate
1233     du2_FANPK        = 0000000100000ull,
1234     // 57 FEXMOP Execute MOP gate
1235     du2_FEXOP        = 0000000040000ull,
1236     // 58 FBLNK Blanking gate
1237     du2_FBLNK        = 0000000020000ull,
1238     // 59 Unused
1239     //               = 0000000010000ull,
1240     // 60 DGBD Binary to decimal execution gate
1241     du2_DGBD         = 0000000004000ull,
1242     // 61 DGDB Decimal to binary execution gate
1243     du2_DGDB         = 0000000002000ull,
1244     // 62 DGSP Shift procedure gate
1245     du2_DGSP         = 0000000001000ull,
1246     // 63 FFLTG Floating result flag
1247     du2_FFLTG        = 0000000000400ull,
1248     // 64 FRND Rounding flag
1249     du2_FRND         = 0000000000200ull,
1250     // 65 DADD-GATE Add/subtract execute gate
1251     du2_DADD_GATE    = 0000000000100ull,
1252     // 66 DMP+DV-GATE Multiply/divide execution gate
1253     du2_DMP_DV_GATE  = 0000000000040ull,
1254     // 67 DXPN-GATE Exponent network execution gate
1255     du2_DXPN_GATE    = 0000000000020ull,
1256     // 68 Unused
1257     //               = 0000000000010ull,
1258     // 69 Unused
1259     //               = 0000000000004ull,
1260     // 70 Unused
1261     //               = 0000000000002ull,
1262     // 71 Unused
1263     //               = 0000000000001ull,
1264   };
1265 
1266 // L68 only
1267 #define DU_CYCLE_GDLDA {   clrmask (& cpu.du.cycle2, du2_nGDLDA);              \
1268                            setmask (& cpu.du.cycle2, du2_nGDLDB | du2_nGDLDC); }
1269 #define DU_CYCLE_GDLDB {   clrmask (& cpu.du.cycle2, du2_nGDLDB);              \
1270                            setmask (& cpu.du.cycle2, du2_nGDLDA | du2_nGDLDC); }
1271 #define DU_CYCLE_GDLDC {   clrmask (& cpu.du.cycle2, du2_nGDLDC);              \
1272                            setmask (& cpu.du.cycle2, du2_nGDLDA | du2_nGDLDB); }
1273 #define DU_CYCLE_FA_I1     setmask (& cpu.du.cycle1, du1_FA_I1)
1274 #define DU_CYCLE_FA_I2     setmask (& cpu.du.cycle1, du1_FA_I2)
1275 #define DU_CYCLE_FA_I3     setmask (& cpu.du.cycle1, du1_FA_I3)
1276 #define DU_CYCLE_ANLD1     setmask (& cpu.du.cycle2, du2_ANLD1)
1277 #define DU_CYCLE_ANLD2     setmask (& cpu.du.cycle2, du2_ANLD2)
1278 #define DU_CYCLE_NLD1      setmask (& cpu.du.cycle2, du2_NLD1)
1279 #define DU_CYCLE_NLD2      setmask (& cpu.du.cycle2, du2_NLD2)
1280 #define DU_CYCLE_FRND      setmask (& cpu.du.cycle2, du2_FRND)
1281 #define DU_CYCLE_DGBD      setmask (& cpu.du.cycle2, du2_DGBD)
1282 #define DU_CYCLE_DGDB      setmask (& cpu.du.cycle2, du2_DGDB)
1283 #define DU_CYCLE_DDU_LDEA  clrmask (& cpu.du.cycle1, du1_nDDU_LDEA)
1284 #define DU_CYCLE_DDU_STEA  clrmask (& cpu.du.cycle1, du1_nDDU_STEA)
1285 #define DU_CYCLE_END       clrmask (& cpu.du.cycle1, du1_nEND)
1286 #define DU_CYCLE_LDWRT1    setmask (& cpu.du.cycle2, du2_LDWRT1)
1287 #define DU_CYCLE_LDWRT2    setmask (& cpu.du.cycle2, du2_LDWRT2)
1288 #define DU_CYCLE_FEXOP     setmask (& cpu.du.cycle2, du2_FEXOP)
1289 #define DU_CYCLE_ANSTR     setmask (& cpu.du.cycle2, du2_ANSTR)
1290 #define DU_CYCLE_GSTR      setmask (& cpu.du.cycle2, du2_GSTR)
1291 #define DU_CYCLE_FLEN_128  clrmask (& cpu.du.cycle2, du2_nFLEN_128)
1292 #define DU_CYCLE_FDUD  { cpu.du.cycle1 = \
1293                       du1_nFPOL        | \
1294                       du1_nFPOP        | \
1295                       du1_nNEED_DESC   | \
1296                       du1_nSEL_DIR     | \
1297                       du1_nDLEN_DIRECT | \
1298                       du1_nDFRST       | \
1299                       du1_nFEXR        | \
1300                       du1_nLAST_DFRST  | \
1301                       du1_nDDU_LDEA    | \
1302                       du1_nDDU_STEA    | \
1303                       du1_nDREDO       | \
1304                       du1_nDLVL_WD_SZ  | \
1305                       du1_nEXH         | \
1306                       du1_nEND         | \
1307                       du1_nDU_RD_WRT   | \
1308                       du1_nWRD         | \
1309                       du1_nNINE        | \
1310                       du1_nSIX         | \
1311                       du1_nFOUR        | \
1312                       du1_nBIT         | \
1313                       du1_nINTRPTD     | \
1314                       du1_nINHIB;        \
1315                     cpu.du.cycle2 =      \
1316                       du2_DUD          | \
1317                       du2_nGDLDA       | \
1318                       du2_nGDLDB       | \
1319                       du2_nGDLDC       | \
1320                       du2_nDATA_AVLDU  | \
1321                       du2_nFEND_SEQ    | \
1322                       du2_nFLEN_128;     \
1323                   }
1324 #define DU_CYCLE_nDUD clrmask (& cpu.du.cycle2, du2_DUD)
1325 
1326 #if defined(PANEL68)
1327 // Control points
1328 # define CPT(R,C) cpu.cpt[R][C]=1
1329 # define CPTUR(C) cpu.cpt[cpt5L][C]=1
1330 #else
1331 # define CPT(R,C)
1332 # define CPTUR(C)
1333 #endif /* if defined(PANEL68) */
1334 
1335 
1336 
1337 
1338 
1339 
1340 
1341 
1342 
1343 
1344 
1345 
1346 
1347 
1348 
1349 
1350 
1351 
1352 
1353 
1354 
1355 
1356 
1357 
1358 
1359 
1360 
1361 
1362 
1363 
1364 
1365 
1366 
1367 
1368 
1369 
1370 
1371 
1372 
1373 
1374 
1375 
1376 
1377 
1378 
1379 
1380 
1381 
1382 
1383 
1384 
1385 
1386 
1387 
1388 
1389 
1390 
1391 
1392 
1393 
1394 
1395 
1396 
1397 
1398 
1399 
1400 
1401 
1402 
1403 
1404 
1405 
1406 
1407 
1408 
1409 
1410 
1411 
1412 
1413 
1414 
1415 
1416 
1417 
1418 
1419 
1420 
1421 
1422 
1423 
1424 
1425 
1426 typedef struct du_unit_data_t
1427   {
1428     // Word 0
1429 
1430                       //  0- 8  9   Zeros
1431     word1 Z;          //     9  1   Z       All bit-string instruction results
1432                       //                      are zero
1433     word1 NOP;        //    10  1   0       Negative overpunch found in 6-4
1434                       //                      expanded move
1435     word24 CHTALLY;   // 12-35 24   CHTALLY The number of characters examined
1436                       //                      by the scm, scmr, scd,
1437                       //                      scdr, tct, or tctr instructions
1438                       //                      (up to the interrupt or match)
1439 
1440     // Word 1
1441 
1442                       //  0-35 26   Zeros
1443 
1444     // Word 2
1445 
1446     // word24 D1_PTR; //  0-23 24   D1 PTR  Address of the last double-word
1447                       //                      accessed by operand descriptor 1;
1448                       //                      bits 17-23 (bit-address) valid
1449                       //                      only for initial access
1450                       //    24  1   Zero
1451     // word2 TA1;     // 25-26  2   TA1     Alphanumeric type of operand
1452                       //                      descriptor 1
1453                       // 27-29  3   Zeroes
1454                       //    30  1   I       Decimal unit interrupted flag; a
1455                       //                      copy of the mid-instruction
1456                       //                      interrupt fault indicator
1457     // word1 F1;      //    31  1   F1      First time; data in operand
1458                       //                      descriptor 1 is valid
1459     // word1 A1;      //    32  1   A1      Operand descriptor 1 is active
1460                       // 33-35  3   Zeroes
1461 
1462     // Word 3
1463 
1464     word10 LEVEL1;    //  0- 9 10   LEVEL 1 Difference in the count of
1465                       //                      characters loaded into the and
1466                       //                      processor characters not acted
1467                       //                      upon
1468     // word24 D1_RES; // 12-35 24   D1 RES  Count of characters remaining in
1469                       //                      operand descriptor 1
1470 
1471     // Word 4
1472 
1473     // word24 D2_PTR; //  0-23 24   D2 PTR  Address of the last double-word
1474                       //                      accessed by operand descriptor 2;
1475                       //                      bits 17-23 (bit-address) valid
1476                       //                      only for initial access
1477                       //    24  1   Zero
1478     // word2 TA2;     // 25-26  2   TA2     Alphanumeric type of operand
1479                       //                      descriptor 2
1480                       // 27-29  3   Zeroes
1481     word1 R;          //    30  1   R       Last cycle performed must be
1482                       //                    repeated
1483     // word1 F2;      //    31  1   F2      First time; data in operand
1484                       //                      descriptor 2 is valid
1485     // word1 A2;      //    32  1   A2      Operand descriptor 2 is active
1486                       // 33-35  3   Zeroes
1487 
1488     // Word 5
1489 
1490     word10 LEVEL2;    //  0- 9 10   LEVEL 2 Same as LEVEL 1, but used mainly
1491                       //                      for OP 2 information
1492     // word24 D2_RES; // 12-35 24   D2 RES  Count of characters remaining in
1493                       //                      operand descriptor 2
1494 
1495     // Word 6
1496 
1497     // word24 D3_PTR; //  0-23 24   D3 PTR  Address of the last double-word
1498                       //                      accessed by operand descriptor 3;
1499                       //                      bits 17-23 (bit-address) valid
1500                       //                      only for initial access
1501                       //    24  1   Zero
1502     // word2 TA3;     // 25-26  2   TA3     Alphanumeric type of operand
1503                       //                      descriptor 3
1504                       // 27-29  3   Zeroes
1505                       //    30  1   R       Last cycle performed must be
1506                       //                      repeated
1507                       //                    [XXX: what is the difference between
1508                       //                      this and word4.R]
1509     // word1 F3;      //    31  1   F3      First time; data in operand
1510                       //                      descriptor 3 is valid
1511     // word1 A3;      //    32  1   A3      Operand descriptor 3 is active
1512     word3 JMP;        // 33-35  3   JMP     Descriptor count; number of words
1513                       //                      to skip to find the next
1514                       //                      instruction following this
1515                       //                      multiword instruction
1516 
1517     // Word 7
1518 
1519                       //  0-12 12   Zeroes
1520     // word24 D3_RES; // 12-35 24   D3 RES  Count of characters remaining in
1521                       //                      operand descriptor 3
1522 
1523     // Fields from above reorganized for generality
1524     word2 TAk [3];
1525 
1526 // D_PTR is a word24 divided into a 18 bit address, and a 6-bit bitno/char
1527 // field
1528 
1529     word18 Dk_PTR_W [3];
1530 #define D1_PTR_W Dk_PTR_W [0]
1531 #define D2_PTR_W Dk_PTR_W [1]
1532 #define D3_PTR_W Dk_PTR_W [2]
1533 
1534     word6 Dk_PTR_B [3];
1535 #define D1_PTR_B Dk_PTR_B [0]
1536 #define D2_PTR_B Dk_PTR_B [1]
1537 #define D3_PTR_B Dk_PTR_B [2]
1538 
1539     word24 Dk_RES [3];
1540 #define D_RES Dk_RES
1541 #define D1_RES Dk_RES [0]
1542 #define D2_RES Dk_RES [1]
1543 #define D3_RES Dk_RES [2]
1544 
1545     word1 Fk [3];
1546 //#define F Fk
1547 #define F1 Fk [0]
1548 #define F2 Fk [0]
1549 #define F3 Fk [0]
1550 
1551     word1 Ak [3];
1552 
1553     // Working storage for EIS instruction processing.
1554 
1555     // These values must be restored on instruction restart
1556     word7 MF [3]; // Modifier fields for each instruction.
1557 
1558     // Image of LPL/SPL for ISOLTS compliance
1559     word36 image [8];
1560 
1561 #if defined(PANEL68)
1562     word37 cycle1;
1563     word37 cycle2;
1564     word1 POL; // Prepare operand length
1565     word1 POP; // Prepare operand pointer
1566 #endif /* if defined(PANEL68) */
1567   } du_unit_data_t;
1568 
1569 #if defined(PANEL68)
1570 // prepare_state bits
1571 enum
1572   {
1573     ps_PIA = 0200,
1574     ps_POA = 0100,
1575     ps_RIW = 0040,
1576     ps_SIW = 0020,
1577     ps_POT = 0010,
1578     ps_PON = 0004,
1579     ps_RAW = 0002,
1580     ps_SAW = 0001
1581   };
1582 #endif /* if defined(PANEL68) */
1583 
1584 // History registers
1585 
1586 // CU History register flag2 field bit
1587 
1588 enum
1589   {
1590     CUH_XINT = 0100,
1591     CUH_IFT  =  040,
1592     CUH_CRD  =  020,
1593     CUH_MRD  =  010,
1594     CUH_MSTO =   04,
1595     CUH_PIB  =   02
1596 };
1597 
1598 #define N_DPS8M_WAM_ENTRIES 64
1599 #define N_DPS8M_WAM_MASK   077
1600 #define N_L68_WAM_ENTRIES   16
1601 #define N_L68_WAM_MASK     017
1602 #define N_NAX_WAM_ENTRIES   64
1603 #define N_MODEL_WAM_ENTRIES (cpu.tweaks.l68_mode ? N_L68_WAM_ENTRIES : N_DPS8M_WAM_ENTRIES)
1604 
1605 #include "ucache.h"
1606 
1607 typedef struct coreLockState_s {
1608     uint64_t lockCnt;
1609     uint64_t lockImmediate;
1610     uint64_t lockWait;
1611     uint64_t lockWaitMax;
1612 #if !defined(SCHED_NEVER_YIELD)
1613     uint64_t lockYield;
1614 #endif /* if !defined(SCHED_NEVER_YIELD) */
1615     word24 locked_addr;
1616 } coreLockState_t;
1617 
1618 typedef struct cpu_state_s
1619   {
1620 
1621 #if defined(THREADZ) || defined(LOCKLESS)
1622     // Set when sim_instr starts fetching and executing; used to improve
1623     // thread creation lag time issues.
1624     volAtomic bool executing;
1625     volAtomic bool forceRestart;
1626     // CPU is running Multics: it has been booted or added, and not deleted,
1627     //  and not an ISOLTS test cpu.
1628     // ISOLTS test CPUs can be master, but never slave.
1629     volAtomic bool inMultics;
1630     bool syncClockModeMaster; // It set, this CPU is the master
1631     volAtomic long int workAllocation; // If in sync clock mode, this is
1632                                            // the amount of work we have
1633                                            // been allocated
1634     // How many cycles has the master held the clock
1635     int masterCycleCnt;
1636     //volatile atomic_bool rcfDelete;  // Set if the CPU was halted by a RCF DELETE
1637     bool syncClockModeCache; // Thread copy of syncClockMode
1638     int syncClockModePoll; // Poll syncClockMode
1639     volAtomic atomic_bool isSlave;
1640     bool becomeSlave;
1641 #endif
1642 
1643     EISstruct currentEISinstruction;
1644 
1645     uCache_t uCache;
1646 
1647     unsigned long long cycleCnt;
1648     unsigned long long instrCnt;
1649     unsigned long long instrCntT0;
1650     unsigned long long instrCntT1;
1651 
1652     coreLockState_t coreLockState;
1653 
1654     // From the control unit history register:
1655     _fault_subtype subFault; // saved by doFault
1656 
1657     word36   rA;     // accumulator
1658     word36   rQ;     // quotient
1659 
1660     fault_acv_subtype_  acvFaults;   // pending ACV faults
1661 
1662     sdw_s * SDW; // working SDW
1663 
1664     // Zone mask
1665     word36 zone;
1666 
1667     ptw_s * PTW;
1668 
1669     word36 CY;              // C(Y) operand data from memory
1670 
1671     uint64 lufCounter;
1672     // T&D mode: lockup time counted in TR decrements (2 ms = 1024), the
1673     // TR decrements so far (T&D calendar clock base), and the transfer
1674     // a lockup is taken on (PM776 08I).
1675     uint64 lufTicks;
1676     uint64 tanddTRTicks;
1677     word18 lufExecIC;   // IC of the instruction being executed
1678     word18 lufXferIC;   // IC of the last transfer (CONT_TRA)
1679     bool lufAfterXfer;  // the PSEUDO_FETCH follows that transfer
1680     bool lufXferTrack;  // keep lufExecIC etc. (T&D or ISOLTS, DPS8/M)
1681     bool lufRFI;        // T&D: doFault sets RFI in the SCU data
1682     bool tanddFetchFault; // T&D: g7 fault at a fetch; keep the fetch's APU status
1683     word24 l68PairAddr;   // L68: absolute address of the last instruction pair fetched
1684     bool l68PairValid;
1685     bool l68OddFault;     // L68: fault in an odd instruction; SCU word 7 = next pair's odd word
1686     volatile bool execSwitchesReq; // EXECUTE DATA SWITCHES pressed
1687     // Something for the instruction loop to do at its next fetch: the
1688     // EXECUTE DATA SWITCHES request, or a change of copies of the loop
1689     // (see FULL_MODEL_ON); one test per instruction covers both
1690 #if defined(THREADZ) || defined(LOCKLESS)
1691     atomic_bool fetchAttention;
1692 #else
1693     bool fetchAttention;
1694 #endif
1695     // The copy of the instruction loop this CPU is running (see
1696     // FULL_MODEL_ON); set when the loop starts, so that the append cycles
1697     // and scu2words of an instruction match its copy of the loop even if
1698     // fullModelOn changes during the instruction
1699     bool fullCopy;
1700     bool execSwitches;    // the fault cycle executes the data switches
1701     bool g7FetchFault;    // g7 fault taken between instructions: a non-transferring
1702                           // fault pair resumes at the IC
1703     bool tanddFetchIntr;  // T&D: interrupt at a fetch; patch the SCU data
1704     bool tanddIntrIC;     // T&D: interrupt pair runs with the IC one back
1705     word36 tanddIRODD;    // T&D: IRODD before that fetch
1706     word6 lastTag;        // tag of the last instruction completed
1707     bool rptXnSaved;      // first repetition changed Xn; restore it on a fault
1708     uint rptXn;
1709     word18 rptXnOld;
1710     uint rptUndo[2];      // 1+Xn advanced for the next even/odd repeated instruction
1711     bool xsfScu;          // XSF for the SCU data: TSR loaded by this instruction's
1712                           //  address preparation (not cu.XSF, "went appending")
1713     bool scuRFI;          // doFault: RFI in the safe-stored SCU data only (not cu.rfi,
1714                           //  which would make the fault pair a restart)
1715     bool tanddFetched;  // T&D: FETCH_cycle fetched before sampling
1716     bool disEnded;      // T&D: a DIS just ended (interrupt or g7 fault)
1717     word1 disInhibit;   // ... and its inhibit bit
1718     word3 neaPort;      // T&D: CPU port of the last NEA/parity illegal action (IACHN)
1719     bool neaNoPort;     // T&D: no enabled CPU port holds that address
1720     bool scLockedOut;   // T&D: a locked read hit bad parity; next access waits
1721     uint tanddEISstart; // T&D: CHTALLY when this execution of an interruptible EIS began
1722 
1723     _fault_subtype dlySubFltNum;
1724 
1725     const char * dlyCtx;
1726 
1727     word36 faultRegister [2];
1728 
1729     word36 itxPair [2];
1730 
1731 //#if defined(THREADZ) || defined(LOCKLESS)
1732 //    struct timespec rTRTime; // time when rTR was set
1733 //#endif
1734 
1735     mode_register_s MR;
1736     // Changes to the mode register history bits do not take affect until
1737     // the next instruction (ISOLTS 700 2a). Cache the values here so
1738     // that post register updates can see the old values.
1739     mode_register_s MR_cache;
1740 
1741     DCDstruct currentInstruction;
1742 
1743     ou_unit_data_t ou;
1744 
1745     word36 Ypair[2];        //  2-words
1746     word36 Yblock8[8];      //  8-words
1747     word36 Yblock16[16];    // 16-words
1748     word36 Yblock32[32];    // 32-words
1749 
1750     word36 scu_data[8];     // For SCU instruction
1751 
1752     ctl_unit_data_t cu;
1753     du_unit_data_t du;
1754 
1755     switches_t switches;
1756     optionsType options;
1757     tweaksType tweaks;
1758     switches_t isolts_switches_save;
1759 
1760     jmp_buf jmpMain; // This is the entry to the CPU state machine
1761 
1762     unsigned long      faultCnt [N_FAULTS];
1763 
1764     word36 history [N_HIST_SETS] [N_MAX_HIST_SIZE] [2];
1765 
1766     cycles_e cycle;
1767 
1768     _fault faultNumber;      // fault number saved by doFault
1769 
1770     apu_unit_data_t apu;
1771 
1772     word27   rTR;    // timer [map: TR, 9 0's]
1773 #if defined(THREADZ) || defined(LOCKLESS)
1774     uint     rTRsample;
1775 #endif
1776     word24   rY;     // address operand
1777 
1778     word18  lnk;     // rpl link value
1779 
1780     volAtomic uint g7FaultsPreset;
1781     uint g7Faults;
1782 
1783     word24 iefpFinalAddress;
1784 
1785     // ISOLTS fine grain TR estimation
1786     uint rTRlsb;
1787     uint shadowTR;
1788     uint TR0; // The value that the TR was set to.
1789 
1790     // Arguments for delayed overflow fault
1791     _fault dlyFltNum;
1792 
1793     word18 last_write;
1794 
1795 #if defined(LOCKLESS)
1796     word24 char_word_address;
1797 #endif /* if defined(LOCKLESS) */
1798 
1799     word24 rmw_address;
1800 
1801     uint restart_address;
1802 
1803     struct
1804       {
1805         word15 PSR;
1806         word3  PRR;
1807         word18 IC;
1808       } cu_data;            // For STCD instruction
1809     uint rTRticks;
1810 
1811     struct tpr_s TPR;     // Temporary Pointer Register
1812     struct ppr_s PPR;     // Procedure Pointer Register
1813     struct dsbr_s DSBR;   // Descriptor Segment Base Register
1814     ptw0_s PTW0; // a PTW not in PTWAM (PTWx1)
1815 
1816     uint history_cyclic [N_HIST_SETS]; // 0..63
1817 
1818     sdw_s SDW0;  // a SDW not in SDWAM
1819     sdw_s _s;
1820 
1821     word18   rX [8]; // index
1822 
1823     // Number of banks in each SCU
1824     uint sc_num_banks [N_SCU_UNITS_MAX];
1825 
1826     // Caching some cabling data for interrupt handling.
1827     // When a CPU calls get_highest_intr(), it needs to know
1828     // what port on the SCU it is attached to. Because of port
1829     // expanders several CPUs can be attached to an SCU port,
1830     // mapping from the CPU to the SCU is easier to query
1831     uint scu_port[N_SCU_UNITS_MAX];
1832 
1833     // L68 FFV faults
1834 
1835      uint FFV_faults_preset;
1836      uint FFV_faults;
1837      uint FFV_fault_number;
1838 
1839 #if defined(AFFINITY)
1840     uint affinity;
1841 #endif /* if defined(AFFINITY) */
1842 
1843     events_t events;
1844 
1845     word24 pad[16];
1846 
1847     struct par_s PAR [8]; // pointer/address registers
1848 
1849     ptw_s PTWAM [N_NAX_WAM_ENTRIES];
1850 
1851     // Map memory address through memory configuration switches
1852     // Minimum allocation chunk is 64K (SCBANK_SZ)
1853     // addr / SCBANK_SZ => bank_number
1854     // scbank_map[bank_number] is address of the bank in M. -1 is unmapped.
1855     int sc_addr_map [N_SCBANKS];
1856     // T&D: CPU ports whose addresses are mapped word by word by
1857     // sc_fine_map instead of by 64K bank through sc_addr_map: those whose
1858     // SCU interlaces stores A and B (config register INT), or whose store
1859     // units, NEA boundary or window are not multiples of 64K (a 64K
1860     // lower store is A + A1 of 32K each, the A/A1 boundary being half the
1861     // store; a 32K store; NEA in 32K units; an L68 32K port). For each:
1862     // the port window's base address and size, its SCU address (absolute
1863     // address mod 4M), the lower and upper store sizes in words, the NEA
1864     // boundary as an SCU address (4M: NEA disabled), and for each 32K unit
1865     // of the lower (slot 0) and upper (slot 1) store's local address
1866     // space, the address in M of its first word (-1: not present).
1867 #define SC_FINE_UNIT  32768u
1868 #define SC_FINE_UNITS ((4u << 20) / SC_FINE_UNIT)
1869     bool sc_fine;
1870     bool sc_fine_port [N_SCU_PORTS];
1871     bool sc_fine_interlace [N_SCU_PORTS];
1872     uint sc_fine_base [N_SCU_PORTS];
1873     uint sc_fine_window [N_SCU_PORTS];
1874     uint sc_fine_scu_base [N_SCU_PORTS];
1875     uint sc_fine_lower_wds [N_SCU_PORTS];
1876     uint sc_fine_upper_wds [N_SCU_PORTS];
1877     uint sc_fine_nea_wds [N_SCU_PORTS];
1878     int sc_fine_phys [N_SCU_PORTS] [2] [SC_FINE_UNITS];
1879     // The SCU number holding each bank
1880     int sc_scu_map [N_SCBANKS];
1881 
1882     sdw_s SDWAM [N_NAX_WAM_ENTRIES]; // Segment Descriptor Word Associative Memory
1883 
1884     // Address Modification tally
1885     word12 AM_tally;
1886 
1887     struct bar_s BAR;     // Base Address Register
1888 
1889     cache_mode_register_s CMR;
1890 
1891     // The following are all from the control unit history register:
1892 
1893     bool interrupt_flag;     // an interrupt is pending in this cycle
1894     bool g7_flag;            // a g7 fault is pending in this cycle;
1895 
1896     bool wasXfer;      // The previous instruction was a transfer
1897 
1898     bool wasInhibited; // One or both of the previous instruction
1899                        // pair was interrupt inhibited.
1900 
1901     bool isExec;  // The instruction being executed is the target of
1902                   // an XEC or XED instruction
1903     bool isXED;   // The instruction being executed is the target of an
1904                   // XEC instruction
1905 
1906     word8    rE;       // exponent [map: rE, 28 0's]
1907 
1908     word6    rTAG;     // instruction tag
1909     word3    rRALR;    // ring alarm [3b] [map: 33 0's, RALR]
1910     word3    RSDWH_R1; // Track the ring number of the last SDW
1911 
1912     // L68: word4
1913     // DPS8M: word6
1914     word6 SDWAMR;
1915 
1916     // Zone mask
1917     bool useZone;
1918 
1919     // L68: word4
1920     // DPS8M: word6
1921     word6 PTWAMR;
1922 
1923     // G7 faults
1924     bool bTroubleFaultCycle;
1925 
1926     bool lufOccurred;
1927     bool secret_addressing_mode;
1928     // Used by LCPR to prevent the LCPR instruction from being recorded
1929     // in the CU.
1930     bool skip_cu_hist;
1931     bool adr_trap_lock;  // L68 ADR TRAP matched: lock the HR after this instruction
1932 
1933     // If the instruction wants overflow thrown after operand write
1934     bool dlyFlt;
1935 
1936     bool restart;
1937 
1938     // L68 FFV faults
1939     bool is_FFV;
1940 
1941 #if defined(AFFINITY)
1942     bool set_affinity;
1943 #endif /* if defined(AFFINITY) */
1944 
1945   ////////////////////////
1946   // Memory cache
1947   //
1948 
1949   directory directories[N_COLUMNS][N_LEVELS];
1950   // 6 "least recently loaded" bits per column, word bits 25-30 of the
1951   // scpr ,06 readout: pairs (0,1) (0,2) (0,3) (1,2) (1,3) (2,3), bit 5..0;
1952   // a pair's bit is 1 when the lower level was loaded more recently
1953   uint8_t cacheLRU[N_COLUMNS];
1954   // the next cache read is an instruction fetch (cleared by the read)
1955   bool cacheFetch;
1956   // scpr ,06 is storing: the store adds the directory entry Y selects
1957   bool cacheDirReadout;
1958   // a general clear started by lcpr is in progress (from instrCnt
1959   // cacheClearStart): the cache neither loads nor hits meanwhile
1960   bool cacheClearing;
1961   unsigned long long cacheClearStart;
1962   // directory clears by read-and-clear instructions not yet done: the
1963   // real addresses, and instrCnt when each was started
1964 #define CACHE_PENDING_CLEARS 4
1965   uint cachePendN;
1966   word24 cachePendAddr[CACHE_PENDING_CLEARS];
1967   unsigned long long cachePendAt[CACHE_PENDING_CLEARS];
1968   // T&D: a parity error in the second half of a block load, reported (as
1969   // a parity fault with these subtype bits) when the instruction is done
1970   uint cacheParPending;
1971 
1972   // Cache stats
1973   uint64_t cacheProbes, cacheHits;
1974 
1975 #if defined(SPEED)
1976 # define SC_MAP_ADDR(addr,real_addr)                           \
1977    if (cpu.tweaks.useMap)                                      \
1978       {                                                        \
1979         if (TANDD_ANY_ON ())                                   \
1980           real_addr = sc_map_addr_tandd (cpup, addr, __func__);\
1981         else                                                   \
1982           {                                                    \
1983             uint pgnum = addr / SCBANK_SZ;                     \
1984             uint os = addr % SCBANK_SZ;                        \
1985             int base = cpu.sc_addr_map[pgnum];                 \
1986             if (base < 0)                                      \
1987               doFault (FAULT_STR, fst_str_nea,  __func__);     \
1988             real_addr = (uint) base + os;                      \
1989           }                                                    \
1990       }                                                        \
1991     else                                                       \
1992       real_addr = addr;
1993 #else
1994 # define SC_MAP_ADDR(addr,real_addr)                           \
1995    if (cpu.tweaks.useMap)                                      \
1996       {                                                        \
1997         if (TANDD_ANY_ON ())                                   \
1998           real_addr = sc_map_addr_tandd (cpup, addr, __func__);\
1999         else                                                   \
2000           {                                                    \
2001             uint pgnum = addr / SCBANK_SZ;                     \
2002             uint os = addr % SCBANK_SZ;                        \
2003             int base = cpu.sc_addr_map[pgnum];                 \
2004             if (base < 0)                                      \
2005               doFault (FAULT_STR, fst_str_nea,  __func__);     \
2006             real_addr = (uint) base + os;                      \
2007           }                                                    \
2008       }                                                        \
2009     else                                                       \
2010       {                                                        \
2011         nem_check (addr, __func__);                            \
2012         real_addr = addr;                                      \
2013       }
2014 #endif /* if defined(SPEED) */
2015 
2016 #if defined(PANEL68)
2017     // Intermediate data collection for APU SCROLL
2018     word18 lastPTWOffset;
2019 // The L68 APU SCROLL 4U has an entry "ACSD"; I am interpreting it as
2020 //   on: lastPTRAddr was a DSPTW
2021 //  off: lastPTRAddr was a PTW
2022     bool lastPTWIsDS;
2023     word18 APUDataBusOffset;
2024     word24 APUDataBusAddr;
2025     word24 APUMemAddr;
2026     word1 panel4_red_ready_light_state;
2027     word1 panel7_enabled_light_state;
2028 // The state of the panel switches
2029     volAtomic word15 APU_panel_segno_sw;
2030     volAtomic word1  APU_panel_enable_match_ptw_sw;  // lock
2031     volAtomic word1  APU_panel_enable_match_sdw_sw;  // lock
2032     volAtomic word1  APU_panel_scroll_select_ul_sw;
2033     volAtomic word4  APU_panel_scroll_select_n_sw;
2034     volAtomic word4  APU_panel_scroll_wheel_sw;
2035     //volAtomic word18 APU_panel_addr_sw;
2036     volAtomic word18 APU_panel_enter_sw;
2037     volAtomic word18 APU_panel_display_sw;
2038     volAtomic word4  CP_panel_wheel_sw;
2039     volAtomic word4  DATA_panel_ds_sw;
2040     volAtomic word4  DATA_panel_d1_sw;
2041     volAtomic word4  DATA_panel_d2_sw;
2042     volAtomic word4  DATA_panel_d3_sw;
2043     volAtomic word4  DATA_panel_d4_sw;
2044     volAtomic word4  DATA_panel_d5_sw;
2045     volAtomic word4  DATA_panel_d6_sw;
2046     volAtomic word4  DATA_panel_d7_sw;
2047     volAtomic word4  DATA_panel_wheel_sw;
2048     volAtomic word4  DATA_panel_addr_stop_sw;
2049     volAtomic word1  DATA_panel_enable_sw;
2050     volAtomic word1  DATA_panel_validate_sw;
2051     volAtomic word1  DATA_panel_auto_fast_sw;  // lock
2052     volAtomic word1  DATA_panel_auto_slow_sw;  // lock
2053     volAtomic word4  DATA_panel_cycle_sw;      // lock
2054     volAtomic word1  DATA_panel_step_sw;       // lock
2055     volAtomic word1  DATA_panel_s_trig_sw;
2056     volAtomic word1  DATA_panel_execute_sw;    // lock
2057     volAtomic word1  DATA_panel_scope_sw;
2058     volAtomic word1  DATA_panel_init_sw;       // lock
2059     volAtomic word1  DATA_panel_exec_sw;       // lock
2060     volAtomic word4  DATA_panel_hr_sel_sw;
2061     volAtomic word4  DATA_panel_trackers_sw;
2062     volAtomic bool panelInitialize;
2063 
2064     // Intermediate data collection for DATA SCROLL
2065     bool portBusy;
2066     word2 portSelect;
2067     word36 portAddr [N_CPU_PORTS];
2068     word36 portData [N_CPU_PORTS];
2069     // Intermediate data collection for CU
2070     word36 IWRAddr;
2071     word7 dataMode; // 0100  9 bit
2072                     // 0040  6 bit
2073                     // 0020  4 bit
2074                     // 0010  1 bit
2075                     // 0004  36 bit
2076                     // 0002  alphanumeric
2077                     // 0001  numeric
2078     word8 prepare_state;
2079     bool DACVpDF;
2080     bool AR_F_E;
2081     bool INS_FETCH;
2082     // Control Points data acquisition
2083     word1 cpt [28] [36];
2084 #endif /* if defined(PANEL68) */
2085 #if defined(THREADZ) || defined(LOCKLESS)
2086     pthread_t thread_id;
2087 #endif
2088 #define cpt1U   0  // Instruction processing tracking
2089 #define cpt1L   1  // Instruction processing tracking
2090 #define cpt2U   2  // Instruction execution tracking
2091 #define cpt2L   3  // Instruction execution tracking
2092 #define cpt3U   4  // Register usage
2093 #define cpt3L   5  // Register usage
2094 #define cpt4U   6
2095 #define cpt4L   7
2096 #define cpt5U   8
2097 #define cpt5L   9
2098 #define cpt6U  10
2099 #define cpt6L  11
2100 #define cpt7U  12
2101 #define cpt7L  13
2102 #define cpt8U  14
2103 #define cpt8L  15
2104 #define cpt9U  16
2105 #define cpt9L  17
2106 #define cpt10U 18
2107 #define cpt10L 19
2108 #define cpt11U 20
2109 #define cpt11L 21
2110 #define cpt12U 22
2111 #define cpt12L 23
2112 #define cpt13U 24
2113 #define cpt13L 25
2114 #define cpt14U 26
2115 #define cpt14L 27
2116 
2117 #define cptUseE     0
2118 #define cptUseBAR   1
2119 #define cptUseTR    2
2120 #define cptUseRALR  3
2121 #define cptUsePRn   4  // 4 - 11
2122 #define cptUseDSBR 12
2123 #define cptUseFR   13
2124 #define cptUseMR   14
2125 #define cptUseCMR  15
2126 #define cptUseIR   16
2127   } cpu_state_t;
2128 
2129 typedef struct MOP_struct_s
2130   {
2131     char * mopName;     // name of microoperation
2132     int (* f) (cpu_state_t *);   // pointer to mop() [returns character to be stored]
2133   } MOP_struct;
2134 
2135 #if defined(M_SHARED)
2136 extern cpu_state_t * cpus;
2137 #else
2138 extern cpu_state_t cpus [N_CPU_UNITS_MAX];
2139 #endif /* if defined(M_SHARED) */
2140 
2141 #if defined(THREADZ) || defined(LOCKLESS)
2142 extern __thread cpu_state_t * restrict _cpup;
2143 #else
2144 extern cpu_state_t * restrict _cpup;
2145 #endif /* if defined(THREADZ) || defined(LOCKLESS) */
2146 
2147 #define cpu (* cpup)
2148 
2149 #define N_STALL_POINTS 16
2150 struct stall_point_s
2151   {
2152     word15 segno;
2153     word18 offset;
2154     useconds_t time;
2155   };
2156 extern struct stall_point_s stall_points [N_STALL_POINTS];
2157 extern bool stall_point_active;
2158 
2159 uint set_cpu_idx (uint cpuNum);
2160 #if defined(THREADZ) || defined(LOCKLESS)
2161 extern __thread uint current_running_cpu_idx;
2162 extern bool bce_dis_called;
2163 #else
2164 # define current_running_cpu_idx 0
2165 #endif /* if defined(THREADZ) || defined(LOCKLESS) */
2166 
2167 // Support code to access ARn.BITNO, ARn.CHAR, PRn.BITNO
2168 
2169 #define GET_PR_BITNO(n) (cpu.PAR[n].PR_BITNO)
2170 #define GET_AR_BITNO(n) (cpu.PAR[n].AR_BITNO)
2171 #define GET_AR_CHAR(n)  (cpu.PAR[n].AR_CHAR)
2172 static inline void SET_PR_BITNO (cpu_state_t * restrict cpup, uint n, word6 b)
     /* [previous][next][first][last][top][bottom][index][help] */
2173   {
2174      // Keep PR_BITNO = 9 * AR_CHAR + AR_BITNO, as LAREG/LARn set it, for
2175      // bit offsets past 35 too (LAREG with CHAR 3, BITNO 9-15 gives 36-42),
2176      // so that saving and restoring the registers (SPRI/SAREG, LPRI/LAREG)
2177      // gives back the same state. PS955 checks this: EAWP2 with PR7 from
2178      // LAREG (36), LPRPn with C(Y)0,5 = 43-47 (BITNO wraps in 4 bits).
2179      if (b < 36) {
2180        cpu.PAR[n].PR_BITNO = b;
2181        cpu.PAR[n].AR_BITNO = (b % 9) & MASK4;
2182        cpu.PAR[n].AR_CHAR = (b / 9) & MASK2;
2183      } else {
2184        cpu.PAR[n].AR_BITNO = (b - 27) & MASK4;
2185        cpu.PAR[n].AR_CHAR = 3;
2186        cpu.PAR[n].PR_BITNO = 27 + cpu.PAR[n].AR_BITNO;
2187      }
2188   }
2189 #define SET_PR_BITNO(n, b) SET_PR_BITNO(cpup, n, b)
2190 static inline void SET_AR_CHAR_BITNO (cpu_state_t * restrict cpup, uint n, word2 c, word4 b)
     /* [previous][next][first][last][top][bottom][index][help] */
2191   {
2192      cpu.PAR[n].PR_BITNO = c * 9 + b;
2193      cpu.PAR[n].AR_BITNO = b & MASK4;
2194      cpu.PAR[n].AR_CHAR = c & MASK2;
2195   }
2196 #define SET_AR_CHAR_BITNO(n, c, b) SET_AR_CHAR_BITNO(cpup, n, c, b)
2197 
2198 bool sample_interrupts (cpu_state_t * cpup);
2199 void disDiagEnter (cpu_state_t * cpup);
2200 void disDiagInterruptSet (uint i);
2201 void disDiagWake (cpu_state_t * cpup);
2202 t_stat simh_hooks (cpu_state_t * cpup);
2203 int operand_size (cpu_state_t * cpup);
2204 //void read_operand (word18 addr, processor_cycle_type cyctyp);
2205 void readOperandRead (cpu_state_t * cpup, word18 addr);
2206 void readOperandRMW (cpu_state_t * cpup, word18 addr);
2207 t_stat write_operand (cpu_state_t * cpup, word18 addr, processor_cycle_type acctyp);
2208 
2209 #if defined(PANEL68)
2210 static inline void trackport (word24 a, word36 d)
     /* [previous][next][first][last][top][bottom][index][help] */
2211   {
2212     cpu_state_t * cpup = _cpup;
2213     // Simplifying assumption: 4 * 4MW SCUs
2214     word2 port = (a >> 22) & MASK2;
2215     cpu.portSelect = port;
2216     cpu.portAddr [port] = a;
2217     cpu.portData [port] = d;
2218     cpu.portBusy = false;
2219   }
2220 #endif /* if defined(PANEL68) */
2221 
2222 #if defined(SPEED) && defined(INLINE_CORE)
2223 # error INLINE_CORE has known issues.
2224 // Ugh. Circular dependencies XXX
2225 NO_RETURN void doFault (_fault faultNumber, _fault_subtype faultSubtype,
2226               const char * faultMsg);
2227 extern const _fault_subtype fst_str_nea;
2228 
2229 static inline int core_read (word24 addr, word36 *data, \
     /* [previous][next][first][last][top][bottom][index][help] */
2230   UNUSED const char * ctx)
2231   {
2232     PNL (cpu.portBusy = true;)
2233     SC_MAP_ADDR (addr, addr);
2234     * data = M[addr] & DMASK;
2235     DO_WORK_MEM;
2236     PNL (trackport (addr, * data);)
2237     return 0;
2238   }
2239 
2240 static inline int core_write (word24 addr, word36 data, \
     /* [previous][next][first][last][top][bottom][index][help] */
2241   UNUSED const char * ctx)
2242   {
2243     PNL (cpu.portBusy = true;)
2244     SC_MAP_ADDR (addr, addr);
2245     if (cpu.tweaks.isolts_mode)
2246       {
2247         if (cpu.MR.sdpap)
2248           {
2249             sim_warn ("failing to implement sdpap\r\n");
2250             cpu.MR.sdpap = 0;
2251           }
2252         if (cpu.MR.separ)
2253           {
2254             sim_warn ("failing to implement separ\r\n");
2255             cpu.MR.separ = 0;
2256           }
2257      }
2258     M[addr] = data & DMASK;
2259     DO_WORK_MEM;
2260     PNL (trackport (addr, data);)
2261     return 0;
2262   }
2263 
2264 static inline int core_write_zone (word24 addr, word36 data, \
     /* [previous][next][first][last][top][bottom][index][help] */
2265   word36 * final, UNUSED const char * ctx)
2266   {
2267     PNL (cpu.portBusy = true;)
2268     SC_MAP_ADDR (addr, addr);
2269     if (cpu.tweaks.isolts_mode)
2270       {
2271         if (cpu.MR.sdpap)
2272           {
2273             sim_warn ("failing to implement sdpap\r\n");
2274             cpu.MR.sdpap = 0;
2275           }
2276         if (cpu.MR.separ)
2277           {
2278             sim_warn ("failing to implement separ\r\n");
2279             cpu.MR.separ = 0;
2280           }
2281       }
2282     M[addr] = (M[addr] & ~cpu.zone) | (data & cpu.zone);
2283     if (final)
2284       * final = v;
2285     cpu.useZone = false; // Safety
2286     DO_WORK_MEM;
2287     PNL (trackport (addr, data);)
2288     return 0;
2289   }
2290 
2291 static inline int core_read2 (word24 addr, word36 *even, word36 *odd,
     /* [previous][next][first][last][top][bottom][index][help] */
2292                               UNUSED const char * ctx)
2293   {
2294     PNL (cpu.portBusy = true;)
2295     SC_MAP_ADDR (addr, addr);
2296     *even = M[addr++] & DMASK;
2297     *odd = M[addr] & DMASK;
2298     DO_WORK_MEM;
2299     PNL (trackport (addr - 1, * even);)
2300     return 0;
2301   }
2302 
2303 static inline int core_write2 (word24 addr, word36 even, word36 odd,
     /* [previous][next][first][last][top][bottom][index][help] */
2304                                UNUSED const char * ctx)
2305   {
2306     PNL (cpu.portBusy = true;)
2307     SC_MAP_ADDR (addr, addr);
2308     if (cpu.tweaks.isolts_mode)
2309       {
2310         if (cpu.MR.sdpap)
2311           {
2312             sim_warn ("failing to implement sdpap\r\n");
2313             cpu.MR.sdpap = 0;
2314           }
2315         if (cpu.MR.separ)
2316           {
2317             sim_warn ("failing to implement separ\r\n");
2318             cpu.MR.separ = 0;
2319           }
2320       }
2321     M[addr++] = even;
2322     M[addr] = odd;
2323     PNL (trackport (addr - 1, even);)
2324     DO_WORK_MEM;
2325     return 0;
2326   }
2327 #else
2328 int core_read (cpu_state_t * cpup, word24 addr, word36 *data, const char * ctx);
2329 int core_write (cpu_state_t * cpup, word24 addr, word36 data, const char * ctx);
2330 // Without the T&D hooks and the cache model, for the fast copies of the
2331 // append cycles (see FULL_MODEL_ON)
2332 int core_read_fast (cpu_state_t * cpup, word24 addr, word36 *data, const char * ctx);
2333 int core_write_fast (cpu_state_t * cpup, word24 addr, word36 data, const char * ctx);
2334 int core_write_zone (cpu_state_t * cpup, word24 addr, word36 data, word36 * final, const char * ctx);
2335 int core_read2 (cpu_state_t * cpup, word24 addr, word36 *even, word36 *odd, const char * ctx);
2336 int core_write2 (cpu_state_t * cpup, word24 addr, word36 even, word36 odd, const char * ctx);
2337 #endif /* if defined(SPEED) && defined(INLINE_CORE) */
2338 
2339 #if defined(LOCKLESS)
2340 
2341 /*
2342  * Atomic operations to use defined as follows:
2343  *
2344  *  AIX_ATOMICS  -  IBM AIX atomics
2345  *  BSD_ATOMICS  -  FreeBSD atomics
2346  *  GNU_ATOMICS  -  GNU atomics
2347  * SYNC_ATOMICS  -  GNU sync-style atomics
2348  *
2349  * The following are reserved and not yet implemented:
2350  *
2351  *  ISO_ATOMICS  -  ISO/IEC 9899:2011 (C11) atomics
2352  *   NT_ATOMICS  -  Microsoft Windows NT atomics
2353  *
2354  * For further details, see:
2355  *
2356  * AIX_ATOMICS:
2357  *  https://www.ibm.com/docs/en/aix/7.3?topic=services-atomic-operations
2358  *
2359  * BSD_ATOMICS:
2360  *  https://www.freebsd.org/cgi/man.cgi?query=atomic&sektion=9&format=html
2361  *  https://man.dragonflybsd.org/?command=atomic&section=9
2362  *
2363  * GNU_ATOMICS:
2364  *  https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html
2365  *
2366  * SYNC_ATOMICS:
2367  *  https://gcc.gnu.org/onlinedocs/gcc/_005f_005fsync-Builtins.html
2368  *
2369  * ISO_ATOMICS:
2370  *  https://en.cppreference.com/w/c/atomic
2371  *
2372  * NT_ATOMICS:
2373  *  https://docs.microsoft.com/en-us/windows/win32/sync/synchronization-functions
2374  *  https://docs.microsoft.com/en-us/windows/win32/sync/interlocked-variable-access
2375  */
2376 
2377 // AIX_ATOMICS are SYNC_ATOMICS (for now)
2378 # if ( defined (AIX_ATOMICS) && \
2379    (! (defined (SYNC_ATOMICS))))
2380 #  define SYNC_ATOMICS 1
2381 # endif
2382 
2383 // FreeBSD atomics (default on for FreeBSD)
2384 # if (! defined (GNU_ATOMICS)) && (! defined (SYNC_ATOMICS)) && \
2385      (! defined (BSD_ATOMICS)) && (! defined (AIX_ATOMICS))
2386 #  if defined(__FreeBSD__) \
2387    || defined(__DragonFly__)
2388 #   undef BSD_ATOMICS
2389 #   define BSD_ATOMICS 1
2390 #  endif
2391 # endif
2392 
2393 // Otherwise, default to GNU_ATOMICS
2394 # if (! defined (GNU_ATOMICS)) && (! defined (BSD_ATOMICS)) && \
2395      (! defined (SYNC_ATOMICS)) && (! defined (AIX_ATOMICS))
2396 #  undef GNU_ATOMICS
2397 #  define GNU_ATOMICS 1
2398 # endif
2399 
2400 int core_read_lock (cpu_state_t * cpup, word24 addr, word36 *data, const char * ctx);
2401 int core_write_unlock (cpu_state_t * cpup, word24 addr, word36 data, const char * ctx);
2402 int core_unlock_all(cpu_state_t * cpup);
2403 
2404 # define DEADLOCK_DETECT   0x40000000U
2405 # define MEM_LOCKED_BIT    61
2406 # define MEM_LOCKED        (1LLU<<MEM_LOCKED_BIT)
2407 
2408 # if !defined(SCHED_NEVER_YIELD)
2409 #  undef SCHED_YIELD
2410 #  define SCHED_YIELD(lockStatePtr)                                      \
2411   do                                                                     \
2412     {                                                                    \
2413       if ((i & 0xff) == 0)                                               \
2414         {                                                                \
2415           sched_yield();                                                 \
2416           (lockStatePtr)->lockYield++;                                   \
2417         }                                                                \
2418     }                                                                    \
2419   while(0)
2420 # else
2421 #  undef SCHED_YIELD
2422 #  define SCHED_YIELD(lockStatePtr)                                      \
2423   do                                                                     \
2424     {                                                                    \
2425     }                                                                    \
2426   while(0)
2427 # endif /* if !defined(SCHED_NEVER_YIELD) */
2428 
2429 # if defined (BSD_ATOMICS)
2430 #  include <machine/atomic.h>
2431 
2432 #  define LOCK_CORE_WORD(addr,lockStatePtr)                              \
2433   do                                                                     \
2434     {                                                                    \
2435       unsigned int i = DEADLOCK_DETECT;                                  \
2436       while ( atomic_testandset_64((volatile uint64_t *)&M[addr],        \
2437             MEM_LOCKED_BIT) == 1 && i > 0)                               \
2438         {                                                                \
2439           i--;                                                           \
2440           SCHED_YIELD(lockStatePtr);                                     \
2441         }                                                                \
2442       if (i == 0)                                                        \
2443         {                                                                \
2444           sim_warn ("%s: locked %x addr %x deadlock\r\n", __func__,      \
2445               (lockStatePtr)->locked_addr, addr);                        \
2446         }                                                                \
2447       (lockStatePtr)->lockCnt++;                                         \
2448       if (i == DEADLOCK_DETECT)                                          \
2449         (lockStatePtr)->lockImmediate++;                                 \
2450       (lockStatePtr)->lockWait += (DEADLOCK_DETECT-i);                   \
2451       (lockStatePtr)->lockWaitMax = ((DEADLOCK_DETECT-i) >               \
2452           (lockStatePtr)->lockWaitMax) ?                                 \
2453               (DEADLOCK_DETECT-i) : (lockStatePtr)->lockWaitMax;         \
2454     }                                                                    \
2455   while (0)
2456 
2457 #  define LOAD_ACQ_CORE_WORD(res, addr)                                  \
2458   do                                                                     \
2459     {                                                                    \
2460       res = atomic_load_acq_64((volatile uint64_t *)&M[addr]);           \
2461     }                                                                    \
2462   while (0)
2463 
2464 #  define STORE_REL_CORE_WORD(addr, data)                                \
2465   do                                                                     \
2466     {                                                                    \
2467       atomic_store_rel_64((volatile uint64_t *)&M[addr], data & DMASK);  \
2468     }                                                                    \
2469   while (0)
2470 
2471 # endif // BSD_ATOMICS
2472 
2473 # if defined(GNU_ATOMICS)
2474 
2475 #  define LOCK_CORE_WORD(addr,lockStatePtr)                              \
2476   do                                                                     \
2477     {                                                                    \
2478       unsigned int i = DEADLOCK_DETECT;                                  \
2479       while ((__atomic_fetch_or((volatile uint64_t *)&M[addr],           \
2480         MEM_LOCKED, __ATOMIC_ACQ_REL) & MEM_LOCKED)                      \
2481                 && i > 0)                                                \
2482     {                                                                    \
2483       i--;                                                               \
2484       SCHED_YIELD(lockStatePtr);                                         \
2485     }                                                                    \
2486       if (i == 0)                                                        \
2487         {                                                                \
2488           sim_warn ("%s: locked %x addr %x deadlock\r\n",                \
2489             __func__, (lockStatePtr)->locked_addr, addr);                \
2490         }                                                                \
2491       (lockStatePtr)->lockCnt++;                                         \
2492       if (i == DEADLOCK_DETECT)                                          \
2493           (lockStatePtr)->lockImmediate++;                               \
2494       (lockStatePtr)->lockWait += (DEADLOCK_DETECT-i);                   \
2495       (lockStatePtr)->lockWaitMax = ((DEADLOCK_DETECT-i) >               \
2496           (lockStatePtr)->lockWaitMax) ? (DEADLOCK_DETECT-i) :           \
2497               (lockStatePtr)->lockWaitMax;                               \
2498     }                                                                    \
2499   while (0)
2500 
2501 #  define LOAD_ACQ_CORE_WORD(res, addr)                                  \
2502   do                                                                     \
2503     {                                                                    \
2504       res = __atomic_load_n((volatile uint64_t *)&M[addr],               \
2505           __ATOMIC_ACQUIRE);                                             \
2506     }                                                                    \
2507   while (0)
2508 
2509 #  define STORE_REL_CORE_WORD(addr, data)                                \
2510   do                                                                     \
2511     {                                                                    \
2512       __atomic_store_n((volatile uint64_t *)&M[addr], data &             \
2513           DMASK, __ATOMIC_RELEASE);                                      \
2514     }                                                                    \
2515   while (0)
2516 
2517 # endif // GNU_ATOMICS
2518 
2519 # if defined(SYNC_ATOMICS)
2520 #  if defined(MEMORY_ACCESS_NOT_STRONGLY_ORDERED)
2521 #   define MEM_BARRIER()   do { __sync_synchronize(); } while (0)
2522 #  else
2523 #   define MEM_BARRIER()   do {} while (0)
2524 #  endif
2525 
2526 #  define LOCK_CORE_WORD(addr,lockStatePtr)                              \
2527      do                                                                  \
2528        {                                                                 \
2529          unsigned int i = DEADLOCK_DETECT;                               \
2530          while ((__sync_fetch_and_or((volatile uint64_t *)&M[addr],      \
2531              MEM_LOCKED) & MEM_LOCKED) && i > 0)                         \
2532            {                                                             \
2533             i--;                                                         \
2534             SCHED_YIELD(lockStatePtr);                                   \
2535            }                                                             \
2536          if (i == 0)                                                     \
2537            {                                                             \
2538             sim_warn ("%s: locked %x addr %x deadlock\r\n", __func__,    \
2539                 (lockStatePtr)->locked_addr, addr);                      \
2540             }                                                            \
2541          (lockStatePtr)->lockCnt++;                                      \
2542          if (i == DEADLOCK_DETECT)                                       \
2543            (lockStatePtr)->lockImmediate++;                              \
2544          (lockStatePtr)->lockWait += (DEADLOCK_DETECT-i);                \
2545          (lockStatePtr)->lockWaitMax = ((DEADLOCK_DETECT-i) >            \
2546              (lockStatePtr)->lockWaitMax) ?                              \
2547                  (DEADLOCK_DETECT-i) : (lockStatePtr)->lockWaitMax;      \
2548        }                                                                 \
2549      while (0)
2550 
2551 #  define LOAD_ACQ_CORE_WORD(res, addr)                                  \
2552      do                                                                  \
2553        {                                                                 \
2554          res = M[addr];                                                  \
2555          MEM_BARRIER();                                                  \
2556        }                                                                 \
2557      while (0)
2558 
2559 #  define STORE_REL_CORE_WORD(addr, data)                                \
2560   do                                                                     \
2561     {                                                                    \
2562       MEM_BARRIER();                                                     \
2563       M[addr] = data & DMASK;                                            \
2564     }                                                                    \
2565   while (0)
2566 
2567 # endif  // SYNC_ATOMICS
2568 #endif  // LOCKLESS
2569 
2570 static inline void core_readN (cpu_state_t * cpup, word24 addr, word36 * data, uint n,
     /* [previous][next][first][last][top][bottom][index][help] */
2571                                UNUSED const char * ctx)
2572   {
2573     for (uint i = 0; i < n; i ++)
2574       {
2575         core_read (cpup, addr + i, data + i, ctx);
2576         //HDBGMRead (addr + i, * (data + i), __func__);
2577       }
2578   }
2579 
2580 static inline void core_writeN (cpu_state_t * cpup, word24 addr, word36 * data, uint n,
     /* [previous][next][first][last][top][bottom][index][help] */
2581                                 UNUSED const char * ctx)
2582   {
2583     for (uint i = 0; i < n; i ++)
2584       {
2585         core_write (cpup, addr + i, data [i], ctx);
2586         //HDBGMWrite (addr + i, * (data + i), __func__);
2587       }
2588   }
2589 
2590 // core_readN and core_writeN for the fast copies of the append cycles
2591 static inline void core_readN_fast (cpu_state_t * cpup, word24 addr, word36 * data, uint n,
     /* [previous][next][first][last][top][bottom][index][help] */
2592                                     UNUSED const char * ctx)
2593   {
2594     for (uint i = 0; i < n; i ++)
2595       core_read_fast (cpup, addr + i, data + i, ctx);
2596   }
2597 
2598 static inline void core_writeN_fast (cpu_state_t * cpup, word24 addr, word36 * data, uint n,
     /* [previous][next][first][last][top][bottom][index][help] */
2599                                      UNUSED const char * ctx)
2600   {
2601     for (uint i = 0; i < n; i ++)
2602       core_write_fast (cpup, addr + i, data [i], ctx);
2603   }
2604 
2605 int is_priv_mode (cpu_state_t * cpup);
2606 //void set_went_appending (void);
2607 //void clr_went_appending (void);
2608 //bool get_went_appending (void);
2609 bool get_bar_mode (cpu_state_t * cpup);
2610 addr_modes_e get_addr_mode (cpu_state_t * cpup);
2611 void set_addr_mode (cpu_state_t * cpup, addr_modes_e mode);
2612 void decode_instruction (cpu_state_t * cpup, word36 inst, DCDstruct * p);
2613 #if !defined(SPEED)
2614 t_stat set_mem_watch (int32 arg, const char * buf);
2615 #endif /* if !defined(SPEED) */
2616 char *str_SDW0 (char * buf, sdw_s *SDW);
2617 int lookup_cpu_mem_map (cpu_state_t * cpup, word24 addr);
2618 #if !defined(SPEED)
2619 void nem_check (word24 addr, const char * context);
2620 #endif /* if !defined(SPEED) */
2621 bool tandd_io_mode (void);
2622 void cpu_init (void);
2623 void cpu_stop_poll_timer (void);
2624 void setup_scbank_map (cpu_state_t * cpup);
2625 void tandd_set_nea_port (cpu_state_t * cpup, word24 addr);
2626 // T&D parity, store not ready and lock out (SM782-SM784)
2627 int tandd_scu_for_addr (cpu_state_t * cpup, word24 addr);
2628 int sc_port_for_addr (cpu_state_t * cpup, word24 addr);
2629 // Is T&D mode on in any CPU?  Kept by tanddUpdateAnyOn when a CPU's
2630 // configuration changes and when the simulation starts. While it is off
2631 // (Multics), the memory routines skip the T&D store parity, lockout and
2632 // fine address map checks altogether, so that they stay small enough to
2633 // be inlined and cost what they did before T&D support.
2634 #if defined(THREADZ) || defined(LOCKLESS)
2635 extern atomic_bool tanddAnyOn;
2636 # define TANDD_ANY_ON() UNLIKELY (atomic_load_explicit (& tanddAnyOn, memory_order_relaxed))
2637 #else
2638 extern bool tanddAnyOn;
2639 # define TANDD_ANY_ON() UNLIKELY (tanddAnyOn)
2640 #endif
2641 void tanddUpdateAnyOn (void);
2642 // Is T&D or ISOLTS mode, the cache model, or L68 mode on in any CPU?  The
2643 // instruction loop (threadz_sim_instr) and the append cycles are compiled
2644 // twice from one source: a full copy with all of the T&D, ISOLTS, cache
2645 // model and L68 support, and a fast copy for everything else (Multics or
2646 // GCOS on a DPS8/M), which leaves out the per-instruction work that only
2647 // they need. This flag picks the copy; kept by fullModelUpdate, called by
2648 // tanddUpdateAnyOn, cacheUpdateAnyOn and the L68/DPS8M CPU settings. The
2649 // instruction loop changes copies at its next fetch; the append cycles
2650 // and scu2words follow the CPU's copy of the loop (cpu.fullCopy).
2651 //
2652 // Fixes kept only in the full copy. Each was found by a T&D or ISOLTS
2653 // test; each costs a store or test on the hottest paths, and Multics on a
2654 // DPS8/M runs as before T&D support without it. Why Multics doesn't need
2655 // each (from the Multics sources), so that it can be reconsidered later:
2656 //
2657 // (1) XSF in the SCU data (cpu.xsfScu, set by an append cycle that loads
2658 //     TSR; scu2words). The fast copy stores cu.XSF. No hardcore code reads
2659 //     scu.apu.xsf; the only reader, the debug command (db_break), clears
2660 //     it before restarting from a break, and RCU restores the stored value,
2661 //     so a restart sees what it always did.
2662 // (2) The CT-HOLD tag saved during a repeat (cpu.lastTag; scu2words). Only
2663 //     displays and decoders read ct_hold (trace_stack's prtscu_,
2664 //     display_cpu_error, BCE's display_scu, sim_6180). The restart fix
2665 //     that clears CT-HOLD in words2scu is in both copies.
2666 // (3) The APU status (FAP/FANP) of a micro-cache hit. Hardcore reads the
2667 //     SCU APU status only for page and bounds faults (page_fault: ptw,
2668 //     dsptw, ptw2; boundfault: ptw2), which are set on the miss paths,
2669 //     unchanged in both copies; a hit resolves no SDW or PTW and so takes
2670 //     neither fault. fim reads FAP/FANP from the APU history registers,
2671 //     not from the SCU data. Affects only SCU displays.
2672 // (4) The restart IC after a group 7 fault (timer runout, connect,
2673 //     execute) taken at a fetch whose fault pair doesn't transfer
2674 //     (cpu.g7FetchFault). Every Multics fault and interrupt pair is
2675 //     SCU + TRA (fault_vector.incl.pl1; bootload's vectors follow the same
2676 //     template), so the pair always transfers. MME (debug's breakpoints)
2677 //     is not group 7 and restarts through SCU/RCU.
2678 // (5) L68 instruction fetch bookkeeping: the pair address (l68PairAddr,
2679 //     l68PairValid), the CU history entry and PI-AP in SCU word 0. Not
2680 //     only diagnostic: doFault uses the pair to store the next pair's odd
2681 //     word as SCU word 7 after a fault in an odd instruction (L68 CU
2682 //     overlap), and read_tra_op sets the pair in both copies, so without
2683 //     the fetch's update it would be stale. L68 mode therefore selects
2684 //     the full copy; the fast copy never runs on an L68.
2685 // (6) The L68 ADR TRAP (trap on address match) check in do_caf. L68 only,
2686 //     so in the full copy with (5); Multics never sets the mode register's
2687 //     tam bit anyway, only T&D (PM701) does.
2688 #if defined(THREADZ) || defined(LOCKLESS)
2689 extern atomic_bool fullModelOn;
2690 # define FULL_MODEL_LOAD() atomic_load_explicit (& fullModelOn, memory_order_relaxed)
2691 #else
2692 extern bool fullModelOn;
2693 # define FULL_MODEL_LOAD() (fullModelOn)
2694 #endif
2695 #define FULL_MODEL_ON() UNLIKELY (FULL_MODEL_LOAD ())
2696 void fullModelUpdate (void);
2697 // Ask CPU to look at fetchAttention's causes at its next fetch: after
2698 // whatever it is to see has been stored (release)
2699 static inline void setFetchAttention (cpu_state_t * cpup)
     /* [previous][next][first][last][top][bottom][index][help] */
2700   {
2701 #if defined(THREADZ) || defined(LOCKLESS)
2702     atomic_store_explicit (& cpup->fetchAttention, true, memory_order_release);
2703 #else
2704     cpup->fetchAttention = true;
2705 #endif
2706   }
2707 // The T&D parts of the memory routines, out of line (see core_read)
2708 COLD word24 sc_map_addr_tandd (cpu_state_t * cpup, word24 addr, const char * func);
2709 COLD void tandd_read_hook (cpu_state_t * cpup, word24 addr, uint nWords);
2710 COLD void tandd_read_lock_hook (cpu_state_t * cpup, word24 addr);
2711 COLD void tandd_write_hook (cpu_state_t * cpup, word24 addr, uint nWords, bool wait);
2712 #define TANDD_HOOK(call) do { if (TANDD_ANY_ON ()) call; } while (0)
2713 // Move preset group 7 and floating faults to the pending ones; inline so
2714 // that the test (most often false) costs no call
2715 void advanceG7FaultsPreset (cpu_state_t * cpup);
2716 static inline void advanceG7Faults (cpu_state_t * cpup)
     /* [previous][next][first][last][top][bottom][index][help] */
2717   {
2718     // This is potentially stale cached, but we don't care, we will see
2719     // eventually ZZZ
2720     if (UNLIKELY (cpu.g7FaultsPreset || cpu.FFV_faults_preset))
2721       advanceG7FaultsPreset (cpup);
2722   }
2723 // T&D/ISOLTS on a DPS8/M: track the transfer a lockup fault is taken on
2724 // (do_LUF_fault); kept by tanddUpdateAnyOn
2725 COLD bool sdpap_store_tandd (cpu_state_t * cpup, word24 addr, word36 * data, uint nWords);
2726 // A store sent with incorrect parity (T&D only); true if it was handled
2727 static inline bool sdpap_store (cpu_state_t * cpup, word24 addr, word36 * data, uint nWords)
     /* [previous][next][first][last][top][bottom][index][help] */
2728   {
2729     return TANDD_ANY_ON () && sdpap_store_tandd (cpup, addr, data, nWords);
2730   }
2731 bool sc_command_parity (cpu_state_t * cpup, uint scuUnitIdx, uint cpuPortNum);
2732 extern uint nBadParity;
2733 void bad_parity_read (cpu_state_t * cpup, word24 addr);
2734 void bad_parity_clear (word24 addr);
2735 void bad_parity_mark (word24 addr);
2736 bool bad_parity_marked (word24 addr);
2737 void sc_lockout_wait (cpu_state_t * cpup);
2738 #if !defined(SPEED)
2739 void cpu_watch_read (cpu_state_t * cpup, word24 real, word36 data, const char * ctx);
2740 #endif
2741 uint scuStoreParityIA (cpu_state_t * cpup, word24 addr, bool zac, bool * doStore, bool * keepBadParity);
2742 uint scuReadParityIA (cpu_state_t * cpup, word24 addr);
2743 uint scuCommandParityIA (uint scuUnitIdx, bool zac);
2744 extern uint scuGoInhibitMask;
2745 bool scuStoreNotReady (cpu_state_t * cpup, word24 addr);
2746 #define BAD_PARITY_READ(a)  do { if (TANDD_ANY_ON () && nBadParity) bad_parity_read (cpup, (a)); } while (0)
2747 #define BAD_PARITY_WRITE(a) do { if (TANDD_ANY_ON () && nBadParity) bad_parity_clear ((a)); } while (0)
2748 #define SC_LOCKOUT_WAIT()   do { if (TANDD_ANY_ON () && cpu.scLockedOut) sc_lockout_wait (cpup); } while (0)
2749 bool sc_fine_map (cpu_state_t * cpup, word24 addr, uint * realp);
2750 bool sc_fine_interlaced (cpu_state_t * cpup, word24 addr);
2751 bool sc_fine_unmap (cpu_state_t * cpup, uint real, word24 * addrp);
2752 void add_dps8m_CU_history (cpu_state_t * cpup);
2753 void add_dps8m_DUOU_history (word36 flags, word18 ICT, word9 RS_REG, word9 flags2);
2754 void add_dps8m_APU_history (word15 ESN, word21 flags, word24 RMA, word3 RTRR, word9 flags2);
2755 void add_dps8m_EAPU_history (word18 ZCA, word18 opcode);
2756 void add_l68_CU_history (cpu_state_t * cpup);
2757 void add_l68_CU_fetch_history (cpu_state_t * cpup);
2758 void press_execute_switches (uint cpuNo);
2759 void add_l68_OU_history (cpu_state_t * cpup);
2760 void add_l68_DU_history (cpu_state_t * cpup);
2761 void add_l68_APU_history (cpu_state_t * cpup, enum APUH_e op);
2762 void add_history_force (cpu_state_t * cpup, uint hset, word36 w0, word36 w1);
2763 word18 get_BAR_address(cpu_state_t * cpup, word18 addr);
2764 #if defined(THREADZ) || defined(LOCKLESS)
2765 t_stat threadz_sim_instr (void);
2766 void * cpu_thread_main (void * arg);
2767 void perfTest (char * testName);
2768 #endif
2769 void cpu_reset_unit_idx (UNUSED uint cpun, bool clear_mem);
2770 void setupPROM (uint cpuNo, unsigned char * PROM);
2771 void cpuStats (uint cpuNo);
2772 #if defined(THREADZ) || defined(LOCKLESS)
2773 void becomeClockMaster (uint cpuNum);
2774 void giveupClockMaster (cpu_state_t * cpup);
2775 #endif
2776 char * cycle_str (cycles_e cycle);

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