1 |
/* |
2 |
* Copyright (C) 2005-2007 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.30 2007/06/17 02:17:45 debug Exp $ |
29 |
* |
30 |
* COMMENT: MIPS evaluation boards (e.g. Malta) |
31 |
*/ |
32 |
|
33 |
#include <stdio.h> |
34 |
#include <stdlib.h> |
35 |
#include <string.h> |
36 |
|
37 |
#include "bus_isa.h" |
38 |
#include "bus_pci.h" |
39 |
#include "cpu.h" |
40 |
#include "device.h" |
41 |
#include "devices.h" |
42 |
#include "machine.h" |
43 |
#include "memory.h" |
44 |
#include "misc.h" |
45 |
|
46 |
#include "maltareg.h" |
47 |
|
48 |
|
49 |
MACHINE_SETUP(evbmips) |
50 |
{ |
51 |
char tmpstr[1000], tmpstr2[1000]; |
52 |
struct pci_data *pci_data; |
53 |
int i; |
54 |
|
55 |
/* See http://www.netbsd.org/ports/evbmips/ for more info. */ |
56 |
|
57 |
switch (machine->machine_subtype) { |
58 |
|
59 |
case MACHINE_EVBMIPS_MALTA: |
60 |
case MACHINE_EVBMIPS_MALTA_BE: |
61 |
if (machine->emulated_hz == 0) |
62 |
machine->emulated_hz = 33000000; |
63 |
cpu->byte_order = EMUL_LITTLE_ENDIAN; |
64 |
machine->machine_name = "MALTA (evbmips, little endian)"; |
65 |
|
66 |
if (machine->machine_subtype == MACHINE_EVBMIPS_MALTA_BE) { |
67 |
machine->machine_name = "MALTA (evbmips, big endian)"; |
68 |
cpu->byte_order = EMUL_BIG_ENDIAN; |
69 |
} |
70 |
|
71 |
/* ISA bus at MIPS irq 2: */ |
72 |
snprintf(tmpstr, sizeof(tmpstr), "%s.cpu[%i].2", |
73 |
machine->path, machine->bootstrap_cpu); |
74 |
bus_isa_init(machine, tmpstr, 0, 0x18000000, 0x10000000); |
75 |
|
76 |
snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=%s.cpu[%i].4 " |
77 |
"addr=0x%x name2=tty2 in_use=0", machine->path, |
78 |
machine->bootstrap_cpu, MALTA_CBUSUART); |
79 |
device_add(machine, tmpstr); |
80 |
|
81 |
/* Add a GT controller; timer interrupts at ISA irq 9: */ |
82 |
snprintf(tmpstr, sizeof(tmpstr), "%s.cpu[%i].2.isa.9", |
83 |
machine->path, machine->bootstrap_cpu); |
84 |
snprintf(tmpstr2, sizeof(tmpstr2), "%s.cpu[%i].2", |
85 |
machine->path, machine->bootstrap_cpu); |
86 |
pci_data = dev_gt_init(machine, machine->memory, 0x1be00000, |
87 |
tmpstr, tmpstr2, 120); |
88 |
|
89 |
if (machine->x11_md.in_use) { |
90 |
if (strlen(machine->boot_string_argument) < 3) { |
91 |
fatal("WARNING: remember to use -o 'console=" |
92 |
"tty0' if you are emulating Linux. (Not" |
93 |
" needed for NetBSD.)\n"); |
94 |
} |
95 |
bus_pci_add(machine, pci_data, machine->memory, |
96 |
0, 8, 0, "s3_virge"); |
97 |
} |
98 |
|
99 |
bus_pci_add(machine, pci_data, machine->memory, |
100 |
0, 9, 0, "piix4_isa"); |
101 |
bus_pci_add(machine, pci_data, machine->memory, |
102 |
0, 9, 1, "piix4_ide"); |
103 |
|
104 |
/* pcn: Not yet, since it is just a bogus device, so far. */ |
105 |
/* bus_pci_add(machine, pci_data, machine->memory, |
106 |
0, 11, 0, "pcn"); */ |
107 |
|
108 |
device_add(machine, "malta_lcd addr=0x1f000400"); |
109 |
break; |
110 |
|
111 |
default:fatal("Unimplemented EVBMIPS model.\n"); |
112 |
exit(1); |
113 |
} |
114 |
|
115 |
if (!machine->prom_emulation) |
116 |
return; |
117 |
|
118 |
|
119 |
/* NetBSD/evbmips wants these: (at least for Malta) */ |
120 |
|
121 |
/* a0 = argc */ |
122 |
cpu->cd.mips.gpr[MIPS_GPR_A0] = 2; |
123 |
|
124 |
/* a1 = argv */ |
125 |
cpu->cd.mips.gpr[MIPS_GPR_A1] = (int32_t)0x9fc01000; |
126 |
store_32bit_word(cpu, (int32_t)0x9fc01000, 0x9fc01040); |
127 |
store_32bit_word(cpu, (int32_t)0x9fc01004, 0x9fc01200); |
128 |
store_32bit_word(cpu, (int32_t)0x9fc01008, 0); |
129 |
|
130 |
machine->bootstr = strdup(machine->boot_kernel_filename); |
131 |
machine->bootarg = strdup(machine->boot_string_argument); |
132 |
store_string(cpu, (int32_t)0x9fc01040, machine->bootstr); |
133 |
store_string(cpu, (int32_t)0x9fc01200, machine->bootarg); |
134 |
|
135 |
/* a2 = (yamon_env_var *)envp */ |
136 |
cpu->cd.mips.gpr[MIPS_GPR_A2] = (int32_t)0x9fc01800; |
137 |
|
138 |
yamon_machine_setup(machine, cpu->cd.mips.gpr[MIPS_GPR_A2]); |
139 |
|
140 |
/* a3 = memsize */ |
141 |
cpu->cd.mips.gpr[MIPS_GPR_A3] = machine->physical_ram_in_mb * 1048576; |
142 |
/* Hm. Linux ignores a3. */ |
143 |
|
144 |
/* Set the Core ID. See maltareg.h for more info. */ |
145 |
store_32bit_word(cpu, (int32_t)(0x80000000 + MALTA_REVISION), |
146 |
(1 << 10) + 0x26); |
147 |
|
148 |
/* Call vectors at 0x9fc005xx: */ |
149 |
for (i=0; i<0x100; i+=4) |
150 |
store_32bit_word(cpu, (int64_t)(int32_t)0x9fc00500 + i, |
151 |
(int64_t)(int32_t)0x9fc00800 + i); |
152 |
|
153 |
/* "Magic trap" PROM instructions at 0x9fc008xx: */ |
154 |
for (i=0; i<0x100; i+=4) |
155 |
store_32bit_word(cpu, (int64_t)(int32_t)0x9fc00800 + i, |
156 |
0x00c0de0c); |
157 |
} |
158 |
|
159 |
|
160 |
MACHINE_DEFAULT_CPU(evbmips) |
161 |
{ |
162 |
switch (machine->machine_subtype) { |
163 |
|
164 |
case MACHINE_EVBMIPS_MALTA: |
165 |
case MACHINE_EVBMIPS_MALTA_BE: |
166 |
/* 5Kc = MIPS64 rev 1, 5KE = MIPS64 rev 2 */ |
167 |
machine->cpu_name = strdup("5Kc"); |
168 |
break; |
169 |
|
170 |
default:fatal("Unimplemented evbmips subtype.\n"); |
171 |
exit(1); |
172 |
} |
173 |
} |
174 |
|
175 |
|
176 |
MACHINE_DEFAULT_RAM(evbmips) |
177 |
{ |
178 |
machine->physical_ram_in_mb = 128; |
179 |
} |
180 |
|
181 |
|
182 |
MACHINE_REGISTER(evbmips) |
183 |
{ |
184 |
MR_DEFAULT(evbmips, "MIPS evaluation boards (evbmips)", |
185 |
ARCH_MIPS, MACHINE_EVBMIPS); |
186 |
|
187 |
machine_entry_add_alias(me, "evbmips"); |
188 |
|
189 |
machine_entry_add_subtype(me, "Malta", MACHINE_EVBMIPS_MALTA, |
190 |
"malta", NULL); |
191 |
|
192 |
machine_entry_add_subtype(me, "Malta (Big-Endian)", |
193 |
MACHINE_EVBMIPS_MALTA_BE, "maltabe", NULL); |
194 |
|
195 |
me->set_default_ram = machine_default_ram_evbmips; |
196 |
} |
197 |
|