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