arch/sparc/lib/checksum_64.S

Source file repositories/reference/linux-study-clean/arch/sparc/lib/checksum_64.S

File Facts

System
Linux kernel
Corpus path
arch/sparc/lib/checksum_64.S
Extension
.S
Size
3986 bytes
Lines
178
Domain
Architecture Layer
Bucket
arch/sparc
Inferred role
Architecture Layer: exported/initcall integration point
Status
integration implementation candidate

Why This File Exists

CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.

Dependency Surface

Detected Declarations

Annotated Snippet

#include <linux/export.h>
	.text

csum_partial_fix_alignment:
	/* We checked for zero length already, so there must be
	 * at least one byte.
	 */
	be,pt		%icc, 1f
	 nop
	ldub		[%o0 + 0x00], %o4
	add		%o0, 1, %o0
	sub		%o1, 1, %o1
1:	andcc		%o0, 0x2, %g0
	be,pn		%icc, csum_partial_post_align
	 cmp		%o1, 2
	blu,pn		%icc, csum_partial_end_cruft
	 nop
	lduh		[%o0 + 0x00], %o5
	add		%o0, 2, %o0
	sub		%o1, 2, %o1
	ba,pt		%xcc, csum_partial_post_align
	 add		%o5, %o4, %o4

	.align		32
	.globl		csum_partial
	.type		csum_partial,#function
	EXPORT_SYMBOL(csum_partial)
csum_partial:		/* %o0=buff, %o1=len, %o2=sum */
	prefetch	[%o0 + 0x000], #n_reads
	clr		%o4
	prefetch	[%o0 + 0x040], #n_reads
	brz,pn		%o1, csum_partial_finish
	 andcc		%o0, 0x3, %g0

	/* We "remember" whether the lowest bit in the address
	 * was set in %g7.  Because if it is, we have to swap
	 * upper and lower 8 bit fields of the sum we calculate.
	*/
	bne,pn		%icc, csum_partial_fix_alignment
	 andcc		%o0, 0x1, %g7

csum_partial_post_align:
	prefetch	[%o0 + 0x080], #n_reads
	andncc		%o1, 0x3f, %o3

	prefetch	[%o0 + 0x0c0], #n_reads
	sub		%o1, %o3, %o1
	brz,pn		%o3, 2f
	 prefetch	[%o0 + 0x100], #n_reads

	/* So that we don't need to use the non-pairing
	 * add-with-carry instructions we accumulate 32-bit
	 * values into a 64-bit register.  At the end of the
	 * loop we fold it down to 32-bits and so on.
	 */
	prefetch	[%o0 + 0x140], #n_reads
1:	lduw		[%o0 + 0x00], %o5
	lduw		[%o0 + 0x04], %g1
	lduw		[%o0 + 0x08], %g2
	add		%o4, %o5, %o4
	lduw		[%o0 + 0x0c], %g3
	add		%o4, %g1, %o4
	lduw		[%o0 + 0x10], %o5
	add		%o4, %g2, %o4
	lduw		[%o0 + 0x14], %g1
	add		%o4, %g3, %o4
	lduw		[%o0 + 0x18], %g2
	add		%o4, %o5, %o4
	lduw		[%o0 + 0x1c], %g3
	add		%o4, %g1, %o4

Annotation

Implementation Notes