From patchwork Mon Apr 2 05:20:12 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peter A. G. Crosthwaite" X-Patchwork-Id: 150069 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 6E4E6B6EEB for ; Mon, 2 Apr 2012 15:20:52 +1000 (EST) Received: from localhost ([::1]:44059 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SEZhC-0002t6-89 for incoming@patchwork.ozlabs.org; Mon, 02 Apr 2012 01:20:50 -0400 Received: from eggs.gnu.org ([208.118.235.92]:53918) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SEZh0-0002io-4q for qemu-devel@nongnu.org; Mon, 02 Apr 2012 01:20:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SEZgy-0002gt-0Y for qemu-devel@nongnu.org; Mon, 02 Apr 2012 01:20:37 -0400 Received: from mail-iy0-f173.google.com ([209.85.210.173]:43014) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SEZgx-0002fi-Rz for qemu-devel@nongnu.org; Mon, 02 Apr 2012 01:20:35 -0400 Received: by mail-iy0-f173.google.com with SMTP id j26so4544506iaf.4 for ; Sun, 01 Apr 2012 22:20:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :in-reply-to:references:x-gm-message-state; bh=pNiJt73SvYGnve7FH/f7xmUqsCDLQNj647AOzZU6E9U=; b=KHObEOMsNK6WPcGTbgvySU7wGdB9HJyS/CItz3mpMtRkKe6RXCQblJqJO4mYITQWrH cJEbbMKaSBMlNcfYxbE38bt4SRJFzHK6+2zHceN7pkn4EPAUOvzd7z2Mp1U5x4o54qa5 aBAIkQID9tDTZlaZTHyE0QfRwwzqkgCzFY/M9vrLW/b+R1Y2Yu1sdnOvdb58iTFab0g7 kVcx3gf3naDeZJT/0C8esGkbMMjgCQp2TMj4CmpQOvltKCJNdgazzmjOBW7QvoVDNCzA MGxz/qiwjHehPCTIbMANzhXv0xLOGBSHO0kw5cbDZttr98QQ9fMgEzj8xHCP5g9YEoIr e0ug== Received: by 10.50.184.131 with SMTP id eu3mr4440804igc.13.1333344034989; Sun, 01 Apr 2012 22:20:34 -0700 (PDT) Received: from localhost ([124.148.20.9]) by mx.google.com with ESMTPS id vr4sm23043427igb.1.2012.04.01.22.20.30 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 01 Apr 2012 22:20:34 -0700 (PDT) From: "Peter A. G. Crosthwaite" To: peter.crosthwaite@petalogix.com, qemu-devel@nongnu.org, paul@codesourcery.com, peter.maydell@linaro.org, edgar.iglesias@gmail.com Date: Mon, 2 Apr 2012 15:20:12 +1000 Message-Id: <3b3f2a975593c1c0b049589371b195db7794aceb.1333343538.git.peter.crosthwaite@petalogix.com> X-Mailer: git-send-email 1.7.3.2 In-Reply-To: References: In-Reply-To: References: X-Gm-Message-State: ALoCoQlgeYdvyoXHDuUqcPWfhjHeq13WoBx0aqasgkzDbW6UO38o6fe4N99GxCGCFTnnGhJZoHLv X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.210.173 Cc: linnj@xilinx.com, john.williams@petalogix.com, duyl@xilinx.com Subject: [Qemu-devel] [PATCH v1 2/3] arm_boot: parameterized intird and dtb locations 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 Added fields that allows a machine model to specify where the initrd and dtb are loaded. Leaving the fields 0 will use to old default values (previously hardcoded in arm_boot.c) Signed-off-by: Peter A. G. Crosthwaite Signed-off-by: John Linn --- hw/arm-misc.h | 8 ++++++++ hw/arm_boot.c | 34 ++++++++++++++++++++-------------- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/hw/arm-misc.h b/hw/arm-misc.h index 2f46e21..25f3da8 100644 --- a/hw/arm-misc.h +++ b/hw/arm-misc.h @@ -31,6 +31,14 @@ struct arm_boot_info { const char *initrd_filename; const char *dtb_filename; target_phys_addr_t loader_start; + /* where to place the initrd relative to loader start. A value of 0 + * will select the default value of loader_start + 0xd00000. + */ + target_phys_addr_t initrd_offset; + /* where to place the dtb relative to loader start. A value of 0 will + * place it immediately after the initrd (page aligned). + */ + target_phys_addr_t dtb_offset; /* multicore boards that use the default secondary core boot functions * need to put the address of the secondary boot code, the boot reg, * and the GIC address in the next 3 values, respectively. boards that diff --git a/hw/arm_boot.c b/hw/arm_boot.c index 7447f5c..302bd17 100644 --- a/hw/arm_boot.c +++ b/hw/arm_boot.c @@ -18,7 +18,8 @@ #define KERNEL_ARGS_ADDR 0x100 #define KERNEL_LOAD_ADDR 0x00010000 -#define INITRD_LOAD_ADDR 0x00d00000 + +#define DEFAULT_INITRD_OFFSET 0x00d00000 /* The worlds second smallest bootloader. Set r0-r2, then jump to kernel. */ static uint32_t bootloader[] = { @@ -107,7 +108,7 @@ static void set_kernel_args(const struct arm_boot_info *info) /* ATAG_INITRD2 */ WRITE_WORD(p, 4); WRITE_WORD(p, 0x54420005); - WRITE_WORD(p, info->loader_start + INITRD_LOAD_ADDR); + WRITE_WORD(p, info->loader_start + info->initrd_offset); WRITE_WORD(p, initrd_size); } if (info->kernel_cmdline && *info->kernel_cmdline) { @@ -184,7 +185,7 @@ static void set_kernel_args_old(const struct arm_boot_info *info) WRITE_WORD(p, 0); /* initrd_start */ if (initrd_size) - WRITE_WORD(p, info->loader_start + INITRD_LOAD_ADDR); + WRITE_WORD(p, info->loader_start + info->initrd_offset); else WRITE_WORD(p, 0); /* initrd_size */ @@ -211,7 +212,7 @@ static void set_kernel_args_old(const struct arm_boot_info *info) } } -static int load_dtb(target_phys_addr_t addr, const struct arm_boot_info *binfo) +static int load_dtb(const struct arm_boot_info *binfo) { #ifdef CONFIG_FDT uint32_t mem_reg_property[] = { cpu_to_be32(binfo->loader_start), @@ -248,20 +249,21 @@ static int load_dtb(target_phys_addr_t addr, const struct arm_boot_info *binfo) if (binfo->initrd_size) { rc = qemu_devtree_setprop_cell(fdt, "/chosen", "linux,initrd-start", - binfo->loader_start + INITRD_LOAD_ADDR); + binfo->loader_start + binfo->initrd_offset); if (rc < 0) { fprintf(stderr, "couldn't set /chosen/linux,initrd-start\n"); } rc = qemu_devtree_setprop_cell(fdt, "/chosen", "linux,initrd-end", - binfo->loader_start + INITRD_LOAD_ADDR + + binfo->loader_start + binfo->initrd_offset + binfo->initrd_size); if (rc < 0) { fprintf(stderr, "couldn't set /chosen/linux,initrd-end\n"); } } - cpu_physical_memory_write(addr, fdt, size); + cpu_physical_memory_write(binfo->loader_start + binfo->dtb_offset, + fdt, size); return 0; @@ -362,10 +364,13 @@ void arm_load_kernel(CPUARMState *env, struct arm_boot_info *info) info->entry = entry; if (is_linux) { if (info->initrd_filename) { + if (!info->initrd_offset) { + info->initrd_offset = DEFAULT_INITRD_OFFSET; + } initrd_size = load_image_targphys(info->initrd_filename, info->loader_start - + INITRD_LOAD_ADDR, - ram_size - INITRD_LOAD_ADDR); + + info->initrd_offset, + ram_size - info->initrd_offset); if (initrd_size < 0) { fprintf(stderr, "qemu: could not load initrd '%s'\n", info->initrd_filename); @@ -382,14 +387,15 @@ void arm_load_kernel(CPUARMState *env, struct arm_boot_info *info) * we point to the kernel args. */ if (info->dtb_filename) { - /* Place the DTB after the initrd in memory */ - target_phys_addr_t dtb_start = TARGET_PAGE_ALIGN(info->loader_start - + INITRD_LOAD_ADDR + if (!info->dtb_offset) { + /* Place the DTB after the initrd in memory */ + info->dtb_offset = TARGET_PAGE_ALIGN(info->initrd_offset + initrd_size); - if (load_dtb(dtb_start, info)) { + } + if (load_dtb(info)) { exit(1); } - bootloader[5] = dtb_start; + bootloader[5] = info->loader_start + info->dtb_offset; } else { bootloader[5] = info->loader_start + KERNEL_ARGS_ADDR; }