diff options
Diffstat (limited to 'arch/x86/boot/compressed/string.c')
-rw-r--r-- | arch/x86/boot/compressed/string.c | 46 |
1 files changed, 40 insertions, 6 deletions
diff --git a/arch/x86/boot/compressed/string.c b/arch/x86/boot/compressed/string.c index ffb9c5c9d748..f3c57e341402 100644 --- a/arch/x86/boot/compressed/string.c +++ b/arch/x86/boot/compressed/string.c | |||
@@ -1,11 +1,45 @@ | |||
1 | #include "misc.h" | 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 | ||
2 | 6 | ||
3 | int memcmp(const void *s1, const void *s2, size_t len) | 7 | #ifdef CONFIG_X86_32 |
8 | void *memcpy(void *dest, const void *src, size_t n) | ||
4 | { | 9 | { |
5 | u8 diff; | 10 | int d0, d1, d2; |
6 | asm("repe; cmpsb; setnz %0" | 11 | asm volatile( |
7 | : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len)); | 12 | "rep ; movsl\n\t" |
8 | return diff; | 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; | ||
9 | } | 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"); | ||
10 | 32 | ||
11 | #include "../string.c" | 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 | } | ||