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