From patchwork Fri Feb 4 12:35:50 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Graeme Russ X-Patchwork-Id: 81873 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 2E679B712B for ; Fri, 4 Feb 2011 23:40:29 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1C471283F4; Fri, 4 Feb 2011 13:38:56 +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 QapPiSttUBgC; Fri, 4 Feb 2011 13:38:55 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9BAEF283B1; Fri, 4 Feb 2011 13:38:02 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1E5BF283C2 for ; Fri, 4 Feb 2011 13:37:59 +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 nrxZM294yAfe for ; Fri, 4 Feb 2011 13:37:58 +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-gy0-f172.google.com (mail-gy0-f172.google.com [209.85.160.172]) by theia.denx.de (Postfix) with ESMTPS id 01F09283B1 for ; Fri, 4 Feb 2011 13:37:16 +0100 (CET) Received: by mail-gy0-f172.google.com with SMTP id 12so991762gyd.3 for ; Fri, 04 Feb 2011 04:37:16 -0800 (PST) Received: by 10.90.51.20 with SMTP id y20mr15453388agy.115.1296823036094; Fri, 04 Feb 2011 04:37:16 -0800 (PST) Received: from helios.localdomain6 (d122-104-34-241.sbr6.nsw.optusnet.com.au [122.104.34.241]) by mx.google.com with ESMTPS id g27sm398868yhc.8.2011.02.04.04.37.13 (version=SSLv3 cipher=RC4-MD5); Fri, 04 Feb 2011 04:37:15 -0800 (PST) From: Graeme Russ To: u-boot@lists.denx.de Date: Fri, 4 Feb 2011 23:35:50 +1100 Message-Id: <1296822959-3927-24-git-send-email-graeme.russ@gmail.com> X-Mailer: git-send-email 1.7.1.422.g049e9 In-Reply-To: <1296822959-3927-1-git-send-email-graeme.russ@gmail.com> References: <1296822959-3927-1-git-send-email-graeme.russ@gmail.com> Subject: [U-Boot] [PATCH 23/32] x86: Defer setup of final stack X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 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: Graeme Russ --- arch/i386/cpu/start.S | 44 +++++++++++++++++++++++++++++--------------- arch/i386/lib/board.c | 6 ++++-- 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/arch/i386/cpu/start.S b/arch/i386/cpu/start.S index 95be5a2..77f0332 100644 --- a/arch/i386/cpu/start.S +++ b/arch/i386/cpu/start.S @@ -96,21 +96,6 @@ car_init_ret: /* size memory */ call dram_init_f - /* Setup stack in SDRAM */ - movl (GD_RAM_SIZE * 4)(%ebp), %esp - - /* Test the stack */ - pushl $0 - popl %ecx - cmpl $0, %ecx - jne die - push $0x55aa55aa - popl %ecx - cmpl $0x55aa55aa, %ecx - jne die - - wbinvd - /* Set parameter to board_init_f() to boot flags */ movl (GD_FLAGS * 4)(%ebp), %eax @@ -118,6 +103,35 @@ car_init_ret: /* indicate (lack of) progress */ movw $0x85, %ax + jmp die + +.globl relocate_code +.type relocate_code, @function +relocate_code: + /* + * 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 + */ + + /* Setup stack in RAM */ + movl %eax, %esp + + /* Setup call address of in-RAM copy of board_init_r() */ + movl $board_init_r, %ebp + subl (GD_RELOC_OFF * 4)(%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 + die: hlt jmp die hlt diff --git a/arch/i386/lib/board.c b/arch/i386/lib/board.c index 09816df..e3869d6 100644 --- a/arch/i386/lib/board.c +++ b/arch/i386/lib/board.c @@ -189,6 +189,7 @@ void board_init_f(ulong boot_flags) ulong *src_addr; ulong *end_addr; + void *addr_sp; void *dest_addr; ulong rel_offset; Elf32_Rel *re_src; @@ -198,6 +199,7 @@ void board_init_f(ulong boot_flags) /* Calculate destination RAM Address and relocation offset */ dest_addr = (void *)gd->ram_size; + addr_sp = dest_addr; dest_addr -= CONFIG_SYS_STACK_SIZE; dest_addr -= (bss_end - text_start); rel_offset = text_start - dest_addr; @@ -242,9 +244,9 @@ void board_init_f(ulong boot_flags) gd->flags |= GD_FLG_RELOC; /* Enter the relocated U-Boot! */ - (board_init_r - rel_offset)(gd, (ulong)dest_addr); + relocate_code((ulong)addr_sp, gd, (ulong)dest_addr); - /* NOTREACHED - board_init_f() does not return */ + /* NOTREACHED - relocate_code() does not return */ while(1); }