X-Git-Url: http://git.maemo.org/git/?p=qemu;a=blobdiff_plain;f=hw%2Fppc_newworld.c;fp=hw%2Fppc_newworld.c;h=f0d167dbd9d87fd707894bb0ab0ec848d746b68c;hp=f67b727e6c62fff10f3489ffe339263f300a0bf1;hb=a03c3bde4e288e790eccfb8cd45abd8ecbf467dc;hpb=e2ffa1bf065fa199f27d661d495573e9d6059bf1 diff --git a/hw/ppc_newworld.c b/hw/ppc_newworld.c index f67b727..f0d167d 100644 --- a/hw/ppc_newworld.c +++ b/hw/ppc_newworld.c @@ -44,10 +44,10 @@ //#define DEBUG_UNIN #ifdef DEBUG_UNIN -#define UNIN_DPRINTF(fmt, args...) \ -do { printf("UNIN: " fmt , ##args); } while (0) +#define UNIN_DPRINTF(fmt, ...) \ + do { printf("UNIN: " fmt , ## __VA_ARGS__); } while (0) #else -#define UNIN_DPRINTF(fmt, args...) +#define UNIN_DPRINTF(fmt, ...) #endif /* UniN device */ @@ -85,7 +85,7 @@ static int fw_cfg_boot_set(void *opaque, const char *boot_device) } /* PowerPC Mac99 hardware initialisation */ -static void ppc_core99_init (ram_addr_t ram_size, int vga_ram_size, +static void ppc_core99_init (ram_addr_t ram_size, const char *boot_device, const char *kernel_filename, const char *kernel_cmdline, @@ -93,7 +93,7 @@ static void ppc_core99_init (ram_addr_t ram_size, int vga_ram_size, const char *cpu_model) { CPUState *env = NULL, *envs[MAX_CPUS]; - char buf[1024]; + char *filename; qemu_irq *pic, **openpic_irqs; int unin_memory; int linux_boot, i; @@ -128,7 +128,7 @@ static void ppc_core99_init (ram_addr_t ram_size, int vga_ram_size, #if 0 env->osi_call = vga_osi_call; #endif - qemu_register_reset(&cpu_ppc_reset, env); + qemu_register_reset(&cpu_ppc_reset, 0, env); envs[i] = env; } @@ -140,24 +140,35 @@ static void ppc_core99_init (ram_addr_t ram_size, int vga_ram_size, bios_offset = qemu_ram_alloc(BIOS_SIZE); if (bios_name == NULL) bios_name = PROM_FILENAME; - snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name); + filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); cpu_register_physical_memory(PROM_ADDR, BIOS_SIZE, bios_offset | IO_MEM_ROM); /* Load OpenBIOS (ELF) */ - bios_size = load_elf(buf, 0, NULL, NULL, NULL); + if (filename) { + bios_size = load_elf(filename, 0, NULL, NULL, NULL); + qemu_free(filename); + } else { + bios_size = -1; + } if (bios_size < 0 || bios_size > BIOS_SIZE) { - cpu_abort(env, "qemu: could not load PowerPC bios '%s'\n", buf); + hw_error("qemu: could not load PowerPC bios '%s'\n", bios_name); exit(1); } /* allocate and load VGA BIOS */ vga_bios_offset = qemu_ram_alloc(VGA_BIOS_SIZE); vga_bios_ptr = qemu_get_ram_ptr(vga_bios_offset); - snprintf(buf, sizeof(buf), "%s/%s", bios_dir, VGABIOS_FILENAME); - vga_bios_size = load_image(buf, vga_bios_ptr + 8); + filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, VGABIOS_FILENAME); + if (filename) { + vga_bios_size = load_image(filename, vga_bios_ptr + 8); + qemu_free(filename); + } else { + vga_bios_size = -1; + } if (vga_bios_size < 0) { /* if no bios is present, we can still work */ - fprintf(stderr, "qemu: warning: could not load VGA bios '%s'\n", buf); + fprintf(stderr, "qemu: warning: could not load VGA bios '%s'\n", + VGABIOS_FILENAME); vga_bios_size = 0; } else { /* set a specific header (XXX: find real Apple format for NDRV @@ -190,8 +201,7 @@ static void ppc_core99_init (ram_addr_t ram_size, int vga_ram_size, kernel_base, ram_size - kernel_base); if (kernel_size < 0) { - cpu_abort(env, "qemu: could not load kernel '%s'\n", - kernel_filename); + hw_error("qemu: could not load kernel '%s'\n", kernel_filename); exit(1); } /* load initrd */ @@ -200,8 +210,8 @@ static void ppc_core99_init (ram_addr_t ram_size, int vga_ram_size, initrd_size = load_image_targphys(initrd_filename, initrd_base, ram_size - initrd_base); if (initrd_size < 0) { - cpu_abort(env, "qemu: could not load initial ram disk '%s'\n", - initrd_filename); + hw_error("qemu: could not load initial ram disk '%s'\n", + initrd_filename); exit(1); } } else { @@ -278,15 +288,14 @@ static void ppc_core99_init (ram_addr_t ram_size, int vga_ram_size, break; #endif /* defined(TARGET_PPC64) */ default: - cpu_abort(env, "Bus model not supported on mac99 machine\n"); + hw_error("Bus model not supported on mac99 machine\n"); exit(1); } } pic = openpic_init(NULL, &pic_mem_index, smp_cpus, openpic_irqs, NULL); pci_bus = pci_pmac_init(pic); /* init basic PC hardware */ - pci_vga_init(pci_bus, vga_ram_size, - vga_bios_offset, vga_bios_size); + pci_vga_init(pci_bus, vga_bios_offset, vga_bios_size); /* XXX: suppress that */ dummy_irq = i8259_init(NULL); @@ -353,9 +362,16 @@ static void ppc_core99_init (ram_addr_t ram_size, int vga_ram_size, qemu_register_boot_set(fw_cfg_boot_set, fw_cfg); } -QEMUMachine core99_machine = { +static QEMUMachine core99_machine = { .name = "mac99", .desc = "Mac99 based PowerMAC", .init = ppc_core99_init, .max_cpus = MAX_CPUS, }; + +static void core99_machine_init(void) +{ + qemu_register_machine(&core99_machine); +} + +machine_init(core99_machine_init);