root / hw / ppc_prep.c @ a1bc20df
History | View | Annotate | Download (20.5 kB)
1 | 9a64fbe4 | bellard | /*
|
---|---|---|---|
2 | a541f297 | bellard | * QEMU PPC PREP hardware System Emulator
|
3 | 5fafdf24 | ths | *
|
4 | 47103572 | j_mayer | * Copyright (c) 2003-2007 Jocelyn Mayer
|
5 | 5fafdf24 | ths | *
|
6 | a541f297 | bellard | * Permission is hereby granted, free of charge, to any person obtaining a copy
|
7 | a541f297 | bellard | * of this software and associated documentation files (the "Software"), to deal
|
8 | a541f297 | bellard | * in the Software without restriction, including without limitation the rights
|
9 | a541f297 | bellard | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10 | a541f297 | bellard | * copies of the Software, and to permit persons to whom the Software is
|
11 | a541f297 | bellard | * furnished to do so, subject to the following conditions:
|
12 | a541f297 | bellard | *
|
13 | a541f297 | bellard | * The above copyright notice and this permission notice shall be included in
|
14 | a541f297 | bellard | * all copies or substantial portions of the Software.
|
15 | a541f297 | bellard | *
|
16 | a541f297 | bellard | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 | a541f297 | bellard | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 | a541f297 | bellard | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 | a541f297 | bellard | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 | a541f297 | bellard | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21 | a541f297 | bellard | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22 | a541f297 | bellard | * THE SOFTWARE.
|
23 | 9a64fbe4 | bellard | */
|
24 | 87ecb68b | pbrook | #include "hw.h" |
25 | 87ecb68b | pbrook | #include "nvram.h" |
26 | 87ecb68b | pbrook | #include "pc.h" |
27 | 488cb996 | Gerd Hoffmann | #include "serial.h" |
28 | 87ecb68b | pbrook | #include "fdc.h" |
29 | 87ecb68b | pbrook | #include "net.h" |
30 | 87ecb68b | pbrook | #include "sysemu.h" |
31 | 87ecb68b | pbrook | #include "isa.h" |
32 | 87ecb68b | pbrook | #include "pci.h" |
33 | 8ca8c7bc | Andreas Färber | #include "pci_host.h" |
34 | 87ecb68b | pbrook | #include "ppc.h" |
35 | 87ecb68b | pbrook | #include "boards.h" |
36 | 3b3fb322 | blueswir1 | #include "qemu-log.h" |
37 | ec82026c | Gerd Hoffmann | #include "ide.h" |
38 | ca20cf32 | Blue Swirl | #include "loader.h" |
39 | 1d914fa0 | Isaku Yamahata | #include "mc146818rtc.h" |
40 | 2446333c | Blue Swirl | #include "blockdev.h" |
41 | 9357b144 | Hervé Poussineau | #include "arch_init.h" |
42 | 1e39101c | Avi Kivity | #include "exec-memory.h" |
43 | 9fddaa0c | bellard | |
44 | 9a64fbe4 | bellard | //#define HARD_DEBUG_PPC_IO
|
45 | a541f297 | bellard | //#define DEBUG_PPC_IO
|
46 | 9a64fbe4 | bellard | |
47 | fe33cc71 | j_mayer | /* SMP is not enabled, for now */
|
48 | fe33cc71 | j_mayer | #define MAX_CPUS 1 |
49 | fe33cc71 | j_mayer | |
50 | e4bcb14c | ths | #define MAX_IDE_BUS 2 |
51 | e4bcb14c | ths | |
52 | bba831e8 | Paul Brook | #define BIOS_SIZE (1024 * 1024) |
53 | b6b8bd18 | bellard | #define BIOS_FILENAME "ppc_rom.bin" |
54 | b6b8bd18 | bellard | #define KERNEL_LOAD_ADDR 0x01000000 |
55 | b6b8bd18 | bellard | #define INITRD_LOAD_ADDR 0x01800000 |
56 | 64201201 | bellard | |
57 | 9a64fbe4 | bellard | #if defined (HARD_DEBUG_PPC_IO) && !defined (DEBUG_PPC_IO)
|
58 | 9a64fbe4 | bellard | #define DEBUG_PPC_IO
|
59 | 9a64fbe4 | bellard | #endif
|
60 | 9a64fbe4 | bellard | |
61 | 9a64fbe4 | bellard | #if defined (HARD_DEBUG_PPC_IO)
|
62 | 001faf32 | Blue Swirl | #define PPC_IO_DPRINTF(fmt, ...) \
|
63 | 9a64fbe4 | bellard | do { \
|
64 | 8fec2b8c | aliguori | if (qemu_loglevel_mask(CPU_LOG_IOPORT)) { \
|
65 | 001faf32 | Blue Swirl | qemu_log("%s: " fmt, __func__ , ## __VA_ARGS__); \ |
66 | 9a64fbe4 | bellard | } else { \
|
67 | 001faf32 | Blue Swirl | printf("%s : " fmt, __func__ , ## __VA_ARGS__); \ |
68 | 9a64fbe4 | bellard | } \ |
69 | 9a64fbe4 | bellard | } while (0) |
70 | 9a64fbe4 | bellard | #elif defined (DEBUG_PPC_IO)
|
71 | 0bf9e31a | Blue Swirl | #define PPC_IO_DPRINTF(fmt, ...) \
|
72 | 0bf9e31a | Blue Swirl | qemu_log_mask(CPU_LOG_IOPORT, fmt, ## __VA_ARGS__) |
73 | 9a64fbe4 | bellard | #else
|
74 | 001faf32 | Blue Swirl | #define PPC_IO_DPRINTF(fmt, ...) do { } while (0) |
75 | 9a64fbe4 | bellard | #endif
|
76 | 9a64fbe4 | bellard | |
77 | 64201201 | bellard | /* Constants for devices init */
|
78 | a541f297 | bellard | static const int ide_iobase[2] = { 0x1f0, 0x170 }; |
79 | a541f297 | bellard | static const int ide_iobase2[2] = { 0x3f6, 0x376 }; |
80 | a541f297 | bellard | static const int ide_irq[2] = { 13, 13 }; |
81 | a541f297 | bellard | |
82 | a541f297 | bellard | #define NE2000_NB_MAX 6 |
83 | a541f297 | bellard | |
84 | a541f297 | bellard | static uint32_t ne2000_io[NE2000_NB_MAX] = { 0x300, 0x320, 0x340, 0x360, 0x280, 0x380 }; |
85 | a541f297 | bellard | static int ne2000_irq[NE2000_NB_MAX] = { 9, 10, 11, 3, 4, 5 }; |
86 | 9a64fbe4 | bellard | |
87 | 64201201 | bellard | /* ISA IO ports bridge */
|
88 | 9a64fbe4 | bellard | #define PPC_IO_BASE 0x80000000 |
89 | 9a64fbe4 | bellard | |
90 | 64201201 | bellard | /* PowerPC control and status registers */
|
91 | 64201201 | bellard | #if 0 // Not used
|
92 | 64201201 | bellard | static struct {
|
93 | 64201201 | bellard | /* IDs */
|
94 | 64201201 | bellard | uint32_t veni_devi;
|
95 | 64201201 | bellard | uint32_t revi;
|
96 | 64201201 | bellard | /* Control and status */
|
97 | 64201201 | bellard | uint32_t gcsr;
|
98 | 64201201 | bellard | uint32_t xcfr;
|
99 | 64201201 | bellard | uint32_t ct32;
|
100 | 64201201 | bellard | uint32_t mcsr;
|
101 | 64201201 | bellard | /* General purpose registers */
|
102 | 64201201 | bellard | uint32_t gprg[6];
|
103 | 64201201 | bellard | /* Exceptions */
|
104 | 64201201 | bellard | uint32_t feen;
|
105 | 64201201 | bellard | uint32_t fest;
|
106 | 64201201 | bellard | uint32_t fema;
|
107 | 64201201 | bellard | uint32_t fecl;
|
108 | 64201201 | bellard | uint32_t eeen;
|
109 | 64201201 | bellard | uint32_t eest;
|
110 | 64201201 | bellard | uint32_t eecl;
|
111 | 64201201 | bellard | uint32_t eeint;
|
112 | 64201201 | bellard | uint32_t eemck0;
|
113 | 64201201 | bellard | uint32_t eemck1;
|
114 | 64201201 | bellard | /* Error diagnostic */
|
115 | 64201201 | bellard | } XCSR;
|
116 | 64201201 | bellard | |
117 | 36081602 | j_mayer | static void PPC_XCSR_writeb (void *opaque,
|
118 | a8170e5e | Avi Kivity | hwaddr addr, uint32_t value)
|
119 | 64201201 | bellard | {
|
120 | 90e189ec | Blue Swirl | printf("%s: 0x" TARGET_FMT_plx " => 0x%08" PRIx32 "\n", __func__, addr,
|
121 | 90e189ec | Blue Swirl | value);
|
122 | 64201201 | bellard | }
|
123 | 64201201 | bellard | |
124 | 36081602 | j_mayer | static void PPC_XCSR_writew (void *opaque,
|
125 | a8170e5e | Avi Kivity | hwaddr addr, uint32_t value)
|
126 | 9a64fbe4 | bellard | {
|
127 | 90e189ec | Blue Swirl | printf("%s: 0x" TARGET_FMT_plx " => 0x%08" PRIx32 "\n", __func__, addr,
|
128 | 90e189ec | Blue Swirl | value);
|
129 | 9a64fbe4 | bellard | }
|
130 | 9a64fbe4 | bellard | |
131 | 36081602 | j_mayer | static void PPC_XCSR_writel (void *opaque,
|
132 | a8170e5e | Avi Kivity | hwaddr addr, uint32_t value)
|
133 | 9a64fbe4 | bellard | {
|
134 | 90e189ec | Blue Swirl | printf("%s: 0x" TARGET_FMT_plx " => 0x%08" PRIx32 "\n", __func__, addr,
|
135 | 90e189ec | Blue Swirl | value);
|
136 | 9a64fbe4 | bellard | }
|
137 | 9a64fbe4 | bellard | |
138 | a8170e5e | Avi Kivity | static uint32_t PPC_XCSR_readb (void *opaque, hwaddr addr)
|
139 | 64201201 | bellard | {
|
140 | 64201201 | bellard | uint32_t retval = 0;
|
141 | 9a64fbe4 | bellard | |
142 | 90e189ec | Blue Swirl | printf("%s: 0x" TARGET_FMT_plx " <= %08" PRIx32 "\n", __func__, addr,
|
143 | 90e189ec | Blue Swirl | retval);
|
144 | 9a64fbe4 | bellard | |
145 | 64201201 | bellard | return retval;
|
146 | 64201201 | bellard | }
|
147 | 64201201 | bellard | |
148 | a8170e5e | Avi Kivity | static uint32_t PPC_XCSR_readw (void *opaque, hwaddr addr)
|
149 | 9a64fbe4 | bellard | {
|
150 | 64201201 | bellard | uint32_t retval = 0;
|
151 | 64201201 | bellard | |
152 | 90e189ec | Blue Swirl | printf("%s: 0x" TARGET_FMT_plx " <= %08" PRIx32 "\n", __func__, addr,
|
153 | 90e189ec | Blue Swirl | retval);
|
154 | 64201201 | bellard | |
155 | 64201201 | bellard | return retval;
|
156 | 9a64fbe4 | bellard | }
|
157 | 9a64fbe4 | bellard | |
158 | a8170e5e | Avi Kivity | static uint32_t PPC_XCSR_readl (void *opaque, hwaddr addr)
|
159 | 9a64fbe4 | bellard | {
|
160 | 9a64fbe4 | bellard | uint32_t retval = 0;
|
161 | 9a64fbe4 | bellard | |
162 | 90e189ec | Blue Swirl | printf("%s: 0x" TARGET_FMT_plx " <= %08" PRIx32 "\n", __func__, addr,
|
163 | 90e189ec | Blue Swirl | retval);
|
164 | 9a64fbe4 | bellard | |
165 | 9a64fbe4 | bellard | return retval;
|
166 | 9a64fbe4 | bellard | }
|
167 | 9a64fbe4 | bellard | |
168 | 0c90c52f | Avi Kivity | static const MemoryRegionOps PPC_XCSR_ops = {
|
169 | 0c90c52f | Avi Kivity | .old_mmio = {
|
170 | 0c90c52f | Avi Kivity | .read = { PPC_XCSR_readb, PPC_XCSR_readw, PPC_XCSR_readl, },
|
171 | 0c90c52f | Avi Kivity | .write = { PPC_XCSR_writeb, PPC_XCSR_writew, PPC_XCSR_writel, },
|
172 | 0c90c52f | Avi Kivity | },
|
173 | 0c90c52f | Avi Kivity | .endianness = DEVICE_LITTLE_ENDIAN,
|
174 | 9a64fbe4 | bellard | };
|
175 | 9a64fbe4 | bellard | |
176 | b6b8bd18 | bellard | #endif
|
177 | 9a64fbe4 | bellard | |
178 | 64201201 | bellard | /* Fake super-io ports for PREP platform (Intel 82378ZB) */
|
179 | c227f099 | Anthony Liguori | typedef struct sysctrl_t { |
180 | c4781a51 | j_mayer | qemu_irq reset_irq; |
181 | 43a34704 | Blue Swirl | M48t59State *nvram; |
182 | 64201201 | bellard | uint8_t state; |
183 | 64201201 | bellard | uint8_t syscontrol; |
184 | 64201201 | bellard | uint8_t fake_io[2];
|
185 | da9b266b | bellard | int contiguous_map;
|
186 | fb3444b8 | bellard | int endian;
|
187 | c227f099 | Anthony Liguori | } sysctrl_t; |
188 | 9a64fbe4 | bellard | |
189 | 64201201 | bellard | enum {
|
190 | 64201201 | bellard | STATE_HARDFILE = 0x01,
|
191 | 9a64fbe4 | bellard | }; |
192 | 9a64fbe4 | bellard | |
193 | c227f099 | Anthony Liguori | static sysctrl_t *sysctrl;
|
194 | 9a64fbe4 | bellard | |
195 | a541f297 | bellard | static void PREP_io_write (void *opaque, uint32_t addr, uint32_t val) |
196 | 9a64fbe4 | bellard | { |
197 | c227f099 | Anthony Liguori | sysctrl_t *sysctrl = opaque; |
198 | 64201201 | bellard | |
199 | aae9366a | j_mayer | PPC_IO_DPRINTF("0x%08" PRIx32 " => 0x%02" PRIx32 "\n", addr - PPC_IO_BASE, |
200 | aae9366a | j_mayer | val); |
201 | 64201201 | bellard | sysctrl->fake_io[addr - 0x0398] = val;
|
202 | 9a64fbe4 | bellard | } |
203 | 9a64fbe4 | bellard | |
204 | a541f297 | bellard | static uint32_t PREP_io_read (void *opaque, uint32_t addr) |
205 | 9a64fbe4 | bellard | { |
206 | c227f099 | Anthony Liguori | sysctrl_t *sysctrl = opaque; |
207 | 9a64fbe4 | bellard | |
208 | aae9366a | j_mayer | PPC_IO_DPRINTF("0x%08" PRIx32 " <= 0x%02" PRIx32 "\n", addr - PPC_IO_BASE, |
209 | 64201201 | bellard | sysctrl->fake_io[addr - 0x0398]);
|
210 | 64201201 | bellard | return sysctrl->fake_io[addr - 0x0398]; |
211 | 64201201 | bellard | } |
212 | 9a64fbe4 | bellard | |
213 | a541f297 | bellard | static void PREP_io_800_writeb (void *opaque, uint32_t addr, uint32_t val) |
214 | 9a64fbe4 | bellard | { |
215 | c227f099 | Anthony Liguori | sysctrl_t *sysctrl = opaque; |
216 | 64201201 | bellard | |
217 | aae9366a | j_mayer | PPC_IO_DPRINTF("0x%08" PRIx32 " => 0x%02" PRIx32 "\n", |
218 | aae9366a | j_mayer | addr - PPC_IO_BASE, val); |
219 | 9a64fbe4 | bellard | switch (addr) {
|
220 | 9a64fbe4 | bellard | case 0x0092: |
221 | 9a64fbe4 | bellard | /* Special port 92 */
|
222 | 9a64fbe4 | bellard | /* Check soft reset asked */
|
223 | 64201201 | bellard | if (val & 0x01) { |
224 | c4781a51 | j_mayer | qemu_irq_raise(sysctrl->reset_irq); |
225 | c4781a51 | j_mayer | } else {
|
226 | c4781a51 | j_mayer | qemu_irq_lower(sysctrl->reset_irq); |
227 | 9a64fbe4 | bellard | } |
228 | 9a64fbe4 | bellard | /* Check LE mode */
|
229 | 64201201 | bellard | if (val & 0x02) { |
230 | fb3444b8 | bellard | sysctrl->endian = 1;
|
231 | fb3444b8 | bellard | } else {
|
232 | fb3444b8 | bellard | sysctrl->endian = 0;
|
233 | 9a64fbe4 | bellard | } |
234 | 9a64fbe4 | bellard | break;
|
235 | 64201201 | bellard | case 0x0800: |
236 | 64201201 | bellard | /* Motorola CPU configuration register : read-only */
|
237 | 64201201 | bellard | break;
|
238 | 64201201 | bellard | case 0x0802: |
239 | 64201201 | bellard | /* Motorola base module feature register : read-only */
|
240 | 64201201 | bellard | break;
|
241 | 64201201 | bellard | case 0x0803: |
242 | 64201201 | bellard | /* Motorola base module status register : read-only */
|
243 | 64201201 | bellard | break;
|
244 | 9a64fbe4 | bellard | case 0x0808: |
245 | 64201201 | bellard | /* Hardfile light register */
|
246 | 64201201 | bellard | if (val & 1) |
247 | 64201201 | bellard | sysctrl->state |= STATE_HARDFILE; |
248 | 64201201 | bellard | else
|
249 | 64201201 | bellard | sysctrl->state &= ~STATE_HARDFILE; |
250 | 9a64fbe4 | bellard | break;
|
251 | 9a64fbe4 | bellard | case 0x0810: |
252 | 9a64fbe4 | bellard | /* Password protect 1 register */
|
253 | 64201201 | bellard | if (sysctrl->nvram != NULL) |
254 | 64201201 | bellard | m48t59_toggle_lock(sysctrl->nvram, 1);
|
255 | 9a64fbe4 | bellard | break;
|
256 | 9a64fbe4 | bellard | case 0x0812: |
257 | 9a64fbe4 | bellard | /* Password protect 2 register */
|
258 | 64201201 | bellard | if (sysctrl->nvram != NULL) |
259 | 64201201 | bellard | m48t59_toggle_lock(sysctrl->nvram, 2);
|
260 | 9a64fbe4 | bellard | break;
|
261 | 9a64fbe4 | bellard | case 0x0814: |
262 | 64201201 | bellard | /* L2 invalidate register */
|
263 | c68ea704 | bellard | // tlb_flush(first_cpu, 1);
|
264 | 9a64fbe4 | bellard | break;
|
265 | 9a64fbe4 | bellard | case 0x081C: |
266 | 9a64fbe4 | bellard | /* system control register */
|
267 | 64201201 | bellard | sysctrl->syscontrol = val & 0x0F;
|
268 | 9a64fbe4 | bellard | break;
|
269 | 9a64fbe4 | bellard | case 0x0850: |
270 | 9a64fbe4 | bellard | /* I/O map type register */
|
271 | da9b266b | bellard | sysctrl->contiguous_map = val & 0x01;
|
272 | 9a64fbe4 | bellard | break;
|
273 | 9a64fbe4 | bellard | default:
|
274 | aae9366a | j_mayer | printf("ERROR: unaffected IO port write: %04" PRIx32
|
275 | aae9366a | j_mayer | " => %02" PRIx32"\n", addr, val); |
276 | 9a64fbe4 | bellard | break;
|
277 | 9a64fbe4 | bellard | } |
278 | 9a64fbe4 | bellard | } |
279 | 9a64fbe4 | bellard | |
280 | a541f297 | bellard | static uint32_t PREP_io_800_readb (void *opaque, uint32_t addr) |
281 | 9a64fbe4 | bellard | { |
282 | c227f099 | Anthony Liguori | sysctrl_t *sysctrl = opaque; |
283 | 9a64fbe4 | bellard | uint32_t retval = 0xFF;
|
284 | 9a64fbe4 | bellard | |
285 | 9a64fbe4 | bellard | switch (addr) {
|
286 | 9a64fbe4 | bellard | case 0x0092: |
287 | 9a64fbe4 | bellard | /* Special port 92 */
|
288 | 64201201 | bellard | retval = 0x00;
|
289 | 64201201 | bellard | break;
|
290 | 64201201 | bellard | case 0x0800: |
291 | 64201201 | bellard | /* Motorola CPU configuration register */
|
292 | 64201201 | bellard | retval = 0xEF; /* MPC750 */ |
293 | 64201201 | bellard | break;
|
294 | 64201201 | bellard | case 0x0802: |
295 | 64201201 | bellard | /* Motorola Base module feature register */
|
296 | 64201201 | bellard | retval = 0xAD; /* No ESCC, PMC slot neither ethernet */ |
297 | 64201201 | bellard | break;
|
298 | 64201201 | bellard | case 0x0803: |
299 | 64201201 | bellard | /* Motorola base module status register */
|
300 | 64201201 | bellard | retval = 0xE0; /* Standard MPC750 */ |
301 | 9a64fbe4 | bellard | break;
|
302 | 9a64fbe4 | bellard | case 0x080C: |
303 | 9a64fbe4 | bellard | /* Equipment present register:
|
304 | 9a64fbe4 | bellard | * no L2 cache
|
305 | 9a64fbe4 | bellard | * no upgrade processor
|
306 | 9a64fbe4 | bellard | * no cards in PCI slots
|
307 | 9a64fbe4 | bellard | * SCSI fuse is bad
|
308 | 9a64fbe4 | bellard | */
|
309 | 64201201 | bellard | retval = 0x3C;
|
310 | 64201201 | bellard | break;
|
311 | 64201201 | bellard | case 0x0810: |
312 | 64201201 | bellard | /* Motorola base module extended feature register */
|
313 | 64201201 | bellard | retval = 0x39; /* No USB, CF and PCI bridge. NVRAM present */ |
314 | 9a64fbe4 | bellard | break;
|
315 | da9b266b | bellard | case 0x0814: |
316 | da9b266b | bellard | /* L2 invalidate: don't care */
|
317 | da9b266b | bellard | break;
|
318 | 9a64fbe4 | bellard | case 0x0818: |
319 | 9a64fbe4 | bellard | /* Keylock */
|
320 | 9a64fbe4 | bellard | retval = 0x00;
|
321 | 9a64fbe4 | bellard | break;
|
322 | 9a64fbe4 | bellard | case 0x081C: |
323 | 9a64fbe4 | bellard | /* system control register
|
324 | 9a64fbe4 | bellard | * 7 - 6 / 1 - 0: L2 cache enable
|
325 | 9a64fbe4 | bellard | */
|
326 | 64201201 | bellard | retval = sysctrl->syscontrol; |
327 | 9a64fbe4 | bellard | break;
|
328 | 9a64fbe4 | bellard | case 0x0823: |
329 | 9a64fbe4 | bellard | /* */
|
330 | 9a64fbe4 | bellard | retval = 0x03; /* no L2 cache */ |
331 | 9a64fbe4 | bellard | break;
|
332 | 9a64fbe4 | bellard | case 0x0850: |
333 | 9a64fbe4 | bellard | /* I/O map type register */
|
334 | da9b266b | bellard | retval = sysctrl->contiguous_map; |
335 | 9a64fbe4 | bellard | break;
|
336 | 9a64fbe4 | bellard | default:
|
337 | aae9366a | j_mayer | printf("ERROR: unaffected IO port: %04" PRIx32 " read\n", addr); |
338 | 9a64fbe4 | bellard | break;
|
339 | 9a64fbe4 | bellard | } |
340 | aae9366a | j_mayer | PPC_IO_DPRINTF("0x%08" PRIx32 " <= 0x%02" PRIx32 "\n", |
341 | aae9366a | j_mayer | addr - PPC_IO_BASE, retval); |
342 | 9a64fbe4 | bellard | |
343 | 9a64fbe4 | bellard | return retval;
|
344 | 9a64fbe4 | bellard | } |
345 | 9a64fbe4 | bellard | |
346 | a8170e5e | Avi Kivity | static inline hwaddr prep_IO_address(sysctrl_t *sysctrl, |
347 | a8170e5e | Avi Kivity | hwaddr addr) |
348 | da9b266b | bellard | { |
349 | da9b266b | bellard | if (sysctrl->contiguous_map == 0) { |
350 | da9b266b | bellard | /* 64 KB contiguous space for IOs */
|
351 | da9b266b | bellard | addr &= 0xFFFF;
|
352 | da9b266b | bellard | } else {
|
353 | da9b266b | bellard | /* 8 MB non-contiguous space for IOs */
|
354 | da9b266b | bellard | addr = (addr & 0x1F) | ((addr & 0x007FFF000) >> 7); |
355 | da9b266b | bellard | } |
356 | da9b266b | bellard | |
357 | da9b266b | bellard | return addr;
|
358 | da9b266b | bellard | } |
359 | da9b266b | bellard | |
360 | a8170e5e | Avi Kivity | static void PPC_prep_io_writeb (void *opaque, hwaddr addr, |
361 | da9b266b | bellard | uint32_t value) |
362 | da9b266b | bellard | { |
363 | c227f099 | Anthony Liguori | sysctrl_t *sysctrl = opaque; |
364 | da9b266b | bellard | |
365 | da9b266b | bellard | addr = prep_IO_address(sysctrl, addr); |
366 | afcea8cb | Blue Swirl | cpu_outb(addr, value); |
367 | da9b266b | bellard | } |
368 | da9b266b | bellard | |
369 | a8170e5e | Avi Kivity | static uint32_t PPC_prep_io_readb (void *opaque, hwaddr addr) |
370 | da9b266b | bellard | { |
371 | c227f099 | Anthony Liguori | sysctrl_t *sysctrl = opaque; |
372 | da9b266b | bellard | uint32_t ret; |
373 | da9b266b | bellard | |
374 | da9b266b | bellard | addr = prep_IO_address(sysctrl, addr); |
375 | afcea8cb | Blue Swirl | ret = cpu_inb(addr); |
376 | da9b266b | bellard | |
377 | da9b266b | bellard | return ret;
|
378 | da9b266b | bellard | } |
379 | da9b266b | bellard | |
380 | a8170e5e | Avi Kivity | static void PPC_prep_io_writew (void *opaque, hwaddr addr, |
381 | da9b266b | bellard | uint32_t value) |
382 | da9b266b | bellard | { |
383 | c227f099 | Anthony Liguori | sysctrl_t *sysctrl = opaque; |
384 | da9b266b | bellard | |
385 | da9b266b | bellard | addr = prep_IO_address(sysctrl, addr); |
386 | 90e189ec | Blue Swirl | PPC_IO_DPRINTF("0x" TARGET_FMT_plx " => 0x%08" PRIx32 "\n", addr, value); |
387 | afcea8cb | Blue Swirl | cpu_outw(addr, value); |
388 | da9b266b | bellard | } |
389 | da9b266b | bellard | |
390 | a8170e5e | Avi Kivity | static uint32_t PPC_prep_io_readw (void *opaque, hwaddr addr) |
391 | da9b266b | bellard | { |
392 | c227f099 | Anthony Liguori | sysctrl_t *sysctrl = opaque; |
393 | da9b266b | bellard | uint32_t ret; |
394 | da9b266b | bellard | |
395 | da9b266b | bellard | addr = prep_IO_address(sysctrl, addr); |
396 | afcea8cb | Blue Swirl | ret = cpu_inw(addr); |
397 | 90e189ec | Blue Swirl | PPC_IO_DPRINTF("0x" TARGET_FMT_plx " <= 0x%08" PRIx32 "\n", addr, ret); |
398 | da9b266b | bellard | |
399 | da9b266b | bellard | return ret;
|
400 | da9b266b | bellard | } |
401 | da9b266b | bellard | |
402 | a8170e5e | Avi Kivity | static void PPC_prep_io_writel (void *opaque, hwaddr addr, |
403 | da9b266b | bellard | uint32_t value) |
404 | da9b266b | bellard | { |
405 | c227f099 | Anthony Liguori | sysctrl_t *sysctrl = opaque; |
406 | da9b266b | bellard | |
407 | da9b266b | bellard | addr = prep_IO_address(sysctrl, addr); |
408 | 90e189ec | Blue Swirl | PPC_IO_DPRINTF("0x" TARGET_FMT_plx " => 0x%08" PRIx32 "\n", addr, value); |
409 | afcea8cb | Blue Swirl | cpu_outl(addr, value); |
410 | da9b266b | bellard | } |
411 | da9b266b | bellard | |
412 | a8170e5e | Avi Kivity | static uint32_t PPC_prep_io_readl (void *opaque, hwaddr addr) |
413 | da9b266b | bellard | { |
414 | c227f099 | Anthony Liguori | sysctrl_t *sysctrl = opaque; |
415 | da9b266b | bellard | uint32_t ret; |
416 | da9b266b | bellard | |
417 | da9b266b | bellard | addr = prep_IO_address(sysctrl, addr); |
418 | afcea8cb | Blue Swirl | ret = cpu_inl(addr); |
419 | 90e189ec | Blue Swirl | PPC_IO_DPRINTF("0x" TARGET_FMT_plx " <= 0x%08" PRIx32 "\n", addr, ret); |
420 | da9b266b | bellard | |
421 | da9b266b | bellard | return ret;
|
422 | da9b266b | bellard | } |
423 | da9b266b | bellard | |
424 | 0c90c52f | Avi Kivity | static const MemoryRegionOps PPC_prep_io_ops = { |
425 | 0c90c52f | Avi Kivity | .old_mmio = { |
426 | 0c90c52f | Avi Kivity | .read = { PPC_prep_io_readb, PPC_prep_io_readw, PPC_prep_io_readl }, |
427 | 0c90c52f | Avi Kivity | .write = { PPC_prep_io_writeb, PPC_prep_io_writew, PPC_prep_io_writel }, |
428 | 0c90c52f | Avi Kivity | }, |
429 | 0c90c52f | Avi Kivity | .endianness = DEVICE_LITTLE_ENDIAN, |
430 | da9b266b | bellard | }; |
431 | da9b266b | bellard | |
432 | 64201201 | bellard | #define NVRAM_SIZE 0x2000 |
433 | a541f297 | bellard | |
434 | 4556bd8b | Blue Swirl | static void cpu_request_exit(void *opaque, int irq, int level) |
435 | 4556bd8b | Blue Swirl | { |
436 | e2684c0b | Andreas Färber | CPUPPCState *env = cpu_single_env; |
437 | 4556bd8b | Blue Swirl | |
438 | 4556bd8b | Blue Swirl | if (env && level) {
|
439 | 4556bd8b | Blue Swirl | cpu_exit(env); |
440 | 4556bd8b | Blue Swirl | } |
441 | 4556bd8b | Blue Swirl | } |
442 | 4556bd8b | Blue Swirl | |
443 | 1bba0dc9 | Andreas Färber | static void ppc_prep_reset(void *opaque) |
444 | 1bba0dc9 | Andreas Färber | { |
445 | 5c3e735f | Andreas Färber | PowerPCCPU *cpu = opaque; |
446 | 1bba0dc9 | Andreas Färber | |
447 | 5c3e735f | Andreas Färber | cpu_reset(CPU(cpu)); |
448 | 1bba0dc9 | Andreas Färber | } |
449 | 1bba0dc9 | Andreas Färber | |
450 | 26aa7d72 | bellard | /* PowerPC PREP hardware initialisation */
|
451 | 5f072e1f | Eduardo Habkost | static void ppc_prep_init(QEMUMachineInitArgs *args) |
452 | a541f297 | bellard | { |
453 | 5f072e1f | Eduardo Habkost | ram_addr_t ram_size = args->ram_size; |
454 | 5f072e1f | Eduardo Habkost | const char *cpu_model = args->cpu_model; |
455 | 5f072e1f | Eduardo Habkost | const char *kernel_filename = args->kernel_filename; |
456 | 5f072e1f | Eduardo Habkost | const char *kernel_cmdline = args->kernel_cmdline; |
457 | 5f072e1f | Eduardo Habkost | const char *initrd_filename = args->initrd_filename; |
458 | 5f072e1f | Eduardo Habkost | const char *boot_device = args->boot_device; |
459 | 0c90c52f | Avi Kivity | MemoryRegion *sysmem = get_system_memory(); |
460 | a9bf3df0 | Andreas Färber | PowerPCCPU *cpu = NULL;
|
461 | e2684c0b | Andreas Färber | CPUPPCState *env = NULL;
|
462 | 5cea8590 | Paul Brook | char *filename;
|
463 | c227f099 | Anthony Liguori | nvram_t nvram; |
464 | 43a34704 | Blue Swirl | M48t59State *m48t59; |
465 | 0c90c52f | Avi Kivity | MemoryRegion *PPC_io_memory = g_new(MemoryRegion, 1);
|
466 | 0c90c52f | Avi Kivity | #if 0
|
467 | 0c90c52f | Avi Kivity | MemoryRegion *xcsr = g_new(MemoryRegion, 1);
|
468 | 0c90c52f | Avi Kivity | #endif
|
469 | 4157a662 | bellard | int linux_boot, i, nb_nics1, bios_size;
|
470 | 0c90c52f | Avi Kivity | MemoryRegion *ram = g_new(MemoryRegion, 1);
|
471 | 0c90c52f | Avi Kivity | MemoryRegion *bios = g_new(MemoryRegion, 1);
|
472 | 093209cd | Blue Swirl | uint32_t kernel_base, initrd_base; |
473 | 093209cd | Blue Swirl | long kernel_size, initrd_size;
|
474 | 8ca8c7bc | Andreas Färber | DeviceState *dev; |
475 | 8ca8c7bc | Andreas Färber | PCIHostState *pcihost; |
476 | 46e50e9d | bellard | PCIBus *pci_bus; |
477 | 506b7ddf | Andreas Färber | PCIDevice *pci; |
478 | 48a18b3c | Hervé Poussineau | ISABus *isa_bus; |
479 | 4556bd8b | Blue Swirl | qemu_irq *cpu_exit_irq; |
480 | 28c5af54 | j_mayer | int ppc_boot_device;
|
481 | f455e98c | Gerd Hoffmann | DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; |
482 | fd8014e1 | Gerd Hoffmann | DriveInfo *fd[MAX_FD]; |
483 | 64201201 | bellard | |
484 | 7267c094 | Anthony Liguori | sysctrl = g_malloc0(sizeof(sysctrl_t));
|
485 | a541f297 | bellard | |
486 | a541f297 | bellard | linux_boot = (kernel_filename != NULL);
|
487 | 0a032cbe | j_mayer | |
488 | c68ea704 | bellard | /* init CPUs */
|
489 | 94fc95cd | j_mayer | if (cpu_model == NULL) |
490 | b37fc148 | Gerd Hoffmann | cpu_model = "602";
|
491 | fe33cc71 | j_mayer | for (i = 0; i < smp_cpus; i++) { |
492 | a9bf3df0 | Andreas Färber | cpu = cpu_ppc_init(cpu_model); |
493 | a9bf3df0 | Andreas Färber | if (cpu == NULL) { |
494 | aaed909a | bellard | fprintf(stderr, "Unable to find PowerPC CPU definition\n");
|
495 | aaed909a | bellard | exit(1);
|
496 | aaed909a | bellard | } |
497 | a9bf3df0 | Andreas Färber | env = &cpu->env; |
498 | a9bf3df0 | Andreas Färber | |
499 | 4018bae9 | j_mayer | if (env->flags & POWERPC_FLAG_RTC_CLK) {
|
500 | 4018bae9 | j_mayer | /* POWER / PowerPC 601 RTC clock frequency is 7.8125 MHz */
|
501 | 4018bae9 | j_mayer | cpu_ppc_tb_init(env, 7812500UL);
|
502 | 4018bae9 | j_mayer | } else {
|
503 | 4018bae9 | j_mayer | /* Set time-base frequency to 100 Mhz */
|
504 | 4018bae9 | j_mayer | cpu_ppc_tb_init(env, 100UL * 1000UL * 1000UL); |
505 | 4018bae9 | j_mayer | } |
506 | 5c3e735f | Andreas Färber | qemu_register_reset(ppc_prep_reset, cpu); |
507 | fe33cc71 | j_mayer | } |
508 | a541f297 | bellard | |
509 | a541f297 | bellard | /* allocate RAM */
|
510 | c5705a77 | Avi Kivity | memory_region_init_ram(ram, "ppc_prep.ram", ram_size);
|
511 | c5705a77 | Avi Kivity | vmstate_register_ram_global(ram); |
512 | 0c90c52f | Avi Kivity | memory_region_add_subregion(sysmem, 0, ram);
|
513 | cf9c147c | blueswir1 | |
514 | 64201201 | bellard | /* allocate and load BIOS */
|
515 | c5705a77 | Avi Kivity | memory_region_init_ram(bios, "ppc_prep.bios", BIOS_SIZE);
|
516 | 809680c0 | Andreas Färber | memory_region_set_readonly(bios, true);
|
517 | 809680c0 | Andreas Färber | memory_region_add_subregion(sysmem, (uint32_t)(-BIOS_SIZE), bios); |
518 | c5705a77 | Avi Kivity | vmstate_register_ram_global(bios); |
519 | 1192dad8 | j_mayer | if (bios_name == NULL) |
520 | 1192dad8 | j_mayer | bios_name = BIOS_FILENAME; |
521 | 5cea8590 | Paul Brook | filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); |
522 | 5cea8590 | Paul Brook | if (filename) {
|
523 | 5cea8590 | Paul Brook | bios_size = get_image_size(filename); |
524 | 5cea8590 | Paul Brook | } else {
|
525 | 5cea8590 | Paul Brook | bios_size = -1;
|
526 | 5cea8590 | Paul Brook | } |
527 | dcac9679 | pbrook | if (bios_size > 0 && bios_size <= BIOS_SIZE) { |
528 | a8170e5e | Avi Kivity | hwaddr bios_addr; |
529 | dcac9679 | pbrook | bios_size = (bios_size + 0xfff) & ~0xfff; |
530 | dcac9679 | pbrook | bios_addr = (uint32_t)(-bios_size); |
531 | 5cea8590 | Paul Brook | bios_size = load_image_targphys(filename, bios_addr, bios_size); |
532 | dcac9679 | pbrook | } |
533 | 4157a662 | bellard | if (bios_size < 0 || bios_size > BIOS_SIZE) { |
534 | 5cea8590 | Paul Brook | hw_error("qemu: could not load PPC PREP bios '%s'\n", bios_name);
|
535 | 5cea8590 | Paul Brook | } |
536 | 5cea8590 | Paul Brook | if (filename) {
|
537 | 7267c094 | Anthony Liguori | g_free(filename); |
538 | 64201201 | bellard | } |
539 | 26aa7d72 | bellard | |
540 | a541f297 | bellard | if (linux_boot) {
|
541 | 64201201 | bellard | kernel_base = KERNEL_LOAD_ADDR; |
542 | a541f297 | bellard | /* now we can load the kernel */
|
543 | dcac9679 | pbrook | kernel_size = load_image_targphys(kernel_filename, kernel_base, |
544 | dcac9679 | pbrook | ram_size - kernel_base); |
545 | 64201201 | bellard | if (kernel_size < 0) { |
546 | 2ac71179 | Paul Brook | hw_error("qemu: could not load kernel '%s'\n", kernel_filename);
|
547 | a541f297 | bellard | exit(1);
|
548 | a541f297 | bellard | } |
549 | a541f297 | bellard | /* load initrd */
|
550 | a541f297 | bellard | if (initrd_filename) {
|
551 | 64201201 | bellard | initrd_base = INITRD_LOAD_ADDR; |
552 | dcac9679 | pbrook | initrd_size = load_image_targphys(initrd_filename, initrd_base, |
553 | dcac9679 | pbrook | ram_size - initrd_base); |
554 | a541f297 | bellard | if (initrd_size < 0) { |
555 | 2ac71179 | Paul Brook | hw_error("qemu: could not load initial ram disk '%s'\n",
|
556 | 4a057712 | j_mayer | initrd_filename); |
557 | a541f297 | bellard | } |
558 | 64201201 | bellard | } else {
|
559 | 64201201 | bellard | initrd_base = 0;
|
560 | 64201201 | bellard | initrd_size = 0;
|
561 | a541f297 | bellard | } |
562 | 6ac0e82d | balrog | ppc_boot_device = 'm';
|
563 | a541f297 | bellard | } else {
|
564 | 64201201 | bellard | kernel_base = 0;
|
565 | 64201201 | bellard | kernel_size = 0;
|
566 | 64201201 | bellard | initrd_base = 0;
|
567 | 64201201 | bellard | initrd_size = 0;
|
568 | 28c5af54 | j_mayer | ppc_boot_device = '\0';
|
569 | 28c5af54 | j_mayer | /* For now, OHW cannot boot from the network. */
|
570 | 0d913fdb | j_mayer | for (i = 0; boot_device[i] != '\0'; i++) { |
571 | 0d913fdb | j_mayer | if (boot_device[i] >= 'a' && boot_device[i] <= 'f') { |
572 | 0d913fdb | j_mayer | ppc_boot_device = boot_device[i]; |
573 | 28c5af54 | j_mayer | break;
|
574 | 0d913fdb | j_mayer | } |
575 | 28c5af54 | j_mayer | } |
576 | 28c5af54 | j_mayer | if (ppc_boot_device == '\0') { |
577 | 28c5af54 | j_mayer | fprintf(stderr, "No valid boot device for Mac99 machine\n");
|
578 | 28c5af54 | j_mayer | exit(1);
|
579 | 28c5af54 | j_mayer | } |
580 | a541f297 | bellard | } |
581 | a541f297 | bellard | |
582 | dd37a5e4 | j_mayer | if (PPC_INPUT(env) != PPC_FLAGS_INPUT_6xx) {
|
583 | 2ac71179 | Paul Brook | hw_error("Only 6xx bus is supported on PREP machine\n");
|
584 | dd37a5e4 | j_mayer | } |
585 | 8ca8c7bc | Andreas Färber | |
586 | 8ca8c7bc | Andreas Färber | dev = qdev_create(NULL, "raven-pcihost"); |
587 | 8558d942 | Andreas Färber | pcihost = PCI_HOST_BRIDGE(dev); |
588 | 8ca8c7bc | Andreas Färber | pcihost->address_space = get_system_memory(); |
589 | f05f6b4a | Paolo Bonzini | object_property_add_child(qdev_get_machine(), "raven", OBJECT(dev), NULL); |
590 | f424d5c4 | Paolo Bonzini | qdev_init_nofail(dev); |
591 | 8ca8c7bc | Andreas Färber | pci_bus = (PCIBus *)qdev_get_child_bus(dev, "pci.0");
|
592 | 8ca8c7bc | Andreas Färber | if (pci_bus == NULL) { |
593 | 8ca8c7bc | Andreas Färber | fprintf(stderr, "Couldn't create PCI host controller.\n");
|
594 | 8ca8c7bc | Andreas Färber | exit(1);
|
595 | 8ca8c7bc | Andreas Färber | } |
596 | 8ca8c7bc | Andreas Färber | |
597 | 506b7ddf | Andreas Färber | /* PCI -> ISA bridge */
|
598 | 506b7ddf | Andreas Färber | pci = pci_create_simple(pci_bus, PCI_DEVFN(1, 0), "i82378"); |
599 | 506b7ddf | Andreas Färber | cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1); |
600 | 506b7ddf | Andreas Färber | qdev_connect_gpio_out(&pci->qdev, 0,
|
601 | 506b7ddf | Andreas Färber | first_cpu->irq_inputs[PPC6xx_INPUT_INT]); |
602 | 506b7ddf | Andreas Färber | qdev_connect_gpio_out(&pci->qdev, 1, *cpu_exit_irq);
|
603 | 506b7ddf | Andreas Färber | sysbus_connect_irq(&pcihost->busdev, 0, qdev_get_gpio_in(&pci->qdev, 9)); |
604 | 506b7ddf | Andreas Färber | sysbus_connect_irq(&pcihost->busdev, 1, qdev_get_gpio_in(&pci->qdev, 11)); |
605 | 506b7ddf | Andreas Färber | sysbus_connect_irq(&pcihost->busdev, 2, qdev_get_gpio_in(&pci->qdev, 9)); |
606 | 506b7ddf | Andreas Färber | sysbus_connect_irq(&pcihost->busdev, 3, qdev_get_gpio_in(&pci->qdev, 11)); |
607 | 506b7ddf | Andreas Färber | isa_bus = DO_UPCAST(ISABus, qbus, qdev_get_child_bus(&pci->qdev, "isa.0"));
|
608 | 506b7ddf | Andreas Färber | |
609 | da9b266b | bellard | /* Register 8 MB of ISA IO space (needed for non-contiguous map) */
|
610 | 0c90c52f | Avi Kivity | memory_region_init_io(PPC_io_memory, &PPC_prep_io_ops, sysctrl, |
611 | 0c90c52f | Avi Kivity | "ppc-io", 0x00800000); |
612 | 0c90c52f | Avi Kivity | memory_region_add_subregion(sysmem, 0x80000000, PPC_io_memory);
|
613 | 64201201 | bellard | |
614 | a541f297 | bellard | /* init basic PC hardware */
|
615 | 95fa01fa | Aurelien Jarno | pci_vga_init(pci_bus); |
616 | a541f297 | bellard | |
617 | ac0be998 | Gerd Hoffmann | if (serial_hds[0]) |
618 | 48a18b3c | Hervé Poussineau | serial_isa_init(isa_bus, 0, serial_hds[0]); |
619 | a541f297 | bellard | nb_nics1 = nb_nics; |
620 | a541f297 | bellard | if (nb_nics1 > NE2000_NB_MAX)
|
621 | a541f297 | bellard | nb_nics1 = NE2000_NB_MAX; |
622 | a541f297 | bellard | for(i = 0; i < nb_nics1; i++) { |
623 | 5652ef78 | aurel32 | if (nd_table[i].model == NULL) { |
624 | 7267c094 | Anthony Liguori | nd_table[i].model = g_strdup("ne2k_isa");
|
625 | 5652ef78 | aurel32 | } |
626 | 5652ef78 | aurel32 | if (strcmp(nd_table[i].model, "ne2k_isa") == 0) { |
627 | 48a18b3c | Hervé Poussineau | isa_ne2000_init(isa_bus, ne2000_io[i], ne2000_irq[i], |
628 | 48a18b3c | Hervé Poussineau | &nd_table[i]); |
629 | a41b2ff2 | pbrook | } else {
|
630 | 07caea31 | Markus Armbruster | pci_nic_init_nofail(&nd_table[i], "ne2k_pci", NULL); |
631 | a41b2ff2 | pbrook | } |
632 | a541f297 | bellard | } |
633 | a541f297 | bellard | |
634 | 75717903 | Isaku Yamahata | ide_drive_get(hd, MAX_IDE_BUS); |
635 | 81aa0647 | Aurelien Jarno | for(i = 0; i < MAX_IDE_BUS; i++) { |
636 | 48a18b3c | Hervé Poussineau | isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i], ide_irq[i], |
637 | e4bcb14c | ths | hd[2 * i],
|
638 | e4bcb14c | ths | hd[2 * i + 1]); |
639 | a541f297 | bellard | } |
640 | 48a18b3c | Hervé Poussineau | isa_create_simple(isa_bus, "i8042");
|
641 | 4556bd8b | Blue Swirl | |
642 | a541f297 | bellard | // SB16_init();
|
643 | a541f297 | bellard | |
644 | e4bcb14c | ths | for(i = 0; i < MAX_FD; i++) { |
645 | fd8014e1 | Gerd Hoffmann | fd[i] = drive_get(IF_FLOPPY, 0, i);
|
646 | e4bcb14c | ths | } |
647 | 48a18b3c | Hervé Poussineau | fdctrl_init_isa(isa_bus, fd); |
648 | a541f297 | bellard | |
649 | a541f297 | bellard | /* Register fake IO ports for PREP */
|
650 | c4781a51 | j_mayer | sysctrl->reset_irq = first_cpu->irq_inputs[PPC6xx_INPUT_HRESET]; |
651 | 64201201 | bellard | register_ioport_read(0x398, 2, 1, &PREP_io_read, sysctrl); |
652 | 64201201 | bellard | register_ioport_write(0x398, 2, 1, &PREP_io_write, sysctrl); |
653 | a541f297 | bellard | /* System control ports */
|
654 | 64201201 | bellard | register_ioport_read(0x0092, 0x01, 1, &PREP_io_800_readb, sysctrl); |
655 | 64201201 | bellard | register_ioport_write(0x0092, 0x01, 1, &PREP_io_800_writeb, sysctrl); |
656 | 64201201 | bellard | register_ioport_read(0x0800, 0x52, 1, &PREP_io_800_readb, sysctrl); |
657 | 64201201 | bellard | register_ioport_write(0x0800, 0x52, 1, &PREP_io_800_writeb, sysctrl); |
658 | 64201201 | bellard | /* PowerPC control and status register group */
|
659 | b6b8bd18 | bellard | #if 0
|
660 | 0c90c52f | Avi Kivity | memory_region_init_io(xcsr, &PPC_XCSR_ops, NULL, "ppc-xcsr", 0x1000);
|
661 | 0c90c52f | Avi Kivity | memory_region_add_subregion(sysmem, 0xFEFF0000, xcsr);
|
662 | b6b8bd18 | bellard | #endif
|
663 | a541f297 | bellard | |
664 | 094b287f | zhlcindy@gmail.com | if (usb_enabled(false)) { |
665 | afb9a60e | Gerd Hoffmann | pci_create_simple(pci_bus, -1, "pci-ohci"); |
666 | 0d92ed30 | pbrook | } |
667 | 0d92ed30 | pbrook | |
668 | 48e93728 | Andreas Färber | m48t59 = m48t59_init_isa(isa_bus, 0x0074, NVRAM_SIZE, 59); |
669 | 3cbee15b | j_mayer | if (m48t59 == NULL) |
670 | 64201201 | bellard | return;
|
671 | 3cbee15b | j_mayer | sysctrl->nvram = m48t59; |
672 | 64201201 | bellard | |
673 | 64201201 | bellard | /* Initialise NVRAM */
|
674 | 3cbee15b | j_mayer | nvram.opaque = m48t59; |
675 | 3cbee15b | j_mayer | nvram.read_fn = &m48t59_read; |
676 | 3cbee15b | j_mayer | nvram.write_fn = &m48t59_write; |
677 | 6ac0e82d | balrog | PPC_NVRAM_set_params(&nvram, NVRAM_SIZE, "PREP", ram_size, ppc_boot_device,
|
678 | 64201201 | bellard | kernel_base, kernel_size, |
679 | b6b8bd18 | bellard | kernel_cmdline, |
680 | 64201201 | bellard | initrd_base, initrd_size, |
681 | 64201201 | bellard | /* XXX: need an option to load a NVRAM image */
|
682 | b6b8bd18 | bellard | 0,
|
683 | b6b8bd18 | bellard | graphic_width, graphic_height, graphic_depth); |
684 | c0e564d5 | bellard | |
685 | c0e564d5 | bellard | /* Special port to get debug messages from Open-Firmware */
|
686 | c0e564d5 | bellard | register_ioport_write(0x0F00, 4, 1, &PPC_debug_write, NULL); |
687 | 9357b144 | Hervé Poussineau | |
688 | 9357b144 | Hervé Poussineau | /* Initialize audio subsystem */
|
689 | 9357b144 | Hervé Poussineau | audio_init(isa_bus, pci_bus); |
690 | a541f297 | bellard | } |
691 | c0e564d5 | bellard | |
692 | f80f9ec9 | Anthony Liguori | static QEMUMachine prep_machine = {
|
693 | 4b32e168 | aliguori | .name = "prep",
|
694 | 4b32e168 | aliguori | .desc = "PowerPC PREP platform",
|
695 | 4b32e168 | aliguori | .init = ppc_prep_init, |
696 | 3d878caa | balrog | .max_cpus = MAX_CPUS, |
697 | c0e564d5 | bellard | }; |
698 | f80f9ec9 | Anthony Liguori | |
699 | f80f9ec9 | Anthony Liguori | static void prep_machine_init(void) |
700 | f80f9ec9 | Anthony Liguori | { |
701 | f80f9ec9 | Anthony Liguori | qemu_register_machine(&prep_machine); |
702 | f80f9ec9 | Anthony Liguori | } |
703 | f80f9ec9 | Anthony Liguori | |
704 | f80f9ec9 | Anthony Liguori | machine_init(prep_machine_init); |