forked from CeRiAl/Xhomer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpro_reg.c
392 lines (334 loc) · 7.71 KB
/
pro_reg.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
/* pro_reg.c: General PRO registers
Copyright (c) 1997-2003, Tarik Isani (xhomer@isani.org)
This file is part of Xhomer.
Xhomer is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation.
Xhomer is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Xhomer; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifdef PRO
#include "pdp11_defs.h"
#include "sim_defs.h" /* For sim_gtime() */
extern int PC; /* from pdp11_cpu */
int pro_led;
int pro_csr;
#ifndef BUILTIN_ROMS
unsigned short ROM[8192];
unsigned short IDROM[32];
#else
#include "id.h"
#include "pro350.h"
#endif
unsigned short BATRAM[50];
/* pro_rom.c: PRO 16KB Boot/diagnostic ROM, I/O address 17730000-17767777 */
int rom_rd (int *data, int pa, int access)
{
*data = ROM[(pa-017730000) >> 1];
return SCPE_OK;
}
int rom_wr (int data, int pa, int access)
{
return SCPE_NXM; /* ??? invalid access */
}
/* Standard I/O dispatch routine, many addresses */
int reg_rd (int *data, int pa, int access)
{
#ifdef IOTRACE
if (iotfptr)
{
fprintf(iotfptr, "%10.0lf ",sim_gtime());
fprintf(iotfptr, "%6o ",PC);
}
#endif
if ((pa>=017773600) && (pa<=017773677)) /* ID PROM */
*data = IDROM[(pa-017773600) >> 1];
else if ((pa>=017773034) && (pa<=017773177)) /* Battery backed RAM */
*data = BATRAM[(pa-017773034) >> 1];
else if ((pa>=017773200) && (pa<=017773213)) /* Int controllers */
*data = pro_int_rd(pa);
else
switch (pa & 017777776)
{
case 017773000:
case 017773002:
case 017773004:
case 017773006:
case 017773010:
case 017773012:
case 017773014:
case 017773016:
case 017773020:
case 017773022:
case 017773024:
case 017773026:
case 017773030:
case 017773032:
*data = pro_clk_rd(pa); /* clock */
break;
case 017773300:
case 017773302:
case 017773304:
case 017773306:
case 017773310:
case 017773312:
case 017773314:
*data = pro_com_rd(pa); /* communication port */
break;
case 017773400:
case 017773402:
case 017773404:
case 017773406:
*data = pro_ptr_rd(pa); /* printer controller */
break;
case 017773500:
case 017773502:
case 017773504:
case 017773506:
*data = pro_kb_rd(pa); /* keyboard controller */
break;
case 017773700:
*data = pro_csr;
break;
case 017773702:
*data = PRO_OMP; /* Option module present */
break;
case 017773704:
*data = pro_led;
break;
#if PRO_RD_PRESENT
case 017774000:
case 017774004:
case 017774006:
case 017774010:
case 017774012:
case 017774014:
case 017774016:
case 017774020:
*data = pro_rd_rd(pa);
break;
#endif
#if PRO_RX_PRESENT
case 017774200:
case 017774204:
case 017774206:
case 017774210:
case 017774212:
case 017774214:
case 017774216:
case 017774220:
case 017774222:
case 017774224:
*data = pro_rx_rd(pa);
break;
#endif
#if PRO_VID_PRESENT
case 017774400:
case 017774404:
case 017774406:
case 017774414:
case 017774416:
case 017774420:
/* EBO */
case 017774410:
#if PRO_EBO_PRESENT
case 017774600:
#endif
*data = pro_vid_rd(pa);
break;
#endif
#if PRO_MEM_PRESENT
case 017775000:
case 017775004:
case 017775006:
*data = pro_mem_rd(pa); /* memory expansion */
break;
#endif
/* Option board 6 not installed
case 017775200:
break;
*/
case 017777560:
case 017777562:
case 017777564:
case 017777566:
*data = pro_maint_rd(pa); /* maintenance terminal interface */
break;
case 017777750:
/* Processor maintenance register */
*data = 0;
break;
default:
*data = PRO_NOREG;
#ifdef IOTRACE
if (iotfptr)
{
fprintf(iotfptr, "*R %o\n",pa);
fflush(iotfptr);
}
#endif
return SCPE_NXM;
}
#ifdef IOTRACE
if (iotfptr)
{
fprintf(iotfptr, " R %o, %o\n",pa,*data);
fflush(iotfptr);
}
#endif
return SCPE_OK;
}
int reg_wr (int data, int pa, int access)
{
/* XXX Writes to ID PROM *should* return NXM */
#ifdef IOTRACE
if (iotfptr)
{
fprintf(iotfptr, "%10.0lf ",sim_gtime());
fprintf(iotfptr, "%6o",PC);
if (access == WRITEB)
fprintf(iotfptr, "B");
else
fprintf(iotfptr, " ");
}
#endif
if ((pa>=017773034) && (pa<=017773177)) /* Battery backed RAM */
WRITE_WB(BATRAM[(pa-017773034) >> 1], PRO_BATRAM_W, access);
else if ((pa>=017773200) && (pa<=017773213)) /* Int controllers */
pro_int_wr(data, pa, access);
else
switch (pa & 017777776)
{
case 017773000:
case 017773002:
case 017773004:
case 017773006:
case 017773010:
case 017773012:
case 017773014:
case 017773016:
case 017773020:
case 017773022:
case 017773024:
case 017773026:
case 017773030:
case 017773032:
pro_clk_wr(data, pa, access);
break;
case 017773300:
case 017773302:
case 017773304:
case 017773306:
case 017773310:
case 017773312:
case 017773314:
pro_com_wr(data, pa, access);
break;
case 017773400:
case 017773402:
case 017773404:
case 017773406:
pro_ptr_wr(data, pa, access);
break;
case 017773500:
case 017773502:
case 017773504:
case 017773506:
pro_kb_wr(data, pa, access);
break;
case 017773700:
WRITE_WB(pro_csr, PRO_CSR_W, access);
break;
case 017773704:
WRITE_WB(pro_led, PRO_LED_W, access);
break;
#if PRO_RD_PRESENT
case 017774002:
case 017774004:
case 017774006:
case 017774010:
case 017774012:
case 017774014:
case 017774016:
case 017774020:
pro_rd_wr(data, pa, access);
break;
#endif
#if PRO_RX_PRESENT
case 017774202:
case 017774204:
case 017774206:
case 017774210:
case 017774212:
case 017774216:
case 017774220:
case 017774222:
case 017774224:
case 017774226:
pro_rx_wr(data, pa, access);
break;
#endif
#if PRO_VID_PRESENT
case 017774402:
case 017774404:
case 017774406:
case 017774414:
case 017774416:
case 017774420:
case 017774422:
case 017774424:
case 017774426:
/* EBO */
case 017774410:
case 017774412:
#if PRO_EBO_PRESENT
case 017774602:
#endif
pro_vid_wr(data, pa, access);
break;
#endif
#if PRO_MEM_PRESENT
case 017775002:
case 017775004:
case 017775006:
pro_mem_wr(data, pa, access);
break;
#endif
/* Option board 6 not installed
case 017775202:
break;
*/
case 017777560:
case 017777562:
case 017777564:
case 017777566:
pro_maint_wr(data, pa, access); /* maintenance terminal interface */
break;
case 017777750:
/* Processor maintenance register */
break;
default:
#ifdef IOTRACE
if (iotfptr)
{
fprintf(iotfptr, "*W %o, %o\n",pa,data);
fflush(iotfptr);
}
#endif
return SCPE_NXM;
}
#ifdef IOTRACE
if (iotfptr)
{
fprintf(iotfptr, " W %o, %o\n",pa,data);
fflush(iotfptr);
}
#endif
return SCPE_OK;
}
#endif