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