remove xen support
[unleashed.git] / usr / src / common / crypto / arcfour / sun4u / arcfour_crypt_asm.s
blob0e61862bfa19259b5960e499b26e58d0062e50d7
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
27 .register %g2,#scratch
28 .register %g3,#scratch
30 .section ".text",#alloc,#execinstr
31 .file "arcfour_crypt_asm.s"
33 .section ".text",#alloc
34 .align 32
36 .section ".text",#alloc,#execinstr
37 .align 32
38 .skip 32
41 * SUBROUTINE arcfour_crypt_aligned
43 * void arcfour_crypt_aligned(ARCFour_key *key, size_t len,
44 * uchar_t *in, uchar_t *out);
46 * in and out should be aligned on an 8-byte boundary, but len can be anything
48 .global arcfour_crypt_aligned
51 arcfour_crypt_aligned:
52 save %sp,-144,%sp
54 srl %i1, 3, %l7
55 ldub [%i0+256], %g1
57 orcc %l7, %g0, %g0
58 ldub [%i0+257], %g2
60 add %g1, 1, %o1
61 bz %icc, .Loop2
62 add %i0, 0, %i5
64 add %o1, 1, %g1
65 and %o1, 255, %o1
67 and %g1, 255, %g1
68 ldub [%i5 + %o1], %o3
70 ldub [%i5 + %g1], %g3
72 add %g2, %o3, %o2
74 add %o2, %g3, %g2
75 and %o2, 255, %o2
77 and %g2, 255, %g2
78 ldub [%i5 + %o2], %o4
80 stb %o3, [%i5+%o2]
81 subcc %o2, %g1, %g0
83 stb %o4, [%i5 + %o1]
84 bz %icc, .L1A
85 add %o3,%o4,%o5
86 .L1B:
87 and %o5, 255, %o5
88 ldub [%i5 + %g2], %g4
90 ldub [%i5 + %o5], %o5
91 add %g1, 1, %o1
93 and %o1, 255, %o1
94 stb %g3, [%i5 + %g2]
95 add %g3, %g4, %g5
97 and %g5, 255, %g5
98 stb %g4, [%i5 + %g1]
99 add %o1, 1, %g1
102 sllx %o5, 56, %o0
103 ldub [%i5 + %o1], %o3
104 and %g1, 255, %g1
106 ldub [%i5 + %g1], %g3
108 add %g2, %o3, %o2
109 ldub [%i5 + %g5], %g5
111 add %o2, %g3, %g2
112 and %o2, 255, %o2
114 sllx %g5, 48, %g5
115 ldub [%i5 + %o2], %o4
116 and %g2, 255, %g2
118 or %o0, %g5, %o0
119 stb %o3, [%i5+%o2]
120 subcc %o2, %g1, %g0
122 stb %o4, [%i5 + %o1]
123 bz %icc, .L2A
124 add %o3,%o4,%o5
125 .L2B:
126 and %o5, 255, %o5
127 ldub [%i5 + %g2], %g4
129 ldub [%i5 + %o5], %o5
130 add %g1, 1, %o1
132 and %o1, 255, %o1
133 stb %g3, [%i5 + %g2]
134 add %g3, %g4, %g5
136 and %g5, 255, %g5
137 stb %g4, [%i5 + %g1]
138 add %o1, 1, %g1
141 sllx %o5, 40, %o5
142 ldub [%i5 + %o1], %o3
143 and %g1, 255, %g1
145 ldub [%i5 + %g1], %g3
146 or %o0, %o5, %o0
148 add %g2, %o3, %o2
149 ldub [%i5 + %g5], %g5
151 add %o2, %g3, %g2
152 and %o2, 255, %o2
154 sllx %g5, 32, %g5
155 ldub [%i5 + %o2], %o4
156 and %g2, 255, %g2
158 or %o0, %g5, %o0
159 stb %o3, [%i5+%o2]
160 subcc %o2, %g1, %g0
162 stb %o4, [%i5 + %o1]
163 bz %icc, .L3A
164 add %o3,%o4,%o5
165 .L3B:
166 and %o5, 255, %o5
167 ldub [%i5 + %g2], %g4
169 ldub [%i5 + %o5], %o5
170 add %g1, 1, %o1
172 and %o1, 255, %o1
173 stb %g3, [%i5 + %g2]
174 add %g3, %g4, %g5
176 and %g5, 255, %g5
177 stb %g4, [%i5 + %g1]
178 add %o1, 1, %g1
181 sll %o5, 24, %o5
182 ldub [%i5 + %o1], %o3
183 and %g1, 255, %g1
185 sub %i1, 8, %i1
186 ldub [%i5 + %g1], %g3
187 or %o0, %o5, %o0
189 srl %i1, 3, %l7
190 ldub [%i5 + %g5], %g5
191 add %g2, %o3, %o2
193 add %o2, %g3, %g2
194 and %o2, 255, %o2
196 sll %g5, 16, %g5
197 ldub [%i5 + %o2], %o4
198 and %g2, 255, %g2
200 or %o0, %g5, %o0
201 stb %o3, [%i5+%o2]
202 subcc %o2, %g1, %g0
204 stb %o4, [%i5 + %o1]
205 bz %icc, .L4A
206 add %o3,%o4,%o5
207 .L4B:
208 and %o5, 255, %o5
209 ldub [%i5 + %g2], %g4
210 add %g1, 1, %o1
212 orcc %l7, %g0, %g0
213 ldub [%i5 + %o5], %o5
214 and %o1, 255, %o1
216 add %g3, %g4, %g5
217 stb %g4, [%i5 + %g1]
218 add %o1, 1, %g1
220 stb %g3, [%i5 + %g2]
221 bz %icc, .EndLoop1
222 and %g5, 255, %g5
225 .Loop1:
226 sll %o5, 8, %o5
227 ldub [%i5 + %o1], %o3
228 and %g1, 255, %g1
230 ldub [%i5 + %g1], %g3
231 or %o0, %o5, %o0
233 ldub [%i5 + %g5], %g5
234 add %g2, %o3, %o2
236 add %o2, %g3, %g2
237 ldx [%i2], %o7
238 and %o2, 255, %o2
240 and %g2, 255, %g2
241 ldub [%i5 + %o2], %o4
243 or %o0, %g5, %o0
244 stb %o3, [%i5+%o2]
245 subcc %o2, %g1, %g0
247 stb %o4, [%i5 + %o1]
248 bz %icc, .L5A
249 add %o3,%o4,%o5
250 .L5B:
251 and %o5, 255, %o5
252 ldub [%i5 + %g2], %g4
254 ldub [%i5 + %o5], %o5
255 add %g1, 1, %o1
257 and %o1, 255, %o1
258 stb %g3, [%i5 + %g2]
259 add %g3, %g4, %g5
261 and %g5, 255, %g5
262 stb %g4, [%i5 + %g1]
263 add %o1, 1, %g1
266 xor %o0, %o7, %o7
267 ldub [%i5 + %o1], %o3
268 and %g1, 255, %g1
270 sllx %o5, 56, %o0
271 ldub [%i5 + %g1], %g3
273 add %g2, %o3, %o2
274 ldub [%i5 + %g5], %g5
276 add %o2, %g3, %g2
277 stx %o7, [%i3]
278 and %o2, 255, %o2
280 sllx %g5, 48, %g5
281 ldub [%i5 + %o2], %o4
282 and %g2, 255, %g2
284 or %o0, %g5, %o0
285 stb %o3, [%i5+%o2]
286 subcc %o2, %g1, %g0
288 stb %o4, [%i5 + %o1]
289 bz %icc, .L6A
290 add %o3,%o4,%o5
291 .L6B:
292 and %o5, 255, %o5
293 ldub [%i5 + %g2], %g4
294 add %i3, 8, %i3
296 add %i2, 8, %i2
297 ldub [%i5 + %o5], %o5
298 add %g1, 1, %o1
300 and %o1, 255, %o1
301 stb %g3, [%i5 + %g2]
302 add %g3, %g4, %g5
304 and %g5, 255, %g5
305 stb %g4, [%i5 + %g1]
306 add %o1, 1, %g1
309 sllx %o5, 40, %o5
310 ldub [%i5 + %o1], %o3
311 and %g1, 255, %g1
313 ldub [%i5 + %g1], %g3
314 or %o0, %o5, %o0
316 add %g2, %o3, %o2
317 ldub [%i5 + %g5], %g5
319 add %o2, %g3, %g2
320 and %o2, 255, %o2
322 sllx %g5, 32, %g5
323 ldub [%i5 + %o2], %o4
324 and %g2, 255, %g2
326 or %o0, %g5, %o0
327 stb %o3, [%i5 + %o2]
328 subcc %o2, %g1, %g0
330 stb %o4, [%i5 + %o1]
331 bz %icc, .L7A
332 add %o3,%o4,%o5
333 .L7B:
334 and %o5, 255, %o5
335 ldub [%i5 + %g2], %g4
337 ldub [%i5 + %o5], %o5
338 add %g1, 1, %o1
340 and %o1, 255, %o1
341 stb %g3, [%i5 + %g2]
342 add %g3, %g4, %g5
344 and %g5, 255, %g5
345 stb %g4, [%i5 + %g1]
346 add %o1, 1, %g1
349 sll %o5, 24, %o5
350 ldub [%i5 + %o1], %o3
351 and %g1, 255, %g1
353 sub %i1, 8, %i1
354 ldub [%i5 + %g1], %g3
355 or %o0, %o5, %o0
357 srl %i1, 3, %l7
358 ldub [%i5 + %g5], %g5
359 add %g2, %o3, %o2
361 add %o2, %g3, %g2
362 and %o2, 255, %o2
364 sll %g5, 16, %g5
365 ldub [%i5 + %o2], %o4
366 and %g2, 255, %g2
368 or %o0, %g5, %o0
369 stb %o3, [%i5 + %o2]
370 subcc %o2, %g1, %g0
372 stb %o4, [%i5 + %o1]
373 bz %icc, .L8A
374 add %o3,%o4,%o5
375 .L8B:
376 and %o5, 255, %o5
377 ldub [%i5 + %g2], %g4
378 add %g1, 1, %o1
380 orcc %l7, %g0, %g0
381 ldub [%i5 + %o5], %o5
382 and %o1, 255, %o1
384 add %g3, %g4, %g5
385 stb %g4, [%i5 + %g1]
386 add %o1, 1, %g1
388 stb %g3, [%i5 + %g2]
389 bnz %icc, .Loop1
390 and %g5, 255, %g5
393 .EndLoop1:
394 sll %o5, 8, %o5
395 ldub [%i5 + %g5], %g5
396 orcc %i1, %g0, %g0
398 or %o0, %o5, %o0
399 ldx [%i2], %o7
400 sub %g1, 2, %g1
402 and %g1, 255, %g1
403 stb %g1, [%i0 + 256]
404 or %o0, %g5, %o0
406 xor %o0, %o7, %o7
407 stx %o7, [%i3]
408 add %i2, 8, %i2
410 add %i3, 8, %i3
411 bnz %icc, .Loop2_1
412 stb %g2, [%i0 + 257]
415 restore %g0,%g0,%g0
418 .Loop2:
419 orcc %i1, %g0, %g0
420 bnz .Loop2_1
423 restore %g0,%g0,%g0
425 .Loop2_1:
426 and %o1, 255, %g1
427 ldub [%i5 + %g1], %g3
429 add %g2, %g3, %g2
431 and %g2, 255, %g2
433 ldub [%i5 + %g2], %g4
435 stb %g3, [%i5 + %g2]
437 add %g3, %g4, %g5
438 stb %g4, [%i5 + %g1]
440 and %g5, 255, %g5
441 ldub [%i2], %o0
443 add %g1, 1, %o1
444 ldub [%i5 + %g5], %g5
445 subcc %i1, 1, %i1
447 add %i2, 1, %i2
448 add %i3, 1, %i3
450 xor %o0, %g5, %o0
451 bnz %icc, .Loop2_1
452 stb %o0, [%i3 - 1]
454 stb %g1, [%i0 + 256]
456 stb %g2, [%i0 + 257]
459 restore %g0,%g0,%g0
461 .L1A:
462 add %o2, %o3, %g2
463 or %o3, %g0, %g3
464 ba .L1B
465 and %g2, 255, %g2
467 .L2A:
468 add %o2, %o3, %g2
469 or %o3, %g0, %g3
470 ba .L2B
471 and %g2, 255, %g2
473 .L3A:
474 add %o2, %o3, %g2
475 or %o3, %g0, %g3
476 ba .L3B
477 and %g2, 255, %g2
479 .L4A:
480 add %o2, %o3, %g2
481 or %o3, %g0, %g3
482 ba .L4B
483 and %g2, 255, %g2
485 .L5A:
486 add %o2, %o3, %g2
487 or %o3, %g0, %g3
488 ba .L5B
489 and %g2, 255, %g2
491 .L6A:
492 add %o2, %o3, %g2
493 or %o3, %g0, %g3
494 ba .L6B
495 and %g2, 255, %g2
497 .L7A:
498 add %o2, %o3, %g2
499 or %o3, %g0, %g3
500 ba .L7B
501 and %g2, 255, %g2
503 .L8A:
504 add %o2, %o3, %g2
505 or %o3, %g0, %g3
506 ba .L8B
507 and %g2, 255, %g2
509 .type arcfour_crypt_aligned,2
510 .size arcfour_crypt_aligned,(. - arcfour_crypt_aligned)