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_prep.c,v 1.17 2007/01/21 21:02:57 debug Exp $ |
29 |
* |
30 |
* Machines conforming to the PowerPC Reference Platform specs. |
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 |
|
47 |
|
48 |
MACHINE_SETUP(prep) |
49 |
{ |
50 |
char tmpstr[300]; |
51 |
|
52 |
struct pci_data *pci_data; |
53 |
char *model_name = ""; |
54 |
|
55 |
switch (machine->machine_subtype) { |
56 |
|
57 |
case MACHINE_PREP_IBM6050: |
58 |
machine->machine_name = |
59 |
"PowerPC Reference Platform, IBM 6050/6070"; |
60 |
machine->stable = 1; |
61 |
model_name = "IBM PPS Model 6050/6070 (E)"; |
62 |
|
63 |
if (machine->emulated_hz == 0) |
64 |
machine->emulated_hz = 20000000; |
65 |
|
66 |
snprintf(tmpstr, sizeof(tmpstr), "prep irq=%s.cpu[%i]", |
67 |
machine->path, machine->bootstrap_cpu); |
68 |
device_add(machine, tmpstr); |
69 |
|
70 |
snprintf(tmpstr, sizeof(tmpstr), "eagle irq=%s.cpu[%i]", |
71 |
machine->path, machine->bootstrap_cpu); |
72 |
pci_data = device_add(machine, tmpstr); |
73 |
|
74 |
bus_pci_add(machine, pci_data, machine->memory, |
75 |
0, 13, 0, "dec21143"); |
76 |
|
77 |
if (machine->use_x11) { |
78 |
bus_pci_add(machine, pci_data, machine->memory, |
79 |
0, 14, 0, "s3_virge"); |
80 |
} |
81 |
break; |
82 |
|
83 |
case MACHINE_PREP_MVME2400: |
84 |
machine->machine_name = "PowerPC Reference Platform, MVME2400"; |
85 |
|
86 |
/* TODO: _EXACT_ model name for mvme2400? */ |
87 |
model_name = "MOT MVME2400"; |
88 |
|
89 |
snprintf(tmpstr, sizeof(tmpstr), "prep irq=%s.cpu[%i]", |
90 |
machine->path, machine->bootstrap_cpu); |
91 |
device_add(machine, tmpstr); |
92 |
|
93 |
snprintf(tmpstr, sizeof(tmpstr), "eagle irq=%s.cpu[%i]", |
94 |
machine->path, machine->bootstrap_cpu); |
95 |
pci_data = device_add(machine, tmpstr); |
96 |
|
97 |
break; |
98 |
|
99 |
default:fatal("Unimplemented PReP machine subtype %i\n", |
100 |
machine->machine_subtype); |
101 |
exit(1); |
102 |
} |
103 |
|
104 |
if (!machine->prom_emulation) |
105 |
return; |
106 |
|
107 |
|
108 |
/* Linux on PReP has 0xdeadc0de at address 0? (See |
109 |
http://joshua.raleigh.nc.us/docs/linux-2.4.10_html/ |
110 |
113568.html) */ |
111 |
store_32bit_word(cpu, 0, 0xdeadc0de); |
112 |
|
113 |
/* |
114 |
* r4 should point to first free byte after the loaded kernel. |
115 |
* r6 should point to bootinfo. |
116 |
*/ |
117 |
cpu->cd.ppc.gpr[4] = 6 * 1048576; |
118 |
cpu->cd.ppc.gpr[6] = machine->physical_ram_in_mb*1048576-0x8000; |
119 |
|
120 |
/* |
121 |
* (See NetBSD's prep/include/bootinfo.h for details.) |
122 |
* |
123 |
* 32-bit "next" offset; |
124 |
* 32-bit "type"; |
125 |
* type-specific data... |
126 |
*/ |
127 |
|
128 |
/* type: clock */ |
129 |
store_32bit_word(cpu, cpu->cd.ppc.gpr[6]+ 0, 12); |
130 |
store_32bit_word(cpu, cpu->cd.ppc.gpr[6]+ 4, 2); |
131 |
store_32bit_word(cpu, cpu->cd.ppc.gpr[6]+ 8, machine->emulated_hz); |
132 |
|
133 |
/* type: console */ |
134 |
store_32bit_word(cpu, cpu->cd.ppc.gpr[6]+12, 20); |
135 |
store_32bit_word(cpu, cpu->cd.ppc.gpr[6]+16, 1); |
136 |
store_buf(cpu, cpu->cd.ppc.gpr[6]+20, machine->use_x11? "vga":"com", 4); |
137 |
store_32bit_word(cpu, cpu->cd.ppc.gpr[6]+24, 0x3f8);/* addr */ |
138 |
store_32bit_word(cpu, cpu->cd.ppc.gpr[6]+28, 9600);/* speed */ |
139 |
|
140 |
/* type: residual */ |
141 |
store_32bit_word(cpu, cpu->cd.ppc.gpr[6]+32, 0); |
142 |
store_32bit_word(cpu, cpu->cd.ppc.gpr[6]+36, 0); |
143 |
store_32bit_word(cpu, cpu->cd.ppc.gpr[6]+40,/* addr of data */ |
144 |
cpu->cd.ppc.gpr[6] + 0x100); |
145 |
|
146 |
/* Residual data: (TODO) */ |
147 |
store_32bit_word(cpu, cpu->cd.ppc.gpr[6]+0x100, 0x200); |
148 |
store_string(cpu, cpu->cd.ppc.gpr[6]+0x100+0x8, model_name); |
149 |
store_32bit_word(cpu, cpu->cd.ppc.gpr[6]+0x100+0x1f8, |
150 |
machine->physical_ram_in_mb * 1048576); /* memsize */ |
151 |
} |
152 |
|
153 |
|
154 |
MACHINE_DEFAULT_CPU(prep) |
155 |
{ |
156 |
switch (machine->machine_subtype) { |
157 |
|
158 |
case MACHINE_PREP_IBM6050: |
159 |
machine->cpu_name = strdup("PPC604"); |
160 |
break; |
161 |
|
162 |
case MACHINE_PREP_MVME2400: |
163 |
machine->cpu_name = strdup("PPC750"); |
164 |
break; |
165 |
|
166 |
default:fatal("Unimplemented PReP machine subtype %i\n", |
167 |
machine->machine_subtype); |
168 |
exit(1); |
169 |
} |
170 |
} |
171 |
|
172 |
|
173 |
MACHINE_DEFAULT_RAM(prep) |
174 |
{ |
175 |
machine->physical_ram_in_mb = 64; |
176 |
} |
177 |
|
178 |
|
179 |
MACHINE_REGISTER(prep) |
180 |
{ |
181 |
MR_DEFAULT(prep, "PowerPC Reference Platform", ARCH_PPC, MACHINE_PREP); |
182 |
|
183 |
machine_entry_add_alias(me, "prep"); |
184 |
me->set_default_ram = machine_default_ram_prep; |
185 |
|
186 |
machine_entry_add_subtype(me, "IBM 6050/6070", MACHINE_PREP_IBM6050, |
187 |
"ibm6050", "ibm6070", NULL); |
188 |
|
189 |
machine_entry_add_subtype(me, "MVME2400", MACHINE_PREP_MVME2400, |
190 |
"mvme2400", NULL); |
191 |
} |
192 |
|