/[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

Annotation of /trunk/src/machines/machine_sgi.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 24 - (hide annotations)
Mon Oct 8 16:19:56 2007 UTC (16 years, 7 months ago) by dpavlin
File MIME type: text/plain
File size: 20797 byte(s)
++ trunk/HISTORY	(local)
$Id: HISTORY,v 1.1256 2006/06/23 20:43:44 debug Exp $
20060219	Various minor updates. Removing the old MIPS16 skeleton code,
		because it will need to be rewritten for dyntrans anyway.
20060220-22	Removing the non-working dyntrans backend support.
		Continuing on the 64-bit dyntrans virtual memory generalization.
20060223	More work on the 64-bit vm generalization.
20060225	Beginning on MIPS dyntrans load/store instructions.
		Minor PPC updates (64-bit load/store, etc).
		Fixes for the variable-instruction-length framework, some
		minor AVR updates (a simple Hello World program works!).
		Beginning on a skeleton for automatically generating documen-
		tation (for devices etc.).
20060226	PPC updates (adding some more 64-bit instructions, etc).
		AVR updates (more instructions).
		FINALLY found and fixed the zs bug, making NetBSD/macppc
		accept the serial console.
20060301	Adding more AVR instructions.
20060304	Continuing on AVR-related stuff. Beginning on a framework for
		cycle-accurate device emulation. Adding an experimental "PAL
		TV" device (just a dummy so far).
20060305	Adding more AVR instructions.
		Adding a dummy epcom serial controller (for TS7200 emulation).
20060310	Removing the emul() command from configuration files, so only
		net() and machine() are supported.
		Minor progress on the MIPS dyntrans rewrite.
20060311	Continuing on the MIPS dyntrans rewrite (adding more
		instructions, etc).
20060315	Adding more instructions (sllv, srav, srlv, bgtz[l], blez[l],
		beql, bnel, slti[u], various loads and stores).
20060316	Removing the ALWAYS_SIGNEXTEND_32 option, since it was rarely
		used.
		Adding more MIPS dyntrans instructions, and fixing bugs.
20060318	Implementing fast loads/stores for MIPS dyntrans (big/little
		endian, 32-bit and 64-bit modes).
20060320	Making MIPS dyntrans the default configure option; use
		"--enable-oldmips" to use the old bintrans system.
		Adding MIPS dyntrans dmult[u]; minor updates.
20060322	Continuing... adding some more instructions.
		Adding a simple skeleton for demangling C++ "_ZN" symbols.
20060323	Moving src/debugger.c into a new directory (src/debugger/).
20060324	Fixing the hack used to load PPC ELFs (useful for relocated
		Linux/ppc kernels), and adding a dummy G3 machine mode.
20060325-26	Beginning to experiment with GDB remote serial protocol
		connections; adding a -G command line option for selecting
		which TCP port to listen to.
20060330	Beginning a major cleanup to replace things like "0x%016llx"
		with more correct "0x%016"PRIx64, etc.
		Continuing on the GDB remote serial protocol support.
20060331	More cleanup, and some minor GDB remote progress.
20060402	Adding a hack to the configure script, to allow compilation
		on systems that lack PRIx64 etc.
20060406	Removing the temporary FreeBSD/arm hack in dev_ns16550.c and
		replacing it with a better fix from Olivier Houchard.
20060407	A remote debugger (gdb or ddd) can now start and stop the
		emulator using the GDB remote serial protocol, and registers
		and memory can be read. MIPS only for now.
20060408	More GDB progress: single-stepping also works, and also adding
		support for ARM, PowerPC, and Alpha targets.
		Continuing on the delay-slot-across-page-boundary issue.
20060412	Minor update: beginning to add support for the SPARC target
		to the remote GDB functionality.
20060414	Various MIPS updates: adding more instructions for dyntrans
		(eret, add), and making some exceptions work. Fixing a bug
		in dmult[u].
		Implementing the first SPARC instructions (sethi, or).
20060415	Adding "magic trap" instructions so that PROM calls can be
		software emulated in MIPS dyntrans.
		Adding more MIPS dyntrans instructions (ddiv, dadd) and
		fixing another bug in dmult.
20060416	More MIPS dyntrans progress: adding [d]addi, movn, movz, dsllv,
		rfi, an ugly hack for supporting R2000/R3000 style faked caches,
		preliminary interrupt support, and various other updates and
		bugfixes.
20060417	Adding more SPARC instructions (add, sub, sll[x], sra[x],
		srl[x]), and useful SPARC header definitions.
		Adding the first (trivial) x86/AMD64 dyntrans instructions (nop,
		cli/sti, stc/clc, std/cld, simple mov, inc ax). Various other
		x86 updates related to variable instruction length stuff.
		Adding unaligned loads/stores to the MIPS dyntrans mode (but
		still using the pre-dyntrans (slow) imlementation).
20060419	Fixing a MIPS dyntrans exception-in-delay-slot bug.
		Removing the old "show opcode statistics" functionality, since
		it wasn't really useful and isn't implemented for dyntrans.
		Single-stepping (or running with instruction trace) now looks
		ok with dyntrans with delay-slot architectures.
20060420	Minor hacks (removing the -B command line option when compiled
		for non-bintrans, and some other very minor updates).
		Adding (slow) MIPS dyntrans load-linked/store-conditional.
20060422	Applying fixes for bugs discovered by Nils Weller's nwcc
		(static DEC memmap => now per machine, and adding an extern
		keyword in cpu_arm_instr.c).
		Finally found one of the MIPS dyntrans bugs that I've been
		looking for (copy/paste spelling error BIG vs LITTLE endian in
		cpu_mips_instr_loadstore.c for 16-bit fast stores).
		FINALLY found the major MIPS dyntrans bug: slti vs sltiu
		signed/unsigned code in cpu_mips_instr.c. :-)
		Adding more MIPS dyntrans instructions (lwc1, swc1, bgezal[l],
		ctc1, tlt[u], tge[u], tne, beginning on rdhwr).
		NetBSD/hpcmips can now reach userland when using dyntrans :-)
		Adding some more x86 dyntrans instructions.
		Finally removed the old Alpha-specific virtual memory code,
		and replaced it with the generic 64-bit version.
		Beginning to add disassembly support for SPECIAL3 MIPS opcodes.
20060423	Continuing on the delay-slot-across-page-boundary issue;
		adding an end_of_page2 ic slot (like I had planned before, but
		had removed for some reason).
		Adding a quick-and-dirty fallback to legacy coprocessor 1
		code (i.e. skipping dyntrans implementation for now).
		NetBSD/hpcmips and NetBSD/pmax (when running on an emulated
		R4400) can now be installed and run. :-)  (Many bugs left
		to fix, though.)
		Adding more MIPS dyntrans instructions: madd[u], msub[u].
		Cleaning up the SPECIAL2 vs R5900/TX79/C790 "MMI" opcode
		maps somewhat (disassembly and dyntrans instruction decoding).
20060424	Adding an isa_revision field to mips_cpu_types.h, and making
		sure that SPECIAL3 opcodes cause Reserved Instruction
		exceptions on MIPS32/64 revisions lower than 2.
		Adding the SPARC 'ba', 'call', 'jmpl/retl', 'and', and 'xor'
		instructions.
20060425	Removing the -m command line option ("run at most x 
		instructions") and -T ("single_step_on_bad_addr"), because
		they never worked correctly with dyntrans anyway.
		Freshening up the man page.
20060428	Adding more MIPS dyntrans instructions: bltzal[l], idle.
		Enabling MIPS dyntrans compare interrupts.
20060429	FINALLY found the weird dyntrans bug, causing NetBSD etc. to
		behave strangely: some floating point code (conditional
		coprocessor branches) could not be reused from the old
		non-dyntrans code. The "quick-and-dirty fallback" only appeared
		to work. Fixing by implementing bc1* for MIPS dyntrans.
		More MIPS instructions: [d]sub, sdc1, ldc1, dmtc1, dmfc1, cfc0.
		Freshening up MIPS floating point disassembly appearance.
20060430	Continuing on C790/R5900/TX79 disassembly; implementing 128-bit
		"por" and "pextlw".
20060504	Disabling -u (userland emulation) unless compiled as unstable
		development version.
		Beginning on freshening up the testmachine include files,
		to make it easier to reuse those files (placing them in
		src/include/testmachine/), and beginning on a set of "demos"
		or "tutorials" for the testmachine functionality.
		Minor updates to the MIPS GDB remote protocol stub.
		Refreshing doc/experiments.html and gdb_remote.html.
		Enabling Alpha emulation in the stable release configuration,
		even though no guest OSes for Alpha can run yet.
20060505	Adding a generic 'settings' object, which will contain
		references to settable variables (which will later be possible
		to access using the debugger).
20060506	Updating dev_disk and corresponding demo/documentation (and
		switching from SCSI to IDE disk types, so it actually works
		with current test machines :-).
20060510	Adding a -D_LARGEFILE_SOURCE hack for 64-bit Linux hosts,
		so that fseeko() doesn't give a warning.
		Updating the section about how dyntrans works (the "runnable
		IR") in doc/intro.html.
		Instruction updates (some x64=1 checks, some more R5900
		dyntrans stuff: better mul/mult separation from MIPS32/64,
		adding ei and di).
		Updating MIPS cpuregs.h to a newer one (from NetBSD).
		Adding more MIPS dyntrans instructions: deret, ehb.
20060514	Adding disassembly and beginning implementation of SPARC wr
		and wrpr instructions.
20060515	Adding a SUN SPARC machine mode, with dummy SS20 and Ultra1
		machines. Adding the 32-bit "rd psr" instruction.
20060517	Disassembly support for the general SPARC rd instruction.
		Partial implementation of the cmp (subcc) instruction.
		Some other minor updates (making sure that R5900 processors
		start up with the EIE bit enabled, otherwise Linux/playstation2
		receives no interrupts).
20060519	Minor MIPS updates/cleanups.
20060521	Moving the MeshCube machine into evbmips; this seems to work
		reasonably well with a snapshot of a NetBSD MeshCube kernel.
		Cleanup/fix of MIPS config0 register initialization.
20060529	Minor MIPS fixes, including a sign-extension fix to the
		unaligned load/store code, which makes NetBSD/pmax on R3000
		work better with dyntrans. (Ultrix and Linux/DECstation still
		don't work, though.)
20060530	Minor updates to the Alpha machine mode: adding an AlphaBook
		mode, an LCA bus (forwarding accesses to an ISA bus), etc.
20060531	Applying a bugfix for the MIPS dyntrans sc[d] instruction from
		Ondrej Palkovsky. (Many thanks.)
20060601	Minifix to allow ARM immediate msr instruction to not give
		an error for some valid values.
		More Alpha updates.
20060602	Some minor Alpha updates.
20060603	Adding the Alpha cmpbge instruction. NetBSD/alpha prints its
		first boot messages :-) on an emulated Alphabook 1.
20060612	Minor updates; adding a dev_ether.h include file for the
		testmachine ether device. Continuing the hunt for the dyntrans
		bug which makes Linux and Ultrix on DECstation behave
		strangely... FINALLY found it! It seems to be related to
		invalidation of the translation cache, on tlbw{r,i}. There
		also seems to be some remaining interrupt-related problems.
20060614	Correcting the implementation of ldc1/sdc1 for MIPS dyntrans
		(so that it uses 16 32-bit registers if the FR bit in the
		status register is not set).
20060616	REMOVING BINTRANS COMPLETELY!
		Removing the old MIPS interpretation mode.
		Removing the MFHILO_DELAY and instruction delay stuff, because
		they wouldn't work with dyntrans anyway.
20060617	Some documentation updates (adding "NetBSD-archive" to some
		URLs, and new Debian/DECstation installation screenshots).
		Removing the "tracenull" and "enable-caches" configure options.
		Improving MIPS dyntrans performance somewhat (only invalidate
		translations if necessary, on writes to the entryhi register,
		instead of doing it for all cop0 writes).
20060618	More cleanup after the removal of the old MIPS emulation.
		Trying to fix the MIPS dyntrans performance bugs/bottlenecks;
		only semi-successful so far (for R3000).
20060620	Minor update to allow clean compilation again on Tru64/Alpha.
20060622	MIPS cleanup and fixes (removing the pc_last stuff, which
		doesn't make sense with dyntrans anyway, and fixing a cross-
		page-delay-slot-with-exception case in end_of_page).
		Removing the old max_random_cycles_per_chunk stuff, and the
		concept of cycles vs instructions for MIPS emulation.
		FINALLY found and fixed the bug which caused NetBSD/pmax
		clocks to behave strangely (it was a load to the zero register,
		which was treated as a NOP; now it is treated as a load to a
		dummy scratch register).
20060623	Increasing the dyntrans chunk size back to
		N_SAFE_DYNTRANS_LIMIT, instead of N_SAFE_DYNTRANS_LIMIT/2.
		Preparing for a quick release, even though there are known
		bugs, and performance for non-R3000 MIPS emulation is very
		poor. :-/
		Reverting to half the dyntrans chunk size again, because
		NetBSD/cats seemed less stable with full size chunks. :(
		NetBSD/sgimips 3.0 can now run :-)  (With release 0.3.8, only
		NetBSD/sgimips 2.1 worked, not 3.0.)

==============  RELEASE 0.4.0  ==============


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

  ViewVC Help
Powered by ViewVC 1.1.26