2 * linux/arch/arm/lib/memcpy.S
4 * Author: Nicolas Pitre
5 * Created: Sep 28, 2005
6 * Copyright: MontaVista Software, Inc.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
19 .macro ldr1w ptr reg abort
20 W(ldr) \reg, [\ptr], #4
23 .macro ldr4w ptr reg1 reg2 reg3 reg4 abort
24 ldmia \ptr!, {\reg1, \reg2, \reg3, \reg4}
27 .macro ldr8w ptr reg1 reg2 reg3 reg4 reg5 reg6 reg7 reg8 abort
28 ldmia \ptr!, {\reg1, \reg2, \reg3, \reg4, \reg5, \reg6, \reg7, \reg8}
31 .macro ldr1b ptr reg cond=al abort
32 ldr\cond\()b \reg, [\ptr], #1
35 .macro str1w ptr reg abort
36 W(str) \reg, [\ptr], #4
39 .macro str8w ptr reg1 reg2 reg3 reg4 reg5 reg6 reg7 reg8 abort
40 stmia \ptr!, {\reg1, \reg2, \reg3, \reg4, \reg5, \reg6, \reg7, \reg8}
43 .macro str1b ptr reg cond=al abort
44 str\cond\()b \reg, [\ptr], #1
47 .macro enter reg1 reg2
48 stmdb sp!, {r0, \reg1, \reg2}
52 ldmfd sp!, {r0, \reg1, \reg2}
55 /* Prototype: void *memcpy(void *dest, const void *src, size_t n); */
73 CALGN( ands ip, r0, #31 )
74 CALGN( rsb r3, ip, #32 )
75 CALGN( sbcnes r4, r3, r2 ) @ C is always set here
78 CALGN( subs r2, r2, r3 ) @ C gets set
79 CALGN( add pc, r4, ip )
82 2: PLD( subs r2, r2, #96 )
88 3: PLD( pld [r1, #124] )
89 4: ldr8w r1, r3, r4, r5, r6, r7, r8, ip, lr, abort=20f
91 str8w r0, r3, r4, r5, r6, r7, r8, ip, lr, abort=20f
99 lsl ip, ip, #LDR1W_SHIFT
101 addne pc, pc, ip @ C is always clear here
104 .rept (1 << LDR1W_SHIFT)
107 ldr1w r1, r3, abort=20f
108 ldr1w r1, r4, abort=20f
109 ldr1w r1, r5, abort=20f
110 ldr1w r1, r6, abort=20f
111 ldr1w r1, r7, abort=20f
112 ldr1w r1, r8, abort=20f
113 ldr1w r1, lr, abort=20f
115 #if LDR1W_SHIFT < STR1W_SHIFT
116 lsl ip, ip, #STR1W_SHIFT - LDR1W_SHIFT
117 #elif LDR1W_SHIFT > STR1W_SHIFT
118 lsr ip, ip, #LDR1W_SHIFT - STR1W_SHIFT
122 .rept (1 << STR1W_SHIFT)
125 str1w r0, r3, abort=20f
126 str1w r0, r4, abort=20f
127 str1w r0, r5, abort=20f
128 str1w r0, r6, abort=20f
129 str1w r0, r7, abort=20f
130 str1w r0, r8, abort=20f
131 str1w r0, lr, abort=20f
135 7: ldmfd sp!, {r5 - r8}
137 8: movs r2, r2, lsl #31
138 ldr1b r1, r3, ne, abort=21f
139 ldr1b r1, r4, cs, abort=21f
140 ldr1b r1, ip, cs, abort=21f
141 str1b r0, r3, ne, abort=21f
142 str1b r0, r4, cs, abort=21f
143 str1b r0, ip, cs, abort=21f
149 ldr1b r1, r3, gt, abort=21f
150 ldr1b r1, r4, ge, abort=21f
151 ldr1b r1, lr, abort=21f
152 str1b r0, r3, gt, abort=21f
153 str1b r0, r4, ge, abort=21f
155 str1b r0, lr, abort=21f
162 ldr1w r1, lr, abort=21f
167 .macro forward_copy_shift pull push
172 CALGN( ands ip, r0, #31 )
173 CALGN( rsb ip, ip, #32 )
174 CALGN( sbcnes r4, ip, r2 ) @ C is always set here
175 CALGN( subcc r2, r2, ip )
178 11: stmfd sp!, {r5 - r9}
181 PLD( subs r2, r2, #96 )
187 12: PLD( pld [r1, #124] )
188 13: ldr4w r1, r4, r5, r6, r7, abort=19f
189 mov r3, lr, pull #\pull
191 ldr4w r1, r8, r9, ip, lr, abort=19f
192 orr r3, r3, r4, push #\push
193 mov r4, r4, pull #\pull
194 orr r4, r4, r5, push #\push
195 mov r5, r5, pull #\pull
196 orr r5, r5, r6, push #\push
197 mov r6, r6, pull #\pull
198 orr r6, r6, r7, push #\push
199 mov r7, r7, pull #\pull
200 orr r7, r7, r8, push #\push
201 mov r8, r8, pull #\pull
202 orr r8, r8, r9, push #\push
203 mov r9, r9, pull #\pull
204 orr r9, r9, ip, push #\push
205 mov ip, ip, pull #\pull
206 orr ip, ip, lr, push #\push
207 str8w r0, r3, r4, r5, r6, r7, r8, r9, ip, , abort=19f
217 15: mov r3, lr, pull #\pull
218 ldr1w r1, lr, abort=21f
220 orr r3, r3, lr, push #\push
221 str1w r0, r3, abort=21f
226 16: sub r1, r1, #(\push / 8)
232 forward_copy_shift pull=8 push=24
234 17: forward_copy_shift pull=16 push=16
236 18: forward_copy_shift pull=24 push=8