/[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 34 - (show annotations)
Mon Oct 8 16:21:17 2007 UTC (16 years, 7 months ago) by dpavlin
File MIME type: text/plain
File size: 21583 byte(s)
++ trunk/HISTORY	(local)
$Id: HISTORY,v 1.1480 2007/02/19 01:34:42 debug Exp $
20061029	Changing usleep(1) calls in the debugger to usleep(10000)
20061107	Adding a new disk image option (-d o...) which sets the ISO9660
		filesystem base offset; also making some other hacks to allow
		NetBSD/dreamcast and homebrew demos/games to boot directly
		from a filesystem image.
		Moving Dreamcast-specific stuff in the documentation to its
		own page (dreamcast.html).
		Adding a border to the Dreamcast PVR framebuffer.
20061108	Adding a -T command line option (again?), for halting the
		emulator on unimplemented memory accesses.
20061109	Continuing on various SH4 and Dreamcast related things.
		The emulator should now halt on more unimplemented device
		accesses, instead of just printing a warning, forcing me to
		actually implement missing stuff :)
20061111	Continuing on SH4 and Dreamcast stuff.
		Adding a bogus Landisk (SH4) machine mode.
20061112	Implementing some parts of the Dreamcast GDROM device. With
		some ugly hacks, NetBSD can (barely) mount an ISO image.
20061113	NetBSD/dreamcast now starts booting from the Live CD image,
		but crashes randomly quite early on in the boot process.
20061122	Beginning on a skeleton interrupt.h and interrupt.c for the
		new interrupt subsystem.
20061124	Continuing on the new interrupt system; taking the first steps
		to attempt to connect CPUs (SuperH and MIPS) and devices
		(dev_cons and SH4 timer interrupts) to it. Many things will
		probably break from now on.
20061125	Converting dev_ns16550, dev_8253 to the new interrupt system.
		Attempting to begin to convert the ISA bus.
20061130	Incorporating a patch from Brian Foley for the configure
		script, which checks for X11 libs in /usr/X11R6/lib64 (which
		is used on some Linux systems).
20061227	Adding a note in the man page about booting from Dreamcast
		CDROM images (i.e. that no external kernel is needed).
20061229	Continuing on the interrupt system rewrite: beginning to
		convert more devices, adding abort() calls for legacy interrupt
		system calls so that everything now _has_ to be rewritten!
		Almost all machine modes are now completely broken.
20061230	More progress on removing old interrupt code, mostly related
		to the ISA bus + devices, the LCA bus (on AlphaBook1), and
		the Footbridge bus (for CATS). And some minor PCI stuff.
		Connecting the ARM cpu to the new interrupt system.
		The CATS, NetWinder, and QEMU_MIPS machine modes now work with
		the new interrupt system :)
20061231	Connecting PowerPC CPUs to the new interrupt system.
		Making PReP machines (IBM 6050) work again.
		Beginning to convert the GT PCI controller (for e.g. Malta
		and Cobalt emulation). Some things work, but not everything.
		Updating Copyright notices for 2007.
20070101	Converting dev_kn02 from legacy style to devinit; the 3max
		machine mode now works with the new interrupt system :-]
20070105	Beginning to convert the SGI O2 machine to the new interrupt
		system; finally converting O2 (IP32) devices to devinit, etc.
20070106	Continuing on the interrupt system redesign/rewrite; KN01
		(PMAX), KN230, and Dreamcast ASIC interrupts should work again,
		moving out stuff from machine.h and devices.h into the
		corresponding devices, beginning the rewrite of i80321
		interrupts, etc.
20070107	Beginning on the rewrite of Eagle interrupt stuff (PReP, etc).
20070117	Beginning the rewrite of Algor (V3) interrupts (finally
		changing dev_v3 into devinit style).
20070118	Removing the "bus" registry concept from machine.h, because
		it was practically meaningless.
		Continuing on the rewrite of Algor V3 ISA interrupts.
20070121	More work on Algor interrupts; they are now working again,
		well enough to run NetBSD/algor. :-)
20070122	Converting VR41xx (HPCmips) interrupts. NetBSD/hpcmips
		can be installed using the new interrupt system :-)
20070123	Making the testmips mode work with the new interrupt system.
20070127	Beginning to convert DEC5800 devices to devinit, and to the
		new interrupt system.
		Converting Playstation 2 devices to devinit, and converting
		the interrupt system. Also fixing a severe bug: the interrupt
		mask register on Playstation 2 is bitwise _toggled_ on writes.
20070128	Removing the dummy NetGear machine mode and the 8250 device
		(which was only used by the NetGear machine).
		Beginning to convert the MacPPC GC (Grand Central) interrupt
		controller to the new interrupt system.
		Converting Jazz interrupts (PICA61 etc.) to the new interrupt
		system. NetBSD/arc can be installed again :-)
		Fixing the JAZZ timer (hardcoding it at 100 Hz, works with
		NetBSD and it is better than a completely dummy timer as it
		was before).
		Converting dev_mp to the new interrupt system, although I
		haven't had time to actually test it yet.
		Completely removing src/machines/interrupts.c, cpu_interrupt
		and cpu_interrupt_ack in src/cpu.c, and
		src/include/machine_interrupts.h! Adding fatal error messages
		+ abort() in the few places that are left to fix.
		Converting dev_z8530 to the new interrupt system.
		FINALLY removing the md_int struct completely from the
		machine struct.
		SH4 fixes (adding a PADDR invalidation in the ITLB replacement
		code in memory_sh.c); the NetBSD/dreamcast LiveCD now runs
		all the way to the login prompt, and can be interacted with :-)
		Converting the CPC700 controller (PCI and interrupt controller
		for PM/PPC) to the new interrupt system.
20070129	Fixing MACE ISA interrupts (SGI IP32 emulation). Both NetBSD/
		sgimips' and OpenBSD/sgi's ramdisk kernels can now be
		interacted with again.
20070130	Moving out the MIPS multi_lw and _sw instruction combinations
		so that they are auto-generated at compile time instead.
20070131	Adding detection of amd64/x86_64 hosts in the configure script,
		for doing initial experiments (again :-) with native code
		generation.
		Adding a -k command line option to set the size of the dyntrans
		cache, and a -B command line option to disable native code
		generation, even if GXemul was compiled with support for
		native code generation for the specific host CPU architecture.
20070201	Experimenting with a skeleton for native code generation.
		Changing the default behaviour, so that native code generation
		is now disabled by default, and has to be enabled by using
		-b on the command line.
20070202	Continuing the native code generation experiments.
		Making PCI interrupts work for Footbridge again.
20070203	More native code generation experiments.
		Removing most of the native code generation experimental code,
		it does not make sense to include any quick hacks like this.
		Minor cleanup/removal of some more legacy MIPS interrupt code.
20070204	Making i80321 interrupts work again (for NetBSD/evbarm etc.),
		and fixing the timer at 100 Hz.
20070206	Experimenting with removing the wdc interrupt slowness hack.
20070207	Lowering the number of dyntrans TLB entries for MIPS from
		192 to 128, resulting in a minor speed improvement.
		Minor optimization to the code invalidation routine in
		cpu_dyntrans.c.
20070208	Increasing (experimentally) the nr of dyntrans instructions per
		loop from 60 to 120.
20070210	Commenting out (experimentally) the dyntrans_device_danger
		detection in memory_rw.c.
		Changing the testmips and baremips machines to use a revision 2
		MIPS64 CPU by default, instead of revision 1.
		Removing the dummy i960, IA64, x86, AVR32, and HP PA-RISC
		files, the PC bios emulation, and the Olivetti M700 (ARC) and
		db64360 emulation modes.
20070211	Adding an "mp" demo to the demos directory, which tests the
		SMP functionality of the testmips machine.
		Fixing PReP interrupts some more. NetBSD/prep now boots again.
20070216	Adding a "nop workaround" for booting Mach/PMAX to the
		documentation; thanks to Artur Bujdoso for the values.
		Converting more of the MacPPC interrupt stuff to the new
		system.
		Beginning to convert BeBox interrupts to the new system.
		PPC603e should NOT have the PPC_NO_DEC flag! Removing it.
		Correcting BeBox clock speed (it was set to 100 in the NetBSD
		bootinfo block, but should be 33000000/4), allowing NetBSD
		to start without using the (incorrect) PPC_NO_DEC hack.
20070217	Implementing (slow) AltiVec vector loads and stores, allowing
		NetBSD/macppc to finally boot using the GENERIC kernel :-)
		Updating the documentation with install instructions for
		NetBSD/macppc.
20070218-19	Regression testing for the release.

==============  RELEASE 0.4.4  ==============


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

  ViewVC Help
Powered by ViewVC 1.1.26