~ubuntu-branches/ubuntu/utopic/simh/utopic

« back to all changes in this revision

Viewing changes to HP2100/hp2100_defs.h

  • Committer: Bazaar Package Importer
  • Author(s): Vince Mulhollon
  • Date: 2004-04-20 20:01:26 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040420200126-ehsuleda8xcgi51h
Tags: 3.2.0-1
New upstream 3.2.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* hp2100_defs.h: HP 2100 simulator definitions
 
2
 
 
3
   Copyright (c) 1993-2004, 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
 
23
   be 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-Apr-03    RMS     Revised for extended file support
 
27
   24-Oct-02    RMS     Added indirect address interrupt
 
28
   08-Feb-02    RMS     Added DMS definitions
 
29
   01-Feb-02    RMS     Added terminal multiplexor support
 
30
   16-Jan-02    RMS     Added additional device support
 
31
   30-Nov-01    RMS     Added extended SET/SHOW support
 
32
   15-Oct-00    RMS     Added dynamic device numbers
 
33
   14-Apr-99    RMS     Changed t_addr to unsigned
 
34
 
 
35
   The author gratefully acknowledges the help of Jeff Moffat in answering
 
36
   questions about the HP2100.
 
37
*/
 
38
 
 
39
#include "sim_defs.h"                                   /* simulator defns */
 
40
 
 
41
/* Simulator stop codes */
 
42
 
 
43
#define STOP_RSRV       1                               /* must be 1 */
 
44
#define STOP_IODV       2                               /* must be 2 */
 
45
#define STOP_HALT       3                               /* HALT */
 
46
#define STOP_IBKPT      4                               /* breakpoint */
 
47
#define STOP_IND        5                               /* indirect loop */
 
48
#define STOP_INDINT     6                               /* indirect intr */
 
49
#define STOP_NOCONN     7                               /* no connection */
 
50
 
 
51
#define ABORT_PRO       1                               /* protection abort */
 
52
 
 
53
/* Memory */
 
54
 
 
55
#define MEMSIZE         (cpu_unit.capac)                /* actual memory size */
 
56
#define MEM_ADDR_OK(x)  (((uint32) (x)) < MEMSIZE)
 
57
#define VA_N_SIZE       15                              /* virtual addr size */
 
58
#define VASIZE          (1 << VA_N_SIZE)
 
59
#define VAMASK          (VASIZE - 1)                    /* virt addr mask */
 
60
#define PA_N_SIZE       20                              /* phys addr size */
 
61
#define PASIZE          (1 << PA_N_SIZE)
 
62
#define PAMASK          (PASIZE - 1)                    /* phys addr mask */
 
63
 
 
64
/* Architectural constants */
 
65
 
 
66
#define SIGN32          020000000000                    /* 32b sign */
 
67
#define SIGN            0100000                         /* 16b sign */
 
68
#define DMASK           0177777                         /* 16b data mask */
 
69
#define AR              M[0]                            /* A = location 0 */
 
70
#define BR              M[1]                            /* B = location 1 */
 
71
#define ABREG           M                               /* register array */
 
72
#define SEXT(x)         ((int32) (((x) & SIGN)? ((x) | ~DMASK): ((x) & DMASK)))
 
73
 
 
74
/* Memory reference instructions */
 
75
 
 
76
#define I_IA            0100000                         /* indirect address */
 
77
#define I_AB            0004000                         /* A/B select */
 
78
#define I_CP            0002000                         /* current page */
 
79
#define I_DISP          0001777                         /* page displacement */
 
80
#define I_PAGENO        0076000                         /* page number */
 
81
 
 
82
/* Other instructions */
 
83
 
 
84
#define I_NMRMASK       0102000                         /* non-mrf opcode */
 
85
#define I_SRG           0000000                         /* shift */
 
86
#define I_ASKP          0002000                         /* alter/skip */
 
87
#define I_EXTD          0100000                         /* extend */
 
88
#define I_IO            0102000                         /* I/O */
 
89
#define I_CTL           0004000                         /* CTL on/off */
 
90
#define I_HC            0001000                         /* hold/clear */
 
91
#define I_DEVMASK       0000077                         /* device mask */
 
92
#define I_GETIOOP(x)    (((x) >> 6) & 07)               /* I/O sub op */
 
93
 
 
94
/* DMA channels */
 
95
 
 
96
#define DMA1_STC        0100000                         /* DMA - issue STC */
 
97
#define DMA1_CLC        0020000                         /* DMA - issue CLC */
 
98
#define DMA2_OI         0100000                         /* DMA - output/input */
 
99
 
 
100
struct DMA {                                            /* DMA channel */
 
101
        int32   cw1;                                    /* device select */
 
102
        int32   cw2;                                    /* direction, address */
 
103
        int32   cw3;                                    /* word count */
 
104
};
 
105
 
 
106
/* Memory management */
 
107
 
 
108
#define VA_N_OFF        10                              /* offset width */
 
109
#define VA_M_OFF        ((1 << VA_N_OFF) - 1)           /* offset mask */
 
110
#define VA_GETOFF(x)    ((x) & VA_M_OFF)
 
111
#define VA_N_PAG        (VA_N_SIZE - VA_N_OFF)          /* page width */
 
112
#define VA_V_PAG        (VA_N_OFF)
 
113
#define VA_M_PAG        ((1 << VA_N_PAG) - 1)
 
114
#define VA_GETPAG(x)    (((x) >> VA_V_PAG) & VA_M_PAG)
 
115
 
 
116
/* Maps */
 
117
 
 
118
#define MAP_NUM         4                               /* num maps */
 
119
#define MAP_LNT         (1 << VA_N_PAG)                 /* map length */
 
120
#define MAP_MASK        ((MAP_NUM * MAP_LNT) - 1)
 
121
#define SMAP            0                               /* system map */
 
122
#define UMAP            (SMAP + MAP_LNT)                /* user map */
 
123
#define PAMAP           (UMAP + MAP_LNT)                /* port A map */
 
124
#define PBMAP           (PAMAP + MAP_LNT)               /* port B map */
 
125
 
 
126
/* Map entries are left shifted by VA_N_OFF, flags in lower 2b */
 
127
 
 
128
#define PA_N_PAG        (PA_N_SIZE - VA_N_OFF)          /* page width */
 
129
#define PA_V_PAG        (VA_N_OFF)
 
130
#define PA_M_PAG        ((1 << PA_N_PAG) - 1)
 
131
#define MAPM_V_RPR      15                              /* in mem: read prot */
 
132
#define MAPM_V_WPR      14                              /* write prot */
 
133
#define MAPA_V_RPR      1                               /* in array: */
 
134
#define MAPA_V_WPR      0
 
135
#define PA_GETPAG(x)    ((x) & (PA_M_PAG << VA_V_PAG))
 
136
#define RD              (1 << MAPA_V_RPR)
 
137
#define WR              (1 << MAPA_V_WPR)
 
138
 
 
139
/* Map status register */
 
140
 
 
141
#define MST_ENBI        0100000                         /* mem enb @ int */
 
142
#define MST_UMPI        0040000                         /* usr map @ int */
 
143
#define MST_ENB         0020000                         /* mem enb */
 
144
#define MST_UMP         0010000                         /* usr map */
 
145
#define MST_PRO         0004000                         /* protection */
 
146
#define MST_FLT         0002000                         /* fence comp */
 
147
#define MST_FENCE       0001777                         /* base page fence */
 
148
 
 
149
/* Map violation register */
 
150
 
 
151
#define MVI_V_RPR       15
 
152
#define MVI_V_WPR       14
 
153
#define MVI_RPR         (1 << MVI_V_RPR)                /* rd viol */
 
154
#define MVI_WPR         (1 << MVI_V_WPR)                /* wr viol */
 
155
#define MVI_BPG         0020000                         /* base page viol */
 
156
#define MVI_PRV         0010000                         /* priv viol */
 
157
#define MVI_MEB         0000200                         /* me bus enb @ viol */
 
158
#define MVI_MEM         0000100                         /* mem enb @ viol */
 
159
#define MVI_UMP         0000040                         /* usr map @ viol */
 
160
#define MVI_PAG         0000037                         /* pag sel */
 
161
 
 
162
/* Timers */
 
163
 
 
164
#define TMR_CLK         0                               /* clock */
 
165
#define TMR_MUX         1                               /* multiplexor */
 
166
 
 
167
/* I/O sub-opcodes */
 
168
 
 
169
#define ioHLT           0                               /* halt */
 
170
#define ioFLG           1                               /* set/clear flag */
 
171
#define ioSFC           2                               /* skip on flag clear */
 
172
#define ioSFS           3                               /* skip on flag set */
 
173
#define ioMIX           4                               /* merge into A/B */
 
174
#define ioLIX           5                               /* load into A/B */
 
175
#define ioOTX           6                               /* output from A/B */
 
176
#define ioCTL           7                               /* set/clear control */
 
177
 
 
178
/* I/O devices - fixed assignments */
 
179
 
 
180
#define CPU             000                             /* interrupt control */
 
181
#define OVF             001                             /* overflow */
 
182
#define DMALT0          002                             /* DMA 0 alternate */
 
183
#define DMALT1          003                             /* DMA 1 alternate */
 
184
#define PWR             004                             /* power fail */
 
185
#define PRO             005                             /* parity/mem protect */
 
186
#define DMA0            006                             /* DMA channel 0 */
 
187
#define DMA1            007                             /* DMA channel 1 */
 
188
#define VARDEV          (DMA1 + 1)                      /* start of var assign */
 
189
#define M_NXDEV         (INT_M (CPU) | INT_M (OVF) | \
 
190
                         INT_M (DMALT0) | INT_M (DMALT1))
 
191
#define M_FXDEV         (M_NXDEV | INT_M (PWR) | INT_M (PRO) | \
 
192
                         INT_M (DMA0) | INT_M (DMA1))
 
193
 
 
194
/* I/O devices - variable assignment defaults */
 
195
 
 
196
#define PTR             010                             /* paper tape reader */
 
197
#define TTY             011                             /* console */
 
198
#define PTP             012                             /* paper tape punch */
 
199
#define CLK             013                             /* clock */
 
200
#define LPS             014                             /* 12653 line printer */
 
201
#define LPT             015                             /* 12845 line printer */
 
202
#define MTD             020                             /* 12559A data */
 
203
#define MTC             021                             /* 12559A control */
 
204
#define DPD             022                             /* 12557A data */
 
205
#define DPC             023                             /* 12557A control */
 
206
#define DQD             024                             /* 12565A data */
 
207
#define DQC             025                             /* 12565A control */
 
208
#define DRD             026                             /* 12610A data */
 
209
#define DRC             027                             /* 12610A control */
 
210
#define MSD             030                             /* 13181A data */
 
211
#define MSC             031                             /* 13181A control */
 
212
#define IPLI            032                             /* 12556B link in */
 
213
#define IPLO            033                             /* 12556B link out */
 
214
#define MUXL            040                             /* 12920A lower data */
 
215
#define MUXU            041                             /* 12920A upper data */
 
216
#define MUXC            042                             /* 12920A control */
 
217
 
 
218
/* IBL assignments */
 
219
 
 
220
#define IBL_PTR         0000000                         /* PTR */
 
221
#define IBL_DP          0040000                         /* DP */
 
222
#define IBL_DQ          0060000                         /* DQ */
 
223
#define IBL_MS          0100000                         /* MS */
 
224
#define IBL_TBD         0140000                         /* tbd */
 
225
#define IBL_V_DEV       6                               /* dev in <11:6> */
 
226
#define IBL_FIX         0000001                         /* DP fixed */
 
227
#define IBL_LNT         64                              /* boot length */
 
228
#define IBL_MASK        (IBL_LNT - 1)                   /* boot length mask */
 
229
 
 
230
/* Dynamic device information table */
 
231
 
 
232
struct hp_dib {
 
233
        int32   devno;                                  /* device number */
 
234
        int32   cmd;                                    /* saved command */
 
235
        int32   ctl;                                    /* saved control */
 
236
        int32   flg;                                    /* saved flag */
 
237
        int32   fbf;                                    /* saved flag buf */
 
238
        int32   (*iot)();                               /* I/O routine */
 
239
};
 
240
 
 
241
typedef struct hp_dib DIB;
 
242
 
 
243
/* I/O macros */
 
244
 
 
245
#define INT_V(x)        ((x) & 037)                     /* device bit pos */
 
246
#define INT_M(x)        (1u << INT_V (x))               /* device bit mask */
 
247
#define setCMD(D)       dev_cmd[(D)/32] = dev_cmd[(D)/32] | INT_M ((D))
 
248
#define clrCMD(D)       dev_cmd[(D)/32] = dev_cmd[(D)/32] & ~INT_M (D)
 
249
#define setCTL(D)       dev_ctl[(D)/32] = dev_ctl[(D)/32] | INT_M ((D))
 
250
#define clrCTL(D)       dev_ctl[(D)/32] = dev_ctl[(D)/32] & ~INT_M (D)
 
251
#define setFBF(D)       dev_fbf[(D)/32] = dev_fbf[(D)/32] | INT_M (D)
 
252
#define clrFBF(D)       dev_fbf[(D)/32] = dev_fbf[(D)/32] & ~INT_M (D)
 
253
#define setFLG(D)       dev_flg[(D)/32] = dev_flg[(D)/32] | INT_M (D); \
 
254
                        setFBF(D)
 
255
#define clrFLG(D)       dev_flg[(D)/32] = dev_flg[(D)/32] & ~INT_M (D); \
 
256
                        clrFBF(D)
 
257
#define CMD(D)          ((dev_cmd[(D)/32] >> INT_V (D)) & 1)
 
258
#define CTL(D)          ((dev_ctl[(D)/32] >> INT_V (D)) & 1)
 
259
#define FLG(D)          ((dev_flg[(D)/32] >> INT_V (D)) & 1)
 
260
#define FBF(D)          ((dev_fbf[(D)/32] >> INT_V (D)) & 1)
 
261
 
 
262
#define IOT_V_REASON    16
 
263
#define IORETURN(f,v)   ((f)? (v): SCPE_OK)             /* stop on error */
 
264
 
 
265
/* Function prototypes */
 
266
 
 
267
t_stat hp_setdev (UNIT *uptr, int32 val, char *cptr, void *desc);
 
268
t_stat hp_showdev (FILE *st, UNIT *uptr, int32 val, void *desc);
 
269
void hp_enbdis_pair (DEVICE *ccp, DEVICE *dcp);