summaryrefslogtreecommitdiffstats
path: root/kernel/arch/avr32/lib/csum_partial.S
blob: 6a262b528eb72ae6bf4bf09d267e4480751c8869 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
 * Copyright (C) 2004-2006 Atmel Corporation
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */

	/*
	 * unsigned int csum_partial(const unsigned char *buff,
	 *			     int len, unsigned int sum)
	 */
	.text
	.global	csum_partial
	.type	csum_partial,"function"
	.align	1
csum_partial:
	/* checksum complete words, aligned or not */
3:	sub	r11, 4
	brlt	5f
4:	ld.w	r9, r12++
	add	r10, r9
	acr	r10
	sub	r11, 4
	brge	4b

	/* return if we had a whole number of words */
5:	sub	r11, -4
	reteq	r10

	/* checksum any remaining bytes at the end */
	mov	r9, 0
	mov	r8, 0
	cp	r11, 2
	brlt	6f
	ld.uh	r9, r12++
	sub	r11, 2
	breq	7f
	lsl	r9, 16
6:	ld.ub	r8, r12++
	lsl	r8, 8
7:	or	r9, r8
	add	r10, r9
	acr	r10

	retal	r10
	.size	csum_partial, . - csum_partial