/[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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 38 - (hide annotations)
Mon Oct 8 16:21:53 2007 UTC (16 years, 6 months ago) by dpavlin
File MIME type: text/plain
File size: 12097 byte(s)
++ trunk/HISTORY	(local)
$Id: HISTORY,v 1.1515 2007/04/14 05:39:46 debug Exp $
20070324	Adding a "--debug" option to the configure script, to disable
		optimizations in unstable development builds.
		Moving out SCSI-specific stuff from diskimage.c into a new
		diskimage_scsicmd.c.
		Applying Hĺvard Eidnes' patch for SCSICDROM_READ_DISKINFO and
		SCSICDROM_READ_TRACKINFO. (Not really tested yet.)
		Implementing disk image "overlays" (to allow simple roll-back
		to previous disk state). Adding a 'V' disk flag for this, and
		updating the man page and misc.html.
20070325	Stability fix to cpu_dyntrans.c, when multiple physical pages
		share the same initial table entry. (The ppp == NULL check
		should be physpage_ofs == 0.) Bug found by analysing GXemul
		against a version patched for Godson.
		Fixing a second occurance of the same problem (also in
		cpu_dyntrans.c).
		Fixing a MAJOR physical page leak in cpu_dyntrans.c; pages
		weren't _added_ to the set of translated pages, they _replaced_
		all previous pages. It's amazing that this bug has been able
		to live for this long. (Triggered when emulating >128MB RAM.)
20070326	Removing the GDB debugging stub support; it was too hackish
		and ugly.
20070328	Moving around some native code generation skeleton code.
20070329	The -lm check in the configure script now also checks for sin()
		in addition to sqrt(). (Thanks to Nigel Horne for noticing that
		sqrt was not enough on Fedora Core 6.) (Not verified yet.)
20070330	Fixing an indexing bug in dev_sh4.c, found by using gcc version
		4.3.0 20070323.
20070331	Some more experimentation with native code generation.
20070404	Attempting to fix some more SH4 SCIF interrupt bugs; rewriting
		the SH interrupt assertion/deassertion code somewhat.
20070410	Splitting src/file.c into separate files in src/file/.
		Cleanup: Removing the dummy TS7200, Walnut, PB1000, and
		Meshcube emulation modes, and dev_epcom and dev_au1x00.
		Removing the experimental CHIP8/RCA180x code; it wasn't really
		working much lately, anyway. It was fun while it lasted.
		Also removing the experimental Transputer CPU support.
20070412	Moving the section about how the dynamic translation system
		works from intro.html to a separate translation.html file.
		Minor SH fixes; attempting to get OpenBSD/landisk to run
		without randomly bugging out, but no success yet.
20070413	SH SCI (serial bit interface) should now work together with a
		(new) RS5C313 clock device (for Landisk emulation).
20070414	Moving Redhat/MIPS down from supported to experimental, in
		guestoses.html.
		Preparing for a new release; doing some regression testing etc.

==============  RELEASE 0.4.5  ==============


1 dpavlin 22 /*
2 dpavlin 34 * Copyright (C) 2003-2007 Anders Gavare. All rights reserved.
3 dpavlin 22 *
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 dpavlin 38 * $Id: machine_arc.c,v 1.14 2007/03/24 06:40:15 debug Exp $
29 dpavlin 22 */
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 "memory.h"
42     #include "misc.h"
43    
44 dpavlin 28 #define MACHINE_NAME_MAXBUF 100
45 dpavlin 22
46 dpavlin 28
47 dpavlin 22 MACHINE_SETUP(arc)
48     {
49     struct pci_data *pci_data;
50 dpavlin 34 void *jazz_data;
51 dpavlin 22 struct memory *mem = machine->memory;
52     char tmpstr[1000];
53 dpavlin 34 char tmpstr2[1000];
54 dpavlin 22 int i, j;
55     char *eaddr_string = "eaddr=10:20:30:40:50:60"; /* bogus */
56     unsigned char macaddr[6];
57    
58     machine->machine_name = malloc(MACHINE_NAME_MAXBUF);
59     if (machine->machine_name == NULL) {
60     fprintf(stderr, "out of memory\n");
61     exit(1);
62     }
63    
64     cpu->byte_order = EMUL_LITTLE_ENDIAN;
65 dpavlin 28 snprintf(machine->machine_name, MACHINE_NAME_MAXBUF, "ARC");
66 dpavlin 22
67     switch (machine->machine_subtype) {
68    
69     case MACHINE_ARC_NEC_RD94:
70     case MACHINE_ARC_NEC_R94:
71     case MACHINE_ARC_NEC_R96:
72     /*
73     * "NEC-RD94" (NEC RISCstation 2250)
74     * "NEC-R94" (NEC RISCstation 2200)
75     * "NEC-R96" (NEC Express RISCserver)
76     *
77     * http://mirror.aarnet.edu.au/pub/NetBSD/misc/chs/arcdiag.out
78     * (NEC-R96)
79     */
80    
81     switch (machine->machine_subtype) {
82     case MACHINE_ARC_NEC_RD94:
83     strlcat(machine->machine_name,
84     " (NEC-RD94, NEC RISCstation 2250)",
85     MACHINE_NAME_MAXBUF);
86     break;
87     case MACHINE_ARC_NEC_R94:
88 dpavlin 24 strlcat(machine->machine_name,
89     " (NEC-R94; NEC RISCstation 2200)",
90 dpavlin 22 MACHINE_NAME_MAXBUF);
91     break;
92     case MACHINE_ARC_NEC_R96:
93 dpavlin 24 strlcat(machine->machine_name,
94     " (NEC-R96; NEC Express RISCserver)",
95 dpavlin 22 MACHINE_NAME_MAXBUF);
96     break;
97     }
98    
99     /* TODO: interrupt controller! */
100    
101     pci_data = device_add(machine,
102     "rd94 addr=0x80000000, irq=0");
103    
104     device_add(machine, "sn addr=0x80001000 irq=0");
105     dev_mc146818_init(machine, mem, 0x80004000ULL, 0,
106     MC146818_ARC_NEC, 1);
107    
108 dpavlin 34 fatal("TODO: legacy rewrite\n");
109     abort();
110     // i = dev_pckbc_init(machine, mem, 0x80005000ULL, PCKBC_8042,
111     // 0, 0, machine->use_x11, 0);
112 dpavlin 38 i = 0;
113 dpavlin 34
114 dpavlin 22 snprintf(tmpstr, sizeof(tmpstr),
115     "ns16550 irq=3 addr=0x80006000 in_use=%i name2=tty0",
116     machine->use_x11? 0 : 1);
117     j = (size_t)device_add(machine, tmpstr);
118     snprintf(tmpstr, sizeof(tmpstr),
119     "ns16550 irq=0 addr=0x80007000 in_use=%i name2=tty1", 0);
120     device_add(machine, tmpstr);
121    
122     if (machine->use_x11)
123     machine->main_console_handle = i;
124     else
125     machine->main_console_handle = j;
126    
127     /* lpt at 0x80008000 */
128    
129     device_add(machine, "fdc addr=0x8000c000, irq=0");
130    
131     switch (machine->machine_subtype) {
132     case MACHINE_ARC_NEC_RD94:
133     case MACHINE_ARC_NEC_R94:
134     /* PCI devices: (NOTE: bus must be 0, device must be
135     3, 4, or 5, for NetBSD to accept interrupts) */
136     bus_pci_add(machine, pci_data, mem, 0, 3, 0,
137     "dec21030"); /* tga graphics */
138     break;
139     case MACHINE_ARC_NEC_R96:
140     dev_fb_init(machine, mem, 0x100e00000ULL,
141     VFB_GENERIC, 640,480, 1024,480,
142     8, "necvdfrb");
143     break;
144     }
145     break;
146    
147     case MACHINE_ARC_NEC_R98:
148     /*
149     * "NEC-R98" (NEC RISCserver 4200)
150     *
151     * According to http://mail-index.netbsd.org/port-arc/
152     * 2004/02/01/0001.html:
153     *
154 dpavlin 24 * Network adapter at "start: 0x 0 18600000, length:
155     * 0x1000, level: 4, vector: 9"
156     * Disk at "start: 0x 0 18c103f0, length: 0x1000, level:
157     * 5, vector: 6"
158     * Keyboard at "start: 0x 0 18c20060, length: 0x1000,
159     * level: 5, vector: 3"
160     * Serial at "start: 0x 0 18c103f8, length: 0x1000,
161     * level: 5, vector: 4"
162     * Serial at "start: 0x 0 18c102f8, length: 0x1000,
163     * level: 5, vector: 4"
164     * Parallel at "start: 0x 0 18c10278, length: 0x1000,
165     * level: 5, vector: 5"
166 dpavlin 22 */
167    
168     strlcat(machine->machine_name,
169     " (NEC-R98; NEC RISCserver 4200)", MACHINE_NAME_MAXBUF);
170    
171     /*
172     * Windows NT access stuff at these addresses:
173     *
174     * 19980308, 18000210, 18c0a008,
175     * 19022018, 19026010, andso on.
176     */
177     break;
178    
179     case MACHINE_ARC_JAZZ_PICA:
180     case MACHINE_ARC_JAZZ_MAGNUM:
181     /*
182     * "PICA-61"
183     *
184     * According to NetBSD 1.6.2:
185     *
186     * jazzio0 at mainbus0
187     * timer0 at jazzio0 addr 0xe0000228
188     * mcclock0 at jazzio0 addr 0xe0004000: mc146818 or compatible
189     * lpt at jazzio0 addr 0xe0008000 intr 0 not configured
190     * fdc at jazzio0 addr 0xe0003000 intr 1 not configured
191     * MAGNUM at jazzio0 addr 0xe000c000 intr 2 not configured
192     * ALI_S3 at jazzio0 addr 0xe0800000 intr 3 not configured
193     * sn0 at jazzio0 addr 0xe0001000 intr 4: SONIC Ethernet
194     * sn0: Ethernet address 69:6a:6b:6c:00:00
195     * asc0 at jazzio0 addr 0xe0002000 intr 5: NCR53C94, target 0
196     * pckbd at jazzio0 addr 0xe0005000 intr 6 not configured
197     * pms at jazzio0 addr 0xe0005000 intr 7 not configured
198 dpavlin 24 * com0 at jazzio0 addr 0xe0006000 intr 8: ns16550a,
199     * working fifo
200 dpavlin 22 * com at jazzio0 addr 0xe0007000 intr 9 not configured
201     * jazzisabr0 at mainbus0
202 dpavlin 24 * isa0 at jazzisabr0 isa_io_base 0xe2000000 isa_mem_base
203     * 0xe3000000
204 dpavlin 22 *
205     * "Microsoft-Jazz", "MIPS Magnum"
206     *
207     * timer0 at jazzio0 addr 0xe0000228
208     * mcclock0 at jazzio0 addr 0xe0004000: mc146818 or compatible
209     * lpt at jazzio0 addr 0xe0008000 intr 0 not configured
210     * fdc at jazzio0 addr 0xe0003000 intr 1 not configured
211     * MAGNUM at jazzio0 addr 0xe000c000 intr 2 not configured
212     * VXL at jazzio0 addr 0xe0800000 intr 3 not configured
213     * sn0 at jazzio0 addr 0xe0001000 intr 4: SONIC Ethernet
214     * sn0: Ethernet address 69:6a:6b:6c:00:00
215     * asc0 at jazzio0 addr 0xe0002000 intr 5: NCR53C94, target 0
216     * scsibus0 at asc0: 8 targets, 8 luns per target
217     * pckbd at jazzio0 addr 0xe0005000 intr 6 not configured
218     * pms at jazzio0 addr 0xe0005000 intr 7 not configured
219 dpavlin 24 * com0 at jazzio0 addr 0xe0006000 intr 8: ns16550a,
220     * working fifo
221 dpavlin 22 * com at jazzio0 addr 0xe0007000 intr 9 not configured
222     * jazzisabr0 at mainbus0
223 dpavlin 24 * isa0 at jazzisabr0 isa_io_base 0xe2000000 isa_mem_base
224     * 0xe3000000
225 dpavlin 22 */
226    
227     switch (machine->machine_subtype) {
228     case MACHINE_ARC_JAZZ_PICA:
229 dpavlin 24 strlcat(machine->machine_name,
230     " (Microsoft Jazz, Acer PICA-61)",
231 dpavlin 22 MACHINE_NAME_MAXBUF);
232     machine->stable = 1;
233     break;
234     case MACHINE_ARC_JAZZ_MAGNUM:
235 dpavlin 24 strlcat(machine->machine_name,
236     " (Microsoft Jazz, MIPS Magnum)",
237 dpavlin 22 MACHINE_NAME_MAXBUF);
238     break;
239     default:
240     fatal("error in machine.c. jazz\n");
241     exit(1);
242     }
243    
244 dpavlin 34 jazz_data = device_add(machine, "jazz addr=0x80000000");
245 dpavlin 22
246 dpavlin 34 /* Keyboard IRQ is jazz.6, mouse is jazz.7 */
247     snprintf(tmpstr, sizeof(tmpstr),
248     "%s.cpu[%i].jazz.6", machine->path,
249     machine->bootstrap_cpu);
250     snprintf(tmpstr2, sizeof(tmpstr2),
251     "%s.cpu[%i].jazz.7", machine->path,
252     machine->bootstrap_cpu);
253 dpavlin 24 i = dev_pckbc_init(machine, mem, 0x80005000ULL,
254 dpavlin 34 PCKBC_JAZZ, tmpstr, tmpstr2,
255 dpavlin 24 machine->use_x11, 0);
256 dpavlin 22
257 dpavlin 34 /* Serial controllers at JAZZ irq 8 and 9: */
258 dpavlin 24 snprintf(tmpstr, sizeof(tmpstr),
259 dpavlin 34 "ns16550 irq=%s.cpu[%i].jazz.8 addr=0x80006000"
260     " in_use=%i name2=tty0", machine->path,
261     machine->bootstrap_cpu, machine->use_x11? 0 : 1);
262 dpavlin 24 j = (size_t)device_add(machine, tmpstr);
263     snprintf(tmpstr, sizeof(tmpstr),
264 dpavlin 34 "ns16550 irq=%s.cpu[%i].jazz.9 addr=0x80007000"
265     " in_use=0 name2=tty1", machine->path,
266     machine->bootstrap_cpu);
267 dpavlin 24 device_add(machine, tmpstr);
268 dpavlin 22
269 dpavlin 24 if (machine->use_x11)
270     machine->main_console_handle = i;
271     else
272     machine->main_console_handle = j;
273 dpavlin 22
274 dpavlin 24 switch (machine->machine_subtype) {
275     case MACHINE_ARC_JAZZ_PICA:
276     if (machine->use_x11) {
277     dev_vga_init(machine, mem, 0x400a0000ULL,
278     0x600003c0ULL, machine->machine_name);
279     arcbios_console_init(machine,
280     0x400b8000ULL, 0x600003c0ULL);
281     }
282     break;
283     case MACHINE_ARC_JAZZ_MAGNUM:
284     /* PROM mirror? */
285     dev_ram_init(machine, 0xfff00000, 0x100000,
286     DEV_RAM_MIRROR | DEV_RAM_MIGHT_POINT_TO_DEVICES,
287     0x1fc00000);
288 dpavlin 22
289 dpavlin 24 /* VXL. TODO */
290     /* control at 0x60100000? */
291     dev_fb_init(machine, mem, 0x60200000ULL,
292     VFB_GENERIC, 1024,768, 1024,768, 8, "VXL");
293     break;
294     }
295 dpavlin 22
296 dpavlin 34 /* SN at JAZZ irq 4 */
297     snprintf(tmpstr, sizeof(tmpstr),
298     "sn addr=0x80001000 irq=%s.cpu[%i].jazz.4",
299     machine->path, machine->bootstrap_cpu);
300     device_add(machine, tmpstr);
301 dpavlin 22
302 dpavlin 34 /* ASC at JAZZ irq 5 */
303     snprintf(tmpstr, sizeof(tmpstr), "%s.cpu[%i].jazz.5",
304     machine->path, machine->bootstrap_cpu);
305     dev_asc_init(machine, mem, 0x80002000ULL, tmpstr, NULL,
306     DEV_ASC_PICA, dev_jazz_dma_controller, jazz_data);
307 dpavlin 22
308 dpavlin 34 /* FDC at JAZZ irq 1 */
309     snprintf(tmpstr, sizeof(tmpstr),
310     "fdc addr=0x80003000 irq=%s.cpu[%i].jazz.1",
311     machine->path, machine->bootstrap_cpu);
312     device_add(machine, tmpstr);
313 dpavlin 22
314 dpavlin 34 /* MC146818 at MIPS irq 2: */
315     snprintf(tmpstr, sizeof(tmpstr), "%s.cpu[%i].2",
316     machine->path, machine->bootstrap_cpu);
317 dpavlin 24 dev_mc146818_init(machine, mem,
318 dpavlin 34 0x80004000ULL, tmpstr, MC146818_ARC_JAZZ, 1);
319 dpavlin 22
320     #if 0
321     Not yet.
322 dpavlin 34 /* WDC at ISA irq 14 */
323 dpavlin 24 device_add(machine, "wdc addr=0x900001f0, irq=38");
324 dpavlin 22 #endif
325    
326 dpavlin 24 break;
327 dpavlin 22
328     default:fatal("Unimplemented ARC machine type %i\n",
329     machine->machine_subtype);
330     exit(1);
331     }
332    
333     /*
334     * NOTE: ARCBIOS shouldn't be used before this point. (The only
335     * exception is that arcbios_console_init() may be called.)
336     */
337    
338     if (!machine->prom_emulation)
339     return;
340    
341     arcbios_init(machine, 0, 0, eaddr_string, macaddr);
342     }
343    
344    
345     MACHINE_DEFAULT_CPU(arc)
346     {
347     switch (machine->machine_subtype) {
348     case MACHINE_ARC_JAZZ_PICA:
349     machine->cpu_name = strdup("R4000");
350     break;
351     default:
352     machine->cpu_name = strdup("R4400");
353     }
354     }
355    
356    
357     MACHINE_DEFAULT_RAM(arc)
358     {
359     machine->physical_ram_in_mb = 64;
360     }
361    
362    
363     MACHINE_REGISTER(arc)
364     {
365 dpavlin 26 MR_DEFAULT(arc, "ARC", ARCH_MIPS, MACHINE_ARC);
366 dpavlin 22
367     me->set_default_ram = machine_default_ram_arc;
368    
369 dpavlin 26 machine_entry_add_alias(me, "arc");
370 dpavlin 22
371 dpavlin 26 machine_entry_add_subtype(me, "Acer PICA-61", MACHINE_ARC_JAZZ_PICA,
372     "pica-61", "acer pica", "pica", NULL);
373 dpavlin 22
374 dpavlin 26 machine_entry_add_subtype(me, "Deskstation Tyne",
375     MACHINE_ARC_DESKTECH_TYNE,
376     "deskstation tyne", "desktech", "tyne", NULL);
377 dpavlin 22
378 dpavlin 26 machine_entry_add_subtype(me, "Jazz Magnum", MACHINE_ARC_JAZZ_MAGNUM,
379     "magnum", "jazz magnum", NULL);
380 dpavlin 22
381 dpavlin 26 machine_entry_add_subtype(me, "NEC-R94", MACHINE_ARC_NEC_R94,
382     "nec-r94", "r94", NULL);
383 dpavlin 22
384 dpavlin 26 machine_entry_add_subtype(me, "NEC-RD94", MACHINE_ARC_NEC_RD94,
385     "nec-rd94", "rd94", NULL);
386 dpavlin 22
387 dpavlin 26 machine_entry_add_subtype(me, "NEC-R96", MACHINE_ARC_NEC_R96,
388     "nec-r96", "r96", NULL);
389 dpavlin 22
390 dpavlin 26 machine_entry_add_subtype(me, "NEC-R98", MACHINE_ARC_NEC_R98,
391     "nec-r98", "r98", NULL);
392 dpavlin 22
393 dpavlin 26 machine_entry_add_subtype(me, "Olivetti M700", MACHINE_ARC_JAZZ_M700,
394     "olivetti", "m700", NULL);
395 dpavlin 22 }
396    

  ViewVC Help
Powered by ViewVC 1.1.26