xref: /openbmc/linux/arch/x86/boot/compressed/string.c (revision 4f3db074)
1 #include "../string.c"
2 
3 #ifdef CONFIG_X86_32
4 void *memcpy(void *dest, const void *src, size_t n)
5 {
6 	int d0, d1, d2;
7 	asm volatile(
8 		"rep ; movsl\n\t"
9 		"movl %4,%%ecx\n\t"
10 		"rep ; movsb\n\t"
11 		: "=&c" (d0), "=&D" (d1), "=&S" (d2)
12 		: "0" (n >> 2), "g" (n & 3), "1" (dest), "2" (src)
13 		: "memory");
14 
15 	return dest;
16 }
17 #else
18 void *memcpy(void *dest, const void *src, size_t n)
19 {
20 	long d0, d1, d2;
21 	asm volatile(
22 		"rep ; movsq\n\t"
23 		"movq %4,%%rcx\n\t"
24 		"rep ; movsb\n\t"
25 		: "=&c" (d0), "=&D" (d1), "=&S" (d2)
26 		: "0" (n >> 3), "g" (n & 7), "1" (dest), "2" (src)
27 		: "memory");
28 
29 	return dest;
30 }
31 #endif
32 
33 void *memset(void *s, int c, size_t n)
34 {
35 	int i;
36 	char *ss = s;
37 
38 	for (i = 0; i < n; i++)
39 		ss[i] = c;
40 	return s;
41 }
42