From patchwork Fri Oct 26 08:02:05 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olivia Yin X-Patchwork-Id: 194398 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 591C52C0097 for ; Fri, 26 Oct 2012 19:47:05 +1100 (EST) Received: from localhost ([::1]:47801 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TRfZH-0003JB-JS for incoming@patchwork.ozlabs.org; Fri, 26 Oct 2012 04:47:03 -0400 Received: from eggs.gnu.org ([208.118.235.92]:34913) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TRfWf-000285-N8 for qemu-devel@nongnu.org; Fri, 26 Oct 2012 04:44:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TRfWd-00022I-Ux for qemu-devel@nongnu.org; Fri, 26 Oct 2012 04:44:21 -0400 Received: from va3ehsobe005.messaging.microsoft.com ([216.32.180.31]:45288 helo=va3outboundpool.messaging.microsoft.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TRfWV-0001wo-P5; Fri, 26 Oct 2012 04:44:11 -0400 Received: from mail159-va3-R.bigfish.com (10.7.14.238) by VA3EHSOBE002.bigfish.com (10.7.40.22) with Microsoft SMTP Server id 14.1.225.23; Fri, 26 Oct 2012 08:44:10 +0000 Received: from mail159-va3 (localhost [127.0.0.1]) by mail159-va3-R.bigfish.com (Postfix) with ESMTP id 8F9941C00CA; Fri, 26 Oct 2012 08:44:10 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: 0 X-BigFish: VS0(zzzz1202h1d1ah1d2ahzz8275bhz2dh2a8h668h839hd24he5bhf0ah1288h12a5h12a9h12bdh12e5h1354h137ah139eh13b6h1441h1504h1537h1155h) Received: from mail159-va3 (localhost.localdomain [127.0.0.1]) by mail159-va3 (MessageSwitch) id 1351241047223846_2390; Fri, 26 Oct 2012 08:44:07 +0000 (UTC) Received: from VA3EHSMHS002.bigfish.com (unknown [10.7.14.253]) by mail159-va3.bigfish.com (Postfix) with ESMTP id 2FA2C420078; Fri, 26 Oct 2012 08:44:07 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by VA3EHSMHS002.bigfish.com (10.7.99.12) with Microsoft SMTP Server (TLS) id 14.1.225.23; Fri, 26 Oct 2012 08:44:05 +0000 Received: from az84smr01.freescale.net (10.64.34.197) by 039-SN1MMR1-004.039d.mgd.msft.net (10.84.1.14) with Microsoft SMTP Server (TLS) id 14.2.318.3; Fri, 26 Oct 2012 08:44:03 +0000 Received: from localhost.localdomain (rock.ap.freescale.net [10.193.20.106]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id q9Q8hghS021898; Fri, 26 Oct 2012 01:44:01 -0700 From: Olivia Yin To: , Date: Fri, 26 Oct 2012 16:02:05 +0800 Message-ID: <1351238526-2551-5-git-send-email-hong-hua.yin@freescale.com> X-Mailer: git-send-email 1.6.4 In-Reply-To: <1351238526-2551-4-git-send-email-hong-hua.yin@freescale.com> References: <1351238526-2551-1-git-send-email-hong-hua.yin@freescale.com> <1351238526-2551-2-git-send-email-hong-hua.yin@freescale.com> <1351238526-2551-3-git-send-email-hong-hua.yin@freescale.com> <1351238526-2551-4-git-send-email-hong-hua.yin@freescale.com> MIME-Version: 1.0 X-OriginatorOrg: freescale.com X-detected-operating-system: by eggs.gnu.org: Windows XP/2000 (RFC1323+, w+, tstamp-) X-Received-From: 216.32.180.31 Cc: Olivia Yin Subject: [Qemu-devel] [PATCH 4/5] replaece rom_add_blob* with image_blob_reset X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Olivia Yin --- 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 a6e9143..53c8861 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 731a983..cf219c7 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 11aa131..ff29221 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 70dc61f..8db1a36 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, target_phys_addr_t 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 4a20ed2..5cf776a 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, target_phys_addr_t 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 d4a8672..87f560e 100644 --- a/hw/mips_fulong2e.c +++ b/hw/mips_fulong2e.c @@ -162,8 +162,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 632b466..6f0fb13 100644 --- a/hw/mips_malta.c +++ b/hw/mips_malta.c @@ -736,8 +736,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 967a76e..401917b 100644 --- a/hw/mips_r4k.c +++ b/hw/mips_r4k.c @@ -134,8 +134,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 c3fb618..c4cc6cc 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -150,19 +150,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. */ @@ -332,15 +332,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 9286438..e3e49dd 100644 --- a/hw/ppc440_bamboo.c +++ b/hw/ppc440_bamboo.c @@ -111,7 +111,14 @@ static int bamboo_load_device_tree(target_phys_addr_t 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 1bc191f..15e1be4 100644 --- a/hw/r2d.c +++ b/hw/r2d.c @@ -338,8 +338,14 @@ static void r2d_init(ram_addr_t ram_size, 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 = {