1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20src .req r0
21dst .req r1
22len .req r2
23sum .req r3
24
25.Lzero: mov r0, sum
26 load_regs
27
28
29
30
31
32
33
34.Ldst_unaligned:
35 tst dst,
36 beq .Ldst_16bit
37
38 load1b ip
39 sub len, len,
40 adcs sum, sum, ip, put_byte_1 @ update checksum
41 strb ip, [dst],
42 tst dst,
43 moveq pc, lr @ dst is now 32bit aligned
44
45.Ldst_16bit: load2b r8, ip
46 sub len, len,
47 adcs sum, sum, r8, put_byte_0
48 strb r8, [dst],
49 adcs sum, sum, ip, put_byte_1
50 strb ip, [dst],
51 mov pc, lr @ dst is now 32bit aligned
52
53
54
55
56
57.Lless8: teq len,
58 beq .Lzero
59
60
61 tst dst,
62 beq .Lless8_aligned
63
64
65 load1b ip
66 sub len, len,
67 adcs sum, sum, ip, put_byte_1 @ update checksum
68 strb ip, [dst],
69 tst len,
70 beq .Lless8_byteonly
71
721: load2b r8, ip
73 sub len, len,
74 adcs sum, sum, r8, put_byte_0
75 strb r8, [dst],
76 adcs sum, sum, ip, put_byte_1
77 strb ip, [dst],
78.Lless8_aligned:
79 tst len,
80 bne 1b
81.Lless8_byteonly:
82 tst len,
83 beq .Ldone
84 load1b r8
85 adcs sum, sum, r8, put_byte_0 @ update checksum
86 strb r8, [dst],
87 b .Ldone
88
89FN_ENTRY
90 save_regs
91
92 cmp len,
93 blo .Lless8 @ 8 bytes to copy.
94
95 adds sum, sum,
96 tst dst,
97 blne .Ldst_unaligned @ align destination, return here
98
99
100
101
102
103
104
105 tst src,
106 bne .Lsrc_not_aligned
107
108
109
110 bics ip, len,
111 beq 2f
112
1131: load4l r4, r5, r6, r7
114 stmia dst!, {r4, r5, r6, r7}
115 adcs sum, sum, r4
116 adcs sum, sum, r5
117 adcs sum, sum, r6
118 adcs sum, sum, r7
119 sub ip, ip,
120 teq ip,
121 bne 1b
122
1232: ands ip, len,
124 beq 4f
125 tst ip,
126 beq 3f
127 load2l r4, r5
128 stmia dst!, {r4, r5}
129 adcs sum, sum, r4
130 adcs sum, sum, r5
131 tst ip,
132 beq 4f
133
1343: load1l r4
135 str r4, [dst],
136 adcs sum, sum, r4
137
1384: ands len, len,
139 beq .Ldone
140 load1l r4
141 tst len,
142 mov r5, r4, get_byte_0
143 beq .Lexit
144 adcs sum, sum, r4, push
145 strb r5, [dst],
146 mov r5, r4, get_byte_1
147 strb r5, [dst],
148 mov r5, r4, get_byte_2
149.Lexit: tst len,
150 strneb r5, [dst],
151 andne r5, r5,
152 adcnes sum, sum, r5, put_byte_0
153
154
155
156
157
158
159
160.Ldone: adc r0, sum,
161 ldr sum, [sp,
162 tst sum,
163 movne r0, r0, ror
164 load_regs
165
166.Lsrc_not_aligned:
167 adc sum, sum,
168 and ip, src,
169 bic src, src,
170 load1l r5
171 cmp ip,
172 beq .Lsrc2_aligned
173 bhi .Lsrc3_aligned
174 mov r4, r5, pull
175 bics ip, len,
176 beq 2f
1771: load4l r5, r6, r7, r8
178 orr r4, r4, r5, push
179 mov r5, r5, pull
180 orr r5, r5, r6, push
181 mov r6, r6, pull
182 orr r6, r6, r7, push
183 mov r7, r7, pull
184 orr r7, r7, r8, push
185 stmia dst!, {r4, r5, r6, r7}
186 adcs sum, sum, r4
187 adcs sum, sum, r5
188 adcs sum, sum, r6
189 adcs sum, sum, r7
190 mov r4, r8, pull
191 sub ip, ip,
192 teq ip,
193 bne 1b
1942: ands ip, len,
195 beq 4f
196 tst ip,
197 beq 3f
198 load2l r5, r6
199 orr r4, r4, r5, push
200 mov r5, r5, pull
201 orr r5, r5, r6, push
202 stmia dst!, {r4, r5}
203 adcs sum, sum, r4
204 adcs sum, sum, r5
205 mov r4, r6, pull
206 tst ip,
207 beq 4f
2083: load1l r5
209 orr r4, r4, r5, push
210 str r4, [dst],
211 adcs sum, sum, r4
212 mov r4, r5, pull
2134: ands len, len,
214 beq .Ldone
215 mov r5, r4, get_byte_0
216 tst len,
217 beq .Lexit
218 adcs sum, sum, r4, push
219 strb r5, [dst],
220 mov r5, r4, get_byte_1
221 strb r5, [dst],
222 mov r5, r4, get_byte_2
223 b .Lexit
224
225.Lsrc2_aligned: mov r4, r5, pull
226 adds sum, sum,
227 bics ip, len,
228 beq 2f
2291: load4l r5, r6, r7, r8
230 orr r4, r4, r5, push
231 mov r5, r5, pull
232 orr r5, r5, r6, push
233 mov r6, r6, pull
234 orr r6, r6, r7, push
235 mov r7, r7, pull
236 orr r7, r7, r8, push
237 stmia dst!, {r4, r5, r6, r7}
238 adcs sum, sum, r4
239 adcs sum, sum, r5
240 adcs sum, sum, r6
241 adcs sum, sum, r7
242 mov r4, r8, pull
243 sub ip, ip,
244 teq ip,
245 bne 1b
2462: ands ip, len,
247 beq 4f
248 tst ip,
249 beq 3f
250 load2l r5, r6
251 orr r4, r4, r5, push
252 mov r5, r5, pull
253 orr r5, r5, r6, push
254 stmia dst!, {r4, r5}
255 adcs sum, sum, r4
256 adcs sum, sum, r5
257 mov r4, r6, pull
258 tst ip,
259 beq 4f
2603: load1l r5
261 orr r4, r4, r5, push
262 str r4, [dst],
263 adcs sum, sum, r4
264 mov r4, r5, pull
2654: ands len, len,
266 beq .Ldone
267 mov r5, r4, get_byte_0
268 tst len,
269 beq .Lexit
270 adcs sum, sum, r4
271 strb r5, [dst],
272 mov r5, r4, get_byte_1
273 strb r5, [dst],
274 tst len,
275 beq .Ldone
276 load1b r5
277 b .Lexit
278
279.Lsrc3_aligned: mov r4, r5, pull
280 adds sum, sum,
281 bics ip, len,
282 beq 2f
2831: load4l r5, r6, r7, r8
284 orr r4, r4, r5, push
285 mov r5, r5, pull
286 orr r5, r5, r6, push
287 mov r6, r6, pull
288 orr r6, r6, r7, push
289 mov r7, r7, pull
290 orr r7, r7, r8, push
291 stmia dst!, {r4, r5, r6, r7}
292 adcs sum, sum, r4
293 adcs sum, sum, r5
294 adcs sum, sum, r6
295 adcs sum, sum, r7
296 mov r4, r8, pull
297 sub ip, ip,
298 teq ip,
299 bne 1b
3002: ands ip, len,
301 beq 4f
302 tst ip,
303 beq 3f
304 load2l r5, r6
305 orr r4, r4, r5, push
306 mov r5, r5, pull
307 orr r5, r5, r6, push
308 stmia dst!, {r4, r5}
309 adcs sum, sum, r4
310 adcs sum, sum, r5
311 mov r4, r6, pull
312 tst ip,
313 beq 4f
3143: load1l r5
315 orr r4, r4, r5, push
316 str r4, [dst],
317 adcs sum, sum, r4
318 mov r4, r5, pull
3194: ands len, len,
320 beq .Ldone
321 mov r5, r4, get_byte_0
322 tst len,
323 beq .Lexit
324 strb r5, [dst],
325 adcs sum, sum, r4
326 load1l r4
327 mov r5, r4, get_byte_0
328 strb r5, [dst],
329 adcs sum, sum, r4, push
330 mov r5, r4, get_byte_1
331 b .Lexit
332FN_EXIT
333