/[gxemul]/trunk/src/machines/machine_evbmips.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_evbmips.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: 7701 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) 2005-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_evbmips.c,v 1.7 2006/06/24 10:19:19 debug Exp $
29 dpavlin 22 */
30    
31     #include <stdio.h>
32     #include <stdlib.h>
33     #include <string.h>
34    
35     #include "bus_isa.h"
36     #include "bus_pci.h"
37     #include "cpu.h"
38     #include "device.h"
39     #include "devices.h"
40     #include "machine.h"
41     #include "machine_interrupts.h"
42     #include "memory.h"
43     #include "misc.h"
44    
45     #include "maltareg.h"
46    
47    
48     MACHINE_SETUP(evbmips)
49     {
50     char tmpstr[1000];
51     char tmps[50];
52     uint64_t env, tmpptr;
53     struct pci_data *pci_data;
54     int i;
55    
56     /* See http://www.netbsd.org/Ports/evbmips/ for more info. */
57    
58     switch (machine->machine_subtype) {
59     case MACHINE_EVBMIPS_MALTA:
60     case MACHINE_EVBMIPS_MALTA_BE:
61     cpu->byte_order = EMUL_LITTLE_ENDIAN;
62     machine->machine_name = "MALTA (evbmips, little endian)";
63     machine->stable = 1;
64    
65     if (machine->machine_subtype == MACHINE_EVBMIPS_MALTA_BE) {
66     machine->machine_name = "MALTA (evbmips, big endian)";
67     cpu->byte_order = EMUL_BIG_ENDIAN;
68     }
69    
70     machine->md_interrupt = isa8_interrupt;
71     machine->isa_pic_data.native_irq = 2;
72    
73     bus_isa_init(machine, 0, 0x18000000, 0x10000000, 8, 24);
74    
75     snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=4 addr=0x%x"
76     " name2=tty2 in_use=0", MALTA_CBUSUART);
77     device_add(machine, tmpstr);
78    
79     pci_data = dev_gt_init(machine, machine->memory, 0x1be00000,
80     8+9, 8+9, 120);
81    
82     if (machine->use_x11) {
83     if (strlen(machine->boot_string_argument) < 3) {
84     fatal("WARNING: remember to use -o 'console="
85     "tty0' if you are emulating Linux. (Not"
86     " needed for NetBSD.)\n");
87     }
88     bus_pci_add(machine, pci_data, machine->memory,
89     0, 8, 0, "s3_virge");
90     }
91    
92     bus_pci_add(machine, pci_data, machine->memory,
93     0, 9, 0, "piix4_isa");
94     bus_pci_add(machine, pci_data, machine->memory,
95     0, 9, 1, "piix4_ide");
96    
97     device_add(machine, "malta_lcd addr=0x1f000400");
98     break;
99    
100 dpavlin 24 case MACHINE_EVBMIPS_MESHCUBE:
101     machine->machine_name = "Meshcube";
102    
103     /* See: http://mail-index.netbsd.org/port-evbmips/2006/
104     02/23/0000.html */
105    
106     if (machine->physical_ram_in_mb != 64)
107     fprintf(stderr, "WARNING! MeshCubes are supposed to "
108     "have exactly 64 MB RAM. Continuing anyway.\n");
109     if (machine->use_x11)
110     fprintf(stderr, "WARNING! MeshCube with -X is "
111     "meaningless. Continuing anyway.\n");
112    
113     /* First of all, the MeshCube has an Au1500 in it: */
114     machine->md_interrupt = au1x00_interrupt;
115     machine->md_int.au1x00_ic_data = dev_au1x00_init(machine,
116     machine->memory);
117    
118     /*
119     * TODO: Which non-Au1500 devices, and at what addresses?
120     *
121     * "4G Systems MTX-1 Board" at ?
122     * 1017fffc, 14005004, 11700000, 11700008, 11900014,
123     * 1190002c, 11900100, 11900108, 1190010c,
124     * 10400040 - 10400074,
125     * 14001000 (possibly LCD?)
126     * 11100028 (possibly ttySx?)
127     *
128     * "usb_ohci=base:0x10100000,len:0x100000,irq:26"
129     */
130    
131     /* Linux reads this during startup... */
132     device_add(machine, "random addr=0x1017fffc len=4");
133    
134     break;
135    
136 dpavlin 22 case MACHINE_EVBMIPS_PB1000:
137     machine->machine_name = "PB1000 (evbmips)";
138     cpu->byte_order = EMUL_BIG_ENDIAN;
139    
140     machine->md_interrupt = au1x00_interrupt;
141     machine->md_int.au1x00_ic_data = dev_au1x00_init(machine,
142     machine->memory);
143     /* TODO */
144     break;
145    
146     default:fatal("Unimplemented EVBMIPS model.\n");
147     exit(1);
148     }
149    
150     if (!machine->prom_emulation)
151     return;
152    
153    
154     /* NetBSD/evbmips wants these: (at least for Malta) */
155    
156     /* a0 = argc */
157     cpu->cd.mips.gpr[MIPS_GPR_A0] = 2;
158    
159     /* a1 = argv */
160     cpu->cd.mips.gpr[MIPS_GPR_A1] = (int32_t)0x9fc01000;
161     store_32bit_word(cpu, (int32_t)0x9fc01000, 0x9fc01040);
162     store_32bit_word(cpu, (int32_t)0x9fc01004, 0x9fc01200);
163     store_32bit_word(cpu, (int32_t)0x9fc01008, 0);
164    
165     machine->bootstr = strdup(machine->boot_kernel_filename);
166     machine->bootarg = strdup(machine->boot_string_argument);
167     store_string(cpu, (int32_t)0x9fc01040, machine->bootstr);
168     store_string(cpu, (int32_t)0x9fc01200, machine->bootarg);
169    
170     /* a2 = (yamon_env_var *)envp */
171     cpu->cd.mips.gpr[MIPS_GPR_A2] = (int32_t)0x9fc01800;
172    
173     env = cpu->cd.mips.gpr[MIPS_GPR_A2];
174     tmpptr = 0xffffffff9fc01c00ULL;
175    
176     snprintf(tmps, sizeof(tmps), "0x%08x", machine->physical_ram_in_mb<<20);
177     add_environment_string_dual(cpu, &env, &tmpptr, "memsize", tmps);
178    
179     add_environment_string_dual(cpu, &env, &tmpptr, "yamonrev", "02.06");
180    
181     /* End of env: */
182     tmpptr = 0;
183     add_environment_string_dual(cpu,
184     &env, &tmpptr, NULL, NULL);
185    
186     /* a3 = memsize */
187     cpu->cd.mips.gpr[MIPS_GPR_A3] = machine->physical_ram_in_mb * 1048576;
188     /* Hm. Linux ignores a3. */
189    
190     /*
191     * TODO:
192     * Core ID numbers.
193     * How much of this is not valid for PBxxxx?
194     *
195     * See maltareg.h for more info.
196     */
197     store_32bit_word(cpu, (int32_t)(0x80000000 + MALTA_REVISION),
198     (1 << 10) + 0x26);
199    
200     /* Call vectors at 0x9fc005xx: */
201     for (i=0; i<0x100; i+=4)
202     store_32bit_word(cpu, (int64_t)(int32_t)0x9fc00500 + i,
203     (int64_t)(int32_t)0x9fc00800 + i);
204 dpavlin 24
205     /* "Magic trap" PROM instructions at 0x9fc008xx: */
206     for (i=0; i<0x100; i+=4)
207     store_32bit_word(cpu, (int64_t)(int32_t)0x9fc00800 + i,
208     0x00c0de0c);
209 dpavlin 22 }
210    
211    
212     MACHINE_DEFAULT_CPU(evbmips)
213     {
214     switch (machine->machine_subtype) {
215     case MACHINE_EVBMIPS_MALTA:
216     case MACHINE_EVBMIPS_MALTA_BE:
217     machine->cpu_name = strdup("5Kc");
218     break;
219 dpavlin 24 case MACHINE_EVBMIPS_MESHCUBE:
220     machine->cpu_name = strdup("AU1500");
221     break;
222 dpavlin 22 case MACHINE_EVBMIPS_PB1000:
223     machine->cpu_name = strdup("AU1000");
224     break;
225     default:fatal("Unimplemented evbmips subtype.\n");
226     exit(1);
227     }
228     }
229    
230    
231     MACHINE_DEFAULT_RAM(evbmips)
232     {
233 dpavlin 24 /* MeshCube is always (?) 64 MB, and the others work fine
234     with 64 MB too. */
235 dpavlin 22 machine->physical_ram_in_mb = 64;
236     }
237    
238    
239     MACHINE_REGISTER(evbmips)
240     {
241 dpavlin 26 MR_DEFAULT(evbmips, "MIPS evaluation boards (evbmips)",
242     ARCH_MIPS, MACHINE_EVBMIPS);
243 dpavlin 24
244 dpavlin 26 machine_entry_add_alias(me, "evbmips");
245 dpavlin 24
246 dpavlin 26 machine_entry_add_subtype(me, "Malta", MACHINE_EVBMIPS_MALTA,
247     "malta", NULL);
248 dpavlin 24
249 dpavlin 26 machine_entry_add_subtype(me, "Malta (Big-Endian)",
250     MACHINE_EVBMIPS_MALTA_BE, "maltabe", NULL);
251 dpavlin 24
252 dpavlin 26 machine_entry_add_subtype(me, "MeshCube", MACHINE_EVBMIPS_MESHCUBE,
253     "meshcube", NULL);
254 dpavlin 24
255 dpavlin 26 machine_entry_add_subtype(me, "PB1000", MACHINE_EVBMIPS_PB1000,
256     "pb1000", NULL);
257 dpavlin 24
258 dpavlin 22 me->set_default_ram = machine_default_ram_evbmips;
259     }
260    

  ViewVC Help
Powered by ViewVC 1.1.26