Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1b654b23 authored by Ard Biesheuvel's avatar Ard Biesheuvel Committed by Eric Biggers
Browse files

BACKPORT: ARM: 9039/1: assembler: generalize byte swapping macro into rev_l



Take the 4 instruction byte swapping sequence from the decompressor's
head.S, and turn it into a rev_l GAS macro for general use. While
at it, make it use the 'rev' instruction when compiling for v6 or
later.

Reviewed-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
Tested-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: default avatarNicolas Pitre <nico@fluxnic.net>
Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>

(cherry picked from commit 6468e898c67b905ec0f95d9678929135bcaf7f67)
(resolved conflict due to different patch context, caused by missing
 other macros in assembler.h)
Bug: 178411248
Change-Id: I8433e97d2880f75cace215f1a8daadec7f29929c
Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
parent 6f5e7693
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -117,10 +117,7 @@
		.macro	be32tocpu, val, tmp
#ifndef __ARMEB__
		/* convert to little endian */
		eor	\tmp, \val, \val, ror #16
		bic	\tmp, \tmp, #0x00ff0000
		mov	\val, \val, ror #8
		eor	\val, \val, \tmp, lsr #8
		rev_l	\val, \tmp
#endif
		.endm

+17 −0
Original line number Diff line number Diff line
@@ -506,4 +506,21 @@ THUMB( orr \reg , \reg , #PSR_T_BIT )
#define _ASM_NOKPROBE(entry)
#endif

	/*
	 * rev_l - byte-swap a 32-bit value
	 *
	 * @val: source/destination register
	 * @tmp: scratch register
	 */
	.macro		rev_l, val:req, tmp:req
	.if		__LINUX_ARM_ARCH__ < 6
	eor		\tmp, \val, \val, ror #16
	bic		\tmp, \tmp, #0x00ff0000
	mov		\val, \val, ror #8
	eor		\val, \val, \tmp, lsr #8
	.else
	rev		\val, \val
	.endif
	.endm

#endif /* __ASM_ASSEMBLER_H__ */