From patchwork Mon Jan 2 04:09:23 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Graeme Russ X-Patchwork-Id: 133781 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 04657B6FA2 for ; Mon, 2 Jan 2012 15:11:14 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D097B2826E; Mon, 2 Jan 2012 05:10:45 +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 X6QeiAterFis; Mon, 2 Jan 2012 05:10:45 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id AE43828239; Mon, 2 Jan 2012 05:10:23 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 826EC281E0 for ; Mon, 2 Jan 2012 05:10:21 +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 iF57lIZNx5if for ; Mon, 2 Jan 2012 05:10:21 +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-yw0-f44.google.com (mail-yw0-f44.google.com [209.85.213.44]) by theia.denx.de (Postfix) with ESMTPS id C8DAE281E9 for ; Mon, 2 Jan 2012 05:10:05 +0100 (CET) Received: by yhjj72 with SMTP id j72so8340314yhj.3 for ; Sun, 01 Jan 2012 20:10:04 -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; bh=busmxaIqEbqH0R71YQOVzX0zFxVJO3sQJ/2zeiQWRds=; b=Jt33JykERtryyBQWmUbCC9/NoKWgA8uFixZHB9U07Sm4NptYoQYad1/DSFu9EwAsGR Zp+fRVYV+tnkO7wMh20mVoEN4YsOCPD+j9KPeAlZjVX5mErix8MQi9cCpRoksdoMdVh2 9uB9uiCXtRs3q6aoRNe6Co6jUhTik2L40lAEs= Received: by 10.236.78.228 with SMTP id g64mr2165611yhe.81.1325477404067; Sun, 01 Jan 2012 20:10:04 -0800 (PST) Received: from localhost.localdomain (d58-106-85-147.sbr801.nsw.optusnet.com.au. [58.106.85.147]) by mx.google.com with ESMTPS id 9sm114431452any.3.2012.01.01.20.10.01 (version=SSLv3 cipher=OTHER); Sun, 01 Jan 2012 20:10:03 -0800 (PST) From: Graeme Russ To: u-boot@lists.denx.de Date: Mon, 2 Jan 2012 15:09:23 +1100 Message-Id: <1325477374-6417-7-git-send-email-graeme.russ@gmail.com> X-Mailer: git-send-email 1.7.5.2.317.g391b14 In-Reply-To: <1325477374-6417-1-git-send-email-graeme.russ@gmail.com> References: <1325477374-6417-1-git-send-email-graeme.russ@gmail.com> Subject: [U-Boot] [PATCH 06/17] x86: Rework relocation calcuations 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: Graeme Russ Acked-by: Simon Glass --- arch/x86/lib/board.c | 23 +++++++++++------------ 1 files changed, 11 insertions(+), 12 deletions(-) diff --git a/arch/x86/lib/board.c b/arch/x86/lib/board.c index 978beaa..bc5027b 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; }