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

Contents of /trunk/src/machine.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 16 - (show annotations)
Mon Oct 8 16:19:01 2007 UTC (16 years, 6 months ago) by dpavlin
File MIME type: text/plain
File size: 194127 byte(s)
++ trunk/HISTORY	(local)
$Id: HISTORY,v 1.988 2005/10/11 03:53:57 debug Exp $

==============  RELEASE 0.3.6  ==============

20051008	The bug was not because of faulty ARM documentation after all,
		but it was related to those parts of the code.
		Fixing the RTC (dev_mc146818) to work with CATS.
20051009	Rewriting the R() function; now there are 8192 automatically
		generated smaller functions doing the same thing, but hopefully
		faster. This also fixes some bugs which were triggered when
		trying to compile GXemul inside itself. :-)
		Adding a dummy dev_lpt.
20051010	Small hack to not update virtual translation tables if memory
		accesses are done with the NO_EXCEPTION flag; a time reduction
		of almost a factor 2 for a full NetBSD/cats install. :-)
20051011	Passing -A as the default boot arg for CATS (works fine with
		OpenBSD/cats).

==============  RELEASE 0.3.6.1  ==============


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

  ViewVC Help
Powered by ViewVC 1.1.26