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