* [RFT] Use pair of shifts instead of and in ARM code
@ 2013-11-13 0:00 Vladimir 'φ-coder/phcoder' Serbinenko
2013-11-13 14:16 ` Leif Lindholm
0 siblings, 1 reply; 3+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2013-11-13 0:00 UTC (permalink / raw)
To: The development of GRUB 2
[-- Attachment #1: Type: text/plain, Size: 1041 bytes --]
1ff and 3fff can't be easily loaded on ARM. This patch replaces load+and
with pair of shift to keep only wanted bits.
diff --git a/grub-core/kern/arm/cache_armv7.S
b/grub-core/kern/arm/cache_armv7.S
index 0c16b10..454bad3 100644
--- a/grub-core/kern/arm/cache_armv7.S
+++ b/grub-core/kern/arm/cache_armv7.S
@@ -58,11 +64,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
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 291 bytes --]
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [RFT] Use pair of shifts instead of and in ARM code
2013-11-13 0:00 [RFT] Use pair of shifts instead of and in ARM code Vladimir 'φ-coder/phcoder' Serbinenko
@ 2013-11-13 14:16 ` Leif Lindholm
2013-11-13 14:56 ` Vladimir 'φ-coder/phcoder' Serbinenko
0 siblings, 1 reply; 3+ messages in thread
From: Leif Lindholm @ 2013-11-13 14:16 UTC (permalink / raw)
To: The development of GNU GRUB
On Wed, Nov 13, 2013 at 01:00:17AM +0100, Vladimir 'φ-coder/phcoder' Serbinenko wrote:
> 1ff and 3fff can't be easily loaded on ARM. This patch replaces load+and
> with pair of shift to keep only wanted bits.
Actually, on ARMv7 we could just use MOVW instead:
> diff --git a/grub-core/kern/arm/cache_armv7.S
> b/grub-core/kern/arm/cache_armv7.S
> index 0c16b10..454bad3 100644
> --- a/grub-core/kern/arm/cache_armv7.S
> +++ b/grub-core/kern/arm/cache_armv7.S
> @@ -58,11 +64,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
movw 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
movw 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
>
/
Leif
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFT] Use pair of shifts instead of and in ARM code
2013-11-13 14:16 ` Leif Lindholm
@ 2013-11-13 14:56 ` Vladimir 'φ-coder/phcoder' Serbinenko
0 siblings, 0 replies; 3+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2013-11-13 14:56 UTC (permalink / raw)
To: grub-devel
[-- Attachment #1: Type: text/plain, Size: 1858 bytes --]
On 13.11.2013 15:16, Leif Lindholm wrote:
> On Wed, Nov 13, 2013 at 01:00:17AM +0100, Vladimir 'φ-coder/phcoder' Serbinenko wrote:
>> 1ff and 3fff can't be easily loaded on ARM. This patch replaces load+and
>> with pair of shift to keep only wanted bits.
>
> Actually, on ARMv7 we could just use MOVW instead:
>
Another goal of this patch was to make this code compilable with clang
(just a silly experiment) which lacks many useful ARM facilities
including architecture switching in file (other than thumb<->arm). This
was one of culprits. The other one was that I had to manually assemble
barrier instructions.
>> diff --git a/grub-core/kern/arm/cache_armv7.S
>> b/grub-core/kern/arm/cache_armv7.S
>> index 0c16b10..454bad3 100644
>> --- a/grub-core/kern/arm/cache_armv7.S
>> +++ b/grub-core/kern/arm/cache_armv7.S
>> @@ -58,11 +64,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
> movw 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
> movw 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
>>
>
> /
> Leif
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 291 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-11-13 14:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-13 0:00 [RFT] Use pair of shifts instead of and in ARM code Vladimir 'φ-coder/phcoder' Serbinenko
2013-11-13 14:16 ` Leif Lindholm
2013-11-13 14:56 ` Vladimir 'φ-coder/phcoder' Serbinenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).