/[gxemul]/trunk/src/machines/machine_arc.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/src/machines/machine_arc.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 26 - (show annotations)
Mon Oct 8 16:20:10 2007 UTC (16 years, 6 months ago) by dpavlin
File MIME type: text/plain
File size: 13725 byte(s)
++ trunk/HISTORY	(local)
$Id: HISTORY,v 1.1264 2006/06/25 11:08:04 debug Exp $
20060624	Replacing the error-prone machine type initialization stuff
		with something more reasonable.
		Finally removing the old "cpu_run" kludge; moving around stuff
		in machine.c and emul.c to better suit the dyntrans system.
		Various minor dyntrans cleanups (renaming translate_address to
		translate_v2p, and experimenting with template physpages).
20060625	Removing the speed hack which separated the vph entries into
		two halves (code vs data); things seem a lot more stable now.
		Minor performance hack: R2000/R3000 cache isolation now only
		clears address translations when going into isolation, not
		when going out of it.
		Fixing the MIPS interrupt problems by letting mtc0 immediately
		cause interrupts.

==============  RELEASE 0.4.0.1  ==============


1 /*
2 * Copyright (C) 2003-2006 Anders Gavare. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * 3. The name of the author may not be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
27 *
28 * $Id: machine_arc.c,v 1.4 2006/06/24 10:19:19 debug Exp $
29 */
30
31 #include <stdio.h>
32 #include <stdlib.h>
33 #include <string.h>
34
35 #include "arcbios.h"
36 #include "bus_isa.h"
37 #include "cpu.h"
38 #include "device.h"
39 #include "devices.h"
40 #include "machine.h"
41 #include "machine_interrupts.h"
42 #include "memory.h"
43 #include "misc.h"
44
45
46 MACHINE_SETUP(arc)
47 {
48 struct pci_data *pci_data;
49 struct memory *mem = machine->memory;
50 char tmpstr[1000];
51 int i, j;
52 char *eaddr_string = "eaddr=10:20:30:40:50:60"; /* bogus */
53 unsigned char macaddr[6];
54
55 machine->machine_name = malloc(MACHINE_NAME_MAXBUF);
56 if (machine->machine_name == NULL) {
57 fprintf(stderr, "out of memory\n");
58 exit(1);
59 }
60
61 cpu->byte_order = EMUL_LITTLE_ENDIAN;
62 snprintf(machine->machine_name,
63 MACHINE_NAME_MAXBUF, "ARC");
64
65 switch (machine->machine_subtype) {
66
67 case MACHINE_ARC_NEC_RD94:
68 case MACHINE_ARC_NEC_R94:
69 case MACHINE_ARC_NEC_R96:
70 /*
71 * "NEC-RD94" (NEC RISCstation 2250)
72 * "NEC-R94" (NEC RISCstation 2200)
73 * "NEC-R96" (NEC Express RISCserver)
74 *
75 * http://mirror.aarnet.edu.au/pub/NetBSD/misc/chs/arcdiag.out
76 * (NEC-R96)
77 */
78
79 switch (machine->machine_subtype) {
80 case MACHINE_ARC_NEC_RD94:
81 strlcat(machine->machine_name,
82 " (NEC-RD94, NEC RISCstation 2250)",
83 MACHINE_NAME_MAXBUF);
84 break;
85 case MACHINE_ARC_NEC_R94:
86 strlcat(machine->machine_name,
87 " (NEC-R94; NEC RISCstation 2200)",
88 MACHINE_NAME_MAXBUF);
89 break;
90 case MACHINE_ARC_NEC_R96:
91 strlcat(machine->machine_name,
92 " (NEC-R96; NEC Express RISCserver)",
93 MACHINE_NAME_MAXBUF);
94 break;
95 }
96
97 /* TODO: interrupt controller! */
98
99 pci_data = device_add(machine,
100 "rd94 addr=0x80000000, irq=0");
101
102 device_add(machine, "sn addr=0x80001000 irq=0");
103 dev_mc146818_init(machine, mem, 0x80004000ULL, 0,
104 MC146818_ARC_NEC, 1);
105 i = dev_pckbc_init(machine, mem, 0x80005000ULL, PCKBC_8042,
106 0, 0, machine->use_x11, 0);
107
108 snprintf(tmpstr, sizeof(tmpstr),
109 "ns16550 irq=3 addr=0x80006000 in_use=%i name2=tty0",
110 machine->use_x11? 0 : 1);
111 j = (size_t)device_add(machine, tmpstr);
112 snprintf(tmpstr, sizeof(tmpstr),
113 "ns16550 irq=0 addr=0x80007000 in_use=%i name2=tty1", 0);
114 device_add(machine, tmpstr);
115
116 if (machine->use_x11)
117 machine->main_console_handle = i;
118 else
119 machine->main_console_handle = j;
120
121 /* lpt at 0x80008000 */
122
123 device_add(machine, "fdc addr=0x8000c000, irq=0");
124
125 switch (machine->machine_subtype) {
126 case MACHINE_ARC_NEC_RD94:
127 case MACHINE_ARC_NEC_R94:
128 /* PCI devices: (NOTE: bus must be 0, device must be
129 3, 4, or 5, for NetBSD to accept interrupts) */
130 bus_pci_add(machine, pci_data, mem, 0, 3, 0,
131 "dec21030"); /* tga graphics */
132 break;
133 case MACHINE_ARC_NEC_R96:
134 dev_fb_init(machine, mem, 0x100e00000ULL,
135 VFB_GENERIC, 640,480, 1024,480,
136 8, "necvdfrb");
137 break;
138 }
139 break;
140
141 case MACHINE_ARC_NEC_R98:
142 /*
143 * "NEC-R98" (NEC RISCserver 4200)
144 *
145 * According to http://mail-index.netbsd.org/port-arc/
146 * 2004/02/01/0001.html:
147 *
148 * Network adapter at "start: 0x 0 18600000, length:
149 * 0x1000, level: 4, vector: 9"
150 * Disk at "start: 0x 0 18c103f0, length: 0x1000, level:
151 * 5, vector: 6"
152 * Keyboard at "start: 0x 0 18c20060, length: 0x1000,
153 * level: 5, vector: 3"
154 * Serial at "start: 0x 0 18c103f8, length: 0x1000,
155 * level: 5, vector: 4"
156 * Serial at "start: 0x 0 18c102f8, length: 0x1000,
157 * level: 5, vector: 4"
158 * Parallel at "start: 0x 0 18c10278, length: 0x1000,
159 * level: 5, vector: 5"
160 */
161
162 strlcat(machine->machine_name,
163 " (NEC-R98; NEC RISCserver 4200)", MACHINE_NAME_MAXBUF);
164
165 /*
166 * Windows NT access stuff at these addresses:
167 *
168 * 19980308, 18000210, 18c0a008,
169 * 19022018, 19026010, andso on.
170 */
171 break;
172
173 case MACHINE_ARC_JAZZ_PICA:
174 case MACHINE_ARC_JAZZ_MAGNUM:
175 /*
176 * "PICA-61"
177 *
178 * According to NetBSD 1.6.2:
179 *
180 * jazzio0 at mainbus0
181 * timer0 at jazzio0 addr 0xe0000228
182 * mcclock0 at jazzio0 addr 0xe0004000: mc146818 or compatible
183 * lpt at jazzio0 addr 0xe0008000 intr 0 not configured
184 * fdc at jazzio0 addr 0xe0003000 intr 1 not configured
185 * MAGNUM at jazzio0 addr 0xe000c000 intr 2 not configured
186 * ALI_S3 at jazzio0 addr 0xe0800000 intr 3 not configured
187 * sn0 at jazzio0 addr 0xe0001000 intr 4: SONIC Ethernet
188 * sn0: Ethernet address 69:6a:6b:6c:00:00
189 * asc0 at jazzio0 addr 0xe0002000 intr 5: NCR53C94, target 0
190 * pckbd at jazzio0 addr 0xe0005000 intr 6 not configured
191 * pms at jazzio0 addr 0xe0005000 intr 7 not configured
192 * com0 at jazzio0 addr 0xe0006000 intr 8: ns16550a,
193 * working fifo
194 * com at jazzio0 addr 0xe0007000 intr 9 not configured
195 * jazzisabr0 at mainbus0
196 * isa0 at jazzisabr0 isa_io_base 0xe2000000 isa_mem_base
197 * 0xe3000000
198 *
199 * "Microsoft-Jazz", "MIPS Magnum"
200 *
201 * timer0 at jazzio0 addr 0xe0000228
202 * mcclock0 at jazzio0 addr 0xe0004000: mc146818 or compatible
203 * lpt at jazzio0 addr 0xe0008000 intr 0 not configured
204 * fdc at jazzio0 addr 0xe0003000 intr 1 not configured
205 * MAGNUM at jazzio0 addr 0xe000c000 intr 2 not configured
206 * VXL at jazzio0 addr 0xe0800000 intr 3 not configured
207 * sn0 at jazzio0 addr 0xe0001000 intr 4: SONIC Ethernet
208 * sn0: Ethernet address 69:6a:6b:6c:00:00
209 * asc0 at jazzio0 addr 0xe0002000 intr 5: NCR53C94, target 0
210 * scsibus0 at asc0: 8 targets, 8 luns per target
211 * pckbd at jazzio0 addr 0xe0005000 intr 6 not configured
212 * pms at jazzio0 addr 0xe0005000 intr 7 not configured
213 * com0 at jazzio0 addr 0xe0006000 intr 8: ns16550a,
214 * working fifo
215 * com at jazzio0 addr 0xe0007000 intr 9 not configured
216 * jazzisabr0 at mainbus0
217 * isa0 at jazzisabr0 isa_io_base 0xe2000000 isa_mem_base
218 * 0xe3000000
219 */
220
221 switch (machine->machine_subtype) {
222 case MACHINE_ARC_JAZZ_PICA:
223 strlcat(machine->machine_name,
224 " (Microsoft Jazz, Acer PICA-61)",
225 MACHINE_NAME_MAXBUF);
226 machine->stable = 1;
227 break;
228 case MACHINE_ARC_JAZZ_MAGNUM:
229 strlcat(machine->machine_name,
230 " (Microsoft Jazz, MIPS Magnum)",
231 MACHINE_NAME_MAXBUF);
232 break;
233 default:
234 fatal("error in machine.c. jazz\n");
235 exit(1);
236 }
237
238 machine->md_int.jazz_data = device_add(machine,
239 "jazz addr=0x80000000");
240 machine->md_interrupt = jazz_interrupt;
241
242 i = dev_pckbc_init(machine, mem, 0x80005000ULL,
243 PCKBC_JAZZ, 8 + 6, 8 + 7,
244 machine->use_x11, 0);
245
246 snprintf(tmpstr, sizeof(tmpstr),
247 "ns16550 irq=16 addr=0x80006000 in_use=%i"
248 " name2=tty0", machine->use_x11? 0 : 1);
249 j = (size_t)device_add(machine, tmpstr);
250 snprintf(tmpstr, sizeof(tmpstr),
251 "ns16550 irq=17 addr=0x80007000 in_use=%i"
252 " name2=tty1", 0);
253 device_add(machine, tmpstr);
254
255 if (machine->use_x11)
256 machine->main_console_handle = i;
257 else
258 machine->main_console_handle = j;
259
260 switch (machine->machine_subtype) {
261 case MACHINE_ARC_JAZZ_PICA:
262 if (machine->use_x11) {
263 dev_vga_init(machine, mem, 0x400a0000ULL,
264 0x600003c0ULL, machine->machine_name);
265 arcbios_console_init(machine,
266 0x400b8000ULL, 0x600003c0ULL);
267 }
268 break;
269 case MACHINE_ARC_JAZZ_MAGNUM:
270 /* PROM mirror? */
271 dev_ram_init(machine, 0xfff00000, 0x100000,
272 DEV_RAM_MIRROR | DEV_RAM_MIGHT_POINT_TO_DEVICES,
273 0x1fc00000);
274
275 /* VXL. TODO */
276 /* control at 0x60100000? */
277 dev_fb_init(machine, mem, 0x60200000ULL,
278 VFB_GENERIC, 1024,768, 1024,768, 8, "VXL");
279 break;
280 }
281
282 /* irq 8 + 4 */
283 device_add(machine, "sn addr=0x80001000 irq=12");
284
285 dev_asc_init(machine, mem, 0x80002000ULL, 8 + 5, NULL,
286 DEV_ASC_PICA, dev_jazz_dma_controller,
287 machine->md_int.jazz_data);
288
289 device_add(machine, "fdc addr=0x80003000, irq=0");
290
291 dev_mc146818_init(machine, mem,
292 0x80004000ULL, 2, MC146818_ARC_JAZZ, 1);
293
294 #if 0
295 Not yet.
296 /* irq = 8+16 + 14 */
297 device_add(machine, "wdc addr=0x900001f0, irq=38");
298 #endif
299
300 break;
301
302 case MACHINE_ARC_JAZZ_M700:
303 /*
304 * "Microsoft-Jazz", "Olivetti M700"
305 *
306 * Different enough from Pica and Magnum to be
307 * separate here.
308 *
309 * http://mail-index.netbsd.org/port-arc/2000/10/18/0001.html
310 */
311
312 strlcat(machine->machine_name, " (Microsoft Jazz, "
313 "Olivetti M700)", MACHINE_NAME_MAXBUF);
314
315 machine->md_int.jazz_data = device_add(machine,
316 "jazz addr=0x80000000");
317 machine->md_interrupt = jazz_interrupt;
318
319 dev_mc146818_init(machine, mem,
320 0x80004000ULL, 2, MC146818_ARC_JAZZ, 1);
321
322 i = 0; /* TODO: Yuck! */
323 #if 0
324 i = dev_pckbc_init(machine, mem, 0x80005000ULL,
325 PCKBC_JAZZ, 8 + 6, 8 + 7, machine->use_x11, 0);
326 #endif
327
328 snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=16 addr="
329 "0x80006000 in_use=%i name2=tty0", machine->use_x11? 0 : 1);
330 j = (size_t)device_add(machine, tmpstr);
331 snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=17 addr="
332 "0x80007000 in_use=%i name2=tty1", 0);
333 device_add(machine, tmpstr);
334
335 if (machine->use_x11)
336 machine->main_console_handle = i;
337 else
338 machine->main_console_handle = j;
339
340 dev_m700_fb_init(machine, mem, 0x180080000ULL, 0x100000000ULL);
341
342 break;
343
344 case MACHINE_ARC_DESKTECH_TYNE:
345 /*
346 * "Deskstation Tyne" (?)
347 *
348 * TODO
349 * http://mail-index.netbsd.org/port-arc/2000/10/14/0000.html
350 */
351
352 strlcat(machine->machine_name, " (Deskstation Tyne)",
353 MACHINE_NAME_MAXBUF);
354
355 /* TODO: IRQs! */
356 bus_isa_init(machine, 0, 0x900000000ULL,
357 0x100000000ULL, 8, 24);
358 #if 0
359 snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=0 addr="
360 "0x9000003f8 in_use=%i name2=tty0", machine->use_x11? 0:1);
361 i = (size_t)device_add(machine, tmpstr);
362 device_add(machine, "ns16550 irq=0 addr=0x9000002f8 in_use=0"
363 " name2=tty1");
364 #endif
365 device_add(machine, "ns16550 irq=0 addr=0x9000003e8 "
366 "in_use=0 name2=tty2");
367 device_add(machine, "ns16550 irq=0 addr=0x9000002e8 "
368 "in_use=0 name2=tty3");
369 #if 0
370 dev_mc146818_init(machine, mem,
371 0x900000070ULL, 2, MC146818_PC_CMOS, 1);
372 /* TODO: irq, etc */
373 device_add(machine, "wdc addr=0x9000001f0, irq=0");
374 device_add(machine, "wdc addr=0x900000170, irq=0");
375
376 /* PC kbd */
377 j = dev_pckbc_init(machine, mem, 0x900000060ULL,
378 PCKBC_8042, 0, 0, machine->use_x11, 0);
379
380 if (machine->use_x11)
381 machine->main_console_handle = j;
382 else
383 machine->main_console_handle = i;
384 #endif
385
386 if (machine->use_x11) {
387 dev_vga_init(machine, mem, 0x1000a0000ULL,
388 0x9000003c0ULL, machine->machine_name);
389 arcbios_console_init(machine,
390 0x1000b8000ULL, 0x9000003c0ULL);
391 }
392 break;
393
394 default:fatal("Unimplemented ARC machine type %i\n",
395 machine->machine_subtype);
396 exit(1);
397 }
398
399 /*
400 * NOTE: ARCBIOS shouldn't be used before this point. (The only
401 * exception is that arcbios_console_init() may be called.)
402 */
403
404 if (!machine->prom_emulation)
405 return;
406
407 arcbios_init(machine, 0, 0, eaddr_string, macaddr);
408 }
409
410
411 MACHINE_DEFAULT_CPU(arc)
412 {
413 switch (machine->machine_subtype) {
414 case MACHINE_ARC_JAZZ_PICA:
415 machine->cpu_name = strdup("R4000");
416 break;
417 default:
418 machine->cpu_name = strdup("R4400");
419 }
420 }
421
422
423 MACHINE_DEFAULT_RAM(arc)
424 {
425 machine->physical_ram_in_mb = 64;
426 }
427
428
429 MACHINE_REGISTER(arc)
430 {
431 MR_DEFAULT(arc, "ARC", ARCH_MIPS, MACHINE_ARC);
432
433 me->set_default_ram = machine_default_ram_arc;
434
435 machine_entry_add_alias(me, "arc");
436
437 machine_entry_add_subtype(me, "Acer PICA-61", MACHINE_ARC_JAZZ_PICA,
438 "pica-61", "acer pica", "pica", NULL);
439
440 machine_entry_add_subtype(me, "Deskstation Tyne",
441 MACHINE_ARC_DESKTECH_TYNE,
442 "deskstation tyne", "desktech", "tyne", NULL);
443
444 machine_entry_add_subtype(me, "Jazz Magnum", MACHINE_ARC_JAZZ_MAGNUM,
445 "magnum", "jazz magnum", NULL);
446
447 machine_entry_add_subtype(me, "NEC-R94", MACHINE_ARC_NEC_R94,
448 "nec-r94", "r94", NULL);
449
450 machine_entry_add_subtype(me, "NEC-RD94", MACHINE_ARC_NEC_RD94,
451 "nec-rd94", "rd94", NULL);
452
453 machine_entry_add_subtype(me, "NEC-R96", MACHINE_ARC_NEC_R96,
454 "nec-r96", "r96", NULL);
455
456 machine_entry_add_subtype(me, "NEC-R98", MACHINE_ARC_NEC_R98,
457 "nec-r98", "r98", NULL);
458
459 machine_entry_add_subtype(me, "Olivetti M700", MACHINE_ARC_JAZZ_M700,
460 "olivetti", "m700", NULL);
461 }
462

  ViewVC Help
Powered by ViewVC 1.1.26