]> git.proxmox.com Git - mirror_qemu.git/blame - hw/ppc_chrp.c
find -type f | xargs sed -i 's/[\t ]$//g' # on most files
[mirror_qemu.git] / hw / ppc_chrp.c
CommitLineData
64201201
FB
1/*
2 * QEMU PPC CHRP/PMAC hardware System Emulator
5fafdf24 3 *
47103572 4 * Copyright (c) 2004-2007 Fabrice Bellard
5fafdf24 5 *
64201201
FB
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
24#include "vl.h"
25
e9df014c
JM
26/* SMP is not enabled, for now */
27#define MAX_CPUS 1
28
64201201 29#define BIOS_FILENAME "ppc_rom.bin"
d5295253 30#define VGABIOS_FILENAME "video.x"
64201201
FB
31#define NVRAM_SIZE 0x2000
32
b6b8bd18
FB
33#define KERNEL_LOAD_ADDR 0x01000000
34#define INITRD_LOAD_ADDR 0x01800000
35
267002cd 36/* MacIO devices (mapped inside the MacIO address space): CUDA, DBDMA,
e5733356 37 NVRAM */
267002cd
FB
38
39static int dbdma_mem_index;
40static int cuda_mem_index;
0aa6a4a2
FB
41static int ide0_mem_index = -1;
42static int ide1_mem_index = -1;
43static int openpic_mem_index = -1;
44static int heathrow_pic_mem_index = -1;
e5733356 45static int macio_nvram_mem_index = -1;
267002cd
FB
46
47/* DBDMA: currently no op - should suffice right now */
48
49static void dbdma_writeb (void *opaque, target_phys_addr_t addr, uint32_t value)
50{
e96efcfc 51 printf("%s: 0x" PADDRX " <= 0x%08x\n", __func__, addr, value);
267002cd
FB
52}
53
54static void dbdma_writew (void *opaque, target_phys_addr_t addr, uint32_t value)
55{
56}
57
58static void dbdma_writel (void *opaque, target_phys_addr_t addr, uint32_t value)
59{
60}
61
62static uint32_t dbdma_readb (void *opaque, target_phys_addr_t addr)
63{
e96efcfc 64 printf("%s: 0x" PADDRX " => 0x00000000\n", __func__, addr);
267002cd
FB
65 return 0;
66}
67
68static uint32_t dbdma_readw (void *opaque, target_phys_addr_t addr)
69{
70 return 0;
71}
72
73static uint32_t dbdma_readl (void *opaque, target_phys_addr_t addr)
74{
75 return 0;
76}
77
78static CPUWriteMemoryFunc *dbdma_write[] = {
79 &dbdma_writeb,
80 &dbdma_writew,
81 &dbdma_writel,
82};
83
84static CPUReadMemoryFunc *dbdma_read[] = {
85 &dbdma_readb,
86 &dbdma_readw,
87 &dbdma_readl,
88};
89
e5733356
FB
90/* macio style NVRAM device */
91typedef struct MacIONVRAMState {
92 uint8_t data[0x2000];
93} MacIONVRAMState;
94
95static void macio_nvram_writeb (void *opaque, target_phys_addr_t addr, uint32_t value)
96{
97 MacIONVRAMState *s = opaque;
98 addr = (addr >> 4) & 0x1fff;
99 s->data[addr] = value;
100 // printf("macio_nvram_writeb %04x = %02x\n", addr, value);
101}
102
103static uint32_t macio_nvram_readb (void *opaque, target_phys_addr_t addr)
104{
105 MacIONVRAMState *s = opaque;
106 uint32_t value;
107
108 addr = (addr >> 4) & 0x1fff;
109 value = s->data[addr];
110 // printf("macio_nvram_readb %04x = %02x\n", addr, value);
111 return value;
112}
113
114static CPUWriteMemoryFunc *macio_nvram_write[] = {
115 &macio_nvram_writeb,
116 &macio_nvram_writeb,
117 &macio_nvram_writeb,
118};
119
120static CPUReadMemoryFunc *macio_nvram_read[] = {
121 &macio_nvram_readb,
122 &macio_nvram_readb,
123 &macio_nvram_readb,
124};
125
126static MacIONVRAMState *macio_nvram_init(void)
127{
128 MacIONVRAMState *s;
129 s = qemu_mallocz(sizeof(MacIONVRAMState));
130 if (!s)
131 return NULL;
5fafdf24 132 macio_nvram_mem_index = cpu_register_io_memory(0, macio_nvram_read,
e5733356
FB
133 macio_nvram_write, s);
134 return s;
135}
136
5fafdf24 137static void macio_map(PCIDevice *pci_dev, int region_num,
267002cd
FB
138 uint32_t addr, uint32_t size, int type)
139{
0aa6a4a2 140 if (heathrow_pic_mem_index >= 0) {
5fafdf24 141 cpu_register_physical_memory(addr + 0x00000, 0x1000,
0aa6a4a2
FB
142 heathrow_pic_mem_index);
143 }
267002cd
FB
144 cpu_register_physical_memory(addr + 0x08000, 0x1000, dbdma_mem_index);
145 cpu_register_physical_memory(addr + 0x16000, 0x2000, cuda_mem_index);
0aa6a4a2
FB
146 if (ide0_mem_index >= 0)
147 cpu_register_physical_memory(addr + 0x1f000, 0x1000, ide0_mem_index);
148 if (ide1_mem_index >= 0)
149 cpu_register_physical_memory(addr + 0x20000, 0x1000, ide1_mem_index);
150 if (openpic_mem_index >= 0) {
5fafdf24 151 cpu_register_physical_memory(addr + 0x40000, 0x40000,
0aa6a4a2
FB
152 openpic_mem_index);
153 }
e5733356
FB
154 if (macio_nvram_mem_index >= 0)
155 cpu_register_physical_memory(addr + 0x60000, 0x20000, macio_nvram_mem_index);
267002cd
FB
156}
157
e5733356 158static void macio_init(PCIBus *bus, int device_id)
267002cd
FB
159{
160 PCIDevice *d;
161
46e50e9d
FB
162 d = pci_register_device(bus, "macio", sizeof(PCIDevice),
163 -1, NULL, NULL);
267002cd
FB
164 /* Note: this code is strongly inspirated from the corresponding code
165 in PearPC */
166 d->config[0x00] = 0x6b; // vendor_id
167 d->config[0x01] = 0x10;
e5733356
FB
168 d->config[0x02] = device_id;
169 d->config[0x03] = device_id >> 8;
267002cd
FB
170
171 d->config[0x0a] = 0x00; // class_sub = pci2pci
172 d->config[0x0b] = 0xff; // class_base = bridge
173 d->config[0x0e] = 0x00; // header_type
174
175 d->config[0x3d] = 0x01; // interrupt on pin 1
5fafdf24 176
267002cd
FB
177 dbdma_mem_index = cpu_register_io_memory(0, dbdma_read, dbdma_write, NULL);
178
5fafdf24 179 pci_register_io_region(d, 0, 0x80000,
267002cd
FB
180 PCI_ADDRESS_SPACE_MEM, macio_map);
181}
182
0aa6a4a2
FB
183/* UniN device */
184static void unin_writel (void *opaque, target_phys_addr_t addr, uint32_t value)
185{
186}
187
188static uint32_t unin_readl (void *opaque, target_phys_addr_t addr)
189{
190 return 0;
191}
192
193static CPUWriteMemoryFunc *unin_write[] = {
194 &unin_writel,
195 &unin_writel,
196 &unin_writel,
197};
198
199static CPUReadMemoryFunc *unin_read[] = {
200 &unin_readl,
201 &unin_readl,
202 &unin_readl,
203};
204
205/* temporary frame buffer OSI calls for the video.x driver. The right
206 solution is to modify the driver to use VGA PCI I/Os */
207static int vga_osi_call(CPUState *env)
208{
209 static int vga_vbl_enabled;
210 int linesize;
5fafdf24 211
0aa6a4a2
FB
212 // printf("osi_call R5=%d\n", env->gpr[5]);
213
214 /* same handler as PearPC, coming from the original MOL video
215 driver. */
216 switch(env->gpr[5]) {
217 case 4:
218 break;
219 case 28: /* set_vmode */
220 if (env->gpr[6] != 1 || env->gpr[7] != 0)
221 env->gpr[3] = 1;
222 else
223 env->gpr[3] = 0;
224 break;
225 case 29: /* get_vmode_info */
226 if (env->gpr[6] != 0) {
227 if (env->gpr[6] != 1 || env->gpr[7] != 0) {
228 env->gpr[3] = 1;
229 break;
230 }
231 }
5fafdf24 232 env->gpr[3] = 0;
0aa6a4a2
FB
233 env->gpr[4] = (1 << 16) | 1; /* num_vmodes, cur_vmode */
234 env->gpr[5] = (1 << 16) | 0; /* num_depths, cur_depth_mode */
235 env->gpr[6] = (graphic_width << 16) | graphic_height; /* w, h */
236 env->gpr[7] = 85 << 16; /* refresh rate */
237 env->gpr[8] = (graphic_depth + 7) & ~7; /* depth (round to byte) */
238 linesize = ((graphic_depth + 7) >> 3) * graphic_width;
239 linesize = (linesize + 3) & ~3;
240 env->gpr[9] = (linesize << 16) | 0; /* row_bytes, offset */
241 break;
242 case 31: /* set_video power */
243 env->gpr[3] = 0;
244 break;
245 case 39: /* video_ctrl */
246 if (env->gpr[6] == 0 || env->gpr[6] == 1)
247 vga_vbl_enabled = env->gpr[6];
248 env->gpr[3] = 0;
249 break;
250 case 47:
251 break;
252 case 59: /* set_color */
253 /* R6 = index, R7 = RGB */
254 env->gpr[3] = 0;
255 break;
256 case 64: /* get color */
257 /* R6 = index */
5fafdf24 258 env->gpr[3] = 0;
0aa6a4a2
FB
259 break;
260 case 116: /* set hwcursor */
261 /* R6 = x, R7 = y, R8 = visible, R9 = data */
262 break;
263 default:
e96efcfc 264 fprintf(stderr, "unsupported OSI call R5=" REGX "\n", env->gpr[5]);
0aa6a4a2
FB
265 break;
266 }
267 return 1; /* osi_call handled */
268}
269
e5733356
FB
270static uint8_t nvram_chksum(const uint8_t *buf, int n)
271{
272 int sum, i;
273 sum = 0;
274 for(i = 0; i < n; i++)
275 sum += buf[i];
276 return (sum & 0xff) + (sum >> 8);
277}
278
279/* set a free Mac OS NVRAM partition */
280void pmac_format_nvram_partition(uint8_t *buf, int len)
281{
282 char partition_name[12] = "wwwwwwwwwwww";
5fafdf24 283
e5733356
FB
284 buf[0] = 0x7f; /* free partition magic */
285 buf[1] = 0; /* checksum */
286 buf[2] = len >> 8;
287 buf[3] = len;
288 memcpy(buf + 4, partition_name, 12);
289 buf[1] = nvram_chksum(buf, 16);
5fafdf24 290}
e5733356 291
0aa6a4a2 292/* PowerPC CHRP hardware initialisation */
94fc95cd
JM
293static void ppc_chrp_init (int ram_size, int vga_ram_size, int boot_device,
294 DisplayState *ds, const char **fd_filename,
295 int snapshot,
296 const char *kernel_filename,
297 const char *kernel_cmdline,
298 const char *initrd_filename,
299 const char *cpu_model,
300 int is_heathrow)
64201201 301{
e9df014c 302 CPUState *env, *envs[MAX_CPUS];
64201201 303 char buf[1024];
e9df014c 304 qemu_irq *pic, **openpic_irqs;
64201201 305 m48t59_t *nvram;
aef445bd 306 int unin_memory;
d5295253
FB
307 int linux_boot, i;
308 unsigned long bios_offset, vga_bios_offset;
b6b8bd18 309 uint32_t kernel_base, kernel_size, initrd_base, initrd_size;
3fc6c082 310 ppc_def_t *def;
46e50e9d 311 PCIBus *pci_bus;
0aa6a4a2 312 const char *arch_name;
d5295253 313 int vga_bios_size, bios_size;
d537cf6c 314 qemu_irq *dummy_irq;
46e50e9d 315
64201201
FB
316 linux_boot = (kernel_filename != NULL);
317
c68ea704
FB
318 /* init CPUs */
319 env = cpu_init();
0a032cbe 320 qemu_register_reset(&cpu_ppc_reset, env);
c68ea704
FB
321 register_savevm("cpu", 0, 3, cpu_save, cpu_load, env);
322
94fc95cd
JM
323 /* Default CPU is a generic 74x/75x */
324 if (cpu_model == NULL)
325 cpu_model = "750";
c68ea704
FB
326 /* XXX: CPU model (or PVR) should be provided on command line */
327 // ppc_find_by_name("750gx", &def); // Linux boot OK
328 // ppc_find_by_name("750fx", &def); // Linux boot OK
329 /* Linux does not boot on 750cxe (and probably other 750cx based)
330 * because it assumes it has 8 IBAT & DBAT pairs as it only have 4.
331 */
94fc95cd 332 ppc_find_by_name(cpu_model, &def);
c68ea704
FB
333 if (def == NULL) {
334 cpu_abort(env, "Unable to find PowerPC CPU definition\n");
335 }
e9df014c
JM
336 for (i = 0; i < smp_cpus; i++) {
337 cpu_ppc_register(env, def);
338 /* Set time-base frequency to 100 Mhz */
339 cpu_ppc_tb_init(env, 100UL * 1000UL * 1000UL);
340 env->osi_call = vga_osi_call;
341 envs[i] = env;
342 }
c68ea704 343
64201201
FB
344 /* allocate RAM */
345 cpu_register_physical_memory(0, ram_size, IO_MEM_RAM);
346
347 /* allocate and load BIOS */
348 bios_offset = ram_size + vga_ram_size;
349 snprintf(buf, sizeof(buf), "%s/%s", bios_dir, BIOS_FILENAME);
d5295253
FB
350 bios_size = load_image(buf, phys_ram_base + bios_offset);
351 if (bios_size < 0 || bios_size > BIOS_SIZE) {
4a057712 352 cpu_abort(env, "qemu: could not load PowerPC bios '%s'\n", buf);
64201201
FB
353 exit(1);
354 }
d5295253 355 bios_size = (bios_size + 0xfff) & ~0xfff;
4a057712 356 cpu_register_physical_memory((uint32_t)(-bios_size),
d5295253 357 bios_size, bios_offset | IO_MEM_ROM);
5fafdf24 358
d5295253
FB
359 /* allocate and load VGA BIOS */
360 vga_bios_offset = bios_offset + bios_size;
361 snprintf(buf, sizeof(buf), "%s/%s", bios_dir, VGABIOS_FILENAME);
362 vga_bios_size = load_image(buf, phys_ram_base + vga_bios_offset + 8);
363 if (vga_bios_size < 0) {
364 /* if no bios is present, we can still work */
365 fprintf(stderr, "qemu: warning: could not load VGA bios '%s'\n", buf);
366 vga_bios_size = 0;
367 } else {
368 /* set a specific header (XXX: find real Apple format for NDRV
369 drivers) */
370 phys_ram_base[vga_bios_offset] = 'N';
371 phys_ram_base[vga_bios_offset + 1] = 'D';
372 phys_ram_base[vga_bios_offset + 2] = 'R';
373 phys_ram_base[vga_bios_offset + 3] = 'V';
5fafdf24 374 cpu_to_be32w((uint32_t *)(phys_ram_base + vga_bios_offset + 4),
d5295253
FB
375 vga_bios_size);
376 vga_bios_size += 8;
377 }
378 vga_bios_size = (vga_bios_size + 0xfff) & ~0xfff;
5fafdf24 379
b6b8bd18
FB
380 if (linux_boot) {
381 kernel_base = KERNEL_LOAD_ADDR;
382 /* now we can load the kernel */
383 kernel_size = load_image(kernel_filename, phys_ram_base + kernel_base);
384 if (kernel_size < 0) {
4a057712
JM
385 cpu_abort(env, "qemu: could not load kernel '%s'\n",
386 kernel_filename);
b6b8bd18
FB
387 exit(1);
388 }
389 /* load initrd */
390 if (initrd_filename) {
391 initrd_base = INITRD_LOAD_ADDR;
392 initrd_size = load_image(initrd_filename,
393 phys_ram_base + initrd_base);
394 if (initrd_size < 0) {
4a057712
JM
395 cpu_abort(env, "qemu: could not load initial ram disk '%s'\n",
396 initrd_filename);
b6b8bd18
FB
397 exit(1);
398 }
399 } else {
400 initrd_base = 0;
401 initrd_size = 0;
402 }
403 boot_device = 'm';
404 } else {
405 kernel_base = 0;
406 kernel_size = 0;
407 initrd_base = 0;
408 initrd_size = 0;
409 }
0aa6a4a2
FB
410
411 if (is_heathrow) {
412 isa_mem_base = 0x80000000;
dd37a5e4 413
0aa6a4a2 414 /* Register 2 MB of ISA IO space */
aef445bd
PB
415 isa_mmio_init(0xfe000000, 0x00200000);
416
0aa6a4a2 417 /* init basic PC hardware */
dd37a5e4
JM
418 if (PPC_INPUT(env) != PPC_FLAGS_INPUT_6xx) {
419 cpu_abort(env, "Only 6xx bus is supported on heathrow machine\n");
420 exit(1);
421 }
502a5395 422 pic = heathrow_pic_init(&heathrow_pic_mem_index);
502a5395 423 pci_bus = pci_grackle_init(0xfec00000, pic);
dd37a5e4 424 pci_vga_init(pci_bus, ds, phys_ram_base + ram_size,
89b6b508
FB
425 ram_size, vga_ram_size,
426 vga_bios_offset, vga_bios_size);
0aa6a4a2
FB
427
428 /* XXX: suppress that */
d537cf6c 429 dummy_irq = i8259_init(NULL);
5fafdf24 430
0aa6a4a2 431 /* XXX: use Mac Serial port */
d537cf6c 432 serial_init(0x3f8, dummy_irq[4], serial_hds[0]);
5fafdf24 433
0aa6a4a2 434 for(i = 0; i < nb_nics; i++) {
a41b2ff2
PB
435 if (!nd_table[i].model)
436 nd_table[i].model = "ne2k_pci";
abcebc7e 437 pci_nic_init(pci_bus, &nd_table[i], -1);
0aa6a4a2 438 }
5fafdf24 439
0aa6a4a2
FB
440 pci_cmd646_ide_init(pci_bus, &bs_table[0], 0);
441
442 /* cuda also initialize ADB */
d537cf6c 443 cuda_mem_index = cuda_init(pic[0x12]);
5fafdf24 444
0aa6a4a2
FB
445 adb_kbd_init(&adb_bus);
446 adb_mouse_init(&adb_bus);
5fafdf24 447
e5733356
FB
448 {
449 MacIONVRAMState *nvr;
450 nvr = macio_nvram_init();
451 pmac_format_nvram_partition(nvr->data, 0x2000);
452 }
453
454 macio_init(pci_bus, 0x0017);
47103572 455
d537cf6c 456 nvram = m48t59_init(dummy_irq[8], 0xFFF04000, 0x0074, NVRAM_SIZE, 59);
47103572 457
0aa6a4a2
FB
458 arch_name = "HEATHROW";
459 } else {
460 isa_mem_base = 0x80000000;
47103572 461
0aa6a4a2 462 /* Register 8 MB of ISA IO space */
aef445bd 463 isa_mmio_init(0xf2000000, 0x00800000);
47103572 464
0aa6a4a2
FB
465 /* UniN init */
466 unin_memory = cpu_register_io_memory(0, unin_read, unin_write, NULL);
467 cpu_register_physical_memory(0xf8000000, 0x00001000, unin_memory);
468
e9df014c
JM
469 openpic_irqs = qemu_mallocz(smp_cpus * sizeof(qemu_irq *));
470 openpic_irqs[0] =
471 qemu_mallocz(smp_cpus * sizeof(qemu_irq) * OPENPIC_OUTPUT_NB);
472 for (i = 0; i < smp_cpus; i++) {
473 /* Mac99 IRQ connection between OpenPIC outputs pins
474 * and PowerPC input pins
475 */
dd37a5e4
JM
476 switch (PPC_INPUT(env)) {
477 case PPC_FLAGS_INPUT_6xx:
478 openpic_irqs[i] = openpic_irqs[0] + (i * OPENPIC_OUTPUT_NB);
479 openpic_irqs[i][OPENPIC_OUTPUT_INT] =
480 ((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_INT];
481 openpic_irqs[i][OPENPIC_OUTPUT_CINT] =
482 ((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_INT];
483 openpic_irqs[i][OPENPIC_OUTPUT_MCK] =
484 ((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_MCP];
485 /* Not connected ? */
486 openpic_irqs[i][OPENPIC_OUTPUT_DEBUG] = NULL;
487 /* Check this */
488 openpic_irqs[i][OPENPIC_OUTPUT_RESET] =
489 ((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_HRESET];
490 break;
491 case PPC_FLAGS_INPUT_970:
492 openpic_irqs[i] = openpic_irqs[0] + (i * OPENPIC_OUTPUT_NB);
493 openpic_irqs[i][OPENPIC_OUTPUT_INT] =
494 ((qemu_irq *)env->irq_inputs)[PPC970_INPUT_INT];
495 openpic_irqs[i][OPENPIC_OUTPUT_CINT] =
496 ((qemu_irq *)env->irq_inputs)[PPC970_INPUT_INT];
497 openpic_irqs[i][OPENPIC_OUTPUT_MCK] =
498 ((qemu_irq *)env->irq_inputs)[PPC970_INPUT_MCP];
499 /* Not connected ? */
500 openpic_irqs[i][OPENPIC_OUTPUT_DEBUG] = NULL;
501 /* Check this */
502 openpic_irqs[i][OPENPIC_OUTPUT_RESET] =
503 ((qemu_irq *)env->irq_inputs)[PPC970_INPUT_HRESET];
504 break;
505 default:
506 cpu_abort(env,
507 "Only bus model not supported on mac99 machine\n");
508 exit(1);
509 }
e9df014c
JM
510 }
511 pic = openpic_init(NULL, &openpic_mem_index, smp_cpus,
512 openpic_irqs, NULL);
502a5395 513 pci_bus = pci_pmac_init(pic);
0aa6a4a2 514 /* init basic PC hardware */
89b6b508
FB
515 pci_vga_init(pci_bus, ds, phys_ram_base + ram_size,
516 ram_size, vga_ram_size,
517 vga_bios_offset, vga_bios_size);
0aa6a4a2
FB
518
519 /* XXX: suppress that */
d537cf6c 520 dummy_irq = i8259_init(NULL);
3079c59a 521
0aa6a4a2 522 /* XXX: use Mac Serial port */
d537cf6c 523 serial_init(0x3f8, dummy_irq[4], serial_hds[0]);
0aa6a4a2 524 for(i = 0; i < nb_nics; i++) {
3079c59a
JM
525 if (!nd_table[i].model)
526 nd_table[i].model = "ne2k_pci";
527 pci_nic_init(pci_bus, &nd_table[i], -1);
0aa6a4a2 528 }
0aa6a4a2 529#if 1
d537cf6c
PB
530 ide0_mem_index = pmac_ide_init(&bs_table[0], pic[0x13]);
531 ide1_mem_index = pmac_ide_init(&bs_table[2], pic[0x14]);
0aa6a4a2
FB
532#else
533 pci_cmd646_ide_init(pci_bus, &bs_table[0], 0);
534#endif
535 /* cuda also initialize ADB */
d537cf6c 536 cuda_mem_index = cuda_init(pic[0x19]);
5fafdf24 537
0aa6a4a2
FB
538 adb_kbd_init(&adb_bus);
539 adb_mouse_init(&adb_bus);
5fafdf24 540
e5733356 541 macio_init(pci_bus, 0x0022);
5fafdf24 542
d537cf6c 543 nvram = m48t59_init(dummy_irq[8], 0xFFF04000, 0x0074, NVRAM_SIZE, 59);
5fafdf24 544
0aa6a4a2 545 arch_name = "MAC99";
64201201 546 }
0d92ed30
PB
547
548 if (usb_enabled) {
e24ad6f1 549 usb_ohci_init_pci(pci_bus, 3, -1);
0d92ed30
PB
550 }
551
b6b8bd18
FB
552 if (graphic_depth != 15 && graphic_depth != 32 && graphic_depth != 8)
553 graphic_depth = 15;
64201201 554
0aa6a4a2 555 PPC_NVRAM_set_params(nvram, NVRAM_SIZE, arch_name, ram_size, boot_device,
b6b8bd18
FB
556 kernel_base, kernel_size,
557 kernel_cmdline,
558 initrd_base, initrd_size,
64201201 559 /* XXX: need an option to load a NVRAM image */
b6b8bd18
FB
560 0,
561 graphic_width, graphic_height, graphic_depth);
562 /* No PCI init: the BIOS will do it */
0aa6a4a2
FB
563
564 /* Special port to get debug messages from Open-Firmware */
565 register_ioport_write(0x0F00, 4, 1, &PPC_debug_write, NULL);
566}
567
94fc95cd
JM
568static void ppc_core99_init (int ram_size, int vga_ram_size, int boot_device,
569 DisplayState *ds, const char **fd_filename,
570 int snapshot,
571 const char *kernel_filename,
572 const char *kernel_cmdline,
573 const char *initrd_filename,
574 const char *cpu_model)
0aa6a4a2
FB
575{
576 ppc_chrp_init(ram_size, vga_ram_size, boot_device,
577 ds, fd_filename, snapshot,
578 kernel_filename, kernel_cmdline,
94fc95cd 579 initrd_filename, cpu_model, 0);
64201201 580}
5fafdf24 581
94fc95cd
JM
582static void ppc_heathrow_init (int ram_size, int vga_ram_size, int boot_device,
583 DisplayState *ds, const char **fd_filename,
584 int snapshot,
585 const char *kernel_filename,
586 const char *kernel_cmdline,
587 const char *initrd_filename,
588 const char *cpu_model)
0aa6a4a2
FB
589{
590 ppc_chrp_init(ram_size, vga_ram_size, boot_device,
591 ds, fd_filename, snapshot,
592 kernel_filename, kernel_cmdline,
94fc95cd 593 initrd_filename, cpu_model, 1);
0aa6a4a2
FB
594}
595
596QEMUMachine core99_machine = {
0289b2c1
FB
597 "mac99",
598 "Mac99 based PowerMAC",
0aa6a4a2
FB
599 ppc_core99_init,
600};
601
602QEMUMachine heathrow_machine = {
0289b2c1 603 "g3bw",
0aa6a4a2
FB
604 "Heathrow based PowerMAC",
605 ppc_heathrow_init,
606};