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