First Commit of my working state
[simh.git] / NOVA / nova_defs.h
1 /* nova_defs.h: NOVA/Eclipse 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 04-Jul-07 BKR BUSY/DONE/INTR "convenience" macros added,
27 INT_TRAP added for Nova 3, 4 trap instruction handling,
28 support for 3rd-party 64KW Nova extensions added,
29 removed STOP_IND_TRP definition due to common INT/TRP handling
30 14-Jan-04 BKR Added support for QTY and ALM
31 22-Nov-03 CEO Added support for PIT device
32 19-Jan-03 RMS Changed CMASK to CDMASK for Apple Dev kit conflict
33 03-Oct-02 RMS Added device information structure
34 22-Dec-00 RMS Added Bruce Ray's second terminal support
35 10-Dec-00 RMS Added Charles Owen's Eclipse support
36 08-Dec-00 RMS Added Bruce Ray's plotter support
37 15-Oct-00 RMS Added stack, byte, trap instructions
38 14-Apr-99 RMS Changed t_addr to unsigned
39 16-Mar-95 RMS Added dynamic memory size
40 06-Dec-95 RMS Added magnetic tape
41
42 The author gratefully acknowledges the help of Tom West, Diana Englebart,
43 Carl Friend, Bruce Ray, and Charles Owen in resolving questions about
44 the NOVA.
45 */
46
47 #ifndef _NOVA_DEFS_H_
48 #define _NOVA_DEFS_H_ 0
49
50 #include "sim_defs.h" /* simulator defns */
51
52 /* Simulator stop codes */
53
54 #define STOP_RSRV 1 /* must be 1 */
55 #define STOP_HALT 2 /* HALT */
56 #define STOP_IBKPT 3 /* breakpoint */
57 #define STOP_IND 4 /* indirect loop */
58 #define STOP_IND_INT 5 /* ind loop, intr or trap */
59
60
61 /* Memory */
62
63 #if defined (ECLIPSE)
64 /*----------------------*/
65 /* Eclipse */
66 /*----------------------*/
67
68 #define MAXMEMSIZE 1048576 /* max memory size in 16-bit words */
69 #define PAMASK (MAXMEMSIZE - 1) /* physical addr mask */
70 #define MEM_ADDR_OK(x) (((uint32) (x)) < (uint32) MEMSIZE)
71
72 #else
73 /*----------------------*/
74 /* Nova */
75 /*----------------------*/
76
77 #define MAXMEMSIZE 65536 /* max memory size in 16-bit words: 32KW = DG max, */
78 /* 64 KW = 3rd-party extended memory feature */
79 #define DFTMEMSIZE 32768 /* default/initial mem size */
80 #define MEM_ADDR_OK(x) (((uint32) (x)) < (uint32) MEMSIZE)
81
82 #endif
83
84
85 #define MEMSIZE (cpu_unit.capac) /* actual memory size */
86 #define A_V_IND 15 /* ind: indirect */
87 #define A_IND (1 << A_V_IND)
88
89 /* Architectural constants */
90
91 #define SIGN 0100000 /* sign */
92 #define DMASK 0177777 /* data mask */
93 #define CBIT (DMASK + 1) /* carry bit */
94 #define CDMASK (CBIT | DMASK) /* carry + data */
95
96 /* Reserved memory locations */
97
98 #define INT_SAV 0 /* intr saved PC */
99 #define INT_JMP 1 /* intr jmp @ */
100 #define STK_JMP 3 /* stack jmp @ */
101 #define TRP_SAV 046 /* trap saved PC */
102 #define TRP_JMP 047 /* trap jmp @ */
103
104 #define AUTO_TOP 037 /* top of autoindex */
105 #define AUTO_DEC 030 /* start autodec */
106 #define AUTO_INC 020 /* start autoinc */
107
108
109 /* Instruction format */
110
111 #define I_OPR 0100000 /* operate */
112 #define I_M_SRC 03 /* OPR: src AC */
113 #define I_V_SRC 13
114 #define I_GETSRC(x) (((x) >> I_V_SRC) & I_M_SRC)
115 #define I_M_DST 03 /* dst AC */
116 #define I_V_DST 11
117 #define I_GETDST(x) (((x) >> I_V_DST) & I_M_DST)
118 #define I_M_ALU 07 /* OPR: ALU op */
119 #define I_V_ALU 8
120 #define I_GETALU(x) (((x) >> I_V_ALU) & I_M_ALU)
121 #define I_M_SHF 03 /* OPR: shift */
122 #define I_V_SHF 6
123 #define I_GETSHF(x) (((x) >> I_V_SHF) & I_M_SHF)
124 #define I_M_CRY 03 /* OPR: carry */
125 #define I_V_CRY 4
126 #define I_GETCRY(x) (((x) >> I_V_CRY) & I_M_CRY)
127 #define I_V_NLD 3 /* OPR: no load */
128 #define I_NLD (1 << I_V_NLD)
129 #define I_M_SKP 07 /* OPR: skip */
130 #define I_V_SKP 0
131 #define I_GETSKP(x) (((x) >> I_V_SKP) & I_M_SKP)
132
133 #define I_M_OPAC 017 /* MRF: opcode + AC */
134 #define I_V_OPAC 11
135 #define I_GETOPAC(x) (((x) >> I_V_OPAC) & I_M_OPAC)
136 #define I_V_IND 10 /* MRF: indirect */
137 #define I_IND (1 << I_V_IND)
138 #define I_M_MODE 03 /* MRF: mode */
139 #define I_V_MODE 8
140 #define I_GETMODE(x) (((x) >> I_V_MODE) & I_M_MODE)
141 #define I_M_DISP 0377 /* MRF: disp */
142 #define I_V_DISP 0
143 #define I_GETDISP(x) (((x) >> I_V_DISP) & I_M_DISP)
144 #define DISPSIZE (I_M_DISP + 1) /* page size */
145 #define DISPSIGN (DISPSIZE >> 1) /* page sign */
146
147 #define I_M_IOT 07 /* IOT: code */
148 #define I_V_IOT 8
149 #define I_GETIOT(x) (((x) >> I_V_IOT) & I_M_IOT)
150 #define I_M_PULSE 03 /* IOT pulse */
151 #define I_V_PULSE 6
152 #define I_GETPULSE(x) (((x) >> I_V_PULSE) & I_M_PULSE)
153 #define I_M_DEV 077 /* IOT: device */
154 #define I_V_DEV 0
155 #define I_GETDEV(x) (((x) >> I_V_DEV) & I_M_DEV)
156
157 #define I_M_XOP 037 /* XOP: code */
158 #define I_V_XOP 6
159 #define I_GETXOP(x) (((x) >> I_V_XOP) & I_M_XOP)
160
161 /* IOT return codes */
162
163 #define IOT_V_REASON 16 /* set reason */
164 #define IORETURN(f,v) ((f)? (v): SCPE_OK) /* stop on error */
165
166 /* IOT fields */
167
168 #define ioNIO 0 /* opcode field */
169 #define ioDIA 1
170 #define ioDOA 2
171 #define ioDIB 3
172 #define ioDOB 4
173 #define ioDIC 5
174 #define ioDOC 6
175 #define ioSKP 7
176
177 #define iopN 0 /* pulse field */
178 #define iopS 1
179 #define iopC 2
180 #define iopP 3
181
182 /* Device numbers */
183
184 #define DEV_LOW 010 /* lowest intr dev */
185 #define DEV_HIGH 051 /* highest intr dev */
186 #define DEV_MDV 001 /* multiply/divide */
187 #define DEV_ECC 002 /* ECC memory control */
188 #define DEV_MAP 003 /* MMPU control */
189 #define DEV_TTI 010 /* console input */
190 #define DEV_TTO 011 /* console output */
191 #define DEV_PTR 012 /* paper tape reader */
192 #define DEV_PTP 013 /* paper tape punch */
193 #define DEV_CLK 014 /* clock */
194 #define DEV_PLT 015 /* plotter */
195 #define DEV_CDR 016 /* card reader */
196 #define DEV_LPT 017 /* line printer */
197 #define DEV_DSK 020 /* fixed head disk */
198 #define DEV_MTA 022 /* magtape */
199 #define DEV_DCM 024 /* data comm mux */
200 #define DEV_ADCV 030 /* A/D converter */
201 #define DEV_QTY 030 /* 4060 multiplexor */
202 #define DEV_DKP 033 /* disk pack */
203 #define DEV_CAS 034 /* cassette */
204 #define DEV_ALM 034 /* ALM/ULM multiplexor */
205 #define DEV_PIT 043 /* programmable interval timer */
206 #define DEV_TTI1 050 /* second console input */
207 #define DEV_TTO1 051 /* second console output */
208 #define DEV_CPU 077 /* CPU control */
209
210 /* I/O structure
211
212 The NOVA I/O structure is tied together by dev_table, indexed by
213 the device number. Each entry in dev_table consists of
214
215 mask device mask for busy, done (simulator representation)
216 pi pi disable bit (hardware representation)
217 routine IOT action routine
218
219 dev_table is populated at run time from the device information
220 blocks in each device.
221 */
222
223 struct ndev {
224 int32 mask; /* done/busy mask */
225 int32 pi; /* assigned pi bit */
226 int32 (*routine)(); /* dispatch routine */
227 };
228
229 typedef struct {
230 int32 dnum; /* device number */
231 int32 mask; /* done/busy mask */
232 int32 pi; /* assigned pi bit */
233 int32 (*routine)(); /* dispatch routine */
234 } DIB;
235
236 /* Device flags (simulator representation)
237
238 Priority (for INTA) runs from low numbers to high
239 */
240
241 #define INT_V_PIT 2 /* PIT */
242 #define INT_V_DKP 3 /* moving head disk */
243 #define INT_V_DSK 4 /* fixed head disk */
244 #define INT_V_MTA 5 /* magnetic tape */
245 #define INT_V_LPT 6 /* line printer */
246 #define INT_V_CLK 7 /* clock */
247 #define INT_V_PTR 8 /* paper tape reader */
248 #define INT_V_PTP 9 /* paper tape punch */
249 #define INT_V_PLT 10 /* plotter */
250 #define INT_V_TTI 11 /* keyboard */
251 #define INT_V_TTO 12 /* terminal */
252 #define INT_V_TTI1 13 /* second keyboard */
253 #define INT_V_TTO1 14 /* second terminal */
254 #define INT_V_QTY 15 /* QTY multiplexor */
255 #define INT_V_ALM 16 /* ALM multiplexor */
256 #define INT_V_STK 17 /* stack overflow */
257 #define INT_V_NO_ION_PENDING 18 /* ion delay */
258 #define INT_V_ION 19 /* interrupts on */
259 #define INT_V_TRAP 20 /* trap instruction */
260
261 #define INT_PIT (1 << INT_V_PIT)
262 #define INT_DKP (1 << INT_V_DKP)
263 #define INT_DSK (1 << INT_V_DSK)
264 #define INT_MTA (1 << INT_V_MTA)
265 #define INT_LPT (1 << INT_V_LPT)
266 #define INT_CLK (1 << INT_V_CLK)
267 #define INT_PTR (1 << INT_V_PTR)
268 #define INT_PTP (1 << INT_V_PTP)
269 #define INT_PLT (1 << INT_V_PLT)
270 #define INT_TTI (1 << INT_V_TTI)
271 #define INT_TTO (1 << INT_V_TTO)
272 #define INT_TTI1 (1 << INT_V_TTI1)
273 #define INT_TTO1 (1 << INT_V_TTO1)
274 #define INT_QTY (1 << INT_V_QTY)
275 #define INT_ALM (1 << INT_V_ALM)
276 #define INT_STK (1 << INT_V_STK)
277 #define INT_NO_ION_PENDING (1 << INT_V_NO_ION_PENDING)
278 #define INT_ION (1 << INT_V_ION)
279 #define INT_DEV ((1 << INT_V_STK) - 1) /* device ints */
280 #define INT_PENDING INT_ION+INT_NO_ION_PENDING
281 #define INT_TRAP (1 << INT_V_TRAP)
282
283 /* PI disable bits */
284
285 #define PI_PIT 0001000
286 #define PI_DKP 0000400
287 #define PI_DSK 0000100
288 #define PI_MTA 0000040
289 #define PI_LPT 0000010
290 #define PI_CLK 0000004
291 #define PI_PTR 0000020
292 #define PI_PTP 0000004
293 #define PI_PLT 0000010
294 #define PI_QTY 0000002
295 #define PI_ALM 0000002
296 #define PI_TTI 0000002
297 #define PI_TTO 0000001
298 #define PI_TTI1 PI_TTI
299 #define PI_TTO1 PI_TTO
300 /* #define PI_CDR 0000040 */
301 /* #define PI_DCM 0100000 */
302 /* #define PI_CAS 0000040 */
303 /* #define PI_ADCV 0000002 */
304
305
306 /* Macros to clear/set BUSY/DONE/INTR bits */
307
308 #define DEV_SET_BUSY( x ) dev_busy = dev_busy | (x)
309 #define DEV_CLR_BUSY( x ) dev_busy = dev_busy & (~(x))
310 #define DEV_SET_DONE( x ) dev_done = dev_done | (x)
311 #define DEV_CLR_DONE( x ) dev_done = dev_done & (~(x))
312 #define DEV_UPDATE_INTR int_req = (int_req & ~INT_DEV) | (dev_done & ~dev_disable)
313
314 #define DEV_IS_BUSY( x ) (dev_busy & (x))
315 #define DEV_IS_DONE( x ) (dev_done & (x))
316
317 /* Function prototypes */
318
319 int32 MapAddr (int32 map, int32 addr);
320 t_stat set_enb (UNIT *uptr, int32 val, char *cptr, void *desc);
321 t_stat set_dsb (UNIT *uptr, int32 val, char *cptr, void *desc);
322
323 #endif