Signed-off-by: Olivia Yin <hong-hua....@freescale.com> --- hw/arm_boot.c | 20 ++++++++++++++++---- hw/elf_ops.h | 9 ++++++++- hw/exynos4210.c | 10 ++++++++-- hw/highbank.c | 9 ++++++++- hw/lm32_hwsetup.h | 9 ++++++++- hw/loader.c | 23 +++++++++++++++++++---- hw/mips_fulong2e.c | 10 ++++++++-- hw/mips_malta.c | 10 ++++++++-- hw/mips_r4k.c | 10 ++++++++-- hw/ppc/e500.c | 21 +++++++++++---------- hw/ppc440_bamboo.c | 9 ++++++++- hw/r2d.c | 10 ++++++++-- 12 files changed, 118 insertions(+), 32 deletions(-)
diff --git a/hw/arm_boot.c b/hw/arm_boot.c index 09bf6c5..bfa5e5b 100644 --- a/hw/arm_boot.c +++ b/hw/arm_boot.c @@ -68,8 +68,14 @@ static void default_write_secondary(ARMCPU *cpu, for (n = 0; n < ARRAY_SIZE(smpboot); n++) { smpboot[n] = tswap32(smpboot[n]); } - rom_add_blob_fixed("smpboot", smpboot, sizeof(smpboot), - info->smp_loader_start); + ImageBlob *blob; + blob = g_malloc0(sizeof(*blob)); + blob->name = g_strdup("smpboot"); + blob->addr = info->smp_loader_start; + blob->size = sizeof(smpboot); + blob->data = g_malloc0(blob->size); + memcpy(blob->data, smpboot, blob->size); + qemu_register_reset(image_blob_reset, blob); } static void default_reset_secondary(ARMCPU *cpu, @@ -439,8 +445,14 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info) for (n = 0; n < sizeof(bootloader) / 4; n++) { bootloader[n] = tswap32(bootloader[n]); } - rom_add_blob_fixed("bootloader", bootloader, sizeof(bootloader), - info->loader_start); + ImageBlob *blob; + blob = g_malloc0(sizeof(*blob)); + blob->name = g_strdup("bootloader"); + blob->addr = dst_addr; + blob->size = sizeof(bootloader); + blob->data = g_malloc0(blob->size); + memcpy(blob->data, bootloader, blob->size); + qemu_register_reset(image_blob_reset, blob); if (info->nb_cpus > 1) { info->write_secondary_boot(cpu, info); } diff --git a/hw/elf_ops.h b/hw/elf_ops.h index 531a425..e15ee4f 100644 --- a/hw/elf_ops.h +++ b/hw/elf_ops.h @@ -281,7 +281,14 @@ static int glue(load_elf, SZ)(const char *name, int fd, } snprintf(label, sizeof(label), "phdr #%d: %s", i, name); - rom_add_blob_fixed(label, data, mem_size, addr); + ImageBlob *blob; + blob = g_malloc0(sizeof(*blob)); + blob->name = g_strdup(label); + blob->addr = addr; + blob->size = mem_size; + blob->data = g_malloc0(blob->size); + memcpy(blob->data, data, blob->size); + qemu_register_reset(image_blob_reset, blob); total_size += mem_size; if (addr < low) diff --git a/hw/exynos4210.c b/hw/exynos4210.c index 00d4db8..9191fdb 100644 --- a/hw/exynos4210.c +++ b/hw/exynos4210.c @@ -100,8 +100,14 @@ void exynos4210_write_secondary(ARMCPU *cpu, for (n = 0; n < ARRAY_SIZE(smpboot); n++) { smpboot[n] = tswap32(smpboot[n]); } - rom_add_blob_fixed("smpboot", smpboot, sizeof(smpboot), - info->smp_loader_start); + ImageBlob *blob; + blob = g_malloc0(sizeof(*blob)); + blob->name = g_strdup("smpboot"); + blob->addr = info->smp_loader_start; + blob->size = sizeof(smpboot); + blob->data = g_malloc0(blob->size); + memcpy(blob->data, smpboot, blob->size); + qemu_register_reset(image_blob_reset, blob); } Exynos4210State *exynos4210_init(MemoryRegion *system_mem, diff --git a/hw/highbank.c b/hw/highbank.c index afbb005..a8f6087 100644 --- a/hw/highbank.c +++ b/hw/highbank.c @@ -57,7 +57,14 @@ static void hb_write_secondary(ARMCPU *cpu, const struct arm_boot_info *info) for (n = 0; n < ARRAY_SIZE(smpboot); n++) { smpboot[n] = tswap32(smpboot[n]); } - rom_add_blob_fixed("smpboot", smpboot, sizeof(smpboot), SMP_BOOT_ADDR); + ImageBlob *blob; + blob = g_malloc0(sizeof(*blob)); + blob->name = g_strdup("smpboot"); + blob->addr = SMP_BOOT_ADDR; + blob->size = sizeof(smpboot); + blob->data = g_malloc0(blob->size); + memcpy(blob->data, smpboot, blob->size); + qemu_register_reset(image_blob_reset, blob); } static void hb_reset_secondary(ARMCPU *cpu, const struct arm_boot_info *info) diff --git a/hw/lm32_hwsetup.h b/hw/lm32_hwsetup.h index 853e9ab..bb6d2fe 100644 --- a/hw/lm32_hwsetup.h +++ b/hw/lm32_hwsetup.h @@ -73,7 +73,14 @@ static inline void hwsetup_free(HWSetup *hw) static inline void hwsetup_create_rom(HWSetup *hw, hwaddr base) { - rom_add_blob("hwsetup", hw->data, TARGET_PAGE_SIZE, base); + ImageBlob *blob; + blob = g_malloc0(sizeof(*blob)); + blob->name = g_strdup("hwsetup"); + blob->addr = base; + blob->size = TARGET_PAGE_SIZE; + blob->data = g_malloc0(blob->size); + memcpy(blob->data, hw->data, blob->size); + qemu_register_reset(image_blob_reset, blob); } static inline void hwsetup_add_u8(HWSetup *hw, uint8_t u) diff --git a/hw/loader.c b/hw/loader.c index 9e2c3c8..2e7072b 100644 --- a/hw/loader.c +++ b/hw/loader.c @@ -134,8 +134,16 @@ ssize_t read_targphys(const char *name, buf = g_malloc(nbytes); did = read(fd, buf, nbytes); - if (did > 0) - rom_add_blob_fixed("read", buf, did, dst_addr); + if (did > 0) { + ImageBlob *blob; + blob = g_malloc0(sizeof(*blob)); + blob->name = g_strdup("read"); + blob->addr = dst_addr; + blob->size = nbytes; + blob->data = g_malloc0(blob->size); + memcpy(blob->data, buf, blob->size); + qemu_register_reset(image_blob_reset, blob); + } g_free(buf); return did; } @@ -169,13 +177,20 @@ void pstrcpy_targphys(const char *name, hwaddr dest, int buf_size, if (buf_size <= 0) return; nulp = memchr(source, 0, buf_size); + ImageBlob *blob; + blob = g_malloc0(sizeof(*blob)); + blob->name = g_strdup(name); + blob->addr = dest; if (nulp) { - rom_add_blob_fixed(name, source, (nulp - source) + 1, dest); + blob->size = (nulp - source) + 1; } else { - rom_add_blob_fixed(name, source, buf_size, dest); + blob->size = buf_size; ptr = rom_ptr(dest + buf_size - 1); *ptr = 0; } + blob->data = g_malloc0(blob->size); + memcpy(blob->data, source, blob->size); + qemu_register_reset(image_blob_reset, blob); } /* A.OUT loader */ diff --git a/hw/mips_fulong2e.c b/hw/mips_fulong2e.c index 5fcf900..edbee1f 100644 --- a/hw/mips_fulong2e.c +++ b/hw/mips_fulong2e.c @@ -163,8 +163,14 @@ static int64_t load_kernel (CPUMIPSState *env) prom_set(prom_buf, index++, "modetty0=38400n8r"); prom_set(prom_buf, index++, NULL); - rom_add_blob_fixed("prom", prom_buf, prom_size, - cpu_mips_kseg0_to_phys(NULL, ENVP_ADDR)); + ImageBlob *blob; + blob = g_malloc0(sizeof(*blob)); + blob->name = g_strdup("prom"); + blob->addr = cpu_mips_kseg0_to_phys(NULL, ENVP_ADDR); + blob->size = prom_size; + blob->data = g_malloc0(blob->size); + memcpy(blob->data, prom_buf, blob->size); + qemu_register_reset(image_blob_reset, blob); return kernel_entry; } diff --git a/hw/mips_malta.c b/hw/mips_malta.c index 0571d58..a3b337e 100644 --- a/hw/mips_malta.c +++ b/hw/mips_malta.c @@ -737,8 +737,14 @@ static int64_t load_kernel (void) prom_set(prom_buf, prom_index++, "38400n8r"); prom_set(prom_buf, prom_index++, NULL); - rom_add_blob_fixed("prom", prom_buf, prom_size, - cpu_mips_kseg0_to_phys(NULL, ENVP_ADDR)); + ImageBlob *blob; + blob = g_malloc0(sizeof(*blob)); + blob->name = g_strdup("prom"); + blob->addr = cpu_mips_kseg0_to_phys(NULL, ENVP_ADDR); + blob->size = prom_size; + blob->data = g_malloc0(blob->size); + memcpy(blob->data, prom_buf, blob->size); + qemu_register_reset(image_blob_reset, blob); return kernel_entry; } diff --git a/hw/mips_r4k.c b/hw/mips_r4k.c index 325098a..4c3a541 100644 --- a/hw/mips_r4k.c +++ b/hw/mips_r4k.c @@ -135,8 +135,14 @@ static int64_t load_kernel(void) snprintf((char *)params_buf + 8, 256, "%s", loaderparams.kernel_cmdline); } - rom_add_blob_fixed("params", params_buf, params_size, - (16 << 20) - 264); + ImageBlob *blob; + blob = g_malloc0(sizeof(*blob)); + blob->name = g_strdup("params"); + blob->addr = (16 << 20) - 264; + blob->size = params_size; + blob->data = g_malloc0(blob->size); + memcpy(blob->data, params_buf, blob->size); + qemu_register_reset(image_blob_reset, blob); return entry; } diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c index d655e3f..67eeb44 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -151,19 +151,19 @@ static int ppce500_load_device_tree(CPUPPCState *env, char *filename; filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, dtb_file); if (!filename) { - goto out; + return ret; } fdt = load_device_tree(filename, &fdt_size); if (!fdt) { - goto out; + return ret; } goto done; } fdt = create_device_tree(&fdt_size); if (fdt == NULL) { - goto out; + return ret; } /* Manipulate device tree in memory. */ @@ -333,15 +333,16 @@ static int ppce500_load_device_tree(CPUPPCState *env, done: qemu_devtree_dumpdtb(fdt, fdt_size); - ret = rom_add_blob_fixed(BINARY_DEVICE_TREE_FILE, fdt, fdt_size, addr); - if (ret < 0) { - goto out; - } + ImageBlob *blob; + blob = g_malloc0(sizeof(*blob)); + blob->name = g_strdup(BINARY_DEVICE_TREE_FILE); + blob->addr = addr; + blob->size = fdt_size; + blob->data = g_malloc0(blob->size); + memcpy(blob->data, fdt, blob->size); + qemu_register_reset(image_blob_reset, blob); g_free(fdt); ret = fdt_size; - -out: - return ret; } diff --git a/hw/ppc440_bamboo.c b/hw/ppc440_bamboo.c index a6b1d51..3d87279 100644 --- a/hw/ppc440_bamboo.c +++ b/hw/ppc440_bamboo.c @@ -111,7 +111,14 @@ static int bamboo_load_device_tree(hwaddr addr, qemu_devtree_setprop_cell(fdt, "/cpus/cpu@0", "timebase-frequency", tb_freq); - ret = rom_add_blob_fixed(BINARY_DEVICE_TREE_FILE, fdt, fdt_size, addr); + ImageBlob *blob; + blob = g_malloc0(sizeof(*blob)); + blob->name = g_strdup(BINARY_DEVICE_TREE_FILE); + blob->addr = addr; + blob->size = fdt_size; + blob->data = g_malloc0(blob->size); + memcpy(blob->data, fdt, blob->size); + qemu_register_reset(image_blob_reset, blob); g_free(fdt); out: diff --git a/hw/r2d.c b/hw/r2d.c index 66212e9..8af8693 100644 --- a/hw/r2d.c +++ b/hw/r2d.c @@ -339,8 +339,14 @@ static void r2d_init(QEMUMachineInitArgs *args) sizeof(boot_params.kernel_cmdline)); } - rom_add_blob_fixed("boot_params", &boot_params, sizeof(boot_params), - SDRAM_BASE + BOOT_PARAMS_OFFSET); + ImageBlob *blob; + blob = g_malloc0(sizeof(*blob)); + blob->name = g_strdup("boot_params"); + blob->addr = SDRAM_BASE + BOOT_PARAMS_OFFSET; + blob->size = sizeof(boot_params); + blob->data = g_malloc0(blob->size); + memcpy(blob->data, &boot_params, blob->size); + qemu_register_reset(image_blob_reset, blob); } static QEMUMachine r2d_machine = { -- 1.7.1