hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/arch/sh/lib/checksum.S
....@@ -1,4 +1,6 @@
1
-/* $Id: checksum.S,v 1.10 2001/07/06 13:11:32 gniibe Exp $
1
+/* SPDX-License-Identifier: GPL-2.0+
2
+ *
3
+ * $Id: checksum.S,v 1.10 2001/07/06 13:11:32 gniibe Exp $
24 *
35 * INET An implementation of the TCP/IP protocol suite for the LINUX
46 * operating system. INET is implemented using the BSD Socket
....@@ -21,11 +23,6 @@
2123 * converted to pure assembler
2224 *
2325 * SuperH version: Copyright (C) 1999 Niibe Yutaka
24
- *
25
- * This program is free software; you can redistribute it and/or
26
- * modify it under the terms of the GNU General Public License
27
- * as published by the Free Software Foundation; either version
28
- * 2 of the License, or (at your option) any later version.
2926 */
3027
3128 #include <asm/errno.h>
....@@ -176,47 +173,27 @@
176173 mov r6, r0
177174
178175 /*
179
-unsigned int csum_partial_copy_generic (const char *src, char *dst, int len,
180
- int sum, int *src_err_ptr, int *dst_err_ptr)
176
+unsigned int csum_partial_copy_generic (const char *src, char *dst, int len)
181177 */
182178
183179 /*
184
- * Copy from ds while checksumming, otherwise like csum_partial
185
- *
186
- * The macros SRC and DST specify the type of access for the instruction.
187
- * thus we can call a custom exception handler for all access types.
188
- *
189
- * FIXME: could someone double-check whether I haven't mixed up some SRC and
190
- * DST definitions? It's damn hard to trigger all cases. I hope I got
191
- * them all but there's no guarantee.
180
+ * Copy from ds while checksumming, otherwise like csum_partial with initial
181
+ * sum being ~0U
192182 */
193183
194
-#define SRC(...) \
184
+#define EXC(...) \
195185 9999: __VA_ARGS__ ; \
196186 .section __ex_table, "a"; \
197187 .long 9999b, 6001f ; \
198
- .previous
199
-
200
-#define DST(...) \
201
- 9999: __VA_ARGS__ ; \
202
- .section __ex_table, "a"; \
203
- .long 9999b, 6002f ; \
204188 .previous
205189
206190 !
207191 ! r4: const char *SRC
208192 ! r5: char *DST
209193 ! r6: int LEN
210
-! r7: int SUM
211
-!
212
-! on stack:
213
-! int *SRC_ERR_PTR
214
-! int *DST_ERR_PTR
215194 !
216195 ENTRY(csum_partial_copy_generic)
217
- mov.l r5,@-r15
218
- mov.l r6,@-r15
219
-
196
+ mov #-1,r7
220197 mov #3,r0 ! Check src and dest are equally aligned
221198 mov r4,r1
222199 and r0,r1
....@@ -246,11 +223,11 @@
246223 clrt
247224 .align 2
248225 5:
249
-SRC( mov.b @r4+,r1 )
250
-SRC( mov.b @r4+,r0 )
226
+EXC( mov.b @r4+,r1 )
227
+EXC( mov.b @r4+,r0 )
251228 extu.b r1,r1
252
-DST( mov.b r1,@r5 )
253
-DST( mov.b r0,@(1,r5) )
229
+EXC( mov.b r1,@r5 )
230
+EXC( mov.b r0,@(1,r5) )
254231 extu.b r0,r0
255232 add #2,r5
256233
....@@ -279,8 +256,8 @@
279256 ! Handle first two bytes as a special case
280257 .align 2
281258 1:
282
-SRC( mov.w @r4+,r0 )
283
-DST( mov.w r0,@r5 )
259
+EXC( mov.w @r4+,r0 )
260
+EXC( mov.w r0,@r5 )
284261 add #2,r5
285262 extu.w r0,r0
286263 addc r0,r7
....@@ -295,32 +272,32 @@
295272 clrt
296273 .align 2
297274 1:
298
-SRC( mov.l @r4+,r0 )
299
-SRC( mov.l @r4+,r1 )
275
+EXC( mov.l @r4+,r0 )
276
+EXC( mov.l @r4+,r1 )
300277 addc r0,r7
301
-DST( mov.l r0,@r5 )
302
-DST( mov.l r1,@(4,r5) )
278
+EXC( mov.l r0,@r5 )
279
+EXC( mov.l r1,@(4,r5) )
303280 addc r1,r7
304281
305
-SRC( mov.l @r4+,r0 )
306
-SRC( mov.l @r4+,r1 )
282
+EXC( mov.l @r4+,r0 )
283
+EXC( mov.l @r4+,r1 )
307284 addc r0,r7
308
-DST( mov.l r0,@(8,r5) )
309
-DST( mov.l r1,@(12,r5) )
285
+EXC( mov.l r0,@(8,r5) )
286
+EXC( mov.l r1,@(12,r5) )
310287 addc r1,r7
311288
312
-SRC( mov.l @r4+,r0 )
313
-SRC( mov.l @r4+,r1 )
289
+EXC( mov.l @r4+,r0 )
290
+EXC( mov.l @r4+,r1 )
314291 addc r0,r7
315
-DST( mov.l r0,@(16,r5) )
316
-DST( mov.l r1,@(20,r5) )
292
+EXC( mov.l r0,@(16,r5) )
293
+EXC( mov.l r1,@(20,r5) )
317294 addc r1,r7
318295
319
-SRC( mov.l @r4+,r0 )
320
-SRC( mov.l @r4+,r1 )
296
+EXC( mov.l @r4+,r0 )
297
+EXC( mov.l @r4+,r1 )
321298 addc r0,r7
322
-DST( mov.l r0,@(24,r5) )
323
-DST( mov.l r1,@(28,r5) )
299
+EXC( mov.l r0,@(24,r5) )
300
+EXC( mov.l r1,@(28,r5) )
324301 addc r1,r7
325302 add #32,r5
326303 movt r0
....@@ -338,9 +315,9 @@
338315 clrt
339316 shlr2 r6
340317 3:
341
-SRC( mov.l @r4+,r0 )
318
+EXC( mov.l @r4+,r0 )
342319 addc r0,r7
343
-DST( mov.l r0,@r5 )
320
+EXC( mov.l r0,@r5 )
344321 add #4,r5
345322 movt r0
346323 dt r6
....@@ -356,8 +333,8 @@
356333 mov #2,r1
357334 cmp/hs r1,r6
358335 bf 5f
359
-SRC( mov.w @r4+,r0 )
360
-DST( mov.w r0,@r5 )
336
+EXC( mov.w @r4+,r0 )
337
+EXC( mov.w r0,@r5 )
361338 extu.w r0,r0
362339 add #2,r5
363340 cmp/eq r1,r6
....@@ -366,8 +343,8 @@
366343 shll16 r0
367344 addc r0,r7
368345 5:
369
-SRC( mov.b @r4+,r0 )
370
-DST( mov.b r0,@r5 )
346
+EXC( mov.b @r4+,r0 )
347
+EXC( mov.b r0,@r5 )
371348 extu.b r0,r0
372349 #ifndef __LITTLE_ENDIAN__
373350 shll8 r0
....@@ -376,42 +353,13 @@
376353 mov #0,r0
377354 addc r0,r7
378355 7:
379
-5000:
380356
381357 # Exception handler:
382358 .section .fixup, "ax"
383359
384360 6001:
385
- mov.l @(8,r15),r0 ! src_err_ptr
386
- mov #-EFAULT,r1
387
- mov.l r1,@r0
388
-
389
- ! zero the complete destination - computing the rest
390
- ! is too much work
391
- mov.l @(4,r15),r5 ! dst
392
- mov.l @r15,r6 ! len
393
- mov #0,r7
394
-1: mov.b r7,@r5
395
- dt r6
396
- bf/s 1b
397
- add #1,r5
398
- mov.l 8000f,r0
399
- jmp @r0
400
- nop
401
- .align 2
402
-8000: .long 5000b
403
-
404
-6002:
405
- mov.l @(12,r15),r0 ! dst_err_ptr
406
- mov #-EFAULT,r1
407
- mov.l r1,@r0
408
- mov.l 8001f,r0
409
- jmp @r0
410
- nop
411
- .align 2
412
-8001: .long 5000b
413
-
361
+ rts
362
+ mov #0,r0
414363 .previous
415
- add #8,r15
416364 rts
417365 mov r7,r0