arch/sparc/lib/memscan_64.S

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

File Facts

System
Linux kernel
Corpus path
arch/sparc/lib/memscan_64.S
Extension
.S
Size
2492 bytes
Lines
137
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>

#define HI_MAGIC	0x8080808080808080
#define LO_MAGIC	0x0101010101010101
#define ASI_PL		0x88

	.text
	.align	32
	.globl		__memscan_zero, __memscan_generic
	.type		__memscan_zero,#function
	.type		__memscan_generic,#function
	.globl		memscan
	EXPORT_SYMBOL(__memscan_zero)
	EXPORT_SYMBOL(__memscan_generic)

__memscan_zero:
	/* %o0 = bufp, %o1 = size */
	brlez,pn	%o1, szzero
	 andcc		%o0, 7, %g0
	be,pt		%icc, we_are_aligned
	 sethi		%hi(HI_MAGIC), %o4
	ldub		[%o0], %o5
1:	subcc		%o1, 1, %o1
	brz,pn		%o5, 10f
	 add		%o0, 1, %o0

	be,pn		%xcc, szzero
	 andcc		%o0, 7, %g0
	bne,a,pn	%icc, 1b
	 ldub		[%o0], %o5
we_are_aligned:
	ldxa		[%o0] ASI_PL, %o5
	or		%o4, %lo(HI_MAGIC), %o3
	sllx		%o3, 32, %o4
	or		%o4, %o3, %o3

	srlx		%o3, 7, %o2
msloop:
	sub		%o1, 8, %o1
	add		%o0, 8, %o0
	sub		%o5, %o2, %o4
	xor		%o4, %o5, %o4
	andcc		%o4, %o3, %g3
	bne,pn		%xcc, check_bytes
	 srlx		%o4, 32, %g3

	brgz,a,pt	%o1, msloop
	 ldxa		[%o0] ASI_PL, %o5
check_bytes:
	bne,a,pn	%icc, 2f
	 andcc		%o5, 0xff, %g0
	add		%o0, -5, %g2
	ba,pt		%xcc, 3f
	 srlx		%o5, 32, %g7

2:	srlx		%o5, 8, %g7
	be,pn		%icc, 1f
	 add		%o0, -8, %g2
	andcc		%g7, 0xff, %g0
	srlx		%g7, 8, %g7
	be,pn		%icc, 1f
	 inc		%g2
	andcc		%g7, 0xff, %g0

	srlx		%g7, 8, %g7
	be,pn		%icc, 1f
	 inc		%g2
	andcc		%g7, 0xff, %g0
	srlx		%g7, 8, %g7
	be,pn		%icc, 1f

Annotation

Implementation Notes