2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
6 * Quick'n'dirty IP checksum ...
8 * Copyright (C) 1998, 1999 Ralf Baechle
9 * Copyright (C) 1999 Silicon Graphics, Inc.
12 #include <asm/regdef.h>
16 * As we are sharing code base with the mips32 tree (which use the o32 ABI
17 * register definitions). We need to redefine the register definitions from
18 * the n64 ABI register naming to the o32 ABI register naming.
48 #endif /* USE_DOUBLE */
50 #define UNIT(unit) ((unit)*NBYTES)
52 #define ADDC(sum,reg) \
57 #define CSUM_BIGCHUNK1(src, offset, sum, _t0, _t1, _t2, _t3) \
58 LOAD _t0, (offset + UNIT(0))(src); \
59 LOAD _t1, (offset + UNIT(1))(src); \
60 LOAD _t2, (offset + UNIT(2))(src); \
61 LOAD _t3, (offset + UNIT(3))(src); \
68 #define CSUM_BIGCHUNK(src, offset, sum, _t0, _t1, _t2, _t3) \
69 CSUM_BIGCHUNK1(src, offset, sum, _t0, _t1, _t2, _t3)
71 #define CSUM_BIGCHUNK(src, offset, sum, _t0, _t1, _t2, _t3) \
72 CSUM_BIGCHUNK1(src, offset, sum, _t0, _t1, _t2, _t3); \
73 CSUM_BIGCHUNK1(src, offset + 0x10, sum, _t0, _t1, _t2, _t3)
78 * a1: length of the area to checksum
79 * a2: partial checksum
93 bnez t8, small_csumcpy /* < 8 bytes to copy */
96 andi t7, src, 0x1 /* odd buffer? */
103 LONG_SUBU a1, a1, 0x1
108 PTR_ADDU src, src, 0x1
116 LONG_SUBU a1, a1, 0x2
119 PTR_ADDU src, src, 0x2
122 bnez t8, do_end_words
130 LONG_SUBU a1, a1, 0x4
132 PTR_ADDU src, src, 0x4
141 LONG_SUBU a1, a1, 0x8
146 LONG_SUBU a1, a1, 0x8
150 PTR_ADDU src, src, 0x8
154 beqz t8, begin_movement
163 CSUM_BIGCHUNK1(src, 0x00, sum, t0, t1, t3, t4)
165 LONG_SUBU a1, a1, 0x10
166 PTR_ADDU src, src, 0x10
174 CSUM_BIGCHUNK(src, 0x00, sum, t0, t1, t3, t4)
175 CSUM_BIGCHUNK(src, 0x20, sum, t0, t1, t3, t4)
176 CSUM_BIGCHUNK(src, 0x40, sum, t0, t1, t3, t4)
177 CSUM_BIGCHUNK(src, 0x60, sum, t0, t1, t3, t4)
178 LONG_SUBU t8, t8, 0x01
179 bnez t8, move_128bytes
180 PTR_ADDU src, src, 0x80
187 CSUM_BIGCHUNK(src, 0x00, sum, t0, t1, t3, t4)
188 CSUM_BIGCHUNK(src, 0x20, sum, t0, t1, t3, t4)
189 PTR_ADDU src, src, 0x40
192 beqz t2, do_end_words
196 CSUM_BIGCHUNK(src, 0x00, sum, t0, t1, t3, t4)
198 PTR_ADDU src, src, 0x20
201 beqz t8, small_csumcpy
207 LONG_SUBU t8, t8, 0x1
210 PTR_ADDU src, src, 0x4
212 /* unknown src alignment and < 8 bytes to go */
220 /* Still a full word to go */
229 /* Still a halfword to go */
260 /* odd buffer alignment? */
269 /* Add the passed partial csum. */