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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 34 - (hide annotations)
Mon Oct 8 16:21:17 2007 UTC (16 years, 6 months ago) by dpavlin
File MIME type: text/plain
File size: 32915 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 dpavlin 22 /*
2 dpavlin 34 * Copyright (C) 2003-2007 Anders Gavare. All rights reserved.
3 dpavlin 22 *
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 34 * $Id: machine_pmax.c,v 1.23 2007/02/18 09:19:48 debug Exp $
29 dpavlin 24 *
30     * DECstation ("PMAX") machine description.
31 dpavlin 22 */
32    
33     #include <stdio.h>
34     #include <stdlib.h>
35     #include <string.h>
36    
37     #include "cpu.h"
38     #include "device.h"
39     #include "devices.h"
40     #include "diskimage.h"
41     #include "machine.h"
42     #include "memory.h"
43     #include "misc.h"
44    
45     #include "dec_prom.h"
46     #include "dec_bootinfo.h"
47     #include "dec_5100.h"
48     #include "dec_kn01.h"
49     #include "dec_kn02.h"
50     #include "dec_kn03.h"
51     #include "dec_kmin.h"
52     #include "dec_maxine.h"
53    
54     #define BOOTARG_BUFLEN 2000
55    
56    
57     MACHINE_SETUP(pmax)
58     {
59     char *framebuffer_console_name, *serial_console_name, *init_bootpath;
60     int color_fb_flag, i;
61     int boot_scsi_boardnumber = 3, boot_net_boardnumber = 3;
62     char *turbochannel_default_gfx_card = "PMAG-BA";
63     /* PMAG-AA, -BA, -CA/DA/EA/FA, -JA, -RO, PMAGB-BA */
64     struct xx {
65     struct btinfo_magic a;
66     struct btinfo_bootpath b;
67     struct btinfo_symtab c;
68     } xx;
69     char tmpstr[1000];
70     struct vfb_data *fb;
71     struct memory *mem = machine->memory;
72     uint64_t addr;
73    
74     cpu->byte_order = EMUL_LITTLE_ENDIAN;
75    
76 dpavlin 34 /*
77     * Add an R2020 or R3220 writeback memory thing:
78     */
79 dpavlin 22 cpu->cd.mips.coproc[3] = mips_coproc_new(cpu, 3);
80    
81     /* There aren't really any good standard values... */
82     framebuffer_console_name = "osconsole=0,3";
83     serial_console_name = "osconsole=1";
84    
85     switch (machine->machine_subtype) {
86    
87     case MACHINE_DEC_PMAX_3100: /* type 1, KN01 */
88     /* Supposed to have 12MHz or 16.67MHz R2000 CPU, R2010 FPC,
89     R2020 Memory coprocessor */
90     machine->machine_name = "DEC PMAX 3100 (KN01)";
91    
92     /* 12 MHz for 2100, 16.67 MHz for 3100 */
93     if (machine->emulated_hz == 0)
94     machine->emulated_hz = 16670000;
95    
96     if (machine->physical_ram_in_mb > 24)
97     fprintf(stderr, "WARNING! Real DECstation 3100 machines"
98     " cannot have more than 24MB RAM.\n");
99    
100     if ((machine->physical_ram_in_mb % 4) != 0)
101     fprintf(stderr, "WARNING! Real DECstation 3100 machines"
102     " have an integer multiple of 4 MBs of RAM.\n");
103    
104     /* 1 for color, 0 for mono. TODO: command line option? */
105     color_fb_flag = 1;
106    
107     /*
108     * According to NetBSD/pmax:
109     *
110     * pm0 at ibus0 addr 0xfc00000: 1024x864x1 (or x8 for color)
111     * dc0 at ibus0 addr 0x1c000000
112     * le0 at ibus0 addr 0x18000000: address 00:00:00:00:00:00
113     * sii0 at ibus0 addr 0x1a000000
114     * mcclock0 at ibus0 addr 0x1d000000: mc146818 or compatible
115     * 0x1e000000 = system status and control register
116     */
117     fb = dev_fb_init(machine, mem, KN01_PHYS_FBUF_START,
118     color_fb_flag? VFB_DEC_VFB02 : VFB_DEC_VFB01,
119     0,0,0,0,0, color_fb_flag? "VFB02":"VFB01");
120     dev_colorplanemask_init(mem, KN01_PHYS_COLMASK_START,
121     &fb->color_plane_mask);
122     dev_vdac_init(mem, KN01_SYS_VDAC, fb->rgb_palette,
123     color_fb_flag);
124 dpavlin 34
125     snprintf(tmpstr, sizeof(tmpstr), "%s.cpu[%i].%i",
126     machine->path, machine->bootstrap_cpu, KN01_INT_LANCE);
127 dpavlin 22 dev_le_init(machine, mem, KN01_SYS_LANCE,
128     KN01_SYS_LANCE_B_START, KN01_SYS_LANCE_B_END,
129 dpavlin 34 tmpstr, 4*1048576);
130    
131     snprintf(tmpstr, sizeof(tmpstr), "%s.cpu[%i].%i",
132     machine->path, machine->bootstrap_cpu, KN01_INT_SII);
133 dpavlin 22 dev_sii_init(machine, mem, KN01_SYS_SII, KN01_SYS_SII_B_START,
134 dpavlin 34 KN01_SYS_SII_B_END, tmpstr);
135    
136     snprintf(tmpstr, sizeof(tmpstr), "%s.cpu[%i].%i",
137     machine->path, machine->bootstrap_cpu, KN01_INT_DZ);
138     dev_dc7085_init(machine, mem, KN01_SYS_DZ, tmpstr,
139 dpavlin 22 machine->use_x11);
140 dpavlin 34
141     snprintf(tmpstr, sizeof(tmpstr), "%s.cpu[%i].%i",
142     machine->path, machine->bootstrap_cpu, KN01_INT_CLOCK);
143     dev_mc146818_init(machine, mem, KN01_SYS_CLOCK, tmpstr,
144 dpavlin 22 MC146818_DEC, 1);
145    
146 dpavlin 34 dev_kn01_init(mem, KN01_SYS_CSR, color_fb_flag);
147    
148 dpavlin 22 framebuffer_console_name = "osconsole=0,3"; /* fb,keyb */
149     serial_console_name = "osconsole=3"; /* 3 */
150     break;
151    
152     case MACHINE_DEC_3MAX_5000: /* type 2, KN02 */
153     /* Supposed to have 25MHz R3000 CPU, R3010 FPC, */
154     /* and a R3220 Memory coprocessor */
155     machine->machine_name = "DECstation 5000/200 (3MAX, KN02)";
156     machine->stable = 1;
157    
158     if (machine->emulated_hz == 0)
159     machine->emulated_hz = 25000000;
160    
161     if (machine->physical_ram_in_mb < 8)
162     fprintf(stderr, "WARNING! Real KN02 machines do not "
163     "have less than 8MB RAM. Continuing anyway.\n");
164     if (machine->physical_ram_in_mb > 480)
165     fprintf(stderr, "WARNING! Real KN02 machines cannot "
166     "have more than 480MB RAM. Continuing anyway.\n");
167    
168     /* An R3220 memory thingy: */
169     cpu->cd.mips.coproc[3] = mips_coproc_new(cpu, 3);
170    
171     /*
172     * According to NetBSD/pmax:
173     * asc0 at tc0 slot 5 offset 0x0
174     * le0 at tc0 slot 6 offset 0x0
175     * ibus0 at tc0 slot 7 offset 0x0
176     * dc0 at ibus0 addr 0x1fe00000
177     * mcclock0 at ibus0 addr 0x1fe80000: mc146818
178     */
179    
180 dpavlin 34 /* KN02 mainbus (TurboChannel interrupt controller): */
181     snprintf(tmpstr, sizeof(tmpstr), "kn02 addr=0x%x "
182     "irq=%s.cpu[%i].2", (int) KN02_SYS_CSR,
183     machine->path, machine->bootstrap_cpu);
184     device_add(machine, tmpstr);
185 dpavlin 22
186     /*
187 dpavlin 34 * TURBOchannel slots 0, 1, and 2 are free for option cards.
188     * Let's put in zero or more graphics boards:
189 dpavlin 22 *
190 dpavlin 34 * TODO: It's also possible to have larger graphics cards that
191     * occupy several slots. How should this be solved nicely?
192 dpavlin 22 */
193 dpavlin 34
194     snprintf(tmpstr, sizeof(tmpstr), "%s.cpu[%i].2.kn02.%i",
195     machine->path, machine->bootstrap_cpu, 0);
196 dpavlin 22 dev_turbochannel_init(machine, mem, 0,
197     KN02_PHYS_TC_0_START, KN02_PHYS_TC_0_END,
198     machine->n_gfx_cards >= 1?
199     turbochannel_default_gfx_card : "",
200 dpavlin 34 tmpstr);
201 dpavlin 22
202 dpavlin 34 snprintf(tmpstr, sizeof(tmpstr), "%s.cpu[%i].2.kn02.%i",
203     machine->path, machine->bootstrap_cpu, 1);
204 dpavlin 22 dev_turbochannel_init(machine, mem, 1,
205     KN02_PHYS_TC_1_START, KN02_PHYS_TC_1_END,
206     machine->n_gfx_cards >= 2?
207     turbochannel_default_gfx_card : "",
208 dpavlin 34 tmpstr);
209 dpavlin 22
210 dpavlin 34 snprintf(tmpstr, sizeof(tmpstr), "%s.cpu[%i].2.kn02.%i",
211     machine->path, machine->bootstrap_cpu, 2);
212 dpavlin 22 dev_turbochannel_init(machine, mem, 2,
213     KN02_PHYS_TC_2_START, KN02_PHYS_TC_2_END,
214     machine->n_gfx_cards >= 3?
215     turbochannel_default_gfx_card : "",
216 dpavlin 34 tmpstr);
217 dpavlin 22
218     /* TURBOchannel slots 3 and 4 are reserved. */
219    
220     /* TURBOchannel slot 5 is PMAZ-AA ("asc" SCSI). */
221 dpavlin 34 snprintf(tmpstr, sizeof(tmpstr), "%s.cpu[%i].2.kn02.%i",
222     machine->path, machine->bootstrap_cpu, 5);
223 dpavlin 22 dev_turbochannel_init(machine, mem, 5,
224     KN02_PHYS_TC_5_START, KN02_PHYS_TC_5_END,
225 dpavlin 34 "PMAZ-AA", tmpstr);
226 dpavlin 22
227     /* TURBOchannel slot 6 is PMAD-AA ("le" ethernet). */
228 dpavlin 34 snprintf(tmpstr, sizeof(tmpstr), "%s.cpu[%i].2.kn02.%i",
229     machine->path, machine->bootstrap_cpu, 6);
230 dpavlin 22 dev_turbochannel_init(machine, mem, 6,
231     KN02_PHYS_TC_6_START, KN02_PHYS_TC_6_END,
232 dpavlin 34 "PMAD-AA", tmpstr);
233 dpavlin 22
234     /* TURBOchannel slot 7 is system stuff. */
235 dpavlin 34 snprintf(tmpstr, sizeof(tmpstr), "%s.cpu[%i].2.kn02.%i",
236     machine->path, machine->bootstrap_cpu, 7);
237 dpavlin 22 machine->main_console_handle =
238     dev_dc7085_init(machine, mem,
239 dpavlin 34 KN02_SYS_DZ, tmpstr, machine->use_x11);
240    
241     snprintf(tmpstr, sizeof(tmpstr), "%s.cpu[%i].%i",
242     machine->path, machine->bootstrap_cpu, KN02_INT_CLOCK);
243 dpavlin 22 dev_mc146818_init(machine, mem,
244 dpavlin 34 KN02_SYS_CLOCK, tmpstr, MC146818_DEC, 1);
245 dpavlin 22
246     framebuffer_console_name = "osconsole=0,7";
247     /* fb,keyb */
248     serial_console_name = "osconsole=2";
249     boot_scsi_boardnumber = 5;
250     boot_net_boardnumber = 6; /* TODO: 3? */
251     break;
252    
253     case MACHINE_DEC_3MIN_5000: /* type 3, KN02BA */
254     machine->machine_name = "DECstation 5000/112 or 145 (3MIN,"
255     " KN02BA)";
256     if (machine->emulated_hz == 0)
257     machine->emulated_hz = 33000000;
258     if (machine->physical_ram_in_mb > 128)
259     fprintf(stderr, "WARNING! Real 3MIN machines cannot "
260     "have more than 128MB RAM. Continuing anyway.\n");
261    
262     /* KMIN interrupts: */
263 dpavlin 34 fatal("TODO: Legacy rewrite\n");
264     abort();
265     // machine->md_interrupt = kmin_interrupt;
266 dpavlin 22
267     /*
268 dpavlin 24 * tc0 at mainbus0: 12.5 MHz clock (0x10000000,slotsize=64MB)
269 dpavlin 22 * tc slot 1: 0x14000000
270     * tc slot 2: 0x18000000
271 dpavlin 24 * ioasic0 at tc0 slot 3 offset 0x0 (0x1c000000) slot 0
272     * asic regs (0x1c040000) slot 1
273     * station's ether address (0x1c080000) slot 2
274     * le0 at ioasic0 offset 0xc0000: address 00:00:00:00:00:00
275     * (0x1c0c0000) slot 3
276     * scc0 at ioasic0 offset 0x100000 (0x1c100000) slot 4
277     * scc1 at ioasic0 offset 0x180000: console(0x1c180000) slot 6
278     * mcclock0 at ioasic0 offset 0x200000: mc146818 or
279     * compatible (0x1c200000) slot 8
280     * asc0 at ioasic0 offset 0x300000: NCR53C94, 25MHz,
281     * SCSI ID 7 (0x1c300000) slot 12
282     * dma for asc0 (0x1c380000) slot 14
283 dpavlin 22 */
284 dpavlin 34 fatal("TODO: dec_ioasic legacy rewrite\n");
285     abort();
286     // machine->md_int.dec_ioasic_data = dev_dec_ioasic_init(cpu,
287     // mem, 0x1c000000, 0);
288     fatal("TODO: kmin dev_le_init.\n");
289     abort();
290     // dev_le_init(machine, mem, 0x1c0c0000, 0, 0,
291     // KMIN_INTR_LANCE + 8, 4 * 65536);
292 dpavlin 24 dev_scc_init(machine, mem, 0x1c100000, KMIN_INTR_SCC_0 + 8,
293     machine->use_x11, 0, 1);
294     dev_scc_init(machine, mem, 0x1c180000, KMIN_INTR_SCC_1 + 8,
295     machine->use_x11, 1, 1);
296 dpavlin 34 fatal("TODO: mc146818 irq\n");
297     abort();
298     // dev_mc146818_init(machine, mem, 0x1c200000,
299     //KMIN_INTR_CLOCK + 8,
300     // MC146818_DEC, 1);
301     fatal("TODO: kmin asc init\n");
302     abort();
303     // dev_asc_init(machine, mem, 0x1c300000, KMIN_INTR_SCSI +8,
304     // NULL, DEV_ASC_DEC, NULL, NULL);
305 dpavlin 22
306     /*
307     * TURBOchannel slots 0, 1, and 2 are free for
308     * option cards. These are by default filled with
309     * zero or more graphics boards.
310     *
311     * TODO: irqs
312     */
313 dpavlin 34 fatal("TODO: turbochannel init rewrite!\n");
314     abort();
315     #if 0
316 dpavlin 22 dev_turbochannel_init(machine, mem, 0, 0x10000000, 0x103fffff,
317     machine->n_gfx_cards >= 1?
318     turbochannel_default_gfx_card : "", KMIN_INT_TC0);
319    
320     dev_turbochannel_init(machine, mem, 1, 0x14000000, 0x143fffff,
321     machine->n_gfx_cards >= 2?
322     turbochannel_default_gfx_card : "", KMIN_INT_TC1);
323    
324     dev_turbochannel_init(machine, mem, 2, 0x18000000, 0x183fffff,
325     machine->n_gfx_cards >= 3?
326     turbochannel_default_gfx_card : "", KMIN_INT_TC2);
327 dpavlin 34 #endif
328 dpavlin 24 /* (kmin shared irq numbers (IP) are offset by +8 in the
329     emulator) */
330 dpavlin 22 /* kmin_csr = dev_kmin_init(cpu, mem, KMIN_REG_INTR); */
331    
332 dpavlin 24 framebuffer_console_name = "osconsole=0,3"; /* fb,keyb(?) */
333     serial_console_name = "osconsole=3"; /* ? */
334 dpavlin 22 break;
335    
336     case MACHINE_DEC_3MAXPLUS_5000: /* type 4, KN03 */
337     machine->machine_name = "DECsystem 5900 or 5000 (3MAX+) (KN03)";
338    
339     /* 5000/240 (KN03-GA, R3000): 40 MHz */
340     /* 5000/260 (KN05-NB, R4000): 60 MHz */
341     /* TODO: are both these type 4? */
342     if (machine->emulated_hz == 0)
343     machine->emulated_hz = 40000000;
344     if (machine->physical_ram_in_mb > 480)
345     fprintf(stderr, "WARNING! Real KN03 machines cannot "
346     "have more than 480MB RAM. Continuing anyway.\n");
347    
348     /* KN03 interrupts: */
349 dpavlin 34 fatal("TODO: Legacy rewrite\n");
350     abort();
351     // machine->md_interrupt = kn03_interrupt;
352 dpavlin 22
353     /*
354 dpavlin 24 * tc0 at mainbus0: 25 MHz clock (slot 0) (0x1e000000)
355     * tc0 slot 1 (0x1e800000)
356     * tc0 slot 2 (0x1f000000)
357     * ioasic0 at tc0 slot 3 offset 0x0 (0x1f800000)
358     * something that has to do with interrupts? (?)(0x1f840000?)
359     * le0 at ioasic0 offset 0xc0000 (0x1f8c0000)
360     * scc0 at ioasic0 offset 0x100000 (0x1f900000)
361     * scc1 at ioasic0 offset 0x180000: console (0x1f980000)
362     * mcclock0 at ioasic0 offset 0x200000: mc146818 or
363     * compatible (0x1fa00000)
364     * asc0 at ioasic0 offset 0x300000: NCR53C94, 25MHz,
365     * SCSI ID 7 (0x1fb00000)
366 dpavlin 22 */
367 dpavlin 34 fatal("TODO: dec_ioasic legacy rewrite\n");
368     abort();
369     // machine->md_int.dec_ioasic_data = dev_dec_ioasic_init(cpu,
370     // mem, 0x1f800000, 0);
371 dpavlin 22
372 dpavlin 34 fatal("TODO: kn03 dev_le_init rewrite\n");
373     abort();
374     // dev_le_init(machine, mem, KN03_SYS_LANCE, 0, 0,
375     // KN03_INTR_LANCE +8, 4 * 65536);
376 dpavlin 22
377 dpavlin 34 fatal("TODO: dec_ioasic legacy rewrite\n");
378     abort();
379     // machine->md_int.dec_ioasic_data->dma_func[3] =
380     // dev_scc_dma_func;
381     // machine->md_int.dec_ioasic_data->dma_func_extra[2] =
382     // dev_scc_init(machine, mem, KN03_SYS_SCC_0,
383     // KN03_INTR_SCC_0 +8, machine->use_x11, 0, 1);
384     // machine->md_int.dec_ioasic_data->dma_func[2] =
385     // dev_scc_dma_func;
386     // machine->md_int.dec_ioasic_data->dma_func_extra[3] =
387     // dev_scc_init(machine, mem, KN03_SYS_SCC_1,
388     // KN03_INTR_SCC_1 +8, machine->use_x11, 1, 1);
389 dpavlin 22
390 dpavlin 34 fatal("TODO: mc146818 irq\n");
391     abort();
392     // dev_mc146818_init(machine, mem, KN03_SYS_CLOCK, KN03_INT_RTC,
393     // MC146818_DEC, 1);
394     fatal("TODO: asc init rewrite\n");
395     abort();
396     // dev_asc_init(machine, mem, KN03_SYS_SCSI,
397     // KN03_INTR_SCSI +8, NULL, DEV_ASC_DEC, NULL, NULL);
398 dpavlin 22
399     /*
400     * TURBOchannel slots 0, 1, and 2 are free for
401     * option cards. These are by default filled with
402     * zero or more graphics boards.
403     *
404     * TODO: irqs
405     */
406 dpavlin 34 fatal("TODO: turbochannel rewrite init\n");
407     abort();
408     #if 0
409 dpavlin 22 dev_turbochannel_init(machine, mem, 0,
410     KN03_PHYS_TC_0_START, KN03_PHYS_TC_0_END,
411     machine->n_gfx_cards >= 1?
412     turbochannel_default_gfx_card : "",
413     KN03_INTR_TC_0 +8);
414    
415     dev_turbochannel_init(machine, mem, 1,
416     KN03_PHYS_TC_1_START, KN03_PHYS_TC_1_END,
417     machine->n_gfx_cards >= 2?
418     turbochannel_default_gfx_card : "",
419     KN03_INTR_TC_1 +8);
420    
421     dev_turbochannel_init(machine, mem, 2,
422     KN03_PHYS_TC_2_START, KN03_PHYS_TC_2_END,
423     machine->n_gfx_cards >= 3?
424     turbochannel_default_gfx_card : "",
425     KN03_INTR_TC_2 +8);
426 dpavlin 34 #endif
427 dpavlin 22
428     /* TODO: interrupts */
429     /* shared (turbochannel) interrupts are +8 */
430    
431 dpavlin 24 framebuffer_console_name = "osconsole=0,3"; /* fb,keyb(?) */
432     serial_console_name = "osconsole=3"; /* ? */
433 dpavlin 22 break;
434    
435     case MACHINE_DEC_5800: /* type 5, KN5800 */
436     machine->machine_name = "DECsystem 5800";
437    
438     /* TODO: this is incorrect, banks multiply by 8 etc */
439     if (machine->physical_ram_in_mb < 48)
440     fprintf(stderr, "WARNING! 5800 will probably not run "
441     "with less than 48MB RAM. Continuing anyway.\n");
442    
443     /*
444 dpavlin 24 * According to
445     * http://www2.no.netbsd.org/Ports/pmax/models.html,
446 dpavlin 22 * the 5800-series is based on VAX 6000/300.
447     */
448    
449     /*
450     * Ultrix might support SMP on this machine type.
451     *
452     * Something at 0x10000000.
453 dpavlin 24 * ssc serial console at 0x10140000, interrupt 2 (shared
454     * with XMI?).
455 dpavlin 22 * xmi 0 at address 0x11800000 (node x at offset x*0x80000)
456     * Clock uses interrupt 3 (shared with XMI?).
457     */
458    
459 dpavlin 34 device_add(machine, "dec5800 addr=0x10000000");
460     device_add(machine, "decbi addr=0x10000000");
461    
462     snprintf(tmpstr, sizeof(tmpstr), "%s.cpu[%i].dec5800.28",
463     machine->path, machine->bootstrap_cpu);
464     dev_ssc_init(machine, mem, 0x10140000,
465     tmpstr, machine->use_x11);
466    
467 dpavlin 22 dev_decxmi_init(mem, 0x11800000);
468     dev_deccca_init(mem, DEC_DECCCA_BASEADDR);
469    
470     break;
471    
472     case MACHINE_DEC_5400: /* type 6, KN210 */
473     machine->machine_name = "DECsystem 5400 (KN210)";
474     /*
475     * Misc. info from the KN210 manual:
476     *
477     * Interrupt lines:
478     * irq5 fpu
479     * irq4 halt
480     * irq3 pwrfl -> mer1 -> mer0 -> wear
481     * irq2 100 Hz -> birq7
482     * irq1 dssi -> ni -> birq6
483     * irq0 birq5 -> console -> timers -> birq4
484     *
485     * Interrupt status register at 0x10048000.
486     * Main memory error status register at 0x1008140.
487     * Interval Timer Register (ITR) at 0x10084010.
488     * Q22 stuff at 0x10088000 - 0x1008ffff.
489     * TODR at 0x1014006c.
490     * TCR0 (timer control register 0) 0x10140100.
491     * TIR0 (timer interval register 0) 0x10140104.
492     * TCR1 (timer control register 1) 0x10140110.
493     * TIR1 (timer interval register 1) 0x10140114.
494     * VRR0 (Vector Read Register 0) at 0x16000050.
495     * VRR1 (Vector Read Register 1) at 0x16000054.
496     * VRR2 (Vector Read Register 2) at 0x16000058.
497     * VRR3 (Vector Read Register 3) at 0x1600005c.
498     */
499     /* ln (ethernet) at 0x10084x00 ? and 0x10120000 ? */
500     /* error registers (?) at 0x17000000 and 0x10080000 */
501     device_add(machine, "kn210 addr=0x10080000");
502 dpavlin 34 dev_ssc_init(machine, mem, 0x10140000, "irq? TODO",
503     machine->use_x11);
504 dpavlin 22 break;
505    
506     case MACHINE_DEC_MAXINE_5000: /* type 7, KN02CA */
507     machine->machine_name = "Personal DECstation 5000/xxx "
508     "(MAXINE) (KN02CA)";
509     if (machine->emulated_hz == 0)
510     machine->emulated_hz = 33000000;
511    
512     if (machine->physical_ram_in_mb < 8)
513     fprintf(stderr, "WARNING! Real KN02CA machines do not "
514     "have less than 8MB RAM. Continuing anyway.\n");
515     if (machine->physical_ram_in_mb > 40)
516     fprintf(stderr, "WARNING! Real KN02CA machines cannot "
517     "have more than 40MB RAM. Continuing anyway.\n");
518    
519     /* Maxine interrupts: */
520 dpavlin 34 fatal("TODO: Legacy rewrite\n");
521     abort();
522 dpavlin 22
523 dpavlin 34 // machine->md_interrupt = maxine_interrupt;
524    
525 dpavlin 22 /*
526     * Something at address 0xca00000. (?)
527     * Something at address 0xe000000. (?)
528 dpavlin 24 * tc0 slot 0 (0x10000000)
529     * tc0 slot 1 (0x14000000)
530 dpavlin 22 * (tc0 slot 2 used by the framebuffer)
531 dpavlin 24 * ioasic0 at tc0 slot 3 offset 0x0 (0x1c000000)
532     * le0 at ioasic0 offset 0xc0000: address 00:00:00:00:00:00
533     * (0x1c0c0000)
534     * scc0 at ioasic0 offset 0x100000: console <-- serial
535     * (0x1c100000)
536     * mcclock0 at ioasic0 offset 0x200000: mc146818 (0x1c200000)
537     * isdn at ioasic0 offset 0x240000 not configured (0x1c240000)
538     * bba0 at ioasic0 offset 0x240000 (audio0 at bba0)
539     * ^--- which one of isdn and bba0?
540     * dtop0 at ioasic0 offset 0x280000 (0x1c280000)
541     * fdc at ioasic0 offset 0x2c0000 not configured
542     * ^-- floppy (0x1c2c0000)
543     * asc0 at ioasic0 offset 0x300000: NCR53C94, 25MHz, SCSI
544     * ID 7 (0x1c300000)
545     * xcfb0 at tc0 slot 2 offset 0x0: 1024x768x8
546     * built-in framebuffer (0xa000000)
547 dpavlin 22 */
548 dpavlin 34 fatal("TODO: dec_ioasic legacy rewrite\n");
549     abort();
550     // machine->md_int.dec_ioasic_data =
551     // dev_dec_ioasic_init(cpu, mem, 0x1c000000, 0);
552 dpavlin 22
553 dpavlin 34 fatal("TODO: turbochannel rewrite!\n");
554     abort();
555     #if 0
556 dpavlin 22 /* TURBOchannel slots (0 and 1): */
557     dev_turbochannel_init(machine, mem, 0,
558     0x10000000, 0x103fffff,
559     machine->n_gfx_cards >= 2?
560     turbochannel_default_gfx_card : "",
561     XINE_INTR_TC_0 +8);
562     dev_turbochannel_init(machine, mem, 1,
563     0x14000000, 0x143fffff,
564     machine->n_gfx_cards >= 3?
565     turbochannel_default_gfx_card : "",
566     XINE_INTR_TC_1 +8);
567    
568     /*
569     * TURBOchannel slot 2 is hardwired to be used by
570     * the framebuffer: (NOTE: 0x8000000, not 0x18000000)
571     */
572     dev_turbochannel_init(machine, mem, 2,
573     0x8000000, 0xbffffff, "PMAG-DV", 0);
574 dpavlin 34 #endif
575 dpavlin 22 /*
576     * TURBOchannel slot 3: fixed, ioasic
577     * (the system stuff), 0x1c000000
578     */
579 dpavlin 34 fatal("TODO: xine dev_le_init rewrite\n");
580     abort();
581     // dev_le_init(machine, mem, 0x1c0c0000, 0, 0,
582     // XINE_INTR_LANCE +8, 4*65536);
583 dpavlin 22 dev_scc_init(machine, mem, 0x1c100000,
584     XINE_INTR_SCC_0 +8, machine->use_x11, 0, 1);
585 dpavlin 34 fatal("TODO: mc146818 irq\n");
586     abort();
587     // dev_mc146818_init(machine, mem, 0x1c200000,
588     // XINE_INT_TOY, MC146818_DEC, 1);
589     fatal("TODO: xine asc init rewrite\n");
590     abort();
591     // dev_asc_init(machine, mem, 0x1c300000,
592     // XINE_INTR_SCSI +8, NULL, DEV_ASC_DEC, NULL, NULL);
593 dpavlin 22
594 dpavlin 24 framebuffer_console_name = "osconsole=3,2"; /* keyb,fb? */
595 dpavlin 22 serial_console_name = "osconsole=3";
596     break;
597    
598     case MACHINE_DEC_5500: /* type 11, KN220 */
599     machine->machine_name = "DECsystem 5500 (KN220)";
600    
601     /*
602     * According to NetBSD's pmax ports page:
603     * KN220-AA is a "30 MHz R3000 CPU with R3010 FPU"
604     * with "512 kBytes of Prestoserve battery backed RAM."
605     */
606     if (machine->emulated_hz == 0)
607     machine->emulated_hz = 30000000;
608    
609     /*
610     * See KN220 docs for more info.
611     *
612     * something at 0x10000000
613     * something at 0x10001000
614     * something at 0x10040000
615     * scc at 0x10140000
616     * qbus at (or around) 0x10080000
617 dpavlin 24 * dssi (disk controller) buffers at 0x10100000,
618     * registers at 0x10160000.
619     * sgec (ethernet) registers at 0x10008000, station
620     * addresss at 0x10120000.
621 dpavlin 22 * asc (scsi) at 0x17100000.
622     */
623    
624 dpavlin 34 dev_ssc_init(machine, mem, 0x10140000, "TODO: irq",
625     machine->use_x11);
626 dpavlin 22
627 dpavlin 24 /* something at 0x17000000, ultrix says "cpu 0 panic: "
628     "DS5500 I/O Board is missing" if this is not here */
629 dpavlin 22 dev_dec5500_ioboard_init(cpu, mem, 0x17000000);
630    
631     dev_sgec_init(mem, 0x10008000, 0); /* irq? */
632    
633     /* The asc controller might be TURBOchannel-ish? */
634     #if 0
635 dpavlin 24 dev_turbochannel_init(machine, mem, 0, 0x17100000,
636     0x171fffff, "PMAZ-AA", 0); /* irq? */
637 dpavlin 22 #else
638 dpavlin 24 dev_asc_init(machine, mem, 0x17100000, 0, NULL,
639     DEV_ASC_DEC, NULL, NULL); /* irq? */
640 dpavlin 22 #endif
641    
642     framebuffer_console_name = "osconsole=0,0"; /* TODO (?) */
643     serial_console_name = "osconsole=0";
644     break;
645    
646     case MACHINE_DEC_MIPSMATE_5100: /* type 12 */
647     machine->machine_name = "DEC MIPSMATE 5100 (KN230)";
648    
649     if (machine->emulated_hz == 0)
650     machine->emulated_hz = 20000000;
651    
652     if (machine->physical_ram_in_mb > 128)
653     fprintf(stderr, "WARNING! Real MIPSMATE 5100 machines "
654     "cannot have more than 128MB RAM. Continuing"
655     " anyway.\n");
656    
657     if (machine->use_x11)
658     fprintf(stderr, "WARNING! Real MIPSMATE 5100 machines "
659     "cannot have a graphical framebuffer. "
660     "Continuing anyway.\n");
661    
662 dpavlin 34 /* KN230 mainbus / interrupt controller: */
663     snprintf(tmpstr, sizeof(tmpstr),
664     "kn230 addr=0x%"PRIx64, (uint64_t) KN230_SYS_ICSR);
665     device_add(machine, tmpstr);
666 dpavlin 22
667     /*
668     * According to NetBSD/pmax:
669     * dc0 at ibus0 addr 0x1c000000
670     * le0 at ibus0 addr 0x18000000: address 00:00:00:00:00:00
671     * sii0 at ibus0 addr 0x1a000000
672     */
673 dpavlin 34
674     snprintf(tmpstr, sizeof(tmpstr), "%s.cpu[%i].%i",
675     machine->path, machine->bootstrap_cpu, 4);
676     dev_mc146818_init(machine, mem, KN230_SYS_CLOCK, tmpstr,
677 dpavlin 24 MC146818_DEC, 1);
678 dpavlin 34
679     snprintf(tmpstr, sizeof(tmpstr), "%s.cpu[%i].kn230.0x%x",
680     machine->path, machine->bootstrap_cpu, KN230_CSR_INTR_DZ0);
681 dpavlin 24 dev_dc7085_init(machine, mem, KN230_SYS_DZ0,
682 dpavlin 34 tmpstr, machine->use_x11);
683    
684 dpavlin 24 /* dev_dc7085_init(machine, mem, KN230_SYS_DZ1,
685 dpavlin 34 KN230_CSR_INTR_OPT0, machine->use_x11); */
686 dpavlin 24 /* dev_dc7085_init(machine, mem, KN230_SYS_DZ2,
687 dpavlin 34 KN230_CSR_INTR_OPT1, machine->use_x11); */
688    
689     snprintf(tmpstr, sizeof(tmpstr), "%s.cpu[%i].kn230.0x%x",
690     machine->path, machine->bootstrap_cpu,
691     KN230_CSR_INTR_LANCE);
692 dpavlin 24 dev_le_init(machine, mem, KN230_SYS_LANCE,
693     KN230_SYS_LANCE_B_START, KN230_SYS_LANCE_B_END,
694 dpavlin 34 tmpstr, 4*1048576);
695    
696     snprintf(tmpstr, sizeof(tmpstr), "%s.cpu[%i].kn230.0x%x",
697     machine->path, machine->bootstrap_cpu, KN230_CSR_INTR_SII);
698 dpavlin 24 dev_sii_init(machine, mem, KN230_SYS_SII,
699 dpavlin 34 KN230_SYS_SII_B_START, KN230_SYS_SII_B_END, tmpstr);
700 dpavlin 22
701     serial_console_name = "osconsole=0";
702     break;
703    
704     default:fatal("Unknown DEC machine type: %i\n",
705     machine->machine_subtype);
706     exit(1);
707     }
708    
709     /*
710     * Most OSes on DECstation use physical addresses below
711     * 0x20000000, but both OSF/1 and Sprite use 0xbe...... as if
712     * it was 0x1e......, so we need this hack:
713     */
714     dev_ram_init(machine, 0xa0000000, 0x20000000,
715     DEV_RAM_MIRROR | DEV_RAM_MIGHT_POINT_TO_DEVICES, 0x0);
716    
717     if (!machine->prom_emulation)
718     return;
719    
720    
721     /* DECstation PROM stuff: (TODO: endianness) */
722 dpavlin 24 for (i=0; i<150; i++)
723 dpavlin 22 store_32bit_word(cpu, DEC_PROM_CALLBACK_STRUCT + i*4,
724     DEC_PROM_EMULATION + i*8);
725    
726 dpavlin 24 /* Fill PROM with special "magic trap" instructions: */
727     for (i=0; i<150; i++) {
728 dpavlin 22 store_32bit_word(cpu, DEC_PROM_EMULATION + i*8,
729 dpavlin 24 0x00c0de0c); /* trap instruction */
730 dpavlin 22 store_32bit_word(cpu, DEC_PROM_EMULATION + i*8 + 4,
731     0x00000000); /* nop */
732     }
733    
734 dpavlin 24 /* Jumptable at beginning of PROM: also "magic trap" instructions: */
735     for (i=0; i<0x180; i+=8) {
736     store_32bit_word(cpu, 0xbfc00000 + i,
737     0x00c0de0c); /* trap instruction */
738     store_32bit_word(cpu, 0xbfc00000 + i + 4,
739     0x00000000); /* nop */
740     }
741    
742    
743 dpavlin 22 /*
744     * According to dec_prom.h from NetBSD:
745     *
746     * "Programs loaded by the new PROMs pass the following arguments:
747     * a0 argc
748     * a1 argv
749     * a2 DEC_PROM_MAGIC
750     * a3 The callback vector defined below"
751     *
752     * So we try to emulate a PROM, even though no such thing has been
753     * loaded.
754     */
755    
756     cpu->cd.mips.gpr[MIPS_GPR_A0] = 3;
757     cpu->cd.mips.gpr[MIPS_GPR_A1] = DEC_PROM_INITIAL_ARGV;
758     cpu->cd.mips.gpr[MIPS_GPR_A2] = DEC_PROM_MAGIC;
759     cpu->cd.mips.gpr[MIPS_GPR_A3] = DEC_PROM_CALLBACK_STRUCT;
760    
761     store_32bit_word(cpu, INITIAL_STACK_POINTER + 0x10, BOOTINFO_MAGIC);
762     store_32bit_word(cpu, INITIAL_STACK_POINTER + 0x14, BOOTINFO_ADDR);
763    
764     store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV,
765     (DEC_PROM_INITIAL_ARGV + 0x10));
766     store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV+4,
767     (DEC_PROM_INITIAL_ARGV + 0x70));
768     store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV+8,
769     (DEC_PROM_INITIAL_ARGV + 0xe0));
770     store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV+12, 0);
771    
772     /*
773     * NetBSD and Ultrix expect the boot args to be like this:
774     *
775     * "boot" "bootdev" [args?]
776     *
777     * where bootdev is supposed to be "rz(0,0,0)netbsd" for
778     * 3100/2100 (although that crashes Ultrix :-/), and
779     * "5/rz0a/netbsd" for all others. The number '5' is the
780     * slot number of the boot device.
781     *
782     * 'rz' for disks, 'tz' for tapes.
783     *
784     * TODO: Make this nicer.
785     */
786     {
787     char bootpath[200];
788     #if 0
789     if (machine->machine_subtype == MACHINE_DEC_PMAX_3100)
790     strlcpy(bootpath, "rz(0,0,0)", sizeof(bootpath));
791     else
792     #endif
793     strlcpy(bootpath, "5/rz1/", sizeof(bootpath));
794    
795     if (machine->bootdev_id < 0 || machine->force_netboot) {
796     /* tftp boot: */
797     strlcpy(bootpath, "5/tftp/", sizeof(bootpath));
798     bootpath[0] = '0' + boot_net_boardnumber;
799     } else {
800     /* disk boot: */
801     bootpath[0] = '0' + boot_scsi_boardnumber;
802     if (diskimage_is_a_tape(machine, machine->bootdev_id,
803     machine->bootdev_type))
804     bootpath[2] = 't';
805     bootpath[4] = '0' + machine->bootdev_id;
806     }
807    
808     init_bootpath = bootpath;
809     }
810    
811     machine->bootarg = malloc(BOOTARG_BUFLEN);
812     if (machine->bootarg == NULL) {
813     fprintf(stderr, "out of memory\n");
814     exit(1);
815     }
816     strlcpy(machine->bootarg, init_bootpath, BOOTARG_BUFLEN);
817     if (strlcat(machine->bootarg, machine->boot_kernel_filename,
818     BOOTARG_BUFLEN) > BOOTARG_BUFLEN) {
819     fprintf(stderr, "bootarg truncated?\n");
820     exit(1);
821     }
822    
823     machine->bootstr = "boot";
824    
825     store_string(cpu, DEC_PROM_INITIAL_ARGV+0x10, machine->bootstr);
826     store_string(cpu, DEC_PROM_INITIAL_ARGV+0x70, machine->bootarg);
827     store_string(cpu, DEC_PROM_INITIAL_ARGV+0xe0,
828     machine->boot_string_argument);
829    
830     /* Decrease the nr of args, if there are no args :-) */
831     if (machine->boot_string_argument == NULL ||
832     machine->boot_string_argument[0] == '\0')
833     cpu->cd.mips.gpr[MIPS_GPR_A0] --;
834    
835     if (machine->boot_string_argument[0] != '\0') {
836     strlcat(machine->bootarg, " ", BOOTARG_BUFLEN);
837     if (strlcat(machine->bootarg, machine->boot_string_argument,
838     BOOTARG_BUFLEN) >= BOOTARG_BUFLEN) {
839     fprintf(stderr, "bootstr truncated?\n");
840     exit(1);
841     }
842     }
843    
844     xx.a.common.next = (char *)&xx.b - (char *)&xx;
845     xx.a.common.type = BTINFO_MAGIC;
846     xx.a.magic = BOOTINFO_MAGIC;
847    
848     xx.b.common.next = (char *)&xx.c - (char *)&xx.b;
849     xx.b.common.type = BTINFO_BOOTPATH;
850     strlcpy(xx.b.bootpath, machine->bootstr, sizeof(xx.b.bootpath));
851    
852     xx.c.common.next = 0;
853     xx.c.common.type = BTINFO_SYMTAB;
854     xx.c.nsym = 0;
855     xx.c.ssym = 0;
856     xx.c.esym = machine->file_loaded_end_addr;
857    
858     store_buf(cpu, BOOTINFO_ADDR, (char *)&xx, sizeof(xx));
859    
860 dpavlin 24 /* The system's memmap: */
861     machine->md.pmax.memmap = malloc(sizeof(struct dec_memmap));
862     if (machine->md.pmax.memmap == NULL) {
863     fprintf(stderr, "out of memory\n");
864     exit(1);
865     }
866 dpavlin 22 store_32bit_word_in_host(cpu,
867 dpavlin 24 (unsigned char *)&machine->md.pmax.memmap->pagesize, 4096);
868 dpavlin 22 {
869     unsigned int i;
870 dpavlin 24 for (i=0; i<sizeof(machine->md.pmax.memmap->bitmap); i++)
871     machine->md.pmax.memmap->bitmap[i] = ((int)i * 4096*8 <
872 dpavlin 22 1048576*machine->physical_ram_in_mb)? 0xff : 0x00;
873     }
874 dpavlin 24 store_buf(cpu, DEC_MEMMAP_ADDR,
875     (char *)machine->md.pmax.memmap, sizeof(struct dec_memmap));
876 dpavlin 22
877     /* Environment variables: */
878     addr = DEC_PROM_STRINGS;
879    
880     if (machine->use_x11 && machine->n_gfx_cards > 0)
881     /* (0,3) Keyboard and Framebuffer */
882     add_environment_string(cpu, framebuffer_console_name, &addr);
883     else
884     /* Serial console */
885     add_environment_string(cpu, serial_console_name, &addr);
886    
887     /*
888     * The KN5800 (SMP system) uses a CCA (console communications
889     * area): (See VAX 6000 documentation for details.)
890     */
891     {
892     char tmps[300];
893 dpavlin 24 snprintf(tmps, sizeof(tmps), "cca=%"PRIx32,
894     (uint32_t) (DEC_DECCCA_BASEADDR + 0xa0000000ULL));
895 dpavlin 22 add_environment_string(cpu, tmps, &addr);
896     }
897    
898     /* These are needed for Sprite to boot: */
899     {
900     char tmps[500];
901    
902     snprintf(tmps, sizeof(tmps), "boot=%s", machine->bootarg);
903     tmps[sizeof(tmps)-1] = '\0';
904     add_environment_string(cpu, tmps, &addr);
905    
906 dpavlin 24 snprintf(tmps, sizeof(tmps), "bitmap=0x%"PRIx32, (uint32_t)
907     ( (DEC_MEMMAP_ADDR + sizeof(uint32_t) /* skip the
908     page size and point to the memmap */
909     ) & 0xffffffffULL) );
910 dpavlin 22 tmps[sizeof(tmps)-1] = '\0';
911     add_environment_string(cpu, tmps, &addr);
912    
913 dpavlin 24 snprintf(tmps, sizeof(tmps), "bitmaplen=0x%"PRIx32, (uint32_t)
914     ( machine->physical_ram_in_mb * 1048576 / 4096 / 8) );
915 dpavlin 22 tmps[sizeof(tmps)-1] = '\0';
916     add_environment_string(cpu, tmps, &addr);
917     }
918    
919     add_environment_string(cpu, "scsiid0=7", &addr);
920     add_environment_string(cpu, "bootmode=a", &addr);
921     add_environment_string(cpu, "testaction=q", &addr);
922     add_environment_string(cpu, "haltaction=h", &addr);
923     add_environment_string(cpu, "more=24", &addr);
924    
925     /* Used in at least Ultrix on the 5100: */
926     add_environment_string(cpu, "scsiid=7", &addr);
927     add_environment_string(cpu, "baud0=9600", &addr);
928     add_environment_string(cpu, "baud1=9600", &addr);
929     add_environment_string(cpu, "baud2=9600", &addr);
930     add_environment_string(cpu, "baud3=9600", &addr);
931     add_environment_string(cpu, "iooption=0x1", &addr);
932    
933     /* The end: */
934     add_environment_string(cpu, "", &addr);
935     }
936    
937    
938     MACHINE_DEFAULT_CPU(pmax)
939     {
940     if (machine->machine_subtype > 2)
941     machine->cpu_name = strdup("R3000A");
942    
943     if (machine->machine_subtype > 1 && machine->cpu_name == NULL)
944     machine->cpu_name = strdup("R3000");
945    
946     if (machine->cpu_name == NULL)
947     machine->cpu_name = strdup("R2000");
948     }
949    
950    
951     MACHINE_DEFAULT_RAM(pmax)
952     {
953     switch (machine->machine_subtype) {
954     case MACHINE_DEC_PMAX_3100:
955     machine->physical_ram_in_mb = 24;
956     break;
957     case MACHINE_DEC_3MAX_5000:
958     machine->physical_ram_in_mb = 64;
959     break;
960     default:machine->physical_ram_in_mb = 32;
961     }
962     }
963    
964    
965     MACHINE_REGISTER(pmax)
966     {
967 dpavlin 26 MR_DEFAULT(pmax, "DECstation/DECsystem", ARCH_MIPS, MACHINE_PMAX);
968 dpavlin 22
969 dpavlin 26 machine_entry_add_alias(me, "decstation");
970     machine_entry_add_alias(me, "decsystem");
971     machine_entry_add_alias(me, "dec");
972 dpavlin 22
973 dpavlin 26 machine_entry_add_subtype(me, "DECstation 3100 (PMAX)",
974     MACHINE_DEC_PMAX_3100, "pmax", "3100", "2100", NULL);
975 dpavlin 22
976 dpavlin 26 machine_entry_add_subtype(me, "DECstation 5000/200 (3MAX)",
977     MACHINE_DEC_3MAX_5000, "3max", "5000/200", NULL);
978 dpavlin 22
979 dpavlin 26 machine_entry_add_subtype(me, "DECstation 5000/1xx (3MIN)",
980     MACHINE_DEC_3MIN_5000, "3min", "5000/1xx", NULL);
981 dpavlin 22
982 dpavlin 26 machine_entry_add_subtype(me, "DECstation 5000 (3MAXPLUS)",
983     MACHINE_DEC_3MAXPLUS_5000, "3maxplus", "3max+", NULL);
984 dpavlin 22
985 dpavlin 26 machine_entry_add_subtype(me, "DECsystem 58x0",
986     MACHINE_DEC_5800, "5800", "58x0", NULL);
987 dpavlin 22
988 dpavlin 26 machine_entry_add_subtype(me, "DECsystem 5400",
989     MACHINE_DEC_5400, "5400", NULL);
990 dpavlin 22
991 dpavlin 26 machine_entry_add_subtype(me, "DECstation Maxine (5000)",
992     MACHINE_DEC_MAXINE_5000, "maxine", NULL);
993 dpavlin 22
994 dpavlin 26 machine_entry_add_subtype(me, "DECsystem 5500",
995     MACHINE_DEC_5500, "5500", NULL);
996 dpavlin 22
997 dpavlin 26 machine_entry_add_subtype(me, "DECstation MipsMate (5100)",
998     MACHINE_DEC_MIPSMATE_5100, "5100", "mipsmate", NULL);
999    
1000 dpavlin 22 me->set_default_ram = machine_default_ram_pmax;
1001     }
1002    

  ViewVC Help
Powered by ViewVC 1.1.26