diff options
Diffstat (limited to 'hw')
-rw-r--r-- | hw/mips_jazz.c | 14 | ||||
-rw-r--r-- | hw/mips_malta.c | 14 | ||||
-rw-r--r-- | hw/mips_mipssim.c | 13 | ||||
-rw-r--r-- | hw/mips_r4k.c | 17 | ||||
-rw-r--r-- | hw/pc.c | 50 | ||||
-rw-r--r-- | hw/ppc405_boards.c | 29 | ||||
-rw-r--r-- | hw/ppc440_bamboo.c | 19 | ||||
-rw-r--r-- | hw/ppc_newworld.c | 25 | ||||
-rw-r--r-- | hw/ppc_oldworld.c | 25 | ||||
-rw-r--r-- | hw/ppc_prep.c | 17 | ||||
-rw-r--r-- | hw/ppce500_mpc8544ds.c | 19 | ||||
-rw-r--r-- | hw/sun4m.c | 57 | ||||
-rw-r--r-- | hw/sun4u.c | 26 |
13 files changed, 214 insertions, 111 deletions
diff --git a/hw/mips_jazz.c b/hw/mips_jazz.c index e496c2868b..e683421d86 100644 --- a/hw/mips_jazz.c +++ b/hw/mips_jazz.c @@ -118,7 +118,7 @@ void mips_jazz_init (ram_addr_t ram_size, const char *cpu_model, enum jazz_model_e jazz_model) { - char buf[1024]; + char *filename; int bios_size, n; CPUState *env; qemu_irq *rc4030, *i8259; @@ -161,11 +161,17 @@ void mips_jazz_init (ram_addr_t ram_size, /* load the BIOS image. */ if (bios_name == NULL) bios_name = BIOS_FILENAME; - snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name); - bios_size = load_image_targphys(buf, 0xfff00000LL, MAGNUM_BIOS_SIZE); + filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); + if (filename) { + bios_size = load_image_targphys(filename, 0xfff00000LL, + MAGNUM_BIOS_SIZE); + qemu_free(filename); + } else { + bios_size = -1; + } if (bios_size < 0 || bios_size > MAGNUM_BIOS_SIZE) { fprintf(stderr, "qemu: Could not load MIPS bios '%s'\n", - buf); + bios_name); exit(1); } diff --git a/hw/mips_malta.c b/hw/mips_malta.c index a300808639..970da4e60f 100644 --- a/hw/mips_malta.c +++ b/hw/mips_malta.c @@ -758,7 +758,7 @@ void mips_malta_init (ram_addr_t ram_size, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename, const char *cpu_model) { - char buf[1024]; + char *filename; ram_addr_t ram_offset; ram_addr_t bios_offset; target_long bios_size; @@ -846,12 +846,18 @@ void mips_malta_init (ram_addr_t ram_size, /* Load a BIOS image. */ if (bios_name == NULL) bios_name = BIOS_FILENAME; - snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name); - bios_size = load_image_targphys(buf, 0x1fc00000LL, BIOS_SIZE); + filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); + if (filename) { + bios_size = load_image_targphys(filename, 0x1fc00000LL, + BIOS_SIZE); + qemu_free(filename); + } else { + bios_size = -1; + } if ((bios_size < 0 || bios_size > BIOS_SIZE) && !kernel_filename) { fprintf(stderr, "qemu: Could not load MIPS bios '%s', and no -kernel argument was specified\n", - buf); + bios_name); exit(1); } } diff --git a/hw/mips_mipssim.c b/hw/mips_mipssim.c index 1117db27b9..448dc02e48 100644 --- a/hw/mips_mipssim.c +++ b/hw/mips_mipssim.c @@ -107,7 +107,7 @@ mips_mipssim_init (ram_addr_t ram_size, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename, const char *cpu_model) { - char buf[1024]; + char *filename; ram_addr_t ram_offset; ram_addr_t bios_offset; CPUState *env; @@ -140,13 +140,18 @@ mips_mipssim_init (ram_addr_t ram_size, /* Load a BIOS / boot exception handler image. */ if (bios_name == NULL) bios_name = BIOS_FILENAME; - snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name); - bios_size = load_image_targphys(buf, 0x1fc00000LL, BIOS_SIZE); + filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); + if (filename) { + bios_size = load_image_targphys(filename, 0x1fc00000LL, BIOS_SIZE); + qemu_free(filename); + } else { + bios_size = -1; + } if ((bios_size < 0 || bios_size > BIOS_SIZE) && !kernel_filename) { /* Bail out if we have neither a kernel image nor boot vector code. */ fprintf(stderr, "qemu: Could not load MIPS bios '%s', and no -kernel argument was specified\n", - buf); + filename); exit(1); } else { /* We have a boot vector start address. */ diff --git a/hw/mips_r4k.c b/hw/mips_r4k.c index ba8c7f61ae..71832d576a 100644 --- a/hw/mips_r4k.c +++ b/hw/mips_r4k.c @@ -147,7 +147,7 @@ void mips_r4k_init (ram_addr_t ram_size, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename, const char *cpu_model) { - char buf[1024]; + char *filename; ram_addr_t ram_offset; ram_addr_t bios_offset; int bios_size; @@ -196,14 +196,18 @@ void mips_r4k_init (ram_addr_t ram_size, run. */ if (bios_name == NULL) bios_name = BIOS_FILENAME; - snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name); - bios_size = get_image_size(buf); + filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); + if (filename) { + bios_size = get_image_size(filename); + } else { + bios_size = -1; + } if ((bios_size > 0) && (bios_size <= BIOS_SIZE)) { bios_offset = qemu_ram_alloc(BIOS_SIZE); cpu_register_physical_memory(0x1fc00000, BIOS_SIZE, bios_offset | IO_MEM_ROM); - load_image_targphys(buf, 0x1fc00000, BIOS_SIZE); + load_image_targphys(filename, 0x1fc00000, BIOS_SIZE); } else if ((index = drive_get_index(IF_PFLASH, 0, 0)) > -1) { uint32_t mips_rom = 0x00400000; bios_offset = qemu_ram_alloc(mips_rom); @@ -216,7 +220,10 @@ void mips_r4k_init (ram_addr_t ram_size, else { /* not fatal */ fprintf(stderr, "qemu: Warning, could not load MIPS bios '%s'\n", - buf); + bios_name); + } + if (filename) { + qemu_free(filename); } if (kernel_filename) { @@ -603,10 +603,10 @@ static void load_linux(target_phys_addr_t option_rom, uint32_t gpr[8]; uint16_t seg[6]; uint16_t real_seg; - int setup_size, kernel_size, initrd_size, cmdline_size; + int setup_size, kernel_size, initrd_size = 0, cmdline_size; uint32_t initrd_max; uint8_t header[1024]; - target_phys_addr_t real_addr, prot_addr, cmdline_addr, initrd_addr; + target_phys_addr_t real_addr, prot_addr, cmdline_addr, initrd_addr = 0; FILE *f, *fi; /* Align to 16 bytes as a paranoia measure */ @@ -805,14 +805,21 @@ static int load_option_rom(const char *oprom, target_phys_addr_t start, target_phys_addr_t end) { int size; - - size = get_image_size(oprom); - if (size > 0 && start + size > end) { - fprintf(stderr, "Not enough space to load option rom '%s'\n", - oprom); - exit(1); + char *filename; + + filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, oprom); + if (filename) { + size = get_image_size(filename); + if (size > 0 && start + size > end) { + fprintf(stderr, "Not enough space to load option rom '%s'\n", + oprom); + exit(1); + } + size = load_image_targphys(filename, start, end - start); + qemu_free(filename); + } else { + size = -1; } - size = load_image_targphys(oprom, start, end - start); if (size < 0) { fprintf(stderr, "Could not load option rom '%s'\n", oprom); exit(1); @@ -830,7 +837,7 @@ static void pc_init1(ram_addr_t ram_size, const char *initrd_filename, int pci_enabled, const char *cpu_model) { - char buf[1024]; + char *filename; int ret, linux_boot, i; ram_addr_t ram_addr, bios_offset, option_rom_offset; ram_addr_t below_4g_mem_size, above_4g_mem_size = 0; @@ -913,19 +920,26 @@ static void pc_init1(ram_addr_t ram_size, /* BIOS load */ if (bios_name == NULL) bios_name = BIOS_FILENAME; - snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name); - bios_size = get_image_size(buf); + filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); + if (filename) { + bios_size = get_image_size(filename); + } else { + bios_size = -1; + } if (bios_size <= 0 || (bios_size % 65536) != 0) { goto bios_error; } bios_offset = qemu_ram_alloc(bios_size); - ret = load_image(buf, qemu_get_ram_ptr(bios_offset)); + ret = load_image(filename, qemu_get_ram_ptr(bios_offset)); if (ret != bios_size) { bios_error: - fprintf(stderr, "qemu: could not load PC BIOS '%s'\n", buf); + fprintf(stderr, "qemu: could not load PC BIOS '%s'\n", bios_name); exit(1); } + if (filename) { + qemu_free(filename); + } /* map the last 128KB of the BIOS in ISA space */ isa_bios_size = bios_size; if (isa_bios_size > (128 * 1024)) @@ -941,14 +955,14 @@ static void pc_init1(ram_addr_t ram_size, cpu_register_physical_memory(0xc0000, 0x20000, option_rom_offset); if (using_vga) { + const char *vgabios_filename; /* VGA BIOS load */ if (cirrus_vga_enabled) { - snprintf(buf, sizeof(buf), "%s/%s", bios_dir, - VGABIOS_CIRRUS_FILENAME); + vgabios_filename = VGABIOS_CIRRUS_FILENAME; } else { - snprintf(buf, sizeof(buf), "%s/%s", bios_dir, VGABIOS_FILENAME); + vgabios_filename = VGABIOS_FILENAME; } - oprom_area_size = load_option_rom(buf, 0xc0000, 0xe0000); + oprom_area_size = load_option_rom(vgabios_filename, 0xc0000, 0xe0000); } /* Although video roms can grow larger than 0x8000, the area between * 0xc0000 - 0xc8000 is reserved for them. It means we won't be looking diff --git a/hw/ppc405_boards.c b/hw/ppc405_boards.c index a8f9a28105..0dec1317e5 100644 --- a/hw/ppc405_boards.c +++ b/hw/ppc405_boards.c @@ -175,7 +175,7 @@ static void ref405ep_init (ram_addr_t ram_size, const char *initrd_filename, const char *cpu_model) { - char buf[1024]; + char *filename; ppc4xx_bd_info_t bd; CPUPPCState *env; qemu_irq *pic; @@ -236,13 +236,19 @@ static void ref405ep_init (ram_addr_t ram_size, #ifdef DEBUG_BOARD_INIT printf("Load BIOS from file\n"); #endif + bios_offset = qemu_ram_alloc(BIOS_SIZE); if (bios_name == NULL) bios_name = BIOS_FILENAME; - snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name); - bios_offset = qemu_ram_alloc(BIOS_SIZE); - bios_size = load_image(buf, qemu_get_ram_ptr(bios_offset)); + filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); + if (filename) { + bios_size = load_image(filename, qemu_get_ram_ptr(bios_offset)); + qemu_free(filename); + } else { + bios_size = -1; + } if (bios_size < 0 || bios_size > BIOS_SIZE) { - fprintf(stderr, "qemu: could not load PowerPC bios '%s'\n", buf); + fprintf(stderr, "qemu: could not load PowerPC bios '%s'\n", + bios_name); exit(1); } bios_size = (bios_size + 0xfff) & ~0xfff; @@ -493,7 +499,7 @@ static void taihu_405ep_init(ram_addr_t ram_size, const char *initrd_filename, const char *cpu_model) { - char buf[1024]; + char *filename; CPUPPCState *env; qemu_irq *pic; ram_addr_t bios_offset; @@ -548,10 +554,15 @@ static void taihu_405ep_init(ram_addr_t ram_size, if (bios_name == NULL) bios_name = BIOS_FILENAME; bios_offset = qemu_ram_alloc(BIOS_SIZE); - snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name); - bios_size = load_image(buf, qemu_get_ram_ptr(bios_offset)); + filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); + if (filename) { + bios_size = load_image(filename, qemu_get_ram_ptr(bios_offset)); + } else { + bios_size = -1; + } if (bios_size < 0 || bios_size > BIOS_SIZE) { - fprintf(stderr, "qemu: could not load PowerPC bios '%s'\n", buf); + fprintf(stderr, "qemu: could not load PowerPC bios '%s'\n", + bios_name); exit(1); } bios_size = (bios_size + 0xfff) & ~0xfff; diff --git a/hw/ppc440_bamboo.c b/hw/ppc440_bamboo.c index cbe7236a4f..00aa2c72a2 100644 --- a/hw/ppc440_bamboo.c +++ b/hw/ppc440_bamboo.c @@ -34,20 +34,19 @@ static void *bamboo_load_device_tree(target_phys_addr_t addr, void *fdt = NULL; #ifdef HAVE_FDT uint32_t mem_reg_property[] = { 0, 0, ramsize }; - char *path; + char *filename; int fdt_size; - int pathlen; int ret; - pathlen = snprintf(NULL, 0, "%s/%s", bios_dir, BINARY_DEVICE_TREE_FILE) + 1; - path = qemu_malloc(pathlen); - - snprintf(path, pathlen, "%s/%s", bios_dir, BINARY_DEVICE_TREE_FILE); - - fdt = load_device_tree(path, &fdt_size); - free(path); - if (fdt == NULL) + filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, BINARY_DEVICE_TREE_FILE); + if (!filename) { goto out; + } + fdt = load_device_tree(filename, &fdt_size); + qemu_free(filename); + if (fdt == NULL) { + goto out; + } /* Manipulate device tree in memory. */ diff --git a/hw/ppc_newworld.c b/hw/ppc_newworld.c index 88ad99db3b..f0d167dbd9 100644 --- a/hw/ppc_newworld.c +++ b/hw/ppc_newworld.c @@ -93,7 +93,7 @@ static void ppc_core99_init (ram_addr_t 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; @@ -140,24 +140,35 @@ static void ppc_core99_init (ram_addr_t 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) { - hw_error("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 diff --git a/hw/ppc_oldworld.c b/hw/ppc_oldworld.c index aeac6aed30..b2c329b74f 100644 --- a/hw/ppc_oldworld.c +++ b/hw/ppc_oldworld.c @@ -122,7 +122,7 @@ static void ppc_heathrow_init (ram_addr_t ram_size, const char *cpu_model) { CPUState *env = NULL, *envs[MAX_CPUS]; - char buf[1024]; + char *filename; qemu_irq *pic, **heathrow_irqs; int linux_boot, i; ram_addr_t ram_offset, bios_offset, vga_bios_offset; @@ -173,24 +173,35 @@ static void ppc_heathrow_init (ram_addr_t 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) { - hw_error("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 diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c index 48321073fa..2d308f3cc6 100644 --- a/hw/ppc_prep.c +++ b/hw/ppc_prep.c @@ -539,7 +539,7 @@ static void ppc_prep_init (ram_addr_t ram_size, const char *cpu_model) { CPUState *env = NULL, *envs[MAX_CPUS]; - char buf[1024]; + char *filename; nvram_t nvram; m48t59_t *m48t59; int PPC_io_memory; @@ -585,18 +585,25 @@ static void ppc_prep_init (ram_addr_t ram_size, bios_offset = qemu_ram_alloc(BIOS_SIZE); if (bios_name == NULL) bios_name = BIOS_FILENAME; - snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name); - bios_size = get_image_size(buf); + filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); + if (filename) { + bios_size = get_image_size(filename); + } else { + bios_size = -1; + } if (bios_size > 0 && bios_size <= BIOS_SIZE) { target_phys_addr_t bios_addr; bios_size = (bios_size + 0xfff) & ~0xfff; bios_addr = (uint32_t)(-bios_size); cpu_register_physical_memory(bios_addr, bios_size, bios_offset | IO_MEM_ROM); - bios_size = load_image_targphys(buf, bios_addr, bios_size); + bios_size = load_image_targphys(filename, bios_addr, bios_size); } if (bios_size < 0 || bios_size > BIOS_SIZE) { - hw_error("qemu: could not load PPC PREP bios '%s'\n", buf); + hw_error("qemu: could not load PPC PREP bios '%s'\n", bios_name); + } + if (filename) { + qemu_free(filename); } if (env->nip < 0xFFF80000 && bios_size < 0x00100000) { hw_error("PowerPC 601 / 620 / 970 need a 1MB BIOS\n"); diff --git a/hw/ppce500_mpc8544ds.c b/hw/ppce500_mpc8544ds.c index 632fb05add..d9ed36ca59 100644 --- a/hw/ppce500_mpc8544ds.c +++ b/hw/ppce500_mpc8544ds.c @@ -79,20 +79,19 @@ static void *mpc8544_load_device_tree(target_phys_addr_t addr, void *fdt = NULL; #ifdef HAVE_FDT uint32_t mem_reg_property[] = {0, ramsize}; - char *path; + char *filename; int fdt_size; - int pathlen; int ret; - pathlen = snprintf(NULL, 0, "%s/%s", bios_dir, BINARY_DEVICE_TREE_FILE) + 1; - path = qemu_malloc(pathlen); - - snprintf(path, pathlen, "%s/%s", bios_dir, BINARY_DEVICE_TREE_FILE); - - fdt = load_device_tree(path, &fdt_size); - qemu_free(path); - if (fdt == NULL) + filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, BINARY_DEVICE_TREE_FILE); + if (!filename) { goto out; + } + fdt = load_device_tree(filename, &fdt_size); + qemu_free(filename); + if (fdt == NULL) { + goto out; + } /* Manipulate device tree in memory. */ ret = qemu_devtree_setprop(fdt, "/memory", "reg", mem_reg_property, diff --git a/hw/sun4m.c b/hw/sun4m.c index 4ba9e89ed8..ef9fa5e0b6 100644 --- a/hw/sun4m.c +++ b/hw/sun4m.c @@ -400,7 +400,7 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef, ram_addr_t RAM_size, ram_addr_t ram_offset, prom_offset, idreg_offset; unsigned long kernel_size; int ret; - char buf[1024]; + char *filename; BlockDriverState *fd[MAX_FD]; int drive_index; void *fw_cfg; @@ -451,13 +451,20 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef, ram_addr_t RAM_size, if (bios_name == NULL) bios_name = PROM_FILENAME; - snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name); - ret = load_elf(buf, hwdef->slavio_base - PROM_VADDR, NULL, NULL, NULL); - if (ret < 0 || ret > PROM_SIZE_MAX) - ret = load_image_targphys(buf, hwdef->slavio_base, PROM_SIZE_MAX); + filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); + if (filename) { + ret = load_elf(filename, hwdef->slavio_base - PROM_VADDR, + NULL, NULL, NULL); + if (ret < 0 || ret > PROM_SIZE_MAX) + ret = load_image_targphys(filename, hwdef->slavio_base, + PROM_SIZE_MAX); + qemu_free(filename); + } else { + ret = -1; + } if (ret < 0 || ret > PROM_SIZE_MAX) { fprintf(stderr, "qemu: could not load prom '%s'\n", - buf); + bios_name); exit(1); } @@ -1185,7 +1192,7 @@ static void sun4d_hw_init(const struct sun4d_hwdef *hwdef, ram_addr_t RAM_size, ram_addr_t ram_offset, prom_offset; unsigned long kernel_size; int ret; - char buf[1024]; + char *filename; void *fw_cfg; /* init CPUs */ @@ -1233,13 +1240,20 @@ static void sun4d_hw_init(const struct sun4d_hwdef *hwdef, ram_addr_t RAM_size, if (bios_name == NULL) bios_name = PROM_FILENAME; - snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name); - ret = load_elf(buf, hwdef->slavio_base - PROM_VADDR, NULL, NULL, NULL); - if (ret < 0 || ret > PROM_SIZE_MAX) - ret = load_image_targphys(buf, hwdef->slavio_base, PROM_SIZE_MAX); + filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); + if (filename) { + ret = load_elf(filename, hwdef->slavio_base - PROM_VADDR, + NULL, NULL, NULL); + if (ret < 0 || ret > PROM_SIZE_MAX) + ret = load_image_targphys(filename, hwdef->slavio_base, + PROM_SIZE_MAX); + qemu_free(filename); + } else { + ret = -1; + } if (ret < 0 || ret > PROM_SIZE_MAX) { fprintf(stderr, "qemu: could not load prom '%s'\n", - buf); + bios_name); exit(1); } @@ -1399,7 +1413,7 @@ static void sun4c_hw_init(const struct sun4c_hwdef *hwdef, ram_addr_t RAM_size, ram_addr_t ram_offset, prom_offset; unsigned long kernel_size; int ret; - char buf[1024]; + char *filename; BlockDriverState *fd[MAX_FD]; int drive_index; void *fw_cfg; @@ -1440,13 +1454,20 @@ static void sun4c_hw_init(const struct sun4c_hwdef *hwdef, ram_addr_t RAM_size, if (bios_name == NULL) bios_name = PROM_FILENAME; - snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name); - ret = load_elf(buf, hwdef->slavio_base - PROM_VADDR, NULL, NULL, NULL); - if (ret < 0 || ret > PROM_SIZE_MAX) - ret = load_image_targphys(buf, hwdef->slavio_base, PROM_SIZE_MAX); + filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); + if (filename) { + ret = load_elf(filename, hwdef->slavio_base - PROM_VADDR, + NULL, NULL, NULL); + if (ret < 0 || ret > PROM_SIZE_MAX) + ret = load_image_targphys(filename, hwdef->slavio_base, + PROM_SIZE_MAX); + qemu_free(filename); + } else { + ret = -1; + } if (ret < 0 || ret > PROM_SIZE_MAX) { fprintf(stderr, "qemu: could not load prom '%s'\n", - buf); + filename); exit(1); } diff --git a/hw/sun4u.c b/hw/sun4u.c index f5bb7322cf..7d020182fe 100644 --- a/hw/sun4u.c +++ b/hw/sun4u.c @@ -333,7 +333,7 @@ static void sun4uv_init(ram_addr_t RAM_size, const struct hwdef *hwdef) { CPUState *env; - char buf[1024]; + char *filename; m48t59_t *nvram; int ret, linux_boot; unsigned int i; @@ -392,17 +392,23 @@ static void sun4uv_init(ram_addr_t RAM_size, if (bios_name == NULL) bios_name = PROM_FILENAME; - snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name); - ret = load_elf(buf, hwdef->prom_addr - PROM_VADDR, NULL, NULL, NULL); - if (ret < 0) { - ret = load_image_targphys(buf, hwdef->prom_addr, - (PROM_SIZE_MAX + TARGET_PAGE_SIZE) & - TARGET_PAGE_MASK); + filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); + if (filename) { + ret = load_elf(filename, hwdef->prom_addr - PROM_VADDR, + NULL, NULL, NULL); if (ret < 0) { - fprintf(stderr, "qemu: could not load prom '%s'\n", - buf); - exit(1); + ret = load_image_targphys(filename, hwdef->prom_addr, + (PROM_SIZE_MAX + TARGET_PAGE_SIZE) & + TARGET_PAGE_MASK); } + qemu_free(filename); + } else { + ret = -1; + } + if (ret < 0) { + fprintf(stderr, "qemu: could not load prom '%s'\n", + bios_name); + exit(1); } kernel_size = 0; |