From patchwork Tue May 14 09:50:28 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Albert ARIBAUD X-Patchwork-Id: 243646 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 0EC552C00BB for ; Tue, 14 May 2013 19:51:45 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 817DD4A10B; Tue, 14 May 2013 11:51:42 +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 rR7Vqcx+04BQ; Tue, 14 May 2013 11:51:42 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7BC9D4A0EE; Tue, 14 May 2013 11:51:38 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5C32F4A0EE for ; Tue, 14 May 2013 11:51:35 +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 2PEP-dZng0hb for ; Tue, 14 May 2013 11:51:34 +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 smtp1-g21.free.fr (smtp1-g21.free.fr [212.27.42.1]) by theia.denx.de (Postfix) with ESMTP id A2A754A0F3 for ; Tue, 14 May 2013 11:51:19 +0200 (CEST) Received: from localhost.localdomain (unknown [IPv6:2a01:e35:2eb9:20:9d7b:1f7:2f:c177]) (Authenticated sender: albert.aribaud) by smtp1-g21.free.fr (Postfix) with ESMTPSA id AD8BE9401C2; Tue, 14 May 2013 11:51:12 +0200 (CEST) From: Albert ARIBAUD To: U-Boot Date: Tue, 14 May 2013 11:50:28 +0200 Message-Id: <1368525030-5162-3-git-send-email-albert.u.boot@aribaud.net> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1368525030-5162-2-git-send-email-albert.u.boot@aribaud.net> References: <1368223012-17609-1-git-send-email-albert.u.boot@aribaud.net> <1368525030-5162-1-git-send-email-albert.u.boot@aribaud.net> <1368525030-5162-2-git-send-email-albert.u.boot@aribaud.net> Subject: [U-Boot] [PATCH v2 2/4] tx25: copy SPL directly, not using relocate_code. 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 Signed-off-by: Albert ARIBAUD --- Changes in v2: - dropped relocate_code() call from tx25 SPL board/karo/tx25/tx25.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/board/karo/tx25/tx25.c b/board/karo/tx25/tx25.c index 2952eba..461e21f 100644 --- a/board/karo/tx25/tx25.c +++ b/board/karo/tx25/tx25.c @@ -35,7 +35,21 @@ DECLARE_GLOBAL_DATA_PTR; #ifdef CONFIG_SPL_BUILD void board_init_f(ulong bootflag) { - relocate_code(CONFIG_SPL_TEXT_BASE); + /* + * copy ourselves from where we are running to where we were + * linked at. Use ulong pointers as all addresses involved + * are 4-byte-aligned. + */ + ulong *start_ptr, *end_ptr, *link_ptr, *run_ptr, *dst; + asm volatile ("ldr %0, =_start" : "=r"(start_ptr)); + asm volatile ("ldr %0, =_end" : "=r"(end_ptr)); + asm volatile ("ldr %0, =board_init_f" : "=r"(link_ptr)); + asm volatile ("adr %0, board_init_f" : "=r"(run_ptr)); + for (dst = start_ptr; dst < end_ptr; dst++) + *dst = *(dst+(run_ptr-link_ptr)); + /* + * branch to nand_boot's link-time address. + */ asm volatile("ldr pc, =nand_boot"); } #endif