/[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 32 - (show annotations)
Mon Oct 8 16:20:58 2007 UTC (16 years, 6 months ago) by dpavlin
File MIME type: text/plain
File size: 20458 byte(s)
++ trunk/HISTORY	(local)
$Id: HISTORY,v 1.1421 2006/11/06 05:32:37 debug Exp $
20060816	Adding a framework for emulated/virtual timers (src/timer.c),
		using only setitimer().
		Rewriting the mc146818 to use the new timer framework.
20060817	Adding a call to gettimeofday() every now and then (once every
		second, at the moment) to resynch the timer if it drifts.
		Beginning to convert the ISA timer interrupt mechanism (8253
		and 8259) to use the new timer framework.
		Removing the -I command line option.
20060819	Adding the -I command line option again, with new semantics.
		Working on Footbridge timer interrupts; NetBSD/NetWinder and
		NetBSD/CATS now run at correct speed, but unfortunately with
		HUGE delays during bootup.
20060821	Some minor m68k updates. Adding the first instruction: nop. :)
		Minor Alpha emulation updates.
20060822	Adding a FreeBSD development specific YAMON environment
		variable ("khz") (as suggested by Bruce M. Simpson).
		Moving YAMON environment variable initialization from
		machine_evbmips.c into promemul/yamon.c, and adding some more
		variables.
		Continuing on the LCA PCI bus controller (for Alpha machines).
20060823	Continuing on the timer stuff: experimenting with MIPS count/
		compare interrupts connected to the timer framework.
20060825	Adding bogus SCSI commands 0x51 (SCSICDROM_READ_DISCINFO) and
		0x52 (SCSICDROM_READ_TRACKINFO) to the SCSI emulation layer,
		to allow NetBSD/pmax 4.0_BETA to be installed from CDROM.
		Minor updates to the LCA PCI controller.
20060827	Implementing a CHIP8 cpu mode, and a corresponding CHIP8
		machine, for fun. Disassembly support for all instructions,
		and most of the common instructions have been implemented: mvi,
		mov_imm, add_imm, jmp, rand, cls, sprite, skeq_imm, jsr,
		skne_imm, bcd, rts, ldr, str, mov, or, and, xor, add, sub,
		font, ssound, sdelay, gdelay, bogus skup/skpr, skeq, skne.
20060828	Beginning to convert the CHIP8 cpu in the CHIP8 machine to a
		(more correct) RCA 180x cpu. (Disassembly for all 1802
		instructions has been implemented, but no execution yet, and
		no 1805 extended instructions.)
20060829	Minor Alpha emulation updates.
20060830	Beginning to experiment a little with PCI IDE for SGI O2.
		Fixing the cursor key mappings for MobilePro 770 emulation.
		Fixing the LK201 warning caused by recent NetBSD/pmax.
		The MIPS R41xx standby, suspend, and hibernate instructions now
		behave like the RM52xx/MIPS32/MIPS64 wait instruction.
		Fixing dev_wdc so it calculates correct (64-bit) offsets before
		giving them to diskimage_access().
20060831	Continuing on Alpha emulation (OSF1 PALcode).
20060901	Minor Alpha updates; beginning on virtual memory pagetables.
		Removed the limit for max nr of devices (in preparation for
		allowing devices' base addresses to be changed during runtime).
		Adding a hack for MIPS [d]mfc0 select 0 (except the count
		register), so that the coproc register is simply copied.
		The MIPS suspend instruction now exits the emulator, instead
		of being treated as a wait instruction (this causes NetBSD/
		hpcmips to get correct 'halt' behavior).
		The VR41xx RTC now returns correct time.
		Connecting the VR41xx timer to the timer framework (fixed at
		128 Hz, for now).
		Continuing on SPARC emulation, adding more instructions:
		restore, ba_xcc, ble. The rectangle drawing demo works :)
		Removing the last traces of the old ENABLE_CACHE_EMULATION
		MIPS stuff (not usable with dyntrans anyway).
20060902	Splitting up src/net.c into several smaller files in its own
		subdirectory (src/net/).
20060903	Cleanup of the files in src/net/, to make them less ugly.
20060904	Continuing on the 'settings' subsystem.
		Minor progress on the SPARC emulation mode.
20060905	Cleanup of various things, and connecting the settings
		infrastructure to various subsystems (emul, machine, cpu, etc).
		Changing the lk201 mouse update routine to not rely on any
		emulated hardware framebuffer cursor coordinates, but instead
		always do (semi-usable) relative movements.
20060906	Continuing on the lk201 mouse stuff. Mouse behaviour with
		multiple framebuffers (which was working in Ultrix) is now
		semi-broken (but it still works, in a way).
		Moving the documentation about networking into its own file
		(networking.html), and refreshing it a bit. Adding an example
		of how to use ethernet frame direct-access (udp_snoop).
20060907	Continuing on the settings infrastructure.
20060908	Minor updates to SH emulation: for 32-bit emulation: delay
		slots and the 'jsr @Rn' instruction. I'm putting 64-bit SH5 on
		ice, for now.
20060909-10	Implementing some more 32-bit SH instructions. Removing the
		64-bit mode completely. Enough has now been implemented to run
		the rectangle drawing demo. :-)
20060912	Adding more SH instructions.
20060916	Continuing on SH emulation (some more instructions: div0u,
		div1, rotcl/rotcr, more mov instructions, dt, braf, sets, sett,
		tst_imm, dmuls.l, subc, ldc_rm_vbr, movt, clrt, clrs, clrmac).
		Continuing on the settings subsystem (beginning on reading/
		writing settings, removing bugs, and connecting more cpus to
		the framework).
20060919	More work on SH emulation; adding an ldc banked instruction,
		and attaching a 640x480 framebuffer to the Dreamcast machine
		mode (NetBSD/dreamcast prints the NetBSD copyright banner :-),
		and then panics).
20060920	Continuing on the settings subsystem.
20060921	Fixing the Footbridge timer stuff so that NetBSD/cats and
		NetBSD/netwinder boot up without the delays.
20060922	Temporarily hardcoding MIPS timer interrupt to 100 Hz. With
		'wait' support disabled, NetBSD/malta and Linux/malta run at
		correct speed.
20060923	Connecting dev_gt to the timer framework, so that NetBSD/cobalt
		runs at correct speed.
		Moving SH4-specific memory mapped registers into its own
		device (dev_sh4.c).
		Running with -N now prints "idling" instead of bogus nr of
		instrs/second (which isn't valid anyway) while idling.
20060924	Algor emulation should now run at correct speed.
		Adding disassembly support for some MIPS64 revision 2
		instructions: ext, dext, dextm, dextu.
20060926	The timer framework now works also when the MIPS wait
		instruction is used.
20060928	Re-implementing checks for coprocessor availability for MIPS
		cop0 instructions. (Thanks to Carl van Schaik for noticing the
		lack of cop0 availability checks.)
20060929	Implementing an instruction combination hack which treats
		NetBSD/pmax' idle loop as a wait-like instruction.
20060930	The ENTRYHI_R_MASK was missing in (at least) memory_mips_v2p.c,
		causing TLB lookups to sometimes succeed when they should have
		failed. (A big thank you to Juli Mallett for noticing the
		problem.)
		Adding disassembly support for more MIPS64 revision 2 opcodes
		(seb, seh, wsbh, jalr.hb, jr.hb, synci, ins, dins, dinsu,
		dinsm, dsbh, dshd, ror, dror, rorv, drorv, dror32). Also
		implementing seb, seh, dsbh, dshd, and wsbh.
		Implementing an instruction combination hack for Linux/pmax'
		idle loop, similar to the NetBSD/pmax case.
20061001	Changing the NetBSD/sgimips install instructions to extract
		files from an iso image, instead of downloading them via ftp.
20061002	More-than-31-bit userland addresses in memory_mips_v2p.c were
		not actually working; applying a fix from Carl van Schaik to
		enable them to work + making some other updates (adding kuseg
		support).
		Fixing hpcmips (vr41xx) timer initialization.
		Experimenting with O(n)->O(1) reduction in the MIPS TLB lookup
		loop. Seems to work both for R3000 and non-R3000.
20061003	Continuing a little on SH emulation (adding more control
		registers; mini-cleanup of memory_sh.c).
20061004	Beginning on a dev_rtc, a clock/timer device for the test
		machines; also adding a demo, and some documentation.
		Fixing a bug in SH "mov.w @(disp,pc),Rn" (the result wasn't
		sign-extended), and adding the addc and ldtlb instructions.
20061005	Contining on SH emulation: virtual to physical address
		translation, and a skeleton exception mechanism.
20061006	Adding more SH instructions (various loads and stores, rte,
		negc, muls.w, various privileged register-move instructions).
20061007	More SH instructions: various move instructions, trapa, div0s,
		float, fdiv, ftrc.
		Continuing on dev_rtc; removing the rtc demo.
20061008	Adding a dummy Dreamcast PROM module. (Homebrew Dreamcast
		programs using KOS libs need this.)
		Adding more SH instructions: "stc vbr,rn", rotl, rotr, fsca,
		fmul, fadd, various floating-point moves, etc. A 256-byte
		demo for Dreamcast runs :-)
20061012	Adding the SH "lds Rm,pr" and bsr instructions.
20061013	More SH instructions: "sts fpscr,rn", tas.b, and some more
		floating point instructions, cmp/str, and more moves.
		Adding a dummy dev_pvr (Dreamcast graphics controller).
20061014	Generalizing the expression evaluator (used in the built-in
		debugger) to support parentheses and +-*/%^&|.
20061015	Removing the experimental tlb index hint code in
		mips_memory_v2p.c, since it didn't really have any effect.
20061017	Minor SH updates; adding the "sts pr,Rn", fcmp/gt, fneg,
		frchg, and some other instructions. Fixing missing sign-
		extension in an 8-bit load instruction.
20061019	Adding a simple dev_dreamcast_rtc.
		Implementing memory-mapped access to the SH ITLB/UTLB arrays.
20061021	Continuing on various SH and Dreamcast things: sh4 timers,
		debug messages for dev_pvr, fixing some virtual address
		translation bugs, adding the bsrf instruction.
		The NetBSD/dreamcast GENERIC_MD kernel now reaches userland :)
		Adding a dummy dev_dreamcast_asic.c (not really useful yet).
		Implementing simple support for Store Queues.
		Beginning on the PVR Tile Accelerator.
20061022	Generalizing the PVR framebuffer to support off-screen drawing,
		multiple bit-depths, etc. (A small speed penalty, but most
		likely worth it.)
		Adding more SH instructions (mulu.w, fcmp/eq, fsub, fmac,
		fschg, and some more); correcting bugs in "fsca" and "float".
20061024	Adding the SH ftrv (matrix * vector) instruction. Marcus
		Comstedt's "tatest" example runs :) (wireframe only).
		Correcting disassembly for SH floating point instructions that
		use the xd* registers.
		Adding the SH fsts instruction.
		In memory_device_dyntrans_access(), only the currently used
		range is now invalidated, and not the entire device range.
20061025	Adding a dummy AVR32 cpu mode skeleton.
20061026	Various Dreamcast updates; beginning on a Maple bus controller.
20061027	Continuing on the Maple bus. A bogus Controller, Keyboard, and
		Mouse can now be detected by NetBSD and KOS homebrew programs.
		Cleaning up the SH4 Timer Management Unit, and beginning on
		SH4 interrupts.
		Implementing the Dreamcast SYSASIC.
20061028	Continuing on the SYSASIC.
		Adding the SH fsqrt instruction.
		memory_sh.c now actually scans the ITLB.
		Fixing a bug in dev_sh4.c, related to associative writes into
		the memory-mapped UTLB array. NetBSD/dreamcast now reaches
		userland stably, and prints the "Terminal type?" message :-]
		Implementing enough of the Dreamcast keyboard to make NetBSD
		accept it for input.
		Enabling SuperH for stable (non-development) builds.
		Adding NetBSD/dreamcast to the documentation, although it
		doesn't support root-on-nfs yet.
20061029	Changing usleep(1) calls in the debugger to to usleep(10000)
		(according to Brian Foley, this makes GXemul run better on
		MacOS X).
		Making the Maple "Controller" do something (enough to barely
		interact with dcircus.elf).
20061030-31	Some progress on the PVR. More test programs start running (but
		with strange output).
		Various other SH4-related updates.
20061102	Various Dreamcast and SH4 updates; more KOS demos run now.
20061104	Adding a skeleton dev_mb8696x.c (the Dreamcast's LAN adapter).
20061105	Continuing on the MB8696x; NetBSD/dreamcast detects it as mbe0.
		Testing for the release.

==============  RELEASE 0.4.3  ==============


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

  ViewVC Help
Powered by ViewVC 1.1.26