This source file includes following definitions.
- csum_partial
- csum_partial_copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 #include <net/checksum.h>
18 #include <asm/string.h>
19
20
21
22
23
24 unsigned int csum_partial(const unsigned char *buff, int len, unsigned int sum)
25 {
26 unsigned long scratch1;
27 unsigned long scratch2;
28
29
30
31
32
33 __asm__("
34 .set noreorder
35 .set noat
36 andi $1,%5,2 # Check alignment
37 beqz $1,2f # Branch if ok
38 subu $1,%4,2 # delay slot, Alignment uses up two bytes
39 bgez $1,1f # Jump if we had at least two bytes
40 move %4,$1 # delay slot
41 j 4f
42 addiu %4,2 # delay slot; len was < 2. Deal with it
43
44 1: lw %2,(%5)
45 addiu %4,2
46 addu %0,%2
47 sltu $1,%0,%2
48 addu %0,$1
49
50 2: move %1,%4
51 srl %1,%1,5
52 beqz %1,2f
53 sll %1,%1,5 # delay slot
54
55 addu %1,%5
56 1: lw %2,0(%5)
57 addu %5,32
58 addu %0,%2
59 sltu $1,%0,%2
60
61 lw %2,-28(%5)
62 addu %0,$1
63 addu %0,%2
64 sltu $1,%0,%2
65
66 lw %2,-24(%5)
67 addu %0,$1
68 addu %0,%2
69 sltu $1,%0,%2
70
71 lw %2,-20(%5)
72 addu %0,$1
73 addu %0,%2
74 sltu $1,%0,%2
75
76 lw %2,-16(%5)
77 addu %0,$1
78 addu %0,%2
79 sltu $1,%0,%2
80
81 lw %2,-12(%5)
82 addu %0,$1
83 addu %0,%2
84 sltu $1,%0,%2
85
86 lw %2,-8(%5)
87 addu %0,$1
88 addu %0,%2
89 sltu $1,%0,%2
90
91 lw %2,-4(%5)
92 addu %0,$1
93 addu %0,%2
94 sltu $1,%0,%2
95
96 bne %5,%1,1b
97 addu %0,$1 # delay slot
98
99 2: andi %1,%4,0x1c
100 srl %1,%1,2
101 beqz %1,4f
102 addu %1,%5 # delay slot
103 3: lw %2,0(%5)
104 addu %5,4
105 addu %0,%2
106 sltu $1,%0,%2
107 bne %5,%1,3b
108 addu %0,$1 # delay slot
109
110 4: andi $1,%3,2
111 beqz $1,5f
112 move %2,$0 # delay slot
113 lhu %2,(%5)
114 addiu %5,2
115
116 5: andi $1,%3,1
117 beqz $1,6f
118 sll %1,16 # delay slot
119 lbu %1,(%5)
120 nop # NOP ALERT (spit, gasp)
121 6: or %2,%1
122 addu %0,%2
123 sltu $1,%0,%2
124 addu %0,$1
125 7: .set at
126 .set reorder"
127 : "=r"(sum), "=r" (scratch1), "=r" (scratch2)
128 : "0"(sum), "r"(len), "r"(buff)
129 : "$1");
130
131 return sum;
132 }
133
134
135
136
137 unsigned int csum_partial_copy(const char *src, char *dst,
138 int len, int sum)
139 {
140
141
142
143
144 sum = csum_partial(src, len, sum);
145 memcpy(dst, src, len);
146
147 return sum;
148 }