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