/[gxemul]/upstream/0.3.8/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 /upstream/0.3.8/src/machines/machine_evbmips.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 23 - (hide annotations)
Mon Oct 8 16:19:43 2007 UTC (16 years, 8 months ago) by dpavlin
File MIME type: text/plain
File size: 6369 byte(s)
0.3.8
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     * $Id: machine_evbmips.c,v 1.2 2006/01/08 11:05:03 debug Exp $
29     */
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     case MACHINE_EVBMIPS_PB1000:
101     machine->machine_name = "PB1000 (evbmips)";
102     cpu->byte_order = EMUL_BIG_ENDIAN;
103    
104     machine->md_interrupt = au1x00_interrupt;
105     machine->md_int.au1x00_ic_data = dev_au1x00_init(machine,
106     machine->memory);
107     /* TODO */
108     break;
109    
110     default:fatal("Unimplemented EVBMIPS model.\n");
111     exit(1);
112     }
113    
114     if (!machine->prom_emulation)
115     return;
116    
117    
118     /* NetBSD/evbmips wants these: (at least for Malta) */
119    
120     /* a0 = argc */
121     cpu->cd.mips.gpr[MIPS_GPR_A0] = 2;
122    
123     /* a1 = argv */
124     cpu->cd.mips.gpr[MIPS_GPR_A1] = (int32_t)0x9fc01000;
125     store_32bit_word(cpu, (int32_t)0x9fc01000, 0x9fc01040);
126     store_32bit_word(cpu, (int32_t)0x9fc01004, 0x9fc01200);
127     store_32bit_word(cpu, (int32_t)0x9fc01008, 0);
128    
129     machine->bootstr = strdup(machine->boot_kernel_filename);
130     machine->bootarg = strdup(machine->boot_string_argument);
131     store_string(cpu, (int32_t)0x9fc01040, machine->bootstr);
132     store_string(cpu, (int32_t)0x9fc01200, machine->bootarg);
133    
134     /* a2 = (yamon_env_var *)envp */
135     cpu->cd.mips.gpr[MIPS_GPR_A2] = (int32_t)0x9fc01800;
136    
137     env = cpu->cd.mips.gpr[MIPS_GPR_A2];
138     tmpptr = 0xffffffff9fc01c00ULL;
139    
140     snprintf(tmps, sizeof(tmps), "0x%08x", machine->physical_ram_in_mb<<20);
141     add_environment_string_dual(cpu, &env, &tmpptr, "memsize", tmps);
142    
143     add_environment_string_dual(cpu, &env, &tmpptr, "yamonrev", "02.06");
144    
145     /* End of env: */
146     tmpptr = 0;
147     add_environment_string_dual(cpu,
148     &env, &tmpptr, NULL, NULL);
149    
150     /* a3 = memsize */
151     cpu->cd.mips.gpr[MIPS_GPR_A3] = machine->physical_ram_in_mb * 1048576;
152     /* Hm. Linux ignores a3. */
153    
154     /*
155     * TODO:
156     * Core ID numbers.
157     * How much of this is not valid for PBxxxx?
158     *
159     * See maltareg.h for more info.
160     */
161     store_32bit_word(cpu, (int32_t)(0x80000000 + MALTA_REVISION),
162     (1 << 10) + 0x26);
163    
164     /* Call vectors at 0x9fc005xx: */
165     for (i=0; i<0x100; i+=4)
166     store_32bit_word(cpu, (int64_t)(int32_t)0x9fc00500 + i,
167     (int64_t)(int32_t)0x9fc00800 + i);
168     }
169    
170    
171     MACHINE_DEFAULT_CPU(evbmips)
172     {
173     switch (machine->machine_subtype) {
174     case MACHINE_EVBMIPS_MALTA:
175     case MACHINE_EVBMIPS_MALTA_BE:
176     machine->cpu_name = strdup("5Kc");
177     break;
178     case MACHINE_EVBMIPS_PB1000:
179     machine->cpu_name = strdup("AU1000");
180     break;
181     default:fatal("Unimplemented evbmips subtype.\n");
182     exit(1);
183     }
184     }
185    
186    
187     MACHINE_DEFAULT_RAM(evbmips)
188     {
189     machine->physical_ram_in_mb = 64;
190     }
191    
192    
193     MACHINE_REGISTER(evbmips)
194     {
195     MR_DEFAULT(evbmips, "MIPS evaluation boards (evbmips)", ARCH_MIPS,
196     MACHINE_EVBMIPS, 1, 3);
197     me->aliases[0] = "evbmips";
198     me->subtype[0] = machine_entry_subtype_new("Malta",
199     MACHINE_EVBMIPS_MALTA, 1);
200     me->subtype[0]->aliases[0] = "malta";
201     me->subtype[1] = machine_entry_subtype_new("Malta (Big-Endian)",
202     MACHINE_EVBMIPS_MALTA_BE, 1);
203     me->subtype[1]->aliases[0] = "maltabe";
204     me->subtype[2] = machine_entry_subtype_new("PB1000",
205     MACHINE_EVBMIPS_PB1000, 1);
206     me->subtype[2]->aliases[0] = "pb1000";
207     machine_entry_add(me, ARCH_MIPS);
208     me->set_default_ram = machine_default_ram_evbmips;
209     machine_entry_add(me, ARCH_ARM);
210     }
211    

  ViewVC Help
Powered by ViewVC 1.1.26