From patchwork Fri Sep 28 01:41:55 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 187694 X-Patchwork-Delegate: albert.aribaud@free.fr Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 3BA6D2C00F5 for ; Fri, 28 Sep 2012 11:42:10 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 56F8D280F8; Fri, 28 Sep 2012 03:42:07 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UkJVJea16Ax6; Fri, 28 Sep 2012 03:42:07 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id CF62D280EC; Fri, 28 Sep 2012 03:42:05 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8BE9A280EC for ; Fri, 28 Sep 2012 03:42:04 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id eq8touGmuKM2 for ; Fri, 28 Sep 2012 03:42:03 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-vb0-f74.google.com (mail-vb0-f74.google.com [209.85.212.74]) by theia.denx.de (Postfix) with ESMTPS id A3AA5280EB for ; Fri, 28 Sep 2012 03:42:00 +0200 (CEST) Received: by vbis24 with SMTP id s24so292895vbi.3 for ; Thu, 27 Sep 2012 18:41:58 -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:x-gm-message-state; bh=sZaQN4cGjT0SyXUg28SDjqsueSKx+cf7RxmbZzA2oLQ=; b=iBi0PBudYijjRTD7jq8+YWFvPpjwTTKdcM/qLK0awcZknhUb3UAkYqNT1cT2ZDPxht y3OTjZ2Ffi0C+MM7XSr/vYnc7YNoTU83M55u/CyUFg4nR5cfXYUMxjsCGPjsmqTi0QCk DxkEtZZAXj4VbVC+P/RXgeNUrd7CRbXudhZZNeq1zhMQeIlMnoDQvCivdwfTPtjpqL4x gqU9mBOD1qK0X4Hd3mP6yGADiq9i1olOLj5zRSfAfTqC9b8lSwgBzueAFhv0xPUPa+WG 4B/NS4HxlF/IndXkCXfXa+PKv8GHoF7jjnGKL2SvHS1fiwAqYACllwys6/pGk1IYefmO jX4A== Received: by 10.236.185.103 with SMTP id t67mr2918389yhm.49.1348796518315; Thu, 27 Sep 2012 18:41:58 -0700 (PDT) Received: by 10.236.185.103 with SMTP id t67mr2918380yhm.49.1348796518251; Thu, 27 Sep 2012 18:41:58 -0700 (PDT) Received: from wpzn4.hot.corp.google.com (216-239-44-65.google.com [216.239.44.65]) by gmr-mx.google.com with ESMTPS id u42si1652739yhg.5.2012.09.27.18.41.58 (version=TLSv1/SSLv3 cipher=AES128-SHA); Thu, 27 Sep 2012 18:41:58 -0700 (PDT) Received: from kaka.mtv.corp.google.com (kaka.mtv.corp.google.com [172.22.73.79]) by wpzn4.hot.corp.google.com (Postfix) with ESMTP id 2112C1E0043; Thu, 27 Sep 2012 18:41:58 -0700 (PDT) Received: by kaka.mtv.corp.google.com (Postfix, from userid 121222) id B447F1606FD; Thu, 27 Sep 2012 18:41:57 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Date: Thu, 27 Sep 2012 18:41:55 -0700 Message-Id: <1348796515-29008-1-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.7.7.3 X-Gm-Message-State: ALoCoQm6QwIyMgSfg7skYhf9Mzwrzl/rbCnHFL8B8lvk3LdNLEuLFyAVEtrrLSw5lVQpl4jGUhUvVZLfHJRUvgWM9pv3m/k+2ikyvTn/nwpqfHEOMi6qVU03MBKBEohDgZLezMoIvF6p0mslGrG/lMgKJdMe6PrD/hJgILam9dzHf7ntM0TxrI6UnjRjZ4THPe9LwT1Al4br Cc: Devicetree Discuss , Jerry Van Baren Subject: [U-Boot] [PATCH] arm: fdt: Relocate fdt along with other data X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Rather than leave the fdt down next to the code/data, we really should relocate it along with everything else. For CONFIG_OF_EMBED this happens automatically, but for CONFIG_OF_SEPARATE it does not. Add code to copy the fdt and point to the new copy after relocation. Signed-off-by: Simon Glass Tested-by: Stephen Warren --- arch/arm/lib/board.c | 22 ++++++++++++++++++++++ 1 files changed, 22 insertions(+), 0 deletions(-) diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c index 109a1ac..6dca891 100644 --- a/arch/arm/lib/board.c +++ b/arch/arm/lib/board.c @@ -274,6 +274,8 @@ void board_init_f(ulong bootflag) #ifdef CONFIG_PRAM ulong reg; #endif + void *new_fdt = NULL; + size_t fdt_size = 0; bootstage_mark_name(BOOTSTAGE_ID_START_UBOOT_F, "board_init_f"); @@ -409,6 +411,22 @@ void board_init_f(ulong bootflag) debug("Reserving %zu Bytes for Global Data at: %08lx\n", sizeof (gd_t), addr_sp); +#if defined(CONFIG_OF_SEPARATE) && defined(CONFIG_OF_CONTROL) + /* + * If the device tree is sitting immediate above our image then we + * must relocate it. If it is embedded in the data section, then it + * will be relocated with other data. + */ + if (gd->fdt_blob) { + fdt_size = ALIGN(fdt_totalsize(gd->fdt_blob) + 0x1000, 32); + + addr_sp -= fdt_size; + new_fdt = (void *)addr_sp; + debug("Reserving %zu Bytes for FDT at: %08lx\n", + fdt_size, addr_sp); + } +#endif + /* setup stackpointer for exeptions */ gd->irq_sp = addr_sp; #ifdef CONFIG_USE_IRQ @@ -442,6 +460,10 @@ void board_init_f(ulong bootflag) gd->start_addr_sp = addr_sp; gd->reloc_off = addr - _TEXT_BASE; debug("relocation Offset is: %08lx\n", gd->reloc_off); + if (new_fdt) { + memcpy(new_fdt, gd->fdt_blob, fdt_size); + gd->fdt_blob = new_fdt; + } memcpy(id, (void *)gd, sizeof(gd_t)); relocate_code(addr_sp, id, addr);