From patchwork Wed Jan 4 19:59:43 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Graeme Russ X-Patchwork-Id: 134341 X-Patchwork-Delegate: graeme.russ@gmail.com 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 542A1B6FA8 for ; Thu, 5 Jan 2012 07:01:05 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3D1FA28415; Wed, 4 Jan 2012 21:00:39 +0100 (CET) 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 CDZ34KW34ncw; Wed, 4 Jan 2012 21:00:38 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 65B8828405; Wed, 4 Jan 2012 21:00:27 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 03067283F2 for ; Wed, 4 Jan 2012 21:00:25 +0100 (CET) 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 SRRkZlxnRv6l for ; Wed, 4 Jan 2012 21:00:24 +0100 (CET) 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-vx0-f172.google.com (mail-vx0-f172.google.com [209.85.220.172]) by theia.denx.de (Postfix) with ESMTPS id 68DC5283FF for ; Wed, 4 Jan 2012 21:00:14 +0100 (CET) Received: by mail-vx0-f172.google.com with SMTP id fk13so13532049vcb.3 for ; Wed, 04 Jan 2012 12:00:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :in-reply-to; bh=lTovBCmSoXHPMtxTTUxM3rkmp695wC9r5IRQ673HsWA=; b=qzmaqRZ5U2Pa3q5Z1Blo7D3r8HeJhCkFjcm9BueidbZEodSMDv+jQaRRwT3lM1h6pc /gT8BQs6yOoT0+FDGeM5czJzizLv1+DrXRQMJmF5ySMMq7ZdnurygGdJqnHQy66tLuBh UkLYV0mxFFmOTOHhxkKko6yujcn2/sNJpnBj8= Received: by 10.220.225.10 with SMTP id iq10mr18683515vcb.62.1325707213894; Wed, 04 Jan 2012 12:00:13 -0800 (PST) Received: from localhost.localdomain (d110-32-162-141.sbr801.nsw.optusnet.com.au. [110.32.162.141]) by mx.google.com with ESMTPS id eb3sm33049296vdc.5.2012.01.04.12.00.11 (version=SSLv3 cipher=OTHER); Wed, 04 Jan 2012 12:00:13 -0800 (PST) From: Graeme Russ To: u-boot@lists.denx.de Date: Thu, 5 Jan 2012 06:59:43 +1100 Message-Id: <1325707195-3218-5-git-send-email-graeme.russ@gmail.com> X-Mailer: git-send-email 1.7.5.2.317.g391b14 In-Reply-To: <1325707195-3218-1-git-send-email-graeme.russ@gmail.com> References: <1325707195-3218-1-git-send-email-graeme.russ@gmail.com> In-Reply-To: <1325477374-6417-6-git-send-email-graeme.russ@gmail.com> Subject: [U-Boot] [PATCH v2 05/17] x86: Simplify Flash-to-RAM code execution transition 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 Move the relocation offset calculation out of assembler and into C. This also paves the way for the upcoming init sequence simplification by adding the board_init_f_r flash to RAM transitional function Signed-off-by: Graeme Russ Acked-by: Simon Glass --- Changes for v2: - Added commit message - Minor adjustment to new stack address comment arch/x86/cpu/start.S | 22 ++++++---------------- arch/x86/include/asm/u-boot-x86.h | 2 ++ arch/x86/lib/board.c | 25 ++++++++++++++++++++++--- 3 files changed, 30 insertions(+), 19 deletions(-) -- 1.7.5.2.317.g391b14 diff --git a/arch/x86/cpu/start.S b/arch/x86/cpu/start.S index 6027f54..69a9b2c 100644 --- a/arch/x86/cpu/start.S +++ b/arch/x86/cpu/start.S @@ -96,32 +96,22 @@ car_init_ret: movw $0x85, %ax jmp die -.globl relocate_code -.type relocate_code, @function -relocate_code: +.globl board_init_f_r_trampoline +.type board_init_f_r_trampoline, @function +board_init_f_r_trampoline: /* * SDRAM has been initialised, U-Boot code has been copied into * RAM, BSS has been cleared and relocation adjustments have been * made. It is now time to jump into the in-RAM copy of U-Boot * - * %eax = Address of top of stack - * %edx = Address of Global Data - * %ecx = Base address of in-RAM copy of U-Boot + * %eax = Address of top of new stack */ /* Setup stack in RAM */ movl %eax, %esp - /* Setup call address of in-RAM copy of board_init_r() */ - movl $board_init_r, %ebp - addl (GENERATED_GD_RELOC_OFF)(%edx), %ebp - - /* Setup parameters to board_init_r() */ - movl %edx, %eax - movl %ecx, %edx - - /* Jump to in-RAM copy of board_init_r() */ - call *%ebp + /* Re-enter U-Boot by calling board_init_f_r */ + call board_init_f_r die: hlt diff --git a/arch/x86/include/asm/u-boot-x86.h b/arch/x86/include/asm/u-boot-x86.h index 755f88a..c3d2277 100644 --- a/arch/x86/include/asm/u-boot-x86.h +++ b/arch/x86/include/asm/u-boot-x86.h @@ -61,5 +61,7 @@ u32 isa_map_rom(u32 bus_addr, int size); int video_bios_init(void); int video_init(void); +void board_init_f_r_trampoline(ulong) __attribute__ ((noreturn)); +void board_init_f_r(void) __attribute__ ((noreturn)); #endif /* _U_BOOT_I386_H_ */ diff --git a/arch/x86/lib/board.c b/arch/x86/lib/board.c index f9eb15b..382ada7 100644 --- a/arch/x86/lib/board.c +++ b/arch/x86/lib/board.c @@ -253,10 +253,29 @@ void board_init_f(ulong boot_flags) gd->flags |= GD_FLG_RELOC; - /* Enter the relocated U-Boot! */ - relocate_code(gd->start_addr_sp, gd, gd->relocaddr); + /* + * SDRAM is now initialised, U-Boot has been copied into SDRAM, + * the BSS has been cleared etc. The final stack can now be setup + * in SDRAM. Code execution will continue (momentarily) in Flash, + * but with the stack in SDRAM and Global Data in temporary memory + * (CPU cache) + */ + board_init_f_r_trampoline(gd->start_addr_sp); + + /* NOTREACHED - board_init_f_r_trampoline() does not return */ + while (1) + ; +} + +void board_init_f_r(void) +{ + /* + * Transfer execution from Flash to RAM by calculating the address + * of the in-RAM copy of board_init_r() and calling it + */ + (board_init_r + gd->reloc_off)(gd, gd->relocaddr); - /* NOTREACHED - relocate_code() does not return */ + /* NOTREACHED - board_init_r() does not return */ while (1) ; }