First Commit of my working state
[simh.git] / PDP8 / pdp8_defs.h
1 /* pdp8_defs.h: PDP-8 simulator definitions
2
3 Copyright (c) 1993-2007, 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 21-Aug-07 RMS Added FPP8 support
27 13-Dec-06 RMS Added TA8E support
28 30-Oct-06 RMS Added infinite loop stop
29 13-Oct-03 RMS Added TSC8-75 support
30 04-Oct-02 RMS Added variable device number support
31 20-Jan-02 RMS Fixed bug in TTx interrupt enable initialization
32 25-Nov-01 RMS Added RL8A support
33 16-Sep-01 RMS Added multiple KL support
34 18-Mar-01 RMS Added DF32 support
35 15-Feb-01 RMS Added DECtape support
36 14-Apr-99 RMS Changed t_addr to unsigned
37 19-Mar-95 RMS Added dynamic memory size
38 02-May-94 RMS Added non-existent memory handling
39
40 The author gratefully acknowledges the help of Max Burnet, Richie Lary,
41 and Bill Haygood in resolving questions about the PDP-8
42 */
43
44 #ifndef _PDP8_DEFS_H_
45 #define _PDP8_DEFS_H_ 0
46
47 #include "sim_defs.h" /* simulator defns */
48
49 /* Simulator stop codes */
50
51 #define STOP_RSRV 1 /* must be 1 */
52 #define STOP_HALT 2 /* HALT */
53 #define STOP_IBKPT 3 /* breakpoint */
54 #define STOP_NOTSTD 4 /* non-std devno */
55 #define STOP_DTOFF 5 /* DECtape off reel */
56 #define STOP_LOOP 6 /* infinite loop */
57
58 /* Memory */
59
60 #define MAXMEMSIZE 32768 /* max memory size */
61 #define MEMSIZE (cpu_unit.capac) /* actual memory size */
62 #define ADDRMASK (MAXMEMSIZE - 1) /* address mask */
63 #define MEM_ADDR_OK(x) (((uint32) (x)) < MEMSIZE)
64
65 /* IOT subroutine return codes */
66
67 #define IOT_V_SKP 12 /* skip */
68 #define IOT_V_REASON 13 /* reason */
69 #define IOT_SKP (1 << IOT_V_SKP)
70 #define IOT_REASON (1 << IOT_V_REASON)
71 #define IORETURN(f,v) ((f)? (v): SCPE_OK) /* stop on error */
72
73 /* Timers */
74
75 #define TMR_CLK 0 /* timer 0 = clock */
76 #define TMR_TTX 1 /* timer 1 = TTx */
77
78 /* Device information block */
79
80 #define DEV_MAXBLK 8 /* max dev block */
81 #define DEV_MAX 64 /* total devices */
82
83 typedef struct {
84 uint32 dev; /* base dev number */
85 uint32 num; /* number of slots */
86 int32 (*dsp[DEV_MAXBLK])(int32 IR, int32 dat);
87 } DIB;
88
89 /* Standard device numbers */
90
91 #define DEV_PTR 001 /* paper tape reader */
92 #define DEV_PTP 002 /* paper tape punch */
93 #define DEV_TTI 003 /* console input */
94 #define DEV_TTO 004 /* console output */
95 #define DEV_CLK 013 /* clock */
96 #define DEV_TSC 036
97 #define DEV_KJ8 040 /* extra terminals */
98 #define DEV_FPP 055 /* floating point */
99 #define DEV_DF 060 /* DF32 */
100 #define DEV_RF 060 /* RF08 */
101 #define DEV_RL 060 /* RL8A */
102 #define DEV_LPT 066 /* line printer */
103 #define DEV_MT 070 /* TM8E */
104 #define DEV_CT 070 /* TA8E */
105 #define DEV_RK 074 /* RK8E */
106 #define DEV_RX 075 /* RX8E/RX28 */
107 #define DEV_DTA 076 /* TC08 */
108 #define DEV_TD8E 077 /* TD8E */
109
110 /* Interrupt flags
111
112 The interrupt flags consist of three groups:
113
114 1. Devices with individual interrupt enables. These record
115 their interrupt requests in device_done and their enables
116 in device_enable, and must occupy the low bit positions.
117
118 2. Devices without interrupt enables. These record their
119 interrupt requests directly in int_req, and must occupy
120 the middle bit positions.
121
122 3. Overhead. These exist only in int_req and must occupy the
123 high bit positions.
124
125 Because the PDP-8 does not have priority interrupts, the order
126 of devices within groups does not matter.
127
128 Note: all extra KL input and output interrupts must be assigned
129 to contiguous bits.
130 */
131
132 #define INT_V_START 0 /* enable start */
133 #define INT_V_LPT (INT_V_START+0) /* line printer */
134 #define INT_V_PTP (INT_V_START+1) /* tape punch */
135 #define INT_V_PTR (INT_V_START+2) /* tape reader */
136 #define INT_V_TTO (INT_V_START+3) /* terminal */
137 #define INT_V_TTI (INT_V_START+4) /* keyboard */
138 #define INT_V_CLK (INT_V_START+5) /* clock */
139 #define INT_V_TTO1 (INT_V_START+6) /* tto1 */
140 #define INT_V_TTO2 (INT_V_START+7) /* tto2 */
141 #define INT_V_TTO3 (INT_V_START+8) /* tto3 */
142 #define INT_V_TTO4 (INT_V_START+9) /* tto4 */
143 #define INT_V_TTI1 (INT_V_START+10) /* tti1 */
144 #define INT_V_TTI2 (INT_V_START+11) /* tti2 */
145 #define INT_V_TTI3 (INT_V_START+12) /* tti3 */
146 #define INT_V_TTI4 (INT_V_START+13) /* tti4 */
147 #define INT_V_DIRECT (INT_V_START+14) /* direct start */
148 #define INT_V_RX (INT_V_DIRECT+0) /* RX8E */
149 #define INT_V_RK (INT_V_DIRECT+1) /* RK8E */
150 #define INT_V_RF (INT_V_DIRECT+2) /* RF08 */
151 #define INT_V_DF (INT_V_DIRECT+3) /* DF32 */
152 #define INT_V_MT (INT_V_DIRECT+4) /* TM8E */
153 #define INT_V_DTA (INT_V_DIRECT+5) /* TC08 */
154 #define INT_V_RL (INT_V_DIRECT+6) /* RL8A */
155 #define INT_V_CT (INT_V_DIRECT+7) /* TA8E int */
156 #define INT_V_PWR (INT_V_DIRECT+8) /* power int */
157 #define INT_V_UF (INT_V_DIRECT+9) /* user int */
158 #define INT_V_TSC (INT_V_DIRECT+10) /* TSC8-75 int */
159 #define INT_V_FPP (INT_V_DIRECT+11) /* FPP8 */
160 #define INT_V_OVHD (INT_V_DIRECT+12) /* overhead start */
161 #define INT_V_NO_ION_PENDING (INT_V_OVHD+0) /* ion pending */
162 #define INT_V_NO_CIF_PENDING (INT_V_OVHD+1) /* cif pending */
163 #define INT_V_ION (INT_V_OVHD+2) /* interrupts on */
164
165 #define INT_LPT (1 << INT_V_LPT)
166 #define INT_PTP (1 << INT_V_PTP)
167 #define INT_PTR (1 << INT_V_PTR)
168 #define INT_TTO (1 << INT_V_TTO)
169 #define INT_TTI (1 << INT_V_TTI)
170 #define INT_CLK (1 << INT_V_CLK)
171 #define INT_TTO1 (1 << INT_V_TTO1)
172 #define INT_TTO2 (1 << INT_V_TTO2)
173 #define INT_TTO3 (1 << INT_V_TTO3)
174 #define INT_TTO4 (1 << INT_V_TTO4)
175 #define INT_TTI1 (1 << INT_V_TTI1)
176 #define INT_TTI2 (1 << INT_V_TTI2)
177 #define INT_TTI3 (1 << INT_V_TTI3)
178 #define INT_TTI4 (1 << INT_V_TTI4)
179 #define INT_RX (1 << INT_V_RX)
180 #define INT_RK (1 << INT_V_RK)
181 #define INT_RF (1 << INT_V_RF)
182 #define INT_DF (1 << INT_V_DF)
183 #define INT_MT (1 << INT_V_MT)
184 #define INT_DTA (1 << INT_V_DTA)
185 #define INT_RL (1 << INT_V_RL)
186 #define INT_CT (1 << INT_V_CT)
187 #define INT_PWR (1 << INT_V_PWR)
188 #define INT_UF (1 << INT_V_UF)
189 #define INT_TSC (1 << INT_V_TSC)
190 #define INT_FPP (1 << INT_V_FPP)
191 #define INT_NO_ION_PENDING (1 << INT_V_NO_ION_PENDING)
192 #define INT_NO_CIF_PENDING (1 << INT_V_NO_CIF_PENDING)
193 #define INT_ION (1 << INT_V_ION)
194 #define INT_DEV_ENABLE ((1 << INT_V_DIRECT) - 1) /* devices w/enables */
195 #define INT_ALL ((1 << INT_V_OVHD) - 1) /* all interrupts */
196 #define INT_INIT_ENABLE (INT_TTI+INT_TTO+INT_PTR+INT_PTP+INT_LPT) | \
197 (INT_TTI1+INT_TTI2+INT_TTI3+INT_TTI4) | \
198 (INT_TTO1+INT_TTO2+INT_TTO3+INT_TTO4)
199 #define INT_PENDING (INT_ION+INT_NO_CIF_PENDING+INT_NO_ION_PENDING)
200 #define INT_UPDATE ((int_req & ~INT_DEV_ENABLE) | (dev_done & int_enable))
201
202 /* Function prototypes */
203
204 t_stat set_dev (UNIT *uptr, int32 val, char *cptr, void *desc);
205 t_stat show_dev (FILE *st, UNIT *uptr, int32 val, void *desc);
206
207 #endif