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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 42 - (show annotations)
Mon Oct 8 16:22:32 2007 UTC (16 years, 6 months ago) by dpavlin
File MIME type: text/plain
File size: 21483 byte(s)
++ trunk/HISTORY	(local)
$Id: HISTORY,v 1.1613 2007/06/15 20:11:26 debug Exp $
20070501	Continuing a little on m88k disassembly (control registers,
		more instructions).
		Adding a dummy mvme88k machine mode.
20070502	Re-adding MIPS load/store alignment exceptions.
20070503	Implementing more of the M88K disassembly code.
20070504	Adding disassembly of some more M88K load/store instructions.
		Implementing some relatively simple M88K instructions (br.n,
		xor[.u] imm, and[.u] imm).
20070505	Implementing M88K three-register and, or, xor, and jmp[.n],
		bsr[.n] including function call trace stuff.
		Applying a patch from Bruce M. Simpson which implements the
		SYSCON_BOARD_CPU_CLOCK_FREQ_ID object of the syscon call in
		the yamon PROM emulation.
20070506	Implementing M88K bb0[.n] and bb1[.n], and skeletons for
		ldcr and stcr (although no control regs are implemented yet).
20070509	Found and fixed the bug which caused Linux for QEMU_MIPS to
		stop working in 0.4.5.1: It was a faulty change to the MIPS
		'sc' and 'scd' instructions I made while going through gcc -W
		warnings on 20070428.
20070510	Updating the Linux/QEMU_MIPS section in guestoses.html to
		use mips-test-0.2.tar.gz instead of 0.1.
		A big thank you to Miod Vallat for sending me M88K manuals.
		Implementing more M88K instructions (addu, subu, div[u], mulu,
		ext[u], clr, set, cmp).
20070511	Fixing bugs in the M88K "and" and "and.u" instructions (found
		by comparing against the manual).
		Implementing more M88K instructions (mask[.u], mak, bcnd (auto-
		generated)) and some more control register details.
		Cleanup: Removing the experimental AVR emulation mode and
		corresponding devices; AVR emulation wasn't really meaningful.
		Implementing autogeneration of most M88K loads/stores. The
		rectangle drawing demo (with -O0) for M88K runs :-)
		Beginning on M88K exception handling.
		More M88K instructions: tb0, tb1, rte, sub, jsr[.n].
		Adding some skeleton MVME PROM ("BUG") emulation.
20070512	Fixing a bug in the M88K cmp instruction.
		Adding the M88K lda (scaled register) instruction.
		Fixing bugs in 64-bit (32-bit pairs) M88K loads/stores.
		Removing the unused tick_hz stuff from the machine struct.
		Implementing the M88K xmem instruction. OpenBSD/mvme88k gets
		far enough to display the Copyright banner :-)
		Implementing subu.co (guess), addu.co, addu.ci, ff0, and ff1.
		Adding a dev_mvme187, for MVME187-specific devices/registers.
		OpenBSD/mvme88k prints more boot messages. :)
20070515	Continuing on MVME187 emulation (adding more devices, beginning
		on the CMMUs, etc).
		Adding the M88K and.c, xor.c, and or.c instructions, and making
		sure that mul, div, etc cause exceptions if executed when SFD1
		is disabled.
20070517	Continuing on M88K and MVME187 emulation in general; moving
		the CMMU registers to the CPU struct, separating dev_pcc2 from
		dev_mvme187, and beginning on memory_m88k.c (BATC and PATC).
		Fixing a bug in 64-bit (32-bit pairs) M88K fast stores.
		Implementing the clock part of dev_mk48txx.
		Implementing the M88K fstcr and xcr instructions.
		Implementing m88k_cpu_tlbdump().
		Beginning on the implementation of a separate address space
		for M88K .usr loads/stores.
20070520	Removing the non-working (skeleton) Sandpoint, SonyNEWS, SHARK
		Dnard, and Zaurus machine modes.
		Experimenting with dyntrans to_be_translated read-ahead. It
		seems to give a very small performance increase for MIPS
		emulation, but a large performance degradation for SuperH. Hm.
20070522	Disabling correct SuperH ITLB emulation; it does not seem to be
		necessary in order to let SH4 guest OSes run, and it slows down
		userspace code.
		Implementing "samepage" branches for SuperH emulation, and some
		other minor speed hacks.
20070525	Continuing on M88K memory-related stuff: exceptions, memory
		transaction register contents, etc.
		Implementing the M88K subu.ci instruction.
		Removing the non-working (skeleton) Iyonix machine mode.
		OpenBSD/mvme88k reaches userland :-), starts executing
		/sbin/init's instructions, and issues a few syscalls, before
		crashing.
20070526	Fixing bugs in dev_mk48txx, so that OpenBSD/mvme88k detects
		the correct time-of-day.
		Implementing a generic IRQ controller for the test machines
		(dev_irqc), similar to a proposed patch from Petr Stepan.
		Experimenting some more with translation read-ahead.
		Adding an "expect" script for automated OpenBSD/landisk
		install regression/performance tests.
20070527	Adding a dummy mmEye (SH3) machine mode skeleton.
		FINALLY found the strange M88K bug I have been hunting: I had
		not emulated the SNIP value for exceptions occurring in
		branch delay slots correctly.
		Implementing correct exceptions for 64-bit M88K loads/stores.
		Address to symbol lookups are now disabled when M88K is
		running in usermode (because usermode addresses don't have
		anything to do with supervisor addresses).
20070531	Removing the mmEye machine mode skeleton.
20070604	Some minor code cleanup.
20070605	Moving src/useremul.c into a subdir (src/useremul/), and
		cleaning up some more legacy constructs.
		Adding -Wstrict-aliasing and -fstrict-aliasing detection to
		the configure script.
20070606	Adding a check for broken GCC on Solaris to the configure
		script. (GCC 3.4.3 on Solaris cannot handle static variables
		which are initialized to 0 or NULL. :-/)
		Removing the old (non-working) ARC emulation modes: NEC RD94,
		R94, R96, and R98, and the last traces of Olivetti M700 and
		Deskstation Tyne.
		Removing the non-working skeleton WDSC device (dev_wdsc).
20070607	Thinking about how to use the host's cc + ld at runtime to
		generate native code. (See experiments/native_cc_ld_test.i
		for an example.)
20070608	Adding a program counter sampling timer, which could be useful
		for native code generation experiments.
		The KN02_CSR_NRMMOD bit in the DECstation 5000/200 (KN02) CSR
		should always be set, to allow a 5000/200 PROM to boot.
20070609	Moving out breakpoint details from the machine struct into
		a helper struct, and removing the limit on max nr of
		breakpoints.
20070610	Moving out tick functions into a helper struct as well (which
		also gets rid of the max limit).
20070612	FINALLY figured out why Debian/DECstation stopped working when
		translation read-ahead was enabled: in src/memory_rw.c, the
		call to invalidate_code_translation was made also if the
		memory access was an instruction load (if the page was mapped
		as writable); it shouldn't be called in that case.
20070613	Implementing some more MIPS32/64 revision 2 instructions: di,
		ei, ext, dext, dextm, dextu, and ins.
20070614	Implementing an instruction combination for the NetBSD/arm
		idle loop (making the host not use any cpu if NetBSD/arm
		inside the emulator is not using any cpu).
		Increasing the nr of ARM VPH entries from 128 to 384.
20070615	Removing the ENABLE_arch stuff from the configure script, so
		that all included architectures are included in both release
		and development builds.
		Moving memory related helper functions from misc.c to memory.c.
		Adding preliminary instructions for netbooting NetBSD/pmppc to
		guestoses.html; it doesn't work yet, there are weird timeouts.
		Beginning a total rewrite of the userland emulation modes
		(removing all emulation modes, beginning from scratch with
		NetBSD/MIPS and FreeBSD/Alpha only).
20070616	After fixing a bug in the DEC21143 NIC (the TDSTAT_OWN bit was
		only cleared for the last segment when transmitting, not all
		segments), NetBSD/pmppc boots with root-on-nfs without the
		timeouts. Updating guestoses.html.
		Removing the skeleton PSP (Playstation Portable) mode.
		Moving X11-related stuff in the machine struct into a helper
		struct.
		Cleanup of out-of-memory checks, to use a new CHECK_ALLOCATION
		macro (which prints a meaningful error message).
		Adding a COMMENT to each machine and device (for automagic
		.index comment generation).
		Doing regression testing for the next release.

==============  RELEASE 0.4.6  ==============


1 /*
2 * Copyright (C) 2003-2007 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_sgi.c,v 1.22 2007/06/15 18:08:10 debug Exp $
29 *
30 * COMMENT: Silicon Graphics' MIPS-based machines
31 *
32 * http://obsolete.majix.org/computers/sgi/iptable.shtml contains a
33 * pretty detailed list of IP ("Inhouse Processor") model numbers.
34 *
35 * See also: http://hardware.majix.org/computers/sgi/iptable.shtml
36 */
37
38 #include <stdio.h>
39 #include <stdlib.h>
40 #include <string.h>
41
42 #include "arcbios.h"
43 #include "bus_pci.h"
44 #include "cpu.h"
45 #include "device.h"
46 #include "devices.h"
47 #include "diskimage.h"
48 #include "machine.h"
49 #include "memory.h"
50 #include "misc.h"
51 #include "net.h"
52
53 #include "sgi_arcbios.h"
54 #include "crimereg.h"
55
56
57 #define ETHERNET_STRING_MAXLEN 40
58 #define MACHINE_NAME_MAXBUF 100
59
60
61 MACHINE_SETUP(sgi)
62 {
63 uint64_t sgi_ram_offset = 0;
64 int arc_wordlen = sizeof(uint32_t);
65 struct memory *mem = machine->memory;
66 char tmpstr[1000];
67 int i, j;
68 char *eaddr_string = "eaddr=10:20:30:40:50:60"; /* bogus */
69 unsigned char macaddr[6];
70
71 struct pci_data *pci_data = NULL;
72
73 CHECK_ALLOCATION(machine->machine_name = malloc(MACHINE_NAME_MAXBUF));
74
75 cpu->byte_order = EMUL_BIG_ENDIAN;
76 snprintf(machine->machine_name, MACHINE_NAME_MAXBUF,
77 "SGI-IP%i", machine->machine_subtype);
78
79 sgi_ram_offset = 1048576 * machine->memory_offset_in_mb;
80
81 /* Special cases for IP20,22,24,26 memory offset: */
82 if (machine->machine_subtype == 20 || machine->machine_subtype == 22 ||
83 machine->machine_subtype == 24 || machine->machine_subtype == 26) {
84 dev_ram_init(machine, 0x00000000, 0x10000, DEV_RAM_MIRROR
85 | DEV_RAM_MIGHT_POINT_TO_DEVICES, sgi_ram_offset);
86 dev_ram_init(machine, 0x00050000, sgi_ram_offset-0x50000,
87 DEV_RAM_MIRROR | DEV_RAM_MIGHT_POINT_TO_DEVICES,
88 sgi_ram_offset + 0x50000);
89 }
90
91 /* Special cases for IP28,30 memory offset: */
92 if (machine->machine_subtype == 28 || machine->machine_subtype == 30) {
93 /* TODO: length below should maybe not be 128MB? */
94 dev_ram_init(machine, 0x00000000, 128*1048576, DEV_RAM_MIRROR
95 | DEV_RAM_MIGHT_POINT_TO_DEVICES, sgi_ram_offset);
96 }
97
98 net_generate_unique_mac(machine, macaddr);
99 CHECK_ALLOCATION(eaddr_string = malloc(ETHERNET_STRING_MAXLEN));
100
101 switch (machine->machine_subtype) {
102
103 case 10:
104 strlcat(machine->machine_name, " (4D/25)", MACHINE_NAME_MAXBUF);
105 /* TODO */
106 break;
107
108 case 12:
109 strlcat(machine->machine_name,
110 " (Iris Indigo IP12)", MACHINE_NAME_MAXBUF);
111
112 /* TODO */
113 /* 33 MHz R3000, according to http://www.irisindigo.com/ */
114 /* "capable of addressing up to 96MB of memory." */
115
116 break;
117
118 case 19:
119 strlcat(machine->machine_name,
120 " (Everest IP19)", MACHINE_NAME_MAXBUF);
121 machine->main_console_handle = (size_t)device_add(machine,
122 "z8530 addr=0x1fbd9830 irq=0 addr_mult=4");
123 dev_scc_init(machine, mem, 0x10086000, 0, machine->x11_md.in_use,
124 0, 8); /* serial? irix? */
125
126 device_add(machine, "sgi_ip19 addr=0x18000000");
127
128 /* Irix' <everest_du_init+0x130> reads this device: */
129 device_add(machine, "random addr=0x10006000 len=16");
130
131 /* Irix' get_mpconf() looks for this: (TODO) */
132 store_32bit_word(cpu, 0xa0000000 + 0x3000,
133 0xbaddeed2);
134
135 /* Memory size, not 4096 byte pages, but 256 bytes?
136 (16 is size of kernel... approx) */
137 store_32bit_word(cpu, 0xa0000000 + 0x26d0, 30000);
138 /* (machine->physical_ram_in_mb - 16) * (1048576 / 256)); */
139
140 break;
141
142 case 20:
143 strlcat(machine->machine_name,
144 " (Indigo)", MACHINE_NAME_MAXBUF);
145
146 /*
147 * Guesses based on NetBSD 2.0 beta, 20040606.
148 *
149 * int0 at mainbus0 addr 0x1fb801c0: bus 1MHz, CPU 2MHz
150 * imc0 at mainbus0 addr 0x1fa00000: revision 0
151 * gio0 at imc0
152 * unknown GIO card (product 0x00 revision 0x00)
153 * at gio0 slot 0 addr 0x1f400000 not configured
154 * unknown GIO card (product 0x00 revision 0x00)
155 * at gio0 slot 1 addr 0x1f600000 not configured
156 * unknown GIO card (product 0x00 revision 0x00)
157 * at gio0 slot 2 addr 0x1f000000 not configured
158 * hpc0 at gio0 addr 0x1fb80000: SGI HPC1
159 * zsc0 at hpc0 offset 0xd10 (channels 0 and 1,
160 * channel 1 for console)
161 * zsc1 at hpc0 offset 0xd00 (2 channels)
162 * sq0 at hpc0 offset 0x100: SGI Seeq 80c03
163 * wdsc0 at hpc0 offset 0x11f
164 * dpclock0 at hpc0 offset 0xe00
165 */
166
167 /* int0 at mainbus0 addr 0x1fb801c0 */
168 fatal("TODO: SGI legacy interrupt system rewrite!\n");
169 abort();
170 // machine->md_int.sgi_ip20_data = dev_sgi_ip20_init(cpu, mem,
171 // DEV_SGI_IP20_BASE);
172
173 /* imc0 at mainbus0 addr 0x1fa00000: revision 0:
174 TODO (or in dev_sgi_ip20?) */
175
176 machine->main_console_handle = (size_t)device_add(machine,
177 "z8530 addr=0x1fbd9830 irq=0 addr_mult=4");
178
179 /* This is the zsc0 reported by NetBSD: TODO: irqs */
180 machine->main_console_handle = (size_t)device_add(machine,
181 "z8530 addr=0x1fb80d10 irq=0 addr_mult=4");
182 machine->main_console_handle = (size_t)device_add(machine,
183 "z8530 addr=0x1fb80d00 irq=0 addr_mult=4");
184
185 /* WDSC SCSI controller: */
186 /* dev_wdsc_init(machine, mem, 0x1fb8011f, 0, 0); */
187
188 /* Return memory read errors so that hpc1
189 and hpc2 are not detected: */
190 device_add(machine, "unreadable addr=0x1fb00000 len=0x10000");
191 device_add(machine, "unreadable addr=0x1f980000 len=0x10000");
192
193 /* Return nothing for gio slots 0, 1, and 2: */
194 device_add(machine, "unreadable addr=0x1f400000 len=0x1000");
195 device_add(machine, "unreadable addr=0x1f600000 len=0x1000");
196 device_add(machine, "unreadable addr=0x1f000000 len=0x1000");
197
198 break;
199
200 case 21:
201 strlcat(machine->machine_name, /* TODO */
202 " (uknown SGI-IP21 ?)", MACHINE_NAME_MAXBUF);
203 /* NOTE: Special case for arc_wordlen: */
204 arc_wordlen = sizeof(uint64_t);
205
206 device_add(machine, "random addr=0x418000200, len=0x20000");
207
208 break;
209
210 case 22:
211 case 24:
212 if (machine->machine_subtype == 22) {
213 strlcat(machine->machine_name,
214 " (Indy, Indigo2, Challenge S; Full-house)",
215 MACHINE_NAME_MAXBUF);
216 fatal("TODO: SGI legacy interrupt system rewrite!\n");
217 abort();
218 // machine->md_int.sgi_ip22_data =
219 // dev_sgi_ip22_init(machine, mem, 0x1fbd9000, 0);
220 } else {
221 strlcat(machine->machine_name,
222 " (Indy, Indigo2, Challenge S; Guiness)",
223 MACHINE_NAME_MAXBUF);
224 fatal("TODO: SGI legacy interrupt system rewrite!\n");
225 abort();
226 // machine->md_int.sgi_ip22_data =
227 // dev_sgi_ip22_init(machine, mem, 0x1fbd9880, 1);
228 }
229
230 /*
231 Why is this here? TODO
232 dev_ram_init(machine, 0x88000000ULL,
233 128 * 1048576, DEV_RAM_MIRROR, 0x08000000);
234 */
235
236 fatal("TODO: Legacy rewrite\n");
237 abort();
238 // machine->md_interrupt = sgi_ip22_interrupt;
239
240 /*
241 * According to NetBSD 1.6.2:
242 *
243 * imc0 at mainbus0 addr 0x1fa00000, Revision 0
244 * gio0 at imc0
245 * hpc0 at gio0 addr 0x1fb80000: SGI HPC3
246 * zsc0 at hpc0 offset 0x59830
247 * zstty0 at zsc0 channel 1 (console i/o)
248 * zstty1 at zsc0 channel 0
249 * sq0 at hpc0 offset 0x54000: SGI Seeq 80c03 (Ethernet)
250 * wdsc0 at hpc0 offset 0x44000: WD33C93 SCSI, rev=0, target 7
251 * scsibus2 at wdsc0: 8 targets, 8 luns per target
252 * dsclock0 at hpc0 offset 0x60000
253 *
254 * According to Linux/IP22:
255 * tty00 at 0xbfbd9830 (irq = 45) is a Zilog8530
256 * tty01 at 0xbfbd9838 (irq = 45) is a Zilog8530
257 *
258 * and according to NetBSD 2.0_BETA (20040606):
259 *
260 * haltwo0 at hpc0 offset 0x58000: HAL2 revision 0.0.0
261 * audio0 at haltwo0: half duplex
262 *
263 * IRQ numbers are of the form 8 + x, where x=0..31 for local0
264 * interrupts, and 32..63 for local1. + y*65 for "mappable".
265 */
266
267 /* zsc0 serial console. 8 + 32 + 3 + 64*5 = 43+64*5 = 363 */
268 i = (size_t)device_add(machine,
269 "z8530 addr=0x1fbd9830 irq=363 addr_mult=4");
270
271 /* Not supported by NetBSD 1.6.2, but by 2.0_BETA: */
272 fatal("TODO: legacy rewrite\n");
273 abort();
274 // j = dev_pckbc_init(machine, mem, 0x1fbd9840, PCKBC_8242,
275 // 0, 0, machine->x11_md.in_use, 0); /* TODO: irq numbers */
276 j = 0;
277
278 if (machine->x11_md.in_use)
279 machine->main_console_handle = j;
280
281 /* sq0: Ethernet. TODO: This should have irq_nr = 8 + 3 */
282 /* dev_sq_init... */
283
284 /* wdsc0: SCSI */
285 /* dev_wdsc_init(machine, mem, 0x1fbc4000, 0, 8 + 1); */
286
287 /* wdsc1: SCSI TODO: irq nr */
288 /* dev_wdsc_init(machine, mem, 0x1fbcc000, 1, 8 + 1); */
289
290 /* dsclock0: TODO: possibly irq 8 + 33 */
291
292 /* Return memory read errors so that hpc1 and hpc2 are
293 not detected: */
294 device_add(machine, "unreadable addr=0x1fb00000, len=0x10000");
295 device_add(machine, "unreadable addr=0x1f980000, len=0x10000");
296
297 /* Similarly for gio slots 0, 1, and 2: */
298 device_add(machine, "unreadable addr=0x1f400000, len=0x1000");
299 device_add(machine, "unreadable addr=0x1f600000, len=0x1000");
300 device_add(machine, "unreadable addr=0x1f000000, len=0x1000");
301
302 break;
303
304 case 25:
305 /* NOTE: Special case for arc_wordlen: */
306 arc_wordlen = sizeof(uint64_t);
307 strlcat(machine->machine_name,
308 " (Everest IP25)", MACHINE_NAME_MAXBUF);
309
310 /* serial? irix? */
311 dev_scc_init(machine, mem,
312 0x400086000ULL, 0, machine->x11_md.in_use, 0, 8);
313
314 /* NOTE: ip19! (perhaps not really the same */
315 device_add(machine, "sgi_ip19 addr=0x18000000");
316
317 /*
318 * Memory size, not 4096 byte pages, but 256
319 * bytes? (16 is size of kernel... approx)
320 */
321 store_32bit_word(cpu, 0xa0000000ULL + 0x26d0,
322 30000); /* (machine->physical_ram_in_mb - 16)
323 * (1048576 / 256)); */
324
325 break;
326
327 case 26:
328 /* NOTE: Special case for arc_wordlen: */
329 arc_wordlen = sizeof(uint64_t);
330 strlcat(machine->machine_name, " (uknown SGI-IP26 ?)",
331 MACHINE_NAME_MAXBUF); /* TODO */
332 machine->main_console_handle = (size_t)device_add(machine,
333 "z8530 addr=0x1fbd9830 irq=0 addr_mult=4");
334 break;
335
336 case 27:
337 strlcat(machine->machine_name, " (Origin 200/2000, Onyx2)",
338 MACHINE_NAME_MAXBUF);
339 arc_wordlen = sizeof(uint64_t);
340 /* 2 cpus per node */
341
342 machine->main_console_handle = (size_t)device_add(machine,
343 "z8530 addr=0x1fbd9830 irq=0 addr_mult=4");
344 break;
345
346 case 28:
347 /* NOTE: Special case for arc_wordlen: */
348 arc_wordlen = sizeof(uint64_t);
349 strlcat(machine->machine_name,
350 " (Impact Indigo2 ?)", MACHINE_NAME_MAXBUF);
351
352 device_add(machine, "random addr=0x1fbe0000, len=1");
353
354 /* Something at paddr 0x1880fb0000. */
355
356 break;
357
358 case 30:
359 /* NOTE: Special case for arc_wordlen: */
360 arc_wordlen = sizeof(uint64_t);
361 strlcat(machine->machine_name, " (Octane)",
362 MACHINE_NAME_MAXBUF);
363
364 fatal("TODO: SGI legacy interrupt system rewrite!\n");
365 abort();
366 // machine->md_int.sgi_ip30_data =
367 // dev_sgi_ip30_init(machine, mem, 0x0ff00000);
368
369 fatal("TODO: Legacy rewrite\n");
370 abort();
371 // machine->md_interrupt = sgi_ip30_interrupt;
372
373 dev_ram_init(machine, 0xa0000000ULL, 128 * 1048576,
374 DEV_RAM_MIRROR | DEV_RAM_MIGHT_POINT_TO_DEVICES,
375 0x00000000);
376
377 dev_ram_init(machine, 0x80000000ULL,
378 32 * 1048576, DEV_RAM_RAM, 0x00000000);
379
380 /*
381 * Something at paddr=1f022004: TODO
382 * Something at paddr=813f0510 - paddr=813f0570 ?
383 * Something at paddr=813f04b8
384 * Something at paddr=f8000003c used by Linux/Octane
385 *
386 * 16550 serial port at paddr=1f620178, addr mul 1
387 * (Error messages are printed to this serial port by
388 * the PROM.)
389 *
390 * There seems to also be a serial port at 1f620170. The
391 * "symmon" program dumps something there, but it doesn't
392 * look like readable text. (TODO)
393 */
394
395 /* TODO: irq! */
396 snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=0 addr="
397 "0x1f620170 name2=tty0 in_use=%i", machine->x11_md.in_use? 0 : 1);
398 machine->main_console_handle = (size_t)device_add(machine,
399 tmpstr);
400 snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=0 addr="
401 "0x1f620178 name2=tty1 in_use=0");
402 device_add(machine, tmpstr);
403
404 /* MardiGras graphics: */
405 device_add(machine, "sgi_mardigras addr=0x1c000000");
406
407 break;
408
409 case 32:
410 strlcat(machine->machine_name, " (O2)", MACHINE_NAME_MAXBUF);
411
412 /* TODO: Find out where the phys ram is actually located. */
413 dev_ram_init(machine, 0x07ffff00ULL, 256,
414 DEV_RAM_MIRROR, 0x03ffff00);
415 dev_ram_init(machine, 0x10000000ULL, 256,
416 DEV_RAM_MIRROR, 0x00000000);
417 dev_ram_init(machine, 0x11ffff00ULL, 256,
418 DEV_RAM_MIRROR, 0x01ffff00);
419 dev_ram_init(machine, 0x12000000ULL, 256,
420 DEV_RAM_MIRROR, 0x02000000);
421 dev_ram_init(machine, 0x17ffff00ULL, 256,
422 DEV_RAM_MIRROR, 0x03ffff00);
423 dev_ram_init(machine, 0x20000000ULL, 128 * 1048576,
424 DEV_RAM_MIRROR, 0x00000000);
425 dev_ram_init(machine, 0x40000000ULL, 128 * 1048576,
426 DEV_RAM_MIRROR, 0x10000000);
427
428 /* Connect CRIME (Interrupt Controller) to MIPS irq 2: */
429 snprintf(tmpstr, sizeof(tmpstr), "%s.cpu[%i].2",
430 machine->path, machine->bootstrap_cpu);
431 dev_crime_init(machine, mem, 0x14000000, tmpstr,
432 machine->x11_md.in_use); /* crime0 */
433 dev_sgi_mte_init(mem, 0x15000000); /* mte ??? */
434 dev_sgi_gbe_init(machine, mem, 0x16000000); /* gbe? */
435
436 /*
437 * A combination of NetBSD and Linux info:
438 *
439 * 17000000 vice (Video Image Compression Engine)
440 * 1f000000 mace
441 * 1f080000 macepci
442 * 1f100000 vin1
443 * 1f180000 vin2
444 * 1f200000 vout
445 * 1f280000 enet (mec0, MAC-110 Ethernet)
446 * 1f300000 perif:
447 * 1f300000 audio
448 * 1f310000 isa
449 * 1f318000 (accessed by Irix'
450 * pciio_pio_write64)
451 * 1f320000 kbdms
452 * 1f330000 i2c
453 * 1f340000 ust
454 * 1f380000 isa ext
455 * 1f390000 com0 (serial)
456 * 1f398000 com1 (serial)
457 * 1f3a0000 mcclock0
458 */
459
460 /*
461 * IRQ mapping is really ugly. TODO: fix
462 *
463 * com0 at mace0 offset 0x390000 intr 4 intrmask
464 * 0x3f00000: ns16550a, working fifo
465 * com1 at mace0 offset 0x398000 intr 4 intrmask
466 * 0xfc000000: ns16550a, working fifo
467 * pckbc0 at mace0 offset 0x320000 intr 5 intrmask 0x0
468 * mcclock0 at mace0 offset 0x3a0000 intrmask 0x0
469 * macepci0 at mace0 offset 0x80000 intr 7 intrmask 0x0: rev 1
470 *
471 * intr 4 = MACE_PERIPH_SERIAL
472 * intr 5 = MACE_PERIPH_MISC
473 * intr 7 = MACE_PCI_BRIDGE
474 */
475
476 snprintf(eaddr_string, ETHERNET_STRING_MAXLEN,
477 "eaddr=%02x:%02x:%02x:%02x:%02x:%02x",
478 macaddr[0], macaddr[1], macaddr[2],
479 macaddr[3], macaddr[4], macaddr[5]);
480
481 snprintf(tmpstr, sizeof(tmpstr), "%s.cpu[%i].2.crime.0x%x",
482 machine->path, machine->bootstrap_cpu, MACE_ETHERNET);
483 dev_sgi_mec_init(machine, mem, 0x1f280000,
484 tmpstr, macaddr);
485
486 dev_sgi_ust_init(mem, 0x1f340000); /* ust? */
487
488 snprintf(tmpstr, sizeof(tmpstr),
489 "ns16550 irq=%s.cpu[%i].2.crime.0x%x.mace.%i addr="
490 "0x1f390000 addr_mult=0x100 in_use=%i name2=tty0",
491 machine->path, machine->bootstrap_cpu,
492 MACE_PERIPH_SERIAL, 20, machine->x11_md.in_use? 0 : 1);
493 j = (size_t)device_add(machine, tmpstr);
494 snprintf(tmpstr, sizeof(tmpstr),
495 "ns16550 irq=%s.cpu[%i].2.crime.0x%x.mace.%i addr="
496 "0x1f398000 addr_mult=0x100 in_use=%i name2=tty1",
497 machine->path, machine->bootstrap_cpu,
498 MACE_PERIPH_SERIAL, 26, 0);
499 device_add(machine, tmpstr);
500
501 machine->main_console_handle = j;
502
503 /* TODO: Once this works, it should be enabled
504 always, not just when using X! */
505 #if 0
506 fatal("TODO: legacy SGI rewrite\n");
507 abort();
508 if (machine->x11_md.in_use) {
509 i = dev_pckbc_init(machine, mem, 0x1f320000,
510 PCKBC_8242, 0x200 + MACE_PERIPH_MISC,
511 0x800 + MACE_PERIPH_MISC, machine->x11_md.in_use, 0);
512 /* keyb+mouse (mace irq numbers) */
513 machine->main_console_handle = i;
514 }
515 #endif
516
517 snprintf(tmpstr, sizeof(tmpstr),
518 "%s.cpu[%i].2.crime.0x%x.mace.%i",
519 machine->path, machine->bootstrap_cpu,
520 MACE_PERIPH_MISC, 8);
521 dev_mc146818_init(machine, mem, 0x1f3a0000, tmpstr,
522 MC146818_SGI, 0x40); /* mcclock0 */
523
524 /* TODO: _WHERE_ does the z8530 interrupt? */
525 snprintf(tmpstr, sizeof(tmpstr), "z8530 addr=0x1fbd9830 "
526 "irq=%s.cpu[%i].2 addr_mult=4",
527 machine->path, machine->bootstrap_cpu);
528 machine->main_console_handle = (size_t)
529 device_add(machine, tmpstr);
530
531 /*
532 * PCI devices: (according to NetBSD's GENERIC
533 * config file for sgimips)
534 *
535 * ne* at pci? dev ? function ?
536 * ahc0 at pci0 dev 1 function ?
537 * ahc1 at pci0 dev 2 function ?
538 */
539
540 snprintf(tmpstr, sizeof(tmpstr),
541 "%s.cpu[%i].2.crime.0x%x", machine->path,
542 machine->bootstrap_cpu, MACE_PCI_BRIDGE);
543 pci_data = dev_macepci_init(machine, mem, 0x1f080000,
544 tmpstr); /* macepci0 */
545 /* bus_pci_add(machine, pci_data, mem, 0, 0, 0,
546 "ne2000"); TODO */
547
548 /* TODO: make this nicer */
549 if (diskimage_exist(machine, 0, DISKIMAGE_SCSI) ||
550 diskimage_exist(machine, 1, DISKIMAGE_SCSI) ||
551 diskimage_exist(machine, 2, DISKIMAGE_SCSI) ||
552 diskimage_exist(machine, 3, DISKIMAGE_SCSI) ||
553 diskimage_exist(machine, 4, DISKIMAGE_SCSI) ||
554 diskimage_exist(machine, 5, DISKIMAGE_SCSI) ||
555 diskimage_exist(machine, 6, DISKIMAGE_SCSI) ||
556 diskimage_exist(machine, 7, DISKIMAGE_SCSI))
557 bus_pci_add(machine, pci_data, mem, 0, 1, 0, "ahc");
558
559 /* TODO: second ahc */
560 /* bus_pci_add(machine, pci_data, mem, 0, 2, 0, "ahc"); */
561
562 /*
563 * An additional PCI IDE controller, for NetBSD/sgimips
564 * experiments: (Not found in a regular O2.)
565 */
566 bus_pci_add(machine, pci_data, mem, 0, 3, 0, "symphony_82c105");
567
568 break;
569
570 case 35:
571 strlcat(machine->machine_name,
572 " (Origin 3000)", MACHINE_NAME_MAXBUF);
573 /* 4 cpus per node */
574
575 machine->main_console_handle = (size_t)device_add(machine,
576 "z8530 addr=0x1fbd9830 irq=0 addr_mult=4");
577 break;
578
579 case 53:
580 strlcat(machine->machine_name, " (Origin 350)",
581 MACHINE_NAME_MAXBUF);
582
583 /*
584 * According to http://kumba.drachentekh.net/xml/myguide.html
585 * Origin 350, Tezro IP53 R16000
586 */
587 break;
588
589 default:
590 fatal("unimplemented SGI machine type IP%i\n",
591 machine->machine_subtype);
592 exit(1);
593 }
594
595 if (!machine->prom_emulation)
596 return;
597
598 arcbios_init(machine, arc_wordlen == sizeof(uint64_t), sgi_ram_offset,
599 eaddr_string, macaddr);
600 }
601
602
603 MACHINE_DEFAULT_CPU(sgi)
604 {
605 if (machine->machine_subtype <= 12)
606 machine->cpu_name = strdup("R3000");
607 if (machine->cpu_name == NULL && machine->machine_subtype == 35)
608 machine->cpu_name = strdup("R12000");
609 if (machine->cpu_name == NULL && (machine->machine_subtype == 25 ||
610 machine->machine_subtype == 27 || machine->machine_subtype == 28 ||
611 machine->machine_subtype == 30 || machine->machine_subtype == 32))
612 machine->cpu_name = strdup("R10000");
613 if (machine->cpu_name == NULL && (machine->machine_subtype == 21 ||
614 machine->machine_subtype == 26))
615 machine->cpu_name = strdup("R8000");
616 if (machine->cpu_name == NULL && machine->machine_subtype == 24)
617 machine->cpu_name = strdup("R5000");
618
619 /* Other SGIs should probably work with
620 R4000, R4400 or R5000 or similar: */
621 if (machine->cpu_name == NULL)
622 machine->cpu_name = strdup("R4400");
623 }
624
625
626 MACHINE_DEFAULT_RAM(sgi)
627 {
628 machine->physical_ram_in_mb = 64;
629 }
630
631
632 MACHINE_REGISTER(sgi)
633 {
634 MR_DEFAULT(sgi, "SGI", ARCH_MIPS, MACHINE_SGI);
635
636 me->set_default_ram = machine_default_ram_sgi;
637
638 machine_entry_add_alias(me, "silicon graphics");
639 machine_entry_add_alias(me, "sgi");
640
641 machine_entry_add_subtype(me, "IP12", 12, "ip12", NULL);
642
643 machine_entry_add_subtype(me, "IP19", 19, "ip19", NULL);
644
645 machine_entry_add_subtype(me, "IP20", 20, "ip20", NULL);
646
647 machine_entry_add_subtype(me, "IP22", 22, "ip22", "indy", NULL);
648
649 machine_entry_add_subtype(me, "IP24", 24, "ip24", NULL);
650
651 machine_entry_add_subtype(me, "IP27", 27,
652 "ip27", "origin 200", "origin 2000", NULL);
653
654 machine_entry_add_subtype(me, "IP28", 28, "ip28", NULL);
655
656 machine_entry_add_subtype(me, "IP30", 30, "ip30", "octane", NULL);
657
658 machine_entry_add_subtype(me, "IP32", 32, "ip32", "o2", NULL);
659
660 machine_entry_add_subtype(me, "IP35", 35, "ip35", NULL);
661 }
662

  ViewVC Help
Powered by ViewVC 1.1.26