Received: from list by lists.gnu.org with archive (Exim 4.71) id 1VhhcU-0006Hs-7f for mharc-grub-devel@gnu.org; Sat, 16 Nov 2013 10:17:10 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51742) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VhhcM-0006EE-On for grub-devel@gnu.org; Sat, 16 Nov 2013 10:17:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VhhcG-0003vC-8Q for grub-devel@gnu.org; Sat, 16 Nov 2013 10:17:02 -0500 Received: from mail-wg0-f53.google.com ([74.125.82.53]:51503) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VhhcG-0003v3-2d for grub-devel@gnu.org; Sat, 16 Nov 2013 10:16:56 -0500 Received: by mail-wg0-f53.google.com with SMTP id b13so4652808wgh.20 for ; Sat, 16 Nov 2013 07:16:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-type:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=DR1fx6oOgbdO2/k7bEhXp28ny9boeoCO0GYrnt2q290=; b=I7kUJlOf711+zcaFfhgXl9fZWkqWk8CxcxhwGJIp9ltcX+FZIPaLs4uJbN8mArsAzf c+4DzCbuAzEQ1pzAcTUbhzE5QnTRmUHA+7OjupuOL+TD2lFu1ODt/TAZ90R9un+LN3By a825WcRHoEqRtCQTprFSDO7ldEn2I/W6mVMiW6gt1thlzP0A2/mROqXme/OBIBQ3wRh0 OHlw3VXusqkyhpMvcvlUXy0NgxvboJxDRTLkgOtKxtJJgtq22Y5YfMlfQ5GCajG+KK7D LmgIJA47UQRnS2zKCIyQsldKElUJ8QnTS+17p77eAvjytcdKp2aMSwhP7T19Koxp98sa dI0A== X-Gm-Message-State: ALoCoQkqQbxrqZNr1djFNe21coyJdiap+MJ/Sv7Kzn4ZcwR7bd4c7OdqwlespPI0zUFFOdBUuYA+ X-Received: by 10.180.219.33 with SMTP id pl1mr11062762wic.49.1384615015200; Sat, 16 Nov 2013 07:16:55 -0800 (PST) Received: from rocoto.smurfnet.nu ([2001:4b98:dc0:41:216:3eff:fea7:75f3]) by mx.google.com with ESMTPSA id i8sm5769531wiy.6.2013.11.16.07.16.53 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 16 Nov 2013 07:16:54 -0800 (PST) Date: Sat, 16 Nov 2013 16:17:07 +0100 From: Leif Lindholm To: The development of GNU GRUB Subject: Re: [PATCH] Compile asm-files to thumb2 Message-ID: <20131116151707.GI30374@rocoto.smurfnet.nu> References: <52847E33.2020901@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <52847E33.2020901@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 74.125.82.53 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 Nov 2013 15:17:08 -0000 Hi Vladimir, The code looks/appears correct - a few comments inline. On Thu, Nov 14, 2013 at 08:39:31AM +0100, Vladimir 'φ-coder/phcoder' Serbinenko wrote: > diff --git a/grub-core/kern/arm/cache.S b/grub-core/kern/arm/cache.S > index 8522d24..2ad774d 100644 > --- a/grub-core/kern/arm/cache.S > +++ b/grub-core/kern/arm/cache.S > @@ -21,7 +21,12 @@ > .file "cache.S" > .text > .syntax unified > +#if !defined (__thumb2__) || !defined (ARMV7) > .arm > +#else > + .thumb > +#endif > + > #if !defined (ARMV6) && !defined (ARMV7) > # error Unsupported architecture version! > #endif > diff --git a/grub-core/kern/arm/cache_armv7.S b/grub-core/kern/arm/cache_armv7.S > index 0c16b10..aa42fad 100644 > --- a/grub-core/kern/arm/cache_armv7.S > +++ b/grub-core/kern/arm/cache_armv7.S > @@ -21,8 +21,13 @@ > .file "cache_armv7.S" > .text > .syntax unified > - .arm > +#if !defined (__thumb2__) > .arch armv7a > + .arm > +#else > + .arch armv7 > + .thumb > +#endif I think ".arch armv7a" could be moved outside of the #if statement, and the ".arch armv7" could be dropped. > # define DMB dmb > # define DSB dsb > # define ISB isb > @@ -58,11 +63,17 @@ clean_invalidate_dcache: > @ read current cache information > mrc p15, 1, r8, c0, c0, 0 @ Read CCSIDR > lsr r3, r8, #13 @ Number of sets -1 > - ldr r9, =0x3fff > - and r3, r3, r9 > + > + @ Keep only 14 bits of r3 > + lsl r3, r3, #18 > + lsr r3, r3, #18 > + > lsr r4, r8, #3 @ Number of ways -1 > - ldr r9, =0x1ff > - and r4, r4, r9 > + > + @ Keep only 9 bits of r4 > + lsl r4, r4, #23 > + lsr r4, r4, #23 > + > and r7, r8, #7 @ log2(line size in words) - 2 > add r7, r7, #2 @ adjust > mov r8, #1 > diff --git a/grub-core/lib/arm/setjmp.S b/grub-core/lib/arm/setjmp.S > index 4f15679..b6febfb 100644 > --- a/grub-core/lib/arm/setjmp.S > +++ b/grub-core/lib/arm/setjmp.S > @@ -24,7 +24,11 @@ > GRUB_MOD_LICENSE "GPLv3+" > > .syntax unified > +#if !defined (__thumb2__) > .arm > +#else > + .thumb > +#endif > > .text > > @@ -32,7 +36,8 @@ GRUB_MOD_LICENSE "GPLv3+" > * int grub_setjmp (grub_jmp_buf env) > */ > FUNCTION(grub_setjmp) > - stm r0, { r4-r11, sp, lr } > + stm r0, { r4-r11, lr } > + str sp, [r0, #36 ] I would lean towards writing this as mov r12, sp stm r0, { r4-r12, lr } just to skip the manual arithmetic. > mov r0, #0 > bx lr > > @@ -40,7 +45,10 @@ FUNCTION(grub_setjmp) > * int grub_longjmp (grub_jmp_buf env, int val) > */ > FUNCTION(grub_longjmp) > - ldm r0, { r4-r11, sp, lr } > + ldm r0, { r4-r11, lr } > + ldr sp, [r0, #36 ] Same here: ldm r0, { r4-r12, lr } mov sp, r12 > movs r0, r1 > - moveq r0, #1 > + bne 1f > + mov r0, #1 > +1: Alternatively we could (because we have .syntax unified) use it eq moveq r0, #1 > bx lr > / Leif