From patchwork Tue Dec 14 23:18:51 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timur Tabi X-Patchwork-Id: 75581 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 9AEE6B6EF2 for ; Wed, 15 Dec 2010 10:19:18 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3AC3F28084; Wed, 15 Dec 2010 00:19:15 +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 L6413NpjOXJq; Wed, 15 Dec 2010 00:19:14 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5F5D62807E; Wed, 15 Dec 2010 00:19:13 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1B8172807E for ; Wed, 15 Dec 2010 00:19:11 +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 YRBPa5rIi74v for ; Wed, 15 Dec 2010 00:19:09 +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 TX2EHSOBE001.bigfish.com (tx2ehsobe001.messaging.microsoft.com [65.55.88.11]) by theia.denx.de (Postfix) with ESMTPS id 0DB112807D for ; Wed, 15 Dec 2010 00:19:07 +0100 (CET) Received: from mail79-tx2-R.bigfish.com (10.9.14.240) by TX2EHSOBE001.bigfish.com (10.9.40.21) with Microsoft SMTP Server id 14.1.225.8; Tue, 14 Dec 2010 23:19:05 +0000 Received: from mail79-tx2 (localhost.localdomain [127.0.0.1]) by mail79-tx2-R.bigfish.com (Postfix) with ESMTP id 64C51B8429 for ; Tue, 14 Dec 2010 23:19:05 +0000 (UTC) X-SpamScore: 3 X-BigFish: VS3(zz853kzz1202hzz8275bhz2dh2a8h668h62h) X-Spam-TCS-SCL: 1:0 X-Forefront-Antispam-Report: KIP:(null); UIP:(null); IPVD:NLI; H:az33egw01.freescale.net; RD:az33egw01.freescale.net; EFVD:NLI Received: from mail79-tx2 (localhost.localdomain [127.0.0.1]) by mail79-tx2 (MessageSwitch) id 1292368745201950_10524; Tue, 14 Dec 2010 23:19:05 +0000 (UTC) Received: from TX2EHSMHS017.bigfish.com (unknown [10.9.14.245]) by mail79-tx2.bigfish.com (Postfix) with ESMTP id 2D56917D0054 for ; Tue, 14 Dec 2010 23:19:05 +0000 (UTC) Received: from az33egw01.freescale.net (192.88.158.102) by TX2EHSMHS017.bigfish.com (10.9.99.117) with Microsoft SMTP Server (TLS) id 14.1.225.8; Tue, 14 Dec 2010 23:19:04 +0000 Received: from az33smr01.freescale.net (az33smr01.freescale.net [10.64.34.199]) by az33egw01.freescale.net (8.14.3/8.14.3) with ESMTP id oBENIrWF005195 for ; Tue, 14 Dec 2010 16:19:03 -0700 (MST) Received: from efes.am.freescale.net (efes.am.freescale.net [10.82.123.3]) by az33smr01.freescale.net (8.13.1/8.13.0) with ESMTP id oBENIqRV010566; Tue, 14 Dec 2010 17:18:52 -0600 (CST) From: Timur Tabi To: , Date: Tue, 14 Dec 2010 17:18:51 -0600 Message-ID: <1292368731-3819-1-git-send-email-timur@freescale.com> X-Mailer: git-send-email 1.7.2.3 MIME-Version: 1.0 X-OriginatorOrg: freescale.com Subject: [U-Boot] [PATCH] powerpc: fix register usage in some inline assembly code 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: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de In some usages of inline assembly, hard-coded registers were specified when a scratch register should have been used instead. Signed-off-by: Timur Tabi --- I can't test the kgdb changes, but the rest appears to be okay. arch/powerpc/lib/kgdb.c | 25 +++++++++++++++---------- arch/powerpc/lib/time.c | 5 ++++- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/arch/powerpc/lib/kgdb.c b/arch/powerpc/lib/kgdb.c index 1ec6818..19a56db 100644 --- a/arch/powerpc/lib/kgdb.c +++ b/arch/powerpc/lib/kgdb.c @@ -12,11 +12,13 @@ void breakinst(void); int kgdb_setjmp(long *buf) { - asm ("mflr 0; stw 0,0(%0);" - "stw 1,4(%0); stw 2,8(%0);" - "mfcr 0; stw 0,12(%0);" - "stmw 13,16(%0)" - : : "r" (buf)); + unsigned long temp; + + asm volatile("mflr %0; stw %0,0(%1);" + "stw %%r1,4(%1); stw %%r2,8(%1);" + "mfcr %0; stw %0,12(%1);" + "stmw %%r13,16(%1)" + : "=&r"(temp) : "r" (buf)); /* XXX should save fp regs as well */ return 0; } @@ -24,13 +26,16 @@ kgdb_setjmp(long *buf) void kgdb_longjmp(long *buf, int val) { + unsigned long temp; + if (val == 0) val = 1; - asm ("lmw 13,16(%0);" - "lwz 0,12(%0); mtcrf 0x38,0;" - "lwz 0,0(%0); lwz 1,4(%0); lwz 2,8(%0);" - "mtlr 0; mr 3,%1" - : : "r" (buf), "r" (val)); + + asm volatile("lmw %%r13,16(%1);" + "lwz %0,12(%1); mtcrf 0x38,%0;" + "lwz %0,0(%1); lwz %%r1,4(%1); lwz %%r2,8(%1);" + "mtlr %0; mr %%r3,%2" + : "=&r"(temp) : "r" (buf), "r" (val)); } static inline unsigned long diff --git a/arch/powerpc/lib/time.c b/arch/powerpc/lib/time.c index 2909961..34633c3 100644 --- a/arch/powerpc/lib/time.c +++ b/arch/powerpc/lib/time.c @@ -78,6 +78,8 @@ unsigned long ticks2usec(unsigned long ticks) int init_timebase (void) { + unsigned long temp; + #if defined(CONFIG_5xx) || defined(CONFIG_8xx) volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR; @@ -86,7 +88,8 @@ int init_timebase (void) #endif /* reset */ - asm ("li 3,0 ; mttbu 3 ; mttbl 3 ;"); + asm volatile("li %0,0 ; mttbu %0 ; mttbl %0;" + : "=&r"(temp) ); #if defined(CONFIG_5xx) || defined(CONFIG_8xx) /* enable */