summaryrefslogtreecommitdiff
path: root/arch/arm/lib/memcpy.S
diff options
context:
space:
mode:
authorStefan Agner <stefan.agner@toradex.com>2014-11-18 19:22:55 +0100
committerStefan Agner <stefan.agner@toradex.com>2014-11-19 14:52:32 +0100
commitbc0ae16c20cb6bacb44f5c5b541840366a267f75 (patch)
tree5ecf7c42105308ea764cd4727359f5d2575356f8 /arch/arm/lib/memcpy.S
parent272736202997407d0d66375fcf95227c005f14ae (diff)
arm: make arch memset/memcpy to work with Thumb2 builds
Resynchronize memcpy/memset with kernel and build them explicitly in Thumb2 mode (unified syntax). Those assembler files can be built and linked in ARM mode too, however when calling them from Thumb2 built code, the stack got corrupted and the copy did not succeed (the exact details have not been traced back). Hoever, the Linux kernel builds those files in Thumb2 mode. Hence U-Boot should build them in Thumb2 mode too when CONFIG_SYS_THUMB_BUILD is set. Also add implicit-it=always to AFLAGS when building for Thumb2. Furthermore add no-warn-deprecated option to AFLAGS to rid of deprecated unified syntax: arch/arm/lib/memcpy.S: Assembler messages: arch/arm/lib/memcpy.S:153: Warning: conditional infixes are deprecated in unified syntax arch/arm/lib/memcpy.S:154: Warning: conditional infixes are deprecated in unified syntax ...
Diffstat (limited to 'arch/arm/lib/memcpy.S')
-rw-r--r--arch/arm/lib/memcpy.S75
1 files changed, 52 insertions, 23 deletions
diff --git a/arch/arm/lib/memcpy.S b/arch/arm/lib/memcpy.S
index f655256b5d..c9424baa51 100644
--- a/arch/arm/lib/memcpy.S
+++ b/arch/arm/lib/memcpy.S
@@ -10,9 +10,14 @@
* published by the Free Software Foundation.
*/
+#include <linux/linkage.h>
#include <asm/assembler.h>
+#ifdef CONFIG_SYS_THUMB_BUILD
+#define W(instr) instr.w
+#else
#define W(instr) instr
+#endif
#define LDR1W_SHIFT 0
#define STR1W_SHIFT 0
@@ -56,13 +61,16 @@
.text
/* Prototype: void *memcpy(void *dest, const void *src, size_t n); */
-
-.globl memcpy
-memcpy:
-
+#ifdef CONFIG_SYS_THUMB_BUILD
+ .syntax unified
+ .thumb
+ .thumb_func
+#endif
+ENTRY(memcpy)
+/*
cmp r0, r1
moveq pc, lr
-
+*/
enter r4, lr
subs r2, r2, #4
@@ -193,24 +201,24 @@ memcpy:
12: PLD( pld [r1, #124] )
13: ldr4w r1, r4, r5, r6, r7, abort=19f
- mov r3, lr, pull #\pull
+ mov r3, lr, lspull #\pull
subs r2, r2, #32
ldr4w r1, r8, r9, ip, lr, abort=19f
- orr r3, r3, r4, push #\push
- mov r4, r4, pull #\pull
- orr r4, r4, r5, push #\push
- mov r5, r5, pull #\pull
- orr r5, r5, r6, push #\push
- mov r6, r6, pull #\pull
- orr r6, r6, r7, push #\push
- mov r7, r7, pull #\pull
- orr r7, r7, r8, push #\push
- mov r8, r8, pull #\pull
- orr r8, r8, r9, push #\push
- mov r9, r9, pull #\pull
- orr r9, r9, ip, push #\push
- mov ip, ip, pull #\pull
- orr ip, ip, lr, push #\push
+ orr r3, r3, r4, lspush #\push
+ mov r4, r4, lspull #\pull
+ orr r4, r4, r5, lspush #\push
+ mov r5, r5, lspull #\pull
+ orr r5, r5, r6, lspush #\push
+ mov r6, r6, lspull #\pull
+ orr r6, r6, r7, lspush #\push
+ mov r7, r7, lspull #\pull
+ orr r7, r7, r8, lspush #\push
+ mov r8, r8, lspull #\pull
+ orr r8, r8, r9, lspush #\push
+ mov r9, r9, lspull #\pull
+ orr r9, r9, ip, lspush #\push
+ mov ip, ip, lspull #\pull
+ orr ip, ip, lr, lspush #\push
str8w r0, r3, r4, r5, r6, r7, r8, r9, ip, , abort=19f
bge 12b
PLD( cmn r2, #96 )
@@ -221,10 +229,10 @@ memcpy:
14: ands ip, r2, #28
beq 16f
-15: mov r3, lr, pull #\pull
+15: mov r3, lr, lspull #\pull
ldr1w r1, lr, abort=21f
subs ip, ip, #4
- orr r3, r3, lr, push #\push
+ orr r3, r3, lr, lspush #\push
str1w r0, r3, abort=21f
bgt 15b
CALGN( cmp r2, #0 )
@@ -241,3 +249,24 @@ memcpy:
17: forward_copy_shift pull=16 push=16
18: forward_copy_shift pull=24 push=8
+
+
+/*
+ * Abort preamble and completion macros.
+ * If a fixup handler is required then those macros must surround it.
+ * It is assumed that the fixup code will handle the private part of
+ * the exit macro.
+ */
+
+ .macro copy_abort_preamble
+19: ldmfd sp!, {r5 - r9}
+ b 21f
+20: ldmfd sp!, {r5 - r8}
+21:
+ .endm
+
+ .macro copy_abort_end
+ ldmfd sp!, {r4, pc}
+ .endm
+
+ENDPROC(memcpy)