root / hw / ppc_prep.c @ 40f16dd1
History | View | Annotate | Download (21.7 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 | 87ecb68b | pbrook | #include "fdc.h" |
28 | 87ecb68b | pbrook | #include "net.h" |
29 | 87ecb68b | pbrook | #include "sysemu.h" |
30 | 87ecb68b | pbrook | #include "isa.h" |
31 | 87ecb68b | pbrook | #include "pci.h" |
32 | 18e08a55 | Michael S. Tsirkin | #include "prep_pci.h" |
33 | 18e08a55 | Michael S. Tsirkin | #include "usb-ohci.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 | 9fddaa0c | bellard | |
42 | 9a64fbe4 | bellard | //#define HARD_DEBUG_PPC_IO
|
43 | a541f297 | bellard | //#define DEBUG_PPC_IO
|
44 | 9a64fbe4 | bellard | |
45 | fe33cc71 | j_mayer | /* SMP is not enabled, for now */
|
46 | fe33cc71 | j_mayer | #define MAX_CPUS 1 |
47 | fe33cc71 | j_mayer | |
48 | e4bcb14c | ths | #define MAX_IDE_BUS 2 |
49 | e4bcb14c | ths | |
50 | bba831e8 | Paul Brook | #define BIOS_SIZE (1024 * 1024) |
51 | b6b8bd18 | bellard | #define BIOS_FILENAME "ppc_rom.bin" |
52 | b6b8bd18 | bellard | #define KERNEL_LOAD_ADDR 0x01000000 |
53 | b6b8bd18 | bellard | #define INITRD_LOAD_ADDR 0x01800000 |
54 | 64201201 | bellard | |
55 | 9a64fbe4 | bellard | #if defined (HARD_DEBUG_PPC_IO) && !defined (DEBUG_PPC_IO)
|
56 | 9a64fbe4 | bellard | #define DEBUG_PPC_IO
|
57 | 9a64fbe4 | bellard | #endif
|
58 | 9a64fbe4 | bellard | |
59 | 9a64fbe4 | bellard | #if defined (HARD_DEBUG_PPC_IO)
|
60 | 001faf32 | Blue Swirl | #define PPC_IO_DPRINTF(fmt, ...) \
|
61 | 9a64fbe4 | bellard | do { \
|
62 | 8fec2b8c | aliguori | if (qemu_loglevel_mask(CPU_LOG_IOPORT)) { \
|
63 | 001faf32 | Blue Swirl | qemu_log("%s: " fmt, __func__ , ## __VA_ARGS__); \ |
64 | 9a64fbe4 | bellard | } else { \
|
65 | 001faf32 | Blue Swirl | printf("%s : " fmt, __func__ , ## __VA_ARGS__); \ |
66 | 9a64fbe4 | bellard | } \ |
67 | 9a64fbe4 | bellard | } while (0) |
68 | 9a64fbe4 | bellard | #elif defined (DEBUG_PPC_IO)
|
69 | 0bf9e31a | Blue Swirl | #define PPC_IO_DPRINTF(fmt, ...) \
|
70 | 0bf9e31a | Blue Swirl | qemu_log_mask(CPU_LOG_IOPORT, fmt, ## __VA_ARGS__) |
71 | 9a64fbe4 | bellard | #else
|
72 | 001faf32 | Blue Swirl | #define PPC_IO_DPRINTF(fmt, ...) do { } while (0) |
73 | 9a64fbe4 | bellard | #endif
|
74 | 9a64fbe4 | bellard | |
75 | 64201201 | bellard | /* Constants for devices init */
|
76 | a541f297 | bellard | static const int ide_iobase[2] = { 0x1f0, 0x170 }; |
77 | a541f297 | bellard | static const int ide_iobase2[2] = { 0x3f6, 0x376 }; |
78 | a541f297 | bellard | static const int ide_irq[2] = { 13, 13 }; |
79 | a541f297 | bellard | |
80 | a541f297 | bellard | #define NE2000_NB_MAX 6 |
81 | a541f297 | bellard | |
82 | a541f297 | bellard | static uint32_t ne2000_io[NE2000_NB_MAX] = { 0x300, 0x320, 0x340, 0x360, 0x280, 0x380 }; |
83 | a541f297 | bellard | static int ne2000_irq[NE2000_NB_MAX] = { 9, 10, 11, 3, 4, 5 }; |
84 | 9a64fbe4 | bellard | |
85 | 64d7e9a4 | Blue Swirl | //static ISADevice *pit;
|
86 | 64201201 | bellard | |
87 | 64201201 | bellard | /* ISA IO ports bridge */
|
88 | 9a64fbe4 | bellard | #define PPC_IO_BASE 0x80000000 |
89 | 9a64fbe4 | bellard | |
90 | b1d8e52e | blueswir1 | #if 0
|
91 | 64201201 | bellard | /* Speaker port 0x61 */
|
92 | b1d8e52e | blueswir1 | static int speaker_data_on;
|
93 | b1d8e52e | blueswir1 | static int dummy_refresh_clock;
|
94 | b1d8e52e | blueswir1 | #endif
|
95 | 64201201 | bellard | |
96 | 36081602 | j_mayer | static void speaker_ioport_write (void *opaque, uint32_t addr, uint32_t val) |
97 | 9a64fbe4 | bellard | { |
98 | a541f297 | bellard | #if 0
|
99 | 64201201 | bellard | speaker_data_on = (val >> 1) & 1;
|
100 | 64201201 | bellard | pit_set_gate(pit, 2, val & 1);
|
101 | a541f297 | bellard | #endif
|
102 | 9a64fbe4 | bellard | } |
103 | 9a64fbe4 | bellard | |
104 | 47103572 | j_mayer | static uint32_t speaker_ioport_read (void *opaque, uint32_t addr) |
105 | 9a64fbe4 | bellard | { |
106 | a541f297 | bellard | #if 0
|
107 | 64201201 | bellard | int out;
|
108 | 74475455 | Paolo Bonzini | out = pit_get_out(pit, 2, qemu_get_clock_ns(vm_clock));
|
109 | 64201201 | bellard | dummy_refresh_clock ^= 1;
|
110 | 64201201 | bellard | return (speaker_data_on << 1) | pit_get_gate(pit, 2) | (out << 5) |
|
111 | 47103572 | j_mayer | (dummy_refresh_clock << 4);
|
112 | a541f297 | bellard | #endif
|
113 | 64201201 | bellard | return 0; |
114 | 9a64fbe4 | bellard | } |
115 | 9a64fbe4 | bellard | |
116 | 64201201 | bellard | /* PCI intack register */
|
117 | 64201201 | bellard | /* Read-only register (?) */
|
118 | 47103572 | j_mayer | static void _PPC_intack_write (void *opaque, |
119 | c227f099 | Anthony Liguori | target_phys_addr_t addr, uint32_t value) |
120 | 64201201 | bellard | { |
121 | 90e189ec | Blue Swirl | #if 0
|
122 | 90e189ec | Blue Swirl | printf("%s: 0x" TARGET_FMT_plx " => 0x%08" PRIx32 "\n", __func__, addr,
|
123 | 90e189ec | Blue Swirl | value);
|
124 | 90e189ec | Blue Swirl | #endif
|
125 | 64201201 | bellard | } |
126 | 64201201 | bellard | |
127 | c227f099 | Anthony Liguori | static inline uint32_t _PPC_intack_read(target_phys_addr_t addr) |
128 | 64201201 | bellard | { |
129 | 64201201 | bellard | uint32_t retval = 0;
|
130 | 64201201 | bellard | |
131 | 4dd8c138 | aurel32 | if ((addr & 0xf) == 0) |
132 | 3de388f6 | bellard | retval = pic_intack_read(isa_pic); |
133 | 90e189ec | Blue Swirl | #if 0
|
134 | 90e189ec | Blue Swirl | printf("%s: 0x" TARGET_FMT_plx " <= %08" PRIx32 "\n", __func__, addr,
|
135 | 90e189ec | Blue Swirl | retval);
|
136 | 90e189ec | Blue Swirl | #endif
|
137 | 64201201 | bellard | |
138 | 64201201 | bellard | return retval;
|
139 | 64201201 | bellard | } |
140 | 64201201 | bellard | |
141 | c227f099 | Anthony Liguori | static uint32_t PPC_intack_readb (void *opaque, target_phys_addr_t addr) |
142 | 64201201 | bellard | { |
143 | 64201201 | bellard | return _PPC_intack_read(addr);
|
144 | 64201201 | bellard | } |
145 | 64201201 | bellard | |
146 | c227f099 | Anthony Liguori | static uint32_t PPC_intack_readw (void *opaque, target_phys_addr_t addr) |
147 | 9a64fbe4 | bellard | { |
148 | 64201201 | bellard | return _PPC_intack_read(addr);
|
149 | 9a64fbe4 | bellard | } |
150 | 9a64fbe4 | bellard | |
151 | c227f099 | Anthony Liguori | static uint32_t PPC_intack_readl (void *opaque, target_phys_addr_t addr) |
152 | 9a64fbe4 | bellard | { |
153 | 64201201 | bellard | return _PPC_intack_read(addr);
|
154 | 9a64fbe4 | bellard | } |
155 | 9a64fbe4 | bellard | |
156 | d60efc6b | Blue Swirl | static CPUWriteMemoryFunc * const PPC_intack_write[] = { |
157 | 64201201 | bellard | &_PPC_intack_write, |
158 | 64201201 | bellard | &_PPC_intack_write, |
159 | 64201201 | bellard | &_PPC_intack_write, |
160 | 64201201 | bellard | }; |
161 | 64201201 | bellard | |
162 | d60efc6b | Blue Swirl | static CPUReadMemoryFunc * const PPC_intack_read[] = { |
163 | 64201201 | bellard | &PPC_intack_readb, |
164 | 64201201 | bellard | &PPC_intack_readw, |
165 | 64201201 | bellard | &PPC_intack_readl, |
166 | 64201201 | bellard | }; |
167 | 64201201 | bellard | |
168 | 64201201 | bellard | /* PowerPC control and status registers */
|
169 | 64201201 | bellard | #if 0 // Not used
|
170 | 64201201 | bellard | static struct {
|
171 | 64201201 | bellard | /* IDs */
|
172 | 64201201 | bellard | uint32_t veni_devi;
|
173 | 64201201 | bellard | uint32_t revi;
|
174 | 64201201 | bellard | /* Control and status */
|
175 | 64201201 | bellard | uint32_t gcsr;
|
176 | 64201201 | bellard | uint32_t xcfr;
|
177 | 64201201 | bellard | uint32_t ct32;
|
178 | 64201201 | bellard | uint32_t mcsr;
|
179 | 64201201 | bellard | /* General purpose registers */
|
180 | 64201201 | bellard | uint32_t gprg[6];
|
181 | 64201201 | bellard | /* Exceptions */
|
182 | 64201201 | bellard | uint32_t feen;
|
183 | 64201201 | bellard | uint32_t fest;
|
184 | 64201201 | bellard | uint32_t fema;
|
185 | 64201201 | bellard | uint32_t fecl;
|
186 | 64201201 | bellard | uint32_t eeen;
|
187 | 64201201 | bellard | uint32_t eest;
|
188 | 64201201 | bellard | uint32_t eecl;
|
189 | 64201201 | bellard | uint32_t eeint;
|
190 | 64201201 | bellard | uint32_t eemck0;
|
191 | 64201201 | bellard | uint32_t eemck1;
|
192 | 64201201 | bellard | /* Error diagnostic */
|
193 | 64201201 | bellard | } XCSR;
|
194 | 64201201 | bellard | |
195 | 36081602 | j_mayer | static void PPC_XCSR_writeb (void *opaque,
|
196 | c227f099 | Anthony Liguori | target_phys_addr_t addr, uint32_t value)
|
197 | 64201201 | bellard | {
|
198 | 90e189ec | Blue Swirl | printf("%s: 0x" TARGET_FMT_plx " => 0x%08" PRIx32 "\n", __func__, addr,
|
199 | 90e189ec | Blue Swirl | value);
|
200 | 64201201 | bellard | }
|
201 | 64201201 | bellard | |
202 | 36081602 | j_mayer | static void PPC_XCSR_writew (void *opaque,
|
203 | c227f099 | Anthony Liguori | target_phys_addr_t addr, uint32_t value)
|
204 | 9a64fbe4 | bellard | {
|
205 | 90e189ec | Blue Swirl | printf("%s: 0x" TARGET_FMT_plx " => 0x%08" PRIx32 "\n", __func__, addr,
|
206 | 90e189ec | Blue Swirl | value);
|
207 | 9a64fbe4 | bellard | }
|
208 | 9a64fbe4 | bellard | |
209 | 36081602 | j_mayer | static void PPC_XCSR_writel (void *opaque,
|
210 | c227f099 | Anthony Liguori | target_phys_addr_t addr, uint32_t value)
|
211 | 9a64fbe4 | bellard | {
|
212 | 90e189ec | Blue Swirl | printf("%s: 0x" TARGET_FMT_plx " => 0x%08" PRIx32 "\n", __func__, addr,
|
213 | 90e189ec | Blue Swirl | value);
|
214 | 9a64fbe4 | bellard | }
|
215 | 9a64fbe4 | bellard | |
216 | c227f099 | Anthony Liguori | static uint32_t PPC_XCSR_readb (void *opaque, target_phys_addr_t addr)
|
217 | 64201201 | bellard | {
|
218 | 64201201 | bellard | uint32_t retval = 0;
|
219 | 9a64fbe4 | bellard | |
220 | 90e189ec | Blue Swirl | printf("%s: 0x" TARGET_FMT_plx " <= %08" PRIx32 "\n", __func__, addr,
|
221 | 90e189ec | Blue Swirl | retval);
|
222 | 9a64fbe4 | bellard | |
223 | 64201201 | bellard | return retval;
|
224 | 64201201 | bellard | }
|
225 | 64201201 | bellard | |
226 | c227f099 | Anthony Liguori | static uint32_t PPC_XCSR_readw (void *opaque, target_phys_addr_t addr)
|
227 | 9a64fbe4 | bellard | {
|
228 | 64201201 | bellard | uint32_t retval = 0;
|
229 | 64201201 | bellard | |
230 | 90e189ec | Blue Swirl | printf("%s: 0x" TARGET_FMT_plx " <= %08" PRIx32 "\n", __func__, addr,
|
231 | 90e189ec | Blue Swirl | retval);
|
232 | 64201201 | bellard | |
233 | 64201201 | bellard | return retval;
|
234 | 9a64fbe4 | bellard | }
|
235 | 9a64fbe4 | bellard | |
236 | c227f099 | Anthony Liguori | static uint32_t PPC_XCSR_readl (void *opaque, target_phys_addr_t addr)
|
237 | 9a64fbe4 | bellard | {
|
238 | 9a64fbe4 | bellard | uint32_t retval = 0;
|
239 | 9a64fbe4 | bellard | |
240 | 90e189ec | Blue Swirl | printf("%s: 0x" TARGET_FMT_plx " <= %08" PRIx32 "\n", __func__, addr,
|
241 | 90e189ec | Blue Swirl | retval);
|
242 | 9a64fbe4 | bellard | |
243 | 9a64fbe4 | bellard | return retval;
|
244 | 9a64fbe4 | bellard | }
|
245 | 9a64fbe4 | bellard | |
246 | d60efc6b | Blue Swirl | static CPUWriteMemoryFunc * const PPC_XCSR_write[] = {
|
247 | 64201201 | bellard | &PPC_XCSR_writeb,
|
248 | 64201201 | bellard | &PPC_XCSR_writew,
|
249 | 64201201 | bellard | &PPC_XCSR_writel,
|
250 | 9a64fbe4 | bellard | };
|
251 | 9a64fbe4 | bellard | |
252 | d60efc6b | Blue Swirl | static CPUReadMemoryFunc * const PPC_XCSR_read[] = {
|
253 | 64201201 | bellard | &PPC_XCSR_readb,
|
254 | 64201201 | bellard | &PPC_XCSR_readw,
|
255 | 64201201 | bellard | &PPC_XCSR_readl,
|
256 | 9a64fbe4 | bellard | };
|
257 | b6b8bd18 | bellard | #endif
|
258 | 9a64fbe4 | bellard | |
259 | 64201201 | bellard | /* Fake super-io ports for PREP platform (Intel 82378ZB) */
|
260 | c227f099 | Anthony Liguori | typedef struct sysctrl_t { |
261 | c4781a51 | j_mayer | qemu_irq reset_irq; |
262 | 43a34704 | Blue Swirl | M48t59State *nvram; |
263 | 64201201 | bellard | uint8_t state; |
264 | 64201201 | bellard | uint8_t syscontrol; |
265 | 64201201 | bellard | uint8_t fake_io[2];
|
266 | da9b266b | bellard | int contiguous_map;
|
267 | fb3444b8 | bellard | int endian;
|
268 | c227f099 | Anthony Liguori | } sysctrl_t; |
269 | 9a64fbe4 | bellard | |
270 | 64201201 | bellard | enum {
|
271 | 64201201 | bellard | STATE_HARDFILE = 0x01,
|
272 | 9a64fbe4 | bellard | }; |
273 | 9a64fbe4 | bellard | |
274 | c227f099 | Anthony Liguori | static sysctrl_t *sysctrl;
|
275 | 9a64fbe4 | bellard | |
276 | a541f297 | bellard | static void PREP_io_write (void *opaque, uint32_t addr, uint32_t val) |
277 | 9a64fbe4 | bellard | { |
278 | c227f099 | Anthony Liguori | sysctrl_t *sysctrl = opaque; |
279 | 64201201 | bellard | |
280 | aae9366a | j_mayer | PPC_IO_DPRINTF("0x%08" PRIx32 " => 0x%02" PRIx32 "\n", addr - PPC_IO_BASE, |
281 | aae9366a | j_mayer | val); |
282 | 64201201 | bellard | sysctrl->fake_io[addr - 0x0398] = val;
|
283 | 9a64fbe4 | bellard | } |
284 | 9a64fbe4 | bellard | |
285 | a541f297 | bellard | static uint32_t PREP_io_read (void *opaque, uint32_t addr) |
286 | 9a64fbe4 | bellard | { |
287 | c227f099 | Anthony Liguori | sysctrl_t *sysctrl = opaque; |
288 | 9a64fbe4 | bellard | |
289 | aae9366a | j_mayer | PPC_IO_DPRINTF("0x%08" PRIx32 " <= 0x%02" PRIx32 "\n", addr - PPC_IO_BASE, |
290 | 64201201 | bellard | sysctrl->fake_io[addr - 0x0398]);
|
291 | 64201201 | bellard | return sysctrl->fake_io[addr - 0x0398]; |
292 | 64201201 | bellard | } |
293 | 9a64fbe4 | bellard | |
294 | a541f297 | bellard | static void PREP_io_800_writeb (void *opaque, uint32_t addr, uint32_t val) |
295 | 9a64fbe4 | bellard | { |
296 | c227f099 | Anthony Liguori | sysctrl_t *sysctrl = opaque; |
297 | 64201201 | bellard | |
298 | aae9366a | j_mayer | PPC_IO_DPRINTF("0x%08" PRIx32 " => 0x%02" PRIx32 "\n", |
299 | aae9366a | j_mayer | addr - PPC_IO_BASE, val); |
300 | 9a64fbe4 | bellard | switch (addr) {
|
301 | 9a64fbe4 | bellard | case 0x0092: |
302 | 9a64fbe4 | bellard | /* Special port 92 */
|
303 | 9a64fbe4 | bellard | /* Check soft reset asked */
|
304 | 64201201 | bellard | if (val & 0x01) { |
305 | c4781a51 | j_mayer | qemu_irq_raise(sysctrl->reset_irq); |
306 | c4781a51 | j_mayer | } else {
|
307 | c4781a51 | j_mayer | qemu_irq_lower(sysctrl->reset_irq); |
308 | 9a64fbe4 | bellard | } |
309 | 9a64fbe4 | bellard | /* Check LE mode */
|
310 | 64201201 | bellard | if (val & 0x02) { |
311 | fb3444b8 | bellard | sysctrl->endian = 1;
|
312 | fb3444b8 | bellard | } else {
|
313 | fb3444b8 | bellard | sysctrl->endian = 0;
|
314 | 9a64fbe4 | bellard | } |
315 | 9a64fbe4 | bellard | break;
|
316 | 64201201 | bellard | case 0x0800: |
317 | 64201201 | bellard | /* Motorola CPU configuration register : read-only */
|
318 | 64201201 | bellard | break;
|
319 | 64201201 | bellard | case 0x0802: |
320 | 64201201 | bellard | /* Motorola base module feature register : read-only */
|
321 | 64201201 | bellard | break;
|
322 | 64201201 | bellard | case 0x0803: |
323 | 64201201 | bellard | /* Motorola base module status register : read-only */
|
324 | 64201201 | bellard | break;
|
325 | 9a64fbe4 | bellard | case 0x0808: |
326 | 64201201 | bellard | /* Hardfile light register */
|
327 | 64201201 | bellard | if (val & 1) |
328 | 64201201 | bellard | sysctrl->state |= STATE_HARDFILE; |
329 | 64201201 | bellard | else
|
330 | 64201201 | bellard | sysctrl->state &= ~STATE_HARDFILE; |
331 | 9a64fbe4 | bellard | break;
|
332 | 9a64fbe4 | bellard | case 0x0810: |
333 | 9a64fbe4 | bellard | /* Password protect 1 register */
|
334 | 64201201 | bellard | if (sysctrl->nvram != NULL) |
335 | 64201201 | bellard | m48t59_toggle_lock(sysctrl->nvram, 1);
|
336 | 9a64fbe4 | bellard | break;
|
337 | 9a64fbe4 | bellard | case 0x0812: |
338 | 9a64fbe4 | bellard | /* Password protect 2 register */
|
339 | 64201201 | bellard | if (sysctrl->nvram != NULL) |
340 | 64201201 | bellard | m48t59_toggle_lock(sysctrl->nvram, 2);
|
341 | 9a64fbe4 | bellard | break;
|
342 | 9a64fbe4 | bellard | case 0x0814: |
343 | 64201201 | bellard | /* L2 invalidate register */
|
344 | c68ea704 | bellard | // tlb_flush(first_cpu, 1);
|
345 | 9a64fbe4 | bellard | break;
|
346 | 9a64fbe4 | bellard | case 0x081C: |
347 | 9a64fbe4 | bellard | /* system control register */
|
348 | 64201201 | bellard | sysctrl->syscontrol = val & 0x0F;
|
349 | 9a64fbe4 | bellard | break;
|
350 | 9a64fbe4 | bellard | case 0x0850: |
351 | 9a64fbe4 | bellard | /* I/O map type register */
|
352 | da9b266b | bellard | sysctrl->contiguous_map = val & 0x01;
|
353 | 9a64fbe4 | bellard | break;
|
354 | 9a64fbe4 | bellard | default:
|
355 | aae9366a | j_mayer | printf("ERROR: unaffected IO port write: %04" PRIx32
|
356 | aae9366a | j_mayer | " => %02" PRIx32"\n", addr, val); |
357 | 9a64fbe4 | bellard | break;
|
358 | 9a64fbe4 | bellard | } |
359 | 9a64fbe4 | bellard | } |
360 | 9a64fbe4 | bellard | |
361 | a541f297 | bellard | static uint32_t PREP_io_800_readb (void *opaque, uint32_t addr) |
362 | 9a64fbe4 | bellard | { |
363 | c227f099 | Anthony Liguori | sysctrl_t *sysctrl = opaque; |
364 | 9a64fbe4 | bellard | uint32_t retval = 0xFF;
|
365 | 9a64fbe4 | bellard | |
366 | 9a64fbe4 | bellard | switch (addr) {
|
367 | 9a64fbe4 | bellard | case 0x0092: |
368 | 9a64fbe4 | bellard | /* Special port 92 */
|
369 | 64201201 | bellard | retval = 0x00;
|
370 | 64201201 | bellard | break;
|
371 | 64201201 | bellard | case 0x0800: |
372 | 64201201 | bellard | /* Motorola CPU configuration register */
|
373 | 64201201 | bellard | retval = 0xEF; /* MPC750 */ |
374 | 64201201 | bellard | break;
|
375 | 64201201 | bellard | case 0x0802: |
376 | 64201201 | bellard | /* Motorola Base module feature register */
|
377 | 64201201 | bellard | retval = 0xAD; /* No ESCC, PMC slot neither ethernet */ |
378 | 64201201 | bellard | break;
|
379 | 64201201 | bellard | case 0x0803: |
380 | 64201201 | bellard | /* Motorola base module status register */
|
381 | 64201201 | bellard | retval = 0xE0; /* Standard MPC750 */ |
382 | 9a64fbe4 | bellard | break;
|
383 | 9a64fbe4 | bellard | case 0x080C: |
384 | 9a64fbe4 | bellard | /* Equipment present register:
|
385 | 9a64fbe4 | bellard | * no L2 cache
|
386 | 9a64fbe4 | bellard | * no upgrade processor
|
387 | 9a64fbe4 | bellard | * no cards in PCI slots
|
388 | 9a64fbe4 | bellard | * SCSI fuse is bad
|
389 | 9a64fbe4 | bellard | */
|
390 | 64201201 | bellard | retval = 0x3C;
|
391 | 64201201 | bellard | break;
|
392 | 64201201 | bellard | case 0x0810: |
393 | 64201201 | bellard | /* Motorola base module extended feature register */
|
394 | 64201201 | bellard | retval = 0x39; /* No USB, CF and PCI bridge. NVRAM present */ |
395 | 9a64fbe4 | bellard | break;
|
396 | da9b266b | bellard | case 0x0814: |
397 | da9b266b | bellard | /* L2 invalidate: don't care */
|
398 | da9b266b | bellard | break;
|
399 | 9a64fbe4 | bellard | case 0x0818: |
400 | 9a64fbe4 | bellard | /* Keylock */
|
401 | 9a64fbe4 | bellard | retval = 0x00;
|
402 | 9a64fbe4 | bellard | break;
|
403 | 9a64fbe4 | bellard | case 0x081C: |
404 | 9a64fbe4 | bellard | /* system control register
|
405 | 9a64fbe4 | bellard | * 7 - 6 / 1 - 0: L2 cache enable
|
406 | 9a64fbe4 | bellard | */
|
407 | 64201201 | bellard | retval = sysctrl->syscontrol; |
408 | 9a64fbe4 | bellard | break;
|
409 | 9a64fbe4 | bellard | case 0x0823: |
410 | 9a64fbe4 | bellard | /* */
|
411 | 9a64fbe4 | bellard | retval = 0x03; /* no L2 cache */ |
412 | 9a64fbe4 | bellard | break;
|
413 | 9a64fbe4 | bellard | case 0x0850: |
414 | 9a64fbe4 | bellard | /* I/O map type register */
|
415 | da9b266b | bellard | retval = sysctrl->contiguous_map; |
416 | 9a64fbe4 | bellard | break;
|
417 | 9a64fbe4 | bellard | default:
|
418 | aae9366a | j_mayer | printf("ERROR: unaffected IO port: %04" PRIx32 " read\n", addr); |
419 | 9a64fbe4 | bellard | break;
|
420 | 9a64fbe4 | bellard | } |
421 | aae9366a | j_mayer | PPC_IO_DPRINTF("0x%08" PRIx32 " <= 0x%02" PRIx32 "\n", |
422 | aae9366a | j_mayer | addr - PPC_IO_BASE, retval); |
423 | 9a64fbe4 | bellard | |
424 | 9a64fbe4 | bellard | return retval;
|
425 | 9a64fbe4 | bellard | } |
426 | 9a64fbe4 | bellard | |
427 | c227f099 | Anthony Liguori | static inline target_phys_addr_t prep_IO_address(sysctrl_t *sysctrl, |
428 | c227f099 | Anthony Liguori | target_phys_addr_t addr) |
429 | da9b266b | bellard | { |
430 | da9b266b | bellard | if (sysctrl->contiguous_map == 0) { |
431 | da9b266b | bellard | /* 64 KB contiguous space for IOs */
|
432 | da9b266b | bellard | addr &= 0xFFFF;
|
433 | da9b266b | bellard | } else {
|
434 | da9b266b | bellard | /* 8 MB non-contiguous space for IOs */
|
435 | da9b266b | bellard | addr = (addr & 0x1F) | ((addr & 0x007FFF000) >> 7); |
436 | da9b266b | bellard | } |
437 | da9b266b | bellard | |
438 | da9b266b | bellard | return addr;
|
439 | da9b266b | bellard | } |
440 | da9b266b | bellard | |
441 | c227f099 | Anthony Liguori | static void PPC_prep_io_writeb (void *opaque, target_phys_addr_t addr, |
442 | da9b266b | bellard | uint32_t value) |
443 | da9b266b | bellard | { |
444 | c227f099 | Anthony Liguori | sysctrl_t *sysctrl = opaque; |
445 | da9b266b | bellard | |
446 | da9b266b | bellard | addr = prep_IO_address(sysctrl, addr); |
447 | afcea8cb | Blue Swirl | cpu_outb(addr, value); |
448 | da9b266b | bellard | } |
449 | da9b266b | bellard | |
450 | c227f099 | Anthony Liguori | static uint32_t PPC_prep_io_readb (void *opaque, target_phys_addr_t addr) |
451 | da9b266b | bellard | { |
452 | c227f099 | Anthony Liguori | sysctrl_t *sysctrl = opaque; |
453 | da9b266b | bellard | uint32_t ret; |
454 | da9b266b | bellard | |
455 | da9b266b | bellard | addr = prep_IO_address(sysctrl, addr); |
456 | afcea8cb | Blue Swirl | ret = cpu_inb(addr); |
457 | da9b266b | bellard | |
458 | da9b266b | bellard | return ret;
|
459 | da9b266b | bellard | } |
460 | da9b266b | bellard | |
461 | c227f099 | Anthony Liguori | static void PPC_prep_io_writew (void *opaque, target_phys_addr_t addr, |
462 | da9b266b | bellard | uint32_t value) |
463 | da9b266b | bellard | { |
464 | c227f099 | Anthony Liguori | sysctrl_t *sysctrl = opaque; |
465 | da9b266b | bellard | |
466 | da9b266b | bellard | addr = prep_IO_address(sysctrl, addr); |
467 | 90e189ec | Blue Swirl | PPC_IO_DPRINTF("0x" TARGET_FMT_plx " => 0x%08" PRIx32 "\n", addr, value); |
468 | afcea8cb | Blue Swirl | cpu_outw(addr, value); |
469 | da9b266b | bellard | } |
470 | da9b266b | bellard | |
471 | c227f099 | Anthony Liguori | static uint32_t PPC_prep_io_readw (void *opaque, target_phys_addr_t addr) |
472 | da9b266b | bellard | { |
473 | c227f099 | Anthony Liguori | sysctrl_t *sysctrl = opaque; |
474 | da9b266b | bellard | uint32_t ret; |
475 | da9b266b | bellard | |
476 | da9b266b | bellard | addr = prep_IO_address(sysctrl, addr); |
477 | afcea8cb | Blue Swirl | ret = cpu_inw(addr); |
478 | 90e189ec | Blue Swirl | PPC_IO_DPRINTF("0x" TARGET_FMT_plx " <= 0x%08" PRIx32 "\n", addr, ret); |
479 | da9b266b | bellard | |
480 | da9b266b | bellard | return ret;
|
481 | da9b266b | bellard | } |
482 | da9b266b | bellard | |
483 | c227f099 | Anthony Liguori | static void PPC_prep_io_writel (void *opaque, target_phys_addr_t addr, |
484 | da9b266b | bellard | uint32_t value) |
485 | da9b266b | bellard | { |
486 | c227f099 | Anthony Liguori | sysctrl_t *sysctrl = opaque; |
487 | da9b266b | bellard | |
488 | da9b266b | bellard | addr = prep_IO_address(sysctrl, addr); |
489 | 90e189ec | Blue Swirl | PPC_IO_DPRINTF("0x" TARGET_FMT_plx " => 0x%08" PRIx32 "\n", addr, value); |
490 | afcea8cb | Blue Swirl | cpu_outl(addr, value); |
491 | da9b266b | bellard | } |
492 | da9b266b | bellard | |
493 | c227f099 | Anthony Liguori | static uint32_t PPC_prep_io_readl (void *opaque, target_phys_addr_t addr) |
494 | da9b266b | bellard | { |
495 | c227f099 | Anthony Liguori | sysctrl_t *sysctrl = opaque; |
496 | da9b266b | bellard | uint32_t ret; |
497 | da9b266b | bellard | |
498 | da9b266b | bellard | addr = prep_IO_address(sysctrl, addr); |
499 | afcea8cb | Blue Swirl | ret = cpu_inl(addr); |
500 | 90e189ec | Blue Swirl | PPC_IO_DPRINTF("0x" TARGET_FMT_plx " <= 0x%08" PRIx32 "\n", addr, ret); |
501 | da9b266b | bellard | |
502 | da9b266b | bellard | return ret;
|
503 | da9b266b | bellard | } |
504 | da9b266b | bellard | |
505 | d60efc6b | Blue Swirl | static CPUWriteMemoryFunc * const PPC_prep_io_write[] = { |
506 | da9b266b | bellard | &PPC_prep_io_writeb, |
507 | da9b266b | bellard | &PPC_prep_io_writew, |
508 | da9b266b | bellard | &PPC_prep_io_writel, |
509 | da9b266b | bellard | }; |
510 | da9b266b | bellard | |
511 | d60efc6b | Blue Swirl | static CPUReadMemoryFunc * const PPC_prep_io_read[] = { |
512 | da9b266b | bellard | &PPC_prep_io_readb, |
513 | da9b266b | bellard | &PPC_prep_io_readw, |
514 | da9b266b | bellard | &PPC_prep_io_readl, |
515 | da9b266b | bellard | }; |
516 | da9b266b | bellard | |
517 | 64201201 | bellard | #define NVRAM_SIZE 0x2000 |
518 | a541f297 | bellard | |
519 | 4556bd8b | Blue Swirl | static void cpu_request_exit(void *opaque, int irq, int level) |
520 | 4556bd8b | Blue Swirl | { |
521 | 4556bd8b | Blue Swirl | CPUState *env = cpu_single_env; |
522 | 4556bd8b | Blue Swirl | |
523 | 4556bd8b | Blue Swirl | if (env && level) {
|
524 | 4556bd8b | Blue Swirl | cpu_exit(env); |
525 | 4556bd8b | Blue Swirl | } |
526 | 4556bd8b | Blue Swirl | } |
527 | 4556bd8b | Blue Swirl | |
528 | 26aa7d72 | bellard | /* PowerPC PREP hardware initialisation */
|
529 | c227f099 | Anthony Liguori | static void ppc_prep_init (ram_addr_t ram_size, |
530 | 3023f332 | aliguori | const char *boot_device, |
531 | b881c2c6 | blueswir1 | const char *kernel_filename, |
532 | 94fc95cd | j_mayer | const char *kernel_cmdline, |
533 | 94fc95cd | j_mayer | const char *initrd_filename, |
534 | 94fc95cd | j_mayer | const char *cpu_model) |
535 | a541f297 | bellard | { |
536 | 49a2942d | Blue Swirl | CPUState *env = NULL;
|
537 | 5cea8590 | Paul Brook | char *filename;
|
538 | c227f099 | Anthony Liguori | nvram_t nvram; |
539 | 43a34704 | Blue Swirl | M48t59State *m48t59; |
540 | a541f297 | bellard | int PPC_io_memory;
|
541 | 4157a662 | bellard | int linux_boot, i, nb_nics1, bios_size;
|
542 | c227f099 | Anthony Liguori | ram_addr_t ram_offset, bios_offset; |
543 | 093209cd | Blue Swirl | uint32_t kernel_base, initrd_base; |
544 | 093209cd | Blue Swirl | long kernel_size, initrd_size;
|
545 | 46e50e9d | bellard | PCIBus *pci_bus; |
546 | d537cf6c | pbrook | qemu_irq *i8259; |
547 | 4556bd8b | Blue Swirl | qemu_irq *cpu_exit_irq; |
548 | 28c5af54 | j_mayer | int ppc_boot_device;
|
549 | f455e98c | Gerd Hoffmann | DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; |
550 | fd8014e1 | Gerd Hoffmann | DriveInfo *fd[MAX_FD]; |
551 | 64201201 | bellard | |
552 | c227f099 | Anthony Liguori | sysctrl = qemu_mallocz(sizeof(sysctrl_t));
|
553 | a541f297 | bellard | |
554 | a541f297 | bellard | linux_boot = (kernel_filename != NULL);
|
555 | 0a032cbe | j_mayer | |
556 | c68ea704 | bellard | /* init CPUs */
|
557 | 94fc95cd | j_mayer | if (cpu_model == NULL) |
558 | b37fc148 | Gerd Hoffmann | cpu_model = "602";
|
559 | fe33cc71 | j_mayer | for (i = 0; i < smp_cpus; i++) { |
560 | aaed909a | bellard | env = cpu_init(cpu_model); |
561 | aaed909a | bellard | if (!env) {
|
562 | aaed909a | bellard | fprintf(stderr, "Unable to find PowerPC CPU definition\n");
|
563 | aaed909a | bellard | exit(1);
|
564 | aaed909a | bellard | } |
565 | 4018bae9 | j_mayer | if (env->flags & POWERPC_FLAG_RTC_CLK) {
|
566 | 4018bae9 | j_mayer | /* POWER / PowerPC 601 RTC clock frequency is 7.8125 MHz */
|
567 | 4018bae9 | j_mayer | cpu_ppc_tb_init(env, 7812500UL);
|
568 | 4018bae9 | j_mayer | } else {
|
569 | 4018bae9 | j_mayer | /* Set time-base frequency to 100 Mhz */
|
570 | 4018bae9 | j_mayer | cpu_ppc_tb_init(env, 100UL * 1000UL * 1000UL); |
571 | 4018bae9 | j_mayer | } |
572 | d84bda46 | Blue Swirl | qemu_register_reset((QEMUResetHandler*)&cpu_reset, env); |
573 | fe33cc71 | j_mayer | } |
574 | a541f297 | bellard | |
575 | a541f297 | bellard | /* allocate RAM */
|
576 | 1724f049 | Alex Williamson | ram_offset = qemu_ram_alloc(NULL, "ppc_prep.ram", ram_size); |
577 | cf9c147c | blueswir1 | cpu_register_physical_memory(0, ram_size, ram_offset);
|
578 | cf9c147c | blueswir1 | |
579 | 64201201 | bellard | /* allocate and load BIOS */
|
580 | 1724f049 | Alex Williamson | bios_offset = qemu_ram_alloc(NULL, "ppc_prep.bios", BIOS_SIZE); |
581 | 1192dad8 | j_mayer | if (bios_name == NULL) |
582 | 1192dad8 | j_mayer | bios_name = BIOS_FILENAME; |
583 | 5cea8590 | Paul Brook | filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); |
584 | 5cea8590 | Paul Brook | if (filename) {
|
585 | 5cea8590 | Paul Brook | bios_size = get_image_size(filename); |
586 | 5cea8590 | Paul Brook | } else {
|
587 | 5cea8590 | Paul Brook | bios_size = -1;
|
588 | 5cea8590 | Paul Brook | } |
589 | dcac9679 | pbrook | if (bios_size > 0 && bios_size <= BIOS_SIZE) { |
590 | c227f099 | Anthony Liguori | target_phys_addr_t bios_addr; |
591 | dcac9679 | pbrook | bios_size = (bios_size + 0xfff) & ~0xfff; |
592 | dcac9679 | pbrook | bios_addr = (uint32_t)(-bios_size); |
593 | dcac9679 | pbrook | cpu_register_physical_memory(bios_addr, bios_size, |
594 | dcac9679 | pbrook | bios_offset | IO_MEM_ROM); |
595 | 5cea8590 | Paul Brook | bios_size = load_image_targphys(filename, bios_addr, bios_size); |
596 | dcac9679 | pbrook | } |
597 | 4157a662 | bellard | if (bios_size < 0 || bios_size > BIOS_SIZE) { |
598 | 5cea8590 | Paul Brook | hw_error("qemu: could not load PPC PREP bios '%s'\n", bios_name);
|
599 | 5cea8590 | Paul Brook | } |
600 | 5cea8590 | Paul Brook | if (filename) {
|
601 | 5cea8590 | Paul Brook | qemu_free(filename); |
602 | 64201201 | bellard | } |
603 | 26aa7d72 | bellard | |
604 | a541f297 | bellard | if (linux_boot) {
|
605 | 64201201 | bellard | kernel_base = KERNEL_LOAD_ADDR; |
606 | a541f297 | bellard | /* now we can load the kernel */
|
607 | dcac9679 | pbrook | kernel_size = load_image_targphys(kernel_filename, kernel_base, |
608 | dcac9679 | pbrook | ram_size - kernel_base); |
609 | 64201201 | bellard | if (kernel_size < 0) { |
610 | 2ac71179 | Paul Brook | hw_error("qemu: could not load kernel '%s'\n", kernel_filename);
|
611 | a541f297 | bellard | exit(1);
|
612 | a541f297 | bellard | } |
613 | a541f297 | bellard | /* load initrd */
|
614 | a541f297 | bellard | if (initrd_filename) {
|
615 | 64201201 | bellard | initrd_base = INITRD_LOAD_ADDR; |
616 | dcac9679 | pbrook | initrd_size = load_image_targphys(initrd_filename, initrd_base, |
617 | dcac9679 | pbrook | ram_size - initrd_base); |
618 | a541f297 | bellard | if (initrd_size < 0) { |
619 | 2ac71179 | Paul Brook | hw_error("qemu: could not load initial ram disk '%s'\n",
|
620 | 4a057712 | j_mayer | initrd_filename); |
621 | a541f297 | bellard | } |
622 | 64201201 | bellard | } else {
|
623 | 64201201 | bellard | initrd_base = 0;
|
624 | 64201201 | bellard | initrd_size = 0;
|
625 | a541f297 | bellard | } |
626 | 6ac0e82d | balrog | ppc_boot_device = 'm';
|
627 | a541f297 | bellard | } else {
|
628 | 64201201 | bellard | kernel_base = 0;
|
629 | 64201201 | bellard | kernel_size = 0;
|
630 | 64201201 | bellard | initrd_base = 0;
|
631 | 64201201 | bellard | initrd_size = 0;
|
632 | 28c5af54 | j_mayer | ppc_boot_device = '\0';
|
633 | 28c5af54 | j_mayer | /* For now, OHW cannot boot from the network. */
|
634 | 0d913fdb | j_mayer | for (i = 0; boot_device[i] != '\0'; i++) { |
635 | 0d913fdb | j_mayer | if (boot_device[i] >= 'a' && boot_device[i] <= 'f') { |
636 | 0d913fdb | j_mayer | ppc_boot_device = boot_device[i]; |
637 | 28c5af54 | j_mayer | break;
|
638 | 0d913fdb | j_mayer | } |
639 | 28c5af54 | j_mayer | } |
640 | 28c5af54 | j_mayer | if (ppc_boot_device == '\0') { |
641 | 28c5af54 | j_mayer | fprintf(stderr, "No valid boot device for Mac99 machine\n");
|
642 | 28c5af54 | j_mayer | exit(1);
|
643 | 28c5af54 | j_mayer | } |
644 | a541f297 | bellard | } |
645 | a541f297 | bellard | |
646 | 64201201 | bellard | isa_mem_base = 0xc0000000;
|
647 | dd37a5e4 | j_mayer | if (PPC_INPUT(env) != PPC_FLAGS_INPUT_6xx) {
|
648 | 2ac71179 | Paul Brook | hw_error("Only 6xx bus is supported on PREP machine\n");
|
649 | dd37a5e4 | j_mayer | } |
650 | 24be5ae3 | j_mayer | i8259 = i8259_init(first_cpu->irq_inputs[PPC6xx_INPUT_INT]); |
651 | d537cf6c | pbrook | pci_bus = pci_prep_init(i8259); |
652 | b37fc148 | Gerd Hoffmann | /* Hmm, prep has no pci-isa bridge ??? */
|
653 | b37fc148 | Gerd Hoffmann | isa_bus_new(NULL);
|
654 | b37fc148 | Gerd Hoffmann | isa_bus_irqs(i8259); |
655 | da9b266b | bellard | // pci_bus = i440fx_init();
|
656 | da9b266b | bellard | /* Register 8 MB of ISA IO space (needed for non-contiguous map) */
|
657 | 1eed09cb | Avi Kivity | PPC_io_memory = cpu_register_io_memory(PPC_prep_io_read, |
658 | 2507c12a | Alexander Graf | PPC_prep_io_write, sysctrl, |
659 | 8cb7da56 | Alexander Graf | DEVICE_LITTLE_ENDIAN); |
660 | da9b266b | bellard | cpu_register_physical_memory(0x80000000, 0x00800000, PPC_io_memory); |
661 | 64201201 | bellard | |
662 | a541f297 | bellard | /* init basic PC hardware */
|
663 | 78895427 | Gerd Hoffmann | pci_vga_init(pci_bus); |
664 | 64201201 | bellard | // openpic = openpic_init(0x00000000, 0xF0000000, 1);
|
665 | 64d7e9a4 | Blue Swirl | // pit = pit_init(0x40, 0);
|
666 | 7d932dfd | Jan Kiszka | rtc_init(2000, NULL); |
667 | a541f297 | bellard | |
668 | ac0be998 | Gerd Hoffmann | if (serial_hds[0]) |
669 | ac0be998 | Gerd Hoffmann | serial_isa_init(0, serial_hds[0]); |
670 | a541f297 | bellard | nb_nics1 = nb_nics; |
671 | a541f297 | bellard | if (nb_nics1 > NE2000_NB_MAX)
|
672 | a541f297 | bellard | nb_nics1 = NE2000_NB_MAX; |
673 | a541f297 | bellard | for(i = 0; i < nb_nics1; i++) { |
674 | 5652ef78 | aurel32 | if (nd_table[i].model == NULL) { |
675 | 9203f520 | Mark McLoughlin | nd_table[i].model = qemu_strdup("ne2k_isa");
|
676 | 5652ef78 | aurel32 | } |
677 | 5652ef78 | aurel32 | if (strcmp(nd_table[i].model, "ne2k_isa") == 0) { |
678 | 9453c5bc | Gerd Hoffmann | isa_ne2000_init(ne2000_io[i], ne2000_irq[i], &nd_table[i]); |
679 | a41b2ff2 | pbrook | } else {
|
680 | 07caea31 | Markus Armbruster | pci_nic_init_nofail(&nd_table[i], "ne2k_pci", NULL); |
681 | a41b2ff2 | pbrook | } |
682 | a541f297 | bellard | } |
683 | a541f297 | bellard | |
684 | 75717903 | Isaku Yamahata | ide_drive_get(hd, MAX_IDE_BUS); |
685 | 81aa0647 | Aurelien Jarno | for(i = 0; i < MAX_IDE_BUS; i++) { |
686 | dea21e97 | Gerd Hoffmann | isa_ide_init(ide_iobase[i], ide_iobase2[i], ide_irq[i], |
687 | e4bcb14c | ths | hd[2 * i],
|
688 | e4bcb14c | ths | hd[2 * i + 1]); |
689 | a541f297 | bellard | } |
690 | 11d23c35 | Gerd Hoffmann | isa_create_simple("i8042");
|
691 | 4556bd8b | Blue Swirl | |
692 | 4556bd8b | Blue Swirl | cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1); |
693 | 4556bd8b | Blue Swirl | DMA_init(1, cpu_exit_irq);
|
694 | 4556bd8b | Blue Swirl | |
695 | a541f297 | bellard | // SB16_init();
|
696 | a541f297 | bellard | |
697 | e4bcb14c | ths | for(i = 0; i < MAX_FD; i++) { |
698 | fd8014e1 | Gerd Hoffmann | fd[i] = drive_get(IF_FLOPPY, 0, i);
|
699 | e4bcb14c | ths | } |
700 | 86c86157 | Gerd Hoffmann | fdctrl_init_isa(fd); |
701 | a541f297 | bellard | |
702 | 64201201 | bellard | /* Register speaker port */
|
703 | 64201201 | bellard | register_ioport_read(0x61, 1, 1, speaker_ioport_read, NULL); |
704 | 64201201 | bellard | register_ioport_write(0x61, 1, 1, speaker_ioport_write, NULL); |
705 | a541f297 | bellard | /* Register fake IO ports for PREP */
|
706 | c4781a51 | j_mayer | sysctrl->reset_irq = first_cpu->irq_inputs[PPC6xx_INPUT_HRESET]; |
707 | 64201201 | bellard | register_ioport_read(0x398, 2, 1, &PREP_io_read, sysctrl); |
708 | 64201201 | bellard | register_ioport_write(0x398, 2, 1, &PREP_io_write, sysctrl); |
709 | a541f297 | bellard | /* System control ports */
|
710 | 64201201 | bellard | register_ioport_read(0x0092, 0x01, 1, &PREP_io_800_readb, sysctrl); |
711 | 64201201 | bellard | register_ioport_write(0x0092, 0x01, 1, &PREP_io_800_writeb, sysctrl); |
712 | 64201201 | bellard | register_ioport_read(0x0800, 0x52, 1, &PREP_io_800_readb, sysctrl); |
713 | 64201201 | bellard | register_ioport_write(0x0800, 0x52, 1, &PREP_io_800_writeb, sysctrl); |
714 | 64201201 | bellard | /* PCI intack location */
|
715 | 1eed09cb | Avi Kivity | PPC_io_memory = cpu_register_io_memory(PPC_intack_read, |
716 | 2507c12a | Alexander Graf | PPC_intack_write, NULL,
|
717 | 8cb7da56 | Alexander Graf | DEVICE_LITTLE_ENDIAN); |
718 | a541f297 | bellard | cpu_register_physical_memory(0xBFFFFFF0, 0x4, PPC_io_memory); |
719 | 64201201 | bellard | /* PowerPC control and status register group */
|
720 | b6b8bd18 | bellard | #if 0
|
721 | 1eed09cb | Avi Kivity | PPC_io_memory = cpu_register_io_memory(PPC_XCSR_read, PPC_XCSR_write,
|
722 | 8cb7da56 | Alexander Graf | NULL, DEVICE_LITTLE_ENDIAN);
|
723 | 64201201 | bellard | cpu_register_physical_memory(0xFEFF0000, 0x1000, PPC_io_memory);
|
724 | b6b8bd18 | bellard | #endif
|
725 | a541f297 | bellard | |
726 | 0d92ed30 | pbrook | if (usb_enabled) {
|
727 | a67ba3b6 | Paul Brook | usb_ohci_init_pci(pci_bus, -1);
|
728 | 0d92ed30 | pbrook | } |
729 | 0d92ed30 | pbrook | |
730 | 3cbee15b | j_mayer | m48t59 = m48t59_init(i8259[8], 0, 0x0074, NVRAM_SIZE, 59); |
731 | 3cbee15b | j_mayer | if (m48t59 == NULL) |
732 | 64201201 | bellard | return;
|
733 | 3cbee15b | j_mayer | sysctrl->nvram = m48t59; |
734 | 64201201 | bellard | |
735 | 64201201 | bellard | /* Initialise NVRAM */
|
736 | 3cbee15b | j_mayer | nvram.opaque = m48t59; |
737 | 3cbee15b | j_mayer | nvram.read_fn = &m48t59_read; |
738 | 3cbee15b | j_mayer | nvram.write_fn = &m48t59_write; |
739 | 6ac0e82d | balrog | PPC_NVRAM_set_params(&nvram, NVRAM_SIZE, "PREP", ram_size, ppc_boot_device,
|
740 | 64201201 | bellard | kernel_base, kernel_size, |
741 | b6b8bd18 | bellard | kernel_cmdline, |
742 | 64201201 | bellard | initrd_base, initrd_size, |
743 | 64201201 | bellard | /* XXX: need an option to load a NVRAM image */
|
744 | b6b8bd18 | bellard | 0,
|
745 | b6b8bd18 | bellard | graphic_width, graphic_height, graphic_depth); |
746 | c0e564d5 | bellard | |
747 | c0e564d5 | bellard | /* Special port to get debug messages from Open-Firmware */
|
748 | c0e564d5 | bellard | register_ioport_write(0x0F00, 4, 1, &PPC_debug_write, NULL); |
749 | a541f297 | bellard | } |
750 | c0e564d5 | bellard | |
751 | f80f9ec9 | Anthony Liguori | static QEMUMachine prep_machine = {
|
752 | 4b32e168 | aliguori | .name = "prep",
|
753 | 4b32e168 | aliguori | .desc = "PowerPC PREP platform",
|
754 | 4b32e168 | aliguori | .init = ppc_prep_init, |
755 | 3d878caa | balrog | .max_cpus = MAX_CPUS, |
756 | c0e564d5 | bellard | }; |
757 | f80f9ec9 | Anthony Liguori | |
758 | f80f9ec9 | Anthony Liguori | static void prep_machine_init(void) |
759 | f80f9ec9 | Anthony Liguori | { |
760 | f80f9ec9 | Anthony Liguori | qemu_register_machine(&prep_machine); |
761 | f80f9ec9 | Anthony Liguori | } |
762 | f80f9ec9 | Anthony Liguori | |
763 | f80f9ec9 | Anthony Liguori | machine_init(prep_machine_init); |