1 /* pdp10_defs.h: PDP-10 simulator definitions 2 3 Copyright (c) 1993-2010, Robert M Supnik 4 5 Permission is hereby granted, free of charge, to any person obtaining a 6 copy of this software and associated documentation files (the "Software"), 7 to deal in the Software without restriction, including without limitation 8 the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 and/or sell copies of the Software, and to permit persons to whom the 10 Software is furnished to do so, subject to the following conditions: 11 12 The above copyright notice and this permission notice shall be included in 13 all copies or substantial portions of the Software. 14 15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 ROBERT M SUPNIK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 22 Except as contained in this notice, the name of Robert M Supnik shall not be 23 used in advertising or otherwise to promote the sale, use or other dealings 24 in this Software without prior written authorization from Robert M Supnik. 25 26 22-May-10 RMS Added check for 64b addresses 27 01-Feb-07 RMS Added CD support 28 29-Oct-06 RMS Added clock coscheduling function 29 29-Dec-03 RMS Added Q18 definition for PDP11 compatibility 30 19-May-03 RMS Revised for new conditional compilation scheme 31 09-Jan-03 RMS Added DEUNA/DELUA support 32 29-Sep-02 RMS Added variable vector, RX211 support 33 22-Apr-02 RMS Removed magtape record length error 34 20-Jan-02 RMS Added multiboard DZ11 support 35 23-Oct-01 RMS New IO page address constants 36 19-Oct-01 RMS Added DZ11 definitions 37 07-Sep-01 RMS Revised for PDP-11 multi-level interrupts 38 31-Aug-01 RMS Changed int64 to t_int64 for Windoze 39 29-Aug-01 RMS Corrected models and dates (found by Lars Brinkhoff) 40 01-Jun-01 RMS Updated DZ11 vector definitions 41 19-May-01 RMS Added workaround for TOPS-20 V4.1 boot bug 42 */ 43 44 #ifndef _PDP10_DEFS_H_ 45 #define _PDP10_DEFS_H_ 0 46 47 #ifndef VM_PDP10 48 #define VM_PDP10 0 49 #endif 50 51 #include "sim_defs.h" /* simulator defns */ 52 53 #if defined(USE_ADDR64) 54 #error "PDP-10 does not support 64b addresses!" 55 #endif 56 57 /* Digital Equipment Corporation's 36b family had six implementations: 58 59 name mips comments 60 61 PDP-6 0.25 Original 36b implementation, 1964 62 KA10 0.38 First PDP-10, flip chips, 1967 63 KI10 0.72 First paging system, flip chip + MSI, 1972 64 KL10 1.8 First ECL system, ECL 10K, 1975 65 KL10B 1.8 Expanded addressing, ECL 10K, 1978 66 KS10 0.3 Last 36b system, 2901 based, 1979 67 68 In addition, it ran four major (incompatible) operating systems: 69 70 name company comments 71 72 TOPS-10 DEC Original timesharing system 73 ITS MIT "Incompatible Timesharing System" 74 TENEX BBN ARPA-sponsored, became 75 TOPS-20 DEC Commercial version of TENEX 76 77 All of the implementations differ from one another, in instruction set, 78 I/O structure, and memory management. Further, each of the operating 79 systems customized the microcode of the paging systems (KI10, KL10, KS10) 80 for additional instructions and specialized memory management. As a 81 result, there is no "reference implementation" for the 36b family that 82 will run all programs and all operating systems. The conditionalization 83 and generality needed to support the full matrix of models and operating 84 systems, and to support 36b hardware on 32b data types, is beyond the 85 scope of this project. 86 87 Instead, this simulator emulates one model -- the KS10. It has the best 88 documentation and allows reuse of some of the Unibus peripheral emulators 89 written for the PDP-11 simulator. Further, the simulator requires that 90 the underlying compiler support 64b integer data types, allowing 36b data 91 to be maintained in a single data item. Lastly, the simulator implements 92 the maximum memory size, so that NXM's never happen. 93 */ 94 95 /* Data types */ 96 97 typedef int32 a10; /* PDP-10 addr (30b) */ 98 typedef t_int64 d10; /* PDP-10 data (36b) */ 99 100 /* Abort codes, used to sort out longjmp's back to the main loop 101 Codes > 0 are simulator stop codes 102 Codes < 0 are internal aborts 103 Code = 0 stops execution for an interrupt check 104 */ 105 106 #define STOP_HALT 1 /* halted */ 107 #define STOP_IBKPT 2 /* breakpoint */ 108 #define STOP_ILLEG 3 /* illegal instr */ 109 #define STOP_ILLINT 4 /* illegal intr inst */ 110 #define STOP_PAGINT 5 /* page fail in intr */ 111 #define STOP_ZERINT 6 /* zero vec in intr */ 112 #define STOP_NXMPHY 7 /* nxm on phys ref */ 113 #define STOP_IND 8 /* indirection loop */ 114 #define STOP_XCT 9 /* XCT loop */ 115 #define STOP_ILLIOC 10 /* invalid UBA num */ 116 #define STOP_ASTOP 11 /* address stop */ 117 #define STOP_UNKNOWN 12 /* unknown stop */ 118 #define PAGE_FAIL -1 /* page fail */ 119 #define INTERRUPT -2 /* interrupt */ 120 #define ABORT(x) longjmp (save_env, (x)) /* abort */ 121 #define IORETURN(f,v) ((f)? (v): SCPE_OK) /* cond error return */ 122 123 /* Return codes from eXTEND */ 124 125 #define XT_MUUO 0 /* invalid operation */ 126 #define XT_SKIP 1 /* skip return */ 127 #define XT_NOSK 2 /* no skip return */ 128 129 /* Operating system flags, kept in cpu_unit.flags */ 130 131 #define UNIT_V_ITS (UNIT_V_UF) /* ITS */ 132 #define UNIT_V_T20 (UNIT_V_UF + 1) /* TOPS-20 */ 133 #define UNIT_V_KLAD (UNIT_V_UF + 2) /* diagnostics */ 134 #define UNIT_ITS (1 << UNIT_V_ITS) 135 #define UNIT_T20 (1 << UNIT_V_T20) 136 #define UNIT_KLAD (1 << UNIT_V_KLAD) 137 #define Q_T10 ((cpu_unit.flags & (UNIT_ITS|UNIT_T20|UNIT_KLAD)) == 0) 138 #define Q_ITS (cpu_unit.flags & UNIT_ITS) 139 #define Q_T20 (cpu_unit.flags & UNIT_T20) 140 #define Q_KLAD (cpu_unit.flags & UNIT_KLAD) 141 #define Q_IDLE (sim_idle_enab) 142 143 /* Architectural constants */ 144 145 #define PASIZE 20 /* phys addr width */ 146 #define MAXMEMSIZE (1 << PASIZE) /* maximum memory */ 147 #define PAMASK ((1 << PASIZE) - 1) 148 #define MEMSIZE MAXMEMSIZE /* fixed, KISS */ 149 #define MEM_ADDR_NXM(x) ((x) >= MEMSIZE) 150 #define VASIZE 18 /* virtual addr width */ 151 #define AMASK ((1 << VASIZE) - 1) /* virtual addr mask */ 152 #define LMASK 0777777000000 /* left mask */ 153 #define LSIGN 0400000000000 /* left sign */ 154 #define RMASK 0000000777777 /* right mask */ 155 #define RSIGN 0000000400000 /* right sign */ 156 #define DMASK 0777777777777 /* data mask */ 157 #define SIGN 0400000000000 /* sign */ 158 #define MMASK 0377777777777 /* magnitude mask */ 159 #define ONES 0777777777777 160 #define MAXPOS 0377777777777 161 #define MAXNEG 0400000000000 162 163 /* Instruction format */ 164 165 #define INST_V_OP 27 /* opcode */ 166 #define INST_M_OP 0777 167 #define INST_V_DEV 26 168 #define INST_M_DEV 0177 /* device */ 169 #define INST_V_AC 23 /* AC */ 170 #define INST_M_AC 017 171 #define INST_V_IND 22 /* indirect */ 172 #define INST_IND (1 << INST_V_IND) 173 #define INST_V_XR 18 /* index */ 174 #define INST_M_XR 017 175 #define OP_JRST 0254 /* JRST */ 176 #define AC_XPCW 07 /* XPCW */ 177 #define OP_JSR 0264 /* JSR */ 178 #define GET_OP(x) ((int32) (((x) >> INST_V_OP) & INST_M_OP)) 179 #define GET_DEV(x) ((int32) (((x) >> INST_V_DEV) & INST_M_DEV)) 180 #define GET_AC(x) ((int32) (((x) >> INST_V_AC) & INST_M_AC)) 181 #define TST_IND(x) ((x) & INST_IND) 182 #define GET_XR(x) ((int32) (((x) >> INST_V_XR) & INST_M_XR)) 183 #define GET_ADDR(x) ((a10) ((x) & AMASK)) 184 185 /* Byte pointer format */ 186 187 #define BP_V_P 30 /* position */ 188 #define BP_M_P 077 189 #define BP_P 0770000000000 190 #define BP_V_S 24 /* size */ 191 #define BP_M_S 077 192 #define BP_S 0007700000000 193 #define GET_P(x) ((int32) (((x) >> BP_V_P) & BP_M_P)) 194 #define GET_S(x) ((int32) (((x) >> BP_V_S) & BP_M_S)) 195 #define PUT_P(b,x) (((b) & ~BP_P) | ((((t_int64) (x)) & BP_M_P) << BP_V_P)) 196 197 /* Flags (stored in their own halfword) */ 198 199 #define F_V_AOV 17 /* arithmetic ovflo */ 200 #define F_V_C0 16 /* carry 0 */ 201 #define F_V_C1 15 /* carry 1 */ 202 #define F_V_FOV 14 /* floating ovflo */ 203 #define F_V_FPD 13 /* first part done */ 204 #define F_V_USR 12 /* user mode */ 205 #define F_V_UIO 11 /* user I/O mode */ 206 #define F_V_PUB 10 /* public mode */ 207 #define F_V_AFI 9 /* addr fail inhibit */ 208 #define F_V_T2 8 /* trap 2 */ 209 #define F_V_T1 7 /* trap 1 */ 210 #define F_V_FXU 6 /* floating exp unflo */ 211 #define F_V_DCK 5 /* divide check */ 212 #define F_AOV (1 << F_V_AOV) 213 #define F_C0 (1 << F_V_C0) 214 #define F_C1 (1 << F_V_C1) 215 #define F_FOV (1 << F_V_FOV) 216 #define F_FPD (1 << F_V_FPD) 217 #define F_USR (1 << F_V_USR) 218 #define F_UIO (1 << F_V_UIO) 219 #define F_PUB (1 << F_V_PUB) 220 #define F_AFI (1 << F_V_AFI) 221 #define F_T2 (1 << F_V_T2) 222 #define F_T1 (1 << F_V_T1) 223 #define F_TR (F_T1 | F_T2) 224 #define F_FXU (1 << F_V_FXU) 225 #define F_DCK (1 << F_V_DCK) 226 #define F_1PR (F_AFI) /* ITS: 1-proceed */ 227 #define F_MASK 0777740 /* all flags */ 228 #define SETF(x) flags = flags | (x) 229 #define CLRF(x) flags = flags & ~(x) 230 #define TSTF(x) (flags & (x)) 231 #define GET_TRAPS(x) (((x) & (F_T2 | F_T1)) >> F_V_T1) 232 233 /* Priority interrupt system */ 234 235 #define PI_CPRQ 020000 /* drop prog req */ 236 #define PI_INIT 010000 /* clear pi system */ 237 #define PI_SPRQ 004000 /* set prog req */ 238 #define PI_SENB 002000 /* set enables */ 239 #define PI_CENB 001000 /* clear enables */ 240 #define PI_CON 000400 /* turn off pi system */ 241 #define PI_SON 000200 /* turn on pi system */ 242 #define PI_M_LVL 000177 /* level mask */ 243 #define PI_V_PRQ 18 /* in CONI */ 244 #define PI_V_ACT 8 245 #define PI_V_ON 7 246 #define PI_V_ENB 0 247 248 /* Arithmetic processor flags */ 249 250 #define APR_SENB 0100000 /* set enable */ 251 #define APR_CENB 0040000 /* clear enable */ 252 #define APR_CFLG 0020000 /* clear flag */ 253 #define APR_SFLG 0010000 /* set flag */ 254 #define APR_IRQ 0000010 /* int request */ 255 #define APR_M_LVL 0000007 /* pi level */ 256 #define APR_V_FLG 4 /* system flags */ 257 #define APR_M_FLG 0377 258 #define APRF_ITC (002000 >> APR_V_FLG) /* int console flag */ 259 #define APRF_NXM (000400 >> APR_V_FLG) /* nxm flag */ 260 #define APRF_TIM (000040 >> APR_V_FLG) /* timer request */ 261 #define APRF_CON (000020 >> APR_V_FLG) /* console int */ 262 #define APR_GETF(x) (((x) >> APR_V_FLG) & APR_M_FLG) 263 264 /* Virtual address, DEC paging */ 265 266 #define PAG_V_OFF 0 /* offset - must be 0 */ 267 #define PAG_N_OFF 9 /* page offset width */ 268 #define PAG_SIZE 01000 /* page offset size */ 269 #define PAG_M_OFF 0777 /* mask for offset */ 270 #define PAG_V_PN PAG_N_OFF /* page number */ 271 #define PAG_N_PPN (PASIZE - PAG_N_OFF) /* phys pageno width */ 272 #define PAG_M_PPN 03777 /* phys pageno mask */ 273 #define PAG_PPN 03777000 274 #define PAG_N_VPN (VASIZE - PAG_N_OFF) /* virt pageno width */ 275 #define PAG_M_VPN 0777 /* virt pageno mask */ 276 #define PAG_VPN 0777000 277 #define PAG_GETOFF(x) ((x) & PAG_M_OFF) 278 #define PAG_GETVPN(x) (((x) >> PAG_V_PN) & PAG_M_VPN) 279 #define PAG_XPTEPA(p,x) (((p) + PAG_GETOFF (x)) & PAMASK) 280 #define PAG_PTEPA(p,x) (((((int32) (p)) & PTE_PPMASK) << PAG_V_PN) + PAG_GETOFF (x)) 281 282 /* Page table entry, TOPS-10 paging */ 283 284 #define PTE_T10_A 0400000 /* T10: access */ 285 #define PTE_T10_P 0200000 /* T10: public */ 286 #define PTE_T10_W 0100000 /* T10: writeable */ 287 #define PTE_T10_S 0040000 /* T10: software */ 288 #define PTE_T10_C 0020000 /* T10: cacheable */ 289 #define PTE_PPMASK PAG_M_PPN 290 291 /* Page table entry, TOPS-20 paging */ 292 293 #define PTE_T20_V_TYP 33 /* T20: pointer type */ 294 #define PTE_T20_M_TYP 07 295 #define T20_NOA 0 /* no access */ 296 #define T20_IMM 1 /* immediate */ 297 #define T20_SHR 2 /* shared */ 298 #define T20_IND 3 /* indirect */ 299 #define PTE_T20_W 0020000000000 /* T20: writeable */ 300 #define PTE_T20_C 0004000000000 /* T20: cacheable */ 301 #define PTE_T20_STM 0000077000000 /* T20: storage medium */ 302 #define PTE_T20_V_PMI 18 /* page map index */ 303 #define PTE_T20_M_PMI 0777 304 #define T20_GETTYP(x) ((int32) (((x) >> PTE_T20_V_TYP) & PTE_T20_M_TYP)) 305 #define T20_GETPMI(x) ((int32) (((x) >> PTE_T20_V_PMI) & PTE_T20_M_PMI)) 306 307 /* CST entry, TOPS-20 paging */ 308 309 #define CST_AGE 0770000000000 /* age field */ 310 #define CST_M 0000000000001 /* modified */ 311 312 /* Page fail word, DEC paging */ 313 314 #define PF_USER 0400000000000 /* user mode */ 315 #define PF_HARD 0200000000000 /* nx I/O reg */ 316 #define PF_NXM 0370000000000 /* nx memory */ 317 #define PF_T10_A 0100000000000 /* T10: pte A bit */ 318 #define PF_T10_W 0040000000000 /* T10: pte W bit */ 319 #define PF_T10_S 0020000000000 /* T10: pte S bit */ 320 #define PF_T20_DN 0100000000000 /* T20: eval done */ 321 #define PF_T20_M 0040000000000 /* T20: modified */ 322 #define PF_T20_W 0020000000000 /* T20: writeable */ 323 #define PF_WRITE 0010000000000 /* write reference */ 324 #define PF_PUB 0004000000000 /* pte public bit */ 325 #define PF_C 0002000000000 /* pte C bit */ 326 #define PF_VIRT 0001000000000 /* pfl: virt ref */ 327 #define PF_NXMP 0001000000000 /* nxm: phys ref */ 328 #define PF_IO 0000200000000 /* I/O reference */ 329 #define PF_BYTE 0000020000000 /* I/O byte ref */ 330 331 /* Virtual address, ITS paging */ 332 333 #define ITS_V_OFF 0 /* offset - must be 0 */ 334 #define ITS_N_OFF 10 /* page offset width */ 335 #define ITS_SIZE 02000 /* page offset size */ 336 #define ITS_M_OFF 01777 /* mask for offset */ 337 #define ITS_V_PN ITS_N_OFF /* page number */ 338 #define ITS_N_PPN (PASIZE- ITS_N_OFF) /* phys pageno width */ 339 #define ITS_M_PPN 01777 /* phys pageno mask */ 340 #define ITS_PPN 03776000 341 #define ITS_N_VPN (VASIZE - ITS_N_OFF) /* virt pageno width */ 342 #define ITS_M_VPN 0377 /* virt pageno mask */ 343 #define ITS_VPN 0776000 344 #define ITS_GETVPN(x) (((x) >> ITS_V_PN) & ITS_M_VPN) 345 346 /* Page table entry, ITS paging */ 347 348 #define PTE_ITS_V_ACC 16 /* access field */ 349 #define PTE_ITS_M_ACC 03 350 #define ITS_ACC_NO 0 /* no access */ 351 #define ITS_ACC_RO 1 /* read only */ 352 #define ITS_ACC_RWF 2 /* read-write first */ 353 #define ITS_ACC_RW 3 /* read write */ 354 #define PTE_ITS_AGE 0020000 /* age */ 355 #define PTE_ITS_C 0010000 /* cacheable */ 356 #define PTE_ITS_PPMASK ITS_M_PPN 357 #define ITS_GETACC(x) (((x) >> PTE_ITS_V_ACC) & PTE_ITS_M_ACC) 358 359 /* Page fail word, ITS paging */ 360 361 #define PF_ITS_WRITE 0010000000000 /* write reference */ 362 #define PF_ITS_V_ACC 28 /* access from PTE */ 363 364 /* Page table fill operations */ 365 366 #define PTF_RD 0 /* read check */ 367 #define PTF_WR 1 /* write check */ 368 #define PTF_MAP 2 /* map instruction */ 369 #define PTF_CON 4 /* console access */ 370 371 /* User base register */ 372 373 #define UBR_SETACB 0400000000000 /* set AC blocks */ 374 #define UBR_SETUBR 0100000000000 /* set UBR */ 375 #define UBR_V_CURAC 27 /* current AC block */ 376 #define UBR_V_PRVAC 24 /* previous AC block */ 377 #define UBR_M_AC 07 378 #define UBR_ACBMASK 0007700000000 379 #define UBR_V_UBR 0 /* user base register */ 380 #define UBR_N_UBR 11 381 #define UBR_M_UBR 03777 382 #define UBR_UBRMASK 0000000003777 383 #define UBR_GETCURAC(x) ((int32) (((x) >> UBR_V_CURAC) & UBR_M_AC)) 384 #define UBR_GETPRVAC(x) ((int32) (((x) >> UBR_V_PRVAC) & UBR_M_AC)) 385 #define UBR_GETUBR(x) ((int32) (((x) >> UBR_V_UBR) & PAG_M_PPN)) 386 #define UBRWORD (ubr | UBR_SETACB | UBR_SETUBR) 387 388 /* Executive base register */ 389 390 #define EBR_V_T20P 14 /* TOPS20 paging */ 391 #define EBR_T20P (1u << EBR_V_T20P) 392 #define EBR_V_PGON 13 /* enable paging */ 393 #define EBR_PGON (1u << EBR_V_PGON) 394 #define EBR_V_EBR 0 /* exec base register */ 395 #define EBR_N_EBR 11 396 #define EBR_M_EBR 03777 397 #define EBR_MASK (EBR_T20P | EBR_PGON | (EBR_M_EBR << EBR_V_EBR)) 398 #define EBR_GETEBR(x) ((int32) (((x) >> EBR_V_EBR) & PAG_M_PPN)) 399 #define PAGING (ebr & EBR_PGON) 400 #define T20PAG (ebr & EBR_T20P) 401 402 /* AC and mapping contexts 403 404 There are only two real contexts for selecting the AC block and 405 the memory map: current and previous. However, PXCT allows the 406 choice of current versus previous to be made selectively for 407 various parts of an instruction. The PXCT flags are kept in a 408 dynamic CPU variable. 409 */ 410 411 #define EA_PXCT 010 /* eff addr calc */ 412 #define OPND_PXCT 004 /* operand, bdst */ 413 #define EABP_PXCT 002 /* bp eff addr calc */ 414 #define BSTK_PXCT 001 /* stk, bp op, bsrc */ 415 #define XSRC_PXCT 002 /* extend source */ 416 #define XDST_PXCT 001 /* extend destination */ 417 #define MM_CUR 000 /* current context */ 418 #define MM_EA (pflgs & EA_PXCT) 419 #define MM_OPND (pflgs & OPND_PXCT) 420 #define MM_EABP (pflgs & EABP_PXCT) 421 #define MM_BSTK (pflgs & BSTK_PXCT) 422 423 /* Accumulator access. The AC blocks are kept in array acs[AC_NBLK * AC_NUM]. 424 Two pointers are provided to the bases of the current and previous blocks. 425 Macro AC selects the current AC block; macro XR selects current or previous, 426 depending on whether the selected bit in the "pxct in progress" flag is set. 427 */ 428 429 #define AC_NUM 16 /* # AC's/block */ 430 #define AC_NBLK 8 /* # AC blocks */ 431 #define AC(r) (ac_cur[r]) /* AC select current */ 432 #define XR(r,prv) ((prv)? ac_prv[r]: ac_cur[r]) /* AC select context */ 433 #define ADDAC(x,i) (((x) + (i)) & INST_M_AC) 434 #define P1 ADDAC (ac, 1) 435 436 /* User process table entries */ 437 438 #define UPT_T10_UMAP 0000 /* T10: user map */ 439 #define UPT_T10_X340 0400 /* T10: exec 340-377 */ 440 #define UPT_TRBASE 0420 /* trap base */ 441 #define UPT_MUUO 0424 /* MUUO block */ 442 #define UPT_MUPC 0425 /* caller's PC */ 443 #define UPT_T10_CTX 0426 /* T10: context */ 444 #define UPT_T20_UEA 0426 /* T20: address */ 445 #define UPT_T20_CTX 0427 /* T20: context */ 446 #define UPT_ENPC 0430 /* MUUO new PC, exec */ 447 #define UPT_1PO 0432 /* ITS 1-proc: old PC */ 448 #define UPT_1PN 0433 /* ITS 1-proc: new PC */ 449 #define UPT_UNPC 0434 /* MUUO new PC, user */ 450 #define UPT_NPCT 1 /* PC offset if trap */ 451 #define UPT_T10_PAG 0500 /* T10: page fail blk */ 452 #define UPT_T20_PFL 0500 /* T20: page fail wd */ 453 #define UPT_T20_OFL 0501 /* T20: flags */ 454 #define UPT_T20_OPC 0502 /* T20: old PC */ 455 #define UPT_T20_NPC 0503 /* T20: new PC */ 456 #define UPT_T20_SCTN 0540 /* T20: section 0 ptr */ 457 458 /* Exec process table entries */ 459 460 #define EPT_PIIT 0040 /* PI interrupt table */ 461 #define EPT_UBIT 0100 /* Unibus intr table */ 462 #define EPT_T10_X400 0200 /* T10: exec 400-777 */ 463 #define EPT_TRBASE 0420 /* trap base */ 464 #define EPT_ITS_PAG 0440 /* ITS: page fail blk */ 465 #define EPT_T20_SCTN 0540 /* T20: section 0 ptr */ 466 #define EPT_T10_X000 0600 /* T10: exec 0 - 337 */ 467 468 /* Microcode constants */ 469 470 #define UC_INHCST 0400000000000 /* inhibit CST update */ 471 #define UC_UBABLT 0040000000000 /* BLTBU and BLTUB */ 472 #define UC_KIPAGE 0020000000000 /* "KI" paging */ 473 #define UC_KLPAGE 0010000000000 /* "KL" paging */ 474 #define UC_VERDEC (0130 << 18) /* ucode version */ 475 #define UC_VERITS (262u << 18) 476 #define UC_SERDEC 4097 /* serial number */ 477 #define UC_SERITS 1729 478 #define UC_AIDDEC (UC_INHCST | UC_UBABLT | UC_KIPAGE | UC_KLPAGE | \ 479 UC_VERDEC | UC_SERDEC) 480 #define UC_AIDITS (UC_KIPAGE | UC_VERITS | UC_SERITS) 481 #define UC_HSBDEC 0376000 /* DEC initial HSB */ 482 #define UC_HSBITS 0000500 /* ITS initial HSB */ 483 484 /* Front end communications region */ 485 486 #define FE_SWITCH 030 /* halt switch */ 487 #define FE_KEEPA 031 /* keep alive */ 488 #define FE_CTYIN 032 /* console in */ 489 #define FE_CTYOUT 033 /* console out */ 490 #define FE_KLININ 034 /* KLINIK in */ 491 #define FE_KLINOUT 035 /* KLINIK out */ 492 #define FE_RHBASE 036 /* boot: RH11 addr */ 493 #define FE_UNIT 037 /* boot: unit num */ 494 #define FE_MTFMT 040 /* boot: magtape params */ 495 #define FE_CVALID 0400 /* char valid flag */ 496 497 /* Halfword operations */ 498 499 #define ADDL(x,y) (((x) + ((y) << 18)) & LMASK) 500 #define ADDR(x,y) (((x) + (y)) & RMASK) 501 #define INCL(x) ADDL (x, 1) 502 #define INCR(x) ADDR (x, 1) 503 #define AOB(x) (INCL (x) | INCR(x)) 504 #define SUBL(x,y) (((x) - ((y) << 18)) & LMASK) 505 #define SUBR(x,y) (((x) - (y)) & RMASK) 506 #define DECL(x) SUBL (x, 1) 507 #define DECR(x) SUBR (x, 1) 508 #define SOB(x) (DECL (x) | DECR(x)) 509 #define LLZ(x) ((x) & LMASK) 510 #define RLZ(x) (((x) << 18) & LMASK) 511 #define RRZ(x) ((x) & RMASK) 512 #define LRZ(x) (((x) >> 18) & RMASK) 513 #define LIT8(x) (((x) & RSIGN)? \ 514 (((x) & 0377)? (-(x) & 0377): 0400): ((x) & 0377)) 515 516 /* Fullword operations */ 517 518 #define INC(x) (((x) + 1) & DMASK) 519 #define DEC(x) (((x) - 1) & DMASK) 520 #define SWP(x) ((((x) << 18) & LMASK) | (((x) >> 18) & RMASK)) 521 #define XWD(x,y) (((((d10) (x)) << 18) & LMASK) | (((d10) (y)) & RMASK)) 522 #define SETS(x) ((x) | SIGN) 523 #define CLRS(x) ((x) & ~SIGN) 524 #define TSTS(x) ((x) & SIGN) 525 #define NEG(x) (-(x) & DMASK) 526 #define ABS(x) (TSTS (x)? NEG(x): (x)) 527 #define SXT(x) (TSTS (x)? (x) | ~DMASK: (x)) 528 529 /* Doubleword operations (on 2-word arrays) */ 530 531 #define DMOVN(rs) rs[1] = (-rs[1]) & MMASK; \ 532 rs[0] = (~rs[0] + (rs[1] == 0)) & DMASK 533 #define MKDNEG(rs) rs[1] = SETS (-rs[1]) & DMASK; \ 534 rs[0] = (~rs[0] + (rs[1] == MAXNEG)) & DMASK 535 #define DCMPGE(a,b) ((a[0] > b[0]) || ((a[0] == b[0]) && (a[1] >= b[1]))) 536 537 /* Address operations */ 538 539 #define ADDA(x,i) (((x) + (i)) & AMASK) 540 #define INCA(x) ADDA (x, 1) 541 542 /* Unibus adapter control/status register */ 543 544 #define UBCS_TMO 0400000 /* timeout */ 545 #define UBCS_BMD 0200000 /* bad mem data NI */ 546 #define UBCS_PAR 0100000 /* parity error NI */ 547 #define UBCS_NXD 0040000 /* nx device */ 548 #define UBCS_HI 0004000 /* irq on BR7 or BR6 */ 549 #define UBCS_LO 0002000 /* irq on BR5 or BR4 */ 550 #define UBCS_PWR 0001000 /* power low NI */ 551 #define UBCS_DXF 0000200 /* disable xfer NI*/ 552 #define UBCS_INI 0000100 /* Unibus init */ 553 #define UBCS_RDZ 0030500 /* read as zero */ 554 #define UBCS_RDW 0000277 /* read/write bits */ 555 #define UBCS_V_LHI 3 /* hi pri irq level */ 556 #define UBCS_V_LLO 0 /* lo pri irq level */ 557 #define UBCS_M_PRI 07 558 #define UBCS_GET_HI(x) (((x) >> UBCS_V_LHI) & UBCS_M_PRI) 559 #define UBCS_GET_LO(x) (((x) >> UBCS_V_LLO) & UBCS_M_PRI) 560 561 /* Unibus adapter page map */ 562 563 #define UBANUM 2 /* # of Unibus adapters */ 564 #define UMAP_ASIZE 6 /* address size */ 565 #define UMAP_MEMSIZE (1 << UMAP_ASIZE) /* length */ 566 #define UMAP_AMASK (UMAP_MEMSIZE - 1) 567 #define UMAP_V_RRV 30 /* read reverse */ 568 #define UMAP_V_DSB 29 /* 16b on NPR read */ 569 #define UMAP_V_FST 28 /* fast transfer */ 570 #define UMAP_V_VLD 27 /* valid flag */ 571 #define UMAP_RRV (1 << UMAP_V_RRV) 572 #define UMAP_DSB (1 << UMAP_V_DSB) 573 #define UMAP_FST (1 << UMAP_V_FST) 574 #define UMAP_VLD (1 << UMAP_V_VLD) 575 #define UMAP_V_FLWR 14 /* flags as written */ 576 #define UMAP_V_FLRD 27 /* flags as stored */ 577 #define UMAP_M_FL 017 578 #define UMAP_V_PNWR 0 /* page num, write */ 579 #define UMAP_V_PNRD 9 /* page num, read */ 580 #define UMAP_M_PN 03777 581 #define UMAP_MASK ((UMAP_M_FL << UMAP_V_FLRD) | (UMAP_M_PN << UMAP_V_PNRD)) 582 #define UMAP_POSFL(x) (((x) & (UMAP_M_FL << UMAP_V_FLWR)) \ 583 << (UMAP_V_FLRD - UMAP_V_FLWR)) 584 #define UMAP_POSPN(x) (((x) & (UMAP_M_PN << UMAP_V_PNWR)) \ 585 << (UMAP_V_PNRD - UMAP_V_PNWR)) 586 587 /* Unibus I/O constants */ 588 589 #define READ 0 /* PDP11 compatible */ 590 /* #define READC 1 /* console read */ 591 #define WRITE 2 592 /* #define WRITEC 3 /* console write */ 593 #define WRITEB 4 594 #define IO_V_UBA 18 /* UBA in I/O addr */ 595 #define IO_N_UBA 16 /* max num of UBA's */ 596 #define IO_M_UBA (IO_N_UBA - 1) 597 #define IO_UBA1 (1 << IO_V_UBA) 598 #define IO_UBA3 (3 << IO_V_UBA) 599 #define GET_IOUBA(x) (((x) >> IO_V_UBA) & IO_M_UBA) 600 601 /* Device information block */ 602 603 #define VEC_DEVMAX 8 /* max device vec */ 604 605 struct pdp_dib { 606 uint32 ba; /* base addr */ 607 uint32 lnt; /* length */ 608 t_stat (*rd)(int32 *dat, int32 ad, int32 md); 609 t_stat (*wr)(int32 dat, int32 ad, int32 md); 610 int32 vnum; /* vectors: number */ 611 int32 vloc; /* locator */ 612 int32 vec; /* value */ 613 int32 (*ack[VEC_DEVMAX])(void); /* ack routines */ 614 }; 615 616 typedef struct pdp_dib DIB; 617 618 /* I/O system parameters */ 619 620 #define DZ_MUXES 4 /* max # of muxes */ 621 #define DZ_LINES 8 /* lines per mux */ 622 #define DIB_MAX 100 /* max DIBs */ 623 624 #define DEV_V_UBUS (DEV_V_UF + 0) /* Unibus */ 625 #define DEV_V_QBUS (DEV_V_UF + 1) /* Qbus */ 626 #define DEV_V_Q18 (DEV_V_UF + 2) /* Qbus, mem <= 256KB */ 627 #define DEV_V_FLTA (DEV_V_UF + 3) /* float addr */ 628 #define DEV_UBUS (1u << DEV_V_UBUS) 629 #define DEV_QBUS (1u << DEV_V_QBUS) 630 #define DEV_Q18 (1u << DEV_V_Q18) 631 #define DEV_FLTA (1u << DEV_V_FLTA) 632 633 #define UNIBUS TRUE /* 18b only */ 634 635 #define DEV_RDX 8 /* default device radix */ 636 637 /* I/O page layout */ 638 639 #define IOPAGEBASE 0760000 /* I/O page base */ 640 #define IOBA_UBMAP 0763000 641 642 #define IOBA_UBMAP1 (IO_UBA1 + IOBA_UBMAP) /* Unibus 1 map */ 643 #define IOLN_UBMAP1 0100 644 #define IOBA_UBCS1 (IO_UBA1 + 0763100) /* Unibus 1 c/s reg */ 645 #define IOLN_UBCS1 001 646 #define IOBA_UBMNT1 (IO_UBA1 + 0763101) /* Unibus 1 maint reg */ 647 #define IOLN_UBMNT1 001 648 #define IOBA_RP (IO_UBA1 + 0776700) /* RH11/disk */ 649 #define IOLN_RP 050 650 651 #define IOBA_DZ (IO_UBA3 + 0760010) /* DZ11 */ 652 #define IOLN_DZ 010 653 #define IOBA_TCU (IO_UBA3 + 0760770) /* TCU150 */ 654 #define IOLN_TCU 006 655 #define IOBA_UBMAP3 (IO_UBA3 + IOBA_UBMAP) /* Unibus 3 map */ 656 #define IOLN_UBMAP3 0100 657 #define IOBA_UBCS3 (IO_UBA3 + 0763100) /* Unibus 3 c/s reg */ 658 #define IOLN_UBCS3 001 659 #define IOBA_UBMNT3 (IO_UBA3 + 0763101) /* Unibus 3 maint reg */ 660 #define IOLN_UBMNT3 001 661 #define IOBA_XU (IO_UBA3 + 0774510) /* DEUNA/DELUA */ 662 #define IOLN_XU 010 663 #define IOBA_CR (IO_UBA3 + 0777160) /* CD/CR/CM */ 664 #define IOLN_CR 010 665 #define IOBA_RY (IO_UBA3 + 0777170) /* RX211 */ 666 #define IOLN_RY 004 667 #define IOBA_TU (IO_UBA3 + 0772440) /* RH11/tape */ 668 #define IOLN_TU 034 669 #define IOBA_LP20 (IO_UBA3 + 0775400) /* LP20 */ 670 #define IOLN_LP20 020 671 #define IOBA_PTR (IO_UBA3 + 017550) /* PC11 reader */ 672 #define IOLN_PTR 004 673 #define IOBA_PTP (IO_UBA3 + 017554) /* PC11 punch */ 674 #define IOLN_PTP 004 675 676 /* Common Unibus CSR flags */ 677 678 #define CSR_V_GO 0 /* go */ 679 #define CSR_V_IE 6 /* interrupt enable */ 680 #define CSR_V_DONE 7 /* done */ 681 #define CSR_V_BUSY 11 /* busy */ 682 #define CSR_V_ERR 15 /* error */ 683 #define CSR_GO (1u << CSR_V_GO) 684 #define CSR_IE (1u << CSR_V_IE) 685 #define CSR_DONE (1u << CSR_V_DONE) 686 #define CSR_BUSY (1u << CSR_V_BUSY) 687 #define CSR_ERR (1u << CSR_V_ERR) 688 689 /* I/O system definitions, lifted from the PDP-11 simulator 690 Interrupt assignments, priority is right to left 691 692 <3:0> = BR7 693 <7:4> = BR6 694 <19:8> = BR5 695 <30:20> = BR4 696 */ 697 698 #define INT_V_RP 6 /* RH11/RP,RM drives */ 699 #define INT_V_TU 7 /* RH11/TM03/TU45 */ 700 #define INT_V_XU 15 /* DEUNA/DELUA */ 701 #define INT_V_DZRX 16 /* DZ11 */ 702 #define INT_V_DZTX 17 703 #define INT_V_RY 18 /* RX211 */ 704 #define INT_V_PTR 24 /* PC11 */ 705 #define INT_V_PTP 25 706 #define INT_V_LP20 26 /* LPT20 */ 707 #define INT_V_CR 27 /* CD20 (CD11) */ 708 709 #define INT_RP (1u << INT_V_RP) 710 #define INT_TU (1u << INT_V_TU) 711 #define INT_XU (1u << INT_V_XU) 712 #define INT_DZRX (1u << INT_V_DZRX) 713 #define INT_DZTX (1u << INT_V_DZTX) 714 #define INT_RY (1u << INT_V_RY) 715 #define INT_PTR (1u << INT_V_PTR) 716 #define INT_PTP (1u << INT_V_PTP) 717 #define INT_LP20 (1u << INT_V_LP20) 718 #define INT_CR (1u << INT_V_CR) 719 720 #define IPL_RP 6 /* int levels */ 721 #define IPL_TU 6 722 #define IPL_XU 5 723 #define IPL_DZRX 5 724 #define IPL_DZTX 5 725 #define IPL_RY 5 726 #define IPL_PTR 4 727 #define IPL_PTP 4 728 #define IPL_LP20 4 729 #define IPL_CR 4 730 731 #define INT_UB1 INT_RP /* on Unibus 1 */ 732 #define INT_UB3 (0xFFFFFFFFu & ~INT_UB1) /* on Unibus 3 */ 733 734 #define INT_IPL7 0x0000000F /* int level masks */ 735 #define INT_IPL6 0x000000F0 736 #define INT_IPL5 0x000FFF00 737 #define INT_IPL4 0x3FF00000 738 739 #define VEC_Q 0000 /* vector base */ 740 #define VEC_PTR 0070 /* interrupt vectors */ 741 #define VEC_PTP 0074 742 #define VEC_XU 0120 743 #define VEC_TU 0224 744 #define VEC_CR 0230 745 #define VEC_RP 0254 746 #define VEC_RY 0264 747 #define VEC_DZRX 0340 748 #define VEC_DZTX 0344 749 #define VEC_LP20 0754 750 751 #define IVCL(dv) (INT_V_##dv) 752 #define IREQ(dv) int_req 753 #define SET_INT(dv) IREQ(dv) = IREQ(dv) | (INT_##dv) 754 #define CLR_INT(dv) IREQ(dv) = IREQ(dv) & ~(INT_##dv) 755 756 /* Function prototypes */ 757 758 int32 Map_ReadB (uint32 ba, int32 bc, uint8 *buf); 759 int32 Map_ReadW (uint32 ba, int32 bc, uint16 *buf); 760 int32 Map_WriteB (uint32 ba, int32 bc, uint8 *buf); 761 int32 Map_WriteW (uint32 ba, int32 bc, uint16 *buf); 762 763 t_stat set_addr (UNIT *uptr, int32 val, char *cptr, void *desc); 764 t_stat set_addr_flt (UNIT *uptr, int32 val, char *cptr, void *desc); 765 t_stat show_addr (FILE *st, UNIT *uptr, int32 val, void *desc); 766 t_stat set_vec (UNIT *uptr, int32 val, char *cptr, void *desc); 767 t_stat show_vec (FILE *st, UNIT *uptr, int32 val, void *desc); 768 t_stat show_vec_mux (FILE *st, UNIT *uptr, int32 val, void *desc); 769 t_stat auto_config (char *name, int32 num); 770 771 int32 clk_cosched (int32 wait); 772 773 /* Global data */ 774 775 extern t_bool sim_idle_enab; 776 777 #endif 778