1
2
3
4
5
6
7
8
9
10
11
12
13#include <linux/errno.h>
14#include <linux/linkage.h>
15#include <asm/asmmacro.h>
16#include <asm/core.h>
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33#define ONES_ADD(sum, val) \
34 add sum, sum, val ; \
35 bgeu sum, val, 99f ; \
36 addi sum, sum, 1 ; \
3799: ;
38
39.text
40ENTRY(csum_partial)
41
42
43
44
45
46 abi_entry_default
47 extui a5, a2, 0, 2
48 bnez a5, 8f
49
501:
51 srli a5, a3, 5
52
53 loopgtz a5, 2f
54#else
55 beqz a5, 2f
56 slli a5, a5, 5
57 add a5, a5, a2
58.Loop1:
59#endif
60 l32i a6, a2, 0
61 l32i a7, a2, 4
62 ONES_ADD(a4, a6)
63 ONES_ADD(a4, a7)
64 l32i a6, a2, 8
65 l32i a7, a2, 12
66 ONES_ADD(a4, a6)
67 ONES_ADD(a4, a7)
68 l32i a6, a2, 16
69 l32i a7, a2, 20
70 ONES_ADD(a4, a6)
71 ONES_ADD(a4, a7)
72 l32i a6, a2, 24
73 l32i a7, a2, 28
74 ONES_ADD(a4, a6)
75 ONES_ADD(a4, a7)
76 addi a2, a2, 4*8
77
78 blt a2, a5, .Loop1
79#endif
802:
81 extui a5, a3, 2, 3
82
83 loopgtz a5, 3f
84#else
85 beqz a5, 3f
86 slli a5, a5, 2
87 add a5, a5, a2
88.Loop2:
89#endif
90 l32i a6, a2, 0
91 ONES_ADD(a4, a6)
92 addi a2, a2, 4
93
94 blt a2, a5, .Loop2
95#endif
963:
97 _bbci.l a3, 1, 5f
98 l16ui a6, a2, 0
99 ONES_ADD(a4, a6)
100 addi a2, a2, 2
1015:
102 _bbci.l a3, 0, 7f
1036: l8ui a6, a2, 0
104#ifdef __XTENSA_EB__
105 slli a6, a6, 8
106#endif
107 ONES_ADD(a4, a6)
1087:
109 mov a2, a4
110 abi_ret_default
111
112
1138:
114 beqz a3, 7b
115 beqi a3, 1, 6b
116
117 extui a5, a2, 0, 1
118 bnez a5, 8f
119
120 l16ui a6, a2, 0
121 ONES_ADD(a4, a6)
122 addi a2, a2, 2
123 addi a3, a3, -2
124 j 1b
125
126
127
128
129
1308:
131 srli a5, a3, 2
132
133 loopgtz a5, 2f
134#else
135 beqz a5, 2f
136 slli a5, a5, 2
137 add a5, a5, a2
138.Loop3:
139#endif
140 l8ui a6, a2, 0
141 l16ui a7, a2, 1
142 l8ui a8, a2, 3
143#ifdef __XTENSA_EB__
144 slli a6, a6, 24
145#else
146 slli a8, a8, 24
147#endif
148 slli a7, a7, 8
149 or a7, a7, a6
150 or a7, a7, a8
151 ONES_ADD(a4, a7)
152 addi a2, a2, 4
153
154 blt a2, a5, .Loop3
155#endif
1562:
157 _bbci.l a3, 1, 3f
158 l8ui a6, a2, 0
159 l8ui a7, a2, 1
160#ifdef __XTENSA_EB__
161 slli a6, a6, 8
162#else
163 slli a7, a7, 8
164#endif
165 or a7, a7, a6
166 ONES_ADD(a4, a7)
167 addi a2, a2, 2
1683:
169 j 5b
170
171ENDPROC(csum_partial)
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191ENTRY(csum_partial_copy_generic)
192
193 abi_entry_default
194 movi a5, -1
195 or a10, a2, a3
196
197
198
199
200
201
202
203
204 extui a9, a10, 0, 2
205 beqz a9, 1f
206 bbsi.l a10, 0, 5f
207 j 3f
208
209
210
211
2121:
213
214 srli a10, a4, 5
215
216 loopgtz a10, 2f
217#else
218 beqz a10, 2f
219 slli a10, a10, 5
220 add a10, a10, a2
221.Loop5:
222#endif
223EX(10f) l32i a9, a2, 0
224EX(10f) l32i a8, a2, 4
225EX(10f) s32i a9, a3, 0
226EX(10f) s32i a8, a3, 4
227 ONES_ADD(a5, a9)
228 ONES_ADD(a5, a8)
229EX(10f) l32i a9, a2, 8
230EX(10f) l32i a8, a2, 12
231EX(10f) s32i a9, a3, 8
232EX(10f) s32i a8, a3, 12
233 ONES_ADD(a5, a9)
234 ONES_ADD(a5, a8)
235EX(10f) l32i a9, a2, 16
236EX(10f) l32i a8, a2, 20
237EX(10f) s32i a9, a3, 16
238EX(10f) s32i a8, a3, 20
239 ONES_ADD(a5, a9)
240 ONES_ADD(a5, a8)
241EX(10f) l32i a9, a2, 24
242EX(10f) l32i a8, a2, 28
243EX(10f) s32i a9, a3, 24
244EX(10f) s32i a8, a3, 28
245 ONES_ADD(a5, a9)
246 ONES_ADD(a5, a8)
247 addi a2, a2, 32
248 addi a3, a3, 32
249
250 blt a2, a10, .Loop5
251#endif
2522:
253 extui a10, a4, 2, 3
254 extui a4, a4, 0, 2
255
256 loopgtz a10, 3f
257#else
258 beqz a10, 3f
259 slli a10, a10, 2
260 add a10, a10, a2
261.Loop6:
262#endif
263EX(10f) l32i a9, a2, 0
264EX(10f) s32i a9, a3, 0
265 ONES_ADD(a5, a9)
266 addi a2, a2, 4
267 addi a3, a3, 4
268
269 blt a2, a10, .Loop6
270#endif
2713:
272
273
274
275
276
277
278
279
280
281
282
283
284
285 srli a10, a4, 1
286
287 loopgtz a10, 4f
288#else
289 beqz a10, 4f
290 slli a10, a10, 1
291 add a10, a10, a2
292.Loop7:
293#endif
294EX(10f) l16ui a9, a2, 0
295EX(10f) s16i a9, a3, 0
296 ONES_ADD(a5, a9)
297 addi a2, a2, 2
298 addi a3, a3, 2
299
300 blt a2, a10, .Loop7
301#endif
3024:
303
304 _bbci.l a4, 0, 8f
305EX(10f) l8ui a9, a2, 0
306EX(10f) s8i a9, a3, 0
307#ifdef __XTENSA_EB__
308 slli a9, a9, 8
309#endif
310 ONES_ADD(a5, a9)
3118:
312 mov a2, a5
313 abi_ret_default
314
3155:
316
317
318
319
320 srli a10, a4, 1
321
322 loopgtz a10, 6f
323#else
324 beqz a10, 6f
325 slli a10, a10, 1
326 add a10, a10, a2
327.Loop8:
328#endif
329EX(10f) l8ui a9, a2, 0
330EX(10f) l8ui a8, a2, 1
331EX(10f) s8i a9, a3, 0
332EX(10f) s8i a8, a3, 1
333#ifdef __XTENSA_EB__
334 slli a9, a9, 8
335#else
336 slli a8, a8, 8
337#endif
338 or a9, a9, a8
339 ONES_ADD(a5, a9)
340 addi a2, a2, 2
341 addi a3, a3, 2
342
343 blt a2, a10, .Loop8
344#endif
3456:
346 j 4b
347
348ENDPROC(csum_partial_copy_generic)
349
350
351
352.section .fixup, "ax"
35310:
354 movi a2, 0
355 abi_ret_default
356
357.previous
358