From patchwork Wed Jan 4 19:59:44 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Graeme Russ X-Patchwork-Id: 134343 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 12BAAB6FA8 for ; Thu, 5 Jan 2012 07:01:27 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id ABA4B28450; Wed, 4 Jan 2012 21:00:54 +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 GZPgytdmVssG; Wed, 4 Jan 2012 21:00:54 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D8FAB28434; Wed, 4 Jan 2012 21:00:34 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 795C62840D for ; Wed, 4 Jan 2012 21:00:31 +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 N1q0TA3GW4Iw for ; Wed, 4 Jan 2012 21:00:31 +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-vw0-f44.google.com (mail-vw0-f44.google.com [209.85.212.44]) by theia.denx.de (Postfix) with ESMTPS id 3CA65283E6 for ; Wed, 4 Jan 2012 21:00:18 +0100 (CET) Received: by vbbfo1 with SMTP id fo1so12279428vbb.3 for ; Wed, 04 Jan 2012 12:00:16 -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=xLjoc0wnkP9LZ3s/yzX1DE03aFzZAf1iLk3G+HfeHK4=; b=qV1pnWacvVJRe7YujtH/1dT3WaLSslbK59YGTbR50OlK243U7tfYYPo16HbLQLM7P4 mxk7v39HzzaZeqxiiT9gPUWmzRgKUYVd9/L78TxE6+aGUvguHzflgXSuQkELpTtngAHH fYqZ/VaoQR5lryNqSiu33X7Hso0QdFrg52YO8= Received: by 10.52.66.65 with SMTP id d1mr27639151vdt.108.1325707216410; Wed, 04 Jan 2012 12:00:16 -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.14 (version=SSLv3 cipher=OTHER); Wed, 04 Jan 2012 12:00:15 -0800 (PST) From: Graeme Russ To: u-boot@lists.denx.de Date: Thu, 5 Jan 2012 06:59:44 +1100 Message-Id: <1325707195-3218-6-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-7-git-send-email-graeme.russ@gmail.com> Subject: [U-Boot] [PATCH v2 06/17] x86: Rework relocation calculations 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 This commit introduces no functional changes - It simply re-arranges the calculations so that adding to them in future commits will be cleaner Signed-off-by: Graeme Russ Acked-by: Simon Glass --- Changes for v2: - Fixed typo in title - Added commit message arch/x86/lib/board.c | 23 +++++++++++------------ 1 files changed, 11 insertions(+), 12 deletions(-) -- 1.7.5.2.317.g391b14 diff --git a/arch/x86/lib/board.c b/arch/x86/lib/board.c index 382ada7..6f075b7 100644 --- a/arch/x86/lib/board.c +++ b/arch/x86/lib/board.c @@ -164,24 +164,23 @@ static int calculate_relocation_address(void) ulong text_start = (ulong)&__text_start; ulong bss_end = (ulong)&__bss_end; ulong dest_addr; - ulong rel_offset; - - /* Calculate destination RAM Address and relocation offset */ - dest_addr = gd->ram_size; - dest_addr -= CONFIG_SYS_STACK_SIZE; - dest_addr -= (bss_end - text_start); /* - * Round destination address down to 16-byte boundary to keep - * IDT and GDT 16-byte aligned + * NOTE: All destination address are rounded down to 16-byte + * boundary to satisfy various worst-case alignment + * requirements */ - dest_addr &= ~15; - rel_offset = dest_addr - text_start; + /* Stack is at top of available memory */ + dest_addr = gd->ram_size; + gd->start_addr_sp = dest_addr; - gd->start_addr_sp = gd->ram_size; + /* U-Boot is below the stack */ + dest_addr -= CONFIG_SYS_STACK_SIZE; + dest_addr -= (bss_end - text_start); + dest_addr &= ~15; gd->relocaddr = dest_addr; - gd->reloc_off = rel_offset; + gd->reloc_off = (dest_addr - text_start); return 0; }