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

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.26