First Commit of my working state
[simh.git] / PDP11 / pdp11_defs.h
1 /* pdp11_defs.h: PDP-11 simulator definitions
2
3 Copyright (c) 1993-2008, 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 The author gratefully acknowledges the help of Max Burnet, Megan Gentry,
27 and John Wilson in resolving questions about the PDP-11
28
29 16-May-08 RMS Added KE11A, DC11 support
30 02-Feb-08 RMS Fixed DMA memory address limit test (found by John Dundas)
31 25-Jan-08 RMS Added RC11, KG11A support (from John Dundas)
32 16-Dec-06 RMS Added TA11 support
33 29-Oct-06 RMS Added clock coscheduling
34 06-Jul-06 RMS Added multiple KL11/DL11 support
35 26-Jun-06 RMS Added RF11 support
36 24-May-06 RMS Added 11/44 DR support (from CIS diagnostic)
37 17-May-06 RMS Added CR11/CD11 support (from John Dundas)
38 30-Sep-04 RMS Added Massbus support
39 Removed Map_Addr prototype
40 Removed map argument from Unibus routines
41 Added framework for model selection
42 28-May-04 RMS Added DHQ support
43 25-Jan-04 RMS Removed local debug logging support
44 22-Dec-03 RMS Added second DEUNA/DELUA support
45 18-Oct-03 RMS Added DECtape off reel message
46 19-May-03 RMS Revised for new conditional compilation
47 05-Apr-03 RMS Fixed bug in MMR1 update (found by Tim Stark)
48 28-Feb-03 RMS Added TM logging support
49 19-Jan-03 RMS Changed mode definitions for Apple Dev Kit conflict
50 11-Nov-02 RMS Changed log definitions to be VAX compatible
51 10-Oct-02 RMS Added vector information to DIB
52 Changed DZ11 vector to Unibus standard
53 Added DEQNA/DELQA, DEUNA/DELUA support
54 Added multiple RQDX3, autoconfigure support
55 12-Sep-02 RMS Added TMSCP, KW11P,and RX211 support
56 28-Apr-02 RMS Clarified PDF ACF mnemonics
57 22-Apr-02 RMS Added HTRAP, BPOK maint register flags, MT_MAXFR
58 06-Mar-02 RMS Changed system type to KDJ11A
59 20-Jan-02 RMS Added multiboard DZ11 support
60 09-Nov-01 RMS Added bus map support
61 07-Nov-01 RMS Added RQDX3 support
62 26-Oct-01 RMS Added symbolic definitions for IO page
63 19-Oct-01 RMS Added DZ definitions
64 15-Oct-01 RMS Added logging capabilities
65 07-Sep-01 RMS Revised for multilevel interrupts
66 01-Jun-01 RMS Added DZ11 support
67 23-Apr-01 RMS Added RK611 support
68 05-Apr-01 RMS Added TS11/TSV05 support
69 10-Feb-01 RMS Added DECtape support
70 */
71
72 #ifndef _PDP11_DEFS_H
73 #define _PDP11_DEFS_H 0
74
75 #ifndef VM_PDP11
76 #define VM_PDP11 0
77 #endif
78
79 #include "sim_defs.h" /* simulator defns */
80 #include <setjmp.h>
81
82 /* Architectural constants */
83
84 #define STKL_R 0340 /* stack limit */
85 #define STKL_Y 0400
86 #define VASIZE 0200000 /* 2**16 */
87 #define VAMASK (VASIZE - 1) /* 2**16 - 1 */
88 #define MEMSIZE64K 0200000 /* 2**16 */
89 #define INIMEMSIZE 001000000 /* 2**18 */
90 #define UNIMEMSIZE 001000000 /* 2**18 */
91 #define UNIMASK (UNIMEMSIZE - 1) /* 2**18 - 1 */
92 #define IOPAGEBASE 017760000 /* 2**22 - 2**13 */
93 #define IOPAGESIZE 000020000 /* 2**13 */
94 #define IOPAGEMASK (IOPAGESIZE - 1) /* 2**13 - 1 */
95 #define MAXMEMSIZE 020000000 /* 2**22 */
96 #define PAMASK (MAXMEMSIZE - 1) /* 2**22 - 1 */
97 #define MEMSIZE (cpu_unit.capac)
98 #define ADDR_IS_MEM(x) (((t_addr) (x)) < cpu_memsize) /* use only in sim! */
99 #define DMASK 0177777
100
101 /* CPU models */
102
103 #define MOD_1103 0
104 #define MOD_1104 1
105 #define MOD_1105 2
106 #define MOD_1120 3
107 #define MOD_1123 4
108 #define MOD_1123P 5
109 #define MOD_1124 6
110 #define MOD_1134 7
111 #define MOD_1140 8
112 #define MOD_1144 9
113 #define MOD_1145 10
114 #define MOD_1160 11
115 #define MOD_1170 12
116 #define MOD_1173 13
117 #define MOD_1153 14
118 #define MOD_1173B 15
119 #define MOD_1183 16
120 #define MOD_1184 17
121 #define MOD_1193 18
122 #define MOD_1194 19
123 #define MOD_T 20
124
125 #define CPUT_03 (1u << MOD_1103) /* LSI-11 */
126 #define CPUT_04 (1u << MOD_1104) /* 11/04 */
127 #define CPUT_05 (1u << MOD_1105) /* 11/05 */
128 #define CPUT_20 (1u << MOD_1120) /* 11/20 */
129 #define CPUT_23 (1u << MOD_1123) /* 11/23 */
130 #define CPUT_23P (1u << MOD_1123P) /* 11/23+ */
131 #define CPUT_24 (1u << MOD_1124) /* 11/24 */
132 #define CPUT_34 (1u << MOD_1134) /* 11/34 */
133 #define CPUT_40 (1u << MOD_1140) /* 11/40 */
134 #define CPUT_44 (1u << MOD_1144) /* 11/44 */
135 #define CPUT_45 (1u << MOD_1145) /* 11/45 */
136 #define CPUT_60 (1u << MOD_1160) /* 11/60 */
137 #define CPUT_70 (1u << MOD_1170) /* 11/70 */
138 #define CPUT_73 (1u << MOD_1173) /* 11/73 */
139 #define CPUT_53 (1u << MOD_1153) /* 11/53 */
140 #define CPUT_73B (1u << MOD_1173B) /* 11/73B */
141 #define CPUT_83 (1u << MOD_1183) /* 11/83 */
142 #define CPUT_84 (1u << MOD_1184) /* 11/84 */
143 #define CPUT_93 (1u << MOD_1193) /* 11/93 */
144 #define CPUT_94 (1u << MOD_1194) /* 11/94 */
145 #define CPUT_T (1u << MOD_T) /* T-11 */
146
147 #define CPUT_F (CPUT_23|CPUT_23P|CPUT_24) /* all F11's */
148 #define CPUT_J (CPUT_53|CPUT_73|CPUT_73B| \
149 CPUT_83|CPUT_84|CPUT_93|CPUT_94)
150 #define CPUT_JB (CPUT_73B|CPUT_83|CPUT_84) /* KDJ11B */
151 #define CPUT_JE (CPUT_93|CPUT_94) /* KDJ11E */
152 #define CPUT_JU (CPUT_84|CPUT_94) /* KTJ11B UBA */
153 #define CPUT_ALL 0xFFFFFFFF
154
155 /* CPU options */
156
157 #define BUS_U (1u << 0) /* Unibus */
158 #define BUS_Q (0) /* Qbus */
159 #define OPT_EIS (1u << 1) /* EIS */
160 #define OPT_FIS (1u << 2) /* FIS */
161 #define OPT_FPP (1u << 3) /* FPP */
162 #define OPT_CIS (1u << 4) /* CIS */
163 #define OPT_MMU (1u << 5) /* MMU */
164 #define OPT_RH11 (1u << 6) /* RH11 */
165 #define OPT_PAR (1u << 7) /* parity */
166 #define OPT_UBM (1u << 8) /* UBM */
167
168 #define CPUT(x) ((cpu_type & (x)) != 0)
169 #define CPUO(x) ((cpu_opt & (x)) != 0)
170 #define UNIBUS (cpu_opt & BUS_U)
171
172 /* Feature sets
173
174 SDSD source addr, dest addr, source fetch, dest fetch
175 SR switch register
176 DR display register
177 RTT RTT instruction
178 SXS SXT, XOR, SOB instructions
179 MARK MARK instruction
180 SPL SPL instruction
181 MXPY MTPI, MTPD, MFPI, MFPD instructions
182 MXPS MTPS, MFPS instructions
183 MFPT MFPT instruction
184 CSM CSM instruction
185 TSWLK TSTSET, WRLCK instructions
186 PSW PSW register
187 EXPT explicit PSW writes can alter T-bit
188 IOSR general registers readable from programs in IO space
189 2REG dual register set
190 MMR3 MMR3 register
191 MMTR mem mgt traps
192 STKLR STKLIM register
193 STKLF fixed stack limit
194 SID supervisor mode, I/D spaces
195 ODD odd address trap
196 HALT4 halt in kernel mode traps to 4
197 JREG4 JMP/JSR R traps to 4
198 STKA stop on stack abort
199 LTCR LTC CSR
200 LTCM LTC CSR<7>
201 */
202
203 #define IS_SDSD (CPUT_20|CPUT_F|CPUT_40|CPUT_60|CPUT_J|CPUT_T)
204 #define HAS_SR (CPUT_04|CPUT_05|CPUT_20|CPUT_34|CPUT_40| \
205 CPUT_44|CPUT_45|CPUT_60|CPUT_70)
206 #define HAS_DR (CPUT_04|CPUT_05|CPUT_20|CPUT_24|CPUT_34| \
207 CPUT_40|CPUT_44|CPUT_45|CPUT_60|CPUT_70)
208 #define HAS_RTT (CPUT_03|CPUT_04|CPUT_F|CPUT_34|CPUT_40| \
209 CPUT_44|CPUT_45|CPUT_60|CPUT_70|CPUT_J|CPUT_T)
210 #define HAS_SXS (CPUT_03|CPUT_F|CPUT_34|CPUT_40|CPUT_44| \
211 CPUT_45|CPUT_60|CPUT_70|CPUT_J|CPUT_T)
212 #define HAS_MARK (CPUT_03|CPUT_F|CPUT_34|CPUT_40|CPUT_44| \
213 CPUT_45|CPUT_60|CPUT_70|CPUT_J)
214 #define HAS_SPL (CPUT_44|CPUT_45|CPUT_70|CPUT_J)
215 #define HAS_MXPY (CPUT_F|CPUT_34|CPUT_40|CPUT_44|CPUT_45| \
216 CPUT_60|CPUT_70|CPUT_J)
217 #define HAS_MXPS (CPUT_03|CPUT_F|CPUT_34|CPUT_J|CPUT_T)
218 #define HAS_MFPT (CPUT_F|CPUT_44|CPUT_J|CPUT_T)
219 #define HAS_CSM (CPUT_44|CPUT_J)
220 #define HAS_TSWLK (CPUT_J)
221 #define HAS_PSW (CPUT_04|CPUT_05|CPUT_20|CPUT_F|CPUT_34|CPUT_40| \
222 CPUT_44|CPUT_45|CPUT_60|CPUT_70|CPUT_J)
223 #define HAS_EXPT (CPUT_04|CPUT_05|CPUT_20)
224 #define HAS_IOSR (CPUT_04|CPUT_05)
225 #define HAS_2REG (CPUT_45|CPUT_70|CPUT_J)
226 #define HAS_MMR3 (CPUT_F|CPUT_44|CPUT_45|CPUT_70|CPUT_J)
227 #define HAS_MMTR (CPUT_45|CPUT_70)
228 #define HAS_STKLR (CPUT_45|CPUT_60|CPUT_70)
229 #define HAS_STKLF (CPUT_04|CPUT_05|CPUT_20|CPUT_F|CPUT_34| \
230 CPUT_40|CPUT_44|CPUT_J)
231 #define HAS_SID (CPUT_44|CPUT_45|CPUT_70|CPUT_J)
232 #define HAS_ODD (CPUT_04|CPUT_05|CPUT_20|CPUT_34|CPUT_40| \
233 CPUT_44|CPUT_45|CPUT_60|CPUT_70|CPUT_J)
234 #define HAS_HALT4 (CPUT_44|CPUT_45|CPUT_70|CPUT_J)
235 #define HAS_JREG4 (CPUT_03|CPUT_04|CPUT_05|CPUT_20|CPUT_F| \
236 CPUT_34|CPUT_40|CPUT_60|CPUT_T)
237 #define STOP_STKA (CPUT_03|CPUT_04|CPUT_05|CPUT_20|CPUT_34|CPUT_44)
238 #define HAS_LTCR (CPUT_04|CPUT_05|CPUT_20|CPUT_23P|CPUT_24| \
239 CPUT_34|CPUT_40|CPUT_44|CPUT_45|CPUT_60| \
240 CPUT_70|CPUT_J)
241 #define HAS_LTCM (CPUT_04|CPUT_05|CPUT_20|CPUT_24|CPUT_34| \
242 CPUT_40|CPUT_44|CPUT_45|CPUT_60|CPUT_70|CPUT_J)
243
244 /* Protection modes */
245
246 #define MD_KER 0
247 #define MD_SUP 1
248 #define MD_UND 2
249 #define MD_USR 3
250
251 /* I/O access modes */
252
253 #define READ 0
254 #define READC 1 /* read console */
255 #define WRITE 2
256 #define WRITEC 3 /* write console */
257 #define WRITEB 4
258
259 /* PSW */
260
261 #define PSW_V_C 0 /* condition codes */
262 #define PSW_V_V 1
263 #define PSW_V_Z 2
264 #define PSW_V_N 3
265 #define PSW_V_TBIT 4 /* trace trap */
266 #define PSW_V_IPL 5 /* int priority */
267 #define PSW_V_FPD 8 /* first part done */
268 #define PSW_V_RS 11 /* register set */
269 #define PSW_V_PM 12 /* previous mode */
270 #define PSW_V_CM 14 /* current mode */
271 #define PSW_CC 017
272 #define PSW_TBIT (1 << PSW_V_TBIT)
273 #define PSW_PM (3 << PSW_V_PM)
274
275 /* FPS */
276
277 #define FPS_V_C 0 /* condition codes */
278 #define FPS_V_V 1
279 #define FPS_V_Z 2
280 #define FPS_V_N 3
281 #define FPS_V_T 5 /* truncate */
282 #define FPS_V_L 6 /* long */
283 #define FPS_V_D 7 /* double */
284 #define FPS_V_IC 8 /* ic err int */
285 #define FPS_V_IV 9 /* overflo err int */
286 #define FPS_V_IU 10 /* underflo err int */
287 #define FPS_V_IUV 11 /* undef var err int */
288 #define FPS_V_ID 14 /* int disable */
289 #define FPS_V_ER 15 /* error */
290
291 /* PIRQ */
292
293 #define PIRQ_PIR1 0001000
294 #define PIRQ_PIR2 0002000
295 #define PIRQ_PIR3 0004000
296 #define PIRQ_PIR4 0010000
297 #define PIRQ_PIR5 0020000
298 #define PIRQ_PIR6 0040000
299 #define PIRQ_PIR7 0100000
300 #define PIRQ_IMP 0177356 /* implemented bits */
301 #define PIRQ_RW 0177000 /* read/write bits */
302
303 /* STKLIM */
304
305 #define STKLIM_RW 0177400
306
307 /* MMR0 */
308
309 #define MMR0_MME 0000001 /* mem mgt enable */
310 #define MMR0_V_PAGE 1 /* offset to pageno */
311 #define MMR0_M_PAGE 077 /* mask for pageno */
312 #define MMR0_PAGE (MMR0_M_PAGE << MMR0_V_PAGE)
313 #define MMR0_IC 0000200 /* instr complete */
314 #define MMR0_MAINT 0000400 /* maintenance */
315 #define MMR0_TENB 0001000 /* trap enable */
316 #define MMR0_TRAP 0010000 /* mem mgt trap */
317 #define MMR0_RO 0020000 /* read only error */
318 #define MMR0_PL 0040000 /* page lnt error */
319 #define MMR0_NR 0100000 /* no access error */
320 #define MMR0_FREEZE 0160000 /* if set, no update */
321 #define MMR0_WR 0171401 /* writeable bits */
322
323 /* MMR3 */
324
325 #define MMR3_UDS 001 /* user dspace enbl */
326 #define MMR3_SDS 002 /* super dspace enbl */
327 #define MMR3_KDS 004 /* krnl dspace enbl */
328 #define MMR3_CSM 010 /* CSM enable */
329 #define MMR3_M22E 020 /* 22b mem mgt enbl */
330 #define MMR3_BME 040 /* DMA bus map enbl */
331
332 /* PAR */
333
334 #define PAR_18B 0007777 /* 18b addressing */
335 #define PAR_22B 0177777 /* 22b addressing */
336
337 /* PDR */
338
339 #define PDR_ACF 0000007 /* access control */
340 #define PDR_ACS 0000006 /* 2b access control */
341 #define PDR_ED 0000010 /* expansion dir */
342 #define PDR_W 0000100 /* written flag */
343 #define PDR_A 0000200 /* access flag */
344 #define PDR_PLF 0077400 /* page lnt field */
345 #define PDR_NOC 0100000 /* don't cache */
346
347 #define PDR_PRD 0000003 /* page readable if 2 */
348
349 /* Virtual address */
350
351 #define VA_DF 0017777 /* displacement */
352 #define VA_BN 0017700 /* block number */
353 #define VA_V_APF 13 /* offset to APF */
354 #define VA_V_DS 16 /* offset to space */
355 #define VA_V_MODE 17 /* offset to mode */
356 #define VA_DS (1u << VA_V_DS) /* data space flag */
357
358 /* Unibus map (if present) */
359
360 #define UBM_LNT_LW 32 /* size in LW */
361 #define UBM_V_PN 13 /* page number */
362 #define UBM_M_PN 037
363 #define UBM_V_OFF 0 /* offset */
364 #define UBM_M_OFF 017777
365 #define UBM_PAGSIZE (UBM_M_OFF + 1) /* page size */
366 #define UBM_GETPN(x) (((x) >> UBM_V_PN) & UBM_M_PN)
367 #define UBM_GETOFF(x) ((x) & UBM_M_OFF)
368
369 /* CPUERR */
370
371 #define CPUE_RED 0004 /* red stack */
372 #define CPUE_YEL 0010 /* yellow stack */
373 #define CPUE_TMO 0020 /* IO page nxm */
374 #define CPUE_NXM 0040 /* memory nxm */
375 #define CPUE_ODD 0100 /* odd address */
376 #define CPUE_HALT 0200 /* HALT not kernel */
377 #define CPUE_IMP 0374 /* implemented bits */
378
379 /* Floating point accumulators */
380
381 typedef struct {
382 uint32 l; /* low 32b */
383 uint32 h; /* high 32b */
384 } fpac_t;
385
386 /* Device CSRs */
387
388 #define CSR_V_GO 0 /* go */
389 #define CSR_V_IE 6 /* interrupt enable */
390 #define CSR_V_DONE 7 /* done */
391 #define CSR_V_BUSY 11 /* busy */
392 #define CSR_V_ERR 15 /* error */
393 #define CSR_GO (1u << CSR_V_GO)
394 #define CSR_IE (1u << CSR_V_IE)
395 #define CSR_DONE (1u << CSR_V_DONE)
396 #define CSR_BUSY (1u << CSR_V_BUSY)
397 #define CSR_ERR (1u << CSR_V_ERR)
398
399 /* Trap masks, descending priority order, following J-11
400 An interrupt summary bit is kept with traps, to minimize overhead
401 */
402
403 #define TRAP_V_RED 0 /* red stk abort 4 */
404 #define TRAP_V_ODD 1 /* odd address 4 */
405 #define TRAP_V_MME 2 /* mem mgt 250 */
406 #define TRAP_V_NXM 3 /* nx memory 4 */
407 #define TRAP_V_PAR 4 /* parity err 114 */
408 #define TRAP_V_PRV 5 /* priv inst 4 */
409 #define TRAP_V_ILL 6 /* illegal inst 10 */
410 #define TRAP_V_BPT 7 /* BPT 14 */
411 #define TRAP_V_IOT 8 /* IOT 20 */
412 #define TRAP_V_EMT 9 /* EMT 30 */
413 #define TRAP_V_TRAP 10 /* TRAP 34 */
414 #define TRAP_V_TRC 11 /* T bit 14 */
415 #define TRAP_V_YEL 12 /* stack 4 */
416 #define TRAP_V_PWRFL 13 /* power fail 24 */
417 #define TRAP_V_FPE 14 /* fpe 244 */
418 #define TRAP_V_MAX 15 /* intr = max trp # */
419 #define TRAP_RED (1u << TRAP_V_RED)
420 #define TRAP_ODD (1u << TRAP_V_ODD)
421 #define TRAP_MME (1u << TRAP_V_MME)
422 #define TRAP_NXM (1u << TRAP_V_NXM)
423 #define TRAP_PAR (1u << TRAP_V_PAR)
424 #define TRAP_PRV (1u << TRAP_V_PRV)
425 #define TRAP_ILL (1u << TRAP_V_ILL)
426 #define TRAP_BPT (1u << TRAP_V_BPT)
427 #define TRAP_IOT (1u << TRAP_V_IOT)
428 #define TRAP_EMT (1u << TRAP_V_EMT)
429 #define TRAP_TRAP (1u << TRAP_V_TRAP)
430 #define TRAP_TRC (1u << TRAP_V_TRC)
431 #define TRAP_YEL (1u << TRAP_V_YEL)
432 #define TRAP_PWRFL (1u << TRAP_V_PWRFL)
433 #define TRAP_FPE (1u << TRAP_V_FPE)
434 #define TRAP_INT (1u << TRAP_V_MAX)
435 #define TRAP_ALL ((1u << TRAP_V_MAX) - 1) /* all traps */
436
437 #define VEC_RED 0004 /* trap vectors */
438 #define VEC_ODD 0004
439 #define VEC_MME 0250
440 #define VEC_NXM 0004
441 #define VEC_PAR 0114
442 #define VEC_PRV 0004
443 #define VEC_ILL 0010
444 #define VEC_BPT 0014
445 #define VEC_IOT 0020
446 #define VEC_EMT 0030
447 #define VEC_TRAP 0034
448 #define VEC_TRC 0014
449 #define VEC_YEL 0004
450 #define VEC_PWRFL 0024
451 #define VEC_FPE 0244
452
453 /* Simulator stop codes; codes 1:TRAP_V_MAX correspond to traps 0:TRAPMAX-1 */
454
455 #define STOP_HALT (TRAP_V_MAX + 1) /* HALT instruction */
456 #define STOP_IBKPT (TRAP_V_MAX + 2) /* instruction bkpt */
457 #define STOP_WAIT (TRAP_V_MAX + 3) /* wait, no events */
458 #define STOP_VECABORT (TRAP_V_MAX + 4) /* abort vector read */
459 #define STOP_SPABORT (TRAP_V_MAX + 5) /* abort trap push */
460 #define STOP_RQ (TRAP_V_MAX + 6) /* RQDX3 panic */
461 #define STOP_SANITY (TRAP_V_MAX + 7) /* sanity timer exp */
462 #define STOP_DTOFF (TRAP_V_MAX + 8) /* DECtape off reel */
463 #define IORETURN(f,v) ((f)? (v): SCPE_OK) /* cond error return */
464
465 /* Timers */
466
467 #define TMR_CLK 0 /* line clock */
468 #define TMR_PCLK 1 /* KW11P */
469
470 /* IO parameters */
471
472 #define DZ_MUXES 4 /* max # of DZ muxes */
473 #define DZ_LINES 8 /* lines per DZ mux */
474 #define VH_MUXES 4 /* max # of VH muxes */
475 #define DLX_LINES 16 /* max # of KL11/DL11's */
476 #define DCX_LINES 16 /* max # of DC11's */
477 #define MT_MAXFR (1 << 16) /* magtape max rec */
478 #define AUTO_LNT 34 /* autoconfig ranks */
479 #define DIB_MAX 100 /* max DIBs */
480
481 #define DEV_V_UBUS (DEV_V_UF + 0) /* Unibus */
482 #define DEV_V_QBUS (DEV_V_UF + 1) /* Qbus */
483 #define DEV_V_Q18 (DEV_V_UF + 2) /* Qbus with <= 256KB */
484 #define DEV_V_FLTA (DEV_V_UF + 3) /* flt addr */
485 #define DEV_V_MBUS (DEV_V_UF + 4) /* Massbus */
486 #define DEV_V_FFUF (DEV_V_UF + 5) /* first free flag */
487 #define DEV_UBUS (1u << DEV_V_UBUS)
488 #define DEV_QBUS (1u << DEV_V_QBUS)
489 #define DEV_Q18 (1u << DEV_V_Q18)
490 #define DEV_FLTA (1u << DEV_V_FLTA)
491 #define DEV_MBUS (1u << DEV_V_MBUS)
492
493 #define DEV_RDX 8 /* default device radix */
494
495 /* Device information block */
496
497 #define VEC_DEVMAX 4 /* max device vec */
498
499 struct pdp_dib {
500 uint32 ba; /* base addr */
501 uint32 lnt; /* length */
502 t_stat (*rd)(int32 *dat, int32 ad, int32 md);
503 t_stat (*wr)(int32 dat, int32 ad, int32 md);
504 int32 vnum; /* vectors: number */
505 int32 vloc; /* locator */
506 int32 vec; /* value */
507 int32 (*ack[VEC_DEVMAX])(void); /* ack routines */
508 };
509
510 typedef struct pdp_dib DIB;
511
512 /* I/O page layout - XUB, RQB,RQC,RQD float based on number of DZ's */
513
514 #define IOBA_DZ (IOPAGEBASE + 000100) /* DZ11 */
515 #define IOLN_DZ 010
516 #define IOBA_XUB (IOPAGEBASE + 000330 + (020 * (DZ_MUXES / 2)))
517 #define IOLN_XUB 010
518 #define IOBA_RQB (IOPAGEBASE + 000334 + (020 * (DZ_MUXES / 2)))
519 #define IOLN_RQB 004
520 #define IOBA_RQC (IOPAGEBASE + IOBA_RQB + IOLN_RQB)
521 #define IOLN_RQC 004
522 #define IOBA_RQD (IOPAGEBASE + IOBA_RQC + IOLN_RQC)
523 #define IOLN_RQD 004
524 #define IOBA_VH (IOPAGEBASE + 000440) /* DHQ11 */
525 #define IOLN_VH 020
526 #define IOBA_UBM (IOPAGEBASE + 010200) /* Unibus map */
527 #define IOLN_UBM (UBM_LNT_LW * sizeof (int32))
528 #define IOBA_KG (IOPAGEBASE + 010700) /* KG11-A */
529 #define IOLN_KG 006
530 #define IOBA_RQ (IOPAGEBASE + 012150) /* RQDX3 */
531 #define IOLN_RQ 004
532 #define IOBA_SUP (IOPAGEBASE + 012200) /* supervisor APR's */
533 #define IOLN_SUP 0100
534 #define IOBA_KIPDR (IOPAGEBASE + 012300) /* kernel APR's */
535 #define IOLN_KIPDR 020
536 #define IOBA_KDPDR (IOPAGEBASE + 012320)
537 #define IOLN_KDPDR 020
538 #define IOBA_KIPAR (IOPAGEBASE + 012340)
539 #define IOLN_KIPAR 020
540 #define IOBA_KDPAR (IOPAGEBASE + 012360)
541 #define IOLN_KDPAR 020
542 #define IOBA_TU (IOPAGEBASE + 012440) /* TU */
543 #define IOLN_TU 040
544 #define IOBA_MMR3 (IOPAGEBASE + 012516) /* MMR3 */
545 #define IOLN_MMR3 002
546 #define IOBA_TM (IOPAGEBASE + 012520) /* TM11 */
547 #define IOLN_TM 014
548 #define IOBA_TS (IOPAGEBASE + 012520) /* TS11 */
549 #define IOLN_TS 004
550 #define IOBA_PCLK (IOPAGEBASE + 012540) /* KW11P */
551 #define IOLN_PCLK 006
552 #define IOBA_DC (IOPAGEBASE + 014000) /* DC11 */
553 #define IOLN_DC (DCX_LINES * 010)
554 #define IOBA_RL (IOPAGEBASE + 014400) /* RL11 */
555 #define IOLN_RL 012
556 #define IOBA_XQ (IOPAGEBASE + 014440) /* DEQNA/DELQA */
557 #define IOLN_XQ 020
558 #define IOBA_XQB (IOPAGEBASE + 014460) /* 2nd DEQNA/DELQA */
559 #define IOLN_XQB 020
560 #define IOBA_TQ (IOPAGEBASE + 014500) /* TMSCP */
561 #define IOLN_TQ 004
562 #define IOBA_XU (IOPAGEBASE + 014510) /* DEUNA/DELUA */
563 #define IOLN_XU 010
564 #define IOBA_DL (IOPAGEBASE + 016500) /* extra KL11/DL11 */
565 #define IOLN_DL (DLX_LINES * 010)
566 #define IOBA_RP (IOPAGEBASE + 016700) /* RP/RM */
567 #define IOLN_RP 054
568 #define IOBA_CR (IOPAGEBASE + 017160) /* CD/CR/CM */
569 #define IOLN_CR 010
570 #define IOBA_RX (IOPAGEBASE + 017170) /* RX11 */
571 #define IOLN_RX 004
572 #define IOBA_RY (IOPAGEBASE + 017170) /* RY11 */
573 #define IOLN_RY 004
574 #define IOBA_KE (IOPAGEBASE + 017300) /* KE11-A */
575 #define IOLN_KE 020
576 #define IOBA_TC (IOPAGEBASE + 017340) /* TC11 */
577 #define IOLN_TC 012
578 #define IOBA_RK (IOPAGEBASE + 017400) /* RK11 */
579 #define IOLN_RK 020
580 #define IOBA_RC (IOPAGEBASE + 017440) /* RC11/RS64 */
581 #define IOLN_RC 020
582 #define IOBA_HK (IOPAGEBASE + 017440) /* RK611 */
583 #define IOLN_HK 040
584 #define IOBA_RF (IOPAGEBASE + 017460) /* RF11 */
585 #define IOLN_RF 020
586 #define IOBA_TA (IOPAGEBASE + 017500) /* TA11 */
587 #define IOLN_TA 004
588 #define IOBA_LPT (IOPAGEBASE + 017514) /* LP11 */
589 #define IOLN_LPT 004
590 #define IOBA_CTL (IOPAGEBASE + 017520) /* board ctrl */
591 #define IOLN_CTL 010
592 #define IOBA_CLK (IOPAGEBASE + 017546) /* KW11L */
593 #define IOLN_CLK 002
594 #define IOBA_PTR (IOPAGEBASE + 017550) /* PC11 reader */
595 #define IOLN_PTR 004
596 #define IOBA_PTP (IOPAGEBASE + 017554) /* PC11 punch */
597 #define IOLN_PTP 004
598 #define IOBA_TTI (IOPAGEBASE + 017560) /* DL11 rcv */
599 #define IOLN_TTI 004
600 #define IOBA_TTO (IOPAGEBASE + 017564) /* DL11 xmt */
601 #define IOLN_TTO 004
602 #define IOBA_SR (IOPAGEBASE + 017570) /* SR */
603 #define IOLN_SR 002
604 #define IOBA_MMR012 (IOPAGEBASE + 017572) /* MMR0-2 */
605 #define IOLN_MMR012 006
606 #define IOBA_UIPDR (IOPAGEBASE + 017600) /* user APR's */
607 #define IOLN_UIPDR 020
608 #define IOBA_UDPDR (IOPAGEBASE + 017620)
609 #define IOLN_UDPDR 020
610 #define IOBA_UIPAR (IOPAGEBASE + 017640)
611 #define IOLN_UIPAR 020
612 #define IOBA_UDPAR (IOPAGEBASE + 017660)
613 #define IOLN_UDPAR 020
614 #define IOBA_GPR (IOPAGEBASE + 017700) /* GPR's */
615 #define IOLN_GPR 010
616 #define IOBA_UCTL (IOPAGEBASE + 017730) /* UBA ctrl */
617 #define IOLN_UCTL 010
618 #define IOBA_CPU (IOPAGEBASE + 017740) /* CPU reg */
619 #define IOLN_CPU 036
620 #define IOBA_PSW (IOPAGEBASE + 017776) /* PSW */
621 #define IOLN_PSW 002
622
623 /* Interrupt assignments; within each level, priority is right to left */
624
625 #define IPL_HLVL 8 /* # int levels */
626
627 #define INT_V_PIR7 0 /* BR7 */
628
629 #define INT_V_CLK 0 /* BR6 */
630 #define INT_V_PCLK 1
631 #define INT_V_DTA 2
632 #define INT_V_TA 3
633 #define INT_V_PIR6 4
634
635 #define INT_V_RK 0 /* BR5 */
636 #define INT_V_RL 1
637 #define INT_V_RX 2
638 #define INT_V_TM 3
639 #define INT_V_RP 4
640 #define INT_V_TS 5
641 #define INT_V_HK 6
642 #define INT_V_RQ 7
643 #define INT_V_DZRX 8
644 #define INT_V_DZTX 9
645 #define INT_V_TQ 10
646 #define INT_V_RY 11
647 #define INT_V_XQ 12
648 #define INT_V_XU 13
649 #define INT_V_TU 14
650 #define INT_V_RF 15
651 #define INT_V_RC 16
652 #define INT_V_PIR5 17
653
654 #define INT_V_TTI 0 /* BR4 */
655 #define INT_V_TTO 1
656 #define INT_V_PTR 2
657 #define INT_V_PTP 3
658 #define INT_V_LPT 4
659 #define INT_V_VHRX 5
660 #define INT_V_VHTX 6
661 #define INT_V_CR 7
662 #define INT_V_DLI 8
663 #define INT_V_DLO 9
664 #define INT_V_DCI 10
665 #define INT_V_DCO 11
666 #define INT_V_PIR4 12
667
668 #define INT_V_PIR3 0 /* BR3 */
669 #define INT_V_PIR2 0 /* BR2 */
670 #define INT_V_PIR1 0 /* BR1 */
671
672 #define INT_PIR7 (1u << INT_V_PIR7)
673 #define INT_CLK (1u << INT_V_CLK)
674 #define INT_PCLK (1u << INT_V_PCLK)
675 #define INT_DTA (1u << INT_V_DTA)
676 #define INT_TA (1u << INT_V_TA)
677 #define INT_PIR6 (1u << INT_V_PIR6)
678 #define INT_RK (1u << INT_V_RK)
679 #define INT_RL (1u << INT_V_RL)
680 #define INT_RX (1u << INT_V_RX)
681 #define INT_TM (1u << INT_V_TM)
682 #define INT_RP (1u << INT_V_RP)
683 #define INT_TS (1u << INT_V_TS)
684 #define INT_HK (1u << INT_V_HK)
685 #define INT_RQ (1u << INT_V_RQ)
686 #define INT_DZRX (1u << INT_V_DZRX)
687 #define INT_DZTX (1u << INT_V_DZTX)
688 #define INT_TQ (1u << INT_V_TQ)
689 #define INT_RY (1u << INT_V_RY)
690 #define INT_XQ (1u << INT_V_XQ)
691 #define INT_XU (1u << INT_V_XU)
692 #define INT_TU (1u << INT_V_TU)
693 #define INT_RF (1u << INT_V_RF)
694 #define INT_RC (1u << INT_V_RC)
695 #define INT_PIR5 (1u << INT_V_PIR5)
696 #define INT_PTR (1u << INT_V_PTR)
697 #define INT_PTP (1u << INT_V_PTP)
698 #define INT_TTI (1u << INT_V_TTI)
699 #define INT_TTO (1u << INT_V_TTO)
700 #define INT_LPT (1u << INT_V_LPT)
701 #define INT_VHRX (1u << INT_V_VHRX)
702 #define INT_VHTX (1u << INT_V_VHTX)
703 #define INT_CR (1u << INT_V_CR)
704 #define INT_DLI (1u << INT_V_DLI)
705 #define INT_DLO (1u << INT_V_DLO)
706 #define INT_DCI (1u << INT_V_DCI)
707 #define INT_DCO (1u << INT_V_DCO)
708 #define INT_PIR4 (1u << INT_V_PIR4)
709 #define INT_PIR3 (1u << INT_V_PIR3)
710 #define INT_PIR2 (1u << INT_V_PIR2)
711 #define INT_PIR1 (1u << INT_V_PIR1)
712
713 #define IPL_CLK 6 /* int pri levels */
714 #define IPL_PCLK 6
715 #define IPL_DTA 6
716 #define IPL_TA 6
717 #define IPL_RK 5
718 #define IPL_RL 5
719 #define IPL_RX 5
720 #define IPL_TM 5
721 #define IPL_RP 5
722 #define IPL_TS 5
723 #define IPL_HK 5
724 #define IPL_RQ 5
725 #define IPL_DZRX 5
726 #define IPL_DZTX 5
727 #define IPL_TQ 5
728 #define IPL_RY 5
729 #define IPL_XQ 5
730 #define IPL_XU 5
731 #define IPL_TU 5
732 #define IPL_RF 5
733 #define IPL_RC 5
734 #define IPL_PTR 4
735 #define IPL_PTP 4
736 #define IPL_TTI 4
737 #define IPL_TTO 4
738 #define IPL_LPT 4
739 #define IPL_VHRX 4
740 #define IPL_VHTX 4
741 #define IPL_CR 4
742 #define IPL_DLI 4
743 #define IPL_DLO 4
744 #define IPL_DCI 4
745 #define IPL_DCO 4
746
747 #define IPL_PIR7 7
748 #define IPL_PIR6 6
749 #define IPL_PIR5 5
750 #define IPL_PIR4 4
751 #define IPL_PIR3 3
752 #define IPL_PIR2 2
753 #define IPL_PIR1 1
754
755 /* Device vectors */
756
757 #define VEC_Q 0000 /* vector base */
758 #define VEC_PIRQ 0240
759 #define VEC_TTI 0060
760 #define VEC_TTO 0064
761 #define VEC_PTR 0070
762 #define VEC_PTP 0074
763 #define VEC_CLK 0100
764 #define VEC_PCLK 0104
765 #define VEC_XQ 0120
766 #define VEC_XU 0120
767 #define VEC_RQ 0154
768 #define VEC_RL 0160
769 #define VEC_LPT 0200
770 #define VEC_RF 0204
771 #define VEC_HK 0210
772 #define VEC_RC 0210
773 #define VEC_RK 0220
774 #define VEC_DTA 0214
775 #define VEC_TM 0224
776 #define VEC_TS 0224
777 #define VEC_TU 0224
778 #define VEC_CR 0230
779 #define VEC_RP 0254
780 #define VEC_TQ 0260
781 #define VEC_TA 0260
782 #define VEC_RX 0264
783 #define VEC_RY 0264
784 #define VEC_DLI 0300
785 #define VEC_DLO 0304
786 #define VEC_DCI 0300
787 #define VEC_DCO 0304
788 #define VEC_DZRX 0300
789 #define VEC_DZTX 0304
790 #define VEC_VHRX 0310
791 #define VEC_VHTX 0314
792
793 /* Interrupt macros */
794
795 #define IVCL(dv) ((IPL_##dv * 32) + INT_V_##dv)
796 #define IREQ(dv) int_req[IPL_##dv]
797 #define SET_INT(dv) int_req[IPL_##dv] = int_req[IPL_##dv] | (INT_##dv)
798 #define CLR_INT(dv) int_req[IPL_##dv] = int_req[IPL_##dv] & ~(INT_##dv)
799
800 /* Massbus definitions */
801
802 #define MBA_NUM 2 /* number of MBA's */
803 #define MBA_RP 0 /* MBA for RP */
804 #define MBA_TU 1 /* MBA for TU */
805 #define MBA_RMASK 037 /* max 32 reg */
806 #define MBE_NXD 1 /* nx drive */
807 #define MBE_NXR 2 /* nx reg */
808 #define MBE_GOE 3 /* err on GO */
809
810 /* CPU and FPU macros */
811
812 #define update_MM ((MMR0 & MMR0_FREEZE) == 0)
813 #define setTRAP(name) trap_req = trap_req | (name)
814 #define setCPUERR(name) CPUERR = CPUERR | (name)
815 #define ABORT(val) longjmp (save_env, (val))
816 #define SP R[6]
817 #define PC R[7]
818
819 /* Function prototypes */
820
821 int32 Map_ReadB (uint32 ba, int32 bc, uint8 *buf);
822 int32 Map_ReadW (uint32 ba, int32 bc, uint16 *buf);
823 int32 Map_WriteB (uint32 ba, int32 bc, uint8 *buf);
824 int32 Map_WriteW (uint32 ba, int32 bc, uint16 *buf);
825
826 t_stat set_addr (UNIT *uptr, int32 val, char *cptr, void *desc);
827 t_stat show_addr (FILE *st, UNIT *uptr, int32 val, void *desc);
828 t_stat set_addr_flt (UNIT *uptr, int32 val, char *cptr, void *desc);
829 t_stat set_vec (UNIT *uptr, int32 val, char *cptr, void *desc);
830 t_stat show_vec (FILE *st, UNIT *uptr, int32 val, void *desc);
831 t_stat auto_config (char *name, int32 nctrl);
832 t_stat build_ubus_tab (DEVICE *dptr, DIB *dibp);
833
834 int32 mba_rdbufW (uint32 mbus, int32 bc, uint16 *buf);
835 int32 mba_wrbufW (uint32 mbus, int32 bc, uint16 *buf);
836 int32 mba_chbufW (uint32 mbus, int32 bc, uint16 *buf);
837 int32 mba_get_bc (uint32 mbus);
838 int32 mba_get_csr (uint32 mbus);
839 void mba_upd_ata (uint32 mbus, uint32 val);
840 void mba_set_exc (uint32 mbus);
841 void mba_set_don (uint32 mbus);
842 void mba_set_enbdis (uint32 mb, t_bool dis);
843 t_stat mba_show_num (FILE *st, UNIT *uptr, int32 val, void *desc);
844
845 int32 clk_cosched (int32 wait);
846
847 #endif