root / hw / ppc_prep.c @ c1ded3dc
History | View | Annotate | Download (22.5 kB)
1 | 9a64fbe4 | bellard | /*
|
---|---|---|---|
2 | a541f297 | bellard | * QEMU PPC PREP hardware System Emulator
|
3 | 5fafdf24 | ths | *
|
4 | 47103572 | j_mayer | * Copyright (c) 2003-2007 Jocelyn Mayer
|
5 | 5fafdf24 | ths | *
|
6 | a541f297 | bellard | * Permission is hereby granted, free of charge, to any person obtaining a copy
|
7 | a541f297 | bellard | * of this software and associated documentation files (the "Software"), to deal
|
8 | a541f297 | bellard | * in the Software without restriction, including without limitation the rights
|
9 | a541f297 | bellard | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10 | a541f297 | bellard | * copies of the Software, and to permit persons to whom the Software is
|
11 | a541f297 | bellard | * furnished to do so, subject to the following conditions:
|
12 | a541f297 | bellard | *
|
13 | a541f297 | bellard | * The above copyright notice and this permission notice shall be included in
|
14 | a541f297 | bellard | * all copies or substantial portions of the Software.
|
15 | a541f297 | bellard | *
|
16 | a541f297 | bellard | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 | a541f297 | bellard | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 | a541f297 | bellard | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 | a541f297 | bellard | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 | a541f297 | bellard | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21 | a541f297 | bellard | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22 | a541f297 | bellard | * THE SOFTWARE.
|
23 | 9a64fbe4 | bellard | */
|
24 | 87ecb68b | pbrook | #include "hw.h" |
25 | 87ecb68b | pbrook | #include "nvram.h" |
26 | 87ecb68b | pbrook | #include "pc.h" |
27 | 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 | 64201201 | bellard | //static PITState *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 | 64201201 | bellard | out = pit_get_out(pit, 2, qemu_get_clock(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 | f658b4db | bellard | #ifdef TARGET_WORDS_BIGENDIAN
|
149 | 64201201 | bellard | return bswap16(_PPC_intack_read(addr));
|
150 | 64201201 | bellard | #else
|
151 | 64201201 | bellard | return _PPC_intack_read(addr);
|
152 | f658b4db | bellard | #endif
|
153 | 9a64fbe4 | bellard | } |
154 | 9a64fbe4 | bellard | |
155 | c227f099 | Anthony Liguori | static uint32_t PPC_intack_readl (void *opaque, target_phys_addr_t addr) |
156 | 9a64fbe4 | bellard | { |
157 | f658b4db | bellard | #ifdef TARGET_WORDS_BIGENDIAN
|
158 | 64201201 | bellard | return bswap32(_PPC_intack_read(addr));
|
159 | 64201201 | bellard | #else
|
160 | 64201201 | bellard | return _PPC_intack_read(addr);
|
161 | f658b4db | bellard | #endif
|
162 | 9a64fbe4 | bellard | } |
163 | 9a64fbe4 | bellard | |
164 | d60efc6b | Blue Swirl | static CPUWriteMemoryFunc * const PPC_intack_write[] = { |
165 | 64201201 | bellard | &_PPC_intack_write, |
166 | 64201201 | bellard | &_PPC_intack_write, |
167 | 64201201 | bellard | &_PPC_intack_write, |
168 | 64201201 | bellard | }; |
169 | 64201201 | bellard | |
170 | d60efc6b | Blue Swirl | static CPUReadMemoryFunc * const PPC_intack_read[] = { |
171 | 64201201 | bellard | &PPC_intack_readb, |
172 | 64201201 | bellard | &PPC_intack_readw, |
173 | 64201201 | bellard | &PPC_intack_readl, |
174 | 64201201 | bellard | }; |
175 | 64201201 | bellard | |
176 | 64201201 | bellard | /* PowerPC control and status registers */
|
177 | 64201201 | bellard | #if 0 // Not used
|
178 | 64201201 | bellard | static struct {
|
179 | 64201201 | bellard | /* IDs */
|
180 | 64201201 | bellard | uint32_t veni_devi;
|
181 | 64201201 | bellard | uint32_t revi;
|
182 | 64201201 | bellard | /* Control and status */
|
183 | 64201201 | bellard | uint32_t gcsr;
|
184 | 64201201 | bellard | uint32_t xcfr;
|
185 | 64201201 | bellard | uint32_t ct32;
|
186 | 64201201 | bellard | uint32_t mcsr;
|
187 | 64201201 | bellard | /* General purpose registers */
|
188 | 64201201 | bellard | uint32_t gprg[6];
|
189 | 64201201 | bellard | /* Exceptions */
|
190 | 64201201 | bellard | uint32_t feen;
|
191 | 64201201 | bellard | uint32_t fest;
|
192 | 64201201 | bellard | uint32_t fema;
|
193 | 64201201 | bellard | uint32_t fecl;
|
194 | 64201201 | bellard | uint32_t eeen;
|
195 | 64201201 | bellard | uint32_t eest;
|
196 | 64201201 | bellard | uint32_t eecl;
|
197 | 64201201 | bellard | uint32_t eeint;
|
198 | 64201201 | bellard | uint32_t eemck0;
|
199 | 64201201 | bellard | uint32_t eemck1;
|
200 | 64201201 | bellard | /* Error diagnostic */
|
201 | 64201201 | bellard | } XCSR;
|
202 | 64201201 | bellard | |
203 | 36081602 | j_mayer | static void PPC_XCSR_writeb (void *opaque,
|
204 | c227f099 | Anthony Liguori | target_phys_addr_t addr, uint32_t value)
|
205 | 64201201 | bellard | {
|
206 | 90e189ec | Blue Swirl | printf("%s: 0x" TARGET_FMT_plx " => 0x%08" PRIx32 "\n", __func__, addr,
|
207 | 90e189ec | Blue Swirl | value);
|
208 | 64201201 | bellard | }
|
209 | 64201201 | bellard | |
210 | 36081602 | j_mayer | static void PPC_XCSR_writew (void *opaque,
|
211 | c227f099 | Anthony Liguori | target_phys_addr_t addr, uint32_t value)
|
212 | 9a64fbe4 | bellard | {
|
213 | f658b4db | bellard | #ifdef TARGET_WORDS_BIGENDIAN
|
214 | 64201201 | bellard | value = bswap16(value);
|
215 | f658b4db | bellard | #endif
|
216 | 90e189ec | Blue Swirl | printf("%s: 0x" TARGET_FMT_plx " => 0x%08" PRIx32 "\n", __func__, addr, |
217 | 90e189ec | Blue Swirl | value); |
218 | 9a64fbe4 | bellard | } |
219 | 9a64fbe4 | bellard | |
220 | 36081602 | j_mayer | static void PPC_XCSR_writel (void *opaque, |
221 | c227f099 | Anthony Liguori | target_phys_addr_t addr, uint32_t value) |
222 | 9a64fbe4 | bellard | { |
223 | f658b4db | bellard | #ifdef TARGET_WORDS_BIGENDIAN
|
224 | 64201201 | bellard | value = bswap32(value); |
225 | f658b4db | bellard | #endif
|
226 | 90e189ec | Blue Swirl | printf("%s: 0x" TARGET_FMT_plx " => 0x%08" PRIx32 "\n", __func__, addr, |
227 | 90e189ec | Blue Swirl | value); |
228 | 9a64fbe4 | bellard | } |
229 | 9a64fbe4 | bellard | |
230 | c227f099 | Anthony Liguori | static uint32_t PPC_XCSR_readb (void *opaque, target_phys_addr_t addr) |
231 | 64201201 | bellard | { |
232 | 64201201 | bellard | uint32_t retval = 0;
|
233 | 9a64fbe4 | bellard | |
234 | 90e189ec | Blue Swirl | printf("%s: 0x" TARGET_FMT_plx " <= %08" PRIx32 "\n", __func__, addr, |
235 | 90e189ec | Blue Swirl | retval); |
236 | 9a64fbe4 | bellard | |
237 | 64201201 | bellard | return retval;
|
238 | 64201201 | bellard | } |
239 | 64201201 | bellard | |
240 | c227f099 | Anthony Liguori | static uint32_t PPC_XCSR_readw (void *opaque, target_phys_addr_t addr) |
241 | 9a64fbe4 | bellard | { |
242 | 64201201 | bellard | uint32_t retval = 0;
|
243 | 64201201 | bellard | |
244 | 90e189ec | Blue Swirl | printf("%s: 0x" TARGET_FMT_plx " <= %08" PRIx32 "\n", __func__, addr, |
245 | 90e189ec | Blue Swirl | retval); |
246 | 64201201 | bellard | #ifdef TARGET_WORDS_BIGENDIAN
|
247 | 64201201 | bellard | retval = bswap16(retval); |
248 | 64201201 | bellard | #endif
|
249 | 64201201 | bellard | |
250 | 64201201 | bellard | return retval;
|
251 | 9a64fbe4 | bellard | } |
252 | 9a64fbe4 | bellard | |
253 | c227f099 | Anthony Liguori | static uint32_t PPC_XCSR_readl (void *opaque, target_phys_addr_t addr) |
254 | 9a64fbe4 | bellard | { |
255 | 9a64fbe4 | bellard | uint32_t retval = 0;
|
256 | 9a64fbe4 | bellard | |
257 | 90e189ec | Blue Swirl | printf("%s: 0x" TARGET_FMT_plx " <= %08" PRIx32 "\n", __func__, addr, |
258 | 90e189ec | Blue Swirl | retval); |
259 | 64201201 | bellard | #ifdef TARGET_WORDS_BIGENDIAN
|
260 | 64201201 | bellard | retval = bswap32(retval); |
261 | 64201201 | bellard | #endif
|
262 | 9a64fbe4 | bellard | |
263 | 9a64fbe4 | bellard | return retval;
|
264 | 9a64fbe4 | bellard | } |
265 | 9a64fbe4 | bellard | |
266 | d60efc6b | Blue Swirl | static CPUWriteMemoryFunc * const PPC_XCSR_write[] = { |
267 | 64201201 | bellard | &PPC_XCSR_writeb, |
268 | 64201201 | bellard | &PPC_XCSR_writew, |
269 | 64201201 | bellard | &PPC_XCSR_writel, |
270 | 9a64fbe4 | bellard | }; |
271 | 9a64fbe4 | bellard | |
272 | d60efc6b | Blue Swirl | static CPUReadMemoryFunc * const PPC_XCSR_read[] = { |
273 | 64201201 | bellard | &PPC_XCSR_readb, |
274 | 64201201 | bellard | &PPC_XCSR_readw, |
275 | 64201201 | bellard | &PPC_XCSR_readl, |
276 | 9a64fbe4 | bellard | }; |
277 | b6b8bd18 | bellard | #endif
|
278 | 9a64fbe4 | bellard | |
279 | 64201201 | bellard | /* Fake super-io ports for PREP platform (Intel 82378ZB) */
|
280 | c227f099 | Anthony Liguori | typedef struct sysctrl_t { |
281 | c4781a51 | j_mayer | qemu_irq reset_irq; |
282 | 43a34704 | Blue Swirl | M48t59State *nvram; |
283 | 64201201 | bellard | uint8_t state; |
284 | 64201201 | bellard | uint8_t syscontrol; |
285 | 64201201 | bellard | uint8_t fake_io[2];
|
286 | da9b266b | bellard | int contiguous_map;
|
287 | fb3444b8 | bellard | int endian;
|
288 | c227f099 | Anthony Liguori | } sysctrl_t; |
289 | 9a64fbe4 | bellard | |
290 | 64201201 | bellard | enum {
|
291 | 64201201 | bellard | STATE_HARDFILE = 0x01,
|
292 | 9a64fbe4 | bellard | }; |
293 | 9a64fbe4 | bellard | |
294 | c227f099 | Anthony Liguori | static sysctrl_t *sysctrl;
|
295 | 9a64fbe4 | bellard | |
296 | a541f297 | bellard | static void PREP_io_write (void *opaque, uint32_t addr, uint32_t val) |
297 | 9a64fbe4 | bellard | { |
298 | c227f099 | Anthony Liguori | sysctrl_t *sysctrl = opaque; |
299 | 64201201 | bellard | |
300 | aae9366a | j_mayer | PPC_IO_DPRINTF("0x%08" PRIx32 " => 0x%02" PRIx32 "\n", addr - PPC_IO_BASE, |
301 | aae9366a | j_mayer | val); |
302 | 64201201 | bellard | sysctrl->fake_io[addr - 0x0398] = val;
|
303 | 9a64fbe4 | bellard | } |
304 | 9a64fbe4 | bellard | |
305 | a541f297 | bellard | static uint32_t PREP_io_read (void *opaque, uint32_t addr) |
306 | 9a64fbe4 | bellard | { |
307 | c227f099 | Anthony Liguori | sysctrl_t *sysctrl = opaque; |
308 | 9a64fbe4 | bellard | |
309 | aae9366a | j_mayer | PPC_IO_DPRINTF("0x%08" PRIx32 " <= 0x%02" PRIx32 "\n", addr - PPC_IO_BASE, |
310 | 64201201 | bellard | sysctrl->fake_io[addr - 0x0398]);
|
311 | 64201201 | bellard | return sysctrl->fake_io[addr - 0x0398]; |
312 | 64201201 | bellard | } |
313 | 9a64fbe4 | bellard | |
314 | a541f297 | bellard | static void PREP_io_800_writeb (void *opaque, uint32_t addr, uint32_t val) |
315 | 9a64fbe4 | bellard | { |
316 | c227f099 | Anthony Liguori | sysctrl_t *sysctrl = opaque; |
317 | 64201201 | bellard | |
318 | aae9366a | j_mayer | PPC_IO_DPRINTF("0x%08" PRIx32 " => 0x%02" PRIx32 "\n", |
319 | aae9366a | j_mayer | addr - PPC_IO_BASE, val); |
320 | 9a64fbe4 | bellard | switch (addr) {
|
321 | 9a64fbe4 | bellard | case 0x0092: |
322 | 9a64fbe4 | bellard | /* Special port 92 */
|
323 | 9a64fbe4 | bellard | /* Check soft reset asked */
|
324 | 64201201 | bellard | if (val & 0x01) { |
325 | c4781a51 | j_mayer | qemu_irq_raise(sysctrl->reset_irq); |
326 | c4781a51 | j_mayer | } else {
|
327 | c4781a51 | j_mayer | qemu_irq_lower(sysctrl->reset_irq); |
328 | 9a64fbe4 | bellard | } |
329 | 9a64fbe4 | bellard | /* Check LE mode */
|
330 | 64201201 | bellard | if (val & 0x02) { |
331 | fb3444b8 | bellard | sysctrl->endian = 1;
|
332 | fb3444b8 | bellard | } else {
|
333 | fb3444b8 | bellard | sysctrl->endian = 0;
|
334 | 9a64fbe4 | bellard | } |
335 | 9a64fbe4 | bellard | break;
|
336 | 64201201 | bellard | case 0x0800: |
337 | 64201201 | bellard | /* Motorola CPU configuration register : read-only */
|
338 | 64201201 | bellard | break;
|
339 | 64201201 | bellard | case 0x0802: |
340 | 64201201 | bellard | /* Motorola base module feature register : read-only */
|
341 | 64201201 | bellard | break;
|
342 | 64201201 | bellard | case 0x0803: |
343 | 64201201 | bellard | /* Motorola base module status register : read-only */
|
344 | 64201201 | bellard | break;
|
345 | 9a64fbe4 | bellard | case 0x0808: |
346 | 64201201 | bellard | /* Hardfile light register */
|
347 | 64201201 | bellard | if (val & 1) |
348 | 64201201 | bellard | sysctrl->state |= STATE_HARDFILE; |
349 | 64201201 | bellard | else
|
350 | 64201201 | bellard | sysctrl->state &= ~STATE_HARDFILE; |
351 | 9a64fbe4 | bellard | break;
|
352 | 9a64fbe4 | bellard | case 0x0810: |
353 | 9a64fbe4 | bellard | /* Password protect 1 register */
|
354 | 64201201 | bellard | if (sysctrl->nvram != NULL) |
355 | 64201201 | bellard | m48t59_toggle_lock(sysctrl->nvram, 1);
|
356 | 9a64fbe4 | bellard | break;
|
357 | 9a64fbe4 | bellard | case 0x0812: |
358 | 9a64fbe4 | bellard | /* Password protect 2 register */
|
359 | 64201201 | bellard | if (sysctrl->nvram != NULL) |
360 | 64201201 | bellard | m48t59_toggle_lock(sysctrl->nvram, 2);
|
361 | 9a64fbe4 | bellard | break;
|
362 | 9a64fbe4 | bellard | case 0x0814: |
363 | 64201201 | bellard | /* L2 invalidate register */
|
364 | c68ea704 | bellard | // tlb_flush(first_cpu, 1);
|
365 | 9a64fbe4 | bellard | break;
|
366 | 9a64fbe4 | bellard | case 0x081C: |
367 | 9a64fbe4 | bellard | /* system control register */
|
368 | 64201201 | bellard | sysctrl->syscontrol = val & 0x0F;
|
369 | 9a64fbe4 | bellard | break;
|
370 | 9a64fbe4 | bellard | case 0x0850: |
371 | 9a64fbe4 | bellard | /* I/O map type register */
|
372 | da9b266b | bellard | sysctrl->contiguous_map = val & 0x01;
|
373 | 9a64fbe4 | bellard | break;
|
374 | 9a64fbe4 | bellard | default:
|
375 | aae9366a | j_mayer | printf("ERROR: unaffected IO port write: %04" PRIx32
|
376 | aae9366a | j_mayer | " => %02" PRIx32"\n", addr, val); |
377 | 9a64fbe4 | bellard | break;
|
378 | 9a64fbe4 | bellard | } |
379 | 9a64fbe4 | bellard | } |
380 | 9a64fbe4 | bellard | |
381 | a541f297 | bellard | static uint32_t PREP_io_800_readb (void *opaque, uint32_t addr) |
382 | 9a64fbe4 | bellard | { |
383 | c227f099 | Anthony Liguori | sysctrl_t *sysctrl = opaque; |
384 | 9a64fbe4 | bellard | uint32_t retval = 0xFF;
|
385 | 9a64fbe4 | bellard | |
386 | 9a64fbe4 | bellard | switch (addr) {
|
387 | 9a64fbe4 | bellard | case 0x0092: |
388 | 9a64fbe4 | bellard | /* Special port 92 */
|
389 | 64201201 | bellard | retval = 0x00;
|
390 | 64201201 | bellard | break;
|
391 | 64201201 | bellard | case 0x0800: |
392 | 64201201 | bellard | /* Motorola CPU configuration register */
|
393 | 64201201 | bellard | retval = 0xEF; /* MPC750 */ |
394 | 64201201 | bellard | break;
|
395 | 64201201 | bellard | case 0x0802: |
396 | 64201201 | bellard | /* Motorola Base module feature register */
|
397 | 64201201 | bellard | retval = 0xAD; /* No ESCC, PMC slot neither ethernet */ |
398 | 64201201 | bellard | break;
|
399 | 64201201 | bellard | case 0x0803: |
400 | 64201201 | bellard | /* Motorola base module status register */
|
401 | 64201201 | bellard | retval = 0xE0; /* Standard MPC750 */ |
402 | 9a64fbe4 | bellard | break;
|
403 | 9a64fbe4 | bellard | case 0x080C: |
404 | 9a64fbe4 | bellard | /* Equipment present register:
|
405 | 9a64fbe4 | bellard | * no L2 cache
|
406 | 9a64fbe4 | bellard | * no upgrade processor
|
407 | 9a64fbe4 | bellard | * no cards in PCI slots
|
408 | 9a64fbe4 | bellard | * SCSI fuse is bad
|
409 | 9a64fbe4 | bellard | */
|
410 | 64201201 | bellard | retval = 0x3C;
|
411 | 64201201 | bellard | break;
|
412 | 64201201 | bellard | case 0x0810: |
413 | 64201201 | bellard | /* Motorola base module extended feature register */
|
414 | 64201201 | bellard | retval = 0x39; /* No USB, CF and PCI bridge. NVRAM present */ |
415 | 9a64fbe4 | bellard | break;
|
416 | da9b266b | bellard | case 0x0814: |
417 | da9b266b | bellard | /* L2 invalidate: don't care */
|
418 | da9b266b | bellard | break;
|
419 | 9a64fbe4 | bellard | case 0x0818: |
420 | 9a64fbe4 | bellard | /* Keylock */
|
421 | 9a64fbe4 | bellard | retval = 0x00;
|
422 | 9a64fbe4 | bellard | break;
|
423 | 9a64fbe4 | bellard | case 0x081C: |
424 | 9a64fbe4 | bellard | /* system control register
|
425 | 9a64fbe4 | bellard | * 7 - 6 / 1 - 0: L2 cache enable
|
426 | 9a64fbe4 | bellard | */
|
427 | 64201201 | bellard | retval = sysctrl->syscontrol; |
428 | 9a64fbe4 | bellard | break;
|
429 | 9a64fbe4 | bellard | case 0x0823: |
430 | 9a64fbe4 | bellard | /* */
|
431 | 9a64fbe4 | bellard | retval = 0x03; /* no L2 cache */ |
432 | 9a64fbe4 | bellard | break;
|
433 | 9a64fbe4 | bellard | case 0x0850: |
434 | 9a64fbe4 | bellard | /* I/O map type register */
|
435 | da9b266b | bellard | retval = sysctrl->contiguous_map; |
436 | 9a64fbe4 | bellard | break;
|
437 | 9a64fbe4 | bellard | default:
|
438 | aae9366a | j_mayer | printf("ERROR: unaffected IO port: %04" PRIx32 " read\n", addr); |
439 | 9a64fbe4 | bellard | break;
|
440 | 9a64fbe4 | bellard | } |
441 | aae9366a | j_mayer | PPC_IO_DPRINTF("0x%08" PRIx32 " <= 0x%02" PRIx32 "\n", |
442 | aae9366a | j_mayer | addr - PPC_IO_BASE, retval); |
443 | 9a64fbe4 | bellard | |
444 | 9a64fbe4 | bellard | return retval;
|
445 | 9a64fbe4 | bellard | } |
446 | 9a64fbe4 | bellard | |
447 | c227f099 | Anthony Liguori | static inline target_phys_addr_t prep_IO_address(sysctrl_t *sysctrl, |
448 | c227f099 | Anthony Liguori | target_phys_addr_t addr) |
449 | da9b266b | bellard | { |
450 | da9b266b | bellard | if (sysctrl->contiguous_map == 0) { |
451 | da9b266b | bellard | /* 64 KB contiguous space for IOs */
|
452 | da9b266b | bellard | addr &= 0xFFFF;
|
453 | da9b266b | bellard | } else {
|
454 | da9b266b | bellard | /* 8 MB non-contiguous space for IOs */
|
455 | da9b266b | bellard | addr = (addr & 0x1F) | ((addr & 0x007FFF000) >> 7); |
456 | da9b266b | bellard | } |
457 | da9b266b | bellard | |
458 | da9b266b | bellard | return addr;
|
459 | da9b266b | bellard | } |
460 | da9b266b | bellard | |
461 | c227f099 | Anthony Liguori | static void PPC_prep_io_writeb (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 | afcea8cb | Blue Swirl | cpu_outb(addr, value); |
468 | da9b266b | bellard | } |
469 | da9b266b | bellard | |
470 | c227f099 | Anthony Liguori | static uint32_t PPC_prep_io_readb (void *opaque, target_phys_addr_t addr) |
471 | da9b266b | bellard | { |
472 | c227f099 | Anthony Liguori | sysctrl_t *sysctrl = opaque; |
473 | da9b266b | bellard | uint32_t ret; |
474 | da9b266b | bellard | |
475 | da9b266b | bellard | addr = prep_IO_address(sysctrl, addr); |
476 | afcea8cb | Blue Swirl | ret = cpu_inb(addr); |
477 | da9b266b | bellard | |
478 | da9b266b | bellard | return ret;
|
479 | da9b266b | bellard | } |
480 | da9b266b | bellard | |
481 | c227f099 | Anthony Liguori | static void PPC_prep_io_writew (void *opaque, target_phys_addr_t addr, |
482 | da9b266b | bellard | uint32_t value) |
483 | da9b266b | bellard | { |
484 | c227f099 | Anthony Liguori | sysctrl_t *sysctrl = opaque; |
485 | da9b266b | bellard | |
486 | da9b266b | bellard | addr = prep_IO_address(sysctrl, addr); |
487 | da9b266b | bellard | #ifdef TARGET_WORDS_BIGENDIAN
|
488 | da9b266b | bellard | value = bswap16(value); |
489 | da9b266b | bellard | #endif
|
490 | 90e189ec | Blue Swirl | PPC_IO_DPRINTF("0x" TARGET_FMT_plx " => 0x%08" PRIx32 "\n", addr, value); |
491 | afcea8cb | Blue Swirl | cpu_outw(addr, value); |
492 | da9b266b | bellard | } |
493 | da9b266b | bellard | |
494 | c227f099 | Anthony Liguori | static uint32_t PPC_prep_io_readw (void *opaque, target_phys_addr_t addr) |
495 | da9b266b | bellard | { |
496 | c227f099 | Anthony Liguori | sysctrl_t *sysctrl = opaque; |
497 | da9b266b | bellard | uint32_t ret; |
498 | da9b266b | bellard | |
499 | da9b266b | bellard | addr = prep_IO_address(sysctrl, addr); |
500 | afcea8cb | Blue Swirl | ret = cpu_inw(addr); |
501 | da9b266b | bellard | #ifdef TARGET_WORDS_BIGENDIAN
|
502 | da9b266b | bellard | ret = bswap16(ret); |
503 | da9b266b | bellard | #endif
|
504 | 90e189ec | Blue Swirl | PPC_IO_DPRINTF("0x" TARGET_FMT_plx " <= 0x%08" PRIx32 "\n", addr, ret); |
505 | da9b266b | bellard | |
506 | da9b266b | bellard | return ret;
|
507 | da9b266b | bellard | } |
508 | da9b266b | bellard | |
509 | c227f099 | Anthony Liguori | static void PPC_prep_io_writel (void *opaque, target_phys_addr_t addr, |
510 | da9b266b | bellard | uint32_t value) |
511 | da9b266b | bellard | { |
512 | c227f099 | Anthony Liguori | sysctrl_t *sysctrl = opaque; |
513 | da9b266b | bellard | |
514 | da9b266b | bellard | addr = prep_IO_address(sysctrl, addr); |
515 | da9b266b | bellard | #ifdef TARGET_WORDS_BIGENDIAN
|
516 | da9b266b | bellard | value = bswap32(value); |
517 | da9b266b | bellard | #endif
|
518 | 90e189ec | Blue Swirl | PPC_IO_DPRINTF("0x" TARGET_FMT_plx " => 0x%08" PRIx32 "\n", addr, value); |
519 | afcea8cb | Blue Swirl | cpu_outl(addr, value); |
520 | da9b266b | bellard | } |
521 | da9b266b | bellard | |
522 | c227f099 | Anthony Liguori | static uint32_t PPC_prep_io_readl (void *opaque, target_phys_addr_t addr) |
523 | da9b266b | bellard | { |
524 | c227f099 | Anthony Liguori | sysctrl_t *sysctrl = opaque; |
525 | da9b266b | bellard | uint32_t ret; |
526 | da9b266b | bellard | |
527 | da9b266b | bellard | addr = prep_IO_address(sysctrl, addr); |
528 | afcea8cb | Blue Swirl | ret = cpu_inl(addr); |
529 | da9b266b | bellard | #ifdef TARGET_WORDS_BIGENDIAN
|
530 | da9b266b | bellard | ret = bswap32(ret); |
531 | da9b266b | bellard | #endif
|
532 | 90e189ec | Blue Swirl | PPC_IO_DPRINTF("0x" TARGET_FMT_plx " <= 0x%08" PRIx32 "\n", addr, ret); |
533 | da9b266b | bellard | |
534 | da9b266b | bellard | return ret;
|
535 | da9b266b | bellard | } |
536 | da9b266b | bellard | |
537 | d60efc6b | Blue Swirl | static CPUWriteMemoryFunc * const PPC_prep_io_write[] = { |
538 | da9b266b | bellard | &PPC_prep_io_writeb, |
539 | da9b266b | bellard | &PPC_prep_io_writew, |
540 | da9b266b | bellard | &PPC_prep_io_writel, |
541 | da9b266b | bellard | }; |
542 | da9b266b | bellard | |
543 | d60efc6b | Blue Swirl | static CPUReadMemoryFunc * const PPC_prep_io_read[] = { |
544 | da9b266b | bellard | &PPC_prep_io_readb, |
545 | da9b266b | bellard | &PPC_prep_io_readw, |
546 | da9b266b | bellard | &PPC_prep_io_readl, |
547 | da9b266b | bellard | }; |
548 | da9b266b | bellard | |
549 | 64201201 | bellard | #define NVRAM_SIZE 0x2000 |
550 | a541f297 | bellard | |
551 | 4556bd8b | Blue Swirl | static void cpu_request_exit(void *opaque, int irq, int level) |
552 | 4556bd8b | Blue Swirl | { |
553 | 4556bd8b | Blue Swirl | CPUState *env = cpu_single_env; |
554 | 4556bd8b | Blue Swirl | |
555 | 4556bd8b | Blue Swirl | if (env && level) {
|
556 | 4556bd8b | Blue Swirl | cpu_exit(env); |
557 | 4556bd8b | Blue Swirl | } |
558 | 4556bd8b | Blue Swirl | } |
559 | 4556bd8b | Blue Swirl | |
560 | 26aa7d72 | bellard | /* PowerPC PREP hardware initialisation */
|
561 | c227f099 | Anthony Liguori | static void ppc_prep_init (ram_addr_t ram_size, |
562 | 3023f332 | aliguori | const char *boot_device, |
563 | b881c2c6 | blueswir1 | const char *kernel_filename, |
564 | 94fc95cd | j_mayer | const char *kernel_cmdline, |
565 | 94fc95cd | j_mayer | const char *initrd_filename, |
566 | 94fc95cd | j_mayer | const char *cpu_model) |
567 | a541f297 | bellard | { |
568 | 49a2942d | Blue Swirl | CPUState *env = NULL;
|
569 | 5cea8590 | Paul Brook | char *filename;
|
570 | c227f099 | Anthony Liguori | nvram_t nvram; |
571 | 43a34704 | Blue Swirl | M48t59State *m48t59; |
572 | a541f297 | bellard | int PPC_io_memory;
|
573 | 4157a662 | bellard | int linux_boot, i, nb_nics1, bios_size;
|
574 | c227f099 | Anthony Liguori | ram_addr_t ram_offset, bios_offset; |
575 | 093209cd | Blue Swirl | uint32_t kernel_base, initrd_base; |
576 | 093209cd | Blue Swirl | long kernel_size, initrd_size;
|
577 | 46e50e9d | bellard | PCIBus *pci_bus; |
578 | d537cf6c | pbrook | qemu_irq *i8259; |
579 | 4556bd8b | Blue Swirl | qemu_irq *cpu_exit_irq; |
580 | 28c5af54 | j_mayer | int ppc_boot_device;
|
581 | f455e98c | Gerd Hoffmann | DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; |
582 | fd8014e1 | Gerd Hoffmann | DriveInfo *fd[MAX_FD]; |
583 | 64201201 | bellard | |
584 | c227f099 | Anthony Liguori | sysctrl = qemu_mallocz(sizeof(sysctrl_t));
|
585 | a541f297 | bellard | |
586 | a541f297 | bellard | linux_boot = (kernel_filename != NULL);
|
587 | 0a032cbe | j_mayer | |
588 | c68ea704 | bellard | /* init CPUs */
|
589 | 94fc95cd | j_mayer | if (cpu_model == NULL) |
590 | b37fc148 | Gerd Hoffmann | cpu_model = "602";
|
591 | fe33cc71 | j_mayer | for (i = 0; i < smp_cpus; i++) { |
592 | aaed909a | bellard | env = cpu_init(cpu_model); |
593 | aaed909a | bellard | if (!env) {
|
594 | aaed909a | bellard | fprintf(stderr, "Unable to find PowerPC CPU definition\n");
|
595 | aaed909a | bellard | exit(1);
|
596 | aaed909a | bellard | } |
597 | 4018bae9 | j_mayer | if (env->flags & POWERPC_FLAG_RTC_CLK) {
|
598 | 4018bae9 | j_mayer | /* POWER / PowerPC 601 RTC clock frequency is 7.8125 MHz */
|
599 | 4018bae9 | j_mayer | cpu_ppc_tb_init(env, 7812500UL);
|
600 | 4018bae9 | j_mayer | } else {
|
601 | 4018bae9 | j_mayer | /* Set time-base frequency to 100 Mhz */
|
602 | 4018bae9 | j_mayer | cpu_ppc_tb_init(env, 100UL * 1000UL * 1000UL); |
603 | 4018bae9 | j_mayer | } |
604 | d84bda46 | Blue Swirl | qemu_register_reset((QEMUResetHandler*)&cpu_reset, env); |
605 | fe33cc71 | j_mayer | } |
606 | a541f297 | bellard | |
607 | a541f297 | bellard | /* allocate RAM */
|
608 | 1724f049 | Alex Williamson | ram_offset = qemu_ram_alloc(NULL, "ppc_prep.ram", ram_size); |
609 | cf9c147c | blueswir1 | cpu_register_physical_memory(0, ram_size, ram_offset);
|
610 | cf9c147c | blueswir1 | |
611 | 64201201 | bellard | /* allocate and load BIOS */
|
612 | 1724f049 | Alex Williamson | bios_offset = qemu_ram_alloc(NULL, "ppc_prep.bios", BIOS_SIZE); |
613 | 1192dad8 | j_mayer | if (bios_name == NULL) |
614 | 1192dad8 | j_mayer | bios_name = BIOS_FILENAME; |
615 | 5cea8590 | Paul Brook | filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); |
616 | 5cea8590 | Paul Brook | if (filename) {
|
617 | 5cea8590 | Paul Brook | bios_size = get_image_size(filename); |
618 | 5cea8590 | Paul Brook | } else {
|
619 | 5cea8590 | Paul Brook | bios_size = -1;
|
620 | 5cea8590 | Paul Brook | } |
621 | dcac9679 | pbrook | if (bios_size > 0 && bios_size <= BIOS_SIZE) { |
622 | c227f099 | Anthony Liguori | target_phys_addr_t bios_addr; |
623 | dcac9679 | pbrook | bios_size = (bios_size + 0xfff) & ~0xfff; |
624 | dcac9679 | pbrook | bios_addr = (uint32_t)(-bios_size); |
625 | dcac9679 | pbrook | cpu_register_physical_memory(bios_addr, bios_size, |
626 | dcac9679 | pbrook | bios_offset | IO_MEM_ROM); |
627 | 5cea8590 | Paul Brook | bios_size = load_image_targphys(filename, bios_addr, bios_size); |
628 | dcac9679 | pbrook | } |
629 | 4157a662 | bellard | if (bios_size < 0 || bios_size > BIOS_SIZE) { |
630 | 5cea8590 | Paul Brook | hw_error("qemu: could not load PPC PREP bios '%s'\n", bios_name);
|
631 | 5cea8590 | Paul Brook | } |
632 | 5cea8590 | Paul Brook | if (filename) {
|
633 | 5cea8590 | Paul Brook | qemu_free(filename); |
634 | 64201201 | bellard | } |
635 | 4c823cff | j_mayer | if (env->nip < 0xFFF80000 && bios_size < 0x00100000) { |
636 | 2ac71179 | Paul Brook | hw_error("PowerPC 601 / 620 / 970 need a 1MB BIOS\n");
|
637 | 4c823cff | j_mayer | } |
638 | 26aa7d72 | bellard | |
639 | a541f297 | bellard | if (linux_boot) {
|
640 | 64201201 | bellard | kernel_base = KERNEL_LOAD_ADDR; |
641 | a541f297 | bellard | /* now we can load the kernel */
|
642 | dcac9679 | pbrook | kernel_size = load_image_targphys(kernel_filename, kernel_base, |
643 | dcac9679 | pbrook | ram_size - kernel_base); |
644 | 64201201 | bellard | if (kernel_size < 0) { |
645 | 2ac71179 | Paul Brook | hw_error("qemu: could not load kernel '%s'\n", kernel_filename);
|
646 | a541f297 | bellard | exit(1);
|
647 | a541f297 | bellard | } |
648 | a541f297 | bellard | /* load initrd */
|
649 | a541f297 | bellard | if (initrd_filename) {
|
650 | 64201201 | bellard | initrd_base = INITRD_LOAD_ADDR; |
651 | dcac9679 | pbrook | initrd_size = load_image_targphys(initrd_filename, initrd_base, |
652 | dcac9679 | pbrook | ram_size - initrd_base); |
653 | a541f297 | bellard | if (initrd_size < 0) { |
654 | 2ac71179 | Paul Brook | hw_error("qemu: could not load initial ram disk '%s'\n",
|
655 | 4a057712 | j_mayer | initrd_filename); |
656 | a541f297 | bellard | } |
657 | 64201201 | bellard | } else {
|
658 | 64201201 | bellard | initrd_base = 0;
|
659 | 64201201 | bellard | initrd_size = 0;
|
660 | a541f297 | bellard | } |
661 | 6ac0e82d | balrog | ppc_boot_device = 'm';
|
662 | a541f297 | bellard | } else {
|
663 | 64201201 | bellard | kernel_base = 0;
|
664 | 64201201 | bellard | kernel_size = 0;
|
665 | 64201201 | bellard | initrd_base = 0;
|
666 | 64201201 | bellard | initrd_size = 0;
|
667 | 28c5af54 | j_mayer | ppc_boot_device = '\0';
|
668 | 28c5af54 | j_mayer | /* For now, OHW cannot boot from the network. */
|
669 | 0d913fdb | j_mayer | for (i = 0; boot_device[i] != '\0'; i++) { |
670 | 0d913fdb | j_mayer | if (boot_device[i] >= 'a' && boot_device[i] <= 'f') { |
671 | 0d913fdb | j_mayer | ppc_boot_device = boot_device[i]; |
672 | 28c5af54 | j_mayer | break;
|
673 | 0d913fdb | j_mayer | } |
674 | 28c5af54 | j_mayer | } |
675 | 28c5af54 | j_mayer | if (ppc_boot_device == '\0') { |
676 | 28c5af54 | j_mayer | fprintf(stderr, "No valid boot device for Mac99 machine\n");
|
677 | 28c5af54 | j_mayer | exit(1);
|
678 | 28c5af54 | j_mayer | } |
679 | a541f297 | bellard | } |
680 | a541f297 | bellard | |
681 | 64201201 | bellard | isa_mem_base = 0xc0000000;
|
682 | dd37a5e4 | j_mayer | if (PPC_INPUT(env) != PPC_FLAGS_INPUT_6xx) {
|
683 | 2ac71179 | Paul Brook | hw_error("Only 6xx bus is supported on PREP machine\n");
|
684 | dd37a5e4 | j_mayer | } |
685 | 24be5ae3 | j_mayer | i8259 = i8259_init(first_cpu->irq_inputs[PPC6xx_INPUT_INT]); |
686 | d537cf6c | pbrook | pci_bus = pci_prep_init(i8259); |
687 | b37fc148 | Gerd Hoffmann | /* Hmm, prep has no pci-isa bridge ??? */
|
688 | b37fc148 | Gerd Hoffmann | isa_bus_new(NULL);
|
689 | b37fc148 | Gerd Hoffmann | isa_bus_irqs(i8259); |
690 | da9b266b | bellard | // pci_bus = i440fx_init();
|
691 | da9b266b | bellard | /* Register 8 MB of ISA IO space (needed for non-contiguous map) */
|
692 | 1eed09cb | Avi Kivity | PPC_io_memory = cpu_register_io_memory(PPC_prep_io_read, |
693 | da9b266b | bellard | PPC_prep_io_write, sysctrl); |
694 | da9b266b | bellard | cpu_register_physical_memory(0x80000000, 0x00800000, PPC_io_memory); |
695 | 64201201 | bellard | |
696 | a541f297 | bellard | /* init basic PC hardware */
|
697 | 78895427 | Gerd Hoffmann | pci_vga_init(pci_bus); |
698 | 64201201 | bellard | // openpic = openpic_init(0x00000000, 0xF0000000, 1);
|
699 | d537cf6c | pbrook | // pit = pit_init(0x40, i8259[0]);
|
700 | 7d932dfd | Jan Kiszka | rtc_init(2000, NULL); |
701 | a541f297 | bellard | |
702 | ac0be998 | Gerd Hoffmann | if (serial_hds[0]) |
703 | ac0be998 | Gerd Hoffmann | serial_isa_init(0, serial_hds[0]); |
704 | a541f297 | bellard | nb_nics1 = nb_nics; |
705 | a541f297 | bellard | if (nb_nics1 > NE2000_NB_MAX)
|
706 | a541f297 | bellard | nb_nics1 = NE2000_NB_MAX; |
707 | a541f297 | bellard | for(i = 0; i < nb_nics1; i++) { |
708 | 5652ef78 | aurel32 | if (nd_table[i].model == NULL) { |
709 | 9203f520 | Mark McLoughlin | nd_table[i].model = qemu_strdup("ne2k_isa");
|
710 | 5652ef78 | aurel32 | } |
711 | 5652ef78 | aurel32 | if (strcmp(nd_table[i].model, "ne2k_isa") == 0) { |
712 | 9453c5bc | Gerd Hoffmann | isa_ne2000_init(ne2000_io[i], ne2000_irq[i], &nd_table[i]); |
713 | a41b2ff2 | pbrook | } else {
|
714 | 07caea31 | Markus Armbruster | pci_nic_init_nofail(&nd_table[i], "ne2k_pci", NULL); |
715 | a41b2ff2 | pbrook | } |
716 | a541f297 | bellard | } |
717 | a541f297 | bellard | |
718 | e4bcb14c | ths | if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) {
|
719 | e4bcb14c | ths | fprintf(stderr, "qemu: too many IDE bus\n");
|
720 | e4bcb14c | ths | exit(1);
|
721 | e4bcb14c | ths | } |
722 | e4bcb14c | ths | |
723 | e4bcb14c | ths | for(i = 0; i < MAX_IDE_BUS * MAX_IDE_DEVS; i++) { |
724 | f455e98c | Gerd Hoffmann | hd[i] = drive_get(IF_IDE, i / MAX_IDE_DEVS, i % MAX_IDE_DEVS); |
725 | e4bcb14c | ths | } |
726 | e4bcb14c | ths | |
727 | e4bcb14c | ths | for(i = 0; i < MAX_IDE_BUS; i++) { |
728 | dea21e97 | Gerd Hoffmann | isa_ide_init(ide_iobase[i], ide_iobase2[i], ide_irq[i], |
729 | e4bcb14c | ths | hd[2 * i],
|
730 | e4bcb14c | ths | hd[2 * i + 1]); |
731 | a541f297 | bellard | } |
732 | 11d23c35 | Gerd Hoffmann | isa_create_simple("i8042");
|
733 | 4556bd8b | Blue Swirl | |
734 | 4556bd8b | Blue Swirl | cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1); |
735 | 4556bd8b | Blue Swirl | DMA_init(1, cpu_exit_irq);
|
736 | 4556bd8b | Blue Swirl | |
737 | a541f297 | bellard | // SB16_init();
|
738 | a541f297 | bellard | |
739 | e4bcb14c | ths | for(i = 0; i < MAX_FD; i++) { |
740 | fd8014e1 | Gerd Hoffmann | fd[i] = drive_get(IF_FLOPPY, 0, i);
|
741 | e4bcb14c | ths | } |
742 | 86c86157 | Gerd Hoffmann | fdctrl_init_isa(fd); |
743 | a541f297 | bellard | |
744 | 64201201 | bellard | /* Register speaker port */
|
745 | 64201201 | bellard | register_ioport_read(0x61, 1, 1, speaker_ioport_read, NULL); |
746 | 64201201 | bellard | register_ioport_write(0x61, 1, 1, speaker_ioport_write, NULL); |
747 | a541f297 | bellard | /* Register fake IO ports for PREP */
|
748 | c4781a51 | j_mayer | sysctrl->reset_irq = first_cpu->irq_inputs[PPC6xx_INPUT_HRESET]; |
749 | 64201201 | bellard | register_ioport_read(0x398, 2, 1, &PREP_io_read, sysctrl); |
750 | 64201201 | bellard | register_ioport_write(0x398, 2, 1, &PREP_io_write, sysctrl); |
751 | a541f297 | bellard | /* System control ports */
|
752 | 64201201 | bellard | register_ioport_read(0x0092, 0x01, 1, &PREP_io_800_readb, sysctrl); |
753 | 64201201 | bellard | register_ioport_write(0x0092, 0x01, 1, &PREP_io_800_writeb, sysctrl); |
754 | 64201201 | bellard | register_ioport_read(0x0800, 0x52, 1, &PREP_io_800_readb, sysctrl); |
755 | 64201201 | bellard | register_ioport_write(0x0800, 0x52, 1, &PREP_io_800_writeb, sysctrl); |
756 | 64201201 | bellard | /* PCI intack location */
|
757 | 1eed09cb | Avi Kivity | PPC_io_memory = cpu_register_io_memory(PPC_intack_read, |
758 | a4193c8a | bellard | PPC_intack_write, NULL);
|
759 | a541f297 | bellard | cpu_register_physical_memory(0xBFFFFFF0, 0x4, PPC_io_memory); |
760 | 64201201 | bellard | /* PowerPC control and status register group */
|
761 | b6b8bd18 | bellard | #if 0
|
762 | 1eed09cb | Avi Kivity | PPC_io_memory = cpu_register_io_memory(PPC_XCSR_read, PPC_XCSR_write,
|
763 | 36081602 | j_mayer | NULL);
|
764 | 64201201 | bellard | cpu_register_physical_memory(0xFEFF0000, 0x1000, PPC_io_memory);
|
765 | b6b8bd18 | bellard | #endif
|
766 | a541f297 | bellard | |
767 | 0d92ed30 | pbrook | if (usb_enabled) {
|
768 | a67ba3b6 | Paul Brook | usb_ohci_init_pci(pci_bus, -1);
|
769 | 0d92ed30 | pbrook | } |
770 | 0d92ed30 | pbrook | |
771 | 3cbee15b | j_mayer | m48t59 = m48t59_init(i8259[8], 0, 0x0074, NVRAM_SIZE, 59); |
772 | 3cbee15b | j_mayer | if (m48t59 == NULL) |
773 | 64201201 | bellard | return;
|
774 | 3cbee15b | j_mayer | sysctrl->nvram = m48t59; |
775 | 64201201 | bellard | |
776 | 64201201 | bellard | /* Initialise NVRAM */
|
777 | 3cbee15b | j_mayer | nvram.opaque = m48t59; |
778 | 3cbee15b | j_mayer | nvram.read_fn = &m48t59_read; |
779 | 3cbee15b | j_mayer | nvram.write_fn = &m48t59_write; |
780 | 6ac0e82d | balrog | PPC_NVRAM_set_params(&nvram, NVRAM_SIZE, "PREP", ram_size, ppc_boot_device,
|
781 | 64201201 | bellard | kernel_base, kernel_size, |
782 | b6b8bd18 | bellard | kernel_cmdline, |
783 | 64201201 | bellard | initrd_base, initrd_size, |
784 | 64201201 | bellard | /* XXX: need an option to load a NVRAM image */
|
785 | b6b8bd18 | bellard | 0,
|
786 | b6b8bd18 | bellard | graphic_width, graphic_height, graphic_depth); |
787 | c0e564d5 | bellard | |
788 | c0e564d5 | bellard | /* Special port to get debug messages from Open-Firmware */
|
789 | c0e564d5 | bellard | register_ioport_write(0x0F00, 4, 1, &PPC_debug_write, NULL); |
790 | a541f297 | bellard | } |
791 | c0e564d5 | bellard | |
792 | f80f9ec9 | Anthony Liguori | static QEMUMachine prep_machine = {
|
793 | 4b32e168 | aliguori | .name = "prep",
|
794 | 4b32e168 | aliguori | .desc = "PowerPC PREP platform",
|
795 | 4b32e168 | aliguori | .init = ppc_prep_init, |
796 | 3d878caa | balrog | .max_cpus = MAX_CPUS, |
797 | c0e564d5 | bellard | }; |
798 | f80f9ec9 | Anthony Liguori | |
799 | f80f9ec9 | Anthony Liguori | static void prep_machine_init(void) |
800 | f80f9ec9 | Anthony Liguori | { |
801 | f80f9ec9 | Anthony Liguori | qemu_register_machine(&prep_machine); |
802 | f80f9ec9 | Anthony Liguori | } |
803 | f80f9ec9 | Anthony Liguori | |
804 | f80f9ec9 | Anthony Liguori | machine_init(prep_machine_init); |