arch/s390/lib/string.c

Source file repositories/reference/linux-study-clean/arch/s390/lib/string.c

File Facts

System
Linux kernel
Corpus path
arch/s390/lib/string.c
Extension
.c
Size
9417 bytes
Lines
486
Domain
Architecture Layer
Bucket
arch/s390
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

while (n >= 256) {
			asm volatile(
				"	mvc	0(256,%[d]),0(%[s])\n"
				:
				: [d] "a" (d), [s] "a" (s)
				: "memory");
			d += 256;
			s += 256;
			n -= 256;
		}
		if (n) {
			asm volatile(
				"	exrl	%[n],0f\n"
				"	j	1f\n"
				"0:	mvc	0(1,%[d]),0(%[s])\n"
				"1:"
				:
				: [d] "a" (d), [s] "a" (s), [n] "a" (n - 1)
				: "memory");
		}
		return dest;
	}
	/* Backward copy */
	if (test_facility(61)) {
		/* Use mvcrl instruction if available */
		while (n >= 256) {
			asm volatile(
				"	lghi	%%r0,255\n"
				"	.insn	sse,0xe50a00000000,%[d],%[s]\n"
				: [d] "=Q" (*(d + n - 256))
				: [s] "Q" (*(s + n - 256))
				: "0", "memory");
			n -= 256;
		}
		if (n) {
			asm volatile(
				"	lgr	%%r0,%[n]\n"
				"	.insn	sse,0xe50a00000000,%[d],%[s]\n"
				: [d] "=Q" (*d)
				: [s] "Q" (*s), [n] "d" (n - 1)
				: "0", "memory");
		}
	} else {
		while (n--)
			d[n] = s[n];
	}
	return dest;
}
SYMBOL_FUNCTION_ALIAS(memmove, __memmove);
EXPORT_SYMBOL(__memmove);
EXPORT_SYMBOL(memmove);
#endif

#ifdef __HAVE_ARCH_MEMSET
noinstr void *__memset(void *s, int c, size_t n)
{
	char *xs = s;

	if (!n)
		return s;
	if (!c) {
		/* Clear memory */
		while (n >= 256) {
			asm volatile(
				"	xc	 0(256,%[xs]),0(%[xs])"
				:
				: [xs] "a" (xs)
				: "cc", "memory");
			xs += 256;
			n -= 256;
		}
		if (!n)
			return s;
		asm volatile(
			"	exrl	%[n],0f\n"
			"	j	1f\n"
			"0:	xc	0(1,%[xs]),0(%[xs])\n"
			"1:"
			:
			: [xs] "a" (xs), [n] "a" (n - 1)
			: "cc", "memory");
	} else {
		/* Fill memory */
		while (n >= 256) {
			*xs = c;
			asm volatile(
				"	mvc	1(255,%[xs]),0(%[xs])"
				:
				: [xs] "a" (xs)
				: "memory");

Annotation

Implementation Notes