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

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.26