/[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 22 - (hide annotations)
Mon Oct 8 16:19:37 2007 UTC (16 years, 6 months ago) by dpavlin
File MIME type: text/plain
File size: 30215 byte(s)
++ trunk/HISTORY	(local)
$Id: HISTORY,v 1.1121 2006/02/18 21:03:08 debug Exp $
20051126	Cobalt and PReP now work with the 21143 NIC.
		Continuing on Alpha dyntrans things.
		Fixing some more left-shift-by-24 to unsigned.
20051127	Working on OpenFirmware emulation; major cleanup/redesign.
		Progress on MacPPC emulation: NetBSD detects two CPUs (when
		running with -n 2), framebuffer output (for text) works.
		Adding quick-hack Bandit PCI controller and "gc" interrupt
		controller for MacPPC.
20051128	Changing from a Bandit to a Uni-North controller for macppc.
		Continuing on OpenFirmware and MacPPC emulation in general
		(obio controller, and wdc attached to the obio seems to work).
20051129	More work on MacPPC emulation (adding a dummy ADB controller).
		Continuing the PCI bus cleanup (endianness and tag composition)
		and rewriting all PCI controllers' access functions.
20051130	Various minor PPC dyntrans optimizations.
		Manually inlining some parts of the framebuffer redraw routine.
		Slowly beginning the conversion of the old MIPS emulation into
		dyntrans (but this will take quite some time to get right).
		Generalizing quick_pc_to_pointers.
20051201	Documentation update (David Muse has made available a kernel
		which simplifies Debian/DECstation installation).
		Continuing on the ADB bus controller.
20051202	Beginning a rewrite of the Zilog serial controller (dev_zs).
20051203	Continuing on the zs rewrite (now called dev_z8530); conversion
		to devinit style.
		Reworking some of the input-only vs output-only vs input-output
		details of src/console.c, better warning messages, and adding
		a debug dump.
		Removing the concept of "device state"; it wasn't really used.
		Changing some debug output (-vv should now be used to show all
		details about devices and busses; not shown during normal
		startup anymore).
		Beginning on some SPARC instruction disassembly support.
20051204	Minor PPC updates (WALNUT skeleton stuff).
		Continuing on the MIPS dyntrans rewrite.
		More progress on the ADB controller (a keyboard is "detected"
		by NetBSD and OpenBSD).
		Downgrading OpenBSD/arc as a guest OS from "working" to
		"almost working" in the documentation.
		Progress on Algor emulation ("v3" PCI controller).
20051205	Minor updates.
20051207	Sorting devices according to address; this reduces complexity
		of device lookups from O(n) to O(log n) in memory_rw (but no
		real performance increase (yet) in experiments).
20051210	Beginning the work on native dyntrans backends (by making a
		simple skeleton; so far only for Alpha hosts).
20051211	Some very minor SPARC updates.
20051215	Fixing a bug in the MIPS mul (note: not mult) instruction,
		so it also works with non-64-bit emulation. (Thanks to Alec
		Voropay for noticing the problem.)
20051216	More work on the fake/empty/simple/skeleton/whatever backend;
		performance doesn't increase, so this isn't really worth it,
		but it was probably worth it to prepare for a real backend
		later.
20051219	More instr call statistics gathering and analysis stuff.
20051220	Another fix for MIPS 'mul'. Also converting mul and {d,}cl{o,z}
		to dyntrans.
		memory_ppc.c syntax error fix (noticed by Peter Valchev).
		Beginning to move out machines from src/machine.c into
		individual files in src/machines (in a way similar to the
		autodev system for devices).
20051222	Updating the documentation regarding NetBSD/pmax 3.0.
20051223	- " - NetBSD/cats 3.0.
20051225	- " - NetBSD/hpcmips 3.0.
20051226	Continuing on the machine registry redesign.
		Adding support for ARM rrx (33-bit rotate).
		Fixing some signed/unsigned issues (exposed by gcc -W).
20051227	Fixing the bug which prevented a NetBSD/prep 3.0 install kernel
		from starting (triggered when an mtmsr was the last instruction
		on a page). Unfortunately not enough to get the kernel to run
		as well as the 2.1 kernels did.
20051230	Some dyntrans refactoring.
20051231	Continuing on the machine registry redesign.
20060101-10	Continuing... moving more machines. Moving MD interrupt stuff
		from machine.c into a new src/machines/interrupts.c.
20060114	Adding various mvmeppc machine skeletons.
20060115	Continuing on mvme* stuff. NetBSD/mvmeppc prints boot messages
		(for MVME1600) and reaches the root device prompt, but no
		specific hardware devices are emulated yet.
20060116	Minor updates to the mvme1600 emulation mode; the Eagle PCI bus
		seems to work without much modification, and a 21143 can be
		detected, interrupts might work (but untested so far).
		Adding a fake MK48Txx (mkclock) device, for NetBSD/mvmeppc.
20060121	Adding an aux control register for ARM. (A BIG thank you to
		Olivier Houchard for tracking down this bug.)
20060122	Adding more ARM instructions (smulXY), and dev_iq80321_7seg.
20060124	Adding disassembly of more ARM instructions (mia*, mra/mar),
		and some semi-bogus XScale and i80321 registers.
20060201-02	Various minor updates. Moving the last machines out of
		machine.c.
20060204	Adding a -c command line option, for running debugger commands
		before the simulation starts, but after all files have been
		loaded.
		Minor iq80321-related updates.
20060209	Minor hacks (DEVINIT macro, etc).
		Preparing for the generalization of the 64-bit dyntrans address
		translation subsystem.
20060216	Adding ARM ldrd (double-register load).
20060217	Continuing on various ARM-related stuff.
20060218	More progress on the ATA/wdc emulation for NetBSD/iq80321.
		NetBSD/evbarm can now be installed :-)  Updating the docs, etc.
		Continuing on Algor emulation.

==============  RELEASE 0.3.8  ==============


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

  ViewVC Help
Powered by ViewVC 1.1.26