From patchwork Tue Nov 23 18:48:48 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joakim Tjernlund X-Patchwork-Id: 72718 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 97F48B70AF for ; Wed, 24 Nov 2010 05:49:46 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 288AD28251; Tue, 23 Nov 2010 19:49:26 +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 XhW3HGr-en0S; Tue, 23 Nov 2010 19:49:25 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 95A8628237; Tue, 23 Nov 2010 19:49:12 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B6BF628222 for ; Tue, 23 Nov 2010 19:49:08 +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 Dl4+w00jkSyT for ; Tue, 23 Nov 2010 19:49:08 +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 50DE2281E4 for ; Tue, 23 Nov 2010 19:49:02 +0100 (CET) Received: from sesr04.transmode.se (sesr04.transmode.se [192.168.201.15]) by gw1.transmode.se (Postfix) with ESMTP id A9F6C650005 for ; Tue, 23 Nov 2010 19:49:01 +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 2010112319490183-51200 ; Tue, 23 Nov 2010 19:49:01 +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 oANIn1v0012439; Tue, 23 Nov 2010 19:49:01 +0100 Received: (from jocke@localhost) by gentoo-jocke.transmode.se (8.14.4/8.14.4/Submit) id oANIn1Pm012438; Tue, 23 Nov 2010 19:49:01 +0100 From: Joakim Tjernlund To: "u-boot@lists.denx.de" Date: Tue, 23 Nov 2010 19:48:48 +0100 Message-Id: <1290538131-12383-4-git-send-email-Joakim.Tjernlund@transmode.se> X-Mailer: git-send-email 1.7.2.2 In-Reply-To: <1290538131-12383-1-git-send-email-Joakim.Tjernlund@transmode.se> References: <1290538131-12383-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-11-23 19:49:01, Serialize by Router on sesr04/Transmode(Release 8.5.2 HF88|October 08, 2010) at 2010-11-23 19:49:01, Serialize complete at 2010-11-23 19:49:01 Cc: Joakim Tjernlund Subject: [U-Boot] [PATCH 3/6] 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 actila load address. This is a must for true PIC u-boot. --- arch/powerpc/cpu/mpc83xx/start.S | 25 +++++++++++++++++++++++++ include/common.h | 5 +++++ 2 files changed, 30 insertions(+), 0 deletions(-) diff --git a/arch/powerpc/cpu/mpc83xx/start.S b/arch/powerpc/cpu/mpc83xx/start.S index 3cac147..ec65f40 100644 --- a/arch/powerpc/cpu/mpc83xx/start.S +++ b/arch/powerpc/cpu/mpc83xx/start.S @@ -427,6 +427,31 @@ _end_of_vectors: . = 0x3000 + .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 + /* * This code finishes saving the registers to the exception frame * and jumps to the appropriate handler for the exception. diff --git a/include/common.h b/include/common.h index 8bca04f..f257ea4 100644 --- a/include/common.h +++ b/include/common.h @@ -94,6 +94,9 @@ typedef volatile unsigned char vu_char; #ifdef CONFIG_MPC83xx #include #include +const void * link_off(const void *); +#else +#define link_off(x) ((const void *)(x)) #endif #ifdef CONFIG_4xx #include @@ -111,6 +114,8 @@ typedef volatile unsigned char vu_char; #include #endif +#define LINK_OFF(x) ((__typeof__(x))link_off(x)) + #include #include #include