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

Contents of /trunk/src/machine.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 18 - (show annotations)
Mon Oct 8 16:19:11 2007 UTC (16 years, 6 months ago) by dpavlin
File MIME type: text/plain
File size: 198455 byte(s)
++ trunk/HISTORY	(local)
$Id: HISTORY,v 1.1004 2005/10/27 14:01:10 debug Exp $
20051011        Passing -A as the default boot arg for CATS (works fine with
                OpenBSD/cats).
20051012	Fixing the VGA cursor offset bug, and speeding up framebuffer
		redraws if character cells contain the same thing as during
		the last redraw.
20051013	Adding a slow strd ARM instruction hack.
20051017	Minor updates: Adding a dummy i80321 Verde controller (for
		XScale emulation), fixing the disassembly of the ARM "ldrd"
		instruction, adding "support" for less-than-4KB pages for ARM
		(by not adding them to translation tables).
20051020	Continuing on some HPCarm stuff. A NetBSD/hpcarm kernel prints
		some boot messages on an emulated Jornada 720.
		Making dev_ram work better with dyntrans (speeds up some things
		quite a bit).
20051021	Automatically generating some of the most common ARM load/store
		multiple instructions.
20051022	Better statistics gathering for the ARM load/store multiple.
		Various other dyntrans and device updates.
20051023	Various minor updates.
20051024	Continuing; minor device and dyntrans fine-tuning. Adding the
		first "reasonable" instruction combination hacks for ARM (the
		cores of NetBSD/cats' memset and memcpy).
20051025	Fixing a dyntrans-related bug in dev_vga. Also changing the
		dyntrans low/high access notification to only be updated on
		writes, not reads. Hopefully it will be enough. (dev_vga in
		charcell mode now seems to work correctly with both reads and
		writes.)
		Experimenting with gathering dyntrans statistics (which parts
		of emulated RAM that are actually executed), and adding
		instruction combination hacks for cache cleaning and a part of
		NetBSD's scanc() function.
20051026	Adding a bitmap for ARM emulation which indicates if a page is
		(specifically) user accessible; loads and stores with the t-
		flag set can now use the translation arrays, which results in
		a measurable speedup.
20051027	Dyntrans updates; adding an extra bitmap array for 32-bit
		emulation modes, speeding up the check whether a physical page
		has any code translations or not (O(n) -> O(1)). Doing a
		similar reduction of O(n) to O(1) by avoiding the scan through
		the translation entries on a translation update (32-bit mode
		only).
		Various other minor hacks.
20051029	Quick release, without any testing at all.

==============  RELEASE 0.3.6.2  ==============


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

  ViewVC Help
Powered by ViewVC 1.1.26