/[gxemul]/trunk/src/machine.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/machine.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4 - (hide annotations)
Mon Oct 8 16:18:00 2007 UTC (16 years, 6 months ago) by dpavlin
File MIME type: text/plain
File size: 173220 byte(s)
++ trunk/HISTORY	(local)
$Id: HISTORY,v 1.707 2005/04/27 16:37:33 debug Exp $
20050408	Some minor updates to the wdc. Linux now doesn't complain
		anymore if a disk is non-present.
20050409	Various minor fixes (a bintrans bug, and some other things).
		The wdc seems to work with Playstation2 emulation, but there
		is a _long_ annoying delay when disks are detected.
		Fixing a really important bintrans bug (when devices and RAM
		are mixed within 4KB pages), which was triggered with
		NetBSD/playstation2 kernels.
20050410	Adding a dummy dev_ps2_ether (just so that NetBSD doesn't
		complain as much during bootup).
		Symbols starting with '$' are now ignored.
		Renaming dev_ps2_ohci.c to dev_ohci.c, etc.
20050411	Moving the bintrans-cache-isolation check from cpu_mips.c to
		cpu_mips_coproc.c. (I thought this would give a speedup, but
		it's not noticable.)
		Better playstation2 sbus interrupt code.
		Skip ahead many ticks if the count register is read manually.
		(This increases the speed of delay-loops that simply read
		the count register.)
20050412	Updates to the playstation2 timer/interrupt code.
		Some other minor updates.
20050413	NetBSD/cobalt runs from a disk image :-) including userland;
		updating the documentation on how to install NetBSD/cobalt
		using NetBSD/pmax (!).
		Some minor bintrans updates (no real speed improvement) and
		other minor updates (playstation2 now uses the -o options).
20050414	Adding a dummy x86 (and AMD64) mode.
20050415	Adding some (32-bit and 16-bit) x86 instructions.
		Adding some initial support for non-SCSI, non-IDE floppy
		images. (The x86 mode can boot from these, more or less.)
		Moving the devices/ and include/ directories to src/devices/
		and src/include/, respectively.
20050416	Continuing on the x86 stuff. (Adding pc_bios.c and some simple
		support for software interrupts in 16-bit mode.)
20050417	Ripping out most of the x86 instruction decoding stuff, trying
		to rewrite it in a cleaner way.
		Disabling some of the least working CPU families in the
		configure script (sparc, x86, alpha, hppa), so that they are
		not enabled by default.
20050418	Trying to fix the bug which caused problems when turning on
		and off bintrans interactively, by flushing the bintrans cache
		whenever bintrans is manually (re)enabled.
20050419	Adding the 'lswi' ppc instruction.
		Minor updates to the x86 instruction decoding.
20050420	Renaming x86 register name indices from R_xx to X86_R_xx (this
		makes building on Tru64 nicer).
20050422	Adding a check for duplicate MIPS TLB entries on tlbwr/tlbwi.
20050427	Adding screenshots to guestoses.html.
		Some minor fixes and testing for the next release.

==============  RELEASE 0.3.2  ==============


1 dpavlin 2 /*
2     * Copyright (C) 2003-2005 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 dpavlin 4 * $Id: machine.c,v 1.420 2005/04/17 00:15:24 debug Exp $
29 dpavlin 2 *
30     * Emulation of specific machines.
31     *
32     * This module is quite large. Hopefully it is still clear enough to be
33     * easily understood. The main parts are:
34     *
35     * Helper functions.
36     *
37     * Machine specific Interrupt routines.
38     *
39     * Machine specific Initialization routines.
40     */
41    
42     #include <stdio.h>
43     #include <stdlib.h>
44     #include <stdarg.h>
45     #ifdef SOLARIS
46     #include <strings.h>
47     #else
48     #include <string.h>
49     #endif
50     #include <time.h>
51     #include <unistd.h>
52    
53     #include "arcbios.h"
54     #include "bus_pci.h"
55     #include "cpu.h"
56     #include "cpu_mips.h"
57     #include "device.h"
58     #include "devices.h"
59     #include "diskimage.h"
60     #include "emul.h"
61     #include "machine.h"
62     #include "memory.h"
63     #include "misc.h"
64     #include "mp.h"
65     #include "net.h"
66     #include "symbol.h"
67    
68     /* For SGI and ARC emulation: */
69     #include "sgi_arcbios.h"
70     #include "arcbios_other.h"
71     #include "crimereg.h"
72    
73     /* For DECstation emulation: */
74     #include "dec_prom.h"
75     #include "dec_bootinfo.h"
76     #include "dec_5100.h"
77     #include "dec_kn01.h"
78     #include "dec_kn02.h"
79     #include "dec_kn03.h"
80     #include "dec_kmin.h"
81     #include "dec_maxine.h"
82    
83     /* HPC: */
84     #include "hpc_bootinfo.h"
85     #include "vripreg.h"
86    
87    
88     struct machine_entry_subtype {
89     int machine_subtype;/* Old-style subtype */
90     const char *name; /* Official name */
91     int n_aliases;
92     char **aliases; /* Aliases */
93     };
94    
95     struct machine_entry {
96     struct machine_entry *next;
97    
98     /* Machine type: */
99     int arch;
100     int machine_type; /* Old-style type */
101     const char *name; /* Official name */
102     int n_aliases;
103     char **aliases; /* Aliases */
104    
105     /* Machine subtypes: */
106     int n_subtypes;
107     struct machine_entry_subtype **subtype;
108     };
109    
110     /* This is initialized by machine_init(): */
111     static struct machine_entry *first_machine_entry = NULL;
112    
113    
114     /*
115     * machine_new():
116     *
117     * Returns a reasonably initialized struct machine.
118     */
119     struct machine *machine_new(char *name, struct emul *emul)
120     {
121     struct machine *m;
122     m = malloc(sizeof(struct machine));
123     if (m == NULL) {
124     fprintf(stderr, "machine_new(): out of memory\n");
125     exit(1);
126     }
127    
128     memset(m, 0, sizeof(struct machine));
129    
130     /* Back pointer: */
131     m->emul = emul;
132    
133     m->name = strdup(name);
134    
135     /* Sane default values: */
136     m->serial_nr = 0;
137     m->machine_type = MACHINE_NONE;
138     m->machine_subtype = MACHINE_NONE;
139     m->bintrans_enable = 1;
140     m->prom_emulation = 1;
141     m->speed_tricks = 1;
142     m->byte_order_override = NO_BYTE_ORDER_OVERRIDE;
143     m->boot_kernel_filename = "";
144     m->boot_string_argument = NULL;
145     m->automatic_clock_adjustment = 1;
146     m->x11_scaledown = 1;
147     m->n_gfx_cards = 1;
148     m->dbe_on_nonexistant_memaccess = 1;
149     m->show_symbolic_register_names = 1;
150     m->bintrans_size = DEFAULT_BINTRANS_SIZE_IN_MB * 1048576;
151     symbol_init(&m->symbol_context);
152    
153     return m;
154     }
155    
156    
157     /*
158     * machine_name_to_type():
159     *
160     * Take a type and a subtype as strings, and convert them into numeric
161     * values used internally throughout the code.
162     *
163     * Return value is 1 on success, 0 if there was no match.
164     * Also, any errors/warnings are printed using fatal()/debug().
165     */
166     int machine_name_to_type(char *stype, char *ssubtype,
167     int *type, int *subtype, int *arch)
168     {
169     struct machine_entry *me;
170     int i, j, k;
171    
172     *type = MACHINE_NONE;
173     *subtype = 0;
174    
175     me = first_machine_entry;
176     while (me != NULL) {
177     for (i=0; i<me->n_aliases; i++)
178     if (strcasecmp(me->aliases[i], stype) == 0) {
179     /* Found a type: */
180     *type = me->machine_type;
181     *arch = me->arch;
182    
183     if (me->n_subtypes == 0)
184     return 1;
185    
186     /* Check for subtype: */
187     for (j=0; j<me->n_subtypes; j++)
188     for (k=0; k<me->subtype[j]->n_aliases;
189     k++)
190     if (strcasecmp(ssubtype,
191     me->subtype[j]->aliases[k]
192     ) == 0) {
193     *subtype = me->subtype[
194     j]->machine_subtype;
195     return 1;
196     }
197    
198     fatal("unknown subtype '%s' for emulation"
199     " '%s'\n", ssubtype, stype);
200     exit(1);
201     }
202    
203     me = me->next;
204     }
205    
206     fatal("machine_name_to_type(): unknown emulation type '%s' (", stype);
207     if (ssubtype == NULL)
208     fatal("no subtype)\n");
209     else
210     fatal("subtype '%s')\n", ssubtype);
211    
212     fatal("Use the -H command line option to get a list of available"
213     " types and subtypes.\n");
214     return 0;
215     }
216    
217    
218     /*
219     * machine_add_tickfunction():
220     *
221     * Adds a tick function (a function called every now and then, depending on
222     * clock cycle count) to a machine.
223     */
224     void machine_add_tickfunction(struct machine *machine, void (*func)
225     (struct cpu *, void *), void *extra, int clockshift)
226     {
227     int n = machine->n_tick_entries;
228    
229     if (n >= MAX_TICK_FUNCTIONS) {
230     fprintf(stderr, "machine_add_tickfunction(): too "
231     "many tick functions\n");
232     exit(1);
233     }
234    
235     /* Don't use too low clockshifts, that would be too inefficient
236     with bintrans. */
237     if (clockshift < N_SAFE_BINTRANS_LIMIT_SHIFT)
238     fatal("WARNING! clockshift = %i, less than "
239     "N_SAFE_BINTRANS_LIMIT_SHIFT (%i)\n",
240     clockshift, N_SAFE_BINTRANS_LIMIT_SHIFT);
241    
242     machine->ticks_till_next[n] = 0;
243     machine->ticks_reset_value[n] = 1 << clockshift;
244     machine->tick_func[n] = func;
245     machine->tick_extra[n] = extra;
246    
247     machine->n_tick_entries ++;
248     }
249    
250    
251     /****************************************************************************
252     * *
253     * Helper functions *
254     * *
255     ****************************************************************************/
256    
257    
258     int int_to_bcd(int i)
259     {
260     return (i/10) * 16 + (i % 10);
261     }
262    
263    
264     /*
265     * dump_mem_string():
266     *
267     * Dump the contents of emulated RAM as readable text. Bytes that aren't
268     * readable are dumped in [xx] notation, where xx is in hexadecimal.
269     * Dumping ends after DUMP_MEM_STRING_MAX bytes, or when a terminating
270     * zero byte is found.
271     */
272     #define DUMP_MEM_STRING_MAX 45
273     void dump_mem_string(struct cpu *cpu, uint64_t addr)
274     {
275     int i;
276     for (i=0; i<DUMP_MEM_STRING_MAX; i++) {
277     unsigned char ch = '\0';
278    
279     cpu->memory_rw(cpu, cpu->mem, addr + i, &ch, sizeof(ch),
280     MEM_READ, CACHE_DATA | NO_EXCEPTIONS);
281     if (ch == '\0')
282     return;
283     if (ch >= ' ' && ch < 126)
284     debug("%c", ch);
285     else
286     debug("[%02x]", ch);
287     }
288     }
289    
290    
291     /*
292     * store_byte():
293     *
294     * Stores a byte in emulated ram. (Helper function.)
295     */
296     void store_byte(struct cpu *cpu, uint64_t addr, uint8_t data)
297     {
298     if ((addr >> 32) == 0)
299     addr = (int64_t)(int32_t)addr;
300     cpu->memory_rw(cpu, cpu->mem,
301     addr, &data, sizeof(data), MEM_WRITE, CACHE_DATA);
302     }
303    
304    
305     /*
306     * store_string():
307     *
308     * Stores chars into emulated RAM until a zero byte (string terminating
309     * character) is found. The zero byte is also copied.
310     * (strcpy()-like helper function, host-RAM-to-emulated-RAM.)
311     */
312     void store_string(struct cpu *cpu, uint64_t addr, char *s)
313     {
314     do {
315     store_byte(cpu, addr++, *s);
316     } while (*s++);
317     }
318    
319    
320     /*
321     * add_environment_string():
322     *
323     * Like store_string(), but advances the pointer afterwards. The most
324     * obvious use is to place a number of strings (such as environment variable
325     * strings) after one-another in emulated memory.
326     */
327     void add_environment_string(struct cpu *cpu, char *s, uint64_t *addr)
328     {
329     store_string(cpu, *addr, s);
330     (*addr) += strlen(s) + 1;
331     }
332    
333    
334     /*
335     * store_64bit_word():
336     *
337     * Stores a 64-bit word in emulated RAM. Byte order is taken into account.
338     * Helper function.
339     */
340     int store_64bit_word(struct cpu *cpu, uint64_t addr, uint64_t data64)
341     {
342     unsigned char data[8];
343     if ((addr >> 32) == 0)
344     addr = (int64_t)(int32_t)addr;
345     data[0] = (data64 >> 56) & 255;
346     data[1] = (data64 >> 48) & 255;
347     data[2] = (data64 >> 40) & 255;
348     data[3] = (data64 >> 32) & 255;
349     data[4] = (data64 >> 24) & 255;
350     data[5] = (data64 >> 16) & 255;
351     data[6] = (data64 >> 8) & 255;
352     data[7] = (data64) & 255;
353     if (cpu->byte_order == EMUL_LITTLE_ENDIAN) {
354     int tmp = data[0]; data[0] = data[7]; data[7] = tmp;
355     tmp = data[1]; data[1] = data[6]; data[6] = tmp;
356     tmp = data[2]; data[2] = data[5]; data[5] = tmp;
357     tmp = data[3]; data[3] = data[4]; data[4] = tmp;
358     }
359     return cpu->memory_rw(cpu, cpu->mem,
360     addr, data, sizeof(data), MEM_WRITE, CACHE_DATA);
361     }
362    
363    
364     /*
365     * store_32bit_word():
366     *
367     * Stores a 32-bit word in emulated RAM. Byte order is taken into account.
368     * (This function takes a 64-bit word as argument, to suppress some
369     * warnings, but only the lowest 32 bits are used.)
370     */
371     int store_32bit_word(struct cpu *cpu, uint64_t addr, uint64_t data32)
372     {
373     unsigned char data[4];
374     if ((addr >> 32) == 0)
375     addr = (int64_t)(int32_t)addr;
376     data[0] = (data32 >> 24) & 255;
377     data[1] = (data32 >> 16) & 255;
378     data[2] = (data32 >> 8) & 255;
379     data[3] = (data32) & 255;
380     if (cpu->byte_order == EMUL_LITTLE_ENDIAN) {
381     int tmp = data[0]; data[0] = data[3]; data[3] = tmp;
382     tmp = data[1]; data[1] = data[2]; data[2] = tmp;
383     }
384     return cpu->memory_rw(cpu, cpu->mem,
385     addr, data, sizeof(data), MEM_WRITE, CACHE_DATA);
386     }
387    
388    
389     /*
390     * store_16bit_word():
391     *
392     * Stores a 16-bit word in emulated RAM. Byte order is taken into account.
393     * (This function takes a 64-bit word as argument, to suppress some
394     * warnings, but only the lowest 16 bits are used.)
395     */
396     int store_16bit_word(struct cpu *cpu, uint64_t addr, uint64_t data16)
397     {
398     unsigned char data[2];
399     if ((addr >> 32) == 0)
400     addr = (int64_t)(int32_t)addr;
401     data[0] = (data16 >> 8) & 255;
402     data[1] = (data16) & 255;
403     if (cpu->byte_order == EMUL_LITTLE_ENDIAN) {
404     int tmp = data[0]; data[0] = data[1]; data[1] = tmp;
405     }
406     return cpu->memory_rw(cpu, cpu->mem,
407     addr, data, sizeof(data), MEM_WRITE, CACHE_DATA);
408     }
409    
410    
411     /*
412     * store_buf():
413     *
414     * memcpy()-like helper function, from host RAM to emulated RAM.
415     */
416     void store_buf(struct cpu *cpu, uint64_t addr, char *s, size_t len)
417     {
418     if ((addr >> 32) == 0)
419     addr = (int64_t)(int32_t)addr;
420     if ((addr & 7) == 0 && (((size_t)s) & 7) == 0) {
421     while (len >= 8) {
422     cpu->memory_rw(cpu, cpu->mem, addr, (unsigned char *)s,
423     8, MEM_WRITE, CACHE_DATA);
424     addr += 8;
425     s += 8;
426     len -= 8;
427     }
428     }
429    
430     if ((addr & 3) == 0 && (((size_t)s) & 3) == 0) {
431     while (len >= 4) {
432     cpu->memory_rw(cpu, cpu->mem, addr, (unsigned char *)s,
433     4, MEM_WRITE, CACHE_DATA);
434     addr += 4;
435     s += 4;
436     len -= 4;
437     }
438     }
439    
440     while (len-- != 0)
441     store_byte(cpu, addr++, *s++);
442     }
443    
444    
445     /*
446     * store_pointer_and_advance():
447     *
448     * Stores a 32-bit or 64-bit pointer in emulated RAM, and advances the
449     * target address. (Used by ARC and SGI initialization.)
450     */
451     void store_pointer_and_advance(struct cpu *cpu, uint64_t *addrp,
452     uint64_t data, int flag64)
453     {
454     uint64_t addr = *addrp;
455     if (flag64) {
456     store_64bit_word(cpu, addr, data);
457     addr += 8;
458     } else {
459     store_32bit_word(cpu, addr, data);
460     addr += 4;
461     }
462     *addrp = addr;
463     }
464    
465    
466     /*
467     * load_32bit_word():
468     *
469     * Helper function. Prints a warning and returns 0, if the read failed.
470     * Emulated byte order is taken into account.
471     */
472     uint32_t load_32bit_word(struct cpu *cpu, uint64_t addr)
473     {
474     unsigned char data[4];
475    
476     if ((addr >> 32) == 0)
477     addr = (int64_t)(int32_t)addr;
478     cpu->memory_rw(cpu, cpu->mem,
479     addr, data, sizeof(data), MEM_READ, CACHE_DATA);
480    
481     if (cpu->byte_order == EMUL_LITTLE_ENDIAN) {
482     int tmp = data[0]; data[0] = data[3]; data[3] = tmp;
483     tmp = data[1]; data[1] = data[2]; data[2] = tmp;
484     }
485    
486     return (data[0] << 24) + (data[1] << 16) + (data[2] << 8) + data[3];
487     }
488    
489    
490     /*
491 dpavlin 4 * load_16bit_word():
492     *
493     * Helper function. Prints a warning and returns 0, if the read failed.
494     * Emulated byte order is taken into account.
495     */
496     uint16_t load_16bit_word(struct cpu *cpu, uint64_t addr)
497     {
498     unsigned char data[2];
499    
500     if ((addr >> 32) == 0)
501     addr = (int64_t)(int32_t)addr;
502     cpu->memory_rw(cpu, cpu->mem,
503     addr, data, sizeof(data), MEM_READ, CACHE_DATA);
504    
505     if (cpu->byte_order == EMUL_LITTLE_ENDIAN) {
506     int tmp = data[0]; data[0] = data[1]; data[1] = tmp;
507     }
508    
509     return (data[0] << 8) + data[1];
510     }
511    
512    
513     /*
514 dpavlin 2 * store_64bit_word_in_host():
515     *
516     * Stores a 64-bit word in the _host's_ RAM. Emulated byte order is taken
517     * into account. This is useful when building structs in the host's RAM
518     * which will later be copied into emulated RAM.
519     */
520     void store_64bit_word_in_host(struct cpu *cpu,
521     unsigned char *data, uint64_t data64)
522     {
523     data[0] = (data64 >> 56) & 255;
524     data[1] = (data64 >> 48) & 255;
525     data[2] = (data64 >> 40) & 255;
526     data[3] = (data64 >> 32) & 255;
527     data[4] = (data64 >> 24) & 255;
528     data[5] = (data64 >> 16) & 255;
529     data[6] = (data64 >> 8) & 255;
530     data[7] = (data64) & 255;
531     if (cpu->byte_order == EMUL_LITTLE_ENDIAN) {
532     int tmp = data[0]; data[0] = data[7]; data[7] = tmp;
533     tmp = data[1]; data[1] = data[6]; data[6] = tmp;
534     tmp = data[2]; data[2] = data[5]; data[5] = tmp;
535     tmp = data[3]; data[3] = data[4]; data[4] = tmp;
536     }
537     }
538    
539    
540     /*
541     * store_32bit_word_in_host():
542     *
543     * See comment for store_64bit_word_in_host().
544     *
545     * (Note: The data32 parameter is a uint64_t. This is done to suppress
546     * some warnings.)
547     */
548     void store_32bit_word_in_host(struct cpu *cpu,
549     unsigned char *data, uint64_t data32)
550     {
551     data[0] = (data32 >> 24) & 255;
552     data[1] = (data32 >> 16) & 255;
553     data[2] = (data32 >> 8) & 255;
554     data[3] = (data32) & 255;
555     if (cpu->byte_order == EMUL_LITTLE_ENDIAN) {
556     int tmp = data[0]; data[0] = data[3]; data[3] = tmp;
557     tmp = data[1]; data[1] = data[2]; data[2] = tmp;
558     }
559     }
560    
561    
562     /*
563     * store_16bit_word_in_host():
564     *
565     * See comment for store_64bit_word_in_host().
566     */
567     void store_16bit_word_in_host(struct cpu *cpu,
568     unsigned char *data, uint16_t data16)
569     {
570     data[0] = (data16 >> 8) & 255;
571     data[1] = (data16) & 255;
572     if (cpu->byte_order == EMUL_LITTLE_ENDIAN) {
573     int tmp = data[0]; data[0] = data[1]; data[1] = tmp;
574     }
575     }
576    
577    
578     /****************************************************************************
579     * *
580     * Machine dependant Interrupt routines *
581     * *
582     ****************************************************************************/
583    
584    
585     /*
586     * DECstation KN02 interrupts:
587     */
588     void kn02_interrupt(struct machine *m, struct cpu *cpu, int irq_nr, int assrt)
589     {
590     int current;
591    
592     irq_nr -= 8;
593     irq_nr &= 0xff;
594    
595     if (assrt) {
596     /* OR in the irq_nr into the CSR: */
597     m->kn02_csr->csr[0] |= irq_nr;
598     } else {
599     /* AND out the irq_nr from the CSR: */
600     m->kn02_csr->csr[0] &= ~irq_nr;
601     }
602    
603     current = m->kn02_csr->csr[0] & m->kn02_csr->csr[2];
604     if (current == 0)
605     cpu_interrupt_ack(cpu, 2);
606     else
607     cpu_interrupt(cpu, 2);
608     }
609    
610    
611     /*
612     * DECstation KMIN interrupts:
613     *
614     * TC slot 3 = system slot.
615     */
616     void kmin_interrupt(struct machine *m, struct cpu *cpu, int irq_nr, int assrt)
617     {
618     irq_nr -= 8;
619     /* debug("kmin_interrupt(): irq_nr=%i assrt=%i\n", irq_nr, assrt); */
620    
621     if (assrt)
622     m->dec_ioasic_data->reg[(IOASIC_INTR - IOASIC_SLOT_1_START) / 0x10] |= irq_nr;
623     else
624     m->dec_ioasic_data->reg[(IOASIC_INTR - IOASIC_SLOT_1_START) / 0x10] &= ~irq_nr;
625    
626     if (m->dec_ioasic_data->reg[(IOASIC_INTR - IOASIC_SLOT_1_START) / 0x10]
627     & m->dec_ioasic_data->reg[(IOASIC_IMSK - IOASIC_SLOT_1_START) / 0x10])
628     cpu_interrupt(cpu, KMIN_INT_TC3);
629     else
630     cpu_interrupt_ack(cpu, KMIN_INT_TC3);
631     }
632    
633    
634     /*
635     * DECstation KN03 interrupts:
636     */
637     void kn03_interrupt(struct machine *m, struct cpu *cpu, int irq_nr, int assrt)
638     {
639     irq_nr -= 8;
640     /* debug("kn03_interrupt(): irq_nr=0x%x assrt=%i\n", irq_nr, assrt); */
641    
642     if (assrt)
643     m->dec_ioasic_data->reg[(IOASIC_INTR - IOASIC_SLOT_1_START) / 0x10] |= irq_nr;
644     else
645     m->dec_ioasic_data->reg[(IOASIC_INTR - IOASIC_SLOT_1_START) / 0x10] &= ~irq_nr;
646    
647     if (m->dec_ioasic_data->reg[(IOASIC_INTR - IOASIC_SLOT_1_START) / 0x10]
648     & m->dec_ioasic_data->reg[(IOASIC_IMSK - IOASIC_SLOT_1_START) / 0x10])
649     cpu_interrupt(cpu, KN03_INT_ASIC);
650     else
651     cpu_interrupt_ack(cpu, KN03_INT_ASIC);
652     }
653    
654    
655     /*
656     * DECstation MAXINE interrupts:
657     */
658     void maxine_interrupt(struct machine *m, struct cpu *cpu,
659     int irq_nr, int assrt)
660     {
661     irq_nr -= 8;
662     debug("maxine_interrupt(): irq_nr=0x%x assrt=%i\n", irq_nr, assrt);
663    
664     if (assrt)
665     m->dec_ioasic_data->reg[(IOASIC_INTR - IOASIC_SLOT_1_START)
666     / 0x10] |= irq_nr;
667     else
668     m->dec_ioasic_data->reg[(IOASIC_INTR - IOASIC_SLOT_1_START)
669     / 0x10] &= ~irq_nr;
670    
671     if (m->dec_ioasic_data->reg[(IOASIC_INTR - IOASIC_SLOT_1_START) / 0x10]
672     & m->dec_ioasic_data->reg[(IOASIC_IMSK - IOASIC_SLOT_1_START)
673     / 0x10])
674     cpu_interrupt(cpu, XINE_INT_TC3);
675     else
676     cpu_interrupt_ack(cpu, XINE_INT_TC3);
677     }
678    
679    
680     /*
681     * DECstation KN230 interrupts:
682     */
683     void kn230_interrupt(struct machine *m, struct cpu *cpu, int irq_nr, int assrt)
684     {
685     int r2 = 0;
686    
687     m->kn230_csr->csr |= irq_nr;
688    
689     switch (irq_nr) {
690     case KN230_CSR_INTR_SII:
691     case KN230_CSR_INTR_LANCE:
692     r2 = 3;
693     break;
694     case KN230_CSR_INTR_DZ0:
695     case KN230_CSR_INTR_OPT0:
696     case KN230_CSR_INTR_OPT1:
697     r2 = 2;
698     break;
699     default:
700     fatal("kn230_interrupt(): irq_nr = %i ?\n", irq_nr);
701     }
702    
703     if (assrt) {
704     /* OR in the irq_nr mask into the CSR: */
705     m->kn230_csr->csr |= irq_nr;
706    
707     /* Assert MIPS interrupt 2 or 3: */
708     cpu_interrupt(cpu, r2);
709     } else {
710     /* AND out the irq_nr mask from the CSR: */
711     m->kn230_csr->csr &= ~irq_nr;
712    
713     /* If the CSR interrupt bits are all zero,
714     clear the bit in the cause register as well. */
715     if (r2 == 2) {
716     /* irq 2: */
717     if ((m->kn230_csr->csr & (KN230_CSR_INTR_DZ0
718     | KN230_CSR_INTR_OPT0 | KN230_CSR_INTR_OPT1)) == 0)
719     cpu_interrupt_ack(cpu, r2);
720     } else {
721     /* irq 3: */
722     if ((m->kn230_csr->csr & (KN230_CSR_INTR_SII |
723     KN230_CSR_INTR_LANCE)) == 0)
724     cpu_interrupt_ack(cpu, r2);
725     }
726     }
727     }
728    
729    
730     /*
731     * Jazz interrupts (for Acer PICA-61 etc):
732     *
733     * 0..7 MIPS interrupts
734     * 8 + x, where x = 0..15 Jazz interrupts
735     * 8 + x, where x = 16..31 ISA interrupt (irq nr + 16)
736     */
737     void jazz_interrupt(struct machine *m, struct cpu *cpu, int irq_nr, int assrt)
738     {
739     uint32_t irq;
740     int isa = 0;
741    
742     irq_nr -= 8;
743    
744     /* debug("jazz_interrupt() irq_nr = %i, assrt = %i\n",
745     irq_nr, assrt); */
746    
747     if (irq_nr >= 16) {
748     isa = 1;
749     irq_nr -= 16;
750     }
751    
752     irq = 1 << irq_nr;
753    
754     if (isa) {
755     if (assrt)
756     m->jazz_data->isa_int_asserted |= irq;
757     else
758     m->jazz_data->isa_int_asserted &= ~irq;
759     } else {
760     if (assrt)
761     m->jazz_data->int_asserted |= irq;
762     else
763     m->jazz_data->int_asserted &= ~irq;
764     }
765    
766     /* debug(" %08x %08x\n", m->jazz_data->int_asserted,
767     m->jazz_data->int_enable_mask); */
768     /* debug(" %08x %08x\n", m->jazz_data->isa_int_asserted,
769     m->jazz_data->isa_int_enable_mask); */
770    
771     if (m->jazz_data->int_asserted /* & m->jazz_data->int_enable_mask */
772     & ~0x8000 )
773     cpu_interrupt(cpu, 3);
774     else
775     cpu_interrupt_ack(cpu, 3);
776    
777     if (m->jazz_data->isa_int_asserted & m->jazz_data->isa_int_enable_mask)
778     cpu_interrupt(cpu, 4);
779     else
780     cpu_interrupt_ack(cpu, 4);
781    
782     /* TODO: this "15" (0x8000) is the timer... fix this? */
783     if (m->jazz_data->int_asserted & 0x8000)
784     cpu_interrupt(cpu, 6);
785     else
786     cpu_interrupt_ack(cpu, 6);
787     }
788    
789    
790     /*
791     * VR41xx interrupt routine:
792     *
793     * irq_nr = 8 + x
794     * x = 0..15 for level1
795     * x = 16..31 for level2
796     * x = 32+y for GIU interrupt y
797     */
798     void vr41xx_interrupt(struct machine *m, struct cpu *cpu,
799     int irq_nr, int assrt)
800     {
801     int giu_irq = 0;
802    
803     irq_nr -= 8;
804     if (irq_nr >= 32) {
805     giu_irq = irq_nr - 32;
806    
807     if (assrt)
808     m->vr41xx_data->giuint |= (1 << giu_irq);
809     else
810     m->vr41xx_data->giuint &= ~(1 << giu_irq);
811     }
812    
813     /* TODO: This is wrong. What about GIU bit 8? */
814    
815     if (irq_nr != 8) {
816     /* If any GIU bit is asserted, then assert the main
817     GIU interrupt: */
818     if (m->vr41xx_data->giuint & m->vr41xx_data->giumask)
819     vr41xx_interrupt(m, cpu, 8 + 8, 1);
820     else
821     vr41xx_interrupt(m, cpu, 8 + 8, 0);
822     }
823    
824     /* debug("vr41xx_interrupt(): irq_nr=%i assrt=%i\n",
825     irq_nr, assrt); */
826    
827     if (irq_nr < 16) {
828     if (assrt)
829     m->vr41xx_data->sysint1 |= (1 << irq_nr);
830     else
831     m->vr41xx_data->sysint1 &= ~(1 << irq_nr);
832     } else if (irq_nr < 32) {
833     irq_nr -= 16;
834     if (assrt)
835     m->vr41xx_data->sysint2 |= (1 << irq_nr);
836     else
837     m->vr41xx_data->sysint2 &= ~(1 << irq_nr);
838     }
839    
840     /* TODO: Which hardware interrupt pin? */
841    
842     /* debug(" sysint1=%04x mask=%04x, sysint2=%04x mask=%04x\n",
843     m->vr41xx_data->sysint1, m->vr41xx_data->msysint1,
844     m->vr41xx_data->sysint2, m->vr41xx_data->msysint2); */
845    
846     if ((m->vr41xx_data->sysint1 & m->vr41xx_data->msysint1) |
847     (m->vr41xx_data->sysint2 & m->vr41xx_data->msysint2))
848     cpu_interrupt(cpu, 2);
849     else
850     cpu_interrupt_ack(cpu, 2);
851     }
852    
853    
854     /*
855     * Playstation 2 interrupt routine:
856 dpavlin 4 *
857     * irq_nr = 8 + x normal irq x
858     * 8 + 16 + y dma irq y
859     * 8 + 32 + 0 sbus irq 0 (pcmcia)
860     * 8 + 32 + 1 sbus irq 1 (usb)
861 dpavlin 2 */
862     void ps2_interrupt(struct machine *m, struct cpu *cpu, int irq_nr, int assrt)
863     {
864     irq_nr -= 8;
865     debug("ps2_interrupt(): irq_nr=0x%x assrt=%i\n", irq_nr, assrt);
866    
867 dpavlin 4 if (irq_nr >= 32) {
868     int msk = 0;
869     switch (irq_nr - 32) {
870     case 0: /* PCMCIA: */
871     msk = 0x100;
872     break;
873     case 1: /* USB: */
874     msk = 0x400;
875     break;
876     default:
877     fatal("ps2_interrupt(): bad irq_nr %i\n", irq_nr);
878     }
879    
880     if (assrt)
881     m->ps2_data->sbus_smflg |= msk;
882     else
883     m->ps2_data->sbus_smflg &= ~msk;
884    
885     if (m->ps2_data->sbus_smflg != 0)
886     cpu_interrupt(cpu, 8 + 1);
887     else
888     cpu_interrupt_ack(cpu, 8 + 1);
889     return;
890     }
891    
892 dpavlin 2 if (assrt) {
893     /* OR into the INTR: */
894 dpavlin 4 if (irq_nr < 16)
895     m->ps2_data->intr |= (1 << irq_nr);
896 dpavlin 2 else
897 dpavlin 4 m->ps2_data->dmac_reg[0x601] |= (1 << (irq_nr-16));
898 dpavlin 2 } else {
899     /* AND out of the INTR: */
900 dpavlin 4 if (irq_nr < 16)
901     m->ps2_data->intr &= ~(1 << irq_nr);
902 dpavlin 2 else
903 dpavlin 4 m->ps2_data->dmac_reg[0x601] &= ~(1 << (irq_nr-16));
904     }
905 dpavlin 2
906 dpavlin 4 /* TODO: Hm? How about the mask? */
907     if (m->ps2_data->intr /* & m->ps2_data->imask */ )
908     cpu_interrupt(cpu, 2);
909     else
910     cpu_interrupt_ack(cpu, 2);
911    
912     /* TODO: mask? */
913     if (m->ps2_data->dmac_reg[0x601] & 0xffff)
914     cpu_interrupt(cpu, 3);
915     else
916     cpu_interrupt_ack(cpu, 3);
917 dpavlin 2 }
918    
919    
920     /*
921     * SGI "IP22" interrupt routine:
922     */
923     void sgi_ip22_interrupt(struct machine *m, struct cpu *cpu,
924     int irq_nr, int assrt)
925     {
926     /*
927     * SGI-IP22 specific interrupt stuff:
928     *
929     * irq_nr should be 8 + x, where x = 0..31 for local0,
930     * and 32..63 for local1 interrupts.
931     * Add 64*y for "mappable" interrupts, where 1<<y is
932     * the mappable interrupt bitmask. TODO: this misses 64*0 !
933     */
934    
935     uint32_t newmask;
936     uint32_t stat, mask;
937    
938     irq_nr -= 8;
939     newmask = 1 << (irq_nr & 31);
940    
941     if (irq_nr >= 64) {
942     int ms = irq_nr / 64;
943     uint32_t new = 1 << ms;
944     if (assrt)
945     m->sgi_ip22_data->reg[4] |= new;
946     else
947     m->sgi_ip22_data->reg[4] &= ~new;
948     /* TODO: is this enough? */
949     irq_nr &= 63;
950     }
951    
952     if (irq_nr < 32) {
953     if (assrt)
954     m->sgi_ip22_data->reg[0] |= newmask;
955     else
956     m->sgi_ip22_data->reg[0] &= ~newmask;
957     } else {
958     if (assrt)
959     m->sgi_ip22_data->reg[2] |= newmask;
960     else
961     m->sgi_ip22_data->reg[2] &= ~newmask;
962     }
963    
964     /* Read stat and mask for local0: */
965     stat = m->sgi_ip22_data->reg[0];
966     mask = m->sgi_ip22_data->reg[1];
967     if ((stat & mask) == 0)
968     cpu_interrupt_ack(cpu, 2);
969     else
970     cpu_interrupt(cpu, 2);
971    
972     /* Read stat and mask for local1: */
973     stat = m->sgi_ip22_data->reg[2];
974     mask = m->sgi_ip22_data->reg[3];
975     if ((stat & mask) == 0)
976     cpu_interrupt_ack(cpu, 3);
977     else
978     cpu_interrupt(cpu, 3);
979     }
980    
981    
982     /*
983     * SGI "IP30" interrupt routine:
984     *
985     * irq_nr = 8 + 1 + nr, where nr is:
986     * 0..49 HEART irqs hardware irq 2,3,4
987     * 50 HEART timer hardware irq 5
988     * 51..63 HEART errors hardware irq 6
989     *
990     * according to Linux/IP30.
991     */
992     void sgi_ip30_interrupt(struct machine *m, struct cpu *cpu,
993     int irq_nr, int assrt)
994     {
995     uint64_t newmask;
996     uint64_t stat, mask;
997    
998     irq_nr -= 8;
999     if (irq_nr == 0)
1000     goto just_assert_and_such;
1001     irq_nr --;
1002    
1003     newmask = (int64_t)1 << irq_nr;
1004    
1005     if (assrt)
1006     m->sgi_ip30_data->isr |= newmask;
1007     else
1008     m->sgi_ip30_data->isr &= ~newmask;
1009    
1010     just_assert_and_such:
1011    
1012     cpu_interrupt_ack(cpu, 2);
1013     cpu_interrupt_ack(cpu, 3);
1014     cpu_interrupt_ack(cpu, 4);
1015     cpu_interrupt_ack(cpu, 5);
1016     cpu_interrupt_ack(cpu, 6);
1017    
1018     stat = m->sgi_ip30_data->isr;
1019     mask = m->sgi_ip30_data->imask0;
1020    
1021     if ((stat & mask) & 0x000000000000ffffULL)
1022     cpu_interrupt(cpu, 2);
1023     if ((stat & mask) & 0x00000000ffff0000ULL)
1024     cpu_interrupt(cpu, 3);
1025     if ((stat & mask) & 0x0003ffff00000000ULL)
1026     cpu_interrupt(cpu, 4);
1027     if ((stat & mask) & 0x0004000000000000ULL)
1028     cpu_interrupt(cpu, 5);
1029     if ((stat & mask) & 0xfff8000000000000ULL)
1030     cpu_interrupt(cpu, 6);
1031     }
1032    
1033    
1034     /*
1035     * SGI "IP32" interrupt routine:
1036     */
1037     void sgi_ip32_interrupt(struct machine *m, struct cpu *cpu,
1038     int irq_nr, int assrt)
1039     {
1040     /*
1041     * The 64-bit word at crime offset 0x10 is CRIME_INTSTAT,
1042     * which contains the current interrupt bits. CRIME_INTMASK
1043     * contains a mask of which bits are actually in use.
1044     *
1045     * crime hardcoded at 0x14000000, for SGI-IP32.
1046     * If any of these bits are asserted, then physical MIPS
1047     * interrupt 2 should be asserted.
1048     *
1049     * TODO: how should all this be done nicely?
1050     *
1051     * TODO: mace interrupt mask
1052     */
1053    
1054     uint64_t crime_addr = CRIME_INTSTAT;
1055     uint64_t mace_addr = 0x14;
1056     uint64_t crime_interrupts, crime_interrupts_mask, mace_interrupts;
1057     unsigned int i;
1058     unsigned char x[8];
1059    
1060     /*
1061     * This mapping of both MACE and CRIME interrupts into the same
1062     * 'int' is really ugly.
1063     *
1064     * If MACE_PERIPH_MISC or MACE_PERIPH_SERIAL is set, then mask
1065     * that bit out and treat the rest of the word as the mace interrupt
1066     * bitmask.
1067     *
1068     * TODO: fix.
1069     */
1070     if (irq_nr & MACE_PERIPH_SERIAL) {
1071     /* Read current MACE interrupt bits: */
1072     memcpy(x, m->mace_data->reg + mace_addr, sizeof(uint32_t));
1073     mace_interrupts = 0;
1074     for (i=0; i<sizeof(uint32_t); i++) {
1075     /* SGI is big-endian... */
1076     mace_interrupts <<= 8;
1077     mace_interrupts |= x[i];
1078     }
1079    
1080     if (assrt)
1081     mace_interrupts |= (irq_nr & ~MACE_PERIPH_SERIAL);
1082     else
1083     mace_interrupts &= ~(irq_nr & ~MACE_PERIPH_SERIAL);
1084    
1085     /* Write back MACE interrupt bits: */
1086     for (i=0; i<4; i++)
1087     x[3-i] = mace_interrupts >> (i*8);
1088     memcpy(m->mace_data->reg + mace_addr, x, sizeof(uint32_t));
1089    
1090     irq_nr = MACE_PERIPH_SERIAL;
1091     if (mace_interrupts == 0)
1092     assrt = 0;
1093     else
1094     assrt = 1;
1095     }
1096    
1097     /* Hopefully _MISC and _SERIAL will not be both on at the same time. */
1098     if (irq_nr & MACE_PERIPH_MISC) {
1099     /* Read current MACE interrupt bits: */
1100     memcpy(x, m->mace_data->reg + mace_addr, sizeof(uint32_t));
1101     mace_interrupts = 0;
1102     for (i=0; i<sizeof(uint32_t); i++) {
1103     /* SGI is big-endian... */
1104     mace_interrupts <<= 8;
1105     mace_interrupts |= x[i];
1106     }
1107    
1108     if (assrt)
1109     mace_interrupts |= (irq_nr & ~MACE_PERIPH_MISC);
1110     else
1111     mace_interrupts &= ~(irq_nr & ~MACE_PERIPH_MISC);
1112    
1113     /* Write back MACE interrupt bits: */
1114     for (i=0; i<4; i++)
1115     x[3-i] = mace_interrupts >> (i*8);
1116     memcpy(m->mace_data->reg + mace_addr, x, sizeof(uint32_t));
1117    
1118     irq_nr = MACE_PERIPH_MISC;
1119     if (mace_interrupts == 0)
1120     assrt = 0;
1121     else
1122     assrt = 1;
1123     }
1124    
1125     /* Read CRIME_INTSTAT: */
1126     memcpy(x, m->crime_data->reg + crime_addr, sizeof(uint64_t));
1127     crime_interrupts = 0;
1128     for (i=0; i<8; i++) {
1129     /* SGI is big-endian... */
1130     crime_interrupts <<= 8;
1131     crime_interrupts |= x[i];
1132     }
1133    
1134     if (assrt)
1135     crime_interrupts |= irq_nr;
1136     else
1137     crime_interrupts &= ~irq_nr;
1138    
1139     /* Write back CRIME_INTSTAT: */
1140     for (i=0; i<8; i++)
1141     x[7-i] = crime_interrupts >> (i*8);
1142     memcpy(m->crime_data->reg + crime_addr, x, sizeof(uint64_t));
1143    
1144     /* Read CRIME_INTMASK: */
1145     memcpy(x, m->crime_data->reg + CRIME_INTMASK, sizeof(uint64_t));
1146     crime_interrupts_mask = 0;
1147     for (i=0; i<8; i++) {
1148     crime_interrupts_mask <<= 8;
1149     crime_interrupts_mask |= x[i];
1150     }
1151    
1152     if ((crime_interrupts & crime_interrupts_mask) == 0)
1153     cpu_interrupt_ack(cpu, 2);
1154     else
1155     cpu_interrupt(cpu, 2);
1156    
1157     /* printf("sgi_crime_machine_irq(%i,%i): new interrupts = 0x%08x\n", assrt, irq_nr, crime_interrupts); */
1158     }
1159    
1160    
1161     /*
1162     * Au1x00 interrupt routine:
1163     *
1164     * TODO: This is just bogus so far. For more info, read this:
1165     * http://www.meshcube.org/cgi-bin/viewcvs.cgi/kernel/linux/arch/mips/au1000/common/
1166     *
1167     * CPU int 2 = IC 0, request 0
1168     * CPU int 3 = IC 0, request 1
1169     * CPU int 4 = IC 1, request 0
1170     * CPU int 5 = IC 1, request 1
1171     *
1172     * Interrupts 0..31 are on interrupt controller 0, interrupts 32..63 are
1173     * on controller 1.
1174     *
1175     * Special case: if irq_nr == 64+8, then this just updates the CPU
1176     * interrupt assertions.
1177     */
1178     void au1x00_interrupt(struct machine *m, struct cpu *cpu,
1179     int irq_nr, int assrt)
1180     {
1181     uint32_t ms;
1182    
1183     irq_nr -= 8;
1184     debug("au1x00_interrupt(): irq_nr=%i assrt=%i\n", irq_nr, assrt);
1185    
1186     if (irq_nr < 64) {
1187     ms = 1 << (irq_nr & 31);
1188    
1189     if (assrt)
1190     m->au1x00_ic_data->request0_int |= ms;
1191     else
1192     m->au1x00_ic_data->request0_int &= ~ms;
1193    
1194     /* TODO: Controller 1 */
1195     }
1196    
1197     if ((m->au1x00_ic_data->request0_int &
1198     m->au1x00_ic_data->mask) != 0)
1199     cpu_interrupt(cpu, 2);
1200     else
1201     cpu_interrupt_ack(cpu, 2);
1202    
1203     /* TODO: What _is_ request1? */
1204    
1205     /* TODO: Controller 1 */
1206     }
1207    
1208    
1209     /****************************************************************************
1210     * *
1211     * Machine dependant Initialization routines *
1212     * *
1213     ****************************************************************************/
1214    
1215    
1216     /*
1217     * machine_setup():
1218     *
1219     * This (rather large) function initializes memory, registers, and/or devices
1220     * required by specific machine emulations.
1221     */
1222     void machine_setup(struct machine *machine)
1223     {
1224     uint64_t addr, addr2;
1225     int i, j;
1226     struct memory *mem;
1227     char tmpstr[1000];
1228    
1229     /* DECstation: */
1230     char *framebuffer_console_name, *serial_console_name;
1231     int color_fb_flag;
1232     int boot_scsi_boardnumber = 3, boot_net_boardnumber = 3;
1233     char *turbochannel_default_gfx_card = "PMAG-BA";
1234     /* PMAG-AA, -BA, -CA/DA/EA/FA, -JA, -RO, PMAGB-BA */
1235    
1236     /* HPCmips: */
1237     struct xx {
1238     struct btinfo_magic a;
1239     struct btinfo_bootpath b;
1240     struct btinfo_symtab c;
1241     } xx;
1242     struct hpc_bootinfo hpc_bootinfo;
1243     uint64_t hpcmips_fb_addr = 0;
1244     int hpcmips_fb_bits = 0, hpcmips_fb_encoding = 0;
1245     int hpcmips_fb_xsize = 0;
1246     int hpcmips_fb_ysize = 0;
1247     int hpcmips_fb_xsize_mem = 0;
1248     int hpcmips_fb_ysize_mem = 0;
1249    
1250     /* ARCBIOS stuff: */
1251     struct arcbios_spb arcbios_spb;
1252     struct arcbios_spb_64 arcbios_spb_64;
1253     struct arcbios_sysid arcbios_sysid;
1254     struct arcbios_dsp_stat arcbios_dsp_stat;
1255     uint64_t mem_base, mem_count;
1256     uint64_t system = 0;
1257     uint64_t sgi_ram_offset = 0;
1258     uint64_t arc_reserved;
1259     int arc_wordlen = sizeof(uint32_t);
1260     char *short_machine_name = NULL;
1261     char *eaddr_string = "eaddr=10:20:30:40:50:60"; /* nonsense */
1262     unsigned char macaddr[6];
1263    
1264     /* Generic bootstring stuff: */
1265     int bootdev_id = diskimage_bootdev(machine);
1266     char *bootstr = NULL;
1267     char *bootarg = NULL;
1268     char *init_bootpath;
1269    
1270     /* PCI stuff: */
1271     struct pci_data *pci_data;
1272    
1273     /* Framebuffer stuff: */
1274     struct vfb_data *fb;
1275    
1276     /* Abreviation: :-) */
1277     struct cpu *cpu = machine->cpus[machine->bootstrap_cpu];
1278    
1279    
1280     mem = cpu->mem;
1281     machine->machine_name = NULL;
1282    
1283     /* TODO: Move this somewhere else? */
1284     if (machine->boot_string_argument == NULL) {
1285     switch (machine->machine_type) {
1286     case MACHINE_ARC:
1287     machine->boot_string_argument = "-aN";
1288     break;
1289     case MACHINE_DEC:
1290     machine->boot_string_argument = "-a";
1291     break;
1292     default:
1293     /* Important, because boot_string_argument should
1294     not be set to NULL: */
1295     machine->boot_string_argument = "";
1296     }
1297     }
1298    
1299     switch (machine->machine_type) {
1300    
1301     case MACHINE_NONE:
1302     printf("\nNo emulation type specified.\n");
1303     exit(1);
1304    
1305     case MACHINE_BAREMIPS:
1306     /*
1307     * A "bare" MIPS test machine.
1308     *
1309     * NOTE: NO devices at all.
1310     */
1311     cpu->byte_order = EMUL_BIG_ENDIAN;
1312     machine->machine_name = "\"Bare\" MIPS machine";
1313     break;
1314    
1315     case MACHINE_TESTMIPS:
1316     /*
1317     * A MIPS test machine (which happens to work with my
1318     * thesis work).
1319     */
1320     cpu->byte_order = EMUL_BIG_ENDIAN;
1321     machine->machine_name = "MIPS test machine";
1322    
1323     machine->main_console_handle = dev_cons_init(
1324     machine, mem, DEV_CONS_ADDRESS, "console", 2);
1325    
1326     snprintf(tmpstr, sizeof(tmpstr) - 1, "mp addr=0x%llx",
1327     (long long)DEV_MP_ADDRESS);
1328     device_add(machine, tmpstr);
1329    
1330     fb = dev_fb_init(machine, mem, 0x12000000, VFB_GENERIC,
1331     640,480, 640,480, 24, "generic", 1);
1332     break;
1333    
1334     case MACHINE_DEC:
1335     cpu->byte_order = EMUL_LITTLE_ENDIAN;
1336    
1337     /* An R2020 or R3220 memory thingy: */
1338     cpu->cd.mips.coproc[3] = mips_coproc_new(cpu, 3);
1339    
1340     /* There aren't really any good standard values... */
1341     framebuffer_console_name = "osconsole=0,3";
1342     serial_console_name = "osconsole=1";
1343    
1344     switch (machine->machine_subtype) {
1345     case MACHINE_DEC_PMAX_3100: /* type 1, KN01 */
1346     /* Supposed to have 12MHz or 16.67MHz R2000 CPU, R2010 FPC, R2020 Memory coprocessor */
1347     machine->machine_name = "DEC PMAX 3100 (KN01)";
1348    
1349     /* 12 MHz for 2100, 16.67 MHz for 3100 */
1350     if (machine->emulated_hz == 0)
1351     machine->emulated_hz = 16670000;
1352    
1353     if (machine->physical_ram_in_mb > 24)
1354     fprintf(stderr, "WARNING! Real DECstation 3100 machines cannot have more than 24MB RAM. Continuing anyway.\n");
1355    
1356     if ((machine->physical_ram_in_mb % 4) != 0)
1357     fprintf(stderr, "WARNING! Real DECstation 3100 machines have an integer multiple of 4 MBs of RAM. Continuing anyway.\n");
1358    
1359     color_fb_flag = 1; /* 1 for color, 0 for mono. TODO: command line option? */
1360    
1361     /*
1362     * According to NetBSD/pmax:
1363     *
1364     * pm0 at ibus0 addr 0xfc00000: 1024x864x1 (or x8 for color)
1365     * dc0 at ibus0 addr 0x1c000000
1366     * le0 at ibus0 addr 0x18000000: address 00:00:00:00:00:00
1367     * sii0 at ibus0 addr 0x1a000000
1368     * mcclock0 at ibus0 addr 0x1d000000: mc146818 or compatible
1369     * 0x1e000000 = system status and control register
1370     */
1371     fb = dev_fb_init(machine, mem, KN01_PHYS_FBUF_START,
1372     color_fb_flag? VFB_DEC_VFB02 : VFB_DEC_VFB01,
1373     0,0,0,0,0, color_fb_flag? "VFB02":"VFB01", 1);
1374     dev_colorplanemask_init(mem, KN01_PHYS_COLMASK_START, &fb->color_plane_mask);
1375     dev_vdac_init(mem, KN01_SYS_VDAC, fb->rgb_palette, color_fb_flag);
1376     dev_le_init(machine, mem, KN01_SYS_LANCE, KN01_SYS_LANCE_B_START, KN01_SYS_LANCE_B_END, KN01_INT_LANCE, 4*1048576);
1377     dev_sii_init(machine, mem, KN01_SYS_SII, KN01_SYS_SII_B_START, KN01_SYS_SII_B_END, KN01_INT_SII);
1378     dev_dc7085_init(machine, mem, KN01_SYS_DZ, KN01_INT_DZ, machine->use_x11);
1379     dev_mc146818_init(machine, mem, KN01_SYS_CLOCK, KN01_INT_CLOCK, MC146818_DEC, 1);
1380     dev_kn01_csr_init(mem, KN01_SYS_CSR, color_fb_flag);
1381    
1382     framebuffer_console_name = "osconsole=0,3"; /* fb,keyb */
1383     serial_console_name = "osconsole=3"; /* 3 */
1384     break;
1385    
1386     case MACHINE_DEC_3MAX_5000: /* type 2, KN02 */
1387     /* Supposed to have 25MHz R3000 CPU, R3010 FPC, */
1388     /* and a R3220 Memory coprocessor */
1389     machine->machine_name = "DECstation 5000/200 (3MAX, KN02)";
1390    
1391     if (machine->emulated_hz == 0)
1392     machine->emulated_hz = 25000000;
1393    
1394     if (machine->physical_ram_in_mb < 8)
1395     fprintf(stderr, "WARNING! Real KN02 machines do not have less than 8MB RAM. Continuing anyway.\n");
1396     if (machine->physical_ram_in_mb > 480)
1397     fprintf(stderr, "WARNING! Real KN02 machines cannot have more than 480MB RAM. Continuing anyway.\n");
1398    
1399     /* An R3220 memory thingy: */
1400     cpu->cd.mips.coproc[3] = mips_coproc_new(cpu, 3);
1401    
1402     /*
1403     * According to NetBSD/pmax:
1404     * asc0 at tc0 slot 5 offset 0x0
1405     * le0 at tc0 slot 6 offset 0x0
1406     * ibus0 at tc0 slot 7 offset 0x0
1407     * dc0 at ibus0 addr 0x1fe00000
1408     * mcclock0 at ibus0 addr 0x1fe80000: mc146818
1409     *
1410     * kn02 shared irq numbers (IP) are offset by +8
1411     * in the emulator
1412     */
1413    
1414     /* KN02 interrupts: */
1415     machine->md_interrupt = kn02_interrupt;
1416    
1417     /*
1418     * TURBOchannel slots 0, 1, and 2 are free for
1419     * option cards. Let's put in zero or more graphics
1420     * boards:
1421     *
1422     * TODO: It's also possible to have larger graphics
1423     * cards that occupy several slots. How to solve
1424     * this nicely?
1425     */
1426     dev_turbochannel_init(machine, mem, 0,
1427     KN02_PHYS_TC_0_START, KN02_PHYS_TC_0_END,
1428     machine->n_gfx_cards >= 1?
1429     turbochannel_default_gfx_card : "",
1430     KN02_IP_SLOT0 +8);
1431    
1432     dev_turbochannel_init(machine, mem, 1,
1433     KN02_PHYS_TC_1_START, KN02_PHYS_TC_1_END,
1434     machine->n_gfx_cards >= 2?
1435     turbochannel_default_gfx_card : "",
1436     KN02_IP_SLOT1 +8);
1437    
1438     dev_turbochannel_init(machine, mem, 2,
1439     KN02_PHYS_TC_2_START, KN02_PHYS_TC_2_END,
1440     machine->n_gfx_cards >= 3?
1441     turbochannel_default_gfx_card : "",
1442     KN02_IP_SLOT2 +8);
1443    
1444     /* TURBOchannel slots 3 and 4 are reserved. */
1445    
1446     /* TURBOchannel slot 5 is PMAZ-AA ("asc" SCSI). */
1447     dev_turbochannel_init(machine, mem, 5,
1448     KN02_PHYS_TC_5_START, KN02_PHYS_TC_5_END,
1449     "PMAZ-AA", KN02_IP_SCSI +8);
1450    
1451     /* TURBOchannel slot 6 is PMAD-AA ("le" ethernet). */
1452     dev_turbochannel_init(machine, mem, 6,
1453     KN02_PHYS_TC_6_START, KN02_PHYS_TC_6_END,
1454     "PMAD-AA", KN02_IP_LANCE +8);
1455    
1456     /* TURBOchannel slot 7 is system stuff. */
1457     machine->main_console_handle =
1458     dev_dc7085_init(machine, mem,
1459     KN02_SYS_DZ, KN02_IP_DZ +8, machine->use_x11);
1460     dev_mc146818_init(machine, mem,
1461     KN02_SYS_CLOCK, KN02_INT_CLOCK, MC146818_DEC, 1);
1462    
1463     machine->kn02_csr =
1464     dev_kn02_init(cpu, mem, KN02_SYS_CSR);
1465    
1466     framebuffer_console_name = "osconsole=0,7";
1467     /* fb,keyb */
1468     serial_console_name = "osconsole=2";
1469     boot_scsi_boardnumber = 5;
1470     boot_net_boardnumber = 6; /* TODO: 3? */
1471     break;
1472    
1473     case MACHINE_DEC_3MIN_5000: /* type 3, KN02BA */
1474     machine->machine_name = "DECstation 5000/112 or 145 (3MIN, KN02BA)";
1475     if (machine->emulated_hz == 0)
1476     machine->emulated_hz = 33000000;
1477     if (machine->physical_ram_in_mb > 128)
1478     fprintf(stderr, "WARNING! Real 3MIN machines cannot have more than 128MB RAM. Continuing anyway.\n");
1479    
1480     /* KMIN interrupts: */
1481     machine->md_interrupt = kmin_interrupt;
1482    
1483     /*
1484     * tc0 at mainbus0: 12.5 MHz clock (0x10000000, slotsize = 64MB)
1485     * tc slot 1: 0x14000000
1486     * tc slot 2: 0x18000000
1487     * ioasic0 at tc0 slot 3 offset 0x0 (0x1c000000) slot 0
1488     * asic regs (0x1c040000) slot 1
1489     * station's ether address (0x1c080000) slot 2
1490     * le0 at ioasic0 offset 0xc0000: address 00:00:00:00:00:00 (0x1c0c0000) slot 3
1491     * scc0 at ioasic0 offset 0x100000 (0x1c100000) slot 4
1492     * scc1 at ioasic0 offset 0x180000: console (0x1c180000) slot 6
1493     * mcclock0 at ioasic0 offset 0x200000: mc146818 or compatible (0x1c200000) slot 8
1494     * asc0 at ioasic0 offset 0x300000: NCR53C94, 25MHz, SCSI ID 7 (0x1c300000) slot 12
1495     * dma for asc0 (0x1c380000) slot 14
1496     */
1497     machine->dec_ioasic_data = dev_dec_ioasic_init(cpu, mem, 0x1c000000, 0);
1498     dev_le_init(machine, mem, 0x1c0c0000, 0, 0, KMIN_INTR_LANCE +8, 4*65536);
1499     dev_scc_init(machine, mem, 0x1c100000, KMIN_INTR_SCC_0 +8, machine->use_x11, 0, 1);
1500     dev_scc_init(machine, mem, 0x1c180000, KMIN_INTR_SCC_1 +8, machine->use_x11, 1, 1);
1501     dev_mc146818_init(machine, mem, 0x1c200000, KMIN_INTR_CLOCK +8, MC146818_DEC, 1);
1502     dev_asc_init(machine, mem, 0x1c300000, KMIN_INTR_SCSI +8,
1503     NULL, DEV_ASC_DEC, NULL, NULL);
1504    
1505     /*
1506     * TURBOchannel slots 0, 1, and 2 are free for
1507     * option cards. These are by default filled with
1508     * zero or more graphics boards.
1509     *
1510     * TODO: irqs
1511     */
1512     dev_turbochannel_init(machine, mem, 0,
1513     0x10000000, 0x103fffff,
1514     machine->n_gfx_cards >= 1?
1515     turbochannel_default_gfx_card : "",
1516     KMIN_INT_TC0);
1517    
1518     dev_turbochannel_init(machine, mem, 1,
1519     0x14000000, 0x143fffff,
1520     machine->n_gfx_cards >= 2?
1521     turbochannel_default_gfx_card : "",
1522     KMIN_INT_TC1);
1523    
1524     dev_turbochannel_init(machine, mem, 2,
1525     0x18000000, 0x183fffff,
1526     machine->n_gfx_cards >= 3?
1527     turbochannel_default_gfx_card : "",
1528     KMIN_INT_TC2);
1529    
1530     /* (kmin shared irq numbers (IP) are offset by +8 in the emulator) */
1531     /* kmin_csr = dev_kmin_init(cpu, mem, KMIN_REG_INTR); */
1532    
1533     framebuffer_console_name = "osconsole=0,3"; /* fb, keyb (?) */
1534     serial_console_name = "osconsole=3"; /* ? */
1535     break;
1536    
1537     case MACHINE_DEC_3MAXPLUS_5000: /* type 4, KN03 */
1538     machine->machine_name = "DECsystem 5900 or 5000 (3MAX+) (KN03)";
1539    
1540     /* 5000/240 (KN03-GA, R3000): 40 MHz */
1541     /* 5000/260 (KN05-NB, R4000): 60 MHz */
1542     /* TODO: are both these type 4? */
1543     if (machine->emulated_hz == 0)
1544     machine->emulated_hz = 40000000;
1545     if (machine->physical_ram_in_mb > 480)
1546     fprintf(stderr, "WARNING! Real KN03 machines cannot have more than 480MB RAM. Continuing anyway.\n");
1547    
1548     /* KN03 interrupts: */
1549     machine->md_interrupt = kn03_interrupt;
1550    
1551     /*
1552     * tc0 at mainbus0: 25 MHz clock (slot 0) (0x1e000000)
1553     * tc0 slot 1 (0x1e800000)
1554     * tc0 slot 2 (0x1f000000)
1555     * ioasic0 at tc0 slot 3 offset 0x0 (0x1f800000)
1556     * something that has to do with interrupts? (?) (0x1f840000 ?)
1557     * le0 at ioasic0 offset 0xc0000 (0x1f8c0000)
1558     * scc0 at ioasic0 offset 0x100000 (0x1f900000)
1559     * scc1 at ioasic0 offset 0x180000: console (0x1f980000)
1560     * mcclock0 at ioasic0 offset 0x200000: mc146818 or compatible (0x1fa00000)
1561     * asc0 at ioasic0 offset 0x300000: NCR53C94, 25MHz, SCSI ID 7 (0x1fb00000)
1562     */
1563     machine->dec_ioasic_data = dev_dec_ioasic_init(cpu, mem, 0x1f800000, 0);
1564    
1565     dev_le_init(machine, mem, KN03_SYS_LANCE, 0, 0, KN03_INTR_LANCE +8, 4*65536);
1566    
1567     machine->dec_ioasic_data->dma_func[3] = dev_scc_dma_func;
1568     machine->dec_ioasic_data->dma_func_extra[2] = dev_scc_init(machine, mem, KN03_SYS_SCC_0, KN03_INTR_SCC_0 +8, machine->use_x11, 0, 1);
1569     machine->dec_ioasic_data->dma_func[2] = dev_scc_dma_func;
1570     machine->dec_ioasic_data->dma_func_extra[3] = dev_scc_init(machine, mem, KN03_SYS_SCC_1, KN03_INTR_SCC_1 +8, machine->use_x11, 1, 1);
1571    
1572     dev_mc146818_init(machine, mem, KN03_SYS_CLOCK, KN03_INT_RTC, MC146818_DEC, 1);
1573     dev_asc_init(machine, mem, KN03_SYS_SCSI,
1574     KN03_INTR_SCSI +8, NULL, DEV_ASC_DEC, NULL, NULL);
1575    
1576     /*
1577     * TURBOchannel slots 0, 1, and 2 are free for
1578     * option cards. These are by default filled with
1579     * zero or more graphics boards.
1580     *
1581     * TODO: irqs
1582     */
1583     dev_turbochannel_init(machine, mem, 0,
1584     KN03_PHYS_TC_0_START, KN03_PHYS_TC_0_END,
1585     machine->n_gfx_cards >= 1?
1586     turbochannel_default_gfx_card : "",
1587     KN03_INTR_TC_0 +8);
1588    
1589     dev_turbochannel_init(machine, mem, 1,
1590     KN03_PHYS_TC_1_START, KN03_PHYS_TC_1_END,
1591     machine->n_gfx_cards >= 2?
1592     turbochannel_default_gfx_card : "",
1593     KN03_INTR_TC_1 +8);
1594    
1595     dev_turbochannel_init(machine, mem, 2,
1596     KN03_PHYS_TC_2_START, KN03_PHYS_TC_2_END,
1597     machine->n_gfx_cards >= 3?
1598     turbochannel_default_gfx_card : "",
1599     KN03_INTR_TC_2 +8);
1600    
1601     /* TODO: interrupts */
1602     /* shared (turbochannel) interrupts are +8 */
1603    
1604     framebuffer_console_name = "osconsole=0,3"; /* fb, keyb (?) */
1605     serial_console_name = "osconsole=3"; /* ? */
1606     break;
1607    
1608     case MACHINE_DEC_5800: /* type 5, KN5800 */
1609     machine->machine_name = "DECsystem 5800";
1610    
1611     /* TODO: this is incorrect, banks multiply by 8 etc */
1612     if (machine->physical_ram_in_mb < 48)
1613     fprintf(stderr, "WARNING! 5800 will probably not run with less than 48MB RAM. Continuing anyway.\n");
1614    
1615     /*
1616     * According to http://www2.no.netbsd.org/Ports/pmax/models.html,
1617     * the 5800-series is based on VAX 6000/300.
1618     */
1619    
1620     /*
1621     * Ultrix might support SMP on this machine type.
1622     *
1623     * Something at 0x10000000.
1624     * ssc serial console at 0x10140000, interrupt 2 (shared with XMI?).
1625     * xmi 0 at address 0x11800000 (node x at offset x*0x80000)
1626     * Clock uses interrupt 3 (shared with XMI?).
1627     */
1628    
1629     machine->dec5800_csr = dev_dec5800_init(machine, mem, 0x10000000);
1630     dev_decbi_init(mem, 0x10000000);
1631     dev_ssc_init(machine, mem, 0x10140000, 2, machine->use_x11, &machine->dec5800_csr->csr);
1632     dev_decxmi_init(mem, 0x11800000);
1633     dev_deccca_init(mem, DEC_DECCCA_BASEADDR);
1634    
1635     break;
1636    
1637     case MACHINE_DEC_5400: /* type 6, KN210 */
1638     machine->machine_name = "DECsystem 5400 (KN210)";
1639     /*
1640     * Misc. info from the KN210 manual:
1641     *
1642     * Interrupt lines:
1643     * irq5 fpu
1644     * irq4 halt
1645     * irq3 pwrfl -> mer1 -> mer0 -> wear
1646     * irq2 100 Hz -> birq7
1647     * irq1 dssi -> ni -> birq6
1648     * irq0 birq5 -> console -> timers -> birq4
1649     *
1650     * Interrupt status register at 0x10048000.
1651     * Main memory error status register at 0x1008140.
1652     * Interval Timer Register (ITR) at 0x10084010.
1653     * Q22 stuff at 0x10088000 - 0x1008ffff.
1654     * TODR at 0x1014006c.
1655     * TCR0 (timer control register 0) 0x10140100.
1656     * TIR0 (timer interval register 0) 0x10140104.
1657     * TCR1 (timer control register 1) 0x10140110.
1658     * TIR1 (timer interval register 1) 0x10140114.
1659     * VRR0 (Vector Read Register 0) at 0x16000050.
1660     * VRR1 (Vector Read Register 1) at 0x16000054.
1661     * VRR2 (Vector Read Register 2) at 0x16000058.
1662     * VRR3 (Vector Read Register 3) at 0x1600005c.
1663     */
1664     /* ln (ethernet) at 0x10084x00 ? and 0x10120000 ? */
1665     /* error registers (?) at 0x17000000 and 0x10080000 */
1666     device_add(machine, "kn210 addr=0x10080000");
1667     dev_ssc_init(machine, mem, 0x10140000, 0, machine->use_x11, NULL); /* TODO: not irq 0 */
1668     break;
1669    
1670     case MACHINE_DEC_MAXINE_5000: /* type 7, KN02CA */
1671     machine->machine_name = "Personal DECstation 5000/xxx (MAXINE) (KN02CA)";
1672     if (machine->emulated_hz == 0)
1673     machine->emulated_hz = 33000000;
1674    
1675     if (machine->physical_ram_in_mb < 8)
1676     fprintf(stderr, "WARNING! Real KN02CA machines do not have less than 8MB RAM. Continuing anyway.\n");
1677     if (machine->physical_ram_in_mb > 40)
1678     fprintf(stderr, "WARNING! Real KN02CA machines cannot have more than 40MB RAM. Continuing anyway.\n");
1679    
1680     /* Maxine interrupts: */
1681     machine->md_interrupt = maxine_interrupt;
1682    
1683     /*
1684     * Something at address 0xca00000. (?)
1685     * Something at address 0xe000000. (?)
1686     * tc0 slot 0 (0x10000000)
1687     * tc0 slot 1 (0x14000000)
1688     * (tc0 slot 2 used by the framebuffer)
1689     * ioasic0 at tc0 slot 3 offset 0x0 (0x1c000000)
1690     * le0 at ioasic0 offset 0xc0000: address 00:00:00:00:00:00 (0x1c0c0000)
1691     * scc0 at ioasic0 offset 0x100000: console <-- serial (0x1c100000)
1692     * mcclock0 at ioasic0 offset 0x200000: mc146818 (0x1c200000)
1693     * isdn at ioasic0 offset 0x240000 not configured (0x1c240000)
1694     * bba0 at ioasic0 offset 0x240000 (audio0 at bba0) <--- which one of isdn and bba0?
1695     * dtop0 at ioasic0 offset 0x280000 (0x1c280000)
1696     * fdc at ioasic0 offset 0x2c0000 not configured <-- floppy (0x1c2c0000)
1697     * asc0 at ioasic0 offset 0x300000: NCR53C94, 25MHz, SCSI ID 7 (0x1c300000)
1698     * xcfb0 at tc0 slot 2 offset 0x0: 1024x768x8 built-in framebuffer (0xa000000)
1699     */
1700     machine->dec_ioasic_data = dev_dec_ioasic_init(cpu, mem, 0x1c000000, 0);
1701    
1702     /* TURBOchannel slots (0 and 1): */
1703     dev_turbochannel_init(machine, mem, 0,
1704     0x10000000, 0x103fffff,
1705     machine->n_gfx_cards >= 2?
1706     turbochannel_default_gfx_card : "",
1707     XINE_INTR_TC_0 +8);
1708     dev_turbochannel_init(machine, mem, 1,
1709     0x14000000, 0x143fffff,
1710     machine->n_gfx_cards >= 3?
1711     turbochannel_default_gfx_card : "",
1712     XINE_INTR_TC_1 +8);
1713    
1714     /*
1715     * TURBOchannel slot 2 is hardwired to be used by
1716     * the framebuffer: (NOTE: 0x8000000, not 0x18000000)
1717     */
1718     dev_turbochannel_init(machine, mem, 2,
1719     0x8000000, 0xbffffff, "PMAG-DV", 0);
1720    
1721     /*
1722     * TURBOchannel slot 3: fixed, ioasic
1723     * (the system stuff), 0x1c000000
1724     */
1725     dev_le_init(machine, mem, 0x1c0c0000, 0, 0, XINE_INTR_LANCE +8, 4*65536);
1726     dev_scc_init(machine, mem, 0x1c100000,
1727     XINE_INTR_SCC_0 +8, machine->use_x11, 0, 1);
1728     dev_mc146818_init(machine, mem, 0x1c200000,
1729     XINE_INT_TOY, MC146818_DEC, 1);
1730     dev_asc_init(machine, mem, 0x1c300000,
1731     XINE_INTR_SCSI +8, NULL, DEV_ASC_DEC, NULL, NULL);
1732    
1733     framebuffer_console_name = "osconsole=3,2"; /* keyb,fb ?? */
1734     serial_console_name = "osconsole=3";
1735     break;
1736    
1737     case MACHINE_DEC_5500: /* type 11, KN220 */
1738     machine->machine_name = "DECsystem 5500 (KN220)";
1739    
1740     /*
1741     * According to NetBSD's pmax ports page:
1742     * KN220-AA is a "30 MHz R3000 CPU with R3010 FPU"
1743     * with "512 kBytes of Prestoserve battery backed RAM."
1744     */
1745     if (machine->emulated_hz == 0)
1746     machine->emulated_hz = 30000000;
1747    
1748     /*
1749     * See KN220 docs for more info.
1750     *
1751     * something at 0x10000000
1752     * something at 0x10001000
1753     * something at 0x10040000
1754     * scc at 0x10140000
1755     * qbus at (or around) 0x10080000
1756     * dssi (disk controller) buffers at 0x10100000, registers at 0x10160000.
1757     * sgec (ethernet) registers at 0x10008000, station addresss at 0x10120000.
1758     * asc (scsi) at 0x17100000.
1759     */
1760    
1761     dev_ssc_init(machine, mem, 0x10140000, 0, machine->use_x11, NULL); /* TODO: not irq 0 */
1762    
1763     /* something at 0x17000000, ultrix says "cpu 0 panic: DS5500 I/O Board is missing" if this is not here */
1764     dev_dec5500_ioboard_init(cpu, mem, 0x17000000);
1765    
1766     dev_sgec_init(mem, 0x10008000, 0); /* irq? */
1767    
1768     /* The asc controller might be TURBOchannel-ish? */
1769     #if 0
1770     dev_turbochannel_init(machine, mem, 0, 0x17100000, 0x171fffff, "PMAZ-AA", 0); /* irq? */
1771     #else
1772     dev_asc_init(machine, mem, 0x17100000, 0, NULL, DEV_ASC_DEC, NULL, NULL); /* irq? */
1773     #endif
1774    
1775     framebuffer_console_name = "osconsole=0,0"; /* TODO (?) */
1776     serial_console_name = "osconsole=0";
1777     break;
1778    
1779     case MACHINE_DEC_MIPSMATE_5100: /* type 12 */
1780     machine->machine_name = "DEC MIPSMATE 5100 (KN230)";
1781     if (machine->emulated_hz == 0)
1782     machine->emulated_hz = 20000000;
1783     if (machine->physical_ram_in_mb > 128)
1784     fprintf(stderr, "WARNING! Real MIPSMATE 5100 machines cannot have more than 128MB RAM. Continuing anyway.\n");
1785    
1786     if (machine->use_x11)
1787     fprintf(stderr, "WARNING! Real MIPSMATE 5100 machines cannot have a graphical framebuffer. Continuing anyway.\n");
1788    
1789     /* KN230 interrupts: */
1790     machine->md_interrupt = kn230_interrupt;
1791    
1792     /*
1793     * According to NetBSD/pmax:
1794     * dc0 at ibus0 addr 0x1c000000
1795     * le0 at ibus0 addr 0x18000000: address 00:00:00:00:00:00
1796     * sii0 at ibus0 addr 0x1a000000
1797     */
1798     dev_mc146818_init(machine, mem, KN230_SYS_CLOCK, 4, MC146818_DEC, 1);
1799     dev_dc7085_init(machine, mem, KN230_SYS_DZ0, KN230_CSR_INTR_DZ0, machine->use_x11); /* NOTE: CSR_INTR */
1800     /* dev_dc7085_init(machine, mem, KN230_SYS_DZ1, KN230_CSR_INTR_OPT0, machine->use_x11); */ /* NOTE: CSR_INTR */
1801     /* dev_dc7085_init(machine, mem, KN230_SYS_DZ2, KN230_CSR_INTR_OPT1, machine->use_x11); */ /* NOTE: CSR_INTR */
1802     dev_le_init(machine, mem, KN230_SYS_LANCE, KN230_SYS_LANCE_B_START, KN230_SYS_LANCE_B_END, KN230_CSR_INTR_LANCE, 4*1048576);
1803     dev_sii_init(machine, mem, KN230_SYS_SII, KN230_SYS_SII_B_START, KN230_SYS_SII_B_END, KN230_CSR_INTR_SII);
1804    
1805     snprintf(tmpstr, sizeof(tmpstr) - 1,
1806     "kn230 addr=0x%llx", (long long)KN230_SYS_ICSR);
1807     machine->kn230_csr = device_add(machine, tmpstr);
1808    
1809     serial_console_name = "osconsole=0";
1810     break;
1811    
1812     default:
1813     ;
1814     }
1815    
1816     /*
1817     * Most OSes on DECstation use physical addresses below
1818     * 0x20000000, but OSF/1 seems to use 0xbe...... as if it was
1819     * 0x1e......, so we need this hack:
1820     */
1821     dev_ram_init(mem, 0xa0000000, 0x20000000, DEV_RAM_MIRROR, 0x0);
1822    
1823     /* DECstation PROM stuff: (TODO: endianness) */
1824     for (i=0; i<100; i++)
1825     store_32bit_word(cpu, DEC_PROM_CALLBACK_STRUCT + i*4,
1826     DEC_PROM_EMULATION + i*8);
1827    
1828     /* Fill PROM with dummy return instructions: (TODO: make this nicer) */
1829     for (i=0; i<100; i++) {
1830     store_32bit_word(cpu, DEC_PROM_EMULATION + i*8,
1831     0x03e00008); /* return */
1832     store_32bit_word(cpu, DEC_PROM_EMULATION + i*8 + 4,
1833     0x00000000); /* nop */
1834     }
1835    
1836     /*
1837     * According to dec_prom.h from NetBSD:
1838     *
1839     * "Programs loaded by the new PROMs pass the following arguments:
1840     * a0 argc
1841     * a1 argv
1842     * a2 DEC_PROM_MAGIC
1843     * a3 The callback vector defined below"
1844     *
1845     * So we try to emulate a PROM, even though no such thing has been
1846     * loaded.
1847     */
1848    
1849     cpu->cd.mips.gpr[MIPS_GPR_A0] = 3;
1850     cpu->cd.mips.gpr[MIPS_GPR_A1] = DEC_PROM_INITIAL_ARGV;
1851     cpu->cd.mips.gpr[MIPS_GPR_A2] = DEC_PROM_MAGIC;
1852     cpu->cd.mips.gpr[MIPS_GPR_A3] = DEC_PROM_CALLBACK_STRUCT;
1853    
1854     store_32bit_word(cpu, INITIAL_STACK_POINTER + 0x10,
1855     BOOTINFO_MAGIC);
1856     store_32bit_word(cpu, INITIAL_STACK_POINTER + 0x14,
1857     BOOTINFO_ADDR);
1858    
1859     store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV,
1860     (DEC_PROM_INITIAL_ARGV + 0x10));
1861     store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV+4,
1862     (DEC_PROM_INITIAL_ARGV + 0x70));
1863     store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV+8,
1864     (DEC_PROM_INITIAL_ARGV + 0xe0));
1865     store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV+12, 0);
1866    
1867     /*
1868     * NetBSD and Ultrix expect the boot args to be like this:
1869     *
1870     * "boot" "bootdev" [args?]
1871     *
1872     * where bootdev is supposed to be "rz(0,0,0)netbsd" for
1873     * 3100/2100 (although that crashes Ultrix :-/), and
1874     * "5/rz0a/netbsd" for all others. The number '5' is the
1875     * slot number of the boot device.
1876     *
1877     * 'rz' for disks, 'tz' for tapes.
1878     *
1879     * TODO: Make this nicer.
1880     */
1881     {
1882     char bootpath[200];
1883    
1884     #if 0
1885     if (machine->machine_subtype == MACHINE_DEC_PMAX_3100)
1886     strcpy(bootpath, "rz(0,0,0)");
1887     else
1888     #endif
1889     strcpy(bootpath, "5/rz1/");
1890    
1891     if (bootdev_id < 0 || machine->force_netboot) {
1892     /* tftp boot: */
1893     strcpy(bootpath, "5/tftp/");
1894     bootpath[0] = '0' + boot_net_boardnumber;
1895     } else {
1896     /* disk boot: */
1897     bootpath[0] = '0' + boot_scsi_boardnumber;
1898     if (diskimage_is_a_tape(machine, bootdev_id))
1899     bootpath[2] = 't';
1900     bootpath[4] = '0' + bootdev_id;
1901     }
1902    
1903     init_bootpath = bootpath;
1904     }
1905    
1906     bootarg = malloc(strlen(init_bootpath) +
1907     strlen(machine->boot_kernel_filename) + 1 +
1908     strlen(machine->boot_string_argument) + 1);
1909     strcpy(bootarg, init_bootpath);
1910     strcat(bootarg, machine->boot_kernel_filename);
1911    
1912     bootstr = "boot";
1913    
1914     store_string(cpu, DEC_PROM_INITIAL_ARGV+0x10, bootstr);
1915     store_string(cpu, DEC_PROM_INITIAL_ARGV+0x70, bootarg);
1916     store_string(cpu, DEC_PROM_INITIAL_ARGV+0xe0,
1917     machine->boot_string_argument);
1918    
1919     /* Decrease the nr of args, if there are no args :-) */
1920     if (machine->boot_string_argument == NULL ||
1921     machine->boot_string_argument[0] == '\0')
1922     cpu->cd.mips.gpr[MIPS_GPR_A0] --;
1923    
1924     if (machine->boot_string_argument[0] != '\0') {
1925     strcat(bootarg, " ");
1926     strcat(bootarg, machine->boot_string_argument);
1927     }
1928    
1929     xx.a.common.next = (char *)&xx.b - (char *)&xx;
1930     xx.a.common.type = BTINFO_MAGIC;
1931     xx.a.magic = BOOTINFO_MAGIC;
1932    
1933     xx.b.common.next = (char *)&xx.c - (char *)&xx.b;
1934     xx.b.common.type = BTINFO_BOOTPATH;
1935     strcpy(xx.b.bootpath, bootstr);
1936    
1937     xx.c.common.next = 0;
1938     xx.c.common.type = BTINFO_SYMTAB;
1939     xx.c.nsym = 0;
1940     xx.c.ssym = 0;
1941     xx.c.esym = machine->file_loaded_end_addr;
1942    
1943     store_buf(cpu, BOOTINFO_ADDR, (char *)&xx, sizeof(xx));
1944    
1945     /*
1946     * The system's memmap: (memmap is a global variable, in
1947     * dec_prom.h)
1948     */
1949     store_32bit_word_in_host(cpu,
1950     (unsigned char *)&memmap.pagesize, 4096);
1951     {
1952     unsigned int i;
1953     for (i=0; i<sizeof(memmap.bitmap); i++)
1954     memmap.bitmap[i] = ((int)i * 4096*8 <
1955     1048576*machine->physical_ram_in_mb)?
1956     0xff : 0x00;
1957     }
1958     store_buf(cpu, DEC_MEMMAP_ADDR, (char *)&memmap, sizeof(memmap));
1959    
1960     /* Environment variables: */
1961     addr = DEC_PROM_STRINGS;
1962    
1963     if (machine->use_x11 && machine->n_gfx_cards > 0)
1964     /* (0,3) Keyboard and Framebuffer */
1965     add_environment_string(cpu, framebuffer_console_name, &addr);
1966     else
1967     /* Serial console */
1968     add_environment_string(cpu, serial_console_name, &addr);
1969    
1970     /*
1971     * The KN5800 (SMP system) uses a CCA (console communications
1972     * area): (See VAX 6000 documentation for details.)
1973     */
1974     {
1975     char tmps[300];
1976     sprintf(tmps, "cca=%x",
1977     (int)(DEC_DECCCA_BASEADDR + 0xa0000000ULL));
1978     add_environment_string(cpu, tmps, &addr);
1979     }
1980    
1981     /* These are needed for Sprite to boot: */
1982     {
1983     char tmps[300];
1984    
1985     sprintf(tmps, "boot=%s", bootarg);
1986     add_environment_string(cpu, tmps, &addr);
1987    
1988     sprintf(tmps, "bitmap=0x%x", (uint32_t)((
1989     DEC_MEMMAP_ADDR + sizeof(memmap.pagesize))
1990     & 0xffffffffULL));
1991     add_environment_string(cpu, tmps, &addr);
1992    
1993     sprintf(tmps, "bitmaplen=0x%x",
1994     machine->physical_ram_in_mb * 1048576 / 4096 / 8);
1995     add_environment_string(cpu, tmps, &addr);
1996     }
1997    
1998     add_environment_string(cpu, "scsiid0=7", &addr);
1999     add_environment_string(cpu, "bootmode=a", &addr);
2000     add_environment_string(cpu, "testaction=q", &addr);
2001     add_environment_string(cpu, "haltaction=h", &addr);
2002     add_environment_string(cpu, "more=24", &addr);
2003    
2004     /* Used in at least Ultrix on the 5100: */
2005     add_environment_string(cpu, "scsiid=7", &addr);
2006     add_environment_string(cpu, "baud0=9600", &addr);
2007     add_environment_string(cpu, "baud1=9600", &addr);
2008     add_environment_string(cpu, "baud2=9600", &addr);
2009     add_environment_string(cpu, "baud3=9600", &addr);
2010     add_environment_string(cpu, "iooption=0x1", &addr);
2011    
2012     /* The end: */
2013     add_environment_string(cpu, "", &addr);
2014    
2015     break;
2016    
2017     case MACHINE_COBALT:
2018     cpu->byte_order = EMUL_LITTLE_ENDIAN;
2019     machine->machine_name = "Cobalt";
2020    
2021     /*
2022     * Interrupts seem to be the following:
2023     * (according to http://www.funet.fi/pub/Linux/PEOPLE/Linus/v2.4/patch-html/patch-2.4.19/linux-2.4.19_arch_mips_cobalt_irq.c.html)
2024     *
2025     * 2 Galileo chip (timer)
2026     * 3 Tulip 0 + NCR SCSI
2027     * 4 Tulip 1
2028     * 5 16550 UART (serial console)
2029     * 6 VIA southbridge PIC
2030     * 7 PCI
2031     */
2032     /* dev_XXX_init(cpu, mem, 0x10000000, machine->emulated_hz); */
2033     dev_mc146818_init(machine, mem, 0x10000070, 0, MC146818_PC_CMOS, 4);
2034     machine->main_console_handle = dev_ns16550_init(machine, mem,
2035     0x1c800000, 5, 1, 1, "serial console");
2036    
2037     /*
2038     * According to NetBSD/cobalt:
2039     *
2040     * pchb0 at pci0 dev 0 function 0: Galileo GT-64111 System Controller, rev 1 (NOTE: added by dev_gt_init())
2041     * tlp0 at pci0 dev 7 function 0: DECchip 21143 Ethernet, pass 4.1
2042     * Symbios Logic 53c860 (SCSI mass storage, revision 0x02) at pci0 dev 8
2043     * pcib0 at pci0 dev 9 function 0, VIA Technologies VT82C586 (Apollo VP) PCI-ISA Bridge, rev 37
2044     * pciide0 at pci0 dev 9 function 1: VIA Technologies VT82C586 (Apollo VP) ATA33 cr
2045     * tlp1 at pci0 dev 12 function 0: DECchip 21143 Ethernet, pass 4.1
2046     */
2047     pci_data = dev_gt_init(machine, mem, 0x14000000, 2, 6); /* 7 for PCI, not 6? */
2048     /* bus_pci_add(machine, pci_data, mem, 0, 7, 0, pci_dec21143_init, pci_dec21143_rr); */
2049     bus_pci_add(machine, pci_data, mem, 0, 8, 0, NULL, NULL); /* PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_860 */
2050     bus_pci_add(machine, pci_data, mem, 0, 9, 0, pci_vt82c586_isa_init, pci_vt82c586_isa_rr);
2051     bus_pci_add(machine, pci_data, mem, 0, 9, 1, pci_vt82c586_ide_init, pci_vt82c586_ide_rr);
2052     /* bus_pci_add(machine, pci_data, mem, 0, 12, 0, pci_dec21143_init, pci_dec21143_rr); */
2053    
2054     /*
2055     * NetBSD/cobalt expects memsize in a0, but it seems that what
2056     * it really wants is the end of memory + 0x80000000.
2057     *
2058     * The bootstring should be stored starting 512 bytes before end
2059     * of physical ram.
2060     */
2061     cpu->cd.mips.gpr[MIPS_GPR_A0] = machine->physical_ram_in_mb * 1048576 + 0x80000000;
2062     bootstr = "root=/dev/hda1 ro";
2063     /* bootstr = "nfsroot=/usr/cobalt/"; */
2064     store_string(cpu, 0xffffffff80000000ULL +
2065     machine->physical_ram_in_mb * 1048576 - 512, bootstr);
2066     break;
2067    
2068     case MACHINE_HPCMIPS:
2069     cpu->byte_order = EMUL_LITTLE_ENDIAN;
2070     memset(&hpc_bootinfo, 0, sizeof(hpc_bootinfo));
2071     /* TODO: set platid from netbsd/usr/src/sys/arch/hpc/include/platid* */
2072     /*
2073     #define PLATID_FLAGS_SHIFT 0
2074     #define PLATID_CPU_SUBMODEL_SHIFT 8
2075     #define PLATID_CPU_MODEL_SHIFT 14
2076     #define PLATID_CPU_SERIES_SHIFT 20
2077     #define PLATID_CPU_ARCH_SHIFT 26
2078    
2079     #define PLATID_SUBMODEL_SHIFT 0
2080     #define PLATID_MODEL_SHIFT 8
2081     #define PLATID_SERIES_SHIFT 16
2082     #define PLATID_VENDOR_SHIFT 22
2083     */
2084    
2085     /*
2086     NOTE: See http://forums.projectmayo.com/viewtopic.php?topic=2743&forum=23
2087     for info on framebuffer addresses.
2088     */
2089    
2090     switch (machine->machine_subtype) {
2091     case MACHINE_HPCMIPS_CASIO_BE300:
2092     /* 166MHz VR4131 */
2093     machine->machine_name = "Casio Cassiopeia BE-300";
2094     hpcmips_fb_addr = 0x0a200000;
2095     hpcmips_fb_xsize = 240;
2096     hpcmips_fb_ysize = 320;
2097     hpcmips_fb_xsize_mem = 256;
2098     hpcmips_fb_ysize_mem = 320;
2099     hpcmips_fb_bits = 15;
2100     hpcmips_fb_encoding = BIFB_D16_0000;
2101    
2102     machine->main_console_handle = dev_ns16550_init(
2103     machine, mem, 0xa008680, 0, 4,
2104     machine->use_x11? 0 : 1, "serial console"); /* TODO: irq? */
2105     machine->vr41xx_data = dev_vr41xx_init(machine, mem, 4131);
2106     machine->md_interrupt = vr41xx_interrupt;
2107    
2108     store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu,
2109     (1 << 26) /* 1 = MIPS */
2110     + (1 << 20) /* 1 = VR */
2111     + (1 << 14) /* 1 = VR41XX */
2112     + (6 << 8) /* 6 = VR4131 */
2113     );
2114     store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_machine,
2115     (3 << 22) /* 22: vendor 3=casio */
2116     + (1 << 16) /* 16: series 1=CASSIOPEIAE*/
2117     + (2 << 8) /* 8: model 2=EXXX*/
2118     + (3) /* 0: submodel 3=E500 */
2119     );
2120     /* TODO: Don't use model number for E500, it's a BE300! */
2121     break;
2122     case MACHINE_HPCMIPS_CASIO_E105:
2123     /* 131MHz VR4121 */
2124     machine->machine_name = "Casio Cassiopeia E-105";
2125     hpcmips_fb_addr = 0x0a200000; /* TODO? */
2126     hpcmips_fb_xsize = 240;
2127     hpcmips_fb_ysize = 320;
2128     hpcmips_fb_xsize_mem = 256;
2129     hpcmips_fb_ysize_mem = 320;
2130     hpcmips_fb_bits = 16;
2131     hpcmips_fb_encoding = BIFB_D16_0000;
2132    
2133     machine->main_console_handle = dev_ns16550_init(
2134     machine, mem, 0xa008680, 0, 4,
2135     machine->use_x11? 0 : 1, "serial console"); /* TODO: irq? */
2136     machine->vr41xx_data = dev_vr41xx_init(machine, mem, 4121);
2137     machine->md_interrupt = vr41xx_interrupt;
2138    
2139     store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu,
2140     (1 << 26) /* 1 = MIPS */
2141     + (1 << 20) /* 1 = VR */
2142     + (1 << 14) /* 1 = VR41XX */
2143     + (3 << 8) /* 3 = VR4121 */
2144     );
2145     store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_machine,
2146     (3 << 22) /* 22: vendor 3=casio */
2147     + (1 << 16) /* 16: series 1=CASSIOPEIAE*/
2148     + (2 << 8) /* 8: model 2=EXXX*/
2149     + (2) /* 0: submodel 2=E105 */
2150     );
2151     break;
2152     case MACHINE_HPCMIPS_NEC_MOBILEPRO_770:
2153     /* 131 MHz VR4121 */
2154     machine->machine_name = "NEC MobilePro 770";
2155     /* TODO: */
2156     hpcmips_fb_addr = 0xa000000;
2157     hpcmips_fb_xsize = 640;
2158     hpcmips_fb_ysize = 240;
2159     hpcmips_fb_xsize_mem = 800;
2160     hpcmips_fb_ysize_mem = 240;
2161     hpcmips_fb_bits = 16;
2162     hpcmips_fb_encoding = BIFB_D16_0000;
2163    
2164     machine->vr41xx_data = dev_vr41xx_init(machine, mem, 4121);
2165     machine->md_interrupt = vr41xx_interrupt;
2166    
2167     store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu,
2168     (1 << 26) /* 1 = MIPS */
2169     + (1 << 20) /* 1 = VR */
2170     + (1 << 14) /* 1 = VR41XX */
2171     + (3 << 8) /* 3 = VR4121 */
2172     );
2173     store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_machine,
2174     (1 << 22) /* 22: vendor 1=NEC */
2175     + (2 << 16) /* 16: series 2="NEC MCR" */
2176     + (2 << 8) /* 8: model 2="MCR 5XX" */
2177     + (4) /* 0: submodel 4="MCR 520A" */
2178     );
2179     break;
2180     case MACHINE_HPCMIPS_NEC_MOBILEPRO_780:
2181     /* 166 (or 168) MHz VR4121 */
2182     machine->machine_name = "NEC MobilePro 780";
2183     /* TODO: */
2184     hpcmips_fb_addr = 0xa180100;
2185     hpcmips_fb_xsize = 640;
2186     hpcmips_fb_ysize = 240;
2187     hpcmips_fb_xsize_mem = 640;
2188     hpcmips_fb_ysize_mem = 240;
2189     hpcmips_fb_bits = 16;
2190     hpcmips_fb_encoding = BIFB_D16_0000;
2191    
2192     machine->vr41xx_data = dev_vr41xx_init(machine, mem, 4121);
2193     machine->md_interrupt = vr41xx_interrupt;
2194    
2195     store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu,
2196     (1 << 26) /* 1 = MIPS */
2197     + (1 << 20) /* 1 = VR */
2198     + (1 << 14) /* 1 = VR41XX */
2199     + (3 << 8) /* 3 = VR4121 */
2200     );
2201     store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_machine,
2202     (1 << 22) /* 22: vendor 1=NEC */
2203     + (2 << 16) /* 16: series 2="NEC MCR" */
2204     + (2 << 8) /* 8: model 2="MCR 5XX" */
2205     + (8) /* 0: submodel 8="MCR 530A" */
2206     );
2207     break;
2208     case MACHINE_HPCMIPS_NEC_MOBILEPRO_800:
2209     /* 131 MHz VR4121 */
2210     machine->machine_name = "NEC MobilePro 800";
2211     /* TODO: */
2212     hpcmips_fb_addr = 0xa000000;
2213     hpcmips_fb_xsize = 800;
2214     hpcmips_fb_ysize = 600;
2215     hpcmips_fb_xsize_mem = 800;
2216     hpcmips_fb_ysize_mem = 600;
2217     hpcmips_fb_bits = 16;
2218     hpcmips_fb_encoding = BIFB_D16_0000;
2219    
2220     machine->vr41xx_data = dev_vr41xx_init(machine, mem, 4121);
2221     machine->md_interrupt = vr41xx_interrupt;
2222    
2223     store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu,
2224     (1 << 26) /* 1 = MIPS */
2225     + (1 << 20) /* 1 = VR */
2226     + (1 << 14) /* 1 = VR41XX */
2227     + (3 << 8) /* 3 = VR4121 */
2228     );
2229     store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_machine,
2230     (1 << 22) /* 22: vendor 1=NEC */
2231     + (2 << 16) /* 16: series 2="NEC MCR" */
2232     + (3 << 8) /* 8: model 3="MCR 7XX" */
2233     + (2) /* 0: submodel 2="MCR 700A" */
2234     );
2235     break;
2236     case MACHINE_HPCMIPS_NEC_MOBILEPRO_880:
2237     /* 168 MHz VR4121 */
2238     machine->machine_name = "NEC MobilePro 880";
2239     /* TODO: */
2240     hpcmips_fb_addr = 0xa0ea600;
2241     hpcmips_fb_xsize = 800;
2242     hpcmips_fb_ysize = 600;
2243     hpcmips_fb_xsize_mem = 800;
2244     hpcmips_fb_ysize_mem = 600;
2245     hpcmips_fb_bits = 16;
2246     hpcmips_fb_encoding = BIFB_D16_0000;
2247    
2248     machine->vr41xx_data = dev_vr41xx_init(machine, mem, 4121);
2249     machine->md_interrupt = vr41xx_interrupt;
2250    
2251     store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu,
2252     (1 << 26) /* 1 = MIPS */
2253     + (1 << 20) /* 1 = VR */
2254     + (1 << 14) /* 1 = VR41XX */
2255     + (3 << 8) /* 3 = VR4121 */
2256     );
2257     store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_machine,
2258     (1 << 22) /* 22: vendor 1=NEC */
2259     + (2 << 16) /* 16: series 2="NEC MCR" */
2260     + (3 << 8) /* 8: model 3="MCR 7XX" */
2261     + (4) /* 0: submodel 4="MCR 730A" */
2262     );
2263     break;
2264     case MACHINE_HPCMIPS_AGENDA_VR3:
2265     /* 66 MHz VR4181 */
2266     machine->machine_name = "Agenda VR3";
2267     /* TODO: */
2268     hpcmips_fb_addr = 0x1000;
2269     hpcmips_fb_xsize = 160;
2270     hpcmips_fb_ysize = 240;
2271     hpcmips_fb_xsize_mem = 160;
2272     hpcmips_fb_ysize_mem = 240;
2273     hpcmips_fb_bits = 4;
2274     hpcmips_fb_encoding = BIFB_D4_M2L_F;
2275    
2276     machine->vr41xx_data = dev_vr41xx_init(machine, mem, 4181);
2277     machine->md_interrupt = vr41xx_interrupt;
2278    
2279     /* TODO: Hm... irq 17 according to linux, but
2280     VRIP_INTR_SIU (=9) here? */
2281     {
2282     int x;
2283     x = dev_ns16550_init(machine, mem, 0x0c000010,
2284     8 + VRIP_INTR_SIU, 1, 1, "serial 0");
2285    
2286     if (!machine->use_x11)
2287     machine->main_console_handle = x;
2288     }
2289    
2290     store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu,
2291     (1 << 26) /* 1 = MIPS */
2292     + (1 << 20) /* 1 = VR */
2293     + (1 << 14) /* 1 = VR41XX */
2294     + (4 << 8) /* 4 = VR4181 */
2295     );
2296     store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_machine,
2297     (15 << 22) /* 22: vendor 15=Agenda */
2298     + (1 << 16) /* 16: series 2=VR */
2299     + (1 << 8) /* 8: model 1=VR3 */
2300     + (0) /* 0: submodel 0="VR3" */
2301     );
2302    
2303     dev_ram_init(mem, 0x0f000000, 0x01000000, DEV_RAM_MIRROR, 0x0);
2304     break;
2305     case MACHINE_HPCMIPS_IBM_WORKPAD_Z50:
2306     /* 131 MHz VR4121 */
2307     machine->machine_name = "Agenda VR3";
2308     /* TODO: */
2309     hpcmips_fb_addr = 0xa000000;
2310     hpcmips_fb_xsize = 640;
2311     hpcmips_fb_ysize = 480;
2312     hpcmips_fb_xsize_mem = 640;
2313     hpcmips_fb_ysize_mem = 480;
2314     hpcmips_fb_bits = 16;
2315     hpcmips_fb_encoding = BIFB_D16_0000;
2316    
2317     machine->vr41xx_data = dev_vr41xx_init(machine, mem, 4121);
2318     machine->md_interrupt = vr41xx_interrupt;
2319    
2320     store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu,
2321     (1 << 26) /* 1 = MIPS */
2322     + (1 << 20) /* 1 = VR */
2323     + (1 << 14) /* 1 = VR41XX */
2324     + (3 << 8) /* 3 = VR4121 */
2325     );
2326     store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_machine,
2327     (9 << 22) /* 22: vendor 9=IBM */
2328     + (1 << 16) /* 16: series 1=WorkPad */
2329     + (1 << 8) /* 8: model 1=Z50 */
2330     + (0) /* 0: submodel 0 */
2331     );
2332     break;
2333     default:
2334     printf("Unimplemented hpcmips machine number.\n");
2335     exit(1);
2336     }
2337    
2338     if (machine->use_x11)
2339     machine->main_console_handle =
2340     machine->vr41xx_data->kiu_console_handle;
2341    
2342     /* NetBSD/hpcmips and possibly others expects the following: */
2343    
2344     cpu->cd.mips.gpr[MIPS_GPR_A0] = 1; /* argc */
2345     cpu->cd.mips.gpr[MIPS_GPR_A1] = machine->physical_ram_in_mb * 1048576
2346     + 0xffffffff80000000ULL - 512; /* argv */
2347     cpu->cd.mips.gpr[MIPS_GPR_A2] = machine->physical_ram_in_mb * 1048576
2348     + 0xffffffff80000000ULL - 256; /* ptr to hpc_bootinfo */
2349    
2350     bootstr = machine->boot_kernel_filename;
2351     store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 16);
2352     store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 4, 0);
2353     store_string(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 16, bootstr);
2354    
2355     /* Special case for the Agenda VR3: */
2356     if (machine->machine_subtype == MACHINE_HPCMIPS_AGENDA_VR3) {
2357     const int tmplen = 1000;
2358     char *tmp = malloc(tmplen);
2359    
2360     cpu->cd.mips.gpr[MIPS_GPR_A0] = 2; /* argc */
2361    
2362     store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 4, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64);
2363     store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 8, 0);
2364    
2365     snprintf(tmp, tmplen, "root=/dev/rom video=vr4181fb:xres:160,yres:240,bpp:4,"
2366     "gray,hpck:3084,inv ether=0,0x03fe0300,eth0");
2367     tmp[tmplen-1] = '\0';
2368    
2369     if (!machine->use_x11)
2370     snprintf(tmp+strlen(tmp), tmplen-strlen(tmp), " console=ttyS0,115200");
2371     tmp[tmplen-1] = '\0';
2372    
2373     if (machine->boot_string_argument[0])
2374     snprintf(tmp+strlen(tmp), tmplen-strlen(tmp), " %s", machine->boot_string_argument);
2375     tmp[tmplen-1] = '\0';
2376    
2377     store_string(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64, tmp);
2378    
2379     bootarg = tmp;
2380     } else if (machine->boot_string_argument[0]) {
2381     cpu->cd.mips.gpr[MIPS_GPR_A0] ++; /* argc */
2382    
2383     store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 4, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64);
2384     store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 8, 0);
2385    
2386     store_string(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64,
2387     machine->boot_string_argument);
2388    
2389     bootarg = machine->boot_string_argument;
2390     }
2391    
2392     store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.length, sizeof(hpc_bootinfo));
2393     store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.magic, HPC_BOOTINFO_MAGIC);
2394     store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_addr, 0x80000000 + hpcmips_fb_addr);
2395     store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_line_bytes, hpcmips_fb_xsize_mem * (((hpcmips_fb_bits-1)|7)+1) / 8);
2396     store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_width, hpcmips_fb_xsize);
2397     store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_height, hpcmips_fb_ysize);
2398     store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_type, hpcmips_fb_encoding);
2399     store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.bi_cnuse, BI_CNUSE_BUILTIN); /* _BUILTIN or _SERIAL */
2400    
2401     /* printf("hpc_bootinfo.platid_cpu = 0x%08x\n", hpc_bootinfo.platid_cpu);
2402     printf("hpc_bootinfo.platid_machine = 0x%08x\n", hpc_bootinfo.platid_machine); */
2403     store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.timezone, 0);
2404     store_buf(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 256, (char *)&hpc_bootinfo, sizeof(hpc_bootinfo));
2405    
2406     if (hpcmips_fb_addr != 0) {
2407     dev_fb_init(machine, mem, hpcmips_fb_addr, VFB_HPCMIPS,
2408     hpcmips_fb_xsize, hpcmips_fb_ysize,
2409     hpcmips_fb_xsize_mem, hpcmips_fb_ysize_mem,
2410     hpcmips_fb_bits, "HPCmips", 0);
2411    
2412     /* NetBSD/hpcmips uses framebuffer at physical
2413     address 0x8.......: */
2414     dev_ram_init(mem, 0x80000000, 0x20000000,
2415     DEV_RAM_MIRROR, 0x0);
2416     }
2417    
2418     break;
2419    
2420     case MACHINE_PS2:
2421     cpu->byte_order = EMUL_LITTLE_ENDIAN;
2422     machine->machine_name = "Playstation 2";
2423    
2424     if (machine->physical_ram_in_mb != 32)
2425     fprintf(stderr, "WARNING! Playstation 2 machines are supposed to have exactly 32 MB RAM. Continuing anyway.\n");
2426     if (!machine->use_x11)
2427     fprintf(stderr, "WARNING! Playstation 2 without -X is pretty meaningless. Continuing anyway.\n");
2428    
2429     /*
2430     * According to NetBSD:
2431     * Hardware irq 0 is timer/interrupt controller
2432     * Hardware irq 1 is dma controller
2433     *
2434     * Some things are not yet emulated (at all), and hence are detected incorrectly:
2435     * sbus0 at mainbus0: controller type 2
2436     * ohci0 at sbus0 (at 0x1f801600, according to linux)
2437     * ohci0: OHCI version 1.0
2438     */
2439    
2440 dpavlin 4 machine->ps2_data = dev_ps2_stuff_init(machine, mem, 0x10000000);
2441 dpavlin 2 device_add(machine, "ps2_gs addr=0x12000000");
2442 dpavlin 4 device_add(machine, "ps2_ether addr=0x14001000");
2443 dpavlin 2 dev_ram_init(mem, 0x1c000000, 4 * 1048576, DEV_RAM_RAM, 0); /* TODO: how much? */
2444 dpavlin 4 /* irq = 8 + 32 + 1 (SBUS/USB) */
2445     device_add(machine, "ohci addr=0x1f801600 irq=41");
2446 dpavlin 2
2447     machine->md_interrupt = ps2_interrupt;
2448    
2449     add_symbol_name(&machine->symbol_context,
2450     PLAYSTATION2_SIFBIOS, 0x10000, "[SIFBIOS entry]", 0);
2451     store_32bit_word(cpu, PLAYSTATION2_BDA + 0, PLAYSTATION2_SIFBIOS);
2452     store_buf(cpu, PLAYSTATION2_BDA + 4, "PS2b", 4);
2453    
2454 dpavlin 4 /* Set the Harddisk controller present flag, if either
2455     disk 0 or 1 is present: */
2456     if (diskimage_exist(machine, 0) || diskimage_exist(machine, 1)) {
2457     store_32bit_word(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x0, 0x100);
2458     dev_ps2_spd_init(machine, mem, 0x14000000);
2459     }
2460 dpavlin 2
2461     store_32bit_word(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x4, PLAYSTATION2_OPTARGS);
2462 dpavlin 4 {
2463     int tmplen = 1000;
2464     char *tmp = malloc(tmplen);
2465     if (tmp == NULL) {
2466     fprintf(stderr, "out of memory\n");
2467     exit(1);
2468     }
2469 dpavlin 2
2470 dpavlin 4 strcpy(tmp, "root=/dev/hda1 crtmode=vesa0,60");
2471    
2472     if (machine->boot_string_argument[0])
2473     snprintf(tmp+strlen(tmp), tmplen-strlen(tmp),
2474     " %s", machine->boot_string_argument);
2475     tmp[tmplen-1] = '\0';
2476    
2477     bootstr = tmp;
2478     store_string(cpu, PLAYSTATION2_OPTARGS, bootstr);
2479     }
2480    
2481 dpavlin 2 /* TODO: netbsd's bootinfo.h, for symbolic names */
2482     {
2483     time_t timet;
2484     struct tm *tmp;
2485    
2486     /* RTC data given by the BIOS: */
2487     timet = time(NULL) + 9*3600; /* PS2 uses Japanese time */
2488     tmp = gmtime(&timet);
2489     /* TODO: are these 0- or 1-based? */
2490     store_byte(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x10 + 1, int_to_bcd(tmp->tm_sec));
2491     store_byte(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x10 + 2, int_to_bcd(tmp->tm_min));
2492     store_byte(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x10 + 3, int_to_bcd(tmp->tm_hour));
2493     store_byte(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x10 + 5, int_to_bcd(tmp->tm_mday));
2494     store_byte(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x10 + 6, int_to_bcd(tmp->tm_mon + 1));
2495     store_byte(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x10 + 7, int_to_bcd(tmp->tm_year - 100));
2496     }
2497    
2498     /* "BOOTINFO_PCMCIA_TYPE" in NetBSD's bootinfo.h. This contains the sbus controller type. */
2499 dpavlin 4 store_32bit_word(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x1c, 2);
2500 dpavlin 2
2501     break;
2502    
2503     case MACHINE_SGI:
2504     case MACHINE_ARC:
2505     /*
2506     * SGI and ARC emulation share a lot of code. (SGI is a special case of
2507     * "almost ARC".)
2508     *
2509     * http://obsolete.majix.org/computers/sgi/iptable.shtml contains a pretty
2510     * detailed list of IP ("Inhouse Processor") model numbers.
2511     * (Or http://hardware.majix.org/computers/sgi/iptable.shtml)
2512     */
2513     machine->machine_name = malloc(500);
2514     if (machine->machine_name == NULL) {
2515     fprintf(stderr, "out of memory\n");
2516     exit(1);
2517     }
2518     short_machine_name = malloc(500);
2519     if (short_machine_name == NULL) {
2520     fprintf(stderr, "out of memory\n");
2521     exit(1);
2522     }
2523    
2524     if (machine->machine_type == MACHINE_SGI) {
2525     cpu->byte_order = EMUL_BIG_ENDIAN;
2526     sprintf(short_machine_name, "SGI-IP%i", machine->machine_subtype);
2527     sprintf(machine->machine_name, "SGI-IP%i", machine->machine_subtype);
2528    
2529     /* Super-special case for IP24: */
2530     if (machine->machine_subtype == 24)
2531     sprintf(short_machine_name, "SGI-IP22");
2532    
2533     sgi_ram_offset = 1048576 * machine->memory_offset_in_mb;
2534    
2535     /* Special cases for IP20,22,24,26 memory offset: */
2536     if (machine->machine_subtype == 20 || machine->machine_subtype == 22 ||
2537     machine->machine_subtype == 24 || machine->machine_subtype == 26) {
2538     dev_ram_init(mem, 0x00000000, 0x10000, DEV_RAM_MIRROR, sgi_ram_offset);
2539     dev_ram_init(mem, 0x00050000, sgi_ram_offset-0x50000, DEV_RAM_MIRROR, sgi_ram_offset + 0x50000);
2540     }
2541    
2542     /* Special cases for IP28,30 memory offset: */
2543     if (machine->machine_subtype == 28 || machine->machine_subtype == 30) {
2544     /* TODO: length below should maybe not be 128MB? */
2545     dev_ram_init(mem, 0x00000000, 128*1048576, DEV_RAM_MIRROR, sgi_ram_offset);
2546     }
2547     } else {
2548     cpu->byte_order = EMUL_LITTLE_ENDIAN;
2549     sprintf(short_machine_name, "ARC");
2550     sprintf(machine->machine_name, "ARC");
2551     }
2552    
2553     if (machine->machine_type == MACHINE_SGI) {
2554     /* TODO: Other SGI machine types? */
2555     switch (machine->machine_subtype) {
2556     case 12:
2557     strcat(machine->machine_name, " (Iris Indigo IP12)");
2558    
2559     /* TODO */
2560     /* 33 MHz R3000, according to http://www.irisindigo.com/ */
2561     /* "capable of addressing up to 96MB of memory." */
2562    
2563     break;
2564     case 19:
2565     strcat(machine->machine_name, " (Everest IP19)");
2566     machine->main_console_handle =
2567     dev_zs_init(machine, mem, 0x1fbd9830, 0, 1, "serial zs"); /* serial? netbsd? */
2568     dev_scc_init(machine, mem, 0x10086000, 0, machine->use_x11, 0, 8); /* serial? irix? */
2569    
2570     device_add(machine, "sgi_ip19 addr=0x18000000");
2571    
2572     /* Irix' <everest_du_init+0x130> reads this device: */
2573     device_add(machine, "random addr=0x10006000 len=16");
2574    
2575     /* Irix' get_mpconf() looks for this: (TODO) */
2576     store_32bit_word(cpu, 0xa0000000 + 0x3000,
2577     0xbaddeed2);
2578    
2579     /* Memory size, not 4096 byte pages, but 256 bytes? (16 is size of kernel... approx) */
2580     store_32bit_word(cpu, 0xa0000000 + 0x26d0,
2581     30000); /* (machine->physical_ram_in_mb - 16) * (1048576 / 256)); */
2582    
2583     break;
2584     case 20:
2585     strcat(machine->machine_name, " (Indigo)");
2586    
2587     /*
2588     * Guesses based on NetBSD 2.0 beta, 20040606.
2589     *
2590     * int0 at mainbus0 addr 0x1fb801c0: bus 1MHz, CPU 2MHz
2591     * imc0 at mainbus0 addr 0x1fa00000: revision 0
2592     * gio0 at imc0
2593     * unknown GIO card (product 0x00 revision 0x00) at gio0 slot 0 addr 0x1f400000 not configured
2594     * unknown GIO card (product 0x00 revision 0x00) at gio0 slot 1 addr 0x1f600000 not configured
2595     * unknown GIO card (product 0x00 revision 0x00) at gio0 slot 2 addr 0x1f000000 not configured
2596     * hpc0 at gio0 addr 0x1fb80000: SGI HPC1
2597     * zsc0 at hpc0 offset 0xd10 (channels 0 and 1, channel 1 for console)
2598     * zsc1 at hpc0 offset 0xd00 (2 channels)
2599     * sq0 at hpc0 offset 0x100: SGI Seeq 80c03
2600     * wdsc0 at hpc0 offset 0x11f
2601     * dpclock0 at hpc0 offset 0xe00
2602     */
2603    
2604     /* int0 at mainbus0 addr 0x1fb801c0 */
2605     machine->sgi_ip20_data = dev_sgi_ip20_init(cpu, mem, DEV_SGI_IP20_BASE);
2606    
2607     /* imc0 at mainbus0 addr 0x1fa00000: revision 0: TODO (or in dev_sgi_ip20?) */
2608    
2609     dev_zs_init(machine, mem, 0x1fbd9830, 0, 1, "zs console");
2610    
2611     /* This is the zsc0 reported by NetBSD: TODO: irqs */
2612     machine->main_console_handle = dev_zs_init(machine, mem, 0x1fb80d10, 0, 1, "zsc0"); /* zsc0 */
2613     dev_zs_init(machine, mem, 0x1fb80d00, 0, 1, "zsc1"); /* zsc1 */
2614    
2615     /* WDSC SCSI controller: */
2616     dev_wdsc_init(machine, mem, 0x1fb8011f, 0, 0);
2617    
2618     /* Return memory read errors so that hpc1
2619     and hpc2 are not detected: */
2620     device_add(machine, "unreadable addr=0x1fb00000 len=0x10000");
2621     device_add(machine, "unreadable addr=0x1f980000 len=0x10000");
2622    
2623     /* Return nothing for gio slots 0, 1, and 2: */
2624     device_add(machine, "unreadable addr=0x1f400000 len=0x1000"); /* gio0 slot 0 */
2625     device_add(machine, "unreadable addr=0x1f600000 len=0x1000"); /* gio0 slot 1 */
2626     device_add(machine, "unreadable addr=0x1f000000 len=0x1000"); /* gio0 slot 2 */
2627    
2628     break;
2629     case 21:
2630     strcat(machine->machine_name, " (uknown SGI-IP21 ?)"); /* TODO */
2631     /* NOTE: Special case for arc_wordlen: */
2632     arc_wordlen = sizeof(uint64_t);
2633    
2634     device_add(machine, "random addr=0x418000200, len=0x20000");
2635    
2636     break;
2637     case 22:
2638     case 24:
2639     if (machine->machine_subtype == 22) {
2640     strcat(machine->machine_name, " (Indy, Indigo2, Challenge S; Full-house)");
2641     machine->sgi_ip22_data = dev_sgi_ip22_init(machine, mem, 0x1fbd9000, 0);
2642     } else {
2643     strcat(machine->machine_name, " (Indy, Indigo2, Challenge S; Guiness)");
2644     machine->sgi_ip22_data = dev_sgi_ip22_init(machine, mem, 0x1fbd9880, 1);
2645     }
2646    
2647     /*
2648     Why is this here? TODO
2649     dev_ram_init(mem, 0x88000000ULL,
2650     128 * 1048576, DEV_RAM_MIRROR, 0x08000000);
2651     */
2652     machine->md_interrupt = sgi_ip22_interrupt;
2653    
2654     /*
2655     * According to NetBSD 1.6.2:
2656     *
2657     * imc0 at mainbus0 addr 0x1fa00000, Revision 0
2658     * gio0 at imc0
2659     * hpc0 at gio0 addr 0x1fb80000: SGI HPC3
2660     * zsc0 at hpc0 offset 0x59830
2661     * zstty0 at zsc0 channel 1 (console i/o)
2662     * zstty1 at zsc0 channel 0
2663     * sq0 at hpc0 offset 0x54000: SGI Seeq 80c03 (Ethernet)
2664     * wdsc0 at hpc0 offset 0x44000: WD33C93 SCSI, rev=0, target 7
2665     * scsibus2 at wdsc0: 8 targets, 8 luns per target
2666     * dsclock0 at hpc0 offset 0x60000
2667     *
2668     * According to Linux/IP22:
2669     * tty00 at 0xbfbd9830 (irq = 45) is a Zilog8530
2670     * tty01 at 0xbfbd9838 (irq = 45) is a Zilog8530
2671     *
2672     * and according to NetBSD 2.0_BETA (20040606):
2673     *
2674     * haltwo0 at hpc0 offset 0x58000: HAL2 revision 0.0.0
2675     * audio0 at haltwo0: half duplex
2676     *
2677     * IRQ numbers are of the form 8 + x, where x = 0..31 for local0
2678     * interrupts, and 32..63 for local1. + y*65 for "mappable".
2679     */
2680    
2681     /* zsc0 serial console. */
2682     i = dev_zs_init(machine, mem, 0x1fbd9830,
2683     8 + 32 + 3 + 64*5, 1, "zsc0");
2684    
2685     /* Not supported by NetBSD 1.6.2, but by 2.0_BETA: */
2686     j = dev_pckbc_init(machine, mem, 0x1fbd9840, PCKBC_8242,
2687     0, 0, machine->use_x11); /* TODO: irq numbers */
2688    
2689     if (machine->use_x11)
2690     machine->main_console_handle = j;
2691    
2692     /* sq0: Ethernet. TODO: This should have irq_nr = 8 + 3 */
2693     /* dev_sq_init... */
2694    
2695     /* wdsc0: SCSI */
2696     dev_wdsc_init(machine, mem, 0x1fbc4000, 0, 8 + 1);
2697    
2698     /* wdsc1: SCSI TODO: irq nr */
2699     dev_wdsc_init(machine, mem, 0x1fbcc000, 1, 8 + 1);
2700    
2701     /* dsclock0: TODO: possibly irq 8 + 33 */
2702    
2703     /* Return memory read errors so that hpc1 and hpc2 are not detected: */
2704     device_add(machine, "unreadable addr=0x1fb00000, len=0x10000");
2705     device_add(machine, "unreadable addr=0x1f980000, len=0x10000");
2706    
2707     /* Similarly for gio slots 0, 1, and 2: */
2708     device_add(machine, "unreadable addr=0x1f400000, len=0x1000"); /* gio0 slot 0 */
2709     device_add(machine, "unreadable addr=0x1f600000, len=0x1000"); /* gio0 slot 1 */
2710     device_add(machine, "unreadable addr=0x1f000000, len=0x1000"); /* gio0 slot 2 */
2711    
2712     break;
2713     case 25:
2714     /* NOTE: Special case for arc_wordlen: */
2715     arc_wordlen = sizeof(uint64_t);
2716     strcat(machine->machine_name, " (Everest IP25)");
2717    
2718     /* serial? irix? */
2719     dev_scc_init(machine, mem,
2720     0x400086000ULL, 0, machine->use_x11, 0, 8);
2721    
2722     /* NOTE: ip19! (perhaps not really the same */
2723     device_add(machine, "sgi_ip19 addr=0x18000000");
2724    
2725     /*
2726     * Memory size, not 4096 byte pages, but 256
2727     * bytes? (16 is size of kernel... approx)
2728     */
2729     store_32bit_word(cpu, 0xa0000000ULL + 0x26d0,
2730     30000); /* (machine->physical_ram_in_mb - 16)
2731     * (1048576 / 256)); */
2732    
2733     break;
2734     case 26:
2735     /* NOTE: Special case for arc_wordlen: */
2736     arc_wordlen = sizeof(uint64_t);
2737     strcat(machine->machine_name,
2738     " (uknown SGI-IP26 ?)"); /* TODO */
2739     machine->main_console_handle =
2740     dev_zs_init(machine, mem, 0x1fbd9830,
2741     0, 1, "zs console");
2742     break;
2743     case 27:
2744     strcat(machine->machine_name,
2745     " (Origin 200/2000, Onyx2)");
2746     arc_wordlen = sizeof(uint64_t);
2747     /* 2 cpus per node */
2748    
2749     machine->main_console_handle =
2750     dev_zs_init(machine, mem, 0x1fbd9830,
2751     0, 1, "zs console");
2752     break;
2753     case 28:
2754     /* NOTE: Special case for arc_wordlen: */
2755     arc_wordlen = sizeof(uint64_t);
2756     strcat(machine->machine_name, " (Impact Indigo2 ?)");
2757    
2758     device_add(machine, "random addr=0x1fbe0000, len=1");
2759    
2760     /* Something at paddr 0x1880fb0000. */
2761    
2762     break;
2763     case 30:
2764     /* NOTE: Special case for arc_wordlen: */
2765     arc_wordlen = sizeof(uint64_t);
2766     strcat(machine->machine_name, " (Octane)");
2767    
2768     machine->sgi_ip30_data = dev_sgi_ip30_init(machine, mem, 0x0ff00000);
2769     machine->md_interrupt = sgi_ip30_interrupt;
2770    
2771     dev_ram_init(mem, 0xa0000000ULL,
2772     128 * 1048576, DEV_RAM_MIRROR, 0x00000000);
2773    
2774     dev_ram_init(mem, 0x80000000ULL,
2775     32 * 1048576, DEV_RAM_RAM, 0x00000000);
2776    
2777     /*
2778     * Something at paddr=1f022004: TODO
2779     * Something at paddr=813f0510 - paddr=813f0570 ?
2780     * Something at paddr=813f04b8
2781     * Something at paddr=f8000003c used by Linux/Octane
2782     *
2783     * 16550 serial port at paddr=1f620178, addr mul 1
2784     * (Error messages are printed to this serial port by the PROM.)
2785     *
2786     * There seems to also be a serial port at 1f620170. The "symmon"
2787     * program dumps something there, but it doesn't look like
2788     * readable text. (TODO)
2789     */
2790     machine->main_console_handle = dev_ns16550_init(machine, mem, 0x1f620170, 0, 1,
2791     machine->use_x11? 0 : 1, "serial 0"); /* TODO: irq? */
2792     dev_ns16550_init(machine, mem, 0x1f620178, 0, 1,
2793     0, "serial 1"); /* TODO: irq? */
2794    
2795     /* MardiGras graphics: */
2796     device_add(machine, "sgi_mardigras addr=0x1c000000");
2797    
2798     break;
2799     case 32:
2800     strcat(machine->machine_name, " (O2)");
2801    
2802     /* TODO: Find out where the physical ram is actually located. */
2803     dev_ram_init(mem, 0x07ffff00ULL, 256, DEV_RAM_MIRROR, 0x03ffff00);
2804     dev_ram_init(mem, 0x10000000ULL, 256, DEV_RAM_MIRROR, 0x00000000);
2805     dev_ram_init(mem, 0x11ffff00ULL, 256, DEV_RAM_MIRROR, 0x01ffff00);
2806     dev_ram_init(mem, 0x12000000ULL, 256, DEV_RAM_MIRROR, 0x02000000);
2807     dev_ram_init(mem, 0x17ffff00ULL, 256, DEV_RAM_MIRROR, 0x03ffff00);
2808     dev_ram_init(mem, 0x20000000ULL, 128 * 1048576, DEV_RAM_MIRROR, 0x00000000);
2809     dev_ram_init(mem, 0x40000000ULL, 128 * 1048576, DEV_RAM_MIRROR, 0x10000000);
2810    
2811     machine->crime_data = dev_crime_init(machine, mem, 0x14000000, 2, machine->use_x11); /* crime0 */
2812     dev_sgi_mte_init(mem, 0x15000000); /* mte ??? memory thing */
2813     dev_sgi_gbe_init(machine, mem, 0x16000000); /* gbe? framebuffer? */
2814    
2815     /*
2816     * A combination of NetBSD and Linux info:
2817     *
2818     * 17000000 vice (Video Image Compression Engine)
2819     * 1f000000 mace
2820     * 1f080000 macepci
2821     * 1f100000 vin1
2822     * 1f180000 vin2
2823     * 1f200000 vout
2824     * 1f280000 enet (mec0, MAC-110 Ethernet)
2825     * 1f300000 perif:
2826     * 1f300000 audio
2827     * 1f310000 isa
2828     * 1f318000 (accessed by Irix' pciio_pio_write64)
2829     * 1f320000 kbdms
2830     * 1f330000 i2c
2831     * 1f340000 ust
2832     * 1f380000 isa ext
2833     * 1f390000 com0 (serial)
2834     * 1f398000 com1 (serial)
2835     * 1f3a0000 mcclock0
2836     */
2837    
2838     machine->mace_data = dev_mace_init(mem, 0x1f310000, 2);
2839     machine->md_interrupt = sgi_ip32_interrupt;
2840    
2841     /*
2842     * IRQ mapping is really ugly. TODO: fix
2843     *
2844     * com0 at mace0 offset 0x390000 intr 4 intrmask 0x3f00000: ns16550a, working fifo
2845     * com1 at mace0 offset 0x398000 intr 4 intrmask 0xfc000000: ns16550a, working fifo
2846     * pckbc0 at mace0 offset 0x320000 intr 5 intrmask 0x0
2847     * mcclock0 at mace0 offset 0x3a0000 intrmask 0x0
2848     * macepci0 at mace0 offset 0x80000 intr 7 intrmask 0x0: rev 1
2849     *
2850     * intr 4 = MACE_PERIPH_SERIAL
2851     * intr 5 = MACE_PERIPH_MISC
2852     * intr 7 = MACE_PCI_BRIDGE
2853     */
2854    
2855     i = dev_pckbc_init(machine, mem, 0x1f320000,
2856     PCKBC_8242, 0x200 + MACE_PERIPH_MISC,
2857     0x800 + MACE_PERIPH_MISC, machine->use_x11);
2858     /* keyb+mouse (mace irq numbers) */
2859    
2860     net_generate_unique_mac(machine, macaddr);
2861     eaddr_string = malloc(30);
2862     if (eaddr_string == NULL) {
2863     fprintf(stderr, "out of memory\n");
2864     exit(1);
2865     }
2866     sprintf(eaddr_string, "eaddr=%02x:%02x:"
2867     "%02x:%02x:%02x:%02x",
2868     macaddr[0], macaddr[1], macaddr[2],
2869     macaddr[3], macaddr[4], macaddr[5]);
2870     dev_sgi_mec_init(machine, mem, 0x1f280000, MACE_ETHERNET, macaddr);
2871    
2872     dev_sgi_ust_init(mem, 0x1f340000); /* ust? */
2873    
2874     j = dev_ns16550_init(machine, mem, 0x1f390000,
2875     (1<<20) + MACE_PERIPH_SERIAL, 0x100,
2876     machine->use_x11? 0 : 1, "serial 0"); /* com0 */
2877     dev_ns16550_init(machine, mem, 0x1f398000,
2878     (1<<26) + MACE_PERIPH_SERIAL, 0x100,
2879     0, "serial 1"); /* com1 */
2880    
2881     if (machine->use_x11)
2882     machine->main_console_handle = i;
2883     else
2884     machine->main_console_handle = j;
2885    
2886     dev_mc146818_init(machine, mem, 0x1f3a0000, (1<<8) + MACE_PERIPH_MISC, MC146818_SGI, 0x40); /* mcclock0 */
2887     dev_zs_init(machine, mem, 0x1fbd9830, 0, 1, "zs console");
2888    
2889     /*
2890     * PCI devices: (according to NetBSD's GENERIC config file for sgimips)
2891     *
2892     * ne* at pci? dev ? function ?
2893     * ahc0 at pci0 dev 1 function ?
2894     * ahc1 at pci0 dev 2 function ?
2895     */
2896    
2897     pci_data = dev_macepci_init(mem, 0x1f080000, MACE_PCI_BRIDGE); /* macepci0 */
2898     /* bus_pci_add(machine, pci_data, mem, 0, 0, 0, pci_ne2000_init, pci_ne2000_rr); TODO */
2899     #if 1
2900     bus_pci_add(machine, pci_data, mem, 0, 1, 0, pci_ahc_init, pci_ahc_rr);
2901     #endif
2902     /* bus_pci_add(machine, pci_data, mem, 0, 2, 0, pci_ahc_init, pci_ahc_rr); */
2903    
2904     break;
2905     case 35:
2906     strcat(machine->machine_name, " (Origin 3000)");
2907     /* 4 cpus per node */
2908    
2909     machine->main_console_handle =
2910     dev_zs_init(machine, mem, 0x1fbd9830,
2911     0, 1, "zs console");
2912     break;
2913     case 53:
2914     strcat(machine->machine_name, " (Origin 350)");
2915     /*
2916     * According to http://kumba.drachentekh.net/xml/myguide.html
2917     * Origin 350, Tezro IP53 R16000
2918     */
2919     break;
2920     default:
2921     fatal("unimplemented SGI machine type IP%i\n",
2922     machine->machine_subtype);
2923     exit(1);
2924     }
2925     } else {
2926     switch (machine->machine_subtype) {
2927    
2928     case MACHINE_ARC_NEC_RD94:
2929     case MACHINE_ARC_NEC_R94:
2930     case MACHINE_ARC_NEC_R96:
2931     /*
2932     * "NEC-RD94" (NEC RISCstation 2250)
2933     * "NEC-R94" (NEC RISCstation 2200)
2934     * "NEC-R96" (NEC Express RISCserver)
2935     *
2936     * http://mirror.aarnet.edu.au/pub/NetBSD/misc/chs/arcdiag.out (NEC-R96)
2937     */
2938    
2939     switch (machine->machine_subtype) {
2940     case MACHINE_ARC_NEC_RD94:
2941     strcat(machine->machine_name, " (NEC-RD94, NEC RISCstation 2250)");
2942     break;
2943     case MACHINE_ARC_NEC_R94:
2944     strcat(machine->machine_name, " (NEC-R94; NEC RISCstation 2200)");
2945     break;
2946     case MACHINE_ARC_NEC_R96:
2947     strcat(machine->machine_name, " (NEC-R96; NEC Express RISCserver)");
2948     break;
2949     }
2950    
2951     /* TODO: interrupt controller! */
2952    
2953     pci_data = device_add(machine,
2954     "rd94 addr=0x80000000, irq=0");
2955    
2956     device_add(machine, "sn addr=0x80001000 irq=0");
2957     dev_mc146818_init(machine, mem, 0x80004000ULL, 0, MC146818_ARC_NEC, 1);
2958     i = dev_pckbc_init(machine, mem, 0x80005000ULL, PCKBC_8042, 0, 0, machine->use_x11);
2959     j = dev_ns16550_init(machine, mem, 0x80006000ULL,
2960     3, 1, machine->use_x11? 0 : 1, "serial 0"); /* com0 */
2961     dev_ns16550_init(machine, mem, 0x80007000ULL,
2962     0, 1, 0, "serial 1"); /* com1 */
2963    
2964     if (machine->use_x11)
2965     machine->main_console_handle = i;
2966     else
2967     machine->main_console_handle = j;
2968    
2969     /* lpt at 0x80008000 */
2970    
2971     device_add(machine, "fdc addr=0x8000c000, irq=0");
2972    
2973     switch (machine->machine_subtype) {
2974     case MACHINE_ARC_NEC_RD94:
2975     case MACHINE_ARC_NEC_R94:
2976     /* PCI devices: (NOTE: bus must be 0, device must be 3, 4, or 5, for NetBSD to accept interrupts) */
2977     bus_pci_add(machine, pci_data, mem, 0, 3, 0, pci_dec21030_init, pci_dec21030_rr); /* tga graphics */
2978     break;
2979     case MACHINE_ARC_NEC_R96:
2980     dev_fb_init(machine, mem, 0x100e00000ULL,
2981     VFB_GENERIC, 640,480, 1024,480,
2982     8, "necvdfrb", 1);
2983     break;
2984     }
2985     break;
2986    
2987     case MACHINE_ARC_NEC_R98:
2988     /*
2989     * "NEC-R98" (NEC RISCserver 4200)
2990     *
2991     * According to http://mail-index.netbsd.org/port-arc/2004/02/01/0001.html:
2992     *
2993     * Network adapter at "start: 0x 0 18600000, length: 0x1000, level: 4, vector: 9"
2994     * Disk at "start: 0x 0 18c103f0, length: 0x1000, level: 5, vector: 6"
2995     * Keyboard at "start: 0x 0 18c20060, length: 0x1000, level: 5, vector: 3"
2996     * Serial at "start: 0x 0 18c103f8, length: 0x1000, level: 5, vector: 4"
2997     * Serial at "start: 0x 0 18c102f8, length: 0x1000, level: 5, vector: 4"
2998     * Parallel at "start: 0x 0 18c10278, length: 0x1000, level: 5, vector: 5"
2999     */
3000    
3001     strcat(machine->machine_name, " (NEC-R98; NEC RISCserver 4200)");
3002    
3003     /*
3004     * Windows NT access stuff at these addresses:
3005     *
3006     * 19980308, 18000210, 18c0a008,
3007     * 19022018, 19026010, andso on.
3008     */
3009     break;
3010    
3011     case MACHINE_ARC_JAZZ_PICA:
3012     case MACHINE_ARC_JAZZ_MAGNUM:
3013     /*
3014     * "PICA-61"
3015     *
3016     * According to NetBSD 1.6.2:
3017     *
3018     * jazzio0 at mainbus0
3019     * timer0 at jazzio0 addr 0xe0000228
3020     * mcclock0 at jazzio0 addr 0xe0004000: mc146818 or compatible
3021     * lpt at jazzio0 addr 0xe0008000 intr 0 not configured
3022     * fdc at jazzio0 addr 0xe0003000 intr 1 not configured
3023     * MAGNUM at jazzio0 addr 0xe000c000 intr 2 not configured
3024     * ALI_S3 at jazzio0 addr 0xe0800000 intr 3 not configured
3025     * sn0 at jazzio0 addr 0xe0001000 intr 4: SONIC Ethernet
3026     * sn0: Ethernet address 69:6a:6b:6c:00:00
3027     * asc0 at jazzio0 addr 0xe0002000 intr 5: NCR53C94, target 0
3028     * pckbd at jazzio0 addr 0xe0005000 intr 6 not configured
3029     * pms at jazzio0 addr 0xe0005000 intr 7 not configured
3030     * com0 at jazzio0 addr 0xe0006000 intr 8: ns16550a, working fifo
3031     * com at jazzio0 addr 0xe0007000 intr 9 not configured
3032     * jazzisabr0 at mainbus0
3033     * isa0 at jazzisabr0 isa_io_base 0xe2000000 isa_mem_base 0xe3000000
3034     *
3035     * "Microsoft-Jazz", "MIPS Magnum"
3036     *
3037     * timer0 at jazzio0 addr 0xe0000228
3038     * mcclock0 at jazzio0 addr 0xe0004000: mc146818 or compatible
3039     * lpt at jazzio0 addr 0xe0008000 intr 0 not configured
3040     * fdc at jazzio0 addr 0xe0003000 intr 1 not configured
3041     * MAGNUM at jazzio0 addr 0xe000c000 intr 2 not configured
3042     * VXL at jazzio0 addr 0xe0800000 intr 3 not configured
3043     * sn0 at jazzio0 addr 0xe0001000 intr 4: SONIC Ethernet
3044     * sn0: Ethernet address 69:6a:6b:6c:00:00
3045     * asc0 at jazzio0 addr 0xe0002000 intr 5: NCR53C94, target 0
3046     * scsibus0 at asc0: 8 targets, 8 luns per target
3047     * pckbd at jazzio0 addr 0xe0005000 intr 6 not configured
3048     * pms at jazzio0 addr 0xe0005000 intr 7 not configured
3049     * com0 at jazzio0 addr 0xe0006000 intr 8: ns16550a, working fifo
3050     * com at jazzio0 addr 0xe0007000 intr 9 not configured
3051     * jazzisabr0 at mainbus0
3052     * isa0 at jazzisabr0 isa_io_base 0xe2000000 isa_mem_base 0xe3000000
3053     */
3054    
3055     switch (machine->machine_subtype) {
3056     case MACHINE_ARC_JAZZ_PICA:
3057     strcat(machine->machine_name, " (Microsoft Jazz, Acer PICA-61)");
3058     break;
3059     case MACHINE_ARC_JAZZ_MAGNUM:
3060     strcat(machine->machine_name, " (Microsoft Jazz, MIPS Magnum)");
3061     break;
3062     default:
3063     fatal("error in machine.c. jazz\n");
3064     exit(1);
3065     }
3066    
3067     machine->jazz_data = device_add(machine,
3068     "jazz addr=0x80000000");
3069     machine->md_interrupt = jazz_interrupt;
3070    
3071     switch (machine->machine_subtype) {
3072     case MACHINE_ARC_JAZZ_PICA:
3073     dev_vga_init(machine, mem,
3074     0x400b8000ULL, 0x600003c0ULL,
3075     ARC_CONSOLE_MAX_X, ARC_CONSOLE_MAX_Y, machine->machine_name);
3076     arcbios_console_init(cpu, 0x400b8000ULL,
3077     0x600003c0ULL, ARC_CONSOLE_MAX_X,
3078     ARC_CONSOLE_MAX_Y);
3079     break;
3080     case MACHINE_ARC_JAZZ_MAGNUM:
3081     /* PROM mirror? */
3082     dev_ram_init(mem, 0xfff00000, 0x100000,
3083     DEV_RAM_MIRROR, 0x1fc00000);
3084    
3085     /* VXL. TODO */
3086     /* control at 0x60100000? */
3087     dev_fb_init(machine, mem, 0x60200000ULL,
3088     VFB_GENERIC, 1024,768, 1024,768,
3089     8, "VXL", 1);
3090     break;
3091     }
3092    
3093     /* irq 8 + 4 */
3094     device_add(machine, "sn addr=0x80001000 irq=12");
3095    
3096     dev_asc_init(machine, mem,
3097     0x80002000ULL, 8 + 5, NULL, DEV_ASC_PICA,
3098     dev_jazz_dma_controller, machine->jazz_data);
3099    
3100     device_add(machine, "fdc addr=0x80003000, irq=0");
3101    
3102     dev_mc146818_init(machine, mem,
3103     0x80004000ULL, 2, MC146818_ARC_JAZZ, 1);
3104    
3105     i = dev_pckbc_init(machine, mem, 0x80005000ULL,
3106     PCKBC_JAZZ, 8 + 6, 8 + 7, machine->use_x11);
3107    
3108     j = dev_ns16550_init(machine, mem,
3109     0x80006000ULL, 8 + 8, 1,
3110     machine->use_x11? 0 : 1, "serial 0");
3111     dev_ns16550_init(machine, mem,
3112     0x80007000ULL, 8 + 9, 1, 0, "serial 1");
3113    
3114     if (machine->use_x11)
3115     machine->main_console_handle = i;
3116     else
3117     machine->main_console_handle = j;
3118    
3119     #if 0
3120     Not yet.
3121     dev_wdc_init(machine, mem, 0x900001f0ULL, 8+16 + 14, 0);
3122     #endif
3123    
3124     break;
3125    
3126     case MACHINE_ARC_JAZZ_M700:
3127     /*
3128     * "Microsoft-Jazz", "Olivetti M700"
3129     *
3130     * Different enough from Pica and Magnum to be
3131     * separate here.
3132     *
3133     * See http://mail-index.netbsd.org/port-arc/2000/10/18/0001.html.
3134     */
3135    
3136     strcat(machine->machine_name, " (Microsoft Jazz, Olivetti M700)");
3137    
3138     machine->jazz_data = device_add(machine,
3139     "jazz addr=0x80000000");
3140     machine->md_interrupt = jazz_interrupt;
3141    
3142     dev_mc146818_init(machine, mem,
3143     0x80004000ULL, 2, MC146818_ARC_JAZZ, 1);
3144    
3145     i = 0; /* TODO: Yuck! */
3146     #if 0
3147     i = dev_pckbc_init(machine, mem, 0x80005000ULL,
3148     PCKBC_JAZZ, 8 + 6, 8 + 7, machine->use_x11);
3149     #endif
3150     j = dev_ns16550_init(machine, mem,
3151     0x80006000ULL, 8 + 8, 1,
3152     machine->use_x11? 0 : 1, "serial 0");
3153     dev_ns16550_init(machine, mem,
3154     0x80007000ULL, 8 + 9, 1, 0, "serial 1");
3155    
3156     if (machine->use_x11)
3157     machine->main_console_handle = i;
3158     else
3159     machine->main_console_handle = j;
3160    
3161     dev_m700_fb_init(machine, mem,
3162     0x180080000ULL, 0x100000000ULL);
3163    
3164     break;
3165    
3166     case MACHINE_ARC_DESKTECH_TYNE:
3167     /*
3168     * "Deskstation Tyne" (?)
3169     *
3170     * TODO
3171     * http://mail-index.netbsd.org/port-arc/2000/10/14/0000.html
3172     */
3173    
3174     strcat(machine->machine_name, " (Deskstation Tyne)");
3175    
3176     dev_vga_init(machine, mem, 0x1000b8000ULL, 0x9000003c0ULL,
3177     ARC_CONSOLE_MAX_X, ARC_CONSOLE_MAX_Y, machine->machine_name);
3178    
3179     arcbios_console_init(cpu, 0x1000b8000ULL,
3180     0x9000003c0ULL, ARC_CONSOLE_MAX_X,
3181     ARC_CONSOLE_MAX_Y);
3182    
3183     i = dev_ns16550_init(machine, mem, 0x9000003f8ULL, 0, 1, machine->use_x11? 0 : 1, "serial 0");
3184     dev_ns16550_init(machine, mem, 0x9000002f8ULL, 0, 1, 0, "serial 1");
3185     dev_ns16550_init(machine, mem, 0x9000003e8ULL, 0, 1, 0, "serial 2");
3186     dev_ns16550_init(machine, mem, 0x9000002e8ULL, 0, 1, 0, "serial 3");
3187    
3188     dev_mc146818_init(machine, mem,
3189     0x900000070ULL, 2, MC146818_PC_CMOS, 1);
3190    
3191     #if 0
3192     dev_wdc_init(machine, mem, 0x9000001f0ULL, 0, 0);
3193     dev_wdc_init(machine, mem, 0x900000170ULL, 0, 2);
3194     #endif
3195     /* PC kbd */
3196     j = dev_pckbc_init(machine, mem, 0x900000060ULL,
3197     PCKBC_8042, 0, 0, machine->use_x11);
3198    
3199     if (machine->use_x11)
3200     machine->main_console_handle = j;
3201     else
3202     machine->main_console_handle = i;
3203    
3204     break;
3205    
3206     default:
3207     fatal("Unimplemented ARC machine type %i\n",
3208     machine->machine_subtype);
3209     exit(1);
3210     }
3211     }
3212    
3213    
3214     if (!machine->prom_emulation)
3215     goto no_arc_prom_emulation; /* TODO: ugly */
3216    
3217    
3218     /*
3219     * This is important: :-)
3220     *
3221     * TODO: There should not be any use of
3222     * ARCBIOS before this statement.
3223     */
3224     if (arc_wordlen == sizeof(uint64_t))
3225     arcbios_set_64bit_mode(1);
3226    
3227     if (machine->physical_ram_in_mb < 16)
3228     fprintf(stderr, "WARNING! The ARC platform specification doesn't allow less than 16 MB of RAM. Continuing anyway.\n");
3229    
3230     arcbios_set_default_exception_handler(cpu);
3231    
3232     memset(&arcbios_sysid, 0, sizeof(arcbios_sysid));
3233     if (machine->machine_type == MACHINE_SGI) {
3234     /* Vendor ID, max 8 chars: */
3235     strncpy(arcbios_sysid.VendorId, "SGI", 3);
3236     switch (machine->machine_subtype) {
3237     case 22:
3238     strncpy(arcbios_sysid.ProductId,
3239     "87654321", 8); /* some kind of ID? */
3240     break;
3241     case 32:
3242     strncpy(arcbios_sysid.ProductId, "8", 1);
3243     /* 6 or 8 (?) */
3244     break;
3245     default:
3246     snprintf(arcbios_sysid.ProductId, 8, "IP%i",
3247     machine->machine_subtype);
3248     }
3249     } else {
3250     switch (machine->machine_subtype) {
3251     case MACHINE_ARC_NEC_RD94:
3252     strncpy(arcbios_sysid.VendorId, "NEC W&S", 8); /* NOTE: max 8 chars */
3253     strncpy(arcbios_sysid.ProductId, "RD94", 4); /* NOTE: max 8 chars */
3254     break;
3255     case MACHINE_ARC_NEC_R94:
3256     strncpy(arcbios_sysid.VendorId, "NEC W&S", 8); /* NOTE: max 8 chars */
3257     strncpy(arcbios_sysid.ProductId, "ijkl", 4); /* NOTE: max 8 chars */
3258     break;
3259     case MACHINE_ARC_NEC_R96:
3260     strncpy(arcbios_sysid.VendorId, "MIPS DUO", 8); /* NOTE: max 8 chars */
3261     strncpy(arcbios_sysid.ProductId, "blahblah", 8); /* NOTE: max 8 chars */
3262     break;
3263     case MACHINE_ARC_NEC_R98:
3264     strncpy(arcbios_sysid.VendorId, "NEC W&S", 8); /* NOTE: max 8 chars */
3265     strncpy(arcbios_sysid.ProductId, "R98", 4); /* NOTE: max 8 chars */
3266     break;
3267     case MACHINE_ARC_JAZZ_PICA:
3268     strncpy(arcbios_sysid.VendorId, "MIPS MAG", 8);/* NOTE: max 8 chars */
3269     strncpy(arcbios_sysid.ProductId, "ijkl", 4); /* NOTE: max 8 chars */
3270     break;
3271     case MACHINE_ARC_JAZZ_MAGNUM:
3272     strncpy(arcbios_sysid.VendorId, "MIPS MAG", 8);/* NOTE: max 8 chars */
3273     strncpy(arcbios_sysid.ProductId, "ijkl", 4); /* NOTE: max 8 chars */
3274     break;
3275     case MACHINE_ARC_JAZZ_M700:
3276     strncpy(arcbios_sysid.VendorId, "OLI00000", 8);/* NOTE: max 8 chars */
3277     strncpy(arcbios_sysid.ProductId, "ijkl", 4); /* NOTE: max 8 chars */
3278     break;
3279     case MACHINE_ARC_DESKTECH_TYNE:
3280     strncpy(arcbios_sysid.VendorId, "DESKTECH", 8);/* NOTE: max 8 chars */
3281     strncpy(arcbios_sysid.ProductId, "ijkl", 4); /* NOTE: max 8 chars */
3282     break;
3283     default:
3284     fatal("error in machine.c sysid\n");
3285     exit(1);
3286     }
3287     }
3288     store_buf(cpu, SGI_SYSID_ADDR, (char *)&arcbios_sysid, sizeof(arcbios_sysid));
3289    
3290     arcbios_get_dsp_stat(cpu, &arcbios_dsp_stat);
3291     store_buf(cpu, ARC_DSPSTAT_ADDR, (char *)&arcbios_dsp_stat, sizeof(arcbios_dsp_stat));
3292    
3293     /*
3294     * The first 12 MBs of RAM are simply reserved... this simplifies things a lot.
3295     * If there's more than 512MB of RAM, it has to be split in two, according to
3296     * the ARC spec. This code creates a number of chunks of at most 512MB each.
3297     *
3298     * NOTE: The region of physical address space between 0x10000000 and 0x1fffffff
3299     * (256 - 512 MB) is usually occupied by memory mapped devices, so that portion is "lost".
3300     */
3301    
3302     arc_reserved = 0x2000;
3303     if (machine->machine_type == MACHINE_SGI)
3304     arc_reserved = 0x4000;
3305    
3306     arcbios_add_memory_descriptor(cpu, 0, arc_reserved, ARCBIOS_MEM_FirmwarePermanent);
3307     arcbios_add_memory_descriptor(cpu, sgi_ram_offset + arc_reserved, 0x60000-arc_reserved, ARCBIOS_MEM_FirmwareTemporary);
3308    
3309     mem_base = 12;
3310     mem_base += sgi_ram_offset / 1048576;
3311    
3312     while (mem_base < machine->physical_ram_in_mb + sgi_ram_offset/1048576) {
3313     mem_count = machine->physical_ram_in_mb + sgi_ram_offset/1048576
3314     - mem_base;
3315    
3316     /* Skip the 256-512MB region (for devices) */
3317     if (mem_base < 256 && mem_base + mem_count > 256) {
3318     mem_count = 256-mem_base;
3319     }
3320    
3321     /* At most 512MB per descriptor (at least the first 512MB
3322     must be separated this way, according to the ARC spec) */
3323     if (mem_count > 512)
3324     mem_count = 512;
3325    
3326     arcbios_add_memory_descriptor(cpu, mem_base * 1048576,
3327     mem_count * 1048576, ARCBIOS_MEM_FreeMemory);
3328    
3329     mem_base += mem_count;
3330    
3331     /* Skip the devices: */
3332     if (mem_base == 256)
3333     mem_base = 512;
3334     }
3335    
3336    
3337     /*
3338     * Components: (this is an example of what a system could look like)
3339     *
3340     * [System]
3341     * [CPU] (one for each cpu)
3342     * [FPU] (one for each cpu)
3343     * [CPU Caches]
3344     * [Memory]
3345     * [Ethernet]
3346     * [Serial]
3347     * [SCSI]
3348     * [Disk]
3349     *
3350     * Here's a good list of what hardware is in different IP-models:
3351     * http://www.linux-mips.org/archives/linux-mips/2001-03/msg00101.html
3352     */
3353    
3354     if (machine->machine_name == NULL)
3355     fatal("ERROR: machine_name == NULL\n");
3356     if (short_machine_name == NULL)
3357     fatal("ERROR: short_machine_name == NULL\n");
3358    
3359     switch (machine->machine_type) {
3360     case MACHINE_SGI:
3361     system = arcbios_addchild_manual(cpu, COMPONENT_CLASS_SystemClass, COMPONENT_TYPE_ARC,
3362     0, 1, 2, 0, 0xffffffff, short_machine_name, 0 /* ROOT */ , NULL, 0);
3363     break;
3364     default:
3365     /* ARC: */
3366     switch (machine->machine_subtype) {
3367     case MACHINE_ARC_NEC_RD94:
3368     system = arcbios_addchild_manual(cpu, COMPONENT_CLASS_SystemClass, COMPONENT_TYPE_ARC,
3369     0, 1, 2, 0, 0xffffffff, "NEC-RD94", 0 /* ROOT */ , NULL, 0);
3370     break;
3371     case MACHINE_ARC_NEC_R94:
3372     system = arcbios_addchild_manual(cpu, COMPONENT_CLASS_SystemClass, COMPONENT_TYPE_ARC,
3373     0, 1, 2, 0, 0xffffffff, "NEC-R94", 0 /* ROOT */ , NULL, 0);
3374     break;
3375     case MACHINE_ARC_NEC_R96:
3376     system = arcbios_addchild_manual(cpu, COMPONENT_CLASS_SystemClass, COMPONENT_TYPE_ARC,
3377     0, 1, 2, 0, 0xffffffff, "NEC-R96", 0 /* ROOT */ , NULL, 0);
3378     break;
3379     case MACHINE_ARC_NEC_R98:
3380     system = arcbios_addchild_manual(cpu, COMPONENT_CLASS_SystemClass, COMPONENT_TYPE_ARC,
3381     0, 1, 2, 0, 0xffffffff, "NEC-R98", 0 /* ROOT */ , NULL, 0);
3382     break;
3383     case MACHINE_ARC_JAZZ_PICA:
3384     system = arcbios_addchild_manual(cpu, COMPONENT_CLASS_SystemClass, COMPONENT_TYPE_ARC,
3385     0, 1, 2, 0, 0xffffffff, "PICA-61", 0 /* ROOT */ , NULL, 0);
3386     break;
3387     case MACHINE_ARC_JAZZ_MAGNUM:
3388     system = arcbios_addchild_manual(cpu, COMPONENT_CLASS_SystemClass, COMPONENT_TYPE_ARC,
3389     0, 1, 2, 0, 0xffffffff, "Microsoft-Jazz", 0 /* ROOT */ , NULL, 0);
3390     break;
3391     case MACHINE_ARC_JAZZ_M700:
3392     system = arcbios_addchild_manual(cpu, COMPONENT_CLASS_SystemClass, COMPONENT_TYPE_ARC,
3393     0, 1, 2, 0, 0xffffffff, "Microsoft-Jazz", 0 /* ROOT */ , NULL, 0);
3394     break;
3395     case MACHINE_ARC_DESKTECH_TYNE:
3396     system = arcbios_addchild_manual(cpu, COMPONENT_CLASS_SystemClass, COMPONENT_TYPE_ARC,
3397     0, 1, 2, 0, 0xffffffff, "DESKTECH-TYNE", 0 /* ROOT */ , NULL, 0);
3398     break;
3399     default:
3400     fatal("Unimplemented ARC machine type %i\n",
3401     machine->machine_subtype);
3402     exit(1);
3403     }
3404     }
3405    
3406    
3407     /*
3408     * Common stuff for both SGI and ARC:
3409     */
3410     debug("ARC system @ 0x%llx\n", (long long)system);
3411    
3412     for (i=0; i<machine->ncpus; i++) {
3413     uint64_t cpuaddr, fpu=0, picache, pdcache, sdcache=0;
3414     int cache_size, cache_line_size;
3415     unsigned int jj;
3416     char arc_cpu_name[100];
3417     char arc_fpc_name[105];
3418    
3419     snprintf(arc_cpu_name, sizeof(arc_cpu_name),
3420     "MIPS-%s", machine->cpu_name);
3421    
3422     if (machine->machine_type == MACHINE_ARC &&
3423     machine->machine_subtype == MACHINE_ARC_NEC_R96)
3424     snprintf(arc_cpu_name, sizeof(arc_cpu_name),
3425     "MIPS-%s - Pr 4/5.0, Fp 5/0",
3426     machine->cpu_name);
3427    
3428     arc_cpu_name[sizeof(arc_cpu_name)-1] = 0;
3429     for (jj=0; jj<strlen(arc_cpu_name); jj++)
3430     if (arc_cpu_name[jj] >= 'a' && arc_cpu_name[jj] <= 'z')
3431     arc_cpu_name[jj] += ('A' - 'a');
3432    
3433     strcpy(arc_fpc_name, arc_cpu_name);
3434     strcat(arc_fpc_name, "FPC");
3435    
3436     cpuaddr = arcbios_addchild_manual(cpu, COMPONENT_CLASS_ProcessorClass, COMPONENT_TYPE_CPU,
3437     0, 1, 2, i, 0xffffffff, arc_cpu_name, system, NULL, 0);
3438    
3439     /*
3440     * TODO: This was in the ARC specs, but it isn't
3441     * really used by ARC implementations?
3442     * At least SGI-IP32 uses it.
3443     */
3444     if (machine->machine_type == MACHINE_SGI)
3445     fpu = arcbios_addchild_manual(cpu, COMPONENT_CLASS_ProcessorClass, COMPONENT_TYPE_FPU,
3446     0, 1, 2, 0, 0xffffffff, arc_fpc_name, cpuaddr, NULL, 0);
3447    
3448     cache_size = DEFAULT_PCACHE_SIZE - 12;
3449     if (machine->cache_picache)
3450     cache_size = machine->cache_picache - 12;
3451     if (cache_size < 0)
3452     cache_size = 0;
3453    
3454     cache_line_size = DEFAULT_PCACHE_LINESIZE;
3455     if (machine->cache_picache_linesize)
3456     cache_line_size = machine->cache_picache_linesize;
3457     if (cache_line_size < 0)
3458     cache_line_size = 0;
3459    
3460     picache = arcbios_addchild_manual(cpu, COMPONENT_CLASS_CacheClass,
3461     COMPONENT_TYPE_PrimaryICache, 0, 1, 2,
3462     /*
3463     * Key bits: 0xXXYYZZZZ
3464     * XX is refill-size.
3465     * Cache line size is 1 << YY,
3466     * Cache size is 4KB << ZZZZ.
3467     */
3468     0x01000000 + (cache_line_size << 16) + cache_size,
3469     /* 32 bytes per line, default = 32 KB total */
3470     0xffffffff, NULL, cpuaddr, NULL, 0);
3471    
3472     cache_size = DEFAULT_PCACHE_SIZE - 12;
3473     if (machine->cache_pdcache)
3474     cache_size = machine->cache_pdcache - 12;
3475     if (cache_size < 0)
3476     cache_size = 0;
3477    
3478     cache_line_size = DEFAULT_PCACHE_LINESIZE;
3479     if (machine->cache_pdcache_linesize)
3480     cache_line_size = machine->cache_pdcache_linesize;
3481     if (cache_line_size < 0)
3482     cache_line_size = 0;
3483    
3484     pdcache = arcbios_addchild_manual(cpu, COMPONENT_CLASS_CacheClass,
3485     COMPONENT_TYPE_PrimaryDCache, 0, 1, 2,
3486     /*
3487     * Key bits: 0xYYZZZZ
3488     * Cache line size is 1 << YY,
3489     * Cache size is 4KB << ZZZZ.
3490     */
3491     0x01000000 + (cache_line_size << 16) + cache_size,
3492     /* 32 bytes per line, default = 32 KB total */
3493     0xffffffff, NULL, cpuaddr, NULL, 0);
3494    
3495     if (machine->cache_secondary >= 12) {
3496     cache_size = machine->cache_secondary - 12;
3497    
3498     cache_line_size = 6; /* 64 bytes default */
3499     if (machine->cache_secondary_linesize)
3500     cache_line_size = machine->cache_secondary_linesize;
3501     if (cache_line_size < 0)
3502     cache_line_size = 0;
3503    
3504     sdcache = arcbios_addchild_manual(cpu, COMPONENT_CLASS_CacheClass,
3505     COMPONENT_TYPE_SecondaryDCache, 0, 1, 2,
3506     /*
3507     * Key bits: 0xYYZZZZ
3508     * Cache line size is 1 << YY,
3509     * Cache size is 4KB << ZZZZ.
3510     */
3511     0x01000000 + (cache_line_size << 16) + cache_size,
3512     /* 64 bytes per line, default = 1 MB total */
3513     0xffffffff, NULL, cpuaddr, NULL, 0);
3514     }
3515    
3516     debug("ARC cpu%i @ 0x%llx", i, (long long)cpuaddr);
3517    
3518     if (fpu != 0)
3519     debug(" (fpu @ 0x%llx)\n", (long long)fpu);
3520     else
3521     debug("\n");
3522    
3523     debug(" picache @ 0x%llx, pdcache @ 0x%llx\n",
3524     (long long)picache, (long long)pdcache);
3525    
3526     if (machine->cache_secondary >= 12)
3527     debug(" sdcache @ 0x%llx\n",
3528     (long long)sdcache);
3529    
3530     if (machine->machine_type == MACHINE_SGI) {
3531     /* TODO: Memory amount (and base address?)! */
3532     uint64_t memory = arcbios_addchild_manual(cpu, COMPONENT_CLASS_MemoryClass,
3533     COMPONENT_TYPE_MemoryUnit,
3534     0, 1, 2, 0, 0xffffffff, "memory", cpuaddr, NULL, 0);
3535     debug(" memory @ 0x%llx\n", (long long)memory);
3536     }
3537     }
3538    
3539    
3540     /*
3541     * Other components, and default TLB entries:
3542     *
3543     * TODO: How to build the component tree intermixed with
3544     * the rest of device initialization?
3545     */
3546    
3547     if (machine->machine_type == MACHINE_SGI) {
3548     /* TODO: On which models is this required? */
3549     mips_coproc_tlb_set_entry(cpu, 0, 1048576*16,
3550     0xc000000000000000ULL,
3551     0x0, 1048576*16,
3552     1, 1, 1, 1, 1, 0, 2, 2);
3553     }
3554    
3555     if (machine->machine_type == MACHINE_ARC &&
3556     ( machine->machine_subtype == MACHINE_ARC_NEC_RD94 ||
3557     machine->machine_subtype == MACHINE_ARC_NEC_R94 ||
3558     machine->machine_subtype == MACHINE_ARC_NEC_R96 )) {
3559     uint64_t jazzbus, eisa, other;
3560    
3561     jazzbus = arcbios_addchild_manual(cpu,
3562     COMPONENT_CLASS_AdapterClass,
3563     COMPONENT_TYPE_MultiFunctionAdapter,
3564     0, 1, 2, 0, 0xffffffff, "Jazz-Internal Bus",
3565     system, NULL, 0);
3566    
3567     switch (machine->machine_subtype) {
3568     case MACHINE_ARC_NEC_RD94:
3569     case MACHINE_ARC_NEC_R94:
3570     if (machine->use_x11)
3571     arcbios_addchild_manual(cpu,
3572     COMPONENT_CLASS_ControllerClass,
3573     COMPONENT_TYPE_DisplayController,
3574     0, 1, 2, 0, 0x0, "10110004",
3575     system, NULL, 0);
3576     break;
3577     case MACHINE_ARC_NEC_R96:
3578     if (machine->use_x11) {
3579     uint64_t x;
3580     x = arcbios_addchild_manual(cpu,
3581     COMPONENT_CLASS_ControllerClass,
3582     COMPONENT_TYPE_DisplayController,
3583     COMPONENT_FLAG_ConsoleOut |
3584     COMPONENT_FLAG_Output,
3585     1, 2, 0, 0x0, "necvdfrb",
3586     jazzbus, NULL, 0);
3587     arcbios_addchild_manual(cpu,
3588     COMPONENT_CLASS_PeripheralClass,
3589     COMPONENT_TYPE_MonitorPeripheral,
3590     COMPONENT_FLAG_ConsoleOut |
3591     COMPONENT_FLAG_Output,
3592     1, 2, 0, 0xffffffff, "640x480",
3593     x, NULL, 0);
3594     }
3595    
3596     /* TODO: R[D]94 too? */
3597     eisa = arcbios_addchild_manual(cpu,
3598     COMPONENT_CLASS_AdapterClass,
3599     COMPONENT_TYPE_EISAAdapter,
3600     0, 1, 2, 0, 0xffffffff, "EISA",
3601     system, NULL, 0);
3602    
3603     other = arcbios_addchild_manual(cpu,
3604     COMPONENT_CLASS_ControllerClass,
3605     COMPONENT_TYPE_OtherController,
3606     0, 1, 2, 0, 0xffffffff, "NEC1C01",
3607     eisa, NULL, 0);
3608    
3609     break;
3610     }
3611     }
3612    
3613     if (machine->machine_type == MACHINE_ARC &&
3614     (machine->machine_subtype == MACHINE_ARC_JAZZ_PICA
3615     || machine->machine_subtype == MACHINE_ARC_JAZZ_MAGNUM)) {
3616     uint64_t jazzbus, ali_s3, vxl;
3617     uint64_t diskcontroller, floppy, kbdctl, kbd;
3618     uint64_t ptrctl, ptr, paral, audio;
3619     uint64_t eisa, scsi;
3620     /* uint64_t serial1, serial2; */
3621    
3622     jazzbus = arcbios_addchild_manual(cpu,
3623     COMPONENT_CLASS_AdapterClass,
3624     COMPONENT_TYPE_MultiFunctionAdapter,
3625     0, 1, 2, 0, 0xffffffff, "Jazz-Internal Bus",
3626     system, NULL, 0);
3627    
3628     /*
3629     * DisplayController, needed by NetBSD:
3630     * TODO: NetBSD still doesn't use it :(
3631     */
3632     switch (machine->machine_subtype) {
3633     case MACHINE_ARC_JAZZ_PICA:
3634     /* Default TLB entries on PICA-61: */
3635    
3636     /* 7: 256K, asid: 0x0, v: 0xe1000000,
3637     p0: 0xfff00000(2.VG), p1: 0x0(0..G) */
3638     mips_coproc_tlb_set_entry(cpu, 7, 262144,
3639     0xffffffffe1000000ULL,
3640     0x0fff00000ULL, 0,
3641     1, 0, 0, 0, 1, 0, 2, 0);
3642    
3643     /* 8: 64K, asid: 0x0, v: 0xe0000000,
3644     p0: 0x80000000(2DVG), p1: 0x0(0..G) */
3645     mips_coproc_tlb_set_entry(cpu, 8, 65536,
3646     0xffffffffe0000000ULL,
3647     0x080000000ULL, 0,
3648     1, 0, 1, 0, 1, 0, 2, 0);
3649    
3650     /* 9: 64K, asid: 0x0, v: 0xe00e0000,
3651     p0: 0x800e0000(2DVG), p1: 0x800f0000(2DVG) */
3652     mips_coproc_tlb_set_entry(cpu, 9, 65536,
3653     (uint64_t)0xffffffffe00e0000ULL,
3654     (uint64_t)0x0800e0000ULL,
3655     (uint64_t)0x0800f0000ULL,
3656     1, 1, 1, 1, 1, 0, 2, 2);
3657    
3658     /* 10: 4K, asid: 0x0, v: 0xe0100000,
3659     p0: 0xf0000000(2DVG), p1: 0x0(0..G) */
3660     mips_coproc_tlb_set_entry(cpu, 10, 4096,
3661     (uint64_t)0xffffffffe0100000ULL,
3662     (uint64_t)0x0f0000000ULL, 0,
3663     1, 0, 1, 0, 1, 0, 2, 0);
3664    
3665     /* 11: 1M, asid: 0x0, v: 0xe0200000,
3666     p0: 0x60000000(2DVG), p1: 0x60100000(2DVG) */
3667     mips_coproc_tlb_set_entry(cpu, 11, 1048576,
3668     0xffffffffe0200000ULL,
3669     0x060000000ULL, 0x060100000ULL,
3670     1, 1, 1, 1, 1, 0, 2, 2);
3671    
3672     /* 12: 1M, asid: 0x0, v: 0xe0400000,
3673     p0: 0x60200000(2DVG), p1: 0x60300000(2DVG) */
3674     mips_coproc_tlb_set_entry(cpu, 12, 1048576,
3675     0xffffffffe0400000ULL,
3676     0x060200000ULL, 0x060300000ULL,
3677     1, 1, 1, 1, 1, 0, 2, 2);
3678    
3679     /* 13: 4M, asid: 0x0, v: 0xe0800000,
3680     p0: 0x40000000(2DVG), p1: 0x40400000(2DVG) */
3681     mips_coproc_tlb_set_entry(cpu, 13, 1048576*4,
3682     0xffffffffe0800000ULL,
3683     0x040000000ULL, 0x040400000ULL,
3684     1, 1, 1, 1, 1, 0, 2, 2);
3685    
3686     /* 14: 16M, asid: 0x0, v: 0xe2000000,
3687     p0: 0x90000000(2DVG), p1: 0x91000000(2DVG) */
3688     mips_coproc_tlb_set_entry(cpu, 14, 1048576*16,
3689     0xffffffffe2000000ULL,
3690     0x090000000ULL, 0x091000000ULL,
3691     1, 1, 1, 1, 1, 0, 2, 2);
3692    
3693     if (machine->use_x11) {
3694     ali_s3 = arcbios_addchild_manual(cpu,
3695     COMPONENT_CLASS_ControllerClass,
3696     COMPONENT_TYPE_DisplayController,
3697     COMPONENT_FLAG_ConsoleOut |
3698     COMPONENT_FLAG_Output,
3699     1, 2, 0, 0xffffffff, "ALI_S3",
3700     jazzbus, NULL, 0);
3701    
3702     arcbios_addchild_manual(cpu,
3703     COMPONENT_CLASS_PeripheralClass,
3704     COMPONENT_TYPE_MonitorPeripheral,
3705     COMPONENT_FLAG_ConsoleOut |
3706     COMPONENT_FLAG_Output,
3707     1, 2, 0, 0xffffffff, "1024x768",
3708     ali_s3, NULL, 0);
3709     }
3710     break;
3711     case MACHINE_ARC_JAZZ_MAGNUM:
3712     if (machine->use_x11) {
3713     vxl = arcbios_addchild_manual(cpu,
3714     COMPONENT_CLASS_ControllerClass,
3715     COMPONENT_TYPE_DisplayController,
3716     COMPONENT_FLAG_ConsoleOut |
3717     COMPONENT_FLAG_Output,
3718     1, 2, 0, 0xffffffff, "VXL",
3719     jazzbus, NULL, 0);
3720    
3721     arcbios_addchild_manual(cpu,
3722     COMPONENT_CLASS_PeripheralClass,
3723     COMPONENT_TYPE_MonitorPeripheral,
3724     COMPONENT_FLAG_ConsoleOut |
3725     COMPONENT_FLAG_Output,
3726     1, 2, 0, 0xffffffff, "1024x768",
3727     vxl, NULL, 0);
3728     }
3729     break;
3730     }
3731    
3732     diskcontroller = arcbios_addchild_manual(cpu,
3733     COMPONENT_CLASS_ControllerClass,
3734     COMPONENT_TYPE_DiskController,
3735     COMPONENT_FLAG_Input |
3736     COMPONENT_FLAG_Output,
3737     1, 2, 0, 0xffffffff, "I82077",
3738     jazzbus, NULL, 0);
3739    
3740     floppy = arcbios_addchild_manual(cpu,
3741     COMPONENT_CLASS_PeripheralClass,
3742     COMPONENT_TYPE_FloppyDiskPeripheral,
3743     COMPONENT_FLAG_Removable |
3744     COMPONENT_FLAG_Input |
3745     COMPONENT_FLAG_Output,
3746     1, 2, 0, 0xffffffff, NULL,
3747     diskcontroller, NULL, 0);
3748    
3749     kbdctl = arcbios_addchild_manual(cpu,
3750     COMPONENT_CLASS_ControllerClass,
3751     COMPONENT_TYPE_KeyboardController,
3752     COMPONENT_FLAG_ConsoleIn |
3753     COMPONENT_FLAG_Input,
3754     1, 2, 0, 0xffffffff, "I8742",
3755     jazzbus, NULL, 0);
3756    
3757     kbd = arcbios_addchild_manual(cpu,
3758     COMPONENT_CLASS_PeripheralClass,
3759     COMPONENT_TYPE_KeyboardPeripheral,
3760     COMPONENT_FLAG_ConsoleIn |
3761     COMPONENT_FLAG_Input,
3762     1, 2, 0, 0xffffffff, "PCAT_ENHANCED",
3763     kbdctl, NULL, 0);
3764    
3765     ptrctl = arcbios_addchild_manual(cpu,
3766     COMPONENT_CLASS_ControllerClass,
3767     COMPONENT_TYPE_PointerController,
3768     COMPONENT_FLAG_Input,
3769     1, 2, 0, 0xffffffff, "I8742",
3770     jazzbus, NULL, 0);
3771    
3772     ptr = arcbios_addchild_manual(cpu,
3773     COMPONENT_CLASS_PeripheralClass,
3774     COMPONENT_TYPE_PointerPeripheral,
3775     COMPONENT_FLAG_Input,
3776     1, 2, 0, 0xffffffff, "PS2 MOUSE",
3777     ptrctl, NULL, 0);
3778    
3779     /* These cause Windows NT to bug out. */
3780     #if 0
3781     serial1 = arcbios_addchild_manual(cpu,
3782     COMPONENT_CLASS_ControllerClass,
3783     COMPONENT_TYPE_SerialController,
3784     COMPONENT_FLAG_Input |
3785     COMPONENT_FLAG_Output,
3786     1, 2, 0, 0xffffffff, "COM1",
3787     jazzbus, NULL, 0);
3788    
3789     serial2 = arcbios_addchild_manual(cpu,
3790     COMPONENT_CLASS_ControllerClass,
3791     COMPONENT_TYPE_SerialController,
3792     COMPONENT_FLAG_Input |
3793     COMPONENT_FLAG_Output,
3794     1, 2, 0, 0xffffffff, "COM1",
3795     jazzbus, NULL, 0);
3796     #endif
3797    
3798     paral = arcbios_addchild_manual(cpu,
3799     COMPONENT_CLASS_ControllerClass,
3800     COMPONENT_TYPE_ParallelController,
3801     COMPONENT_FLAG_Input |
3802     COMPONENT_FLAG_Output,
3803     1, 2, 0, 0xffffffff, "LPT1",
3804     jazzbus, NULL, 0);
3805    
3806     audio = arcbios_addchild_manual(cpu,
3807     COMPONENT_CLASS_ControllerClass,
3808     COMPONENT_TYPE_AudioController,
3809     COMPONENT_FLAG_Input |
3810     COMPONENT_FLAG_Output,
3811     1, 2, 0, 0xffffffff, "MAGNUM",
3812     jazzbus, NULL, 0);
3813    
3814     eisa = arcbios_addchild_manual(cpu,
3815     COMPONENT_CLASS_AdapterClass,
3816     COMPONENT_TYPE_EISAAdapter,
3817     0, 1, 2, 0, 0xffffffff, "EISA",
3818     system, NULL, 0);
3819    
3820     {
3821     unsigned char config[78];
3822     memset(config, 0, sizeof(config));
3823    
3824     /* config data version: 1, revision: 2, count: 4 */
3825     config[0] = 0x01; config[1] = 0x00;
3826     config[2] = 0x02; config[3] = 0x00;
3827     config[4] = 0x04; config[5] = 0x00; config[6] = 0x00; config[7] = 0x00;
3828    
3829     /*
3830     type: Interrupt
3831     share_disposition: DeviceExclusive, flags: LevelSensitive
3832     level: 4, vector: 22, reserved1: 0
3833     */
3834     config[8] = arc_CmResourceTypeInterrupt;
3835     config[9] = arc_CmResourceShareDeviceExclusive;
3836     config[10] = arc_CmResourceInterruptLevelSensitive;
3837     config[12] = 4;
3838     config[16] = 22;
3839     config[20] = 0;
3840    
3841     /*
3842     type: Memory
3843     share_disposition: DeviceExclusive, flags: ReadWrite
3844     start: 0x 0 80002000, length: 0x1000
3845     */
3846     config[24] = arc_CmResourceTypeMemory;
3847     config[25] = arc_CmResourceShareDeviceExclusive;
3848     config[26] = arc_CmResourceMemoryReadWrite;
3849     config[28] = 0x00; config[29] = 0x20; config[30] = 0x00; config[31] = 0x80;
3850     config[32] = 0x00; config[33] = 0x00; config[34] = 0x00; config[35] = 0x00;
3851     config[36] = 0x00; config[37] = 0x10; config[38] = 0x00; config[39] = 0x00;
3852    
3853     /*
3854     type: DMA
3855     share_disposition: DeviceExclusive, flags: 0x0
3856     channel: 0, port: 0, reserved1: 0
3857     */
3858     config[40] = arc_CmResourceTypeDMA;
3859     config[41] = arc_CmResourceShareDeviceExclusive;
3860     /* 42..43 = flags, 44,45,46,47 = channel, 48,49,50,51 = port, 52,53,54,55 = reserved */
3861    
3862     /* type: DeviceSpecific
3863     share_disposition: DeviceExclusive, flags: 0x0
3864     datasize: 6, reserved1: 0, reserved2: 0
3865     data: [0x1:0x0:0x2:0x0:0x7:0x30]
3866     */
3867     config[56] = arc_CmResourceTypeDeviceSpecific;
3868     config[57] = arc_CmResourceShareDeviceExclusive;
3869     /* 58,59 = flags 60,61,62,63 = data size, 64..71 = reserved */
3870     config[60] = 6;
3871     /* 72..77 = the data */
3872     config[72] = 0x01;
3873     config[73] = 0x00;
3874     config[74] = 0x02;
3875     config[75] = 0x00;
3876     config[76] = 0x07;
3877     config[77] = 0x30;
3878     scsi = arcbios_addchild_manual(cpu,
3879     COMPONENT_CLASS_AdapterClass,
3880     COMPONENT_TYPE_SCSIAdapter,
3881     0, 1, 2, 0, 0xffffffff, "ESP216",
3882     system, config, sizeof(config));
3883    
3884     arcbios_register_scsicontroller(scsi);
3885     }
3886    
3887     }
3888    
3889    
3890     add_symbol_name(&machine->symbol_context,
3891     ARC_FIRMWARE_ENTRIES, 0x10000, "[ARCBIOS entry]", 0);
3892    
3893     switch (arc_wordlen) {
3894     case sizeof(uint64_t):
3895     for (i=0; i<100; i++)
3896     store_64bit_word(cpu, ARC_FIRMWARE_VECTORS + i*8,
3897     ARC_FIRMWARE_ENTRIES + i*8);
3898     for (i=0; i<100; i++)
3899     store_64bit_word(cpu, ARC_PRIVATE_VECTORS + i*8,
3900     ARC_PRIVATE_ENTRIES + i*8);
3901     break;
3902     default:
3903     for (i=0; i<100; i++)
3904     store_32bit_word(cpu, ARC_FIRMWARE_VECTORS + i*4,
3905     ARC_FIRMWARE_ENTRIES + i*4);
3906     for (i=0; i<100; i++)
3907     store_32bit_word(cpu, ARC_PRIVATE_VECTORS + i*4,
3908     ARC_PRIVATE_ENTRIES + i*4);
3909     }
3910    
3911     switch (arc_wordlen) {
3912     case sizeof(uint64_t):
3913     /*
3914     * ARCS64 SPD (TODO: This is just a guess)
3915     */
3916     memset(&arcbios_spb_64, 0, sizeof(arcbios_spb_64));
3917     store_64bit_word_in_host(cpu, (unsigned char *)&arcbios_spb_64.SPBSignature, ARCBIOS_SPB_SIGNATURE);
3918     store_16bit_word_in_host(cpu, (unsigned char *)&arcbios_spb_64.Version, 64);
3919     store_16bit_word_in_host(cpu, (unsigned char *)&arcbios_spb_64.Revision, 0);
3920     store_64bit_word_in_host(cpu, (unsigned char *)&arcbios_spb_64.FirmwareVector, ARC_FIRMWARE_VECTORS);
3921     store_buf(cpu, SGI_SPB_ADDR, (char *)&arcbios_spb_64, sizeof(arcbios_spb_64));
3922     break;
3923     default: /* 32-bit */
3924     /*
3925     * ARCBIOS SPB: (For ARC and 32-bit SGI modes)
3926     */
3927     memset(&arcbios_spb, 0, sizeof(arcbios_spb));
3928     store_32bit_word_in_host(cpu, (unsigned char *)&arcbios_spb.SPBSignature, ARCBIOS_SPB_SIGNATURE);
3929     store_32bit_word_in_host(cpu, (unsigned char *)&arcbios_spb.SPBLength, sizeof(arcbios_spb));
3930     store_16bit_word_in_host(cpu, (unsigned char *)&arcbios_spb.Version, 1);
3931     store_16bit_word_in_host(cpu, (unsigned char *)&arcbios_spb.Revision, machine->machine_type == MACHINE_SGI? 10 : 2);
3932     store_32bit_word_in_host(cpu, (unsigned char *)&arcbios_spb.FirmwareVector, ARC_FIRMWARE_VECTORS);
3933     store_32bit_word_in_host(cpu, (unsigned char *)&arcbios_spb.FirmwareVectorLength, 100 * 4); /* ? */
3934     store_32bit_word_in_host(cpu, (unsigned char *)&arcbios_spb.PrivateVector, ARC_PRIVATE_VECTORS);
3935     store_32bit_word_in_host(cpu, (unsigned char *)&arcbios_spb.PrivateVectorLength, 100 * 4); /* ? */
3936     store_buf(cpu, SGI_SPB_ADDR, (char *)&arcbios_spb, sizeof(arcbios_spb));
3937     }
3938    
3939     /*
3940     * Boot string in ARC format:
3941     *
3942     * TODO: How about floppies? multi()disk()fdisk()
3943     * Is tftp() good for netbooting?
3944     */
3945     init_bootpath = malloc(500);
3946     if (init_bootpath == NULL) {
3947     fprintf(stderr, "out of mem, bootpath\n");
3948     exit(1);
3949     }
3950     init_bootpath[0] = '\0';
3951    
3952     if (bootdev_id < 0 || machine->force_netboot) {
3953     snprintf(init_bootpath, 400, "tftp()");
3954     } else {
3955     /* TODO: Make this nicer. */
3956     if (machine->machine_type == MACHINE_SGI) {
3957     if (machine->machine_subtype == 30)
3958     strcat(init_bootpath, "xio(0)pci(15)");
3959     if (machine->machine_subtype == 32)
3960     strcat(init_bootpath, "pci(0)");
3961     }
3962    
3963     if (diskimage_is_a_cdrom(machine, bootdev_id))
3964     snprintf(init_bootpath + strlen(init_bootpath), 400,
3965     "scsi(0)cdrom(%i)fdisk(0)", bootdev_id);
3966     else
3967     snprintf(init_bootpath + strlen(init_bootpath), 400,
3968     "scsi(0)disk(%i)rdisk(0)partition(1)", bootdev_id);
3969     }
3970    
3971     if (machine->machine_type == MACHINE_ARC)
3972     strcat(init_bootpath, "\\");
3973    
3974     bootstr = malloc(strlen(init_bootpath) +
3975     strlen(machine->boot_kernel_filename) + 1);
3976     strcpy(bootstr, init_bootpath);
3977     strcat(bootstr, machine->boot_kernel_filename);
3978    
3979     /* Boot args., eg "-a" */
3980     bootarg = machine->boot_string_argument;
3981    
3982     /* argc, argv, envp in a0, a1, a2: */
3983     cpu->cd.mips.gpr[MIPS_GPR_A0] = 0; /* note: argc is increased later */
3984    
3985     /* TODO: not needed? */
3986     cpu->cd.mips.gpr[MIPS_GPR_SP] = machine->physical_ram_in_mb * 1048576 + 0x80000000 - 0x2080;
3987    
3988     /* Set up argc/argv: */
3989     addr = ARC_ENV_STRINGS;
3990     addr2 = ARC_ARGV_START;
3991     cpu->cd.mips.gpr[MIPS_GPR_A1] = addr2;
3992    
3993     /* bootstr: */
3994     store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3995     add_environment_string(cpu, bootstr, &addr);
3996     cpu->cd.mips.gpr[MIPS_GPR_A0] ++;
3997    
3998     /* bootarg: */
3999     if (bootarg[0] != '\0') {
4000     store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
4001     add_environment_string(cpu, bootarg, &addr);
4002     cpu->cd.mips.gpr[MIPS_GPR_A0] ++;
4003     }
4004    
4005     cpu->cd.mips.gpr[MIPS_GPR_A2] = addr2;
4006    
4007     /*
4008     * Add environment variables. For each variable, add it
4009     * as a string using add_environment_string(), and add a
4010     * pointer to it to the ARC_ENV_POINTERS array.
4011     */
4012     if (machine->use_x11) {
4013     if (machine->machine_type == MACHINE_ARC) {
4014     store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
4015     add_environment_string(cpu, "CONSOLEIN=multi()key()keyboard()console()", &addr);
4016     store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
4017     add_environment_string(cpu, "CONSOLEOUT=multi()video()monitor()console()", &addr);
4018     } else {
4019     store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
4020     add_environment_string(cpu, "ConsoleIn=keyboard()", &addr);
4021     store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
4022     add_environment_string(cpu, "ConsoleOut=video()", &addr);
4023    
4024     /* g for graphical mode. G for graphical mode
4025     with SGI logo visible on Irix? */
4026     store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
4027     add_environment_string(cpu, "console=g", &addr);
4028     }
4029     } else {
4030     if (machine->machine_type == MACHINE_ARC) {
4031     /* TODO: serial console for ARC? */
4032     store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
4033     add_environment_string(cpu, "CONSOLEIN=multi()serial(0)", &addr);
4034     store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
4035     add_environment_string(cpu, "CONSOLEOUT=multi()serial(0)", &addr);
4036     } else {
4037     store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
4038     add_environment_string(cpu, "ConsoleIn=serial(0)", &addr);
4039     store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
4040     add_environment_string(cpu, "ConsoleOut=serial(0)", &addr);
4041    
4042     /* 'd' or 'd2' in Irix, 'ttyS0' in Linux? */
4043     store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
4044     add_environment_string(cpu, "console=d", &addr); /* d2 = serial? */
4045     }
4046     }
4047    
4048     if (machine->machine_type == MACHINE_SGI) {
4049     store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
4050     add_environment_string(cpu, "AutoLoad=No", &addr);
4051     store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
4052     add_environment_string(cpu, "diskless=0", &addr);
4053     store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
4054     add_environment_string(cpu, "volume=80", &addr);
4055     store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
4056     add_environment_string(cpu, "sgilogo=y", &addr);
4057    
4058     store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
4059     add_environment_string(cpu, "monitor=h", &addr);
4060     store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
4061     add_environment_string(cpu, "TimeZone=GMT", &addr);
4062     store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
4063     add_environment_string(cpu, "nogfxkbd=1", &addr);
4064    
4065     /* TODO: 'xio(0)pci(15)scsi(0)disk(1)rdisk(0)partition(0)' on IP30 at least */
4066    
4067     store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
4068     add_environment_string(cpu, "SystemPartition=pci(0)scsi(0)disk(2)rdisk(0)partition(8)", &addr);
4069     store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
4070     add_environment_string(cpu, "OSLoadPartition=pci(0)scsi(0)disk(2)rdisk(0)partition(0)", &addr);
4071     store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
4072     add_environment_string(cpu, "OSLoadFilename=/unix", &addr);
4073     store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
4074     add_environment_string(cpu, "OSLoader=sash", &addr);
4075    
4076     store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
4077     add_environment_string(cpu, "rbaud=9600", &addr);
4078     store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
4079     add_environment_string(cpu, "rebound=y", &addr);
4080     store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
4081     add_environment_string(cpu, "crt_option=1", &addr);
4082     store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
4083     add_environment_string(cpu, "netaddr=10.0.0.1", &addr);
4084    
4085     store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
4086     add_environment_string(cpu, "keybd=US", &addr);
4087    
4088     store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
4089     add_environment_string(cpu, "cpufreq=3", &addr);
4090     store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
4091     add_environment_string(cpu, "dbaud=9600", &addr);
4092     store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
4093     add_environment_string(cpu, eaddr_string, &addr);
4094     store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
4095     add_environment_string(cpu, "verbose=istrue", &addr);
4096     store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
4097     add_environment_string(cpu, "showconfig=istrue", &addr);
4098     store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
4099     add_environment_string(cpu, "diagmode=v", &addr);
4100     store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
4101     add_environment_string(cpu, "kernname=unix", &addr);
4102     } else {
4103     char *tmp;
4104     tmp = malloc(strlen(bootarg) + strlen("OSLOADOPTIONS=") + 2);
4105     sprintf(tmp, "OSLOADOPTIONS=%s", bootarg);
4106     store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
4107     add_environment_string(cpu, tmp, &addr);
4108    
4109     store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
4110     add_environment_string(cpu, "OSLOADPARTITION=scsi(0)cdrom(6)fdisk(0);scsi(0)disk(0)rdisk(0)partition(1)", &addr);
4111    
4112     store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
4113     add_environment_string(cpu, "SYSTEMPARTITION=scsi(0)cdrom(6)fdisk(0);scsi(0)disk(0)rdisk(0)partition(1)", &addr);
4114     }
4115    
4116     /* End the environment strings with an empty zero-terminated
4117     string, and the envp array with a NULL pointer. */
4118     add_environment_string(cpu, "", &addr); /* the end */
4119     store_pointer_and_advance(cpu, &addr2,
4120     0, arc_wordlen==sizeof(uint64_t));
4121    
4122     no_arc_prom_emulation: /* TODO: ugly, get rid of the goto */
4123    
4124     /* Return address: (0x20 = ReturnFromMain()) */
4125     cpu->cd.mips.gpr[MIPS_GPR_RA] = ARC_FIRMWARE_ENTRIES + 0x20;
4126    
4127     break;
4128    
4129     case MACHINE_MESHCUBE:
4130     machine->machine_name = "MeshCube";
4131    
4132     if (machine->physical_ram_in_mb != 64)
4133     fprintf(stderr, "WARNING! MeshCubes are supposed to have exactly 64 MB RAM. Continuing anyway.\n");
4134     if (machine->use_x11)
4135     fprintf(stderr, "WARNING! MeshCube with -X is meaningless. Continuing anyway.\n");
4136    
4137     /* First of all, the MeshCube has an Au1500 in it: */
4138     machine->md_interrupt = au1x00_interrupt;
4139     machine->au1x00_ic_data = dev_au1x00_init(machine, mem);
4140    
4141     /*
4142     * TODO: Which non-Au1500 devices, and at what addresses?
4143     *
4144     * "4G Systems MTX-1 Board" at ?
4145     * 1017fffc, 14005004, 11700000, 11700008, 11900014,
4146     * 1190002c, 11900100, 11900108, 1190010c,
4147     * 10400040 - 10400074,
4148     * 14001000 (possibly LCD?)
4149     * 11100028 (possibly ttySx?)
4150     *
4151     * "usb_ohci=base:0x10100000,len:0x100000,irq:26"
4152     */
4153    
4154     device_add(machine, "random addr=0x1017fffc len=4");
4155    
4156     /*
4157     * TODO: A Linux kernel wants "memsize" from somewhere... I
4158     * haven't found any docs on how it is used though.
4159     */
4160    
4161     cpu->cd.mips.gpr[MIPS_GPR_A0] = 1;
4162     cpu->cd.mips.gpr[MIPS_GPR_A1] = 0xa0001000ULL;
4163     store_32bit_word(cpu, cpu->cd.mips.gpr[MIPS_GPR_A1],
4164     0xa0002000ULL);
4165     store_string(cpu, 0xa0002000ULL, "something=somethingelse");
4166    
4167     cpu->cd.mips.gpr[MIPS_GPR_A2] = 0xa0003000ULL;
4168     store_string(cpu, 0xa0002000ULL, "hello=world\n");
4169    
4170     break;
4171    
4172     case MACHINE_NETGEAR:
4173     machine->machine_name = "NetGear WG602";
4174    
4175     if (machine->use_x11)
4176     fprintf(stderr, "WARNING! NetGear with -X is meaningless. Continuing anyway.\n");
4177     if (machine->physical_ram_in_mb != 16)
4178     fprintf(stderr, "WARNING! Real NetGear WG602 boxes have exactly 16 MB RAM. Continuing anyway.\n");
4179    
4180     /*
4181     * Lots of info about the IDT 79RC 32334
4182     * http://www.idt.com/products/pages/Integrated_Processors-79RC32334.html
4183     */
4184     device_add(machine, "8250 addr=0x18000800 addr_mult=4 irq=0");
4185     break;
4186    
4187     case MACHINE_WRT54G:
4188     machine->machine_name = "Linksys WRT54G";
4189    
4190     if (machine->use_x11)
4191     fprintf(stderr, "WARNING! Linksys WRT54G with -X is meaningless. Continuing anyway.\n");
4192    
4193     /* 200 MHz default */
4194     if (machine->emulated_hz == 0)
4195     machine->emulated_hz = 200000000;
4196    
4197     /*
4198     * Linux should be loaded at 0x80001000.
4199     * RAM: 16 or 32 MB, Flash RAM: 4 or 8 MB.
4200     * http://www.bumpclub.ee/~jaanus/wrt54g/vana/minicom.cap:
4201     *
4202     * Starting program at 0x80001000
4203     * CPU revision is: 00029007
4204     * Primary instruction cache 8kb, linesize 16 bytes (2 ways)
4205     * Primary data cache 4kb, linesize 16 bytes (2 ways)
4206     * memory: 01000000 @ 00000000 (usable)
4207     * Kernel command line: root=/dev/mtdblock2 rootfstype=squashfs init=/etc/preinit noinitrd console=ttyS0,115200
4208     * CPU: BCM4712 rev 1 at 200 MHz
4209     * Calibrating delay loop... 199.47 BogoMIPS
4210     * ttyS00 at 0xb8000300 (irq = 3) is a 16550A
4211     * ttyS01 at 0xb8000400 (irq = 0) is a 16550A
4212     * Flash device: 0x400000 at 0x1c000000
4213     * ..
4214     */
4215    
4216     /* TODO: What should the initial register contents be? */
4217     #if 1
4218     {
4219     int i;
4220     for (i=0; i<32; i++)
4221     cpu->cd.mips.gpr[i] = 0x01230000 + (i << 8) + 0x55;
4222     }
4223     #endif
4224    
4225     break;
4226    
4227     case MACHINE_SONYNEWS:
4228     /*
4229     * There are several models, according to
4230     * http://www.netbsd.org/Ports/newsmips/:
4231     *
4232     * "R3000 and hyper-bus based models"
4233     * NWS-3470D, -3410, -3460, -3710, -3720
4234     *
4235     * "R4000/4400 and apbus based models"
4236     * NWS-5000
4237     *
4238     * For example: (found using google)
4239     *
4240     * cpu_model = news3700
4241     * SONY NET WORK STATION, Model NWS-3710, Machine ID #30145
4242     * cpu0: MIPS R3000 (0x220) Rev. 2.0 with MIPS R3010 Rev.2.0
4243     * 64KB/4B direct-mapped I, 64KB/4B direct-mapped w-thr. D
4244     *
4245     * See http://katsu.watanabe.name/doc/sonynews/model.html
4246     * for more details.
4247     */
4248     cpu->byte_order = EMUL_BIG_ENDIAN;
4249     machine->machine_name = "Sony NeWS (NET WORK STATION)";
4250    
4251     /* This is just a test. TODO */
4252     {
4253     int i;
4254     for (i=0; i<32; i++)
4255     cpu->cd.mips.gpr[i] =
4256     0x01230000 + (i << 8) + 0x55;
4257     }
4258    
4259     machine->main_console_handle =
4260     dev_zs_init(machine, mem, 0x1e950000, 0, 1, "zs console");
4261    
4262     break;
4263    
4264     case MACHINE_BAREPPC:
4265     /*
4266     * A "bare" PPC machine.
4267     *
4268     * NOTE: NO devices at all.
4269     */
4270     machine->machine_name = "\"Bare\" PPC machine";
4271     break;
4272    
4273     case MACHINE_TESTPPC:
4274     /*
4275     * A PPC test machine, similar to the test machine for MIPS.
4276     */
4277     machine->machine_name = "PPC test machine";
4278    
4279     /* TODO: interrupt for PPC? */
4280     machine->main_console_handle = dev_cons_init(
4281     machine, mem, DEV_CONS_ADDRESS, "console", 0);
4282    
4283     snprintf(tmpstr, sizeof(tmpstr) - 1, "mp addr=0x%llx",
4284     (long long)DEV_MP_ADDRESS);
4285     device_add(machine, tmpstr);
4286    
4287     fb = dev_fb_init(machine, mem, 0x12000000, VFB_GENERIC,
4288     640,480, 640,480, 24, "generic", 1);
4289     break;
4290    
4291     case MACHINE_WALNUT:
4292     /*
4293     * NetBSD/evbppc (http://www.netbsd.org/Ports/evbppc/)
4294     */
4295     machine->machine_name = "Walnut evaluation board";
4296    
4297     break;
4298    
4299     case MACHINE_PMPPC:
4300     /*
4301     * NetBSD/pmppc (http://www.netbsd.org/Ports/pmppc/)
4302     */
4303     machine->machine_name = "Artesyn's PM/PPC board";
4304    
4305     dev_pmppc_init(mem);
4306    
4307     /* com0 = 0xff600300, com1 = 0xff600400 */
4308     machine->main_console_handle = dev_ns16550_init(machine, mem,
4309     0xff600300, 0, 1, 1, "serial 0");
4310     dev_ns16550_init(machine, mem,
4311     0xff600400, 0, 1, 0, "serial 1");
4312    
4313     break;
4314    
4315     case MACHINE_SANDPOINT:
4316     /*
4317     * NetBSD/sandpoint (http://www.netbsd.org/Ports/sandpoint/)
4318     */
4319     machine->machine_name = "Motorola Sandpoint";
4320    
4321     {
4322     int i;
4323     for (i=0; i<32; i++)
4324     cpu->cd.ppc.gpr[i] =
4325     0x12340000 + (i << 8) + 0x55;
4326     }
4327    
4328     break;
4329    
4330     case MACHINE_BEBOX:
4331     /*
4332     * NetBSD/bebox (http://www.netbsd.org/Ports/bebox/)
4333     */
4334     machine->machine_name = "BeBox";
4335    
4336     device_add(machine, "bebox");
4337    
4338     /* Serial, used by NetBSD: */
4339     machine->main_console_handle = dev_ns16550_init(machine, mem,
4340     0x800003f8, 0, 1, 1, "serial 0");
4341    
4342     /* Serial, used by Linux: */
4343     dev_ns16550_init(machine, mem, 0x800002f8, 0, 1, 0, "serial 1");
4344    
4345     /* This is used by Linux too: */
4346     dev_vga_init(machine, mem, 0xc00b8000ULL, 0x800003c0ULL, 80, 25,
4347     machine->machine_name);
4348    
4349     store_32bit_word(cpu, 0x3010,
4350     machine->physical_ram_in_mb * 1048576);
4351    
4352     /* TODO: List of stuff, see http://www.beatjapan.org/
4353     mirror/www.be.com/aboutbe/benewsletter/
4354     Issue27.html#Cookbook for the details. */
4355     store_32bit_word(cpu, 0x301c, 0);
4356    
4357     /* NetBSD/bebox: r3 = startkernel, r4 = endkernel,
4358     r5 = args, r6 = ptr to bootinfo? */
4359     cpu->cd.ppc.gpr[3] = 0x3100;
4360     cpu->cd.ppc.gpr[4] = 0x200000;
4361     cpu->cd.ppc.gpr[5] = 0x2000;
4362     store_string(cpu, cpu->cd.ppc.gpr[5], "-a");
4363     cpu->cd.ppc.gpr[6] = machine->physical_ram_in_mb * 1048576
4364     - 0x100;
4365    
4366     /* See NetBSD's bebox/include/bootinfo.h for details */
4367     store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 0, 12); /* next */
4368     store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 4, 0); /* mem */
4369     store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 8,
4370     machine->physical_ram_in_mb * 1048576);
4371    
4372     store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 12, 20); /* next */
4373     store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 16, 1); /* console */
4374     store_buf(cpu, cpu->cd.ppc.gpr[6] + 20, "com", 4);
4375     store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 24, 0x3f8);/* addr */
4376     store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 28, 9600);/* speed */
4377    
4378     store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 32, 0); /* next */
4379     store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 36, 2); /* clock */
4380     store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 40, 100);
4381    
4382     break;
4383    
4384     case MACHINE_PREP:
4385     /*
4386     * NetBSD/prep (http://www.netbsd.org/Ports/prep/)
4387     */
4388     machine->machine_name = "PowerPC Reference Platform";
4389    
4390     {
4391     int i;
4392     for (i=0; i<32; i++)
4393     cpu->cd.ppc.gpr[i] =
4394     0x12340000 + (i << 8) + 0x55;
4395     }
4396    
4397     /* Linux on PReP has 0xdeadc0de at address 0? (See
4398     http://joshua.raleigh.nc.us/docs/linux-2.4.10_html/113568.html) */
4399     store_32bit_word(cpu, 0, 0xdeadc0de);
4400    
4401     /* r6 should point to "residual data"? */
4402     cpu->cd.ppc.gpr[6] = machine->physical_ram_in_mb * 1048576
4403     - 0x1000;
4404    
4405     break;
4406    
4407     case MACHINE_MACPPC:
4408     /*
4409     * NetBSD/macppc (http://www.netbsd.org/Ports/macppc/)
4410     * OpenBSD/macppc (http://www.openbsd.org/macppc.html)
4411     */
4412     machine->machine_name = "Macintosh (PPC)";
4413    
4414     /* r5 = OpenFirmware entry point */
4415     cpu->cd.ppc.gpr[5] = cpu->cd.ppc.of_emul_addr;
4416    
4417     break;
4418    
4419     case MACHINE_DB64360:
4420     /* For playing with PMON2000 for PPC: */
4421     machine->machine_name = "DB64360";
4422    
4423     machine->main_console_handle = dev_ns16550_init(machine, mem,
4424     0x1d000020, 0, 4, 1, "serial console");
4425    
4426     {
4427     int i;
4428     for (i=0; i<32; i++)
4429     cpu->cd.ppc.gpr[i] =
4430     0x12340000 + (i << 8) + 0x55;
4431     }
4432    
4433     break;
4434    
4435     case MACHINE_BARESPARC:
4436     /* A bare SPARC machine, with no devices. */
4437     machine->machine_name = "\"Bare\" SPARC machine";
4438     break;
4439    
4440     case MACHINE_ULTRA1:
4441     /*
4442     * NetBSD/sparc64 (http://www.netbsd.org/Ports/sparc64/)
4443     * OpenBSD/sparc64 (http://www.openbsd.org/sparc64.html)
4444     */
4445     machine->machine_name = "Sun Ultra1";
4446     break;
4447    
4448     case MACHINE_BAREURISC:
4449     machine->machine_name = "\"Bare\" URISC machine";
4450     break;
4451    
4452     case MACHINE_TESTURISC:
4453     machine->machine_name = "URISC test machine";
4454    
4455     /* TODO */
4456     /* A special "device" for accessing normal devices
4457     using urisc accesses? */
4458    
4459     device_add(machine, "urisc addr=0x12341234");
4460    
4461     break;
4462    
4463     case MACHINE_BAREHPPA:
4464     machine->machine_name = "\"Bare\" HPPA machine";
4465     break;
4466    
4467     case MACHINE_TESTHPPA:
4468     machine->machine_name = "HPPA test machine";
4469    
4470     /* TODO */
4471     break;
4472    
4473     case MACHINE_BAREALPHA:
4474     machine->machine_name = "\"Bare\" Alpha machine";
4475     break;
4476    
4477     case MACHINE_TESTALPHA:
4478     machine->machine_name = "Alpha test machine";
4479    
4480     /* TODO */
4481     break;
4482    
4483 dpavlin 4 case MACHINE_BAREX86:
4484     machine->machine_name = "\"Bare\" x86 machine";
4485     break;
4486    
4487     case MACHINE_X86:
4488     machine->machine_name = "Generic x86 PC";
4489    
4490     if (!machine->use_x11)
4491     fprintf(stderr, "WARNING! You are emulating a PC "
4492     "without -X. You will miss any output going\n"
4493     "to the screen!\n\n");
4494    
4495     /*
4496     * Initialize all 16-bit interrupt vectors to point to
4497     * somewhere within the PC BIOS area (0xf000:0x8yyy):
4498     */
4499     for (i=0; i<256; i++) {
4500     store_16bit_word(cpu, i*4, 0x8000 + i);
4501     store_16bit_word(cpu, i*4 + 2, 0xf000);
4502     }
4503    
4504     dev_vga_init(machine, mem, 0xb8000ULL, 0x1000003c0ULL, 80, 25,
4505     "Generic x86 PC");
4506    
4507     dev_wdc_init(machine, mem, 0x1000001f0ULL, 14, 0);
4508    
4509     /* TODO: disable the "enable" flag when a keyboard has
4510     been added: */
4511     machine->main_console_handle = dev_ns16550_init(machine, mem,
4512     0x1000003f8ULL, 4, 1, 1, "com1");
4513     dev_ns16550_init(machine, mem, 0x100000378ULL, 3, 1, 0, "com2");
4514    
4515     break;
4516    
4517 dpavlin 2 default:
4518     fatal("Unknown emulation type %i\n", machine->machine_type);
4519     exit(1);
4520     }
4521    
4522     if (machine->machine_name != NULL)
4523     debug("machine: %s", machine->machine_name);
4524    
4525     if (machine->emulated_hz > 0)
4526     debug(" (%.2f MHz)", (float)machine->emulated_hz / 1000000);
4527     debug("\n");
4528    
4529     if (machine->emulated_hz < 1)
4530     machine->emulated_hz = 1000000;
4531    
4532     if (bootstr != NULL) {
4533     debug("bootstring%s: %s", (bootarg!=NULL &&
4534     strlen(bootarg) >= 1)? "(+bootarg)" : "", bootstr);
4535     if (bootarg != NULL && strlen(bootarg) >= 1)
4536     debug(" %s", bootarg);
4537     debug("\n");
4538     }
4539     }
4540    
4541    
4542     /*
4543     * machine_memsize_fix():
4544     *
4545     * Sets physical_ram_in_mb (if not already set), and memory_offset_in_mb,
4546     * depending on machine type.
4547     */
4548     void machine_memsize_fix(struct machine *m)
4549     {
4550     if (m == NULL) {
4551     fatal("machine_defaultmemsize(): m == NULL?\n");
4552     exit(1);
4553     }
4554    
4555     if (m->physical_ram_in_mb == 0) {
4556     switch (m->machine_type) {
4557     case MACHINE_PS2:
4558     m->physical_ram_in_mb = 32;
4559     break;
4560     case MACHINE_SGI:
4561     m->physical_ram_in_mb = 64;
4562     break;
4563     case MACHINE_HPCMIPS:
4564     /* Most have 32 MB by default. */
4565     m->physical_ram_in_mb = 32;
4566     switch (m->machine_subtype) {
4567     case MACHINE_HPCMIPS_CASIO_BE300:
4568     m->physical_ram_in_mb = 16;
4569     break;
4570     case MACHINE_HPCMIPS_CASIO_E105:
4571     m->physical_ram_in_mb = 32;
4572     break;
4573     case MACHINE_HPCMIPS_AGENDA_VR3:
4574     m->physical_ram_in_mb = 16;
4575     break;
4576     }
4577     break;
4578     case MACHINE_MESHCUBE:
4579     m->physical_ram_in_mb = 64;
4580     break;
4581     case MACHINE_NETGEAR:
4582     m->physical_ram_in_mb = 16;
4583     break;
4584     case MACHINE_WRT54G:
4585     m->physical_ram_in_mb = 32;
4586     break;
4587     case MACHINE_ARC:
4588     switch (m->machine_subtype) {
4589     case MACHINE_ARC_JAZZ_PICA:
4590     m->physical_ram_in_mb = 64;
4591     break;
4592     case MACHINE_ARC_JAZZ_M700:
4593     m->physical_ram_in_mb = 64;
4594     break;
4595     default:
4596     m->physical_ram_in_mb = 32;
4597     }
4598     break;
4599     case MACHINE_DEC:
4600     switch (m->machine_subtype) {
4601     case MACHINE_DEC_PMAX_3100:
4602     m->physical_ram_in_mb = 24;
4603     break;
4604     default:
4605     m->physical_ram_in_mb = 32;
4606     }
4607     break;
4608     case MACHINE_BEBOX:
4609     m->physical_ram_in_mb = 64;
4610     break;
4611     case MACHINE_BAREURISC:
4612     case MACHINE_TESTURISC:
4613     m->physical_ram_in_mb = 2;
4614     break;
4615     }
4616     }
4617    
4618     /* Special hack for WRT54G and hpcmips machines: */
4619     if (m->machine_type == MACHINE_WRT54G ||
4620     m->machine_type == MACHINE_HPCMIPS) {
4621     m->dbe_on_nonexistant_memaccess = 0;
4622     }
4623    
4624     /* Special SGI memory offsets: */
4625     if (m->machine_type == MACHINE_SGI) {
4626     switch (m->machine_subtype) {
4627     case 20:
4628     case 22:
4629     case 24:
4630     case 26:
4631     m->memory_offset_in_mb = 128;
4632     break;
4633     case 28:
4634     case 30:
4635     m->memory_offset_in_mb = 512;
4636     break;
4637     }
4638     }
4639    
4640     if (m->physical_ram_in_mb == 0)
4641     m->physical_ram_in_mb = DEFAULT_RAM_IN_MB;
4642     }
4643    
4644    
4645     /*
4646     * machine_default_cputype():
4647     *
4648     * Sets m->cpu_name, if it isn't already set, depending on the machine
4649     * type.
4650     */
4651     void machine_default_cputype(struct machine *m)
4652     {
4653     if (m == NULL) {
4654     fatal("machine_default_cputype(): m == NULL?\n");
4655     exit(1);
4656     }
4657    
4658     if (m->cpu_name != NULL)
4659     return;
4660    
4661     switch (m->machine_type) {
4662     case MACHINE_BAREMIPS:
4663     case MACHINE_TESTMIPS:
4664     m->cpu_name = strdup("R4000");
4665     break;
4666     case MACHINE_PS2:
4667     m->cpu_name = strdup("R5900");
4668     break;
4669     case MACHINE_DEC:
4670     if (m->machine_subtype > 2)
4671     m->cpu_name = strdup("R3000A");
4672     if (m->machine_subtype > 1 && m->cpu_name == NULL)
4673     m->cpu_name = strdup("R3000");
4674     if (m->cpu_name == NULL)
4675     m->cpu_name = strdup("R2000");
4676     break;
4677     case MACHINE_SONYNEWS:
4678     m->cpu_name = strdup("R3000");
4679     break;
4680     case MACHINE_HPCMIPS:
4681     switch (m->machine_subtype) {
4682     case MACHINE_HPCMIPS_CASIO_BE300:
4683     m->cpu_name = strdup("VR4131");
4684     break;
4685     case MACHINE_HPCMIPS_CASIO_E105:
4686     m->cpu_name = strdup("VR4121");
4687     break;
4688     case MACHINE_HPCMIPS_NEC_MOBILEPRO_770:
4689     case MACHINE_HPCMIPS_NEC_MOBILEPRO_780:
4690     case MACHINE_HPCMIPS_NEC_MOBILEPRO_800:
4691     case MACHINE_HPCMIPS_NEC_MOBILEPRO_880:
4692     m->cpu_name = strdup("VR4121");
4693     break;
4694     case MACHINE_HPCMIPS_AGENDA_VR3:
4695     m->cpu_name = strdup("VR4181");
4696     break;
4697     case MACHINE_HPCMIPS_IBM_WORKPAD_Z50:
4698     m->cpu_name = strdup("VR4121");
4699     break;
4700     default:
4701     printf("Unimplemented HPCMIPS model?\n");
4702     exit(1);
4703     }
4704     break;
4705     case MACHINE_COBALT:
4706     m->cpu_name = strdup("RM5200");
4707     break;
4708     case MACHINE_MESHCUBE:
4709     m->cpu_name = strdup("R4400");
4710     /* TODO: Should be AU1500, but Linux doesn't like
4711     the absence of caches in the emulator */
4712     break;
4713     case MACHINE_NETGEAR:
4714     m->cpu_name = strdup("RC32334");
4715     break;
4716     case MACHINE_WRT54G:
4717     m->cpu_name = strdup("BCM4712");
4718     break;
4719     case MACHINE_ARC:
4720     switch (m->machine_subtype) {
4721     case MACHINE_ARC_JAZZ_PICA:
4722     m->cpu_name = strdup("R4000");
4723     break;
4724     default:
4725     m->cpu_name = strdup("R4400");
4726     }
4727     break;
4728     case MACHINE_SGI:
4729     if (m->machine_subtype <= 12)
4730     m->cpu_name = strdup("R3000");
4731     if (m->cpu_name == NULL && m->machine_subtype == 35)
4732     m->cpu_name = strdup("R12000");
4733     if (m->cpu_name == NULL && (m->machine_subtype == 25 ||
4734     m->machine_subtype == 27 ||
4735     m->machine_subtype == 28 ||
4736     m->machine_subtype == 30 ||
4737     m->machine_subtype == 32))
4738     m->cpu_name = strdup("R10000");
4739     if (m->cpu_name == NULL && (m->machine_subtype == 21 ||
4740     m->machine_subtype == 26))
4741     m->cpu_name = strdup("R8000");
4742     if (m->cpu_name == NULL && m->machine_subtype == 24)
4743     m->cpu_name = strdup("R5000");
4744    
4745     /* Other SGIs should probably work with
4746     R4000, R4400 or R5000 or similar: */
4747     if (m->cpu_name == NULL)
4748     m->cpu_name = strdup("R4400");
4749     break;
4750    
4751     /* PowerPC: */
4752     case MACHINE_BAREPPC:
4753     case MACHINE_TESTPPC:
4754     m->cpu_name = strdup("PPC970");
4755     break;
4756     case MACHINE_WALNUT:
4757     /* For NetBSD/evbppc. */
4758     m->cpu_name = strdup("PPC405GP");
4759     break;
4760     case MACHINE_PMPPC:
4761     /* For NetBSD/pmppc. */
4762     m->cpu_name = strdup("PPC750");
4763     break;
4764     case MACHINE_SANDPOINT:
4765     /*
4766     * For NetBSD/sandpoint. According to NetBSD's page:
4767     *
4768     * "Unity" module has an MPC8240.
4769     * "Altimus" module has an MPC7400 (G4) or an MPC107.
4770     */
4771     m->cpu_name = strdup("MPC7400");
4772     break;
4773     case MACHINE_BEBOX:
4774     /* For NetBSD/bebox. Dual 133 MHz 603e CPUs, for example. */
4775     m->cpu_name = strdup("PPC603e");
4776     break;
4777     case MACHINE_PREP:
4778     /* For NetBSD/prep. TODO */
4779     m->cpu_name = strdup("PPC603e");
4780     break;
4781     case MACHINE_MACPPC:
4782     switch (m->machine_subtype) {
4783     case MACHINE_MACPPC_G4:
4784     m->cpu_name = strdup("G4e");
4785     break;
4786     case MACHINE_MACPPC_G5:
4787     m->cpu_name = strdup("PPC970");
4788     break;
4789     }
4790     break;
4791     case MACHINE_DB64360:
4792     m->cpu_name = strdup("PPC750");
4793     break;
4794    
4795     /* SPARC: */
4796     case MACHINE_BARESPARC:
4797     m->cpu_name = strdup("SPARCV9");
4798     break;
4799     case MACHINE_ULTRA1:
4800     m->cpu_name = strdup("SPARCV9");
4801     break;
4802    
4803     /* URISC: */
4804     case MACHINE_BAREURISC:
4805     case MACHINE_TESTURISC:
4806     m->cpu_name = strdup("URISC");
4807     break;
4808    
4809     /* HPPA: */
4810     case MACHINE_BAREHPPA:
4811     case MACHINE_TESTHPPA:
4812     m->cpu_name = strdup("HPPA2.0");
4813     break;
4814    
4815     /* Alpha: */
4816     case MACHINE_BAREALPHA:
4817     case MACHINE_TESTALPHA:
4818     m->cpu_name = strdup("EV4");
4819     break;
4820 dpavlin 4
4821     /* x86: */
4822     case MACHINE_BAREX86:
4823     case MACHINE_X86:
4824     m->cpu_name = strdup("PENTIUM");
4825     break;
4826 dpavlin 2 }
4827    
4828     if (m->cpu_name == NULL) {
4829     fprintf(stderr, "machine_default_cputype(): no default"
4830     " cpu for machine type %i subtype %i\n",
4831     m->machine_type, m->machine_subtype);
4832     exit(1);
4833     }
4834     }
4835    
4836    
4837     /*
4838     * machine_dumpinfo():
4839     *
4840     * Dumps info about a machine in some kind of readable format. (Used by
4841     * the 'machine' debugger command.)
4842     */
4843     void machine_dumpinfo(struct machine *m)
4844     {
4845     int i;
4846    
4847     debug("serial nr: %i", m->serial_nr);
4848     if (m->nr_of_nics > 0)
4849     debug(" (nr of nics: %i)", m->nr_of_nics);
4850     debug("\n");
4851    
4852     debug("memory: %i MB", m->physical_ram_in_mb);
4853     if (m->memory_offset_in_mb != 0)
4854     debug(" (offset by %i MB)", m->memory_offset_in_mb);
4855     if (m->random_mem_contents)
4856     debug(", randomized contents");
4857     if (m->dbe_on_nonexistant_memaccess)
4858     debug(", dbe_on_nonexistant_memaccess");
4859     debug("\n");
4860    
4861     if (m->single_step_on_bad_addr)
4862     debug("single-step on bad addresses\n");
4863    
4864     if (m->bintrans_enable)
4865     debug("bintrans enabled (%i MB cache)\n",
4866     (int) (m->bintrans_size / 1048576));
4867     else
4868     debug("bintrans disabled, other speedtricks %s\n",
4869     m->speed_tricks? "enabled" : "disabled");
4870    
4871     debug("clock: ");
4872     if (m->automatic_clock_adjustment)
4873     debug("adjusted automatically");
4874     else
4875     debug("fixed at %i Hz", m->emulated_hz);
4876     debug("\n");
4877    
4878     if (!m->prom_emulation)
4879     debug("PROM emulation disabled\n");
4880    
4881     for (i=0; i<m->ncpus; i++)
4882     cpu_dumpinfo(m, m->cpus[i]);
4883    
4884     if (m->ncpus > 1)
4885     debug("Bootstrap cpu is nr %i\n", m->bootstrap_cpu);
4886    
4887     if (m->slow_serial_interrupts_hack_for_linux)
4888     debug("Using slow_serial_interrupts_hack_for_linux\n");
4889    
4890     if (m->use_x11) {
4891     debug("Using X11");
4892     if (m->x11_scaledown > 1)
4893     debug(", scaledown %i", m->x11_scaledown);
4894     if (m->x11_n_display_names > 0) {
4895     for (i=0; i<m->x11_n_display_names; i++) {
4896     debug(i? ", " : " (");
4897     debug("\"%s\"", m->x11_display_names[i]);
4898     }
4899     debug(")");
4900     }
4901     debug("\n");
4902     }
4903    
4904     diskimage_dump_info(m);
4905    
4906     if (m->force_netboot)
4907     debug("Forced netboot\n");
4908     }
4909    
4910    
4911     /*
4912     * machine_entry_new():
4913     *
4914     * This function creates a new machine_entry struct, and fills it with some
4915     * valid data; it is up to the caller to add additional data that weren't
4916     * passed as arguments to this function.
4917     *
4918     * For internal use.
4919     */
4920     static struct machine_entry *machine_entry_new(const char *name,
4921     int arch, int oldstyle_type, int n_aliases, int n_subtypes)
4922     {
4923     struct machine_entry *me;
4924    
4925     me = malloc(sizeof(struct machine_entry));
4926     if (me == NULL) {
4927     fprintf(stderr, "machine_entry_new(): out of memory (1)\n");
4928     exit(1);
4929     }
4930    
4931     memset(me, 0, sizeof(struct machine_entry));
4932    
4933     me->name = name;
4934     me->arch = arch;
4935     me->machine_type = oldstyle_type;
4936     me->n_aliases = n_aliases;
4937     me->aliases = malloc(sizeof(char *) * n_aliases);
4938     if (me->aliases == NULL) {
4939     fprintf(stderr, "machine_entry_new(): out of memory (2)\n");
4940     exit(1);
4941     }
4942     me->n_subtypes = n_subtypes;
4943    
4944     if (n_subtypes > 0) {
4945     me->subtype = malloc(sizeof(struct machine_entry_subtype *) *
4946     n_subtypes);
4947     if (me->subtype == NULL) {
4948     fprintf(stderr, "machine_entry_new(): out of "
4949     "memory (3)\n");
4950     exit(1);
4951     }
4952     }
4953    
4954     return me;
4955     }
4956    
4957    
4958     /*
4959     * machine_entry_subtype_new():
4960     *
4961     * This function creates a new machine_entry_subtype struct, and fills it with
4962     * some valid data; it is up to the caller to add additional data that weren't
4963     * passed as arguments to this function.
4964     *
4965     * For internal use.
4966     */
4967     static struct machine_entry_subtype *machine_entry_subtype_new(
4968     const char *name, int oldstyle_type, int n_aliases)
4969     {
4970     struct machine_entry_subtype *mes;
4971    
4972     mes = malloc(sizeof(struct machine_entry_subtype));
4973     if (mes == NULL) {
4974     fprintf(stderr, "machine_entry_subtype_new(): out "
4975     "of memory (1)\n");
4976     exit(1);
4977     }
4978    
4979     memset(mes, 0, sizeof(struct machine_entry_subtype));
4980     mes->name = name;
4981     mes->machine_subtype = oldstyle_type;
4982     mes->n_aliases = n_aliases;
4983     mes->aliases = malloc(sizeof(char *) * n_aliases);
4984     if (mes->aliases == NULL) {
4985     fprintf(stderr, "machine_entry_subtype_new(): "
4986     "out of memory (2)\n");
4987     exit(1);
4988     }
4989    
4990     return mes;
4991     }
4992    
4993    
4994     /*
4995     * machine_list_available_types_and_cpus():
4996     *
4997     * List all available machine types (for example when running the emulator
4998     * with just -H as command line argument).
4999     */
5000     void machine_list_available_types_and_cpus(void)
5001     {
5002     struct machine_entry *me;
5003     int iadd = 8;
5004    
5005     debug("Available CPU types:\n\n");
5006    
5007     debug_indentation(iadd);
5008     cpu_list_available_types();
5009     debug_indentation(-iadd);
5010    
5011     debug("\nMost of the CPU types are bogus, and not really implemented."
5012     " The main effect of\nselecting a specific CPU type is to choose "
5013     "what kind of 'id' it will have.\n\nAvailable machine types (with "
5014     "aliases) and their subtypes:\n\n");
5015    
5016     debug_indentation(iadd);
5017     me = first_machine_entry;
5018    
5019     if (me == NULL)
5020     fatal("No machines defined!\n");
5021    
5022     while (me != NULL) {
5023     int i, j, iadd = 4;
5024    
5025     debug("%s", me->name);
5026     debug(" (");
5027     for (i=0; i<me->n_aliases; i++)
5028     debug("%s\"%s\"", i? ", " : "", me->aliases[i]);
5029     debug(")\n");
5030    
5031     debug_indentation(iadd);
5032     for (i=0; i<me->n_subtypes; i++) {
5033     struct machine_entry_subtype *mes;
5034     mes = me->subtype[i];
5035     debug("- %s", mes->name);
5036     debug(" (");
5037     for (j=0; j<mes->n_aliases; j++)
5038     debug("%s\"%s\"", j? ", " : "",
5039     mes->aliases[j]);
5040     debug(")\n");
5041     }
5042     debug_indentation(-iadd);
5043    
5044     me = me->next;
5045     }
5046     debug_indentation(-iadd);
5047    
5048     debug("\nMost of the machine types are bogus too. Please read the "
5049     "GXemul\ndocumentation for information about which machine"
5050     " types that actually\nwork. Use the alias when selecting a "
5051     "machine type or subtype, not the\nreal name.\n");
5052    
5053     debug("\n");
5054    
5055     useremul_list_emuls();
5056     }
5057    
5058    
5059     /*
5060     * machine_init():
5061     *
5062     * This function should be called before any other machine_*() function
5063     * is used.
5064     */
5065     void machine_init(void)
5066     {
5067     struct machine_entry *me;
5068    
5069     /*
5070     * NOTE: This list is in reverse order, so that the
5071     * entries will appear in normal order when listed. :-)
5072     */
5073    
5074 dpavlin 4 /* X86 machine: */
5075     me = machine_entry_new("x86 (generic PC-style machine)", ARCH_X86,
5076     MACHINE_X86, 2, 0);
5077     me->aliases[0] = "pc";
5078     me->aliases[1] = "x86";
5079     if (cpu_family_ptr_by_number(ARCH_X86) != NULL) {
5080     me->next = first_machine_entry; first_machine_entry = me;
5081     }
5082    
5083 dpavlin 2 /* Walnut: (NetBSD/evbppc) */
5084     me = machine_entry_new("Walnut evaluation board", ARCH_PPC,
5085     MACHINE_WALNUT, 2, 0);
5086     me->aliases[0] = "walnut";
5087     me->aliases[1] = "evbppc";
5088     if (cpu_family_ptr_by_number(ARCH_PPC) != NULL) {
5089     me->next = first_machine_entry; first_machine_entry = me;
5090     }
5091    
5092     /* Test-machine for URISC: */
5093     me = machine_entry_new("Test-machine for URISC", ARCH_URISC,
5094     MACHINE_TESTURISC, 1, 0);
5095     me->aliases[0] = "testurisc";
5096     if (cpu_family_ptr_by_number(ARCH_URISC) != NULL) {
5097     me->next = first_machine_entry; first_machine_entry = me;
5098     }
5099    
5100     /* Test-machine for PPC: */
5101     me = machine_entry_new("Test-machine for PPC", ARCH_PPC,
5102     MACHINE_TESTPPC, 1, 0);
5103     me->aliases[0] = "testppc";
5104     if (cpu_family_ptr_by_number(ARCH_PPC) != NULL) {
5105     me->next = first_machine_entry; first_machine_entry = me;
5106     }
5107    
5108     /* Test-machine for MIPS: */
5109     me = machine_entry_new("Test-machine for MIPS", ARCH_MIPS,
5110     MACHINE_TESTMIPS, 1, 0);
5111     me->aliases[0] = "testmips";
5112     if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {
5113     me->next = first_machine_entry; first_machine_entry = me;
5114     }
5115    
5116     /* Test-machine for HPPA: */
5117     me = machine_entry_new("Test-machine for HPPA", ARCH_HPPA,
5118     MACHINE_TESTHPPA, 1, 0);
5119     me->aliases[0] = "testhppa";
5120     if (cpu_family_ptr_by_number(ARCH_HPPA) != NULL) {
5121     me->next = first_machine_entry; first_machine_entry = me;
5122     }
5123    
5124     /* Test-machine for Alpha: */
5125     me = machine_entry_new("Test-machine for Alpha", ARCH_ALPHA,
5126     MACHINE_TESTALPHA, 1, 0);
5127     me->aliases[0] = "testalpha";
5128     if (cpu_family_ptr_by_number(ARCH_ALPHA) != NULL) {
5129     me->next = first_machine_entry; first_machine_entry = me;
5130     }
5131    
5132     /* Sun Ultra1: */
5133     me = machine_entry_new("Sun Ultra1", ARCH_SPARC, MACHINE_ULTRA1, 1, 0);
5134     me->aliases[0] = "ultra1";
5135     if (cpu_family_ptr_by_number(ARCH_SPARC) != NULL) {
5136     me->next = first_machine_entry; first_machine_entry = me;
5137     }
5138    
5139     /* Sony Playstation 2: */
5140     me = machine_entry_new("Sony Playstation 2", ARCH_MIPS,
5141     MACHINE_PS2, 2, 0);
5142     me->aliases[0] = "playstation2";
5143     me->aliases[1] = "ps2";
5144     if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {
5145     me->next = first_machine_entry; first_machine_entry = me;
5146     }
5147    
5148     /* Sony NeWS: */
5149     me = machine_entry_new("Sony NeWS", ARCH_MIPS,
5150     MACHINE_SONYNEWS, 2, 0);
5151     me->aliases[0] = "sonynews";
5152     me->aliases[1] = "news";
5153     if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {
5154     me->next = first_machine_entry; first_machine_entry = me;
5155     }
5156    
5157     /* SGI: */
5158     me = machine_entry_new("SGI", ARCH_MIPS, MACHINE_SGI, 2, 9);
5159     me->aliases[0] = "silicon graphics";
5160     me->aliases[1] = "sgi";
5161     me->subtype[0] = machine_entry_subtype_new("IP19", 19, 1);
5162     me->subtype[0]->aliases[0] = "ip19";
5163     me->subtype[1] = machine_entry_subtype_new("IP20", 20, 1);
5164     me->subtype[1]->aliases[0] = "ip20";
5165     me->subtype[2] = machine_entry_subtype_new("IP22", 22, 2);
5166     me->subtype[2]->aliases[0] = "ip22";
5167     me->subtype[2]->aliases[1] = "indy";
5168     me->subtype[3] = machine_entry_subtype_new("IP24", 24, 1);
5169     me->subtype[3]->aliases[0] = "ip24";
5170     me->subtype[4] = machine_entry_subtype_new("IP27", 27, 3);
5171     me->subtype[4]->aliases[0] = "ip27";
5172     me->subtype[4]->aliases[1] = "origin 200";
5173     me->subtype[4]->aliases[2] = "origin 2000";
5174     me->subtype[5] = machine_entry_subtype_new("IP28", 28, 1);
5175     me->subtype[5]->aliases[0] = "ip28";
5176     me->subtype[6] = machine_entry_subtype_new("IP30", 30, 2);
5177     me->subtype[6]->aliases[0] = "ip30";
5178     me->subtype[6]->aliases[1] = "octane";
5179     me->subtype[7] = machine_entry_subtype_new("IP32", 32, 2);
5180     me->subtype[7]->aliases[0] = "ip32";
5181     me->subtype[7]->aliases[1] = "o2";
5182     me->subtype[8] = machine_entry_subtype_new("IP35", 35, 1);
5183     me->subtype[8]->aliases[0] = "ip35";
5184     if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {
5185     me->next = first_machine_entry; first_machine_entry = me;
5186     }
5187    
5188     /* PReP: (NetBSD/prep etc.) */
5189     me = machine_entry_new("PowerPC Reference Platform", ARCH_PPC,
5190     MACHINE_PREP, 1, 0);
5191     me->aliases[0] = "prep";
5192     if (cpu_family_ptr_by_number(ARCH_PPC) != NULL) {
5193     me->next = first_machine_entry; first_machine_entry = me;
5194     }
5195    
5196     /* NetGear: */
5197     me = machine_entry_new("NetGear WG602", ARCH_MIPS,
5198     MACHINE_NETGEAR, 2, 0);
5199     me->aliases[0] = "netgear";
5200     me->aliases[1] = "wg602";
5201     if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {
5202     me->next = first_machine_entry; first_machine_entry = me;
5203     }
5204    
5205     /* Motorola Sandpoint: (NetBSD/sandpoint) */
5206     me = machine_entry_new("Motorola Sandpoint",
5207     ARCH_PPC, MACHINE_SANDPOINT, 1, 0);
5208     me->aliases[0] = "sandpoint";
5209     if (cpu_family_ptr_by_number(ARCH_PPC) != NULL) {
5210     me->next = first_machine_entry; first_machine_entry = me;
5211     }
5212    
5213     /* Meshcube: */
5214     me = machine_entry_new("Meshcube", ARCH_MIPS, MACHINE_MESHCUBE, 1, 0);
5215     me->aliases[0] = "meshcube";
5216     if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {
5217     me->next = first_machine_entry; first_machine_entry = me;
5218     }
5219    
5220     /* Macintosh (PPC): */
5221     me = machine_entry_new("Macintosh (PPC)", ARCH_PPC,
5222     MACHINE_MACPPC, 1, 2);
5223     me->aliases[0] = "macppc";
5224     me->subtype[0] = machine_entry_subtype_new("MacPPC G4",
5225     MACHINE_MACPPC_G4, 1);
5226     me->subtype[0]->aliases[0] = "g4";
5227     me->subtype[1] = machine_entry_subtype_new("MacPPC G5",
5228     MACHINE_MACPPC_G5, 1);
5229     me->subtype[1]->aliases[0] = "g5";
5230     if (cpu_family_ptr_by_number(ARCH_PPC) != NULL) {
5231     me->next = first_machine_entry; first_machine_entry = me;
5232     }
5233    
5234     /* Linksys: */
5235     me = machine_entry_new("Linksys WRT54G", ARCH_MIPS,
5236     MACHINE_WRT54G, 2, 0);
5237     me->aliases[0] = "linksys";
5238     me->aliases[1] = "wrt54g";
5239     if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {
5240     me->next = first_machine_entry; first_machine_entry = me;
5241     }
5242    
5243     /* HPCmips: */
5244     me = machine_entry_new("Handheld MIPS (HPC)",
5245     ARCH_MIPS, MACHINE_HPCMIPS, 2, 8);
5246     me->aliases[0] = "hpcmips";
5247     me->aliases[1] = "hpc";
5248     me->subtype[0] = machine_entry_subtype_new(
5249     "Casio Cassiopeia BE-300", MACHINE_HPCMIPS_CASIO_BE300, 2);
5250     me->subtype[0]->aliases[0] = "be-300";
5251     me->subtype[0]->aliases[1] = "be300";
5252     me->subtype[1] = machine_entry_subtype_new(
5253     "Casio Cassiopeia E-105", MACHINE_HPCMIPS_CASIO_E105, 2);
5254     me->subtype[1]->aliases[0] = "e-105";
5255     me->subtype[1]->aliases[1] = "e105";
5256     me->subtype[2] = machine_entry_subtype_new(
5257     "Agenda VR3", MACHINE_HPCMIPS_AGENDA_VR3, 2);
5258     me->subtype[2]->aliases[0] = "agenda";
5259     me->subtype[2]->aliases[1] = "vr3";
5260     me->subtype[3] = machine_entry_subtype_new(
5261     "IBM WorkPad Z50", MACHINE_HPCMIPS_IBM_WORKPAD_Z50, 2);
5262     me->subtype[3]->aliases[0] = "workpad";
5263     me->subtype[3]->aliases[1] = "z50";
5264     me->subtype[4] = machine_entry_subtype_new(
5265     "NEC MobilePro 770", MACHINE_HPCMIPS_NEC_MOBILEPRO_770, 1);
5266     me->subtype[4]->aliases[0] = "mobilepro770";
5267     me->subtype[5] = machine_entry_subtype_new(
5268     "NEC MobilePro 780", MACHINE_HPCMIPS_NEC_MOBILEPRO_780, 1);
5269     me->subtype[5]->aliases[0] = "mobilepro780";
5270     me->subtype[6] = machine_entry_subtype_new(
5271     "NEC MobilePro 800", MACHINE_HPCMIPS_NEC_MOBILEPRO_800, 1);
5272     me->subtype[6]->aliases[0] = "mobilepro800";
5273     me->subtype[7] = machine_entry_subtype_new(
5274     "NEC MobilePro 880", MACHINE_HPCMIPS_NEC_MOBILEPRO_880, 1);
5275     me->subtype[7]->aliases[0] = "mobilepro880";
5276     if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {
5277     me->next = first_machine_entry; first_machine_entry = me;
5278     }
5279    
5280 dpavlin 4 /* Generic "bare" X86 machine: */
5281     me = machine_entry_new("Generic \"bare\" X86 machine", ARCH_X86,
5282     MACHINE_BAREX86, 1, 0);
5283     me->aliases[0] = "barex86";
5284     if (cpu_family_ptr_by_number(ARCH_X86) != NULL) {
5285     me->next = first_machine_entry; first_machine_entry = me;
5286     }
5287    
5288 dpavlin 2 /* Generic "bare" URISC machine: */
5289     me = machine_entry_new("Generic \"bare\" URISC machine", ARCH_URISC,
5290     MACHINE_BAREURISC, 1, 0);
5291     me->aliases[0] = "bareurisc";
5292     if (cpu_family_ptr_by_number(ARCH_URISC) != NULL) {
5293     me->next = first_machine_entry; first_machine_entry = me;
5294     }
5295    
5296     /* Generic "bare" SPARC machine: */
5297     me = machine_entry_new("Generic \"bare\" SPARC machine", ARCH_SPARC,
5298     MACHINE_BARESPARC, 1, 0);
5299     me->aliases[0] = "baresparc";
5300     if (cpu_family_ptr_by_number(ARCH_SPARC) != NULL) {
5301     me->next = first_machine_entry; first_machine_entry = me;
5302     }
5303    
5304     /* Generic "bare" PPC machine: */
5305     me = machine_entry_new("Generic \"bare\" PPC machine", ARCH_PPC,
5306     MACHINE_BAREPPC, 1, 0);
5307     me->aliases[0] = "bareppc";
5308     if (cpu_family_ptr_by_number(ARCH_PPC) != NULL) {
5309     me->next = first_machine_entry; first_machine_entry = me;
5310     }
5311    
5312     /* Generic "bare" MIPS machine: */
5313     me = machine_entry_new("Generic \"bare\" MIPS machine", ARCH_MIPS,
5314     MACHINE_BAREMIPS, 1, 0);
5315     me->aliases[0] = "baremips";
5316     if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {
5317     me->next = first_machine_entry; first_machine_entry = me;
5318     }
5319    
5320     /* Generic "bare" HPPA machine: */
5321     me = machine_entry_new("Generic \"bare\" HPPA machine", ARCH_HPPA,
5322     MACHINE_BAREHPPA, 1, 0);
5323     me->aliases[0] = "barehppa";
5324     if (cpu_family_ptr_by_number(ARCH_HPPA) != NULL) {
5325     me->next = first_machine_entry; first_machine_entry = me;
5326     }
5327    
5328     /* Generic "bare" Alpha machine: */
5329     me = machine_entry_new("Generic \"bare\" Alpha machine", ARCH_ALPHA,
5330     MACHINE_BAREALPHA, 1, 0);
5331     me->aliases[0] = "barealpha";
5332     if (cpu_family_ptr_by_number(ARCH_ALPHA) != NULL) {
5333     me->next = first_machine_entry; first_machine_entry = me;
5334     }
5335    
5336     /* DECstation: */
5337     me = machine_entry_new("DECstation/DECsystem",
5338     ARCH_MIPS, MACHINE_DEC, 3, 9);
5339     me->aliases[0] = "decstation";
5340     me->aliases[1] = "decsystem";
5341     me->aliases[2] = "dec";
5342     me->subtype[0] = machine_entry_subtype_new(
5343     "DECstation 3100 (PMAX)", MACHINE_DEC_PMAX_3100, 3);
5344     me->subtype[0]->aliases[0] = "pmax";
5345     me->subtype[0]->aliases[1] = "3100";
5346     me->subtype[0]->aliases[2] = "2100";
5347    
5348     me->subtype[1] = machine_entry_subtype_new(
5349     "DECstation 5000/200 (3MAX)", MACHINE_DEC_3MAX_5000, 2);
5350     me->subtype[1]->aliases[0] = "3max";
5351     me->subtype[1]->aliases[1] = "5000/200";
5352    
5353     me->subtype[2] = machine_entry_subtype_new(
5354     "DECstation 5000/1xx (3MIN)", MACHINE_DEC_3MIN_5000, 2);
5355     me->subtype[2]->aliases[0] = "3min";
5356     me->subtype[2]->aliases[1] = "5000/1xx";
5357    
5358     me->subtype[3] = machine_entry_subtype_new(
5359     "DECstation 5000 (3MAXPLUS)", MACHINE_DEC_3MAXPLUS_5000, 2);
5360     me->subtype[3]->aliases[0] = "3maxplus";
5361     me->subtype[3]->aliases[1] = "3max+";
5362    
5363     me->subtype[4] = machine_entry_subtype_new(
5364     "DECsystem 58x0", MACHINE_DEC_5800, 2);
5365     me->subtype[4]->aliases[0] = "5800";
5366     me->subtype[4]->aliases[1] = "58x0";
5367    
5368     me->subtype[5] = machine_entry_subtype_new(
5369     "DECsystem 5400", MACHINE_DEC_5400, 1);
5370     me->subtype[5]->aliases[0] = "5400";
5371    
5372     me->subtype[6] = machine_entry_subtype_new(
5373     "DECstation Maxine (5000)", MACHINE_DEC_MAXINE_5000, 1);
5374     me->subtype[6]->aliases[0] = "maxine";
5375    
5376     me->subtype[7] = machine_entry_subtype_new(
5377     "DECsystem 5500", MACHINE_DEC_5500, 1);
5378     me->subtype[7]->aliases[0] = "5500";
5379    
5380     me->subtype[8] = machine_entry_subtype_new(
5381     "DECstation MipsMate (5100)", MACHINE_DEC_MIPSMATE_5100, 2);
5382     me->subtype[8]->aliases[0] = "5100";
5383     me->subtype[8]->aliases[1] = "mipsmate";
5384    
5385     if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {
5386     me->next = first_machine_entry; first_machine_entry = me;
5387     }
5388    
5389     /* DB64360: (for playing with PMON for PPC) */
5390     me = machine_entry_new("DB64360", ARCH_PPC, MACHINE_DB64360, 1, 0);
5391     me->aliases[0] = "db64360";
5392     if (cpu_family_ptr_by_number(ARCH_PPC) != NULL) {
5393     me->next = first_machine_entry; first_machine_entry = me;
5394     }
5395    
5396     /* Cobalt: */
5397     me = machine_entry_new("Cobalt", ARCH_MIPS, MACHINE_COBALT, 1, 0);
5398     me->aliases[0] = "cobalt";
5399     if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {
5400     me->next = first_machine_entry; first_machine_entry = me;
5401     }
5402    
5403     /* BeBox: (NetBSD/bebox) */
5404     me = machine_entry_new("BeBox", ARCH_PPC, MACHINE_BEBOX, 1, 0);
5405     me->aliases[0] = "bebox";
5406     if (cpu_family_ptr_by_number(ARCH_PPC) != NULL) {
5407     me->next = first_machine_entry; first_machine_entry = me;
5408     }
5409    
5410     /* Artesyn's PM/PPC board: (NetBSD/pmppc) */
5411     me = machine_entry_new("Artesyn's PM/PPC board", ARCH_PPC,
5412     MACHINE_PMPPC, 1, 0);
5413     me->aliases[0] = "pmppc";
5414     if (cpu_family_ptr_by_number(ARCH_PPC) != NULL) {
5415     me->next = first_machine_entry; first_machine_entry = me;
5416     }
5417    
5418     /* ARC: */
5419     me = machine_entry_new("ARC", ARCH_MIPS, MACHINE_ARC, 1, 8);
5420     me->aliases[0] = "arc";
5421    
5422     me->subtype[0] = machine_entry_subtype_new(
5423     "Acer PICA-61", MACHINE_ARC_JAZZ_PICA, 3);
5424     me->subtype[0]->aliases[0] = "pica-61";
5425     me->subtype[0]->aliases[1] = "acer pica";
5426     me->subtype[0]->aliases[2] = "pica";
5427    
5428     me->subtype[1] = machine_entry_subtype_new(
5429     "Deskstation Tyne", MACHINE_ARC_DESKTECH_TYNE, 3);
5430     me->subtype[1]->aliases[0] = "deskstation tyne";
5431     me->subtype[1]->aliases[1] = "desktech";
5432     me->subtype[1]->aliases[2] = "tyne";
5433    
5434     me->subtype[2] = machine_entry_subtype_new(
5435     "Jazz Magnum", MACHINE_ARC_JAZZ_MAGNUM, 2);
5436     me->subtype[2]->aliases[0] = "magnum";
5437     me->subtype[2]->aliases[1] = "jazz magnum";
5438    
5439     me->subtype[3] = machine_entry_subtype_new(
5440     "NEC-R94", MACHINE_ARC_NEC_R94, 2);
5441     me->subtype[3]->aliases[0] = "nec-r94";
5442     me->subtype[3]->aliases[1] = "r94";
5443    
5444     me->subtype[4] = machine_entry_subtype_new(
5445     "NEC-RD94", MACHINE_ARC_NEC_RD94, 2);
5446     me->subtype[4]->aliases[0] = "nec-rd94";
5447     me->subtype[4]->aliases[1] = "rd94";
5448    
5449     me->subtype[5] = machine_entry_subtype_new(
5450     "NEC-R96", MACHINE_ARC_NEC_R96, 2);
5451     me->subtype[5]->aliases[0] = "nec-r96";
5452     me->subtype[5]->aliases[1] = "r96";
5453    
5454     me->subtype[6] = machine_entry_subtype_new(
5455     "NEC-R98", MACHINE_ARC_NEC_R98, 2);
5456     me->subtype[6]->aliases[0] = "nec-r98";
5457     me->subtype[6]->aliases[1] = "r98";
5458    
5459     me->subtype[7] = machine_entry_subtype_new(
5460     "Olivetti M700", MACHINE_ARC_JAZZ_M700, 2);
5461     me->subtype[7]->aliases[0] = "olivetti";
5462     me->subtype[7]->aliases[1] = "m700";
5463    
5464     if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {
5465     me->next = first_machine_entry; first_machine_entry = me;
5466     }
5467     }
5468    

  ViewVC Help
Powered by ViewVC 1.1.26