From patchwork Mon Dec 20 09:47:13 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joakim Tjernlund X-Patchwork-Id: 76180 X-Patchwork-Delegate: marek.vasut@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 98365B7088 for ; Mon, 20 Dec 2010 20:47:53 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7DEC128147; Mon, 20 Dec 2010 10:47:40 +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 1Fe+0VIFG6DE; Mon, 20 Dec 2010 10:47:40 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 51A112812F; Mon, 20 Dec 2010 10:47:27 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 064722810A for ; Mon, 20 Dec 2010 10:47:24 +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 NOlVT0QosdZF for ; Mon, 20 Dec 2010 10:47:22 +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 gw1.transmode.se (gw1.transmode.se [213.115.205.20]) by theia.denx.de (Postfix) with ESMTPS id 0177A28108 for ; Mon, 20 Dec 2010 10:47:20 +0100 (CET) Received: from sesr04.transmode.se (sesr04.transmode.se [192.168.201.15]) by gw1.transmode.se (Postfix) with ESMTP id 68D24650004; Mon, 20 Dec 2010 10:47:20 +0100 (CET) Received: from gentoo-jocke.transmode.se ([192.168.1.15]) by sesr04.transmode.se (Lotus Domino Release 8.5.2 HF88) with ESMTP id 2010122010472067-3194 ; Mon, 20 Dec 2010 10:47:20 +0100 Received: from gentoo-jocke.transmode.se (gentoo-jocke.transmode.se [127.0.0.1]) by gentoo-jocke.transmode.se (8.14.4/8.14.0) with ESMTP id oBK9lKOW015018; Mon, 20 Dec 2010 10:47:20 +0100 Received: (from jocke@localhost) by gentoo-jocke.transmode.se (8.14.4/8.14.4/Submit) id oBK9lKNq015017; Mon, 20 Dec 2010 10:47:20 +0100 From: Joakim Tjernlund To: u-boot@lists.denx.de, Kim Phillips Date: Mon, 20 Dec 2010 10:47:13 +0100 Message-Id: <1292838435-14958-2-git-send-email-Joakim.Tjernlund@transmode.se> X-Mailer: git-send-email 1.7.2.2 In-Reply-To: <1292838435-14958-1-git-send-email-Joakim.Tjernlund@transmode.se> References: <1292838435-14958-1-git-send-email-Joakim.Tjernlund@transmode.se> X-MIMETrack: Itemize by SMTP Server on sesr04/Transmode(Release 8.5.2 HF88|October 08, 2010) at 2010-12-20 10:47:20, Serialize by Router on sesr04/Transmode(Release 8.5.2 HF88|October 08, 2010) at 2010-12-20 10:47:20, Serialize complete at 2010-12-20 10:47:20 Cc: Joakim Tjernlund Subject: [U-Boot] [PATCH 2/4] mpc83xx: Add link vs. load address calculation 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 link_off calculates the difference between link address and actual load address. This is a must for true PIC u-boot. Signed-off-by: Joakim Tjernlund --- arch/powerpc/cpu/mpc83xx/start.S | 26 ++++++++++++++++++++++++++ include/common.h | 7 +++++++ 2 files changed, 33 insertions(+), 0 deletions(-) diff --git a/arch/powerpc/cpu/mpc83xx/start.S b/arch/powerpc/cpu/mpc83xx/start.S index 1ab8c88..16aed0a 100644 --- a/arch/powerpc/cpu/mpc83xx/start.S +++ b/arch/powerpc/cpu/mpc83xx/start.S @@ -419,6 +419,32 @@ ProgramCheck: _end_of_vectors: . = 0x3000 +#ifdef CONFIG_SYS_TRUE_PIC + .globl link_off /* const void * link_off(const void * ptr) */ + .type link_off, @function + /* + * Calculates the offset between link address and load address + * and subtracs the offset to from its argument(r3) + * This function must be where _GOT2_TABLE_ is defined + */ +link_off: + /* GOT hand coded as we cannot clobber r12 */ + mflr r4 + bl 1f + .text 2 +0: .long .LCTOC1-1f + .text +1: mflr r6 + lwz r0,0b-1b(r6) + add r6,r0,r6 + mtlr r4 + la r4,.L__GOT2_TABLE_(r6) /* addi r4,r6,.L__GOT2_TABLE_ */ + lwz r5,.L__GOT2_TABLE_(r6) + sub r4,r5,r4 /* r4 - r5 */ + sub r3,r3,r4 /* r4 - r3 */ + blr + .size link_off, .-link_off +#endif /* * This code finishes saving the registers to the exception frame diff --git a/include/common.h b/include/common.h index 189ad81..a04bd27 100644 --- a/include/common.h +++ b/include/common.h @@ -112,6 +112,13 @@ typedef volatile unsigned char vu_char; #include #endif +#ifdef CONFIG_SYS_TRUE_PIC +const void * link_off(const void *); +#else +#define link_off(x) ((const void *)(x)) +#endif +#define LINK_OFF(x) ((__typeof__(x))link_off(x)) + #include #include #include