aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-mips/checksum.h
diff options
context:
space:
mode:
authorThiemo Seufer <ths@networkno.de>2005-07-08 05:17:05 -0400
committerRalf Baechle <ralf@linux-mips.org>2005-10-29 14:31:40 -0400
commit04988d6fda5c1cc670bd4c4d563b3443cf7ccce7 (patch)
treedc3ead52d31bb9014f1f8ebea75525364d699b15 /include/asm-mips/checksum.h
parent9556ac2fa1b16ec702e200fc558636a09a50f0e0 (diff)
Protect noat assembly with .set push/pop and make it somewhat readable.
Signed-off-by: Ralf Baechle <ralf@linux-mips.org> Signed-off-by: Thiemo Seufer <ths@networkno.de>
Diffstat (limited to 'include/asm-mips/checksum.h')
-rw-r--r--include/asm-mips/checksum.h154
1 files changed, 78 insertions, 76 deletions
diff --git a/include/asm-mips/checksum.h b/include/asm-mips/checksum.h
index 436d26cd6f6f..2ff53db8c023 100644
--- a/include/asm-mips/checksum.h
+++ b/include/asm-mips/checksum.h
@@ -71,14 +71,15 @@ unsigned int csum_partial_copy_nocheck(const unsigned char *src, unsigned char *
71static inline unsigned short int csum_fold(unsigned int sum) 71static inline unsigned short int csum_fold(unsigned int sum)
72{ 72{
73 __asm__( 73 __asm__(
74 ".set\tnoat\t\t\t# csum_fold\n\t" 74 " .set push # csum_fold\n"
75 "sll\t$1,%0,16\n\t" 75 " .set noat \n"
76 "addu\t%0,$1\n\t" 76 " sll $1, %0, 16 \n"
77 "sltu\t$1,%0,$1\n\t" 77 " addu %0, $1 \n"
78 "srl\t%0,%0,16\n\t" 78 " sltu $1, %0, $1 \n"
79 "addu\t%0,$1\n\t" 79 " srl %0, %0, 16 \n"
80 "xori\t%0,0xffff\n\t" 80 " addu %0, $1 \n"
81 ".set\tat" 81 " xori %0, 0xffff \n"
82 " .set pop"
82 : "=r" (sum) 83 : "=r" (sum)
83 : "0" (sum)); 84 : "0" (sum));
84 85
@@ -128,29 +129,30 @@ static inline unsigned int csum_tcpudp_nofold(unsigned long saddr,
128 unsigned int sum) 129 unsigned int sum)
129{ 130{
130 __asm__( 131 __asm__(
131 ".set\tnoat\t\t\t# csum_tcpudp_nofold\n\t" 132 " .set push # csum_tcpudp_nofold\n"
133 " .set noat \n"
132#ifdef CONFIG_32BIT 134#ifdef CONFIG_32BIT
133 "addu\t%0, %2\n\t" 135 " addu %0, %2 \n"
134 "sltu\t$1, %0, %2\n\t" 136 " sltu $1, %0, %2 \n"
135 "addu\t%0, $1\n\t" 137 " addu %0, $1 \n"
136 138
137 "addu\t%0, %3\n\t" 139 " addu %0, %3 \n"
138 "sltu\t$1, %0, %3\n\t" 140 " sltu $1, %0, %3 \n"
139 "addu\t%0, $1\n\t" 141 " addu %0, $1 \n"
140 142
141 "addu\t%0, %4\n\t" 143 " addu %0, %4 \n"
142 "sltu\t$1, %0, %4\n\t" 144 " sltu $1, %0, %4 \n"
143 "addu\t%0, $1\n\t" 145 " addu %0, $1 \n"
144#endif 146#endif
145#ifdef CONFIG_64BIT 147#ifdef CONFIG_64BIT
146 "daddu\t%0, %2\n\t" 148 " daddu %0, %2 \n"
147 "daddu\t%0, %3\n\t" 149 " daddu %0, %3 \n"
148 "daddu\t%0, %4\n\t" 150 " daddu %0, %4 \n"
149 "dsll32\t$1, %0, 0\n\t" 151 " dsll32 $1, %0, 0 \n"
150 "daddu\t%0, $1\n\t" 152 " daddu %0, $1 \n"
151 "dsrl32\t%0, %0, 0\n\t" 153 " dsrl32 %0, %0, 0 \n"
152#endif 154#endif
153 ".set\tat" 155 " .set pop"
154 : "=r" (sum) 156 : "=r" (sum)
155 : "0" (daddr), "r"(saddr), 157 : "0" (daddr), "r"(saddr),
156#ifdef __MIPSEL__ 158#ifdef __MIPSEL__
@@ -193,57 +195,57 @@ static __inline__ unsigned short int csum_ipv6_magic(struct in6_addr *saddr,
193 unsigned int sum) 195 unsigned int sum)
194{ 196{
195 __asm__( 197 __asm__(
196 ".set\tpush\t\t\t# csum_ipv6_magic\n\t" 198 " .set push # csum_ipv6_magic\n"
197 ".set\tnoreorder\n\t" 199 " .set noreorder \n"
198 ".set\tnoat\n\t" 200 " .set noat \n"
199 "addu\t%0, %5\t\t\t# proto (long in network byte order)\n\t" 201 " addu %0, %5 # proto (long in network byte order)\n"
200 "sltu\t$1, %0, %5\n\t" 202 " sltu $1, %0, %5 \n"
201 "addu\t%0, $1\n\t" 203 " addu %0, $1 \n"
202 204
203 "addu\t%0, %6\t\t\t# csum\n\t" 205 " addu %0, %6 # csum\n"
204 "sltu\t$1, %0, %6\n\t" 206 " sltu $1, %0, %6 \n"
205 "lw\t%1, 0(%2)\t\t\t# four words source address\n\t" 207 " lw %1, 0(%2) # four words source address\n"
206 "addu\t%0, $1\n\t" 208 " addu %0, $1 \n"
207 "addu\t%0, %1\n\t" 209 " addu %0, %1 \n"
208 "sltu\t$1, %0, %1\n\t" 210 " sltu $1, %0, %1 \n"
209 211
210 "lw\t%1, 4(%2)\n\t" 212 " lw %1, 4(%2) \n"
211 "addu\t%0, $1\n\t" 213 " addu %0, $1 \n"
212 "addu\t%0, %1\n\t" 214 " addu %0, %1 \n"
213 "sltu\t$1, %0, %1\n\t" 215 " sltu $1, %0, %1 \n"
214 216
215 "lw\t%1, 8(%2)\n\t" 217 " lw %1, 8(%2) \n"
216 "addu\t%0, $1\n\t" 218 " addu %0, $1 \n"
217 "addu\t%0, %1\n\t" 219 " addu %0, %1 \n"
218 "sltu\t$1, %0, %1\n\t" 220 " sltu $1, %0, %1 \n"
219 221
220 "lw\t%1, 12(%2)\n\t" 222 " lw %1, 12(%2) \n"
221 "addu\t%0, $1\n\t" 223 " addu %0, $1 \n"
222 "addu\t%0, %1\n\t" 224 " addu %0, %1 \n"
223 "sltu\t$1, %0, %1\n\t" 225 " sltu $1, %0, %1 \n"
224 226
225 "lw\t%1, 0(%3)\n\t" 227 " lw %1, 0(%3) \n"
226 "addu\t%0, $1\n\t" 228 " addu %0, $1 \n"
227 "addu\t%0, %1\n\t" 229 " addu %0, %1 \n"
228 "sltu\t$1, %0, %1\n\t" 230 " sltu $1, %0, %1 \n"
229 231
230 "lw\t%1, 4(%3)\n\t" 232 " lw %1, 4(%3) \n"
231 "addu\t%0, $1\n\t" 233 " addu %0, $1 \n"
232 "addu\t%0, %1\n\t" 234 " addu %0, %1 \n"
233 "sltu\t$1, %0, %1\n\t" 235 " sltu $1, %0, %1 \n"
234 236
235 "lw\t%1, 8(%3)\n\t" 237 " lw %1, 8(%3) \n"
236 "addu\t%0, $1\n\t" 238 " addu %0, $1 \n"
237 "addu\t%0, %1\n\t" 239 " addu %0, %1 \n"
238 "sltu\t$1, %0, %1\n\t" 240 " sltu $1, %0, %1 \n"
239 241
240 "lw\t%1, 12(%3)\n\t" 242 " lw %1, 12(%3) \n"
241 "addu\t%0, $1\n\t" 243 " addu %0, $1 \n"
242 "addu\t%0, %1\n\t" 244 " addu %0, %1 \n"
243 "sltu\t$1, %0, %1\n\t" 245 " sltu $1, %0, %1 \n"
244 246
245 "addu\t%0, $1\t\t\t# Add final carry\n\t" 247 " addu %0, $1 # Add final carry\n"
246 ".set\tpop" 248 " .set pop"
247 : "=r" (sum), "=r" (proto) 249 : "=r" (sum), "=r" (proto)
248 : "r" (saddr), "r" (daddr), 250 : "r" (saddr), "r" (daddr),
249 "0" (htonl(len)), "1" (htonl(proto)), "r" (sum)); 251 "0" (htonl(len)), "1" (htonl(proto)), "r" (sum));