/[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 26 - (hide annotations)
Mon Oct 8 16:20:10 2007 UTC (16 years, 6 months ago) by dpavlin
File MIME type: text/plain
File size: 30425 byte(s)
++ trunk/HISTORY	(local)
$Id: HISTORY,v 1.1264 2006/06/25 11:08:04 debug Exp $
20060624	Replacing the error-prone machine type initialization stuff
		with something more reasonable.
		Finally removing the old "cpu_run" kludge; moving around stuff
		in machine.c and emul.c to better suit the dyntrans system.
		Various minor dyntrans cleanups (renaming translate_address to
		translate_v2p, and experimenting with template physpages).
20060625	Removing the speed hack which separated the vph entries into
		two halves (code vs data); things seem a lot more stable now.
		Minor performance hack: R2000/R3000 cache isolation now only
		clears address translations when going into isolation, not
		when going out of it.
		Fixing the MIPS interrupt problems by letting mtc0 immediately
		cause interrupts.

==============  RELEASE 0.4.0.1  ==============


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

  ViewVC Help
Powered by ViewVC 1.1.26