Statistics
| Branch: | Revision:

root / hw / ppc_chrp.c @ 36081602

History | View | Annotate | Download (20 kB)

1
/*
2
 * QEMU PPC CHRP/PMAC hardware System Emulator
3
 *
4
 * Copyright (c) 2004-2007 Fabrice Bellard
5
 *
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

    
26
/* SMP is not enabled, for now */
27
#define MAX_CPUS 1
28

    
29
#define BIOS_FILENAME "ppc_rom.bin"
30
#define VGABIOS_FILENAME "video.x"
31
#define NVRAM_SIZE        0x2000
32

    
33
#define KERNEL_LOAD_ADDR 0x01000000
34
#define INITRD_LOAD_ADDR 0x01800000
35

    
36
/* MacIO devices (mapped inside the MacIO address space): CUDA, DBDMA,
37
   NVRAM */
38

    
39
static int dbdma_mem_index;
40
static int cuda_mem_index;
41
static int ide0_mem_index = -1;
42
static int ide1_mem_index = -1;
43
static int openpic_mem_index = -1;
44
static int heathrow_pic_mem_index = -1;
45
static int macio_nvram_mem_index = -1;
46

    
47
/* DBDMA: currently no op - should suffice right now */
48

    
49
static void dbdma_writeb (void *opaque,
50
                          target_phys_addr_t addr, uint32_t value)
51
{
52
    printf("%s: 0x" PADDRX " <= 0x%08x\n", __func__, addr, value);
53
}
54

    
55
static void dbdma_writew (void *opaque,
56
                          target_phys_addr_t addr, uint32_t value)
57
{
58
}
59

    
60
static void dbdma_writel (void *opaque,
61
                          target_phys_addr_t addr, uint32_t value)
62
{
63
}
64

    
65
static uint32_t dbdma_readb (void *opaque, target_phys_addr_t addr)
66
{
67
    printf("%s: 0x" PADDRX " => 0x00000000\n", __func__, addr);
68

    
69
    return 0;
70
}
71

    
72
static uint32_t dbdma_readw (void *opaque, target_phys_addr_t addr)
73
{
74
    return 0;
75
}
76

    
77
static uint32_t dbdma_readl (void *opaque, target_phys_addr_t addr)
78
{
79
    return 0;
80
}
81

    
82
static CPUWriteMemoryFunc *dbdma_write[] = {
83
    &dbdma_writeb,
84
    &dbdma_writew,
85
    &dbdma_writel,
86
};
87

    
88
static CPUReadMemoryFunc *dbdma_read[] = {
89
    &dbdma_readb,
90
    &dbdma_readw,
91
    &dbdma_readl,
92
};
93

    
94
/* macio style NVRAM device */
95
typedef struct MacIONVRAMState {
96
    uint8_t data[0x2000];
97
} MacIONVRAMState;
98

    
99
static void macio_nvram_writeb (void *opaque,
100
                                target_phys_addr_t addr, uint32_t value)
101
{
102
    MacIONVRAMState *s = opaque;
103
    addr = (addr >> 4) & 0x1fff;
104
    s->data[addr] = value;
105
    //    printf("macio_nvram_writeb %04x = %02x\n", addr, value);
106
}
107

    
108
static uint32_t macio_nvram_readb (void *opaque, target_phys_addr_t addr)
109
{
110
    MacIONVRAMState *s = opaque;
111
    uint32_t value;
112

    
113
    addr = (addr >> 4) & 0x1fff;
114
    value = s->data[addr];
115
    //    printf("macio_nvram_readb %04x = %02x\n", addr, value);
116

    
117
    return value;
118
}
119

    
120
static CPUWriteMemoryFunc *macio_nvram_write[] = {
121
    &macio_nvram_writeb,
122
    &macio_nvram_writeb,
123
    &macio_nvram_writeb,
124
};
125

    
126
static CPUReadMemoryFunc *macio_nvram_read[] = {
127
    &macio_nvram_readb,
128
    &macio_nvram_readb,
129
    &macio_nvram_readb,
130
};
131

    
132
static MacIONVRAMState *macio_nvram_init (void)
133
{
134
    MacIONVRAMState *s;
135
    s = qemu_mallocz(sizeof(MacIONVRAMState));
136
    if (!s)
137
        return NULL;
138
    macio_nvram_mem_index = cpu_register_io_memory(0, macio_nvram_read,
139
                                                   macio_nvram_write, s);
140

    
141
    return s;
142
}
143

    
144
static void macio_map (PCIDevice *pci_dev, int region_num,
145
                       uint32_t addr, uint32_t size, int type)
146
{
147
    if (heathrow_pic_mem_index >= 0) {
148
        cpu_register_physical_memory(addr + 0x00000, 0x1000,
149
                                     heathrow_pic_mem_index);
150
    }
151
    cpu_register_physical_memory(addr + 0x08000, 0x1000, dbdma_mem_index);
152
    cpu_register_physical_memory(addr + 0x16000, 0x2000, cuda_mem_index);
153
    if (ide0_mem_index >= 0)
154
        cpu_register_physical_memory(addr + 0x1f000, 0x1000, ide0_mem_index);
155
    if (ide1_mem_index >= 0)
156
        cpu_register_physical_memory(addr + 0x20000, 0x1000, ide1_mem_index);
157
    if (openpic_mem_index >= 0) {
158
        cpu_register_physical_memory(addr + 0x40000, 0x40000,
159
                                     openpic_mem_index);
160
    }
161
    if (macio_nvram_mem_index >= 0)
162
        cpu_register_physical_memory(addr + 0x60000, 0x20000,
163
                                     macio_nvram_mem_index);
164
}
165

    
166
static void macio_init (PCIBus *bus, int device_id)
167
{
168
    PCIDevice *d;
169

    
170
    d = pci_register_device(bus, "macio", sizeof(PCIDevice),
171
                            -1, NULL, NULL);
172
    /* Note: this code is strongly inspirated from the corresponding code
173
       in PearPC */
174
    d->config[0x00] = 0x6b; // vendor_id
175
    d->config[0x01] = 0x10;
176
    d->config[0x02] = device_id;
177
    d->config[0x03] = device_id >> 8;
178

    
179
    d->config[0x0a] = 0x00; // class_sub = pci2pci
180
    d->config[0x0b] = 0xff; // class_base = bridge
181
    d->config[0x0e] = 0x00; // header_type
182

    
183
    d->config[0x3d] = 0x01; // interrupt on pin 1
184

    
185
    dbdma_mem_index = cpu_register_io_memory(0, dbdma_read, dbdma_write, NULL);
186

    
187
    pci_register_io_region(d, 0, 0x80000,
188
                           PCI_ADDRESS_SPACE_MEM, macio_map);
189
}
190

    
191
/* UniN device */
192
static void unin_writel (void *opaque, target_phys_addr_t addr, uint32_t value)
193
{
194
}
195

    
196
static uint32_t unin_readl (void *opaque, target_phys_addr_t addr)
197
{
198
    return 0;
199
}
200

    
201
static CPUWriteMemoryFunc *unin_write[] = {
202
    &unin_writel,
203
    &unin_writel,
204
    &unin_writel,
205
};
206

    
207
static CPUReadMemoryFunc *unin_read[] = {
208
    &unin_readl,
209
    &unin_readl,
210
    &unin_readl,
211
};
212

    
213
/* temporary frame buffer OSI calls for the video.x driver. The right
214
   solution is to modify the driver to use VGA PCI I/Os */
215
/* XXX: to be removed. This is no way related to emulation */
216
static int vga_osi_call (CPUState *env)
217
{
218
    static int vga_vbl_enabled;
219
    int linesize;
220

    
221
    //    printf("osi_call R5=%d\n", env->gpr[5]);
222

    
223
    /* same handler as PearPC, coming from the original MOL video
224
       driver. */
225
    switch(env->gpr[5]) {
226
    case 4:
227
        break;
228
    case 28: /* set_vmode */
229
        if (env->gpr[6] != 1 || env->gpr[7] != 0)
230
            env->gpr[3] = 1;
231
        else
232
            env->gpr[3] = 0;
233
        break;
234
    case 29: /* get_vmode_info */
235
        if (env->gpr[6] != 0) {
236
            if (env->gpr[6] != 1 || env->gpr[7] != 0) {
237
                env->gpr[3] = 1;
238
                break;
239
            }
240
        }
241
        env->gpr[3] = 0;
242
        env->gpr[4] = (1 << 16) | 1; /* num_vmodes, cur_vmode */
243
        env->gpr[5] = (1 << 16) | 0; /* num_depths, cur_depth_mode */
244
        env->gpr[6] = (graphic_width << 16) | graphic_height; /* w, h */
245
        env->gpr[7] = 85 << 16; /* refresh rate */
246
        env->gpr[8] = (graphic_depth + 7) & ~7; /* depth (round to byte) */
247
        linesize = ((graphic_depth + 7) >> 3) * graphic_width;
248
        linesize = (linesize + 3) & ~3;
249
        env->gpr[9] = (linesize << 16) | 0; /* row_bytes, offset */
250
        break;
251
    case 31: /* set_video power */
252
        env->gpr[3] = 0;
253
        break;
254
    case 39: /* video_ctrl */
255
        if (env->gpr[6] == 0 || env->gpr[6] == 1)
256
            vga_vbl_enabled = env->gpr[6];
257
        env->gpr[3] = 0;
258
        break;
259
    case 47:
260
        break;
261
    case 59: /* set_color */
262
        /* R6 = index, R7 = RGB */
263
        env->gpr[3] = 0;
264
        break;
265
    case 64: /* get color */
266
        /* R6 = index */
267
        env->gpr[3] = 0;
268
        break;
269
    case 116: /* set hwcursor */
270
        /* R6 = x, R7 = y, R8 = visible, R9 = data */
271
        break;
272
    default:
273
        fprintf(stderr, "unsupported OSI call R5=" REGX "\n", env->gpr[5]);
274
        break;
275
    }
276

    
277
    return 1; /* osi_call handled */
278
}
279

    
280
static uint8_t nvram_chksum (const uint8_t *buf, int n)
281
{
282
    int sum, i;
283
    sum = 0;
284
    for(i = 0; i < n; i++)
285
        sum += buf[i];
286
    return (sum & 0xff) + (sum >> 8);
287
}
288

    
289
/* set a free Mac OS NVRAM partition */
290
void pmac_format_nvram_partition (uint8_t *buf, int len)
291
{
292
    char partition_name[12] = "wwwwwwwwwwww";
293

    
294
    buf[0] = 0x7f; /* free partition magic */
295
    buf[1] = 0; /* checksum */
296
    buf[2] = len >> 8;
297
    buf[3] = len;
298
    memcpy(buf + 4, partition_name, 12);
299
    buf[1] = nvram_chksum(buf, 16);
300
}
301

    
302
/* PowerPC CHRP hardware initialisation */
303
static void ppc_chrp_init (int ram_size, int vga_ram_size, int boot_device,
304
                           DisplayState *ds, const char **fd_filename,
305
                           int snapshot,
306
                           const char *kernel_filename,
307
                           const char *kernel_cmdline,
308
                           const char *initrd_filename,
309
                           const char *cpu_model,
310
                           int is_heathrow)
311
{
312
    CPUState *env, *envs[MAX_CPUS];
313
    char buf[1024];
314
    qemu_irq *pic, **openpic_irqs;
315
    m48t59_t *nvram;
316
    int unin_memory;
317
    int linux_boot, i;
318
    unsigned long bios_offset, vga_bios_offset;
319
    uint32_t kernel_base, kernel_size, initrd_base, initrd_size;
320
    ppc_def_t *def;
321
    PCIBus *pci_bus;
322
    const char *arch_name;
323
    int vga_bios_size, bios_size;
324
    qemu_irq *dummy_irq;
325

    
326
    linux_boot = (kernel_filename != NULL);
327

    
328
    /* init CPUs */
329
    env = cpu_init();
330
    qemu_register_reset(&cpu_ppc_reset, env);
331
    register_savevm("cpu", 0, 3, cpu_save, cpu_load, env);
332

    
333
    /* Default CPU is a generic 74x/75x */
334
    if (cpu_model == NULL)
335
        cpu_model = "750";
336
    /* XXX: CPU model (or PVR) should be provided on command line */
337
    //    ppc_find_by_name("750gx", &def); // Linux boot OK
338
    //    ppc_find_by_name("750fx", &def); // Linux boot OK
339
    /* Linux does not boot on 750cxe (and probably other 750cx based)
340
     * because it assumes it has 8 IBAT & DBAT pairs as it only have 4.
341
     */
342
    ppc_find_by_name(cpu_model, &def);
343
    if (def == NULL) {
344
        cpu_abort(env, "Unable to find PowerPC CPU definition\n");
345
    }
346
    for (i = 0; i < smp_cpus; i++) {
347
        cpu_ppc_register(env, def);
348
        /* Set time-base frequency to 100 Mhz */
349
        cpu_ppc_tb_init(env, 100UL * 1000UL * 1000UL);
350
        env->osi_call = vga_osi_call;
351
        envs[i] = env;
352
    }
353

    
354
    /* allocate RAM */
355
    cpu_register_physical_memory(0, ram_size, IO_MEM_RAM);
356

    
357
    /* allocate and load BIOS */
358
    bios_offset = ram_size + vga_ram_size;
359
    snprintf(buf, sizeof(buf), "%s/%s", bios_dir, BIOS_FILENAME);
360
    bios_size = load_image(buf, phys_ram_base + bios_offset);
361
    if (bios_size < 0 || bios_size > BIOS_SIZE) {
362
        cpu_abort(env, "qemu: could not load PowerPC bios '%s'\n", buf);
363
        exit(1);
364
    }
365
    bios_size = (bios_size + 0xfff) & ~0xfff;
366
    cpu_register_physical_memory((uint32_t)(-bios_size),
367
                                 bios_size, bios_offset | IO_MEM_ROM);
368

    
369
    /* allocate and load VGA BIOS */
370
    vga_bios_offset = bios_offset + bios_size;
371
    snprintf(buf, sizeof(buf), "%s/%s", bios_dir, VGABIOS_FILENAME);
372
    vga_bios_size = load_image(buf, phys_ram_base + vga_bios_offset + 8);
373
    if (vga_bios_size < 0) {
374
        /* if no bios is present, we can still work */
375
        fprintf(stderr, "qemu: warning: could not load VGA bios '%s'\n", buf);
376
        vga_bios_size = 0;
377
    } else {
378
        /* set a specific header (XXX: find real Apple format for NDRV
379
           drivers) */
380
        phys_ram_base[vga_bios_offset] = 'N';
381
        phys_ram_base[vga_bios_offset + 1] = 'D';
382
        phys_ram_base[vga_bios_offset + 2] = 'R';
383
        phys_ram_base[vga_bios_offset + 3] = 'V';
384
        cpu_to_be32w((uint32_t *)(phys_ram_base + vga_bios_offset + 4),
385
                     vga_bios_size);
386
        vga_bios_size += 8;
387
    }
388
    vga_bios_size = (vga_bios_size + 0xfff) & ~0xfff;
389

    
390
    if (linux_boot) {
391
        kernel_base = KERNEL_LOAD_ADDR;
392
        /* now we can load the kernel */
393
        kernel_size = load_image(kernel_filename, phys_ram_base + kernel_base);
394
        if (kernel_size < 0) {
395
            cpu_abort(env, "qemu: could not load kernel '%s'\n",
396
                      kernel_filename);
397
            exit(1);
398
        }
399
        /* load initrd */
400
        if (initrd_filename) {
401
            initrd_base = INITRD_LOAD_ADDR;
402
            initrd_size = load_image(initrd_filename,
403
                                     phys_ram_base + initrd_base);
404
            if (initrd_size < 0) {
405
                cpu_abort(env, "qemu: could not load initial ram disk '%s'\n",
406
                          initrd_filename);
407
                exit(1);
408
            }
409
        } else {
410
            initrd_base = 0;
411
            initrd_size = 0;
412
        }
413
        boot_device = 'm';
414
    } else {
415
        kernel_base = 0;
416
        kernel_size = 0;
417
        initrd_base = 0;
418
        initrd_size = 0;
419
    }
420

    
421
    if (is_heathrow) {
422
        isa_mem_base = 0x80000000;
423

    
424
        /* Register 2 MB of ISA IO space */
425
        isa_mmio_init(0xfe000000, 0x00200000);
426

    
427
        /* init basic PC hardware */
428
        if (PPC_INPUT(env) != PPC_FLAGS_INPUT_6xx) {
429
            cpu_abort(env, "Only 6xx bus is supported on heathrow machine\n");
430
            exit(1);
431
        }
432
        pic = heathrow_pic_init(&heathrow_pic_mem_index);
433
        pci_bus = pci_grackle_init(0xfec00000, pic);
434
        pci_vga_init(pci_bus, ds, phys_ram_base + ram_size,
435
                     ram_size, vga_ram_size,
436
                     vga_bios_offset, vga_bios_size);
437

    
438
        /* XXX: suppress that */
439
        dummy_irq = i8259_init(NULL);
440

    
441
        /* XXX: use Mac Serial port */
442
        serial_init(0x3f8, dummy_irq[4], serial_hds[0]);
443

    
444
        for(i = 0; i < nb_nics; i++) {
445
            if (!nd_table[i].model)
446
                nd_table[i].model = "ne2k_pci";
447
            pci_nic_init(pci_bus, &nd_table[i], -1);
448
        }
449

    
450
        pci_cmd646_ide_init(pci_bus, &bs_table[0], 0);
451

    
452
        /* cuda also initialize ADB */
453
        cuda_mem_index = cuda_init(pic[0x12]);
454

    
455
        adb_kbd_init(&adb_bus);
456
        adb_mouse_init(&adb_bus);
457

    
458
        {
459
            MacIONVRAMState *nvr;
460
            nvr = macio_nvram_init();
461
            pmac_format_nvram_partition(nvr->data, 0x2000);
462
        }
463

    
464
        macio_init(pci_bus, 0x0017);
465

    
466
        nvram = m48t59_init(dummy_irq[8], 0xFFF04000, 0x0074, NVRAM_SIZE, 59);
467

    
468
        arch_name = "HEATHROW";
469
    } else {
470
        isa_mem_base = 0x80000000;
471

    
472
        /* Register 8 MB of ISA IO space */
473
        isa_mmio_init(0xf2000000, 0x00800000);
474

    
475
        /* UniN init */
476
        unin_memory = cpu_register_io_memory(0, unin_read, unin_write, NULL);
477
        cpu_register_physical_memory(0xf8000000, 0x00001000, unin_memory);
478

    
479
        openpic_irqs = qemu_mallocz(smp_cpus * sizeof(qemu_irq *));
480
        openpic_irqs[0] =
481
            qemu_mallocz(smp_cpus * sizeof(qemu_irq) * OPENPIC_OUTPUT_NB);
482
        for (i = 0; i < smp_cpus; i++) {
483
            /* Mac99 IRQ connection between OpenPIC outputs pins
484
             * and PowerPC input pins
485
             */
486
            switch (PPC_INPUT(env)) {
487
            case PPC_FLAGS_INPUT_6xx:
488
                openpic_irqs[i] = openpic_irqs[0] + (i * OPENPIC_OUTPUT_NB);
489
                openpic_irqs[i][OPENPIC_OUTPUT_INT] =
490
                    ((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_INT];
491
                openpic_irqs[i][OPENPIC_OUTPUT_CINT] =
492
                    ((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_INT];
493
                openpic_irqs[i][OPENPIC_OUTPUT_MCK] =
494
                    ((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_MCP];
495
                /* Not connected ? */
496
                openpic_irqs[i][OPENPIC_OUTPUT_DEBUG] = NULL;
497
                /* Check this */
498
                openpic_irqs[i][OPENPIC_OUTPUT_RESET] =
499
                    ((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_HRESET];
500
                break;
501
            case PPC_FLAGS_INPUT_970:
502
                openpic_irqs[i] = openpic_irqs[0] + (i * OPENPIC_OUTPUT_NB);
503
                openpic_irqs[i][OPENPIC_OUTPUT_INT] =
504
                    ((qemu_irq *)env->irq_inputs)[PPC970_INPUT_INT];
505
                openpic_irqs[i][OPENPIC_OUTPUT_CINT] =
506
                    ((qemu_irq *)env->irq_inputs)[PPC970_INPUT_INT];
507
                openpic_irqs[i][OPENPIC_OUTPUT_MCK] =
508
                    ((qemu_irq *)env->irq_inputs)[PPC970_INPUT_MCP];
509
                /* Not connected ? */
510
                openpic_irqs[i][OPENPIC_OUTPUT_DEBUG] = NULL;
511
                /* Check this */
512
                openpic_irqs[i][OPENPIC_OUTPUT_RESET] =
513
                    ((qemu_irq *)env->irq_inputs)[PPC970_INPUT_HRESET];
514
                break;
515
            default:
516
                cpu_abort(env, "Bus model not supported on mac99 machine\n");
517
                exit(1);
518
            }
519
        }
520
        pic = openpic_init(NULL, &openpic_mem_index, smp_cpus,
521
                           openpic_irqs, NULL);
522
        pci_bus = pci_pmac_init(pic);
523
        /* init basic PC hardware */
524
        pci_vga_init(pci_bus, ds, phys_ram_base + ram_size,
525
                     ram_size, vga_ram_size,
526
                     vga_bios_offset, vga_bios_size);
527

    
528
        /* XXX: suppress that */
529
        dummy_irq = i8259_init(NULL);
530

    
531
        /* XXX: use Mac Serial port */
532
        serial_init(0x3f8, dummy_irq[4], serial_hds[0]);
533
        for(i = 0; i < nb_nics; i++) {
534
            if (!nd_table[i].model)
535
                nd_table[i].model = "ne2k_pci";
536
            pci_nic_init(pci_bus, &nd_table[i], -1);
537
        }
538
#if 1
539
        ide0_mem_index = pmac_ide_init(&bs_table[0], pic[0x13]);
540
        ide1_mem_index = pmac_ide_init(&bs_table[2], pic[0x14]);
541
#else
542
        pci_cmd646_ide_init(pci_bus, &bs_table[0], 0);
543
#endif
544
        /* cuda also initialize ADB */
545
        cuda_mem_index = cuda_init(pic[0x19]);
546

    
547
        adb_kbd_init(&adb_bus);
548
        adb_mouse_init(&adb_bus);
549

    
550
        macio_init(pci_bus, 0x0022);
551

    
552
        nvram = m48t59_init(dummy_irq[8], 0xFFF04000, 0x0074, NVRAM_SIZE, 59);
553

    
554
        arch_name = "MAC99";
555
    }
556

    
557
    if (usb_enabled) {
558
        usb_ohci_init_pci(pci_bus, 3, -1);
559
    }
560

    
561
    if (graphic_depth != 15 && graphic_depth != 32 && graphic_depth != 8)
562
        graphic_depth = 15;
563

    
564
    PPC_NVRAM_set_params(nvram, NVRAM_SIZE, arch_name, ram_size, boot_device,
565
                         kernel_base, kernel_size,
566
                         kernel_cmdline,
567
                         initrd_base, initrd_size,
568
                         /* XXX: need an option to load a NVRAM image */
569
                         0,
570
                         graphic_width, graphic_height, graphic_depth);
571
    /* No PCI init: the BIOS will do it */
572

    
573
    /* Special port to get debug messages from Open-Firmware */
574
    register_ioport_write(0x0F00, 4, 1, &PPC_debug_write, NULL);
575
}
576

    
577
static void ppc_core99_init (int ram_size, int vga_ram_size, int boot_device,
578
                             DisplayState *ds, const char **fd_filename,
579
                             int snapshot,
580
                             const char *kernel_filename,
581
                             const char *kernel_cmdline,
582
                             const char *initrd_filename,
583
                             const char *cpu_model)
584
{
585
    ppc_chrp_init(ram_size, vga_ram_size, boot_device,
586
                  ds, fd_filename, snapshot,
587
                  kernel_filename, kernel_cmdline,
588
                  initrd_filename, cpu_model, 0);
589
}
590

    
591
static void ppc_heathrow_init (int ram_size, int vga_ram_size, int boot_device,
592
                               DisplayState *ds, const char **fd_filename,
593
                               int snapshot,
594
                               const char *kernel_filename,
595
                               const char *kernel_cmdline,
596
                               const char *initrd_filename,
597
                               const char *cpu_model)
598
{
599
    ppc_chrp_init(ram_size, vga_ram_size, boot_device,
600
                  ds, fd_filename, snapshot,
601
                  kernel_filename, kernel_cmdline,
602
                  initrd_filename, cpu_model, 1);
603
}
604

    
605
QEMUMachine core99_machine = {
606
    "mac99",
607
    "Mac99 based PowerMAC",
608
    ppc_core99_init,
609
};
610

    
611
QEMUMachine heathrow_machine = {
612
    "g3bw",
613
    "Heathrow based PowerMAC",
614
    ppc_heathrow_init,
615
};