]> git.baikalelectronics.ru Git - kernel.git/commitdiff
ARM: 9035/1: uncompress: Add be32tocpu macro
authorGeert Uytterhoeven <geert+renesas@glider.be>
Fri, 4 Dec 2020 09:37:47 +0000 (10:37 +0100)
committerRussell King <rmk+kernel@armlinux.org.uk>
Mon, 21 Dec 2020 11:19:20 +0000 (11:19 +0000)
DTB stores all values as 32-bit big-endian integers.
Add a macro to convert such values to native CPU endianness, to reduce
duplication.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Nicolas Pitre <nico@fluxnic.net>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
arch/arm/boot/compressed/head.S

index 2e04ec5b54469b661187ff4c0619c24992e26b79..14d1995106c28e3f35525f2bb4c0d30addcedf62 100644 (file)
                orr     \res, \res, \tmp1, lsl #24
                .endm
 
+               .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
+#endif
+               .endm
+
                .section ".start", "ax"
 /*
  * sort out different calling conventions
@@ -345,13 +355,7 @@ restart:   adr     r0, LC1
 
                /* Get the initial DTB size */
                ldr     r5, [r6, #4]
-#ifndef __ARMEB__
-               /* convert to little endian */
-               eor     r1, r5, r5, ror #16
-               bic     r1, r1, #0x00ff0000
-               mov     r5, r5, ror #8
-               eor     r5, r5, r1, lsr #8
-#endif
+               be32tocpu r5, r1
                dbgadtb r6, r5
                /* 50% DTB growth should be good enough */
                add     r5, r5, r5, lsr #1
@@ -403,13 +407,7 @@ restart:   adr     r0, LC1
 
                /* Get the current DTB size */
                ldr     r5, [r6, #4]
-#ifndef __ARMEB__
-               /* convert r5 (dtb size) to little endian */
-               eor     r1, r5, r5, ror #16
-               bic     r1, r1, #0x00ff0000
-               mov     r5, r5, ror #8
-               eor     r5, r5, r1, lsr #8
-#endif
+               be32tocpu r5, r1
 
                /* preserve 64-bit alignment */
                add     r5, r5, #7